@rubytech/taskmaster 1.0.70 → 1.0.72

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
1
  var Mu=Object.defineProperty;var Pu=(e,t,n)=>t in e?Mu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var U=(e,t,n)=>Pu(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 r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=n(s);fetch(s.href,r)}})();const Lu="modulepreload",Iu=function(e,t){return new URL(e,t).href},ao={},ie=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let u=function(l){return Promise.all(l.map(d=>Promise.resolve(d).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};const o=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),c=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=u(n.map(l=>{if(l=Iu(l,i),l in ao)return;ao[l]=!0;const d=l.endsWith(".css"),h=d?'[rel="stylesheet"]':"";if(i)for(let y=o.length-1;y>=0;y--){const b=o[y];if(b.href===l&&(!d||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${h}`))return;const v=document.createElement("link");if(v.rel=d?"stylesheet":Lu,d||(v.as="script"),v.crossOrigin="",v.href=l,c&&v.setAttribute("nonce",c),document.head.appendChild(v),d)return new Promise((y,b)=>{v.addEventListener("load",y),v.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return t().catch(r)})};const qn=globalThis,Xs=qn.ShadowRoot&&(qn.ShadyCSS===void 0||qn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Zs=Symbol(),lo=new WeakMap;let Ja=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==Zs)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(Xs&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=lo.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&lo.set(n,t))}return t}toString(){return this.cssText}};const Ru=e=>new Ja(typeof e=="string"?e:e+"",void 0,Zs),Nu=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((i,s,r)=>i+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[r+1],e[0]);return new Ja(n,e,Zs)},Du=(e,t)=>{if(Xs)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=qn.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},co=Xs?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return Ru(n)})(e):e;const{is:Ou,defineProperty:Bu,getOwnPropertyDescriptor:Fu,getOwnPropertyNames:Uu,getOwnPropertySymbols:Wu,getPrototypeOf:Ku}=Object,Ke=globalThis,uo=Ke.trustedTypes,zu=uo?uo.emptyScript:"",Ki=Ke.reactiveElementPolyfillSupport,en=(e,t)=>e,Xn={toAttribute(e,t){switch(t){case Boolean:e=e?zu: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}},Js=(e,t)=>!Ou(e,t),po={attribute:!0,type:String,converter:Xn,reflect:!1,useDefault:!1,hasChanged:Js};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Ke.litPropertyMetadata??(Ke.litPropertyMetadata=new WeakMap);let St=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=po){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&&Bu(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:r}=Fu(this.prototype,t)??{get(){return this[n]},set(o){this[n]=o}};return{get:s,set(o){const a=s==null?void 0:s.call(this);r==null||r.call(this,o),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??po}static _$Ei(){if(this.hasOwnProperty(en("elementProperties")))return;const t=Ku(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(en("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(en("properties"))){const n=this.properties,i=[...Uu(n),...Wu(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(co(s))}else t!==void 0&&n.push(co(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 Du(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 r;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const o=(((r=i.converter)==null?void 0:r.toAttribute)!==void 0?i.converter:Xn).toAttribute(n,i.type);this._$Em=t,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(t,n){var r,o;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const a=i.getPropertyOptions(s),c=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)==null?void 0:r.fromAttribute)!==void 0?a.converter:Xn;this._$Em=s;const u=c.fromAttribute(n,a.type);this[s]=u??((o=this._$Ej)==null?void 0:o.get(s))??u,this._$Em=null}}requestUpdate(t,n,i,s=!1,r){var o;if(t!==void 0){const a=this.constructor;if(s===!1&&(r=this[t]),i??(i=a.getPropertyOptions(t)),!((i.hasChanged??Js)(r,n)||i.useDefault&&i.reflect&&r===((o=this._$Ej)==null?void 0:o.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:r},o){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,o??n??this[t]),r!==!0||o!==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[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,o]of s){const{wrapped:a}=o,c=this[r];a!==!0||this._$AL.has(r)||c===void 0||this.C(r,void 0,o,c)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),(i=this._$EO)==null||i.forEach(s=>{var r;return(r=s.hostUpdate)==null?void 0:r.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){}};St.elementStyles=[],St.shadowRootOptions={mode:"open"},St[en("elementProperties")]=new Map,St[en("finalized")]=new Map,Ki==null||Ki({ReactiveElement:St}),(Ke.reactiveElementVersions??(Ke.reactiveElementVersions=[])).push("2.1.2");const tn=globalThis,ho=e=>e,Zn=tn.trustedTypes,fo=Zn?Zn.createPolicy("lit-html",{createHTML:e=>e}):void 0,el="$lit$",We=`lit$${Math.random().toFixed(9).slice(2)}$`,tl="?"+We,ju=`<${tl}>`,it=document,un=()=>it.createComment(""),dn=e=>e===null||typeof e!="object"&&typeof e!="function",er=Array.isArray,Hu=e=>er(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",zi=`[
2
2
  \f\r]`,Ut=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,go=/-->/g,mo=/>/g,Xe=RegExp(`>|${zi}(?:([^\\s"'>=/]+)(${zi}*=${zi}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),yo=/'/g,vo=/"/g,nl=/^(?:script|style|textarea|title)$/i,qu=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),p=qu(1),je=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),bo=new WeakMap,et=it.createTreeWalker(it,129);function il(e,t){if(!er(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return fo!==void 0?fo.createHTML(t):t}const Vu=(e,t)=>{const n=e.length-1,i=[];let s,r=t===2?"<svg>":t===3?"<math>":"",o=Ut;for(let a=0;a<n;a++){const c=e[a];let u,l,d=-1,h=0;for(;h<c.length&&(o.lastIndex=h,l=o.exec(c),l!==null);)h=o.lastIndex,o===Ut?l[1]==="!--"?o=go:l[1]!==void 0?o=mo:l[2]!==void 0?(nl.test(l[2])&&(s=RegExp("</"+l[2],"g")),o=Xe):l[3]!==void 0&&(o=Xe):o===Xe?l[0]===">"?(o=s??Ut,d=-1):l[1]===void 0?d=-2:(d=o.lastIndex-l[2].length,u=l[1],o=l[3]===void 0?Xe:l[3]==='"'?vo:yo):o===vo||o===yo?o=Xe:o===go||o===mo?o=Ut:(o=Xe,s=void 0);const v=o===Xe&&e[a+1].startsWith("/>")?" ":"";r+=o===Ut?c+ju:d>=0?(i.push(u),c.slice(0,d)+el+c.slice(d)+We+v):c+We+(d===-2?a:v)}return[il(e,r+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let As=class sl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let r=0,o=0;const a=t.length-1,c=this.parts,[u,l]=Vu(t,n);if(this.el=sl.createElement(u,i),et.currentNode=this.el.content,n===2||n===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=et.nextNode())!==null&&c.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith(el)){const h=l[o++],v=s.getAttribute(d).split(We),y=/([.?@])?(.*)/.exec(h);c.push({type:1,index:r,name:y[2],strings:v,ctor:y[1]==="."?Qu:y[1]==="?"?Yu:y[1]==="@"?Xu:vi}),s.removeAttribute(d)}else d.startsWith(We)&&(c.push({type:6,index:r}),s.removeAttribute(d));if(nl.test(s.tagName)){const d=s.textContent.split(We),h=d.length-1;if(h>0){s.textContent=Zn?Zn.emptyScript:"";for(let v=0;v<h;v++)s.append(d[v],un()),et.nextNode(),c.push({type:2,index:++r});s.append(d[h],un())}}}else if(s.nodeType===8)if(s.data===tl)c.push({type:2,index:r});else{let d=-1;for(;(d=s.data.indexOf(We,d+1))!==-1;)c.push({type:7,index:r}),d+=We.length-1}r++}}static createElement(t,n){const i=it.createElement("template");return i.innerHTML=t,i}};function Tt(e,t,n=e,i){var o,a;if(t===je)return t;let s=i!==void 0?(o=n._$Co)==null?void 0:o[i]:n._$Cl;const r=dn(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),r===void 0?s=void 0:(s=new r(e),s._$AT(e,n,i)),i!==void 0?(n._$Co??(n._$Co=[]))[i]=s:n._$Cl=s),s!==void 0&&(t=Tt(e,s._$AS(e,t.values),s,i)),t}class Gu{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)??it).importNode(n,!0);et.currentNode=s;let r=et.nextNode(),o=0,a=0,c=i[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new yi(r,r.nextSibling,this,t):c.type===1?u=new c.ctor(r,c.name,c.strings,this,t):c.type===6&&(u=new Zu(r,this,t)),this._$AV.push(u),c=i[++a]}o!==(c==null?void 0:c.index)&&(r=et.nextNode(),o++)}return et.currentNode=it,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 yi=class rl{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=Tt(this,t,n),dn(t)?t===k||t==null||t===""?(this._$AH!==k&&this._$AR(),this._$AH=k):t!==this._$AH&&t!==je&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Hu(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&&dn(this._$AH)?this._$AA.nextSibling.data=t:this.T(it.createTextNode(t)),this._$AH=t}$(t){var r;const{values:n,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=As.createElement(il(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(n);else{const o=new Gu(s,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(t){let n=bo.get(t.strings);return n===void 0&&bo.set(t.strings,n=new As(t)),n}k(t){er(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let i,s=0;for(const r of t)s===n.length?n.push(i=new rl(this.O(un()),this.O(un()),this,this.options)):i=n[s],i._$AI(r),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=ho(t).nextSibling;ho(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class vi{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,r){this.type=1,this._$AH=k,this._$AN=void 0,this.element=t,this.name=n,this._$AM=s,this.options=r,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 r=this.strings;let o=!1;if(r===void 0)t=Tt(this,t,n,0),o=!dn(t)||t!==this._$AH&&t!==je,o&&(this._$AH=t);else{const a=t;let c,u;for(t=r[0],c=0;c<r.length-1;c++)u=Tt(this,a[i+c],n,c),u===je&&(u=this._$AH[c]),o||(o=!dn(u)||u!==this._$AH[c]),u===k?t=k:t!==k&&(t+=(u??"")+r[c+1]),this._$AH[c]=u}o&&!s&&this.j(t)}j(t){t===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let Qu=class extends vi{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===k?void 0:t}},Yu=class extends vi{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==k)}},Xu=class extends vi{constructor(t,n,i,s,r){super(t,n,i,s,r),this.type=5}_$AI(t,n=this){if((t=Tt(this,t,n,0)??k)===je)return;const i=this._$AH,s=t===k&&i!==k||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==k&&(i===k||s);s&&this.element.removeEventListener(this.name,this,i),r&&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)}},Zu=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){Tt(this,t)}};const Ju={I:yi},ji=tn.litHtmlPolyfillSupport;ji==null||ji(As,yi),(tn.litHtmlVersions??(tn.litHtmlVersions=[])).push("3.3.2");const ed=(e,t,n)=>{const i=(n==null?void 0:n.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const r=(n==null?void 0:n.renderBefore)??null;i._$litPart$=s=new yi(t.insertBefore(un(),r),r,void 0,n??{})}return s._$AI(e),s};const nt=globalThis;let $t=class extends St{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=ed(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 je}};var Za;$t._$litElement$=!0,$t.finalized=!0,(Za=nt.litElementHydrateSupport)==null||Za.call(nt,{LitElement:$t});const Hi=nt.litElementPolyfillSupport;Hi==null||Hi({LitElement:$t});(nt.litElementVersions??(nt.litElementVersions=[])).push("4.2.2");const ol=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const td={attribute:!0,type:String,converter:Xn,reflect:!1,hasChanged:Js},nd=(e=td,t,n)=>{const{kind:i,metadata:s}=n;let r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),r.set(n.name,e),i==="accessor"){const{name:o}=n;return{set(a){const c=t.get.call(this);t.set.call(this,a),this.requestUpdate(o,c,e,!0,a)},init(a){return a!==void 0&&this.C(o,void 0,e,a),a}}}if(i==="setter"){const{name:o}=n;return function(a){const c=this[o];t.call(this,a),this.requestUpdate(o,c,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function bi(e){return(t,n)=>typeof n=="object"?nd(e,t,n):((i,s,r)=>{const o=s.hasOwnProperty(r);return s.constructor.createProperty(r,i),o?Object.getOwnPropertyDescriptor(s,r):void 0})(e,t,n)}function m(e){return bi({...e,state:!0,attribute:!1})}const id=50,sd=200,rd="Assistant";function wo(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function xs(e){const t=wo(e==null?void 0:e.name,id)??rd,n=wo((e==null?void 0:e.avatar)??void 0,sd)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function al(){return xs(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Jn="taskmaster.control.settings.v1",ll="taskmaster.account.settings.";function nn(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const kt={gatewayUrl:nn(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},Ue={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function od(){try{const e=localStorage.getItem(Jn);if(!e)return{...kt,gatewayUrl:nn()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():nn(),token:typeof t.token=="string"?t.token:kt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:kt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:kt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:kt.navGroupsCollapsed}}catch{return{...kt,gatewayUrl:nn()}}}function ad(e){if(!e)return{...Ue};try{const t=localStorage.getItem(ll+e);if(!t)return{...Ue};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():Ue.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||Ue.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:Ue.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:Ue.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:Ue.splitRatio}}catch{return{...Ue}}}let ei=null;function ko(e){ei=e}function qi(){return{...od(),...ad(ei)}}function ld(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Jn,JSON.stringify(t)),ei){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(ll+ei,JSON.stringify(n))}}(function(){try{const t=localStorage.getItem(Jn);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:nn(),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(Jn,JSON.stringify(i))}catch{}})();function cl(e){var r;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=(r=n[1])==null?void 0:r.trim(),s=n.slice(2).join(":");return!i||!s?null:{agentId:i,rest:s}}const cd=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Pn=/<\s*\/?\s*final\b[^>]*>/gi,So=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function ud(e,t){return e.trimStart()}function dd(e,t){if(!e||!cd.test(e))return e;let n=e;Pn.test(n)?(Pn.lastIndex=0,n=n.replace(Pn,"")):Pn.lastIndex=0,So.lastIndex=0;let i="",s=0,r=!1;for(const o of n.matchAll(So)){const a=o.index??0,c=o[1]==="/";r?c&&(r=!1):(i+=n.slice(s,a),c||(r=!0)),s=a+o[0].length}return i+=n.slice(s),ud(i)}function ul(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function wi(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const o=-t,a=Math.round(o/1e3);if(a<60)return`in ${a}s`;const c=Math.round(a/60);if(c<60)return`in ${c}m`;const u=Math.round(c/60);return u<48?`in ${u}h`:`in ${Math.round(u/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 dl(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 pd(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function pl(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 ti(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Vi(e){return dd(e)}const hd=/^\[([^\]]+)\]\s*/,fd=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Gi=new WeakMap,Qi=new WeakMap;function gd(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:fd.some(t=>e.startsWith(`${t} `))}function Yi(e){const t=e.match(hd);if(!t)return e;const n=t[1]??"";return gd(n)?e.slice(t[0].length):e}function sn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?Vi(i):Yi(i);if(Array.isArray(i)){const s=i.map(r=>{const o=r;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(r=>typeof r=="string");if(s.length>0){const r=s.join(`
4
- `);return n==="assistant"?Vi(r):Yi(r)}}return typeof t.text=="string"?n==="assistant"?Vi(t.text):Yi(t.text):null}function hl(e){if(!e||typeof e!="object")return sn(e);const t=e;if(Gi.has(t))return Gi.get(t)??null;const n=sn(e);return Gi.set(t,n),n}function Ao(e){const n=e.content,i=[];if(Array.isArray(n))for(const a of n){const c=a;if(c.type==="thinking"&&typeof c.thinking=="string"){const u=c.thinking.trim();u&&i.push(u)}}if(i.length>0)return i.join(`
5
- `);const s=yd(e);if(!s)return null;const o=[...s.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(a=>(a[1]??"").trim()).filter(Boolean);return o.length>0?o.join(`
6
- `):null}function md(e){if(!e||typeof e!="object")return Ao(e);const t=e;if(Qi.has(t))return Qi.get(t)??null;const n=Ao(e);return Qi.set(t,n),n}function yd(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const i=n.map(s=>{const r=s;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(s=>typeof s=="string");if(i.length>0)return i.join(`
7
- `)}return typeof t.text=="string"?t.text:null}function vd(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 bd=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,wd=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,kd=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Sd=/^A new session was started via \/new or \/reset\./;function Ad(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(r=>typeof r=="object"&&r!==null).map(r=>r.text??"").join(" "):typeof t.text=="string"&&(i=t.text);const s=i.trim();return s?!!(n==="user"&&bd.test(s)||n==="assistant"&&wd.test(s)||n==="user"&&Sd.test(s)||n==="assistant"&&kd.test(s)):!1}function xd(e){return e.filter(t=>!Ad(t))}function fl(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,r=Array.isArray(s)?s:null,o=Array.isArray(r)&&r.some(d=>{const v=String(d.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),a=typeof t.toolName=="string"||typeof t.tool_name=="string";(i||o||a)&&(n="toolResult");let c=[];typeof t.content=="string"?c=[{type:"text",text:t.content}]:Array.isArray(t.content)?c=t.content.map(d=>({type:d.type||"text",text:d.text,name:d.name,args:d.args||d.arguments})):typeof t.text=="string"&&(c=[{type:"text",text:t.text}]);const u=typeof t.timestamp=="number"?t.timestamp:Date.now(),l=typeof t.id=="string"?t.id:void 0;return{role:n,content:c,timestamp:u,id:l}}function gl(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 ml(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function xo(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 $d(){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 tr(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),xo(t)}return xo($d())}async function Te(e){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{const t=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:5e3}),n=Array.isArray(t.messages)?t.messages:[];e.chatMessages=xd(n),e.chatThinkingLevel=t.thinkingLevel??null,e.chatModelProvider=typeof t.modelProvider=="string"?t.modelProvider:null,e.chatModel=typeof t.model=="string"?t.model:null,e.chatVerboseLevel=typeof t.verboseLevel=="string"?t.verboseLevel:null,e.chatFillerEnabled=typeof t.fillerEnabled=="boolean"?t.fillerEnabled:null}catch(t){e.lastError=String(t)}finally{e.chatLoading=!1}}}function Ed(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function yl(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 r=Date.now(),o=(n??[]).filter(v=>!v.fileName),a=(n??[]).filter(v=>v.fileName),c=[],u=a.map(v=>v.fileName).filter(Boolean);if(u.length>0){const v=i?`${u.join(", ")}
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),yo=/'/g,vo=/"/g,nl=/^(?:script|style|textarea|title)$/i,qu=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),p=qu(1),je=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),bo=new WeakMap,et=it.createTreeWalker(it,129);function il(e,t){if(!er(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return fo!==void 0?fo.createHTML(t):t}const Vu=(e,t)=>{const n=e.length-1,i=[];let s,r=t===2?"<svg>":t===3?"<math>":"",o=Ut;for(let a=0;a<n;a++){const c=e[a];let u,l,d=-1,h=0;for(;h<c.length&&(o.lastIndex=h,l=o.exec(c),l!==null);)h=o.lastIndex,o===Ut?l[1]==="!--"?o=go:l[1]!==void 0?o=mo:l[2]!==void 0?(nl.test(l[2])&&(s=RegExp("</"+l[2],"g")),o=Xe):l[3]!==void 0&&(o=Xe):o===Xe?l[0]===">"?(o=s??Ut,d=-1):l[1]===void 0?d=-2:(d=o.lastIndex-l[2].length,u=l[1],o=l[3]===void 0?Xe:l[3]==='"'?vo:yo):o===vo||o===yo?o=Xe:o===go||o===mo?o=Ut:(o=Xe,s=void 0);const v=o===Xe&&e[a+1].startsWith("/>")?" ":"";r+=o===Ut?c+ju:d>=0?(i.push(u),c.slice(0,d)+el+c.slice(d)+We+v):c+We+(d===-2?a:v)}return[il(e,r+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let As=class sl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let r=0,o=0;const a=t.length-1,c=this.parts,[u,l]=Vu(t,n);if(this.el=sl.createElement(u,i),et.currentNode=this.el.content,n===2||n===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=et.nextNode())!==null&&c.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith(el)){const h=l[o++],v=s.getAttribute(d).split(We),y=/([.?@])?(.*)/.exec(h);c.push({type:1,index:r,name:y[2],strings:v,ctor:y[1]==="."?Qu:y[1]==="?"?Yu:y[1]==="@"?Xu:vi}),s.removeAttribute(d)}else d.startsWith(We)&&(c.push({type:6,index:r}),s.removeAttribute(d));if(nl.test(s.tagName)){const d=s.textContent.split(We),h=d.length-1;if(h>0){s.textContent=Zn?Zn.emptyScript:"";for(let v=0;v<h;v++)s.append(d[v],un()),et.nextNode(),c.push({type:2,index:++r});s.append(d[h],un())}}}else if(s.nodeType===8)if(s.data===tl)c.push({type:2,index:r});else{let d=-1;for(;(d=s.data.indexOf(We,d+1))!==-1;)c.push({type:7,index:r}),d+=We.length-1}r++}}static createElement(t,n){const i=it.createElement("template");return i.innerHTML=t,i}};function Tt(e,t,n=e,i){var o,a;if(t===je)return t;let s=i!==void 0?(o=n._$Co)==null?void 0:o[i]:n._$Cl;const r=dn(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),r===void 0?s=void 0:(s=new r(e),s._$AT(e,n,i)),i!==void 0?(n._$Co??(n._$Co=[]))[i]=s:n._$Cl=s),s!==void 0&&(t=Tt(e,s._$AS(e,t.values),s,i)),t}class Gu{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)??it).importNode(n,!0);et.currentNode=s;let r=et.nextNode(),o=0,a=0,c=i[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new yi(r,r.nextSibling,this,t):c.type===1?u=new c.ctor(r,c.name,c.strings,this,t):c.type===6&&(u=new Zu(r,this,t)),this._$AV.push(u),c=i[++a]}o!==(c==null?void 0:c.index)&&(r=et.nextNode(),o++)}return et.currentNode=it,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 yi=class rl{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=Tt(this,t,n),dn(t)?t===k||t==null||t===""?(this._$AH!==k&&this._$AR(),this._$AH=k):t!==this._$AH&&t!==je&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Hu(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&&dn(this._$AH)?this._$AA.nextSibling.data=t:this.T(it.createTextNode(t)),this._$AH=t}$(t){var r;const{values:n,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=As.createElement(il(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(n);else{const o=new Gu(s,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(t){let n=bo.get(t.strings);return n===void 0&&bo.set(t.strings,n=new As(t)),n}k(t){er(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let i,s=0;for(const r of t)s===n.length?n.push(i=new rl(this.O(un()),this.O(un()),this,this.options)):i=n[s],i._$AI(r),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=ho(t).nextSibling;ho(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class vi{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,r){this.type=1,this._$AH=k,this._$AN=void 0,this.element=t,this.name=n,this._$AM=s,this.options=r,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 r=this.strings;let o=!1;if(r===void 0)t=Tt(this,t,n,0),o=!dn(t)||t!==this._$AH&&t!==je,o&&(this._$AH=t);else{const a=t;let c,u;for(t=r[0],c=0;c<r.length-1;c++)u=Tt(this,a[i+c],n,c),u===je&&(u=this._$AH[c]),o||(o=!dn(u)||u!==this._$AH[c]),u===k?t=k:t!==k&&(t+=(u??"")+r[c+1]),this._$AH[c]=u}o&&!s&&this.j(t)}j(t){t===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let Qu=class extends vi{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===k?void 0:t}},Yu=class extends vi{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==k)}},Xu=class extends vi{constructor(t,n,i,s,r){super(t,n,i,s,r),this.type=5}_$AI(t,n=this){if((t=Tt(this,t,n,0)??k)===je)return;const i=this._$AH,s=t===k&&i!==k||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==k&&(i===k||s);s&&this.element.removeEventListener(this.name,this,i),r&&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)}},Zu=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){Tt(this,t)}};const Ju={I:yi},ji=tn.litHtmlPolyfillSupport;ji==null||ji(As,yi),(tn.litHtmlVersions??(tn.litHtmlVersions=[])).push("3.3.2");const ed=(e,t,n)=>{const i=(n==null?void 0:n.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const r=(n==null?void 0:n.renderBefore)??null;i._$litPart$=s=new yi(t.insertBefore(un(),r),r,void 0,n??{})}return s._$AI(e),s};const nt=globalThis;let $t=class extends St{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=ed(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 je}};var Za;$t._$litElement$=!0,$t.finalized=!0,(Za=nt.litElementHydrateSupport)==null||Za.call(nt,{LitElement:$t});const Hi=nt.litElementPolyfillSupport;Hi==null||Hi({LitElement:$t});(nt.litElementVersions??(nt.litElementVersions=[])).push("4.2.2");const ol=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const td={attribute:!0,type:String,converter:Xn,reflect:!1,hasChanged:Js},nd=(e=td,t,n)=>{const{kind:i,metadata:s}=n;let r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),r.set(n.name,e),i==="accessor"){const{name:o}=n;return{set(a){const c=t.get.call(this);t.set.call(this,a),this.requestUpdate(o,c,e,!0,a)},init(a){return a!==void 0&&this.C(o,void 0,e,a),a}}}if(i==="setter"){const{name:o}=n;return function(a){const c=this[o];t.call(this,a),this.requestUpdate(o,c,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function bi(e){return(t,n)=>typeof n=="object"?nd(e,t,n):((i,s,r)=>{const o=s.hasOwnProperty(r);return s.constructor.createProperty(r,i),o?Object.getOwnPropertyDescriptor(s,r):void 0})(e,t,n)}function m(e){return bi({...e,state:!0,attribute:!1})}const id=50,sd=200,rd="Assistant";function wo(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function xs(e){const t=wo(e==null?void 0:e.name,id)??rd,n=wo((e==null?void 0:e.avatar)??void 0,sd)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function od(){return xs(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Jn="taskmaster.control.settings.v1",al="taskmaster.account.settings.";function nn(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const kt={gatewayUrl:nn(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},Ue={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function ad(){try{const e=localStorage.getItem(Jn);if(!e)return{...kt,gatewayUrl:nn()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():nn(),token:typeof t.token=="string"?t.token:kt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:kt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:kt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:kt.navGroupsCollapsed}}catch{return{...kt,gatewayUrl:nn()}}}function ld(e){if(!e)return{...Ue};try{const t=localStorage.getItem(al+e);if(!t)return{...Ue};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():Ue.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||Ue.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:Ue.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:Ue.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:Ue.splitRatio}}catch{return{...Ue}}}let ei=null;function ko(e){ei=e}function qi(){return{...ad(),...ld(ei)}}function cd(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Jn,JSON.stringify(t)),ei){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(al+ei,JSON.stringify(n))}}(function(){try{const t=localStorage.getItem(Jn);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:nn(),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(Jn,JSON.stringify(i))}catch{}})();function ll(e){var r;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=(r=n[1])==null?void 0:r.trim(),s=n.slice(2).join(":");return!i||!s?null:{agentId:i,rest:s}}const ud=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Pn=/<\s*\/?\s*final\b[^>]*>/gi,So=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function dd(e,t){return e.trimStart()}function pd(e,t){if(!e||!ud.test(e))return e;let n=e;Pn.test(n)?(Pn.lastIndex=0,n=n.replace(Pn,"")):Pn.lastIndex=0,So.lastIndex=0;let i="",s=0,r=!1;for(const o of n.matchAll(So)){const a=o.index??0,c=o[1]==="/";r?c&&(r=!1):(i+=n.slice(s,a),c||(r=!0)),s=a+o[0].length}return i+=n.slice(s),dd(i)}function cl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function wi(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const o=-t,a=Math.round(o/1e3);if(a<60)return`in ${a}s`;const c=Math.round(a/60);if(c<60)return`in ${c}m`;const u=Math.round(c/60);return u<48?`in ${u}h`:`in ${Math.round(u/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 ul(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 hd(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 ti(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Vi(e){return pd(e)}const fd=/^\[([^\]]+)\]\s*/,gd=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Gi=new WeakMap,Qi=new WeakMap;function md(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:gd.some(t=>e.startsWith(`${t} `))}function Yi(e){const t=e.match(fd);if(!t)return e;const n=t[1]??"";return md(n)?e.slice(t[0].length):e}function sn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?Vi(i):Yi(i);if(Array.isArray(i)){const s=i.map(r=>{const o=r;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(r=>typeof r=="string");if(s.length>0){const r=s.join(`
4
+ `);return n==="assistant"?Vi(r):Yi(r)}}return typeof t.text=="string"?n==="assistant"?Vi(t.text):Yi(t.text):null}function pl(e){if(!e||typeof e!="object")return sn(e);const t=e;if(Gi.has(t))return Gi.get(t)??null;const n=sn(e);return Gi.set(t,n),n}function Ao(e){const n=e.content,i=[];if(Array.isArray(n))for(const a of n){const c=a;if(c.type==="thinking"&&typeof c.thinking=="string"){const u=c.thinking.trim();u&&i.push(u)}}if(i.length>0)return i.join(`
5
+ `);const s=vd(e);if(!s)return null;const o=[...s.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(a=>(a[1]??"").trim()).filter(Boolean);return o.length>0?o.join(`
6
+ `):null}function yd(e){if(!e||typeof e!="object")return Ao(e);const t=e;if(Qi.has(t))return Qi.get(t)??null;const n=Ao(e);return Qi.set(t,n),n}function vd(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const i=n.map(s=>{const r=s;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(s=>typeof s=="string");if(i.length>0)return i.join(`
7
+ `)}return typeof t.text=="string"?t.text:null}function bd(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 wd=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,kd=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Sd=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Ad=/^A new session was started via \/new or \/reset\./;function xd(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(r=>typeof r=="object"&&r!==null).map(r=>r.text??"").join(" "):typeof t.text=="string"&&(i=t.text);const s=i.trim();return s?!!(n==="user"&&wd.test(s)||n==="assistant"&&kd.test(s)||n==="user"&&Ad.test(s)||n==="assistant"&&Sd.test(s)):!1}function $d(e){return e.filter(t=>!xd(t))}function hl(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,r=Array.isArray(s)?s:null,o=Array.isArray(r)&&r.some(d=>{const v=String(d.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),a=typeof t.toolName=="string"||typeof t.tool_name=="string";(i||o||a)&&(n="toolResult");let c=[];typeof t.content=="string"?c=[{type:"text",text:t.content}]:Array.isArray(t.content)?c=t.content.map(d=>({type:d.type||"text",text:d.text,name:d.name,args:d.args||d.arguments})):typeof t.text=="string"&&(c=[{type:"text",text:t.text}]);const u=typeof t.timestamp=="number"?t.timestamp:Date.now(),l=typeof t.id=="string"?t.id:void 0;return{role:n,content:c,timestamp:u,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 gl(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function xo(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 Ed(){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 tr(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),xo(t)}return xo(Ed())}async function Te(e){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{const t=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:5e3}),n=Array.isArray(t.messages)?t.messages:[];e.chatMessages=$d(n),e.chatThinkingLevel=t.thinkingLevel??null,e.chatModelProvider=typeof t.modelProvider=="string"?t.modelProvider:null,e.chatModel=typeof t.model=="string"?t.model:null,e.chatVerboseLevel=typeof t.verboseLevel=="string"?t.verboseLevel:null,e.chatFillerEnabled=typeof t.fillerEnabled=="boolean"?t.fillerEnabled:null}catch(t){e.lastError=String(t)}finally{e.chatLoading=!1}}}function Cd(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function ml(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 r=Date.now(),o=(n??[]).filter(v=>!v.fileName),a=(n??[]).filter(v=>v.fileName),c=[],u=a.map(v=>v.fileName).filter(Boolean);if(u.length>0){const v=i?`${u.join(", ")}
9
9
 
10
- ${i}`:u.join(", ");c.push({type:"text",text:v})}else i&&c.push({type:"text",text:i});for(const v of o)c.push({type:"image",source:{type:"base64",media_type:v.mimeType,data:v.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:c,timestamp:r}],e.chatSending=!0,e.lastError=null;const l=tr();e.chatRunId=l,e.chatStream="",e.chatStreamStartedAt=r;const d=[...o,...a],h=d.length>0?d.map(v=>{if(v.textContent)return{type:"document",mimeType:v.mimeType||"text/plain",fileName:v.fileName,content:btoa(unescape(encodeURIComponent(v.textContent)))};const y=Ed(v.dataUrl);return y?{type:v.fileName?"document":"image",mimeType:y.mimeType,fileName:v.fileName,content:y.content}:null}).filter(v=>v!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:l,attachments:h}),!0}catch(v){const y=String(v);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=y,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+y}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function vl(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 bl(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 r=(t.message?(n=sn(t.message))==null?void 0:n.trim():void 0)||((i=e.chatStream)==null?void 0:i.trim());return r&&(e.chatInterimText=e.chatInterimText?`${e.chatInterimText}
10
+ ${i}`:u.join(", ");c.push({type:"text",text:v})}else i&&c.push({type:"text",text:i});for(const v of o)c.push({type:"image",source:{type:"base64",media_type:v.mimeType,data:v.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:c,timestamp:r}],e.chatSending=!0,e.lastError=null;const l=tr();e.chatRunId=l,e.chatStream="",e.chatStreamStartedAt=r;const d=[...o,...a],h=d.length>0?d.map(v=>{if(v.textContent)return{type:"document",mimeType:v.mimeType||"text/plain",fileName:v.fileName,content:btoa(unescape(encodeURIComponent(v.textContent)))};const y=Cd(v.dataUrl);return y?{type:v.fileName?"document":"image",mimeType:y.mimeType,fileName:v.fileName,content:y.content}:null}).filter(v=>v!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:l,attachments:h}),!0}catch(v){const y=String(v);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=y,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+y}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function yl(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 vl(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 r=(t.message?(n=sn(t.message))==null?void 0:n.trim():void 0)||((i=e.chatStream)==null?void 0:i.trim());return r&&(e.chatInterimText=e.chatInterimText?`${e.chatInterimText}
11
11
 
12
- ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(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=sn(t.message);if(typeof s=="string"){if(s.trim()==="NO_REPLY")return null;const r=e.chatStream??"";(!r||s.length>=r.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 $s=Object.freeze(Object.defineProperty({__proto__:null,abortChatRun:vl,handleChatEvent:bl,loadChatHistory:Te,sendChatMessage:yl},Symbol.toStringTag,{value:"Module"}));async function nr(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=ti(e.sessionsFilterActive??"",0),i=ti(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 Ln(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 nr(e)}catch(s){e.sessionsError=String(s)}}const $o=50,Cd=80,Td=12e4;function _d(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 r=s;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(s=>!!s);return i.length===0?null:i.join(`
13
- `)}function Eo(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=_d(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=pl(n,Td);return i.truncated?`${i.text}
12
+ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(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=sn(t.message);if(typeof s=="string"){if(s.trim()==="NO_REPLY")return null;const r=e.chatStream??"";(!r||s.length>=r.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 $s=Object.freeze(Object.defineProperty({__proto__:null,abortChatRun:yl,handleChatEvent:vl,loadChatHistory:Te,sendChatMessage:ml},Symbol.toStringTag,{value:"Module"}));async function nr(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=ti(e.sessionsFilterActive??"",0),i=ti(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 Ln(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 nr(e)}catch(s){e.sessionsError=String(s)}}const $o=50,Td=80,_d=12e4;function Md(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 r=s;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(s=>!!s);return i.length===0?null:i.join(`
13
+ `)}function Eo(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Md(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,_d);return i.truncated?`${i.text}
14
14
 
15
- … truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function Md(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 Pd(e){if(e.toolStreamOrder.length<=$o)return;const t=e.toolStreamOrder.length-$o,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function Ld(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function Es(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Ld(e)}function Id(e,t=!1){if(t){Es(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>Es(e),Cd))}function ir(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],Es(e)}const Rd=5e3;function Nd(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},Rd))}function Dd(e,t){if(!t)return;if(t.stream==="compaction"){Nd(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 r=typeof i.name=="string"?i.name:"tool",o=typeof i.phase=="string"?i.phase:"",a=o==="start"?i.args:void 0,c=o==="update"?Eo(i.partialResult):o==="result"?Eo(i.result):void 0,u=Date.now();let l=e.toolStreamById.get(s);l?(l.name=r,a!==void 0&&(l.args=a),c!==void 0&&(l.output=c),l.updatedAt=u):(l={toolCallId:s,runId:t.runId,sessionKey:n,name:r,args:a,output:c,startedAt:typeof t.ts=="number"?t.ts:u,updatedAt:u,message:{}},e.toolStreamById.set(s,l),e.toolStreamOrder.push(s)),l.message=Md(l),Pd(e),Id(e,o==="result")}function fn(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=()=>{const i=e.querySelector(".chat-thread");if(i){const s=getComputedStyle(i).overflowY;if(s==="auto"||s==="scroll"||i.scrollHeight-i.clientHeight>1)return i}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;const i=n();if(!i)return;const s=i.scrollHeight-i.scrollTop-i.clientHeight;if(!(t||e.chatUserNearBottom||s<200))return;t&&(e.chatHasAutoScrolled=!0),i.scrollTop=i.scrollHeight,e.chatUserNearBottom=!0;const o=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;const a=n();if(!a)return;const c=a.scrollHeight-a.scrollTop-a.clientHeight;(t||e.chatUserNearBottom||c<200)&&(a.scrollTop=a.scrollHeight,e.chatUserNearBottom=!0)},o)})})}function wl(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 Od(e,t){const n=t.currentTarget;if(!n)return;const i=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=i<200}function Bd(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Fd(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Ud(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function Wd(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 Pd(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 Ld(e){if(e.toolStreamOrder.length<=$o)return;const t=e.toolStreamOrder.length-$o,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function Id(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function Es(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Id(e)}function Rd(e,t=!1){if(t){Es(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>Es(e),Td))}function ir(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],Es(e)}const Nd=5e3;function Dd(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},Nd))}function Od(e,t){if(!t)return;if(t.stream==="compaction"){Dd(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 r=typeof i.name=="string"?i.name:"tool",o=typeof i.phase=="string"?i.phase:"",a=o==="start"?i.args:void 0,c=o==="update"?Eo(i.partialResult):o==="result"?Eo(i.result):void 0,u=Date.now();let l=e.toolStreamById.get(s);l?(l.name=r,a!==void 0&&(l.args=a),c!==void 0&&(l.output=c),l.updatedAt=u):(l={toolCallId:s,runId:t.runId,sessionKey:n,name:r,args:a,output:c,startedAt:typeof t.ts=="number"?t.ts:u,updatedAt:u,message:{}},e.toolStreamById.set(s,l),e.toolStreamOrder.push(s)),l.message=Pd(l),Ld(e),Rd(e,o==="result")}function fn(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=()=>{const i=e.querySelector(".chat-thread");if(i){const s=getComputedStyle(i).overflowY;if(s==="auto"||s==="scroll"||i.scrollHeight-i.clientHeight>1)return i}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;const i=n();if(!i)return;const s=i.scrollHeight-i.scrollTop-i.clientHeight;if(!(t||e.chatUserNearBottom||s<200))return;t&&(e.chatHasAutoScrolled=!0),i.scrollTop=i.scrollHeight,e.chatUserNearBottom=!0;const o=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;const a=n();if(!a)return;const c=a.scrollHeight-a.scrollTop-a.clientHeight;(t||e.chatUserNearBottom||c<200)&&(a.scrollTop=a.scrollHeight,e.chatUserNearBottom=!0)},o)})})}function bl(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 Bd(e,t){const n=t.currentTarget;if(!n)return;const i=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=i<200}function Fd(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Ud(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Wd(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function Kd(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"),r=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-logs-${t}-${r}.log`,s.click(),URL.revokeObjectURL(i)}function Kd(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"),r=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-logs-${t}-${r}.log`,s.click(),URL.revokeObjectURL(i)}function zd(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"),r=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-session-logs-${t}-${r}.log`,s.click(),URL.revokeObjectURL(i)}function zd(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 He(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function st(e){return`${JSON.stringify(e,null,2).trimEnd()}
20
- `}function kl(e,t,n){if(t.length===0)return;let i=e;for(let r=0;r<t.length-1;r+=1){const o=t[r],a=t[r+1];if(typeof o=="number"){if(!Array.isArray(i))return;i[o]==null&&(i[o]=typeof a=="number"?[]:{}),i=i[o]}else{if(typeof i!="object"||i==null)return;const c=i;c[o]==null&&(c[o]=typeof a=="number"?[]:{}),i=c[o]}}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 _e(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});Hd(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function Sl(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});jd(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function jd(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function Hd(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?st(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=st(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=He(t.config??{}),e.configFormOriginal=He(t.config??{}),e.configRawOriginal=n)}async function qd(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?st(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 _e(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function gn(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 ki(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 Vd(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=ti(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 Gd(e){if(e.payloadKind==="systemEvent"){const s=e.payloadText.trim();if(!s)throw new Error("System event text required.");return{kind:"systemEvent",text:s}}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),e.to.trim()&&(n.to=e.to.trim());const i=ti(e.timeoutSeconds,0);return i>0&&(n.timeoutSeconds=i),n}async function Qd(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=Vd(e.cronForm),i=Gd(e.cronForm),s=e.cronForm.agentId.trim(),r=(t=e.cronForm.accountId)==null?void 0:t.trim(),o={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:r||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(!o.name)throw new Error("Name required.");await e.client.request("cron.add",o),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await ki(e),await gn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Yd(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 ki(e),await gn(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function Xd(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 Cs(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Zd(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 ki(e),await gn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Cs(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 V(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 sr(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 Al(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 xl(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 $l(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 r=He(s.config??{});(!r.channels||typeof r.channels!="object")&&(r.channels={});const o=r.channels;(!o.whatsapp||typeof o.whatsapp!="object")&&(o.whatsapp={});const a=o.whatsapp;(!a.accounts||typeof a.accounts!="object")&&(a.accounts={});const c=a.accounts;if(c[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}c[i]={name:n,provider:"baileys"};const u=s.hash;if(!u){e.whatsappAccountError="Config hash missing; reload and retry.";return}const l=st(r);await e.client.request("config.set",{raw:l,baseHash:u}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await V(e,!0),await sr(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function El(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=He(n.config??{}),s=i.channels,r=s==null?void 0:s.whatsapp,o=r==null?void 0:r.accounts;if(!o){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(o).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!o[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete o[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(l=>{const d=l.match;return!d||d.channel!=="whatsapp"?!0:d.accountId!==t}));const c=n.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const u=st(i);await e.client.request("config.set",{raw:u,baseHash:c}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await V(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Jd=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:$l,loadChannels:V,logoutWhatsApp:xl,removeWhatsAppAccount:El,startWhatsAppLogin:sr,waitWhatsAppLogin:Al},Symbol.toStringTag,{value:"Module"}));async function rr(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 r=i;e.debugModels=Array.isArray(r==null?void 0:r.models)?r==null?void 0:r.models:[],e.debugHeartbeat=s}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const ep=2e3,tp=new Set(["trace","debug","info","warn","error","fatal"]);function np(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 ip(e){if(typeof e!="string")return null;const t=e.toLowerCase();return tp.has(t)?t:null}function Cl(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=ip((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),r=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,o=np(r);let a=null;o&&(typeof o.subsystem=="string"?a=o.subsystem:typeof o.module=="string"&&(a=o.module)),!a&&r&&r.length<120&&(a=r);let c=null;return typeof t[1]=="string"?c=t[1]:!o&&typeof t[0]=="string"?c=t[0]:typeof t.message=="string"&&(c=t.message),{raw:e,time:i,level:s,subsystem:a,message:c??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Et(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}),r=(Array.isArray(i.lines)?i.lines.filter(a=>typeof a=="string"):[]).map(Cl),o=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=o?r:[...e.logsEntries,...r].slice(-ep),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 sp=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Et,parseLogLine:Cl},Symbol.toStringTag,{value:"Module"}));const Tl={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:re,n:Vn,Gx:Co,Gy:To,a:Xi,d:Zi,h:rp}=Tl,rt=32,or=64,op=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},ee=(e="")=>{const t=new Error(e);throw op(t,ee),t},ap=e=>typeof e=="bigint",lp=e=>typeof e=="string",cp=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",Ve=(e,t,n="")=>{const i=cp(e),s=e==null?void 0:e.length,r=t!==void 0;if(!i||r&&s!==t){const o=n&&`"${n}" `,a=r?` of length ${t}`:"",c=i?`length=${s}`:`type=${typeof e}`;ee(o+"expected Uint8Array"+a+", got "+c)}return e},Si=e=>new Uint8Array(e),_l=e=>Uint8Array.from(e),Ml=(e,t)=>e.toString(16).padStart(t,"0"),Pl=e=>Array.from(Ve(e)).map(t=>Ml(t,2)).join(""),Ie={_0:48,_9:57,A:65,F:70,a:97,f:102},_o=e=>{if(e>=Ie._0&&e<=Ie._9)return e-Ie._0;if(e>=Ie.A&&e<=Ie.F)return e-(Ie.A-10);if(e>=Ie.a&&e<=Ie.f)return e-(Ie.a-10)},Ll=e=>{const t="hex invalid";if(!lp(e))return ee(t);const n=e.length,i=n/2;if(n%2)return ee(t);const s=Si(i);for(let r=0,o=0;r<i;r++,o+=2){const a=_o(e.charCodeAt(o)),c=_o(e.charCodeAt(o+1));if(a===void 0||c===void 0)return ee(t);s[r]=a*16+c}return s},Il=()=>globalThis==null?void 0:globalThis.crypto,up=()=>{var e;return((e=Il())==null?void 0:e.subtle)??ee("crypto.subtle must be defined, consider polyfill")},pn=(...e)=>{const t=Si(e.reduce((i,s)=>i+Ve(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},dp=(e=rt)=>Il().getRandomValues(Si(e)),ni=BigInt,Je=(e,t,n,i="bad number: out of range")=>ap(e)&&t<=e&&e<n?e:ee(i),P=(e,t=re)=>{const n=e%t;return n>=0n?n:t+n},Rl=e=>P(e,Vn),pp=(e,t)=>{(e===0n||t<=0n)&&ee("no inverse n="+e+" mod="+t);let n=P(e,t),i=t,s=0n,r=1n;for(;n!==0n;){const o=i/n,a=i%n,c=s-r*o;i=n,n=a,s=r,r=c}return i===1n?P(s,t):ee("no inverse")},hp=e=>{const t=Bl[e];return typeof t!="function"&&ee("hashes."+e+" not set"),t},Ji=e=>e instanceof ot?e:ee("Point expected"),Ts=2n**256n,Ce=class Ce{constructor(t,n,i,s){U(this,"X");U(this,"Y");U(this,"Z");U(this,"T");const r=Ts;this.X=Je(t,0n,r),this.Y=Je(n,0n,r),this.Z=Je(i,1n,r),this.T=Je(s,0n,r),Object.freeze(this)}static CURVE(){return Tl}static fromAffine(t){return new Ce(t.x,t.y,1n,P(t.x*t.y))}static fromBytes(t,n=!1){const i=Zi,s=_l(Ve(t,rt)),r=t[31];s[31]=r&-129;const o=Dl(s);Je(o,0n,n?Ts:re);const c=P(o*o),u=P(c-1n),l=P(i*c+1n);let{isValid:d,value:h}=gp(u,l);d||ee("bad point: y not sqrt");const v=(h&1n)===1n,y=(r&128)!==0;return!n&&h===0n&&y&&ee("bad point: x==0, isLastByteOdd"),y!==v&&(h=P(-h)),new Ce(h,o,1n,P(h*o))}static fromHex(t,n){return Ce.fromBytes(Ll(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Xi,n=Zi,i=this;if(i.is0())return ee("bad point: ZERO");const{X:s,Y:r,Z:o,T:a}=i,c=P(s*s),u=P(r*r),l=P(o*o),d=P(l*l),h=P(c*t),v=P(l*P(h+u)),y=P(d+P(n*P(c*u)));if(v!==y)return ee("bad point: equation left != right (1)");const b=P(s*r),S=P(o*a);return b!==S?ee("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:r,Y:o,Z:a}=Ji(t),c=P(n*a),u=P(r*s),l=P(i*a),d=P(o*s);return c===u&&l===d}is0(){return this.equals(xt)}negate(){return new Ce(P(-this.X),this.Y,this.Z,P(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=Xi,r=P(t*t),o=P(n*n),a=P(2n*P(i*i)),c=P(s*r),u=t+n,l=P(P(u*u)-r-o),d=c+o,h=d-a,v=c-o,y=P(l*h),b=P(d*v),S=P(l*v),x=P(h*d);return new Ce(y,b,x,S)}add(t){const{X:n,Y:i,Z:s,T:r}=this,{X:o,Y:a,Z:c,T:u}=Ji(t),l=Xi,d=Zi,h=P(n*o),v=P(i*a),y=P(r*d*u),b=P(s*c),S=P((n+i)*(o+a)-h-v),x=P(b-y),$=P(b+y),C=P(v-l*h),T=P(S*x),M=P($*C),R=P(S*C),B=P(x*$);return new Ce(T,M,B,R)}subtract(t){return this.add(Ji(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return xt;if(Je(t,1n,Vn),t===1n)return this;if(this.equals(at))return Ep(t).p;let i=xt,s=at;for(let r=this;t>0n;r=r.double(),t>>=1n)t&1n?i=i.add(r):n&&(s=s.add(r));return i}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:i}=this;if(this.equals(xt))return{x:0n,y:1n};const s=pp(i,re);P(i*s)!==1n&&ee("invalid inverse");const r=P(t*s),o=P(n*s);return{x:r,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Nl(n);return i[31]|=t&1n?128:0,i}toHex(){return Pl(this.toBytes())}clearCofactor(){return this.multiply(ni(rp),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Vn/2n,!1).double();return Vn%2n&&(t=t.add(this)),t.is0()}};U(Ce,"BASE"),U(Ce,"ZERO");let ot=Ce;const at=new ot(Co,To,1n,P(Co*To)),xt=new ot(0n,1n,1n,0n);ot.BASE=at;ot.ZERO=xt;const Nl=e=>Ll(Ml(Je(e,0n,Ts),or)).reverse(),Dl=e=>ni("0x"+Pl(_l(Ve(e)).reverse())),Ae=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=re;return n},fp=e=>{const n=e*e%re*e%re,i=Ae(n,2n)*n%re,s=Ae(i,1n)*e%re,r=Ae(s,5n)*s%re,o=Ae(r,10n)*r%re,a=Ae(o,20n)*o%re,c=Ae(a,40n)*a%re,u=Ae(c,80n)*c%re,l=Ae(u,80n)*c%re,d=Ae(l,10n)*r%re;return{pow_p_5_8:Ae(d,2n)*e%re,b2:n}},Mo=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,gp=(e,t)=>{const n=P(t*t*t),i=P(n*n*t),s=fp(e*i).pow_p_5_8;let r=P(e*n*s);const o=P(t*r*r),a=r,c=P(r*Mo),u=o===e,l=o===P(-e),d=o===P(-e*Mo);return u&&(r=a),(l||d)&&(r=c),(P(r)&1n)===1n&&(r=P(-r)),{isValid:u||l,value:r}},_s=e=>Rl(Dl(e)),ar=(...e)=>Bl.sha512Async(pn(...e)),mp=(...e)=>hp("sha512")(pn(...e)),Ol=e=>{const t=e.slice(0,rt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(rt,or),i=_s(t),s=at.multiply(i),r=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:r}},lr=e=>ar(Ve(e,rt)).then(Ol),yp=e=>Ol(mp(Ve(e,rt))),vp=e=>lr(e).then(t=>t.pointBytes),bp=e=>ar(e.hashable).then(e.finish),wp=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,r=_s(t),o=at.multiply(r).toBytes();return{hashable:pn(o,i,n),finish:u=>{const l=Rl(r+_s(u)*s);return Ve(pn(o,Nl(l)),or)}}},kp=async(e,t)=>{const n=Ve(e),i=await lr(t),s=await ar(i.prefix,n);return bp(wp(i,s,n))},Bl={sha512Async:async e=>{const t=up(),n=pn(e);return Si(await t.digest("SHA-512",n.buffer))},sha512:void 0},Sp=(e=dp(rt))=>e,Ap={getExtendedPublicKeyAsync:lr,getExtendedPublicKey:yp,randomSecretKey:Sp},ii=8,xp=256,Fl=Math.ceil(xp/ii)+1,Ms=2**(ii-1),$p=()=>{const e=[];let t=at,n=t;for(let i=0;i<Fl;i++){n=t,e.push(n);for(let s=1;s<Ms;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Po;const Lo=(e,t)=>{const n=t.negate();return e?n:t},Ep=e=>{const t=Po||(Po=$p());let n=xt,i=at;const s=2**ii,r=s,o=ni(s-1),a=ni(ii);for(let c=0;c<Fl;c++){let u=Number(e&o);e>>=a,u>Ms&&(u-=r,e+=1n);const l=c*Ms,d=l,h=l+Math.abs(u)-1,v=c%2!==0,y=u<0;u===0?i=i.add(Lo(v,t[d])):n=n.add(Lo(y,t[h]))}return e!==0n&&ee("invalid wnaf"),{p:n,f:i}},es="taskmaster-device-identity-v1";function Ps(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Ul(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 r=0;r<i.length;r+=1)s[r]=i.charCodeAt(r);return s}function Cp(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Wl(e){const t=await crypto.subtle.digest("SHA-256",e);return Cp(new Uint8Array(t))}async function Tp(){const e=Ap.randomSecretKey(),t=await vp(e);return{deviceId:await Wl(t),publicKey:Ps(t),privateKey:Ps(e)}}async function _p(){try{const n=localStorage.getItem(es);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 Wl(Ul(i.publicKey));if(s!==i.deviceId){const r={...i,deviceId:s};return localStorage.setItem(es,JSON.stringify(r)),{deviceId:s,publicKey:i.publicKey,privateKey:i.privateKey}}return{deviceId:i.deviceId,publicKey:i.publicKey,privateKey:i.privateKey}}}}catch{}const e=await Tp(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(es,JSON.stringify(t)),e}async function Mp(e,t){const n=Ul(e),i=new TextEncoder().encode(t),s=await kp(i,n);return Ps(s)}const Kl="taskmaster.device.auth.v1";function cr(e){return e.trim()}function Pp(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 ur(){try{const e=window.localStorage.getItem(Kl);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 zl(e){try{window.localStorage.setItem(Kl,JSON.stringify(e))}catch{}}function Lp(e){const t=ur();if(!t||t.deviceId!==e.deviceId)return null;const n=cr(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function Ip(e){const t=cr(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=ur();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:Pp(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,zl(n),s}function Rp(e){const t=ur();if(!t||t.deviceId!==e.deviceId)return;const n=cr(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],zl(i)}async function dr(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 pr(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 Np(e){return{method:"exec.approvals.get",params:{}}}async function Dp(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Np(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);Op(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Op(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=He(t.file??{}))}async function jl(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 _t(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function Ai(e){return e instanceof Error?e.message:String(e)}async function lt(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=Ai(n)}finally{e.skillsLoading=!1}}}function Hl(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function ql(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 lt(e),_t(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=Ai(i);e.skillsError=s,_t(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Vl(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 lt(e),_t(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=Ai(n);e.skillsError=i,_t(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Gl(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 lt(e),_t(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const r=Ai(s);e.skillsError=r,_t(e,t,{kind:"error",message:r})}finally{e.skillsBusyKey=null}}}const Bp=Object.freeze(Object.defineProperty({__proto__:null,installSkill:Gl,loadSkills:lt,saveSkillApiKey:Vl,updateSkillEdit:Hl,updateSkillEnabled:ql},Symbol.toStringTag,{value:"Module"})),Ql={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},Yl=new Map(Object.entries(Ql).map(([e,t])=>[t,e]));function xi(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function hn(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 Fp(e,t=""){const n=xi(t),i=Ql[e];return n?`${n}${i}`:i}function Xl(e,t=""){const n=xi(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=hn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":Yl.get(s)??null}function Up(e){let t=hn(e);if(t.endsWith("/index.html")&&(t=hn(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(Yl.has(s)){const r=n.slice(0,i);return r.length?`/${r.join("/")}`:""}}return`/${n.join("/")}`}function Wp(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function hr(e){return e==="system"?Wp():e}const In=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,Kp=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Rn=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},zp=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var u;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const r=s.documentElement,o=s,a=Kp();if(!!o.startViewTransition&&!a){let l=.5,d=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")l=In(n.pointerClientX/window.innerWidth),d=In(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const h=n.element.getBoundingClientRect();h.width>0&&h.height>0&&typeof window<"u"&&(l=In((h.left+h.width/2)/window.innerWidth),d=In((h.top+h.height/2)/window.innerHeight))}r.style.setProperty("--theme-switch-x",`${l*100}%`),r.style.setProperty("--theme-switch-y",`${d*100}%`),r.classList.add("theme-transition");try{const h=(u=o.startViewTransition)==null?void 0:u.call(o,()=>{t()});h!=null&&h.finished?h.finished.finally(()=>Rn(r)):Rn(r)}catch{Rn(r),t()}return}t(),Rn(r)},jp=2e3;async function rn(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),r=Array.isArray(s.entries)?s.entries:[],o=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=o?r:[...e.sessionLogsEntries,...r].slice(-jp),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 Zl=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:rn},Symbol.toStringTag,{value:"Module"}));async function Jl(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 Hp(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 Nn=null;function mn(e,t){Nn&&clearTimeout(Nn),e.filesMessage={kind:"success",text:t},Nn=setTimeout(()=>{e.filesMessage=null,Nn=null},3e3)}async function yn(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 qp(e,t,n){e.filesSelectedPaths=new Set([t]),await ec(e,t,n)}async function Vp(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 ec(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Gp(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let i=0,s="";for(const r of n)try{await tc(e,r,t),i++}catch(o){s=Ne(o)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:mn(e,`${i} file${i!==1?"s":""} downloaded`)}async function Qp(e,t,n,i){const s=t.split("/").pop()??t,r=n==="."?s:`${n}/${s}`;r!==t&&await nc(e,t,r,i)}async function ec(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 tc(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 r=Uint8Array.from(atob(s.base64),u=>u.charCodeAt(0)),o=new Blob([r]),a=URL.createObjectURL(o),c=document.createElement("a");c.href=a,c.download=s.name??t.split("/").pop()??"download",document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(a)}catch(i){e.filesMessage={kind:"error",text:Ne(i)}}}async function Yp(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,r="";for(const o of n)try{const a=await o.arrayBuffer(),c=btoa(new Uint8Array(a).reduce((l,d)=>l+String.fromCharCode(d),"")),u={path:t,name:o.name,data:c};i&&(u.agentId=i),await e.client.request("files.upload",u),s++}catch(a){r=Ne(a)}e.filesUploadBusy=!1,r?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${r}`:r}:mn(e,`${s} file${s!==1?"s":""} uploaded`),await yn(e,i)}async function Xp(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),mn(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await yn(e,n)}catch(i){e.filesMessage={kind:"error",text:Ne(i)}}}}async function nc(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),mn(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await yn(e,i)}catch(s){e.filesMessage={kind:"error",text:Ne(s)}}}}async function fr(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 Zp(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,r=(i==null?void 0:i.chunks)??0;mn(e,`Re-indexed: ${s} files, ${r} chunks`),await fr(e,t)}catch(n){e.filesMessage={kind:"error",text:Ne(n)}}finally{e.filesReindexBusy=!1}}}function Jp(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n}async function eh(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 th(e){e.filesSearchQuery="",e.filesSearchResults=null}function nh(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{pr(e,{quiet:!0})},5e3))}function ih(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function gr(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Et(e,{quiet:!0})},2e3))}function mr(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function yr(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||rn(e,{quiet:!0})},2e3))}function vr(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function br(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&rr(e)},3e3))}function wr(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function sh(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{Jl(e)},3e4))}function rh(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function oh(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{e.tab==="files"&&fr(e)},3e3))}function ah(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function ze(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,ld(n),t.theme!==e.theme&&(e.theme=t.theme,$i(e,hr(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function ic(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&ze(e,{...e.settings,lastActiveSessionKey:n})}function lh(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"),r=t.get("gatewayUrl");let o=!1;if(n!=null){const c=n.trim();c&&c!==e.settings.token&&ze(e,{...e.settings,token:c}),t.delete("token"),o=!0}if(i!=null){const c=i.trim();c&&(e.password=c),t.delete("password"),o=!0}if(s!=null){const c=s.trim();c&&(e.sessionKey=c,ze(e,{...e.settings,sessionKey:c,lastActiveSessionKey:c}))}if(r!=null){const c=r.trim();c&&c!==e.settings.gatewayUrl&&ze(e,{...e.settings,gatewayUrl:c}),t.delete("gatewayUrl"),o=!0}if(!o)return;const a=new URL(window.location.href);a.search=t.toString(),window.history.replaceState({},"",a.toString())}function ch(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?yr(e):gr(e):(mr(e),vr(e)),t==="debug"?br(e):wr(e),si(e),rc(e,t,!1)}function uh(e,t,n){zp({nextTheme:t,applyTheme:()=>{e.theme=t,ze(e,{...e.settings,theme:t}),$i(e,hr(t))},context:n,currentTheme:e.theme})}async function si(e){if(e.tab==="overview"&&await oc(e),e.tab==="channels"&&await yh(e),e.tab==="instances"&&await jl(e),e.tab==="cron"&&await kr(e),e.tab==="skills"&&await lt(e),e.tab==="nodes"&&(await pr(e),await dr(e),await _e(e),await Dp(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await Sh(e),fn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await Sl(e),await _e(e)),e.tab==="debug"&&(await rr(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await ie(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>Zl);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Et(e,{reset:!0});wl(e,!0)}}function dh(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?xi(e):Up(window.location.pathname)}function ph(e){e.theme=e.settings.theme??"system",$i(e,hr(e.theme))}function $i(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function hh(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"&&$i(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function fh(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 gh(e,t){if(typeof window>"u")return;const n=Xl(window.location.pathname,e.basePath)??"chat";sc(e,n),rc(e,n,t)}function mh(e){var s;if(typeof window>"u")return;const t=Xl(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,ze(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),sc(e,t)}function sc(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?yr(e):gr(e):(mr(e),vr(e)),t==="debug"?br(e):wr(e),e.connected&&si(e)}function rc(e,t,n){if(typeof window>"u")return;const i=hn(Fp(t,e.basePath)),s=hn(window.location.pathname),r=new URL(window.location.href);t==="chat"&&e.sessionKey?r.searchParams.set("session",e.sessionKey):r.searchParams.delete("session"),s!==i&&(r.pathname=i),n?window.history.replaceState({},"",r.toString()):window.history.pushState({},"",r.toString())}async function oc(e){await Promise.all([V(e,!1),jl(e),nr(e),gn(e),rr(e)])}async function yh(e){await Promise.all([V(e,!0),Sl(e),_e(e)])}async function kr(e){await Promise.all([V(e,!1),gn(e),ki(e)])}function ac(e){return e.chatSending||!!e.chatRunId}function vh(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 lc(e){e.connected&&(e.chatMessage="",await vl(e))}function bh(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:tr(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(r=>({...r})):void 0}],fn(e))}async function cc(e,t,n){var s,r;ir(e);const i=await yl(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&&ic(e,e.sessionKey),i&&(n!=null&&n.restoreDraft)&&((s=n.previousDraft)!=null&&s.trim())&&(e.chatMessage=n.previousDraft),i&&(n!=null&&n.restoreAttachments)&&((r=n.previousAttachments)!=null&&r.length)&&(e.chatAttachments=n.previousAttachments),fn(e),i&&!e.chatRunId&&uc(e),i}async function uc(e){if(!e.connected||ac(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await cc(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function wh(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function kh(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),r=e.chatAttachments??[],o=t==null?r:[],a=o.length>0;if(!(!s&&!a)){if(vh(s)){await lc(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),ac(e)){bh(e,s,o);return}await cc(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:a?o:void 0,previousAttachments:t==null?r:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function Sh(e){await Promise.all([Te(e),nr(e),Ls(e)]),fn(e,!0)}const Ah=uc;function xh(e){var s,r,o;const t=cl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((o=(r=n==null?void 0:n.sessionDefaults)==null?void 0:r.defaultAgentId)==null?void 0:o.trim())||"main"}function $h(e,t){const n=xi(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Ls(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=xh(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=$h(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),r=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=r||null}catch{e.chatAvatarUrl=null}}const O={messageSquare:p`<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:p`<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:p`<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>`,radio:p`<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:p`<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:p`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:p`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:p`<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:p`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:p`<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:p`<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:p`<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:p`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:p`<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:p`<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:p`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:p`<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:p`<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:p`<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>`,chevronDown:p`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:p`<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>`},Eh="Taskmaster",Ch="/taskmaster-icon.png",dc="#00d4ff";let Dn=null;function qe(){return Dn||(Dn={name:window.__TASKMASTER_BRAND_NAME__||Eh,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||Ch,accentColor:window.__TASKMASTER_ACCENT_COLOR__||dc},Dn)}function Th(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 _h(e){if(e===dc)return;const t=Th(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 Mh=p`<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>`,Ph=p`<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 Io=!1;function Lh(){Io||(Io=!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 pt(e,t){const n=(l,d)=>l===e?p`<span class="sp-page-nav-current">${l}</span>`:p`<a href=${d}>${l}</a>`,i=p`
19
+ `],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),r=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-session-logs-${t}-${r}.log`,s.click(),URL.revokeObjectURL(i)}function jd(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 He(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function st(e){return`${JSON.stringify(e,null,2).trimEnd()}
20
+ `}function wl(e,t,n){if(t.length===0)return;let i=e;for(let r=0;r<t.length-1;r+=1){const o=t[r],a=t[r+1];if(typeof o=="number"){if(!Array.isArray(i))return;i[o]==null&&(i[o]=typeof a=="number"?[]:{}),i=i[o]}else{if(typeof i!="object"||i==null)return;const c=i;c[o]==null&&(c[o]=typeof a=="number"?[]:{}),i=c[o]}}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 _e(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});qd(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function kl(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});Hd(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function Hd(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function qd(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?st(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=st(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=He(t.config??{}),e.configFormOriginal=He(t.config??{}),e.configRawOriginal=n)}async function Vd(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?st(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 _e(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function gn(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 ki(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 Gd(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=ti(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 Qd(e){if(e.payloadKind==="systemEvent"){const s=e.payloadText.trim();if(!s)throw new Error("System event text required.");return{kind:"systemEvent",text:s}}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),e.to.trim()&&(n.to=e.to.trim());const i=ti(e.timeoutSeconds,0);return i>0&&(n.timeoutSeconds=i),n}async function Yd(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=Gd(e.cronForm),i=Qd(e.cronForm),s=e.cronForm.agentId.trim(),r=(t=e.cronForm.accountId)==null?void 0:t.trim(),o={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:r||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(!o.name)throw new Error("Name required.");await e.client.request("cron.add",o),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await ki(e),await gn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Xd(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 ki(e),await gn(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function Zd(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 Cs(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Jd(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 ki(e),await gn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Cs(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 V(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 sr(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 Sl(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 Al(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 r=He(s.config??{});(!r.channels||typeof r.channels!="object")&&(r.channels={});const o=r.channels;(!o.whatsapp||typeof o.whatsapp!="object")&&(o.whatsapp={});const a=o.whatsapp;(!a.accounts||typeof a.accounts!="object")&&(a.accounts={});const c=a.accounts;if(c[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}c[i]={name:n,provider:"baileys"};const u=s.hash;if(!u){e.whatsappAccountError="Config hash missing; reload and retry.";return}const l=st(r);await e.client.request("config.set",{raw:l,baseHash:u}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await V(e,!0),await sr(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function $l(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=He(n.config??{}),s=i.channels,r=s==null?void 0:s.whatsapp,o=r==null?void 0:r.accounts;if(!o){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(o).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!o[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete o[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(l=>{const d=l.match;return!d||d.channel!=="whatsapp"?!0:d.accountId!==t}));const c=n.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const u=st(i);await e.client.request("config.set",{raw:u,baseHash:c}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await V(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const ep=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:xl,loadChannels:V,logoutWhatsApp:Al,removeWhatsAppAccount:$l,startWhatsAppLogin:sr,waitWhatsAppLogin:Sl},Symbol.toStringTag,{value:"Module"}));async function rr(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 r=i;e.debugModels=Array.isArray(r==null?void 0:r.models)?r==null?void 0:r.models:[],e.debugHeartbeat=s}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const tp=2e3,np=new Set(["trace","debug","info","warn","error","fatal"]);function ip(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 sp(e){if(typeof e!="string")return null;const t=e.toLowerCase();return np.has(t)?t:null}function El(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=sp((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),r=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,o=ip(r);let a=null;o&&(typeof o.subsystem=="string"?a=o.subsystem:typeof o.module=="string"&&(a=o.module)),!a&&r&&r.length<120&&(a=r);let c=null;return typeof t[1]=="string"?c=t[1]:!o&&typeof t[0]=="string"?c=t[0]:typeof t.message=="string"&&(c=t.message),{raw:e,time:i,level:s,subsystem:a,message:c??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Et(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}),r=(Array.isArray(i.lines)?i.lines.filter(a=>typeof a=="string"):[]).map(El),o=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=o?r:[...e.logsEntries,...r].slice(-tp),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 rp=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Et,parseLogLine:El},Symbol.toStringTag,{value:"Module"}));const Cl={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:re,n:Vn,Gx:Co,Gy:To,a:Xi,d:Zi,h:op}=Cl,rt=32,or=64,ap=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},ee=(e="")=>{const t=new Error(e);throw ap(t,ee),t},lp=e=>typeof e=="bigint",cp=e=>typeof e=="string",up=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",Ve=(e,t,n="")=>{const i=up(e),s=e==null?void 0:e.length,r=t!==void 0;if(!i||r&&s!==t){const o=n&&`"${n}" `,a=r?` of length ${t}`:"",c=i?`length=${s}`:`type=${typeof e}`;ee(o+"expected Uint8Array"+a+", got "+c)}return e},Si=e=>new Uint8Array(e),Tl=e=>Uint8Array.from(e),_l=(e,t)=>e.toString(16).padStart(t,"0"),Ml=e=>Array.from(Ve(e)).map(t=>_l(t,2)).join(""),Ie={_0:48,_9:57,A:65,F:70,a:97,f:102},_o=e=>{if(e>=Ie._0&&e<=Ie._9)return e-Ie._0;if(e>=Ie.A&&e<=Ie.F)return e-(Ie.A-10);if(e>=Ie.a&&e<=Ie.f)return e-(Ie.a-10)},Pl=e=>{const t="hex invalid";if(!cp(e))return ee(t);const n=e.length,i=n/2;if(n%2)return ee(t);const s=Si(i);for(let r=0,o=0;r<i;r++,o+=2){const a=_o(e.charCodeAt(o)),c=_o(e.charCodeAt(o+1));if(a===void 0||c===void 0)return ee(t);s[r]=a*16+c}return s},Ll=()=>globalThis==null?void 0:globalThis.crypto,dp=()=>{var e;return((e=Ll())==null?void 0:e.subtle)??ee("crypto.subtle must be defined, consider polyfill")},pn=(...e)=>{const t=Si(e.reduce((i,s)=>i+Ve(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},pp=(e=rt)=>Ll().getRandomValues(Si(e)),ni=BigInt,Je=(e,t,n,i="bad number: out of range")=>lp(e)&&t<=e&&e<n?e:ee(i),P=(e,t=re)=>{const n=e%t;return n>=0n?n:t+n},Il=e=>P(e,Vn),hp=(e,t)=>{(e===0n||t<=0n)&&ee("no inverse n="+e+" mod="+t);let n=P(e,t),i=t,s=0n,r=1n;for(;n!==0n;){const o=i/n,a=i%n,c=s-r*o;i=n,n=a,s=r,r=c}return i===1n?P(s,t):ee("no inverse")},fp=e=>{const t=Ol[e];return typeof t!="function"&&ee("hashes."+e+" not set"),t},Ji=e=>e instanceof ot?e:ee("Point expected"),Ts=2n**256n,Ce=class Ce{constructor(t,n,i,s){U(this,"X");U(this,"Y");U(this,"Z");U(this,"T");const r=Ts;this.X=Je(t,0n,r),this.Y=Je(n,0n,r),this.Z=Je(i,1n,r),this.T=Je(s,0n,r),Object.freeze(this)}static CURVE(){return Cl}static fromAffine(t){return new Ce(t.x,t.y,1n,P(t.x*t.y))}static fromBytes(t,n=!1){const i=Zi,s=Tl(Ve(t,rt)),r=t[31];s[31]=r&-129;const o=Nl(s);Je(o,0n,n?Ts:re);const c=P(o*o),u=P(c-1n),l=P(i*c+1n);let{isValid:d,value:h}=mp(u,l);d||ee("bad point: y not sqrt");const v=(h&1n)===1n,y=(r&128)!==0;return!n&&h===0n&&y&&ee("bad point: x==0, isLastByteOdd"),y!==v&&(h=P(-h)),new Ce(h,o,1n,P(h*o))}static fromHex(t,n){return Ce.fromBytes(Pl(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Xi,n=Zi,i=this;if(i.is0())return ee("bad point: ZERO");const{X:s,Y:r,Z:o,T:a}=i,c=P(s*s),u=P(r*r),l=P(o*o),d=P(l*l),h=P(c*t),v=P(l*P(h+u)),y=P(d+P(n*P(c*u)));if(v!==y)return ee("bad point: equation left != right (1)");const b=P(s*r),S=P(o*a);return b!==S?ee("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:r,Y:o,Z:a}=Ji(t),c=P(n*a),u=P(r*s),l=P(i*a),d=P(o*s);return c===u&&l===d}is0(){return this.equals(xt)}negate(){return new Ce(P(-this.X),this.Y,this.Z,P(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=Xi,r=P(t*t),o=P(n*n),a=P(2n*P(i*i)),c=P(s*r),u=t+n,l=P(P(u*u)-r-o),d=c+o,h=d-a,v=c-o,y=P(l*h),b=P(d*v),S=P(l*v),x=P(h*d);return new Ce(y,b,x,S)}add(t){const{X:n,Y:i,Z:s,T:r}=this,{X:o,Y:a,Z:c,T:u}=Ji(t),l=Xi,d=Zi,h=P(n*o),v=P(i*a),y=P(r*d*u),b=P(s*c),S=P((n+i)*(o+a)-h-v),x=P(b-y),$=P(b+y),C=P(v-l*h),T=P(S*x),M=P($*C),R=P(S*C),B=P(x*$);return new Ce(T,M,B,R)}subtract(t){return this.add(Ji(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return xt;if(Je(t,1n,Vn),t===1n)return this;if(this.equals(at))return Cp(t).p;let i=xt,s=at;for(let r=this;t>0n;r=r.double(),t>>=1n)t&1n?i=i.add(r):n&&(s=s.add(r));return i}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:i}=this;if(this.equals(xt))return{x:0n,y:1n};const s=hp(i,re);P(i*s)!==1n&&ee("invalid inverse");const r=P(t*s),o=P(n*s);return{x:r,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Rl(n);return i[31]|=t&1n?128:0,i}toHex(){return Ml(this.toBytes())}clearCofactor(){return this.multiply(ni(op),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Vn/2n,!1).double();return Vn%2n&&(t=t.add(this)),t.is0()}};U(Ce,"BASE"),U(Ce,"ZERO");let ot=Ce;const at=new ot(Co,To,1n,P(Co*To)),xt=new ot(0n,1n,1n,0n);ot.BASE=at;ot.ZERO=xt;const Rl=e=>Pl(_l(Je(e,0n,Ts),or)).reverse(),Nl=e=>ni("0x"+Ml(Tl(Ve(e)).reverse())),Ae=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=re;return n},gp=e=>{const n=e*e%re*e%re,i=Ae(n,2n)*n%re,s=Ae(i,1n)*e%re,r=Ae(s,5n)*s%re,o=Ae(r,10n)*r%re,a=Ae(o,20n)*o%re,c=Ae(a,40n)*a%re,u=Ae(c,80n)*c%re,l=Ae(u,80n)*c%re,d=Ae(l,10n)*r%re;return{pow_p_5_8:Ae(d,2n)*e%re,b2:n}},Mo=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,mp=(e,t)=>{const n=P(t*t*t),i=P(n*n*t),s=gp(e*i).pow_p_5_8;let r=P(e*n*s);const o=P(t*r*r),a=r,c=P(r*Mo),u=o===e,l=o===P(-e),d=o===P(-e*Mo);return u&&(r=a),(l||d)&&(r=c),(P(r)&1n)===1n&&(r=P(-r)),{isValid:u||l,value:r}},_s=e=>Il(Nl(e)),ar=(...e)=>Ol.sha512Async(pn(...e)),yp=(...e)=>fp("sha512")(pn(...e)),Dl=e=>{const t=e.slice(0,rt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(rt,or),i=_s(t),s=at.multiply(i),r=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:r}},lr=e=>ar(Ve(e,rt)).then(Dl),vp=e=>Dl(yp(Ve(e,rt))),bp=e=>lr(e).then(t=>t.pointBytes),wp=e=>ar(e.hashable).then(e.finish),kp=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,r=_s(t),o=at.multiply(r).toBytes();return{hashable:pn(o,i,n),finish:u=>{const l=Il(r+_s(u)*s);return Ve(pn(o,Rl(l)),or)}}},Sp=async(e,t)=>{const n=Ve(e),i=await lr(t),s=await ar(i.prefix,n);return wp(kp(i,s,n))},Ol={sha512Async:async e=>{const t=dp(),n=pn(e);return Si(await t.digest("SHA-512",n.buffer))},sha512:void 0},Ap=(e=pp(rt))=>e,xp={getExtendedPublicKeyAsync:lr,getExtendedPublicKey:vp,randomSecretKey:Ap},ii=8,$p=256,Bl=Math.ceil($p/ii)+1,Ms=2**(ii-1),Ep=()=>{const e=[];let t=at,n=t;for(let i=0;i<Bl;i++){n=t,e.push(n);for(let s=1;s<Ms;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Po;const Lo=(e,t)=>{const n=t.negate();return e?n:t},Cp=e=>{const t=Po||(Po=Ep());let n=xt,i=at;const s=2**ii,r=s,o=ni(s-1),a=ni(ii);for(let c=0;c<Bl;c++){let u=Number(e&o);e>>=a,u>Ms&&(u-=r,e+=1n);const l=c*Ms,d=l,h=l+Math.abs(u)-1,v=c%2!==0,y=u<0;u===0?i=i.add(Lo(v,t[d])):n=n.add(Lo(y,t[h]))}return e!==0n&&ee("invalid wnaf"),{p:n,f:i}},es="taskmaster-device-identity-v1";function Ps(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Fl(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 r=0;r<i.length;r+=1)s[r]=i.charCodeAt(r);return s}function Tp(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Ul(e){const t=await crypto.subtle.digest("SHA-256",e);return Tp(new Uint8Array(t))}async function _p(){const e=xp.randomSecretKey(),t=await bp(e);return{deviceId:await Ul(t),publicKey:Ps(t),privateKey:Ps(e)}}async function Mp(){try{const n=localStorage.getItem(es);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 Ul(Fl(i.publicKey));if(s!==i.deviceId){const r={...i,deviceId:s};return localStorage.setItem(es,JSON.stringify(r)),{deviceId:s,publicKey:i.publicKey,privateKey:i.privateKey}}return{deviceId:i.deviceId,publicKey:i.publicKey,privateKey:i.privateKey}}}}catch{}const e=await _p(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(es,JSON.stringify(t)),e}async function Pp(e,t){const n=Fl(e),i=new TextEncoder().encode(t),s=await Sp(i,n);return Ps(s)}const Wl="taskmaster.device.auth.v1";function cr(e){return e.trim()}function Lp(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 ur(){try{const e=window.localStorage.getItem(Wl);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 Kl(e){try{window.localStorage.setItem(Wl,JSON.stringify(e))}catch{}}function Ip(e){const t=ur();if(!t||t.deviceId!==e.deviceId)return null;const n=cr(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function Rp(e){const t=cr(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=ur();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:Lp(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Kl(n),s}function Np(e){const t=ur();if(!t||t.deviceId!==e.deviceId)return;const n=cr(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Kl(i)}async function dr(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 pr(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 Dp(e){return{method:"exec.approvals.get",params:{}}}async function Op(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Dp(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);Bp(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Bp(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=He(t.file??{}))}async function zl(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 _t(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function Ai(e){return e instanceof Error?e.message:String(e)}async function lt(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=Ai(n)}finally{e.skillsLoading=!1}}}function jl(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Hl(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 lt(e),_t(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=Ai(i);e.skillsError=s,_t(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function ql(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 lt(e),_t(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=Ai(n);e.skillsError=i,_t(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Vl(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 lt(e),_t(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const r=Ai(s);e.skillsError=r,_t(e,t,{kind:"error",message:r})}finally{e.skillsBusyKey=null}}}const Fp=Object.freeze(Object.defineProperty({__proto__:null,installSkill:Vl,loadSkills:lt,saveSkillApiKey:ql,updateSkillEdit:jl,updateSkillEnabled:Hl},Symbol.toStringTag,{value:"Module"})),Gl={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},Ql=new Map(Object.entries(Gl).map(([e,t])=>[t,e]));function xi(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function hn(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 Up(e,t=""){const n=xi(t),i=Gl[e];return n?`${n}${i}`:i}function Yl(e,t=""){const n=xi(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=hn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":Ql.get(s)??null}function Wp(e){let t=hn(e);if(t.endsWith("/index.html")&&(t=hn(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(Ql.has(s)){const r=n.slice(0,i);return r.length?`/${r.join("/")}`:""}}return`/${n.join("/")}`}function Kp(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function hr(e){return e==="system"?Kp():e}const In=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,zp=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Rn=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},jp=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var u;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const r=s.documentElement,o=s,a=zp();if(!!o.startViewTransition&&!a){let l=.5,d=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")l=In(n.pointerClientX/window.innerWidth),d=In(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const h=n.element.getBoundingClientRect();h.width>0&&h.height>0&&typeof window<"u"&&(l=In((h.left+h.width/2)/window.innerWidth),d=In((h.top+h.height/2)/window.innerHeight))}r.style.setProperty("--theme-switch-x",`${l*100}%`),r.style.setProperty("--theme-switch-y",`${d*100}%`),r.classList.add("theme-transition");try{const h=(u=o.startViewTransition)==null?void 0:u.call(o,()=>{t()});h!=null&&h.finished?h.finished.finally(()=>Rn(r)):Rn(r)}catch{Rn(r),t()}return}t(),Rn(r)},Hp=2e3;async function rn(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),r=Array.isArray(s.entries)?s.entries:[],o=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=o?r:[...e.sessionLogsEntries,...r].slice(-Hp),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 Xl=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:rn},Symbol.toStringTag,{value:"Module"}));async function Zl(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 qp(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 Nn=null;function mn(e,t){Nn&&clearTimeout(Nn),e.filesMessage={kind:"success",text:t},Nn=setTimeout(()=>{e.filesMessage=null,Nn=null},3e3)}async function yn(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 Vp(e,t,n){e.filesSelectedPaths=new Set([t]),await Jl(e,t,n)}async function Gp(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 Jl(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Qp(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let i=0,s="";for(const r of n)try{await ec(e,r,t),i++}catch(o){s=Ne(o)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:mn(e,`${i} file${i!==1?"s":""} downloaded`)}async function Yp(e,t,n,i){const s=t.split("/").pop()??t,r=n==="."?s:`${n}/${s}`;r!==t&&await tc(e,t,r,i)}async function Jl(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 ec(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 r=Uint8Array.from(atob(s.base64),u=>u.charCodeAt(0)),o=new Blob([r]),a=URL.createObjectURL(o),c=document.createElement("a");c.href=a,c.download=s.name??t.split("/").pop()??"download",document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(a)}catch(i){e.filesMessage={kind:"error",text:Ne(i)}}}async function Xp(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,r="";for(const o of n)try{const a=await o.arrayBuffer(),c=btoa(new Uint8Array(a).reduce((l,d)=>l+String.fromCharCode(d),"")),u={path:t,name:o.name,data:c};i&&(u.agentId=i),await e.client.request("files.upload",u),s++}catch(a){r=Ne(a)}e.filesUploadBusy=!1,r?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${r}`:r}:mn(e,`${s} file${s!==1?"s":""} uploaded`),await yn(e,i)}async function Zp(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),mn(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await yn(e,n)}catch(i){e.filesMessage={kind:"error",text:Ne(i)}}}}async function tc(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),mn(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await yn(e,i)}catch(s){e.filesMessage={kind:"error",text:Ne(s)}}}}async function fr(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 Jp(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,r=(i==null?void 0:i.chunks)??0;mn(e,`Re-indexed: ${s} files, ${r} chunks`),await fr(e,t)}catch(n){e.filesMessage={kind:"error",text:Ne(n)}}finally{e.filesReindexBusy=!1}}}function eh(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n}async function th(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 nh(e){e.filesSearchQuery="",e.filesSearchResults=null}function ih(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{pr(e,{quiet:!0})},5e3))}function sh(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function gr(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Et(e,{quiet:!0})},2e3))}function mr(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function yr(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||rn(e,{quiet:!0})},2e3))}function vr(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function br(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&rr(e)},3e3))}function wr(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function rh(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{Zl(e)},3e4))}function oh(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function ah(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{e.tab==="files"&&fr(e)},3e3))}function lh(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function ze(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,cd(n),t.theme!==e.theme&&(e.theme=t.theme,$i(e,hr(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function nc(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&ze(e,{...e.settings,lastActiveSessionKey:n})}function ch(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"),r=t.get("gatewayUrl");let o=!1;if(n!=null){const c=n.trim();c&&c!==e.settings.token&&ze(e,{...e.settings,token:c}),t.delete("token"),o=!0}if(i!=null){const c=i.trim();c&&(e.password=c),t.delete("password"),o=!0}if(s!=null){const c=s.trim();c&&(e.sessionKey=c,ze(e,{...e.settings,sessionKey:c,lastActiveSessionKey:c}))}if(r!=null){const c=r.trim();c&&c!==e.settings.gatewayUrl&&ze(e,{...e.settings,gatewayUrl:c}),t.delete("gatewayUrl"),o=!0}if(!o)return;const a=new URL(window.location.href);a.search=t.toString(),window.history.replaceState({},"",a.toString())}function uh(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?yr(e):gr(e):(mr(e),vr(e)),t==="debug"?br(e):wr(e),si(e),sc(e,t,!1)}function dh(e,t,n){jp({nextTheme:t,applyTheme:()=>{e.theme=t,ze(e,{...e.settings,theme:t}),$i(e,hr(t))},context:n,currentTheme:e.theme})}async function si(e){if(e.tab==="overview"&&await rc(e),e.tab==="channels"&&await vh(e),e.tab==="instances"&&await zl(e),e.tab==="cron"&&await kr(e),e.tab==="skills"&&await lt(e),e.tab==="nodes"&&(await pr(e),await dr(e),await _e(e),await Op(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await Ah(e),fn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await kl(e),await _e(e)),e.tab==="debug"&&(await rr(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await ie(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>Xl);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Et(e,{reset:!0});bl(e,!0)}}function ph(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?xi(e):Wp(window.location.pathname)}function hh(e){e.theme=e.settings.theme??"system",$i(e,hr(e.theme))}function $i(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function fh(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"&&$i(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function gh(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 mh(e,t){if(typeof window>"u")return;const n=Yl(window.location.pathname,e.basePath)??"chat";ic(e,n),sc(e,n,t)}function yh(e){var s;if(typeof window>"u")return;const t=Yl(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,ze(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),ic(e,t)}function ic(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?yr(e):gr(e):(mr(e),vr(e)),t==="debug"?br(e):wr(e),e.connected&&si(e)}function sc(e,t,n){if(typeof window>"u")return;const i=hn(Up(t,e.basePath)),s=hn(window.location.pathname),r=new URL(window.location.href);t==="chat"&&e.sessionKey?r.searchParams.set("session",e.sessionKey):r.searchParams.delete("session"),s!==i&&(r.pathname=i),n?window.history.replaceState({},"",r.toString()):window.history.pushState({},"",r.toString())}async function rc(e){await Promise.all([V(e,!1),zl(e),nr(e),gn(e),rr(e)])}async function vh(e){await Promise.all([V(e,!0),kl(e),_e(e)])}async function kr(e){await Promise.all([V(e,!1),gn(e),ki(e)])}function oc(e){return e.chatSending||!!e.chatRunId}function bh(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 ac(e){e.connected&&(e.chatMessage="",await yl(e))}function wh(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:tr(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(r=>({...r})):void 0}],fn(e))}async function lc(e,t,n){var s,r;ir(e);const i=await ml(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)&&((r=n.previousAttachments)!=null&&r.length)&&(e.chatAttachments=n.previousAttachments),fn(e),i&&!e.chatRunId&&cc(e),i}async function cc(e){if(!e.connected||oc(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await lc(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function kh(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Sh(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),r=e.chatAttachments??[],o=t==null?r:[],a=o.length>0;if(!(!s&&!a)){if(bh(s)){await ac(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),oc(e)){wh(e,s,o);return}await lc(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:a?o:void 0,previousAttachments:t==null?r:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function Ah(e){await Promise.all([Te(e),nr(e),Ls(e)]),fn(e,!0)}const xh=cc;function $h(e){var s,r,o;const t=ll(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((o=(r=n==null?void 0:n.sessionDefaults)==null?void 0:r.defaultAgentId)==null?void 0:o.trim())||"main"}function Eh(e,t){const n=xi(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Ls(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=$h(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Eh(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),r=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=r||null}catch{e.chatAvatarUrl=null}}const O={messageSquare:p`<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:p`<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:p`<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>`,radio:p`<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:p`<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:p`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:p`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:p`<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:p`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<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:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:p`<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:p`<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:p`<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:p`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:p`<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:p`<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:p`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:p`<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:p`<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:p`<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>`,chevronDown:p`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:p`<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>`},Ch="Taskmaster",Th="/taskmaster-icon.png",uc="#00d4ff";let Dn=null;function qe(){return Dn||(Dn={name:window.__TASKMASTER_BRAND_NAME__||Ch,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||Th,accentColor:window.__TASKMASTER_ACCENT_COLOR__||uc},Dn)}function _h(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 Mh(e){if(e===uc)return;const t=_h(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 Ph=p`<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>`,Lh=p`<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 Io=!1;function Ih(){Io||(Io=!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 pt(e,t){const n=(l,d)=>l===e?p`<span class="sp-page-nav-current">${l}</span>`:p`<a href=${d}>${l}</a>`,i=p`
21
21
  ${n("Setup","/setup")}
22
22
  ${n("Chat","/chat")}
23
23
  ${n("Admins","/admins")}
@@ -25,10 +25,10 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
25
25
  ${n("Files","/files")}
26
26
  ${n("Browser","/browser")}
27
27
  ${n("Advanced","/advanced")}
28
- `,r=t&&(t.isMaster!==!1||!t.hasPins)?Ih(t):k,o=t!=null&&t.hasPins&&t.onLogout?p`<button class="nav-logout-btn" @click=${t.onLogout} title="Lock">${Mh}</button>`:k,a=(t==null?void 0:t.auditCount)??0,c=a>0&&(t!=null&&t.onAuditClick)?p`<button class="nav-audit-btn" @click=${t.onAuditClick} title="Memory writes to review">
29
- ${Ph}
28
+ `,r=t&&(t.isMaster!==!1||!t.hasPins)?Rh(t):k,o=t!=null&&t.hasPins&&t.onLogout?p`<button class="nav-logout-btn" @click=${t.onLogout} title="Lock">${Ph}</button>`:k,a=(t==null?void 0:t.auditCount)??0,c=a>0&&(t!=null&&t.onAuditClick)?p`<button class="nav-audit-btn" @click=${t.onAuditClick} title="Memory writes to review">
29
+ ${Lh}
30
30
  <span class="nav-audit-badge">${a>99?"99+":a}</span>
31
- </button>`:k,u=()=>{const l=document.getElementById("nav-burger-toggle");l&&(l.checked=!1)};return Lh(),p`
31
+ </button>`:k,u=()=>{const l=document.getElementById("nav-burger-toggle");l&&(l.checked=!1)};return Ih(),p`
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 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
50
50
  ${i}
51
51
  </nav>
52
52
  </div>
53
- `}function Ih(e){const{workspaces:t,selectedWorkspace:n,onWorkspaceSelect:i}=e;return p`
53
+ `}function Rh(e){const{workspaces:t,selectedWorkspace:n,onWorkspaceSelect:i}=e;return p`
54
54
  <select
55
55
  class="sp-workspace-selector"
56
56
  .value=${n??""}
@@ -64,7 +64,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
64
64
  <option disabled>───</option>
65
65
  <option value="__add__">+ Add Account</option>
66
66
  </select>
67
- `}function Rh(e){return e.connected?e.fullscreen&&e.active?p`
67
+ `}function Nh(e){return e.connected?e.fullscreen&&e.active?p`
68
68
  <div class="sp-fullscreen-overlay">
69
69
  <div class="sp-fullscreen-toolbar">
70
70
  <button
@@ -196,20 +196,20 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
196
196
  <p>Connecting to gateway...</p>
197
197
  </div>
198
198
  </div>
199
- `}const ri="application/x-taskmaster-file-path";function pc(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function hc(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function Nh(e,t,n){var r,o;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const i=(r=e.dataTransfer)==null?void 0:r.getData(ri);if(i){hc(i)!==t&&n.onMoveToDir(i,t);return}const s=(o=e.dataTransfer)==null?void 0:o.files;if(s&&s.length>0){const a=Array.from(s).filter(c=>c.name.toLowerCase().endsWith(".md"));a.length>0&&n.onUpload(t,a)}}function fc(e,t,n){const i=e.type==="directory"||e.type==="symlink"&&e.children!=null,s=t.expandedDirs.has(e.path),r=t.selectedPaths.has(e.path),o=n*20+12;return i?p`
199
+ `}const ri="application/x-taskmaster-file-path";function dc(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function pc(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function Dh(e,t,n){var r,o;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const i=(r=e.dataTransfer)==null?void 0:r.getData(ri);if(i){pc(i)!==t&&n.onMoveToDir(i,t);return}const s=(o=e.dataTransfer)==null?void 0:o.files;if(s&&s.length>0){const a=Array.from(s).filter(c=>c.name.toLowerCase().endsWith(".md"));a.length>0&&n.onUpload(t,a)}}function hc(e,t,n){const i=e.type==="directory"||e.type==="symlink"&&e.children!=null,s=t.expandedDirs.has(e.path),r=t.selectedPaths.has(e.path),o=n*20+12;return i?p`
200
200
  <div
201
201
  class="sp-tree-item sp-tree-dir ${s?"expanded":""}"
202
202
  style="padding-left: ${o}px;"
203
203
  @click=${()=>t.onToggleDir(e.path)}
204
204
  @dragover=${a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&(a.dataTransfer.dropEffect="move"),a.currentTarget.classList.add("sp-drop-target")}}
205
205
  @dragleave=${a=>{a.currentTarget.classList.remove("sp-drop-target")}}
206
- @drop=${a=>Nh(a,e.path,t)}
206
+ @drop=${a=>Dh(a,e.path,t)}
207
207
  >
208
208
  <span class="sp-tree-chevron">${s?"−":"+"}</span>
209
209
  <span class="sp-tree-icon">${O.folder}</span>
210
210
  <span class="sp-tree-name">${e.name}</span>
211
211
  </div>
212
- ${s&&e.children?e.children.map(a=>fc(a,t,n+1)):k}
212
+ ${s&&e.children?e.children.map(a=>hc(a,t,n+1)):k}
213
213
  `:p`
214
214
  <div
215
215
  class="sp-tree-item sp-tree-file ${r?"selected":""}"
@@ -220,9 +220,9 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
220
220
  >
221
221
  <span class="sp-tree-icon">${O.fileText}</span>
222
222
  <span class="sp-tree-name">${e.name}</span>
223
- <span class="sp-tree-size">${pc(e.size)}</span>
223
+ <span class="sp-tree-size">${dc(e.size)}</span>
224
224
  </div>
225
- `}function Dh(e){const t=e.selectedPaths.size;return t<2?k:p`
225
+ `}function Oh(e){const t=e.selectedPaths.size;return t<2?k:p`
226
226
  <div class="sp-bulk-actions">
227
227
  <span style="color: var(--tasker-muted-grey); font-size: 13px;">${t} files selected</span>
228
228
  <button
@@ -233,7 +233,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
233
233
  Download ${t} files
234
234
  </button>
235
235
  </div>
236
- `}function Oh(e){if(e.selectedPaths.size!==1||!e.selectedPath)return k;if(e.previewLoading)return p`
236
+ `}function Bh(e){if(e.selectedPaths.size!==1||!e.selectedPath)return k;if(e.previewLoading)return p`
237
237
  <div class="sp-file-preview">
238
238
  <div class="setup-spinner" style="width: 32px; height: 32px; margin: 24px auto;"></div>
239
239
  </div>
@@ -243,7 +243,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
243
243
  <div>
244
244
  <strong>${t}</strong>
245
245
  <div class="sp-file-preview-meta">
246
- ${e.selectedPath}${e.previewSize!=null?` — ${pc(e.previewSize)}`:""}
246
+ ${e.selectedPath}${e.previewSize!=null?` — ${dc(e.previewSize)}`:""}
247
247
  </div>
248
248
  </div>
249
249
  <div class="sp-file-actions">
@@ -260,7 +260,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
260
260
  </div>
261
261
  ${e.previewBinary?p`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">Binary file — use Download to view.</p></div>`:e.previewContent!=null?p`<div class="sp-file-preview-body"><pre class="sp-file-code">${e.previewContent}</pre></div>`:p`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">File too large for preview — use Download.</p></div>`}
262
262
  </div>
263
- `}function Bh(e){if(!e.selectedPath)return".";if(e.expandedDirs.has(e.selectedPath))return e.selectedPath;const t=e.selectedPath.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function Fh(e){return p`
263
+ `}function Fh(e){if(!e.selectedPath)return".";if(e.expandedDirs.has(e.selectedPath))return e.selectedPath;const t=e.selectedPath.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function Uh(e){return p`
264
264
  <div class="sp-search-bar">
265
265
  <input
266
266
  type="text"
@@ -292,7 +292,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
292
292
  Clear
293
293
  </button>`:k}
294
294
  </div>
295
- `}function Uh(e){return e.searchResults?e.searchResults.length===0?p`<div class="sp-search-results">
295
+ `}function Wh(e){return e.searchResults?e.searchResults.length===0?p`<div class="sp-search-results">
296
296
  <div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No results found.</div>
297
297
  </div>`:p`
298
298
  <div class="sp-search-results">
@@ -312,7 +312,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
312
312
  </div>
313
313
  `)}
314
314
  </div>
315
- `:k}function Wh(e){const t=Bh(e);return e.connected?p`
315
+ `:k}function Kh(e){const t=Fh(e);return e.connected?p`
316
316
  <div class="setup-container">
317
317
  ${pt("Files",e.wsProps)}
318
318
  <div class="setup-card sp-card-wide">
@@ -369,18 +369,18 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
369
369
 
370
370
  ${e.uploadBusy?p`<div style="margin-top: 12px; color: var(--tasker-orange); font-weight: 600; font-size: 14px;">Uploading...</div>`:k}
371
371
 
372
- ${Fh(e)}
372
+ ${Uh(e)}
373
373
 
374
- ${e.searchResults!==null?Uh(e):p`<div
374
+ ${e.searchResults!==null?Wh(e):p`<div
375
375
  class="sp-file-tree"
376
376
  @dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(ri)?"move":"copy")}}
377
- @drop=${n=>{var r,o;n.preventDefault();const i=(r=n.dataTransfer)==null?void 0:r.getData(ri);if(i){hc(i)!=="."&&e.onMoveToDir(i,".");return}const s=(o=n.dataTransfer)==null?void 0:o.files;if(s&&s.length>0){const a=Array.from(s).filter(c=>c.name.toLowerCase().endsWith(".md"));a.length>0&&e.onUpload(t,a)}}}
377
+ @drop=${n=>{var r,o;n.preventDefault();const i=(r=n.dataTransfer)==null?void 0:r.getData(ri);if(i){pc(i)!=="."&&e.onMoveToDir(i,".");return}const s=(o=n.dataTransfer)==null?void 0:o.files;if(s&&s.length>0){const a=Array.from(s).filter(c=>c.name.toLowerCase().endsWith(".md"));a.length>0&&e.onUpload(t,a)}}}
378
378
  >
379
- ${e.tree.length===0&&!e.loading?p`<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=>fc(n,e,0))}
379
+ ${e.tree.length===0&&!e.loading?p`<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=>hc(n,e,0))}
380
380
  </div>`}
381
381
 
382
- ${Dh(e)}
383
382
  ${Oh(e)}
383
+ ${Bh(e)}
384
384
  </div>
385
385
  </div>
386
386
  `:p`
@@ -390,7 +390,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
390
390
  <p>Connecting to gateway...</p>
391
391
  </div>
392
392
  </div>
393
- `}const Sr="taskmaster_uninstall_done";async function Kh(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),zh();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 oi(){try{return localStorage.getItem(Sr)==="1"}catch{return!1}}function Ar(){try{localStorage.removeItem(Sr)}catch{}}function zh(){try{localStorage.setItem(Sr,"1")}catch{}}const Ro=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:oi,clearUninstallDone:Ar,runUninstall:Kh},Symbol.toStringTag,{value:"Module"}));function he(e){return p`
393
+ `}const Sr="taskmaster_uninstall_done";async function zh(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),jh();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 oi(){try{return localStorage.getItem(Sr)==="1"}catch{return!1}}function Ar(){try{localStorage.removeItem(Sr)}catch{}}function jh(){try{localStorage.setItem(Sr,"1")}catch{}}const Ro=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:oi,clearUninstallDone:Ar,runUninstall:zh},Symbol.toStringTag,{value:"Module"}));function he(e){return p`
394
394
  <span
395
395
  class="setup-status-light"
396
396
  style="background: ${{good:"#22c55e",bad:"#ef4444",partial:"#eab308",unknown:"#6b7280"}[e]}"
@@ -403,7 +403,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
403
403
  >
404
404
  ${O.info}
405
405
  </button>
406
- `}function jh(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 r="N/A";if(s!=null&&s>0)if(s>60){const o=Math.floor(s/60),a=s%60;r=a>0?`${o}h ${a}m`:`${o}h`}else r=`${s}m`;t="Claude",n=[{label:"Connected",value:e.authConnected?"Yes":"No"},{label:"Token Expiry",value:r},{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=Rt(e),r=s?xr(s,e):null;t="WhatsApp",n=[{label:"Account",value:(r==null?void 0:r.name)||(r==null?void 0:r.accountId)||"Default"},{label:"Phone",value:((i=r==null?void 0:r.self)==null?void 0:i.e164)||"Not paired"},{label:"Connected",value:r!=null&&r.connected?"Yes":"No"},{label:"Linked",value:r!=null&&r.linked?"Yes":"No"},...r!=null&&r.lastError?[{label:"Last Error",value:r.lastError}]:[]];break}case"imessage":{const{thisWsOwns:s}=$r(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}default:return k}return p`
406
+ `}function Hh(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 r="N/A";if(s!=null&&s>0)if(s>60){const o=Math.floor(s/60),a=s%60;r=a>0?`${o}h ${a}m`:`${o}h`}else r=`${s}m`;t="Claude",n=[{label:"Connected",value:e.authConnected?"Yes":"No"},{label:"Token Expiry",value:r},{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=Rt(e),r=s?xr(s,e):null;t="WhatsApp",n=[{label:"Account",value:(r==null?void 0:r.name)||(r==null?void 0:r.accountId)||"Default"},{label:"Phone",value:((i=r==null?void 0:r.self)==null?void 0:i.e164)||"Not paired"},{label:"Connected",value:r!=null&&r.connected?"Yes":"No"},{label:"Linked",value:r!=null&&r.linked?"Yes":"No"},...r!=null&&r.lastError?[{label:"Last Error",value:r.lastError}]:[]];break}case"imessage":{const{thisWsOwns:s}=$r(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}default:return k}return p`
407
407
  <div class="setup-info-overlay" @click=${s=>{s.target.classList.contains("setup-info-overlay")&&e.onInfoModalClose()}}>
408
408
  <div class="setup-info-card">
409
409
  <h3>${t}</h3>
@@ -502,7 +502,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
502
502
  </p>
503
503
  </div>
504
504
  </div>
505
- `}function Hh(e){const{authConnected:t,authBusy:n,authMessage:i,authUrl:s,authCodeInput:r,authExpiresIn:o,onStartAuth:a,onSubmitAuthCode:c,onAuthCodeChange:u,onSkipToWhatsApp:l}=e;return t===!0?p`
505
+ `}function qh(e){const{authConnected:t,authBusy:n,authMessage:i,authUrl:s,authCodeInput:r,authExpiresIn:o,onStartAuth:a,onSubmitAuthCode:c,onAuthCodeChange:u,onSkipToWhatsApp:l}=e;return t===!0?p`
506
506
  <div class="setup-container">
507
507
  <div class="setup-card setup-success">
508
508
  ${be("auth")}
@@ -805,7 +805,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
805
805
  </div>
806
806
  `:k}
807
807
  </div>
808
- `}const qh=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],Vh="anthropic/claude-sonnet-4-5-20250929",Gh=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function Qh(e){if(!e.whatsappSettingsOpen)return k;const t=Rt(e);if(!t)return k;const n=xr(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected);if(!n||!i)return k;const s=()=>e.onWhatsAppSettingsClose(),r=e.whatsappModelCatalog??[],o=new Set(r.filter(l=>l.provider==="anthropic").map(l=>l.id)),a=qh.filter(l=>o.has(l.id)),c=e.whatsappModel??Vh,u=e.whatsappThinkingLevel??"off";return p`
808
+ `}const Vh=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],Gh="anthropic/claude-sonnet-4-5-20250929",Qh=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function Yh(e){if(!e.whatsappSettingsOpen)return k;const t=Rt(e);if(!t)return k;const n=xr(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected);if(!n||!i)return k;const s=()=>e.onWhatsAppSettingsClose(),r=e.whatsappModelCatalog??[],o=new Set(r.filter(l=>l.provider==="anthropic").map(l=>l.id)),a=Vh.filter(l=>o.has(l.id)),c=e.whatsappModel??Gh,u=e.whatsappThinkingLevel??"off";return p`
809
809
  <div class="setup-info-overlay" @click=${l=>{l.target.classList.contains("setup-info-overlay")&&s()}}>
810
810
  <div class="setup-info-card" style="max-width: 360px;">
811
811
  <h3>Public Agent Settings</h3>
@@ -891,7 +891,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
891
891
  .value=${u}
892
892
  @change=${l=>{e.onWhatsAppThinkingChange(l.target.value)}}
893
893
  >
894
- ${Gh.map(l=>p`
894
+ ${Qh.map(l=>p`
895
895
  <option value=${l.value} ?selected=${u===l.value}>
896
896
  ${l.label}
897
897
  </option>
@@ -926,7 +926,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
926
926
  </button>
927
927
  ${k}
928
928
  </div>
929
- `}function Yh(e){if(!e.imessageEnableConfirm)return k;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=$r(e),s=()=>{e.onIMessageEnableCancel()};return n?p`
929
+ `}function Xh(e){if(!e.imessageEnableConfirm)return k;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=$r(e),s=()=>{e.onIMessageEnableCancel()};return n?p`
930
930
  <div class="setup-info-overlay" @click=${r=>{r.target.classList.contains("setup-info-overlay")&&s()}}>
931
931
  <div class="setup-info-card" style="text-align: center;">
932
932
  <h3>iMessage</h3>
@@ -1016,8 +1016,8 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
1016
1016
  >Manage</button>
1017
1017
  </div>
1018
1018
  </div>
1019
- ${Xh(e)}
1020
- `}function Xh(e){if(!e.apiKeyModalOpen)return k;const t=e.apiKeyProviders,n={};for(const u of t)u.key&&(n[u.id]=u.key);const i=(u,l)=>{const d=l==null?void 0:l.closest(".setup-apikey-input"),h=d==null?void 0:d.querySelector("input"),v=h==null?void 0:h.value.trim();!v||v===n[u]||e.onApiKeySave(u,v)},s=u=>{const l=u.currentTarget,d=l.closest(".setup-apikey-input"),h=d==null?void 0:d.querySelector("input");if(!h)return;const v=h.type==="text";h.type=v?"password":"text",l.classList.toggle("active",!v)},r=(u,l)=>{const d=l.target,h=d.closest(".setup-apikey-input"),v=d.value.trim(),y=v.length>0&&v!==n[u],b=h==null?void 0:h.querySelector(".setup-apikey-save");b&&(b.style.display=y?"":"none");const S=h==null?void 0:h.querySelector(".setup-apikey-eye");S&&(S.style.display=v.length>0?"":"none")},o=t.filter(u=>u.primary),a=t.filter(u=>!u.primary),c=u=>{const l=e.apiKeySavingProvider===u.id&&e.apiKeyBusy,d=!e.apiKeyBusy&&e.apiKeySuccess===`${u.id} key saved`,h=!e.apiKeyBusy&&e.apiKeySuccess===`${u.id} key removed`;return p`
1019
+ ${Zh(e)}
1020
+ `}function Zh(e){if(!e.apiKeyModalOpen)return k;const t=e.apiKeyProviders,n={};for(const u of t)u.key&&(n[u.id]=u.key);const i=(u,l)=>{const d=l==null?void 0:l.closest(".setup-apikey-input"),h=d==null?void 0:d.querySelector("input"),v=h==null?void 0:h.value.trim();!v||v===n[u]||e.onApiKeySave(u,v)},s=u=>{const l=u.currentTarget,d=l.closest(".setup-apikey-input"),h=d==null?void 0:d.querySelector("input");if(!h)return;const v=h.type==="text";h.type=v?"password":"text",l.classList.toggle("active",!v)},r=(u,l)=>{const d=l.target,h=d.closest(".setup-apikey-input"),v=d.value.trim(),y=v.length>0&&v!==n[u],b=h==null?void 0:h.querySelector(".setup-apikey-save");b&&(b.style.display=y?"":"none");const S=h==null?void 0:h.querySelector(".setup-apikey-eye");S&&(S.style.display=v.length>0?"":"none")},o=t.filter(u=>u.primary),a=t.filter(u=>!u.primary),c=u=>{const l=e.apiKeySavingProvider===u.id&&e.apiKeyBusy,d=!e.apiKeyBusy&&e.apiKeySuccess===`${u.id} key saved`,h=!e.apiKeyBusy&&e.apiKeySuccess===`${u.id} key removed`;return p`
1021
1021
  <div class="setup-apikey-row">
1022
1022
  <div class="setup-apikey-info">
1023
1023
  <strong>${u.name}</strong>
@@ -1100,7 +1100,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
1100
1100
  </button>
1101
1101
  `}
1102
1102
  </div>
1103
- `}const Zh={anonymous:"Open access",verified:"WhatsApp OTP",choice:"Visitor chooses"};function jo(e){const t=e.publicChatEnabled,n=t?"good":"unknown",i=Zh[e.publicChatAuthMode]??"Open access";return p`
1103
+ `}const Jh={anonymous:"Open access",verified:"WhatsApp OTP",choice:"Visitor chooses"};function jo(e){const t=e.publicChatEnabled,n=t?"good":"unknown",i=Jh[e.publicChatAuthMode]??"Open access";return p`
1104
1104
  <div class="setup-status-item">
1105
1105
  ${he(n)}
1106
1106
  <div class="setup-status-info">
@@ -1124,7 +1124,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
1124
1124
  @click=${e.onPublicChatToggle}
1125
1125
  >${e.publicChatBusy?"...":t?"Disable":"Enable"}</button>
1126
1126
  </div>
1127
- `}function Jh(e){var i,s,r;const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return k;if(t)return p`
1127
+ `}function ef(e){var i,s,r;const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return k;if(t)return p`
1128
1128
  <div class="setup-info-overlay">
1129
1129
  <div class="setup-info-card" style="max-width: 400px;">
1130
1130
  <h3>Software Update</h3>
@@ -1374,7 +1374,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
1374
1374
  <p class="setup-hint" style="margin-top: 4px; font-size: 12px; opacity: 0.6;">
1375
1375
  Need help? <a href="https://wa.me/447591215452" target="_blank" rel="noopener" style="color: var(--tasker-orange);">Message Dave on WhatsApp</a>
1376
1376
  </p>
1377
- `}function ef(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:i,whatsappLoginConnected:s,whatsappChannelStatus:r}=e;if(i)return p`
1377
+ `}function tf(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:i,whatsappLoginConnected:s,whatsappChannelStatus:r}=e;if(i)return p`
1378
1378
  <div class="setup-container">
1379
1379
  <div class="setup-card">
1380
1380
  <h1>Scan with WhatsApp</h1>
@@ -1497,7 +1497,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
1497
1497
  </button>
1498
1498
  </div>
1499
1499
  </div>
1500
- `}function tf(e){const{connected:t,currentStep:n}=e;if(t&&oi()&&Ar(),e.uninstallDone||!t&&oi())return p`
1500
+ `}function nf(e){const{connected:t,currentStep:n}=e;if(t&&oi()&&Ar(),e.uninstallDone||!t&&oi())return p`
1501
1501
  <div class="setup-container">
1502
1502
  <div class="setup-card">
1503
1503
  <p style="color: var(--tasker-danger, #ef4444); font-size: 16px; font-weight: 600; margin: 0 0 12px 0;">
@@ -1520,7 +1520,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
1520
1520
  <p>${r?"Restarting gateway after update…":"Connecting to gateway..."}</p>
1521
1521
  </div>
1522
1522
  </div>
1523
- `}let i;switch(n){case"license":i=No(e);break;case"auth":i=Hh(e);break;case"whatsapp":case"complete":i=ef(e);break;default:i=No(e)}const s=pt("Setup",e.wsProps);return p`${i}${jh(e)}${Yh(e)}${Qh(e)}${Jh(e)}${s}`}function nf(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return p`
1523
+ `}let i;switch(n){case"license":i=No(e);break;case"auth":i=qh(e);break;case"whatsapp":case"complete":i=tf(e);break;default:i=No(e)}const s=pt("Setup",e.wsProps);return p`${i}${Hh(e)}${Xh(e)}${Yh(e)}${ef(e)}${s}`}function sf(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return p`
1524
1524
  <div class="sp-list-item">
1525
1525
  <div class="sp-list-item-main">
1526
1526
  <div class="sp-list-item-title">${e.phone}</div>
@@ -1535,7 +1535,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
1535
1535
  Remove
1536
1536
  </button>`}
1537
1537
  </div>
1538
- `}function sf(e){if(!e.connected)return p`
1538
+ `}function rf(e){if(!e.connected)return p`
1539
1539
  <div class="setup-container">
1540
1540
  <div class="setup-card">
1541
1541
  <div class="setup-spinner"></div>
@@ -1584,7 +1584,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
1584
1584
  </form>
1585
1585
 
1586
1586
  <div class="sp-list" style="margin-top: 20px;">
1587
- ${e.phones.length===0?p`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>nf(n,e))}
1587
+ ${e.phones.length===0?p`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>sf(n,e))}
1588
1588
  </div>
1589
1589
 
1590
1590
  <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
@@ -1595,7 +1595,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
1595
1595
 
1596
1596
  </div>
1597
1597
  </div>
1598
- `}function rf(e){return Object.keys(e.fields).length}function of(e,t){const n=Object.entries(e.fields);return p`
1598
+ `}function of(e){return Object.keys(e.fields).length}function af(e,t){const n=Object.entries(e.fields);return p`
1599
1599
  <div class="customers-record-fields">
1600
1600
  ${n.length===0?p`<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])=>p`
1601
1601
  <div class="customers-field-row">
@@ -1642,7 +1642,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
1642
1642
  </button>
1643
1643
  </div>
1644
1644
  </div>
1645
- `}function af(e,t){const n=t.editingId===e.id,i=rf(e),s=i===0?"No fields":`${i} field${i>1?"s":""}`;return p`
1645
+ `}function lf(e,t){const n=t.editingId===e.id,i=of(e),s=i===0?"No fields":`${i} field${i>1?"s":""}`;return p`
1646
1646
  <div class="customers-record">
1647
1647
  <div
1648
1648
  class="customers-record-header"
@@ -1654,9 +1654,9 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
1654
1654
  </div>
1655
1655
  <span class="customers-record-meta">${s}</span>
1656
1656
  </div>
1657
- ${n?of(e,t):k}
1657
+ ${n?af(e,t):k}
1658
1658
  </div>
1659
- `}function lf(e){if(!e.connected)return p`
1659
+ `}function cf(e){if(!e.connected)return p`
1660
1660
  <div class="setup-container">
1661
1661
  <div class="setup-card">
1662
1662
  <div class="setup-spinner"></div>
@@ -1752,7 +1752,7 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
1752
1752
  <div style="margin-top: 16px;">
1753
1753
  ${e.records.length===0?p`<div class="customers-empty">
1754
1754
  ${e.searchQuery.trim()?`No records matching "${e.searchQuery}".`:"No customer records yet. Add one to get started."}
1755
- </div>`:e.records.map(i=>af(i,e))}
1755
+ </div>`:e.records.map(i=>lf(i,e))}
1756
1756
  </div>
1757
1757
 
1758
1758
  <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
@@ -1763,12 +1763,12 @@ ${r}`:r),e.chatStream="","working"}else if(t.state==="block"){const s=sn(t.messa
1763
1763
  </div>
1764
1764
  </div>
1765
1765
  </div>
1766
- `}const gc={CHILD:2},mc=e=>(...t)=>({_$litDirective$:e,values:t});let yc=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:cf}=Ju,Zo=e=>e,Jo=()=>document.createComment(""),Wt=(e,t,n)=>{var r;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const o=i.insertBefore(Jo(),s),a=i.insertBefore(Jo(),s);n=new cf(o,a,e,e.options)}else{const o=n._$AB.nextSibling,a=n._$AM,c=a!==e;if(c){let u;(r=n._$AQ)==null||r.call(n,e),n._$AM=e,n._$AP!==void 0&&(u=e._$AU)!==a._$AU&&n._$AP(u)}if(o!==s||c){let u=n._$AA;for(;u!==o;){const l=Zo(u).nextSibling;Zo(i).insertBefore(u,s),u=l}}}return n},Ze=(e,t,n=e)=>(e._$AI(t,n),e),uf={},df=(e,t=uf)=>e._$AH=t,pf=e=>e._$AH,ts=e=>{e._$AR(),e._$AA.remove()};const ea=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},hf=mc(class extends yc{constructor(e){if(super(e),e.type!==gc.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=[],r=[];let o=0;for(const a of e)s[o]=i?i(a,o):o,r[o]=n(a,o),o++;return{values:r,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=pf(e),{values:r,keys:o}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=o,r;const a=this.ut??(this.ut=[]),c=[];let u,l,d=0,h=s.length-1,v=0,y=r.length-1;for(;d<=h&&v<=y;)if(s[d]===null)d++;else if(s[h]===null)h--;else if(a[d]===o[v])c[v]=Ze(s[d],r[v]),d++,v++;else if(a[h]===o[y])c[y]=Ze(s[h],r[y]),h--,y--;else if(a[d]===o[y])c[y]=Ze(s[d],r[y]),Wt(e,c[y+1],s[d]),d++,y--;else if(a[h]===o[v])c[v]=Ze(s[h],r[v]),Wt(e,s[d],s[h]),h--,v++;else if(u===void 0&&(u=ea(o,v,y),l=ea(a,d,h)),u.has(a[d]))if(u.has(a[h])){const b=l.get(o[v]),S=b!==void 0?s[b]:null;if(S===null){const x=Wt(e,s[d]);Ze(x,r[v]),c[v]=x}else c[v]=Ze(S,r[v]),Wt(e,s[d],S),s[b]=null;v++}else ts(s[h]),h--;else ts(s[d]),d++;for(;v<=y;){const b=Wt(e,c[y+1]);Ze(b,r[v]),c[v++]=b}for(;d<=h;){const b=s[d++];b!==null&&ts(b)}return this.ut=o,df(e,c),je}});class Is extends yc{constructor(t){if(super(t),this.it=k,t.type!==gc.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===je)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:[]}}}Is.directiveName="unsafeHTML",Is.resultType=1;const ai=mc(Is);const{entries:vc,setPrototypeOf:ta,isFrozen:ff,getPrototypeOf:gf,getOwnPropertyDescriptor:mf}=Object;let{freeze:ue,seal:fe,create:Rs}=Object,{apply:Ns,construct:Ds}=typeof Reflect<"u"&&Reflect;ue||(ue=function(t){return t});fe||(fe=function(t){return t});Ns||(Ns=function(t,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),r=2;r<i;r++)s[r-2]=arguments[r];return t.apply(n,s)});Ds||(Ds=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 On=de(Array.prototype.forEach),yf=de(Array.prototype.lastIndexOf),na=de(Array.prototype.pop),Kt=de(Array.prototype.push),vf=de(Array.prototype.splice),Gn=de(String.prototype.toLowerCase),ns=de(String.prototype.toString),is=de(String.prototype.match),zt=de(String.prototype.replace),bf=de(String.prototype.indexOf),wf=de(String.prototype.trim),me=de(Object.prototype.hasOwnProperty),ae=de(RegExp.prototype.test),jt=kf(TypeError);function de(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 Ns(e,t,i)}}function kf(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Ds(e,n)}}function F(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Gn;ta&&ta(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const r=n(s);r!==s&&(ff(t)||(t[i]=r),s=r)}e[s]=!0}return e}function Sf(e){for(let t=0;t<e.length;t++)me(e,t)||(e[t]=null);return e}function $e(e){const t=Rs(null);for(const[n,i]of vc(e))me(e,n)&&(Array.isArray(i)?t[n]=Sf(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=$e(i):t[n]=i);return t}function Ht(e,t){for(;e!==null;){const i=mf(e,t);if(i){if(i.get)return de(i.get);if(typeof i.value=="function")return de(i.value)}e=gf(e)}function n(){return null}return n}const ia=ue(["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=ue(["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"]),rs=ue(["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"]),Af=ue(["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"]),os=ue(["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"]),xf=ue(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),sa=ue(["#text"]),ra=ue(["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=ue(["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"]),oa=ue(["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"]),Bn=ue(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),$f=fe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ef=fe(/<%[\w\W]*|[\w\W]*%>/gm),Cf=fe(/\$\{[\w\W]*/gm),Tf=fe(/^data-[\-\w.\u00B7-\uFFFF]+$/),_f=fe(/^aria-[\-\w]+$/),bc=fe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Mf=fe(/^(?:\w+script|data):/i),Pf=fe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),wc=fe(/^html$/i),Lf=fe(/^[a-z][.\w]*(-[.\w]+)+$/i);var aa=Object.freeze({__proto__:null,ARIA_ATTR:_f,ATTR_WHITESPACE:Pf,CUSTOM_ELEMENT:Lf,DATA_ATTR:Tf,DOCTYPE_NAME:wc,ERB_EXPR:Ef,IS_ALLOWED_URI:bc,IS_SCRIPT_OR_DATA:Mf,MUSTACHE_EXPR:$f,TMPLIT_EXPR:Cf});const qt={element:1,text:3,progressingInstruction:7,comment:8,document:9},If=function(){return typeof window>"u"?null:window},Rf=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 r="dompurify"+(i?"#"+i:"");try{return t.createPolicy(r,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},la=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function kc(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:If();const t=I=>kc(I);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==qt.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:l=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:h,trustedTypes:v}=e,y=c.prototype,b=Ht(y,"cloneNode"),S=Ht(y,"remove"),x=Ht(y,"nextSibling"),$=Ht(y,"childNodes"),C=Ht(y,"parentNode");if(typeof o=="function"){const I=n.createElement("template");I.content&&I.content.ownerDocument&&(n=I.content.ownerDocument)}let T,M="";const{implementation:R,createNodeIterator:B,createDocumentFragment:J,getElementsByTagName:ge}=n,{importNode:Oe}=i;let X=la();t.isSupported=typeof vc=="function"&&typeof C=="function"&&R&&R.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Dt,ERB_EXPR:gt,TMPLIT_EXPR:Ge,DATA_ATTR:Mi,ARIA_ATTR:Pi,IS_SCRIPT_OR_DATA:Li,ATTR_WHITESPACE:wn,CUSTOM_ELEMENT:Ii}=aa;let{IS_ALLOWED_URI:kn}=aa,G=null;const Sn=F({},[...ia,...ss,...rs,...os,...sa]);let Q=null;const An=F({},[...ra,...as,...oa,...Bn]);let H=Object.seal(Rs(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}})),Qe=null,Ot=null;const Be=Object.seal(Rs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let xn=!0,A=!0,_=!1,N=!0,D=!1,q=!0,z=!1,oe=!1,Fe=!1,mt=!1,$n=!1,En=!1,jr=!0,Hr=!1;const Su="user-content-";let Ri=!0,Bt=!1,yt={},ke=null;const Ni=F({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let qr=null;const Vr=F({},["audio","video","img","source","image","track"]);let Di=null;const Gr=F({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Cn="http://www.w3.org/1998/Math/MathML",Tn="http://www.w3.org/2000/svg",Me="http://www.w3.org/1999/xhtml";let vt=Me,Oi=!1,Bi=null;const Au=F({},[Cn,Tn,Me],ns);let _n=F({},["mi","mo","mn","ms","mtext"]),Mn=F({},["annotation-xml"]);const xu=F({},["title","style","font","a","script"]);let Ft=null;const $u=["application/xhtml+xml","text/html"],Eu="text/html";let Z=null,bt=null;const Cu=n.createElement("form"),Qr=function(w){return w instanceof RegExp||w instanceof Function},Fi=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(bt&&bt===w)){if((!w||typeof w!="object")&&(w={}),w=$e(w),Ft=$u.indexOf(w.PARSER_MEDIA_TYPE)===-1?Eu:w.PARSER_MEDIA_TYPE,Z=Ft==="application/xhtml+xml"?ns:Gn,G=me(w,"ALLOWED_TAGS")?F({},w.ALLOWED_TAGS,Z):Sn,Q=me(w,"ALLOWED_ATTR")?F({},w.ALLOWED_ATTR,Z):An,Bi=me(w,"ALLOWED_NAMESPACES")?F({},w.ALLOWED_NAMESPACES,ns):Au,Di=me(w,"ADD_URI_SAFE_ATTR")?F($e(Gr),w.ADD_URI_SAFE_ATTR,Z):Gr,qr=me(w,"ADD_DATA_URI_TAGS")?F($e(Vr),w.ADD_DATA_URI_TAGS,Z):Vr,ke=me(w,"FORBID_CONTENTS")?F({},w.FORBID_CONTENTS,Z):Ni,Qe=me(w,"FORBID_TAGS")?F({},w.FORBID_TAGS,Z):$e({}),Ot=me(w,"FORBID_ATTR")?F({},w.FORBID_ATTR,Z):$e({}),yt=me(w,"USE_PROFILES")?w.USE_PROFILES:!1,xn=w.ALLOW_ARIA_ATTR!==!1,A=w.ALLOW_DATA_ATTR!==!1,_=w.ALLOW_UNKNOWN_PROTOCOLS||!1,N=w.ALLOW_SELF_CLOSE_IN_ATTR!==!1,D=w.SAFE_FOR_TEMPLATES||!1,q=w.SAFE_FOR_XML!==!1,z=w.WHOLE_DOCUMENT||!1,mt=w.RETURN_DOM||!1,$n=w.RETURN_DOM_FRAGMENT||!1,En=w.RETURN_TRUSTED_TYPE||!1,Fe=w.FORCE_BODY||!1,jr=w.SANITIZE_DOM!==!1,Hr=w.SANITIZE_NAMED_PROPS||!1,Ri=w.KEEP_CONTENT!==!1,Bt=w.IN_PLACE||!1,kn=w.ALLOWED_URI_REGEXP||bc,vt=w.NAMESPACE||Me,_n=w.MATHML_TEXT_INTEGRATION_POINTS||_n,Mn=w.HTML_INTEGRATION_POINTS||Mn,H=w.CUSTOM_ELEMENT_HANDLING||{},w.CUSTOM_ELEMENT_HANDLING&&Qr(w.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(H.tagNameCheck=w.CUSTOM_ELEMENT_HANDLING.tagNameCheck),w.CUSTOM_ELEMENT_HANDLING&&Qr(w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(H.attributeNameCheck=w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),w.CUSTOM_ELEMENT_HANDLING&&typeof w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(H.allowCustomizedBuiltInElements=w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),D&&(A=!1),$n&&(mt=!0),yt&&(G=F({},sa),Q=[],yt.html===!0&&(F(G,ia),F(Q,ra)),yt.svg===!0&&(F(G,ss),F(Q,as),F(Q,Bn)),yt.svgFilters===!0&&(F(G,rs),F(Q,as),F(Q,Bn)),yt.mathMl===!0&&(F(G,os),F(Q,oa),F(Q,Bn))),w.ADD_TAGS&&(typeof w.ADD_TAGS=="function"?Be.tagCheck=w.ADD_TAGS:(G===Sn&&(G=$e(G)),F(G,w.ADD_TAGS,Z))),w.ADD_ATTR&&(typeof w.ADD_ATTR=="function"?Be.attributeCheck=w.ADD_ATTR:(Q===An&&(Q=$e(Q)),F(Q,w.ADD_ATTR,Z))),w.ADD_URI_SAFE_ATTR&&F(Di,w.ADD_URI_SAFE_ATTR,Z),w.FORBID_CONTENTS&&(ke===Ni&&(ke=$e(ke)),F(ke,w.FORBID_CONTENTS,Z)),w.ADD_FORBID_CONTENTS&&(ke===Ni&&(ke=$e(ke)),F(ke,w.ADD_FORBID_CONTENTS,Z)),Ri&&(G["#text"]=!0),z&&F(G,["html","head","body"]),G.table&&(F(G,["tbody"]),delete Qe.tbody),w.TRUSTED_TYPES_POLICY){if(typeof w.TRUSTED_TYPES_POLICY.createHTML!="function")throw jt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof w.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw jt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');T=w.TRUSTED_TYPES_POLICY,M=T.createHTML("")}else T===void 0&&(T=Rf(v,s)),T!==null&&typeof M=="string"&&(M=T.createHTML(""));ue&&ue(w),bt=w}},Yr=F({},[...ss,...rs,...Af]),Xr=F({},[...os,...xf]),Tu=function(w){let E=C(w);(!E||!E.tagName)&&(E={namespaceURI:vt,tagName:"template"});const L=Gn(w.tagName),j=Gn(E.tagName);return Bi[w.namespaceURI]?w.namespaceURI===Tn?E.namespaceURI===Me?L==="svg":E.namespaceURI===Cn?L==="svg"&&(j==="annotation-xml"||_n[j]):!!Yr[L]:w.namespaceURI===Cn?E.namespaceURI===Me?L==="math":E.namespaceURI===Tn?L==="math"&&Mn[j]:!!Xr[L]:w.namespaceURI===Me?E.namespaceURI===Tn&&!Mn[j]||E.namespaceURI===Cn&&!_n[j]?!1:!Xr[L]&&(xu[L]||!Yr[L]):!!(Ft==="application/xhtml+xml"&&Bi[w.namespaceURI]):!1},Se=function(w){Kt(t.removed,{element:w});try{C(w).removeChild(w)}catch{S(w)}},Ye=function(w,E){try{Kt(t.removed,{attribute:E.getAttributeNode(w),from:E})}catch{Kt(t.removed,{attribute:null,from:E})}if(E.removeAttribute(w),w==="is")if(mt||$n)try{Se(E)}catch{}else try{E.setAttribute(w,"")}catch{}},Zr=function(w){let E=null,L=null;if(Fe)w="<remove></remove>"+w;else{const Y=is(w,/^[\r\n\t ]+/);L=Y&&Y[0]}Ft==="application/xhtml+xml"&&vt===Me&&(w='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+w+"</body></html>");const j=T?T.createHTML(w):w;if(vt===Me)try{E=new h().parseFromString(j,Ft)}catch{}if(!E||!E.documentElement){E=R.createDocument(vt,"template",null);try{E.documentElement.innerHTML=Oi?M:j}catch{}}const ne=E.body||E.documentElement;return w&&L&&ne.insertBefore(n.createTextNode(L),ne.childNodes[0]||null),vt===Me?ge.call(E,z?"html":"body")[0]:z?E.documentElement:ne},Jr=function(w){return B.call(w.ownerDocument||w,w,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Ui=function(w){return w instanceof d&&(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")},eo=function(w){return typeof a=="function"&&w instanceof a};function Pe(I,w,E){On(I,L=>{L.call(t,w,E,bt)})}const to=function(w){let E=null;if(Pe(X.beforeSanitizeElements,w,null),Ui(w))return Se(w),!0;const L=Z(w.nodeName);if(Pe(X.uponSanitizeElement,w,{tagName:L,allowedTags:G}),q&&w.hasChildNodes()&&!eo(w.firstElementChild)&&ae(/<[/\w!]/g,w.innerHTML)&&ae(/<[/\w!]/g,w.textContent)||w.nodeType===qt.progressingInstruction||q&&w.nodeType===qt.comment&&ae(/<[/\w]/g,w.data))return Se(w),!0;if(!(Be.tagCheck instanceof Function&&Be.tagCheck(L))&&(!G[L]||Qe[L])){if(!Qe[L]&&io(L)&&(H.tagNameCheck instanceof RegExp&&ae(H.tagNameCheck,L)||H.tagNameCheck instanceof Function&&H.tagNameCheck(L)))return!1;if(Ri&&!ke[L]){const j=C(w)||w.parentNode,ne=$(w)||w.childNodes;if(ne&&j){const Y=ne.length;for(let pe=Y-1;pe>=0;--pe){const Le=b(ne[pe],!0);Le.__removalCount=(w.__removalCount||0)+1,j.insertBefore(Le,x(w))}}}return Se(w),!0}return w instanceof c&&!Tu(w)||(L==="noscript"||L==="noembed"||L==="noframes")&&ae(/<\/no(script|embed|frames)/i,w.innerHTML)?(Se(w),!0):(D&&w.nodeType===qt.text&&(E=w.textContent,On([Dt,gt,Ge],j=>{E=zt(E,j," ")}),w.textContent!==E&&(Kt(t.removed,{element:w.cloneNode()}),w.textContent=E)),Pe(X.afterSanitizeElements,w,null),!1)},no=function(w,E,L){if(jr&&(E==="id"||E==="name")&&(L in n||L in Cu))return!1;if(!(A&&!Ot[E]&&ae(Mi,E))){if(!(xn&&ae(Pi,E))){if(!(Be.attributeCheck instanceof Function&&Be.attributeCheck(E,w))){if(!Q[E]||Ot[E]){if(!(io(w)&&(H.tagNameCheck instanceof RegExp&&ae(H.tagNameCheck,w)||H.tagNameCheck instanceof Function&&H.tagNameCheck(w))&&(H.attributeNameCheck instanceof RegExp&&ae(H.attributeNameCheck,E)||H.attributeNameCheck instanceof Function&&H.attributeNameCheck(E,w))||E==="is"&&H.allowCustomizedBuiltInElements&&(H.tagNameCheck instanceof RegExp&&ae(H.tagNameCheck,L)||H.tagNameCheck instanceof Function&&H.tagNameCheck(L))))return!1}else if(!Di[E]){if(!ae(kn,zt(L,wn,""))){if(!((E==="src"||E==="xlink:href"||E==="href")&&w!=="script"&&bf(L,"data:")===0&&qr[w])){if(!(_&&!ae(Li,zt(L,wn,"")))){if(L)return!1}}}}}}}return!0},io=function(w){return w!=="annotation-xml"&&is(w,Ii)},so=function(w){Pe(X.beforeSanitizeAttributes,w,null);const{attributes:E}=w;if(!E||Ui(w))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Q,forceKeepAttr:void 0};let j=E.length;for(;j--;){const ne=E[j],{name:Y,namespaceURI:pe,value:Le}=ne,wt=Z(Y),Wi=Le;let te=Y==="value"?Wi:wf(Wi);if(L.attrName=wt,L.attrValue=te,L.keepAttr=!0,L.forceKeepAttr=void 0,Pe(X.uponSanitizeAttribute,w,L),te=L.attrValue,Hr&&(wt==="id"||wt==="name")&&(Ye(Y,w),te=Su+te),q&&ae(/((--!?|])>)|<\/(style|title|textarea)/i,te)){Ye(Y,w);continue}if(wt==="attributename"&&is(te,"href")){Ye(Y,w);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){Ye(Y,w);continue}if(!N&&ae(/\/>/i,te)){Ye(Y,w);continue}D&&On([Dt,gt,Ge],oo=>{te=zt(te,oo," ")});const ro=Z(w.nodeName);if(!no(ro,wt,te)){Ye(Y,w);continue}if(T&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!pe)switch(v.getAttributeType(ro,wt)){case"TrustedHTML":{te=T.createHTML(te);break}case"TrustedScriptURL":{te=T.createScriptURL(te);break}}if(te!==Wi)try{pe?w.setAttributeNS(pe,Y,te):w.setAttribute(Y,te),Ui(w)?Se(w):na(t.removed)}catch{Ye(Y,w)}}Pe(X.afterSanitizeAttributes,w,null)},_u=function I(w){let E=null;const L=Jr(w);for(Pe(X.beforeSanitizeShadowDOM,w,null);E=L.nextNode();)Pe(X.uponSanitizeShadowNode,E,null),to(E),so(E),E.content instanceof r&&I(E.content);Pe(X.afterSanitizeShadowDOM,w,null)};return t.sanitize=function(I){let w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,L=null,j=null,ne=null;if(Oi=!I,Oi&&(I="<!-->"),typeof I!="string"&&!eo(I))if(typeof I.toString=="function"){if(I=I.toString(),typeof I!="string")throw jt("dirty is not a string, aborting")}else throw jt("toString is not a function");if(!t.isSupported)return I;if(oe||Fi(w),t.removed=[],typeof I=="string"&&(Bt=!1),Bt){if(I.nodeName){const Le=Z(I.nodeName);if(!G[Le]||Qe[Le])throw jt("root node is forbidden and cannot be sanitized in-place")}}else if(I instanceof a)E=Zr("<!---->"),L=E.ownerDocument.importNode(I,!0),L.nodeType===qt.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?E=L:E.appendChild(L);else{if(!mt&&!D&&!z&&I.indexOf("<")===-1)return T&&En?T.createHTML(I):I;if(E=Zr(I),!E)return mt?null:En?M:""}E&&Fe&&Se(E.firstChild);const Y=Jr(Bt?I:E);for(;j=Y.nextNode();)to(j),so(j),j.content instanceof r&&_u(j.content);if(Bt)return I;if(mt){if($n)for(ne=J.call(E.ownerDocument);E.firstChild;)ne.appendChild(E.firstChild);else ne=E;return(Q.shadowroot||Q.shadowrootmode)&&(ne=Oe.call(i,ne,!0)),ne}let pe=z?E.outerHTML:E.innerHTML;return z&&G["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&ae(wc,E.ownerDocument.doctype.name)&&(pe="<!DOCTYPE "+E.ownerDocument.doctype.name+`>
1767
- `+pe),D&&On([Dt,gt,Ge],Le=>{pe=zt(pe,Le," ")}),T&&En?T.createHTML(pe):pe},t.setConfig=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Fi(I),oe=!0},t.clearConfig=function(){bt=null,oe=!1},t.isValidAttribute=function(I,w,E){bt||Fi({});const L=Z(I),j=Z(w);return no(L,j,E)},t.addHook=function(I,w){typeof w=="function"&&Kt(X[I],w)},t.removeHook=function(I,w){if(w!==void 0){const E=yf(X[I],w);return E===-1?void 0:vf(X[I],E,1)[0]}return na(X[I])},t.removeHooks=function(I){X[I]=[]},t.removeAllHooks=function(){X=la()},t}var Os=kc();function Er(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ht=Er();function Sc(e){ht=e}var on={exec:()=>null};function W(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(s,r)=>{let o=typeof r=="string"?r:r.source;return o=o.replace(le.caret,"$1"),n=n.replace(s,o),i},getRegex:()=>new RegExp(n,t)};return i}var Nf=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),le={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")},Df=/^(?:[ \t]*(?:\n|$))+/,Of=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Bf=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,vn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ff=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Cr=/(?:[*+-]|\d{1,9}[.)])/,Ac=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,xc=W(Ac).replace(/bull/g,Cr).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(),Uf=W(Ac).replace(/bull/g,Cr).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(),Tr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Wf=/^[^\n]+/,_r=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Kf=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_r).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),zf=W(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Cr).getRegex(),Ei="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",Mr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,jf=W("^ {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",Mr).replace("tag",Ei).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),$c=W(Tr).replace("hr",vn).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",Ei).getRegex(),Hf=W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",$c).getRegex(),Pr={blockquote:Hf,code:Of,def:Kf,fences:Bf,heading:Ff,hr:vn,html:jf,lheading:xc,list:zf,newline:Df,paragraph:$c,table:on,text:Wf},ca=W("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",vn).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",Ei).getRegex(),qf={...Pr,lheading:Uf,table:ca,paragraph:W(Tr).replace("hr",vn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ca).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",Ei).getRegex()},Vf={...Pr,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Mr).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:on,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(Tr).replace("hr",vn).replace("heading",` *#{1,6} *[^
1768
- ]`).replace("lheading",xc).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Gf=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Qf=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ec=/^( {2,}|\\)\n(?!\s*$)/,Yf=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ci=/[\p{P}\p{S}]/u,Lr=/[\s\p{P}\p{S}]/u,Cc=/[^\s\p{P}\p{S}]/u,Xf=W(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Lr).getRegex(),Tc=/(?!~)[\p{P}\p{S}]/u,Zf=/(?!~)[\s\p{P}\p{S}]/u,Jf=/(?:[^\s\p{P}\p{S}]|~)/u,eg=W(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Nf?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),_c=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,tg=W(_c,"u").replace(/punct/g,Ci).getRegex(),ng=W(_c,"u").replace(/punct/g,Tc).getRegex(),Mc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ig=W(Mc,"gu").replace(/notPunctSpace/g,Cc).replace(/punctSpace/g,Lr).replace(/punct/g,Ci).getRegex(),sg=W(Mc,"gu").replace(/notPunctSpace/g,Jf).replace(/punctSpace/g,Zf).replace(/punct/g,Tc).getRegex(),rg=W("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Cc).replace(/punctSpace/g,Lr).replace(/punct/g,Ci).getRegex(),og=W(/\\(punct)/,"gu").replace(/punct/g,Ci).getRegex(),ag=W(/^<(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(),lg=W(Mr).replace("(?:-->|$)","-->").getRegex(),cg=W("^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",lg).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),li=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,ug=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",li).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Pc=W(/^!?\[(label)\]\[(ref)\]/).replace("label",li).replace("ref",_r).getRegex(),Lc=W(/^!?\[(ref)\](?:\[\])?/).replace("ref",_r).getRegex(),dg=W("reflink|nolink(?!\\()","g").replace("reflink",Pc).replace("nolink",Lc).getRegex(),ua=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ir={_backpedal:on,anyPunctuation:og,autolink:ag,blockSkip:eg,br:Ec,code:Qf,del:on,emStrongLDelim:tg,emStrongRDelimAst:ig,emStrongRDelimUnd:rg,escape:Gf,link:ug,nolink:Lc,punctuation:Xf,reflink:Pc,reflinkSearch:dg,tag:cg,text:Yf,url:on},pg={...Ir,link:W(/^!?\[(label)\]\((.*?)\)/).replace("label",li).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",li).getRegex()},Bs={...Ir,emStrongRDelimAst:sg,emStrongLDelim:ng,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ua).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:W(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ua).getRegex()},hg={...Bs,br:W(Ec).replace("{2,}","*").getRegex(),text:W(Bs.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Fn={normal:Pr,gfm:qf,pedantic:Vf},Vt={normal:Ir,gfm:Bs,breaks:hg,pedantic:pg},fg={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},da=e=>fg[e];function Re(e,t){if(t){if(le.escapeTest.test(e))return e.replace(le.escapeReplace,da)}else if(le.escapeTestNoEncode.test(e))return e.replace(le.escapeReplaceNoEncode,da);return e}function pa(e){try{e=encodeURI(e).replace(le.percentDecode,"%")}catch{return null}return e}function ha(e,t){var r;let n=e.replace(le.findPipe,(o,a,c)=>{let u=!1,l=a;for(;--l>=0&&c[l]==="\\";)u=!u;return u?"|":" |"}),i=n.split(le.splitPipe),s=0;if(i[0].trim()||i.shift(),i.length>0&&!((r=i.at(-1))!=null&&r.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(le.slashPipe,"|");return i}function Gt(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 gg(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 fa(e,t,n,i,s){let r=t.href,o=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let c={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:o,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,c}function mg(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
1766
+ `}const fc={CHILD:2},gc=e=>(...t)=>({_$litDirective$:e,values:t});let mc=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:uf}=Ju,Zo=e=>e,Jo=()=>document.createComment(""),Wt=(e,t,n)=>{var r;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const o=i.insertBefore(Jo(),s),a=i.insertBefore(Jo(),s);n=new uf(o,a,e,e.options)}else{const o=n._$AB.nextSibling,a=n._$AM,c=a!==e;if(c){let u;(r=n._$AQ)==null||r.call(n,e),n._$AM=e,n._$AP!==void 0&&(u=e._$AU)!==a._$AU&&n._$AP(u)}if(o!==s||c){let u=n._$AA;for(;u!==o;){const l=Zo(u).nextSibling;Zo(i).insertBefore(u,s),u=l}}}return n},Ze=(e,t,n=e)=>(e._$AI(t,n),e),df={},pf=(e,t=df)=>e._$AH=t,hf=e=>e._$AH,ts=e=>{e._$AR(),e._$AA.remove()};const ea=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},ff=gc(class extends mc{constructor(e){if(super(e),e.type!==fc.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=[],r=[];let o=0;for(const a of e)s[o]=i?i(a,o):o,r[o]=n(a,o),o++;return{values:r,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=hf(e),{values:r,keys:o}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=o,r;const a=this.ut??(this.ut=[]),c=[];let u,l,d=0,h=s.length-1,v=0,y=r.length-1;for(;d<=h&&v<=y;)if(s[d]===null)d++;else if(s[h]===null)h--;else if(a[d]===o[v])c[v]=Ze(s[d],r[v]),d++,v++;else if(a[h]===o[y])c[y]=Ze(s[h],r[y]),h--,y--;else if(a[d]===o[y])c[y]=Ze(s[d],r[y]),Wt(e,c[y+1],s[d]),d++,y--;else if(a[h]===o[v])c[v]=Ze(s[h],r[v]),Wt(e,s[d],s[h]),h--,v++;else if(u===void 0&&(u=ea(o,v,y),l=ea(a,d,h)),u.has(a[d]))if(u.has(a[h])){const b=l.get(o[v]),S=b!==void 0?s[b]:null;if(S===null){const x=Wt(e,s[d]);Ze(x,r[v]),c[v]=x}else c[v]=Ze(S,r[v]),Wt(e,s[d],S),s[b]=null;v++}else ts(s[h]),h--;else ts(s[d]),d++;for(;v<=y;){const b=Wt(e,c[y+1]);Ze(b,r[v]),c[v++]=b}for(;d<=h;){const b=s[d++];b!==null&&ts(b)}return this.ut=o,pf(e,c),je}});class Is extends mc{constructor(t){if(super(t),this.it=k,t.type!==fc.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===je)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:[]}}}Is.directiveName="unsafeHTML",Is.resultType=1;const ai=gc(Is);const{entries:yc,setPrototypeOf:ta,isFrozen:gf,getPrototypeOf:mf,getOwnPropertyDescriptor:yf}=Object;let{freeze:ue,seal:fe,create:Rs}=Object,{apply:Ns,construct:Ds}=typeof Reflect<"u"&&Reflect;ue||(ue=function(t){return t});fe||(fe=function(t){return t});Ns||(Ns=function(t,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),r=2;r<i;r++)s[r-2]=arguments[r];return t.apply(n,s)});Ds||(Ds=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 On=de(Array.prototype.forEach),vf=de(Array.prototype.lastIndexOf),na=de(Array.prototype.pop),Kt=de(Array.prototype.push),bf=de(Array.prototype.splice),Gn=de(String.prototype.toLowerCase),ns=de(String.prototype.toString),is=de(String.prototype.match),zt=de(String.prototype.replace),wf=de(String.prototype.indexOf),kf=de(String.prototype.trim),me=de(Object.prototype.hasOwnProperty),ae=de(RegExp.prototype.test),jt=Sf(TypeError);function de(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 Ns(e,t,i)}}function Sf(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Ds(e,n)}}function F(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Gn;ta&&ta(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const r=n(s);r!==s&&(gf(t)||(t[i]=r),s=r)}e[s]=!0}return e}function Af(e){for(let t=0;t<e.length;t++)me(e,t)||(e[t]=null);return e}function $e(e){const t=Rs(null);for(const[n,i]of yc(e))me(e,n)&&(Array.isArray(i)?t[n]=Af(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=$e(i):t[n]=i);return t}function Ht(e,t){for(;e!==null;){const i=yf(e,t);if(i){if(i.get)return de(i.get);if(typeof i.value=="function")return de(i.value)}e=mf(e)}function n(){return null}return n}const ia=ue(["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=ue(["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"]),rs=ue(["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"]),xf=ue(["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"]),os=ue(["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"]),$f=ue(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),sa=ue(["#text"]),ra=ue(["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=ue(["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"]),oa=ue(["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"]),Bn=ue(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ef=fe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Cf=fe(/<%[\w\W]*|[\w\W]*%>/gm),Tf=fe(/\$\{[\w\W]*/gm),_f=fe(/^data-[\-\w.\u00B7-\uFFFF]+$/),Mf=fe(/^aria-[\-\w]+$/),vc=fe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Pf=fe(/^(?:\w+script|data):/i),Lf=fe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),bc=fe(/^html$/i),If=fe(/^[a-z][.\w]*(-[.\w]+)+$/i);var aa=Object.freeze({__proto__:null,ARIA_ATTR:Mf,ATTR_WHITESPACE:Lf,CUSTOM_ELEMENT:If,DATA_ATTR:_f,DOCTYPE_NAME:bc,ERB_EXPR:Cf,IS_ALLOWED_URI:vc,IS_SCRIPT_OR_DATA:Pf,MUSTACHE_EXPR:Ef,TMPLIT_EXPR:Tf});const qt={element:1,text:3,progressingInstruction:7,comment:8,document:9},Rf=function(){return typeof window>"u"?null:window},Nf=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 r="dompurify"+(i?"#"+i:"");try{return t.createPolicy(r,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},la=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function wc(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Rf();const t=I=>wc(I);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==qt.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:l=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:h,trustedTypes:v}=e,y=c.prototype,b=Ht(y,"cloneNode"),S=Ht(y,"remove"),x=Ht(y,"nextSibling"),$=Ht(y,"childNodes"),C=Ht(y,"parentNode");if(typeof o=="function"){const I=n.createElement("template");I.content&&I.content.ownerDocument&&(n=I.content.ownerDocument)}let T,M="";const{implementation:R,createNodeIterator:B,createDocumentFragment:J,getElementsByTagName:ge}=n,{importNode:Oe}=i;let X=la();t.isSupported=typeof yc=="function"&&typeof C=="function"&&R&&R.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Dt,ERB_EXPR:gt,TMPLIT_EXPR:Ge,DATA_ATTR:Mi,ARIA_ATTR:Pi,IS_SCRIPT_OR_DATA:Li,ATTR_WHITESPACE:wn,CUSTOM_ELEMENT:Ii}=aa;let{IS_ALLOWED_URI:kn}=aa,G=null;const Sn=F({},[...ia,...ss,...rs,...os,...sa]);let Q=null;const An=F({},[...ra,...as,...oa,...Bn]);let H=Object.seal(Rs(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}})),Qe=null,Ot=null;const Be=Object.seal(Rs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let xn=!0,A=!0,_=!1,N=!0,D=!1,q=!0,z=!1,oe=!1,Fe=!1,mt=!1,$n=!1,En=!1,jr=!0,Hr=!1;const Su="user-content-";let Ri=!0,Bt=!1,yt={},ke=null;const Ni=F({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let qr=null;const Vr=F({},["audio","video","img","source","image","track"]);let Di=null;const Gr=F({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Cn="http://www.w3.org/1998/Math/MathML",Tn="http://www.w3.org/2000/svg",Me="http://www.w3.org/1999/xhtml";let vt=Me,Oi=!1,Bi=null;const Au=F({},[Cn,Tn,Me],ns);let _n=F({},["mi","mo","mn","ms","mtext"]),Mn=F({},["annotation-xml"]);const xu=F({},["title","style","font","a","script"]);let Ft=null;const $u=["application/xhtml+xml","text/html"],Eu="text/html";let Z=null,bt=null;const Cu=n.createElement("form"),Qr=function(w){return w instanceof RegExp||w instanceof Function},Fi=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(bt&&bt===w)){if((!w||typeof w!="object")&&(w={}),w=$e(w),Ft=$u.indexOf(w.PARSER_MEDIA_TYPE)===-1?Eu:w.PARSER_MEDIA_TYPE,Z=Ft==="application/xhtml+xml"?ns:Gn,G=me(w,"ALLOWED_TAGS")?F({},w.ALLOWED_TAGS,Z):Sn,Q=me(w,"ALLOWED_ATTR")?F({},w.ALLOWED_ATTR,Z):An,Bi=me(w,"ALLOWED_NAMESPACES")?F({},w.ALLOWED_NAMESPACES,ns):Au,Di=me(w,"ADD_URI_SAFE_ATTR")?F($e(Gr),w.ADD_URI_SAFE_ATTR,Z):Gr,qr=me(w,"ADD_DATA_URI_TAGS")?F($e(Vr),w.ADD_DATA_URI_TAGS,Z):Vr,ke=me(w,"FORBID_CONTENTS")?F({},w.FORBID_CONTENTS,Z):Ni,Qe=me(w,"FORBID_TAGS")?F({},w.FORBID_TAGS,Z):$e({}),Ot=me(w,"FORBID_ATTR")?F({},w.FORBID_ATTR,Z):$e({}),yt=me(w,"USE_PROFILES")?w.USE_PROFILES:!1,xn=w.ALLOW_ARIA_ATTR!==!1,A=w.ALLOW_DATA_ATTR!==!1,_=w.ALLOW_UNKNOWN_PROTOCOLS||!1,N=w.ALLOW_SELF_CLOSE_IN_ATTR!==!1,D=w.SAFE_FOR_TEMPLATES||!1,q=w.SAFE_FOR_XML!==!1,z=w.WHOLE_DOCUMENT||!1,mt=w.RETURN_DOM||!1,$n=w.RETURN_DOM_FRAGMENT||!1,En=w.RETURN_TRUSTED_TYPE||!1,Fe=w.FORCE_BODY||!1,jr=w.SANITIZE_DOM!==!1,Hr=w.SANITIZE_NAMED_PROPS||!1,Ri=w.KEEP_CONTENT!==!1,Bt=w.IN_PLACE||!1,kn=w.ALLOWED_URI_REGEXP||vc,vt=w.NAMESPACE||Me,_n=w.MATHML_TEXT_INTEGRATION_POINTS||_n,Mn=w.HTML_INTEGRATION_POINTS||Mn,H=w.CUSTOM_ELEMENT_HANDLING||{},w.CUSTOM_ELEMENT_HANDLING&&Qr(w.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(H.tagNameCheck=w.CUSTOM_ELEMENT_HANDLING.tagNameCheck),w.CUSTOM_ELEMENT_HANDLING&&Qr(w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(H.attributeNameCheck=w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),w.CUSTOM_ELEMENT_HANDLING&&typeof w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(H.allowCustomizedBuiltInElements=w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),D&&(A=!1),$n&&(mt=!0),yt&&(G=F({},sa),Q=[],yt.html===!0&&(F(G,ia),F(Q,ra)),yt.svg===!0&&(F(G,ss),F(Q,as),F(Q,Bn)),yt.svgFilters===!0&&(F(G,rs),F(Q,as),F(Q,Bn)),yt.mathMl===!0&&(F(G,os),F(Q,oa),F(Q,Bn))),w.ADD_TAGS&&(typeof w.ADD_TAGS=="function"?Be.tagCheck=w.ADD_TAGS:(G===Sn&&(G=$e(G)),F(G,w.ADD_TAGS,Z))),w.ADD_ATTR&&(typeof w.ADD_ATTR=="function"?Be.attributeCheck=w.ADD_ATTR:(Q===An&&(Q=$e(Q)),F(Q,w.ADD_ATTR,Z))),w.ADD_URI_SAFE_ATTR&&F(Di,w.ADD_URI_SAFE_ATTR,Z),w.FORBID_CONTENTS&&(ke===Ni&&(ke=$e(ke)),F(ke,w.FORBID_CONTENTS,Z)),w.ADD_FORBID_CONTENTS&&(ke===Ni&&(ke=$e(ke)),F(ke,w.ADD_FORBID_CONTENTS,Z)),Ri&&(G["#text"]=!0),z&&F(G,["html","head","body"]),G.table&&(F(G,["tbody"]),delete Qe.tbody),w.TRUSTED_TYPES_POLICY){if(typeof w.TRUSTED_TYPES_POLICY.createHTML!="function")throw jt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof w.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw jt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');T=w.TRUSTED_TYPES_POLICY,M=T.createHTML("")}else T===void 0&&(T=Nf(v,s)),T!==null&&typeof M=="string"&&(M=T.createHTML(""));ue&&ue(w),bt=w}},Yr=F({},[...ss,...rs,...xf]),Xr=F({},[...os,...$f]),Tu=function(w){let E=C(w);(!E||!E.tagName)&&(E={namespaceURI:vt,tagName:"template"});const L=Gn(w.tagName),j=Gn(E.tagName);return Bi[w.namespaceURI]?w.namespaceURI===Tn?E.namespaceURI===Me?L==="svg":E.namespaceURI===Cn?L==="svg"&&(j==="annotation-xml"||_n[j]):!!Yr[L]:w.namespaceURI===Cn?E.namespaceURI===Me?L==="math":E.namespaceURI===Tn?L==="math"&&Mn[j]:!!Xr[L]:w.namespaceURI===Me?E.namespaceURI===Tn&&!Mn[j]||E.namespaceURI===Cn&&!_n[j]?!1:!Xr[L]&&(xu[L]||!Yr[L]):!!(Ft==="application/xhtml+xml"&&Bi[w.namespaceURI]):!1},Se=function(w){Kt(t.removed,{element:w});try{C(w).removeChild(w)}catch{S(w)}},Ye=function(w,E){try{Kt(t.removed,{attribute:E.getAttributeNode(w),from:E})}catch{Kt(t.removed,{attribute:null,from:E})}if(E.removeAttribute(w),w==="is")if(mt||$n)try{Se(E)}catch{}else try{E.setAttribute(w,"")}catch{}},Zr=function(w){let E=null,L=null;if(Fe)w="<remove></remove>"+w;else{const Y=is(w,/^[\r\n\t ]+/);L=Y&&Y[0]}Ft==="application/xhtml+xml"&&vt===Me&&(w='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+w+"</body></html>");const j=T?T.createHTML(w):w;if(vt===Me)try{E=new h().parseFromString(j,Ft)}catch{}if(!E||!E.documentElement){E=R.createDocument(vt,"template",null);try{E.documentElement.innerHTML=Oi?M:j}catch{}}const ne=E.body||E.documentElement;return w&&L&&ne.insertBefore(n.createTextNode(L),ne.childNodes[0]||null),vt===Me?ge.call(E,z?"html":"body")[0]:z?E.documentElement:ne},Jr=function(w){return B.call(w.ownerDocument||w,w,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Ui=function(w){return w instanceof d&&(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")},eo=function(w){return typeof a=="function"&&w instanceof a};function Pe(I,w,E){On(I,L=>{L.call(t,w,E,bt)})}const to=function(w){let E=null;if(Pe(X.beforeSanitizeElements,w,null),Ui(w))return Se(w),!0;const L=Z(w.nodeName);if(Pe(X.uponSanitizeElement,w,{tagName:L,allowedTags:G}),q&&w.hasChildNodes()&&!eo(w.firstElementChild)&&ae(/<[/\w!]/g,w.innerHTML)&&ae(/<[/\w!]/g,w.textContent)||w.nodeType===qt.progressingInstruction||q&&w.nodeType===qt.comment&&ae(/<[/\w]/g,w.data))return Se(w),!0;if(!(Be.tagCheck instanceof Function&&Be.tagCheck(L))&&(!G[L]||Qe[L])){if(!Qe[L]&&io(L)&&(H.tagNameCheck instanceof RegExp&&ae(H.tagNameCheck,L)||H.tagNameCheck instanceof Function&&H.tagNameCheck(L)))return!1;if(Ri&&!ke[L]){const j=C(w)||w.parentNode,ne=$(w)||w.childNodes;if(ne&&j){const Y=ne.length;for(let pe=Y-1;pe>=0;--pe){const Le=b(ne[pe],!0);Le.__removalCount=(w.__removalCount||0)+1,j.insertBefore(Le,x(w))}}}return Se(w),!0}return w instanceof c&&!Tu(w)||(L==="noscript"||L==="noembed"||L==="noframes")&&ae(/<\/no(script|embed|frames)/i,w.innerHTML)?(Se(w),!0):(D&&w.nodeType===qt.text&&(E=w.textContent,On([Dt,gt,Ge],j=>{E=zt(E,j," ")}),w.textContent!==E&&(Kt(t.removed,{element:w.cloneNode()}),w.textContent=E)),Pe(X.afterSanitizeElements,w,null),!1)},no=function(w,E,L){if(jr&&(E==="id"||E==="name")&&(L in n||L in Cu))return!1;if(!(A&&!Ot[E]&&ae(Mi,E))){if(!(xn&&ae(Pi,E))){if(!(Be.attributeCheck instanceof Function&&Be.attributeCheck(E,w))){if(!Q[E]||Ot[E]){if(!(io(w)&&(H.tagNameCheck instanceof RegExp&&ae(H.tagNameCheck,w)||H.tagNameCheck instanceof Function&&H.tagNameCheck(w))&&(H.attributeNameCheck instanceof RegExp&&ae(H.attributeNameCheck,E)||H.attributeNameCheck instanceof Function&&H.attributeNameCheck(E,w))||E==="is"&&H.allowCustomizedBuiltInElements&&(H.tagNameCheck instanceof RegExp&&ae(H.tagNameCheck,L)||H.tagNameCheck instanceof Function&&H.tagNameCheck(L))))return!1}else if(!Di[E]){if(!ae(kn,zt(L,wn,""))){if(!((E==="src"||E==="xlink:href"||E==="href")&&w!=="script"&&wf(L,"data:")===0&&qr[w])){if(!(_&&!ae(Li,zt(L,wn,"")))){if(L)return!1}}}}}}}return!0},io=function(w){return w!=="annotation-xml"&&is(w,Ii)},so=function(w){Pe(X.beforeSanitizeAttributes,w,null);const{attributes:E}=w;if(!E||Ui(w))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Q,forceKeepAttr:void 0};let j=E.length;for(;j--;){const ne=E[j],{name:Y,namespaceURI:pe,value:Le}=ne,wt=Z(Y),Wi=Le;let te=Y==="value"?Wi:kf(Wi);if(L.attrName=wt,L.attrValue=te,L.keepAttr=!0,L.forceKeepAttr=void 0,Pe(X.uponSanitizeAttribute,w,L),te=L.attrValue,Hr&&(wt==="id"||wt==="name")&&(Ye(Y,w),te=Su+te),q&&ae(/((--!?|])>)|<\/(style|title|textarea)/i,te)){Ye(Y,w);continue}if(wt==="attributename"&&is(te,"href")){Ye(Y,w);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){Ye(Y,w);continue}if(!N&&ae(/\/>/i,te)){Ye(Y,w);continue}D&&On([Dt,gt,Ge],oo=>{te=zt(te,oo," ")});const ro=Z(w.nodeName);if(!no(ro,wt,te)){Ye(Y,w);continue}if(T&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!pe)switch(v.getAttributeType(ro,wt)){case"TrustedHTML":{te=T.createHTML(te);break}case"TrustedScriptURL":{te=T.createScriptURL(te);break}}if(te!==Wi)try{pe?w.setAttributeNS(pe,Y,te):w.setAttribute(Y,te),Ui(w)?Se(w):na(t.removed)}catch{Ye(Y,w)}}Pe(X.afterSanitizeAttributes,w,null)},_u=function I(w){let E=null;const L=Jr(w);for(Pe(X.beforeSanitizeShadowDOM,w,null);E=L.nextNode();)Pe(X.uponSanitizeShadowNode,E,null),to(E),so(E),E.content instanceof r&&I(E.content);Pe(X.afterSanitizeShadowDOM,w,null)};return t.sanitize=function(I){let w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,L=null,j=null,ne=null;if(Oi=!I,Oi&&(I="<!-->"),typeof I!="string"&&!eo(I))if(typeof I.toString=="function"){if(I=I.toString(),typeof I!="string")throw jt("dirty is not a string, aborting")}else throw jt("toString is not a function");if(!t.isSupported)return I;if(oe||Fi(w),t.removed=[],typeof I=="string"&&(Bt=!1),Bt){if(I.nodeName){const Le=Z(I.nodeName);if(!G[Le]||Qe[Le])throw jt("root node is forbidden and cannot be sanitized in-place")}}else if(I instanceof a)E=Zr("<!---->"),L=E.ownerDocument.importNode(I,!0),L.nodeType===qt.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?E=L:E.appendChild(L);else{if(!mt&&!D&&!z&&I.indexOf("<")===-1)return T&&En?T.createHTML(I):I;if(E=Zr(I),!E)return mt?null:En?M:""}E&&Fe&&Se(E.firstChild);const Y=Jr(Bt?I:E);for(;j=Y.nextNode();)to(j),so(j),j.content instanceof r&&_u(j.content);if(Bt)return I;if(mt){if($n)for(ne=J.call(E.ownerDocument);E.firstChild;)ne.appendChild(E.firstChild);else ne=E;return(Q.shadowroot||Q.shadowrootmode)&&(ne=Oe.call(i,ne,!0)),ne}let pe=z?E.outerHTML:E.innerHTML;return z&&G["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&ae(bc,E.ownerDocument.doctype.name)&&(pe="<!DOCTYPE "+E.ownerDocument.doctype.name+`>
1767
+ `+pe),D&&On([Dt,gt,Ge],Le=>{pe=zt(pe,Le," ")}),T&&En?T.createHTML(pe):pe},t.setConfig=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Fi(I),oe=!0},t.clearConfig=function(){bt=null,oe=!1},t.isValidAttribute=function(I,w,E){bt||Fi({});const L=Z(I),j=Z(w);return no(L,j,E)},t.addHook=function(I,w){typeof w=="function"&&Kt(X[I],w)},t.removeHook=function(I,w){if(w!==void 0){const E=vf(X[I],w);return E===-1?void 0:bf(X[I],E,1)[0]}return na(X[I])},t.removeHooks=function(I){X[I]=[]},t.removeAllHooks=function(){X=la()},t}var Os=wc();function Er(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ht=Er();function kc(e){ht=e}var on={exec:()=>null};function W(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(s,r)=>{let o=typeof r=="string"?r:r.source;return o=o.replace(le.caret,"$1"),n=n.replace(s,o),i},getRegex:()=>new RegExp(n,t)};return i}var Df=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),le={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")},Of=/^(?:[ \t]*(?:\n|$))+/,Bf=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ff=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,vn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Uf=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Cr=/(?:[*+-]|\d{1,9}[.)])/,Sc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ac=W(Sc).replace(/bull/g,Cr).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(),Wf=W(Sc).replace(/bull/g,Cr).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(),Tr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Kf=/^[^\n]+/,_r=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,zf=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_r).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),jf=W(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Cr).getRegex(),Ei="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",Mr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Hf=W("^ {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",Mr).replace("tag",Ei).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),xc=W(Tr).replace("hr",vn).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",Ei).getRegex(),qf=W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",xc).getRegex(),Pr={blockquote:qf,code:Bf,def:zf,fences:Ff,heading:Uf,hr:vn,html:Hf,lheading:Ac,list:jf,newline:Of,paragraph:xc,table:on,text:Kf},ca=W("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",vn).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",Ei).getRegex(),Vf={...Pr,lheading:Wf,table:ca,paragraph:W(Tr).replace("hr",vn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ca).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",Ei).getRegex()},Gf={...Pr,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Mr).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:on,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(Tr).replace("hr",vn).replace("heading",` *#{1,6} *[^
1768
+ ]`).replace("lheading",Ac).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Qf=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Yf=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$c=/^( {2,}|\\)\n(?!\s*$)/,Xf=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ci=/[\p{P}\p{S}]/u,Lr=/[\s\p{P}\p{S}]/u,Ec=/[^\s\p{P}\p{S}]/u,Zf=W(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Lr).getRegex(),Cc=/(?!~)[\p{P}\p{S}]/u,Jf=/(?!~)[\s\p{P}\p{S}]/u,eg=/(?:[^\s\p{P}\p{S}]|~)/u,tg=W(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Df?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Tc=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ng=W(Tc,"u").replace(/punct/g,Ci).getRegex(),ig=W(Tc,"u").replace(/punct/g,Cc).getRegex(),_c="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",sg=W(_c,"gu").replace(/notPunctSpace/g,Ec).replace(/punctSpace/g,Lr).replace(/punct/g,Ci).getRegex(),rg=W(_c,"gu").replace(/notPunctSpace/g,eg).replace(/punctSpace/g,Jf).replace(/punct/g,Cc).getRegex(),og=W("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ec).replace(/punctSpace/g,Lr).replace(/punct/g,Ci).getRegex(),ag=W(/\\(punct)/,"gu").replace(/punct/g,Ci).getRegex(),lg=W(/^<(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(),cg=W(Mr).replace("(?:-->|$)","-->").getRegex(),ug=W("^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",cg).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),li=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,dg=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",li).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Mc=W(/^!?\[(label)\]\[(ref)\]/).replace("label",li).replace("ref",_r).getRegex(),Pc=W(/^!?\[(ref)\](?:\[\])?/).replace("ref",_r).getRegex(),pg=W("reflink|nolink(?!\\()","g").replace("reflink",Mc).replace("nolink",Pc).getRegex(),ua=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ir={_backpedal:on,anyPunctuation:ag,autolink:lg,blockSkip:tg,br:$c,code:Yf,del:on,emStrongLDelim:ng,emStrongRDelimAst:sg,emStrongRDelimUnd:og,escape:Qf,link:dg,nolink:Pc,punctuation:Zf,reflink:Mc,reflinkSearch:pg,tag:ug,text:Xf,url:on},hg={...Ir,link:W(/^!?\[(label)\]\((.*?)\)/).replace("label",li).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",li).getRegex()},Bs={...Ir,emStrongRDelimAst:rg,emStrongLDelim:ig,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ua).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:W(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ua).getRegex()},fg={...Bs,br:W($c).replace("{2,}","*").getRegex(),text:W(Bs.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Fn={normal:Pr,gfm:Vf,pedantic:Gf},Vt={normal:Ir,gfm:Bs,breaks:fg,pedantic:hg},gg={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},da=e=>gg[e];function Re(e,t){if(t){if(le.escapeTest.test(e))return e.replace(le.escapeReplace,da)}else if(le.escapeTestNoEncode.test(e))return e.replace(le.escapeReplaceNoEncode,da);return e}function pa(e){try{e=encodeURI(e).replace(le.percentDecode,"%")}catch{return null}return e}function ha(e,t){var r;let n=e.replace(le.findPipe,(o,a,c)=>{let u=!1,l=a;for(;--l>=0&&c[l]==="\\";)u=!u;return u?"|":" |"}),i=n.split(le.splitPipe),s=0;if(i[0].trim()||i.shift(),i.length>0&&!((r=i.at(-1))!=null&&r.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(le.slashPipe,"|");return i}function Gt(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 mg(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 fa(e,t,n,i,s){let r=t.href,o=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let c={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:o,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,c}function yg(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
1769
1769
  `).map(r=>{let o=r.match(n.other.beginningSpace);if(o===null)return r;let[a]=o;return a.length>=s.length?r.slice(s.length):r}).join(`
1770
1770
  `)}var ci=class{constructor(e){U(this,"options");U(this,"rules");U(this,"lexer");this.options=e||ht}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:Gt(n,`
1771
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=mg(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=Gt(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:Gt(t[0],`
1771
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=yg(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=Gt(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:Gt(t[0],`
1772
1772
  `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Gt(t[0],`
1773
1773
  `).split(`
1774
1774
  `),i="",s="",r=[];for(;n.length>0;){let o=!1,a=[],c;for(c=0;c<n.length;c++)if(this.rules.other.blockquoteStart.test(n[c]))a.push(n[c]),o=!0;else if(!o)a.push(n[c]);else break;n=n.slice(c);let u=a.join(`
@@ -1789,7 +1789,7 @@ ${l}`:l;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
1789
1789
  `+y}!b&&!y.trim()&&(b=!0),d+=R+`
1790
1790
  `,e=e.substring(R.length+1),v=B.slice(S)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(c=!0)),o.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),o.raw+=d}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let l of o.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 h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}}let d=this.rules.other.listTaskCheckbox.exec(l.raw);if(d){let h={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};l.checked=h.checked,o.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=h.raw+l.tokens[0].raw,l.tokens[0].text=h.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(h)):l.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):l.tokens.unshift(h)}}if(!o.loose){let d=l.tokens.filter(v=>v.type==="space"),h=d.length>0&&d.some(v=>this.rules.other.anyLine.test(v.raw));o.loose=h}}if(o.loose)for(let l of o.items){l.loose=!0;for(let d of l.tokens)d.type==="text"&&(d.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),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 o;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=ha(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(o=t[3])!=null&&o.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
1791
1791
  `):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let a of i)this.rules.other.tableAlignRight.test(a)?r.align.push("right"):this.rules.other.tableAlignCenter.test(a)?r.align.push("center"):this.rules.other.tableAlignLeft.test(a)?r.align.push("left"):r.align.push(null);for(let a=0;a<n.length;a++)r.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:r.align[a]});for(let a of s)r.rows.push(ha(a,r.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:r.align[u]})));return r}}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)===`
1792
- `?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 r=Gt(n.slice(0,-1),"\\");if((n.length-r.length)%2===0)return}else{let r=gg(t[2],"()");if(r===-2)return;if(r>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+r;t[2]=t[2].substring(0,r),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){let r=this.rules.other.pedanticHrefTitle.exec(i);r&&(i=r[1],s=r[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)),fa(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 r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return fa(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,r,o,a=s,c=0,u=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*e.length+s);(i=u.exec(t))!=null;){if(r=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!r)continue;if(o=[...r].length,i[3]||i[4]){a+=o;continue}else if((i[5]||i[6])&&s%3&&!((s+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let l=[...i[0]][0].length,d=e.slice(0,s+i.index+l+o);if(Math.min(s,o)%2){let v=d.slice(1,-1);return{type:"em",raw:d,text:v,tokens:this.lexer.inlineTokens(v)}}let h=d.slice(2,-2);return{type:"strong",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}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 r;do r=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(r!==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}}}},ye=class Fs{constructor(t){U(this,"tokens");U(this,"options");U(this,"state");U(this,"inlineQueue");U(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ht,this.options.tokenizer=this.options.tokenizer||new ci,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:le,block:Fn.normal,inline:Vt.normal};this.options.pedantic?(n.block=Fn.pedantic,n.inline=Vt.pedantic):this.options.gfm&&(n.block=Fn.gfm,this.options.breaks?n.inline=Vt.breaks:n.inline=Vt.gfm),this.tokenizer.rules=n}static get rules(){return{block:Fn,inline:Vt}}static lex(t,n){return new Fs(n).lex(t)}static lexInline(t,n){return new Fs(n).inlineTokens(t)}lex(t){t=t.replace(le.carriageReturn,`
1792
+ `?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 r=Gt(n.slice(0,-1),"\\");if((n.length-r.length)%2===0)return}else{let r=mg(t[2],"()");if(r===-2)return;if(r>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+r;t[2]=t[2].substring(0,r),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){let r=this.rules.other.pedanticHrefTitle.exec(i);r&&(i=r[1],s=r[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)),fa(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 r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return fa(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,r,o,a=s,c=0,u=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*e.length+s);(i=u.exec(t))!=null;){if(r=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!r)continue;if(o=[...r].length,i[3]||i[4]){a+=o;continue}else if((i[5]||i[6])&&s%3&&!((s+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let l=[...i[0]][0].length,d=e.slice(0,s+i.index+l+o);if(Math.min(s,o)%2){let v=d.slice(1,-1);return{type:"em",raw:d,text:v,tokens:this.lexer.inlineTokens(v)}}let h=d.slice(2,-2);return{type:"strong",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}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 r;do r=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(r!==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}}}},ye=class Fs{constructor(t){U(this,"tokens");U(this,"options");U(this,"state");U(this,"inlineQueue");U(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ht,this.options.tokenizer=this.options.tokenizer||new ci,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:le,block:Fn.normal,inline:Vt.normal};this.options.pedantic?(n.block=Fn.pedantic,n.inline=Vt.pedantic):this.options.gfm&&(n.block=Fn.gfm,this.options.breaks?n.inline=Vt.breaks:n.inline=Vt.gfm),this.tokenizer.rules=n}static get rules(){return{block:Fn,inline:Vt}}static lex(t,n){return new Fs(n).lex(t)}static lexInline(t,n){return new Fs(n).inlineTokens(t)}lex(t){t=t.replace(le.carriageReturn,`
1793
1793
  `),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,r,o;for(this.options.pedantic&&(t=t.replace(le.tabCharGlobal," ").replace(le.spaceLine,""));t;){let a;if((r=(s=this.options.extensions)==null?void 0:s.block)!=null&&r.some(u=>(a=u.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 u=n.at(-1);a.raw.length===1&&u!==void 0?u.raw+=`
1794
1794
  `:n.push(a);continue}if(a=this.tokenizer.code(t)){t=t.substring(a.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
1795
1795
  `)?"":`
@@ -1821,23 +1821,23 @@ ${this.parser.parse(e)}</blockquote>
1821
1821
  `}tablerow({text:e}){return`<tr>
1822
1822
  ${e}</tr>
1823
1823
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
1824
- `}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>${Re(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=pa(e);if(s===null)return i;e=s;let r='<a href="'+e+'"';return t&&(r+=' title="'+Re(t)+'"'),r+=">"+i+"</a>",r}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=pa(e);if(s===null)return Re(n);e=s;let r=`<img src="${e}" alt="${n}"`;return t&&(r+=` title="${Re(t)}"`),r+=">",r}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Re(e.text)}},Rr=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}},ve=class Us{constructor(t){U(this,"options");U(this,"renderer");U(this,"textRenderer");this.options=t||ht,this.options.renderer=this.options.renderer||new ui,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Rr}static parse(t,n){return new Us(n).parse(t)}static parseInline(t,n){return new Us(n).parseInline(t)}parse(t){var i,s;let n="";for(let r=0;r<t.length;r++){let o=t[r];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){n+=u||"";continue}}let a=o;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return n}parseInline(t,n=this.renderer){var s,r;let i="";for(let o=0;o<t.length;o++){let a=t[o];if((r=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&r[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){i+=u||"";continue}}let c=a;switch(c.type){case"escape":{i+=n.text(c);break}case"html":{i+=n.html(c);break}case"link":{i+=n.link(c);break}case"image":{i+=n.image(c);break}case"checkbox":{i+=n.checkbox(c);break}case"strong":{i+=n.strong(c);break}case"em":{i+=n.em(c);break}case"codespan":{i+=n.codespan(c);break}case"br":{i+=n.br(c);break}case"del":{i+=n.del(c);break}case"text":{i+=n.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return i}},Hn,Xt=(Hn=class{constructor(e){U(this,"options");U(this,"block");this.options=e||ht}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ye.lex:ye.lexInline}provideParser(){return this.block?ve.parse:ve.parseInline}},U(Hn,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),U(Hn,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Hn),yg=class{constructor(...e){U(this,"defaults",Er());U(this,"options",this.setOptions);U(this,"parse",this.parseMarkdown(!0));U(this,"parseInline",this.parseMarkdown(!1));U(this,"Parser",ve);U(this,"Renderer",ui);U(this,"TextRenderer",Rr);U(this,"Lexer",ye);U(this,"Tokenizer",ci);U(this,"Hooks",Xt);this.use(...e)}walkTokens(e,t){var i,s;let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let o=r;for(let a of o.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of o.rows)for(let c of a)n=n.concat(this.walkTokens(c.tokens,t));break}case"list":{let o=r;n=n.concat(this.walkTokens(o.items,t));break}default:{let o=r;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);n=n.concat(this.walkTokens(c,t))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let 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 r=t.renderers[s.name];r?t.renderers[s.name]=function(...o){let a=s.renderer.apply(this,o);return a===!1&&(a=r.apply(this,o)),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 r=t[s.level];r?r.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 ui(this.defaults);for(let r in n.renderer){if(!(r in s))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;let o=r,a=n.renderer[o],c=s[o];s[o]=(...u)=>{let l=a.apply(s,u);return l===!1&&(l=c.apply(s,u)),l||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new ci(this.defaults);for(let r in n.tokenizer){if(!(r in s))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let o=r,a=n.tokenizer[o],c=s[o];s[o]=(...u)=>{let l=a.apply(s,u);return l===!1&&(l=c.apply(s,u)),l}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new Xt;for(let r in n.hooks){if(!(r in s))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;let o=r,a=n.hooks[o],c=s[o];Xt.passThroughHooks.has(r)?s[o]=u=>{if(this.defaults.async&&Xt.passThroughHooksRespectAsync.has(r))return(async()=>{let d=await a.call(s,u);return c.call(s,d)})();let l=a.call(s,u);return c.call(s,l)}:s[o]=(...u)=>{if(this.defaults.async)return(async()=>{let d=await a.apply(s,u);return d===!1&&(d=await c.apply(s,u)),d})();let l=a.apply(s,u);return l===!1&&(l=c.apply(s,u)),l}}i.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,r=n.walkTokens;i.walkTokens=function(o){let a=[];return a.push(r.call(this,o)),s&&(a=a.concat(s.call(this,o))),a}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ye.lex(e,t??this.defaults)}parser(e,t){return ve.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},r=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return r(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 r(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return r(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 o=s.hooks?await s.hooks.preprocess(t):t,a=await(s.hooks?await s.hooks.provideLexer():e?ye.lex:ye.lexInline)(o,s),c=s.hooks?await s.hooks.processAllTokens(a):a;s.walkTokens&&await Promise.all(this.walkTokens(c,s.walkTokens));let u=await(s.hooks?await s.hooks.provideParser():e?ve.parse:ve.parseInline)(c,s);return s.hooks?await s.hooks.postprocess(u):u})().catch(r);try{s.hooks&&(t=s.hooks.preprocess(t));let o=(s.hooks?s.hooks.provideLexer():e?ye.lex:ye.lexInline)(t,s);s.hooks&&(o=s.hooks.processAllTokens(o)),s.walkTokens&&this.walkTokens(o,s.walkTokens);let a=(s.hooks?s.hooks.provideParser():e?ve.parse:ve.parseInline)(o,s);return s.hooks&&(a=s.hooks.postprocess(a)),a}catch(o){return r(o)}}}onError(e,t){return n=>{if(n.message+=`
1825
- Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Re(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},ct=new yg;function K(e,t){return ct.parse(e,t)}K.options=K.setOptions=function(e){return ct.setOptions(e),K.defaults=ct.defaults,Sc(K.defaults),K};K.getDefaults=Er;K.defaults=ht;K.use=function(...e){return ct.use(...e),K.defaults=ct.defaults,Sc(K.defaults),K};K.walkTokens=function(e,t){return ct.walkTokens(e,t)};K.parseInline=ct.parseInline;K.Parser=ve;K.parser=ve.parse;K.Renderer=ui;K.TextRenderer=Rr;K.Lexer=ye;K.lexer=ye.lex;K.Tokenizer=ci;K.Hooks=Xt;K.parse=K;K.options;K.setOptions;K.use;K.walkTokens;K.parseInline;ve.parse;ye.lex;K.setOptions({gfm:!0,breaks:!0,mangle:!1});const ga=["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"],ma=["class","href","rel","target","title","start"];let ya=!1;const vg=14e4,bg=4e4,wg=200,ls=5e4,tt=new Map;function kg(e){const t=tt.get(e);return t===void 0?null:(tt.delete(e),tt.set(e,t),t)}function va(e,t){if(tt.set(e,t),tt.size<=wg)return;const n=tt.keys().next().value;n&&tt.delete(n)}function Sg(){ya||(ya=!0,Os.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function di(e){const t=e.trim();if(!t)return"";if(Sg(),t.length<=ls){const o=kg(t);if(o!==null)return o}const n=pl(t,vg),i=n.truncated?`
1824
+ `}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>${Re(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=pa(e);if(s===null)return i;e=s;let r='<a href="'+e+'"';return t&&(r+=' title="'+Re(t)+'"'),r+=">"+i+"</a>",r}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=pa(e);if(s===null)return Re(n);e=s;let r=`<img src="${e}" alt="${n}"`;return t&&(r+=` title="${Re(t)}"`),r+=">",r}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Re(e.text)}},Rr=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}},ve=class Us{constructor(t){U(this,"options");U(this,"renderer");U(this,"textRenderer");this.options=t||ht,this.options.renderer=this.options.renderer||new ui,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Rr}static parse(t,n){return new Us(n).parse(t)}static parseInline(t,n){return new Us(n).parseInline(t)}parse(t){var i,s;let n="";for(let r=0;r<t.length;r++){let o=t[r];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){n+=u||"";continue}}let a=o;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return n}parseInline(t,n=this.renderer){var s,r;let i="";for(let o=0;o<t.length;o++){let a=t[o];if((r=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&r[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){i+=u||"";continue}}let c=a;switch(c.type){case"escape":{i+=n.text(c);break}case"html":{i+=n.html(c);break}case"link":{i+=n.link(c);break}case"image":{i+=n.image(c);break}case"checkbox":{i+=n.checkbox(c);break}case"strong":{i+=n.strong(c);break}case"em":{i+=n.em(c);break}case"codespan":{i+=n.codespan(c);break}case"br":{i+=n.br(c);break}case"del":{i+=n.del(c);break}case"text":{i+=n.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return i}},Hn,Xt=(Hn=class{constructor(e){U(this,"options");U(this,"block");this.options=e||ht}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ye.lex:ye.lexInline}provideParser(){return this.block?ve.parse:ve.parseInline}},U(Hn,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),U(Hn,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Hn),vg=class{constructor(...e){U(this,"defaults",Er());U(this,"options",this.setOptions);U(this,"parse",this.parseMarkdown(!0));U(this,"parseInline",this.parseMarkdown(!1));U(this,"Parser",ve);U(this,"Renderer",ui);U(this,"TextRenderer",Rr);U(this,"Lexer",ye);U(this,"Tokenizer",ci);U(this,"Hooks",Xt);this.use(...e)}walkTokens(e,t){var i,s;let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let o=r;for(let a of o.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of o.rows)for(let c of a)n=n.concat(this.walkTokens(c.tokens,t));break}case"list":{let o=r;n=n.concat(this.walkTokens(o.items,t));break}default:{let o=r;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);n=n.concat(this.walkTokens(c,t))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let 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 r=t.renderers[s.name];r?t.renderers[s.name]=function(...o){let a=s.renderer.apply(this,o);return a===!1&&(a=r.apply(this,o)),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 r=t[s.level];r?r.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 ui(this.defaults);for(let r in n.renderer){if(!(r in s))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;let o=r,a=n.renderer[o],c=s[o];s[o]=(...u)=>{let l=a.apply(s,u);return l===!1&&(l=c.apply(s,u)),l||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new ci(this.defaults);for(let r in n.tokenizer){if(!(r in s))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let o=r,a=n.tokenizer[o],c=s[o];s[o]=(...u)=>{let l=a.apply(s,u);return l===!1&&(l=c.apply(s,u)),l}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new Xt;for(let r in n.hooks){if(!(r in s))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;let o=r,a=n.hooks[o],c=s[o];Xt.passThroughHooks.has(r)?s[o]=u=>{if(this.defaults.async&&Xt.passThroughHooksRespectAsync.has(r))return(async()=>{let d=await a.call(s,u);return c.call(s,d)})();let l=a.call(s,u);return c.call(s,l)}:s[o]=(...u)=>{if(this.defaults.async)return(async()=>{let d=await a.apply(s,u);return d===!1&&(d=await c.apply(s,u)),d})();let l=a.apply(s,u);return l===!1&&(l=c.apply(s,u)),l}}i.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,r=n.walkTokens;i.walkTokens=function(o){let a=[];return a.push(r.call(this,o)),s&&(a=a.concat(s.call(this,o))),a}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ye.lex(e,t??this.defaults)}parser(e,t){return ve.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},r=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return r(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 r(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return r(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 o=s.hooks?await s.hooks.preprocess(t):t,a=await(s.hooks?await s.hooks.provideLexer():e?ye.lex:ye.lexInline)(o,s),c=s.hooks?await s.hooks.processAllTokens(a):a;s.walkTokens&&await Promise.all(this.walkTokens(c,s.walkTokens));let u=await(s.hooks?await s.hooks.provideParser():e?ve.parse:ve.parseInline)(c,s);return s.hooks?await s.hooks.postprocess(u):u})().catch(r);try{s.hooks&&(t=s.hooks.preprocess(t));let o=(s.hooks?s.hooks.provideLexer():e?ye.lex:ye.lexInline)(t,s);s.hooks&&(o=s.hooks.processAllTokens(o)),s.walkTokens&&this.walkTokens(o,s.walkTokens);let a=(s.hooks?s.hooks.provideParser():e?ve.parse:ve.parseInline)(o,s);return s.hooks&&(a=s.hooks.postprocess(a)),a}catch(o){return r(o)}}}onError(e,t){return n=>{if(n.message+=`
1825
+ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Re(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},ct=new vg;function K(e,t){return ct.parse(e,t)}K.options=K.setOptions=function(e){return ct.setOptions(e),K.defaults=ct.defaults,kc(K.defaults),K};K.getDefaults=Er;K.defaults=ht;K.use=function(...e){return ct.use(...e),K.defaults=ct.defaults,kc(K.defaults),K};K.walkTokens=function(e,t){return ct.walkTokens(e,t)};K.parseInline=ct.parseInline;K.Parser=ve;K.parser=ve.parse;K.Renderer=ui;K.TextRenderer=Rr;K.Lexer=ye;K.lexer=ye.lex;K.Tokenizer=ci;K.Hooks=Xt;K.parse=K;K.options;K.setOptions;K.use;K.walkTokens;K.parseInline;ve.parse;ye.lex;K.setOptions({gfm:!0,breaks:!0,mangle:!1});const ga=["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"],ma=["class","href","rel","target","title","start"];let ya=!1;const bg=14e4,wg=4e4,kg=200,ls=5e4,tt=new Map;function Sg(e){const t=tt.get(e);return t===void 0?null:(tt.delete(e),tt.set(e,t),t)}function va(e,t){if(tt.set(e,t),tt.size<=kg)return;const n=tt.keys().next().value;n&&tt.delete(n)}function Ag(){ya||(ya=!0,Os.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function di(e){const t=e.trim();if(!t)return"";if(Ag(),t.length<=ls){const o=Sg(t);if(o!==null)return o}const n=dl(t,bg),i=n.truncated?`
1826
1826
 
1827
- … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>bg){const a=`<pre class="code-block">${Ag(`${n.text}${i}`)}</pre>`,c=Os.sanitize(a,{ALLOWED_TAGS:ga,ALLOWED_ATTR:ma});return t.length<=ls&&va(t,c),c}const s=K.parse(`${n.text}${i}`),r=Os.sanitize(s,{ALLOWED_TAGS:ga,ALLOWED_ATTR:ma});return t.length<=ls&&va(t,r),r}function Ag(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const xg=1500,$g=2e3,Ic="Copy as markdown",Eg="Copied",Cg="Copy failed";async function Tg(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 Un(e,t){e.title=t,e.setAttribute("aria-label",t)}function _g(e){const t=e.label??Ic;return p`
1827
+ … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>wg){const a=`<pre class="code-block">${xg(`${n.text}${i}`)}</pre>`,c=Os.sanitize(a,{ALLOWED_TAGS:ga,ALLOWED_ATTR:ma});return t.length<=ls&&va(t,c),c}const s=K.parse(`${n.text}${i}`),r=Os.sanitize(s,{ALLOWED_TAGS:ga,ALLOWED_ATTR:ma});return t.length<=ls&&va(t,r),r}function xg(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const $g=1500,Eg=2e3,Lc="Copy as markdown",Cg="Copied",Tg="Copy failed";async function _g(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 Un(e,t){e.title=t,e.setAttribute("aria-label",t)}function Mg(e){const t=e.label??Lc;return p`
1828
1828
  <button
1829
1829
  class="chat-copy-btn"
1830
1830
  type="button"
1831
1831
  title=${t}
1832
1832
  aria-label=${t}
1833
- @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 Tg(e.text());if(i.isConnected){if(delete i.dataset.copying,i.removeAttribute("aria-busy"),i.disabled=!1,!s){i.dataset.error="1",Un(i,Cg),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.error,Un(i,t))},$g);return}i.dataset.copied="1",Un(i,Eg),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,Un(i,t))},xg)}}}
1833
+ @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 _g(e.text());if(i.isConnected){if(delete i.dataset.copying,i.removeAttribute("aria-busy"),i.disabled=!1,!s){i.dataset.error="1",Un(i,Tg),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.error,Un(i,t))},Eg);return}i.dataset.copied="1",Un(i,Cg),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,Un(i,t))},$g)}}}
1834
1834
  >
1835
1835
  <span class="chat-copy-btn__icon" aria-hidden="true">
1836
1836
  <span class="chat-copy-btn__icon-copy">${O.copy}</span>
1837
1837
  <span class="chat-copy-btn__icon-check">${O.check}</span>
1838
1838
  </span>
1839
1839
  </button>
1840
- `}function Mg(e){return _g({text:()=>e,label:Ic})}function Pg(e){const t=e,n=Lg(t.content),i=[];for(const s of n){const r=String(s.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(r)||typeof s.name=="string"&&s.arguments!=null)&&i.push({kind:"call",name:s.name??"tool",args:Ig(s.arguments??s.args)})}for(const s of n){const r=String(s.type??"").toLowerCase();if(r!=="toolresult"&&r!=="tool_result")continue;const o=Rg(s),a=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:a,text:o})}if(ml(e)&&!i.some(s=>s.kind==="result")){const s=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",r=hl(e)??void 0;i.push({kind:"result",name:s,text:r})}return i}function Lg(e){return Array.isArray(e)?e.filter(Boolean):[]}function Ig(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 Rg(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function Ng(e){var s;const n=e.content,i=[];if(Array.isArray(n))for(const r of n){if(typeof r!="object"||r===null)continue;const o=r;if(o.type==="image")if(((s=o.source)==null?void 0:s.type)==="base64"){const a=o.source,c=a.data,u=a.media_type||"image/png",l=c.startsWith("data:")?c:`data:${u};base64,${c}`;i.push({url:l})}else if(typeof o.data=="string"&&o.data){const a=o.data,c=o.mimeType||o.media_type||"image/png",u=a.startsWith("data:")?a:`data:${c};base64,${a}`;i.push({url:u})}else typeof o.url=="string"&&i.push({url:o.url});else if(o.type==="image_url"){const a=o.image_url;typeof(a==null?void 0:a.url)=="string"&&i.push({url:a.url})}}return i}function Dg(e){return p`
1840
+ `}function Pg(e){return Mg({text:()=>e,label:Lc})}function Lg(e){const t=e,n=Ig(t.content),i=[];for(const s of n){const r=String(s.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(r)||typeof s.name=="string"&&s.arguments!=null)&&i.push({kind:"call",name:s.name??"tool",args:Rg(s.arguments??s.args)})}for(const s of n){const r=String(s.type??"").toLowerCase();if(r!=="toolresult"&&r!=="tool_result")continue;const o=Ng(s),a=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:a,text:o})}if(gl(e)&&!i.some(s=>s.kind==="result")){const s=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",r=pl(e)??void 0;i.push({kind:"result",name:s,text:r})}return i}function Ig(e){return Array.isArray(e)?e.filter(Boolean):[]}function Rg(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 Ng(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function Dg(e){var s;const n=e.content,i=[];if(Array.isArray(n))for(const r of n){if(typeof r!="object"||r===null)continue;const o=r;if(o.type==="image")if(((s=o.source)==null?void 0:s.type)==="base64"){const a=o.source,c=a.data,u=a.media_type||"image/png",l=c.startsWith("data:")?c:`data:${u};base64,${c}`;i.push({url:l})}else if(typeof o.data=="string"&&o.data){const a=o.data,c=o.mimeType||o.media_type||"image/png",u=a.startsWith("data:")?a:`data:${c};base64,${a}`;i.push({url:u})}else typeof o.url=="string"&&i.push({url:o.url});else if(o.type==="image_url"){const a=o.image_url;typeof(a==null?void 0:a.url)=="string"&&i.push({url:a.url})}}return i}function Og(e){return p`
1841
1841
  <div class="chat-group assistant">
1842
1842
  <div class="chat-group-messages">
1843
1843
  <div class="chat-bubble chat-reading-indicator" aria-hidden="true">
@@ -1847,7 +1847,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
1847
1847
  </div>
1848
1848
  </div>
1849
1849
  </div>
1850
- `}function Og(e){return p`
1850
+ `}function Bg(e){return p`
1851
1851
  <div class="chat-group assistant">
1852
1852
  <div class="chat-group-messages">
1853
1853
  <div class="chat-interim fade-in">
@@ -1855,22 +1855,22 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
1855
1855
  </div>
1856
1856
  </div>
1857
1857
  </div>
1858
- `}function Bg(e,t,n,i){return p`
1858
+ `}function Fg(e,t,n,i){return p`
1859
1859
  <div class="chat-group assistant">
1860
1860
  <div class="chat-group-messages">
1861
- ${Rc({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
1861
+ ${Ic({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
1862
1862
  </div>
1863
1863
  </div>
1864
- `}function Fg(e,t){const n=gl(e.role),i=n==="user"?"user":n==="assistant"?"assistant":"other",s=new Date(e.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"});return p`
1864
+ `}function Ug(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 p`
1865
1865
  <div class="chat-group ${i}">
1866
1866
  <div class="chat-group-messages">
1867
- ${e.messages.map((r,o)=>Rc(r.message,{isStreaming:e.isStreaming&&o===e.messages.length-1,showReasoning:t.showReasoning}))}
1867
+ ${e.messages.map((r,o)=>Ic(r.message,{isStreaming:e.isStreaming&&o===e.messages.length-1,showReasoning:t.showReasoning}))}
1868
1868
  <div class="chat-group-footer">
1869
1869
  <span class="chat-group-timestamp">${s}</span>
1870
1870
  </div>
1871
1871
  </div>
1872
1872
  </div>
1873
- `}function Ug(e){return e.length===0?k:p`
1873
+ `}function Wg(e){return e.length===0?k:p`
1874
1874
  <div class="chat-message-images">
1875
1875
  ${e.map(t=>p`
1876
1876
  <img
@@ -1881,14 +1881,14 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
1881
1881
  />
1882
1882
  `)}
1883
1883
  </div>
1884
- `}function Rc(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",r=ml(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",a=Pg(e).length>0,c=Ng(e),u=c.length>0,l=hl(e),d=t.showReasoning&&s==="assistant"?md(e):null,h=l!=null&&l.trim()?l:null,v=d?vd(d):null,y=h,b=(s==="assistant"||s==="user")&&!!(y!=null&&y.trim()),S=["chat-bubble",b?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!y&&(a||r)||!y&&!u?k:p`
1884
+ `}function Ic(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",r=gl(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",a=Lg(e).length>0,c=Dg(e),u=c.length>0,l=pl(e),d=t.showReasoning&&s==="assistant"?yd(e):null,h=l!=null&&l.trim()?l:null,v=d?bd(d):null,y=h,b=(s==="assistant"||s==="user")&&!!(y!=null&&y.trim()),S=["chat-bubble",b?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!y&&(a||r)||!y&&!u?k:p`
1885
1885
  <div class="${S}">
1886
- ${b?Mg(y):k}
1887
- ${Ug(c)}
1886
+ ${b?Pg(y):k}
1887
+ ${Wg(c)}
1888
1888
  ${v?p`<div class="chat-thinking">${ai(di(v))}</div>`:k}
1889
1889
  ${y?p`<div class="chat-text">${ai(di(y))}</div>`:k}
1890
1890
  </div>
1891
- `}function Wg(e){return p`
1891
+ `}function Kg(e){return p`
1892
1892
  <div class="sidebar-panel">
1893
1893
  <div class="sidebar-header">
1894
1894
  <div class="sidebar-title">Tool Output</div>
@@ -1905,7 +1905,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
1905
1905
  `:e.content?p`<div class="sidebar-markdown">${ai(di(e.content))}</div>`:p`<div class="muted">No content available</div>`}
1906
1906
  </div>
1907
1907
  </div>
1908
- `}var Kg=Object.defineProperty,zg=Object.getOwnPropertyDescriptor,Ti=(e,t,n,i)=>{for(var s=i>1?void 0:i?zg(t,n):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(s=(i?o(t,n,s):o(s))||s);return i&&s&&Kg(t,n,s),s};let Mt=class extends $t{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 r=this.startRatio+s;r=Math.max(this.minRatio,Math.min(this.maxRatio,r)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:r},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 p``}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)}};Mt.styles=Nu`
1908
+ `}var zg=Object.defineProperty,jg=Object.getOwnPropertyDescriptor,Ti=(e,t,n,i)=>{for(var s=i>1?void 0:i?jg(t,n):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(s=(i?o(t,n,s):o(s))||s);return i&&s&&zg(t,n,s),s};let Mt=class extends $t{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 r=this.startRatio+s;r=Math.max(this.minRatio,Math.min(this.maxRatio,r)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:r},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 p``}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)}};Mt.styles=Nu`
1909
1909
  :host {
1910
1910
  width: 4px;
1911
1911
  cursor: col-resize;
@@ -1931,21 +1931,21 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
1931
1931
  :host(.dragging) {
1932
1932
  background: var(--accent, #007bff);
1933
1933
  }
1934
- `;Ti([bi({type:Number})],Mt.prototype,"splitRatio",2);Ti([bi({type:Number})],Mt.prototype,"minRatio",2);Ti([bi({type:Number})],Mt.prototype,"maxRatio",2);Mt=Ti([ol("resizable-divider")],Mt);function Wn(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 jg=1,Hg=1,ft="emoji",Pt="keyvalue",Nr="favorites",qg="tokens",Nc="tokens",Vg="unicode",Dc="count",Gg="group",Qg="order",Oc="group-order",Ws="eTag",pi="url",ba="skinTone",Nt="readonly",Dr="readwrite",Bc="skinUnicodes",Yg="skinUnicodes",Xg="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Zg="en";function Jg(e,t){const n=new Set,i=[];for(const s of e){const r=t(s);n.has(r)||(n.add(r),i.push(s))}return i}function wa(e){return Jg(e,t=>t.unicode)}function em(e){function t(n,i,s){const r=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[o,[a,c]]of Object.entries(s))r.createIndex(o,a,{multiEntry:c});return r}t(Pt),t(ft,Vg,{[Nc]:[qg,!0],[Oc]:[[Gg,Qg]],[Bc]:[Yg,!0]}),t(Nr,void 0,{[Dc]:[""]})}const Ks={},Qn={},hi={};function Fc(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function tm(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,jg);Ks[e]=s,s.onupgradeneeded=r=>{r.oldVersion<Hg&&em(s.result)},Fc(n,i,s)});return t.onclose=()=>Or(e),t}function nm(e){return Qn[e]||(Qn[e]=tm(e)),Qn[e]}function De(e,t,n,i){return new Promise((s,r)=>{const o=e.transaction(t,n,{durability:"relaxed"}),a=typeof t=="string"?o.objectStore(t):t.map(u=>o.objectStore(u));let c;i(a,o,u=>{c=u}),o.oncomplete=()=>s(c),o.onerror=()=>r(o.error)})}function Or(e){const t=Ks[e],n=t&&t.result;if(n){n.close();const i=hi[e];if(i)for(const s of i)s()}delete Ks[e],delete Qn[e],delete hi[e]}function im(e){return new Promise((t,n)=>{Or(e);const i=indexedDB.deleteDatabase(e);Fc(t,n,i)})}function sm(e,t){let n=hi[e];n||(n=hi[e]=[]),n.push(t)}const rm=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 Ct(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||rm.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const om=2;function Uc(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=om)}function am(e){return e.map(({annotation:n,emoticon:i,group:s,order:r,shortcodes:o,skins:a,tags:c,emoji:u,version:l})=>{const d=[...new Set(Uc([...(o||[]).map(Ct).flat(),...(c||[]).map(Ct).flat(),...Ct(n),i]))].sort(),h={annotation:n,group:s,order:r,tags:c,tokens:d,unicode:u,version:l};if(i&&(h.emoticon=i),o&&(h.shortcodes=o),a){h.skinTones=[],h.skinUnicodes=[],h.skinVersions=[];for(const{tone:v,emoji:y,version:b}of a)h.skinTones.push(v),h.skinUnicodes.push(y),h.skinVersions.push(b)}return h})}function Wc(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function ut(e,t,n){Wc(e,"get",t,n)}function Kc(e,t,n){Wc(e,"getAll",t,n)}function Br(e){e.commit&&e.commit()}function lm(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 zc(e,t){const n=lm(e,s=>s.length),i=[];for(const s of n)e.some(r=>r.findIndex(o=>t(o)===t(s))===-1)||i.push(s);return i}async function cm(e){return!await Fr(e,Pt,pi)}async function um(e,t,n){const[i,s]=await Promise.all([Ws,pi].map(r=>Fr(e,Pt,r)));return i===n&&s===t}async function dm(e,t){return De(e,ft,Nt,(i,s,r)=>{let o;const a=()=>{i.getAll(o&&IDBKeyRange.lowerBound(o,!0),50).onsuccess=c=>{const u=c.target.result;for(const l of u)if(o=l.unicode,t(l))return r(l);if(u.length<50)return r();a()}};a()})}async function jc(e,t,n,i){{const s=am(t);await De(e,[ft,Pt],Dr,([r,o],a)=>{let c,u,l=0;function d(){++l===2&&h()}function h(){if(!(c===i&&u===n)){r.clear();for(const v of s)r.put(v);o.put(i,Ws),o.put(n,pi),Br(a)}}ut(o,Ws,v=>{c=v,d()}),ut(o,pi,v=>{u=v,d()})})}}async function pm(e,t){return De(e,ft,Nt,(n,i,s)=>{const r=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);Kc(n.index(Oc),r,s)})}async function Hc(e,t){const n=Uc(Ct(t));return n.length?De(e,ft,Nt,(i,s,r)=>{const o=[],a=()=>{o.length===n.length&&c()},c=()=>{const u=zc(o,l=>l.unicode);r(u.sort((l,d)=>l.order<d.order?-1:1))};for(let u=0;u<n.length;u++){const l=n[u],d=u===n.length-1?IDBKeyRange.bound(l,l+"￿",!1,!0):IDBKeyRange.only(l);Kc(i.index(Nc),d,h=>{o.push(h),a()})}}):[]}async function hm(e,t){const n=await Hc(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(r=>r.toLowerCase()).includes(t.toLowerCase()))[0]||null:await dm(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function fm(e,t){return De(e,ft,Nt,(n,i,s)=>ut(n,t,r=>{if(r)return s(r);ut(n.index(Bc),t,o=>s(o||null))}))}function Fr(e,t,n){return De(e,t,Nt,(i,s,r)=>ut(i,n,r))}function gm(e,t,n,i){return De(e,t,Dr,(s,r)=>{s.put(i,n),Br(r)})}function mm(e,t){return De(e,Nr,Dr,(n,i)=>ut(n,t,s=>{n.put((s||0)+1,t),Br(i)}))}function ym(e,t,n){return n===0?[]:De(e,[Nr,ft],Nt,([i,s],r,o)=>{const a=[];i.index(Dc).openCursor(void 0,"prev").onsuccess=c=>{const u=c.target.result;if(!u)return o(a);function l(v){if(a.push(v),a.length===n)return o(a);u.continue()}const d=u.primaryKey,h=t.byName(d);if(h)return l(h);ut(s,d,v=>{if(v)return l(v);u.continue()})}})}const Kn="";function vm(e,t){const n=new Map;for(const s of e){const r=t(s);for(const o of r){let a=n;for(let u=0;u<o.length;u++){const l=o.charAt(u);let d=a.get(l);d||(d=new Map,a.set(l,d)),a=d}let c=a.get(Kn);c||(c=[],a.set(Kn,c)),c.push(s)}}return(s,r)=>{let o=n;for(let u=0;u<s.length;u++){const l=s.charAt(u),d=o.get(l);if(d)o=d;else return[]}if(r)return o.get(Kn)||[];const a=[],c=[o];for(;c.length;){const l=[...c.shift().entries()].sort((d,h)=>d[0]<h[0]?-1:1);for(const[d,h]of l)d===Kn?a.push(...h):c.push(h)}return a}}const bm=["name","url"];function wm(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||bm.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function ka(e){wm(e);const t=(h,v)=>h.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),s=vm(e,h=>{const v=new Set;if(h.shortcodes)for(const y of h.shortcodes)for(const b of Ct(y))v.add(b);return v}),r=h=>s(h,!0),o=h=>s(h,!1),a=h=>{const v=Ct(h),y=v.map((b,S)=>(S<v.length-1?r:o)(b));return zc(y,b=>b.name).sort(t)},c=new Map,u=new Map;for(const h of e){u.set(h.name.toLowerCase(),h);for(const v of h.shortcodes||[])c.set(v.toLowerCase(),h)}return{all:n,search:a,byShortcode:h=>c.get(h.toLowerCase()),byName:h=>u.get(h.toLowerCase())}}const km=typeof wrappedJSObject<"u";function Qt(e){if(!e)return e;if(km&&(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 qc(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Sm=["annotation","emoji","group","order","version"];function Am(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Sm.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function Vc(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function xm(e){const t=await fetch(e,{method:"HEAD"});Vc(t,e);const n=t.headers.get("etag");return qc(n),n}async function zs(e){const t=await fetch(e);Vc(t,e);const n=t.headers.get("etag");qc(n);const i=await t.json();return Am(i),[n,i]}function $m(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Em(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 Gc(e){const t=JSON.stringify(e);let n=Em(t);const i=await crypto.subtle.digest("SHA-1",n),s=$m(i);return btoa(s)}async function Cm(e,t){let n,i=await xm(t);if(!i){const s=await zs(t);i=s[0],n=s[1],i||(i=await Gc(n))}await um(e,t,i)||(n||(n=(await zs(t))[1]),await jc(e,n,t,i))}async function Tm(e,t){let[n,i]=await zs(t);n||(n=await Gc(i)),await jc(e,i,t,n)}async function _m(e,t){try{await Cm(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class Mm{constructor({dataSource:t=Xg,locale:n=Zg,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=ka(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await nm(this._dbName);sm(this._dbName,this._clear);const n=this.dataSource;await cm(t)?await Tm(t,n):this._lazyUpdate=_m(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(),wa(await pm(this._db,t)).map(Qt)}async getEmojiBySearchQuery(t){Wn(t),await this.ready();const n=this._custom.search(t),i=wa(await Hc(this._db,t)).map(Qt);return[...n,...i]}async getEmojiByShortcode(t){Wn(t),await this.ready();const n=this._custom.byShortcode(t);return n||Qt(await hm(this._db,t))}async getEmojiByUnicodeOrName(t){Wn(t),await this.ready();const n=this._custom.byName(t);return n||Qt(await fm(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Fr(this._db,Pt,ba)||0}async setPreferredSkinTone(t){return cs(t),await this.ready(),gm(this._db,Pt,ba,t)}async incrementFavoriteEmojiCount(t){return Wn(t),await this.ready(),mm(this._db,t)}async getTopFavoriteEmoji(t){return cs(t),await this.ready(),(await ym(this._db,this._custom,t)).map(Qt)}set customEmoji(t){this._custom=ka(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 Or(this._dbName)}async delete(){await this._shutdown(),await im(this._dbName)}}const js=[[-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})),us=js.slice(1),Pm=2,Sa=6,Qc=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function Aa(e){return e.unicode.includes("‍")}const Lm={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},Im=1e3,Rm="🖐️",Nm=8,Dm=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],Yc='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',Om=(e,t)=>e<t?-1:e>t?1:0,xa=(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 ${Yc}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},Bm=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function Fm(e){const t=xa(e,"#000"),n=xa(e,"#fff");return t&&n&&Bm(t,n)}function Um(){const e=Object.entries(Lm);try{for(const[t,n]of e)if(Fm(t))return n}catch{}return e[0][1]}let ds;const ps=()=>(ds||(ds=new Promise(e=>Qc(()=>e(Um())))),ds),Hs=new Map,Wm="️",Km="\uD83C",zm="‍",jm=127995,Hm=57339;function qm(e,t){if(t===0)return e;const n=e.indexOf(zm);return n!==-1?e.substring(0,n)+String.fromCodePoint(jm+t-1)+e.substring(n):(e.endsWith(Wm)&&(e=e.substring(0,e.length-1)),e+Km+String.fromCodePoint(Hm+t-1))}function xe(e){e.preventDefault(),e.stopPropagation()}function hs(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function Xc(e,t){const n=new Set,i=[];for(const s of e){const r=t(s);n.has(r)||(n.add(r),i.push(s))}return i}function Vm(e,t){const n=i=>{const s={};for(const r of i)typeof r.tone=="number"&&r.version<=t&&(s[r.tone]=r.unicode);return s};return e.map(({unicode:i,skins:s,shortcodes:r,url:o,name:a,category:c,annotation:u})=>({unicode:i,name:a,shortcodes:r,url:o,category:c,annotation:u,id:i||a,skins:s&&n(s)}))}const Yn=requestAnimationFrame;let Gm=typeof ResizeObserver=="function";function Qm(e,t,n){let i;Gm?(i=new ResizeObserver(n),i.observe(e)):Yn(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function $a(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let fs;function Ym(e,t,n){let i=!0,s=!1;for(const r of e){const o=n(r);if(!o)continue;const a=$a(o);a===0&&(s=!0),typeof fs>"u"&&(fs=$a(t));const c=a/1.8<fs;Hs.set(r.unicode,c),c||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
1934
+ `;Ti([bi({type:Number})],Mt.prototype,"splitRatio",2);Ti([bi({type:Number})],Mt.prototype,"minRatio",2);Ti([bi({type:Number})],Mt.prototype,"maxRatio",2);Mt=Ti([ol("resizable-divider")],Mt);function Wn(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 Hg=1,qg=1,ft="emoji",Pt="keyvalue",Nr="favorites",Vg="tokens",Rc="tokens",Gg="unicode",Nc="count",Qg="group",Yg="order",Dc="group-order",Ws="eTag",pi="url",ba="skinTone",Nt="readonly",Dr="readwrite",Oc="skinUnicodes",Xg="skinUnicodes",Zg="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Jg="en";function em(e,t){const n=new Set,i=[];for(const s of e){const r=t(s);n.has(r)||(n.add(r),i.push(s))}return i}function wa(e){return em(e,t=>t.unicode)}function tm(e){function t(n,i,s){const r=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[o,[a,c]]of Object.entries(s))r.createIndex(o,a,{multiEntry:c});return r}t(Pt),t(ft,Gg,{[Rc]:[Vg,!0],[Dc]:[[Qg,Yg]],[Oc]:[Xg,!0]}),t(Nr,void 0,{[Nc]:[""]})}const Ks={},Qn={},hi={};function Bc(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function nm(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,Hg);Ks[e]=s,s.onupgradeneeded=r=>{r.oldVersion<qg&&tm(s.result)},Bc(n,i,s)});return t.onclose=()=>Or(e),t}function im(e){return Qn[e]||(Qn[e]=nm(e)),Qn[e]}function De(e,t,n,i){return new Promise((s,r)=>{const o=e.transaction(t,n,{durability:"relaxed"}),a=typeof t=="string"?o.objectStore(t):t.map(u=>o.objectStore(u));let c;i(a,o,u=>{c=u}),o.oncomplete=()=>s(c),o.onerror=()=>r(o.error)})}function Or(e){const t=Ks[e],n=t&&t.result;if(n){n.close();const i=hi[e];if(i)for(const s of i)s()}delete Ks[e],delete Qn[e],delete hi[e]}function sm(e){return new Promise((t,n)=>{Or(e);const i=indexedDB.deleteDatabase(e);Bc(t,n,i)})}function rm(e,t){let n=hi[e];n||(n=hi[e]=[]),n.push(t)}const om=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 Ct(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||om.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const am=2;function Fc(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=am)}function lm(e){return e.map(({annotation:n,emoticon:i,group:s,order:r,shortcodes:o,skins:a,tags:c,emoji:u,version:l})=>{const d=[...new Set(Fc([...(o||[]).map(Ct).flat(),...(c||[]).map(Ct).flat(),...Ct(n),i]))].sort(),h={annotation:n,group:s,order:r,tags:c,tokens:d,unicode:u,version:l};if(i&&(h.emoticon=i),o&&(h.shortcodes=o),a){h.skinTones=[],h.skinUnicodes=[],h.skinVersions=[];for(const{tone:v,emoji:y,version:b}of a)h.skinTones.push(v),h.skinUnicodes.push(y),h.skinVersions.push(b)}return h})}function Uc(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function ut(e,t,n){Uc(e,"get",t,n)}function Wc(e,t,n){Uc(e,"getAll",t,n)}function Br(e){e.commit&&e.commit()}function cm(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 Kc(e,t){const n=cm(e,s=>s.length),i=[];for(const s of n)e.some(r=>r.findIndex(o=>t(o)===t(s))===-1)||i.push(s);return i}async function um(e){return!await Fr(e,Pt,pi)}async function dm(e,t,n){const[i,s]=await Promise.all([Ws,pi].map(r=>Fr(e,Pt,r)));return i===n&&s===t}async function pm(e,t){return De(e,ft,Nt,(i,s,r)=>{let o;const a=()=>{i.getAll(o&&IDBKeyRange.lowerBound(o,!0),50).onsuccess=c=>{const u=c.target.result;for(const l of u)if(o=l.unicode,t(l))return r(l);if(u.length<50)return r();a()}};a()})}async function zc(e,t,n,i){{const s=lm(t);await De(e,[ft,Pt],Dr,([r,o],a)=>{let c,u,l=0;function d(){++l===2&&h()}function h(){if(!(c===i&&u===n)){r.clear();for(const v of s)r.put(v);o.put(i,Ws),o.put(n,pi),Br(a)}}ut(o,Ws,v=>{c=v,d()}),ut(o,pi,v=>{u=v,d()})})}}async function hm(e,t){return De(e,ft,Nt,(n,i,s)=>{const r=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);Wc(n.index(Dc),r,s)})}async function jc(e,t){const n=Fc(Ct(t));return n.length?De(e,ft,Nt,(i,s,r)=>{const o=[],a=()=>{o.length===n.length&&c()},c=()=>{const u=Kc(o,l=>l.unicode);r(u.sort((l,d)=>l.order<d.order?-1:1))};for(let u=0;u<n.length;u++){const l=n[u],d=u===n.length-1?IDBKeyRange.bound(l,l+"￿",!1,!0):IDBKeyRange.only(l);Wc(i.index(Rc),d,h=>{o.push(h),a()})}}):[]}async function fm(e,t){const n=await jc(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(r=>r.toLowerCase()).includes(t.toLowerCase()))[0]||null:await pm(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function gm(e,t){return De(e,ft,Nt,(n,i,s)=>ut(n,t,r=>{if(r)return s(r);ut(n.index(Oc),t,o=>s(o||null))}))}function Fr(e,t,n){return De(e,t,Nt,(i,s,r)=>ut(i,n,r))}function mm(e,t,n,i){return De(e,t,Dr,(s,r)=>{s.put(i,n),Br(r)})}function ym(e,t){return De(e,Nr,Dr,(n,i)=>ut(n,t,s=>{n.put((s||0)+1,t),Br(i)}))}function vm(e,t,n){return n===0?[]:De(e,[Nr,ft],Nt,([i,s],r,o)=>{const a=[];i.index(Nc).openCursor(void 0,"prev").onsuccess=c=>{const u=c.target.result;if(!u)return o(a);function l(v){if(a.push(v),a.length===n)return o(a);u.continue()}const d=u.primaryKey,h=t.byName(d);if(h)return l(h);ut(s,d,v=>{if(v)return l(v);u.continue()})}})}const Kn="";function bm(e,t){const n=new Map;for(const s of e){const r=t(s);for(const o of r){let a=n;for(let u=0;u<o.length;u++){const l=o.charAt(u);let d=a.get(l);d||(d=new Map,a.set(l,d)),a=d}let c=a.get(Kn);c||(c=[],a.set(Kn,c)),c.push(s)}}return(s,r)=>{let o=n;for(let u=0;u<s.length;u++){const l=s.charAt(u),d=o.get(l);if(d)o=d;else return[]}if(r)return o.get(Kn)||[];const a=[],c=[o];for(;c.length;){const l=[...c.shift().entries()].sort((d,h)=>d[0]<h[0]?-1:1);for(const[d,h]of l)d===Kn?a.push(...h):c.push(h)}return a}}const wm=["name","url"];function km(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||wm.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function ka(e){km(e);const t=(h,v)=>h.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),s=bm(e,h=>{const v=new Set;if(h.shortcodes)for(const y of h.shortcodes)for(const b of Ct(y))v.add(b);return v}),r=h=>s(h,!0),o=h=>s(h,!1),a=h=>{const v=Ct(h),y=v.map((b,S)=>(S<v.length-1?r:o)(b));return Kc(y,b=>b.name).sort(t)},c=new Map,u=new Map;for(const h of e){u.set(h.name.toLowerCase(),h);for(const v of h.shortcodes||[])c.set(v.toLowerCase(),h)}return{all:n,search:a,byShortcode:h=>c.get(h.toLowerCase()),byName:h=>u.get(h.toLowerCase())}}const Sm=typeof wrappedJSObject<"u";function Qt(e){if(!e)return e;if(Sm&&(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 Hc(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Am=["annotation","emoji","group","order","version"];function xm(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Am.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function qc(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function $m(e){const t=await fetch(e,{method:"HEAD"});qc(t,e);const n=t.headers.get("etag");return Hc(n),n}async function zs(e){const t=await fetch(e);qc(t,e);const n=t.headers.get("etag");Hc(n);const i=await t.json();return xm(i),[n,i]}function Em(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Cm(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 Vc(e){const t=JSON.stringify(e);let n=Cm(t);const i=await crypto.subtle.digest("SHA-1",n),s=Em(i);return btoa(s)}async function Tm(e,t){let n,i=await $m(t);if(!i){const s=await zs(t);i=s[0],n=s[1],i||(i=await Vc(n))}await dm(e,t,i)||(n||(n=(await zs(t))[1]),await zc(e,n,t,i))}async function _m(e,t){let[n,i]=await zs(t);n||(n=await Vc(i)),await zc(e,i,t,n)}async function Mm(e,t){try{await Tm(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class Pm{constructor({dataSource:t=Zg,locale:n=Jg,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=ka(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await im(this._dbName);rm(this._dbName,this._clear);const n=this.dataSource;await um(t)?await _m(t,n):this._lazyUpdate=Mm(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(),wa(await hm(this._db,t)).map(Qt)}async getEmojiBySearchQuery(t){Wn(t),await this.ready();const n=this._custom.search(t),i=wa(await jc(this._db,t)).map(Qt);return[...n,...i]}async getEmojiByShortcode(t){Wn(t),await this.ready();const n=this._custom.byShortcode(t);return n||Qt(await fm(this._db,t))}async getEmojiByUnicodeOrName(t){Wn(t),await this.ready();const n=this._custom.byName(t);return n||Qt(await gm(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Fr(this._db,Pt,ba)||0}async setPreferredSkinTone(t){return cs(t),await this.ready(),mm(this._db,Pt,ba,t)}async incrementFavoriteEmojiCount(t){return Wn(t),await this.ready(),ym(this._db,t)}async getTopFavoriteEmoji(t){return cs(t),await this.ready(),(await vm(this._db,this._custom,t)).map(Qt)}set customEmoji(t){this._custom=ka(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 Or(this._dbName)}async delete(){await this._shutdown(),await sm(this._dbName)}}const js=[[-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})),us=js.slice(1),Lm=2,Sa=6,Gc=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function Aa(e){return e.unicode.includes("‍")}const Im={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},Rm=1e3,Nm="🖐️",Dm=8,Om=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],Qc='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',Bm=(e,t)=>e<t?-1:e>t?1:0,xa=(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 ${Qc}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},Fm=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function Um(e){const t=xa(e,"#000"),n=xa(e,"#fff");return t&&n&&Fm(t,n)}function Wm(){const e=Object.entries(Im);try{for(const[t,n]of e)if(Um(t))return n}catch{}return e[0][1]}let ds;const ps=()=>(ds||(ds=new Promise(e=>Gc(()=>e(Wm())))),ds),Hs=new Map,Km="️",zm="\uD83C",jm="‍",Hm=127995,qm=57339;function Vm(e,t){if(t===0)return e;const n=e.indexOf(jm);return n!==-1?e.substring(0,n)+String.fromCodePoint(Hm+t-1)+e.substring(n):(e.endsWith(Km)&&(e=e.substring(0,e.length-1)),e+zm+String.fromCodePoint(qm+t-1))}function xe(e){e.preventDefault(),e.stopPropagation()}function hs(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function Yc(e,t){const n=new Set,i=[];for(const s of e){const r=t(s);n.has(r)||(n.add(r),i.push(s))}return i}function Gm(e,t){const n=i=>{const s={};for(const r of i)typeof r.tone=="number"&&r.version<=t&&(s[r.tone]=r.unicode);return s};return e.map(({unicode:i,skins:s,shortcodes:r,url:o,name:a,category:c,annotation:u})=>({unicode:i,name:a,shortcodes:r,url:o,category:c,annotation:u,id:i||a,skins:s&&n(s)}))}const Yn=requestAnimationFrame;let Qm=typeof ResizeObserver=="function";function Ym(e,t,n){let i;Qm?(i=new ResizeObserver(n),i.observe(e)):Yn(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function $a(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let fs;function Xm(e,t,n){let i=!0,s=!1;for(const r of e){const o=n(r);if(!o)continue;const a=$a(o);a===0&&(s=!0),typeof fs>"u"&&(fs=$a(t));const c=a/1.8<fs;Hs.set(r.unicode,c),c||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
1935
1935
  This is likely due to using \`display:none\` which is unsupported.
1936
1936
  If this is a Jest/Vitest environment, you can ignore this warning.
1937
- For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function Xm(e){return Xc(e,t=>t)}function Zm(e){e&&(e.scrollTop=0)}function an(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function Ea(e){return""+e}function Jm(e){const t=document.createElement("template");return t.innerHTML=e,t}const ey=new WeakMap,ty=new WeakMap,ny=Symbol("un-keyed"),iy="replaceChildren"in Element.prototype;function sy(e,t){iy?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function ry(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 oy(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=ry(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&sy(i,e)}function ay(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:r,attributeName:o,attributeValuePre:a,attributeValuePost:c}}=n,u=e[r];if(s!==u)if(n.currentExpression=u,o)if(u===null)i.removeAttribute(o);else{const l=a+Ea(u)+c;i.setAttribute(o,l)}else{let l;Array.isArray(u)?oy(u,n):u instanceof Element?(l=u,i.replaceWith(l)):i.nodeValue=Ea(u),l&&(n.targetNode=l)}}}function ly(e){let t="",n=!1,i=!1,s=-1;const r=new Map,o=[];let a=0;for(let u=0,l=e.length;u<l;u++){const d=e[u];if(t+=d.slice(a),u===l-1)break;for(let $=0;$<d.length;$++)switch(d.charAt($)){case"<":{d.charAt($+1)==="/"?o.pop():(n=!0,o.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const h=o[o.length-1],v=an(r,h,()=>[]);let y,b,S;if(i){const $=/(\S+)="?([^"=]*)$/.exec(d);y=$[1],b=$[2];const C=/^([^">]*)("?)/.exec(e[u+1]);S=C[1],t=t.slice(0,-1*$[0].length),a=C[0].length}else a=0;const x={attributeName:y,attributeValuePre:b,attributeValuePost:S,expressionIndex:u};v.push(x),!n&&!i&&(t+=" ")}return{template:Jm(t),elementsToBindings:r}}function Ca(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],r=s.attributeName?t:t.firstChild,o={binding:s,targetNode:r,targetParentNode:void 0,currentExpression:void 0};n.push(o)}}function cy(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))Ca(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let r=e,o=-1;do{const a=t.get(++o);a&&Ca(a,r,n)}while(r=s.nextNode())}return n}function uy(e){const{template:t,elementsToBindings:n}=an(ey,e,()=>ly(e)),i=t.cloneNode(!0).content.firstElementChild,s=cy(i,n);return function(o){return ay(o,s),i}}function dy(e){const t=an(ty,e,()=>new Map);let n=ny;function i(r,...o){const a=an(t,r,()=>new Map);return an(a,n,()=>uy(r))(o)}function s(r,o,a){return r.map((c,u)=>{const l=n;n=a(c);try{return o(c,u)}finally{n=l}})}return{map:s,html:i}}function py(e,t,n,i,s,r,o,a,c){const{labelWithSkin:u,titleForEmoji:l,unicodeWithSkin:d}=n,{html:h,map:v}=dy(t);function y($,C,T){return v($,(M,R)=>h`<button role="${C?"option":"menuitem"}" aria-selected="${C?R===t.activeSearchItem:null}" aria-label="${u(M,t.currentSkinTone)}" title="${l(M)}" class="${"emoji"+(C&&R===t.activeSearchItem?" active":"")+(M.unicode?"":" custom-emoji")}" id="${`${T}-${M.id}`}" style="${M.unicode?null:`--custom-emoji-background: url(${JSON.stringify(M.url)})`}">${M.unicode?d(M,t.currentSkinTone):""}</button>`,M=>`${T}-${M.id}`)}const S=h`<section data-ref="rootElement" class="picker" aria-label="${t.i18n.regionLabel}" style="${t.pickerStyle||""}"><div class="pad-top"></div><div class="search-row"><div class="search-wrapper"><input id="search" class="search" type="search" role="combobox" enterkeyhint="search" placeholder="${t.i18n.searchLabel}" autocapitalize="none" autocomplete="off" spellcheck="true" aria-expanded="${!!(t.searchMode&&t.currentEmojis.length)}" aria-controls="search-results" aria-describedby="search-description" aria-autocomplete="list" aria-activedescendant="${t.activeSearchItemId?`emo-${t.activeSearchItemId}`:null}" data-ref="searchElement" data-on-input="onSearchInput" data-on-keydown="onSearchKeydown"><label class="sr-only" for="search">${t.i18n.searchLabel}</label> <span id="search-description" class="sr-only">${t.i18n.searchDescription}</span></div><div class="skintone-button-wrapper ${t.skinTonePickerExpandedAfterAnimation?"expanded":""}"><button id="skintone-button" class="emoji ${t.skinTonePickerExpanded?"hide-focus":""}" aria-label="${t.skinToneButtonLabel}" title="${t.skinToneButtonLabel}" aria-describedby="skintone-description" aria-haspopup="listbox" aria-expanded="${t.skinTonePickerExpanded}" aria-controls="skintone-list" data-on-click="onClickSkinToneButton">${t.skinToneButtonText||""}</button></div><span id="skintone-description" class="sr-only">${t.i18n.skinToneDescription}</span><div data-ref="skinToneDropdown" id="skintone-list" class="skintone-list hide-focus ${t.skinTonePickerExpanded?"":"hidden no-animate"}" style="transform:translateY(${t.skinTonePickerExpanded?0:"calc(-1 * var(--num-skintones) * var(--total-emoji-size))"})" role="listbox" aria-label="${t.i18n.skinTonesLabel}" aria-activedescendant="skintone-${t.activeSkinTone}" aria-hidden="${!t.skinTonePickerExpanded}" tabIndex="-1" data-on-focusout="onSkinToneOptionsFocusOut" data-on-click="onSkinToneOptionsClick" data-on-keydown="onSkinToneOptionsKeydown" data-on-keyup="onSkinToneOptionsKeyup">${v(t.skinTones,($,C)=>h`<div id="skintone-${C}" class="emoji ${C===t.activeSkinTone?"active":""}" aria-selected="${C===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[C]}" aria-label="${t.i18n.skinTones[C]}">${$}</div>`,$=>$)}</div></div><div class="nav" role="tablist" style="grid-template-columns:repeat(${t.groups.length},1fr)" aria-label="${t.i18n.categoriesLabel}" data-on-keydown="onNavKeydown" data-on-click="onNavClick">${v(t.groups,$=>h`<button role="tab" class="nav-button" aria-controls="tab-${$.id}" aria-label="${t.i18n.categories[$.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===$.id}" title="${t.i18n.categories[$.name]}" data-group-id="${$.id}"><div class="nav-emoji emoji">${$.emoji}</div></button>`,$=>$.id)}</div><div class="indicator-wrapper"><div class="indicator" style="transform:translateX(${(t.isRtl?-1:1)*t.currentGroupIndex*100}%)"></div></div><div class="message ${t.message?"":"gone"}" role="alert" aria-live="polite">${t.message||""}</div><div data-ref="tabpanelElement" class="tabpanel ${!t.databaseLoaded||t.message?"gone":""}" role="${t.searchMode?"region":"tabpanel"}" aria-label="${t.searchMode?t.i18n.searchResultsLabel:t.i18n.categories[t.currentGroup.name]}" id="${t.searchMode?null:`tab-${t.currentGroup.id}`}" tabIndex="0" data-on-click="onEmojiClick"><div data-action="calculateEmojiGridStyle">${v(t.currentEmojisWithCategories,($,C)=>h`<div><div id="menu-label-${C}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:$.category?$.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${C!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil($.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${C}" id="${t.searchMode?"search-results":null}">${y($.emojis,t.searchMode,"emo")}</div></div>`,$=>$.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${y(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,x=($,C)=>{for(const T of e.querySelectorAll(`[${$}]`))C(T,T.getAttribute($))};if(c){e.appendChild(S);for(const $ of["click","focusout","input","keydown","keyup"])x(`data-on-${$}`,(C,T)=>{C.addEventListener($,i[T])});x("data-ref",($,C)=>{r[C]=$}),o.addEventListener("abort",()=>{e.removeChild(S)})}x("data-action",($,C)=>{let T=a.get(C);T||a.set(C,T=new WeakSet),T.has($)||(T.add($),s[C]($))})}const fi=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function hy(e){let t=!1,n;const i=new Map,s=new Set;let r;const o=()=>{if(t)return;const u=[...s];s.clear();try{for(const l of u)l()}finally{r=!1,s.size&&(r=!0,fi(o))}},a=new Proxy({},{get(u,l){if(n){let d=i.get(l);d||(d=new Set,i.set(l,d)),d.add(n)}return u[l]},set(u,l,d){if(u[l]!==d){u[l]=d;const h=i.get(l);if(h){for(const v of h)s.add(v);r||(r=!0,fi(o))}}return!0}}),c=u=>{const l=()=>{const d=n;n=l;try{return u()}finally{n=d}};return l()};return e.addEventListener("abort",()=>{t=!0}),{state:a,createEffect:c}}function gs(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 Ta=new WeakMap;function fy(e,t,n){{const i=e.closest(".tabpanel");let s=Ta.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),Ta.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const ms=[],{assign:zn}=Object;function gy(e,t){const n={},i=new AbortController,s=i.signal,{state:r,createEffect:o}=hy(s),a=new Map;zn(r,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),zn(r,t),zn(r,{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:Nm,isRtl:!1,currentGroupIndex:0,groups:us,databaseLoaded:!1,activeSearchItemId:void 0}),o(()=>{r.currentGroup!==r.groups[r.currentGroupIndex]&&(r.currentGroup=r.groups[r.currentGroupIndex])});const c=A=>{e.getElementById(A).focus()},u=A=>e.getElementById(`emo-${A.id}`),l=(A,_)=>{n.rootElement.dispatchEvent(new CustomEvent(A,{detail:_,bubbles:!0,composed:!0}))},d=(A,_)=>A.id===_.id,h=(A,_)=>{const{category:N,emojis:D}=A,{category:q,emojis:z}=_;return N!==q?!1:gs(D,z,d)},v=A=>{gs(r.currentEmojis,A,d)||(r.currentEmojis=A)},y=A=>{r.searchMode!==A&&(r.searchMode=A)},b=A=>{gs(r.currentEmojisWithCategories,A,h)||(r.currentEmojisWithCategories=A)},S=(A,_)=>_&&A.skins&&A.skins[_]||A.unicode,C={labelWithSkin:(A,_)=>Xm([A.name||S(A,_),A.annotation,...A.shortcodes||ms].filter(Boolean)).join(", "),titleForEmoji:A=>A.annotation||(A.shortcodes||ms).join(", "),unicodeWithSkin:S},T={onClickSkinToneButton:H,onEmojiClick:Sn,onNavClick:wn,onNavKeydown:Ii,onSearchKeydown:Li,onSkinToneOptionsClick:An,onSkinToneOptionsFocusOut:Be,onSkinToneOptionsKeydown:Qe,onSkinToneOptionsKeyup:Ot,onSearchInput:xn},M={calculateEmojiGridStyle:J,updateOnIntersection:ge};let R=!0;o(()=>{py(e,r,C,T,M,n,s,a,R),R=!1}),r.emojiVersion||ps().then(A=>{A||(r.message=r.i18n.emojiUnsupportedMessage)}),o(()=>{async function A(){let _=!1;const N=setTimeout(()=>{_=!0,r.message=r.i18n.loadingMessage},Im);try{await r.database.ready(),r.databaseLoaded=!0}catch(D){console.error(D),r.message=r.i18n.networkErrorMessage}finally{clearTimeout(N),_&&(_=!1,r.message="")}}r.database&&A()}),o(()=>{r.pickerStyle=`
1937
+ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function Zm(e){return Yc(e,t=>t)}function Jm(e){e&&(e.scrollTop=0)}function an(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function Ea(e){return""+e}function ey(e){const t=document.createElement("template");return t.innerHTML=e,t}const ty=new WeakMap,ny=new WeakMap,iy=Symbol("un-keyed"),sy="replaceChildren"in Element.prototype;function ry(e,t){sy?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function oy(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 ay(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=oy(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&ry(i,e)}function ly(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:r,attributeName:o,attributeValuePre:a,attributeValuePost:c}}=n,u=e[r];if(s!==u)if(n.currentExpression=u,o)if(u===null)i.removeAttribute(o);else{const l=a+Ea(u)+c;i.setAttribute(o,l)}else{let l;Array.isArray(u)?ay(u,n):u instanceof Element?(l=u,i.replaceWith(l)):i.nodeValue=Ea(u),l&&(n.targetNode=l)}}}function cy(e){let t="",n=!1,i=!1,s=-1;const r=new Map,o=[];let a=0;for(let u=0,l=e.length;u<l;u++){const d=e[u];if(t+=d.slice(a),u===l-1)break;for(let $=0;$<d.length;$++)switch(d.charAt($)){case"<":{d.charAt($+1)==="/"?o.pop():(n=!0,o.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const h=o[o.length-1],v=an(r,h,()=>[]);let y,b,S;if(i){const $=/(\S+)="?([^"=]*)$/.exec(d);y=$[1],b=$[2];const C=/^([^">]*)("?)/.exec(e[u+1]);S=C[1],t=t.slice(0,-1*$[0].length),a=C[0].length}else a=0;const x={attributeName:y,attributeValuePre:b,attributeValuePost:S,expressionIndex:u};v.push(x),!n&&!i&&(t+=" ")}return{template:ey(t),elementsToBindings:r}}function Ca(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],r=s.attributeName?t:t.firstChild,o={binding:s,targetNode:r,targetParentNode:void 0,currentExpression:void 0};n.push(o)}}function uy(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))Ca(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let r=e,o=-1;do{const a=t.get(++o);a&&Ca(a,r,n)}while(r=s.nextNode())}return n}function dy(e){const{template:t,elementsToBindings:n}=an(ty,e,()=>cy(e)),i=t.cloneNode(!0).content.firstElementChild,s=uy(i,n);return function(o){return ly(o,s),i}}function py(e){const t=an(ny,e,()=>new Map);let n=iy;function i(r,...o){const a=an(t,r,()=>new Map);return an(a,n,()=>dy(r))(o)}function s(r,o,a){return r.map((c,u)=>{const l=n;n=a(c);try{return o(c,u)}finally{n=l}})}return{map:s,html:i}}function hy(e,t,n,i,s,r,o,a,c){const{labelWithSkin:u,titleForEmoji:l,unicodeWithSkin:d}=n,{html:h,map:v}=py(t);function y($,C,T){return v($,(M,R)=>h`<button role="${C?"option":"menuitem"}" aria-selected="${C?R===t.activeSearchItem:null}" aria-label="${u(M,t.currentSkinTone)}" title="${l(M)}" class="${"emoji"+(C&&R===t.activeSearchItem?" active":"")+(M.unicode?"":" custom-emoji")}" id="${`${T}-${M.id}`}" style="${M.unicode?null:`--custom-emoji-background: url(${JSON.stringify(M.url)})`}">${M.unicode?d(M,t.currentSkinTone):""}</button>`,M=>`${T}-${M.id}`)}const S=h`<section data-ref="rootElement" class="picker" aria-label="${t.i18n.regionLabel}" style="${t.pickerStyle||""}"><div class="pad-top"></div><div class="search-row"><div class="search-wrapper"><input id="search" class="search" type="search" role="combobox" enterkeyhint="search" placeholder="${t.i18n.searchLabel}" autocapitalize="none" autocomplete="off" spellcheck="true" aria-expanded="${!!(t.searchMode&&t.currentEmojis.length)}" aria-controls="search-results" aria-describedby="search-description" aria-autocomplete="list" aria-activedescendant="${t.activeSearchItemId?`emo-${t.activeSearchItemId}`:null}" data-ref="searchElement" data-on-input="onSearchInput" data-on-keydown="onSearchKeydown"><label class="sr-only" for="search">${t.i18n.searchLabel}</label> <span id="search-description" class="sr-only">${t.i18n.searchDescription}</span></div><div class="skintone-button-wrapper ${t.skinTonePickerExpandedAfterAnimation?"expanded":""}"><button id="skintone-button" class="emoji ${t.skinTonePickerExpanded?"hide-focus":""}" aria-label="${t.skinToneButtonLabel}" title="${t.skinToneButtonLabel}" aria-describedby="skintone-description" aria-haspopup="listbox" aria-expanded="${t.skinTonePickerExpanded}" aria-controls="skintone-list" data-on-click="onClickSkinToneButton">${t.skinToneButtonText||""}</button></div><span id="skintone-description" class="sr-only">${t.i18n.skinToneDescription}</span><div data-ref="skinToneDropdown" id="skintone-list" class="skintone-list hide-focus ${t.skinTonePickerExpanded?"":"hidden no-animate"}" style="transform:translateY(${t.skinTonePickerExpanded?0:"calc(-1 * var(--num-skintones) * var(--total-emoji-size))"})" role="listbox" aria-label="${t.i18n.skinTonesLabel}" aria-activedescendant="skintone-${t.activeSkinTone}" aria-hidden="${!t.skinTonePickerExpanded}" tabIndex="-1" data-on-focusout="onSkinToneOptionsFocusOut" data-on-click="onSkinToneOptionsClick" data-on-keydown="onSkinToneOptionsKeydown" data-on-keyup="onSkinToneOptionsKeyup">${v(t.skinTones,($,C)=>h`<div id="skintone-${C}" class="emoji ${C===t.activeSkinTone?"active":""}" aria-selected="${C===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[C]}" aria-label="${t.i18n.skinTones[C]}">${$}</div>`,$=>$)}</div></div><div class="nav" role="tablist" style="grid-template-columns:repeat(${t.groups.length},1fr)" aria-label="${t.i18n.categoriesLabel}" data-on-keydown="onNavKeydown" data-on-click="onNavClick">${v(t.groups,$=>h`<button role="tab" class="nav-button" aria-controls="tab-${$.id}" aria-label="${t.i18n.categories[$.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===$.id}" title="${t.i18n.categories[$.name]}" data-group-id="${$.id}"><div class="nav-emoji emoji">${$.emoji}</div></button>`,$=>$.id)}</div><div class="indicator-wrapper"><div class="indicator" style="transform:translateX(${(t.isRtl?-1:1)*t.currentGroupIndex*100}%)"></div></div><div class="message ${t.message?"":"gone"}" role="alert" aria-live="polite">${t.message||""}</div><div data-ref="tabpanelElement" class="tabpanel ${!t.databaseLoaded||t.message?"gone":""}" role="${t.searchMode?"region":"tabpanel"}" aria-label="${t.searchMode?t.i18n.searchResultsLabel:t.i18n.categories[t.currentGroup.name]}" id="${t.searchMode?null:`tab-${t.currentGroup.id}`}" tabIndex="0" data-on-click="onEmojiClick"><div data-action="calculateEmojiGridStyle">${v(t.currentEmojisWithCategories,($,C)=>h`<div><div id="menu-label-${C}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:$.category?$.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${C!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil($.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${C}" id="${t.searchMode?"search-results":null}">${y($.emojis,t.searchMode,"emo")}</div></div>`,$=>$.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${y(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,x=($,C)=>{for(const T of e.querySelectorAll(`[${$}]`))C(T,T.getAttribute($))};if(c){e.appendChild(S);for(const $ of["click","focusout","input","keydown","keyup"])x(`data-on-${$}`,(C,T)=>{C.addEventListener($,i[T])});x("data-ref",($,C)=>{r[C]=$}),o.addEventListener("abort",()=>{e.removeChild(S)})}x("data-action",($,C)=>{let T=a.get(C);T||a.set(C,T=new WeakSet),T.has($)||(T.add($),s[C]($))})}const fi=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function fy(e){let t=!1,n;const i=new Map,s=new Set;let r;const o=()=>{if(t)return;const u=[...s];s.clear();try{for(const l of u)l()}finally{r=!1,s.size&&(r=!0,fi(o))}},a=new Proxy({},{get(u,l){if(n){let d=i.get(l);d||(d=new Set,i.set(l,d)),d.add(n)}return u[l]},set(u,l,d){if(u[l]!==d){u[l]=d;const h=i.get(l);if(h){for(const v of h)s.add(v);r||(r=!0,fi(o))}}return!0}}),c=u=>{const l=()=>{const d=n;n=l;try{return u()}finally{n=d}};return l()};return e.addEventListener("abort",()=>{t=!0}),{state:a,createEffect:c}}function gs(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 Ta=new WeakMap;function gy(e,t,n){{const i=e.closest(".tabpanel");let s=Ta.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),Ta.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const ms=[],{assign:zn}=Object;function my(e,t){const n={},i=new AbortController,s=i.signal,{state:r,createEffect:o}=fy(s),a=new Map;zn(r,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),zn(r,t),zn(r,{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:Dm,isRtl:!1,currentGroupIndex:0,groups:us,databaseLoaded:!1,activeSearchItemId:void 0}),o(()=>{r.currentGroup!==r.groups[r.currentGroupIndex]&&(r.currentGroup=r.groups[r.currentGroupIndex])});const c=A=>{e.getElementById(A).focus()},u=A=>e.getElementById(`emo-${A.id}`),l=(A,_)=>{n.rootElement.dispatchEvent(new CustomEvent(A,{detail:_,bubbles:!0,composed:!0}))},d=(A,_)=>A.id===_.id,h=(A,_)=>{const{category:N,emojis:D}=A,{category:q,emojis:z}=_;return N!==q?!1:gs(D,z,d)},v=A=>{gs(r.currentEmojis,A,d)||(r.currentEmojis=A)},y=A=>{r.searchMode!==A&&(r.searchMode=A)},b=A=>{gs(r.currentEmojisWithCategories,A,h)||(r.currentEmojisWithCategories=A)},S=(A,_)=>_&&A.skins&&A.skins[_]||A.unicode,C={labelWithSkin:(A,_)=>Zm([A.name||S(A,_),A.annotation,...A.shortcodes||ms].filter(Boolean)).join(", "),titleForEmoji:A=>A.annotation||(A.shortcodes||ms).join(", "),unicodeWithSkin:S},T={onClickSkinToneButton:H,onEmojiClick:Sn,onNavClick:wn,onNavKeydown:Ii,onSearchKeydown:Li,onSkinToneOptionsClick:An,onSkinToneOptionsFocusOut:Be,onSkinToneOptionsKeydown:Qe,onSkinToneOptionsKeyup:Ot,onSearchInput:xn},M={calculateEmojiGridStyle:J,updateOnIntersection:ge};let R=!0;o(()=>{hy(e,r,C,T,M,n,s,a,R),R=!1}),r.emojiVersion||ps().then(A=>{A||(r.message=r.i18n.emojiUnsupportedMessage)}),o(()=>{async function A(){let _=!1;const N=setTimeout(()=>{_=!0,r.message=r.i18n.loadingMessage},Rm);try{await r.database.ready(),r.databaseLoaded=!0}catch(D){console.error(D),r.message=r.i18n.networkErrorMessage}finally{clearTimeout(N),_&&(_=!1,r.message="")}}r.database&&A()}),o(()=>{r.pickerStyle=`
1938
1938
  --num-groups: ${r.groups.length};
1939
1939
  --indicator-opacity: ${r.searchMode?0:1};
1940
- --num-skintones: ${Sa};`}),o(()=>{r.customEmoji&&r.database&&B()}),o(()=>{r.customEmoji&&r.customEmoji.length?r.groups!==js&&(r.groups=js):r.groups!==us&&(r.currentGroupIndex&&r.currentGroupIndex--,r.groups=us)}),o(()=>{async function A(){r.databaseLoaded&&(r.currentSkinTone=await r.database.getPreferredSkinTone())}A()}),o(()=>{r.skinTones=Array(Sa).fill().map((A,_)=>qm(r.skinToneEmoji,_))}),o(()=>{r.skinToneButtonText=r.skinTones[r.currentSkinTone]}),o(()=>{r.skinToneButtonLabel=r.i18n.skinToneLabel.replace("{skinTone}",r.i18n.skinTones[r.currentSkinTone])}),o(()=>{async function A(){const{database:_}=r,N=(await Promise.all(Dm.map(D=>_.getEmojiByUnicodeOrName(D)))).filter(Boolean);r.defaultFavoriteEmojis=N}r.databaseLoaded&&A()});function B(){const{customEmoji:A,database:_}=r,N=A||ms;_.customEmoji!==N&&(_.customEmoji=N)}o(()=>{async function A(){B();const{database:_,defaultFavoriteEmojis:N,numColumns:D}=r,q=await _.getTopFavoriteEmoji(D),z=await Ge(Xc([...q,...N],oe=>oe.unicode||oe.name).slice(0,D));r.currentFavorites=z}r.databaseLoaded&&r.defaultFavoriteEmojis&&A()});function J(A){Qm(A,s,()=>{{const _=getComputedStyle(n.rootElement),N=parseInt(_.getPropertyValue("--num-columns"),10),D=_.getPropertyValue("direction")==="rtl";r.numColumns=N,r.isRtl=D}})}function ge(A){fy(A,s,_=>{for(const{target:N,isIntersecting:D}of _)N.classList.toggle("onscreen",D)})}o(()=>{async function A(){const{searchText:_,currentGroup:N,databaseLoaded:D,customEmoji:q}=r;if(!D)r.currentEmojis=[],r.searchMode=!1;else if(_.length>=Pm){const z=await Pi(_);r.searchText===_&&(v(z),y(!0))}else{const{id:z}=N;if(z!==-1||q&&q.length){const oe=await Mi(z);r.currentGroup.id===z&&(v(oe),y(!1))}}}A()});const Oe=()=>{Yn(()=>Zm(n.tabpanelElement))};o(()=>{const{currentEmojis:A,emojiVersion:_}=r,N=A.filter(D=>D.unicode).filter(D=>Aa(D)&&!Hs.has(D.unicode));if(!_&&N.length)v(A),Yn(()=>X(N));else{const D=_?A:A.filter(Dt);v(D),Oe()}});function X(A){Ym(A,n.baselineEmoji,u)?Oe():r.currentEmojis=[...r.currentEmojis]}function Dt(A){return!A.unicode||!Aa(A)||Hs.get(A.unicode)}async function gt(A){const _=r.emojiVersion||await ps();return A.filter(({version:N})=>!N||N<=_)}async function Ge(A){return Vm(A,r.emojiVersion||await ps())}async function Mi(A){const _=A===-1?r.customEmoji:await r.database.getEmojiByGroup(A);return Ge(await gt(_))}async function Pi(A){return Ge(await gt(await r.database.getEmojiBySearchQuery(A)))}o(()=>{}),o(()=>{function A(){const{searchMode:N,currentEmojis:D}=r;if(N)return[{category:"",emojis:D}];const q=new Map;for(const z of D){const oe=z.category||"";let Fe=q.get(oe);Fe||(Fe=[],q.set(oe,Fe)),Fe.push(z)}return[...q.entries()].map(([z,oe])=>({category:z,emojis:oe})).sort((z,oe)=>r.customCategorySorting(z.category,oe.category))}const _=A();b(_)}),o(()=>{r.activeSearchItemId=r.activeSearchItem!==-1&&r.currentEmojis[r.activeSearchItem].id}),o(()=>{const{rawSearchText:A}=r;Qc(()=>{r.searchText=(A||"").trim(),r.activeSearchItem=-1})});function Li(A){if(!r.searchMode||!r.currentEmojis.length)return;const _=N=>{xe(A),r.activeSearchItem=hs(N,r.activeSearchItem,r.currentEmojis)};switch(A.key){case"ArrowDown":return _(!1);case"ArrowUp":return _(!0);case"Enter":if(r.activeSearchItem===-1)r.activeSearchItem=0;else return xe(A),G(r.currentEmojis[r.activeSearchItem].id)}}function wn(A){const{target:_}=A,N=_.closest(".nav-button");if(!N)return;const D=parseInt(N.dataset.groupId,10);n.searchElement.value="",r.rawSearchText="",r.searchText="",r.activeSearchItem=-1,r.currentGroupIndex=r.groups.findIndex(q=>q.id===D)}function Ii(A){const{target:_,key:N}=A,D=q=>{q&&(xe(A),q.focus())};switch(N){case"ArrowLeft":return D(_.previousElementSibling);case"ArrowRight":return D(_.nextElementSibling);case"Home":return D(_.parentElement.firstElementChild);case"End":return D(_.parentElement.lastElementChild)}}async function kn(A){const _=await r.database.getEmojiByUnicodeOrName(A),N=[...r.currentEmojis,...r.currentFavorites].find(q=>q.id===A),D=N.unicode&&S(N,r.currentSkinTone);return await r.database.incrementFavoriteEmojiCount(A),{emoji:_,skinTone:r.currentSkinTone,...D&&{unicode:D},...N.name&&{name:N.name}}}async function G(A){const _=kn(A);l("emoji-click-sync",_),l("emoji-click",await _)}function Sn(A){const{target:_}=A;if(!_.classList.contains("emoji"))return;xe(A);const N=_.id.substring(4);G(N)}function Q(A){r.currentSkinTone=A,r.skinTonePickerExpanded=!1,c("skintone-button"),l("skin-tone-change",{skinTone:A}),r.database.setPreferredSkinTone(A)}function An(A){const{target:{id:_}}=A,N=_&&_.match(/^skintone-(\d)/);if(!N)return;xe(A);const D=parseInt(N[1],10);Q(D)}function H(A){r.skinTonePickerExpanded=!r.skinTonePickerExpanded,r.activeSkinTone=r.currentSkinTone,r.skinTonePickerExpanded&&(xe(A),Yn(()=>c("skintone-list")))}o(()=>{r.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{r.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):r.skinTonePickerExpandedAfterAnimation=!1});function Qe(A){if(!r.skinTonePickerExpanded)return;const _=async N=>{xe(A),r.activeSkinTone=N};switch(A.key){case"ArrowUp":return _(hs(!0,r.activeSkinTone,r.skinTones));case"ArrowDown":return _(hs(!1,r.activeSkinTone,r.skinTones));case"Home":return _(0);case"End":return _(r.skinTones.length-1);case"Enter":return xe(A),Q(r.activeSkinTone);case"Escape":return xe(A),r.skinTonePickerExpanded=!1,c("skintone-button")}}function Ot(A){if(r.skinTonePickerExpanded&&A.key===" ")return xe(A),Q(r.activeSkinTone)}async function Be(A){const{relatedTarget:_}=A;(!_||_.id!=="skintone-list")&&(r.skinTonePickerExpanded=!1)}function xn(A){r.rawSearchText=A.target.value}return{$set(A){zn(r,A)},$destroy(){i.abort()}}}const my="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",yy="en";var vy={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"}},by=':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 Zc=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],wy=`:host{--emoji-font-family:${Yc}}`;class Ur extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=by+wy,this.shadowRoot.appendChild(n),this._ctx={locale:yy,dataSource:my,skinToneEmoji:Rm,customCategorySorting:Om,customEmoji:null,i18n:vy,emojiVersion:null,...t};for(const i of Zc)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){_a(this),this._cmp||(this._cmp=gy(this.shadowRoot,this._ctx))}disconnectedCallback(){_a(this),fi(()=>{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,r)=>r.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 Mm({locale:t,dataSource:n}))}_dbFlush(){fi(()=>this._dbCreate())}}const Jc={};for(const e of Zc)Jc[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(Ur.prototype,Jc);function _a(e){e instanceof Ur||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Ur);function ky(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 Ma(e){e.style.height="44px",e.style.overflowY="hidden"}const Sy=5e3;function Ay(e){return e?e.active?p`
1940
+ --num-skintones: ${Sa};`}),o(()=>{r.customEmoji&&r.database&&B()}),o(()=>{r.customEmoji&&r.customEmoji.length?r.groups!==js&&(r.groups=js):r.groups!==us&&(r.currentGroupIndex&&r.currentGroupIndex--,r.groups=us)}),o(()=>{async function A(){r.databaseLoaded&&(r.currentSkinTone=await r.database.getPreferredSkinTone())}A()}),o(()=>{r.skinTones=Array(Sa).fill().map((A,_)=>Vm(r.skinToneEmoji,_))}),o(()=>{r.skinToneButtonText=r.skinTones[r.currentSkinTone]}),o(()=>{r.skinToneButtonLabel=r.i18n.skinToneLabel.replace("{skinTone}",r.i18n.skinTones[r.currentSkinTone])}),o(()=>{async function A(){const{database:_}=r,N=(await Promise.all(Om.map(D=>_.getEmojiByUnicodeOrName(D)))).filter(Boolean);r.defaultFavoriteEmojis=N}r.databaseLoaded&&A()});function B(){const{customEmoji:A,database:_}=r,N=A||ms;_.customEmoji!==N&&(_.customEmoji=N)}o(()=>{async function A(){B();const{database:_,defaultFavoriteEmojis:N,numColumns:D}=r,q=await _.getTopFavoriteEmoji(D),z=await Ge(Yc([...q,...N],oe=>oe.unicode||oe.name).slice(0,D));r.currentFavorites=z}r.databaseLoaded&&r.defaultFavoriteEmojis&&A()});function J(A){Ym(A,s,()=>{{const _=getComputedStyle(n.rootElement),N=parseInt(_.getPropertyValue("--num-columns"),10),D=_.getPropertyValue("direction")==="rtl";r.numColumns=N,r.isRtl=D}})}function ge(A){gy(A,s,_=>{for(const{target:N,isIntersecting:D}of _)N.classList.toggle("onscreen",D)})}o(()=>{async function A(){const{searchText:_,currentGroup:N,databaseLoaded:D,customEmoji:q}=r;if(!D)r.currentEmojis=[],r.searchMode=!1;else if(_.length>=Lm){const z=await Pi(_);r.searchText===_&&(v(z),y(!0))}else{const{id:z}=N;if(z!==-1||q&&q.length){const oe=await Mi(z);r.currentGroup.id===z&&(v(oe),y(!1))}}}A()});const Oe=()=>{Yn(()=>Jm(n.tabpanelElement))};o(()=>{const{currentEmojis:A,emojiVersion:_}=r,N=A.filter(D=>D.unicode).filter(D=>Aa(D)&&!Hs.has(D.unicode));if(!_&&N.length)v(A),Yn(()=>X(N));else{const D=_?A:A.filter(Dt);v(D),Oe()}});function X(A){Xm(A,n.baselineEmoji,u)?Oe():r.currentEmojis=[...r.currentEmojis]}function Dt(A){return!A.unicode||!Aa(A)||Hs.get(A.unicode)}async function gt(A){const _=r.emojiVersion||await ps();return A.filter(({version:N})=>!N||N<=_)}async function Ge(A){return Gm(A,r.emojiVersion||await ps())}async function Mi(A){const _=A===-1?r.customEmoji:await r.database.getEmojiByGroup(A);return Ge(await gt(_))}async function Pi(A){return Ge(await gt(await r.database.getEmojiBySearchQuery(A)))}o(()=>{}),o(()=>{function A(){const{searchMode:N,currentEmojis:D}=r;if(N)return[{category:"",emojis:D}];const q=new Map;for(const z of D){const oe=z.category||"";let Fe=q.get(oe);Fe||(Fe=[],q.set(oe,Fe)),Fe.push(z)}return[...q.entries()].map(([z,oe])=>({category:z,emojis:oe})).sort((z,oe)=>r.customCategorySorting(z.category,oe.category))}const _=A();b(_)}),o(()=>{r.activeSearchItemId=r.activeSearchItem!==-1&&r.currentEmojis[r.activeSearchItem].id}),o(()=>{const{rawSearchText:A}=r;Gc(()=>{r.searchText=(A||"").trim(),r.activeSearchItem=-1})});function Li(A){if(!r.searchMode||!r.currentEmojis.length)return;const _=N=>{xe(A),r.activeSearchItem=hs(N,r.activeSearchItem,r.currentEmojis)};switch(A.key){case"ArrowDown":return _(!1);case"ArrowUp":return _(!0);case"Enter":if(r.activeSearchItem===-1)r.activeSearchItem=0;else return xe(A),G(r.currentEmojis[r.activeSearchItem].id)}}function wn(A){const{target:_}=A,N=_.closest(".nav-button");if(!N)return;const D=parseInt(N.dataset.groupId,10);n.searchElement.value="",r.rawSearchText="",r.searchText="",r.activeSearchItem=-1,r.currentGroupIndex=r.groups.findIndex(q=>q.id===D)}function Ii(A){const{target:_,key:N}=A,D=q=>{q&&(xe(A),q.focus())};switch(N){case"ArrowLeft":return D(_.previousElementSibling);case"ArrowRight":return D(_.nextElementSibling);case"Home":return D(_.parentElement.firstElementChild);case"End":return D(_.parentElement.lastElementChild)}}async function kn(A){const _=await r.database.getEmojiByUnicodeOrName(A),N=[...r.currentEmojis,...r.currentFavorites].find(q=>q.id===A),D=N.unicode&&S(N,r.currentSkinTone);return await r.database.incrementFavoriteEmojiCount(A),{emoji:_,skinTone:r.currentSkinTone,...D&&{unicode:D},...N.name&&{name:N.name}}}async function G(A){const _=kn(A);l("emoji-click-sync",_),l("emoji-click",await _)}function Sn(A){const{target:_}=A;if(!_.classList.contains("emoji"))return;xe(A);const N=_.id.substring(4);G(N)}function Q(A){r.currentSkinTone=A,r.skinTonePickerExpanded=!1,c("skintone-button"),l("skin-tone-change",{skinTone:A}),r.database.setPreferredSkinTone(A)}function An(A){const{target:{id:_}}=A,N=_&&_.match(/^skintone-(\d)/);if(!N)return;xe(A);const D=parseInt(N[1],10);Q(D)}function H(A){r.skinTonePickerExpanded=!r.skinTonePickerExpanded,r.activeSkinTone=r.currentSkinTone,r.skinTonePickerExpanded&&(xe(A),Yn(()=>c("skintone-list")))}o(()=>{r.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{r.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):r.skinTonePickerExpandedAfterAnimation=!1});function Qe(A){if(!r.skinTonePickerExpanded)return;const _=async N=>{xe(A),r.activeSkinTone=N};switch(A.key){case"ArrowUp":return _(hs(!0,r.activeSkinTone,r.skinTones));case"ArrowDown":return _(hs(!1,r.activeSkinTone,r.skinTones));case"Home":return _(0);case"End":return _(r.skinTones.length-1);case"Enter":return xe(A),Q(r.activeSkinTone);case"Escape":return xe(A),r.skinTonePickerExpanded=!1,c("skintone-button")}}function Ot(A){if(r.skinTonePickerExpanded&&A.key===" ")return xe(A),Q(r.activeSkinTone)}async function Be(A){const{relatedTarget:_}=A;(!_||_.id!=="skintone-list")&&(r.skinTonePickerExpanded=!1)}function xn(A){r.rawSearchText=A.target.value}return{$set(A){zn(r,A)},$destroy(){i.abort()}}}const yy="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",vy="en";var by={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"}},wy=':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 Xc=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],ky=`:host{--emoji-font-family:${Qc}}`;class Ur extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=wy+ky,this.shadowRoot.appendChild(n),this._ctx={locale:vy,dataSource:yy,skinToneEmoji:Nm,customCategorySorting:Bm,customEmoji:null,i18n:by,emojiVersion:null,...t};for(const i of Xc)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){_a(this),this._cmp||(this._cmp=my(this.shadowRoot,this._ctx))}disconnectedCallback(){_a(this),fi(()=>{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,r)=>r.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 Pm({locale:t,dataSource:n}))}_dbFlush(){fi(()=>this._dbCreate())}}const Zc={};for(const e of Xc)Zc[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(Ur.prototype,Zc);function _a(e){e instanceof Ur||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Ur);function Sy(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 Ma(e){e.style.height="44px",e.style.overflowY="hidden"}const Ay=5e3;function xy(e){return e?e.active?p`
1941
1941
  <div class="callout info compaction-indicator compaction-indicator--active">
1942
1942
  ${O.loader} Compacting context...
1943
1943
  </div>
1944
- `:e.completedAt&&Date.now()-e.completedAt<Sy?p`
1944
+ `:e.completedAt&&Date.now()-e.completedAt<Ay?p`
1945
1945
  <div class="callout success compaction-indicator compaction-indicator--complete">
1946
1946
  ${O.check} Context compacted
1947
1947
  </div>
1948
- `:k:k}const Zt=5*1024*1024;function Jt(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function At(e,t){var i,s,r;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 o=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(r=o==null?void 0:o.parentElement)==null||r.insertBefore(n,o)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const xy=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function $y(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function Ey(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||xy.test(e.name)}function Cy(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function Ty(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function _y(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 r=0;r<i.length;r++){const o=i[r];if($y(o)){if(!t.onAttachmentsChange)continue;if(o.size>Zt){At(n,`Image too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const c=a.result,u={id:Jt(),dataUrl:c,mimeType:o.type},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,u])},a.readAsDataURL(o)}else if(Ey(o)){if(!t.onAttachmentsChange)continue;if(o.size>Zt){At(n,`File too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const c=a.result,u={id:Jt(),dataUrl:"",mimeType:o.type||"text/plain",fileName:o.name,textContent:c},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,u])},a.readAsText(o)}else if(Cy(o)){if(!t.onAttachmentsChange)continue;if(o.size>Zt){At(n,`PDF too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const c=a.result,u={id:Jt(),dataUrl:c,mimeType:"application/pdf",fileName:o.name},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,u])},a.readAsDataURL(o)}else if(Ty(o)){if(!t.onAttachmentsChange)continue;if(o.size>Zt){At(n,`Video too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const c=a.result,u={id:Jt(),dataUrl:c,mimeType:o.type||"video/mp4",fileName:o.name},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,u])},a.readAsDataURL(o)}else At(n,`Unsupported file type: ${o.name}. Use the Files page to upload to workspace.`)}}function My(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Py(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function Ly(e,t){var s,r,o;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 c=n[a];(c.type.startsWith("image/")||c.type.startsWith("video/"))&&i.push(c)}if(i.length!==0){e.preventDefault();for(const a of i){const c=a.getAsFile();if(!c)continue;const u=c.type.startsWith("video/")?"Video":"Image";if(c.size>Zt){const d=((o=(r=e.target)==null?void 0:r.closest)==null?void 0:o.call(r,".chat"))??document.querySelector(".chat");d&&At(d,`${u} too large (${(c.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const l=new FileReader;l.onload=()=>{var b;const d=l.result,h=c.type.startsWith("video/"),v={id:Jt(),dataUrl:d,mimeType:c.type,fileName:h?c.name||"video.mp4":void 0},y=t.attachments??[];(b=t.onAttachmentsChange)==null||b.call(t,[...y,v])},l.readAsDataURL(c)}}}function Iy(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 r=o=>{i.contains(o.target)||t.contains(o.target)||(i.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",r,!0))};requestAnimationFrame(()=>document.addEventListener("click",r,!0))}}function Ry(e,t){const n=e.detail,i=n==null?void 0:n.unicode;if(!i)return;const s=e.currentTarget.closest(".chat-compose"),r=s==null?void 0:s.querySelector("textarea");if(!r)return;const o=r.selectionStart??t.draft.length,a=r.selectionEnd??o,c=t.draft.slice(0,o),u=t.draft.slice(a);t.onDraftChange(c+i+u);const l=s==null?void 0:s.querySelector(".emoji-picker-popup"),d=s==null?void 0:s.querySelector(".chat-compose__emoji");l==null||l.classList.remove("active"),d==null||d.classList.remove("active"),requestAnimationFrame(()=>{r.focus();const h=o+i.length;r.setSelectionRange(h,h)})}function Ny(e){const t=e.attachments??[];return t.length===0?k:p`
1948
+ `:k:k}const Zt=5*1024*1024;function Jt(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function At(e,t){var i,s,r;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 o=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(r=o==null?void 0:o.parentElement)==null||r.insertBefore(n,o)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const $y=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function Ey(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function Cy(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||$y.test(e.name)}function Ty(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function _y(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function My(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 r=0;r<i.length;r++){const o=i[r];if(Ey(o)){if(!t.onAttachmentsChange)continue;if(o.size>Zt){At(n,`Image too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const c=a.result,u={id:Jt(),dataUrl:c,mimeType:o.type},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,u])},a.readAsDataURL(o)}else if(Cy(o)){if(!t.onAttachmentsChange)continue;if(o.size>Zt){At(n,`File too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const c=a.result,u={id:Jt(),dataUrl:"",mimeType:o.type||"text/plain",fileName:o.name,textContent:c},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,u])},a.readAsText(o)}else if(Ty(o)){if(!t.onAttachmentsChange)continue;if(o.size>Zt){At(n,`PDF too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const c=a.result,u={id:Jt(),dataUrl:c,mimeType:"application/pdf",fileName:o.name},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,u])},a.readAsDataURL(o)}else if(_y(o)){if(!t.onAttachmentsChange)continue;if(o.size>Zt){At(n,`Video too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const c=a.result,u={id:Jt(),dataUrl:c,mimeType:o.type||"video/mp4",fileName:o.name},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,u])},a.readAsDataURL(o)}else At(n,`Unsupported file type: ${o.name}. Use the Files page to upload to workspace.`)}}function Py(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Ly(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function Iy(e,t){var s,r,o;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 c=n[a];(c.type.startsWith("image/")||c.type.startsWith("video/"))&&i.push(c)}if(i.length!==0){e.preventDefault();for(const a of i){const c=a.getAsFile();if(!c)continue;const u=c.type.startsWith("video/")?"Video":"Image";if(c.size>Zt){const d=((o=(r=e.target)==null?void 0:r.closest)==null?void 0:o.call(r,".chat"))??document.querySelector(".chat");d&&At(d,`${u} too large (${(c.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const l=new FileReader;l.onload=()=>{var b;const d=l.result,h=c.type.startsWith("video/"),v={id:Jt(),dataUrl:d,mimeType:c.type,fileName:h?c.name||"video.mp4":void 0},y=t.attachments??[];(b=t.onAttachmentsChange)==null||b.call(t,[...y,v])},l.readAsDataURL(c)}}}function Ry(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 r=o=>{i.contains(o.target)||t.contains(o.target)||(i.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",r,!0))};requestAnimationFrame(()=>document.addEventListener("click",r,!0))}}function Ny(e,t){const n=e.detail,i=n==null?void 0:n.unicode;if(!i)return;const s=e.currentTarget.closest(".chat-compose"),r=s==null?void 0:s.querySelector("textarea");if(!r)return;const o=r.selectionStart??t.draft.length,a=r.selectionEnd??o,c=t.draft.slice(0,o),u=t.draft.slice(a);t.onDraftChange(c+i+u);const l=s==null?void 0:s.querySelector(".emoji-picker-popup"),d=s==null?void 0:s.querySelector(".chat-compose__emoji");l==null||l.classList.remove("active"),d==null||d.classList.remove("active"),requestAnimationFrame(()=>{r.focus();const h=o+i.length;r.setSelectionRange(h,h)})}function Dy(e){const t=e.attachments??[];return t.length===0?k:p`
1949
1949
  <div class="chat-attachments">
1950
1950
  ${t.map(n=>{var i;return n.fileName?p`
1951
1951
  <div class="chat-attachment chat-attachment--file">
@@ -1978,7 +1978,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
1978
1978
  </div>
1979
1979
  `})}
1980
1980
  </div>
1981
- `}function eu(e){var h,v,y;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(b=>b.key===e.sessionKey),r=(s==null?void 0:s.reasoningLevel)??"off",o=e.showThinking&&r!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const a=(((y=e.attachments)==null?void 0:y.length)??0)>0,c=e.connected?a?"Add a message...":"Message...":"Connecting…",u=e.splitRatio??.6,l=!!(e.sidebarOpen&&e.onCloseSidebar),d=p`
1981
+ `}function Jc(e){var h,v,y;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(b=>b.key===e.sessionKey),r=(s==null?void 0:s.reasoningLevel)??"off",o=e.showThinking&&r!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const a=(((y=e.attachments)==null?void 0:y.length)??0)>0,c=e.connected?a?"Add a message...":"Message...":"Connecting…",u=e.splitRatio??.6,l=!!(e.sidebarOpen&&e.onCloseSidebar),d=p`
1982
1982
  <div
1983
1983
  class="chat-thread"
1984
1984
  role="log"
@@ -1986,20 +1986,20 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
1986
1986
  @scroll=${e.onChatScroll}
1987
1987
  >
1988
1988
  ${e.loading?p`<div class="muted">Loading chat…</div>`:k}
1989
- ${hf(Ky(e),b=>b.key,b=>b.kind==="interim"?Og(b.text):b.kind==="reading-indicator"?Dg():b.kind==="stream"?Bg(b.text,b.startedAt,e.onOpenSidebar):b.kind==="group"?Fg(b,{onOpenSidebar:e.onOpenSidebar,showReasoning:o,assistantName:e.assistantName}):k)}
1989
+ ${ff(zy(e),b=>b.key,b=>b.kind==="interim"?Bg(b.text):b.kind==="reading-indicator"?Og():b.kind==="stream"?Fg(b.text,b.startedAt,e.onOpenSidebar):b.kind==="group"?Ug(b,{onOpenSidebar:e.onOpenSidebar,showReasoning:o,assistantName:e.assistantName}):k)}
1990
1990
  </div>
1991
1991
  `;return p`
1992
1992
  <section
1993
1993
  class="card chat"
1994
- @drop=${b=>_y(b,e)}
1995
- @dragover=${My}
1996
- @dragleave=${Py}
1994
+ @drop=${b=>My(b,e)}
1995
+ @dragover=${Py}
1996
+ @dragleave=${Ly}
1997
1997
  >
1998
1998
  ${e.disabledReason?p`<div class="callout">${e.disabledReason}</div>`:k}
1999
1999
 
2000
2000
  ${e.error?p`<div class="callout danger">${e.error}</div>`:k}
2001
2001
 
2002
- ${Ay(e.compactionStatus)}
2002
+ ${xy(e.compactionStatus)}
2003
2003
 
2004
2004
  ${e.focusMode?p`
2005
2005
  <button
@@ -2040,7 +2040,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
2040
2040
  @resize=${b=>{var S;return(S=e.onSplitRatioChange)==null?void 0:S.call(e,b.detail.splitRatio)}}
2041
2041
  ></resizable-divider>
2042
2042
  <div class="chat-sidebar">
2043
- ${Wg({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
2043
+ ${Kg({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
2044
2044
  ${e.sidebarContent}
2045
2045
  \`\`\``)}})}
2046
2046
  </div>
@@ -2060,12 +2060,12 @@ ${e.sidebarContent}
2060
2060
  `:k}
2061
2061
 
2062
2062
  <div class="chat-compose">
2063
- ${Ny(e)}
2063
+ ${Dy(e)}
2064
2064
  <div class="chat-compose__row">
2065
2065
  <button
2066
2066
  class="chat-compose__emoji"
2067
2067
  type="button"
2068
- @click=${Iy}
2068
+ @click=${Ry}
2069
2069
  aria-label="Emoji"
2070
2070
  title="Emoji"
2071
2071
  >
@@ -2077,8 +2077,8 @@ ${e.sidebarContent}
2077
2077
  .value=${e.draft}
2078
2078
  ?disabled=${!e.connected}
2079
2079
  @keydown=${b=>{b.key==="Enter"&&(b.isComposing||b.keyCode===229||b.shiftKey||e.connected&&(b.preventDefault(),t&&(e.onSend(),Ma(b.target))))}}
2080
- @input=${b=>{const S=b.target;e.onDraftChange(S.value),ky(S)}}
2081
- @paste=${b=>Ly(b,e)}
2080
+ @input=${b=>{const S=b.target;e.onDraftChange(S.value),Sy(S)}}
2081
+ @paste=${b=>Iy(b,e)}
2082
2082
  placeholder=${c}
2083
2083
  ></textarea>
2084
2084
  </label>
@@ -2104,13 +2104,13 @@ ${e.sidebarContent}
2104
2104
  </div>
2105
2105
  <div class="emoji-picker-popup">
2106
2106
  <emoji-picker
2107
- @emoji-click=${b=>Ry(b,e)}
2107
+ @emoji-click=${b=>Ny(b,e)}
2108
2108
  ></emoji-picker>
2109
2109
  </div>
2110
- ${e.publicMode?k:Uy(e)}
2110
+ ${e.publicMode?k:Wy(e)}
2111
2111
  </div>
2112
2112
  </section>
2113
- `}const Dy=[{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 Oy(e){const t=new Set(e.filter(n=>n.provider==="anthropic").map(n=>n.id));return Dy.filter(n=>t.has(n.id)).map(n=>({key:`anthropic/${n.id}`,...n}))}const By=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function Fy(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(r=>r.classList.remove("active")),!i){n.classList.add("active");const r=o=>{!n.contains(o.target)&&o.target!==t&&!t.contains(o.target)&&(n.classList.remove("active"),document.removeEventListener("click",r))};requestAnimationFrame(()=>document.addEventListener("click",r))}}function Uy(e){if(!e.connected)return k;const t=e.modelCatalog??[],n=Oy(t);if(n.length===0)return k;const i=e.modelProvider&&e.model?`${e.modelProvider}/${e.model}`:null,s=e.thinkingLevel??"off",r=e.verboseLevel==="on"||e.verboseLevel==="full",o=e.fillerEnabled===!0;return p`
2113
+ `}const Oy=[{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 By(e){const t=new Set(e.filter(n=>n.provider==="anthropic").map(n=>n.id));return Oy.filter(n=>t.has(n.id)).map(n=>({key:`anthropic/${n.id}`,...n}))}const Fy=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function Uy(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(r=>r.classList.remove("active")),!i){n.classList.add("active");const r=o=>{!n.contains(o.target)&&o.target!==t&&!t.contains(o.target)&&(n.classList.remove("active"),document.removeEventListener("click",r))};requestAnimationFrame(()=>document.addEventListener("click",r))}}function Wy(e){if(!e.connected)return k;const t=e.modelCatalog??[],n=By(t);if(n.length===0)return k;const i=e.modelProvider&&e.model?`${e.modelProvider}/${e.model}`:null,s=e.thinkingLevel??"off",r=e.verboseLevel==="on"||e.verboseLevel==="full",o=e.fillerEnabled===!0;return p`
2114
2114
  <div class="chat-model-bar">
2115
2115
  <div class="chat-model-bar__select">
2116
2116
  <select
@@ -2131,7 +2131,7 @@ ${e.sidebarContent}
2131
2131
  .value=${s}
2132
2132
  @change=${a=>{const c=a.target.value;e.onThinkingLevelChange&&e.onThinkingLevelChange(c)}}
2133
2133
  >
2134
- ${By.map(a=>p`
2134
+ ${Fy.map(a=>p`
2135
2135
  <option value=${a.value} ?selected=${a.value===s}>
2136
2136
  Thinking: ${a.label}
2137
2137
  </option>
@@ -2141,7 +2141,7 @@ ${e.sidebarContent}
2141
2141
  <button
2142
2142
  class="chat-model-bar__settings-btn"
2143
2143
  type="button"
2144
- @click=${Fy}
2144
+ @click=${Uy}
2145
2145
  aria-label="Message settings"
2146
2146
  title="Message settings"
2147
2147
  >
@@ -2168,9 +2168,9 @@ ${e.sidebarContent}
2168
2168
  </label>
2169
2169
  </div>
2170
2170
  </div>
2171
- `}const Pa=200;function Wy(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=fl(i.message),r=gl(s.role),o=s.timestamp||Date.now();!n||n.role!==r?(n&&t.push(n),n={kind:"group",key:`group:${r}:${i.key}`,role:r,messages:[{message:i.message,key:i.key}],timestamp:o,isStreaming:!1}):n.messages.push({message:i.message,key:i.key})}return n&&t.push(n),t}function Ky(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",r=Math.max(0,n.length-Pa);r>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${Pa} messages (${r} hidden).`,timestamp:Date.now()}});for(let a=r;a<n.length;a++){const c=n[a],u=fl(c);!s&&u.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:La(c,a),message:c})}if(s)for(let a=0;a<i.length;a++)t.push({kind:"message",key:La(i[a],a+n.length),message:i[a]});if(e.interimText&&t.push({kind:"interim",key:"interim:thinking",text:e.interimText}),e.stream!==null){const a=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:a,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:a})}for(const a of e.queue){const c=((o=a.attachments)==null?void 0:o.filter(l=>l.fileName).map(l=>l.fileName))??[],u=c.length>0?a.text?`${c.join(", ")}
2171
+ `}const Pa=200;function Ky(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=hl(i.message),r=fl(s.role),o=s.timestamp||Date.now();!n||n.role!==r?(n&&t.push(n),n={kind:"group",key:`group:${r}:${i.key}`,role:r,messages:[{message:i.message,key:i.key}],timestamp:o,isStreaming:!1}):n.messages.push({message:i.message,key:i.key})}return n&&t.push(n),t}function zy(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",r=Math.max(0,n.length-Pa);r>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${Pa} messages (${r} hidden).`,timestamp:Date.now()}});for(let a=r;a<n.length;a++){const c=n[a],u=hl(c);!s&&u.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:La(c,a),message:c})}if(s)for(let a=0;a<i.length;a++)t.push({kind:"message",key:La(i[a],a+n.length),message:i[a]});if(e.interimText&&t.push({kind:"interim",key:"interim:thinking",text:e.interimText}),e.stream!==null){const a=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:a,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:a})}for(const a of e.queue){const c=((o=a.attachments)==null?void 0:o.filter(l=>l.fileName).map(l=>l.fileName))??[],u=c.length>0?a.text?`${c.join(", ")}
2172
2172
 
2173
- ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,message:{role:"user",content:[{type:"text",text:u}],timestamp:a.createdAt}})}return Wy(t)}function La(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 r=typeof n.messageId=="string"?n.messageId:"";if(r)return`msg:${r}`;const o=typeof n.timestamp=="number"?n.timestamp:null,a=typeof n.role=="string"?n.role:"unknown";return o!=null?`msg:${a}:${o}:${t}`:`msg:${a}:${t}`}const zy=p`<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 jy(e){if(!e.connected)return p`
2173
+ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,message:{role:"user",content:[{type:"text",text:u}],timestamp:a.createdAt}})}return Ky(t)}function La(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 r=typeof n.messageId=="string"?n.messageId:"";if(r)return`msg:${r}`;const o=typeof n.timestamp=="number"?n.timestamp:null,a=typeof n.role=="string"?n.role:"unknown";return o!=null?`msg:${a}:${o}:${t}`:`msg:${a}:${t}`}const jy=p`<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 Hy(e){if(!e.connected)return p`
2174
2174
  <div class="setup-container">
2175
2175
  <div class="setup-card">
2176
2176
  <div class="setup-spinner"></div>
@@ -2183,20 +2183,20 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2183
2183
  target="_blank"
2184
2184
  rel="noopener"
2185
2185
  title="Open public chat in new tab"
2186
- >Public ${zy}</a>`:k;return p`
2186
+ >Public ${jy}</a>`:k;return p`
2187
2187
  <div class="setup-container setup-container--full chat-page">
2188
2188
  ${pt("Chat",e.wsProps)}
2189
2189
  ${t}
2190
2190
  <div class="chat-viewport">
2191
- ${eu(e)}
2191
+ ${Jc(e)}
2192
2192
  </div>
2193
2193
  </div>
2194
- `}function Hy(e){return e?`${ul(e)} (${wi(e)})`:"n/a"}function tu(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?wi(t.lastRunAtMs):"never";return`${n} · last ${i}`}function nu(e){const t=e.schedule;return t.kind==="at"?`One-time: ${ul(t.atMs)}`:t.kind==="every"?`Every ${dl(t.everyMs)}`:qy(t.expr,t.tz)}function qy(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,r,o,a]=n,c=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",u=(b,S)=>new Date(2e3,0,1,b,S).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),l=/^\d{1,2}$/.test(i)?parseInt(i,10):null,d=Ia(s);if(l===null||!d)return`${e}${t?` (${t})`:""}`;const h=d.map(b=>u(b,l)),v=h.length<=3?h.join(" & "):`${h.slice(0,-1).join(", ")} & ${h[h.length-1]}`,y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(r==="*"&&o==="*"){if(a==="*")return`Daily at ${v}${c}`;if(a==="1-5")return`Weekdays at ${v}${c}`;if(a==="0,6"||a==="6,0")return`Weekends at ${v}${c}`;const b=Ia(a);if(b)return`${b.map(x=>y[x%7]??String(x)).join(", ")} at ${v}${c}`}return`${e}${t?` (${t})`:""}`}function Ia(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 Vy(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 Ra(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=[];return i&&s.push(i),n&&n!=="last"&&s.push(`via ${n}`),s.join(" ")||null}function Gy(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(r=>i.has(r)?!1:(i.add(r),!0))}function Qy(e,t){var i,s;if(t==="last")return"last";const n=(i=e.channelMeta)==null?void 0:i.find(r=>r.id===t);return n!=null&&n.label?n.label:((s=e.channelLabels)==null?void 0:s[t])??t}function Yy(e){return e||"Default"}const Na=p`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,Xy=p`<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>`,Zy=p`<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>`,iu=p`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,Jy=p`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`;function Da(e){const t=e.detailJobId?e.jobs.find(n=>n.id===e.detailJobId)??null:null;return p`
2195
- ${ev(e)}
2194
+ `}function qy(e){return e?`${cl(e)} (${wi(e)})`:"n/a"}function eu(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?wi(t.lastRunAtMs):"never";return`${n} · last ${i}`}function tu(e){const t=e.schedule;return t.kind==="at"?`One-time: ${cl(t.atMs)}`:t.kind==="every"?`Every ${ul(t.everyMs)}`:Vy(t.expr,t.tz)}function Vy(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,r,o,a]=n,c=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",u=(b,S)=>new Date(2e3,0,1,b,S).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),l=/^\d{1,2}$/.test(i)?parseInt(i,10):null,d=Ia(s);if(l===null||!d)return`${e}${t?` (${t})`:""}`;const h=d.map(b=>u(b,l)),v=h.length<=3?h.join(" & "):`${h.slice(0,-1).join(", ")} & ${h[h.length-1]}`,y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(r==="*"&&o==="*"){if(a==="*")return`Daily at ${v}${c}`;if(a==="1-5")return`Weekdays at ${v}${c}`;if(a==="0,6"||a==="6,0")return`Weekends at ${v}${c}`;const b=Ia(a);if(b)return`${b.map(x=>y[x%7]??String(x)).join(", ")} at ${v}${c}`}return`${e}${t?` (${t})`:""}`}function Ia(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 Gy(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 Ra(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=[];return i&&s.push(i),n&&n!=="last"&&s.push(`via ${n}`),s.join(" ")||null}function Qy(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(r=>i.has(r)?!1:(i.add(r),!0))}function Yy(e,t){var i,s;if(t==="last")return"last";const n=(i=e.channelMeta)==null?void 0:i.find(r=>r.id===t);return n!=null&&n.label?n.label:((s=e.channelLabels)==null?void 0:s[t])??t}function Xy(e){return e||"Default"}const Na=p`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,Zy=p`<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>`,Jy=p`<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>`,nu=p`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,ev=p`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`;function Da(e){const t=e.detailJobId?e.jobs.find(n=>n.id===e.detailJobId)??null:null;return p`
2196
2195
  ${tv(e)}
2197
- ${e.newEventModalOpen?iv(e):k}
2198
- ${t?rv(t,e):k}
2199
- `}function ev(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 p`
2196
+ ${nv(e)}
2197
+ ${e.newEventModalOpen?sv(e):k}
2198
+ ${t?ov(t,e):k}
2199
+ `}function tv(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 p`
2200
2200
  <div class="event-status-bar">
2201
2201
  <div class="event-status-bar__info">
2202
2202
  <span class="statusDot ${n?"ok":""}"></span>
@@ -2218,14 +2218,14 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2218
2218
  ${e.error?p`<span class="muted">${e.error}</span>`:k}
2219
2219
  </div>
2220
2220
  <button class="btn primary btn--sm" @click=${e.onNewEventModalOpen}>
2221
- ${Jy} New Event
2221
+ ${ev} New Event
2222
2222
  </button>
2223
2223
  </div>
2224
- `}function tv(e){return e.jobs.length===0?p`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:p`
2224
+ `}function nv(e){return e.jobs.length===0?p`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:p`
2225
2225
  <div class="event-grid">
2226
- ${e.jobs.map(t=>nv(t,e))}
2226
+ ${e.jobs.map(t=>iv(t,e))}
2227
2227
  </div>
2228
- `}function nv(e,t){return p`
2228
+ `}function iv(e,t){return p`
2229
2229
  <div
2230
2230
  class="event-card ${e.enabled?"":"disabled"}"
2231
2231
  @click=${()=>t.onDetailOpen(e)}
@@ -2236,12 +2236,12 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2236
2236
  ${e.enabled?"On":"Off"}
2237
2237
  </span>
2238
2238
  </div>
2239
- <div class="event-card__schedule">${nu(e)}</div>
2240
- ${e.agentId?p`<div class="event-card__agent">${Yy(e.agentId)}</div>`:k}
2239
+ <div class="event-card__schedule">${tu(e)}</div>
2240
+ ${e.agentId?p`<div class="event-card__agent">${Xy(e.agentId)}</div>`:k}
2241
2241
  ${Ra(e)?p`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${Ra(e)}</div>`:k}
2242
2242
  <div class="event-card__footer">
2243
2243
  <div class="event-card__status">
2244
- <span class="muted" style="font-size: 11px;">${tu(e)}</span>
2244
+ <span class="muted" style="font-size: 11px;">${eu(e)}</span>
2245
2245
  </div>
2246
2246
  <div class="event-card__actions" @click=${n=>n.stopPropagation()}>
2247
2247
  <button
@@ -2250,7 +2250,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2250
2250
  ?disabled=${t.busy}
2251
2251
  @click=${()=>t.onToggle(e,!e.enabled)}
2252
2252
  >
2253
- ${e.enabled?Xy:Na}
2253
+ ${e.enabled?Zy:Na}
2254
2254
  </button>
2255
2255
  <button
2256
2256
  class="btn-icon"
@@ -2266,18 +2266,18 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2266
2266
  ?disabled=${t.busy}
2267
2267
  @click=${()=>t.onRemove(e)}
2268
2268
  >
2269
- ${Zy}
2269
+ ${Jy}
2270
2270
  </button>
2271
2271
  </div>
2272
2272
  </div>
2273
2273
  </div>
2274
- `}function iv(e){const t=Gy(e);return p`
2274
+ `}function sv(e){const t=Qy(e);return p`
2275
2275
  <div class="event-modal-overlay" @click=${e.onNewEventModalClose}>
2276
2276
  <div class="event-modal" @click=${n=>n.stopPropagation()}>
2277
2277
  <div class="event-modal__header">
2278
2278
  <div class="event-modal__title">New Event</div>
2279
2279
  <button class="event-modal__close" @click=${e.onNewEventModalClose}>
2280
- ${iu}
2280
+ ${nu}
2281
2281
  </button>
2282
2282
  </div>
2283
2283
 
@@ -2329,7 +2329,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2329
2329
  </label>
2330
2330
  </div>
2331
2331
 
2332
- ${sv(e)}
2332
+ ${rv(e)}
2333
2333
 
2334
2334
  <div class="form-grid" style="margin-top: 12px;">
2335
2335
  <label class="field">
@@ -2391,7 +2391,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2391
2391
  @change=${n=>e.onFormChange({channel:n.target.value})}
2392
2392
  >
2393
2393
  ${t.map(n=>p`<option value=${n}>
2394
- ${Qy(e,n)}
2394
+ ${Yy(e,n)}
2395
2395
  </option>`)}
2396
2396
  </select>
2397
2397
  </label>
@@ -2430,7 +2430,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2430
2430
  </div>
2431
2431
  </div>
2432
2432
  </div>
2433
- `}function sv(e){const t=e.form;return t.scheduleKind==="at"?p`
2433
+ `}function rv(e){const t=e.form;return t.scheduleKind==="at"?p`
2434
2434
  <label class="field" style="margin-top: 12px;">
2435
2435
  <span>Run at</span>
2436
2436
  <input
@@ -2479,13 +2479,13 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2479
2479
  />
2480
2480
  </label>
2481
2481
  </div>
2482
- `}function rv(e,t){var n;return p`
2482
+ `}function ov(e,t){var n;return p`
2483
2483
  <div class="event-modal-overlay" @click=${t.onDetailClose}>
2484
2484
  <div class="event-modal" @click=${i=>i.stopPropagation()}>
2485
2485
  <div class="event-modal__header">
2486
2486
  <div class="event-modal__title">${e.name||"Untitled Event"}</div>
2487
2487
  <button class="event-modal__close" @click=${t.onDetailClose}>
2488
- ${iu}
2488
+ ${nu}
2489
2489
  </button>
2490
2490
  </div>
2491
2491
 
@@ -2502,7 +2502,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2502
2502
  </div>
2503
2503
  <div class="event-detail-row">
2504
2504
  <span class="event-detail-label">Schedule</span>
2505
- <span class="event-detail-value">${nu(e)}</span>
2505
+ <span class="event-detail-value">${tu(e)}</span>
2506
2506
  </div>
2507
2507
  ${e.agentId?p`
2508
2508
  <div class="event-detail-row">
@@ -2524,7 +2524,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2524
2524
  </div>
2525
2525
  <div class="event-detail-row" style="flex-direction: column; align-items: stretch; gap: 4px;">
2526
2526
  <span class="event-detail-label">Action</span>
2527
- <span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${Vy(e,!1)}</span>
2527
+ <span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${Gy(e,!1)}</span>
2528
2528
  </div>
2529
2529
  ${e.payload.kind==="agentTurn"&&e.payload.to?p`
2530
2530
  <div class="event-detail-row">
@@ -2549,12 +2549,12 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2549
2549
  <div class="event-detail-section">
2550
2550
  <div class="event-detail-row">
2551
2551
  <span class="event-detail-label">Last run</span>
2552
- <span class="event-detail-value">${tu(e)}</span>
2552
+ <span class="event-detail-value">${eu(e)}</span>
2553
2553
  </div>
2554
2554
  ${(n=e.state)!=null&&n.nextRunAtMs?p`
2555
2555
  <div class="event-detail-row">
2556
2556
  <span class="event-detail-label">Next run</span>
2557
- <span class="event-detail-value">${Hy(e.state.nextRunAtMs)}</span>
2557
+ <span class="event-detail-value">${qy(e.state.nextRunAtMs)}</span>
2558
2558
  </div>
2559
2559
  `:k}
2560
2560
  </div>
@@ -2565,7 +2565,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2565
2565
  </div>
2566
2566
  ${t.runs.length===0?p`<div class="muted" style="font-size: 13px;">No runs recorded yet.</div>`:p`
2567
2567
  <div class="list">
2568
- ${[...t.runs].sort((i,s)=>s.ts-i.ts).map(i=>av(i))}
2568
+ ${[...t.runs].sort((i,s)=>s.ts-i.ts).map(i=>lv(i))}
2569
2569
  </div>
2570
2570
  `}
2571
2571
  </div>
@@ -2595,14 +2595,14 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2595
2595
  </div>
2596
2596
  </div>
2597
2597
  </div>
2598
- `}function ov(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"?"chip chip-warn":"chip"}function av(e){return p`
2598
+ `}function av(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"?"chip chip-warn":"chip"}function lv(e){return p`
2599
2599
  <div class="list-item" style="grid-template-columns: 1fr; gap: 6px;">
2600
2600
  <div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
2601
- <span class=${ov(e.status)} style="font-size: 11px; padding: 2px 8px;">
2601
+ <span class=${av(e.status)} style="font-size: 11px; padding: 2px 8px;">
2602
2602
  ${e.status}
2603
2603
  </span>
2604
2604
  <span class="muted" style="font-size: 12px;">${wi(e.ts)}</span>
2605
- <span class="muted" style="font-size: 12px;">${dl(e.durationMs)}</span>
2605
+ <span class="muted" style="font-size: 12px;">${ul(e.durationMs)}</span>
2606
2606
  </div>
2607
2607
  ${e.summary?p`<div class="muted" style="font-size: 12px;">${e.summary}</div>`:k}
2608
2608
  ${e.error?p`
@@ -2612,7 +2612,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2612
2612
  </details>
2613
2613
  `:k}
2614
2614
  </div>
2615
- `}function lv(e){var s;const t=((s=e.report)==null?void 0:s.skills)??[],n=e.filter.trim().toLowerCase(),i=n?t.filter(r=>[r.name,r.description,r.source].join(" ").toLowerCase().includes(n)):t;return p`
2615
+ `}function cv(e){var s;const t=((s=e.report)==null?void 0:s.skills)??[],n=e.filter.trim().toLowerCase(),i=n?t.filter(r=>[r.name,r.description,r.source].join(" ").toLowerCase().includes(n)):t;return p`
2616
2616
  <section class="card">
2617
2617
  <div class="row" style="justify-content: space-between;">
2618
2618
  <div>
@@ -2640,17 +2640,17 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2640
2640
 
2641
2641
  ${i.length===0?p`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:p`
2642
2642
  <div class="list" style="margin-top: 16px;">
2643
- ${i.map(r=>cv(r,e))}
2643
+ ${i.map(r=>uv(r,e))}
2644
2644
  </div>
2645
2645
  `}
2646
2646
  </section>
2647
- `}function cv(e,t){const n=t.busyKey===e.skillKey,i=t.edits[e.skillKey]??"",s=t.messages[e.skillKey]??null,r=e.install.length>0&&e.missing.bins.length>0,o=[...e.missing.bins.map(c=>`bin:${c}`),...e.missing.env.map(c=>`env:${c}`),...e.missing.config.map(c=>`config:${c}`),...e.missing.os.map(c=>`os:${c}`)],a=[];return e.disabled&&a.push("disabled"),e.blockedByAllowlist&&a.push("blocked by allowlist"),p`
2647
+ `}function uv(e,t){const n=t.busyKey===e.skillKey,i=t.edits[e.skillKey]??"",s=t.messages[e.skillKey]??null,r=e.install.length>0&&e.missing.bins.length>0,o=[...e.missing.bins.map(c=>`bin:${c}`),...e.missing.env.map(c=>`env:${c}`),...e.missing.config.map(c=>`config:${c}`),...e.missing.os.map(c=>`os:${c}`)],a=[];return e.disabled&&a.push("disabled"),e.blockedByAllowlist&&a.push("blocked by allowlist"),p`
2648
2648
  <div class="list-item">
2649
2649
  <div class="list-main">
2650
2650
  <div class="list-title">
2651
2651
  ${e.emoji?`${e.emoji} `:""}${e.name}
2652
2652
  </div>
2653
- <div class="list-sub">${pd(e.description,140)}</div>
2653
+ <div class="list-sub">${hd(e.description,140)}</div>
2654
2654
  <div class="chip-row" style="margin-top: 6px;">
2655
2655
  <span class="chip">${e.source}</span>
2656
2656
  <span class="chip ${e.eligible?"chip-ok":"chip-warn"}">
@@ -2712,7 +2712,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2712
2712
  `:k}
2713
2713
  </div>
2714
2714
  </div>
2715
- `}const Oa=["user","assistant","tool","thinking","error"],Ba={user:"User",assistant:"Assistant",tool:"Tool",thinking:"Thinking",error:"Error",system:"System"};function uv(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 dv(e){return e.split(":").slice(2).join(":")||e}function pv(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function hv(e,t=500){return e.length<=t?e:e.slice(0,t)+"..."}function fv(e){const t=e.filterText.trim().toLowerCase();Oa.some(i=>!e.typeFilters[i]),e.agents.some(i=>!e.agentFilters[i]);const n=e.entries.filter(i=>!e.typeFilters[i.type]||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:pv(i,t));return p`
2715
+ `}const Oa=["user","assistant","tool","thinking","error"],Ba={user:"User",assistant:"Assistant",tool:"Tool",thinking:"Thinking",error:"Error",system:"System"};function dv(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 pv(e){return e.split(":").slice(2).join(":")||e}function hv(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function fv(e,t=500){return e.length<=t?e:e.slice(0,t)+"..."}function gv(e){const t=e.filterText.trim().toLowerCase();Oa.some(i=>!e.typeFilters[i]),e.agents.some(i=>!e.agentFilters[i]);const n=e.entries.filter(i=>!e.typeFilters[i.type]||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:hv(i,t));return p`
2716
2716
  <div>
2717
2717
  <div class="filters" style="margin-top: 14px;">
2718
2718
  <label class="field" style="min-width: 220px;">
@@ -2765,19 +2765,19 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2765
2765
  ${n.length===0?p`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map(i=>p`
2766
2766
  <div class="log-row session-entry ${i.type}">
2767
2767
  <div class="log-row-header">
2768
- <span class="log-time mono">${uv(i.timestamp)}</span>
2768
+ <span class="log-time mono">${dv(i.timestamp)}</span>
2769
2769
  <span class="session-log-type ${i.type}">${Ba[i.type]}</span>
2770
2770
  <span class="log-subsystem mono">${i.agentId}</span>
2771
- <span class="session-label mono">${dv(i.sessionKey)}</span>
2771
+ <span class="session-label mono">${pv(i.sessionKey)}</span>
2772
2772
  ${i.toolName?p`<span class="session-tool mono">${i.toolName}</span>`:k}
2773
2773
  ${i.model?p`<span class="session-model mono">${i.model}</span>`:k}
2774
2774
  </div>
2775
- <div class="log-message mono">${hv(i.content)}</div>
2775
+ <div class="log-message mono">${fv(i.content)}</div>
2776
2776
  </div>
2777
2777
  `)}
2778
2778
  </div>
2779
2779
  </div>
2780
- `}const qs=["trace","debug","info","warn","error","fatal"];function gv(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function su(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function mv(e){return p`
2780
+ `}const qs=["trace","debug","info","warn","error","fatal"];function mv(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function iu(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function yv(e){return p`
2781
2781
  <section class="card">
2782
2782
  <div class="row" style="justify-content: space-between;">
2783
2783
  <div>
@@ -2792,7 +2792,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2792
2792
  <button
2793
2793
  class="btn"
2794
2794
  ?disabled=${e.entries.length===0}
2795
- @click=${()=>{const t=e.filterText.trim().toLowerCase(),n=qs.some(r=>!e.levelFilters[r]),i=e.entries.filter(r=>r.level&&!e.levelFilters[r.level]?!1:su(r,t)),s=t||n?"filtered":"visible";e.onExport(i.map(r=>r.raw),s)}}
2795
+ @click=${()=>{const t=e.filterText.trim().toLowerCase(),n=qs.some(r=>!e.levelFilters[r]),i=e.entries.filter(r=>r.level&&!e.levelFilters[r.level]?!1:iu(r,t)),s=t||n?"filtered":"visible";e.onExport(i.map(r=>r.raw),s)}}
2796
2796
  >
2797
2797
  Export
2798
2798
  </button>
@@ -2822,9 +2822,9 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2822
2822
  </button>
2823
2823
  </div>
2824
2824
 
2825
- ${e.logsSubTab==="session"?fv(e.sessionLogsProps):yv(e)}
2825
+ ${e.logsSubTab==="session"?gv(e.sessionLogsProps):vv(e)}
2826
2826
  </section>
2827
- `}function yv(e){const t=e.filterText.trim().toLowerCase();qs.some(i=>!e.levelFilters[i]);const n=e.entries.filter(i=>i.level&&!e.levelFilters[i.level]?!1:su(i,t));return p`
2827
+ `}function vv(e){const t=e.filterText.trim().toLowerCase();qs.some(i=>!e.levelFilters[i]);const n=e.entries.filter(i=>i.level&&!e.levelFilters[i.level]?!1:iu(i,t));return p`
2828
2828
  <div class="filters" style="margin-top: 14px;">
2829
2829
  <label class="field" style="min-width: 220px;">
2830
2830
  <span>Filter</span>
@@ -2867,7 +2867,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2867
2867
  ${n.length===0?p`<div class="muted" style="padding: 12px;">No log entries.</div>`:[...n].reverse().map(i=>p`
2868
2868
  <div class="log-row">
2869
2869
  <div class="log-row-header">
2870
- <span class="log-time mono">${gv(i.time)}</span>
2870
+ <span class="log-time mono">${mv(i.time)}</span>
2871
2871
  <span class="log-level ${i.level??""}">${i.level??""}</span>
2872
2872
  <span class="log-subsystem mono">${i.subsystem??""}</span>
2873
2873
  </div>
@@ -2875,13 +2875,13 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2875
2875
  </div>
2876
2876
  `)}
2877
2877
  </div>
2878
- `}const vv=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function bv(e){switch(e.activeTab){case"cron":return Da(e.cronProps);case"skills":return lv(e.skillsProps);case"logs":return mv(e.logsProps);default:return Da(e.cronProps)}}function wv(e){return e.connected?p`
2878
+ `}const bv=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function wv(e){switch(e.activeTab){case"cron":return Da(e.cronProps);case"skills":return cv(e.skillsProps);case"logs":return yv(e.logsProps);default:return Da(e.cronProps)}}function kv(e){return e.connected?p`
2879
2879
  <div class="setup-container">
2880
2880
  ${pt("Advanced",e.wsProps)}
2881
2881
  <div class="setup-card sp-card-advanced" style="text-align: left;">
2882
2882
  <h1>Advanced</h1>
2883
2883
  <div class="sp-tabs">
2884
- ${vv.map(t=>p`
2884
+ ${bv.map(t=>p`
2885
2885
  <button
2886
2886
  class="sp-tab ${e.activeTab===t.id?"active":""}"
2887
2887
  @click=${()=>e.onTabChange(t.id)}
@@ -2890,7 +2890,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
2890
2890
  </button>
2891
2891
  `)}
2892
2892
  </div>
2893
- ${bv(e)}
2893
+ ${wv(e)}
2894
2894
  </div>
2895
2895
  </div>
2896
2896
  `:p`
@@ -3024,7 +3024,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3024
3024
  </p>`:k}
3025
3025
  </div>
3026
3026
  </div>
3027
- `}function kv(e){if(!e.connected)return p`
3027
+ `}function Sv(e){if(!e.connected)return p`
3028
3028
  <div class="setup-container">
3029
3029
  <div class="setup-card">
3030
3030
  <div class="setup-spinner"></div>
@@ -3037,10 +3037,10 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3037
3037
  <span class="public-chat-header__name">${n}</span>
3038
3038
  </div>
3039
3039
  <div class="chat-viewport">
3040
- ${eu(t)}
3040
+ ${Jc(t)}
3041
3041
  </div>
3042
3042
  </div>
3043
- `}async function Sv(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 bn(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 Av(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 r=await e.client.request("config.get",{});e.configSnapshot=r;const o=r.hash;if(!o){e.workspacesError="Config hash missing; reload and retry.";return}const a={name:n,baseHash:o,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(a.workspaceDir=t.workspacePath.trim());const c=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await bn(e),(s=t.onCreated)==null||s.call(t,c)}catch(r){e.workspacesError=String(r)}finally{e.workspaceSaving=!1}}async function xv(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 bn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function $v(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 bn(e)}catch(i){e.workspacesError=String(i)}}}const jn=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Av,loadWorkspaces:bn,removeWorkspace:xv,renameWorkspace:$v},Symbol.toStringTag,{value:"Module"})),ru={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"},Ua=ru,Vs={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(ru));new Set(Object.values(Vs));function Ev(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 Cv=4008;class Tv{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{var i,s;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(s=(i=this.opts).onClose)==null||s.call(i,{code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){var d;if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=this.opts.role??"operator",n=this.opts.scopes??["operator.admin","operator.approvals","operator.pairing"],s=!(t!=="operator")&&typeof crypto<"u"&&!!crypto.subtle;let r=null,o=!1,a=this.opts.token;if(s){r=await _p();const h=(d=Lp({deviceId:r.deviceId,role:t}))==null?void 0:d.token;a=h??this.opts.token,o=!!(h&&this.opts.token)}const c=a||this.opts.password?{token:a,password:this.opts.password}:void 0;let u;if(s&&r){const h=Date.now(),v=this.connectNonce??void 0,y=Ev({deviceId:r.deviceId,clientId:this.opts.clientName??Ua.CONTROL_UI,clientMode:this.opts.mode??Vs.WEBCHAT,role:t,scopes:n,signedAtMs:h,token:a??null,nonce:v}),b=await Mp(r.privateKey,y);u={id:r.deviceId,publicKey:r.publicKey,signature:b,signedAt:h,nonce:v}}const l={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Ua.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Vs.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:u,caps:[],auth:c,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",l).then(h=>{var v,y,b;(v=h==null?void 0:h.auth)!=null&&v.deviceToken&&r&&Ip({deviceId:r.deviceId,role:h.auth.role??t,token:h.auth.deviceToken,scopes:h.auth.scopes??[]}),this.backoffMs=800,(b=(y=this.opts).onHello)==null||b.call(y,h)}).catch(()=>{var h;o&&r&&Rp({deviceId:r.deviceId,role:t}),(h=this.ws)==null||h.close(Cv,"connect failed")})}handleMessage(t){var s,r,o,a,c;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const u=n;if(u.event==="connect.challenge"){const d=u.payload,h=d&&typeof d.nonce=="string"?d.nonce:null;h&&(this.connectNonce=h,this.sendConnect());return}const l=typeof u.seq=="number"?u.seq:null;l!==null&&(this.lastSeq!==null&&l>this.lastSeq+1&&((r=(s=this.opts).onGap)==null||r.call(s,{expected:this.lastSeq+1,received:l})),this.lastSeq=l);try{(a=(o=this.opts).onEvent)==null||a.call(o,u)}catch(d){console.error("[gateway] event handler error:",d)}return}if(i.type==="res"){const u=n,l=this.pending.get(u.id);if(!l)return;this.pending.delete(u.id),u.ok?l.resolve(u.payload):l.reject(new Error(((c=u.error)==null?void 0:c.message)??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=tr(),s={type:"req",id:i,method:t,params:n},r=new Promise((o,a)=>{this.pending.set(i,{resolve:c=>o(c),reject:a})});return this.ws.send(JSON.stringify(s)),r}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Gs(e){return typeof e=="object"&&e!==null}function _v(e){if(!Gs(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Gs(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,r=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!s||!r?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:r}}function Mv(e){if(!Gs(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 ou(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Pv(e,t){const n=ou(e).filter(i=>i.id!==t.id);return n.push(t),n}function Wa(e,t){return ou(e).filter(n=>n.id!==t)}class Lv{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,r=this.canvas.height/i.height,o=this.deviceWidth/this.canvas.width,a=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*o),y:Math.round(n*r*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 ys=null;function ln(){return ys||(ys=new Lv),ys}function Wr(e){return e instanceof Error?e.message:String(e)}async function Iv(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=Wr(t)}finally{e.browserLoading=!1}}async function Rv(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=Wr(t)}finally{e.browserLoading=!1}}}async function vs(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 bs(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 Nv(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=Wr(t)}}function Dv(e){e.browserInputMode=!e.browserInputMode}function Ov(e){e.browserFullscreen=!e.browserFullscreen,ln().detach()}function Bv(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,ln().updateFrame(t.data,t.metadata)}function Fv(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function Uv(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function Qs(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 r=xs(s);e.assistantName=r.name,e.assistantAvatar=r.avatar,e.assistantAgentId=r.agentId??null}catch{}}async function Ys(e){return(await e.request("apikeys.list")).providers??[]}async function Ka(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function Wv(e,t){await e.request("apikeys.remove",{provider:t})}const gi="taskmaster_update_pending";async function au(e){var t,n;if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("update.status",{});e.currentVersion=i.current,e.latestVersion=i.latest,e.updateAvailable=i.updateAvailable,e.updateMessage=i.updateAvailable?`v${i.latest} available`:"Up to date"}catch(i){e.updateMessage=`Check failed: ${String(i)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function Kv(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(gi,String(Date.now())),localStorage.removeItem(Kr)}catch{}try{const r=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(r.ok&&r.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(r.ok&&r.result.status==="skipped")cn(),e.updateMessage=r.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw cn(),new Error(r.result.reason||"Update failed")}catch(r){cn(),e.updateMessage=`Update failed: ${String(r)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function zv(e,t){var i,s,r;const n=t.phase;if(n==="step-start"){const o=t.name,a=t.index,c=t.total;e.updateMessage=`Updating: ${o} (${a+1}/${c})`;const u=e.updateProgressSteps.find(l=>l.index===a);u?(u.status="running",u.name=o):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:c,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const o=t.name,a=t.index,c=t.total,u=t.ok,l=t.durationMs,d=e.updateProgressSteps.find(v=>v.index===a);d?(d.status=u?"done":"failed",d.durationMs=l):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:c,status:u?"done":"failed",durationMs:l}];const h=!u&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=u?`Updating: ${o} done (${a+1}/${c})`:`Update step failed: ${o}${h}`,(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,cn()}(r=e.requestUpdate)==null||r.call(e)}}async function jv(e){var n,i,s,r;if(!e.client||!e.connected)return;const t=qv();cn();try{const o=await e.client.request("update.lastResult",{});if(!o.ok||!o.result)return;const a=5*6e4,c=Date.now()-o.result.ts<a;if(!t&&!c||Vv(o.result.ts))return;e.updateLastResult=o.result;const u=(n=o.result.after)==null?void 0:n.version;if(o.result.status==="ok"&&u&&(e.currentVersion=u),e.updateAvailable=!1,o.result.status==="ok"){const l=(i=o.result.before)==null?void 0:i.version,d=u??o.result.currentVersion;e.updateMessage=l?`Updated: v${l} → v${d}`:`Updated to v${d}`}else{const l=o.result.reason??((s=o.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${l}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(r=e.requestUpdate)==null||r.call(e)}}const Kr="taskmaster_update_dismissed";function Hv(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Kr,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function qv(){try{const e=localStorage.getItem(gi);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(gi),!1):!0:!1}catch{return!1}}function cn(){try{localStorage.removeItem(gi)}catch{}}function Vv(e){try{const t=localStorage.getItem(Kr);return t?Number(t)>=e:!1}catch{return!1}}function ws(e,t){var a,c,u;const n=(e??"").trim(),i=(a=t.mainSessionKey)==null?void 0:a.trim();if(!i)return n;if(!n)return i;const s=((c=t.mainKey)==null?void 0:c.trim())||"main",r=(u=t.defaultAgentId)==null?void 0:u.trim();return n==="main"||n===s||r&&(n===`agent:${r}:main`||n===`agent:${r}:${s}`)?i:n}function Gv(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=ws(e.sessionKey,t),i=ws(e.settings.sessionKey,t),s=ws(e.settings.lastActiveSessionKey,t),r=n||i||e.sessionKey,o={...e.settings,sessionKey:i||r,lastActiveSessionKey:s||r},a=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;r!==e.sessionKey&&(e.sessionKey=r),a&&ze(e,o)}function Ee(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.customersPage||e.advancedPage,i=t?"public-chat":n?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new Tv({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:r=>{var o;if(e.connected=!0,e.lastError=null,e.hello=r,t){za(e,r),Qs(e),(((o=e.publicChatConfig)==null?void 0:o.auth)??"anonymous")==="anonymous"&&Jv(e);return}oi()&&(Ar(),e.uninstallDone=!1),za(e,r),e.handleAccessCheck(),jv(e).then(()=>{au(e)}),Qs(e),Sv(e),(e.chatPage||e.setup)&&Xv(e),pr(e,{quiet:!0}),dr(e,{quiet:!0}),bn(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&_e(e),e.setup&&Zv(e),si(e)},onClose:({code:r,reason:o})=>{e.connected=!1,r!==1012&&(e.lastError=`disconnected (${r}): ${o||"no reason"}`)},onEvent:r=>Qv(e,r),onGap:({expected:r,received:o})=>{console.warn(`[gateway] event gap: expected seq ${r}, got ${o}`),si(e)}}),e.client.start()}function Qv(e,t){try{Yv(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Yv(e,t){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;Dd(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n!=null&&n.sessionKey&&ic(e,n.sessionKey);const i=bl(e,n);(i==="final"||i==="error"||i==="aborted")&&(ir(e),Ah(e)),i==="final"&&Te(e);return}if(t.event==="suggestions"){const n=t.payload;(n==null?void 0:n.sessionKey)===e.sessionKey&&Array.isArray(n.suggestions)&&n.suggestions.length>0&&(e.chatSuggestion=n.suggestions[0]);return}if(t.event==="presence"){const n=t.payload;n!=null&&n.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&kr(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&dr(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=_v(t.payload);if(n){e.execApprovalQueue=Pv(e.execApprovalQueue,n),e.execApprovalError=null;const i=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Wa(e.execApprovalQueue,n.id)},i)}return}if(t.event==="browser.screencast.frame"){Bv(e,t.payload);return}if(t.event==="browser.handoff"){Fv(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){Uv(e);return}if(t.event==="exec.approval.resolved"){const n=Mv(t.payload);n&&(e.execApprovalQueue=Wa(e.execApprovalQueue,n.id));return}if(t.event==="update.progress"){zv(e,t.payload);return}}function za(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&&Gv(e,n.sessionDefaults)}async function Xv(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 Zv(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await Ys(e.client)}catch{}}const ja="taskmaster_public_id";function lu(e=30){var s;const t=document.cookie.split(";").map(r=>r.trim()).find(r=>r.startsWith(`${ja}=`));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=`${ja}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function Jv(e){var n,i;if(!e.client||!e.connected)return;const t=lu((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const s=(i=e.publicChatConfig)==null?void 0:i.accountId,r=await e.client.request("public.session",{cookieId:t,accountId:s});r!=null&&r.sessionKey&&(e.publicChatSessionKey=r.sessionKey,e.sessionKey=r.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready",Te(e))}catch(s){console.error("[public-chat] failed to resolve anonymous session:",s),e.lastError="Failed to start chat session"}}let we=!1,ce=null,Lt="",mi="";function cu(){we=!1,ce=null,Lt="",mi=""}async function eb(e){if(!e.client||!e.connected)return;const t=lu(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){ce=n instanceof Error?n.message:"Failed to start session"}}async function Ha(e){if(!e.client||we)return;const t=Lt.trim();if(!t){ce="Please enter your phone number";return}we=!0,ce=null;try{const n=await e.client.request("public.otp.request",{phone:t,name:mi.trim()||void 0});n!=null&&n.ok?e.onAuthStepChange("otp"):ce=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ce=n instanceof Error?n.message:"Failed to send verification code"}finally{we=!1}}async function qa(e,t){if(!(!e.client||we)){if(!t.trim()){ce="Please enter the verification code";return}we=!0,ce=null;try{const n=await e.client.request("public.otp.verify",{phone:Lt.trim(),code:t.trim(),accountId:e.accountId});n!=null&&n.ok&&n.sessionKey?(cu(),e.onAuthenticated(n.sessionKey)):ce=(n==null?void 0:n.error)??"Invalid verification code"}catch(n){ce=n instanceof Error?n.message:"Verification failed"}finally{we=!1}}}function ks(e){return k}function Va(e){return p`
3043
+ `}async function Av(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 bn(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 xv(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 r=await e.client.request("config.get",{});e.configSnapshot=r;const o=r.hash;if(!o){e.workspacesError="Config hash missing; reload and retry.";return}const a={name:n,baseHash:o,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(a.workspaceDir=t.workspacePath.trim());const c=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await bn(e),(s=t.onCreated)==null||s.call(t,c)}catch(r){e.workspacesError=String(r)}finally{e.workspaceSaving=!1}}async function $v(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 bn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Ev(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 bn(e)}catch(i){e.workspacesError=String(i)}}}const jn=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:xv,loadWorkspaces:bn,removeWorkspace:$v,renameWorkspace:Ev},Symbol.toStringTag,{value:"Module"})),su={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"taskmaster-control-ui",SETUP_UI:"setup-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"taskmaster-macos",IOS_APP:"taskmaster-ios",ANDROID_APP:"taskmaster-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"taskmaster-probe",PUBLIC_CHAT:"public-chat"},Ua=su,Vs={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(su));new Set(Object.values(Vs));function Cv(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 Tv=4008;class _v{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{var i,s;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(s=(i=this.opts).onClose)==null||s.call(i,{code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){var d;if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=this.opts.role??"operator",n=this.opts.scopes??["operator.admin","operator.approvals","operator.pairing"],s=!(t!=="operator")&&typeof crypto<"u"&&!!crypto.subtle;let r=null,o=!1,a=this.opts.token;if(s){r=await Mp();const h=(d=Ip({deviceId:r.deviceId,role:t}))==null?void 0:d.token;a=h??this.opts.token,o=!!(h&&this.opts.token)}const c=a||this.opts.password?{token:a,password:this.opts.password}:void 0;let u;if(s&&r){const h=Date.now(),v=this.connectNonce??void 0,y=Cv({deviceId:r.deviceId,clientId:this.opts.clientName??Ua.CONTROL_UI,clientMode:this.opts.mode??Vs.WEBCHAT,role:t,scopes:n,signedAtMs:h,token:a??null,nonce:v}),b=await Pp(r.privateKey,y);u={id:r.deviceId,publicKey:r.publicKey,signature:b,signedAt:h,nonce:v}}const l={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Ua.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Vs.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:u,caps:[],auth:c,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",l).then(h=>{var v,y,b;(v=h==null?void 0:h.auth)!=null&&v.deviceToken&&r&&Rp({deviceId:r.deviceId,role:h.auth.role??t,token:h.auth.deviceToken,scopes:h.auth.scopes??[]}),this.backoffMs=800,(b=(y=this.opts).onHello)==null||b.call(y,h)}).catch(()=>{var h;o&&r&&Np({deviceId:r.deviceId,role:t}),(h=this.ws)==null||h.close(Tv,"connect failed")})}handleMessage(t){var s,r,o,a,c;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const u=n;if(u.event==="connect.challenge"){const d=u.payload,h=d&&typeof d.nonce=="string"?d.nonce:null;h&&(this.connectNonce=h,this.sendConnect());return}const l=typeof u.seq=="number"?u.seq:null;l!==null&&(this.lastSeq!==null&&l>this.lastSeq+1&&((r=(s=this.opts).onGap)==null||r.call(s,{expected:this.lastSeq+1,received:l})),this.lastSeq=l);try{(a=(o=this.opts).onEvent)==null||a.call(o,u)}catch(d){console.error("[gateway] event handler error:",d)}return}if(i.type==="res"){const u=n,l=this.pending.get(u.id);if(!l)return;this.pending.delete(u.id),u.ok?l.resolve(u.payload):l.reject(new Error(((c=u.error)==null?void 0:c.message)??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=tr(),s={type:"req",id:i,method:t,params:n},r=new Promise((o,a)=>{this.pending.set(i,{resolve:c=>o(c),reject:a})});return this.ws.send(JSON.stringify(s)),r}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Gs(e){return typeof e=="object"&&e!==null}function Mv(e){if(!Gs(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Gs(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,r=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!s||!r?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:r}}function Pv(e){if(!Gs(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 ru(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Lv(e,t){const n=ru(e).filter(i=>i.id!==t.id);return n.push(t),n}function Wa(e,t){return ru(e).filter(n=>n.id!==t)}class Iv{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,r=this.canvas.height/i.height,o=this.deviceWidth/this.canvas.width,a=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*o),y:Math.round(n*r*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 ys=null;function ln(){return ys||(ys=new Iv),ys}function Wr(e){return e instanceof Error?e.message:String(e)}async function Rv(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=Wr(t)}finally{e.browserLoading=!1}}async function Nv(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=Wr(t)}finally{e.browserLoading=!1}}}async function vs(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 bs(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 Dv(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=Wr(t)}}function Ov(e){e.browserInputMode=!e.browserInputMode}function Bv(e){e.browserFullscreen=!e.browserFullscreen,ln().detach()}function Fv(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,ln().updateFrame(t.data,t.metadata)}function Uv(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function Wv(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function Qs(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 r=xs(s);e.assistantName=r.name,e.assistantAvatar=r.avatar,e.assistantAgentId=r.agentId??null}catch{}}async function Ys(e){return(await e.request("apikeys.list")).providers??[]}async function Ka(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function Kv(e,t){await e.request("apikeys.remove",{provider:t})}const gi="taskmaster_update_pending";async function ou(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 zv(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(gi,String(Date.now())),localStorage.removeItem(Kr)}catch{}try{const r=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(r.ok&&r.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(r.ok&&r.result.status==="skipped")cn(),e.updateMessage=r.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw cn(),new Error(r.result.reason||"Update failed")}catch(r){cn(),e.updateMessage=`Update failed: ${String(r)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function jv(e,t){var i,s,r;const n=t.phase;if(n==="step-start"){const o=t.name,a=t.index,c=t.total;e.updateMessage=`Updating: ${o} (${a+1}/${c})`;const u=e.updateProgressSteps.find(l=>l.index===a);u?(u.status="running",u.name=o):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:c,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const o=t.name,a=t.index,c=t.total,u=t.ok,l=t.durationMs,d=e.updateProgressSteps.find(v=>v.index===a);d?(d.status=u?"done":"failed",d.durationMs=l):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:c,status:u?"done":"failed",durationMs:l}];const h=!u&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=u?`Updating: ${o} done (${a+1}/${c})`:`Update step failed: ${o}${h}`,(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,cn()}(r=e.requestUpdate)==null||r.call(e)}}async function Hv(e){var n,i,s,r;if(!e.client||!e.connected)return;const t=Vv();cn();try{const o=await e.client.request("update.lastResult",{});if(!o.ok||!o.result)return;const a=5*6e4,c=Date.now()-o.result.ts<a;if(!t&&!c||Gv(o.result.ts))return;e.updateLastResult=o.result;const u=(n=o.result.after)==null?void 0:n.version;if(o.result.status==="ok"&&u&&(e.currentVersion=u),e.updateAvailable=!1,o.result.status==="ok"){const l=(i=o.result.before)==null?void 0:i.version,d=u??o.result.currentVersion;e.updateMessage=l?`Updated: v${l} → v${d}`:`Updated to v${d}`}else{const l=o.result.reason??((s=o.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${l}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(r=e.requestUpdate)==null||r.call(e)}}const Kr="taskmaster_update_dismissed";function qv(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Kr,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function Vv(){try{const e=localStorage.getItem(gi);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(gi),!1):!0:!1}catch{return!1}}function cn(){try{localStorage.removeItem(gi)}catch{}}function Gv(e){try{const t=localStorage.getItem(Kr);return t?Number(t)>=e:!1}catch{return!1}}function ws(e,t){var a,c,u;const n=(e??"").trim(),i=(a=t.mainSessionKey)==null?void 0:a.trim();if(!i)return n;if(!n)return i;const s=((c=t.mainKey)==null?void 0:c.trim())||"main",r=(u=t.defaultAgentId)==null?void 0:u.trim();return n==="main"||n===s||r&&(n===`agent:${r}:main`||n===`agent:${r}:${s}`)?i:n}function Qv(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=ws(e.sessionKey,t),i=ws(e.settings.sessionKey,t),s=ws(e.settings.lastActiveSessionKey,t),r=n||i||e.sessionKey,o={...e.settings,sessionKey:i||r,lastActiveSessionKey:s||r},a=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;r!==e.sessionKey&&(e.sessionKey=r),a&&ze(e,o)}function Ee(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.customersPage||e.advancedPage,i=t?"public-chat":n?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new _v({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:r=>{var o;if(e.connected=!0,e.lastError=null,e.hello=r,t){za(e,r),Qs(e),(((o=e.publicChatConfig)==null?void 0:o.auth)??"anonymous")==="anonymous"&&eb(e);return}oi()&&(Ar(),e.uninstallDone=!1),za(e,r),e.handleAccessCheck(),Hv(e).then(()=>{ou(e)}),Qs(e),Av(e),(e.chatPage||e.setup)&&Zv(e),pr(e,{quiet:!0}),dr(e,{quiet:!0}),bn(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&_e(e),e.setup&&Jv(e),si(e)},onClose:({code:r,reason:o})=>{e.connected=!1,r!==1012&&(e.lastError=`disconnected (${r}): ${o||"no reason"}`)},onEvent:r=>Yv(e,r),onGap:({expected:r,received:o})=>{console.warn(`[gateway] event gap: expected seq ${r}, got ${o}`),si(e)}}),e.client.start()}function Yv(e,t){try{Xv(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Xv(e,t){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;Od(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n!=null&&n.sessionKey&&nc(e,n.sessionKey);const i=vl(e,n);(i==="final"||i==="error"||i==="aborted")&&(ir(e),xh(e)),i==="final"&&Te(e);return}if(t.event==="suggestions"){const n=t.payload;(n==null?void 0:n.sessionKey)===e.sessionKey&&Array.isArray(n.suggestions)&&n.suggestions.length>0&&(e.chatSuggestion=n.suggestions[0]);return}if(t.event==="presence"){const n=t.payload;n!=null&&n.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&kr(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&dr(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=Mv(t.payload);if(n){e.execApprovalQueue=Lv(e.execApprovalQueue,n),e.execApprovalError=null;const i=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Wa(e.execApprovalQueue,n.id)},i)}return}if(t.event==="browser.screencast.frame"){Fv(e,t.payload);return}if(t.event==="browser.handoff"){Uv(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){Wv(e);return}if(t.event==="exec.approval.resolved"){const n=Pv(t.payload);n&&(e.execApprovalQueue=Wa(e.execApprovalQueue,n.id));return}if(t.event==="update.progress"){jv(e,t.payload);return}}function za(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&&Qv(e,n.sessionDefaults)}async function Zv(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 Jv(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await Ys(e.client)}catch{}}const ja="taskmaster_public_id";function au(e=30){var s;const t=document.cookie.split(";").map(r=>r.trim()).find(r=>r.startsWith(`${ja}=`));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=`${ja}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function eb(e){var n,i;if(!e.client||!e.connected)return;const t=au((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const s=(i=e.publicChatConfig)==null?void 0:i.accountId,r=await e.client.request("public.session",{cookieId:t,accountId:s});r!=null&&r.sessionKey&&(e.publicChatSessionKey=r.sessionKey,e.sessionKey=r.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready",Te(e))}catch(s){console.error("[public-chat] failed to resolve anonymous session:",s),e.lastError="Failed to start chat session"}}let we=!1,ce=null,Lt="",mi="";function lu(e){return e.replace(/[\s\-()]/g,"")}function cu(){we=!1,ce=null,Lt="",mi=""}async function tb(e){if(!e.client||!e.connected)return;const t=au(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){ce=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function Ha(e){if(!e.client||we)return;const t=lu(Lt);if(!t){ce="Please enter your phone number",e.requestUpdate();return}we=!0,ce=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:mi.trim()||void 0});n!=null&&n.ok?e.onAuthStepChange("otp"):ce=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ce=n instanceof Error?n.message:"Failed to send verification code"}finally{we=!1,e.requestUpdate()}}async function qa(e,t){if(!(!e.client||we)){if(!t.trim()){ce="Please enter the verification code",e.requestUpdate();return}we=!0,ce=null,e.requestUpdate();try{const n=await e.client.request("public.otp.verify",{phone:lu(Lt),code:t.trim(),accountId:e.accountId});n!=null&&n.ok&&n.sessionKey?(cu(),e.onAuthenticated(n.sessionKey)):ce=(n==null?void 0:n.error)??"Invalid verification code"}catch(n){ce=n instanceof Error?n.message:"Verification failed"}finally{we=!1,e.requestUpdate()}}}function ks(e){return k}function Va(e){return p`
3044
3044
  <div class="public-auth__form">
3045
3045
  <label class="field public-auth__field">
3046
3046
  <span>Your name (optional)</span>
@@ -3058,7 +3058,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3058
3058
  .value=${Lt}
3059
3059
  @input=${t=>{Lt=t.target.value}}
3060
3060
  @keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),Ha(e))}}
3061
- placeholder="+1234567890"
3061
+ placeholder="+44 7123 456789"
3062
3062
  required
3063
3063
  />
3064
3064
  </label>
@@ -3103,7 +3103,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3103
3103
  Use a different number
3104
3104
  </button>
3105
3105
  </div>
3106
- `}function tb(e){const{authMode:t,authStep:n}=e;return t==="anonymous"?p`
3106
+ `}function nb(e){const{authMode:t,authStep:n}=e;return t==="anonymous"?p`
3107
3107
  <div class="setup-container">
3108
3108
  <div class="setup-card">
3109
3109
  <div class="setup-spinner"></div>
@@ -3137,7 +3137,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3137
3137
  <div class="public-auth__choices">
3138
3138
  <button
3139
3139
  class="btn primary public-auth__btn"
3140
- @click=${()=>{eb(e)}}
3140
+ @click=${()=>{tb(e)}}
3141
3141
  >
3142
3142
  Chat now
3143
3143
  </button>
@@ -3153,7 +3153,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3153
3153
  </p>
3154
3154
  </div>
3155
3155
  </div>
3156
- `}const zr="taskmaster-access-session",uu={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function du(){try{return localStorage.getItem(zr)}catch{return null}}function pu(e){try{localStorage.setItem(zr,e)}catch{}}function nb(){try{localStorage.removeItem(zr)}catch{}}async function Qa(e){if(e.client)try{const t=du(),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 ib(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?(pu(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 sb(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?(pu(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 rb(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 ob(e){const t=du();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}nb(),e.accessState={...uu,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function ab(e,t="admin"){var s;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const i=[];for(const r of n){if(!r||typeof r!="object"||r.agentId!==t&&r.agentId!=="management")continue;const o=r.match;if(!o||typeof o!="object"||(o.channel??"").toLowerCase()!=="whatsapp")continue;const c=o.peer;if(!c||typeof c!="object"||c.kind!=="dm")continue;const u=c.id??"";u&&i.push({phone:u,paired:((s=r.meta)==null?void 0:s.paired)===!0})}return i.sort((r,o)=>r.paired&&!o.paired?-1:!r.paired&&o.paired?1:0),i}function hu(e,t,n="admin",i){const s=u=>u===n||u==="management",r=new Map,o=new Map;for(const u of e){if(!u||typeof u!="object"||!s(u.agentId))continue;const l=u.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")continue;const h=l.peer;if(!h||typeof h!="object"||h.kind!=="dm")continue;const v=h.id??"";v&&(u.meta&&r.set(v,u.meta),l.accountId&&o.set(v,l.accountId))}const a=e.filter(u=>{if(!u||typeof u!="object"||!s(u.agentId))return!0;const l=u.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")return!0;const h=l.peer;return!h||typeof h!="object"?!0:h.kind!=="dm"}),c=t.map(u=>{const l=i??o.get(u.phone),d={channel:"whatsapp",peer:{kind:"dm",id:u.phone}};l&&(d.accountId=l);const h={agentId:n,match:d},v=r.get(u.phone);return v?h.meta=v:u.paired&&(h.meta={paired:!0}),h});return[...a,...c]}async function _i(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=He(s??{}),e.adminPhones=ab(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function fu(e,t,n,i){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n;let r=t.replace(/[\s\-\(\)]/g,"");if(!r){e.adminsError="Phone number is required";return}if(r.startsWith("+")||(r="+"+r),!/^\+[1-9]\d{6,14}$/.test(r)){e.adminsError="Invalid phone number. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(c=>c.phone===r)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const c=He(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),u=c.bindings??[],l=[...e.adminPhones,{phone:r}],d=hu(u,l,s,i);kl(c,["bindings"],d);const h=(a=e.configSnapshot)==null?void 0:a.hash;if(!h){e.adminsError="Config hash missing; reload and retry.";return}const v=st(c);await e.client.request("config.set",{raw:v,baseHash:h}),await _i(e,n)}catch(c){e.adminsError=String(c)}finally{e.adminsSaving=!1}}async function gu(e,t,n,i){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n,r=e.adminPhones.find(c=>c.phone===t);if(r!=null&&r.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const c=He(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),u=c.bindings??[],l=e.adminPhones.filter(y=>y.phone!==t),d=hu(u,l,s,i);kl(c,["bindings"],d);const h=(a=e.configSnapshot)==null?void 0:a.hash;if(!h){e.adminsError="Config hash missing; reload and retry.";return}const v=st(c);await e.client.request("config.set",{raw:v,baseHash:h}),await _i(e,n)}catch(c){e.adminsError=String(c)}finally{e.adminsSaving=!1}}const lb=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:fu,loadAdmins:_i,removeAdmin:gu},Symbol.toStringTag,{value:"Module"}));async function dt(e,t){if(!(!e.client||!e.connected)){if(!t){e.customersRecords=[];return}if(!e.customersLoading){e.customersLoading=!0,e.customersError=null;try{const n=e.customersSearchQuery.trim(),i=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.customersRecords=i.records??[]}catch(n){e.customersError=String(n)}finally{e.customersLoading=!1}}}}async function mu(e,t,n,i){if(!e.client||!e.connected||e.customersSaving)return;let s=t.replace(/[\s\-\(\)]/g,"");const r=n.trim();if(!s){e.customersError="Phone number is required";return}if(!r){e.customersError="Name is required";return}if(s.startsWith("+")||(s="+"+s),!/^\+[1-9]\d{6,14}$/.test(s)){e.customersError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.set",{id:s,name:r,fields:{},workspace:i}),e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName="",await dt(e,i)}catch(o){e.customersError=String(o)}finally{e.customersSaving=!1}}async function yu(e,t,n){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.delete",{id:t}),e.customersEditingId===t&&(e.customersEditingId=null),await dt(e,n)}catch(i){e.customersError=String(i)}finally{e.customersSaving=!1}}}async function vu(e,t,n,i,s){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.setField",{id:t,key:n,value:i}),await dt(e,s)}catch(r){e.customersError=String(r)}finally{e.customersSaving=!1}}}async function bu(e,t,n,i){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await dt(e,i)}catch(s){e.customersError=String(s)}finally{e.customersSaving=!1}}}const cb=Object.freeze(Object.defineProperty({__proto__:null,addCustomer:mu,deleteCustomer:yu,deleteCustomerField:bu,loadCustomers:dt,setCustomerField:vu},Symbol.toStringTag,{value:"Module"}));function Yt(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 ub(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 db(e){const t=se(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 pb(e){const t=se(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function hb(e){var n;const t=se(e);if(t)return(n=t.agents[0])==null?void 0:n.id}function fb(e){return e.selectedWorkspace??void 0}function se(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const gb=/^data:/i,mb=/^https?:\/\//i;function Ya(e){var a,c;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=cl(e.sessionKey),i=(n==null?void 0:n.agentId)??((c=e.agentsList)==null?void 0:c.defaultId)??"main",s=t.find(u=>u.id===i),r=s==null?void 0:s.identity,o=(r==null?void 0:r.avatarUrl)??(r==null?void 0:r.avatar);if(o)return gb.test(o)||mb.test(o)?o:r==null?void 0:r.avatarUrl}function yb(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 vb(e){var o;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(o=e.channelAccounts)==null?void 0:o.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,r=s!=null?s.ok===!0:i;return{configured:n.configured??!1,running:i,connected:r,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function bb(e){var o;const t=(o=e.configSnapshot)==null?void 0:o.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(a=>{var c,u;return((c=a.match)==null?void 0:c.channel)==="imessage"&&((u=a.meta)==null?void 0:u.imessageOwner)});if(!i)return null;const s=i.agentId;for(const a of e.workspaces)if(a.agents.some(c=>c.id===s))return a.name;if(s==="admin"||s==="public"){const a=e.workspaces.find(c=>c.isDefault);return(a==null?void 0:a.name)??null}const r=s.replace(/-(admin|public)$/,"");if(r!==s){const a=e.workspaces.find(c=>c.name===r);return(a==null?void 0:a.name)??null}return null}function wb(e){var t,n,i,s,r,o,a,c,u;if(e.embeddingDownloading&&!e.publicChat)return p`
3156
+ `}const zr="taskmaster-access-session",uu={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function du(){try{return localStorage.getItem(zr)}catch{return null}}function pu(e){try{localStorage.setItem(zr,e)}catch{}}function ib(){try{localStorage.removeItem(zr)}catch{}}async function Qa(e){if(e.client)try{const t=du(),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 sb(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?(pu(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 rb(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?(pu(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 ob(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 ab(e){const t=du();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}ib(),e.accessState={...uu,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function lb(e,t="admin"){var s;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const i=[];for(const r of n){if(!r||typeof r!="object"||r.agentId!==t&&r.agentId!=="management")continue;const o=r.match;if(!o||typeof o!="object"||(o.channel??"").toLowerCase()!=="whatsapp")continue;const c=o.peer;if(!c||typeof c!="object"||c.kind!=="dm")continue;const u=c.id??"";u&&i.push({phone:u,paired:((s=r.meta)==null?void 0:s.paired)===!0})}return i.sort((r,o)=>r.paired&&!o.paired?-1:!r.paired&&o.paired?1:0),i}function hu(e,t,n="admin",i){const s=u=>u===n||u==="management",r=new Map,o=new Map;for(const u of e){if(!u||typeof u!="object"||!s(u.agentId))continue;const l=u.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")continue;const h=l.peer;if(!h||typeof h!="object"||h.kind!=="dm")continue;const v=h.id??"";v&&(u.meta&&r.set(v,u.meta),l.accountId&&o.set(v,l.accountId))}const a=e.filter(u=>{if(!u||typeof u!="object"||!s(u.agentId))return!0;const l=u.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")return!0;const h=l.peer;return!h||typeof h!="object"?!0:h.kind!=="dm"}),c=t.map(u=>{const l=i??o.get(u.phone),d={channel:"whatsapp",peer:{kind:"dm",id:u.phone}};l&&(d.accountId=l);const h={agentId:n,match:d},v=r.get(u.phone);return v?h.meta=v:u.paired&&(h.meta={paired:!0}),h});return[...a,...c]}async function _i(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=He(s??{}),e.adminPhones=lb(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function fu(e,t,n,i){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n;let r=t.replace(/[\s\-\(\)]/g,"");if(!r){e.adminsError="Phone number is required";return}if(r.startsWith("+")||(r="+"+r),!/^\+[1-9]\d{6,14}$/.test(r)){e.adminsError="Invalid phone number. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(c=>c.phone===r)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const c=He(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),u=c.bindings??[],l=[...e.adminPhones,{phone:r}],d=hu(u,l,s,i);wl(c,["bindings"],d);const h=(a=e.configSnapshot)==null?void 0:a.hash;if(!h){e.adminsError="Config hash missing; reload and retry.";return}const v=st(c);await e.client.request("config.set",{raw:v,baseHash:h}),await _i(e,n)}catch(c){e.adminsError=String(c)}finally{e.adminsSaving=!1}}async function gu(e,t,n,i){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n,r=e.adminPhones.find(c=>c.phone===t);if(r!=null&&r.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const c=He(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),u=c.bindings??[],l=e.adminPhones.filter(y=>y.phone!==t),d=hu(u,l,s,i);wl(c,["bindings"],d);const h=(a=e.configSnapshot)==null?void 0:a.hash;if(!h){e.adminsError="Config hash missing; reload and retry.";return}const v=st(c);await e.client.request("config.set",{raw:v,baseHash:h}),await _i(e,n)}catch(c){e.adminsError=String(c)}finally{e.adminsSaving=!1}}const cb=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:fu,loadAdmins:_i,removeAdmin:gu},Symbol.toStringTag,{value:"Module"}));async function dt(e,t){if(!(!e.client||!e.connected)){if(!t){e.customersRecords=[];return}if(!e.customersLoading){e.customersLoading=!0,e.customersError=null;try{const n=e.customersSearchQuery.trim(),i=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.customersRecords=i.records??[]}catch(n){e.customersError=String(n)}finally{e.customersLoading=!1}}}}async function mu(e,t,n,i){if(!e.client||!e.connected||e.customersSaving)return;let s=t.replace(/[\s\-\(\)]/g,"");const r=n.trim();if(!s){e.customersError="Phone number is required";return}if(!r){e.customersError="Name is required";return}if(s.startsWith("+")||(s="+"+s),!/^\+[1-9]\d{6,14}$/.test(s)){e.customersError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.set",{id:s,name:r,fields:{},workspace:i}),e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName="",await dt(e,i)}catch(o){e.customersError=String(o)}finally{e.customersSaving=!1}}async function yu(e,t,n){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.delete",{id:t}),e.customersEditingId===t&&(e.customersEditingId=null),await dt(e,n)}catch(i){e.customersError=String(i)}finally{e.customersSaving=!1}}}async function vu(e,t,n,i,s){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.setField",{id:t,key:n,value:i}),await dt(e,s)}catch(r){e.customersError=String(r)}finally{e.customersSaving=!1}}}async function bu(e,t,n,i){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await dt(e,i)}catch(s){e.customersError=String(s)}finally{e.customersSaving=!1}}}const ub=Object.freeze(Object.defineProperty({__proto__:null,addCustomer:mu,deleteCustomer:yu,deleteCustomerField:bu,loadCustomers:dt,setCustomerField:vu},Symbol.toStringTag,{value:"Module"}));function Yt(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 db(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 pb(e){const t=se(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 hb(e){const t=se(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function fb(e){var n;const t=se(e);if(t)return(n=t.agents[0])==null?void 0:n.id}function gb(e){return e.selectedWorkspace??void 0}function se(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const mb=/^data:/i,yb=/^https?:\/\//i;function Ya(e){var a,c;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=ll(e.sessionKey),i=(n==null?void 0:n.agentId)??((c=e.agentsList)==null?void 0:c.defaultId)??"main",s=t.find(u=>u.id===i),r=s==null?void 0:s.identity,o=(r==null?void 0:r.avatarUrl)??(r==null?void 0:r.avatar);if(o)return mb.test(o)||yb.test(o)?o:r==null?void 0:r.avatarUrl}function vb(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 bb(e){var o;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(o=e.channelAccounts)==null?void 0:o.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,r=s!=null?s.ok===!0:i;return{configured:n.configured??!1,running:i,connected:r,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function wb(e){var o;const t=(o=e.configSnapshot)==null?void 0:o.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(a=>{var c,u;return((c=a.match)==null?void 0:c.channel)==="imessage"&&((u=a.meta)==null?void 0:u.imessageOwner)});if(!i)return null;const s=i.agentId;for(const a of e.workspaces)if(a.agents.some(c=>c.id===s))return a.name;if(s==="admin"||s==="public"){const a=e.workspaces.find(c=>c.isDefault);return(a==null?void 0:a.name)??null}const r=s.replace(/-(admin|public)$/,"");if(r!==s){const a=e.workspaces.find(c=>c.name===r);return(a==null?void 0:a.name)??null}return null}function kb(e){var t,n,i,s,r,o,a,c,u;if(e.embeddingDownloading&&!e.publicChat)return p`
3157
3157
  <div class="setup-container">
3158
3158
  <div class="setup-card" style="text-align:center; max-width:420px;">
3159
3159
  <div class="setup-spinner"></div>
@@ -3167,14 +3167,14 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3167
3167
  </p>
3168
3168
  </div>
3169
3169
  </div>
3170
- `;if(e.publicChat)return e.connected?e.publicChatAuthenticated?kv({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??Ya(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(),ie(async()=>{const{loadChatHistory:l}=await Promise.resolve().then(()=>$s);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}):tb({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",ie(async()=>{const{loadChatHistory:d}=await Promise.resolve().then(()=>$s);return{loadChatHistory:d}},void 0,import.meta.url).then(({loadChatHistory:d})=>{d(e)})},onAuthStepChange:l=>{e.publicChatAuthStep=l}}):p`
3170
+ `;if(e.publicChat)return e.connected?e.publicChatAuthenticated?Sv({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??Ya(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(),ie(async()=>{const{loadChatHistory:l}=await Promise.resolve().then(()=>$s);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}):nb({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",ie(async()=>{const{loadChatHistory:d}=await Promise.resolve().then(()=>$s);return{loadChatHistory:d}},void 0,import.meta.url).then(({loadChatHistory:d})=>{d(e)})},onAuthStepChange:l=>{e.publicChatAuthStep=l},requestUpdate:()=>{e.requestUpdate()}}):p`
3171
3171
  <div class="setup-container">
3172
3172
  <div class="setup-card">
3173
3173
  <div class="setup-spinner"></div>
3174
3174
  <p>Connecting...</p>
3175
3175
  </div>
3176
3176
  </div>
3177
- `;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return Fa({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(d,h)=>{h!=null&&e.handlePinSubmit(d,h)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(d,h,v)=>e.handleChangePin(d,h,v)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return Fa({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:d=>e.handleSetMasterPin(d)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",k}if(e.setup){const l=yb(e.channelsSnapshot),d=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],h=vb(e.channelsSnapshot),v=bb(e);return tf({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:y=>e.handleLicenseKeyChange(y),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:l,whatsappAccounts:d,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:y=>e.handleUninstallConfirmTextChange(y),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:y=>e.handleAuthSubmitCode(y),onAuthCodeChange:y=>e.handleAuthCodeChange(y),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async y=>{await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await V(e,!0),e.requestUpdate())},onWhatsAppReset:async y=>{await e.handleWhatsAppLogout(y),await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await V(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await V(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),V(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:y=>e.handleRemoveWhatsAppAccount(y),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:y=>{e.newWorkspacePin=y},onWorkspaceCreate:async(y,b)=>{const S=e.newWorkspacePin;await e.handleWorkspaceCreate(y,b),S.match(/^\d{4,6}$/)&&(await rb(e,y,S),e.newWorkspacePin="")},onWorkspaceRemove:y=>e.handleWorkspaceRemove(y),onSetAddingWorkspace:y=>{e.addingWorkspace=y},onSetNewWorkspaceName:y=>{e.newWorkspaceName=y},onSetNewWorkspacePath:y=>{e.newWorkspacePath=y},onSetWorkspaceRemoveConfirm:y=>{e.workspaceRemoveConfirm=y},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(y,b)=>e.handleWorkspaceRename(y,b),whatsappDmPolicy:(()=>{const y=se(e),b=y==null?void 0:y.whatsappAccountId,S=b?d.find(x=>x.accountId===b):d[0];return(S==null?void 0:S.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var T;const y=se(e),b=y==null?void 0:y.whatsappAccountId,S=b?d.find(M=>M.accountId===b):d[0];if(!S)return;const $=S.dmPolicy!=null&&S.dmPolicy!=="disabled"?"disabled":"open",C=$==="open"?{dmPolicy:$,allowFrom:["*"]}:{dmPolicy:$};try{const M=await e.client.request("config.get"),R=M.config,B=(T=R==null?void 0:R.channels)==null?void 0:T.whatsapp,ge=((B==null?void 0:B.accounts)??{})[S.accountId]?{channels:{whatsapp:{accounts:{[S.accountId]:C}}}}:{channels:{whatsapp:C}};await e.client.request("config.patch",{raw:JSON.stringify(ge),baseHash:M.hash,note:`WhatsApp DM policy → ${$}`,skipRestart:!0}),await V(e,!1)}catch(M){console.error("DM toggle failed:",M)}},whatsappModel:(()=>{var T,M;const y=se(e);if(!y)return null;const b=y.agents.find(R=>R.id.endsWith("-public")||R.id==="public");if(!b)return null;const S=(T=e.configSnapshot)==null?void 0:T.config,x=(M=S==null?void 0:S.agents)==null?void 0:M.list;if(!Array.isArray(x))return null;const $=x.find(R=>R.id===b.id);if(!($!=null&&$.model))return null;const C=typeof $.model=="string"?$.model:$.model.primary;return(C==null?void 0:C.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async y=>{const b=se(e);if(!b)return;const S=b.agents.find(x=>x.id.endsWith("-public")||x.id==="public");if(S)try{const x=await e.client.request("config.get"),$=x.config,C=($==null?void 0:$.agents)??{},T=Array.isArray(C.list)?[...C.list]:[],M=T.findIndex(B=>B.id===S.id);if(y)M>=0?T[M]={...T[M],model:y}:T.push({id:S.id,model:y});else if(M>=0){const{model:B,...J}=T[M];Object.keys(J).length<=1?T.splice(M,1):T[M]=J}const R=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(R),baseHash:x.hash,note:`Public agent model → ${y||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(x){console.error("Model change failed:",x)}},whatsappThinkingLevel:(()=>{var C,T,M;const y=se(e);if(!y)return null;const b=y.agents.find(R=>R.id.endsWith("-public")||R.id==="public");if(!b)return null;const S=(C=e.configSnapshot)==null?void 0:C.config,x=(T=S==null?void 0:S.agents)==null?void 0:T.list;if(!Array.isArray(x))return null;const $=x.find(R=>R.id===b.id);return((M=$==null?void 0:$.thinkingLevel)==null?void 0:M.trim())||null})(),onWhatsAppThinkingChange:async y=>{const b=se(e);if(!b)return;const S=b.agents.find(x=>x.id.endsWith("-public")||x.id==="public");if(S)try{const x=await e.client.request("config.get"),$=x.config,C=($==null?void 0:$.agents)??{},T=Array.isArray(C.list)?[...C.list]:[],M=T.findIndex(J=>J.id===S.id),R=y==="off"?void 0:y;if(R)M>=0?T[M]={...T[M],thinkingLevel:R}:T.push({id:S.id,thinkingLevel:R});else if(M>=0){const{thinkingLevel:J,...ge}=T[M];Object.keys(ge).length<=1?T.splice(M,1):T[M]=ge}const B=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(B),baseHash:x.hash,note:`Public agent thinking → ${R||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(x){console.error("Thinking change failed:",x)}},whatsappGroupPolicy:(()=>{var M,R;const y=(M=e.configSnapshot)==null?void 0:M.config,b=(R=y==null?void 0:y.channels)==null?void 0:R.whatsapp,S=se(e),x=S==null?void 0:S.whatsappAccountId,$=(b==null?void 0:b.accounts)??{},C=x?$[x]:void 0;return(C==null?void 0:C.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var R,B;const y=(R=e.configSnapshot)==null?void 0:R.config,b=(B=y==null?void 0:y.channels)==null?void 0:B.whatsapp,S=se(e),x=S==null?void 0:S.whatsappAccountId,$=(b==null?void 0:b.accounts)??{},C=x?$[x]:void 0,M=((C==null?void 0:C.groups)??(b==null?void 0:b.groups)??{})["*"];return(M==null?void 0:M.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var S;const y=se(e),b=y==null?void 0:y.whatsappAccountId;try{const x=await e.client.request("config.get"),$=x.config,C=((S=$==null?void 0:$.channels)==null?void 0:S.whatsapp)??{},T=C.accounts??{},M=b?T[b]:void 0,R=(M==null?void 0:M.groupPolicy)??C.groupPolicy??"allowlist",B=R==="disabled"||R==="allowlist",J=B?"open":"disabled",ge=B?{"*":{}}:void 0,Oe={groupPolicy:J};ge&&(Oe.groups=ge);const X=M?{channels:{whatsapp:{accounts:{[b]:Oe}}}}:{channels:{whatsapp:Oe}};await e.client.request("config.patch",{raw:JSON.stringify(X),baseHash:x.hash,note:`WhatsApp groups → ${J}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(x){console.error("Group toggle failed:",x)}},onWhatsAppGroupMentionChange:async y=>{var x;const b=se(e),S=b==null?void 0:b.whatsappAccountId;try{const $=await e.client.request("config.get"),C=$.config,M=(((x=C==null?void 0:C.channels)==null?void 0:x.whatsapp)??{}).accounts??{},R=S?M[S]:void 0,B={"*":{requireMention:y}},J=R?{channels:{whatsapp:{accounts:{[S]:{groups:B}}}}}:{channels:{whatsapp:{groups:B}}};await e.client.request("config.patch",{raw:JSON.stringify(J),baseHash:$.hash,note:`WhatsApp group mention → ${y?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Group mention change failed:",$)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:h.configured,imessageRunning:h.running,imessageConnected:h.connected,imessageLastError:h.lastError,imessageSelfChatMode:h.selfChatMode,imessageCliPath:h.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:v,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,S=(b==null?void 0:b.bindings)??[],x=se(e),$=x==null?void 0:x.agents.find(B=>B.id.endsWith("-admin")||B.id==="admin"),C=($==null?void 0:$.id)??"admin",T=S.filter(B=>{var J;return((J=B.match)==null?void 0:J.channel)!=="imessage"}),M=[{agentId:C,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],R=[...T,...M];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:R}),baseHash:y.hash,note:"Enable iMessage (self-chat) for "+((x==null?void 0:x.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([V(e,!0),_e(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await V(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,x=((b==null?void 0:b.bindings)??[]).filter($=>{var C;return((C=$.match)==null?void 0:C.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:x}),baseHash:y.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([V(e,!0),_e(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,S=(b==null?void 0:b.bindings)??[],x=se(e),$=x==null?void 0:x.agents.find(R=>R.id.endsWith("-admin")||R.id==="admin"),C=($==null?void 0:$.id)??"admin",T=S.filter(R=>{var B;return((B=R.match)==null?void 0:B.channel)!=="imessage"}),M=[{agentId:C,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,...M]}),baseHash:y.hash,note:"Reassign iMessage to "+((x==null?void 0:x.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([V(e,!0),_e(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:y=>{e.infoModalOpen=y},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(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ka(e.client,y,b);const S=`${y} key saved`;e.apiKeySuccess=S,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Ys(e.client)}catch{}y==="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 y=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Wv(e.client,y);const b=`${y} key removed`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Ys(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:y=>{e.authApiKeyInput=y},onAuthApiKeySubmit:async()=>{const y=e.authApiKeyInput.trim();if(y){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await Ka(e.client,"anthropic",y),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(b){e.authApiKeyError=b instanceof Error?b.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var b;const y=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return y?e.accessState.accounts.some(S=>S.id===y):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(y,b)=>{var x;const S=e.selectedWorkspace??((x=e.workspaces[0])==null?void 0:x.name);S&&e.handleAccountPinSave(S,y,b)},publicChatEnabled:(()=>{var S;const y=(S=e.configSnapshot)==null?void 0:S.config,b=y==null?void 0:y.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var x;const y=(x=e.configSnapshot)==null?void 0:x.config,b=y==null?void 0:y.publicChat,S=b==null?void 0:b.auth;return S==="verified"||S==="choice"?S:"anonymous"})(),publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var y;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),S=b.config,x=((y=S==null?void 0:S.publicChat)==null?void 0:y.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!x}}),baseHash:b.hash,note:`Public chat → ${x?"disabled":"enabled"}`}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Public chat toggle failed:",b)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async y=>{if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{auth:y}}),baseHash:b.hash,note:`Public chat auth → ${y}`}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Public chat auth mode change failed:",b)}finally{e.publicChatToggleBusy=!1}}},wsProps:ub(e)})}if(e.filesPage){const l=hb(e);return Wh({connected:e.connected,wsProps:Yt(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,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>yn(e,l),onReindex:()=>Zp(e,l),onSelectFile:d=>qp(e,d,l),onToggleSelectFile:d=>Vp(e,d,l),onToggleDir:d=>Jp(e,d),onUpload:(d,h)=>Yp(e,d,h,l),onDownload:d=>tc(e,d,l),onBulkDownload:()=>Gp(e,l),onDelete:d=>Xp(e,d,l),onMove:(d,h)=>nc(e,d,h,l),onMoveToDir:(d,h)=>Qp(e,d,h,l),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:d=>{const h=e.filesSearchAgentId??l;eh(e,d,h)},onSearchAgentChange:d=>{e.filesSearchAgentId=d},onSearchClear:()=>{th(e)},onSearchQueryChange:d=>{e.filesSearchQuery=d}})}if(e.browserPage)return Rh({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:()=>Iv(e),onStop:()=>Rv(e),onToggleInput:()=>Dv(e),onToggleFullscreen:()=>Ov(e),onCompleteHandoff:()=>Nv(e),onCanvasMouseDown:l=>{const h=l.target.getBoundingClientRect(),y=ln().translateCoordinates(l.clientX-h.left,l.clientY-h.top);vs(e,"mousePressed",y.x,y.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const h=l.target.getBoundingClientRect(),y=ln().translateCoordinates(l.clientX-h.left,l.clientY-h.top);vs(e,"mouseReleased",y.x,y.y)},onCanvasMouseMove:l=>{const d=ln();if(d.shouldThrottleMouseMove())return;const v=l.target.getBoundingClientRect(),y=d.translateCoordinates(l.clientX-v.left,l.clientY-v.top);vs(e,"mouseMoved",y.x,y.y)},onCanvasKeyDown:l=>{let d=0;l.altKey&&(d|=1),l.ctrlKey&&(d|=2),l.metaKey&&(d|=4),l.shiftKey&&(d|=8),bs(e,"keyDown",l.key,{code:l.code,modifiers:d||void 0}),l.key.length===1&&bs(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{bs(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=db(e),d=pb(e);return sf({connected:e.connected,wsProps:Yt(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>_i(e,l),onAdd:h=>{fu(e,h,l,d).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:h=>gu(e,h,l,d),onNewPhoneChange:h=>e.handleAdminsNewPhoneChange(h)})}if(e.customersPage){const l=fb(e);return lf({connected:e.connected,wsProps:Yt(e),loading:e.customersLoading,saving:e.customersSaving,records:e.customersRecords,error:e.customersError,searchQuery:e.customersSearchQuery,editingId:e.customersEditingId,showAddForm:e.customersShowAddForm,newRecordPhone:e.customersNewPhone,newRecordName:e.customersNewName,onSearch:d=>e.customersSearchQuery=d,onSearchSubmit:()=>dt(e,l),onAdd:(d,h)=>mu(e,d,h,l),onDelete:d=>yu(e,d,l),onSetField:(d,h,v)=>vu(e,d,h,v,l),onDeleteField:(d,h)=>bu(e,d,h,l),onToggleExpand:d=>{e.customersEditingId=e.customersEditingId===d?null:d},onShowAddForm:()=>e.customersShowAddForm=!0,onCancelAddForm:()=>{e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName=""},onNewRecordPhoneChange:d=>e.handleCustomersNewPhoneChange(d),onNewRecordNameChange:d=>e.handleCustomersNewNameChange(d),onRefresh:()=>dt(e,l)})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",d=Ya(e),h=e.chatAvatarUrl??d??null,v=(()=>{var S;const y=(S=e.configSnapshot)==null?void 0:S.config,b=y==null?void 0:y.publicChat;return(b==null?void 0:b.enabled)===!0})();return jy({connected:e.connected,wsProps:Yt(e),publicChatEnabled:v,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:y=>{e.sessionKey=y,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:y,lastActiveSessionKey:y}),e.loadAssistantIdentity(),Te(e),Ls(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:y=>{Ln(e,e.sessionKey,{model:y}).then(()=>{Te(e)})},onThinkingLevelChange:y=>{Ln(e,e.sessionKey,{thinkingLevel:y==="off"?null:y}).then(()=>{Te(e)})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestion:e.chatSuggestion,onSuggestionClick:y=>{e.chatMessage=y,e.chatSuggestion=null,e.handleSendChat()},onVerboseChange:y=>{Ln(e,e.sessionKey,{verboseLevel:y==="off"?null:y}).then(()=>{Te(e)})},onFillerChange:y=>{Ln(e,e.sessionKey,{fillerEnabled:y}).then(()=>{Te(e)})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:h,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(),Promise.all([Te(e),Ls(e)])),onToggleFocusMode:()=>{},onChatScroll:y=>e.handleChatScroll(y),nearBottom:e.chatUserNearBottom,onDraftChange:y=>e.chatMessage=y,attachments:e.chatAttachments,onAttachmentsChange:y=>e.chatAttachments=y,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:y=>e.removeQueuedMessage(y),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:y=>e.handleOpenSidebar(y),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:y=>e.handleSplitRatioChange(y),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?wv({connected:e.connected,wsProps:Yt(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&lt(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?rn(e,{reset:!0}):Et(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(o=(r=e.channelsSnapshot)==null?void 0:r.channelMeta)!=null&&o.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((a=e.channelsSnapshot)==null?void 0:a.channelOrder)??[],channelLabels:((c=e.channelsSnapshot)==null?void 0:c.channelLabels)??{},channelMeta:((u=e.channelsSnapshot)==null?void 0:u.channelMeta)??[],agentIds:(()=>{var d;const l=se(e);return((d=l==null?void 0:l.agents)==null?void 0:d.map(h=>h.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1},detailJobId:e.cronDetailJobId,onDetailOpen:l=>{e.cronDetailJobId=l.id,Cs(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{Qd(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,d)=>Yd(e,l,d),onRun:l=>Xd(e,l),onRemove:l=>Zd(e,l),onLoadRuns:l=>Cs(e,l)},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:l=>e.skillsFilter=l,onRefresh:()=>lt(e,{clearMessages:!0}),onToggle:(l,d)=>ql(e,l,d),onEdit:(l,d)=>Hl(e,l,d),onSaveKey:l=>Vl(e,l),onInstall:(l,d,h)=>Gl(e,l,d,h)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?rn(e,{reset:!0}):Et(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,onFilterTextChange:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,d)=>{const h=e;h.sessionLogsTypeFilters={...h.sessionLogsTypeFilters,[l]:d}},onAgentToggle:(l,d)=>{const h=e;h.sessionLogsAgentFilters={...h.sessionLogsAgentFilters,[l]:d}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onRefresh:()=>{rn(e,{reset:!0})},onExport:(l,d)=>e.exportSessionLogs(l,d),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,d)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:d}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onRefresh:()=>Et(e,{reset:!0}),onExport:(l,d)=>e.exportSessionLogs(l,d),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),p``)}function kb(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 Xa(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Sb(e,t,n){return p`
3177
+ `;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return Fa({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(d,h)=>{h!=null&&e.handlePinSubmit(d,h)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(d,h,v)=>e.handleChangePin(d,h,v)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return Fa({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:d=>e.handleSetMasterPin(d)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",k}if(e.setup){const l=vb(e.channelsSnapshot),d=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],h=bb(e.channelsSnapshot),v=wb(e);return nf({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:y=>e.handleLicenseKeyChange(y),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:l,whatsappAccounts:d,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:y=>e.handleUninstallConfirmTextChange(y),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:y=>e.handleAuthSubmitCode(y),onAuthCodeChange:y=>e.handleAuthCodeChange(y),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async y=>{await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await V(e,!0),e.requestUpdate())},onWhatsAppReset:async y=>{await e.handleWhatsAppLogout(y),await e.handleWhatsAppStart(!0,y),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(y),await V(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await V(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),V(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:y=>e.handleRemoveWhatsAppAccount(y),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:y=>{e.newWorkspacePin=y},onWorkspaceCreate:async(y,b)=>{const S=e.newWorkspacePin;await e.handleWorkspaceCreate(y,b),S.match(/^\d{4,6}$/)&&(await ob(e,y,S),e.newWorkspacePin="")},onWorkspaceRemove:y=>e.handleWorkspaceRemove(y),onSetAddingWorkspace:y=>{e.addingWorkspace=y},onSetNewWorkspaceName:y=>{e.newWorkspaceName=y},onSetNewWorkspacePath:y=>{e.newWorkspacePath=y},onSetWorkspaceRemoveConfirm:y=>{e.workspaceRemoveConfirm=y},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(y,b)=>e.handleWorkspaceRename(y,b),whatsappDmPolicy:(()=>{const y=se(e),b=y==null?void 0:y.whatsappAccountId,S=b?d.find(x=>x.accountId===b):d[0];return(S==null?void 0:S.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var T;const y=se(e),b=y==null?void 0:y.whatsappAccountId,S=b?d.find(M=>M.accountId===b):d[0];if(!S)return;const $=S.dmPolicy!=null&&S.dmPolicy!=="disabled"?"disabled":"open",C=$==="open"?{dmPolicy:$,allowFrom:["*"]}:{dmPolicy:$};try{const M=await e.client.request("config.get"),R=M.config,B=(T=R==null?void 0:R.channels)==null?void 0:T.whatsapp,ge=((B==null?void 0:B.accounts)??{})[S.accountId]?{channels:{whatsapp:{accounts:{[S.accountId]:C}}}}:{channels:{whatsapp:C}};await e.client.request("config.patch",{raw:JSON.stringify(ge),baseHash:M.hash,note:`WhatsApp DM policy → ${$}`,skipRestart:!0}),await V(e,!1)}catch(M){console.error("DM toggle failed:",M)}},whatsappModel:(()=>{var T,M;const y=se(e);if(!y)return null;const b=y.agents.find(R=>R.id.endsWith("-public")||R.id==="public");if(!b)return null;const S=(T=e.configSnapshot)==null?void 0:T.config,x=(M=S==null?void 0:S.agents)==null?void 0:M.list;if(!Array.isArray(x))return null;const $=x.find(R=>R.id===b.id);if(!($!=null&&$.model))return null;const C=typeof $.model=="string"?$.model:$.model.primary;return(C==null?void 0:C.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async y=>{const b=se(e);if(!b)return;const S=b.agents.find(x=>x.id.endsWith("-public")||x.id==="public");if(S)try{const x=await e.client.request("config.get"),$=x.config,C=($==null?void 0:$.agents)??{},T=Array.isArray(C.list)?[...C.list]:[],M=T.findIndex(B=>B.id===S.id);if(y)M>=0?T[M]={...T[M],model:y}:T.push({id:S.id,model:y});else if(M>=0){const{model:B,...J}=T[M];Object.keys(J).length<=1?T.splice(M,1):T[M]=J}const R=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(R),baseHash:x.hash,note:`Public agent model → ${y||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(x){console.error("Model change failed:",x)}},whatsappThinkingLevel:(()=>{var C,T,M;const y=se(e);if(!y)return null;const b=y.agents.find(R=>R.id.endsWith("-public")||R.id==="public");if(!b)return null;const S=(C=e.configSnapshot)==null?void 0:C.config,x=(T=S==null?void 0:S.agents)==null?void 0:T.list;if(!Array.isArray(x))return null;const $=x.find(R=>R.id===b.id);return((M=$==null?void 0:$.thinkingLevel)==null?void 0:M.trim())||null})(),onWhatsAppThinkingChange:async y=>{const b=se(e);if(!b)return;const S=b.agents.find(x=>x.id.endsWith("-public")||x.id==="public");if(S)try{const x=await e.client.request("config.get"),$=x.config,C=($==null?void 0:$.agents)??{},T=Array.isArray(C.list)?[...C.list]:[],M=T.findIndex(J=>J.id===S.id),R=y==="off"?void 0:y;if(R)M>=0?T[M]={...T[M],thinkingLevel:R}:T.push({id:S.id,thinkingLevel:R});else if(M>=0){const{thinkingLevel:J,...ge}=T[M];Object.keys(ge).length<=1?T.splice(M,1):T[M]=ge}const B=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(B),baseHash:x.hash,note:`Public agent thinking → ${R||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(x){console.error("Thinking change failed:",x)}},whatsappGroupPolicy:(()=>{var M,R;const y=(M=e.configSnapshot)==null?void 0:M.config,b=(R=y==null?void 0:y.channels)==null?void 0:R.whatsapp,S=se(e),x=S==null?void 0:S.whatsappAccountId,$=(b==null?void 0:b.accounts)??{},C=x?$[x]:void 0;return(C==null?void 0:C.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var R,B;const y=(R=e.configSnapshot)==null?void 0:R.config,b=(B=y==null?void 0:y.channels)==null?void 0:B.whatsapp,S=se(e),x=S==null?void 0:S.whatsappAccountId,$=(b==null?void 0:b.accounts)??{},C=x?$[x]:void 0,M=((C==null?void 0:C.groups)??(b==null?void 0:b.groups)??{})["*"];return(M==null?void 0:M.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var S;const y=se(e),b=y==null?void 0:y.whatsappAccountId;try{const x=await e.client.request("config.get"),$=x.config,C=((S=$==null?void 0:$.channels)==null?void 0:S.whatsapp)??{},T=C.accounts??{},M=b?T[b]:void 0,R=(M==null?void 0:M.groupPolicy)??C.groupPolicy??"allowlist",B=R==="disabled"||R==="allowlist",J=B?"open":"disabled",ge=B?{"*":{}}:void 0,Oe={groupPolicy:J};ge&&(Oe.groups=ge);const X=M?{channels:{whatsapp:{accounts:{[b]:Oe}}}}:{channels:{whatsapp:Oe}};await e.client.request("config.patch",{raw:JSON.stringify(X),baseHash:x.hash,note:`WhatsApp groups → ${J}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(x){console.error("Group toggle failed:",x)}},onWhatsAppGroupMentionChange:async y=>{var x;const b=se(e),S=b==null?void 0:b.whatsappAccountId;try{const $=await e.client.request("config.get"),C=$.config,M=(((x=C==null?void 0:C.channels)==null?void 0:x.whatsapp)??{}).accounts??{},R=S?M[S]:void 0,B={"*":{requireMention:y}},J=R?{channels:{whatsapp:{accounts:{[S]:{groups:B}}}}}:{channels:{whatsapp:{groups:B}}};await e.client.request("config.patch",{raw:JSON.stringify(J),baseHash:$.hash,note:`WhatsApp group mention → ${y?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Group mention change failed:",$)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:h.configured,imessageRunning:h.running,imessageConnected:h.connected,imessageLastError:h.lastError,imessageSelfChatMode:h.selfChatMode,imessageCliPath:h.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:v,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,S=(b==null?void 0:b.bindings)??[],x=se(e),$=x==null?void 0:x.agents.find(B=>B.id.endsWith("-admin")||B.id==="admin"),C=($==null?void 0:$.id)??"admin",T=S.filter(B=>{var J;return((J=B.match)==null?void 0:J.channel)!=="imessage"}),M=[{agentId:C,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],R=[...T,...M];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:R}),baseHash:y.hash,note:"Enable iMessage (self-chat) for "+((x==null?void 0:x.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([V(e,!0),_e(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await V(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,x=((b==null?void 0:b.bindings)??[]).filter($=>{var C;return((C=$.match)==null?void 0:C.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:x}),baseHash:y.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([V(e,!0),_e(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const y=await e.client.request("config.get"),b=y.config,S=(b==null?void 0:b.bindings)??[],x=se(e),$=x==null?void 0:x.agents.find(R=>R.id.endsWith("-admin")||R.id==="admin"),C=($==null?void 0:$.id)??"admin",T=S.filter(R=>{var B;return((B=R.match)==null?void 0:B.channel)!=="imessage"}),M=[{agentId:C,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,...M]}),baseHash:y.hash,note:"Reassign iMessage to "+((x==null?void 0:x.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([V(e,!0),_e(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:y=>{e.infoModalOpen=y},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(y,b)=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ka(e.client,y,b);const S=`${y} key saved`;e.apiKeySuccess=S,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Ys(e.client)}catch{}y==="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 y=>{e.apiKeySavingProvider=y,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Kv(e.client,y);const b=`${y} key removed`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Ys(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:y=>{e.authApiKeyInput=y},onAuthApiKeySubmit:async()=>{const y=e.authApiKeyInput.trim();if(y){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await Ka(e.client,"anthropic",y),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(b){e.authApiKeyError=b instanceof Error?b.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var b;const y=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return y?e.accessState.accounts.some(S=>S.id===y):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(y,b)=>{var x;const S=e.selectedWorkspace??((x=e.workspaces[0])==null?void 0:x.name);S&&e.handleAccountPinSave(S,y,b)},publicChatEnabled:(()=>{var S;const y=(S=e.configSnapshot)==null?void 0:S.config,b=y==null?void 0:y.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var x;const y=(x=e.configSnapshot)==null?void 0:x.config,b=y==null?void 0:y.publicChat,S=b==null?void 0:b.auth;return S==="verified"||S==="choice"?S:"anonymous"})(),publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var y;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),S=b.config,x=((y=S==null?void 0:S.publicChat)==null?void 0:y.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!x}}),baseHash:b.hash,note:`Public chat → ${x?"disabled":"enabled"}`}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Public chat toggle failed:",b)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async y=>{if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{auth:y}}),baseHash:b.hash,note:`Public chat auth → ${y}`}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Public chat auth mode change failed:",b)}finally{e.publicChatToggleBusy=!1}}},wsProps:db(e)})}if(e.filesPage){const l=fb(e);return Kh({connected:e.connected,wsProps:Yt(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,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>yn(e,l),onReindex:()=>Jp(e,l),onSelectFile:d=>Vp(e,d,l),onToggleSelectFile:d=>Gp(e,d,l),onToggleDir:d=>eh(e,d),onUpload:(d,h)=>Xp(e,d,h,l),onDownload:d=>ec(e,d,l),onBulkDownload:()=>Qp(e,l),onDelete:d=>Zp(e,d,l),onMove:(d,h)=>tc(e,d,h,l),onMoveToDir:(d,h)=>Yp(e,d,h,l),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:d=>{const h=e.filesSearchAgentId??l;th(e,d,h)},onSearchAgentChange:d=>{e.filesSearchAgentId=d},onSearchClear:()=>{nh(e)},onSearchQueryChange:d=>{e.filesSearchQuery=d}})}if(e.browserPage)return Nh({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:()=>Rv(e),onStop:()=>Nv(e),onToggleInput:()=>Ov(e),onToggleFullscreen:()=>Bv(e),onCompleteHandoff:()=>Dv(e),onCanvasMouseDown:l=>{const h=l.target.getBoundingClientRect(),y=ln().translateCoordinates(l.clientX-h.left,l.clientY-h.top);vs(e,"mousePressed",y.x,y.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const h=l.target.getBoundingClientRect(),y=ln().translateCoordinates(l.clientX-h.left,l.clientY-h.top);vs(e,"mouseReleased",y.x,y.y)},onCanvasMouseMove:l=>{const d=ln();if(d.shouldThrottleMouseMove())return;const v=l.target.getBoundingClientRect(),y=d.translateCoordinates(l.clientX-v.left,l.clientY-v.top);vs(e,"mouseMoved",y.x,y.y)},onCanvasKeyDown:l=>{let d=0;l.altKey&&(d|=1),l.ctrlKey&&(d|=2),l.metaKey&&(d|=4),l.shiftKey&&(d|=8),bs(e,"keyDown",l.key,{code:l.code,modifiers:d||void 0}),l.key.length===1&&bs(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{bs(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=pb(e),d=hb(e);return rf({connected:e.connected,wsProps:Yt(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>_i(e,l),onAdd:h=>{fu(e,h,l,d).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:h=>gu(e,h,l,d),onNewPhoneChange:h=>e.handleAdminsNewPhoneChange(h)})}if(e.customersPage){const l=gb(e);return cf({connected:e.connected,wsProps:Yt(e),loading:e.customersLoading,saving:e.customersSaving,records:e.customersRecords,error:e.customersError,searchQuery:e.customersSearchQuery,editingId:e.customersEditingId,showAddForm:e.customersShowAddForm,newRecordPhone:e.customersNewPhone,newRecordName:e.customersNewName,onSearch:d=>e.customersSearchQuery=d,onSearchSubmit:()=>dt(e,l),onAdd:(d,h)=>mu(e,d,h,l),onDelete:d=>yu(e,d,l),onSetField:(d,h,v)=>vu(e,d,h,v,l),onDeleteField:(d,h)=>bu(e,d,h,l),onToggleExpand:d=>{e.customersEditingId=e.customersEditingId===d?null:d},onShowAddForm:()=>e.customersShowAddForm=!0,onCancelAddForm:()=>{e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName=""},onNewRecordPhoneChange:d=>e.handleCustomersNewPhoneChange(d),onNewRecordNameChange:d=>e.handleCustomersNewNameChange(d),onRefresh:()=>dt(e,l)})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",d=Ya(e),h=e.chatAvatarUrl??d??null,v=(()=>{var S;const y=(S=e.configSnapshot)==null?void 0:S.config,b=y==null?void 0:y.publicChat;return(b==null?void 0:b.enabled)===!0})();return Hy({connected:e.connected,wsProps:Yt(e),publicChatEnabled:v,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:y=>{e.sessionKey=y,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:y,lastActiveSessionKey:y}),e.loadAssistantIdentity(),Te(e),Ls(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:y=>{Ln(e,e.sessionKey,{model:y}).then(()=>{Te(e)})},onThinkingLevelChange:y=>{Ln(e,e.sessionKey,{thinkingLevel:y==="off"?null:y}).then(()=>{Te(e)})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestion:e.chatSuggestion,onSuggestionClick:y=>{e.chatMessage=y,e.chatSuggestion=null,e.handleSendChat()},onVerboseChange:y=>{Ln(e,e.sessionKey,{verboseLevel:y==="off"?null:y}).then(()=>{Te(e)})},onFillerChange:y=>{Ln(e,e.sessionKey,{fillerEnabled:y}).then(()=>{Te(e)})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:h,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(),Promise.all([Te(e),Ls(e)])),onToggleFocusMode:()=>{},onChatScroll:y=>e.handleChatScroll(y),nearBottom:e.chatUserNearBottom,onDraftChange:y=>e.chatMessage=y,attachments:e.chatAttachments,onAttachmentsChange:y=>e.chatAttachments=y,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:y=>e.removeQueuedMessage(y),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:y=>e.handleOpenSidebar(y),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:y=>e.handleSplitRatioChange(y),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?kv({connected:e.connected,wsProps:Yt(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&lt(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?rn(e,{reset:!0}):Et(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(o=(r=e.channelsSnapshot)==null?void 0:r.channelMeta)!=null&&o.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((a=e.channelsSnapshot)==null?void 0:a.channelOrder)??[],channelLabels:((c=e.channelsSnapshot)==null?void 0:c.channelLabels)??{},channelMeta:((u=e.channelsSnapshot)==null?void 0:u.channelMeta)??[],agentIds:(()=>{var d;const l=se(e);return((d=l==null?void 0:l.agents)==null?void 0:d.map(h=>h.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1},detailJobId:e.cronDetailJobId,onDetailOpen:l=>{e.cronDetailJobId=l.id,Cs(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{Yd(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,d)=>Xd(e,l,d),onRun:l=>Zd(e,l),onRemove:l=>Jd(e,l),onLoadRuns:l=>Cs(e,l)},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:l=>e.skillsFilter=l,onRefresh:()=>lt(e,{clearMessages:!0}),onToggle:(l,d)=>Hl(e,l,d),onEdit:(l,d)=>jl(e,l,d),onSaveKey:l=>ql(e,l),onInstall:(l,d,h)=>Vl(e,l,d,h)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?rn(e,{reset:!0}):Et(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,onFilterTextChange:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,d)=>{const h=e;h.sessionLogsTypeFilters={...h.sessionLogsTypeFilters,[l]:d}},onAgentToggle:(l,d)=>{const h=e;h.sessionLogsAgentFilters={...h.sessionLogsAgentFilters,[l]:d}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onRefresh:()=>{rn(e,{reset:!0})},onExport:(l,d)=>e.exportSessionLogs(l,d),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,d)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:d}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onRefresh:()=>Et(e,{reset:!0}),onExport:(l,d)=>e.exportSessionLogs(l,d),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),p``)}function Sb(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 Xa(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Ab(e,t,n){return p`
3178
3178
  <div class="audit-modal-overlay" @click=${s=>{s.target.classList.contains("audit-modal-overlay")&&n()}}>
3179
3179
  <div class="audit-modal-card">
3180
3180
  <div class="audit-modal-header">
@@ -3194,7 +3194,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3194
3194
  <a href="/files" class="audit-modal-path-link">${s.path}</a>
3195
3195
  </div>
3196
3196
  <div class="audit-modal-entry-meta">
3197
- ${kb(s.timestamp)}
3197
+ ${Sb(s.timestamp)}
3198
3198
  <span class="audit-modal-agent">${s.agentId}</span>
3199
3199
  </div>
3200
3200
  </div>
@@ -3206,7 +3206,7 @@ ${a.text}`:c.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3206
3206
  `}
3207
3207
  </div>
3208
3208
  </div>
3209
- `}const Ab={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},xb={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",to:"",timeoutSeconds:"",postToMainPrefix:""};function $b(e){e.basePath=dh();const t=qe();if(_h(t.accentColor),window.scrollTo(0,0),sh(e),e.publicChat){const n=al();document.title=`Chat with ${n.name}`,Ee(e);return}if(e.setup){document.title=`${t.name} Setup`,Ee(e);return}if(e.filesPage){document.title=`${t.name} Files`,oh(e),Ee(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Ee(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Ee(e);return}if(e.customersPage){document.title=`${t.name} Customers`,Ee(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Ee(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Ee(e);return}gh(e,!0),ph(e),hh(e),window.addEventListener("popstate",e.popStateHandler),lh(e),Ee(e),nh(e),e.tab==="logs"&&(e.logsSubTab==="session"?yr(e):gr(e)),e.tab==="debug"&&br(e)}function Eb(e){zd(e)}function Cb(e){var t;window.removeEventListener("popstate",e.popStateHandler),ih(e),mr(e),vr(e),wr(e),rh(e),ah(e),fh(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function Tb(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.customersPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleCustomersLoad&&e.handleCustomersLoad(),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(r=>{e.channelsSnapshot=r,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;fn(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&wl(e,t.has("tab")||t.has("logsAutoFollow"))}}function _b(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 Mb(e,t,n){await sr(e,t,n),await V(e,!0)}async function Pb(e,t){await Al(e,t),await V(e,!0)}async function Lb(e,t){await xl(e,t),await V(e,!0)}async function Ib(e,t){await $l(e,t)}async function Rb(e,t){await El(e,t)}async function Nb(e){await qd(e),await _e(e),await V(e,!0)}async function Db(e){await _e(e),await V(e,!0)}function Ob(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 r=i.trim(),o=s.join(":").trim();r&&o&&(t[r]=o)}return t}function wu(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 ku(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function Bb(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=_b(n??void 0)}function Fb(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function Ub(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function Wb(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function Kb(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=wu(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(ku(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 r=(s==null?void 0:s.error)??`Profile update failed (${i.status})`;e.nostrProfileFormState={...t,saving:!1,error:r,success:null,fieldErrors:Ob(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 V(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function zb(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=wu(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(ku(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 c=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:c,success:null};return}const r=s.merged??s.imported??null,o=r?{...t.values,...r}:t.values,a=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:a},s.saved&&await V(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function jb(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 Hb(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 qb(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 Vb(e,t){e.authCodeInput=t}function Gb(e){e.setupStep="whatsapp"}async function Qb(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 Yb(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 Xb(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 Zb(e,t){e.licenseKey=t}async function Jb(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 ew(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 tw=Object.defineProperty,nw=Object.getOwnPropertyDescriptor,g=(e,t,n,i)=>{for(var s=i>1?void 0:i?nw(t,n):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(s=(i?o(t,n,s):o(s))||s);return i&&s&&tw(t,n,s),s};const Ss=al();function iw(){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 sw(){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 rw(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function ow(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function aw(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function lw(){const e=window.location.pathname;return e==="/customers"||e.endsWith("/customers")}function cw(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function uw(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let f=class extends $t{constructor(){super(...arguments),this.settings=qi(),this.password="",this.tab="chat",this.onboarding=iw(),this.setup=sw(),this.filesPage=rw(),this.browserPage=ow(),this.adminsPage=aw(),this.customersPage=lw(),this.chatPage=cw(),this.advancedPage=uw(),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=uu,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=Ss.name,this.assistantAvatar=Ss.avatar,this.assistantAgentId=Ss.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],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=`{
3209
+ `}const xb={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},$b={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",to:"",timeoutSeconds:"",postToMainPrefix:""};function Eb(e){e.basePath=ph();const t=qe();if(Mh(t.accentColor),window.scrollTo(0,0),rh(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}`,Ee(e);return}if(e.setup){document.title=`${t.name} Setup`,Ee(e);return}if(e.filesPage){document.title=`${t.name} Files`,ah(e),Ee(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Ee(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Ee(e);return}if(e.customersPage){document.title=`${t.name} Customers`,Ee(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Ee(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Ee(e);return}mh(e,!0),hh(e),fh(e),window.addEventListener("popstate",e.popStateHandler),ch(e),Ee(e),ih(e),e.tab==="logs"&&(e.logsSubTab==="session"?yr(e):gr(e)),e.tab==="debug"&&br(e)}function Cb(e){jd(e)}function Tb(e){var t;window.removeEventListener("popstate",e.popStateHandler),sh(e),mr(e),vr(e),wr(e),oh(e),lh(e),gh(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function _b(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.customersPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleCustomersLoad&&e.handleCustomersLoad(),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(r=>{e.channelsSnapshot=r,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;fn(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&bl(e,t.has("tab")||t.has("logsAutoFollow"))}}function Mb(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 Pb(e,t,n){await sr(e,t,n),await V(e,!0)}async function Lb(e,t){await Sl(e,t),await V(e,!0)}async function Ib(e,t){await Al(e,t),await V(e,!0)}async function Rb(e,t){await xl(e,t)}async function Nb(e,t){await $l(e,t)}async function Db(e){await Vd(e),await _e(e),await V(e,!0)}async function Ob(e){await _e(e),await V(e,!0)}function Bb(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 r=i.trim(),o=s.join(":").trim();r&&o&&(t[r]=o)}return t}function wu(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 ku(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function Fb(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Mb(n??void 0)}function Ub(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function Wb(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function Kb(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function zb(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=wu(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(ku(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 r=(s==null?void 0:s.error)??`Profile update failed (${i.status})`;e.nostrProfileFormState={...t,saving:!1,error:r,success:null,fieldErrors:Bb(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 V(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function jb(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=wu(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(ku(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 c=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:c,success:null};return}const r=s.merged??s.imported??null,o=r?{...t.values,...r}:t.values,a=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:a},s.saved&&await V(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function Hb(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 qb(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 Vb(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 Gb(e,t){e.authCodeInput=t}function Qb(e){e.setupStep="whatsapp"}async function Yb(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 Xb(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 Zb(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 Jb(e,t){e.licenseKey=t}async function ew(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 tw(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 nw=Object.defineProperty,iw=Object.getOwnPropertyDescriptor,g=(e,t,n,i)=>{for(var s=i>1?void 0:i?iw(t,n):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(s=(i?o(t,n,s):o(s))||s);return i&&s&&nw(t,n,s),s};const Ss=od();function sw(){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 rw(){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 ow(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function aw(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function lw(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function cw(){const e=window.location.pathname;return e==="/customers"||e.endsWith("/customers")}function uw(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function dw(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let f=class extends $t{constructor(){super(...arguments),this.settings=qi(),this.password="",this.tab="chat",this.onboarding=sw(),this.setup=rw(),this.filesPage=ow(),this.browserPage=aw(),this.adminsPage=lw(),this.customersPage=cw(),this.chatPage=uw(),this.advancedPage=dw(),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=uu,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=Ss.name,this.assistantAvatar=Ss.avatar,this.assistantAgentId=Ss.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],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=`{
3210
3210
  }
3211
- `,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.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={...xb},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=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.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.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.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.customersLoading=!1,this.customersSaving=!1,this.customersRecords=[],this.customersError=null,this.customersSearchQuery="",this.customersEditingId=null,this.customersShowAddForm=!1,this.customersNewPhone="",this.customersNewName="",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={...Ab},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,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,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=()=>mh(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),$b(this)}firstUpdated(){Eb(this)}disconnectedCallback(){this.stopEmbeddingPoll(),Cb(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){Tb(this,e)}connect(){Ee(this)}handleChatScroll(e){Od(this,e)}handleLogsScroll(e){Bd(this,e)}handleSessionLogsScroll(e){Fd(this,e)}exportLogs(e,t){Wd(e,t)}exportSessionLogs(e,t){Kd(e,t)}resetToolStream(){ir(this)}resetChatScroll(){Ud(this)}async loadAssistantIdentity(){await Qs(this)}applySettings(e){ze(this,e)}setTab(e){ch(this,e)}setTheme(e,t){uh(this,e,t)}async loadOverview(){await oc(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 kr(this)}async handleAbortChat(){await lc(this)}removeQueuedMessage(e){wh(this,e)}async handleSendChat(e,t){await kh(this,e,t)}async handleWhatsAppStart(e,t){await Mb(this,e,t)}async handleWhatsAppWait(e){await Pb(this,e)}async handleWhatsAppLogout(e){await Lb(this,e)}async handleAddWhatsAppAccount(e){await Ib(this,e)}async handleRemoveWhatsAppAccount(e){await Rb(this,e)}async handleAccessCheck(){await Qa(this)}async handlePinSubmit(e,t){await ib(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await sb(this,e)}async handleLogout(){await ob(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 Qa(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 Qb(this)}async handleLicenseActivate(){await Yb(this)}async handleLicenseRemove(){await Xb(this)}handleLicenseKeyChange(e){Zb(this,e)}async handleAuthStatusCheck(){await jb(this)}async handleAuthStart(){await Hb(this)}async handleAuthSubmitCode(e){await qb(this,e)}handleAuthCodeChange(e){Vb(this,e)}handleSkipToWhatsApp(){Gb(this)}async handleGatewayHealthCheck(){await Jb(this)}async handleGatewayRestart(){await ew(this)}async handleUpdateCheck(){await au(this)}async handleUpdateRun(){await Kv(this)}handleUpdateDismissResult(){Hv(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 ie(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Ro);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){ie(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Ro);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await Jl(this)}async clearAudit(){await Hp(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();yn(this,t),fr(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();ie(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>lb);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 t;const e=this.getSelectedWorkspaceInfo();if(e)return(t=e.agents[0])==null?void 0:t.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.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}ie(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>$s);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this)})}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"?ie(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>Zl);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):ie(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>sp);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&ie(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>Bp);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await Nb(this)}async handleChannelConfigReload(){await Db(this)}handleNostrProfileEdit(e,t){Bb(this,e,t)}handleNostrProfileCancel(){Fb(this)}handleNostrProfileFieldChange(e,t){Ub(this,e,t)}async handleNostrProfileSave(){await Kb(this)}async handleNostrProfileImport(){await zb(this)}handleNostrProfileToggleAdvanced(){Wb(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)}handleCustomersLoad(){const e=this.selectedWorkspace??void 0;ie(async()=>{const{loadCustomers:t}=await Promise.resolve().then(()=>cb);return{loadCustomers:t}},void 0,import.meta.url).then(({loadCustomers:t})=>{t(this,e)})}handleCustomersNewPhoneChange(e){this.customersNewPhone=e,this.customersError&&(this.customersError=null)}handleCustomersNewNameChange(e){this.customersNewName=e,this.customersError&&(this.customersError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await ie(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>jn);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await ie(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>jn);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await ie(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>Jd);return{loadChannels:s}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:s=>{if(!s.whatsappAccountId)return;const r=s.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await i(this,!0),await this.handleWhatsAppStart(!0,r),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(r),await i(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await ie(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>jn);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 ie(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>jn);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),ko(e),this.settings=qi(),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.customersPage?this.handleCustomersLoad():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)}ko(this.selectedWorkspace),this.settings=qi(),this.reloadCurrentPageData()}render(){return p`${wb(this)}${this.auditModalOpen?Sb(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):k}`}};g([m()],f.prototype,"settings",2);g([m()],f.prototype,"password",2);g([m()],f.prototype,"tab",2);g([m()],f.prototype,"onboarding",2);g([m()],f.prototype,"setup",2);g([m()],f.prototype,"filesPage",2);g([m()],f.prototype,"browserPage",2);g([m()],f.prototype,"adminsPage",2);g([m()],f.prototype,"customersPage",2);g([m()],f.prototype,"chatPage",2);g([m()],f.prototype,"advancedPage",2);g([m()],f.prototype,"advancedTab",2);g([m()],f.prototype,"publicChat",2);g([m()],f.prototype,"publicChatConfig",2);g([m()],f.prototype,"publicChatSessionKey",2);g([m()],f.prototype,"publicChatAuthenticated",2);g([m()],f.prototype,"publicChatAuthStep",2);g([m()],f.prototype,"connected",2);g([m()],f.prototype,"accessState",2);g([m()],f.prototype,"theme",2);g([m()],f.prototype,"themeResolved",2);g([m()],f.prototype,"hello",2);g([m()],f.prototype,"lastError",2);g([m()],f.prototype,"eventLog",2);g([m()],f.prototype,"assistantName",2);g([m()],f.prototype,"assistantAvatar",2);g([m()],f.prototype,"assistantAgentId",2);g([m()],f.prototype,"sessionKey",2);g([m()],f.prototype,"chatLoading",2);g([m()],f.prototype,"chatSending",2);g([m()],f.prototype,"chatMessage",2);g([m()],f.prototype,"chatMessages",2);g([m()],f.prototype,"chatToolMessages",2);g([m()],f.prototype,"chatStream",2);g([m()],f.prototype,"chatInterimText",2);g([m()],f.prototype,"chatSuggestion",2);g([m()],f.prototype,"chatStreamStartedAt",2);g([m()],f.prototype,"chatRunId",2);g([m()],f.prototype,"compactionStatus",2);g([m()],f.prototype,"chatAvatarUrl",2);g([m()],f.prototype,"chatThinkingLevel",2);g([m()],f.prototype,"chatModelProvider",2);g([m()],f.prototype,"chatModel",2);g([m()],f.prototype,"chatModelCatalog",2);g([m()],f.prototype,"chatVerboseLevel",2);g([m()],f.prototype,"chatFillerEnabled",2);g([m()],f.prototype,"chatQueue",2);g([m()],f.prototype,"chatAttachments",2);g([m()],f.prototype,"sidebarOpen",2);g([m()],f.prototype,"sidebarContent",2);g([m()],f.prototype,"sidebarError",2);g([m()],f.prototype,"splitRatio",2);g([m()],f.prototype,"nodesLoading",2);g([m()],f.prototype,"nodes",2);g([m()],f.prototype,"devicesLoading",2);g([m()],f.prototype,"devicesError",2);g([m()],f.prototype,"devicesList",2);g([m()],f.prototype,"execApprovalsLoading",2);g([m()],f.prototype,"execApprovalsSaving",2);g([m()],f.prototype,"execApprovalsDirty",2);g([m()],f.prototype,"execApprovalsSnapshot",2);g([m()],f.prototype,"execApprovalsForm",2);g([m()],f.prototype,"execApprovalsSelectedAgent",2);g([m()],f.prototype,"execApprovalsTarget",2);g([m()],f.prototype,"execApprovalsTargetNodeId",2);g([m()],f.prototype,"execApprovalQueue",2);g([m()],f.prototype,"execApprovalBusy",2);g([m()],f.prototype,"execApprovalError",2);g([m()],f.prototype,"configLoading",2);g([m()],f.prototype,"configRaw",2);g([m()],f.prototype,"configRawOriginal",2);g([m()],f.prototype,"configValid",2);g([m()],f.prototype,"configIssues",2);g([m()],f.prototype,"configSaving",2);g([m()],f.prototype,"configApplying",2);g([m()],f.prototype,"updateRunning",2);g([m()],f.prototype,"applySessionKey",2);g([m()],f.prototype,"configSnapshot",2);g([m()],f.prototype,"configSchema",2);g([m()],f.prototype,"configSchemaVersion",2);g([m()],f.prototype,"configSchemaLoading",2);g([m()],f.prototype,"configUiHints",2);g([m()],f.prototype,"configForm",2);g([m()],f.prototype,"configFormOriginal",2);g([m()],f.prototype,"configFormDirty",2);g([m()],f.prototype,"configFormMode",2);g([m()],f.prototype,"configSearchQuery",2);g([m()],f.prototype,"configActiveSection",2);g([m()],f.prototype,"configActiveSubsection",2);g([m()],f.prototype,"channelsLoading",2);g([m()],f.prototype,"channelsSnapshot",2);g([m()],f.prototype,"channelsError",2);g([m()],f.prototype,"channelsLastSuccess",2);g([m()],f.prototype,"whatsappLoginMessage",2);g([m()],f.prototype,"whatsappLoginQrDataUrl",2);g([m()],f.prototype,"whatsappLoginConnected",2);g([m()],f.prototype,"whatsappBusy",2);g([m()],f.prototype,"whatsappActiveQrAccountId",2);g([m()],f.prototype,"whatsappPairedPhone",2);g([m()],f.prototype,"addingWhatsAppAccount",2);g([m()],f.prototype,"newWhatsAppAccountName",2);g([m()],f.prototype,"whatsappAccountError",2);g([m()],f.prototype,"whatsappAccountSaving",2);g([m()],f.prototype,"whatsappSettingsOpen",2);g([m()],f.prototype,"publicChatToggleBusy",2);g([m()],f.prototype,"licenseKey",2);g([m()],f.prototype,"licenseBusy",2);g([m()],f.prototype,"licenseValid",2);g([m()],f.prototype,"licenseMessage",2);g([m()],f.prototype,"licenseTier",2);g([m()],f.prototype,"licenseDeviceId",2);g([m()],f.prototype,"licenseStoredKey",2);g([m()],f.prototype,"licenseRemoveConfirm",2);g([m()],f.prototype,"authConnected",2);g([m()],f.prototype,"authBusy",2);g([m()],f.prototype,"authMessage",2);g([m()],f.prototype,"authUrl",2);g([m()],f.prototype,"authCodeInput",2);g([m()],f.prototype,"authExpiresIn",2);g([m()],f.prototype,"setupStep",2);g([m()],f.prototype,"gatewayHealthy",2);g([m()],f.prototype,"gatewayHealthLoading",2);g([m()],f.prototype,"gatewayHealthMessage",2);g([m()],f.prototype,"gatewayRestartBusy",2);g([m()],f.prototype,"updateAvailable",2);g([m()],f.prototype,"currentVersion",2);g([m()],f.prototype,"latestVersion",2);g([m()],f.prototype,"updateChecking",2);g([m()],f.prototype,"updateMessage",2);g([m()],f.prototype,"updateProgressSteps",2);g([m()],f.prototype,"updateLastResult",2);g([m()],f.prototype,"uninstallConfirm",2);g([m()],f.prototype,"uninstallBusy",2);g([m()],f.prototype,"uninstallDone",2);g([m()],f.prototype,"uninstallError",2);g([m()],f.prototype,"uninstallConfirmText",2);g([m()],f.prototype,"nostrProfileFormState",2);g([m()],f.prototype,"nostrProfileAccountId",2);g([m()],f.prototype,"presenceLoading",2);g([m()],f.prototype,"presenceEntries",2);g([m()],f.prototype,"presenceError",2);g([m()],f.prototype,"presenceStatus",2);g([m()],f.prototype,"agentsLoading",2);g([m()],f.prototype,"agentsList",2);g([m()],f.prototype,"agentsError",2);g([m()],f.prototype,"sessionsLoading",2);g([m()],f.prototype,"sessionsResult",2);g([m()],f.prototype,"sessionsError",2);g([m()],f.prototype,"cronLoading",2);g([m()],f.prototype,"cronJobs",2);g([m()],f.prototype,"cronStatus",2);g([m()],f.prototype,"cronError",2);g([m()],f.prototype,"cronForm",2);g([m()],f.prototype,"cronRunsJobId",2);g([m()],f.prototype,"cronRuns",2);g([m()],f.prototype,"cronBusy",2);g([m()],f.prototype,"cronNewEventModal",2);g([m()],f.prototype,"cronDetailJobId",2);g([m()],f.prototype,"browserScreencastActive",2);g([m()],f.prototype,"browserScreencastFrame",2);g([m()],f.prototype,"browserScreencastMetadata",2);g([m()],f.prototype,"browserHandoffPending",2);g([m()],f.prototype,"browserHandoffReason",2);g([m()],f.prototype,"browserHandoffId",2);g([m()],f.prototype,"browserInputMode",2);g([m()],f.prototype,"browserFullscreen",2);g([m()],f.prototype,"browserLoading",2);g([m()],f.prototype,"browserError",2);g([m()],f.prototype,"filesLoading",2);g([m()],f.prototype,"filesTree",2);g([m()],f.prototype,"filesRoot",2);g([m()],f.prototype,"filesError",2);g([m()],f.prototype,"filesSelectedPath",2);g([m()],f.prototype,"filesSelectedPaths",2);g([m()],f.prototype,"filesPreviewContent",2);g([m()],f.prototype,"filesPreviewLoading",2);g([m()],f.prototype,"filesPreviewBinary",2);g([m()],f.prototype,"filesPreviewSize",2);g([m()],f.prototype,"filesExpandedDirs",2);g([m()],f.prototype,"filesMessage",2);g([m()],f.prototype,"filesUploadBusy",2);g([m()],f.prototype,"filesReindexBusy",2);g([m()],f.prototype,"filesMemoryStatus",2);g([m()],f.prototype,"embeddingDownloading",2);g([m()],f.prototype,"filesSearchQuery",2);g([m()],f.prototype,"filesSearchResults",2);g([m()],f.prototype,"filesSearchLoading",2);g([m()],f.prototype,"filesSearchAgentId",2);g([m()],f.prototype,"auditEntries",2);g([m()],f.prototype,"auditLoading",2);g([m()],f.prototype,"auditModalOpen",2);g([m()],f.prototype,"skillsLoading",2);g([m()],f.prototype,"skillsReport",2);g([m()],f.prototype,"skillsError",2);g([m()],f.prototype,"skillsFilter",2);g([m()],f.prototype,"skillEdits",2);g([m()],f.prototype,"skillsBusyKey",2);g([m()],f.prototype,"skillMessages",2);g([m()],f.prototype,"adminsLoading",2);g([m()],f.prototype,"adminPhones",2);g([m()],f.prototype,"adminsError",2);g([m()],f.prototype,"adminsSaving",2);g([m()],f.prototype,"adminsNewPhone",2);g([m()],f.prototype,"customersLoading",2);g([m()],f.prototype,"customersSaving",2);g([m()],f.prototype,"customersRecords",2);g([m()],f.prototype,"customersError",2);g([m()],f.prototype,"customersSearchQuery",2);g([m()],f.prototype,"customersEditingId",2);g([m()],f.prototype,"customersShowAddForm",2);g([m()],f.prototype,"customersNewPhone",2);g([m()],f.prototype,"customersNewName",2);g([m()],f.prototype,"imessageEnableConfirm",2);g([m()],f.prototype,"imessageEnabling",2);g([m()],f.prototype,"infoModalOpen",2);g([m()],f.prototype,"workspaces",2);g([m()],f.prototype,"workspacesLoading",2);g([m()],f.prototype,"workspacesError",2);g([m()],f.prototype,"selectedWorkspace",2);g([m()],f.prototype,"addingWorkspace",2);g([m()],f.prototype,"newWorkspaceName",2);g([m()],f.prototype,"newWorkspacePath",2);g([m()],f.prototype,"newWorkspacePin",2);g([m()],f.prototype,"accountPinModalOpen",2);g([m()],f.prototype,"accountPinBusy",2);g([m()],f.prototype,"accountPinError",2);g([m()],f.prototype,"accountPinSuccess",2);g([m()],f.prototype,"apiKeyProviders",2);g([m()],f.prototype,"apiKeyModalOpen",2);g([m()],f.prototype,"apiKeyBusy",2);g([m()],f.prototype,"apiKeyError",2);g([m()],f.prototype,"apiKeySuccess",2);g([m()],f.prototype,"apiKeySavingProvider",2);g([m()],f.prototype,"authApiKeyMode",2);g([m()],f.prototype,"authApiKeyInput",2);g([m()],f.prototype,"authApiKeyBusy",2);g([m()],f.prototype,"authApiKeyError",2);g([m()],f.prototype,"pinChanging",2);g([m()],f.prototype,"pinChangeBusy",2);g([m()],f.prototype,"pinChangeError",2);g([m()],f.prototype,"loginChangePinMode",2);g([m()],f.prototype,"changePinBusy",2);g([m()],f.prototype,"changePinError",2);g([m()],f.prototype,"changePinSuccess",2);g([m()],f.prototype,"workspaceSaving",2);g([m()],f.prototype,"workspaceRemoveConfirm",2);g([m()],f.prototype,"renamingWorkspace",2);g([m()],f.prototype,"renameWorkspaceName",2);g([m()],f.prototype,"debugLoading",2);g([m()],f.prototype,"debugStatus",2);g([m()],f.prototype,"debugHealth",2);g([m()],f.prototype,"debugModels",2);g([m()],f.prototype,"debugHeartbeat",2);g([m()],f.prototype,"debugCallMethod",2);g([m()],f.prototype,"debugCallParams",2);g([m()],f.prototype,"debugCallResult",2);g([m()],f.prototype,"debugCallError",2);g([m()],f.prototype,"logsLoading",2);g([m()],f.prototype,"logsError",2);g([m()],f.prototype,"logsFile",2);g([m()],f.prototype,"logsEntries",2);g([m()],f.prototype,"logsFilterText",2);g([m()],f.prototype,"logsLevelFilters",2);g([m()],f.prototype,"logsAutoFollow",2);g([m()],f.prototype,"logsTruncated",2);g([m()],f.prototype,"logsCursor",2);g([m()],f.prototype,"logsLastFetchAt",2);g([m()],f.prototype,"logsLimit",2);g([m()],f.prototype,"logsMaxBytes",2);g([m()],f.prototype,"logsAtBottom",2);g([m()],f.prototype,"logsSubTab",2);g([m()],f.prototype,"sessionLogsLoading",2);g([m()],f.prototype,"sessionLogsError",2);g([m()],f.prototype,"sessionLogsEntries",2);g([m()],f.prototype,"sessionLogsFilterText",2);g([m()],f.prototype,"sessionLogsTypeFilters",2);g([m()],f.prototype,"sessionLogsAgentFilters",2);g([m()],f.prototype,"sessionLogsAgents",2);g([m()],f.prototype,"sessionLogsAutoFollow",2);g([m()],f.prototype,"sessionLogsCursors",2);g([m()],f.prototype,"sessionLogsLastFetchAt",2);g([m()],f.prototype,"sessionLogsAtBottom",2);g([m()],f.prototype,"chatUserNearBottom",2);f=g([ol("taskmaster-app")],f);
3212
- //# sourceMappingURL=index-lEyZ7hzB.js.map
3211
+ `,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.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={...$b},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=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.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.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.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.customersLoading=!1,this.customersSaving=!1,this.customersRecords=[],this.customersError=null,this.customersSearchQuery="",this.customersEditingId=null,this.customersShowAddForm=!1,this.customersNewPhone="",this.customersNewName="",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={...xb},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,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,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=()=>yh(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),Eb(this)}firstUpdated(){Cb(this)}disconnectedCallback(){this.stopEmbeddingPoll(),Tb(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){_b(this,e)}connect(){Ee(this)}handleChatScroll(e){Bd(this,e)}handleLogsScroll(e){Fd(this,e)}handleSessionLogsScroll(e){Ud(this,e)}exportLogs(e,t){Kd(e,t)}exportSessionLogs(e,t){zd(e,t)}resetToolStream(){ir(this)}resetChatScroll(){Wd(this)}async loadAssistantIdentity(){await Qs(this)}applySettings(e){ze(this,e)}setTab(e){uh(this,e)}setTheme(e,t){dh(this,e,t)}async loadOverview(){await rc(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 kr(this)}async handleAbortChat(){await ac(this)}removeQueuedMessage(e){kh(this,e)}async handleSendChat(e,t){await Sh(this,e,t)}async handleWhatsAppStart(e,t){await Pb(this,e,t)}async handleWhatsAppWait(e){await Lb(this,e)}async handleWhatsAppLogout(e){await Ib(this,e)}async handleAddWhatsAppAccount(e){await Rb(this,e)}async handleRemoveWhatsAppAccount(e){await Nb(this,e)}async handleAccessCheck(){await Qa(this)}async handlePinSubmit(e,t){await sb(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await rb(this,e)}async handleLogout(){await ab(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 Qa(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 Yb(this)}async handleLicenseActivate(){await Xb(this)}async handleLicenseRemove(){await Zb(this)}handleLicenseKeyChange(e){Jb(this,e)}async handleAuthStatusCheck(){await Hb(this)}async handleAuthStart(){await qb(this)}async handleAuthSubmitCode(e){await Vb(this,e)}handleAuthCodeChange(e){Gb(this,e)}handleSkipToWhatsApp(){Qb(this)}async handleGatewayHealthCheck(){await ew(this)}async handleGatewayRestart(){await tw(this)}async handleUpdateCheck(){await ou(this)}async handleUpdateRun(){await zv(this)}handleUpdateDismissResult(){qv(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 ie(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Ro);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){ie(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Ro);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await Zl(this)}async clearAudit(){await qp(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();yn(this,t),fr(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();ie(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>cb);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 t;const e=this.getSelectedWorkspaceInfo();if(e)return(t=e.agents[0])==null?void 0:t.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.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}ie(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>$s);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this)})}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"?ie(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>Xl);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):ie(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>rp);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&ie(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>Fp);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await Db(this)}async handleChannelConfigReload(){await Ob(this)}handleNostrProfileEdit(e,t){Fb(this,e,t)}handleNostrProfileCancel(){Ub(this)}handleNostrProfileFieldChange(e,t){Wb(this,e,t)}async handleNostrProfileSave(){await zb(this)}async handleNostrProfileImport(){await jb(this)}handleNostrProfileToggleAdvanced(){Kb(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)}handleCustomersLoad(){const e=this.selectedWorkspace??void 0;ie(async()=>{const{loadCustomers:t}=await Promise.resolve().then(()=>ub);return{loadCustomers:t}},void 0,import.meta.url).then(({loadCustomers:t})=>{t(this,e)})}handleCustomersNewPhoneChange(e){this.customersNewPhone=e,this.customersError&&(this.customersError=null)}handleCustomersNewNameChange(e){this.customersNewName=e,this.customersError&&(this.customersError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await ie(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>jn);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await ie(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>jn);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await ie(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>ep);return{loadChannels:s}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:s=>{if(!s.whatsappAccountId)return;const r=s.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await i(this,!0),await this.handleWhatsAppStart(!0,r),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(r),await i(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await ie(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>jn);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 ie(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>jn);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),ko(e),this.settings=qi(),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.customersPage?this.handleCustomersLoad():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)}ko(this.selectedWorkspace),this.settings=qi(),this.reloadCurrentPageData()}render(){return p`${kb(this)}${this.auditModalOpen?Ab(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):k}`}};g([m()],f.prototype,"settings",2);g([m()],f.prototype,"password",2);g([m()],f.prototype,"tab",2);g([m()],f.prototype,"onboarding",2);g([m()],f.prototype,"setup",2);g([m()],f.prototype,"filesPage",2);g([m()],f.prototype,"browserPage",2);g([m()],f.prototype,"adminsPage",2);g([m()],f.prototype,"customersPage",2);g([m()],f.prototype,"chatPage",2);g([m()],f.prototype,"advancedPage",2);g([m()],f.prototype,"advancedTab",2);g([m()],f.prototype,"publicChat",2);g([m()],f.prototype,"publicChatConfig",2);g([m()],f.prototype,"publicChatSessionKey",2);g([m()],f.prototype,"publicChatAuthenticated",2);g([m()],f.prototype,"publicChatAuthStep",2);g([m()],f.prototype,"connected",2);g([m()],f.prototype,"accessState",2);g([m()],f.prototype,"theme",2);g([m()],f.prototype,"themeResolved",2);g([m()],f.prototype,"hello",2);g([m()],f.prototype,"lastError",2);g([m()],f.prototype,"eventLog",2);g([m()],f.prototype,"assistantName",2);g([m()],f.prototype,"assistantAvatar",2);g([m()],f.prototype,"assistantAgentId",2);g([m()],f.prototype,"sessionKey",2);g([m()],f.prototype,"chatLoading",2);g([m()],f.prototype,"chatSending",2);g([m()],f.prototype,"chatMessage",2);g([m()],f.prototype,"chatMessages",2);g([m()],f.prototype,"chatToolMessages",2);g([m()],f.prototype,"chatStream",2);g([m()],f.prototype,"chatInterimText",2);g([m()],f.prototype,"chatSuggestion",2);g([m()],f.prototype,"chatStreamStartedAt",2);g([m()],f.prototype,"chatRunId",2);g([m()],f.prototype,"compactionStatus",2);g([m()],f.prototype,"chatAvatarUrl",2);g([m()],f.prototype,"chatThinkingLevel",2);g([m()],f.prototype,"chatModelProvider",2);g([m()],f.prototype,"chatModel",2);g([m()],f.prototype,"chatModelCatalog",2);g([m()],f.prototype,"chatVerboseLevel",2);g([m()],f.prototype,"chatFillerEnabled",2);g([m()],f.prototype,"chatQueue",2);g([m()],f.prototype,"chatAttachments",2);g([m()],f.prototype,"sidebarOpen",2);g([m()],f.prototype,"sidebarContent",2);g([m()],f.prototype,"sidebarError",2);g([m()],f.prototype,"splitRatio",2);g([m()],f.prototype,"nodesLoading",2);g([m()],f.prototype,"nodes",2);g([m()],f.prototype,"devicesLoading",2);g([m()],f.prototype,"devicesError",2);g([m()],f.prototype,"devicesList",2);g([m()],f.prototype,"execApprovalsLoading",2);g([m()],f.prototype,"execApprovalsSaving",2);g([m()],f.prototype,"execApprovalsDirty",2);g([m()],f.prototype,"execApprovalsSnapshot",2);g([m()],f.prototype,"execApprovalsForm",2);g([m()],f.prototype,"execApprovalsSelectedAgent",2);g([m()],f.prototype,"execApprovalsTarget",2);g([m()],f.prototype,"execApprovalsTargetNodeId",2);g([m()],f.prototype,"execApprovalQueue",2);g([m()],f.prototype,"execApprovalBusy",2);g([m()],f.prototype,"execApprovalError",2);g([m()],f.prototype,"configLoading",2);g([m()],f.prototype,"configRaw",2);g([m()],f.prototype,"configRawOriginal",2);g([m()],f.prototype,"configValid",2);g([m()],f.prototype,"configIssues",2);g([m()],f.prototype,"configSaving",2);g([m()],f.prototype,"configApplying",2);g([m()],f.prototype,"updateRunning",2);g([m()],f.prototype,"applySessionKey",2);g([m()],f.prototype,"configSnapshot",2);g([m()],f.prototype,"configSchema",2);g([m()],f.prototype,"configSchemaVersion",2);g([m()],f.prototype,"configSchemaLoading",2);g([m()],f.prototype,"configUiHints",2);g([m()],f.prototype,"configForm",2);g([m()],f.prototype,"configFormOriginal",2);g([m()],f.prototype,"configFormDirty",2);g([m()],f.prototype,"configFormMode",2);g([m()],f.prototype,"configSearchQuery",2);g([m()],f.prototype,"configActiveSection",2);g([m()],f.prototype,"configActiveSubsection",2);g([m()],f.prototype,"channelsLoading",2);g([m()],f.prototype,"channelsSnapshot",2);g([m()],f.prototype,"channelsError",2);g([m()],f.prototype,"channelsLastSuccess",2);g([m()],f.prototype,"whatsappLoginMessage",2);g([m()],f.prototype,"whatsappLoginQrDataUrl",2);g([m()],f.prototype,"whatsappLoginConnected",2);g([m()],f.prototype,"whatsappBusy",2);g([m()],f.prototype,"whatsappActiveQrAccountId",2);g([m()],f.prototype,"whatsappPairedPhone",2);g([m()],f.prototype,"addingWhatsAppAccount",2);g([m()],f.prototype,"newWhatsAppAccountName",2);g([m()],f.prototype,"whatsappAccountError",2);g([m()],f.prototype,"whatsappAccountSaving",2);g([m()],f.prototype,"whatsappSettingsOpen",2);g([m()],f.prototype,"publicChatToggleBusy",2);g([m()],f.prototype,"licenseKey",2);g([m()],f.prototype,"licenseBusy",2);g([m()],f.prototype,"licenseValid",2);g([m()],f.prototype,"licenseMessage",2);g([m()],f.prototype,"licenseTier",2);g([m()],f.prototype,"licenseDeviceId",2);g([m()],f.prototype,"licenseStoredKey",2);g([m()],f.prototype,"licenseRemoveConfirm",2);g([m()],f.prototype,"authConnected",2);g([m()],f.prototype,"authBusy",2);g([m()],f.prototype,"authMessage",2);g([m()],f.prototype,"authUrl",2);g([m()],f.prototype,"authCodeInput",2);g([m()],f.prototype,"authExpiresIn",2);g([m()],f.prototype,"setupStep",2);g([m()],f.prototype,"gatewayHealthy",2);g([m()],f.prototype,"gatewayHealthLoading",2);g([m()],f.prototype,"gatewayHealthMessage",2);g([m()],f.prototype,"gatewayRestartBusy",2);g([m()],f.prototype,"updateAvailable",2);g([m()],f.prototype,"currentVersion",2);g([m()],f.prototype,"latestVersion",2);g([m()],f.prototype,"updateChecking",2);g([m()],f.prototype,"updateMessage",2);g([m()],f.prototype,"updateProgressSteps",2);g([m()],f.prototype,"updateLastResult",2);g([m()],f.prototype,"uninstallConfirm",2);g([m()],f.prototype,"uninstallBusy",2);g([m()],f.prototype,"uninstallDone",2);g([m()],f.prototype,"uninstallError",2);g([m()],f.prototype,"uninstallConfirmText",2);g([m()],f.prototype,"nostrProfileFormState",2);g([m()],f.prototype,"nostrProfileAccountId",2);g([m()],f.prototype,"presenceLoading",2);g([m()],f.prototype,"presenceEntries",2);g([m()],f.prototype,"presenceError",2);g([m()],f.prototype,"presenceStatus",2);g([m()],f.prototype,"agentsLoading",2);g([m()],f.prototype,"agentsList",2);g([m()],f.prototype,"agentsError",2);g([m()],f.prototype,"sessionsLoading",2);g([m()],f.prototype,"sessionsResult",2);g([m()],f.prototype,"sessionsError",2);g([m()],f.prototype,"cronLoading",2);g([m()],f.prototype,"cronJobs",2);g([m()],f.prototype,"cronStatus",2);g([m()],f.prototype,"cronError",2);g([m()],f.prototype,"cronForm",2);g([m()],f.prototype,"cronRunsJobId",2);g([m()],f.prototype,"cronRuns",2);g([m()],f.prototype,"cronBusy",2);g([m()],f.prototype,"cronNewEventModal",2);g([m()],f.prototype,"cronDetailJobId",2);g([m()],f.prototype,"browserScreencastActive",2);g([m()],f.prototype,"browserScreencastFrame",2);g([m()],f.prototype,"browserScreencastMetadata",2);g([m()],f.prototype,"browserHandoffPending",2);g([m()],f.prototype,"browserHandoffReason",2);g([m()],f.prototype,"browserHandoffId",2);g([m()],f.prototype,"browserInputMode",2);g([m()],f.prototype,"browserFullscreen",2);g([m()],f.prototype,"browserLoading",2);g([m()],f.prototype,"browserError",2);g([m()],f.prototype,"filesLoading",2);g([m()],f.prototype,"filesTree",2);g([m()],f.prototype,"filesRoot",2);g([m()],f.prototype,"filesError",2);g([m()],f.prototype,"filesSelectedPath",2);g([m()],f.prototype,"filesSelectedPaths",2);g([m()],f.prototype,"filesPreviewContent",2);g([m()],f.prototype,"filesPreviewLoading",2);g([m()],f.prototype,"filesPreviewBinary",2);g([m()],f.prototype,"filesPreviewSize",2);g([m()],f.prototype,"filesExpandedDirs",2);g([m()],f.prototype,"filesMessage",2);g([m()],f.prototype,"filesUploadBusy",2);g([m()],f.prototype,"filesReindexBusy",2);g([m()],f.prototype,"filesMemoryStatus",2);g([m()],f.prototype,"embeddingDownloading",2);g([m()],f.prototype,"filesSearchQuery",2);g([m()],f.prototype,"filesSearchResults",2);g([m()],f.prototype,"filesSearchLoading",2);g([m()],f.prototype,"filesSearchAgentId",2);g([m()],f.prototype,"auditEntries",2);g([m()],f.prototype,"auditLoading",2);g([m()],f.prototype,"auditModalOpen",2);g([m()],f.prototype,"skillsLoading",2);g([m()],f.prototype,"skillsReport",2);g([m()],f.prototype,"skillsError",2);g([m()],f.prototype,"skillsFilter",2);g([m()],f.prototype,"skillEdits",2);g([m()],f.prototype,"skillsBusyKey",2);g([m()],f.prototype,"skillMessages",2);g([m()],f.prototype,"adminsLoading",2);g([m()],f.prototype,"adminPhones",2);g([m()],f.prototype,"adminsError",2);g([m()],f.prototype,"adminsSaving",2);g([m()],f.prototype,"adminsNewPhone",2);g([m()],f.prototype,"customersLoading",2);g([m()],f.prototype,"customersSaving",2);g([m()],f.prototype,"customersRecords",2);g([m()],f.prototype,"customersError",2);g([m()],f.prototype,"customersSearchQuery",2);g([m()],f.prototype,"customersEditingId",2);g([m()],f.prototype,"customersShowAddForm",2);g([m()],f.prototype,"customersNewPhone",2);g([m()],f.prototype,"customersNewName",2);g([m()],f.prototype,"imessageEnableConfirm",2);g([m()],f.prototype,"imessageEnabling",2);g([m()],f.prototype,"infoModalOpen",2);g([m()],f.prototype,"workspaces",2);g([m()],f.prototype,"workspacesLoading",2);g([m()],f.prototype,"workspacesError",2);g([m()],f.prototype,"selectedWorkspace",2);g([m()],f.prototype,"addingWorkspace",2);g([m()],f.prototype,"newWorkspaceName",2);g([m()],f.prototype,"newWorkspacePath",2);g([m()],f.prototype,"newWorkspacePin",2);g([m()],f.prototype,"accountPinModalOpen",2);g([m()],f.prototype,"accountPinBusy",2);g([m()],f.prototype,"accountPinError",2);g([m()],f.prototype,"accountPinSuccess",2);g([m()],f.prototype,"apiKeyProviders",2);g([m()],f.prototype,"apiKeyModalOpen",2);g([m()],f.prototype,"apiKeyBusy",2);g([m()],f.prototype,"apiKeyError",2);g([m()],f.prototype,"apiKeySuccess",2);g([m()],f.prototype,"apiKeySavingProvider",2);g([m()],f.prototype,"authApiKeyMode",2);g([m()],f.prototype,"authApiKeyInput",2);g([m()],f.prototype,"authApiKeyBusy",2);g([m()],f.prototype,"authApiKeyError",2);g([m()],f.prototype,"pinChanging",2);g([m()],f.prototype,"pinChangeBusy",2);g([m()],f.prototype,"pinChangeError",2);g([m()],f.prototype,"loginChangePinMode",2);g([m()],f.prototype,"changePinBusy",2);g([m()],f.prototype,"changePinError",2);g([m()],f.prototype,"changePinSuccess",2);g([m()],f.prototype,"workspaceSaving",2);g([m()],f.prototype,"workspaceRemoveConfirm",2);g([m()],f.prototype,"renamingWorkspace",2);g([m()],f.prototype,"renameWorkspaceName",2);g([m()],f.prototype,"debugLoading",2);g([m()],f.prototype,"debugStatus",2);g([m()],f.prototype,"debugHealth",2);g([m()],f.prototype,"debugModels",2);g([m()],f.prototype,"debugHeartbeat",2);g([m()],f.prototype,"debugCallMethod",2);g([m()],f.prototype,"debugCallParams",2);g([m()],f.prototype,"debugCallResult",2);g([m()],f.prototype,"debugCallError",2);g([m()],f.prototype,"logsLoading",2);g([m()],f.prototype,"logsError",2);g([m()],f.prototype,"logsFile",2);g([m()],f.prototype,"logsEntries",2);g([m()],f.prototype,"logsFilterText",2);g([m()],f.prototype,"logsLevelFilters",2);g([m()],f.prototype,"logsAutoFollow",2);g([m()],f.prototype,"logsTruncated",2);g([m()],f.prototype,"logsCursor",2);g([m()],f.prototype,"logsLastFetchAt",2);g([m()],f.prototype,"logsLimit",2);g([m()],f.prototype,"logsMaxBytes",2);g([m()],f.prototype,"logsAtBottom",2);g([m()],f.prototype,"logsSubTab",2);g([m()],f.prototype,"sessionLogsLoading",2);g([m()],f.prototype,"sessionLogsError",2);g([m()],f.prototype,"sessionLogsEntries",2);g([m()],f.prototype,"sessionLogsFilterText",2);g([m()],f.prototype,"sessionLogsTypeFilters",2);g([m()],f.prototype,"sessionLogsAgentFilters",2);g([m()],f.prototype,"sessionLogsAgents",2);g([m()],f.prototype,"sessionLogsAutoFollow",2);g([m()],f.prototype,"sessionLogsCursors",2);g([m()],f.prototype,"sessionLogsLastFetchAt",2);g([m()],f.prototype,"sessionLogsAtBottom",2);g([m()],f.prototype,"chatUserNearBottom",2);f=g([ol("taskmaster-app")],f);
3212
+ //# sourceMappingURL=index-DiwtIkvl.js.map