@rubytech/taskmaster 1.0.38 → 1.0.39

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.
@@ -0,0 +1,2890 @@
1
+ var nu=Object.defineProperty;var su=(e,t,n)=>t in e?nu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var B=(e,t,n)=>su(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(i){if(i.ep)return;i.ep=!0;const r=n(i);fetch(i.href,r)}})();const iu="modulepreload",ru=function(e,t){return new URL(e,t).href},Jr={},pe=function(t,n,s){let i=Promise.resolve();if(n&&n.length>0){let c=function(u){return Promise.all(u.map(p=>Promise.resolve(p).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const o=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=c(n.map(u=>{if(u=ru(u,s),u in Jr)return;Jr[u]=!0;const p=u.endsWith(".css"),d=p?'[rel="stylesheet"]':"";if(s)for(let b=o.length-1;b>=0;b--){const w=o[b];if(w.href===u&&(!p||w.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${d}`))return;const f=document.createElement("link");if(f.rel=p?"stylesheet":iu,p||(f.as="script"),f.crossOrigin="",f.href=u,l&&f.setAttribute("nonce",l),document.head.appendChild(f),p)return new Promise((b,w)=>{f.addEventListener("load",b),f.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${u}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return t().catch(r)})};const Wn=globalThis,zi=Wn.ShadowRoot&&(Wn.ShadyCSS===void 0||Wn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ji=Symbol(),eo=new WeakMap;let Ra=class{constructor(t,n,s){if(this._$cssResult$=!0,s!==ji)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(zi&&t===void 0){const s=n!==void 0&&n.length===1;s&&(t=eo.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&eo.set(n,t))}return t}toString(){return this.cssText}};const ou=e=>new Ra(typeof e=="string"?e:e+"",void 0,ji),au=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((s,i,r)=>s+(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.")})(i)+e[r+1],e[0]);return new Ra(n,e,ji)},lu=(e,t)=>{if(zi)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const s=document.createElement("style"),i=Wn.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=n.cssText,e.appendChild(s)}},to=zi?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const s of t.cssRules)n+=s.cssText;return ou(n)})(e):e;const{is:cu,defineProperty:uu,getOwnPropertyDescriptor:du,getOwnPropertyNames:pu,getOwnPropertySymbols:hu,getPrototypeOf:fu}=Object,De=globalThis,no=De.trustedTypes,gu=no?no.emptyScript:"",Ns=De.reactiveElementPolyfillSupport,Qt=(e,t)=>e,Gn={toAttribute(e,t){switch(t){case Boolean:e=e?gu: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}},Hi=(e,t)=>!cu(e,t),so={attribute:!0,type:String,converter:Gn,reflect:!1,useDefault:!1,hasChanged:Hi};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),De.litPropertyMetadata??(De.litPropertyMetadata=new WeakMap);let yt=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=so){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 s=Symbol(),i=this.getPropertyDescriptor(t,s,n);i!==void 0&&uu(this.prototype,t,i)}}static getPropertyDescriptor(t,n,s){const{get:i,set:r}=du(this.prototype,t)??{get(){return this[n]},set(o){this[n]=o}};return{get:i,set(o){const a=i==null?void 0:i.call(this);r==null||r.call(this,o),this.requestUpdate(t,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??so}static _$Ei(){if(this.hasOwnProperty(Qt("elementProperties")))return;const t=fu(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Qt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Qt("properties"))){const n=this.properties,s=[...pu(n),...hu(n)];for(const i of s)this.createProperty(i,n[i])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[s,i]of n)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[n,s]of this.elementProperties){const i=this._$Eu(n,s);i!==void 0&&this._$Eh.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)n.unshift(to(i))}else t!==void 0&&n.push(to(t));return n}static _$Eu(t,n){const s=n.attribute;return s===!1?void 0:typeof s=="string"?s: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 s of n.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return lu(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 s;return(s=n.hostConnected)==null?void 0:s.call(n)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(n=>{var s;return(s=n.hostDisconnected)==null?void 0:s.call(n)})}attributeChangedCallback(t,n,s){this._$AK(t,s)}_$ET(t,n){var r;const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const o=(((r=s.converter)==null?void 0:r.toAttribute)!==void 0?s.converter:Gn).toAttribute(n,s.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,n){var r,o;const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const a=s.getPropertyOptions(i),l=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)==null?void 0:r.fromAttribute)!==void 0?a.converter:Gn;this._$Em=i;const c=l.fromAttribute(n,a.type);this[i]=c??((o=this._$Ej)==null?void 0:o.get(i))??c,this._$Em=null}}requestUpdate(t,n,s,i=!1,r){var o;if(t!==void 0){const a=this.constructor;if(i===!1&&(r=this[t]),s??(s=a.getPropertyOptions(t)),!((s.hasChanged??Hi)(r,n)||s.useDefault&&s.reflect&&r===((o=this._$Ej)==null?void 0:o.get(t))&&!this.hasAttribute(a._$Eu(t,s))))return;this.C(t,n,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:s,reflect:i,wrapped:r},o){s&&!(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||s||(n=void 0),this._$AL.set(t,n)),i===!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 s;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 i=this.constructor.elementProperties;if(i.size>0)for(const[r,o]of i){const{wrapped:a}=o,l=this[r];a!==!0||this._$AL.has(r)||l===void 0||this.C(r,void 0,o,l)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),(s=this._$EO)==null||s.forEach(i=>{var r;return(r=i.hostUpdate)==null?void 0:r.call(i)}),this.update(n)):this._$EM()}catch(i){throw t=!1,this._$EM(),i}t&&this._$AE(n)}willUpdate(t){}_$AE(t){var n;(n=this._$EO)==null||n.forEach(s=>{var i;return(i=s.hostUpdated)==null?void 0:i.call(s)}),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){}};yt.elementStyles=[],yt.shadowRootOptions={mode:"open"},yt[Qt("elementProperties")]=new Map,yt[Qt("finalized")]=new Map,Ns==null||Ns({ReactiveElement:yt}),(De.reactiveElementVersions??(De.reactiveElementVersions=[])).push("2.1.2");const Xt=globalThis,io=e=>e,Vn=Xt.trustedTypes,ro=Vn?Vn.createPolicy("lit-html",{createHTML:e=>e}):void 0,Ia="$lit$",Ne=`lit$${Math.random().toFixed(9).slice(2)}$`,Na="?"+Ne,mu=`<${Na}>`,Je=document,sn=()=>Je.createComment(""),rn=e=>e===null||typeof e!="object"&&typeof e!="function",qi=Array.isArray,yu=e=>qi(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Ds=`[
2
+ \f\r]`,Dt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,oo=/-->/g,ao=/>/g,Ge=RegExp(`>|${Ds}(?:([^\\s"'>=/]+)(${Ds}*=${Ds}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),lo=/'/g,co=/"/g,Da=/^(?:script|style|textarea|title)$/i,vu=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),h=vu(1),Be=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),uo=new WeakMap,Qe=Je.createTreeWalker(Je,129);function Oa(e,t){if(!qi(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return ro!==void 0?ro.createHTML(t):t}const bu=(e,t)=>{const n=e.length-1,s=[];let i,r=t===2?"<svg>":t===3?"<math>":"",o=Dt;for(let a=0;a<n;a++){const l=e[a];let c,u,p=-1,d=0;for(;d<l.length&&(o.lastIndex=d,u=o.exec(l),u!==null);)d=o.lastIndex,o===Dt?u[1]==="!--"?o=oo:u[1]!==void 0?o=ao:u[2]!==void 0?(Da.test(u[2])&&(i=RegExp("</"+u[2],"g")),o=Ge):u[3]!==void 0&&(o=Ge):o===Ge?u[0]===">"?(o=i??Dt,p=-1):u[1]===void 0?p=-2:(p=o.lastIndex-u[2].length,c=u[1],o=u[3]===void 0?Ge:u[3]==='"'?co:lo):o===co||o===lo?o=Ge:o===oo||o===ao?o=Dt:(o=Ge,i=void 0);const f=o===Ge&&e[a+1].startsWith("/>")?" ":"";r+=o===Dt?l+mu:p>=0?(s.push(c),l.slice(0,p)+Ia+l.slice(p)+Ne+f):l+Ne+(p===-2?a:f)}return[Oa(e,r+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};let gi=class Ba{constructor({strings:t,_$litType$:n},s){let i;this.parts=[];let r=0,o=0;const a=t.length-1,l=this.parts,[c,u]=bu(t,n);if(this.el=Ba.createElement(c,s),Qe.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Qe.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(Ia)){const d=u[o++],f=i.getAttribute(p).split(Ne),b=/([.?@])?(.*)/.exec(d);l.push({type:1,index:r,name:b[2],strings:f,ctor:b[1]==="."?ku:b[1]==="?"?Su:b[1]==="@"?Au:ds}),i.removeAttribute(p)}else p.startsWith(Ne)&&(l.push({type:6,index:r}),i.removeAttribute(p));if(Da.test(i.tagName)){const p=i.textContent.split(Ne),d=p.length-1;if(d>0){i.textContent=Vn?Vn.emptyScript:"";for(let f=0;f<d;f++)i.append(p[f],sn()),Qe.nextNode(),l.push({type:2,index:++r});i.append(p[d],sn())}}}else if(i.nodeType===8)if(i.data===Na)l.push({type:2,index:r});else{let p=-1;for(;(p=i.data.indexOf(Ne,p+1))!==-1;)l.push({type:7,index:r}),p+=Ne.length-1}r++}}static createElement(t,n){const s=Je.createElement("template");return s.innerHTML=t,s}};function At(e,t,n=e,s){var o,a;if(t===Be)return t;let i=s!==void 0?(o=n._$Co)==null?void 0:o[s]:n._$Cl;const r=rn(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==r&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),r===void 0?i=void 0:(i=new r(e),i._$AT(e,n,s)),s!==void 0?(n._$Co??(n._$Co=[]))[s]=i:n._$Cl=i),i!==void 0&&(t=At(e,i._$AS(e,t.values),i,s)),t}class wu{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:s}=this._$AD,i=((t==null?void 0:t.creationScope)??Je).importNode(n,!0);Qe.currentNode=i;let r=Qe.nextNode(),o=0,a=0,l=s[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new us(r,r.nextSibling,this,t):l.type===1?c=new l.ctor(r,l.name,l.strings,this,t):l.type===6&&(c=new xu(r,this,t)),this._$AV.push(c),l=s[++a]}o!==(l==null?void 0:l.index)&&(r=Qe.nextNode(),o++)}return Qe.currentNode=Je,i}p(t){let n=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,n),n+=s.strings.length-2):s._$AI(t[n])),n++}}let us=class Fa{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,n,s,i){this.type=2,this._$AH=k,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=s,this.options=i,this._$Cv=(i==null?void 0:i.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=At(this,t,n),rn(t)?t===k||t==null||t===""?(this._$AH!==k&&this._$AR(),this._$AH=k):t!==this._$AH&&t!==Be&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):yu(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&&rn(this._$AH)?this._$AA.nextSibling.data=t:this.T(Je.createTextNode(t)),this._$AH=t}$(t){var r;const{values:n,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=gi.createElement(Oa(s.h,s.h[0]),this.options)),s);if(((r=this._$AH)==null?void 0:r._$AD)===i)this._$AH.p(n);else{const o=new wu(i,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(t){let n=uo.get(t.strings);return n===void 0&&uo.set(t.strings,n=new gi(t)),n}k(t){qi(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let s,i=0;for(const r of t)i===n.length?n.push(s=new Fa(this.O(sn()),this.O(sn()),this,this.options)):s=n[i],s._$AI(r),i++;i<n.length&&(this._$AR(s&&s._$AB.nextSibling,i),n.length=i)}_$AR(t=this._$AA.nextSibling,n){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,n);t!==this._$AB;){const i=io(t).nextSibling;io(t).remove(),t=i}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class ds{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,s,i,r){this.type=1,this._$AH=k,this._$AN=void 0,this.element=t,this.name=n,this._$AM=i,this.options=r,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=k}_$AI(t,n=this,s,i){const r=this.strings;let o=!1;if(r===void 0)t=At(this,t,n,0),o=!rn(t)||t!==this._$AH&&t!==Be,o&&(this._$AH=t);else{const a=t;let l,c;for(t=r[0],l=0;l<r.length-1;l++)c=At(this,a[s+l],n,l),c===Be&&(c=this._$AH[l]),o||(o=!rn(c)||c!==this._$AH[l]),c===k?t=k:t!==k&&(t+=(c??"")+r[l+1]),this._$AH[l]=c}o&&!i&&this.j(t)}j(t){t===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let ku=class extends ds{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===k?void 0:t}},Su=class extends ds{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==k)}},Au=class extends ds{constructor(t,n,s,i,r){super(t,n,s,i,r),this.type=5}_$AI(t,n=this){if((t=At(this,t,n,0)??k)===Be)return;const s=this._$AH,i=t===k&&s!==k||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==k&&(s===k||i);i&&this.element.removeEventListener(this.name,this,s),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)}},xu=class{constructor(t,n,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){At(this,t)}};const $u={I:us},Os=Xt.litHtmlPolyfillSupport;Os==null||Os(gi,us),(Xt.litHtmlVersions??(Xt.litHtmlVersions=[])).push("3.3.2");const Eu=(e,t,n)=>{const s=(n==null?void 0:n.renderBefore)??t;let i=s._$litPart$;if(i===void 0){const r=(n==null?void 0:n.renderBefore)??null;s._$litPart$=i=new us(t.insertBefore(sn(),r),r,void 0,n??{})}return i._$AI(e),i};const Ze=globalThis;let kt=class extends yt{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=Eu(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 Be}};var Pa;kt._$litElement$=!0,kt.finalized=!0,(Pa=Ze.litElementHydrateSupport)==null||Pa.call(Ze,{LitElement:kt});const Bs=Ze.litElementPolyfillSupport;Bs==null||Bs({LitElement:kt});(Ze.litElementVersions??(Ze.litElementVersions=[])).push("4.2.2");const Ua=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const Tu={attribute:!0,type:String,converter:Gn,reflect:!1,hasChanged:Hi},Cu=(e=Tu,t,n)=>{const{kind:s,metadata:i}=n;let r=globalThis.litPropertyMetadata.get(i);if(r===void 0&&globalThis.litPropertyMetadata.set(i,r=new Map),s==="setter"&&((e=Object.create(e)).wrapped=!0),r.set(n.name,e),s==="accessor"){const{name:o}=n;return{set(a){const l=t.get.call(this);t.set.call(this,a),this.requestUpdate(o,l,e,!0,a)},init(a){return a!==void 0&&this.C(o,void 0,e,a),a}}}if(s==="setter"){const{name:o}=n;return function(a){const l=this[o];t.call(this,a),this.requestUpdate(o,l,e,!0,a)}}throw Error("Unsupported decorator location: "+s)};function ps(e){return(t,n)=>typeof n=="object"?Cu(e,t,n):((s,i,r)=>{const o=i.hasOwnProperty(r);return i.constructor.createProperty(r,s),o?Object.getOwnPropertyDescriptor(i,r):void 0})(e,t,n)}function y(e){return ps({...e,state:!0,attribute:!1})}const _u=50,Mu=200,Lu="Assistant";function po(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function mi(e){const t=po(e==null?void 0:e.name,_u)??Lu,n=po((e==null?void 0:e.avatar)??void 0,Mu)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function Pu(){return mi(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Yn="taskmaster.control.settings.v1",Wa="taskmaster.account.settings.";function Zt(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const mt={gatewayUrl:Zt(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},Ie={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function Ru(){try{const e=localStorage.getItem(Yn);if(!e)return{...mt,gatewayUrl:Zt()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():Zt(),token:typeof t.token=="string"?t.token:mt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:mt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:mt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:mt.navGroupsCollapsed}}catch{return{...mt,gatewayUrl:Zt()}}}function Iu(e){if(!e)return{...Ie};try{const t=localStorage.getItem(Wa+e);if(!t)return{...Ie};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():Ie.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||Ie.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:Ie.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:Ie.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:Ie.splitRatio}}catch{return{...Ie}}}let Qn=null;function ho(e){Qn=e}function Fs(){return{...Ru(),...Iu(Qn)}}function Nu(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Yn,JSON.stringify(t)),Qn){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Wa+Qn,JSON.stringify(n))}}(function(){try{const t=localStorage.getItem(Yn);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const s={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:Zt(),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(Yn,JSON.stringify(s))}catch{}})();function Ka(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 s=(r=n[1])==null?void 0:r.trim(),i=n.slice(2).join(":");return!s||!i?null:{agentId:s,rest:i}}const Du=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,En=/<\s*\/?\s*final\b[^>]*>/gi,fo=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Ou(e,t){return e.trimStart()}function Bu(e,t){if(!e||!Du.test(e))return e;let n=e;En.test(n)?(En.lastIndex=0,n=n.replace(En,"")):En.lastIndex=0,fo.lastIndex=0;let s="",i=0,r=!1;for(const o of n.matchAll(fo)){const a=o.index??0,l=o[1]==="/";r?l&&(r=!1):(s+=n.slice(i,a),l||(r=!0)),i=a+o[0].length}return s+=n.slice(i),Ou(s)}function za(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString()}function hs(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0)return"just now";const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const s=Math.round(n/60);if(s<60)return`${s}m ago`;const i=Math.round(s/60);return i<48?`${i}h ago`:`${Math.round(i/24)}d ago`}function ja(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 s=Math.round(n/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function Fu(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Ha(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 Xn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Us(e){return Bu(e)}const Uu=/^\[([^\]]+)\]\s*/,Wu=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Ws=new WeakMap,Ks=new WeakMap;function Ku(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:Wu.some(t=>e.startsWith(`${t} `))}function zs(e){const t=e.match(Uu);if(!t)return e;const n=t[1]??"";return Ku(n)?e.slice(t[0].length):e}function Zn(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?Us(s):zs(s);if(Array.isArray(s)){const i=s.map(r=>{const o=r;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(r=>typeof r=="string");if(i.length>0){const r=i.join(`
4
+ `);return n==="assistant"?Us(r):zs(r)}}return typeof t.text=="string"?n==="assistant"?Us(t.text):zs(t.text):null}function qa(e){if(!e||typeof e!="object")return Zn(e);const t=e;if(Ws.has(t))return Ws.get(t)??null;const n=Zn(e);return Ws.set(t,n),n}function go(e){const n=e.content,s=[];if(Array.isArray(n))for(const a of n){const l=a;if(l.type==="thinking"&&typeof l.thinking=="string"){const c=l.thinking.trim();c&&s.push(c)}}if(s.length>0)return s.join(`
5
+ `);const i=ju(e);if(!i)return null;const o=[...i.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 zu(e){if(!e||typeof e!="object")return go(e);const t=e;if(Ks.has(t))return Ks.get(t)??null;const n=go(e);return Ks.set(t,n),n}function ju(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const s=n.map(i=>{const r=i;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(i=>typeof i=="string");if(s.length>0)return s.join(`
7
+ `)}return typeof t.text=="string"?t.text:null}function Hu(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean).map(s=>`_${s}_`);return n.length?["_Reasoning:_",...n].join(`
8
+ `):""}const qu=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Gu=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Vu=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Yu=/^A new session was started via \/new or \/reset\./;function Qu(e){const t=e,n=typeof t.role=="string"?t.role:"";let s="";typeof t.content=="string"?s=t.content:Array.isArray(t.content)?s=t.content.filter(r=>typeof r=="object"&&r!==null).map(r=>r.text??"").join(" "):typeof t.text=="string"&&(s=t.text);const i=s.trim();return i?!!(n==="user"&&qu.test(i)||n==="assistant"&&Gu.test(i)||n==="user"&&Yu.test(i)||n==="assistant"&&Vu.test(i)):!1}function Xu(e){return e.filter(t=>!Qu(t))}function Ga(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const s=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",i=t.content,r=Array.isArray(i)?i:null,o=Array.isArray(r)&&r.some(p=>{const f=String(p.type??"").toLowerCase();return f==="toolresult"||f==="tool_result"}),a=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||a)&&(n="toolResult");let l=[];typeof t.content=="string"?l=[{type:"text",text:t.content}]:Array.isArray(t.content)?l=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(l=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),u=typeof t.id=="string"?t.id:void 0;return{role:n,content:l,timestamp:c,id:u}}function Va(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 Ya(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function mo(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 Zu(){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 Gi(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),mo(t)}return mo(Zu())}async function Me(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:200}),n=Array.isArray(t.messages)?t.messages:[];e.chatMessages=Xu(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 Ju(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function Qa(e,t,n){if(!e.client||!e.connected)return!1;const s=t.trim(),i=n&&n.length>0;if(!s&&!i)return!1;const r=Date.now(),o=(n??[]).filter(f=>!f.fileName),a=(n??[]).filter(f=>f.fileName),l=[],c=a.map(f=>f.fileName).filter(Boolean);if(c.length>0){const f=s?`${c.join(", ")}
9
+
10
+ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text:s});for(const f of o)l.push({type:"image",source:{type:"base64",media_type:f.mimeType,data:f.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:l,timestamp:r}],e.chatSending=!0,e.lastError=null;const u=Gi();e.chatRunId=u,e.chatStream="",e.chatStreamStartedAt=r;const p=[...o,...a],d=p.length>0?p.map(f=>{if(f.textContent)return{type:"document",mimeType:f.mimeType||"text/plain",fileName:f.fileName,content:btoa(unescape(encodeURIComponent(f.textContent)))};const b=Ju(f.dataUrl);return b?{type:f.fileName?"document":"image",mimeType:b.mimeType,fileName:f.fileName,content:b.content}:null}).filter(f=>f!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:s,deliver:!1,idempotencyKey:u,attachments:d}),!0}catch(f){const b=String(f);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=b,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+b}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function Xa(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 Za(e,t){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==="block"){const n=Zn(t.message);return typeof n=="string"&&n.trim()&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:n.trim()}],timestamp:Date.now(),filler:!0}]),"block"}else if(t.state==="delta"){const n=Zn(t.message);if(typeof n=="string"){if(n.trim()==="NO_REPLY")return null;const s=e.chatStream??"";(!s||n.length>=s.length)&&(e.chatStream=n)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.lastError=t.errorMessage??"chat error");return t.state}const ed=Object.freeze(Object.defineProperty({__proto__:null,abortChatRun:Xa,handleChatEvent:Za,loadChatHistory:Me,sendChatMessage:Qa},Symbol.toStringTag,{value:"Module"}));async function Vi(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=Xn(e.sessionsFilterActive??"",0),s=Xn(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),s>0&&(t.limit=s);const i=await e.client.request("sessions.list",t);i&&(e.sessionsResult=i)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function Tn(e,t,n){if(!e.client||!e.connected)return;const s={key:t};"label"in n&&(s.label=n.label),"thinkingLevel"in n&&(s.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(s.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(s.reasoningLevel=n.reasoningLevel),"model"in n&&(s.model=n.model),"fillerEnabled"in n&&(s.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",s),await Vi(e)}catch(i){e.sessionsError=String(i)}}const yo=50,td=80,nd=12e4;function sd(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 s=n.map(i=>{if(!i||typeof i!="object")return null;const r=i;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(i=>!!i);return s.length===0?null:s.join(`
11
+ `)}function vo(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=sd(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 s=Ha(n,nd);return s.truncated?`${s.text}
12
+
13
+ … truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function id(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 rd(e){if(e.toolStreamOrder.length<=yo)return;const t=e.toolStreamOrder.length-yo,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function od(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function yi(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),od(e)}function ad(e,t=!1){if(t){yi(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>yi(e),td))}function Yi(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],yi(e)}const ld=5e3;function cd(e,t){var i;const n=t.data??{},s=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),s==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:s==="end"&&(e.compactionStatus={active:!1,startedAt:((i=e.compactionStatus)==null?void 0:i.startedAt)??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},ld))}function ud(e,t){if(!t)return;if(t.stream==="compaction"){cd(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 s=t.data??{},i=typeof s.toolCallId=="string"?s.toolCallId:"";if(!i)return;const r=typeof s.name=="string"?s.name:"tool",o=typeof s.phase=="string"?s.phase:"",a=o==="start"?s.args:void 0,l=o==="update"?vo(s.partialResult):o==="result"?vo(s.result):void 0,c=Date.now();let u=e.toolStreamById.get(i);u?(u.name=r,a!==void 0&&(u.args=a),l!==void 0&&(u.output=l),u.updatedAt=c):(u={toolCallId:i,runId:t.runId,sessionKey:n,name:r,args:a,output:l,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(i,u),e.toolStreamOrder.push(i)),u.message=id(u),rd(e),ad(e,o==="result")}function ln(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=()=>{const s=e.querySelector(".chat-thread");if(s){const i=getComputedStyle(s).overflowY;if(i==="auto"||i==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;const s=n();if(!s)return;const i=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||i<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const o=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;const a=n();if(!a)return;const l=a.scrollHeight-a.scrollTop-a.clientHeight;(t||e.chatUserNearBottom||l<200)&&(a.scrollTop=a.scrollHeight,e.chatUserNearBottom=!0)},o)})})}function Ja(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 dd(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<200}function pd(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function hd(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function fd(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function gd(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
14
+ `)}
15
+ `],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),r=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`taskmaster-logs-${t}-${r}.log`,i.click(),URL.revokeObjectURL(s)}function md(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
16
+ `)}
17
+ `],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),r=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`taskmaster-session-logs-${t}-${r}.log`,i.click(),URL.revokeObjectURL(s)}function yd(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:s}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${s}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function Fe(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function et(e){return`${JSON.stringify(e,null,2).trimEnd()}
18
+ `}function el(e,t,n){if(t.length===0)return;let s=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(s))return;s[o]==null&&(s[o]=typeof a=="number"?[]:{}),s=s[o]}else{if(typeof s!="object"||s==null)return;const l=s;l[o]==null&&(l[o]=typeof a=="number"?[]:{}),s=l[o]}}const i=t[t.length-1];if(typeof i=="number"){Array.isArray(s)&&(s[i]=n);return}typeof s=="object"&&s!=null&&(s[i]=n)}async function Ae(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});bd(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function tl(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});vd(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function vd(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function bd(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?et(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=et(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=Fe(t.config??{}),e.configFormOriginal=Fe(t.config??{}),e.configRawOriginal=n)}async function wd(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?et(e.configForm):e.configRaw,s=(t=e.configSnapshot)==null?void 0:t.hash;if(!s){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:n,baseHash:s}),e.configFormDirty=!1,await Ae(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function cn(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 fs(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 kd(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=Xn(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const s=e.everyUnit;return{kind:"every",everyMs:n*(s==="minutes"?6e4:s==="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 Sd(e){if(e.payloadKind==="systemEvent"){const i=e.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}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 s=Xn(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function Ad(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=kd(e.cronForm),s=Sd(e.cronForm),i=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:i||void 0,accountId:r||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:s,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 fs(e),await cn(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 fs(e),await cn(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function $d(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 vi(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Ed(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 fs(e),await cn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function vi(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 q(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 Qi(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const s=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=s.message??null,e.whatsappLoginQrDataUrl=s.qrDataUrl??null,e.whatsappLoginConnected=null}catch(s){e.whatsappLoginMessage=String(s),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function nl(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 sl(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 il(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const s=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!s){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const r=Fe(i.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 l=a.accounts;if(l[s]){e.whatsappAccountError=`Account "${s}" already exists.`;return}l[s]={name:n,provider:"baileys"};const c=i.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const u=et(r);await e.client.request("config.set",{raw:u,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await q(e,!0),await Qi(e,!0,s)}catch(i){e.whatsappAccountError=String(i)}finally{e.whatsappAccountSaving=!1}}async function rl(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 s=Fe(n.config??{}),i=s.channels,r=i==null?void 0:i.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(s.bindings)&&(s.bindings=s.bindings.filter(u=>{const p=u.match;return!p||p.channel!=="whatsapp"?!0:p.accountId!==t}));const l=n.hash;if(!l){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=et(s);await e.client.request("config.set",{raw:c,baseHash:l}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await q(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Td=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:il,loadChannels:q,logoutWhatsApp:sl,removeWhatsAppAccount:rl,startWhatsAppLogin:Qi,waitWhatsAppLogin:nl},Symbol.toStringTag,{value:"Module"}));async function Xi(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,s,i]=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=s;e.debugModels=Array.isArray(r==null?void 0:r.models)?r==null?void 0:r.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const Cd=2e3,_d=new Set(["trace","debug","info","warn","error","fatal"]);function Md(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 Ld(e){if(typeof e!="string")return null;const t=e.toLowerCase();return _d.has(t)?t:null}function Pd(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,s=typeof t.time=="string"?t.time:typeof(n==null?void 0:n.date)=="string"?n==null?void 0:n.date:null,i=Ld((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=Md(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 l=null;return typeof t[1]=="string"?l=t[1]:!o&&typeof t[0]=="string"?l=t[0]:typeof t.message=="string"&&(l=t.message),{raw:e,time:s,level:i,subsystem:a,message:l??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Jt(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 s=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(s.lines)?s.lines.filter(a=>typeof a=="string"):[]).map(Pd),o=!!(t!=null&&t.reset||s.reset||e.logsCursor==null);e.logsEntries=o?r:[...e.logsEntries,...r].slice(-Cd),typeof s.cursor=="number"&&(e.logsCursor=s.cursor),typeof s.file=="string"&&(e.logsFile=s.file),e.logsTruncated=!!s.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const ol={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:se,n:Kn,Gx:bo,Gy:wo,a:js,d:Hs,h:Rd}=ol,tt=32,Zi=64,Id=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},Z=(e="")=>{const t=new Error(e);throw Id(t,Z),t},Nd=e=>typeof e=="bigint",Dd=e=>typeof e=="string",Od=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",We=(e,t,n="")=>{const s=Od(e),i=e==null?void 0:e.length,r=t!==void 0;if(!s||r&&i!==t){const o=n&&`"${n}" `,a=r?` of length ${t}`:"",l=s?`length=${i}`:`type=${typeof e}`;Z(o+"expected Uint8Array"+a+", got "+l)}return e},gs=e=>new Uint8Array(e),al=e=>Uint8Array.from(e),ll=(e,t)=>e.toString(16).padStart(t,"0"),cl=e=>Array.from(We(e)).map(t=>ll(t,2)).join(""),Te={_0:48,_9:57,A:65,F:70,a:97,f:102},ko=e=>{if(e>=Te._0&&e<=Te._9)return e-Te._0;if(e>=Te.A&&e<=Te.F)return e-(Te.A-10);if(e>=Te.a&&e<=Te.f)return e-(Te.a-10)},ul=e=>{const t="hex invalid";if(!Dd(e))return Z(t);const n=e.length,s=n/2;if(n%2)return Z(t);const i=gs(s);for(let r=0,o=0;r<s;r++,o+=2){const a=ko(e.charCodeAt(o)),l=ko(e.charCodeAt(o+1));if(a===void 0||l===void 0)return Z(t);i[r]=a*16+l}return i},dl=()=>globalThis==null?void 0:globalThis.crypto,Bd=()=>{var e;return((e=dl())==null?void 0:e.subtle)??Z("crypto.subtle must be defined, consider polyfill")},on=(...e)=>{const t=gs(e.reduce((s,i)=>s+We(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},Fd=(e=tt)=>dl().getRandomValues(gs(e)),Jn=BigInt,Ye=(e,t,n,s="bad number: out of range")=>Nd(e)&&t<=e&&e<n?e:Z(s),M=(e,t=se)=>{const n=e%t;return n>=0n?n:t+n},pl=e=>M(e,Kn),Ud=(e,t)=>{(e===0n||t<=0n)&&Z("no inverse n="+e+" mod="+t);let n=M(e,t),s=t,i=0n,r=1n;for(;n!==0n;){const o=s/n,a=s%n,l=i-r*o;s=n,n=a,i=r,r=l}return s===1n?M(i,t):Z("no inverse")},Wd=e=>{const t=ml[e];return typeof t!="function"&&Z("hashes."+e+" not set"),t},qs=e=>e instanceof nt?e:Z("Point expected"),bi=2n**256n,Se=class Se{constructor(t,n,s,i){B(this,"X");B(this,"Y");B(this,"Z");B(this,"T");const r=bi;this.X=Ye(t,0n,r),this.Y=Ye(n,0n,r),this.Z=Ye(s,1n,r),this.T=Ye(i,0n,r),Object.freeze(this)}static CURVE(){return ol}static fromAffine(t){return new Se(t.x,t.y,1n,M(t.x*t.y))}static fromBytes(t,n=!1){const s=Hs,i=al(We(t,tt)),r=t[31];i[31]=r&-129;const o=fl(i);Ye(o,0n,n?bi:se);const l=M(o*o),c=M(l-1n),u=M(s*l+1n);let{isValid:p,value:d}=zd(c,u);p||Z("bad point: y not sqrt");const f=(d&1n)===1n,b=(r&128)!==0;return!n&&d===0n&&b&&Z("bad point: x==0, isLastByteOdd"),b!==f&&(d=M(-d)),new Se(d,o,1n,M(d*o))}static fromHex(t,n){return Se.fromBytes(ul(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=js,n=Hs,s=this;if(s.is0())return Z("bad point: ZERO");const{X:i,Y:r,Z:o,T:a}=s,l=M(i*i),c=M(r*r),u=M(o*o),p=M(u*u),d=M(l*t),f=M(u*M(d+c)),b=M(p+M(n*M(l*c)));if(f!==b)return Z("bad point: equation left != right (1)");const w=M(i*r),A=M(o*a);return w!==A?Z("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:r,Y:o,Z:a}=qs(t),l=M(n*a),c=M(r*i),u=M(s*a),p=M(o*i);return l===c&&u===p}is0(){return this.equals(bt)}negate(){return new Se(M(-this.X),this.Y,this.Z,M(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=js,r=M(t*t),o=M(n*n),a=M(2n*M(s*s)),l=M(i*r),c=t+n,u=M(M(c*c)-r-o),p=l+o,d=p-a,f=l-o,b=M(u*d),w=M(p*f),A=M(u*f),T=M(d*p);return new Se(b,w,T,A)}add(t){const{X:n,Y:s,Z:i,T:r}=this,{X:o,Y:a,Z:l,T:c}=qs(t),u=js,p=Hs,d=M(n*o),f=M(s*a),b=M(r*p*c),w=M(i*l),A=M((n+s)*(o+a)-d-f),T=M(w-b),x=M(w+b),E=M(f-u*d),C=M(A*T),R=M(x*E),U=M(A*E),Y=M(T*x);return new Se(C,R,Y,U)}subtract(t){return this.add(qs(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return bt;if(Ye(t,1n,Kn),t===1n)return this;if(this.equals(st))return ep(t).p;let s=bt,i=st;for(let r=this;t>0n;r=r.double(),t>>=1n)t&1n?s=s.add(r):n&&(i=i.add(r));return s}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:s}=this;if(this.equals(bt))return{x:0n,y:1n};const i=Ud(s,se);M(s*i)!==1n&&Z("invalid inverse");const r=M(t*i),o=M(n*i);return{x:r,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=hl(n);return s[31]|=t&1n?128:0,s}toHex(){return cl(this.toBytes())}clearCofactor(){return this.multiply(Jn(Rd),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Kn/2n,!1).double();return Kn%2n&&(t=t.add(this)),t.is0()}};B(Se,"BASE"),B(Se,"ZERO");let nt=Se;const st=new nt(bo,wo,1n,M(bo*wo)),bt=new nt(0n,1n,1n,0n);nt.BASE=st;nt.ZERO=bt;const hl=e=>ul(ll(Ye(e,0n,bi),Zi)).reverse(),fl=e=>Jn("0x"+cl(al(We(e)).reverse())),be=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=se;return n},Kd=e=>{const n=e*e%se*e%se,s=be(n,2n)*n%se,i=be(s,1n)*e%se,r=be(i,5n)*i%se,o=be(r,10n)*r%se,a=be(o,20n)*o%se,l=be(a,40n)*a%se,c=be(l,80n)*l%se,u=be(c,80n)*l%se,p=be(u,10n)*r%se;return{pow_p_5_8:be(p,2n)*e%se,b2:n}},So=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,zd=(e,t)=>{const n=M(t*t*t),s=M(n*n*t),i=Kd(e*s).pow_p_5_8;let r=M(e*n*i);const o=M(t*r*r),a=r,l=M(r*So),c=o===e,u=o===M(-e),p=o===M(-e*So);return c&&(r=a),(u||p)&&(r=l),(M(r)&1n)===1n&&(r=M(-r)),{isValid:c||u,value:r}},wi=e=>pl(fl(e)),Ji=(...e)=>ml.sha512Async(on(...e)),jd=(...e)=>Wd("sha512")(on(...e)),gl=e=>{const t=e.slice(0,tt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(tt,Zi),s=wi(t),i=st.multiply(s),r=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:r}},er=e=>Ji(We(e,tt)).then(gl),Hd=e=>gl(jd(We(e,tt))),qd=e=>er(e).then(t=>t.pointBytes),Gd=e=>Ji(e.hashable).then(e.finish),Vd=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,r=wi(t),o=st.multiply(r).toBytes();return{hashable:on(o,s,n),finish:c=>{const u=pl(r+wi(c)*i);return We(on(o,hl(u)),Zi)}}},Yd=async(e,t)=>{const n=We(e),s=await er(t),i=await Ji(s.prefix,n);return Gd(Vd(s,i,n))},ml={sha512Async:async e=>{const t=Bd(),n=on(e);return gs(await t.digest("SHA-512",n.buffer))},sha512:void 0},Qd=(e=Fd(tt))=>e,Xd={getExtendedPublicKeyAsync:er,getExtendedPublicKey:Hd,randomSecretKey:Qd},es=8,Zd=256,yl=Math.ceil(Zd/es)+1,ki=2**(es-1),Jd=()=>{const e=[];let t=st,n=t;for(let s=0;s<yl;s++){n=t,e.push(n);for(let i=1;i<ki;i++)n=n.add(t),e.push(n);t=n.double()}return e};let Ao;const xo=(e,t)=>{const n=t.negate();return e?n:t},ep=e=>{const t=Ao||(Ao=Jd());let n=bt,s=st;const i=2**es,r=i,o=Jn(i-1),a=Jn(es);for(let l=0;l<yl;l++){let c=Number(e&o);e>>=a,c>ki&&(c-=r,e+=1n);const u=l*ki,p=u,d=u+Math.abs(c)-1,f=l%2!==0,b=c<0;c===0?s=s.add(xo(f,t[p])):n=n.add(xo(b,t[d]))}return e!==0n&&Z("invalid wnaf"),{p:n,f:s}},Gs="taskmaster-device-identity-v1";function Si(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vl(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),s=atob(n),i=new Uint8Array(s.length);for(let r=0;r<s.length;r+=1)i[r]=s.charCodeAt(r);return i}function tp(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function bl(e){const t=await crypto.subtle.digest("SHA-256",e);return tp(new Uint8Array(t))}async function np(){const e=Xd.randomSecretKey(),t=await qd(e);return{deviceId:await bl(t),publicKey:Si(t),privateKey:Si(e)}}async function sp(){try{const n=localStorage.getItem(Gs);if(n){const s=JSON.parse(n);if((s==null?void 0:s.version)===1&&typeof s.deviceId=="string"&&typeof s.publicKey=="string"&&typeof s.privateKey=="string"){const i=await bl(vl(s.publicKey));if(i!==s.deviceId){const r={...s,deviceId:i};return localStorage.setItem(Gs,JSON.stringify(r)),{deviceId:i,publicKey:s.publicKey,privateKey:s.privateKey}}return{deviceId:s.deviceId,publicKey:s.publicKey,privateKey:s.privateKey}}}}catch{}const e=await np(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Gs,JSON.stringify(t)),e}async function ip(e,t){const n=vl(e),s=new TextEncoder().encode(t),i=await Yd(s,n);return Si(i)}const wl="taskmaster.device.auth.v1";function tr(e){return e.trim()}function rp(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const s=n.trim();s&&t.add(s)}return[...t].sort()}function nr(){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 op(e){const t=nr();if(!t||t.deviceId!==e.deviceId)return null;const n=tr(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function ap(e){const t=tr(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=nr();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:rp(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,kl(n),i}function lp(e){const t=nr();if(!t||t.deviceId!==e.deviceId)return;const n=tr(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],kl(s)}async function sr(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 ir(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 cp(e){return{method:"exec.approvals.get",params:{}}}async function up(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=cp(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);dp(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function dp(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=Fe(t.file??{}))}async function Sl(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 xt(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function ms(e){return e instanceof Error?e.message:String(e)}async function $t(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=ms(n)}finally{e.skillsLoading=!1}}}function pp(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function hp(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 $t(e),xt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=ms(s);e.skillsError=i,xt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function fp(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 $t(e),xt(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=ms(n);e.skillsError=s,xt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function gp(e,t,n,s){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.install",{name:n,installId:s,timeoutMs:12e4});await $t(e),xt(e,t,{kind:"success",message:(i==null?void 0:i.message)??"Installed"})}catch(i){const r=ms(i);e.skillsError=r,xt(e,t,{kind:"error",message:r})}finally{e.skillsBusyKey=null}}}const Al={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},xl=new Map(Object.entries(Al).map(([e,t])=>[t,e]));function ys(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function an(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 mp(e,t=""){const n=ys(t),s=Al[e];return n?`${n}${s}`:s}function $l(e,t=""){const n=ys(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=an(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":xl.get(i)??null}function yp(e){let t=an(e);if(t.endsWith("/index.html")&&(t=an(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let s=0;s<n.length;s++){const i=`/${n.slice(s).join("/")}`.toLowerCase();if(xl.has(i)){const r=n.slice(0,s);return r.length?`/${r.join("/")}`:""}}return`/${n.join("/")}`}function vp(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function rr(e){return e==="system"?vp():e}const Cn=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,bp=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,_n=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},wp=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{var c;if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const r=i.documentElement,o=i,a=bp();if(!!o.startViewTransition&&!a){let u=.5,p=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")u=Cn(n.pointerClientX/window.innerWidth),p=Cn(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const d=n.element.getBoundingClientRect();d.width>0&&d.height>0&&typeof window<"u"&&(u=Cn((d.left+d.width/2)/window.innerWidth),p=Cn((d.top+d.height/2)/window.innerHeight))}r.style.setProperty("--theme-switch-x",`${u*100}%`),r.style.setProperty("--theme-switch-y",`${p*100}%`),r.classList.add("theme-transition");try{const d=(c=o.startViewTransition)==null?void 0:c.call(o,()=>{t()});d!=null&&d.finished?d.finished.finally(()=>_n(r)):_n(r)}catch{_n(r),t()}return}t(),_n(r)},kp=2e3;async function wt(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 s=await e.client.request("sessions.transcript",{cursors:t!=null&&t.reset?void 0:e.sessionLogsCursors,limit:200,maxBytesPerFile:e.sessionLogsFull?25e4:5e4,...e.sessionLogsFull?{full:!0}:{}}),i=Array.isArray(s.entries)?s.entries:[],r=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=r?i:[...e.sessionLogsEntries,...i].slice(-kp),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 Sp=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:wt},Symbol.toStringTag,{value:"Module"}));async function El(e,t){if(!(!e.client||!e.connected))try{const n={},s=await e.client.request("memory.audit",n);s!=null&&s.ok&&(e.auditEntries=s.entries??[])}catch{}}async function Ap(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function xp(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{ir(e,{quiet:!0})},5e3))}function $p(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function or(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Jt(e,{quiet:!0})},2e3))}function ar(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function lr(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{e.tab!=="logs"||e.logsSubTab!=="session"||wt(e,{quiet:!0})},2e3))}function cr(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function ur(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&Xi(e)},3e3))}function dr(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Ep(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{El(e)},3e4))}function Tp(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function Oe(e,t){var s;const n={...t,lastActiveSessionKey:((s=t.lastActiveSessionKey)==null?void 0:s.trim())||t.sessionKey.trim()||"main"};e.settings=n,Nu(n),t.theme!==e.theme&&(e.theme=t.theme,vs(e,rr(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function Tl(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Oe(e,{...e.settings,lastActiveSessionKey:n})}function Cp(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),s=t.get("password"),i=t.get("session"),r=t.get("gatewayUrl");let o=!1;if(n!=null){const l=n.trim();l&&l!==e.settings.token&&Oe(e,{...e.settings,token:l}),t.delete("token"),o=!0}if(s!=null){const l=s.trim();l&&(e.password=l),t.delete("password"),o=!0}if(i!=null){const l=i.trim();l&&(e.sessionKey=l,Oe(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(r!=null){const l=r.trim();l&&l!==e.settings.gatewayUrl&&Oe(e,{...e.settings,gatewayUrl:l}),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 _p(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?lr(e):or(e):(ar(e),cr(e)),t==="debug"?ur(e):dr(e),pr(e),_l(e,t,!1)}function Mp(e,t,n){wp({nextTheme:t,applyTheme:()=>{e.theme=t,Oe(e,{...e.settings,theme:t}),vs(e,rr(t))},context:n,currentTheme:e.theme})}async function pr(e){if(e.tab==="overview"&&await Ml(e),e.tab==="channels"&&await Op(e),e.tab==="instances"&&await Sl(e),e.tab==="cron"&&await hr(e),e.tab==="skills"&&await $t(e),e.tab==="nodes"&&(await ir(e),await sr(e),await Ae(e),await up(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await Kp(e),ln(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await tl(e),await Ae(e)),e.tab==="debug"&&(await Xi(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await pe(async()=>{const{loadSessionLogs:s}=await Promise.resolve().then(()=>Sp);return{loadSessionLogs:s}},void 0,import.meta.url);await n(e,{reset:!0})}else await Jt(e,{reset:!0});Ja(e,!0)}}function Lp(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?ys(e):yp(window.location.pathname)}function Pp(e){e.theme=e.settings.theme??"system",vs(e,rr(e.theme))}function vs(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Rp(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"&&vs(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Ip(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 Np(e,t){if(typeof window>"u")return;const n=$l(window.location.pathname,e.basePath)??"chat";Cl(e,n),_l(e,n,t)}function Dp(e){var i;if(typeof window>"u")return;const t=$l(window.location.pathname,e.basePath);if(!t)return;const s=(i=new URL(window.location.href).searchParams.get("session"))==null?void 0:i.trim();s&&(e.sessionKey=s,Oe(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s})),Cl(e,t)}function Cl(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?lr(e):or(e):(ar(e),cr(e)),t==="debug"?ur(e):dr(e),e.connected&&pr(e)}function _l(e,t,n){if(typeof window>"u")return;const s=an(mp(t,e.basePath)),i=an(window.location.pathname),r=new URL(window.location.href);t==="chat"&&e.sessionKey?r.searchParams.set("session",e.sessionKey):r.searchParams.delete("session"),i!==s&&(r.pathname=s),n?window.history.replaceState({},"",r.toString()):window.history.pushState({},"",r.toString())}async function Ml(e){await Promise.all([q(e,!1),Sl(e),Vi(e),cn(e),Xi(e)])}async function Op(e){await Promise.all([q(e,!0),tl(e),Ae(e)])}async function hr(e){await Promise.all([q(e,!1),cn(e),fs(e)])}function Ll(e){return e.chatSending||!!e.chatRunId}function Bp(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 Pl(e){e.connected&&(e.chatMessage="",await Xa(e))}function Fp(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);!s&&!i||(e.chatQueue=[...e.chatQueue,{id:Gi(),text:s,createdAt:Date.now(),attachments:i?n==null?void 0:n.map(r=>({...r})):void 0}],ln(e))}async function Rl(e,t,n){var i,r;Yi(e);const s=await Qa(e,t,n==null?void 0:n.attachments);return!s&&(n==null?void 0:n.previousDraft)!=null&&(e.chatMessage=n.previousDraft),!s&&(n!=null&&n.previousAttachments)&&(e.chatAttachments=n.previousAttachments),s&&Tl(e,e.sessionKey),s&&(n!=null&&n.restoreDraft)&&((i=n.previousDraft)!=null&&i.trim())&&(e.chatMessage=n.previousDraft),s&&(n!=null&&n.restoreAttachments)&&((r=n.previousAttachments)!=null&&r.length)&&(e.chatAttachments=n.previousAttachments),ln(e),s&&!e.chatRunId&&Il(e),s}async function Il(e){if(!e.connected||Ll(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await Rl(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function Up(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Wp(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),r=e.chatAttachments??[],o=t==null?r:[],a=o.length>0;if(!(!i&&!a)){if(Bp(i)){await Pl(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),Ll(e)){Fp(e,i,o);return}await Rl(e,i,{previousDraft:t==null?s: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 Kp(e){await Promise.all([Me(e),Vi(e),Ai(e)]),ln(e,!0)}const zp=Il;function jp(e){var i,r,o;const t=Ka(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(i=e.hello)==null?void 0:i.snapshot;return((o=(r=n==null?void 0:n.sessionDefaults)==null?void 0:r.defaultAgentId)==null?void 0:o.trim())||"main"}function Hp(e,t){const n=ys(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function Ai(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=jp(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Hp(e.basePath,t);try{const s=await fetch(n,{method:"GET"});if(!s.ok){e.chatAvatarUrl=null;return}const i=await s.json(),r=typeof i.avatarUrl=="string"?i.avatarUrl.trim():"";e.chatAvatarUrl=r||null}catch{e.chatAvatarUrl=null}}const O={messageSquare:h`<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:h`<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:h`<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:h`<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:h`<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:h`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:h`<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:h`<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:h`<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:h`<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:h`<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:h`<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:h`<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:h`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:h`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:h`<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:h`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:h`<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:h`<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:h`<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:h`<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:h`<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:h`<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:h`<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:h`<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:h`<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:h`<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:h`<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:h`<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:h`<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:h`<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:h`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,puzzle:h`<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:h`<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:h`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:h`<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:h`<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:h`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:h`<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:h`<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:h`<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:h`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:h`<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>`},qp="Taskmaster",Gp="/taskmaster-icon.png",Nl="#00d4ff";let Mn=null;function Ue(){return Mn||(Mn={name:window.__TASKMASTER_BRAND_NAME__||qp,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||Gp,accentColor:window.__TASKMASTER_ACCENT_COLOR__||Nl},Mn)}function Vp(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 Yp(e){if(e===Nl)return;const t=Vp(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 Qp=h`<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>`,Xp=h`<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="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path></svg>`;let $o=!1;function Zp(){$o||($o=!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 at(e,t){const n=(u,p)=>u===e?h`<span class="sp-page-nav-current">${u}</span>`:h`<a href=${p}>${u}</a>`,s=h`
19
+ ${n("Setup","/setup")}
20
+ ${n("Chat","/chat")}
21
+ ${n("Admins","/admins")}
22
+ ${n("Customers","/customers")}
23
+ ${n("Files","/files")}
24
+ ${n("Browser","/browser")}
25
+ ${n("Advanced","/advanced")}
26
+ `,r=t&&(t.isMaster!==!1||!t.hasPins)?Jp(t):k,o=t!=null&&t.hasPins&&t.onLogout?h`<button class="nav-logout-btn" @click=${t.onLogout} title="Lock">${Qp}</button>`:k,a=(t==null?void 0:t.auditCount)??0,l=a>0&&(t!=null&&t.onAuditClick)?h`<button class="nav-audit-btn" @click=${t.onAuditClick} title="Memory writes to review">
27
+ ${Xp}
28
+ <span class="nav-audit-badge">${a>99?"99+":a}</span>
29
+ </button>`:k,c=()=>{const u=document.getElementById("nav-burger-toggle");u&&(u.checked=!1)};return Zp(),h`
30
+ <div class="setup-header">
31
+ <input type="checkbox" id="nav-burger-toggle" class="nav-burger-checkbox" />
32
+ <div class="setup-header-inner">
33
+ <img class="setup-header-logo" src="${Ue().iconUrl}" alt="${Ue().name}" />
34
+ <nav class="setup-header-nav">
35
+ ${s}
36
+ </nav>
37
+ <div class="setup-header-right">
38
+ ${r!==k?h`<span class="nav-selector-inline">${r}</span>`:k}
39
+ ${l}
40
+ ${o}
41
+ <label for="nav-burger-toggle" class="nav-burger-button" aria-label="Toggle menu">
42
+ <span class="nav-burger-icon"></span>
43
+ </label>
44
+ </div>
45
+ </div>
46
+ <nav class="setup-header-dropdown" @click=${c}>
47
+ ${r!==k?h`<div class="nav-selector-mobile">${r}</div>`:k}
48
+ ${s}
49
+ </nav>
50
+ </div>
51
+ `}function Jp(e){const{workspaces:t,selectedWorkspace:n,onWorkspaceSelect:s}=e;return h`
52
+ <select
53
+ class="sp-workspace-selector"
54
+ .value=${n??""}
55
+ @change=${r=>{const o=r.target,a=o.value;if(a==="__add__"){o.value=n??"",e.onAddAccount?e.onAddAccount():window.location.href="/setup";return}s(a)}}
56
+ >
57
+ ${t.map(r=>h`
58
+ <option value=${r.name} ?selected=${r.name===n}>
59
+ ${r.displayName??r.name}
60
+ </option>
61
+ `)}
62
+ <option disabled>───</option>
63
+ <option value="__add__">+ Add Account</option>
64
+ </select>
65
+ `}function eh(e){return e.connected?h`
66
+ <div class="setup-container">
67
+ ${at("Browser")}
68
+ <div class="setup-card sp-card-wide">
69
+ <h1>Remote Browser</h1>
70
+ <p style="margin-bottom: 16px;">Live view of the headless Chrome instance.</p>
71
+
72
+ <div class="sp-toolbar">
73
+ ${e.active?h`
74
+ <button
75
+ class="setup-button ${e.inputMode?"primary":"secondary"}"
76
+ style="padding: 10px 20px; font-size: 14px;"
77
+ @click=${e.onToggleInput}
78
+ >
79
+ ${e.inputMode?"Input: ON":"Input: OFF"}
80
+ </button>
81
+ <button
82
+ class="setup-button danger"
83
+ style="padding: 10px 20px; font-size: 14px;"
84
+ ?disabled=${e.loading}
85
+ @click=${e.onStop}
86
+ >
87
+ Stop
88
+ </button>
89
+ `:h`
90
+ <button
91
+ class="setup-button primary"
92
+ style="padding: 10px 20px; font-size: 14px;"
93
+ ?disabled=${e.loading}
94
+ @click=${e.onStart}
95
+ >
96
+ ${e.loading?"Starting...":"Start"}
97
+ </button>
98
+ `}
99
+ </div>
100
+
101
+ ${e.error?h`<div class="setup-error" style="margin-top: 16px;">${e.error}</div>`:k}
102
+
103
+ ${e.handoffPending?h`
104
+ <div class="setup-warning" style="margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left;">
105
+ <div>
106
+ <strong>Action required:</strong> ${e.handoffReason??"The agent needs you to complete an action in the browser."}
107
+ </div>
108
+ <button class="setup-button primary" style="flex-shrink: 0; padding: 10px 20px; font-size: 14px;" @click=${e.onCompleteHandoff}>
109
+ Done
110
+ </button>
111
+ </div>
112
+ `:k}
113
+
114
+ <div class="sp-canvas-area" style="margin-top: 16px;">
115
+ ${e.active?h`
116
+ <div class="sp-canvas-wrap ${e.inputMode?"sp-input-active":""}">
117
+ <canvas
118
+ id="browser-screencast-canvas"
119
+ class="sp-canvas"
120
+ tabindex="0"
121
+ @mousedown=${t=>e.onCanvasMouseDown(t)}
122
+ @mouseup=${t=>e.onCanvasMouseUp(t)}
123
+ @mousemove=${t=>e.onCanvasMouseMove(t)}
124
+ @keydown=${t=>{t.preventDefault(),e.onCanvasKeyDown(t)}}
125
+ @keyup=${t=>{t.preventDefault(),e.onCanvasKeyUp(t)}}
126
+ @contextmenu=${t=>t.preventDefault()}
127
+ ></canvas>
128
+ </div>
129
+ `:h`
130
+ <div class="sp-canvas-placeholder">
131
+ <div class="sp-canvas-placeholder-icon">${O.globe}</div>
132
+ <p>Click Start to begin streaming the Chrome viewport.</p>
133
+ </div>
134
+ `}
135
+ </div>
136
+
137
+ ${e.active&&e.inputMode?h`<p class="setup-hint" style="margin-top: 12px;">
138
+ Click the canvas to focus, then interact with the browser. Mouse and keyboard input are forwarded.
139
+ </p>`:k}
140
+
141
+ </div>
142
+ </div>
143
+ `:h`
144
+ <div class="setup-container">
145
+ <div class="setup-card">
146
+ <div class="setup-spinner"></div>
147
+ <p>Connecting to gateway...</p>
148
+ </div>
149
+ </div>
150
+ `}const ts="application/x-taskmaster-file-path";function fr(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Dl(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function th(e,t,n){var r,o;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const s=(r=e.dataTransfer)==null?void 0:r.getData(ts);if(s){Dl(s)!==t&&n.onMoveToDir(s,t);return}const i=(o=e.dataTransfer)==null?void 0:o.files;if(i&&i.length>0){const a=Array.from(i).filter(l=>l.name.toLowerCase().endsWith(".md"));a.length>0&&n.onUpload(t,a)}}function Ol(e,t,n){const s=e.type==="directory"||e.type==="symlink"&&e.children!=null,i=t.expandedDirs.has(e.path),r=t.selectedPaths.has(e.path),o=n*20+12;return s?h`
151
+ <div
152
+ class="sp-tree-item sp-tree-dir ${i?"expanded":""}"
153
+ style="padding-left: ${o}px;"
154
+ @click=${()=>t.onToggleDir(e.path)}
155
+ @dragover=${a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&(a.dataTransfer.dropEffect="move"),a.currentTarget.classList.add("sp-drop-target")}}
156
+ @dragleave=${a=>{a.currentTarget.classList.remove("sp-drop-target")}}
157
+ @drop=${a=>th(a,e.path,t)}
158
+ >
159
+ <span class="sp-tree-chevron">${i?"−":"+"}</span>
160
+ <span class="sp-tree-icon">${O.folder}</span>
161
+ <span class="sp-tree-name">${e.name}</span>
162
+ </div>
163
+ ${i&&e.children?e.children.map(a=>Ol(a,t,n+1)):k}
164
+ `:h`
165
+ <div
166
+ class="sp-tree-item sp-tree-file ${r?"selected":""}"
167
+ style="padding-left: ${o}px;"
168
+ draggable="true"
169
+ @click=${a=>{a.metaKey||a.ctrlKey?t.onToggleSelectFile(e.path):t.onSelectFile(e.path)}}
170
+ @dragstart=${a=>{a.dataTransfer&&(a.dataTransfer.effectAllowed="move",a.dataTransfer.setData(ts,e.path),a.dataTransfer.setData("text/plain",e.name))}}
171
+ >
172
+ <span class="sp-tree-icon">${O.fileText}</span>
173
+ <span class="sp-tree-name">${e.name}</span>
174
+ <span class="sp-tree-size">${fr(e.size)}</span>
175
+ </div>
176
+ `}function nh(e){const t=e.selectedPaths.size;return t<2?k:h`
177
+ <div class="sp-bulk-actions">
178
+ <span style="color: var(--tasker-muted-grey); font-size: 13px;">${t} files selected</span>
179
+ <button
180
+ class="setup-button secondary"
181
+ style="padding: 8px 16px; font-size: 13px;"
182
+ @click=${e.onBulkDownload}
183
+ >
184
+ Download ${t} files
185
+ </button>
186
+ </div>
187
+ `}function sh(e){if(e.selectedPaths.size!==1||!e.selectedPath)return k;if(e.previewLoading)return h`
188
+ <div class="sp-file-preview">
189
+ <div class="setup-spinner" style="width: 32px; height: 32px; margin: 24px auto;"></div>
190
+ </div>
191
+ `;const t=e.selectedPath.split("/").pop()??e.selectedPath;return h`
192
+ <div class="sp-file-preview">
193
+ <div class="sp-file-preview-header">
194
+ <div>
195
+ <strong>${t}</strong>
196
+ <div class="sp-file-preview-meta">
197
+ ${e.selectedPath}${e.previewSize!=null?` — ${fr(e.previewSize)}`:""}
198
+ </div>
199
+ </div>
200
+ <div class="sp-file-actions">
201
+ <button class="setup-button secondary" style="padding: 8px 16px; font-size: 13px;" @click=${()=>e.onDownload(e.selectedPath)}>
202
+ Download
203
+ </button>
204
+ <button class="setup-button secondary" style="padding: 8px 16px; font-size: 13px;" @click=${()=>{const n=prompt("Move to (relative path):",e.selectedPath);n&&n!==e.selectedPath&&e.onMove(e.selectedPath,n)}}>
205
+ Move
206
+ </button>
207
+ <button class="setup-button danger" style="padding: 8px 16px; font-size: 13px;" @click=${()=>{confirm(`Delete ${t}?`)&&e.onDelete(e.selectedPath)}}>
208
+ Delete
209
+ </button>
210
+ </div>
211
+ </div>
212
+ ${e.previewBinary?h`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">Binary file — use Download to view.</p></div>`:e.previewContent!=null?h`<div class="sp-file-preview-body"><pre class="sp-file-code">${e.previewContent}</pre></div>`:h`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">File too large for preview — use Download.</p></div>`}
213
+ </div>
214
+ `}function ih(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 Bl(e){let t=0,n=0;for(const s of e)if(s.children){const i=Bl(s.children);t+=i.count,n+=i.bytes}else t++,n+=s.size??0;return{count:t,bytes:n}}function rh(e){const t=ih(e);return e.connected?h`
215
+ <div class="setup-container">
216
+ ${at("Files",e.wsProps)}
217
+ <div class="setup-card sp-card-wide">
218
+ <h1>Workspace Files</h1>
219
+ <p style="margin-bottom: 16px;">Browse, upload, and manage files in your workspace. Drag files between folders to move them.</p>
220
+
221
+ <div class="sp-toolbar">
222
+ <label class="setup-button secondary" style="padding: 10px 20px; font-size: 14px; cursor: pointer;">
223
+ Upload
224
+ <input
225
+ type="file"
226
+ multiple
227
+ accept=".md"
228
+ style="display: none;"
229
+ @change=${n=>{const s=n.target;s.files&&s.files.length>0&&(e.onUpload(t,Array.from(s.files)),s.value="")}}
230
+ />
231
+ </label>
232
+ <button
233
+ class="setup-button secondary"
234
+ style="padding: 10px 20px; font-size: 14px;"
235
+ ?disabled=${e.loading}
236
+ @click=${e.onRefresh}
237
+ >
238
+ ${e.loading?"Loading...":"Refresh"}
239
+ </button>
240
+ <button
241
+ class="setup-button secondary"
242
+ style="padding: 10px 20px; font-size: 14px;"
243
+ ?disabled=${e.reindexBusy}
244
+ @click=${e.onReindex}
245
+ >
246
+ ${e.reindexBusy?"Re-indexing...":"Re-index"}
247
+ </button>
248
+ ${e.memoryStatus?h`<span style="display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--tasker-text-grey);">
249
+ <span
250
+ class="setup-status-light"
251
+ style="width: 10px; height: 10px; background: ${e.memoryStatus.dirty?"#ef4444":"#22c55e"}"
252
+ ></span>
253
+ ${(()=>{const n=Bl(e.tree);return`${n.count} file${n.count!==1?"s":""}, ${fr(n.bytes)}`})()}
254
+ </span>`:k}
255
+ </div>
256
+
257
+ ${e.error?h`<div class="setup-error" style="margin-top: 16px;">${e.error}</div>`:k}
258
+
259
+ ${e.message?h`<div class="${e.message.kind==="error"?"setup-error":"setup-success-message"}" style="margin-top: 12px;">
260
+ ${e.message.text}
261
+ </div>`:k}
262
+
263
+ ${e.uploadBusy?h`<div style="margin-top: 12px; color: var(--tasker-orange); font-weight: 600; font-size: 14px;">Uploading...</div>`:k}
264
+
265
+ <div
266
+ class="sp-file-tree"
267
+ @dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(ts)?"move":"copy")}}
268
+ @drop=${n=>{var r,o;n.preventDefault();const s=(r=n.dataTransfer)==null?void 0:r.getData(ts);if(s){Dl(s)!=="."&&e.onMoveToDir(s,".");return}const i=(o=n.dataTransfer)==null?void 0:o.files;if(i&&i.length>0){const a=Array.from(i).filter(l=>l.name.toLowerCase().endsWith(".md"));a.length>0&&e.onUpload(t,a)}}}
269
+ >
270
+ ${e.tree.length===0&&!e.loading?h`<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=>Ol(n,e,0))}
271
+ </div>
272
+
273
+ ${nh(e)}
274
+ ${sh(e)}
275
+ </div>
276
+ </div>
277
+ `:h`
278
+ <div class="setup-container">
279
+ <div class="setup-card">
280
+ <div class="setup-spinner"></div>
281
+ <p>Connecting to gateway...</p>
282
+ </div>
283
+ </div>
284
+ `}const gr="taskmaster_uninstall_done";async function oh(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),ah();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 ns(){try{return localStorage.getItem(gr)==="1"}catch{return!1}}function mr(){try{localStorage.removeItem(gr)}catch{}}function ah(){try{localStorage.setItem(gr,"1")}catch{}}const Eo=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:ns,clearUninstallDone:mr,runUninstall:oh},Symbol.toStringTag,{value:"Module"}));function ue(e){return h`
285
+ <span
286
+ class="setup-status-light"
287
+ style="background: ${{good:"#22c55e",bad:"#ef4444",partial:"#eab308",unknown:"#6b7280"}[e]}"
288
+ ></span>
289
+ `}function Ct(e,t){return h`
290
+ <button
291
+ class="setup-info-btn"
292
+ @click=${()=>t.onInfoModalOpen(e)}
293
+ title="Details"
294
+ >
295
+ ${O.info}
296
+ </button>
297
+ `}function lh(e){var s;if(!e.infoModalOpen)return k;let t="",n=[];switch(e.infoModalOpen){case"gateway":{const i=typeof window<"u"?window.location.host:"unknown";t="Gateway",n=[{label:"Status",value:e.gatewayHealthy===!1?"Stopped":"Running"},{label:"Address",value:i},{label:"Health",value:e.gatewayHealthMessage||"OK"}];break}case"claude":{const i=e.authExpiresIn;let r="N/A";if(i!=null&&i>0)if(i>60){const o=Math.floor(i/60),a=i%60;r=a>0?`${o}h ${a}m`:`${o}h`}else r=`${i}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 i=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"Key",value:i},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A"}];break}case"whatsapp":{const i=_t(e),r=i?yr(i,e):null;t="WhatsApp",n=[{label:"Account",value:(r==null?void 0:r.name)||(r==null?void 0:r.accountId)||"Default"},{label:"Phone",value:((s=r==null?void 0:r.self)==null?void 0:s.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:i}=vr(e);t="iMessage",n=[{label:"Connected",value:i&&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 h`
298
+ <div class="setup-info-overlay" @click=${i=>{i.target.classList.contains("setup-info-overlay")&&e.onInfoModalClose()}}>
299
+ <div class="setup-info-card">
300
+ <h3>${t}</h3>
301
+ ${n.map(i=>h`
302
+ <div class="setup-info-row">
303
+ <span class="setup-info-label">${i.label}</span>
304
+ <span class="setup-info-value">${i.value}</span>
305
+ </div>
306
+ `)}
307
+ <button
308
+ class="setup-button secondary"
309
+ style="margin-top: 16px; width: 100%; padding: 10px;"
310
+ @click=${e.onInfoModalClose}
311
+ >
312
+ Close
313
+ </button>
314
+ </div>
315
+ </div>
316
+ `}function me(e){const t=[{id:"license",label:"1. Activate License"},{id:"auth",label:"2. Connect Claude"},{id:"whatsapp",label:"3. Link WhatsApp"}],n=["license","auth","whatsapp","complete"],s=n.indexOf(e);return h`
317
+ <div class="setup-steps">
318
+ ${t.map(i=>{const r=n.indexOf(i.id),o=e===i.id,a=s>r;return h`
319
+ <div
320
+ class="setup-step ${o?"active":""} ${a?"completed":""}"
321
+ >
322
+ <span class="setup-step-dot"></span>
323
+ <span class="setup-step-label">${i.label}</span>
324
+ </div>
325
+ `})}
326
+ </div>
327
+ `}function To(e){const{licenseKey:t,licenseBusy:n,licenseValid:s,licenseMessage:i,licenseDeviceId:r,onLicenseKeyChange:o,onLicenseActivate:a}=e;return s===!0?h`
328
+ <div class="setup-container">
329
+ <div class="setup-card setup-success">
330
+ ${me("license")}
331
+ <div class="setup-status-row">
332
+ ${ue("good")}
333
+ <span>License Activated</span>
334
+ </div>
335
+ <p>${i??"Your license is active."}</p>
336
+ </div>
337
+ </div>
338
+ `:n&&!t?h`
339
+ <div class="setup-container">
340
+ <div class="setup-card">
341
+ ${me("license")}
342
+ <div class="setup-spinner"></div>
343
+ <p>Checking license...</p>
344
+ </div>
345
+ </div>
346
+ `:h`
347
+ <div class="setup-container">
348
+ <div class="setup-card">
349
+ ${me("license")}
350
+ <h1>Activate License</h1>
351
+ <p>Enter your license key to get started.</p>
352
+ ${r?h`
353
+ <div class="setup-device-id">
354
+ <span class="setup-device-id-label">Your Device ID</span>
355
+ <code class="setup-device-id-value">${r}</code>
356
+ <button
357
+ class="setup-device-id-copy"
358
+ title="Copy Device ID"
359
+ @click=${async l=>{const c=l.currentTarget;try{await navigator.clipboard.writeText(r),c.textContent="Copied!",setTimeout(()=>{c.textContent="Copy"},1500)}catch{const u=document.createElement("textarea");u.value=r,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.select(),document.execCommand("copy"),document.body.removeChild(u),c.textContent="Copied!",setTimeout(()=>{c.textContent="Copy"},1500)}}}
360
+ >Copy</button>
361
+ <p class="setup-hint" style="margin-top: 4px;">
362
+ Send this ID along with your order number to our WhatsApp to receive your license key.
363
+ </p>
364
+ </div>
365
+ `:k}
366
+ <div class="setup-code-input">
367
+ <input
368
+ type="text"
369
+ placeholder="Paste your license key here"
370
+ .value=${t}
371
+ @input=${l=>o(l.target.value)}
372
+ @keydown=${l=>{l.key==="Enter"&&t.trim()&&a()}}
373
+ />
374
+ <button
375
+ class="setup-button"
376
+ ?disabled=${!t.trim()||n}
377
+ @click=${a}
378
+ >
379
+ ${n?"Activating...":"Activate"}
380
+ </button>
381
+ </div>
382
+ ${s===!1&&i?h`
383
+ <div class="setup-status-row" style="margin-top: 12px;">
384
+ ${ue("bad")}
385
+ <span class="setup-error">${i}</span>
386
+ </div>
387
+ `:k}
388
+ <p class="setup-hint">
389
+ Need a license?
390
+ <a href="https://taskmaster.bot" target="_blank" rel="noopener">
391
+ Purchase at taskmaster.bot
392
+ </a>
393
+ </p>
394
+ </div>
395
+ </div>
396
+ `}function ch(e){const{authConnected:t,authBusy:n,authMessage:s,authUrl:i,authCodeInput:r,authExpiresIn:o,onStartAuth:a,onSubmitAuthCode:l,onAuthCodeChange:c,onSkipToWhatsApp:u}=e;return t===!0?h`
397
+ <div class="setup-container">
398
+ <div class="setup-card setup-success">
399
+ ${me("auth")}
400
+ <div class="setup-status-row">
401
+ ${ue("good")}
402
+ <span>Claude Connected</span>
403
+ </div>
404
+ <p>
405
+ Your Claude Pro subscription is linked.
406
+ ${o?h`<br /><span class="setup-hint"
407
+ >Expires in ${o} minutes</span
408
+ >`:k}
409
+ </p>
410
+ <button class="setup-button primary" @click=${u}>
411
+ Continue to WhatsApp →
412
+ </button>
413
+ </div>
414
+ </div>
415
+ `:n&&!i?h`
416
+ <div class="setup-container">
417
+ <div class="setup-card">
418
+ ${me("auth")}
419
+ <div class="setup-spinner"></div>
420
+ <p>Starting Claude connection...</p>
421
+ </div>
422
+ </div>
423
+ `:i?h`
424
+ <div class="setup-container">
425
+ <div class="setup-card">
426
+ ${me("auth")}
427
+ <h1>Connect to Claude</h1>
428
+ <p>Click the button below to sign in with your Claude Pro account.</p>
429
+ <a
430
+ href=${i}
431
+ target="_blank"
432
+ rel="noopener"
433
+ class="setup-button primary"
434
+ >
435
+ Sign in with Claude →
436
+ </a>
437
+ <div class="setup-divider">
438
+ <span>Then enter the code shown</span>
439
+ </div>
440
+ <div class="setup-code-input">
441
+ <input
442
+ type="text"
443
+ placeholder="Enter authorization code"
444
+ .value=${r}
445
+ @input=${p=>c(p.target.value)}
446
+ @keydown=${p=>{p.key==="Enter"&&r.trim()&&l(r.trim())}}
447
+ />
448
+ <button
449
+ class="setup-button"
450
+ ?disabled=${!r.trim()||n}
451
+ @click=${()=>l(r.trim())}
452
+ >
453
+ ${n?"Verifying...":"Submit"}
454
+ </button>
455
+ </div>
456
+ ${s?h`<p class="setup-hint">${s}</p>`:k}
457
+ <p class="setup-hint" style="margin-top: 16px;">
458
+ <a href="#" class="setup-link" @click=${p=>{p.preventDefault(),e.onAuthApiKeyToggle()}}>
459
+ Or use an API key instead
460
+ </a>
461
+ </p>
462
+ </div>
463
+ </div>
464
+ `:e.authApiKeyMode?h`
465
+ <div class="setup-container">
466
+ <div class="setup-card">
467
+ ${me("auth")}
468
+ <h1>Enter API Key</h1>
469
+ <p>Paste your Anthropic API key below.</p>
470
+ <div class="setup-code-input">
471
+ <input
472
+ type="password"
473
+ placeholder="sk-ant-..."
474
+ .value=${e.authApiKeyInput}
475
+ @input=${p=>e.onAuthApiKeyChange(p.target.value)}
476
+ @keydown=${p=>{p.key==="Enter"&&e.authApiKeyInput.trim()&&e.onAuthApiKeySubmit()}}
477
+ ?disabled=${e.authApiKeyBusy}
478
+ autofocus
479
+ />
480
+ <button
481
+ class="setup-button"
482
+ ?disabled=${!e.authApiKeyInput.trim()||e.authApiKeyBusy}
483
+ @click=${()=>e.onAuthApiKeySubmit()}
484
+ >${e.authApiKeyBusy?"Saving...":"Save"}</button>
485
+ </div>
486
+ ${e.authApiKeyError?h`<p class="setup-error">${e.authApiKeyError}</p>`:k}
487
+ <p class="setup-hint" style="margin-top: 16px;">
488
+ <a href="#" class="setup-link" @click=${p=>{p.preventDefault(),e.onAuthApiKeyToggle()}}>
489
+ Use OAuth instead
490
+ </a>
491
+ </p>
492
+ <p class="setup-hint">
493
+ Get an API key from
494
+ <a href="https://console.anthropic.com/settings/keys" target="_blank" rel="noopener">
495
+ console.anthropic.com
496
+ </a>
497
+ </p>
498
+ </div>
499
+ </div>
500
+ `:h`
501
+ <div class="setup-container">
502
+ <div class="setup-card">
503
+ ${me("auth")}
504
+ <h1>Connect to Claude</h1>
505
+ ${t===!1&&s?h`<p class="setup-error">${s}</p>`:h`<p>
506
+ First, let's connect your Claude Pro subscription.<br />
507
+ This powers your AI assistant.
508
+ </p>`}
509
+ <button class="setup-button primary" @click=${a}>
510
+ Connect to Claude →
511
+ </button>
512
+ <p class="setup-hint" style="margin-top: 8px;">
513
+ <a href="#" class="setup-link" @click=${p=>{p.preventDefault(),e.onAuthApiKeyToggle()}}>
514
+ Or enter your API key
515
+ </a>
516
+ </p>
517
+ <p class="setup-hint">
518
+ Need a Claude subscription?
519
+ <a href="https://claude.ai/upgrade" target="_blank" rel="noopener">
520
+ Get Claude Pro
521
+ </a>
522
+ </p>
523
+ </div>
524
+ </div>
525
+ `}function yr(e,t){const n=new Map(t.whatsappAccounts.map(s=>[s.accountId,s]));return e.whatsappAccountId?n.get(e.whatsappAccountId)??null:e.isDefault&&t.whatsappAccounts.length===1?t.whatsappAccounts[0]??null:null}function _t(e){var n;const t=(n=e.wsProps)==null?void 0:n.selectedWorkspace;return t?e.workspaces.find(s=>s.name===t)??null:e.workspaces[0]??null}function Co(e){const t=_t(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??Ue().name,s=e.whatsappBusy||e.gatewayHealthLoading;if(e.renamingWorkspace&&t){const i=()=>{const r=e.renameWorkspaceName.trim();r&&e.onWorkspaceRename(t.name,r)};return h`
526
+ <div style="display: flex; align-items: center; gap: 6px; margin-bottom: 4px;">
527
+ <input
528
+ type="text"
529
+ .value=${e.renameWorkspaceName}
530
+ @input=${r=>{e.renameWorkspaceName=r.target.value}}
531
+ @keydown=${r=>{r.key==="Enter"&&i(),r.key==="Escape"&&e.onWorkspaceRenameCancel()}}
532
+ style="flex: 1; font-size: 18px; font-weight: 600; background: var(--tasker-bg-input, rgba(255,255,255,0.08)); border: 1px solid var(--tasker-border, rgba(255,255,255,0.15)); border-radius: 6px; color: var(--tasker-white); padding: 4px 8px; outline: none;"
533
+ autofocus
534
+ />
535
+ <button
536
+ class="setup-status-action"
537
+ @click=${i}
538
+ title="Save"
539
+ style="color: #22c55e;"
540
+ >${O.check}</button>
541
+ <button
542
+ class="setup-status-action"
543
+ @click=${e.onWorkspaceRenameCancel}
544
+ title="Cancel"
545
+ >${O.x}</button>
546
+ </div>
547
+ `}return h`
548
+ <div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px;">
549
+ <div style="display: flex; align-items: center; gap: 6px;">
550
+ <h2 style="margin: 0; font-size: 20px; font-weight: 600; color: var(--tasker-white);">${n}</h2>
551
+ <button
552
+ class="setup-status-action"
553
+ @click=${e.onWorkspaceRenameStart}
554
+ title="Rename"
555
+ style="opacity: 0.5; transform: scale(0.8);"
556
+ >${O.edit}</button>
557
+ </div>
558
+ <button
559
+ class="setup-status-action ${s?"spinning":""}"
560
+ ?disabled=${s}
561
+ @click=${e.onRefreshStatus}
562
+ title="Refresh Status"
563
+ >
564
+ ${O.rotateCw}
565
+ </button>
566
+ </div>
567
+ `}function _o(e){return h`
568
+ <div class="setup-status-item">
569
+ ${ue(e.gatewayHealthy===!1?"bad":"good")}
570
+ <div class="setup-status-info">
571
+ <strong>Gateway</strong>
572
+ <span>${e.gatewayHealthMessage||"Running"}</span>
573
+ </div>
574
+ ${Ct("gateway",e)}
575
+ <button
576
+ class="setup-status-action ${e.gatewayRestartBusy?"spinning":""}"
577
+ ?disabled=${e.gatewayRestartBusy}
578
+ @click=${e.onRestartGateway}
579
+ title="Restart Gateway"
580
+ >
581
+ ${O.rotateCw}
582
+ </button>
583
+ </div>
584
+ `}function Mo(e){const t=e.authConnected===!0;return h`
585
+ <div class="setup-status-item">
586
+ ${ue(t?"good":"bad")}
587
+ <div class="setup-status-info">
588
+ <strong>Claude</strong>
589
+ <span>
590
+ ${t?"Connected":"Not connected"}${t&&e.authExpiresIn?h` <span style="color: var(--tasker-text-grey); font-size: 12px;">(${e.authExpiresIn>60?`${Math.floor(e.authExpiresIn/60)}h ${e.authExpiresIn%60}m`:`${e.authExpiresIn}m`})</span>`:k}
591
+ </span>
592
+ </div>
593
+ ${Ct("claude",e)}
594
+ ${t?h`
595
+ <button
596
+ class="setup-status-action ${e.authBusy?"spinning":""}"
597
+ ?disabled=${e.authBusy}
598
+ @click=${e.onStartAuth}
599
+ title="Refresh Token"
600
+ >
601
+ ${O.rotateCw}
602
+ </button>
603
+ `:h`
604
+ <button
605
+ class="setup-status-action"
606
+ @click=${e.onStartAuth}
607
+ title="Connect Claude"
608
+ >
609
+ ${O.rotateCw}
610
+ </button>
611
+ `}
612
+ </div>
613
+ `}function Lo(e){return h`
614
+ <div class="setup-status-item" style="flex-wrap: wrap;">
615
+ ${ue("good")}
616
+ <div class="setup-status-info">
617
+ <strong>License</strong>
618
+ <span>Active</span>
619
+ </div>
620
+ ${Ct("license",e)}
621
+ <button
622
+ class="setup-status-action"
623
+ @click=${()=>{e.licenseRemoveConfirm?e.onLicenseRemoveCancel():e.onLicenseRemoveConfirm()}}
624
+ title="Manage License"
625
+ >
626
+ ${O.rotateCw}
627
+ </button>
628
+ ${e.licenseRemoveConfirm?h`
629
+ <div style="width: 100%; margin-top: 8px; margin-left: 30px;">
630
+ <p style="color: var(--tasker-text-grey); font-size: 13px; margin: 0 0 8px;">
631
+ Removing your license will disable ${Ue().name} until you enter a new key.
632
+ </p>
633
+ <div style="display: flex; gap: 8px;">
634
+ <button
635
+ class="setup-button danger"
636
+ style="font-size: 12px; padding: 4px 12px;"
637
+ ?disabled=${e.licenseBusy}
638
+ @click=${e.onLicenseRemove}
639
+ >
640
+ ${e.licenseBusy?"Removing…":"Remove License"}
641
+ </button>
642
+ <button
643
+ class="setup-button secondary"
644
+ style="font-size: 12px; padding: 4px 12px;"
645
+ @click=${e.onLicenseRemoveCancel}
646
+ >
647
+ Cancel
648
+ </button>
649
+ </div>
650
+ </div>
651
+ `:k}
652
+ </div>
653
+ `}function Po(e){var p;const t=_t(e);if(!t)return k;const n=yr(t,e),s=(n==null?void 0:n.running)&&(n==null?void 0:n.connected),i=(n==null?void 0:n.linked)&&!s,r=!!n,o=s?"good":i?"partial":r?"bad":"unknown",a=s?"Connected":i?"Linked, not connected":r?(n==null?void 0:n.lastError)||"Not connected":"Not paired",l=!(n!=null&&n.provider)||(n==null?void 0:n.provider)==="baileys",c=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(p=e.whatsappAccounts[0])==null?void 0:p.accountId:void 0),u=c!=null&&e.whatsappActiveQrAccountId===c;return h`
654
+ <div class="setup-status-item" style="flex-wrap: wrap;">
655
+ ${ue(o)}
656
+ <div class="setup-status-info">
657
+ <div style="display: flex; align-items: center; gap: 4px;">
658
+ <strong>WhatsApp</strong>
659
+ ${r&&s?h`
660
+ <button
661
+ class="setup-status-action"
662
+ @click=${e.onWhatsAppSettingsOpen}
663
+ title="WhatsApp Settings"
664
+ style="opacity: 0.5; transform: scale(0.75);"
665
+ >
666
+ ${O.settings}
667
+ </button>
668
+ `:k}
669
+ </div>
670
+ <span>${a}</span>
671
+ </div>
672
+ ${Ct("whatsapp",e)}
673
+ ${l&&c?h`
674
+ <button
675
+ class="setup-status-action ${e.whatsappBusy&&u?"spinning":""}"
676
+ ?disabled=${e.whatsappBusy}
677
+ @click=${()=>e.onWhatsAppRelink(c)}
678
+ title="${s?"Relink":"Link"} WhatsApp"
679
+ >
680
+ ${O.rotateCw}
681
+ </button>
682
+ `:k}
683
+ ${u&&e.whatsappLoginQrDataUrl?h`
684
+ <div style="width: 100%; margin-top: 8px; margin-left: 30px;">
685
+ <div class="setup-qr" style="display: inline-flex;">
686
+ <img
687
+ src=${e.whatsappLoginQrDataUrl}
688
+ alt="WhatsApp QR"
689
+ style="width: 140px; height: 140px;"
690
+ />
691
+ </div>
692
+ ${e.whatsappLoginMessage?h`<p class="setup-hint" style="margin-top: 4px;">${e.whatsappLoginMessage}</p>`:k}
693
+ </div>
694
+ `:k}
695
+ </div>
696
+ `}const uh=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],dh="anthropic/claude-sonnet-4-5-20250929",ph=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function hh(e){if(!e.whatsappSettingsOpen)return k;const t=_t(e);if(!t)return k;const n=yr(t,e),s=(n==null?void 0:n.running)&&(n==null?void 0:n.connected);if(!n||!s)return k;const i=()=>e.onWhatsAppSettingsClose(),r=e.whatsappModelCatalog??[],o=new Set(r.filter(u=>u.provider==="anthropic").map(u=>u.id)),a=uh.filter(u=>o.has(u.id)),l=e.whatsappModel??dh,c=e.whatsappThinkingLevel??"off";return h`
697
+ <div class="setup-info-overlay" @click=${u=>{u.target.classList.contains("setup-info-overlay")&&i()}}>
698
+ <div class="setup-info-card" style="max-width: 360px;">
699
+ <h3>Public Agent Settings</h3>
700
+ <div style="display: flex; flex-direction: column; gap: 16px; margin-top: 12px;">
701
+ <label style="display: flex; align-items: flex-start; gap: 8px; cursor: pointer;">
702
+ <input
703
+ type="checkbox"
704
+ .checked=${e.whatsappDmPolicy!=="disabled"&&e.whatsappDmPolicy!==null}
705
+ @change=${e.onWhatsAppDmToggle}
706
+ style="accent-color: #22c55e; margin-top: 2px;"
707
+ />
708
+ <div>
709
+ <div style="font-size: 13px; color: var(--tasker-white);">Enabled</div>
710
+ <div style="font-size: 12px; color: var(--tasker-text-grey); opacity: 0.7;">Agent replies to 3rd party messages</div>
711
+ </div>
712
+ </label>
713
+ <div style="border-top: 1px solid rgba(255,255,255,0.08); margin: 4px 0;"></div>
714
+ <label style="display: flex; align-items: flex-start; gap: 8px; cursor: pointer;">
715
+ <input
716
+ type="checkbox"
717
+ .checked=${e.whatsappGroupPolicy==="open"}
718
+ @change=${e.onWhatsAppGroupToggle}
719
+ style="accent-color: #22c55e; margin-top: 2px;"
720
+ />
721
+ <div>
722
+ <div style="font-size: 13px; color: var(--tasker-white);">Group chats</div>
723
+ <div style="font-size: 12px; color: var(--tasker-text-grey); opacity: 0.7;">Agent responds in WhatsApp groups</div>
724
+ </div>
725
+ </label>
726
+ ${e.whatsappGroupPolicy==="open"?h`
727
+ <div style="display: flex; flex-direction: column; gap: 6px; padding-left: 24px;">
728
+ <label style="display: flex; align-items: center; gap: 8px; cursor: pointer;">
729
+ <input
730
+ type="radio"
731
+ name="wa-group-mention"
732
+ .checked=${e.whatsappGroupRequireMention}
733
+ @change=${()=>e.onWhatsAppGroupMentionChange(!0)}
734
+ style="accent-color: #22c55e;"
735
+ />
736
+ <div>
737
+ <div style="font-size: 13px; color: var(--tasker-white);">When mentioned</div>
738
+ <div style="font-size: 11px; color: var(--tasker-text-grey); opacity: 0.7;">Only responds when @mentioned</div>
739
+ </div>
740
+ </label>
741
+ <label style="display: flex; align-items: center; gap: 8px; cursor: pointer;">
742
+ <input
743
+ type="radio"
744
+ name="wa-group-mention"
745
+ .checked=${!e.whatsappGroupRequireMention}
746
+ @change=${()=>e.onWhatsAppGroupMentionChange(!1)}
747
+ style="accent-color: #22c55e;"
748
+ />
749
+ <div>
750
+ <div style="font-size: 13px; color: var(--tasker-white);">Always respond</div>
751
+ <div style="font-size: 11px; color: var(--tasker-text-grey); opacity: 0.7;">Responds to every message in groups</div>
752
+ </div>
753
+ </label>
754
+ </div>
755
+ `:k}
756
+ <div style="border-top: 1px solid rgba(255,255,255,0.08); margin: 4px 0;"></div>
757
+ ${a.length>0?h`
758
+ <div style="display: flex; align-items: center; gap: 8px;">
759
+ <div style="font-size: 13px; color: var(--tasker-text-grey); min-width: 60px;">Model</div>
760
+ <select
761
+ class="setup-model-select"
762
+ style="flex: 1;"
763
+ .value=${l}
764
+ @change=${u=>{e.onWhatsAppModelChange(u.target.value)}}
765
+ >
766
+ ${a.map(u=>h`
767
+ <option value=${"anthropic/"+u.id} ?selected=${l==="anthropic/"+u.id}>
768
+ ${u.shortName}
769
+ </option>
770
+ `)}
771
+ </select>
772
+ </div>
773
+ `:k}
774
+ <div style="display: flex; align-items: center; gap: 8px;">
775
+ <div style="font-size: 13px; color: var(--tasker-text-grey); min-width: 60px;">Thinking</div>
776
+ <select
777
+ class="setup-model-select"
778
+ style="flex: 1;"
779
+ .value=${c}
780
+ @change=${u=>{e.onWhatsAppThinkingChange(u.target.value)}}
781
+ >
782
+ ${ph.map(u=>h`
783
+ <option value=${u.value} ?selected=${c===u.value}>
784
+ ${u.label}
785
+ </option>
786
+ `)}
787
+ </select>
788
+ </div>
789
+ </div>
790
+ <button
791
+ class="setup-button secondary"
792
+ style="margin-top: 20px; width: 100%; padding: 10px;"
793
+ @click=${i}
794
+ >
795
+ Close
796
+ </button>
797
+ </div>
798
+ </div>
799
+ `}function vr(e){const t=_t(e),n=e.imessageOwnerWorkspace,s=!!(t&&n===t.name),i=!!(n&&t&&n!==t.name);return{selectedWs:t,ownerWs:n,thisWsOwns:s,anotherWsOwns:i}}function Ro(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:s}=vr(e);let i,r;return s?(i="partial",r=`Connected to ${t}`):n&&e.imessageConnected?(i="good",r="Connected"):n&&e.imessageRunning?(i="partial",r="Running, not connected"):n?(i="bad",r="Not running"):e.imessageConfigured?(i="unknown",r="Not connected"):(i="bad",r="Not configured"),h`
800
+ <div class="setup-status-item" style="flex-wrap: wrap;">
801
+ ${ue(i)}
802
+ <div class="setup-status-info">
803
+ <strong>iMessage</strong>
804
+ <span>${r}</span>
805
+ </div>
806
+ ${Ct("imessage",e)}
807
+ <button
808
+ class="setup-status-action ${e.imessageEnabling?"spinning":""}"
809
+ ?disabled=${e.imessageEnabling}
810
+ @click=${e.onIMessageEnable}
811
+ title="${n?"Manage iMessage":"Connect iMessage"}"
812
+ >
813
+ ${O.rotateCw}
814
+ </button>
815
+ ${k}
816
+ </div>
817
+ `}function fh(e){if(!e.imessageEnableConfirm)return k;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:s}=vr(e),i=()=>{e.onIMessageEnableCancel()};return n?h`
818
+ <div class="setup-info-overlay" @click=${r=>{r.target.classList.contains("setup-info-overlay")&&i()}}>
819
+ <div class="setup-info-card" style="text-align: center;">
820
+ <h3>iMessage</h3>
821
+ <p style="color: var(--tasker-text-grey); font-size: 13px; margin: 8px 0 16px;">
822
+ iMessage is connected to this business.
823
+ </p>
824
+ <p style="font-size: 12px; color: var(--tasker-text-grey); opacity: 0.6; margin-bottom: 16px;">
825
+ Self-chat only. Third-party iMessage DMs are not processed.
826
+ </p>
827
+ <button
828
+ class="setup-button secondary"
829
+ style="width: 100%; padding: 10px; color: #ef4444; border-color: #ef4444;"
830
+ ?disabled=${e.imessageEnabling}
831
+ @click=${()=>{e.onIMessageDisconnect()}}
832
+ >
833
+ ${e.imessageEnabling?"Disconnecting…":"Disconnect iMessage"}
834
+ </button>
835
+ <button
836
+ class="setup-button secondary"
837
+ style="width: 100%; padding: 10px; margin-top: 8px;"
838
+ @click=${i}
839
+ >
840
+ Close
841
+ </button>
842
+ </div>
843
+ </div>
844
+ `:s?h`
845
+ <div class="setup-info-overlay" @click=${r=>{r.target.classList.contains("setup-info-overlay")&&i()}}>
846
+ <div class="setup-info-card" style="text-align: center;">
847
+ <h3>Connect iMessage</h3>
848
+ <p style="color: var(--tasker-text-grey); font-size: 13px; margin: 8px 0 16px;">
849
+ iMessage is currently connected to <strong style="text-transform: capitalize;">${t}</strong>.
850
+ Move it to this business?
851
+ </p>
852
+ <button
853
+ class="setup-button primary"
854
+ style="width: 100%; padding: 10px;"
855
+ ?disabled=${e.imessageEnabling}
856
+ @click=${()=>{e.onIMessageReassign()}}
857
+ >
858
+ ${e.imessageEnabling?"Connecting…":"Connect to This Business"}
859
+ </button>
860
+ <button
861
+ class="setup-button secondary"
862
+ style="width: 100%; padding: 10px; margin-top: 8px;"
863
+ @click=${i}
864
+ >
865
+ Cancel
866
+ </button>
867
+ </div>
868
+ </div>
869
+ `:h`
870
+ <div class="setup-info-overlay" @click=${r=>{r.target.classList.contains("setup-info-overlay")&&i()}}>
871
+ <div class="setup-info-card" style="text-align: center;">
872
+ <h3>Enable iMessage</h3>
873
+ <p style="color: var(--tasker-text-grey); font-size: 13px; margin: 8px 0 16px;">
874
+ ${Ue().name} will respond to messages in Messages.app for this business.
875
+ </p>
876
+ <button
877
+ class="setup-button primary"
878
+ style="width: 100%; padding: 10px;"
879
+ ?disabled=${e.imessageEnabling}
880
+ @click=${()=>{e.onIMessageEnableConfirm()}}
881
+ >
882
+ ${e.imessageEnabling?"Connecting…":"Connect"}
883
+ </button>
884
+ <button
885
+ class="setup-button secondary"
886
+ style="width: 100%; padding: 10px; margin-top: 8px;"
887
+ @click=${i}
888
+ >
889
+ Cancel
890
+ </button>
891
+ </div>
892
+ </div>
893
+ `}function Io(e){if(!e.isMaster)return k;const t=e.apiKeyProviders,n=t.filter(i=>i.hasKey).length,s=t.length;return h`
894
+ <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
895
+ <div class="setup-status-item">
896
+ ${ue(n>0?"good":"bad")}
897
+ <div class="setup-status-info">
898
+ <strong>API Keys</strong>
899
+ <span>${n} of ${s} configured</span>
900
+ </div>
901
+ <button
902
+ class="setup-link-btn"
903
+ @click=${()=>e.onApiKeyModalOpen()}
904
+ >Manage</button>
905
+ </div>
906
+ </div>
907
+ ${gh(e)}
908
+ `}function gh(e){if(!e.apiKeyModalOpen)return k;const t=e.apiKeyProviders,n={};for(const o of t)o.key&&(n[o.id]=o.key);const s=(o,a)=>{const l=a==null?void 0:a.closest(".setup-apikey-input"),c=l==null?void 0:l.querySelector("input"),u=c==null?void 0:c.value.trim();!u||u===n[o]||e.onApiKeySave(o,u)},i=o=>{const a=o.currentTarget,l=a.closest(".setup-apikey-input"),c=l==null?void 0:l.querySelector("input");if(!c)return;const u=c.type==="text";c.type=u?"password":"text",a.classList.toggle("active",!u)},r=(o,a)=>{const l=a.target,c=l.closest(".setup-apikey-input"),u=l.value.trim(),p=u.length>0&&u!==n[o],d=c==null?void 0:c.querySelector(".setup-apikey-save");d&&(d.style.display=p?"":"none");const f=c==null?void 0:c.querySelector(".setup-apikey-eye");f&&(f.style.display=u.length>0?"":"none")};return h`
909
+ <div class="setup-info-overlay" style="align-items: flex-start; padding-top: 72px;" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&e.onApiKeyModalClose()}}>
910
+ <div class="setup-info-card" style="max-width: 480px;">
911
+ <h3 style="margin: 0 0 4px; text-align: center;">API Keys</h3>
912
+ <div class="setup-apikey-list">
913
+ ${e.apiKeyError?h`<p class="setup-error" style="margin: 0;">${e.apiKeyError}</p>`:k}
914
+ ${e.apiKeySuccess?h`<p class="login-success" style="margin: 0;">${e.apiKeySuccess}</p>`:k}
915
+ ${t.map(o=>h`
916
+ <div class="setup-apikey-row">
917
+ <div class="setup-apikey-info">
918
+ <strong>${o.name}</strong>
919
+ <span class="setup-apikey-category">${o.category}</span>
920
+ </div>
921
+ <div class="setup-apikey-input">
922
+ <input
923
+ type="password"
924
+ .value=${o.key??""}
925
+ placeholder="Enter key"
926
+ ?disabled=${e.apiKeyBusy}
927
+ @input=${a=>r(o.id,a)}
928
+ @keydown=${a=>{a.key==="Enter"&&s(o.id,a.target)}}
929
+ />
930
+ <button
931
+ class="setup-apikey-icon-btn setup-apikey-eye"
932
+ style=${o.hasKey?"":"display: none;"}
933
+ title="Toggle visibility"
934
+ @click=${i}
935
+ >${O.eye}</button>
936
+ <button
937
+ class="setup-apikey-save setup-button"
938
+ style="display: none;"
939
+ ?disabled=${e.apiKeyBusy}
940
+ @click=${a=>s(o.id,a.currentTarget)}
941
+ >Save</button>
942
+ ${o.hasKey?h`
943
+ <button
944
+ class="setup-apikey-icon-btn danger"
945
+ title="Remove key"
946
+ ?disabled=${e.apiKeyBusy}
947
+ @click=${()=>e.onApiKeyRemove(o.id)}
948
+ >${O.trash}</button>
949
+ `:k}
950
+ </div>
951
+ </div>
952
+ `)}
953
+ </div>
954
+ </div>
955
+ </div>
956
+ `}function No(e){const t=e.updateAvailable===null?"unknown":e.updateAvailable?"partial":"good",n=e.updateAvailable&&e.latestVersion?`v${e.currentVersion} → v${e.latestVersion}`:e.currentVersion?`v${e.currentVersion}`:"Unknown",s=e.updateChecking||e.updateRunning;return h`
957
+ <div class="setup-status-item">
958
+ ${ue(t)}
959
+ <div class="setup-status-info">
960
+ <strong>Software</strong>
961
+ <span>${n}</span>
962
+ </div>
963
+ ${Ct("update",e)}
964
+ ${e.updateAvailable?h`
965
+ <button
966
+ class="setup-status-action ${s?"spinning":""}"
967
+ ?disabled=${s}
968
+ @click=${e.onUpdateRun}
969
+ title="Update Now"
970
+ >
971
+ ${O.download}
972
+ </button>
973
+ `:h`
974
+ <button
975
+ class="setup-status-action ${s?"spinning":""}"
976
+ ?disabled=${s}
977
+ @click=${e.onUpdateCheck}
978
+ title="Check for Updates"
979
+ >
980
+ ${O.rotateCw}
981
+ </button>
982
+ `}
983
+ </div>
984
+ `}function mh(e){var s,i,r;const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return k;if(t)return h`
985
+ <div class="setup-info-overlay">
986
+ <div class="setup-info-card" style="max-width: 400px;">
987
+ <h3>Software Update</h3>
988
+ ${e.updateProgressSteps.length>0?h`
989
+ <div class="setup-update-progress">
990
+ ${e.updateProgressSteps.map(o=>h`
991
+ <div class="setup-update-step ${o.status}">
992
+ <span class="setup-update-step-icon">
993
+ ${o.status==="running"?h`<span class="setup-update-spinner"></span>`:o.status==="done"?h`<span class="setup-update-check">&#10003;</span>`:h`<span class="setup-update-cross">&#10007;</span>`}
994
+ </span>
995
+ <span class="setup-update-step-name">${o.name}</span>
996
+ ${o.durationMs!=null?h`<span class="setup-update-step-time">${Do(o.durationMs)}</span>`:k}
997
+ </div>
998
+ `)}
999
+ </div>
1000
+ `:h`<div class="setup-spinner" style="margin: 16px auto;"></div>`}
1001
+ ${e.updateMessage?h`<p style="text-align: center; color: var(--tasker-text-grey); font-size: 13px; margin: 12px 0 0;">${e.updateMessage}</p>`:k}
1002
+ </div>
1003
+ </div>
1004
+ `;if(n){const o=n.status==="ok";let a;if(o){const c=(s=n.before)==null?void 0:s.version,u=((i=n.after)==null?void 0:i.version)??n.currentVersion;a=c?`v${c} → v${u}`:`Updated to v${u}`}else a=n.reason??((r=n.failedStep)==null?void 0:r.name)??"unknown error";const l=n.durationMs!=null?Do(n.durationMs):null;return h`
1005
+ <div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onUpdateDismissResult()}}>
1006
+ <div class="setup-info-card" style="max-width: 360px; text-align: center;">
1007
+ <div style="font-size: 40px; margin-bottom: 8px;">${o?"✓":"✗"}</div>
1008
+ <h3 style="color: ${o?"#22c55e":"#ef4444"};">
1009
+ ${o?"Update Complete":"Update Failed"}
1010
+ </h3>
1011
+ <p style="color: var(--tasker-text-grey); font-size: 14px; margin: 8px 0;">
1012
+ ${a}
1013
+ </p>
1014
+ ${l?h`<p style="color: rgba(255,255,255,0.3); font-size: 12px; margin: 4px 0 0;">${l}</p>`:k}
1015
+ <button
1016
+ class="setup-button secondary"
1017
+ style="margin-top: 20px; width: 100%; padding: 10px;"
1018
+ @click=${e.onUpdateDismissResult}
1019
+ >
1020
+ Close
1021
+ </button>
1022
+ </div>
1023
+ </div>
1024
+ `}return k}function Do(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return s>0?`${n}m ${s}s`:`${n}m`}function yh(e){const t=e.accountHasPin;return h`
1025
+ <div class="setup-status-item">
1026
+ ${ue(t?"good":"bad")}
1027
+ <div class="setup-status-info">
1028
+ <strong>Account PIN</strong>
1029
+ <span>${t?"Set":"Not set"}</span>
1030
+ </div>
1031
+ <button
1032
+ class="setup-link-btn"
1033
+ @click=${()=>e.onAccountPinModalOpen()}
1034
+ >${t?"Change":"Set PIN"}</button>
1035
+ </div>
1036
+ `}function vh(e){if(!e.accountPinModalOpen)return k;const t=e.accountHasPin,n=e.accountPinBusy;let s="",i="",r="";const o=c=>u=>{const p=u.target;p.value=p.value.replace(/\D/g,"").slice(0,6),c(p.value)},a=(c,u)=>{var d;let p=c.querySelector(".pin-modal-validation");p||(p=document.createElement("p"),p.className="login-error pin-modal-validation",(d=c.querySelector("button[type=submit]"))==null||d.before(p)),p.textContent=u},l=c=>{c.preventDefault();const u=c.target;if(!n){if(t&&!s){a(u,"Enter your current PIN");return}if(!i){a(u,"Enter a new PIN");return}if(!r){a(u,"Confirm your new PIN");return}if(i!==r){a(u,"PINs do not match");return}if(i.length<4){a(u,"PIN must be 4–6 digits");return}e.onAccountPinSave(t?s:null,i)}};return h`
1037
+ <div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onAccountPinModalClose()}}>
1038
+ <div class="setup-info-card" style="max-width: 340px;">
1039
+ <div class="setup-info-header">
1040
+ <h3>${t?"Change Account PIN":"Set Account PIN"}</h3>
1041
+ <button class="setup-info-close" @click=${()=>e.onAccountPinModalClose()}>
1042
+ ${O.close}
1043
+ </button>
1044
+ </div>
1045
+ <form @submit=${l} style="display: flex; flex-direction: column; gap: 12px; padding: 16px 0 8px;">
1046
+ ${t?h`
1047
+ <input
1048
+ class="login-pin-input"
1049
+ type="password"
1050
+ inputmode="numeric"
1051
+ pattern="[0-9]*"
1052
+ minlength="4"
1053
+ maxlength="6"
1054
+ placeholder="Current PIN"
1055
+ ?disabled=${n}
1056
+ @input=${o(c=>{s=c})}
1057
+ autofocus
1058
+ />
1059
+ `:k}
1060
+ <input
1061
+ class="login-pin-input"
1062
+ type="password"
1063
+ inputmode="numeric"
1064
+ pattern="[0-9]*"
1065
+ minlength="4"
1066
+ maxlength="6"
1067
+ placeholder="New PIN (4–6 digits)"
1068
+ ?disabled=${n}
1069
+ @input=${o(c=>{i=c})}
1070
+ ${t?k:h`autofocus`}
1071
+ />
1072
+ <input
1073
+ class="login-pin-input"
1074
+ type="password"
1075
+ inputmode="numeric"
1076
+ pattern="[0-9]*"
1077
+ minlength="4"
1078
+ maxlength="6"
1079
+ placeholder="Confirm PIN"
1080
+ ?disabled=${n}
1081
+ @input=${o(c=>{r=c})}
1082
+ />
1083
+ ${e.accountPinError?h`<p class="login-error">${e.accountPinError}</p>`:k}
1084
+ ${e.accountPinSuccess?h`<p class="login-success">${e.accountPinSuccess}</p>`:k}
1085
+ <button
1086
+ class="login-submit"
1087
+ type="submit"
1088
+ ?disabled=${n}
1089
+ >${n?h`<span class="login-spinner"></span>`:t?"Change PIN":"Set PIN"}</button>
1090
+ </form>
1091
+ </div>
1092
+ </div>
1093
+ `}function Oo(e){if(!e.addingWorkspace)return k;const{workspaceSaving:t}=e;return h`
1094
+ <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
1095
+ <div class="setup-add-account">
1096
+ <strong>New Account</strong>
1097
+ <input
1098
+ type="text"
1099
+ class="setup-add-account-input"
1100
+ placeholder=""
1101
+ .value=${e.newWorkspaceName}
1102
+ @input=${n=>e.onSetNewWorkspaceName(n.target.value)}
1103
+ @keydown=${n=>{n.key==="Enter"&&e.newWorkspaceName.trim()&&e.newWorkspacePin.match(/^\d{4,6}$/)&&e.onWorkspaceCreate(e.newWorkspaceName,e.newWorkspacePath||void 0)}}
1104
+ />
1105
+ <input
1106
+ type="password"
1107
+ inputmode="numeric"
1108
+ pattern="[0-9]*"
1109
+ minlength="4"
1110
+ maxlength="6"
1111
+ class="setup-add-account-input"
1112
+ placeholder="PIN for this account (4-6 digits)"
1113
+ .value=${e.newWorkspacePin}
1114
+ @input=${n=>{const s=n.target;s.value=s.value.replace(/\D/g,"").slice(0,6),e.onSetNewWorkspacePin(s.value)}}
1115
+ />
1116
+ <details style="margin-top: 8px;">
1117
+ <summary style="cursor: pointer; font-size: 12px; color: var(--tasker-text-grey);">
1118
+ Use existing workspace (advanced)
1119
+ </summary>
1120
+ <input
1121
+ type="text"
1122
+ class="setup-add-account-input"
1123
+ placeholder="/path/to/workspace"
1124
+ style="margin-top: 8px;"
1125
+ .value=${e.newWorkspacePath}
1126
+ @input=${n=>e.onSetNewWorkspacePath(n.target.value)}
1127
+ />
1128
+ </details>
1129
+ <div class="setup-add-account-actions" style="margin-top: 8px;">
1130
+ <button
1131
+ class="setup-button primary"
1132
+ ?disabled=${t||!e.newWorkspaceName.trim()||!e.newWorkspacePin.match(/^\d{4,6}$/)}
1133
+ @click=${()=>e.onWorkspaceCreate(e.newWorkspaceName,e.newWorkspacePath||void 0)}
1134
+ >
1135
+ ${t?"Creating…":"Create"}
1136
+ </button>
1137
+ <button
1138
+ class="setup-button secondary"
1139
+ @click=${()=>{e.onSetAddingWorkspace(!1),e.onSetNewWorkspaceName(""),e.onSetNewWorkspacePath(""),e.onSetNewWorkspacePin("")}}
1140
+ >
1141
+ Cancel
1142
+ </button>
1143
+ </div>
1144
+ </div>
1145
+ </div>
1146
+ `}function Bo(e){const t=_t(e);return!t||t.isDefault?k:e.workspaceRemoveConfirm===t.name?h`
1147
+ <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 12px;">
1148
+ <div style="font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
1149
+ <span style="color: var(--tasker-danger, #ef4444);">Remove "${t.displayName??t.name}" and its WhatsApp account?</span>
1150
+ <button
1151
+ class="setup-button danger"
1152
+ style="font-size: 12px; padding: 4px 12px;"
1153
+ ?disabled=${e.workspaceSaving}
1154
+ @click=${()=>e.onWorkspaceRemove(t.name)}
1155
+ >
1156
+ ${e.workspaceSaving?"Removing…":"Remove"}
1157
+ </button>
1158
+ <button
1159
+ class="setup-button secondary"
1160
+ style="font-size: 12px; padding: 4px 12px;"
1161
+ @click=${()=>e.onSetWorkspaceRemoveConfirm(null)}
1162
+ >
1163
+ Cancel
1164
+ </button>
1165
+ </div>
1166
+ </div>
1167
+ `:h`
1168
+ <p class="setup-hint" style="margin-top: 12px;">
1169
+ <a
1170
+ href="#"
1171
+ class="setup-link-danger"
1172
+ @click=${s=>{s.preventDefault(),e.onSetWorkspaceRemoveConfirm(t.name)}}
1173
+ >Remove Account</a>
1174
+ </p>
1175
+ `}function Fo(e){if(e.uninstallDone)return h`
1176
+ <div style="margin-top: 24px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
1177
+ <p style="color: var(--tasker-danger, #ef4444); font-size: 13px; font-weight: 600; margin: 0 0 8px 0;">
1178
+ Taskmaster has been uninstalled.
1179
+ </p>
1180
+ <p style="font-size: 12px; color: var(--tasker-text-grey); margin: 0;">
1181
+ If the npm package was not removed automatically, run:<br/>
1182
+ <code style="font-size: 11px; background: rgba(255,255,255,0.06); padding: 2px 6px; border-radius: 3px;">sudo npm uninstall -g @rubytech/taskmaster</code>
1183
+ </p>
1184
+ </div>
1185
+ `;if(e.uninstallConfirm){const t=e.uninstallConfirmText==="UNINSTALL";return h`
1186
+ <div style="margin-top: 24px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
1187
+ <p style="color: var(--tasker-danger, #ef4444); font-size: 13px; font-weight: 600; margin: 0 0 8px 0;">
1188
+ Uninstall Taskmaster
1189
+ </p>
1190
+ <p style="font-size: 12px; color: var(--tasker-text-grey); margin: 0 0 12px 0;">
1191
+ This will stop the gateway, remove all configuration, workspace files, and the npm package.
1192
+ This cannot be undone.
1193
+ </p>
1194
+ <div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
1195
+ <input
1196
+ type="text"
1197
+ placeholder="Type UNINSTALL to confirm"
1198
+ .value=${e.uninstallConfirmText}
1199
+ ?disabled=${e.uninstallBusy}
1200
+ @input=${n=>e.onUninstallConfirmTextChange(n.target.value)}
1201
+ style="font-size: 12px; padding: 4px 8px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15); border-radius: 4px; color: inherit; width: 180px;"
1202
+ />
1203
+ <button
1204
+ class="setup-button danger"
1205
+ style="font-size: 12px; padding: 4px 12px;"
1206
+ ?disabled=${!t||e.uninstallBusy}
1207
+ @click=${e.onUninstallRun}
1208
+ >
1209
+ ${e.uninstallBusy?"Uninstalling…":"Uninstall"}
1210
+ </button>
1211
+ <button
1212
+ class="setup-button secondary"
1213
+ style="font-size: 12px; padding: 4px 12px;"
1214
+ ?disabled=${e.uninstallBusy}
1215
+ @click=${e.onUninstallCancel}
1216
+ >
1217
+ Cancel
1218
+ </button>
1219
+ </div>
1220
+ ${e.uninstallError?h`<p class="setup-error" style="margin-top: 8px; font-size: 12px;">${e.uninstallError}</p>`:k}
1221
+ </div>
1222
+ `}return h`
1223
+ <p class="setup-hint" style="margin-top: 8px;">
1224
+ <a
1225
+ href="#"
1226
+ class="setup-link-danger"
1227
+ @click=${t=>{t.preventDefault(),e.onUninstallConfirm()}}
1228
+ >Uninstall Taskmaster</a>
1229
+ </p>
1230
+ `}function bh(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:s,whatsappLoginConnected:i,whatsappChannelStatus:r}=e;if(s)return h`
1231
+ <div class="setup-container">
1232
+ <div class="setup-card">
1233
+ <h1>Scan with WhatsApp</h1>
1234
+ <p>
1235
+ On your phone: WhatsApp → Settings → Linked Devices → Link a Device
1236
+ </p>
1237
+ <div class="setup-qr">
1238
+ <img src=${s} alt="WhatsApp QR Code" />
1239
+ </div>
1240
+ ${t?h`<p class="setup-waiting">Waiting for scan...</p>`:h`<p class="setup-hint">
1241
+ Scan the code above with your phone
1242
+ </p>`}
1243
+ <p class="setup-hint" style="margin-top: 16px;">
1244
+ <strong>Important:</strong> If you see "${Ue().name}" in your Linked
1245
+ Devices, remove it first before scanning.
1246
+ </p>
1247
+ <div class="setup-actions" style="margin-top: 24px;">
1248
+ <button
1249
+ class="setup-button secondary"
1250
+ @click=${e.onWhatsAppBack}
1251
+ >
1252
+ ← Back
1253
+ </button>
1254
+ </div>
1255
+ </div>
1256
+ </div>
1257
+ `;if(t)return h`
1258
+ <div class="setup-container">
1259
+ <div class="setup-card">
1260
+ <div class="setup-spinner"></div>
1261
+ <p>${n||"Connecting to WhatsApp..."}</p>
1262
+ </div>
1263
+ </div>
1264
+ `;const o=(r==null?void 0:r.running)&&(r==null?void 0:r.connected);return r?(e.whatsappAccounts.length>1?e.whatsappAccounts.every(u=>u.running&&u.connected):o)&&e.authConnected?h`
1265
+ <div class="setup-container">
1266
+ <div class="setup-card setup-success">
1267
+ ${Co(e)}
1268
+ <div class="setup-status-dashboard">
1269
+ ${_o(e)}
1270
+ ${Mo(e)}
1271
+ ${Lo(e)}
1272
+ ${Po(e)}
1273
+ ${Ro(e)}
1274
+ ${yh(e)}
1275
+ ${No(e)}
1276
+ </div>
1277
+
1278
+ ${vh(e)}
1279
+ ${Io(e)}
1280
+ ${Oo(e)}
1281
+ ${Bo(e)}
1282
+ ${Fo(e)}
1283
+ ${e.workspacesError?h`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:k}
1284
+ </div>
1285
+ </div>
1286
+ `:h`
1287
+ <div class="setup-container">
1288
+ <div class="setup-card">
1289
+ ${Co(e)}
1290
+ <div class="setup-status-dashboard">
1291
+ ${_o(e)}
1292
+ ${Mo(e)}
1293
+ ${Lo(e)}
1294
+ ${Po(e)}
1295
+ ${Ro(e)}
1296
+ ${No(e)}
1297
+ </div>
1298
+
1299
+ ${Io(e)}
1300
+ ${Oo(e)}
1301
+ ${Bo(e)}
1302
+ ${Fo(e)}
1303
+ ${e.workspacesError?h`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:k}
1304
+ </div>
1305
+ </div>
1306
+ `:r?i===!1&&n&&!t?h`
1307
+ <div class="setup-container">
1308
+ <div class="setup-card">
1309
+ ${me("whatsapp")}
1310
+ <div class="setup-status-row">
1311
+ ${ue("bad")}
1312
+ <span>Connection Failed</span>
1313
+ </div>
1314
+ <p class="setup-error">${n}</p>
1315
+ <button
1316
+ class="setup-button primary"
1317
+ ?disabled=${t}
1318
+ @click=${e.onWhatsAppRelink}
1319
+ >
1320
+ Try Again
1321
+ </button>
1322
+ </div>
1323
+ </div>
1324
+ `:h`
1325
+ <div class="setup-container">
1326
+ <div class="setup-card">
1327
+ ${me("whatsapp")}
1328
+ ${n?h`<p class="setup-error">${n}</p>`:h`<div class="setup-spinner"></div>
1329
+ <p>Preparing...</p>`}
1330
+ </div>
1331
+ </div>
1332
+ `:h`
1333
+ <div class="setup-container">
1334
+ <div class="setup-card">
1335
+ ${me("whatsapp")}
1336
+ <div class="setup-spinner"></div>
1337
+ <p>Checking connection status...</p>
1338
+ <button
1339
+ class="setup-button secondary"
1340
+ style="margin-top: 16px;"
1341
+ @click=${e.onRefreshStatus}
1342
+ >
1343
+ Refresh Status
1344
+ </button>
1345
+ </div>
1346
+ </div>
1347
+ `}function wh(e){const{connected:t,currentStep:n}=e;if(t&&ns()&&mr(),e.uninstallDone||!t&&ns())return h`
1348
+ <div class="setup-container">
1349
+ <div class="setup-card">
1350
+ <p style="color: var(--tasker-danger, #ef4444); font-size: 16px; font-weight: 600; margin: 0 0 12px 0;">
1351
+ Taskmaster has been uninstalled.
1352
+ </p>
1353
+ <p style="font-size: 13px; color: var(--tasker-text-grey); margin: 0 0 16px 0;">
1354
+ The gateway service, configuration, and workspace files have been removed.
1355
+ </p>
1356
+ <p style="font-size: 13px; color: var(--tasker-text-grey); margin: 0 0 16px 0;">
1357
+ If the npm package was not removed automatically, run:
1358
+ </p>
1359
+ <code style="display: block; font-size: 12px; background: rgba(255,255,255,0.06); padding: 8px 12px; border-radius: 4px; margin: 0 0 16px 0;">sudo npm uninstall -g @rubytech/taskmaster</code>
1360
+ <p style="font-size: 12px; color: var(--tasker-text-grey); margin: 0;">You can close this tab.</p>
1361
+ </div>
1362
+ </div>
1363
+ `;if(!t){const r=e.updateRunning;return h`
1364
+ <div class="setup-container">
1365
+ <div class="setup-card">
1366
+ <div class="setup-spinner"></div>
1367
+ <p>${r?"Restarting gateway after update…":"Connecting to gateway..."}</p>
1368
+ </div>
1369
+ </div>
1370
+ `}let s;switch(n){case"license":s=To(e);break;case"auth":s=ch(e);break;case"whatsapp":case"complete":s=bh(e);break;default:s=To(e)}const i=at("Setup",e.wsProps);return h`${s}${lh(e)}${fh(e)}${hh(e)}${mh(e)}${i}`}function kh(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return h`
1371
+ <div class="sp-list-item">
1372
+ <div class="sp-list-item-main">
1373
+ <div class="sp-list-item-title">${e.phone}</div>
1374
+ <div class="sp-list-item-sub">${n}</div>
1375
+ </div>
1376
+ ${e.paired?h`<span style="color: var(--tasker-orange); font-size: 13px; padding: 8px 16px;">Primary</span>`:h`<button
1377
+ class="setup-button danger"
1378
+ style="padding: 8px 16px; font-size: 13px;"
1379
+ ?disabled=${t.saving}
1380
+ @click=${()=>t.onRemove(e.phone)}
1381
+ >
1382
+ Remove
1383
+ </button>`}
1384
+ </div>
1385
+ `}function Sh(e){if(!e.connected)return h`
1386
+ <div class="setup-container">
1387
+ <div class="setup-card">
1388
+ <div class="setup-spinner"></div>
1389
+ <p>Connecting to gateway...</p>
1390
+ </div>
1391
+ </div>
1392
+ `;const t=n=>{n.preventDefault(),e.newPhone.trim()&&e.onAdd(e.newPhone)};return h`
1393
+ <div class="setup-container">
1394
+ ${at("Admins",e.wsProps)}
1395
+ <div class="setup-card" style="max-width: 520px;">
1396
+ <h1>Admin Phones</h1>
1397
+ <p style="margin-bottom: 16px;">
1398
+ Phone numbers that route to the admin agent instead of the public agent.
1399
+ </p>
1400
+
1401
+ <div class="sp-toolbar">
1402
+ <button
1403
+ class="setup-button secondary"
1404
+ style="padding: 10px 20px; font-size: 14px;"
1405
+ ?disabled=${e.loading}
1406
+ @click=${e.onRefresh}
1407
+ >
1408
+ ${e.loading?"Loading...":"Refresh"}
1409
+ </button>
1410
+ </div>
1411
+
1412
+ ${e.error?h`<div class="setup-error" style="margin-top: 16px;">${e.error}</div>`:k}
1413
+
1414
+ <form style="display: flex; flex-direction: row; gap: 12px; margin-top: 20px; align-items: stretch;" @submit=${t}>
1415
+ <input
1416
+ type="tel"
1417
+ style="flex: 1; padding: 10px 14px; font-size: 14px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.15); background: rgba(0, 0, 0, 0.3); color: var(--tasker-white); font-family: inherit;"
1418
+ placeholder="+44..."
1419
+ .value=${e.newPhone}
1420
+ @input=${n=>e.onNewPhoneChange(n.target.value)}
1421
+ ?disabled=${e.saving}
1422
+ />
1423
+ <button
1424
+ type="submit"
1425
+ class="setup-button primary"
1426
+ style="padding: 10px 20px; font-size: 14px; flex-shrink: 0;"
1427
+ ?disabled=${e.saving||!e.newPhone.trim()}
1428
+ >
1429
+ ${e.saving?"Saving...":"Add"}
1430
+ </button>
1431
+ </form>
1432
+
1433
+ <div class="sp-list" style="margin-top: 20px;">
1434
+ ${e.phones.length===0?h`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>kh(n,e))}
1435
+ </div>
1436
+
1437
+ <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
1438
+ <strong style="color: var(--tasker-white);">How it works:</strong><br/>
1439
+ Messages from admin phones route to the <code style="background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px; color: var(--tasker-orange);">admin</code> agent with full tool access.
1440
+ All other numbers go to <code style="background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px; color: var(--tasker-orange);">public</code> with restricted access.
1441
+ </div>
1442
+
1443
+ </div>
1444
+ </div>
1445
+ `}function Ah(e){return Object.keys(e.fields).length}function xh(e,t){const n=Object.entries(e.fields);return h`
1446
+ <div class="customers-record-fields">
1447
+ ${n.length===0?h`<div style="color: rgba(255,255,255,0.4); font-size: 13px; margin-top: 12px;">No fields yet. Add one below.</div>`:n.map(([s,i])=>h`
1448
+ <div class="customers-field-row">
1449
+ <input
1450
+ class="field-key"
1451
+ type="text"
1452
+ .value=${s}
1453
+ disabled
1454
+ title="Field name"
1455
+ />
1456
+ <input
1457
+ class="field-value"
1458
+ type="text"
1459
+ .value=${i}
1460
+ @change=${r=>t.onSetField(e.id,s,r.target.value)}
1461
+ ?disabled=${t.saving}
1462
+ title="Field value"
1463
+ />
1464
+ <button
1465
+ class="setup-button danger field-delete"
1466
+ ?disabled=${t.saving}
1467
+ @click=${()=>t.onDeleteField(e.id,s)}
1468
+ >
1469
+ ×
1470
+ </button>
1471
+ </div>
1472
+ `)}
1473
+ <div class="customers-record-actions">
1474
+ <button
1475
+ class="setup-button secondary"
1476
+ style="font-size: 13px; padding: 8px 14px;"
1477
+ ?disabled=${t.saving}
1478
+ @click=${()=>{const s=prompt("Field name (e.g. status, plan, notes):");if(!(s!=null&&s.trim()))return;const i=prompt(`Value for "${s.trim()}":`);i!==null&&t.onSetField(e.id,s.trim(),i)}}
1479
+ >
1480
+ + Add Field
1481
+ </button>
1482
+ <button
1483
+ class="setup-button danger"
1484
+ style="font-size: 13px; padding: 8px 14px;"
1485
+ ?disabled=${t.saving}
1486
+ @click=${()=>{confirm(`Delete customer "${e.name}" (${e.id})?`)&&t.onDelete(e.id)}}
1487
+ >
1488
+ Delete Customer
1489
+ </button>
1490
+ </div>
1491
+ </div>
1492
+ `}function $h(e,t){const n=t.editingId===e.id,s=Ah(e),i=s===0?"No fields":`${s} field${s>1?"s":""}`;return h`
1493
+ <div class="customers-record">
1494
+ <div
1495
+ class="customers-record-header"
1496
+ @click=${()=>t.onToggleExpand(e.id)}
1497
+ >
1498
+ <div class="customers-record-info">
1499
+ <span class="customers-record-name">${e.name}</span>
1500
+ <span class="customers-record-phone">${e.id}</span>
1501
+ </div>
1502
+ <span class="customers-record-meta">${i}</span>
1503
+ </div>
1504
+ ${n?xh(e,t):k}
1505
+ </div>
1506
+ `}function Eh(e){if(!e.connected)return h`
1507
+ <div class="setup-container">
1508
+ <div class="setup-card">
1509
+ <div class="setup-spinner"></div>
1510
+ <p>Connecting to gateway...</p>
1511
+ </div>
1512
+ </div>
1513
+ `;const t=s=>{s.preventDefault(),e.onSearchSubmit()},n=s=>{s.preventDefault(),e.newRecordPhone.trim()&&e.newRecordName.trim()&&e.onAdd(e.newRecordPhone,e.newRecordName)};return h`
1514
+ <div class="setup-container">
1515
+ ${at("Customers",e.wsProps)}
1516
+ <div class="setup-card" style="max-width: 620px;">
1517
+ <h1>Customer Records</h1>
1518
+ <p style="margin-bottom: 16px;">
1519
+ Verified customer data managed by the business owner. Agents can read these records but cannot modify them.
1520
+ </p>
1521
+
1522
+ <div class="sp-toolbar" style="display: flex; gap: 8px;">
1523
+ <button
1524
+ class="setup-button secondary"
1525
+ style="padding: 10px 20px; font-size: 14px;"
1526
+ ?disabled=${e.loading}
1527
+ @click=${e.onRefresh}
1528
+ >
1529
+ ${e.loading?"Loading...":"Refresh"}
1530
+ </button>
1531
+ <button
1532
+ class="setup-button primary"
1533
+ style="padding: 10px 20px; font-size: 14px;"
1534
+ @click=${e.onShowAddForm}
1535
+ >
1536
+ + Add Customer
1537
+ </button>
1538
+ </div>
1539
+
1540
+ ${e.error?h`<div class="setup-error" style="margin-top: 16px;">${e.error}</div>`:k}
1541
+
1542
+ ${e.showAddForm?h`
1543
+ <form class="customers-add-form" @submit=${n}>
1544
+ <input
1545
+ type="tel"
1546
+ placeholder="+447490553305"
1547
+ .value=${e.newRecordPhone}
1548
+ @input=${s=>e.onNewRecordPhoneChange(s.target.value)}
1549
+ ?disabled=${e.saving}
1550
+ />
1551
+ <input
1552
+ type="text"
1553
+ placeholder="Customer name"
1554
+ .value=${e.newRecordName}
1555
+ @input=${s=>e.onNewRecordNameChange(s.target.value)}
1556
+ ?disabled=${e.saving}
1557
+ />
1558
+ <div class="customers-add-form-buttons">
1559
+ <button
1560
+ type="submit"
1561
+ class="setup-button primary"
1562
+ style="padding: 10px 20px; font-size: 14px;"
1563
+ ?disabled=${e.saving||!e.newRecordPhone.trim()||!e.newRecordName.trim()}
1564
+ >
1565
+ ${e.saving?"Saving...":"Add"}
1566
+ </button>
1567
+ <button
1568
+ type="button"
1569
+ class="setup-button secondary"
1570
+ style="padding: 10px 20px; font-size: 14px;"
1571
+ @click=${e.onCancelAddForm}
1572
+ >
1573
+ Cancel
1574
+ </button>
1575
+ </div>
1576
+ </form>
1577
+ `:k}
1578
+
1579
+ <form
1580
+ class="customers-search"
1581
+ style="margin-top: 16px;"
1582
+ @submit=${t}
1583
+ >
1584
+ <input
1585
+ type="text"
1586
+ placeholder="Search by name or phone..."
1587
+ .value=${e.searchQuery}
1588
+ @input=${s=>e.onSearch(s.target.value)}
1589
+ />
1590
+ <button
1591
+ type="submit"
1592
+ class="setup-button secondary"
1593
+ style="padding: 10px 20px; font-size: 14px; flex-shrink: 0;"
1594
+ >
1595
+ Search
1596
+ </button>
1597
+ </form>
1598
+
1599
+ <div style="margin-top: 16px;">
1600
+ ${e.records.length===0?h`<div class="customers-empty">
1601
+ ${e.searchQuery.trim()?`No records matching "${e.searchQuery}".`:"No customer records yet. Add one to get started."}
1602
+ </div>`:e.records.map(s=>$h(s,e))}
1603
+ </div>
1604
+
1605
+ <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
1606
+ <strong style="color: var(--tasker-white);">How it works:</strong><br/>
1607
+ Records stored here are <strong>read-only for agents</strong> — they use the
1608
+ <code style="background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px; color: var(--tasker-orange);">customer_lookup</code>
1609
+ tool to check payment status and account details, but cannot modify them. This prevents prompt injection from altering sensitive data.
1610
+ </div>
1611
+ </div>
1612
+ </div>
1613
+ `}const Fl={CHILD:2},Ul=e=>(...t)=>({_$litDirective$:e,values:t});let Wl=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,s){this._$Ct=t,this._$AM=n,this._$Ci=s}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:Th}=$u,Uo=e=>e,Wo=()=>document.createComment(""),Ot=(e,t,n)=>{var r;const s=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0){const o=s.insertBefore(Wo(),i),a=s.insertBefore(Wo(),i);n=new Th(o,a,e,e.options)}else{const o=n._$AB.nextSibling,a=n._$AM,l=a!==e;if(l){let c;(r=n._$AQ)==null||r.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==a._$AU&&n._$AP(c)}if(o!==i||l){let c=n._$AA;for(;c!==o;){const u=Uo(c).nextSibling;Uo(s).insertBefore(c,i),c=u}}}return n},Ve=(e,t,n=e)=>(e._$AI(t,n),e),Ch={},_h=(e,t=Ch)=>e._$AH=t,Mh=e=>e._$AH,Vs=e=>{e._$AR(),e._$AA.remove()};const Ko=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s},Lh=Ul(class extends Wl{constructor(e){if(super(e),e.type!==Fl.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let s;n===void 0?n=t:t!==void 0&&(s=t);const i=[],r=[];let o=0;for(const a of e)i[o]=s?s(a,o):o,r[o]=n(a,o),o++;return{values:r,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,s]){const i=Mh(e),{values:r,keys:o}=this.dt(t,n,s);if(!Array.isArray(i))return this.ut=o,r;const a=this.ut??(this.ut=[]),l=[];let c,u,p=0,d=i.length-1,f=0,b=r.length-1;for(;p<=d&&f<=b;)if(i[p]===null)p++;else if(i[d]===null)d--;else if(a[p]===o[f])l[f]=Ve(i[p],r[f]),p++,f++;else if(a[d]===o[b])l[b]=Ve(i[d],r[b]),d--,b--;else if(a[p]===o[b])l[b]=Ve(i[p],r[b]),Ot(e,l[b+1],i[p]),p++,b--;else if(a[d]===o[f])l[f]=Ve(i[d],r[f]),Ot(e,i[p],i[d]),d--,f++;else if(c===void 0&&(c=Ko(o,f,b),u=Ko(a,p,d)),c.has(a[p]))if(c.has(a[d])){const w=u.get(o[f]),A=w!==void 0?i[w]:null;if(A===null){const T=Ot(e,i[p]);Ve(T,r[f]),l[f]=T}else l[f]=Ve(A,r[f]),Ot(e,i[p],A),i[w]=null;f++}else Vs(i[d]),d--;else Vs(i[p]),p++;for(;f<=b;){const w=Ot(e,l[b+1]);Ve(w,r[f]),l[f++]=w}for(;p<=d;){const w=i[p++];w!==null&&Vs(w)}return this.ut=o,_h(e,l),Be}});class xi extends Wl{constructor(t){if(super(t),this.it=k,t.type!==Fl.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===Be)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:[]}}}xi.directiveName="unsafeHTML",xi.resultType=1;const $i=Ul(xi);const{entries:Kl,setPrototypeOf:zo,isFrozen:Ph,getPrototypeOf:Rh,getOwnPropertyDescriptor:Ih}=Object;let{freeze:ae,seal:de,create:Ei}=Object,{apply:Ti,construct:Ci}=typeof Reflect<"u"&&Reflect;ae||(ae=function(t){return t});de||(de=function(t){return t});Ti||(Ti=function(t,n){for(var s=arguments.length,i=new Array(s>2?s-2:0),r=2;r<s;r++)i[r-2]=arguments[r];return t.apply(n,i)});Ci||(Ci=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return new t(...s)});const Ln=le(Array.prototype.forEach),Nh=le(Array.prototype.lastIndexOf),jo=le(Array.prototype.pop),Bt=le(Array.prototype.push),Dh=le(Array.prototype.splice),zn=le(String.prototype.toLowerCase),Ys=le(String.prototype.toString),Qs=le(String.prototype.match),Ft=le(String.prototype.replace),Oh=le(String.prototype.indexOf),Bh=le(String.prototype.trim),he=le(Object.prototype.hasOwnProperty),re=le(RegExp.prototype.test),Ut=Fh(TypeError);function le(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return Ti(e,t,s)}}function Fh(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return Ci(e,n)}}function D(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:zn;zo&&zo(e,null);let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){const r=n(i);r!==i&&(Ph(t)||(t[s]=r),i=r)}e[i]=!0}return e}function Uh(e){for(let t=0;t<e.length;t++)he(e,t)||(e[t]=null);return e}function ke(e){const t=Ei(null);for(const[n,s]of Kl(e))he(e,n)&&(Array.isArray(s)?t[n]=Uh(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=ke(s):t[n]=s);return t}function Wt(e,t){for(;e!==null;){const s=Ih(e,t);if(s){if(s.get)return le(s.get);if(typeof s.value=="function")return le(s.value)}e=Rh(e)}function n(){return null}return n}const Ho=ae(["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"]),Xs=ae(["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"]),Zs=ae(["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"]),Wh=ae(["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"]),Js=ae(["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"]),Kh=ae(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),qo=ae(["#text"]),Go=ae(["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"]),ei=ae(["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"]),Vo=ae(["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"]),Pn=ae(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),zh=de(/\{\{[\w\W]*|[\w\W]*\}\}/gm),jh=de(/<%[\w\W]*|[\w\W]*%>/gm),Hh=de(/\$\{[\w\W]*/gm),qh=de(/^data-[\-\w.\u00B7-\uFFFF]+$/),Gh=de(/^aria-[\-\w]+$/),zl=de(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Vh=de(/^(?:\w+script|data):/i),Yh=de(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),jl=de(/^html$/i),Qh=de(/^[a-z][.\w]*(-[.\w]+)+$/i);var Yo=Object.freeze({__proto__:null,ARIA_ATTR:Gh,ATTR_WHITESPACE:Yh,CUSTOM_ELEMENT:Qh,DATA_ATTR:qh,DOCTYPE_NAME:jl,ERB_EXPR:jh,IS_ALLOWED_URI:zl,IS_SCRIPT_OR_DATA:Vh,MUSTACHE_EXPR:zh,TMPLIT_EXPR:Hh});const Kt={element:1,text:3,progressingInstruction:7,comment:8,document:9},Xh=function(){return typeof window>"u"?null:window},Zh=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(s=n.getAttribute(i));const r="dompurify"+(s?"#"+s:"");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}},Qo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Hl(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Xh();const t=P=>Hl(P);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==Kt.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,i=s.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:d,trustedTypes:f}=e,b=l.prototype,w=Wt(b,"cloneNode"),A=Wt(b,"remove"),T=Wt(b,"nextSibling"),x=Wt(b,"childNodes"),E=Wt(b,"parentNode");if(typeof o=="function"){const P=n.createElement("template");P.content&&P.content.ownerDocument&&(n=P.content.ownerDocument)}let C,R="";const{implementation:U,createNodeIterator:Y,createDocumentFragment:ze,getElementsByTagName:Lt}=n,{importNode:fn}=s;let J=Qo();t.isSupported=typeof Kl=="function"&&typeof E=="function"&&U&&U.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Pt,ERB_EXPR:ut,TMPLIT_EXPR:je,DATA_ATTR:As,ARIA_ATTR:xs,IS_SCRIPT_OR_DATA:$s,ATTR_WHITESPACE:gn,CUSTOM_ELEMENT:Es}=Yo;let{IS_ALLOWED_URI:mn}=Yo,G=null;const yn=D({},[...Ho,...Xs,...Zs,...Js,...qo]);let V=null;const vn=D({},[...Go,...ei,...Vo,...Pn]);let j=Object.seal(Ei(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}})),He=null,Rt=null;const Pe=Object.seal(Ei(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let bn=!0,S=!0,_=!1,I=!0,N=!1,H=!0,K=!1,ie=!1,Re=!1,dt=!1,wn=!1,kn=!1,Dr=!0,Or=!1;const Vc="user-content-";let Ts=!0,It=!1,pt={},ye=null;const Cs=D({},["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 Br=null;const Fr=D({},["audio","video","img","source","image","track"]);let _s=null;const Ur=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Sn="http://www.w3.org/1998/Math/MathML",An="http://www.w3.org/2000/svg",xe="http://www.w3.org/1999/xhtml";let ht=xe,Ms=!1,Ls=null;const Yc=D({},[Sn,An,xe],Ys);let xn=D({},["mi","mo","mn","ms","mtext"]),$n=D({},["annotation-xml"]);const Qc=D({},["title","style","font","a","script"]);let Nt=null;const Xc=["application/xhtml+xml","text/html"],Zc="text/html";let X=null,ft=null;const Jc=n.createElement("form"),Wr=function(v){return v instanceof RegExp||v instanceof Function},Ps=function(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ft&&ft===v)){if((!v||typeof v!="object")&&(v={}),v=ke(v),Nt=Xc.indexOf(v.PARSER_MEDIA_TYPE)===-1?Zc:v.PARSER_MEDIA_TYPE,X=Nt==="application/xhtml+xml"?Ys:zn,G=he(v,"ALLOWED_TAGS")?D({},v.ALLOWED_TAGS,X):yn,V=he(v,"ALLOWED_ATTR")?D({},v.ALLOWED_ATTR,X):vn,Ls=he(v,"ALLOWED_NAMESPACES")?D({},v.ALLOWED_NAMESPACES,Ys):Yc,_s=he(v,"ADD_URI_SAFE_ATTR")?D(ke(Ur),v.ADD_URI_SAFE_ATTR,X):Ur,Br=he(v,"ADD_DATA_URI_TAGS")?D(ke(Fr),v.ADD_DATA_URI_TAGS,X):Fr,ye=he(v,"FORBID_CONTENTS")?D({},v.FORBID_CONTENTS,X):Cs,He=he(v,"FORBID_TAGS")?D({},v.FORBID_TAGS,X):ke({}),Rt=he(v,"FORBID_ATTR")?D({},v.FORBID_ATTR,X):ke({}),pt=he(v,"USE_PROFILES")?v.USE_PROFILES:!1,bn=v.ALLOW_ARIA_ATTR!==!1,S=v.ALLOW_DATA_ATTR!==!1,_=v.ALLOW_UNKNOWN_PROTOCOLS||!1,I=v.ALLOW_SELF_CLOSE_IN_ATTR!==!1,N=v.SAFE_FOR_TEMPLATES||!1,H=v.SAFE_FOR_XML!==!1,K=v.WHOLE_DOCUMENT||!1,dt=v.RETURN_DOM||!1,wn=v.RETURN_DOM_FRAGMENT||!1,kn=v.RETURN_TRUSTED_TYPE||!1,Re=v.FORCE_BODY||!1,Dr=v.SANITIZE_DOM!==!1,Or=v.SANITIZE_NAMED_PROPS||!1,Ts=v.KEEP_CONTENT!==!1,It=v.IN_PLACE||!1,mn=v.ALLOWED_URI_REGEXP||zl,ht=v.NAMESPACE||xe,xn=v.MATHML_TEXT_INTEGRATION_POINTS||xn,$n=v.HTML_INTEGRATION_POINTS||$n,j=v.CUSTOM_ELEMENT_HANDLING||{},v.CUSTOM_ELEMENT_HANDLING&&Wr(v.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(j.tagNameCheck=v.CUSTOM_ELEMENT_HANDLING.tagNameCheck),v.CUSTOM_ELEMENT_HANDLING&&Wr(v.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(j.attributeNameCheck=v.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),v.CUSTOM_ELEMENT_HANDLING&&typeof v.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(j.allowCustomizedBuiltInElements=v.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),N&&(S=!1),wn&&(dt=!0),pt&&(G=D({},qo),V=[],pt.html===!0&&(D(G,Ho),D(V,Go)),pt.svg===!0&&(D(G,Xs),D(V,ei),D(V,Pn)),pt.svgFilters===!0&&(D(G,Zs),D(V,ei),D(V,Pn)),pt.mathMl===!0&&(D(G,Js),D(V,Vo),D(V,Pn))),v.ADD_TAGS&&(typeof v.ADD_TAGS=="function"?Pe.tagCheck=v.ADD_TAGS:(G===yn&&(G=ke(G)),D(G,v.ADD_TAGS,X))),v.ADD_ATTR&&(typeof v.ADD_ATTR=="function"?Pe.attributeCheck=v.ADD_ATTR:(V===vn&&(V=ke(V)),D(V,v.ADD_ATTR,X))),v.ADD_URI_SAFE_ATTR&&D(_s,v.ADD_URI_SAFE_ATTR,X),v.FORBID_CONTENTS&&(ye===Cs&&(ye=ke(ye)),D(ye,v.FORBID_CONTENTS,X)),v.ADD_FORBID_CONTENTS&&(ye===Cs&&(ye=ke(ye)),D(ye,v.ADD_FORBID_CONTENTS,X)),Ts&&(G["#text"]=!0),K&&D(G,["html","head","body"]),G.table&&(D(G,["tbody"]),delete He.tbody),v.TRUSTED_TYPES_POLICY){if(typeof v.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ut('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof v.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ut('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');C=v.TRUSTED_TYPES_POLICY,R=C.createHTML("")}else C===void 0&&(C=Zh(f,i)),C!==null&&typeof R=="string"&&(R=C.createHTML(""));ae&&ae(v),ft=v}},Kr=D({},[...Xs,...Zs,...Wh]),zr=D({},[...Js,...Kh]),eu=function(v){let $=E(v);(!$||!$.tagName)&&($={namespaceURI:ht,tagName:"template"});const L=zn(v.tagName),z=zn($.tagName);return Ls[v.namespaceURI]?v.namespaceURI===An?$.namespaceURI===xe?L==="svg":$.namespaceURI===Sn?L==="svg"&&(z==="annotation-xml"||xn[z]):!!Kr[L]:v.namespaceURI===Sn?$.namespaceURI===xe?L==="math":$.namespaceURI===An?L==="math"&&$n[z]:!!zr[L]:v.namespaceURI===xe?$.namespaceURI===An&&!$n[z]||$.namespaceURI===Sn&&!xn[z]?!1:!zr[L]&&(Qc[L]||!Kr[L]):!!(Nt==="application/xhtml+xml"&&Ls[v.namespaceURI]):!1},ve=function(v){Bt(t.removed,{element:v});try{E(v).removeChild(v)}catch{A(v)}},qe=function(v,$){try{Bt(t.removed,{attribute:$.getAttributeNode(v),from:$})}catch{Bt(t.removed,{attribute:null,from:$})}if($.removeAttribute(v),v==="is")if(dt||wn)try{ve($)}catch{}else try{$.setAttribute(v,"")}catch{}},jr=function(v){let $=null,L=null;if(Re)v="<remove></remove>"+v;else{const Q=Qs(v,/^[\r\n\t ]+/);L=Q&&Q[0]}Nt==="application/xhtml+xml"&&ht===xe&&(v='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+v+"</body></html>");const z=C?C.createHTML(v):v;if(ht===xe)try{$=new d().parseFromString(z,Nt)}catch{}if(!$||!$.documentElement){$=U.createDocument(ht,"template",null);try{$.documentElement.innerHTML=Ms?R:z}catch{}}const te=$.body||$.documentElement;return v&&L&&te.insertBefore(n.createTextNode(L),te.childNodes[0]||null),ht===xe?Lt.call($,K?"html":"body")[0]:K?$.documentElement:te},Hr=function(v){return Y.call(v.ownerDocument||v,v,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Rs=function(v){return v instanceof p&&(typeof v.nodeName!="string"||typeof v.textContent!="string"||typeof v.removeChild!="function"||!(v.attributes instanceof u)||typeof v.removeAttribute!="function"||typeof v.setAttribute!="function"||typeof v.namespaceURI!="string"||typeof v.insertBefore!="function"||typeof v.hasChildNodes!="function")},qr=function(v){return typeof a=="function"&&v instanceof a};function $e(P,v,$){Ln(P,L=>{L.call(t,v,$,ft)})}const Gr=function(v){let $=null;if($e(J.beforeSanitizeElements,v,null),Rs(v))return ve(v),!0;const L=X(v.nodeName);if($e(J.uponSanitizeElement,v,{tagName:L,allowedTags:G}),H&&v.hasChildNodes()&&!qr(v.firstElementChild)&&re(/<[/\w!]/g,v.innerHTML)&&re(/<[/\w!]/g,v.textContent)||v.nodeType===Kt.progressingInstruction||H&&v.nodeType===Kt.comment&&re(/<[/\w]/g,v.data))return ve(v),!0;if(!(Pe.tagCheck instanceof Function&&Pe.tagCheck(L))&&(!G[L]||He[L])){if(!He[L]&&Yr(L)&&(j.tagNameCheck instanceof RegExp&&re(j.tagNameCheck,L)||j.tagNameCheck instanceof Function&&j.tagNameCheck(L)))return!1;if(Ts&&!ye[L]){const z=E(v)||v.parentNode,te=x(v)||v.childNodes;if(te&&z){const Q=te.length;for(let ce=Q-1;ce>=0;--ce){const Ee=w(te[ce],!0);Ee.__removalCount=(v.__removalCount||0)+1,z.insertBefore(Ee,T(v))}}}return ve(v),!0}return v instanceof l&&!eu(v)||(L==="noscript"||L==="noembed"||L==="noframes")&&re(/<\/no(script|embed|frames)/i,v.innerHTML)?(ve(v),!0):(N&&v.nodeType===Kt.text&&($=v.textContent,Ln([Pt,ut,je],z=>{$=Ft($,z," ")}),v.textContent!==$&&(Bt(t.removed,{element:v.cloneNode()}),v.textContent=$)),$e(J.afterSanitizeElements,v,null),!1)},Vr=function(v,$,L){if(Dr&&($==="id"||$==="name")&&(L in n||L in Jc))return!1;if(!(S&&!Rt[$]&&re(As,$))){if(!(bn&&re(xs,$))){if(!(Pe.attributeCheck instanceof Function&&Pe.attributeCheck($,v))){if(!V[$]||Rt[$]){if(!(Yr(v)&&(j.tagNameCheck instanceof RegExp&&re(j.tagNameCheck,v)||j.tagNameCheck instanceof Function&&j.tagNameCheck(v))&&(j.attributeNameCheck instanceof RegExp&&re(j.attributeNameCheck,$)||j.attributeNameCheck instanceof Function&&j.attributeNameCheck($,v))||$==="is"&&j.allowCustomizedBuiltInElements&&(j.tagNameCheck instanceof RegExp&&re(j.tagNameCheck,L)||j.tagNameCheck instanceof Function&&j.tagNameCheck(L))))return!1}else if(!_s[$]){if(!re(mn,Ft(L,gn,""))){if(!(($==="src"||$==="xlink:href"||$==="href")&&v!=="script"&&Oh(L,"data:")===0&&Br[v])){if(!(_&&!re($s,Ft(L,gn,"")))){if(L)return!1}}}}}}}return!0},Yr=function(v){return v!=="annotation-xml"&&Qs(v,Es)},Qr=function(v){$e(J.beforeSanitizeAttributes,v,null);const{attributes:$}=v;if(!$||Rs(v))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:V,forceKeepAttr:void 0};let z=$.length;for(;z--;){const te=$[z],{name:Q,namespaceURI:ce,value:Ee}=te,gt=X(Q),Is=Ee;let ee=Q==="value"?Is:Bh(Is);if(L.attrName=gt,L.attrValue=ee,L.keepAttr=!0,L.forceKeepAttr=void 0,$e(J.uponSanitizeAttribute,v,L),ee=L.attrValue,Or&&(gt==="id"||gt==="name")&&(qe(Q,v),ee=Vc+ee),H&&re(/((--!?|])>)|<\/(style|title|textarea)/i,ee)){qe(Q,v);continue}if(gt==="attributename"&&Qs(ee,"href")){qe(Q,v);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){qe(Q,v);continue}if(!I&&re(/\/>/i,ee)){qe(Q,v);continue}N&&Ln([Pt,ut,je],Zr=>{ee=Ft(ee,Zr," ")});const Xr=X(v.nodeName);if(!Vr(Xr,gt,ee)){qe(Q,v);continue}if(C&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!ce)switch(f.getAttributeType(Xr,gt)){case"TrustedHTML":{ee=C.createHTML(ee);break}case"TrustedScriptURL":{ee=C.createScriptURL(ee);break}}if(ee!==Is)try{ce?v.setAttributeNS(ce,Q,ee):v.setAttribute(Q,ee),Rs(v)?ve(v):jo(t.removed)}catch{qe(Q,v)}}$e(J.afterSanitizeAttributes,v,null)},tu=function P(v){let $=null;const L=Hr(v);for($e(J.beforeSanitizeShadowDOM,v,null);$=L.nextNode();)$e(J.uponSanitizeShadowNode,$,null),Gr($),Qr($),$.content instanceof r&&P($.content);$e(J.afterSanitizeShadowDOM,v,null)};return t.sanitize=function(P){let v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},$=null,L=null,z=null,te=null;if(Ms=!P,Ms&&(P="<!-->"),typeof P!="string"&&!qr(P))if(typeof P.toString=="function"){if(P=P.toString(),typeof P!="string")throw Ut("dirty is not a string, aborting")}else throw Ut("toString is not a function");if(!t.isSupported)return P;if(ie||Ps(v),t.removed=[],typeof P=="string"&&(It=!1),It){if(P.nodeName){const Ee=X(P.nodeName);if(!G[Ee]||He[Ee])throw Ut("root node is forbidden and cannot be sanitized in-place")}}else if(P instanceof a)$=jr("<!---->"),L=$.ownerDocument.importNode(P,!0),L.nodeType===Kt.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?$=L:$.appendChild(L);else{if(!dt&&!N&&!K&&P.indexOf("<")===-1)return C&&kn?C.createHTML(P):P;if($=jr(P),!$)return dt?null:kn?R:""}$&&Re&&ve($.firstChild);const Q=Hr(It?P:$);for(;z=Q.nextNode();)Gr(z),Qr(z),z.content instanceof r&&tu(z.content);if(It)return P;if(dt){if(wn)for(te=ze.call($.ownerDocument);$.firstChild;)te.appendChild($.firstChild);else te=$;return(V.shadowroot||V.shadowrootmode)&&(te=fn.call(s,te,!0)),te}let ce=K?$.outerHTML:$.innerHTML;return K&&G["!doctype"]&&$.ownerDocument&&$.ownerDocument.doctype&&$.ownerDocument.doctype.name&&re(jl,$.ownerDocument.doctype.name)&&(ce="<!DOCTYPE "+$.ownerDocument.doctype.name+`>
1614
+ `+ce),N&&Ln([Pt,ut,je],Ee=>{ce=Ft(ce,Ee," ")}),C&&kn?C.createHTML(ce):ce},t.setConfig=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ps(P),ie=!0},t.clearConfig=function(){ft=null,ie=!1},t.isValidAttribute=function(P,v,$){ft||Ps({});const L=X(P),z=X(v);return Vr(L,z,$)},t.addHook=function(P,v){typeof v=="function"&&Bt(J[P],v)},t.removeHook=function(P,v){if(v!==void 0){const $=Nh(J[P],v);return $===-1?void 0:Dh(J[P],$,1)[0]}return jo(J[P])},t.removeHooks=function(P){J[P]=[]},t.removeAllHooks=function(){J=Qo()},t}var _i=Hl();function br(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var lt=br();function ql(e){lt=e}var en={exec:()=>null};function F(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(i,r)=>{let o=typeof r=="string"?r:r.source;return o=o.replace(oe.caret,"$1"),n=n.replace(i,o),s},getRegex:()=>new RegExp(n,t)};return s}var Jh=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),oe={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")},ef=/^(?:[ \t]*(?:\n|$))+/,tf=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,nf=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,un=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,sf=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,wr=/(?:[*+-]|\d{1,9}[.)])/,Gl=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Vl=F(Gl).replace(/bull/g,wr).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(),rf=F(Gl).replace(/bull/g,wr).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(),kr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,of=/^[^\n]+/,Sr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,af=F(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Sr).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),lf=F(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,wr).getRegex(),bs="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",Ar=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,cf=F("^ {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",Ar).replace("tag",bs).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Yl=F(kr).replace("hr",un).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",bs).getRegex(),uf=F(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Yl).getRegex(),xr={blockquote:uf,code:tf,def:af,fences:nf,heading:sf,hr:un,html:cf,lheading:Vl,list:lf,newline:ef,paragraph:Yl,table:en,text:of},Xo=F("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",un).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",bs).getRegex(),df={...xr,lheading:rf,table:Xo,paragraph:F(kr).replace("hr",un).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Xo).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",bs).getRegex()},pf={...xr,html:F(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ar).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:en,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:F(kr).replace("hr",un).replace("heading",` *#{1,6} *[^
1615
+ ]`).replace("lheading",Vl).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},hf=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ff=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ql=/^( {2,}|\\)\n(?!\s*$)/,gf=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ws=/[\p{P}\p{S}]/u,$r=/[\s\p{P}\p{S}]/u,Xl=/[^\s\p{P}\p{S}]/u,mf=F(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,$r).getRegex(),Zl=/(?!~)[\p{P}\p{S}]/u,yf=/(?!~)[\s\p{P}\p{S}]/u,vf=/(?:[^\s\p{P}\p{S}]|~)/u,bf=F(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Jh?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Jl=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,wf=F(Jl,"u").replace(/punct/g,ws).getRegex(),kf=F(Jl,"u").replace(/punct/g,Zl).getRegex(),ec="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Sf=F(ec,"gu").replace(/notPunctSpace/g,Xl).replace(/punctSpace/g,$r).replace(/punct/g,ws).getRegex(),Af=F(ec,"gu").replace(/notPunctSpace/g,vf).replace(/punctSpace/g,yf).replace(/punct/g,Zl).getRegex(),xf=F("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Xl).replace(/punctSpace/g,$r).replace(/punct/g,ws).getRegex(),$f=F(/\\(punct)/,"gu").replace(/punct/g,ws).getRegex(),Ef=F(/^<(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(),Tf=F(Ar).replace("(?:-->|$)","-->").getRegex(),Cf=F("^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",Tf).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ss=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,_f=F(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",ss).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),tc=F(/^!?\[(label)\]\[(ref)\]/).replace("label",ss).replace("ref",Sr).getRegex(),nc=F(/^!?\[(ref)\](?:\[\])?/).replace("ref",Sr).getRegex(),Mf=F("reflink|nolink(?!\\()","g").replace("reflink",tc).replace("nolink",nc).getRegex(),Zo=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Er={_backpedal:en,anyPunctuation:$f,autolink:Ef,blockSkip:bf,br:Ql,code:ff,del:en,emStrongLDelim:wf,emStrongRDelimAst:Sf,emStrongRDelimUnd:xf,escape:hf,link:_f,nolink:nc,punctuation:mf,reflink:tc,reflinkSearch:Mf,tag:Cf,text:gf,url:en},Lf={...Er,link:F(/^!?\[(label)\]\((.*?)\)/).replace("label",ss).getRegex(),reflink:F(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ss).getRegex()},Mi={...Er,emStrongRDelimAst:Af,emStrongLDelim:kf,url:F(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Zo).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:F(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Zo).getRegex()},Pf={...Mi,br:F(Ql).replace("{2,}","*").getRegex(),text:F(Mi.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Rn={normal:xr,gfm:df,pedantic:pf},zt={normal:Er,gfm:Mi,breaks:Pf,pedantic:Lf},Rf={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Jo=e=>Rf[e];function Ce(e,t){if(t){if(oe.escapeTest.test(e))return e.replace(oe.escapeReplace,Jo)}else if(oe.escapeTestNoEncode.test(e))return e.replace(oe.escapeReplaceNoEncode,Jo);return e}function ea(e){try{e=encodeURI(e).replace(oe.percentDecode,"%")}catch{return null}return e}function ta(e,t){var r;let n=e.replace(oe.findPipe,(o,a,l)=>{let c=!1,u=a;for(;--u>=0&&l[u]==="\\";)c=!c;return c?"|":" |"}),s=n.split(oe.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!((r=s.at(-1))!=null&&r.trim())&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(oe.slashPipe,"|");return s}function jt(e,t,n){let s=e.length;if(s===0)return"";let i=0;for(;i<s&&e.charAt(s-i-1)===t;)i++;return e.slice(0,s-i)}function If(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function na(e,t,n,s,i){let r=t.href,o=t.title||null,a=e[1].replace(i.other.outputLinkReplace,"$1");s.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:o,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,l}function Nf(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let i=s[1];return t.split(`
1616
+ `).map(r=>{let o=r.match(n.other.beginningSpace);if(o===null)return r;let[a]=o;return a.length>=i.length?r.slice(i.length):r}).join(`
1617
+ `)}var is=class{constructor(e){B(this,"options");B(this,"rules");B(this,"lexer");this.options=e||lt}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:jt(n,`
1618
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=Nf(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=jt(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:jt(t[0],`
1619
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=jt(t[0],`
1620
+ `).split(`
1621
+ `),s="",i="",r=[];for(;n.length>0;){let o=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=!0;else if(!o)a.push(n[l]);else break;n=n.slice(l);let c=a.join(`
1622
+ `),u=c.replace(this.rules.other.blockquoteSetextReplace,`
1623
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
1624
+ ${c}`:c,i=i?`${i}
1625
+ ${u}`:u;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,r,!0),this.lexer.state.top=p,n.length===0)break;let d=r.at(-1);if((d==null?void 0:d.type)==="code")break;if((d==null?void 0:d.type)==="blockquote"){let f=d,b=f.raw+`
1626
+ `+n.join(`
1627
+ `),w=this.blockquote(b);r[r.length-1]=w,s=s.substring(0,s.length-f.raw.length)+w.raw,i=i.substring(0,i.length-f.text.length)+w.text;break}else if((d==null?void 0:d.type)==="list"){let f=d,b=f.raw+`
1628
+ `+n.join(`
1629
+ `),w=this.list(b);r[r.length-1]=w,s=s.substring(0,s.length-d.raw.length)+w.raw,i=i.substring(0,i.length-f.raw.length)+w.raw,n=b.substring(r.at(-1).raw.length).split(`
1630
+ `);continue}}return{type:"blockquote",raw:s,tokens:r,text:i}}}list(e){var n,s;let t=this.rules.block.list.exec(e);if(t){let i=t[1].trim(),r=i.length>1,o={type:"list",raw:"",ordered:r,start:r?+i.slice(0,-1):"",loose:!1,items:[]};i=r?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=r?i:"[*+-]");let a=this.rules.other.listItemRegex(i),l=!1;for(;e;){let u=!1,p="",d="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let f=t[2].split(`
1631
+ `,1)[0].replace(this.rules.other.listReplaceTabs,T=>" ".repeat(3*T.length)),b=e.split(`
1632
+ `,1)[0],w=!f.trim(),A=0;if(this.options.pedantic?(A=2,d=f.trimStart()):w?A=t[1].length+1:(A=t[2].search(this.rules.other.nonSpaceChar),A=A>4?1:A,d=f.slice(A),A+=t[1].length),w&&this.rules.other.blankLine.test(b)&&(p+=b+`
1633
+ `,e=e.substring(b.length+1),u=!0),!u){let T=this.rules.other.nextBulletRegex(A),x=this.rules.other.hrRegex(A),E=this.rules.other.fencesBeginRegex(A),C=this.rules.other.headingBeginRegex(A),R=this.rules.other.htmlBeginRegex(A);for(;e;){let U=e.split(`
1634
+ `,1)[0],Y;if(b=U,this.options.pedantic?(b=b.replace(this.rules.other.listReplaceNesting," "),Y=b):Y=b.replace(this.rules.other.tabCharGlobal," "),E.test(b)||C.test(b)||R.test(b)||T.test(b)||x.test(b))break;if(Y.search(this.rules.other.nonSpaceChar)>=A||!b.trim())d+=`
1635
+ `+Y.slice(A);else{if(w||f.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||E.test(f)||C.test(f)||x.test(f))break;d+=`
1636
+ `+b}!w&&!b.trim()&&(w=!0),p+=U+`
1637
+ `,e=e.substring(U.length+1),f=Y.slice(A)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(l=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),o.raw+=p}let c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let u of o.items){if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),u.task){if(u.text=u.text.replace(this.rules.other.listReplaceTask,""),((n=u.tokens[0])==null?void 0:n.type)==="text"||((s=u.tokens[0])==null?void 0:s.type)==="paragraph"){u.tokens[0].raw=u.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),u.tokens[0].text=u.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(u.raw);if(p){let d={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};u.checked=d.checked,o.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=d.raw+u.tokens[0].raw,u.tokens[0].text=d.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(d)):u.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):u.tokens.unshift(d)}}if(!o.loose){let p=u.tokens.filter(f=>f.type==="space"),d=p.length>0&&p.some(f=>this.rules.other.anyLine.test(f.raw));o.loose=d}}if(o.loose)for(let u of o.items){u.loose=!0;for(let p of u.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:i}}}table(e){var o;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=ta(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=t[3])!=null&&o.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
1638
+ `):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let a of s)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 i)r.rows.push(ta(a,r.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:r.align[c]})));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)===`
1639
+ `?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=jt(n.slice(0,-1),"\\");if((n.length-r.length)%2===0)return}else{let r=If(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 s=t[2],i="";if(this.options.pedantic){let r=this.rules.other.pedanticHrefTitle.exec(s);r&&(s=r[1],i=r[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),na(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[s.toLowerCase()];if(!i){let r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return na(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||s[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...s[0]].length-1,r,o,a=i,l=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+i);(s=c.exec(t))!=null;){if(r=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!r)continue;if(o=[...r].length,s[3]||s[4]){a+=o;continue}else if((s[5]||s[6])&&i%3&&!((i+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let u=[...s[0]][0].length,p=e.slice(0,i+s.index+u+o);if(Math.min(i,o)%2){let f=p.slice(1,-1);return{type:"em",raw:p,text:f,tokens:this.lexer.inlineTokens(f)}}let d=p.slice(2,-2);return{type:"strong",raw:p,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&i&&(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,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let s,i;if(t[2]==="@")s=t[0],i="mailto:"+s;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]);s=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:s,href:i,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},fe=class Li{constructor(t){B(this,"tokens");B(this,"options");B(this,"state");B(this,"inlineQueue");B(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||lt,this.options.tokenizer=this.options.tokenizer||new is,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:oe,block:Rn.normal,inline:zt.normal};this.options.pedantic?(n.block=Rn.pedantic,n.inline=zt.pedantic):this.options.gfm&&(n.block=Rn.gfm,this.options.breaks?n.inline=zt.breaks:n.inline=zt.gfm),this.tokenizer.rules=n}static get rules(){return{block:Rn,inline:zt}}static lex(t,n){return new Li(n).lex(t)}static lexInline(t,n){return new Li(n).inlineTokens(t)}lex(t){t=t.replace(oe.carriageReturn,`
1640
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],s=!1){var i,r,o;for(this.options.pedantic&&(t=t.replace(oe.tabCharGlobal," ").replace(oe.spaceLine,""));t;){let a;if((r=(i=this.options.extensions)==null?void 0:i.block)!=null&&r.some(c=>(a=c.call({lexer:this},t,n))?(t=t.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(t)){t=t.substring(a.raw.length);let c=n.at(-1);a.raw.length===1&&c!==void 0?c.raw+=`
1641
+ `:n.push(a);continue}if(a=this.tokenizer.code(t)){t=t.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
1642
+ `)?"":`
1643
+ `)+a.raw,c.text+=`
1644
+ `+a.text,this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(a=this.tokenizer.fences(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.heading(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.hr(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.blockquote(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.list(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.html(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.def(t)){t=t.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
1645
+ `)?"":`
1646
+ `)+a.raw,c.text+=`
1647
+ `+a.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},n.push(a));continue}if(a=this.tokenizer.table(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.lheading(t)){t=t.substring(a.raw.length),n.push(a);continue}let l=t;if((o=this.options.extensions)!=null&&o.startBlock){let c=1/0,u=t.slice(1),p;this.options.extensions.startBlock.forEach(d=>{p=d.call({lexer:this},u),typeof p=="number"&&p>=0&&(c=Math.min(c,p))}),c<1/0&&c>=0&&(l=t.substring(0,c+1))}if(this.state.top&&(a=this.tokenizer.paragraph(l))){let c=n.at(-1);s&&(c==null?void 0:c.type)==="paragraph"?(c.raw+=(c.raw.endsWith(`
1648
+ `)?"":`
1649
+ `)+a.raw,c.text+=`
1650
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a),s=l.length!==t.length,t=t.substring(a.raw.length);continue}if(a=this.tokenizer.text(t)){t=t.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
1651
+ `)?"":`
1652
+ `)+a.raw,c.text+=`
1653
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var l,c,u,p,d;let s=t,i=null;if(this.tokens.links){let f=Object.keys(this.tokens.links);if(f.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)f.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,i.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let r;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)r=i[2]?i[2].length:0,s=s.slice(0,i.index+r)+"["+"a".repeat(i[0].length-r-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=((c=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:c.call({lexer:this},s))??s;let o=!1,a="";for(;t;){o||(a=""),o=!1;let f;if((p=(u=this.options.extensions)==null?void 0:u.inline)!=null&&p.some(w=>(f=w.call({lexer:this},t,n))?(t=t.substring(f.raw.length),n.push(f),!0):!1))continue;if(f=this.tokenizer.escape(t)){t=t.substring(f.raw.length),n.push(f);continue}if(f=this.tokenizer.tag(t)){t=t.substring(f.raw.length),n.push(f);continue}if(f=this.tokenizer.link(t)){t=t.substring(f.raw.length),n.push(f);continue}if(f=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(f.raw.length);let w=n.at(-1);f.type==="text"&&(w==null?void 0:w.type)==="text"?(w.raw+=f.raw,w.text+=f.text):n.push(f);continue}if(f=this.tokenizer.emStrong(t,s,a)){t=t.substring(f.raw.length),n.push(f);continue}if(f=this.tokenizer.codespan(t)){t=t.substring(f.raw.length),n.push(f);continue}if(f=this.tokenizer.br(t)){t=t.substring(f.raw.length),n.push(f);continue}if(f=this.tokenizer.del(t)){t=t.substring(f.raw.length),n.push(f);continue}if(f=this.tokenizer.autolink(t)){t=t.substring(f.raw.length),n.push(f);continue}if(!this.state.inLink&&(f=this.tokenizer.url(t))){t=t.substring(f.raw.length),n.push(f);continue}let b=t;if((d=this.options.extensions)!=null&&d.startInline){let w=1/0,A=t.slice(1),T;this.options.extensions.startInline.forEach(x=>{T=x.call({lexer:this},A),typeof T=="number"&&T>=0&&(w=Math.min(w,T))}),w<1/0&&w>=0&&(b=t.substring(0,w+1))}if(f=this.tokenizer.inlineText(b)){t=t.substring(f.raw.length),f.raw.slice(-1)!=="_"&&(a=f.raw.slice(-1)),o=!0;let w=n.at(-1);(w==null?void 0:w.type)==="text"?(w.raw+=f.raw,w.text+=f.text):n.push(f);continue}if(t){let w="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(w);break}else throw new Error(w)}}return n}},rs=class{constructor(e){B(this,"options");B(this,"parser");this.options=e||lt}space(e){return""}code({text:e,lang:t,escaped:n}){var r;let s=(r=(t||"").match(oe.notSpaceStart))==null?void 0:r[0],i=e.replace(oe.endingNewline,"")+`
1654
+ `;return s?'<pre><code class="language-'+Ce(s)+'">'+(n?i:Ce(i,!0))+`</code></pre>
1655
+ `:"<pre><code>"+(n?i:Ce(i,!0))+`</code></pre>
1656
+ `}blockquote({tokens:e}){return`<blockquote>
1657
+ ${this.parser.parse(e)}</blockquote>
1658
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
1659
+ `}hr(e){return`<hr>
1660
+ `}list(e){let t=e.ordered,n=e.start,s="";for(let o=0;o<e.items.length;o++){let a=e.items[o];s+=this.listitem(a)}let i=t?"ol":"ul",r=t&&n!==1?' start="'+n+'"':"";return"<"+i+r+`>
1661
+ `+s+"</"+i+`>
1662
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
1663
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
1664
+ `}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let s="";for(let i=0;i<e.rows.length;i++){let r=e.rows[i];n="";for(let o=0;o<r.length;o++)n+=this.tablecell(r[o]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
1665
+ <thead>
1666
+ `+t+`</thead>
1667
+ `+s+`</table>
1668
+ `}tablerow({text:e}){return`<tr>
1669
+ ${e}</tr>
1670
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
1671
+ `}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>${Ce(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),i=ea(e);if(i===null)return s;e=i;let r='<a href="'+e+'"';return t&&(r+=' title="'+Ce(t)+'"'),r+=">"+s+"</a>",r}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let i=ea(e);if(i===null)return Ce(n);e=i;let r=`<img src="${e}" alt="${n}"`;return t&&(r+=` title="${Ce(t)}"`),r+=">",r}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ce(e.text)}},Tr=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}},ge=class Pi{constructor(t){B(this,"options");B(this,"renderer");B(this,"textRenderer");this.options=t||lt,this.options.renderer=this.options.renderer||new rs,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Tr}static parse(t,n){return new Pi(n).parse(t)}static parseInline(t,n){return new Pi(n).parseInline(t)}parse(t){var s,i;let n="";for(let r=0;r<t.length;r++){let o=t[r];if((i=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&i[o.type]){let l=o,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=c||"";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 l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(t,n=this.renderer){var i,r;let s="";for(let o=0;o<t.length;o++){let a=t[o];if((r=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&r[a.type]){let c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=c||"";continue}}let l=a;switch(l.type){case"escape":{s+=n.text(l);break}case"html":{s+=n.html(l);break}case"link":{s+=n.link(l);break}case"image":{s+=n.image(l);break}case"checkbox":{s+=n.checkbox(l);break}case"strong":{s+=n.strong(l);break}case"em":{s+=n.em(l);break}case"codespan":{s+=n.codespan(l);break}case"br":{s+=n.br(l);break}case"del":{s+=n.del(l);break}case"text":{s+=n.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}},Un,Gt=(Un=class{constructor(e){B(this,"options");B(this,"block");this.options=e||lt}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?fe.lex:fe.lexInline}provideParser(){return this.block?ge.parse:ge.parseInline}},B(Un,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),B(Un,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Un),Df=class{constructor(...e){B(this,"defaults",br());B(this,"options",this.setOptions);B(this,"parse",this.parseMarkdown(!0));B(this,"parseInline",this.parseMarkdown(!1));B(this,"Parser",ge);B(this,"Renderer",rs);B(this,"TextRenderer",Tr);B(this,"Lexer",fe);B(this,"Tokenizer",is);B(this,"Hooks",Gt);this.use(...e)}walkTokens(e,t){var s,i;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 l of a)n=n.concat(this.walkTokens(l.tokens,t));break}case"list":{let o=r;n=n.concat(this.walkTokens(o.items,t));break}default:{let o=r;(i=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let l=o[a].flat(1/0);n=n.concat(this.walkTokens(l,t))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let r=t.renderers[i.name];r?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=r.apply(this,o)),a}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let r=t[i.level];r?r.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),s.extensions=t),n.renderer){let i=this.defaults.renderer||new rs(this.defaults);for(let r in n.renderer){if(!(r in i))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;let o=r,a=n.renderer[o],l=i[o];i[o]=(...c)=>{let u=a.apply(i,c);return u===!1&&(u=l.apply(i,c)),u||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new is(this.defaults);for(let r in n.tokenizer){if(!(r in i))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let o=r,a=n.tokenizer[o],l=i[o];i[o]=(...c)=>{let u=a.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Gt;for(let r in n.hooks){if(!(r in i))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;let o=r,a=n.hooks[o],l=i[o];Gt.passThroughHooks.has(r)?i[o]=c=>{if(this.defaults.async&&Gt.passThroughHooksRespectAsync.has(r))return(async()=>{let p=await a.call(i,c);return l.call(i,p)})();let u=a.call(i,c);return l.call(i,u)}:i[o]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(i,c);return p===!1&&(p=await l.apply(i,c)),p})();let u=a.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}s.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,r=n.walkTokens;s.walkTokens=function(o){let a=[];return a.push(r.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return fe.lex(e,t??this.defaults)}parser(e,t){return ge.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},i={...this.defaults,...s},r=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&s.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(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,a=await(i.hooks?await i.hooks.provideLexer():e?fe.lex:fe.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let c=await(i.hooks?await i.hooks.provideParser():e?ge.parse:ge.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(c):c})().catch(r);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():e?fe.lex:fe.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():e?ge.parse:ge.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return r(o)}}}onError(e,t){return n=>{if(n.message+=`
1672
+ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+Ce(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},it=new Df;function W(e,t){return it.parse(e,t)}W.options=W.setOptions=function(e){return it.setOptions(e),W.defaults=it.defaults,ql(W.defaults),W};W.getDefaults=br;W.defaults=lt;W.use=function(...e){return it.use(...e),W.defaults=it.defaults,ql(W.defaults),W};W.walkTokens=function(e,t){return it.walkTokens(e,t)};W.parseInline=it.parseInline;W.Parser=ge;W.parser=ge.parse;W.Renderer=rs;W.TextRenderer=Tr;W.Lexer=fe;W.lexer=fe.lex;W.Tokenizer=is;W.Hooks=Gt;W.parse=W;W.options;W.setOptions;W.use;W.walkTokens;W.parseInline;ge.parse;fe.lex;W.setOptions({gfm:!0,breaks:!0,mangle:!1});const sa=["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"],ia=["class","href","rel","target","title","start"];let ra=!1;const Of=14e4,Bf=4e4,Ff=200,ti=5e4,Xe=new Map;function Uf(e){const t=Xe.get(e);return t===void 0?null:(Xe.delete(e),Xe.set(e,t),t)}function oa(e,t){if(Xe.set(e,t),Xe.size<=Ff)return;const n=Xe.keys().next().value;n&&Xe.delete(n)}function Wf(){ra||(ra=!0,_i.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Ri(e){const t=e.trim();if(!t)return"";if(Wf(),t.length<=ti){const o=Uf(t);if(o!==null)return o}const n=Ha(t,Of),s=n.truncated?`
1673
+
1674
+ … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Bf){const a=`<pre class="code-block">${Kf(`${n.text}${s}`)}</pre>`,l=_i.sanitize(a,{ALLOWED_TAGS:sa,ALLOWED_ATTR:ia});return t.length<=ti&&oa(t,l),l}const i=W.parse(`${n.text}${s}`),r=_i.sanitize(i,{ALLOWED_TAGS:sa,ALLOWED_ATTR:ia});return t.length<=ti&&oa(t,r),r}function Kf(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const zf=1500,jf=2e3,sc="Copy as markdown",Hf="Copied",qf="Copy failed";async function Gf(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 In(e,t){e.title=t,e.setAttribute("aria-label",t)}function Vf(e){const t=e.label??sc;return h`
1675
+ <button
1676
+ class="chat-copy-btn"
1677
+ type="button"
1678
+ title=${t}
1679
+ aria-label=${t}
1680
+ @click=${async n=>{const s=n.currentTarget;if(s==null||s.querySelector(".chat-copy-btn__icon"),!s||s.dataset.copying==="1")return;s.dataset.copying="1",s.setAttribute("aria-busy","true"),s.disabled=!0;const i=await Gf(e.text());if(s.isConnected){if(delete s.dataset.copying,s.removeAttribute("aria-busy"),s.disabled=!1,!i){s.dataset.error="1",In(s,qf),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.error,In(s,t))},jf);return}s.dataset.copied="1",In(s,Hf),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,In(s,t))},zf)}}}
1681
+ >
1682
+ <span class="chat-copy-btn__icon" aria-hidden="true">
1683
+ <span class="chat-copy-btn__icon-copy">${O.copy}</span>
1684
+ <span class="chat-copy-btn__icon-check">${O.check}</span>
1685
+ </span>
1686
+ </button>
1687
+ `}function Yf(e){return Vf({text:()=>e,label:sc})}function Qf(e){const t=e,n=Xf(t.content),s=[];for(const i of n){const r=String(i.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(r)||typeof i.name=="string"&&i.arguments!=null)&&s.push({kind:"call",name:i.name??"tool",args:Zf(i.arguments??i.args)})}for(const i of n){const r=String(i.type??"").toLowerCase();if(r!=="toolresult"&&r!=="tool_result")continue;const o=Jf(i),a=typeof i.name=="string"?i.name:"tool";s.push({kind:"result",name:a,text:o})}if(Ya(e)&&!s.some(i=>i.kind==="result")){const i=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",r=qa(e)??void 0;s.push({kind:"result",name:i,text:r})}return s}function Xf(e){return Array.isArray(e)?e.filter(Boolean):[]}function Zf(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 Jf(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function eg(e){var i;const n=e.content,s=[];if(Array.isArray(n))for(const r of n){if(typeof r!="object"||r===null)continue;const o=r;if(o.type==="image")if(((i=o.source)==null?void 0:i.type)==="base64"){const a=o.source,l=a.data,c=a.media_type||"image/png",u=l.startsWith("data:")?l:`data:${c};base64,${l}`;s.push({url:u})}else if(typeof o.data=="string"&&o.data){const a=o.data,l=o.mimeType||o.media_type||"image/png",c=a.startsWith("data:")?a:`data:${l};base64,${a}`;s.push({url:c})}else typeof o.url=="string"&&s.push({url:o.url});else if(o.type==="image_url"){const a=o.image_url;typeof(a==null?void 0:a.url)=="string"&&s.push({url:a.url})}}return s}function tg(e){return h`
1688
+ <div class="chat-group assistant">
1689
+ <div class="chat-group-messages">
1690
+ <div class="chat-bubble chat-reading-indicator" aria-hidden="true">
1691
+ <span class="chat-reading-indicator__dots">
1692
+ <span></span><span></span><span></span>
1693
+ </span>
1694
+ </div>
1695
+ </div>
1696
+ </div>
1697
+ `}function ng(e,t,n,s){return h`
1698
+ <div class="chat-group assistant">
1699
+ <div class="chat-group-messages">
1700
+ ${ic({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
1701
+ </div>
1702
+ </div>
1703
+ `}function sg(e,t){const n=Va(e.role),s=n==="user"?"user":n==="assistant"?"assistant":"other",i=new Date(e.timestamp).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return h`
1704
+ <div class="chat-group ${s}">
1705
+ <div class="chat-group-messages">
1706
+ ${e.messages.map((r,o)=>ic(r.message,{isStreaming:e.isStreaming&&o===e.messages.length-1,showReasoning:t.showReasoning}))}
1707
+ <div class="chat-group-footer">
1708
+ <span class="chat-group-timestamp">${i}</span>
1709
+ </div>
1710
+ </div>
1711
+ </div>
1712
+ `}function ig(e){return e.length===0?k:h`
1713
+ <div class="chat-message-images">
1714
+ ${e.map(t=>h`
1715
+ <img
1716
+ src=${t.url}
1717
+ alt=${t.alt??"Attached image"}
1718
+ class="chat-message-image"
1719
+ @click=${()=>window.open(t.url,"_blank")}
1720
+ />
1721
+ `)}
1722
+ </div>
1723
+ `}function ic(e,t,n){const s=e,i=typeof s.role=="string"?s.role:"unknown",r=Ya(e)||i.toLowerCase()==="toolresult"||i.toLowerCase()==="tool_result"||typeof s.toolCallId=="string"||typeof s.tool_call_id=="string",a=Qf(e).length>0,l=eg(e),c=l.length>0,u=qa(e),p=t.showReasoning&&i==="assistant"?zu(e):null,d=u!=null&&u.trim()?u:null,f=p?Hu(p):null,b=d,w=(i==="assistant"||i==="user")&&!!(b!=null&&b.trim()),A=["chat-bubble",w?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!b&&(a||r)||!b&&!c?k:h`
1724
+ <div class="${A}">
1725
+ ${w?Yf(b):k}
1726
+ ${ig(l)}
1727
+ ${f?h`<div class="chat-thinking">${$i(Ri(f))}</div>`:k}
1728
+ ${b?h`<div class="chat-text">${$i(Ri(b))}</div>`:k}
1729
+ </div>
1730
+ `}function rg(e){return h`
1731
+ <div class="sidebar-panel">
1732
+ <div class="sidebar-header">
1733
+ <div class="sidebar-title">Tool Output</div>
1734
+ <button @click=${e.onClose} class="btn" title="Close sidebar">
1735
+ ${O.x}
1736
+ </button>
1737
+ </div>
1738
+ <div class="sidebar-content">
1739
+ ${e.error?h`
1740
+ <div class="callout danger">${e.error}</div>
1741
+ <button @click=${e.onViewRawText} class="btn" style="margin-top: 12px;">
1742
+ View Raw Text
1743
+ </button>
1744
+ `:e.content?h`<div class="sidebar-markdown">${$i(Ri(e.content))}</div>`:h`<div class="muted">No content available</div>`}
1745
+ </div>
1746
+ </div>
1747
+ `}var og=Object.defineProperty,ag=Object.getOwnPropertyDescriptor,ks=(e,t,n,s)=>{for(var i=s>1?void 0:s?ag(t,n):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&og(t,n,i),i};let Et=class extends kt{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,i=(e.clientX-this.startX)/n;let r=this.startRatio+i;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 h``}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)}};Et.styles=au`
1748
+ :host {
1749
+ width: 4px;
1750
+ cursor: col-resize;
1751
+ background: var(--border, #333);
1752
+ transition: background 150ms ease-out;
1753
+ flex-shrink: 0;
1754
+ position: relative;
1755
+ }
1756
+
1757
+ :host::before {
1758
+ content: "";
1759
+ position: absolute;
1760
+ top: 0;
1761
+ left: -4px;
1762
+ right: -4px;
1763
+ bottom: 0;
1764
+ }
1765
+
1766
+ :host(:hover) {
1767
+ background: var(--accent, #007bff);
1768
+ }
1769
+
1770
+ :host(.dragging) {
1771
+ background: var(--accent, #007bff);
1772
+ }
1773
+ `;ks([ps({type:Number})],Et.prototype,"splitRatio",2);ks([ps({type:Number})],Et.prototype,"minRatio",2);ks([ps({type:Number})],Et.prototype,"maxRatio",2);Et=ks([Ua("resizable-divider")],Et);function Nn(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function ni(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const lg=1,cg=1,ct="emoji",Tt="keyvalue",Cr="favorites",ug="tokens",rc="tokens",dg="unicode",oc="count",pg="group",hg="order",ac="group-order",Ii="eTag",os="url",aa="skinTone",Mt="readonly",_r="readwrite",lc="skinUnicodes",fg="skinUnicodes",gg="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",mg="en";function yg(e,t){const n=new Set,s=[];for(const i of e){const r=t(i);n.has(r)||(n.add(r),s.push(i))}return s}function la(e){return yg(e,t=>t.unicode)}function vg(e){function t(n,s,i){const r=s?e.createObjectStore(n,{keyPath:s}):e.createObjectStore(n);if(i)for(const[o,[a,l]]of Object.entries(i))r.createIndex(o,a,{multiEntry:l});return r}t(Tt),t(ct,dg,{[rc]:[ug,!0],[ac]:[[pg,hg]],[lc]:[fg,!0]}),t(Cr,void 0,{[oc]:[""]})}const Ni={},jn={},as={};function cc(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function bg(e){const t=await new Promise((n,s)=>{const i=indexedDB.open(e,lg);Ni[e]=i,i.onupgradeneeded=r=>{r.oldVersion<cg&&vg(i.result)},cc(n,s,i)});return t.onclose=()=>Mr(e),t}function wg(e){return jn[e]||(jn[e]=bg(e)),jn[e]}function Le(e,t,n,s){return new Promise((i,r)=>{const o=e.transaction(t,n,{durability:"relaxed"}),a=typeof t=="string"?o.objectStore(t):t.map(c=>o.objectStore(c));let l;s(a,o,c=>{l=c}),o.oncomplete=()=>i(l),o.onerror=()=>r(o.error)})}function Mr(e){const t=Ni[e],n=t&&t.result;if(n){n.close();const s=as[e];if(s)for(const i of s)i()}delete Ni[e],delete jn[e],delete as[e]}function kg(e){return new Promise((t,n)=>{Mr(e);const s=indexedDB.deleteDatabase(e);cc(t,n,s)})}function Sg(e,t){let n=as[e];n||(n=as[e]=[]),n.push(t)}const Ag=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 St(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||Ag.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const xg=2;function uc(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=xg)}function $g(e){return e.map(({annotation:n,emoticon:s,group:i,order:r,shortcodes:o,skins:a,tags:l,emoji:c,version:u})=>{const p=[...new Set(uc([...(o||[]).map(St).flat(),...(l||[]).map(St).flat(),...St(n),s]))].sort(),d={annotation:n,group:i,order:r,tags:l,tokens:p,unicode:c,version:u};if(s&&(d.emoticon=s),o&&(d.shortcodes=o),a){d.skinTones=[],d.skinUnicodes=[],d.skinVersions=[];for(const{tone:f,emoji:b,version:w}of a)d.skinTones.push(f),d.skinUnicodes.push(b),d.skinVersions.push(w)}return d})}function dc(e,t,n,s){e[t](n).onsuccess=i=>s&&s(i.target.result)}function rt(e,t,n){dc(e,"get",t,n)}function pc(e,t,n){dc(e,"getAll",t,n)}function Lr(e){e.commit&&e.commit()}function Eg(e,t){let n=e[0];for(let s=1;s<e.length;s++){const i=e[s];t(n)>t(i)&&(n=i)}return n}function hc(e,t){const n=Eg(e,i=>i.length),s=[];for(const i of n)e.some(r=>r.findIndex(o=>t(o)===t(i))===-1)||s.push(i);return s}async function Tg(e){return!await Pr(e,Tt,os)}async function Cg(e,t,n){const[s,i]=await Promise.all([Ii,os].map(r=>Pr(e,Tt,r)));return s===n&&i===t}async function _g(e,t){return Le(e,ct,Mt,(s,i,r)=>{let o;const a=()=>{s.getAll(o&&IDBKeyRange.lowerBound(o,!0),50).onsuccess=l=>{const c=l.target.result;for(const u of c)if(o=u.unicode,t(u))return r(u);if(c.length<50)return r();a()}};a()})}async function fc(e,t,n,s){{const i=$g(t);await Le(e,[ct,Tt],_r,([r,o],a)=>{let l,c,u=0;function p(){++u===2&&d()}function d(){if(!(l===s&&c===n)){r.clear();for(const f of i)r.put(f);o.put(s,Ii),o.put(n,os),Lr(a)}}rt(o,Ii,f=>{l=f,p()}),rt(o,os,f=>{c=f,p()})})}}async function Mg(e,t){return Le(e,ct,Mt,(n,s,i)=>{const r=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);pc(n.index(ac),r,i)})}async function gc(e,t){const n=uc(St(t));return n.length?Le(e,ct,Mt,(s,i,r)=>{const o=[],a=()=>{o.length===n.length&&l()},l=()=>{const c=hc(o,u=>u.unicode);r(c.sort((u,p)=>u.order<p.order?-1:1))};for(let c=0;c<n.length;c++){const u=n[c],p=c===n.length-1?IDBKeyRange.bound(u,u+"￿",!1,!0):IDBKeyRange.only(u);pc(s.index(rc),p,d=>{o.push(d),a()})}}):[]}async function Lg(e,t){const n=await gc(e,t);return n.length?n.filter(s=>(s.shortcodes||[]).map(r=>r.toLowerCase()).includes(t.toLowerCase()))[0]||null:await _g(e,i=>(i.shortcodes||[]).includes(t.toLowerCase()))||null}async function Pg(e,t){return Le(e,ct,Mt,(n,s,i)=>rt(n,t,r=>{if(r)return i(r);rt(n.index(lc),t,o=>i(o||null))}))}function Pr(e,t,n){return Le(e,t,Mt,(s,i,r)=>rt(s,n,r))}function Rg(e,t,n,s){return Le(e,t,_r,(i,r)=>{i.put(s,n),Lr(r)})}function Ig(e,t){return Le(e,Cr,_r,(n,s)=>rt(n,t,i=>{n.put((i||0)+1,t),Lr(s)}))}function Ng(e,t,n){return n===0?[]:Le(e,[Cr,ct],Mt,([s,i],r,o)=>{const a=[];s.index(oc).openCursor(void 0,"prev").onsuccess=l=>{const c=l.target.result;if(!c)return o(a);function u(f){if(a.push(f),a.length===n)return o(a);c.continue()}const p=c.primaryKey,d=t.byName(p);if(d)return u(d);rt(i,p,f=>{if(f)return u(f);c.continue()})}})}const Dn="";function Dg(e,t){const n=new Map;for(const i of e){const r=t(i);for(const o of r){let a=n;for(let c=0;c<o.length;c++){const u=o.charAt(c);let p=a.get(u);p||(p=new Map,a.set(u,p)),a=p}let l=a.get(Dn);l||(l=[],a.set(Dn,l)),l.push(i)}}return(i,r)=>{let o=n;for(let c=0;c<i.length;c++){const u=i.charAt(c),p=o.get(u);if(p)o=p;else return[]}if(r)return o.get(Dn)||[];const a=[],l=[o];for(;l.length;){const u=[...l.shift().entries()].sort((p,d)=>p[0]<d[0]?-1:1);for(const[p,d]of u)p===Dn?a.push(...d):l.push(d)}return a}}const Og=["name","url"];function Bg(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||Og.some(s=>!(s in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function ca(e){Bg(e);const t=(d,f)=>d.name.toLowerCase()<f.name.toLowerCase()?-1:1,n=e.sort(t),i=Dg(e,d=>{const f=new Set;if(d.shortcodes)for(const b of d.shortcodes)for(const w of St(b))f.add(w);return f}),r=d=>i(d,!0),o=d=>i(d,!1),a=d=>{const f=St(d),b=f.map((w,A)=>(A<f.length-1?r:o)(w));return hc(b,w=>w.name).sort(t)},l=new Map,c=new Map;for(const d of e){c.set(d.name.toLowerCase(),d);for(const f of d.shortcodes||[])l.set(f.toLowerCase(),d)}return{all:n,search:a,byShortcode:d=>l.get(d.toLowerCase()),byName:d=>c.get(d.toLowerCase())}}const Fg=typeof wrappedJSObject<"u";function Ht(e){if(!e)return e;if(Fg&&(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 mc(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Ug=["annotation","emoji","group","order","version"];function Wg(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Ug.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function yc(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Kg(e){const t=await fetch(e,{method:"HEAD"});yc(t,e);const n=t.headers.get("etag");return mc(n),n}async function Di(e){const t=await fetch(e);yc(t,e);const n=t.headers.get("etag");mc(n);const s=await t.json();return Wg(s),[n,s]}function zg(e){for(var t="",n=new Uint8Array(e),s=n.byteLength,i=-1;++i<s;)t+=String.fromCharCode(n[i]);return t}function jg(e){for(var t=e.length,n=new ArrayBuffer(t),s=new Uint8Array(n),i=-1;++i<t;)s[i]=e.charCodeAt(i);return n}async function vc(e){const t=JSON.stringify(e);let n=jg(t);const s=await crypto.subtle.digest("SHA-1",n),i=zg(s);return btoa(i)}async function Hg(e,t){let n,s=await Kg(t);if(!s){const i=await Di(t);s=i[0],n=i[1],s||(s=await vc(n))}await Cg(e,t,s)||(n||(n=(await Di(t))[1]),await fc(e,n,t,s))}async function qg(e,t){let[n,s]=await Di(t);n||(n=await vc(s)),await fc(e,s,t,n)}async function Gg(e,t){try{await Hg(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class Vg{constructor({dataSource:t=gg,locale:n=mg,customEmoji:s=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=ca(s),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await wg(this._dbName);Sg(this._dbName,this._clear);const n=this.dataSource;await Tg(t)?await qg(t,n):this._lazyUpdate=Gg(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 ni(t),await this.ready(),la(await Mg(this._db,t)).map(Ht)}async getEmojiBySearchQuery(t){Nn(t),await this.ready();const n=this._custom.search(t),s=la(await gc(this._db,t)).map(Ht);return[...n,...s]}async getEmojiByShortcode(t){Nn(t),await this.ready();const n=this._custom.byShortcode(t);return n||Ht(await Lg(this._db,t))}async getEmojiByUnicodeOrName(t){Nn(t),await this.ready();const n=this._custom.byName(t);return n||Ht(await Pg(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Pr(this._db,Tt,aa)||0}async setPreferredSkinTone(t){return ni(t),await this.ready(),Rg(this._db,Tt,aa,t)}async incrementFavoriteEmojiCount(t){return Nn(t),await this.ready(),Ig(this._db,t)}async getTopFavoriteEmoji(t){return ni(t),await this.ready(),(await Ng(this._db,this._custom,t)).map(Ht)}set customEmoji(t){this._custom=ca(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 Mr(this._dbName)}async delete(){await this._shutdown(),await kg(this._dbName)}}const Oi=[[-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})),si=Oi.slice(1),Yg=2,ua=6,bc=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function da(e){return e.unicode.includes("‍")}const Qg={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},Xg=1e3,Zg="🖐️",Jg=8,em=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],wc='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',tm=(e,t)=>e<t?-1:e>t?1:0,pa=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const s=n.getContext("2d",{willReadFrequently:!0});return s.textBaseline="top",s.font=`100px ${wc}`,s.fillStyle=t,s.scale(.01,.01),s.fillText(e,0,0),s.getImageData(0,0,1,1).data},nm=(e,t)=>{const n=[...e].join(","),s=[...t].join(",");return n===s&&!n.startsWith("0,0,0,")};function sm(e){const t=pa(e,"#000"),n=pa(e,"#fff");return t&&n&&nm(t,n)}function im(){const e=Object.entries(Qg);try{for(const[t,n]of e)if(sm(t))return n}catch{}return e[0][1]}let ii;const ri=()=>(ii||(ii=new Promise(e=>bc(()=>e(im())))),ii),Bi=new Map,rm="️",om="\uD83C",am="‍",lm=127995,cm=57339;function um(e,t){if(t===0)return e;const n=e.indexOf(am);return n!==-1?e.substring(0,n)+String.fromCodePoint(lm+t-1)+e.substring(n):(e.endsWith(rm)&&(e=e.substring(0,e.length-1)),e+om+String.fromCodePoint(cm+t-1))}function we(e){e.preventDefault(),e.stopPropagation()}function oi(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function kc(e,t){const n=new Set,s=[];for(const i of e){const r=t(i);n.has(r)||(n.add(r),s.push(i))}return s}function dm(e,t){const n=s=>{const i={};for(const r of s)typeof r.tone=="number"&&r.version<=t&&(i[r.tone]=r.unicode);return i};return e.map(({unicode:s,skins:i,shortcodes:r,url:o,name:a,category:l,annotation:c})=>({unicode:s,name:a,shortcodes:r,url:o,category:l,annotation:c,id:s||a,skins:i&&n(i)}))}const Hn=requestAnimationFrame;let pm=typeof ResizeObserver=="function";function hm(e,t,n){let s;pm?(s=new ResizeObserver(n),s.observe(e)):Hn(n),t.addEventListener("abort",()=>{s&&s.disconnect()})}function ha(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let ai;function fm(e,t,n){let s=!0,i=!1;for(const r of e){const o=n(r);if(!o)continue;const a=ha(o);a===0&&(i=!0),typeof ai>"u"&&(ai=ha(t));const l=a/1.8<ai;Bi.set(r.unicode,l),l||(s=!1)}return i&&console.warn(`Emoji support detection failed - emoji character is 0 width.
1774
+ This is likely due to using \`display:none\` which is unsupported.
1775
+ If this is a Jest/Vitest environment, you can ignore this warning.
1776
+ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),s}function gm(e){return kc(e,t=>t)}function mm(e){e&&(e.scrollTop=0)}function tn(e,t,n){let s=e.get(t);return s||(s=n(),e.set(t,s)),s}function fa(e){return""+e}function ym(e){const t=document.createElement("template");return t.innerHTML=e,t}const vm=new WeakMap,bm=new WeakMap,wm=Symbol("un-keyed"),km="replaceChildren"in Element.prototype;function Sm(e,t){km?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function Am(e,t){let n=e.firstChild,s=0;for(;n;){if(t[s]!==n)return!0;n=n.nextSibling,s++}return s!==t.length}function xm(e,t){const{targetNode:n}=t;let{targetParentNode:s}=t,i=!1;s?i=Am(s,e):(i=!0,t.targetNode=void 0,t.targetParentNode=s=n.parentNode),i&&Sm(s,e)}function $m(e,t){for(const n of t){const{targetNode:s,currentExpression:i,binding:{expressionIndex:r,attributeName:o,attributeValuePre:a,attributeValuePost:l}}=n,c=e[r];if(i!==c)if(n.currentExpression=c,o)if(c===null)s.removeAttribute(o);else{const u=a+fa(c)+l;s.setAttribute(o,u)}else{let u;Array.isArray(c)?xm(c,n):c instanceof Element?(u=c,s.replaceWith(u)):s.nodeValue=fa(c),u&&(n.targetNode=u)}}}function Em(e){let t="",n=!1,s=!1,i=-1;const r=new Map,o=[];let a=0;for(let c=0,u=e.length;c<u;c++){const p=e[c];if(t+=p.slice(a),c===u-1)break;for(let x=0;x<p.length;x++)switch(p.charAt(x)){case"<":{p.charAt(x+1)==="/"?o.pop():(n=!0,o.push(++i));break}case">":{n=!1,s=!1;break}case"=":{s=!0;break}}const d=o[o.length-1],f=tn(r,d,()=>[]);let b,w,A;if(s){const x=/(\S+)="?([^"=]*)$/.exec(p);b=x[1],w=x[2];const E=/^([^">]*)("?)/.exec(e[c+1]);A=E[1],t=t.slice(0,-1*x[0].length),a=E[0].length}else a=0;const T={attributeName:b,attributeValuePre:w,attributeValuePost:A,expressionIndex:c};f.push(T),!n&&!s&&(t+=" ")}return{template:ym(t),elementsToBindings:r}}function ga(e,t,n){for(let s=0;s<e.length;s++){const i=e[s],r=i.attributeName?t:t.firstChild,o={binding:i,targetNode:r,targetParentNode:void 0,currentExpression:void 0};n.push(o)}}function Tm(e,t){const n=[];let s;if(t.size===1&&(s=t.get(0)))ga(s,e,n);else{const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let r=e,o=-1;do{const a=t.get(++o);a&&ga(a,r,n)}while(r=i.nextNode())}return n}function Cm(e){const{template:t,elementsToBindings:n}=tn(vm,e,()=>Em(e)),s=t.cloneNode(!0).content.firstElementChild,i=Tm(s,n);return function(o){return $m(o,i),s}}function _m(e){const t=tn(bm,e,()=>new Map);let n=wm;function s(r,...o){const a=tn(t,r,()=>new Map);return tn(a,n,()=>Cm(r))(o)}function i(r,o,a){return r.map((l,c)=>{const u=n;n=a(l);try{return o(l,c)}finally{n=u}})}return{map:i,html:s}}function Mm(e,t,n,s,i,r,o,a,l){const{labelWithSkin:c,titleForEmoji:u,unicodeWithSkin:p}=n,{html:d,map:f}=_m(t);function b(x,E,C){return f(x,(R,U)=>d`<button role="${E?"option":"menuitem"}" aria-selected="${E?U===t.activeSearchItem:null}" aria-label="${c(R,t.currentSkinTone)}" title="${u(R)}" class="${"emoji"+(E&&U===t.activeSearchItem?" active":"")+(R.unicode?"":" custom-emoji")}" id="${`${C}-${R.id}`}" style="${R.unicode?null:`--custom-emoji-background: url(${JSON.stringify(R.url)})`}">${R.unicode?p(R,t.currentSkinTone):""}</button>`,R=>`${C}-${R.id}`)}const A=d`<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">${f(t.skinTones,(x,E)=>d`<div id="skintone-${E}" class="emoji ${E===t.activeSkinTone?"active":""}" aria-selected="${E===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[E]}" aria-label="${t.i18n.skinTones[E]}">${x}</div>`,x=>x)}</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">${f(t.groups,x=>d`<button role="tab" class="nav-button" aria-controls="tab-${x.id}" aria-label="${t.i18n.categories[x.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===x.id}" title="${t.i18n.categories[x.name]}" data-group-id="${x.id}"><div class="nav-emoji emoji">${x.emoji}</div></button>`,x=>x.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">${f(t.currentEmojisWithCategories,(x,E)=>d`<div><div id="menu-label-${E}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:x.category?x.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${E!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(x.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${E}" id="${t.searchMode?"search-results":null}">${b(x.emojis,t.searchMode,"emo")}</div></div>`,x=>x.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${b(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,T=(x,E)=>{for(const C of e.querySelectorAll(`[${x}]`))E(C,C.getAttribute(x))};if(l){e.appendChild(A);for(const x of["click","focusout","input","keydown","keyup"])T(`data-on-${x}`,(E,C)=>{E.addEventListener(x,s[C])});T("data-ref",(x,E)=>{r[E]=x}),o.addEventListener("abort",()=>{e.removeChild(A)})}T("data-action",(x,E)=>{let C=a.get(E);C||a.set(E,C=new WeakSet),C.has(x)||(C.add(x),i[E](x))})}const ls=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Lm(e){let t=!1,n;const s=new Map,i=new Set;let r;const o=()=>{if(t)return;const c=[...i];i.clear();try{for(const u of c)u()}finally{r=!1,i.size&&(r=!0,ls(o))}},a=new Proxy({},{get(c,u){if(n){let p=s.get(u);p||(p=new Set,s.set(u,p)),p.add(n)}return c[u]},set(c,u,p){if(c[u]!==p){c[u]=p;const d=s.get(u);if(d){for(const f of d)i.add(f);r||(r=!0,ls(o))}}return!0}}),l=c=>{const u=()=>{const p=n;n=u;try{return c()}finally{n=p}};return u()};return e.addEventListener("abort",()=>{t=!0}),{state:a,createEffect:l}}function li(e,t,n){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!n(e[s],t[s]))return!1;return!0}const ma=new WeakMap;function Pm(e,t,n){{const s=e.closest(".tabpanel");let i=ma.get(s);i||(i=new IntersectionObserver(n,{root:s,rootMargin:"50% 0px 50% 0px",threshold:0}),ma.set(s,i),t.addEventListener("abort",()=>{i.disconnect()})),i.observe(e)}}const ci=[],{assign:On}=Object;function Rm(e,t){const n={},s=new AbortController,i=s.signal,{state:r,createEffect:o}=Lm(i),a=new Map;On(r,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),On(r,t),On(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:Jg,isRtl:!1,currentGroupIndex:0,groups:si,databaseLoaded:!1,activeSearchItemId:void 0}),o(()=>{r.currentGroup!==r.groups[r.currentGroupIndex]&&(r.currentGroup=r.groups[r.currentGroupIndex])});const l=S=>{e.getElementById(S).focus()},c=S=>e.getElementById(`emo-${S.id}`),u=(S,_)=>{n.rootElement.dispatchEvent(new CustomEvent(S,{detail:_,bubbles:!0,composed:!0}))},p=(S,_)=>S.id===_.id,d=(S,_)=>{const{category:I,emojis:N}=S,{category:H,emojis:K}=_;return I!==H?!1:li(N,K,p)},f=S=>{li(r.currentEmojis,S,p)||(r.currentEmojis=S)},b=S=>{r.searchMode!==S&&(r.searchMode=S)},w=S=>{li(r.currentEmojisWithCategories,S,d)||(r.currentEmojisWithCategories=S)},A=(S,_)=>_&&S.skins&&S.skins[_]||S.unicode,E={labelWithSkin:(S,_)=>gm([S.name||A(S,_),S.annotation,...S.shortcodes||ci].filter(Boolean)).join(", "),titleForEmoji:S=>S.annotation||(S.shortcodes||ci).join(", "),unicodeWithSkin:A},C={onClickSkinToneButton:j,onEmojiClick:yn,onNavClick:gn,onNavKeydown:Es,onSearchKeydown:$s,onSkinToneOptionsClick:vn,onSkinToneOptionsFocusOut:Pe,onSkinToneOptionsKeydown:He,onSkinToneOptionsKeyup:Rt,onSearchInput:bn},R={calculateEmojiGridStyle:ze,updateOnIntersection:Lt};let U=!0;o(()=>{Mm(e,r,E,C,R,n,i,a,U),U=!1}),r.emojiVersion||ri().then(S=>{S||(r.message=r.i18n.emojiUnsupportedMessage)}),o(()=>{async function S(){let _=!1;const I=setTimeout(()=>{_=!0,r.message=r.i18n.loadingMessage},Xg);try{await r.database.ready(),r.databaseLoaded=!0}catch(N){console.error(N),r.message=r.i18n.networkErrorMessage}finally{clearTimeout(I),_&&(_=!1,r.message="")}}r.database&&S()}),o(()=>{r.pickerStyle=`
1777
+ --num-groups: ${r.groups.length};
1778
+ --indicator-opacity: ${r.searchMode?0:1};
1779
+ --num-skintones: ${ua};`}),o(()=>{r.customEmoji&&r.database&&Y()}),o(()=>{r.customEmoji&&r.customEmoji.length?r.groups!==Oi&&(r.groups=Oi):r.groups!==si&&(r.currentGroupIndex&&r.currentGroupIndex--,r.groups=si)}),o(()=>{async function S(){r.databaseLoaded&&(r.currentSkinTone=await r.database.getPreferredSkinTone())}S()}),o(()=>{r.skinTones=Array(ua).fill().map((S,_)=>um(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 S(){const{database:_}=r,I=(await Promise.all(em.map(N=>_.getEmojiByUnicodeOrName(N)))).filter(Boolean);r.defaultFavoriteEmojis=I}r.databaseLoaded&&S()});function Y(){const{customEmoji:S,database:_}=r,I=S||ci;_.customEmoji!==I&&(_.customEmoji=I)}o(()=>{async function S(){Y();const{database:_,defaultFavoriteEmojis:I,numColumns:N}=r,H=await _.getTopFavoriteEmoji(N),K=await je(kc([...H,...I],ie=>ie.unicode||ie.name).slice(0,N));r.currentFavorites=K}r.databaseLoaded&&r.defaultFavoriteEmojis&&S()});function ze(S){hm(S,i,()=>{{const _=getComputedStyle(n.rootElement),I=parseInt(_.getPropertyValue("--num-columns"),10),N=_.getPropertyValue("direction")==="rtl";r.numColumns=I,r.isRtl=N}})}function Lt(S){Pm(S,i,_=>{for(const{target:I,isIntersecting:N}of _)I.classList.toggle("onscreen",N)})}o(()=>{async function S(){const{searchText:_,currentGroup:I,databaseLoaded:N,customEmoji:H}=r;if(!N)r.currentEmojis=[],r.searchMode=!1;else if(_.length>=Yg){const K=await xs(_);r.searchText===_&&(f(K),b(!0))}else{const{id:K}=I;if(K!==-1||H&&H.length){const ie=await As(K);r.currentGroup.id===K&&(f(ie),b(!1))}}}S()});const fn=()=>{Hn(()=>mm(n.tabpanelElement))};o(()=>{const{currentEmojis:S,emojiVersion:_}=r,I=S.filter(N=>N.unicode).filter(N=>da(N)&&!Bi.has(N.unicode));if(!_&&I.length)f(S),Hn(()=>J(I));else{const N=_?S:S.filter(Pt);f(N),fn()}});function J(S){fm(S,n.baselineEmoji,c)?fn():r.currentEmojis=[...r.currentEmojis]}function Pt(S){return!S.unicode||!da(S)||Bi.get(S.unicode)}async function ut(S){const _=r.emojiVersion||await ri();return S.filter(({version:I})=>!I||I<=_)}async function je(S){return dm(S,r.emojiVersion||await ri())}async function As(S){const _=S===-1?r.customEmoji:await r.database.getEmojiByGroup(S);return je(await ut(_))}async function xs(S){return je(await ut(await r.database.getEmojiBySearchQuery(S)))}o(()=>{}),o(()=>{function S(){const{searchMode:I,currentEmojis:N}=r;if(I)return[{category:"",emojis:N}];const H=new Map;for(const K of N){const ie=K.category||"";let Re=H.get(ie);Re||(Re=[],H.set(ie,Re)),Re.push(K)}return[...H.entries()].map(([K,ie])=>({category:K,emojis:ie})).sort((K,ie)=>r.customCategorySorting(K.category,ie.category))}const _=S();w(_)}),o(()=>{r.activeSearchItemId=r.activeSearchItem!==-1&&r.currentEmojis[r.activeSearchItem].id}),o(()=>{const{rawSearchText:S}=r;bc(()=>{r.searchText=(S||"").trim(),r.activeSearchItem=-1})});function $s(S){if(!r.searchMode||!r.currentEmojis.length)return;const _=I=>{we(S),r.activeSearchItem=oi(I,r.activeSearchItem,r.currentEmojis)};switch(S.key){case"ArrowDown":return _(!1);case"ArrowUp":return _(!0);case"Enter":if(r.activeSearchItem===-1)r.activeSearchItem=0;else return we(S),G(r.currentEmojis[r.activeSearchItem].id)}}function gn(S){const{target:_}=S,I=_.closest(".nav-button");if(!I)return;const N=parseInt(I.dataset.groupId,10);n.searchElement.value="",r.rawSearchText="",r.searchText="",r.activeSearchItem=-1,r.currentGroupIndex=r.groups.findIndex(H=>H.id===N)}function Es(S){const{target:_,key:I}=S,N=H=>{H&&(we(S),H.focus())};switch(I){case"ArrowLeft":return N(_.previousElementSibling);case"ArrowRight":return N(_.nextElementSibling);case"Home":return N(_.parentElement.firstElementChild);case"End":return N(_.parentElement.lastElementChild)}}async function mn(S){const _=await r.database.getEmojiByUnicodeOrName(S),I=[...r.currentEmojis,...r.currentFavorites].find(H=>H.id===S),N=I.unicode&&A(I,r.currentSkinTone);return await r.database.incrementFavoriteEmojiCount(S),{emoji:_,skinTone:r.currentSkinTone,...N&&{unicode:N},...I.name&&{name:I.name}}}async function G(S){const _=mn(S);u("emoji-click-sync",_),u("emoji-click",await _)}function yn(S){const{target:_}=S;if(!_.classList.contains("emoji"))return;we(S);const I=_.id.substring(4);G(I)}function V(S){r.currentSkinTone=S,r.skinTonePickerExpanded=!1,l("skintone-button"),u("skin-tone-change",{skinTone:S}),r.database.setPreferredSkinTone(S)}function vn(S){const{target:{id:_}}=S,I=_&&_.match(/^skintone-(\d)/);if(!I)return;we(S);const N=parseInt(I[1],10);V(N)}function j(S){r.skinTonePickerExpanded=!r.skinTonePickerExpanded,r.activeSkinTone=r.currentSkinTone,r.skinTonePickerExpanded&&(we(S),Hn(()=>l("skintone-list")))}o(()=>{r.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{r.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):r.skinTonePickerExpandedAfterAnimation=!1});function He(S){if(!r.skinTonePickerExpanded)return;const _=async I=>{we(S),r.activeSkinTone=I};switch(S.key){case"ArrowUp":return _(oi(!0,r.activeSkinTone,r.skinTones));case"ArrowDown":return _(oi(!1,r.activeSkinTone,r.skinTones));case"Home":return _(0);case"End":return _(r.skinTones.length-1);case"Enter":return we(S),V(r.activeSkinTone);case"Escape":return we(S),r.skinTonePickerExpanded=!1,l("skintone-button")}}function Rt(S){if(r.skinTonePickerExpanded&&S.key===" ")return we(S),V(r.activeSkinTone)}async function Pe(S){const{relatedTarget:_}=S;(!_||_.id!=="skintone-list")&&(r.skinTonePickerExpanded=!1)}function bn(S){r.rawSearchText=S.target.value}return{$set(S){On(r,S)},$destroy(){s.abort()}}}const Im="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Nm="en";var Dm={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"}},Om=':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 Sc=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Bm=`:host{--emoji-font-family:${wc}}`;class Rr extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Om+Bm,this.shadowRoot.appendChild(n),this._ctx={locale:Nm,dataSource:Im,skinToneEmoji:Zg,customCategorySorting:tm,customEmoji:null,i18n:Dm,emojiVersion:null,...t};for(const s of Sc)s!=="database"&&Object.prototype.hasOwnProperty.call(this,s)&&(this._ctx[s]=this[s],delete this[s]);this._dbFlush()}connectedCallback(){ya(this),this._cmp||(this._cmp=Rm(this.shadowRoot,this._ctx))}disconnectedCallback(){ya(this),ls(()=>{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,s){this._set(t.replace(/-([a-z])/g,(i,r)=>r.toUpperCase()),t==="emoji-version"?parseFloat(s):s)}_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:s}=this._ctx;(!s||s.locale!==t||s.dataSource!==n)&&this._set("database",new Vg({locale:t,dataSource:n}))}_dbFlush(){ls(()=>this._dbCreate())}}const Ac={};for(const e of Sc)Ac[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(Rr.prototype,Ac);function ya(e){e instanceof Rr||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Rr);function Fm(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 va(e){e.style.height="44px",e.style.overflowY="hidden"}const Um=5e3;function Wm(e){return e?e.active?h`
1780
+ <div class="callout info compaction-indicator compaction-indicator--active">
1781
+ ${O.loader} Compacting context...
1782
+ </div>
1783
+ `:e.completedAt&&Date.now()-e.completedAt<Um?h`
1784
+ <div class="callout success compaction-indicator compaction-indicator--complete">
1785
+ ${O.check} Context compacted
1786
+ </div>
1787
+ `:k:k}const Vt=5*1024*1024;function Yt(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function vt(e,t){var s,i,r;let n=(s=e.closest(".chat"))==null?void 0:s.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=(i=e.closest(".chat"))==null?void 0:i.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 Km=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function zm(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function jm(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||Km.test(e.name)}function Hm(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function qm(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function Gm(e,t){var i;e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const s=(i=e.dataTransfer)==null?void 0:i.files;if(!(!s||s.length===0))for(let r=0;r<s.length;r++){const o=s[r];if(zm(o)){if(!t.onAttachmentsChange)continue;if(o.size>Vt){vt(n,`Image too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const l=a.result,c={id:Yt(),dataUrl:l,mimeType:o.type},u=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...u,c])},a.readAsDataURL(o)}else if(jm(o)){if(!t.onAttachmentsChange)continue;if(o.size>Vt){vt(n,`File too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const l=a.result,c={id:Yt(),dataUrl:"",mimeType:o.type||"text/plain",fileName:o.name,textContent:l},u=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...u,c])},a.readAsText(o)}else if(Hm(o)){if(!t.onAttachmentsChange)continue;if(o.size>Vt){vt(n,`PDF too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const l=a.result,c={id:Yt(),dataUrl:l,mimeType:"application/pdf",fileName:o.name},u=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...u,c])},a.readAsDataURL(o)}else if(qm(o)){if(!t.onAttachmentsChange)continue;if(o.size>Vt){vt(n,`Video too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const l=a.result,c={id:Yt(),dataUrl:l,mimeType:o.type||"video/mp4",fileName:o.name},u=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...u,c])},a.readAsDataURL(o)}else vt(n,`Unsupported file type: ${o.name}. Use the Files page to upload to workspace.`)}}function Vm(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Ym(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function Qm(e,t){var i,r,o;const n=(i=e.clipboardData)==null?void 0:i.items;if(!n||!t.onAttachmentsChange)return;const s=[];for(let a=0;a<n.length;a++){const l=n[a];(l.type.startsWith("image/")||l.type.startsWith("video/"))&&s.push(l)}if(s.length!==0){e.preventDefault();for(const a of s){const l=a.getAsFile();if(!l)continue;const c=l.type.startsWith("video/")?"Video":"Image";if(l.size>Vt){const p=((o=(r=e.target)==null?void 0:r.closest)==null?void 0:o.call(r,".chat"))??document.querySelector(".chat");p&&vt(p,`${c} too large (${(l.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const u=new FileReader;u.onload=()=>{var w;const p=u.result,d=l.type.startsWith("video/"),f={id:Yt(),dataUrl:p,mimeType:l.type,fileName:d?l.name||"video.mp4":void 0},b=t.attachments??[];(w=t.onAttachmentsChange)==null||w.call(t,[...b,f])},u.readAsDataURL(l)}}}function Xm(e){const t=e.currentTarget,n=t.closest(".chat-compose"),s=n==null?void 0:n.querySelector(".emoji-picker-popup");if(!s)return;const i=s.classList.toggle("active");if(t.classList.toggle("active",i),i){const r=o=>{s.contains(o.target)||t.contains(o.target)||(s.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",r,!0))};requestAnimationFrame(()=>document.addEventListener("click",r,!0))}}function Zm(e,t){const n=e.detail,s=n==null?void 0:n.unicode;if(!s)return;const i=e.currentTarget.closest(".chat-compose"),r=i==null?void 0:i.querySelector("textarea");if(!r)return;const o=r.selectionStart??t.draft.length,a=r.selectionEnd??o,l=t.draft.slice(0,o),c=t.draft.slice(a);t.onDraftChange(l+s+c);const u=i==null?void 0:i.querySelector(".emoji-picker-popup"),p=i==null?void 0:i.querySelector(".chat-compose__emoji");u==null||u.classList.remove("active"),p==null||p.classList.remove("active"),requestAnimationFrame(()=>{r.focus();const d=o+s.length;r.setSelectionRange(d,d)})}function Jm(e){const t=e.attachments??[];return t.length===0?k:h`
1788
+ <div class="chat-attachments">
1789
+ ${t.map(n=>{var s;return n.fileName?h`
1790
+ <div class="chat-attachment chat-attachment--file">
1791
+ <span class="chat-attachment__icon">${(s=n.mimeType)!=null&&s.startsWith("video/")?O.film:O.fileText}</span>
1792
+ <span class="chat-attachment__name" title=${n.fileName}>${n.fileName}</span>
1793
+ <button
1794
+ class="chat-attachment__remove chat-attachment__remove--file"
1795
+ type="button"
1796
+ aria-label="Remove attachment"
1797
+ @click=${()=>{var r;const i=(e.attachments??[]).filter(o=>o.id!==n.id);(r=e.onAttachmentsChange)==null||r.call(e,i)}}
1798
+ >
1799
+ ${O.x}
1800
+ </button>
1801
+ </div>
1802
+ `:h`
1803
+ <div class="chat-attachment">
1804
+ <img
1805
+ src=${n.dataUrl}
1806
+ alt="Attachment preview"
1807
+ class="chat-attachment__img"
1808
+ />
1809
+ <button
1810
+ class="chat-attachment__remove"
1811
+ type="button"
1812
+ aria-label="Remove attachment"
1813
+ @click=${()=>{var r;const i=(e.attachments??[]).filter(o=>o.id!==n.id);(r=e.onAttachmentsChange)==null||r.call(e,i)}}
1814
+ >
1815
+ ${O.x}
1816
+ </button>
1817
+ </div>
1818
+ `})}
1819
+ </div>
1820
+ `}function ey(e){var d,f,b;const t=e.connected,n=e.sending||e.stream!==null,s=!!(e.canAbort&&e.onAbort),i=(f=(d=e.sessions)==null?void 0:d.sessions)==null?void 0:f.find(w=>w.key===e.sessionKey),r=(i==null?void 0:i.reasoningLevel)??"off",o=e.showThinking&&r!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const a=(((b=e.attachments)==null?void 0:b.length)??0)>0,l=e.connected?a?"Add a message...":"Message...":"Connecting…",c=e.splitRatio??.6,u=!!(e.sidebarOpen&&e.onCloseSidebar),p=h`
1821
+ <div
1822
+ class="chat-thread"
1823
+ role="log"
1824
+ aria-live="polite"
1825
+ @scroll=${e.onChatScroll}
1826
+ >
1827
+ ${e.loading?h`<div class="muted">Loading chat…</div>`:k}
1828
+ ${Lh(ay(e),w=>w.key,w=>w.kind==="reading-indicator"?tg():w.kind==="stream"?ng(w.text,w.startedAt,e.onOpenSidebar):w.kind==="group"?sg(w,{onOpenSidebar:e.onOpenSidebar,showReasoning:o,assistantName:e.assistantName}):k)}
1829
+ </div>
1830
+ `;return h`
1831
+ <section
1832
+ class="card chat"
1833
+ @drop=${w=>Gm(w,e)}
1834
+ @dragover=${Vm}
1835
+ @dragleave=${Ym}
1836
+ >
1837
+ ${e.disabledReason?h`<div class="callout">${e.disabledReason}</div>`:k}
1838
+
1839
+ ${e.error?h`<div class="callout danger">${e.error}</div>`:k}
1840
+
1841
+ ${Wm(e.compactionStatus)}
1842
+
1843
+ ${e.focusMode?h`
1844
+ <button
1845
+ class="chat-focus-exit"
1846
+ type="button"
1847
+ @click=${e.onToggleFocusMode}
1848
+ aria-label="Exit focus mode"
1849
+ title="Exit focus mode"
1850
+ >
1851
+ ${O.x}
1852
+ </button>
1853
+ `:k}
1854
+
1855
+ <div
1856
+ class="chat-split-container ${u?"chat-split-container--open":""}"
1857
+ >
1858
+ <div
1859
+ class="chat-main"
1860
+ style="flex: ${u?`0 0 ${c*100}%`:"1 1 100%"}"
1861
+ >
1862
+ ${p}
1863
+ ${e.nearBottom===!1?h`
1864
+ <button
1865
+ class="chat-scroll-bottom"
1866
+ type="button"
1867
+ @click=${w=>{const A=w.currentTarget.closest(".chat-main"),T=A==null?void 0:A.querySelector(".chat-thread");T&&T.scrollTo({top:T.scrollHeight,behavior:"smooth"})}}
1868
+ aria-label="Scroll to bottom"
1869
+ title="Scroll to bottom"
1870
+ >
1871
+ ${O.chevronDown}
1872
+ </button>
1873
+ `:k}
1874
+ </div>
1875
+
1876
+ ${u?h`
1877
+ <resizable-divider
1878
+ .splitRatio=${c}
1879
+ @resize=${w=>{var A;return(A=e.onSplitRatioChange)==null?void 0:A.call(e,w.detail.splitRatio)}}
1880
+ ></resizable-divider>
1881
+ <div class="chat-sidebar">
1882
+ ${rg({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
1883
+ ${e.sidebarContent}
1884
+ \`\`\``)}})}
1885
+ </div>
1886
+ `:k}
1887
+ </div>
1888
+
1889
+ <div class="chat-compose">
1890
+ ${Jm(e)}
1891
+ <div class="chat-compose__row">
1892
+ <button
1893
+ class="chat-compose__emoji"
1894
+ type="button"
1895
+ @click=${Xm}
1896
+ aria-label="Emoji"
1897
+ title="Emoji"
1898
+ >
1899
+ ${O.smile}
1900
+ </button>
1901
+ <label class="field chat-compose__field">
1902
+ <span>Message</span>
1903
+ <textarea
1904
+ .value=${e.draft}
1905
+ ?disabled=${!e.connected}
1906
+ @keydown=${w=>{w.key==="Enter"&&(w.isComposing||w.keyCode===229||w.shiftKey||e.connected&&(w.preventDefault(),t&&(e.onSend(),va(w.target))))}}
1907
+ @input=${w=>{const A=w.target;e.onDraftChange(A.value),Fm(A)}}
1908
+ @paste=${w=>Qm(w,e)}
1909
+ placeholder=${l}
1910
+ ></textarea>
1911
+ </label>
1912
+ ${s?h`
1913
+ <button
1914
+ class="btn btn--icon chat-compose__send"
1915
+ @click=${e.onAbort}
1916
+ aria-label="Stop"
1917
+ title="Stop generating"
1918
+ >
1919
+ ${O.square}
1920
+ </button>
1921
+ `:k}
1922
+ <button
1923
+ class="btn btn--icon chat-compose__send primary"
1924
+ ?disabled=${!e.connected}
1925
+ @click=${w=>{var T;e.onSend();const A=(T=w.target.closest(".chat-compose"))==null?void 0:T.querySelector("textarea");A&&va(A)}}
1926
+ aria-label="${n?"Queue":"Send"}"
1927
+ title="${n?"Queue message":"Send (Enter)"}"
1928
+ >
1929
+ ${O.send}
1930
+ </button>
1931
+ </div>
1932
+ <div class="emoji-picker-popup">
1933
+ <emoji-picker
1934
+ @emoji-click=${w=>Zm(w,e)}
1935
+ ></emoji-picker>
1936
+ </div>
1937
+ ${ry(e)}
1938
+ </div>
1939
+ </section>
1940
+ `}const ty=[{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 ny(e){const t=new Set(e.filter(n=>n.provider==="anthropic").map(n=>n.id));return ty.filter(n=>t.has(n.id)).map(n=>({key:`anthropic/${n.id}`,...n}))}const sy=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function iy(e){var i;const t=e.currentTarget,n=(i=t.closest(".chat-model-bar"))==null?void 0:i.querySelector(".chat-settings-menu");if(!n)return;const s=n.classList.contains("active");if(document.querySelectorAll(".chat-settings-menu.active").forEach(r=>r.classList.remove("active")),!s){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 ry(e){if(!e.connected)return k;const t=e.modelCatalog??[],n=ny(t);if(n.length===0)return k;const s=e.modelProvider&&e.model?`${e.modelProvider}/${e.model}`:null,i=e.thinkingLevel??"off",r=e.verboseLevel==="on"||e.verboseLevel==="full",o=e.fillerEnabled===!0;return h`
1941
+ <div class="chat-model-bar">
1942
+ <div class="chat-model-bar__select">
1943
+ <select
1944
+ class="chat-model-bar__dropdown"
1945
+ .value=${s??""}
1946
+ @change=${a=>{const l=a.target.value;l&&e.onModelChange&&e.onModelChange(l)}}
1947
+ >
1948
+ ${n.map(a=>h`
1949
+ <option value=${a.key} ?selected=${a.key===s}>
1950
+ ${a.shortName} — ${a.description}
1951
+ </option>
1952
+ `)}
1953
+ </select>
1954
+ </div>
1955
+ <div class="chat-model-bar__select">
1956
+ <select
1957
+ class="chat-model-bar__dropdown"
1958
+ .value=${i}
1959
+ @change=${a=>{const l=a.target.value;e.onThinkingLevelChange&&e.onThinkingLevelChange(l)}}
1960
+ >
1961
+ ${sy.map(a=>h`
1962
+ <option value=${a.value} ?selected=${a.value===i}>
1963
+ Thinking: ${a.label}
1964
+ </option>
1965
+ `)}
1966
+ </select>
1967
+ </div>
1968
+ <button
1969
+ class="chat-model-bar__settings-btn"
1970
+ type="button"
1971
+ @click=${iy}
1972
+ aria-label="Message settings"
1973
+ title="Message settings"
1974
+ >
1975
+ ${O.slidersHorizontal}
1976
+ </button>
1977
+ <div class="chat-settings-menu">
1978
+ <label class="chat-settings-menu__item">
1979
+ <input
1980
+ type="checkbox"
1981
+ .checked=${r}
1982
+ @change=${a=>{const l=a.target.checked;e.onVerboseChange&&e.onVerboseChange(l?"on":"off")}}
1983
+ />
1984
+ <span>Verbose</span>
1985
+ <span class="chat-settings-menu__hint">Detailed responses</span>
1986
+ </label>
1987
+ <label class="chat-settings-menu__item">
1988
+ <input
1989
+ type="checkbox"
1990
+ .checked=${o}
1991
+ @change=${a=>{const l=a.target.checked;e.onFillerChange&&e.onFillerChange(l)}}
1992
+ />
1993
+ <span>Filler</span>
1994
+ <span class="chat-settings-menu__hint">Quick acks while thinking</span>
1995
+ </label>
1996
+ </div>
1997
+ </div>
1998
+ `}const ba=200;function oy(e){const t=[];let n=null;for(const s of e){if(s.kind!=="message"){n&&(t.push(n),n=null),t.push(s);continue}const i=Ga(s.message),r=Va(i.role),o=i.timestamp||Date.now();!n||n.role!==r?(n&&t.push(n),n={kind:"group",key:`group:${r}:${s.key}`,role:r,messages:[{message:s.message,key:s.key}],timestamp:o,isStreaming:!1}):n.messages.push({message:s.message,key:s.key})}return n&&t.push(n),t}function ay(e){var o;const t=[],n=Array.isArray(e.messages)?e.messages:[],s=Array.isArray(e.toolMessages)?e.toolMessages:[],i=e.showThinking||e.verboseLevel==="on"||e.verboseLevel==="full",r=Math.max(0,n.length-ba);r>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${ba} messages (${r} hidden).`,timestamp:Date.now()}});for(let a=r;a<n.length;a++){const l=n[a],c=Ga(l);!i&&c.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:wa(l,a),message:l})}if(i)for(let a=0;a<s.length;a++)t.push({kind:"message",key:wa(s[a],a+n.length),message:s[a]});if(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 l=((o=a.attachments)==null?void 0:o.filter(u=>u.fileName).map(u=>u.fileName))??[],c=l.length>0?a.text?`${l.join(", ")}
1999
+
2000
+ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,message:{role:"user",content:[{type:"text",text:c}],timestamp:a.createdAt}})}return oy(t)}function wa(e,t){const n=e,s=typeof n.toolCallId=="string"?n.toolCallId:"";if(s)return`tool:${s}`;const i=typeof n.id=="string"?n.id:"";if(i)return`msg:${i}`;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}`}function ly(e){return e.connected?h`
2001
+ <div class="setup-container setup-container--full chat-page">
2002
+ ${at("Chat",e.wsProps)}
2003
+ <div class="chat-viewport">
2004
+ ${ey(e)}
2005
+ </div>
2006
+ </div>
2007
+ `:h`
2008
+ <div class="setup-container">
2009
+ <div class="setup-card">
2010
+ <div class="setup-spinner"></div>
2011
+ <p>Connecting to gateway...</p>
2012
+ </div>
2013
+ </div>
2014
+ `}function cy(e){return e?`${za(e)} (${hs(e)})`:"n/a"}function xc(e){const t=e.state??{},n=t.lastStatus??"n/a",s=t.lastRunAtMs?hs(t.lastRunAtMs):"never";return`${n} · last ${s}`}function $c(e){const t=e.schedule;return t.kind==="at"?`One-time: ${za(t.atMs)}`:t.kind==="every"?`Every ${ja(t.everyMs)}`:`Schedule: ${t.expr}${t.tz?` (${t.tz})`:""}`}function uy(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 ka(e){const t=e.payload;if(t.kind!=="agentTurn")return null;const n=t.channel??t.provider,s=t.to;if(!s&&!n)return null;const i=[];return s&&i.push(s),n&&n!=="last"&&i.push(`via ${n}`),i.join(" ")||null}function dy(e){var i;const t=["last",...e.channels.filter(Boolean)],n=(i=e.form.channel)==null?void 0:i.trim();n&&!t.includes(n)&&t.push(n);const s=new Set;return t.filter(r=>s.has(r)?!1:(s.add(r),!0))}function py(e,t){var s,i;if(t==="last")return"last";const n=(s=e.channelMeta)==null?void 0:s.find(r=>r.id===t);return n!=null&&n.label?n.label:((i=e.channelLabels)==null?void 0:i[t])??t}function hy(e){return e||"Default"}const Sa=h`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,fy=h`<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>`,gy=h`<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>`,Ec=h`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,my=h`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`;function Aa(e){const t=e.detailJobId?e.jobs.find(n=>n.id===e.detailJobId)??null:null;return h`
2015
+ ${yy(e)}
2016
+ ${vy(e)}
2017
+ ${e.newEventModalOpen?wy(e):k}
2018
+ ${t?Sy(t,e):k}
2019
+ `}function yy(e){const t=e.status,n=(t==null?void 0:t.enabled)??!1,s=(t==null?void 0:t.jobs)??0,i=t==null?void 0:t.nextWakeAtMs;return h`
2020
+ <div class="event-status-bar">
2021
+ <div class="event-status-bar__info">
2022
+ <span class="statusDot ${n?"ok":""}"></span>
2023
+ <span>${n?"Active":"Inactive"}</span>
2024
+ <span class="event-status-bar__sep">\u00b7</span>
2025
+ <span>${s} event${s!==1?"s":""}</span>
2026
+ ${i?h`
2027
+ <span class="event-status-bar__sep">\u00b7</span>
2028
+ <span>Next: ${hs(i)}</span>
2029
+ `:k}
2030
+ <button
2031
+ class="btn btn--sm"
2032
+ ?disabled=${e.loading}
2033
+ @click=${e.onRefresh}
2034
+ style="margin-left: 4px;"
2035
+ >
2036
+ ${e.loading?"Refreshing…":"Refresh"}
2037
+ </button>
2038
+ ${e.error?h`<span class="muted">${e.error}</span>`:k}
2039
+ </div>
2040
+ <button class="btn primary btn--sm" @click=${e.onNewEventModalOpen}>
2041
+ ${my} New Event
2042
+ </button>
2043
+ </div>
2044
+ `}function vy(e){return e.jobs.length===0?h`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:h`
2045
+ <div class="event-grid">
2046
+ ${e.jobs.map(t=>by(t,e))}
2047
+ </div>
2048
+ `}function by(e,t){return h`
2049
+ <div
2050
+ class="event-card ${e.enabled?"":"disabled"}"
2051
+ @click=${()=>t.onDetailOpen(e)}
2052
+ >
2053
+ <div class="event-card__header">
2054
+ <div class="event-card__name">${e.name||"Untitled"}</div>
2055
+ <span class="chip ${e.enabled?"chip-ok":""}" style="font-size: 11px; padding: 2px 8px;">
2056
+ ${e.enabled?"On":"Off"}
2057
+ </span>
2058
+ </div>
2059
+ <div class="event-card__schedule">${$c(e)}</div>
2060
+ ${e.agentId?h`<div class="event-card__agent">${hy(e.agentId)}</div>`:k}
2061
+ ${ka(e)?h`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${ka(e)}</div>`:k}
2062
+ <div class="event-card__footer">
2063
+ <div class="event-card__status">
2064
+ <span class="muted" style="font-size: 11px;">${xc(e)}</span>
2065
+ </div>
2066
+ <div class="event-card__actions" @click=${n=>n.stopPropagation()}>
2067
+ <button
2068
+ class="btn-icon"
2069
+ title="${e.enabled?"Pause":"Resume"}"
2070
+ ?disabled=${t.busy}
2071
+ @click=${()=>t.onToggle(e,!e.enabled)}
2072
+ >
2073
+ ${e.enabled?fy:Sa}
2074
+ </button>
2075
+ <button
2076
+ class="btn-icon"
2077
+ title="Run now"
2078
+ ?disabled=${t.busy}
2079
+ @click=${()=>t.onRun(e)}
2080
+ >
2081
+ ${Sa}
2082
+ </button>
2083
+ <button
2084
+ class="btn-icon danger"
2085
+ title="Delete"
2086
+ ?disabled=${t.busy}
2087
+ @click=${()=>t.onRemove(e)}
2088
+ >
2089
+ ${gy}
2090
+ </button>
2091
+ </div>
2092
+ </div>
2093
+ </div>
2094
+ `}function wy(e){const t=dy(e);return h`
2095
+ <div class="event-modal-overlay" @click=${e.onNewEventModalClose}>
2096
+ <div class="event-modal" @click=${n=>n.stopPropagation()}>
2097
+ <div class="event-modal__header">
2098
+ <div class="event-modal__title">New Event</div>
2099
+ <button class="event-modal__close" @click=${e.onNewEventModalClose}>
2100
+ ${Ec}
2101
+ </button>
2102
+ </div>
2103
+
2104
+ <div class="form-grid">
2105
+ <label class="field">
2106
+ <span>Name</span>
2107
+ <input
2108
+ .value=${e.form.name}
2109
+ @input=${n=>e.onFormChange({name:n.target.value})}
2110
+ placeholder="e.g. Morning briefing"
2111
+ />
2112
+ </label>
2113
+ <label class="field">
2114
+ <span>Description</span>
2115
+ <input
2116
+ .value=${e.form.description}
2117
+ @input=${n=>e.onFormChange({description:n.target.value})}
2118
+ placeholder="What does this event do?"
2119
+ />
2120
+ </label>
2121
+ <label class="field">
2122
+ <span>Agent</span>
2123
+ <select
2124
+ .value=${e.form.agentId}
2125
+ @change=${n=>e.onFormChange({agentId:n.target.value})}
2126
+ >
2127
+ <option value="">Default</option>
2128
+ ${e.agentIds.map(n=>h`<option value=${n}>${n}</option>`)}
2129
+ </select>
2130
+ </label>
2131
+ <label class="field checkbox">
2132
+ <span>Enabled</span>
2133
+ <input
2134
+ type="checkbox"
2135
+ .checked=${e.form.enabled}
2136
+ @change=${n=>e.onFormChange({enabled:n.target.checked})}
2137
+ />
2138
+ </label>
2139
+ <label class="field">
2140
+ <span>Timing</span>
2141
+ <select
2142
+ .value=${e.form.scheduleKind}
2143
+ @change=${n=>e.onFormChange({scheduleKind:n.target.value})}
2144
+ >
2145
+ <option value="every">Repeating</option>
2146
+ <option value="at">One-time</option>
2147
+ <option value="cron">Custom schedule</option>
2148
+ </select>
2149
+ </label>
2150
+ </div>
2151
+
2152
+ ${ky(e)}
2153
+
2154
+ <div class="form-grid" style="margin-top: 12px;">
2155
+ <label class="field">
2156
+ <span>Session type</span>
2157
+ <select
2158
+ .value=${e.form.sessionTarget}
2159
+ @change=${n=>e.onFormChange({sessionTarget:n.target.value})}
2160
+ >
2161
+ <option value="main">Shared session</option>
2162
+ <option value="isolated">Separate session</option>
2163
+ </select>
2164
+ </label>
2165
+ <label class="field">
2166
+ <span>When to run</span>
2167
+ <select
2168
+ .value=${e.form.wakeMode}
2169
+ @change=${n=>e.onFormChange({wakeMode:n.target.value})}
2170
+ >
2171
+ <option value="next-heartbeat">Next available time</option>
2172
+ <option value="now">Right away</option>
2173
+ </select>
2174
+ </label>
2175
+ <label class="field">
2176
+ <span>Action type</span>
2177
+ <select
2178
+ .value=${e.form.payloadKind}
2179
+ @change=${n=>e.onFormChange({payloadKind:n.target.value})}
2180
+ >
2181
+ <option value="systemEvent">Background task</option>
2182
+ <option value="agentTurn">Send a message</option>
2183
+ </select>
2184
+ </label>
2185
+ </div>
2186
+
2187
+ <label class="field" style="margin-top: 12px;">
2188
+ <span>${e.form.payloadKind==="systemEvent"?"Task description":"Message to send"}</span>
2189
+ <textarea
2190
+ .value=${e.form.payloadText}
2191
+ @input=${n=>e.onFormChange({payloadText:n.target.value})}
2192
+ rows="4"
2193
+ placeholder="${e.form.payloadKind==="systemEvent"?"Describe what the assistant should do…":"Type the message to send…"}"
2194
+ ></textarea>
2195
+ </label>
2196
+
2197
+ ${e.form.payloadKind==="agentTurn"?h`
2198
+ <div class="form-grid" style="margin-top: 12px;">
2199
+ <label class="field checkbox">
2200
+ <span>Deliver response</span>
2201
+ <input
2202
+ type="checkbox"
2203
+ .checked=${e.form.deliver}
2204
+ @change=${n=>e.onFormChange({deliver:n.target.checked})}
2205
+ />
2206
+ </label>
2207
+ <label class="field">
2208
+ <span>Channel</span>
2209
+ <select
2210
+ .value=${e.form.channel||"last"}
2211
+ @change=${n=>e.onFormChange({channel:n.target.value})}
2212
+ >
2213
+ ${t.map(n=>h`<option value=${n}>
2214
+ ${py(e,n)}
2215
+ </option>`)}
2216
+ </select>
2217
+ </label>
2218
+ <label class="field">
2219
+ <span>Send to</span>
2220
+ <input
2221
+ .value=${e.form.to}
2222
+ @input=${n=>e.onFormChange({to:n.target.value})}
2223
+ placeholder="+1555\u2026 or chat id"
2224
+ />
2225
+ </label>
2226
+ <label class="field">
2227
+ <span>Timeout (seconds)</span>
2228
+ <input
2229
+ .value=${e.form.timeoutSeconds}
2230
+ @input=${n=>e.onFormChange({timeoutSeconds:n.target.value})}
2231
+ />
2232
+ </label>
2233
+ ${e.form.sessionTarget==="isolated"?h`
2234
+ <label class="field">
2235
+ <span>Summary prefix</span>
2236
+ <input
2237
+ .value=${e.form.postToMainPrefix}
2238
+ @input=${n=>e.onFormChange({postToMainPrefix:n.target.value})}
2239
+ />
2240
+ </label>
2241
+ `:k}
2242
+ </div>
2243
+ `:k}
2244
+
2245
+ <div class="row" style="margin-top: 16px; justify-content: flex-end;">
2246
+ <button class="btn" @click=${e.onNewEventModalClose}>Cancel</button>
2247
+ <button class="btn primary" ?disabled=${e.busy} @click=${e.onAdd}>
2248
+ ${e.busy?"Creating…":"Create Event"}
2249
+ </button>
2250
+ </div>
2251
+ </div>
2252
+ </div>
2253
+ `}function ky(e){const t=e.form;return t.scheduleKind==="at"?h`
2254
+ <label class="field" style="margin-top: 12px;">
2255
+ <span>Run at</span>
2256
+ <input
2257
+ type="datetime-local"
2258
+ .value=${t.scheduleAt}
2259
+ @input=${n=>e.onFormChange({scheduleAt:n.target.value})}
2260
+ />
2261
+ </label>
2262
+ `:t.scheduleKind==="every"?h`
2263
+ <div class="form-grid" style="margin-top: 12px;">
2264
+ <label class="field">
2265
+ <span>Repeat every</span>
2266
+ <input
2267
+ .value=${t.everyAmount}
2268
+ @input=${n=>e.onFormChange({everyAmount:n.target.value})}
2269
+ />
2270
+ </label>
2271
+ <label class="field">
2272
+ <span>Unit</span>
2273
+ <select
2274
+ .value=${t.everyUnit}
2275
+ @change=${n=>e.onFormChange({everyUnit:n.target.value})}
2276
+ >
2277
+ <option value="minutes">Minutes</option>
2278
+ <option value="hours">Hours</option>
2279
+ <option value="days">Days</option>
2280
+ </select>
2281
+ </label>
2282
+ </div>
2283
+ `:h`
2284
+ <div class="form-grid" style="margin-top: 12px;">
2285
+ <label class="field">
2286
+ <span>Cron expression</span>
2287
+ <input
2288
+ .value=${t.cronExpr}
2289
+ @input=${n=>e.onFormChange({cronExpr:n.target.value})}
2290
+ placeholder="e.g. 0 7 * * *"
2291
+ />
2292
+ </label>
2293
+ <label class="field">
2294
+ <span>Timezone (optional)</span>
2295
+ <input
2296
+ .value=${t.cronTz}
2297
+ @input=${n=>e.onFormChange({cronTz:n.target.value})}
2298
+ placeholder="e.g. America/New_York"
2299
+ />
2300
+ </label>
2301
+ </div>
2302
+ `}function Sy(e,t){var n;return h`
2303
+ <div class="event-modal-overlay" @click=${t.onDetailClose}>
2304
+ <div class="event-modal" @click=${s=>s.stopPropagation()}>
2305
+ <div class="event-modal__header">
2306
+ <div class="event-modal__title">${e.name||"Untitled Event"}</div>
2307
+ <button class="event-modal__close" @click=${t.onDetailClose}>
2308
+ ${Ec}
2309
+ </button>
2310
+ </div>
2311
+
2312
+ ${e.description?h`<div style="color: var(--muted); font-size: 13px; margin-bottom: 16px;">${e.description}</div>`:k}
2313
+
2314
+ <div class="event-detail-section">
2315
+ <div class="event-detail-row">
2316
+ <span class="event-detail-label">Status</span>
2317
+ <span class="event-detail-value">
2318
+ <span class="chip ${e.enabled?"chip-ok":""}" style="font-size: 11px; padding: 2px 8px;">
2319
+ ${e.enabled?"Enabled":"Disabled"}
2320
+ </span>
2321
+ </span>
2322
+ </div>
2323
+ <div class="event-detail-row">
2324
+ <span class="event-detail-label">Schedule</span>
2325
+ <span class="event-detail-value">${$c(e)}</span>
2326
+ </div>
2327
+ ${e.agentId?h`
2328
+ <div class="event-detail-row">
2329
+ <span class="event-detail-label">Agent</span>
2330
+ <span class="event-detail-value mono">${e.agentId}</span>
2331
+ </div>
2332
+ `:k}
2333
+ <div class="event-detail-row">
2334
+ <span class="event-detail-label">Session</span>
2335
+ <span class="event-detail-value">
2336
+ ${e.sessionTarget==="main"?"Shared":"Separate"}
2337
+ </span>
2338
+ </div>
2339
+ <div class="event-detail-row">
2340
+ <span class="event-detail-label">Run mode</span>
2341
+ <span class="event-detail-value">
2342
+ ${e.wakeMode==="now"?"Right away":"Next available time"}
2343
+ </span>
2344
+ </div>
2345
+ <div class="event-detail-row" style="flex-direction: column; align-items: stretch; gap: 4px;">
2346
+ <span class="event-detail-label">Action</span>
2347
+ <span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${uy(e,!1)}</span>
2348
+ </div>
2349
+ ${e.payload.kind==="agentTurn"&&e.payload.to?h`
2350
+ <div class="event-detail-row">
2351
+ <span class="event-detail-label">Send to</span>
2352
+ <span class="event-detail-value mono">${e.payload.to}</span>
2353
+ </div>
2354
+ `:k}
2355
+ ${e.payload.kind==="agentTurn"&&(e.payload.channel??e.payload.provider)?h`
2356
+ <div class="event-detail-row">
2357
+ <span class="event-detail-label">Channel</span>
2358
+ <span class="event-detail-value">${e.payload.channel??e.payload.provider}</span>
2359
+ </div>
2360
+ `:k}
2361
+ ${e.payload.kind==="agentTurn"?h`
2362
+ <div class="event-detail-row">
2363
+ <span class="event-detail-label">Auto-deliver</span>
2364
+ <span class="event-detail-value">${e.payload.deliver?"Yes":"No"}</span>
2365
+ </div>
2366
+ `:k}
2367
+ </div>
2368
+
2369
+ <div class="event-detail-section">
2370
+ <div class="event-detail-row">
2371
+ <span class="event-detail-label">Last run</span>
2372
+ <span class="event-detail-value">${xc(e)}</span>
2373
+ </div>
2374
+ ${(n=e.state)!=null&&n.nextRunAtMs?h`
2375
+ <div class="event-detail-row">
2376
+ <span class="event-detail-label">Next run</span>
2377
+ <span class="event-detail-value">${cy(e.state.nextRunAtMs)}</span>
2378
+ </div>
2379
+ `:k}
2380
+ </div>
2381
+
2382
+ <div class="event-detail-section">
2383
+ <div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;">
2384
+ <span class="event-detail-label" style="font-size: 14px;">Recent Activity</span>
2385
+ </div>
2386
+ ${t.runs.length===0?h`<div class="muted" style="font-size: 13px;">No runs recorded yet.</div>`:h`
2387
+ <div class="list">
2388
+ ${[...t.runs].sort((s,i)=>i.ts-s.ts).map(s=>xy(s))}
2389
+ </div>
2390
+ `}
2391
+ </div>
2392
+
2393
+ <div class="row" style="margin-top: 16px; gap: 8px; justify-content: flex-end;">
2394
+ <button
2395
+ class="btn"
2396
+ ?disabled=${t.busy}
2397
+ @click=${()=>t.onToggle(e,!e.enabled)}
2398
+ >
2399
+ ${e.enabled?"Disable":"Enable"}
2400
+ </button>
2401
+ <button
2402
+ class="btn primary"
2403
+ ?disabled=${t.busy}
2404
+ @click=${()=>t.onRun(e)}
2405
+ >
2406
+ Run Now
2407
+ </button>
2408
+ <button
2409
+ class="btn danger"
2410
+ ?disabled=${t.busy}
2411
+ @click=${()=>{t.onRemove(e),t.onDetailClose()}}
2412
+ >
2413
+ Delete
2414
+ </button>
2415
+ </div>
2416
+ </div>
2417
+ </div>
2418
+ `}function Ay(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"?"chip chip-warn":"chip"}function xy(e){return h`
2419
+ <div class="list-item" style="grid-template-columns: 1fr; gap: 6px;">
2420
+ <div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
2421
+ <span class=${Ay(e.status)} style="font-size: 11px; padding: 2px 8px;">
2422
+ ${e.status}
2423
+ </span>
2424
+ <span class="muted" style="font-size: 12px;">${hs(e.ts)}</span>
2425
+ <span class="muted" style="font-size: 12px;">${ja(e.durationMs)}</span>
2426
+ </div>
2427
+ ${e.summary?h`<div class="muted" style="font-size: 12px;">${e.summary}</div>`:k}
2428
+ ${e.error?h`
2429
+ <details style="margin-top: 2px;">
2430
+ <summary class="muted" style="cursor: pointer; font-size: 12px;">Error details</summary>
2431
+ <div class="muted" style="margin-top: 4px; white-space: pre-wrap; font-size: 12px;">${e.error}</div>
2432
+ </details>
2433
+ `:k}
2434
+ </div>
2435
+ `}function $y(e){var i;const t=((i=e.report)==null?void 0:i.skills)??[],n=e.filter.trim().toLowerCase(),s=n?t.filter(r=>[r.name,r.description,r.source].join(" ").toLowerCase().includes(n)):t;return h`
2436
+ <section class="card">
2437
+ <div class="row" style="justify-content: space-between;">
2438
+ <div>
2439
+ <div class="card-title">Skills</div>
2440
+ <div class="card-sub">Bundled, managed, and workspace skills.</div>
2441
+ </div>
2442
+ <button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
2443
+ ${e.loading?"Loading…":"Refresh"}
2444
+ </button>
2445
+ </div>
2446
+
2447
+ <div class="filters" style="margin-top: 14px;">
2448
+ <label class="field" style="flex: 1;">
2449
+ <span>Filter</span>
2450
+ <input
2451
+ .value=${e.filter}
2452
+ @input=${r=>e.onFilterChange(r.target.value)}
2453
+ placeholder="Search skills"
2454
+ />
2455
+ </label>
2456
+ <div class="muted">${s.length} shown</div>
2457
+ </div>
2458
+
2459
+ ${e.error?h`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:k}
2460
+
2461
+ ${s.length===0?h`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:h`
2462
+ <div class="list" style="margin-top: 16px;">
2463
+ ${s.map(r=>Ey(r,e))}
2464
+ </div>
2465
+ `}
2466
+ </section>
2467
+ `}function Ey(e,t){const n=t.busyKey===e.skillKey,s=t.edits[e.skillKey]??"",i=t.messages[e.skillKey]??null,r=e.install.length>0&&e.missing.bins.length>0,o=[...e.missing.bins.map(l=>`bin:${l}`),...e.missing.env.map(l=>`env:${l}`),...e.missing.config.map(l=>`config:${l}`),...e.missing.os.map(l=>`os:${l}`)],a=[];return e.disabled&&a.push("disabled"),e.blockedByAllowlist&&a.push("blocked by allowlist"),h`
2468
+ <div class="list-item">
2469
+ <div class="list-main">
2470
+ <div class="list-title">
2471
+ ${e.emoji?`${e.emoji} `:""}${e.name}
2472
+ </div>
2473
+ <div class="list-sub">${Fu(e.description,140)}</div>
2474
+ <div class="chip-row" style="margin-top: 6px;">
2475
+ <span class="chip">${e.source}</span>
2476
+ <span class="chip ${e.eligible?"chip-ok":"chip-warn"}">
2477
+ ${e.eligible?"eligible":"blocked"}
2478
+ </span>
2479
+ ${e.disabled?h`<span class="chip chip-warn">disabled</span>`:k}
2480
+ </div>
2481
+ ${o.length>0?h`
2482
+ <div class="muted" style="margin-top: 6px;">
2483
+ Missing: ${o.join(", ")}
2484
+ </div>
2485
+ `:k}
2486
+ ${a.length>0?h`
2487
+ <div class="muted" style="margin-top: 6px;">
2488
+ Reason: ${a.join(", ")}
2489
+ </div>
2490
+ `:k}
2491
+ </div>
2492
+ <div class="list-meta">
2493
+ <div class="row" style="justify-content: flex-end; flex-wrap: wrap;">
2494
+ <button
2495
+ class="btn"
2496
+ ?disabled=${n}
2497
+ @click=${()=>t.onToggle(e.skillKey,e.disabled)}
2498
+ >
2499
+ ${e.disabled?"Enable":"Disable"}
2500
+ </button>
2501
+ ${r?h`<button
2502
+ class="btn"
2503
+ ?disabled=${n}
2504
+ @click=${()=>t.onInstall(e.skillKey,e.name,e.install[0].id)}
2505
+ >
2506
+ ${n?"Installing…":e.install[0].label}
2507
+ </button>`:k}
2508
+ </div>
2509
+ ${i?h`<div
2510
+ class="muted"
2511
+ style="margin-top: 8px; color: ${i.kind==="error"?"var(--danger-color, #d14343)":"var(--success-color, #0a7f5a)"};"
2512
+ >
2513
+ ${i.message}
2514
+ </div>`:k}
2515
+ ${e.primaryEnv?h`
2516
+ <div class="field" style="margin-top: 10px;">
2517
+ <span>API key</span>
2518
+ <input
2519
+ type="password"
2520
+ .value=${s}
2521
+ @input=${l=>t.onEdit(e.skillKey,l.target.value)}
2522
+ />
2523
+ </div>
2524
+ <button
2525
+ class="btn primary"
2526
+ style="margin-top: 8px;"
2527
+ ?disabled=${n}
2528
+ @click=${()=>t.onSaveKey(e.skillKey)}
2529
+ >
2530
+ Save key
2531
+ </button>
2532
+ `:k}
2533
+ </div>
2534
+ </div>
2535
+ `}const xa=["user","assistant","tool","thinking","error"],$a={user:"User",assistant:"Assistant",tool:"Tool",thinking:"Thinking",error:"Error",system:"System"};function Ty(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Cy(e){return e.split(":").slice(2).join(":")||e}function _y(e,t){return t?[e.content,e.agentId,e.sessionKey,e.toolName].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function My(e,t=500){return e.length<=t?e:e.slice(0,t)+"..."}function Ly(e){const t=e.filterText.trim().toLowerCase();xa.some(s=>!e.typeFilters[s]),e.agents.some(s=>!e.agentFilters[s]);const n=e.entries.filter(s=>!e.typeFilters[s.type]||e.agents.length>0&&!(e.agentFilters[s.agentId]??!0)?!1:_y(s,t));return h`
2536
+ <div>
2537
+ <div class="filters" style="margin-top: 14px;">
2538
+ <label class="field" style="min-width: 220px;">
2539
+ <span>Filter</span>
2540
+ <input
2541
+ .value=${e.filterText}
2542
+ @input=${s=>e.onFilterTextChange(s.target.value)}
2543
+ placeholder="Search session logs"
2544
+ />
2545
+ </label>
2546
+ </div>
2547
+
2548
+ <div class="chip-row" style="margin-top: 12px;">
2549
+ ${xa.map(s=>h`
2550
+ <label class="chip session-log-chip ${s}">
2551
+ <input
2552
+ type="checkbox"
2553
+ .checked=${e.typeFilters[s]}
2554
+ @change=${i=>e.onTypeToggle(s,i.target.checked)}
2555
+ />
2556
+ <span>${$a[s]}</span>
2557
+ </label>
2558
+ `)}
2559
+ </div>
2560
+
2561
+ <div class="chip-row" style="margin-top: 8px; align-items: center;">
2562
+ ${e.agents.map(s=>h`
2563
+ <label class="chip agent-chip">
2564
+ <input
2565
+ type="checkbox"
2566
+ .checked=${e.agentFilters[s]??!0}
2567
+ @change=${i=>e.onAgentToggle(s,i.target.checked)}
2568
+ />
2569
+ <span>${s}</span>
2570
+ </label>
2571
+ `)}
2572
+ <label class="chip">
2573
+ <input
2574
+ type="checkbox"
2575
+ .checked=${e.autoFollow}
2576
+ @change=${s=>e.onToggleAutoFollow(s.target.checked)}
2577
+ />
2578
+ <span>Auto-follow</span>
2579
+ </label>
2580
+ <label class="chip">
2581
+ <input
2582
+ type="checkbox"
2583
+ .checked=${e.full}
2584
+ @change=${s=>e.onToggleFull(s.target.checked)}
2585
+ />
2586
+ <span>Full</span>
2587
+ </label>
2588
+ </div>
2589
+
2590
+ ${e.error?h`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:k}
2591
+
2592
+ <div class="log-stream" style="margin-top: 12px;" @scroll=${e.onScroll}>
2593
+ ${n.length===0?h`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map(s=>h`
2594
+ <div class="log-row session-entry ${s.type}">
2595
+ <div class="log-row-header">
2596
+ <span class="log-time mono">${Ty(s.timestamp)}</span>
2597
+ <span class="session-log-type ${s.type}">${$a[s.type]}</span>
2598
+ <span class="log-subsystem mono">${s.agentId}</span>
2599
+ <span class="session-label mono">${Cy(s.sessionKey)}</span>
2600
+ ${s.toolName?h`<span class="session-tool mono">${s.toolName}</span>`:k}
2601
+ ${s.model?h`<span class="session-model mono">${s.model}</span>`:k}
2602
+ </div>
2603
+ <div class="log-message mono">${e.full?s.content:My(s.content)}</div>
2604
+ </div>
2605
+ `)}
2606
+ </div>
2607
+ </div>
2608
+ `}const Fi=["trace","debug","info","warn","error","fatal"];function Py(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function Tc(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Ry(e){return h`
2609
+ <section class="card">
2610
+ <div class="row" style="justify-content: space-between;">
2611
+ <div>
2612
+ <div class="card-title">Logs</div>
2613
+ <div class="card-sub">Session transcripts and system logs.</div>
2614
+ </div>
2615
+ <div class="row" style="gap: 8px;">
2616
+ ${e.logsSubTab==="system"?h`
2617
+ <button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
2618
+ ${e.loading?"Loading…":"Refresh"}
2619
+ </button>
2620
+ <button
2621
+ class="btn"
2622
+ ?disabled=${e.entries.length===0}
2623
+ @click=${()=>{const t=e.filterText.trim().toLowerCase(),n=Fi.some(r=>!e.levelFilters[r]),s=e.entries.filter(r=>r.level&&!e.levelFilters[r.level]?!1:Tc(r,t)),i=t||n?"filtered":"visible";e.onExport(s.map(r=>r.raw),i)}}
2624
+ >
2625
+ Export
2626
+ </button>
2627
+ `:h`
2628
+ <button class="btn" ?disabled=${e.sessionLogsProps.loading} @click=${e.sessionLogsProps.onRefresh}>
2629
+ ${e.sessionLogsProps.loading?"Loading…":"Refresh"}
2630
+ </button>
2631
+ <button
2632
+ class="btn"
2633
+ ?disabled=${e.sessionLogsProps.entries.length===0}
2634
+ @click=${()=>{const t=e.sessionLogsProps,n=t.filterText.trim().toLowerCase(),i=t.entries.filter(r=>!t.typeFilters[r.type]||t.agents.length>0&&!(t.agentFilters[r.agentId]??!0)?!1:n?[r.content,r.agentId,r.sessionKey,r.toolName].filter(Boolean).join(" ").toLowerCase().includes(n):!0).map(r=>`${r.timestamp} [${r.type}] ${r.agentId} ${r.sessionKey} ${r.toolName??""} ${r.content}`);t.onExport(i,n?"filtered":"visible")}}
2635
+ >
2636
+ Export
2637
+ </button>
2638
+ `}
2639
+ </div>
2640
+ </div>
2641
+
2642
+ <div class="sp-tabs" style="margin-top: 12px;">
2643
+ <button class="sp-tab ${e.logsSubTab==="session"?"active":""}"
2644
+ @click=${()=>e.onSubTabChange("session")}>
2645
+ Session Logs
2646
+ </button>
2647
+ <button class="sp-tab ${e.logsSubTab==="system"?"active":""}"
2648
+ @click=${()=>e.onSubTabChange("system")}>
2649
+ System Logs
2650
+ </button>
2651
+ </div>
2652
+
2653
+ ${e.logsSubTab==="session"?Ly(e.sessionLogsProps):Iy(e)}
2654
+ </section>
2655
+ `}function Iy(e){const t=e.filterText.trim().toLowerCase();Fi.some(s=>!e.levelFilters[s]);const n=e.entries.filter(s=>s.level&&!e.levelFilters[s.level]?!1:Tc(s,t));return h`
2656
+ <div class="filters" style="margin-top: 14px;">
2657
+ <label class="field" style="min-width: 220px;">
2658
+ <span>Filter</span>
2659
+ <input
2660
+ .value=${e.filterText}
2661
+ @input=${s=>e.onFilterTextChange(s.target.value)}
2662
+ placeholder="Search logs"
2663
+ />
2664
+ </label>
2665
+ <label class="field checkbox">
2666
+ <span>Auto-follow</span>
2667
+ <input
2668
+ type="checkbox"
2669
+ .checked=${e.autoFollow}
2670
+ @change=${s=>e.onToggleAutoFollow(s.target.checked)}
2671
+ />
2672
+ </label>
2673
+ </div>
2674
+
2675
+ <div class="chip-row" style="margin-top: 12px;">
2676
+ ${Fi.map(s=>h`
2677
+ <label class="chip log-chip ${s}">
2678
+ <input
2679
+ type="checkbox"
2680
+ .checked=${e.levelFilters[s]}
2681
+ @change=${i=>e.onLevelToggle(s,i.target.checked)}
2682
+ />
2683
+ <span>${s}</span>
2684
+ </label>
2685
+ `)}
2686
+ </div>
2687
+
2688
+ ${e.file?h`<div class="muted" style="margin-top: 10px;">File: ${e.file}</div>`:k}
2689
+ ${e.truncated?h`<div class="callout" style="margin-top: 10px;">
2690
+ Log output truncated; showing latest chunk.
2691
+ </div>`:k}
2692
+ ${e.error?h`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:k}
2693
+
2694
+ <div class="log-stream" style="margin-top: 12px;" @scroll=${e.onScroll}>
2695
+ ${n.length===0?h`<div class="muted" style="padding: 12px;">No log entries.</div>`:[...n].reverse().map(s=>h`
2696
+ <div class="log-row">
2697
+ <div class="log-row-header">
2698
+ <span class="log-time mono">${Py(s.time)}</span>
2699
+ <span class="log-level ${s.level??""}">${s.level??""}</span>
2700
+ <span class="log-subsystem mono">${s.subsystem??""}</span>
2701
+ </div>
2702
+ <div class="log-message mono">${s.message??s.raw}</div>
2703
+ </div>
2704
+ `)}
2705
+ </div>
2706
+ `}const Ny=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function Dy(e){switch(e.activeTab){case"cron":return Aa(e.cronProps);case"skills":return $y(e.skillsProps);case"logs":return Ry(e.logsProps);default:return Aa(e.cronProps)}}function Oy(e){return e.connected?h`
2707
+ <div class="setup-container">
2708
+ ${at("Advanced",e.wsProps)}
2709
+ <div class="setup-card sp-card-advanced" style="text-align: left;">
2710
+ <h1>Advanced</h1>
2711
+ <div class="sp-tabs">
2712
+ ${Ny.map(t=>h`
2713
+ <button
2714
+ class="sp-tab ${e.activeTab===t.id?"active":""}"
2715
+ @click=${()=>e.onTabChange(t.id)}
2716
+ >
2717
+ ${t.label}
2718
+ </button>
2719
+ `)}
2720
+ </div>
2721
+ ${Dy(e)}
2722
+ </div>
2723
+ </div>
2724
+ `:h`
2725
+ <div class="setup-container">
2726
+ <div class="setup-card">
2727
+ <div class="setup-spinner"></div>
2728
+ <p>Connecting to gateway...</p>
2729
+ </div>
2730
+ </div>
2731
+ `}function Ea(e){if(!e.show)return k;const t=Ue(),n=e.isFirstTime,s=e.changePinMode===!0&&!n,i=e.changePinBusy===!0;let r=e.accounts.length>0?e.accounts[0].id:"";const o=d=>{var b;r=d.target.value;const f=(b=d.target.closest(".login-card"))==null?void 0:b.querySelector(".login-change-pin");f&&(f.style.display=r==="__master__"?"":"none")},a=d=>f=>{const b=f.target;b.value=b.value.replace(/\D/g,"").slice(0,6),d(b.value)},l=!n&&e.accounts.length>1?h`
2732
+ <select
2733
+ class="login-account-select"
2734
+ @change=${o}
2735
+ ?disabled=${e.busy||i}
2736
+ >
2737
+ ${e.accounts.map((d,f)=>h`
2738
+ <option value=${d.id} ?selected=${f===0}>
2739
+ ${d.displayName}
2740
+ </option>
2741
+ `)}
2742
+ </select>
2743
+ `:k;if(s){let d="",f="",b="";const w=A=>{var T;A.preventDefault(),!i&&(!d||!f||!b||f===b&&r&&((T=e.onChangePin)==null||T.call(e,r,d,f)))};return h`
2744
+ <div class="login-overlay">
2745
+ <div class="login-card">
2746
+ <img class="login-logo" src="${t.iconUrl}" alt="${t.name}" />
2747
+ <h2 class="login-title">Change PIN</h2>
2748
+ <p class="login-subtitle">Enter your current PIN, then choose a new one</p>
2749
+ <form class="login-form" @submit=${w}>
2750
+ ${l}
2751
+ <input
2752
+ class="login-pin-input"
2753
+ type="password"
2754
+ inputmode="numeric"
2755
+ pattern="[0-9]*"
2756
+ minlength="4"
2757
+ maxlength="6"
2758
+ placeholder="Current PIN"
2759
+ ?disabled=${i}
2760
+ @input=${a(A=>{d=A})}
2761
+ autofocus
2762
+ />
2763
+ <input
2764
+ class="login-pin-input"
2765
+ type="password"
2766
+ inputmode="numeric"
2767
+ pattern="[0-9]*"
2768
+ minlength="4"
2769
+ maxlength="6"
2770
+ placeholder="New PIN (4-6 digits)"
2771
+ ?disabled=${i}
2772
+ @input=${a(A=>{f=A})}
2773
+ />
2774
+ <input
2775
+ class="login-pin-input"
2776
+ type="password"
2777
+ inputmode="numeric"
2778
+ pattern="[0-9]*"
2779
+ minlength="4"
2780
+ maxlength="6"
2781
+ placeholder="Confirm new PIN"
2782
+ ?disabled=${i}
2783
+ @input=${a(A=>{b=A})}
2784
+ />
2785
+ ${e.changePinError?h`<p class="login-error">${e.changePinError}</p>`:k}
2786
+ ${e.changePinSuccess?h`<p class="login-success">${e.changePinSuccess}</p>`:k}
2787
+ <button
2788
+ class="login-submit"
2789
+ type="submit"
2790
+ ?disabled=${i}
2791
+ >${i?h`<span class="login-spinner"></span>`:"Change PIN"}</button>
2792
+ </form>
2793
+ <p class="login-hint" style="margin-top: 16px;">
2794
+ <a
2795
+ class="login-link"
2796
+ href="#"
2797
+ @click=${A=>{var T;A.preventDefault(),(T=e.onToggleChangePinMode)==null||T.call(e)}}
2798
+ >Back to login</a>
2799
+ </p>
2800
+ </div>
2801
+ </div>
2802
+ `}let c="",u="";const p=d=>{if(d.preventDefault(),!e.busy)if(n){if(!c||!u||c!==u)return;e.onSubmit(c)}else{if(!c||!r)return;e.onSubmit(r,c)}};return h`
2803
+ <div class="login-overlay">
2804
+ <div class="login-card">
2805
+ <img class="login-logo" src="${t.iconUrl}" alt="${t.name}" />
2806
+ <h2 class="login-title">${t.name}</h2>
2807
+ <p class="login-subtitle">
2808
+ ${n?"Set a PIN to protect this device":"Enter your PIN to continue"}
2809
+ </p>
2810
+ <form class="login-form" @submit=${p}>
2811
+ ${l}
2812
+ <input
2813
+ class="login-pin-input"
2814
+ type="password"
2815
+ inputmode="numeric"
2816
+ pattern="[0-9]*"
2817
+ minlength="4"
2818
+ maxlength="6"
2819
+ placeholder="${n?"Choose a 4-6 digit PIN":"PIN"}"
2820
+ ?disabled=${e.busy}
2821
+ @input=${a(d=>{c=d})}
2822
+ autofocus
2823
+ />
2824
+ ${n?h`
2825
+ <input
2826
+ class="login-pin-input"
2827
+ type="password"
2828
+ inputmode="numeric"
2829
+ pattern="[0-9]*"
2830
+ minlength="4"
2831
+ maxlength="6"
2832
+ placeholder="Confirm PIN"
2833
+ ?disabled=${e.busy}
2834
+ @input=${a(d=>{u=d})}
2835
+ />
2836
+ `:k}
2837
+ ${e.error?h`<p class="login-error">${e.error}</p>`:k}
2838
+ <button
2839
+ class="login-submit"
2840
+ type="submit"
2841
+ ?disabled=${e.busy}
2842
+ >
2843
+ ${e.busy?h`<span class="login-spinner"></span>`:n?"Set PIN":"Unlock"}
2844
+ </button>
2845
+ </form>
2846
+ ${n?h`<p class="login-hint">This PIN protects all accounts on this device. You'll need it every time you open the dashboard.</p>`:e.accounts.some(d=>d.id==="__master__")?h`<p class="login-hint login-change-pin" style="margin-top: 16px;${r!=="__master__"?" display: none;":""}">
2847
+ <a
2848
+ class="login-link"
2849
+ href="#"
2850
+ @click=${d=>{var f;d.preventDefault(),(f=e.onToggleChangePinMode)==null||f.call(e)}}
2851
+ >Change PIN</a>
2852
+ </p>`:k}
2853
+ </div>
2854
+ </div>
2855
+ `}const Ir="taskmaster-access-session",Cc={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function _c(){try{return localStorage.getItem(Ir)}catch{return null}}function Mc(e){try{localStorage.setItem(Ir,e)}catch{}}function By(){try{localStorage.removeItem(Ir)}catch{}}async function Ta(e){if(e.client)try{const t=_c(),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 Fy(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const s=await e.client.request("access.verify",{account:t,pin:n});s.ok&&s.token?(Mc(s.token),e.accessState={...e.accessState,authenticated:!0,workspace:s.workspace??null,master:s.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:s.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function Uy(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?(Mc(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 Wy(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 Ky(e){const t=_c();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}By(),e.accessState={...Cc,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}async function Ui(e){return(await e.request("apikeys.list")).providers??[]}async function Ca(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function zy(e,t){await e.request("apikeys.remove",{provider:t})}class jy{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){n!=null&&n.deviceWidth&&(this.deviceWidth=n.deviceWidth),n!=null&&n.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,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 s=this.canvas.getBoundingClientRect(),i=this.canvas.width/s.width,r=this.canvas.height/s.height,o=this.deviceWidth/this.canvas.width,a=this.deviceHeight/this.canvas.height;return{x:Math.round(t*i*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 ui=null;function qn(){return ui||(ui=new jy),ui}function Nr(e){return e instanceof Error?e.message:String(e)}async function Hy(e){if(!(!e.client||!e.connected)){e.browserLoading=!0,e.browserError=null;try{const t=await e.client.request("browser.screencast.start",{quality:60,maxWidth:1280,maxHeight:720});t!=null&&t.ok&&(e.browserScreencastActive=!0)}catch(t){e.browserError=Nr(t)}finally{e.browserLoading=!1}}}async function qy(e){if(!(!e.client||!e.connected)){e.browserLoading=!0;try{await e.client.request("browser.screencast.stop",{}),e.browserScreencastActive=!1,e.browserScreencastFrame=null,e.browserScreencastMetadata=null}catch(t){e.browserError=Nr(t)}finally{e.browserLoading=!1}}}async function di(e,t,n,s,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:s,button:i??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function pi(e,t,n,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...s!=null&&s.text?{text:s.text}:{},...s!=null&&s.code?{code:s.code}:{},...s!=null&&s.modifiers?{modifiers:s.modifiers}:{}})}catch{}}async function Gy(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=Nr(t)}}function Vy(e){e.browserInputMode=!e.browserInputMode}function Yy(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,qn().updateFrame(t.data,t.metadata)}function Qy(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function Xy(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}function Ke(e){return e instanceof Error?e.message:String(e)}let Bn=null;function dn(e,t){Bn&&clearTimeout(Bn),e.filesMessage={kind:"success",text:t},Bn=setTimeout(()=>{e.filesMessage=null,Bn=null},3e3)}async function pn(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 s=await e.client.request("files.tree",n);s!=null&&s.tree&&(e.filesTree=s.tree,e.filesRoot=s.root??"")}catch(n){e.filesError=Ke(n)}finally{e.filesLoading=!1}}}}async function Zy(e,t,n){e.filesSelectedPaths=new Set([t]),await Lc(e,t,n)}async function Jy(e,t,n){const s=new Set(e.filesSelectedPaths);if(s.has(t)?s.delete(t):s.add(t),e.filesSelectedPaths=s,s.size===1){const i=[...s][0];await Lc(e,i,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function ev(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let s=0,i="";for(const r of n)try{await Pc(e,r,t),s++}catch(o){i=Ke(o)}i?e.filesMessage={kind:"error",text:`${s} downloaded, error: ${i}`}:dn(e,`${s} file${s!==1?"s":""} downloaded`)}async function tv(e,t,n,s){const i=t.split("/").pop()??t,r=n==="."?i:`${n}/${i}`;r!==t&&await Rc(e,t,r,s)}async function Lc(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 s={path:t};n&&(s.agentId=n);const i=await e.client.request("files.read",s);e.filesPreviewContent=(i==null?void 0:i.content)??null,e.filesPreviewBinary=(i==null?void 0:i.binary)??!1,e.filesPreviewSize=(i==null?void 0:i.size)??null}catch(s){e.filesError=Ke(s)}finally{e.filesPreviewLoading=!1}}}async function Pc(e,t,n){if(!(!e.client||!e.connected))try{const s={path:t};n&&(s.agentId=n);const i=await e.client.request("files.download",s);if(!(i!=null&&i.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const r=Uint8Array.from(atob(i.base64),c=>c.charCodeAt(0)),o=new Blob([r]),a=URL.createObjectURL(o),l=document.createElement("a");l.href=a,l.download=i.name??t.split("/").pop()??"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)}catch(s){e.filesMessage={kind:"error",text:Ke(s)}}}async function nv(e,t,n,s){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let i=0,r="";for(const o of n)try{const a=await o.arrayBuffer(),l=btoa(new Uint8Array(a).reduce((u,p)=>u+String.fromCharCode(p),"")),c={path:t,name:o.name,data:l};s&&(c.agentId=s),await e.client.request("files.upload",c),i++}catch(a){r=Ke(a)}e.filesUploadBusy=!1,r?e.filesMessage={kind:"error",text:i>0?`${i} uploaded, error: ${r}`:r}:dn(e,`${i} file${i!==1?"s":""} uploaded`),await pn(e,s)}async function sv(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={path:t};n&&(s.agentId=n),await e.client.request("files.delete",s),dn(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await pn(e,n)}catch(s){e.filesMessage={kind:"error",text:Ke(s)}}}}async function Rc(e,t,n,s){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={from:t,to:n};s&&(i.agentId=s),await e.client.request("files.move",i),dn(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await pn(e,s)}catch(i){e.filesMessage={kind:"error",text:Ke(i)}}}}async function Ic(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const s=await e.client.request("memory.status",n);s!=null&&s.ok&&(e.filesMemoryStatus={dirty:s.dirty??!1,files:s.files??0,chunks:s.chunks??0})}catch{}}async function iv(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 s=await e.client.request("memory.reindex",n),i=(s==null?void 0:s.files)??0,r=(s==null?void 0:s.chunks)??0;dn(e,`Re-indexed: ${i} files, ${r} chunks`),await Ic(e,t)}catch(n){e.filesMessage={kind:"error",text:Ke(n)}}finally{e.filesReindexBusy=!1}}}function rv(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n}function ov(e,t="admin"){var i;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const s=[];for(const r of n){if(!r||typeof r!="object"||r.agentId!==t)continue;const o=r.match;if(!o||typeof o!="object"||(o.channel??"").toLowerCase()!=="whatsapp")continue;const l=o.peer;if(!l||typeof l!="object"||l.kind!=="dm")continue;const c=l.id??"";c&&s.push({phone:c,paired:((i=r.meta)==null?void 0:i.paired)===!0})}return s.sort((r,o)=>r.paired&&!o.paired?-1:!r.paired&&o.paired?1:0),s}function Nc(e,t,n="admin",s){const i=new Map,r=new Map;for(const l of e){if(!l||typeof l!="object"||l.agentId!==n)continue;const c=l.match;if(!c||typeof c!="object"||(c.channel??"").toLowerCase()!=="whatsapp")continue;const p=c.peer;if(!p||typeof p!="object"||p.kind!=="dm")continue;const d=p.id??"";d&&(l.meta&&i.set(d,l.meta),c.accountId&&r.set(d,c.accountId))}const o=e.filter(l=>{if(!l||typeof l!="object"||l.agentId!==n)return!0;const c=l.match;if(!c||typeof c!="object"||(c.channel??"").toLowerCase()!=="whatsapp")return!0;const p=c.peer;return!p||typeof p!="object"?!0:p.kind!=="dm"}),a=t.map(l=>{const c=s??r.get(l.phone),u={channel:"whatsapp",peer:{kind:"dm",id:l.phone}};c&&(u.accountId=c);const p={agentId:n,match:u},d=i.get(l.phone);return d?p.meta=d:l.paired&&(p.meta={paired:!0}),p});return[...o,...a]}async function Ss(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 s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.config;e.configForm=Fe(i??{}),e.adminPhones=ov(i,n),e.configFormDirty=!1}catch(s){e.adminsError=String(s)}finally{e.adminsLoading=!1}}async function Dc(e,t,n,s){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n;let r=t.trim();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 format. Use E.164 format (e.g., +14155552671)";return}if(e.adminPhones.some(l=>l.phone===r)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const l=Fe(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),c=l.bindings??[],u=[...e.adminPhones,{phone:r}],p=Nc(c,u,i,s);el(l,["bindings"],p);const d=(a=e.configSnapshot)==null?void 0:a.hash;if(!d){e.adminsError="Config hash missing; reload and retry.";return}const f=et(l);await e.client.request("config.set",{raw:f,baseHash:d}),await Ss(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}async function Oc(e,t,n,s){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n,r=e.adminPhones.find(l=>l.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 l=Fe(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),c=l.bindings??[],u=e.adminPhones.filter(b=>b.phone!==t),p=Nc(c,u,i,s);el(l,["bindings"],p);const d=(a=e.configSnapshot)==null?void 0:a.hash;if(!d){e.adminsError="Config hash missing; reload and retry.";return}const f=et(l);await e.client.request("config.set",{raw:f,baseHash:d}),await Ss(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}const av=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:Dc,loadAdmins:Ss,removeAdmin:Oc},Symbol.toStringTag,{value:"Module"}));async function ot(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(),s=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.customersRecords=s.records??[]}catch(n){e.customersError=String(n)}finally{e.customersLoading=!1}}}}async function Bc(e,t,n,s){if(!e.client||!e.connected||e.customersSaving)return;let i=t.trim();const r=n.trim();if(!i){e.customersError="Phone number is required";return}if(!r){e.customersError="Name is required";return}if(i.startsWith("+")||(i="+"+i),!/^\+[1-9]\d{6,14}$/.test(i)){e.customersError="Invalid phone number format. Use E.164 (e.g. +447490553305)";return}e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.set",{id:i,name:r,fields:{},workspace:s}),e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName="",await ot(e,s)}catch(o){e.customersError=String(o)}finally{e.customersSaving=!1}}async function Fc(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 ot(e,n)}catch(s){e.customersError=String(s)}finally{e.customersSaving=!1}}}async function Uc(e,t,n,s,i){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:s}),await ot(e,i)}catch(r){e.customersError=String(r)}finally{e.customersSaving=!1}}}async function Wc(e,t,n,s){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 ot(e,s)}catch(i){e.customersError=String(i)}finally{e.customersSaving=!1}}}const lv=Object.freeze(Object.defineProperty({__proto__:null,addCustomer:Bc,deleteCustomer:Fc,deleteCustomerField:Wc,loadCustomers:ot,setCustomerField:Uc},Symbol.toStringTag,{value:"Module"}));function qt(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 cv(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 uv(e){const t=ne(e);if(!t)return;const n=t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin");return n==null?void 0:n.id}function dv(e){const t=ne(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function pv(e){var n;const t=ne(e);if(t)return(n=t.agents[0])==null?void 0:n.id}function hv(e){return e.selectedWorkspace??void 0}function ne(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const fv=/^data:/i,gv=/^https?:\/\//i;function mv(e){var a,l;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=Ka(e.sessionKey),s=(n==null?void 0:n.agentId)??((l=e.agentsList)==null?void 0:l.defaultId)??"main",i=t.find(c=>c.id===s),r=i==null?void 0:i.identity,o=(r==null?void 0:r.avatarUrl)??(r==null?void 0:r.avatar);if(o)return fv.test(o)||gv.test(o)?o:r==null?void 0:r.avatarUrl}function yv(e){var s;if(!e)return null;const t=(s=e.channelAccounts)==null?void 0:s.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 vv(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],s=n.running??!1,i=n.probe,r=i!=null?i.ok===!0:s;return{configured:n.configured??!1,running:s,connected:r,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function bv(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 s=n.find(a=>{var l,c;return((l=a.match)==null?void 0:l.channel)==="imessage"&&((c=a.meta)==null?void 0:c.imessageOwner)});if(!s)return null;const i=s.agentId;for(const a of e.workspaces)if(a.agents.some(l=>l.id===i))return a.name;if(i==="admin"||i==="public"){const a=e.workspaces.find(l=>l.isDefault);return(a==null?void 0:a.name)??null}const r=i.replace(/-(admin|public)$/,"");if(r!==i){const a=e.workspaces.find(l=>l.name===r);return(a==null?void 0:a.name)??null}return null}function wv(e){var t,n,s,i,r,o,a;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return Ea({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(c,u)=>{u!=null&&e.handlePinSubmit(c,u)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(c,u,p)=>e.handleChangePin(c,u,p)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return Ea({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:c=>e.handleSetMasterPin(c)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",k}if(e.setup){const l=yv(e.channelsSnapshot),c=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],u=vv(e.channelsSnapshot),p=bv(e);return wh({connected:e.connected,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:d=>e.handleLicenseKeyChange(d),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:c,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:d=>e.handleUninstallConfirmTextChange(d),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:d=>e.handleAuthSubmitCode(d),onAuthCodeChange:d=>e.handleAuthCodeChange(d),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async d=>{await e.handleWhatsAppStart(!0,d),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(d),await q(e,!0),e.requestUpdate())},onWhatsAppReset:async d=>{await e.handleWhatsAppLogout(d),await e.handleWhatsAppStart(!0,d),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(d),await q(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await q(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),q(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:d=>e.handleRemoveWhatsAppAccount(d),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:d=>{e.newWorkspacePin=d},onWorkspaceCreate:async(d,f)=>{const b=e.newWorkspacePin;await e.handleWorkspaceCreate(d,f),b.match(/^\d{4,6}$/)&&(await Wy(e,d,b),e.newWorkspacePin="")},onWorkspaceRemove:d=>e.handleWorkspaceRemove(d),onSetAddingWorkspace:d=>{e.addingWorkspace=d},onSetNewWorkspaceName:d=>{e.newWorkspaceName=d},onSetNewWorkspacePath:d=>{e.newWorkspacePath=d},onSetWorkspaceRemoveConfirm:d=>{e.workspaceRemoveConfirm=d},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(d,f)=>e.handleWorkspaceRename(d,f),whatsappDmPolicy:(()=>{const d=ne(e),f=d==null?void 0:d.whatsappAccountId,b=f?c.find(w=>w.accountId===f):c[0];return(b==null?void 0:b.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var x;const d=ne(e),f=d==null?void 0:d.whatsappAccountId,b=f?c.find(E=>E.accountId===f):c[0];if(!b)return;const A=b.dmPolicy!=null&&b.dmPolicy!=="disabled"?"disabled":"open",T=A==="open"?{dmPolicy:A,allowFrom:["*"]}:{dmPolicy:A};try{const E=await e.client.request("config.get"),C=E.config,R=(x=C==null?void 0:C.channels)==null?void 0:x.whatsapp,Y=((R==null?void 0:R.accounts)??{})[b.accountId]?{channels:{whatsapp:{accounts:{[b.accountId]:T}}}}:{channels:{whatsapp:T}};await e.client.request("config.patch",{raw:JSON.stringify(Y),baseHash:E.hash,note:`WhatsApp DM policy → ${A}`,skipRestart:!0}),await q(e,!1)}catch(E){console.error("DM toggle failed:",E)}},whatsappModel:(()=>{var x,E;const d=ne(e);if(!d)return null;const f=d.agents.find(C=>C.id.endsWith("-public")||C.id==="public");if(!f)return null;const b=(x=e.configSnapshot)==null?void 0:x.config,w=(E=b==null?void 0:b.agents)==null?void 0:E.list;if(!Array.isArray(w))return null;const A=w.find(C=>C.id===f.id);if(!(A!=null&&A.model))return null;const T=typeof A.model=="string"?A.model:A.model.primary;return(T==null?void 0:T.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async d=>{const f=ne(e);if(!f)return;const b=f.agents.find(w=>w.id.endsWith("-public")||w.id==="public");if(b)try{const w=await e.client.request("config.get"),A=w.config,T=(A==null?void 0:A.agents)??{},x=Array.isArray(T.list)?[...T.list]:[],E=x.findIndex(R=>R.id===b.id);if(d)E>=0?x[E]={...x[E],model:d}:x.push({id:b.id,model:d});else if(E>=0){const{model:R,...U}=x[E];Object.keys(U).length<=1?x.splice(E,1):x[E]=U}const C=x.length>0?{agents:{list:x}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(C),baseHash:w.hash,note:`Public agent model → ${d||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Model change failed:",w)}},whatsappThinkingLevel:(()=>{var T,x,E;const d=ne(e);if(!d)return null;const f=d.agents.find(C=>C.id.endsWith("-public")||C.id==="public");if(!f)return null;const b=(T=e.configSnapshot)==null?void 0:T.config,w=(x=b==null?void 0:b.agents)==null?void 0:x.list;if(!Array.isArray(w))return null;const A=w.find(C=>C.id===f.id);return((E=A==null?void 0:A.thinkingLevel)==null?void 0:E.trim())||null})(),onWhatsAppThinkingChange:async d=>{const f=ne(e);if(!f)return;const b=f.agents.find(w=>w.id.endsWith("-public")||w.id==="public");if(b)try{const w=await e.client.request("config.get"),A=w.config,T=(A==null?void 0:A.agents)??{},x=Array.isArray(T.list)?[...T.list]:[],E=x.findIndex(U=>U.id===b.id),C=d==="off"?void 0:d;if(C)E>=0?x[E]={...x[E],thinkingLevel:C}:x.push({id:b.id,thinkingLevel:C});else if(E>=0){const{thinkingLevel:U,...Y}=x[E];Object.keys(Y).length<=1?x.splice(E,1):x[E]=Y}const R=x.length>0?{agents:{list:x}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(R),baseHash:w.hash,note:`Public agent thinking → ${C||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Thinking change failed:",w)}},whatsappGroupPolicy:(()=>{var E,C;const d=(E=e.configSnapshot)==null?void 0:E.config,f=(C=d==null?void 0:d.channels)==null?void 0:C.whatsapp,b=ne(e),w=b==null?void 0:b.whatsappAccountId,A=(f==null?void 0:f.accounts)??{},T=w?A[w]:void 0;return(T==null?void 0:T.groupPolicy)??(f==null?void 0:f.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var C,R;const d=(C=e.configSnapshot)==null?void 0:C.config,f=(R=d==null?void 0:d.channels)==null?void 0:R.whatsapp,b=ne(e),w=b==null?void 0:b.whatsappAccountId,A=(f==null?void 0:f.accounts)??{},T=w?A[w]:void 0,E=((T==null?void 0:T.groups)??(f==null?void 0:f.groups)??{})["*"];return(E==null?void 0:E.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var b;const d=ne(e),f=d==null?void 0:d.whatsappAccountId;try{const w=await e.client.request("config.get"),A=w.config,T=((b=A==null?void 0:A.channels)==null?void 0:b.whatsapp)??{},x=T.accounts??{},E=f?x[f]:void 0,C=(E==null?void 0:E.groupPolicy)??T.groupPolicy??"allowlist",R=C==="disabled"||C==="allowlist",U=R?"open":"disabled",Y=R?{"*":{}}:void 0,ze={groupPolicy:U};Y&&(ze.groups=Y);const Lt=E?{channels:{whatsapp:{accounts:{[f]:ze}}}}:{channels:{whatsapp:ze}};await e.client.request("config.patch",{raw:JSON.stringify(Lt),baseHash:w.hash,note:`WhatsApp groups → ${U}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Group toggle failed:",w)}},onWhatsAppGroupMentionChange:async d=>{var w;const f=ne(e),b=f==null?void 0:f.whatsappAccountId;try{const A=await e.client.request("config.get"),T=A.config,E=(((w=T==null?void 0:T.channels)==null?void 0:w.whatsapp)??{}).accounts??{},C=b?E[b]:void 0,R={"*":{requireMention:d}},U=C?{channels:{whatsapp:{accounts:{[b]:{groups:R}}}}}:{channels:{whatsapp:{groups:R}}};await e.client.request("config.patch",{raw:JSON.stringify(U),baseHash:A.hash,note:`WhatsApp group mention → ${d?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group mention change failed:",A)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:u.configured,imessageRunning:u.running,imessageConnected:u.connected,imessageLastError:u.lastError,imessageSelfChatMode:u.selfChatMode,imessageCliPath:u.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:p,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),f=d.config,b=(f==null?void 0:f.bindings)??[],w=ne(e),A=w==null?void 0:w.agents.find(R=>R.id.endsWith("-admin")||R.id==="admin"),T=(A==null?void 0:A.id)??"admin",x=b.filter(R=>{var U;return((U=R.match)==null?void 0:U.channel)!=="imessage"}),E=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],C=[...x,...E];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:C}),baseHash:d.hash,note:"Enable iMessage (self-chat) for "+((w==null?void 0:w.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),Ae(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await q(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),f=d.config,w=((f==null?void 0:f.bindings)??[]).filter(A=>{var T;return((T=A.match)==null?void 0:T.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:w}),baseHash:d.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),Ae(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),f=d.config,b=(f==null?void 0:f.bindings)??[],w=ne(e),A=w==null?void 0:w.agents.find(C=>C.id.endsWith("-admin")||C.id==="admin"),T=(A==null?void 0:A.id)??"admin",x=b.filter(C=>{var R;return((R=C.match)==null?void 0:R.channel)!=="imessage"}),E=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:[...x,...E]}),baseHash:d.hash,note:"Reassign iMessage to "+((w==null?void 0:w.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),Ae(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:d=>{e.infoModalOpen=d},onInfoModalClose:()=>{e.infoModalOpen=null},isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null},onApiKeySave:async(d,f)=>{e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ca(e.client,d,f),e.apiKeySuccess=`${d} key saved`;try{e.apiKeyProviders=await Ui(e.client)}catch{}d==="anthropic"&&await e.handleAuthStatusCheck()}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to save key"}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async d=>{e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await zy(e.client,d),e.apiKeySuccess=`${d} key removed`;try{e.apiKeyProviders=await Ui(e.client)}catch{}}catch(f){e.apiKeyError=f instanceof Error?f.message:"Failed to remove key"}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:d=>{e.authApiKeyInput=d},onAuthApiKeySubmit:async()=>{const d=e.authApiKeyInput.trim();if(d){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await Ca(e.client,"anthropic",d),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(f){e.authApiKeyError=f instanceof Error?f.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var f;const d=e.selectedWorkspace??((f=e.workspaces[0])==null?void 0:f.name);return d?e.accessState.accounts.some(b=>b.id===d):!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:(d,f)=>{var w;const b=e.selectedWorkspace??((w=e.workspaces[0])==null?void 0:w.name);b&&e.handleAccountPinSave(b,d,f)},wsProps:cv(e)})}if(e.filesPage){const l=pv(e);return rh({connected:e.connected,wsProps:qt(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:()=>pn(e,l),onReindex:()=>iv(e,l),onSelectFile:c=>Zy(e,c,l),onToggleSelectFile:c=>Jy(e,c,l),onToggleDir:c=>rv(e,c),onUpload:(c,u)=>nv(e,c,u,l),onDownload:c=>Pc(e,c,l),onBulkDownload:()=>ev(e,l),onDelete:c=>sv(e,c,l),onMove:(c,u)=>Rc(e,c,u,l),onMoveToDir:(c,u)=>tv(e,c,u,l)})}if(e.browserPage)return eh({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>Hy(e),onStop:()=>qy(e),onToggleInput:()=>Vy(e),onCompleteHandoff:()=>Gy(e),onCanvasMouseDown:l=>{const u=l.target.getBoundingClientRect(),d=qn().translateCoordinates(l.clientX-u.left,l.clientY-u.top);di(e,"mousePressed",d.x,d.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const u=l.target.getBoundingClientRect(),d=qn().translateCoordinates(l.clientX-u.left,l.clientY-u.top);di(e,"mouseReleased",d.x,d.y)},onCanvasMouseMove:l=>{const c=qn();if(c.shouldThrottleMouseMove())return;const p=l.target.getBoundingClientRect(),d=c.translateCoordinates(l.clientX-p.left,l.clientY-p.top);di(e,"mouseMoved",d.x,d.y)},onCanvasKeyDown:l=>{let c=0;l.altKey&&(c|=1),l.ctrlKey&&(c|=2),l.metaKey&&(c|=4),l.shiftKey&&(c|=8),pi(e,"keyDown",l.key,{code:l.code,modifiers:c||void 0}),l.key.length===1&&pi(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{pi(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=uv(e),c=dv(e);return Sh({connected:e.connected,wsProps:qt(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>Ss(e,l),onAdd:u=>{Dc(e,u,l,c).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:u=>Oc(e,u,l,c),onNewPhoneChange:u=>e.handleAdminsNewPhoneChange(u)})}if(e.customersPage){const l=hv(e);return Eh({connected:e.connected,wsProps:qt(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:c=>e.customersSearchQuery=c,onSearchSubmit:()=>ot(e,l),onAdd:(c,u)=>Bc(e,c,u,l),onDelete:c=>Fc(e,c,l),onSetField:(c,u,p)=>Uc(e,c,u,p,l),onDeleteField:(c,u)=>Wc(e,c,u,l),onToggleExpand:c=>{e.customersEditingId=e.customersEditingId===c?null:c},onShowAddForm:()=>e.customersShowAddForm=!0,onCancelAddForm:()=>{e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName=""},onNewRecordPhoneChange:c=>e.handleCustomersNewPhoneChange(c),onNewRecordNameChange:c=>e.handleCustomersNewNameChange(c),onRefresh:()=>ot(e,l)})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",c=mv(e),u=e.chatAvatarUrl??c??null;return ly({connected:e.connected,wsProps:qt(e),sessionKey:e.sessionKey,onSessionKeyChange:p=>{e.sessionKey=p,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:p,lastActiveSessionKey:p}),e.loadAssistantIdentity(),Me(e),Ai(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:p=>{Tn(e,e.sessionKey,{model:p}).then(()=>{Me(e)})},onThinkingLevelChange:p=>{Tn(e,e.sessionKey,{thinkingLevel:p==="off"?null:p}).then(()=>{Me(e)})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,onVerboseChange:p=>{Tn(e,e.sessionKey,{verboseLevel:p==="off"?null:p}).then(()=>{Me(e)})},onFillerChange:p=>{Tn(e,e.sessionKey,{fillerEnabled:p}).then(()=>{Me(e)})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:u,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:l,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>(e.resetToolStream(),Promise.all([Me(e),Ai(e)])),onToggleFocusMode:()=>{},onChatScroll:p=>e.handleChatScroll(p),nearBottom:e.chatUserNearBottom,onDraftChange:p=>e.chatMessage=p,attachments:e.chatAttachments,onAttachmentsChange:p=>e.chatAttachments=p,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:p=>e.removeQueuedMessage(p),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:p=>e.handleOpenSidebar(p),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:p=>e.handleSplitRatioChange(p),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?Oy({connected:e.connected,wsProps:qt(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&$t(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?wt(e,{reset:!0}):Jt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(i=(s=e.channelsSnapshot)==null?void 0:s.channelMeta)!=null&&i.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((r=e.channelsSnapshot)==null?void 0:r.channelOrder)??[],channelLabels:((o=e.channelsSnapshot)==null?void 0:o.channelLabels)??{},channelMeta:((a=e.channelsSnapshot)==null?void 0:a.channelMeta)??[],agentIds:(()=>{var c;const l=ne(e);return((c=l==null?void 0:l.agents)==null?void 0:c.map(u=>u.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,vi(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{Ad(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,c)=>xd(e,l,c),onRun:l=>$d(e,l),onRemove:l=>Ed(e,l),onLoadRuns:l=>vi(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:()=>$t(e,{clearMessages:!0}),onToggle:(l,c)=>hp(e,l,c),onEdit:(l,c)=>pp(e,l,c),onSaveKey:l=>fp(e,l),onInstall:(l,c,u)=>gp(e,l,c,u)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?wt(e,{reset:!0}):Jt(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,full:e.sessionLogsFull,onFilterTextChange:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,c)=>{const u=e;u.sessionLogsTypeFilters={...u.sessionLogsTypeFilters,[l]:c}},onAgentToggle:(l,c)=>{const u=e;u.sessionLogsAgentFilters={...u.sessionLogsAgentFilters,[l]:c}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onToggleFull:l=>{e.sessionLogsFull=l,wt(e,{reset:!0})},onRefresh:()=>{wt(e,{reset:!0})},onExport:(l,c)=>e.exportSessionLogs(l,c),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,c)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:c}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onRefresh:()=>Jt(e,{reset:!0}),onExport:(l,c)=>e.exportSessionLogs(l,c),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),h``)}function kv(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),s=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${s}`}function _a(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Sv(e,t,n){return h`
2856
+ <div class="audit-modal-overlay" @click=${i=>{i.target.classList.contains("audit-modal-overlay")&&n()}}>
2857
+ <div class="audit-modal-card">
2858
+ <div class="audit-modal-header">
2859
+ <h3>Memory Writes to Review</h3>
2860
+ <button class="audit-modal-close" @click=${n}>&times;</button>
2861
+ </div>
2862
+ <p class="audit-modal-desc">
2863
+ These files were written to shared or public folders by the agent.
2864
+ Review to ensure no sensitive data was misplaced.
2865
+ </p>
2866
+ ${e.length===0?h`<p class="audit-modal-empty">No unreviewed writes.</p>`:h`
2867
+ <div class="audit-modal-list">
2868
+ ${e.map(i=>h`
2869
+ <div class="audit-modal-entry">
2870
+ <div class="audit-modal-entry-path">
2871
+ <span class="audit-modal-folder audit-modal-folder--${_a(i.path)}">${_a(i.path)}</span>
2872
+ <a href="/files" class="audit-modal-path-link">${i.path}</a>
2873
+ </div>
2874
+ <div class="audit-modal-entry-meta">
2875
+ ${kv(i.timestamp)}
2876
+ <span class="audit-modal-agent">${i.agentId}</span>
2877
+ </div>
2878
+ </div>
2879
+ `)}
2880
+ </div>
2881
+ <button class="setup-button audit-modal-clear" @click=${t}>
2882
+ Mark All Reviewed
2883
+ </button>
2884
+ `}
2885
+ </div>
2886
+ </div>
2887
+ `}const Av={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},xv={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:""};async function $v(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 hn(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 Ev(e,t){var s,i;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};(s=t.workspacePath)!=null&&s.trim()&&(a.workspaceDir=t.workspacePath.trim());const l=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await hn(e),(i=t.onCreated)==null||i.call(t,l)}catch(r){e.workspacesError=String(r)}finally{e.workspaceSaving=!1}}async function Tv(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 s=n.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:s}),e.workspaceRemoveConfirm=null,await hn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Cv(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:i}),await hn(e)}catch(s){e.workspacesError=String(s)}}}const Fn=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Ev,loadWorkspaces:hn,removeWorkspace:Tv,renameWorkspace:Cv},Symbol.toStringTag,{value:"Module"})),Kc={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"},Ma=Kc,Wi={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Kc));new Set(Object.values(Wi));function _v(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),s=e.token??"",i=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),s];return t==="v2"&&i.push(e.nonce??""),i.join("|")}const Mv=4008;class Lv{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 s,i;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(i=(s=this.opts).onClose)==null||i.call(s,{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 u;if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.approvals","operator.pairing"],s="operator";let i=null,r=!1,o=this.opts.token;if(t){i=await sp();const p=(u=op({deviceId:i.deviceId,role:s}))==null?void 0:u.token;o=p??this.opts.token,r=!!(p&&this.opts.token)}const a=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let l;if(t&&i){const p=Date.now(),d=this.connectNonce??void 0,f=_v({deviceId:i.deviceId,clientId:this.opts.clientName??Ma.CONTROL_UI,clientMode:this.opts.mode??Wi.WEBCHAT,role:s,scopes:n,signedAtMs:p,token:o??null,nonce:d}),b=await ip(i.privateKey,f);l={id:i.deviceId,publicKey:i.publicKey,signature:b,signedAt:p,nonce:d}}const c={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Ma.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Wi.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:l,caps:[],auth:a,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",c).then(p=>{var d,f,b;(d=p==null?void 0:p.auth)!=null&&d.deviceToken&&i&&ap({deviceId:i.deviceId,role:p.auth.role??s,token:p.auth.deviceToken,scopes:p.auth.scopes??[]}),this.backoffMs=800,(b=(f=this.opts).onHello)==null||b.call(f,p)}).catch(()=>{var p;r&&i&&lp({deviceId:i.deviceId,role:s}),(p=this.ws)==null||p.close(Mv,"connect failed")})}handleMessage(t){var i,r,o,a,l;let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const c=n;if(c.event==="connect.challenge"){const p=c.payload,d=p&&typeof p.nonce=="string"?p.nonce:null;d&&(this.connectNonce=d,this.sendConnect());return}const u=typeof c.seq=="number"?c.seq:null;u!==null&&(this.lastSeq!==null&&u>this.lastSeq+1&&((r=(i=this.opts).onGap)==null||r.call(i,{expected:this.lastSeq+1,received:u})),this.lastSeq=u);try{(a=(o=this.opts).onEvent)==null||a.call(o,c)}catch(p){console.error("[gateway] event handler error:",p)}return}if(s.type==="res"){const c=n,u=this.pending.get(c.id);if(!u)return;this.pending.delete(c.id),c.ok?u.resolve(c.payload):u.reject(new Error(((l=c.error)==null?void 0:l.message)??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const s=Gi(),i={type:"req",id:s,method:t,params:n},r=new Promise((o,a)=>{this.pending.set(s,{resolve:l=>o(l),reject:a})});return this.ws.send(JSON.stringify(i)),r}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ki(e){return typeof e=="object"&&e!==null}function Pv(e){if(!Ki(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ki(n))return null;const s=typeof n.command=="string"?n.command.trim():"";if(!s)return null;const i=typeof e.createdAtMs=="number"?e.createdAtMs:0,r=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!r?null:{id:t,request:{command:s,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:i,expiresAtMs:r}}function Rv(e){if(!Ki(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 zc(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Iv(e,t){const n=zc(e).filter(s=>s.id!==t.id);return n.push(t),n}function La(e,t){return zc(e).filter(n=>n.id!==t)}async function jc(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),s=n?{sessionKey:n}:{};try{const i=await e.client.request("agent.identity.get",s);if(!i)return;const r=mi(i);e.assistantName=r.name,e.assistantAvatar=r.avatar,e.assistantAgentId=r.agentId??null}catch{}}const cs="taskmaster_update_pending";async function Hc(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 s=await e.client.request("update.status",{});e.currentVersion=s.current,e.latestVersion=s.latest,e.updateAvailable=s.updateAvailable,e.updateMessage=s.updateAvailable?`v${s.latest} available`:"Up to date"}catch(s){e.updateMessage=`Check failed: ${String(s)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function Nv(e){var t,n,s,i;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(cs,String(Date.now()))}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")nn(),e.updateMessage=r.result.reason||"Update skipped",e.updateRunning=!1,(s=e.requestUpdate)==null||s.call(e);else throw nn(),new Error(r.result.reason||"Update failed")}catch(r){nn(),e.updateMessage=`Update failed: ${String(r)}`,e.updateRunning=!1,e.updateProgressSteps=[],(i=e.requestUpdate)==null||i.call(e)}}}function Dv(e,t){var s,i,r;const n=t.phase;if(n==="step-start"){const o=t.name,a=t.index,l=t.total;e.updateMessage=`Updating: ${o} (${a+1}/${l})`;const c=e.updateProgressSteps.find(u=>u.index===a);c?(c.status="running",c.name=o):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:l,status:"running"}],(s=e.requestUpdate)==null||s.call(e)}else if(n==="step-done"){const o=t.name,a=t.index,l=t.total,c=t.ok,u=t.durationMs,p=e.updateProgressSteps.find(d=>d.index===a);p?(p.status=c?"done":"failed",p.durationMs=u):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:l,status:c?"done":"failed",durationMs:u}],e.updateMessage=c?`Updating: ${o} done (${a+1}/${l})`:`Update step failed: ${o}`,(i=e.requestUpdate)==null||i.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,nn()}(r=e.requestUpdate)==null||r.call(e)}}async function Ov(e){var n,s,i,r;if(!e.client||!e.connected)return;const t=Fv();nn();try{const o=await e.client.request("update.lastResult",{});if(!o.ok||!o.result)return;const a=5*6e4,l=Date.now()-o.result.ts<a;if(!t&&!l)return;e.updateLastResult=o.result;const c=(n=o.result.after)==null?void 0:n.version;if(o.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,o.result.status==="ok"){const u=(s=o.result.before)==null?void 0:s.version,p=c??o.result.currentVersion;e.updateMessage=u?`Updated: v${u} → v${p}`:`Updated to v${p}`}else{const u=o.result.reason??((i=o.result.failedStep)==null?void 0:i.name)??"unknown error";e.updateMessage=`Update failed: ${u}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(r=e.requestUpdate)==null||r.call(e)}}function Bv(e){var t;e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e)}function Fv(){try{const e=localStorage.getItem(cs);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(cs),!1):!0:!1}catch{return!1}}function nn(){try{localStorage.removeItem(cs)}catch{}}function hi(e,t){var a,l,c;const n=(e??"").trim(),s=(a=t.mainSessionKey)==null?void 0:a.trim();if(!s)return n;if(!n)return s;const i=((l=t.mainKey)==null?void 0:l.trim())||"main",r=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===i||r&&(n===`agent:${r}:main`||n===`agent:${r}:${i}`)?s:n}function Uv(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=hi(e.sessionKey,t),s=hi(e.settings.sessionKey,t),i=hi(e.settings.lastActiveSessionKey,t),r=n||s||e.sessionKey,o={...e.settings,sessionKey:s||r,lastActiveSessionKey:i||r},a=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;r!==e.sessionKey&&(e.sessionKey=r),a&&Oe(e,o)}function _e(e){var n;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=e.setup||e.filesPage||e.browserPage?"setup-ui":"taskmaster-control-ui";(n=e.client)==null||n.stop(),e.client=new Lv({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:t,mode:"webchat",onHello:s=>{e.connected=!0,e.lastError=null,e.hello=s,ns()&&(mr(),e.uninstallDone=!1),zv(e,s),e.handleAccessCheck(),Ov(e).then(()=>{Hc(e)}),jc(e),$v(e),(e.chatPage||e.setup)&&jv(e),ir(e,{quiet:!0}),sr(e,{quiet:!0}),hn(e).then(()=>{e.initWorkspaceSelection()}),e.setup&&(Ae(e),Hv(e)),pr(e)},onClose:({code:s,reason:i})=>{e.connected=!1,s!==1012&&(e.lastError=`disconnected (${s}): ${i||"no reason"}`)},onEvent:s=>Wv(e,s),onGap:({expected:s,received:i})=>{e.lastError=`event gap detected (expected seq ${s}, got ${i}); refresh recommended`}}),e.client.start()}function Wv(e,t){try{Kv(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Kv(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;ud(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n!=null&&n.sessionKey&&Tl(e,n.sessionKey);const s=Za(e,n);(s==="final"||s==="error"||s==="aborted")&&(Yi(e),zp(e)),s==="final"&&Me(e);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"&&hr(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&sr(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=Pv(t.payload);if(n){e.execApprovalQueue=Iv(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=La(e.execApprovalQueue,n.id)},s)}return}if(t.event==="browser.screencast.frame"){Yy(e,t.payload);return}if(t.event==="browser.handoff"){Qy(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){Xy(e);return}if(t.event==="exec.approval.resolved"){const n=Rv(t.payload);n&&(e.execApprovalQueue=La(e.execApprovalQueue,n.id));return}if(t.event==="update.progress"){Dv(e,t.payload);return}}function zv(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&&Uv(e,n.sessionDefaults)}async function jv(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 Hv(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await Ui(e.client)}catch{}}function qv(e){e.basePath=Lp();const t=Ue();if(Yp(t.accentColor),window.scrollTo(0,0),Ep(e),e.setup){document.title=`${t.name} Setup`,_e(e);return}if(e.filesPage){document.title=`${t.name} Files`,_e(e);return}if(e.browserPage){document.title=`${t.name} Browser`,_e(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,_e(e);return}if(e.customersPage){document.title=`${t.name} Customers`,_e(e);return}if(e.chatPage){document.title=`${t.name} Chat`,_e(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,_e(e);return}Np(e,!0),Pp(e),Rp(e),window.addEventListener("popstate",e.popStateHandler),Cp(e),_e(e),xp(e),e.tab==="logs"&&(e.logsSubTab==="session"?lr(e):or(e)),e.tab==="debug"&&ur(e)}function Gv(e){yd(e)}function Vv(e){var t;window.removeEventListener("popstate",e.popStateHandler),$p(e),ar(e),cr(e),dr(e),Tp(e),Ip(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function Yv(e,t){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 s=t.has("setupStep")&&e.setupStep==="auth";(n||s)&&e.setupStep==="auth"&&(e.authConnected===!0?e.setupStep="whatsapp":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(i=>{e.channelsSnapshot=i,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"),s=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;ln(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&Ja(e,t.has("tab")||t.has("logsAutoFollow"))}function Qv(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 Xv(e,t,n){await Qi(e,t,n),await q(e,!0)}async function Zv(e,t){await nl(e,t),await q(e,!0)}async function Jv(e,t){await sl(e,t),await q(e,!0)}async function eb(e,t){await il(e,t)}async function tb(e,t){await rl(e,t)}async function nb(e){await wd(e),await Ae(e),await q(e,!0)}async function sb(e){await Ae(e),await q(e,!0)}function ib(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[s,...i]=n.split(":");if(!s||i.length===0)continue;const r=s.trim(),o=i.join(":").trim();r&&o&&(t[r]=o)}return t}function qc(e){var n,s,i;return((i=(((s=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:s.nostr)??[])[0])==null?void 0:i.accountId)??e.nostrProfileAccountId??"default"}function Gc(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function rb(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Qv(n??void 0)}function ob(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function ab(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function lb(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function cb(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=qc(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Gc(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||(i==null?void 0:i.ok)===!1||!i){const r=(i==null?void 0:i.error)??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:r,success:null,fieldErrors:ib(i==null?void 0:i.details)};return}if(!i.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 q(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function ub(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=qc(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Gc(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||(i==null?void 0:i.ok)===!1||!i){const l=(i==null?void 0:i.error)??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const r=i.merged??i.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:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:a},i.saved&&await q(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}async function db(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 pb(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 hb(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="",setTimeout(()=>{e.setupStep="whatsapp"},1500)):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 fb(e,t){e.authCodeInput=t}function gb(e){e.setupStep="whatsapp"}async function mb(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 vb(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 bb(e,t){e.licenseKey=t}async function wb(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("health",{probe:!0});e.gatewayHealthy=s.ok===!0,e.gatewayHealthMessage=s.ok?`Healthy${s.durationMs?` (${s.durationMs}ms)`:""}`:"Unhealthy"}catch(s){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(s)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function kb(e){var t,n,s;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(i.ok&&((n=i.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(i){e.gatewayHealthMessage=`Restart failed: ${String(i)}`,e.gatewayRestartBusy=!1,(s=e.requestUpdate)==null||s.call(e)}}}var Sb=Object.defineProperty,Ab=Object.getOwnPropertyDescriptor,m=(e,t,n,s)=>{for(var i=s>1?void 0:s?Ab(t,n):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&Sb(t,n,i),i};const fi=Pu();function xb(){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 $b(){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 s=n.trim().toLowerCase();return s==="1"||s==="true"||s==="yes"||s==="on"}function Eb(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function Tb(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function Cb(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function _b(){const e=window.location.pathname;return e==="/customers"||e.endsWith("/customers")}function Mb(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function Lb(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends kt{constructor(){super(...arguments),this.settings=Fs(),this.password="",this.tab="chat",this.onboarding=xb(),this.setup=$b(),this.filesPage=Eb(),this.browserPage=Tb(),this.adminsPage=Cb(),this.customersPage=_b(),this.chatPage=Mb(),this.advancedPage=Lb(),this.advancedTab="cron",this.connected=!1,this.accessState=Cc,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=fi.name,this.assistantAvatar=fi.avatar,this.assistantAgentId=fi.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=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=`{
2888
+ }
2889
+ `,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.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={...xv},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.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.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.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={...Av},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.sessionLogsFull=!1,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=()=>Dp(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),qv(this)}firstUpdated(){Gv(this)}disconnectedCallback(){Vv(this),super.disconnectedCallback()}updated(e){Yv(this,e)}connect(){_e(this)}handleChatScroll(e){dd(this,e)}handleLogsScroll(e){pd(this,e)}handleSessionLogsScroll(e){hd(this,e)}exportLogs(e,t){gd(e,t)}exportSessionLogs(e,t){md(e,t)}resetToolStream(){Yi(this)}resetChatScroll(){fd(this)}async loadAssistantIdentity(){await jc(this)}applySettings(e){Oe(this,e)}setTab(e){_p(this,e)}setTheme(e,t){Mp(this,e,t)}async loadOverview(){await Ml(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 hr(this)}async handleAbortChat(){await Pl(this)}removeQueuedMessage(e){Up(this,e)}async handleSendChat(e,t){await Wp(this,e,t)}async handleWhatsAppStart(e,t){await Xv(this,e,t)}async handleWhatsAppWait(e){await Zv(this,e)}async handleWhatsAppLogout(e){await Jv(this,e)}async handleAddWhatsAppAccount(e){await eb(this,e)}async handleRemoveWhatsAppAccount(e){await tb(this,e)}async handleAccessCheck(){await Ta(this)}async handlePinSubmit(e,t){await Fy(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await Uy(this,e)}async handleLogout(){await Ky(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 s=await this.client.request("access.verify",{account:e,pin:t});if(!s.ok){this.changePinError=s.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 s=await this.client.request("access.verify",{account:e,pin:t});if(!s.ok){this.accountPinError=s.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 Ta(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 mb(this)}async handleLicenseActivate(){await yb(this)}async handleLicenseRemove(){await vb(this)}handleLicenseKeyChange(e){bb(this,e)}async handleAuthStatusCheck(){await db(this)}async handleAuthStart(){await pb(this)}async handleAuthSubmitCode(e){await hb(this,e)}handleAuthCodeChange(e){fb(this,e)}handleSkipToWhatsApp(){gb(this)}async handleGatewayHealthCheck(){await wb(this)}async handleGatewayRestart(){await kb(this)}async handleUpdateCheck(){await Hc(this)}async handleUpdateRun(){await Nv(this)}handleUpdateDismissResult(){Bv(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 pe(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Eo);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){pe(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Eo);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await El(this)}async clearAudit(){await Ap(this),this.auditModalOpen=!1}handleFilesLoad(){const e=this.resolveFilesAgentId();pn(this,e),Ic(this,e)}handleAdminsLoad(){const e=this.resolveAdminAgentId();pe(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>av);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.chatRunId=null,this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}pe(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>ed);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this)})}handleAdvancedLoad(){this.loadCron()}async handleChannelConfigSave(){await nb(this)}async handleChannelConfigReload(){await sb(this)}handleNostrProfileEdit(e,t){rb(this,e,t)}handleNostrProfileCancel(){ob(this)}handleNostrProfileFieldChange(e,t){ab(this,e,t)}async handleNostrProfileSave(){await cb(this)}async handleNostrProfileImport(){await ub(this)}handleNostrProfileToggleAdvanced(){lb(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;pe(async()=>{const{loadCustomers:t}=await Promise.resolve().then(()=>lv);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 pe(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>Fn);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await pe(async()=>{const{createWorkspace:i}=await Promise.resolve().then(()=>Fn);return{createWorkspace:i}},void 0,import.meta.url),{loadChannels:s}=await pe(async()=>{const{loadChannels:i}=await Promise.resolve().then(()=>Td);return{loadChannels:i}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:i=>{if(!i.whatsappAccountId)return;const r=i.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await s(this,!0),await this.handleWhatsAppStart(!0,r),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(r),await s(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await pe(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>Fn);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 pe(async()=>{const{renameWorkspace:s}=await Promise.resolve().then(()=>Fn);return{renameWorkspace:s}},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),ho(e),this.settings=Fs(),this.chatMessage="",this.chatAttachments=[],this.chatStream=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)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(s=>s.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}ho(this.selectedWorkspace),this.settings=Fs(),this.reloadCurrentPageData()}render(){return h`${wv(this)}${this.auditModalOpen?Sv(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):k}`}};m([y()],g.prototype,"settings",2);m([y()],g.prototype,"password",2);m([y()],g.prototype,"tab",2);m([y()],g.prototype,"onboarding",2);m([y()],g.prototype,"setup",2);m([y()],g.prototype,"filesPage",2);m([y()],g.prototype,"browserPage",2);m([y()],g.prototype,"adminsPage",2);m([y()],g.prototype,"customersPage",2);m([y()],g.prototype,"chatPage",2);m([y()],g.prototype,"advancedPage",2);m([y()],g.prototype,"advancedTab",2);m([y()],g.prototype,"connected",2);m([y()],g.prototype,"accessState",2);m([y()],g.prototype,"theme",2);m([y()],g.prototype,"themeResolved",2);m([y()],g.prototype,"hello",2);m([y()],g.prototype,"lastError",2);m([y()],g.prototype,"eventLog",2);m([y()],g.prototype,"assistantName",2);m([y()],g.prototype,"assistantAvatar",2);m([y()],g.prototype,"assistantAgentId",2);m([y()],g.prototype,"sessionKey",2);m([y()],g.prototype,"chatLoading",2);m([y()],g.prototype,"chatSending",2);m([y()],g.prototype,"chatMessage",2);m([y()],g.prototype,"chatMessages",2);m([y()],g.prototype,"chatToolMessages",2);m([y()],g.prototype,"chatStream",2);m([y()],g.prototype,"chatStreamStartedAt",2);m([y()],g.prototype,"chatRunId",2);m([y()],g.prototype,"compactionStatus",2);m([y()],g.prototype,"chatAvatarUrl",2);m([y()],g.prototype,"chatThinkingLevel",2);m([y()],g.prototype,"chatModelProvider",2);m([y()],g.prototype,"chatModel",2);m([y()],g.prototype,"chatModelCatalog",2);m([y()],g.prototype,"chatVerboseLevel",2);m([y()],g.prototype,"chatFillerEnabled",2);m([y()],g.prototype,"chatQueue",2);m([y()],g.prototype,"chatAttachments",2);m([y()],g.prototype,"sidebarOpen",2);m([y()],g.prototype,"sidebarContent",2);m([y()],g.prototype,"sidebarError",2);m([y()],g.prototype,"splitRatio",2);m([y()],g.prototype,"nodesLoading",2);m([y()],g.prototype,"nodes",2);m([y()],g.prototype,"devicesLoading",2);m([y()],g.prototype,"devicesError",2);m([y()],g.prototype,"devicesList",2);m([y()],g.prototype,"execApprovalsLoading",2);m([y()],g.prototype,"execApprovalsSaving",2);m([y()],g.prototype,"execApprovalsDirty",2);m([y()],g.prototype,"execApprovalsSnapshot",2);m([y()],g.prototype,"execApprovalsForm",2);m([y()],g.prototype,"execApprovalsSelectedAgent",2);m([y()],g.prototype,"execApprovalsTarget",2);m([y()],g.prototype,"execApprovalsTargetNodeId",2);m([y()],g.prototype,"execApprovalQueue",2);m([y()],g.prototype,"execApprovalBusy",2);m([y()],g.prototype,"execApprovalError",2);m([y()],g.prototype,"configLoading",2);m([y()],g.prototype,"configRaw",2);m([y()],g.prototype,"configRawOriginal",2);m([y()],g.prototype,"configValid",2);m([y()],g.prototype,"configIssues",2);m([y()],g.prototype,"configSaving",2);m([y()],g.prototype,"configApplying",2);m([y()],g.prototype,"updateRunning",2);m([y()],g.prototype,"applySessionKey",2);m([y()],g.prototype,"configSnapshot",2);m([y()],g.prototype,"configSchema",2);m([y()],g.prototype,"configSchemaVersion",2);m([y()],g.prototype,"configSchemaLoading",2);m([y()],g.prototype,"configUiHints",2);m([y()],g.prototype,"configForm",2);m([y()],g.prototype,"configFormOriginal",2);m([y()],g.prototype,"configFormDirty",2);m([y()],g.prototype,"configFormMode",2);m([y()],g.prototype,"configSearchQuery",2);m([y()],g.prototype,"configActiveSection",2);m([y()],g.prototype,"configActiveSubsection",2);m([y()],g.prototype,"channelsLoading",2);m([y()],g.prototype,"channelsSnapshot",2);m([y()],g.prototype,"channelsError",2);m([y()],g.prototype,"channelsLastSuccess",2);m([y()],g.prototype,"whatsappLoginMessage",2);m([y()],g.prototype,"whatsappLoginQrDataUrl",2);m([y()],g.prototype,"whatsappLoginConnected",2);m([y()],g.prototype,"whatsappBusy",2);m([y()],g.prototype,"whatsappActiveQrAccountId",2);m([y()],g.prototype,"whatsappPairedPhone",2);m([y()],g.prototype,"addingWhatsAppAccount",2);m([y()],g.prototype,"newWhatsAppAccountName",2);m([y()],g.prototype,"whatsappAccountError",2);m([y()],g.prototype,"whatsappAccountSaving",2);m([y()],g.prototype,"whatsappSettingsOpen",2);m([y()],g.prototype,"licenseKey",2);m([y()],g.prototype,"licenseBusy",2);m([y()],g.prototype,"licenseValid",2);m([y()],g.prototype,"licenseMessage",2);m([y()],g.prototype,"licenseTier",2);m([y()],g.prototype,"licenseDeviceId",2);m([y()],g.prototype,"licenseStoredKey",2);m([y()],g.prototype,"licenseRemoveConfirm",2);m([y()],g.prototype,"authConnected",2);m([y()],g.prototype,"authBusy",2);m([y()],g.prototype,"authMessage",2);m([y()],g.prototype,"authUrl",2);m([y()],g.prototype,"authCodeInput",2);m([y()],g.prototype,"authExpiresIn",2);m([y()],g.prototype,"setupStep",2);m([y()],g.prototype,"gatewayHealthy",2);m([y()],g.prototype,"gatewayHealthLoading",2);m([y()],g.prototype,"gatewayHealthMessage",2);m([y()],g.prototype,"gatewayRestartBusy",2);m([y()],g.prototype,"updateAvailable",2);m([y()],g.prototype,"currentVersion",2);m([y()],g.prototype,"latestVersion",2);m([y()],g.prototype,"updateChecking",2);m([y()],g.prototype,"updateMessage",2);m([y()],g.prototype,"updateProgressSteps",2);m([y()],g.prototype,"updateLastResult",2);m([y()],g.prototype,"uninstallConfirm",2);m([y()],g.prototype,"uninstallBusy",2);m([y()],g.prototype,"uninstallDone",2);m([y()],g.prototype,"uninstallError",2);m([y()],g.prototype,"uninstallConfirmText",2);m([y()],g.prototype,"nostrProfileFormState",2);m([y()],g.prototype,"nostrProfileAccountId",2);m([y()],g.prototype,"presenceLoading",2);m([y()],g.prototype,"presenceEntries",2);m([y()],g.prototype,"presenceError",2);m([y()],g.prototype,"presenceStatus",2);m([y()],g.prototype,"agentsLoading",2);m([y()],g.prototype,"agentsList",2);m([y()],g.prototype,"agentsError",2);m([y()],g.prototype,"sessionsLoading",2);m([y()],g.prototype,"sessionsResult",2);m([y()],g.prototype,"sessionsError",2);m([y()],g.prototype,"cronLoading",2);m([y()],g.prototype,"cronJobs",2);m([y()],g.prototype,"cronStatus",2);m([y()],g.prototype,"cronError",2);m([y()],g.prototype,"cronForm",2);m([y()],g.prototype,"cronRunsJobId",2);m([y()],g.prototype,"cronRuns",2);m([y()],g.prototype,"cronBusy",2);m([y()],g.prototype,"cronNewEventModal",2);m([y()],g.prototype,"cronDetailJobId",2);m([y()],g.prototype,"browserScreencastActive",2);m([y()],g.prototype,"browserScreencastFrame",2);m([y()],g.prototype,"browserScreencastMetadata",2);m([y()],g.prototype,"browserHandoffPending",2);m([y()],g.prototype,"browserHandoffReason",2);m([y()],g.prototype,"browserHandoffId",2);m([y()],g.prototype,"browserInputMode",2);m([y()],g.prototype,"browserLoading",2);m([y()],g.prototype,"browserError",2);m([y()],g.prototype,"filesLoading",2);m([y()],g.prototype,"filesTree",2);m([y()],g.prototype,"filesRoot",2);m([y()],g.prototype,"filesError",2);m([y()],g.prototype,"filesSelectedPath",2);m([y()],g.prototype,"filesSelectedPaths",2);m([y()],g.prototype,"filesPreviewContent",2);m([y()],g.prototype,"filesPreviewLoading",2);m([y()],g.prototype,"filesPreviewBinary",2);m([y()],g.prototype,"filesPreviewSize",2);m([y()],g.prototype,"filesExpandedDirs",2);m([y()],g.prototype,"filesMessage",2);m([y()],g.prototype,"filesUploadBusy",2);m([y()],g.prototype,"filesReindexBusy",2);m([y()],g.prototype,"filesMemoryStatus",2);m([y()],g.prototype,"auditEntries",2);m([y()],g.prototype,"auditLoading",2);m([y()],g.prototype,"auditModalOpen",2);m([y()],g.prototype,"skillsLoading",2);m([y()],g.prototype,"skillsReport",2);m([y()],g.prototype,"skillsError",2);m([y()],g.prototype,"skillsFilter",2);m([y()],g.prototype,"skillEdits",2);m([y()],g.prototype,"skillsBusyKey",2);m([y()],g.prototype,"skillMessages",2);m([y()],g.prototype,"adminsLoading",2);m([y()],g.prototype,"adminPhones",2);m([y()],g.prototype,"adminsError",2);m([y()],g.prototype,"adminsSaving",2);m([y()],g.prototype,"adminsNewPhone",2);m([y()],g.prototype,"customersLoading",2);m([y()],g.prototype,"customersSaving",2);m([y()],g.prototype,"customersRecords",2);m([y()],g.prototype,"customersError",2);m([y()],g.prototype,"customersSearchQuery",2);m([y()],g.prototype,"customersEditingId",2);m([y()],g.prototype,"customersShowAddForm",2);m([y()],g.prototype,"customersNewPhone",2);m([y()],g.prototype,"customersNewName",2);m([y()],g.prototype,"imessageEnableConfirm",2);m([y()],g.prototype,"imessageEnabling",2);m([y()],g.prototype,"infoModalOpen",2);m([y()],g.prototype,"workspaces",2);m([y()],g.prototype,"workspacesLoading",2);m([y()],g.prototype,"workspacesError",2);m([y()],g.prototype,"selectedWorkspace",2);m([y()],g.prototype,"addingWorkspace",2);m([y()],g.prototype,"newWorkspaceName",2);m([y()],g.prototype,"newWorkspacePath",2);m([y()],g.prototype,"newWorkspacePin",2);m([y()],g.prototype,"accountPinModalOpen",2);m([y()],g.prototype,"accountPinBusy",2);m([y()],g.prototype,"accountPinError",2);m([y()],g.prototype,"accountPinSuccess",2);m([y()],g.prototype,"apiKeyProviders",2);m([y()],g.prototype,"apiKeyModalOpen",2);m([y()],g.prototype,"apiKeyBusy",2);m([y()],g.prototype,"apiKeyError",2);m([y()],g.prototype,"apiKeySuccess",2);m([y()],g.prototype,"authApiKeyMode",2);m([y()],g.prototype,"authApiKeyInput",2);m([y()],g.prototype,"authApiKeyBusy",2);m([y()],g.prototype,"authApiKeyError",2);m([y()],g.prototype,"pinChanging",2);m([y()],g.prototype,"pinChangeBusy",2);m([y()],g.prototype,"pinChangeError",2);m([y()],g.prototype,"loginChangePinMode",2);m([y()],g.prototype,"changePinBusy",2);m([y()],g.prototype,"changePinError",2);m([y()],g.prototype,"changePinSuccess",2);m([y()],g.prototype,"workspaceSaving",2);m([y()],g.prototype,"workspaceRemoveConfirm",2);m([y()],g.prototype,"renamingWorkspace",2);m([y()],g.prototype,"renameWorkspaceName",2);m([y()],g.prototype,"debugLoading",2);m([y()],g.prototype,"debugStatus",2);m([y()],g.prototype,"debugHealth",2);m([y()],g.prototype,"debugModels",2);m([y()],g.prototype,"debugHeartbeat",2);m([y()],g.prototype,"debugCallMethod",2);m([y()],g.prototype,"debugCallParams",2);m([y()],g.prototype,"debugCallResult",2);m([y()],g.prototype,"debugCallError",2);m([y()],g.prototype,"logsLoading",2);m([y()],g.prototype,"logsError",2);m([y()],g.prototype,"logsFile",2);m([y()],g.prototype,"logsEntries",2);m([y()],g.prototype,"logsFilterText",2);m([y()],g.prototype,"logsLevelFilters",2);m([y()],g.prototype,"logsAutoFollow",2);m([y()],g.prototype,"logsTruncated",2);m([y()],g.prototype,"logsCursor",2);m([y()],g.prototype,"logsLastFetchAt",2);m([y()],g.prototype,"logsLimit",2);m([y()],g.prototype,"logsMaxBytes",2);m([y()],g.prototype,"logsAtBottom",2);m([y()],g.prototype,"logsSubTab",2);m([y()],g.prototype,"sessionLogsLoading",2);m([y()],g.prototype,"sessionLogsError",2);m([y()],g.prototype,"sessionLogsEntries",2);m([y()],g.prototype,"sessionLogsFilterText",2);m([y()],g.prototype,"sessionLogsTypeFilters",2);m([y()],g.prototype,"sessionLogsAgentFilters",2);m([y()],g.prototype,"sessionLogsAgents",2);m([y()],g.prototype,"sessionLogsAutoFollow",2);m([y()],g.prototype,"sessionLogsFull",2);m([y()],g.prototype,"sessionLogsCursors",2);m([y()],g.prototype,"sessionLogsLastFetchAt",2);m([y()],g.prototype,"sessionLogsAtBottom",2);m([y()],g.prototype,"chatUserNearBottom",2);g=m([Ua("taskmaster-app")],g);
2890
+ //# sourceMappingURL=index-gQeHDI6a.js.map