@rubytech/taskmaster 1.19.1 → 1.19.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,23 @@
1
- var ju=Object.defineProperty;var Gu=(e,t,n)=>t in e?ju(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var q=(e,t,n)=>Gu(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const Vu="modulepreload",Qu=function(e,t){return new URL(e,t).href},ar={},ae=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let c=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};const a=document.getElementsByTagName("link"),r=document.querySelector("meta[property=csp-nonce]"),u=(r==null?void 0:r.nonce)||(r==null?void 0:r.getAttribute("nonce"));s=c(n.map(h=>{if(h=Qu(h,i),h in ar)return;ar[h]=!0;const d=h.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(i)for(let $=a.length-1;$>=0;$--){const S=a[$];if(S.href===h&&(!d||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${p}`))return;const v=document.createElement("link");if(v.rel=d?"stylesheet":Vu,d||(v.as="script"),v.crossOrigin="",v.href=h,u&&v.setAttribute("nonce",u),document.head.appendChild(v),d)return new Promise(($,S)=>{v.addEventListener("load",$),v.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(a){const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=a,window.dispatchEvent(r),!r.defaultPrevented)throw a}return s.then(a=>{for(const r of a||[])r.status==="rejected"&&o(r.reason);return t().catch(o)})};const Si=globalThis,Go=Si.ShadowRoot&&(Si.ShadyCSS===void 0||Si.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Vo=Symbol(),rr=new WeakMap;let Ol=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==Vo)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=n}get styleSheet(){let t=this.o;const n=this.t;if(Go&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=rr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&rr.set(n,t))}return t}toString(){return this.cssText}};const Ju=e=>new Ol(typeof e=="string"?e:e+"",void 0,Vo),Yu=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((i,s,o)=>i+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[o+1],e[0]);return new Ol(n,e,Vo)},Xu=(e,t)=>{if(Go)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=Si.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},lr=Go?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return Ju(n)})(e):e;const{is:Zu,defineProperty:ep,getOwnPropertyDescriptor:tp,getOwnPropertyNames:np,getOwnPropertySymbols:ip,getPrototypeOf:sp}=Object,st=globalThis,cr=st.trustedTypes,op=cr?cr.emptyScript:"",Ms=st.reactiveElementPolyfillSupport,Cn=(e,t)=>e,Li={toAttribute(e,t){switch(t){case Boolean:e=e?op:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},Qo=(e,t)=>!Zu(e,t),dr={attribute:!0,type:String,converter:Li,reflect:!1,useDefault:!1,hasChanged:Qo};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),st.litPropertyMetadata??(st.litPropertyMetadata=new WeakMap);let zt=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,n=dr){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,n);s!==void 0&&ep(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=tp(this.prototype,t)??{get(){return this[n]},set(a){this[n]=a}};return{get:s,set(a){const r=s==null?void 0:s.call(this);o==null||o.call(this,a),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??dr}static _$Ei(){if(this.hasOwnProperty(Cn("elementProperties")))return;const t=sp(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Cn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Cn("properties"))){const n=this.properties,i=[...np(n),...ip(n)];for(const s of i)this.createProperty(s,n[s])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[i,s]of n)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[n,i]of this.elementProperties){const s=this._$Eu(n,i);s!==void 0&&this._$Eh.set(s,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)n.unshift(lr(s))}else t!==void 0&&n.push(lr(t));return n}static _$Eu(t,n){const i=n.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(n=>n(this))}addController(t){var n;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)==null||n.call(t))}removeController(t){var n;(n=this._$EO)==null||n.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const i of n.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Xu(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostConnected)==null?void 0:i.call(n)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostDisconnected)==null?void 0:i.call(n)})}attributeChangedCallback(t,n,i){this._$AK(t,i)}_$ET(t,n){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const a=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Li).toAttribute(n,i.type);this._$Em=t,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$Em=null}}_$AK(t,n){var o,a;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const r=i.getPropertyOptions(s),u=typeof r.converter=="function"?{fromAttribute:r.converter}:((o=r.converter)==null?void 0:o.fromAttribute)!==void 0?r.converter:Li;this._$Em=s;const c=u.fromAttribute(n,r.type);this[s]=c??((a=this._$Ej)==null?void 0:a.get(s))??c,this._$Em=null}}requestUpdate(t,n,i,s=!1,o){var a;if(t!==void 0){const r=this.constructor;if(s===!1&&(o=this[t]),i??(i=r.getPropertyOptions(t)),!((i.hasChanged??Qo)(o,n)||i.useDefault&&i.reflect&&o===((a=this._$Ej)==null?void 0:a.get(t))&&!this.hasAttribute(r._$Eu(t,i))))return;this.C(t,n,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:i,reflect:s,wrapped:o},a){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,a??n??this[t]),o!==!0||a!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(n=void 0),this._$AL.set(t,n)),s===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,a]of this._$Ep)this[o]=a;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,a]of s){const{wrapped:r}=a,u=this[o];r!==!0||this._$AL.has(o)||u===void 0||this.C(o,void 0,a,u)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),(i=this._$EO)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){var n;(n=this._$EO)==null||n.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(n=>this._$ET(n,this[n]))),this._$EM()}updated(t){}firstUpdated(t){}};zt.elementStyles=[],zt.shadowRootOptions={mode:"open"},zt[Cn("elementProperties")]=new Map,zt[Cn("finalized")]=new Map,Ms==null||Ms({ReactiveElement:zt}),(st.reactiveElementVersions??(st.reactiveElementVersions=[])).push("2.1.2");const En=globalThis,ur=e=>e,Ri=En.trustedTypes,pr=Ri?Ri.createPolicy("lit-html",{createHTML:e=>e}):void 0,Fl="$lit$",it=`lit$${Math.random().toFixed(9).slice(2)}$`,Ul="?"+it,ap=`<${Ul}>`,St=document,Fn=()=>St.createComment(""),Un=e=>e===null||typeof e!="object"&&typeof e!="function",Jo=Array.isArray,rp=e=>Jo(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Ps=`[
1
+ var Gu=Object.defineProperty;var Vu=(e,t,n)=>t in e?Gu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var q=(e,t,n)=>Vu(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const Qu="modulepreload",Ju=function(e,t){return new URL(e,t).href},ar={},ae=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let c=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};const a=document.getElementsByTagName("link"),r=document.querySelector("meta[property=csp-nonce]"),u=(r==null?void 0:r.nonce)||(r==null?void 0:r.getAttribute("nonce"));s=c(n.map(h=>{if(h=Ju(h,i),h in ar)return;ar[h]=!0;const d=h.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(i)for(let $=a.length-1;$>=0;$--){const S=a[$];if(S.href===h&&(!d||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${p}`))return;const v=document.createElement("link");if(v.rel=d?"stylesheet":Qu,d||(v.as="script"),v.crossOrigin="",v.href=h,u&&v.setAttribute("nonce",u),document.head.appendChild(v),d)return new Promise(($,S)=>{v.addEventListener("load",$),v.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(a){const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=a,window.dispatchEvent(r),!r.defaultPrevented)throw a}return s.then(a=>{for(const r of a||[])r.status==="rejected"&&o(r.reason);return t().catch(o)})};const Si=globalThis,Go=Si.ShadowRoot&&(Si.ShadyCSS===void 0||Si.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Vo=Symbol(),rr=new WeakMap;let Ol=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==Vo)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=n}get styleSheet(){let t=this.o;const n=this.t;if(Go&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=rr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&rr.set(n,t))}return t}toString(){return this.cssText}};const Yu=e=>new Ol(typeof e=="string"?e:e+"",void 0,Vo),Xu=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((i,s,o)=>i+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[o+1],e[0]);return new Ol(n,e,Vo)},Zu=(e,t)=>{if(Go)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=Si.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},lr=Go?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return Yu(n)})(e):e;const{is:ep,defineProperty:tp,getOwnPropertyDescriptor:np,getOwnPropertyNames:ip,getOwnPropertySymbols:sp,getPrototypeOf:op}=Object,ot=globalThis,cr=ot.trustedTypes,ap=cr?cr.emptyScript:"",Ms=ot.reactiveElementPolyfillSupport,Cn=(e,t)=>e,Li={toAttribute(e,t){switch(t){case Boolean:e=e?ap:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},Qo=(e,t)=>!ep(e,t),dr={attribute:!0,type:String,converter:Li,reflect:!1,useDefault:!1,hasChanged:Qo};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),ot.litPropertyMetadata??(ot.litPropertyMetadata=new WeakMap);let zt=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,n=dr){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,n);s!==void 0&&tp(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=np(this.prototype,t)??{get(){return this[n]},set(a){this[n]=a}};return{get:s,set(a){const r=s==null?void 0:s.call(this);o==null||o.call(this,a),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??dr}static _$Ei(){if(this.hasOwnProperty(Cn("elementProperties")))return;const t=op(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Cn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Cn("properties"))){const n=this.properties,i=[...ip(n),...sp(n)];for(const s of i)this.createProperty(s,n[s])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[i,s]of n)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[n,i]of this.elementProperties){const s=this._$Eu(n,i);s!==void 0&&this._$Eh.set(s,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)n.unshift(lr(s))}else t!==void 0&&n.push(lr(t));return n}static _$Eu(t,n){const i=n.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(n=>n(this))}addController(t){var n;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)==null||n.call(t))}removeController(t){var n;(n=this._$EO)==null||n.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const i of n.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Zu(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostConnected)==null?void 0:i.call(n)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostDisconnected)==null?void 0:i.call(n)})}attributeChangedCallback(t,n,i){this._$AK(t,i)}_$ET(t,n){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const a=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Li).toAttribute(n,i.type);this._$Em=t,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$Em=null}}_$AK(t,n){var o,a;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const r=i.getPropertyOptions(s),u=typeof r.converter=="function"?{fromAttribute:r.converter}:((o=r.converter)==null?void 0:o.fromAttribute)!==void 0?r.converter:Li;this._$Em=s;const c=u.fromAttribute(n,r.type);this[s]=c??((a=this._$Ej)==null?void 0:a.get(s))??c,this._$Em=null}}requestUpdate(t,n,i,s=!1,o){var a;if(t!==void 0){const r=this.constructor;if(s===!1&&(o=this[t]),i??(i=r.getPropertyOptions(t)),!((i.hasChanged??Qo)(o,n)||i.useDefault&&i.reflect&&o===((a=this._$Ej)==null?void 0:a.get(t))&&!this.hasAttribute(r._$Eu(t,i))))return;this.C(t,n,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:i,reflect:s,wrapped:o},a){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,a??n??this[t]),o!==!0||a!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(n=void 0),this._$AL.set(t,n)),s===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,a]of this._$Ep)this[o]=a;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,a]of s){const{wrapped:r}=a,u=this[o];r!==!0||this._$AL.has(o)||u===void 0||this.C(o,void 0,a,u)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),(i=this._$EO)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){var n;(n=this._$EO)==null||n.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(n=>this._$ET(n,this[n]))),this._$EM()}updated(t){}firstUpdated(t){}};zt.elementStyles=[],zt.shadowRootOptions={mode:"open"},zt[Cn("elementProperties")]=new Map,zt[Cn("finalized")]=new Map,Ms==null||Ms({ReactiveElement:zt}),(ot.reactiveElementVersions??(ot.reactiveElementVersions=[])).push("2.1.2");const En=globalThis,ur=e=>e,Ri=En.trustedTypes,pr=Ri?Ri.createPolicy("lit-html",{createHTML:e=>e}):void 0,Fl="$lit$",st=`lit$${Math.random().toFixed(9).slice(2)}$`,Ul="?"+st,rp=`<${Ul}>`,St=document,Fn=()=>St.createComment(""),Un=e=>e===null||typeof e!="object"&&typeof e!="function",Jo=Array.isArray,lp=e=>Jo(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Ps=`[
2
2
  \f\r]`,hn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,hr=/-->/g,fr=/>/g,pt=RegExp(`>|${Ps}(?:([^\\s"'>=/]+)(${Ps}*=${Ps}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),gr=/'/g,mr=/"/g,Wl=/^(?:script|style|textarea|title)$/i,lp=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),l=lp(1),at=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),yr=new WeakMap,yt=St.createTreeWalker(St,129);function Kl(e,t){if(!Jo(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return pr!==void 0?pr.createHTML(t):t}const cp=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",a=hn;for(let r=0;r<n;r++){const u=e[r];let c,h,d=-1,p=0;for(;p<u.length&&(a.lastIndex=p,h=a.exec(u),h!==null);)p=a.lastIndex,a===hn?h[1]==="!--"?a=hr:h[1]!==void 0?a=fr:h[2]!==void 0?(Wl.test(h[2])&&(s=RegExp("</"+h[2],"g")),a=pt):h[3]!==void 0&&(a=pt):a===pt?h[0]===">"?(a=s??hn,d=-1):h[1]===void 0?d=-2:(d=a.lastIndex-h[2].length,c=h[1],a=h[3]===void 0?pt:h[3]==='"'?mr:gr):a===mr||a===gr?a=pt:a===hr||a===fr?a=hn:(a=pt,s=void 0);const v=a===pt&&e[r+1].startsWith("/>")?" ":"";o+=a===hn?u+ap:d>=0?(i.push(c),u.slice(0,d)+Fl+u.slice(d)+it+v):u+it+(d===-2?r:v)}return[Kl(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let vo=class zl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,a=0;const r=t.length-1,u=this.parts,[c,h]=cp(t,n);if(this.el=zl.createElement(c,i),yt.currentNode=this.el.content,n===2||n===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=yt.nextNode())!==null&&u.length<r;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith(Fl)){const p=h[a++],v=s.getAttribute(d).split(it),$=/([.?@])?(.*)/.exec(p);u.push({type:1,index:o,name:$[2],strings:v,ctor:$[1]==="."?up:$[1]==="?"?pp:$[1]==="@"?hp:is}),s.removeAttribute(d)}else d.startsWith(it)&&(u.push({type:6,index:o}),s.removeAttribute(d));if(Wl.test(s.tagName)){const d=s.textContent.split(it),p=d.length-1;if(p>0){s.textContent=Ri?Ri.emptyScript:"";for(let v=0;v<p;v++)s.append(d[v],Fn()),yt.nextNode(),u.push({type:2,index:++o});s.append(d[p],Fn())}}}else if(s.nodeType===8)if(s.data===Ul)u.push({type:2,index:o});else{let d=-1;for(;(d=s.data.indexOf(it,d+1))!==-1;)u.push({type:7,index:o}),d+=it.length-1}o++}}static createElement(t,n){const i=St.createElement("template");return i.innerHTML=t,i}};function Qt(e,t,n=e,i){var a,r;if(t===at)return t;let s=i!==void 0?(a=n._$Co)==null?void 0:a[i]:n._$Cl;const o=Un(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((r=s==null?void 0:s._$AO)==null||r.call(s,!1),o===void 0?s=void 0:(s=new o(e),s._$AT(e,n,i)),i!==void 0?(n._$Co??(n._$Co=[]))[i]=s:n._$Cl=s),s!==void 0&&(t=Qt(e,s._$AS(e,t.values),s,i)),t}class dp{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:i}=this._$AD,s=((t==null?void 0:t.creationScope)??St).importNode(n,!0);yt.currentNode=s;let o=yt.nextNode(),a=0,r=0,u=i[0];for(;u!==void 0;){if(a===u.index){let c;u.type===2?c=new ns(o,o.nextSibling,this,t):u.type===1?c=new u.ctor(o,u.name,u.strings,this,t):u.type===6&&(c=new fp(o,this,t)),this._$AV.push(c),u=i[++r]}a!==(u==null?void 0:u.index)&&(o=yt.nextNode(),a++)}return yt.currentNode=St,s}p(t){let n=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,n),n+=i.strings.length-2):i._$AI(t[n])),n++}}let ns=class Hl{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,n,i,s){this.type=2,this._$AH=w,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.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=Qt(this,t,n),Un(t)?t===w||t==null||t===""?(this._$AH!==w&&this._$AR(),this._$AH=w):t!==this._$AH&&t!==at&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):rp(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!==w&&Un(this._$AH)?this._$AA.nextSibling.data=t:this.T(St.createTextNode(t)),this._$AH=t}$(t){var o;const{values:n,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=vo.createElement(Kl(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(n);else{const a=new dp(s,this),r=a.u(this.options);a.p(n),this.T(r),this._$AH=a}}_$AC(t){let n=yr.get(t.strings);return n===void 0&&yr.set(t.strings,n=new vo(t)),n}k(t){Jo(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let i,s=0;for(const o of t)s===n.length?n.push(i=new Hl(this.O(Fn()),this.O(Fn()),this,this.options)):i=n[s],i._$AI(o),s++;s<n.length&&(this._$AR(i&&i._$AB.nextSibling,s),n.length=s)}_$AR(t=this._$AA.nextSibling,n){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,n);t!==this._$AB;){const s=ur(t).nextSibling;ur(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class is{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=w,this._$AN=void 0,this.element=t,this.name=n,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=w}_$AI(t,n=this,i,s){const o=this.strings;let a=!1;if(o===void 0)t=Qt(this,t,n,0),a=!Un(t)||t!==this._$AH&&t!==at,a&&(this._$AH=t);else{const r=t;let u,c;for(t=o[0],u=0;u<o.length-1;u++)c=Qt(this,r[i+u],n,u),c===at&&(c=this._$AH[u]),a||(a=!Un(c)||c!==this._$AH[u]),c===w?t=w:t!==w&&(t+=(c??"")+o[u+1]),this._$AH[u]=c}a&&!s&&this.j(t)}j(t){t===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let up=class extends is{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===w?void 0:t}},pp=class extends is{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==w)}},hp=class extends is{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=Qt(this,t,n,0)??w)===at)return;const i=this._$AH,s=t===w&&i!==w||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==w&&(i===w||s);s&&this.element.removeEventListener(this.name,this,i),o&&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)}},fp=class{constructor(t,n,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Qt(this,t)}};const gp={I:ns},Is=En.litHtmlPolyfillSupport;Is==null||Is(vo,ns),(En.litHtmlVersions??(En.litHtmlVersions=[])).push("3.3.2");const mp=(e,t,n)=>{const i=(n==null?void 0:n.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const o=(n==null?void 0:n.renderBefore)??null;i._$litPart$=s=new ns(t.insertBefore(Fn(),o),o,void 0,n??{})}return s._$AI(e),s};const kt=globalThis;let jt=class extends zt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var n;const t=super.createRenderRoot();return(n=this.renderOptions).renderBefore??(n.renderBefore=t.firstChild),t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=mp(n,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return at}};var Nl;jt._$litElement$=!0,jt.finalized=!0,(Nl=kt.litElementHydrateSupport)==null||Nl.call(kt,{LitElement:jt});const Ls=kt.litElementPolyfillSupport;Ls==null||Ls({LitElement:jt});(kt.litElementVersions??(kt.litElementVersions=[])).push("4.2.2");const ql=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const yp={attribute:!0,type:String,converter:Li,reflect:!1,hasChanged:Qo},vp=(e=yp,t,n)=>{const{kind:i,metadata:s}=n;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(n.name,e),i==="accessor"){const{name:a}=n;return{set(r){const u=t.get.call(this);t.set.call(this,r),this.requestUpdate(a,u,e,!0,r)},init(r){return r!==void 0&&this.C(a,void 0,e,r),r}}}if(i==="setter"){const{name:a}=n;return function(r){const u=this[a];t.call(this,r),this.requestUpdate(a,u,e,!0,r)}}throw Error("Unsupported decorator location: "+i)};function ss(e){return(t,n)=>typeof n=="object"?vp(e,t,n):((i,s,o)=>{const a=s.hasOwnProperty(o);return s.constructor.createProperty(o,i),a?Object.getOwnPropertyDescriptor(s,o):void 0})(e,t,n)}function m(e){return ss({...e,state:!0,attribute:!1})}const bp=50,wp=200,kp="Assistant";function vr(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function bo(e){const t=vr(e==null?void 0:e.name,bp)??kp,n=vr((e==null?void 0:e.avatar)??void 0,wp)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function xp(){return bo(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const $p="Taskmaster",Sp="/taskmaster-icon.png",Ap="#00d4ff",Cp="";let ai=null;function Qe(){return ai||(ai={name:window.__TASKMASTER_BRAND_NAME__||$p,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||Sp,accentColor:window.__TASKMASTER_ACCENT_COLOR__||Ap,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||Cp},ai)}function Be(){return window.__TASKMASTER_WORKSPACE_BRANDS__??{}}function jl(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);return t?`${parseInt(t[1],16)}, ${parseInt(t[2],16)}, ${parseInt(t[3],16)}`:null}function Ep(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!t)return 0;const[n,i,s]=[t[1],t[2],t[3]].map(o=>{const a=parseInt(o,16)/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return .2126*n+.7152*i+.0722*s}function Gl(e){const t=jl(e);if(!t)return;const n=document.documentElement;n.style.setProperty("--accent",e),n.style.setProperty("--accent-hover",e),n.style.setProperty("--accent-muted",e),n.style.setProperty("--primary",e),n.style.setProperty("--ring",e),n.style.setProperty("--accent-subtle",`rgba(${t}, 0.15)`),n.style.setProperty("--accent-glow",`rgba(${t}, 0.25)`),n.style.setProperty("--tasker-orange",e),n.style.setProperty("--tasker-orange-hover",e),n.style.setProperty("--tasker-orange-glow",`rgba(${t}, 0.25)`);const i=Ep(e)>.4?"#111111":"#ffffff";n.style.setProperty("--accent-foreground",i),n.style.setProperty("--primary-foreground",i)}function ri(e,t,n){const i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e),s=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!i||!s)return e;const o=(c,h)=>Math.round(parseInt(i[c],16)*(1-n)+parseInt(s[h],16)*n),a=o(1,1),r=o(2,2),u=o(3,3);return`#${a.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${u.toString(16).padStart(2,"0")}`}const fn={"--bg":"#12141a","--bg-muted":"#262a35","--card":"#181b22","--secondary":"#1e2028"};function Vl(e){const t=document.documentElement;if(!e){for(const[i,s]of Object.entries(fn))t.style.setProperty(i,s);t.style.removeProperty("--brand-bg"),t.style.removeProperty("--brand-bg-subtle"),t.style.removeProperty("--brand-bg-card");return}const n=jl(e);n&&(t.style.setProperty("--bg",ri(fn["--bg"],e,.08)),t.style.setProperty("--bg-muted",ri(fn["--bg-muted"],e,.1)),t.style.setProperty("--card",ri(fn["--card"],e,.12)),t.style.setProperty("--secondary",ri(fn["--secondary"],e,.1)),t.style.setProperty("--brand-bg",e),t.style.setProperty("--brand-bg-subtle",`rgba(${n}, 0.08)`),t.style.setProperty("--brand-bg-card",`rgba(${n}, 0.12)`))}function Tn(e){const t=Qe(),n=Be(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;Gl(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;Vl(o)}const Di="taskmaster.control.settings.v1",Ql="taskmaster.account.settings.";function _n(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const Wt={gatewayUrl:_n(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},tt={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function Tp(){try{const e=localStorage.getItem(Di);if(!e)return{...Wt,gatewayUrl:_n()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():_n(),token:typeof t.token=="string"?t.token:Wt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:Wt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:Wt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:Wt.navGroupsCollapsed}}catch{return{...Wt,gatewayUrl:_n()}}}function _p(e){if(!e)return{...tt};try{const t=localStorage.getItem(Ql+e);if(!t)return{...tt};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():tt.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||tt.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:tt.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:tt.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:tt.splitRatio}}catch{return{...tt}}}let Bi=null;function br(e){Bi=e}function Rs(){return{...Tp(),..._p(Bi)}}function Mp(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Di,JSON.stringify(t)),Bi){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Ql+Bi,JSON.stringify(n))}}const Pp="taskmaster.draft.";function Yo(e,t){return Pp+e+"."+t}function Wn(e,t,n){try{const i=Yo(e,t);n?localStorage.setItem(i,n):localStorage.removeItem(i)}catch{}}function Kn(e,t){try{return localStorage.getItem(Yo(e,t))??""}catch{return""}}function Ip(e,t){try{localStorage.removeItem(Yo(e,t))}catch{}}let vt=null,Se=null;function wr(e,t,n){Se={workspace:e,sessionKey:t,text:n},vt!=null&&clearTimeout(vt),vt=setTimeout(()=>{Se&&Wn(Se.workspace,Se.sessionKey,Se.text),Se=null,vt=null},300)}function wo(){vt!=null&&clearTimeout(vt),vt=null,Se&&(Wn(Se.workspace,Se.sessionKey,Se.text),Se=null)}(function(){try{const t=localStorage.getItem(Di);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:_n(),token:typeof n.token=="string"?n.token:"",theme:n.theme==="light"||n.theme==="dark"||n.theme==="system"?n.theme:"system",navCollapsed:typeof n.navCollapsed=="boolean"?n.navCollapsed:!1,navGroupsCollapsed:typeof n.navGroupsCollapsed=="object"&&n.navGroupsCollapsed!==null?n.navGroupsCollapsed:{}};localStorage.setItem(Di,JSON.stringify(i))}catch{}})();function Jl(e){var o;const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const i=(o=n[1])==null?void 0:o.trim(),s=n.slice(2).join(":");return!i||!s?null:{agentId:i,rest:s}}const Lp=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,li=/<\s*\/?\s*final\b[^>]*>/gi,kr=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Rp(e,t){return e.trimStart()}function Dp(e,t){if(!e||!Lp.test(e))return e;let n=e;li.test(n)?(li.lastIndex=0,n=n.replace(li,"")):li.lastIndex=0,kr.lastIndex=0;let i="",s=0,o=!1;for(const a of n.matchAll(kr)){const r=a.index??0,u=a[1]==="/";o?u&&(o=!1):(i+=n.slice(s,r),u||(o=!0)),s=r+a[0].length}return i+=n.slice(s),Rp(i)}function Yl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function os(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const a=-t,r=Math.round(a/1e3);if(r<60)return`in ${r}s`;const u=Math.round(r/60);if(u<60)return`in ${u}m`;const c=Math.round(u/60);return c<48?`in ${c}h`:`in ${Math.round(c/24)}d`}const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<48?`${s}h ago`:`${Math.round(s/24)}d ago`}function Xo(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const i=Math.round(n/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function Bp(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Xl(e,t){return e.length<=t?{text:e,truncated:!1,total:e.length}:{text:e.slice(0,Math.max(0,t)),truncated:!0,total:e.length}}function Ni(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Ds(e){return Dp(e)}const Np=/^\[([^\]]+)\]\s*/,Op=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Bs=new WeakMap,Ns=new WeakMap;function Fp(e){return/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}Z\b/.test(e)||/\d{4}-\d{2}-\d{2} \d{2}:\d{2}\b/.test(e)?!0:Op.some(t=>e.startsWith(`${t} `))}function Os(e){const t=e.match(Np);if(!t)return e;const n=t[1]??"";return Fp(n)?e.slice(t[0].length):e}function Mn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?Ds(i):Os(i);if(Array.isArray(i)){const s=i.map(o=>{const a=o;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(o=>typeof o=="string");if(s.length>0){const o=s.join(`
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),gr=/'/g,mr=/"/g,Wl=/^(?:script|style|textarea|title)$/i,cp=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),l=cp(1),rt=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),yr=new WeakMap,yt=St.createTreeWalker(St,129);function Kl(e,t){if(!Jo(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return pr!==void 0?pr.createHTML(t):t}const dp=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",a=hn;for(let r=0;r<n;r++){const u=e[r];let c,h,d=-1,p=0;for(;p<u.length&&(a.lastIndex=p,h=a.exec(u),h!==null);)p=a.lastIndex,a===hn?h[1]==="!--"?a=hr:h[1]!==void 0?a=fr:h[2]!==void 0?(Wl.test(h[2])&&(s=RegExp("</"+h[2],"g")),a=pt):h[3]!==void 0&&(a=pt):a===pt?h[0]===">"?(a=s??hn,d=-1):h[1]===void 0?d=-2:(d=a.lastIndex-h[2].length,c=h[1],a=h[3]===void 0?pt:h[3]==='"'?mr:gr):a===mr||a===gr?a=pt:a===hr||a===fr?a=hn:(a=pt,s=void 0);const v=a===pt&&e[r+1].startsWith("/>")?" ":"";o+=a===hn?u+rp:d>=0?(i.push(c),u.slice(0,d)+Fl+u.slice(d)+st+v):u+st+(d===-2?r:v)}return[Kl(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let vo=class zl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,a=0;const r=t.length-1,u=this.parts,[c,h]=dp(t,n);if(this.el=zl.createElement(c,i),yt.currentNode=this.el.content,n===2||n===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=yt.nextNode())!==null&&u.length<r;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith(Fl)){const p=h[a++],v=s.getAttribute(d).split(st),$=/([.?@])?(.*)/.exec(p);u.push({type:1,index:o,name:$[2],strings:v,ctor:$[1]==="."?pp:$[1]==="?"?hp:$[1]==="@"?fp:is}),s.removeAttribute(d)}else d.startsWith(st)&&(u.push({type:6,index:o}),s.removeAttribute(d));if(Wl.test(s.tagName)){const d=s.textContent.split(st),p=d.length-1;if(p>0){s.textContent=Ri?Ri.emptyScript:"";for(let v=0;v<p;v++)s.append(d[v],Fn()),yt.nextNode(),u.push({type:2,index:++o});s.append(d[p],Fn())}}}else if(s.nodeType===8)if(s.data===Ul)u.push({type:2,index:o});else{let d=-1;for(;(d=s.data.indexOf(st,d+1))!==-1;)u.push({type:7,index:o}),d+=st.length-1}o++}}static createElement(t,n){const i=St.createElement("template");return i.innerHTML=t,i}};function Qt(e,t,n=e,i){var a,r;if(t===rt)return t;let s=i!==void 0?(a=n._$Co)==null?void 0:a[i]:n._$Cl;const o=Un(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((r=s==null?void 0:s._$AO)==null||r.call(s,!1),o===void 0?s=void 0:(s=new o(e),s._$AT(e,n,i)),i!==void 0?(n._$Co??(n._$Co=[]))[i]=s:n._$Cl=s),s!==void 0&&(t=Qt(e,s._$AS(e,t.values),s,i)),t}class up{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:i}=this._$AD,s=((t==null?void 0:t.creationScope)??St).importNode(n,!0);yt.currentNode=s;let o=yt.nextNode(),a=0,r=0,u=i[0];for(;u!==void 0;){if(a===u.index){let c;u.type===2?c=new ns(o,o.nextSibling,this,t):u.type===1?c=new u.ctor(o,u.name,u.strings,this,t):u.type===6&&(c=new gp(o,this,t)),this._$AV.push(c),u=i[++r]}a!==(u==null?void 0:u.index)&&(o=yt.nextNode(),a++)}return yt.currentNode=St,s}p(t){let n=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,n),n+=i.strings.length-2):i._$AI(t[n])),n++}}let ns=class Hl{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,n,i,s){this.type=2,this._$AH=w,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.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=Qt(this,t,n),Un(t)?t===w||t==null||t===""?(this._$AH!==w&&this._$AR(),this._$AH=w):t!==this._$AH&&t!==rt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):lp(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!==w&&Un(this._$AH)?this._$AA.nextSibling.data=t:this.T(St.createTextNode(t)),this._$AH=t}$(t){var o;const{values:n,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=vo.createElement(Kl(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(n);else{const a=new up(s,this),r=a.u(this.options);a.p(n),this.T(r),this._$AH=a}}_$AC(t){let n=yr.get(t.strings);return n===void 0&&yr.set(t.strings,n=new vo(t)),n}k(t){Jo(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let i,s=0;for(const o of t)s===n.length?n.push(i=new Hl(this.O(Fn()),this.O(Fn()),this,this.options)):i=n[s],i._$AI(o),s++;s<n.length&&(this._$AR(i&&i._$AB.nextSibling,s),n.length=s)}_$AR(t=this._$AA.nextSibling,n){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,n);t!==this._$AB;){const s=ur(t).nextSibling;ur(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class is{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=w,this._$AN=void 0,this.element=t,this.name=n,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=w}_$AI(t,n=this,i,s){const o=this.strings;let a=!1;if(o===void 0)t=Qt(this,t,n,0),a=!Un(t)||t!==this._$AH&&t!==rt,a&&(this._$AH=t);else{const r=t;let u,c;for(t=o[0],u=0;u<o.length-1;u++)c=Qt(this,r[i+u],n,u),c===rt&&(c=this._$AH[u]),a||(a=!Un(c)||c!==this._$AH[u]),c===w?t=w:t!==w&&(t+=(c??"")+o[u+1]),this._$AH[u]=c}a&&!s&&this.j(t)}j(t){t===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let pp=class extends is{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===w?void 0:t}},hp=class extends is{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==w)}},fp=class extends is{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=Qt(this,t,n,0)??w)===rt)return;const i=this._$AH,s=t===w&&i!==w||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==w&&(i===w||s);s&&this.element.removeEventListener(this.name,this,i),o&&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)}},gp=class{constructor(t,n,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Qt(this,t)}};const mp={I:ns},Is=En.litHtmlPolyfillSupport;Is==null||Is(vo,ns),(En.litHtmlVersions??(En.litHtmlVersions=[])).push("3.3.2");const yp=(e,t,n)=>{const i=(n==null?void 0:n.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const o=(n==null?void 0:n.renderBefore)??null;i._$litPart$=s=new ns(t.insertBefore(Fn(),o),o,void 0,n??{})}return s._$AI(e),s};const kt=globalThis;let jt=class extends zt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var n;const t=super.createRenderRoot();return(n=this.renderOptions).renderBefore??(n.renderBefore=t.firstChild),t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=yp(n,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return rt}};var Nl;jt._$litElement$=!0,jt.finalized=!0,(Nl=kt.litElementHydrateSupport)==null||Nl.call(kt,{LitElement:jt});const Ls=kt.litElementPolyfillSupport;Ls==null||Ls({LitElement:jt});(kt.litElementVersions??(kt.litElementVersions=[])).push("4.2.2");const ql=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const vp={attribute:!0,type:String,converter:Li,reflect:!1,hasChanged:Qo},bp=(e=vp,t,n)=>{const{kind:i,metadata:s}=n;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(n.name,e),i==="accessor"){const{name:a}=n;return{set(r){const u=t.get.call(this);t.set.call(this,r),this.requestUpdate(a,u,e,!0,r)},init(r){return r!==void 0&&this.C(a,void 0,e,r),r}}}if(i==="setter"){const{name:a}=n;return function(r){const u=this[a];t.call(this,r),this.requestUpdate(a,u,e,!0,r)}}throw Error("Unsupported decorator location: "+i)};function ss(e){return(t,n)=>typeof n=="object"?bp(e,t,n):((i,s,o)=>{const a=s.hasOwnProperty(o);return s.constructor.createProperty(o,i),a?Object.getOwnPropertyDescriptor(s,o):void 0})(e,t,n)}function m(e){return ss({...e,state:!0,attribute:!1})}const wp=50,kp=200,xp="Assistant";function vr(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function bo(e){const t=vr(e==null?void 0:e.name,wp)??xp,n=vr((e==null?void 0:e.avatar)??void 0,kp)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function $p(){return bo(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Sp="Taskmaster",Ap="/taskmaster-icon.png",Cp="#00d4ff",Ep="";let ai=null;function Xe(){return ai||(ai={name:window.__TASKMASTER_BRAND_NAME__||Sp,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||Ap,accentColor:window.__TASKMASTER_ACCENT_COLOR__||Cp,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||Ep},ai)}function Ne(){return window.__TASKMASTER_WORKSPACE_BRANDS__??{}}function jl(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);return t?`${parseInt(t[1],16)}, ${parseInt(t[2],16)}, ${parseInt(t[3],16)}`:null}function Tp(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!t)return 0;const[n,i,s]=[t[1],t[2],t[3]].map(o=>{const a=parseInt(o,16)/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return .2126*n+.7152*i+.0722*s}function Gl(e){const t=jl(e);if(!t)return;const n=document.documentElement;n.style.setProperty("--accent",e),n.style.setProperty("--accent-hover",e),n.style.setProperty("--accent-muted",e),n.style.setProperty("--primary",e),n.style.setProperty("--ring",e),n.style.setProperty("--accent-subtle",`rgba(${t}, 0.15)`),n.style.setProperty("--accent-glow",`rgba(${t}, 0.25)`),n.style.setProperty("--tasker-orange",e),n.style.setProperty("--tasker-orange-hover",e),n.style.setProperty("--tasker-orange-glow",`rgba(${t}, 0.25)`);const i=Tp(e)>.4?"#111111":"#ffffff";n.style.setProperty("--accent-foreground",i),n.style.setProperty("--primary-foreground",i)}function ri(e,t,n){const i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e),s=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!i||!s)return e;const o=(c,h)=>Math.round(parseInt(i[c],16)*(1-n)+parseInt(s[h],16)*n),a=o(1,1),r=o(2,2),u=o(3,3);return`#${a.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${u.toString(16).padStart(2,"0")}`}const fn={"--bg":"#12141a","--bg-muted":"#262a35","--card":"#181b22","--secondary":"#1e2028"};function Vl(e){const t=document.documentElement;if(!e){for(const[i,s]of Object.entries(fn))t.style.setProperty(i,s);t.style.removeProperty("--brand-bg"),t.style.removeProperty("--brand-bg-subtle"),t.style.removeProperty("--brand-bg-card");return}const n=jl(e);n&&(t.style.setProperty("--bg",ri(fn["--bg"],e,.08)),t.style.setProperty("--bg-muted",ri(fn["--bg-muted"],e,.1)),t.style.setProperty("--card",ri(fn["--card"],e,.12)),t.style.setProperty("--secondary",ri(fn["--secondary"],e,.1)),t.style.setProperty("--brand-bg",e),t.style.setProperty("--brand-bg-subtle",`rgba(${n}, 0.08)`),t.style.setProperty("--brand-bg-card",`rgba(${n}, 0.12)`))}function Tn(e){const t=Xe(),n=Ne(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;Gl(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;Vl(o)}const Di="taskmaster.control.settings.v1",Ql="taskmaster.account.settings.";function _n(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const Wt={gatewayUrl:_n(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},nt={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function _p(){try{const e=localStorage.getItem(Di);if(!e)return{...Wt,gatewayUrl:_n()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():_n(),token:typeof t.token=="string"?t.token:Wt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:Wt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:Wt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:Wt.navGroupsCollapsed}}catch{return{...Wt,gatewayUrl:_n()}}}function Mp(e){if(!e)return{...nt};try{const t=localStorage.getItem(Ql+e);if(!t)return{...nt};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():nt.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||nt.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:nt.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:nt.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:nt.splitRatio}}catch{return{...nt}}}let Bi=null;function br(e){Bi=e}function Rs(){return{..._p(),...Mp(Bi)}}function Pp(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Di,JSON.stringify(t)),Bi){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Ql+Bi,JSON.stringify(n))}}const Ip="taskmaster.draft.";function Yo(e,t){return Ip+e+"."+t}function Wn(e,t,n){try{const i=Yo(e,t);n?localStorage.setItem(i,n):localStorage.removeItem(i)}catch{}}function Kn(e,t){try{return localStorage.getItem(Yo(e,t))??""}catch{return""}}function Lp(e,t){try{localStorage.removeItem(Yo(e,t))}catch{}}let vt=null,Se=null;function wr(e,t,n){Se={workspace:e,sessionKey:t,text:n},vt!=null&&clearTimeout(vt),vt=setTimeout(()=>{Se&&Wn(Se.workspace,Se.sessionKey,Se.text),Se=null,vt=null},300)}function wo(){vt!=null&&clearTimeout(vt),vt=null,Se&&(Wn(Se.workspace,Se.sessionKey,Se.text),Se=null)}(function(){try{const t=localStorage.getItem(Di);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:_n(),token:typeof n.token=="string"?n.token:"",theme:n.theme==="light"||n.theme==="dark"||n.theme==="system"?n.theme:"system",navCollapsed:typeof n.navCollapsed=="boolean"?n.navCollapsed:!1,navGroupsCollapsed:typeof n.navGroupsCollapsed=="object"&&n.navGroupsCollapsed!==null?n.navGroupsCollapsed:{}};localStorage.setItem(Di,JSON.stringify(i))}catch{}})();function Jl(e){var o;const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const i=(o=n[1])==null?void 0:o.trim(),s=n.slice(2).join(":");return!i||!s?null:{agentId:i,rest:s}}const Rp=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,li=/<\s*\/?\s*final\b[^>]*>/gi,kr=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Dp(e,t){return e.trimStart()}function Bp(e,t){if(!e||!Rp.test(e))return e;let n=e;li.test(n)?(li.lastIndex=0,n=n.replace(li,"")):li.lastIndex=0,kr.lastIndex=0;let i="",s=0,o=!1;for(const a of n.matchAll(kr)){const r=a.index??0,u=a[1]==="/";o?u&&(o=!1):(i+=n.slice(s,r),u||(o=!0)),s=r+a[0].length}return i+=n.slice(s),Dp(i)}function Yl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function os(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const a=-t,r=Math.round(a/1e3);if(r<60)return`in ${r}s`;const u=Math.round(r/60);if(u<60)return`in ${u}m`;const c=Math.round(u/60);return c<48?`in ${c}h`:`in ${Math.round(c/24)}d`}const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<48?`${s}h ago`:`${Math.round(s/24)}d ago`}function Xo(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const i=Math.round(n/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function Np(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Xl(e,t){return e.length<=t?{text:e,truncated:!1,total:e.length}:{text:e.slice(0,Math.max(0,t)),truncated:!0,total:e.length}}function Ni(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Ds(e){return Bp(e)}const Op=/^\[([^\]]+)\]\s*/,Fp=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Bs=new WeakMap,Ns=new WeakMap;function Up(e){return/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}Z\b/.test(e)||/\d{4}-\d{2}-\d{2} \d{2}:\d{2}\b/.test(e)?!0:Fp.some(t=>e.startsWith(`${t} `))}function Os(e){const t=e.match(Op);if(!t)return e;const n=t[1]??"";return Up(n)?e.slice(t[0].length):e}function Mn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?Ds(i):Os(i);if(Array.isArray(i)){const s=i.map(o=>{const a=o;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(o=>typeof o=="string");if(s.length>0){const o=s.join(`
4
4
  `);return n==="assistant"?Ds(o):Os(o)}}return typeof t.text=="string"?n==="assistant"?Ds(t.text):Os(t.text):null}function Zl(e){if(!e||typeof e!="object")return Mn(e);const t=e;if(Bs.has(t))return Bs.get(t)??null;const n=Mn(e);return Bs.set(t,n),n}function xr(e){const n=e.content,i=[];if(Array.isArray(n))for(const r of n){const u=r;if(u.type==="thinking"&&typeof u.thinking=="string"){const c=u.thinking.trim();c&&i.push(c)}}if(i.length>0)return i.join(`
5
- `);const s=Wp(e);if(!s)return null;const a=[...s.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(r=>(r[1]??"").trim()).filter(Boolean);return a.length>0?a.join(`
6
- `):null}function Up(e){if(!e||typeof e!="object")return xr(e);const t=e;if(Ns.has(t))return Ns.get(t)??null;const n=xr(e);return Ns.set(t,n),n}function Wp(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const i=n.map(s=>{const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>typeof s=="string");if(i.length>0)return i.join(`
7
- `)}return typeof t.text=="string"?t.text:null}function Kp(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean).map(i=>`_${i}_`);return n.length?["_Reasoning:_",...n].join(`
8
- `):""}const zp=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Hp=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,qp=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,jp=/^A new session was started via \/new or \/reset\./;function Gp(e){const t=e,n=typeof t.role=="string"?t.role:"";let i="";typeof t.content=="string"?i=t.content:Array.isArray(t.content)?i=t.content.filter(o=>typeof o=="object"&&o!==null).map(o=>o.text??"").join(" "):typeof t.text=="string"&&(i=t.text);const s=i.trim();return s?!!(n==="user"&&zp.test(s)||n==="assistant"&&Hp.test(s)||n==="user"&&jp.test(s)||n==="assistant"&&qp.test(s)):!1}function ec(e){return e.filter(t=>!Gp(t))}function tc(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const i=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",s=t.content,o=Array.isArray(s)?s:null,a=Array.isArray(o)&&o.some(d=>{const v=String(d.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),r=typeof t.toolName=="string"||typeof t.tool_name=="string";(i||a||r)&&(n="toolResult");let u=[];typeof t.content=="string"?u=[{type:"text",text:t.content}]:Array.isArray(t.content)?u=t.content.map(d=>({type:d.type||"text",text:d.text,name:d.name,args:d.args||d.arguments})):typeof t.text=="string"&&(u=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),h=typeof t.id=="string"?t.id:void 0;return{role:n,content:u,timestamp:c,id:h}}function nc(e){const t=e.toLowerCase();return e==="user"||e==="User"?e:e==="assistant"?"assistant":e==="system"?"system":t==="toolresult"||t==="tool_result"||t==="tool"||t==="function"?"tool":e}function ic(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function $r(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,"0");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Vp(){const e=new Uint8Array(16),t=Date.now();for(let n=0;n<e.length;n++)e[n]=Math.floor(Math.random()*256);return e[0]^=t&255,e[1]^=t>>>8&255,e[2]^=t>>>16&255,e[3]^=t>>>24&255,e}function as(e=globalThis.crypto){if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),$r(t)}return $r(Vp())}const nn=50;async function Jt(e,t){if(!e.client||!e.connected)return;e.chatLoading=!0,e.lastError=null;const n=(t==null?void 0:t.limit)??nn;try{const i=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:n}),s=Array.isArray(i.messages)?i.messages:[],o=typeof i.totalMessages=="number"?i.totalMessages:s.length,a=ec(s);e.chatMessages=a,e.chatHistoryTotal=o,e.chatHistoryHasMore=o>s.length,e.chatVerboseLevel=typeof i.verboseLevel=="string"?i.verboseLevel:null}catch(i){e.lastError=String(i)}finally{e.chatLoading=!1}}async function Qp(e){if(!e.client||!e.connected||e.chatLoadingOlder||!e.chatHistoryHasMore)return!1;e.chatLoadingOlder=!0;try{const t=e.chatMessages.length,n=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:nn,offset:t}),i=Array.isArray(n.messages)?n.messages:[],s=typeof n.totalMessages=="number"?n.totalMessages:0;if(i.length===0)return e.chatHistoryHasMore=!1,!1;const o=ec(i);return e.chatMessages=[...o,...e.chatMessages],e.chatHistoryTotal=s,e.chatHistoryHasMore=s>t+i.length,!0}catch(t){return e.lastError=String(t),!1}finally{e.chatLoadingOlder=!1}}function Jp(e){const t=/^data:(.+?);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function sc(e,t,n){if(e.chatSuggestions=[],!e.client||!e.connected)return!1;const i=t.trim(),s=n&&n.length>0;if(!i&&!s)return!1;const o=Date.now(),a=(n??[]).filter(v=>!v.fileName),r=(n??[]).filter(v=>v.fileName),u=[],c=r.map(v=>v.fileName).filter(Boolean);if(c.length>0){const v=i?`${c.join(", ")}
5
+ `);const s=Kp(e);if(!s)return null;const a=[...s.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(r=>(r[1]??"").trim()).filter(Boolean);return a.length>0?a.join(`
6
+ `):null}function Wp(e){if(!e||typeof e!="object")return xr(e);const t=e;if(Ns.has(t))return Ns.get(t)??null;const n=xr(e);return Ns.set(t,n),n}function Kp(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const i=n.map(s=>{const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>typeof s=="string");if(i.length>0)return i.join(`
7
+ `)}return typeof t.text=="string"?t.text:null}function zp(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean).map(i=>`_${i}_`);return n.length?["_Reasoning:_",...n].join(`
8
+ `):""}const Hp=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,qp=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,jp=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Gp=/^A new session was started via \/new or \/reset\./;function Vp(e){const t=e,n=typeof t.role=="string"?t.role:"";let i="";typeof t.content=="string"?i=t.content:Array.isArray(t.content)?i=t.content.filter(o=>typeof o=="object"&&o!==null).map(o=>o.text??"").join(" "):typeof t.text=="string"&&(i=t.text);const s=i.trim();return s?!!(n==="user"&&Hp.test(s)||n==="assistant"&&qp.test(s)||n==="user"&&Gp.test(s)||n==="assistant"&&jp.test(s)):!1}function ec(e){return e.filter(t=>!Vp(t))}function tc(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const i=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",s=t.content,o=Array.isArray(s)?s:null,a=Array.isArray(o)&&o.some(d=>{const v=String(d.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),r=typeof t.toolName=="string"||typeof t.tool_name=="string";(i||a||r)&&(n="toolResult");let u=[];typeof t.content=="string"?u=[{type:"text",text:t.content}]:Array.isArray(t.content)?u=t.content.map(d=>({type:d.type||"text",text:d.text,name:d.name,args:d.args||d.arguments})):typeof t.text=="string"&&(u=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),h=typeof t.id=="string"?t.id:void 0;return{role:n,content:u,timestamp:c,id:h}}function nc(e){const t=e.toLowerCase();return e==="user"||e==="User"?e:e==="assistant"?"assistant":e==="system"?"system":t==="toolresult"||t==="tool_result"||t==="tool"||t==="function"?"tool":e}function ic(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function $r(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,"0");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Qp(){const e=new Uint8Array(16),t=Date.now();for(let n=0;n<e.length;n++)e[n]=Math.floor(Math.random()*256);return e[0]^=t&255,e[1]^=t>>>8&255,e[2]^=t>>>16&255,e[3]^=t>>>24&255,e}function as(e=globalThis.crypto){if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),$r(t)}return $r(Qp())}const nn=50;async function Jt(e,t){if(!e.client||!e.connected)return;e.chatLoading=!0,e.lastError=null;const n=(t==null?void 0:t.limit)??nn;try{const i=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:n}),s=Array.isArray(i.messages)?i.messages:[],o=typeof i.totalMessages=="number"?i.totalMessages:s.length,a=ec(s);e.chatMessages=a,e.chatHistoryTotal=o,e.chatHistoryHasMore=o>s.length,e.chatVerboseLevel=typeof i.verboseLevel=="string"?i.verboseLevel:null}catch(i){e.lastError=String(i)}finally{e.chatLoading=!1}}async function Jp(e){if(!e.client||!e.connected||e.chatLoadingOlder||!e.chatHistoryHasMore)return!1;e.chatLoadingOlder=!0;try{const t=e.chatMessages.length,n=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:nn,offset:t}),i=Array.isArray(n.messages)?n.messages:[],s=typeof n.totalMessages=="number"?n.totalMessages:0;if(i.length===0)return e.chatHistoryHasMore=!1,!1;const o=ec(i);return e.chatMessages=[...o,...e.chatMessages],e.chatHistoryTotal=s,e.chatHistoryHasMore=s>t+i.length,!0}catch(t){return e.lastError=String(t),!1}finally{e.chatLoadingOlder=!1}}function Yp(e){const t=/^data:(.+?);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function sc(e,t,n){if(e.chatSuggestions=[],!e.client||!e.connected)return!1;const i=t.trim(),s=n&&n.length>0;if(!i&&!s)return!1;const o=Date.now(),a=(n??[]).filter(v=>!v.fileName),r=(n??[]).filter(v=>v.fileName),u=[],c=r.map(v=>v.fileName).filter(Boolean);if(c.length>0){const v=i?`${c.join(", ")}
9
9
 
10
- ${i}`:c.join(", ");u.push({type:"text",text:v})}else i&&u.push({type:"text",text:i});for(const v of a)u.push({type:"image",source:{type:"base64",media_type:v.mimeType,data:v.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:u,timestamp:o}],e.chatSending=!0,e.lastError=null;const h=as();e.chatRunId=h,e.chatStream="",e.chatStreamStartedAt=o;const d=[...a,...r],p=d.length>0?d.map(v=>{if(v.textContent)return{type:"document",mimeType:v.mimeType||"text/plain",fileName:v.fileName,content:btoa(unescape(encodeURIComponent(v.textContent)))};const $=Jp(v.dataUrl);return $?{type:v.fileName?"document":"image",mimeType:$.mimeType,fileName:v.fileName,content:$.content}:null}).filter(v=>v!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:h,attachments:p}),!0}catch(v){const $=String(v);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=$,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+$}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function oc(e){if(!e.client||!e.connected)return!1;const t=e.chatRunId;try{return await e.client.request("chat.abort",t?{sessionKey:e.sessionKey,runId:t}:{sessionKey:e.sessionKey}),!0}catch(n){return e.lastError=String(n),!1}}function ac(e,t){var n,i;if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="working"){const o=(t.message?(n=Mn(t.message))==null?void 0:n.trim():void 0)||((i=e.chatStream)==null?void 0:i.trim());if(o)if(!e.chatInterimText)e.chatInterimText=o;else{const a=o.trim(),r=e.chatInterimText.trim();a===r||r.endsWith(a)||(a.startsWith(r)?e.chatInterimText=o:e.chatInterimText=`${e.chatInterimText}
10
+ ${i}`:c.join(", ");u.push({type:"text",text:v})}else i&&u.push({type:"text",text:i});for(const v of a)u.push({type:"image",source:{type:"base64",media_type:v.mimeType,data:v.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:u,timestamp:o}],e.chatSending=!0,e.lastError=null;const h=as();e.chatRunId=h,e.chatStream="",e.chatStreamStartedAt=o;const d=[...a,...r],p=d.length>0?d.map(v=>{if(v.textContent)return{type:"document",mimeType:v.mimeType||"text/plain",fileName:v.fileName,content:btoa(unescape(encodeURIComponent(v.textContent)))};const $=Yp(v.dataUrl);return $?{type:v.fileName?"document":"image",mimeType:$.mimeType,fileName:v.fileName,content:$.content}:null}).filter(v=>v!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:h,attachments:p}),!0}catch(v){const $=String(v);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=$,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+$}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function oc(e){if(!e.client||!e.connected)return!1;const t=e.chatRunId;try{return await e.client.request("chat.abort",t?{sessionKey:e.sessionKey,runId:t}:{sessionKey:e.sessionKey}),!0}catch(n){return e.lastError=String(n),!1}}function ac(e,t){var n,i;if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="working"){const o=(t.message?(n=Mn(t.message))==null?void 0:n.trim():void 0)||((i=e.chatStream)==null?void 0:i.trim());if(o)if(!e.chatInterimText)e.chatInterimText=o;else{const a=o.trim(),r=e.chatInterimText.trim();a===r||r.endsWith(a)||(a.startsWith(r)?e.chatInterimText=o:e.chatInterimText=`${e.chatInterimText}
11
11
 
12
- ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.message);return typeof s=="string"&&s.trim()&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:s.trim()}],timestamp:Date.now(),filler:!0}]),"block"}else if(t.state==="delta"){e.chatSuggestions=[];const s=Mn(t.message);if(typeof s=="string"){if(s.trim()==="NO_REPLY")return null;const o=e.chatStream??"";(!o||s.length>=o.length)&&(e.chatStream=s)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null,e.lastError=t.errorMessage??"chat error");return t.state}const Oi=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:nn,abortChatRun:oc,handleChatEvent:ac,loadChatHistory:Jt,loadOlderChatHistory:Qp,sendChatMessage:sc},Symbol.toStringTag,{value:"Module"}));async function rc(e){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const t={includeGlobal:e.sessionsIncludeGlobal??!0,includeUnknown:e.sessionsIncludeUnknown??!1},n=Ni(e.sessionsFilterActive??"",0),i=Ni(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),i>0&&(t.limit=i);const s=await e.client.request("sessions.list",t);s&&(e.sessionsResult=s)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}const Sr=50,Yp=80,Xp=12e4;function Zp(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const i=n.map(s=>{if(!s||typeof s!="object")return null;const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>!!s);return i.length===0?null:i.join(`
13
- `)}function Ar(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Zp(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const i=Xl(n,Xp);return i.truncated?`${i.text}
12
+ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.message);return typeof s=="string"&&s.trim()&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:s.trim()}],timestamp:Date.now(),filler:!0}]),"block"}else if(t.state==="delta"){e.chatSuggestions=[];const s=Mn(t.message);if(typeof s=="string"){if(s.trim()==="NO_REPLY")return null;const o=e.chatStream??"";(!o||s.length>=o.length)&&(e.chatStream=s)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null,e.lastError=t.errorMessage??"chat error");return t.state}const Oi=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:nn,abortChatRun:oc,handleChatEvent:ac,loadChatHistory:Jt,loadOlderChatHistory:Jp,sendChatMessage:sc},Symbol.toStringTag,{value:"Module"}));async function rc(e){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const t={includeGlobal:e.sessionsIncludeGlobal??!0,includeUnknown:e.sessionsIncludeUnknown??!1},n=Ni(e.sessionsFilterActive??"",0),i=Ni(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),i>0&&(t.limit=i);const s=await e.client.request("sessions.list",t);s&&(e.sessionsResult=s)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}const Sr=50,Xp=80,Zp=12e4;function eh(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const i=n.map(s=>{if(!s||typeof s!="object")return null;const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>!!s);return i.length===0?null:i.join(`
13
+ `)}function Ar(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=eh(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const i=Xl(n,Zp);return i.truncated?`${i.text}
14
14
 
15
- … truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function eh(e){const t=[];return t.push({type:"toolcall",name:e.name,arguments:e.args??{}}),e.output&&t.push({type:"toolresult",name:e.name,text:e.output}),{role:"assistant",toolCallId:e.toolCallId,runId:e.runId,content:t,timestamp:e.startedAt}}function th(e){if(e.toolStreamOrder.length<=Sr)return;const t=e.toolStreamOrder.length-Sr,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function nh(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function ko(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),nh(e)}function ih(e,t=!1){if(t){ko(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>ko(e),Yp))}function Zo(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],ko(e)}const sh=5e3;function oh(e,t){var s;const n=t.data??{},i=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),i==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:i==="end"&&(e.compactionStatus={active:!1,startedAt:((s=e.compactionStatus)==null?void 0:s.startedAt)??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},sh))}function ah(e,t){if(!t)return;if(t.stream==="compaction"){oh(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const i=t.data??{},s=typeof i.toolCallId=="string"?i.toolCallId:"";if(!s)return;const o=typeof i.name=="string"?i.name:"tool",a=typeof i.phase=="string"?i.phase:"",r=a==="start"?i.args:void 0,u=a==="update"?Ar(i.partialResult):a==="result"?Ar(i.result):void 0,c=Date.now();let h=e.toolStreamById.get(s);h?(h.name=o,r!==void 0&&(h.args=r),u!==void 0&&(h.output=u),h.updatedAt=c):(h={toolCallId:s,runId:t.runId,sessionKey:n,name:o,args:r,output:u,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(s,h),e.toolStreamOrder.push(s)),h.message=eh(h),th(e),ih(e,a==="result")}let ci=0;function sn(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=++ci,i=()=>{const s=e.querySelector(".chat-thread");if(s){const o=getComputedStyle(s).overflowY;if(o==="auto"||o==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{n===ci&&(e.chatScrollFrame=requestAnimationFrame(()=>{if(e.chatScrollFrame=null,n!==ci)return;const s=i();if(!s)return;const o=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||o<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const r=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{if(e.chatScrollTimeout=null,n!==ci)return;const u=i();if(!u)return;const c=u.scrollHeight-u.scrollTop-u.clientHeight;(t||e.chatUserNearBottom||c<200)&&(u.scrollTop=u.scrollHeight,e.chatUserNearBottom=!0)},r)}))})}function lc(e,t=!1){e.logsScrollFrame&&cancelAnimationFrame(e.logsScrollFrame),e.updateComplete.then(()=>{e.logsScrollFrame=requestAnimationFrame(()=>{e.logsScrollFrame=null;const n=e.querySelector(".log-stream");!n||!(t||n.scrollTop<80)||(n.scrollTop=0)})})}function rh(e,t){const n=t.currentTarget;if(!n)return;const i=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=i<200,n.scrollTop<100&&e.onLoadOlder&&e.onLoadOlder()}function lh(e){const t=e.querySelector(".chat-thread");if(!t)return null;const n=t.scrollHeight,i=t.scrollTop;return()=>{const s=t.scrollHeight-n;t.scrollTop=i+s}}function ch(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function dh(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function uh(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function ph(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
15
+ … truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function th(e){const t=[];return t.push({type:"toolcall",name:e.name,arguments:e.args??{}}),e.output&&t.push({type:"toolresult",name:e.name,text:e.output}),{role:"assistant",toolCallId:e.toolCallId,runId:e.runId,content:t,timestamp:e.startedAt}}function nh(e){if(e.toolStreamOrder.length<=Sr)return;const t=e.toolStreamOrder.length-Sr,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function ih(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function ko(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),ih(e)}function sh(e,t=!1){if(t){ko(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>ko(e),Xp))}function Zo(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],ko(e)}const oh=5e3;function ah(e,t){var s;const n=t.data??{},i=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),i==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:i==="end"&&(e.compactionStatus={active:!1,startedAt:((s=e.compactionStatus)==null?void 0:s.startedAt)??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},oh))}function rh(e,t){if(!t)return;if(t.stream==="compaction"){ah(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const i=t.data??{},s=typeof i.toolCallId=="string"?i.toolCallId:"";if(!s)return;const o=typeof i.name=="string"?i.name:"tool",a=typeof i.phase=="string"?i.phase:"",r=a==="start"?i.args:void 0,u=a==="update"?Ar(i.partialResult):a==="result"?Ar(i.result):void 0,c=Date.now();let h=e.toolStreamById.get(s);h?(h.name=o,r!==void 0&&(h.args=r),u!==void 0&&(h.output=u),h.updatedAt=c):(h={toolCallId:s,runId:t.runId,sessionKey:n,name:o,args:r,output:u,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(s,h),e.toolStreamOrder.push(s)),h.message=th(h),nh(e),sh(e,a==="result")}let ci=0;function sn(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=++ci,i=()=>{const s=e.querySelector(".chat-thread");if(s){const o=getComputedStyle(s).overflowY;if(o==="auto"||o==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{n===ci&&(e.chatScrollFrame=requestAnimationFrame(()=>{if(e.chatScrollFrame=null,n!==ci)return;const s=i();if(!s)return;const o=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||o<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const r=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{if(e.chatScrollTimeout=null,n!==ci)return;const u=i();if(!u)return;const c=u.scrollHeight-u.scrollTop-u.clientHeight;(t||e.chatUserNearBottom||c<200)&&(u.scrollTop=u.scrollHeight,e.chatUserNearBottom=!0)},r)}))})}function lc(e,t=!1){e.logsScrollFrame&&cancelAnimationFrame(e.logsScrollFrame),e.updateComplete.then(()=>{e.logsScrollFrame=requestAnimationFrame(()=>{e.logsScrollFrame=null;const n=e.querySelector(".log-stream");!n||!(t||n.scrollTop<80)||(n.scrollTop=0)})})}function lh(e,t){const n=t.currentTarget;if(!n)return;const i=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=i<200,n.scrollTop<100&&e.onLoadOlder&&e.onLoadOlder()}function ch(e){const t=e.querySelector(".chat-thread");if(!t)return null;const n=t.scrollHeight,i=t.scrollTop;return()=>{const s=t.scrollHeight-n;t.scrollTop=i+s}}function dh(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function uh(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function ph(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function hh(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
16
16
  `)}
17
- `],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function hh(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
17
+ `],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function fh(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
18
18
  `)}
19
- `],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-session-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function fh(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:i}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${i}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function rt(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function At(e){return`${JSON.stringify(e,null,2).trimEnd()}
20
- `}function cc(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const a=t[o],r=t[o+1];if(typeof a=="number"){if(!Array.isArray(i))return;i[a]==null&&(i[a]=typeof r=="number"?[]:{}),i=i[a]}else{if(typeof i!="object"||i==null)return;const u=i;u[a]==null&&(u[a]=typeof r=="number"?[]:{}),i=u[a]}}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(i)&&(i[s]=n);return}typeof i=="object"&&i!=null&&(i[s]=n)}async function Oe(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});mh(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function dc(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});gh(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function gh(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function mh(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?At(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=At(e.configForm):e.configRaw=n,e.configValid=typeof t.valid=="boolean"?t.valid:null,e.configIssues=Array.isArray(t.issues)?t.issues:[],e.configFormDirty||(e.configForm=rt(t.config??{}),e.configFormOriginal=rt(t.config??{}),e.configRawOriginal=n)}async function yh(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?At(e.configForm):e.configRaw,i=(t=e.configSnapshot)==null?void 0:t.hash;if(!i){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:n,baseHash:i}),e.configFormDirty=!1,await Oe(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function on(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("cron.status",{});e.cronStatus=t}catch(t){e.cronError=String(t)}}async function jn(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t={includeDisabled:!0};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(t.agentIds=e.workspaceAgentIds),e.accountId&&(t.accountId=e.accountId);const n=await e.client.request("cron.list",t);e.cronJobs=Array.isArray(n.jobs)?n.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function uc(e){if(e.scheduleKind==="at"){const n=Date.parse(e.scheduleAt);if(!Number.isFinite(n))throw new Error("Invalid run time.");return{kind:"at",atMs:n}}if(e.scheduleKind==="every"){const n=Ni(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const i=e.everyUnit;return{kind:"every",everyMs:n*(i==="minutes"?6e4:i==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function pc(e){if(e.payloadKind==="systemEvent"){const o=e.payloadText.trim();if(!o)throw new Error("System event text required.");return{kind:"systemEvent",text:o}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel);const i=[];e.toAdmins&&i.push("admins");for(const o of e.recipients){const a=o.trim();a&&i.push(a)}i.length>0&&(n.to=i.join(","));const s=Ni(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function vh(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=uc(e.cronForm),i=pc(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),a={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:o||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!a.name)throw new Error("Name required.");await e.client.request("cron.add",a),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await jn(e),await on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function bh(e,t,n){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.update",{id:t.id,patch:{enabled:n}}),await jn(e),await on(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function wh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null,e.cronRunModalJobId=t.id,e.cronRunModalJobName=t.name||"Untitled",e.cronRunResult=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await xo(e,t.id)}catch(n){e.cronError=String(n),e.cronRunResult={status:"error",error:String(n)}}finally{e.cronBusy=!1}}}function kh(e,t){e.cronRunModalJobId&&t.jobId===e.cronRunModalJobId&&t.action==="finished"&&(e.cronRunResult={status:t.status??"unknown",durationMs:t.durationMs,summary:t.summary,outputText:t.outputText,error:t.error})}async function xh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.remove",{id:t.id}),e.cronRunsJobId===t.id&&(e.cronRunsJobId=null,e.cronRuns=[]),await jn(e),await on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function $h(e){var n;const t={name:e.name||"",description:e.description||"",agentId:e.agentId||"",enabled:e.enabled,scheduleKind:e.schedule.kind,scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"",cronTz:"",sessionTarget:e.sessionTarget||"main",wakeMode:e.wakeMode||"next-heartbeat",payloadKind:e.payload.kind,payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};if(e.schedule.kind==="at"){const i=new Date(e.schedule.atMs),s=o=>String(o).padStart(2,"0");t.scheduleAt=`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}T${s(i.getHours())}:${s(i.getMinutes())}`}else if(e.schedule.kind==="every"){const i=e.schedule.everyMs;i%864e5===0?(t.everyAmount=String(i/864e5),t.everyUnit="days"):i%36e5===0?(t.everyAmount=String(i/36e5),t.everyUnit="hours"):(t.everyAmount=String(i/6e4),t.everyUnit="minutes")}else e.schedule.kind==="cron"&&(t.cronExpr=e.schedule.expr,t.cronTz=e.schedule.tz||"");if(e.payload.kind==="systemEvent")t.payloadText=e.payload.text;else if(e.payload.kind==="agentTurn"){t.payloadText=e.payload.message,t.deliver=e.payload.deliver??!1,t.timeoutSeconds=e.payload.timeoutSeconds?String(e.payload.timeoutSeconds):"";const i=e.payload.channel??e.payload.provider;t.channel=i||"last";const s=e.payload.to||"";if(s){const o=s.split(",").map(a=>a.trim()).filter(Boolean);t.toAdmins=o.some(a=>a.toLowerCase()==="admins"),t.recipients=o.filter(a=>a.toLowerCase()!=="admins")}}return(n=e.isolation)!=null&&n.postToMainPrefix&&(t.postToMainPrefix=e.isolation.postToMainPrefix),t}async function Sh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=uc(e.cronForm),i=pc(e.cronForm),s={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:e.cronForm.agentId.trim()||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i};if(e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?s.isolation={postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:s.isolation=void 0,!s.name)throw new Error("Name required.");await e.client.request("cron.update",{id:t,patch:s}),await jn(e),await on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function xo(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("cron.runs",{id:t,limit:50});e.cronRunsJobId=t,e.cronRuns=Array.isArray(n.entries)?n.entries:[]}catch(n){e.cronError=String(n)}}async function ee(e,t){if(!(!e.client||!e.connected)&&!e.channelsLoading){e.channelsLoading=!0,e.channelsError=null;try{const n=await e.client.request("channels.status",{probe:t,timeoutMs:8e3});e.channelsSnapshot=n,e.channelsLastSuccess=Date.now()}catch(n){e.channelsError=String(n)}finally{e.channelsLoading=!1}}}async function ea(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const i=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=i.message??null,e.whatsappLoginQrDataUrl=i.qrDataUrl??null,e.whatsappLoginConnected=null}catch(i){e.whatsappLoginMessage=String(i),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function hc(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const n=await e.client.request("web.login.wait",{timeoutMs:12e4,accountId:t});e.whatsappLoginMessage=n.message??null,e.whatsappLoginConnected=n.connected??null,n.connected&&(e.whatsappLoginQrDataUrl=null,e.whatsappActiveQrAccountId=null,e.whatsappPairedPhone=n.selfPhone??null)}catch(n){e.whatsappLoginMessage=String(n),e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function fc(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t}),e.whatsappLoginMessage="Logged out.",e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null}catch(n){e.whatsappLoginMessage=String(n)}finally{e.whatsappBusy=!1}}}async function gc(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const i=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!i){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const o=rt(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const a=o.channels;(!a.whatsapp||typeof a.whatsapp!="object")&&(a.whatsapp={});const r=a.whatsapp;(!r.accounts||typeof r.accounts!="object")&&(r.accounts={});const u=r.accounts;if(u[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}u[i]={name:n,provider:"baileys"};const c=s.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const h=At(o);await e.client.request("config.set",{raw:h,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await ee(e,!0),await ea(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function mc(e,t){if(!(!e.client||!e.connected)&&!e.whatsappAccountSaving){e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=rt(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,a=o==null?void 0:o.accounts;if(!a){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(a).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!a[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete a[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(h=>{const d=h.match;return!d||d.channel!=="whatsapp"?!0:d.accountId!==t}));const u=n.hash;if(!u){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=At(i);await e.client.request("config.set",{raw:c,baseHash:u}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await ee(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Ah=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:gc,loadChannels:ee,logoutWhatsApp:fc,removeWhatsAppAccount:mc,startWhatsAppLogin:ea,waitWhatsAppLogin:hc},Symbol.toStringTag,{value:"Module"}));async function ta(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,i,s]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const o=i;e.debugModels=Array.isArray(o==null?void 0:o.models)?o==null?void 0:o.models:[],e.debugHeartbeat=s}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const na="taskmaster-access-session",yc={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function ia(){try{return localStorage.getItem(na)}catch{return null}}function vc(e){try{localStorage.setItem(na,e)}catch{}}function Ch(){try{localStorage.removeItem(na)}catch{}}async function Cr(e){if(e.client)try{const t=ia(),n=await e.client.request("access.status",{token:t});e.accessState={...e.accessState,checked:!0,hasPins:n.hasPins,hasMasterPin:n.hasMasterPin,accounts:n.accounts??[],authenticated:n.authenticated,workspace:n.workspace,master:n.master,error:null}}catch{e.accessState={...e.accessState,checked:!0,hasPins:!1,hasMasterPin:!1,accounts:[],authenticated:!0,error:null}}}async function Eh(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const i=await e.client.request("access.verify",{account:t,pin:n});i.ok&&i.token?(vc(i.token),e.accessState={...e.accessState,authenticated:!0,workspace:i.workspace??null,master:i.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:i.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function Th(e,t){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const n=await e.client.request("access.setMasterPin",{pin:t});n.ok&&n.token?(vc(n.token),e.accessState={...e.accessState,checked:!0,hasPins:!0,hasMasterPin:!0,authenticated:!0,workspace:null,master:!0,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}}}async function _h(e,t,n){if(!e.client)return!1;try{return(await e.client.request("access.setAccountPin",{workspace:t,pin:n})).ok}catch{return!1}}async function Mh(e){const t=ia();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}Ch(),e.accessState={...yc,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}const Ph=2e3,Ih=new Set(["trace","debug","info","warn","error","fatal"]);function Lh(e){if(typeof e!="string")return null;const t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;try{const n=JSON.parse(t);return!n||typeof n!="object"?null:n}catch{return null}}function Rh(e){if(typeof e!="string")return null;const t=e.toLowerCase();return Ih.has(t)?t:null}function bc(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,i=typeof t.time=="string"?t.time:typeof(n==null?void 0:n.date)=="string"?n==null?void 0:n.date:null,s=Rh((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),o=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,a=Lh(o);let r=null;a&&(typeof a.subsystem=="string"?r=a.subsystem:typeof a.module=="string"&&(r=a.module)),!r&&o&&o.length<120&&(r=o);let u=null;return typeof t[1]=="string"?u=t[1]:!a&&typeof t[0]=="string"?u=t[0]:typeof t.message=="string"&&(u=t.message),{raw:e,time:i,level:s,subsystem:r,message:u??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Gt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const i=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes,accessToken:ia()??void 0}),o=(Array.isArray(i.lines)?i.lines.filter(r=>typeof r=="string"):[]).map(bc),a=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=a?o:[...e.logsEntries,...o].slice(-Ph),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const Dh=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Gt,parseLogLine:bc},Symbol.toStringTag,{value:"Module"}));const wc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ue,n:Ai,Gx:Er,Gy:Tr,a:Fs,d:Us,h:Bh}=wc,Ct=32,sa=64,Nh=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},re=(e="")=>{const t=new Error(e);throw Nh(t,re),t},Oh=e=>typeof e=="bigint",Fh=e=>typeof e=="string",Uh=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",ct=(e,t,n="")=>{const i=Uh(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const a=n&&`"${n}" `,r=o?` of length ${t}`:"",u=i?`length=${s}`:`type=${typeof e}`;re(a+"expected Uint8Array"+r+", got "+u)}return e},rs=e=>new Uint8Array(e),kc=e=>Uint8Array.from(e),xc=(e,t)=>e.toString(16).padStart(t,"0"),$c=e=>Array.from(ct(e)).map(t=>xc(t,2)).join(""),He={_0:48,_9:57,A:65,F:70,a:97,f:102},_r=e=>{if(e>=He._0&&e<=He._9)return e-He._0;if(e>=He.A&&e<=He.F)return e-(He.A-10);if(e>=He.a&&e<=He.f)return e-(He.a-10)},Sc=e=>{const t="hex invalid";if(!Fh(e))return re(t);const n=e.length,i=n/2;if(n%2)return re(t);const s=rs(i);for(let o=0,a=0;o<i;o++,a+=2){const r=_r(e.charCodeAt(a)),u=_r(e.charCodeAt(a+1));if(r===void 0||u===void 0)return re(t);s[o]=r*16+u}return s},Ac=()=>globalThis==null?void 0:globalThis.crypto,Wh=()=>{var e;return((e=Ac())==null?void 0:e.subtle)??re("crypto.subtle must be defined, consider polyfill")},zn=(...e)=>{const t=rs(e.reduce((i,s)=>i+ct(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},Kh=(e=Ct)=>Ac().getRandomValues(rs(e)),Fi=BigInt,gt=(e,t,n,i="bad number: out of range")=>Oh(e)&&t<=e&&e<n?e:re(i),R=(e,t=ue)=>{const n=e%t;return n>=0n?n:t+n},Cc=e=>R(e,Ai),zh=(e,t)=>{(e===0n||t<=0n)&&re("no inverse n="+e+" mod="+t);let n=R(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const a=i/n,r=i%n,u=s-o*a;i=n,n=r,s=o,o=u}return i===1n?R(s,t):re("no inverse")},Hh=e=>{const t=Mc[e];return typeof t!="function"&&re("hashes."+e+" not set"),t},Ws=e=>e instanceof Et?e:re("Point expected"),$o=2n**256n,Ne=class Ne{constructor(t,n,i,s){q(this,"X");q(this,"Y");q(this,"Z");q(this,"T");const o=$o;this.X=gt(t,0n,o),this.Y=gt(n,0n,o),this.Z=gt(i,1n,o),this.T=gt(s,0n,o),Object.freeze(this)}static CURVE(){return wc}static fromAffine(t){return new Ne(t.x,t.y,1n,R(t.x*t.y))}static fromBytes(t,n=!1){const i=Us,s=kc(ct(t,Ct)),o=t[31];s[31]=o&-129;const a=Tc(s);gt(a,0n,n?$o:ue);const u=R(a*a),c=R(u-1n),h=R(i*u+1n);let{isValid:d,value:p}=jh(c,h);d||re("bad point: y not sqrt");const v=(p&1n)===1n,$=(o&128)!==0;return!n&&p===0n&&$&&re("bad point: x==0, isLastByteOdd"),$!==v&&(p=R(-p)),new Ne(p,a,1n,R(p*a))}static fromHex(t,n){return Ne.fromBytes(Sc(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Fs,n=Us,i=this;if(i.is0())return re("bad point: ZERO");const{X:s,Y:o,Z:a,T:r}=i,u=R(s*s),c=R(o*o),h=R(a*a),d=R(h*h),p=R(u*t),v=R(h*R(p+c)),$=R(d+R(n*R(u*c)));if(v!==$)return re("bad point: equation left != right (1)");const S=R(s*o),M=R(a*r);return S!==M?re("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:a,Z:r}=Ws(t),u=R(n*r),c=R(o*s),h=R(i*r),d=R(a*s);return u===c&&h===d}is0(){return this.equals(qt)}negate(){return new Ne(R(-this.X),this.Y,this.Z,R(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=Fs,o=R(t*t),a=R(n*n),r=R(2n*R(i*i)),u=R(s*o),c=t+n,h=R(R(c*c)-o-a),d=u+a,p=d-r,v=u-a,$=R(h*p),S=R(d*v),M=R(h*v),y=R(p*d);return new Ne($,S,y,M)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:r,Z:u,T:c}=Ws(t),h=Fs,d=Us,p=R(n*a),v=R(i*r),$=R(o*d*c),S=R(s*u),M=R((n+i)*(a+r)-p-v),y=R(S-$),b=R(S+$),k=R(v-h*p),A=R(M*y),E=R(b*k),T=R(M*k),P=R(y*b);return new Ne(A,E,P,T)}subtract(t){return this.add(Ws(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return qt;if(gt(t,1n,Ai),t===1n)return this;if(this.equals(Tt))return sf(t).p;let i=qt,s=Tt;for(let o=this;t>0n;o=o.double(),t>>=1n)t&1n?i=i.add(o):n&&(s=s.add(o));return i}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:i}=this;if(this.equals(qt))return{x:0n,y:1n};const s=zh(i,ue);R(i*s)!==1n&&re("invalid inverse");const o=R(t*s),a=R(n*s);return{x:o,y:a}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Ec(n);return i[31]|=t&1n?128:0,i}toHex(){return $c(this.toBytes())}clearCofactor(){return this.multiply(Fi(Bh),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Ai/2n,!1).double();return Ai%2n&&(t=t.add(this)),t.is0()}};q(Ne,"BASE"),q(Ne,"ZERO");let Et=Ne;const Tt=new Et(Er,Tr,1n,R(Er*Tr)),qt=new Et(0n,1n,1n,0n);Et.BASE=Tt;Et.ZERO=qt;const Ec=e=>Sc(xc(gt(e,0n,$o),sa)).reverse(),Tc=e=>Fi("0x"+$c(kc(ct(e)).reverse())),Ie=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=ue;return n},qh=e=>{const n=e*e%ue*e%ue,i=Ie(n,2n)*n%ue,s=Ie(i,1n)*e%ue,o=Ie(s,5n)*s%ue,a=Ie(o,10n)*o%ue,r=Ie(a,20n)*a%ue,u=Ie(r,40n)*r%ue,c=Ie(u,80n)*u%ue,h=Ie(c,80n)*u%ue,d=Ie(h,10n)*o%ue;return{pow_p_5_8:Ie(d,2n)*e%ue,b2:n}},Mr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,jh=(e,t)=>{const n=R(t*t*t),i=R(n*n*t),s=qh(e*i).pow_p_5_8;let o=R(e*n*s);const a=R(t*o*o),r=o,u=R(o*Mr),c=a===e,h=a===R(-e),d=a===R(-e*Mr);return c&&(o=r),(h||d)&&(o=u),(R(o)&1n)===1n&&(o=R(-o)),{isValid:c||h,value:o}},So=e=>Cc(Tc(e)),oa=(...e)=>Mc.sha512Async(zn(...e)),Gh=(...e)=>Hh("sha512")(zn(...e)),_c=e=>{const t=e.slice(0,Ct);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Ct,sa),i=So(t),s=Tt.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},aa=e=>oa(ct(e,Ct)).then(_c),Vh=e=>_c(Gh(ct(e,Ct))),Qh=e=>aa(e).then(t=>t.pointBytes),Jh=e=>oa(e.hashable).then(e.finish),Yh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=So(t),a=Tt.multiply(o).toBytes();return{hashable:zn(a,i,n),finish:c=>{const h=Cc(o+So(c)*s);return ct(zn(a,Ec(h)),sa)}}},Xh=async(e,t)=>{const n=ct(e),i=await aa(t),s=await oa(i.prefix,n);return Jh(Yh(i,s,n))},Mc={sha512Async:async e=>{const t=Wh(),n=zn(e);return rs(await t.digest("SHA-512",n.buffer))},sha512:void 0},Zh=(e=Kh(Ct))=>e,ef={getExtendedPublicKeyAsync:aa,getExtendedPublicKey:Vh,randomSecretKey:Zh},Ui=8,tf=256,Pc=Math.ceil(tf/Ui)+1,Ao=2**(Ui-1),nf=()=>{const e=[];let t=Tt,n=t;for(let i=0;i<Pc;i++){n=t,e.push(n);for(let s=1;s<Ao;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Pr;const Ir=(e,t)=>{const n=t.negate();return e?n:t},sf=e=>{const t=Pr||(Pr=nf());let n=qt,i=Tt;const s=2**Ui,o=s,a=Fi(s-1),r=Fi(Ui);for(let u=0;u<Pc;u++){let c=Number(e&a);e>>=r,c>Ao&&(c-=o,e+=1n);const h=u*Ao,d=h,p=h+Math.abs(c)-1,v=u%2!==0,$=c<0;c===0?i=i.add(Ir(v,t[d])):n=n.add(Ir($,t[p]))}return e!==0n&&re("invalid wnaf"),{p:n,f:i}},Ks="taskmaster-device-identity-v1";function Co(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Ic(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)s[o]=i.charCodeAt(o);return s}function of(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Lc(e){const t=await crypto.subtle.digest("SHA-256",e);return of(new Uint8Array(t))}async function af(){const e=ef.randomSecretKey(),t=await Qh(e);return{deviceId:await Lc(t),publicKey:Co(t),privateKey:Co(e)}}async function rf(){try{const n=localStorage.getItem(Ks);if(n){const i=JSON.parse(n);if((i==null?void 0:i.version)===1&&typeof i.deviceId=="string"&&typeof i.publicKey=="string"&&typeof i.privateKey=="string"){const s=await Lc(Ic(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(Ks,JSON.stringify(o)),{deviceId:s,publicKey:i.publicKey,privateKey:i.privateKey}}return{deviceId:i.deviceId,publicKey:i.publicKey,privateKey:i.privateKey}}}}catch{}const e=await af(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Ks,JSON.stringify(t)),e}async function lf(e,t){const n=Ic(e),i=new TextEncoder().encode(t),s=await Xh(i,n);return Co(s)}const Rc="taskmaster.device.auth.v1";function ra(e){return e.trim()}function cf(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const i=n.trim();i&&t.add(i)}return[...t].sort()}function la(){try{const e=window.localStorage.getItem(Rc);if(!e)return null;const t=JSON.parse(e);return!t||t.version!==1||!t.deviceId||typeof t.deviceId!="string"||!t.tokens||typeof t.tokens!="object"?null:t}catch{return null}}function Dc(e){try{window.localStorage.setItem(Rc,JSON.stringify(e))}catch{}}function df(e){const t=la();if(!t||t.deviceId!==e.deviceId)return null;const n=ra(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function uf(e){const t=ra(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=la();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:cf(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Dc(n),s}function pf(e){const t=la();if(!t||t.deviceId!==e.deviceId)return;const n=ra(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Dc(i)}async function ca(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t!=null&&t.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n==null?void 0:n.pending)?n.pending:[],paired:Array.isArray(n==null?void 0:n.paired)?n.paired:[]}}catch(n){t!=null&&t.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function da(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t!=null&&t.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t!=null&&t.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function hf(e){return{method:"exec.approvals.get",params:{}}}async function ff(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=hf(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);gf(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function gf(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=rt(t.file??{}))}async function Bc(e){if(!(!e.client||!e.connected)&&!e.presenceLoading){e.presenceLoading=!0,e.presenceError=null,e.presenceStatus=null;try{const t=await e.client.request("system-presence",{});Array.isArray(t)?(e.presenceEntries=t,e.presenceStatus=t.length===0?"No instances yet.":null):(e.presenceEntries=[],e.presenceStatus="No presence payload.")}catch(t){e.presenceError=String(t)}finally{e.presenceLoading=!1}}}function lt(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function Ye(e){return e instanceof Error?e.message:String(e)}function Hn(){return{name:"",skillContent:"",references:[]}}async function Je(e,t){if(t!=null&&t.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{const n=await e.client.request("skills.status",{});n&&(e.skillsReport=n)}catch(n){e.skillsError=Ye(n)}finally{e.skillsLoading=!1}}}function Nc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Oc(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,enabled:n}),await Je(e),lt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=Ye(i);e.skillsError=s,lt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Fc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const n=e.skillEdits[t]??"";await e.client.request("skills.update",{skillKey:t,apiKey:n}),await Je(e),lt(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=Ye(n);e.skillsError=i,lt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Uc(e,t,n,i){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const s=await e.client.request("skills.install",{name:n,installId:i,timeoutMs:12e4});await Je(e),lt(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=Ye(s);e.skillsError=o,lt(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}async function Wc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});n&&(e.skillDetail=n,e.skillDetailTab="SKILL.md")}catch(n){e.skillsError=Ye(n)}}function Kc(e){e.skillDetail=null,e.skillDetailTab=""}function zc(e,t){e.skillDetailTab=t}async function Hc(e){if(e.skillAddModal=!0,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[],!(!e.client||!e.connected))try{const t=await e.client.request("skills.drafts",{});t&&(e.skillDrafts=t.drafts)}catch{}}function qc(e){e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[]}function jc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))},e.skillAddFormSource="draft"}async function Gc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))},e.skillAddFormSource="installed",await ua(e)}async function ua(e){if(!e.client||!e.connected)return;const t=e.skillAddForm;if(!(!t.name.trim()||!t.skillContent.trim())){e.skillsBusyKey="__add__",e.skillsError=null;try{const n=t.references.filter(s=>s.name.trim()&&s.content.trim()).map(s=>({name:s.name.trim(),content:s.content})),i=t.name.trim();e.skillAddFormSource==="installed"?(await e.client.request("skills.create",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],await Je(e),lt(e,i,{kind:"success",message:"Skill saved — active on next message"})):(await e.client.request("skills.saveDraft",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],lt(e,i,{kind:"success",message:"Draft saved"}))}catch(n){e.skillsError=Ye(n)}finally{e.skillsBusyKey=null}}}async function Vc(e,t){if(!(!e.client||!e.connected))try{await e.client.request("skills.deleteDraft",{name:t}),e.skillDrafts=e.skillDrafts.filter(n=>n.name!==t)}catch(n){e.skillsError=Ye(n)}}async function Qc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});if(!n)return;e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i}))},e.skillAddFormSource="installed",e.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=Ye(n)}}function Jc(e,t){const n=e.skillDetail;n&&(e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i}))},e.skillAddFormSource="installed",e.skillEditTab=t&&t!=="SKILL.md"?t:"SKILL.md",e.skillDetail=null,e.skillDetailTab="",e.skillAddModal=!0,e.skillDrafts=[])}function Yc(e,t,n){e.skillAddForm={...e.skillAddForm,references:e.skillAddForm.references.map(i=>i.name===t?{...i,content:n}:i)}}function Xc(e,t){e.skillEditTab=t}async function Zc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await Je(e)}catch(n){e.skillsError=Ye(n)}finally{e.skillsBusyKey=null}}}const mf=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:qc,closeSkillDetail:Kc,deleteDraft:Vc,deleteSkill:Zc,editDetailSkill:Jc,editSkill:Qc,emptyAddForm:Hn,importDraft:jc,installDraft:Gc,installSkill:Uc,loadSkills:Je,openAddSkillModal:Hc,saveNewSkill:ua,saveSkillApiKey:Fc,setEditTab:Xc,setSkillDetailTab:zc,updateFormReference:Yc,updateSkillEdit:Nc,updateSkillEnabled:Oc,viewSkillDetail:Wc},Symbol.toStringTag,{value:"Module"})),ed={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},td=new Map(Object.entries(ed).map(([e,t])=>[t,e]));function ls(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function qn(e){if(!e)return"/";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}function yf(e,t=""){const n=ls(t),i=ed[e];return n?`${n}${i}`:i}function nd(e,t=""){const n=ls(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=qn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":td.get(s)??null}function vf(e){let t=qn(e);if(t.endsWith("/index.html")&&(t=qn(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let i=0;i<n.length;i++){const s=`/${n.slice(i).join("/")}`.toLowerCase();if(td.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function bf(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function pa(e){return e==="system"?bf():e}const di=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,wf=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,ui=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},kf=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var c;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,a=s,r=wf();if(!!a.startViewTransition&&!r){let h=.5,d=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")h=di(n.pointerClientX/window.innerWidth),d=di(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(h=di((p.left+p.width/2)/window.innerWidth),d=di((p.top+p.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${h*100}%`),o.style.setProperty("--theme-switch-y",`${d*100}%`),o.classList.add("theme-transition");try{const p=(c=a.startViewTransition)==null?void 0:c.call(a,()=>{t()});p!=null&&p.finished?p.finished.finally(()=>ui(o)):ui(o)}catch{ui(o),t()}return}t(),ui(o)},xf=2e3;async function Pn(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const n={cursors:t!=null&&t.reset?void 0:e.sessionLogsCursors,limit:500};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(n.agents=e.workspaceAgentIds);const s=await e.client.request("sessions.transcript",n),o=Array.isArray(s.entries)?s.entries:[],a=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=a?o:[...e.sessionLogsEntries,...o].slice(-xf),s.cursors&&(e.sessionLogsCursors=s.cursors),Array.isArray(s.agents)&&(e.sessionLogsAgents=s.agents),e.sessionLogsLastFetchAt=Date.now()}catch(n){e.sessionLogsError=String(n)}finally{t!=null&&t.quiet||(e.sessionLogsLoading=!1)}}}const id=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:Pn},Symbol.toStringTag,{value:"Module"}));async function sd(e,t){if(!(!e.client||!e.connected))try{const n={},i=await e.client.request("memory.audit",n);i!=null&&i.ok&&(e.auditEntries=i.entries??[])}catch{}}async function $f(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function Fe(e){return e instanceof Error?e.message:String(e)}let pi=null;function an(e,t){pi&&clearTimeout(pi),e.filesMessage={kind:"success",text:t},pi=setTimeout(()=>{e.filesMessage=null,pi=null},3e3)}async function rn(e,t){if(!(!e.client||!e.connected)){if(!t){e.filesTree=[],e.filesRoot="";return}if(!e.filesLoading){e.filesLoading=!0,e.filesError=null;try{const n={};t&&(n.agentId=t);const i=await e.client.request("files.tree",n);i!=null&&i.tree&&(e.filesTree=i.tree,e.filesRoot=i.root??"")}catch(n){e.filesError=Fe(n)}finally{e.filesLoading=!1}}}}async function Sf(e,t,n){e.filesSelectedPaths=new Set([t]),await od(e,t,n)}async function Af(e,t,n){const i=new Set(e.filesSelectedPaths);if(i.has(t)?i.delete(t):i.add(t),e.filesSelectedPaths=i,i.size===1){const s=[...i][0];await od(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Cf(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let i=0,s="";for(const o of n)try{await ad(e,o,t),i++}catch(a){s=Fe(a)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:an(e,`${i} file${i!==1?"s":""} downloaded`)}async function Ef(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await Pf(e,t,o,i)}async function od(e,t,n){if(!(!e.client||!e.connected)){e.filesSelectedPath=t,e.filesPreviewLoading=!0,e.filesPreviewContent=null,e.filesPreviewBinary=!1,e.filesPreviewSize=null;try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.read",i);e.filesPreviewContent=(s==null?void 0:s.content)??null,e.filesPreviewBinary=(s==null?void 0:s.binary)??!1,e.filesPreviewSize=(s==null?void 0:s.size)??null}catch(i){e.filesError=Fe(i)}finally{e.filesPreviewLoading=!1}}}async function ad(e,t,n){if(!(!e.client||!e.connected))try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.download",i);if(!(s!=null&&s.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(s.base64),c=>c.charCodeAt(0)),a=new Blob([o]),r=URL.createObjectURL(a),u=document.createElement("a");u.href=r,u.download=s.name??t.split("/").pop()??"download",document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(r)}catch(i){e.filesMessage={kind:"error",text:Fe(i)}}}async function Tf(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const a of n)try{const r=await a.arrayBuffer(),u=btoa(new Uint8Array(r).reduce((h,d)=>h+String.fromCharCode(d),"")),c={path:t,name:a.name,data:u};i&&(c.agentId=i),await e.client.request("files.upload",c),s++}catch(r){o=Fe(r)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:an(e,`${s} file${s!==1?"s":""} uploaded`),await rn(e,i)}async function _f(e,t,n,i){if(!e.client||!e.connected)return;e.filesMessage=null;const s=t==="."?n:`${t}/${n}`;try{const o={path:s};i&&(o.agentId=i),await e.client.request("files.mkdir",o),an(e,`Created ${s}`),await rn(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:Fe(o)}}}async function Mf(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={path:t};n&&(i.agentId=n),await e.client.request("files.delete",i),an(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await rn(e,n)}catch(i){e.filesMessage={kind:"error",text:Fe(i)}}}}async function Pf(e,t,n,i){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={from:t,to:n};i&&(s.agentId=i),await e.client.request("files.move",s),an(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await rn(e,i)}catch(s){e.filesMessage={kind:"error",text:Fe(s)}}}}async function cs(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const i=await e.client.request("memory.status",n);i!=null&&i.ok&&(e.filesMemoryStatus={dirty:i.dirty??!1,syncing:i.syncing,syncProgress:i.syncProgress,files:i.files??0,chunks:i.chunks??0,model:i.model,embeddingState:i.embeddingState})}catch{}}async function If(e,t){if(!(!e.client||!e.connected)&&!e.filesReindexBusy){e.filesReindexBusy=!0,e.filesMessage=null;try{const n={force:!0};t&&(n.agentId=t);const i=await e.client.request("memory.reindex",n),s=(i==null?void 0:i.files)??0,o=(i==null?void 0:i.chunks)??0;an(e,`Re-indexed: ${s} files, ${o} chunks`),await cs(e,t)}catch(n){e.filesMessage={kind:"error",text:Fe(n)}}finally{e.filesReindexBusy=!1}}}function Lf(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n,e.filesCurrentDir=t}async function Rf(e,t,n){if(!(!e.client||!e.connected)){if(!t.trim()){e.filesSearchResults=null;return}e.filesSearchLoading=!0,e.filesSearchResults=null;try{const i={query:t.trim(),maxResults:20};n&&(i.agentId=n);const s=await e.client.request("memory.search",i);e.filesSearchResults=(s==null?void 0:s.results)??[]}catch(i){e.filesMessage={kind:"error",text:Fe(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Df(e){e.filesSearchQuery="",e.filesSearchResults=null}function Bf(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{da(e,{quiet:!0})},5e3))}function Nf(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function ha(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Gt(e,{quiet:!0})},2e3))}function fa(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function ga(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||Pn(e,{quiet:!0})},2e3))}function ma(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function ya(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ta(e)},3e3))}function va(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Of(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{sd(e)},3e4))}function Ff(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function Uf(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{const t=e;t.filesPage&&cs(t,t.filesResolvedAgentId)},3e3))}function Wf(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function ot(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,Mp(n),t.theme!==e.theme&&(e.theme=t.theme,ds(e,pa(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function rd(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&ot(e,{...e.settings,lastActiveSessionKey:n})}function Kf(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),i=t.get("password"),s=t.get("session"),o=t.get("gatewayUrl");let a=!1;if(n!=null){const u=n.trim();u&&u!==e.settings.token&&ot(e,{...e.settings,token:u}),t.delete("token"),a=!0}if(i!=null){const u=i.trim();u&&(e.password=u),t.delete("password"),a=!0}if(s!=null){const u=s.trim();u&&(e.sessionKey=u,ot(e,{...e.settings,sessionKey:u,lastActiveSessionKey:u}))}if(o!=null){const u=o.trim();u&&u!==e.settings.gatewayUrl&&ot(e,{...e.settings,gatewayUrl:u}),t.delete("gatewayUrl"),a=!0}if(!a)return;const r=new URL(window.location.href);r.search=t.toString(),window.history.replaceState({},"",r.toString())}function zf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ga(e):ha(e):(fa(e),ma(e)),t==="debug"?ya(e):va(e),Wi(e),cd(e,t,!1)}function Hf(e,t,n){kf({nextTheme:t,applyTheme:()=>{e.theme=t,ot(e,{...e.settings,theme:t}),ds(e,pa(t))},context:n,currentTheme:e.theme})}async function Wi(e){if(e.tab==="overview"&&await dd(e),e.tab==="channels"&&await Yf(e),e.tab==="instances"&&await Bc(e),e.tab==="cron"&&await ud(e),e.tab==="skills"&&await Je(e),e.tab==="nodes"&&(await da(e),await ca(e),await Oe(e),await ff(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await ng(e),sn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await dc(e),await Oe(e)),e.tab==="debug"&&(await ta(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await ae(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>id);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Gt(e,{reset:!0});lc(e,!0)}}function qf(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?ls(e):vf(window.location.pathname)}function jf(e){e.theme=e.settings.theme??"system",ds(e,pa(e.theme))}function ds(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Gf(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;if(e.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaHandler=n=>{e.theme==="system"&&ds(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Vf(e){if(!e.themeMedia||!e.themeMediaHandler)return;if(typeof e.themeMedia.removeEventListener=="function"){e.themeMedia.removeEventListener("change",e.themeMediaHandler);return}e.themeMedia.removeListener(e.themeMediaHandler),e.themeMedia=null,e.themeMediaHandler=null}function Qf(e,t){if(typeof window>"u")return;const n=nd(window.location.pathname,e.basePath)??"chat";ld(e,n),cd(e,n,t)}function Jf(e){var s;if(typeof window>"u")return;const t=nd(window.location.pathname,e.basePath);if(!t)return;const i=(s=new URL(window.location.href).searchParams.get("session"))==null?void 0:s.trim();i&&(e.sessionKey=i,ot(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),ld(e,t)}function ld(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ga(e):ha(e):(fa(e),ma(e)),t==="debug"?ya(e):va(e),e.connected&&Wi(e)}function cd(e,t,n){if(typeof window>"u")return;const i=qn(yf(t,e.basePath)),s=qn(window.location.pathname),o=new URL(window.location.href);t==="chat"&&e.sessionKey?o.searchParams.set("session",e.sessionKey):o.searchParams.delete("session"),s!==i&&(o.pathname=i),n?window.history.replaceState({},"",o.toString()):window.history.pushState({},"",o.toString())}async function dd(e){await Promise.all([ee(e,!1),Bc(e),rc(e),on(e),ta(e)])}async function Yf(e){await Promise.all([ee(e,!0),dc(e),Oe(e)])}async function ud(e){await Promise.all([ee(e,!1),on(e),jn(e)])}function pd(e){return e.chatSending||!!e.chatRunId}function Xf(e){const t=e.trim();if(!t)return!1;const n=t.toLowerCase();return n==="/stop"?!0:n==="stop"||n==="esc"||n==="abort"||n==="wait"||n==="exit"}async function hd(e){e.connected&&(e.chatMessage="",await oc(e))}function Zf(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:as(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],sn(e))}async function fd(e,t,n){var s,o;Zo(e);const i=await sc(e,t,n==null?void 0:n.attachments);return!i&&(n==null?void 0:n.previousDraft)!=null&&(e.chatMessage=n.previousDraft),!i&&(n!=null&&n.previousAttachments)&&(e.chatAttachments=n.previousAttachments),i&&rd(e,e.sessionKey),i&&(n!=null&&n.restoreDraft)&&((s=n.previousDraft)!=null&&s.trim())&&(e.chatMessage=n.previousDraft),i&&(n!=null&&n.restoreAttachments)&&((o=n.previousAttachments)!=null&&o.length)&&(e.chatAttachments=n.previousAttachments),sn(e),i&&!e.chatRunId&&gd(e),i}async function gd(e){if(!e.connected||pd(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await fd(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function eg(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function tg(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],a=t==null?o:[],r=a.length>0;if(!(!s&&!r)){if(Xf(s)){await hd(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[],Ip(e.selectedWorkspace??"",e.sessionKey)),pd(e)){Zf(e,s,a);return}await fd(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:r?a:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function ng(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,nn);await Promise.all([Jt(t,{limit:n}),rc(t),Eo(e)]),sn(e,!0)}const ig=gd;function sg(e){var s,o,a;const t=Jl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((a=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:a.trim())||"main"}function og(e,t){const n=ls(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Eo(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=sg(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=og(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),o=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const L={messageSquare:l`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:l`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:l`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,unlink:l`<svg viewBox="0 0 24 24"><path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" x2="8" y1="2" y2="5"/><line x1="2" x2="5" y1="8" y2="8"/><line x1="16" x2="16" y1="19" y2="22"/><line x1="19" x2="22" y1="16" y2="16"/></svg>`,radio:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:l`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:l`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:l`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:l`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:l`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:l`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:l`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,users:l`<svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,user:l`<svg viewBox="0 0 24 24"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>`,menu:l`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:l`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:l`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:l`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:l`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:l`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:l`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:l`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,rotateCw:l`<svg viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,download:l`<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wrench:l`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:l`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:l`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:l`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:l`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,globeOff:l`<svg viewBox="0 0 24 24"><path d="M21.54 15H17"/><path d="M7 3.34V5a3 3 0 0 0 3 3 2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17"/><path d="M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05"/><circle cx="12" cy="12" r="10"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,image:l`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:l`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:l`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,puzzle:l`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`,info:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,send:l`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`,slidersHorizontal:l`<svg viewBox="0 0 24 24"><line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/></svg>`,square:l`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:l`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:l`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,trash:l`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,mic:l`<svg viewBox="0 0 24 24"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>`,chevronDown:l`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:l`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`,wifi:l`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M2 8.82a15 15 0 0 1 20 0"/><path d="M5 12.859a10 10 0 0 1 14 0"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/></svg>`,wifiOff:l`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/><path d="M5 12.859a10 10 0 0 1 5.17-2.69"/><path d="M13.41 10.28a10 10 0 0 1 5.59 2.58"/><path d="M2 8.82a15 15 0 0 1 4.17-2.65"/><path d="M10.66 5c4.01-.36 8.14.9 11.34 3.76"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,power:l`<svg viewBox="0 0 24 24"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"/><line x1="12" x2="12" y1="2" y2="12"/></svg>`,powerOff:l`<svg viewBox="0 0 24 24"><path d="M18.36 6.64A9 9 0 0 1 20.77 15"/><path d="M6.16 6.16a9 9 0 1 0 12.68 12.68"/><path d="M12 2v4"/><path d="m2 2 20 20"/></svg>`},ag=l`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,rg=l`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>`,lg=l`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path><line x1="12" y1="2" x2="12" y2="12"></line></svg>`;let Lr=!1;function cg(){Lr||(Lr=!0,document.addEventListener("click",e=>{const t=document.getElementById("nav-burger-toggle");if(!(t!=null&&t.checked))return;const n=t.closest(".setup-header");n!=null&&n.contains(e.target)||(t.checked=!1)}))}function It(e,t){var d;const n=(p,v)=>p===e?l`<span class="sp-page-nav-current">${p}</span>`:l`<a href=${v}>${p}</a>`,i=l`
19
+ `],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-session-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function gh(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:i}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${i}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function lt(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function At(e){return`${JSON.stringify(e,null,2).trimEnd()}
20
+ `}function cc(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const a=t[o],r=t[o+1];if(typeof a=="number"){if(!Array.isArray(i))return;i[a]==null&&(i[a]=typeof r=="number"?[]:{}),i=i[a]}else{if(typeof i!="object"||i==null)return;const u=i;u[a]==null&&(u[a]=typeof r=="number"?[]:{}),i=u[a]}}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(i)&&(i[s]=n);return}typeof i=="object"&&i!=null&&(i[s]=n)}async function Fe(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});yh(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function dc(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});mh(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function mh(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function yh(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?At(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=At(e.configForm):e.configRaw=n,e.configValid=typeof t.valid=="boolean"?t.valid:null,e.configIssues=Array.isArray(t.issues)?t.issues:[],e.configFormDirty||(e.configForm=lt(t.config??{}),e.configFormOriginal=lt(t.config??{}),e.configRawOriginal=n)}async function vh(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?At(e.configForm):e.configRaw,i=(t=e.configSnapshot)==null?void 0:t.hash;if(!i){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:n,baseHash:i}),e.configFormDirty=!1,await Fe(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function on(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("cron.status",{});e.cronStatus=t}catch(t){e.cronError=String(t)}}async function jn(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t={includeDisabled:!0};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(t.agentIds=e.workspaceAgentIds),e.accountId&&(t.accountId=e.accountId);const n=await e.client.request("cron.list",t);e.cronJobs=Array.isArray(n.jobs)?n.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function uc(e){if(e.scheduleKind==="at"){const n=Date.parse(e.scheduleAt);if(!Number.isFinite(n))throw new Error("Invalid run time.");return{kind:"at",atMs:n}}if(e.scheduleKind==="every"){const n=Ni(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const i=e.everyUnit;return{kind:"every",everyMs:n*(i==="minutes"?6e4:i==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function pc(e){if(e.payloadKind==="systemEvent"){const o=e.payloadText.trim();if(!o)throw new Error("System event text required.");return{kind:"systemEvent",text:o}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel);const i=[];e.toAdmins&&i.push("admins");for(const o of e.recipients){const a=o.trim();a&&i.push(a)}i.length>0&&(n.to=i.join(","));const s=Ni(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function bh(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=uc(e.cronForm),i=pc(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),a={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:o||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!a.name)throw new Error("Name required.");await e.client.request("cron.add",a),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await jn(e),await on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function wh(e,t,n){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.update",{id:t.id,patch:{enabled:n}}),await jn(e),await on(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function kh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null,e.cronRunModalJobId=t.id,e.cronRunModalJobName=t.name||"Untitled",e.cronRunResult=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await xo(e,t.id)}catch(n){e.cronError=String(n),e.cronRunResult={status:"error",error:String(n)}}finally{e.cronBusy=!1}}}function xh(e,t){e.cronRunModalJobId&&t.jobId===e.cronRunModalJobId&&t.action==="finished"&&(e.cronRunResult={status:t.status??"unknown",durationMs:t.durationMs,summary:t.summary,outputText:t.outputText,error:t.error})}async function $h(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.remove",{id:t.id}),e.cronRunsJobId===t.id&&(e.cronRunsJobId=null,e.cronRuns=[]),await jn(e),await on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function Sh(e){var n;const t={name:e.name||"",description:e.description||"",agentId:e.agentId||"",enabled:e.enabled,scheduleKind:e.schedule.kind,scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"",cronTz:"",sessionTarget:e.sessionTarget||"main",wakeMode:e.wakeMode||"next-heartbeat",payloadKind:e.payload.kind,payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};if(e.schedule.kind==="at"){const i=new Date(e.schedule.atMs),s=o=>String(o).padStart(2,"0");t.scheduleAt=`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}T${s(i.getHours())}:${s(i.getMinutes())}`}else if(e.schedule.kind==="every"){const i=e.schedule.everyMs;i%864e5===0?(t.everyAmount=String(i/864e5),t.everyUnit="days"):i%36e5===0?(t.everyAmount=String(i/36e5),t.everyUnit="hours"):(t.everyAmount=String(i/6e4),t.everyUnit="minutes")}else e.schedule.kind==="cron"&&(t.cronExpr=e.schedule.expr,t.cronTz=e.schedule.tz||"");if(e.payload.kind==="systemEvent")t.payloadText=e.payload.text;else if(e.payload.kind==="agentTurn"){t.payloadText=e.payload.message,t.deliver=e.payload.deliver??!1,t.timeoutSeconds=e.payload.timeoutSeconds?String(e.payload.timeoutSeconds):"";const i=e.payload.channel??e.payload.provider;t.channel=i||"last";const s=e.payload.to||"";if(s){const o=s.split(",").map(a=>a.trim()).filter(Boolean);t.toAdmins=o.some(a=>a.toLowerCase()==="admins"),t.recipients=o.filter(a=>a.toLowerCase()!=="admins")}}return(n=e.isolation)!=null&&n.postToMainPrefix&&(t.postToMainPrefix=e.isolation.postToMainPrefix),t}async function Ah(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=uc(e.cronForm),i=pc(e.cronForm),s={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:e.cronForm.agentId.trim()||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i};if(e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?s.isolation={postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:s.isolation=void 0,!s.name)throw new Error("Name required.");await e.client.request("cron.update",{id:t,patch:s}),await jn(e),await on(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function xo(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("cron.runs",{id:t,limit:50});e.cronRunsJobId=t,e.cronRuns=Array.isArray(n.entries)?n.entries:[]}catch(n){e.cronError=String(n)}}async function ee(e,t){if(!(!e.client||!e.connected)&&!e.channelsLoading){e.channelsLoading=!0,e.channelsError=null;try{const n=await e.client.request("channels.status",{probe:t,timeoutMs:8e3});e.channelsSnapshot=n,e.channelsLastSuccess=Date.now()}catch(n){e.channelsError=String(n)}finally{e.channelsLoading=!1}}}async function ea(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const i=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=i.message??null,e.whatsappLoginQrDataUrl=i.qrDataUrl??null,e.whatsappLoginConnected=null}catch(i){e.whatsappLoginMessage=String(i),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function hc(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const n=await e.client.request("web.login.wait",{timeoutMs:12e4,accountId:t});e.whatsappLoginMessage=n.message??null,e.whatsappLoginConnected=n.connected??null,n.connected&&(e.whatsappLoginQrDataUrl=null,e.whatsappActiveQrAccountId=null,e.whatsappPairedPhone=n.selfPhone??null)}catch(n){e.whatsappLoginMessage=String(n),e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function fc(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t}),e.whatsappLoginMessage="Logged out.",e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null}catch(n){e.whatsappLoginMessage=String(n)}finally{e.whatsappBusy=!1}}}async function gc(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const i=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!i){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const o=lt(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const a=o.channels;(!a.whatsapp||typeof a.whatsapp!="object")&&(a.whatsapp={});const r=a.whatsapp;(!r.accounts||typeof r.accounts!="object")&&(r.accounts={});const u=r.accounts;if(u[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}u[i]={name:n,provider:"baileys"};const c=s.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const h=At(o);await e.client.request("config.set",{raw:h,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await ee(e,!0),await ea(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function mc(e,t){if(!(!e.client||!e.connected)&&!e.whatsappAccountSaving){e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=lt(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,a=o==null?void 0:o.accounts;if(!a){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(a).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!a[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete a[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(h=>{const d=h.match;return!d||d.channel!=="whatsapp"?!0:d.accountId!==t}));const u=n.hash;if(!u){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=At(i);await e.client.request("config.set",{raw:c,baseHash:u}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await ee(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Ch=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:gc,loadChannels:ee,logoutWhatsApp:fc,removeWhatsAppAccount:mc,startWhatsAppLogin:ea,waitWhatsAppLogin:hc},Symbol.toStringTag,{value:"Module"}));async function ta(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,i,s]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const o=i;e.debugModels=Array.isArray(o==null?void 0:o.models)?o==null?void 0:o.models:[],e.debugHeartbeat=s}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const na="taskmaster-access-session",yc={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function ia(){try{return localStorage.getItem(na)}catch{return null}}function vc(e){try{localStorage.setItem(na,e)}catch{}}function Eh(){try{localStorage.removeItem(na)}catch{}}async function Cr(e){if(e.client)try{const t=ia(),n=await e.client.request("access.status",{token:t});e.accessState={...e.accessState,checked:!0,hasPins:n.hasPins,hasMasterPin:n.hasMasterPin,accounts:n.accounts??[],authenticated:n.authenticated,workspace:n.workspace,master:n.master,error:null}}catch{e.accessState={...e.accessState,checked:!0,hasPins:!1,hasMasterPin:!1,accounts:[],authenticated:!0,error:null}}}async function Th(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const i=await e.client.request("access.verify",{account:t,pin:n});i.ok&&i.token?(vc(i.token),e.accessState={...e.accessState,authenticated:!0,workspace:i.workspace??null,master:i.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:i.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function _h(e,t){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const n=await e.client.request("access.setMasterPin",{pin:t});n.ok&&n.token?(vc(n.token),e.accessState={...e.accessState,checked:!0,hasPins:!0,hasMasterPin:!0,authenticated:!0,workspace:null,master:!0,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}}}async function Mh(e,t,n){if(!e.client)return!1;try{return(await e.client.request("access.setAccountPin",{workspace:t,pin:n})).ok}catch{return!1}}async function Ph(e){const t=ia();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}Eh(),e.accessState={...yc,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}const Ih=2e3,Lh=new Set(["trace","debug","info","warn","error","fatal"]);function Rh(e){if(typeof e!="string")return null;const t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;try{const n=JSON.parse(t);return!n||typeof n!="object"?null:n}catch{return null}}function Dh(e){if(typeof e!="string")return null;const t=e.toLowerCase();return Lh.has(t)?t:null}function bc(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,i=typeof t.time=="string"?t.time:typeof(n==null?void 0:n.date)=="string"?n==null?void 0:n.date:null,s=Dh((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),o=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,a=Rh(o);let r=null;a&&(typeof a.subsystem=="string"?r=a.subsystem:typeof a.module=="string"&&(r=a.module)),!r&&o&&o.length<120&&(r=o);let u=null;return typeof t[1]=="string"?u=t[1]:!a&&typeof t[0]=="string"?u=t[0]:typeof t.message=="string"&&(u=t.message),{raw:e,time:i,level:s,subsystem:r,message:u??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Gt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const i=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes,accessToken:ia()??void 0}),o=(Array.isArray(i.lines)?i.lines.filter(r=>typeof r=="string"):[]).map(bc),a=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=a?o:[...e.logsEntries,...o].slice(-Ih),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const Bh=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Gt,parseLogLine:bc},Symbol.toStringTag,{value:"Module"}));const wc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ue,n:Ai,Gx:Er,Gy:Tr,a:Fs,d:Us,h:Nh}=wc,Ct=32,sa=64,Oh=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},re=(e="")=>{const t=new Error(e);throw Oh(t,re),t},Fh=e=>typeof e=="bigint",Uh=e=>typeof e=="string",Wh=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",ct=(e,t,n="")=>{const i=Wh(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const a=n&&`"${n}" `,r=o?` of length ${t}`:"",u=i?`length=${s}`:`type=${typeof e}`;re(a+"expected Uint8Array"+r+", got "+u)}return e},rs=e=>new Uint8Array(e),kc=e=>Uint8Array.from(e),xc=(e,t)=>e.toString(16).padStart(t,"0"),$c=e=>Array.from(ct(e)).map(t=>xc(t,2)).join(""),Ge={_0:48,_9:57,A:65,F:70,a:97,f:102},_r=e=>{if(e>=Ge._0&&e<=Ge._9)return e-Ge._0;if(e>=Ge.A&&e<=Ge.F)return e-(Ge.A-10);if(e>=Ge.a&&e<=Ge.f)return e-(Ge.a-10)},Sc=e=>{const t="hex invalid";if(!Uh(e))return re(t);const n=e.length,i=n/2;if(n%2)return re(t);const s=rs(i);for(let o=0,a=0;o<i;o++,a+=2){const r=_r(e.charCodeAt(a)),u=_r(e.charCodeAt(a+1));if(r===void 0||u===void 0)return re(t);s[o]=r*16+u}return s},Ac=()=>globalThis==null?void 0:globalThis.crypto,Kh=()=>{var e;return((e=Ac())==null?void 0:e.subtle)??re("crypto.subtle must be defined, consider polyfill")},zn=(...e)=>{const t=rs(e.reduce((i,s)=>i+ct(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},zh=(e=Ct)=>Ac().getRandomValues(rs(e)),Fi=BigInt,gt=(e,t,n,i="bad number: out of range")=>Fh(e)&&t<=e&&e<n?e:re(i),R=(e,t=ue)=>{const n=e%t;return n>=0n?n:t+n},Cc=e=>R(e,Ai),Hh=(e,t)=>{(e===0n||t<=0n)&&re("no inverse n="+e+" mod="+t);let n=R(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const a=i/n,r=i%n,u=s-o*a;i=n,n=r,s=o,o=u}return i===1n?R(s,t):re("no inverse")},qh=e=>{const t=Mc[e];return typeof t!="function"&&re("hashes."+e+" not set"),t},Ws=e=>e instanceof Et?e:re("Point expected"),$o=2n**256n,Oe=class Oe{constructor(t,n,i,s){q(this,"X");q(this,"Y");q(this,"Z");q(this,"T");const o=$o;this.X=gt(t,0n,o),this.Y=gt(n,0n,o),this.Z=gt(i,1n,o),this.T=gt(s,0n,o),Object.freeze(this)}static CURVE(){return wc}static fromAffine(t){return new Oe(t.x,t.y,1n,R(t.x*t.y))}static fromBytes(t,n=!1){const i=Us,s=kc(ct(t,Ct)),o=t[31];s[31]=o&-129;const a=Tc(s);gt(a,0n,n?$o:ue);const u=R(a*a),c=R(u-1n),h=R(i*u+1n);let{isValid:d,value:p}=Gh(c,h);d||re("bad point: y not sqrt");const v=(p&1n)===1n,$=(o&128)!==0;return!n&&p===0n&&$&&re("bad point: x==0, isLastByteOdd"),$!==v&&(p=R(-p)),new Oe(p,a,1n,R(p*a))}static fromHex(t,n){return Oe.fromBytes(Sc(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Fs,n=Us,i=this;if(i.is0())return re("bad point: ZERO");const{X:s,Y:o,Z:a,T:r}=i,u=R(s*s),c=R(o*o),h=R(a*a),d=R(h*h),p=R(u*t),v=R(h*R(p+c)),$=R(d+R(n*R(u*c)));if(v!==$)return re("bad point: equation left != right (1)");const S=R(s*o),M=R(a*r);return S!==M?re("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:a,Z:r}=Ws(t),u=R(n*r),c=R(o*s),h=R(i*r),d=R(a*s);return u===c&&h===d}is0(){return this.equals(qt)}negate(){return new Oe(R(-this.X),this.Y,this.Z,R(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=Fs,o=R(t*t),a=R(n*n),r=R(2n*R(i*i)),u=R(s*o),c=t+n,h=R(R(c*c)-o-a),d=u+a,p=d-r,v=u-a,$=R(h*p),S=R(d*v),M=R(h*v),y=R(p*d);return new Oe($,S,y,M)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:r,Z:u,T:c}=Ws(t),h=Fs,d=Us,p=R(n*a),v=R(i*r),$=R(o*d*c),S=R(s*u),M=R((n+i)*(a+r)-p-v),y=R(S-$),b=R(S+$),k=R(v-h*p),A=R(M*y),E=R(b*k),T=R(M*k),P=R(y*b);return new Oe(A,E,P,T)}subtract(t){return this.add(Ws(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return qt;if(gt(t,1n,Ai),t===1n)return this;if(this.equals(Tt))return of(t).p;let i=qt,s=Tt;for(let o=this;t>0n;o=o.double(),t>>=1n)t&1n?i=i.add(o):n&&(s=s.add(o));return i}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:i}=this;if(this.equals(qt))return{x:0n,y:1n};const s=Hh(i,ue);R(i*s)!==1n&&re("invalid inverse");const o=R(t*s),a=R(n*s);return{x:o,y:a}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Ec(n);return i[31]|=t&1n?128:0,i}toHex(){return $c(this.toBytes())}clearCofactor(){return this.multiply(Fi(Nh),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Ai/2n,!1).double();return Ai%2n&&(t=t.add(this)),t.is0()}};q(Oe,"BASE"),q(Oe,"ZERO");let Et=Oe;const Tt=new Et(Er,Tr,1n,R(Er*Tr)),qt=new Et(0n,1n,1n,0n);Et.BASE=Tt;Et.ZERO=qt;const Ec=e=>Sc(xc(gt(e,0n,$o),sa)).reverse(),Tc=e=>Fi("0x"+$c(kc(ct(e)).reverse())),Le=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=ue;return n},jh=e=>{const n=e*e%ue*e%ue,i=Le(n,2n)*n%ue,s=Le(i,1n)*e%ue,o=Le(s,5n)*s%ue,a=Le(o,10n)*o%ue,r=Le(a,20n)*a%ue,u=Le(r,40n)*r%ue,c=Le(u,80n)*u%ue,h=Le(c,80n)*u%ue,d=Le(h,10n)*o%ue;return{pow_p_5_8:Le(d,2n)*e%ue,b2:n}},Mr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Gh=(e,t)=>{const n=R(t*t*t),i=R(n*n*t),s=jh(e*i).pow_p_5_8;let o=R(e*n*s);const a=R(t*o*o),r=o,u=R(o*Mr),c=a===e,h=a===R(-e),d=a===R(-e*Mr);return c&&(o=r),(h||d)&&(o=u),(R(o)&1n)===1n&&(o=R(-o)),{isValid:c||h,value:o}},So=e=>Cc(Tc(e)),oa=(...e)=>Mc.sha512Async(zn(...e)),Vh=(...e)=>qh("sha512")(zn(...e)),_c=e=>{const t=e.slice(0,Ct);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Ct,sa),i=So(t),s=Tt.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},aa=e=>oa(ct(e,Ct)).then(_c),Qh=e=>_c(Vh(ct(e,Ct))),Jh=e=>aa(e).then(t=>t.pointBytes),Yh=e=>oa(e.hashable).then(e.finish),Xh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=So(t),a=Tt.multiply(o).toBytes();return{hashable:zn(a,i,n),finish:c=>{const h=Cc(o+So(c)*s);return ct(zn(a,Ec(h)),sa)}}},Zh=async(e,t)=>{const n=ct(e),i=await aa(t),s=await oa(i.prefix,n);return Yh(Xh(i,s,n))},Mc={sha512Async:async e=>{const t=Kh(),n=zn(e);return rs(await t.digest("SHA-512",n.buffer))},sha512:void 0},ef=(e=zh(Ct))=>e,tf={getExtendedPublicKeyAsync:aa,getExtendedPublicKey:Qh,randomSecretKey:ef},Ui=8,nf=256,Pc=Math.ceil(nf/Ui)+1,Ao=2**(Ui-1),sf=()=>{const e=[];let t=Tt,n=t;for(let i=0;i<Pc;i++){n=t,e.push(n);for(let s=1;s<Ao;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Pr;const Ir=(e,t)=>{const n=t.negate();return e?n:t},of=e=>{const t=Pr||(Pr=sf());let n=qt,i=Tt;const s=2**Ui,o=s,a=Fi(s-1),r=Fi(Ui);for(let u=0;u<Pc;u++){let c=Number(e&a);e>>=r,c>Ao&&(c-=o,e+=1n);const h=u*Ao,d=h,p=h+Math.abs(c)-1,v=u%2!==0,$=c<0;c===0?i=i.add(Ir(v,t[d])):n=n.add(Ir($,t[p]))}return e!==0n&&re("invalid wnaf"),{p:n,f:i}},Ks="taskmaster-device-identity-v1";function Co(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Ic(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)s[o]=i.charCodeAt(o);return s}function af(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Lc(e){const t=await crypto.subtle.digest("SHA-256",e);return af(new Uint8Array(t))}async function rf(){const e=tf.randomSecretKey(),t=await Jh(e);return{deviceId:await Lc(t),publicKey:Co(t),privateKey:Co(e)}}async function lf(){try{const n=localStorage.getItem(Ks);if(n){const i=JSON.parse(n);if((i==null?void 0:i.version)===1&&typeof i.deviceId=="string"&&typeof i.publicKey=="string"&&typeof i.privateKey=="string"){const s=await Lc(Ic(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(Ks,JSON.stringify(o)),{deviceId:s,publicKey:i.publicKey,privateKey:i.privateKey}}return{deviceId:i.deviceId,publicKey:i.publicKey,privateKey:i.privateKey}}}}catch{}const e=await rf(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Ks,JSON.stringify(t)),e}async function cf(e,t){const n=Ic(e),i=new TextEncoder().encode(t),s=await Zh(i,n);return Co(s)}const Rc="taskmaster.device.auth.v1";function ra(e){return e.trim()}function df(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const i=n.trim();i&&t.add(i)}return[...t].sort()}function la(){try{const e=window.localStorage.getItem(Rc);if(!e)return null;const t=JSON.parse(e);return!t||t.version!==1||!t.deviceId||typeof t.deviceId!="string"||!t.tokens||typeof t.tokens!="object"?null:t}catch{return null}}function Dc(e){try{window.localStorage.setItem(Rc,JSON.stringify(e))}catch{}}function uf(e){const t=la();if(!t||t.deviceId!==e.deviceId)return null;const n=ra(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function pf(e){const t=ra(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=la();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:df(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Dc(n),s}function hf(e){const t=la();if(!t||t.deviceId!==e.deviceId)return;const n=ra(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Dc(i)}async function ca(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t!=null&&t.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n==null?void 0:n.pending)?n.pending:[],paired:Array.isArray(n==null?void 0:n.paired)?n.paired:[]}}catch(n){t!=null&&t.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function da(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t!=null&&t.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t!=null&&t.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function ff(e){return{method:"exec.approvals.get",params:{}}}async function gf(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=ff(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);mf(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function mf(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=lt(t.file??{}))}async function Bc(e){if(!(!e.client||!e.connected)&&!e.presenceLoading){e.presenceLoading=!0,e.presenceError=null,e.presenceStatus=null;try{const t=await e.client.request("system-presence",{});Array.isArray(t)?(e.presenceEntries=t,e.presenceStatus=t.length===0?"No instances yet.":null):(e.presenceEntries=[],e.presenceStatus="No presence payload.")}catch(t){e.presenceError=String(t)}finally{e.presenceLoading=!1}}}function Ue(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function _e(e){return e instanceof Error?e.message:String(e)}function Hn(){return{name:"",skillContent:"",references:[],alwaysActive:!1}}async function We(e,t){if(t!=null&&t.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{const n=await e.client.request("skills.status",{});n&&(e.skillsReport=n)}catch(n){e.skillsError=_e(n)}finally{e.skillsLoading=!1}}}function Nc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Oc(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,enabled:n}),await We(e),Ue(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=_e(i);e.skillsError=s,Ue(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Fc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const n=e.skillEdits[t]??"";await e.client.request("skills.update",{skillKey:t,apiKey:n}),await We(e),Ue(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=_e(n);e.skillsError=i,Ue(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Uc(e,t,n,i){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const s=await e.client.request("skills.install",{name:n,installId:i,timeoutMs:12e4});await We(e),Ue(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=_e(s);e.skillsError=o,Ue(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}async function Wc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});n&&(e.skillDetail=n,e.skillDetailTab="SKILL.md")}catch(n){e.skillsError=_e(n)}}function Kc(e){e.skillDetail=null,e.skillDetailTab=""}function zc(e,t){e.skillDetailTab=t}async function Hc(e){if(e.skillAddModal=!0,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[],!(!e.client||!e.connected))try{const t=await e.client.request("skills.drafts",{});t&&(e.skillDrafts=t.drafts)}catch{}}function qc(e){e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[]}function jc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n})),alwaysActive:!1},e.skillAddFormSource="draft"}async function Gc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n})),alwaysActive:!1},e.skillAddFormSource="installed",await ua(e)}async function ua(e){if(!e.client||!e.connected)return;const t=e.skillAddForm;if(!(!t.name.trim()||!t.skillContent.trim())){e.skillsBusyKey="__add__",e.skillsError=null;try{const n=t.references.filter(s=>s.name.trim()&&s.content.trim()).map(s=>({name:s.name.trim(),content:s.content})),i=t.name.trim();e.skillAddFormSource==="installed"?(await e.client.request("skills.create",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0,alwaysActive:t.alwaysActive}),e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],await We(e),Ue(e,i,{kind:"success",message:"Skill saved — active on next message"})):(await e.client.request("skills.saveDraft",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],Ue(e,i,{kind:"success",message:"Draft saved"}))}catch(n){e.skillsError=_e(n)}finally{e.skillsBusyKey=null}}}async function Vc(e,t){if(!(!e.client||!e.connected))try{await e.client.request("skills.deleteDraft",{name:t}),e.skillDrafts=e.skillDrafts.filter(n=>n.name!==t)}catch(n){e.skillsError=_e(n)}}async function Qc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});if(!n)return;e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i})),alwaysActive:n.alwaysActive??!1},e.skillAddFormSource="installed",e.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=_e(n)}}function Jc(e,t){const n=e.skillDetail;n&&(e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i})),alwaysActive:n.alwaysActive??!1},e.skillAddFormSource="installed",e.skillEditTab=t&&t!=="SKILL.md"?t:"SKILL.md",e.skillDetail=null,e.skillDetailTab="",e.skillAddModal=!0,e.skillDrafts=[])}function Yc(e,t,n){e.skillAddForm={...e.skillAddForm,references:e.skillAddForm.references.map(i=>i.name===t?{...i,content:n}:i)}}function Xc(e,t){e.skillEditTab=t}async function Zc(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.read",{name:t});if(!i)return;const s=i.references.filter(o=>o.name.trim()&&o.content.trim()).map(o=>({name:o.name.trim(),content:o.content}));await e.client.request("skills.create",{name:t,skillContent:i.content,references:s.length>0?s:void 0,alwaysActive:n}),await We(e),Ue(e,t,{kind:"success",message:n?"Skill is now always active":"Skill loads on demand"})}catch(i){e.skillsError=_e(i),Ue(e,t,{kind:"error",message:_e(i)})}finally{e.skillsBusyKey=null}}}async function ed(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await We(e)}catch(n){e.skillsError=_e(n)}finally{e.skillsBusyKey=null}}}const yf=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:qc,closeSkillDetail:Kc,deleteDraft:Vc,deleteSkill:ed,editDetailSkill:Jc,editSkill:Qc,emptyAddForm:Hn,importDraft:jc,installDraft:Gc,installSkill:Uc,loadSkills:We,openAddSkillModal:Hc,saveNewSkill:ua,saveSkillApiKey:Fc,setEditTab:Xc,setSkillDetailTab:zc,toggleAlwaysActive:Zc,updateFormReference:Yc,updateSkillEdit:Nc,updateSkillEnabled:Oc,viewSkillDetail:Wc},Symbol.toStringTag,{value:"Module"})),td={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},nd=new Map(Object.entries(td).map(([e,t])=>[t,e]));function ls(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function qn(e){if(!e)return"/";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}function vf(e,t=""){const n=ls(t),i=td[e];return n?`${n}${i}`:i}function id(e,t=""){const n=ls(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=qn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":nd.get(s)??null}function bf(e){let t=qn(e);if(t.endsWith("/index.html")&&(t=qn(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let i=0;i<n.length;i++){const s=`/${n.slice(i).join("/")}`.toLowerCase();if(nd.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function wf(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function pa(e){return e==="system"?wf():e}const di=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,kf=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,ui=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},xf=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var c;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,a=s,r=kf();if(!!a.startViewTransition&&!r){let h=.5,d=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")h=di(n.pointerClientX/window.innerWidth),d=di(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(h=di((p.left+p.width/2)/window.innerWidth),d=di((p.top+p.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${h*100}%`),o.style.setProperty("--theme-switch-y",`${d*100}%`),o.classList.add("theme-transition");try{const p=(c=a.startViewTransition)==null?void 0:c.call(a,()=>{t()});p!=null&&p.finished?p.finished.finally(()=>ui(o)):ui(o)}catch{ui(o),t()}return}t(),ui(o)},$f=2e3;async function Pn(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const n={cursors:t!=null&&t.reset?void 0:e.sessionLogsCursors,limit:500};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(n.agents=e.workspaceAgentIds);const s=await e.client.request("sessions.transcript",n),o=Array.isArray(s.entries)?s.entries:[],a=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=a?o:[...e.sessionLogsEntries,...o].slice(-$f),s.cursors&&(e.sessionLogsCursors=s.cursors),Array.isArray(s.agents)&&(e.sessionLogsAgents=s.agents),e.sessionLogsLastFetchAt=Date.now()}catch(n){e.sessionLogsError=String(n)}finally{t!=null&&t.quiet||(e.sessionLogsLoading=!1)}}}const sd=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:Pn},Symbol.toStringTag,{value:"Module"}));async function od(e,t){if(!(!e.client||!e.connected))try{const n={},i=await e.client.request("memory.audit",n);i!=null&&i.ok&&(e.auditEntries=i.entries??[])}catch{}}async function Sf(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function Ke(e){return e instanceof Error?e.message:String(e)}let pi=null;function an(e,t){pi&&clearTimeout(pi),e.filesMessage={kind:"success",text:t},pi=setTimeout(()=>{e.filesMessage=null,pi=null},3e3)}async function rn(e,t){if(!(!e.client||!e.connected)){if(!t){e.filesTree=[],e.filesRoot="";return}if(!e.filesLoading){e.filesLoading=!0,e.filesError=null;try{const n={};t&&(n.agentId=t);const i=await e.client.request("files.tree",n);i!=null&&i.tree&&(e.filesTree=i.tree,e.filesRoot=i.root??"")}catch(n){e.filesError=Ke(n)}finally{e.filesLoading=!1}}}}async function Af(e,t,n){e.filesSelectedPaths=new Set([t]),await ad(e,t,n)}async function Cf(e,t,n){const i=new Set(e.filesSelectedPaths);if(i.has(t)?i.delete(t):i.add(t),e.filesSelectedPaths=i,i.size===1){const s=[...i][0];await ad(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Ef(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let i=0,s="";for(const o of n)try{await rd(e,o,t),i++}catch(a){s=Ke(a)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:an(e,`${i} file${i!==1?"s":""} downloaded`)}async function Tf(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await If(e,t,o,i)}async function ad(e,t,n){if(!(!e.client||!e.connected)){e.filesSelectedPath=t,e.filesPreviewLoading=!0,e.filesPreviewContent=null,e.filesPreviewBinary=!1,e.filesPreviewSize=null;try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.read",i);e.filesPreviewContent=(s==null?void 0:s.content)??null,e.filesPreviewBinary=(s==null?void 0:s.binary)??!1,e.filesPreviewSize=(s==null?void 0:s.size)??null}catch(i){e.filesError=Ke(i)}finally{e.filesPreviewLoading=!1}}}async function rd(e,t,n){if(!(!e.client||!e.connected))try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.download",i);if(!(s!=null&&s.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(s.base64),c=>c.charCodeAt(0)),a=new Blob([o]),r=URL.createObjectURL(a),u=document.createElement("a");u.href=r,u.download=s.name??t.split("/").pop()??"download",document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(r)}catch(i){e.filesMessage={kind:"error",text:Ke(i)}}}async function _f(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const a of n)try{const r=await a.arrayBuffer(),u=btoa(new Uint8Array(r).reduce((h,d)=>h+String.fromCharCode(d),"")),c={path:t,name:a.name,data:u};i&&(c.agentId=i),await e.client.request("files.upload",c),s++}catch(r){o=Ke(r)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:an(e,`${s} file${s!==1?"s":""} uploaded`),await rn(e,i)}async function Mf(e,t,n,i){if(!e.client||!e.connected)return;e.filesMessage=null;const s=t==="."?n:`${t}/${n}`;try{const o={path:s};i&&(o.agentId=i),await e.client.request("files.mkdir",o),an(e,`Created ${s}`),await rn(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:Ke(o)}}}async function Pf(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={path:t};n&&(i.agentId=n),await e.client.request("files.delete",i),an(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await rn(e,n)}catch(i){e.filesMessage={kind:"error",text:Ke(i)}}}}async function If(e,t,n,i){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={from:t,to:n};i&&(s.agentId=i),await e.client.request("files.move",s),an(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await rn(e,i)}catch(s){e.filesMessage={kind:"error",text:Ke(s)}}}}async function cs(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const i=await e.client.request("memory.status",n);i!=null&&i.ok&&(e.filesMemoryStatus={dirty:i.dirty??!1,syncing:i.syncing,syncProgress:i.syncProgress,files:i.files??0,chunks:i.chunks??0,model:i.model,embeddingState:i.embeddingState})}catch{}}async function Lf(e,t){if(!(!e.client||!e.connected)&&!e.filesReindexBusy){e.filesReindexBusy=!0,e.filesMessage=null;try{const n={force:!0};t&&(n.agentId=t);const i=await e.client.request("memory.reindex",n),s=(i==null?void 0:i.files)??0,o=(i==null?void 0:i.chunks)??0;an(e,`Re-indexed: ${s} files, ${o} chunks`),await cs(e,t)}catch(n){e.filesMessage={kind:"error",text:Ke(n)}}finally{e.filesReindexBusy=!1}}}function Rf(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n,e.filesCurrentDir=t}async function Df(e,t,n){if(!(!e.client||!e.connected)){if(!t.trim()){e.filesSearchResults=null;return}e.filesSearchLoading=!0,e.filesSearchResults=null;try{const i={query:t.trim(),maxResults:20};n&&(i.agentId=n);const s=await e.client.request("memory.search",i);e.filesSearchResults=(s==null?void 0:s.results)??[]}catch(i){e.filesMessage={kind:"error",text:Ke(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Bf(e){e.filesSearchQuery="",e.filesSearchResults=null}function Nf(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{da(e,{quiet:!0})},5e3))}function Of(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function ha(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Gt(e,{quiet:!0})},2e3))}function fa(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function ga(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||Pn(e,{quiet:!0})},2e3))}function ma(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function ya(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ta(e)},3e3))}function va(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Ff(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{od(e)},3e4))}function Uf(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function Wf(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{const t=e;t.filesPage&&cs(t,t.filesResolvedAgentId)},3e3))}function Kf(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function at(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,Pp(n),t.theme!==e.theme&&(e.theme=t.theme,ds(e,pa(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function ld(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&at(e,{...e.settings,lastActiveSessionKey:n})}function zf(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),i=t.get("password"),s=t.get("session"),o=t.get("gatewayUrl");let a=!1;if(n!=null){const u=n.trim();u&&u!==e.settings.token&&at(e,{...e.settings,token:u}),t.delete("token"),a=!0}if(i!=null){const u=i.trim();u&&(e.password=u),t.delete("password"),a=!0}if(s!=null){const u=s.trim();u&&(e.sessionKey=u,at(e,{...e.settings,sessionKey:u,lastActiveSessionKey:u}))}if(o!=null){const u=o.trim();u&&u!==e.settings.gatewayUrl&&at(e,{...e.settings,gatewayUrl:u}),t.delete("gatewayUrl"),a=!0}if(!a)return;const r=new URL(window.location.href);r.search=t.toString(),window.history.replaceState({},"",r.toString())}function Hf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ga(e):ha(e):(fa(e),ma(e)),t==="debug"?ya(e):va(e),Wi(e),dd(e,t,!1)}function qf(e,t,n){xf({nextTheme:t,applyTheme:()=>{e.theme=t,at(e,{...e.settings,theme:t}),ds(e,pa(t))},context:n,currentTheme:e.theme})}async function Wi(e){if(e.tab==="overview"&&await ud(e),e.tab==="channels"&&await Xf(e),e.tab==="instances"&&await Bc(e),e.tab==="cron"&&await pd(e),e.tab==="skills"&&await We(e),e.tab==="nodes"&&(await da(e),await ca(e),await Fe(e),await gf(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await ig(e),sn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await dc(e),await Fe(e)),e.tab==="debug"&&(await ta(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await ae(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>sd);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Gt(e,{reset:!0});lc(e,!0)}}function jf(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?ls(e):bf(window.location.pathname)}function Gf(e){e.theme=e.settings.theme??"system",ds(e,pa(e.theme))}function ds(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Vf(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;if(e.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaHandler=n=>{e.theme==="system"&&ds(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Qf(e){if(!e.themeMedia||!e.themeMediaHandler)return;if(typeof e.themeMedia.removeEventListener=="function"){e.themeMedia.removeEventListener("change",e.themeMediaHandler);return}e.themeMedia.removeListener(e.themeMediaHandler),e.themeMedia=null,e.themeMediaHandler=null}function Jf(e,t){if(typeof window>"u")return;const n=id(window.location.pathname,e.basePath)??"chat";cd(e,n),dd(e,n,t)}function Yf(e){var s;if(typeof window>"u")return;const t=id(window.location.pathname,e.basePath);if(!t)return;const i=(s=new URL(window.location.href).searchParams.get("session"))==null?void 0:s.trim();i&&(e.sessionKey=i,at(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),cd(e,t)}function cd(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ga(e):ha(e):(fa(e),ma(e)),t==="debug"?ya(e):va(e),e.connected&&Wi(e)}function dd(e,t,n){if(typeof window>"u")return;const i=qn(vf(t,e.basePath)),s=qn(window.location.pathname),o=new URL(window.location.href);t==="chat"&&e.sessionKey?o.searchParams.set("session",e.sessionKey):o.searchParams.delete("session"),s!==i&&(o.pathname=i),n?window.history.replaceState({},"",o.toString()):window.history.pushState({},"",o.toString())}async function ud(e){await Promise.all([ee(e,!1),Bc(e),rc(e),on(e),ta(e)])}async function Xf(e){await Promise.all([ee(e,!0),dc(e),Fe(e)])}async function pd(e){await Promise.all([ee(e,!1),on(e),jn(e)])}function hd(e){return e.chatSending||!!e.chatRunId}function Zf(e){const t=e.trim();if(!t)return!1;const n=t.toLowerCase();return n==="/stop"?!0:n==="stop"||n==="esc"||n==="abort"||n==="wait"||n==="exit"}async function fd(e){e.connected&&(e.chatMessage="",await oc(e))}function eg(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:as(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],sn(e))}async function gd(e,t,n){var s,o;Zo(e);const i=await sc(e,t,n==null?void 0:n.attachments);return!i&&(n==null?void 0:n.previousDraft)!=null&&(e.chatMessage=n.previousDraft),!i&&(n!=null&&n.previousAttachments)&&(e.chatAttachments=n.previousAttachments),i&&ld(e,e.sessionKey),i&&(n!=null&&n.restoreDraft)&&((s=n.previousDraft)!=null&&s.trim())&&(e.chatMessage=n.previousDraft),i&&(n!=null&&n.restoreAttachments)&&((o=n.previousAttachments)!=null&&o.length)&&(e.chatAttachments=n.previousAttachments),sn(e),i&&!e.chatRunId&&md(e),i}async function md(e){if(!e.connected||hd(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await gd(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function tg(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function ng(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],a=t==null?o:[],r=a.length>0;if(!(!s&&!r)){if(Zf(s)){await fd(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[],Lp(e.selectedWorkspace??"",e.sessionKey)),hd(e)){eg(e,s,a);return}await gd(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:r?a:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function ig(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,nn);await Promise.all([Jt(t,{limit:n}),rc(t),Eo(e)]),sn(e,!0)}const sg=md;function og(e){var s,o,a;const t=Jl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((a=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:a.trim())||"main"}function ag(e,t){const n=ls(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Eo(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=og(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=ag(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),o=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const L={messageSquare:l`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:l`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:l`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,unlink:l`<svg viewBox="0 0 24 24"><path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" x2="8" y1="2" y2="5"/><line x1="2" x2="5" y1="8" y2="8"/><line x1="16" x2="16" y1="19" y2="22"/><line x1="19" x2="22" y1="16" y2="16"/></svg>`,radio:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:l`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:l`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:l`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:l`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:l`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:l`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:l`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,users:l`<svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,user:l`<svg viewBox="0 0 24 24"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>`,menu:l`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:l`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:l`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:l`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:l`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:l`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:l`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:l`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,rotateCw:l`<svg viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,download:l`<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wrench:l`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:l`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:l`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:l`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:l`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,globeOff:l`<svg viewBox="0 0 24 24"><path d="M21.54 15H17"/><path d="M7 3.34V5a3 3 0 0 0 3 3 2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17"/><path d="M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05"/><circle cx="12" cy="12" r="10"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,image:l`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:l`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:l`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,puzzle:l`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`,info:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,send:l`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:l`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`,slidersHorizontal:l`<svg viewBox="0 0 24 24"><line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/></svg>`,square:l`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:l`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:l`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,trash:l`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,mic:l`<svg viewBox="0 0 24 24"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>`,chevronDown:l`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:l`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`,wifi:l`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M2 8.82a15 15 0 0 1 20 0"/><path d="M5 12.859a10 10 0 0 1 14 0"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/></svg>`,wifiOff:l`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/><path d="M5 12.859a10 10 0 0 1 5.17-2.69"/><path d="M13.41 10.28a10 10 0 0 1 5.59 2.58"/><path d="M2 8.82a15 15 0 0 1 4.17-2.65"/><path d="M10.66 5c4.01-.36 8.14.9 11.34 3.76"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,power:l`<svg viewBox="0 0 24 24"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"/><line x1="12" x2="12" y1="2" y2="12"/></svg>`,powerOff:l`<svg viewBox="0 0 24 24"><path d="M18.36 6.64A9 9 0 0 1 20.77 15"/><path d="M6.16 6.16a9 9 0 1 0 12.68 12.68"/><path d="M12 2v4"/><path d="m2 2 20 20"/></svg>`},rg=l`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,lg=l`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>`,cg=l`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path><line x1="12" y1="2" x2="12" y2="12"></line></svg>`;let Lr=!1;function dg(){Lr||(Lr=!0,document.addEventListener("click",e=>{const t=document.getElementById("nav-burger-toggle");if(!(t!=null&&t.checked))return;const n=t.closest(".setup-header");n!=null&&n.contains(e.target)||(t.checked=!1)}))}function It(e,t){var d;const n=(p,v)=>p===e?l`<span class="sp-page-nav-current">${p}</span>`:l`<a href=${v}>${p}</a>`,i=l`
21
21
  ${n("Setup","/setup")}
22
22
  ${n("Chat","/chat")}
23
23
  ${n("Admins","/admins")}
@@ -25,14 +25,14 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
25
25
  ${n("Files","/files")}
26
26
  ${n("Browser","/browser")}
27
27
  ${n("Advanced","/advanced")}
28
- `,o=t&&(t.isMaster!==!1||!t.hasPins)?ug(t):w,a=t!=null&&t.hasPins&&t.onLogout?l`<button class="nav-logout-btn" @click=${t.onLogout} title="Lock">${ag}</button>`:w,r=t!=null&&t.onRestartGateway?dg(t.onRestartGateway):w,u=(t==null?void 0:t.auditCount)??0,c=u>0&&(t!=null&&t.onAuditClick)?l`<button class="nav-audit-btn" @click=${t.onAuditClick} title="Memory writes to review">
29
- ${rg}
28
+ `,o=t&&(t.isMaster!==!1||!t.hasPins)?pg(t):w,a=t!=null&&t.hasPins&&t.onLogout?l`<button class="nav-logout-btn" @click=${t.onLogout} title="Lock">${rg}</button>`:w,r=t!=null&&t.onRestartGateway?ug(t.onRestartGateway):w,u=(t==null?void 0:t.auditCount)??0,c=u>0&&(t!=null&&t.onAuditClick)?l`<button class="nav-audit-btn" @click=${t.onAuditClick} title="Memory writes to review">
29
+ ${lg}
30
30
  <span class="nav-audit-badge">${u>99?"99+":u}</span>
31
- </button>`:w,h=()=>{const p=document.getElementById("nav-burger-toggle");p&&(p.checked=!1)};return cg(),l`
31
+ </button>`:w,h=()=>{const p=document.getElementById("nav-burger-toggle");p&&(p.checked=!1)};return dg(),l`
32
32
  <div class="setup-header">
33
33
  <input type="checkbox" id="nav-burger-toggle" class="nav-burger-checkbox" />
34
34
  <div class="setup-header-inner">
35
- <img class="setup-header-logo" src="${(t==null?void 0:t.selectedWorkspace)&&((d=Be()[t.selectedWorkspace])==null?void 0:d.logoUrl)||Qe().iconUrl}" alt="${Qe().name}" />
35
+ <img class="setup-header-logo" src="${(t==null?void 0:t.selectedWorkspace)&&((d=Ne()[t.selectedWorkspace])==null?void 0:d.logoUrl)||Xe().iconUrl}" alt="${Xe().name}" />
36
36
  <nav class="setup-header-nav">
37
37
  ${i}
38
38
  </nav>
@@ -51,10 +51,10 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
51
51
  ${i}
52
52
  </nav>
53
53
  </div>
54
- `}function dg(e){let t=!1;return l`
54
+ `}function ug(e){let t=!1;return l`
55
55
  <span class="nav-restart-container" style="position: relative;">
56
56
  <button class="nav-restart-btn" @click=${o=>{const r=o.currentTarget.closest(".nav-restart-container");if(!r)return;const u=r.querySelector(".nav-restart-confirm");u&&(t=!t,u.style.display=t?"flex":"none")}} title="Restart gateway">
57
- ${lg}
57
+ ${cg}
58
58
  </button>
59
59
  <div class="nav-restart-confirm" style="display: none;">
60
60
  <p>Restart the gateway?</p>
@@ -64,7 +64,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
64
64
  </div>
65
65
  </div>
66
66
  </span>
67
- `}function ug(e){const{workspaces:t,selectedWorkspace:n,onWorkspaceSelect:i}=e;return l`
67
+ `}function pg(e){const{workspaces:t,selectedWorkspace:n,onWorkspaceSelect:i}=e;return l`
68
68
  <select
69
69
  class="sp-workspace-selector"
70
70
  .value=${n??""}
@@ -78,7 +78,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
78
78
  <option disabled>───</option>
79
79
  <option value="__add__">+ Add Account</option>
80
80
  </select>
81
- `}function pg(e){return e.connected?e.fullscreen&&e.active?l`
81
+ `}function hg(e){return e.connected?e.fullscreen&&e.active?l`
82
82
  <div class="sp-fullscreen-overlay">
83
83
  <div class="sp-fullscreen-toolbar">
84
84
  <button
@@ -210,14 +210,14 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
210
210
  <p>Connecting to gateway...</p>
211
211
  </div>
212
212
  </div>
213
- `}const Ki="application/x-taskmaster-file-path";let ht=null;function md(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function yd(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function hg(e,t,n){var o,a;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const i=(o=e.dataTransfer)==null?void 0:o.getData(Ki);if(i){yd(i)!==t&&n.onMoveToDir(i,t);return}const s=(a=e.dataTransfer)==null?void 0:a.files;if(s&&s.length>0){const r=Array.from(s).filter(u=>u.name.toLowerCase().endsWith(".md"));r.length>0&&n.onUpload(t,r)}}function vd(e,t,n){var u;const i=e.type==="directory"||e.type==="symlink"&&e.children!=null,s=t.expandedDirs.has(e.path),o=t.selectedPaths.has(e.path),a=t.currentDir===e.path,r=n*20+12;return i?l`
213
+ `}const Ki="application/x-taskmaster-file-path";let ht=null;function yd(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function vd(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function fg(e,t,n){var o,a;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const i=(o=e.dataTransfer)==null?void 0:o.getData(Ki);if(i){vd(i)!==t&&n.onMoveToDir(i,t);return}const s=(a=e.dataTransfer)==null?void 0:a.files;if(s&&s.length>0){const r=Array.from(s).filter(u=>u.name.toLowerCase().endsWith(".md"));r.length>0&&n.onUpload(t,r)}}function bd(e,t,n){var u;const i=e.type==="directory"||e.type==="symlink"&&e.children!=null,s=t.expandedDirs.has(e.path),o=t.selectedPaths.has(e.path),a=t.currentDir===e.path,r=n*20+12;return i?l`
214
214
  <div
215
215
  class="sp-tree-item sp-tree-dir ${s?"expanded":""} ${a?"current":""}"
216
216
  style="padding-left: ${r}px;"
217
217
  @click=${()=>t.onToggleDir(e.path)}
218
218
  @dragover=${c=>{c.preventDefault(),c.stopPropagation(),c.dataTransfer&&(c.dataTransfer.dropEffect="move"),c.currentTarget.classList.add("sp-drop-target")}}
219
219
  @dragleave=${c=>{c.currentTarget.classList.remove("sp-drop-target")}}
220
- @drop=${c=>hg(c,e.path,t)}
220
+ @drop=${c=>fg(c,e.path,t)}
221
221
  >
222
222
  <span class="sp-tree-chevron">${s?"−":"+"}</span>
223
223
  <span class="sp-tree-icon">${L.folder}</span>
@@ -228,7 +228,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
228
228
  @click=${c=>{c.stopPropagation(),t.onDelete(e.path)}}
229
229
  >×</span>`:w}
230
230
  </div>
231
- ${s&&e.children?e.children.map(c=>vd(c,t,n+1)):w}
231
+ ${s&&e.children?e.children.map(c=>bd(c,t,n+1)):w}
232
232
  `:l`
233
233
  <div
234
234
  class="sp-tree-item sp-tree-file ${o?"selected":""}"
@@ -239,9 +239,9 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
239
239
  >
240
240
  <span class="sp-tree-icon">${L.fileText}</span>
241
241
  <span class="sp-tree-name">${e.name}</span>
242
- <span class="sp-tree-size">${md(e.size)}</span>
242
+ <span class="sp-tree-size">${yd(e.size)}</span>
243
243
  </div>
244
- `}function fg(e){const t=e.selectedPaths.size;return t<2?w:l`
244
+ `}function gg(e){const t=e.selectedPaths.size;return t<2?w:l`
245
245
  <div class="sp-bulk-actions">
246
246
  <span style="color: var(--tasker-muted-grey); font-size: 13px;">${t} files selected</span>
247
247
  <button
@@ -252,7 +252,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
252
252
  Download ${t} files
253
253
  </button>
254
254
  </div>
255
- `}function gg(e){if(e.selectedPaths.size!==1||!e.selectedPath)return w;if(e.previewLoading)return l`
255
+ `}function mg(e){if(e.selectedPaths.size!==1||!e.selectedPath)return w;if(e.previewLoading)return l`
256
256
  <div class="sp-file-preview">
257
257
  <div class="setup-spinner" style="width: 32px; height: 32px; margin: 24px auto;"></div>
258
258
  </div>
@@ -262,7 +262,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
262
262
  <div>
263
263
  <strong>${t}</strong>
264
264
  <div class="sp-file-preview-meta">
265
- ${e.selectedPath}${e.previewSize!=null?` — ${md(e.previewSize)}`:""}
265
+ ${e.selectedPath}${e.previewSize!=null?` — ${yd(e.previewSize)}`:""}
266
266
  </div>
267
267
  </div>
268
268
  <div class="sp-file-actions">
@@ -276,7 +276,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
276
276
  </div>
277
277
  ${e.previewBinary?l`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">Binary file — use Download to view.</p></div>`:e.previewContent!=null?l`<div class="sp-file-preview-body"><pre class="sp-file-code">${e.previewContent}</pre></div>`:l`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">File too large for preview — use Download.</p></div>`}
278
278
  </div>
279
- `}function mg(e){return l`
279
+ `}function yg(e){return l`
280
280
  <div class="sp-search-bar">
281
281
  <input
282
282
  type="text"
@@ -308,7 +308,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
308
308
  Clear
309
309
  </button>`:w}
310
310
  </div>
311
- `}function yg(e){return e.searchResults?e.searchResults.length===0?l`<div class="sp-search-results">
311
+ `}function vg(e){return e.searchResults?e.searchResults.length===0?l`<div class="sp-search-results">
312
312
  <div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No results found.</div>
313
313
  </div>`:l`
314
314
  <div class="sp-search-results">
@@ -328,7 +328,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
328
328
  </div>
329
329
  `)}
330
330
  </div>
331
- `:w}function vg(e){const t=e.currentDir;return e.connected?l`
331
+ `:w}function bg(e){const t=e.currentDir;return e.connected?l`
332
332
  <div class="setup-container">
333
333
  ${It("Files",e.wsProps)}
334
334
  <div class="setup-card sp-card-wide">
@@ -392,18 +392,18 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
392
392
 
393
393
  ${e.uploadBusy?l`<div style="margin-top: 12px; color: var(--tasker-orange); font-weight: 600; font-size: 14px;">Uploading...</div>`:w}
394
394
 
395
- ${mg(e)}
395
+ ${yg(e)}
396
396
 
397
- ${e.searchResults!==null?yg(e):l`<div
397
+ ${e.searchResults!==null?vg(e):l`<div
398
398
  class="sp-file-tree"
399
399
  @dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(Ki)?"move":"copy")}}
400
- @drop=${n=>{var o,a;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(Ki);if(i){yd(i)!=="."&&e.onMoveToDir(i,".");return}const s=(a=n.dataTransfer)==null?void 0:a.files;if(s&&s.length>0){const r=Array.from(s).filter(u=>u.name.toLowerCase().endsWith(".md"));r.length>0&&e.onUpload(t,r)}}}
400
+ @drop=${n=>{var o,a;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(Ki);if(i){vd(i)!=="."&&e.onMoveToDir(i,".");return}const s=(a=n.dataTransfer)==null?void 0:a.files;if(s&&s.length>0){const r=Array.from(s).filter(u=>u.name.toLowerCase().endsWith(".md"));r.length>0&&e.onUpload(t,r)}}}
401
401
  >
402
- ${e.tree.length===0&&!e.loading?l`<div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No files found. Drop .md files here to upload.</div>`:e.tree.map(n=>vd(n,e,0))}
402
+ ${e.tree.length===0&&!e.loading?l`<div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No files found. Drop .md files here to upload.</div>`:e.tree.map(n=>bd(n,e,0))}
403
403
  </div>`}
404
404
 
405
- ${fg(e)}
406
405
  ${gg(e)}
406
+ ${mg(e)}
407
407
  </div>
408
408
  </div>
409
409
  `:l`
@@ -413,7 +413,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
413
413
  <p>Connecting to gateway...</p>
414
414
  </div>
415
415
  </div>
416
- `}const ba="taskmaster_uninstall_done";async function bg(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),wg();try{await e.client.request("system.uninstall",{scopes:["service","state","workspace"],purge:!0})}catch{}e.uninstallBusy=!1,e.uninstallDone=!0,(n=e.requestUpdate)==null||n.call(e)}}function zi(){try{return localStorage.getItem(ba)==="1"}catch{return!1}}function wa(){try{localStorage.removeItem(ba)}catch{}}function wg(){try{localStorage.setItem(ba,"1")}catch{}}const Rr=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:zi,clearUninstallDone:wa,runUninstall:bg},Symbol.toStringTag,{value:"Module"}));function Q(e){return l`
416
+ `}const ba="taskmaster_uninstall_done";async function wg(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),kg();try{await e.client.request("system.uninstall",{scopes:["service","state","workspace"],purge:!0})}catch{}e.uninstallBusy=!1,e.uninstallDone=!0,(n=e.requestUpdate)==null||n.call(e)}}function zi(){try{return localStorage.getItem(ba)==="1"}catch{return!1}}function wa(){try{localStorage.removeItem(ba)}catch{}}function kg(){try{localStorage.setItem(ba,"1")}catch{}}const Rr=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:zi,clearUninstallDone:wa,runUninstall:wg},Symbol.toStringTag,{value:"Module"}));function Q(e){return l`
417
417
  <span
418
418
  class="setup-status-light"
419
419
  style="background: ${{good:"#22c55e",bad:"#ef4444",partial:"#eab308",unknown:"#6b7280"}[e]}"
@@ -426,7 +426,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
426
426
  >
427
427
  ${L.info}
428
428
  </button>
429
- `}function kg(e){var s;if(!e.infoModalOpen)return w;let t="",n=[],i=w;switch(e.infoModalOpen){case"gateway":{const o=typeof window<"u"?window.location.host:"unknown";t="Gateway",n=[{label:"Status",value:e.gatewayHealthy===!1?"Stopped":"Running"},{label:"What",value:"The core service that powers Taskmaster — handles AI conversations, message routing, and all connected channels"},{label:"Address",value:o},{label:"Health",value:e.gatewayHealthMessage||"OK"}];break}case"claude":{const o=e.authExpiresIn;let a="N/A";if(o!=null&&o>0)if(o>60){const r=Math.floor(o/60),u=o%60;a=u>0?`${r}h ${u}m`:`${r}h`}else a=`${o}m`;t="Claude",n=[{label:"Status",value:e.authConnected?"Connected":"Disconnected"},{label:"What",value:"Connection to Claude, the AI that powers natural conversation and tool use"},{label:"How",value:"Authenticated via OAuth — tokens refresh automatically when they expire"},{label:"Token Expiry",value:a},...e.authMessage?[{label:"Message",value:e.authMessage}]:[]];break}case"license":{const o=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"What",value:"Your Taskmaster license key, tied to this specific device"},{label:"Key",value:o},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A"}];break}case"whatsapp":{const o=Lt(e),a=o?us(o,e):null;t="WhatsApp",n=[{label:"Status",value:a!=null&&a.connected?"Connected":"Disconnected"},{label:"What",value:"WhatsApp integration — receive and respond to customer messages through WhatsApp"},{label:"How",value:"Links to your WhatsApp account by scanning a QR code, then routes messages to your AI assistant"},{label:"Account",value:(a==null?void 0:a.name)||(a==null?void 0:a.accountId)||"Default"},{label:"Phone",value:((s=a==null?void 0:a.self)==null?void 0:s.e164)||"Not paired"},{label:"Linked",value:a!=null&&a.linked?"Yes":"No"},...a!=null&&a.lastError?[{label:"Last Error",value:ka(a.lastError)}]:[]];break}case"imessage":{const{thisWsOwns:o}=xa(e);t="iMessage",n=[{label:"Status",value:o&&e.imessageConnected?"Connected":"Disconnected"},{label:"What",value:"iMessage integration — communicate with your AI assistant through Apple Messages"},{label:"How",value:"Uses the Mac's built-in Messages app; only one account can own the iMessage channel at a time"},{label:"Assigned To",value:e.imessageOwnerWorkspace??"Not assigned"},{label:"Mode",value:"Self-chat only"},...e.imessageLastError?[{label:"Last Error",value:e.imessageLastError}]:[]];break}case"update":{t="Software Update",n=[{label:"Status",value:e.updateAvailable===null?"Not checked":e.updateAvailable?"Update available":"Up to date"},{label:"What",value:"Checks for new versions of Taskmaster and lets you update from the control panel"},{label:"Current",value:e.currentVersion?`v${e.currentVersion}`:"Unknown"},{label:"Latest",value:e.latestVersion?`v${e.latestVersion}`:"Unknown"},...e.updateMessage?[{label:"Message",value:e.updateMessage}]:[]];break}case"remote-access":{const o=e.tailscaleStatus,a=o?o.installed?o.loggedIn?o.serveEnabled&&o.serveActive?"Active":o.serveEnabled&&!o.serveActive?"Enabled but not active":"Off":"Not connected":"Not installed":"Checking...";if(t="Remote Access",n=[{label:"Status",value:a},{label:"What",value:"Access this control panel from anywhere — your phone, another computer, or while away from home"},{label:"How",value:"Uses Tailscale to create a private, encrypted connection with a trusted HTTPS certificate (no browser warnings)"},{label:"Requires",value:"Tailscale installed on this device and on any device you want to access the control panel from, all logged into the same Tailscale account"},{label:"Internet Access",value:"Enable internet access (globe icon) to make Public Chat reachable from the web"},{label:"Cost",value:"Tailscale is free for personal use (up to 100 devices)"}],o!=null&&o.tailnetUrl){const r=o.tailnetUrl;i=l`
429
+ `}function xg(e){var s;if(!e.infoModalOpen)return w;let t="",n=[],i=w;switch(e.infoModalOpen){case"gateway":{const o=typeof window<"u"?window.location.host:"unknown";t="Gateway",n=[{label:"Status",value:e.gatewayHealthy===!1?"Stopped":"Running"},{label:"What",value:"The core service that powers Taskmaster — handles AI conversations, message routing, and all connected channels"},{label:"Address",value:o},{label:"Health",value:e.gatewayHealthMessage||"OK"}];break}case"claude":{const o=e.authExpiresIn;let a="N/A";if(o!=null&&o>0)if(o>60){const r=Math.floor(o/60),u=o%60;a=u>0?`${r}h ${u}m`:`${r}h`}else a=`${o}m`;t="Claude",n=[{label:"Status",value:e.authConnected?"Connected":"Disconnected"},{label:"What",value:"Connection to Claude, the AI that powers natural conversation and tool use"},{label:"How",value:"Authenticated via OAuth — tokens refresh automatically when they expire"},{label:"Token Expiry",value:a},...e.authMessage?[{label:"Message",value:e.authMessage}]:[]];break}case"license":{const o=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"What",value:"Your Taskmaster license key, tied to this specific device"},{label:"Key",value:o},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A"}];break}case"whatsapp":{const o=Lt(e),a=o?us(o,e):null;t="WhatsApp",n=[{label:"Status",value:a!=null&&a.connected?"Connected":"Disconnected"},{label:"What",value:"WhatsApp integration — receive and respond to customer messages through WhatsApp"},{label:"How",value:"Links to your WhatsApp account by scanning a QR code, then routes messages to your AI assistant"},{label:"Account",value:(a==null?void 0:a.name)||(a==null?void 0:a.accountId)||"Default"},{label:"Phone",value:((s=a==null?void 0:a.self)==null?void 0:s.e164)||"Not paired"},{label:"Linked",value:a!=null&&a.linked?"Yes":"No"},...a!=null&&a.lastError?[{label:"Last Error",value:ka(a.lastError)}]:[]];break}case"imessage":{const{thisWsOwns:o}=xa(e);t="iMessage",n=[{label:"Status",value:o&&e.imessageConnected?"Connected":"Disconnected"},{label:"What",value:"iMessage integration — communicate with your AI assistant through Apple Messages"},{label:"How",value:"Uses the Mac's built-in Messages app; only one account can own the iMessage channel at a time"},{label:"Assigned To",value:e.imessageOwnerWorkspace??"Not assigned"},{label:"Mode",value:"Self-chat only"},...e.imessageLastError?[{label:"Last Error",value:e.imessageLastError}]:[]];break}case"update":{t="Software Update",n=[{label:"Status",value:e.updateAvailable===null?"Not checked":e.updateAvailable?"Update available":"Up to date"},{label:"What",value:"Checks for new versions of Taskmaster and lets you update from the control panel"},{label:"Current",value:e.currentVersion?`v${e.currentVersion}`:"Unknown"},{label:"Latest",value:e.latestVersion?`v${e.latestVersion}`:"Unknown"},...e.updateMessage?[{label:"Message",value:e.updateMessage}]:[]];break}case"remote-access":{const o=e.tailscaleStatus,a=o?o.installed?o.loggedIn?o.serveEnabled&&o.serveActive?"Active":o.serveEnabled&&!o.serveActive?"Enabled but not active":"Off":"Not connected":"Not installed":"Checking...";if(t="Remote Access",n=[{label:"Status",value:a},{label:"What",value:"Access this control panel from anywhere — your phone, another computer, or while away from home"},{label:"How",value:"Uses Tailscale to create a private, encrypted connection with a trusted HTTPS certificate (no browser warnings)"},{label:"Requires",value:"Tailscale installed on this device and on any device you want to access the control panel from, all logged into the same Tailscale account"},{label:"Internet Access",value:"Enable internet access (globe icon) to make Public Chat reachable from the web"},{label:"Cost",value:"Tailscale is free for personal use (up to 100 devices)"}],o!=null&&o.tailnetUrl){const r=o.tailnetUrl;i=l`
430
430
  ${e.remoteAccessQrDataUrl?l`<div style="text-align: center; padding: 12px 0;">
431
431
  <img src=${e.remoteAccessQrDataUrl} alt="QR code for remote access URL" style="width: 180px; height: 180px; image-rendering: pixelated; border-radius: 8px;" />
432
432
  </div>`:w}
@@ -436,7 +436,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
436
436
  >${r}</a>
437
437
  <button class="setup-info-btn" title="Copy URL" @click=${async u=>{const c=u.currentTarget;try{await navigator.clipboard.writeText(r)}catch{const h=document.createElement("textarea");h.value=r,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h)}c.classList.add("copied"),setTimeout(()=>c.classList.remove("copied"),1500)}}>${L.copy}</button>
438
438
  </div>
439
- `}break}case"public-chat":{if(t="Public Chat",n=[{label:"Status",value:e.publicChatEnabled?"Enabled":"Disabled"},{label:"What",value:"A chat widget anyone can use to message your business from a web browser"},{label:"Requires",value:"Remote Access with internet access enabled — this gives your device a public URL that visitors can reach"},{label:"Access mode",value:Rg[e.publicChatAuthMode]??"Open access"},{label:"WhatsApp",value:"Sends verification codes via WhatsApp. Requires a connected WhatsApp account."},{label:"SMS",value:"Sends verification codes via text message. Uses Brevo — same API key as email. Requires prepaid SMS credits in your Brevo account."},{label:"Email",value:"Sends verification codes via email. Uses Brevo (free, 300 emails/day). Sender address is auto-detected from your verified sender in Brevo."},{label:"Provider",value:"SMS and email both use Brevo — one API key, configured in API Keys above. WhatsApp uses your connected account."}],e.publicChatEnabled&&e.publicChatFullUrl){const o=e.publicChatFullUrl;i=l`
439
+ `}break}case"public-chat":{if(t="Public Chat",n=[{label:"Status",value:e.publicChatEnabled?"Enabled":"Disabled"},{label:"What",value:"A chat widget anyone can use to message your business from a web browser"},{label:"Requires",value:"Remote Access with internet access enabled — this gives your device a public URL that visitors can reach"},{label:"Access mode",value:Dg[e.publicChatAuthMode]??"Open access"},{label:"WhatsApp",value:"Sends verification codes via WhatsApp. Requires a connected WhatsApp account."},{label:"SMS",value:"Sends verification codes via text message. Uses Brevo — same API key as email. Requires prepaid SMS credits in your Brevo account."},{label:"Email",value:"Sends verification codes via email. Uses Brevo (free, 300 emails/day). Sender address is auto-detected from your verified sender in Brevo."},{label:"Provider",value:"SMS and email both use Brevo — one API key, configured in API Keys above. WhatsApp uses your connected account."}],e.publicChatEnabled&&e.publicChatFullUrl){const o=e.publicChatFullUrl;i=l`
440
440
  ${e.publicChatQrDataUrl?l`<div style="text-align: center; padding: 12px 0;">
441
441
  <img src=${e.publicChatQrDataUrl} alt="QR code for public chat URL" style="width: 180px; height: 180px; image-rendering: pixelated; border-radius: 8px;" />
442
442
  </div>`:w}
@@ -546,7 +546,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
546
546
  </p>
547
547
  </div>
548
548
  </div>
549
- `}function xg(e){const{authConnected:t,authBusy:n,authMessage:i,authUrl:s,authCodeInput:o,authExpiresIn:a,onStartAuth:r,onSubmitAuthCode:u,onAuthCodeChange:c,onSkipToWhatsApp:h}=e;return t===!0?l`
549
+ `}function $g(e){const{authConnected:t,authBusy:n,authMessage:i,authUrl:s,authCodeInput:o,authExpiresIn:a,onStartAuth:r,onSubmitAuthCode:u,onAuthCodeChange:c,onSkipToWhatsApp:h}=e;return t===!0?l`
550
550
  <div class="setup-container">
551
551
  <div class="setup-card setup-success">
552
552
  ${Ee("auth")}
@@ -678,7 +678,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
678
678
  </p>
679
679
  </div>
680
680
  </div>
681
- `}function us(e,t){const n=new Map(t.whatsappAccounts.map(i=>[i.accountId,i]));return e.whatsappAccountId?n.get(e.whatsappAccountId)??null:e.isDefault&&t.whatsappAccounts.length===1?t.whatsappAccounts[0]??null:null}function Lt(e){var n;const t=(n=e.wsProps)==null?void 0:n.selectedWorkspace;return t?e.workspaces.find(i=>i.name===t)??null:e.workspaces[0]??null}function $g(e){const t=Lt(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??Qe().name,i=e.whatsappBusy||e.gatewayHealthLoading;if(e.renamingWorkspace&&t){const s=()=>{const o=e.renameWorkspaceName.trim();o&&e.onWorkspaceRename(t.name,o)};return l`
681
+ `}function us(e,t){const n=new Map(t.whatsappAccounts.map(i=>[i.accountId,i]));return e.whatsappAccountId?n.get(e.whatsappAccountId)??null:e.isDefault&&t.whatsappAccounts.length===1?t.whatsappAccounts[0]??null:null}function Lt(e){var n;const t=(n=e.wsProps)==null?void 0:n.selectedWorkspace;return t?e.workspaces.find(i=>i.name===t)??null:e.workspaces[0]??null}function Sg(e){const t=Lt(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??Xe().name,i=e.whatsappBusy||e.gatewayHealthLoading;if(e.renamingWorkspace&&t){const s=()=>{const o=e.renameWorkspaceName.trim();o&&e.onWorkspaceRename(t.name,o)};return l`
682
682
  <div style="display: flex; align-items: center; gap: 6px; margin-bottom: 4px;">
683
683
  <input
684
684
  type="text"
@@ -720,7 +720,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
720
720
  ${L.rotateCw}
721
721
  </button>
722
722
  </div>
723
- `}function Sg(e){return l`
723
+ `}function Ag(e){return l`
724
724
  <div class="setup-status-item">
725
725
  ${Q(e.gatewayHealthy===!1?"bad":"good")}
726
726
  <div class="setup-status-info">
@@ -737,7 +737,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
737
737
  ${L.rotateCw}
738
738
  </button>
739
739
  </div>
740
- `}function Ag(e){const t=e.authConnected===!0;return l`
740
+ `}function Cg(e){const t=e.authConnected===!0;return l`
741
741
  <div class="setup-status-item">
742
742
  ${Q(t?"good":"bad")}
743
743
  <div class="setup-status-info">
@@ -766,7 +766,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
766
766
  </button>
767
767
  `}
768
768
  </div>
769
- `}function Cg(e){return l`
769
+ `}function Eg(e){return l`
770
770
  <div class="setup-status-item" style="flex-wrap: wrap;">
771
771
  ${Q("good")}
772
772
  <div class="setup-status-info">
@@ -784,7 +784,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
784
784
  ${e.licenseRemoveConfirm?l`
785
785
  <div style="width: 100%; margin-top: 8px; margin-left: 30px;">
786
786
  <p style="color: var(--tasker-text-grey); font-size: 13px; margin: 0 0 8px;">
787
- Removing your license will disable ${Qe().name} until you enter a new key.
787
+ Removing your license will disable ${Xe().name} until you enter a new key.
788
788
  </p>
789
789
  <div style="display: flex; gap: 8px;">
790
790
  <button
@@ -806,7 +806,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
806
806
  </div>
807
807
  `:w}
808
808
  </div>
809
- `}function ka(e){var t,n;try{const i=JSON.parse(e),s=(i==null?void 0:i.error)??i,o=((n=(t=s==null?void 0:s.output)==null?void 0:t.payload)==null?void 0:n.message)??(s==null?void 0:s.message)??(i==null?void 0:i.message);if(o&&typeof o=="string")return o}catch{}return e.length>80?e.slice(0,77)+"…":e}function Eg(e){var d;const t=Lt(e);if(!t)return w;const n=us(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected),s=(n==null?void 0:n.linked)&&!i,o=!!n,a=i?"good":s?"partial":o?"bad":"unknown",r=i?"Connected":s?"Linked, not connected":o?n!=null&&n.lastError?ka(n.lastError):"Not connected":"Not paired",u=!(n!=null&&n.provider)||(n==null?void 0:n.provider)==="baileys",c=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(d=e.whatsappAccounts[0])==null?void 0:d.accountId:void 0),h=c!=null&&e.whatsappActiveQrAccountId===c;return l`
809
+ `}function ka(e){var t,n;try{const i=JSON.parse(e),s=(i==null?void 0:i.error)??i,o=((n=(t=s==null?void 0:s.output)==null?void 0:t.payload)==null?void 0:n.message)??(s==null?void 0:s.message)??(i==null?void 0:i.message);if(o&&typeof o=="string")return o}catch{}return e.length>80?e.slice(0,77)+"…":e}function Tg(e){var d;const t=Lt(e);if(!t)return w;const n=us(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected),s=(n==null?void 0:n.linked)&&!i,o=!!n,a=i?"good":s?"partial":o?"bad":"unknown",r=i?"Connected":s?"Linked, not connected":o?n!=null&&n.lastError?ka(n.lastError):"Not connected":"Not paired",u=!(n!=null&&n.provider)||(n==null?void 0:n.provider)==="baileys",c=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(d=e.whatsappAccounts[0])==null?void 0:d.accountId:void 0),h=c!=null&&e.whatsappActiveQrAccountId===c;return l`
810
810
  <div class="setup-status-item" style="flex-wrap: wrap;">
811
811
  ${Q(a)}
812
812
  <div class="setup-status-info">
@@ -837,7 +837,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
837
837
  </div>
838
838
  `:w}
839
839
  </div>
840
- `}function Tg(e){var h,d;if(!e.whatsappSettingsOpen)return w;const t=Lt(e);if(!t)return w;const n=us(t,e);if(!n)return w;const i=n.running&&n.connected,s=!n.provider||n.provider==="baileys",o=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(h=e.whatsappAccounts[0])==null?void 0:h.accountId:void 0),a=()=>e.onWhatsAppSettingsClose(),r="display: flex; justify-content: space-between; font-size: 13px;",u="color: var(--tasker-text-grey);",c="color: var(--tasker-white); text-align: right;";return l`
840
+ `}function _g(e){var h,d;if(!e.whatsappSettingsOpen)return w;const t=Lt(e);if(!t)return w;const n=us(t,e);if(!n)return w;const i=n.running&&n.connected,s=!n.provider||n.provider==="baileys",o=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(h=e.whatsappAccounts[0])==null?void 0:h.accountId:void 0),a=()=>e.onWhatsAppSettingsClose(),r="display: flex; justify-content: space-between; font-size: 13px;",u="color: var(--tasker-text-grey);",c="color: var(--tasker-white); text-align: right;";return l`
841
841
  <div class="setup-info-overlay" @click=${p=>{p.target.classList.contains("setup-info-overlay")&&a()}}>
842
842
  <div class="setup-info-card" style="max-width: 360px;">
843
843
  <h3>WhatsApp</h3>
@@ -931,7 +931,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
931
931
  </button>
932
932
  </div>
933
933
  </div>
934
- `}function xa(e){const t=Lt(e),n=e.imessageOwnerWorkspace,i=!!(t&&n===t.name),s=!!(n&&t&&n!==t.name);return{selectedWs:t,ownerWs:n,thisWsOwns:i,anotherWsOwns:s}}function _g(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=xa(e);let s,o;return i?(s="partial",o=`Connected to ${t}`):n&&e.imessageConnected?(s="good",o="Connected"):n&&e.imessageRunning?(s="partial",o="Running, not connected"):n?(s="bad",o="Not running"):e.imessageConfigured?(s="unknown",o="Not connected"):(s="bad",o="Not configured"),l`
934
+ `}function xa(e){const t=Lt(e),n=e.imessageOwnerWorkspace,i=!!(t&&n===t.name),s=!!(n&&t&&n!==t.name);return{selectedWs:t,ownerWs:n,thisWsOwns:i,anotherWsOwns:s}}function Mg(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=xa(e);let s,o;return i?(s="partial",o=`Connected to ${t}`):n&&e.imessageConnected?(s="good",o="Connected"):n&&e.imessageRunning?(s="partial",o="Running, not connected"):n?(s="bad",o="Not running"):e.imessageConfigured?(s="unknown",o="Not connected"):(s="bad",o="Not configured"),l`
935
935
  <div class="setup-status-item" style="flex-wrap: wrap;">
936
936
  ${Q(s)}
937
937
  <div class="setup-status-info">
@@ -949,7 +949,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
949
949
  </button>
950
950
  ${w}
951
951
  </div>
952
- `}function Mg(e){if(!e.imessageEnableConfirm)return w;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=xa(e),s=()=>{e.onIMessageEnableCancel()};return n?l`
952
+ `}function Pg(e){if(!e.imessageEnableConfirm)return w;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=xa(e),s=()=>{e.onIMessageEnableCancel()};return n?l`
953
953
  <div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&s()}}>
954
954
  <div class="setup-info-card" style="text-align: center;">
955
955
  <h3>iMessage</h3>
@@ -1006,7 +1006,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1006
1006
  <div class="setup-info-card" style="text-align: center;">
1007
1007
  <h3>Enable iMessage</h3>
1008
1008
  <p style="color: var(--tasker-text-grey); font-size: 13px; margin: 8px 0 16px;">
1009
- ${Qe().name} will respond to messages in Messages.app for this business.
1009
+ ${Xe().name} will respond to messages in Messages.app for this business.
1010
1010
  </p>
1011
1011
  <button
1012
1012
  class="setup-button primary"
@@ -1025,7 +1025,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1025
1025
  </button>
1026
1026
  </div>
1027
1027
  </div>
1028
- `}function Pg(e){if(!e.isMaster)return w;const n=e.apiKeyProviders.filter(i=>i.hasKey).length;return l`
1028
+ `}function Ig(e){if(!e.isMaster)return w;const n=e.apiKeyProviders.filter(i=>i.hasKey).length;return l`
1029
1029
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
1030
1030
  <div class="setup-status-item">
1031
1031
  ${Q(n>0?"good":"bad")}
@@ -1040,8 +1040,8 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1040
1040
  >Manage</button>
1041
1041
  </div>
1042
1042
  </div>
1043
- ${Ig(e)}
1044
- `}function Ig(e){if(!e.apiKeyModalOpen)return w;const t=e.apiKeyProviders,n={};for(const c of t)c.key&&(n[c.id]=c.key);const i=(c,h)=>{const d=h==null?void 0:h.closest(".setup-apikey-input"),p=d==null?void 0:d.querySelector("input"),v=p==null?void 0:p.value.trim();!v||v===n[c]||e.onApiKeySave(c,v)},s=c=>{const h=c.currentTarget,d=h.closest(".setup-apikey-input"),p=d==null?void 0:d.querySelector("input");if(!p)return;const v=p.type==="text";p.type=v?"password":"text",h.classList.toggle("active",!v)},o=(c,h)=>{const d=h.target,p=d.closest(".setup-apikey-input"),v=d.value.trim(),$=v.length>0&&v!==n[c],S=p==null?void 0:p.querySelector(".setup-apikey-save");S&&(S.style.display=$?"":"none");const M=p==null?void 0:p.querySelector(".setup-apikey-eye");M&&(M.style.display=v.length>0?"":"none")},a=t.filter(c=>c.primary),r=t.filter(c=>!c.primary),u=c=>{const h=e.apiKeySavingProvider===c.id&&e.apiKeyBusy,d=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key saved`,p=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key removed`,v=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} disabled`,$=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} enabled`;return l`
1043
+ ${Lg(e)}
1044
+ `}function Lg(e){if(!e.apiKeyModalOpen)return w;const t=e.apiKeyProviders,n={};for(const c of t)c.key&&(n[c.id]=c.key);const i=(c,h)=>{const d=h==null?void 0:h.closest(".setup-apikey-input"),p=d==null?void 0:d.querySelector("input"),v=p==null?void 0:p.value.trim();!v||v===n[c]||e.onApiKeySave(c,v)},s=c=>{const h=c.currentTarget,d=h.closest(".setup-apikey-input"),p=d==null?void 0:d.querySelector("input");if(!p)return;const v=p.type==="text";p.type=v?"password":"text",h.classList.toggle("active",!v)},o=(c,h)=>{const d=h.target,p=d.closest(".setup-apikey-input"),v=d.value.trim(),$=v.length>0&&v!==n[c],S=p==null?void 0:p.querySelector(".setup-apikey-save");S&&(S.style.display=$?"":"none");const M=p==null?void 0:p.querySelector(".setup-apikey-eye");M&&(M.style.display=v.length>0?"":"none")},a=t.filter(c=>c.primary),r=t.filter(c=>!c.primary),u=c=>{const h=e.apiKeySavingProvider===c.id&&e.apiKeyBusy,d=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key saved`,p=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key removed`,v=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} disabled`,$=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} enabled`;return l`
1045
1045
  <div class="setup-apikey-row ${c.disabled?"disabled":""}">
1046
1046
  <div class="setup-apikey-info">
1047
1047
  <strong>${c.name}</strong>
@@ -1105,7 +1105,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1105
1105
  </div>
1106
1106
  </div>
1107
1107
  </div>
1108
- `}function Lg(e){const t=e.updateAvailable===null?"unknown":e.updateAvailable?"partial":"good",n=e.updateAvailable&&e.latestVersion?`v${e.currentVersion} → v${e.latestVersion}`:e.currentVersion?`v${e.currentVersion}`:"Unknown",i=e.updateChecking||e.updateRunning;return l`
1108
+ `}function Rg(e){const t=e.updateAvailable===null?"unknown":e.updateAvailable?"partial":"good",n=e.updateAvailable&&e.latestVersion?`v${e.currentVersion} → v${e.latestVersion}`:e.currentVersion?`v${e.currentVersion}`:"Unknown",i=e.updateChecking||e.updateRunning;return l`
1109
1109
  <div class="setup-status-item">
1110
1110
  ${Q(t)}
1111
1111
  <div class="setup-status-info">
@@ -1133,7 +1133,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1133
1133
  </button>
1134
1134
  `}
1135
1135
  </div>
1136
- `}const Rg={anonymous:"Open access",verified:"Phone OTP",choice:"Visitor chooses"};function Dg(e){const t=e.publicChatEnabled;return l`
1136
+ `}const Dg={anonymous:"Open access",verified:"Phone OTP",choice:"Visitor chooses"};function Bg(e){const t=e.publicChatEnabled;return l`
1137
1137
  <div class="setup-status-item">
1138
1138
  ${Q(t?"good":"unknown")}
1139
1139
  <div class="setup-status-info">
@@ -1153,7 +1153,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1153
1153
  @click=${e.onPublicChatToggle}
1154
1154
  >${t?L.powerOff:L.power}</button>
1155
1155
  </div>
1156
- `}function Bg(e){if(!e.publicChatSettingsOpen)return w;const t=()=>e.onPublicChatSettingsClose(),n=!!e.publicChatGreeting,i=e.publicChatAuthMode==="verified"||e.publicChatAuthMode==="choice",s=e.publicChatVerifyMethods.length>0?e.publicChatVerifyMethods:["whatsapp","sms"],o=s.includes("whatsapp"),a=s.includes("sms"),r=s.includes("email"),u=Lt(e),c=u?us(u,e):null,h=!!(c!=null&&c.connected);return l`
1156
+ `}function Ng(e){if(!e.publicChatSettingsOpen)return w;const t=()=>e.onPublicChatSettingsClose(),n=!!e.publicChatGreeting,i=e.publicChatAuthMode==="verified"||e.publicChatAuthMode==="choice",s=e.publicChatVerifyMethods.length>0?e.publicChatVerifyMethods:["whatsapp","sms"],o=s.includes("whatsapp"),a=s.includes("sms"),r=s.includes("email"),u=Lt(e),c=u?us(u,e):null,h=!!(c!=null&&c.connected);return l`
1157
1157
  <div class="setup-info-overlay" @click=${d=>{d.target.classList.contains("setup-info-overlay")&&t()}}>
1158
1158
  <div class="setup-info-card" style="max-width: 380px; max-height: 80vh; overflow-y: auto;">
1159
1159
  <h3 style="margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between;">
@@ -1281,7 +1281,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1281
1281
  </div>
1282
1282
  </div>
1283
1283
  </div>
1284
- `}function Ng(e){var r,u;if(!e.publicChatWidgetModalOpen)return w;const t=((r=e.tailscaleStatus)==null?void 0:r.publicUrl)??((u=e.tailscaleStatus)==null?void 0:u.tailnetUrl)??null,n=e.publicChatAccountId??"your-account-id",i=t??"https://YOUR-PUBLIC-URL",s=`<script src="${i}/public/widget.js"><\/script>
1284
+ `}function Og(e){var r,u;if(!e.publicChatWidgetModalOpen)return w;const t=((r=e.tailscaleStatus)==null?void 0:r.publicUrl)??((u=e.tailscaleStatus)==null?void 0:u.tailnetUrl)??null,n=e.publicChatAccountId??"your-account-id",i=t??"https://YOUR-PUBLIC-URL",s=`<script src="${i}/public/widget.js"><\/script>
1285
1285
  <script>
1286
1286
  Taskmaster.init({
1287
1287
  server: "${i}",
@@ -1311,7 +1311,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1311
1311
  </div>
1312
1312
  </div>
1313
1313
  </div>
1314
- `}const bd=[{id:"claude-opus-4-6",shortName:"Opus",description:"Most capable"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet",description:"Fast & capable"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku",description:"Fastest"}],Og=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}],Fg="anthropic/claude-sonnet-4-5-20250929";function Ug(e){const t=e.agentSettingsAgents??[],n=t.length>0?t.map(i=>{var o;return i.model?((o=bd.find(a=>i.model===`anthropic/${a.id}`))==null?void 0:o.shortName)??i.model.split("/").pop():"Sonnet"}).join(" / "):"Default";return l`
1314
+ `}const wd=[{id:"claude-opus-4-6",shortName:"Opus",description:"Most capable"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet",description:"Fast & capable"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku",description:"Fastest"}],Fg=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}],Ug="anthropic/claude-sonnet-4-5-20250929";function Wg(e){const t=e.agentSettingsAgents??[],n=t.length>0?t.map(i=>{var o;return i.model?((o=wd.find(a=>i.model===`anthropic/${a.id}`))==null?void 0:o.shortName)??i.model.split("/").pop():"Sonnet"}).join(" / "):"Default";return l`
1315
1315
  <div class="setup-status-item">
1316
1316
  ${Q("good")}
1317
1317
  <div class="setup-status-info">
@@ -1320,12 +1320,12 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1320
1320
  </div>
1321
1321
  <button class="setup-link-btn" @click=${e.onAgentSettingsToggle}>Edit</button>
1322
1322
  </div>
1323
- `}function Wg(e){if(!e.agentSettingsOpen)return w;const t=e.agentSettingsAgents??[];if(t.length===0)return w;const n=e.agentSettingsModelCatalog??[],i=new Set(n.filter(a=>a.provider==="anthropic").map(a=>a.id)),s=bd.filter(a=>i.has(a.id)),o=()=>e.onAgentSettingsToggle();return l`
1323
+ `}function Kg(e){if(!e.agentSettingsOpen)return w;const t=e.agentSettingsAgents??[];if(t.length===0)return w;const n=e.agentSettingsModelCatalog??[],i=new Set(n.filter(a=>a.provider==="anthropic").map(a=>a.id)),s=wd.filter(a=>i.has(a.id)),o=()=>e.onAgentSettingsToggle();return l`
1324
1324
  <div class="setup-info-overlay" @click=${a=>{a.target.classList.contains("setup-info-overlay")&&o()}}>
1325
1325
  <div class="setup-info-card" style="max-width: 400px;">
1326
1326
  <h3>Agent Settings</h3>
1327
1327
  <div style="display: flex; flex-direction: column; gap: 20px; margin-top: 16px;">
1328
- ${t.map(a=>{const r=a.model??Fg,u=a.thinkingLevel??"off",c=a.id.endsWith("-admin")||a.id==="admin";return l`
1328
+ ${t.map(a=>{const r=a.model??Ug,u=a.thinkingLevel??"off",c=a.id.endsWith("-admin")||a.id==="admin";return l`
1329
1329
  <div style="display: flex; flex-direction: column; gap: 10px;">
1330
1330
  <div style="font-size: 14px; font-weight: 600; color: var(--tasker-white);">
1331
1331
  ${a.label||(c?"Admin":"Public")}
@@ -1355,7 +1355,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1355
1355
  .value=${u}
1356
1356
  @change=${h=>{e.onAgentThinkingChange(a.id,h.target.value)}}
1357
1357
  >
1358
- ${Og.map(h=>l`
1358
+ ${Fg.map(h=>l`
1359
1359
  <option value=${h.value} ?selected=${u===h.value}>
1360
1360
  ${h.label}
1361
1361
  </option>
@@ -1408,7 +1408,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1408
1408
  </button>
1409
1409
  </div>
1410
1410
  </div>
1411
- `}function Kg(e){const t=!!(e.brandAccentColor||e.brandBackgroundColor||e.brandHasLogo),n=t?"good":"unknown",i=e.brandingBusy;return l`
1411
+ `}function zg(e){const t=!!(e.brandAccentColor||e.brandBackgroundColor||e.brandHasLogo),n=t?"good":"unknown",i=e.brandingBusy;return l`
1412
1412
  <div class="setup-status-item">
1413
1413
  ${Q(n)}
1414
1414
  <div class="setup-status-info">
@@ -1422,7 +1422,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1422
1422
  @click=${e.onBrandingToggle}
1423
1423
  >${i?"...":"Edit"}</button>
1424
1424
  </div>
1425
- `}function zg(e){var s;if(!e.brandingExpanded)return w;const t=e.brandingBusy,n=(s=e.wsProps)==null?void 0:s.selectedWorkspace,i=e.brandHasLogo&&n?`/brand-logo/${encodeURIComponent(n)}`:"";return l`
1425
+ `}function Hg(e){var s;if(!e.brandingExpanded)return w;const t=e.brandingBusy,n=(s=e.wsProps)==null?void 0:s.selectedWorkspace,i=e.brandHasLogo&&n?`/brand-logo/${encodeURIComponent(n)}`:"";return l`
1426
1426
  <div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&e.onBrandingToggle()}}>
1427
1427
  <div class="setup-info-card" style="max-width: 400px; position: relative;">
1428
1428
  <h3 style="margin-right: 24px;">Branding</h3>
@@ -1503,7 +1503,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1503
1503
 
1504
1504
  </div>
1505
1505
  </div>
1506
- `}function Hg(e){const t=e.tailscaleBusy,n=e.tailscaleAuthUrl,i=e.tailscaleError,s=e.tailscaleConnectSuccess,o=e.tailscaleConnectProgress,a=e.tailscaleConnectMessage;return!t&&!s&&!i?w:i&&!t?l`
1506
+ `}function qg(e){const t=e.tailscaleBusy,n=e.tailscaleAuthUrl,i=e.tailscaleError,s=e.tailscaleConnectSuccess,o=e.tailscaleConnectProgress,a=e.tailscaleConnectMessage;return!t&&!s&&!i?w:i&&!t?l`
1507
1507
  <div class="setup-info-overlay" @click=${r=>{r.target.classList.contains("setup-info-overlay")&&e.onTailscaleErrorDismiss()}}>
1508
1508
  <div class="setup-info-card" style="max-width: 380px; text-align: center;">
1509
1509
  <h3>Remote Access</h3>
@@ -1570,7 +1570,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1570
1570
  <p style="font-size: 14px; color: var(--tasker-text-grey); margin: 12px 0 0;">${a}</p>
1571
1571
  </div>
1572
1572
  </div>
1573
- `}function qg(e){if(!e.isMaster)return w;const t=e.tailscaleStatus,n=e.tailscaleBusy,i=e.tailscaleAuthUrl;if(!t)return l`
1573
+ `}function jg(e){if(!e.isMaster)return w;const t=e.tailscaleStatus,n=e.tailscaleBusy,i=e.tailscaleAuthUrl;if(!t)return l`
1574
1574
  <div class="setup-status-item">
1575
1575
  ${Q("unknown")}
1576
1576
  <div class="setup-status-info">
@@ -1701,7 +1701,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1701
1701
  background: ${s<t?"var(--tasker-accent, #00e5ff)":"rgba(255,255,255,0.15)"};
1702
1702
  "></span>`)}
1703
1703
  </span>
1704
- `}function jg(e){if(e.serverPlatform!=="linux")return w;const t=e.wifiStatus,n=e.wifiBusy;if(!t)return l`
1704
+ `}function Gg(e){if(e.serverPlatform!=="linux")return w;const t=e.wifiStatus,n=e.wifiBusy;if(!t)return l`
1705
1705
  <div class="setup-status-item">
1706
1706
  ${Q("unknown")}
1707
1707
  <div class="setup-status-info">
@@ -1731,7 +1731,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1731
1731
  @click=${e.onWifiModalToggle}
1732
1732
  >${n?"...":"Edit"}</button>
1733
1733
  </div>
1734
- `}function Gg(e){if(!e.wifiModalOpen)return w;const t=e.wifiStatus,n=e.wifiBusy,i=e.wifiNetworks,s=e.wifiSelectedSsid;return l`
1734
+ `}function Vg(e){if(!e.wifiModalOpen)return w;const t=e.wifiStatus,n=e.wifiBusy,i=e.wifiNetworks,s=e.wifiSelectedSsid;return l`
1735
1735
  <div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&e.onWifiModalToggle()}}>
1736
1736
  <div class="setup-info-card" style="max-width: 420px; position: relative;">
1737
1737
  <h3 style="margin-right: 24px;">WiFi</h3>
@@ -1843,7 +1843,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1843
1843
  `:w}
1844
1844
  </div>
1845
1845
  </div>
1846
- `}function Vg(e){return e.isMaster?e.networkPort==null?l`
1846
+ `}function Qg(e){return e.isMaster?e.networkPort==null?l`
1847
1847
  <div class="setup-status-item">
1848
1848
  ${Q("unknown")}
1849
1849
  <div class="setup-status-info">
@@ -1864,7 +1864,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1864
1864
  @click=${e.onNetworkModalToggle}
1865
1865
  >Edit</button>
1866
1866
  </div>
1867
- `:w}function Qg(e){if(!e.networkModalOpen)return w;const t=e.networkBusy,n=e.networkPortInput!==String(e.networkPort),i=e.networkHostnameInput!==e.networkHostname,s=n||i;return l`
1867
+ `:w}function Jg(e){if(!e.networkModalOpen)return w;const t=e.networkBusy,n=e.networkPortInput!==String(e.networkPort),i=e.networkHostnameInput!==e.networkHostname,s=n||i;return l`
1868
1868
  <div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&e.onNetworkModalToggle()}}>
1869
1869
  <div class="setup-info-card" style="max-width: 400px; position: relative;">
1870
1870
  <h3 style="margin-right: 24px;">Network</h3>
@@ -1934,7 +1934,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1934
1934
  </div>
1935
1935
  </div>
1936
1936
  </div>
1937
- `}function Jg(e){var i,s,o;const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return w;if(t)return l`
1937
+ `}function Yg(e){var i,s,o;const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return w;if(t)return l`
1938
1938
  <div class="setup-info-overlay">
1939
1939
  <div class="setup-info-card" style="max-width: 400px;">
1940
1940
  <h3>Software Update</h3>
@@ -1974,7 +1974,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1974
1974
  </button>
1975
1975
  </div>
1976
1976
  </div>
1977
- `}return w}function Br(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),i=t%60;return i>0?`${n}m ${i}s`:`${n}m`}function Yg(e){const t=e.accountHasPin;return l`
1977
+ `}return w}function Br(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),i=t%60;return i>0?`${n}m ${i}s`:`${n}m`}function Xg(e){const t=e.accountHasPin;return l`
1978
1978
  <div class="setup-status-item">
1979
1979
  ${Q(t?"good":"bad")}
1980
1980
  <div class="setup-status-info">
@@ -1987,7 +1987,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1987
1987
  @click=${()=>e.onAccountPinModalOpen()}
1988
1988
  >${t?"Change":"Set PIN"}</button>
1989
1989
  </div>
1990
- `}function Xg(e){if(!e.accountPinModalOpen)return w;const t=e.accountHasPin,n=e.accountPinBusy;let i="",s="",o="";const a=c=>h=>{const d=h.target;d.value=d.value.replace(/\D/g,"").slice(0,6),c(d.value)},r=(c,h)=>{var p;let d=c.querySelector(".pin-modal-validation");d||(d=document.createElement("p"),d.className="login-error pin-modal-validation",(p=c.querySelector("button[type=submit]"))==null||p.before(d)),d.textContent=h},u=c=>{c.preventDefault();const h=c.target;if(!n){if(t&&!i){r(h,"Enter your current PIN");return}if(!s){r(h,"Enter a new PIN");return}if(!o){r(h,"Confirm your new PIN");return}if(s!==o){r(h,"PINs do not match");return}if(s.length<4){r(h,"PIN must be 4–6 digits");return}e.onAccountPinSave(t?i:null,s)}};return l`
1990
+ `}function Zg(e){if(!e.accountPinModalOpen)return w;const t=e.accountHasPin,n=e.accountPinBusy;let i="",s="",o="";const a=c=>h=>{const d=h.target;d.value=d.value.replace(/\D/g,"").slice(0,6),c(d.value)},r=(c,h)=>{var p;let d=c.querySelector(".pin-modal-validation");d||(d=document.createElement("p"),d.className="login-error pin-modal-validation",(p=c.querySelector("button[type=submit]"))==null||p.before(d)),d.textContent=h},u=c=>{c.preventDefault();const h=c.target;if(!n){if(t&&!i){r(h,"Enter your current PIN");return}if(!s){r(h,"Enter a new PIN");return}if(!o){r(h,"Confirm your new PIN");return}if(s!==o){r(h,"PINs do not match");return}if(s.length<4){r(h,"PIN must be 4–6 digits");return}e.onAccountPinSave(t?i:null,s)}};return l`
1991
1991
  <div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onAccountPinModalClose()}}>
1992
1992
  <div class="setup-info-card" style="max-width: 340px;">
1993
1993
  <div class="setup-info-header">
@@ -2044,7 +2044,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2044
2044
  </form>
2045
2045
  </div>
2046
2046
  </div>
2047
- `}function Zg(e){if(!e.addingWorkspace)return w;const{workspaceSaving:t}=e,n=()=>{e.newWorkspaceName.trim()&&e.newWorkspacePin.match(/^\d{4,6}$/)&&e.onWorkspaceCreate(e.newWorkspaceName,e.newWorkspacePath||void 0)},i=s=>{const o=s.currentTarget,a=o.closest(".login-pin-wrapper"),r=a==null?void 0:a.querySelector("input");if(!r)return;const u=r.type==="text";r.type=u?"password":"text",o.classList.toggle("active",!u)};return l`
2047
+ `}function em(e){if(!e.addingWorkspace)return w;const{workspaceSaving:t}=e,n=()=>{e.newWorkspaceName.trim()&&e.newWorkspacePin.match(/^\d{4,6}$/)&&e.onWorkspaceCreate(e.newWorkspaceName,e.newWorkspacePath||void 0)},i=s=>{const o=s.currentTarget,a=o.closest(".login-pin-wrapper"),r=a==null?void 0:a.querySelector("input");if(!r)return;const u=r.type==="text";r.type=u?"password":"text",o.classList.toggle("active",!u)};return l`
2048
2048
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
2049
2049
  <div class="setup-add-account">
2050
2050
  <strong>New Account</strong>
@@ -2107,7 +2107,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2107
2107
  </div>
2108
2108
  </div>
2109
2109
  </div>
2110
- `}function em(e){const t=Lt(e);return!t||t.isDefault?w:e.workspaceRemoveConfirm===t.name?l`
2110
+ `}function tm(e){const t=Lt(e);return!t||t.isDefault?w:e.workspaceRemoveConfirm===t.name?l`
2111
2111
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 12px;">
2112
2112
  <div style="font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
2113
2113
  <span style="color: var(--tasker-danger, #ef4444);">Remove "${t.displayName??t.name}" and its WhatsApp account?</span>
@@ -2136,7 +2136,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2136
2136
  @click=${i=>{i.preventDefault(),e.onSetWorkspaceRemoveConfirm(t.name)}}
2137
2137
  >Remove Account</a>
2138
2138
  </p>
2139
- `}function tm(e){if(e.uninstallDone)return l`
2139
+ `}function nm(e){if(e.uninstallDone)return l`
2140
2140
  <div style="margin-top: 24px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
2141
2141
  <p style="color: var(--tasker-danger, #ef4444); font-size: 13px; font-weight: 600; margin: 0 0 8px 0;">
2142
2142
  Taskmaster has been uninstalled.
@@ -2191,11 +2191,11 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2191
2191
  @click=${t=>{t.preventDefault(),e.onUninstallConfirm()}}
2192
2192
  >Uninstall Taskmaster</a>
2193
2193
  </p>
2194
- `}function nm(){return l`
2194
+ `}function im(){return l`
2195
2195
  <p class="setup-hint" style="margin-top: 4px; font-size: 12px; opacity: 0.6;">
2196
2196
  Need help? <a href="https://wa.me/447591215452" target="_blank" rel="noopener" style="color: var(--tasker-orange);">Message Tuesday on WhatsApp</a>
2197
2197
  </p>
2198
- `}function im(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:i,whatsappLoginConnected:s,whatsappChannelStatus:o}=e;if(i)return l`
2198
+ `}function sm(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:i,whatsappLoginConnected:s,whatsappChannelStatus:o}=e;if(i)return l`
2199
2199
  <div class="setup-container">
2200
2200
  <div class="setup-card">
2201
2201
  <h1>Scan with WhatsApp</h1>
@@ -2209,7 +2209,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2209
2209
  Scan the code above with your phone
2210
2210
  </p>`}
2211
2211
  <p class="setup-hint" style="margin-top: 16px;">
2212
- <strong>Important:</strong> If you see "${Qe().name}" in your Linked
2212
+ <strong>Important:</strong> If you see "${Xe().name}" in your Linked
2213
2213
  Devices, remove it first before scanning.
2214
2214
  </p>
2215
2215
  <div class="setup-actions" style="margin-top: 24px;">
@@ -2232,35 +2232,35 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2232
2232
  `;const a=(o==null?void 0:o.running)&&(o==null?void 0:o.connected);if(o){const h=(e.whatsappAccounts.length>1?e.whatsappAccounts.every(d=>d.running&&d.connected):a)&&e.authConnected;return l`
2233
2233
  <div class="setup-container">
2234
2234
  <div class="setup-card ${h?"setup-success":""} setup-dashboard-wide">
2235
- ${$g(e)}
2235
+ ${Sg(e)}
2236
2236
  <div class="setup-status-dashboard">
2237
- ${Sg(e)}
2238
2237
  ${Ag(e)}
2239
2238
  ${Cg(e)}
2240
2239
  ${Eg(e)}
2241
- ${e.serverPlatform==="darwin"?_g(e):w}
2242
- ${Ug(e)}
2243
- ${Yg(e)}
2244
- ${Lg(e)}
2245
- ${Dg(e)}
2246
- ${Kg(e)}
2247
- ${qg(e)}
2248
- ${Vg(e)}
2240
+ ${Tg(e)}
2241
+ ${e.serverPlatform==="darwin"?Mg(e):w}
2242
+ ${Wg(e)}
2243
+ ${Xg(e)}
2244
+ ${Rg(e)}
2245
+ ${Bg(e)}
2246
+ ${zg(e)}
2249
2247
  ${jg(e)}
2248
+ ${Qg(e)}
2249
+ ${Gg(e)}
2250
2250
  </div>
2251
2251
 
2252
- ${Wg(e)}
2253
- ${Xg(e)}
2254
- ${zg(e)}
2255
- ${Bg(e)}
2256
- ${Qg(e)}
2257
- ${Gg(e)}
2258
- ${Hg(e)}
2259
- ${Pg(e)}
2252
+ ${Kg(e)}
2260
2253
  ${Zg(e)}
2254
+ ${Hg(e)}
2255
+ ${Ng(e)}
2256
+ ${Jg(e)}
2257
+ ${Vg(e)}
2258
+ ${qg(e)}
2259
+ ${Ig(e)}
2261
2260
  ${em(e)}
2262
2261
  ${tm(e)}
2263
- ${nm()}
2262
+ ${nm(e)}
2263
+ ${im()}
2264
2264
  ${e.workspacesError?l`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:w}
2265
2265
  </div>
2266
2266
  </div>
@@ -2305,7 +2305,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2305
2305
  </button>
2306
2306
  </div>
2307
2307
  </div>
2308
- `}function sm(e){const{connected:t,currentStep:n}=e;if(t&&zi()&&wa(),e.uninstallDone||!t&&zi())return l`
2308
+ `}function om(e){const{connected:t,currentStep:n}=e;if(t&&zi()&&wa(),e.uninstallDone||!t&&zi())return l`
2309
2309
  <div class="setup-container">
2310
2310
  <div class="setup-card">
2311
2311
  <p style="color: var(--tasker-danger, #ef4444); font-size: 16px; font-weight: 600; margin: 0 0 12px 0;">
@@ -2328,7 +2328,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2328
2328
  <p>${o?"Restarting gateway after update…":"Connecting to gateway..."}</p>
2329
2329
  </div>
2330
2330
  </div>
2331
- `}let i;switch(n){case"license":i=Dr(e);break;case"auth":i=xg(e);break;case"whatsapp":case"complete":i=im(e);break;default:i=Dr(e)}const s=It("Setup",e.wsProps);return l`${i}${kg(e)}${Mg(e)}${Tg(e)}${Jg(e)}${Ng(e)}${s}`}function om(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return l`
2331
+ `}let i;switch(n){case"license":i=Dr(e);break;case"auth":i=$g(e);break;case"whatsapp":case"complete":i=sm(e);break;default:i=Dr(e)}const s=It("Setup",e.wsProps);return l`${i}${xg(e)}${Pg(e)}${_g(e)}${Yg(e)}${Og(e)}${s}`}function am(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return l`
2332
2332
  <div class="sp-list-item">
2333
2333
  <div class="sp-list-item-main">
2334
2334
  <div class="sp-list-item-title">${e.phone}</div>
@@ -2343,7 +2343,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2343
2343
  Remove
2344
2344
  </button>`}
2345
2345
  </div>
2346
- `}function am(e){if(!e.connected)return l`
2346
+ `}function rm(e){if(!e.connected)return l`
2347
2347
  <div class="setup-container">
2348
2348
  <div class="setup-card">
2349
2349
  <div class="setup-spinner"></div>
@@ -2392,7 +2392,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2392
2392
  </form>
2393
2393
 
2394
2394
  <div class="sp-list" style="margin-top: 20px;">
2395
- ${e.phones.length===0?l`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>om(n,e))}
2395
+ ${e.phones.length===0?l`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>am(n,e))}
2396
2396
  </div>
2397
2397
 
2398
2398
  <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
@@ -2403,13 +2403,13 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2403
2403
 
2404
2404
  </div>
2405
2405
  </div>
2406
- `}const wd=l`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`;function rm(e){return Object.keys(e.fields).length}function lm(e,t){return l`
2406
+ `}const kd=l`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`;function lm(e){return Object.keys(e.fields).length}function cm(e,t){return l`
2407
2407
  <div class="event-modal-overlay" @click=${t.onDeleteConfirmClose}>
2408
2408
  <div class="event-modal" style="width: min(400px, 100%);" @click=${n=>n.stopPropagation()}>
2409
2409
  <div class="event-modal__header">
2410
2410
  <div class="event-modal__title">Delete Contact</div>
2411
2411
  <button class="event-modal__close" @click=${t.onDeleteConfirmClose}>
2412
- ${wd}
2412
+ ${kd}
2413
2413
  </button>
2414
2414
  </div>
2415
2415
  <p style="margin: 0 0 8px; color: rgba(255,255,255,0.7); font-size: 14px; line-height: 1.5;">
@@ -2435,13 +2435,13 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2435
2435
  </div>
2436
2436
  </div>
2437
2437
  </div>
2438
- `}function cm(e,t){const n=t.addFieldKey.trim().length>0,i=s=>{s.preventDefault(),n&&t.onAddFieldSubmit()};return l`
2438
+ `}function dm(e,t){const n=t.addFieldKey.trim().length>0,i=s=>{s.preventDefault(),n&&t.onAddFieldSubmit()};return l`
2439
2439
  <div class="event-modal-overlay" @click=${t.onAddFieldClose}>
2440
2440
  <div class="event-modal" style="width: min(400px, 100%);" @click=${s=>s.stopPropagation()}>
2441
2441
  <div class="event-modal__header">
2442
2442
  <div class="event-modal__title">Add Field</div>
2443
2443
  <button class="event-modal__close" @click=${t.onAddFieldClose}>
2444
- ${wd}
2444
+ ${kd}
2445
2445
  </button>
2446
2446
  </div>
2447
2447
  <p style="margin: 0 0 16px; color: rgba(255,255,255,0.5); font-size: 13px;">
@@ -2486,7 +2486,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2486
2486
  </form>
2487
2487
  </div>
2488
2488
  </div>
2489
- `}function dm(e,t){const n=Object.entries(e.fields);return l`
2489
+ `}function um(e,t){const n=Object.entries(e.fields);return l`
2490
2490
  <div class="contacts-record-fields">
2491
2491
  ${n.length===0?l`<div style="color: rgba(255,255,255,0.4); font-size: 13px; margin-top: 12px;">No fields yet. Add one below.</div>`:n.map(([i,s])=>l`
2492
2492
  <div class="contacts-field-row">
@@ -2533,7 +2533,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2533
2533
  </button>
2534
2534
  </div>
2535
2535
  </div>
2536
- `}function um(e,t){const n=t.editingId===e.id,i=rm(e),s=i===0?"No fields":`${i} field${i>1?"s":""}`;return l`
2536
+ `}function pm(e,t){const n=t.editingId===e.id,i=lm(e),s=i===0?"No fields":`${i} field${i>1?"s":""}`;return l`
2537
2537
  <div class="contacts-record">
2538
2538
  <div
2539
2539
  class="contacts-record-header"
@@ -2545,9 +2545,9 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2545
2545
  </div>
2546
2546
  <span class="contacts-record-meta">${s}</span>
2547
2547
  </div>
2548
- ${n?dm(e,t):w}
2548
+ ${n?um(e,t):w}
2549
2549
  </div>
2550
- `}function pm(e){if(!e.connected)return l`
2550
+ `}function hm(e){if(!e.connected)return l`
2551
2551
  <div class="setup-container">
2552
2552
  <div class="setup-card">
2553
2553
  <div class="setup-spinner"></div>
@@ -2643,7 +2643,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2643
2643
  <div style="margin-top: 16px;">
2644
2644
  ${e.records.length===0?l`<div class="contacts-empty">
2645
2645
  ${e.searchQuery.trim()?`No records matching "${e.searchQuery}".`:"No contact records yet. Add one to get started."}
2646
- </div>`:e.records.map(o=>um(o,e))}
2646
+ </div>`:e.records.map(o=>pm(o,e))}
2647
2647
  </div>
2648
2648
 
2649
2649
  <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
@@ -2655,14 +2655,14 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2655
2655
  </div>
2656
2656
  </div>
2657
2657
 
2658
- ${i?lm(i,e):w}
2659
- ${s?cm(s,e):w}
2660
- `}const kd={CHILD:2},xd=e=>(...t)=>({_$litDirective$:e,values:t});let $d=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,i){this._$Ct=t,this._$AM=n,this._$Ci=i}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:hm}=gp,Nr=e=>e,Or=()=>document.createComment(""),gn=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const a=i.insertBefore(Or(),s),r=i.insertBefore(Or(),s);n=new hm(a,r,e,e.options)}else{const a=n._$AB.nextSibling,r=n._$AM,u=r!==e;if(u){let c;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==r._$AU&&n._$AP(c)}if(a!==s||u){let c=n._$AA;for(;c!==a;){const h=Nr(c).nextSibling;Nr(i).insertBefore(c,s),c=h}}}return n},ft=(e,t,n=e)=>(e._$AI(t,n),e),fm={},gm=(e,t=fm)=>e._$AH=t,mm=e=>e._$AH,zs=e=>{e._$AR(),e._$AA.remove()};const Fr=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},ym=xd(class extends $d{constructor(e){if(super(e),e.type!==kd.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let i;n===void 0?n=t:t!==void 0&&(i=t);const s=[],o=[];let a=0;for(const r of e)s[a]=i?i(r,a):a,o[a]=n(r,a),a++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=mm(e),{values:o,keys:a}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=a,o;const r=this.ut??(this.ut=[]),u=[];let c,h,d=0,p=s.length-1,v=0,$=o.length-1;for(;d<=p&&v<=$;)if(s[d]===null)d++;else if(s[p]===null)p--;else if(r[d]===a[v])u[v]=ft(s[d],o[v]),d++,v++;else if(r[p]===a[$])u[$]=ft(s[p],o[$]),p--,$--;else if(r[d]===a[$])u[$]=ft(s[d],o[$]),gn(e,u[$+1],s[d]),d++,$--;else if(r[p]===a[v])u[v]=ft(s[p],o[v]),gn(e,s[d],s[p]),p--,v++;else if(c===void 0&&(c=Fr(a,v,$),h=Fr(r,d,p)),c.has(r[d]))if(c.has(r[p])){const S=h.get(a[v]),M=S!==void 0?s[S]:null;if(M===null){const y=gn(e,s[d]);ft(y,o[v]),u[v]=y}else u[v]=ft(M,o[v]),gn(e,s[d],M),s[S]=null;v++}else zs(s[p]),p--;else zs(s[d]),d++;for(;v<=$;){const S=gn(e,u[$+1]);ft(S,o[v]),u[v++]=S}for(;d<=p;){const S=s[d++];S!==null&&zs(S)}return this.ut=a,gm(e,u),at}});class _o extends $d{constructor(t){if(super(t),this.it=w,t.type!==kd.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===w||t==null)return this._t=void 0,this.it=t;if(t===at)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:[]}}}_o.directiveName="unsafeHTML",_o.resultType=1;const Hi=xd(_o);const{entries:Sd,setPrototypeOf:Ur,isFrozen:vm,getPrototypeOf:bm,getOwnPropertyDescriptor:wm}=Object;let{freeze:me,seal:xe,create:Mo}=Object,{apply:Po,construct:Io}=typeof Reflect<"u"&&Reflect;me||(me=function(t){return t});xe||(xe=function(t){return t});Po||(Po=function(t,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),o=2;o<i;o++)s[o-2]=arguments[o];return t.apply(n,s)});Io||(Io=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return new t(...i)});const hi=ye(Array.prototype.forEach),km=ye(Array.prototype.lastIndexOf),Wr=ye(Array.prototype.pop),mn=ye(Array.prototype.push),xm=ye(Array.prototype.splice),Ci=ye(String.prototype.toLowerCase),Hs=ye(String.prototype.toString),qs=ye(String.prototype.match),yn=ye(String.prototype.replace),$m=ye(String.prototype.indexOf),Sm=ye(String.prototype.trim),$e=ye(Object.prototype.hasOwnProperty),fe=ye(RegExp.prototype.test),vn=Am(TypeError);function ye(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return Po(e,t,i)}}function Am(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Io(e,n)}}function K(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ci;Ur&&Ur(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(vm(t)||(t[i]=o),s=o)}e[s]=!0}return e}function Cm(e){for(let t=0;t<e.length;t++)$e(e,t)||(e[t]=null);return e}function Re(e){const t=Mo(null);for(const[n,i]of Sd(e))$e(e,n)&&(Array.isArray(i)?t[n]=Cm(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Re(i):t[n]=i);return t}function bn(e,t){for(;e!==null;){const i=wm(e,t);if(i){if(i.get)return ye(i.get);if(typeof i.value=="function")return ye(i.value)}e=bm(e)}function n(){return null}return n}const Kr=me(["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"]),js=me(["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"]),Gs=me(["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"]),Em=me(["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"]),Vs=me(["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"]),Tm=me(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),zr=me(["#text"]),Hr=me(["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"]),Qs=me(["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"]),qr=me(["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"]),fi=me(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),_m=xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Mm=xe(/<%[\w\W]*|[\w\W]*%>/gm),Pm=xe(/\$\{[\w\W]*/gm),Im=xe(/^data-[\-\w.\u00B7-\uFFFF]+$/),Lm=xe(/^aria-[\-\w]+$/),Ad=xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Rm=xe(/^(?:\w+script|data):/i),Dm=xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Cd=xe(/^html$/i),Bm=xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var jr=Object.freeze({__proto__:null,ARIA_ATTR:Lm,ATTR_WHITESPACE:Dm,CUSTOM_ELEMENT:Bm,DATA_ATTR:Im,DOCTYPE_NAME:Cd,ERB_EXPR:Mm,IS_ALLOWED_URI:Ad,IS_SCRIPT_OR_DATA:Rm,MUSTACHE_EXPR:_m,TMPLIT_EXPR:Pm});const wn={element:1,text:3,progressingInstruction:7,comment:8,document:9},Nm=function(){return typeof window>"u"?null:window},Om=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(i=n.getAttribute(s));const o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Gr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ed(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Nm();const t=N=>Ed(N);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==wn.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:r,Element:u,NodeFilter:c,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:p,trustedTypes:v}=e,$=u.prototype,S=bn($,"cloneNode"),M=bn($,"remove"),y=bn($,"nextSibling"),b=bn($,"childNodes"),k=bn($,"parentNode");if(typeof a=="function"){const N=n.createElement("template");N.content&&N.content.ownerDocument&&(n=N.content.ownerDocument)}let A,E="";const{implementation:T,createNodeIterator:P,createDocumentFragment:D,getElementsByTagName:W}=n,{importNode:z}=i;let H=Gr();t.isSupported=typeof Sd=="function"&&typeof k=="function"&&T&&T.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ke,ERB_EXPR:_e,TMPLIT_EXPR:Ue,DATA_ATTR:vs,ARIA_ATTR:bs,IS_SCRIPT_OR_DATA:ws,ATTR_WHITESPACE:Qn,CUSTOM_ELEMENT:ks}=jr;let{IS_ALLOWED_URI:Jn}=jr,te=null;const Yn=K({},[...Kr,...js,...Gs,...Vs,...zr]);let ne=null;const Xn=K({},[...Hr,...Qs,...qr,...fi]);let X=Object.seal(Mo(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}})),dt=null,dn=null;const Ze=Object.seal(Mo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Zn=!0,C=!0,I=!1,F=!0,U=!1,Z=!0,J=!1,he=!1,et=!1,Bt=!1,ei=!1,ti=!1,za=!0,Ha=!1;const Ou="user-content-";let xs=!0,un=!1,Nt={},Me=null;const $s=K({},["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 qa=null;const ja=K({},["audio","video","img","source","image","track"]);let Ss=null;const Ga=K({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ni="http://www.w3.org/1998/Math/MathML",ii="http://www.w3.org/2000/svg",We="http://www.w3.org/1999/xhtml";let Ot=We,As=!1,Cs=null;const Fu=K({},[ni,ii,We],Hs);let si=K({},["mi","mo","mn","ms","mtext"]),oi=K({},["annotation-xml"]);const Uu=K({},["title","style","font","a","script"]);let pn=null;const Wu=["application/xhtml+xml","text/html"],Ku="text/html";let oe=null,Ft=null;const zu=n.createElement("form"),Va=function(x){return x instanceof RegExp||x instanceof Function},Es=function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ft&&Ft===x)){if((!x||typeof x!="object")&&(x={}),x=Re(x),pn=Wu.indexOf(x.PARSER_MEDIA_TYPE)===-1?Ku:x.PARSER_MEDIA_TYPE,oe=pn==="application/xhtml+xml"?Hs:Ci,te=$e(x,"ALLOWED_TAGS")?K({},x.ALLOWED_TAGS,oe):Yn,ne=$e(x,"ALLOWED_ATTR")?K({},x.ALLOWED_ATTR,oe):Xn,Cs=$e(x,"ALLOWED_NAMESPACES")?K({},x.ALLOWED_NAMESPACES,Hs):Fu,Ss=$e(x,"ADD_URI_SAFE_ATTR")?K(Re(Ga),x.ADD_URI_SAFE_ATTR,oe):Ga,qa=$e(x,"ADD_DATA_URI_TAGS")?K(Re(ja),x.ADD_DATA_URI_TAGS,oe):ja,Me=$e(x,"FORBID_CONTENTS")?K({},x.FORBID_CONTENTS,oe):$s,dt=$e(x,"FORBID_TAGS")?K({},x.FORBID_TAGS,oe):Re({}),dn=$e(x,"FORBID_ATTR")?K({},x.FORBID_ATTR,oe):Re({}),Nt=$e(x,"USE_PROFILES")?x.USE_PROFILES:!1,Zn=x.ALLOW_ARIA_ATTR!==!1,C=x.ALLOW_DATA_ATTR!==!1,I=x.ALLOW_UNKNOWN_PROTOCOLS||!1,F=x.ALLOW_SELF_CLOSE_IN_ATTR!==!1,U=x.SAFE_FOR_TEMPLATES||!1,Z=x.SAFE_FOR_XML!==!1,J=x.WHOLE_DOCUMENT||!1,Bt=x.RETURN_DOM||!1,ei=x.RETURN_DOM_FRAGMENT||!1,ti=x.RETURN_TRUSTED_TYPE||!1,et=x.FORCE_BODY||!1,za=x.SANITIZE_DOM!==!1,Ha=x.SANITIZE_NAMED_PROPS||!1,xs=x.KEEP_CONTENT!==!1,un=x.IN_PLACE||!1,Jn=x.ALLOWED_URI_REGEXP||Ad,Ot=x.NAMESPACE||We,si=x.MATHML_TEXT_INTEGRATION_POINTS||si,oi=x.HTML_INTEGRATION_POINTS||oi,X=x.CUSTOM_ELEMENT_HANDLING||{},x.CUSTOM_ELEMENT_HANDLING&&Va(x.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(X.tagNameCheck=x.CUSTOM_ELEMENT_HANDLING.tagNameCheck),x.CUSTOM_ELEMENT_HANDLING&&Va(x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(X.attributeNameCheck=x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),x.CUSTOM_ELEMENT_HANDLING&&typeof x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(X.allowCustomizedBuiltInElements=x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),U&&(C=!1),ei&&(Bt=!0),Nt&&(te=K({},zr),ne=[],Nt.html===!0&&(K(te,Kr),K(ne,Hr)),Nt.svg===!0&&(K(te,js),K(ne,Qs),K(ne,fi)),Nt.svgFilters===!0&&(K(te,Gs),K(ne,Qs),K(ne,fi)),Nt.mathMl===!0&&(K(te,Vs),K(ne,qr),K(ne,fi))),x.ADD_TAGS&&(typeof x.ADD_TAGS=="function"?Ze.tagCheck=x.ADD_TAGS:(te===Yn&&(te=Re(te)),K(te,x.ADD_TAGS,oe))),x.ADD_ATTR&&(typeof x.ADD_ATTR=="function"?Ze.attributeCheck=x.ADD_ATTR:(ne===Xn&&(ne=Re(ne)),K(ne,x.ADD_ATTR,oe))),x.ADD_URI_SAFE_ATTR&&K(Ss,x.ADD_URI_SAFE_ATTR,oe),x.FORBID_CONTENTS&&(Me===$s&&(Me=Re(Me)),K(Me,x.FORBID_CONTENTS,oe)),x.ADD_FORBID_CONTENTS&&(Me===$s&&(Me=Re(Me)),K(Me,x.ADD_FORBID_CONTENTS,oe)),xs&&(te["#text"]=!0),J&&K(te,["html","head","body"]),te.table&&(K(te,["tbody"]),delete dt.tbody),x.TRUSTED_TYPES_POLICY){if(typeof x.TRUSTED_TYPES_POLICY.createHTML!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof x.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=x.TRUSTED_TYPES_POLICY,E=A.createHTML("")}else A===void 0&&(A=Om(v,s)),A!==null&&typeof E=="string"&&(E=A.createHTML(""));me&&me(x),Ft=x}},Qa=K({},[...js,...Gs,...Em]),Ja=K({},[...Vs,...Tm]),Hu=function(x){let _=k(x);(!_||!_.tagName)&&(_={namespaceURI:Ot,tagName:"template"});const B=Ci(x.tagName),Y=Ci(_.tagName);return Cs[x.namespaceURI]?x.namespaceURI===ii?_.namespaceURI===We?B==="svg":_.namespaceURI===ni?B==="svg"&&(Y==="annotation-xml"||si[Y]):!!Qa[B]:x.namespaceURI===ni?_.namespaceURI===We?B==="math":_.namespaceURI===ii?B==="math"&&oi[Y]:!!Ja[B]:x.namespaceURI===We?_.namespaceURI===ii&&!oi[Y]||_.namespaceURI===ni&&!si[Y]?!1:!Ja[B]&&(Uu[B]||!Qa[B]):!!(pn==="application/xhtml+xml"&&Cs[x.namespaceURI]):!1},Pe=function(x){mn(t.removed,{element:x});try{k(x).removeChild(x)}catch{M(x)}},ut=function(x,_){try{mn(t.removed,{attribute:_.getAttributeNode(x),from:_})}catch{mn(t.removed,{attribute:null,from:_})}if(_.removeAttribute(x),x==="is")if(Bt||ei)try{Pe(_)}catch{}else try{_.setAttribute(x,"")}catch{}},Ya=function(x){let _=null,B=null;if(et)x="<remove></remove>"+x;else{const se=qs(x,/^[\r\n\t ]+/);B=se&&se[0]}pn==="application/xhtml+xml"&&Ot===We&&(x='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+x+"</body></html>");const Y=A?A.createHTML(x):x;if(Ot===We)try{_=new p().parseFromString(Y,pn)}catch{}if(!_||!_.documentElement){_=T.createDocument(Ot,"template",null);try{_.documentElement.innerHTML=As?E:Y}catch{}}const de=_.body||_.documentElement;return x&&B&&de.insertBefore(n.createTextNode(B),de.childNodes[0]||null),Ot===We?W.call(_,J?"html":"body")[0]:J?_.documentElement:de},Xa=function(x){return P.call(x.ownerDocument||x,x,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ts=function(x){return x instanceof d&&(typeof x.nodeName!="string"||typeof x.textContent!="string"||typeof x.removeChild!="function"||!(x.attributes instanceof h)||typeof x.removeAttribute!="function"||typeof x.setAttribute!="function"||typeof x.namespaceURI!="string"||typeof x.insertBefore!="function"||typeof x.hasChildNodes!="function")},Za=function(x){return typeof r=="function"&&x instanceof r};function Ke(N,x,_){hi(N,B=>{B.call(t,x,_,Ft)})}const er=function(x){let _=null;if(Ke(H.beforeSanitizeElements,x,null),Ts(x))return Pe(x),!0;const B=oe(x.nodeName);if(Ke(H.uponSanitizeElement,x,{tagName:B,allowedTags:te}),Z&&x.hasChildNodes()&&!Za(x.firstElementChild)&&fe(/<[/\w!]/g,x.innerHTML)&&fe(/<[/\w!]/g,x.textContent)||x.nodeType===wn.progressingInstruction||Z&&x.nodeType===wn.comment&&fe(/<[/\w]/g,x.data))return Pe(x),!0;if(!(Ze.tagCheck instanceof Function&&Ze.tagCheck(B))&&(!te[B]||dt[B])){if(!dt[B]&&nr(B)&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B)))return!1;if(xs&&!Me[B]){const Y=k(x)||x.parentNode,de=b(x)||x.childNodes;if(de&&Y){const se=de.length;for(let ve=se-1;ve>=0;--ve){const ze=S(de[ve],!0);ze.__removalCount=(x.__removalCount||0)+1,Y.insertBefore(ze,y(x))}}}return Pe(x),!0}return x instanceof u&&!Hu(x)||(B==="noscript"||B==="noembed"||B==="noframes")&&fe(/<\/no(script|embed|frames)/i,x.innerHTML)?(Pe(x),!0):(U&&x.nodeType===wn.text&&(_=x.textContent,hi([ke,_e,Ue],Y=>{_=yn(_,Y," ")}),x.textContent!==_&&(mn(t.removed,{element:x.cloneNode()}),x.textContent=_)),Ke(H.afterSanitizeElements,x,null),!1)},tr=function(x,_,B){if(za&&(_==="id"||_==="name")&&(B in n||B in zu))return!1;if(!(C&&!dn[_]&&fe(vs,_))){if(!(Zn&&fe(bs,_))){if(!(Ze.attributeCheck instanceof Function&&Ze.attributeCheck(_,x))){if(!ne[_]||dn[_]){if(!(nr(x)&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,x)||X.tagNameCheck instanceof Function&&X.tagNameCheck(x))&&(X.attributeNameCheck instanceof RegExp&&fe(X.attributeNameCheck,_)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(_,x))||_==="is"&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B))))return!1}else if(!Ss[_]){if(!fe(Jn,yn(B,Qn,""))){if(!((_==="src"||_==="xlink:href"||_==="href")&&x!=="script"&&$m(B,"data:")===0&&qa[x])){if(!(I&&!fe(ws,yn(B,Qn,"")))){if(B)return!1}}}}}}}return!0},nr=function(x){return x!=="annotation-xml"&&qs(x,ks)},ir=function(x){Ke(H.beforeSanitizeAttributes,x,null);const{attributes:_}=x;if(!_||Ts(x))return;const B={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let Y=_.length;for(;Y--;){const de=_[Y],{name:se,namespaceURI:ve,value:ze}=de,Ut=oe(se),_s=ze;let le=se==="value"?_s:Sm(_s);if(B.attrName=Ut,B.attrValue=le,B.keepAttr=!0,B.forceKeepAttr=void 0,Ke(H.uponSanitizeAttribute,x,B),le=B.attrValue,Ha&&(Ut==="id"||Ut==="name")&&(ut(se,x),le=Ou+le),Z&&fe(/((--!?|])>)|<\/(style|title|textarea)/i,le)){ut(se,x);continue}if(Ut==="attributename"&&qs(le,"href")){ut(se,x);continue}if(B.forceKeepAttr)continue;if(!B.keepAttr){ut(se,x);continue}if(!F&&fe(/\/>/i,le)){ut(se,x);continue}U&&hi([ke,_e,Ue],or=>{le=yn(le,or," ")});const sr=oe(x.nodeName);if(!tr(sr,Ut,le)){ut(se,x);continue}if(A&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!ve)switch(v.getAttributeType(sr,Ut)){case"TrustedHTML":{le=A.createHTML(le);break}case"TrustedScriptURL":{le=A.createScriptURL(le);break}}if(le!==_s)try{ve?x.setAttributeNS(ve,se,le):x.setAttribute(se,le),Ts(x)?Pe(x):Wr(t.removed)}catch{ut(se,x)}}Ke(H.afterSanitizeAttributes,x,null)},qu=function N(x){let _=null;const B=Xa(x);for(Ke(H.beforeSanitizeShadowDOM,x,null);_=B.nextNode();)Ke(H.uponSanitizeShadowNode,_,null),er(_),ir(_),_.content instanceof o&&N(_.content);Ke(H.afterSanitizeShadowDOM,x,null)};return t.sanitize=function(N){let x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=null,B=null,Y=null,de=null;if(As=!N,As&&(N="<!-->"),typeof N!="string"&&!Za(N))if(typeof N.toString=="function"){if(N=N.toString(),typeof N!="string")throw vn("dirty is not a string, aborting")}else throw vn("toString is not a function");if(!t.isSupported)return N;if(he||Es(x),t.removed=[],typeof N=="string"&&(un=!1),un){if(N.nodeName){const ze=oe(N.nodeName);if(!te[ze]||dt[ze])throw vn("root node is forbidden and cannot be sanitized in-place")}}else if(N instanceof r)_=Ya("<!---->"),B=_.ownerDocument.importNode(N,!0),B.nodeType===wn.element&&B.nodeName==="BODY"||B.nodeName==="HTML"?_=B:_.appendChild(B);else{if(!Bt&&!U&&!J&&N.indexOf("<")===-1)return A&&ti?A.createHTML(N):N;if(_=Ya(N),!_)return Bt?null:ti?E:""}_&&et&&Pe(_.firstChild);const se=Xa(un?N:_);for(;Y=se.nextNode();)er(Y),ir(Y),Y.content instanceof o&&qu(Y.content);if(un)return N;if(Bt){if(ei)for(de=D.call(_.ownerDocument);_.firstChild;)de.appendChild(_.firstChild);else de=_;return(ne.shadowroot||ne.shadowrootmode)&&(de=z.call(i,de,!0)),de}let ve=J?_.outerHTML:_.innerHTML;return J&&te["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&fe(Cd,_.ownerDocument.doctype.name)&&(ve="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
2661
- `+ve),U&&hi([ke,_e,Ue],ze=>{ve=yn(ve,ze," ")}),A&&ti?A.createHTML(ve):ve},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Es(N),he=!0},t.clearConfig=function(){Ft=null,he=!1},t.isValidAttribute=function(N,x,_){Ft||Es({});const B=oe(N),Y=oe(x);return tr(B,Y,_)},t.addHook=function(N,x){typeof x=="function"&&mn(H[N],x)},t.removeHook=function(N,x){if(x!==void 0){const _=km(H[N],x);return _===-1?void 0:xm(H[N],_,1)[0]}return Wr(H[N])},t.removeHooks=function(N){H[N]=[]},t.removeAllHooks=function(){H=Gr()},t}var Lo=Ed();function $a(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Rt=$a();function Td(e){Rt=e}var In={exec:()=>null};function j(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(s,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(ge.caret,"$1"),n=n.replace(s,a),i},getRegex:()=>new RegExp(n,t)};return i}var Fm=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ge={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,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,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,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")},Um=/^(?:[ \t]*(?:\n|$))+/,Wm=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Km=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Gn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,zm=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Sa=/(?:[*+-]|\d{1,9}[.)])/,_d=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Md=j(_d).replace(/bull/g,Sa).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(),Hm=j(_d).replace(/bull/g,Sa).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(),Aa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,qm=/^[^\n]+/,Ca=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,jm=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ca).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Gm=j(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Sa).getRegex(),ps="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",Ea=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Vm=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",Ea).replace("tag",ps).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Pd=j(Aa).replace("hr",Gn).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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex(),Qm=j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Pd).getRegex(),Ta={blockquote:Qm,code:Wm,def:jm,fences:Km,heading:zm,hr:Gn,html:Vm,lheading:Md,list:Gm,newline:Um,paragraph:Pd,table:In,text:qm},Vr=j("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Gn).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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex(),Jm={...Ta,lheading:Hm,table:Vr,paragraph:j(Aa).replace("hr",Gn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Vr).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex()},Ym={...Ta,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ea).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:In,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(Aa).replace("hr",Gn).replace("heading",` *#{1,6} *[^
2662
- ]`).replace("lheading",Md).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Xm=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Zm=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Id=/^( {2,}|\\)\n(?!\s*$)/,ey=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,hs=/[\p{P}\p{S}]/u,_a=/[\s\p{P}\p{S}]/u,Ld=/[^\s\p{P}\p{S}]/u,ty=j(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,_a).getRegex(),Rd=/(?!~)[\p{P}\p{S}]/u,ny=/(?!~)[\s\p{P}\p{S}]/u,iy=/(?:[^\s\p{P}\p{S}]|~)/u,sy=j(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Fm?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Dd=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,oy=j(Dd,"u").replace(/punct/g,hs).getRegex(),ay=j(Dd,"u").replace(/punct/g,Rd).getRegex(),Bd="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ry=j(Bd,"gu").replace(/notPunctSpace/g,Ld).replace(/punctSpace/g,_a).replace(/punct/g,hs).getRegex(),ly=j(Bd,"gu").replace(/notPunctSpace/g,iy).replace(/punctSpace/g,ny).replace(/punct/g,Rd).getRegex(),cy=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ld).replace(/punctSpace/g,_a).replace(/punct/g,hs).getRegex(),dy=j(/\\(punct)/,"gu").replace(/punct/g,hs).getRegex(),uy=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(),py=j(Ea).replace("(?:-->|$)","-->").getRegex(),hy=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",py).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,fy=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",qi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Nd=j(/^!?\[(label)\]\[(ref)\]/).replace("label",qi).replace("ref",Ca).getRegex(),Od=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ca).getRegex(),gy=j("reflink|nolink(?!\\()","g").replace("reflink",Nd).replace("nolink",Od).getRegex(),Qr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ma={_backpedal:In,anyPunctuation:dy,autolink:uy,blockSkip:sy,br:Id,code:Zm,del:In,emStrongLDelim:oy,emStrongRDelimAst:ry,emStrongRDelimUnd:cy,escape:Xm,link:fy,nolink:Od,punctuation:ty,reflink:Nd,reflinkSearch:gy,tag:hy,text:ey,url:In},my={...Ma,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",qi).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qi).getRegex()},Ro={...Ma,emStrongRDelimAst:ly,emStrongLDelim:ay,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Qr).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",Qr).getRegex()},yy={...Ro,br:j(Id).replace("{2,}","*").getRegex(),text:j(Ro.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},gi={normal:Ta,gfm:Jm,pedantic:Ym},kn={normal:Ma,gfm:Ro,breaks:yy,pedantic:my},vy={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Jr=e=>vy[e];function je(e,t){if(t){if(ge.escapeTest.test(e))return e.replace(ge.escapeReplace,Jr)}else if(ge.escapeTestNoEncode.test(e))return e.replace(ge.escapeReplaceNoEncode,Jr);return e}function Yr(e){try{e=encodeURI(e).replace(ge.percentDecode,"%")}catch{return null}return e}function Xr(e,t){var o;let n=e.replace(ge.findPipe,(a,r,u)=>{let c=!1,h=r;for(;--h>=0&&u[h]==="\\";)c=!c;return c?"|":" |"}),i=n.split(ge.splitPipe),s=0;if(i[0].trim()||i.shift(),i.length>0&&!((o=i.at(-1))!=null&&o.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(ge.slashPipe,"|");return i}function xn(e,t,n){let i=e.length;if(i===0)return"";let s=0;for(;s<i&&e.charAt(i-s-1)===t;)s++;return e.slice(0,i-s)}function by(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}function Zr(e,t,n,i,s){let o=t.href,a=t.title||null,r=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let u={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:r,tokens:i.inlineTokens(r)};return i.state.inLink=!1,u}function wy(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
2658
+ ${i?cm(i,e):w}
2659
+ ${s?dm(s,e):w}
2660
+ `}const xd={CHILD:2},$d=e=>(...t)=>({_$litDirective$:e,values:t});let Sd=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,i){this._$Ct=t,this._$AM=n,this._$Ci=i}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:fm}=mp,Nr=e=>e,Or=()=>document.createComment(""),gn=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const a=i.insertBefore(Or(),s),r=i.insertBefore(Or(),s);n=new fm(a,r,e,e.options)}else{const a=n._$AB.nextSibling,r=n._$AM,u=r!==e;if(u){let c;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==r._$AU&&n._$AP(c)}if(a!==s||u){let c=n._$AA;for(;c!==a;){const h=Nr(c).nextSibling;Nr(i).insertBefore(c,s),c=h}}}return n},ft=(e,t,n=e)=>(e._$AI(t,n),e),gm={},mm=(e,t=gm)=>e._$AH=t,ym=e=>e._$AH,zs=e=>{e._$AR(),e._$AA.remove()};const Fr=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},vm=$d(class extends Sd{constructor(e){if(super(e),e.type!==xd.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let i;n===void 0?n=t:t!==void 0&&(i=t);const s=[],o=[];let a=0;for(const r of e)s[a]=i?i(r,a):a,o[a]=n(r,a),a++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=ym(e),{values:o,keys:a}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=a,o;const r=this.ut??(this.ut=[]),u=[];let c,h,d=0,p=s.length-1,v=0,$=o.length-1;for(;d<=p&&v<=$;)if(s[d]===null)d++;else if(s[p]===null)p--;else if(r[d]===a[v])u[v]=ft(s[d],o[v]),d++,v++;else if(r[p]===a[$])u[$]=ft(s[p],o[$]),p--,$--;else if(r[d]===a[$])u[$]=ft(s[d],o[$]),gn(e,u[$+1],s[d]),d++,$--;else if(r[p]===a[v])u[v]=ft(s[p],o[v]),gn(e,s[d],s[p]),p--,v++;else if(c===void 0&&(c=Fr(a,v,$),h=Fr(r,d,p)),c.has(r[d]))if(c.has(r[p])){const S=h.get(a[v]),M=S!==void 0?s[S]:null;if(M===null){const y=gn(e,s[d]);ft(y,o[v]),u[v]=y}else u[v]=ft(M,o[v]),gn(e,s[d],M),s[S]=null;v++}else zs(s[p]),p--;else zs(s[d]),d++;for(;v<=$;){const S=gn(e,u[$+1]);ft(S,o[v]),u[v++]=S}for(;d<=p;){const S=s[d++];S!==null&&zs(S)}return this.ut=a,mm(e,u),rt}});class _o extends Sd{constructor(t){if(super(t),this.it=w,t.type!==xd.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===w||t==null)return this._t=void 0,this.it=t;if(t===rt)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:[]}}}_o.directiveName="unsafeHTML",_o.resultType=1;const Hi=$d(_o);const{entries:Ad,setPrototypeOf:Ur,isFrozen:bm,getPrototypeOf:wm,getOwnPropertyDescriptor:km}=Object;let{freeze:me,seal:xe,create:Mo}=Object,{apply:Po,construct:Io}=typeof Reflect<"u"&&Reflect;me||(me=function(t){return t});xe||(xe=function(t){return t});Po||(Po=function(t,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),o=2;o<i;o++)s[o-2]=arguments[o];return t.apply(n,s)});Io||(Io=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return new t(...i)});const hi=ye(Array.prototype.forEach),xm=ye(Array.prototype.lastIndexOf),Wr=ye(Array.prototype.pop),mn=ye(Array.prototype.push),$m=ye(Array.prototype.splice),Ci=ye(String.prototype.toLowerCase),Hs=ye(String.prototype.toString),qs=ye(String.prototype.match),yn=ye(String.prototype.replace),Sm=ye(String.prototype.indexOf),Am=ye(String.prototype.trim),$e=ye(Object.prototype.hasOwnProperty),fe=ye(RegExp.prototype.test),vn=Cm(TypeError);function ye(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return Po(e,t,i)}}function Cm(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Io(e,n)}}function K(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ci;Ur&&Ur(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(bm(t)||(t[i]=o),s=o)}e[s]=!0}return e}function Em(e){for(let t=0;t<e.length;t++)$e(e,t)||(e[t]=null);return e}function De(e){const t=Mo(null);for(const[n,i]of Ad(e))$e(e,n)&&(Array.isArray(i)?t[n]=Em(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=De(i):t[n]=i);return t}function bn(e,t){for(;e!==null;){const i=km(e,t);if(i){if(i.get)return ye(i.get);if(typeof i.value=="function")return ye(i.value)}e=wm(e)}function n(){return null}return n}const Kr=me(["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"]),js=me(["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"]),Gs=me(["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"]),Tm=me(["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"]),Vs=me(["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"]),_m=me(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),zr=me(["#text"]),Hr=me(["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"]),Qs=me(["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"]),qr=me(["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"]),fi=me(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Mm=xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Pm=xe(/<%[\w\W]*|[\w\W]*%>/gm),Im=xe(/\$\{[\w\W]*/gm),Lm=xe(/^data-[\-\w.\u00B7-\uFFFF]+$/),Rm=xe(/^aria-[\-\w]+$/),Cd=xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Dm=xe(/^(?:\w+script|data):/i),Bm=xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ed=xe(/^html$/i),Nm=xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var jr=Object.freeze({__proto__:null,ARIA_ATTR:Rm,ATTR_WHITESPACE:Bm,CUSTOM_ELEMENT:Nm,DATA_ATTR:Lm,DOCTYPE_NAME:Ed,ERB_EXPR:Pm,IS_ALLOWED_URI:Cd,IS_SCRIPT_OR_DATA:Dm,MUSTACHE_EXPR:Mm,TMPLIT_EXPR:Im});const wn={element:1,text:3,progressingInstruction:7,comment:8,document:9},Om=function(){return typeof window>"u"?null:window},Fm=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(i=n.getAttribute(s));const o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Gr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Td(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Om();const t=N=>Td(N);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==wn.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:r,Element:u,NodeFilter:c,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:p,trustedTypes:v}=e,$=u.prototype,S=bn($,"cloneNode"),M=bn($,"remove"),y=bn($,"nextSibling"),b=bn($,"childNodes"),k=bn($,"parentNode");if(typeof a=="function"){const N=n.createElement("template");N.content&&N.content.ownerDocument&&(n=N.content.ownerDocument)}let A,E="";const{implementation:T,createNodeIterator:P,createDocumentFragment:D,getElementsByTagName:W}=n,{importNode:z}=i;let H=Gr();t.isSupported=typeof Ad=="function"&&typeof k=="function"&&T&&T.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ke,ERB_EXPR:Me,TMPLIT_EXPR:ze,DATA_ATTR:vs,ARIA_ATTR:bs,IS_SCRIPT_OR_DATA:ws,ATTR_WHITESPACE:Qn,CUSTOM_ELEMENT:ks}=jr;let{IS_ALLOWED_URI:Jn}=jr,te=null;const Yn=K({},[...Kr,...js,...Gs,...Vs,...zr]);let ne=null;const Xn=K({},[...Hr,...Qs,...qr,...fi]);let X=Object.seal(Mo(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}})),dt=null,dn=null;const et=Object.seal(Mo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Zn=!0,C=!0,I=!1,F=!0,U=!1,Z=!0,J=!1,he=!1,tt=!1,Bt=!1,ei=!1,ti=!1,za=!0,Ha=!1;const Fu="user-content-";let xs=!0,un=!1,Nt={},Pe=null;const $s=K({},["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 qa=null;const ja=K({},["audio","video","img","source","image","track"]);let Ss=null;const Ga=K({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ni="http://www.w3.org/1998/Math/MathML",ii="http://www.w3.org/2000/svg",He="http://www.w3.org/1999/xhtml";let Ot=He,As=!1,Cs=null;const Uu=K({},[ni,ii,He],Hs);let si=K({},["mi","mo","mn","ms","mtext"]),oi=K({},["annotation-xml"]);const Wu=K({},["title","style","font","a","script"]);let pn=null;const Ku=["application/xhtml+xml","text/html"],zu="text/html";let oe=null,Ft=null;const Hu=n.createElement("form"),Va=function(x){return x instanceof RegExp||x instanceof Function},Es=function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ft&&Ft===x)){if((!x||typeof x!="object")&&(x={}),x=De(x),pn=Ku.indexOf(x.PARSER_MEDIA_TYPE)===-1?zu:x.PARSER_MEDIA_TYPE,oe=pn==="application/xhtml+xml"?Hs:Ci,te=$e(x,"ALLOWED_TAGS")?K({},x.ALLOWED_TAGS,oe):Yn,ne=$e(x,"ALLOWED_ATTR")?K({},x.ALLOWED_ATTR,oe):Xn,Cs=$e(x,"ALLOWED_NAMESPACES")?K({},x.ALLOWED_NAMESPACES,Hs):Uu,Ss=$e(x,"ADD_URI_SAFE_ATTR")?K(De(Ga),x.ADD_URI_SAFE_ATTR,oe):Ga,qa=$e(x,"ADD_DATA_URI_TAGS")?K(De(ja),x.ADD_DATA_URI_TAGS,oe):ja,Pe=$e(x,"FORBID_CONTENTS")?K({},x.FORBID_CONTENTS,oe):$s,dt=$e(x,"FORBID_TAGS")?K({},x.FORBID_TAGS,oe):De({}),dn=$e(x,"FORBID_ATTR")?K({},x.FORBID_ATTR,oe):De({}),Nt=$e(x,"USE_PROFILES")?x.USE_PROFILES:!1,Zn=x.ALLOW_ARIA_ATTR!==!1,C=x.ALLOW_DATA_ATTR!==!1,I=x.ALLOW_UNKNOWN_PROTOCOLS||!1,F=x.ALLOW_SELF_CLOSE_IN_ATTR!==!1,U=x.SAFE_FOR_TEMPLATES||!1,Z=x.SAFE_FOR_XML!==!1,J=x.WHOLE_DOCUMENT||!1,Bt=x.RETURN_DOM||!1,ei=x.RETURN_DOM_FRAGMENT||!1,ti=x.RETURN_TRUSTED_TYPE||!1,tt=x.FORCE_BODY||!1,za=x.SANITIZE_DOM!==!1,Ha=x.SANITIZE_NAMED_PROPS||!1,xs=x.KEEP_CONTENT!==!1,un=x.IN_PLACE||!1,Jn=x.ALLOWED_URI_REGEXP||Cd,Ot=x.NAMESPACE||He,si=x.MATHML_TEXT_INTEGRATION_POINTS||si,oi=x.HTML_INTEGRATION_POINTS||oi,X=x.CUSTOM_ELEMENT_HANDLING||{},x.CUSTOM_ELEMENT_HANDLING&&Va(x.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(X.tagNameCheck=x.CUSTOM_ELEMENT_HANDLING.tagNameCheck),x.CUSTOM_ELEMENT_HANDLING&&Va(x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(X.attributeNameCheck=x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),x.CUSTOM_ELEMENT_HANDLING&&typeof x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(X.allowCustomizedBuiltInElements=x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),U&&(C=!1),ei&&(Bt=!0),Nt&&(te=K({},zr),ne=[],Nt.html===!0&&(K(te,Kr),K(ne,Hr)),Nt.svg===!0&&(K(te,js),K(ne,Qs),K(ne,fi)),Nt.svgFilters===!0&&(K(te,Gs),K(ne,Qs),K(ne,fi)),Nt.mathMl===!0&&(K(te,Vs),K(ne,qr),K(ne,fi))),x.ADD_TAGS&&(typeof x.ADD_TAGS=="function"?et.tagCheck=x.ADD_TAGS:(te===Yn&&(te=De(te)),K(te,x.ADD_TAGS,oe))),x.ADD_ATTR&&(typeof x.ADD_ATTR=="function"?et.attributeCheck=x.ADD_ATTR:(ne===Xn&&(ne=De(ne)),K(ne,x.ADD_ATTR,oe))),x.ADD_URI_SAFE_ATTR&&K(Ss,x.ADD_URI_SAFE_ATTR,oe),x.FORBID_CONTENTS&&(Pe===$s&&(Pe=De(Pe)),K(Pe,x.FORBID_CONTENTS,oe)),x.ADD_FORBID_CONTENTS&&(Pe===$s&&(Pe=De(Pe)),K(Pe,x.ADD_FORBID_CONTENTS,oe)),xs&&(te["#text"]=!0),J&&K(te,["html","head","body"]),te.table&&(K(te,["tbody"]),delete dt.tbody),x.TRUSTED_TYPES_POLICY){if(typeof x.TRUSTED_TYPES_POLICY.createHTML!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof x.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=x.TRUSTED_TYPES_POLICY,E=A.createHTML("")}else A===void 0&&(A=Fm(v,s)),A!==null&&typeof E=="string"&&(E=A.createHTML(""));me&&me(x),Ft=x}},Qa=K({},[...js,...Gs,...Tm]),Ja=K({},[...Vs,..._m]),qu=function(x){let _=k(x);(!_||!_.tagName)&&(_={namespaceURI:Ot,tagName:"template"});const B=Ci(x.tagName),Y=Ci(_.tagName);return Cs[x.namespaceURI]?x.namespaceURI===ii?_.namespaceURI===He?B==="svg":_.namespaceURI===ni?B==="svg"&&(Y==="annotation-xml"||si[Y]):!!Qa[B]:x.namespaceURI===ni?_.namespaceURI===He?B==="math":_.namespaceURI===ii?B==="math"&&oi[Y]:!!Ja[B]:x.namespaceURI===He?_.namespaceURI===ii&&!oi[Y]||_.namespaceURI===ni&&!si[Y]?!1:!Ja[B]&&(Wu[B]||!Qa[B]):!!(pn==="application/xhtml+xml"&&Cs[x.namespaceURI]):!1},Ie=function(x){mn(t.removed,{element:x});try{k(x).removeChild(x)}catch{M(x)}},ut=function(x,_){try{mn(t.removed,{attribute:_.getAttributeNode(x),from:_})}catch{mn(t.removed,{attribute:null,from:_})}if(_.removeAttribute(x),x==="is")if(Bt||ei)try{Ie(_)}catch{}else try{_.setAttribute(x,"")}catch{}},Ya=function(x){let _=null,B=null;if(tt)x="<remove></remove>"+x;else{const se=qs(x,/^[\r\n\t ]+/);B=se&&se[0]}pn==="application/xhtml+xml"&&Ot===He&&(x='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+x+"</body></html>");const Y=A?A.createHTML(x):x;if(Ot===He)try{_=new p().parseFromString(Y,pn)}catch{}if(!_||!_.documentElement){_=T.createDocument(Ot,"template",null);try{_.documentElement.innerHTML=As?E:Y}catch{}}const de=_.body||_.documentElement;return x&&B&&de.insertBefore(n.createTextNode(B),de.childNodes[0]||null),Ot===He?W.call(_,J?"html":"body")[0]:J?_.documentElement:de},Xa=function(x){return P.call(x.ownerDocument||x,x,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ts=function(x){return x instanceof d&&(typeof x.nodeName!="string"||typeof x.textContent!="string"||typeof x.removeChild!="function"||!(x.attributes instanceof h)||typeof x.removeAttribute!="function"||typeof x.setAttribute!="function"||typeof x.namespaceURI!="string"||typeof x.insertBefore!="function"||typeof x.hasChildNodes!="function")},Za=function(x){return typeof r=="function"&&x instanceof r};function qe(N,x,_){hi(N,B=>{B.call(t,x,_,Ft)})}const er=function(x){let _=null;if(qe(H.beforeSanitizeElements,x,null),Ts(x))return Ie(x),!0;const B=oe(x.nodeName);if(qe(H.uponSanitizeElement,x,{tagName:B,allowedTags:te}),Z&&x.hasChildNodes()&&!Za(x.firstElementChild)&&fe(/<[/\w!]/g,x.innerHTML)&&fe(/<[/\w!]/g,x.textContent)||x.nodeType===wn.progressingInstruction||Z&&x.nodeType===wn.comment&&fe(/<[/\w]/g,x.data))return Ie(x),!0;if(!(et.tagCheck instanceof Function&&et.tagCheck(B))&&(!te[B]||dt[B])){if(!dt[B]&&nr(B)&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B)))return!1;if(xs&&!Pe[B]){const Y=k(x)||x.parentNode,de=b(x)||x.childNodes;if(de&&Y){const se=de.length;for(let ve=se-1;ve>=0;--ve){const je=S(de[ve],!0);je.__removalCount=(x.__removalCount||0)+1,Y.insertBefore(je,y(x))}}}return Ie(x),!0}return x instanceof u&&!qu(x)||(B==="noscript"||B==="noembed"||B==="noframes")&&fe(/<\/no(script|embed|frames)/i,x.innerHTML)?(Ie(x),!0):(U&&x.nodeType===wn.text&&(_=x.textContent,hi([ke,Me,ze],Y=>{_=yn(_,Y," ")}),x.textContent!==_&&(mn(t.removed,{element:x.cloneNode()}),x.textContent=_)),qe(H.afterSanitizeElements,x,null),!1)},tr=function(x,_,B){if(za&&(_==="id"||_==="name")&&(B in n||B in Hu))return!1;if(!(C&&!dn[_]&&fe(vs,_))){if(!(Zn&&fe(bs,_))){if(!(et.attributeCheck instanceof Function&&et.attributeCheck(_,x))){if(!ne[_]||dn[_]){if(!(nr(x)&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,x)||X.tagNameCheck instanceof Function&&X.tagNameCheck(x))&&(X.attributeNameCheck instanceof RegExp&&fe(X.attributeNameCheck,_)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(_,x))||_==="is"&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&fe(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B))))return!1}else if(!Ss[_]){if(!fe(Jn,yn(B,Qn,""))){if(!((_==="src"||_==="xlink:href"||_==="href")&&x!=="script"&&Sm(B,"data:")===0&&qa[x])){if(!(I&&!fe(ws,yn(B,Qn,"")))){if(B)return!1}}}}}}}return!0},nr=function(x){return x!=="annotation-xml"&&qs(x,ks)},ir=function(x){qe(H.beforeSanitizeAttributes,x,null);const{attributes:_}=x;if(!_||Ts(x))return;const B={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let Y=_.length;for(;Y--;){const de=_[Y],{name:se,namespaceURI:ve,value:je}=de,Ut=oe(se),_s=je;let le=se==="value"?_s:Am(_s);if(B.attrName=Ut,B.attrValue=le,B.keepAttr=!0,B.forceKeepAttr=void 0,qe(H.uponSanitizeAttribute,x,B),le=B.attrValue,Ha&&(Ut==="id"||Ut==="name")&&(ut(se,x),le=Fu+le),Z&&fe(/((--!?|])>)|<\/(style|title|textarea)/i,le)){ut(se,x);continue}if(Ut==="attributename"&&qs(le,"href")){ut(se,x);continue}if(B.forceKeepAttr)continue;if(!B.keepAttr){ut(se,x);continue}if(!F&&fe(/\/>/i,le)){ut(se,x);continue}U&&hi([ke,Me,ze],or=>{le=yn(le,or," ")});const sr=oe(x.nodeName);if(!tr(sr,Ut,le)){ut(se,x);continue}if(A&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!ve)switch(v.getAttributeType(sr,Ut)){case"TrustedHTML":{le=A.createHTML(le);break}case"TrustedScriptURL":{le=A.createScriptURL(le);break}}if(le!==_s)try{ve?x.setAttributeNS(ve,se,le):x.setAttribute(se,le),Ts(x)?Ie(x):Wr(t.removed)}catch{ut(se,x)}}qe(H.afterSanitizeAttributes,x,null)},ju=function N(x){let _=null;const B=Xa(x);for(qe(H.beforeSanitizeShadowDOM,x,null);_=B.nextNode();)qe(H.uponSanitizeShadowNode,_,null),er(_),ir(_),_.content instanceof o&&N(_.content);qe(H.afterSanitizeShadowDOM,x,null)};return t.sanitize=function(N){let x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=null,B=null,Y=null,de=null;if(As=!N,As&&(N="<!-->"),typeof N!="string"&&!Za(N))if(typeof N.toString=="function"){if(N=N.toString(),typeof N!="string")throw vn("dirty is not a string, aborting")}else throw vn("toString is not a function");if(!t.isSupported)return N;if(he||Es(x),t.removed=[],typeof N=="string"&&(un=!1),un){if(N.nodeName){const je=oe(N.nodeName);if(!te[je]||dt[je])throw vn("root node is forbidden and cannot be sanitized in-place")}}else if(N instanceof r)_=Ya("<!---->"),B=_.ownerDocument.importNode(N,!0),B.nodeType===wn.element&&B.nodeName==="BODY"||B.nodeName==="HTML"?_=B:_.appendChild(B);else{if(!Bt&&!U&&!J&&N.indexOf("<")===-1)return A&&ti?A.createHTML(N):N;if(_=Ya(N),!_)return Bt?null:ti?E:""}_&&tt&&Ie(_.firstChild);const se=Xa(un?N:_);for(;Y=se.nextNode();)er(Y),ir(Y),Y.content instanceof o&&ju(Y.content);if(un)return N;if(Bt){if(ei)for(de=D.call(_.ownerDocument);_.firstChild;)de.appendChild(_.firstChild);else de=_;return(ne.shadowroot||ne.shadowrootmode)&&(de=z.call(i,de,!0)),de}let ve=J?_.outerHTML:_.innerHTML;return J&&te["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&fe(Ed,_.ownerDocument.doctype.name)&&(ve="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
2661
+ `+ve),U&&hi([ke,Me,ze],je=>{ve=yn(ve,je," ")}),A&&ti?A.createHTML(ve):ve},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Es(N),he=!0},t.clearConfig=function(){Ft=null,he=!1},t.isValidAttribute=function(N,x,_){Ft||Es({});const B=oe(N),Y=oe(x);return tr(B,Y,_)},t.addHook=function(N,x){typeof x=="function"&&mn(H[N],x)},t.removeHook=function(N,x){if(x!==void 0){const _=xm(H[N],x);return _===-1?void 0:$m(H[N],_,1)[0]}return Wr(H[N])},t.removeHooks=function(N){H[N]=[]},t.removeAllHooks=function(){H=Gr()},t}var Lo=Td();function $a(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Rt=$a();function _d(e){Rt=e}var In={exec:()=>null};function j(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(s,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(ge.caret,"$1"),n=n.replace(s,a),i},getRegex:()=>new RegExp(n,t)};return i}var Um=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ge={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,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,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,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")},Wm=/^(?:[ \t]*(?:\n|$))+/,Km=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,zm=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Gn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Hm=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Sa=/(?:[*+-]|\d{1,9}[.)])/,Md=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Pd=j(Md).replace(/bull/g,Sa).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(),qm=j(Md).replace(/bull/g,Sa).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(),Aa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,jm=/^[^\n]+/,Ca=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Gm=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ca).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Vm=j(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Sa).getRegex(),ps="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",Ea=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Qm=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",Ea).replace("tag",ps).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Id=j(Aa).replace("hr",Gn).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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex(),Jm=j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Id).getRegex(),Ta={blockquote:Jm,code:Km,def:Gm,fences:zm,heading:Hm,hr:Gn,html:Qm,lheading:Pd,list:Vm,newline:Wm,paragraph:Id,table:In,text:jm},Vr=j("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Gn).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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex(),Ym={...Ta,lheading:qm,table:Vr,paragraph:j(Aa).replace("hr",Gn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Vr).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex()},Xm={...Ta,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ea).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:In,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(Aa).replace("hr",Gn).replace("heading",` *#{1,6} *[^
2662
+ ]`).replace("lheading",Pd).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Zm=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ey=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ld=/^( {2,}|\\)\n(?!\s*$)/,ty=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,hs=/[\p{P}\p{S}]/u,_a=/[\s\p{P}\p{S}]/u,Rd=/[^\s\p{P}\p{S}]/u,ny=j(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,_a).getRegex(),Dd=/(?!~)[\p{P}\p{S}]/u,iy=/(?!~)[\s\p{P}\p{S}]/u,sy=/(?:[^\s\p{P}\p{S}]|~)/u,oy=j(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Um?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Bd=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ay=j(Bd,"u").replace(/punct/g,hs).getRegex(),ry=j(Bd,"u").replace(/punct/g,Dd).getRegex(),Nd="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ly=j(Nd,"gu").replace(/notPunctSpace/g,Rd).replace(/punctSpace/g,_a).replace(/punct/g,hs).getRegex(),cy=j(Nd,"gu").replace(/notPunctSpace/g,sy).replace(/punctSpace/g,iy).replace(/punct/g,Dd).getRegex(),dy=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Rd).replace(/punctSpace/g,_a).replace(/punct/g,hs).getRegex(),uy=j(/\\(punct)/,"gu").replace(/punct/g,hs).getRegex(),py=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(),hy=j(Ea).replace("(?:-->|$)","-->").getRegex(),fy=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",hy).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,gy=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",qi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Od=j(/^!?\[(label)\]\[(ref)\]/).replace("label",qi).replace("ref",Ca).getRegex(),Fd=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ca).getRegex(),my=j("reflink|nolink(?!\\()","g").replace("reflink",Od).replace("nolink",Fd).getRegex(),Qr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ma={_backpedal:In,anyPunctuation:uy,autolink:py,blockSkip:oy,br:Ld,code:ey,del:In,emStrongLDelim:ay,emStrongRDelimAst:ly,emStrongRDelimUnd:dy,escape:Zm,link:gy,nolink:Fd,punctuation:ny,reflink:Od,reflinkSearch:my,tag:fy,text:ty,url:In},yy={...Ma,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",qi).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qi).getRegex()},Ro={...Ma,emStrongRDelimAst:cy,emStrongLDelim:ry,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Qr).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",Qr).getRegex()},vy={...Ro,br:j(Ld).replace("{2,}","*").getRegex(),text:j(Ro.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},gi={normal:Ta,gfm:Ym,pedantic:Xm},kn={normal:Ma,gfm:Ro,breaks:vy,pedantic:yy},by={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Jr=e=>by[e];function Qe(e,t){if(t){if(ge.escapeTest.test(e))return e.replace(ge.escapeReplace,Jr)}else if(ge.escapeTestNoEncode.test(e))return e.replace(ge.escapeReplaceNoEncode,Jr);return e}function Yr(e){try{e=encodeURI(e).replace(ge.percentDecode,"%")}catch{return null}return e}function Xr(e,t){var o;let n=e.replace(ge.findPipe,(a,r,u)=>{let c=!1,h=r;for(;--h>=0&&u[h]==="\\";)c=!c;return c?"|":" |"}),i=n.split(ge.splitPipe),s=0;if(i[0].trim()||i.shift(),i.length>0&&!((o=i.at(-1))!=null&&o.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(ge.slashPipe,"|");return i}function xn(e,t,n){let i=e.length;if(i===0)return"";let s=0;for(;s<i&&e.charAt(i-s-1)===t;)s++;return e.slice(0,i-s)}function wy(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}function Zr(e,t,n,i,s){let o=t.href,a=t.title||null,r=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let u={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:r,tokens:i.inlineTokens(r)};return i.state.inLink=!1,u}function ky(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
2663
2663
  `).map(o=>{let a=o.match(n.other.beginningSpace);if(a===null)return o;let[r]=a;return r.length>=s.length?o.slice(s.length):o}).join(`
2664
2664
  `)}var ji=class{constructor(e){q(this,"options");q(this,"rules");q(this,"lexer");this.options=e||Rt}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:xn(n,`
2665
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=wy(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:i}}}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 i=xn(n,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(n=i.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:xn(t[0],`
2665
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=ky(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:i}}}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 i=xn(n,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(n=i.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:xn(t[0],`
2666
2666
  `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=xn(t[0],`
2667
2667
  `).split(`
2668
2668
  `),i="",s="",o=[];for(;n.length>0;){let a=!1,r=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))r.push(n[u]),a=!0;else if(!a)r.push(n[u]);else break;n=n.slice(u);let c=r.join(`
@@ -2683,7 +2683,7 @@ ${h}`:h;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
2683
2683
  `+$}!S&&!$.trim()&&(S=!0),d+=T+`
2684
2684
  `,e=e.substring(T.length+1),v=P.slice(M)}}a.loose||(u?a.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(u=!0)),a.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),a.raw+=d}let c=a.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;a.raw=a.raw.trimEnd();for(let h of a.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"||((i=h.tokens[0])==null?void 0:i.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 p=this.lexer.inlineQueue.length-1;p>=0;p--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)){this.lexer.inlineQueue[p].src=this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask,"");break}}let d=this.rules.other.listTaskCheckbox.exec(h.raw);if(d){let p={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};h.checked=p.checked,a.loose?h.tokens[0]&&["paragraph","text"].includes(h.tokens[0].type)&&"tokens"in h.tokens[0]&&h.tokens[0].tokens?(h.tokens[0].raw=p.raw+h.tokens[0].raw,h.tokens[0].text=p.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(p)):h.tokens.unshift({type:"paragraph",raw:p.raw,text:p.raw,tokens:[p]}):h.tokens.unshift(p)}}if(!a.loose){let d=h.tokens.filter(v=>v.type==="space"),p=d.length>0&&d.some(v=>this.rules.other.anyLine.test(v.raw));a.loose=p}}if(a.loose)for(let h of a.items){h.loose=!0;for(let d of h.tokens)d.type==="text"&&(d.type="paragraph")}return a}}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," "),i=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=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:i,title:s}}}table(e){var a;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Xr(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(a=t[3])!=null&&a.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
2685
2685
  `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let r of i)this.rules.other.tableAlignRight.test(r)?o.align.push("right"):this.rules.other.tableAlignCenter.test(r)?o.align.push("center"):this.rules.other.tableAlignLeft.test(r)?o.align.push("left"):o.align.push(null);for(let r=0;r<n.length;r++)o.header.push({text:n[r],tokens:this.lexer.inline(n[r]),header:!0,align:o.align[r]});for(let r of s)o.rows.push(Xr(r,o.header.length).map((u,c)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:o.align[c]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
2686
- `?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 o=xn(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=by(t[2],"()");if(o===-2)return;if(o>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(i);o&&(i=o[1],s=o[3])}else s=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?i=i.slice(1):i=i.slice(1,-1)),Zr(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.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 i=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=t[i.toLowerCase()];if(!s){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return Zr(n,s,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!n||this.rules.inline.punctuation.exec(n))){let s=[...i[0]].length-1,o,a,r=s,u=0,c=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+s);(i=c.exec(t))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(a=[...o].length,i[3]||i[4]){r+=a;continue}else if((i[5]||i[6])&&s%3&&!((s+a)%3)){u+=a;continue}if(r-=a,r>0)continue;a=Math.min(a,a+r+u);let h=[...i[0]][0].length,d=e.slice(0,s+i.index+h+a);if(Math.min(s,a)%2){let v=d.slice(1,-1);return{type:"em",raw:d,text:v,tokens:this.lexer.inlineTokens(v)}}let p=d.slice(2,-2);return{type:"strong",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return i&&s&&(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){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,i;return t[2]==="@"?(n=t[1],i="mailto:"+n):(n=t[1],i=n),{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let i,s;if(t[2]==="@")i=t[0],s="mailto:"+i;else{let o;do o=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(o!==t[0]);i=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}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}}}},Ae=class Do{constructor(t){q(this,"tokens");q(this,"options");q(this,"state");q(this,"inlineQueue");q(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Rt,this.options.tokenizer=this.options.tokenizer||new ji,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:ge,block:gi.normal,inline:kn.normal};this.options.pedantic?(n.block=gi.pedantic,n.inline=kn.pedantic):this.options.gfm&&(n.block=gi.gfm,this.options.breaks?n.inline=kn.breaks:n.inline=kn.gfm),this.tokenizer.rules=n}static get rules(){return{block:gi,inline:kn}}static lex(t,n){return new Do(n).lex(t)}static lexInline(t,n){return new Do(n).inlineTokens(t)}lex(t){t=t.replace(ge.carriageReturn,`
2686
+ `?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 o=xn(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=wy(t[2],"()");if(o===-2)return;if(o>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(i);o&&(i=o[1],s=o[3])}else s=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?i=i.slice(1):i=i.slice(1,-1)),Zr(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.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 i=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=t[i.toLowerCase()];if(!s){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return Zr(n,s,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!n||this.rules.inline.punctuation.exec(n))){let s=[...i[0]].length-1,o,a,r=s,u=0,c=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+s);(i=c.exec(t))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(a=[...o].length,i[3]||i[4]){r+=a;continue}else if((i[5]||i[6])&&s%3&&!((s+a)%3)){u+=a;continue}if(r-=a,r>0)continue;a=Math.min(a,a+r+u);let h=[...i[0]][0].length,d=e.slice(0,s+i.index+h+a);if(Math.min(s,a)%2){let v=d.slice(1,-1);return{type:"em",raw:d,text:v,tokens:this.lexer.inlineTokens(v)}}let p=d.slice(2,-2);return{type:"strong",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return i&&s&&(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){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,i;return t[2]==="@"?(n=t[1],i="mailto:"+n):(n=t[1],i=n),{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let i,s;if(t[2]==="@")i=t[0],s="mailto:"+i;else{let o;do o=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(o!==t[0]);i=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}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}}}},Ae=class Do{constructor(t){q(this,"tokens");q(this,"options");q(this,"state");q(this,"inlineQueue");q(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Rt,this.options.tokenizer=this.options.tokenizer||new ji,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:ge,block:gi.normal,inline:kn.normal};this.options.pedantic?(n.block=gi.pedantic,n.inline=kn.pedantic):this.options.gfm&&(n.block=gi.gfm,this.options.breaks?n.inline=kn.breaks:n.inline=kn.gfm),this.tokenizer.rules=n}static get rules(){return{block:gi,inline:kn}}static lex(t,n){return new Do(n).lex(t)}static lexInline(t,n){return new Do(n).inlineTokens(t)}lex(t){t=t.replace(ge.carriageReturn,`
2687
2687
  `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let i=this.inlineQueue[n];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],i=!1){var s,o,a;for(this.options.pedantic&&(t=t.replace(ge.tabCharGlobal," ").replace(ge.spaceLine,""));t;){let r;if((o=(s=this.options.extensions)==null?void 0:s.block)!=null&&o.some(c=>(r=c.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))continue;if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length);let c=n.at(-1);r.raw.length===1&&c!==void 0?c.raw+=`
2688
2688
  `:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
2689
2689
  `)?"":`
@@ -2698,8 +2698,8 @@ ${h}`:h;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
2698
2698
  `)?"":`
2699
2699
  `)+r.raw,c.text+=`
2700
2700
  `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(r);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var u,c,h,d,p;let i=t,s=null;if(this.tokens.links){let v=Object.keys(this.tokens.links);if(v.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)v.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,s.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)o=s[2]?s[2].length:0,i=i.slice(0,s.index+o)+"["+"a".repeat(s[0].length-o-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=((c=(u=this.options.hooks)==null?void 0:u.emStrongMask)==null?void 0:c.call({lexer:this},i))??i;let a=!1,r="";for(;t;){a||(r=""),a=!1;let v;if((d=(h=this.options.extensions)==null?void 0:h.inline)!=null&&d.some(S=>(v=S.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 S=n.at(-1);v.type==="text"&&(S==null?void 0:S.type)==="text"?(S.raw+=v.raw,S.text+=v.text):n.push(v);continue}if(v=this.tokenizer.emStrong(t,i,r)){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)){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 $=t;if((p=this.options.extensions)!=null&&p.startInline){let S=1/0,M=t.slice(1),y;this.options.extensions.startInline.forEach(b=>{y=b.call({lexer:this},M),typeof y=="number"&&y>=0&&(S=Math.min(S,y))}),S<1/0&&S>=0&&($=t.substring(0,S+1))}if(v=this.tokenizer.inlineText($)){t=t.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(r=v.raw.slice(-1)),a=!0;let S=n.at(-1);(S==null?void 0:S.type)==="text"?(S.raw+=v.raw,S.text+=v.text):n.push(v);continue}if(t){let S="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(S);break}else throw new Error(S)}}return n}},Gi=class{constructor(e){q(this,"options");q(this,"parser");this.options=e||Rt}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let i=(o=(t||"").match(ge.notSpaceStart))==null?void 0:o[0],s=e.replace(ge.endingNewline,"")+`
2701
- `;return i?'<pre><code class="language-'+je(i)+'">'+(n?s:je(s,!0))+`</code></pre>
2702
- `:"<pre><code>"+(n?s:je(s,!0))+`</code></pre>
2701
+ `;return i?'<pre><code class="language-'+Qe(i)+'">'+(n?s:Qe(s,!0))+`</code></pre>
2702
+ `:"<pre><code>"+(n?s:Qe(s,!0))+`</code></pre>
2703
2703
  `}blockquote({tokens:e}){return`<blockquote>
2704
2704
  ${this.parser.parse(e)}</blockquote>
2705
2705
  `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
@@ -2715,26 +2715,26 @@ ${this.parser.parse(e)}</blockquote>
2715
2715
  `}tablerow({text:e}){return`<tr>
2716
2716
  ${e}</tr>
2717
2717
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
2718
- `}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>${je(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 i=this.parser.parseInline(n),s=Yr(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+je(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=Yr(e);if(s===null)return je(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${je(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:je(e.text)}},Pa=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}},Ce=class Bo{constructor(t){q(this,"options");q(this,"renderer");q(this,"textRenderer");this.options=t||Rt,this.options.renderer=this.options.renderer||new Gi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Pa}static parse(t,n){return new Bo(n).parse(t)}static parseInline(t,n){return new Bo(n).parseInline(t)}parse(t){var i,s;let n="";for(let o=0;o<t.length;o++){let a=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=a,c=this.options.extensions.renderers[u.type].call({parser:this},u);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(u.type)){n+=c||"";continue}}let r=a;switch(r.type){case"space":{n+=this.renderer.space(r);break}case"hr":{n+=this.renderer.hr(r);break}case"heading":{n+=this.renderer.heading(r);break}case"code":{n+=this.renderer.code(r);break}case"table":{n+=this.renderer.table(r);break}case"blockquote":{n+=this.renderer.blockquote(r);break}case"list":{n+=this.renderer.list(r);break}case"checkbox":{n+=this.renderer.checkbox(r);break}case"html":{n+=this.renderer.html(r);break}case"def":{n+=this.renderer.def(r);break}case"paragraph":{n+=this.renderer.paragraph(r);break}case"text":{n+=this.renderer.text(r);break}default:{let u='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}parseInline(t,n=this.renderer){var s,o;let i="";for(let a=0;a<t.length;a++){let r=t[a];if((o=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&o[r.type]){let c=this.options.extensions.renderers[r.type].call({parser:this},r);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){i+=c||"";continue}}let u=r;switch(u.type){case"escape":{i+=n.text(u);break}case"html":{i+=n.html(u);break}case"link":{i+=n.link(u);break}case"image":{i+=n.image(u);break}case"checkbox":{i+=n.checkbox(u);break}case"strong":{i+=n.strong(u);break}case"em":{i+=n.em(u);break}case"codespan":{i+=n.codespan(u);break}case"br":{i+=n.br(u);break}case"del":{i+=n.del(u);break}case"text":{i+=n.text(u);break}default:{let c='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},$i,An=($i=class{constructor(e){q(this,"options");q(this,"block");this.options=e||Rt}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Ae.lex:Ae.lexInline}provideParser(){return this.block?Ce.parse:Ce.parseInline}},q($i,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),q($i,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),$i),ky=class{constructor(...e){q(this,"defaults",$a());q(this,"options",this.setOptions);q(this,"parse",this.parseMarkdown(!0));q(this,"parseInline",this.parseMarkdown(!1));q(this,"Parser",Ce);q(this,"Renderer",Gi);q(this,"TextRenderer",Pa);q(this,"Lexer",Ae);q(this,"Tokenizer",ji);q(this,"Hooks",An);this.use(...e)}walkTokens(e,t){var i,s;let n=[];for(let o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{let a=o;for(let r of a.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of a.rows)for(let u of r)n=n.concat(this.walkTokens(u.tokens,t));break}case"list":{let a=o;n=n.concat(this.walkTokens(a.items,t));break}default:{let a=o;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[a.type]?this.defaults.extensions.childTokens[a.type].forEach(r=>{let u=a[r].flat(1/0);n=n.concat(this.walkTokens(u,t))}):a.tokens&&(n=n.concat(this.walkTokens(a.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let o=t.renderers[s.name];o?t.renderers[s.name]=function(...a){let r=s.renderer.apply(this,a);return r===!1&&(r=o.apply(this,a)),r}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[s.level];o?o.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),i.extensions=t),n.renderer){let s=this.defaults.renderer||new Gi(this.defaults);for(let o in n.renderer){if(!(o in s))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,r=n.renderer[a],u=s[a];s[a]=(...c)=>{let h=r.apply(s,c);return h===!1&&(h=u.apply(s,c)),h||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new ji(this.defaults);for(let o in n.tokenizer){if(!(o in s))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,r=n.tokenizer[a],u=s[a];s[a]=(...c)=>{let h=r.apply(s,c);return h===!1&&(h=u.apply(s,c)),h}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new An;for(let o in n.hooks){if(!(o in s))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,r=n.hooks[a],u=s[a];An.passThroughHooks.has(o)?s[a]=c=>{if(this.defaults.async&&An.passThroughHooksRespectAsync.has(o))return(async()=>{let d=await r.call(s,c);return u.call(s,d)})();let h=r.call(s,c);return u.call(s,h)}:s[a]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await r.apply(s,c);return d===!1&&(d=await u.apply(s,c)),d})();let h=r.apply(s,c);return h===!1&&(h=u.apply(s,c)),h}}i.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,o=n.walkTokens;i.walkTokens=function(a){let r=[];return r.push(o.call(this,a)),s&&(r=r.concat(s.call(this,a))),r}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ae.lex(e,t??this.defaults)}parser(e,t){return Ce.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return o(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 o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let a=s.hooks?await s.hooks.preprocess(t):t,r=await(s.hooks?await s.hooks.provideLexer():e?Ae.lex:Ae.lexInline)(a,s),u=s.hooks?await s.hooks.processAllTokens(r):r;s.walkTokens&&await Promise.all(this.walkTokens(u,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():e?Ce.parse:Ce.parseInline)(u,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let a=(s.hooks?s.hooks.provideLexer():e?Ae.lex:Ae.lexInline)(t,s);s.hooks&&(a=s.hooks.processAllTokens(a)),s.walkTokens&&this.walkTokens(a,s.walkTokens);let r=(s.hooks?s.hooks.provideParser():e?Ce.parse:Ce.parseInline)(a,s);return s.hooks&&(r=s.hooks.postprocess(r)),r}catch(a){return o(a)}}}onError(e,t){return n=>{if(n.message+=`
2719
- Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+je(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},_t=new ky;function V(e,t){return _t.parse(e,t)}V.options=V.setOptions=function(e){return _t.setOptions(e),V.defaults=_t.defaults,Td(V.defaults),V};V.getDefaults=$a;V.defaults=Rt;V.use=function(...e){return _t.use(...e),V.defaults=_t.defaults,Td(V.defaults),V};V.walkTokens=function(e,t){return _t.walkTokens(e,t)};V.parseInline=_t.parseInline;V.Parser=Ce;V.parser=Ce.parse;V.Renderer=Gi;V.TextRenderer=Pa;V.Lexer=Ae;V.lexer=Ae.lex;V.Tokenizer=ji;V.Hooks=An;V.parse=V;V.options;V.setOptions;V.use;V.walkTokens;V.parseInline;Ce.parse;Ae.lex;V.setOptions({gfm:!0,breaks:!0,mangle:!1});const el=["a","b","blockquote","br","code","del","em","h1","h2","h3","h4","hr","i","li","ol","p","pre","strong","table","tbody","td","th","thead","tr","ul"],tl=["class","href","rel","target","title","start"];let nl=!1;const xy=14e4,$y=4e4,Sy=200,Js=5e4,bt=new Map;function Ay(e){const t=bt.get(e);return t===void 0?null:(bt.delete(e),bt.set(e,t),t)}function il(e,t){if(bt.set(e,t),bt.size<=Sy)return;const n=bt.keys().next().value;n&&bt.delete(n)}function Cy(){nl||(nl=!0,Lo.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Vi(e){const t=e.trim();if(!t)return"";if(Cy(),t.length<=Js){const a=Ay(t);if(a!==null)return a}const n=Xl(t,xy),i=n.truncated?`
2718
+ `}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>${Qe(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 i=this.parser.parseInline(n),s=Yr(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+Qe(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=Yr(e);if(s===null)return Qe(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Qe(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Qe(e.text)}},Pa=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}},Ce=class Bo{constructor(t){q(this,"options");q(this,"renderer");q(this,"textRenderer");this.options=t||Rt,this.options.renderer=this.options.renderer||new Gi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Pa}static parse(t,n){return new Bo(n).parse(t)}static parseInline(t,n){return new Bo(n).parseInline(t)}parse(t){var i,s;let n="";for(let o=0;o<t.length;o++){let a=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let u=a,c=this.options.extensions.renderers[u.type].call({parser:this},u);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(u.type)){n+=c||"";continue}}let r=a;switch(r.type){case"space":{n+=this.renderer.space(r);break}case"hr":{n+=this.renderer.hr(r);break}case"heading":{n+=this.renderer.heading(r);break}case"code":{n+=this.renderer.code(r);break}case"table":{n+=this.renderer.table(r);break}case"blockquote":{n+=this.renderer.blockquote(r);break}case"list":{n+=this.renderer.list(r);break}case"checkbox":{n+=this.renderer.checkbox(r);break}case"html":{n+=this.renderer.html(r);break}case"def":{n+=this.renderer.def(r);break}case"paragraph":{n+=this.renderer.paragraph(r);break}case"text":{n+=this.renderer.text(r);break}default:{let u='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}parseInline(t,n=this.renderer){var s,o;let i="";for(let a=0;a<t.length;a++){let r=t[a];if((o=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&o[r.type]){let c=this.options.extensions.renderers[r.type].call({parser:this},r);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){i+=c||"";continue}}let u=r;switch(u.type){case"escape":{i+=n.text(u);break}case"html":{i+=n.html(u);break}case"link":{i+=n.link(u);break}case"image":{i+=n.image(u);break}case"checkbox":{i+=n.checkbox(u);break}case"strong":{i+=n.strong(u);break}case"em":{i+=n.em(u);break}case"codespan":{i+=n.codespan(u);break}case"br":{i+=n.br(u);break}case"del":{i+=n.del(u);break}case"text":{i+=n.text(u);break}default:{let c='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},$i,An=($i=class{constructor(e){q(this,"options");q(this,"block");this.options=e||Rt}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Ae.lex:Ae.lexInline}provideParser(){return this.block?Ce.parse:Ce.parseInline}},q($i,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),q($i,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),$i),xy=class{constructor(...e){q(this,"defaults",$a());q(this,"options",this.setOptions);q(this,"parse",this.parseMarkdown(!0));q(this,"parseInline",this.parseMarkdown(!1));q(this,"Parser",Ce);q(this,"Renderer",Gi);q(this,"TextRenderer",Pa);q(this,"Lexer",Ae);q(this,"Tokenizer",ji);q(this,"Hooks",An);this.use(...e)}walkTokens(e,t){var i,s;let n=[];for(let o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{let a=o;for(let r of a.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of a.rows)for(let u of r)n=n.concat(this.walkTokens(u.tokens,t));break}case"list":{let a=o;n=n.concat(this.walkTokens(a.items,t));break}default:{let a=o;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[a.type]?this.defaults.extensions.childTokens[a.type].forEach(r=>{let u=a[r].flat(1/0);n=n.concat(this.walkTokens(u,t))}):a.tokens&&(n=n.concat(this.walkTokens(a.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let o=t.renderers[s.name];o?t.renderers[s.name]=function(...a){let r=s.renderer.apply(this,a);return r===!1&&(r=o.apply(this,a)),r}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[s.level];o?o.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),i.extensions=t),n.renderer){let s=this.defaults.renderer||new Gi(this.defaults);for(let o in n.renderer){if(!(o in s))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,r=n.renderer[a],u=s[a];s[a]=(...c)=>{let h=r.apply(s,c);return h===!1&&(h=u.apply(s,c)),h||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new ji(this.defaults);for(let o in n.tokenizer){if(!(o in s))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,r=n.tokenizer[a],u=s[a];s[a]=(...c)=>{let h=r.apply(s,c);return h===!1&&(h=u.apply(s,c)),h}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new An;for(let o in n.hooks){if(!(o in s))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,r=n.hooks[a],u=s[a];An.passThroughHooks.has(o)?s[a]=c=>{if(this.defaults.async&&An.passThroughHooksRespectAsync.has(o))return(async()=>{let d=await r.call(s,c);return u.call(s,d)})();let h=r.call(s,c);return u.call(s,h)}:s[a]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await r.apply(s,c);return d===!1&&(d=await u.apply(s,c)),d})();let h=r.apply(s,c);return h===!1&&(h=u.apply(s,c)),h}}i.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,o=n.walkTokens;i.walkTokens=function(a){let r=[];return r.push(o.call(this,a)),s&&(r=r.concat(s.call(this,a))),r}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ae.lex(e,t??this.defaults)}parser(e,t){return Ce.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return o(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 o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let a=s.hooks?await s.hooks.preprocess(t):t,r=await(s.hooks?await s.hooks.provideLexer():e?Ae.lex:Ae.lexInline)(a,s),u=s.hooks?await s.hooks.processAllTokens(r):r;s.walkTokens&&await Promise.all(this.walkTokens(u,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():e?Ce.parse:Ce.parseInline)(u,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let a=(s.hooks?s.hooks.provideLexer():e?Ae.lex:Ae.lexInline)(t,s);s.hooks&&(a=s.hooks.processAllTokens(a)),s.walkTokens&&this.walkTokens(a,s.walkTokens);let r=(s.hooks?s.hooks.provideParser():e?Ce.parse:Ce.parseInline)(a,s);return s.hooks&&(r=s.hooks.postprocess(r)),r}catch(a){return o(a)}}}onError(e,t){return n=>{if(n.message+=`
2719
+ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Qe(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},_t=new xy;function V(e,t){return _t.parse(e,t)}V.options=V.setOptions=function(e){return _t.setOptions(e),V.defaults=_t.defaults,_d(V.defaults),V};V.getDefaults=$a;V.defaults=Rt;V.use=function(...e){return _t.use(...e),V.defaults=_t.defaults,_d(V.defaults),V};V.walkTokens=function(e,t){return _t.walkTokens(e,t)};V.parseInline=_t.parseInline;V.Parser=Ce;V.parser=Ce.parse;V.Renderer=Gi;V.TextRenderer=Pa;V.Lexer=Ae;V.lexer=Ae.lex;V.Tokenizer=ji;V.Hooks=An;V.parse=V;V.options;V.setOptions;V.use;V.walkTokens;V.parseInline;Ce.parse;Ae.lex;V.setOptions({gfm:!0,breaks:!0,mangle:!1});const el=["a","b","blockquote","br","code","del","em","h1","h2","h3","h4","hr","i","li","ol","p","pre","strong","table","tbody","td","th","thead","tr","ul"],tl=["class","href","rel","target","title","start"];let nl=!1;const $y=14e4,Sy=4e4,Ay=200,Js=5e4,bt=new Map;function Cy(e){const t=bt.get(e);return t===void 0?null:(bt.delete(e),bt.set(e,t),t)}function il(e,t){if(bt.set(e,t),bt.size<=Ay)return;const n=bt.keys().next().value;n&&bt.delete(n)}function Ey(){nl||(nl=!0,Lo.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Vi(e){const t=e.trim();if(!t)return"";if(Ey(),t.length<=Js){const a=Cy(t);if(a!==null)return a}const n=Xl(t,$y),i=n.truncated?`
2720
2720
 
2721
- … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>$y){const r=`<pre class="code-block">${Ey(`${n.text}${i}`)}</pre>`,u=Lo.sanitize(r,{ALLOWED_TAGS:el,ALLOWED_ATTR:tl});return t.length<=Js&&il(t,u),u}const s=V.parse(`${n.text}${i}`),o=Lo.sanitize(s,{ALLOWED_TAGS:el,ALLOWED_ATTR:tl});return t.length<=Js&&il(t,o),o}function Ey(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Ty=1500,_y=2e3,Fd="Copy as markdown",My="Copied",Py="Copy failed";async function Iy(e){if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}}function mi(e,t){e.title=t,e.setAttribute("aria-label",t)}function Ly(e){const t=e.label??Fd;return l`
2721
+ … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Sy){const r=`<pre class="code-block">${Ty(`${n.text}${i}`)}</pre>`,u=Lo.sanitize(r,{ALLOWED_TAGS:el,ALLOWED_ATTR:tl});return t.length<=Js&&il(t,u),u}const s=V.parse(`${n.text}${i}`),o=Lo.sanitize(s,{ALLOWED_TAGS:el,ALLOWED_ATTR:tl});return t.length<=Js&&il(t,o),o}function Ty(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const _y=1500,My=2e3,Ud="Copy as markdown",Py="Copied",Iy="Copy failed";async function Ly(e){if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}}function mi(e,t){e.title=t,e.setAttribute("aria-label",t)}function Ry(e){const t=e.label??Ud;return l`
2722
2722
  <button
2723
2723
  class="chat-copy-btn"
2724
2724
  type="button"
2725
2725
  title=${t}
2726
2726
  aria-label=${t}
2727
- @click=${async n=>{const i=n.currentTarget;if(i==null||i.querySelector(".chat-copy-btn__icon"),!i||i.dataset.copying==="1")return;i.dataset.copying="1",i.setAttribute("aria-busy","true"),i.disabled=!0;const s=await Iy(e.text());if(i.isConnected){if(delete i.dataset.copying,i.removeAttribute("aria-busy"),i.disabled=!1,!s){i.dataset.error="1",mi(i,Py),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.error,mi(i,t))},_y);return}i.dataset.copied="1",mi(i,My),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,mi(i,t))},Ty)}}}
2727
+ @click=${async n=>{const i=n.currentTarget;if(i==null||i.querySelector(".chat-copy-btn__icon"),!i||i.dataset.copying==="1")return;i.dataset.copying="1",i.setAttribute("aria-busy","true"),i.disabled=!0;const s=await Ly(e.text());if(i.isConnected){if(delete i.dataset.copying,i.removeAttribute("aria-busy"),i.disabled=!1,!s){i.dataset.error="1",mi(i,Iy),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.error,mi(i,t))},My);return}i.dataset.copied="1",mi(i,Py),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,mi(i,t))},_y)}}}
2728
2728
  >
2729
2729
  <span class="chat-copy-btn__icon" aria-hidden="true">
2730
2730
  <span class="chat-copy-btn__icon-copy">${L.copy}</span>
2731
2731
  <span class="chat-copy-btn__icon-check">${L.check}</span>
2732
2732
  </span>
2733
2733
  </button>
2734
- `}function Ry(e){return Ly({text:()=>e,label:Fd})}function Dy(e){const t=e,n=By(t.content),i=[];for(const s of n){const o=String(s.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(o)||typeof s.name=="string"&&s.arguments!=null)&&i.push({kind:"call",name:s.name??"tool",args:Ny(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const a=Oy(s),r=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:r,text:a})}if(ic(e)&&!i.some(s=>s.kind==="result")){const s=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",o=Zl(e)??void 0;i.push({kind:"result",name:s,text:o})}return i}function By(e){return Array.isArray(e)?e.filter(Boolean):[]}function Ny(e){if(typeof e!="string")return e;const t=e.trim();if(!t||!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.parse(t)}catch{return e}}function Oy(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}const Ys=40,Xs=new Map;async function Fy(e){const t=Xs.get(e);if(t)return t;try{const n=new(window.AudioContext||window.webkitAudioContext),s=await(await fetch(e)).arrayBuffer(),a=(await n.decodeAudioData(s)).getChannelData(0),r=Math.floor(a.length/Ys),u=[];for(let d=0;d<Ys;d++){let p=0;const v=d*r,$=Math.min(v+r,a.length);for(let S=v;S<$;S++){const M=Math.abs(a[S]);M>p&&(p=M)}u.push(p)}const c=Math.max(...u,.01),h=u.map(d=>Math.max(d/c,.08));return Xs.set(e,h),n.close(),h}catch{const n=Array.from(e).reduce((s,o)=>(s<<5)-s+o.charCodeAt(0)|0,0),i=[];for(let s=0;s<Ys;s++){const o=Math.abs((n*(s+1)*9301+49297)%233280/233280);i.push(.15+o*.85)}return Xs.set(e,i),i}}const Zs=[1,1.5,2],Qi=new Map;function Uy(e){let t=Qi.get(e);if(t)return t;const n=new Audio;return n.preload="metadata",n.src=e,t={audio:n,playing:!1,currentTime:0,duration:0,speed:1,waveform:[]},Qi.set(e,t),Fy(e).then(i=>{t.waveform=i,Ud(e)}),t}const Ln="http://www.w3.org/2000/svg";function Wy(){const e=document.createElementNS(Ln,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Ln,"polygon");return t.setAttribute("points","6,3 20,12 6,21"),e.appendChild(t),e}function Ky(){const e=document.createElementNS(Ln,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Ln,"rect");t.setAttribute("x","5"),t.setAttribute("y","3"),t.setAttribute("width","4"),t.setAttribute("height","18"),t.setAttribute("rx","1");const n=document.createElementNS(Ln,"rect");return n.setAttribute("x","15"),n.setAttribute("y","3"),n.setAttribute("width","4"),n.setAttribute("height","18"),n.setAttribute("rx","1"),e.append(t,n),e}function Ht(e){return document.querySelector(`.vnp[data-url="${CSS.escape(e)}"]`)}function Ud(e){const t=Ht(e);if(!t)return;const n=Qi.get(e);if(!n||n.waveform.length===0)return;const i=t.querySelector(".vnp__waveform");if(i){if(i.children.length===0){const s=document.createDocumentFragment();for(const o of n.waveform){const a=document.createElement("span");a.className="vnp__bar",a.style.height=`${Math.round(o*100)}%`,s.appendChild(a)}i.appendChild(s)}Rn(t,n)}}function Rn(e,t){const n=t.duration>0?t.currentTime/t.duration:0,i=e.querySelectorAll(".vnp__bar"),s=i.length;i.forEach((a,r)=>{a.classList.toggle("vnp__bar--active",r/s<n)});const o=e.querySelector(".vnp__time");o&&(o.textContent=t.playing||t.currentTime>0?Ji(t.currentTime):Ji(t.duration))}function eo(e,t){const n=e.querySelector(".vnp__play");if(!n)return;const i=n.querySelector("svg"),s=t?Ky():Wy();i?n.replaceChild(s,i):n.appendChild(s)}function Ji(e){if(!isFinite(e)||e<0)return"0:00";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${n.toString().padStart(2,"0")}`}const sl=new Set;function zy(e){if(sl.has(e))return;sl.add(e);const t=Qi.get(e);if(!t)return;const{audio:n}=t;n.addEventListener("loadedmetadata",()=>{t.duration=n.duration;const i=Ht(e);i&&Rn(i,t)}),n.addEventListener("timeupdate",()=>{t.currentTime=n.currentTime;const i=Ht(e);i&&Rn(i,t)}),n.addEventListener("ended",()=>{t.playing=!1,n.currentTime=0,t.currentTime=0;const i=Ht(e);i&&(Rn(i,t),eo(i,!1))}),n.addEventListener("pause",()=>{t.playing=!1;const i=Ht(e);i&&eo(i,!1)}),n.addEventListener("play",()=>{t.playing=!0;const i=Ht(e);i&&eo(i,!0)})}function Hy(e,t){const n=Uy(e);zy(e);const i=r=>{r.stopPropagation(),n.playing?n.audio.pause():n.audio.play()},s=r=>{r.stopPropagation();const u=Zs.indexOf(n.speed),c=Zs[(u+1)%Zs.length];n.speed=c,n.audio.playbackRate=c;const h=r.target.closest(".vnp__speed");h&&(h.textContent=`${c}×`)},o=r=>{r.stopPropagation();const u=r.target.closest(".vnp__waveform");if(!u)return;const c=u.getBoundingClientRect(),h=Math.max(0,Math.min(1,(r.clientX-c.left)/c.width));if(n.duration>0){n.audio.currentTime=h*n.duration,n.currentTime=n.audio.currentTime;const d=u.closest(".vnp");d&&Rn(d,n)}},a=n.playing||n.currentTime>0?Ji(n.currentTime):Ji(n.duration);return queueMicrotask(()=>Ud(e)),l`
2734
+ `}function Dy(e){return Ry({text:()=>e,label:Ud})}function By(e){const t=e,n=Ny(t.content),i=[];for(const s of n){const o=String(s.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(o)||typeof s.name=="string"&&s.arguments!=null)&&i.push({kind:"call",name:s.name??"tool",args:Oy(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const a=Fy(s),r=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:r,text:a})}if(ic(e)&&!i.some(s=>s.kind==="result")){const s=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",o=Zl(e)??void 0;i.push({kind:"result",name:s,text:o})}return i}function Ny(e){return Array.isArray(e)?e.filter(Boolean):[]}function Oy(e){if(typeof e!="string")return e;const t=e.trim();if(!t||!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.parse(t)}catch{return e}}function Fy(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}const Ys=40,Xs=new Map;async function Uy(e){const t=Xs.get(e);if(t)return t;try{const n=new(window.AudioContext||window.webkitAudioContext),s=await(await fetch(e)).arrayBuffer(),a=(await n.decodeAudioData(s)).getChannelData(0),r=Math.floor(a.length/Ys),u=[];for(let d=0;d<Ys;d++){let p=0;const v=d*r,$=Math.min(v+r,a.length);for(let S=v;S<$;S++){const M=Math.abs(a[S]);M>p&&(p=M)}u.push(p)}const c=Math.max(...u,.01),h=u.map(d=>Math.max(d/c,.08));return Xs.set(e,h),n.close(),h}catch{const n=Array.from(e).reduce((s,o)=>(s<<5)-s+o.charCodeAt(0)|0,0),i=[];for(let s=0;s<Ys;s++){const o=Math.abs((n*(s+1)*9301+49297)%233280/233280);i.push(.15+o*.85)}return Xs.set(e,i),i}}const Zs=[1,1.5,2],Qi=new Map;function Wy(e){let t=Qi.get(e);if(t)return t;const n=new Audio;return n.preload="metadata",n.src=e,t={audio:n,playing:!1,currentTime:0,duration:0,speed:1,waveform:[]},Qi.set(e,t),Uy(e).then(i=>{t.waveform=i,Wd(e)}),t}const Ln="http://www.w3.org/2000/svg";function Ky(){const e=document.createElementNS(Ln,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Ln,"polygon");return t.setAttribute("points","6,3 20,12 6,21"),e.appendChild(t),e}function zy(){const e=document.createElementNS(Ln,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Ln,"rect");t.setAttribute("x","5"),t.setAttribute("y","3"),t.setAttribute("width","4"),t.setAttribute("height","18"),t.setAttribute("rx","1");const n=document.createElementNS(Ln,"rect");return n.setAttribute("x","15"),n.setAttribute("y","3"),n.setAttribute("width","4"),n.setAttribute("height","18"),n.setAttribute("rx","1"),e.append(t,n),e}function Ht(e){return document.querySelector(`.vnp[data-url="${CSS.escape(e)}"]`)}function Wd(e){const t=Ht(e);if(!t)return;const n=Qi.get(e);if(!n||n.waveform.length===0)return;const i=t.querySelector(".vnp__waveform");if(i){if(i.children.length===0){const s=document.createDocumentFragment();for(const o of n.waveform){const a=document.createElement("span");a.className="vnp__bar",a.style.height=`${Math.round(o*100)}%`,s.appendChild(a)}i.appendChild(s)}Rn(t,n)}}function Rn(e,t){const n=t.duration>0?t.currentTime/t.duration:0,i=e.querySelectorAll(".vnp__bar"),s=i.length;i.forEach((a,r)=>{a.classList.toggle("vnp__bar--active",r/s<n)});const o=e.querySelector(".vnp__time");o&&(o.textContent=t.playing||t.currentTime>0?Ji(t.currentTime):Ji(t.duration))}function eo(e,t){const n=e.querySelector(".vnp__play");if(!n)return;const i=n.querySelector("svg"),s=t?zy():Ky();i?n.replaceChild(s,i):n.appendChild(s)}function Ji(e){if(!isFinite(e)||e<0)return"0:00";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${n.toString().padStart(2,"0")}`}const sl=new Set;function Hy(e){if(sl.has(e))return;sl.add(e);const t=Qi.get(e);if(!t)return;const{audio:n}=t;n.addEventListener("loadedmetadata",()=>{t.duration=n.duration;const i=Ht(e);i&&Rn(i,t)}),n.addEventListener("timeupdate",()=>{t.currentTime=n.currentTime;const i=Ht(e);i&&Rn(i,t)}),n.addEventListener("ended",()=>{t.playing=!1,n.currentTime=0,t.currentTime=0;const i=Ht(e);i&&(Rn(i,t),eo(i,!1))}),n.addEventListener("pause",()=>{t.playing=!1;const i=Ht(e);i&&eo(i,!1)}),n.addEventListener("play",()=>{t.playing=!0;const i=Ht(e);i&&eo(i,!0)})}function qy(e,t){const n=Wy(e);Hy(e);const i=r=>{r.stopPropagation(),n.playing?n.audio.pause():n.audio.play()},s=r=>{r.stopPropagation();const u=Zs.indexOf(n.speed),c=Zs[(u+1)%Zs.length];n.speed=c,n.audio.playbackRate=c;const h=r.target.closest(".vnp__speed");h&&(h.textContent=`${c}×`)},o=r=>{r.stopPropagation();const u=r.target.closest(".vnp__waveform");if(!u)return;const c=u.getBoundingClientRect(),h=Math.max(0,Math.min(1,(r.clientX-c.left)/c.width));if(n.duration>0){n.audio.currentTime=h*n.duration,n.currentTime=n.audio.currentTime;const d=u.closest(".vnp");d&&Rn(d,n)}},a=n.playing||n.currentTime>0?Ji(n.currentTime):Ji(n.duration);return queueMicrotask(()=>Wd(e)),l`
2735
2735
  <div class="vnp" data-url=${e} @click=${r=>r.stopPropagation()}>
2736
2736
  <button class="vnp__play" @click=${i} aria-label=${n.playing?"Pause":"Play"}>
2737
- ${n.playing?jy():qy()}
2737
+ ${n.playing?Gy():jy()}
2738
2738
  </button>
2739
2739
 
2740
2740
  <div class="vnp__body">
@@ -2747,7 +2747,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2747
2747
  </div>
2748
2748
  </div>
2749
2749
  </div>
2750
- `}function qy(){return l`<svg viewBox="0 0 24 24" fill="currentColor"><polygon points="6,3 20,12 6,21" /></svg>`}function jy(){return l`<svg viewBox="0 0 24 24" fill="currentColor"><rect x="5" y="3" width="4" height="18" rx="1"/><rect x="15" y="3" width="4" height="18" rx="1"/></svg>`}function Gy(e){var s;const n=e.content,i=[];if(Array.isArray(n))for(const o of n){if(typeof o!="object"||o===null)continue;const a=o;if(a.type==="image")if(((s=a.source)==null?void 0:s.type)==="base64"){const r=a.source,u=r.data,c=r.media_type||"image/png",h=u.startsWith("data:")?u:`data:${c};base64,${u}`;i.push({url:h})}else if(typeof a.data=="string"&&a.data){const r=a.data,u=a.mimeType||a.media_type||"image/png",c=r.startsWith("data:")?r:`data:${u};base64,${r}`;i.push({url:c})}else typeof a.url=="string"&&i.push({url:a.url});else if(a.type==="image_url"){const r=a.image_url;typeof(r==null?void 0:r.url)=="string"&&i.push({url:r.url})}}return i}function Vy(e){const n=e.content,i=[];if(Array.isArray(n))for(const s of n){if(typeof s!="object"||s===null)continue;const o=s;o.type==="file"&&typeof o.url=="string"&&typeof o.name=="string"&&i.push({url:o.url,name:o.name,mimeType:o.mimeType??"application/octet-stream"})}return i}function Qy(e){return e==="application/pdf"?"📄":e.startsWith("audio/")?"🎵":"📎"}function Jy(e){return l`
2750
+ `}function jy(){return l`<svg viewBox="0 0 24 24" fill="currentColor"><polygon points="6,3 20,12 6,21" /></svg>`}function Gy(){return l`<svg viewBox="0 0 24 24" fill="currentColor"><rect x="5" y="3" width="4" height="18" rx="1"/><rect x="15" y="3" width="4" height="18" rx="1"/></svg>`}function Vy(e){var s;const n=e.content,i=[];if(Array.isArray(n))for(const o of n){if(typeof o!="object"||o===null)continue;const a=o;if(a.type==="image")if(((s=a.source)==null?void 0:s.type)==="base64"){const r=a.source,u=r.data,c=r.media_type||"image/png",h=u.startsWith("data:")?u:`data:${c};base64,${u}`;i.push({url:h})}else if(typeof a.data=="string"&&a.data){const r=a.data,u=a.mimeType||a.media_type||"image/png",c=r.startsWith("data:")?r:`data:${u};base64,${r}`;i.push({url:c})}else typeof a.url=="string"&&i.push({url:a.url});else if(a.type==="image_url"){const r=a.image_url;typeof(r==null?void 0:r.url)=="string"&&i.push({url:r.url})}}return i}function Qy(e){const n=e.content,i=[];if(Array.isArray(n))for(const s of n){if(typeof s!="object"||s===null)continue;const o=s;o.type==="file"&&typeof o.url=="string"&&typeof o.name=="string"&&i.push({url:o.url,name:o.name,mimeType:o.mimeType??"application/octet-stream"})}return i}function Jy(e){return e==="application/pdf"?"📄":e.startsWith("audio/")?"🎵":"📎"}function Yy(e){return l`
2751
2751
  <div class="chat-group assistant">
2752
2752
  <div class="chat-group-messages">
2753
2753
  <div class="chat-bubble chat-reading-indicator" aria-hidden="true">
@@ -2757,7 +2757,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2757
2757
  </div>
2758
2758
  </div>
2759
2759
  </div>
2760
- `}function Yy(e){return l`
2760
+ `}function Xy(e){return l`
2761
2761
  <div class="chat-group assistant">
2762
2762
  <div class="chat-group-messages">
2763
2763
  <div class="chat-interim fade-in">
@@ -2765,22 +2765,22 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2765
2765
  </div>
2766
2766
  </div>
2767
2767
  </div>
2768
- `}function Xy(e,t,n,i){return l`
2768
+ `}function Zy(e,t,n,i){return l`
2769
2769
  <div class="chat-group assistant">
2770
2770
  <div class="chat-group-messages">
2771
- ${Wd({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
2771
+ ${Kd({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
2772
2772
  </div>
2773
2773
  </div>
2774
- `}function Zy(e,t){const n=nc(e.role),i=n==="user"?"user":n==="assistant"?"assistant":"other",s=new Date(e.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"});return l`
2774
+ `}function ev(e,t){const n=nc(e.role),i=n==="user"?"user":n==="assistant"?"assistant":"other",s=new Date(e.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"});return l`
2775
2775
  <div class="chat-group ${i}">
2776
2776
  <div class="chat-group-messages">
2777
- ${e.messages.map((o,a)=>Wd(o.message,{isStreaming:e.isStreaming&&a===e.messages.length-1,showReasoning:t.showReasoning}))}
2777
+ ${e.messages.map((o,a)=>Kd(o.message,{isStreaming:e.isStreaming&&a===e.messages.length-1,showReasoning:t.showReasoning}))}
2778
2778
  <div class="chat-group-footer">
2779
2779
  <span class="chat-group-timestamp">${s}</span>
2780
2780
  </div>
2781
2781
  </div>
2782
2782
  </div>
2783
- `}function ev(e){return e.length===0?w:l`
2783
+ `}function tv(e){return e.length===0?w:l`
2784
2784
  <div class="chat-message-images">
2785
2785
  ${e.map(t=>l`
2786
2786
  <img
@@ -2791,12 +2791,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2791
2791
  />
2792
2792
  `)}
2793
2793
  </div>
2794
- `}function tv(e){return e.length===0?w:l`
2794
+ `}function nv(e){return e.length===0?w:l`
2795
2795
  <div class="chat-message-files">
2796
- ${e.map(t=>t.mimeType==="application/pdf"?iv(t):t.mimeType.startsWith("audio/")?Hy(t.url,t.name):sv(t))}
2796
+ ${e.map(t=>t.mimeType==="application/pdf"?sv(t):t.mimeType.startsWith("audio/")?qy(t.url,t.name):ov(t))}
2797
2797
  </div>
2798
- `}function nv(e,t){const n=document.createElement("div");n.className="chat-pdf-modal-overlay";const i=document.createElement("div");i.className="chat-pdf-modal";const s=document.createElement("div");s.className="chat-pdf-modal__header";const o=document.createElement("span");o.className="chat-pdf-modal__title",o.textContent=t;const a=document.createElement("a");a.className="chat-pdf-modal__open",a.href=e,a.target="_blank",a.rel="noreferrer noopener",a.textContent="Open in new tab";const r=document.createElement("button");r.className="chat-pdf-modal__close",r.setAttribute("aria-label","Close");const u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("viewBox","0 0 24 24");const c=document.createElementNS("http://www.w3.org/2000/svg","line");c.setAttribute("x1","18"),c.setAttribute("y1","6"),c.setAttribute("x2","6"),c.setAttribute("y2","18");const h=document.createElementNS("http://www.w3.org/2000/svg","line");h.setAttribute("x1","6"),h.setAttribute("y1","6"),h.setAttribute("x2","18"),h.setAttribute("y2","18"),u.append(c,h),r.appendChild(u),s.append(o,a,r);const d=document.createElement("iframe");d.className="chat-pdf-modal__frame",d.src=e,d.title=t,i.append(s,d),n.appendChild(i),n.addEventListener("click",p=>{p.target===n&&n.remove()}),r.addEventListener("click",()=>n.remove()),document.body.appendChild(n)}function iv(e){return l`
2799
- <div class="chat-pdf-preview" @click=${()=>nv(e.url,e.name)}>
2798
+ `}function iv(e,t){const n=document.createElement("div");n.className="chat-pdf-modal-overlay";const i=document.createElement("div");i.className="chat-pdf-modal";const s=document.createElement("div");s.className="chat-pdf-modal__header";const o=document.createElement("span");o.className="chat-pdf-modal__title",o.textContent=t;const a=document.createElement("a");a.className="chat-pdf-modal__open",a.href=e,a.target="_blank",a.rel="noreferrer noopener",a.textContent="Open in new tab";const r=document.createElement("button");r.className="chat-pdf-modal__close",r.setAttribute("aria-label","Close");const u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("viewBox","0 0 24 24");const c=document.createElementNS("http://www.w3.org/2000/svg","line");c.setAttribute("x1","18"),c.setAttribute("y1","6"),c.setAttribute("x2","6"),c.setAttribute("y2","18");const h=document.createElementNS("http://www.w3.org/2000/svg","line");h.setAttribute("x1","6"),h.setAttribute("y1","6"),h.setAttribute("x2","18"),h.setAttribute("y2","18"),u.append(c,h),r.appendChild(u),s.append(o,a,r);const d=document.createElement("iframe");d.className="chat-pdf-modal__frame",d.src=e,d.title=t,i.append(s,d),n.appendChild(i),n.addEventListener("click",p=>{p.target===n&&n.remove()}),r.addEventListener("click",()=>n.remove()),document.body.appendChild(n)}function sv(e){return l`
2799
+ <div class="chat-pdf-preview" @click=${()=>iv(e.url,e.name)}>
2800
2800
  <iframe
2801
2801
  src=${e.url}
2802
2802
  class="chat-pdf-preview__frame"
@@ -2810,39 +2810,39 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2810
2810
  @click=${t=>t.stopPropagation()}
2811
2811
  >${e.name}</a>
2812
2812
  </div>
2813
- `}function sv(e){return l`
2813
+ `}function ov(e){return l`
2814
2814
  <a
2815
2815
  class="chat-file-card"
2816
2816
  href=${e.url}
2817
2817
  target="_blank"
2818
2818
  rel="noreferrer noopener"
2819
2819
  >
2820
- <span class="chat-file-card__icon">${Qy(e.mimeType)}</span>
2820
+ <span class="chat-file-card__icon">${Jy(e.mimeType)}</span>
2821
2821
  <span class="chat-file-card__name">${e.name}</span>
2822
2822
  </a>
2823
- `}function Wd(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=ic(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",r=Dy(e).length>0,u=Gy(e),c=u.length>0,h=Vy(e),d=h.length>0,p=Zl(e),v=t.showReasoning&&s==="assistant"?Up(e):null,$=p!=null&&p.trim()?p:null,S=v?Kp(v):null,M=$,y=(s==="assistant"||s==="user")&&!!(M!=null&&M.trim()),b=["chat-bubble",y?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!M&&(r||o)||!M&&!c&&!d?w:l`
2823
+ `}function Kd(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=ic(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",r=By(e).length>0,u=Vy(e),c=u.length>0,h=Qy(e),d=h.length>0,p=Zl(e),v=t.showReasoning&&s==="assistant"?Wp(e):null,$=p!=null&&p.trim()?p:null,S=v?zp(v):null,M=$,y=(s==="assistant"||s==="user")&&!!(M!=null&&M.trim()),b=["chat-bubble",y?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!M&&(r||o)||!M&&!c&&!d?w:l`
2824
2824
  <div class="${b}">
2825
- ${y?Ry(M):w}
2826
- ${ev(u)}
2827
- ${tv(h)}
2825
+ ${y?Dy(M):w}
2826
+ ${tv(u)}
2827
+ ${nv(h)}
2828
2828
  ${S?l`<div class="chat-thinking">${Hi(Vi(S))}</div>`:w}
2829
2829
  ${M?l`<div class="chat-text">${Hi(Vi(M))}</div>`:w}
2830
2830
  </div>
2831
- `}const O={active:!1,mode:"tap",startTime:0,elapsed:0,mediaRecorder:null,audioChunks:[],stream:null,timerId:null,startX:0,cancelled:!1};let G=null,xt=null,$t=!1;function ol(e){const t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}function mt(){if(O.timerId&&(clearInterval(O.timerId),O.timerId=null),O.stream){for(const e of O.stream.getTracks())e.stop();O.stream=null}xt&&(clearTimeout(xt),xt=null),Yi(),O.mediaRecorder=null,O.audioChunks=[],O.active=!1,O.cancelled=!1,$t=!1}async function Kd(e){var t;try{if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia))return console.warn("[voice] getUserMedia unavailable (requires secure context)"),mt(),!1;const n=await navigator.mediaDevices.getUserMedia({audio:!0});O.stream=n;const i=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",s=i?new MediaRecorder(n,{mimeType:i}):new MediaRecorder(n);return O.mediaRecorder=s,O.audioChunks=[],O.mode=e,O.startTime=Date.now(),O.elapsed=0,O.active=!0,O.cancelled=!1,s.ondataavailable=o=>{o.data.size>0&&O.audioChunks.push(o.data)},s.onstop=()=>{if(O.cancelled){mt(),G==null||G.onRequestRender();return}const o=new Blob(O.audioChunks,{type:s.mimeType});if(o.size===0){mt(),G==null||G.onRequestRender();return}const a=new FileReader;a.onload=()=>{const r=a.result,u=s.mimeType.includes("mp4")?"m4a":"webm",c={id:as(),dataUrl:r,mimeType:s.mimeType||"audio/webm",fileName:`voice-note-${Date.now()}.${u}`};mt(),G==null||G.onSend(c),G==null||G.onRequestRender()},a.onerror=()=>{mt(),G==null||G.onRequestRender()},a.readAsDataURL(o)},s.start(250),O.timerId=setInterval(()=>{O.elapsed=Math.floor((Date.now()-O.startTime)/1e3),G==null||G.onRequestRender()},1e3),G==null||G.onRequestRender(),!0}catch(n){return console.warn("[voice] startRecording failed:",n),mt(),!1}}function zd(){!O.active||!O.mediaRecorder||(O.cancelled=!1,O.mediaRecorder.state==="recording"&&O.mediaRecorder.stop())}function Hd(){!O.active||!O.mediaRecorder||(O.cancelled=!0,O.mediaRecorder.state==="recording"?O.mediaRecorder.stop():(mt(),G==null||G.onRequestRender()))}function ov(){document.addEventListener("pointerup",qd)}function Yi(){document.removeEventListener("pointerup",qd)}function qd(e){if(!$t&&!O.active){Yi();return}if($t=!1,Yi(),xt&&(clearTimeout(xt),xt=null,!O.active)){Kd("tap");return}O.active&&O.mode==="hold"&&(O.cancelled?Hd():zd()),e.preventDefault()}function av(e){O.active||($t=!0,O.startX=e.clientX,ov(),xt=setTimeout(async()=>{if(!$t)return;await Kd("hold")||($t=!1,Yi())},300))}function al(e){if(!O.active||O.mode!=="hold"||!$t)return;const t=O.startX-e.clientX;t>80?(O.cancelled=!0,G==null||G.onRequestRender()):O.cancelled&&t<=60&&(O.cancelled=!1,G==null||G.onRequestRender())}function rv(){return O.active}function lv(e){G=e}function cv(e){return l`
2831
+ `}const O={active:!1,mode:"tap",startTime:0,elapsed:0,mediaRecorder:null,audioChunks:[],stream:null,timerId:null,startX:0,cancelled:!1};let G=null,xt=null,$t=!1;function ol(e){const t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}function mt(){if(O.timerId&&(clearInterval(O.timerId),O.timerId=null),O.stream){for(const e of O.stream.getTracks())e.stop();O.stream=null}xt&&(clearTimeout(xt),xt=null),Yi(),O.mediaRecorder=null,O.audioChunks=[],O.active=!1,O.cancelled=!1,$t=!1}async function zd(e){var t;try{if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia))return console.warn("[voice] getUserMedia unavailable (requires secure context)"),mt(),!1;const n=await navigator.mediaDevices.getUserMedia({audio:!0});O.stream=n;const i=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",s=i?new MediaRecorder(n,{mimeType:i}):new MediaRecorder(n);return O.mediaRecorder=s,O.audioChunks=[],O.mode=e,O.startTime=Date.now(),O.elapsed=0,O.active=!0,O.cancelled=!1,s.ondataavailable=o=>{o.data.size>0&&O.audioChunks.push(o.data)},s.onstop=()=>{if(O.cancelled){mt(),G==null||G.onRequestRender();return}const o=new Blob(O.audioChunks,{type:s.mimeType});if(o.size===0){mt(),G==null||G.onRequestRender();return}const a=new FileReader;a.onload=()=>{const r=a.result,u=s.mimeType.includes("mp4")?"m4a":"webm",c={id:as(),dataUrl:r,mimeType:s.mimeType||"audio/webm",fileName:`voice-note-${Date.now()}.${u}`};mt(),G==null||G.onSend(c),G==null||G.onRequestRender()},a.onerror=()=>{mt(),G==null||G.onRequestRender()},a.readAsDataURL(o)},s.start(250),O.timerId=setInterval(()=>{O.elapsed=Math.floor((Date.now()-O.startTime)/1e3),G==null||G.onRequestRender()},1e3),G==null||G.onRequestRender(),!0}catch(n){return console.warn("[voice] startRecording failed:",n),mt(),!1}}function Hd(){!O.active||!O.mediaRecorder||(O.cancelled=!1,O.mediaRecorder.state==="recording"&&O.mediaRecorder.stop())}function qd(){!O.active||!O.mediaRecorder||(O.cancelled=!0,O.mediaRecorder.state==="recording"?O.mediaRecorder.stop():(mt(),G==null||G.onRequestRender()))}function av(){document.addEventListener("pointerup",jd)}function Yi(){document.removeEventListener("pointerup",jd)}function jd(e){if(!$t&&!O.active){Yi();return}if($t=!1,Yi(),xt&&(clearTimeout(xt),xt=null,!O.active)){zd("tap");return}O.active&&O.mode==="hold"&&(O.cancelled?qd():Hd()),e.preventDefault()}function rv(e){O.active||($t=!0,O.startX=e.clientX,av(),xt=setTimeout(async()=>{if(!$t)return;await zd("hold")||($t=!1,Yi())},300))}function al(e){if(!O.active||O.mode!=="hold"||!$t)return;const t=O.startX-e.clientX;t>80?(O.cancelled=!0,G==null||G.onRequestRender()):O.cancelled&&t<=60&&(O.cancelled=!1,G==null||G.onRequestRender())}function lv(){return O.active}function cv(e){G=e}function dv(e){return l`
2832
2832
  <button
2833
2833
  class="btn btn--icon chat-compose__mic"
2834
2834
  ?disabled=${!e}
2835
- @pointerdown=${av}
2835
+ @pointerdown=${rv}
2836
2836
  aria-label="Record voice note"
2837
2837
  title="Tap to record, hold to send on release"
2838
2838
  >
2839
2839
  ${L.mic}
2840
2840
  </button>
2841
- `}function dv(){return O.active?O.mode==="tap"?l`
2841
+ `}function uv(){return O.active?O.mode==="tap"?l`
2842
2842
  <div class="chat-voice-recording" @pointermove=${al}>
2843
2843
  <button
2844
2844
  class="btn btn--icon chat-voice-recording__trash"
2845
- @click=${Hd}
2845
+ @click=${qd}
2846
2846
  aria-label="Cancel recording"
2847
2847
  title="Discard"
2848
2848
  >
@@ -2854,7 +2854,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2854
2854
  </div>
2855
2855
  <button
2856
2856
  class="btn btn--icon chat-voice-recording__send primary"
2857
- @click=${zd}
2857
+ @click=${Hd}
2858
2858
  aria-label="Send voice note"
2859
2859
  title="Send"
2860
2860
  >
@@ -2871,7 +2871,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2871
2871
  </span>
2872
2872
  </div>
2873
2873
  </div>
2874
- `:w}function uv(e){return l`
2874
+ `:w}function pv(e){return l`
2875
2875
  <div class="sidebar-panel">
2876
2876
  <div class="sidebar-header">
2877
2877
  <div class="sidebar-title">Tool Output</div>
@@ -2888,7 +2888,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2888
2888
  `:e.content?l`<div class="sidebar-markdown">${Hi(Vi(e.content))}</div>`:l`<div class="muted">No content available</div>`}
2889
2889
  </div>
2890
2890
  </div>
2891
- `}var pv=Object.defineProperty,hv=Object.getOwnPropertyDescriptor,fs=(e,t,n,i)=>{for(var s=i>1?void 0:i?hv(t,n):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(i?a(t,n,s):a(s))||s);return i&&s&&pv(t,n,s),s};let Yt=class extends jt{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,s=(e.clientX-this.startX)/n;let o=this.startRatio+s;o=Math.max(this.minRatio,Math.min(this.maxRatio,o)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:o},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return l``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};Yt.styles=Yu`
2891
+ `}var hv=Object.defineProperty,fv=Object.getOwnPropertyDescriptor,fs=(e,t,n,i)=>{for(var s=i>1?void 0:i?fv(t,n):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(i?a(t,n,s):a(s))||s);return i&&s&&hv(t,n,s),s};let Yt=class extends jt{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,s=(e.clientX-this.startX)/n;let o=this.startRatio+s;o=Math.max(this.minRatio,Math.min(this.maxRatio,o)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:o},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return l``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};Yt.styles=Xu`
2892
2892
  :host {
2893
2893
  width: 4px;
2894
2894
  cursor: col-resize;
@@ -2914,21 +2914,21 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2914
2914
  :host(.dragging) {
2915
2915
  background: var(--accent, #007bff);
2916
2916
  }
2917
- `;fs([ss({type:Number})],Yt.prototype,"splitRatio",2);fs([ss({type:Number})],Yt.prototype,"minRatio",2);fs([ss({type:Number})],Yt.prototype,"maxRatio",2);Yt=fs([ql("resizable-divider")],Yt);function yi(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function to(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const fv=1,gv=1,Dt="emoji",Xt="keyvalue",Ia="favorites",mv="tokens",jd="tokens",yv="unicode",Gd="count",vv="group",bv="order",Vd="group-order",No="eTag",Xi="url",rl="skinTone",ln="readonly",La="readwrite",Qd="skinUnicodes",wv="skinUnicodes",kv="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",xv="en";function $v(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function ll(e){return $v(e,t=>t.unicode)}function Sv(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[a,[r,u]]of Object.entries(s))o.createIndex(a,r,{multiEntry:u});return o}t(Xt),t(Dt,yv,{[jd]:[mv,!0],[Vd]:[[vv,bv]],[Qd]:[wv,!0]}),t(Ia,void 0,{[Gd]:[""]})}const Oo={},Ei={},Zi={};function Jd(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function Av(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,fv);Oo[e]=s,s.onupgradeneeded=o=>{o.oldVersion<gv&&Sv(s.result)},Jd(n,i,s)});return t.onclose=()=>Ra(e),t}function Cv(e){return Ei[e]||(Ei[e]=Av(e)),Ei[e]}function Xe(e,t,n,i){return new Promise((s,o)=>{const a=e.transaction(t,n,{durability:"relaxed"}),r=typeof t=="string"?a.objectStore(t):t.map(c=>a.objectStore(c));let u;i(r,a,c=>{u=c}),a.oncomplete=()=>s(u),a.onerror=()=>o(a.error)})}function Ra(e){const t=Oo[e],n=t&&t.result;if(n){n.close();const i=Zi[e];if(i)for(const s of i)s()}delete Oo[e],delete Ei[e],delete Zi[e]}function Ev(e){return new Promise((t,n)=>{Ra(e);const i=indexedDB.deleteDatabase(e);Jd(t,n,i)})}function Tv(e,t){let n=Zi[e];n||(n=Zi[e]=[]),n.push(t)}const _v=new Set([":D","XD",":'D","O:)",":X",":P",";P","XP",":L",":Z",":j","8D","XO","8)",":B",":O",":S",":'o","Dx","X(","D:",":C",">0)",":3","</3","<3","\\M/",":E","8#"]);function Vt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||_v.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const Mv=2;function Yd(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=Mv)}function Pv(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:a,skins:r,tags:u,emoji:c,version:h})=>{const d=[...new Set(Yd([...(a||[]).map(Vt).flat(),...(u||[]).map(Vt).flat(),...Vt(n),i]))].sort(),p={annotation:n,group:s,order:o,tags:u,tokens:d,unicode:c,version:h};if(i&&(p.emoticon=i),a&&(p.shortcodes=a),r){p.skinTones=[],p.skinUnicodes=[],p.skinVersions=[];for(const{tone:v,emoji:$,version:S}of r)p.skinTones.push(v),p.skinUnicodes.push($),p.skinVersions.push(S)}return p})}function Xd(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function Mt(e,t,n){Xd(e,"get",t,n)}function Zd(e,t,n){Xd(e,"getAll",t,n)}function Da(e){e.commit&&e.commit()}function Iv(e,t){let n=e[0];for(let i=1;i<e.length;i++){const s=e[i];t(n)>t(s)&&(n=s)}return n}function eu(e,t){const n=Iv(e,s=>s.length),i=[];for(const s of n)e.some(o=>o.findIndex(a=>t(a)===t(s))===-1)||i.push(s);return i}async function Lv(e){return!await Ba(e,Xt,Xi)}async function Rv(e,t,n){const[i,s]=await Promise.all([No,Xi].map(o=>Ba(e,Xt,o)));return i===n&&s===t}async function Dv(e,t){return Xe(e,Dt,ln,(i,s,o)=>{let a;const r=()=>{i.getAll(a&&IDBKeyRange.lowerBound(a,!0),50).onsuccess=u=>{const c=u.target.result;for(const h of c)if(a=h.unicode,t(h))return o(h);if(c.length<50)return o();r()}};r()})}async function tu(e,t,n,i){{const s=Pv(t);await Xe(e,[Dt,Xt],La,([o,a],r)=>{let u,c,h=0;function d(){++h===2&&p()}function p(){if(!(u===i&&c===n)){o.clear();for(const v of s)o.put(v);a.put(i,No),a.put(n,Xi),Da(r)}}Mt(a,No,v=>{u=v,d()}),Mt(a,Xi,v=>{c=v,d()})})}}async function Bv(e,t){return Xe(e,Dt,ln,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);Zd(n.index(Vd),o,s)})}async function nu(e,t){const n=Yd(Vt(t));return n.length?Xe(e,Dt,ln,(i,s,o)=>{const a=[],r=()=>{a.length===n.length&&u()},u=()=>{const c=eu(a,h=>h.unicode);o(c.sort((h,d)=>h.order<d.order?-1:1))};for(let c=0;c<n.length;c++){const h=n[c],d=c===n.length-1?IDBKeyRange.bound(h,h+"￿",!1,!0):IDBKeyRange.only(h);Zd(i.index(jd),d,p=>{a.push(p),r()})}}):[]}async function Nv(e,t){const n=await nu(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await Dv(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function Ov(e,t){return Xe(e,Dt,ln,(n,i,s)=>Mt(n,t,o=>{if(o)return s(o);Mt(n.index(Qd),t,a=>s(a||null))}))}function Ba(e,t,n){return Xe(e,t,ln,(i,s,o)=>Mt(i,n,o))}function Fv(e,t,n,i){return Xe(e,t,La,(s,o)=>{s.put(i,n),Da(o)})}function Uv(e,t){return Xe(e,Ia,La,(n,i)=>Mt(n,t,s=>{n.put((s||0)+1,t),Da(i)}))}function Wv(e,t,n){return n===0?[]:Xe(e,[Ia,Dt],ln,([i,s],o,a)=>{const r=[];i.index(Gd).openCursor(void 0,"prev").onsuccess=u=>{const c=u.target.result;if(!c)return a(r);function h(v){if(r.push(v),r.length===n)return a(r);c.continue()}const d=c.primaryKey,p=t.byName(d);if(p)return h(p);Mt(s,d,v=>{if(v)return h(v);c.continue()})}})}const vi="";function Kv(e,t){const n=new Map;for(const s of e){const o=t(s);for(const a of o){let r=n;for(let c=0;c<a.length;c++){const h=a.charAt(c);let d=r.get(h);d||(d=new Map,r.set(h,d)),r=d}let u=r.get(vi);u||(u=[],r.set(vi,u)),u.push(s)}}return(s,o)=>{let a=n;for(let c=0;c<s.length;c++){const h=s.charAt(c),d=a.get(h);if(d)a=d;else return[]}if(o)return a.get(vi)||[];const r=[],u=[a];for(;u.length;){const h=[...u.shift().entries()].sort((d,p)=>d[0]<p[0]?-1:1);for(const[d,p]of h)d===vi?r.push(...p):u.push(p)}return r}}const zv=["name","url"];function Hv(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||zv.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function cl(e){Hv(e);const t=(p,v)=>p.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),s=Kv(e,p=>{const v=new Set;if(p.shortcodes)for(const $ of p.shortcodes)for(const S of Vt($))v.add(S);return v}),o=p=>s(p,!0),a=p=>s(p,!1),r=p=>{const v=Vt(p),$=v.map((S,M)=>(M<v.length-1?o:a)(S));return eu($,S=>S.name).sort(t)},u=new Map,c=new Map;for(const p of e){c.set(p.name.toLowerCase(),p);for(const v of p.shortcodes||[])u.set(v.toLowerCase(),p)}return{all:n,search:r,byShortcode:p=>u.get(p.toLowerCase()),byName:p=>c.get(p.toLowerCase())}}const qv=typeof wrappedJSObject<"u";function $n(e){if(!e)return e;if(qv&&(e=structuredClone(e)),delete e.tokens,e.skinTones){const t=e.skinTones.length;e.skins=Array(t);for(let n=0;n<t;n++)e.skins[n]={tone:e.skinTones[n],unicode:e.skinUnicodes[n],version:e.skinVersions[n]};delete e.skinTones,delete e.skinUnicodes,delete e.skinVersions}return e}function iu(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const jv=["annotation","emoji","group","order","version"];function Gv(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||jv.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function su(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Vv(e){const t=await fetch(e,{method:"HEAD"});su(t,e);const n=t.headers.get("etag");return iu(n),n}async function Fo(e){const t=await fetch(e);su(t,e);const n=t.headers.get("etag");iu(n);const i=await t.json();return Gv(i),[n,i]}function Qv(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Jv(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),s=-1;++s<t;)i[s]=e.charCodeAt(s);return n}async function ou(e){const t=JSON.stringify(e);let n=Jv(t);const i=await crypto.subtle.digest("SHA-1",n),s=Qv(i);return btoa(s)}async function Yv(e,t){let n,i=await Vv(t);if(!i){const s=await Fo(t);i=s[0],n=s[1],i||(i=await ou(n))}await Rv(e,t,i)||(n||(n=(await Fo(t))[1]),await tu(e,n,t,i))}async function Xv(e,t){let[n,i]=await Fo(t);n||(n=await ou(i)),await tu(e,i,t,n)}async function Zv(e,t){try{await Yv(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class eb{constructor({dataSource:t=kv,locale:n=xv,customEmoji:i=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=cl(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await Cv(this._dbName);Tv(this._dbName,this._clear);const n=this.dataSource;await Lv(t)?await Xv(t,n):this._lazyUpdate=Zv(t,n)}async ready(){const t=async()=>(this._ready||(this._ready=this._init()),this._ready);await t(),this._db||await t()}async getEmojiByGroup(t){return to(t),await this.ready(),ll(await Bv(this._db,t)).map($n)}async getEmojiBySearchQuery(t){yi(t),await this.ready();const n=this._custom.search(t),i=ll(await nu(this._db,t)).map($n);return[...n,...i]}async getEmojiByShortcode(t){yi(t),await this.ready();const n=this._custom.byShortcode(t);return n||$n(await Nv(this._db,t))}async getEmojiByUnicodeOrName(t){yi(t),await this.ready();const n=this._custom.byName(t);return n||$n(await Ov(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Ba(this._db,Xt,rl)||0}async setPreferredSkinTone(t){return to(t),await this.ready(),Fv(this._db,Xt,rl,t)}async incrementFavoriteEmojiCount(t){return yi(t),await this.ready(),Uv(this._db,t)}async getTopFavoriteEmoji(t){return to(t),await this.ready(),(await Wv(this._db,this._custom,t)).map($n)}set customEmoji(t){this._custom=cl(t)}get customEmoji(){return this._custom.all}async _shutdown(){await this.ready();try{await this._lazyUpdate}catch{}}_clear(){this._db=this._ready=this._lazyUpdate=void 0}async close(){await this._shutdown(),await Ra(this._dbName)}async delete(){await this._shutdown(),await Ev(this._dbName)}}const Uo=[[-1,"✨","custom"],[0,"😀","smileys-emotion"],[1,"👋","people-body"],[3,"🐱","animals-nature"],[4,"🍎","food-drink"],[5,"🏠️","travel-places"],[6,"⚽","activities"],[7,"📝","objects"],[8,"⛔️","symbols"],[9,"🏁","flags"]].map(([e,t,n])=>({id:e,emoji:t,name:n})),no=Uo.slice(1),tb=2,dl=6,au=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function ul(e){return e.unicode.includes("‍")}const nb={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},ib=1e3,sb="🖐️",ob=8,ab=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],ru='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',rb=(e,t)=>e<t?-1:e>t?1:0,pl=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const i=n.getContext("2d",{willReadFrequently:!0});return i.textBaseline="top",i.font=`100px ${ru}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},lb=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function cb(e){const t=pl(e,"#000"),n=pl(e,"#fff");return t&&n&&lb(t,n)}function db(){const e=Object.entries(nb);try{for(const[t,n]of e)if(cb(t))return n}catch{}return e[0][1]}let io;const so=()=>(io||(io=new Promise(e=>au(()=>e(db())))),io),Wo=new Map,ub="️",pb="\uD83C",hb="‍",fb=127995,gb=57339;function mb(e,t){if(t===0)return e;const n=e.indexOf(hb);return n!==-1?e.substring(0,n)+String.fromCodePoint(fb+t-1)+e.substring(n):(e.endsWith(ub)&&(e=e.substring(0,e.length-1)),e+pb+String.fromCodePoint(gb+t-1))}function Le(e){e.preventDefault(),e.stopPropagation()}function oo(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function lu(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function yb(e,t){const n=i=>{const s={};for(const o of i)typeof o.tone=="number"&&o.version<=t&&(s[o.tone]=o.unicode);return s};return e.map(({unicode:i,skins:s,shortcodes:o,url:a,name:r,category:u,annotation:c})=>({unicode:i,name:r,shortcodes:o,url:a,category:u,annotation:c,id:i||r,skins:s&&n(s)}))}const Ti=requestAnimationFrame;let vb=typeof ResizeObserver=="function";function bb(e,t,n){let i;vb?(i=new ResizeObserver(n),i.observe(e)):Ti(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function hl(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let ao;function wb(e,t,n){let i=!0,s=!1;for(const o of e){const a=n(o);if(!a)continue;const r=hl(a);r===0&&(s=!0),typeof ao>"u"&&(ao=hl(t));const u=r/1.8<ao;Wo.set(o.unicode,u),u||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
2917
+ `;fs([ss({type:Number})],Yt.prototype,"splitRatio",2);fs([ss({type:Number})],Yt.prototype,"minRatio",2);fs([ss({type:Number})],Yt.prototype,"maxRatio",2);Yt=fs([ql("resizable-divider")],Yt);function yi(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function to(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const gv=1,mv=1,Dt="emoji",Xt="keyvalue",Ia="favorites",yv="tokens",Gd="tokens",vv="unicode",Vd="count",bv="group",wv="order",Qd="group-order",No="eTag",Xi="url",rl="skinTone",ln="readonly",La="readwrite",Jd="skinUnicodes",kv="skinUnicodes",xv="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",$v="en";function Sv(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function ll(e){return Sv(e,t=>t.unicode)}function Av(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[a,[r,u]]of Object.entries(s))o.createIndex(a,r,{multiEntry:u});return o}t(Xt),t(Dt,vv,{[Gd]:[yv,!0],[Qd]:[[bv,wv]],[Jd]:[kv,!0]}),t(Ia,void 0,{[Vd]:[""]})}const Oo={},Ei={},Zi={};function Yd(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function Cv(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,gv);Oo[e]=s,s.onupgradeneeded=o=>{o.oldVersion<mv&&Av(s.result)},Yd(n,i,s)});return t.onclose=()=>Ra(e),t}function Ev(e){return Ei[e]||(Ei[e]=Cv(e)),Ei[e]}function Ze(e,t,n,i){return new Promise((s,o)=>{const a=e.transaction(t,n,{durability:"relaxed"}),r=typeof t=="string"?a.objectStore(t):t.map(c=>a.objectStore(c));let u;i(r,a,c=>{u=c}),a.oncomplete=()=>s(u),a.onerror=()=>o(a.error)})}function Ra(e){const t=Oo[e],n=t&&t.result;if(n){n.close();const i=Zi[e];if(i)for(const s of i)s()}delete Oo[e],delete Ei[e],delete Zi[e]}function Tv(e){return new Promise((t,n)=>{Ra(e);const i=indexedDB.deleteDatabase(e);Yd(t,n,i)})}function _v(e,t){let n=Zi[e];n||(n=Zi[e]=[]),n.push(t)}const Mv=new Set([":D","XD",":'D","O:)",":X",":P",";P","XP",":L",":Z",":j","8D","XO","8)",":B",":O",":S",":'o","Dx","X(","D:",":C",">0)",":3","</3","<3","\\M/",":E","8#"]);function Vt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||Mv.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const Pv=2;function Xd(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=Pv)}function Iv(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:a,skins:r,tags:u,emoji:c,version:h})=>{const d=[...new Set(Xd([...(a||[]).map(Vt).flat(),...(u||[]).map(Vt).flat(),...Vt(n),i]))].sort(),p={annotation:n,group:s,order:o,tags:u,tokens:d,unicode:c,version:h};if(i&&(p.emoticon=i),a&&(p.shortcodes=a),r){p.skinTones=[],p.skinUnicodes=[],p.skinVersions=[];for(const{tone:v,emoji:$,version:S}of r)p.skinTones.push(v),p.skinUnicodes.push($),p.skinVersions.push(S)}return p})}function Zd(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function Mt(e,t,n){Zd(e,"get",t,n)}function eu(e,t,n){Zd(e,"getAll",t,n)}function Da(e){e.commit&&e.commit()}function Lv(e,t){let n=e[0];for(let i=1;i<e.length;i++){const s=e[i];t(n)>t(s)&&(n=s)}return n}function tu(e,t){const n=Lv(e,s=>s.length),i=[];for(const s of n)e.some(o=>o.findIndex(a=>t(a)===t(s))===-1)||i.push(s);return i}async function Rv(e){return!await Ba(e,Xt,Xi)}async function Dv(e,t,n){const[i,s]=await Promise.all([No,Xi].map(o=>Ba(e,Xt,o)));return i===n&&s===t}async function Bv(e,t){return Ze(e,Dt,ln,(i,s,o)=>{let a;const r=()=>{i.getAll(a&&IDBKeyRange.lowerBound(a,!0),50).onsuccess=u=>{const c=u.target.result;for(const h of c)if(a=h.unicode,t(h))return o(h);if(c.length<50)return o();r()}};r()})}async function nu(e,t,n,i){{const s=Iv(t);await Ze(e,[Dt,Xt],La,([o,a],r)=>{let u,c,h=0;function d(){++h===2&&p()}function p(){if(!(u===i&&c===n)){o.clear();for(const v of s)o.put(v);a.put(i,No),a.put(n,Xi),Da(r)}}Mt(a,No,v=>{u=v,d()}),Mt(a,Xi,v=>{c=v,d()})})}}async function Nv(e,t){return Ze(e,Dt,ln,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);eu(n.index(Qd),o,s)})}async function iu(e,t){const n=Xd(Vt(t));return n.length?Ze(e,Dt,ln,(i,s,o)=>{const a=[],r=()=>{a.length===n.length&&u()},u=()=>{const c=tu(a,h=>h.unicode);o(c.sort((h,d)=>h.order<d.order?-1:1))};for(let c=0;c<n.length;c++){const h=n[c],d=c===n.length-1?IDBKeyRange.bound(h,h+"￿",!1,!0):IDBKeyRange.only(h);eu(i.index(Gd),d,p=>{a.push(p),r()})}}):[]}async function Ov(e,t){const n=await iu(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await Bv(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function Fv(e,t){return Ze(e,Dt,ln,(n,i,s)=>Mt(n,t,o=>{if(o)return s(o);Mt(n.index(Jd),t,a=>s(a||null))}))}function Ba(e,t,n){return Ze(e,t,ln,(i,s,o)=>Mt(i,n,o))}function Uv(e,t,n,i){return Ze(e,t,La,(s,o)=>{s.put(i,n),Da(o)})}function Wv(e,t){return Ze(e,Ia,La,(n,i)=>Mt(n,t,s=>{n.put((s||0)+1,t),Da(i)}))}function Kv(e,t,n){return n===0?[]:Ze(e,[Ia,Dt],ln,([i,s],o,a)=>{const r=[];i.index(Vd).openCursor(void 0,"prev").onsuccess=u=>{const c=u.target.result;if(!c)return a(r);function h(v){if(r.push(v),r.length===n)return a(r);c.continue()}const d=c.primaryKey,p=t.byName(d);if(p)return h(p);Mt(s,d,v=>{if(v)return h(v);c.continue()})}})}const vi="";function zv(e,t){const n=new Map;for(const s of e){const o=t(s);for(const a of o){let r=n;for(let c=0;c<a.length;c++){const h=a.charAt(c);let d=r.get(h);d||(d=new Map,r.set(h,d)),r=d}let u=r.get(vi);u||(u=[],r.set(vi,u)),u.push(s)}}return(s,o)=>{let a=n;for(let c=0;c<s.length;c++){const h=s.charAt(c),d=a.get(h);if(d)a=d;else return[]}if(o)return a.get(vi)||[];const r=[],u=[a];for(;u.length;){const h=[...u.shift().entries()].sort((d,p)=>d[0]<p[0]?-1:1);for(const[d,p]of h)d===vi?r.push(...p):u.push(p)}return r}}const Hv=["name","url"];function qv(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||Hv.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function cl(e){qv(e);const t=(p,v)=>p.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),s=zv(e,p=>{const v=new Set;if(p.shortcodes)for(const $ of p.shortcodes)for(const S of Vt($))v.add(S);return v}),o=p=>s(p,!0),a=p=>s(p,!1),r=p=>{const v=Vt(p),$=v.map((S,M)=>(M<v.length-1?o:a)(S));return tu($,S=>S.name).sort(t)},u=new Map,c=new Map;for(const p of e){c.set(p.name.toLowerCase(),p);for(const v of p.shortcodes||[])u.set(v.toLowerCase(),p)}return{all:n,search:r,byShortcode:p=>u.get(p.toLowerCase()),byName:p=>c.get(p.toLowerCase())}}const jv=typeof wrappedJSObject<"u";function $n(e){if(!e)return e;if(jv&&(e=structuredClone(e)),delete e.tokens,e.skinTones){const t=e.skinTones.length;e.skins=Array(t);for(let n=0;n<t;n++)e.skins[n]={tone:e.skinTones[n],unicode:e.skinUnicodes[n],version:e.skinVersions[n]};delete e.skinTones,delete e.skinUnicodes,delete e.skinVersions}return e}function su(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Gv=["annotation","emoji","group","order","version"];function Vv(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Gv.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function ou(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Qv(e){const t=await fetch(e,{method:"HEAD"});ou(t,e);const n=t.headers.get("etag");return su(n),n}async function Fo(e){const t=await fetch(e);ou(t,e);const n=t.headers.get("etag");su(n);const i=await t.json();return Vv(i),[n,i]}function Jv(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Yv(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),s=-1;++s<t;)i[s]=e.charCodeAt(s);return n}async function au(e){const t=JSON.stringify(e);let n=Yv(t);const i=await crypto.subtle.digest("SHA-1",n),s=Jv(i);return btoa(s)}async function Xv(e,t){let n,i=await Qv(t);if(!i){const s=await Fo(t);i=s[0],n=s[1],i||(i=await au(n))}await Dv(e,t,i)||(n||(n=(await Fo(t))[1]),await nu(e,n,t,i))}async function Zv(e,t){let[n,i]=await Fo(t);n||(n=await au(i)),await nu(e,i,t,n)}async function eb(e,t){try{await Xv(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class tb{constructor({dataSource:t=xv,locale:n=$v,customEmoji:i=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=cl(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await Ev(this._dbName);_v(this._dbName,this._clear);const n=this.dataSource;await Rv(t)?await Zv(t,n):this._lazyUpdate=eb(t,n)}async ready(){const t=async()=>(this._ready||(this._ready=this._init()),this._ready);await t(),this._db||await t()}async getEmojiByGroup(t){return to(t),await this.ready(),ll(await Nv(this._db,t)).map($n)}async getEmojiBySearchQuery(t){yi(t),await this.ready();const n=this._custom.search(t),i=ll(await iu(this._db,t)).map($n);return[...n,...i]}async getEmojiByShortcode(t){yi(t),await this.ready();const n=this._custom.byShortcode(t);return n||$n(await Ov(this._db,t))}async getEmojiByUnicodeOrName(t){yi(t),await this.ready();const n=this._custom.byName(t);return n||$n(await Fv(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Ba(this._db,Xt,rl)||0}async setPreferredSkinTone(t){return to(t),await this.ready(),Uv(this._db,Xt,rl,t)}async incrementFavoriteEmojiCount(t){return yi(t),await this.ready(),Wv(this._db,t)}async getTopFavoriteEmoji(t){return to(t),await this.ready(),(await Kv(this._db,this._custom,t)).map($n)}set customEmoji(t){this._custom=cl(t)}get customEmoji(){return this._custom.all}async _shutdown(){await this.ready();try{await this._lazyUpdate}catch{}}_clear(){this._db=this._ready=this._lazyUpdate=void 0}async close(){await this._shutdown(),await Ra(this._dbName)}async delete(){await this._shutdown(),await Tv(this._dbName)}}const Uo=[[-1,"✨","custom"],[0,"😀","smileys-emotion"],[1,"👋","people-body"],[3,"🐱","animals-nature"],[4,"🍎","food-drink"],[5,"🏠️","travel-places"],[6,"⚽","activities"],[7,"📝","objects"],[8,"⛔️","symbols"],[9,"🏁","flags"]].map(([e,t,n])=>({id:e,emoji:t,name:n})),no=Uo.slice(1),nb=2,dl=6,ru=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function ul(e){return e.unicode.includes("‍")}const ib={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},sb=1e3,ob="🖐️",ab=8,rb=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],lu='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',lb=(e,t)=>e<t?-1:e>t?1:0,pl=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const i=n.getContext("2d",{willReadFrequently:!0});return i.textBaseline="top",i.font=`100px ${lu}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},cb=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function db(e){const t=pl(e,"#000"),n=pl(e,"#fff");return t&&n&&cb(t,n)}function ub(){const e=Object.entries(ib);try{for(const[t,n]of e)if(db(t))return n}catch{}return e[0][1]}let io;const so=()=>(io||(io=new Promise(e=>ru(()=>e(ub())))),io),Wo=new Map,pb="️",hb="\uD83C",fb="‍",gb=127995,mb=57339;function yb(e,t){if(t===0)return e;const n=e.indexOf(fb);return n!==-1?e.substring(0,n)+String.fromCodePoint(gb+t-1)+e.substring(n):(e.endsWith(pb)&&(e=e.substring(0,e.length-1)),e+hb+String.fromCodePoint(mb+t-1))}function Re(e){e.preventDefault(),e.stopPropagation()}function oo(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function cu(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function vb(e,t){const n=i=>{const s={};for(const o of i)typeof o.tone=="number"&&o.version<=t&&(s[o.tone]=o.unicode);return s};return e.map(({unicode:i,skins:s,shortcodes:o,url:a,name:r,category:u,annotation:c})=>({unicode:i,name:r,shortcodes:o,url:a,category:u,annotation:c,id:i||r,skins:s&&n(s)}))}const Ti=requestAnimationFrame;let bb=typeof ResizeObserver=="function";function wb(e,t,n){let i;bb?(i=new ResizeObserver(n),i.observe(e)):Ti(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function hl(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let ao;function kb(e,t,n){let i=!0,s=!1;for(const o of e){const a=n(o);if(!a)continue;const r=hl(a);r===0&&(s=!0),typeof ao>"u"&&(ao=hl(t));const u=r/1.8<ao;Wo.set(o.unicode,u),u||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
2918
2918
  This is likely due to using \`display:none\` which is unsupported.
2919
2919
  If this is a Jest/Vitest environment, you can ignore this warning.
2920
- For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function kb(e){return lu(e,t=>t)}function xb(e){e&&(e.scrollTop=0)}function Dn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function fl(e){return""+e}function $b(e){const t=document.createElement("template");return t.innerHTML=e,t}const Sb=new WeakMap,Ab=new WeakMap,Cb=Symbol("un-keyed"),Eb="replaceChildren"in Element.prototype;function Tb(e,t){Eb?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function _b(e,t){let n=e.firstChild,i=0;for(;n;){if(t[i]!==n)return!0;n=n.nextSibling,i++}return i!==t.length}function Mb(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=_b(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&Tb(i,e)}function Pb(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:a,attributeValuePre:r,attributeValuePost:u}}=n,c=e[o];if(s!==c)if(n.currentExpression=c,a)if(c===null)i.removeAttribute(a);else{const h=r+fl(c)+u;i.setAttribute(a,h)}else{let h;Array.isArray(c)?Mb(c,n):c instanceof Element?(h=c,i.replaceWith(h)):i.nodeValue=fl(c),h&&(n.targetNode=h)}}}function Ib(e){let t="",n=!1,i=!1,s=-1;const o=new Map,a=[];let r=0;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(t+=d.slice(r),c===h-1)break;for(let b=0;b<d.length;b++)switch(d.charAt(b)){case"<":{d.charAt(b+1)==="/"?a.pop():(n=!0,a.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const p=a[a.length-1],v=Dn(o,p,()=>[]);let $,S,M;if(i){const b=/(\S+)="?([^"=]*)$/.exec(d);$=b[1],S=b[2];const k=/^([^">]*)("?)/.exec(e[c+1]);M=k[1],t=t.slice(0,-1*b[0].length),r=k[0].length}else r=0;const y={attributeName:$,attributeValuePre:S,attributeValuePost:M,expressionIndex:c};v.push(y),!n&&!i&&(t+=" ")}return{template:$b(t),elementsToBindings:o}}function gl(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,a={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(a)}}function Lb(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))gl(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,a=-1;do{const r=t.get(++a);r&&gl(r,o,n)}while(o=s.nextNode())}return n}function Rb(e){const{template:t,elementsToBindings:n}=Dn(Sb,e,()=>Ib(e)),i=t.cloneNode(!0).content.firstElementChild,s=Lb(i,n);return function(a){return Pb(a,s),i}}function Db(e){const t=Dn(Ab,e,()=>new Map);let n=Cb;function i(o,...a){const r=Dn(t,o,()=>new Map);return Dn(r,n,()=>Rb(o))(a)}function s(o,a,r){return o.map((u,c)=>{const h=n;n=r(u);try{return a(u,c)}finally{n=h}})}return{map:s,html:i}}function Bb(e,t,n,i,s,o,a,r,u){const{labelWithSkin:c,titleForEmoji:h,unicodeWithSkin:d}=n,{html:p,map:v}=Db(t);function $(b,k,A){return v(b,(E,T)=>p`<button role="${k?"option":"menuitem"}" aria-selected="${k?T===t.activeSearchItem:null}" aria-label="${c(E,t.currentSkinTone)}" title="${h(E)}" class="${"emoji"+(k&&T===t.activeSearchItem?" active":"")+(E.unicode?"":" custom-emoji")}" id="${`${A}-${E.id}`}" style="${E.unicode?null:`--custom-emoji-background: url(${JSON.stringify(E.url)})`}">${E.unicode?d(E,t.currentSkinTone):""}</button>`,E=>`${A}-${E.id}`)}const M=p`<section data-ref="rootElement" class="picker" aria-label="${t.i18n.regionLabel}" style="${t.pickerStyle||""}"><div class="pad-top"></div><div class="search-row"><div class="search-wrapper"><input id="search" class="search" type="search" role="combobox" enterkeyhint="search" placeholder="${t.i18n.searchLabel}" autocapitalize="none" autocomplete="off" spellcheck="true" aria-expanded="${!!(t.searchMode&&t.currentEmojis.length)}" aria-controls="search-results" aria-describedby="search-description" aria-autocomplete="list" aria-activedescendant="${t.activeSearchItemId?`emo-${t.activeSearchItemId}`:null}" data-ref="searchElement" data-on-input="onSearchInput" data-on-keydown="onSearchKeydown"><label class="sr-only" for="search">${t.i18n.searchLabel}</label> <span id="search-description" class="sr-only">${t.i18n.searchDescription}</span></div><div class="skintone-button-wrapper ${t.skinTonePickerExpandedAfterAnimation?"expanded":""}"><button id="skintone-button" class="emoji ${t.skinTonePickerExpanded?"hide-focus":""}" aria-label="${t.skinToneButtonLabel}" title="${t.skinToneButtonLabel}" aria-describedby="skintone-description" aria-haspopup="listbox" aria-expanded="${t.skinTonePickerExpanded}" aria-controls="skintone-list" data-on-click="onClickSkinToneButton">${t.skinToneButtonText||""}</button></div><span id="skintone-description" class="sr-only">${t.i18n.skinToneDescription}</span><div data-ref="skinToneDropdown" id="skintone-list" class="skintone-list hide-focus ${t.skinTonePickerExpanded?"":"hidden no-animate"}" style="transform:translateY(${t.skinTonePickerExpanded?0:"calc(-1 * var(--num-skintones) * var(--total-emoji-size))"})" role="listbox" aria-label="${t.i18n.skinTonesLabel}" aria-activedescendant="skintone-${t.activeSkinTone}" aria-hidden="${!t.skinTonePickerExpanded}" tabIndex="-1" data-on-focusout="onSkinToneOptionsFocusOut" data-on-click="onSkinToneOptionsClick" data-on-keydown="onSkinToneOptionsKeydown" data-on-keyup="onSkinToneOptionsKeyup">${v(t.skinTones,(b,k)=>p`<div id="skintone-${k}" class="emoji ${k===t.activeSkinTone?"active":""}" aria-selected="${k===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[k]}" aria-label="${t.i18n.skinTones[k]}">${b}</div>`,b=>b)}</div></div><div class="nav" role="tablist" style="grid-template-columns:repeat(${t.groups.length},1fr)" aria-label="${t.i18n.categoriesLabel}" data-on-keydown="onNavKeydown" data-on-click="onNavClick">${v(t.groups,b=>p`<button role="tab" class="nav-button" aria-controls="tab-${b.id}" aria-label="${t.i18n.categories[b.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===b.id}" title="${t.i18n.categories[b.name]}" data-group-id="${b.id}"><div class="nav-emoji emoji">${b.emoji}</div></button>`,b=>b.id)}</div><div class="indicator-wrapper"><div class="indicator" style="transform:translateX(${(t.isRtl?-1:1)*t.currentGroupIndex*100}%)"></div></div><div class="message ${t.message?"":"gone"}" role="alert" aria-live="polite">${t.message||""}</div><div data-ref="tabpanelElement" class="tabpanel ${!t.databaseLoaded||t.message?"gone":""}" role="${t.searchMode?"region":"tabpanel"}" aria-label="${t.searchMode?t.i18n.searchResultsLabel:t.i18n.categories[t.currentGroup.name]}" id="${t.searchMode?null:`tab-${t.currentGroup.id}`}" tabIndex="0" data-on-click="onEmojiClick"><div data-action="calculateEmojiGridStyle">${v(t.currentEmojisWithCategories,(b,k)=>p`<div><div id="menu-label-${k}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:b.category?b.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${k!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(b.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${k}" id="${t.searchMode?"search-results":null}">${$(b.emojis,t.searchMode,"emo")}</div></div>`,b=>b.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${$(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,y=(b,k)=>{for(const A of e.querySelectorAll(`[${b}]`))k(A,A.getAttribute(b))};if(u){e.appendChild(M);for(const b of["click","focusout","input","keydown","keyup"])y(`data-on-${b}`,(k,A)=>{k.addEventListener(b,i[A])});y("data-ref",(b,k)=>{o[k]=b}),a.addEventListener("abort",()=>{e.removeChild(M)})}y("data-action",(b,k)=>{let A=r.get(k);A||r.set(k,A=new WeakSet),A.has(b)||(A.add(b),s[k](b))})}const es=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Nb(e){let t=!1,n;const i=new Map,s=new Set;let o;const a=()=>{if(t)return;const c=[...s];s.clear();try{for(const h of c)h()}finally{o=!1,s.size&&(o=!0,es(a))}},r=new Proxy({},{get(c,h){if(n){let d=i.get(h);d||(d=new Set,i.set(h,d)),d.add(n)}return c[h]},set(c,h,d){if(c[h]!==d){c[h]=d;const p=i.get(h);if(p){for(const v of p)s.add(v);o||(o=!0,es(a))}}return!0}}),u=c=>{const h=()=>{const d=n;n=h;try{return c()}finally{n=d}};return h()};return e.addEventListener("abort",()=>{t=!0}),{state:r,createEffect:u}}function ro(e,t,n){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}const ml=new WeakMap;function Ob(e,t,n){{const i=e.closest(".tabpanel");let s=ml.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),ml.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const lo=[],{assign:bi}=Object;function Fb(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:a}=Nb(s),r=new Map;bi(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),bi(o,t),bi(o,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:ob,isRtl:!1,currentGroupIndex:0,groups:no,databaseLoaded:!1,activeSearchItemId:void 0}),a(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const u=C=>{e.getElementById(C).focus()},c=C=>e.getElementById(`emo-${C.id}`),h=(C,I)=>{n.rootElement.dispatchEvent(new CustomEvent(C,{detail:I,bubbles:!0,composed:!0}))},d=(C,I)=>C.id===I.id,p=(C,I)=>{const{category:F,emojis:U}=C,{category:Z,emojis:J}=I;return F!==Z?!1:ro(U,J,d)},v=C=>{ro(o.currentEmojis,C,d)||(o.currentEmojis=C)},$=C=>{o.searchMode!==C&&(o.searchMode=C)},S=C=>{ro(o.currentEmojisWithCategories,C,p)||(o.currentEmojisWithCategories=C)},M=(C,I)=>I&&C.skins&&C.skins[I]||C.unicode,k={labelWithSkin:(C,I)=>kb([C.name||M(C,I),C.annotation,...C.shortcodes||lo].filter(Boolean)).join(", "),titleForEmoji:C=>C.annotation||(C.shortcodes||lo).join(", "),unicodeWithSkin:M},A={onClickSkinToneButton:X,onEmojiClick:Yn,onNavClick:Qn,onNavKeydown:ks,onSearchKeydown:ws,onSkinToneOptionsClick:Xn,onSkinToneOptionsFocusOut:Ze,onSkinToneOptionsKeydown:dt,onSkinToneOptionsKeyup:dn,onSearchInput:Zn},E={calculateEmojiGridStyle:D,updateOnIntersection:W};let T=!0;a(()=>{Bb(e,o,k,A,E,n,s,r,T),T=!1}),o.emojiVersion||so().then(C=>{C||(o.message=o.i18n.emojiUnsupportedMessage)}),a(()=>{async function C(){let I=!1;const F=setTimeout(()=>{I=!0,o.message=o.i18n.loadingMessage},ib);try{await o.database.ready(),o.databaseLoaded=!0}catch(U){console.error(U),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(F),I&&(I=!1,o.message="")}}o.database&&C()}),a(()=>{o.pickerStyle=`
2920
+ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function xb(e){return cu(e,t=>t)}function $b(e){e&&(e.scrollTop=0)}function Dn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function fl(e){return""+e}function Sb(e){const t=document.createElement("template");return t.innerHTML=e,t}const Ab=new WeakMap,Cb=new WeakMap,Eb=Symbol("un-keyed"),Tb="replaceChildren"in Element.prototype;function _b(e,t){Tb?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function Mb(e,t){let n=e.firstChild,i=0;for(;n;){if(t[i]!==n)return!0;n=n.nextSibling,i++}return i!==t.length}function Pb(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=Mb(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&_b(i,e)}function Ib(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:a,attributeValuePre:r,attributeValuePost:u}}=n,c=e[o];if(s!==c)if(n.currentExpression=c,a)if(c===null)i.removeAttribute(a);else{const h=r+fl(c)+u;i.setAttribute(a,h)}else{let h;Array.isArray(c)?Pb(c,n):c instanceof Element?(h=c,i.replaceWith(h)):i.nodeValue=fl(c),h&&(n.targetNode=h)}}}function Lb(e){let t="",n=!1,i=!1,s=-1;const o=new Map,a=[];let r=0;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(t+=d.slice(r),c===h-1)break;for(let b=0;b<d.length;b++)switch(d.charAt(b)){case"<":{d.charAt(b+1)==="/"?a.pop():(n=!0,a.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const p=a[a.length-1],v=Dn(o,p,()=>[]);let $,S,M;if(i){const b=/(\S+)="?([^"=]*)$/.exec(d);$=b[1],S=b[2];const k=/^([^">]*)("?)/.exec(e[c+1]);M=k[1],t=t.slice(0,-1*b[0].length),r=k[0].length}else r=0;const y={attributeName:$,attributeValuePre:S,attributeValuePost:M,expressionIndex:c};v.push(y),!n&&!i&&(t+=" ")}return{template:Sb(t),elementsToBindings:o}}function gl(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,a={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(a)}}function Rb(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))gl(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,a=-1;do{const r=t.get(++a);r&&gl(r,o,n)}while(o=s.nextNode())}return n}function Db(e){const{template:t,elementsToBindings:n}=Dn(Ab,e,()=>Lb(e)),i=t.cloneNode(!0).content.firstElementChild,s=Rb(i,n);return function(a){return Ib(a,s),i}}function Bb(e){const t=Dn(Cb,e,()=>new Map);let n=Eb;function i(o,...a){const r=Dn(t,o,()=>new Map);return Dn(r,n,()=>Db(o))(a)}function s(o,a,r){return o.map((u,c)=>{const h=n;n=r(u);try{return a(u,c)}finally{n=h}})}return{map:s,html:i}}function Nb(e,t,n,i,s,o,a,r,u){const{labelWithSkin:c,titleForEmoji:h,unicodeWithSkin:d}=n,{html:p,map:v}=Bb(t);function $(b,k,A){return v(b,(E,T)=>p`<button role="${k?"option":"menuitem"}" aria-selected="${k?T===t.activeSearchItem:null}" aria-label="${c(E,t.currentSkinTone)}" title="${h(E)}" class="${"emoji"+(k&&T===t.activeSearchItem?" active":"")+(E.unicode?"":" custom-emoji")}" id="${`${A}-${E.id}`}" style="${E.unicode?null:`--custom-emoji-background: url(${JSON.stringify(E.url)})`}">${E.unicode?d(E,t.currentSkinTone):""}</button>`,E=>`${A}-${E.id}`)}const M=p`<section data-ref="rootElement" class="picker" aria-label="${t.i18n.regionLabel}" style="${t.pickerStyle||""}"><div class="pad-top"></div><div class="search-row"><div class="search-wrapper"><input id="search" class="search" type="search" role="combobox" enterkeyhint="search" placeholder="${t.i18n.searchLabel}" autocapitalize="none" autocomplete="off" spellcheck="true" aria-expanded="${!!(t.searchMode&&t.currentEmojis.length)}" aria-controls="search-results" aria-describedby="search-description" aria-autocomplete="list" aria-activedescendant="${t.activeSearchItemId?`emo-${t.activeSearchItemId}`:null}" data-ref="searchElement" data-on-input="onSearchInput" data-on-keydown="onSearchKeydown"><label class="sr-only" for="search">${t.i18n.searchLabel}</label> <span id="search-description" class="sr-only">${t.i18n.searchDescription}</span></div><div class="skintone-button-wrapper ${t.skinTonePickerExpandedAfterAnimation?"expanded":""}"><button id="skintone-button" class="emoji ${t.skinTonePickerExpanded?"hide-focus":""}" aria-label="${t.skinToneButtonLabel}" title="${t.skinToneButtonLabel}" aria-describedby="skintone-description" aria-haspopup="listbox" aria-expanded="${t.skinTonePickerExpanded}" aria-controls="skintone-list" data-on-click="onClickSkinToneButton">${t.skinToneButtonText||""}</button></div><span id="skintone-description" class="sr-only">${t.i18n.skinToneDescription}</span><div data-ref="skinToneDropdown" id="skintone-list" class="skintone-list hide-focus ${t.skinTonePickerExpanded?"":"hidden no-animate"}" style="transform:translateY(${t.skinTonePickerExpanded?0:"calc(-1 * var(--num-skintones) * var(--total-emoji-size))"})" role="listbox" aria-label="${t.i18n.skinTonesLabel}" aria-activedescendant="skintone-${t.activeSkinTone}" aria-hidden="${!t.skinTonePickerExpanded}" tabIndex="-1" data-on-focusout="onSkinToneOptionsFocusOut" data-on-click="onSkinToneOptionsClick" data-on-keydown="onSkinToneOptionsKeydown" data-on-keyup="onSkinToneOptionsKeyup">${v(t.skinTones,(b,k)=>p`<div id="skintone-${k}" class="emoji ${k===t.activeSkinTone?"active":""}" aria-selected="${k===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[k]}" aria-label="${t.i18n.skinTones[k]}">${b}</div>`,b=>b)}</div></div><div class="nav" role="tablist" style="grid-template-columns:repeat(${t.groups.length},1fr)" aria-label="${t.i18n.categoriesLabel}" data-on-keydown="onNavKeydown" data-on-click="onNavClick">${v(t.groups,b=>p`<button role="tab" class="nav-button" aria-controls="tab-${b.id}" aria-label="${t.i18n.categories[b.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===b.id}" title="${t.i18n.categories[b.name]}" data-group-id="${b.id}"><div class="nav-emoji emoji">${b.emoji}</div></button>`,b=>b.id)}</div><div class="indicator-wrapper"><div class="indicator" style="transform:translateX(${(t.isRtl?-1:1)*t.currentGroupIndex*100}%)"></div></div><div class="message ${t.message?"":"gone"}" role="alert" aria-live="polite">${t.message||""}</div><div data-ref="tabpanelElement" class="tabpanel ${!t.databaseLoaded||t.message?"gone":""}" role="${t.searchMode?"region":"tabpanel"}" aria-label="${t.searchMode?t.i18n.searchResultsLabel:t.i18n.categories[t.currentGroup.name]}" id="${t.searchMode?null:`tab-${t.currentGroup.id}`}" tabIndex="0" data-on-click="onEmojiClick"><div data-action="calculateEmojiGridStyle">${v(t.currentEmojisWithCategories,(b,k)=>p`<div><div id="menu-label-${k}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:b.category?b.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${k!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(b.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${k}" id="${t.searchMode?"search-results":null}">${$(b.emojis,t.searchMode,"emo")}</div></div>`,b=>b.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${$(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,y=(b,k)=>{for(const A of e.querySelectorAll(`[${b}]`))k(A,A.getAttribute(b))};if(u){e.appendChild(M);for(const b of["click","focusout","input","keydown","keyup"])y(`data-on-${b}`,(k,A)=>{k.addEventListener(b,i[A])});y("data-ref",(b,k)=>{o[k]=b}),a.addEventListener("abort",()=>{e.removeChild(M)})}y("data-action",(b,k)=>{let A=r.get(k);A||r.set(k,A=new WeakSet),A.has(b)||(A.add(b),s[k](b))})}const es=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Ob(e){let t=!1,n;const i=new Map,s=new Set;let o;const a=()=>{if(t)return;const c=[...s];s.clear();try{for(const h of c)h()}finally{o=!1,s.size&&(o=!0,es(a))}},r=new Proxy({},{get(c,h){if(n){let d=i.get(h);d||(d=new Set,i.set(h,d)),d.add(n)}return c[h]},set(c,h,d){if(c[h]!==d){c[h]=d;const p=i.get(h);if(p){for(const v of p)s.add(v);o||(o=!0,es(a))}}return!0}}),u=c=>{const h=()=>{const d=n;n=h;try{return c()}finally{n=d}};return h()};return e.addEventListener("abort",()=>{t=!0}),{state:r,createEffect:u}}function ro(e,t,n){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}const ml=new WeakMap;function Fb(e,t,n){{const i=e.closest(".tabpanel");let s=ml.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),ml.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const lo=[],{assign:bi}=Object;function Ub(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:a}=Ob(s),r=new Map;bi(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),bi(o,t),bi(o,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:ab,isRtl:!1,currentGroupIndex:0,groups:no,databaseLoaded:!1,activeSearchItemId:void 0}),a(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const u=C=>{e.getElementById(C).focus()},c=C=>e.getElementById(`emo-${C.id}`),h=(C,I)=>{n.rootElement.dispatchEvent(new CustomEvent(C,{detail:I,bubbles:!0,composed:!0}))},d=(C,I)=>C.id===I.id,p=(C,I)=>{const{category:F,emojis:U}=C,{category:Z,emojis:J}=I;return F!==Z?!1:ro(U,J,d)},v=C=>{ro(o.currentEmojis,C,d)||(o.currentEmojis=C)},$=C=>{o.searchMode!==C&&(o.searchMode=C)},S=C=>{ro(o.currentEmojisWithCategories,C,p)||(o.currentEmojisWithCategories=C)},M=(C,I)=>I&&C.skins&&C.skins[I]||C.unicode,k={labelWithSkin:(C,I)=>xb([C.name||M(C,I),C.annotation,...C.shortcodes||lo].filter(Boolean)).join(", "),titleForEmoji:C=>C.annotation||(C.shortcodes||lo).join(", "),unicodeWithSkin:M},A={onClickSkinToneButton:X,onEmojiClick:Yn,onNavClick:Qn,onNavKeydown:ks,onSearchKeydown:ws,onSkinToneOptionsClick:Xn,onSkinToneOptionsFocusOut:et,onSkinToneOptionsKeydown:dt,onSkinToneOptionsKeyup:dn,onSearchInput:Zn},E={calculateEmojiGridStyle:D,updateOnIntersection:W};let T=!0;a(()=>{Nb(e,o,k,A,E,n,s,r,T),T=!1}),o.emojiVersion||so().then(C=>{C||(o.message=o.i18n.emojiUnsupportedMessage)}),a(()=>{async function C(){let I=!1;const F=setTimeout(()=>{I=!0,o.message=o.i18n.loadingMessage},sb);try{await o.database.ready(),o.databaseLoaded=!0}catch(U){console.error(U),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(F),I&&(I=!1,o.message="")}}o.database&&C()}),a(()=>{o.pickerStyle=`
2921
2921
  --num-groups: ${o.groups.length};
2922
2922
  --indicator-opacity: ${o.searchMode?0:1};
2923
- --num-skintones: ${dl};`}),a(()=>{o.customEmoji&&o.database&&P()}),a(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Uo&&(o.groups=Uo):o.groups!==no&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=no)}),a(()=>{async function C(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}C()}),a(()=>{o.skinTones=Array(dl).fill().map((C,I)=>mb(o.skinToneEmoji,I))}),a(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),a(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),a(()=>{async function C(){const{database:I}=o,F=(await Promise.all(ab.map(U=>I.getEmojiByUnicodeOrName(U)))).filter(Boolean);o.defaultFavoriteEmojis=F}o.databaseLoaded&&C()});function P(){const{customEmoji:C,database:I}=o,F=C||lo;I.customEmoji!==F&&(I.customEmoji=F)}a(()=>{async function C(){P();const{database:I,defaultFavoriteEmojis:F,numColumns:U}=o,Z=await I.getTopFavoriteEmoji(U),J=await Ue(lu([...Z,...F],he=>he.unicode||he.name).slice(0,U));o.currentFavorites=J}o.databaseLoaded&&o.defaultFavoriteEmojis&&C()});function D(C){bb(C,s,()=>{{const I=getComputedStyle(n.rootElement),F=parseInt(I.getPropertyValue("--num-columns"),10),U=I.getPropertyValue("direction")==="rtl";o.numColumns=F,o.isRtl=U}})}function W(C){Ob(C,s,I=>{for(const{target:F,isIntersecting:U}of I)F.classList.toggle("onscreen",U)})}a(()=>{async function C(){const{searchText:I,currentGroup:F,databaseLoaded:U,customEmoji:Z}=o;if(!U)o.currentEmojis=[],o.searchMode=!1;else if(I.length>=tb){const J=await bs(I);o.searchText===I&&(v(J),$(!0))}else{const{id:J}=F;if(J!==-1||Z&&Z.length){const he=await vs(J);o.currentGroup.id===J&&(v(he),$(!1))}}}C()});const z=()=>{Ti(()=>xb(n.tabpanelElement))};a(()=>{const{currentEmojis:C,emojiVersion:I}=o,F=C.filter(U=>U.unicode).filter(U=>ul(U)&&!Wo.has(U.unicode));if(!I&&F.length)v(C),Ti(()=>H(F));else{const U=I?C:C.filter(ke);v(U),z()}});function H(C){wb(C,n.baselineEmoji,c)?z():o.currentEmojis=[...o.currentEmojis]}function ke(C){return!C.unicode||!ul(C)||Wo.get(C.unicode)}async function _e(C){const I=o.emojiVersion||await so();return C.filter(({version:F})=>!F||F<=I)}async function Ue(C){return yb(C,o.emojiVersion||await so())}async function vs(C){const I=C===-1?o.customEmoji:await o.database.getEmojiByGroup(C);return Ue(await _e(I))}async function bs(C){return Ue(await _e(await o.database.getEmojiBySearchQuery(C)))}a(()=>{}),a(()=>{function C(){const{searchMode:F,currentEmojis:U}=o;if(F)return[{category:"",emojis:U}];const Z=new Map;for(const J of U){const he=J.category||"";let et=Z.get(he);et||(et=[],Z.set(he,et)),et.push(J)}return[...Z.entries()].map(([J,he])=>({category:J,emojis:he})).sort((J,he)=>o.customCategorySorting(J.category,he.category))}const I=C();S(I)}),a(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),a(()=>{const{rawSearchText:C}=o;au(()=>{o.searchText=(C||"").trim(),o.activeSearchItem=-1})});function ws(C){if(!o.searchMode||!o.currentEmojis.length)return;const I=F=>{Le(C),o.activeSearchItem=oo(F,o.activeSearchItem,o.currentEmojis)};switch(C.key){case"ArrowDown":return I(!1);case"ArrowUp":return I(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Le(C),te(o.currentEmojis[o.activeSearchItem].id)}}function Qn(C){const{target:I}=C,F=I.closest(".nav-button");if(!F)return;const U=parseInt(F.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(Z=>Z.id===U)}function ks(C){const{target:I,key:F}=C,U=Z=>{Z&&(Le(C),Z.focus())};switch(F){case"ArrowLeft":return U(I.previousElementSibling);case"ArrowRight":return U(I.nextElementSibling);case"Home":return U(I.parentElement.firstElementChild);case"End":return U(I.parentElement.lastElementChild)}}async function Jn(C){const I=await o.database.getEmojiByUnicodeOrName(C),F=[...o.currentEmojis,...o.currentFavorites].find(Z=>Z.id===C),U=F.unicode&&M(F,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(C),{emoji:I,skinTone:o.currentSkinTone,...U&&{unicode:U},...F.name&&{name:F.name}}}async function te(C){const I=Jn(C);h("emoji-click-sync",I),h("emoji-click",await I)}function Yn(C){const{target:I}=C;if(!I.classList.contains("emoji"))return;Le(C);const F=I.id.substring(4);te(F)}function ne(C){o.currentSkinTone=C,o.skinTonePickerExpanded=!1,u("skintone-button"),h("skin-tone-change",{skinTone:C}),o.database.setPreferredSkinTone(C)}function Xn(C){const{target:{id:I}}=C,F=I&&I.match(/^skintone-(\d)/);if(!F)return;Le(C);const U=parseInt(F[1],10);ne(U)}function X(C){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Le(C),Ti(()=>u("skintone-list")))}a(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function dt(C){if(!o.skinTonePickerExpanded)return;const I=async F=>{Le(C),o.activeSkinTone=F};switch(C.key){case"ArrowUp":return I(oo(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return I(oo(!1,o.activeSkinTone,o.skinTones));case"Home":return I(0);case"End":return I(o.skinTones.length-1);case"Enter":return Le(C),ne(o.activeSkinTone);case"Escape":return Le(C),o.skinTonePickerExpanded=!1,u("skintone-button")}}function dn(C){if(o.skinTonePickerExpanded&&C.key===" ")return Le(C),ne(o.activeSkinTone)}async function Ze(C){const{relatedTarget:I}=C;(!I||I.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function Zn(C){o.rawSearchText=C.target.value}return{$set(C){bi(o,C)},$destroy(){i.abort()}}}const Ub="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Wb="en";var Kb={categoriesLabel:"Categories",emojiUnsupportedMessage:"Your browser does not support color emoji.",favoritesLabel:"Favorites",loadingMessage:"Loading…",networkErrorMessage:"Could not load emoji.",regionLabel:"Emoji picker",searchDescription:"When search results are available, press up or down to select and enter to choose.",searchLabel:"Search",searchResultsLabel:"Search results",skinToneDescription:"When expanded, press up or down to select and enter to choose.",skinToneLabel:"Choose a skin tone (currently {skinTone})",skinTonesLabel:"Skin tones",skinTones:["Default","Light","Medium-Light","Medium","Medium-Dark","Dark"],categories:{custom:"Custom","smileys-emotion":"Smileys and emoticons","people-body":"People and body","animals-nature":"Animals and nature","food-drink":"Food and drink","travel-places":"Travel and places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"}},zb=':host{--emoji-size:1.375rem;--emoji-padding:0.5rem;--category-emoji-size:var(--emoji-size);--category-emoji-padding:var(--emoji-padding);--indicator-height:3px;--input-border-radius:0.5rem;--input-border-size:1px;--input-font-size:1rem;--input-line-height:1.5;--input-padding:0.25rem;--num-columns:8;--outline-size:2px;--border-size:1px;--border-radius:0;--skintone-border-radius:1rem;--category-font-size:1rem;display:flex;width:min-content;height:400px}:host,:host(.light){color-scheme:light;--background:#fff;--border-color:#e0e0e0;--indicator-color:#385ac1;--input-border-color:#999;--input-font-color:#111;--input-placeholder-color:#999;--outline-color:#999;--category-font-color:#111;--button-active-background:#e6e6e6;--button-hover-background:#d9d9d9}:host(.dark){color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}@media (prefers-color-scheme:dark){:host{color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}}:host([hidden]){display:none}button{margin:0;padding:0;border:0;background:0 0;box-shadow:none;-webkit-tap-highlight-color:transparent}button::-moz-focus-inner{border:0}input{padding:0;margin:0;line-height:1.15;font-family:inherit}input[type=search]{-webkit-appearance:none}:focus{outline:var(--outline-color) solid var(--outline-size);outline-offset:calc(-1*var(--outline-size))}:host([data-js-focus-visible]) :focus:not([data-focus-visible-added]){outline:0}:focus:not(:focus-visible){outline:0}.hide-focus{outline:0}*{box-sizing:border-box}.picker{contain:content;display:flex;flex-direction:column;background:var(--background);border:var(--border-size) solid var(--border-color);border-radius:var(--border-radius);width:100%;height:100%;overflow:hidden;--total-emoji-size:calc(var(--emoji-size) + (2 * var(--emoji-padding)));--total-category-emoji-size:calc(var(--category-emoji-size) + (2 * var(--category-emoji-padding)))}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.hidden{opacity:0;pointer-events:none}.abs-pos{position:absolute;left:0;top:0}.gone{display:none!important}.skintone-button-wrapper,.skintone-list{background:var(--background);z-index:3}.skintone-button-wrapper.expanded{z-index:1}.skintone-list{position:absolute;inset-inline-end:0;top:0;z-index:2;overflow:visible;border-bottom:var(--border-size) solid var(--border-color);border-radius:0 0 var(--skintone-border-radius) var(--skintone-border-radius);will-change:transform;transition:transform .2s ease-in-out;transform-origin:center 0}@media (prefers-reduced-motion:reduce){.skintone-list{transition-duration:.001s}}@supports not (inset-inline-end:0){.skintone-list{right:0}}.skintone-list.no-animate{transition:none}.tabpanel{overflow-y:auto;scrollbar-gutter:stable;-webkit-overflow-scrolling:touch;will-change:transform;min-height:0;flex:1;contain:content}.emoji-menu{display:grid;grid-template-columns:repeat(var(--num-columns),var(--total-emoji-size));justify-content:space-around;align-items:flex-start;width:100%}.emoji-menu.visibility-auto{content-visibility:auto;contain-intrinsic-size:calc(var(--num-columns)*var(--total-emoji-size)) calc(var(--num-rows)*var(--total-emoji-size))}.category{padding:var(--emoji-padding);font-size:var(--category-font-size);color:var(--category-font-color)}.emoji,button.emoji{font-size:var(--emoji-size);display:flex;align-items:center;justify-content:center;border-radius:100%;height:var(--total-emoji-size);width:var(--total-emoji-size);line-height:1;overflow:hidden;font-family:var(--emoji-font-family);cursor:pointer}@media (hover:hover) and (pointer:fine){.emoji:hover,button.emoji:hover{background:var(--button-hover-background)}}.emoji.active,.emoji:active,button.emoji.active,button.emoji:active{background:var(--button-active-background)}.onscreen .custom-emoji::after{content:"";width:var(--emoji-size);height:var(--emoji-size);background-repeat:no-repeat;background-position:center center;background-size:contain;background-image:var(--custom-emoji-background)}.nav,.nav-button{align-items:center}.nav{display:grid;justify-content:space-between;contain:content}.nav-button{display:flex;justify-content:center}.nav-emoji{font-size:var(--category-emoji-size);width:var(--total-category-emoji-size);height:var(--total-category-emoji-size)}.indicator-wrapper{display:flex;border-bottom:1px solid var(--border-color)}.indicator{width:calc(100%/var(--num-groups));height:var(--indicator-height);opacity:var(--indicator-opacity);background-color:var(--indicator-color);will-change:transform,opacity;transition:opacity .1s linear,transform .25s ease-in-out}@media (prefers-reduced-motion:reduce){.indicator{will-change:opacity;transition:opacity .1s linear}}.pad-top,input.search{background:var(--background);width:100%}.pad-top{height:var(--emoji-padding);z-index:3}.search-row{display:flex;align-items:center;position:relative;padding-inline-start:var(--emoji-padding);padding-bottom:var(--emoji-padding)}.search-wrapper{flex:1;min-width:0}input.search{padding:var(--input-padding);border-radius:var(--input-border-radius);border:var(--input-border-size) solid var(--input-border-color);color:var(--input-font-color);font-size:var(--input-font-size);line-height:var(--input-line-height)}input.search::placeholder{color:var(--input-placeholder-color)}.favorites{overflow-y:auto;scrollbar-gutter:stable;display:flex;flex-direction:row;border-top:var(--border-size) solid var(--border-color);contain:content}.message{padding:var(--emoji-padding)}';const cu=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Hb=`:host{--emoji-font-family:${ru}}`;class Na extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=zb+Hb,this.shadowRoot.appendChild(n),this._ctx={locale:Wb,dataSource:Ub,skinToneEmoji:sb,customCategorySorting:rb,customEmoji:null,i18n:Kb,emojiVersion:null,...t};for(const i of cu)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){yl(this),this._cmp||(this._cmp=Fb(this.shadowRoot,this._ctx))}disconnectedCallback(){yl(this),es(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:t}=this._ctx;t.close().catch(n=>console.error(n))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(t,n,i){this._set(t.replace(/-([a-z])/g,(s,o)=>o.toUpperCase()),t==="emoji-version"?parseFloat(i):i)}_set(t,n){this._ctx[t]=n,this._cmp&&this._cmp.$set({[t]:n}),["locale","dataSource"].includes(t)&&this._dbFlush()}_dbCreate(){const{locale:t,dataSource:n,database:i}=this._ctx;(!i||i.locale!==t||i.dataSource!==n)&&this._set("database",new eb({locale:t,dataSource:n}))}_dbFlush(){es(()=>this._dbCreate())}}const du={};for(const e of cu)du[e]={get(){return e==="database"&&this._dbCreate(),this._ctx[e]},set(t){if(e==="database")throw new Error("database is read-only");this._set(e,t)}};Object.defineProperties(Na.prototype,du);function yl(e){e instanceof Na||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Na);function qb(e){e.style.height="0";const t=Math.max(e.scrollHeight,44);e.style.height=`${t}px`,e.style.overflowY=e.scrollHeight>e.offsetHeight?"auto":"hidden"}function vl(e){e.style.height="44px",e.style.overflowY="hidden"}const jb=5e3;function Gb(e){return e?e.active?l`
2923
+ --num-skintones: ${dl};`}),a(()=>{o.customEmoji&&o.database&&P()}),a(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Uo&&(o.groups=Uo):o.groups!==no&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=no)}),a(()=>{async function C(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}C()}),a(()=>{o.skinTones=Array(dl).fill().map((C,I)=>yb(o.skinToneEmoji,I))}),a(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),a(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),a(()=>{async function C(){const{database:I}=o,F=(await Promise.all(rb.map(U=>I.getEmojiByUnicodeOrName(U)))).filter(Boolean);o.defaultFavoriteEmojis=F}o.databaseLoaded&&C()});function P(){const{customEmoji:C,database:I}=o,F=C||lo;I.customEmoji!==F&&(I.customEmoji=F)}a(()=>{async function C(){P();const{database:I,defaultFavoriteEmojis:F,numColumns:U}=o,Z=await I.getTopFavoriteEmoji(U),J=await ze(cu([...Z,...F],he=>he.unicode||he.name).slice(0,U));o.currentFavorites=J}o.databaseLoaded&&o.defaultFavoriteEmojis&&C()});function D(C){wb(C,s,()=>{{const I=getComputedStyle(n.rootElement),F=parseInt(I.getPropertyValue("--num-columns"),10),U=I.getPropertyValue("direction")==="rtl";o.numColumns=F,o.isRtl=U}})}function W(C){Fb(C,s,I=>{for(const{target:F,isIntersecting:U}of I)F.classList.toggle("onscreen",U)})}a(()=>{async function C(){const{searchText:I,currentGroup:F,databaseLoaded:U,customEmoji:Z}=o;if(!U)o.currentEmojis=[],o.searchMode=!1;else if(I.length>=nb){const J=await bs(I);o.searchText===I&&(v(J),$(!0))}else{const{id:J}=F;if(J!==-1||Z&&Z.length){const he=await vs(J);o.currentGroup.id===J&&(v(he),$(!1))}}}C()});const z=()=>{Ti(()=>$b(n.tabpanelElement))};a(()=>{const{currentEmojis:C,emojiVersion:I}=o,F=C.filter(U=>U.unicode).filter(U=>ul(U)&&!Wo.has(U.unicode));if(!I&&F.length)v(C),Ti(()=>H(F));else{const U=I?C:C.filter(ke);v(U),z()}});function H(C){kb(C,n.baselineEmoji,c)?z():o.currentEmojis=[...o.currentEmojis]}function ke(C){return!C.unicode||!ul(C)||Wo.get(C.unicode)}async function Me(C){const I=o.emojiVersion||await so();return C.filter(({version:F})=>!F||F<=I)}async function ze(C){return vb(C,o.emojiVersion||await so())}async function vs(C){const I=C===-1?o.customEmoji:await o.database.getEmojiByGroup(C);return ze(await Me(I))}async function bs(C){return ze(await Me(await o.database.getEmojiBySearchQuery(C)))}a(()=>{}),a(()=>{function C(){const{searchMode:F,currentEmojis:U}=o;if(F)return[{category:"",emojis:U}];const Z=new Map;for(const J of U){const he=J.category||"";let tt=Z.get(he);tt||(tt=[],Z.set(he,tt)),tt.push(J)}return[...Z.entries()].map(([J,he])=>({category:J,emojis:he})).sort((J,he)=>o.customCategorySorting(J.category,he.category))}const I=C();S(I)}),a(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),a(()=>{const{rawSearchText:C}=o;ru(()=>{o.searchText=(C||"").trim(),o.activeSearchItem=-1})});function ws(C){if(!o.searchMode||!o.currentEmojis.length)return;const I=F=>{Re(C),o.activeSearchItem=oo(F,o.activeSearchItem,o.currentEmojis)};switch(C.key){case"ArrowDown":return I(!1);case"ArrowUp":return I(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Re(C),te(o.currentEmojis[o.activeSearchItem].id)}}function Qn(C){const{target:I}=C,F=I.closest(".nav-button");if(!F)return;const U=parseInt(F.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(Z=>Z.id===U)}function ks(C){const{target:I,key:F}=C,U=Z=>{Z&&(Re(C),Z.focus())};switch(F){case"ArrowLeft":return U(I.previousElementSibling);case"ArrowRight":return U(I.nextElementSibling);case"Home":return U(I.parentElement.firstElementChild);case"End":return U(I.parentElement.lastElementChild)}}async function Jn(C){const I=await o.database.getEmojiByUnicodeOrName(C),F=[...o.currentEmojis,...o.currentFavorites].find(Z=>Z.id===C),U=F.unicode&&M(F,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(C),{emoji:I,skinTone:o.currentSkinTone,...U&&{unicode:U},...F.name&&{name:F.name}}}async function te(C){const I=Jn(C);h("emoji-click-sync",I),h("emoji-click",await I)}function Yn(C){const{target:I}=C;if(!I.classList.contains("emoji"))return;Re(C);const F=I.id.substring(4);te(F)}function ne(C){o.currentSkinTone=C,o.skinTonePickerExpanded=!1,u("skintone-button"),h("skin-tone-change",{skinTone:C}),o.database.setPreferredSkinTone(C)}function Xn(C){const{target:{id:I}}=C,F=I&&I.match(/^skintone-(\d)/);if(!F)return;Re(C);const U=parseInt(F[1],10);ne(U)}function X(C){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Re(C),Ti(()=>u("skintone-list")))}a(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function dt(C){if(!o.skinTonePickerExpanded)return;const I=async F=>{Re(C),o.activeSkinTone=F};switch(C.key){case"ArrowUp":return I(oo(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return I(oo(!1,o.activeSkinTone,o.skinTones));case"Home":return I(0);case"End":return I(o.skinTones.length-1);case"Enter":return Re(C),ne(o.activeSkinTone);case"Escape":return Re(C),o.skinTonePickerExpanded=!1,u("skintone-button")}}function dn(C){if(o.skinTonePickerExpanded&&C.key===" ")return Re(C),ne(o.activeSkinTone)}async function et(C){const{relatedTarget:I}=C;(!I||I.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function Zn(C){o.rawSearchText=C.target.value}return{$set(C){bi(o,C)},$destroy(){i.abort()}}}const Wb="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Kb="en";var zb={categoriesLabel:"Categories",emojiUnsupportedMessage:"Your browser does not support color emoji.",favoritesLabel:"Favorites",loadingMessage:"Loading…",networkErrorMessage:"Could not load emoji.",regionLabel:"Emoji picker",searchDescription:"When search results are available, press up or down to select and enter to choose.",searchLabel:"Search",searchResultsLabel:"Search results",skinToneDescription:"When expanded, press up or down to select and enter to choose.",skinToneLabel:"Choose a skin tone (currently {skinTone})",skinTonesLabel:"Skin tones",skinTones:["Default","Light","Medium-Light","Medium","Medium-Dark","Dark"],categories:{custom:"Custom","smileys-emotion":"Smileys and emoticons","people-body":"People and body","animals-nature":"Animals and nature","food-drink":"Food and drink","travel-places":"Travel and places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"}},Hb=':host{--emoji-size:1.375rem;--emoji-padding:0.5rem;--category-emoji-size:var(--emoji-size);--category-emoji-padding:var(--emoji-padding);--indicator-height:3px;--input-border-radius:0.5rem;--input-border-size:1px;--input-font-size:1rem;--input-line-height:1.5;--input-padding:0.25rem;--num-columns:8;--outline-size:2px;--border-size:1px;--border-radius:0;--skintone-border-radius:1rem;--category-font-size:1rem;display:flex;width:min-content;height:400px}:host,:host(.light){color-scheme:light;--background:#fff;--border-color:#e0e0e0;--indicator-color:#385ac1;--input-border-color:#999;--input-font-color:#111;--input-placeholder-color:#999;--outline-color:#999;--category-font-color:#111;--button-active-background:#e6e6e6;--button-hover-background:#d9d9d9}:host(.dark){color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}@media (prefers-color-scheme:dark){:host{color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}}:host([hidden]){display:none}button{margin:0;padding:0;border:0;background:0 0;box-shadow:none;-webkit-tap-highlight-color:transparent}button::-moz-focus-inner{border:0}input{padding:0;margin:0;line-height:1.15;font-family:inherit}input[type=search]{-webkit-appearance:none}:focus{outline:var(--outline-color) solid var(--outline-size);outline-offset:calc(-1*var(--outline-size))}:host([data-js-focus-visible]) :focus:not([data-focus-visible-added]){outline:0}:focus:not(:focus-visible){outline:0}.hide-focus{outline:0}*{box-sizing:border-box}.picker{contain:content;display:flex;flex-direction:column;background:var(--background);border:var(--border-size) solid var(--border-color);border-radius:var(--border-radius);width:100%;height:100%;overflow:hidden;--total-emoji-size:calc(var(--emoji-size) + (2 * var(--emoji-padding)));--total-category-emoji-size:calc(var(--category-emoji-size) + (2 * var(--category-emoji-padding)))}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.hidden{opacity:0;pointer-events:none}.abs-pos{position:absolute;left:0;top:0}.gone{display:none!important}.skintone-button-wrapper,.skintone-list{background:var(--background);z-index:3}.skintone-button-wrapper.expanded{z-index:1}.skintone-list{position:absolute;inset-inline-end:0;top:0;z-index:2;overflow:visible;border-bottom:var(--border-size) solid var(--border-color);border-radius:0 0 var(--skintone-border-radius) var(--skintone-border-radius);will-change:transform;transition:transform .2s ease-in-out;transform-origin:center 0}@media (prefers-reduced-motion:reduce){.skintone-list{transition-duration:.001s}}@supports not (inset-inline-end:0){.skintone-list{right:0}}.skintone-list.no-animate{transition:none}.tabpanel{overflow-y:auto;scrollbar-gutter:stable;-webkit-overflow-scrolling:touch;will-change:transform;min-height:0;flex:1;contain:content}.emoji-menu{display:grid;grid-template-columns:repeat(var(--num-columns),var(--total-emoji-size));justify-content:space-around;align-items:flex-start;width:100%}.emoji-menu.visibility-auto{content-visibility:auto;contain-intrinsic-size:calc(var(--num-columns)*var(--total-emoji-size)) calc(var(--num-rows)*var(--total-emoji-size))}.category{padding:var(--emoji-padding);font-size:var(--category-font-size);color:var(--category-font-color)}.emoji,button.emoji{font-size:var(--emoji-size);display:flex;align-items:center;justify-content:center;border-radius:100%;height:var(--total-emoji-size);width:var(--total-emoji-size);line-height:1;overflow:hidden;font-family:var(--emoji-font-family);cursor:pointer}@media (hover:hover) and (pointer:fine){.emoji:hover,button.emoji:hover{background:var(--button-hover-background)}}.emoji.active,.emoji:active,button.emoji.active,button.emoji:active{background:var(--button-active-background)}.onscreen .custom-emoji::after{content:"";width:var(--emoji-size);height:var(--emoji-size);background-repeat:no-repeat;background-position:center center;background-size:contain;background-image:var(--custom-emoji-background)}.nav,.nav-button{align-items:center}.nav{display:grid;justify-content:space-between;contain:content}.nav-button{display:flex;justify-content:center}.nav-emoji{font-size:var(--category-emoji-size);width:var(--total-category-emoji-size);height:var(--total-category-emoji-size)}.indicator-wrapper{display:flex;border-bottom:1px solid var(--border-color)}.indicator{width:calc(100%/var(--num-groups));height:var(--indicator-height);opacity:var(--indicator-opacity);background-color:var(--indicator-color);will-change:transform,opacity;transition:opacity .1s linear,transform .25s ease-in-out}@media (prefers-reduced-motion:reduce){.indicator{will-change:opacity;transition:opacity .1s linear}}.pad-top,input.search{background:var(--background);width:100%}.pad-top{height:var(--emoji-padding);z-index:3}.search-row{display:flex;align-items:center;position:relative;padding-inline-start:var(--emoji-padding);padding-bottom:var(--emoji-padding)}.search-wrapper{flex:1;min-width:0}input.search{padding:var(--input-padding);border-radius:var(--input-border-radius);border:var(--input-border-size) solid var(--input-border-color);color:var(--input-font-color);font-size:var(--input-font-size);line-height:var(--input-line-height)}input.search::placeholder{color:var(--input-placeholder-color)}.favorites{overflow-y:auto;scrollbar-gutter:stable;display:flex;flex-direction:row;border-top:var(--border-size) solid var(--border-color);contain:content}.message{padding:var(--emoji-padding)}';const du=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],qb=`:host{--emoji-font-family:${lu}}`;class Na extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Hb+qb,this.shadowRoot.appendChild(n),this._ctx={locale:Kb,dataSource:Wb,skinToneEmoji:ob,customCategorySorting:lb,customEmoji:null,i18n:zb,emojiVersion:null,...t};for(const i of du)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){yl(this),this._cmp||(this._cmp=Ub(this.shadowRoot,this._ctx))}disconnectedCallback(){yl(this),es(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:t}=this._ctx;t.close().catch(n=>console.error(n))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(t,n,i){this._set(t.replace(/-([a-z])/g,(s,o)=>o.toUpperCase()),t==="emoji-version"?parseFloat(i):i)}_set(t,n){this._ctx[t]=n,this._cmp&&this._cmp.$set({[t]:n}),["locale","dataSource"].includes(t)&&this._dbFlush()}_dbCreate(){const{locale:t,dataSource:n,database:i}=this._ctx;(!i||i.locale!==t||i.dataSource!==n)&&this._set("database",new tb({locale:t,dataSource:n}))}_dbFlush(){es(()=>this._dbCreate())}}const uu={};for(const e of du)uu[e]={get(){return e==="database"&&this._dbCreate(),this._ctx[e]},set(t){if(e==="database")throw new Error("database is read-only");this._set(e,t)}};Object.defineProperties(Na.prototype,uu);function yl(e){e instanceof Na||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Na);function jb(e){e.style.height="0";const t=Math.max(e.scrollHeight,44);e.style.height=`${t}px`,e.style.overflowY=e.scrollHeight>e.offsetHeight?"auto":"hidden"}function vl(e){e.style.height="44px",e.style.overflowY="hidden"}const Gb=5e3;function Vb(e){return e?e.active?l`
2924
2924
  <div class="callout info compaction-indicator compaction-indicator--active">
2925
2925
  ${L.loader} Compacting context...
2926
2926
  </div>
2927
- `:e.completedAt&&Date.now()-e.completedAt<jb?l`
2927
+ `:e.completedAt&&Date.now()-e.completedAt<Gb?l`
2928
2928
  <div class="callout success compaction-indicator compaction-indicator--complete">
2929
2929
  ${L.check} Context compacted
2930
2930
  </div>
2931
- `:w:w}const Ge=5*1024*1024;function Ve(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Te(e,t){var i,s,o;let n=(i=e.closest(".chat"))==null?void 0:i.querySelector(".chat-attachment-error");if(!n){n=document.createElement("div"),n.className="callout danger chat-attachment-error",n.style.cssText="margin: 8px 4px; animation: fade-in 200ms ease-out;";const a=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(o=a==null?void 0:a.parentElement)==null||o.insertBefore(n,a)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const Vb=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function uu(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function pu(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||Vb.test(e.name)}function hu(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function fu(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function Qb(e,t){if(!t.onAttachmentsChange)return;const n=document.querySelector(".chat");if(uu(e)){if(e.size>Ge){n&&Te(n,`Image too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Ve(),dataUrl:i.result,mimeType:e.type};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(pu(e)){if(e.size>Ge){n&&Te(n,`File too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Ve(),dataUrl:"",mimeType:e.type||"text/plain",fileName:e.name,textContent:i.result};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsText(e)}else if(hu(e)){if(e.size>Ge){n&&Te(n,`PDF too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Ve(),dataUrl:i.result,mimeType:"application/pdf",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(fu(e)){if(e.size>Ge){n&&Te(n,`Video too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Ve(),dataUrl:i.result,mimeType:e.type||"video/mp4",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else n&&Te(n,`Unsupported file type: ${e.name}. Use the Files page to upload to workspace.`)}function Jb(e,t){var s;e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const i=(s=e.dataTransfer)==null?void 0:s.files;if(!(!i||i.length===0))for(let o=0;o<i.length;o++){const a=i[o];if(uu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Ge){Te(n,`Image too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const u=r.result,c={id:Ve(),dataUrl:u,mimeType:a.type},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else if(pu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Ge){Te(n,`File too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const u=r.result,c={id:Ve(),dataUrl:"",mimeType:a.type||"text/plain",fileName:a.name,textContent:u},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsText(a)}else if(hu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Ge){Te(n,`PDF too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const u=r.result,c={id:Ve(),dataUrl:u,mimeType:"application/pdf",fileName:a.name},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else if(fu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Ge){Te(n,`Video too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const u=r.result,c={id:Ve(),dataUrl:u,mimeType:a.type||"video/mp4",fileName:a.name},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else Te(n,`Unsupported file type: ${a.name}. Use the Files page to upload to workspace.`)}}function Yb(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Xb(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function Zb(e,t){var s,o,a;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n||!t.onAttachmentsChange)return;const i=[];for(let r=0;r<n.length;r++){const u=n[r];(u.type.startsWith("image/")||u.type.startsWith("video/"))&&i.push(u)}if(i.length!==0){e.preventDefault();for(const r of i){const u=r.getAsFile();if(!u)continue;const c=u.type.startsWith("video/")?"Video":"Image";if(u.size>Ge){const d=((a=(o=e.target)==null?void 0:o.closest)==null?void 0:a.call(o,".chat"))??document.querySelector(".chat");d&&Te(d,`${c} too large (${(u.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const h=new FileReader;h.onload=()=>{var S;const d=h.result,p=u.type.startsWith("video/"),v={id:Ve(),dataUrl:d,mimeType:u.type,fileName:p?u.name||"video.mp4":void 0},$=t.attachments??[];(S=t.onAttachmentsChange)==null||S.call(t,[...$,v])},h.readAsDataURL(u)}}}function ew(e){const t=e.currentTarget,n=t.closest(".chat-compose"),i=n==null?void 0:n.querySelector(".emoji-picker-popup");if(!i)return;const s=i.classList.toggle("active");if(t.classList.toggle("active",s),s){const o=a=>{i.contains(a.target)||t.contains(a.target)||(i.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",o,!0))};requestAnimationFrame(()=>document.addEventListener("click",o,!0))}}function tw(e,t){const n=e.detail,i=n==null?void 0:n.unicode;if(!i)return;const s=e.currentTarget.closest(".chat-compose"),o=s==null?void 0:s.querySelector("textarea");if(!o)return;const a=o.selectionStart??t.draft.length,r=o.selectionEnd??a,u=t.draft.slice(0,a),c=t.draft.slice(r);t.onDraftChange(u+i+c);const h=s==null?void 0:s.querySelector(".emoji-picker-popup"),d=s==null?void 0:s.querySelector(".chat-compose__emoji");h==null||h.classList.remove("active"),d==null||d.classList.remove("active"),requestAnimationFrame(()=>{o.focus();const p=a+i.length;o.setSelectionRange(p,p)})}function nw(e){const t=e.attachments??[];return t.length===0?w:l`
2931
+ `:w:w}const Je=5*1024*1024;function Ye(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Te(e,t){var i,s,o;let n=(i=e.closest(".chat"))==null?void 0:i.querySelector(".chat-attachment-error");if(!n){n=document.createElement("div"),n.className="callout danger chat-attachment-error",n.style.cssText="margin: 8px 4px; animation: fade-in 200ms ease-out;";const a=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(o=a==null?void 0:a.parentElement)==null||o.insertBefore(n,a)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const Qb=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function pu(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function hu(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||Qb.test(e.name)}function fu(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function gu(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function Jb(e,t){if(!t.onAttachmentsChange)return;const n=document.querySelector(".chat");if(pu(e)){if(e.size>Je){n&&Te(n,`Image too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Ye(),dataUrl:i.result,mimeType:e.type};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(hu(e)){if(e.size>Je){n&&Te(n,`File too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Ye(),dataUrl:"",mimeType:e.type||"text/plain",fileName:e.name,textContent:i.result};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsText(e)}else if(fu(e)){if(e.size>Je){n&&Te(n,`PDF too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Ye(),dataUrl:i.result,mimeType:"application/pdf",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(gu(e)){if(e.size>Je){n&&Te(n,`Video too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Ye(),dataUrl:i.result,mimeType:e.type||"video/mp4",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else n&&Te(n,`Unsupported file type: ${e.name}. Use the Files page to upload to workspace.`)}function Yb(e,t){var s;e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const i=(s=e.dataTransfer)==null?void 0:s.files;if(!(!i||i.length===0))for(let o=0;o<i.length;o++){const a=i[o];if(pu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Je){Te(n,`Image too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const u=r.result,c={id:Ye(),dataUrl:u,mimeType:a.type},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else if(hu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Je){Te(n,`File too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const u=r.result,c={id:Ye(),dataUrl:"",mimeType:a.type||"text/plain",fileName:a.name,textContent:u},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsText(a)}else if(fu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Je){Te(n,`PDF too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const u=r.result,c={id:Ye(),dataUrl:u,mimeType:"application/pdf",fileName:a.name},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else if(gu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Je){Te(n,`Video too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const u=r.result,c={id:Ye(),dataUrl:u,mimeType:a.type||"video/mp4",fileName:a.name},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else Te(n,`Unsupported file type: ${a.name}. Use the Files page to upload to workspace.`)}}function Xb(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Zb(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function ew(e,t){var s,o,a;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n||!t.onAttachmentsChange)return;const i=[];for(let r=0;r<n.length;r++){const u=n[r];(u.type.startsWith("image/")||u.type.startsWith("video/"))&&i.push(u)}if(i.length!==0){e.preventDefault();for(const r of i){const u=r.getAsFile();if(!u)continue;const c=u.type.startsWith("video/")?"Video":"Image";if(u.size>Je){const d=((a=(o=e.target)==null?void 0:o.closest)==null?void 0:a.call(o,".chat"))??document.querySelector(".chat");d&&Te(d,`${c} too large (${(u.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const h=new FileReader;h.onload=()=>{var S;const d=h.result,p=u.type.startsWith("video/"),v={id:Ye(),dataUrl:d,mimeType:u.type,fileName:p?u.name||"video.mp4":void 0},$=t.attachments??[];(S=t.onAttachmentsChange)==null||S.call(t,[...$,v])},h.readAsDataURL(u)}}}function tw(e){const t=e.currentTarget,n=t.closest(".chat-compose"),i=n==null?void 0:n.querySelector(".emoji-picker-popup");if(!i)return;const s=i.classList.toggle("active");if(t.classList.toggle("active",s),s){const o=a=>{i.contains(a.target)||t.contains(a.target)||(i.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",o,!0))};requestAnimationFrame(()=>document.addEventListener("click",o,!0))}}function nw(e,t){const n=e.detail,i=n==null?void 0:n.unicode;if(!i)return;const s=e.currentTarget.closest(".chat-compose"),o=s==null?void 0:s.querySelector("textarea");if(!o)return;const a=o.selectionStart??t.draft.length,r=o.selectionEnd??a,u=t.draft.slice(0,a),c=t.draft.slice(r);t.onDraftChange(u+i+c);const h=s==null?void 0:s.querySelector(".emoji-picker-popup"),d=s==null?void 0:s.querySelector(".chat-compose__emoji");h==null||h.classList.remove("active"),d==null||d.classList.remove("active"),requestAnimationFrame(()=>{o.focus();const p=a+i.length;o.setSelectionRange(p,p)})}function iw(e){const t=e.attachments??[];return t.length===0?w:l`
2932
2932
  <div class="chat-attachments">
2933
2933
  ${t.map(n=>{var i;return n.fileName?l`
2934
2934
  <div class="chat-attachment chat-attachment--file">
@@ -2961,7 +2961,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
2961
2961
  </div>
2962
2962
  `})}
2963
2963
  </div>
2964
- `}function gu(e){var $,S,M;const t=e.connected,n=e.sending||e.stream!==null,i=!!(e.canAbort&&e.onAbort),s=(S=($=e.sessions)==null?void 0:$.sessions)==null?void 0:S.find(y=>y.key===e.sessionKey),o=(s==null?void 0:s.reasoningLevel)??"off",a=e.showThinking&&o!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const r=(((M=e.attachments)==null?void 0:M.length)??0)>0,u=e.connected?r?"Add a message...":"Message...":"Connecting…";lv({onSend:y=>{e.onAttachmentsChange&&e.onAttachmentsChange([...e.attachments??[],y]),requestAnimationFrame(()=>e.onSend())},onRequestRender:()=>{var y;(y=e.requestUpdate)==null||y.call(e)}});const c=rv(),h=!c&&!e.draft.trim()&&!r&&!n,d=e.splitRatio??.6,p=!!(e.sidebarOpen&&e.onCloseSidebar),v=l`
2964
+ `}function mu(e){var $,S,M;const t=e.connected,n=e.sending||e.stream!==null,i=!!(e.canAbort&&e.onAbort),s=(S=($=e.sessions)==null?void 0:$.sessions)==null?void 0:S.find(y=>y.key===e.sessionKey),o=(s==null?void 0:s.reasoningLevel)??"off",a=e.showThinking&&o!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const r=(((M=e.attachments)==null?void 0:M.length)??0)>0,u=e.connected?r?"Add a message...":"Message...":"Connecting…";cv({onSend:y=>{e.onAttachmentsChange&&e.onAttachmentsChange([...e.attachments??[],y]),requestAnimationFrame(()=>e.onSend())},onRequestRender:()=>{var y;(y=e.requestUpdate)==null||y.call(e)}});const c=lv(),h=!c&&!e.draft.trim()&&!r&&!n,d=e.splitRatio??.6,p=!!(e.sidebarOpen&&e.onCloseSidebar),v=l`
2965
2965
  <div
2966
2966
  class="chat-thread"
2967
2967
  role="log"
@@ -2972,20 +2972,20 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
2972
2972
  ${e.loadingOlder?l`<span class="chat-load-more__spinner">${L.loader}</span> Loading older messages…`:l`<button class="chat-load-more__btn" type="button" @click=${e.onLoadOlder}>Load older messages</button>`}
2973
2973
  </div>`:w}
2974
2974
  ${e.loading?l`<div class="muted">Loading chat…</div>`:w}
2975
- ${ym(sw(e),y=>y.key,y=>y.kind==="interim"?Yy(y.text):y.kind==="reading-indicator"?Jy():y.kind==="stream"?Xy(y.text,y.startedAt,e.onOpenSidebar):y.kind==="group"?Zy(y,{onOpenSidebar:e.onOpenSidebar,showReasoning:a,assistantName:e.assistantName}):w)}
2975
+ ${vm(ow(e),y=>y.key,y=>y.kind==="interim"?Xy(y.text):y.kind==="reading-indicator"?Yy():y.kind==="stream"?Zy(y.text,y.startedAt,e.onOpenSidebar):y.kind==="group"?ev(y,{onOpenSidebar:e.onOpenSidebar,showReasoning:a,assistantName:e.assistantName}):w)}
2976
2976
  </div>
2977
2977
  `;return l`
2978
2978
  <section
2979
2979
  class="card chat"
2980
- @drop=${y=>Jb(y,e)}
2981
- @dragover=${Yb}
2982
- @dragleave=${Xb}
2980
+ @drop=${y=>Yb(y,e)}
2981
+ @dragover=${Xb}
2982
+ @dragleave=${Zb}
2983
2983
  >
2984
2984
  ${e.disabledReason?l`<div class="callout">${e.disabledReason}</div>`:w}
2985
2985
 
2986
2986
  ${e.error?l`<div class="callout danger">${e.error}</div>`:w}
2987
2987
 
2988
- ${Gb(e.compactionStatus)}
2988
+ ${Vb(e.compactionStatus)}
2989
2989
 
2990
2990
  ${e.focusMode?l`
2991
2991
  <button
@@ -3026,7 +3026,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
3026
3026
  @resize=${y=>{var b;return(b=e.onSplitRatioChange)==null?void 0:b.call(e,y.detail.splitRatio)}}
3027
3027
  ></resizable-divider>
3028
3028
  <div class="chat-sidebar">
3029
- ${uv({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
3029
+ ${pv({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
3030
3030
  ${e.sidebarContent}
3031
3031
  \`\`\``)}})}
3032
3032
  </div>
@@ -3048,13 +3048,13 @@ ${e.sidebarContent}
3048
3048
  `:w}
3049
3049
 
3050
3050
  <div class="chat-compose">
3051
- ${nw(e)}
3052
- ${c?dv():l`
3051
+ ${iw(e)}
3052
+ ${c?uv():l`
3053
3053
  <div class="chat-compose__row">
3054
3054
  <button
3055
3055
  class="chat-compose__emoji"
3056
3056
  type="button"
3057
- @click=${ew}
3057
+ @click=${tw}
3058
3058
  aria-label="Emoji"
3059
3059
  title="Emoji"
3060
3060
  >
@@ -3075,7 +3075,7 @@ ${e.sidebarContent}
3075
3075
  multiple
3076
3076
  accept="image/*,video/*,.pdf,.md,.txt,.csv,.json,.xml,.html,.css,.js,.ts,.py,.sh,.yaml,.yml,.toml,.ini,.cfg,.log,.sql"
3077
3077
  style="display:none"
3078
- @change=${y=>{const b=y.target,k=b.files;if(!(!k||k.length===0||!e.onAttachmentsChange)){for(let A=0;A<k.length;A++)Qb(k[A],e);b.value=""}}}
3078
+ @change=${y=>{const b=y.target,k=b.files;if(!(!k||k.length===0||!e.onAttachmentsChange)){for(let A=0;A<k.length;A++)Jb(k[A],e);b.value=""}}}
3079
3079
  />
3080
3080
  <label class="field chat-compose__field">
3081
3081
  <span>Message</span>
@@ -3083,8 +3083,8 @@ ${e.sidebarContent}
3083
3083
  .value=${e.draft}
3084
3084
  ?disabled=${!e.connected}
3085
3085
  @keydown=${y=>{y.key==="Enter"&&(y.isComposing||y.keyCode===229||y.shiftKey||e.connected&&(y.preventDefault(),t&&(e.onSend(),vl(y.target))))}}
3086
- @input=${y=>{const b=y.target;e.onDraftChange(b.value),qb(b)}}
3087
- @paste=${y=>Zb(y,e)}
3086
+ @input=${y=>{const b=y.target;e.onDraftChange(b.value),jb(b)}}
3087
+ @paste=${y=>ew(y,e)}
3088
3088
  placeholder=${u}
3089
3089
  ></textarea>
3090
3090
  </label>
@@ -3098,7 +3098,7 @@ ${e.sidebarContent}
3098
3098
  ${L.square}
3099
3099
  </button>
3100
3100
  `:w}
3101
- ${h?cv(e.connected):l`
3101
+ ${h?dv(e.connected):l`
3102
3102
  <button
3103
3103
  class="btn btn--icon chat-compose__send primary"
3104
3104
  ?disabled=${!e.connected}
@@ -3111,14 +3111,14 @@ ${e.sidebarContent}
3111
3111
  </div>`}
3112
3112
  <div class="emoji-picker-popup">
3113
3113
  <emoji-picker
3114
- @emoji-click=${y=>tw(y,e)}
3114
+ @emoji-click=${y=>nw(y,e)}
3115
3115
  ></emoji-picker>
3116
3116
  </div>
3117
3117
  </div>
3118
3118
  </section>
3119
- `}function iw(e){return e.map(t=>{if(t.kind!=="message")return t;const n=tc(t.message),i=nc(n.role),s=n.timestamp||Date.now();return{kind:"group",key:`group:${i}:${t.key}`,role:i,messages:[{message:t.message,key:t.key}],timestamp:s,isStreaming:!1}})}function sw(e){var o;const t=[],n=Array.isArray(e.messages)?e.messages:[],i=Array.isArray(e.toolMessages)?e.toolMessages:[],s=e.showThinking||e.verboseLevel==="on"||e.verboseLevel==="full";for(let a=0;a<n.length;a++){const r=n[a],u=tc(r);if(!s&&u.role.toLowerCase()==="toolresult"){const c=r,d=(Array.isArray(c.content)?c.content:[]).filter(p=>{const v=p.type;return v==="image"||v==="file"});d.length>0&&t.push({kind:"message",key:co(r,a),message:{role:"assistant",content:d,timestamp:u.timestamp}});continue}t.push({kind:"message",key:co(r,a),message:r})}if(s)for(let a=0;a<i.length;a++)t.push({kind:"message",key:co(i[a],a+n.length),message:i[a]});if(e.interimText&&t.push({kind:"interim",key:"interim:thinking",text:e.interimText}),e.stream!==null){const a=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:a,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:a})}for(const a of e.queue){const r=((o=a.attachments)==null?void 0:o.filter(c=>c.fileName).map(c=>c.fileName))??[],u=r.length>0?a.text?`${r.join(", ")}
3119
+ `}function sw(e){return e.map(t=>{if(t.kind!=="message")return t;const n=tc(t.message),i=nc(n.role),s=n.timestamp||Date.now();return{kind:"group",key:`group:${i}:${t.key}`,role:i,messages:[{message:t.message,key:t.key}],timestamp:s,isStreaming:!1}})}function ow(e){var o;const t=[],n=Array.isArray(e.messages)?e.messages:[],i=Array.isArray(e.toolMessages)?e.toolMessages:[],s=e.showThinking||e.verboseLevel==="on"||e.verboseLevel==="full";for(let a=0;a<n.length;a++){const r=n[a],u=tc(r);if(!s&&u.role.toLowerCase()==="toolresult"){const c=r,d=(Array.isArray(c.content)?c.content:[]).filter(p=>{const v=p.type;return v==="image"||v==="file"});d.length>0&&t.push({kind:"message",key:co(r,a),message:{role:"assistant",content:d,timestamp:u.timestamp}});continue}t.push({kind:"message",key:co(r,a),message:r})}if(s)for(let a=0;a<i.length;a++)t.push({kind:"message",key:co(i[a],a+n.length),message:i[a]});if(e.interimText&&t.push({kind:"interim",key:"interim:thinking",text:e.interimText}),e.stream!==null){const a=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:a,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:a})}for(const a of e.queue){const r=((o=a.attachments)==null?void 0:o.filter(c=>c.fileName).map(c=>c.fileName))??[],u=r.length>0?a.text?`${r.join(", ")}
3120
3120
 
3121
- ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,message:{role:"user",content:[{type:"text",text:u}],timestamp:a.createdAt}})}return iw(t)}function co(e,t){const n=e,i=typeof n.toolCallId=="string"?n.toolCallId:"";if(i)return`tool:${i}`;const s=typeof n.id=="string"?n.id:"";if(s)return`msg:${s}`;const o=typeof n.messageId=="string"?n.messageId:"";if(o)return`msg:${o}`;const a=typeof n.timestamp=="number"?n.timestamp:null,r=typeof n.role=="string"?n.role:"unknown";return a!=null?`msg:${r}:${a}:${t}`:`msg:${r}:${t}`}function ow(e){if(!e)return"";const t=new Date(e*1e3);return t.toLocaleDateString([],{year:"numeric",month:"short",day:"numeric"})+" "+t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function mu(e){return e.replace(/@s\.whatsapp\.net$/,"").replace(/@g\.us$/,"")}function aw(e){const t=e.searchQuery.toLowerCase(),n=t?e.conversations.filter(i=>i.name.toLowerCase().includes(t)||i.jid.includes(t)):e.conversations;return l`
3121
+ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,message:{role:"user",content:[{type:"text",text:u}],timestamp:a.createdAt}})}return sw(t)}function co(e,t){const n=e,i=typeof n.toolCallId=="string"?n.toolCallId:"";if(i)return`tool:${i}`;const s=typeof n.id=="string"?n.id:"";if(s)return`msg:${s}`;const o=typeof n.messageId=="string"?n.messageId:"";if(o)return`msg:${o}`;const a=typeof n.timestamp=="number"?n.timestamp:null,r=typeof n.role=="string"?n.role:"unknown";return a!=null?`msg:${r}:${a}:${t}`:`msg:${r}:${t}`}function aw(e){if(!e)return"";const t=new Date(e*1e3);return t.toLocaleDateString([],{year:"numeric",month:"short",day:"numeric"})+" "+t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function yu(e){return e.replace(/@s\.whatsapp\.net$/,"").replace(/@g\.us$/,"")}function rw(e){const t=e.searchQuery.toLowerCase(),n=t?e.conversations.filter(i=>i.name.toLowerCase().includes(t)||i.jid.includes(t)):e.conversations;return l`
3122
3122
  <div class="wa-list">
3123
3123
  <div class="wa-list__header">
3124
3124
  <input
@@ -3133,29 +3133,29 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3133
3133
  </button>
3134
3134
  </div>
3135
3135
  <div class="wa-list__items">
3136
- ${e.loading?l`<div class="wa-list__empty">Loading...</div>`:n.length===0?l`<div class="wa-list__empty">${e.conversations.length===0?"No conversations yet":"No matches"}</div>`:n.map(i=>rw(i,i.jid===e.selectedJid,()=>e.onSelectConversation(i.jid)))}
3136
+ ${e.loading?l`<div class="wa-list__empty">Loading...</div>`:n.length===0?l`<div class="wa-list__empty">${e.conversations.length===0?"No conversations yet":"No matches"}</div>`:n.map(i=>lw(i,i.jid===e.selectedJid,()=>e.onSelectConversation(i.jid)))}
3137
3137
  </div>
3138
3138
  </div>
3139
- `}function rw(e,t,n){const i=e.type==="group"&&e.activation?l`<span class="wa-badge wa-badge--${e.activation}">${e.activation}</span>`:w;return l`
3139
+ `}function lw(e,t,n){const i=e.type==="group"&&e.activation?l`<span class="wa-badge wa-badge--${e.activation}">${e.activation}</span>`:w;return l`
3140
3140
  <button class="wa-list__item ${t?"wa-list__item--selected":""}" @click=${n}>
3141
3141
  <span class="wa-list__icon ${e.type==="group"?"wa-list__icon--group":""}">${e.type==="group"?L.users:L.user}</span>
3142
3142
  <div class="wa-list__info">
3143
3143
  <span class="wa-list__name">${e.name}</span>
3144
- <span class="wa-list__jid">${mu(e.jid)}</span>
3144
+ <span class="wa-list__jid">${yu(e.jid)}</span>
3145
3145
  </div>
3146
3146
  ${i}
3147
3147
  </button>
3148
- `}function lw(e){const t=e.conversations.find(n=>n.jid===e.selectedJid);return t?l`
3148
+ `}function cw(e){const t=e.conversations.find(n=>n.jid===e.selectedJid);return t?l`
3149
3149
  <div class="wa-header">
3150
3150
  <button class="wa-header__back" @click=${e.onBack} title="Back to conversations">
3151
3151
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg>
3152
3152
  </button>
3153
3153
  <div class="wa-header__info">
3154
3154
  <span class="wa-header__name">${t.name}</span>
3155
- <span class="wa-header__jid">${mu(t.jid)}</span>
3155
+ <span class="wa-header__jid">${yu(t.jid)}</span>
3156
3156
  </div>
3157
3157
  </div>
3158
- `:l``}function cw(e){var n;const t=e.groupInfo;return!t||!((n=e.selectedJid)!=null&&n.endsWith("@g.us"))?l``:l`
3158
+ `:l``}function dw(e){var n;const t=e.groupInfo;return!t||!((n=e.selectedJid)!=null&&n.endsWith("@g.us"))?l``:l`
3159
3159
  <div class="wa-group-settings">
3160
3160
  <div class="wa-group-settings__row">
3161
3161
  <label class="wa-group-settings__label">Activation</label>
@@ -3174,29 +3174,29 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3174
3174
  ${t.desc?l` · ${t.desc}`:w}
3175
3175
  </div>
3176
3176
  </div>
3177
- `}function dw(e){return e.length===0?l`<div class="wa-messages__empty">No messages available</div>`:l`
3177
+ `}function uw(e){return e.length===0?l`<div class="wa-messages__empty">No messages available</div>`:l`
3178
3178
  ${e.map(t=>l`
3179
3179
  <div class="wa-bubble ${t.fromMe?"wa-bubble--me":""}">
3180
3180
  ${!t.fromMe&&t.senderName?l`<div class="wa-bubble__sender">${t.senderName}</div>`:w}
3181
3181
  ${t.quoted?l`<div class="wa-bubble__quoted">${t.quoted.body}</div>`:w}
3182
3182
  <div class="wa-bubble__body">${t.body}</div>
3183
- <div class="wa-bubble__time">${ow(t.timestamp)}</div>
3183
+ <div class="wa-bubble__time">${aw(t.timestamp)}</div>
3184
3184
  </div>
3185
3185
  `)}
3186
- `}function uw(e){return l`
3186
+ `}function pw(e){return l`
3187
3187
  <div class="wa-container ${e.selectedJid?"wa-container--detail":""}">
3188
- ${aw(e)}
3188
+ ${rw(e)}
3189
3189
  <div class="wa-view">
3190
3190
  ${e.selectedJid?l`
3191
- ${lw(e)}
3192
3191
  ${cw(e)}
3192
+ ${dw(e)}
3193
3193
  <div class="wa-messages">
3194
- ${e.messagesLoading?l`<div class="wa-messages__empty">Loading messages...</div>`:dw(e.messages)}
3194
+ ${e.messagesLoading?l`<div class="wa-messages__empty">Loading messages...</div>`:uw(e.messages)}
3195
3195
  </div>
3196
3196
  `:l`<div class="wa-view__empty">Select a conversation</div>`}
3197
3197
  </div>
3198
3198
  </div>
3199
- `}const pw=l`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>`;function hw(e){if(!e.connected)return l`
3199
+ `}const hw=l`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>`;function fw(e){if(!e.connected)return l`
3200
3200
  <div class="setup-container">
3201
3201
  <div class="setup-card">
3202
3202
  <div class="setup-spinner"></div>
@@ -3209,7 +3209,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3209
3209
  target="_blank"
3210
3210
  rel="noopener"
3211
3211
  title="Open public chat in new tab"
3212
- >Public ${pw}</a>`:w,i=e.whatsappProps?l`
3212
+ >Public ${hw}</a>`:w,i=e.whatsappProps?l`
3213
3213
  <div class="chat-page-tabs">
3214
3214
  <button
3215
3215
  class="chat-page-tab ${t==="chat"?"active":""}"
@@ -3226,16 +3226,16 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3226
3226
  ${n}
3227
3227
  ${i}
3228
3228
  <div class="chat-viewport">
3229
- ${t==="whatsapp"&&e.whatsappProps?uw(e.whatsappProps):gu(e)}
3229
+ ${t==="whatsapp"&&e.whatsappProps?pw(e.whatsappProps):mu(e)}
3230
3230
  </div>
3231
3231
  </div>
3232
- `}async function yu(e){if(!(!e.client||!e.connected)){e.loading=!0,e.lastError=null;try{const t=await e.client.request("whatsapp.conversations",{accountId:e.accountId});e.conversations=t.conversations}catch(t){e.lastError=String(t)}finally{e.loading=!1}}}async function fw(e,t){if(!(!e.client||!e.connected)){e.selectedJid=t,e.messagesLoading=!0,e.messages=[],e.groupInfo=null,e.lastError=null;try{const n=await e.client.request("whatsapp.messages",{jid:t,limit:100,accountId:e.accountId});e.messages=n.messages}catch(n){e.lastError=String(n)}if(t.endsWith("@g.us"))try{const n=await e.client.request("whatsapp.groupInfo",{jid:t,accountId:e.accountId});e.groupInfo=n}catch{}e.messagesLoading=!1}}async function gw(e,t,n){if(!(!e.client||!e.connected))try{await e.client.request("whatsapp.setActivation",{jid:t,activation:n,accountId:e.accountId}),e.groupInfo&&(e.groupInfo.activation=n);const i=e.conversations.find(s=>s.jid===t);i&&(i.activation=n)}catch(i){e.lastError=String(i)}}function mw(e){return e?`${Yl(e)} (${os(e)})`:"n/a"}function vu(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?os(t.lastRunAtMs):"never";return`${n} · last ${i}`}function bu(e){const t=e.schedule;return t.kind==="at"?`One-time: ${Yl(t.atMs)}`:t.kind==="every"?`Every ${Xo(t.everyMs)}`:yw(t.expr,t.tz)}function yw(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,o,a,r]=n,u=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",c=(S,M)=>new Date(2e3,0,1,S,M).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),h=/^\d{1,2}$/.test(i)?parseInt(i,10):null,d=bl(s);if(h===null||!d)return`${e}${t?` (${t})`:""}`;const p=d.map(S=>c(S,h)),v=p.length<=3?p.join(" & "):`${p.slice(0,-1).join(", ")} & ${p[p.length-1]}`,$=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(o==="*"&&a==="*"){if(r==="*")return`Daily at ${v}${u}`;if(r==="1-5")return`Weekdays at ${v}${u}`;if(r==="0,6"||r==="6,0")return`Weekends at ${v}${u}`;const S=bl(r);if(S)return`${S.map(y=>$[y%7]??String(y)).join(", ")} at ${v}${u}`}return`${e}${t?` (${t})`:""}`}function bl(e){if(e==="*")return null;if(/^\d+(,\d+)*$/.test(e))return e.split(",").map(Number);if(/^\d+-\d+$/.test(e)){const[t,n]=e.split("-").map(Number);if(t>n)return null;const i=[];for(let s=t;s<=n;s++)i.push(s);return i}return null}function vw(e,t=!0){const n=e.payload;return n.kind==="systemEvent"?`Task: ${t&&n.text.length>60?`${n.text.slice(0,57)}…`:n.text}`:`Message: ${t&&n.message.length>60?`${n.message.slice(0,57)}…`:n.message}`}function wl(e){const t=e.payload;if(t.kind!=="agentTurn")return null;const n=t.channel??t.provider,i=t.to;if(!i&&!n)return null;const s=[];if(i){const a=i.split(",").map(r=>r.trim()).filter(Boolean).map(r=>r.toLowerCase()==="admins"?"All admins":r);s.push(a.join(", "))}return n&&n!=="last"&&s.push(`via ${n}`),s.join(" ")||null}let be=null;function bw(e){var s;const t=["last",...e.channels.filter(Boolean)],n=(s=e.form.channel)==null?void 0:s.trim();n&&!t.includes(n)&&t.push(n);const i=new Set;return t.filter(o=>i.has(o)?!1:(i.add(o),!0))}function ww(e,t){var i,s;if(t==="last")return"last";const n=(i=e.channelMeta)==null?void 0:i.find(o=>o.id===t);return n!=null&&n.label?n.label:((s=e.channelLabels)==null?void 0:s[t])??t}function kw(e){return e.split(",").map(n=>n.trim()).filter(Boolean).map(n=>n.toLowerCase()==="admins"?"All admins":n).join(", ")}function xw(e){return e||"Default"}const $w=l`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,Sw=l`<svg viewBox="0 0 24 24"><rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/></svg>`,Aw=l`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,gs=l`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,Cw=l`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,wu=l`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`,Ew=l`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`;function kl(e){const t=e.detailJobId?e.jobs.find(i=>i.id===e.detailJobId)??null:null,n=e.newEventModalOpen||!!e.editJobId;return l`
3233
- ${Tw(e)}
3232
+ `}async function vu(e){if(!(!e.client||!e.connected)){e.loading=!0,e.lastError=null;try{const t=await e.client.request("whatsapp.conversations",{accountId:e.accountId});e.conversations=t.conversations}catch(t){e.lastError=String(t)}finally{e.loading=!1}}}async function gw(e,t){if(!(!e.client||!e.connected)){e.selectedJid=t,e.messagesLoading=!0,e.messages=[],e.groupInfo=null,e.lastError=null;try{const n=await e.client.request("whatsapp.messages",{jid:t,limit:100,accountId:e.accountId});e.messages=n.messages}catch(n){e.lastError=String(n)}if(t.endsWith("@g.us"))try{const n=await e.client.request("whatsapp.groupInfo",{jid:t,accountId:e.accountId});e.groupInfo=n}catch{}e.messagesLoading=!1}}async function mw(e,t,n){if(!(!e.client||!e.connected))try{await e.client.request("whatsapp.setActivation",{jid:t,activation:n,accountId:e.accountId}),e.groupInfo&&(e.groupInfo.activation=n);const i=e.conversations.find(s=>s.jid===t);i&&(i.activation=n)}catch(i){e.lastError=String(i)}}function yw(e){return e?`${Yl(e)} (${os(e)})`:"n/a"}function bu(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?os(t.lastRunAtMs):"never";return`${n} · last ${i}`}function wu(e){const t=e.schedule;return t.kind==="at"?`One-time: ${Yl(t.atMs)}`:t.kind==="every"?`Every ${Xo(t.everyMs)}`:vw(t.expr,t.tz)}function vw(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,o,a,r]=n,u=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",c=(S,M)=>new Date(2e3,0,1,S,M).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),h=/^\d{1,2}$/.test(i)?parseInt(i,10):null,d=bl(s);if(h===null||!d)return`${e}${t?` (${t})`:""}`;const p=d.map(S=>c(S,h)),v=p.length<=3?p.join(" & "):`${p.slice(0,-1).join(", ")} & ${p[p.length-1]}`,$=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(o==="*"&&a==="*"){if(r==="*")return`Daily at ${v}${u}`;if(r==="1-5")return`Weekdays at ${v}${u}`;if(r==="0,6"||r==="6,0")return`Weekends at ${v}${u}`;const S=bl(r);if(S)return`${S.map(y=>$[y%7]??String(y)).join(", ")} at ${v}${u}`}return`${e}${t?` (${t})`:""}`}function bl(e){if(e==="*")return null;if(/^\d+(,\d+)*$/.test(e))return e.split(",").map(Number);if(/^\d+-\d+$/.test(e)){const[t,n]=e.split("-").map(Number);if(t>n)return null;const i=[];for(let s=t;s<=n;s++)i.push(s);return i}return null}function bw(e,t=!0){const n=e.payload;return n.kind==="systemEvent"?`Task: ${t&&n.text.length>60?`${n.text.slice(0,57)}…`:n.text}`:`Message: ${t&&n.message.length>60?`${n.message.slice(0,57)}…`:n.message}`}function wl(e){const t=e.payload;if(t.kind!=="agentTurn")return null;const n=t.channel??t.provider,i=t.to;if(!i&&!n)return null;const s=[];if(i){const a=i.split(",").map(r=>r.trim()).filter(Boolean).map(r=>r.toLowerCase()==="admins"?"All admins":r);s.push(a.join(", "))}return n&&n!=="last"&&s.push(`via ${n}`),s.join(" ")||null}let be=null;function ww(e){var s;const t=["last",...e.channels.filter(Boolean)],n=(s=e.form.channel)==null?void 0:s.trim();n&&!t.includes(n)&&t.push(n);const i=new Set;return t.filter(o=>i.has(o)?!1:(i.add(o),!0))}function kw(e,t){var i,s;if(t==="last")return"last";const n=(i=e.channelMeta)==null?void 0:i.find(o=>o.id===t);return n!=null&&n.label?n.label:((s=e.channelLabels)==null?void 0:s[t])??t}function xw(e){return e.split(",").map(n=>n.trim()).filter(Boolean).map(n=>n.toLowerCase()==="admins"?"All admins":n).join(", ")}function $w(e){return e||"Default"}const Sw=l`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,Aw=l`<svg viewBox="0 0 24 24"><rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/></svg>`,Cw=l`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,gs=l`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,Ew=l`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,ku=l`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`,Tw=l`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`;function kl(e){const t=e.detailJobId?e.jobs.find(i=>i.id===e.detailJobId)??null:null,n=e.newEventModalOpen||!!e.editJobId;return l`
3234
3233
  ${_w(e)}
3235
- ${n?Pw(e):w}
3236
- ${t?Rw(t,e):w}
3237
- ${e.runModalJobId?Dw(e):w}
3238
- `}function Tw(e){const t=e.status,n=(t==null?void 0:t.enabled)??!1,i=e.jobs.length,s=t==null?void 0:t.nextWakeAtMs;return l`
3234
+ ${Mw(e)}
3235
+ ${n?Iw(e):w}
3236
+ ${t?Dw(t,e):w}
3237
+ ${e.runModalJobId?Bw(e):w}
3238
+ `}function _w(e){const t=e.status,n=(t==null?void 0:t.enabled)??!1,i=e.jobs.length,s=t==null?void 0:t.nextWakeAtMs;return l`
3239
3239
  <div class="event-status-bar">
3240
3240
  <div class="event-status-bar__info">
3241
3241
  <span class="statusDot ${n?"ok":""}"></span>
@@ -3257,14 +3257,14 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3257
3257
  ${e.error?l`<span class="muted">${e.error}</span>`:w}
3258
3258
  </div>
3259
3259
  <button class="btn primary btn--sm" @click=${e.onNewEventModalOpen}>
3260
- ${wu} New Event
3260
+ ${ku} New Event
3261
3261
  </button>
3262
3262
  </div>
3263
- `}function _w(e){return e.jobs.length===0?l`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:l`
3263
+ `}function Mw(e){return e.jobs.length===0?l`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:l`
3264
3264
  <div class="event-grid">
3265
- ${e.jobs.map(t=>Mw(t,e))}
3265
+ ${e.jobs.map(t=>Pw(t,e))}
3266
3266
  </div>
3267
- `}function Mw(e,t){return l`
3267
+ `}function Pw(e,t){return l`
3268
3268
  <div
3269
3269
  class="event-card ${e.enabled?"":"disabled"}"
3270
3270
  @click=${()=>t.onDetailOpen(e)}
@@ -3275,12 +3275,12 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3275
3275
  ${e.enabled?"On":"Off"}
3276
3276
  </span>
3277
3277
  </div>
3278
- <div class="event-card__schedule">${bu(e)}</div>
3279
- ${e.agentId?l`<div class="event-card__agent">${xw(e.agentId)}</div>`:w}
3278
+ <div class="event-card__schedule">${wu(e)}</div>
3279
+ ${e.agentId?l`<div class="event-card__agent">${$w(e.agentId)}</div>`:w}
3280
3280
  ${wl(e)?l`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${wl(e)}</div>`:w}
3281
3281
  <div class="event-card__footer">
3282
3282
  <div class="event-card__status">
3283
- <span class="muted" style="font-size: 11px;">${vu(e)}</span>
3283
+ <span class="muted" style="font-size: 11px;">${bu(e)}</span>
3284
3284
  </div>
3285
3285
  <div class="event-card__actions" @click=${n=>n.stopPropagation()}>
3286
3286
  <button
@@ -3289,7 +3289,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3289
3289
  ?disabled=${t.busy}
3290
3290
  @click=${()=>t.onToggle(e,!e.enabled)}
3291
3291
  >
3292
- ${e.enabled?Sw:$w}
3292
+ ${e.enabled?Aw:Sw}
3293
3293
  </button>
3294
3294
  <button
3295
3295
  class="btn-icon"
@@ -3297,7 +3297,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3297
3297
  ?disabled=${t.busy}
3298
3298
  @click=${()=>t.onRun(e)}
3299
3299
  >
3300
- ${Cw}
3300
+ ${Ew}
3301
3301
  </button>
3302
3302
  ${t.pendingDeleteId===e.id?l`<button
3303
3303
  class="btn danger btn--sm"
@@ -3308,11 +3308,11 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3308
3308
  title="Delete"
3309
3309
  ?disabled=${t.busy}
3310
3310
  @click=${()=>{t.onArmDelete(e.id),be&&clearTimeout(be),be=setTimeout(()=>{t.onArmDelete(""),be=null},3e3)}}
3311
- >${Aw}</button>`}
3311
+ >${Cw}</button>`}
3312
3312
  </div>
3313
3313
  </div>
3314
3314
  </div>
3315
- `}function Pw(e){const t=!!e.editJobId,n=bw(e),i=()=>{e.onNewEventModalClose()};return l`
3315
+ `}function Iw(e){const t=!!e.editJobId,n=ww(e),i=()=>{e.onNewEventModalClose()};return l`
3316
3316
  <div class="event-modal-overlay" @click=${i}>
3317
3317
  <div class="event-modal" @click=${s=>s.stopPropagation()}>
3318
3318
  <div class="event-modal__header">
@@ -3370,7 +3370,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3370
3370
  </label>
3371
3371
  </div>
3372
3372
 
3373
- ${Lw(e)}
3373
+ ${Rw(e)}
3374
3374
 
3375
3375
  <div class="form-grid" style="margin-top: 12px;">
3376
3376
  <label class="field">
@@ -3432,7 +3432,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3432
3432
  @change=${s=>e.onFormChange({channel:s.target.value})}
3433
3433
  >
3434
3434
  ${n.map(s=>l`<option value=${s}>
3435
- ${ww(e,s)}
3435
+ ${kw(e,s)}
3436
3436
  </option>`)}
3437
3437
  </select>
3438
3438
  </label>
@@ -3445,7 +3445,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3445
3445
  />
3446
3446
  </label>
3447
3447
  </div>
3448
- ${Iw(e)}
3448
+ ${Lw(e)}
3449
3449
  <div class="form-grid" style="margin-top: 12px;">
3450
3450
  <label class="field">
3451
3451
  <span>Timeout (seconds)</span>
@@ -3476,7 +3476,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3476
3476
  </div>
3477
3477
  </div>
3478
3478
  </div>
3479
- `}function Iw(e){const t=e.form.recipients;return l`
3479
+ `}function Lw(e){const t=e.form.recipients;return l`
3480
3480
  <div style="margin-top: 8px;">
3481
3481
  <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
3482
3482
  <span style="font-size: 13px; color: var(--muted);">Recipients</span>
@@ -3484,7 +3484,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3484
3484
  class="btn btn--sm"
3485
3485
  @click=${()=>{e.onFormChange({recipients:[...t,""]})}}
3486
3486
  >
3487
- ${wu} Add
3487
+ ${ku} Add
3488
3488
  </button>
3489
3489
  </div>
3490
3490
  ${t.length===0&&!e.form.toAdmins?l`<div class="muted" style="font-size: 12px; padding: 4px 0;">No recipients. Add a phone number or enable "All admins".</div>`:w}
@@ -3506,7 +3506,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3506
3506
  </div>
3507
3507
  `)}
3508
3508
  </div>
3509
- `}function Lw(e){const t=e.form;return t.scheduleKind==="at"?l`
3509
+ `}function Rw(e){const t=e.form;return t.scheduleKind==="at"?l`
3510
3510
  <label class="field" style="margin-top: 12px;">
3511
3511
  <span>Run at</span>
3512
3512
  <input
@@ -3555,7 +3555,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3555
3555
  />
3556
3556
  </label>
3557
3557
  </div>
3558
- `}function Rw(e,t){var n;return l`
3558
+ `}function Dw(e,t){var n;return l`
3559
3559
  <div class="event-modal-overlay" @click=${t.onDetailClose}>
3560
3560
  <div class="event-modal" @click=${i=>i.stopPropagation()}>
3561
3561
  <div class="event-modal__header">
@@ -3573,7 +3573,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3573
3573
  ?disabled=${t.busy}
3574
3574
  @click=${()=>t.onEdit(e)}
3575
3575
  >
3576
- ${Ew} Edit
3576
+ ${Tw} Edit
3577
3577
  </button>
3578
3578
  <button
3579
3579
  class="btn"
@@ -3609,7 +3609,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3609
3609
  </div>
3610
3610
  <div class="event-detail-row">
3611
3611
  <span class="event-detail-label">Schedule</span>
3612
- <span class="event-detail-value">${bu(e)}</span>
3612
+ <span class="event-detail-value">${wu(e)}</span>
3613
3613
  </div>
3614
3614
  ${e.agentId?l`
3615
3615
  <div class="event-detail-row">
@@ -3631,12 +3631,12 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3631
3631
  </div>
3632
3632
  <div class="event-detail-row" style="flex-direction: column; align-items: stretch; gap: 4px;">
3633
3633
  <span class="event-detail-label">Action</span>
3634
- <span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${vw(e,!1)}</span>
3634
+ <span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${bw(e,!1)}</span>
3635
3635
  </div>
3636
3636
  ${e.payload.kind==="agentTurn"&&e.payload.to?l`
3637
3637
  <div class="event-detail-row">
3638
3638
  <span class="event-detail-label">Send to</span>
3639
- <span class="event-detail-value mono">${kw(e.payload.to)}</span>
3639
+ <span class="event-detail-value mono">${xw(e.payload.to)}</span>
3640
3640
  </div>
3641
3641
  `:w}
3642
3642
  ${e.payload.kind==="agentTurn"&&(e.payload.channel??e.payload.provider)?l`
@@ -3656,12 +3656,12 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3656
3656
  <div class="event-detail-section">
3657
3657
  <div class="event-detail-row">
3658
3658
  <span class="event-detail-label">Last run</span>
3659
- <span class="event-detail-value">${vu(e)}</span>
3659
+ <span class="event-detail-value">${bu(e)}</span>
3660
3660
  </div>
3661
3661
  ${(n=e.state)!=null&&n.nextRunAtMs?l`
3662
3662
  <div class="event-detail-row">
3663
3663
  <span class="event-detail-label">Next run</span>
3664
- <span class="event-detail-value">${mw(e.state.nextRunAtMs)}</span>
3664
+ <span class="event-detail-value">${yw(e.state.nextRunAtMs)}</span>
3665
3665
  </div>
3666
3666
  `:w}
3667
3667
  </div>
@@ -3672,14 +3672,14 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3672
3672
  </div>
3673
3673
  ${t.runs.length===0?l`<div class="muted" style="font-size: 13px;">No runs recorded yet.</div>`:l`
3674
3674
  <div class="list">
3675
- ${[...t.runs].sort((i,s)=>s.ts-i.ts).map(i=>Nw(i))}
3675
+ ${[...t.runs].sort((i,s)=>s.ts-i.ts).map(i=>Ow(i))}
3676
3676
  </div>
3677
3677
  `}
3678
3678
  </div>
3679
3679
 
3680
3680
  </div>
3681
3681
  </div>
3682
- `}function Dw(e){const t=e.runResult,n=!t,i=(t==null?void 0:t.status)==="ok"?"Completed":(t==null?void 0:t.status)==="error"?"Error":(t==null?void 0:t.status)==="skipped"?"Skipped":(t==null?void 0:t.status)??"";return l`
3682
+ `}function Bw(e){const t=e.runResult,n=!t,i=(t==null?void 0:t.status)==="ok"?"Completed":(t==null?void 0:t.status)==="error"?"Error":(t==null?void 0:t.status)==="skipped"?"Skipped":(t==null?void 0:t.status)??"";return l`
3683
3683
  <div class="event-modal-overlay" @click=${e.onRunModalClose}>
3684
3684
  <div class="event-modal" style="max-width: 480px;" @click=${s=>s.stopPropagation()}>
3685
3685
  <div class="event-modal__header">
@@ -3724,10 +3724,10 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3724
3724
  `}
3725
3725
  </div>
3726
3726
  </div>
3727
- `}function Bw(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"||t==="skipped"?"chip chip-warn":"chip"}function Nw(e){return l`
3727
+ `}function Nw(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"||t==="skipped"?"chip chip-warn":"chip"}function Ow(e){return l`
3728
3728
  <div class="list-item" style="grid-template-columns: 1fr; gap: 6px;">
3729
3729
  <div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
3730
- <span class=${Bw(e.status)} style="font-size: 11px; padding: 2px 8px;">
3730
+ <span class=${Nw(e.status)} style="font-size: 11px; padding: 2px 8px;">
3731
3731
  ${e.status}
3732
3732
  </span>
3733
3733
  <span class="muted" style="font-size: 12px;">${os(e.ts)}</span>
@@ -3741,7 +3741,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3741
3741
  </details>
3742
3742
  `:w}
3743
3743
  </div>
3744
- `}function Ow(e){var a;const t=((a=e.report)==null?void 0:a.skills)??[],n=e.filter.trim().toLowerCase(),i=e.typeFilter,s=t.filter(r=>i==="preloaded"&&!r.preloaded||i==="user"&&r.preloaded?!1:n?[r.name,r.description].join(" ").toLowerCase().includes(n):!0),o=(r,u)=>l`
3744
+ `}function Fw(e){var a;const t=((a=e.report)==null?void 0:a.skills)??[],n=e.filter.trim().toLowerCase(),i=e.typeFilter,s=t.filter(r=>i==="preloaded"&&!r.preloaded||i==="user"&&r.preloaded?!1:n?[r.name,r.description].join(" ").toLowerCase().includes(n):!0),o=(r,u)=>l`
3745
3745
  <button
3746
3746
  class="chip ${i===u?"chip-ok":""}"
3747
3747
  style="cursor: pointer; border: none; background: ${i===u?"var(--accent, #3b82f6)":"var(--bg-hover, rgba(255,255,255,0.06))"}; color: ${i===u?"#fff":"var(--text)"}; padding: 4px 10px; border-radius: 4px; font-size: 12px;"
@@ -3783,25 +3783,31 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3783
3783
 
3784
3784
  ${s.length===0?l`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:l`
3785
3785
  <div class="list" style="margin-top: 16px;">
3786
- ${s.map(r=>Fw(r,e))}
3786
+ ${s.map(r=>Uw(r,e))}
3787
3787
  </div>
3788
3788
  `}
3789
3789
  </section>
3790
3790
 
3791
- ${e.detail?Uw(e):w}
3792
- ${e.addModal?Ww(e):w}
3793
- `}function Fw(e,t){const n=t.busyKey===e.skillKey,i=t.edits[e.skillKey]??"",s=t.messages[e.skillKey]??null,o=e.install.length>0&&e.missing.bins.length>0,a=[...e.missing.bins.map(u=>`bin:${u}`),...e.missing.env.map(u=>`env:${u}`),...e.missing.config.map(u=>`config:${u}`),...e.missing.os.map(u=>`os:${u}`)],r=[];return e.disabled&&r.push("disabled"),e.blockedByAllowlist&&r.push("blocked by allowlist"),l`
3791
+ ${e.detail?Ww(e):w}
3792
+ ${e.addModal?Kw(e):w}
3793
+ `}function Uw(e,t){const n=t.busyKey===e.skillKey,i=t.edits[e.skillKey]??"",s=t.messages[e.skillKey]??null,o=e.install.length>0&&e.missing.bins.length>0,a=[...e.missing.bins.map(u=>`bin:${u}`),...e.missing.env.map(u=>`env:${u}`),...e.missing.config.map(u=>`config:${u}`),...e.missing.os.map(u=>`os:${u}`)],r=[];return e.disabled&&r.push("disabled"),e.blockedByAllowlist&&r.push("blocked by allowlist"),l`
3794
3794
  <div class="list-item" style="cursor: pointer;" @click=${()=>t.onViewDetail(e.name)}>
3795
3795
  <div class="list-main">
3796
3796
  <div class="list-title">
3797
3797
  ${e.emoji?`${e.emoji} `:""}${e.name}
3798
3798
  </div>
3799
- <div class="list-sub">${Bp(e.description,140)}</div>
3799
+ <div class="list-sub">${Np(e.description,140)}</div>
3800
3800
  <div class="chip-row" style="margin-top: 6px;">
3801
3801
  <span class="chip ${e.preloaded?"chip-ok":""}">
3802
3802
  ${e.preloaded?"Preloaded":"User"}
3803
3803
  </span>
3804
3804
  ${e.disabled?l`<span class="chip chip-warn">Disabled</span>`:w}
3805
+ ${e.preloaded?w:l`<span
3806
+ class="chip ${e.alwaysActive?"chip-ok":""}"
3807
+ style="cursor: pointer; user-select: none;"
3808
+ title=${e.alwaysActive?"This skill is part of every conversation. Click to switch to on-demand.":"This skill loads only when relevant. Click to make it always active."}
3809
+ @click=${u=>{u.stopPropagation(),t.onAlwaysActiveToggle(e.name,!e.alwaysActive)}}
3810
+ >${e.alwaysActive?"Always active":"On demand"}</span>`}
3805
3811
  </div>
3806
3812
  ${a.length>0?l`
3807
3813
  <div class="muted" style="margin-top: 6px;">
@@ -3871,7 +3877,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3871
3877
  `:w}
3872
3878
  </div>
3873
3879
  </div>
3874
- `}function Uw(e){var u,c,h;const t=e.detail,n=["SKILL.md",...t.references.map(d=>d.name)],i=e.detailTab||"SKILL.md",s=i==="SKILL.md"?t.content:((u=t.references.find(d=>d.name===i))==null?void 0:u.content)??"",o=d=>{d.target.classList.contains("event-modal-overlay")&&e.onDetailClose()},a=(h=(c=e.report)==null?void 0:c.skills)==null?void 0:h.find(d=>d.name===t.name),r=a?!a.preloaded:!1;return l`
3880
+ `}function Ww(e){var u,c,h;const t=e.detail,n=["SKILL.md",...t.references.map(d=>d.name)],i=e.detailTab||"SKILL.md",s=i==="SKILL.md"?t.content:((u=t.references.find(d=>d.name===i))==null?void 0:u.content)??"",o=d=>{d.target.classList.contains("event-modal-overlay")&&e.onDetailClose()},a=(h=(c=e.report)==null?void 0:c.skills)==null?void 0:h.find(d=>d.name===t.name),r=a?!a.preloaded:!1;return l`
3875
3881
  <div class="event-modal-overlay" @click=${o}>
3876
3882
  <div class="event-modal" style="width: min(720px, 100%);" @click=${d=>d.stopPropagation()}>
3877
3883
  <div class="event-modal__header">
@@ -3897,7 +3903,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3897
3903
  <pre style="white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.5; max-height: 60vh; overflow-y: auto; background: var(--bg, #111); padding: 16px; border-radius: 8px; border: 1px solid var(--border);">${s}</pre>
3898
3904
  </div>
3899
3905
  </div>
3900
- `}function Ww(e){const t=e.drafts.length>0,n=e.busyKey==="__add__",i=e.addForm.name.trim()!=="",s=e.formSource==="installed",o=r=>{r.target.classList.contains("event-modal-overlay")&&e.onAddClose()},a=i?s?`Edit Skill: ${e.addForm.name}`:`Edit Draft: ${e.addForm.name}`:"Skill Drafts";return l`
3906
+ `}function Kw(e){const t=e.drafts.length>0,n=e.busyKey==="__add__",i=e.addForm.name.trim()!=="",s=e.formSource==="installed",o=r=>{r.target.classList.contains("event-modal-overlay")&&e.onAddClose()},a=i?s?`Edit Skill: ${e.addForm.name}`:`Edit Draft: ${e.addForm.name}`:"Skill Drafts";return l`
3901
3907
  <div class="event-modal-overlay" @click=${o}>
3902
3908
  <div class="event-modal" style="width: min(620px, 100%);" @click=${r=>r.stopPropagation()}>
3903
3909
  <div class="event-modal__header">
@@ -3905,14 +3911,14 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3905
3911
  <button class="event-modal__close" @click=${e.onAddClose}>&times;</button>
3906
3912
  </div>
3907
3913
 
3908
- ${i?Kw(e,n):t?zw(e,n):l`
3914
+ ${i?zw(e,n):t?Hw(e,n):l`
3909
3915
  <div class="muted" style="text-align: center; padding: 32px 16px;">
3910
3916
  No drafts available. Ask your assistant to create a skill and it will appear here.
3911
3917
  </div>
3912
3918
  `}
3913
3919
  </div>
3914
3920
  </div>
3915
- `}function Kw(e,t){const n=e.addForm,s=e.formSource==="installed"?"Save Skill":"Save Draft",o=n.references.length>0,a=e.editTab||"SKILL.md",r=n.references.find(c=>c.name===a),u=c=>l`
3921
+ `}function zw(e,t){const n=e.addForm,s=e.formSource==="installed"?"Save Skill":"Save Draft",o=n.references.length>0,a=e.editTab||"SKILL.md",r=n.references.find(c=>c.name===a),u=c=>l`
3916
3922
  <button
3917
3923
  class="chip ${c===a?"chip-ok":""}"
3918
3924
  style="cursor: pointer; border: none; background: ${c===a?"var(--accent, #3b82f6)":"var(--bg-hover, rgba(255,255,255,0.06))"}; color: ${c===a?"#fff":"var(--text)"}; padding: 4px 10px; border-radius: 4px; font-size: 12px;"
@@ -3963,7 +3969,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3963
3969
  ${t?"Saving…":s}
3964
3970
  </button>
3965
3971
  </div>
3966
- `}function zw(e,t){return l`
3972
+ `}function Hw(e,t){return l`
3967
3973
  <div class="card-sub" style="margin-bottom: 16px;">
3968
3974
  Skills prepared by your assistant. Review, install, or delete.
3969
3975
  </div>
@@ -4004,7 +4010,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4004
4010
  </div>
4005
4011
  `})}
4006
4012
  </div>
4007
- `}const Hw=["user","assistant","tool_call","tool_result","thinking","error"],xl={user:"User",assistant:"Assistant",tool:"Tool",tool_call:"Call",tool_result:"Result",thinking:"Thinking",error:"Error",system:"System"};function ku(e,t){return e==="tool"?"tool_call":e==="tool_result"&&typeof t=="string"&&t.startsWith("[error]")?"error":e}function qw(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function jw(e){return e.split(":").slice(2).join(":")||e}function Gw(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName,e.toolCallId].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Vw(e,t){return`${e.sessionId}:${e.timestamp}:${t}`}const $l=300;function Qw(e,t){const n=ku(e.type,e.content);return t[n]??!0}function Jw(e){const t=e.filterText.trim().toLowerCase(),n=e.entries.filter(i=>!Qw(i,e.typeFilters)||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:Gw(i,t));return l`
4013
+ `}const qw=["user","assistant","tool_call","tool_result","thinking","error"],xl={user:"User",assistant:"Assistant",tool:"Tool",tool_call:"Call",tool_result:"Result",thinking:"Thinking",error:"Error",system:"System"};function xu(e,t){return e==="tool"?"tool_call":e==="tool_result"&&typeof t=="string"&&t.startsWith("[error]")?"error":e}function jw(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Gw(e){return e.split(":").slice(2).join(":")||e}function Vw(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName,e.toolCallId].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Qw(e,t){return`${e.sessionId}:${e.timestamp}:${t}`}const $l=300;function Jw(e,t){const n=xu(e.type,e.content);return t[n]??!0}function Yw(e){const t=e.filterText.trim().toLowerCase(),n=e.entries.filter(i=>!Jw(i,e.typeFilters)||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:Vw(i,t));return l`
4008
4014
  <div>
4009
4015
  <button class="chips-toggle" style="margin-top: 10px;" @click=${e.onToggleChips}>
4010
4016
  <span class="chips-toggle-icon ${e.chipsExpanded?"expanded":""}">${L.chevronDown}</span>
@@ -4012,7 +4018,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4012
4018
  </button>
4013
4019
  ${e.chipsExpanded?l`
4014
4020
  <div class="chip-row" style="margin-top: 6px;">
4015
- ${Hw.map(i=>l`
4021
+ ${qw.map(i=>l`
4016
4022
  <label class="chip session-log-chip ${i}">
4017
4023
  <input
4018
4024
  type="checkbox"
@@ -4046,13 +4052,13 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4046
4052
  ${e.error?l`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:w}
4047
4053
 
4048
4054
  <div class="log-stream" style="margin-top: 10px;" @scroll=${e.onScroll}>
4049
- ${n.length===0?l`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map((i,s)=>{const o=ku(i.type,i.content),a=Vw(i,s),r=e.expandedIds.has(a),u=i.content.length>$l,c=r||!u?i.content:i.content.slice(0,$l)+"…";return l`
4055
+ ${n.length===0?l`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map((i,s)=>{const o=xu(i.type,i.content),a=Qw(i,s),r=e.expandedIds.has(a),u=i.content.length>$l,c=r||!u?i.content:i.content.slice(0,$l)+"…";return l`
4050
4056
  <div class="log-row session-entry ${o}">
4051
4057
  <div class="log-row-header">
4052
- <span class="log-time mono">${qw(i.timestamp)}</span>
4058
+ <span class="log-time mono">${jw(i.timestamp)}</span>
4053
4059
  <span class="session-log-type ${o}">${xl[o]}</span>
4054
4060
  <span class="log-subsystem mono">${i.agentId}</span>
4055
- <span class="session-label mono">${jw(i.sessionKey)}</span>
4061
+ <span class="session-label mono">${Gw(i.sessionKey)}</span>
4056
4062
  ${i.toolName?l`<span class="session-tool mono">${i.toolName}</span>`:w}
4057
4063
  ${i.toolCallId?l`<span class="session-call-id mono">${i.toolCallId.slice(0,12)}</span>`:w}
4058
4064
  ${i.model?l`<span class="session-model mono">${i.model}</span>`:w}
@@ -4066,7 +4072,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4066
4072
  `})}
4067
4073
  </div>
4068
4074
  </div>
4069
- `}const Ko=["trace","debug","info","warn","error","fatal"];function Yw(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function xu(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Xw(e){const t=!e.isAdmin||e.logsSubTab==="session";return l`
4075
+ `}const Ko=["trace","debug","info","warn","error","fatal"];function Xw(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function $u(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Zw(e){const t=!e.isAdmin||e.logsSubTab==="session";return l`
4070
4076
  <section class="card">
4071
4077
  <div class="logs-toolbar">
4072
4078
  <div class="sp-tabs" style="margin: 0;">
@@ -4117,7 +4123,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4117
4123
  <button
4118
4124
  class="btn btn-sm"
4119
4125
  ?disabled=${e.entries.length===0}
4120
- @click=${()=>{const n=e.filterText.trim().toLowerCase(),i=Ko.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:xu(a,n)),o=n||i?"filtered":"visible";e.onExport(s.map(a=>a.raw),o)}}
4126
+ @click=${()=>{const n=e.filterText.trim().toLowerCase(),i=Ko.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:$u(a,n)),o=n||i?"filtered":"visible";e.onExport(s.map(a=>a.raw),o)}}
4121
4127
  >
4122
4128
  Export
4123
4129
  </button>
@@ -4125,9 +4131,9 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4125
4131
  </div>
4126
4132
  </div>
4127
4133
 
4128
- ${t?Jw(e.sessionLogsProps):Zw(e)}
4134
+ ${t?Yw(e.sessionLogsProps):ek(e)}
4129
4135
  </section>
4130
- `}function Zw(e){const t=e.filterText.trim().toLowerCase();Ko.some(i=>!e.levelFilters[i]);const n=e.entries.filter(i=>i.level&&!e.levelFilters[i.level]?!1:xu(i,t));return l`
4136
+ `}function ek(e){const t=e.filterText.trim().toLowerCase();Ko.some(i=>!e.levelFilters[i]);const n=e.entries.filter(i=>i.level&&!e.levelFilters[i.level]?!1:$u(i,t));return l`
4131
4137
  <button class="chips-toggle" @click=${e.onToggleChips}>
4132
4138
  <span class="chips-toggle-icon ${e.chipsExpanded?"expanded":""}">${L.chevronDown}</span>
4133
4139
  Filters
@@ -4165,7 +4171,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4165
4171
  ${n.length===0?l`<div class="muted" style="padding: 12px;">No log entries.</div>`:[...n].reverse().map(i=>l`
4166
4172
  <div class="log-row">
4167
4173
  <div class="log-row-header">
4168
- <span class="log-time mono">${Yw(i.time)}</span>
4174
+ <span class="log-time mono">${Xw(i.time)}</span>
4169
4175
  <span class="log-level ${i.level??""}">${i.level??""}</span>
4170
4176
  <span class="log-subsystem mono">${i.subsystem??""}</span>
4171
4177
  </div>
@@ -4173,13 +4179,13 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4173
4179
  </div>
4174
4180
  `)}
4175
4181
  </div>
4176
- `}const ek=[{key:"monday",label:"Monday"},{key:"tuesday",label:"Tuesday"},{key:"wednesday",label:"Wednesday"},{key:"thursday",label:"Thursday"},{key:"friday",label:"Friday"},{key:"saturday",label:"Saturday"},{key:"sunday",label:"Sunday"}],tk=l`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,nk=l`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`;function ik(e){return l`
4177
- ${sk(e)}
4182
+ `}const tk=[{key:"monday",label:"Monday"},{key:"tuesday",label:"Tuesday"},{key:"wednesday",label:"Wednesday"},{key:"thursday",label:"Thursday"},{key:"friday",label:"Friday"},{key:"saturday",label:"Saturday"},{key:"sunday",label:"Sunday"}],nk=l`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,ik=l`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`;function sk(e){return l`
4178
4183
  ${ok(e)}
4179
4184
  ${ak(e)}
4180
- ${lk(e)}
4185
+ ${rk(e)}
4181
4186
  ${ck(e)}
4182
- `}function sk(e){return l`
4187
+ ${dk(e)}
4188
+ `}function ok(e){return l`
4183
4189
  <label class="field checkbox" style="margin: 16px 0;">
4184
4190
  <input
4185
4191
  type="checkbox"
@@ -4193,7 +4199,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4193
4199
  </span>
4194
4200
  </span>
4195
4201
  </label>
4196
- `}function ok(e){const t=e.form.enabled;return l`
4202
+ `}function ak(e){const t=e.form.enabled;return l`
4197
4203
  <label
4198
4204
  class="field checkbox"
4199
4205
  style="margin: 0 0 16px; ${t?"":"opacity: 0.4; pointer-events: none;"}"
@@ -4211,14 +4217,14 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4211
4217
  </span>
4212
4218
  </span>
4213
4219
  </label>
4214
- `}function ak(e){return l`
4220
+ `}function rk(e){return l`
4215
4221
  <div style="margin-bottom: 20px;">
4216
4222
  <div style="font-size: 14px; font-weight: 500; margin-bottom: 12px;">Weekly Schedule</div>
4217
4223
  <div class="oh-schedule">
4218
- ${ek.map(t=>rk(t,e))}
4224
+ ${tk.map(t=>lk(t,e))}
4219
4225
  </div>
4220
4226
  </div>
4221
- `}function rk(e,t){const n=t.form.days[e.key];if(!n)return w;const i=n.closed;return l`
4227
+ `}function lk(e,t){const n=t.form.days[e.key];if(!n)return w;const i=n.closed;return l`
4222
4228
  <div class="oh-day-row">
4223
4229
  <div class="oh-day-label">${e.label}</div>
4224
4230
  <div class="oh-day-times" style="${i?"opacity: 0.35; pointer-events: none;":""}">
@@ -4243,7 +4249,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4243
4249
  <span>Closed</span>
4244
4250
  </label>
4245
4251
  </div>
4246
- `}let wi="";function lk(e){const t=e.form.closedDates;return l`
4252
+ `}let wi="";function ck(e){const t=e.form.closedDates;return l`
4247
4253
  <div style="margin-bottom: 20px;">
4248
4254
  <div style="font-size: 14px; font-weight: 500; margin-bottom: 10px;">Closed Dates</div>
4249
4255
  <div style="display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;">
@@ -4255,7 +4261,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4255
4261
  style="width: 16px; height: 16px; padding: 0;"
4256
4262
  @click=${()=>e.onRemoveClosedDate(n)}
4257
4263
  >
4258
- ${tk}
4264
+ ${nk}
4259
4265
  </button>
4260
4266
  </span>
4261
4267
  `)}
@@ -4271,11 +4277,11 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4271
4277
  class="btn btn--sm"
4272
4278
  @click=${()=>{if(wi){e.onAddClosedDate(wi);const n=document.getElementById("oh-new-closed-date");n&&(n.value=""),wi=""}}}
4273
4279
  >
4274
- ${nk} Add
4280
+ ${ik} Add
4275
4281
  </button>
4276
4282
  </div>
4277
4283
  </div>
4278
- `}function ck(e){return l`
4284
+ `}function dk(e){return l`
4279
4285
  <div style="display: flex; justify-content: flex-end; padding-top: 8px;">
4280
4286
  <button
4281
4287
  class="btn primary"
@@ -4285,12 +4291,12 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4285
4291
  ${e.busy?"Saving…":"Save"}
4286
4292
  </button>
4287
4293
  </div>
4288
- `}const dk=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"opening-hours",label:"Opening Hours"},{id:"logs",label:"Logs"}];function uk(e){switch(e.activeTab){case"cron":return kl(e.cronProps);case"skills":return Ow(e.skillsProps);case"opening-hours":return ik(e.openingHoursProps);case"logs":return Xw(e.logsProps);default:return kl(e.cronProps)}}function pk(e){return e.connected?l`
4294
+ `}const uk=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"opening-hours",label:"Opening Hours"},{id:"logs",label:"Logs"}];function pk(e){switch(e.activeTab){case"cron":return kl(e.cronProps);case"skills":return Fw(e.skillsProps);case"opening-hours":return sk(e.openingHoursProps);case"logs":return Zw(e.logsProps);default:return kl(e.cronProps)}}function hk(e){return e.connected?l`
4289
4295
  <div class="setup-container">
4290
4296
  ${It("Advanced",e.wsProps)}
4291
4297
  <div class="setup-card sp-card-advanced" style="text-align: left;">
4292
4298
  <div class="sp-tabs">
4293
- ${dk.map(t=>l`
4299
+ ${uk.map(t=>l`
4294
4300
  <button
4295
4301
  class="sp-tab ${e.activeTab===t.id?"active":""}"
4296
4302
  @click=${()=>e.onTabChange(t.id)}
@@ -4299,7 +4305,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4299
4305
  </button>
4300
4306
  `)}
4301
4307
  </div>
4302
- ${uk(e)}
4308
+ ${pk(e)}
4303
4309
  </div>
4304
4310
  </div>
4305
4311
  `:l`
@@ -4309,7 +4315,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4309
4315
  <p>Connecting to gateway...</p>
4310
4316
  </div>
4311
4317
  </div>
4312
- `}function Sl(e){if(!e.show)return w;const t=Qe(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const a=v=>{var S;o=v.target.value;const $=(S=v.target.closest(".login-card"))==null?void 0:S.querySelector(".login-change-pin");$&&($.style.display=o==="__master__"?"":"none")},r=v=>$=>{const S=$.target;S.value=S.value.replace(/\D/g,"").slice(0,6),v(S.value)},u=v=>{const $=v.currentTarget,S=$.closest(".login-pin-wrapper"),M=S==null?void 0:S.querySelector("input");if(!M)return;const y=M.type==="text";M.type=y?"password":"text",$.classList.toggle("active",!y)},c=!n&&e.accounts.length>1?l`
4318
+ `}function Sl(e){if(!e.show)return w;const t=Xe(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const a=v=>{var S;o=v.target.value;const $=(S=v.target.closest(".login-card"))==null?void 0:S.querySelector(".login-change-pin");$&&($.style.display=o==="__master__"?"":"none")},r=v=>$=>{const S=$.target;S.value=S.value.replace(/\D/g,"").slice(0,6),v(S.value)},u=v=>{const $=v.currentTarget,S=$.closest(".login-pin-wrapper"),M=S==null?void 0:S.querySelector("input");if(!M)return;const y=M.type==="text";M.type=y?"password":"text",$.classList.toggle("active",!y)},c=!n&&e.accounts.length>1?l`
4313
4319
  <select
4314
4320
  class="login-account-select"
4315
4321
  @change=${a}
@@ -4463,7 +4469,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4463
4469
  </p>`:w}
4464
4470
  </div>
4465
4471
  </div>
4466
- `}function hk(e){if(!e.connected)return l`
4472
+ `}function fk(e){if(!e.connected)return l`
4467
4473
  <div class="setup-container">
4468
4474
  <div class="setup-card">
4469
4475
  <div class="setup-spinner"></div>
@@ -4476,10 +4482,10 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4476
4482
  <span class="public-chat-header__name">${n}</span>
4477
4483
  </div>
4478
4484
  <div class="chat-viewport">
4479
- ${gu(t)}
4485
+ ${mu(t)}
4480
4486
  </div>
4481
4487
  </div>
4482
- `}async function fk(e){if(!(!e.client||!e.connected)&&!e.agentsLoading){e.agentsLoading=!0,e.agentsError=null;try{const t=await e.client.request("agents.list",{});t&&(e.agentsList=t)}catch(t){e.agentsError=String(t)}finally{e.agentsLoading=!1}}}async function Vn(e){if(!(!e.client||!e.connected)&&!e.workspacesLoading){e.workspacesLoading=!0,e.workspacesError=null;try{const t=await e.client.request("workspaces.list",{});e.workspaces=t.workspaces}catch(t){e.workspacesError=String(t)}finally{e.workspacesLoading=!1}}}async function gk(e,t){var i,s;if(!e.client||!e.connected||e.workspaceSaving)return;const n=t.name.trim();if(!n){e.workspacesError="Account name is required.";return}e.workspaceSaving=!0,e.workspacesError=null;try{const o=await e.client.request("config.get",{});e.configSnapshot=o;const a=o.hash;if(!a){e.workspacesError="Config hash missing; reload and retry.";return}const r={name:n,baseHash:a,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(r.workspaceDir=t.workspacePath.trim());const u=await e.client.request("workspaces.create",r);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await Vn(e),(s=t.onCreated)==null||s.call(t,u)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function mk(e,t){if(!(!e.client||!e.connected)&&!e.workspaceSaving){e.workspaceSaving=!0,e.workspacesError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=n.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:i}),e.workspaceRemoveConfirm=null,await Vn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function yk(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:s}),await Vn(e)}catch(i){e.workspacesError=String(i)}}}const ki=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:gk,loadWorkspaces:Vn,removeWorkspace:mk,renameWorkspace:yk},Symbol.toStringTag,{value:"Module"})),$u={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"taskmaster-control-ui",SETUP_UI:"setup-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"taskmaster-macos",IOS_APP:"taskmaster-ios",ANDROID_APP:"taskmaster-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"taskmaster-probe",PUBLIC_CHAT:"public-chat"},Al=$u,zo={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values($u));new Set(Object.values(zo));function vk(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),i=e.token??"",s=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),i];return t==="v2"&&s.push(e.nonce??""),s.join("|")}const bk=4008;class wk{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{var i,s;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(s=(i=this.opts).onClose)==null||s.call(i,{code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){var d;if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=this.opts.role??"operator",n=this.opts.scopes??["operator.admin","operator.approvals","operator.pairing"],s=!(t!=="operator")&&typeof crypto<"u"&&!!crypto.subtle;let o=null,a=!1,r=this.opts.token;if(s){o=await rf();const p=(d=df({deviceId:o.deviceId,role:t}))==null?void 0:d.token;r=p??this.opts.token,a=!!(p&&this.opts.token)}const u=r||this.opts.password?{token:r,password:this.opts.password}:void 0;let c;if(s&&o){const p=Date.now(),v=this.connectNonce??void 0,$=vk({deviceId:o.deviceId,clientId:this.opts.clientName??Al.CONTROL_UI,clientMode:this.opts.mode??zo.WEBCHAT,role:t,scopes:n,signedAtMs:p,token:r??null,nonce:v}),S=await lf(o.privateKey,$);c={id:o.deviceId,publicKey:o.publicKey,signature:S,signedAt:p,nonce:v}}const h={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Al.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??zo.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:c,caps:[],auth:u,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",h).then(p=>{var v,$,S;(v=p==null?void 0:p.auth)!=null&&v.deviceToken&&o&&uf({deviceId:o.deviceId,role:p.auth.role??t,token:p.auth.deviceToken,scopes:p.auth.scopes??[]}),this.backoffMs=800,(S=($=this.opts).onHello)==null||S.call($,p)}).catch(()=>{var p;a&&o&&pf({deviceId:o.deviceId,role:t}),(p=this.ws)==null||p.close(bk,"connect failed")})}handleMessage(t){var s,o,a,r,u,c;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const h=n;if(h.event==="connect.challenge"){const p=h.payload,v=p&&typeof p.nonce=="string"?p.nonce:null;v&&(this.connectNonce=v,this.sendConnect());return}const d=typeof h.seq=="number"?h.seq:null;d!==null&&(this.lastSeq!==null&&d>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:d})),this.lastSeq=d);try{(r=(a=this.opts).onEvent)==null||r.call(a,h)}catch(p){console.error("[gateway] event handler error:",p)}return}if(i.type==="res"){const h=n,d=this.pending.get(h.id);if(!d)return;if(this.pending.delete(h.id),h.ok)d.resolve(h.payload);else{const p=new Error(((u=h.error)==null?void 0:u.message)??"request failed");p.payload=h.payload,p.details=(c=h.error)==null?void 0:c.details,d.reject(p)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=as(),s={type:"req",id:i,method:t,params:n},o=new Promise((a,r)=>{this.pending.set(i,{resolve:u=>a(u),reject:r})});return this.ws.send(JSON.stringify(s)),o}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ho(e){return typeof e=="object"&&e!==null}function kk(e){if(!Ho(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ho(n))return null;const i=typeof n.command=="string"?n.command.trim():"";if(!i)return null;const s=typeof e.createdAtMs=="number"?e.createdAtMs:0,o=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!s||!o?null:{id:t,request:{command:i,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:s,expiresAtMs:o}}function xk(e){if(!Ho(e))return null;const t=typeof e.id=="string"?e.id.trim():"";return t?{id:t,decision:typeof e.decision=="string"?e.decision:null,resolvedBy:typeof e.resolvedBy=="string"?e.resolvedBy:null,ts:typeof e.ts=="number"?e.ts:null}:null}function Su(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function $k(e,t){const n=Su(e).filter(i=>i.id!==t.id);return n.push(t),n}function Cl(e,t){return Su(e).filter(n=>n.id!==t)}class Sk{constructor(){this.canvas=null,this.ctx=null,this.img=new Image,this.pendingFrame=null,this.rafId=null,this.deviceWidth=1280,this.deviceHeight=720,this.lastMouseMoveAt=0,this.MOUSE_THROTTLE_MS=30}attach(t){this.canvas=t,this.ctx=t.getContext("2d")}detach(){this.rafId!=null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.canvas=null,this.ctx=null,this.pendingFrame=null}updateFrame(t,n){if(n!=null&&n.deviceWidth&&(this.deviceWidth=n.deviceWidth),n!=null&&n.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,!this.canvas){const i=document.getElementById("browser-screencast-canvas");i&&this.attach(i)}this.rafId==null&&(this.rafId=requestAnimationFrame(()=>this.renderFrame()))}renderFrame(){this.rafId=null;const t=this.pendingFrame;!t||!this.canvas||!this.ctx||(this.pendingFrame=null,this.img.onload=()=>{!this.canvas||!this.ctx||((this.canvas.width!==this.img.width||this.canvas.height!==this.img.height)&&(this.canvas.width=this.img.width,this.canvas.height=this.img.height),this.ctx.drawImage(this.img,0,0))},this.img.src=`data:image/jpeg;base64,${t}`)}translateCoordinates(t,n){if(!this.canvas)return{x:t,y:n};const i=this.canvas.getBoundingClientRect(),s=this.canvas.width/i.width,o=this.canvas.height/i.height,a=this.deviceWidth/this.canvas.width,r=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*a),y:Math.round(n*o*r)}}shouldThrottleMouseMove(){const t=performance.now();return t-this.lastMouseMoveAt<this.MOUSE_THROTTLE_MS?!0:(this.lastMouseMoveAt=t,!1)}getDeviceDimensions(){return{width:this.deviceWidth,height:this.deviceHeight}}}let uo=null;function Bn(){return uo||(uo=new Sk),uo}function Oa(e){return e instanceof Error?e.message:String(e)}async function Ak(e){if(!e.client){console.error("[browser] startScreencast: no client"),e.browserError="Not connected to gateway";return}if(!e.connected){console.error("[browser] startScreencast: client exists but not connected"),e.browserError="Not connected to gateway";return}console.log("[browser] startScreencast: sending request"),e.browserLoading=!0,e.browserError=null;try{const t=await e.client.request("browser.screencast.start",{quality:60,maxWidth:1280,maxHeight:720});console.log("[browser] startScreencast response:",t),t!=null&&t.ok?e.browserScreencastActive=!0:(console.warn("[browser] startScreencast: response did not have ok=true",t),e.browserError="Screencast start failed (no ok in response)")}catch(t){console.error("[browser] startScreencast error:",t),e.browserError=Oa(t)}finally{e.browserLoading=!1}}async function Ck(e){if(!(!e.client||!e.connected)){e.browserLoading=!0,e.browserFullscreen=!1;try{await e.client.request("browser.screencast.stop",{}),e.browserScreencastActive=!1,e.browserScreencastFrame=null,e.browserScreencastMetadata=null}catch(t){e.browserError=Oa(t)}finally{e.browserLoading=!1}}}async function po(e,t,n,i,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:i,button:s??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function ho(e,t,n,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...i!=null&&i.text?{text:i.text}:{},...i!=null&&i.code?{code:i.code}:{},...i!=null&&i.modifiers?{modifiers:i.modifiers}:{}})}catch{}}async function Ek(e){if(!(!e.client||!e.connected))try{await e.client.request("browser.handoff.complete",{}),e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}catch(t){e.browserError=Oa(t)}}function Tk(e){e.browserInputMode=!e.browserInputMode}function _k(e){e.browserFullscreen=!e.browserFullscreen,Bn().detach()}function Mk(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,Bn().updateFrame(t.data,t.metadata)}function Pk(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function Ik(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function qo(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),i=n?{sessionKey:n}:{};try{const s=await e.client.request("agent.identity.get",i);if(!s)return;const o=bo(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function _i(e){return(await e.request("apikeys.list")).providers??[]}async function El(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function Lk(e,t){await e.request("apikeys.remove",{provider:t})}async function Rk(e,t,n){await e.request("apikeys.disable",{provider:t,disabled:n})}const ts="taskmaster_update_pending";async function Au(e){var t,n;if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("update.status",{});e.currentVersion=i.current,e.latestVersion=i.latest,e.updateAvailable=i.updateAvailable,e.updateMessage=i.updateAvailable?`v${i.latest} available`:"Up to date"}catch(i){e.updateMessage=`Check failed: ${String(i)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function Dk(e){var t,n,i,s;if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e);try{localStorage.setItem(ts,String(Date.now())),localStorage.removeItem(Fa)}catch{}try{const o=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(o.ok&&o.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(o.ok&&o.result.status==="skipped")Nn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw Nn(),new Error(o.result.reason||"Update failed")}catch(o){Nn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function Bk(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const a=t.name,r=t.index,u=t.total;e.updateMessage=`Updating: ${a} (${r+1}/${u})`;const c=e.updateProgressSteps.find(h=>h.index===r);c?(c.status="running",c.name=a):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:u,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const a=t.name,r=t.index,u=t.total,c=t.ok,h=t.durationMs,d=e.updateProgressSteps.find(v=>v.index===r);d?(d.status=c?"done":"failed",d.durationMs=h):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:u,status:c?"done":"failed",durationMs:h}];const p=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${a} done (${r+1}/${u})`:`Update step failed: ${a}${p}`,(s=e.requestUpdate)==null||s.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const r=t.reason;e.updateMessage=r?`Update failed: ${r}`:"Update failed",e.updateRunning=!1,Nn()}(o=e.requestUpdate)==null||o.call(e)}}async function Nk(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=Fk();Nn();try{const a=await e.client.request("update.lastResult",{});if(!a.ok||!a.result)return;const r=5*6e4,u=Date.now()-a.result.ts<r;if(!t&&!u||Uk(a.result.ts))return;e.updateLastResult=a.result;const c=(n=a.result.after)==null?void 0:n.version;if(a.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,a.result.status==="ok"){const h=(i=a.result.before)==null?void 0:i.version,d=c??a.result.currentVersion;e.updateMessage=h?`Updated: v${h} → v${d}`:`Updated to v${d}`}else{const h=a.result.reason??((s=a.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${h}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(o=e.requestUpdate)==null||o.call(e)}}const Fa="taskmaster_update_dismissed";function Ok(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Fa,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function Fk(){try{const e=localStorage.getItem(ts);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(ts),!1):!0:!1}catch{return!1}}function Nn(){try{localStorage.removeItem(ts)}catch{}}function Uk(e){try{const t=localStorage.getItem(Fa);return t?Number(t)>=e:!1}catch{return!1}}const Tl="notification-banner";function Wk(e){const t=document.getElementById(Tl);if(!e){t==null||t.remove();return}t&&t.remove();const n=document.createElement("div");n.id=Tl,Object.assign(n.style,{background:"rgba(255, 180, 50, 0.15)",border:"1px solid rgba(255, 180, 50, 0.3)",borderRadius:"8px",padding:"12px 16px",margin:"0 0 16px 0",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"12px",color:"rgba(255, 255, 255, 0.9)",fontSize:"14px"});const i=document.createElement("span");i.textContent=e.message,n.appendChild(i);const s=document.createElement("button");s.setAttribute("aria-label","Dismiss"),s.textContent="×",Object.assign(s.style,{background:"none",border:"none",color:"rgba(255, 255, 255, 0.7)",cursor:"pointer",fontSize:"18px",padding:"0 4px"}),s.addEventListener("click",()=>n.remove()),n.appendChild(s),(document.querySelector("main")??document.body).prepend(n)}function fo(e,t){var r,u,c;const n=(e??"").trim(),i=(r=t.mainSessionKey)==null?void 0:r.trim();if(!i)return n;if(!n)return i;const s=((u=t.mainKey)==null?void 0:u.trim())||"main",o=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===s||o&&(n===`agent:${o}:main`||n===`agent:${o}:${s}`)?i:n}function Kk(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=fo(e.sessionKey,t),i=fo(e.settings.sessionKey,t),s=fo(e.settings.lastActiveSessionKey,t),o=n||i||e.sessionKey,a={...e.settings,sessionKey:i||o,lastActiveSessionKey:s||o},r=a.sessionKey!==e.settings.sessionKey||a.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),r&&ot(e,a)}function De(e){var o;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;let t=null;const n=!!e.publicChat,i=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,s=n?"public-chat":i?"setup-ui":"taskmaster-control-ui";(o=e.client)==null||o.stop(),e.client=new wk({url:e.settings.gatewayUrl,token:n?void 0:e.settings.token.trim()?e.settings.token:void 0,password:n?void 0:e.password.trim()?e.password:void 0,clientName:s,mode:"webchat",role:n?"public":void 0,scopes:n?[]:void 0,onHello:a=>{var u,c;const r=((u=a.server)==null?void 0:u.version)??null;if(t!==null&&r!==null&&r!==t){window.location.reload();return}if(t===null&&(t=r),e.connected=!0,e.lastError=null,e.hello=a,n){_l(e,a),qo(e),(((c=e.publicChatConfig)==null?void 0:c.auth)??"anonymous")==="anonymous"&&Jk(e);return}zi()&&(wa(),e.uninstallDone=!1),_l(e,a),e.handleAccessCheck(),Nk(e).then(()=>{Au(e)}),qo(e),fk(e),(e.chatPage||e.setup)&&qk(e),da(e,{quiet:!0}),ca(e,{quiet:!0}),Vn(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Oe(e),e.setup&&(jk(e),Gk(e),Vk(e),Qk(e)),Wi(e)},onClose:({code:a,reason:r})=>{e.connected=!1,a!==1012&&(e.lastError=`disconnected (${a}): ${r||"no reason"}`)},onEvent:a=>zk(e,a),onGap:({expected:a,received:r})=>{console.warn(`[gateway] event gap: expected seq ${a}, got ${r}`),Wi(e)}}),e.client.start()}function zk(e,t){try{Hk(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Hk(e,t){var n;if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;ah(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&rd(e,i.sessionKey);const s=ac(e,i);if((s==="final"||s==="error"||s==="aborted")&&(Zo(e),ig(e)),s==="final"){const o=e,a=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,nn);Jt(o,{limit:a})}return}if(t.event==="suggestions"){const i=t.payload;(i==null?void 0:i.sessionKey)===e.sessionKey&&Array.isArray(i.suggestions)&&i.suggestions.length>0&&(e.chatSuggestions=i.suggestions);return}if(t.event==="presence"){const i=t.payload;i!=null&&i.presence&&Array.isArray(i.presence)&&(e.presenceEntries=i.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"){const i=t.payload;i&&kh(e,i),e.tab==="cron"&&e.loadCron()}if((t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&ca(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=kk(t.payload);if(i){e.execApprovalQueue=$k(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Cl(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){Mk(e,t.payload);return}if(t.event==="browser.handoff"){Pk(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){Ik(e);return}if(t.event==="exec.approval.resolved"){const i=xk(t.payload);i&&(e.execApprovalQueue=Cl(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){Bk(e,t.payload);return}if(t.event==="notification"){const i=t.payload;(i==null?void 0:i.category)==="model-fallback"&&Wk(i);return}}function _l(e,t){const n=t.snapshot;n!=null&&n.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n!=null&&n.health&&(e.debugHealth=n.health),n!=null&&n.sessionDefaults&&Kk(e,n.sessionDefaults)}async function qk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("models.list",{});Array.isArray(t==null?void 0:t.models)&&(e.chatModelCatalog=t.models)}catch{}}async function jk(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await _i(e.client)}catch{}}async function Gk(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null}catch{}}async function Vk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("wifi.status");if(e.wifiStatus=t,t!=null&&t.connected&&t.signal==null)try{const[n,i]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiStatus=i,i.signal==null&&n.networks){const s=n.networks.find(o=>o.active);s&&(e.wifiStatus={...i,signal:s.signal})}}catch{}}catch{}}async function Qk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("network.status");e.networkPort=t.port,e.networkHostname=t.hostname,e.networkPortInput=String(t.port),e.networkHostnameInput=t.hostname}catch{}}const Ml="taskmaster_public_id";function Cu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${Ml}=`));if(t)return t.split("=")[1];const n=`anon-${((s=crypto.randomUUID)==null?void 0:s.call(crypto))??Math.random().toString(36).slice(2)}`,i=new Date(Date.now()+e*864e5).toUTCString();return document.cookie=`${Ml}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function Jk(e){var n,i,s;if(!e.client||!e.connected)return;const t=Cu((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const o=(i=e.publicChatConfig)==null?void 0:i.accountId,a=await e.client.request("public.session",{cookieId:t,accountId:o});if(a!=null&&a.sessionKey){e.publicChatSessionKey=a.sessionKey,e.sessionKey=a.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const r=((s=e.publicChatConfig)==null?void 0:s.accountId)??"";e.chatMessage=Kn(r,a.sessionKey),Jt(e)}}catch(o){console.error("[public-chat] failed to resolve anonymous session:",o),e.lastError="Failed to start chat session"}}let pe=!1,ie=null,Zt="",en="",tn="",ms="",cn="phone",On="";function Eu(e){return e.replace(/[\s\-()]/g,"")}function nt(){pe=!1,ie=null,Zt="",en="",tn="",ms="",cn="phone",On=""}async function Yk(e){if(!e.client||!e.connected)return;const t=Cu(e.cookieTtlDays);try{const n=await e.client.request("public.session",{cookieId:t,accountId:e.accountId});n!=null&&n.sessionKey&&e.onAuthenticated(n.sessionKey)}catch(n){ie=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function Pl(e){if(!e.client||pe)return;const t=Eu(Zt);if(!t){ie="Please enter your phone number",e.requestUpdate();return}pe=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:tn.trim()||void 0,accountId:e.accountId,channel:On||void 0});n!=null&&n.ok?(ms=n.channel??"",cn="phone",e.onAuthStepChange("otp")):ie=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ie=n instanceof Error?n.message:"Failed to send verification code"}finally{pe=!1,e.requestUpdate()}}async function Il(e){if(!e.client||pe)return;const t=en.trim().toLowerCase();if(!t||!t.includes("@")){ie="Please enter a valid email address",e.requestUpdate();return}pe=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{identifier:t,accountId:e.accountId});n!=null&&n.ok?(ms=n.channel??"email",cn="email",e.onAuthStepChange("otp")):ie=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ie=n instanceof Error?n.message:"Failed to send verification code"}finally{pe=!1,e.requestUpdate()}}async function Ll(e,t){if(!(!e.client||pe)){if(!t.trim()){ie="Please enter the verification code",e.requestUpdate();return}pe=!0,ie=null,e.requestUpdate();try{const n=cn==="email"?en.trim().toLowerCase():Eu(Zt),i=await e.client.request("public.otp.verify",{identifier:n,code:t.trim(),accountId:e.accountId});i!=null&&i.ok&&i.sessionKey?(nt(),e.onAuthenticated(i.sessionKey)):ie=(i==null?void 0:i.error)??"Invalid verification code"}catch(n){ie=n instanceof Error?n.message:"Verification failed"}finally{pe=!1,e.requestUpdate()}}}function qe(e){return w}function xi(e){return l`
4488
+ `}async function gk(e){if(!(!e.client||!e.connected)&&!e.agentsLoading){e.agentsLoading=!0,e.agentsError=null;try{const t=await e.client.request("agents.list",{});t&&(e.agentsList=t)}catch(t){e.agentsError=String(t)}finally{e.agentsLoading=!1}}}async function Vn(e){if(!(!e.client||!e.connected)&&!e.workspacesLoading){e.workspacesLoading=!0,e.workspacesError=null;try{const t=await e.client.request("workspaces.list",{});e.workspaces=t.workspaces}catch(t){e.workspacesError=String(t)}finally{e.workspacesLoading=!1}}}async function mk(e,t){var i,s;if(!e.client||!e.connected||e.workspaceSaving)return;const n=t.name.trim();if(!n){e.workspacesError="Account name is required.";return}e.workspaceSaving=!0,e.workspacesError=null;try{const o=await e.client.request("config.get",{});e.configSnapshot=o;const a=o.hash;if(!a){e.workspacesError="Config hash missing; reload and retry.";return}const r={name:n,baseHash:a,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(r.workspaceDir=t.workspacePath.trim());const u=await e.client.request("workspaces.create",r);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await Vn(e),(s=t.onCreated)==null||s.call(t,u)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function yk(e,t){if(!(!e.client||!e.connected)&&!e.workspaceSaving){e.workspaceSaving=!0,e.workspacesError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=n.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:i}),e.workspaceRemoveConfirm=null,await Vn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function vk(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:s}),await Vn(e)}catch(i){e.workspacesError=String(i)}}}const ki=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:mk,loadWorkspaces:Vn,removeWorkspace:yk,renameWorkspace:vk},Symbol.toStringTag,{value:"Module"})),Su={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"taskmaster-control-ui",SETUP_UI:"setup-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"taskmaster-macos",IOS_APP:"taskmaster-ios",ANDROID_APP:"taskmaster-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"taskmaster-probe",PUBLIC_CHAT:"public-chat"},Al=Su,zo={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Su));new Set(Object.values(zo));function bk(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),i=e.token??"",s=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),i];return t==="v2"&&s.push(e.nonce??""),s.join("|")}const wk=4008;class kk{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{var i,s;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(s=(i=this.opts).onClose)==null||s.call(i,{code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){var d;if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=this.opts.role??"operator",n=this.opts.scopes??["operator.admin","operator.approvals","operator.pairing"],s=!(t!=="operator")&&typeof crypto<"u"&&!!crypto.subtle;let o=null,a=!1,r=this.opts.token;if(s){o=await lf();const p=(d=uf({deviceId:o.deviceId,role:t}))==null?void 0:d.token;r=p??this.opts.token,a=!!(p&&this.opts.token)}const u=r||this.opts.password?{token:r,password:this.opts.password}:void 0;let c;if(s&&o){const p=Date.now(),v=this.connectNonce??void 0,$=bk({deviceId:o.deviceId,clientId:this.opts.clientName??Al.CONTROL_UI,clientMode:this.opts.mode??zo.WEBCHAT,role:t,scopes:n,signedAtMs:p,token:r??null,nonce:v}),S=await cf(o.privateKey,$);c={id:o.deviceId,publicKey:o.publicKey,signature:S,signedAt:p,nonce:v}}const h={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Al.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??zo.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:c,caps:[],auth:u,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",h).then(p=>{var v,$,S;(v=p==null?void 0:p.auth)!=null&&v.deviceToken&&o&&pf({deviceId:o.deviceId,role:p.auth.role??t,token:p.auth.deviceToken,scopes:p.auth.scopes??[]}),this.backoffMs=800,(S=($=this.opts).onHello)==null||S.call($,p)}).catch(()=>{var p;a&&o&&hf({deviceId:o.deviceId,role:t}),(p=this.ws)==null||p.close(wk,"connect failed")})}handleMessage(t){var s,o,a,r,u,c;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const h=n;if(h.event==="connect.challenge"){const p=h.payload,v=p&&typeof p.nonce=="string"?p.nonce:null;v&&(this.connectNonce=v,this.sendConnect());return}const d=typeof h.seq=="number"?h.seq:null;d!==null&&(this.lastSeq!==null&&d>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:d})),this.lastSeq=d);try{(r=(a=this.opts).onEvent)==null||r.call(a,h)}catch(p){console.error("[gateway] event handler error:",p)}return}if(i.type==="res"){const h=n,d=this.pending.get(h.id);if(!d)return;if(this.pending.delete(h.id),h.ok)d.resolve(h.payload);else{const p=new Error(((u=h.error)==null?void 0:u.message)??"request failed");p.payload=h.payload,p.details=(c=h.error)==null?void 0:c.details,d.reject(p)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=as(),s={type:"req",id:i,method:t,params:n},o=new Promise((a,r)=>{this.pending.set(i,{resolve:u=>a(u),reject:r})});return this.ws.send(JSON.stringify(s)),o}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ho(e){return typeof e=="object"&&e!==null}function xk(e){if(!Ho(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ho(n))return null;const i=typeof n.command=="string"?n.command.trim():"";if(!i)return null;const s=typeof e.createdAtMs=="number"?e.createdAtMs:0,o=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!s||!o?null:{id:t,request:{command:i,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:s,expiresAtMs:o}}function $k(e){if(!Ho(e))return null;const t=typeof e.id=="string"?e.id.trim():"";return t?{id:t,decision:typeof e.decision=="string"?e.decision:null,resolvedBy:typeof e.resolvedBy=="string"?e.resolvedBy:null,ts:typeof e.ts=="number"?e.ts:null}:null}function Au(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Sk(e,t){const n=Au(e).filter(i=>i.id!==t.id);return n.push(t),n}function Cl(e,t){return Au(e).filter(n=>n.id!==t)}class Ak{constructor(){this.canvas=null,this.ctx=null,this.img=new Image,this.pendingFrame=null,this.rafId=null,this.deviceWidth=1280,this.deviceHeight=720,this.lastMouseMoveAt=0,this.MOUSE_THROTTLE_MS=30}attach(t){this.canvas=t,this.ctx=t.getContext("2d")}detach(){this.rafId!=null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.canvas=null,this.ctx=null,this.pendingFrame=null}updateFrame(t,n){if(n!=null&&n.deviceWidth&&(this.deviceWidth=n.deviceWidth),n!=null&&n.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,!this.canvas){const i=document.getElementById("browser-screencast-canvas");i&&this.attach(i)}this.rafId==null&&(this.rafId=requestAnimationFrame(()=>this.renderFrame()))}renderFrame(){this.rafId=null;const t=this.pendingFrame;!t||!this.canvas||!this.ctx||(this.pendingFrame=null,this.img.onload=()=>{!this.canvas||!this.ctx||((this.canvas.width!==this.img.width||this.canvas.height!==this.img.height)&&(this.canvas.width=this.img.width,this.canvas.height=this.img.height),this.ctx.drawImage(this.img,0,0))},this.img.src=`data:image/jpeg;base64,${t}`)}translateCoordinates(t,n){if(!this.canvas)return{x:t,y:n};const i=this.canvas.getBoundingClientRect(),s=this.canvas.width/i.width,o=this.canvas.height/i.height,a=this.deviceWidth/this.canvas.width,r=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*a),y:Math.round(n*o*r)}}shouldThrottleMouseMove(){const t=performance.now();return t-this.lastMouseMoveAt<this.MOUSE_THROTTLE_MS?!0:(this.lastMouseMoveAt=t,!1)}getDeviceDimensions(){return{width:this.deviceWidth,height:this.deviceHeight}}}let uo=null;function Bn(){return uo||(uo=new Ak),uo}function Oa(e){return e instanceof Error?e.message:String(e)}async function Ck(e){if(!e.client){console.error("[browser] startScreencast: no client"),e.browserError="Not connected to gateway";return}if(!e.connected){console.error("[browser] startScreencast: client exists but not connected"),e.browserError="Not connected to gateway";return}console.log("[browser] startScreencast: sending request"),e.browserLoading=!0,e.browserError=null;try{const t=await e.client.request("browser.screencast.start",{quality:60,maxWidth:1280,maxHeight:720});console.log("[browser] startScreencast response:",t),t!=null&&t.ok?e.browserScreencastActive=!0:(console.warn("[browser] startScreencast: response did not have ok=true",t),e.browserError="Screencast start failed (no ok in response)")}catch(t){console.error("[browser] startScreencast error:",t),e.browserError=Oa(t)}finally{e.browserLoading=!1}}async function Ek(e){if(!(!e.client||!e.connected)){e.browserLoading=!0,e.browserFullscreen=!1;try{await e.client.request("browser.screencast.stop",{}),e.browserScreencastActive=!1,e.browserScreencastFrame=null,e.browserScreencastMetadata=null}catch(t){e.browserError=Oa(t)}finally{e.browserLoading=!1}}}async function po(e,t,n,i,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:i,button:s??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function ho(e,t,n,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...i!=null&&i.text?{text:i.text}:{},...i!=null&&i.code?{code:i.code}:{},...i!=null&&i.modifiers?{modifiers:i.modifiers}:{}})}catch{}}async function Tk(e){if(!(!e.client||!e.connected))try{await e.client.request("browser.handoff.complete",{}),e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}catch(t){e.browserError=Oa(t)}}function _k(e){e.browserInputMode=!e.browserInputMode}function Mk(e){e.browserFullscreen=!e.browserFullscreen,Bn().detach()}function Pk(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,Bn().updateFrame(t.data,t.metadata)}function Ik(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function Lk(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function qo(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),i=n?{sessionKey:n}:{};try{const s=await e.client.request("agent.identity.get",i);if(!s)return;const o=bo(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function _i(e){return(await e.request("apikeys.list")).providers??[]}async function El(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function Rk(e,t){await e.request("apikeys.remove",{provider:t})}async function Dk(e,t,n){await e.request("apikeys.disable",{provider:t,disabled:n})}const ts="taskmaster_update_pending";async function Cu(e){var t,n;if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("update.status",{});e.currentVersion=i.current,e.latestVersion=i.latest,e.updateAvailable=i.updateAvailable,e.updateMessage=i.updateAvailable?`v${i.latest} available`:"Up to date"}catch(i){e.updateMessage=`Check failed: ${String(i)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function Bk(e){var t,n,i,s;if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e);try{localStorage.setItem(ts,String(Date.now())),localStorage.removeItem(Fa)}catch{}try{const o=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(o.ok&&o.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(o.ok&&o.result.status==="skipped")Nn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw Nn(),new Error(o.result.reason||"Update failed")}catch(o){Nn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function Nk(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const a=t.name,r=t.index,u=t.total;e.updateMessage=`Updating: ${a} (${r+1}/${u})`;const c=e.updateProgressSteps.find(h=>h.index===r);c?(c.status="running",c.name=a):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:u,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const a=t.name,r=t.index,u=t.total,c=t.ok,h=t.durationMs,d=e.updateProgressSteps.find(v=>v.index===r);d?(d.status=c?"done":"failed",d.durationMs=h):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:u,status:c?"done":"failed",durationMs:h}];const p=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${a} done (${r+1}/${u})`:`Update step failed: ${a}${p}`,(s=e.requestUpdate)==null||s.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const r=t.reason;e.updateMessage=r?`Update failed: ${r}`:"Update failed",e.updateRunning=!1,Nn()}(o=e.requestUpdate)==null||o.call(e)}}async function Ok(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=Uk();Nn();try{const a=await e.client.request("update.lastResult",{});if(!a.ok||!a.result)return;const r=5*6e4,u=Date.now()-a.result.ts<r;if(!t&&!u||Wk(a.result.ts))return;e.updateLastResult=a.result;const c=(n=a.result.after)==null?void 0:n.version;if(a.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,a.result.status==="ok"){const h=(i=a.result.before)==null?void 0:i.version,d=c??a.result.currentVersion;e.updateMessage=h?`Updated: v${h} → v${d}`:`Updated to v${d}`}else{const h=a.result.reason??((s=a.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${h}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(o=e.requestUpdate)==null||o.call(e)}}const Fa="taskmaster_update_dismissed";function Fk(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Fa,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function Uk(){try{const e=localStorage.getItem(ts);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(ts),!1):!0:!1}catch{return!1}}function Nn(){try{localStorage.removeItem(ts)}catch{}}function Wk(e){try{const t=localStorage.getItem(Fa);return t?Number(t)>=e:!1}catch{return!1}}const Tl="notification-banner";function Kk(e){const t=document.getElementById(Tl);if(!e){t==null||t.remove();return}t&&t.remove();const n=document.createElement("div");n.id=Tl,Object.assign(n.style,{background:"rgba(255, 180, 50, 0.15)",border:"1px solid rgba(255, 180, 50, 0.3)",borderRadius:"8px",padding:"12px 16px",margin:"0 0 16px 0",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"12px",color:"rgba(255, 255, 255, 0.9)",fontSize:"14px"});const i=document.createElement("span");i.textContent=e.message,n.appendChild(i);const s=document.createElement("button");s.setAttribute("aria-label","Dismiss"),s.textContent="×",Object.assign(s.style,{background:"none",border:"none",color:"rgba(255, 255, 255, 0.7)",cursor:"pointer",fontSize:"18px",padding:"0 4px"}),s.addEventListener("click",()=>n.remove()),n.appendChild(s),(document.querySelector("main")??document.body).prepend(n)}function fo(e,t){var r,u,c;const n=(e??"").trim(),i=(r=t.mainSessionKey)==null?void 0:r.trim();if(!i)return n;if(!n)return i;const s=((u=t.mainKey)==null?void 0:u.trim())||"main",o=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===s||o&&(n===`agent:${o}:main`||n===`agent:${o}:${s}`)?i:n}function zk(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=fo(e.sessionKey,t),i=fo(e.settings.sessionKey,t),s=fo(e.settings.lastActiveSessionKey,t),o=n||i||e.sessionKey,a={...e.settings,sessionKey:i||o,lastActiveSessionKey:s||o},r=a.sessionKey!==e.settings.sessionKey||a.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),r&&at(e,a)}function Be(e){var o;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;let t=null;const n=!!e.publicChat,i=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,s=n?"public-chat":i?"setup-ui":"taskmaster-control-ui";(o=e.client)==null||o.stop(),e.client=new kk({url:e.settings.gatewayUrl,token:n?void 0:e.settings.token.trim()?e.settings.token:void 0,password:n?void 0:e.password.trim()?e.password:void 0,clientName:s,mode:"webchat",role:n?"public":void 0,scopes:n?[]:void 0,onHello:a=>{var u,c;const r=((u=a.server)==null?void 0:u.version)??null;if(t!==null&&r!==null&&r!==t){window.location.reload();return}if(t===null&&(t=r),e.connected=!0,e.lastError=null,e.hello=a,n){_l(e,a),qo(e),(((c=e.publicChatConfig)==null?void 0:c.auth)??"anonymous")==="anonymous"&&Yk(e);return}zi()&&(wa(),e.uninstallDone=!1),_l(e,a),e.handleAccessCheck(),Ok(e).then(()=>{Cu(e)}),qo(e),gk(e),(e.chatPage||e.setup)&&jk(e),da(e,{quiet:!0}),ca(e,{quiet:!0}),Vn(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Fe(e),e.setup&&(Gk(e),Vk(e),Qk(e),Jk(e)),Wi(e)},onClose:({code:a,reason:r})=>{e.connected=!1,a!==1012&&(e.lastError=`disconnected (${a}): ${r||"no reason"}`)},onEvent:a=>Hk(e,a),onGap:({expected:a,received:r})=>{console.warn(`[gateway] event gap: expected seq ${a}, got ${r}`),Wi(e)}}),e.client.start()}function Hk(e,t){try{qk(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function qk(e,t){var n;if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;rh(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&ld(e,i.sessionKey);const s=ac(e,i);if((s==="final"||s==="error"||s==="aborted")&&(Zo(e),sg(e)),s==="final"){const o=e,a=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,nn);Jt(o,{limit:a})}return}if(t.event==="suggestions"){const i=t.payload;(i==null?void 0:i.sessionKey)===e.sessionKey&&Array.isArray(i.suggestions)&&i.suggestions.length>0&&(e.chatSuggestions=i.suggestions);return}if(t.event==="presence"){const i=t.payload;i!=null&&i.presence&&Array.isArray(i.presence)&&(e.presenceEntries=i.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"){const i=t.payload;i&&xh(e,i),e.tab==="cron"&&e.loadCron()}if((t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&ca(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=xk(t.payload);if(i){e.execApprovalQueue=Sk(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Cl(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){Pk(e,t.payload);return}if(t.event==="browser.handoff"){Ik(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){Lk(e);return}if(t.event==="exec.approval.resolved"){const i=$k(t.payload);i&&(e.execApprovalQueue=Cl(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){Nk(e,t.payload);return}if(t.event==="notification"){const i=t.payload;(i==null?void 0:i.category)==="model-fallback"&&Kk(i);return}}function _l(e,t){const n=t.snapshot;n!=null&&n.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n!=null&&n.health&&(e.debugHealth=n.health),n!=null&&n.sessionDefaults&&zk(e,n.sessionDefaults)}async function jk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("models.list",{});Array.isArray(t==null?void 0:t.models)&&(e.chatModelCatalog=t.models)}catch{}}async function Gk(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await _i(e.client)}catch{}}async function Vk(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null}catch{}}async function Qk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("wifi.status");if(e.wifiStatus=t,t!=null&&t.connected&&t.signal==null)try{const[n,i]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiStatus=i,i.signal==null&&n.networks){const s=n.networks.find(o=>o.active);s&&(e.wifiStatus={...i,signal:s.signal})}}catch{}}catch{}}async function Jk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("network.status");e.networkPort=t.port,e.networkHostname=t.hostname,e.networkPortInput=String(t.port),e.networkHostnameInput=t.hostname}catch{}}const Ml="taskmaster_public_id";function Eu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${Ml}=`));if(t)return t.split("=")[1];const n=`anon-${((s=crypto.randomUUID)==null?void 0:s.call(crypto))??Math.random().toString(36).slice(2)}`,i=new Date(Date.now()+e*864e5).toUTCString();return document.cookie=`${Ml}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function Yk(e){var n,i,s;if(!e.client||!e.connected)return;const t=Eu((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const o=(i=e.publicChatConfig)==null?void 0:i.accountId,a=await e.client.request("public.session",{cookieId:t,accountId:o});if(a!=null&&a.sessionKey){e.publicChatSessionKey=a.sessionKey,e.sessionKey=a.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const r=((s=e.publicChatConfig)==null?void 0:s.accountId)??"";e.chatMessage=Kn(r,a.sessionKey),Jt(e)}}catch(o){console.error("[public-chat] failed to resolve anonymous session:",o),e.lastError="Failed to start chat session"}}let pe=!1,ie=null,Zt="",en="",tn="",ms="",cn="phone",On="";function Tu(e){return e.replace(/[\s\-()]/g,"")}function it(){pe=!1,ie=null,Zt="",en="",tn="",ms="",cn="phone",On=""}async function Xk(e){if(!e.client||!e.connected)return;const t=Eu(e.cookieTtlDays);try{const n=await e.client.request("public.session",{cookieId:t,accountId:e.accountId});n!=null&&n.sessionKey&&e.onAuthenticated(n.sessionKey)}catch(n){ie=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function Pl(e){if(!e.client||pe)return;const t=Tu(Zt);if(!t){ie="Please enter your phone number",e.requestUpdate();return}pe=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:tn.trim()||void 0,accountId:e.accountId,channel:On||void 0});n!=null&&n.ok?(ms=n.channel??"",cn="phone",e.onAuthStepChange("otp")):ie=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ie=n instanceof Error?n.message:"Failed to send verification code"}finally{pe=!1,e.requestUpdate()}}async function Il(e){if(!e.client||pe)return;const t=en.trim().toLowerCase();if(!t||!t.includes("@")){ie="Please enter a valid email address",e.requestUpdate();return}pe=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{identifier:t,accountId:e.accountId});n!=null&&n.ok?(ms=n.channel??"email",cn="email",e.onAuthStepChange("otp")):ie=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ie=n instanceof Error?n.message:"Failed to send verification code"}finally{pe=!1,e.requestUpdate()}}async function Ll(e,t){if(!(!e.client||pe)){if(!t.trim()){ie="Please enter the verification code",e.requestUpdate();return}pe=!0,ie=null,e.requestUpdate();try{const n=cn==="email"?en.trim().toLowerCase():Tu(Zt),i=await e.client.request("public.otp.verify",{identifier:n,code:t.trim(),accountId:e.accountId});i!=null&&i.ok&&i.sessionKey?(it(),e.onAuthenticated(i.sessionKey)):ie=(i==null?void 0:i.error)??"Invalid verification code"}catch(n){ie=n instanceof Error?n.message:"Verification failed"}finally{pe=!1,e.requestUpdate()}}}function Ve(e){return w}function xi(e){return l`
4483
4489
  <div class="public-auth__form">
4484
4490
  <label class="field public-auth__field">
4485
4491
  <span>Your name (optional)</span>
@@ -4573,7 +4579,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4573
4579
  ${n?"Use a different email":"Use a different number"}
4574
4580
  </button>
4575
4581
  </div>
4576
- `}function Xk(e){const{authMode:t,authStep:n}=e,i=!e.otpChannels||e.otpChannels.length>0;if(t==="anonymous")return l`
4582
+ `}function Zk(e){const{authMode:t,authStep:n}=e,i=!e.otpChannels||e.otpChannels.length>0;if(t==="anonymous")return l`
4577
4583
  <div class="setup-container">
4578
4584
  <div class="setup-card">
4579
4585
  <div class="setup-spinner"></div>
@@ -4583,7 +4589,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4583
4589
  `;if(t==="verified"){const h=e.verifyMethods??["whatsapp","sms"],d=h.includes("whatsapp")||h.includes("sms")||h.includes("phone"),p=h.includes("email");return!i&&!p?l`
4584
4590
  <div class="setup-container">
4585
4591
  <div class="public-auth">
4586
- ${qe()}
4592
+ ${Ve()}
4587
4593
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4588
4594
  <p class="public-auth__subtitle">Verification is not available right now.</p>
4589
4595
  </div>
@@ -4591,7 +4597,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4591
4597
  `:n==="otp"?l`
4592
4598
  <div class="setup-container">
4593
4599
  <div class="public-auth">
4594
- ${qe()}
4600
+ ${Ve()}
4595
4601
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4596
4602
  ${Rl(e)}
4597
4603
  </div>
@@ -4599,13 +4605,13 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4599
4605
  `:n==="email"?l`
4600
4606
  <div class="setup-container">
4601
4607
  <div class="public-auth">
4602
- ${qe()}
4608
+ ${Ve()}
4603
4609
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4604
4610
  <p class="public-auth__subtitle">Verify your email address to get started.</p>
4605
4611
  ${go(e)}
4606
4612
  ${d?l`
4607
4613
  <button class="btn public-auth__btn public-auth__btn--link"
4608
- @click=${()=>{nt(),e.onAuthStepChange("phone")}}>
4614
+ @click=${()=>{it(),e.onAuthStepChange("phone")}}>
4609
4615
  Use phone number instead
4610
4616
  </button>
4611
4617
  `:w}
@@ -4614,13 +4620,13 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4614
4620
  `:n==="phone"?l`
4615
4621
  <div class="setup-container">
4616
4622
  <div class="public-auth">
4617
- ${qe()}
4623
+ ${Ve()}
4618
4624
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4619
4625
  <p class="public-auth__subtitle">Verify your phone number to get started.</p>
4620
4626
  ${xi(e)}
4621
4627
  ${p?l`
4622
4628
  <button class="btn public-auth__btn public-auth__btn--link"
4623
- @click=${()=>{nt(),e.onAuthStepChange("email")}}>
4629
+ @click=${()=>{it(),e.onAuthStepChange("email")}}>
4624
4630
  Use email instead
4625
4631
  </button>
4626
4632
  `:w}
@@ -4629,12 +4635,12 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4629
4635
  `:d&&p?l`
4630
4636
  <div class="setup-container">
4631
4637
  <div class="public-auth">
4632
- ${qe()}
4638
+ ${Ve()}
4633
4639
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4634
4640
  <p class="public-auth__subtitle">Authenticate to get started.</p>
4635
4641
  ${xi(e)}
4636
4642
  <button class="btn public-auth__btn public-auth__btn--link"
4637
- @click=${()=>{nt(),e.onAuthStepChange("email")}}>
4643
+ @click=${()=>{it(),e.onAuthStepChange("email")}}>
4638
4644
  Use email instead
4639
4645
  </button>
4640
4646
  </div>
@@ -4642,7 +4648,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4642
4648
  `:p?l`
4643
4649
  <div class="setup-container">
4644
4650
  <div class="public-auth">
4645
- ${qe()}
4651
+ ${Ve()}
4646
4652
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4647
4653
  <p class="public-auth__subtitle">Verify your email address to get started.</p>
4648
4654
  ${go(e)}
@@ -4651,7 +4657,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4651
4657
  `:l`
4652
4658
  <div class="setup-container">
4653
4659
  <div class="public-auth">
4654
- ${qe()}
4660
+ ${Ve()}
4655
4661
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4656
4662
  <p class="public-auth__subtitle">Verify your phone number to get started.</p>
4657
4663
  ${xi(e)}
@@ -4660,13 +4666,13 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4660
4666
  `}const s=e.verifyMethods??["whatsapp","sms"],o=s.includes("whatsapp")&&(!e.otpChannels||e.otpChannels.includes("whatsapp")),a=s.includes("sms"),r=s.includes("email"),c=o||a||s.includes("phone")||r;if(n==="phone"||n==="email"||n==="otp"){const h=n==="email"||n==="otp"&&cn==="email",p=h?"Verify your email address to continue your conversation across devices.":`Verify your phone number to receive a code via ${h?"email":On==="sms"?"SMS":"WhatsApp"}.`;return l`
4661
4667
  <div class="setup-container">
4662
4668
  <div class="public-auth">
4663
- ${qe()}
4669
+ ${Ve()}
4664
4670
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4665
4671
  <p class="public-auth__subtitle">${p}</p>
4666
4672
  ${n==="otp"?Rl(e):n==="email"?go(e):xi(e)}
4667
4673
  ${n!=="otp"?l`
4668
4674
  <button class="btn public-auth__btn public-auth__btn--link"
4669
- @click=${()=>{nt(),e.onAuthStepChange("idle")}}>
4675
+ @click=${()=>{it(),e.onAuthStepChange("idle")}}>
4670
4676
  Back
4671
4677
  </button>
4672
4678
  `:w}
@@ -4675,20 +4681,20 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4675
4681
  `}return l`
4676
4682
  <div class="setup-container">
4677
4683
  <div class="public-auth">
4678
- ${qe()}
4684
+ ${Ve()}
4679
4685
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4680
4686
  <p class="public-auth__subtitle">How would you like to get started?</p>
4681
4687
  <div class="public-auth__choices">
4682
4688
  <button
4683
4689
  class="btn primary public-auth__btn"
4684
- @click=${()=>{Yk(e)}}
4690
+ @click=${()=>{Xk(e)}}
4685
4691
  >
4686
4692
  Chat now
4687
4693
  </button>
4688
4694
  ${o?l`
4689
4695
  <button
4690
4696
  class="btn public-auth__btn"
4691
- @click=${()=>{nt(),On="whatsapp",e.onAuthStepChange("phone")}}
4697
+ @click=${()=>{it(),On="whatsapp",e.onAuthStepChange("phone")}}
4692
4698
  >
4693
4699
  Authenticate with WhatsApp
4694
4700
  </button>
@@ -4696,7 +4702,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4696
4702
  ${a?l`
4697
4703
  <button
4698
4704
  class="btn public-auth__btn"
4699
- @click=${()=>{nt(),On="sms",e.onAuthStepChange("phone")}}
4705
+ @click=${()=>{it(),On="sms",e.onAuthStepChange("phone")}}
4700
4706
  >
4701
4707
  Authenticate with SMS
4702
4708
  </button>
@@ -4704,7 +4710,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4704
4710
  ${r?l`
4705
4711
  <button
4706
4712
  class="btn public-auth__btn"
4707
- @click=${()=>{nt(),e.onAuthStepChange("email")}}
4713
+ @click=${()=>{it(),e.onAuthStepChange("email")}}
4708
4714
  >
4709
4715
  Authenticate with email
4710
4716
  </button>
@@ -4717,7 +4723,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4717
4723
  `:w}
4718
4724
  </div>
4719
4725
  </div>
4720
- `}function Ua(){return{enabled:!1,publicAgentEnabled:!0,days:{monday:{start:"09:00",end:"17:00",closed:!1},tuesday:{start:"09:00",end:"17:00",closed:!1},wednesday:{start:"09:00",end:"17:00",closed:!1},thursday:{start:"09:00",end:"17:00",closed:!1},friday:{start:"09:00",end:"17:00",closed:!1},saturday:{start:"09:00",end:"17:00",closed:!0},sunday:{start:"09:00",end:"17:00",closed:!0}},closedDates:[]}}const Tu=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];async function Wa(e){if(!(!e.client||!e.connected)&&!e.openingHoursLoading){e.openingHoursLoading=!0,e.openingHoursError=null;try{const t=await e.client.request("business.openingHours.get",{});if(t.openingHours){const n=t.openingHours,i={};for(const s of Tu){const o=n.schedule[s];o==null?i[s]={start:"09:00",end:"17:00",closed:!0}:i[s]={start:o.start,end:o.end,closed:!1}}e.openingHoursForm={enabled:n.enabled,publicAgentEnabled:t.publicAgentEnabled,days:i,closedDates:[...n.closedDates??[]].sort()}}else{const n=Ua();n.publicAgentEnabled=t.publicAgentEnabled,e.openingHoursForm=n}}catch(t){e.openingHoursError=String(t)}finally{e.openingHoursLoading=!1}}}async function _u(e){if(!(!e.client||!e.connected||e.openingHoursBusy)){e.openingHoursBusy=!0,e.openingHoursError=null;try{const t=e.openingHoursForm,n={};for(const a of Tu){const r=t.days[a];n[a]=r!=null&&r.closed?null:{start:r.start,end:r.end}}const i=Intl.DateTimeFormat().resolvedOptions().timeZone,s={enabled:t.enabled,timezone:i,schedule:n,closedDates:t.closedDates.length>0?[...t.closedDates].sort():void 0},o=await e.client.request("config.get",{});await e.client.request("config.patch",{raw:JSON.stringify({business:{openingHours:s,publicAgentEnabled:t.publicAgentEnabled}}),baseHash:o.hash,note:"Opening hours updated"}),await Wa(e)}catch(t){e.openingHoursError=String(t)}finally{e.openingHoursBusy=!1}}}const Zk=Object.freeze(Object.defineProperty({__proto__:null,defaultOpeningHoursForm:Ua,loadOpeningHours:Wa,saveOpeningHours:_u},Symbol.toStringTag,{value:"Module"}));function e0(e,t="admin"){var s;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const i=[];for(const o of n){if(!o||typeof o!="object"||o.agentId!==t&&o.agentId!=="management")continue;const a=o.match;if(!a||typeof a!="object"||(a.channel??"").toLowerCase()!=="whatsapp")continue;const u=a.peer;if(!u||typeof u!="object"||u.kind!=="dm")continue;const c=u.id??"";c&&i.push({phone:c,paired:((s=o.meta)==null?void 0:s.paired)===!0})}return i.sort((o,a)=>o.paired&&!a.paired?-1:!o.paired&&a.paired?1:0),i}function Mu(e,t,n="admin",i){const s=c=>c===n||c==="management",o=new Map,a=new Map;for(const c of e){if(!c||typeof c!="object"||!s(c.agentId))continue;const h=c.match;if(!h||typeof h!="object"||(h.channel??"").toLowerCase()!=="whatsapp")continue;const p=h.peer;if(!p||typeof p!="object"||p.kind!=="dm")continue;const v=p.id??"";v&&(c.meta&&o.set(v,c.meta),h.accountId&&a.set(v,h.accountId))}const r=e.filter(c=>{if(!c||typeof c!="object"||!s(c.agentId))return!0;const h=c.match;if(!h||typeof h!="object"||(h.channel??"").toLowerCase()!=="whatsapp")return!0;const p=h.peer;return!p||typeof p!="object"?!0:p.kind!=="dm"}),u=t.map(c=>{const h=i??a.get(c.phone),d={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};h&&(d.accountId=h);const p={agentId:n,match:d},v=o.get(c.phone);return v?p.meta=v:c.paired&&(p.meta={paired:!0}),p});return[...r,...u]}async function ys(e,t){if(!e.client||!e.connected)return;if(!t){e.adminPhones=[];return}if(e.adminsLoading)return;e.adminsLoading=!0,e.adminsError=null;const n=t;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.config;e.configForm=rt(s??{}),e.adminPhones=e0(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function Pu(e,t,n,i){var a,r;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n;let o=t.replace(/[\s\-\(\)]/g,"");if(!o){e.adminsError="Phone number is required";return}if(o.startsWith("+")||(o="+"+o),!/^\+[1-9]\d{6,14}$/.test(o)){e.adminsError="Invalid phone number. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(u=>u.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const u=rt(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),c=u.bindings??[],h=[...e.adminPhones,{phone:o}],d=Mu(c,h,s,i);cc(u,["bindings"],d);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const v=At(u);await e.client.request("config.set",{raw:v,baseHash:p}),await ys(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}async function Iu(e,t,n,i){var a,r;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n,o=e.adminPhones.find(u=>u.phone===t);if(o!=null&&o.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const u=rt(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),c=u.bindings??[],h=e.adminPhones.filter($=>$.phone!==t),d=Mu(c,h,s,i);cc(u,["bindings"],d);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const v=At(u);await e.client.request("config.set",{raw:v,baseHash:p}),await ys(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}const t0=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:Pu,loadAdmins:ys,removeAdmin:Iu},Symbol.toStringTag,{value:"Module"}));async function Pt(e,t){if(!(!e.client||!e.connected)){if(!t){e.contactsRecords=[];return}if(!e.contactsLoading){e.contactsLoading=!0,e.contactsError=null;try{const n=e.contactsSearchQuery.trim(),i=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.contactsRecords=i.records??[]}catch(n){e.contactsError=String(n)}finally{e.contactsLoading=!1}}}}async function Lu(e,t,n,i){if(!e.client||!e.connected||e.contactsSaving)return;let s=t.replace(/[\s\-\(\)]/g,"");const o=n.trim();if(!s){e.contactsError="Phone number is required";return}if(!o){e.contactsError="Name is required";return}if(s.startsWith("+")||(s="+"+s),!/^\+[1-9]\d{6,14}$/.test(s)){e.contactsError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.set",{id:s,name:o,fields:{},workspace:i}),e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName="",await Pt(e,i)}catch(a){e.contactsError=String(a)}finally{e.contactsSaving=!1}}async function Ru(e,t,n){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.delete",{id:t}),e.contactsEditingId===t&&(e.contactsEditingId=null),await Pt(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function jo(e,t,n,i,s){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.setField",{id:t,key:n,value:i}),await Pt(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function Du(e,t,n,i){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await Pt(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const n0=Object.freeze(Object.defineProperty({__proto__:null,addContact:Lu,deleteContact:Ru,deleteContactField:Du,loadContacts:Pt,setContactField:jo},Symbol.toStringTag,{value:"Module"}));let wt=null,Mi=null,Pi=null;const mo=[[0,"Checking Tailscale service..."],[5,"Starting login..."],[15,"Requesting authentication link..."],[40,"Setting up secure connection..."],[70,"Almost ready..."]];function Kt(){wt&&(clearInterval(wt),wt=null),Mi&&(clearInterval(Mi),Mi=null),Pi&&(clearTimeout(Pi),Pi=null)}function Sn(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0},onRestartGateway:()=>e.handleGatewayRestart()}}function i0(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),onAddAccount:()=>{e.addingWorkspace=!0},hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0},onRestartGateway:()=>e.handleGatewayRestart()}}function s0(e){const t=we(e);if(!t)return;const n=t.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return n==null?void 0:n.id}function Ka(e){const t=we(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function o0(e){var i;const t=we(e);if(!t)return;const n=t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin");return(n==null?void 0:n.id)??((i=t.agents[0])==null?void 0:i.id)}function a0(e){return e.selectedWorkspace??void 0}function we(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const r0=/^data:/i,l0=/^https?:\/\//i;function Dl(e){var r,u;const t=((r=e.agentsList)==null?void 0:r.agents)??[],n=Jl(e.sessionKey),i=(n==null?void 0:n.agentId)??((u=e.agentsList)==null?void 0:u.defaultId)??"main",s=t.find(c=>c.id===i),o=s==null?void 0:s.identity,a=(o==null?void 0:o.avatarUrl)??(o==null?void 0:o.avatar);if(a)return r0.test(a)||l0.test(a)?a:o==null?void 0:o.avatarUrl}function c0(e){var i;if(!e)return null;const t=(i=e.channelAccounts)==null?void 0:i.whatsapp;if(!t||t.length===0)return null;const n=t[0];return{running:n.running??!1,connected:n.connected??!1,linked:n.linked??!1,lastError:n.lastError}}function d0(e){var a;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(a=e.channelAccounts)==null?void 0:a.imessage;if(!t||t.length===0)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const n=t[0],i=n.running??!1,s=n.probe,o=s!=null?s.ok===!0:i;return{configured:n.configured??!1,running:i,connected:o,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function u0(e){var a;const t=(a=e.configSnapshot)==null?void 0:a.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(r=>{var u,c;return((u=r.match)==null?void 0:u.channel)==="imessage"&&((c=r.meta)==null?void 0:c.imessageOwner)});if(!i)return null;const s=i.agentId;for(const r of e.workspaces)if(r.agents.some(u=>u.id===s))return r.name;if(s==="admin"||s==="public"){const r=e.workspaces.find(u=>u.isDefault);return(r==null?void 0:r.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const r=e.workspaces.find(u=>u.name===o);return(r==null?void 0:r.name)??null}return null}function Ii(e){const t=Object.create(null);return Object.defineProperties(t,{client:{get:()=>e.client,set:()=>{}},connected:{get:()=>e.connected,set:()=>{}},conversations:{get:()=>e.waConversations,set:n=>{e.waConversations=n}},selectedJid:{get:()=>e.waSelectedJid,set:n=>{e.waSelectedJid=n}},messages:{get:()=>e.waMessages,set:n=>{e.waMessages=n}},groupInfo:{get:()=>e.waGroupInfo,set:n=>{e.waGroupInfo=n}},loading:{get:()=>e.waLoading,set:n=>{e.waLoading=n}},messagesLoading:{get:()=>e.waMessagesLoading,set:n=>{e.waMessagesLoading=n}},searchQuery:{get:()=>e.waSearchQuery,set:n=>{e.waSearchQuery=n}},composeDraft:{get:()=>e.waComposeDraft,set:n=>{e.waComposeDraft=n}},sending:{get:()=>e.waSending,set:n=>{e.waSending=n}},lastError:{get:()=>e.waLastError,set:n=>{e.waLastError=n}},accountId:{get:()=>Ka(e),set:()=>{}}}),t}function p0(){requestAnimationFrame(()=>{const e=document.querySelector(".wa-messages");e&&(e.scrollTop=e.scrollHeight)})}function h0(e){return{client:e.client,connected:e.connected,conversations:e.waConversations??[],selectedJid:e.waSelectedJid??null,messages:e.waMessages??[],groupInfo:e.waGroupInfo??null,loading:e.waLoading??!1,messagesLoading:e.waMessagesLoading??!1,searchQuery:e.waSearchQuery??"",composeDraft:e.waComposeDraft??"",sending:e.waSending??!1,lastError:e.waLastError??null,accountId:Ka(e),onSelectConversation:t=>{const n=Ii(e);fw(n,t).then(()=>{e.requestUpdate(),p0()})},onBack:()=>{e.waSelectedJid=null,e.waMessages=[],e.waGroupInfo=null,e.requestUpdate()},onSearchChange:t=>{e.waSearchQuery=t,e.requestUpdate()},onActivationChange:(t,n)=>{const i=Ii(e);gw(i,t,n).then(()=>e.requestUpdate())},onRefresh:()=>{const t=Ii(e);yu(t).then(()=>e.requestUpdate())},requestUpdate:()=>e.requestUpdate()}}function f0(e){var t,n,i,s,o,a,r,u,c,h;if(e.embeddingDownloading&&!e.publicChat)return l`
4726
+ `}function Ua(){return{enabled:!1,publicAgentEnabled:!0,days:{monday:{start:"09:00",end:"17:00",closed:!1},tuesday:{start:"09:00",end:"17:00",closed:!1},wednesday:{start:"09:00",end:"17:00",closed:!1},thursday:{start:"09:00",end:"17:00",closed:!1},friday:{start:"09:00",end:"17:00",closed:!1},saturday:{start:"09:00",end:"17:00",closed:!0},sunday:{start:"09:00",end:"17:00",closed:!0}},closedDates:[]}}const _u=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];async function Wa(e){if(!(!e.client||!e.connected)&&!e.openingHoursLoading){e.openingHoursLoading=!0,e.openingHoursError=null;try{const t=await e.client.request("business.openingHours.get",{});if(t.openingHours){const n=t.openingHours,i={};for(const s of _u){const o=n.schedule[s];o==null?i[s]={start:"09:00",end:"17:00",closed:!0}:i[s]={start:o.start,end:o.end,closed:!1}}e.openingHoursForm={enabled:n.enabled,publicAgentEnabled:t.publicAgentEnabled,days:i,closedDates:[...n.closedDates??[]].sort()}}else{const n=Ua();n.publicAgentEnabled=t.publicAgentEnabled,e.openingHoursForm=n}}catch(t){e.openingHoursError=String(t)}finally{e.openingHoursLoading=!1}}}async function Mu(e){if(!(!e.client||!e.connected||e.openingHoursBusy)){e.openingHoursBusy=!0,e.openingHoursError=null;try{const t=e.openingHoursForm,n={};for(const a of _u){const r=t.days[a];n[a]=r!=null&&r.closed?null:{start:r.start,end:r.end}}const i=Intl.DateTimeFormat().resolvedOptions().timeZone,s={enabled:t.enabled,timezone:i,schedule:n,closedDates:t.closedDates.length>0?[...t.closedDates].sort():void 0},o=await e.client.request("config.get",{});await e.client.request("config.patch",{raw:JSON.stringify({business:{openingHours:s,publicAgentEnabled:t.publicAgentEnabled}}),baseHash:o.hash,note:"Opening hours updated"}),await Wa(e)}catch(t){e.openingHoursError=String(t)}finally{e.openingHoursBusy=!1}}}const e0=Object.freeze(Object.defineProperty({__proto__:null,defaultOpeningHoursForm:Ua,loadOpeningHours:Wa,saveOpeningHours:Mu},Symbol.toStringTag,{value:"Module"}));function t0(e,t="admin"){var s;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const i=[];for(const o of n){if(!o||typeof o!="object"||o.agentId!==t&&o.agentId!=="management")continue;const a=o.match;if(!a||typeof a!="object"||(a.channel??"").toLowerCase()!=="whatsapp")continue;const u=a.peer;if(!u||typeof u!="object"||u.kind!=="dm")continue;const c=u.id??"";c&&i.push({phone:c,paired:((s=o.meta)==null?void 0:s.paired)===!0})}return i.sort((o,a)=>o.paired&&!a.paired?-1:!o.paired&&a.paired?1:0),i}function Pu(e,t,n="admin",i){const s=c=>c===n||c==="management",o=new Map,a=new Map;for(const c of e){if(!c||typeof c!="object"||!s(c.agentId))continue;const h=c.match;if(!h||typeof h!="object"||(h.channel??"").toLowerCase()!=="whatsapp")continue;const p=h.peer;if(!p||typeof p!="object"||p.kind!=="dm")continue;const v=p.id??"";v&&(c.meta&&o.set(v,c.meta),h.accountId&&a.set(v,h.accountId))}const r=e.filter(c=>{if(!c||typeof c!="object"||!s(c.agentId))return!0;const h=c.match;if(!h||typeof h!="object"||(h.channel??"").toLowerCase()!=="whatsapp")return!0;const p=h.peer;return!p||typeof p!="object"?!0:p.kind!=="dm"}),u=t.map(c=>{const h=i??a.get(c.phone),d={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};h&&(d.accountId=h);const p={agentId:n,match:d},v=o.get(c.phone);return v?p.meta=v:c.paired&&(p.meta={paired:!0}),p});return[...r,...u]}async function ys(e,t){if(!e.client||!e.connected)return;if(!t){e.adminPhones=[];return}if(e.adminsLoading)return;e.adminsLoading=!0,e.adminsError=null;const n=t;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.config;e.configForm=lt(s??{}),e.adminPhones=t0(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function Iu(e,t,n,i){var a,r;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n;let o=t.replace(/[\s\-\(\)]/g,"");if(!o){e.adminsError="Phone number is required";return}if(o.startsWith("+")||(o="+"+o),!/^\+[1-9]\d{6,14}$/.test(o)){e.adminsError="Invalid phone number. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(u=>u.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const u=lt(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),c=u.bindings??[],h=[...e.adminPhones,{phone:o}],d=Pu(c,h,s,i);cc(u,["bindings"],d);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const v=At(u);await e.client.request("config.set",{raw:v,baseHash:p}),await ys(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}async function Lu(e,t,n,i){var a,r;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n,o=e.adminPhones.find(u=>u.phone===t);if(o!=null&&o.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const u=lt(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),c=u.bindings??[],h=e.adminPhones.filter($=>$.phone!==t),d=Pu(c,h,s,i);cc(u,["bindings"],d);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const v=At(u);await e.client.request("config.set",{raw:v,baseHash:p}),await ys(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}const n0=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:Iu,loadAdmins:ys,removeAdmin:Lu},Symbol.toStringTag,{value:"Module"}));async function Pt(e,t){if(!(!e.client||!e.connected)){if(!t){e.contactsRecords=[];return}if(!e.contactsLoading){e.contactsLoading=!0,e.contactsError=null;try{const n=e.contactsSearchQuery.trim(),i=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.contactsRecords=i.records??[]}catch(n){e.contactsError=String(n)}finally{e.contactsLoading=!1}}}}async function Ru(e,t,n,i){if(!e.client||!e.connected||e.contactsSaving)return;let s=t.replace(/[\s\-\(\)]/g,"");const o=n.trim();if(!s){e.contactsError="Phone number is required";return}if(!o){e.contactsError="Name is required";return}if(s.startsWith("+")||(s="+"+s),!/^\+[1-9]\d{6,14}$/.test(s)){e.contactsError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.set",{id:s,name:o,fields:{},workspace:i}),e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName="",await Pt(e,i)}catch(a){e.contactsError=String(a)}finally{e.contactsSaving=!1}}async function Du(e,t,n){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.delete",{id:t}),e.contactsEditingId===t&&(e.contactsEditingId=null),await Pt(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function jo(e,t,n,i,s){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.setField",{id:t,key:n,value:i}),await Pt(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function Bu(e,t,n,i){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await Pt(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const i0=Object.freeze(Object.defineProperty({__proto__:null,addContact:Ru,deleteContact:Du,deleteContactField:Bu,loadContacts:Pt,setContactField:jo},Symbol.toStringTag,{value:"Module"}));let wt=null,Mi=null,Pi=null;const mo=[[0,"Checking Tailscale service..."],[5,"Starting login..."],[15,"Requesting authentication link..."],[40,"Setting up secure connection..."],[70,"Almost ready..."]];function Kt(){wt&&(clearInterval(wt),wt=null),Mi&&(clearInterval(Mi),Mi=null),Pi&&(clearTimeout(Pi),Pi=null)}function Sn(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0},onRestartGateway:()=>e.handleGatewayRestart()}}function s0(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),onAddAccount:()=>{e.addingWorkspace=!0},hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0},onRestartGateway:()=>e.handleGatewayRestart()}}function o0(e){const t=we(e);if(!t)return;const n=t.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return n==null?void 0:n.id}function Ka(e){const t=we(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function a0(e){var i;const t=we(e);if(!t)return;const n=t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin");return(n==null?void 0:n.id)??((i=t.agents[0])==null?void 0:i.id)}function r0(e){return e.selectedWorkspace??void 0}function we(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const l0=/^data:/i,c0=/^https?:\/\//i;function Dl(e){var r,u;const t=((r=e.agentsList)==null?void 0:r.agents)??[],n=Jl(e.sessionKey),i=(n==null?void 0:n.agentId)??((u=e.agentsList)==null?void 0:u.defaultId)??"main",s=t.find(c=>c.id===i),o=s==null?void 0:s.identity,a=(o==null?void 0:o.avatarUrl)??(o==null?void 0:o.avatar);if(a)return l0.test(a)||c0.test(a)?a:o==null?void 0:o.avatarUrl}function d0(e){var i;if(!e)return null;const t=(i=e.channelAccounts)==null?void 0:i.whatsapp;if(!t||t.length===0)return null;const n=t[0];return{running:n.running??!1,connected:n.connected??!1,linked:n.linked??!1,lastError:n.lastError}}function u0(e){var a;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(a=e.channelAccounts)==null?void 0:a.imessage;if(!t||t.length===0)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const n=t[0],i=n.running??!1,s=n.probe,o=s!=null?s.ok===!0:i;return{configured:n.configured??!1,running:i,connected:o,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function p0(e){var a;const t=(a=e.configSnapshot)==null?void 0:a.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(r=>{var u,c;return((u=r.match)==null?void 0:u.channel)==="imessage"&&((c=r.meta)==null?void 0:c.imessageOwner)});if(!i)return null;const s=i.agentId;for(const r of e.workspaces)if(r.agents.some(u=>u.id===s))return r.name;if(s==="admin"||s==="public"){const r=e.workspaces.find(u=>u.isDefault);return(r==null?void 0:r.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const r=e.workspaces.find(u=>u.name===o);return(r==null?void 0:r.name)??null}return null}function Ii(e){const t=Object.create(null);return Object.defineProperties(t,{client:{get:()=>e.client,set:()=>{}},connected:{get:()=>e.connected,set:()=>{}},conversations:{get:()=>e.waConversations,set:n=>{e.waConversations=n}},selectedJid:{get:()=>e.waSelectedJid,set:n=>{e.waSelectedJid=n}},messages:{get:()=>e.waMessages,set:n=>{e.waMessages=n}},groupInfo:{get:()=>e.waGroupInfo,set:n=>{e.waGroupInfo=n}},loading:{get:()=>e.waLoading,set:n=>{e.waLoading=n}},messagesLoading:{get:()=>e.waMessagesLoading,set:n=>{e.waMessagesLoading=n}},searchQuery:{get:()=>e.waSearchQuery,set:n=>{e.waSearchQuery=n}},composeDraft:{get:()=>e.waComposeDraft,set:n=>{e.waComposeDraft=n}},sending:{get:()=>e.waSending,set:n=>{e.waSending=n}},lastError:{get:()=>e.waLastError,set:n=>{e.waLastError=n}},accountId:{get:()=>Ka(e),set:()=>{}}}),t}function h0(){requestAnimationFrame(()=>{const e=document.querySelector(".wa-messages");e&&(e.scrollTop=e.scrollHeight)})}function f0(e){return{client:e.client,connected:e.connected,conversations:e.waConversations??[],selectedJid:e.waSelectedJid??null,messages:e.waMessages??[],groupInfo:e.waGroupInfo??null,loading:e.waLoading??!1,messagesLoading:e.waMessagesLoading??!1,searchQuery:e.waSearchQuery??"",composeDraft:e.waComposeDraft??"",sending:e.waSending??!1,lastError:e.waLastError??null,accountId:Ka(e),onSelectConversation:t=>{const n=Ii(e);gw(n,t).then(()=>{e.requestUpdate(),h0()})},onBack:()=>{e.waSelectedJid=null,e.waMessages=[],e.waGroupInfo=null,e.requestUpdate()},onSearchChange:t=>{e.waSearchQuery=t,e.requestUpdate()},onActivationChange:(t,n)=>{const i=Ii(e);mw(i,t,n).then(()=>e.requestUpdate())},onRefresh:()=>{const t=Ii(e);vu(t).then(()=>e.requestUpdate())},requestUpdate:()=>e.requestUpdate()}}function g0(e){var t,n,i,s,o,a,r,u,c,h;if(e.embeddingDownloading&&!e.publicChat)return l`
4721
4727
  <div class="setup-container">
4722
4728
  <div class="setup-card" style="text-align:center; max-width:420px;">
4723
4729
  <div class="setup-spinner"></div>
@@ -4738,7 +4744,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4738
4744
  <p>Connecting...</p>
4739
4745
  </div>
4740
4746
  </div>
4741
- `;if(!e.publicChatAuthenticated)return Xk({authMode:e.publicChatConfig.auth??"anonymous",authStep:e.publicChatAuthStep,connected:e.connected,client:e.client,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,accountId:e.publicChatConfig.accountId,cookieTtlDays:e.publicChatConfig.cookieTtlDays,otpChannels:e.publicChatConfig.otpChannels,verifyMethods:e.publicChatConfig.verifyMethods,onAuthenticated:$=>{var M;e.publicChatSessionKey=$,e.sessionKey=$,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const S=((M=e.publicChatConfig)==null?void 0:M.accountId)??"";e.chatMessage=Kn(S,$),ae(async()=>{const{loadChatHistory:y}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:y}},void 0,import.meta.url).then(({loadChatHistory:y})=>{y(e)})},onAuthStepChange:$=>{e.publicChatAuthStep=$},requestUpdate:()=>{e.requestUpdate()}});const d=(t=e.publicChatConfig)==null?void 0:t.greeting,p=e.chatMessages,v=!e.chatLoading&&d?[{role:"assistant",content:[{type:"text",text:d}],timestamp:0},...Array.isArray(p)?p:[]]:p;return hk({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:v,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??Dl(e)??null,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,canAbort:!!e.chatRunId,disabledReason:e.connected?null:"Disconnected.",error:e.lastError,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,suggestions:e.chatSuggestions,onSuggestionClick:$=>{e.chatMessage=$,e.chatSuggestions=[],e.handleSendChat()},onRefresh:()=>(e.resetToolStream(),ae(async()=>{const{loadChatHistory:$}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:$}},void 0,import.meta.url).then(({loadChatHistory:$})=>{$(e)})),onDraftChange:$=>{var M;e.chatMessage=$;const S=((M=e.publicChatConfig)==null?void 0:M.accountId)??"";wr(S,e.sessionKey,$)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:$=>e.chatAttachments=$,onSend:()=>e.handleSendChat(),onAbort:()=>{e.handleAbortChat()},onQueueRemove:$=>e.removeQueuedMessage($),onChatScroll:$=>e.handleChatScroll($),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()}})}if(e.connected&&e.accessState.checked){const{accessState:d}=e;if(d.hasPins&&!d.authenticated)return Sl({show:!0,isFirstTime:!1,accounts:d.accounts,error:d.error,busy:d.busy,onSubmit:(p,v)=>{v!=null&&e.handlePinSubmit(p,v)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(p,v,$)=>e.handleChangePin(p,v,$)});if(!d.hasMasterPin&&!d.authenticated&&e.setup)return Sl({show:!0,isFirstTime:!0,accounts:[],error:d.error,busy:d.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!d.hasMasterPin&&!d.authenticated&&!e.setup)return window.location.href="/setup",w}if(e.setup){const d=c0(e.channelsSnapshot),p=((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.whatsapp)??[],v=d0(e.channelsSnapshot),$=u0(e),S=async()=>{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null},M=()=>{const y=Date.now();e.tailscaleConnectProgress=0,e.tailscaleConnectMessage=mo[0][1],e.tailscaleConnectSuccess=!1,e.tailscaleError=null,Kt(),wt=setInterval(()=>{const b=(Date.now()-y)/1e3,k=Math.min(95,95*(1-Math.exp(-b/30)));e.tailscaleConnectProgress=Math.round(k);let A=mo[0][1];for(const[E,T]of mo)b>=E&&(A=T);e.tailscaleConnectMessage=A},500)};return sm({connected:e.connected,serverPlatform:((o=(s=e.hello)==null?void 0:s.server)==null?void 0:o.platform)??null,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:y=>e.handleLicenseKeyChange(y),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:d,whatsappAccounts:p,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:y=>e.handleUninstallConfirmTextChange(y),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:y=>e.handleAuthSubmitCode(y),onAuthCodeChange:y=>e.handleAuthCodeChange(y),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async y=>{await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await ee(e,!0),e.requestUpdate())},onWhatsAppUnlink:async y=>{await e.handleWhatsAppLogout(y)},onWhatsAppReset:async y=>{await e.handleWhatsAppLogout(y),await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await ee(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await ee(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),ee(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:y=>e.handleRemoveWhatsAppAccount(y),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:y=>{e.newWorkspacePin=y},onWorkspaceCreate:async(y,b)=>{const k=e.newWorkspacePin;await e.handleWorkspaceCreate(y,b),k.match(/^\d{4,6}$/)&&(await _h(e,y,k),e.newWorkspacePin="")},onWorkspaceRemove:y=>e.handleWorkspaceRemove(y),onSetAddingWorkspace:y=>{e.addingWorkspace=y},onSetNewWorkspaceName:y=>{e.newWorkspaceName=y},onSetNewWorkspacePath:y=>{e.newWorkspacePath=y},onSetWorkspaceRemoveConfirm:y=>{e.workspaceRemoveConfirm=y},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(y,b)=>e.handleWorkspaceRename(y,b),whatsappDmPolicy:(()=>{const y=we(e),b=y==null?void 0:y.whatsappAccountId,k=b?p.find(A=>A.accountId===b):p[0];return(k==null?void 0:k.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var P;const y=we(e),b=y==null?void 0:y.whatsappAccountId,k=b?p.find(D=>D.accountId===b):p[0];if(!k)return;const E=k.dmPolicy!=null&&k.dmPolicy!=="disabled"?"disabled":"open",T=E==="open"?{dmPolicy:E,allowFrom:["*"]}:{dmPolicy:E};try{const D=await e.client.request("config.get"),W=D.config,z=(P=W==null?void 0:W.channels)==null?void 0:P.whatsapp,ke=((z==null?void 0:z.accounts)??{})[k.accountId]?{channels:{whatsapp:{accounts:{[k.accountId]:T}}}}:{channels:{whatsapp:T}};await e.client.request("config.patch",{raw:JSON.stringify(ke),baseHash:D.hash,note:`WhatsApp DM policy → ${E}`,skipRestart:!0}),await ee(e,!1)}catch(D){console.error("DM toggle failed:",D)}},whatsappGroupPolicy:(()=>{var D,W;const y=(D=e.configSnapshot)==null?void 0:D.config,b=(W=y==null?void 0:y.channels)==null?void 0:W.whatsapp,k=we(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},T=A?E[A]:void 0;return(T==null?void 0:T.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var W,z;const y=(W=e.configSnapshot)==null?void 0:W.config,b=(z=y==null?void 0:y.channels)==null?void 0:z.whatsapp,k=we(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},T=A?E[A]:void 0,D=((T==null?void 0:T.groups)??(b==null?void 0:b.groups)??{})["*"];return(D==null?void 0:D.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var k;const y=we(e),b=y==null?void 0:y.whatsappAccountId;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.channels)==null?void 0:k.whatsapp)??{},P=T.accounts??{},D=b?P[b]:void 0,W=(D==null?void 0:D.groupPolicy)??T.groupPolicy??"allowlist",z=W==="disabled"||W==="allowlist",H=z?"open":"disabled",ke=z?{"*":{}}:void 0,_e={groupPolicy:H};ke&&(_e.groups=ke);const Ue=D?{channels:{whatsapp:{accounts:{[b]:_e}}}}:{channels:{whatsapp:_e}};await e.client.request("config.patch",{raw:JSON.stringify(Ue),baseHash:A.hash,note:`WhatsApp groups → ${H}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group toggle failed:",A)}},onWhatsAppGroupMentionChange:async y=>{var A;const b=we(e),k=b==null?void 0:b.whatsappAccountId;try{const E=await e.client.request("config.get"),T=E.config,D=(((A=T==null?void 0:T.channels)==null?void 0:A.whatsapp)??{}).accounts??{},W=k?D[k]:void 0,z={"*":{requireMention:y}},H=W?{channels:{whatsapp:{accounts:{[k]:{groups:z}}}}}:{channels:{whatsapp:{groups:z}}};await e.client.request("config.patch",{raw:JSON.stringify(H),baseHash:E.hash,note:`WhatsApp group mention → ${y?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(E){console.error("Group mention change failed:",E)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:v.configured,imessageRunning:v.running,imessageConnected:v.connected,imessageLastError:v.lastError,imessageSelfChatMode:v.selfChatMode,imessageCliPath:v.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:$,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,k=(b==null?void 0:b.bindings)??[],A=we(e),E=A==null?void 0:A.agents.find(z=>z.id.endsWith("-admin")||z.id==="admin"),T=(E==null?void 0:E.id)??"admin",P=k.filter(z=>{var H;return((H=z.match)==null?void 0:H.channel)!=="imessage"}),D=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],W=[...P,...D];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:W}),baseHash:y.hash,note:"Enable iMessage (self-chat) for "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Oe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await ee(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,A=((b==null?void 0:b.bindings)??[]).filter(E=>{var T;return((T=E.match)==null?void 0:T.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:A}),baseHash:y.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Oe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,k=(b==null?void 0:b.bindings)??[],A=we(e),E=A==null?void 0:A.agents.find(W=>W.id.endsWith("-admin")||W.id==="admin"),T=(E==null?void 0:E.id)??"admin",P=k.filter(W=>{var z;return((z=W.match)==null?void 0:z.channel)!=="imessage"}),D=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:[...P,...D]}),baseHash:y.hash,note:"Reassign iMessage to "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Oe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:y=>{var b,k,A,E;if(e.infoModalOpen=y,y==="remote-access"){const T=((b=e.tailscaleStatus)==null?void 0:b.tailnetUrl)??((k=e.tailscaleStatus)!=null&&k.hostname?`https://${e.tailscaleStatus.hostname}`:null);T&&!e.remoteAccessQrDataUrl&&e.client.request("qr.generate",{url:T}).then(P=>{e.remoteAccessQrDataUrl=(P==null?void 0:P.dataUrl)??null}).catch(()=>{})}else if(y==="public-chat"){const T=((A=e.tailscaleStatus)==null?void 0:A.publicUrl)??((E=e.tailscaleStatus)==null?void 0:E.tailnetUrl)??null,P=e.selectedWorkspace??null;if(T&&P){const D=`${T}/public/chat/${encodeURIComponent(P)}`;e.publicChatQrDataUrl||e.client.request("qr.generate",{url:D}).then(W=>{e.publicChatQrDataUrl=(W==null?void 0:W.dataUrl)??null}).catch(()=>{})}}},onInfoModalClose:()=>{e.infoModalOpen=null},remoteAccessQrDataUrl:e.remoteAccessQrDataUrl??null,publicChatQrDataUrl:e.publicChatQrDataUrl??null,publicChatFullUrl:(()=>{var k,A;const y=((k=e.tailscaleStatus)==null?void 0:k.publicUrl)??((A=e.tailscaleStatus)==null?void 0:A.tailnetUrl)??null,b=e.selectedWorkspace??null;return!y||!b?null:`${y}/public/chat/${encodeURIComponent(b)}`})(),isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,apiKeySavingProvider:e.apiKeySavingProvider,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeySave:async(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await El(e.client,y,b);const k=`${y} key saved`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}y==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async y=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Lk(e.client,y);const b=`${y} key removed`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyDisable:async(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Rk(e.client,y,b);const k=`${y} ${b?"disabled":"enabled"}`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:`Failed to ${b?"disable":"enable"} key`,e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:y=>{e.authApiKeyInput=y},onAuthApiKeySubmit:async()=>{const y=e.authApiKeyInput.trim();if(y){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await El(e.client,"anthropic",y),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(b){e.authApiKeyError=b instanceof Error?b.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var b;const y=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return y?e.accessState.accounts.some(k=>k.id===y):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(y,b)=>{var A;const k=e.selectedWorkspace??((A=e.workspaces[0])==null?void 0:A.name);k&&e.handleAccountPinSave(k,y,b)},publicChatAccountId:e.selectedWorkspace??null,publicChatSettingsOpen:e.publicChatSettingsOpen,onPublicChatSettingsOpen:()=>{e.publicChatSettingsOpen=!0},onPublicChatSettingsClose:()=>{e.publicChatSettingsOpen=!1},publicChatWidgetModalOpen:e.publicChatWidgetModalOpen,onPublicChatWidgetModalOpen:()=>{e.publicChatWidgetModalOpen=!0},onPublicChatWidgetModalClose:()=>{e.publicChatWidgetModalOpen=!1},publicChatEnabled:(()=>{var k;const y=(k=e.configSnapshot)==null?void 0:k.config,b=y==null?void 0:y.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var T,P;const y=(T=e.configSnapshot)==null?void 0:T.config,b=y==null?void 0:y.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.auth)??(b==null?void 0:b.auth);return E==="verified"||E==="choice"?E:"anonymous"})(),publicChatGreeting:(()=>{var E;const y=(E=e.configSnapshot)==null?void 0:E.config,b=y==null?void 0:y.publicChat,k=b==null?void 0:b.greetings,A=e.selectedWorkspace??"";return(A&&(k==null?void 0:k[A]))??""})(),publicChatGreetingBusy:e.publicChatGreetingBusy,onPublicChatGreetingToggle:async()=>{var b;if(e.publicChatGreetingBusy)return;const y=e.selectedWorkspace??"";if(y){e.publicChatGreetingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=(b=A==null?void 0:A.publicChat)==null?void 0:b.greetings;if(E==null?void 0:E[y]){const P={publicChat:{greetings:{[y]:null}}};await e.client.request("config.patch",{raw:JSON.stringify(P),baseHash:k.hash,note:`Public chat greeting → disabled (${y})`,skipRestart:!0})}else{const P=await e.client.request("public.greeting.generate",{accountId:y});if(P!=null&&P.ok&&P.greeting){const D=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[y]:P.greeting}}}),baseHash:D.hash,note:`Public chat greeting → enabled (${y})`,skipRestart:!0})}}e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting toggle failed:",k)}finally{e.publicChatGreetingBusy=!1}}},onPublicChatGreetingSave:async y=>{const b=e.selectedWorkspace??"";if(b)try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[b]:y}}}),baseHash:k.hash,note:`Public chat greeting text updated (${b})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting save failed:",k)}},onPublicChatGreetingRegenerate:async()=>{if(e.publicChatGreetingBusy)return;const y=e.selectedWorkspace??"";if(y){e.publicChatGreetingBusy=!0;try{const b=await e.client.request("public.greeting.generate",{accountId:y});if(b!=null&&b.ok&&b.greeting){const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[y]:b.greeting}}}),baseHash:k.hash,note:`Public chat greeting regenerated (${y})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}}catch(b){console.error("Public chat greeting regeneration failed:",b)}finally{e.publicChatGreetingBusy=!1}}},publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var y;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),k=b.config,A=((y=k==null?void 0:k.publicChat)==null?void 0:y.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!A}}),baseHash:b.hash,note:`Public chat → ${A?"disabled":"enabled"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get"),e.publicChatQrDataUrl=null}catch(b){console.error("Public chat toggle failed:",b)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async y=>{if(e.publicChatToggleBusy)return;const b=e.selectedWorkspace??"";if(b){e.publicChatToggleBusy=!0;try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{accountSettings:{[b]:{auth:y}}}}),baseHash:k.hash,note:`Public chat auth → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat auth mode change failed:",k)}finally{e.publicChatToggleBusy=!1}}},publicChatEmailFrom:(()=>{var k,A;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(A=y==null?void 0:y.publicChat)==null?void 0:A.email;return(b==null?void 0:b.from)??""})(),publicChatEmailBusy:e.publicChatEmailBusy,publicChatVerifyMethods:(()=>{var T,P;const y=(T=e.configSnapshot)==null?void 0:T.config,b=y==null?void 0:y.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.verifyMethods)??(b==null?void 0:b.verifyMethods);return Array.isArray(E)?E:["whatsapp","sms"]})(),onPublicChatEmailSave:async(y,b)=>{if(e.publicChatEmailBusy)return;const k=e.selectedWorkspace??"";if(k){e.publicChatEmailBusy=!0;try{const A=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{email:{from:y||void 0},accountSettings:{[k]:{verifyMethods:b}}}}),baseHash:A.hash,note:"Update email verification settings for public chat",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Email verification save failed:",A)}finally{e.publicChatEmailBusy=!1}}},brandAccentColor:(()=>{var k;const y=e.selectedWorkspace;return y?((k=Be()[y])==null?void 0:k.accentColor)??"":""})(),brandBackgroundColor:(()=>{var k;const y=e.selectedWorkspace;return y?((k=Be()[y])==null?void 0:k.backgroundColor)??"":""})(),brandHasLogo:(()=>{var k;const y=e.selectedWorkspace;return y?!!((k=Be()[y])!=null&&k.logoUrl):!1})(),agentSettingsOpen:e.agentSettingsOpen,agentSettingsAgents:(()=>{var A,E;const y=we(e);if(!y)return[];const b=(A=e.configSnapshot)==null?void 0:A.config,k=(E=b==null?void 0:b.agents)==null?void 0:E.list;return y.agents.map(T=>{var H;const P=Array.isArray(k)?k.find(ke=>ke.id===T.id):void 0,D=P==null?void 0:P.model,W=typeof D=="string"?D:(D==null?void 0:D.primary)??null,z=T.id.endsWith("-admin")||T.id==="admin";return{id:T.id,label:z?"Admin":"Public",model:(W==null?void 0:W.trim())||null,thinkingLevel:((H=P==null?void 0:P.thinkingLevel)==null?void 0:H.trim())||null}})})(),agentSettingsModelCatalog:e.chatModelCatalog??[],memoryProvider:(()=>{var k,A,E;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(E=(A=y==null?void 0:y.agents)==null?void 0:A.defaults)==null?void 0:E.memorySearch;return typeof(b==null?void 0:b.provider)=="string"&&b.provider?b.provider:"local"})(),memoryFallback:(()=>{var k,A,E;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(E=(A=y==null?void 0:y.agents)==null?void 0:A.defaults)==null?void 0:E.memorySearch;return typeof(b==null?void 0:b.fallback)=="string"&&b.fallback?b.fallback:"none"})(),onAgentSettingsToggle:()=>{e.agentSettingsOpen=!e.agentSettingsOpen},onAgentModelChange:async(y,b)=>{try{const k=await e.client.request("config.get"),A=k.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],P=T.findIndex(W=>W.id===y);if(b)P>=0?T[P]={...T[P],model:b}:T.push({id:y,model:b});else if(P>=0){const{model:W,...z}=T[P];Object.keys(z).length<=1?T.splice(P,1):T[P]=z}const D=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(D),baseHash:k.hash,note:`Agent ${y} model → ${b||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Agent model change failed:",k)}},onAgentThinkingChange:async(y,b)=>{try{const k=await e.client.request("config.get"),A=k.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],P=T.findIndex(z=>z.id===y),D=b==="off"?void 0:b;if(D)P>=0?T[P]={...T[P],thinkingLevel:D}:T.push({id:y,thinkingLevel:D});else if(P>=0){const{thinkingLevel:z,...H}=T[P];Object.keys(H).length<=1?T.splice(P,1):T[P]=H}const W=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(W),baseHash:k.hash,note:`Agent ${y} thinking → ${D||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Agent thinking change failed:",k)}},onMemoryProviderChange:async y=>{try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({agents:{defaults:{memorySearch:{provider:y}}}}),baseHash:b.hash,note:`Memory search provider → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Memory provider change failed:",b)}},onMemoryFallbackChange:async y=>{try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({agents:{defaults:{memorySearch:{fallback:y}}}}),baseHash:b.hash,note:`Memory search fallback → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Memory fallback change failed:",b)}},brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async y=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=T.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...T,brand:{...P,accentColor:y}}}}),baseHash:A.hash,note:`Brand accent → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const D=Be();D[b]||(D[b]={}),D[b].accentColor=y,Tn(b)}catch(A){console.error("Brand accent change failed:",A)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async y=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=T.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...T,brand:{...P,backgroundColor:y}}}}),baseHash:A.hash,note:`Brand background → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const D=Be();D[b]||(D[b]={}),D[b].backgroundColor=y,Tn(b)}catch(A){console.error("Brand background change failed:",A)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async y=>{const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const k=await y.arrayBuffer(),A=new Uint8Array(k);let E="";for(let D=0;D<A.length;D++)E+=String.fromCharCode(A[D]);const T=btoa(E);await e.client.request("brand.uploadLogo",{workspace:b,data:T,mimeType:y.type});const P=Be();P[b]||(P[b]={}),P[b].logoUrl=`/brand-logo/${encodeURIComponent(b)}`}catch(k){console.error("Brand logo upload failed:",k)}finally{e.brandingBusy=!1}}},onBrandLogoRemove:async()=>{const y=e.selectedWorkspace;if(!(!y||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:y});const b=Be();b[y]&&delete b[y].logoUrl}catch(b){console.error("Brand logo remove failed:",b)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var b;const y=e.selectedWorkspace;if(!(!y||e.brandingBusy)){e.brandingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=((b=A==null?void 0:A.workspaces)==null?void 0:b[y])??{},{brand:T,...P}=E;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[y]:{...P,brand:null}}}),baseHash:k.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:y})}catch{}const D=Be();delete D[y],Tn(y)}catch(k){console.error("Brand reset failed:",k)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleServeEnableUrl:e.tailscaleServeEnableUrl,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,tailscaleDisableConfirm:e.tailscaleDisableConfirm,tailscaleConnectProgress:e.tailscaleConnectProgress,tailscaleConnectMessage:e.tailscaleConnectMessage,tailscaleConnectSuccess:e.tailscaleConnectSuccess,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null,M();try{const y=await e.client.request("tailscale.enable");y.authUrl?(wt&&(clearInterval(wt),wt=null),e.tailscaleConnectProgress=100,e.tailscaleConnectMessage="Waiting for authentication...",e.tailscaleAuthUrl=y.authUrl,Mi=setInterval(async()=>{try{const b=await e.client.request("tailscale.status");e.tailscaleStatus=b,e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,b.loggedIn&&(Kt(),e.tailscaleAuthUrl=null,e.tailscaleConnectSuccess=!0,e.tailscaleConnectMessage="Connected!",setTimeout(()=>{e.tailscaleConnectSuccess=!1,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1},1500))}catch{}},3e3),Pi=setTimeout(()=>{Kt(),e.tailscaleBusy&&(e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)},3e5)):y.alreadyLoggedIn?(Kt(),e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1):(Kt(),e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)}catch(y){console.error("Tailscale enable failed:",y),Kt(),e.tailscaleError=y.message||"Failed to enable Remote Access",e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1}}},onTailscaleErrorDismiss:()=>{e.tailscaleError=null},onTailscaleServeEnable:async()=>{var y;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleServeEnableUrl=null;try{await e.client.request("tailscale.serve.enable"),await S()}catch(b){console.error("Tailscale serve enable failed:",b);const k=b;(y=k.payload)!=null&&y.enableUrl&&(e.tailscaleServeEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Remote Access"}finally{e.tailscaleBusy=!1}}},onTailscaleServeDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.serve.disable"),await S()}catch(y){console.error("Tailscale serve disable failed:",y)}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var y;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable"),await S()}catch(b){console.error("Tailscale funnel enable failed:",b);const k=b;(y=k.payload)!=null&&y.enableUrl&&(e.tailscaleFunnelEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Funnel"}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable"),await S()}catch(y){console.error("Tailscale funnel disable failed:",y)}finally{e.tailscaleBusy=!1}}},onTailscaleDisableConfirmToggle:()=>{e.tailscaleDisableConfirm=!e.tailscaleDisableConfirm},wifiModalOpen:e.wifiModalOpen,onWifiModalToggle:()=>{e.wifiModalOpen=!e.wifiModalOpen,e.wifiModalOpen||(e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null)},wifiStatus:e.wifiStatus,wifiNetworks:e.wifiNetworks,wifiBusy:e.wifiBusy,wifiError:e.wifiError,wifiPassword:e.wifiPassword,wifiSelectedSsid:e.wifiSelectedSsid,onWifiScan:async()=>{var y;if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[b,k]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiNetworks=b.networks,k.connected&&k.signal==null&&((y=b.networks)!=null&&y.length)){const A=b.networks.find(E=>E.active)||b.networks.find(E=>E.ssid===k.ssid);A&&(k.signal=A.signal)}e.wifiStatus=k}catch(b){console.error("WiFi scan failed:",b),e.wifiError=b.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{var b;if(e.wifiBusy||!e.wifiSelectedSsid)return;const y=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const k=await e.client.request("wifi.connect",{ssid:y,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:k.connected,ssid:k.ssid,signal:null,ip:k.ip,savedSsid:k.ssid,autoconnect:!0},e.wifiBusy=!1;try{const[A,E]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(E.connected&&E.signal==null&&((b=A.networks)!=null&&b.length)){const T=A.networks.find(P=>P.active)||A.networks.find(P=>P.ssid===E.ssid);T&&(E.signal=T.signal)}e.wifiStatus=E}catch{}}catch(k){console.error("WiFi connect failed:",k),e.wifiError=k.message||"Failed to connect",e.wifiBusy=!1}},onWifiDisconnect:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.disconnect"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const y=await e.client.request("wifi.status");e.wifiStatus=y}catch(y){console.error("WiFi disconnect failed:",y),e.wifiError=y.message||"Failed to disconnect"}finally{e.wifiBusy=!1}}},onWifiForget:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.forget"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const y=await e.client.request("wifi.status");e.wifiStatus=y}catch(y){console.error("WiFi forget failed:",y),e.wifiError=y.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:y=>{e.wifiSelectedSsid=y,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:y=>{e.wifiPassword=y},networkPort:e.networkPort,networkHostname:e.networkHostname,networkPortInput:e.networkPortInput,networkHostnameInput:e.networkHostnameInput,networkModalOpen:e.networkModalOpen,networkBusy:e.networkBusy,networkError:e.networkError,networkSuccess:e.networkSuccess,onNetworkModalToggle:()=>{e.networkModalOpen=!e.networkModalOpen,e.networkModalOpen&&(e.networkPortInput=String(e.networkPort??""),e.networkHostnameInput=e.networkHostname,e.networkError=null,e.networkSuccess=null)},onNetworkPortChange:y=>{e.networkPortInput=y,e.networkError=null,e.networkSuccess=null},onNetworkHostnameChange:y=>{e.networkHostnameInput=y,e.networkError=null,e.networkSuccess=null},onNetworkSave:async()=>{if(e.networkBusy)return;e.networkBusy=!0,e.networkError=null,e.networkSuccess=null;const y=e.networkPortInput.trim(),b=Number.parseInt(y,10),k=e.networkHostnameInput.trim();if(!y||!Number.isFinite(b)||b<1024||b>65535){e.networkError="Port must be a number between 1024 and 65535",e.networkBusy=!1;return}const A=b!==e.networkPort,E=k!==e.networkHostname;if(!A&&!E){e.networkBusy=!1;return}try{E&&await e.client.request("network.setHostname",{hostname:k});const T={};A&&(T.gateway={port:b}),E&&(T.discovery={bonjourHostname:k});const P=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify(T),baseHash:P.hash,note:[A?`Port → ${b}`:null,E?`Hostname → ${k}`:null].filter(Boolean).join(", "),restartDelayMs:2e3}),e.networkSuccess="Saved — redirecting...";const D=window.location.protocol,W=E?`${k}.local`:window.location.hostname,z=A?b:e.networkPort,H=`${D}//${W}:${z}/setup`;setTimeout(()=>{window.location.href=H},1500)}catch(T){console.error("Network save failed:",T),e.networkError=T.message||"Failed to save network settings",e.networkBusy=!1}},wsProps:i0(e)})}if(e.filesPage){const d=o0(e);return vg({connected:e.connected,wsProps:Sn(e),loading:e.filesLoading,tree:e.filesTree,root:e.filesRoot,error:e.filesError,selectedPath:e.filesSelectedPath,selectedPaths:e.filesSelectedPaths,previewContent:e.filesPreviewContent,previewLoading:e.filesPreviewLoading,previewBinary:e.filesPreviewBinary,previewSize:e.filesPreviewSize,expandedDirs:e.filesExpandedDirs,currentDir:e.filesCurrentDir,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>{rn(e,d),cs(e,d)},onReindex:()=>If(e,d),onSelectFile:p=>{e.filesPendingDeletePath=null,Sf(e,p,d)},onToggleSelectFile:p=>Af(e,p,d),onToggleDir:p=>Lf(e,p),onUpload:(p,v)=>Tf(e,p,v,d),onNewFolder:(p,v)=>_f(e,p,v,d),onDownload:p=>ad(e,p,d),onBulkDownload:()=>Cf(e,d),onDelete:p=>{e.filesPendingDeletePath=null,Mf(e,p,d)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,v)=>Ef(e,p,v,d),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const v=e.filesSearchAgentId??d;Rf(e,p,v)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{Df(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return pg({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,fullscreen:e.browserFullscreen,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>Ak(e),onStop:()=>Ck(e),onToggleInput:()=>Tk(e),onToggleFullscreen:()=>_k(e),onCompleteHandoff:()=>Ek(e),onCanvasMouseDown:d=>{const v=d.target.getBoundingClientRect(),S=Bn().translateCoordinates(d.clientX-v.left,d.clientY-v.top);po(e,"mousePressed",S.x,S.y,d.button===2?"right":d.button===1?"middle":"left")},onCanvasMouseUp:d=>{const v=d.target.getBoundingClientRect(),S=Bn().translateCoordinates(d.clientX-v.left,d.clientY-v.top);po(e,"mouseReleased",S.x,S.y)},onCanvasMouseMove:d=>{const p=Bn();if(p.shouldThrottleMouseMove())return;const $=d.target.getBoundingClientRect(),S=p.translateCoordinates(d.clientX-$.left,d.clientY-$.top);po(e,"mouseMoved",S.x,S.y)},onCanvasKeyDown:d=>{let p=0;d.altKey&&(p|=1),d.ctrlKey&&(p|=2),d.metaKey&&(p|=4),d.shiftKey&&(p|=8),ho(e,"keyDown",d.key,{code:d.code,modifiers:p||void 0}),d.key.length===1&&ho(e,"char",d.key,{text:d.key})},onCanvasKeyUp:d=>{ho(e,"keyUp",d.key,{code:d.code})}});if(e.adminsPage){const d=s0(e),p=Ka(e);return am({connected:e.connected,wsProps:Sn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>ys(e,d),onAdd:v=>{Pu(e,v,d,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:v=>Iu(e,v,d,p),onNewPhoneChange:v=>e.handleAdminsNewPhoneChange(v)})}if(e.contactsPage){const d=a0(e);return pm({connected:e.connected,wsProps:Sn(e),loading:e.contactsLoading,saving:e.contactsSaving,records:e.contactsRecords,error:e.contactsError,searchQuery:e.contactsSearchQuery,editingId:e.contactsEditingId,showAddForm:e.contactsShowAddForm,newRecordPhone:e.contactsNewPhone,newRecordName:e.contactsNewName,deleteConfirmId:e.contactsDeleteConfirmId,addFieldForId:e.contactsAddFieldForId,addFieldKey:e.contactsAddFieldKey,addFieldValue:e.contactsAddFieldValue,onSearch:p=>e.contactsSearchQuery=p,onSearchSubmit:()=>Pt(e,d),onAdd:(p,v)=>Lu(e,p,v,d),onDelete:p=>Ru(e,p,d),onSetField:(p,v,$)=>jo(e,p,v,$,d),onDeleteField:(p,v)=>Du(e,p,v,d),onToggleExpand:p=>{e.contactsEditingId=e.contactsEditingId===p?null:p},onShowAddForm:()=>e.contactsShowAddForm=!0,onCancelAddForm:()=>{e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName=""},onNewRecordPhoneChange:p=>e.handleContactsNewPhoneChange(p),onNewRecordNameChange:p=>e.handleContactsNewNameChange(p),onRefresh:()=>Pt(e,d),onDeleteConfirmOpen:p=>e.contactsDeleteConfirmId=p,onDeleteConfirmClose:()=>e.contactsDeleteConfirmId=null,onAddFieldOpen:p=>{e.contactsAddFieldForId=p,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldClose:()=>{e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldKeyChange:p=>e.contactsAddFieldKey=p,onAddFieldValueChange:p=>e.contactsAddFieldValue=p,onAddFieldSubmit:()=>{const p=e.contactsAddFieldForId,v=e.contactsAddFieldKey.trim();!p||!v||(jo(e,p,v,e.contactsAddFieldValue,d),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const d=e.connected?null:"Disconnected from gateway.",p=Dl(e),v=e.chatAvatarUrl??p??null,$=(()=>{var y;const S=(y=e.configSnapshot)==null?void 0:y.config,M=S==null?void 0:S.publicChat;return(M==null?void 0:M.enabled)===!0})();return hw({connected:e.connected,wsProps:Sn(e),publicChatEnabled:$,publicChatAccountId:e.selectedWorkspace??void 0,chatPageTab:e.chatPageTab??"chat",onChatPageTabChange:S=>{if(e.chatPageTab=S,S==="whatsapp"&&!e.waLoading&&e.waConversations.length===0){const M=Ii(e);yu(M).then(()=>e.requestUpdate())}},whatsappProps:h0(e),sessionKey:e.sessionKey,onSessionKeyChange:S=>{const M=e.selectedWorkspace??"";wo(),Wn(M,e.sessionKey,e.chatMessage),e.sessionKey=S,e.chatMessage=Kn(M,S),e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestions=[],e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:S,lastActiveSessionKey:S}),e.loadAssistantIdentity(),Jt(e),Eo(e)},showThinking:e.settings.chatShowThinking??!1,verboseLevel:e.chatVerboseLevel,suggestions:e.chatSuggestions,onSuggestionClick:S=>{e.chatMessage=S,e.chatSuggestions=[],e.handleSendChat()},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:v,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:d,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const S=Math.max(e.chatMessages.length+10,nn);return Promise.all([Jt(e,{limit:S}),Eo(e)])},onToggleFocusMode:()=>{},onChatScroll:S=>e.handleChatScroll(S),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:S=>{e.chatMessage=S,wr(e.selectedWorkspace??"",e.sessionKey,S)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:S=>e.chatAttachments=S,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:S=>e.removeQueuedMessage(S),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:S=>e.handleOpenSidebar(S),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:S=>e.handleSplitRatioChange(S),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?pk({connected:e.connected,wsProps:Sn(e),activeTab:e.advancedTab,onTabChange:d=>{e.advancedTab=d,d==="cron"&&e.loadCron(),d==="skills"&&Je(e,{clearMessages:!0}),d==="opening-hours"&&Wa(e),d==="logs"&&(e.logsSubTab==="session"?Pn(e,{reset:!0}):Gt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(a=e.channelsSnapshot)==null?void 0:a.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(d=>d.id):((u=e.channelsSnapshot)==null?void 0:u.channelOrder)??[],channelLabels:((c=e.channelsSnapshot)==null?void 0:c.channelLabels)??{},channelMeta:((h=e.channelsSnapshot)==null?void 0:h.channelMeta)??[],agentIds:(()=>{var p;const d=we(e);return((p=d==null?void 0:d.agents)==null?void 0:p.map(v=>v.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1,e.cronEditJobId=null},detailJobId:e.cronDetailJobId,editJobId:e.cronEditJobId,onDetailOpen:d=>{e.cronDetailJobId=d.id,xo(e,d.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:d=>{e.cronForm=$h(d),e.cronEditJobId=d.id,e.cronDetailJobId=null},onEditSave:()=>{const d=e.cronEditJobId;d&&Sh(e,d).then(()=>{e.cronEditJobId=null})},onFormChange:d=>e.cronForm={...e.cronForm,...d},onRefresh:()=>e.loadCron(),onAdd:()=>{vh(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(d,p)=>bh(e,d,p),onRun:d=>wh(e,d),onRemove:d=>{e.cronPendingDeleteId=null,xh(e,d)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:d=>{e.cronPendingDeleteId=d||null},onLoadRuns:d=>xo(e,d),runModalJobId:e.cronRunModalJobId,runModalJobName:e.cronRunModalJobName,runResult:e.cronRunResult,onRunModalClose:()=>{e.cronRunModalJobId=null,e.cronRunModalJobName="",e.cronRunResult=null}},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,typeFilter:e.skillsTypeFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,detail:e.skillDetail,detailTab:e.skillDetailTab,addModal:e.skillAddModal,addForm:e.skillAddForm,formSource:e.skillAddFormSource,editTab:e.skillEditTab,drafts:e.skillDrafts,onFilterChange:d=>e.skillsFilter=d,onTypeFilterChange:d=>e.skillsTypeFilter=d,onRefresh:()=>Je(e,{clearMessages:!0}),onToggle:(d,p)=>Oc(e,d,p),onEdit:(d,p)=>Nc(e,d,p),onSaveKey:d=>Fc(e,d),onInstall:(d,p,v)=>Uc(e,d,p,v),onViewDetail:d=>Wc(e,d),onDetailClose:()=>Kc(e),onDetailTab:d=>zc(e,d),onAddOpen:()=>Hc(e),onAddClose:()=>qc(e),onImportDraft:d=>jc(e,d),onInstallDraft:d=>Gc(e,d),onDeleteDraft:d=>Vc(e,d),onAddSave:()=>ua(e),onAddFormUpdate:(d,p)=>{e.skillAddForm={...e.skillAddForm,[d]:p}},onDelete:d=>Zc(e,d),onEditSkill:d=>Qc(e,d),onEditDetail:d=>Jc(e,d),onRefUpdate:(d,p)=>Yc(e,d,p),onEditTab:d=>Xc(e,d)},logsProps:{logsSubTab:e.logsSubTab,isAdmin:e.accessState.master||!e.accessState.hasPins,onSubTabChange:d=>{e.logsSubTab=d,d==="session"?Pn(e,{reset:!0}):Gt(e,{reset:!0})},sessionLogsProps:{loading:e.sessionLogsLoading,error:e.sessionLogsError,entries:e.sessionLogsEntries,agents:e.sessionLogsAgents,filterText:e.sessionLogsFilterText,typeFilters:e.sessionLogsTypeFilters,agentFilters:e.sessionLogsAgentFilters,autoFollow:e.sessionLogsAutoFollow,chipsExpanded:e.sessionLogsChipsExpanded,expandedIds:e.sessionLogsExpandedIds,onFilterTextChange:d=>e.sessionLogsFilterText=d,onTypeToggle:(d,p)=>{const v=e;v.sessionLogsTypeFilters={...v.sessionLogsTypeFilters,[d]:p}},onAgentToggle:(d,p)=>{const v=e;v.sessionLogsAgentFilters={...v.sessionLogsAgentFilters,[d]:p}},onToggleAutoFollow:d=>e.sessionLogsAutoFollow=d,onToggleChips:()=>{const d=e;d.sessionLogsChipsExpanded=!d.sessionLogsChipsExpanded},onToggleExpand:d=>{const p=e,v=new Set(p.sessionLogsExpandedIds);v.has(d)?v.delete(d):v.add(d),p.sessionLogsExpandedIds=v,p.requestUpdate()},onRefresh:()=>{Pn(e,{reset:!0})},onExport:(d,p)=>e.exportSessionLogs(d,p),onScroll:d=>e.handleSessionLogsScroll(d)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,chipsExpanded:e.logsChipsExpanded,truncated:e.logsTruncated,onFilterTextChange:d=>e.logsFilterText=d,onLevelToggle:(d,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[d]:p}},onToggleAutoFollow:d=>e.logsAutoFollow=d,onToggleChips:()=>{const d=e;d.logsChipsExpanded=!d.logsChipsExpanded},onRefresh:()=>Gt(e,{reset:!0}),onExport:(d,p)=>e.exportSessionLogs(d,p),onScroll:d=>e.handleLogsScroll(d)},openingHoursProps:{loading:e.openingHoursLoading,error:e.openingHoursError,busy:e.openingHoursBusy,form:e.openingHoursForm,onFormChange:d=>{const p=e;p.openingHoursForm={...p.openingHoursForm,...d}},onDayChange:(d,p,v)=>{const $=e,S={...$.openingHoursForm.days};S[d]={...S[d],[p]:v},$.openingHoursForm={...$.openingHoursForm,days:S}},onAddClosedDate:d=>{const p=e;p.openingHoursForm.closedDates.includes(d)||(p.openingHoursForm={...p.openingHoursForm,closedDates:[...p.openingHoursForm.closedDates,d].sort()})},onRemoveClosedDate:d=>{const p=e;p.openingHoursForm={...p.openingHoursForm,closedDates:p.openingHoursForm.closedDates.filter(v=>v!==d)}},onSave:()=>{_u(e)}}}):(window.location.replace("/chat"),l``)}function g0(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${i}`}function Bl(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function m0(e,t,n){return l`
4747
+ `;if(!e.publicChatAuthenticated)return Zk({authMode:e.publicChatConfig.auth??"anonymous",authStep:e.publicChatAuthStep,connected:e.connected,client:e.client,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,accountId:e.publicChatConfig.accountId,cookieTtlDays:e.publicChatConfig.cookieTtlDays,otpChannels:e.publicChatConfig.otpChannels,verifyMethods:e.publicChatConfig.verifyMethods,onAuthenticated:$=>{var M;e.publicChatSessionKey=$,e.sessionKey=$,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const S=((M=e.publicChatConfig)==null?void 0:M.accountId)??"";e.chatMessage=Kn(S,$),ae(async()=>{const{loadChatHistory:y}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:y}},void 0,import.meta.url).then(({loadChatHistory:y})=>{y(e)})},onAuthStepChange:$=>{e.publicChatAuthStep=$},requestUpdate:()=>{e.requestUpdate()}});const d=(t=e.publicChatConfig)==null?void 0:t.greeting,p=e.chatMessages,v=!e.chatLoading&&d?[{role:"assistant",content:[{type:"text",text:d}],timestamp:0},...Array.isArray(p)?p:[]]:p;return fk({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:v,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??Dl(e)??null,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,canAbort:!!e.chatRunId,disabledReason:e.connected?null:"Disconnected.",error:e.lastError,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,suggestions:e.chatSuggestions,onSuggestionClick:$=>{e.chatMessage=$,e.chatSuggestions=[],e.handleSendChat()},onRefresh:()=>(e.resetToolStream(),ae(async()=>{const{loadChatHistory:$}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:$}},void 0,import.meta.url).then(({loadChatHistory:$})=>{$(e)})),onDraftChange:$=>{var M;e.chatMessage=$;const S=((M=e.publicChatConfig)==null?void 0:M.accountId)??"";wr(S,e.sessionKey,$)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:$=>e.chatAttachments=$,onSend:()=>e.handleSendChat(),onAbort:()=>{e.handleAbortChat()},onQueueRemove:$=>e.removeQueuedMessage($),onChatScroll:$=>e.handleChatScroll($),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()}})}if(e.connected&&e.accessState.checked){const{accessState:d}=e;if(d.hasPins&&!d.authenticated)return Sl({show:!0,isFirstTime:!1,accounts:d.accounts,error:d.error,busy:d.busy,onSubmit:(p,v)=>{v!=null&&e.handlePinSubmit(p,v)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(p,v,$)=>e.handleChangePin(p,v,$)});if(!d.hasMasterPin&&!d.authenticated&&e.setup)return Sl({show:!0,isFirstTime:!0,accounts:[],error:d.error,busy:d.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!d.hasMasterPin&&!d.authenticated&&!e.setup)return window.location.href="/setup",w}if(e.setup){const d=d0(e.channelsSnapshot),p=((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.whatsapp)??[],v=u0(e.channelsSnapshot),$=p0(e),S=async()=>{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null},M=()=>{const y=Date.now();e.tailscaleConnectProgress=0,e.tailscaleConnectMessage=mo[0][1],e.tailscaleConnectSuccess=!1,e.tailscaleError=null,Kt(),wt=setInterval(()=>{const b=(Date.now()-y)/1e3,k=Math.min(95,95*(1-Math.exp(-b/30)));e.tailscaleConnectProgress=Math.round(k);let A=mo[0][1];for(const[E,T]of mo)b>=E&&(A=T);e.tailscaleConnectMessage=A},500)};return om({connected:e.connected,serverPlatform:((o=(s=e.hello)==null?void 0:s.server)==null?void 0:o.platform)??null,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:y=>e.handleLicenseKeyChange(y),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:d,whatsappAccounts:p,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:y=>e.handleUninstallConfirmTextChange(y),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:y=>e.handleAuthSubmitCode(y),onAuthCodeChange:y=>e.handleAuthCodeChange(y),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async y=>{await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await ee(e,!0),e.requestUpdate())},onWhatsAppUnlink:async y=>{await e.handleWhatsAppLogout(y)},onWhatsAppReset:async y=>{await e.handleWhatsAppLogout(y),await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await ee(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await ee(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),ee(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:y=>e.handleRemoveWhatsAppAccount(y),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:y=>{e.newWorkspacePin=y},onWorkspaceCreate:async(y,b)=>{const k=e.newWorkspacePin;await e.handleWorkspaceCreate(y,b),k.match(/^\d{4,6}$/)&&(await Mh(e,y,k),e.newWorkspacePin="")},onWorkspaceRemove:y=>e.handleWorkspaceRemove(y),onSetAddingWorkspace:y=>{e.addingWorkspace=y},onSetNewWorkspaceName:y=>{e.newWorkspaceName=y},onSetNewWorkspacePath:y=>{e.newWorkspacePath=y},onSetWorkspaceRemoveConfirm:y=>{e.workspaceRemoveConfirm=y},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(y,b)=>e.handleWorkspaceRename(y,b),whatsappDmPolicy:(()=>{const y=we(e),b=y==null?void 0:y.whatsappAccountId,k=b?p.find(A=>A.accountId===b):p[0];return(k==null?void 0:k.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var P;const y=we(e),b=y==null?void 0:y.whatsappAccountId,k=b?p.find(D=>D.accountId===b):p[0];if(!k)return;const E=k.dmPolicy!=null&&k.dmPolicy!=="disabled"?"disabled":"open",T=E==="open"?{dmPolicy:E,allowFrom:["*"]}:{dmPolicy:E};try{const D=await e.client.request("config.get"),W=D.config,z=(P=W==null?void 0:W.channels)==null?void 0:P.whatsapp,ke=((z==null?void 0:z.accounts)??{})[k.accountId]?{channels:{whatsapp:{accounts:{[k.accountId]:T}}}}:{channels:{whatsapp:T}};await e.client.request("config.patch",{raw:JSON.stringify(ke),baseHash:D.hash,note:`WhatsApp DM policy → ${E}`,skipRestart:!0}),await ee(e,!1)}catch(D){console.error("DM toggle failed:",D)}},whatsappGroupPolicy:(()=>{var D,W;const y=(D=e.configSnapshot)==null?void 0:D.config,b=(W=y==null?void 0:y.channels)==null?void 0:W.whatsapp,k=we(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},T=A?E[A]:void 0;return(T==null?void 0:T.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var W,z;const y=(W=e.configSnapshot)==null?void 0:W.config,b=(z=y==null?void 0:y.channels)==null?void 0:z.whatsapp,k=we(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},T=A?E[A]:void 0,D=((T==null?void 0:T.groups)??(b==null?void 0:b.groups)??{})["*"];return(D==null?void 0:D.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var k;const y=we(e),b=y==null?void 0:y.whatsappAccountId;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.channels)==null?void 0:k.whatsapp)??{},P=T.accounts??{},D=b?P[b]:void 0,W=(D==null?void 0:D.groupPolicy)??T.groupPolicy??"allowlist",z=W==="disabled"||W==="allowlist",H=z?"open":"disabled",ke=z?{"*":{}}:void 0,Me={groupPolicy:H};ke&&(Me.groups=ke);const ze=D?{channels:{whatsapp:{accounts:{[b]:Me}}}}:{channels:{whatsapp:Me}};await e.client.request("config.patch",{raw:JSON.stringify(ze),baseHash:A.hash,note:`WhatsApp groups → ${H}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group toggle failed:",A)}},onWhatsAppGroupMentionChange:async y=>{var A;const b=we(e),k=b==null?void 0:b.whatsappAccountId;try{const E=await e.client.request("config.get"),T=E.config,D=(((A=T==null?void 0:T.channels)==null?void 0:A.whatsapp)??{}).accounts??{},W=k?D[k]:void 0,z={"*":{requireMention:y}},H=W?{channels:{whatsapp:{accounts:{[k]:{groups:z}}}}}:{channels:{whatsapp:{groups:z}}};await e.client.request("config.patch",{raw:JSON.stringify(H),baseHash:E.hash,note:`WhatsApp group mention → ${y?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(E){console.error("Group mention change failed:",E)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:v.configured,imessageRunning:v.running,imessageConnected:v.connected,imessageLastError:v.lastError,imessageSelfChatMode:v.selfChatMode,imessageCliPath:v.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:$,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,k=(b==null?void 0:b.bindings)??[],A=we(e),E=A==null?void 0:A.agents.find(z=>z.id.endsWith("-admin")||z.id==="admin"),T=(E==null?void 0:E.id)??"admin",P=k.filter(z=>{var H;return((H=z.match)==null?void 0:H.channel)!=="imessage"}),D=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],W=[...P,...D];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:W}),baseHash:y.hash,note:"Enable iMessage (self-chat) for "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Fe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await ee(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,A=((b==null?void 0:b.bindings)??[]).filter(E=>{var T;return((T=E.match)==null?void 0:T.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:A}),baseHash:y.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Fe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,k=(b==null?void 0:b.bindings)??[],A=we(e),E=A==null?void 0:A.agents.find(W=>W.id.endsWith("-admin")||W.id==="admin"),T=(E==null?void 0:E.id)??"admin",P=k.filter(W=>{var z;return((z=W.match)==null?void 0:z.channel)!=="imessage"}),D=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:[...P,...D]}),baseHash:y.hash,note:"Reassign iMessage to "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Fe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:y=>{var b,k,A,E;if(e.infoModalOpen=y,y==="remote-access"){const T=((b=e.tailscaleStatus)==null?void 0:b.tailnetUrl)??((k=e.tailscaleStatus)!=null&&k.hostname?`https://${e.tailscaleStatus.hostname}`:null);T&&!e.remoteAccessQrDataUrl&&e.client.request("qr.generate",{url:T}).then(P=>{e.remoteAccessQrDataUrl=(P==null?void 0:P.dataUrl)??null}).catch(()=>{})}else if(y==="public-chat"){const T=((A=e.tailscaleStatus)==null?void 0:A.publicUrl)??((E=e.tailscaleStatus)==null?void 0:E.tailnetUrl)??null,P=e.selectedWorkspace??null;if(T&&P){const D=`${T}/public/chat/${encodeURIComponent(P)}`;e.publicChatQrDataUrl||e.client.request("qr.generate",{url:D}).then(W=>{e.publicChatQrDataUrl=(W==null?void 0:W.dataUrl)??null}).catch(()=>{})}}},onInfoModalClose:()=>{e.infoModalOpen=null},remoteAccessQrDataUrl:e.remoteAccessQrDataUrl??null,publicChatQrDataUrl:e.publicChatQrDataUrl??null,publicChatFullUrl:(()=>{var k,A;const y=((k=e.tailscaleStatus)==null?void 0:k.publicUrl)??((A=e.tailscaleStatus)==null?void 0:A.tailnetUrl)??null,b=e.selectedWorkspace??null;return!y||!b?null:`${y}/public/chat/${encodeURIComponent(b)}`})(),isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,apiKeySavingProvider:e.apiKeySavingProvider,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeySave:async(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await El(e.client,y,b);const k=`${y} key saved`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}y==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async y=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Rk(e.client,y);const b=`${y} key removed`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyDisable:async(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Dk(e.client,y,b);const k=`${y} ${b?"disabled":"enabled"}`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:`Failed to ${b?"disable":"enable"} key`,e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:y=>{e.authApiKeyInput=y},onAuthApiKeySubmit:async()=>{const y=e.authApiKeyInput.trim();if(y){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await El(e.client,"anthropic",y),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(b){e.authApiKeyError=b instanceof Error?b.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var b;const y=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return y?e.accessState.accounts.some(k=>k.id===y):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(y,b)=>{var A;const k=e.selectedWorkspace??((A=e.workspaces[0])==null?void 0:A.name);k&&e.handleAccountPinSave(k,y,b)},publicChatAccountId:e.selectedWorkspace??null,publicChatSettingsOpen:e.publicChatSettingsOpen,onPublicChatSettingsOpen:()=>{e.publicChatSettingsOpen=!0},onPublicChatSettingsClose:()=>{e.publicChatSettingsOpen=!1},publicChatWidgetModalOpen:e.publicChatWidgetModalOpen,onPublicChatWidgetModalOpen:()=>{e.publicChatWidgetModalOpen=!0},onPublicChatWidgetModalClose:()=>{e.publicChatWidgetModalOpen=!1},publicChatEnabled:(()=>{var k;const y=(k=e.configSnapshot)==null?void 0:k.config,b=y==null?void 0:y.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var T,P;const y=(T=e.configSnapshot)==null?void 0:T.config,b=y==null?void 0:y.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.auth)??(b==null?void 0:b.auth);return E==="verified"||E==="choice"?E:"anonymous"})(),publicChatGreeting:(()=>{var E;const y=(E=e.configSnapshot)==null?void 0:E.config,b=y==null?void 0:y.publicChat,k=b==null?void 0:b.greetings,A=e.selectedWorkspace??"";return(A&&(k==null?void 0:k[A]))??""})(),publicChatGreetingBusy:e.publicChatGreetingBusy,onPublicChatGreetingToggle:async()=>{var b;if(e.publicChatGreetingBusy)return;const y=e.selectedWorkspace??"";if(y){e.publicChatGreetingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=(b=A==null?void 0:A.publicChat)==null?void 0:b.greetings;if(E==null?void 0:E[y]){const P={publicChat:{greetings:{[y]:null}}};await e.client.request("config.patch",{raw:JSON.stringify(P),baseHash:k.hash,note:`Public chat greeting → disabled (${y})`,skipRestart:!0})}else{const P=await e.client.request("public.greeting.generate",{accountId:y});if(P!=null&&P.ok&&P.greeting){const D=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[y]:P.greeting}}}),baseHash:D.hash,note:`Public chat greeting → enabled (${y})`,skipRestart:!0})}}e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting toggle failed:",k)}finally{e.publicChatGreetingBusy=!1}}},onPublicChatGreetingSave:async y=>{const b=e.selectedWorkspace??"";if(b)try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[b]:y}}}),baseHash:k.hash,note:`Public chat greeting text updated (${b})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting save failed:",k)}},onPublicChatGreetingRegenerate:async()=>{if(e.publicChatGreetingBusy)return;const y=e.selectedWorkspace??"";if(y){e.publicChatGreetingBusy=!0;try{const b=await e.client.request("public.greeting.generate",{accountId:y});if(b!=null&&b.ok&&b.greeting){const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[y]:b.greeting}}}),baseHash:k.hash,note:`Public chat greeting regenerated (${y})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}}catch(b){console.error("Public chat greeting regeneration failed:",b)}finally{e.publicChatGreetingBusy=!1}}},publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var y;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),k=b.config,A=((y=k==null?void 0:k.publicChat)==null?void 0:y.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!A}}),baseHash:b.hash,note:`Public chat → ${A?"disabled":"enabled"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get"),e.publicChatQrDataUrl=null}catch(b){console.error("Public chat toggle failed:",b)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async y=>{if(e.publicChatToggleBusy)return;const b=e.selectedWorkspace??"";if(b){e.publicChatToggleBusy=!0;try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{accountSettings:{[b]:{auth:y}}}}),baseHash:k.hash,note:`Public chat auth → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat auth mode change failed:",k)}finally{e.publicChatToggleBusy=!1}}},publicChatEmailFrom:(()=>{var k,A;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(A=y==null?void 0:y.publicChat)==null?void 0:A.email;return(b==null?void 0:b.from)??""})(),publicChatEmailBusy:e.publicChatEmailBusy,publicChatVerifyMethods:(()=>{var T,P;const y=(T=e.configSnapshot)==null?void 0:T.config,b=y==null?void 0:y.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.verifyMethods)??(b==null?void 0:b.verifyMethods);return Array.isArray(E)?E:["whatsapp","sms"]})(),onPublicChatEmailSave:async(y,b)=>{if(e.publicChatEmailBusy)return;const k=e.selectedWorkspace??"";if(k){e.publicChatEmailBusy=!0;try{const A=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{email:{from:y||void 0},accountSettings:{[k]:{verifyMethods:b}}}}),baseHash:A.hash,note:"Update email verification settings for public chat",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Email verification save failed:",A)}finally{e.publicChatEmailBusy=!1}}},brandAccentColor:(()=>{var k;const y=e.selectedWorkspace;return y?((k=Ne()[y])==null?void 0:k.accentColor)??"":""})(),brandBackgroundColor:(()=>{var k;const y=e.selectedWorkspace;return y?((k=Ne()[y])==null?void 0:k.backgroundColor)??"":""})(),brandHasLogo:(()=>{var k;const y=e.selectedWorkspace;return y?!!((k=Ne()[y])!=null&&k.logoUrl):!1})(),agentSettingsOpen:e.agentSettingsOpen,agentSettingsAgents:(()=>{var A,E;const y=we(e);if(!y)return[];const b=(A=e.configSnapshot)==null?void 0:A.config,k=(E=b==null?void 0:b.agents)==null?void 0:E.list;return y.agents.map(T=>{var H;const P=Array.isArray(k)?k.find(ke=>ke.id===T.id):void 0,D=P==null?void 0:P.model,W=typeof D=="string"?D:(D==null?void 0:D.primary)??null,z=T.id.endsWith("-admin")||T.id==="admin";return{id:T.id,label:z?"Admin":"Public",model:(W==null?void 0:W.trim())||null,thinkingLevel:((H=P==null?void 0:P.thinkingLevel)==null?void 0:H.trim())||null}})})(),agentSettingsModelCatalog:e.chatModelCatalog??[],memoryProvider:(()=>{var k,A,E;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(E=(A=y==null?void 0:y.agents)==null?void 0:A.defaults)==null?void 0:E.memorySearch;return typeof(b==null?void 0:b.provider)=="string"&&b.provider?b.provider:"local"})(),memoryFallback:(()=>{var k,A,E;const y=(k=e.configSnapshot)==null?void 0:k.config,b=(E=(A=y==null?void 0:y.agents)==null?void 0:A.defaults)==null?void 0:E.memorySearch;return typeof(b==null?void 0:b.fallback)=="string"&&b.fallback?b.fallback:"none"})(),onAgentSettingsToggle:()=>{e.agentSettingsOpen=!e.agentSettingsOpen},onAgentModelChange:async(y,b)=>{try{const k=await e.client.request("config.get"),A=k.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],P=T.findIndex(W=>W.id===y);if(b)P>=0?T[P]={...T[P],model:b}:T.push({id:y,model:b});else if(P>=0){const{model:W,...z}=T[P];Object.keys(z).length<=1?T.splice(P,1):T[P]=z}const D=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(D),baseHash:k.hash,note:`Agent ${y} model → ${b||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Agent model change failed:",k)}},onAgentThinkingChange:async(y,b)=>{try{const k=await e.client.request("config.get"),A=k.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],P=T.findIndex(z=>z.id===y),D=b==="off"?void 0:b;if(D)P>=0?T[P]={...T[P],thinkingLevel:D}:T.push({id:y,thinkingLevel:D});else if(P>=0){const{thinkingLevel:z,...H}=T[P];Object.keys(H).length<=1?T.splice(P,1):T[P]=H}const W=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(W),baseHash:k.hash,note:`Agent ${y} thinking → ${D||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Agent thinking change failed:",k)}},onMemoryProviderChange:async y=>{try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({agents:{defaults:{memorySearch:{provider:y}}}}),baseHash:b.hash,note:`Memory search provider → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Memory provider change failed:",b)}},onMemoryFallbackChange:async y=>{try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({agents:{defaults:{memorySearch:{fallback:y}}}}),baseHash:b.hash,note:`Memory search fallback → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Memory fallback change failed:",b)}},brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async y=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=T.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...T,brand:{...P,accentColor:y}}}}),baseHash:A.hash,note:`Brand accent → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const D=Ne();D[b]||(D[b]={}),D[b].accentColor=y,Tn(b)}catch(A){console.error("Brand accent change failed:",A)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async y=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,T=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=T.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...T,brand:{...P,backgroundColor:y}}}}),baseHash:A.hash,note:`Brand background → ${y}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const D=Ne();D[b]||(D[b]={}),D[b].backgroundColor=y,Tn(b)}catch(A){console.error("Brand background change failed:",A)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async y=>{const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const k=await y.arrayBuffer(),A=new Uint8Array(k);let E="";for(let D=0;D<A.length;D++)E+=String.fromCharCode(A[D]);const T=btoa(E);await e.client.request("brand.uploadLogo",{workspace:b,data:T,mimeType:y.type});const P=Ne();P[b]||(P[b]={}),P[b].logoUrl=`/brand-logo/${encodeURIComponent(b)}`}catch(k){console.error("Brand logo upload failed:",k)}finally{e.brandingBusy=!1}}},onBrandLogoRemove:async()=>{const y=e.selectedWorkspace;if(!(!y||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:y});const b=Ne();b[y]&&delete b[y].logoUrl}catch(b){console.error("Brand logo remove failed:",b)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var b;const y=e.selectedWorkspace;if(!(!y||e.brandingBusy)){e.brandingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=((b=A==null?void 0:A.workspaces)==null?void 0:b[y])??{},{brand:T,...P}=E;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[y]:{...P,brand:null}}}),baseHash:k.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:y})}catch{}const D=Ne();delete D[y],Tn(y)}catch(k){console.error("Brand reset failed:",k)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleServeEnableUrl:e.tailscaleServeEnableUrl,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,tailscaleDisableConfirm:e.tailscaleDisableConfirm,tailscaleConnectProgress:e.tailscaleConnectProgress,tailscaleConnectMessage:e.tailscaleConnectMessage,tailscaleConnectSuccess:e.tailscaleConnectSuccess,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null,M();try{const y=await e.client.request("tailscale.enable");y.authUrl?(wt&&(clearInterval(wt),wt=null),e.tailscaleConnectProgress=100,e.tailscaleConnectMessage="Waiting for authentication...",e.tailscaleAuthUrl=y.authUrl,Mi=setInterval(async()=>{try{const b=await e.client.request("tailscale.status");e.tailscaleStatus=b,e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,b.loggedIn&&(Kt(),e.tailscaleAuthUrl=null,e.tailscaleConnectSuccess=!0,e.tailscaleConnectMessage="Connected!",setTimeout(()=>{e.tailscaleConnectSuccess=!1,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1},1500))}catch{}},3e3),Pi=setTimeout(()=>{Kt(),e.tailscaleBusy&&(e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)},3e5)):y.alreadyLoggedIn?(Kt(),e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1):(Kt(),e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)}catch(y){console.error("Tailscale enable failed:",y),Kt(),e.tailscaleError=y.message||"Failed to enable Remote Access",e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1}}},onTailscaleErrorDismiss:()=>{e.tailscaleError=null},onTailscaleServeEnable:async()=>{var y;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleServeEnableUrl=null;try{await e.client.request("tailscale.serve.enable"),await S()}catch(b){console.error("Tailscale serve enable failed:",b);const k=b;(y=k.payload)!=null&&y.enableUrl&&(e.tailscaleServeEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Remote Access"}finally{e.tailscaleBusy=!1}}},onTailscaleServeDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.serve.disable"),await S()}catch(y){console.error("Tailscale serve disable failed:",y)}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var y;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable"),await S()}catch(b){console.error("Tailscale funnel enable failed:",b);const k=b;(y=k.payload)!=null&&y.enableUrl&&(e.tailscaleFunnelEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Funnel"}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable"),await S()}catch(y){console.error("Tailscale funnel disable failed:",y)}finally{e.tailscaleBusy=!1}}},onTailscaleDisableConfirmToggle:()=>{e.tailscaleDisableConfirm=!e.tailscaleDisableConfirm},wifiModalOpen:e.wifiModalOpen,onWifiModalToggle:()=>{e.wifiModalOpen=!e.wifiModalOpen,e.wifiModalOpen||(e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null)},wifiStatus:e.wifiStatus,wifiNetworks:e.wifiNetworks,wifiBusy:e.wifiBusy,wifiError:e.wifiError,wifiPassword:e.wifiPassword,wifiSelectedSsid:e.wifiSelectedSsid,onWifiScan:async()=>{var y;if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[b,k]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiNetworks=b.networks,k.connected&&k.signal==null&&((y=b.networks)!=null&&y.length)){const A=b.networks.find(E=>E.active)||b.networks.find(E=>E.ssid===k.ssid);A&&(k.signal=A.signal)}e.wifiStatus=k}catch(b){console.error("WiFi scan failed:",b),e.wifiError=b.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{var b;if(e.wifiBusy||!e.wifiSelectedSsid)return;const y=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const k=await e.client.request("wifi.connect",{ssid:y,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:k.connected,ssid:k.ssid,signal:null,ip:k.ip,savedSsid:k.ssid,autoconnect:!0},e.wifiBusy=!1;try{const[A,E]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(E.connected&&E.signal==null&&((b=A.networks)!=null&&b.length)){const T=A.networks.find(P=>P.active)||A.networks.find(P=>P.ssid===E.ssid);T&&(E.signal=T.signal)}e.wifiStatus=E}catch{}}catch(k){console.error("WiFi connect failed:",k),e.wifiError=k.message||"Failed to connect",e.wifiBusy=!1}},onWifiDisconnect:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.disconnect"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const y=await e.client.request("wifi.status");e.wifiStatus=y}catch(y){console.error("WiFi disconnect failed:",y),e.wifiError=y.message||"Failed to disconnect"}finally{e.wifiBusy=!1}}},onWifiForget:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.forget"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const y=await e.client.request("wifi.status");e.wifiStatus=y}catch(y){console.error("WiFi forget failed:",y),e.wifiError=y.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:y=>{e.wifiSelectedSsid=y,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:y=>{e.wifiPassword=y},networkPort:e.networkPort,networkHostname:e.networkHostname,networkPortInput:e.networkPortInput,networkHostnameInput:e.networkHostnameInput,networkModalOpen:e.networkModalOpen,networkBusy:e.networkBusy,networkError:e.networkError,networkSuccess:e.networkSuccess,onNetworkModalToggle:()=>{e.networkModalOpen=!e.networkModalOpen,e.networkModalOpen&&(e.networkPortInput=String(e.networkPort??""),e.networkHostnameInput=e.networkHostname,e.networkError=null,e.networkSuccess=null)},onNetworkPortChange:y=>{e.networkPortInput=y,e.networkError=null,e.networkSuccess=null},onNetworkHostnameChange:y=>{e.networkHostnameInput=y,e.networkError=null,e.networkSuccess=null},onNetworkSave:async()=>{if(e.networkBusy)return;e.networkBusy=!0,e.networkError=null,e.networkSuccess=null;const y=e.networkPortInput.trim(),b=Number.parseInt(y,10),k=e.networkHostnameInput.trim();if(!y||!Number.isFinite(b)||b<1024||b>65535){e.networkError="Port must be a number between 1024 and 65535",e.networkBusy=!1;return}const A=b!==e.networkPort,E=k!==e.networkHostname;if(!A&&!E){e.networkBusy=!1;return}try{E&&await e.client.request("network.setHostname",{hostname:k});const T={};A&&(T.gateway={port:b}),E&&(T.discovery={bonjourHostname:k});const P=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify(T),baseHash:P.hash,note:[A?`Port → ${b}`:null,E?`Hostname → ${k}`:null].filter(Boolean).join(", "),restartDelayMs:2e3}),e.networkSuccess="Saved — redirecting...";const D=window.location.protocol,W=E?`${k}.local`:window.location.hostname,z=A?b:e.networkPort,H=`${D}//${W}:${z}/setup`;setTimeout(()=>{window.location.href=H},1500)}catch(T){console.error("Network save failed:",T),e.networkError=T.message||"Failed to save network settings",e.networkBusy=!1}},wsProps:s0(e)})}if(e.filesPage){const d=a0(e);return bg({connected:e.connected,wsProps:Sn(e),loading:e.filesLoading,tree:e.filesTree,root:e.filesRoot,error:e.filesError,selectedPath:e.filesSelectedPath,selectedPaths:e.filesSelectedPaths,previewContent:e.filesPreviewContent,previewLoading:e.filesPreviewLoading,previewBinary:e.filesPreviewBinary,previewSize:e.filesPreviewSize,expandedDirs:e.filesExpandedDirs,currentDir:e.filesCurrentDir,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>{rn(e,d),cs(e,d)},onReindex:()=>Lf(e,d),onSelectFile:p=>{e.filesPendingDeletePath=null,Af(e,p,d)},onToggleSelectFile:p=>Cf(e,p,d),onToggleDir:p=>Rf(e,p),onUpload:(p,v)=>_f(e,p,v,d),onNewFolder:(p,v)=>Mf(e,p,v,d),onDownload:p=>rd(e,p,d),onBulkDownload:()=>Ef(e,d),onDelete:p=>{e.filesPendingDeletePath=null,Pf(e,p,d)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,v)=>Tf(e,p,v,d),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const v=e.filesSearchAgentId??d;Df(e,p,v)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{Bf(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return hg({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,fullscreen:e.browserFullscreen,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>Ck(e),onStop:()=>Ek(e),onToggleInput:()=>_k(e),onToggleFullscreen:()=>Mk(e),onCompleteHandoff:()=>Tk(e),onCanvasMouseDown:d=>{const v=d.target.getBoundingClientRect(),S=Bn().translateCoordinates(d.clientX-v.left,d.clientY-v.top);po(e,"mousePressed",S.x,S.y,d.button===2?"right":d.button===1?"middle":"left")},onCanvasMouseUp:d=>{const v=d.target.getBoundingClientRect(),S=Bn().translateCoordinates(d.clientX-v.left,d.clientY-v.top);po(e,"mouseReleased",S.x,S.y)},onCanvasMouseMove:d=>{const p=Bn();if(p.shouldThrottleMouseMove())return;const $=d.target.getBoundingClientRect(),S=p.translateCoordinates(d.clientX-$.left,d.clientY-$.top);po(e,"mouseMoved",S.x,S.y)},onCanvasKeyDown:d=>{let p=0;d.altKey&&(p|=1),d.ctrlKey&&(p|=2),d.metaKey&&(p|=4),d.shiftKey&&(p|=8),ho(e,"keyDown",d.key,{code:d.code,modifiers:p||void 0}),d.key.length===1&&ho(e,"char",d.key,{text:d.key})},onCanvasKeyUp:d=>{ho(e,"keyUp",d.key,{code:d.code})}});if(e.adminsPage){const d=o0(e),p=Ka(e);return rm({connected:e.connected,wsProps:Sn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>ys(e,d),onAdd:v=>{Iu(e,v,d,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:v=>Lu(e,v,d,p),onNewPhoneChange:v=>e.handleAdminsNewPhoneChange(v)})}if(e.contactsPage){const d=r0(e);return hm({connected:e.connected,wsProps:Sn(e),loading:e.contactsLoading,saving:e.contactsSaving,records:e.contactsRecords,error:e.contactsError,searchQuery:e.contactsSearchQuery,editingId:e.contactsEditingId,showAddForm:e.contactsShowAddForm,newRecordPhone:e.contactsNewPhone,newRecordName:e.contactsNewName,deleteConfirmId:e.contactsDeleteConfirmId,addFieldForId:e.contactsAddFieldForId,addFieldKey:e.contactsAddFieldKey,addFieldValue:e.contactsAddFieldValue,onSearch:p=>e.contactsSearchQuery=p,onSearchSubmit:()=>Pt(e,d),onAdd:(p,v)=>Ru(e,p,v,d),onDelete:p=>Du(e,p,d),onSetField:(p,v,$)=>jo(e,p,v,$,d),onDeleteField:(p,v)=>Bu(e,p,v,d),onToggleExpand:p=>{e.contactsEditingId=e.contactsEditingId===p?null:p},onShowAddForm:()=>e.contactsShowAddForm=!0,onCancelAddForm:()=>{e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName=""},onNewRecordPhoneChange:p=>e.handleContactsNewPhoneChange(p),onNewRecordNameChange:p=>e.handleContactsNewNameChange(p),onRefresh:()=>Pt(e,d),onDeleteConfirmOpen:p=>e.contactsDeleteConfirmId=p,onDeleteConfirmClose:()=>e.contactsDeleteConfirmId=null,onAddFieldOpen:p=>{e.contactsAddFieldForId=p,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldClose:()=>{e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldKeyChange:p=>e.contactsAddFieldKey=p,onAddFieldValueChange:p=>e.contactsAddFieldValue=p,onAddFieldSubmit:()=>{const p=e.contactsAddFieldForId,v=e.contactsAddFieldKey.trim();!p||!v||(jo(e,p,v,e.contactsAddFieldValue,d),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const d=e.connected?null:"Disconnected from gateway.",p=Dl(e),v=e.chatAvatarUrl??p??null,$=(()=>{var y;const S=(y=e.configSnapshot)==null?void 0:y.config,M=S==null?void 0:S.publicChat;return(M==null?void 0:M.enabled)===!0})();return fw({connected:e.connected,wsProps:Sn(e),publicChatEnabled:$,publicChatAccountId:e.selectedWorkspace??void 0,chatPageTab:e.chatPageTab??"chat",onChatPageTabChange:S=>{if(e.chatPageTab=S,S==="whatsapp"&&!e.waLoading&&e.waConversations.length===0){const M=Ii(e);vu(M).then(()=>e.requestUpdate())}},whatsappProps:f0(e),sessionKey:e.sessionKey,onSessionKeyChange:S=>{const M=e.selectedWorkspace??"";wo(),Wn(M,e.sessionKey,e.chatMessage),e.sessionKey=S,e.chatMessage=Kn(M,S),e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestions=[],e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:S,lastActiveSessionKey:S}),e.loadAssistantIdentity(),Jt(e),Eo(e)},showThinking:e.settings.chatShowThinking??!1,verboseLevel:e.chatVerboseLevel,suggestions:e.chatSuggestions,onSuggestionClick:S=>{e.chatMessage=S,e.chatSuggestions=[],e.handleSendChat()},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:v,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:d,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const S=Math.max(e.chatMessages.length+10,nn);return Promise.all([Jt(e,{limit:S}),Eo(e)])},onToggleFocusMode:()=>{},onChatScroll:S=>e.handleChatScroll(S),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:S=>{e.chatMessage=S,wr(e.selectedWorkspace??"",e.sessionKey,S)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:S=>e.chatAttachments=S,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:S=>e.removeQueuedMessage(S),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:S=>e.handleOpenSidebar(S),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:S=>e.handleSplitRatioChange(S),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?hk({connected:e.connected,wsProps:Sn(e),activeTab:e.advancedTab,onTabChange:d=>{e.advancedTab=d,d==="cron"&&e.loadCron(),d==="skills"&&We(e,{clearMessages:!0}),d==="opening-hours"&&Wa(e),d==="logs"&&(e.logsSubTab==="session"?Pn(e,{reset:!0}):Gt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(a=e.channelsSnapshot)==null?void 0:a.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(d=>d.id):((u=e.channelsSnapshot)==null?void 0:u.channelOrder)??[],channelLabels:((c=e.channelsSnapshot)==null?void 0:c.channelLabels)??{},channelMeta:((h=e.channelsSnapshot)==null?void 0:h.channelMeta)??[],agentIds:(()=>{var p;const d=we(e);return((p=d==null?void 0:d.agents)==null?void 0:p.map(v=>v.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1,e.cronEditJobId=null},detailJobId:e.cronDetailJobId,editJobId:e.cronEditJobId,onDetailOpen:d=>{e.cronDetailJobId=d.id,xo(e,d.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:d=>{e.cronForm=Sh(d),e.cronEditJobId=d.id,e.cronDetailJobId=null},onEditSave:()=>{const d=e.cronEditJobId;d&&Ah(e,d).then(()=>{e.cronEditJobId=null})},onFormChange:d=>e.cronForm={...e.cronForm,...d},onRefresh:()=>e.loadCron(),onAdd:()=>{bh(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(d,p)=>wh(e,d,p),onRun:d=>kh(e,d),onRemove:d=>{e.cronPendingDeleteId=null,$h(e,d)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:d=>{e.cronPendingDeleteId=d||null},onLoadRuns:d=>xo(e,d),runModalJobId:e.cronRunModalJobId,runModalJobName:e.cronRunModalJobName,runResult:e.cronRunResult,onRunModalClose:()=>{e.cronRunModalJobId=null,e.cronRunModalJobName="",e.cronRunResult=null}},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,typeFilter:e.skillsTypeFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,detail:e.skillDetail,detailTab:e.skillDetailTab,addModal:e.skillAddModal,addForm:e.skillAddForm,formSource:e.skillAddFormSource,editTab:e.skillEditTab,drafts:e.skillDrafts,onFilterChange:d=>e.skillsFilter=d,onTypeFilterChange:d=>e.skillsTypeFilter=d,onRefresh:()=>We(e,{clearMessages:!0}),onToggle:(d,p)=>Oc(e,d,p),onEdit:(d,p)=>Nc(e,d,p),onSaveKey:d=>Fc(e,d),onInstall:(d,p,v)=>Uc(e,d,p,v),onViewDetail:d=>Wc(e,d),onDetailClose:()=>Kc(e),onDetailTab:d=>zc(e,d),onAddOpen:()=>Hc(e),onAddClose:()=>qc(e),onImportDraft:d=>jc(e,d),onInstallDraft:d=>Gc(e,d),onDeleteDraft:d=>Vc(e,d),onAddSave:()=>ua(e),onAddFormUpdate:(d,p)=>{e.skillAddForm={...e.skillAddForm,[d]:p}},onAlwaysActiveToggle:(d,p)=>Zc(e,d,p),onDelete:d=>ed(e,d),onEditSkill:d=>Qc(e,d),onEditDetail:d=>Jc(e,d),onRefUpdate:(d,p)=>Yc(e,d,p),onEditTab:d=>Xc(e,d)},logsProps:{logsSubTab:e.logsSubTab,isAdmin:e.accessState.master||!e.accessState.hasPins,onSubTabChange:d=>{e.logsSubTab=d,d==="session"?Pn(e,{reset:!0}):Gt(e,{reset:!0})},sessionLogsProps:{loading:e.sessionLogsLoading,error:e.sessionLogsError,entries:e.sessionLogsEntries,agents:e.sessionLogsAgents,filterText:e.sessionLogsFilterText,typeFilters:e.sessionLogsTypeFilters,agentFilters:e.sessionLogsAgentFilters,autoFollow:e.sessionLogsAutoFollow,chipsExpanded:e.sessionLogsChipsExpanded,expandedIds:e.sessionLogsExpandedIds,onFilterTextChange:d=>e.sessionLogsFilterText=d,onTypeToggle:(d,p)=>{const v=e;v.sessionLogsTypeFilters={...v.sessionLogsTypeFilters,[d]:p}},onAgentToggle:(d,p)=>{const v=e;v.sessionLogsAgentFilters={...v.sessionLogsAgentFilters,[d]:p}},onToggleAutoFollow:d=>e.sessionLogsAutoFollow=d,onToggleChips:()=>{const d=e;d.sessionLogsChipsExpanded=!d.sessionLogsChipsExpanded},onToggleExpand:d=>{const p=e,v=new Set(p.sessionLogsExpandedIds);v.has(d)?v.delete(d):v.add(d),p.sessionLogsExpandedIds=v,p.requestUpdate()},onRefresh:()=>{Pn(e,{reset:!0})},onExport:(d,p)=>e.exportSessionLogs(d,p),onScroll:d=>e.handleSessionLogsScroll(d)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,chipsExpanded:e.logsChipsExpanded,truncated:e.logsTruncated,onFilterTextChange:d=>e.logsFilterText=d,onLevelToggle:(d,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[d]:p}},onToggleAutoFollow:d=>e.logsAutoFollow=d,onToggleChips:()=>{const d=e;d.logsChipsExpanded=!d.logsChipsExpanded},onRefresh:()=>Gt(e,{reset:!0}),onExport:(d,p)=>e.exportSessionLogs(d,p),onScroll:d=>e.handleLogsScroll(d)},openingHoursProps:{loading:e.openingHoursLoading,error:e.openingHoursError,busy:e.openingHoursBusy,form:e.openingHoursForm,onFormChange:d=>{const p=e;p.openingHoursForm={...p.openingHoursForm,...d}},onDayChange:(d,p,v)=>{const $=e,S={...$.openingHoursForm.days};S[d]={...S[d],[p]:v},$.openingHoursForm={...$.openingHoursForm,days:S}},onAddClosedDate:d=>{const p=e;p.openingHoursForm.closedDates.includes(d)||(p.openingHoursForm={...p.openingHoursForm,closedDates:[...p.openingHoursForm.closedDates,d].sort()})},onRemoveClosedDate:d=>{const p=e;p.openingHoursForm={...p.openingHoursForm,closedDates:p.openingHoursForm.closedDates.filter(v=>v!==d)}},onSave:()=>{Mu(e)}}}):(window.location.replace("/chat"),l``)}function m0(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${i}`}function Bl(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function y0(e,t,n){return l`
4742
4748
  <div class="audit-modal-overlay" @click=${s=>{s.target.classList.contains("audit-modal-overlay")&&n()}}>
4743
4749
  <div class="audit-modal-card">
4744
4750
  <div class="audit-modal-header">
@@ -4758,7 +4764,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4758
4764
  <a href="/files" class="audit-modal-path-link">${s.path}</a>
4759
4765
  </div>
4760
4766
  <div class="audit-modal-entry-meta">
4761
- ${g0(s.timestamp)}
4767
+ ${m0(s.timestamp)}
4762
4768
  <span class="audit-modal-agent">${s.agentId}</span>
4763
4769
  </div>
4764
4770
  </div>
@@ -4770,7 +4776,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4770
4776
  `}
4771
4777
  </div>
4772
4778
  </div>
4773
- `}const y0={trace:!1,debug:!1,info:!0,warn:!0,error:!0,fatal:!0},v0={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};function b0(e){e.basePath=qf();const t=Qe();Gl(t.accentColor),Vl(t.backgroundColor);const n=document.querySelector('link[rel="icon"]');if(n&&(n.href=t.iconUrl),window.scrollTo(0,0),Of(e),e.publicChat){const i=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,s=(i==null?void 0:i.accountId)??"",o=s?s.charAt(0).toUpperCase()+s.slice(1):"Assistant";document.title=`Chat with ${o}`,De(e);return}if(e.setup){document.title=`${t.name} Setup`,De(e);return}if(e.filesPage){document.title=`${t.name} Files`,Uf(e),De(e);return}if(e.browserPage){document.title=`${t.name} Browser`,De(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,De(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,De(e);return}if(e.chatPage){document.title=`${t.name} Chat`,De(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,De(e);return}Qf(e,!0),jf(e),Gf(e),window.addEventListener("popstate",e.popStateHandler),Kf(e),De(e),Bf(e),e.tab==="logs"&&(e.logsSubTab==="session"?ga(e):ha(e)),e.tab==="debug"&&ya(e)}function w0(e){fh(e)}function k0(e){var t;window.removeEventListener("popstate",e.popStateHandler),Nf(e),fa(e),ma(e),va(e),Ff(e),Wf(e),Vf(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function x0(e,t){if(!e.publicChat){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.contactsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleContactsLoad&&e.handleContactsLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const i=t.has("setupStep")&&e.setupStep==="auth";(n||i)&&e.setupStep==="auth"&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="whatsapp"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(o=>{e.channelsSnapshot=o,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(s=>{e.channelsSnapshot=s,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),i=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;sn(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&lc(e,t.has("tab")||t.has("logsAutoFollow"))}}function $0(e){const t={name:(e==null?void 0:e.name)??"",displayName:(e==null?void 0:e.displayName)??"",about:(e==null?void 0:e.about)??"",picture:(e==null?void 0:e.picture)??"",banner:(e==null?void 0:e.banner)??"",website:(e==null?void 0:e.website)??"",nip05:(e==null?void 0:e.nip05)??"",lud16:(e==null?void 0:e.lud16)??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e!=null&&e.banner||e!=null&&e.website||e!=null&&e.nip05||e!=null&&e.lud16)}}async function S0(e,t,n){await ea(e,t,n),await ee(e,!0)}async function A0(e,t){await hc(e,t),await ee(e,!0)}async function C0(e,t){await fc(e,t),await ee(e,!0)}async function E0(e,t){await gc(e,t)}async function T0(e,t){await mc(e,t)}async function _0(e){await yh(e),await Oe(e),await ee(e,!0)}async function M0(e){await Oe(e),await ee(e,!0)}function P0(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[i,...s]=n.split(":");if(!i||s.length===0)continue;const o=i.trim(),a=s.join(":").trim();o&&a&&(t[o]=a)}return t}function Bu(e){var n,i,s;return((s=(((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.nostr)??[])[0])==null?void 0:s.accountId)??e.nostrProfileAccountId??"default"}function Nu(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function I0(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=$0(n??void 0)}function L0(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function R0(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function D0(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function B0(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Bu(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Nu(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const o=(s==null?void 0:s.error)??`Profile update failed (${i.status})`;e.nostrProfileFormState={...t,saving:!1,error:o,success:null,fieldErrors:P0(s==null?void 0:s.details)};return}if(!s.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await ee(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function N0(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Bu(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Nu(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const u=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:u,success:null};return}const o=s.merged??s.imported??null,a=o?{...t.values,...o}:t.values,r=!!(a.banner||a.website||a.nip05||a.lud16);e.nostrProfileFormState={...t,importing:!1,values:a,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:r},s.saved&&await ee(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function O0(e){if(e.client){e.authBusy=!0,e.authMessage=null;try{const t=await e.client.request("auth.status",{});e.authConnected=t.connected,e.authExpiresIn=t.expiresIn??null,e.authMessage=t.message??null,t.connected&&(e.setupStep="whatsapp")}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to check auth status"}finally{e.authBusy=!1}}}async function F0(e){if(e.client){e.authBusy=!0,e.authMessage=null,e.authUrl=null,e.authConnected=null;try{const t=await e.client.request("auth.oauth.start",{provider:"anthropic"});e.authUrl=t.authUrl,e.authMessage=t.message??"Sign in with your Claude Pro account"}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to start auth flow"}finally{e.authBusy=!1}}}async function U0(e,t){if(e.client){e.authBusy=!0,e.authMessage="Verifying code...";try{await e.client.request("auth.oauth.code",{code:t});const n=await e.client.request("auth.oauth.wait",{timeoutMs:3e4});n.connected?(e.authConnected=!0,e.authMessage=n.message??"Connected to Claude!",e.authUrl=null,e.authCodeInput=""):e.authMessage=n.message??"Still waiting for authorization..."}catch(n){e.authConnected=!1,e.authMessage=n instanceof Error?n.message:"Verification failed"}finally{e.authBusy=!1}}}function W0(e,t){e.authCodeInput=t}function K0(e){e.setupStep="whatsapp"}async function z0(e){if(e.client){e.licenseBusy=!0,e.licenseMessage=null;try{const t=await e.client.request("license.status",{});e.licenseDeviceId=t.deviceId??null,e.licenseStoredKey=t.key??null,t.licensed?(e.licenseValid=!0,e.licenseTier=t.tier??null,e.setupStep="auth"):(e.licenseValid=null,e.setupStep="license")}catch(t){const n=t instanceof Error?t.message:String(t);n.includes("unknown method")?(e.licenseValid=!0,e.setupStep="auth"):(e.licenseValid=null,e.licenseMessage=n,e.setupStep="license")}finally{e.licenseBusy=!1}}}async function H0(e){if(e.client&&e.licenseKey.trim()){e.licenseBusy=!0,e.licenseMessage=null,e.licenseValid=null;try{const t=await e.client.request("license.activate",{key:e.licenseKey.trim()});t.valid?(e.licenseValid=!0,e.licenseMessage=t.message??"License activated",e.licenseTier=t.tier??null,setTimeout(()=>{e.setupStep="auth"},1500)):(e.licenseValid=!1,e.licenseMessage=t.message??"Invalid license key")}catch(t){e.licenseValid=!1,e.licenseMessage=t instanceof Error?t.message:"Activation failed"}finally{e.licenseBusy=!1}}}async function q0(e){if(e.client){e.licenseBusy=!0;try{await e.client.request("license.remove",{}),e.licenseValid=null,e.licenseKey="",e.licenseTier=null,e.licenseMessage=null,e.setupStep="license"}catch(t){e.licenseMessage=t instanceof Error?t.message:"Failed to remove license"}finally{e.licenseBusy=!1}}}function j0(e,t){e.licenseKey=t}async function G0(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("health",{probe:!0});e.gatewayHealthy=i.ok===!0,e.gatewayHealthMessage=i.ok?`Healthy${i.durationMs?` (${i.durationMs}ms)`:""}`:"Unhealthy"}catch(i){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(i)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function V0(e){var t,n,i;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(s.ok&&((n=s.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(s){e.gatewayHealthMessage=`Restart failed: ${String(s)}`,e.gatewayRestartBusy=!1,(i=e.requestUpdate)==null||i.call(e)}}}var Q0=Object.defineProperty,J0=Object.getOwnPropertyDescriptor,g=(e,t,n,i)=>{for(var s=i>1?void 0:i?J0(t,n):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(i?a(t,n,s):a(s))||s);return i&&s&&Q0(t,n,s),s};const yo=xp();function Y0(){if(!window.location.search)return!1;const t=new URLSearchParams(window.location.search).get("onboarding");if(!t)return!1;const n=t.trim().toLowerCase();return n==="1"||n==="true"||n==="yes"||n==="on"}function X0(){const e=window.location.pathname;if(e==="/setup"||e.endsWith("/setup"))return!0;if(!window.location.search)return!1;const n=new URLSearchParams(window.location.search).get("setup");if(!n)return!1;const i=n.trim().toLowerCase();return i==="1"||i==="true"||i==="yes"||i==="on"}function Z0(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function ex(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function tx(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function nx(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function ix(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function sx(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let f=class extends jt{constructor(){super(...arguments),this.settings=Rs(),this.password="",this.tab="chat",this.onboarding=Y0(),this.setup=X0(),this.filesPage=Z0(),this.browserPage=ex(),this.adminsPage=tx(),this.contactsPage=nx(),this.chatPage=ix(),this.advancedPage=sx(),this.advancedTab="cron",this.publicChat=!!window.__TASKMASTER_PUBLIC_CHAT__,this.publicChatConfig=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__??{},this.publicChatSessionKey=null,this.publicChatAuthenticated=!1,this.publicChatAuthStep="idle",this.connected=!1,this.accessState=yc,this.theme=this.settings.theme??"system",this.themeResolved="dark",this.hello=null,this.lastError=null,this.eventLog=[],this.eventLogBuffer=[],this.toolStreamSyncTimer=null,this.sidebarCloseTimer=null,this.assistantName=yo.name,this.assistantAvatar=yo.avatar,this.assistantAgentId=yo.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatHistoryTotal=0,this.chatHistoryHasMore=!1,this.chatLoadingOlder=!1,this.chatToolMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatModelCatalog=[],this.chatVerboseLevel=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
4779
+ `}const v0={trace:!1,debug:!1,info:!0,warn:!0,error:!0,fatal:!0},b0={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};function w0(e){e.basePath=jf();const t=Xe();Gl(t.accentColor),Vl(t.backgroundColor);const n=document.querySelector('link[rel="icon"]');if(n&&(n.href=t.iconUrl),window.scrollTo(0,0),Ff(e),e.publicChat){const i=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,s=(i==null?void 0:i.accountId)??"",o=s?s.charAt(0).toUpperCase()+s.slice(1):"Assistant";document.title=`Chat with ${o}`,Be(e);return}if(e.setup){document.title=`${t.name} Setup`,Be(e);return}if(e.filesPage){document.title=`${t.name} Files`,Wf(e),Be(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Be(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Be(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,Be(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Be(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Be(e);return}Jf(e,!0),Gf(e),Vf(e),window.addEventListener("popstate",e.popStateHandler),zf(e),Be(e),Nf(e),e.tab==="logs"&&(e.logsSubTab==="session"?ga(e):ha(e)),e.tab==="debug"&&ya(e)}function k0(e){gh(e)}function x0(e){var t;window.removeEventListener("popstate",e.popStateHandler),Of(e),fa(e),ma(e),va(e),Uf(e),Kf(e),Qf(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function $0(e,t){if(!e.publicChat){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.contactsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleContactsLoad&&e.handleContactsLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const i=t.has("setupStep")&&e.setupStep==="auth";(n||i)&&e.setupStep==="auth"&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="whatsapp"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(o=>{e.channelsSnapshot=o,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(s=>{e.channelsSnapshot=s,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),i=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;sn(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&lc(e,t.has("tab")||t.has("logsAutoFollow"))}}function S0(e){const t={name:(e==null?void 0:e.name)??"",displayName:(e==null?void 0:e.displayName)??"",about:(e==null?void 0:e.about)??"",picture:(e==null?void 0:e.picture)??"",banner:(e==null?void 0:e.banner)??"",website:(e==null?void 0:e.website)??"",nip05:(e==null?void 0:e.nip05)??"",lud16:(e==null?void 0:e.lud16)??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e!=null&&e.banner||e!=null&&e.website||e!=null&&e.nip05||e!=null&&e.lud16)}}async function A0(e,t,n){await ea(e,t,n),await ee(e,!0)}async function C0(e,t){await hc(e,t),await ee(e,!0)}async function E0(e,t){await fc(e,t),await ee(e,!0)}async function T0(e,t){await gc(e,t)}async function _0(e,t){await mc(e,t)}async function M0(e){await vh(e),await Fe(e),await ee(e,!0)}async function P0(e){await Fe(e),await ee(e,!0)}function I0(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[i,...s]=n.split(":");if(!i||s.length===0)continue;const o=i.trim(),a=s.join(":").trim();o&&a&&(t[o]=a)}return t}function Nu(e){var n,i,s;return((s=(((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.nostr)??[])[0])==null?void 0:s.accountId)??e.nostrProfileAccountId??"default"}function Ou(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function L0(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=S0(n??void 0)}function R0(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function D0(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function B0(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function N0(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Nu(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Ou(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const o=(s==null?void 0:s.error)??`Profile update failed (${i.status})`;e.nostrProfileFormState={...t,saving:!1,error:o,success:null,fieldErrors:I0(s==null?void 0:s.details)};return}if(!s.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await ee(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function O0(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Nu(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Ou(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const u=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:u,success:null};return}const o=s.merged??s.imported??null,a=o?{...t.values,...o}:t.values,r=!!(a.banner||a.website||a.nip05||a.lud16);e.nostrProfileFormState={...t,importing:!1,values:a,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:r},s.saved&&await ee(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function F0(e){if(e.client){e.authBusy=!0,e.authMessage=null;try{const t=await e.client.request("auth.status",{});e.authConnected=t.connected,e.authExpiresIn=t.expiresIn??null,e.authMessage=t.message??null,t.connected&&(e.setupStep="whatsapp")}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to check auth status"}finally{e.authBusy=!1}}}async function U0(e){if(e.client){e.authBusy=!0,e.authMessage=null,e.authUrl=null,e.authConnected=null;try{const t=await e.client.request("auth.oauth.start",{provider:"anthropic"});e.authUrl=t.authUrl,e.authMessage=t.message??"Sign in with your Claude Pro account"}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to start auth flow"}finally{e.authBusy=!1}}}async function W0(e,t){if(e.client){e.authBusy=!0,e.authMessage="Verifying code...";try{await e.client.request("auth.oauth.code",{code:t});const n=await e.client.request("auth.oauth.wait",{timeoutMs:3e4});n.connected?(e.authConnected=!0,e.authMessage=n.message??"Connected to Claude!",e.authUrl=null,e.authCodeInput=""):e.authMessage=n.message??"Still waiting for authorization..."}catch(n){e.authConnected=!1,e.authMessage=n instanceof Error?n.message:"Verification failed"}finally{e.authBusy=!1}}}function K0(e,t){e.authCodeInput=t}function z0(e){e.setupStep="whatsapp"}async function H0(e){if(e.client){e.licenseBusy=!0,e.licenseMessage=null;try{const t=await e.client.request("license.status",{});e.licenseDeviceId=t.deviceId??null,e.licenseStoredKey=t.key??null,t.licensed?(e.licenseValid=!0,e.licenseTier=t.tier??null,e.setupStep="auth"):(e.licenseValid=null,e.setupStep="license")}catch(t){const n=t instanceof Error?t.message:String(t);n.includes("unknown method")?(e.licenseValid=!0,e.setupStep="auth"):(e.licenseValid=null,e.licenseMessage=n,e.setupStep="license")}finally{e.licenseBusy=!1}}}async function q0(e){if(e.client&&e.licenseKey.trim()){e.licenseBusy=!0,e.licenseMessage=null,e.licenseValid=null;try{const t=await e.client.request("license.activate",{key:e.licenseKey.trim()});t.valid?(e.licenseValid=!0,e.licenseMessage=t.message??"License activated",e.licenseTier=t.tier??null,setTimeout(()=>{e.setupStep="auth"},1500)):(e.licenseValid=!1,e.licenseMessage=t.message??"Invalid license key")}catch(t){e.licenseValid=!1,e.licenseMessage=t instanceof Error?t.message:"Activation failed"}finally{e.licenseBusy=!1}}}async function j0(e){if(e.client){e.licenseBusy=!0;try{await e.client.request("license.remove",{}),e.licenseValid=null,e.licenseKey="",e.licenseTier=null,e.licenseMessage=null,e.setupStep="license"}catch(t){e.licenseMessage=t instanceof Error?t.message:"Failed to remove license"}finally{e.licenseBusy=!1}}}function G0(e,t){e.licenseKey=t}async function V0(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("health",{probe:!0});e.gatewayHealthy=i.ok===!0,e.gatewayHealthMessage=i.ok?`Healthy${i.durationMs?` (${i.durationMs}ms)`:""}`:"Unhealthy"}catch(i){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(i)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function Q0(e){var t,n,i;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(s.ok&&((n=s.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(s){e.gatewayHealthMessage=`Restart failed: ${String(s)}`,e.gatewayRestartBusy=!1,(i=e.requestUpdate)==null||i.call(e)}}}var J0=Object.defineProperty,Y0=Object.getOwnPropertyDescriptor,g=(e,t,n,i)=>{for(var s=i>1?void 0:i?Y0(t,n):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(i?a(t,n,s):a(s))||s);return i&&s&&J0(t,n,s),s};const yo=$p();function X0(){if(!window.location.search)return!1;const t=new URLSearchParams(window.location.search).get("onboarding");if(!t)return!1;const n=t.trim().toLowerCase();return n==="1"||n==="true"||n==="yes"||n==="on"}function Z0(){const e=window.location.pathname;if(e==="/setup"||e.endsWith("/setup"))return!0;if(!window.location.search)return!1;const n=new URLSearchParams(window.location.search).get("setup");if(!n)return!1;const i=n.trim().toLowerCase();return i==="1"||i==="true"||i==="yes"||i==="on"}function ex(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function tx(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function nx(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function ix(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function sx(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function ox(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let f=class extends jt{constructor(){super(...arguments),this.settings=Rs(),this.password="",this.tab="chat",this.onboarding=X0(),this.setup=Z0(),this.filesPage=ex(),this.browserPage=tx(),this.adminsPage=nx(),this.contactsPage=ix(),this.chatPage=sx(),this.advancedPage=ox(),this.advancedTab="cron",this.publicChat=!!window.__TASKMASTER_PUBLIC_CHAT__,this.publicChatConfig=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__??{},this.publicChatSessionKey=null,this.publicChatAuthenticated=!1,this.publicChatAuthStep="idle",this.connected=!1,this.accessState=yc,this.theme=this.settings.theme??"system",this.themeResolved="dark",this.hello=null,this.lastError=null,this.eventLog=[],this.eventLogBuffer=[],this.toolStreamSyncTimer=null,this.sidebarCloseTimer=null,this.assistantName=yo.name,this.assistantAvatar=yo.avatar,this.assistantAgentId=yo.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatHistoryTotal=0,this.chatHistoryHasMore=!1,this.chatLoadingOlder=!1,this.chatToolMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatModelCatalog=[],this.chatVerboseLevel=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
4774
4780
  }
4775
- `,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.whatsappActiveQrAccountId=null,this.whatsappPairedPhone=null,this.addingWhatsAppAccount=!1,this.newWhatsAppAccountName="",this.whatsappAccountError=null,this.whatsappAccountSaving=!1,this.whatsappSettingsOpen=!1,this.publicChatToggleBusy=!1,this.publicChatGreetingBusy=!1,this.publicChatEmailBusy=!1,this.publicChatSettingsOpen=!1,this.publicChatWidgetModalOpen=!1,this.brandingBusy=!1,this.agentSettingsOpen=!1,this.brandingExpanded=!1,this.tailscaleStatus=null,this.tailscaleBusy=!1,this.tailscaleAuthUrl=null,this.tailscaleError=null,this.tailscaleServeEnableUrl=null,this.tailscaleFunnelEnableUrl=null,this.tailscaleDisableConfirm=!1,this.tailscaleConnectProgress=0,this.tailscaleConnectMessage="",this.tailscaleConnectSuccess=!1,this.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,this.networkPort=null,this.networkHostname="",this.networkPortInput="",this.networkHostnameInput="",this.networkModalOpen=!1,this.networkBusy=!1,this.networkError=null,this.networkSuccess=null,this.wifiModalOpen=!1,this.licenseKey="",this.licenseBusy=!1,this.licenseValid=null,this.licenseMessage=null,this.licenseTier=null,this.licenseDeviceId=null,this.licenseStoredKey=null,this.licenseRemoveConfirm=!1,this.authConnected=null,this.authBusy=!1,this.authMessage=null,this.authUrl=null,this.authCodeInput="",this.authExpiresIn=null,this.setupStep="license",this.gatewayHealthy=null,this.gatewayHealthLoading=!1,this.gatewayHealthMessage=null,this.gatewayRestartBusy=!1,this.updateAvailable=null,this.currentVersion=null,this.latestVersion=null,this.updateChecking=!1,this.updateMessage=null,this.updateProgressSteps=[],this.updateLastResult=null,this.uninstallConfirm=!1,this.uninstallBusy=!1,this.uninstallDone=!1,this.uninstallError=null,this.uninstallConfirmText="",this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...v0},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.cronEditJobId=null,this.cronPendingDeleteId=null,this.cronRunModalJobId=null,this.cronRunModalJobName="",this.cronRunResult=null,this.openingHoursLoading=!1,this.openingHoursError=null,this.openingHoursBusy=!1,this.openingHoursForm=Ua(),this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserFullscreen=!1,this.browserLoading=!1,this.browserError=null,this.filesLoading=!1,this.filesTree=[],this.filesRoot="",this.filesError=null,this.filesSelectedPath=null,this.filesSelectedPaths=new Set,this.filesPreviewContent=null,this.filesPreviewLoading=!1,this.filesPreviewBinary=!1,this.filesPreviewSize=null,this.filesExpandedDirs=new Set,this.filesCurrentDir=".",this.filesPendingDeletePath=null,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.embeddingDownloading=!1,this.embeddingPollTimer=null,this.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.filesResolvedAgentId=void 0,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillsTypeFilter="all",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillDetail=null,this.skillDetailTab="",this.skillAddModal=!1,this.skillAddForm={name:"",skillContent:"",references:[]},this.skillAddFormSource="draft",this.skillEditTab="SKILL.md",this.skillDrafts=[],this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.contactsLoading=!1,this.contactsSaving=!1,this.contactsRecords=[],this.contactsError=null,this.contactsSearchQuery="",this.contactsEditingId=null,this.contactsShowAddForm=!1,this.contactsNewPhone="",this.contactsNewName="",this.contactsDeleteConfirmId=null,this.contactsAddFieldForId=null,this.contactsAddFieldKey="",this.contactsAddFieldValue="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.chatPageTab="chat",this.waConversations=[],this.waSelectedJid=null,this.waMessages=[],this.waGroupInfo=null,this.waLoading=!1,this.waMessagesLoading=!1,this.waSearchQuery="",this.waComposeDraft="",this.waSending=!1,this.waLastError=null,this.infoModalOpen=null,this.remoteAccessQrDataUrl=null,this.publicChatQrDataUrl=null,this.workspaces=[],this.workspacesLoading=!1,this.workspacesError=null,this.selectedWorkspace=null,this.addingWorkspace=!1,this.newWorkspaceName="",this.newWorkspacePath="",this.newWorkspacePin="",this.accountPinModalOpen=!1,this.accountPinBusy=!1,this.accountPinError=null,this.accountPinSuccess=null,this.apiKeyProviders=[],this.apiKeyModalOpen=!1,this.apiKeyBusy=!1,this.apiKeyError=null,this.apiKeySuccess=null,this.apiKeySavingProvider=null,this.authApiKeyMode=!1,this.authApiKeyInput="",this.authApiKeyBusy=!1,this.authApiKeyError=null,this.pinChanging=null,this.pinChangeBusy=!1,this.pinChangeError=null,this.loginChangePinMode=!1,this.changePinBusy=!1,this.changePinError=null,this.changePinSuccess=null,this.workspaceSaving=!1,this.workspaceRemoveConfirm=null,this.renamingWorkspace=!1,this.renameWorkspaceName="",this.debugLoading=!1,this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugCallMethod="",this.debugCallParams="{}",this.debugCallResult=null,this.debugCallError=null,this.logsLoading=!1,this.logsError=null,this.logsFile=null,this.logsEntries=[],this.logsFilterText="",this.logsLevelFilters={...y0},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsSubTab="session",this.logsChipsExpanded=!1,this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,tool_call:!0,tool_result:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsChipsExpanded=!1,this.sessionLogsExpandedIds=new Set,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.onLoadOlder=()=>this.handleLoadOlderChat(),this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>Jf(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null,this._beforeUnloadHandler=()=>{var t;wo();const e=this.selectedWorkspace??((t=this.publicChatConfig)==null?void 0:t.accountId)??"";e&&Wn(e,this.sessionKey,this.chatMessage)}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),b0(this),window.addEventListener("beforeunload",this._beforeUnloadHandler)}firstUpdated(){w0(this)}disconnectedCallback(){window.removeEventListener("beforeunload",this._beforeUnloadHandler),this.stopEmbeddingPoll(),k0(this),super.disconnectedCallback()}startEmbeddingPoll(){if(this.embeddingPollTimer!=null)return;const e=async()=>{if(!(!this.client||!this.connected)){try{const t=await this.client.request("memory.status",{});if((t==null?void 0:t.embeddingState)==="downloading")this.embeddingDownloading=!0;else{this.embeddingDownloading&&(this.embeddingDownloading=!1),this.stopEmbeddingPoll();return}}catch{this.embeddingDownloading=!1,this.stopEmbeddingPoll();return}this.embeddingPollTimer=window.setTimeout(e,3e3)}};e()}stopEmbeddingPoll(){this.embeddingPollTimer!=null&&(window.clearTimeout(this.embeddingPollTimer),this.embeddingPollTimer=null)}updated(e){x0(this,e)}connect(){De(this)}handleChatScroll(e){rh(this,e)}handleLogsScroll(e){ch(this,e)}handleSessionLogsScroll(e){dh(this,e)}exportLogs(e,t){ph(e,t)}exportSessionLogs(e,t){hh(e,t)}resetToolStream(){Zo(this)}resetChatScroll(){uh(this)}async loadAssistantIdentity(){await qo(this)}applySettings(e){ot(this,e)}setTab(e){zf(this,e)}setTheme(e,t){Hf(this,e,t)}async loadOverview(){await dd(this)}async loadCron(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.accountId=this.selectedWorkspace??void 0,this.cronForm={...this.cronForm,accountId:this.selectedWorkspace??void 0},await ud(this)}async handleAbortChat(){await hd(this)}removeQueuedMessage(e){eg(this,e)}async handleSendChat(e,t){await tg(this,e,t)}async handleWhatsAppStart(e,t){await S0(this,e,t)}async handleWhatsAppWait(e){await A0(this,e)}async handleWhatsAppLogout(e){await C0(this,e)}async handleAddWhatsAppAccount(e){await E0(this,e)}async handleRemoveWhatsAppAccount(e){await T0(this,e)}async handleAccessCheck(){await Cr(this)}async handlePinSubmit(e,t){await Eh(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await Th(this,e)}async handleLogout(){await Mh(this)}toggleChangePinMode(){this.loginChangePinMode=!this.loginChangePinMode,this.changePinError=null,this.changePinSuccess=null}async handleChangePin(e,t,n){if(this.client){this.changePinBusy=!0,this.changePinError=null,this.changePinSuccess=null;try{const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.changePinError=i.message??"Incorrect current PIN",this.changePinBusy=!1;return}e==="__master__"?await this.client.request("access.setMasterPin",{pin:n}):await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.changePinSuccess="PIN changed successfully",this.changePinBusy=!1,setTimeout(()=>{this.loginChangePinMode=!1,this.changePinSuccess=null},2e3)}catch{this.changePinError="Failed to change PIN",this.changePinBusy=!1}}}async handleAccountPinSave(e,t,n){if(this.client){this.accountPinBusy=!0,this.accountPinError=null,this.accountPinSuccess=null;try{if(t!==null){const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.accountPinError=i.message??"Incorrect current PIN",this.accountPinBusy=!1;return}}await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.accountPinSuccess="PIN saved",this.accountPinBusy=!1,await Cr(this),setTimeout(()=>{this.accountPinModalOpen=!1,this.accountPinSuccess=null,this.accountPinError=null},1500)}catch{this.accountPinError="Failed to save PIN",this.accountPinBusy=!1}}}async handleLicenseStatusCheck(){await z0(this)}async handleLicenseActivate(){await H0(this)}async handleLicenseRemove(){await q0(this)}handleLicenseKeyChange(e){j0(this,e)}async handleAuthStatusCheck(){await O0(this)}async handleAuthStart(){await F0(this)}async handleAuthSubmitCode(e){await U0(this,e)}handleAuthCodeChange(e){W0(this,e)}handleSkipToWhatsApp(){K0(this)}async handleGatewayHealthCheck(){await G0(this)}async handleGatewayRestart(){await V0(this)}async handleUpdateCheck(){await Au(this)}async handleUpdateRun(){await Dk(this)}handleUpdateDismissResult(){Ok(this)}handleUninstallConfirm(){this.uninstallConfirm=!0,this.uninstallConfirmText=""}handleUninstallCancel(){this.uninstallConfirm=!1,this.uninstallConfirmText="",this.uninstallError=null}handleUninstallConfirmTextChange(e){this.uninstallConfirmText=e}async handleUninstallRun(){const{runUninstall:e}=await ae(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Rr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){ae(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Rr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await sd(this)}async clearAudit(){await $f(this),this.auditModalOpen=!1}handleFilesLoad(){var n;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((n=e==null?void 0:e.agents)==null?void 0:n.map(i=>i.id))??void 0;const t=this.resolveFilesAgentId();this.filesResolvedAgentId=t,rn(this,t),cs(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();ae(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>t0);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin");return t==null?void 0:t.id}resolveFilesAgentId(){var n;const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return(t==null?void 0:t.id)??((n=e.agents[0])==null?void 0:n.id)}handleChatLoad(){const e=this.resolveAdminAgentId();if(e){const t=`agent:${e}:main`;t!==this.sessionKey&&(this.sessionKey=t,this.chatMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatRunId=null,this.chatSuggestions=[],this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}ae(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{sn(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=lh(this),{loadOlderChatHistory:t}=await ae(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>Oi);return{loadOlderChatHistory:i}},void 0,import.meta.url);await t(this)&&e&&(await this.updateComplete,e())}handleAdvancedLoad(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.sessionLogsEntries=[],this.sessionLogsCursors={},this.sessionLogsAgents=[],this.advancedTab==="cron"&&this.selectedWorkspace&&this.loadCron(),this.advancedTab==="opening-hours"&&ae(async()=>{const{loadOpeningHours:n}=await Promise.resolve().then(()=>Zk);return{loadOpeningHours:n}},void 0,import.meta.url).then(({loadOpeningHours:n})=>{n(this)}),this.advancedTab==="logs"&&(this.logsSubTab==="session"?ae(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>id);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):ae(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>Dh);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&ae(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>mf);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await _0(this)}async handleChannelConfigReload(){await M0(this)}handleNostrProfileEdit(e,t){I0(this,e,t)}handleNostrProfileCancel(){L0(this)}handleNostrProfileFieldChange(e,t){R0(this,e,t)}async handleNostrProfileSave(){await B0(this)}async handleNostrProfileImport(){await N0(this)}handleNostrProfileToggleAdvanced(){D0(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleAdminsNewPhoneChange(e){this.adminsNewPhone=e,this.adminsError&&(this.adminsError=null)}handleContactsLoad(){const e=this.selectedWorkspace??void 0;ae(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>n0);return{loadContacts:t}},void 0,import.meta.url).then(({loadContacts:t})=>{t(this,e)})}handleContactsNewPhoneChange(e){this.contactsNewPhone=e,this.contactsError&&(this.contactsError=null)}handleContactsNewNameChange(e){this.contactsNewName=e,this.contactsError&&(this.contactsError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await ae(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>ki);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await ae(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>ki);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await ae(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>Ah);return{loadChannels:s}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:s=>{if(!s.whatsappAccountId)return;const o=s.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await i(this,!0),await this.handleWhatsAppStart(!0,o),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(o),await i(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await ae(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>ki);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=(e==null?void 0:e.displayName)??(e==null?void 0:e.name)??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await ae(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>ki);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){wo(),this.selectedWorkspace&&Wn(this.selectedWorkspace,this.sessionKey,this.chatMessage),this.selectedWorkspace=e,this.publicChatQrDataUrl=null,localStorage.setItem("taskmaster-selected-workspace",e),Tn(e),br(e),this.settings=Rs(),this.chatMessage=Kn(e,this.settings.sessionKey),this.chatAttachments=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.waConversations=[],this.waSelectedJid=null,this.waMessages=[],this.waGroupInfo=null,this.waLastError=null,this.waSearchQuery="",this.waComposeDraft="",this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.loadAuditEntries(),this.adminsPage?this.handleAdminsLoad():this.contactsPage?this.handleContactsLoad():this.filesPage?this.handleFilesLoad():this.chatPage?(this.handleChatLoad(),this.chatPageTab==="whatsapp"&&!this.waLoading&&this.waConversations.length===0&&this.reloadWhatsAppConversations()):this.advancedPage&&this.handleAdvancedLoad()}async reloadWhatsAppConversations(){if(!(!this.client||!this.connected)){this.waLoading=!0,this.waLastError=null;try{const e=this.getSelectedWorkspaceInfo(),t=e==null?void 0:e.whatsappAccountId,n=await this.client.request("whatsapp.conversations",{accountId:t});this.waConversations=n.conversations}catch(e){this.waLastError=String(e)}finally{this.waLoading=!1}}}initWorkspaceSelection(){if(this.workspaces.length===0){this.reloadCurrentPageData();return}const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(i=>i.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}Tn(this.selectedWorkspace),br(this.selectedWorkspace),this.settings=Rs(),this.chatMessage=Kn(this.selectedWorkspace,this.settings.sessionKey),this.reloadCurrentPageData()}render(){return l`${f0(this)}${this.auditModalOpen?m0(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):w}`}};g([m()],f.prototype,"settings",2);g([m()],f.prototype,"password",2);g([m()],f.prototype,"tab",2);g([m()],f.prototype,"onboarding",2);g([m()],f.prototype,"setup",2);g([m()],f.prototype,"filesPage",2);g([m()],f.prototype,"browserPage",2);g([m()],f.prototype,"adminsPage",2);g([m()],f.prototype,"contactsPage",2);g([m()],f.prototype,"chatPage",2);g([m()],f.prototype,"advancedPage",2);g([m()],f.prototype,"advancedTab",2);g([m()],f.prototype,"publicChat",2);g([m()],f.prototype,"publicChatConfig",2);g([m()],f.prototype,"publicChatSessionKey",2);g([m()],f.prototype,"publicChatAuthenticated",2);g([m()],f.prototype,"publicChatAuthStep",2);g([m()],f.prototype,"connected",2);g([m()],f.prototype,"accessState",2);g([m()],f.prototype,"theme",2);g([m()],f.prototype,"themeResolved",2);g([m()],f.prototype,"hello",2);g([m()],f.prototype,"lastError",2);g([m()],f.prototype,"eventLog",2);g([m()],f.prototype,"assistantName",2);g([m()],f.prototype,"assistantAvatar",2);g([m()],f.prototype,"assistantAgentId",2);g([m()],f.prototype,"sessionKey",2);g([m()],f.prototype,"chatLoading",2);g([m()],f.prototype,"chatSending",2);g([m()],f.prototype,"chatMessage",2);g([m()],f.prototype,"chatMessages",2);g([m()],f.prototype,"chatHistoryTotal",2);g([m()],f.prototype,"chatHistoryHasMore",2);g([m()],f.prototype,"chatLoadingOlder",2);g([m()],f.prototype,"chatToolMessages",2);g([m()],f.prototype,"chatStream",2);g([m()],f.prototype,"chatInterimText",2);g([m()],f.prototype,"chatSuggestions",2);g([m()],f.prototype,"chatStreamStartedAt",2);g([m()],f.prototype,"chatRunId",2);g([m()],f.prototype,"compactionStatus",2);g([m()],f.prototype,"chatAvatarUrl",2);g([m()],f.prototype,"chatModelCatalog",2);g([m()],f.prototype,"chatVerboseLevel",2);g([m()],f.prototype,"chatQueue",2);g([m()],f.prototype,"chatAttachments",2);g([m()],f.prototype,"sidebarOpen",2);g([m()],f.prototype,"sidebarContent",2);g([m()],f.prototype,"sidebarError",2);g([m()],f.prototype,"splitRatio",2);g([m()],f.prototype,"nodesLoading",2);g([m()],f.prototype,"nodes",2);g([m()],f.prototype,"devicesLoading",2);g([m()],f.prototype,"devicesError",2);g([m()],f.prototype,"devicesList",2);g([m()],f.prototype,"execApprovalsLoading",2);g([m()],f.prototype,"execApprovalsSaving",2);g([m()],f.prototype,"execApprovalsDirty",2);g([m()],f.prototype,"execApprovalsSnapshot",2);g([m()],f.prototype,"execApprovalsForm",2);g([m()],f.prototype,"execApprovalsSelectedAgent",2);g([m()],f.prototype,"execApprovalsTarget",2);g([m()],f.prototype,"execApprovalsTargetNodeId",2);g([m()],f.prototype,"execApprovalQueue",2);g([m()],f.prototype,"execApprovalBusy",2);g([m()],f.prototype,"execApprovalError",2);g([m()],f.prototype,"configLoading",2);g([m()],f.prototype,"configRaw",2);g([m()],f.prototype,"configRawOriginal",2);g([m()],f.prototype,"configValid",2);g([m()],f.prototype,"configIssues",2);g([m()],f.prototype,"configSaving",2);g([m()],f.prototype,"configApplying",2);g([m()],f.prototype,"updateRunning",2);g([m()],f.prototype,"applySessionKey",2);g([m()],f.prototype,"configSnapshot",2);g([m()],f.prototype,"configSchema",2);g([m()],f.prototype,"configSchemaVersion",2);g([m()],f.prototype,"configSchemaLoading",2);g([m()],f.prototype,"configUiHints",2);g([m()],f.prototype,"configForm",2);g([m()],f.prototype,"configFormOriginal",2);g([m()],f.prototype,"configFormDirty",2);g([m()],f.prototype,"configFormMode",2);g([m()],f.prototype,"configSearchQuery",2);g([m()],f.prototype,"configActiveSection",2);g([m()],f.prototype,"configActiveSubsection",2);g([m()],f.prototype,"channelsLoading",2);g([m()],f.prototype,"channelsSnapshot",2);g([m()],f.prototype,"channelsError",2);g([m()],f.prototype,"channelsLastSuccess",2);g([m()],f.prototype,"whatsappLoginMessage",2);g([m()],f.prototype,"whatsappLoginQrDataUrl",2);g([m()],f.prototype,"whatsappLoginConnected",2);g([m()],f.prototype,"whatsappBusy",2);g([m()],f.prototype,"whatsappActiveQrAccountId",2);g([m()],f.prototype,"whatsappPairedPhone",2);g([m()],f.prototype,"addingWhatsAppAccount",2);g([m()],f.prototype,"newWhatsAppAccountName",2);g([m()],f.prototype,"whatsappAccountError",2);g([m()],f.prototype,"whatsappAccountSaving",2);g([m()],f.prototype,"whatsappSettingsOpen",2);g([m()],f.prototype,"publicChatToggleBusy",2);g([m()],f.prototype,"publicChatGreetingBusy",2);g([m()],f.prototype,"publicChatEmailBusy",2);g([m()],f.prototype,"publicChatSettingsOpen",2);g([m()],f.prototype,"publicChatWidgetModalOpen",2);g([m()],f.prototype,"brandingBusy",2);g([m()],f.prototype,"agentSettingsOpen",2);g([m()],f.prototype,"brandingExpanded",2);g([m()],f.prototype,"tailscaleStatus",2);g([m()],f.prototype,"tailscaleBusy",2);g([m()],f.prototype,"tailscaleAuthUrl",2);g([m()],f.prototype,"tailscaleError",2);g([m()],f.prototype,"tailscaleServeEnableUrl",2);g([m()],f.prototype,"tailscaleFunnelEnableUrl",2);g([m()],f.prototype,"tailscaleDisableConfirm",2);g([m()],f.prototype,"tailscaleConnectProgress",2);g([m()],f.prototype,"tailscaleConnectMessage",2);g([m()],f.prototype,"tailscaleConnectSuccess",2);g([m()],f.prototype,"wifiStatus",2);g([m()],f.prototype,"wifiNetworks",2);g([m()],f.prototype,"wifiBusy",2);g([m()],f.prototype,"wifiError",2);g([m()],f.prototype,"wifiPassword",2);g([m()],f.prototype,"wifiSelectedSsid",2);g([m()],f.prototype,"networkPort",2);g([m()],f.prototype,"networkHostname",2);g([m()],f.prototype,"networkPortInput",2);g([m()],f.prototype,"networkHostnameInput",2);g([m()],f.prototype,"networkModalOpen",2);g([m()],f.prototype,"networkBusy",2);g([m()],f.prototype,"networkError",2);g([m()],f.prototype,"networkSuccess",2);g([m()],f.prototype,"wifiModalOpen",2);g([m()],f.prototype,"licenseKey",2);g([m()],f.prototype,"licenseBusy",2);g([m()],f.prototype,"licenseValid",2);g([m()],f.prototype,"licenseMessage",2);g([m()],f.prototype,"licenseTier",2);g([m()],f.prototype,"licenseDeviceId",2);g([m()],f.prototype,"licenseStoredKey",2);g([m()],f.prototype,"licenseRemoveConfirm",2);g([m()],f.prototype,"authConnected",2);g([m()],f.prototype,"authBusy",2);g([m()],f.prototype,"authMessage",2);g([m()],f.prototype,"authUrl",2);g([m()],f.prototype,"authCodeInput",2);g([m()],f.prototype,"authExpiresIn",2);g([m()],f.prototype,"setupStep",2);g([m()],f.prototype,"gatewayHealthy",2);g([m()],f.prototype,"gatewayHealthLoading",2);g([m()],f.prototype,"gatewayHealthMessage",2);g([m()],f.prototype,"gatewayRestartBusy",2);g([m()],f.prototype,"updateAvailable",2);g([m()],f.prototype,"currentVersion",2);g([m()],f.prototype,"latestVersion",2);g([m()],f.prototype,"updateChecking",2);g([m()],f.prototype,"updateMessage",2);g([m()],f.prototype,"updateProgressSteps",2);g([m()],f.prototype,"updateLastResult",2);g([m()],f.prototype,"uninstallConfirm",2);g([m()],f.prototype,"uninstallBusy",2);g([m()],f.prototype,"uninstallDone",2);g([m()],f.prototype,"uninstallError",2);g([m()],f.prototype,"uninstallConfirmText",2);g([m()],f.prototype,"nostrProfileFormState",2);g([m()],f.prototype,"nostrProfileAccountId",2);g([m()],f.prototype,"presenceLoading",2);g([m()],f.prototype,"presenceEntries",2);g([m()],f.prototype,"presenceError",2);g([m()],f.prototype,"presenceStatus",2);g([m()],f.prototype,"agentsLoading",2);g([m()],f.prototype,"agentsList",2);g([m()],f.prototype,"agentsError",2);g([m()],f.prototype,"sessionsLoading",2);g([m()],f.prototype,"sessionsResult",2);g([m()],f.prototype,"sessionsError",2);g([m()],f.prototype,"cronLoading",2);g([m()],f.prototype,"cronJobs",2);g([m()],f.prototype,"cronStatus",2);g([m()],f.prototype,"cronError",2);g([m()],f.prototype,"cronForm",2);g([m()],f.prototype,"cronRunsJobId",2);g([m()],f.prototype,"cronRuns",2);g([m()],f.prototype,"cronBusy",2);g([m()],f.prototype,"cronNewEventModal",2);g([m()],f.prototype,"cronDetailJobId",2);g([m()],f.prototype,"cronEditJobId",2);g([m()],f.prototype,"cronPendingDeleteId",2);g([m()],f.prototype,"cronRunModalJobId",2);g([m()],f.prototype,"cronRunModalJobName",2);g([m()],f.prototype,"cronRunResult",2);g([m()],f.prototype,"openingHoursLoading",2);g([m()],f.prototype,"openingHoursError",2);g([m()],f.prototype,"openingHoursBusy",2);g([m()],f.prototype,"openingHoursForm",2);g([m()],f.prototype,"browserScreencastActive",2);g([m()],f.prototype,"browserScreencastFrame",2);g([m()],f.prototype,"browserScreencastMetadata",2);g([m()],f.prototype,"browserHandoffPending",2);g([m()],f.prototype,"browserHandoffReason",2);g([m()],f.prototype,"browserHandoffId",2);g([m()],f.prototype,"browserInputMode",2);g([m()],f.prototype,"browserFullscreen",2);g([m()],f.prototype,"browserLoading",2);g([m()],f.prototype,"browserError",2);g([m()],f.prototype,"filesLoading",2);g([m()],f.prototype,"filesTree",2);g([m()],f.prototype,"filesRoot",2);g([m()],f.prototype,"filesError",2);g([m()],f.prototype,"filesSelectedPath",2);g([m()],f.prototype,"filesSelectedPaths",2);g([m()],f.prototype,"filesPreviewContent",2);g([m()],f.prototype,"filesPreviewLoading",2);g([m()],f.prototype,"filesPreviewBinary",2);g([m()],f.prototype,"filesPreviewSize",2);g([m()],f.prototype,"filesExpandedDirs",2);g([m()],f.prototype,"filesCurrentDir",2);g([m()],f.prototype,"filesPendingDeletePath",2);g([m()],f.prototype,"filesMessage",2);g([m()],f.prototype,"filesUploadBusy",2);g([m()],f.prototype,"filesReindexBusy",2);g([m()],f.prototype,"filesMemoryStatus",2);g([m()],f.prototype,"embeddingDownloading",2);g([m()],f.prototype,"filesSearchQuery",2);g([m()],f.prototype,"filesSearchResults",2);g([m()],f.prototype,"filesSearchLoading",2);g([m()],f.prototype,"filesSearchAgentId",2);g([m()],f.prototype,"auditEntries",2);g([m()],f.prototype,"auditLoading",2);g([m()],f.prototype,"auditModalOpen",2);g([m()],f.prototype,"skillsLoading",2);g([m()],f.prototype,"skillsReport",2);g([m()],f.prototype,"skillsError",2);g([m()],f.prototype,"skillsFilter",2);g([m()],f.prototype,"skillsTypeFilter",2);g([m()],f.prototype,"skillEdits",2);g([m()],f.prototype,"skillsBusyKey",2);g([m()],f.prototype,"skillMessages",2);g([m()],f.prototype,"skillDetail",2);g([m()],f.prototype,"skillDetailTab",2);g([m()],f.prototype,"skillAddModal",2);g([m()],f.prototype,"skillAddForm",2);g([m()],f.prototype,"skillAddFormSource",2);g([m()],f.prototype,"skillEditTab",2);g([m()],f.prototype,"skillDrafts",2);g([m()],f.prototype,"adminsLoading",2);g([m()],f.prototype,"adminPhones",2);g([m()],f.prototype,"adminsError",2);g([m()],f.prototype,"adminsSaving",2);g([m()],f.prototype,"adminsNewPhone",2);g([m()],f.prototype,"contactsLoading",2);g([m()],f.prototype,"contactsSaving",2);g([m()],f.prototype,"contactsRecords",2);g([m()],f.prototype,"contactsError",2);g([m()],f.prototype,"contactsSearchQuery",2);g([m()],f.prototype,"contactsEditingId",2);g([m()],f.prototype,"contactsShowAddForm",2);g([m()],f.prototype,"contactsNewPhone",2);g([m()],f.prototype,"contactsNewName",2);g([m()],f.prototype,"contactsDeleteConfirmId",2);g([m()],f.prototype,"contactsAddFieldForId",2);g([m()],f.prototype,"contactsAddFieldKey",2);g([m()],f.prototype,"contactsAddFieldValue",2);g([m()],f.prototype,"imessageEnableConfirm",2);g([m()],f.prototype,"imessageEnabling",2);g([m()],f.prototype,"chatPageTab",2);g([m()],f.prototype,"waConversations",2);g([m()],f.prototype,"waSelectedJid",2);g([m()],f.prototype,"waMessages",2);g([m()],f.prototype,"waGroupInfo",2);g([m()],f.prototype,"waLoading",2);g([m()],f.prototype,"waMessagesLoading",2);g([m()],f.prototype,"waSearchQuery",2);g([m()],f.prototype,"waComposeDraft",2);g([m()],f.prototype,"waSending",2);g([m()],f.prototype,"waLastError",2);g([m()],f.prototype,"infoModalOpen",2);g([m()],f.prototype,"remoteAccessQrDataUrl",2);g([m()],f.prototype,"publicChatQrDataUrl",2);g([m()],f.prototype,"workspaces",2);g([m()],f.prototype,"workspacesLoading",2);g([m()],f.prototype,"workspacesError",2);g([m()],f.prototype,"selectedWorkspace",2);g([m()],f.prototype,"addingWorkspace",2);g([m()],f.prototype,"newWorkspaceName",2);g([m()],f.prototype,"newWorkspacePath",2);g([m()],f.prototype,"newWorkspacePin",2);g([m()],f.prototype,"accountPinModalOpen",2);g([m()],f.prototype,"accountPinBusy",2);g([m()],f.prototype,"accountPinError",2);g([m()],f.prototype,"accountPinSuccess",2);g([m()],f.prototype,"apiKeyProviders",2);g([m()],f.prototype,"apiKeyModalOpen",2);g([m()],f.prototype,"apiKeyBusy",2);g([m()],f.prototype,"apiKeyError",2);g([m()],f.prototype,"apiKeySuccess",2);g([m()],f.prototype,"apiKeySavingProvider",2);g([m()],f.prototype,"authApiKeyMode",2);g([m()],f.prototype,"authApiKeyInput",2);g([m()],f.prototype,"authApiKeyBusy",2);g([m()],f.prototype,"authApiKeyError",2);g([m()],f.prototype,"pinChanging",2);g([m()],f.prototype,"pinChangeBusy",2);g([m()],f.prototype,"pinChangeError",2);g([m()],f.prototype,"loginChangePinMode",2);g([m()],f.prototype,"changePinBusy",2);g([m()],f.prototype,"changePinError",2);g([m()],f.prototype,"changePinSuccess",2);g([m()],f.prototype,"workspaceSaving",2);g([m()],f.prototype,"workspaceRemoveConfirm",2);g([m()],f.prototype,"renamingWorkspace",2);g([m()],f.prototype,"renameWorkspaceName",2);g([m()],f.prototype,"debugLoading",2);g([m()],f.prototype,"debugStatus",2);g([m()],f.prototype,"debugHealth",2);g([m()],f.prototype,"debugModels",2);g([m()],f.prototype,"debugHeartbeat",2);g([m()],f.prototype,"debugCallMethod",2);g([m()],f.prototype,"debugCallParams",2);g([m()],f.prototype,"debugCallResult",2);g([m()],f.prototype,"debugCallError",2);g([m()],f.prototype,"logsLoading",2);g([m()],f.prototype,"logsError",2);g([m()],f.prototype,"logsFile",2);g([m()],f.prototype,"logsEntries",2);g([m()],f.prototype,"logsFilterText",2);g([m()],f.prototype,"logsLevelFilters",2);g([m()],f.prototype,"logsAutoFollow",2);g([m()],f.prototype,"logsTruncated",2);g([m()],f.prototype,"logsCursor",2);g([m()],f.prototype,"logsLastFetchAt",2);g([m()],f.prototype,"logsLimit",2);g([m()],f.prototype,"logsMaxBytes",2);g([m()],f.prototype,"logsAtBottom",2);g([m()],f.prototype,"logsSubTab",2);g([m()],f.prototype,"logsChipsExpanded",2);g([m()],f.prototype,"sessionLogsLoading",2);g([m()],f.prototype,"sessionLogsError",2);g([m()],f.prototype,"sessionLogsEntries",2);g([m()],f.prototype,"sessionLogsFilterText",2);g([m()],f.prototype,"sessionLogsTypeFilters",2);g([m()],f.prototype,"sessionLogsAgentFilters",2);g([m()],f.prototype,"sessionLogsAgents",2);g([m()],f.prototype,"sessionLogsAutoFollow",2);g([m()],f.prototype,"sessionLogsChipsExpanded",2);g([m()],f.prototype,"sessionLogsCursors",2);g([m()],f.prototype,"sessionLogsLastFetchAt",2);g([m()],f.prototype,"sessionLogsAtBottom",2);g([m()],f.prototype,"chatUserNearBottom",2);f=g([ql("taskmaster-app")],f);
4776
- //# sourceMappingURL=index-mjAT1dyG.js.map
4781
+ `,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.whatsappActiveQrAccountId=null,this.whatsappPairedPhone=null,this.addingWhatsAppAccount=!1,this.newWhatsAppAccountName="",this.whatsappAccountError=null,this.whatsappAccountSaving=!1,this.whatsappSettingsOpen=!1,this.publicChatToggleBusy=!1,this.publicChatGreetingBusy=!1,this.publicChatEmailBusy=!1,this.publicChatSettingsOpen=!1,this.publicChatWidgetModalOpen=!1,this.brandingBusy=!1,this.agentSettingsOpen=!1,this.brandingExpanded=!1,this.tailscaleStatus=null,this.tailscaleBusy=!1,this.tailscaleAuthUrl=null,this.tailscaleError=null,this.tailscaleServeEnableUrl=null,this.tailscaleFunnelEnableUrl=null,this.tailscaleDisableConfirm=!1,this.tailscaleConnectProgress=0,this.tailscaleConnectMessage="",this.tailscaleConnectSuccess=!1,this.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,this.networkPort=null,this.networkHostname="",this.networkPortInput="",this.networkHostnameInput="",this.networkModalOpen=!1,this.networkBusy=!1,this.networkError=null,this.networkSuccess=null,this.wifiModalOpen=!1,this.licenseKey="",this.licenseBusy=!1,this.licenseValid=null,this.licenseMessage=null,this.licenseTier=null,this.licenseDeviceId=null,this.licenseStoredKey=null,this.licenseRemoveConfirm=!1,this.authConnected=null,this.authBusy=!1,this.authMessage=null,this.authUrl=null,this.authCodeInput="",this.authExpiresIn=null,this.setupStep="license",this.gatewayHealthy=null,this.gatewayHealthLoading=!1,this.gatewayHealthMessage=null,this.gatewayRestartBusy=!1,this.updateAvailable=null,this.currentVersion=null,this.latestVersion=null,this.updateChecking=!1,this.updateMessage=null,this.updateProgressSteps=[],this.updateLastResult=null,this.uninstallConfirm=!1,this.uninstallBusy=!1,this.uninstallDone=!1,this.uninstallError=null,this.uninstallConfirmText="",this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...b0},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.cronEditJobId=null,this.cronPendingDeleteId=null,this.cronRunModalJobId=null,this.cronRunModalJobName="",this.cronRunResult=null,this.openingHoursLoading=!1,this.openingHoursError=null,this.openingHoursBusy=!1,this.openingHoursForm=Ua(),this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserFullscreen=!1,this.browserLoading=!1,this.browserError=null,this.filesLoading=!1,this.filesTree=[],this.filesRoot="",this.filesError=null,this.filesSelectedPath=null,this.filesSelectedPaths=new Set,this.filesPreviewContent=null,this.filesPreviewLoading=!1,this.filesPreviewBinary=!1,this.filesPreviewSize=null,this.filesExpandedDirs=new Set,this.filesCurrentDir=".",this.filesPendingDeletePath=null,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.embeddingDownloading=!1,this.embeddingPollTimer=null,this.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.filesResolvedAgentId=void 0,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillsTypeFilter="all",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillDetail=null,this.skillDetailTab="",this.skillAddModal=!1,this.skillAddForm={name:"",skillContent:"",references:[]},this.skillAddFormSource="draft",this.skillEditTab="SKILL.md",this.skillDrafts=[],this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.contactsLoading=!1,this.contactsSaving=!1,this.contactsRecords=[],this.contactsError=null,this.contactsSearchQuery="",this.contactsEditingId=null,this.contactsShowAddForm=!1,this.contactsNewPhone="",this.contactsNewName="",this.contactsDeleteConfirmId=null,this.contactsAddFieldForId=null,this.contactsAddFieldKey="",this.contactsAddFieldValue="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.chatPageTab="chat",this.waConversations=[],this.waSelectedJid=null,this.waMessages=[],this.waGroupInfo=null,this.waLoading=!1,this.waMessagesLoading=!1,this.waSearchQuery="",this.waComposeDraft="",this.waSending=!1,this.waLastError=null,this.infoModalOpen=null,this.remoteAccessQrDataUrl=null,this.publicChatQrDataUrl=null,this.workspaces=[],this.workspacesLoading=!1,this.workspacesError=null,this.selectedWorkspace=null,this.addingWorkspace=!1,this.newWorkspaceName="",this.newWorkspacePath="",this.newWorkspacePin="",this.accountPinModalOpen=!1,this.accountPinBusy=!1,this.accountPinError=null,this.accountPinSuccess=null,this.apiKeyProviders=[],this.apiKeyModalOpen=!1,this.apiKeyBusy=!1,this.apiKeyError=null,this.apiKeySuccess=null,this.apiKeySavingProvider=null,this.authApiKeyMode=!1,this.authApiKeyInput="",this.authApiKeyBusy=!1,this.authApiKeyError=null,this.pinChanging=null,this.pinChangeBusy=!1,this.pinChangeError=null,this.loginChangePinMode=!1,this.changePinBusy=!1,this.changePinError=null,this.changePinSuccess=null,this.workspaceSaving=!1,this.workspaceRemoveConfirm=null,this.renamingWorkspace=!1,this.renameWorkspaceName="",this.debugLoading=!1,this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugCallMethod="",this.debugCallParams="{}",this.debugCallResult=null,this.debugCallError=null,this.logsLoading=!1,this.logsError=null,this.logsFile=null,this.logsEntries=[],this.logsFilterText="",this.logsLevelFilters={...v0},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsSubTab="session",this.logsChipsExpanded=!1,this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,tool_call:!0,tool_result:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsChipsExpanded=!1,this.sessionLogsExpandedIds=new Set,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.onLoadOlder=()=>this.handleLoadOlderChat(),this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>Yf(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null,this._beforeUnloadHandler=()=>{var t;wo();const e=this.selectedWorkspace??((t=this.publicChatConfig)==null?void 0:t.accountId)??"";e&&Wn(e,this.sessionKey,this.chatMessage)}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),w0(this),window.addEventListener("beforeunload",this._beforeUnloadHandler)}firstUpdated(){k0(this)}disconnectedCallback(){window.removeEventListener("beforeunload",this._beforeUnloadHandler),this.stopEmbeddingPoll(),x0(this),super.disconnectedCallback()}startEmbeddingPoll(){if(this.embeddingPollTimer!=null)return;const e=async()=>{if(!(!this.client||!this.connected)){try{const t=await this.client.request("memory.status",{});if((t==null?void 0:t.embeddingState)==="downloading")this.embeddingDownloading=!0;else{this.embeddingDownloading&&(this.embeddingDownloading=!1),this.stopEmbeddingPoll();return}}catch{this.embeddingDownloading=!1,this.stopEmbeddingPoll();return}this.embeddingPollTimer=window.setTimeout(e,3e3)}};e()}stopEmbeddingPoll(){this.embeddingPollTimer!=null&&(window.clearTimeout(this.embeddingPollTimer),this.embeddingPollTimer=null)}updated(e){$0(this,e)}connect(){Be(this)}handleChatScroll(e){lh(this,e)}handleLogsScroll(e){dh(this,e)}handleSessionLogsScroll(e){uh(this,e)}exportLogs(e,t){hh(e,t)}exportSessionLogs(e,t){fh(e,t)}resetToolStream(){Zo(this)}resetChatScroll(){ph(this)}async loadAssistantIdentity(){await qo(this)}applySettings(e){at(this,e)}setTab(e){Hf(this,e)}setTheme(e,t){qf(this,e,t)}async loadOverview(){await ud(this)}async loadCron(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.accountId=this.selectedWorkspace??void 0,this.cronForm={...this.cronForm,accountId:this.selectedWorkspace??void 0},await pd(this)}async handleAbortChat(){await fd(this)}removeQueuedMessage(e){tg(this,e)}async handleSendChat(e,t){await ng(this,e,t)}async handleWhatsAppStart(e,t){await A0(this,e,t)}async handleWhatsAppWait(e){await C0(this,e)}async handleWhatsAppLogout(e){await E0(this,e)}async handleAddWhatsAppAccount(e){await T0(this,e)}async handleRemoveWhatsAppAccount(e){await _0(this,e)}async handleAccessCheck(){await Cr(this)}async handlePinSubmit(e,t){await Th(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await _h(this,e)}async handleLogout(){await Ph(this)}toggleChangePinMode(){this.loginChangePinMode=!this.loginChangePinMode,this.changePinError=null,this.changePinSuccess=null}async handleChangePin(e,t,n){if(this.client){this.changePinBusy=!0,this.changePinError=null,this.changePinSuccess=null;try{const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.changePinError=i.message??"Incorrect current PIN",this.changePinBusy=!1;return}e==="__master__"?await this.client.request("access.setMasterPin",{pin:n}):await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.changePinSuccess="PIN changed successfully",this.changePinBusy=!1,setTimeout(()=>{this.loginChangePinMode=!1,this.changePinSuccess=null},2e3)}catch{this.changePinError="Failed to change PIN",this.changePinBusy=!1}}}async handleAccountPinSave(e,t,n){if(this.client){this.accountPinBusy=!0,this.accountPinError=null,this.accountPinSuccess=null;try{if(t!==null){const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.accountPinError=i.message??"Incorrect current PIN",this.accountPinBusy=!1;return}}await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.accountPinSuccess="PIN saved",this.accountPinBusy=!1,await Cr(this),setTimeout(()=>{this.accountPinModalOpen=!1,this.accountPinSuccess=null,this.accountPinError=null},1500)}catch{this.accountPinError="Failed to save PIN",this.accountPinBusy=!1}}}async handleLicenseStatusCheck(){await H0(this)}async handleLicenseActivate(){await q0(this)}async handleLicenseRemove(){await j0(this)}handleLicenseKeyChange(e){G0(this,e)}async handleAuthStatusCheck(){await F0(this)}async handleAuthStart(){await U0(this)}async handleAuthSubmitCode(e){await W0(this,e)}handleAuthCodeChange(e){K0(this,e)}handleSkipToWhatsApp(){z0(this)}async handleGatewayHealthCheck(){await V0(this)}async handleGatewayRestart(){await Q0(this)}async handleUpdateCheck(){await Cu(this)}async handleUpdateRun(){await Bk(this)}handleUpdateDismissResult(){Fk(this)}handleUninstallConfirm(){this.uninstallConfirm=!0,this.uninstallConfirmText=""}handleUninstallCancel(){this.uninstallConfirm=!1,this.uninstallConfirmText="",this.uninstallError=null}handleUninstallConfirmTextChange(e){this.uninstallConfirmText=e}async handleUninstallRun(){const{runUninstall:e}=await ae(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Rr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){ae(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Rr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await od(this)}async clearAudit(){await Sf(this),this.auditModalOpen=!1}handleFilesLoad(){var n;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((n=e==null?void 0:e.agents)==null?void 0:n.map(i=>i.id))??void 0;const t=this.resolveFilesAgentId();this.filesResolvedAgentId=t,rn(this,t),cs(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();ae(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>n0);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin");return t==null?void 0:t.id}resolveFilesAgentId(){var n;const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return(t==null?void 0:t.id)??((n=e.agents[0])==null?void 0:n.id)}handleChatLoad(){const e=this.resolveAdminAgentId();if(e){const t=`agent:${e}:main`;t!==this.sessionKey&&(this.sessionKey=t,this.chatMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatRunId=null,this.chatSuggestions=[],this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}ae(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{sn(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=ch(this),{loadOlderChatHistory:t}=await ae(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>Oi);return{loadOlderChatHistory:i}},void 0,import.meta.url);await t(this)&&e&&(await this.updateComplete,e())}handleAdvancedLoad(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.sessionLogsEntries=[],this.sessionLogsCursors={},this.sessionLogsAgents=[],this.advancedTab==="cron"&&this.selectedWorkspace&&this.loadCron(),this.advancedTab==="opening-hours"&&ae(async()=>{const{loadOpeningHours:n}=await Promise.resolve().then(()=>e0);return{loadOpeningHours:n}},void 0,import.meta.url).then(({loadOpeningHours:n})=>{n(this)}),this.advancedTab==="logs"&&(this.logsSubTab==="session"?ae(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>sd);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):ae(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>Bh);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&ae(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>yf);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await M0(this)}async handleChannelConfigReload(){await P0(this)}handleNostrProfileEdit(e,t){L0(this,e,t)}handleNostrProfileCancel(){R0(this)}handleNostrProfileFieldChange(e,t){D0(this,e,t)}async handleNostrProfileSave(){await N0(this)}async handleNostrProfileImport(){await O0(this)}handleNostrProfileToggleAdvanced(){B0(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleAdminsNewPhoneChange(e){this.adminsNewPhone=e,this.adminsError&&(this.adminsError=null)}handleContactsLoad(){const e=this.selectedWorkspace??void 0;ae(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>i0);return{loadContacts:t}},void 0,import.meta.url).then(({loadContacts:t})=>{t(this,e)})}handleContactsNewPhoneChange(e){this.contactsNewPhone=e,this.contactsError&&(this.contactsError=null)}handleContactsNewNameChange(e){this.contactsNewName=e,this.contactsError&&(this.contactsError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await ae(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>ki);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await ae(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>ki);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await ae(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>Ch);return{loadChannels:s}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:s=>{if(!s.whatsappAccountId)return;const o=s.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await i(this,!0),await this.handleWhatsAppStart(!0,o),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(o),await i(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await ae(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>ki);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=(e==null?void 0:e.displayName)??(e==null?void 0:e.name)??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await ae(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>ki);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){wo(),this.selectedWorkspace&&Wn(this.selectedWorkspace,this.sessionKey,this.chatMessage),this.selectedWorkspace=e,this.publicChatQrDataUrl=null,localStorage.setItem("taskmaster-selected-workspace",e),Tn(e),br(e),this.settings=Rs(),this.chatMessage=Kn(e,this.settings.sessionKey),this.chatAttachments=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.waConversations=[],this.waSelectedJid=null,this.waMessages=[],this.waGroupInfo=null,this.waLastError=null,this.waSearchQuery="",this.waComposeDraft="",this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.loadAuditEntries(),this.adminsPage?this.handleAdminsLoad():this.contactsPage?this.handleContactsLoad():this.filesPage?this.handleFilesLoad():this.chatPage?(this.handleChatLoad(),this.chatPageTab==="whatsapp"&&!this.waLoading&&this.waConversations.length===0&&this.reloadWhatsAppConversations()):this.advancedPage&&this.handleAdvancedLoad()}async reloadWhatsAppConversations(){if(!(!this.client||!this.connected)){this.waLoading=!0,this.waLastError=null;try{const e=this.getSelectedWorkspaceInfo(),t=e==null?void 0:e.whatsappAccountId,n=await this.client.request("whatsapp.conversations",{accountId:t});this.waConversations=n.conversations}catch(e){this.waLastError=String(e)}finally{this.waLoading=!1}}}initWorkspaceSelection(){if(this.workspaces.length===0){this.reloadCurrentPageData();return}const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(i=>i.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}Tn(this.selectedWorkspace),br(this.selectedWorkspace),this.settings=Rs(),this.chatMessage=Kn(this.selectedWorkspace,this.settings.sessionKey),this.reloadCurrentPageData()}render(){return l`${g0(this)}${this.auditModalOpen?y0(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):w}`}};g([m()],f.prototype,"settings",2);g([m()],f.prototype,"password",2);g([m()],f.prototype,"tab",2);g([m()],f.prototype,"onboarding",2);g([m()],f.prototype,"setup",2);g([m()],f.prototype,"filesPage",2);g([m()],f.prototype,"browserPage",2);g([m()],f.prototype,"adminsPage",2);g([m()],f.prototype,"contactsPage",2);g([m()],f.prototype,"chatPage",2);g([m()],f.prototype,"advancedPage",2);g([m()],f.prototype,"advancedTab",2);g([m()],f.prototype,"publicChat",2);g([m()],f.prototype,"publicChatConfig",2);g([m()],f.prototype,"publicChatSessionKey",2);g([m()],f.prototype,"publicChatAuthenticated",2);g([m()],f.prototype,"publicChatAuthStep",2);g([m()],f.prototype,"connected",2);g([m()],f.prototype,"accessState",2);g([m()],f.prototype,"theme",2);g([m()],f.prototype,"themeResolved",2);g([m()],f.prototype,"hello",2);g([m()],f.prototype,"lastError",2);g([m()],f.prototype,"eventLog",2);g([m()],f.prototype,"assistantName",2);g([m()],f.prototype,"assistantAvatar",2);g([m()],f.prototype,"assistantAgentId",2);g([m()],f.prototype,"sessionKey",2);g([m()],f.prototype,"chatLoading",2);g([m()],f.prototype,"chatSending",2);g([m()],f.prototype,"chatMessage",2);g([m()],f.prototype,"chatMessages",2);g([m()],f.prototype,"chatHistoryTotal",2);g([m()],f.prototype,"chatHistoryHasMore",2);g([m()],f.prototype,"chatLoadingOlder",2);g([m()],f.prototype,"chatToolMessages",2);g([m()],f.prototype,"chatStream",2);g([m()],f.prototype,"chatInterimText",2);g([m()],f.prototype,"chatSuggestions",2);g([m()],f.prototype,"chatStreamStartedAt",2);g([m()],f.prototype,"chatRunId",2);g([m()],f.prototype,"compactionStatus",2);g([m()],f.prototype,"chatAvatarUrl",2);g([m()],f.prototype,"chatModelCatalog",2);g([m()],f.prototype,"chatVerboseLevel",2);g([m()],f.prototype,"chatQueue",2);g([m()],f.prototype,"chatAttachments",2);g([m()],f.prototype,"sidebarOpen",2);g([m()],f.prototype,"sidebarContent",2);g([m()],f.prototype,"sidebarError",2);g([m()],f.prototype,"splitRatio",2);g([m()],f.prototype,"nodesLoading",2);g([m()],f.prototype,"nodes",2);g([m()],f.prototype,"devicesLoading",2);g([m()],f.prototype,"devicesError",2);g([m()],f.prototype,"devicesList",2);g([m()],f.prototype,"execApprovalsLoading",2);g([m()],f.prototype,"execApprovalsSaving",2);g([m()],f.prototype,"execApprovalsDirty",2);g([m()],f.prototype,"execApprovalsSnapshot",2);g([m()],f.prototype,"execApprovalsForm",2);g([m()],f.prototype,"execApprovalsSelectedAgent",2);g([m()],f.prototype,"execApprovalsTarget",2);g([m()],f.prototype,"execApprovalsTargetNodeId",2);g([m()],f.prototype,"execApprovalQueue",2);g([m()],f.prototype,"execApprovalBusy",2);g([m()],f.prototype,"execApprovalError",2);g([m()],f.prototype,"configLoading",2);g([m()],f.prototype,"configRaw",2);g([m()],f.prototype,"configRawOriginal",2);g([m()],f.prototype,"configValid",2);g([m()],f.prototype,"configIssues",2);g([m()],f.prototype,"configSaving",2);g([m()],f.prototype,"configApplying",2);g([m()],f.prototype,"updateRunning",2);g([m()],f.prototype,"applySessionKey",2);g([m()],f.prototype,"configSnapshot",2);g([m()],f.prototype,"configSchema",2);g([m()],f.prototype,"configSchemaVersion",2);g([m()],f.prototype,"configSchemaLoading",2);g([m()],f.prototype,"configUiHints",2);g([m()],f.prototype,"configForm",2);g([m()],f.prototype,"configFormOriginal",2);g([m()],f.prototype,"configFormDirty",2);g([m()],f.prototype,"configFormMode",2);g([m()],f.prototype,"configSearchQuery",2);g([m()],f.prototype,"configActiveSection",2);g([m()],f.prototype,"configActiveSubsection",2);g([m()],f.prototype,"channelsLoading",2);g([m()],f.prototype,"channelsSnapshot",2);g([m()],f.prototype,"channelsError",2);g([m()],f.prototype,"channelsLastSuccess",2);g([m()],f.prototype,"whatsappLoginMessage",2);g([m()],f.prototype,"whatsappLoginQrDataUrl",2);g([m()],f.prototype,"whatsappLoginConnected",2);g([m()],f.prototype,"whatsappBusy",2);g([m()],f.prototype,"whatsappActiveQrAccountId",2);g([m()],f.prototype,"whatsappPairedPhone",2);g([m()],f.prototype,"addingWhatsAppAccount",2);g([m()],f.prototype,"newWhatsAppAccountName",2);g([m()],f.prototype,"whatsappAccountError",2);g([m()],f.prototype,"whatsappAccountSaving",2);g([m()],f.prototype,"whatsappSettingsOpen",2);g([m()],f.prototype,"publicChatToggleBusy",2);g([m()],f.prototype,"publicChatGreetingBusy",2);g([m()],f.prototype,"publicChatEmailBusy",2);g([m()],f.prototype,"publicChatSettingsOpen",2);g([m()],f.prototype,"publicChatWidgetModalOpen",2);g([m()],f.prototype,"brandingBusy",2);g([m()],f.prototype,"agentSettingsOpen",2);g([m()],f.prototype,"brandingExpanded",2);g([m()],f.prototype,"tailscaleStatus",2);g([m()],f.prototype,"tailscaleBusy",2);g([m()],f.prototype,"tailscaleAuthUrl",2);g([m()],f.prototype,"tailscaleError",2);g([m()],f.prototype,"tailscaleServeEnableUrl",2);g([m()],f.prototype,"tailscaleFunnelEnableUrl",2);g([m()],f.prototype,"tailscaleDisableConfirm",2);g([m()],f.prototype,"tailscaleConnectProgress",2);g([m()],f.prototype,"tailscaleConnectMessage",2);g([m()],f.prototype,"tailscaleConnectSuccess",2);g([m()],f.prototype,"wifiStatus",2);g([m()],f.prototype,"wifiNetworks",2);g([m()],f.prototype,"wifiBusy",2);g([m()],f.prototype,"wifiError",2);g([m()],f.prototype,"wifiPassword",2);g([m()],f.prototype,"wifiSelectedSsid",2);g([m()],f.prototype,"networkPort",2);g([m()],f.prototype,"networkHostname",2);g([m()],f.prototype,"networkPortInput",2);g([m()],f.prototype,"networkHostnameInput",2);g([m()],f.prototype,"networkModalOpen",2);g([m()],f.prototype,"networkBusy",2);g([m()],f.prototype,"networkError",2);g([m()],f.prototype,"networkSuccess",2);g([m()],f.prototype,"wifiModalOpen",2);g([m()],f.prototype,"licenseKey",2);g([m()],f.prototype,"licenseBusy",2);g([m()],f.prototype,"licenseValid",2);g([m()],f.prototype,"licenseMessage",2);g([m()],f.prototype,"licenseTier",2);g([m()],f.prototype,"licenseDeviceId",2);g([m()],f.prototype,"licenseStoredKey",2);g([m()],f.prototype,"licenseRemoveConfirm",2);g([m()],f.prototype,"authConnected",2);g([m()],f.prototype,"authBusy",2);g([m()],f.prototype,"authMessage",2);g([m()],f.prototype,"authUrl",2);g([m()],f.prototype,"authCodeInput",2);g([m()],f.prototype,"authExpiresIn",2);g([m()],f.prototype,"setupStep",2);g([m()],f.prototype,"gatewayHealthy",2);g([m()],f.prototype,"gatewayHealthLoading",2);g([m()],f.prototype,"gatewayHealthMessage",2);g([m()],f.prototype,"gatewayRestartBusy",2);g([m()],f.prototype,"updateAvailable",2);g([m()],f.prototype,"currentVersion",2);g([m()],f.prototype,"latestVersion",2);g([m()],f.prototype,"updateChecking",2);g([m()],f.prototype,"updateMessage",2);g([m()],f.prototype,"updateProgressSteps",2);g([m()],f.prototype,"updateLastResult",2);g([m()],f.prototype,"uninstallConfirm",2);g([m()],f.prototype,"uninstallBusy",2);g([m()],f.prototype,"uninstallDone",2);g([m()],f.prototype,"uninstallError",2);g([m()],f.prototype,"uninstallConfirmText",2);g([m()],f.prototype,"nostrProfileFormState",2);g([m()],f.prototype,"nostrProfileAccountId",2);g([m()],f.prototype,"presenceLoading",2);g([m()],f.prototype,"presenceEntries",2);g([m()],f.prototype,"presenceError",2);g([m()],f.prototype,"presenceStatus",2);g([m()],f.prototype,"agentsLoading",2);g([m()],f.prototype,"agentsList",2);g([m()],f.prototype,"agentsError",2);g([m()],f.prototype,"sessionsLoading",2);g([m()],f.prototype,"sessionsResult",2);g([m()],f.prototype,"sessionsError",2);g([m()],f.prototype,"cronLoading",2);g([m()],f.prototype,"cronJobs",2);g([m()],f.prototype,"cronStatus",2);g([m()],f.prototype,"cronError",2);g([m()],f.prototype,"cronForm",2);g([m()],f.prototype,"cronRunsJobId",2);g([m()],f.prototype,"cronRuns",2);g([m()],f.prototype,"cronBusy",2);g([m()],f.prototype,"cronNewEventModal",2);g([m()],f.prototype,"cronDetailJobId",2);g([m()],f.prototype,"cronEditJobId",2);g([m()],f.prototype,"cronPendingDeleteId",2);g([m()],f.prototype,"cronRunModalJobId",2);g([m()],f.prototype,"cronRunModalJobName",2);g([m()],f.prototype,"cronRunResult",2);g([m()],f.prototype,"openingHoursLoading",2);g([m()],f.prototype,"openingHoursError",2);g([m()],f.prototype,"openingHoursBusy",2);g([m()],f.prototype,"openingHoursForm",2);g([m()],f.prototype,"browserScreencastActive",2);g([m()],f.prototype,"browserScreencastFrame",2);g([m()],f.prototype,"browserScreencastMetadata",2);g([m()],f.prototype,"browserHandoffPending",2);g([m()],f.prototype,"browserHandoffReason",2);g([m()],f.prototype,"browserHandoffId",2);g([m()],f.prototype,"browserInputMode",2);g([m()],f.prototype,"browserFullscreen",2);g([m()],f.prototype,"browserLoading",2);g([m()],f.prototype,"browserError",2);g([m()],f.prototype,"filesLoading",2);g([m()],f.prototype,"filesTree",2);g([m()],f.prototype,"filesRoot",2);g([m()],f.prototype,"filesError",2);g([m()],f.prototype,"filesSelectedPath",2);g([m()],f.prototype,"filesSelectedPaths",2);g([m()],f.prototype,"filesPreviewContent",2);g([m()],f.prototype,"filesPreviewLoading",2);g([m()],f.prototype,"filesPreviewBinary",2);g([m()],f.prototype,"filesPreviewSize",2);g([m()],f.prototype,"filesExpandedDirs",2);g([m()],f.prototype,"filesCurrentDir",2);g([m()],f.prototype,"filesPendingDeletePath",2);g([m()],f.prototype,"filesMessage",2);g([m()],f.prototype,"filesUploadBusy",2);g([m()],f.prototype,"filesReindexBusy",2);g([m()],f.prototype,"filesMemoryStatus",2);g([m()],f.prototype,"embeddingDownloading",2);g([m()],f.prototype,"filesSearchQuery",2);g([m()],f.prototype,"filesSearchResults",2);g([m()],f.prototype,"filesSearchLoading",2);g([m()],f.prototype,"filesSearchAgentId",2);g([m()],f.prototype,"auditEntries",2);g([m()],f.prototype,"auditLoading",2);g([m()],f.prototype,"auditModalOpen",2);g([m()],f.prototype,"skillsLoading",2);g([m()],f.prototype,"skillsReport",2);g([m()],f.prototype,"skillsError",2);g([m()],f.prototype,"skillsFilter",2);g([m()],f.prototype,"skillsTypeFilter",2);g([m()],f.prototype,"skillEdits",2);g([m()],f.prototype,"skillsBusyKey",2);g([m()],f.prototype,"skillMessages",2);g([m()],f.prototype,"skillDetail",2);g([m()],f.prototype,"skillDetailTab",2);g([m()],f.prototype,"skillAddModal",2);g([m()],f.prototype,"skillAddForm",2);g([m()],f.prototype,"skillAddFormSource",2);g([m()],f.prototype,"skillEditTab",2);g([m()],f.prototype,"skillDrafts",2);g([m()],f.prototype,"adminsLoading",2);g([m()],f.prototype,"adminPhones",2);g([m()],f.prototype,"adminsError",2);g([m()],f.prototype,"adminsSaving",2);g([m()],f.prototype,"adminsNewPhone",2);g([m()],f.prototype,"contactsLoading",2);g([m()],f.prototype,"contactsSaving",2);g([m()],f.prototype,"contactsRecords",2);g([m()],f.prototype,"contactsError",2);g([m()],f.prototype,"contactsSearchQuery",2);g([m()],f.prototype,"contactsEditingId",2);g([m()],f.prototype,"contactsShowAddForm",2);g([m()],f.prototype,"contactsNewPhone",2);g([m()],f.prototype,"contactsNewName",2);g([m()],f.prototype,"contactsDeleteConfirmId",2);g([m()],f.prototype,"contactsAddFieldForId",2);g([m()],f.prototype,"contactsAddFieldKey",2);g([m()],f.prototype,"contactsAddFieldValue",2);g([m()],f.prototype,"imessageEnableConfirm",2);g([m()],f.prototype,"imessageEnabling",2);g([m()],f.prototype,"chatPageTab",2);g([m()],f.prototype,"waConversations",2);g([m()],f.prototype,"waSelectedJid",2);g([m()],f.prototype,"waMessages",2);g([m()],f.prototype,"waGroupInfo",2);g([m()],f.prototype,"waLoading",2);g([m()],f.prototype,"waMessagesLoading",2);g([m()],f.prototype,"waSearchQuery",2);g([m()],f.prototype,"waComposeDraft",2);g([m()],f.prototype,"waSending",2);g([m()],f.prototype,"waLastError",2);g([m()],f.prototype,"infoModalOpen",2);g([m()],f.prototype,"remoteAccessQrDataUrl",2);g([m()],f.prototype,"publicChatQrDataUrl",2);g([m()],f.prototype,"workspaces",2);g([m()],f.prototype,"workspacesLoading",2);g([m()],f.prototype,"workspacesError",2);g([m()],f.prototype,"selectedWorkspace",2);g([m()],f.prototype,"addingWorkspace",2);g([m()],f.prototype,"newWorkspaceName",2);g([m()],f.prototype,"newWorkspacePath",2);g([m()],f.prototype,"newWorkspacePin",2);g([m()],f.prototype,"accountPinModalOpen",2);g([m()],f.prototype,"accountPinBusy",2);g([m()],f.prototype,"accountPinError",2);g([m()],f.prototype,"accountPinSuccess",2);g([m()],f.prototype,"apiKeyProviders",2);g([m()],f.prototype,"apiKeyModalOpen",2);g([m()],f.prototype,"apiKeyBusy",2);g([m()],f.prototype,"apiKeyError",2);g([m()],f.prototype,"apiKeySuccess",2);g([m()],f.prototype,"apiKeySavingProvider",2);g([m()],f.prototype,"authApiKeyMode",2);g([m()],f.prototype,"authApiKeyInput",2);g([m()],f.prototype,"authApiKeyBusy",2);g([m()],f.prototype,"authApiKeyError",2);g([m()],f.prototype,"pinChanging",2);g([m()],f.prototype,"pinChangeBusy",2);g([m()],f.prototype,"pinChangeError",2);g([m()],f.prototype,"loginChangePinMode",2);g([m()],f.prototype,"changePinBusy",2);g([m()],f.prototype,"changePinError",2);g([m()],f.prototype,"changePinSuccess",2);g([m()],f.prototype,"workspaceSaving",2);g([m()],f.prototype,"workspaceRemoveConfirm",2);g([m()],f.prototype,"renamingWorkspace",2);g([m()],f.prototype,"renameWorkspaceName",2);g([m()],f.prototype,"debugLoading",2);g([m()],f.prototype,"debugStatus",2);g([m()],f.prototype,"debugHealth",2);g([m()],f.prototype,"debugModels",2);g([m()],f.prototype,"debugHeartbeat",2);g([m()],f.prototype,"debugCallMethod",2);g([m()],f.prototype,"debugCallParams",2);g([m()],f.prototype,"debugCallResult",2);g([m()],f.prototype,"debugCallError",2);g([m()],f.prototype,"logsLoading",2);g([m()],f.prototype,"logsError",2);g([m()],f.prototype,"logsFile",2);g([m()],f.prototype,"logsEntries",2);g([m()],f.prototype,"logsFilterText",2);g([m()],f.prototype,"logsLevelFilters",2);g([m()],f.prototype,"logsAutoFollow",2);g([m()],f.prototype,"logsTruncated",2);g([m()],f.prototype,"logsCursor",2);g([m()],f.prototype,"logsLastFetchAt",2);g([m()],f.prototype,"logsLimit",2);g([m()],f.prototype,"logsMaxBytes",2);g([m()],f.prototype,"logsAtBottom",2);g([m()],f.prototype,"logsSubTab",2);g([m()],f.prototype,"logsChipsExpanded",2);g([m()],f.prototype,"sessionLogsLoading",2);g([m()],f.prototype,"sessionLogsError",2);g([m()],f.prototype,"sessionLogsEntries",2);g([m()],f.prototype,"sessionLogsFilterText",2);g([m()],f.prototype,"sessionLogsTypeFilters",2);g([m()],f.prototype,"sessionLogsAgentFilters",2);g([m()],f.prototype,"sessionLogsAgents",2);g([m()],f.prototype,"sessionLogsAutoFollow",2);g([m()],f.prototype,"sessionLogsChipsExpanded",2);g([m()],f.prototype,"sessionLogsCursors",2);g([m()],f.prototype,"sessionLogsLastFetchAt",2);g([m()],f.prototype,"sessionLogsAtBottom",2);g([m()],f.prototype,"chatUserNearBottom",2);f=g([ql("taskmaster-app")],f);
4782
+ //# sourceMappingURL=index-wJYMFZnC.js.map