@rubytech/taskmaster 1.3.0 → 1.4.1

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 bd=Object.defineProperty;var wd=(e,t,n)=>t in e?bd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var W=(e,t,n)=>wd(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 r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).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 kd="modulepreload",Sd=function(e,t){return new URL(e,t).href},xr={},oe=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let c=function(l){return Promise.all(l.map(p=>Promise.resolve(p).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const r=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),u=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=c(n.map(l=>{if(l=Sd(l,i),l in xr)return;xr[l]=!0;const p=l.endsWith(".css"),f=p?'[rel="stylesheet"]':"";if(i)for(let h=r.length-1;h>=0;h--){const v=r[h];if(v.href===l&&(!p||v.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${f}`))return;const b=document.createElement("link");if(b.rel=p?"stylesheet":kd,p||(b.as="script"),b.crossOrigin="",b.href=l,u&&b.setAttribute("nonce",u),document.head.appendChild(b),p)return new Promise((h,v)=>{b.addEventListener("load",h),b.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(r){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=r,window.dispatchEvent(a),!a.defaultPrevented)throw r}return s.then(r=>{for(const a of r||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};const ai=globalThis,go=ai.ShadowRoot&&(ai.ShadyCSS===void 0||ai.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,mo=Symbol(),Er=new WeakMap;let bl=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==mo)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=Er.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Er.set(n,t))}return t}toString(){return this.cssText}};const $d=e=>new bl(typeof e=="string"?e:e+"",void 0,mo),Ad=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((i,s,o)=>i+(r=>{if(r._$cssResult$===!0)return r.cssText;if(typeof r=="number")return r;throw Error("Value passed to 'css' function must be a 'css' function result: "+r+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[o+1],e[0]);return new bl(n,e,mo)},xd=(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=ai.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},Cr=go?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return $d(n)})(e):e;const{is:Ed,defineProperty:Cd,getOwnPropertyDescriptor:Td,getOwnPropertyNames:_d,getOwnPropertySymbols:Md,getPrototypeOf:Pd}=Object,et=globalThis,Tr=et.trustedTypes,Ld=Tr?Tr.emptyScript:"",os=et.reactiveElementPolyfillSupport,mn=(e,t)=>e,hi={toAttribute(e,t){switch(t){case Boolean:e=e?Ld: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}},yo=(e,t)=>!Ed(e,t),_r={attribute:!0,type:String,converter:hi,reflect:!1,useDefault:!1,hasChanged:yo};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),et.litPropertyMetadata??(et.litPropertyMetadata=new WeakMap);let Dt=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=_r){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&&Cd(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=Td(this.prototype,t)??{get(){return this[n]},set(r){this[n]=r}};return{get:s,set(r){const a=s==null?void 0:s.call(this);o==null||o.call(this,r),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??_r}static _$Ei(){if(this.hasOwnProperty(mn("elementProperties")))return;const t=Pd(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(mn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(mn("properties"))){const n=this.properties,i=[..._d(n),...Md(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(Cr(s))}else t!==void 0&&n.push(Cr(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 xd(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 r=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:hi).toAttribute(n,i.type);this._$Em=t,r==null?this.removeAttribute(s):this.setAttribute(s,r),this._$Em=null}}_$AK(t,n){var o,r;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const a=i.getPropertyOptions(s),u=typeof a.converter=="function"?{fromAttribute:a.converter}:((o=a.converter)==null?void 0:o.fromAttribute)!==void 0?a.converter:hi;this._$Em=s;const c=u.fromAttribute(n,a.type);this[s]=c??((r=this._$Ej)==null?void 0:r.get(s))??c,this._$Em=null}}requestUpdate(t,n,i,s=!1,o){var r;if(t!==void 0){const a=this.constructor;if(s===!1&&(o=this[t]),i??(i=a.getPropertyOptions(t)),!((i.hasChanged??yo)(o,n)||i.useDefault&&i.reflect&&o===((r=this._$Ej)==null?void 0:r.get(t))&&!this.hasAttribute(a._$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},r){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,r??n??this[t]),o!==!0||r!==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,r]of this._$Ep)this[o]=r;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,r]of s){const{wrapped:a}=r,u=this[o];a!==!0||this._$AL.has(o)||u===void 0||this.C(o,void 0,r,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){}};Dt.elementStyles=[],Dt.shadowRootOptions={mode:"open"},Dt[mn("elementProperties")]=new Map,Dt[mn("finalized")]=new Map,os==null||os({ReactiveElement:Dt}),(et.reactiveElementVersions??(et.reactiveElementVersions=[])).push("2.1.2");const yn=globalThis,Mr=e=>e,fi=yn.trustedTypes,Pr=fi?fi.createPolicy("lit-html",{createHTML:e=>e}):void 0,wl="$lit$",Ze=`lit$${Math.random().toFixed(9).slice(2)}$`,kl="?"+Ze,Id=`<${kl}>`,yt=document,En=()=>yt.createComment(""),Cn=e=>e===null||typeof e!="object"&&typeof e!="function",vo=Array.isArray,Rd=e=>vo(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",rs=`[
2
- \f\r]`,nn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Lr=/-->/g,Ir=/>/g,ct=RegExp(`>|${rs}(?:([^\\s"'>=/]+)(${rs}*=${rs}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Rr=/'/g,Dr=/"/g,Sl=/^(?:script|style|textarea|title)$/i,Dd=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),d=Dd(1),it=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),Br=new WeakMap,ht=yt.createTreeWalker(yt,129);function $l(e,t){if(!vo(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Pr!==void 0?Pr.createHTML(t):t}const Bd=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",r=nn;for(let a=0;a<n;a++){const u=e[a];let c,l,p=-1,f=0;for(;f<u.length&&(r.lastIndex=f,l=r.exec(u),l!==null);)f=r.lastIndex,r===nn?l[1]==="!--"?r=Lr:l[1]!==void 0?r=Ir:l[2]!==void 0?(Sl.test(l[2])&&(s=RegExp("</"+l[2],"g")),r=ct):l[3]!==void 0&&(r=ct):r===ct?l[0]===">"?(r=s??nn,p=-1):l[1]===void 0?p=-2:(p=r.lastIndex-l[2].length,c=l[1],r=l[3]===void 0?ct:l[3]==='"'?Dr:Rr):r===Dr||r===Rr?r=ct:r===Lr||r===Ir?r=nn:(r=ct,s=void 0);const b=r===ct&&e[a+1].startsWith("/>")?" ":"";o+=r===nn?u+Id:p>=0?(i.push(c),u.slice(0,p)+wl+u.slice(p)+Ze+b):u+Ze+(p===-2?a:b)}return[$l(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let Ws=class Al{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,r=0;const a=t.length-1,u=this.parts,[c,l]=Bd(t,n);if(this.el=Al.createElement(c,i),ht.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=ht.nextNode())!==null&&u.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const p of s.getAttributeNames())if(p.endsWith(wl)){const f=l[r++],b=s.getAttribute(p).split(Ze),h=/([.?@])?(.*)/.exec(f);u.push({type:1,index:o,name:h[2],strings:b,ctor:h[1]==="."?Od:h[1]==="?"?Fd:h[1]==="@"?Ud:Di}),s.removeAttribute(p)}else p.startsWith(Ze)&&(u.push({type:6,index:o}),s.removeAttribute(p));if(Sl.test(s.tagName)){const p=s.textContent.split(Ze),f=p.length-1;if(f>0){s.textContent=fi?fi.emptyScript:"";for(let b=0;b<f;b++)s.append(p[b],En()),ht.nextNode(),u.push({type:2,index:++o});s.append(p[f],En())}}}else if(s.nodeType===8)if(s.data===kl)u.push({type:2,index:o});else{let p=-1;for(;(p=s.data.indexOf(Ze,p+1))!==-1;)u.push({type:7,index:o}),p+=Ze.length-1}o++}}static createElement(t,n){const i=yt.createElement("template");return i.innerHTML=t,i}};function Wt(e,t,n=e,i){var r,a;if(t===it)return t;let s=i!==void 0?(r=n._$Co)==null?void 0:r[i]:n._$Cl;const o=Cn(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((a=s==null?void 0:s._$AO)==null||a.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=Wt(e,s._$AS(e,t.values),s,i)),t}class Nd{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)??yt).importNode(n,!0);ht.currentNode=s;let o=ht.nextNode(),r=0,a=0,u=i[0];for(;u!==void 0;){if(r===u.index){let c;u.type===2?c=new Ri(o,o.nextSibling,this,t):u.type===1?c=new u.ctor(o,u.name,u.strings,this,t):u.type===6&&(c=new Wd(o,this,t)),this._$AV.push(c),u=i[++a]}r!==(u==null?void 0:u.index)&&(o=ht.nextNode(),r++)}return ht.currentNode=yt,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 Ri=class xl{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=k,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=Wt(this,t,n),Cn(t)?t===k||t==null||t===""?(this._$AH!==k&&this._$AR(),this._$AH=k):t!==this._$AH&&t!==it&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Rd(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!==k&&Cn(this._$AH)?this._$AA.nextSibling.data=t:this.T(yt.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=Ws.createElement($l(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(n);else{const r=new Nd(s,this),a=r.u(this.options);r.p(n),this.T(a),this._$AH=r}}_$AC(t){let n=Br.get(t.strings);return n===void 0&&Br.set(t.strings,n=new Ws(t)),n}k(t){vo(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 xl(this.O(En()),this.O(En()),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=Mr(t).nextSibling;Mr(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class Di{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=k,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=k}_$AI(t,n=this,i,s){const o=this.strings;let r=!1;if(o===void 0)t=Wt(this,t,n,0),r=!Cn(t)||t!==this._$AH&&t!==it,r&&(this._$AH=t);else{const a=t;let u,c;for(t=o[0],u=0;u<o.length-1;u++)c=Wt(this,a[i+u],n,u),c===it&&(c=this._$AH[u]),r||(r=!Cn(c)||c!==this._$AH[u]),c===k?t=k:t!==k&&(t+=(c??"")+o[u+1]),this._$AH[u]=c}r&&!s&&this.j(t)}j(t){t===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let Od=class extends Di{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===k?void 0:t}},Fd=class extends Di{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==k)}},Ud=class extends Di{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=Wt(this,t,n,0)??k)===it)return;const i=this._$AH,s=t===k&&i!==k||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==k&&(i===k||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)}},Wd=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){Wt(this,t)}};const Kd={I:Ri},as=yn.litHtmlPolyfillSupport;as==null||as(Ws,Ri),(yn.litHtmlVersions??(yn.litHtmlVersions=[])).push("3.3.2");const zd=(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 Ri(t.insertBefore(En(),o),o,void 0,n??{})}return s._$AI(e),s};const gt=globalThis;let Ot=class extends Dt{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=zd(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 it}};var vl;Ot._$litElement$=!0,Ot.finalized=!0,(vl=gt.litElementHydrateSupport)==null||vl.call(gt,{LitElement:Ot});const ls=gt.litElementPolyfillSupport;ls==null||ls({LitElement:Ot});(gt.litElementVersions??(gt.litElementVersions=[])).push("4.2.2");const El=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const qd={attribute:!0,type:String,converter:hi,reflect:!1,hasChanged:yo},Hd=(e=qd,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:r}=n;return{set(a){const u=t.get.call(this);t.set.call(this,a),this.requestUpdate(r,u,e,!0,a)},init(a){return a!==void 0&&this.C(r,void 0,e,a),a}}}if(i==="setter"){const{name:r}=n;return function(a){const u=this[r];t.call(this,a),this.requestUpdate(r,u,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function Bi(e){return(t,n)=>typeof n=="object"?Hd(e,t,n):((i,s,o)=>{const r=s.hasOwnProperty(o);return s.constructor.createProperty(o,i),r?Object.getOwnPropertyDescriptor(s,o):void 0})(e,t,n)}function y(e){return Bi({...e,state:!0,attribute:!1})}const jd=50,Vd=200,Gd="Assistant";function Nr(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function Ks(e){const t=Nr(e==null?void 0:e.name,jd)??Gd,n=Nr((e==null?void 0:e.avatar)??void 0,Vd)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function Qd(){return Ks(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Yd="Taskmaster",Xd="/taskmaster-icon.png",Jd="#00d4ff",Zd="";let qn=null;function He(){return qn||(qn={name:window.__TASKMASTER_BRAND_NAME__||Yd,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||Xd,accentColor:window.__TASKMASTER_ACCENT_COLOR__||Jd,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||Zd},qn)}function Le(){return window.__TASKMASTER_WORKSPACE_BRANDS__??{}}function Cl(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 r=parseInt(o,16)/255;return r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)});return .2126*n+.7152*i+.0722*s}function Tl(e){const t=Cl(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 Hn(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,l)=>Math.round(parseInt(i[c],16)*(1-n)+parseInt(s[l],16)*n),r=o(1,1),a=o(2,2),u=o(3,3);return`#${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${u.toString(16).padStart(2,"0")}`}const sn={"--bg":"#12141a","--bg-muted":"#262a35","--card":"#181b22","--secondary":"#1e2028"};function _l(e){const t=document.documentElement;if(!e){for(const[i,s]of Object.entries(sn))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=Cl(e);n&&(t.style.setProperty("--bg",Hn(sn["--bg"],e,.08)),t.style.setProperty("--bg-muted",Hn(sn["--bg-muted"],e,.1)),t.style.setProperty("--card",Hn(sn["--card"],e,.12)),t.style.setProperty("--secondary",Hn(sn["--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 vn(e){const t=He(),n=Le(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;Tl(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;_l(o)}const gi="taskmaster.control.settings.v1",Ml="taskmaster.account.settings.";function bn(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const Rt={gatewayUrl:bn(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},Je={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function tp(){try{const e=localStorage.getItem(gi);if(!e)return{...Rt,gatewayUrl:bn()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():bn(),token:typeof t.token=="string"?t.token:Rt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:Rt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:Rt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:Rt.navGroupsCollapsed}}catch{return{...Rt,gatewayUrl:bn()}}}function np(e){if(!e)return{...Je};try{const t=localStorage.getItem(Ml+e);if(!t)return{...Je};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():Je.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||Je.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:Je.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:Je.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:Je.splitRatio}}catch{return{...Je}}}let mi=null;function Or(e){mi=e}function cs(){return{...tp(),...np(mi)}}function ip(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(gi,JSON.stringify(t)),mi){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Ml+mi,JSON.stringify(n))}}(function(){try{const t=localStorage.getItem(gi);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:bn(),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(gi,JSON.stringify(i))}catch{}})();function Pl(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 sp=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,jn=/<\s*\/?\s*final\b[^>]*>/gi,Fr=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function op(e,t){return e.trimStart()}function rp(e,t){if(!e||!sp.test(e))return e;let n=e;jn.test(n)?(jn.lastIndex=0,n=n.replace(jn,"")):jn.lastIndex=0,Fr.lastIndex=0;let i="",s=0,o=!1;for(const r of n.matchAll(Fr)){const a=r.index??0,u=r[1]==="/";o?u&&(o=!1):(i+=n.slice(s,a),u||(o=!0)),s=a+r[0].length}return i+=n.slice(s),op(i)}function Ll(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function Ni(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const r=-t,a=Math.round(r/1e3);if(a<60)return`in ${a}s`;const u=Math.round(a/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 Il(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 ap(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Rl(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 yi(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function us(e){return rp(e)}const lp=/^\[([^\]]+)\]\s*/,cp=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],ds=new WeakMap,ps=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:cp.some(t=>e.startsWith(`${t} `))}function hs(e){const t=e.match(lp);if(!t)return e;const n=t[1]??"";return up(n)?e.slice(t[0].length):e}function wn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?us(i):hs(i);if(Array.isArray(i)){const s=i.map(o=>{const r=o;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(o=>typeof o=="string");if(s.length>0){const o=s.join(`
4
- `);return n==="assistant"?us(o):hs(o)}}return typeof t.text=="string"?n==="assistant"?us(t.text):hs(t.text):null}function Dl(e){if(!e||typeof e!="object")return wn(e);const t=e;if(ds.has(t))return ds.get(t)??null;const n=wn(e);return ds.set(t,n),n}function Ur(e){const n=e.content,i=[];if(Array.isArray(n))for(const a of n){const u=a;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=pp(e);if(!s)return null;const r=[...s.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(a=>(a[1]??"").trim()).filter(Boolean);return r.length>0?r.join(`
6
- `):null}function dp(e){if(!e||typeof e!="object")return Ur(e);const t=e;if(ps.has(t))return ps.get(t)??null;const n=Ur(e);return ps.set(t,n),n}function pp(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 hp(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 fp=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,gp=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,mp=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,yp=/^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"&&fp.test(s)||n==="assistant"&&gp.test(s)||n==="user"&&yp.test(s)||n==="assistant"&&mp.test(s)):!1}function Bl(e){return e.filter(t=>!vp(t))}function Nl(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,r=Array.isArray(o)&&o.some(p=>{const b=String(p.type??"").toLowerCase();return b==="toolresult"||b==="tool_result"}),a=typeof t.toolName=="string"||typeof t.tool_name=="string";(i||r||a)&&(n="toolResult");let u=[];typeof t.content=="string"?u=[{type:"text",text:t.content}]:Array.isArray(t.content)?u=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(u=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),l=typeof t.id=="string"?t.id:void 0;return{role:n,content:u,timestamp:c,id:l}}function Ol(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 Fl(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function Wr(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 bp(){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 Oi(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),Wr(t)}return Wr(bp())}const De=50;async function Re(e,t){if(!e.client||!e.connected)return;e.chatLoading=!0,e.lastError=null;const n=(t==null?void 0:t.limit)??De;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,r=Bl(s);e.chatMessages=r,e.chatHistoryTotal=o,e.chatHistoryHasMore=o>s.length,e.chatThinkingLevel=i.thinkingLevel??null,e.chatModelProvider=typeof i.modelProvider=="string"?i.modelProvider:null,e.chatModel=typeof i.model=="string"?i.model:null,e.chatVerboseLevel=typeof i.verboseLevel=="string"?i.verboseLevel:null,e.chatFillerEnabled=typeof i.fillerEnabled=="boolean"?i.fillerEnabled:null}catch(i){e.lastError=String(i)}finally{e.chatLoading=!1}}async function wp(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:De,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=Bl(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 kp(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function Ul(e,t,n){if(e.chatSuggestion=null,!e.client||!e.connected)return!1;const i=t.trim(),s=n&&n.length>0;if(!i&&!s)return!1;const o=Date.now(),r=(n??[]).filter(b=>!b.fileName),a=(n??[]).filter(b=>b.fileName),u=[],c=a.map(b=>b.fileName).filter(Boolean);if(c.length>0){const b=i?`${c.join(", ")}
1
+ var kd=Object.defineProperty;var Sd=(e,t,n)=>t in e?kd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var W=(e,t,n)=>Sd(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 r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).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 $d="modulepreload",Ad=function(e,t){return new URL(e,t).href},Er={},oe=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let c=function(l){return Promise.all(l.map(p=>Promise.resolve(p).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const r=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),u=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=c(n.map(l=>{if(l=Ad(l,i),l in Er)return;Er[l]=!0;const p=l.endsWith(".css"),f=p?'[rel="stylesheet"]':"";if(i)for(let h=r.length-1;h>=0;h--){const v=r[h];if(v.href===l&&(!p||v.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${f}`))return;const b=document.createElement("link");if(b.rel=p?"stylesheet":$d,p||(b.as="script"),b.crossOrigin="",b.href=l,u&&b.setAttribute("nonce",u),document.head.appendChild(b),p)return new Promise((h,v)=>{b.addEventListener("load",h),b.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(r){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=r,window.dispatchEvent(a),!a.defaultPrevented)throw r}return s.then(r=>{for(const a of r||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};const ai=globalThis,mo=ai.ShadowRoot&&(ai.ShadyCSS===void 0||ai.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,yo=Symbol(),Cr=new WeakMap;let wl=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==yo)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(mo&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=Cr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Cr.set(n,t))}return t}toString(){return this.cssText}};const xd=e=>new wl(typeof e=="string"?e:e+"",void 0,yo),Ed=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((i,s,o)=>i+(r=>{if(r._$cssResult$===!0)return r.cssText;if(typeof r=="number")return r;throw Error("Value passed to 'css' function must be a 'css' function result: "+r+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[o+1],e[0]);return new wl(n,e,yo)},Cd=(e,t)=>{if(mo)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=ai.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},Tr=mo?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return xd(n)})(e):e;const{is:Td,defineProperty:_d,getOwnPropertyDescriptor:Md,getOwnPropertyNames:Pd,getOwnPropertySymbols:Ld,getPrototypeOf:Id}=Object,et=globalThis,_r=et.trustedTypes,Rd=_r?_r.emptyScript:"",rs=et.reactiveElementPolyfillSupport,mn=(e,t)=>e,hi={toAttribute(e,t){switch(t){case Boolean:e=e?Rd: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}},vo=(e,t)=>!Td(e,t),Mr={attribute:!0,type:String,converter:hi,reflect:!1,useDefault:!1,hasChanged:vo};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),et.litPropertyMetadata??(et.litPropertyMetadata=new WeakMap);let Bt=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=Mr){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&&_d(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=Md(this.prototype,t)??{get(){return this[n]},set(r){this[n]=r}};return{get:s,set(r){const a=s==null?void 0:s.call(this);o==null||o.call(this,r),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Mr}static _$Ei(){if(this.hasOwnProperty(mn("elementProperties")))return;const t=Id(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(mn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(mn("properties"))){const n=this.properties,i=[...Pd(n),...Ld(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(Tr(s))}else t!==void 0&&n.push(Tr(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 Cd(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 r=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:hi).toAttribute(n,i.type);this._$Em=t,r==null?this.removeAttribute(s):this.setAttribute(s,r),this._$Em=null}}_$AK(t,n){var o,r;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const a=i.getPropertyOptions(s),u=typeof a.converter=="function"?{fromAttribute:a.converter}:((o=a.converter)==null?void 0:o.fromAttribute)!==void 0?a.converter:hi;this._$Em=s;const c=u.fromAttribute(n,a.type);this[s]=c??((r=this._$Ej)==null?void 0:r.get(s))??c,this._$Em=null}}requestUpdate(t,n,i,s=!1,o){var r;if(t!==void 0){const a=this.constructor;if(s===!1&&(o=this[t]),i??(i=a.getPropertyOptions(t)),!((i.hasChanged??vo)(o,n)||i.useDefault&&i.reflect&&o===((r=this._$Ej)==null?void 0:r.get(t))&&!this.hasAttribute(a._$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},r){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,r??n??this[t]),o!==!0||r!==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,r]of this._$Ep)this[o]=r;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,r]of s){const{wrapped:a}=r,u=this[o];a!==!0||this._$AL.has(o)||u===void 0||this.C(o,void 0,r,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){}};Bt.elementStyles=[],Bt.shadowRootOptions={mode:"open"},Bt[mn("elementProperties")]=new Map,Bt[mn("finalized")]=new Map,rs==null||rs({ReactiveElement:Bt}),(et.reactiveElementVersions??(et.reactiveElementVersions=[])).push("2.1.2");const yn=globalThis,Pr=e=>e,fi=yn.trustedTypes,Lr=fi?fi.createPolicy("lit-html",{createHTML:e=>e}):void 0,kl="$lit$",Ze=`lit$${Math.random().toFixed(9).slice(2)}$`,Sl="?"+Ze,Dd=`<${Sl}>`,vt=document,En=()=>vt.createComment(""),Cn=e=>e===null||typeof e!="object"&&typeof e!="function",bo=Array.isArray,Bd=e=>bo(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",as=`[
2
+ \f\r]`,nn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ir=/-->/g,Rr=/>/g,lt=RegExp(`>|${as}(?:([^\\s"'>=/]+)(${as}*=${as}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Dr=/'/g,Br=/"/g,$l=/^(?:script|style|textarea|title)$/i,Nd=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),d=Nd(1),nt=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),Nr=new WeakMap,ht=vt.createTreeWalker(vt,129);function Al(e,t){if(!bo(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Lr!==void 0?Lr.createHTML(t):t}const Od=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",r=nn;for(let a=0;a<n;a++){const u=e[a];let c,l,p=-1,f=0;for(;f<u.length&&(r.lastIndex=f,l=r.exec(u),l!==null);)f=r.lastIndex,r===nn?l[1]==="!--"?r=Ir:l[1]!==void 0?r=Rr:l[2]!==void 0?($l.test(l[2])&&(s=RegExp("</"+l[2],"g")),r=lt):l[3]!==void 0&&(r=lt):r===lt?l[0]===">"?(r=s??nn,p=-1):l[1]===void 0?p=-2:(p=r.lastIndex-l[2].length,c=l[1],r=l[3]===void 0?lt:l[3]==='"'?Br:Dr):r===Br||r===Dr?r=lt:r===Ir||r===Rr?r=nn:(r=lt,s=void 0);const b=r===lt&&e[a+1].startsWith("/>")?" ":"";o+=r===nn?u+Dd:p>=0?(i.push(c),u.slice(0,p)+kl+u.slice(p)+Ze+b):u+Ze+(p===-2?a:b)}return[Al(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let Ks=class xl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,r=0;const a=t.length-1,u=this.parts,[c,l]=Od(t,n);if(this.el=xl.createElement(c,i),ht.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=ht.nextNode())!==null&&u.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const p of s.getAttributeNames())if(p.endsWith(kl)){const f=l[r++],b=s.getAttribute(p).split(Ze),h=/([.?@])?(.*)/.exec(f);u.push({type:1,index:o,name:h[2],strings:b,ctor:h[1]==="."?Ud:h[1]==="?"?Wd:h[1]==="@"?Kd:Bi}),s.removeAttribute(p)}else p.startsWith(Ze)&&(u.push({type:6,index:o}),s.removeAttribute(p));if($l.test(s.tagName)){const p=s.textContent.split(Ze),f=p.length-1;if(f>0){s.textContent=fi?fi.emptyScript:"";for(let b=0;b<f;b++)s.append(p[b],En()),ht.nextNode(),u.push({type:2,index:++o});s.append(p[f],En())}}}else if(s.nodeType===8)if(s.data===Sl)u.push({type:2,index:o});else{let p=-1;for(;(p=s.data.indexOf(Ze,p+1))!==-1;)u.push({type:7,index:o}),p+=Ze.length-1}o++}}static createElement(t,n){const i=vt.createElement("template");return i.innerHTML=t,i}};function Wt(e,t,n=e,i){var r,a;if(t===nt)return t;let s=i!==void 0?(r=n._$Co)==null?void 0:r[i]:n._$Cl;const o=Cn(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((a=s==null?void 0:s._$AO)==null||a.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=Wt(e,s._$AS(e,t.values),s,i)),t}class Fd{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)??vt).importNode(n,!0);ht.currentNode=s;let o=ht.nextNode(),r=0,a=0,u=i[0];for(;u!==void 0;){if(r===u.index){let c;u.type===2?c=new Di(o,o.nextSibling,this,t):u.type===1?c=new u.ctor(o,u.name,u.strings,this,t):u.type===6&&(c=new zd(o,this,t)),this._$AV.push(c),u=i[++a]}r!==(u==null?void 0:u.index)&&(o=ht.nextNode(),r++)}return ht.currentNode=vt,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 Di=class El{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=k,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=Wt(this,t,n),Cn(t)?t===k||t==null||t===""?(this._$AH!==k&&this._$AR(),this._$AH=k):t!==this._$AH&&t!==nt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Bd(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!==k&&Cn(this._$AH)?this._$AA.nextSibling.data=t:this.T(vt.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=Ks.createElement(Al(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(n);else{const r=new Fd(s,this),a=r.u(this.options);r.p(n),this.T(a),this._$AH=r}}_$AC(t){let n=Nr.get(t.strings);return n===void 0&&Nr.set(t.strings,n=new Ks(t)),n}k(t){bo(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 El(this.O(En()),this.O(En()),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=Pr(t).nextSibling;Pr(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class Bi{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=k,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=k}_$AI(t,n=this,i,s){const o=this.strings;let r=!1;if(o===void 0)t=Wt(this,t,n,0),r=!Cn(t)||t!==this._$AH&&t!==nt,r&&(this._$AH=t);else{const a=t;let u,c;for(t=o[0],u=0;u<o.length-1;u++)c=Wt(this,a[i+u],n,u),c===nt&&(c=this._$AH[u]),r||(r=!Cn(c)||c!==this._$AH[u]),c===k?t=k:t!==k&&(t+=(c??"")+o[u+1]),this._$AH[u]=c}r&&!s&&this.j(t)}j(t){t===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let Ud=class extends Bi{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===k?void 0:t}},Wd=class extends Bi{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==k)}},Kd=class extends Bi{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=Wt(this,t,n,0)??k)===nt)return;const i=this._$AH,s=t===k&&i!==k||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==k&&(i===k||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)}},zd=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){Wt(this,t)}};const qd={I:Di},ls=yn.litHtmlPolyfillSupport;ls==null||ls(Ks,Di),(yn.litHtmlVersions??(yn.litHtmlVersions=[])).push("3.3.2");const Hd=(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 Di(t.insertBefore(En(),o),o,void 0,n??{})}return s._$AI(e),s};const gt=globalThis;let Ot=class extends Bt{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=Hd(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 nt}};var bl;Ot._$litElement$=!0,Ot.finalized=!0,(bl=gt.litElementHydrateSupport)==null||bl.call(gt,{LitElement:Ot});const cs=gt.litElementPolyfillSupport;cs==null||cs({LitElement:Ot});(gt.litElementVersions??(gt.litElementVersions=[])).push("4.2.2");const Cl=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const jd={attribute:!0,type:String,converter:hi,reflect:!1,hasChanged:vo},Vd=(e=jd,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:r}=n;return{set(a){const u=t.get.call(this);t.set.call(this,a),this.requestUpdate(r,u,e,!0,a)},init(a){return a!==void 0&&this.C(r,void 0,e,a),a}}}if(i==="setter"){const{name:r}=n;return function(a){const u=this[r];t.call(this,a),this.requestUpdate(r,u,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function Ni(e){return(t,n)=>typeof n=="object"?Vd(e,t,n):((i,s,o)=>{const r=s.hasOwnProperty(o);return s.constructor.createProperty(o,i),r?Object.getOwnPropertyDescriptor(s,o):void 0})(e,t,n)}function y(e){return Ni({...e,state:!0,attribute:!1})}const Gd=50,Qd=200,Yd="Assistant";function Or(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function zs(e){const t=Or(e==null?void 0:e.name,Gd)??Yd,n=Or((e==null?void 0:e.avatar)??void 0,Qd)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function Xd(){return zs(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Jd="Taskmaster",Zd="/taskmaster-icon.png",ep="#00d4ff",tp="";let qn=null;function He(){return qn||(qn={name:window.__TASKMASTER_BRAND_NAME__||Jd,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||Zd,accentColor:window.__TASKMASTER_ACCENT_COLOR__||ep,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||tp},qn)}function Le(){return window.__TASKMASTER_WORKSPACE_BRANDS__??{}}function Tl(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 np(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 r=parseInt(o,16)/255;return r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)});return .2126*n+.7152*i+.0722*s}function _l(e){const t=Tl(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=np(e)>.4?"#111111":"#ffffff";n.style.setProperty("--accent-foreground",i),n.style.setProperty("--primary-foreground",i)}function Hn(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,l)=>Math.round(parseInt(i[c],16)*(1-n)+parseInt(s[l],16)*n),r=o(1,1),a=o(2,2),u=o(3,3);return`#${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${u.toString(16).padStart(2,"0")}`}const sn={"--bg":"#12141a","--bg-muted":"#262a35","--card":"#181b22","--secondary":"#1e2028"};function Ml(e){const t=document.documentElement;if(!e){for(const[i,s]of Object.entries(sn))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=Tl(e);n&&(t.style.setProperty("--bg",Hn(sn["--bg"],e,.08)),t.style.setProperty("--bg-muted",Hn(sn["--bg-muted"],e,.1)),t.style.setProperty("--card",Hn(sn["--card"],e,.12)),t.style.setProperty("--secondary",Hn(sn["--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 vn(e){const t=He(),n=Le(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;_l(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;Ml(o)}const gi="taskmaster.control.settings.v1",Pl="taskmaster.account.settings.";function bn(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const Dt={gatewayUrl:bn(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},Je={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function ip(){try{const e=localStorage.getItem(gi);if(!e)return{...Dt,gatewayUrl:bn()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():bn(),token:typeof t.token=="string"?t.token:Dt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:Dt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:Dt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:Dt.navGroupsCollapsed}}catch{return{...Dt,gatewayUrl:bn()}}}function sp(e){if(!e)return{...Je};try{const t=localStorage.getItem(Pl+e);if(!t)return{...Je};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():Je.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||Je.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:Je.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:Je.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:Je.splitRatio}}catch{return{...Je}}}let mi=null;function Fr(e){mi=e}function us(){return{...ip(),...sp(mi)}}function op(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(gi,JSON.stringify(t)),mi){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Pl+mi,JSON.stringify(n))}}(function(){try{const t=localStorage.getItem(gi);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:bn(),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(gi,JSON.stringify(i))}catch{}})();function Ll(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,jn=/<\s*\/?\s*final\b[^>]*>/gi,Ur=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function ap(e,t){return e.trimStart()}function lp(e,t){if(!e||!rp.test(e))return e;let n=e;jn.test(n)?(jn.lastIndex=0,n=n.replace(jn,"")):jn.lastIndex=0,Ur.lastIndex=0;let i="",s=0,o=!1;for(const r of n.matchAll(Ur)){const a=r.index??0,u=r[1]==="/";o?u&&(o=!1):(i+=n.slice(s,a),u||(o=!0)),s=a+r[0].length}return i+=n.slice(s),ap(i)}function Il(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function Oi(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const r=-t,a=Math.round(r/1e3);if(a<60)return`in ${a}s`;const u=Math.round(a/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 Rl(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 cp(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Dl(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 yi(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function ds(e){return lp(e)}const up=/^\[([^\]]+)\]\s*/,dp=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],ps=new WeakMap,hs=new WeakMap;function pp(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:dp.some(t=>e.startsWith(`${t} `))}function fs(e){const t=e.match(up);if(!t)return e;const n=t[1]??"";return pp(n)?e.slice(t[0].length):e}function wn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?ds(i):fs(i);if(Array.isArray(i)){const s=i.map(o=>{const r=o;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(o=>typeof o=="string");if(s.length>0){const o=s.join(`
4
+ `);return n==="assistant"?ds(o):fs(o)}}return typeof t.text=="string"?n==="assistant"?ds(t.text):fs(t.text):null}function Bl(e){if(!e||typeof e!="object")return wn(e);const t=e;if(ps.has(t))return ps.get(t)??null;const n=wn(e);return ps.set(t,n),n}function Wr(e){const n=e.content,i=[];if(Array.isArray(n))for(const a of n){const u=a;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=fp(e);if(!s)return null;const r=[...s.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(a=>(a[1]??"").trim()).filter(Boolean);return r.length>0?r.join(`
6
+ `):null}function hp(e){if(!e||typeof e!="object")return Wr(e);const t=e;if(hs.has(t))return hs.get(t)??null;const n=Wr(e);return hs.set(t,n),n}function fp(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 gp(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 mp=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,yp=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,vp=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,bp=/^A new session was started via \/new or \/reset\./;function wp(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"&&mp.test(s)||n==="assistant"&&yp.test(s)||n==="user"&&bp.test(s)||n==="assistant"&&vp.test(s)):!1}function Nl(e){return e.filter(t=>!wp(t))}function Ol(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,r=Array.isArray(o)&&o.some(p=>{const b=String(p.type??"").toLowerCase();return b==="toolresult"||b==="tool_result"}),a=typeof t.toolName=="string"||typeof t.tool_name=="string";(i||r||a)&&(n="toolResult");let u=[];typeof t.content=="string"?u=[{type:"text",text:t.content}]:Array.isArray(t.content)?u=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(u=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),l=typeof t.id=="string"?t.id:void 0;return{role:n,content:u,timestamp:c,id:l}}function Fl(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 Ul(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function Kr(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 kp(){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 Fi(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),Kr(t)}return Kr(kp())}const De=50;async function Re(e,t){if(!e.client||!e.connected)return;e.chatLoading=!0,e.lastError=null;const n=(t==null?void 0:t.limit)??De;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,r=Nl(s);e.chatMessages=r,e.chatHistoryTotal=o,e.chatHistoryHasMore=o>s.length,e.chatThinkingLevel=i.thinkingLevel??null,e.chatModelProvider=typeof i.modelProvider=="string"?i.modelProvider:null,e.chatModel=typeof i.model=="string"?i.model:null,e.chatVerboseLevel=typeof i.verboseLevel=="string"?i.verboseLevel:null,e.chatFillerEnabled=typeof i.fillerEnabled=="boolean"?i.fillerEnabled:null}catch(i){e.lastError=String(i)}finally{e.chatLoading=!1}}async function Sp(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:De,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=Nl(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 $p(e){const t=/^data:(.+?);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function Wl(e,t,n){if(e.chatSuggestion=null,!e.client||!e.connected)return!1;const i=t.trim(),s=n&&n.length>0;if(!i&&!s)return!1;const o=Date.now(),r=(n??[]).filter(b=>!b.fileName),a=(n??[]).filter(b=>b.fileName),u=[],c=a.map(b=>b.fileName).filter(Boolean);if(c.length>0){const b=i?`${c.join(", ")}
9
9
 
10
- ${i}`:c.join(", ");u.push({type:"text",text:b})}else i&&u.push({type:"text",text:i});for(const b of r)u.push({type:"image",source:{type:"base64",media_type:b.mimeType,data:b.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:u,timestamp:o}],e.chatSending=!0,e.lastError=null;const l=Oi();e.chatRunId=l,e.chatStream="",e.chatStreamStartedAt=o;const p=[...r,...a],f=p.length>0?p.map(b=>{if(b.textContent)return{type:"document",mimeType:b.mimeType||"text/plain",fileName:b.fileName,content:btoa(unescape(encodeURIComponent(b.textContent)))};const h=kp(b.dataUrl);return h?{type:b.fileName?"document":"image",mimeType:h.mimeType,fileName:b.fileName,content:h.content}:null}).filter(b=>b!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:l,attachments:f}),!0}catch(b){const h=String(b);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=h,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+h}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function Wl(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 Kl(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=wn(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 r=o.trim(),a=e.chatInterimText.trim();r===a||a.endsWith(r)||(r.startsWith(a)?e.chatInterimText=o:e.chatInterimText=`${e.chatInterimText}
10
+ ${i}`:c.join(", ");u.push({type:"text",text:b})}else i&&u.push({type:"text",text:i});for(const b of r)u.push({type:"image",source:{type:"base64",media_type:b.mimeType,data:b.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:u,timestamp:o}],e.chatSending=!0,e.lastError=null;const l=Fi();e.chatRunId=l,e.chatStream="",e.chatStreamStartedAt=o;const p=[...r,...a],f=p.length>0?p.map(b=>{if(b.textContent)return{type:"document",mimeType:b.mimeType||"text/plain",fileName:b.fileName,content:btoa(unescape(encodeURIComponent(b.textContent)))};const h=$p(b.dataUrl);return h?{type:b.fileName?"document":"image",mimeType:h.mimeType,fileName:b.fileName,content:h.content}:null}).filter(b=>b!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:l,attachments:f}),!0}catch(b){const h=String(b);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=h,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+h}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function Kl(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 zl(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=wn(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 r=o.trim(),a=e.chatInterimText.trim();r===a||a.endsWith(r)||(r.startsWith(a)?e.chatInterimText=o:e.chatInterimText=`${e.chatInterimText}
11
11
 
12
- ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(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.chatSuggestion=null;const s=wn(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 vi=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:De,abortChatRun:Wl,handleChatEvent:Kl,loadChatHistory:Re,loadOlderChatHistory:wp,sendChatMessage:Ul},Symbol.toStringTag,{value:"Module"}));async function bo(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=yi(e.sessionsFilterActive??"",0),i=yi(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}}}async function Vn(e,t,n){if(!e.client||!e.connected)return;const i={key:t};"label"in n&&(i.label=n.label),"thinkingLevel"in n&&(i.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(i.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(i.reasoningLevel=n.reasoningLevel),"model"in n&&(i.model=n.model),"fillerEnabled"in n&&(i.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",i),await bo(e)}catch(s){e.sessionsError=String(s)}}const Kr=50,Sp=80,$p=12e4;function Ap(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 zr(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Ap(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=Rl(n,$p);return i.truncated?`${i.text}
12
+ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(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.chatSuggestion=null;const s=wn(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 vi=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:De,abortChatRun:Kl,handleChatEvent:zl,loadChatHistory:Re,loadOlderChatHistory:Sp,sendChatMessage:Wl},Symbol.toStringTag,{value:"Module"}));async function wo(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=yi(e.sessionsFilterActive??"",0),i=yi(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}}}async function Vn(e,t,n){if(!e.client||!e.connected)return;const i={key:t};"label"in n&&(i.label=n.label),"thinkingLevel"in n&&(i.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(i.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(i.reasoningLevel=n.reasoningLevel),"model"in n&&(i.model=n.model),"fillerEnabled"in n&&(i.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",i),await wo(e)}catch(s){e.sessionsError=String(s)}}const zr=50,Ap=80,xp=12e4;function Ep(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 qr(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Ep(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=Dl(n,xp);return i.truncated?`${i.text}
14
14
 
15
- … truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function xp(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 Ep(e){if(e.toolStreamOrder.length<=Kr)return;const t=e.toolStreamOrder.length-Kr,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function Cp(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function zs(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Cp(e)}function Tp(e,t=!1){if(t){zs(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>zs(e),Sp))}function wo(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],zs(e)}const _p=5e3;function Mp(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},_p))}function Pp(e,t){if(!t)return;if(t.stream==="compaction"){Mp(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",r=typeof i.phase=="string"?i.phase:"",a=r==="start"?i.args:void 0,u=r==="update"?zr(i.partialResult):r==="result"?zr(i.result):void 0,c=Date.now();let l=e.toolStreamById.get(s);l?(l.name=o,a!==void 0&&(l.args=a),u!==void 0&&(l.output=u),l.updatedAt=c):(l={toolCallId:s,runId:t.runId,sessionKey:n,name:o,args:a,output:u,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(s,l),e.toolStreamOrder.push(s)),l.message=xp(l),Ep(e),Tp(e,r==="result")}let Gn=0;function jt(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=++Gn,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===Gn&&(e.chatScrollFrame=requestAnimationFrame(()=>{if(e.chatScrollFrame=null,n!==Gn)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 a=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{if(e.chatScrollTimeout=null,n!==Gn)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)},a)}))})}function zl(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 Lp(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 Ip(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 Rp(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Dp(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Bp(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function Np(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 Cp(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 Tp(e){if(e.toolStreamOrder.length<=zr)return;const t=e.toolStreamOrder.length-zr,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function _p(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function qs(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),_p(e)}function Mp(e,t=!1){if(t){qs(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>qs(e),Ap))}function ko(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],qs(e)}const Pp=5e3;function Lp(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},Pp))}function Ip(e,t){if(!t)return;if(t.stream==="compaction"){Lp(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",r=typeof i.phase=="string"?i.phase:"",a=r==="start"?i.args:void 0,u=r==="update"?qr(i.partialResult):r==="result"?qr(i.result):void 0,c=Date.now();let l=e.toolStreamById.get(s);l?(l.name=o,a!==void 0&&(l.args=a),u!==void 0&&(l.output=u),l.updatedAt=c):(l={toolCallId:s,runId:t.runId,sessionKey:n,name:o,args:a,output:u,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(s,l),e.toolStreamOrder.push(s)),l.message=Cp(l),Tp(e),Mp(e,r==="result")}let Gn=0;function jt(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=++Gn,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===Gn&&(e.chatScrollFrame=requestAnimationFrame(()=>{if(e.chatScrollFrame=null,n!==Gn)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 a=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{if(e.chatScrollTimeout=null,n!==Gn)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)},a)}))})}function ql(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 Rp(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 Dp(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 Bp(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Np(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Op(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function Fp(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 Op(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 Up(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 Fp(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 st(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function vt(e){return`${JSON.stringify(e,null,2).trimEnd()}
20
- `}function ql(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const r=t[o],a=t[o+1];if(typeof r=="number"){if(!Array.isArray(i))return;i[r]==null&&(i[r]=typeof a=="number"?[]:{}),i=i[r]}else{if(typeof i!="object"||i==null)return;const u=i;u[r]==null&&(u[r]=typeof a=="number"?[]:{}),i=u[r]}}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 Be(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});Wp(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function Hl(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});Up(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function Up(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function Wp(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?vt(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=vt(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=st(t.config??{}),e.configFormOriginal=st(t.config??{}),e.configRawOriginal=n)}async function Kp(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?vt(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 Be(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function Vt(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 Mn(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);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 jl(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=yi(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 Vl(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 r=o.trim();r&&i.push(r)}i.length>0&&(n.to=i.join(","));const s=yi(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function zp(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=jl(e.cronForm),i=Vl(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),r={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(!r.name)throw new Error("Name required.");await e.client.request("cron.add",r),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await Mn(e),await Vt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function qp(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 Mn(e),await Vt(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function Hp(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await qs(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function jp(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 Mn(e),await Vt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function Vp(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(r=>r.trim()).filter(Boolean);t.toAdmins=o.some(r=>r.toLowerCase()==="admins"),t.recipients=o.filter(r=>r.toLowerCase()!=="admins")}}return(n=e.isolation)!=null&&n.postToMainPrefix&&(t.postToMainPrefix=e.isolation.postToMainPrefix),t}async function Gp(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=jl(e.cronForm),i=Vl(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 Mn(e),await Vt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function qs(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 Y(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 ko(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 Gl(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 Ql(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 Yl(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=st(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const r=o.channels;(!r.whatsapp||typeof r.whatsapp!="object")&&(r.whatsapp={});const a=r.whatsapp;(!a.accounts||typeof a.accounts!="object")&&(a.accounts={});const u=a.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 l=vt(o);await e.client.request("config.set",{raw:l,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await Y(e,!0),await ko(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function Xl(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=st(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,r=o==null?void 0:o.accounts;if(!r){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(r).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!r[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete r[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(l=>{const p=l.match;return!p||p.channel!=="whatsapp"?!0:p.accountId!==t}));const u=n.hash;if(!u){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=vt(i);await e.client.request("config.set",{raw:c,baseHash:u}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await Y(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Qp=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:Yl,loadChannels:Y,logoutWhatsApp:Ql,removeWhatsAppAccount:Xl,startWhatsAppLogin:ko,waitWhatsAppLogin:Gl},Symbol.toStringTag,{value:"Module"}));async function So(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 Yp=2e3,Xp=new Set(["trace","debug","info","warn","error","fatal"]);function Jp(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 Zp(e){if(typeof e!="string")return null;const t=e.toLowerCase();return Xp.has(t)?t:null}function Jl(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=Zp((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,r=Jp(o);let a=null;r&&(typeof r.subsystem=="string"?a=r.subsystem:typeof r.module=="string"&&(a=r.module)),!a&&o&&o.length<120&&(a=o);let u=null;return typeof t[1]=="string"?u=t[1]:!r&&typeof t[0]=="string"?u=t[0]:typeof t.message=="string"&&(u=t.message),{raw:e,time:i,level:s,subsystem:a,message:u??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Ft(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}),o=(Array.isArray(i.lines)?i.lines.filter(a=>typeof a=="string"):[]).map(Jl),r=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=r?o:[...e.logsEntries,...o].slice(-Yp),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 eh=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Ft,parseLogLine:Jl},Symbol.toStringTag,{value:"Module"}));const Zl={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:le,n:li,Gx:qr,Gy:Hr,a:fs,d:gs,h:th}=Zl,bt=32,$o=64,nh=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},ie=(e="")=>{const t=new Error(e);throw nh(t,ie),t},ih=e=>typeof e=="bigint",sh=e=>typeof e=="string",oh=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",ot=(e,t,n="")=>{const i=oh(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const r=n&&`"${n}" `,a=o?` of length ${t}`:"",u=i?`length=${s}`:`type=${typeof e}`;ie(r+"expected Uint8Array"+a+", got "+u)}return e},Fi=e=>new Uint8Array(e),ec=e=>Uint8Array.from(e),tc=(e,t)=>e.toString(16).padStart(t,"0"),nc=e=>Array.from(ot(e)).map(t=>tc(t,2)).join(""),We={_0:48,_9:57,A:65,F:70,a:97,f:102},jr=e=>{if(e>=We._0&&e<=We._9)return e-We._0;if(e>=We.A&&e<=We.F)return e-(We.A-10);if(e>=We.a&&e<=We.f)return e-(We.a-10)},ic=e=>{const t="hex invalid";if(!sh(e))return ie(t);const n=e.length,i=n/2;if(n%2)return ie(t);const s=Fi(i);for(let o=0,r=0;o<i;o++,r+=2){const a=jr(e.charCodeAt(r)),u=jr(e.charCodeAt(r+1));if(a===void 0||u===void 0)return ie(t);s[o]=a*16+u}return s},sc=()=>globalThis==null?void 0:globalThis.crypto,rh=()=>{var e;return((e=sc())==null?void 0:e.subtle)??ie("crypto.subtle must be defined, consider polyfill")},Tn=(...e)=>{const t=Fi(e.reduce((i,s)=>i+ot(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},ah=(e=bt)=>sc().getRandomValues(Fi(e)),bi=BigInt,pt=(e,t,n,i="bad number: out of range")=>ih(e)&&t<=e&&e<n?e:ie(i),P=(e,t=le)=>{const n=e%t;return n>=0n?n:t+n},oc=e=>P(e,li),lh=(e,t)=>{(e===0n||t<=0n)&&ie("no inverse n="+e+" mod="+t);let n=P(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const r=i/n,a=i%n,u=s-o*r;i=n,n=a,s=o,o=u}return i===1n?P(s,t):ie("no inverse")},ch=e=>{const t=cc[e];return typeof t!="function"&&ie("hashes."+e+" not set"),t},ms=e=>e instanceof wt?e:ie("Point expected"),Hs=2n**256n,Ie=class Ie{constructor(t,n,i,s){W(this,"X");W(this,"Y");W(this,"Z");W(this,"T");const o=Hs;this.X=pt(t,0n,o),this.Y=pt(n,0n,o),this.Z=pt(i,1n,o),this.T=pt(s,0n,o),Object.freeze(this)}static CURVE(){return Zl}static fromAffine(t){return new Ie(t.x,t.y,1n,P(t.x*t.y))}static fromBytes(t,n=!1){const i=gs,s=ec(ot(t,bt)),o=t[31];s[31]=o&-129;const r=ac(s);pt(r,0n,n?Hs:le);const u=P(r*r),c=P(u-1n),l=P(i*u+1n);let{isValid:p,value:f}=dh(c,l);p||ie("bad point: y not sqrt");const b=(f&1n)===1n,h=(o&128)!==0;return!n&&f===0n&&h&&ie("bad point: x==0, isLastByteOdd"),h!==b&&(f=P(-f)),new Ie(f,r,1n,P(f*r))}static fromHex(t,n){return Ie.fromBytes(ic(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=fs,n=gs,i=this;if(i.is0())return ie("bad point: ZERO");const{X:s,Y:o,Z:r,T:a}=i,u=P(s*s),c=P(o*o),l=P(r*r),p=P(l*l),f=P(u*t),b=P(l*P(f+c)),h=P(p+P(n*P(u*c)));if(b!==h)return ie("bad point: equation left != right (1)");const v=P(s*o),S=P(r*a);return v!==S?ie("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:r,Z:a}=ms(t),u=P(n*a),c=P(o*s),l=P(i*a),p=P(r*s);return u===c&&l===p}is0(){return this.equals(Nt)}negate(){return new Ie(P(-this.X),this.Y,this.Z,P(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=fs,o=P(t*t),r=P(n*n),a=P(2n*P(i*i)),u=P(s*o),c=t+n,l=P(P(c*c)-o-r),p=u+r,f=p-a,b=u-r,h=P(l*f),v=P(p*b),S=P(l*b),$=P(f*p);return new Ie(h,v,$,S)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:r,Y:a,Z:u,T:c}=ms(t),l=fs,p=gs,f=P(n*r),b=P(i*a),h=P(o*p*c),v=P(s*u),S=P((n+i)*(r+a)-f-b),$=P(v-h),A=P(v+h),E=P(b-l*f),T=P(S*$),_=P(A*E),B=P(S*E),F=P($*A);return new Ie(T,_,F,B)}subtract(t){return this.add(ms(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Nt;if(pt(t,1n,li),t===1n)return this;if(this.equals(kt))return Sh(t).p;let i=Nt,s=kt;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(Nt))return{x:0n,y:1n};const s=lh(i,le);P(i*s)!==1n&&ie("invalid inverse");const o=P(t*s),r=P(n*s);return{x:o,y:r}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=rc(n);return i[31]|=t&1n?128:0,i}toHex(){return nc(this.toBytes())}clearCofactor(){return this.multiply(bi(th),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(li/2n,!1).double();return li%2n&&(t=t.add(this)),t.is0()}};W(Ie,"BASE"),W(Ie,"ZERO");let wt=Ie;const kt=new wt(qr,Hr,1n,P(qr*Hr)),Nt=new wt(0n,1n,1n,0n);wt.BASE=kt;wt.ZERO=Nt;const rc=e=>ic(tc(pt(e,0n,Hs),$o)).reverse(),ac=e=>bi("0x"+nc(ec(ot(e)).reverse())),Te=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=le;return n},uh=e=>{const n=e*e%le*e%le,i=Te(n,2n)*n%le,s=Te(i,1n)*e%le,o=Te(s,5n)*s%le,r=Te(o,10n)*o%le,a=Te(r,20n)*r%le,u=Te(a,40n)*a%le,c=Te(u,80n)*u%le,l=Te(c,80n)*u%le,p=Te(l,10n)*o%le;return{pow_p_5_8:Te(p,2n)*e%le,b2:n}},Vr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,dh=(e,t)=>{const n=P(t*t*t),i=P(n*n*t),s=uh(e*i).pow_p_5_8;let o=P(e*n*s);const r=P(t*o*o),a=o,u=P(o*Vr),c=r===e,l=r===P(-e),p=r===P(-e*Vr);return c&&(o=a),(l||p)&&(o=u),(P(o)&1n)===1n&&(o=P(-o)),{isValid:c||l,value:o}},js=e=>oc(ac(e)),Ao=(...e)=>cc.sha512Async(Tn(...e)),ph=(...e)=>ch("sha512")(Tn(...e)),lc=e=>{const t=e.slice(0,bt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(bt,$o),i=js(t),s=kt.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},xo=e=>Ao(ot(e,bt)).then(lc),hh=e=>lc(ph(ot(e,bt))),fh=e=>xo(e).then(t=>t.pointBytes),gh=e=>Ao(e.hashable).then(e.finish),mh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=js(t),r=kt.multiply(o).toBytes();return{hashable:Tn(r,i,n),finish:c=>{const l=oc(o+js(c)*s);return ot(Tn(r,rc(l)),$o)}}},yh=async(e,t)=>{const n=ot(e),i=await xo(t),s=await Ao(i.prefix,n);return gh(mh(i,s,n))},cc={sha512Async:async e=>{const t=rh(),n=Tn(e);return Fi(await t.digest("SHA-512",n.buffer))},sha512:void 0},vh=(e=ah(bt))=>e,bh={getExtendedPublicKeyAsync:xo,getExtendedPublicKey:hh,randomSecretKey:vh},wi=8,wh=256,uc=Math.ceil(wh/wi)+1,Vs=2**(wi-1),kh=()=>{const e=[];let t=kt,n=t;for(let i=0;i<uc;i++){n=t,e.push(n);for(let s=1;s<Vs;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Gr;const Qr=(e,t)=>{const n=t.negate();return e?n:t},Sh=e=>{const t=Gr||(Gr=kh());let n=Nt,i=kt;const s=2**wi,o=s,r=bi(s-1),a=bi(wi);for(let u=0;u<uc;u++){let c=Number(e&r);e>>=a,c>Vs&&(c-=o,e+=1n);const l=u*Vs,p=l,f=l+Math.abs(c)-1,b=u%2!==0,h=c<0;c===0?i=i.add(Qr(b,t[p])):n=n.add(Qr(h,t[f]))}return e!==0n&&ie("invalid wnaf"),{p:n,f:i}},ys="taskmaster-device-identity-v1";function Gs(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function dc(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 $h(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function pc(e){const t=await crypto.subtle.digest("SHA-256",e);return $h(new Uint8Array(t))}async function Ah(){const e=bh.randomSecretKey(),t=await fh(e);return{deviceId:await pc(t),publicKey:Gs(t),privateKey:Gs(e)}}async function xh(){try{const n=localStorage.getItem(ys);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 pc(dc(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(ys,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 Ah(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(ys,JSON.stringify(t)),e}async function Eh(e,t){const n=dc(e),i=new TextEncoder().encode(t),s=await yh(i,n);return Gs(s)}const hc="taskmaster.device.auth.v1";function Eo(e){return e.trim()}function Ch(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 Co(){try{const e=window.localStorage.getItem(hc);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 fc(e){try{window.localStorage.setItem(hc,JSON.stringify(e))}catch{}}function Th(e){const t=Co();if(!t||t.deviceId!==e.deviceId)return null;const n=Eo(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function _h(e){const t=Eo(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=Co();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:Ch(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,fc(n),s}function Mh(e){const t=Co();if(!t||t.deviceId!==e.deviceId)return;const n=Eo(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],fc(i)}async function To(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 _o(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 Ph(e){return{method:"exec.approvals.get",params:{}}}async function Lh(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Ph(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);Ih(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Ih(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=st(t.file??{}))}async function gc(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 Kt(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function Ve(e){return e instanceof Error?e.message:String(e)}function Ui(){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=Ve(n)}finally{e.skillsLoading=!1}}}function mc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function yc(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),Kt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=Ve(i);e.skillsError=s,Kt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function vc(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),Kt(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=Ve(n);e.skillsError=i,Kt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function bc(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),Kt(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=Ve(s);e.skillsError=o,Kt(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=Ve(n)}}function kc(e){e.skillDetail=null,e.skillDetailTab=""}function Sc(e,t){e.skillDetailTab=t}async function $c(e){if(e.skillAddModal=!0,e.skillAddForm=Ui(),e.skillDrafts=[],!(!e.client||!e.connected))try{const t=await e.client.request("skills.drafts",{});t&&(e.skillDrafts=t.drafts)}catch{}}function Ac(e){e.skillAddModal=!1,e.skillAddForm=Ui(),e.skillDrafts=[]}function xc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))}}async function Ec(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(i=>i.name.trim()&&i.content.trim()).map(i=>({name:i.name.trim(),content:i.content}));await e.client.request("skills.create",{name:t.name.trim(),skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=Ui(),e.skillDrafts=[],await je(e)}catch(n){e.skillsError=Ve(n)}finally{e.skillsBusyKey=null}}}async function Cc(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=Ve(n)}}async function Tc(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.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=Ve(n)}}async function _c(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=Ve(n)}finally{e.skillsBusyKey=null}}}const Rh=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:Ac,closeSkillDetail:kc,deleteDraft:Cc,deleteSkill:_c,editSkill:Tc,emptyAddForm:Ui,importDraft:xc,installSkill:bc,loadSkills:je,openAddSkillModal:$c,saveNewSkill:Ec,saveSkillApiKey:vc,setSkillDetailTab:Sc,updateSkillEdit:mc,updateSkillEnabled:yc,viewSkillDetail:wc},Symbol.toStringTag,{value:"Module"})),Mc={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},Pc=new Map(Object.entries(Mc).map(([e,t])=>[t,e]));function Wi(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function _n(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 Dh(e,t=""){const n=Wi(t),i=Mc[e];return n?`${n}${i}`:i}function Lc(e,t=""){const n=Wi(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=_n(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":Pc.get(s)??null}function Bh(e){let t=_n(e);if(t.endsWith("/index.html")&&(t=_n(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(Pc.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function Nh(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Mo(e){return e==="system"?Nh():e}const Qn=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,Oh=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Yn=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},Fh=({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,r=s,a=Oh();if(!!r.startViewTransition&&!a){let l=.5,p=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")l=Qn(n.pointerClientX/window.innerWidth),p=Qn(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const f=n.element.getBoundingClientRect();f.width>0&&f.height>0&&typeof window<"u"&&(l=Qn((f.left+f.width/2)/window.innerWidth),p=Qn((f.top+f.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${l*100}%`),o.style.setProperty("--theme-switch-y",`${p*100}%`),o.classList.add("theme-transition");try{const f=(c=r.startViewTransition)==null?void 0:c.call(r,()=>{t()});f!=null&&f.finished?f.finished.finally(()=>Yn(o)):Yn(o)}catch{Yn(o),t()}return}t(),Yn(o)},Uh=2e3;async function kn(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:[],r=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=r?o:[...e.sessionLogsEntries,...o].slice(-Uh),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 Ic=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:kn},Symbol.toStringTag,{value:"Module"}));async function Rc(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 Wh(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function Ne(e){return e instanceof Error?e.message:String(e)}let Xn=null;function Gt(e,t){Xn&&clearTimeout(Xn),e.filesMessage={kind:"success",text:t},Xn=setTimeout(()=>{e.filesMessage=null,Xn=null},3e3)}async function Qt(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=Ne(n)}finally{e.filesLoading=!1}}}}async function Kh(e,t,n){e.filesSelectedPaths=new Set([t]),await Dc(e,t,n)}async function zh(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 Dc(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function qh(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 Bc(e,o,t),i++}catch(r){s=Ne(r)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:Gt(e,`${i} file${i!==1?"s":""} downloaded`)}async function Hh(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await Qh(e,t,o,i)}async function Dc(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=Ne(i)}finally{e.filesPreviewLoading=!1}}}async function Bc(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)),r=new Blob([o]),a=URL.createObjectURL(r),u=document.createElement("a");u.href=a,u.download=s.name??t.split("/").pop()??"download",document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(a)}catch(i){e.filesMessage={kind:"error",text:Ne(i)}}}async function jh(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const r of n)try{const a=await r.arrayBuffer(),u=btoa(new Uint8Array(a).reduce((l,p)=>l+String.fromCharCode(p),"")),c={path:t,name:r.name,data:u};i&&(c.agentId=i),await e.client.request("files.upload",c),s++}catch(a){o=Ne(a)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:Gt(e,`${s} file${s!==1?"s":""} uploaded`),await Qt(e,i)}async function Vh(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),Gt(e,`Created ${s}`),await Qt(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:Ne(o)}}}async function Gh(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),Gt(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await Qt(e,n)}catch(i){e.filesMessage={kind:"error",text:Ne(i)}}}}async function Qh(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),Gt(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await Qt(e,i)}catch(s){e.filesMessage={kind:"error",text:Ne(s)}}}}async function Po(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 Yh(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;Gt(e,`Re-indexed: ${s} files, ${o} chunks`),await Po(e,t)}catch(n){e.filesMessage={kind:"error",text:Ne(n)}}finally{e.filesReindexBusy=!1}}}function Xh(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 Jh(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:Ne(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Zh(e){e.filesSearchQuery="",e.filesSearchResults=null}function ef(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{_o(e,{quiet:!0})},5e3))}function tf(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Lo(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Ft(e,{quiet:!0})},2e3))}function Io(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Ro(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||kn(e,{quiet:!0})},2e3))}function Do(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function Bo(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&So(e)},3e3))}function No(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function nf(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{Rc(e)},3e4))}function sf(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function of(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{if(e.tab!=="files")return;const t=e;Po(t,t.filesResolvedAgentId)},3e3))}function rf(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function tt(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,ip(n),t.theme!==e.theme&&(e.theme=t.theme,Ki(e,Mo(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function Nc(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&tt(e,{...e.settings,lastActiveSessionKey:n})}function af(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 r=!1;if(n!=null){const u=n.trim();u&&u!==e.settings.token&&tt(e,{...e.settings,token:u}),t.delete("token"),r=!0}if(i!=null){const u=i.trim();u&&(e.password=u),t.delete("password"),r=!0}if(s!=null){const u=s.trim();u&&(e.sessionKey=u,tt(e,{...e.settings,sessionKey:u,lastActiveSessionKey:u}))}if(o!=null){const u=o.trim();u&&u!==e.settings.gatewayUrl&&tt(e,{...e.settings,gatewayUrl:u}),t.delete("gatewayUrl"),r=!0}if(!r)return;const a=new URL(window.location.href);a.search=t.toString(),window.history.replaceState({},"",a.toString())}function lf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?Ro(e):Lo(e):(Io(e),Do(e)),t==="debug"?Bo(e):No(e),ki(e),Fc(e,t,!1)}function cf(e,t,n){Fh({nextTheme:t,applyTheme:()=>{e.theme=t,tt(e,{...e.settings,theme:t}),Ki(e,Mo(t))},context:n,currentTheme:e.theme})}async function ki(e){if(e.tab==="overview"&&await Uc(e),e.tab==="channels"&&await mf(e),e.tab==="instances"&&await gc(e),e.tab==="cron"&&await Oo(e),e.tab==="skills"&&await je(e),e.tab==="nodes"&&(await _o(e),await To(e),await Be(e),await Lh(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await kf(e),jt(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await Hl(e),await Be(e)),e.tab==="debug"&&(await So(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await oe(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>Ic);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Ft(e,{reset:!0});zl(e,!0)}}function uf(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?Wi(e):Bh(window.location.pathname)}function df(e){e.theme=e.settings.theme??"system",Ki(e,Mo(e.theme))}function Ki(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function pf(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"&&Ki(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function hf(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 ff(e,t){if(typeof window>"u")return;const n=Lc(window.location.pathname,e.basePath)??"chat";Oc(e,n),Fc(e,n,t)}function gf(e){var s;if(typeof window>"u")return;const t=Lc(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,tt(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),Oc(e,t)}function Oc(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?Ro(e):Lo(e):(Io(e),Do(e)),t==="debug"?Bo(e):No(e),e.connected&&ki(e)}function Fc(e,t,n){if(typeof window>"u")return;const i=_n(Dh(t,e.basePath)),s=_n(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 Uc(e){await Promise.all([Y(e,!1),gc(e),bo(e),Vt(e),So(e)])}async function mf(e){await Promise.all([Y(e,!0),Hl(e),Be(e)])}async function Oo(e){await Promise.all([Y(e,!1),Vt(e),Mn(e)])}function Wc(e){return e.chatSending||!!e.chatRunId}function yf(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 Kc(e){e.connected&&(e.chatMessage="",await Wl(e))}function vf(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:Oi(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],jt(e))}async function zc(e,t,n){var s,o;wo(e);const i=await Ul(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&&Nc(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),jt(e),i&&!e.chatRunId&&qc(e),i}async function qc(e){if(!e.connected||Wc(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await zc(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function bf(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function wf(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],r=t==null?o:[],a=r.length>0;if(!(!s&&!a)){if(yf(s)){await Kc(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),Wc(e)){vf(e,s,r);return}await zc(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:a?r:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function kf(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,De);await Promise.all([Re(t,{limit:n}),bo(t),Qs(e)]),jt(e,!0)}const Sf=qc;function $f(e){var s,o,r;const t=Pl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((r=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:r.trim())||"main"}function Af(e,t){const n=Wi(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Qs(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=$f(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Af(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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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>`,menu:d`<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:d`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:d`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:d`<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:d`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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>`,image:d`<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:d`<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:d`<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:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:d`<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:d`<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:d`<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:d`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:d`<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:d`<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:d`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:d`<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:d`<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:d`<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:d`<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:d`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:d`<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:d`<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:d`<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:d`<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>`},xf=d`<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>`,Ef=d`<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>`;let Yr=!1;function Cf(){Yr||(Yr=!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 xt(e,t){var l;const n=(p,f)=>p===e?d`<span class="sp-page-nav-current">${p}</span>`:d`<a href=${f}>${p}</a>`,i=d`
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 Wp(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 it(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function bt(e){return`${JSON.stringify(e,null,2).trimEnd()}
20
+ `}function Hl(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const r=t[o],a=t[o+1];if(typeof r=="number"){if(!Array.isArray(i))return;i[r]==null&&(i[r]=typeof a=="number"?[]:{}),i=i[r]}else{if(typeof i!="object"||i==null)return;const u=i;u[r]==null&&(u[r]=typeof a=="number"?[]:{}),i=u[r]}}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 Be(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});zp(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function jl(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});Kp(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function Kp(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function zp(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?bt(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=bt(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=it(t.config??{}),e.configFormOriginal=it(t.config??{}),e.configRawOriginal=n)}async function qp(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?bt(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 Be(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function Vt(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 Mn(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);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 Vl(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=yi(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 Gl(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 r=o.trim();r&&i.push(r)}i.length>0&&(n.to=i.join(","));const s=yi(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function Hp(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=Vl(e.cronForm),i=Gl(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),r={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(!r.name)throw new Error("Name required.");await e.client.request("cron.add",r),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await Mn(e),await Vt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function jp(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 Mn(e),await Vt(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function Vp(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await Hs(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Gp(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 Mn(e),await Vt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function Qp(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(r=>r.trim()).filter(Boolean);t.toAdmins=o.some(r=>r.toLowerCase()==="admins"),t.recipients=o.filter(r=>r.toLowerCase()!=="admins")}}return(n=e.isolation)!=null&&n.postToMainPrefix&&(t.postToMainPrefix=e.isolation.postToMainPrefix),t}async function Yp(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=Vl(e.cronForm),i=Gl(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 Mn(e),await Vt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Hs(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 Y(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 So(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 Ql(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 Yl(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 Xl(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=it(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const r=o.channels;(!r.whatsapp||typeof r.whatsapp!="object")&&(r.whatsapp={});const a=r.whatsapp;(!a.accounts||typeof a.accounts!="object")&&(a.accounts={});const u=a.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 l=bt(o);await e.client.request("config.set",{raw:l,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await Y(e,!0),await So(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function Jl(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=it(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,r=o==null?void 0:o.accounts;if(!r){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(r).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!r[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete r[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(l=>{const p=l.match;return!p||p.channel!=="whatsapp"?!0:p.accountId!==t}));const u=n.hash;if(!u){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=bt(i);await e.client.request("config.set",{raw:c,baseHash:u}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await Y(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Xp=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:Xl,loadChannels:Y,logoutWhatsApp:Yl,removeWhatsAppAccount:Jl,startWhatsAppLogin:So,waitWhatsAppLogin:Ql},Symbol.toStringTag,{value:"Module"}));async function $o(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 Jp=2e3,Zp=new Set(["trace","debug","info","warn","error","fatal"]);function eh(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 th(e){if(typeof e!="string")return null;const t=e.toLowerCase();return Zp.has(t)?t:null}function Zl(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=th((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,r=eh(o);let a=null;r&&(typeof r.subsystem=="string"?a=r.subsystem:typeof r.module=="string"&&(a=r.module)),!a&&o&&o.length<120&&(a=o);let u=null;return typeof t[1]=="string"?u=t[1]:!r&&typeof t[0]=="string"?u=t[0]:typeof t.message=="string"&&(u=t.message),{raw:e,time:i,level:s,subsystem:a,message:u??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Ft(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}),o=(Array.isArray(i.lines)?i.lines.filter(a=>typeof a=="string"):[]).map(Zl),r=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=r?o:[...e.logsEntries,...o].slice(-Jp),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 nh=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Ft,parseLogLine:Zl},Symbol.toStringTag,{value:"Module"}));const ec={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:le,n:li,Gx:Hr,Gy:jr,a:gs,d:ms,h:ih}=ec,wt=32,Ao=64,sh=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},ie=(e="")=>{const t=new Error(e);throw sh(t,ie),t},oh=e=>typeof e=="bigint",rh=e=>typeof e=="string",ah=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",st=(e,t,n="")=>{const i=ah(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const r=n&&`"${n}" `,a=o?` of length ${t}`:"",u=i?`length=${s}`:`type=${typeof e}`;ie(r+"expected Uint8Array"+a+", got "+u)}return e},Ui=e=>new Uint8Array(e),tc=e=>Uint8Array.from(e),nc=(e,t)=>e.toString(16).padStart(t,"0"),ic=e=>Array.from(st(e)).map(t=>nc(t,2)).join(""),We={_0:48,_9:57,A:65,F:70,a:97,f:102},Vr=e=>{if(e>=We._0&&e<=We._9)return e-We._0;if(e>=We.A&&e<=We.F)return e-(We.A-10);if(e>=We.a&&e<=We.f)return e-(We.a-10)},sc=e=>{const t="hex invalid";if(!rh(e))return ie(t);const n=e.length,i=n/2;if(n%2)return ie(t);const s=Ui(i);for(let o=0,r=0;o<i;o++,r+=2){const a=Vr(e.charCodeAt(r)),u=Vr(e.charCodeAt(r+1));if(a===void 0||u===void 0)return ie(t);s[o]=a*16+u}return s},oc=()=>globalThis==null?void 0:globalThis.crypto,lh=()=>{var e;return((e=oc())==null?void 0:e.subtle)??ie("crypto.subtle must be defined, consider polyfill")},Tn=(...e)=>{const t=Ui(e.reduce((i,s)=>i+st(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},ch=(e=wt)=>oc().getRandomValues(Ui(e)),bi=BigInt,dt=(e,t,n,i="bad number: out of range")=>oh(e)&&t<=e&&e<n?e:ie(i),P=(e,t=le)=>{const n=e%t;return n>=0n?n:t+n},rc=e=>P(e,li),uh=(e,t)=>{(e===0n||t<=0n)&&ie("no inverse n="+e+" mod="+t);let n=P(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const r=i/n,a=i%n,u=s-o*r;i=n,n=a,s=o,o=u}return i===1n?P(s,t):ie("no inverse")},dh=e=>{const t=uc[e];return typeof t!="function"&&ie("hashes."+e+" not set"),t},ys=e=>e instanceof kt?e:ie("Point expected"),js=2n**256n,Ie=class Ie{constructor(t,n,i,s){W(this,"X");W(this,"Y");W(this,"Z");W(this,"T");const o=js;this.X=dt(t,0n,o),this.Y=dt(n,0n,o),this.Z=dt(i,1n,o),this.T=dt(s,0n,o),Object.freeze(this)}static CURVE(){return ec}static fromAffine(t){return new Ie(t.x,t.y,1n,P(t.x*t.y))}static fromBytes(t,n=!1){const i=ms,s=tc(st(t,wt)),o=t[31];s[31]=o&-129;const r=lc(s);dt(r,0n,n?js:le);const u=P(r*r),c=P(u-1n),l=P(i*u+1n);let{isValid:p,value:f}=hh(c,l);p||ie("bad point: y not sqrt");const b=(f&1n)===1n,h=(o&128)!==0;return!n&&f===0n&&h&&ie("bad point: x==0, isLastByteOdd"),h!==b&&(f=P(-f)),new Ie(f,r,1n,P(f*r))}static fromHex(t,n){return Ie.fromBytes(sc(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=gs,n=ms,i=this;if(i.is0())return ie("bad point: ZERO");const{X:s,Y:o,Z:r,T:a}=i,u=P(s*s),c=P(o*o),l=P(r*r),p=P(l*l),f=P(u*t),b=P(l*P(f+c)),h=P(p+P(n*P(u*c)));if(b!==h)return ie("bad point: equation left != right (1)");const v=P(s*o),S=P(r*a);return v!==S?ie("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:r,Z:a}=ys(t),u=P(n*a),c=P(o*s),l=P(i*a),p=P(r*s);return u===c&&l===p}is0(){return this.equals(Nt)}negate(){return new Ie(P(-this.X),this.Y,this.Z,P(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=gs,o=P(t*t),r=P(n*n),a=P(2n*P(i*i)),u=P(s*o),c=t+n,l=P(P(c*c)-o-r),p=u+r,f=p-a,b=u-r,h=P(l*f),v=P(p*b),S=P(l*b),$=P(f*p);return new Ie(h,v,$,S)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:r,Y:a,Z:u,T:c}=ys(t),l=gs,p=ms,f=P(n*r),b=P(i*a),h=P(o*p*c),v=P(s*u),S=P((n+i)*(r+a)-f-b),$=P(v-h),A=P(v+h),E=P(b-l*f),T=P(S*$),_=P(A*E),D=P(S*E),F=P($*A);return new Ie(T,_,F,D)}subtract(t){return this.add(ys(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Nt;if(dt(t,1n,li),t===1n)return this;if(this.equals(St))return Ah(t).p;let i=Nt,s=St;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(Nt))return{x:0n,y:1n};const s=uh(i,le);P(i*s)!==1n&&ie("invalid inverse");const o=P(t*s),r=P(n*s);return{x:o,y:r}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=ac(n);return i[31]|=t&1n?128:0,i}toHex(){return ic(this.toBytes())}clearCofactor(){return this.multiply(bi(ih),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(li/2n,!1).double();return li%2n&&(t=t.add(this)),t.is0()}};W(Ie,"BASE"),W(Ie,"ZERO");let kt=Ie;const St=new kt(Hr,jr,1n,P(Hr*jr)),Nt=new kt(0n,1n,1n,0n);kt.BASE=St;kt.ZERO=Nt;const ac=e=>sc(nc(dt(e,0n,js),Ao)).reverse(),lc=e=>bi("0x"+ic(tc(st(e)).reverse())),Te=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=le;return n},ph=e=>{const n=e*e%le*e%le,i=Te(n,2n)*n%le,s=Te(i,1n)*e%le,o=Te(s,5n)*s%le,r=Te(o,10n)*o%le,a=Te(r,20n)*r%le,u=Te(a,40n)*a%le,c=Te(u,80n)*u%le,l=Te(c,80n)*u%le,p=Te(l,10n)*o%le;return{pow_p_5_8:Te(p,2n)*e%le,b2:n}},Gr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,hh=(e,t)=>{const n=P(t*t*t),i=P(n*n*t),s=ph(e*i).pow_p_5_8;let o=P(e*n*s);const r=P(t*o*o),a=o,u=P(o*Gr),c=r===e,l=r===P(-e),p=r===P(-e*Gr);return c&&(o=a),(l||p)&&(o=u),(P(o)&1n)===1n&&(o=P(-o)),{isValid:c||l,value:o}},Vs=e=>rc(lc(e)),xo=(...e)=>uc.sha512Async(Tn(...e)),fh=(...e)=>dh("sha512")(Tn(...e)),cc=e=>{const t=e.slice(0,wt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(wt,Ao),i=Vs(t),s=St.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},Eo=e=>xo(st(e,wt)).then(cc),gh=e=>cc(fh(st(e,wt))),mh=e=>Eo(e).then(t=>t.pointBytes),yh=e=>xo(e.hashable).then(e.finish),vh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=Vs(t),r=St.multiply(o).toBytes();return{hashable:Tn(r,i,n),finish:c=>{const l=rc(o+Vs(c)*s);return st(Tn(r,ac(l)),Ao)}}},bh=async(e,t)=>{const n=st(e),i=await Eo(t),s=await xo(i.prefix,n);return yh(vh(i,s,n))},uc={sha512Async:async e=>{const t=lh(),n=Tn(e);return Ui(await t.digest("SHA-512",n.buffer))},sha512:void 0},wh=(e=ch(wt))=>e,kh={getExtendedPublicKeyAsync:Eo,getExtendedPublicKey:gh,randomSecretKey:wh},wi=8,Sh=256,dc=Math.ceil(Sh/wi)+1,Gs=2**(wi-1),$h=()=>{const e=[];let t=St,n=t;for(let i=0;i<dc;i++){n=t,e.push(n);for(let s=1;s<Gs;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Qr;const Yr=(e,t)=>{const n=t.negate();return e?n:t},Ah=e=>{const t=Qr||(Qr=$h());let n=Nt,i=St;const s=2**wi,o=s,r=bi(s-1),a=bi(wi);for(let u=0;u<dc;u++){let c=Number(e&r);e>>=a,c>Gs&&(c-=o,e+=1n);const l=u*Gs,p=l,f=l+Math.abs(c)-1,b=u%2!==0,h=c<0;c===0?i=i.add(Yr(b,t[p])):n=n.add(Yr(h,t[f]))}return e!==0n&&ie("invalid wnaf"),{p:n,f:i}},vs="taskmaster-device-identity-v1";function Qs(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function pc(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 xh(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function hc(e){const t=await crypto.subtle.digest("SHA-256",e);return xh(new Uint8Array(t))}async function Eh(){const e=kh.randomSecretKey(),t=await mh(e);return{deviceId:await hc(t),publicKey:Qs(t),privateKey:Qs(e)}}async function Ch(){try{const n=localStorage.getItem(vs);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 hc(pc(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(vs,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 Eh(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(vs,JSON.stringify(t)),e}async function Th(e,t){const n=pc(e),i=new TextEncoder().encode(t),s=await bh(i,n);return Qs(s)}const fc="taskmaster.device.auth.v1";function Co(e){return e.trim()}function _h(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 To(){try{const e=window.localStorage.getItem(fc);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 gc(e){try{window.localStorage.setItem(fc,JSON.stringify(e))}catch{}}function Mh(e){const t=To();if(!t||t.deviceId!==e.deviceId)return null;const n=Co(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function Ph(e){const t=Co(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=To();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:_h(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,gc(n),s}function Lh(e){const t=To();if(!t||t.deviceId!==e.deviceId)return;const n=Co(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],gc(i)}async function _o(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 Mo(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 Ih(e){return{method:"exec.approvals.get",params:{}}}async function Rh(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Ih(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);Dh(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Dh(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=it(t.file??{}))}async function mc(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 Kt(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function Ve(e){return e instanceof Error?e.message:String(e)}function Wi(){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=Ve(n)}finally{e.skillsLoading=!1}}}function yc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function vc(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),Kt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=Ve(i);e.skillsError=s,Kt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function bc(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),Kt(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=Ve(n);e.skillsError=i,Kt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function wc(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),Kt(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=Ve(s);e.skillsError=o,Kt(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}async function kc(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=Ve(n)}}function Sc(e){e.skillDetail=null,e.skillDetailTab=""}function $c(e,t){e.skillDetailTab=t}async function Ac(e){if(e.skillAddModal=!0,e.skillAddForm=Wi(),e.skillDrafts=[],!(!e.client||!e.connected))try{const t=await e.client.request("skills.drafts",{});t&&(e.skillDrafts=t.drafts)}catch{}}function xc(e){e.skillAddModal=!1,e.skillAddForm=Wi(),e.skillDrafts=[]}function Ec(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))}}async function Cc(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(i=>i.name.trim()&&i.content.trim()).map(i=>({name:i.name.trim(),content:i.content}));await e.client.request("skills.create",{name:t.name.trim(),skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=Wi(),e.skillDrafts=[],await je(e)}catch(n){e.skillsError=Ve(n)}finally{e.skillsBusyKey=null}}}async function Tc(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=Ve(n)}}async function _c(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.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=Ve(n)}}async function Mc(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=Ve(n)}finally{e.skillsBusyKey=null}}}const Bh=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:xc,closeSkillDetail:Sc,deleteDraft:Tc,deleteSkill:Mc,editSkill:_c,emptyAddForm:Wi,importDraft:Ec,installSkill:wc,loadSkills:je,openAddSkillModal:Ac,saveNewSkill:Cc,saveSkillApiKey:bc,setSkillDetailTab:$c,updateSkillEdit:yc,updateSkillEnabled:vc,viewSkillDetail:kc},Symbol.toStringTag,{value:"Module"})),Pc={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},Lc=new Map(Object.entries(Pc).map(([e,t])=>[t,e]));function Ki(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function _n(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 Nh(e,t=""){const n=Ki(t),i=Pc[e];return n?`${n}${i}`:i}function Ic(e,t=""){const n=Ki(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=_n(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":Lc.get(s)??null}function Oh(e){let t=_n(e);if(t.endsWith("/index.html")&&(t=_n(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(Lc.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function Fh(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Po(e){return e==="system"?Fh():e}const Qn=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,Uh=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Yn=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},Wh=({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,r=s,a=Uh();if(!!r.startViewTransition&&!a){let l=.5,p=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")l=Qn(n.pointerClientX/window.innerWidth),p=Qn(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const f=n.element.getBoundingClientRect();f.width>0&&f.height>0&&typeof window<"u"&&(l=Qn((f.left+f.width/2)/window.innerWidth),p=Qn((f.top+f.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${l*100}%`),o.style.setProperty("--theme-switch-y",`${p*100}%`),o.classList.add("theme-transition");try{const f=(c=r.startViewTransition)==null?void 0:c.call(r,()=>{t()});f!=null&&f.finished?f.finished.finally(()=>Yn(o)):Yn(o)}catch{Yn(o),t()}return}t(),Yn(o)},Kh=2e3;async function kn(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:[],r=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=r?o:[...e.sessionLogsEntries,...o].slice(-Kh),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 Rc=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:kn},Symbol.toStringTag,{value:"Module"}));async function Dc(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 zh(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function Ne(e){return e instanceof Error?e.message:String(e)}let Xn=null;function Gt(e,t){Xn&&clearTimeout(Xn),e.filesMessage={kind:"success",text:t},Xn=setTimeout(()=>{e.filesMessage=null,Xn=null},3e3)}async function Qt(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=Ne(n)}finally{e.filesLoading=!1}}}}async function qh(e,t,n){e.filesSelectedPaths=new Set([t]),await Bc(e,t,n)}async function Hh(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 Bc(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function jh(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 Nc(e,o,t),i++}catch(r){s=Ne(r)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:Gt(e,`${i} file${i!==1?"s":""} downloaded`)}async function Vh(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await Xh(e,t,o,i)}async function Bc(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=Ne(i)}finally{e.filesPreviewLoading=!1}}}async function Nc(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)),r=new Blob([o]),a=URL.createObjectURL(r),u=document.createElement("a");u.href=a,u.download=s.name??t.split("/").pop()??"download",document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(a)}catch(i){e.filesMessage={kind:"error",text:Ne(i)}}}async function Gh(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const r of n)try{const a=await r.arrayBuffer(),u=btoa(new Uint8Array(a).reduce((l,p)=>l+String.fromCharCode(p),"")),c={path:t,name:r.name,data:u};i&&(c.agentId=i),await e.client.request("files.upload",c),s++}catch(a){o=Ne(a)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:Gt(e,`${s} file${s!==1?"s":""} uploaded`),await Qt(e,i)}async function Qh(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),Gt(e,`Created ${s}`),await Qt(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:Ne(o)}}}async function Yh(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),Gt(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await Qt(e,n)}catch(i){e.filesMessage={kind:"error",text:Ne(i)}}}}async function Xh(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),Gt(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await Qt(e,i)}catch(s){e.filesMessage={kind:"error",text:Ne(s)}}}}async function Lo(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 Jh(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;Gt(e,`Re-indexed: ${s} files, ${o} chunks`),await Lo(e,t)}catch(n){e.filesMessage={kind:"error",text:Ne(n)}}finally{e.filesReindexBusy=!1}}}function Zh(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 ef(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:Ne(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function tf(e){e.filesSearchQuery="",e.filesSearchResults=null}function nf(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{Mo(e,{quiet:!0})},5e3))}function sf(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Io(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Ft(e,{quiet:!0})},2e3))}function Ro(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Do(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||kn(e,{quiet:!0})},2e3))}function Bo(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function No(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&$o(e)},3e3))}function Oo(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function of(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{Dc(e)},3e4))}function rf(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function af(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{if(e.tab!=="files")return;const t=e;Lo(t,t.filesResolvedAgentId)},3e3))}function lf(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function tt(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,op(n),t.theme!==e.theme&&(e.theme=t.theme,zi(e,Po(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function Oc(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&tt(e,{...e.settings,lastActiveSessionKey:n})}function cf(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 r=!1;if(n!=null){const u=n.trim();u&&u!==e.settings.token&&tt(e,{...e.settings,token:u}),t.delete("token"),r=!0}if(i!=null){const u=i.trim();u&&(e.password=u),t.delete("password"),r=!0}if(s!=null){const u=s.trim();u&&(e.sessionKey=u,tt(e,{...e.settings,sessionKey:u,lastActiveSessionKey:u}))}if(o!=null){const u=o.trim();u&&u!==e.settings.gatewayUrl&&tt(e,{...e.settings,gatewayUrl:u}),t.delete("gatewayUrl"),r=!0}if(!r)return;const a=new URL(window.location.href);a.search=t.toString(),window.history.replaceState({},"",a.toString())}function uf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?Do(e):Io(e):(Ro(e),Bo(e)),t==="debug"?No(e):Oo(e),ki(e),Uc(e,t,!1)}function df(e,t,n){Wh({nextTheme:t,applyTheme:()=>{e.theme=t,tt(e,{...e.settings,theme:t}),zi(e,Po(t))},context:n,currentTheme:e.theme})}async function ki(e){if(e.tab==="overview"&&await Wc(e),e.tab==="channels"&&await vf(e),e.tab==="instances"&&await mc(e),e.tab==="cron"&&await Fo(e),e.tab==="skills"&&await je(e),e.tab==="nodes"&&(await Mo(e),await _o(e),await Be(e),await Rh(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await $f(e),jt(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await jl(e),await Be(e)),e.tab==="debug"&&(await $o(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await oe(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>Rc);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Ft(e,{reset:!0});ql(e,!0)}}function pf(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?Ki(e):Oh(window.location.pathname)}function hf(e){e.theme=e.settings.theme??"system",zi(e,Po(e.theme))}function zi(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function ff(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"&&zi(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function gf(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 mf(e,t){if(typeof window>"u")return;const n=Ic(window.location.pathname,e.basePath)??"chat";Fc(e,n),Uc(e,n,t)}function yf(e){var s;if(typeof window>"u")return;const t=Ic(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,tt(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),Fc(e,t)}function Fc(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?Do(e):Io(e):(Ro(e),Bo(e)),t==="debug"?No(e):Oo(e),e.connected&&ki(e)}function Uc(e,t,n){if(typeof window>"u")return;const i=_n(Nh(t,e.basePath)),s=_n(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 Wc(e){await Promise.all([Y(e,!1),mc(e),wo(e),Vt(e),$o(e)])}async function vf(e){await Promise.all([Y(e,!0),jl(e),Be(e)])}async function Fo(e){await Promise.all([Y(e,!1),Vt(e),Mn(e)])}function Kc(e){return e.chatSending||!!e.chatRunId}function bf(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 zc(e){e.connected&&(e.chatMessage="",await Kl(e))}function wf(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:Fi(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],jt(e))}async function qc(e,t,n){var s,o;ko(e);const i=await Wl(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&&Oc(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),jt(e),i&&!e.chatRunId&&Hc(e),i}async function Hc(e){if(!e.connected||Kc(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await qc(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function kf(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Sf(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],r=t==null?o:[],a=r.length>0;if(!(!s&&!a)){if(bf(s)){await zc(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),Kc(e)){wf(e,s,r);return}await qc(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:a?r:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function $f(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,De);await Promise.all([Re(t,{limit:n}),wo(t),Ys(e)]),jt(e,!0)}const Af=Hc;function xf(e){var s,o,r;const t=Ll(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((r=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:r.trim())||"main"}function Ef(e,t){const n=Ki(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Ys(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=xf(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Ef(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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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>`,menu:d`<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:d`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:d`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:d`<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:d`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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:d`<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>`,image:d`<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:d`<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:d`<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:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:d`<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:d`<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:d`<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:d`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:d`<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:d`<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:d`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:d`<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:d`<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:d`<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:d`<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:d`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:d`<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:d`<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:d`<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:d`<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>`},Cf=d`<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>`,Tf=d`<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>`;let Xr=!1;function _f(){Xr||(Xr=!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 Et(e,t){var l;const n=(p,f)=>p===e?d`<span class="sp-page-nav-current">${p}</span>`:d`<a href=${f}>${p}</a>`,i=d`
21
21
  ${n("Setup","/setup")}
22
22
  ${n("Chat","/chat")}
23
23
  ${n("Admins","/admins")}
@@ -25,10 +25,10 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
25
25
  ${n("Files","/files")}
26
26
  ${n("Browser","/browser")}
27
27
  ${n("Advanced","/advanced")}
28
- `,o=t&&(t.isMaster!==!1||!t.hasPins)?Tf(t):k,r=t!=null&&t.hasPins&&t.onLogout?d`<button class="nav-logout-btn" @click=${t.onLogout} title="Lock">${xf}</button>`:k,a=(t==null?void 0:t.auditCount)??0,u=a>0&&(t!=null&&t.onAuditClick)?d`<button class="nav-audit-btn" @click=${t.onAuditClick} title="Memory writes to review">
29
- ${Ef}
28
+ `,o=t&&(t.isMaster!==!1||!t.hasPins)?Mf(t):k,r=t!=null&&t.hasPins&&t.onLogout?d`<button class="nav-logout-btn" @click=${t.onLogout} title="Lock">${Cf}</button>`:k,a=(t==null?void 0:t.auditCount)??0,u=a>0&&(t!=null&&t.onAuditClick)?d`<button class="nav-audit-btn" @click=${t.onAuditClick} title="Memory writes to review">
29
+ ${Tf}
30
30
  <span class="nav-audit-badge">${a>99?"99+":a}</span>
31
- </button>`:k,c=()=>{const p=document.getElementById("nav-burger-toggle");p&&(p.checked=!1)};return Cf(),d`
31
+ </button>`:k,c=()=>{const p=document.getElementById("nav-burger-toggle");p&&(p.checked=!1)};return _f(),d`
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">
@@ -50,7 +50,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
50
50
  ${i}
51
51
  </nav>
52
52
  </div>
53
- `}function Tf(e){const{workspaces:t,selectedWorkspace:n,onWorkspaceSelect:i}=e;return d`
53
+ `}function Mf(e){const{workspaces:t,selectedWorkspace:n,onWorkspaceSelect:i}=e;return d`
54
54
  <select
55
55
  class="sp-workspace-selector"
56
56
  .value=${n??""}
@@ -64,7 +64,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
64
64
  <option disabled>───</option>
65
65
  <option value="__add__">+ Add Account</option>
66
66
  </select>
67
- `}function _f(e){return e.connected?e.fullscreen&&e.active?d`
67
+ `}function Pf(e){return e.connected?e.fullscreen&&e.active?d`
68
68
  <div class="sp-fullscreen-overlay">
69
69
  <div class="sp-fullscreen-toolbar">
70
70
  <button
@@ -106,7 +106,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
106
106
  </div>
107
107
  `:d`
108
108
  <div class="setup-container">
109
- ${xt("Browser")}
109
+ ${Et("Browser")}
110
110
  <div class="setup-card sp-card-wide">
111
111
  <h1>Remote Browser</h1>
112
112
  <p style="margin-bottom: 16px;">Live view of the headless Chrome instance.</p>
@@ -196,14 +196,14 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
196
196
  <p>Connecting to gateway...</p>
197
197
  </div>
198
198
  </div>
199
- `}const Si="application/x-taskmaster-file-path";let ut=null;function Hc(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function jc(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function Mf(e,t,n){var o,r;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const i=(o=e.dataTransfer)==null?void 0:o.getData(Si);if(i){jc(i)!==t&&n.onMoveToDir(i,t);return}const s=(r=e.dataTransfer)==null?void 0:r.files;if(s&&s.length>0){const a=Array.from(s).filter(u=>u.name.toLowerCase().endsWith(".md"));a.length>0&&n.onUpload(t,a)}}function Vc(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),r=t.currentDir===e.path,a=n*20+12;return i?d`
199
+ `}const Si="application/x-taskmaster-file-path";let ct=null;function jc(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Vc(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function Lf(e,t,n){var o,r;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const i=(o=e.dataTransfer)==null?void 0:o.getData(Si);if(i){Vc(i)!==t&&n.onMoveToDir(i,t);return}const s=(r=e.dataTransfer)==null?void 0:r.files;if(s&&s.length>0){const a=Array.from(s).filter(u=>u.name.toLowerCase().endsWith(".md"));a.length>0&&n.onUpload(t,a)}}function Gc(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),r=t.currentDir===e.path,a=n*20+12;return i?d`
200
200
  <div
201
201
  class="sp-tree-item sp-tree-dir ${s?"expanded":""} ${r?"current":""}"
202
202
  style="padding-left: ${a}px;"
203
203
  @click=${()=>t.onToggleDir(e.path)}
204
204
  @dragover=${c=>{c.preventDefault(),c.stopPropagation(),c.dataTransfer&&(c.dataTransfer.dropEffect="move"),c.currentTarget.classList.add("sp-drop-target")}}
205
205
  @dragleave=${c=>{c.currentTarget.classList.remove("sp-drop-target")}}
206
- @drop=${c=>Mf(c,e.path,t)}
206
+ @drop=${c=>Lf(c,e.path,t)}
207
207
  >
208
208
  <span class="sp-tree-chevron">${s?"−":"+"}</span>
209
209
  <span class="sp-tree-icon">${L.folder}</span>
@@ -214,7 +214,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
214
214
  @click=${c=>{c.stopPropagation(),t.onDelete(e.path)}}
215
215
  >×</span>`:k}
216
216
  </div>
217
- ${s&&e.children?e.children.map(c=>Vc(c,t,n+1)):k}
217
+ ${s&&e.children?e.children.map(c=>Gc(c,t,n+1)):k}
218
218
  `:d`
219
219
  <div
220
220
  class="sp-tree-item sp-tree-file ${o?"selected":""}"
@@ -225,9 +225,9 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
225
225
  >
226
226
  <span class="sp-tree-icon">${L.fileText}</span>
227
227
  <span class="sp-tree-name">${e.name}</span>
228
- <span class="sp-tree-size">${Hc(e.size)}</span>
228
+ <span class="sp-tree-size">${jc(e.size)}</span>
229
229
  </div>
230
- `}function Pf(e){const t=e.selectedPaths.size;return t<2?k:d`
230
+ `}function If(e){const t=e.selectedPaths.size;return t<2?k:d`
231
231
  <div class="sp-bulk-actions">
232
232
  <span style="color: var(--tasker-muted-grey); font-size: 13px;">${t} files selected</span>
233
233
  <button
@@ -238,7 +238,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
238
238
  Download ${t} files
239
239
  </button>
240
240
  </div>
241
- `}function Lf(e){if(e.selectedPaths.size!==1||!e.selectedPath)return k;if(e.previewLoading)return d`
241
+ `}function Rf(e){if(e.selectedPaths.size!==1||!e.selectedPath)return k;if(e.previewLoading)return d`
242
242
  <div class="sp-file-preview">
243
243
  <div class="setup-spinner" style="width: 32px; height: 32px; margin: 24px auto;"></div>
244
244
  </div>
@@ -248,21 +248,21 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
248
248
  <div>
249
249
  <strong>${t}</strong>
250
250
  <div class="sp-file-preview-meta">
251
- ${e.selectedPath}${e.previewSize!=null?` — ${Hc(e.previewSize)}`:""}
251
+ ${e.selectedPath}${e.previewSize!=null?` — ${jc(e.previewSize)}`:""}
252
252
  </div>
253
253
  </div>
254
254
  <div class="sp-file-actions">
255
255
  <button class="setup-button secondary" style="padding: 8px 16px; font-size: 13px;" @click=${()=>e.onDownload(e.selectedPath)}>
256
256
  Download
257
257
  </button>
258
- <button class="setup-button danger" style="padding: 8px 16px; font-size: 13px;" @click=${()=>{e.pendingDeletePath===e.selectedPath?(ut&&clearTimeout(ut),ut=null,e.onDelete(e.selectedPath)):(e.onArmDelete(e.selectedPath),ut&&clearTimeout(ut),ut=setTimeout(()=>{e.onArmDelete(""),ut=null},3e3))}}>
258
+ <button class="setup-button danger" style="padding: 8px 16px; font-size: 13px;" @click=${()=>{e.pendingDeletePath===e.selectedPath?(ct&&clearTimeout(ct),ct=null,e.onDelete(e.selectedPath)):(e.onArmDelete(e.selectedPath),ct&&clearTimeout(ct),ct=setTimeout(()=>{e.onArmDelete(""),ct=null},3e3))}}>
259
259
  ${e.pendingDeletePath===e.selectedPath?"Confirm delete?":"Delete"}
260
260
  </button>
261
261
  </div>
262
262
  </div>
263
263
  ${e.previewBinary?d`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">Binary file — use Download to view.</p></div>`:e.previewContent!=null?d`<div class="sp-file-preview-body"><pre class="sp-file-code">${e.previewContent}</pre></div>`:d`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">File too large for preview — use Download.</p></div>`}
264
264
  </div>
265
- `}function If(e){return d`
265
+ `}function Df(e){return d`
266
266
  <div class="sp-search-bar">
267
267
  <input
268
268
  type="text"
@@ -294,7 +294,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
294
294
  Clear
295
295
  </button>`:k}
296
296
  </div>
297
- `}function Rf(e){return e.searchResults?e.searchResults.length===0?d`<div class="sp-search-results">
297
+ `}function Bf(e){return e.searchResults?e.searchResults.length===0?d`<div class="sp-search-results">
298
298
  <div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No results found.</div>
299
299
  </div>`:d`
300
300
  <div class="sp-search-results">
@@ -314,9 +314,9 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
314
314
  </div>
315
315
  `)}
316
316
  </div>
317
- `:k}function Df(e){const t=e.currentDir;return e.connected?d`
317
+ `:k}function Nf(e){const t=e.currentDir;return e.connected?d`
318
318
  <div class="setup-container">
319
- ${xt("Files",e.wsProps)}
319
+ ${Et("Files",e.wsProps)}
320
320
  <div class="setup-card sp-card-wide">
321
321
  <h1>Workspace Files</h1>
322
322
  <p style="margin-bottom: 16px;">Browse, upload, and manage files in your workspace. Drag files between folders to move them.</p>
@@ -378,18 +378,18 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
378
378
 
379
379
  ${e.uploadBusy?d`<div style="margin-top: 12px; color: var(--tasker-orange); font-weight: 600; font-size: 14px;">Uploading...</div>`:k}
380
380
 
381
- ${If(e)}
381
+ ${Df(e)}
382
382
 
383
- ${e.searchResults!==null?Rf(e):d`<div
383
+ ${e.searchResults!==null?Bf(e):d`<div
384
384
  class="sp-file-tree"
385
385
  @dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(Si)?"move":"copy")}}
386
- @drop=${n=>{var o,r;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(Si);if(i){jc(i)!=="."&&e.onMoveToDir(i,".");return}const s=(r=n.dataTransfer)==null?void 0:r.files;if(s&&s.length>0){const a=Array.from(s).filter(u=>u.name.toLowerCase().endsWith(".md"));a.length>0&&e.onUpload(t,a)}}}
386
+ @drop=${n=>{var o,r;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(Si);if(i){Vc(i)!=="."&&e.onMoveToDir(i,".");return}const s=(r=n.dataTransfer)==null?void 0:r.files;if(s&&s.length>0){const a=Array.from(s).filter(u=>u.name.toLowerCase().endsWith(".md"));a.length>0&&e.onUpload(t,a)}}}
387
387
  >
388
- ${e.tree.length===0&&!e.loading?d`<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=>Vc(n,e,0))}
388
+ ${e.tree.length===0&&!e.loading?d`<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=>Gc(n,e,0))}
389
389
  </div>`}
390
390
 
391
- ${Pf(e)}
392
- ${Lf(e)}
391
+ ${If(e)}
392
+ ${Rf(e)}
393
393
  </div>
394
394
  </div>
395
395
  `:d`
@@ -399,7 +399,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
399
399
  <p>Connecting to gateway...</p>
400
400
  </div>
401
401
  </div>
402
- `}const Fo="taskmaster_uninstall_done";async function Bf(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),Nf();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 $i(){try{return localStorage.getItem(Fo)==="1"}catch{return!1}}function Uo(){try{localStorage.removeItem(Fo)}catch{}}function Nf(){try{localStorage.setItem(Fo,"1")}catch{}}const Xr=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:$i,clearUninstallDone:Uo,runUninstall:Bf},Symbol.toStringTag,{value:"Module"}));function V(e){return d`
402
+ `}const Uo="taskmaster_uninstall_done";async function Of(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),Ff();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 $i(){try{return localStorage.getItem(Uo)==="1"}catch{return!1}}function Wo(){try{localStorage.removeItem(Uo)}catch{}}function Ff(){try{localStorage.setItem(Uo,"1")}catch{}}const Jr=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:$i,clearUninstallDone:Wo,runUninstall:Of},Symbol.toStringTag,{value:"Module"}));function V(e){return d`
403
403
  <span
404
404
  class="setup-status-light"
405
405
  style="background: ${{good:"#22c55e",bad:"#ef4444",partial:"#eab308",unknown:"#6b7280"}[e]}"
@@ -412,7 +412,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
412
412
  >
413
413
  ${L.info}
414
414
  </button>
415
- `}function Of(e){var i;if(!e.infoModalOpen)return k;let t="",n=[];switch(e.infoModalOpen){case"gateway":{const s=typeof window<"u"?window.location.host:"unknown";t="Gateway",n=[{label:"Status",value:e.gatewayHealthy===!1?"Stopped":"Running"},{label:"Address",value:s},{label:"Health",value:e.gatewayHealthMessage||"OK"}];break}case"claude":{const s=e.authExpiresIn;let o="N/A";if(s!=null&&s>0)if(s>60){const r=Math.floor(s/60),a=s%60;o=a>0?`${r}h ${a}m`:`${r}h`}else o=`${s}m`;t="Claude",n=[{label:"Connected",value:e.authConnected?"Yes":"No"},{label:"Token Expiry",value:o},{label:"Renewal",value:"Automatic (tokens refresh on expiry)"},...e.authMessage?[{label:"Message",value:e.authMessage}]:[]];break}case"license":{const s=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"Key",value:s},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A"}];break}case"whatsapp":{const s=Yt(e),o=s?Wo(s,e):null;t="WhatsApp",n=[{label:"Account",value:(o==null?void 0:o.name)||(o==null?void 0:o.accountId)||"Default"},{label:"Phone",value:((i=o==null?void 0:o.self)==null?void 0:i.e164)||"Not paired"},{label:"Connected",value:o!=null&&o.connected?"Yes":"No"},{label:"Linked",value:o!=null&&o.linked?"Yes":"No"},...o!=null&&o.lastError?[{label:"Last Error",value:Gc(o.lastError)}]:[]];break}case"imessage":{const{thisWsOwns:s}=Ko(e);t="iMessage",n=[{label:"Connected",value:s&&e.imessageConnected?"Yes":"No"},{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:"Current",value:e.currentVersion?`v${e.currentVersion}`:"Unknown"},{label:"Latest",value:e.latestVersion?`v${e.latestVersion}`:"Unknown"},{label:"Status",value:e.updateAvailable===null?"Not checked":e.updateAvailable?"Update available":"Up to date"},...e.updateMessage?[{label:"Message",value:e.updateMessage}]:[]];break}case"internet":{const s=e.tailscaleStatus,o=s?s.installed?s.loggedIn?s.funnelEnabled&&s.funnelActive?"Active":s.funnelEnabled&&!s.funnelActive?"Enabled but not active":"Connected (not public)":"Not connected":"Not installed":"Checking...";t="Internet Access",n=[{label:"Status",value:o},{label:"What",value:"Makes your public chat and API reachable from the internet, not just your local network"},{label:"How",value:"Uses Tailscale Funnel — a free, secure tunnel that gives your device a public HTTPS address"},{label:"Security",value:"Only the /public/* paths are exposed. The control panel stays LAN-only."},...s!=null&&s.publicUrl?[{label:"Public URL",value:s.publicUrl}]:[],...s!=null&&s.hostname?[{label:"Hostname",value:s.hostname}]:[]];break}case"public-chat":{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:"Access mode",value:jf[e.publicChatAuthMode]??"Open access"},{label:"Open access",value:"Anyone can chat without identifying themselves"},{label:"WhatsApp OTP",value:"Visitors verify their phone number before chatting"},{label:"Visitor chooses",value:"Visitors can chat anonymously or verify via WhatsApp"}];break}case"account-pin":{t="Account PIN",n=[{label:"Status",value:e.accountHasPin?"Set":"Not set"},{label:"What",value:"A numeric PIN that protects this account on the control panel"},{label:"When needed",value:"Required when switching to this account or after the session expires"},{label:"Format",value:"4 to 6 digits"}];break}case"branding":{const s=!!(e.brandAccentColor||e.brandBackgroundColor||e.brandHasLogo);t="Branding",n=[{label:"Status",value:s?"Customised":"Default"},{label:"What",value:"Your business logo and colour scheme, displayed on the control panel and public chat pages"},{label:"Logo",value:"Shown on public chat pages alongside your business name"},{label:"Accent colour",value:"Used for buttons, links, and interactive elements"},{label:"Background tint",value:"A subtle colour wash applied to page and card backgrounds"},{label:"Scope",value:"Each account has its own branding — switch accounts to customise each one separately"}];break}default:return k}return d`
415
+ `}function Uf(e){var i;if(!e.infoModalOpen)return k;let t="",n=[];switch(e.infoModalOpen){case"gateway":{const s=typeof window<"u"?window.location.host:"unknown";t="Gateway",n=[{label:"Status",value:e.gatewayHealthy===!1?"Stopped":"Running"},{label:"Address",value:s},{label:"Health",value:e.gatewayHealthMessage||"OK"}];break}case"claude":{const s=e.authExpiresIn;let o="N/A";if(s!=null&&s>0)if(s>60){const r=Math.floor(s/60),a=s%60;o=a>0?`${r}h ${a}m`:`${r}h`}else o=`${s}m`;t="Claude",n=[{label:"Connected",value:e.authConnected?"Yes":"No"},{label:"Token Expiry",value:o},{label:"Renewal",value:"Automatic (tokens refresh on expiry)"},...e.authMessage?[{label:"Message",value:e.authMessage}]:[]];break}case"license":{const s=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"Key",value:s},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A"}];break}case"whatsapp":{const s=Yt(e),o=s?Ko(s,e):null;t="WhatsApp",n=[{label:"Account",value:(o==null?void 0:o.name)||(o==null?void 0:o.accountId)||"Default"},{label:"Phone",value:((i=o==null?void 0:o.self)==null?void 0:i.e164)||"Not paired"},{label:"Connected",value:o!=null&&o.connected?"Yes":"No"},{label:"Linked",value:o!=null&&o.linked?"Yes":"No"},...o!=null&&o.lastError?[{label:"Last Error",value:Qc(o.lastError)}]:[]];break}case"imessage":{const{thisWsOwns:s}=zo(e);t="iMessage",n=[{label:"Connected",value:s&&e.imessageConnected?"Yes":"No"},{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:"Current",value:e.currentVersion?`v${e.currentVersion}`:"Unknown"},{label:"Latest",value:e.latestVersion?`v${e.latestVersion}`:"Unknown"},{label:"Status",value:e.updateAvailable===null?"Not checked":e.updateAvailable?"Update available":"Up to date"},...e.updateMessage?[{label:"Message",value:e.updateMessage}]:[]];break}case"internet":{const s=e.tailscaleStatus,o=s?s.installed?s.loggedIn?s.funnelEnabled&&s.funnelActive?"Active":s.funnelEnabled&&!s.funnelActive?"Enabled but not active":"Connected (not public)":"Not connected":"Not installed":"Checking...";t="Internet Access",n=[{label:"Status",value:o},{label:"What",value:"Makes your public chat and API reachable from the internet, not just your local network"},{label:"How",value:"Uses Tailscale Funnel — a free, secure tunnel that gives your device a public HTTPS address"},{label:"Security",value:"Only the /public/* paths are exposed. The control panel stays LAN-only."},...s!=null&&s.publicUrl?[{label:"Public URL",value:s.publicUrl}]:[],...s!=null&&s.hostname?[{label:"Hostname",value:s.hostname}]:[]];break}case"public-chat":{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:"Access mode",value:Gf[e.publicChatAuthMode]??"Open access"},{label:"Open access",value:"Anyone can chat without identifying themselves"},{label:"WhatsApp OTP",value:"Visitors verify their phone number before chatting"},{label:"Visitor chooses",value:"Visitors can chat anonymously or verify via WhatsApp"}];break}case"account-pin":{t="Account PIN",n=[{label:"Status",value:e.accountHasPin?"Set":"Not set"},{label:"What",value:"A numeric PIN that protects this account on the control panel"},{label:"When needed",value:"Required when switching to this account or after the session expires"},{label:"Format",value:"4 to 6 digits"}];break}case"branding":{const s=!!(e.brandAccentColor||e.brandBackgroundColor||e.brandHasLogo);t="Branding",n=[{label:"Status",value:s?"Customised":"Default"},{label:"What",value:"Your business logo and colour scheme, displayed on the control panel and public chat pages"},{label:"Logo",value:"Shown on public chat pages alongside your business name"},{label:"Accent colour",value:"Used for buttons, links, and interactive elements"},{label:"Background tint",value:"A subtle colour wash applied to page and card backgrounds"},{label:"Scope",value:"Each account has its own branding — switch accounts to customise each one separately"}];break}default:return k}return d`
416
416
  <div class="setup-info-overlay" @click=${s=>{s.target.classList.contains("setup-info-overlay")&&e.onInfoModalClose()}}>
417
417
  <div class="setup-info-card">
418
418
  <h3>${t}</h3>
@@ -442,7 +442,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
442
442
  </div>
443
443
  `})}
444
444
  </div>
445
- `}function Jr(e){const{licenseKey:t,licenseBusy:n,licenseValid:i,licenseMessage:s,licenseDeviceId:o,onLicenseKeyChange:r,onLicenseActivate:a}=e;return i===!0?d`
445
+ `}function Zr(e){const{licenseKey:t,licenseBusy:n,licenseValid:i,licenseMessage:s,licenseDeviceId:o,onLicenseKeyChange:r,onLicenseActivate:a}=e;return i===!0?d`
446
446
  <div class="setup-container">
447
447
  <div class="setup-card setup-success">
448
448
  ${$e("license")}
@@ -511,7 +511,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
511
511
  </p>
512
512
  </div>
513
513
  </div>
514
- `}function Ff(e){const{authConnected:t,authBusy:n,authMessage:i,authUrl:s,authCodeInput:o,authExpiresIn:r,onStartAuth:a,onSubmitAuthCode:u,onAuthCodeChange:c,onSkipToWhatsApp:l}=e;return t===!0?d`
514
+ `}function Wf(e){const{authConnected:t,authBusy:n,authMessage:i,authUrl:s,authCodeInput:o,authExpiresIn:r,onStartAuth:a,onSubmitAuthCode:u,onAuthCodeChange:c,onSkipToWhatsApp:l}=e;return t===!0?d`
515
515
  <div class="setup-container">
516
516
  <div class="setup-card setup-success">
517
517
  ${$e("auth")}
@@ -643,7 +643,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
643
643
  </p>
644
644
  </div>
645
645
  </div>
646
- `}function Wo(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 Yt(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 Zr(e){const t=Yt(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??He().name,i=e.whatsappBusy||e.gatewayHealthLoading;if(e.renamingWorkspace&&t){const s=()=>{const o=e.renameWorkspaceName.trim();o&&e.onWorkspaceRename(t.name,o)};return d`
646
+ `}function Ko(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 Yt(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 ea(e){const t=Yt(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??He().name,i=e.whatsappBusy||e.gatewayHealthLoading;if(e.renamingWorkspace&&t){const s=()=>{const o=e.renameWorkspaceName.trim();o&&e.onWorkspaceRename(t.name,o)};return d`
647
647
  <div style="display: flex; align-items: center; gap: 6px; margin-bottom: 4px;">
648
648
  <input
649
649
  type="text"
@@ -685,7 +685,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
685
685
  ${L.rotateCw}
686
686
  </button>
687
687
  </div>
688
- `}function ea(e){return d`
688
+ `}function ta(e){return d`
689
689
  <div class="setup-status-item">
690
690
  ${V(e.gatewayHealthy===!1?"bad":"good")}
691
691
  <div class="setup-status-info">
@@ -702,7 +702,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
702
702
  ${L.rotateCw}
703
703
  </button>
704
704
  </div>
705
- `}function ta(e){const t=e.authConnected===!0;return d`
705
+ `}function na(e){const t=e.authConnected===!0;return d`
706
706
  <div class="setup-status-item">
707
707
  ${V(t?"good":"bad")}
708
708
  <div class="setup-status-info">
@@ -731,7 +731,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
731
731
  </button>
732
732
  `}
733
733
  </div>
734
- `}function na(e){return d`
734
+ `}function ia(e){return d`
735
735
  <div class="setup-status-item" style="flex-wrap: wrap;">
736
736
  ${V("good")}
737
737
  <div class="setup-status-info">
@@ -771,7 +771,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
771
771
  </div>
772
772
  `:k}
773
773
  </div>
774
- `}function Gc(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 ia(e){var p;const t=Yt(e);if(!t)return k;const n=Wo(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,r=i?"good":s?"partial":o?"bad":"unknown",a=i?"Connected":s?"Linked, not connected":o?n!=null&&n.lastError?Gc(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?(p=e.whatsappAccounts[0])==null?void 0:p.accountId:void 0),l=c!=null&&e.whatsappActiveQrAccountId===c;return d`
774
+ `}function Qc(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 sa(e){var p;const t=Yt(e);if(!t)return k;const n=Ko(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,r=i?"good":s?"partial":o?"bad":"unknown",a=i?"Connected":s?"Linked, not connected":o?n!=null&&n.lastError?Qc(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?(p=e.whatsappAccounts[0])==null?void 0:p.accountId:void 0),l=c!=null&&e.whatsappActiveQrAccountId===c;return d`
775
775
  <div class="setup-status-item" style="flex-wrap: wrap;">
776
776
  ${V(r)}
777
777
  <div class="setup-status-info">
@@ -832,7 +832,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
832
832
  </div>
833
833
  `:k}
834
834
  </div>
835
- `}const Uf=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],Wf="anthropic/claude-sonnet-4-5-20250929",Kf=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function zf(e){if(!e.whatsappSettingsOpen)return k;const t=Yt(e);if(!t)return k;const n=Wo(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected);if(!n||!i)return k;const s=()=>e.onWhatsAppSettingsClose(),o=e.whatsappModelCatalog??[],r=new Set(o.filter(l=>l.provider==="anthropic").map(l=>l.id)),a=Uf.filter(l=>r.has(l.id)),u=e.whatsappModel??Wf,c=e.whatsappThinkingLevel??"off";return d`
835
+ `}const Kf=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],zf="anthropic/claude-sonnet-4-5-20250929",qf=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function Hf(e){if(!e.whatsappSettingsOpen)return k;const t=Yt(e);if(!t)return k;const n=Ko(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected);if(!n||!i)return k;const s=()=>e.onWhatsAppSettingsClose(),o=e.whatsappModelCatalog??[],r=new Set(o.filter(l=>l.provider==="anthropic").map(l=>l.id)),a=Kf.filter(l=>r.has(l.id)),u=e.whatsappModel??zf,c=e.whatsappThinkingLevel??"off";return d`
836
836
  <div class="setup-info-overlay" @click=${l=>{l.target.classList.contains("setup-info-overlay")&&s()}}>
837
837
  <div class="setup-info-card" style="max-width: 360px;">
838
838
  <h3>Public Agent Settings</h3>
@@ -918,7 +918,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
918
918
  .value=${c}
919
919
  @change=${l=>{e.onWhatsAppThinkingChange(l.target.value)}}
920
920
  >
921
- ${Kf.map(l=>d`
921
+ ${qf.map(l=>d`
922
922
  <option value=${l.value} ?selected=${c===l.value}>
923
923
  ${l.label}
924
924
  </option>
@@ -935,7 +935,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
935
935
  </button>
936
936
  </div>
937
937
  </div>
938
- `}function Ko(e){const t=Yt(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 sa(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=Ko(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"),d`
938
+ `}function zo(e){const t=Yt(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 oa(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=zo(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"),d`
939
939
  <div class="setup-status-item" style="flex-wrap: wrap;">
940
940
  ${V(s)}
941
941
  <div class="setup-status-info">
@@ -953,7 +953,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
953
953
  </button>
954
954
  ${k}
955
955
  </div>
956
- `}function qf(e){if(!e.imessageEnableConfirm)return k;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=Ko(e),s=()=>{e.onIMessageEnableCancel()};return n?d`
956
+ `}function jf(e){if(!e.imessageEnableConfirm)return k;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=zo(e),s=()=>{e.onIMessageEnableCancel()};return n?d`
957
957
  <div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&s()}}>
958
958
  <div class="setup-info-card" style="text-align: center;">
959
959
  <h3>iMessage</h3>
@@ -1029,7 +1029,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1029
1029
  </button>
1030
1030
  </div>
1031
1031
  </div>
1032
- `}function oa(e){if(!e.isMaster)return k;const n=e.apiKeyProviders.filter(i=>i.hasKey).length;return d`
1032
+ `}function ra(e){if(!e.isMaster)return k;const n=e.apiKeyProviders.filter(i=>i.hasKey).length;return d`
1033
1033
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
1034
1034
  <div class="setup-status-item">
1035
1035
  ${V(n>0?"good":"bad")}
@@ -1043,8 +1043,8 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1043
1043
  >Manage</button>
1044
1044
  </div>
1045
1045
  </div>
1046
- ${Hf(e)}
1047
- `}function Hf(e){if(!e.apiKeyModalOpen)return k;const t=e.apiKeyProviders,n={};for(const c of t)c.key&&(n[c.id]=c.key);const i=(c,l)=>{const p=l==null?void 0:l.closest(".setup-apikey-input"),f=p==null?void 0:p.querySelector("input"),b=f==null?void 0:f.value.trim();!b||b===n[c]||e.onApiKeySave(c,b)},s=c=>{const l=c.currentTarget,p=l.closest(".setup-apikey-input"),f=p==null?void 0:p.querySelector("input");if(!f)return;const b=f.type==="text";f.type=b?"password":"text",l.classList.toggle("active",!b)},o=(c,l)=>{const p=l.target,f=p.closest(".setup-apikey-input"),b=p.value.trim(),h=b.length>0&&b!==n[c],v=f==null?void 0:f.querySelector(".setup-apikey-save");v&&(v.style.display=h?"":"none");const S=f==null?void 0:f.querySelector(".setup-apikey-eye");S&&(S.style.display=b.length>0?"":"none")},r=t.filter(c=>c.primary),a=t.filter(c=>!c.primary),u=c=>{const l=e.apiKeySavingProvider===c.id&&e.apiKeyBusy,p=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key saved`,f=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key removed`,b=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} disabled`,h=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} enabled`;return d`
1046
+ ${Vf(e)}
1047
+ `}function Vf(e){if(!e.apiKeyModalOpen)return k;const t=e.apiKeyProviders,n={};for(const c of t)c.key&&(n[c.id]=c.key);const i=(c,l)=>{const p=l==null?void 0:l.closest(".setup-apikey-input"),f=p==null?void 0:p.querySelector("input"),b=f==null?void 0:f.value.trim();!b||b===n[c]||e.onApiKeySave(c,b)},s=c=>{const l=c.currentTarget,p=l.closest(".setup-apikey-input"),f=p==null?void 0:p.querySelector("input");if(!f)return;const b=f.type==="text";f.type=b?"password":"text",l.classList.toggle("active",!b)},o=(c,l)=>{const p=l.target,f=p.closest(".setup-apikey-input"),b=p.value.trim(),h=b.length>0&&b!==n[c],v=f==null?void 0:f.querySelector(".setup-apikey-save");v&&(v.style.display=h?"":"none");const S=f==null?void 0:f.querySelector(".setup-apikey-eye");S&&(S.style.display=b.length>0?"":"none")},r=t.filter(c=>c.primary),a=t.filter(c=>!c.primary),u=c=>{const l=e.apiKeySavingProvider===c.id&&e.apiKeyBusy,p=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key saved`,f=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key removed`,b=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} disabled`,h=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} enabled`;return d`
1048
1048
  <div class="setup-apikey-row ${c.disabled?"disabled":""}">
1049
1049
  <div class="setup-apikey-info">
1050
1050
  <strong>${c.name}</strong>
@@ -1108,7 +1108,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1108
1108
  </div>
1109
1109
  </div>
1110
1110
  </div>
1111
- `}function ra(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 d`
1111
+ `}function aa(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 d`
1112
1112
  <div class="setup-status-item">
1113
1113
  ${V(t)}
1114
1114
  <div class="setup-status-info">
@@ -1136,7 +1136,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1136
1136
  </button>
1137
1137
  `}
1138
1138
  </div>
1139
- `}const jf={anonymous:"Open access",verified:"WhatsApp OTP",choice:"Visitor chooses"};function aa(e){const t=e.publicChatEnabled;return d`
1139
+ `}const Gf={anonymous:"Open access",verified:"WhatsApp OTP",choice:"Visitor chooses"};function la(e){const t=e.publicChatEnabled;return d`
1140
1140
  <div class="setup-status-item">
1141
1141
  ${V(t?"good":"unknown")}
1142
1142
  <div class="setup-status-info">
@@ -1160,7 +1160,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1160
1160
  @click=${e.onPublicChatToggle}
1161
1161
  >${e.publicChatBusy?"...":t?"Disable":"Enable"}</button>
1162
1162
  </div>
1163
- `}function la(e){const t=!!(e.brandAccentColor||e.brandBackgroundColor||e.brandHasLogo),n=t?"good":"unknown",i=e.brandingBusy;return d`
1163
+ `}function ca(e){const t=!!(e.brandAccentColor||e.brandBackgroundColor||e.brandHasLogo),n=t?"good":"unknown",i=e.brandingBusy;return d`
1164
1164
  <div class="setup-status-item">
1165
1165
  ${V(n)}
1166
1166
  <div class="setup-status-info">
@@ -1174,7 +1174,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1174
1174
  @click=${e.onBrandingToggle}
1175
1175
  >${i?"...":"Edit"}</button>
1176
1176
  </div>
1177
- `}function ca(e){var s;if(!e.brandingExpanded)return k;const t=e.brandingBusy,n=(s=e.wsProps)==null?void 0:s.selectedWorkspace,i=e.brandHasLogo&&n?`/brand-logo/${encodeURIComponent(n)}`:"";return d`
1177
+ `}function ua(e){var s;if(!e.brandingExpanded)return k;const t=e.brandingBusy,n=(s=e.wsProps)==null?void 0:s.selectedWorkspace,i=e.brandHasLogo&&n?`/brand-logo/${encodeURIComponent(n)}`:"";return d`
1178
1178
  <div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&e.onBrandingToggle()}}>
1179
1179
  <div class="setup-info-card" style="max-width: 400px; position: relative;">
1180
1180
  <h3 style="margin-right: 24px;">Branding</h3>
@@ -1255,7 +1255,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1255
1255
 
1256
1256
  </div>
1257
1257
  </div>
1258
- `}function Vf(e){if(!e.isMaster)return k;const t=e.tailscaleStatus,n=e.tailscaleBusy,i=e.tailscaleAuthUrl;if(!t)return d`
1258
+ `}function Qf(e){if(!e.isMaster)return k;const t=e.tailscaleStatus,n=e.tailscaleBusy,i=e.tailscaleAuthUrl;if(!t)return d`
1259
1259
  <div class="setup-status-item">
1260
1260
  ${V("unknown")}
1261
1261
  <div class="setup-status-info">
@@ -1402,7 +1402,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1402
1402
  @click=${e.onTailscaleFunnelDisable}
1403
1403
  >${n?"...":"Disable"}</button>
1404
1404
  </div>
1405
- `}function ua(e){const t=e>=70?4:e>=50?3:e>=30?2:1;return d`
1405
+ `}function da(e){const t=e>=70?4:e>=50?3:e>=30?2:1;return d`
1406
1406
  <span style="display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; vertical-align: middle;">
1407
1407
  ${[4,7,10,14].map((i,s)=>d`<span style="
1408
1408
  width: 3px;
@@ -1411,7 +1411,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1411
1411
  background: ${s<t?"var(--tasker-accent, #00e5ff)":"rgba(255,255,255,0.15)"};
1412
1412
  "></span>`)}
1413
1413
  </span>
1414
- `}function da(e){if(e.serverPlatform!=="linux")return k;const t=e.wifiStatus,n=e.wifiBusy;if(!t)return d`
1414
+ `}function pa(e){if(e.serverPlatform!=="linux")return k;const t=e.wifiStatus,n=e.wifiBusy;if(!t)return d`
1415
1415
  <div class="setup-status-item">
1416
1416
  ${V("unknown")}
1417
1417
  <div class="setup-status-info">
@@ -1427,7 +1427,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1427
1427
  <span>NetworkManager not available</span>
1428
1428
  </div>
1429
1429
  </div>
1430
- `;const i=e.wifiNetworks,s=e.wifiSelectedSsid,o=i.length>0,r=!!t.savedSsid&&!t.connected,a=t.connected?"good":"partial",u=t.connected?d`${t.ssid} ${t.signal!=null?d`<span style="margin-left: 4px;">${ua(t.signal)}</span>`:k}`:r?d`${t.savedSsid} <span style="opacity: 0.4;">\u2014 reconnecting\u2026</span>`:"Not connected";return d`
1430
+ `;const i=e.wifiNetworks,s=e.wifiSelectedSsid,o=i.length>0,r=!!t.savedSsid&&!t.connected,a=t.connected?"good":"partial",u=t.connected?d`${t.ssid} ${t.signal!=null?d`<span style="margin-left: 4px;">${da(t.signal)}</span>`:k}`:r?d`${t.savedSsid} <span style="opacity: 0.4;">\u2014 reconnecting\u2026</span>`:"Not connected";return d`
1431
1431
  <div>
1432
1432
  <div class="setup-status-item">
1433
1433
  ${V(a)}
@@ -1487,7 +1487,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1487
1487
  </span>
1488
1488
  <span style="display: flex; align-items: center; gap: 8px;">
1489
1489
  ${c.security!=="Open"?d`<span style="opacity: 0.4; font-size: 11px;" title="${c.security}">\uD83D\uDD12</span>`:k}
1490
- <span title="Signal: ${c.signal}%">${ua(c.signal)}</span>
1490
+ <span title="Signal: ${c.signal}%">${da(c.signal)}</span>
1491
1491
  </span>
1492
1492
  </button>
1493
1493
  `})}
@@ -1531,7 +1531,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1531
1531
  </div>
1532
1532
  `:k}
1533
1533
  </div>
1534
- `}function Gf(e){var i,s,o;const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return k;if(t)return d`
1534
+ `}function Yf(e){var i,s,o;const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return k;if(t)return d`
1535
1535
  <div class="setup-info-overlay">
1536
1536
  <div class="setup-info-card" style="max-width: 400px;">
1537
1537
  <h3>Software Update</h3>
@@ -1543,7 +1543,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1543
1543
  ${r.status==="running"?d`<span class="setup-update-spinner"></span>`:r.status==="done"?d`<span class="setup-update-icon-ok">${L.check}</span>`:d`<span class="setup-update-icon-fail">${L.x}</span>`}
1544
1544
  </span>
1545
1545
  <span class="setup-update-step-name">${r.name}</span>
1546
- ${r.durationMs!=null?d`<span class="setup-update-step-time">${pa(r.durationMs)}</span>`:k}
1546
+ ${r.durationMs!=null?d`<span class="setup-update-step-time">${ha(r.durationMs)}</span>`:k}
1547
1547
  </div>
1548
1548
  `)}
1549
1549
  </div>
@@ -1551,7 +1551,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1551
1551
  ${e.updateMessage?d`<p style="text-align: center; color: var(--tasker-text-grey); font-size: 13px; margin: 12px 0 0;">${e.updateMessage}</p>`:k}
1552
1552
  </div>
1553
1553
  </div>
1554
- `;if(n){const r=n.status==="ok";let a;if(r){const c=(i=n.before)==null?void 0:i.version,l=((s=n.after)==null?void 0:s.version)??n.currentVersion;a=c?`v${c} → v${l}`:`Updated to v${l}`}else a=n.reason??((o=n.failedStep)==null?void 0:o.name)??"unknown error";const u=n.durationMs!=null?pa(n.durationMs):null;return d`
1554
+ `;if(n){const r=n.status==="ok";let a;if(r){const c=(i=n.before)==null?void 0:i.version,l=((s=n.after)==null?void 0:s.version)??n.currentVersion;a=c?`v${c} → v${l}`:`Updated to v${l}`}else a=n.reason??((o=n.failedStep)==null?void 0:o.name)??"unknown error";const u=n.durationMs!=null?ha(n.durationMs):null;return d`
1555
1555
  <div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onUpdateDismissResult()}}>
1556
1556
  <div class="setup-info-card" style="max-width: 360px; text-align: center;">
1557
1557
  <div class="setup-update-result-icon ${r?"ok":"fail"}">${r?L.circleCheck:L.circleX}</div>
@@ -1571,7 +1571,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1571
1571
  </button>
1572
1572
  </div>
1573
1573
  </div>
1574
- `}return k}function pa(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 ha(e){const t=e.accountHasPin;return d`
1574
+ `}return k}function ha(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 fa(e){const t=e.accountHasPin;return d`
1575
1575
  <div class="setup-status-item">
1576
1576
  ${V(t?"good":"bad")}
1577
1577
  <div class="setup-status-info">
@@ -1584,7 +1584,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1584
1584
  @click=${()=>e.onAccountPinModalOpen()}
1585
1585
  >${t?"Change":"Set PIN"}</button>
1586
1586
  </div>
1587
- `}function fa(e){if(!e.accountPinModalOpen)return k;const t=e.accountHasPin,n=e.accountPinBusy;let i="",s="",o="";const r=c=>l=>{const p=l.target;p.value=p.value.replace(/\D/g,"").slice(0,6),c(p.value)},a=(c,l)=>{var f;let p=c.querySelector(".pin-modal-validation");p||(p=document.createElement("p"),p.className="login-error pin-modal-validation",(f=c.querySelector("button[type=submit]"))==null||f.before(p)),p.textContent=l},u=c=>{c.preventDefault();const l=c.target;if(!n){if(t&&!i){a(l,"Enter your current PIN");return}if(!s){a(l,"Enter a new PIN");return}if(!o){a(l,"Confirm your new PIN");return}if(s!==o){a(l,"PINs do not match");return}if(s.length<4){a(l,"PIN must be 4–6 digits");return}e.onAccountPinSave(t?i:null,s)}};return d`
1587
+ `}function ga(e){if(!e.accountPinModalOpen)return k;const t=e.accountHasPin,n=e.accountPinBusy;let i="",s="",o="";const r=c=>l=>{const p=l.target;p.value=p.value.replace(/\D/g,"").slice(0,6),c(p.value)},a=(c,l)=>{var f;let p=c.querySelector(".pin-modal-validation");p||(p=document.createElement("p"),p.className="login-error pin-modal-validation",(f=c.querySelector("button[type=submit]"))==null||f.before(p)),p.textContent=l},u=c=>{c.preventDefault();const l=c.target;if(!n){if(t&&!i){a(l,"Enter your current PIN");return}if(!s){a(l,"Enter a new PIN");return}if(!o){a(l,"Confirm your new PIN");return}if(s!==o){a(l,"PINs do not match");return}if(s.length<4){a(l,"PIN must be 4–6 digits");return}e.onAccountPinSave(t?i:null,s)}};return d`
1588
1588
  <div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onAccountPinModalClose()}}>
1589
1589
  <div class="setup-info-card" style="max-width: 340px;">
1590
1590
  <div class="setup-info-header">
@@ -1641,7 +1641,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1641
1641
  </form>
1642
1642
  </div>
1643
1643
  </div>
1644
- `}function ga(e){if(!e.addingWorkspace)return k;const{workspaceSaving:t}=e;return d`
1644
+ `}function ma(e){if(!e.addingWorkspace)return k;const{workspaceSaving:t}=e;return d`
1645
1645
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
1646
1646
  <div class="setup-add-account">
1647
1647
  <strong>New Account</strong>
@@ -1694,7 +1694,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1694
1694
  </div>
1695
1695
  </div>
1696
1696
  </div>
1697
- `}function ma(e){const t=Yt(e);return!t||t.isDefault?k:e.workspaceRemoveConfirm===t.name?d`
1697
+ `}function ya(e){const t=Yt(e);return!t||t.isDefault?k:e.workspaceRemoveConfirm===t.name?d`
1698
1698
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 12px;">
1699
1699
  <div style="font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
1700
1700
  <span style="color: var(--tasker-danger, #ef4444);">Remove "${t.displayName??t.name}" and its WhatsApp account?</span>
@@ -1723,7 +1723,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1723
1723
  @click=${i=>{i.preventDefault(),e.onSetWorkspaceRemoveConfirm(t.name)}}
1724
1724
  >Remove Account</a>
1725
1725
  </p>
1726
- `}function ya(e){if(e.uninstallDone)return d`
1726
+ `}function va(e){if(e.uninstallDone)return d`
1727
1727
  <div style="margin-top: 24px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
1728
1728
  <p style="color: var(--tasker-danger, #ef4444); font-size: 13px; font-weight: 600; margin: 0 0 8px 0;">
1729
1729
  Taskmaster has been uninstalled.
@@ -1778,11 +1778,11 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1778
1778
  @click=${t=>{t.preventDefault(),e.onUninstallConfirm()}}
1779
1779
  >Uninstall Taskmaster</a>
1780
1780
  </p>
1781
- `}function va(){return d`
1781
+ `}function ba(){return d`
1782
1782
  <p class="setup-hint" style="margin-top: 4px; font-size: 12px; opacity: 0.6;">
1783
1783
  Need help? <a href="https://wa.me/447591215452" target="_blank" rel="noopener" style="color: var(--tasker-orange);">Message Dave on WhatsApp</a>
1784
1784
  </p>
1785
- `}function Qf(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:i,whatsappLoginConnected:s,whatsappChannelStatus:o}=e;if(i)return d`
1785
+ `}function Xf(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:i,whatsappLoginConnected:s,whatsappChannelStatus:o}=e;if(i)return d`
1786
1786
  <div class="setup-container">
1787
1787
  <div class="setup-card">
1788
1788
  <h1>Scan with WhatsApp</h1>
@@ -1819,55 +1819,55 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1819
1819
  `;const r=(o==null?void 0:o.running)&&(o==null?void 0:o.connected);return o?(e.whatsappAccounts.length>1?e.whatsappAccounts.every(l=>l.running&&l.connected):r)&&e.authConnected?d`
1820
1820
  <div class="setup-container">
1821
1821
  <div class="setup-card setup-success setup-dashboard-wide">
1822
- ${Zr(e)}
1822
+ ${ea(e)}
1823
1823
  <div class="setup-status-dashboard">
1824
- ${ea(e)}
1825
1824
  ${ta(e)}
1826
1825
  ${na(e)}
1827
1826
  ${ia(e)}
1828
- ${e.serverPlatform==="darwin"?sa(e):k}
1829
- ${ha(e)}
1830
- ${ra(e)}
1827
+ ${sa(e)}
1828
+ ${e.serverPlatform==="darwin"?oa(e):k}
1829
+ ${fa(e)}
1831
1830
  ${aa(e)}
1832
1831
  ${la(e)}
1833
- ${Vf(e)}
1834
- ${da(e)}
1832
+ ${ca(e)}
1833
+ ${Qf(e)}
1834
+ ${pa(e)}
1835
1835
  </div>
1836
1836
 
1837
- ${fa(e)}
1838
- ${ca(e)}
1839
- ${oa(e)}
1840
1837
  ${ga(e)}
1838
+ ${ua(e)}
1839
+ ${ra(e)}
1841
1840
  ${ma(e)}
1842
1841
  ${ya(e)}
1843
- ${va()}
1842
+ ${va(e)}
1843
+ ${ba()}
1844
1844
  ${e.workspacesError?d`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:k}
1845
1845
  </div>
1846
1846
  </div>
1847
1847
  `:d`
1848
1848
  <div class="setup-container">
1849
1849
  <div class="setup-card setup-dashboard-wide">
1850
- ${Zr(e)}
1850
+ ${ea(e)}
1851
1851
  <div class="setup-status-dashboard">
1852
- ${ea(e)}
1853
1852
  ${ta(e)}
1854
1853
  ${na(e)}
1855
1854
  ${ia(e)}
1856
- ${e.serverPlatform==="darwin"?sa(e):k}
1857
- ${ha(e)}
1858
- ${ra(e)}
1855
+ ${sa(e)}
1856
+ ${e.serverPlatform==="darwin"?oa(e):k}
1857
+ ${fa(e)}
1859
1858
  ${aa(e)}
1860
1859
  ${la(e)}
1861
- ${da(e)}
1860
+ ${ca(e)}
1861
+ ${pa(e)}
1862
1862
  </div>
1863
1863
 
1864
- ${fa(e)}
1865
- ${ca(e)}
1866
- ${oa(e)}
1867
1864
  ${ga(e)}
1865
+ ${ua(e)}
1866
+ ${ra(e)}
1868
1867
  ${ma(e)}
1869
1868
  ${ya(e)}
1870
- ${va()}
1869
+ ${va(e)}
1870
+ ${ba()}
1871
1871
  ${e.workspacesError?d`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:k}
1872
1872
  </div>
1873
1873
  </div>
@@ -1912,7 +1912,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1912
1912
  </button>
1913
1913
  </div>
1914
1914
  </div>
1915
- `}function Yf(e){const{connected:t,currentStep:n}=e;if(t&&$i()&&Uo(),e.uninstallDone||!t&&$i())return d`
1915
+ `}function Jf(e){const{connected:t,currentStep:n}=e;if(t&&$i()&&Wo(),e.uninstallDone||!t&&$i())return d`
1916
1916
  <div class="setup-container">
1917
1917
  <div class="setup-card">
1918
1918
  <p style="color: var(--tasker-danger, #ef4444); font-size: 16px; font-weight: 600; margin: 0 0 12px 0;">
@@ -1935,7 +1935,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1935
1935
  <p>${o?"Restarting gateway after update…":"Connecting to gateway..."}</p>
1936
1936
  </div>
1937
1937
  </div>
1938
- `}let i;switch(n){case"license":i=Jr(e);break;case"auth":i=Ff(e);break;case"whatsapp":case"complete":i=Qf(e);break;default:i=Jr(e)}const s=xt("Setup",e.wsProps);return d`${i}${Of(e)}${qf(e)}${zf(e)}${Gf(e)}${s}`}function Xf(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return d`
1938
+ `}let i;switch(n){case"license":i=Zr(e);break;case"auth":i=Wf(e);break;case"whatsapp":case"complete":i=Xf(e);break;default:i=Zr(e)}const s=Et("Setup",e.wsProps);return d`${i}${Uf(e)}${jf(e)}${Hf(e)}${Yf(e)}${s}`}function Zf(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return d`
1939
1939
  <div class="sp-list-item">
1940
1940
  <div class="sp-list-item-main">
1941
1941
  <div class="sp-list-item-title">${e.phone}</div>
@@ -1950,7 +1950,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1950
1950
  Remove
1951
1951
  </button>`}
1952
1952
  </div>
1953
- `}function Jf(e){if(!e.connected)return d`
1953
+ `}function eg(e){if(!e.connected)return d`
1954
1954
  <div class="setup-container">
1955
1955
  <div class="setup-card">
1956
1956
  <div class="setup-spinner"></div>
@@ -1959,7 +1959,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1959
1959
  </div>
1960
1960
  `;const t=n=>{n.preventDefault(),e.newPhone.trim()&&e.onAdd(e.newPhone)};return d`
1961
1961
  <div class="setup-container">
1962
- ${xt("Admins",e.wsProps)}
1962
+ ${Et("Admins",e.wsProps)}
1963
1963
  <div class="setup-card" style="max-width: 520px;">
1964
1964
  <h1>Admin Phones</h1>
1965
1965
  <p style="margin-bottom: 16px;">
@@ -1999,7 +1999,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
1999
1999
  </form>
2000
2000
 
2001
2001
  <div class="sp-list" style="margin-top: 20px;">
2002
- ${e.phones.length===0?d`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>Xf(n,e))}
2002
+ ${e.phones.length===0?d`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>Zf(n,e))}
2003
2003
  </div>
2004
2004
 
2005
2005
  <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
@@ -2010,13 +2010,13 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
2010
2010
 
2011
2011
  </div>
2012
2012
  </div>
2013
- `}const Qc=d`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`;function Zf(e){return Object.keys(e.fields).length}function eg(e,t){return d`
2013
+ `}const Yc=d`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`;function tg(e){return Object.keys(e.fields).length}function ng(e,t){return d`
2014
2014
  <div class="event-modal-overlay" @click=${t.onDeleteConfirmClose}>
2015
2015
  <div class="event-modal" style="width: min(400px, 100%);" @click=${n=>n.stopPropagation()}>
2016
2016
  <div class="event-modal__header">
2017
2017
  <div class="event-modal__title">Delete Contact</div>
2018
2018
  <button class="event-modal__close" @click=${t.onDeleteConfirmClose}>
2019
- ${Qc}
2019
+ ${Yc}
2020
2020
  </button>
2021
2021
  </div>
2022
2022
  <p style="margin: 0 0 8px; color: rgba(255,255,255,0.7); font-size: 14px; line-height: 1.5;">
@@ -2042,13 +2042,13 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
2042
2042
  </div>
2043
2043
  </div>
2044
2044
  </div>
2045
- `}function tg(e,t){const n=t.addFieldKey.trim().length>0,i=s=>{s.preventDefault(),n&&t.onAddFieldSubmit()};return d`
2045
+ `}function ig(e,t){const n=t.addFieldKey.trim().length>0,i=s=>{s.preventDefault(),n&&t.onAddFieldSubmit()};return d`
2046
2046
  <div class="event-modal-overlay" @click=${t.onAddFieldClose}>
2047
2047
  <div class="event-modal" style="width: min(400px, 100%);" @click=${s=>s.stopPropagation()}>
2048
2048
  <div class="event-modal__header">
2049
2049
  <div class="event-modal__title">Add Field</div>
2050
2050
  <button class="event-modal__close" @click=${t.onAddFieldClose}>
2051
- ${Qc}
2051
+ ${Yc}
2052
2052
  </button>
2053
2053
  </div>
2054
2054
  <p style="margin: 0 0 16px; color: rgba(255,255,255,0.5); font-size: 13px;">
@@ -2093,7 +2093,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
2093
2093
  </form>
2094
2094
  </div>
2095
2095
  </div>
2096
- `}function ng(e,t){const n=Object.entries(e.fields);return d`
2096
+ `}function sg(e,t){const n=Object.entries(e.fields);return d`
2097
2097
  <div class="contacts-record-fields">
2098
2098
  ${n.length===0?d`<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])=>d`
2099
2099
  <div class="contacts-field-row">
@@ -2140,7 +2140,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
2140
2140
  </button>
2141
2141
  </div>
2142
2142
  </div>
2143
- `}function ig(e,t){const n=t.editingId===e.id,i=Zf(e),s=i===0?"No fields":`${i} field${i>1?"s":""}`;return d`
2143
+ `}function og(e,t){const n=t.editingId===e.id,i=tg(e),s=i===0?"No fields":`${i} field${i>1?"s":""}`;return d`
2144
2144
  <div class="contacts-record">
2145
2145
  <div
2146
2146
  class="contacts-record-header"
@@ -2152,9 +2152,9 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
2152
2152
  </div>
2153
2153
  <span class="contacts-record-meta">${s}</span>
2154
2154
  </div>
2155
- ${n?ng(e,t):k}
2155
+ ${n?sg(e,t):k}
2156
2156
  </div>
2157
- `}function sg(e){if(!e.connected)return d`
2157
+ `}function rg(e){if(!e.connected)return d`
2158
2158
  <div class="setup-container">
2159
2159
  <div class="setup-card">
2160
2160
  <div class="setup-spinner"></div>
@@ -2163,7 +2163,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
2163
2163
  </div>
2164
2164
  `;const t=o=>{o.preventDefault(),e.onSearchSubmit()},n=o=>{o.preventDefault(),e.newRecordPhone.trim()&&e.newRecordName.trim()&&e.onAdd(e.newRecordPhone,e.newRecordName)},i=e.deleteConfirmId?e.records.find(o=>o.id===e.deleteConfirmId):null,s=e.addFieldForId?e.records.find(o=>o.id===e.addFieldForId):null;return d`
2165
2165
  <div class="setup-container">
2166
- ${xt("Contacts",e.wsProps)}
2166
+ ${Et("Contacts",e.wsProps)}
2167
2167
  <div class="setup-card" style="max-width: 620px;">
2168
2168
  <h1>Contact Records</h1>
2169
2169
  <p style="margin-bottom: 16px;">
@@ -2250,7 +2250,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
2250
2250
  <div style="margin-top: 16px;">
2251
2251
  ${e.records.length===0?d`<div class="contacts-empty">
2252
2252
  ${e.searchQuery.trim()?`No records matching "${e.searchQuery}".`:"No contact records yet. Add one to get started."}
2253
- </div>`:e.records.map(o=>ig(o,e))}
2253
+ </div>`:e.records.map(o=>og(o,e))}
2254
2254
  </div>
2255
2255
 
2256
2256
  <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
@@ -2262,14 +2262,14 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=wn(t.
2262
2262
  </div>
2263
2263
  </div>
2264
2264
 
2265
- ${i?eg(i,e):k}
2266
- ${s?tg(s,e):k}
2267
- `}const Yc={CHILD:2},Xc=e=>(...t)=>({_$litDirective$:e,values:t});let Jc=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:og}=Kd,ba=e=>e,wa=()=>document.createComment(""),on=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const r=i.insertBefore(wa(),s),a=i.insertBefore(wa(),s);n=new og(r,a,e,e.options)}else{const r=n._$AB.nextSibling,a=n._$AM,u=a!==e;if(u){let c;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==a._$AU&&n._$AP(c)}if(r!==s||u){let c=n._$AA;for(;c!==r;){const l=ba(c).nextSibling;ba(i).insertBefore(c,s),c=l}}}return n},dt=(e,t,n=e)=>(e._$AI(t,n),e),rg={},ag=(e,t=rg)=>e._$AH=t,lg=e=>e._$AH,vs=e=>{e._$AR(),e._$AA.remove()};const ka=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},cg=Xc(class extends Jc{constructor(e){if(super(e),e.type!==Yc.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 r=0;for(const a of e)s[r]=i?i(a,r):r,o[r]=n(a,r),r++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=lg(e),{values:o,keys:r}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=r,o;const a=this.ut??(this.ut=[]),u=[];let c,l,p=0,f=s.length-1,b=0,h=o.length-1;for(;p<=f&&b<=h;)if(s[p]===null)p++;else if(s[f]===null)f--;else if(a[p]===r[b])u[b]=dt(s[p],o[b]),p++,b++;else if(a[f]===r[h])u[h]=dt(s[f],o[h]),f--,h--;else if(a[p]===r[h])u[h]=dt(s[p],o[h]),on(e,u[h+1],s[p]),p++,h--;else if(a[f]===r[b])u[b]=dt(s[f],o[b]),on(e,s[p],s[f]),f--,b++;else if(c===void 0&&(c=ka(r,b,h),l=ka(a,p,f)),c.has(a[p]))if(c.has(a[f])){const v=l.get(r[b]),S=v!==void 0?s[v]:null;if(S===null){const $=on(e,s[p]);dt($,o[b]),u[b]=$}else u[b]=dt(S,o[b]),on(e,s[p],S),s[v]=null;b++}else vs(s[f]),f--;else vs(s[p]),p++;for(;b<=h;){const v=on(e,u[h+1]);dt(v,o[b]),u[b++]=v}for(;p<=f;){const v=s[p++];v!==null&&vs(v)}return this.ut=r,ag(e,u),it}});class Ys extends Jc{constructor(t){if(super(t),this.it=k,t.type!==Yc.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===k||t==null)return this._t=void 0,this.it=t;if(t===it)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:[]}}}Ys.directiveName="unsafeHTML",Ys.resultType=1;const Ai=Xc(Ys);const{entries:Zc,setPrototypeOf:Sa,isFrozen:ug,getPrototypeOf:dg,getOwnPropertyDescriptor:pg}=Object;let{freeze:fe,seal:ve,create:Xs}=Object,{apply:Js,construct:Zs}=typeof Reflect<"u"&&Reflect;fe||(fe=function(t){return t});ve||(ve=function(t){return t});Js||(Js=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)});Zs||(Zs=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 Jn=ge(Array.prototype.forEach),hg=ge(Array.prototype.lastIndexOf),$a=ge(Array.prototype.pop),rn=ge(Array.prototype.push),fg=ge(Array.prototype.splice),ci=ge(String.prototype.toLowerCase),bs=ge(String.prototype.toString),ws=ge(String.prototype.match),an=ge(String.prototype.replace),gg=ge(String.prototype.indexOf),mg=ge(String.prototype.trim),we=ge(Object.prototype.hasOwnProperty),de=ge(RegExp.prototype.test),ln=yg(TypeError);function ge(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 Js(e,t,i)}}function yg(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Zs(e,n)}}function U(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ci;Sa&&Sa(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(ug(t)||(t[i]=o),s=o)}e[s]=!0}return e}function vg(e){for(let t=0;t<e.length;t++)we(e,t)||(e[t]=null);return e}function Me(e){const t=Xs(null);for(const[n,i]of Zc(e))we(e,n)&&(Array.isArray(i)?t[n]=vg(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Me(i):t[n]=i);return t}function cn(e,t){for(;e!==null;){const i=pg(e,t);if(i){if(i.get)return ge(i.get);if(typeof i.value=="function")return ge(i.value)}e=dg(e)}function n(){return null}return n}const Aa=fe(["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"]),ks=fe(["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"]),Ss=fe(["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"]),bg=fe(["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"]),$s=fe(["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"]),wg=fe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),xa=fe(["#text"]),Ea=fe(["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"]),As=fe(["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"]),Ca=fe(["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"]),Zn=fe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),kg=ve(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Sg=ve(/<%[\w\W]*|[\w\W]*%>/gm),$g=ve(/\$\{[\w\W]*/gm),Ag=ve(/^data-[\-\w.\u00B7-\uFFFF]+$/),xg=ve(/^aria-[\-\w]+$/),eu=ve(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Eg=ve(/^(?:\w+script|data):/i),Cg=ve(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),tu=ve(/^html$/i),Tg=ve(/^[a-z][.\w]*(-[.\w]+)+$/i);var Ta=Object.freeze({__proto__:null,ARIA_ATTR:xg,ATTR_WHITESPACE:Cg,CUSTOM_ELEMENT:Tg,DATA_ATTR:Ag,DOCTYPE_NAME:tu,ERB_EXPR:Sg,IS_ALLOWED_URI:eu,IS_SCRIPT_OR_DATA:Eg,MUSTACHE_EXPR:kg,TMPLIT_EXPR:$g});const un={element:1,text:3,progressingInstruction:7,comment:8,document:9},_g=function(){return typeof window>"u"?null:window},Mg=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(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},_a=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function nu(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_g();const t=D=>nu(D);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==un.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:r,Node:a,Element:u,NodeFilter:c,NamedNodeMap:l=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:f,trustedTypes:b}=e,h=u.prototype,v=cn(h,"cloneNode"),S=cn(h,"remove"),$=cn(h,"nextSibling"),A=cn(h,"childNodes"),E=cn(h,"parentNode");if(typeof r=="function"){const D=n.createElement("template");D.content&&D.content.ownerDocument&&(n=D.content.ownerDocument)}let T,_="";const{implementation:B,createNodeIterator:F,createDocumentFragment:ne,getElementsByTagName:be}=n,{importNode:Qe}=i;let ee=_a();t.isSupported=typeof Zc=="function"&&typeof E=="function"&&B&&B.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Jt,ERB_EXPR:Tt,TMPLIT_EXPR:rt,DATA_ATTR:Vi,ARIA_ATTR:Gi,IS_SCRIPT_OR_DATA:Qi,ATTR_WHITESPACE:In,CUSTOM_ELEMENT:Yi}=Ta;let{IS_ALLOWED_URI:Rn}=Ta,X=null;const Dn=U({},[...Aa,...ks,...Ss,...$s,...xa]);let J=null;const Bn=U({},[...Ea,...As,...Ca,...Zn]);let G=Object.seal(Xs(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}})),at=null,Zt=null;const Ye=Object.seal(Xs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Nn=!0,x=!0,M=!1,N=!0,O=!1,Q=!0,H=!1,ue=!1,Xe=!1,_t=!1,On=!1,Fn=!1,lr=!0,cr=!1;const dd="user-content-";let Xi=!0,en=!1,Mt={},Ee=null;const Ji=U({},["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 ur=null;const dr=U({},["audio","video","img","source","image","track"]);let Zi=null;const pr=U({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Un="http://www.w3.org/1998/Math/MathML",Wn="http://www.w3.org/2000/svg",Oe="http://www.w3.org/1999/xhtml";let Pt=Oe,es=!1,ts=null;const pd=U({},[Un,Wn,Oe],bs);let Kn=U({},["mi","mo","mn","ms","mtext"]),zn=U({},["annotation-xml"]);const hd=U({},["title","style","font","a","script"]);let tn=null;const fd=["application/xhtml+xml","text/html"],gd="text/html";let te=null,Lt=null;const md=n.createElement("form"),hr=function(w){return w instanceof RegExp||w instanceof Function},ns=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Lt&&Lt===w)){if((!w||typeof w!="object")&&(w={}),w=Me(w),tn=fd.indexOf(w.PARSER_MEDIA_TYPE)===-1?gd:w.PARSER_MEDIA_TYPE,te=tn==="application/xhtml+xml"?bs:ci,X=we(w,"ALLOWED_TAGS")?U({},w.ALLOWED_TAGS,te):Dn,J=we(w,"ALLOWED_ATTR")?U({},w.ALLOWED_ATTR,te):Bn,ts=we(w,"ALLOWED_NAMESPACES")?U({},w.ALLOWED_NAMESPACES,bs):pd,Zi=we(w,"ADD_URI_SAFE_ATTR")?U(Me(pr),w.ADD_URI_SAFE_ATTR,te):pr,ur=we(w,"ADD_DATA_URI_TAGS")?U(Me(dr),w.ADD_DATA_URI_TAGS,te):dr,Ee=we(w,"FORBID_CONTENTS")?U({},w.FORBID_CONTENTS,te):Ji,at=we(w,"FORBID_TAGS")?U({},w.FORBID_TAGS,te):Me({}),Zt=we(w,"FORBID_ATTR")?U({},w.FORBID_ATTR,te):Me({}),Mt=we(w,"USE_PROFILES")?w.USE_PROFILES:!1,Nn=w.ALLOW_ARIA_ATTR!==!1,x=w.ALLOW_DATA_ATTR!==!1,M=w.ALLOW_UNKNOWN_PROTOCOLS||!1,N=w.ALLOW_SELF_CLOSE_IN_ATTR!==!1,O=w.SAFE_FOR_TEMPLATES||!1,Q=w.SAFE_FOR_XML!==!1,H=w.WHOLE_DOCUMENT||!1,_t=w.RETURN_DOM||!1,On=w.RETURN_DOM_FRAGMENT||!1,Fn=w.RETURN_TRUSTED_TYPE||!1,Xe=w.FORCE_BODY||!1,lr=w.SANITIZE_DOM!==!1,cr=w.SANITIZE_NAMED_PROPS||!1,Xi=w.KEEP_CONTENT!==!1,en=w.IN_PLACE||!1,Rn=w.ALLOWED_URI_REGEXP||eu,Pt=w.NAMESPACE||Oe,Kn=w.MATHML_TEXT_INTEGRATION_POINTS||Kn,zn=w.HTML_INTEGRATION_POINTS||zn,G=w.CUSTOM_ELEMENT_HANDLING||{},w.CUSTOM_ELEMENT_HANDLING&&hr(w.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(G.tagNameCheck=w.CUSTOM_ELEMENT_HANDLING.tagNameCheck),w.CUSTOM_ELEMENT_HANDLING&&hr(w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(G.attributeNameCheck=w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),w.CUSTOM_ELEMENT_HANDLING&&typeof w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(G.allowCustomizedBuiltInElements=w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),O&&(x=!1),On&&(_t=!0),Mt&&(X=U({},xa),J=[],Mt.html===!0&&(U(X,Aa),U(J,Ea)),Mt.svg===!0&&(U(X,ks),U(J,As),U(J,Zn)),Mt.svgFilters===!0&&(U(X,Ss),U(J,As),U(J,Zn)),Mt.mathMl===!0&&(U(X,$s),U(J,Ca),U(J,Zn))),w.ADD_TAGS&&(typeof w.ADD_TAGS=="function"?Ye.tagCheck=w.ADD_TAGS:(X===Dn&&(X=Me(X)),U(X,w.ADD_TAGS,te))),w.ADD_ATTR&&(typeof w.ADD_ATTR=="function"?Ye.attributeCheck=w.ADD_ATTR:(J===Bn&&(J=Me(J)),U(J,w.ADD_ATTR,te))),w.ADD_URI_SAFE_ATTR&&U(Zi,w.ADD_URI_SAFE_ATTR,te),w.FORBID_CONTENTS&&(Ee===Ji&&(Ee=Me(Ee)),U(Ee,w.FORBID_CONTENTS,te)),w.ADD_FORBID_CONTENTS&&(Ee===Ji&&(Ee=Me(Ee)),U(Ee,w.ADD_FORBID_CONTENTS,te)),Xi&&(X["#text"]=!0),H&&U(X,["html","head","body"]),X.table&&(U(X,["tbody"]),delete at.tbody),w.TRUSTED_TYPES_POLICY){if(typeof w.TRUSTED_TYPES_POLICY.createHTML!="function")throw ln('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof w.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ln('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');T=w.TRUSTED_TYPES_POLICY,_=T.createHTML("")}else T===void 0&&(T=Mg(b,s)),T!==null&&typeof _=="string"&&(_=T.createHTML(""));fe&&fe(w),Lt=w}},fr=U({},[...ks,...Ss,...bg]),gr=U({},[...$s,...wg]),yd=function(w){let C=E(w);(!C||!C.tagName)&&(C={namespaceURI:Pt,tagName:"template"});const I=ci(w.tagName),j=ci(C.tagName);return ts[w.namespaceURI]?w.namespaceURI===Wn?C.namespaceURI===Oe?I==="svg":C.namespaceURI===Un?I==="svg"&&(j==="annotation-xml"||Kn[j]):!!fr[I]:w.namespaceURI===Un?C.namespaceURI===Oe?I==="math":C.namespaceURI===Wn?I==="math"&&zn[j]:!!gr[I]:w.namespaceURI===Oe?C.namespaceURI===Wn&&!zn[j]||C.namespaceURI===Un&&!Kn[j]?!1:!gr[I]&&(hd[I]||!fr[I]):!!(tn==="application/xhtml+xml"&&ts[w.namespaceURI]):!1},Ce=function(w){rn(t.removed,{element:w});try{E(w).removeChild(w)}catch{S(w)}},lt=function(w,C){try{rn(t.removed,{attribute:C.getAttributeNode(w),from:C})}catch{rn(t.removed,{attribute:null,from:C})}if(C.removeAttribute(w),w==="is")if(_t||On)try{Ce(C)}catch{}else try{C.setAttribute(w,"")}catch{}},mr=function(w){let C=null,I=null;if(Xe)w="<remove></remove>"+w;else{const Z=ws(w,/^[\r\n\t ]+/);I=Z&&Z[0]}tn==="application/xhtml+xml"&&Pt===Oe&&(w='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+w+"</body></html>");const j=T?T.createHTML(w):w;if(Pt===Oe)try{C=new f().parseFromString(j,tn)}catch{}if(!C||!C.documentElement){C=B.createDocument(Pt,"template",null);try{C.documentElement.innerHTML=es?_:j}catch{}}const re=C.body||C.documentElement;return w&&I&&re.insertBefore(n.createTextNode(I),re.childNodes[0]||null),Pt===Oe?be.call(C,H?"html":"body")[0]:H?C.documentElement:re},yr=function(w){return F.call(w.ownerDocument||w,w,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},is=function(w){return w instanceof p&&(typeof w.nodeName!="string"||typeof w.textContent!="string"||typeof w.removeChild!="function"||!(w.attributes instanceof l)||typeof w.removeAttribute!="function"||typeof w.setAttribute!="function"||typeof w.namespaceURI!="string"||typeof w.insertBefore!="function"||typeof w.hasChildNodes!="function")},vr=function(w){return typeof a=="function"&&w instanceof a};function Fe(D,w,C){Jn(D,I=>{I.call(t,w,C,Lt)})}const br=function(w){let C=null;if(Fe(ee.beforeSanitizeElements,w,null),is(w))return Ce(w),!0;const I=te(w.nodeName);if(Fe(ee.uponSanitizeElement,w,{tagName:I,allowedTags:X}),Q&&w.hasChildNodes()&&!vr(w.firstElementChild)&&de(/<[/\w!]/g,w.innerHTML)&&de(/<[/\w!]/g,w.textContent)||w.nodeType===un.progressingInstruction||Q&&w.nodeType===un.comment&&de(/<[/\w]/g,w.data))return Ce(w),!0;if(!(Ye.tagCheck instanceof Function&&Ye.tagCheck(I))&&(!X[I]||at[I])){if(!at[I]&&kr(I)&&(G.tagNameCheck instanceof RegExp&&de(G.tagNameCheck,I)||G.tagNameCheck instanceof Function&&G.tagNameCheck(I)))return!1;if(Xi&&!Ee[I]){const j=E(w)||w.parentNode,re=A(w)||w.childNodes;if(re&&j){const Z=re.length;for(let me=Z-1;me>=0;--me){const Ue=v(re[me],!0);Ue.__removalCount=(w.__removalCount||0)+1,j.insertBefore(Ue,$(w))}}}return Ce(w),!0}return w instanceof u&&!yd(w)||(I==="noscript"||I==="noembed"||I==="noframes")&&de(/<\/no(script|embed|frames)/i,w.innerHTML)?(Ce(w),!0):(O&&w.nodeType===un.text&&(C=w.textContent,Jn([Jt,Tt,rt],j=>{C=an(C,j," ")}),w.textContent!==C&&(rn(t.removed,{element:w.cloneNode()}),w.textContent=C)),Fe(ee.afterSanitizeElements,w,null),!1)},wr=function(w,C,I){if(lr&&(C==="id"||C==="name")&&(I in n||I in md))return!1;if(!(x&&!Zt[C]&&de(Vi,C))){if(!(Nn&&de(Gi,C))){if(!(Ye.attributeCheck instanceof Function&&Ye.attributeCheck(C,w))){if(!J[C]||Zt[C]){if(!(kr(w)&&(G.tagNameCheck instanceof RegExp&&de(G.tagNameCheck,w)||G.tagNameCheck instanceof Function&&G.tagNameCheck(w))&&(G.attributeNameCheck instanceof RegExp&&de(G.attributeNameCheck,C)||G.attributeNameCheck instanceof Function&&G.attributeNameCheck(C,w))||C==="is"&&G.allowCustomizedBuiltInElements&&(G.tagNameCheck instanceof RegExp&&de(G.tagNameCheck,I)||G.tagNameCheck instanceof Function&&G.tagNameCheck(I))))return!1}else if(!Zi[C]){if(!de(Rn,an(I,In,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&w!=="script"&&gg(I,"data:")===0&&ur[w])){if(!(M&&!de(Qi,an(I,In,"")))){if(I)return!1}}}}}}}return!0},kr=function(w){return w!=="annotation-xml"&&ws(w,Yi)},Sr=function(w){Fe(ee.beforeSanitizeAttributes,w,null);const{attributes:C}=w;if(!C||is(w))return;const I={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:J,forceKeepAttr:void 0};let j=C.length;for(;j--;){const re=C[j],{name:Z,namespaceURI:me,value:Ue}=re,It=te(Z),ss=Ue;let se=Z==="value"?ss:mg(ss);if(I.attrName=It,I.attrValue=se,I.keepAttr=!0,I.forceKeepAttr=void 0,Fe(ee.uponSanitizeAttribute,w,I),se=I.attrValue,cr&&(It==="id"||It==="name")&&(lt(Z,w),se=dd+se),Q&&de(/((--!?|])>)|<\/(style|title|textarea)/i,se)){lt(Z,w);continue}if(It==="attributename"&&ws(se,"href")){lt(Z,w);continue}if(I.forceKeepAttr)continue;if(!I.keepAttr){lt(Z,w);continue}if(!N&&de(/\/>/i,se)){lt(Z,w);continue}O&&Jn([Jt,Tt,rt],Ar=>{se=an(se,Ar," ")});const $r=te(w.nodeName);if(!wr($r,It,se)){lt(Z,w);continue}if(T&&typeof b=="object"&&typeof b.getAttributeType=="function"&&!me)switch(b.getAttributeType($r,It)){case"TrustedHTML":{se=T.createHTML(se);break}case"TrustedScriptURL":{se=T.createScriptURL(se);break}}if(se!==ss)try{me?w.setAttributeNS(me,Z,se):w.setAttribute(Z,se),is(w)?Ce(w):$a(t.removed)}catch{lt(Z,w)}}Fe(ee.afterSanitizeAttributes,w,null)},vd=function D(w){let C=null;const I=yr(w);for(Fe(ee.beforeSanitizeShadowDOM,w,null);C=I.nextNode();)Fe(ee.uponSanitizeShadowNode,C,null),br(C),Sr(C),C.content instanceof o&&D(C.content);Fe(ee.afterSanitizeShadowDOM,w,null)};return t.sanitize=function(D){let w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,I=null,j=null,re=null;if(es=!D,es&&(D="<!-->"),typeof D!="string"&&!vr(D))if(typeof D.toString=="function"){if(D=D.toString(),typeof D!="string")throw ln("dirty is not a string, aborting")}else throw ln("toString is not a function");if(!t.isSupported)return D;if(ue||ns(w),t.removed=[],typeof D=="string"&&(en=!1),en){if(D.nodeName){const Ue=te(D.nodeName);if(!X[Ue]||at[Ue])throw ln("root node is forbidden and cannot be sanitized in-place")}}else if(D instanceof a)C=mr("<!---->"),I=C.ownerDocument.importNode(D,!0),I.nodeType===un.element&&I.nodeName==="BODY"||I.nodeName==="HTML"?C=I:C.appendChild(I);else{if(!_t&&!O&&!H&&D.indexOf("<")===-1)return T&&Fn?T.createHTML(D):D;if(C=mr(D),!C)return _t?null:Fn?_:""}C&&Xe&&Ce(C.firstChild);const Z=yr(en?D:C);for(;j=Z.nextNode();)br(j),Sr(j),j.content instanceof o&&vd(j.content);if(en)return D;if(_t){if(On)for(re=ne.call(C.ownerDocument);C.firstChild;)re.appendChild(C.firstChild);else re=C;return(J.shadowroot||J.shadowrootmode)&&(re=Qe.call(i,re,!0)),re}let me=H?C.outerHTML:C.innerHTML;return H&&X["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&de(tu,C.ownerDocument.doctype.name)&&(me="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
2268
- `+me),O&&Jn([Jt,Tt,rt],Ue=>{me=an(me,Ue," ")}),T&&Fn?T.createHTML(me):me},t.setConfig=function(){let D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ns(D),ue=!0},t.clearConfig=function(){Lt=null,ue=!1},t.isValidAttribute=function(D,w,C){Lt||ns({});const I=te(D),j=te(w);return wr(I,j,C)},t.addHook=function(D,w){typeof w=="function"&&rn(ee[D],w)},t.removeHook=function(D,w){if(w!==void 0){const C=hg(ee[D],w);return C===-1?void 0:fg(ee[D],C,1)[0]}return $a(ee[D])},t.removeHooks=function(D){ee[D]=[]},t.removeAllHooks=function(){ee=_a()},t}var eo=nu();function zo(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Et=zo();function iu(e){Et=e}var Sn={exec:()=>null};function z(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(s,o)=>{let r=typeof o=="string"?o:o.source;return r=r.replace(pe.caret,"$1"),n=n.replace(s,r),i},getRegex:()=>new RegExp(n,t)};return i}var Pg=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),pe={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")},Lg=/^(?:[ \t]*(?:\n|$))+/,Ig=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Rg=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Pn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Dg=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,qo=/(?:[*+-]|\d{1,9}[.)])/,su=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ou=z(su).replace(/bull/g,qo).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(),Bg=z(su).replace(/bull/g,qo).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(),Ho=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ng=/^[^\n]+/,jo=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Og=z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",jo).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Fg=z(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,qo).getRegex(),zi="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",Vo=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ug=z("^ {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",Vo).replace("tag",zi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ru=z(Ho).replace("hr",Pn).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",zi).getRegex(),Wg=z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ru).getRegex(),Go={blockquote:Wg,code:Ig,def:Og,fences:Rg,heading:Dg,hr:Pn,html:Ug,lheading:ou,list:Fg,newline:Lg,paragraph:ru,table:Sn,text:Ng},Ma=z("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Pn).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",zi).getRegex(),Kg={...Go,lheading:Bg,table:Ma,paragraph:z(Ho).replace("hr",Pn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ma).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",zi).getRegex()},zg={...Go,html:z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Vo).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:Sn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:z(Ho).replace("hr",Pn).replace("heading",` *#{1,6} *[^
2269
- ]`).replace("lheading",ou).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},qg=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Hg=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,au=/^( {2,}|\\)\n(?!\s*$)/,jg=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,qi=/[\p{P}\p{S}]/u,Qo=/[\s\p{P}\p{S}]/u,lu=/[^\s\p{P}\p{S}]/u,Vg=z(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Qo).getRegex(),cu=/(?!~)[\p{P}\p{S}]/u,Gg=/(?!~)[\s\p{P}\p{S}]/u,Qg=/(?:[^\s\p{P}\p{S}]|~)/u,Yg=z(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Pg?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),uu=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Xg=z(uu,"u").replace(/punct/g,qi).getRegex(),Jg=z(uu,"u").replace(/punct/g,cu).getRegex(),du="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Zg=z(du,"gu").replace(/notPunctSpace/g,lu).replace(/punctSpace/g,Qo).replace(/punct/g,qi).getRegex(),em=z(du,"gu").replace(/notPunctSpace/g,Qg).replace(/punctSpace/g,Gg).replace(/punct/g,cu).getRegex(),tm=z("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,lu).replace(/punctSpace/g,Qo).replace(/punct/g,qi).getRegex(),nm=z(/\\(punct)/,"gu").replace(/punct/g,qi).getRegex(),im=z(/^<(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(),sm=z(Vo).replace("(?:-->|$)","-->").getRegex(),om=z("^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",sm).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),xi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,rm=z(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",xi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),pu=z(/^!?\[(label)\]\[(ref)\]/).replace("label",xi).replace("ref",jo).getRegex(),hu=z(/^!?\[(ref)\](?:\[\])?/).replace("ref",jo).getRegex(),am=z("reflink|nolink(?!\\()","g").replace("reflink",pu).replace("nolink",hu).getRegex(),Pa=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Yo={_backpedal:Sn,anyPunctuation:nm,autolink:im,blockSkip:Yg,br:au,code:Hg,del:Sn,emStrongLDelim:Xg,emStrongRDelimAst:Zg,emStrongRDelimUnd:tm,escape:qg,link:rm,nolink:hu,punctuation:Vg,reflink:pu,reflinkSearch:am,tag:om,text:jg,url:Sn},lm={...Yo,link:z(/^!?\[(label)\]\((.*?)\)/).replace("label",xi).getRegex(),reflink:z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",xi).getRegex()},to={...Yo,emStrongRDelimAst:em,emStrongLDelim:Jg,url:z(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Pa).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:z(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Pa).getRegex()},cm={...to,br:z(au).replace("{2,}","*").getRegex(),text:z(to.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ei={normal:Go,gfm:Kg,pedantic:zg},dn={normal:Yo,gfm:to,breaks:cm,pedantic:lm},um={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},La=e=>um[e];function Ke(e,t){if(t){if(pe.escapeTest.test(e))return e.replace(pe.escapeReplace,La)}else if(pe.escapeTestNoEncode.test(e))return e.replace(pe.escapeReplaceNoEncode,La);return e}function Ia(e){try{e=encodeURI(e).replace(pe.percentDecode,"%")}catch{return null}return e}function Ra(e,t){var o;let n=e.replace(pe.findPipe,(r,a,u)=>{let c=!1,l=a;for(;--l>=0&&u[l]==="\\";)c=!c;return c?"|":" |"}),i=n.split(pe.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(pe.slashPipe,"|");return i}function pn(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 dm(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 Da(e,t,n,i,s){let o=t.href,r=t.title||null,a=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:r,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,u}function pm(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
2265
+ ${i?ng(i,e):k}
2266
+ ${s?ig(s,e):k}
2267
+ `}const Xc={CHILD:2},Jc=e=>(...t)=>({_$litDirective$:e,values:t});let Zc=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:ag}=qd,wa=e=>e,ka=()=>document.createComment(""),on=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const r=i.insertBefore(ka(),s),a=i.insertBefore(ka(),s);n=new ag(r,a,e,e.options)}else{const r=n._$AB.nextSibling,a=n._$AM,u=a!==e;if(u){let c;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==a._$AU&&n._$AP(c)}if(r!==s||u){let c=n._$AA;for(;c!==r;){const l=wa(c).nextSibling;wa(i).insertBefore(c,s),c=l}}}return n},ut=(e,t,n=e)=>(e._$AI(t,n),e),lg={},cg=(e,t=lg)=>e._$AH=t,ug=e=>e._$AH,bs=e=>{e._$AR(),e._$AA.remove()};const Sa=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},dg=Jc(class extends Zc{constructor(e){if(super(e),e.type!==Xc.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 r=0;for(const a of e)s[r]=i?i(a,r):r,o[r]=n(a,r),r++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=ug(e),{values:o,keys:r}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=r,o;const a=this.ut??(this.ut=[]),u=[];let c,l,p=0,f=s.length-1,b=0,h=o.length-1;for(;p<=f&&b<=h;)if(s[p]===null)p++;else if(s[f]===null)f--;else if(a[p]===r[b])u[b]=ut(s[p],o[b]),p++,b++;else if(a[f]===r[h])u[h]=ut(s[f],o[h]),f--,h--;else if(a[p]===r[h])u[h]=ut(s[p],o[h]),on(e,u[h+1],s[p]),p++,h--;else if(a[f]===r[b])u[b]=ut(s[f],o[b]),on(e,s[p],s[f]),f--,b++;else if(c===void 0&&(c=Sa(r,b,h),l=Sa(a,p,f)),c.has(a[p]))if(c.has(a[f])){const v=l.get(r[b]),S=v!==void 0?s[v]:null;if(S===null){const $=on(e,s[p]);ut($,o[b]),u[b]=$}else u[b]=ut(S,o[b]),on(e,s[p],S),s[v]=null;b++}else bs(s[f]),f--;else bs(s[p]),p++;for(;b<=h;){const v=on(e,u[h+1]);ut(v,o[b]),u[b++]=v}for(;p<=f;){const v=s[p++];v!==null&&bs(v)}return this.ut=r,cg(e,u),nt}});class Xs extends Zc{constructor(t){if(super(t),this.it=k,t.type!==Xc.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===k||t==null)return this._t=void 0,this.it=t;if(t===nt)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:[]}}}Xs.directiveName="unsafeHTML",Xs.resultType=1;const Ai=Jc(Xs);const{entries:eu,setPrototypeOf:$a,isFrozen:pg,getPrototypeOf:hg,getOwnPropertyDescriptor:fg}=Object;let{freeze:fe,seal:ve,create:Js}=Object,{apply:Zs,construct:eo}=typeof Reflect<"u"&&Reflect;fe||(fe=function(t){return t});ve||(ve=function(t){return t});Zs||(Zs=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)});eo||(eo=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 Jn=ge(Array.prototype.forEach),gg=ge(Array.prototype.lastIndexOf),Aa=ge(Array.prototype.pop),rn=ge(Array.prototype.push),mg=ge(Array.prototype.splice),ci=ge(String.prototype.toLowerCase),ws=ge(String.prototype.toString),ks=ge(String.prototype.match),an=ge(String.prototype.replace),yg=ge(String.prototype.indexOf),vg=ge(String.prototype.trim),we=ge(Object.prototype.hasOwnProperty),de=ge(RegExp.prototype.test),ln=bg(TypeError);function ge(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 Zs(e,t,i)}}function bg(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return eo(e,n)}}function U(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ci;$a&&$a(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(pg(t)||(t[i]=o),s=o)}e[s]=!0}return e}function wg(e){for(let t=0;t<e.length;t++)we(e,t)||(e[t]=null);return e}function Me(e){const t=Js(null);for(const[n,i]of eu(e))we(e,n)&&(Array.isArray(i)?t[n]=wg(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Me(i):t[n]=i);return t}function cn(e,t){for(;e!==null;){const i=fg(e,t);if(i){if(i.get)return ge(i.get);if(typeof i.value=="function")return ge(i.value)}e=hg(e)}function n(){return null}return n}const xa=fe(["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"]),Ss=fe(["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"]),$s=fe(["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"]),kg=fe(["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"]),As=fe(["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"]),Sg=fe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ea=fe(["#text"]),Ca=fe(["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"]),xs=fe(["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"]),Ta=fe(["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"]),Zn=fe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),$g=ve(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ag=ve(/<%[\w\W]*|[\w\W]*%>/gm),xg=ve(/\$\{[\w\W]*/gm),Eg=ve(/^data-[\-\w.\u00B7-\uFFFF]+$/),Cg=ve(/^aria-[\-\w]+$/),tu=ve(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Tg=ve(/^(?:\w+script|data):/i),_g=ve(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),nu=ve(/^html$/i),Mg=ve(/^[a-z][.\w]*(-[.\w]+)+$/i);var _a=Object.freeze({__proto__:null,ARIA_ATTR:Cg,ATTR_WHITESPACE:_g,CUSTOM_ELEMENT:Mg,DATA_ATTR:Eg,DOCTYPE_NAME:nu,ERB_EXPR:Ag,IS_ALLOWED_URI:tu,IS_SCRIPT_OR_DATA:Tg,MUSTACHE_EXPR:$g,TMPLIT_EXPR:xg});const un={element:1,text:3,progressingInstruction:7,comment:8,document:9},Pg=function(){return typeof window>"u"?null:window},Lg=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(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Ma=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function iu(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Pg();const t=R=>iu(R);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==un.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:r,Node:a,Element:u,NodeFilter:c,NamedNodeMap:l=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:f,trustedTypes:b}=e,h=u.prototype,v=cn(h,"cloneNode"),S=cn(h,"remove"),$=cn(h,"nextSibling"),A=cn(h,"childNodes"),E=cn(h,"parentNode");if(typeof r=="function"){const R=n.createElement("template");R.content&&R.content.ownerDocument&&(n=R.content.ownerDocument)}let T,_="";const{implementation:D,createNodeIterator:F,createDocumentFragment:ne,getElementsByTagName:be}=n,{importNode:Qe}=i;let ee=Ma();t.isSupported=typeof eu=="function"&&typeof E=="function"&&D&&D.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Jt,ERB_EXPR:_t,TMPLIT_EXPR:ot,DATA_ATTR:Gi,ARIA_ATTR:Qi,IS_SCRIPT_OR_DATA:Yi,ATTR_WHITESPACE:In,CUSTOM_ELEMENT:Xi}=_a;let{IS_ALLOWED_URI:Rn}=_a,X=null;const Dn=U({},[...xa,...Ss,...$s,...As,...Ea]);let J=null;const Bn=U({},[...Ca,...xs,...Ta,...Zn]);let G=Object.seal(Js(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}})),rt=null,Zt=null;const Ye=Object.seal(Js(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Nn=!0,x=!0,M=!1,N=!0,O=!1,Q=!0,H=!1,ue=!1,Xe=!1,Mt=!1,On=!1,Fn=!1,cr=!0,ur=!1;const hd="user-content-";let Ji=!0,en=!1,Pt={},Ee=null;const Zi=U({},["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 dr=null;const pr=U({},["audio","video","img","source","image","track"]);let es=null;const hr=U({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Un="http://www.w3.org/1998/Math/MathML",Wn="http://www.w3.org/2000/svg",Oe="http://www.w3.org/1999/xhtml";let Lt=Oe,ts=!1,ns=null;const fd=U({},[Un,Wn,Oe],ws);let Kn=U({},["mi","mo","mn","ms","mtext"]),zn=U({},["annotation-xml"]);const gd=U({},["title","style","font","a","script"]);let tn=null;const md=["application/xhtml+xml","text/html"],yd="text/html";let te=null,It=null;const vd=n.createElement("form"),fr=function(w){return w instanceof RegExp||w instanceof Function},is=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(It&&It===w)){if((!w||typeof w!="object")&&(w={}),w=Me(w),tn=md.indexOf(w.PARSER_MEDIA_TYPE)===-1?yd:w.PARSER_MEDIA_TYPE,te=tn==="application/xhtml+xml"?ws:ci,X=we(w,"ALLOWED_TAGS")?U({},w.ALLOWED_TAGS,te):Dn,J=we(w,"ALLOWED_ATTR")?U({},w.ALLOWED_ATTR,te):Bn,ns=we(w,"ALLOWED_NAMESPACES")?U({},w.ALLOWED_NAMESPACES,ws):fd,es=we(w,"ADD_URI_SAFE_ATTR")?U(Me(hr),w.ADD_URI_SAFE_ATTR,te):hr,dr=we(w,"ADD_DATA_URI_TAGS")?U(Me(pr),w.ADD_DATA_URI_TAGS,te):pr,Ee=we(w,"FORBID_CONTENTS")?U({},w.FORBID_CONTENTS,te):Zi,rt=we(w,"FORBID_TAGS")?U({},w.FORBID_TAGS,te):Me({}),Zt=we(w,"FORBID_ATTR")?U({},w.FORBID_ATTR,te):Me({}),Pt=we(w,"USE_PROFILES")?w.USE_PROFILES:!1,Nn=w.ALLOW_ARIA_ATTR!==!1,x=w.ALLOW_DATA_ATTR!==!1,M=w.ALLOW_UNKNOWN_PROTOCOLS||!1,N=w.ALLOW_SELF_CLOSE_IN_ATTR!==!1,O=w.SAFE_FOR_TEMPLATES||!1,Q=w.SAFE_FOR_XML!==!1,H=w.WHOLE_DOCUMENT||!1,Mt=w.RETURN_DOM||!1,On=w.RETURN_DOM_FRAGMENT||!1,Fn=w.RETURN_TRUSTED_TYPE||!1,Xe=w.FORCE_BODY||!1,cr=w.SANITIZE_DOM!==!1,ur=w.SANITIZE_NAMED_PROPS||!1,Ji=w.KEEP_CONTENT!==!1,en=w.IN_PLACE||!1,Rn=w.ALLOWED_URI_REGEXP||tu,Lt=w.NAMESPACE||Oe,Kn=w.MATHML_TEXT_INTEGRATION_POINTS||Kn,zn=w.HTML_INTEGRATION_POINTS||zn,G=w.CUSTOM_ELEMENT_HANDLING||{},w.CUSTOM_ELEMENT_HANDLING&&fr(w.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(G.tagNameCheck=w.CUSTOM_ELEMENT_HANDLING.tagNameCheck),w.CUSTOM_ELEMENT_HANDLING&&fr(w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(G.attributeNameCheck=w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),w.CUSTOM_ELEMENT_HANDLING&&typeof w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(G.allowCustomizedBuiltInElements=w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),O&&(x=!1),On&&(Mt=!0),Pt&&(X=U({},Ea),J=[],Pt.html===!0&&(U(X,xa),U(J,Ca)),Pt.svg===!0&&(U(X,Ss),U(J,xs),U(J,Zn)),Pt.svgFilters===!0&&(U(X,$s),U(J,xs),U(J,Zn)),Pt.mathMl===!0&&(U(X,As),U(J,Ta),U(J,Zn))),w.ADD_TAGS&&(typeof w.ADD_TAGS=="function"?Ye.tagCheck=w.ADD_TAGS:(X===Dn&&(X=Me(X)),U(X,w.ADD_TAGS,te))),w.ADD_ATTR&&(typeof w.ADD_ATTR=="function"?Ye.attributeCheck=w.ADD_ATTR:(J===Bn&&(J=Me(J)),U(J,w.ADD_ATTR,te))),w.ADD_URI_SAFE_ATTR&&U(es,w.ADD_URI_SAFE_ATTR,te),w.FORBID_CONTENTS&&(Ee===Zi&&(Ee=Me(Ee)),U(Ee,w.FORBID_CONTENTS,te)),w.ADD_FORBID_CONTENTS&&(Ee===Zi&&(Ee=Me(Ee)),U(Ee,w.ADD_FORBID_CONTENTS,te)),Ji&&(X["#text"]=!0),H&&U(X,["html","head","body"]),X.table&&(U(X,["tbody"]),delete rt.tbody),w.TRUSTED_TYPES_POLICY){if(typeof w.TRUSTED_TYPES_POLICY.createHTML!="function")throw ln('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof w.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ln('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');T=w.TRUSTED_TYPES_POLICY,_=T.createHTML("")}else T===void 0&&(T=Lg(b,s)),T!==null&&typeof _=="string"&&(_=T.createHTML(""));fe&&fe(w),It=w}},gr=U({},[...Ss,...$s,...kg]),mr=U({},[...As,...Sg]),bd=function(w){let C=E(w);(!C||!C.tagName)&&(C={namespaceURI:Lt,tagName:"template"});const I=ci(w.tagName),j=ci(C.tagName);return ns[w.namespaceURI]?w.namespaceURI===Wn?C.namespaceURI===Oe?I==="svg":C.namespaceURI===Un?I==="svg"&&(j==="annotation-xml"||Kn[j]):!!gr[I]:w.namespaceURI===Un?C.namespaceURI===Oe?I==="math":C.namespaceURI===Wn?I==="math"&&zn[j]:!!mr[I]:w.namespaceURI===Oe?C.namespaceURI===Wn&&!zn[j]||C.namespaceURI===Un&&!Kn[j]?!1:!mr[I]&&(gd[I]||!gr[I]):!!(tn==="application/xhtml+xml"&&ns[w.namespaceURI]):!1},Ce=function(w){rn(t.removed,{element:w});try{E(w).removeChild(w)}catch{S(w)}},at=function(w,C){try{rn(t.removed,{attribute:C.getAttributeNode(w),from:C})}catch{rn(t.removed,{attribute:null,from:C})}if(C.removeAttribute(w),w==="is")if(Mt||On)try{Ce(C)}catch{}else try{C.setAttribute(w,"")}catch{}},yr=function(w){let C=null,I=null;if(Xe)w="<remove></remove>"+w;else{const Z=ks(w,/^[\r\n\t ]+/);I=Z&&Z[0]}tn==="application/xhtml+xml"&&Lt===Oe&&(w='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+w+"</body></html>");const j=T?T.createHTML(w):w;if(Lt===Oe)try{C=new f().parseFromString(j,tn)}catch{}if(!C||!C.documentElement){C=D.createDocument(Lt,"template",null);try{C.documentElement.innerHTML=ts?_:j}catch{}}const re=C.body||C.documentElement;return w&&I&&re.insertBefore(n.createTextNode(I),re.childNodes[0]||null),Lt===Oe?be.call(C,H?"html":"body")[0]:H?C.documentElement:re},vr=function(w){return F.call(w.ownerDocument||w,w,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ss=function(w){return w instanceof p&&(typeof w.nodeName!="string"||typeof w.textContent!="string"||typeof w.removeChild!="function"||!(w.attributes instanceof l)||typeof w.removeAttribute!="function"||typeof w.setAttribute!="function"||typeof w.namespaceURI!="string"||typeof w.insertBefore!="function"||typeof w.hasChildNodes!="function")},br=function(w){return typeof a=="function"&&w instanceof a};function Fe(R,w,C){Jn(R,I=>{I.call(t,w,C,It)})}const wr=function(w){let C=null;if(Fe(ee.beforeSanitizeElements,w,null),ss(w))return Ce(w),!0;const I=te(w.nodeName);if(Fe(ee.uponSanitizeElement,w,{tagName:I,allowedTags:X}),Q&&w.hasChildNodes()&&!br(w.firstElementChild)&&de(/<[/\w!]/g,w.innerHTML)&&de(/<[/\w!]/g,w.textContent)||w.nodeType===un.progressingInstruction||Q&&w.nodeType===un.comment&&de(/<[/\w]/g,w.data))return Ce(w),!0;if(!(Ye.tagCheck instanceof Function&&Ye.tagCheck(I))&&(!X[I]||rt[I])){if(!rt[I]&&Sr(I)&&(G.tagNameCheck instanceof RegExp&&de(G.tagNameCheck,I)||G.tagNameCheck instanceof Function&&G.tagNameCheck(I)))return!1;if(Ji&&!Ee[I]){const j=E(w)||w.parentNode,re=A(w)||w.childNodes;if(re&&j){const Z=re.length;for(let me=Z-1;me>=0;--me){const Ue=v(re[me],!0);Ue.__removalCount=(w.__removalCount||0)+1,j.insertBefore(Ue,$(w))}}}return Ce(w),!0}return w instanceof u&&!bd(w)||(I==="noscript"||I==="noembed"||I==="noframes")&&de(/<\/no(script|embed|frames)/i,w.innerHTML)?(Ce(w),!0):(O&&w.nodeType===un.text&&(C=w.textContent,Jn([Jt,_t,ot],j=>{C=an(C,j," ")}),w.textContent!==C&&(rn(t.removed,{element:w.cloneNode()}),w.textContent=C)),Fe(ee.afterSanitizeElements,w,null),!1)},kr=function(w,C,I){if(cr&&(C==="id"||C==="name")&&(I in n||I in vd))return!1;if(!(x&&!Zt[C]&&de(Gi,C))){if(!(Nn&&de(Qi,C))){if(!(Ye.attributeCheck instanceof Function&&Ye.attributeCheck(C,w))){if(!J[C]||Zt[C]){if(!(Sr(w)&&(G.tagNameCheck instanceof RegExp&&de(G.tagNameCheck,w)||G.tagNameCheck instanceof Function&&G.tagNameCheck(w))&&(G.attributeNameCheck instanceof RegExp&&de(G.attributeNameCheck,C)||G.attributeNameCheck instanceof Function&&G.attributeNameCheck(C,w))||C==="is"&&G.allowCustomizedBuiltInElements&&(G.tagNameCheck instanceof RegExp&&de(G.tagNameCheck,I)||G.tagNameCheck instanceof Function&&G.tagNameCheck(I))))return!1}else if(!es[C]){if(!de(Rn,an(I,In,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&w!=="script"&&yg(I,"data:")===0&&dr[w])){if(!(M&&!de(Yi,an(I,In,"")))){if(I)return!1}}}}}}}return!0},Sr=function(w){return w!=="annotation-xml"&&ks(w,Xi)},$r=function(w){Fe(ee.beforeSanitizeAttributes,w,null);const{attributes:C}=w;if(!C||ss(w))return;const I={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:J,forceKeepAttr:void 0};let j=C.length;for(;j--;){const re=C[j],{name:Z,namespaceURI:me,value:Ue}=re,Rt=te(Z),os=Ue;let se=Z==="value"?os:vg(os);if(I.attrName=Rt,I.attrValue=se,I.keepAttr=!0,I.forceKeepAttr=void 0,Fe(ee.uponSanitizeAttribute,w,I),se=I.attrValue,ur&&(Rt==="id"||Rt==="name")&&(at(Z,w),se=hd+se),Q&&de(/((--!?|])>)|<\/(style|title|textarea)/i,se)){at(Z,w);continue}if(Rt==="attributename"&&ks(se,"href")){at(Z,w);continue}if(I.forceKeepAttr)continue;if(!I.keepAttr){at(Z,w);continue}if(!N&&de(/\/>/i,se)){at(Z,w);continue}O&&Jn([Jt,_t,ot],xr=>{se=an(se,xr," ")});const Ar=te(w.nodeName);if(!kr(Ar,Rt,se)){at(Z,w);continue}if(T&&typeof b=="object"&&typeof b.getAttributeType=="function"&&!me)switch(b.getAttributeType(Ar,Rt)){case"TrustedHTML":{se=T.createHTML(se);break}case"TrustedScriptURL":{se=T.createScriptURL(se);break}}if(se!==os)try{me?w.setAttributeNS(me,Z,se):w.setAttribute(Z,se),ss(w)?Ce(w):Aa(t.removed)}catch{at(Z,w)}}Fe(ee.afterSanitizeAttributes,w,null)},wd=function R(w){let C=null;const I=vr(w);for(Fe(ee.beforeSanitizeShadowDOM,w,null);C=I.nextNode();)Fe(ee.uponSanitizeShadowNode,C,null),wr(C),$r(C),C.content instanceof o&&R(C.content);Fe(ee.afterSanitizeShadowDOM,w,null)};return t.sanitize=function(R){let w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,I=null,j=null,re=null;if(ts=!R,ts&&(R="<!-->"),typeof R!="string"&&!br(R))if(typeof R.toString=="function"){if(R=R.toString(),typeof R!="string")throw ln("dirty is not a string, aborting")}else throw ln("toString is not a function");if(!t.isSupported)return R;if(ue||is(w),t.removed=[],typeof R=="string"&&(en=!1),en){if(R.nodeName){const Ue=te(R.nodeName);if(!X[Ue]||rt[Ue])throw ln("root node is forbidden and cannot be sanitized in-place")}}else if(R instanceof a)C=yr("<!---->"),I=C.ownerDocument.importNode(R,!0),I.nodeType===un.element&&I.nodeName==="BODY"||I.nodeName==="HTML"?C=I:C.appendChild(I);else{if(!Mt&&!O&&!H&&R.indexOf("<")===-1)return T&&Fn?T.createHTML(R):R;if(C=yr(R),!C)return Mt?null:Fn?_:""}C&&Xe&&Ce(C.firstChild);const Z=vr(en?R:C);for(;j=Z.nextNode();)wr(j),$r(j),j.content instanceof o&&wd(j.content);if(en)return R;if(Mt){if(On)for(re=ne.call(C.ownerDocument);C.firstChild;)re.appendChild(C.firstChild);else re=C;return(J.shadowroot||J.shadowrootmode)&&(re=Qe.call(i,re,!0)),re}let me=H?C.outerHTML:C.innerHTML;return H&&X["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&de(nu,C.ownerDocument.doctype.name)&&(me="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
2268
+ `+me),O&&Jn([Jt,_t,ot],Ue=>{me=an(me,Ue," ")}),T&&Fn?T.createHTML(me):me},t.setConfig=function(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};is(R),ue=!0},t.clearConfig=function(){It=null,ue=!1},t.isValidAttribute=function(R,w,C){It||is({});const I=te(R),j=te(w);return kr(I,j,C)},t.addHook=function(R,w){typeof w=="function"&&rn(ee[R],w)},t.removeHook=function(R,w){if(w!==void 0){const C=gg(ee[R],w);return C===-1?void 0:mg(ee[R],C,1)[0]}return Aa(ee[R])},t.removeHooks=function(R){ee[R]=[]},t.removeAllHooks=function(){ee=Ma()},t}var to=iu();function qo(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ct=qo();function su(e){Ct=e}var Sn={exec:()=>null};function K(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(s,o)=>{let r=typeof o=="string"?o:o.source;return r=r.replace(pe.caret,"$1"),n=n.replace(s,r),i},getRegex:()=>new RegExp(n,t)};return i}var Ig=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),pe={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")},Rg=/^(?:[ \t]*(?:\n|$))+/,Dg=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Bg=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Pn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ng=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ho=/(?:[*+-]|\d{1,9}[.)])/,ou=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ru=K(ou).replace(/bull/g,Ho).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(),Og=K(ou).replace(/bull/g,Ho).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(),jo=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Fg=/^[^\n]+/,Vo=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ug=K(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Vo).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Wg=K(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ho).getRegex(),qi="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",Go=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Kg=K("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Go).replace("tag",qi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),au=K(jo).replace("hr",Pn).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",qi).getRegex(),zg=K(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",au).getRegex(),Qo={blockquote:zg,code:Dg,def:Ug,fences:Bg,heading:Ng,hr:Pn,html:Kg,lheading:ru,list:Wg,newline:Rg,paragraph:au,table:Sn,text:Fg},Pa=K("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Pn).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",qi).getRegex(),qg={...Qo,lheading:Og,table:Pa,paragraph:K(jo).replace("hr",Pn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Pa).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",qi).getRegex()},Hg={...Qo,html:K(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Go).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:Sn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:K(jo).replace("hr",Pn).replace("heading",` *#{1,6} *[^
2269
+ ]`).replace("lheading",ru).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},jg=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Vg=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,lu=/^( {2,}|\\)\n(?!\s*$)/,Gg=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Hi=/[\p{P}\p{S}]/u,Yo=/[\s\p{P}\p{S}]/u,cu=/[^\s\p{P}\p{S}]/u,Qg=K(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Yo).getRegex(),uu=/(?!~)[\p{P}\p{S}]/u,Yg=/(?!~)[\s\p{P}\p{S}]/u,Xg=/(?:[^\s\p{P}\p{S}]|~)/u,Jg=K(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Ig?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),du=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Zg=K(du,"u").replace(/punct/g,Hi).getRegex(),em=K(du,"u").replace(/punct/g,uu).getRegex(),pu="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",tm=K(pu,"gu").replace(/notPunctSpace/g,cu).replace(/punctSpace/g,Yo).replace(/punct/g,Hi).getRegex(),nm=K(pu,"gu").replace(/notPunctSpace/g,Xg).replace(/punctSpace/g,Yg).replace(/punct/g,uu).getRegex(),im=K("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,cu).replace(/punctSpace/g,Yo).replace(/punct/g,Hi).getRegex(),sm=K(/\\(punct)/,"gu").replace(/punct/g,Hi).getRegex(),om=K(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),rm=K(Go).replace("(?:-->|$)","-->").getRegex(),am=K("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",rm).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),xi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,lm=K(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",xi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),hu=K(/^!?\[(label)\]\[(ref)\]/).replace("label",xi).replace("ref",Vo).getRegex(),fu=K(/^!?\[(ref)\](?:\[\])?/).replace("ref",Vo).getRegex(),cm=K("reflink|nolink(?!\\()","g").replace("reflink",hu).replace("nolink",fu).getRegex(),La=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Xo={_backpedal:Sn,anyPunctuation:sm,autolink:om,blockSkip:Jg,br:lu,code:Vg,del:Sn,emStrongLDelim:Zg,emStrongRDelimAst:tm,emStrongRDelimUnd:im,escape:jg,link:lm,nolink:fu,punctuation:Qg,reflink:hu,reflinkSearch:cm,tag:am,text:Gg,url:Sn},um={...Xo,link:K(/^!?\[(label)\]\((.*?)\)/).replace("label",xi).getRegex(),reflink:K(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",xi).getRegex()},no={...Xo,emStrongRDelimAst:nm,emStrongLDelim:em,url:K(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",La).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:K(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",La).getRegex()},dm={...no,br:K(lu).replace("{2,}","*").getRegex(),text:K(no.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ei={normal:Qo,gfm:qg,pedantic:Hg},dn={normal:Xo,gfm:no,breaks:dm,pedantic:um},pm={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ia=e=>pm[e];function Ke(e,t){if(t){if(pe.escapeTest.test(e))return e.replace(pe.escapeReplace,Ia)}else if(pe.escapeTestNoEncode.test(e))return e.replace(pe.escapeReplaceNoEncode,Ia);return e}function Ra(e){try{e=encodeURI(e).replace(pe.percentDecode,"%")}catch{return null}return e}function Da(e,t){var o;let n=e.replace(pe.findPipe,(r,a,u)=>{let c=!1,l=a;for(;--l>=0&&u[l]==="\\";)c=!c;return c?"|":" |"}),i=n.split(pe.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(pe.slashPipe,"|");return i}function pn(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 hm(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 Ba(e,t,n,i,s){let o=t.href,r=t.title||null,a=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:r,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,u}function fm(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
2270
2270
  `).map(o=>{let r=o.match(n.other.beginningSpace);if(r===null)return o;let[a]=r;return a.length>=s.length?o.slice(s.length):o}).join(`
2271
- `)}var Ei=class{constructor(e){W(this,"options");W(this,"rules");W(this,"lexer");this.options=e||Et}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:pn(n,`
2272
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=pm(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=pn(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:pn(t[0],`
2271
+ `)}var Ei=class{constructor(e){W(this,"options");W(this,"rules");W(this,"lexer");this.options=e||Ct}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:pn(n,`
2272
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=fm(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=pn(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:pn(t[0],`
2273
2273
  `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=pn(t[0],`
2274
2274
  `).split(`
2275
2275
  `),i="",s="",o=[];for(;n.length>0;){let r=!1,a=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))a.push(n[u]),r=!0;else if(!r)a.push(n[u]);else break;n=n.slice(u);let c=a.join(`
@@ -2284,13 +2284,13 @@ ${l}`:l;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
2284
2284
  `);continue}}return{type:"blockquote",raw:i,tokens:o,text:s}}}list(e){var n,i;let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),o=s.length>1,r={type:"list",raw:"",ordered:o,start:o?+s.slice(0,-1):"",loose:!1,items:[]};s=o?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=o?s:"[*+-]");let a=this.rules.other.listItemRegex(s),u=!1;for(;e;){let l=!1,p="",f="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let b=t[2].split(`
2285
2285
  `,1)[0].replace(this.rules.other.listReplaceTabs,$=>" ".repeat(3*$.length)),h=e.split(`
2286
2286
  `,1)[0],v=!b.trim(),S=0;if(this.options.pedantic?(S=2,f=b.trimStart()):v?S=t[1].length+1:(S=t[2].search(this.rules.other.nonSpaceChar),S=S>4?1:S,f=b.slice(S),S+=t[1].length),v&&this.rules.other.blankLine.test(h)&&(p+=h+`
2287
- `,e=e.substring(h.length+1),l=!0),!l){let $=this.rules.other.nextBulletRegex(S),A=this.rules.other.hrRegex(S),E=this.rules.other.fencesBeginRegex(S),T=this.rules.other.headingBeginRegex(S),_=this.rules.other.htmlBeginRegex(S);for(;e;){let B=e.split(`
2288
- `,1)[0],F;if(h=B,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),F=h):F=h.replace(this.rules.other.tabCharGlobal," "),E.test(h)||T.test(h)||_.test(h)||$.test(h)||A.test(h))break;if(F.search(this.rules.other.nonSpaceChar)>=S||!h.trim())f+=`
2287
+ `,e=e.substring(h.length+1),l=!0),!l){let $=this.rules.other.nextBulletRegex(S),A=this.rules.other.hrRegex(S),E=this.rules.other.fencesBeginRegex(S),T=this.rules.other.headingBeginRegex(S),_=this.rules.other.htmlBeginRegex(S);for(;e;){let D=e.split(`
2288
+ `,1)[0],F;if(h=D,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),F=h):F=h.replace(this.rules.other.tabCharGlobal," "),E.test(h)||T.test(h)||_.test(h)||$.test(h)||A.test(h))break;if(F.search(this.rules.other.nonSpaceChar)>=S||!h.trim())f+=`
2289
2289
  `+F.slice(S);else{if(v||b.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||E.test(b)||T.test(b)||A.test(b))break;f+=`
2290
- `+h}!v&&!h.trim()&&(v=!0),p+=B+`
2291
- `,e=e.substring(B.length+1),b=F.slice(S)}}r.loose||(u?r.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(u=!0)),r.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(f),loose:!1,text:f,tokens:[]}),r.raw+=p}let c=r.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let l of r.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),((n=l.tokens[0])==null?void 0:n.type)==="text"||((i=l.tokens[0])==null?void 0:i.type)==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let f=this.lexer.inlineQueue.length-1;f>=0;f--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[f].src)){this.lexer.inlineQueue[f].src=this.lexer.inlineQueue[f].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(l.raw);if(p){let f={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};l.checked=f.checked,r.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=f.raw+l.tokens[0].raw,l.tokens[0].text=f.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(f)):l.tokens.unshift({type:"paragraph",raw:f.raw,text:f.raw,tokens:[f]}):l.tokens.unshift(f)}}if(!r.loose){let p=l.tokens.filter(b=>b.type==="space"),f=p.length>0&&p.some(b=>this.rules.other.anyLine.test(b.raw));r.loose=f}}if(r.loose)for(let l of r.items){l.loose=!0;for(let p of l.tokens)p.type==="text"&&(p.type="paragraph")}return r}}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 r;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Ra(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(r=t[3])!=null&&r.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
2292
- `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let a of i)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of s)o.rows.push(Ra(a,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)===`
2293
- `?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=pn(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=dm(t[2],"()");if(o===-2)return;if(o>-1){let r=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,r).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)),Da(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 Da(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,r,a=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(r=[...o].length,i[3]||i[4]){a+=r;continue}else if((i[5]||i[6])&&s%3&&!((s+r)%3)){u+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a+u);let l=[...i[0]][0].length,p=e.slice(0,s+i.index+l+r);if(Math.min(s,r)%2){let b=p.slice(1,-1);return{type:"em",raw:p,text:b,tokens:this.lexer.inlineTokens(b)}}let f=p.slice(2,-2);return{type:"strong",raw:p,text:f,tokens:this.lexer.inlineTokens(f)}}}}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}}}},ke=class no{constructor(t){W(this,"tokens");W(this,"options");W(this,"state");W(this,"inlineQueue");W(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Et,this.options.tokenizer=this.options.tokenizer||new Ei,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:pe,block:ei.normal,inline:dn.normal};this.options.pedantic?(n.block=ei.pedantic,n.inline=dn.pedantic):this.options.gfm&&(n.block=ei.gfm,this.options.breaks?n.inline=dn.breaks:n.inline=dn.gfm),this.tokenizer.rules=n}static get rules(){return{block:ei,inline:dn}}static lex(t,n){return new no(n).lex(t)}static lexInline(t,n){return new no(n).inlineTokens(t)}lex(t){t=t.replace(pe.carriageReturn,`
2290
+ `+h}!v&&!h.trim()&&(v=!0),p+=D+`
2291
+ `,e=e.substring(D.length+1),b=F.slice(S)}}r.loose||(u?r.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(u=!0)),r.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(f),loose:!1,text:f,tokens:[]}),r.raw+=p}let c=r.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let l of r.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),((n=l.tokens[0])==null?void 0:n.type)==="text"||((i=l.tokens[0])==null?void 0:i.type)==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let f=this.lexer.inlineQueue.length-1;f>=0;f--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[f].src)){this.lexer.inlineQueue[f].src=this.lexer.inlineQueue[f].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(l.raw);if(p){let f={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};l.checked=f.checked,r.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=f.raw+l.tokens[0].raw,l.tokens[0].text=f.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(f)):l.tokens.unshift({type:"paragraph",raw:f.raw,text:f.raw,tokens:[f]}):l.tokens.unshift(f)}}if(!r.loose){let p=l.tokens.filter(b=>b.type==="space"),f=p.length>0&&p.some(b=>this.rules.other.anyLine.test(b.raw));r.loose=f}}if(r.loose)for(let l of r.items){l.loose=!0;for(let p of l.tokens)p.type==="text"&&(p.type="paragraph")}return r}}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 r;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Da(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(r=t[3])!=null&&r.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
2292
+ `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let a of i)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of s)o.rows.push(Da(a,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)===`
2293
+ `?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=pn(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=hm(t[2],"()");if(o===-2)return;if(o>-1){let r=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,r).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)),Ba(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 Ba(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,r,a=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(r=[...o].length,i[3]||i[4]){a+=r;continue}else if((i[5]||i[6])&&s%3&&!((s+r)%3)){u+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a+u);let l=[...i[0]][0].length,p=e.slice(0,s+i.index+l+r);if(Math.min(s,r)%2){let b=p.slice(1,-1);return{type:"em",raw:p,text:b,tokens:this.lexer.inlineTokens(b)}}let f=p.slice(2,-2);return{type:"strong",raw:p,text:f,tokens:this.lexer.inlineTokens(f)}}}}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}}}},ke=class io{constructor(t){W(this,"tokens");W(this,"options");W(this,"state");W(this,"inlineQueue");W(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ct,this.options.tokenizer=this.options.tokenizer||new Ei,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:pe,block:ei.normal,inline:dn.normal};this.options.pedantic?(n.block=ei.pedantic,n.inline=dn.pedantic):this.options.gfm&&(n.block=ei.gfm,this.options.breaks?n.inline=dn.breaks:n.inline=dn.gfm),this.tokenizer.rules=n}static get rules(){return{block:ei,inline:dn}}static lex(t,n){return new io(n).lex(t)}static lexInline(t,n){return new io(n).inlineTokens(t)}lex(t){t=t.replace(pe.carriageReturn,`
2294
2294
  `),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,r;for(this.options.pedantic&&(t=t.replace(pe.tabCharGlobal," ").replace(pe.spaceLine,""));t;){let a;if((o=(s=this.options.extensions)==null?void 0:s.block)!=null&&o.some(c=>(a=c.call({lexer:this},t,n))?(t=t.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(t)){t=t.substring(a.raw.length);let c=n.at(-1);a.raw.length===1&&c!==void 0?c.raw+=`
2295
2295
  `:n.push(a);continue}if(a=this.tokenizer.code(t)){t=t.substring(a.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(`
2296
2296
  `)?"":`
@@ -2304,7 +2304,7 @@ ${l}`:l;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
2304
2304
  `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a),i=u.length!==t.length,t=t.substring(a.raw.length);continue}if(a=this.tokenizer.text(t)){t=t.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
2305
2305
  `)?"":`
2306
2306
  `)+a.raw,c.text+=`
2307
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a);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,l,p,f;let i=t,s=null;if(this.tokens.links){let b=Object.keys(this.tokens.links);if(b.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)b.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 r=!1,a="";for(;t;){r||(a=""),r=!1;let b;if((p=(l=this.options.extensions)==null?void 0:l.inline)!=null&&p.some(v=>(b=v.call({lexer:this},t,n))?(t=t.substring(b.raw.length),n.push(b),!0):!1))continue;if(b=this.tokenizer.escape(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.tag(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.link(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(b.raw.length);let v=n.at(-1);b.type==="text"&&(v==null?void 0:v.type)==="text"?(v.raw+=b.raw,v.text+=b.text):n.push(b);continue}if(b=this.tokenizer.emStrong(t,i,a)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.codespan(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.br(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.del(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.autolink(t)){t=t.substring(b.raw.length),n.push(b);continue}if(!this.state.inLink&&(b=this.tokenizer.url(t))){t=t.substring(b.raw.length),n.push(b);continue}let h=t;if((f=this.options.extensions)!=null&&f.startInline){let v=1/0,S=t.slice(1),$;this.options.extensions.startInline.forEach(A=>{$=A.call({lexer:this},S),typeof $=="number"&&$>=0&&(v=Math.min(v,$))}),v<1/0&&v>=0&&(h=t.substring(0,v+1))}if(b=this.tokenizer.inlineText(h)){t=t.substring(b.raw.length),b.raw.slice(-1)!=="_"&&(a=b.raw.slice(-1)),r=!0;let v=n.at(-1);(v==null?void 0:v.type)==="text"?(v.raw+=b.raw,v.text+=b.text):n.push(b);continue}if(t){let v="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(v);break}else throw new Error(v)}}return n}},Ci=class{constructor(e){W(this,"options");W(this,"parser");this.options=e||Et}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let i=(o=(t||"").match(pe.notSpaceStart))==null?void 0:o[0],s=e.replace(pe.endingNewline,"")+`
2307
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a);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,l,p,f;let i=t,s=null;if(this.tokens.links){let b=Object.keys(this.tokens.links);if(b.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)b.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 r=!1,a="";for(;t;){r||(a=""),r=!1;let b;if((p=(l=this.options.extensions)==null?void 0:l.inline)!=null&&p.some(v=>(b=v.call({lexer:this},t,n))?(t=t.substring(b.raw.length),n.push(b),!0):!1))continue;if(b=this.tokenizer.escape(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.tag(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.link(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(b.raw.length);let v=n.at(-1);b.type==="text"&&(v==null?void 0:v.type)==="text"?(v.raw+=b.raw,v.text+=b.text):n.push(b);continue}if(b=this.tokenizer.emStrong(t,i,a)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.codespan(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.br(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.del(t)){t=t.substring(b.raw.length),n.push(b);continue}if(b=this.tokenizer.autolink(t)){t=t.substring(b.raw.length),n.push(b);continue}if(!this.state.inLink&&(b=this.tokenizer.url(t))){t=t.substring(b.raw.length),n.push(b);continue}let h=t;if((f=this.options.extensions)!=null&&f.startInline){let v=1/0,S=t.slice(1),$;this.options.extensions.startInline.forEach(A=>{$=A.call({lexer:this},S),typeof $=="number"&&$>=0&&(v=Math.min(v,$))}),v<1/0&&v>=0&&(h=t.substring(0,v+1))}if(b=this.tokenizer.inlineText(h)){t=t.substring(b.raw.length),b.raw.slice(-1)!=="_"&&(a=b.raw.slice(-1)),r=!0;let v=n.at(-1);(v==null?void 0:v.type)==="text"?(v.raw+=b.raw,v.text+=b.text):n.push(b);continue}if(t){let v="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(v);break}else throw new Error(v)}}return n}},Ci=class{constructor(e){W(this,"options");W(this,"parser");this.options=e||Ct}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let i=(o=(t||"").match(pe.notSpaceStart))==null?void 0:o[0],s=e.replace(pe.endingNewline,"")+`
2308
2308
  `;return i?'<pre><code class="language-'+Ke(i)+'">'+(n?s:Ke(s,!0))+`</code></pre>
2309
2309
  `:"<pre><code>"+(n?s:Ke(s,!0))+`</code></pre>
2310
2310
  `}blockquote({tokens:e}){return`<blockquote>
@@ -2322,23 +2322,23 @@ ${this.parser.parse(e)}</blockquote>
2322
2322
  `}tablerow({text:e}){return`<tr>
2323
2323
  ${e}</tr>
2324
2324
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
2325
- `}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>${Ke(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=Ia(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+Ke(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=Ia(e);if(s===null)return Ke(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Ke(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ke(e.text)}},Xo=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}},Se=class io{constructor(t){W(this,"options");W(this,"renderer");W(this,"textRenderer");this.options=t||Et,this.options.renderer=this.options.renderer||new Ci,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Xo}static parse(t,n){return new io(n).parse(t)}static parseInline(t,n){return new io(n).parseInline(t)}parse(t){var i,s;let n="";for(let o=0;o<t.length;o++){let r=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[r.type]){let u=r,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 a=r;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let u='Token with "'+a.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 r=0;r<t.length;r++){let a=t[r];if((o=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&o[a.type]){let c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){i+=c||"";continue}}let u=a;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}},ri,gn=(ri=class{constructor(e){W(this,"options");W(this,"block");this.options=e||Et}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ke.lex:ke.lexInline}provideParser(){return this.block?Se.parse:Se.parseInline}},W(ri,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),W(ri,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),ri),hm=class{constructor(...e){W(this,"defaults",zo());W(this,"options",this.setOptions);W(this,"parse",this.parseMarkdown(!0));W(this,"parseInline",this.parseMarkdown(!1));W(this,"Parser",Se);W(this,"Renderer",Ci);W(this,"TextRenderer",Xo);W(this,"Lexer",ke);W(this,"Tokenizer",Ei);W(this,"Hooks",gn);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 r=o;for(let a of r.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of r.rows)for(let u of a)n=n.concat(this.walkTokens(u.tokens,t));break}case"list":{let r=o;n=n.concat(this.walkTokens(r.items,t));break}default:{let r=o;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[r.type]?this.defaults.extensions.childTokens[r.type].forEach(a=>{let u=r[a].flat(1/0);n=n.concat(this.walkTokens(u,t))}):r.tokens&&(n=n.concat(this.walkTokens(r.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(...r){let a=s.renderer.apply(this,r);return a===!1&&(a=o.apply(this,r)),a}: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 Ci(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 r=o,a=n.renderer[r],u=s[r];s[r]=(...c)=>{let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new Ei(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 r=o,a=n.tokenizer[r],u=s[r];s[r]=(...c)=>{let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new gn;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 r=o,a=n.hooks[r],u=s[r];gn.passThroughHooks.has(o)?s[r]=c=>{if(this.defaults.async&&gn.passThroughHooksRespectAsync.has(o))return(async()=>{let p=await a.call(s,c);return u.call(s,p)})();let l=a.call(s,c);return u.call(s,l)}:s[r]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(s,c);return p===!1&&(p=await u.apply(s,c)),p})();let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l}}i.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,o=n.walkTokens;i.walkTokens=function(r){let a=[];return a.push(o.call(this,r)),s&&(a=a.concat(s.call(this,r))),a}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ke.lex(e,t??this.defaults)}parser(e,t){return Se.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 r=s.hooks?await s.hooks.preprocess(t):t,a=await(s.hooks?await s.hooks.provideLexer():e?ke.lex:ke.lexInline)(r,s),u=s.hooks?await s.hooks.processAllTokens(a):a;s.walkTokens&&await Promise.all(this.walkTokens(u,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():e?Se.parse:Se.parseInline)(u,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let r=(s.hooks?s.hooks.provideLexer():e?ke.lex:ke.lexInline)(t,s);s.hooks&&(r=s.hooks.processAllTokens(r)),s.walkTokens&&this.walkTokens(r,s.walkTokens);let a=(s.hooks?s.hooks.provideParser():e?Se.parse:Se.parseInline)(r,s);return s.hooks&&(a=s.hooks.postprocess(a)),a}catch(r){return o(r)}}}onError(e,t){return n=>{if(n.message+=`
2326
- Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Ke(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},St=new hm;function q(e,t){return St.parse(e,t)}q.options=q.setOptions=function(e){return St.setOptions(e),q.defaults=St.defaults,iu(q.defaults),q};q.getDefaults=zo;q.defaults=Et;q.use=function(...e){return St.use(...e),q.defaults=St.defaults,iu(q.defaults),q};q.walkTokens=function(e,t){return St.walkTokens(e,t)};q.parseInline=St.parseInline;q.Parser=Se;q.parser=Se.parse;q.Renderer=Ci;q.TextRenderer=Xo;q.Lexer=ke;q.lexer=ke.lex;q.Tokenizer=Ei;q.Hooks=gn;q.parse=q;q.options;q.setOptions;q.use;q.walkTokens;q.parseInline;Se.parse;ke.lex;q.setOptions({gfm:!0,breaks:!0,mangle:!1});const Ba=["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"],Na=["class","href","rel","target","title","start"];let Oa=!1;const fm=14e4,gm=4e4,mm=200,xs=5e4,ft=new Map;function ym(e){const t=ft.get(e);return t===void 0?null:(ft.delete(e),ft.set(e,t),t)}function Fa(e,t){if(ft.set(e,t),ft.size<=mm)return;const n=ft.keys().next().value;n&&ft.delete(n)}function vm(){Oa||(Oa=!0,eo.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Ti(e){const t=e.trim();if(!t)return"";if(vm(),t.length<=xs){const r=ym(t);if(r!==null)return r}const n=Rl(t,fm),i=n.truncated?`
2325
+ `}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>${Ke(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=Ra(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+Ke(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=Ra(e);if(s===null)return Ke(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Ke(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ke(e.text)}},Jo=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}},Se=class so{constructor(t){W(this,"options");W(this,"renderer");W(this,"textRenderer");this.options=t||Ct,this.options.renderer=this.options.renderer||new Ci,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Jo}static parse(t,n){return new so(n).parse(t)}static parseInline(t,n){return new so(n).parseInline(t)}parse(t){var i,s;let n="";for(let o=0;o<t.length;o++){let r=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[r.type]){let u=r,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 a=r;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let u='Token with "'+a.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 r=0;r<t.length;r++){let a=t[r];if((o=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&o[a.type]){let c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){i+=c||"";continue}}let u=a;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}},ri,gn=(ri=class{constructor(e){W(this,"options");W(this,"block");this.options=e||Ct}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ke.lex:ke.lexInline}provideParser(){return this.block?Se.parse:Se.parseInline}},W(ri,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),W(ri,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),ri),gm=class{constructor(...e){W(this,"defaults",qo());W(this,"options",this.setOptions);W(this,"parse",this.parseMarkdown(!0));W(this,"parseInline",this.parseMarkdown(!1));W(this,"Parser",Se);W(this,"Renderer",Ci);W(this,"TextRenderer",Jo);W(this,"Lexer",ke);W(this,"Tokenizer",Ei);W(this,"Hooks",gn);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 r=o;for(let a of r.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of r.rows)for(let u of a)n=n.concat(this.walkTokens(u.tokens,t));break}case"list":{let r=o;n=n.concat(this.walkTokens(r.items,t));break}default:{let r=o;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[r.type]?this.defaults.extensions.childTokens[r.type].forEach(a=>{let u=r[a].flat(1/0);n=n.concat(this.walkTokens(u,t))}):r.tokens&&(n=n.concat(this.walkTokens(r.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(...r){let a=s.renderer.apply(this,r);return a===!1&&(a=o.apply(this,r)),a}: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 Ci(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 r=o,a=n.renderer[r],u=s[r];s[r]=(...c)=>{let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new Ei(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 r=o,a=n.tokenizer[r],u=s[r];s[r]=(...c)=>{let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new gn;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 r=o,a=n.hooks[r],u=s[r];gn.passThroughHooks.has(o)?s[r]=c=>{if(this.defaults.async&&gn.passThroughHooksRespectAsync.has(o))return(async()=>{let p=await a.call(s,c);return u.call(s,p)})();let l=a.call(s,c);return u.call(s,l)}:s[r]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(s,c);return p===!1&&(p=await u.apply(s,c)),p})();let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l}}i.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,o=n.walkTokens;i.walkTokens=function(r){let a=[];return a.push(o.call(this,r)),s&&(a=a.concat(s.call(this,r))),a}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ke.lex(e,t??this.defaults)}parser(e,t){return Se.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 r=s.hooks?await s.hooks.preprocess(t):t,a=await(s.hooks?await s.hooks.provideLexer():e?ke.lex:ke.lexInline)(r,s),u=s.hooks?await s.hooks.processAllTokens(a):a;s.walkTokens&&await Promise.all(this.walkTokens(u,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():e?Se.parse:Se.parseInline)(u,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let r=(s.hooks?s.hooks.provideLexer():e?ke.lex:ke.lexInline)(t,s);s.hooks&&(r=s.hooks.processAllTokens(r)),s.walkTokens&&this.walkTokens(r,s.walkTokens);let a=(s.hooks?s.hooks.provideParser():e?Se.parse:Se.parseInline)(r,s);return s.hooks&&(a=s.hooks.postprocess(a)),a}catch(r){return o(r)}}}onError(e,t){return n=>{if(n.message+=`
2326
+ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Ke(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},$t=new gm;function q(e,t){return $t.parse(e,t)}q.options=q.setOptions=function(e){return $t.setOptions(e),q.defaults=$t.defaults,su(q.defaults),q};q.getDefaults=qo;q.defaults=Ct;q.use=function(...e){return $t.use(...e),q.defaults=$t.defaults,su(q.defaults),q};q.walkTokens=function(e,t){return $t.walkTokens(e,t)};q.parseInline=$t.parseInline;q.Parser=Se;q.parser=Se.parse;q.Renderer=Ci;q.TextRenderer=Jo;q.Lexer=ke;q.lexer=ke.lex;q.Tokenizer=Ei;q.Hooks=gn;q.parse=q;q.options;q.setOptions;q.use;q.walkTokens;q.parseInline;Se.parse;ke.lex;q.setOptions({gfm:!0,breaks:!0,mangle:!1});const Na=["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"],Oa=["class","href","rel","target","title","start"];let Fa=!1;const mm=14e4,ym=4e4,vm=200,Es=5e4,ft=new Map;function bm(e){const t=ft.get(e);return t===void 0?null:(ft.delete(e),ft.set(e,t),t)}function Ua(e,t){if(ft.set(e,t),ft.size<=vm)return;const n=ft.keys().next().value;n&&ft.delete(n)}function wm(){Fa||(Fa=!0,to.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Ti(e){const t=e.trim();if(!t)return"";if(wm(),t.length<=Es){const r=bm(t);if(r!==null)return r}const n=Dl(t,mm),i=n.truncated?`
2327
2327
 
2328
- … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>gm){const a=`<pre class="code-block">${bm(`${n.text}${i}`)}</pre>`,u=eo.sanitize(a,{ALLOWED_TAGS:Ba,ALLOWED_ATTR:Na});return t.length<=xs&&Fa(t,u),u}const s=q.parse(`${n.text}${i}`),o=eo.sanitize(s,{ALLOWED_TAGS:Ba,ALLOWED_ATTR:Na});return t.length<=xs&&Fa(t,o),o}function bm(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const wm=1500,km=2e3,fu="Copy as markdown",Sm="Copied",$m="Copy failed";async function Am(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 ti(e,t){e.title=t,e.setAttribute("aria-label",t)}function xm(e){const t=e.label??fu;return d`
2328
+ … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>ym){const a=`<pre class="code-block">${km(`${n.text}${i}`)}</pre>`,u=to.sanitize(a,{ALLOWED_TAGS:Na,ALLOWED_ATTR:Oa});return t.length<=Es&&Ua(t,u),u}const s=q.parse(`${n.text}${i}`),o=to.sanitize(s,{ALLOWED_TAGS:Na,ALLOWED_ATTR:Oa});return t.length<=Es&&Ua(t,o),o}function km(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Sm=1500,$m=2e3,gu="Copy as markdown",Am="Copied",xm="Copy failed";async function Em(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 ti(e,t){e.title=t,e.setAttribute("aria-label",t)}function Cm(e){const t=e.label??gu;return d`
2329
2329
  <button
2330
2330
  class="chat-copy-btn"
2331
2331
  type="button"
2332
2332
  title=${t}
2333
2333
  aria-label=${t}
2334
- @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 Am(e.text());if(i.isConnected){if(delete i.dataset.copying,i.removeAttribute("aria-busy"),i.disabled=!1,!s){i.dataset.error="1",ti(i,$m),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.error,ti(i,t))},km);return}i.dataset.copied="1",ti(i,Sm),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,ti(i,t))},wm)}}}
2334
+ @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 Em(e.text());if(i.isConnected){if(delete i.dataset.copying,i.removeAttribute("aria-busy"),i.disabled=!1,!s){i.dataset.error="1",ti(i,xm),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.error,ti(i,t))},$m);return}i.dataset.copied="1",ti(i,Am),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,ti(i,t))},Sm)}}}
2335
2335
  >
2336
2336
  <span class="chat-copy-btn__icon" aria-hidden="true">
2337
2337
  <span class="chat-copy-btn__icon-copy">${L.copy}</span>
2338
2338
  <span class="chat-copy-btn__icon-check">${L.check}</span>
2339
2339
  </span>
2340
2340
  </button>
2341
- `}function Em(e){return xm({text:()=>e,label:fu})}function Cm(e){const t=e,n=Tm(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:_m(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const r=Mm(s),a=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:a,text:r})}if(Fl(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=Dl(e)??void 0;i.push({kind:"result",name:s,text:o})}return i}function Tm(e){return Array.isArray(e)?e.filter(Boolean):[]}function _m(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 Mm(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function Pm(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 r=o;if(r.type==="image")if(((s=r.source)==null?void 0:s.type)==="base64"){const a=r.source,u=a.data,c=a.media_type||"image/png",l=u.startsWith("data:")?u:`data:${c};base64,${u}`;i.push({url:l})}else if(typeof r.data=="string"&&r.data){const a=r.data,u=r.mimeType||r.media_type||"image/png",c=a.startsWith("data:")?a:`data:${u};base64,${a}`;i.push({url:c})}else typeof r.url=="string"&&i.push({url:r.url});else if(r.type==="image_url"){const a=r.image_url;typeof(a==null?void 0:a.url)=="string"&&i.push({url:a.url})}}return i}function Lm(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 Im(e){return e==="application/pdf"?"📄":e.startsWith("audio/")?"🎵":"📎"}function Rm(e){return d`
2341
+ `}function Tm(e){return Cm({text:()=>e,label:gu})}function _m(e){const t=e,n=Mm(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:Pm(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const r=Lm(s),a=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:a,text:r})}if(Ul(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=Bl(e)??void 0;i.push({kind:"result",name:s,text:o})}return i}function Mm(e){return Array.isArray(e)?e.filter(Boolean):[]}function Pm(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 Lm(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function Im(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 r=o;if(r.type==="image")if(((s=r.source)==null?void 0:s.type)==="base64"){const a=r.source,u=a.data,c=a.media_type||"image/png",l=u.startsWith("data:")?u:`data:${c};base64,${u}`;i.push({url:l})}else if(typeof r.data=="string"&&r.data){const a=r.data,u=r.mimeType||r.media_type||"image/png",c=a.startsWith("data:")?a:`data:${u};base64,${a}`;i.push({url:c})}else typeof r.url=="string"&&i.push({url:r.url});else if(r.type==="image_url"){const a=r.image_url;typeof(a==null?void 0:a.url)=="string"&&i.push({url:a.url})}}return i}function Rm(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 Dm(e){return e==="application/pdf"?"📄":e.startsWith("audio/")?"🎵":"📎"}function Bm(e){return d`
2342
2342
  <div class="chat-group assistant">
2343
2343
  <div class="chat-group-messages">
2344
2344
  <div class="chat-bubble chat-reading-indicator" aria-hidden="true">
@@ -2348,7 +2348,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2348
2348
  </div>
2349
2349
  </div>
2350
2350
  </div>
2351
- `}function Dm(e){return d`
2351
+ `}function Nm(e){return d`
2352
2352
  <div class="chat-group assistant">
2353
2353
  <div class="chat-group-messages">
2354
2354
  <div class="chat-interim fade-in">
@@ -2356,22 +2356,22 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2356
2356
  </div>
2357
2357
  </div>
2358
2358
  </div>
2359
- `}function Bm(e,t,n,i){return d`
2359
+ `}function Om(e,t,n,i){return d`
2360
2360
  <div class="chat-group assistant">
2361
2361
  <div class="chat-group-messages">
2362
- ${gu({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
2362
+ ${mu({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
2363
2363
  </div>
2364
2364
  </div>
2365
- `}function Nm(e,t){const n=Ol(e.role),i=n==="user"?"user":n==="assistant"?"assistant":"other",s=new Date(e.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"});return d`
2365
+ `}function Fm(e,t){const n=Fl(e.role),i=n==="user"?"user":n==="assistant"?"assistant":"other",s=new Date(e.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"});return d`
2366
2366
  <div class="chat-group ${i}">
2367
2367
  <div class="chat-group-messages">
2368
- ${e.messages.map((o,r)=>gu(o.message,{isStreaming:e.isStreaming&&r===e.messages.length-1,showReasoning:t.showReasoning}))}
2368
+ ${e.messages.map((o,r)=>mu(o.message,{isStreaming:e.isStreaming&&r===e.messages.length-1,showReasoning:t.showReasoning}))}
2369
2369
  <div class="chat-group-footer">
2370
2370
  <span class="chat-group-timestamp">${s}</span>
2371
2371
  </div>
2372
2372
  </div>
2373
2373
  </div>
2374
- `}function Om(e){return e.length===0?k:d`
2374
+ `}function Um(e){return e.length===0?k:d`
2375
2375
  <div class="chat-message-images">
2376
2376
  ${e.map(t=>d`
2377
2377
  <img
@@ -2382,12 +2382,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2382
2382
  />
2383
2383
  `)}
2384
2384
  </div>
2385
- `}function Fm(e){return e.length===0?k:d`
2385
+ `}function Wm(e){return e.length===0?k:d`
2386
2386
  <div class="chat-message-files">
2387
- ${e.map(t=>t.mimeType==="application/pdf"?Wm(t):t.mimeType.startsWith("audio/")?Km(t):zm(t))}
2387
+ ${e.map(t=>t.mimeType==="application/pdf"?zm(t):t.mimeType.startsWith("audio/")?qm(t):Hm(t))}
2388
2388
  </div>
2389
- `}function Um(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 r=document.createElement("a");r.className="chat-pdf-modal__open",r.href=e,r.target="_blank",r.rel="noreferrer noopener",r.textContent="Open in new tab";const a=document.createElement("button");a.className="chat-pdf-modal__close",a.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 l=document.createElementNS("http://www.w3.org/2000/svg","line");l.setAttribute("x1","6"),l.setAttribute("y1","6"),l.setAttribute("x2","18"),l.setAttribute("y2","18"),u.append(c,l),a.appendChild(u),s.append(o,r,a);const p=document.createElement("iframe");p.className="chat-pdf-modal__frame",p.src=e,p.title=t,i.append(s,p),n.appendChild(i),n.addEventListener("click",f=>{f.target===n&&n.remove()}),a.addEventListener("click",()=>n.remove()),document.body.appendChild(n)}function Wm(e){return d`
2390
- <div class="chat-pdf-preview" @click=${()=>Um(e.url,e.name)}>
2389
+ `}function Km(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 r=document.createElement("a");r.className="chat-pdf-modal__open",r.href=e,r.target="_blank",r.rel="noreferrer noopener",r.textContent="Open in new tab";const a=document.createElement("button");a.className="chat-pdf-modal__close",a.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 l=document.createElementNS("http://www.w3.org/2000/svg","line");l.setAttribute("x1","6"),l.setAttribute("y1","6"),l.setAttribute("x2","18"),l.setAttribute("y2","18"),u.append(c,l),a.appendChild(u),s.append(o,r,a);const p=document.createElement("iframe");p.className="chat-pdf-modal__frame",p.src=e,p.title=t,i.append(s,p),n.appendChild(i),n.addEventListener("click",f=>{f.target===n&&n.remove()}),a.addEventListener("click",()=>n.remove()),document.body.appendChild(n)}function zm(e){return d`
2390
+ <div class="chat-pdf-preview" @click=${()=>Km(e.url,e.name)}>
2391
2391
  <iframe
2392
2392
  src=${e.url}
2393
2393
  class="chat-pdf-preview__frame"
@@ -2401,7 +2401,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2401
2401
  @click=${t=>t.stopPropagation()}
2402
2402
  >${e.name}</a>
2403
2403
  </div>
2404
- `}function Km(e){return d`
2404
+ `}function qm(e){return d`
2405
2405
  <div class="chat-audio-player">
2406
2406
  <audio controls preload="metadata" src=${e.url}></audio>
2407
2407
  <a
@@ -2411,41 +2411,39 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2411
2411
  rel="noreferrer noopener"
2412
2412
  >${e.name}</a>
2413
2413
  </div>
2414
- `}function zm(e){return d`
2414
+ `}function Hm(e){return d`
2415
2415
  <a
2416
2416
  class="chat-file-card"
2417
2417
  href=${e.url}
2418
2418
  target="_blank"
2419
2419
  rel="noreferrer noopener"
2420
2420
  >
2421
- <span class="chat-file-card__icon">${Im(e.mimeType)}</span>
2421
+ <span class="chat-file-card__icon">${Dm(e.mimeType)}</span>
2422
2422
  <span class="chat-file-card__name">${e.name}</span>
2423
2423
  </a>
2424
- `}function gu(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=Fl(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",a=Cm(e).length>0,u=Pm(e),c=u.length>0,l=Lm(e),p=l.length>0,f=Dl(e),b=t.showReasoning&&s==="assistant"?dp(e):null,h=f!=null&&f.trim()?f:null,v=b?hp(b):null,S=h,$=(s==="assistant"||s==="user")&&!!(S!=null&&S.trim()),A=["chat-bubble",$?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!S&&(a||o)||!S&&!c&&!p?k:d`
2424
+ `}function mu(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=Ul(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",a=_m(e).length>0,u=Im(e),c=u.length>0,l=Rm(e),p=l.length>0,f=Bl(e),b=t.showReasoning&&s==="assistant"?hp(e):null,h=f!=null&&f.trim()?f:null,v=b?gp(b):null,S=h,$=(s==="assistant"||s==="user")&&!!(S!=null&&S.trim()),A=["chat-bubble",$?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!S&&(a||o)||!S&&!c&&!p?k:d`
2425
2425
  <div class="${A}">
2426
- ${$?Em(S):k}
2427
- ${Om(u)}
2428
- ${Fm(l)}
2426
+ ${$?Tm(S):k}
2427
+ ${Um(u)}
2428
+ ${Wm(l)}
2429
2429
  ${v?d`<div class="chat-thinking">${Ai(Ti(v))}</div>`:k}
2430
2430
  ${S?d`<div class="chat-text">${Ai(Ti(S))}</div>`:k}
2431
2431
  </div>
2432
- `}const R={active:!1,mode:"tap",startTime:0,elapsed:0,mediaRecorder:null,audioChunks:[],stream:null,timerId:null,startX:0,cancelled:!1};let K=null,mt=null,nt=!1;function Ua(e){const t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}function Bt(){if(R.timerId&&(clearInterval(R.timerId),R.timerId=null),R.stream){for(const e of R.stream.getTracks())e.stop();R.stream=null}mt&&(clearTimeout(mt),mt=null),R.mediaRecorder=null,R.audioChunks=[],R.active=!1,R.cancelled=!1,nt=!1}async function mu(e){try{const t=await navigator.mediaDevices.getUserMedia({audio:!0});R.stream=t;const n=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",i=n?new MediaRecorder(t,{mimeType:n}):new MediaRecorder(t);return R.mediaRecorder=i,R.audioChunks=[],R.mode=e,R.startTime=Date.now(),R.elapsed=0,R.active=!0,R.cancelled=!1,i.ondataavailable=s=>{s.data.size>0&&R.audioChunks.push(s.data)},i.onstop=()=>{if(R.cancelled){Bt(),K==null||K.onRequestRender();return}const s=new Blob(R.audioChunks,{type:i.mimeType});if(s.size===0){Bt(),K==null||K.onRequestRender();return}const o=new FileReader;o.onload=()=>{const r=o.result,a=i.mimeType.includes("mp4")?"m4a":"webm",u={id:Oi(),dataUrl:r,mimeType:i.mimeType||"audio/webm",fileName:`voice-note.${a}`};Bt(),K==null||K.onSend(u),K==null||K.onRequestRender()},o.onerror=()=>{Bt(),K==null||K.onRequestRender()},o.readAsDataURL(s)},i.start(250),R.timerId=setInterval(()=>{R.elapsed=Math.floor((Date.now()-R.startTime)/1e3),K==null||K.onRequestRender()},1e3),K==null||K.onRequestRender(),!0}catch{return Bt(),!1}}function yu(){!R.active||!R.mediaRecorder||(R.cancelled=!1,R.mediaRecorder.state==="recording"&&R.mediaRecorder.stop())}function vu(){!R.active||!R.mediaRecorder||(R.cancelled=!0,R.mediaRecorder.state==="recording"?R.mediaRecorder.stop():(Bt(),K==null||K.onRequestRender()))}function qm(e){R.active||(nt=!0,R.startX=e.clientX,mt=setTimeout(async()=>{if(!nt)return;await mu("hold")||(nt=!1)},300))}function Hm(e){if(!(!nt&&!R.active)){if(nt=!1,mt&&(clearTimeout(mt),mt=null,!R.active)){mu("tap");return}R.active&&R.mode==="hold"&&(R.cancelled?vu():yu()),e.preventDefault()}}function jm(e){R.active&&R.mode==="hold"&&nt&&(R.cancelled=!0,K==null||K.onRequestRender())}function Wa(e){if(!R.active||R.mode!=="hold"||!nt)return;const t=R.startX-e.clientX;t>80?(R.cancelled=!0,K==null||K.onRequestRender()):R.cancelled&&t<=60&&(R.cancelled=!1,K==null||K.onRequestRender())}function Vm(){return R.active}function Gm(e){K=e}function Qm(e){return d`
2432
+ `}const B={active:!1,mode:"tap",startTime:0,elapsed:0,mediaRecorder:null,audioChunks:[],stream:null,timerId:null,startX:0,cancelled:!1};let z=null,mt=null,yt=!1;function Wa(e){const t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}function pt(){if(B.timerId&&(clearInterval(B.timerId),B.timerId=null),B.stream){for(const e of B.stream.getTracks())e.stop();B.stream=null}mt&&(clearTimeout(mt),mt=null),_i(),B.mediaRecorder=null,B.audioChunks=[],B.active=!1,B.cancelled=!1,yt=!1}async function yu(e){var t;try{if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia))return console.warn("[voice] getUserMedia unavailable (requires secure context)"),pt(),!1;const n=await navigator.mediaDevices.getUserMedia({audio:!0});B.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 B.mediaRecorder=s,B.audioChunks=[],B.mode=e,B.startTime=Date.now(),B.elapsed=0,B.active=!0,B.cancelled=!1,s.ondataavailable=o=>{o.data.size>0&&B.audioChunks.push(o.data)},s.onstop=()=>{if(B.cancelled){pt(),z==null||z.onRequestRender();return}const o=new Blob(B.audioChunks,{type:s.mimeType});if(o.size===0){pt(),z==null||z.onRequestRender();return}const r=new FileReader;r.onload=()=>{const a=r.result,u=s.mimeType.includes("mp4")?"m4a":"webm",c={id:Fi(),dataUrl:a,mimeType:s.mimeType||"audio/webm",fileName:`voice-note-${Date.now()}.${u}`};pt(),z==null||z.onSend(c),z==null||z.onRequestRender()},r.onerror=()=>{pt(),z==null||z.onRequestRender()},r.readAsDataURL(o)},s.start(250),B.timerId=setInterval(()=>{B.elapsed=Math.floor((Date.now()-B.startTime)/1e3),z==null||z.onRequestRender()},1e3),z==null||z.onRequestRender(),!0}catch(n){return console.warn("[voice] startRecording failed:",n),pt(),!1}}function vu(){!B.active||!B.mediaRecorder||(B.cancelled=!1,B.mediaRecorder.state==="recording"&&B.mediaRecorder.stop())}function bu(){!B.active||!B.mediaRecorder||(B.cancelled=!0,B.mediaRecorder.state==="recording"?B.mediaRecorder.stop():(pt(),z==null||z.onRequestRender()))}function jm(){document.addEventListener("pointerup",wu)}function _i(){document.removeEventListener("pointerup",wu)}function wu(e){if(!yt&&!B.active){_i();return}if(yt=!1,_i(),mt&&(clearTimeout(mt),mt=null,!B.active)){yu("tap");return}B.active&&B.mode==="hold"&&(B.cancelled?bu():vu()),e.preventDefault()}function Vm(e){B.active||(yt=!0,B.startX=e.clientX,jm(),mt=setTimeout(async()=>{if(!yt)return;await yu("hold")||(yt=!1,_i())},300))}function Ka(e){if(!B.active||B.mode!=="hold"||!yt)return;const t=B.startX-e.clientX;t>80?(B.cancelled=!0,z==null||z.onRequestRender()):B.cancelled&&t<=60&&(B.cancelled=!1,z==null||z.onRequestRender())}function Gm(){return B.active}function Qm(e){z=e}function Ym(e){return d`
2433
2433
  <button
2434
2434
  class="btn btn--icon chat-compose__mic"
2435
2435
  ?disabled=${!e}
2436
- @pointerdown=${qm}
2437
- @pointerup=${Hm}
2438
- @pointerleave=${jm}
2436
+ @pointerdown=${Vm}
2439
2437
  aria-label="Record voice note"
2440
2438
  title="Tap to record, hold to send on release"
2441
2439
  >
2442
2440
  ${L.mic}
2443
2441
  </button>
2444
- `}function Ym(){return R.active?R.mode==="tap"?d`
2445
- <div class="chat-voice-recording" @pointermove=${Wa}>
2442
+ `}function Xm(){return B.active?B.mode==="tap"?d`
2443
+ <div class="chat-voice-recording" @pointermove=${Ka}>
2446
2444
  <button
2447
2445
  class="btn btn--icon chat-voice-recording__trash"
2448
- @click=${vu}
2446
+ @click=${bu}
2449
2447
  aria-label="Cancel recording"
2450
2448
  title="Discard"
2451
2449
  >
@@ -2453,11 +2451,11 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2453
2451
  </button>
2454
2452
  <div class="chat-voice-recording__indicator">
2455
2453
  <span class="chat-voice-recording__dot"></span>
2456
- <span class="chat-voice-recording__timer">${Ua(R.elapsed)}</span>
2454
+ <span class="chat-voice-recording__timer">${Wa(B.elapsed)}</span>
2457
2455
  </div>
2458
2456
  <button
2459
2457
  class="btn btn--icon chat-voice-recording__send primary"
2460
- @click=${yu}
2458
+ @click=${vu}
2461
2459
  aria-label="Send voice note"
2462
2460
  title="Send"
2463
2461
  >
@@ -2465,16 +2463,16 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2465
2463
  </button>
2466
2464
  </div>
2467
2465
  `:d`
2468
- <div class="chat-voice-recording hold" @pointermove=${Wa}>
2466
+ <div class="chat-voice-recording hold" @pointermove=${Ka}>
2469
2467
  <div class="chat-voice-recording__indicator">
2470
2468
  <span class="chat-voice-recording__dot"></span>
2471
- <span class="chat-voice-recording__timer">${Ua(R.elapsed)}</span>
2472
- <span class="chat-voice-recording__slide ${R.cancelled?"cancelled":""}">
2473
- ${R.cancelled?"Release to cancel":"← Slide to cancel"}
2469
+ <span class="chat-voice-recording__timer">${Wa(B.elapsed)}</span>
2470
+ <span class="chat-voice-recording__slide ${B.cancelled?"cancelled":""}">
2471
+ ${B.cancelled?"Release to cancel":"← Slide to cancel"}
2474
2472
  </span>
2475
2473
  </div>
2476
2474
  </div>
2477
- `:k}function Xm(e){return d`
2475
+ `:k}function Jm(e){return d`
2478
2476
  <div class="sidebar-panel">
2479
2477
  <div class="sidebar-header">
2480
2478
  <div class="sidebar-title">Tool Output</div>
@@ -2491,7 +2489,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2491
2489
  `:e.content?d`<div class="sidebar-markdown">${Ai(Ti(e.content))}</div>`:d`<div class="muted">No content available</div>`}
2492
2490
  </div>
2493
2491
  </div>
2494
- `}var Jm=Object.defineProperty,Zm=Object.getOwnPropertyDescriptor,Hi=(e,t,n,i)=>{for(var s=i>1?void 0:i?Zm(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(s=(i?r(t,n,s):r(s))||s);return i&&s&&Jm(t,n,s),s};let zt=class extends Ot{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 d``}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)}};zt.styles=Ad`
2492
+ `}var Zm=Object.defineProperty,ey=Object.getOwnPropertyDescriptor,ji=(e,t,n,i)=>{for(var s=i>1?void 0:i?ey(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(s=(i?r(t,n,s):r(s))||s);return i&&s&&Zm(t,n,s),s};let zt=class extends Ot{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 d``}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)}};zt.styles=Ed`
2495
2493
  :host {
2496
2494
  width: 4px;
2497
2495
  cursor: col-resize;
@@ -2517,21 +2515,21 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2517
2515
  :host(.dragging) {
2518
2516
  background: var(--accent, #007bff);
2519
2517
  }
2520
- `;Hi([Bi({type:Number})],zt.prototype,"splitRatio",2);Hi([Bi({type:Number})],zt.prototype,"minRatio",2);Hi([Bi({type:Number})],zt.prototype,"maxRatio",2);zt=Hi([El("resizable-divider")],zt);function ni(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function Es(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const ey=1,ty=1,Ct="emoji",qt="keyvalue",Jo="favorites",ny="tokens",bu="tokens",iy="unicode",wu="count",sy="group",oy="order",ku="group-order",so="eTag",_i="url",Ka="skinTone",Xt="readonly",Zo="readwrite",Su="skinUnicodes",ry="skinUnicodes",ay="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",ly="en";function cy(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 za(e){return cy(e,t=>t.unicode)}function uy(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[r,[a,u]]of Object.entries(s))o.createIndex(r,a,{multiEntry:u});return o}t(qt),t(Ct,iy,{[bu]:[ny,!0],[ku]:[[sy,oy]],[Su]:[ry,!0]}),t(Jo,void 0,{[wu]:[""]})}const oo={},ui={},Mi={};function $u(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function dy(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,ey);oo[e]=s,s.onupgradeneeded=o=>{o.oldVersion<ty&&uy(s.result)},$u(n,i,s)});return t.onclose=()=>er(e),t}function py(e){return ui[e]||(ui[e]=dy(e)),ui[e]}function Ge(e,t,n,i){return new Promise((s,o)=>{const r=e.transaction(t,n,{durability:"relaxed"}),a=typeof t=="string"?r.objectStore(t):t.map(c=>r.objectStore(c));let u;i(a,r,c=>{u=c}),r.oncomplete=()=>s(u),r.onerror=()=>o(r.error)})}function er(e){const t=oo[e],n=t&&t.result;if(n){n.close();const i=Mi[e];if(i)for(const s of i)s()}delete oo[e],delete ui[e],delete Mi[e]}function hy(e){return new Promise((t,n)=>{er(e);const i=indexedDB.deleteDatabase(e);$u(t,n,i)})}function fy(e,t){let n=Mi[e];n||(n=Mi[e]=[]),n.push(t)}const gy=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 Ut(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||gy.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const my=2;function Au(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=my)}function yy(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:r,skins:a,tags:u,emoji:c,version:l})=>{const p=[...new Set(Au([...(r||[]).map(Ut).flat(),...(u||[]).map(Ut).flat(),...Ut(n),i]))].sort(),f={annotation:n,group:s,order:o,tags:u,tokens:p,unicode:c,version:l};if(i&&(f.emoticon=i),r&&(f.shortcodes=r),a){f.skinTones=[],f.skinUnicodes=[],f.skinVersions=[];for(const{tone:b,emoji:h,version:v}of a)f.skinTones.push(b),f.skinUnicodes.push(h),f.skinVersions.push(v)}return f})}function xu(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function $t(e,t,n){xu(e,"get",t,n)}function Eu(e,t,n){xu(e,"getAll",t,n)}function tr(e){e.commit&&e.commit()}function vy(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 Cu(e,t){const n=vy(e,s=>s.length),i=[];for(const s of n)e.some(o=>o.findIndex(r=>t(r)===t(s))===-1)||i.push(s);return i}async function by(e){return!await nr(e,qt,_i)}async function wy(e,t,n){const[i,s]=await Promise.all([so,_i].map(o=>nr(e,qt,o)));return i===n&&s===t}async function ky(e,t){return Ge(e,Ct,Xt,(i,s,o)=>{let r;const a=()=>{i.getAll(r&&IDBKeyRange.lowerBound(r,!0),50).onsuccess=u=>{const c=u.target.result;for(const l of c)if(r=l.unicode,t(l))return o(l);if(c.length<50)return o();a()}};a()})}async function Tu(e,t,n,i){{const s=yy(t);await Ge(e,[Ct,qt],Zo,([o,r],a)=>{let u,c,l=0;function p(){++l===2&&f()}function f(){if(!(u===i&&c===n)){o.clear();for(const b of s)o.put(b);r.put(i,so),r.put(n,_i),tr(a)}}$t(r,so,b=>{u=b,p()}),$t(r,_i,b=>{c=b,p()})})}}async function Sy(e,t){return Ge(e,Ct,Xt,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);Eu(n.index(ku),o,s)})}async function _u(e,t){const n=Au(Ut(t));return n.length?Ge(e,Ct,Xt,(i,s,o)=>{const r=[],a=()=>{r.length===n.length&&u()},u=()=>{const c=Cu(r,l=>l.unicode);o(c.sort((l,p)=>l.order<p.order?-1:1))};for(let c=0;c<n.length;c++){const l=n[c],p=c===n.length-1?IDBKeyRange.bound(l,l+"￿",!1,!0):IDBKeyRange.only(l);Eu(i.index(bu),p,f=>{r.push(f),a()})}}):[]}async function $y(e,t){const n=await _u(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await ky(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function Ay(e,t){return Ge(e,Ct,Xt,(n,i,s)=>$t(n,t,o=>{if(o)return s(o);$t(n.index(Su),t,r=>s(r||null))}))}function nr(e,t,n){return Ge(e,t,Xt,(i,s,o)=>$t(i,n,o))}function xy(e,t,n,i){return Ge(e,t,Zo,(s,o)=>{s.put(i,n),tr(o)})}function Ey(e,t){return Ge(e,Jo,Zo,(n,i)=>$t(n,t,s=>{n.put((s||0)+1,t),tr(i)}))}function Cy(e,t,n){return n===0?[]:Ge(e,[Jo,Ct],Xt,([i,s],o,r)=>{const a=[];i.index(wu).openCursor(void 0,"prev").onsuccess=u=>{const c=u.target.result;if(!c)return r(a);function l(b){if(a.push(b),a.length===n)return r(a);c.continue()}const p=c.primaryKey,f=t.byName(p);if(f)return l(f);$t(s,p,b=>{if(b)return l(b);c.continue()})}})}const ii="";function Ty(e,t){const n=new Map;for(const s of e){const o=t(s);for(const r of o){let a=n;for(let c=0;c<r.length;c++){const l=r.charAt(c);let p=a.get(l);p||(p=new Map,a.set(l,p)),a=p}let u=a.get(ii);u||(u=[],a.set(ii,u)),u.push(s)}}return(s,o)=>{let r=n;for(let c=0;c<s.length;c++){const l=s.charAt(c),p=r.get(l);if(p)r=p;else return[]}if(o)return r.get(ii)||[];const a=[],u=[r];for(;u.length;){const l=[...u.shift().entries()].sort((p,f)=>p[0]<f[0]?-1:1);for(const[p,f]of l)p===ii?a.push(...f):u.push(f)}return a}}const _y=["name","url"];function My(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||_y.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function qa(e){My(e);const t=(f,b)=>f.name.toLowerCase()<b.name.toLowerCase()?-1:1,n=e.sort(t),s=Ty(e,f=>{const b=new Set;if(f.shortcodes)for(const h of f.shortcodes)for(const v of Ut(h))b.add(v);return b}),o=f=>s(f,!0),r=f=>s(f,!1),a=f=>{const b=Ut(f),h=b.map((v,S)=>(S<b.length-1?o:r)(v));return Cu(h,v=>v.name).sort(t)},u=new Map,c=new Map;for(const f of e){c.set(f.name.toLowerCase(),f);for(const b of f.shortcodes||[])u.set(b.toLowerCase(),f)}return{all:n,search:a,byShortcode:f=>u.get(f.toLowerCase()),byName:f=>c.get(f.toLowerCase())}}const Py=typeof wrappedJSObject<"u";function hn(e){if(!e)return e;if(Py&&(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 Mu(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Ly=["annotation","emoji","group","order","version"];function Iy(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Ly.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function Pu(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Ry(e){const t=await fetch(e,{method:"HEAD"});Pu(t,e);const n=t.headers.get("etag");return Mu(n),n}async function ro(e){const t=await fetch(e);Pu(t,e);const n=t.headers.get("etag");Mu(n);const i=await t.json();return Iy(i),[n,i]}function Dy(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function By(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 Lu(e){const t=JSON.stringify(e);let n=By(t);const i=await crypto.subtle.digest("SHA-1",n),s=Dy(i);return btoa(s)}async function Ny(e,t){let n,i=await Ry(t);if(!i){const s=await ro(t);i=s[0],n=s[1],i||(i=await Lu(n))}await wy(e,t,i)||(n||(n=(await ro(t))[1]),await Tu(e,n,t,i))}async function Oy(e,t){let[n,i]=await ro(t);n||(n=await Lu(i)),await Tu(e,i,t,n)}async function Fy(e,t){try{await Ny(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class Uy{constructor({dataSource:t=ay,locale:n=ly,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=qa(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await py(this._dbName);fy(this._dbName,this._clear);const n=this.dataSource;await by(t)?await Oy(t,n):this._lazyUpdate=Fy(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 Es(t),await this.ready(),za(await Sy(this._db,t)).map(hn)}async getEmojiBySearchQuery(t){ni(t),await this.ready();const n=this._custom.search(t),i=za(await _u(this._db,t)).map(hn);return[...n,...i]}async getEmojiByShortcode(t){ni(t),await this.ready();const n=this._custom.byShortcode(t);return n||hn(await $y(this._db,t))}async getEmojiByUnicodeOrName(t){ni(t),await this.ready();const n=this._custom.byName(t);return n||hn(await Ay(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await nr(this._db,qt,Ka)||0}async setPreferredSkinTone(t){return Es(t),await this.ready(),xy(this._db,qt,Ka,t)}async incrementFavoriteEmojiCount(t){return ni(t),await this.ready(),Ey(this._db,t)}async getTopFavoriteEmoji(t){return Es(t),await this.ready(),(await Cy(this._db,this._custom,t)).map(hn)}set customEmoji(t){this._custom=qa(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 er(this._dbName)}async delete(){await this._shutdown(),await hy(this._dbName)}}const ao=[[-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})),Cs=ao.slice(1),Wy=2,Ha=6,Iu=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function ja(e){return e.unicode.includes("‍")}const Ky={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},zy=1e3,qy="🖐️",Hy=8,jy=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],Ru='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',Vy=(e,t)=>e<t?-1:e>t?1:0,Va=(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},Gy=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function Qy(e){const t=Va(e,"#000"),n=Va(e,"#fff");return t&&n&&Gy(t,n)}function Yy(){const e=Object.entries(Ky);try{for(const[t,n]of e)if(Qy(t))return n}catch{}return e[0][1]}let Ts;const _s=()=>(Ts||(Ts=new Promise(e=>Iu(()=>e(Yy())))),Ts),lo=new Map,Xy="️",Jy="\uD83C",Zy="‍",ev=127995,tv=57339;function nv(e,t){if(t===0)return e;const n=e.indexOf(Zy);return n!==-1?e.substring(0,n)+String.fromCodePoint(ev+t-1)+e.substring(n):(e.endsWith(Xy)&&(e=e.substring(0,e.length-1)),e+Jy+String.fromCodePoint(tv+t-1))}function _e(e){e.preventDefault(),e.stopPropagation()}function Ms(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function Du(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 iv(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:r,name:a,category:u,annotation:c})=>({unicode:i,name:a,shortcodes:o,url:r,category:u,annotation:c,id:i||a,skins:s&&n(s)}))}const di=requestAnimationFrame;let sv=typeof ResizeObserver=="function";function ov(e,t,n){let i;sv?(i=new ResizeObserver(n),i.observe(e)):di(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function Ga(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let Ps;function rv(e,t,n){let i=!0,s=!1;for(const o of e){const r=n(o);if(!r)continue;const a=Ga(r);a===0&&(s=!0),typeof Ps>"u"&&(Ps=Ga(t));const u=a/1.8<Ps;lo.set(o.unicode,u),u||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
2518
+ `;ji([Ni({type:Number})],zt.prototype,"splitRatio",2);ji([Ni({type:Number})],zt.prototype,"minRatio",2);ji([Ni({type:Number})],zt.prototype,"maxRatio",2);zt=ji([Cl("resizable-divider")],zt);function ni(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function Cs(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const ty=1,ny=1,Tt="emoji",qt="keyvalue",Zo="favorites",iy="tokens",ku="tokens",sy="unicode",Su="count",oy="group",ry="order",$u="group-order",oo="eTag",Mi="url",za="skinTone",Xt="readonly",er="readwrite",Au="skinUnicodes",ay="skinUnicodes",ly="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",cy="en";function uy(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 qa(e){return uy(e,t=>t.unicode)}function dy(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[r,[a,u]]of Object.entries(s))o.createIndex(r,a,{multiEntry:u});return o}t(qt),t(Tt,sy,{[ku]:[iy,!0],[$u]:[[oy,ry]],[Au]:[ay,!0]}),t(Zo,void 0,{[Su]:[""]})}const ro={},ui={},Pi={};function xu(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function py(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,ty);ro[e]=s,s.onupgradeneeded=o=>{o.oldVersion<ny&&dy(s.result)},xu(n,i,s)});return t.onclose=()=>tr(e),t}function hy(e){return ui[e]||(ui[e]=py(e)),ui[e]}function Ge(e,t,n,i){return new Promise((s,o)=>{const r=e.transaction(t,n,{durability:"relaxed"}),a=typeof t=="string"?r.objectStore(t):t.map(c=>r.objectStore(c));let u;i(a,r,c=>{u=c}),r.oncomplete=()=>s(u),r.onerror=()=>o(r.error)})}function tr(e){const t=ro[e],n=t&&t.result;if(n){n.close();const i=Pi[e];if(i)for(const s of i)s()}delete ro[e],delete ui[e],delete Pi[e]}function fy(e){return new Promise((t,n)=>{tr(e);const i=indexedDB.deleteDatabase(e);xu(t,n,i)})}function gy(e,t){let n=Pi[e];n||(n=Pi[e]=[]),n.push(t)}const my=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 Ut(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||my.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const yy=2;function Eu(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=yy)}function vy(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:r,skins:a,tags:u,emoji:c,version:l})=>{const p=[...new Set(Eu([...(r||[]).map(Ut).flat(),...(u||[]).map(Ut).flat(),...Ut(n),i]))].sort(),f={annotation:n,group:s,order:o,tags:u,tokens:p,unicode:c,version:l};if(i&&(f.emoticon=i),r&&(f.shortcodes=r),a){f.skinTones=[],f.skinUnicodes=[],f.skinVersions=[];for(const{tone:b,emoji:h,version:v}of a)f.skinTones.push(b),f.skinUnicodes.push(h),f.skinVersions.push(v)}return f})}function Cu(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function At(e,t,n){Cu(e,"get",t,n)}function Tu(e,t,n){Cu(e,"getAll",t,n)}function nr(e){e.commit&&e.commit()}function by(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 _u(e,t){const n=by(e,s=>s.length),i=[];for(const s of n)e.some(o=>o.findIndex(r=>t(r)===t(s))===-1)||i.push(s);return i}async function wy(e){return!await ir(e,qt,Mi)}async function ky(e,t,n){const[i,s]=await Promise.all([oo,Mi].map(o=>ir(e,qt,o)));return i===n&&s===t}async function Sy(e,t){return Ge(e,Tt,Xt,(i,s,o)=>{let r;const a=()=>{i.getAll(r&&IDBKeyRange.lowerBound(r,!0),50).onsuccess=u=>{const c=u.target.result;for(const l of c)if(r=l.unicode,t(l))return o(l);if(c.length<50)return o();a()}};a()})}async function Mu(e,t,n,i){{const s=vy(t);await Ge(e,[Tt,qt],er,([o,r],a)=>{let u,c,l=0;function p(){++l===2&&f()}function f(){if(!(u===i&&c===n)){o.clear();for(const b of s)o.put(b);r.put(i,oo),r.put(n,Mi),nr(a)}}At(r,oo,b=>{u=b,p()}),At(r,Mi,b=>{c=b,p()})})}}async function $y(e,t){return Ge(e,Tt,Xt,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);Tu(n.index($u),o,s)})}async function Pu(e,t){const n=Eu(Ut(t));return n.length?Ge(e,Tt,Xt,(i,s,o)=>{const r=[],a=()=>{r.length===n.length&&u()},u=()=>{const c=_u(r,l=>l.unicode);o(c.sort((l,p)=>l.order<p.order?-1:1))};for(let c=0;c<n.length;c++){const l=n[c],p=c===n.length-1?IDBKeyRange.bound(l,l+"￿",!1,!0):IDBKeyRange.only(l);Tu(i.index(ku),p,f=>{r.push(f),a()})}}):[]}async function Ay(e,t){const n=await Pu(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await Sy(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function xy(e,t){return Ge(e,Tt,Xt,(n,i,s)=>At(n,t,o=>{if(o)return s(o);At(n.index(Au),t,r=>s(r||null))}))}function ir(e,t,n){return Ge(e,t,Xt,(i,s,o)=>At(i,n,o))}function Ey(e,t,n,i){return Ge(e,t,er,(s,o)=>{s.put(i,n),nr(o)})}function Cy(e,t){return Ge(e,Zo,er,(n,i)=>At(n,t,s=>{n.put((s||0)+1,t),nr(i)}))}function Ty(e,t,n){return n===0?[]:Ge(e,[Zo,Tt],Xt,([i,s],o,r)=>{const a=[];i.index(Su).openCursor(void 0,"prev").onsuccess=u=>{const c=u.target.result;if(!c)return r(a);function l(b){if(a.push(b),a.length===n)return r(a);c.continue()}const p=c.primaryKey,f=t.byName(p);if(f)return l(f);At(s,p,b=>{if(b)return l(b);c.continue()})}})}const ii="";function _y(e,t){const n=new Map;for(const s of e){const o=t(s);for(const r of o){let a=n;for(let c=0;c<r.length;c++){const l=r.charAt(c);let p=a.get(l);p||(p=new Map,a.set(l,p)),a=p}let u=a.get(ii);u||(u=[],a.set(ii,u)),u.push(s)}}return(s,o)=>{let r=n;for(let c=0;c<s.length;c++){const l=s.charAt(c),p=r.get(l);if(p)r=p;else return[]}if(o)return r.get(ii)||[];const a=[],u=[r];for(;u.length;){const l=[...u.shift().entries()].sort((p,f)=>p[0]<f[0]?-1:1);for(const[p,f]of l)p===ii?a.push(...f):u.push(f)}return a}}const My=["name","url"];function Py(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||My.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function Ha(e){Py(e);const t=(f,b)=>f.name.toLowerCase()<b.name.toLowerCase()?-1:1,n=e.sort(t),s=_y(e,f=>{const b=new Set;if(f.shortcodes)for(const h of f.shortcodes)for(const v of Ut(h))b.add(v);return b}),o=f=>s(f,!0),r=f=>s(f,!1),a=f=>{const b=Ut(f),h=b.map((v,S)=>(S<b.length-1?o:r)(v));return _u(h,v=>v.name).sort(t)},u=new Map,c=new Map;for(const f of e){c.set(f.name.toLowerCase(),f);for(const b of f.shortcodes||[])u.set(b.toLowerCase(),f)}return{all:n,search:a,byShortcode:f=>u.get(f.toLowerCase()),byName:f=>c.get(f.toLowerCase())}}const Ly=typeof wrappedJSObject<"u";function hn(e){if(!e)return e;if(Ly&&(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 Lu(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Iy=["annotation","emoji","group","order","version"];function Ry(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Iy.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function Iu(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Dy(e){const t=await fetch(e,{method:"HEAD"});Iu(t,e);const n=t.headers.get("etag");return Lu(n),n}async function ao(e){const t=await fetch(e);Iu(t,e);const n=t.headers.get("etag");Lu(n);const i=await t.json();return Ry(i),[n,i]}function By(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Ny(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 Ru(e){const t=JSON.stringify(e);let n=Ny(t);const i=await crypto.subtle.digest("SHA-1",n),s=By(i);return btoa(s)}async function Oy(e,t){let n,i=await Dy(t);if(!i){const s=await ao(t);i=s[0],n=s[1],i||(i=await Ru(n))}await ky(e,t,i)||(n||(n=(await ao(t))[1]),await Mu(e,n,t,i))}async function Fy(e,t){let[n,i]=await ao(t);n||(n=await Ru(i)),await Mu(e,i,t,n)}async function Uy(e,t){try{await Oy(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class Wy{constructor({dataSource:t=ly,locale:n=cy,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=Ha(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await hy(this._dbName);gy(this._dbName,this._clear);const n=this.dataSource;await wy(t)?await Fy(t,n):this._lazyUpdate=Uy(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 Cs(t),await this.ready(),qa(await $y(this._db,t)).map(hn)}async getEmojiBySearchQuery(t){ni(t),await this.ready();const n=this._custom.search(t),i=qa(await Pu(this._db,t)).map(hn);return[...n,...i]}async getEmojiByShortcode(t){ni(t),await this.ready();const n=this._custom.byShortcode(t);return n||hn(await Ay(this._db,t))}async getEmojiByUnicodeOrName(t){ni(t),await this.ready();const n=this._custom.byName(t);return n||hn(await xy(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await ir(this._db,qt,za)||0}async setPreferredSkinTone(t){return Cs(t),await this.ready(),Ey(this._db,qt,za,t)}async incrementFavoriteEmojiCount(t){return ni(t),await this.ready(),Cy(this._db,t)}async getTopFavoriteEmoji(t){return Cs(t),await this.ready(),(await Ty(this._db,this._custom,t)).map(hn)}set customEmoji(t){this._custom=Ha(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 tr(this._dbName)}async delete(){await this._shutdown(),await fy(this._dbName)}}const lo=[[-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})),Ts=lo.slice(1),Ky=2,ja=6,Du=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function Va(e){return e.unicode.includes("‍")}const zy={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},qy=1e3,Hy="🖐️",jy=8,Vy=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],Bu='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',Gy=(e,t)=>e<t?-1:e>t?1:0,Ga=(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 ${Bu}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},Qy=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function Yy(e){const t=Ga(e,"#000"),n=Ga(e,"#fff");return t&&n&&Qy(t,n)}function Xy(){const e=Object.entries(zy);try{for(const[t,n]of e)if(Yy(t))return n}catch{}return e[0][1]}let _s;const Ms=()=>(_s||(_s=new Promise(e=>Du(()=>e(Xy())))),_s),co=new Map,Jy="️",Zy="\uD83C",ev="‍",tv=127995,nv=57339;function iv(e,t){if(t===0)return e;const n=e.indexOf(ev);return n!==-1?e.substring(0,n)+String.fromCodePoint(tv+t-1)+e.substring(n):(e.endsWith(Jy)&&(e=e.substring(0,e.length-1)),e+Zy+String.fromCodePoint(nv+t-1))}function _e(e){e.preventDefault(),e.stopPropagation()}function Ps(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function Nu(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 sv(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:r,name:a,category:u,annotation:c})=>({unicode:i,name:a,shortcodes:o,url:r,category:u,annotation:c,id:i||a,skins:s&&n(s)}))}const di=requestAnimationFrame;let ov=typeof ResizeObserver=="function";function rv(e,t,n){let i;ov?(i=new ResizeObserver(n),i.observe(e)):di(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function Qa(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let Ls;function av(e,t,n){let i=!0,s=!1;for(const o of e){const r=n(o);if(!r)continue;const a=Qa(r);a===0&&(s=!0),typeof Ls>"u"&&(Ls=Qa(t));const u=a/1.8<Ls;co.set(o.unicode,u),u||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
2521
2519
  This is likely due to using \`display:none\` which is unsupported.
2522
2520
  If this is a Jest/Vitest environment, you can ignore this warning.
2523
- For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function av(e){return Du(e,t=>t)}function lv(e){e&&(e.scrollTop=0)}function $n(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function Qa(e){return""+e}function cv(e){const t=document.createElement("template");return t.innerHTML=e,t}const uv=new WeakMap,dv=new WeakMap,pv=Symbol("un-keyed"),hv="replaceChildren"in Element.prototype;function fv(e,t){hv?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function gv(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 mv(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=gv(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&fv(i,e)}function yv(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:r,attributeValuePre:a,attributeValuePost:u}}=n,c=e[o];if(s!==c)if(n.currentExpression=c,r)if(c===null)i.removeAttribute(r);else{const l=a+Qa(c)+u;i.setAttribute(r,l)}else{let l;Array.isArray(c)?mv(c,n):c instanceof Element?(l=c,i.replaceWith(l)):i.nodeValue=Qa(c),l&&(n.targetNode=l)}}}function vv(e){let t="",n=!1,i=!1,s=-1;const o=new Map,r=[];let a=0;for(let c=0,l=e.length;c<l;c++){const p=e[c];if(t+=p.slice(a),c===l-1)break;for(let A=0;A<p.length;A++)switch(p.charAt(A)){case"<":{p.charAt(A+1)==="/"?r.pop():(n=!0,r.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const f=r[r.length-1],b=$n(o,f,()=>[]);let h,v,S;if(i){const A=/(\S+)="?([^"=]*)$/.exec(p);h=A[1],v=A[2];const E=/^([^">]*)("?)/.exec(e[c+1]);S=E[1],t=t.slice(0,-1*A[0].length),a=E[0].length}else a=0;const $={attributeName:h,attributeValuePre:v,attributeValuePost:S,expressionIndex:c};b.push($),!n&&!i&&(t+=" ")}return{template:cv(t),elementsToBindings:o}}function Ya(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,r={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(r)}}function bv(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))Ya(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,r=-1;do{const a=t.get(++r);a&&Ya(a,o,n)}while(o=s.nextNode())}return n}function wv(e){const{template:t,elementsToBindings:n}=$n(uv,e,()=>vv(e)),i=t.cloneNode(!0).content.firstElementChild,s=bv(i,n);return function(r){return yv(r,s),i}}function kv(e){const t=$n(dv,e,()=>new Map);let n=pv;function i(o,...r){const a=$n(t,o,()=>new Map);return $n(a,n,()=>wv(o))(r)}function s(o,r,a){return o.map((u,c)=>{const l=n;n=a(u);try{return r(u,c)}finally{n=l}})}return{map:s,html:i}}function Sv(e,t,n,i,s,o,r,a,u){const{labelWithSkin:c,titleForEmoji:l,unicodeWithSkin:p}=n,{html:f,map:b}=kv(t);function h(A,E,T){return b(A,(_,B)=>f`<button role="${E?"option":"menuitem"}" aria-selected="${E?B===t.activeSearchItem:null}" aria-label="${c(_,t.currentSkinTone)}" title="${l(_)}" class="${"emoji"+(E&&B===t.activeSearchItem?" active":"")+(_.unicode?"":" custom-emoji")}" id="${`${T}-${_.id}`}" style="${_.unicode?null:`--custom-emoji-background: url(${JSON.stringify(_.url)})`}">${_.unicode?p(_,t.currentSkinTone):""}</button>`,_=>`${T}-${_.id}`)}const S=f`<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">${b(t.skinTones,(A,E)=>f`<div id="skintone-${E}" class="emoji ${E===t.activeSkinTone?"active":""}" aria-selected="${E===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[E]}" aria-label="${t.i18n.skinTones[E]}">${A}</div>`,A=>A)}</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">${b(t.groups,A=>f`<button role="tab" class="nav-button" aria-controls="tab-${A.id}" aria-label="${t.i18n.categories[A.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===A.id}" title="${t.i18n.categories[A.name]}" data-group-id="${A.id}"><div class="nav-emoji emoji">${A.emoji}</div></button>`,A=>A.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">${b(t.currentEmojisWithCategories,(A,E)=>f`<div><div id="menu-label-${E}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:A.category?A.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${E!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(A.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${E}" id="${t.searchMode?"search-results":null}">${h(A.emojis,t.searchMode,"emo")}</div></div>`,A=>A.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${h(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,$=(A,E)=>{for(const T of e.querySelectorAll(`[${A}]`))E(T,T.getAttribute(A))};if(u){e.appendChild(S);for(const A of["click","focusout","input","keydown","keyup"])$(`data-on-${A}`,(E,T)=>{E.addEventListener(A,i[T])});$("data-ref",(A,E)=>{o[E]=A}),r.addEventListener("abort",()=>{e.removeChild(S)})}$("data-action",(A,E)=>{let T=a.get(E);T||a.set(E,T=new WeakSet),T.has(A)||(T.add(A),s[E](A))})}const Pi=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function $v(e){let t=!1,n;const i=new Map,s=new Set;let o;const r=()=>{if(t)return;const c=[...s];s.clear();try{for(const l of c)l()}finally{o=!1,s.size&&(o=!0,Pi(r))}},a=new Proxy({},{get(c,l){if(n){let p=i.get(l);p||(p=new Set,i.set(l,p)),p.add(n)}return c[l]},set(c,l,p){if(c[l]!==p){c[l]=p;const f=i.get(l);if(f){for(const b of f)s.add(b);o||(o=!0,Pi(r))}}return!0}}),u=c=>{const l=()=>{const p=n;n=l;try{return c()}finally{n=p}};return l()};return e.addEventListener("abort",()=>{t=!0}),{state:a,createEffect:u}}function Ls(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 Xa=new WeakMap;function Av(e,t,n){{const i=e.closest(".tabpanel");let s=Xa.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),Xa.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const Is=[],{assign:si}=Object;function xv(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:r}=$v(s),a=new Map;si(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),si(o,t),si(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:Hy,isRtl:!1,currentGroupIndex:0,groups:Cs,databaseLoaded:!1,activeSearchItemId:void 0}),r(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const u=x=>{e.getElementById(x).focus()},c=x=>e.getElementById(`emo-${x.id}`),l=(x,M)=>{n.rootElement.dispatchEvent(new CustomEvent(x,{detail:M,bubbles:!0,composed:!0}))},p=(x,M)=>x.id===M.id,f=(x,M)=>{const{category:N,emojis:O}=x,{category:Q,emojis:H}=M;return N!==Q?!1:Ls(O,H,p)},b=x=>{Ls(o.currentEmojis,x,p)||(o.currentEmojis=x)},h=x=>{o.searchMode!==x&&(o.searchMode=x)},v=x=>{Ls(o.currentEmojisWithCategories,x,f)||(o.currentEmojisWithCategories=x)},S=(x,M)=>M&&x.skins&&x.skins[M]||x.unicode,E={labelWithSkin:(x,M)=>av([x.name||S(x,M),x.annotation,...x.shortcodes||Is].filter(Boolean)).join(", "),titleForEmoji:x=>x.annotation||(x.shortcodes||Is).join(", "),unicodeWithSkin:S},T={onClickSkinToneButton:G,onEmojiClick:Dn,onNavClick:In,onNavKeydown:Yi,onSearchKeydown:Qi,onSkinToneOptionsClick:Bn,onSkinToneOptionsFocusOut:Ye,onSkinToneOptionsKeydown:at,onSkinToneOptionsKeyup:Zt,onSearchInput:Nn},_={calculateEmojiGridStyle:ne,updateOnIntersection:be};let B=!0;r(()=>{Sv(e,o,E,T,_,n,s,a,B),B=!1}),o.emojiVersion||_s().then(x=>{x||(o.message=o.i18n.emojiUnsupportedMessage)}),r(()=>{async function x(){let M=!1;const N=setTimeout(()=>{M=!0,o.message=o.i18n.loadingMessage},zy);try{await o.database.ready(),o.databaseLoaded=!0}catch(O){console.error(O),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(N),M&&(M=!1,o.message="")}}o.database&&x()}),r(()=>{o.pickerStyle=`
2521
+ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function lv(e){return Nu(e,t=>t)}function cv(e){e&&(e.scrollTop=0)}function $n(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function Ya(e){return""+e}function uv(e){const t=document.createElement("template");return t.innerHTML=e,t}const dv=new WeakMap,pv=new WeakMap,hv=Symbol("un-keyed"),fv="replaceChildren"in Element.prototype;function gv(e,t){fv?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function mv(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 yv(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=mv(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&gv(i,e)}function vv(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:r,attributeValuePre:a,attributeValuePost:u}}=n,c=e[o];if(s!==c)if(n.currentExpression=c,r)if(c===null)i.removeAttribute(r);else{const l=a+Ya(c)+u;i.setAttribute(r,l)}else{let l;Array.isArray(c)?yv(c,n):c instanceof Element?(l=c,i.replaceWith(l)):i.nodeValue=Ya(c),l&&(n.targetNode=l)}}}function bv(e){let t="",n=!1,i=!1,s=-1;const o=new Map,r=[];let a=0;for(let c=0,l=e.length;c<l;c++){const p=e[c];if(t+=p.slice(a),c===l-1)break;for(let A=0;A<p.length;A++)switch(p.charAt(A)){case"<":{p.charAt(A+1)==="/"?r.pop():(n=!0,r.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const f=r[r.length-1],b=$n(o,f,()=>[]);let h,v,S;if(i){const A=/(\S+)="?([^"=]*)$/.exec(p);h=A[1],v=A[2];const E=/^([^">]*)("?)/.exec(e[c+1]);S=E[1],t=t.slice(0,-1*A[0].length),a=E[0].length}else a=0;const $={attributeName:h,attributeValuePre:v,attributeValuePost:S,expressionIndex:c};b.push($),!n&&!i&&(t+=" ")}return{template:uv(t),elementsToBindings:o}}function Xa(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,r={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(r)}}function wv(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))Xa(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,r=-1;do{const a=t.get(++r);a&&Xa(a,o,n)}while(o=s.nextNode())}return n}function kv(e){const{template:t,elementsToBindings:n}=$n(dv,e,()=>bv(e)),i=t.cloneNode(!0).content.firstElementChild,s=wv(i,n);return function(r){return vv(r,s),i}}function Sv(e){const t=$n(pv,e,()=>new Map);let n=hv;function i(o,...r){const a=$n(t,o,()=>new Map);return $n(a,n,()=>kv(o))(r)}function s(o,r,a){return o.map((u,c)=>{const l=n;n=a(u);try{return r(u,c)}finally{n=l}})}return{map:s,html:i}}function $v(e,t,n,i,s,o,r,a,u){const{labelWithSkin:c,titleForEmoji:l,unicodeWithSkin:p}=n,{html:f,map:b}=Sv(t);function h(A,E,T){return b(A,(_,D)=>f`<button role="${E?"option":"menuitem"}" aria-selected="${E?D===t.activeSearchItem:null}" aria-label="${c(_,t.currentSkinTone)}" title="${l(_)}" class="${"emoji"+(E&&D===t.activeSearchItem?" active":"")+(_.unicode?"":" custom-emoji")}" id="${`${T}-${_.id}`}" style="${_.unicode?null:`--custom-emoji-background: url(${JSON.stringify(_.url)})`}">${_.unicode?p(_,t.currentSkinTone):""}</button>`,_=>`${T}-${_.id}`)}const S=f`<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">${b(t.skinTones,(A,E)=>f`<div id="skintone-${E}" class="emoji ${E===t.activeSkinTone?"active":""}" aria-selected="${E===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[E]}" aria-label="${t.i18n.skinTones[E]}">${A}</div>`,A=>A)}</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">${b(t.groups,A=>f`<button role="tab" class="nav-button" aria-controls="tab-${A.id}" aria-label="${t.i18n.categories[A.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===A.id}" title="${t.i18n.categories[A.name]}" data-group-id="${A.id}"><div class="nav-emoji emoji">${A.emoji}</div></button>`,A=>A.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">${b(t.currentEmojisWithCategories,(A,E)=>f`<div><div id="menu-label-${E}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:A.category?A.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${E!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(A.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${E}" id="${t.searchMode?"search-results":null}">${h(A.emojis,t.searchMode,"emo")}</div></div>`,A=>A.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${h(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,$=(A,E)=>{for(const T of e.querySelectorAll(`[${A}]`))E(T,T.getAttribute(A))};if(u){e.appendChild(S);for(const A of["click","focusout","input","keydown","keyup"])$(`data-on-${A}`,(E,T)=>{E.addEventListener(A,i[T])});$("data-ref",(A,E)=>{o[E]=A}),r.addEventListener("abort",()=>{e.removeChild(S)})}$("data-action",(A,E)=>{let T=a.get(E);T||a.set(E,T=new WeakSet),T.has(A)||(T.add(A),s[E](A))})}const Li=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Av(e){let t=!1,n;const i=new Map,s=new Set;let o;const r=()=>{if(t)return;const c=[...s];s.clear();try{for(const l of c)l()}finally{o=!1,s.size&&(o=!0,Li(r))}},a=new Proxy({},{get(c,l){if(n){let p=i.get(l);p||(p=new Set,i.set(l,p)),p.add(n)}return c[l]},set(c,l,p){if(c[l]!==p){c[l]=p;const f=i.get(l);if(f){for(const b of f)s.add(b);o||(o=!0,Li(r))}}return!0}}),u=c=>{const l=()=>{const p=n;n=l;try{return c()}finally{n=p}};return l()};return e.addEventListener("abort",()=>{t=!0}),{state:a,createEffect:u}}function Is(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 Ja=new WeakMap;function xv(e,t,n){{const i=e.closest(".tabpanel");let s=Ja.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),Ja.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const Rs=[],{assign:si}=Object;function Ev(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:r}=Av(s),a=new Map;si(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),si(o,t),si(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:jy,isRtl:!1,currentGroupIndex:0,groups:Ts,databaseLoaded:!1,activeSearchItemId:void 0}),r(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const u=x=>{e.getElementById(x).focus()},c=x=>e.getElementById(`emo-${x.id}`),l=(x,M)=>{n.rootElement.dispatchEvent(new CustomEvent(x,{detail:M,bubbles:!0,composed:!0}))},p=(x,M)=>x.id===M.id,f=(x,M)=>{const{category:N,emojis:O}=x,{category:Q,emojis:H}=M;return N!==Q?!1:Is(O,H,p)},b=x=>{Is(o.currentEmojis,x,p)||(o.currentEmojis=x)},h=x=>{o.searchMode!==x&&(o.searchMode=x)},v=x=>{Is(o.currentEmojisWithCategories,x,f)||(o.currentEmojisWithCategories=x)},S=(x,M)=>M&&x.skins&&x.skins[M]||x.unicode,E={labelWithSkin:(x,M)=>lv([x.name||S(x,M),x.annotation,...x.shortcodes||Rs].filter(Boolean)).join(", "),titleForEmoji:x=>x.annotation||(x.shortcodes||Rs).join(", "),unicodeWithSkin:S},T={onClickSkinToneButton:G,onEmojiClick:Dn,onNavClick:In,onNavKeydown:Xi,onSearchKeydown:Yi,onSkinToneOptionsClick:Bn,onSkinToneOptionsFocusOut:Ye,onSkinToneOptionsKeydown:rt,onSkinToneOptionsKeyup:Zt,onSearchInput:Nn},_={calculateEmojiGridStyle:ne,updateOnIntersection:be};let D=!0;r(()=>{$v(e,o,E,T,_,n,s,a,D),D=!1}),o.emojiVersion||Ms().then(x=>{x||(o.message=o.i18n.emojiUnsupportedMessage)}),r(()=>{async function x(){let M=!1;const N=setTimeout(()=>{M=!0,o.message=o.i18n.loadingMessage},qy);try{await o.database.ready(),o.databaseLoaded=!0}catch(O){console.error(O),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(N),M&&(M=!1,o.message="")}}o.database&&x()}),r(()=>{o.pickerStyle=`
2524
2522
  --num-groups: ${o.groups.length};
2525
2523
  --indicator-opacity: ${o.searchMode?0:1};
2526
- --num-skintones: ${Ha};`}),r(()=>{o.customEmoji&&o.database&&F()}),r(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==ao&&(o.groups=ao):o.groups!==Cs&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=Cs)}),r(()=>{async function x(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}x()}),r(()=>{o.skinTones=Array(Ha).fill().map((x,M)=>nv(o.skinToneEmoji,M))}),r(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),r(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),r(()=>{async function x(){const{database:M}=o,N=(await Promise.all(jy.map(O=>M.getEmojiByUnicodeOrName(O)))).filter(Boolean);o.defaultFavoriteEmojis=N}o.databaseLoaded&&x()});function F(){const{customEmoji:x,database:M}=o,N=x||Is;M.customEmoji!==N&&(M.customEmoji=N)}r(()=>{async function x(){F();const{database:M,defaultFavoriteEmojis:N,numColumns:O}=o,Q=await M.getTopFavoriteEmoji(O),H=await rt(Du([...Q,...N],ue=>ue.unicode||ue.name).slice(0,O));o.currentFavorites=H}o.databaseLoaded&&o.defaultFavoriteEmojis&&x()});function ne(x){ov(x,s,()=>{{const M=getComputedStyle(n.rootElement),N=parseInt(M.getPropertyValue("--num-columns"),10),O=M.getPropertyValue("direction")==="rtl";o.numColumns=N,o.isRtl=O}})}function be(x){Av(x,s,M=>{for(const{target:N,isIntersecting:O}of M)N.classList.toggle("onscreen",O)})}r(()=>{async function x(){const{searchText:M,currentGroup:N,databaseLoaded:O,customEmoji:Q}=o;if(!O)o.currentEmojis=[],o.searchMode=!1;else if(M.length>=Wy){const H=await Gi(M);o.searchText===M&&(b(H),h(!0))}else{const{id:H}=N;if(H!==-1||Q&&Q.length){const ue=await Vi(H);o.currentGroup.id===H&&(b(ue),h(!1))}}}x()});const Qe=()=>{di(()=>lv(n.tabpanelElement))};r(()=>{const{currentEmojis:x,emojiVersion:M}=o,N=x.filter(O=>O.unicode).filter(O=>ja(O)&&!lo.has(O.unicode));if(!M&&N.length)b(x),di(()=>ee(N));else{const O=M?x:x.filter(Jt);b(O),Qe()}});function ee(x){rv(x,n.baselineEmoji,c)?Qe():o.currentEmojis=[...o.currentEmojis]}function Jt(x){return!x.unicode||!ja(x)||lo.get(x.unicode)}async function Tt(x){const M=o.emojiVersion||await _s();return x.filter(({version:N})=>!N||N<=M)}async function rt(x){return iv(x,o.emojiVersion||await _s())}async function Vi(x){const M=x===-1?o.customEmoji:await o.database.getEmojiByGroup(x);return rt(await Tt(M))}async function Gi(x){return rt(await Tt(await o.database.getEmojiBySearchQuery(x)))}r(()=>{}),r(()=>{function x(){const{searchMode:N,currentEmojis:O}=o;if(N)return[{category:"",emojis:O}];const Q=new Map;for(const H of O){const ue=H.category||"";let Xe=Q.get(ue);Xe||(Xe=[],Q.set(ue,Xe)),Xe.push(H)}return[...Q.entries()].map(([H,ue])=>({category:H,emojis:ue})).sort((H,ue)=>o.customCategorySorting(H.category,ue.category))}const M=x();v(M)}),r(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),r(()=>{const{rawSearchText:x}=o;Iu(()=>{o.searchText=(x||"").trim(),o.activeSearchItem=-1})});function Qi(x){if(!o.searchMode||!o.currentEmojis.length)return;const M=N=>{_e(x),o.activeSearchItem=Ms(N,o.activeSearchItem,o.currentEmojis)};switch(x.key){case"ArrowDown":return M(!1);case"ArrowUp":return M(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return _e(x),X(o.currentEmojis[o.activeSearchItem].id)}}function In(x){const{target:M}=x,N=M.closest(".nav-button");if(!N)return;const O=parseInt(N.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(Q=>Q.id===O)}function Yi(x){const{target:M,key:N}=x,O=Q=>{Q&&(_e(x),Q.focus())};switch(N){case"ArrowLeft":return O(M.previousElementSibling);case"ArrowRight":return O(M.nextElementSibling);case"Home":return O(M.parentElement.firstElementChild);case"End":return O(M.parentElement.lastElementChild)}}async function Rn(x){const M=await o.database.getEmojiByUnicodeOrName(x),N=[...o.currentEmojis,...o.currentFavorites].find(Q=>Q.id===x),O=N.unicode&&S(N,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(x),{emoji:M,skinTone:o.currentSkinTone,...O&&{unicode:O},...N.name&&{name:N.name}}}async function X(x){const M=Rn(x);l("emoji-click-sync",M),l("emoji-click",await M)}function Dn(x){const{target:M}=x;if(!M.classList.contains("emoji"))return;_e(x);const N=M.id.substring(4);X(N)}function J(x){o.currentSkinTone=x,o.skinTonePickerExpanded=!1,u("skintone-button"),l("skin-tone-change",{skinTone:x}),o.database.setPreferredSkinTone(x)}function Bn(x){const{target:{id:M}}=x,N=M&&M.match(/^skintone-(\d)/);if(!N)return;_e(x);const O=parseInt(N[1],10);J(O)}function G(x){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(_e(x),di(()=>u("skintone-list")))}r(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function at(x){if(!o.skinTonePickerExpanded)return;const M=async N=>{_e(x),o.activeSkinTone=N};switch(x.key){case"ArrowUp":return M(Ms(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return M(Ms(!1,o.activeSkinTone,o.skinTones));case"Home":return M(0);case"End":return M(o.skinTones.length-1);case"Enter":return _e(x),J(o.activeSkinTone);case"Escape":return _e(x),o.skinTonePickerExpanded=!1,u("skintone-button")}}function Zt(x){if(o.skinTonePickerExpanded&&x.key===" ")return _e(x),J(o.activeSkinTone)}async function Ye(x){const{relatedTarget:M}=x;(!M||M.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function Nn(x){o.rawSearchText=x.target.value}return{$set(x){si(o,x)},$destroy(){i.abort()}}}const Ev="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Cv="en";var Tv={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"}},_v=':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 Bu=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Mv=`:host{--emoji-font-family:${Ru}}`;class ir extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=_v+Mv,this.shadowRoot.appendChild(n),this._ctx={locale:Cv,dataSource:Ev,skinToneEmoji:qy,customCategorySorting:Vy,customEmoji:null,i18n:Tv,emojiVersion:null,...t};for(const i of Bu)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){Ja(this),this._cmp||(this._cmp=xv(this.shadowRoot,this._ctx))}disconnectedCallback(){Ja(this),Pi(()=>{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 Uy({locale:t,dataSource:n}))}_dbFlush(){Pi(()=>this._dbCreate())}}const Nu={};for(const e of Bu)Nu[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(ir.prototype,Nu);function Ja(e){e instanceof ir||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",ir);function Pv(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 Za(e){e.style.height="44px",e.style.overflowY="hidden"}const Lv=5e3;function Iv(e){return e?e.active?d`
2524
+ --num-skintones: ${ja};`}),r(()=>{o.customEmoji&&o.database&&F()}),r(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==lo&&(o.groups=lo):o.groups!==Ts&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=Ts)}),r(()=>{async function x(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}x()}),r(()=>{o.skinTones=Array(ja).fill().map((x,M)=>iv(o.skinToneEmoji,M))}),r(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),r(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),r(()=>{async function x(){const{database:M}=o,N=(await Promise.all(Vy.map(O=>M.getEmojiByUnicodeOrName(O)))).filter(Boolean);o.defaultFavoriteEmojis=N}o.databaseLoaded&&x()});function F(){const{customEmoji:x,database:M}=o,N=x||Rs;M.customEmoji!==N&&(M.customEmoji=N)}r(()=>{async function x(){F();const{database:M,defaultFavoriteEmojis:N,numColumns:O}=o,Q=await M.getTopFavoriteEmoji(O),H=await ot(Nu([...Q,...N],ue=>ue.unicode||ue.name).slice(0,O));o.currentFavorites=H}o.databaseLoaded&&o.defaultFavoriteEmojis&&x()});function ne(x){rv(x,s,()=>{{const M=getComputedStyle(n.rootElement),N=parseInt(M.getPropertyValue("--num-columns"),10),O=M.getPropertyValue("direction")==="rtl";o.numColumns=N,o.isRtl=O}})}function be(x){xv(x,s,M=>{for(const{target:N,isIntersecting:O}of M)N.classList.toggle("onscreen",O)})}r(()=>{async function x(){const{searchText:M,currentGroup:N,databaseLoaded:O,customEmoji:Q}=o;if(!O)o.currentEmojis=[],o.searchMode=!1;else if(M.length>=Ky){const H=await Qi(M);o.searchText===M&&(b(H),h(!0))}else{const{id:H}=N;if(H!==-1||Q&&Q.length){const ue=await Gi(H);o.currentGroup.id===H&&(b(ue),h(!1))}}}x()});const Qe=()=>{di(()=>cv(n.tabpanelElement))};r(()=>{const{currentEmojis:x,emojiVersion:M}=o,N=x.filter(O=>O.unicode).filter(O=>Va(O)&&!co.has(O.unicode));if(!M&&N.length)b(x),di(()=>ee(N));else{const O=M?x:x.filter(Jt);b(O),Qe()}});function ee(x){av(x,n.baselineEmoji,c)?Qe():o.currentEmojis=[...o.currentEmojis]}function Jt(x){return!x.unicode||!Va(x)||co.get(x.unicode)}async function _t(x){const M=o.emojiVersion||await Ms();return x.filter(({version:N})=>!N||N<=M)}async function ot(x){return sv(x,o.emojiVersion||await Ms())}async function Gi(x){const M=x===-1?o.customEmoji:await o.database.getEmojiByGroup(x);return ot(await _t(M))}async function Qi(x){return ot(await _t(await o.database.getEmojiBySearchQuery(x)))}r(()=>{}),r(()=>{function x(){const{searchMode:N,currentEmojis:O}=o;if(N)return[{category:"",emojis:O}];const Q=new Map;for(const H of O){const ue=H.category||"";let Xe=Q.get(ue);Xe||(Xe=[],Q.set(ue,Xe)),Xe.push(H)}return[...Q.entries()].map(([H,ue])=>({category:H,emojis:ue})).sort((H,ue)=>o.customCategorySorting(H.category,ue.category))}const M=x();v(M)}),r(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),r(()=>{const{rawSearchText:x}=o;Du(()=>{o.searchText=(x||"").trim(),o.activeSearchItem=-1})});function Yi(x){if(!o.searchMode||!o.currentEmojis.length)return;const M=N=>{_e(x),o.activeSearchItem=Ps(N,o.activeSearchItem,o.currentEmojis)};switch(x.key){case"ArrowDown":return M(!1);case"ArrowUp":return M(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return _e(x),X(o.currentEmojis[o.activeSearchItem].id)}}function In(x){const{target:M}=x,N=M.closest(".nav-button");if(!N)return;const O=parseInt(N.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(Q=>Q.id===O)}function Xi(x){const{target:M,key:N}=x,O=Q=>{Q&&(_e(x),Q.focus())};switch(N){case"ArrowLeft":return O(M.previousElementSibling);case"ArrowRight":return O(M.nextElementSibling);case"Home":return O(M.parentElement.firstElementChild);case"End":return O(M.parentElement.lastElementChild)}}async function Rn(x){const M=await o.database.getEmojiByUnicodeOrName(x),N=[...o.currentEmojis,...o.currentFavorites].find(Q=>Q.id===x),O=N.unicode&&S(N,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(x),{emoji:M,skinTone:o.currentSkinTone,...O&&{unicode:O},...N.name&&{name:N.name}}}async function X(x){const M=Rn(x);l("emoji-click-sync",M),l("emoji-click",await M)}function Dn(x){const{target:M}=x;if(!M.classList.contains("emoji"))return;_e(x);const N=M.id.substring(4);X(N)}function J(x){o.currentSkinTone=x,o.skinTonePickerExpanded=!1,u("skintone-button"),l("skin-tone-change",{skinTone:x}),o.database.setPreferredSkinTone(x)}function Bn(x){const{target:{id:M}}=x,N=M&&M.match(/^skintone-(\d)/);if(!N)return;_e(x);const O=parseInt(N[1],10);J(O)}function G(x){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(_e(x),di(()=>u("skintone-list")))}r(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function rt(x){if(!o.skinTonePickerExpanded)return;const M=async N=>{_e(x),o.activeSkinTone=N};switch(x.key){case"ArrowUp":return M(Ps(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return M(Ps(!1,o.activeSkinTone,o.skinTones));case"Home":return M(0);case"End":return M(o.skinTones.length-1);case"Enter":return _e(x),J(o.activeSkinTone);case"Escape":return _e(x),o.skinTonePickerExpanded=!1,u("skintone-button")}}function Zt(x){if(o.skinTonePickerExpanded&&x.key===" ")return _e(x),J(o.activeSkinTone)}async function Ye(x){const{relatedTarget:M}=x;(!M||M.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function Nn(x){o.rawSearchText=x.target.value}return{$set(x){si(o,x)},$destroy(){i.abort()}}}const Cv="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Tv="en";var _v={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"}},Mv=':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 Ou=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Pv=`:host{--emoji-font-family:${Bu}}`;class sr extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Mv+Pv,this.shadowRoot.appendChild(n),this._ctx={locale:Tv,dataSource:Cv,skinToneEmoji:Hy,customCategorySorting:Gy,customEmoji:null,i18n:_v,emojiVersion:null,...t};for(const i of Ou)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){Za(this),this._cmp||(this._cmp=Ev(this.shadowRoot,this._ctx))}disconnectedCallback(){Za(this),Li(()=>{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 Wy({locale:t,dataSource:n}))}_dbFlush(){Li(()=>this._dbCreate())}}const Fu={};for(const e of Ou)Fu[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(sr.prototype,Fu);function Za(e){e instanceof sr||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",sr);function Lv(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 el(e){e.style.height="44px",e.style.overflowY="hidden"}const Iv=5e3;function Rv(e){return e?e.active?d`
2527
2525
  <div class="callout info compaction-indicator compaction-indicator--active">
2528
2526
  ${L.loader} Compacting context...
2529
2527
  </div>
2530
- `:e.completedAt&&Date.now()-e.completedAt<Lv?d`
2528
+ `:e.completedAt&&Date.now()-e.completedAt<Iv?d`
2531
2529
  <div class="callout success compaction-indicator compaction-indicator--complete">
2532
2530
  ${L.check} Context compacted
2533
2531
  </div>
2534
- `:k:k}const ze=5*1024*1024;function qe(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Ae(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 r=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(o=r==null?void 0:r.parentElement)==null||o.insertBefore(n,r)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const Rv=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function Ou(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function Fu(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||Rv.test(e.name)}function Uu(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function Wu(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function Dv(e,t){if(!t.onAttachmentsChange)return;const n=document.querySelector(".chat");if(Ou(e)){if(e.size>ze){n&&Ae(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:qe(),dataUrl:i.result,mimeType:e.type};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(Fu(e)){if(e.size>ze){n&&Ae(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:qe(),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(Uu(e)){if(e.size>ze){n&&Ae(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:qe(),dataUrl:i.result,mimeType:"application/pdf",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(Wu(e)){if(e.size>ze){n&&Ae(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:qe(),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&&Ae(n,`Unsupported file type: ${e.name}. Use the Files page to upload to workspace.`)}function Bv(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 r=i[o];if(Ou(r)){if(!t.onAttachmentsChange)continue;if(r.size>ze){Ae(n,`Image too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const u=a.result,c={id:qe(),dataUrl:u,mimeType:r.type},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else if(Fu(r)){if(!t.onAttachmentsChange)continue;if(r.size>ze){Ae(n,`File too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const u=a.result,c={id:qe(),dataUrl:"",mimeType:r.type||"text/plain",fileName:r.name,textContent:u},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsText(r)}else if(Uu(r)){if(!t.onAttachmentsChange)continue;if(r.size>ze){Ae(n,`PDF too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const u=a.result,c={id:qe(),dataUrl:u,mimeType:"application/pdf",fileName:r.name},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else if(Wu(r)){if(!t.onAttachmentsChange)continue;if(r.size>ze){Ae(n,`Video too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const u=a.result,c={id:qe(),dataUrl:u,mimeType:r.type||"video/mp4",fileName:r.name},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else Ae(n,`Unsupported file type: ${r.name}. Use the Files page to upload to workspace.`)}}function Nv(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Ov(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function Fv(e,t){var s,o,r;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n||!t.onAttachmentsChange)return;const i=[];for(let a=0;a<n.length;a++){const u=n[a];(u.type.startsWith("image/")||u.type.startsWith("video/"))&&i.push(u)}if(i.length!==0){e.preventDefault();for(const a of i){const u=a.getAsFile();if(!u)continue;const c=u.type.startsWith("video/")?"Video":"Image";if(u.size>ze){const p=((r=(o=e.target)==null?void 0:o.closest)==null?void 0:r.call(o,".chat"))??document.querySelector(".chat");p&&Ae(p,`${c} too large (${(u.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const l=new FileReader;l.onload=()=>{var v;const p=l.result,f=u.type.startsWith("video/"),b={id:qe(),dataUrl:p,mimeType:u.type,fileName:f?u.name||"video.mp4":void 0},h=t.attachments??[];(v=t.onAttachmentsChange)==null||v.call(t,[...h,b])},l.readAsDataURL(u)}}}function Uv(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=r=>{i.contains(r.target)||t.contains(r.target)||(i.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",o,!0))};requestAnimationFrame(()=>document.addEventListener("click",o,!0))}}function Wv(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 r=o.selectionStart??t.draft.length,a=o.selectionEnd??r,u=t.draft.slice(0,r),c=t.draft.slice(a);t.onDraftChange(u+i+c);const l=s==null?void 0:s.querySelector(".emoji-picker-popup"),p=s==null?void 0:s.querySelector(".chat-compose__emoji");l==null||l.classList.remove("active"),p==null||p.classList.remove("active"),requestAnimationFrame(()=>{o.focus();const f=r+i.length;o.setSelectionRange(f,f)})}function Kv(e){const t=e.attachments??[];return t.length===0?k:d`
2532
+ `:k:k}const ze=5*1024*1024;function qe(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Ae(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 r=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(o=r==null?void 0:r.parentElement)==null||o.insertBefore(n,r)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const Dv=/\.(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 Wu(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||Dv.test(e.name)}function Ku(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function zu(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function Bv(e,t){if(!t.onAttachmentsChange)return;const n=document.querySelector(".chat");if(Uu(e)){if(e.size>ze){n&&Ae(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:qe(),dataUrl:i.result,mimeType:e.type};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(Wu(e)){if(e.size>ze){n&&Ae(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:qe(),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(Ku(e)){if(e.size>ze){n&&Ae(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:qe(),dataUrl:i.result,mimeType:"application/pdf",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(zu(e)){if(e.size>ze){n&&Ae(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:qe(),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&&Ae(n,`Unsupported file type: ${e.name}. Use the Files page to upload to workspace.`)}function Nv(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 r=i[o];if(Uu(r)){if(!t.onAttachmentsChange)continue;if(r.size>ze){Ae(n,`Image too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const u=a.result,c={id:qe(),dataUrl:u,mimeType:r.type},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else if(Wu(r)){if(!t.onAttachmentsChange)continue;if(r.size>ze){Ae(n,`File too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const u=a.result,c={id:qe(),dataUrl:"",mimeType:r.type||"text/plain",fileName:r.name,textContent:u},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsText(r)}else if(Ku(r)){if(!t.onAttachmentsChange)continue;if(r.size>ze){Ae(n,`PDF too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const u=a.result,c={id:qe(),dataUrl:u,mimeType:"application/pdf",fileName:r.name},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else if(zu(r)){if(!t.onAttachmentsChange)continue;if(r.size>ze){Ae(n,`Video too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const u=a.result,c={id:qe(),dataUrl:u,mimeType:r.type||"video/mp4",fileName:r.name},l=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...l,c])},a.readAsDataURL(r)}else Ae(n,`Unsupported file type: ${r.name}. Use the Files page to upload to workspace.`)}}function Ov(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Fv(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function Uv(e,t){var s,o,r;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n||!t.onAttachmentsChange)return;const i=[];for(let a=0;a<n.length;a++){const u=n[a];(u.type.startsWith("image/")||u.type.startsWith("video/"))&&i.push(u)}if(i.length!==0){e.preventDefault();for(const a of i){const u=a.getAsFile();if(!u)continue;const c=u.type.startsWith("video/")?"Video":"Image";if(u.size>ze){const p=((r=(o=e.target)==null?void 0:o.closest)==null?void 0:r.call(o,".chat"))??document.querySelector(".chat");p&&Ae(p,`${c} too large (${(u.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const l=new FileReader;l.onload=()=>{var v;const p=l.result,f=u.type.startsWith("video/"),b={id:qe(),dataUrl:p,mimeType:u.type,fileName:f?u.name||"video.mp4":void 0},h=t.attachments??[];(v=t.onAttachmentsChange)==null||v.call(t,[...h,b])},l.readAsDataURL(u)}}}function Wv(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=r=>{i.contains(r.target)||t.contains(r.target)||(i.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",o,!0))};requestAnimationFrame(()=>document.addEventListener("click",o,!0))}}function Kv(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 r=o.selectionStart??t.draft.length,a=o.selectionEnd??r,u=t.draft.slice(0,r),c=t.draft.slice(a);t.onDraftChange(u+i+c);const l=s==null?void 0:s.querySelector(".emoji-picker-popup"),p=s==null?void 0:s.querySelector(".chat-compose__emoji");l==null||l.classList.remove("active"),p==null||p.classList.remove("active"),requestAnimationFrame(()=>{o.focus();const f=r+i.length;o.setSelectionRange(f,f)})}function zv(e){const t=e.attachments??[];return t.length===0?k:d`
2535
2533
  <div class="chat-attachments">
2536
2534
  ${t.map(n=>{var i;return n.fileName?d`
2537
2535
  <div class="chat-attachment chat-attachment--file">
@@ -2564,7 +2562,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
2564
2562
  </div>
2565
2563
  `})}
2566
2564
  </div>
2567
- `}function Ku(e){var h,v,S;const t=e.connected,n=e.sending||e.stream!==null,i=!!(e.canAbort&&e.onAbort),s=(v=(h=e.sessions)==null?void 0:h.sessions)==null?void 0:v.find($=>$.key===e.sessionKey),o=(s==null?void 0:s.reasoningLevel)??"off",r=e.showThinking&&o!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const a=(((S=e.attachments)==null?void 0:S.length)??0)>0,u=e.connected?a?"Add a message...":"Message...":"Connecting…";Gm({onSend:$=>{e.onAttachmentsChange&&e.onAttachmentsChange([...e.attachments??[],$]),requestAnimationFrame(()=>e.onSend())},onRequestRender:()=>{e.onDraftChange(e.draft)}});const c=Vm(),l=!c&&!e.draft.trim()&&!a&&!n,p=e.splitRatio??.6,f=!!(e.sidebarOpen&&e.onCloseSidebar),b=d`
2565
+ `}function qu(e){var h,v,S;const t=e.connected,n=e.sending||e.stream!==null,i=!!(e.canAbort&&e.onAbort),s=(v=(h=e.sessions)==null?void 0:h.sessions)==null?void 0:v.find($=>$.key===e.sessionKey),o=(s==null?void 0:s.reasoningLevel)??"off",r=e.showThinking&&o!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const a=(((S=e.attachments)==null?void 0:S.length)??0)>0,u=e.connected?a?"Add a message...":"Message...":"Connecting…";Qm({onSend:$=>{e.onAttachmentsChange&&e.onAttachmentsChange([...e.attachments??[],$]),requestAnimationFrame(()=>e.onSend())},onRequestRender:()=>{var $;($=e.requestUpdate)==null||$.call(e)}});const c=Gm(),l=!c&&!e.draft.trim()&&!a&&!n,p=e.splitRatio??.6,f=!!(e.sidebarOpen&&e.onCloseSidebar),b=d`
2568
2566
  <div
2569
2567
  class="chat-thread"
2570
2568
  role="log"
@@ -2575,20 +2573,20 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
2575
2573
  ${e.loadingOlder?d`<span class="chat-load-more__spinner">${L.loader}</span> Loading older messages…`:d`<button class="chat-load-more__btn" type="button" @click=${e.onLoadOlder}>Load older messages</button>`}
2576
2574
  </div>`:k}
2577
2575
  ${e.loading?d`<div class="muted">Loading chat…</div>`:k}
2578
- ${cg(Qv(e),$=>$.key,$=>$.kind==="interim"?Dm($.text):$.kind==="reading-indicator"?Rm():$.kind==="stream"?Bm($.text,$.startedAt,e.onOpenSidebar):$.kind==="group"?Nm($,{onOpenSidebar:e.onOpenSidebar,showReasoning:r,assistantName:e.assistantName}):k)}
2576
+ ${dg(Yv(e),$=>$.key,$=>$.kind==="interim"?Nm($.text):$.kind==="reading-indicator"?Bm():$.kind==="stream"?Om($.text,$.startedAt,e.onOpenSidebar):$.kind==="group"?Fm($,{onOpenSidebar:e.onOpenSidebar,showReasoning:r,assistantName:e.assistantName}):k)}
2579
2577
  </div>
2580
2578
  `;return d`
2581
2579
  <section
2582
2580
  class="card chat"
2583
- @drop=${$=>Bv($,e)}
2584
- @dragover=${Nv}
2585
- @dragleave=${Ov}
2581
+ @drop=${$=>Nv($,e)}
2582
+ @dragover=${Ov}
2583
+ @dragleave=${Fv}
2586
2584
  >
2587
2585
  ${e.disabledReason?d`<div class="callout">${e.disabledReason}</div>`:k}
2588
2586
 
2589
2587
  ${e.error?d`<div class="callout danger">${e.error}</div>`:k}
2590
2588
 
2591
- ${Iv(e.compactionStatus)}
2589
+ ${Rv(e.compactionStatus)}
2592
2590
 
2593
2591
  ${e.focusMode?d`
2594
2592
  <button
@@ -2629,7 +2627,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
2629
2627
  @resize=${$=>{var A;return(A=e.onSplitRatioChange)==null?void 0:A.call(e,$.detail.splitRatio)}}
2630
2628
  ></resizable-divider>
2631
2629
  <div class="chat-sidebar">
2632
- ${Xm({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
2630
+ ${Jm({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
2633
2631
  ${e.sidebarContent}
2634
2632
  \`\`\``)}})}
2635
2633
  </div>
@@ -2649,13 +2647,13 @@ ${e.sidebarContent}
2649
2647
  `:k}
2650
2648
 
2651
2649
  <div class="chat-compose">
2652
- ${Kv(e)}
2653
- ${c?Ym():d`
2650
+ ${zv(e)}
2651
+ ${c?Xm():d`
2654
2652
  <div class="chat-compose__row">
2655
2653
  <button
2656
2654
  class="chat-compose__emoji"
2657
2655
  type="button"
2658
- @click=${Uv}
2656
+ @click=${Wv}
2659
2657
  aria-label="Emoji"
2660
2658
  title="Emoji"
2661
2659
  >
@@ -2676,16 +2674,16 @@ ${e.sidebarContent}
2676
2674
  multiple
2677
2675
  accept="image/*,video/*,.pdf,.md,.txt,.csv,.json,.xml,.html,.css,.js,.ts,.py,.sh,.yaml,.yml,.toml,.ini,.cfg,.log,.sql"
2678
2676
  style="display:none"
2679
- @change=${$=>{const A=$.target,E=A.files;if(!(!E||E.length===0||!e.onAttachmentsChange)){for(let T=0;T<E.length;T++)Dv(E[T],e);A.value=""}}}
2677
+ @change=${$=>{const A=$.target,E=A.files;if(!(!E||E.length===0||!e.onAttachmentsChange)){for(let T=0;T<E.length;T++)Bv(E[T],e);A.value=""}}}
2680
2678
  />
2681
2679
  <label class="field chat-compose__field">
2682
2680
  <span>Message</span>
2683
2681
  <textarea
2684
2682
  .value=${e.draft}
2685
2683
  ?disabled=${!e.connected}
2686
- @keydown=${$=>{$.key==="Enter"&&($.isComposing||$.keyCode===229||$.shiftKey||e.connected&&($.preventDefault(),t&&(e.onSend(),Za($.target))))}}
2687
- @input=${$=>{const A=$.target;e.onDraftChange(A.value),Pv(A)}}
2688
- @paste=${$=>Fv($,e)}
2684
+ @keydown=${$=>{$.key==="Enter"&&($.isComposing||$.keyCode===229||$.shiftKey||e.connected&&($.preventDefault(),t&&(e.onSend(),el($.target))))}}
2685
+ @input=${$=>{const A=$.target;e.onDraftChange(A.value),Lv(A)}}
2686
+ @paste=${$=>Uv($,e)}
2689
2687
  placeholder=${u}
2690
2688
  ></textarea>
2691
2689
  </label>
@@ -2699,11 +2697,11 @@ ${e.sidebarContent}
2699
2697
  ${L.square}
2700
2698
  </button>
2701
2699
  `:k}
2702
- ${l?Qm(e.connected):d`
2700
+ ${l?Ym(e.connected):d`
2703
2701
  <button
2704
2702
  class="btn btn--icon chat-compose__send primary"
2705
2703
  ?disabled=${!e.connected}
2706
- @click=${$=>{var E;e.onSend();const A=(E=$.target.closest(".chat-compose"))==null?void 0:E.querySelector("textarea");A&&Za(A)}}
2704
+ @click=${$=>{var E;e.onSend();const A=(E=$.target.closest(".chat-compose"))==null?void 0:E.querySelector("textarea");A&&el(A)}}
2707
2705
  aria-label="${n?"Queue":"Send"}"
2708
2706
  title="${n?"Queue message":"Send (Enter)"}"
2709
2707
  >
@@ -2712,13 +2710,13 @@ ${e.sidebarContent}
2712
2710
  </div>`}
2713
2711
  <div class="emoji-picker-popup">
2714
2712
  <emoji-picker
2715
- @emoji-click=${$=>Wv($,e)}
2713
+ @emoji-click=${$=>Kv($,e)}
2716
2714
  ></emoji-picker>
2717
2715
  </div>
2718
- ${e.publicMode?k:Vv(e)}
2716
+ ${e.publicMode?k:Gv(e)}
2719
2717
  </div>
2720
2718
  </section>
2721
- `}const zv=[{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"}];function qv(e){const t=new Set(e.filter(n=>n.provider==="anthropic").map(n=>n.id));return zv.filter(n=>t.has(n.id)).map(n=>({key:`anthropic/${n.id}`,...n}))}const Hv=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function jv(e){var s;const t=e.currentTarget,n=(s=t.closest(".chat-model-bar"))==null?void 0:s.querySelector(".chat-settings-menu");if(!n)return;const i=n.classList.contains("active");if(document.querySelectorAll(".chat-settings-menu.active").forEach(o=>o.classList.remove("active")),!i){n.classList.add("active");const o=r=>{!n.contains(r.target)&&r.target!==t&&!t.contains(r.target)&&(n.classList.remove("active"),document.removeEventListener("click",o))};requestAnimationFrame(()=>document.addEventListener("click",o))}}function Vv(e){if(!e.connected)return k;const t=e.modelCatalog??[],n=qv(t);if(n.length===0)return k;const i=e.modelProvider&&e.model?`${e.modelProvider}/${e.model}`:null,s=e.thinkingLevel??"off",o=e.verboseLevel==="on"||e.verboseLevel==="full",r=e.fillerEnabled===!0;return d`
2719
+ `}const qv=[{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"}];function Hv(e){const t=new Set(e.filter(n=>n.provider==="anthropic").map(n=>n.id));return qv.filter(n=>t.has(n.id)).map(n=>({key:`anthropic/${n.id}`,...n}))}const jv=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function Vv(e){var s;const t=e.currentTarget,n=(s=t.closest(".chat-model-bar"))==null?void 0:s.querySelector(".chat-settings-menu");if(!n)return;const i=n.classList.contains("active");if(document.querySelectorAll(".chat-settings-menu.active").forEach(o=>o.classList.remove("active")),!i){n.classList.add("active");const o=r=>{!n.contains(r.target)&&r.target!==t&&!t.contains(r.target)&&(n.classList.remove("active"),document.removeEventListener("click",o))};requestAnimationFrame(()=>document.addEventListener("click",o))}}function Gv(e){if(!e.connected)return k;const t=e.modelCatalog??[],n=Hv(t);if(n.length===0)return k;const i=e.modelProvider&&e.model?`${e.modelProvider}/${e.model}`:null,s=e.thinkingLevel??"off",o=e.verboseLevel==="on"||e.verboseLevel==="full",r=e.fillerEnabled===!0;return d`
2722
2720
  <div class="chat-model-bar">
2723
2721
  <div class="chat-model-bar__select">
2724
2722
  <select
@@ -2739,7 +2737,7 @@ ${e.sidebarContent}
2739
2737
  .value=${s}
2740
2738
  @change=${a=>{const u=a.target.value;e.onThinkingLevelChange&&e.onThinkingLevelChange(u)}}
2741
2739
  >
2742
- ${Hv.map(a=>d`
2740
+ ${jv.map(a=>d`
2743
2741
  <option value=${a.value} ?selected=${a.value===s}>
2744
2742
  Thinking: ${a.label}
2745
2743
  </option>
@@ -2749,7 +2747,7 @@ ${e.sidebarContent}
2749
2747
  <button
2750
2748
  class="chat-model-bar__settings-btn"
2751
2749
  type="button"
2752
- @click=${jv}
2750
+ @click=${Vv}
2753
2751
  aria-label="Message settings"
2754
2752
  title="Message settings"
2755
2753
  >
@@ -2776,9 +2774,9 @@ ${e.sidebarContent}
2776
2774
  </label>
2777
2775
  </div>
2778
2776
  </div>
2779
- `}function Gv(e){const t=[];let n=null;for(const i of e){if(i.kind!=="message"){n&&(t.push(n),n=null),t.push(i);continue}const s=Nl(i.message),o=Ol(s.role),r=s.timestamp||Date.now();!n||n.role!==o?(n&&t.push(n),n={kind:"group",key:`group:${o}:${i.key}`,role:o,messages:[{message:i.message,key:i.key}],timestamp:r,isStreaming:!1}):n.messages.push({message:i.message,key:i.key})}return n&&t.push(n),t}function Qv(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 r=0;r<n.length;r++){const a=n[r],u=Nl(a);if(!s&&u.role.toLowerCase()==="toolresult"){const c=a,p=(Array.isArray(c.content)?c.content:[]).filter(f=>{const b=f.type;return b==="image"||b==="file"});p.length>0&&t.push({kind:"message",key:Rs(a,r),message:{role:"assistant",content:p,timestamp:u.timestamp}});continue}t.push({kind:"message",key:Rs(a,r),message:a})}if(s)for(let r=0;r<i.length;r++)t.push({kind:"message",key:Rs(i[r],r+n.length),message:i[r]});if(e.interimText&&t.push({kind:"interim",key:"interim:thinking",text:e.interimText}),e.stream!==null){const r=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:r,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:r})}for(const r of e.queue){const a=((o=r.attachments)==null?void 0:o.filter(c=>c.fileName).map(c=>c.fileName))??[],u=a.length>0?r.text?`${a.join(", ")}
2777
+ `}function Qv(e){const t=[];let n=null;for(const i of e){if(i.kind!=="message"){n&&(t.push(n),n=null),t.push(i);continue}const s=Ol(i.message),o=Fl(s.role),r=s.timestamp||Date.now();!n||n.role!==o?(n&&t.push(n),n={kind:"group",key:`group:${o}:${i.key}`,role:o,messages:[{message:i.message,key:i.key}],timestamp:r,isStreaming:!1}):n.messages.push({message:i.message,key:i.key})}return n&&t.push(n),t}function Yv(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 r=0;r<n.length;r++){const a=n[r],u=Ol(a);if(!s&&u.role.toLowerCase()==="toolresult"){const c=a,p=(Array.isArray(c.content)?c.content:[]).filter(f=>{const b=f.type;return b==="image"||b==="file"});p.length>0&&t.push({kind:"message",key:Ds(a,r),message:{role:"assistant",content:p,timestamp:u.timestamp}});continue}t.push({kind:"message",key:Ds(a,r),message:a})}if(s)for(let r=0;r<i.length;r++)t.push({kind:"message",key:Ds(i[r],r+n.length),message:i[r]});if(e.interimText&&t.push({kind:"interim",key:"interim:thinking",text:e.interimText}),e.stream!==null){const r=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:r,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:r})}for(const r of e.queue){const a=((o=r.attachments)==null?void 0:o.filter(c=>c.fileName).map(c=>c.fileName))??[],u=a.length>0?r.text?`${a.join(", ")}
2780
2778
 
2781
- ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,message:{role:"user",content:[{type:"text",text:u}],timestamp:r.createdAt}})}return Gv(t)}function Rs(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 r=typeof n.timestamp=="number"?n.timestamp:null,a=typeof n.role=="string"?n.role:"unknown";return r!=null?`msg:${a}:${r}:${t}`:`msg:${a}:${t}`}const Yv=d`<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 Xv(e){if(!e.connected)return d`
2779
+ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,message:{role:"user",content:[{type:"text",text:u}],timestamp:r.createdAt}})}return Qv(t)}function Ds(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 r=typeof n.timestamp=="number"?n.timestamp:null,a=typeof n.role=="string"?n.role:"unknown";return r!=null?`msg:${a}:${r}:${t}`:`msg:${a}:${t}`}const Xv=d`<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 Jv(e){if(!e.connected)return d`
2782
2780
  <div class="setup-container">
2783
2781
  <div class="setup-card">
2784
2782
  <div class="setup-spinner"></div>
@@ -2791,20 +2789,20 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2791
2789
  target="_blank"
2792
2790
  rel="noopener"
2793
2791
  title="Open public chat in new tab"
2794
- >Public ${Yv}</a>`:k;return d`
2792
+ >Public ${Xv}</a>`:k;return d`
2795
2793
  <div class="setup-container setup-container--full chat-page">
2796
- ${xt("Chat",e.wsProps)}
2794
+ ${Et("Chat",e.wsProps)}
2797
2795
  ${t}
2798
2796
  <div class="chat-viewport">
2799
- ${Ku(e)}
2797
+ ${qu(e)}
2800
2798
  </div>
2801
2799
  </div>
2802
- `}function Jv(e){return e?`${Ll(e)} (${Ni(e)})`:"n/a"}function zu(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?Ni(t.lastRunAtMs):"never";return`${n} · last ${i}`}function qu(e){const t=e.schedule;return t.kind==="at"?`One-time: ${Ll(t.atMs)}`:t.kind==="every"?`Every ${Il(t.everyMs)}`:Zv(t.expr,t.tz)}function Zv(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,o,r,a]=n,u=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",c=(v,S)=>new Date(2e3,0,1,v,S).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),l=/^\d{1,2}$/.test(i)?parseInt(i,10):null,p=el(s);if(l===null||!p)return`${e}${t?` (${t})`:""}`;const f=p.map(v=>c(v,l)),b=f.length<=3?f.join(" & "):`${f.slice(0,-1).join(", ")} & ${f[f.length-1]}`,h=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(o==="*"&&r==="*"){if(a==="*")return`Daily at ${b}${u}`;if(a==="1-5")return`Weekdays at ${b}${u}`;if(a==="0,6"||a==="6,0")return`Weekends at ${b}${u}`;const v=el(a);if(v)return`${v.map($=>h[$%7]??String($)).join(", ")} at ${b}${u}`}return`${e}${t?` (${t})`:""}`}function el(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 eb(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 tl(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 r=i.split(",").map(a=>a.trim()).filter(Boolean).map(a=>a.toLowerCase()==="admins"?"All admins":a);s.push(r.join(", "))}return n&&n!=="last"&&s.push(`via ${n}`),s.join(" ")||null}let ye=null;function tb(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 nb(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 ib(e){return e.split(",").map(n=>n.trim()).filter(Boolean).map(n=>n.toLowerCase()==="admins"?"All admins":n).join(", ")}function sb(e){return e||"Default"}const ob=d`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,rb=d`<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>`,ab=d`<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>`,sr=d`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,lb=d`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,Hu=d`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`,cb=d`<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 nl(e){const t=e.detailJobId?e.jobs.find(i=>i.id===e.detailJobId)??null:null,n=e.newEventModalOpen||!!e.editJobId;return d`
2803
- ${ub(e)}
2800
+ `}function Zv(e){return e?`${Il(e)} (${Oi(e)})`:"n/a"}function Hu(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?Oi(t.lastRunAtMs):"never";return`${n} · last ${i}`}function ju(e){const t=e.schedule;return t.kind==="at"?`One-time: ${Il(t.atMs)}`:t.kind==="every"?`Every ${Rl(t.everyMs)}`:eb(t.expr,t.tz)}function eb(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,o,r,a]=n,u=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",c=(v,S)=>new Date(2e3,0,1,v,S).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),l=/^\d{1,2}$/.test(i)?parseInt(i,10):null,p=tl(s);if(l===null||!p)return`${e}${t?` (${t})`:""}`;const f=p.map(v=>c(v,l)),b=f.length<=3?f.join(" & "):`${f.slice(0,-1).join(", ")} & ${f[f.length-1]}`,h=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(o==="*"&&r==="*"){if(a==="*")return`Daily at ${b}${u}`;if(a==="1-5")return`Weekdays at ${b}${u}`;if(a==="0,6"||a==="6,0")return`Weekends at ${b}${u}`;const v=tl(a);if(v)return`${v.map($=>h[$%7]??String($)).join(", ")} at ${b}${u}`}return`${e}${t?` (${t})`:""}`}function tl(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 tb(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 nl(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 r=i.split(",").map(a=>a.trim()).filter(Boolean).map(a=>a.toLowerCase()==="admins"?"All admins":a);s.push(r.join(", "))}return n&&n!=="last"&&s.push(`via ${n}`),s.join(" ")||null}let ye=null;function nb(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 ib(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 sb(e){return e.split(",").map(n=>n.trim()).filter(Boolean).map(n=>n.toLowerCase()==="admins"?"All admins":n).join(", ")}function ob(e){return e||"Default"}const rb=d`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,ab=d`<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>`,lb=d`<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>`,or=d`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,cb=d`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,Vu=d`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`,ub=d`<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 il(e){const t=e.detailJobId?e.jobs.find(i=>i.id===e.detailJobId)??null:null,n=e.newEventModalOpen||!!e.editJobId;return d`
2804
2801
  ${db(e)}
2805
- ${n?hb(e):k}
2806
- ${t?mb(t,e):k}
2807
- `}function ub(e){const t=e.status,n=(t==null?void 0:t.enabled)??!1,i=(t==null?void 0:t.jobs)??0,s=t==null?void 0:t.nextWakeAtMs;return d`
2802
+ ${pb(e)}
2803
+ ${n?fb(e):k}
2804
+ ${t?yb(t,e):k}
2805
+ `}function db(e){const t=e.status,n=(t==null?void 0:t.enabled)??!1,i=(t==null?void 0:t.jobs)??0,s=t==null?void 0:t.nextWakeAtMs;return d`
2808
2806
  <div class="event-status-bar">
2809
2807
  <div class="event-status-bar__info">
2810
2808
  <span class="statusDot ${n?"ok":""}"></span>
@@ -2813,7 +2811,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2813
2811
  <span>${i} event${i!==1?"s":""}</span>
2814
2812
  ${s?d`
2815
2813
  <span class="event-status-bar__sep">\u00b7</span>
2816
- <span>Next: ${Ni(s)}</span>
2814
+ <span>Next: ${Oi(s)}</span>
2817
2815
  `:k}
2818
2816
  <button
2819
2817
  class="btn btn--sm"
@@ -2826,14 +2824,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2826
2824
  ${e.error?d`<span class="muted">${e.error}</span>`:k}
2827
2825
  </div>
2828
2826
  <button class="btn primary btn--sm" @click=${e.onNewEventModalOpen}>
2829
- ${Hu} New Event
2827
+ ${Vu} New Event
2830
2828
  </button>
2831
2829
  </div>
2832
- `}function db(e){return e.jobs.length===0?d`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:d`
2830
+ `}function pb(e){return e.jobs.length===0?d`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:d`
2833
2831
  <div class="event-grid">
2834
- ${e.jobs.map(t=>pb(t,e))}
2832
+ ${e.jobs.map(t=>hb(t,e))}
2835
2833
  </div>
2836
- `}function pb(e,t){return d`
2834
+ `}function hb(e,t){return d`
2837
2835
  <div
2838
2836
  class="event-card ${e.enabled?"":"disabled"}"
2839
2837
  @click=${()=>t.onDetailOpen(e)}
@@ -2844,12 +2842,12 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2844
2842
  ${e.enabled?"On":"Off"}
2845
2843
  </span>
2846
2844
  </div>
2847
- <div class="event-card__schedule">${qu(e)}</div>
2848
- ${e.agentId?d`<div class="event-card__agent">${sb(e.agentId)}</div>`:k}
2849
- ${tl(e)?d`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${tl(e)}</div>`:k}
2845
+ <div class="event-card__schedule">${ju(e)}</div>
2846
+ ${e.agentId?d`<div class="event-card__agent">${ob(e.agentId)}</div>`:k}
2847
+ ${nl(e)?d`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${nl(e)}</div>`:k}
2850
2848
  <div class="event-card__footer">
2851
2849
  <div class="event-card__status">
2852
- <span class="muted" style="font-size: 11px;">${zu(e)}</span>
2850
+ <span class="muted" style="font-size: 11px;">${Hu(e)}</span>
2853
2851
  </div>
2854
2852
  <div class="event-card__actions" @click=${n=>n.stopPropagation()}>
2855
2853
  <button
@@ -2858,7 +2856,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2858
2856
  ?disabled=${t.busy}
2859
2857
  @click=${()=>t.onToggle(e,!e.enabled)}
2860
2858
  >
2861
- ${e.enabled?rb:ob}
2859
+ ${e.enabled?ab:rb}
2862
2860
  </button>
2863
2861
  <button
2864
2862
  class="btn-icon"
@@ -2866,7 +2864,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2866
2864
  ?disabled=${t.busy}
2867
2865
  @click=${()=>t.onRun(e)}
2868
2866
  >
2869
- ${lb}
2867
+ ${cb}
2870
2868
  </button>
2871
2869
  ${t.pendingDeleteId===e.id?d`<button
2872
2870
  class="btn danger btn--sm"
@@ -2877,17 +2875,17 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2877
2875
  title="Delete"
2878
2876
  ?disabled=${t.busy}
2879
2877
  @click=${()=>{t.onArmDelete(e.id),ye&&clearTimeout(ye),ye=setTimeout(()=>{t.onArmDelete(""),ye=null},3e3)}}
2880
- >${ab}</button>`}
2878
+ >${lb}</button>`}
2881
2879
  </div>
2882
2880
  </div>
2883
2881
  </div>
2884
- `}function hb(e){const t=!!e.editJobId,n=tb(e),i=()=>{e.onNewEventModalClose()};return d`
2882
+ `}function fb(e){const t=!!e.editJobId,n=nb(e),i=()=>{e.onNewEventModalClose()};return d`
2885
2883
  <div class="event-modal-overlay" @click=${i}>
2886
2884
  <div class="event-modal" @click=${s=>s.stopPropagation()}>
2887
2885
  <div class="event-modal__header">
2888
2886
  <div class="event-modal__title">${t?"Edit Event":"New Event"}</div>
2889
2887
  <button class="event-modal__close" @click=${i}>
2890
- ${sr}
2888
+ ${or}
2891
2889
  </button>
2892
2890
  </div>
2893
2891
 
@@ -2939,7 +2937,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2939
2937
  </label>
2940
2938
  </div>
2941
2939
 
2942
- ${gb(e)}
2940
+ ${mb(e)}
2943
2941
 
2944
2942
  <div class="form-grid" style="margin-top: 12px;">
2945
2943
  <label class="field">
@@ -3001,7 +2999,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3001
2999
  @change=${s=>e.onFormChange({channel:s.target.value})}
3002
3000
  >
3003
3001
  ${n.map(s=>d`<option value=${s}>
3004
- ${nb(e,s)}
3002
+ ${ib(e,s)}
3005
3003
  </option>`)}
3006
3004
  </select>
3007
3005
  </label>
@@ -3014,7 +3012,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3014
3012
  />
3015
3013
  </label>
3016
3014
  </div>
3017
- ${fb(e)}
3015
+ ${gb(e)}
3018
3016
  <div class="form-grid" style="margin-top: 12px;">
3019
3017
  <label class="field">
3020
3018
  <span>Timeout (seconds)</span>
@@ -3045,7 +3043,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3045
3043
  </div>
3046
3044
  </div>
3047
3045
  </div>
3048
- `}function fb(e){const t=e.form.recipients;return d`
3046
+ `}function gb(e){const t=e.form.recipients;return d`
3049
3047
  <div style="margin-top: 8px;">
3050
3048
  <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
3051
3049
  <span style="font-size: 13px; color: var(--muted);">Recipients</span>
@@ -3053,7 +3051,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3053
3051
  class="btn btn--sm"
3054
3052
  @click=${()=>{e.onFormChange({recipients:[...t,""]})}}
3055
3053
  >
3056
- ${Hu} Add
3054
+ ${Vu} Add
3057
3055
  </button>
3058
3056
  </div>
3059
3057
  ${t.length===0&&!e.form.toAdmins?d`<div class="muted" style="font-size: 12px; padding: 4px 0;">No recipients. Add a phone number or enable "All admins".</div>`:k}
@@ -3070,12 +3068,12 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3070
3068
  title="Remove"
3071
3069
  @click=${()=>{const s=t.filter((o,r)=>r!==i);e.onFormChange({recipients:s})}}
3072
3070
  >
3073
- ${sr}
3071
+ ${or}
3074
3072
  </button>
3075
3073
  </div>
3076
3074
  `)}
3077
3075
  </div>
3078
- `}function gb(e){const t=e.form;return t.scheduleKind==="at"?d`
3076
+ `}function mb(e){const t=e.form;return t.scheduleKind==="at"?d`
3079
3077
  <label class="field" style="margin-top: 12px;">
3080
3078
  <span>Run at</span>
3081
3079
  <input
@@ -3124,13 +3122,13 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3124
3122
  />
3125
3123
  </label>
3126
3124
  </div>
3127
- `}function mb(e,t){var n;return d`
3125
+ `}function yb(e,t){var n;return d`
3128
3126
  <div class="event-modal-overlay" @click=${t.onDetailClose}>
3129
3127
  <div class="event-modal" @click=${i=>i.stopPropagation()}>
3130
3128
  <div class="event-modal__header">
3131
3129
  <div class="event-modal__title">${e.name||"Untitled Event"}</div>
3132
3130
  <button class="event-modal__close" @click=${t.onDetailClose}>
3133
- ${sr}
3131
+ ${or}
3134
3132
  </button>
3135
3133
  </div>
3136
3134
 
@@ -3142,7 +3140,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3142
3140
  ?disabled=${t.busy}
3143
3141
  @click=${()=>t.onEdit(e)}
3144
3142
  >
3145
- ${cb} Edit
3143
+ ${ub} Edit
3146
3144
  </button>
3147
3145
  <button
3148
3146
  class="btn"
@@ -3178,7 +3176,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3178
3176
  </div>
3179
3177
  <div class="event-detail-row">
3180
3178
  <span class="event-detail-label">Schedule</span>
3181
- <span class="event-detail-value">${qu(e)}</span>
3179
+ <span class="event-detail-value">${ju(e)}</span>
3182
3180
  </div>
3183
3181
  ${e.agentId?d`
3184
3182
  <div class="event-detail-row">
@@ -3200,12 +3198,12 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3200
3198
  </div>
3201
3199
  <div class="event-detail-row" style="flex-direction: column; align-items: stretch; gap: 4px;">
3202
3200
  <span class="event-detail-label">Action</span>
3203
- <span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${eb(e,!1)}</span>
3201
+ <span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${tb(e,!1)}</span>
3204
3202
  </div>
3205
3203
  ${e.payload.kind==="agentTurn"&&e.payload.to?d`
3206
3204
  <div class="event-detail-row">
3207
3205
  <span class="event-detail-label">Send to</span>
3208
- <span class="event-detail-value mono">${ib(e.payload.to)}</span>
3206
+ <span class="event-detail-value mono">${sb(e.payload.to)}</span>
3209
3207
  </div>
3210
3208
  `:k}
3211
3209
  ${e.payload.kind==="agentTurn"&&(e.payload.channel??e.payload.provider)?d`
@@ -3225,12 +3223,12 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3225
3223
  <div class="event-detail-section">
3226
3224
  <div class="event-detail-row">
3227
3225
  <span class="event-detail-label">Last run</span>
3228
- <span class="event-detail-value">${zu(e)}</span>
3226
+ <span class="event-detail-value">${Hu(e)}</span>
3229
3227
  </div>
3230
3228
  ${(n=e.state)!=null&&n.nextRunAtMs?d`
3231
3229
  <div class="event-detail-row">
3232
3230
  <span class="event-detail-label">Next run</span>
3233
- <span class="event-detail-value">${Jv(e.state.nextRunAtMs)}</span>
3231
+ <span class="event-detail-value">${Zv(e.state.nextRunAtMs)}</span>
3234
3232
  </div>
3235
3233
  `:k}
3236
3234
  </div>
@@ -3241,21 +3239,21 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3241
3239
  </div>
3242
3240
  ${t.runs.length===0?d`<div class="muted" style="font-size: 13px;">No runs recorded yet.</div>`:d`
3243
3241
  <div class="list">
3244
- ${[...t.runs].sort((i,s)=>s.ts-i.ts).map(i=>vb(i))}
3242
+ ${[...t.runs].sort((i,s)=>s.ts-i.ts).map(i=>bb(i))}
3245
3243
  </div>
3246
3244
  `}
3247
3245
  </div>
3248
3246
 
3249
3247
  </div>
3250
3248
  </div>
3251
- `}function yb(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"?"chip chip-warn":"chip"}function vb(e){return d`
3249
+ `}function vb(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"?"chip chip-warn":"chip"}function bb(e){return d`
3252
3250
  <div class="list-item" style="grid-template-columns: 1fr; gap: 6px;">
3253
3251
  <div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
3254
- <span class=${yb(e.status)} style="font-size: 11px; padding: 2px 8px;">
3252
+ <span class=${vb(e.status)} style="font-size: 11px; padding: 2px 8px;">
3255
3253
  ${e.status}
3256
3254
  </span>
3257
- <span class="muted" style="font-size: 12px;">${Ni(e.ts)}</span>
3258
- <span class="muted" style="font-size: 12px;">${Il(e.durationMs)}</span>
3255
+ <span class="muted" style="font-size: 12px;">${Oi(e.ts)}</span>
3256
+ <span class="muted" style="font-size: 12px;">${Rl(e.durationMs)}</span>
3259
3257
  </div>
3260
3258
  ${e.summary?d`<div class="muted" style="font-size: 12px;">${e.summary}</div>`:k}
3261
3259
  ${e.error?d`
@@ -3265,7 +3263,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3265
3263
  </details>
3266
3264
  `:k}
3267
3265
  </div>
3268
- `}function bb(e){var s;const t=((s=e.report)==null?void 0:s.skills)??[],n=e.filter.trim().toLowerCase(),i=n?t.filter(o=>[o.name,o.description,o.preloaded?"preloaded":"user"].join(" ").toLowerCase().includes(n)):t;return d`
3266
+ `}function wb(e){var s;const t=((s=e.report)==null?void 0:s.skills)??[],n=e.filter.trim().toLowerCase(),i=n?t.filter(o=>[o.name,o.description,o.preloaded?"preloaded":"user"].join(" ").toLowerCase().includes(n)):t;return d`
3269
3267
  <section class="card">
3270
3268
  <div class="row" style="justify-content: space-between;">
3271
3269
  <div>
@@ -3296,20 +3294,20 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3296
3294
 
3297
3295
  ${i.length===0?d`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:d`
3298
3296
  <div class="list" style="margin-top: 16px;">
3299
- ${i.map(o=>wb(o,e))}
3297
+ ${i.map(o=>kb(o,e))}
3300
3298
  </div>
3301
3299
  `}
3302
3300
  </section>
3303
3301
 
3304
- ${e.detail?kb(e):k}
3305
- ${e.addModal?Sb(e):k}
3306
- `}function wb(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,r=[...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}`)],a=[];return e.disabled&&a.push("disabled"),e.blockedByAllowlist&&a.push("blocked by allowlist"),d`
3302
+ ${e.detail?Sb(e):k}
3303
+ ${e.addModal?$b(e):k}
3304
+ `}function kb(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,r=[...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}`)],a=[];return e.disabled&&a.push("disabled"),e.blockedByAllowlist&&a.push("blocked by allowlist"),d`
3307
3305
  <div class="list-item" style="cursor: pointer;" @click=${()=>t.onViewDetail(e.name)}>
3308
3306
  <div class="list-main">
3309
3307
  <div class="list-title">
3310
3308
  ${e.emoji?`${e.emoji} `:""}${e.name}
3311
3309
  </div>
3312
- <div class="list-sub">${ap(e.description,140)}</div>
3310
+ <div class="list-sub">${cp(e.description,140)}</div>
3313
3311
  <div class="chip-row" style="margin-top: 6px;">
3314
3312
  <span class="chip ${e.preloaded?"chip-ok":""}">
3315
3313
  ${e.preloaded?"Preloaded":"User"}
@@ -3384,7 +3382,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3384
3382
  `:k}
3385
3383
  </div>
3386
3384
  </div>
3387
- `}function kb(e){var r;const t=e.detail,n=["SKILL.md",...t.references.map(a=>a.name)],i=e.detailTab||"SKILL.md",s=i==="SKILL.md"?t.content:((r=t.references.find(a=>a.name===i))==null?void 0:r.content)??"";return d`
3385
+ `}function Sb(e){var r;const t=e.detail,n=["SKILL.md",...t.references.map(a=>a.name)],i=e.detailTab||"SKILL.md",s=i==="SKILL.md"?t.content:((r=t.references.find(a=>a.name===i))==null?void 0:r.content)??"";return d`
3388
3386
  <div class="event-modal-overlay" @click=${a=>{a.target.classList.contains("event-modal-overlay")&&e.onDetailClose()}}>
3389
3387
  <div class="event-modal" style="width: min(720px, 100%);" @click=${a=>a.stopPropagation()}>
3390
3388
  <div class="event-modal__header">
@@ -3407,7 +3405,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3407
3405
  <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>
3408
3406
  </div>
3409
3407
  </div>
3410
- `}function Sb(e){const t=e.drafts.length>0,n=e.busyKey==="__add__";return d`
3408
+ `}function $b(e){const t=e.drafts.length>0,n=e.busyKey==="__add__";return d`
3411
3409
  <div class="event-modal-overlay" @click=${s=>{s.target.classList.contains("event-modal-overlay")&&e.onAddClose()}}>
3412
3410
  <div class="event-modal" style="width: min(520px, 100%);" @click=${s=>s.stopPropagation()}>
3413
3411
  <div class="event-modal__header">
@@ -3456,17 +3454,17 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3456
3454
  `}
3457
3455
  </div>
3458
3456
  </div>
3459
- `}const $b=["user","assistant","tool_call","tool_result","thinking","error"],il={user:"User",assistant:"Assistant",tool:"Tool",tool_call:"Call",tool_result:"Result",thinking:"Thinking",error:"Error",system:"System"};function ju(e){return e==="tool"?"tool_call":e}function Ab(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 xb(e){return e.split(":").slice(2).join(":")||e}function Eb(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName,e.toolCallId].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Cb(e,t){return`${e.sessionId}:${e.timestamp}:${t}`}const sl=300;function Tb(e,t){const n=ju(e);return t[n]??!0}function _b(e){const t=e.filterText.trim().toLowerCase(),n=e.entries.filter(i=>!Tb(i.type,e.typeFilters)||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:Eb(i,t));return d`
3457
+ `}const Ab=["user","assistant","tool_call","tool_result","thinking","error"],sl={user:"User",assistant:"Assistant",tool:"Tool",tool_call:"Call",tool_result:"Result",thinking:"Thinking",error:"Error",system:"System"};function Gu(e){return e==="tool"?"tool_call":e}function xb(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 Eb(e){return e.split(":").slice(2).join(":")||e}function Cb(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName,e.toolCallId].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Tb(e,t){return`${e.sessionId}:${e.timestamp}:${t}`}const ol=300;function _b(e,t){const n=Gu(e);return t[n]??!0}function Mb(e){const t=e.filterText.trim().toLowerCase(),n=e.entries.filter(i=>!_b(i.type,e.typeFilters)||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:Cb(i,t));return d`
3460
3458
  <div>
3461
3459
  <div class="chip-row" style="margin-top: 10px;">
3462
- ${$b.map(i=>d`
3460
+ ${Ab.map(i=>d`
3463
3461
  <label class="chip session-log-chip ${i}">
3464
3462
  <input
3465
3463
  type="checkbox"
3466
3464
  .checked=${e.typeFilters[i]}
3467
3465
  @change=${s=>e.onTypeToggle(i,s.target.checked)}
3468
3466
  />
3469
- <span>${il[i]}</span>
3467
+ <span>${sl[i]}</span>
3470
3468
  </label>
3471
3469
  `)}
3472
3470
  ${e.agents.map(i=>d`
@@ -3492,13 +3490,13 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3492
3490
  ${e.error?d`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:k}
3493
3491
 
3494
3492
  <div class="log-stream" style="margin-top: 10px;" @scroll=${e.onScroll}>
3495
- ${n.length===0?d`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map((i,s)=>{const o=ju(i.type),r=Cb(i,s),a=e.expandedIds.has(r),u=i.content.length>sl,c=a||!u?i.content:i.content.slice(0,sl)+"…";return d`
3493
+ ${n.length===0?d`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map((i,s)=>{const o=Gu(i.type),r=Tb(i,s),a=e.expandedIds.has(r),u=i.content.length>ol,c=a||!u?i.content:i.content.slice(0,ol)+"…";return d`
3496
3494
  <div class="log-row session-entry ${o}">
3497
3495
  <div class="log-row-header">
3498
- <span class="log-time mono">${Ab(i.timestamp)}</span>
3499
- <span class="session-log-type ${o}">${il[o]}</span>
3496
+ <span class="log-time mono">${xb(i.timestamp)}</span>
3497
+ <span class="session-log-type ${o}">${sl[o]}</span>
3500
3498
  <span class="log-subsystem mono">${i.agentId}</span>
3501
- <span class="session-label mono">${xb(i.sessionKey)}</span>
3499
+ <span class="session-label mono">${Eb(i.sessionKey)}</span>
3502
3500
  ${i.toolName?d`<span class="session-tool mono">${i.toolName}</span>`:k}
3503
3501
  ${i.toolCallId?d`<span class="session-call-id mono">${i.toolCallId.slice(0,12)}</span>`:k}
3504
3502
  ${i.model?d`<span class="session-model mono">${i.model}</span>`:k}
@@ -3512,7 +3510,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3512
3510
  `})}
3513
3511
  </div>
3514
3512
  </div>
3515
- `}const co=["trace","debug","info","warn","error","fatal"];function Mb(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function Vu(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Pb(e){const t=e.logsSubTab==="session";return d`
3513
+ `}const uo=["trace","debug","info","warn","error","fatal"];function Pb(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function Qu(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Lb(e){const t=e.logsSubTab==="session";return d`
3516
3514
  <section class="card">
3517
3515
  <div class="logs-toolbar">
3518
3516
  <div class="sp-tabs" style="margin: 0;">
@@ -3561,7 +3559,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3561
3559
  <button
3562
3560
  class="btn btn-sm"
3563
3561
  ?disabled=${e.entries.length===0}
3564
- @click=${()=>{const n=e.filterText.trim().toLowerCase(),i=co.some(r=>!e.levelFilters[r]),s=e.entries.filter(r=>r.level&&!e.levelFilters[r.level]?!1:Vu(r,n)),o=n||i?"filtered":"visible";e.onExport(s.map(r=>r.raw),o)}}
3562
+ @click=${()=>{const n=e.filterText.trim().toLowerCase(),i=uo.some(r=>!e.levelFilters[r]),s=e.entries.filter(r=>r.level&&!e.levelFilters[r.level]?!1:Qu(r,n)),o=n||i?"filtered":"visible";e.onExport(s.map(r=>r.raw),o)}}
3565
3563
  >
3566
3564
  Export
3567
3565
  </button>
@@ -3569,11 +3567,11 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3569
3567
  </div>
3570
3568
  </div>
3571
3569
 
3572
- ${t?_b(e.sessionLogsProps):Lb(e)}
3570
+ ${t?Mb(e.sessionLogsProps):Ib(e)}
3573
3571
  </section>
3574
- `}function Lb(e){const t=e.filterText.trim().toLowerCase();co.some(i=>!e.levelFilters[i]);const n=e.entries.filter(i=>i.level&&!e.levelFilters[i.level]?!1:Vu(i,t));return d`
3572
+ `}function Ib(e){const t=e.filterText.trim().toLowerCase();uo.some(i=>!e.levelFilters[i]);const n=e.entries.filter(i=>i.level&&!e.levelFilters[i.level]?!1:Qu(i,t));return d`
3575
3573
  <div class="chip-row" style="margin-top: 10px; align-items: center;">
3576
- ${co.map(i=>d`
3574
+ ${uo.map(i=>d`
3577
3575
  <label class="chip log-chip ${i}">
3578
3576
  <input
3579
3577
  type="checkbox"
@@ -3603,7 +3601,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3603
3601
  ${n.length===0?d`<div class="muted" style="padding: 12px;">No log entries.</div>`:[...n].reverse().map(i=>d`
3604
3602
  <div class="log-row">
3605
3603
  <div class="log-row-header">
3606
- <span class="log-time mono">${Mb(i.time)}</span>
3604
+ <span class="log-time mono">${Pb(i.time)}</span>
3607
3605
  <span class="log-level ${i.level??""}">${i.level??""}</span>
3608
3606
  <span class="log-subsystem mono">${i.subsystem??""}</span>
3609
3607
  </div>
@@ -3611,12 +3609,12 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3611
3609
  </div>
3612
3610
  `)}
3613
3611
  </div>
3614
- `}const Ib=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function Rb(e){switch(e.activeTab){case"cron":return nl(e.cronProps);case"skills":return bb(e.skillsProps);case"logs":return Pb(e.logsProps);default:return nl(e.cronProps)}}function Db(e){return e.connected?d`
3612
+ `}const Rb=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function Db(e){switch(e.activeTab){case"cron":return il(e.cronProps);case"skills":return wb(e.skillsProps);case"logs":return Lb(e.logsProps);default:return il(e.cronProps)}}function Bb(e){return e.connected?d`
3615
3613
  <div class="setup-container">
3616
- ${xt("Advanced",e.wsProps)}
3614
+ ${Et("Advanced",e.wsProps)}
3617
3615
  <div class="setup-card sp-card-advanced" style="text-align: left;">
3618
3616
  <div class="sp-tabs">
3619
- ${Ib.map(t=>d`
3617
+ ${Rb.map(t=>d`
3620
3618
  <button
3621
3619
  class="sp-tab ${e.activeTab===t.id?"active":""}"
3622
3620
  @click=${()=>e.onTabChange(t.id)}
@@ -3625,7 +3623,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3625
3623
  </button>
3626
3624
  `)}
3627
3625
  </div>
3628
- ${Rb(e)}
3626
+ ${Db(e)}
3629
3627
  </div>
3630
3628
  </div>
3631
3629
  `:d`
@@ -3635,7 +3633,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3635
3633
  <p>Connecting to gateway...</p>
3636
3634
  </div>
3637
3635
  </div>
3638
- `}function ol(e){if(!e.show)return k;const t=He(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const r=b=>{var v;o=b.target.value;const h=(v=b.target.closest(".login-card"))==null?void 0:v.querySelector(".login-change-pin");h&&(h.style.display=o==="__master__"?"":"none")},a=b=>h=>{const v=h.target;v.value=v.value.replace(/\D/g,"").slice(0,6),b(v.value)},u=b=>{const h=b.currentTarget,v=h.closest(".login-pin-wrapper"),S=v==null?void 0:v.querySelector("input");if(!S)return;const $=S.type==="text";S.type=$?"password":"text",h.classList.toggle("active",!$)},c=!n&&e.accounts.length>1?d`
3636
+ `}function rl(e){if(!e.show)return k;const t=He(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const r=b=>{var v;o=b.target.value;const h=(v=b.target.closest(".login-card"))==null?void 0:v.querySelector(".login-change-pin");h&&(h.style.display=o==="__master__"?"":"none")},a=b=>h=>{const v=h.target;v.value=v.value.replace(/\D/g,"").slice(0,6),b(v.value)},u=b=>{const h=b.currentTarget,v=h.closest(".login-pin-wrapper"),S=v==null?void 0:v.querySelector("input");if(!S)return;const $=S.type==="text";S.type=$?"password":"text",h.classList.toggle("active",!$)},c=!n&&e.accounts.length>1?d`
3639
3637
  <select
3640
3638
  class="login-account-select"
3641
3639
  @change=${r}
@@ -3789,7 +3787,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3789
3787
  </p>`:k}
3790
3788
  </div>
3791
3789
  </div>
3792
- `}function Bb(e){if(!e.connected)return d`
3790
+ `}function Nb(e){if(!e.connected)return d`
3793
3791
  <div class="setup-container">
3794
3792
  <div class="setup-card">
3795
3793
  <div class="setup-spinner"></div>
@@ -3802,17 +3800,17 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3802
3800
  <span class="public-chat-header__name">${n}</span>
3803
3801
  </div>
3804
3802
  <div class="chat-viewport">
3805
- ${Ku(t)}
3803
+ ${qu(t)}
3806
3804
  </div>
3807
3805
  </div>
3808
- `}async function Nb(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 Ln(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 Ob(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 r=o.hash;if(!r){e.workspacesError="Config hash missing; reload and retry.";return}const a={name:n,baseHash:r,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(a.workspaceDir=t.workspacePath.trim());const u=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await Ln(e),(s=t.onCreated)==null||s.call(t,u)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function Fb(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 Ln(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Ub(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 Ln(e)}catch(i){e.workspacesError=String(i)}}}const oi=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Ob,loadWorkspaces:Ln,removeWorkspace:Fb,renameWorkspace:Ub},Symbol.toStringTag,{value:"Module"})),Gu={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"},rl=Gu,uo={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Gu));new Set(Object.values(uo));function Wb(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 Kb=4008;class zb{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 p;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,r=!1,a=this.opts.token;if(s){o=await xh();const f=(p=Th({deviceId:o.deviceId,role:t}))==null?void 0:p.token;a=f??this.opts.token,r=!!(f&&this.opts.token)}const u=a||this.opts.password?{token:a,password:this.opts.password}:void 0;let c;if(s&&o){const f=Date.now(),b=this.connectNonce??void 0,h=Wb({deviceId:o.deviceId,clientId:this.opts.clientName??rl.CONTROL_UI,clientMode:this.opts.mode??uo.WEBCHAT,role:t,scopes:n,signedAtMs:f,token:a??null,nonce:b}),v=await Eh(o.privateKey,h);c={id:o.deviceId,publicKey:o.publicKey,signature:v,signedAt:f,nonce:b}}const l={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??rl.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??uo.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:c,caps:[],auth:u,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",l).then(f=>{var b,h,v;(b=f==null?void 0:f.auth)!=null&&b.deviceToken&&o&&_h({deviceId:o.deviceId,role:f.auth.role??t,token:f.auth.deviceToken,scopes:f.auth.scopes??[]}),this.backoffMs=800,(v=(h=this.opts).onHello)==null||v.call(h,f)}).catch(()=>{var f;r&&o&&Mh({deviceId:o.deviceId,role:t}),(f=this.ws)==null||f.close(Kb,"connect failed")})}handleMessage(t){var s,o,r,a,u,c;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const l=n;if(l.event==="connect.challenge"){const f=l.payload,b=f&&typeof f.nonce=="string"?f.nonce:null;b&&(this.connectNonce=b,this.sendConnect());return}const p=typeof l.seq=="number"?l.seq:null;p!==null&&(this.lastSeq!==null&&p>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:p})),this.lastSeq=p);try{(a=(r=this.opts).onEvent)==null||a.call(r,l)}catch(f){console.error("[gateway] event handler error:",f)}return}if(i.type==="res"){const l=n,p=this.pending.get(l.id);if(!p)return;if(this.pending.delete(l.id),l.ok)p.resolve(l.payload);else{const f=new Error(((u=l.error)==null?void 0:u.message)??"request failed");f.payload=l.payload,f.details=(c=l.error)==null?void 0:c.details,p.reject(f)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=Oi(),s={type:"req",id:i,method:t,params:n},o=new Promise((r,a)=>{this.pending.set(i,{resolve:u=>r(u),reject:a})});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 po(e){return typeof e=="object"&&e!==null}function qb(e){if(!po(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!po(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 Hb(e){if(!po(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 Qu(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function jb(e,t){const n=Qu(e).filter(i=>i.id!==t.id);return n.push(t),n}function al(e,t){return Qu(e).filter(n=>n.id!==t)}class Vb{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,r=this.deviceWidth/this.canvas.width,a=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*r),y:Math.round(n*o*a)}}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 Ds=null;function An(){return Ds||(Ds=new Vb),Ds}function or(e){return e instanceof Error?e.message:String(e)}async function Gb(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=or(t)}finally{e.browserLoading=!1}}async function Qb(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=or(t)}finally{e.browserLoading=!1}}}async function Bs(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 Ns(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 Yb(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=or(t)}}function Xb(e){e.browserInputMode=!e.browserInputMode}function Jb(e){e.browserFullscreen=!e.browserFullscreen,An().detach()}function Zb(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,An().updateFrame(t.data,t.metadata)}function ew(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function tw(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function ho(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=Ks(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function pi(e){return(await e.request("apikeys.list")).providers??[]}async function ll(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function nw(e,t){await e.request("apikeys.remove",{provider:t})}async function iw(e,t,n){await e.request("apikeys.disable",{provider:t,disabled:n})}const Li="taskmaster_update_pending";async function Yu(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 sw(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(Li,String(Date.now())),localStorage.removeItem(rr)}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")xn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw xn(),new Error(o.result.reason||"Update failed")}catch(o){xn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function ow(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const r=t.name,a=t.index,u=t.total;e.updateMessage=`Updating: ${r} (${a+1}/${u})`;const c=e.updateProgressSteps.find(l=>l.index===a);c?(c.status="running",c.name=r):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:u,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const r=t.name,a=t.index,u=t.total,c=t.ok,l=t.durationMs,p=e.updateProgressSteps.find(b=>b.index===a);p?(p.status=c?"done":"failed",p.durationMs=l):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:u,status:c?"done":"failed",durationMs:l}];const f=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${r} done (${a+1}/${u})`:`Update step failed: ${r}${f}`,(s=e.requestUpdate)==null||s.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const a=t.reason;e.updateMessage=a?`Update failed: ${a}`:"Update failed",e.updateRunning=!1,xn()}(o=e.requestUpdate)==null||o.call(e)}}async function rw(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=lw();xn();try{const r=await e.client.request("update.lastResult",{});if(!r.ok||!r.result)return;const a=5*6e4,u=Date.now()-r.result.ts<a;if(!t&&!u||cw(r.result.ts))return;e.updateLastResult=r.result;const c=(n=r.result.after)==null?void 0:n.version;if(r.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,r.result.status==="ok"){const l=(i=r.result.before)==null?void 0:i.version,p=c??r.result.currentVersion;e.updateMessage=l?`Updated: v${l} → v${p}`:`Updated to v${p}`}else{const l=r.result.reason??((s=r.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${l}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(o=e.requestUpdate)==null||o.call(e)}}const rr="taskmaster_update_dismissed";function aw(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(rr,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function lw(){try{const e=localStorage.getItem(Li);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(Li),!1):!0:!1}catch{return!1}}function xn(){try{localStorage.removeItem(Li)}catch{}}function cw(e){try{const t=localStorage.getItem(rr);return t?Number(t)>=e:!1}catch{return!1}}function Os(e,t){var a,u,c;const n=(e??"").trim(),i=(a=t.mainSessionKey)==null?void 0:a.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 uw(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=Os(e.sessionKey,t),i=Os(e.settings.sessionKey,t),s=Os(e.settings.lastActiveSessionKey,t),o=n||i||e.sessionKey,r={...e.settings,sessionKey:i||o,lastActiveSessionKey:s||o},a=r.sessionKey!==e.settings.sessionKey||r.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),a&&tt(e,r)}function Pe(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=!!e.publicChat,n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,i=t?"public-chat":n?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new zb({url:e.settings.gatewayUrl,token:t?void 0:e.settings.token.trim()?e.settings.token:void 0,password:t?void 0:e.password.trim()?e.password:void 0,clientName:i,mode:"webchat",role:t?"public":void 0,scopes:t?[]:void 0,onHello:o=>{var r;if(e.connected=!0,e.lastError=null,e.hello=o,t){cl(e,o),ho(e),(((r=e.publicChatConfig)==null?void 0:r.auth)??"anonymous")==="anonymous"&&yw(e);return}$i()&&(Uo(),e.uninstallDone=!1),cl(e,o),e.handleAccessCheck(),rw(e).then(()=>{Yu(e)}),ho(e),Nb(e),(e.chatPage||e.setup)&&hw(e),_o(e,{quiet:!0}),To(e,{quiet:!0}),Ln(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Be(e),e.setup&&(fw(e),gw(e),mw(e)),ki(e)},onClose:({code:o,reason:r})=>{e.connected=!1,o!==1012&&(e.lastError=`disconnected (${o}): ${r||"no reason"}`)},onEvent:o=>dw(e,o),onGap:({expected:o,received:r})=>{console.warn(`[gateway] event gap: expected seq ${o}, got ${r}`),ki(e)}}),e.client.start()}function dw(e,t){try{pw(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function pw(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;Pp(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&Nc(e,i.sessionKey);const s=Kl(e,i);if((s==="final"||s==="error"||s==="aborted")&&(wo(e),Sf(e)),s==="final"){const o=e,r=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,De);Re(o,{limit:r})}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.chatSuggestion=i.suggestions[0]);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"&&e.tab==="cron"&&Oo(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&To(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=qb(t.payload);if(i){e.execApprovalQueue=jb(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=al(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){Zb(e,t.payload);return}if(t.event==="browser.handoff"){ew(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){tw(e);return}if(t.event==="exec.approval.resolved"){const i=Hb(t.payload);i&&(e.execApprovalQueue=al(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){ow(e,t.payload);return}}function cl(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&&uw(e,n.sessionDefaults)}async function hw(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 fw(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await pi(e.client)}catch{}}async function gw(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status")}catch{}}async function mw(e){if(!(!e.client||!e.connected))try{e.wifiStatus=await e.client.request("wifi.status")}catch{}}const ul="taskmaster_public_id";function Xu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${ul}=`));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=`${ul}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function yw(e){var n,i;if(!e.client||!e.connected)return;const t=Xu((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const s=(i=e.publicChatConfig)==null?void 0:i.accountId,o=await e.client.request("public.session",{cookieId:t,accountId:s});o!=null&&o.sessionKey&&(e.publicChatSessionKey=o.sessionKey,e.sessionKey=o.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready",Re(e))}catch(s){console.error("[public-chat] failed to resolve anonymous session:",s),e.lastError="Failed to start chat session"}}let xe=!1,he=null,Ht="",Ii="";function Ju(e){return e.replace(/[\s\-()]/g,"")}function Zu(){xe=!1,he=null,Ht="",Ii=""}async function vw(e){if(!e.client||!e.connected)return;const t=Xu(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){he=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function dl(e){if(!e.client||xe)return;const t=Ju(Ht);if(!t){he="Please enter your phone number",e.requestUpdate();return}xe=!0,he=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:Ii.trim()||void 0,accountId:e.accountId});n!=null&&n.ok?e.onAuthStepChange("otp"):he=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){he=n instanceof Error?n.message:"Failed to send verification code"}finally{xe=!1,e.requestUpdate()}}async function pl(e,t){if(!(!e.client||xe)){if(!t.trim()){he="Please enter the verification code",e.requestUpdate();return}xe=!0,he=null,e.requestUpdate();try{const n=await e.client.request("public.otp.verify",{phone:Ju(Ht),code:t.trim(),accountId:e.accountId});n!=null&&n.ok&&n.sessionKey?(Zu(),e.onAuthenticated(n.sessionKey)):he=(n==null?void 0:n.error)??"Invalid verification code"}catch(n){he=n instanceof Error?n.message:"Verification failed"}finally{xe=!1,e.requestUpdate()}}}function Fs(e){return k}function hl(e){return d`
3806
+ `}async function Ob(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 Ln(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 Fb(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 r=o.hash;if(!r){e.workspacesError="Config hash missing; reload and retry.";return}const a={name:n,baseHash:r,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(a.workspaceDir=t.workspacePath.trim());const u=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await Ln(e),(s=t.onCreated)==null||s.call(t,u)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function Ub(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 Ln(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Wb(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 Ln(e)}catch(i){e.workspacesError=String(i)}}}const oi=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Fb,loadWorkspaces:Ln,removeWorkspace:Ub,renameWorkspace:Wb},Symbol.toStringTag,{value:"Module"})),Yu={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=Yu,po={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Yu));new Set(Object.values(po));function Kb(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 zb=4008;class qb{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 p;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,r=!1,a=this.opts.token;if(s){o=await Ch();const f=(p=Mh({deviceId:o.deviceId,role:t}))==null?void 0:p.token;a=f??this.opts.token,r=!!(f&&this.opts.token)}const u=a||this.opts.password?{token:a,password:this.opts.password}:void 0;let c;if(s&&o){const f=Date.now(),b=this.connectNonce??void 0,h=Kb({deviceId:o.deviceId,clientId:this.opts.clientName??al.CONTROL_UI,clientMode:this.opts.mode??po.WEBCHAT,role:t,scopes:n,signedAtMs:f,token:a??null,nonce:b}),v=await Th(o.privateKey,h);c={id:o.deviceId,publicKey:o.publicKey,signature:v,signedAt:f,nonce:b}}const l={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??po.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:c,caps:[],auth:u,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",l).then(f=>{var b,h,v;(b=f==null?void 0:f.auth)!=null&&b.deviceToken&&o&&Ph({deviceId:o.deviceId,role:f.auth.role??t,token:f.auth.deviceToken,scopes:f.auth.scopes??[]}),this.backoffMs=800,(v=(h=this.opts).onHello)==null||v.call(h,f)}).catch(()=>{var f;r&&o&&Lh({deviceId:o.deviceId,role:t}),(f=this.ws)==null||f.close(zb,"connect failed")})}handleMessage(t){var s,o,r,a,u,c;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const l=n;if(l.event==="connect.challenge"){const f=l.payload,b=f&&typeof f.nonce=="string"?f.nonce:null;b&&(this.connectNonce=b,this.sendConnect());return}const p=typeof l.seq=="number"?l.seq:null;p!==null&&(this.lastSeq!==null&&p>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:p})),this.lastSeq=p);try{(a=(r=this.opts).onEvent)==null||a.call(r,l)}catch(f){console.error("[gateway] event handler error:",f)}return}if(i.type==="res"){const l=n,p=this.pending.get(l.id);if(!p)return;if(this.pending.delete(l.id),l.ok)p.resolve(l.payload);else{const f=new Error(((u=l.error)==null?void 0:u.message)??"request failed");f.payload=l.payload,f.details=(c=l.error)==null?void 0:c.details,p.reject(f)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=Fi(),s={type:"req",id:i,method:t,params:n},o=new Promise((r,a)=>{this.pending.set(i,{resolve:u=>r(u),reject:a})});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 Hb(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 jb(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 Xu(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Vb(e,t){const n=Xu(e).filter(i=>i.id!==t.id);return n.push(t),n}function ll(e,t){return Xu(e).filter(n=>n.id!==t)}class Gb{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,r=this.deviceWidth/this.canvas.width,a=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*r),y:Math.round(n*o*a)}}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 Bs=null;function An(){return Bs||(Bs=new Gb),Bs}function rr(e){return e instanceof Error?e.message:String(e)}async function Qb(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=rr(t)}finally{e.browserLoading=!1}}async function Yb(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=rr(t)}finally{e.browserLoading=!1}}}async function Ns(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 Os(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 Xb(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=rr(t)}}function Jb(e){e.browserInputMode=!e.browserInputMode}function Zb(e){e.browserFullscreen=!e.browserFullscreen,An().detach()}function ew(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,An().updateFrame(t.data,t.metadata)}function tw(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function nw(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function fo(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=zs(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function pi(e){return(await e.request("apikeys.list")).providers??[]}async function cl(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function iw(e,t){await e.request("apikeys.remove",{provider:t})}async function sw(e,t,n){await e.request("apikeys.disable",{provider:t,disabled:n})}const Ii="taskmaster_update_pending";async function Ju(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 ow(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(Ii,String(Date.now())),localStorage.removeItem(ar)}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")xn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw xn(),new Error(o.result.reason||"Update failed")}catch(o){xn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function rw(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const r=t.name,a=t.index,u=t.total;e.updateMessage=`Updating: ${r} (${a+1}/${u})`;const c=e.updateProgressSteps.find(l=>l.index===a);c?(c.status="running",c.name=r):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:u,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const r=t.name,a=t.index,u=t.total,c=t.ok,l=t.durationMs,p=e.updateProgressSteps.find(b=>b.index===a);p?(p.status=c?"done":"failed",p.durationMs=l):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:u,status:c?"done":"failed",durationMs:l}];const f=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${r} done (${a+1}/${u})`:`Update step failed: ${r}${f}`,(s=e.requestUpdate)==null||s.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const a=t.reason;e.updateMessage=a?`Update failed: ${a}`:"Update failed",e.updateRunning=!1,xn()}(o=e.requestUpdate)==null||o.call(e)}}async function aw(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=cw();xn();try{const r=await e.client.request("update.lastResult",{});if(!r.ok||!r.result)return;const a=5*6e4,u=Date.now()-r.result.ts<a;if(!t&&!u||uw(r.result.ts))return;e.updateLastResult=r.result;const c=(n=r.result.after)==null?void 0:n.version;if(r.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,r.result.status==="ok"){const l=(i=r.result.before)==null?void 0:i.version,p=c??r.result.currentVersion;e.updateMessage=l?`Updated: v${l} → v${p}`:`Updated to v${p}`}else{const l=r.result.reason??((s=r.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${l}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(o=e.requestUpdate)==null||o.call(e)}}const ar="taskmaster_update_dismissed";function lw(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(ar,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function cw(){try{const e=localStorage.getItem(Ii);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(Ii),!1):!0:!1}catch{return!1}}function xn(){try{localStorage.removeItem(Ii)}catch{}}function uw(e){try{const t=localStorage.getItem(ar);return t?Number(t)>=e:!1}catch{return!1}}function Fs(e,t){var a,u,c;const n=(e??"").trim(),i=(a=t.mainSessionKey)==null?void 0:a.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 dw(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=Fs(e.sessionKey,t),i=Fs(e.settings.sessionKey,t),s=Fs(e.settings.lastActiveSessionKey,t),o=n||i||e.sessionKey,r={...e.settings,sessionKey:i||o,lastActiveSessionKey:s||o},a=r.sessionKey!==e.settings.sessionKey||r.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),a&&tt(e,r)}function Pe(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=!!e.publicChat,n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,i=t?"public-chat":n?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new qb({url:e.settings.gatewayUrl,token:t?void 0:e.settings.token.trim()?e.settings.token:void 0,password:t?void 0:e.password.trim()?e.password:void 0,clientName:i,mode:"webchat",role:t?"public":void 0,scopes:t?[]:void 0,onHello:o=>{var r;if(e.connected=!0,e.lastError=null,e.hello=o,t){ul(e,o),fo(e),(((r=e.publicChatConfig)==null?void 0:r.auth)??"anonymous")==="anonymous"&&vw(e);return}$i()&&(Wo(),e.uninstallDone=!1),ul(e,o),e.handleAccessCheck(),aw(e).then(()=>{Ju(e)}),fo(e),Ob(e),(e.chatPage||e.setup)&&fw(e),Mo(e,{quiet:!0}),_o(e,{quiet:!0}),Ln(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Be(e),e.setup&&(gw(e),mw(e),yw(e)),ki(e)},onClose:({code:o,reason:r})=>{e.connected=!1,o!==1012&&(e.lastError=`disconnected (${o}): ${r||"no reason"}`)},onEvent:o=>pw(e,o),onGap:({expected:o,received:r})=>{console.warn(`[gateway] event gap: expected seq ${o}, got ${r}`),ki(e)}}),e.client.start()}function pw(e,t){try{hw(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function hw(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;Ip(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&Oc(e,i.sessionKey);const s=zl(e,i);if((s==="final"||s==="error"||s==="aborted")&&(ko(e),Af(e)),s==="final"){const o=e,r=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,De);Re(o,{limit:r})}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.chatSuggestion=i.suggestions[0]);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"&&e.tab==="cron"&&Fo(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&_o(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=Hb(t.payload);if(i){e.execApprovalQueue=Vb(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=ll(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){ew(e,t.payload);return}if(t.event==="browser.handoff"){tw(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){nw(e);return}if(t.event==="exec.approval.resolved"){const i=jb(t.payload);i&&(e.execApprovalQueue=ll(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){rw(e,t.payload);return}}function ul(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&&dw(e,n.sessionDefaults)}async function fw(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 gw(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await pi(e.client)}catch{}}async function mw(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status")}catch{}}async function yw(e){if(!(!e.client||!e.connected))try{e.wifiStatus=await e.client.request("wifi.status")}catch{}}const dl="taskmaster_public_id";function Zu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${dl}=`));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=`${dl}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function vw(e){var n,i;if(!e.client||!e.connected)return;const t=Zu((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const s=(i=e.publicChatConfig)==null?void 0:i.accountId,o=await e.client.request("public.session",{cookieId:t,accountId:s});o!=null&&o.sessionKey&&(e.publicChatSessionKey=o.sessionKey,e.sessionKey=o.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready",Re(e))}catch(s){console.error("[public-chat] failed to resolve anonymous session:",s),e.lastError="Failed to start chat session"}}let xe=!1,he=null,Ht="",Ri="";function ed(e){return e.replace(/[\s\-()]/g,"")}function td(){xe=!1,he=null,Ht="",Ri=""}async function bw(e){if(!e.client||!e.connected)return;const t=Zu(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){he=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function pl(e){if(!e.client||xe)return;const t=ed(Ht);if(!t){he="Please enter your phone number",e.requestUpdate();return}xe=!0,he=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:Ri.trim()||void 0,accountId:e.accountId});n!=null&&n.ok?e.onAuthStepChange("otp"):he=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){he=n instanceof Error?n.message:"Failed to send verification code"}finally{xe=!1,e.requestUpdate()}}async function hl(e,t){if(!(!e.client||xe)){if(!t.trim()){he="Please enter the verification code",e.requestUpdate();return}xe=!0,he=null,e.requestUpdate();try{const n=await e.client.request("public.otp.verify",{phone:ed(Ht),code:t.trim(),accountId:e.accountId});n!=null&&n.ok&&n.sessionKey?(td(),e.onAuthenticated(n.sessionKey)):he=(n==null?void 0:n.error)??"Invalid verification code"}catch(n){he=n instanceof Error?n.message:"Verification failed"}finally{xe=!1,e.requestUpdate()}}}function Us(e){return k}function fl(e){return d`
3809
3807
  <div class="public-auth__form">
3810
3808
  <label class="field public-auth__field">
3811
3809
  <span>Your name (optional)</span>
3812
3810
  <input
3813
3811
  type="text"
3814
- .value=${Ii}
3815
- @input=${t=>{Ii=t.target.value}}
3812
+ .value=${Ri}
3813
+ @input=${t=>{Ri=t.target.value}}
3816
3814
  placeholder="Name"
3817
3815
  />
3818
3816
  </label>
@@ -3822,7 +3820,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3822
3820
  type="tel"
3823
3821
  .value=${Ht}
3824
3822
  @input=${t=>{Ht=t.target.value}}
3825
- @keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),dl(e))}}
3823
+ @keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),pl(e))}}
3826
3824
  placeholder="+44 7123 456789"
3827
3825
  required
3828
3826
  />
@@ -3831,12 +3829,12 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3831
3829
  <button
3832
3830
  class="btn primary public-auth__btn"
3833
3831
  ?disabled=${xe}
3834
- @click=${()=>{dl(e)}}
3832
+ @click=${()=>{pl(e)}}
3835
3833
  >
3836
3834
  ${xe?"Sending...":"Send verification code"}
3837
3835
  </button>
3838
3836
  </div>
3839
- `}function fl(e){let t="";return d`
3837
+ `}function gl(e){let t="";return d`
3840
3838
  <div class="public-auth__form">
3841
3839
  <p class="public-auth__hint">
3842
3840
  We sent a verification code to <strong>${Ht}</strong> via WhatsApp.
@@ -3848,7 +3846,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3848
3846
  inputmode="numeric"
3849
3847
  maxlength="6"
3850
3848
  @input=${n=>{t=n.target.value}}
3851
- @keydown=${n=>{n.key==="Enter"&&(n.preventDefault(),pl(e,t))}}
3849
+ @keydown=${n=>{n.key==="Enter"&&(n.preventDefault(),hl(e,t))}}
3852
3850
  placeholder="123456"
3853
3851
  required
3854
3852
  />
@@ -3857,7 +3855,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3857
3855
  <button
3858
3856
  class="btn primary public-auth__btn"
3859
3857
  ?disabled=${xe}
3860
- @click=${()=>{pl(e,t)}}
3858
+ @click=${()=>{hl(e,t)}}
3861
3859
  >
3862
3860
  ${xe?"Verifying...":"Verify"}
3863
3861
  </button>
@@ -3868,7 +3866,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3868
3866
  Use a different number
3869
3867
  </button>
3870
3868
  </div>
3871
- `}function bw(e){const{authMode:t,authStep:n}=e;return t==="anonymous"?d`
3869
+ `}function ww(e){const{authMode:t,authStep:n}=e;return t==="anonymous"?d`
3872
3870
  <div class="setup-container">
3873
3871
  <div class="setup-card">
3874
3872
  <div class="setup-spinner"></div>
@@ -3878,37 +3876,37 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3878
3876
  `:t==="verified"?d`
3879
3877
  <div class="setup-container">
3880
3878
  <div class="public-auth">
3881
- ${Fs()}
3879
+ ${Us()}
3882
3880
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
3883
3881
  <p class="public-auth__subtitle">Verify your WhatsApp number to get started.</p>
3884
- ${n==="otp"?fl(e):hl(e)}
3882
+ ${n==="otp"?gl(e):fl(e)}
3885
3883
  </div>
3886
3884
  </div>
3887
3885
  `:n==="phone"||n==="otp"?d`
3888
3886
  <div class="setup-container">
3889
3887
  <div class="public-auth">
3890
- ${Fs()}
3888
+ ${Us()}
3891
3889
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
3892
3890
  <p class="public-auth__subtitle">Verify your WhatsApp number to continue your conversation across devices.</p>
3893
- ${n==="otp"?fl(e):hl(e)}
3891
+ ${n==="otp"?gl(e):fl(e)}
3894
3892
  </div>
3895
3893
  </div>
3896
3894
  `:d`
3897
3895
  <div class="setup-container">
3898
3896
  <div class="public-auth">
3899
- ${Fs()}
3897
+ ${Us()}
3900
3898
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
3901
3899
  <p class="public-auth__subtitle">How would you like to get started?</p>
3902
3900
  <div class="public-auth__choices">
3903
3901
  <button
3904
3902
  class="btn primary public-auth__btn"
3905
- @click=${()=>{vw(e)}}
3903
+ @click=${()=>{bw(e)}}
3906
3904
  >
3907
3905
  Chat now
3908
3906
  </button>
3909
3907
  <button
3910
3908
  class="btn public-auth__btn"
3911
- @click=${()=>{Zu(),e.onAuthStepChange("phone")}}
3909
+ @click=${()=>{td(),e.onAuthStepChange("phone")}}
3912
3910
  >
3913
3911
  Verify with WhatsApp
3914
3912
  </button>
@@ -3918,7 +3916,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3918
3916
  </p>
3919
3917
  </div>
3920
3918
  </div>
3921
- `}const ar="taskmaster-access-session",ed={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function td(){try{return localStorage.getItem(ar)}catch{return null}}function nd(e){try{localStorage.setItem(ar,e)}catch{}}function ww(){try{localStorage.removeItem(ar)}catch{}}async function gl(e){if(e.client)try{const t=td(),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 kw(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?(nd(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 Sw(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?(nd(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 $w(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 Aw(e){const t=td();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}ww(),e.accessState={...ed,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function xw(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 r=o.match;if(!r||typeof r!="object"||(r.channel??"").toLowerCase()!=="whatsapp")continue;const u=r.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,r)=>o.paired&&!r.paired?-1:!o.paired&&r.paired?1:0),i}function id(e,t,n="admin",i){const s=c=>c===n||c==="management",o=new Map,r=new Map;for(const c of e){if(!c||typeof c!="object"||!s(c.agentId))continue;const l=c.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")continue;const f=l.peer;if(!f||typeof f!="object"||f.kind!=="dm")continue;const b=f.id??"";b&&(c.meta&&o.set(b,c.meta),l.accountId&&r.set(b,l.accountId))}const a=e.filter(c=>{if(!c||typeof c!="object"||!s(c.agentId))return!0;const l=c.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")return!0;const f=l.peer;return!f||typeof f!="object"?!0:f.kind!=="dm"}),u=t.map(c=>{const l=i??r.get(c.phone),p={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};l&&(p.accountId=l);const f={agentId:n,match:p},b=o.get(c.phone);return b?f.meta=b:c.paired&&(f.meta={paired:!0}),f});return[...a,...u]}async function ji(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=st(s??{}),e.adminPhones=xw(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function sd(e,t,n,i){var r,a;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=st(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=u.bindings??[],l=[...e.adminPhones,{phone:o}],p=id(c,l,s,i);ql(u,["bindings"],p);const f=(a=e.configSnapshot)==null?void 0:a.hash;if(!f){e.adminsError="Config hash missing; reload and retry.";return}const b=vt(u);await e.client.request("config.set",{raw:b,baseHash:f}),await ji(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}async function od(e,t,n,i){var r,a;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=st(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=u.bindings??[],l=e.adminPhones.filter(h=>h.phone!==t),p=id(c,l,s,i);ql(u,["bindings"],p);const f=(a=e.configSnapshot)==null?void 0:a.hash;if(!f){e.adminsError="Config hash missing; reload and retry.";return}const b=vt(u);await e.client.request("config.set",{raw:b,baseHash:f}),await ji(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}const Ew=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:sd,loadAdmins:ji,removeAdmin:od},Symbol.toStringTag,{value:"Module"}));async function At(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 rd(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 At(e,i)}catch(r){e.contactsError=String(r)}finally{e.contactsSaving=!1}}async function ad(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 At(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function fo(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 At(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function ld(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 At(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const Cw=Object.freeze(Object.defineProperty({__proto__:null,addContact:rd,deleteContact:ad,deleteContactField:ld,loadContacts:At,setContactField:fo},Symbol.toStringTag,{value:"Module"}));function fn(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}}}function Tw(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}}}function _w(e){const t=ae(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 Mw(e){const t=ae(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function Pw(e){var i;const t=ae(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 Lw(e){return e.selectedWorkspace??void 0}function ae(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const Iw=/^data:/i,Rw=/^https?:\/\//i;function ml(e){var a,u;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=Pl(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,r=(o==null?void 0:o.avatarUrl)??(o==null?void 0:o.avatar);if(r)return Iw.test(r)||Rw.test(r)?r:o==null?void 0:o.avatarUrl}function Dw(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 Bw(e){var r;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(r=e.channelAccounts)==null?void 0:r.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 Nw(e){var r;const t=(r=e.configSnapshot)==null?void 0:r.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(a=>{var u,c;return((u=a.match)==null?void 0:u.channel)==="imessage"&&((c=a.meta)==null?void 0:c.imessageOwner)});if(!i)return null;const s=i.agentId;for(const a of e.workspaces)if(a.agents.some(u=>u.id===s))return a.name;if(s==="admin"||s==="public"){const a=e.workspaces.find(u=>u.isDefault);return(a==null?void 0:a.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const a=e.workspaces.find(u=>u.name===o);return(a==null?void 0:a.name)??null}return null}function Ow(e){var t,n,i,s,o,r,a,u,c;if(e.embeddingDownloading&&!e.publicChat)return d`
3919
+ `}const lr="taskmaster-access-session",nd={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function id(){try{return localStorage.getItem(lr)}catch{return null}}function sd(e){try{localStorage.setItem(lr,e)}catch{}}function kw(){try{localStorage.removeItem(lr)}catch{}}async function ml(e){if(e.client)try{const t=id(),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 Sw(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?(sd(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 $w(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?(sd(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 Aw(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 xw(e){const t=id();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}kw(),e.accessState={...nd,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function Ew(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 r=o.match;if(!r||typeof r!="object"||(r.channel??"").toLowerCase()!=="whatsapp")continue;const u=r.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,r)=>o.paired&&!r.paired?-1:!o.paired&&r.paired?1:0),i}function od(e,t,n="admin",i){const s=c=>c===n||c==="management",o=new Map,r=new Map;for(const c of e){if(!c||typeof c!="object"||!s(c.agentId))continue;const l=c.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")continue;const f=l.peer;if(!f||typeof f!="object"||f.kind!=="dm")continue;const b=f.id??"";b&&(c.meta&&o.set(b,c.meta),l.accountId&&r.set(b,l.accountId))}const a=e.filter(c=>{if(!c||typeof c!="object"||!s(c.agentId))return!0;const l=c.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")return!0;const f=l.peer;return!f||typeof f!="object"?!0:f.kind!=="dm"}),u=t.map(c=>{const l=i??r.get(c.phone),p={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};l&&(p.accountId=l);const f={agentId:n,match:p},b=o.get(c.phone);return b?f.meta=b:c.paired&&(f.meta={paired:!0}),f});return[...a,...u]}async function Vi(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=it(s??{}),e.adminPhones=Ew(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function rd(e,t,n,i){var r,a;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=it(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=u.bindings??[],l=[...e.adminPhones,{phone:o}],p=od(c,l,s,i);Hl(u,["bindings"],p);const f=(a=e.configSnapshot)==null?void 0:a.hash;if(!f){e.adminsError="Config hash missing; reload and retry.";return}const b=bt(u);await e.client.request("config.set",{raw:b,baseHash:f}),await Vi(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}async function ad(e,t,n,i){var r,a;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=it(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=u.bindings??[],l=e.adminPhones.filter(h=>h.phone!==t),p=od(c,l,s,i);Hl(u,["bindings"],p);const f=(a=e.configSnapshot)==null?void 0:a.hash;if(!f){e.adminsError="Config hash missing; reload and retry.";return}const b=bt(u);await e.client.request("config.set",{raw:b,baseHash:f}),await Vi(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}const Cw=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:rd,loadAdmins:Vi,removeAdmin:ad},Symbol.toStringTag,{value:"Module"}));async function xt(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 ld(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 xt(e,i)}catch(r){e.contactsError=String(r)}finally{e.contactsSaving=!1}}async function cd(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 xt(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function go(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 xt(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function ud(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 xt(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const Tw=Object.freeze(Object.defineProperty({__proto__:null,addContact:ld,deleteContact:cd,deleteContactField:ud,loadContacts:xt,setContactField:go},Symbol.toStringTag,{value:"Module"}));function fn(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}}}function _w(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}}}function Mw(e){const t=ae(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 Pw(e){const t=ae(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function Lw(e){var i;const t=ae(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 Iw(e){return e.selectedWorkspace??void 0}function ae(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const Rw=/^data:/i,Dw=/^https?:\/\//i;function yl(e){var a,u;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=Ll(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,r=(o==null?void 0:o.avatarUrl)??(o==null?void 0:o.avatar);if(r)return Rw.test(r)||Dw.test(r)?r:o==null?void 0:o.avatarUrl}function Bw(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 Nw(e){var r;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(r=e.channelAccounts)==null?void 0:r.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 Ow(e){var r;const t=(r=e.configSnapshot)==null?void 0:r.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(a=>{var u,c;return((u=a.match)==null?void 0:u.channel)==="imessage"&&((c=a.meta)==null?void 0:c.imessageOwner)});if(!i)return null;const s=i.agentId;for(const a of e.workspaces)if(a.agents.some(u=>u.id===s))return a.name;if(s==="admin"||s==="public"){const a=e.workspaces.find(u=>u.isDefault);return(a==null?void 0:a.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const a=e.workspaces.find(u=>u.name===o);return(a==null?void 0:a.name)??null}return null}function Fw(e){var t,n,i,s,o,r,a,u,c;if(e.embeddingDownloading&&!e.publicChat)return d`
3922
3920
  <div class="setup-container">
3923
3921
  <div class="setup-card" style="text-align:center; max-width:420px;">
3924
3922
  <div class="setup-spinner"></div>
@@ -3932,14 +3930,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3932
3930
  </p>
3933
3931
  </div>
3934
3932
  </div>
3935
- `;if(e.publicChat)return e.connected?e.publicChatAuthenticated?Bb({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??ml(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,suggestion:e.chatSuggestion,onSuggestionClick:l=>{e.chatMessage=l,e.chatSuggestion=null,e.handleSendChat()},onRefresh:()=>(e.resetToolStream(),oe(async()=>{const{loadChatHistory:l}=await Promise.resolve().then(()=>vi);return{loadChatHistory:l}},void 0,import.meta.url).then(({loadChatHistory:l})=>{l(e)})),onDraftChange:l=>e.chatMessage=l,attachments:e.chatAttachments,onAttachmentsChange:l=>e.chatAttachments=l,onSend:()=>e.handleSendChat(),onAbort:()=>{e.handleAbortChat()},onQueueRemove:l=>e.removeQueuedMessage(l),onChatScroll:l=>e.handleChatScroll(l),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()}}):bw({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,onAuthenticated:l=>{e.publicChatSessionKey=l,e.sessionKey=l,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready",oe(async()=>{const{loadChatHistory:p}=await Promise.resolve().then(()=>vi);return{loadChatHistory:p}},void 0,import.meta.url).then(({loadChatHistory:p})=>{p(e)})},onAuthStepChange:l=>{e.publicChatAuthStep=l},requestUpdate:()=>{e.requestUpdate()}}):d`
3933
+ `;if(e.publicChat)return e.connected?e.publicChatAuthenticated?Nb({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??yl(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,suggestion:e.chatSuggestion,onSuggestionClick:l=>{e.chatMessage=l,e.chatSuggestion=null,e.handleSendChat()},onRefresh:()=>(e.resetToolStream(),oe(async()=>{const{loadChatHistory:l}=await Promise.resolve().then(()=>vi);return{loadChatHistory:l}},void 0,import.meta.url).then(({loadChatHistory:l})=>{l(e)})),onDraftChange:l=>e.chatMessage=l,requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:l=>e.chatAttachments=l,onSend:()=>e.handleSendChat(),onAbort:()=>{e.handleAbortChat()},onQueueRemove:l=>e.removeQueuedMessage(l),onChatScroll:l=>e.handleChatScroll(l),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()}}):ww({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,onAuthenticated:l=>{e.publicChatSessionKey=l,e.sessionKey=l,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready",oe(async()=>{const{loadChatHistory:p}=await Promise.resolve().then(()=>vi);return{loadChatHistory:p}},void 0,import.meta.url).then(({loadChatHistory:p})=>{p(e)})},onAuthStepChange:l=>{e.publicChatAuthStep=l},requestUpdate:()=>{e.requestUpdate()}}):d`
3936
3934
  <div class="setup-container">
3937
3935
  <div class="setup-card">
3938
3936
  <div class="setup-spinner"></div>
3939
3937
  <p>Connecting...</p>
3940
3938
  </div>
3941
3939
  </div>
3942
- `;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return ol({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(p,f)=>{f!=null&&e.handlePinSubmit(p,f)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(p,f,b)=>e.handleChangePin(p,f,b)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return ol({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",k}if(e.setup){const l=Dw(e.channelsSnapshot),p=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],f=Bw(e.channelsSnapshot),b=Nw(e);return Yf({connected:e.connected,serverPlatform:((s=(i=e.hello)==null?void 0:i.server)==null?void 0:s.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:h=>e.handleLicenseKeyChange(h),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:l,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:h=>e.handleUninstallConfirmTextChange(h),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:h=>e.handleAuthSubmitCode(h),onAuthCodeChange:h=>e.handleAuthCodeChange(h),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async h=>{await e.handleWhatsAppStart(!0,h),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(h),await Y(e,!0),e.requestUpdate())},onWhatsAppUnlink:async h=>{await e.handleWhatsAppLogout(h)},onWhatsAppReset:async h=>{await e.handleWhatsAppLogout(h),await e.handleWhatsAppStart(!0,h),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(h),await Y(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await Y(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),Y(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:h=>e.handleRemoveWhatsAppAccount(h),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:h=>{e.newWorkspacePin=h},onWorkspaceCreate:async(h,v)=>{const S=e.newWorkspacePin;await e.handleWorkspaceCreate(h,v),S.match(/^\d{4,6}$/)&&(await $w(e,h,S),e.newWorkspacePin="")},onWorkspaceRemove:h=>e.handleWorkspaceRemove(h),onSetAddingWorkspace:h=>{e.addingWorkspace=h},onSetNewWorkspaceName:h=>{e.newWorkspaceName=h},onSetNewWorkspacePath:h=>{e.newWorkspacePath=h},onSetWorkspaceRemoveConfirm:h=>{e.workspaceRemoveConfirm=h},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(h,v)=>e.handleWorkspaceRename(h,v),whatsappDmPolicy:(()=>{const h=ae(e),v=h==null?void 0:h.whatsappAccountId,S=v?p.find($=>$.accountId===v):p[0];return(S==null?void 0:S.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var T;const h=ae(e),v=h==null?void 0:h.whatsappAccountId,S=v?p.find(_=>_.accountId===v):p[0];if(!S)return;const A=S.dmPolicy!=null&&S.dmPolicy!=="disabled"?"disabled":"open",E=A==="open"?{dmPolicy:A,allowFrom:["*"]}:{dmPolicy:A};try{const _=await e.client.request("config.get"),B=_.config,F=(T=B==null?void 0:B.channels)==null?void 0:T.whatsapp,be=((F==null?void 0:F.accounts)??{})[S.accountId]?{channels:{whatsapp:{accounts:{[S.accountId]:E}}}}:{channels:{whatsapp:E}};await e.client.request("config.patch",{raw:JSON.stringify(be),baseHash:_.hash,note:`WhatsApp DM policy → ${A}`,skipRestart:!0}),await Y(e,!1)}catch(_){console.error("DM toggle failed:",_)}},whatsappModel:(()=>{var T,_;const h=ae(e);if(!h)return null;const v=h.agents.find(B=>B.id.endsWith("-public")||B.id==="public");if(!v)return null;const S=(T=e.configSnapshot)==null?void 0:T.config,$=(_=S==null?void 0:S.agents)==null?void 0:_.list;if(!Array.isArray($))return null;const A=$.find(B=>B.id===v.id);if(!(A!=null&&A.model))return null;const E=typeof A.model=="string"?A.model:A.model.primary;return(E==null?void 0:E.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async h=>{const v=ae(e);if(!v)return;const S=v.agents.find($=>$.id.endsWith("-public")||$.id==="public");if(S)try{const $=await e.client.request("config.get"),A=$.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],_=T.findIndex(F=>F.id===S.id);if(h)_>=0?T[_]={...T[_],model:h}:T.push({id:S.id,model:h});else if(_>=0){const{model:F,...ne}=T[_];Object.keys(ne).length<=1?T.splice(_,1):T[_]=ne}const B=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(B),baseHash:$.hash,note:`Public agent model → ${h||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Model change failed:",$)}},whatsappThinkingLevel:(()=>{var E,T,_;const h=ae(e);if(!h)return null;const v=h.agents.find(B=>B.id.endsWith("-public")||B.id==="public");if(!v)return null;const S=(E=e.configSnapshot)==null?void 0:E.config,$=(T=S==null?void 0:S.agents)==null?void 0:T.list;if(!Array.isArray($))return null;const A=$.find(B=>B.id===v.id);return((_=A==null?void 0:A.thinkingLevel)==null?void 0:_.trim())||null})(),onWhatsAppThinkingChange:async h=>{const v=ae(e);if(!v)return;const S=v.agents.find($=>$.id.endsWith("-public")||$.id==="public");if(S)try{const $=await e.client.request("config.get"),A=$.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],_=T.findIndex(ne=>ne.id===S.id),B=h==="off"?void 0:h;if(B)_>=0?T[_]={...T[_],thinkingLevel:B}:T.push({id:S.id,thinkingLevel:B});else if(_>=0){const{thinkingLevel:ne,...be}=T[_];Object.keys(be).length<=1?T.splice(_,1):T[_]=be}const F=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(F),baseHash:$.hash,note:`Public agent thinking → ${B||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Thinking change failed:",$)}},whatsappGroupPolicy:(()=>{var _,B;const h=(_=e.configSnapshot)==null?void 0:_.config,v=(B=h==null?void 0:h.channels)==null?void 0:B.whatsapp,S=ae(e),$=S==null?void 0:S.whatsappAccountId,A=(v==null?void 0:v.accounts)??{},E=$?A[$]:void 0;return(E==null?void 0:E.groupPolicy)??(v==null?void 0:v.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var B,F;const h=(B=e.configSnapshot)==null?void 0:B.config,v=(F=h==null?void 0:h.channels)==null?void 0:F.whatsapp,S=ae(e),$=S==null?void 0:S.whatsappAccountId,A=(v==null?void 0:v.accounts)??{},E=$?A[$]:void 0,_=((E==null?void 0:E.groups)??(v==null?void 0:v.groups)??{})["*"];return(_==null?void 0:_.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var S;const h=ae(e),v=h==null?void 0:h.whatsappAccountId;try{const $=await e.client.request("config.get"),A=$.config,E=((S=A==null?void 0:A.channels)==null?void 0:S.whatsapp)??{},T=E.accounts??{},_=v?T[v]:void 0,B=(_==null?void 0:_.groupPolicy)??E.groupPolicy??"allowlist",F=B==="disabled"||B==="allowlist",ne=F?"open":"disabled",be=F?{"*":{}}:void 0,Qe={groupPolicy:ne};be&&(Qe.groups=be);const ee=_?{channels:{whatsapp:{accounts:{[v]:Qe}}}}:{channels:{whatsapp:Qe}};await e.client.request("config.patch",{raw:JSON.stringify(ee),baseHash:$.hash,note:`WhatsApp groups → ${ne}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Group toggle failed:",$)}},onWhatsAppGroupMentionChange:async h=>{var $;const v=ae(e),S=v==null?void 0:v.whatsappAccountId;try{const A=await e.client.request("config.get"),E=A.config,_=((($=E==null?void 0:E.channels)==null?void 0:$.whatsapp)??{}).accounts??{},B=S?_[S]:void 0,F={"*":{requireMention:h}},ne=B?{channels:{whatsapp:{accounts:{[S]:{groups:F}}}}}:{channels:{whatsapp:{groups:F}}};await e.client.request("config.patch",{raw:JSON.stringify(ne),baseHash:A.hash,note:`WhatsApp group mention → ${h?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group mention change failed:",A)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:f.configured,imessageRunning:f.running,imessageConnected:f.connected,imessageLastError:f.lastError,imessageSelfChatMode:f.selfChatMode,imessageCliPath:f.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:b,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),v=h.config,S=(v==null?void 0:v.bindings)??[],$=ae(e),A=$==null?void 0:$.agents.find(F=>F.id.endsWith("-admin")||F.id==="admin"),E=(A==null?void 0:A.id)??"admin",T=S.filter(F=>{var ne;return((ne=F.match)==null?void 0:ne.channel)!=="imessage"}),_=[{agentId:E,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],B=[...T,..._];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:B}),baseHash:h.hash,note:"Enable iMessage (self-chat) for "+(($==null?void 0:$.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Y(e,!0),Be(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await Y(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),v=h.config,$=((v==null?void 0:v.bindings)??[]).filter(A=>{var E;return((E=A.match)==null?void 0:E.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:$}),baseHash:h.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Y(e,!0),Be(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),v=h.config,S=(v==null?void 0:v.bindings)??[],$=ae(e),A=$==null?void 0:$.agents.find(B=>B.id.endsWith("-admin")||B.id==="admin"),E=(A==null?void 0:A.id)??"admin",T=S.filter(B=>{var F;return((F=B.match)==null?void 0:F.channel)!=="imessage"}),_=[{agentId:E,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:[...T,..._]}),baseHash:h.hash,note:"Reassign iMessage to "+(($==null?void 0:$.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Y(e,!0),Be(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:h=>{e.infoModalOpen=h},onInfoModalClose:()=>{e.infoModalOpen=null},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(h,v)=>{e.apiKeySavingProvider=h,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await ll(e.client,h,v);const S=`${h} key saved`;e.apiKeySuccess=S,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await pi(e.client)}catch{}h==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===S&&(e.apiKeySuccess=null)},2500)}catch(S){e.apiKeyError=S instanceof Error?S.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async h=>{e.apiKeySavingProvider=h,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await nw(e.client,h);const v=`${h} key removed`;e.apiKeySuccess=v,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await pi(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===v&&(e.apiKeySuccess=null)},2500)}catch(v){e.apiKeyError=v instanceof Error?v.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyDisable:async(h,v)=>{e.apiKeySavingProvider=h,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await iw(e.client,h,v);const S=`${h} ${v?"disabled":"enabled"}`;e.apiKeySuccess=S,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await pi(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===S&&(e.apiKeySuccess=null)},2500)}catch(S){e.apiKeyError=S instanceof Error?S.message:`Failed to ${v?"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:h=>{e.authApiKeyInput=h},onAuthApiKeySubmit:async()=>{const h=e.authApiKeyInput.trim();if(h){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await ll(e.client,"anthropic",h),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(v){e.authApiKeyError=v instanceof Error?v.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var v;const h=e.selectedWorkspace??((v=e.workspaces[0])==null?void 0:v.name);return h?e.accessState.accounts.some(S=>S.id===h):!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:(h,v)=>{var $;const S=e.selectedWorkspace??(($=e.workspaces[0])==null?void 0:$.name);S&&e.handleAccountPinSave(S,h,v)},publicChatEnabled:(()=>{var S;const h=(S=e.configSnapshot)==null?void 0:S.config,v=h==null?void 0:h.publicChat;return(v==null?void 0:v.enabled)===!0})(),publicChatAuthMode:(()=>{var $;const h=($=e.configSnapshot)==null?void 0:$.config,v=h==null?void 0:h.publicChat,S=v==null?void 0:v.auth;return S==="verified"||S==="choice"?S:"anonymous"})(),publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var h;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const v=await e.client.request("config.get"),S=v.config,$=((h=S==null?void 0:S.publicChat)==null?void 0:h.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!$}}),baseHash:v.hash,note:`Public chat → ${$?"disabled":"enabled"}`}),e.configSnapshot=await e.client.request("config.get")}catch(v){console.error("Public chat toggle failed:",v)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async h=>{if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const v=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{auth:h}}),baseHash:v.hash,note:`Public chat auth → ${h}`}),e.configSnapshot=await e.client.request("config.get")}catch(v){console.error("Public chat auth mode change failed:",v)}finally{e.publicChatToggleBusy=!1}}},brandAccentColor:(()=>{var S;const h=e.selectedWorkspace;return h?((S=Le()[h])==null?void 0:S.accentColor)??"":""})(),brandBackgroundColor:(()=>{var S;const h=e.selectedWorkspace;return h?((S=Le()[h])==null?void 0:S.backgroundColor)??"":""})(),brandHasLogo:(()=>{var S;const h=e.selectedWorkspace;return h?!!((S=Le()[h])!=null&&S.logoUrl):!1})(),brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async h=>{var S;const v=e.selectedWorkspace;if(!(!v||e.brandingBusy)){e.brandingBusy=!0;try{const $=await e.client.request("config.get"),A=$.config,E=((S=A==null?void 0:A.workspaces)==null?void 0:S[v])??{},T=E.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[v]:{...E,brand:{...T,accentColor:h}}}}),baseHash:$.hash,note:`Brand accent → ${h}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const _=Le();_[v]||(_[v]={}),_[v].accentColor=h,vn(v)}catch($){console.error("Brand accent change failed:",$)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async h=>{var S;const v=e.selectedWorkspace;if(!(!v||e.brandingBusy)){e.brandingBusy=!0;try{const $=await e.client.request("config.get"),A=$.config,E=((S=A==null?void 0:A.workspaces)==null?void 0:S[v])??{},T=E.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[v]:{...E,brand:{...T,backgroundColor:h}}}}),baseHash:$.hash,note:`Brand background → ${h}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const _=Le();_[v]||(_[v]={}),_[v].backgroundColor=h,vn(v)}catch($){console.error("Brand background change failed:",$)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async h=>{const v=e.selectedWorkspace;if(!(!v||e.brandingBusy)){e.brandingBusy=!0;try{const S=await h.arrayBuffer(),$=new Uint8Array(S);let A="";for(let _=0;_<$.length;_++)A+=String.fromCharCode($[_]);const E=btoa(A);await e.client.request("brand.uploadLogo",{workspace:v,data:E,mimeType:h.type});const T=Le();T[v]||(T[v]={}),T[v].logoUrl=`/brand-logo/${encodeURIComponent(v)}`}catch(S){console.error("Brand logo upload failed:",S)}finally{e.brandingBusy=!1}}},onBrandLogoRemove:async()=>{const h=e.selectedWorkspace;if(!(!h||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:h});const v=Le();v[h]&&delete v[h].logoUrl}catch(v){console.error("Brand logo remove failed:",v)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var v;const h=e.selectedWorkspace;if(!(!h||e.brandingBusy)){e.brandingBusy=!0;try{const S=await e.client.request("config.get"),$=S.config,A=((v=$==null?void 0:$.workspaces)==null?void 0:v[h])??{},{brand:E,...T}=A;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[h]:{...T,brand:null}}}),baseHash:S.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:h})}catch{}const _=Le();delete _[h],vn(h)}catch(S){console.error("Brand reset failed:",S)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null;try{const h=await e.client.request("tailscale.enable");if(h.authUrl){e.tailscaleAuthUrl=h.authUrl;const v=setInterval(async()=>{try{const S=await e.client.request("tailscale.status");e.tailscaleStatus=S,S.loggedIn&&(clearInterval(v),e.tailscaleAuthUrl=null,e.tailscaleBusy=!1)}catch{}},3e3);setTimeout(()=>{clearInterval(v),e.tailscaleBusy&&(e.tailscaleBusy=!1)},3e5)}else h.alreadyLoggedIn&&(e.tailscaleStatus=await e.client.request("tailscale.status")),e.tailscaleBusy=!1}catch(h){console.error("Tailscale enable failed:",h),e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var h;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable")}catch(v){console.error("Tailscale funnel enable failed:",v);const S=v;(h=S.payload)!=null&&h.enableUrl&&(e.tailscaleFunnelEnableUrl=S.payload.enableUrl),e.tailscaleError=S.message||"Failed to enable Funnel",e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable")}catch(h){console.error("Tailscale funnel disable failed:",h),e.tailscaleBusy=!1}}},wifiStatus:e.wifiStatus,wifiNetworks:e.wifiNetworks,wifiBusy:e.wifiBusy,wifiError:e.wifiError,wifiPassword:e.wifiPassword,wifiSelectedSsid:e.wifiSelectedSsid,onWifiScan:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[h,v]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);e.wifiNetworks=h.networks,e.wifiStatus=v}catch(h){console.error("WiFi scan failed:",h),e.wifiError=h.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{if(e.wifiBusy||!e.wifiSelectedSsid)return;const h=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const v=await e.client.request("wifi.connect",{ssid:h,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:v.connected,ssid:v.ssid,signal:null,ip:v.ip,savedSsid:v.ssid,autoconnect:!0},e.wifiBusy=!1;try{const S=await e.client.request("wifi.status");e.wifiStatus=S}catch{}}catch(v){console.error("WiFi connect failed:",v),e.wifiError=v.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 h=await e.client.request("wifi.status");e.wifiStatus=h}catch(h){console.error("WiFi disconnect failed:",h),e.wifiError=h.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 h=await e.client.request("wifi.status");e.wifiStatus=h}catch(h){console.error("WiFi forget failed:",h),e.wifiError=h.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:h=>{e.wifiSelectedSsid=h,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:h=>{e.wifiPassword=h},wsProps:Tw(e)})}if(e.filesPage){const l=Pw(e);return Df({connected:e.connected,wsProps:fn(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:()=>Qt(e,l),onReindex:()=>Yh(e,l),onSelectFile:p=>{e.filesPendingDeletePath=null,Kh(e,p,l)},onToggleSelectFile:p=>zh(e,p,l),onToggleDir:p=>Xh(e,p),onUpload:(p,f)=>jh(e,p,f,l),onNewFolder:(p,f)=>Vh(e,p,f,l),onDownload:p=>Bc(e,p,l),onBulkDownload:()=>qh(e,l),onDelete:p=>{e.filesPendingDeletePath=null,Gh(e,p,l)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,f)=>Hh(e,p,f,l),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const f=e.filesSearchAgentId??l;Jh(e,p,f)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{Zh(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return _f({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:()=>Gb(e),onStop:()=>Qb(e),onToggleInput:()=>Xb(e),onToggleFullscreen:()=>Jb(e),onCompleteHandoff:()=>Yb(e),onCanvasMouseDown:l=>{const f=l.target.getBoundingClientRect(),h=An().translateCoordinates(l.clientX-f.left,l.clientY-f.top);Bs(e,"mousePressed",h.x,h.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const f=l.target.getBoundingClientRect(),h=An().translateCoordinates(l.clientX-f.left,l.clientY-f.top);Bs(e,"mouseReleased",h.x,h.y)},onCanvasMouseMove:l=>{const p=An();if(p.shouldThrottleMouseMove())return;const b=l.target.getBoundingClientRect(),h=p.translateCoordinates(l.clientX-b.left,l.clientY-b.top);Bs(e,"mouseMoved",h.x,h.y)},onCanvasKeyDown:l=>{let p=0;l.altKey&&(p|=1),l.ctrlKey&&(p|=2),l.metaKey&&(p|=4),l.shiftKey&&(p|=8),Ns(e,"keyDown",l.key,{code:l.code,modifiers:p||void 0}),l.key.length===1&&Ns(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{Ns(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=_w(e),p=Mw(e);return Jf({connected:e.connected,wsProps:fn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>ji(e,l),onAdd:f=>{sd(e,f,l,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:f=>od(e,f,l,p),onNewPhoneChange:f=>e.handleAdminsNewPhoneChange(f)})}if(e.contactsPage){const l=Lw(e);return sg({connected:e.connected,wsProps:fn(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:()=>At(e,l),onAdd:(p,f)=>rd(e,p,f,l),onDelete:p=>ad(e,p,l),onSetField:(p,f,b)=>fo(e,p,f,b,l),onDeleteField:(p,f)=>ld(e,p,f,l),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:()=>At(e,l),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,f=e.contactsAddFieldKey.trim();!p||!f||(fo(e,p,f,e.contactsAddFieldValue,l),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",p=ml(e),f=e.chatAvatarUrl??p??null,b=(()=>{var S;const h=(S=e.configSnapshot)==null?void 0:S.config,v=h==null?void 0:h.publicChat;return(v==null?void 0:v.enabled)===!0})();return Xv({connected:e.connected,wsProps:fn(e),publicChatEnabled:b,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:h=>{e.sessionKey=h,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestion=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:h,lastActiveSessionKey:h}),e.loadAssistantIdentity(),Re(e),Qs(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:h=>{const v=Math.max(e.chatMessages.length+10,De);Vn(e,e.sessionKey,{model:h}).then(()=>{Re(e,{limit:v})})},onThinkingLevelChange:h=>{const v=Math.max(e.chatMessages.length+10,De);Vn(e,e.sessionKey,{thinkingLevel:h==="off"?null:h}).then(()=>{Re(e,{limit:v})})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestion:e.chatSuggestion,onSuggestionClick:h=>{e.chatMessage=h,e.chatSuggestion=null,e.handleSendChat()},onVerboseChange:h=>{const v=Math.max(e.chatMessages.length+10,De);Vn(e,e.sessionKey,{verboseLevel:h==="off"?null:h}).then(()=>{Re(e,{limit:v})})},onFillerChange:h=>{const v=Math.max(e.chatMessages.length+10,De);Vn(e,e.sessionKey,{fillerEnabled:h}).then(()=>{Re(e,{limit:v})})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:f,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:l,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const h=Math.max(e.chatMessages.length+10,De);return Promise.all([Re(e,{limit:h}),Qs(e)])},onToggleFocusMode:()=>{},onChatScroll:h=>e.handleChatScroll(h),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:h=>e.chatMessage=h,attachments:e.chatAttachments,onAttachmentsChange:h=>e.chatAttachments=h,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:h=>e.removeQueuedMessage(h),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:h=>e.handleOpenSidebar(h),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:h=>e.handleSplitRatioChange(h),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?Db({connected:e.connected,wsProps:fn(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&je(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?kn(e,{reset:!0}):Ft(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(o=e.channelsSnapshot)==null?void 0:o.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((a=e.channelsSnapshot)==null?void 0:a.channelOrder)??[],channelLabels:((u=e.channelsSnapshot)==null?void 0:u.channelLabels)??{},channelMeta:((c=e.channelsSnapshot)==null?void 0:c.channelMeta)??[],agentIds:(()=>{var p;const l=ae(e);return((p=l==null?void 0:l.agents)==null?void 0:p.map(f=>f.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:l=>{e.cronDetailJobId=l.id,qs(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:l=>{e.cronForm=Vp(l),e.cronEditJobId=l.id,e.cronDetailJobId=null},onEditSave:()=>{const l=e.cronEditJobId;l&&Gp(e,l).then(()=>{e.cronEditJobId=null})},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{zp(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,p)=>qp(e,l,p),onRun:l=>Hp(e,l),onRemove:l=>{e.cronPendingDeleteId=null,jp(e,l)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:l=>{e.cronPendingDeleteId=l||null},onLoadRuns:l=>qs(e,l)},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,detail:e.skillDetail,detailTab:e.skillDetailTab,addModal:e.skillAddModal,drafts:e.skillDrafts,onFilterChange:l=>e.skillsFilter=l,onRefresh:()=>je(e,{clearMessages:!0}),onToggle:(l,p)=>yc(e,l,p),onEdit:(l,p)=>mc(e,l,p),onSaveKey:l=>vc(e,l),onInstall:(l,p,f)=>bc(e,l,p,f),onViewDetail:l=>wc(e,l),onDetailClose:()=>kc(e),onDetailTab:l=>Sc(e,l),onAddOpen:()=>$c(e),onAddClose:()=>Ac(e),onImportDraft:l=>xc(e,l),onDeleteDraft:l=>Cc(e,l),onAddSave:()=>Ec(e),onDelete:l=>_c(e,l),onEditSkill:l=>Tc(e,l)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?kn(e,{reset:!0}):Ft(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,expandedIds:e.sessionLogsExpandedIds,onFilterTextChange:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,p)=>{const f=e;f.sessionLogsTypeFilters={...f.sessionLogsTypeFilters,[l]:p}},onAgentToggle:(l,p)=>{const f=e;f.sessionLogsAgentFilters={...f.sessionLogsAgentFilters,[l]:p}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onToggleExpand:l=>{const p=e,f=new Set(p.sessionLogsExpandedIds);f.has(l)?f.delete(l):f.add(l),p.sessionLogsExpandedIds=f,p.requestUpdate()},onRefresh:()=>{kn(e,{reset:!0})},onExport:(l,p)=>e.exportSessionLogs(l,p),onScroll:l=>e.handleSessionLogsScroll(l)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,truncated:e.logsTruncated,onFilterTextChange:l=>e.logsFilterText=l,onLevelToggle:(l,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:p}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onRefresh:()=>Ft(e,{reset:!0}),onExport:(l,p)=>e.exportSessionLogs(l,p),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),d``)}function Fw(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 yl(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Uw(e,t,n){return d`
3940
+ `;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return rl({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(p,f)=>{f!=null&&e.handlePinSubmit(p,f)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(p,f,b)=>e.handleChangePin(p,f,b)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return rl({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",k}if(e.setup){const l=Bw(e.channelsSnapshot),p=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],f=Nw(e.channelsSnapshot),b=Ow(e);return Jf({connected:e.connected,serverPlatform:((s=(i=e.hello)==null?void 0:i.server)==null?void 0:s.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:h=>e.handleLicenseKeyChange(h),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:l,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:h=>e.handleUninstallConfirmTextChange(h),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:h=>e.handleAuthSubmitCode(h),onAuthCodeChange:h=>e.handleAuthCodeChange(h),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async h=>{await e.handleWhatsAppStart(!0,h),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(h),await Y(e,!0),e.requestUpdate())},onWhatsAppUnlink:async h=>{await e.handleWhatsAppLogout(h)},onWhatsAppReset:async h=>{await e.handleWhatsAppLogout(h),await e.handleWhatsAppStart(!0,h),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(h),await Y(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await Y(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),Y(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:h=>e.handleRemoveWhatsAppAccount(h),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:h=>{e.newWorkspacePin=h},onWorkspaceCreate:async(h,v)=>{const S=e.newWorkspacePin;await e.handleWorkspaceCreate(h,v),S.match(/^\d{4,6}$/)&&(await Aw(e,h,S),e.newWorkspacePin="")},onWorkspaceRemove:h=>e.handleWorkspaceRemove(h),onSetAddingWorkspace:h=>{e.addingWorkspace=h},onSetNewWorkspaceName:h=>{e.newWorkspaceName=h},onSetNewWorkspacePath:h=>{e.newWorkspacePath=h},onSetWorkspaceRemoveConfirm:h=>{e.workspaceRemoveConfirm=h},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(h,v)=>e.handleWorkspaceRename(h,v),whatsappDmPolicy:(()=>{const h=ae(e),v=h==null?void 0:h.whatsappAccountId,S=v?p.find($=>$.accountId===v):p[0];return(S==null?void 0:S.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var T;const h=ae(e),v=h==null?void 0:h.whatsappAccountId,S=v?p.find(_=>_.accountId===v):p[0];if(!S)return;const A=S.dmPolicy!=null&&S.dmPolicy!=="disabled"?"disabled":"open",E=A==="open"?{dmPolicy:A,allowFrom:["*"]}:{dmPolicy:A};try{const _=await e.client.request("config.get"),D=_.config,F=(T=D==null?void 0:D.channels)==null?void 0:T.whatsapp,be=((F==null?void 0:F.accounts)??{})[S.accountId]?{channels:{whatsapp:{accounts:{[S.accountId]:E}}}}:{channels:{whatsapp:E}};await e.client.request("config.patch",{raw:JSON.stringify(be),baseHash:_.hash,note:`WhatsApp DM policy → ${A}`,skipRestart:!0}),await Y(e,!1)}catch(_){console.error("DM toggle failed:",_)}},whatsappModel:(()=>{var T,_;const h=ae(e);if(!h)return null;const v=h.agents.find(D=>D.id.endsWith("-public")||D.id==="public");if(!v)return null;const S=(T=e.configSnapshot)==null?void 0:T.config,$=(_=S==null?void 0:S.agents)==null?void 0:_.list;if(!Array.isArray($))return null;const A=$.find(D=>D.id===v.id);if(!(A!=null&&A.model))return null;const E=typeof A.model=="string"?A.model:A.model.primary;return(E==null?void 0:E.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async h=>{const v=ae(e);if(!v)return;const S=v.agents.find($=>$.id.endsWith("-public")||$.id==="public");if(S)try{const $=await e.client.request("config.get"),A=$.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],_=T.findIndex(F=>F.id===S.id);if(h)_>=0?T[_]={...T[_],model:h}:T.push({id:S.id,model:h});else if(_>=0){const{model:F,...ne}=T[_];Object.keys(ne).length<=1?T.splice(_,1):T[_]=ne}const D=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(D),baseHash:$.hash,note:`Public agent model → ${h||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Model change failed:",$)}},whatsappThinkingLevel:(()=>{var E,T,_;const h=ae(e);if(!h)return null;const v=h.agents.find(D=>D.id.endsWith("-public")||D.id==="public");if(!v)return null;const S=(E=e.configSnapshot)==null?void 0:E.config,$=(T=S==null?void 0:S.agents)==null?void 0:T.list;if(!Array.isArray($))return null;const A=$.find(D=>D.id===v.id);return((_=A==null?void 0:A.thinkingLevel)==null?void 0:_.trim())||null})(),onWhatsAppThinkingChange:async h=>{const v=ae(e);if(!v)return;const S=v.agents.find($=>$.id.endsWith("-public")||$.id==="public");if(S)try{const $=await e.client.request("config.get"),A=$.config,E=(A==null?void 0:A.agents)??{},T=Array.isArray(E.list)?[...E.list]:[],_=T.findIndex(ne=>ne.id===S.id),D=h==="off"?void 0:h;if(D)_>=0?T[_]={...T[_],thinkingLevel:D}:T.push({id:S.id,thinkingLevel:D});else if(_>=0){const{thinkingLevel:ne,...be}=T[_];Object.keys(be).length<=1?T.splice(_,1):T[_]=be}const F=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(F),baseHash:$.hash,note:`Public agent thinking → ${D||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Thinking change failed:",$)}},whatsappGroupPolicy:(()=>{var _,D;const h=(_=e.configSnapshot)==null?void 0:_.config,v=(D=h==null?void 0:h.channels)==null?void 0:D.whatsapp,S=ae(e),$=S==null?void 0:S.whatsappAccountId,A=(v==null?void 0:v.accounts)??{},E=$?A[$]:void 0;return(E==null?void 0:E.groupPolicy)??(v==null?void 0:v.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var D,F;const h=(D=e.configSnapshot)==null?void 0:D.config,v=(F=h==null?void 0:h.channels)==null?void 0:F.whatsapp,S=ae(e),$=S==null?void 0:S.whatsappAccountId,A=(v==null?void 0:v.accounts)??{},E=$?A[$]:void 0,_=((E==null?void 0:E.groups)??(v==null?void 0:v.groups)??{})["*"];return(_==null?void 0:_.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var S;const h=ae(e),v=h==null?void 0:h.whatsappAccountId;try{const $=await e.client.request("config.get"),A=$.config,E=((S=A==null?void 0:A.channels)==null?void 0:S.whatsapp)??{},T=E.accounts??{},_=v?T[v]:void 0,D=(_==null?void 0:_.groupPolicy)??E.groupPolicy??"allowlist",F=D==="disabled"||D==="allowlist",ne=F?"open":"disabled",be=F?{"*":{}}:void 0,Qe={groupPolicy:ne};be&&(Qe.groups=be);const ee=_?{channels:{whatsapp:{accounts:{[v]:Qe}}}}:{channels:{whatsapp:Qe}};await e.client.request("config.patch",{raw:JSON.stringify(ee),baseHash:$.hash,note:`WhatsApp groups → ${ne}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Group toggle failed:",$)}},onWhatsAppGroupMentionChange:async h=>{var $;const v=ae(e),S=v==null?void 0:v.whatsappAccountId;try{const A=await e.client.request("config.get"),E=A.config,_=((($=E==null?void 0:E.channels)==null?void 0:$.whatsapp)??{}).accounts??{},D=S?_[S]:void 0,F={"*":{requireMention:h}},ne=D?{channels:{whatsapp:{accounts:{[S]:{groups:F}}}}}:{channels:{whatsapp:{groups:F}}};await e.client.request("config.patch",{raw:JSON.stringify(ne),baseHash:A.hash,note:`WhatsApp group mention → ${h?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group mention change failed:",A)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:f.configured,imessageRunning:f.running,imessageConnected:f.connected,imessageLastError:f.lastError,imessageSelfChatMode:f.selfChatMode,imessageCliPath:f.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:b,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),v=h.config,S=(v==null?void 0:v.bindings)??[],$=ae(e),A=$==null?void 0:$.agents.find(F=>F.id.endsWith("-admin")||F.id==="admin"),E=(A==null?void 0:A.id)??"admin",T=S.filter(F=>{var ne;return((ne=F.match)==null?void 0:ne.channel)!=="imessage"}),_=[{agentId:E,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],D=[...T,..._];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:D}),baseHash:h.hash,note:"Enable iMessage (self-chat) for "+(($==null?void 0:$.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Y(e,!0),Be(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await Y(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),v=h.config,$=((v==null?void 0:v.bindings)??[]).filter(A=>{var E;return((E=A.match)==null?void 0:E.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:$}),baseHash:h.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Y(e,!0),Be(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const h=await e.client.request("config.get"),v=h.config,S=(v==null?void 0:v.bindings)??[],$=ae(e),A=$==null?void 0:$.agents.find(D=>D.id.endsWith("-admin")||D.id==="admin"),E=(A==null?void 0:A.id)??"admin",T=S.filter(D=>{var F;return((F=D.match)==null?void 0:F.channel)!=="imessage"}),_=[{agentId:E,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:[...T,..._]}),baseHash:h.hash,note:"Reassign iMessage to "+(($==null?void 0:$.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([Y(e,!0),Be(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:h=>{e.infoModalOpen=h},onInfoModalClose:()=>{e.infoModalOpen=null},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(h,v)=>{e.apiKeySavingProvider=h,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await cl(e.client,h,v);const S=`${h} key saved`;e.apiKeySuccess=S,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await pi(e.client)}catch{}h==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===S&&(e.apiKeySuccess=null)},2500)}catch(S){e.apiKeyError=S instanceof Error?S.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async h=>{e.apiKeySavingProvider=h,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await iw(e.client,h);const v=`${h} key removed`;e.apiKeySuccess=v,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await pi(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===v&&(e.apiKeySuccess=null)},2500)}catch(v){e.apiKeyError=v instanceof Error?v.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyDisable:async(h,v)=>{e.apiKeySavingProvider=h,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await sw(e.client,h,v);const S=`${h} ${v?"disabled":"enabled"}`;e.apiKeySuccess=S,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await pi(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===S&&(e.apiKeySuccess=null)},2500)}catch(S){e.apiKeyError=S instanceof Error?S.message:`Failed to ${v?"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:h=>{e.authApiKeyInput=h},onAuthApiKeySubmit:async()=>{const h=e.authApiKeyInput.trim();if(h){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await cl(e.client,"anthropic",h),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(v){e.authApiKeyError=v instanceof Error?v.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var v;const h=e.selectedWorkspace??((v=e.workspaces[0])==null?void 0:v.name);return h?e.accessState.accounts.some(S=>S.id===h):!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:(h,v)=>{var $;const S=e.selectedWorkspace??(($=e.workspaces[0])==null?void 0:$.name);S&&e.handleAccountPinSave(S,h,v)},publicChatEnabled:(()=>{var S;const h=(S=e.configSnapshot)==null?void 0:S.config,v=h==null?void 0:h.publicChat;return(v==null?void 0:v.enabled)===!0})(),publicChatAuthMode:(()=>{var $;const h=($=e.configSnapshot)==null?void 0:$.config,v=h==null?void 0:h.publicChat,S=v==null?void 0:v.auth;return S==="verified"||S==="choice"?S:"anonymous"})(),publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var h;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const v=await e.client.request("config.get"),S=v.config,$=((h=S==null?void 0:S.publicChat)==null?void 0:h.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!$}}),baseHash:v.hash,note:`Public chat → ${$?"disabled":"enabled"}`}),e.configSnapshot=await e.client.request("config.get")}catch(v){console.error("Public chat toggle failed:",v)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async h=>{if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const v=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{auth:h}}),baseHash:v.hash,note:`Public chat auth → ${h}`}),e.configSnapshot=await e.client.request("config.get")}catch(v){console.error("Public chat auth mode change failed:",v)}finally{e.publicChatToggleBusy=!1}}},brandAccentColor:(()=>{var S;const h=e.selectedWorkspace;return h?((S=Le()[h])==null?void 0:S.accentColor)??"":""})(),brandBackgroundColor:(()=>{var S;const h=e.selectedWorkspace;return h?((S=Le()[h])==null?void 0:S.backgroundColor)??"":""})(),brandHasLogo:(()=>{var S;const h=e.selectedWorkspace;return h?!!((S=Le()[h])!=null&&S.logoUrl):!1})(),brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async h=>{var S;const v=e.selectedWorkspace;if(!(!v||e.brandingBusy)){e.brandingBusy=!0;try{const $=await e.client.request("config.get"),A=$.config,E=((S=A==null?void 0:A.workspaces)==null?void 0:S[v])??{},T=E.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[v]:{...E,brand:{...T,accentColor:h}}}}),baseHash:$.hash,note:`Brand accent → ${h}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const _=Le();_[v]||(_[v]={}),_[v].accentColor=h,vn(v)}catch($){console.error("Brand accent change failed:",$)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async h=>{var S;const v=e.selectedWorkspace;if(!(!v||e.brandingBusy)){e.brandingBusy=!0;try{const $=await e.client.request("config.get"),A=$.config,E=((S=A==null?void 0:A.workspaces)==null?void 0:S[v])??{},T=E.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[v]:{...E,brand:{...T,backgroundColor:h}}}}),baseHash:$.hash,note:`Brand background → ${h}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const _=Le();_[v]||(_[v]={}),_[v].backgroundColor=h,vn(v)}catch($){console.error("Brand background change failed:",$)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async h=>{const v=e.selectedWorkspace;if(!(!v||e.brandingBusy)){e.brandingBusy=!0;try{const S=await h.arrayBuffer(),$=new Uint8Array(S);let A="";for(let _=0;_<$.length;_++)A+=String.fromCharCode($[_]);const E=btoa(A);await e.client.request("brand.uploadLogo",{workspace:v,data:E,mimeType:h.type});const T=Le();T[v]||(T[v]={}),T[v].logoUrl=`/brand-logo/${encodeURIComponent(v)}`}catch(S){console.error("Brand logo upload failed:",S)}finally{e.brandingBusy=!1}}},onBrandLogoRemove:async()=>{const h=e.selectedWorkspace;if(!(!h||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:h});const v=Le();v[h]&&delete v[h].logoUrl}catch(v){console.error("Brand logo remove failed:",v)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var v;const h=e.selectedWorkspace;if(!(!h||e.brandingBusy)){e.brandingBusy=!0;try{const S=await e.client.request("config.get"),$=S.config,A=((v=$==null?void 0:$.workspaces)==null?void 0:v[h])??{},{brand:E,...T}=A;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[h]:{...T,brand:null}}}),baseHash:S.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:h})}catch{}const _=Le();delete _[h],vn(h)}catch(S){console.error("Brand reset failed:",S)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null;try{const h=await e.client.request("tailscale.enable");if(h.authUrl){e.tailscaleAuthUrl=h.authUrl;const v=setInterval(async()=>{try{const S=await e.client.request("tailscale.status");e.tailscaleStatus=S,S.loggedIn&&(clearInterval(v),e.tailscaleAuthUrl=null,e.tailscaleBusy=!1)}catch{}},3e3);setTimeout(()=>{clearInterval(v),e.tailscaleBusy&&(e.tailscaleBusy=!1)},3e5)}else h.alreadyLoggedIn&&(e.tailscaleStatus=await e.client.request("tailscale.status")),e.tailscaleBusy=!1}catch(h){console.error("Tailscale enable failed:",h),e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var h;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable")}catch(v){console.error("Tailscale funnel enable failed:",v);const S=v;(h=S.payload)!=null&&h.enableUrl&&(e.tailscaleFunnelEnableUrl=S.payload.enableUrl),e.tailscaleError=S.message||"Failed to enable Funnel",e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable")}catch(h){console.error("Tailscale funnel disable failed:",h),e.tailscaleBusy=!1}}},wifiStatus:e.wifiStatus,wifiNetworks:e.wifiNetworks,wifiBusy:e.wifiBusy,wifiError:e.wifiError,wifiPassword:e.wifiPassword,wifiSelectedSsid:e.wifiSelectedSsid,onWifiScan:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[h,v]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);e.wifiNetworks=h.networks,e.wifiStatus=v}catch(h){console.error("WiFi scan failed:",h),e.wifiError=h.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{if(e.wifiBusy||!e.wifiSelectedSsid)return;const h=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const v=await e.client.request("wifi.connect",{ssid:h,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:v.connected,ssid:v.ssid,signal:null,ip:v.ip,savedSsid:v.ssid,autoconnect:!0},e.wifiBusy=!1;try{const S=await e.client.request("wifi.status");e.wifiStatus=S}catch{}}catch(v){console.error("WiFi connect failed:",v),e.wifiError=v.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 h=await e.client.request("wifi.status");e.wifiStatus=h}catch(h){console.error("WiFi disconnect failed:",h),e.wifiError=h.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 h=await e.client.request("wifi.status");e.wifiStatus=h}catch(h){console.error("WiFi forget failed:",h),e.wifiError=h.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:h=>{e.wifiSelectedSsid=h,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:h=>{e.wifiPassword=h},wsProps:_w(e)})}if(e.filesPage){const l=Lw(e);return Nf({connected:e.connected,wsProps:fn(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:()=>Qt(e,l),onReindex:()=>Jh(e,l),onSelectFile:p=>{e.filesPendingDeletePath=null,qh(e,p,l)},onToggleSelectFile:p=>Hh(e,p,l),onToggleDir:p=>Zh(e,p),onUpload:(p,f)=>Gh(e,p,f,l),onNewFolder:(p,f)=>Qh(e,p,f,l),onDownload:p=>Nc(e,p,l),onBulkDownload:()=>jh(e,l),onDelete:p=>{e.filesPendingDeletePath=null,Yh(e,p,l)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,f)=>Vh(e,p,f,l),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const f=e.filesSearchAgentId??l;ef(e,p,f)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{tf(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return Pf({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:()=>Qb(e),onStop:()=>Yb(e),onToggleInput:()=>Jb(e),onToggleFullscreen:()=>Zb(e),onCompleteHandoff:()=>Xb(e),onCanvasMouseDown:l=>{const f=l.target.getBoundingClientRect(),h=An().translateCoordinates(l.clientX-f.left,l.clientY-f.top);Ns(e,"mousePressed",h.x,h.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const f=l.target.getBoundingClientRect(),h=An().translateCoordinates(l.clientX-f.left,l.clientY-f.top);Ns(e,"mouseReleased",h.x,h.y)},onCanvasMouseMove:l=>{const p=An();if(p.shouldThrottleMouseMove())return;const b=l.target.getBoundingClientRect(),h=p.translateCoordinates(l.clientX-b.left,l.clientY-b.top);Ns(e,"mouseMoved",h.x,h.y)},onCanvasKeyDown:l=>{let p=0;l.altKey&&(p|=1),l.ctrlKey&&(p|=2),l.metaKey&&(p|=4),l.shiftKey&&(p|=8),Os(e,"keyDown",l.key,{code:l.code,modifiers:p||void 0}),l.key.length===1&&Os(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{Os(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=Mw(e),p=Pw(e);return eg({connected:e.connected,wsProps:fn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>Vi(e,l),onAdd:f=>{rd(e,f,l,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:f=>ad(e,f,l,p),onNewPhoneChange:f=>e.handleAdminsNewPhoneChange(f)})}if(e.contactsPage){const l=Iw(e);return rg({connected:e.connected,wsProps:fn(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:()=>xt(e,l),onAdd:(p,f)=>ld(e,p,f,l),onDelete:p=>cd(e,p,l),onSetField:(p,f,b)=>go(e,p,f,b,l),onDeleteField:(p,f)=>ud(e,p,f,l),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:()=>xt(e,l),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,f=e.contactsAddFieldKey.trim();!p||!f||(go(e,p,f,e.contactsAddFieldValue,l),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",p=yl(e),f=e.chatAvatarUrl??p??null,b=(()=>{var S;const h=(S=e.configSnapshot)==null?void 0:S.config,v=h==null?void 0:h.publicChat;return(v==null?void 0:v.enabled)===!0})();return Jv({connected:e.connected,wsProps:fn(e),publicChatEnabled:b,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:h=>{e.sessionKey=h,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestion=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:h,lastActiveSessionKey:h}),e.loadAssistantIdentity(),Re(e),Ys(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:h=>{const v=Math.max(e.chatMessages.length+10,De);Vn(e,e.sessionKey,{model:h}).then(()=>{Re(e,{limit:v})})},onThinkingLevelChange:h=>{const v=Math.max(e.chatMessages.length+10,De);Vn(e,e.sessionKey,{thinkingLevel:h==="off"?null:h}).then(()=>{Re(e,{limit:v})})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestion:e.chatSuggestion,onSuggestionClick:h=>{e.chatMessage=h,e.chatSuggestion=null,e.handleSendChat()},onVerboseChange:h=>{const v=Math.max(e.chatMessages.length+10,De);Vn(e,e.sessionKey,{verboseLevel:h==="off"?null:h}).then(()=>{Re(e,{limit:v})})},onFillerChange:h=>{const v=Math.max(e.chatMessages.length+10,De);Vn(e,e.sessionKey,{fillerEnabled:h}).then(()=>{Re(e,{limit:v})})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:f,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:l,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const h=Math.max(e.chatMessages.length+10,De);return Promise.all([Re(e,{limit:h}),Ys(e)])},onToggleFocusMode:()=>{},onChatScroll:h=>e.handleChatScroll(h),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:h=>e.chatMessage=h,requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:h=>e.chatAttachments=h,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:h=>e.removeQueuedMessage(h),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:h=>e.handleOpenSidebar(h),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:h=>e.handleSplitRatioChange(h),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?Bb({connected:e.connected,wsProps:fn(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&je(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?kn(e,{reset:!0}):Ft(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(o=e.channelsSnapshot)==null?void 0:o.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((a=e.channelsSnapshot)==null?void 0:a.channelOrder)??[],channelLabels:((u=e.channelsSnapshot)==null?void 0:u.channelLabels)??{},channelMeta:((c=e.channelsSnapshot)==null?void 0:c.channelMeta)??[],agentIds:(()=>{var p;const l=ae(e);return((p=l==null?void 0:l.agents)==null?void 0:p.map(f=>f.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:l=>{e.cronDetailJobId=l.id,Hs(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:l=>{e.cronForm=Qp(l),e.cronEditJobId=l.id,e.cronDetailJobId=null},onEditSave:()=>{const l=e.cronEditJobId;l&&Yp(e,l).then(()=>{e.cronEditJobId=null})},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{Hp(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,p)=>jp(e,l,p),onRun:l=>Vp(e,l),onRemove:l=>{e.cronPendingDeleteId=null,Gp(e,l)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:l=>{e.cronPendingDeleteId=l||null},onLoadRuns:l=>Hs(e,l)},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,detail:e.skillDetail,detailTab:e.skillDetailTab,addModal:e.skillAddModal,drafts:e.skillDrafts,onFilterChange:l=>e.skillsFilter=l,onRefresh:()=>je(e,{clearMessages:!0}),onToggle:(l,p)=>vc(e,l,p),onEdit:(l,p)=>yc(e,l,p),onSaveKey:l=>bc(e,l),onInstall:(l,p,f)=>wc(e,l,p,f),onViewDetail:l=>kc(e,l),onDetailClose:()=>Sc(e),onDetailTab:l=>$c(e,l),onAddOpen:()=>Ac(e),onAddClose:()=>xc(e),onImportDraft:l=>Ec(e,l),onDeleteDraft:l=>Tc(e,l),onAddSave:()=>Cc(e),onDelete:l=>Mc(e,l),onEditSkill:l=>_c(e,l)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?kn(e,{reset:!0}):Ft(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,expandedIds:e.sessionLogsExpandedIds,onFilterTextChange:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,p)=>{const f=e;f.sessionLogsTypeFilters={...f.sessionLogsTypeFilters,[l]:p}},onAgentToggle:(l,p)=>{const f=e;f.sessionLogsAgentFilters={...f.sessionLogsAgentFilters,[l]:p}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onToggleExpand:l=>{const p=e,f=new Set(p.sessionLogsExpandedIds);f.has(l)?f.delete(l):f.add(l),p.sessionLogsExpandedIds=f,p.requestUpdate()},onRefresh:()=>{kn(e,{reset:!0})},onExport:(l,p)=>e.exportSessionLogs(l,p),onScroll:l=>e.handleSessionLogsScroll(l)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,truncated:e.logsTruncated,onFilterTextChange:l=>e.logsFilterText=l,onLevelToggle:(l,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:p}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onRefresh:()=>Ft(e,{reset:!0}),onExport:(l,p)=>e.exportSessionLogs(l,p),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),d``)}function Uw(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 vl(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Ww(e,t,n){return d`
3943
3941
  <div class="audit-modal-overlay" @click=${s=>{s.target.classList.contains("audit-modal-overlay")&&n()}}>
3944
3942
  <div class="audit-modal-card">
3945
3943
  <div class="audit-modal-header">
@@ -3955,11 +3953,11 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3955
3953
  ${e.map(s=>d`
3956
3954
  <div class="audit-modal-entry">
3957
3955
  <div class="audit-modal-entry-path">
3958
- <span class="audit-modal-folder audit-modal-folder--${yl(s.path)}">${yl(s.path)}</span>
3956
+ <span class="audit-modal-folder audit-modal-folder--${vl(s.path)}">${vl(s.path)}</span>
3959
3957
  <a href="/files" class="audit-modal-path-link">${s.path}</a>
3960
3958
  </div>
3961
3959
  <div class="audit-modal-entry-meta">
3962
- ${Fw(s.timestamp)}
3960
+ ${Uw(s.timestamp)}
3963
3961
  <span class="audit-modal-agent">${s.agentId}</span>
3964
3962
  </div>
3965
3963
  </div>
@@ -3971,7 +3969,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3971
3969
  `}
3972
3970
  </div>
3973
3971
  </div>
3974
- `}const Ww={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Kw={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 zw(e){e.basePath=uf();const t=He();if(Tl(t.accentColor),_l(t.backgroundColor),window.scrollTo(0,0),nf(e),e.publicChat){const n=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,i=(n==null?void 0:n.accountId)??"",s=i?i.charAt(0).toUpperCase()+i.slice(1):"Assistant";document.title=`Chat with ${s}`,Pe(e);return}if(e.setup){document.title=`${t.name} Setup`,Pe(e);return}if(e.filesPage){document.title=`${t.name} Files`,of(e),Pe(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Pe(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Pe(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,Pe(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Pe(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Pe(e);return}ff(e,!0),df(e),pf(e),window.addEventListener("popstate",e.popStateHandler),af(e),Pe(e),ef(e),e.tab==="logs"&&(e.logsSubTab==="session"?Ro(e):Lo(e)),e.tab==="debug"&&Bo(e)}function qw(e){Fp(e)}function Hw(e){var t;window.removeEventListener("popstate",e.popStateHandler),tf(e),Io(e),Do(e),No(e),sf(e),rf(e),hf(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function jw(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;jt(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&zl(e,t.has("tab")||t.has("logsAutoFollow"))}}function Vw(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 Gw(e,t,n){await ko(e,t,n),await Y(e,!0)}async function Qw(e,t){await Gl(e,t),await Y(e,!0)}async function Yw(e,t){await Ql(e,t),await Y(e,!0)}async function Xw(e,t){await Yl(e,t)}async function Jw(e,t){await Xl(e,t)}async function Zw(e){await Kp(e),await Be(e),await Y(e,!0)}async function ek(e){await Be(e),await Y(e,!0)}function tk(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(),r=s.join(":").trim();o&&r&&(t[o]=r)}return t}function cd(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 ud(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function nk(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Vw(n??void 0)}function ik(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function sk(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function ok(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function rk(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=cd(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(ud(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:tk(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 Y(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function ak(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=cd(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(ud(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,r=o?{...t.values,...o}:t.values,a=!!(r.banner||r.website||r.nip05||r.lud16);e.nostrProfileFormState={...t,importing:!1,values:r,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:a},s.saved&&await Y(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function lk(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 ck(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 uk(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 dk(e,t){e.authCodeInput=t}function pk(e){e.setupStep="whatsapp"}async function hk(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 fk(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 gk(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 mk(e,t){e.licenseKey=t}async function yk(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 vk(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 bk=Object.defineProperty,wk=Object.getOwnPropertyDescriptor,m=(e,t,n,i)=>{for(var s=i>1?void 0:i?wk(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(s=(i?r(t,n,s):r(s))||s);return i&&s&&bk(t,n,s),s};const Us=Qd();function kk(){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 Sk(){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 $k(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function Ak(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function xk(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function Ek(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function Ck(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function Tk(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends Ot{constructor(){super(...arguments),this.settings=cs(),this.password="",this.tab="chat",this.onboarding=kk(),this.setup=Sk(),this.filesPage=$k(),this.browserPage=Ak(),this.adminsPage=xk(),this.contactsPage=Ek(),this.chatPage=Ck(),this.advancedPage=Tk(),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=ed,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=Us.name,this.assistantAvatar=Us.avatar,this.assistantAgentId=Us.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.chatSuggestion=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatModelProvider=null,this.chatModel=null,this.chatModelCatalog=[],this.chatVerboseLevel=null,this.chatFillerEnabled=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=`{
3972
+ `}const Kw={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},zw={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 qw(e){e.basePath=pf();const t=He();if(_l(t.accentColor),Ml(t.backgroundColor),window.scrollTo(0,0),of(e),e.publicChat){const n=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,i=(n==null?void 0:n.accountId)??"",s=i?i.charAt(0).toUpperCase()+i.slice(1):"Assistant";document.title=`Chat with ${s}`,Pe(e);return}if(e.setup){document.title=`${t.name} Setup`,Pe(e);return}if(e.filesPage){document.title=`${t.name} Files`,af(e),Pe(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Pe(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Pe(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,Pe(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Pe(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Pe(e);return}mf(e,!0),hf(e),ff(e),window.addEventListener("popstate",e.popStateHandler),cf(e),Pe(e),nf(e),e.tab==="logs"&&(e.logsSubTab==="session"?Do(e):Io(e)),e.tab==="debug"&&No(e)}function Hw(e){Wp(e)}function jw(e){var t;window.removeEventListener("popstate",e.popStateHandler),sf(e),Ro(e),Bo(e),Oo(e),rf(e),lf(e),gf(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function Vw(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;jt(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&ql(e,t.has("tab")||t.has("logsAutoFollow"))}}function Gw(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 Qw(e,t,n){await So(e,t,n),await Y(e,!0)}async function Yw(e,t){await Ql(e,t),await Y(e,!0)}async function Xw(e,t){await Yl(e,t),await Y(e,!0)}async function Jw(e,t){await Xl(e,t)}async function Zw(e,t){await Jl(e,t)}async function ek(e){await qp(e),await Be(e),await Y(e,!0)}async function tk(e){await Be(e),await Y(e,!0)}function nk(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(),r=s.join(":").trim();o&&r&&(t[o]=r)}return t}function dd(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 pd(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function ik(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Gw(n??void 0)}function sk(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function ok(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function rk(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function ak(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=dd(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(pd(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:nk(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 Y(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function lk(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=dd(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(pd(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,r=o?{...t.values,...o}:t.values,a=!!(r.banner||r.website||r.nip05||r.lud16);e.nostrProfileFormState={...t,importing:!1,values:r,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:a},s.saved&&await Y(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function ck(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 uk(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 dk(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 pk(e,t){e.authCodeInput=t}function hk(e){e.setupStep="whatsapp"}async function fk(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 gk(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 mk(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 yk(e,t){e.licenseKey=t}async function vk(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 bk(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 wk=Object.defineProperty,kk=Object.getOwnPropertyDescriptor,m=(e,t,n,i)=>{for(var s=i>1?void 0:i?kk(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(s=(i?r(t,n,s):r(s))||s);return i&&s&&wk(t,n,s),s};const Ws=Xd();function Sk(){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 $k(){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 Ak(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function xk(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function Ek(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function Ck(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function Tk(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function _k(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends Ot{constructor(){super(...arguments),this.settings=us(),this.password="",this.tab="chat",this.onboarding=Sk(),this.setup=$k(),this.filesPage=Ak(),this.browserPage=xk(),this.adminsPage=Ek(),this.contactsPage=Ck(),this.chatPage=Tk(),this.advancedPage=_k(),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=nd,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=Ws.name,this.assistantAvatar=Ws.avatar,this.assistantAgentId=Ws.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.chatSuggestion=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatModelProvider=null,this.chatModel=null,this.chatModelCatalog=[],this.chatVerboseLevel=null,this.chatFillerEnabled=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=`{
3975
3973
  }
3976
- `,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.brandingBusy=!1,this.brandingExpanded=!1,this.tailscaleStatus=null,this.tailscaleBusy=!1,this.tailscaleAuthUrl=null,this.tailscaleError=null,this.tailscaleFunnelEnableUrl=null,this.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,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={...Kw},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.cronEditJobId=null,this.cronPendingDeleteId=null,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.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillDetail=null,this.skillDetailTab="",this.skillAddModal=!1,this.skillAddForm={name:"",skillContent:"",references:[]},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.infoModalOpen=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={...Ww},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.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.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=()=>gf(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),zw(this)}firstUpdated(){qw(this)}disconnectedCallback(){this.stopEmbeddingPoll(),Hw(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){jw(this,e)}connect(){Pe(this)}handleChatScroll(e){Lp(this,e)}handleLogsScroll(e){Rp(this,e)}handleSessionLogsScroll(e){Dp(this,e)}exportLogs(e,t){Np(e,t)}exportSessionLogs(e,t){Op(e,t)}resetToolStream(){wo(this)}resetChatScroll(){Bp(this)}async loadAssistantIdentity(){await ho(this)}applySettings(e){tt(this,e)}setTab(e){lf(this,e)}setTheme(e,t){cf(this,e,t)}async loadOverview(){await Uc(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.cronForm={...this.cronForm,accountId:(e==null?void 0:e.whatsappAccountId)??void 0},await Oo(this)}async handleAbortChat(){await Kc(this)}removeQueuedMessage(e){bf(this,e)}async handleSendChat(e,t){await wf(this,e,t)}async handleWhatsAppStart(e,t){await Gw(this,e,t)}async handleWhatsAppWait(e){await Qw(this,e)}async handleWhatsAppLogout(e){await Yw(this,e)}async handleAddWhatsAppAccount(e){await Xw(this,e)}async handleRemoveWhatsAppAccount(e){await Jw(this,e)}async handleAccessCheck(){await gl(this)}async handlePinSubmit(e,t){await kw(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await Sw(this,e)}async handleLogout(){await Aw(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 gl(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 hk(this)}async handleLicenseActivate(){await fk(this)}async handleLicenseRemove(){await gk(this)}handleLicenseKeyChange(e){mk(this,e)}async handleAuthStatusCheck(){await lk(this)}async handleAuthStart(){await ck(this)}async handleAuthSubmitCode(e){await uk(this,e)}handleAuthCodeChange(e){dk(this,e)}handleSkipToWhatsApp(){pk(this)}async handleGatewayHealthCheck(){await yk(this)}async handleGatewayRestart(){await vk(this)}async handleUpdateCheck(){await Yu(this)}async handleUpdateRun(){await sw(this)}handleUpdateDismissResult(){aw(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 oe(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Xr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){oe(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Xr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await Rc(this)}async clearAudit(){await Wh(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,Qt(this,t),Po(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();oe(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>Ew);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.chatSuggestion=null,this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}oe(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>vi);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{jt(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=Ip(this),{loadOlderChatHistory:t}=await oe(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>vi);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.loadCron(),this.advancedTab==="logs"&&(this.logsSubTab==="session"?oe(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>Ic);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):oe(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>eh);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&oe(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>Rh);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await Zw(this)}async handleChannelConfigReload(){await ek(this)}handleNostrProfileEdit(e,t){nk(this,e,t)}handleNostrProfileCancel(){ik(this)}handleNostrProfileFieldChange(e,t){sk(this,e,t)}async handleNostrProfileSave(){await rk(this)}async handleNostrProfileImport(){await ak(this)}handleNostrProfileToggleAdvanced(){ok(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;oe(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>Cw);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 oe(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>oi);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await oe(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>oi);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await oe(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>Qp);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 oe(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>oi);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 oe(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>oi);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){this.selectedWorkspace=e,localStorage.setItem("taskmaster-selected-workspace",e),vn(e),Or(e),this.settings=cs(),this.chatMessage="",this.chatAttachments=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestion=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,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.advancedPage&&this.handleAdvancedLoad()}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)}vn(this.selectedWorkspace),Or(this.selectedWorkspace),this.settings=cs(),this.reloadCurrentPageData()}render(){return d`${Ow(this)}${this.auditModalOpen?Uw(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):k}`}};m([y()],g.prototype,"settings",2);m([y()],g.prototype,"password",2);m([y()],g.prototype,"tab",2);m([y()],g.prototype,"onboarding",2);m([y()],g.prototype,"setup",2);m([y()],g.prototype,"filesPage",2);m([y()],g.prototype,"browserPage",2);m([y()],g.prototype,"adminsPage",2);m([y()],g.prototype,"contactsPage",2);m([y()],g.prototype,"chatPage",2);m([y()],g.prototype,"advancedPage",2);m([y()],g.prototype,"advancedTab",2);m([y()],g.prototype,"publicChat",2);m([y()],g.prototype,"publicChatConfig",2);m([y()],g.prototype,"publicChatSessionKey",2);m([y()],g.prototype,"publicChatAuthenticated",2);m([y()],g.prototype,"publicChatAuthStep",2);m([y()],g.prototype,"connected",2);m([y()],g.prototype,"accessState",2);m([y()],g.prototype,"theme",2);m([y()],g.prototype,"themeResolved",2);m([y()],g.prototype,"hello",2);m([y()],g.prototype,"lastError",2);m([y()],g.prototype,"eventLog",2);m([y()],g.prototype,"assistantName",2);m([y()],g.prototype,"assistantAvatar",2);m([y()],g.prototype,"assistantAgentId",2);m([y()],g.prototype,"sessionKey",2);m([y()],g.prototype,"chatLoading",2);m([y()],g.prototype,"chatSending",2);m([y()],g.prototype,"chatMessage",2);m([y()],g.prototype,"chatMessages",2);m([y()],g.prototype,"chatHistoryTotal",2);m([y()],g.prototype,"chatHistoryHasMore",2);m([y()],g.prototype,"chatLoadingOlder",2);m([y()],g.prototype,"chatToolMessages",2);m([y()],g.prototype,"chatStream",2);m([y()],g.prototype,"chatInterimText",2);m([y()],g.prototype,"chatSuggestion",2);m([y()],g.prototype,"chatStreamStartedAt",2);m([y()],g.prototype,"chatRunId",2);m([y()],g.prototype,"compactionStatus",2);m([y()],g.prototype,"chatAvatarUrl",2);m([y()],g.prototype,"chatThinkingLevel",2);m([y()],g.prototype,"chatModelProvider",2);m([y()],g.prototype,"chatModel",2);m([y()],g.prototype,"chatModelCatalog",2);m([y()],g.prototype,"chatVerboseLevel",2);m([y()],g.prototype,"chatFillerEnabled",2);m([y()],g.prototype,"chatQueue",2);m([y()],g.prototype,"chatAttachments",2);m([y()],g.prototype,"sidebarOpen",2);m([y()],g.prototype,"sidebarContent",2);m([y()],g.prototype,"sidebarError",2);m([y()],g.prototype,"splitRatio",2);m([y()],g.prototype,"nodesLoading",2);m([y()],g.prototype,"nodes",2);m([y()],g.prototype,"devicesLoading",2);m([y()],g.prototype,"devicesError",2);m([y()],g.prototype,"devicesList",2);m([y()],g.prototype,"execApprovalsLoading",2);m([y()],g.prototype,"execApprovalsSaving",2);m([y()],g.prototype,"execApprovalsDirty",2);m([y()],g.prototype,"execApprovalsSnapshot",2);m([y()],g.prototype,"execApprovalsForm",2);m([y()],g.prototype,"execApprovalsSelectedAgent",2);m([y()],g.prototype,"execApprovalsTarget",2);m([y()],g.prototype,"execApprovalsTargetNodeId",2);m([y()],g.prototype,"execApprovalQueue",2);m([y()],g.prototype,"execApprovalBusy",2);m([y()],g.prototype,"execApprovalError",2);m([y()],g.prototype,"configLoading",2);m([y()],g.prototype,"configRaw",2);m([y()],g.prototype,"configRawOriginal",2);m([y()],g.prototype,"configValid",2);m([y()],g.prototype,"configIssues",2);m([y()],g.prototype,"configSaving",2);m([y()],g.prototype,"configApplying",2);m([y()],g.prototype,"updateRunning",2);m([y()],g.prototype,"applySessionKey",2);m([y()],g.prototype,"configSnapshot",2);m([y()],g.prototype,"configSchema",2);m([y()],g.prototype,"configSchemaVersion",2);m([y()],g.prototype,"configSchemaLoading",2);m([y()],g.prototype,"configUiHints",2);m([y()],g.prototype,"configForm",2);m([y()],g.prototype,"configFormOriginal",2);m([y()],g.prototype,"configFormDirty",2);m([y()],g.prototype,"configFormMode",2);m([y()],g.prototype,"configSearchQuery",2);m([y()],g.prototype,"configActiveSection",2);m([y()],g.prototype,"configActiveSubsection",2);m([y()],g.prototype,"channelsLoading",2);m([y()],g.prototype,"channelsSnapshot",2);m([y()],g.prototype,"channelsError",2);m([y()],g.prototype,"channelsLastSuccess",2);m([y()],g.prototype,"whatsappLoginMessage",2);m([y()],g.prototype,"whatsappLoginQrDataUrl",2);m([y()],g.prototype,"whatsappLoginConnected",2);m([y()],g.prototype,"whatsappBusy",2);m([y()],g.prototype,"whatsappActiveQrAccountId",2);m([y()],g.prototype,"whatsappPairedPhone",2);m([y()],g.prototype,"addingWhatsAppAccount",2);m([y()],g.prototype,"newWhatsAppAccountName",2);m([y()],g.prototype,"whatsappAccountError",2);m([y()],g.prototype,"whatsappAccountSaving",2);m([y()],g.prototype,"whatsappSettingsOpen",2);m([y()],g.prototype,"publicChatToggleBusy",2);m([y()],g.prototype,"brandingBusy",2);m([y()],g.prototype,"brandingExpanded",2);m([y()],g.prototype,"tailscaleStatus",2);m([y()],g.prototype,"tailscaleBusy",2);m([y()],g.prototype,"tailscaleAuthUrl",2);m([y()],g.prototype,"tailscaleError",2);m([y()],g.prototype,"tailscaleFunnelEnableUrl",2);m([y()],g.prototype,"wifiStatus",2);m([y()],g.prototype,"wifiNetworks",2);m([y()],g.prototype,"wifiBusy",2);m([y()],g.prototype,"wifiError",2);m([y()],g.prototype,"wifiPassword",2);m([y()],g.prototype,"wifiSelectedSsid",2);m([y()],g.prototype,"licenseKey",2);m([y()],g.prototype,"licenseBusy",2);m([y()],g.prototype,"licenseValid",2);m([y()],g.prototype,"licenseMessage",2);m([y()],g.prototype,"licenseTier",2);m([y()],g.prototype,"licenseDeviceId",2);m([y()],g.prototype,"licenseStoredKey",2);m([y()],g.prototype,"licenseRemoveConfirm",2);m([y()],g.prototype,"authConnected",2);m([y()],g.prototype,"authBusy",2);m([y()],g.prototype,"authMessage",2);m([y()],g.prototype,"authUrl",2);m([y()],g.prototype,"authCodeInput",2);m([y()],g.prototype,"authExpiresIn",2);m([y()],g.prototype,"setupStep",2);m([y()],g.prototype,"gatewayHealthy",2);m([y()],g.prototype,"gatewayHealthLoading",2);m([y()],g.prototype,"gatewayHealthMessage",2);m([y()],g.prototype,"gatewayRestartBusy",2);m([y()],g.prototype,"updateAvailable",2);m([y()],g.prototype,"currentVersion",2);m([y()],g.prototype,"latestVersion",2);m([y()],g.prototype,"updateChecking",2);m([y()],g.prototype,"updateMessage",2);m([y()],g.prototype,"updateProgressSteps",2);m([y()],g.prototype,"updateLastResult",2);m([y()],g.prototype,"uninstallConfirm",2);m([y()],g.prototype,"uninstallBusy",2);m([y()],g.prototype,"uninstallDone",2);m([y()],g.prototype,"uninstallError",2);m([y()],g.prototype,"uninstallConfirmText",2);m([y()],g.prototype,"nostrProfileFormState",2);m([y()],g.prototype,"nostrProfileAccountId",2);m([y()],g.prototype,"presenceLoading",2);m([y()],g.prototype,"presenceEntries",2);m([y()],g.prototype,"presenceError",2);m([y()],g.prototype,"presenceStatus",2);m([y()],g.prototype,"agentsLoading",2);m([y()],g.prototype,"agentsList",2);m([y()],g.prototype,"agentsError",2);m([y()],g.prototype,"sessionsLoading",2);m([y()],g.prototype,"sessionsResult",2);m([y()],g.prototype,"sessionsError",2);m([y()],g.prototype,"cronLoading",2);m([y()],g.prototype,"cronJobs",2);m([y()],g.prototype,"cronStatus",2);m([y()],g.prototype,"cronError",2);m([y()],g.prototype,"cronForm",2);m([y()],g.prototype,"cronRunsJobId",2);m([y()],g.prototype,"cronRuns",2);m([y()],g.prototype,"cronBusy",2);m([y()],g.prototype,"cronNewEventModal",2);m([y()],g.prototype,"cronDetailJobId",2);m([y()],g.prototype,"cronEditJobId",2);m([y()],g.prototype,"cronPendingDeleteId",2);m([y()],g.prototype,"browserScreencastActive",2);m([y()],g.prototype,"browserScreencastFrame",2);m([y()],g.prototype,"browserScreencastMetadata",2);m([y()],g.prototype,"browserHandoffPending",2);m([y()],g.prototype,"browserHandoffReason",2);m([y()],g.prototype,"browserHandoffId",2);m([y()],g.prototype,"browserInputMode",2);m([y()],g.prototype,"browserFullscreen",2);m([y()],g.prototype,"browserLoading",2);m([y()],g.prototype,"browserError",2);m([y()],g.prototype,"filesLoading",2);m([y()],g.prototype,"filesTree",2);m([y()],g.prototype,"filesRoot",2);m([y()],g.prototype,"filesError",2);m([y()],g.prototype,"filesSelectedPath",2);m([y()],g.prototype,"filesSelectedPaths",2);m([y()],g.prototype,"filesPreviewContent",2);m([y()],g.prototype,"filesPreviewLoading",2);m([y()],g.prototype,"filesPreviewBinary",2);m([y()],g.prototype,"filesPreviewSize",2);m([y()],g.prototype,"filesExpandedDirs",2);m([y()],g.prototype,"filesCurrentDir",2);m([y()],g.prototype,"filesPendingDeletePath",2);m([y()],g.prototype,"filesMessage",2);m([y()],g.prototype,"filesUploadBusy",2);m([y()],g.prototype,"filesReindexBusy",2);m([y()],g.prototype,"filesMemoryStatus",2);m([y()],g.prototype,"embeddingDownloading",2);m([y()],g.prototype,"filesSearchQuery",2);m([y()],g.prototype,"filesSearchResults",2);m([y()],g.prototype,"filesSearchLoading",2);m([y()],g.prototype,"filesSearchAgentId",2);m([y()],g.prototype,"auditEntries",2);m([y()],g.prototype,"auditLoading",2);m([y()],g.prototype,"auditModalOpen",2);m([y()],g.prototype,"skillsLoading",2);m([y()],g.prototype,"skillsReport",2);m([y()],g.prototype,"skillsError",2);m([y()],g.prototype,"skillsFilter",2);m([y()],g.prototype,"skillEdits",2);m([y()],g.prototype,"skillsBusyKey",2);m([y()],g.prototype,"skillMessages",2);m([y()],g.prototype,"skillDetail",2);m([y()],g.prototype,"skillDetailTab",2);m([y()],g.prototype,"skillAddModal",2);m([y()],g.prototype,"skillAddForm",2);m([y()],g.prototype,"skillDrafts",2);m([y()],g.prototype,"adminsLoading",2);m([y()],g.prototype,"adminPhones",2);m([y()],g.prototype,"adminsError",2);m([y()],g.prototype,"adminsSaving",2);m([y()],g.prototype,"adminsNewPhone",2);m([y()],g.prototype,"contactsLoading",2);m([y()],g.prototype,"contactsSaving",2);m([y()],g.prototype,"contactsRecords",2);m([y()],g.prototype,"contactsError",2);m([y()],g.prototype,"contactsSearchQuery",2);m([y()],g.prototype,"contactsEditingId",2);m([y()],g.prototype,"contactsShowAddForm",2);m([y()],g.prototype,"contactsNewPhone",2);m([y()],g.prototype,"contactsNewName",2);m([y()],g.prototype,"contactsDeleteConfirmId",2);m([y()],g.prototype,"contactsAddFieldForId",2);m([y()],g.prototype,"contactsAddFieldKey",2);m([y()],g.prototype,"contactsAddFieldValue",2);m([y()],g.prototype,"imessageEnableConfirm",2);m([y()],g.prototype,"imessageEnabling",2);m([y()],g.prototype,"infoModalOpen",2);m([y()],g.prototype,"workspaces",2);m([y()],g.prototype,"workspacesLoading",2);m([y()],g.prototype,"workspacesError",2);m([y()],g.prototype,"selectedWorkspace",2);m([y()],g.prototype,"addingWorkspace",2);m([y()],g.prototype,"newWorkspaceName",2);m([y()],g.prototype,"newWorkspacePath",2);m([y()],g.prototype,"newWorkspacePin",2);m([y()],g.prototype,"accountPinModalOpen",2);m([y()],g.prototype,"accountPinBusy",2);m([y()],g.prototype,"accountPinError",2);m([y()],g.prototype,"accountPinSuccess",2);m([y()],g.prototype,"apiKeyProviders",2);m([y()],g.prototype,"apiKeyModalOpen",2);m([y()],g.prototype,"apiKeyBusy",2);m([y()],g.prototype,"apiKeyError",2);m([y()],g.prototype,"apiKeySuccess",2);m([y()],g.prototype,"apiKeySavingProvider",2);m([y()],g.prototype,"authApiKeyMode",2);m([y()],g.prototype,"authApiKeyInput",2);m([y()],g.prototype,"authApiKeyBusy",2);m([y()],g.prototype,"authApiKeyError",2);m([y()],g.prototype,"pinChanging",2);m([y()],g.prototype,"pinChangeBusy",2);m([y()],g.prototype,"pinChangeError",2);m([y()],g.prototype,"loginChangePinMode",2);m([y()],g.prototype,"changePinBusy",2);m([y()],g.prototype,"changePinError",2);m([y()],g.prototype,"changePinSuccess",2);m([y()],g.prototype,"workspaceSaving",2);m([y()],g.prototype,"workspaceRemoveConfirm",2);m([y()],g.prototype,"renamingWorkspace",2);m([y()],g.prototype,"renameWorkspaceName",2);m([y()],g.prototype,"debugLoading",2);m([y()],g.prototype,"debugStatus",2);m([y()],g.prototype,"debugHealth",2);m([y()],g.prototype,"debugModels",2);m([y()],g.prototype,"debugHeartbeat",2);m([y()],g.prototype,"debugCallMethod",2);m([y()],g.prototype,"debugCallParams",2);m([y()],g.prototype,"debugCallResult",2);m([y()],g.prototype,"debugCallError",2);m([y()],g.prototype,"logsLoading",2);m([y()],g.prototype,"logsError",2);m([y()],g.prototype,"logsFile",2);m([y()],g.prototype,"logsEntries",2);m([y()],g.prototype,"logsFilterText",2);m([y()],g.prototype,"logsLevelFilters",2);m([y()],g.prototype,"logsAutoFollow",2);m([y()],g.prototype,"logsTruncated",2);m([y()],g.prototype,"logsCursor",2);m([y()],g.prototype,"logsLastFetchAt",2);m([y()],g.prototype,"logsLimit",2);m([y()],g.prototype,"logsMaxBytes",2);m([y()],g.prototype,"logsAtBottom",2);m([y()],g.prototype,"logsSubTab",2);m([y()],g.prototype,"sessionLogsLoading",2);m([y()],g.prototype,"sessionLogsError",2);m([y()],g.prototype,"sessionLogsEntries",2);m([y()],g.prototype,"sessionLogsFilterText",2);m([y()],g.prototype,"sessionLogsTypeFilters",2);m([y()],g.prototype,"sessionLogsAgentFilters",2);m([y()],g.prototype,"sessionLogsAgents",2);m([y()],g.prototype,"sessionLogsAutoFollow",2);m([y()],g.prototype,"sessionLogsCursors",2);m([y()],g.prototype,"sessionLogsLastFetchAt",2);m([y()],g.prototype,"sessionLogsAtBottom",2);m([y()],g.prototype,"chatUserNearBottom",2);g=m([El("taskmaster-app")],g);
3977
- //# sourceMappingURL=index-DQ1kxYd4.js.map
3974
+ `,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.brandingBusy=!1,this.brandingExpanded=!1,this.tailscaleStatus=null,this.tailscaleBusy=!1,this.tailscaleAuthUrl=null,this.tailscaleError=null,this.tailscaleFunnelEnableUrl=null,this.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,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={...zw},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.cronEditJobId=null,this.cronPendingDeleteId=null,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.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillDetail=null,this.skillDetailTab="",this.skillAddModal=!1,this.skillAddForm={name:"",skillContent:"",references:[]},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.infoModalOpen=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={...Kw},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.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.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}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),qw(this)}firstUpdated(){Hw(this)}disconnectedCallback(){this.stopEmbeddingPoll(),jw(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){Vw(this,e)}connect(){Pe(this)}handleChatScroll(e){Rp(this,e)}handleLogsScroll(e){Bp(this,e)}handleSessionLogsScroll(e){Np(this,e)}exportLogs(e,t){Fp(e,t)}exportSessionLogs(e,t){Up(e,t)}resetToolStream(){ko(this)}resetChatScroll(){Op(this)}async loadAssistantIdentity(){await fo(this)}applySettings(e){tt(this,e)}setTab(e){uf(this,e)}setTheme(e,t){df(this,e,t)}async loadOverview(){await Wc(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.cronForm={...this.cronForm,accountId:(e==null?void 0:e.whatsappAccountId)??void 0},await Fo(this)}async handleAbortChat(){await zc(this)}removeQueuedMessage(e){kf(this,e)}async handleSendChat(e,t){await Sf(this,e,t)}async handleWhatsAppStart(e,t){await Qw(this,e,t)}async handleWhatsAppWait(e){await Yw(this,e)}async handleWhatsAppLogout(e){await Xw(this,e)}async handleAddWhatsAppAccount(e){await Jw(this,e)}async handleRemoveWhatsAppAccount(e){await Zw(this,e)}async handleAccessCheck(){await ml(this)}async handlePinSubmit(e,t){await Sw(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await $w(this,e)}async handleLogout(){await xw(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 ml(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 fk(this)}async handleLicenseActivate(){await gk(this)}async handleLicenseRemove(){await mk(this)}handleLicenseKeyChange(e){yk(this,e)}async handleAuthStatusCheck(){await ck(this)}async handleAuthStart(){await uk(this)}async handleAuthSubmitCode(e){await dk(this,e)}handleAuthCodeChange(e){pk(this,e)}handleSkipToWhatsApp(){hk(this)}async handleGatewayHealthCheck(){await vk(this)}async handleGatewayRestart(){await bk(this)}async handleUpdateCheck(){await Ju(this)}async handleUpdateRun(){await ow(this)}handleUpdateDismissResult(){lw(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 oe(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Jr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){oe(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Jr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await Dc(this)}async clearAudit(){await zh(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,Qt(this,t),Lo(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();oe(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>Cw);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.chatSuggestion=null,this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}oe(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>vi);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{jt(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=Dp(this),{loadOlderChatHistory:t}=await oe(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>vi);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.loadCron(),this.advancedTab==="logs"&&(this.logsSubTab==="session"?oe(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>Rc);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):oe(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>nh);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&oe(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>Bh);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await ek(this)}async handleChannelConfigReload(){await tk(this)}handleNostrProfileEdit(e,t){ik(this,e,t)}handleNostrProfileCancel(){sk(this)}handleNostrProfileFieldChange(e,t){ok(this,e,t)}async handleNostrProfileSave(){await ak(this)}async handleNostrProfileImport(){await lk(this)}handleNostrProfileToggleAdvanced(){rk(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;oe(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>Tw);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 oe(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>oi);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await oe(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>oi);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await oe(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>Xp);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 oe(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>oi);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 oe(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>oi);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){this.selectedWorkspace=e,localStorage.setItem("taskmaster-selected-workspace",e),vn(e),Fr(e),this.settings=us(),this.chatMessage="",this.chatAttachments=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestion=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,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.advancedPage&&this.handleAdvancedLoad()}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)}vn(this.selectedWorkspace),Fr(this.selectedWorkspace),this.settings=us(),this.reloadCurrentPageData()}render(){return d`${Fw(this)}${this.auditModalOpen?Ww(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):k}`}};m([y()],g.prototype,"settings",2);m([y()],g.prototype,"password",2);m([y()],g.prototype,"tab",2);m([y()],g.prototype,"onboarding",2);m([y()],g.prototype,"setup",2);m([y()],g.prototype,"filesPage",2);m([y()],g.prototype,"browserPage",2);m([y()],g.prototype,"adminsPage",2);m([y()],g.prototype,"contactsPage",2);m([y()],g.prototype,"chatPage",2);m([y()],g.prototype,"advancedPage",2);m([y()],g.prototype,"advancedTab",2);m([y()],g.prototype,"publicChat",2);m([y()],g.prototype,"publicChatConfig",2);m([y()],g.prototype,"publicChatSessionKey",2);m([y()],g.prototype,"publicChatAuthenticated",2);m([y()],g.prototype,"publicChatAuthStep",2);m([y()],g.prototype,"connected",2);m([y()],g.prototype,"accessState",2);m([y()],g.prototype,"theme",2);m([y()],g.prototype,"themeResolved",2);m([y()],g.prototype,"hello",2);m([y()],g.prototype,"lastError",2);m([y()],g.prototype,"eventLog",2);m([y()],g.prototype,"assistantName",2);m([y()],g.prototype,"assistantAvatar",2);m([y()],g.prototype,"assistantAgentId",2);m([y()],g.prototype,"sessionKey",2);m([y()],g.prototype,"chatLoading",2);m([y()],g.prototype,"chatSending",2);m([y()],g.prototype,"chatMessage",2);m([y()],g.prototype,"chatMessages",2);m([y()],g.prototype,"chatHistoryTotal",2);m([y()],g.prototype,"chatHistoryHasMore",2);m([y()],g.prototype,"chatLoadingOlder",2);m([y()],g.prototype,"chatToolMessages",2);m([y()],g.prototype,"chatStream",2);m([y()],g.prototype,"chatInterimText",2);m([y()],g.prototype,"chatSuggestion",2);m([y()],g.prototype,"chatStreamStartedAt",2);m([y()],g.prototype,"chatRunId",2);m([y()],g.prototype,"compactionStatus",2);m([y()],g.prototype,"chatAvatarUrl",2);m([y()],g.prototype,"chatThinkingLevel",2);m([y()],g.prototype,"chatModelProvider",2);m([y()],g.prototype,"chatModel",2);m([y()],g.prototype,"chatModelCatalog",2);m([y()],g.prototype,"chatVerboseLevel",2);m([y()],g.prototype,"chatFillerEnabled",2);m([y()],g.prototype,"chatQueue",2);m([y()],g.prototype,"chatAttachments",2);m([y()],g.prototype,"sidebarOpen",2);m([y()],g.prototype,"sidebarContent",2);m([y()],g.prototype,"sidebarError",2);m([y()],g.prototype,"splitRatio",2);m([y()],g.prototype,"nodesLoading",2);m([y()],g.prototype,"nodes",2);m([y()],g.prototype,"devicesLoading",2);m([y()],g.prototype,"devicesError",2);m([y()],g.prototype,"devicesList",2);m([y()],g.prototype,"execApprovalsLoading",2);m([y()],g.prototype,"execApprovalsSaving",2);m([y()],g.prototype,"execApprovalsDirty",2);m([y()],g.prototype,"execApprovalsSnapshot",2);m([y()],g.prototype,"execApprovalsForm",2);m([y()],g.prototype,"execApprovalsSelectedAgent",2);m([y()],g.prototype,"execApprovalsTarget",2);m([y()],g.prototype,"execApprovalsTargetNodeId",2);m([y()],g.prototype,"execApprovalQueue",2);m([y()],g.prototype,"execApprovalBusy",2);m([y()],g.prototype,"execApprovalError",2);m([y()],g.prototype,"configLoading",2);m([y()],g.prototype,"configRaw",2);m([y()],g.prototype,"configRawOriginal",2);m([y()],g.prototype,"configValid",2);m([y()],g.prototype,"configIssues",2);m([y()],g.prototype,"configSaving",2);m([y()],g.prototype,"configApplying",2);m([y()],g.prototype,"updateRunning",2);m([y()],g.prototype,"applySessionKey",2);m([y()],g.prototype,"configSnapshot",2);m([y()],g.prototype,"configSchema",2);m([y()],g.prototype,"configSchemaVersion",2);m([y()],g.prototype,"configSchemaLoading",2);m([y()],g.prototype,"configUiHints",2);m([y()],g.prototype,"configForm",2);m([y()],g.prototype,"configFormOriginal",2);m([y()],g.prototype,"configFormDirty",2);m([y()],g.prototype,"configFormMode",2);m([y()],g.prototype,"configSearchQuery",2);m([y()],g.prototype,"configActiveSection",2);m([y()],g.prototype,"configActiveSubsection",2);m([y()],g.prototype,"channelsLoading",2);m([y()],g.prototype,"channelsSnapshot",2);m([y()],g.prototype,"channelsError",2);m([y()],g.prototype,"channelsLastSuccess",2);m([y()],g.prototype,"whatsappLoginMessage",2);m([y()],g.prototype,"whatsappLoginQrDataUrl",2);m([y()],g.prototype,"whatsappLoginConnected",2);m([y()],g.prototype,"whatsappBusy",2);m([y()],g.prototype,"whatsappActiveQrAccountId",2);m([y()],g.prototype,"whatsappPairedPhone",2);m([y()],g.prototype,"addingWhatsAppAccount",2);m([y()],g.prototype,"newWhatsAppAccountName",2);m([y()],g.prototype,"whatsappAccountError",2);m([y()],g.prototype,"whatsappAccountSaving",2);m([y()],g.prototype,"whatsappSettingsOpen",2);m([y()],g.prototype,"publicChatToggleBusy",2);m([y()],g.prototype,"brandingBusy",2);m([y()],g.prototype,"brandingExpanded",2);m([y()],g.prototype,"tailscaleStatus",2);m([y()],g.prototype,"tailscaleBusy",2);m([y()],g.prototype,"tailscaleAuthUrl",2);m([y()],g.prototype,"tailscaleError",2);m([y()],g.prototype,"tailscaleFunnelEnableUrl",2);m([y()],g.prototype,"wifiStatus",2);m([y()],g.prototype,"wifiNetworks",2);m([y()],g.prototype,"wifiBusy",2);m([y()],g.prototype,"wifiError",2);m([y()],g.prototype,"wifiPassword",2);m([y()],g.prototype,"wifiSelectedSsid",2);m([y()],g.prototype,"licenseKey",2);m([y()],g.prototype,"licenseBusy",2);m([y()],g.prototype,"licenseValid",2);m([y()],g.prototype,"licenseMessage",2);m([y()],g.prototype,"licenseTier",2);m([y()],g.prototype,"licenseDeviceId",2);m([y()],g.prototype,"licenseStoredKey",2);m([y()],g.prototype,"licenseRemoveConfirm",2);m([y()],g.prototype,"authConnected",2);m([y()],g.prototype,"authBusy",2);m([y()],g.prototype,"authMessage",2);m([y()],g.prototype,"authUrl",2);m([y()],g.prototype,"authCodeInput",2);m([y()],g.prototype,"authExpiresIn",2);m([y()],g.prototype,"setupStep",2);m([y()],g.prototype,"gatewayHealthy",2);m([y()],g.prototype,"gatewayHealthLoading",2);m([y()],g.prototype,"gatewayHealthMessage",2);m([y()],g.prototype,"gatewayRestartBusy",2);m([y()],g.prototype,"updateAvailable",2);m([y()],g.prototype,"currentVersion",2);m([y()],g.prototype,"latestVersion",2);m([y()],g.prototype,"updateChecking",2);m([y()],g.prototype,"updateMessage",2);m([y()],g.prototype,"updateProgressSteps",2);m([y()],g.prototype,"updateLastResult",2);m([y()],g.prototype,"uninstallConfirm",2);m([y()],g.prototype,"uninstallBusy",2);m([y()],g.prototype,"uninstallDone",2);m([y()],g.prototype,"uninstallError",2);m([y()],g.prototype,"uninstallConfirmText",2);m([y()],g.prototype,"nostrProfileFormState",2);m([y()],g.prototype,"nostrProfileAccountId",2);m([y()],g.prototype,"presenceLoading",2);m([y()],g.prototype,"presenceEntries",2);m([y()],g.prototype,"presenceError",2);m([y()],g.prototype,"presenceStatus",2);m([y()],g.prototype,"agentsLoading",2);m([y()],g.prototype,"agentsList",2);m([y()],g.prototype,"agentsError",2);m([y()],g.prototype,"sessionsLoading",2);m([y()],g.prototype,"sessionsResult",2);m([y()],g.prototype,"sessionsError",2);m([y()],g.prototype,"cronLoading",2);m([y()],g.prototype,"cronJobs",2);m([y()],g.prototype,"cronStatus",2);m([y()],g.prototype,"cronError",2);m([y()],g.prototype,"cronForm",2);m([y()],g.prototype,"cronRunsJobId",2);m([y()],g.prototype,"cronRuns",2);m([y()],g.prototype,"cronBusy",2);m([y()],g.prototype,"cronNewEventModal",2);m([y()],g.prototype,"cronDetailJobId",2);m([y()],g.prototype,"cronEditJobId",2);m([y()],g.prototype,"cronPendingDeleteId",2);m([y()],g.prototype,"browserScreencastActive",2);m([y()],g.prototype,"browserScreencastFrame",2);m([y()],g.prototype,"browserScreencastMetadata",2);m([y()],g.prototype,"browserHandoffPending",2);m([y()],g.prototype,"browserHandoffReason",2);m([y()],g.prototype,"browserHandoffId",2);m([y()],g.prototype,"browserInputMode",2);m([y()],g.prototype,"browserFullscreen",2);m([y()],g.prototype,"browserLoading",2);m([y()],g.prototype,"browserError",2);m([y()],g.prototype,"filesLoading",2);m([y()],g.prototype,"filesTree",2);m([y()],g.prototype,"filesRoot",2);m([y()],g.prototype,"filesError",2);m([y()],g.prototype,"filesSelectedPath",2);m([y()],g.prototype,"filesSelectedPaths",2);m([y()],g.prototype,"filesPreviewContent",2);m([y()],g.prototype,"filesPreviewLoading",2);m([y()],g.prototype,"filesPreviewBinary",2);m([y()],g.prototype,"filesPreviewSize",2);m([y()],g.prototype,"filesExpandedDirs",2);m([y()],g.prototype,"filesCurrentDir",2);m([y()],g.prototype,"filesPendingDeletePath",2);m([y()],g.prototype,"filesMessage",2);m([y()],g.prototype,"filesUploadBusy",2);m([y()],g.prototype,"filesReindexBusy",2);m([y()],g.prototype,"filesMemoryStatus",2);m([y()],g.prototype,"embeddingDownloading",2);m([y()],g.prototype,"filesSearchQuery",2);m([y()],g.prototype,"filesSearchResults",2);m([y()],g.prototype,"filesSearchLoading",2);m([y()],g.prototype,"filesSearchAgentId",2);m([y()],g.prototype,"auditEntries",2);m([y()],g.prototype,"auditLoading",2);m([y()],g.prototype,"auditModalOpen",2);m([y()],g.prototype,"skillsLoading",2);m([y()],g.prototype,"skillsReport",2);m([y()],g.prototype,"skillsError",2);m([y()],g.prototype,"skillsFilter",2);m([y()],g.prototype,"skillEdits",2);m([y()],g.prototype,"skillsBusyKey",2);m([y()],g.prototype,"skillMessages",2);m([y()],g.prototype,"skillDetail",2);m([y()],g.prototype,"skillDetailTab",2);m([y()],g.prototype,"skillAddModal",2);m([y()],g.prototype,"skillAddForm",2);m([y()],g.prototype,"skillDrafts",2);m([y()],g.prototype,"adminsLoading",2);m([y()],g.prototype,"adminPhones",2);m([y()],g.prototype,"adminsError",2);m([y()],g.prototype,"adminsSaving",2);m([y()],g.prototype,"adminsNewPhone",2);m([y()],g.prototype,"contactsLoading",2);m([y()],g.prototype,"contactsSaving",2);m([y()],g.prototype,"contactsRecords",2);m([y()],g.prototype,"contactsError",2);m([y()],g.prototype,"contactsSearchQuery",2);m([y()],g.prototype,"contactsEditingId",2);m([y()],g.prototype,"contactsShowAddForm",2);m([y()],g.prototype,"contactsNewPhone",2);m([y()],g.prototype,"contactsNewName",2);m([y()],g.prototype,"contactsDeleteConfirmId",2);m([y()],g.prototype,"contactsAddFieldForId",2);m([y()],g.prototype,"contactsAddFieldKey",2);m([y()],g.prototype,"contactsAddFieldValue",2);m([y()],g.prototype,"imessageEnableConfirm",2);m([y()],g.prototype,"imessageEnabling",2);m([y()],g.prototype,"infoModalOpen",2);m([y()],g.prototype,"workspaces",2);m([y()],g.prototype,"workspacesLoading",2);m([y()],g.prototype,"workspacesError",2);m([y()],g.prototype,"selectedWorkspace",2);m([y()],g.prototype,"addingWorkspace",2);m([y()],g.prototype,"newWorkspaceName",2);m([y()],g.prototype,"newWorkspacePath",2);m([y()],g.prototype,"newWorkspacePin",2);m([y()],g.prototype,"accountPinModalOpen",2);m([y()],g.prototype,"accountPinBusy",2);m([y()],g.prototype,"accountPinError",2);m([y()],g.prototype,"accountPinSuccess",2);m([y()],g.prototype,"apiKeyProviders",2);m([y()],g.prototype,"apiKeyModalOpen",2);m([y()],g.prototype,"apiKeyBusy",2);m([y()],g.prototype,"apiKeyError",2);m([y()],g.prototype,"apiKeySuccess",2);m([y()],g.prototype,"apiKeySavingProvider",2);m([y()],g.prototype,"authApiKeyMode",2);m([y()],g.prototype,"authApiKeyInput",2);m([y()],g.prototype,"authApiKeyBusy",2);m([y()],g.prototype,"authApiKeyError",2);m([y()],g.prototype,"pinChanging",2);m([y()],g.prototype,"pinChangeBusy",2);m([y()],g.prototype,"pinChangeError",2);m([y()],g.prototype,"loginChangePinMode",2);m([y()],g.prototype,"changePinBusy",2);m([y()],g.prototype,"changePinError",2);m([y()],g.prototype,"changePinSuccess",2);m([y()],g.prototype,"workspaceSaving",2);m([y()],g.prototype,"workspaceRemoveConfirm",2);m([y()],g.prototype,"renamingWorkspace",2);m([y()],g.prototype,"renameWorkspaceName",2);m([y()],g.prototype,"debugLoading",2);m([y()],g.prototype,"debugStatus",2);m([y()],g.prototype,"debugHealth",2);m([y()],g.prototype,"debugModels",2);m([y()],g.prototype,"debugHeartbeat",2);m([y()],g.prototype,"debugCallMethod",2);m([y()],g.prototype,"debugCallParams",2);m([y()],g.prototype,"debugCallResult",2);m([y()],g.prototype,"debugCallError",2);m([y()],g.prototype,"logsLoading",2);m([y()],g.prototype,"logsError",2);m([y()],g.prototype,"logsFile",2);m([y()],g.prototype,"logsEntries",2);m([y()],g.prototype,"logsFilterText",2);m([y()],g.prototype,"logsLevelFilters",2);m([y()],g.prototype,"logsAutoFollow",2);m([y()],g.prototype,"logsTruncated",2);m([y()],g.prototype,"logsCursor",2);m([y()],g.prototype,"logsLastFetchAt",2);m([y()],g.prototype,"logsLimit",2);m([y()],g.prototype,"logsMaxBytes",2);m([y()],g.prototype,"logsAtBottom",2);m([y()],g.prototype,"logsSubTab",2);m([y()],g.prototype,"sessionLogsLoading",2);m([y()],g.prototype,"sessionLogsError",2);m([y()],g.prototype,"sessionLogsEntries",2);m([y()],g.prototype,"sessionLogsFilterText",2);m([y()],g.prototype,"sessionLogsTypeFilters",2);m([y()],g.prototype,"sessionLogsAgentFilters",2);m([y()],g.prototype,"sessionLogsAgents",2);m([y()],g.prototype,"sessionLogsAutoFollow",2);m([y()],g.prototype,"sessionLogsCursors",2);m([y()],g.prototype,"sessionLogsLastFetchAt",2);m([y()],g.prototype,"sessionLogsAtBottom",2);m([y()],g.prototype,"chatUserNearBottom",2);g=m([Cl("taskmaster-app")],g);
3975
+ //# sourceMappingURL=index-BDETQp97.js.map