@rubytech/taskmaster 1.0.100 → 1.0.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,23 @@
1
- var Fu=Object.defineProperty;var Uu=(e,t,n)=>t in e?Fu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var U=(e,t,n)=>Uu(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const Wu="modulepreload",Ku=function(e,t){return new URL(e,t).href},dr={},ie=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let c=function(l){return Promise.all(l.map(d=>Promise.resolve(d).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};const r=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),u=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=c(n.map(l=>{if(l=Ku(l,i),l in dr)return;dr[l]=!0;const d=l.endsWith(".css"),h=d?'[rel="stylesheet"]':"";if(i)for(let f=r.length-1;f>=0;f--){const b=r[f];if(b.href===l&&(!d||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${h}`))return;const v=document.createElement("link");if(v.rel=d?"stylesheet":Wu,d||(v.as="script"),v.crossOrigin="",v.href=l,u&&v.setAttribute("nonce",u),document.head.appendChild(v),d)return new Promise((f,b)=>{v.addEventListener("load",f),v.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(r){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=r,window.dispatchEvent(a),!a.defaultPrevented)throw r}return s.then(r=>{for(const a of r||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};const Gn=globalThis,eo=Gn.ShadowRoot&&(Gn.ShadyCSS===void 0||Gn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,to=Symbol(),pr=new WeakMap;let nl=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==to)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(eo&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=pr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&pr.set(n,t))}return t}toString(){return this.cssText}};const zu=e=>new nl(typeof e=="string"?e:e+"",void 0,to),ju=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((i,s,o)=>i+(r=>{if(r._$cssResult$===!0)return r.cssText;if(typeof r=="number")return r;throw Error("Value passed to 'css' function must be a 'css' function result: "+r+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[o+1],e[0]);return new nl(n,e,to)},Hu=(e,t)=>{if(eo)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=Gn.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},hr=eo?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return zu(n)})(e):e;const{is:qu,defineProperty:Vu,getOwnPropertyDescriptor:Gu,getOwnPropertyNames:Qu,getOwnPropertySymbols:Yu,getPrototypeOf:Xu}=Object,Ve=globalThis,fr=Ve.trustedTypes,Zu=fr?fr.emptyScript:"",Hi=Ve.reactiveElementPolyfillSupport,nn=(e,t)=>e,Jn={toAttribute(e,t){switch(t){case Boolean:e=e?Zu:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},no=(e,t)=>!qu(e,t),gr={attribute:!0,type:String,converter:Jn,reflect:!1,useDefault:!1,hasChanged:no};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Ve.litPropertyMetadata??(Ve.litPropertyMetadata=new WeakMap);let Ct=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=gr){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,n);s!==void 0&&Vu(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=Gu(this.prototype,t)??{get(){return this[n]},set(r){this[n]=r}};return{get:s,set(r){const a=s==null?void 0:s.call(this);o==null||o.call(this,r),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??gr}static _$Ei(){if(this.hasOwnProperty(nn("elementProperties")))return;const t=Xu(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(nn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(nn("properties"))){const n=this.properties,i=[...Qu(n),...Yu(n)];for(const s of i)this.createProperty(s,n[s])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[i,s]of n)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[n,i]of this.elementProperties){const s=this._$Eu(n,i);s!==void 0&&this._$Eh.set(s,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)n.unshift(hr(s))}else t!==void 0&&n.push(hr(t));return n}static _$Eu(t,n){const i=n.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(n=>n(this))}addController(t){var n;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)==null||n.call(t))}removeController(t){var n;(n=this._$EO)==null||n.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const i of n.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Hu(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostConnected)==null?void 0:i.call(n)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostDisconnected)==null?void 0:i.call(n)})}attributeChangedCallback(t,n,i){this._$AK(t,i)}_$ET(t,n){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const r=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Jn).toAttribute(n,i.type);this._$Em=t,r==null?this.removeAttribute(s):this.setAttribute(s,r),this._$Em=null}}_$AK(t,n){var o,r;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const a=i.getPropertyOptions(s),u=typeof a.converter=="function"?{fromAttribute:a.converter}:((o=a.converter)==null?void 0:o.fromAttribute)!==void 0?a.converter:Jn;this._$Em=s;const c=u.fromAttribute(n,a.type);this[s]=c??((r=this._$Ej)==null?void 0:r.get(s))??c,this._$Em=null}}requestUpdate(t,n,i,s=!1,o){var r;if(t!==void 0){const a=this.constructor;if(s===!1&&(o=this[t]),i??(i=a.getPropertyOptions(t)),!((i.hasChanged??no)(o,n)||i.useDefault&&i.reflect&&o===((r=this._$Ej)==null?void 0:r.get(t))&&!this.hasAttribute(a._$Eu(t,i))))return;this.C(t,n,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:i,reflect:s,wrapped:o},r){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,r??n??this[t]),o!==!0||r!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(n=void 0),this._$AL.set(t,n)),s===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,r]of this._$Ep)this[o]=r;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,r]of s){const{wrapped:a}=r,u=this[o];a!==!0||this._$AL.has(o)||u===void 0||this.C(o,void 0,r,u)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),(i=this._$EO)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){var n;(n=this._$EO)==null||n.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(n=>this._$ET(n,this[n]))),this._$EM()}updated(t){}firstUpdated(t){}};Ct.elementStyles=[],Ct.shadowRootOptions={mode:"open"},Ct[nn("elementProperties")]=new Map,Ct[nn("finalized")]=new Map,Hi==null||Hi({ReactiveElement:Ct}),(Ve.reactiveElementVersions??(Ve.reactiveElementVersions=[])).push("2.1.2");const sn=globalThis,mr=e=>e,ei=sn.trustedTypes,yr=ei?ei.createPolicy("lit-html",{createHTML:e=>e}):void 0,il="$lit$",qe=`lit$${Math.random().toFixed(9).slice(2)}$`,sl="?"+qe,Ju=`<${sl}>`,lt=document,pn=()=>lt.createComment(""),hn=e=>e===null||typeof e!="object"&&typeof e!="function",io=Array.isArray,ed=e=>io(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",qi=`[
2
- \f\r]`,jt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,vr=/-->/g,br=/>/g,nt=RegExp(`>|${qi}(?:([^\\s"'>=/]+)(${qi}*=${qi}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),wr=/'/g,kr=/"/g,ol=/^(?:script|style|textarea|title)$/i,td=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),p=td(1),Qe=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),Sr=new WeakMap,ot=lt.createTreeWalker(lt,129);function rl(e,t){if(!io(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return yr!==void 0?yr.createHTML(t):t}const nd=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",r=jt;for(let a=0;a<n;a++){const u=e[a];let c,l,d=-1,h=0;for(;h<u.length&&(r.lastIndex=h,l=r.exec(u),l!==null);)h=r.lastIndex,r===jt?l[1]==="!--"?r=vr:l[1]!==void 0?r=br:l[2]!==void 0?(ol.test(l[2])&&(s=RegExp("</"+l[2],"g")),r=nt):l[3]!==void 0&&(r=nt):r===nt?l[0]===">"?(r=s??jt,d=-1):l[1]===void 0?d=-2:(d=r.lastIndex-l[2].length,c=l[1],r=l[3]===void 0?nt:l[3]==='"'?kr:wr):r===kr||r===wr?r=nt:r===vr||r===br?r=jt:(r=nt,s=void 0);const v=r===nt&&e[a+1].startsWith("/>")?" ":"";o+=r===jt?u+Ju:d>=0?(i.push(c),u.slice(0,d)+il+u.slice(d)+qe+v):u+qe+(d===-2?a:v)}return[rl(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let Cs=class al{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,r=0;const a=t.length-1,u=this.parts,[c,l]=nd(t,n);if(this.el=al.createElement(c,i),ot.currentNode=this.el.content,n===2||n===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=ot.nextNode())!==null&&u.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith(il)){const h=l[r++],v=s.getAttribute(d).split(qe),f=/([.?@])?(.*)/.exec(h);u.push({type:1,index:o,name:f[2],strings:v,ctor:f[1]==="."?sd:f[1]==="?"?od:f[1]==="@"?rd:ki}),s.removeAttribute(d)}else d.startsWith(qe)&&(u.push({type:6,index:o}),s.removeAttribute(d));if(ol.test(s.tagName)){const d=s.textContent.split(qe),h=d.length-1;if(h>0){s.textContent=ei?ei.emptyScript:"";for(let v=0;v<h;v++)s.append(d[v],pn()),ot.nextNode(),u.push({type:2,index:++o});s.append(d[h],pn())}}}else if(s.nodeType===8)if(s.data===sl)u.push({type:2,index:o});else{let d=-1;for(;(d=s.data.indexOf(qe,d+1))!==-1;)u.push({type:7,index:o}),d+=qe.length-1}o++}}static createElement(t,n){const i=lt.createElement("template");return i.innerHTML=t,i}};function Lt(e,t,n=e,i){var r,a;if(t===Qe)return t;let s=i!==void 0?(r=n._$Co)==null?void 0:r[i]:n._$Cl;const o=hn(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),o===void 0?s=void 0:(s=new o(e),s._$AT(e,n,i)),i!==void 0?(n._$Co??(n._$Co=[]))[i]=s:n._$Cl=s),s!==void 0&&(t=Lt(e,s._$AS(e,t.values),s,i)),t}class id{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??lt).importNode(n,!0);ot.currentNode=s;let o=ot.nextNode(),r=0,a=0,u=i[0];for(;u!==void 0;){if(r===u.index){let c;u.type===2?c=new wi(o,o.nextSibling,this,t):u.type===1?c=new u.ctor(o,u.name,u.strings,this,t):u.type===6&&(c=new ad(o,this,t)),this._$AV.push(c),u=i[++a]}r!==(u==null?void 0:u.index)&&(o=ot.nextNode(),r++)}return ot.currentNode=lt,s}p(t){let n=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,n),n+=i.strings.length-2):i._$AI(t[n])),n++}}let wi=class ll{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,n,i,s){this.type=2,this._$AH=k,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=Lt(this,t,n),hn(t)?t===k||t==null||t===""?(this._$AH!==k&&this._$AR(),this._$AH=k):t!==this._$AH&&t!==Qe&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):ed(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&&hn(this._$AH)?this._$AA.nextSibling.data=t:this.T(lt.createTextNode(t)),this._$AH=t}$(t){var o;const{values:n,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Cs.createElement(rl(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(n);else{const r=new id(s,this),a=r.u(this.options);r.p(n),this.T(a),this._$AH=r}}_$AC(t){let n=Sr.get(t.strings);return n===void 0&&Sr.set(t.strings,n=new Cs(t)),n}k(t){io(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let i,s=0;for(const o of t)s===n.length?n.push(i=new ll(this.O(pn()),this.O(pn()),this,this.options)):i=n[s],i._$AI(o),s++;s<n.length&&(this._$AR(i&&i._$AB.nextSibling,s),n.length=s)}_$AR(t=this._$AA.nextSibling,n){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,n);t!==this._$AB;){const s=mr(t).nextSibling;mr(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class ki{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=k,this._$AN=void 0,this.element=t,this.name=n,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=k}_$AI(t,n=this,i,s){const o=this.strings;let r=!1;if(o===void 0)t=Lt(this,t,n,0),r=!hn(t)||t!==this._$AH&&t!==Qe,r&&(this._$AH=t);else{const a=t;let u,c;for(t=o[0],u=0;u<o.length-1;u++)c=Lt(this,a[i+u],n,u),c===Qe&&(c=this._$AH[u]),r||(r=!hn(c)||c!==this._$AH[u]),c===k?t=k:t!==k&&(t+=(c??"")+o[u+1]),this._$AH[u]=c}r&&!s&&this.j(t)}j(t){t===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let sd=class extends ki{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===k?void 0:t}},od=class extends ki{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==k)}},rd=class extends ki{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=Lt(this,t,n,0)??k)===Qe)return;const i=this._$AH,s=t===k&&i!==k||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==k&&(i===k||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,t):this._$AH.handleEvent(t)}},ad=class{constructor(t,n,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Lt(this,t)}};const ld={I:wi},Vi=sn.litHtmlPolyfillSupport;Vi==null||Vi(Cs,wi),(sn.litHtmlVersions??(sn.litHtmlVersions=[])).push("3.3.2");const cd=(e,t,n)=>{const i=(n==null?void 0:n.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const o=(n==null?void 0:n.renderBefore)??null;i._$litPart$=s=new wi(t.insertBefore(pn(),o),o,void 0,n??{})}return s._$AI(e),s};const at=globalThis;let _t=class extends Ct{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=cd(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 Qe}};var tl;_t._$litElement$=!0,_t.finalized=!0,(tl=at.litElementHydrateSupport)==null||tl.call(at,{LitElement:_t});const Gi=at.litElementPolyfillSupport;Gi==null||Gi({LitElement:_t});(at.litElementVersions??(at.litElementVersions=[])).push("4.2.2");const cl=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const ud={attribute:!0,type:String,converter:Jn,reflect:!1,hasChanged:no},dd=(e=ud,t,n)=>{const{kind:i,metadata:s}=n;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(n.name,e),i==="accessor"){const{name:r}=n;return{set(a){const u=t.get.call(this);t.set.call(this,a),this.requestUpdate(r,u,e,!0,a)},init(a){return a!==void 0&&this.C(r,void 0,e,a),a}}}if(i==="setter"){const{name:r}=n;return function(a){const u=this[r];t.call(this,a),this.requestUpdate(r,u,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function Si(e){return(t,n)=>typeof n=="object"?dd(e,t,n):((i,s,o)=>{const r=s.hasOwnProperty(o);return s.constructor.createProperty(o,i),r?Object.getOwnPropertyDescriptor(s,o):void 0})(e,t,n)}function y(e){return Si({...e,state:!0,attribute:!1})}const pd=50,hd=200,fd="Assistant";function xr(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function Ts(e){const t=xr(e==null?void 0:e.name,pd)??fd,n=xr((e==null?void 0:e.avatar)??void 0,hd)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function gd(){return Ts(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const ti="taskmaster.control.settings.v1",ul="taskmaster.account.settings.";function on(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const Et={gatewayUrl:on(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},He={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function md(){try{const e=localStorage.getItem(ti);if(!e)return{...Et,gatewayUrl:on()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():on(),token:typeof t.token=="string"?t.token:Et.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:Et.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:Et.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:Et.navGroupsCollapsed}}catch{return{...Et,gatewayUrl:on()}}}function yd(e){if(!e)return{...He};try{const t=localStorage.getItem(ul+e);if(!t)return{...He};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():He.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||He.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:He.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:He.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:He.splitRatio}}catch{return{...He}}}let ni=null;function $r(e){ni=e}function Qi(){return{...md(),...yd(ni)}}function vd(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(ti,JSON.stringify(t)),ni){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(ul+ni,JSON.stringify(n))}}(function(){try{const t=localStorage.getItem(ti);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:on(),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(ti,JSON.stringify(i))}catch{}})();function dl(e){var o;const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const i=(o=n[1])==null?void 0:o.trim(),s=n.slice(2).join(":");return!i||!s?null:{agentId:i,rest:s}}const bd=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Ln=/<\s*\/?\s*final\b[^>]*>/gi,Ar=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function wd(e,t){return e.trimStart()}function kd(e,t){if(!e||!bd.test(e))return e;let n=e;Ln.test(n)?(Ln.lastIndex=0,n=n.replace(Ln,"")):Ln.lastIndex=0,Ar.lastIndex=0;let i="",s=0,o=!1;for(const r of n.matchAll(Ar)){const a=r.index??0,u=r[1]==="/";o?u&&(o=!1):(i+=n.slice(s,a),u||(o=!0)),s=a+r[0].length}return i+=n.slice(s),wd(i)}function pl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function xi(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const r=-t,a=Math.round(r/1e3);if(a<60)return`in ${a}s`;const u=Math.round(a/60);if(u<60)return`in ${u}m`;const c=Math.round(u/60);return c<48?`in ${c}h`:`in ${Math.round(c/24)}d`}const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<48?`${s}h ago`:`${Math.round(s/24)}d ago`}function hl(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const i=Math.round(n/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function Sd(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function fl(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 ii(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Yi(e){return kd(e)}const xd=/^\[([^\]]+)\]\s*/,$d=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Xi=new WeakMap,Zi=new WeakMap;function Ad(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:$d.some(t=>e.startsWith(`${t} `))}function Ji(e){const t=e.match(xd);if(!t)return e;const n=t[1]??"";return Ad(n)?e.slice(t[0].length):e}function rn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?Yi(i):Ji(i);if(Array.isArray(i)){const s=i.map(o=>{const r=o;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(o=>typeof o=="string");if(s.length>0){const o=s.join(`
4
- `);return n==="assistant"?Yi(o):Ji(o)}}return typeof t.text=="string"?n==="assistant"?Yi(t.text):Ji(t.text):null}function gl(e){if(!e||typeof e!="object")return rn(e);const t=e;if(Xi.has(t))return Xi.get(t)??null;const n=rn(e);return Xi.set(t,n),n}function Er(e){const n=e.content,i=[];if(Array.isArray(n))for(const a of n){const u=a;if(u.type==="thinking"&&typeof u.thinking=="string"){const c=u.thinking.trim();c&&i.push(c)}}if(i.length>0)return i.join(`
1
+ var Fu=Object.defineProperty;var Uu=(e,t,n)=>t in e?Fu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var U=(e,t,n)=>Uu(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const Wu="modulepreload",Ku=function(e,t){return new URL(e,t).href},pr={},ie=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let c=function(l){return Promise.all(l.map(d=>Promise.resolve(d).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};const r=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),u=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=c(n.map(l=>{if(l=Ku(l,i),l in pr)return;pr[l]=!0;const d=l.endsWith(".css"),h=d?'[rel="stylesheet"]':"";if(i)for(let f=r.length-1;f>=0;f--){const b=r[f];if(b.href===l&&(!d||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${h}`))return;const v=document.createElement("link");if(v.rel=d?"stylesheet":Wu,d||(v.as="script"),v.crossOrigin="",v.href=l,u&&v.setAttribute("nonce",u),document.head.appendChild(v),d)return new Promise((f,b)=>{v.addEventListener("load",f),v.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(r){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=r,window.dispatchEvent(a),!a.defaultPrevented)throw r}return s.then(r=>{for(const a of r||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};const Qn=globalThis,to=Qn.ShadowRoot&&(Qn.ShadyCSS===void 0||Qn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,no=Symbol(),hr=new WeakMap;let il=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==no)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(to&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=hr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&hr.set(n,t))}return t}toString(){return this.cssText}};const zu=e=>new il(typeof e=="string"?e:e+"",void 0,no),ju=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((i,s,o)=>i+(r=>{if(r._$cssResult$===!0)return r.cssText;if(typeof r=="number")return r;throw Error("Value passed to 'css' function must be a 'css' function result: "+r+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[o+1],e[0]);return new il(n,e,no)},Hu=(e,t)=>{if(to)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=Qn.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},fr=to?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return zu(n)})(e):e;const{is:qu,defineProperty:Vu,getOwnPropertyDescriptor:Gu,getOwnPropertyNames:Qu,getOwnPropertySymbols:Yu,getPrototypeOf:Xu}=Object,Ve=globalThis,gr=Ve.trustedTypes,Zu=gr?gr.emptyScript:"",qi=Ve.reactiveElementPolyfillSupport,rn=(e,t)=>e,ei={toAttribute(e,t){switch(t){case Boolean:e=e?Zu:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},io=(e,t)=>!qu(e,t),mr={attribute:!0,type:String,converter:ei,reflect:!1,useDefault:!1,hasChanged:io};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Ve.litPropertyMetadata??(Ve.litPropertyMetadata=new WeakMap);let Tt=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,n=mr){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,n);s!==void 0&&Vu(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=Gu(this.prototype,t)??{get(){return this[n]},set(r){this[n]=r}};return{get:s,set(r){const a=s==null?void 0:s.call(this);o==null||o.call(this,r),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??mr}static _$Ei(){if(this.hasOwnProperty(rn("elementProperties")))return;const t=Xu(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(rn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(rn("properties"))){const n=this.properties,i=[...Qu(n),...Yu(n)];for(const s of i)this.createProperty(s,n[s])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[i,s]of n)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[n,i]of this.elementProperties){const s=this._$Eu(n,i);s!==void 0&&this._$Eh.set(s,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)n.unshift(fr(s))}else t!==void 0&&n.push(fr(t));return n}static _$Eu(t,n){const i=n.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(n=>n(this))}addController(t){var n;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)==null||n.call(t))}removeController(t){var n;(n=this._$EO)==null||n.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const i of n.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Hu(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostConnected)==null?void 0:i.call(n)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostDisconnected)==null?void 0:i.call(n)})}attributeChangedCallback(t,n,i){this._$AK(t,i)}_$ET(t,n){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const r=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:ei).toAttribute(n,i.type);this._$Em=t,r==null?this.removeAttribute(s):this.setAttribute(s,r),this._$Em=null}}_$AK(t,n){var o,r;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const a=i.getPropertyOptions(s),u=typeof a.converter=="function"?{fromAttribute:a.converter}:((o=a.converter)==null?void 0:o.fromAttribute)!==void 0?a.converter:ei;this._$Em=s;const c=u.fromAttribute(n,a.type);this[s]=c??((r=this._$Ej)==null?void 0:r.get(s))??c,this._$Em=null}}requestUpdate(t,n,i,s=!1,o){var r;if(t!==void 0){const a=this.constructor;if(s===!1&&(o=this[t]),i??(i=a.getPropertyOptions(t)),!((i.hasChanged??io)(o,n)||i.useDefault&&i.reflect&&o===((r=this._$Ej)==null?void 0:r.get(t))&&!this.hasAttribute(a._$Eu(t,i))))return;this.C(t,n,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:i,reflect:s,wrapped:o},r){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,r??n??this[t]),o!==!0||r!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(n=void 0),this._$AL.set(t,n)),s===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,r]of this._$Ep)this[o]=r;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,r]of s){const{wrapped:a}=r,u=this[o];a!==!0||this._$AL.has(o)||u===void 0||this.C(o,void 0,r,u)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),(i=this._$EO)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){var n;(n=this._$EO)==null||n.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(n=>this._$ET(n,this[n]))),this._$EM()}updated(t){}firstUpdated(t){}};Tt.elementStyles=[],Tt.shadowRootOptions={mode:"open"},Tt[rn("elementProperties")]=new Map,Tt[rn("finalized")]=new Map,qi==null||qi({ReactiveElement:Tt}),(Ve.reactiveElementVersions??(Ve.reactiveElementVersions=[])).push("2.1.2");const an=globalThis,yr=e=>e,ti=an.trustedTypes,vr=ti?ti.createPolicy("lit-html",{createHTML:e=>e}):void 0,sl="$lit$",qe=`lit$${Math.random().toFixed(9).slice(2)}$`,ol="?"+qe,Ju=`<${ol}>`,ct=document,gn=()=>ct.createComment(""),mn=e=>e===null||typeof e!="object"&&typeof e!="function",so=Array.isArray,ed=e=>so(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Vi=`[
2
+ \f\r]`,Vt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,br=/-->/g,wr=/>/g,nt=RegExp(`>|${Vi}(?:([^\\s"'>=/]+)(${Vi}*=${Vi}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),kr=/'/g,Sr=/"/g,rl=/^(?:script|style|textarea|title)$/i,td=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),p=td(1),Qe=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),xr=new WeakMap,rt=ct.createTreeWalker(ct,129);function al(e,t){if(!so(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return vr!==void 0?vr.createHTML(t):t}const nd=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",r=Vt;for(let a=0;a<n;a++){const u=e[a];let c,l,d=-1,h=0;for(;h<u.length&&(r.lastIndex=h,l=r.exec(u),l!==null);)h=r.lastIndex,r===Vt?l[1]==="!--"?r=br:l[1]!==void 0?r=wr:l[2]!==void 0?(rl.test(l[2])&&(s=RegExp("</"+l[2],"g")),r=nt):l[3]!==void 0&&(r=nt):r===nt?l[0]===">"?(r=s??Vt,d=-1):l[1]===void 0?d=-2:(d=r.lastIndex-l[2].length,c=l[1],r=l[3]===void 0?nt:l[3]==='"'?Sr:kr):r===Sr||r===kr?r=nt:r===br||r===wr?r=Vt:(r=nt,s=void 0);const v=r===nt&&e[a+1].startsWith("/>")?" ":"";o+=r===Vt?u+Ju:d>=0?(i.push(c),u.slice(0,d)+sl+u.slice(d)+qe+v):u+qe+(d===-2?a:v)}return[al(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let Ts=class ll{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,r=0;const a=t.length-1,u=this.parts,[c,l]=nd(t,n);if(this.el=ll.createElement(c,i),rt.currentNode=this.el.content,n===2||n===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=rt.nextNode())!==null&&u.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith(sl)){const h=l[r++],v=s.getAttribute(d).split(qe),f=/([.?@])?(.*)/.exec(h);u.push({type:1,index:o,name:f[2],strings:v,ctor:f[1]==="."?sd:f[1]==="?"?od:f[1]==="@"?rd:Si}),s.removeAttribute(d)}else d.startsWith(qe)&&(u.push({type:6,index:o}),s.removeAttribute(d));if(rl.test(s.tagName)){const d=s.textContent.split(qe),h=d.length-1;if(h>0){s.textContent=ti?ti.emptyScript:"";for(let v=0;v<h;v++)s.append(d[v],gn()),rt.nextNode(),u.push({type:2,index:++o});s.append(d[h],gn())}}}else if(s.nodeType===8)if(s.data===ol)u.push({type:2,index:o});else{let d=-1;for(;(d=s.data.indexOf(qe,d+1))!==-1;)u.push({type:7,index:o}),d+=qe.length-1}o++}}static createElement(t,n){const i=ct.createElement("template");return i.innerHTML=t,i}};function It(e,t,n=e,i){var r,a;if(t===Qe)return t;let s=i!==void 0?(r=n._$Co)==null?void 0:r[i]:n._$Cl;const o=mn(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),o===void 0?s=void 0:(s=new o(e),s._$AT(e,n,i)),i!==void 0?(n._$Co??(n._$Co=[]))[i]=s:n._$Cl=s),s!==void 0&&(t=It(e,s._$AS(e,t.values),s,i)),t}class id{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??ct).importNode(n,!0);rt.currentNode=s;let o=rt.nextNode(),r=0,a=0,u=i[0];for(;u!==void 0;){if(r===u.index){let c;u.type===2?c=new ki(o,o.nextSibling,this,t):u.type===1?c=new u.ctor(o,u.name,u.strings,this,t):u.type===6&&(c=new ad(o,this,t)),this._$AV.push(c),u=i[++a]}r!==(u==null?void 0:u.index)&&(o=rt.nextNode(),r++)}return rt.currentNode=ct,s}p(t){let n=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,n),n+=i.strings.length-2):i._$AI(t[n])),n++}}let ki=class cl{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,n,i,s){this.type=2,this._$AH=k,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=It(this,t,n),mn(t)?t===k||t==null||t===""?(this._$AH!==k&&this._$AR(),this._$AH=k):t!==this._$AH&&t!==Qe&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):ed(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&&mn(this._$AH)?this._$AA.nextSibling.data=t:this.T(ct.createTextNode(t)),this._$AH=t}$(t){var o;const{values:n,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Ts.createElement(al(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(n);else{const r=new id(s,this),a=r.u(this.options);r.p(n),this.T(a),this._$AH=r}}_$AC(t){let n=xr.get(t.strings);return n===void 0&&xr.set(t.strings,n=new Ts(t)),n}k(t){so(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let i,s=0;for(const o of t)s===n.length?n.push(i=new cl(this.O(gn()),this.O(gn()),this,this.options)):i=n[s],i._$AI(o),s++;s<n.length&&(this._$AR(i&&i._$AB.nextSibling,s),n.length=s)}_$AR(t=this._$AA.nextSibling,n){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,n);t!==this._$AB;){const s=yr(t).nextSibling;yr(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class Si{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=k,this._$AN=void 0,this.element=t,this.name=n,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=k}_$AI(t,n=this,i,s){const o=this.strings;let r=!1;if(o===void 0)t=It(this,t,n,0),r=!mn(t)||t!==this._$AH&&t!==Qe,r&&(this._$AH=t);else{const a=t;let u,c;for(t=o[0],u=0;u<o.length-1;u++)c=It(this,a[i+u],n,u),c===Qe&&(c=this._$AH[u]),r||(r=!mn(c)||c!==this._$AH[u]),c===k?t=k:t!==k&&(t+=(c??"")+o[u+1]),this._$AH[u]=c}r&&!s&&this.j(t)}j(t){t===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let sd=class extends Si{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===k?void 0:t}},od=class extends Si{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==k)}},rd=class extends Si{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=It(this,t,n,0)??k)===Qe)return;const i=this._$AH,s=t===k&&i!==k||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==k&&(i===k||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,t):this._$AH.handleEvent(t)}},ad=class{constructor(t,n,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){It(this,t)}};const ld={I:ki},Gi=an.litHtmlPolyfillSupport;Gi==null||Gi(Ts,ki),(an.litHtmlVersions??(an.litHtmlVersions=[])).push("3.3.2");const cd=(e,t,n)=>{const i=(n==null?void 0:n.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const o=(n==null?void 0:n.renderBefore)??null;i._$litPart$=s=new ki(t.insertBefore(gn(),o),o,void 0,n??{})}return s._$AI(e),s};const lt=globalThis;let Mt=class extends Tt{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=cd(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 Qe}};var nl;Mt._$litElement$=!0,Mt.finalized=!0,(nl=lt.litElementHydrateSupport)==null||nl.call(lt,{LitElement:Mt});const Qi=lt.litElementPolyfillSupport;Qi==null||Qi({LitElement:Mt});(lt.litElementVersions??(lt.litElementVersions=[])).push("4.2.2");const ul=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const ud={attribute:!0,type:String,converter:ei,reflect:!1,hasChanged:io},dd=(e=ud,t,n)=>{const{kind:i,metadata:s}=n;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(n.name,e),i==="accessor"){const{name:r}=n;return{set(a){const u=t.get.call(this);t.set.call(this,a),this.requestUpdate(r,u,e,!0,a)},init(a){return a!==void 0&&this.C(r,void 0,e,a),a}}}if(i==="setter"){const{name:r}=n;return function(a){const u=this[r];t.call(this,a),this.requestUpdate(r,u,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function xi(e){return(t,n)=>typeof n=="object"?dd(e,t,n):((i,s,o)=>{const r=s.hasOwnProperty(o);return s.constructor.createProperty(o,i),r?Object.getOwnPropertyDescriptor(s,o):void 0})(e,t,n)}function y(e){return xi({...e,state:!0,attribute:!1})}const pd=50,hd=200,fd="Assistant";function $r(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function _s(e){const t=$r(e==null?void 0:e.name,pd)??fd,n=$r((e==null?void 0:e.avatar)??void 0,hd)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function gd(){return _s(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const ni="taskmaster.control.settings.v1",dl="taskmaster.account.settings.";function ln(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const Ct={gatewayUrl:ln(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},He={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function md(){try{const e=localStorage.getItem(ni);if(!e)return{...Ct,gatewayUrl:ln()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():ln(),token:typeof t.token=="string"?t.token:Ct.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:Ct.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:Ct.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:Ct.navGroupsCollapsed}}catch{return{...Ct,gatewayUrl:ln()}}}function yd(e){if(!e)return{...He};try{const t=localStorage.getItem(dl+e);if(!t)return{...He};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():He.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||He.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:He.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:He.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:He.splitRatio}}catch{return{...He}}}let ii=null;function Ar(e){ii=e}function Yi(){return{...md(),...yd(ii)}}function vd(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(ni,JSON.stringify(t)),ii){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(dl+ii,JSON.stringify(n))}}(function(){try{const t=localStorage.getItem(ni);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:ln(),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(ni,JSON.stringify(i))}catch{}})();function pl(e){var o;const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const i=(o=n[1])==null?void 0:o.trim(),s=n.slice(2).join(":");return!i||!s?null:{agentId:i,rest:s}}const bd=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,In=/<\s*\/?\s*final\b[^>]*>/gi,Er=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function wd(e,t){return e.trimStart()}function kd(e,t){if(!e||!bd.test(e))return e;let n=e;In.test(n)?(In.lastIndex=0,n=n.replace(In,"")):In.lastIndex=0,Er.lastIndex=0;let i="",s=0,o=!1;for(const r of n.matchAll(Er)){const a=r.index??0,u=r[1]==="/";o?u&&(o=!1):(i+=n.slice(s,a),u||(o=!0)),s=a+r[0].length}return i+=n.slice(s),wd(i)}function hl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function $i(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const r=-t,a=Math.round(r/1e3);if(a<60)return`in ${a}s`;const u=Math.round(a/60);if(u<60)return`in ${u}m`;const c=Math.round(u/60);return c<48?`in ${c}h`:`in ${Math.round(c/24)}d`}const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<48?`${s}h ago`:`${Math.round(s/24)}d ago`}function fl(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const i=Math.round(n/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function Sd(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function gl(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 si(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Xi(e){return kd(e)}const xd=/^\[([^\]]+)\]\s*/,$d=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Zi=new WeakMap,Ji=new WeakMap;function Ad(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:$d.some(t=>e.startsWith(`${t} `))}function es(e){const t=e.match(xd);if(!t)return e;const n=t[1]??"";return Ad(n)?e.slice(t[0].length):e}function cn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?Xi(i):es(i);if(Array.isArray(i)){const s=i.map(o=>{const r=o;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(o=>typeof o=="string");if(s.length>0){const o=s.join(`
4
+ `);return n==="assistant"?Xi(o):es(o)}}return typeof t.text=="string"?n==="assistant"?Xi(t.text):es(t.text):null}function ml(e){if(!e||typeof e!="object")return cn(e);const t=e;if(Zi.has(t))return Zi.get(t)??null;const n=cn(e);return Zi.set(t,n),n}function Cr(e){const n=e.content,i=[];if(Array.isArray(n))for(const a of n){const u=a;if(u.type==="thinking"&&typeof u.thinking=="string"){const c=u.thinking.trim();c&&i.push(c)}}if(i.length>0)return i.join(`
5
5
  `);const s=Cd(e);if(!s)return null;const r=[...s.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(a=>(a[1]??"").trim()).filter(Boolean);return r.length>0?r.join(`
6
- `):null}function Ed(e){if(!e||typeof e!="object")return Er(e);const t=e;if(Zi.has(t))return Zi.get(t)??null;const n=Er(e);return Zi.set(t,n),n}function Cd(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const i=n.map(s=>{const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>typeof s=="string");if(i.length>0)return i.join(`
6
+ `):null}function Ed(e){if(!e||typeof e!="object")return Cr(e);const t=e;if(Ji.has(t))return Ji.get(t)??null;const n=Cr(e);return Ji.set(t,n),n}function Cd(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const i=n.map(s=>{const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>typeof s=="string");if(i.length>0)return i.join(`
7
7
  `)}return typeof t.text=="string"?t.text:null}function Td(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean).map(i=>`_${i}_`);return n.length?["_Reasoning:_",...n].join(`
8
- `):""}const _d=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Md=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Pd=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Ld=/^A new session was started via \/new or \/reset\./;function Id(e){const t=e,n=typeof t.role=="string"?t.role:"";let i="";typeof t.content=="string"?i=t.content:Array.isArray(t.content)?i=t.content.filter(o=>typeof o=="object"&&o!==null).map(o=>o.text??"").join(" "):typeof t.text=="string"&&(i=t.text);const s=i.trim();return s?!!(n==="user"&&_d.test(s)||n==="assistant"&&Md.test(s)||n==="user"&&Ld.test(s)||n==="assistant"&&Pd.test(s)):!1}function ml(e){return e.filter(t=>!Id(t))}function yl(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const i=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",s=t.content,o=Array.isArray(s)?s:null,r=Array.isArray(o)&&o.some(d=>{const v=String(d.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),a=typeof t.toolName=="string"||typeof t.tool_name=="string";(i||r||a)&&(n="toolResult");let u=[];typeof t.content=="string"?u=[{type:"text",text:t.content}]:Array.isArray(t.content)?u=t.content.map(d=>({type:d.type||"text",text:d.text,name:d.name,args:d.args||d.arguments})):typeof t.text=="string"&&(u=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),l=typeof t.id=="string"?t.id:void 0;return{role:n,content:u,timestamp:c,id:l}}function vl(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 bl(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function Cr(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 Rd(){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 so(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),Cr(t)}return Cr(Rd())}const Pe=50;async function Me(e,t){if(!e.client||!e.connected)return;e.chatLoading=!0,e.lastError=null;const n=(t==null?void 0:t.limit)??Pe;try{const i=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:n}),s=Array.isArray(i.messages)?i.messages:[],o=typeof i.totalMessages=="number"?i.totalMessages:s.length,r=ml(s);e.chatMessages=r,e.chatHistoryTotal=o,e.chatHistoryHasMore=o>s.length,e.chatThinkingLevel=i.thinkingLevel??null,e.chatModelProvider=typeof i.modelProvider=="string"?i.modelProvider:null,e.chatModel=typeof i.model=="string"?i.model:null,e.chatVerboseLevel=typeof i.verboseLevel=="string"?i.verboseLevel:null,e.chatFillerEnabled=typeof i.fillerEnabled=="boolean"?i.fillerEnabled:null}catch(i){e.lastError=String(i)}finally{e.chatLoading=!1}}async function Nd(e){if(!e.client||!e.connected||e.chatLoadingOlder||!e.chatHistoryHasMore)return!1;e.chatLoadingOlder=!0;try{const t=e.chatMessages.length,n=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:Pe,offset:t}),i=Array.isArray(n.messages)?n.messages:[],s=typeof n.totalMessages=="number"?n.totalMessages:0;if(i.length===0)return e.chatHistoryHasMore=!1,!1;const o=ml(i);return e.chatMessages=[...o,...e.chatMessages],e.chatHistoryTotal=s,e.chatHistoryHasMore=s>t+i.length,!0}catch(t){return e.lastError=String(t),!1}finally{e.chatLoadingOlder=!1}}function Dd(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function wl(e,t,n){if(e.chatSuggestion=null,!e.client||!e.connected)return!1;const i=t.trim(),s=n&&n.length>0;if(!i&&!s)return!1;const o=Date.now(),r=(n??[]).filter(v=>!v.fileName),a=(n??[]).filter(v=>v.fileName),u=[],c=a.map(v=>v.fileName).filter(Boolean);if(c.length>0){const v=i?`${c.join(", ")}
8
+ `):""}const _d=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Md=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Pd=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Ld=/^A new session was started via \/new or \/reset\./;function Id(e){const t=e,n=typeof t.role=="string"?t.role:"";let i="";typeof t.content=="string"?i=t.content:Array.isArray(t.content)?i=t.content.filter(o=>typeof o=="object"&&o!==null).map(o=>o.text??"").join(" "):typeof t.text=="string"&&(i=t.text);const s=i.trim();return s?!!(n==="user"&&_d.test(s)||n==="assistant"&&Md.test(s)||n==="user"&&Ld.test(s)||n==="assistant"&&Pd.test(s)):!1}function yl(e){return e.filter(t=>!Id(t))}function vl(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const i=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",s=t.content,o=Array.isArray(s)?s:null,r=Array.isArray(o)&&o.some(d=>{const v=String(d.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),a=typeof t.toolName=="string"||typeof t.tool_name=="string";(i||r||a)&&(n="toolResult");let u=[];typeof t.content=="string"?u=[{type:"text",text:t.content}]:Array.isArray(t.content)?u=t.content.map(d=>({type:d.type||"text",text:d.text,name:d.name,args:d.args||d.arguments})):typeof t.text=="string"&&(u=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),l=typeof t.id=="string"?t.id:void 0;return{role:n,content:u,timestamp:c,id:l}}function bl(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 wl(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function Tr(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 Rd(){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 oo(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),Tr(t)}return Tr(Rd())}const Pe=50;async function Me(e,t){if(!e.client||!e.connected)return;e.chatLoading=!0,e.lastError=null;const n=(t==null?void 0:t.limit)??Pe;try{const i=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:n}),s=Array.isArray(i.messages)?i.messages:[],o=typeof i.totalMessages=="number"?i.totalMessages:s.length,r=yl(s);e.chatMessages=r,e.chatHistoryTotal=o,e.chatHistoryHasMore=o>s.length,e.chatThinkingLevel=i.thinkingLevel??null,e.chatModelProvider=typeof i.modelProvider=="string"?i.modelProvider:null,e.chatModel=typeof i.model=="string"?i.model:null,e.chatVerboseLevel=typeof i.verboseLevel=="string"?i.verboseLevel:null,e.chatFillerEnabled=typeof i.fillerEnabled=="boolean"?i.fillerEnabled:null}catch(i){e.lastError=String(i)}finally{e.chatLoading=!1}}async function Nd(e){if(!e.client||!e.connected||e.chatLoadingOlder||!e.chatHistoryHasMore)return!1;e.chatLoadingOlder=!0;try{const t=e.chatMessages.length,n=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:Pe,offset:t}),i=Array.isArray(n.messages)?n.messages:[],s=typeof n.totalMessages=="number"?n.totalMessages:0;if(i.length===0)return e.chatHistoryHasMore=!1,!1;const o=yl(i);return e.chatMessages=[...o,...e.chatMessages],e.chatHistoryTotal=s,e.chatHistoryHasMore=s>t+i.length,!0}catch(t){return e.lastError=String(t),!1}finally{e.chatLoadingOlder=!1}}function Dd(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function kl(e,t,n){if(e.chatSuggestion=null,!e.client||!e.connected)return!1;const i=t.trim(),s=n&&n.length>0;if(!i&&!s)return!1;const o=Date.now(),r=(n??[]).filter(v=>!v.fileName),a=(n??[]).filter(v=>v.fileName),u=[],c=a.map(v=>v.fileName).filter(Boolean);if(c.length>0){const v=i?`${c.join(", ")}
9
9
 
10
- ${i}`:c.join(", ");u.push({type:"text",text:v})}else i&&u.push({type:"text",text:i});for(const v of r)u.push({type:"image",source:{type:"base64",media_type:v.mimeType,data:v.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:u,timestamp:o}],e.chatSending=!0,e.lastError=null;const l=so();e.chatRunId=l,e.chatStream="",e.chatStreamStartedAt=o;const d=[...r,...a],h=d.length>0?d.map(v=>{if(v.textContent)return{type:"document",mimeType:v.mimeType||"text/plain",fileName:v.fileName,content:btoa(unescape(encodeURIComponent(v.textContent)))};const f=Dd(v.dataUrl);return f?{type:v.fileName?"document":"image",mimeType:f.mimeType,fileName:v.fileName,content:f.content}:null}).filter(v=>v!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:l,attachments:h}),!0}catch(v){const f=String(v);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=f,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+f}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function kl(e){if(!e.client||!e.connected)return!1;const t=e.chatRunId;try{return await e.client.request("chat.abort",t?{sessionKey:e.sessionKey,runId:t}:{sessionKey:e.sessionKey}),!0}catch(n){return e.lastError=String(n),!1}}function Sl(e,t){var n,i;if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="working"){const o=(t.message?(n=rn(t.message))==null?void 0:n.trim():void 0)||((i=e.chatStream)==null?void 0:i.trim());return o&&(e.chatInterimText=e.chatInterimText?`${e.chatInterimText}
10
+ ${i}`:c.join(", ");u.push({type:"text",text:v})}else i&&u.push({type:"text",text:i});for(const v of r)u.push({type:"image",source:{type:"base64",media_type:v.mimeType,data:v.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:u,timestamp:o}],e.chatSending=!0,e.lastError=null;const l=oo();e.chatRunId=l,e.chatStream="",e.chatStreamStartedAt=o;const d=[...r,...a],h=d.length>0?d.map(v=>{if(v.textContent)return{type:"document",mimeType:v.mimeType||"text/plain",fileName:v.fileName,content:btoa(unescape(encodeURIComponent(v.textContent)))};const f=Dd(v.dataUrl);return f?{type:v.fileName?"document":"image",mimeType:f.mimeType,fileName:v.fileName,content:f.content}:null}).filter(v=>v!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:l,attachments:h}),!0}catch(v){const f=String(v);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=f,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+f}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function Sl(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 xl(e,t){var n,i;if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="working"){const o=(t.message?(n=cn(t.message))==null?void 0:n.trim():void 0)||((i=e.chatStream)==null?void 0:i.trim());return o&&(e.chatInterimText=e.chatInterimText?`${e.chatInterimText}
11
11
 
12
- ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.message);return typeof s=="string"&&s.trim()&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:s.trim()}],timestamp:Date.now(),filler:!0}]),"block"}else if(t.state==="delta"){e.chatSuggestion=null;const s=rn(t.message);if(typeof s=="string"){if(s.trim()==="NO_REPLY")return null;const o=e.chatStream??"";(!o||s.length>=o.length)&&(e.chatStream=s)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null,e.lastError=t.errorMessage??"chat error");return t.state}const si=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:Pe,abortChatRun:kl,handleChatEvent:Sl,loadChatHistory:Me,loadOlderChatHistory:Nd,sendChatMessage:wl},Symbol.toStringTag,{value:"Module"}));async function oo(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=ii(e.sessionsFilterActive??"",0),i=ii(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),i>0&&(t.limit=i);const s=await e.client.request("sessions.list",t);s&&(e.sessionsResult=s)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function In(e,t,n){if(!e.client||!e.connected)return;const i={key:t};"label"in n&&(i.label=n.label),"thinkingLevel"in n&&(i.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(i.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(i.reasoningLevel=n.reasoningLevel),"model"in n&&(i.model=n.model),"fillerEnabled"in n&&(i.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",i),await oo(e)}catch(s){e.sessionsError=String(s)}}const Tr=50,Od=80,Bd=12e4;function Fd(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const i=n.map(s=>{if(!s||typeof s!="object")return null;const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>!!s);return i.length===0?null:i.join(`
13
- `)}function _r(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Fd(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const i=fl(n,Bd);return i.truncated?`${i.text}
12
+ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=cn(t.message);return typeof s=="string"&&s.trim()&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:s.trim()}],timestamp:Date.now(),filler:!0}]),"block"}else if(t.state==="delta"){e.chatSuggestion=null;const s=cn(t.message);if(typeof s=="string"){if(s.trim()==="NO_REPLY")return null;const o=e.chatStream??"";(!o||s.length>=o.length)&&(e.chatStream=s)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null,e.lastError=t.errorMessage??"chat error");return t.state}const oi=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:Pe,abortChatRun:Sl,handleChatEvent:xl,loadChatHistory:Me,loadOlderChatHistory:Nd,sendChatMessage:kl},Symbol.toStringTag,{value:"Module"}));async function ro(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=si(e.sessionsFilterActive??"",0),i=si(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),i>0&&(t.limit=i);const s=await e.client.request("sessions.list",t);s&&(e.sessionsResult=s)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function Rn(e,t,n){if(!e.client||!e.connected)return;const i={key:t};"label"in n&&(i.label=n.label),"thinkingLevel"in n&&(i.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(i.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(i.reasoningLevel=n.reasoningLevel),"model"in n&&(i.model=n.model),"fillerEnabled"in n&&(i.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",i),await ro(e)}catch(s){e.sessionsError=String(s)}}const _r=50,Od=80,Bd=12e4;function Fd(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const i=n.map(s=>{if(!s||typeof s!="object")return null;const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>!!s);return i.length===0?null:i.join(`
13
+ `)}function Mr(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Fd(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const i=gl(n,Bd);return i.truncated?`${i.text}
14
14
 
15
- … truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function Ud(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 Wd(e){if(e.toolStreamOrder.length<=Tr)return;const t=e.toolStreamOrder.length-Tr,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function Kd(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function _s(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Kd(e)}function zd(e,t=!1){if(t){_s(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>_s(e),Od))}function ro(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],_s(e)}const jd=5e3;function Hd(e,t){var s;const n=t.data??{},i=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),i==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:i==="end"&&(e.compactionStatus={active:!1,startedAt:((s=e.compactionStatus)==null?void 0:s.startedAt)??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},jd))}function qd(e,t){if(!t)return;if(t.stream==="compaction"){Hd(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const i=t.data??{},s=typeof i.toolCallId=="string"?i.toolCallId:"";if(!s)return;const o=typeof i.name=="string"?i.name:"tool",r=typeof i.phase=="string"?i.phase:"",a=r==="start"?i.args:void 0,u=r==="update"?_r(i.partialResult):r==="result"?_r(i.result):void 0,c=Date.now();let l=e.toolStreamById.get(s);l?(l.name=o,a!==void 0&&(l.args=a),u!==void 0&&(l.output=u),l.updatedAt=c):(l={toolCallId:s,runId:t.runId,sessionKey:n,name:o,args:a,output:u,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(s,l),e.toolStreamOrder.push(s)),l.message=Ud(l),Wd(e),zd(e,r==="result")}let Rn=0;function Ot(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=++Rn,i=()=>{const s=e.querySelector(".chat-thread");if(s){const o=getComputedStyle(s).overflowY;if(o==="auto"||o==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{n===Rn&&(e.chatScrollFrame=requestAnimationFrame(()=>{if(e.chatScrollFrame=null,n!==Rn)return;const s=i();if(!s)return;const o=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||o<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const a=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{if(e.chatScrollTimeout=null,n!==Rn)return;const u=i();if(!u)return;const c=u.scrollHeight-u.scrollTop-u.clientHeight;(t||e.chatUserNearBottom||c<200)&&(u.scrollTop=u.scrollHeight,e.chatUserNearBottom=!0)},a)}))})}function xl(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 Vd(e,t){const n=t.currentTarget;if(!n)return;const i=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=i<200,n.scrollTop<100&&e.onLoadOlder&&e.onLoadOlder()}function Gd(e){const t=e.querySelector(".chat-thread");if(!t)return null;const n=t.scrollHeight,i=t.scrollTop;return()=>{const s=t.scrollHeight-n;t.scrollTop=i+s}}function Qd(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Yd(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Xd(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function Zd(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
15
+ … truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function Ud(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 Wd(e){if(e.toolStreamOrder.length<=_r)return;const t=e.toolStreamOrder.length-_r,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function Kd(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function Ms(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Kd(e)}function zd(e,t=!1){if(t){Ms(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>Ms(e),Od))}function ao(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],Ms(e)}const jd=5e3;function Hd(e,t){var s;const n=t.data??{},i=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),i==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:i==="end"&&(e.compactionStatus={active:!1,startedAt:((s=e.compactionStatus)==null?void 0:s.startedAt)??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},jd))}function qd(e,t){if(!t)return;if(t.stream==="compaction"){Hd(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const i=t.data??{},s=typeof i.toolCallId=="string"?i.toolCallId:"";if(!s)return;const o=typeof i.name=="string"?i.name:"tool",r=typeof i.phase=="string"?i.phase:"",a=r==="start"?i.args:void 0,u=r==="update"?Mr(i.partialResult):r==="result"?Mr(i.result):void 0,c=Date.now();let l=e.toolStreamById.get(s);l?(l.name=o,a!==void 0&&(l.args=a),u!==void 0&&(l.output=u),l.updatedAt=c):(l={toolCallId:s,runId:t.runId,sessionKey:n,name:o,args:a,output:u,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(s,l),e.toolStreamOrder.push(s)),l.message=Ud(l),Wd(e),zd(e,r==="result")}let Nn=0;function Bt(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=++Nn,i=()=>{const s=e.querySelector(".chat-thread");if(s){const o=getComputedStyle(s).overflowY;if(o==="auto"||o==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{n===Nn&&(e.chatScrollFrame=requestAnimationFrame(()=>{if(e.chatScrollFrame=null,n!==Nn)return;const s=i();if(!s)return;const o=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||o<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const a=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{if(e.chatScrollTimeout=null,n!==Nn)return;const u=i();if(!u)return;const c=u.scrollHeight-u.scrollTop-u.clientHeight;(t||e.chatUserNearBottom||c<200)&&(u.scrollTop=u.scrollHeight,e.chatUserNearBottom=!0)},a)}))})}function $l(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 Vd(e,t){const n=t.currentTarget;if(!n)return;const i=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=i<200,n.scrollTop<100&&e.onLoadOlder&&e.onLoadOlder()}function Gd(e){const t=e.querySelector(".chat-thread");if(!t)return null;const n=t.scrollHeight,i=t.scrollTop;return()=>{const s=t.scrollHeight-n;t.scrollTop=i+s}}function Qd(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Yd(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Xd(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function Zd(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
16
16
  `)}
17
17
  `],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function Jd(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
18
18
  `)}
19
- `],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-session-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function ep(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:i}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${i}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function Ye(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function ct(e){return`${JSON.stringify(e,null,2).trimEnd()}
20
- `}function $l(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const r=t[o],a=t[o+1];if(typeof r=="number"){if(!Array.isArray(i))return;i[r]==null&&(i[r]=typeof a=="number"?[]:{}),i=i[r]}else{if(typeof i!="object"||i==null)return;const u=i;u[r]==null&&(u[r]=typeof a=="number"?[]:{}),i=u[r]}}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(i)&&(i[s]=n);return}typeof i=="object"&&i!=null&&(i[s]=n)}async function Le(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});np(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function Al(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});tp(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function tp(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function np(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?ct(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=ct(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=Ye(t.config??{}),e.configFormOriginal=Ye(t.config??{}),e.configRawOriginal=n)}async function ip(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?ct(e.configForm):e.configRaw,i=(t=e.configSnapshot)==null?void 0:t.hash;if(!i){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:n,baseHash:i}),e.configFormDirty=!1,await Le(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function mn(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 $i(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 sp(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=ii(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const i=e.everyUnit;return{kind:"every",everyMs:n*(i==="minutes"?6e4:i==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function op(e){if(e.payloadKind==="systemEvent"){const s=e.payloadText.trim();if(!s)throw new Error("System event text required.");return{kind:"systemEvent",text:s}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel),e.to.trim()&&(n.to=e.to.trim());const i=ii(e.timeoutSeconds,0);return i>0&&(n.timeoutSeconds=i),n}async function rp(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=sp(e.cronForm),i=op(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),r={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:o||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!r.name)throw new Error("Name required.");await e.client.request("cron.add",r),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await $i(e),await mn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function ap(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 $i(e),await mn(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function lp(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 Ms(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function cp(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 $i(e),await mn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Ms(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 G(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 ao(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const i=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=i.message??null,e.whatsappLoginQrDataUrl=i.qrDataUrl??null,e.whatsappLoginConnected=null}catch(i){e.whatsappLoginMessage=String(i),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function El(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 Cl(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 Tl(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const i=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!i){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const o=Ye(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const r=o.channels;(!r.whatsapp||typeof r.whatsapp!="object")&&(r.whatsapp={});const a=r.whatsapp;(!a.accounts||typeof a.accounts!="object")&&(a.accounts={});const u=a.accounts;if(u[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}u[i]={name:n,provider:"baileys"};const c=s.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const l=ct(o);await e.client.request("config.set",{raw:l,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await G(e,!0),await ao(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function _l(e,t){if(!(!e.client||!e.connected)&&!e.whatsappAccountSaving){e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=Ye(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,r=o==null?void 0:o.accounts;if(!r){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(r).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!r[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete r[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(l=>{const d=l.match;return!d||d.channel!=="whatsapp"?!0:d.accountId!==t}));const u=n.hash;if(!u){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=ct(i);await e.client.request("config.set",{raw:c,baseHash:u}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await G(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const up=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:Tl,loadChannels:G,logoutWhatsApp:Cl,removeWhatsAppAccount:_l,startWhatsAppLogin:ao,waitWhatsAppLogin:El},Symbol.toStringTag,{value:"Module"}));async function lo(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,i,s]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const o=i;e.debugModels=Array.isArray(o==null?void 0:o.models)?o==null?void 0:o.models:[],e.debugHeartbeat=s}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const dp=2e3,pp=new Set(["trace","debug","info","warn","error","fatal"]);function hp(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 fp(e){if(typeof e!="string")return null;const t=e.toLowerCase();return pp.has(t)?t:null}function Ml(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,i=typeof t.time=="string"?t.time:typeof(n==null?void 0:n.date)=="string"?n==null?void 0:n.date:null,s=fp((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),o=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,r=hp(o);let a=null;r&&(typeof r.subsystem=="string"?a=r.subsystem:typeof r.module=="string"&&(a=r.module)),!a&&o&&o.length<120&&(a=o);let u=null;return typeof t[1]=="string"?u=t[1]:!r&&typeof t[0]=="string"?u=t[0]:typeof t.message=="string"&&(u=t.message),{raw:e,time:i,level:s,subsystem:a,message:u??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Mt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const i=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),o=(Array.isArray(i.lines)?i.lines.filter(a=>typeof a=="string"):[]).map(Ml),r=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=r?o:[...e.logsEntries,...o].slice(-dp),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const gp=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Mt,parseLogLine:Ml},Symbol.toStringTag,{value:"Module"}));const Pl={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:re,n:Qn,Gx:Mr,Gy:Pr,a:es,d:ts,h:mp}=Pl,ut=32,co=64,yp=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},te=(e="")=>{const t=new Error(e);throw yp(t,te),t},vp=e=>typeof e=="bigint",bp=e=>typeof e=="string",wp=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",Ze=(e,t,n="")=>{const i=wp(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const r=n&&`"${n}" `,a=o?` of length ${t}`:"",u=i?`length=${s}`:`type=${typeof e}`;te(r+"expected Uint8Array"+a+", got "+u)}return e},Ai=e=>new Uint8Array(e),Ll=e=>Uint8Array.from(e),Il=(e,t)=>e.toString(16).padStart(t,"0"),Rl=e=>Array.from(Ze(e)).map(t=>Il(t,2)).join(""),De={_0:48,_9:57,A:65,F:70,a:97,f:102},Lr=e=>{if(e>=De._0&&e<=De._9)return e-De._0;if(e>=De.A&&e<=De.F)return e-(De.A-10);if(e>=De.a&&e<=De.f)return e-(De.a-10)},Nl=e=>{const t="hex invalid";if(!bp(e))return te(t);const n=e.length,i=n/2;if(n%2)return te(t);const s=Ai(i);for(let o=0,r=0;o<i;o++,r+=2){const a=Lr(e.charCodeAt(r)),u=Lr(e.charCodeAt(r+1));if(a===void 0||u===void 0)return te(t);s[o]=a*16+u}return s},Dl=()=>globalThis==null?void 0:globalThis.crypto,kp=()=>{var e;return((e=Dl())==null?void 0:e.subtle)??te("crypto.subtle must be defined, consider polyfill")},fn=(...e)=>{const t=Ai(e.reduce((i,s)=>i+Ze(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},Sp=(e=ut)=>Dl().getRandomValues(Ai(e)),oi=BigInt,st=(e,t,n,i="bad number: out of range")=>vp(e)&&t<=e&&e<n?e:te(i),P=(e,t=re)=>{const n=e%t;return n>=0n?n:t+n},Ol=e=>P(e,Qn),xp=(e,t)=>{(e===0n||t<=0n)&&te("no inverse n="+e+" mod="+t);let n=P(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const r=i/n,a=i%n,u=s-o*r;i=n,n=a,s=o,o=u}return i===1n?P(s,t):te("no inverse")},$p=e=>{const t=Wl[e];return typeof t!="function"&&te("hashes."+e+" not set"),t},ns=e=>e instanceof dt?e:te("Point expected"),Ps=2n**256n,_e=class _e{constructor(t,n,i,s){U(this,"X");U(this,"Y");U(this,"Z");U(this,"T");const o=Ps;this.X=st(t,0n,o),this.Y=st(n,0n,o),this.Z=st(i,1n,o),this.T=st(s,0n,o),Object.freeze(this)}static CURVE(){return Pl}static fromAffine(t){return new _e(t.x,t.y,1n,P(t.x*t.y))}static fromBytes(t,n=!1){const i=ts,s=Ll(Ze(t,ut)),o=t[31];s[31]=o&-129;const r=Fl(s);st(r,0n,n?Ps:re);const u=P(r*r),c=P(u-1n),l=P(i*u+1n);let{isValid:d,value:h}=Ep(c,l);d||te("bad point: y not sqrt");const v=(h&1n)===1n,f=(o&128)!==0;return!n&&h===0n&&f&&te("bad point: x==0, isLastByteOdd"),f!==v&&(h=P(-h)),new _e(h,r,1n,P(h*r))}static fromHex(t,n){return _e.fromBytes(Nl(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=es,n=ts,i=this;if(i.is0())return te("bad point: ZERO");const{X:s,Y:o,Z:r,T:a}=i,u=P(s*s),c=P(o*o),l=P(r*r),d=P(l*l),h=P(u*t),v=P(l*P(h+c)),f=P(d+P(n*P(u*c)));if(v!==f)return te("bad point: equation left != right (1)");const b=P(s*o),S=P(r*a);return b!==S?te("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:r,Z:a}=ns(t),u=P(n*a),c=P(o*s),l=P(i*a),d=P(r*s);return u===c&&l===d}is0(){return this.equals(Tt)}negate(){return new _e(P(-this.X),this.Y,this.Z,P(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=es,o=P(t*t),r=P(n*n),a=P(2n*P(i*i)),u=P(s*o),c=t+n,l=P(P(c*c)-o-r),d=u+r,h=d-a,v=u-r,f=P(l*h),b=P(d*v),S=P(l*v),$=P(h*d);return new _e(f,b,$,S)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:r,Y:a,Z:u,T:c}=ns(t),l=es,d=ts,h=P(n*r),v=P(i*a),f=P(o*d*c),b=P(s*u),S=P((n+i)*(r+a)-h-v),$=P(b-f),A=P(b+f),C=P(v-l*h),T=P(S*$),M=P(A*C),R=P(S*C),B=P($*A);return new _e(T,M,B,R)}subtract(t){return this.add(ns(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Tt;if(st(t,1n,Qn),t===1n)return this;if(this.equals(pt))return Op(t).p;let i=Tt,s=pt;for(let o=this;t>0n;o=o.double(),t>>=1n)t&1n?i=i.add(o):n&&(s=s.add(o));return i}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:i}=this;if(this.equals(Tt))return{x:0n,y:1n};const s=xp(i,re);P(i*s)!==1n&&te("invalid inverse");const o=P(t*s),r=P(n*s);return{x:o,y:r}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Bl(n);return i[31]|=t&1n?128:0,i}toHex(){return Rl(this.toBytes())}clearCofactor(){return this.multiply(oi(mp),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Qn/2n,!1).double();return Qn%2n&&(t=t.add(this)),t.is0()}};U(_e,"BASE"),U(_e,"ZERO");let dt=_e;const pt=new dt(Mr,Pr,1n,P(Mr*Pr)),Tt=new dt(0n,1n,1n,0n);dt.BASE=pt;dt.ZERO=Tt;const Bl=e=>Nl(Il(st(e,0n,Ps),co)).reverse(),Fl=e=>oi("0x"+Rl(Ll(Ze(e)).reverse())),Ae=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=re;return n},Ap=e=>{const n=e*e%re*e%re,i=Ae(n,2n)*n%re,s=Ae(i,1n)*e%re,o=Ae(s,5n)*s%re,r=Ae(o,10n)*o%re,a=Ae(r,20n)*r%re,u=Ae(a,40n)*a%re,c=Ae(u,80n)*u%re,l=Ae(c,80n)*u%re,d=Ae(l,10n)*o%re;return{pow_p_5_8:Ae(d,2n)*e%re,b2:n}},Ir=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Ep=(e,t)=>{const n=P(t*t*t),i=P(n*n*t),s=Ap(e*i).pow_p_5_8;let o=P(e*n*s);const r=P(t*o*o),a=o,u=P(o*Ir),c=r===e,l=r===P(-e),d=r===P(-e*Ir);return c&&(o=a),(l||d)&&(o=u),(P(o)&1n)===1n&&(o=P(-o)),{isValid:c||l,value:o}},Ls=e=>Ol(Fl(e)),uo=(...e)=>Wl.sha512Async(fn(...e)),Cp=(...e)=>$p("sha512")(fn(...e)),Ul=e=>{const t=e.slice(0,ut);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(ut,co),i=Ls(t),s=pt.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},po=e=>uo(Ze(e,ut)).then(Ul),Tp=e=>Ul(Cp(Ze(e,ut))),_p=e=>po(e).then(t=>t.pointBytes),Mp=e=>uo(e.hashable).then(e.finish),Pp=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=Ls(t),r=pt.multiply(o).toBytes();return{hashable:fn(r,i,n),finish:c=>{const l=Ol(o+Ls(c)*s);return Ze(fn(r,Bl(l)),co)}}},Lp=async(e,t)=>{const n=Ze(e),i=await po(t),s=await uo(i.prefix,n);return Mp(Pp(i,s,n))},Wl={sha512Async:async e=>{const t=kp(),n=fn(e);return Ai(await t.digest("SHA-512",n.buffer))},sha512:void 0},Ip=(e=Sp(ut))=>e,Rp={getExtendedPublicKeyAsync:po,getExtendedPublicKey:Tp,randomSecretKey:Ip},ri=8,Np=256,Kl=Math.ceil(Np/ri)+1,Is=2**(ri-1),Dp=()=>{const e=[];let t=pt,n=t;for(let i=0;i<Kl;i++){n=t,e.push(n);for(let s=1;s<Is;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Rr;const Nr=(e,t)=>{const n=t.negate();return e?n:t},Op=e=>{const t=Rr||(Rr=Dp());let n=Tt,i=pt;const s=2**ri,o=s,r=oi(s-1),a=oi(ri);for(let u=0;u<Kl;u++){let c=Number(e&r);e>>=a,c>Is&&(c-=o,e+=1n);const l=u*Is,d=l,h=l+Math.abs(c)-1,v=u%2!==0,f=c<0;c===0?i=i.add(Nr(v,t[d])):n=n.add(Nr(f,t[h]))}return e!==0n&&te("invalid wnaf"),{p:n,f:i}},is="taskmaster-device-identity-v1";function Rs(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function zl(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)s[o]=i.charCodeAt(o);return s}function Bp(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function jl(e){const t=await crypto.subtle.digest("SHA-256",e);return Bp(new Uint8Array(t))}async function Fp(){const e=Rp.randomSecretKey(),t=await _p(e);return{deviceId:await jl(t),publicKey:Rs(t),privateKey:Rs(e)}}async function Up(){try{const n=localStorage.getItem(is);if(n){const i=JSON.parse(n);if((i==null?void 0:i.version)===1&&typeof i.deviceId=="string"&&typeof i.publicKey=="string"&&typeof i.privateKey=="string"){const s=await jl(zl(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(is,JSON.stringify(o)),{deviceId:s,publicKey:i.publicKey,privateKey:i.privateKey}}return{deviceId:i.deviceId,publicKey:i.publicKey,privateKey:i.privateKey}}}}catch{}const e=await Fp(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(is,JSON.stringify(t)),e}async function Wp(e,t){const n=zl(e),i=new TextEncoder().encode(t),s=await Lp(i,n);return Rs(s)}const Hl="taskmaster.device.auth.v1";function ho(e){return e.trim()}function Kp(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const i=n.trim();i&&t.add(i)}return[...t].sort()}function fo(){try{const e=window.localStorage.getItem(Hl);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 ql(e){try{window.localStorage.setItem(Hl,JSON.stringify(e))}catch{}}function zp(e){const t=fo();if(!t||t.deviceId!==e.deviceId)return null;const n=ho(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function jp(e){const t=ho(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=fo();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:Kp(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,ql(n),s}function Hp(e){const t=fo();if(!t||t.deviceId!==e.deviceId)return;const n=ho(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],ql(i)}async function go(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t!=null&&t.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n==null?void 0:n.pending)?n.pending:[],paired:Array.isArray(n==null?void 0:n.paired)?n.paired:[]}}catch(n){t!=null&&t.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function mo(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t!=null&&t.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t!=null&&t.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function qp(e){return{method:"exec.approvals.get",params:{}}}async function Vp(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=qp(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);Gp(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Gp(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=Ye(t.file??{}))}async function Vl(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 It(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function Ei(e){return e instanceof Error?e.message:String(e)}async function ht(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=Ei(n)}finally{e.skillsLoading=!1}}}function Gl(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Ql(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,enabled:n}),await ht(e),It(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=Ei(i);e.skillsError=s,It(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Yl(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 ht(e),It(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=Ei(n);e.skillsError=i,It(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Xl(e,t,n,i){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const s=await e.client.request("skills.install",{name:n,installId:i,timeoutMs:12e4});await ht(e),It(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=Ei(s);e.skillsError=o,It(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}const Qp=Object.freeze(Object.defineProperty({__proto__:null,installSkill:Xl,loadSkills:ht,saveSkillApiKey:Yl,updateSkillEdit:Gl,updateSkillEnabled:Ql},Symbol.toStringTag,{value:"Module"})),Zl={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},Jl=new Map(Object.entries(Zl).map(([e,t])=>[t,e]));function Ci(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function gn(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 Yp(e,t=""){const n=Ci(t),i=Zl[e];return n?`${n}${i}`:i}function ec(e,t=""){const n=Ci(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=gn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":Jl.get(s)??null}function Xp(e){let t=gn(e);if(t.endsWith("/index.html")&&(t=gn(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let i=0;i<n.length;i++){const s=`/${n.slice(i).join("/")}`.toLowerCase();if(Jl.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function Zp(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function yo(e){return e==="system"?Zp():e}const Nn=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,Jp=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Dn=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},eh=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var c;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,r=s,a=Jp();if(!!r.startViewTransition&&!a){let l=.5,d=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")l=Nn(n.pointerClientX/window.innerWidth),d=Nn(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const h=n.element.getBoundingClientRect();h.width>0&&h.height>0&&typeof window<"u"&&(l=Nn((h.left+h.width/2)/window.innerWidth),d=Nn((h.top+h.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${l*100}%`),o.style.setProperty("--theme-switch-y",`${d*100}%`),o.classList.add("theme-transition");try{const h=(c=r.startViewTransition)==null?void 0:c.call(r,()=>{t()});h!=null&&h.finished?h.finished.finally(()=>Dn(o)):Dn(o)}catch{Dn(o),t()}return}t(),Dn(o)},th=2e3;async function an(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const n={cursors:t!=null&&t.reset?void 0:e.sessionLogsCursors,limit:500};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(n.agents=e.workspaceAgentIds);const s=await e.client.request("sessions.transcript",n),o=Array.isArray(s.entries)?s.entries:[],r=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=r?o:[...e.sessionLogsEntries,...o].slice(-th),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 tc=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:an},Symbol.toStringTag,{value:"Module"}));async function nc(e,t){if(!(!e.client||!e.connected))try{const n={},i=await e.client.request("memory.audit",n);i!=null&&i.ok&&(e.auditEntries=i.entries??[])}catch{}}async function nh(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function Ue(e){return e instanceof Error?e.message:String(e)}let On=null;function yn(e,t){On&&clearTimeout(On),e.filesMessage={kind:"success",text:t},On=setTimeout(()=>{e.filesMessage=null,On=null},3e3)}async function vn(e,t){if(!(!e.client||!e.connected)){if(!t){e.filesTree=[],e.filesRoot="";return}if(!e.filesLoading){e.filesLoading=!0,e.filesError=null;try{const n={};t&&(n.agentId=t);const i=await e.client.request("files.tree",n);i!=null&&i.tree&&(e.filesTree=i.tree,e.filesRoot=i.root??"")}catch(n){e.filesError=Ue(n)}finally{e.filesLoading=!1}}}}async function ih(e,t,n){e.filesSelectedPaths=new Set([t]),await ic(e,t,n)}async function sh(e,t,n){const i=new Set(e.filesSelectedPaths);if(i.has(t)?i.delete(t):i.add(t),e.filesSelectedPaths=i,i.size===1){const s=[...i][0];await ic(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function oh(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let i=0,s="";for(const o of n)try{await sc(e,o,t),i++}catch(r){s=Ue(r)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:yn(e,`${i} file${i!==1?"s":""} downloaded`)}async function rh(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await oc(e,t,o,i)}async function ic(e,t,n){if(!(!e.client||!e.connected)){e.filesSelectedPath=t,e.filesPreviewLoading=!0,e.filesPreviewContent=null,e.filesPreviewBinary=!1,e.filesPreviewSize=null;try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.read",i);e.filesPreviewContent=(s==null?void 0:s.content)??null,e.filesPreviewBinary=(s==null?void 0:s.binary)??!1,e.filesPreviewSize=(s==null?void 0:s.size)??null}catch(i){e.filesError=Ue(i)}finally{e.filesPreviewLoading=!1}}}async function sc(e,t,n){if(!(!e.client||!e.connected))try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.download",i);if(!(s!=null&&s.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(s.base64),c=>c.charCodeAt(0)),r=new Blob([o]),a=URL.createObjectURL(r),u=document.createElement("a");u.href=a,u.download=s.name??t.split("/").pop()??"download",document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(a)}catch(i){e.filesMessage={kind:"error",text:Ue(i)}}}async function ah(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const r of n)try{const a=await r.arrayBuffer(),u=btoa(new Uint8Array(a).reduce((l,d)=>l+String.fromCharCode(d),"")),c={path:t,name:r.name,data:u};i&&(c.agentId=i),await e.client.request("files.upload",c),s++}catch(a){o=Ue(a)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:yn(e,`${s} file${s!==1?"s":""} uploaded`),await vn(e,i)}async function lh(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={path:t};n&&(i.agentId=n),await e.client.request("files.delete",i),yn(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await vn(e,n)}catch(i){e.filesMessage={kind:"error",text:Ue(i)}}}}async function oc(e,t,n,i){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={from:t,to:n};i&&(s.agentId=i),await e.client.request("files.move",s),yn(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await vn(e,i)}catch(s){e.filesMessage={kind:"error",text:Ue(s)}}}}async function vo(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const i=await e.client.request("memory.status",n);i!=null&&i.ok&&(e.filesMemoryStatus={dirty:i.dirty??!1,syncing:i.syncing,syncProgress:i.syncProgress,files:i.files??0,chunks:i.chunks??0,model:i.model,embeddingState:i.embeddingState})}catch{}}async function ch(e,t){if(!(!e.client||!e.connected)&&!e.filesReindexBusy){e.filesReindexBusy=!0,e.filesMessage=null;try{const n={force:!0};t&&(n.agentId=t);const i=await e.client.request("memory.reindex",n),s=(i==null?void 0:i.files)??0,o=(i==null?void 0:i.chunks)??0;yn(e,`Re-indexed: ${s} files, ${o} chunks`),await vo(e,t)}catch(n){e.filesMessage={kind:"error",text:Ue(n)}}finally{e.filesReindexBusy=!1}}}function uh(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n}async function dh(e,t,n){if(!(!e.client||!e.connected)){if(!t.trim()){e.filesSearchResults=null;return}e.filesSearchLoading=!0,e.filesSearchResults=null;try{const i={query:t.trim(),maxResults:20};n&&(i.agentId=n);const s=await e.client.request("memory.search",i);e.filesSearchResults=(s==null?void 0:s.results)??[]}catch(i){e.filesMessage={kind:"error",text:Ue(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function ph(e){e.filesSearchQuery="",e.filesSearchResults=null}function hh(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{mo(e,{quiet:!0})},5e3))}function fh(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function bo(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Mt(e,{quiet:!0})},2e3))}function wo(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function ko(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||an(e,{quiet:!0})},2e3))}function So(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function xo(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&lo(e)},3e3))}function $o(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function gh(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{nc(e)},3e4))}function mh(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function yh(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{if(e.tab!=="files")return;const t=e;vo(t,t.filesResolvedAgentId)},3e3))}function vh(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function Ge(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,vd(n),t.theme!==e.theme&&(e.theme=t.theme,Ti(e,yo(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function rc(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Ge(e,{...e.settings,lastActiveSessionKey:n})}function bh(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),i=t.get("password"),s=t.get("session"),o=t.get("gatewayUrl");let r=!1;if(n!=null){const u=n.trim();u&&u!==e.settings.token&&Ge(e,{...e.settings,token:u}),t.delete("token"),r=!0}if(i!=null){const u=i.trim();u&&(e.password=u),t.delete("password"),r=!0}if(s!=null){const u=s.trim();u&&(e.sessionKey=u,Ge(e,{...e.settings,sessionKey:u,lastActiveSessionKey:u}))}if(o!=null){const u=o.trim();u&&u!==e.settings.gatewayUrl&&Ge(e,{...e.settings,gatewayUrl:u}),t.delete("gatewayUrl"),r=!0}if(!r)return;const a=new URL(window.location.href);a.search=t.toString(),window.history.replaceState({},"",a.toString())}function wh(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ko(e):bo(e):(wo(e),So(e)),t==="debug"?xo(e):$o(e),ai(e),lc(e,t,!1)}function kh(e,t,n){eh({nextTheme:t,applyTheme:()=>{e.theme=t,Ge(e,{...e.settings,theme:t}),Ti(e,yo(t))},context:n,currentTheme:e.theme})}async function ai(e){if(e.tab==="overview"&&await cc(e),e.tab==="channels"&&await Th(e),e.tab==="instances"&&await Vl(e),e.tab==="cron"&&await Ao(e),e.tab==="skills"&&await ht(e),e.tab==="nodes"&&(await mo(e),await go(e),await Le(e),await Vp(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await Ih(e),Ot(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await Al(e),await Le(e)),e.tab==="debug"&&(await lo(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await ie(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>tc);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Mt(e,{reset:!0});xl(e,!0)}}function Sh(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?Ci(e):Xp(window.location.pathname)}function xh(e){e.theme=e.settings.theme??"system",Ti(e,yo(e.theme))}function Ti(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function $h(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"&&Ti(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Ah(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 Eh(e,t){if(typeof window>"u")return;const n=ec(window.location.pathname,e.basePath)??"chat";ac(e,n),lc(e,n,t)}function Ch(e){var s;if(typeof window>"u")return;const t=ec(window.location.pathname,e.basePath);if(!t)return;const i=(s=new URL(window.location.href).searchParams.get("session"))==null?void 0:s.trim();i&&(e.sessionKey=i,Ge(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),ac(e,t)}function ac(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ko(e):bo(e):(wo(e),So(e)),t==="debug"?xo(e):$o(e),e.connected&&ai(e)}function lc(e,t,n){if(typeof window>"u")return;const i=gn(Yp(t,e.basePath)),s=gn(window.location.pathname),o=new URL(window.location.href);t==="chat"&&e.sessionKey?o.searchParams.set("session",e.sessionKey):o.searchParams.delete("session"),s!==i&&(o.pathname=i),n?window.history.replaceState({},"",o.toString()):window.history.pushState({},"",o.toString())}async function cc(e){await Promise.all([G(e,!1),Vl(e),oo(e),mn(e),lo(e)])}async function Th(e){await Promise.all([G(e,!0),Al(e),Le(e)])}async function Ao(e){await Promise.all([G(e,!1),mn(e),$i(e)])}function uc(e){return e.chatSending||!!e.chatRunId}function _h(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 dc(e){e.connected&&(e.chatMessage="",await kl(e))}function Mh(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:so(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],Ot(e))}async function pc(e,t,n){var s,o;ro(e);const i=await wl(e,t,n==null?void 0:n.attachments);return!i&&(n==null?void 0:n.previousDraft)!=null&&(e.chatMessage=n.previousDraft),!i&&(n!=null&&n.previousAttachments)&&(e.chatAttachments=n.previousAttachments),i&&rc(e,e.sessionKey),i&&(n!=null&&n.restoreDraft)&&((s=n.previousDraft)!=null&&s.trim())&&(e.chatMessage=n.previousDraft),i&&(n!=null&&n.restoreAttachments)&&((o=n.previousAttachments)!=null&&o.length)&&(e.chatAttachments=n.previousAttachments),Ot(e),i&&!e.chatRunId&&hc(e),i}async function hc(e){if(!e.connected||uc(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await pc(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function Ph(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Lh(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],r=t==null?o:[],a=r.length>0;if(!(!s&&!a)){if(_h(s)){await dc(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),uc(e)){Mh(e,s,r);return}await pc(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:a?r:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function Ih(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,Pe);await Promise.all([Me(t,{limit:n}),oo(t),Ns(e)]),Ot(e,!0)}const Rh=hc;function Nh(e){var s,o,r;const t=dl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((r=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:r.trim())||"main"}function Dh(e,t){const n=Ci(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Ns(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Nh(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Dh(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),o=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const D={messageSquare:p`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:p`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:p`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,unlink:p`<svg viewBox="0 0 24 24"><path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" x2="8" y1="2" y2="5"/><line x1="2" x2="5" y1="8" y2="8"/><line x1="16" x2="16" y1="19" y2="22"/><line x1="19" x2="22" y1="16" y2="16"/></svg>`,radio:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:p`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:p`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:p`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:p`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:p`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:p`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:p`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,users:p`<svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,menu:p`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:p`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:p`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:p`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:p`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:p`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:p`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:p`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,rotateCw:p`<svg viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,download:p`<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wrench:p`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:p`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:p`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:p`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:p`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,image:p`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:p`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:p`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,puzzle:p`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`,info:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,send:p`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`,slidersHorizontal:p`<svg viewBox="0 0 24 24"><line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/></svg>`,square:p`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:p`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:p`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,trash:p`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,chevronDown:p`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:p`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`},Oh="Taskmaster",Bh="/taskmaster-icon.png",fc="#00d4ff";let Bn=null;function Xe(){return Bn||(Bn={name:window.__TASKMASTER_BRAND_NAME__||Oh,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||Bh,accentColor:window.__TASKMASTER_ACCENT_COLOR__||fc},Bn)}function Fh(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 Uh(e){if(e===fc)return;const t=Fh(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 Wh=p`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,Kh=p`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>`;let Dr=!1;function zh(){Dr||(Dr=!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 yt(e,t){const n=(l,d)=>l===e?p`<span class="sp-page-nav-current">${l}</span>`:p`<a href=${d}>${l}</a>`,i=p`
19
+ `],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-session-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function ep(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:i}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${i}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function Ye(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function ut(e){return`${JSON.stringify(e,null,2).trimEnd()}
20
+ `}function Al(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const r=t[o],a=t[o+1];if(typeof r=="number"){if(!Array.isArray(i))return;i[r]==null&&(i[r]=typeof a=="number"?[]:{}),i=i[r]}else{if(typeof i!="object"||i==null)return;const u=i;u[r]==null&&(u[r]=typeof a=="number"?[]:{}),i=u[r]}}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(i)&&(i[s]=n);return}typeof i=="object"&&i!=null&&(i[s]=n)}async function Le(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});np(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function El(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});tp(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function tp(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function np(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?ut(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=ut(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=Ye(t.config??{}),e.configFormOriginal=Ye(t.config??{}),e.configRawOriginal=n)}async function ip(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?ut(e.configForm):e.configRaw,i=(t=e.configSnapshot)==null?void 0:t.hash;if(!i){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:n,baseHash:i}),e.configFormDirty=!1,await Le(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function bn(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 Ai(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 sp(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=si(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const i=e.everyUnit;return{kind:"every",everyMs:n*(i==="minutes"?6e4:i==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function op(e){if(e.payloadKind==="systemEvent"){const s=e.payloadText.trim();if(!s)throw new Error("System event text required.");return{kind:"systemEvent",text:s}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel),e.to.trim()&&(n.to=e.to.trim());const i=si(e.timeoutSeconds,0);return i>0&&(n.timeoutSeconds=i),n}async function rp(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=sp(e.cronForm),i=op(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),r={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:o||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!r.name)throw new Error("Name required.");await e.client.request("cron.add",r),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await Ai(e),await bn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function ap(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 Ai(e),await bn(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function lp(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 Ps(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function cp(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 Ai(e),await bn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Ps(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 G(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 lo(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const i=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=i.message??null,e.whatsappLoginQrDataUrl=i.qrDataUrl??null,e.whatsappLoginConnected=null}catch(i){e.whatsappLoginMessage=String(i),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function Cl(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 Tl(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t}),e.whatsappLoginMessage="Logged out.",e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null}catch(n){e.whatsappLoginMessage=String(n)}finally{e.whatsappBusy=!1}}}async function _l(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const i=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!i){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const o=Ye(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const r=o.channels;(!r.whatsapp||typeof r.whatsapp!="object")&&(r.whatsapp={});const a=r.whatsapp;(!a.accounts||typeof a.accounts!="object")&&(a.accounts={});const u=a.accounts;if(u[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}u[i]={name:n,provider:"baileys"};const c=s.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const l=ut(o);await e.client.request("config.set",{raw:l,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await G(e,!0),await lo(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function Ml(e,t){if(!(!e.client||!e.connected)&&!e.whatsappAccountSaving){e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=Ye(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,r=o==null?void 0:o.accounts;if(!r){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(r).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!r[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete r[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(l=>{const d=l.match;return!d||d.channel!=="whatsapp"?!0:d.accountId!==t}));const u=n.hash;if(!u){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=ut(i);await e.client.request("config.set",{raw:c,baseHash:u}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await G(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const up=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:_l,loadChannels:G,logoutWhatsApp:Tl,removeWhatsAppAccount:Ml,startWhatsAppLogin:lo,waitWhatsAppLogin:Cl},Symbol.toStringTag,{value:"Module"}));async function co(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,i,s]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const o=i;e.debugModels=Array.isArray(o==null?void 0:o.models)?o==null?void 0:o.models:[],e.debugHeartbeat=s}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const dp=2e3,pp=new Set(["trace","debug","info","warn","error","fatal"]);function hp(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 fp(e){if(typeof e!="string")return null;const t=e.toLowerCase();return pp.has(t)?t:null}function Pl(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,i=typeof t.time=="string"?t.time:typeof(n==null?void 0:n.date)=="string"?n==null?void 0:n.date:null,s=fp((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),o=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,r=hp(o);let a=null;r&&(typeof r.subsystem=="string"?a=r.subsystem:typeof r.module=="string"&&(a=r.module)),!a&&o&&o.length<120&&(a=o);let u=null;return typeof t[1]=="string"?u=t[1]:!r&&typeof t[0]=="string"?u=t[0]:typeof t.message=="string"&&(u=t.message),{raw:e,time:i,level:s,subsystem:a,message:u??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Pt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const i=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),o=(Array.isArray(i.lines)?i.lines.filter(a=>typeof a=="string"):[]).map(Pl),r=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=r?o:[...e.logsEntries,...o].slice(-dp),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const gp=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Pt,parseLogLine:Pl},Symbol.toStringTag,{value:"Module"}));const Ll={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:re,n:Yn,Gx:Pr,Gy:Lr,a:ts,d:ns,h:mp}=Ll,dt=32,uo=64,yp=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},te=(e="")=>{const t=new Error(e);throw yp(t,te),t},vp=e=>typeof e=="bigint",bp=e=>typeof e=="string",wp=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",Ze=(e,t,n="")=>{const i=wp(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const r=n&&`"${n}" `,a=o?` of length ${t}`:"",u=i?`length=${s}`:`type=${typeof e}`;te(r+"expected Uint8Array"+a+", got "+u)}return e},Ei=e=>new Uint8Array(e),Il=e=>Uint8Array.from(e),Rl=(e,t)=>e.toString(16).padStart(t,"0"),Nl=e=>Array.from(Ze(e)).map(t=>Rl(t,2)).join(""),Oe={_0:48,_9:57,A:65,F:70,a:97,f:102},Ir=e=>{if(e>=Oe._0&&e<=Oe._9)return e-Oe._0;if(e>=Oe.A&&e<=Oe.F)return e-(Oe.A-10);if(e>=Oe.a&&e<=Oe.f)return e-(Oe.a-10)},Dl=e=>{const t="hex invalid";if(!bp(e))return te(t);const n=e.length,i=n/2;if(n%2)return te(t);const s=Ei(i);for(let o=0,r=0;o<i;o++,r+=2){const a=Ir(e.charCodeAt(r)),u=Ir(e.charCodeAt(r+1));if(a===void 0||u===void 0)return te(t);s[o]=a*16+u}return s},Ol=()=>globalThis==null?void 0:globalThis.crypto,kp=()=>{var e;return((e=Ol())==null?void 0:e.subtle)??te("crypto.subtle must be defined, consider polyfill")},yn=(...e)=>{const t=Ei(e.reduce((i,s)=>i+Ze(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},Sp=(e=dt)=>Ol().getRandomValues(Ei(e)),ri=BigInt,ot=(e,t,n,i="bad number: out of range")=>vp(e)&&t<=e&&e<n?e:te(i),P=(e,t=re)=>{const n=e%t;return n>=0n?n:t+n},Bl=e=>P(e,Yn),xp=(e,t)=>{(e===0n||t<=0n)&&te("no inverse n="+e+" mod="+t);let n=P(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const r=i/n,a=i%n,u=s-o*r;i=n,n=a,s=o,o=u}return i===1n?P(s,t):te("no inverse")},$p=e=>{const t=Kl[e];return typeof t!="function"&&te("hashes."+e+" not set"),t},is=e=>e instanceof pt?e:te("Point expected"),Ls=2n**256n,_e=class _e{constructor(t,n,i,s){U(this,"X");U(this,"Y");U(this,"Z");U(this,"T");const o=Ls;this.X=ot(t,0n,o),this.Y=ot(n,0n,o),this.Z=ot(i,1n,o),this.T=ot(s,0n,o),Object.freeze(this)}static CURVE(){return Ll}static fromAffine(t){return new _e(t.x,t.y,1n,P(t.x*t.y))}static fromBytes(t,n=!1){const i=ns,s=Il(Ze(t,dt)),o=t[31];s[31]=o&-129;const r=Ul(s);ot(r,0n,n?Ls:re);const u=P(r*r),c=P(u-1n),l=P(i*u+1n);let{isValid:d,value:h}=Ep(c,l);d||te("bad point: y not sqrt");const v=(h&1n)===1n,f=(o&128)!==0;return!n&&h===0n&&f&&te("bad point: x==0, isLastByteOdd"),f!==v&&(h=P(-h)),new _e(h,r,1n,P(h*r))}static fromHex(t,n){return _e.fromBytes(Dl(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=ts,n=ns,i=this;if(i.is0())return te("bad point: ZERO");const{X:s,Y:o,Z:r,T:a}=i,u=P(s*s),c=P(o*o),l=P(r*r),d=P(l*l),h=P(u*t),v=P(l*P(h+c)),f=P(d+P(n*P(u*c)));if(v!==f)return te("bad point: equation left != right (1)");const b=P(s*o),S=P(r*a);return b!==S?te("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:r,Z:a}=is(t),u=P(n*a),c=P(o*s),l=P(i*a),d=P(r*s);return u===c&&l===d}is0(){return this.equals(_t)}negate(){return new _e(P(-this.X),this.Y,this.Z,P(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=ts,o=P(t*t),r=P(n*n),a=P(2n*P(i*i)),u=P(s*o),c=t+n,l=P(P(c*c)-o-r),d=u+r,h=d-a,v=u-r,f=P(l*h),b=P(d*v),S=P(l*v),$=P(h*d);return new _e(f,b,$,S)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:r,Y:a,Z:u,T:c}=is(t),l=ts,d=ns,h=P(n*r),v=P(i*a),f=P(o*d*c),b=P(s*u),S=P((n+i)*(r+a)-h-v),$=P(b-f),A=P(b+f),C=P(v-l*h),T=P(S*$),M=P(A*C),R=P(S*C),B=P($*A);return new _e(T,M,B,R)}subtract(t){return this.add(is(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return _t;if(ot(t,1n,Yn),t===1n)return this;if(this.equals(ht))return Op(t).p;let i=_t,s=ht;for(let o=this;t>0n;o=o.double(),t>>=1n)t&1n?i=i.add(o):n&&(s=s.add(o));return i}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:i}=this;if(this.equals(_t))return{x:0n,y:1n};const s=xp(i,re);P(i*s)!==1n&&te("invalid inverse");const o=P(t*s),r=P(n*s);return{x:o,y:r}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Fl(n);return i[31]|=t&1n?128:0,i}toHex(){return Nl(this.toBytes())}clearCofactor(){return this.multiply(ri(mp),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Yn/2n,!1).double();return Yn%2n&&(t=t.add(this)),t.is0()}};U(_e,"BASE"),U(_e,"ZERO");let pt=_e;const ht=new pt(Pr,Lr,1n,P(Pr*Lr)),_t=new pt(0n,1n,1n,0n);pt.BASE=ht;pt.ZERO=_t;const Fl=e=>Dl(Rl(ot(e,0n,Ls),uo)).reverse(),Ul=e=>ri("0x"+Nl(Il(Ze(e)).reverse())),Ae=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=re;return n},Ap=e=>{const n=e*e%re*e%re,i=Ae(n,2n)*n%re,s=Ae(i,1n)*e%re,o=Ae(s,5n)*s%re,r=Ae(o,10n)*o%re,a=Ae(r,20n)*r%re,u=Ae(a,40n)*a%re,c=Ae(u,80n)*u%re,l=Ae(c,80n)*u%re,d=Ae(l,10n)*o%re;return{pow_p_5_8:Ae(d,2n)*e%re,b2:n}},Rr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Ep=(e,t)=>{const n=P(t*t*t),i=P(n*n*t),s=Ap(e*i).pow_p_5_8;let o=P(e*n*s);const r=P(t*o*o),a=o,u=P(o*Rr),c=r===e,l=r===P(-e),d=r===P(-e*Rr);return c&&(o=a),(l||d)&&(o=u),(P(o)&1n)===1n&&(o=P(-o)),{isValid:c||l,value:o}},Is=e=>Bl(Ul(e)),po=(...e)=>Kl.sha512Async(yn(...e)),Cp=(...e)=>$p("sha512")(yn(...e)),Wl=e=>{const t=e.slice(0,dt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(dt,uo),i=Is(t),s=ht.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},ho=e=>po(Ze(e,dt)).then(Wl),Tp=e=>Wl(Cp(Ze(e,dt))),_p=e=>ho(e).then(t=>t.pointBytes),Mp=e=>po(e.hashable).then(e.finish),Pp=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=Is(t),r=ht.multiply(o).toBytes();return{hashable:yn(r,i,n),finish:c=>{const l=Bl(o+Is(c)*s);return Ze(yn(r,Fl(l)),uo)}}},Lp=async(e,t)=>{const n=Ze(e),i=await ho(t),s=await po(i.prefix,n);return Mp(Pp(i,s,n))},Kl={sha512Async:async e=>{const t=kp(),n=yn(e);return Ei(await t.digest("SHA-512",n.buffer))},sha512:void 0},Ip=(e=Sp(dt))=>e,Rp={getExtendedPublicKeyAsync:ho,getExtendedPublicKey:Tp,randomSecretKey:Ip},ai=8,Np=256,zl=Math.ceil(Np/ai)+1,Rs=2**(ai-1),Dp=()=>{const e=[];let t=ht,n=t;for(let i=0;i<zl;i++){n=t,e.push(n);for(let s=1;s<Rs;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Nr;const Dr=(e,t)=>{const n=t.negate();return e?n:t},Op=e=>{const t=Nr||(Nr=Dp());let n=_t,i=ht;const s=2**ai,o=s,r=ri(s-1),a=ri(ai);for(let u=0;u<zl;u++){let c=Number(e&r);e>>=a,c>Rs&&(c-=o,e+=1n);const l=u*Rs,d=l,h=l+Math.abs(c)-1,v=u%2!==0,f=c<0;c===0?i=i.add(Dr(v,t[d])):n=n.add(Dr(f,t[h]))}return e!==0n&&te("invalid wnaf"),{p:n,f:i}},ss="taskmaster-device-identity-v1";function Ns(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function jl(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)s[o]=i.charCodeAt(o);return s}function Bp(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Hl(e){const t=await crypto.subtle.digest("SHA-256",e);return Bp(new Uint8Array(t))}async function Fp(){const e=Rp.randomSecretKey(),t=await _p(e);return{deviceId:await Hl(t),publicKey:Ns(t),privateKey:Ns(e)}}async function Up(){try{const n=localStorage.getItem(ss);if(n){const i=JSON.parse(n);if((i==null?void 0:i.version)===1&&typeof i.deviceId=="string"&&typeof i.publicKey=="string"&&typeof i.privateKey=="string"){const s=await Hl(jl(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(ss,JSON.stringify(o)),{deviceId:s,publicKey:i.publicKey,privateKey:i.privateKey}}return{deviceId:i.deviceId,publicKey:i.publicKey,privateKey:i.privateKey}}}}catch{}const e=await Fp(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(ss,JSON.stringify(t)),e}async function Wp(e,t){const n=jl(e),i=new TextEncoder().encode(t),s=await Lp(i,n);return Ns(s)}const ql="taskmaster.device.auth.v1";function fo(e){return e.trim()}function Kp(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const i=n.trim();i&&t.add(i)}return[...t].sort()}function go(){try{const e=window.localStorage.getItem(ql);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 Vl(e){try{window.localStorage.setItem(ql,JSON.stringify(e))}catch{}}function zp(e){const t=go();if(!t||t.deviceId!==e.deviceId)return null;const n=fo(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function jp(e){const t=fo(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=go();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:Kp(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Vl(n),s}function Hp(e){const t=go();if(!t||t.deviceId!==e.deviceId)return;const n=fo(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Vl(i)}async function mo(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 yo(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 qp(e){return{method:"exec.approvals.get",params:{}}}async function Vp(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=qp(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);Gp(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Gp(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=Ye(t.file??{}))}async function Gl(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 Rt(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function Ci(e){return e instanceof Error?e.message:String(e)}async function ft(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=Ci(n)}finally{e.skillsLoading=!1}}}function Ql(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Yl(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 ft(e),Rt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=Ci(i);e.skillsError=s,Rt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Xl(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 ft(e),Rt(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=Ci(n);e.skillsError=i,Rt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Zl(e,t,n,i){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const s=await e.client.request("skills.install",{name:n,installId:i,timeoutMs:12e4});await ft(e),Rt(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=Ci(s);e.skillsError=o,Rt(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}const Qp=Object.freeze(Object.defineProperty({__proto__:null,installSkill:Zl,loadSkills:ft,saveSkillApiKey:Xl,updateSkillEdit:Ql,updateSkillEnabled:Yl},Symbol.toStringTag,{value:"Module"})),Jl={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},ec=new Map(Object.entries(Jl).map(([e,t])=>[t,e]));function Ti(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function vn(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 Yp(e,t=""){const n=Ti(t),i=Jl[e];return n?`${n}${i}`:i}function tc(e,t=""){const n=Ti(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=vn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":ec.get(s)??null}function Xp(e){let t=vn(e);if(t.endsWith("/index.html")&&(t=vn(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let i=0;i<n.length;i++){const s=`/${n.slice(i).join("/")}`.toLowerCase();if(ec.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function Zp(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function vo(e){return e==="system"?Zp():e}const Dn=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,Jp=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,On=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},eh=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var c;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,r=s,a=Jp();if(!!r.startViewTransition&&!a){let l=.5,d=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")l=Dn(n.pointerClientX/window.innerWidth),d=Dn(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const h=n.element.getBoundingClientRect();h.width>0&&h.height>0&&typeof window<"u"&&(l=Dn((h.left+h.width/2)/window.innerWidth),d=Dn((h.top+h.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${l*100}%`),o.style.setProperty("--theme-switch-y",`${d*100}%`),o.classList.add("theme-transition");try{const h=(c=r.startViewTransition)==null?void 0:c.call(r,()=>{t()});h!=null&&h.finished?h.finished.finally(()=>On(o)):On(o)}catch{On(o),t()}return}t(),On(o)},th=2e3;async function un(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const n={cursors:t!=null&&t.reset?void 0:e.sessionLogsCursors,limit:500};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(n.agents=e.workspaceAgentIds);const s=await e.client.request("sessions.transcript",n),o=Array.isArray(s.entries)?s.entries:[],r=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=r?o:[...e.sessionLogsEntries,...o].slice(-th),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 nc=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:un},Symbol.toStringTag,{value:"Module"}));async function ic(e,t){if(!(!e.client||!e.connected))try{const n={},i=await e.client.request("memory.audit",n);i!=null&&i.ok&&(e.auditEntries=i.entries??[])}catch{}}async function nh(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function Ie(e){return e instanceof Error?e.message:String(e)}let Bn=null;function Ft(e,t){Bn&&clearTimeout(Bn),e.filesMessage={kind:"success",text:t},Bn=setTimeout(()=>{e.filesMessage=null,Bn=null},3e3)}async function Ut(e,t){if(!(!e.client||!e.connected)){if(!t){e.filesTree=[],e.filesRoot="";return}if(!e.filesLoading){e.filesLoading=!0,e.filesError=null;try{const n={};t&&(n.agentId=t);const i=await e.client.request("files.tree",n);i!=null&&i.tree&&(e.filesTree=i.tree,e.filesRoot=i.root??"")}catch(n){e.filesError=Ie(n)}finally{e.filesLoading=!1}}}}async function ih(e,t,n){e.filesSelectedPaths=new Set([t]),await sc(e,t,n)}async function sh(e,t,n){const i=new Set(e.filesSelectedPaths);if(i.has(t)?i.delete(t):i.add(t),e.filesSelectedPaths=i,i.size===1){const s=[...i][0];await sc(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function oh(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let i=0,s="";for(const o of n)try{await oc(e,o,t),i++}catch(r){s=Ie(r)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:Ft(e,`${i} file${i!==1?"s":""} downloaded`)}async function rh(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await uh(e,t,o,i)}async function sc(e,t,n){if(!(!e.client||!e.connected)){e.filesSelectedPath=t,e.filesPreviewLoading=!0,e.filesPreviewContent=null,e.filesPreviewBinary=!1,e.filesPreviewSize=null;try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.read",i);e.filesPreviewContent=(s==null?void 0:s.content)??null,e.filesPreviewBinary=(s==null?void 0:s.binary)??!1,e.filesPreviewSize=(s==null?void 0:s.size)??null}catch(i){e.filesError=Ie(i)}finally{e.filesPreviewLoading=!1}}}async function oc(e,t,n){if(!(!e.client||!e.connected))try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.download",i);if(!(s!=null&&s.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(s.base64),c=>c.charCodeAt(0)),r=new Blob([o]),a=URL.createObjectURL(r),u=document.createElement("a");u.href=a,u.download=s.name??t.split("/").pop()??"download",document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(a)}catch(i){e.filesMessage={kind:"error",text:Ie(i)}}}async function ah(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const r of n)try{const a=await r.arrayBuffer(),u=btoa(new Uint8Array(a).reduce((l,d)=>l+String.fromCharCode(d),"")),c={path:t,name:r.name,data:u};i&&(c.agentId=i),await e.client.request("files.upload",c),s++}catch(a){o=Ie(a)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:Ft(e,`${s} file${s!==1?"s":""} uploaded`),await Ut(e,i)}async function lh(e,t,n,i){if(!e.client||!e.connected)return;e.filesMessage=null;const s=t==="."?n:`${t}/${n}`;try{const o={path:s};i&&(o.agentId=i),await e.client.request("files.mkdir",o),Ft(e,`Created ${s}`),await Ut(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:Ie(o)}}}async function ch(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={path:t};n&&(i.agentId=n),await e.client.request("files.delete",i),Ft(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await Ut(e,n)}catch(i){e.filesMessage={kind:"error",text:Ie(i)}}}}async function uh(e,t,n,i){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={from:t,to:n};i&&(s.agentId=i),await e.client.request("files.move",s),Ft(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await Ut(e,i)}catch(s){e.filesMessage={kind:"error",text:Ie(s)}}}}async function bo(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const i=await e.client.request("memory.status",n);i!=null&&i.ok&&(e.filesMemoryStatus={dirty:i.dirty??!1,syncing:i.syncing,syncProgress:i.syncProgress,files:i.files??0,chunks:i.chunks??0,model:i.model,embeddingState:i.embeddingState})}catch{}}async function dh(e,t){if(!(!e.client||!e.connected)&&!e.filesReindexBusy){e.filesReindexBusy=!0,e.filesMessage=null;try{const n={force:!0};t&&(n.agentId=t);const i=await e.client.request("memory.reindex",n),s=(i==null?void 0:i.files)??0,o=(i==null?void 0:i.chunks)??0;Ft(e,`Re-indexed: ${s} files, ${o} chunks`),await bo(e,t)}catch(n){e.filesMessage={kind:"error",text:Ie(n)}}finally{e.filesReindexBusy=!1}}}function ph(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n,e.filesCurrentDir=t}async function hh(e,t,n){if(!(!e.client||!e.connected)){if(!t.trim()){e.filesSearchResults=null;return}e.filesSearchLoading=!0,e.filesSearchResults=null;try{const i={query:t.trim(),maxResults:20};n&&(i.agentId=n);const s=await e.client.request("memory.search",i);e.filesSearchResults=(s==null?void 0:s.results)??[]}catch(i){e.filesMessage={kind:"error",text:Ie(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function fh(e){e.filesSearchQuery="",e.filesSearchResults=null}function gh(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{yo(e,{quiet:!0})},5e3))}function mh(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function wo(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Pt(e,{quiet:!0})},2e3))}function ko(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function So(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||un(e,{quiet:!0})},2e3))}function xo(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function $o(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&co(e)},3e3))}function Ao(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function yh(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{ic(e)},3e4))}function vh(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function bh(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{if(e.tab!=="files")return;const t=e;bo(t,t.filesResolvedAgentId)},3e3))}function wh(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function Ge(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,vd(n),t.theme!==e.theme&&(e.theme=t.theme,_i(e,vo(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function rc(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Ge(e,{...e.settings,lastActiveSessionKey:n})}function kh(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),i=t.get("password"),s=t.get("session"),o=t.get("gatewayUrl");let r=!1;if(n!=null){const u=n.trim();u&&u!==e.settings.token&&Ge(e,{...e.settings,token:u}),t.delete("token"),r=!0}if(i!=null){const u=i.trim();u&&(e.password=u),t.delete("password"),r=!0}if(s!=null){const u=s.trim();u&&(e.sessionKey=u,Ge(e,{...e.settings,sessionKey:u,lastActiveSessionKey:u}))}if(o!=null){const u=o.trim();u&&u!==e.settings.gatewayUrl&&Ge(e,{...e.settings,gatewayUrl:u}),t.delete("gatewayUrl"),r=!0}if(!r)return;const a=new URL(window.location.href);a.search=t.toString(),window.history.replaceState({},"",a.toString())}function Sh(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?So(e):wo(e):(ko(e),xo(e)),t==="debug"?$o(e):Ao(e),li(e),lc(e,t,!1)}function xh(e,t,n){eh({nextTheme:t,applyTheme:()=>{e.theme=t,Ge(e,{...e.settings,theme:t}),_i(e,vo(t))},context:n,currentTheme:e.theme})}async function li(e){if(e.tab==="overview"&&await cc(e),e.tab==="channels"&&await Mh(e),e.tab==="instances"&&await Gl(e),e.tab==="cron"&&await Eo(e),e.tab==="skills"&&await ft(e),e.tab==="nodes"&&(await yo(e),await mo(e),await Le(e),await Vp(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await Nh(e),Bt(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await El(e),await Le(e)),e.tab==="debug"&&(await co(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await ie(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>nc);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Pt(e,{reset:!0});$l(e,!0)}}function $h(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?Ti(e):Xp(window.location.pathname)}function Ah(e){e.theme=e.settings.theme??"system",_i(e,vo(e.theme))}function _i(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Eh(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;if(e.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaHandler=n=>{e.theme==="system"&&_i(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Ch(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 Th(e,t){if(typeof window>"u")return;const n=tc(window.location.pathname,e.basePath)??"chat";ac(e,n),lc(e,n,t)}function _h(e){var s;if(typeof window>"u")return;const t=tc(window.location.pathname,e.basePath);if(!t)return;const i=(s=new URL(window.location.href).searchParams.get("session"))==null?void 0:s.trim();i&&(e.sessionKey=i,Ge(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),ac(e,t)}function ac(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?So(e):wo(e):(ko(e),xo(e)),t==="debug"?$o(e):Ao(e),e.connected&&li(e)}function lc(e,t,n){if(typeof window>"u")return;const i=vn(Yp(t,e.basePath)),s=vn(window.location.pathname),o=new URL(window.location.href);t==="chat"&&e.sessionKey?o.searchParams.set("session",e.sessionKey):o.searchParams.delete("session"),s!==i&&(o.pathname=i),n?window.history.replaceState({},"",o.toString()):window.history.pushState({},"",o.toString())}async function cc(e){await Promise.all([G(e,!1),Gl(e),ro(e),bn(e),co(e)])}async function Mh(e){await Promise.all([G(e,!0),El(e),Le(e)])}async function Eo(e){await Promise.all([G(e,!1),bn(e),Ai(e)])}function uc(e){return e.chatSending||!!e.chatRunId}function Ph(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 dc(e){e.connected&&(e.chatMessage="",await Sl(e))}function Lh(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:oo(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],Bt(e))}async function pc(e,t,n){var s,o;ao(e);const i=await kl(e,t,n==null?void 0:n.attachments);return!i&&(n==null?void 0:n.previousDraft)!=null&&(e.chatMessage=n.previousDraft),!i&&(n!=null&&n.previousAttachments)&&(e.chatAttachments=n.previousAttachments),i&&rc(e,e.sessionKey),i&&(n!=null&&n.restoreDraft)&&((s=n.previousDraft)!=null&&s.trim())&&(e.chatMessage=n.previousDraft),i&&(n!=null&&n.restoreAttachments)&&((o=n.previousAttachments)!=null&&o.length)&&(e.chatAttachments=n.previousAttachments),Bt(e),i&&!e.chatRunId&&hc(e),i}async function hc(e){if(!e.connected||uc(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await pc(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function Ih(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Rh(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],r=t==null?o:[],a=r.length>0;if(!(!s&&!a)){if(Ph(s)){await dc(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),uc(e)){Lh(e,s,r);return}await pc(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:a?r:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function Nh(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,Pe);await Promise.all([Me(t,{limit:n}),ro(t),Ds(e)]),Bt(e,!0)}const Dh=hc;function Oh(e){var s,o,r;const t=pl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((r=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:r.trim())||"main"}function Bh(e,t){const n=Ti(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Ds(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Oh(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Bh(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),o=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const D={messageSquare:p`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:p`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:p`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,unlink:p`<svg viewBox="0 0 24 24"><path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" x2="8" y1="2" y2="5"/><line x1="2" x2="5" y1="8" y2="8"/><line x1="16" x2="16" y1="19" y2="22"/><line x1="19" x2="22" y1="16" y2="16"/></svg>`,radio:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:p`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:p`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:p`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:p`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:p`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:p`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:p`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,users:p`<svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,menu:p`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:p`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:p`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:p`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:p`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:p`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:p`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:p`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,rotateCw:p`<svg viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,download:p`<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wrench:p`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:p`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:p`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:p`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:p`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,image:p`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:p`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:p`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,puzzle:p`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`,info:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,send:p`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:p`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`,slidersHorizontal:p`<svg viewBox="0 0 24 24"><line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/></svg>`,square:p`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:p`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:p`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,trash:p`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,chevronDown:p`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:p`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`},Fh="Taskmaster",Uh="/taskmaster-icon.png",fc="#00d4ff";let Fn=null;function Xe(){return Fn||(Fn={name:window.__TASKMASTER_BRAND_NAME__||Fh,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||Uh,accentColor:window.__TASKMASTER_ACCENT_COLOR__||fc},Fn)}function Wh(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 Kh(e){if(e===fc)return;const t=Wh(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 zh=p`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,jh=p`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>`;let Or=!1;function Hh(){Or||(Or=!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 vt(e,t){const n=(l,d)=>l===e?p`<span class="sp-page-nav-current">${l}</span>`:p`<a href=${d}>${l}</a>`,i=p`
21
21
  ${n("Setup","/setup")}
22
22
  ${n("Chat","/chat")}
23
23
  ${n("Admins","/admins")}
@@ -25,10 +25,10 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
25
25
  ${n("Files","/files")}
26
26
  ${n("Browser","/browser")}
27
27
  ${n("Advanced","/advanced")}
28
- `,o=t&&(t.isMaster!==!1||!t.hasPins)?jh(t):k,r=t!=null&&t.hasPins&&t.onLogout?p`<button class="nav-logout-btn" @click=${t.onLogout} title="Lock">${Wh}</button>`:k,a=(t==null?void 0:t.auditCount)??0,u=a>0&&(t!=null&&t.onAuditClick)?p`<button class="nav-audit-btn" @click=${t.onAuditClick} title="Memory writes to review">
29
- ${Kh}
28
+ `,o=t&&(t.isMaster!==!1||!t.hasPins)?qh(t):k,r=t!=null&&t.hasPins&&t.onLogout?p`<button class="nav-logout-btn" @click=${t.onLogout} title="Lock">${zh}</button>`:k,a=(t==null?void 0:t.auditCount)??0,u=a>0&&(t!=null&&t.onAuditClick)?p`<button class="nav-audit-btn" @click=${t.onAuditClick} title="Memory writes to review">
29
+ ${jh}
30
30
  <span class="nav-audit-badge">${a>99?"99+":a}</span>
31
- </button>`:k,c=()=>{const l=document.getElementById("nav-burger-toggle");l&&(l.checked=!1)};return zh(),p`
31
+ </button>`:k,c=()=>{const l=document.getElementById("nav-burger-toggle");l&&(l.checked=!1)};return Hh(),p`
32
32
  <div class="setup-header">
33
33
  <input type="checkbox" id="nav-burger-toggle" class="nav-burger-checkbox" />
34
34
  <div class="setup-header-inner">
@@ -50,7 +50,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
50
50
  ${i}
51
51
  </nav>
52
52
  </div>
53
- `}function jh(e){const{workspaces:t,selectedWorkspace:n,onWorkspaceSelect:i}=e;return p`
53
+ `}function qh(e){const{workspaces:t,selectedWorkspace:n,onWorkspaceSelect:i}=e;return p`
54
54
  <select
55
55
  class="sp-workspace-selector"
56
56
  .value=${n??""}
@@ -64,7 +64,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
64
64
  <option disabled>───</option>
65
65
  <option value="__add__">+ Add Account</option>
66
66
  </select>
67
- `}function Hh(e){return e.connected?e.fullscreen&&e.active?p`
67
+ `}function Vh(e){return e.connected?e.fullscreen&&e.active?p`
68
68
  <div class="sp-fullscreen-overlay">
69
69
  <div class="sp-fullscreen-toolbar">
70
70
  <button
@@ -106,7 +106,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
106
106
  </div>
107
107
  `:p`
108
108
  <div class="setup-container">
109
- ${yt("Browser")}
109
+ ${vt("Browser")}
110
110
  <div class="setup-card sp-card-wide">
111
111
  <h1>Remote Browser</h1>
112
112
  <p style="margin-bottom: 16px;">Live view of the headless Chrome instance.</p>
@@ -196,33 +196,38 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
196
196
  <p>Connecting to gateway...</p>
197
197
  </div>
198
198
  </div>
199
- `}const li="application/x-taskmaster-file-path";function gc(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function mc(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function qh(e,t,n){var o,r;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const i=(o=e.dataTransfer)==null?void 0:o.getData(li);if(i){mc(i)!==t&&n.onMoveToDir(i,t);return}const s=(r=e.dataTransfer)==null?void 0:r.files;if(s&&s.length>0){const a=Array.from(s).filter(u=>u.name.toLowerCase().endsWith(".md"));a.length>0&&n.onUpload(t,a)}}function yc(e,t,n){const i=e.type==="directory"||e.type==="symlink"&&e.children!=null,s=t.expandedDirs.has(e.path),o=t.selectedPaths.has(e.path),r=n*20+12;return i?p`
199
+ `}const ci="application/x-taskmaster-file-path";let it=null;function gc(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function mc(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function Gh(e,t,n){var o,r;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const i=(o=e.dataTransfer)==null?void 0:o.getData(ci);if(i){mc(i)!==t&&n.onMoveToDir(i,t);return}const s=(r=e.dataTransfer)==null?void 0:r.files;if(s&&s.length>0){const a=Array.from(s).filter(u=>u.name.toLowerCase().endsWith(".md"));a.length>0&&n.onUpload(t,a)}}function yc(e,t,n){var u;const i=e.type==="directory"||e.type==="symlink"&&e.children!=null,s=t.expandedDirs.has(e.path),o=t.selectedPaths.has(e.path),r=t.currentDir===e.path,a=n*20+12;return i?p`
200
200
  <div
201
- class="sp-tree-item sp-tree-dir ${s?"expanded":""}"
202
- style="padding-left: ${r}px;"
201
+ class="sp-tree-item sp-tree-dir ${s?"expanded":""} ${r?"current":""}"
202
+ style="padding-left: ${a}px;"
203
203
  @click=${()=>t.onToggleDir(e.path)}
204
- @dragover=${a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&(a.dataTransfer.dropEffect="move"),a.currentTarget.classList.add("sp-drop-target")}}
205
- @dragleave=${a=>{a.currentTarget.classList.remove("sp-drop-target")}}
206
- @drop=${a=>qh(a,e.path,t)}
204
+ @dragover=${c=>{c.preventDefault(),c.stopPropagation(),c.dataTransfer&&(c.dataTransfer.dropEffect="move"),c.currentTarget.classList.add("sp-drop-target")}}
205
+ @dragleave=${c=>{c.currentTarget.classList.remove("sp-drop-target")}}
206
+ @drop=${c=>Gh(c,e.path,t)}
207
207
  >
208
208
  <span class="sp-tree-chevron">${s?"−":"+"}</span>
209
209
  <span class="sp-tree-icon">${D.folder}</span>
210
210
  <span class="sp-tree-name">${e.name}</span>
211
+ ${s&&((u=e.children)==null?void 0:u.length)===0?p`<span
212
+ class="sp-tree-dir-delete"
213
+ title="Delete empty folder"
214
+ @click=${c=>{c.stopPropagation(),t.onDelete(e.path)}}
215
+ >×</span>`:k}
211
216
  </div>
212
- ${s&&e.children?e.children.map(a=>yc(a,t,n+1)):k}
217
+ ${s&&e.children?e.children.map(c=>yc(c,t,n+1)):k}
213
218
  `:p`
214
219
  <div
215
220
  class="sp-tree-item sp-tree-file ${o?"selected":""}"
216
- style="padding-left: ${r}px;"
221
+ style="padding-left: ${a}px;"
217
222
  draggable="true"
218
- @click=${a=>{a.metaKey||a.ctrlKey?t.onToggleSelectFile(e.path):t.onSelectFile(e.path)}}
219
- @dragstart=${a=>{a.dataTransfer&&(a.dataTransfer.effectAllowed="move",a.dataTransfer.setData(li,e.path),a.dataTransfer.setData("text/plain",e.name))}}
223
+ @click=${c=>{c.metaKey||c.ctrlKey?t.onToggleSelectFile(e.path):t.onSelectFile(e.path)}}
224
+ @dragstart=${c=>{c.dataTransfer&&(c.dataTransfer.effectAllowed="move",c.dataTransfer.setData(ci,e.path),c.dataTransfer.setData("text/plain",e.name))}}
220
225
  >
221
226
  <span class="sp-tree-icon">${D.fileText}</span>
222
227
  <span class="sp-tree-name">${e.name}</span>
223
228
  <span class="sp-tree-size">${gc(e.size)}</span>
224
229
  </div>
225
- `}function Vh(e){const t=e.selectedPaths.size;return t<2?k:p`
230
+ `}function Qh(e){const t=e.selectedPaths.size;return t<2?k:p`
226
231
  <div class="sp-bulk-actions">
227
232
  <span style="color: var(--tasker-muted-grey); font-size: 13px;">${t} files selected</span>
228
233
  <button
@@ -233,7 +238,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
233
238
  Download ${t} files
234
239
  </button>
235
240
  </div>
236
- `}function Gh(e){if(e.selectedPaths.size!==1||!e.selectedPath)return k;if(e.previewLoading)return p`
241
+ `}function Yh(e){if(e.selectedPaths.size!==1||!e.selectedPath)return k;if(e.previewLoading)return p`
237
242
  <div class="sp-file-preview">
238
243
  <div class="setup-spinner" style="width: 32px; height: 32px; margin: 24px auto;"></div>
239
244
  </div>
@@ -250,17 +255,14 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
250
255
  <button class="setup-button secondary" style="padding: 8px 16px; font-size: 13px;" @click=${()=>e.onDownload(e.selectedPath)}>
251
256
  Download
252
257
  </button>
253
- <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)}}>
254
- Move
255
- </button>
256
- <button class="setup-button danger" style="padding: 8px 16px; font-size: 13px;" @click=${()=>{confirm(`Delete ${t}?`)&&e.onDelete(e.selectedPath)}}>
257
- Delete
258
+ <button class="setup-button danger" style="padding: 8px 16px; font-size: 13px;" @click=${()=>{e.pendingDeletePath===e.selectedPath?(it&&clearTimeout(it),it=null,e.onDelete(e.selectedPath)):(e.onArmDelete(e.selectedPath),it&&clearTimeout(it),it=setTimeout(()=>{e.onArmDelete(""),it=null},3e3))}}>
259
+ ${e.pendingDeletePath===e.selectedPath?"Confirm delete?":"Delete"}
258
260
  </button>
259
261
  </div>
260
262
  </div>
261
263
  ${e.previewBinary?p`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">Binary file — use Download to view.</p></div>`:e.previewContent!=null?p`<div class="sp-file-preview-body"><pre class="sp-file-code">${e.previewContent}</pre></div>`:p`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">File too large for preview — use Download.</p></div>`}
262
264
  </div>
263
- `}function Qh(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 Yh(e){return p`
265
+ `}function Xh(e){return p`
264
266
  <div class="sp-search-bar">
265
267
  <input
266
268
  type="text"
@@ -292,7 +294,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
292
294
  Clear
293
295
  </button>`:k}
294
296
  </div>
295
- `}function Xh(e){return e.searchResults?e.searchResults.length===0?p`<div class="sp-search-results">
297
+ `}function Zh(e){return e.searchResults?e.searchResults.length===0?p`<div class="sp-search-results">
296
298
  <div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No results found.</div>
297
299
  </div>`:p`
298
300
  <div class="sp-search-results">
@@ -312,16 +314,16 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
312
314
  </div>
313
315
  `)}
314
316
  </div>
315
- `:k}function Zh(e){const t=Qh(e);return e.connected?p`
317
+ `:k}function Jh(e){const t=e.currentDir;return e.connected?p`
316
318
  <div class="setup-container">
317
- ${yt("Files",e.wsProps)}
319
+ ${vt("Files",e.wsProps)}
318
320
  <div class="setup-card sp-card-wide">
319
321
  <h1>Workspace Files</h1>
320
322
  <p style="margin-bottom: 16px;">Browse, upload, and manage files in your workspace. Drag files between folders to move them.</p>
321
323
 
322
324
  <div class="sp-toolbar">
323
325
  <label class="setup-button secondary" style="padding: 10px 20px; font-size: 14px; cursor: pointer;">
324
- Upload
326
+ Upload${t!=="."?p` to <em>${t}</em>`:k}
325
327
  <input
326
328
  type="file"
327
329
  multiple
@@ -330,6 +332,13 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
330
332
  @change=${n=>{const i=n.target;i.files&&i.files.length>0&&(e.onUpload(t,Array.from(i.files)),i.value="")}}
331
333
  />
332
334
  </label>
335
+ <button
336
+ class="setup-button secondary"
337
+ style="padding: 10px 20px; font-size: 14px;"
338
+ @click=${()=>{const n=prompt("Folder name:");n!=null&&n.trim()&&e.onNewFolder(t,n.trim())}}
339
+ >
340
+ New Folder${t!=="."?p` in <em>${t}</em>`:k}
341
+ </button>
333
342
  <button
334
343
  class="setup-button secondary"
335
344
  style="padding: 10px 20px; font-size: 14px;"
@@ -369,18 +378,18 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
369
378
 
370
379
  ${e.uploadBusy?p`<div style="margin-top: 12px; color: var(--tasker-orange); font-weight: 600; font-size: 14px;">Uploading...</div>`:k}
371
380
 
372
- ${Yh(e)}
381
+ ${Xh(e)}
373
382
 
374
- ${e.searchResults!==null?Xh(e):p`<div
383
+ ${e.searchResults!==null?Zh(e):p`<div
375
384
  class="sp-file-tree"
376
- @dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(li)?"move":"copy")}}
377
- @drop=${n=>{var o,r;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(li);if(i){mc(i)!=="."&&e.onMoveToDir(i,".");return}const s=(r=n.dataTransfer)==null?void 0:r.files;if(s&&s.length>0){const a=Array.from(s).filter(u=>u.name.toLowerCase().endsWith(".md"));a.length>0&&e.onUpload(t,a)}}}
385
+ @dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(ci)?"move":"copy")}}
386
+ @drop=${n=>{var o,r;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(ci);if(i){mc(i)!=="."&&e.onMoveToDir(i,".");return}const s=(r=n.dataTransfer)==null?void 0:r.files;if(s&&s.length>0){const a=Array.from(s).filter(u=>u.name.toLowerCase().endsWith(".md"));a.length>0&&e.onUpload(t,a)}}}
378
387
  >
379
388
  ${e.tree.length===0&&!e.loading?p`<div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No files found. Drop .md files here to upload.</div>`:e.tree.map(n=>yc(n,e,0))}
380
389
  </div>`}
381
390
 
382
- ${Vh(e)}
383
- ${Gh(e)}
391
+ ${Qh(e)}
392
+ ${Yh(e)}
384
393
  </div>
385
394
  </div>
386
395
  `:p`
@@ -390,7 +399,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
390
399
  <p>Connecting to gateway...</p>
391
400
  </div>
392
401
  </div>
393
- `}const Eo="taskmaster_uninstall_done";async function Jh(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),ef();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 ci(){try{return localStorage.getItem(Eo)==="1"}catch{return!1}}function Co(){try{localStorage.removeItem(Eo)}catch{}}function ef(){try{localStorage.setItem(Eo,"1")}catch{}}const Or=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:ci,clearUninstallDone:Co,runUninstall:Jh},Symbol.toStringTag,{value:"Module"}));function q(e){return p`
402
+ `}const Co="taskmaster_uninstall_done";async function ef(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),tf();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 ui(){try{return localStorage.getItem(Co)==="1"}catch{return!1}}function To(){try{localStorage.removeItem(Co)}catch{}}function tf(){try{localStorage.setItem(Co,"1")}catch{}}const Br=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:ui,clearUninstallDone:To,runUninstall:ef},Symbol.toStringTag,{value:"Module"}));function q(e){return p`
394
403
  <span
395
404
  class="setup-status-light"
396
405
  style="background: ${{good:"#22c55e",bad:"#ef4444",partial:"#eab308",unknown:"#6b7280"}[e]}"
@@ -403,7 +412,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
403
412
  >
404
413
  ${D.info}
405
414
  </button>
406
- `}function tf(e){var i;if(!e.infoModalOpen)return k;let t="",n=[];switch(e.infoModalOpen){case"gateway":{const s=typeof window<"u"?window.location.host:"unknown";t="Gateway",n=[{label:"Status",value:e.gatewayHealthy===!1?"Stopped":"Running"},{label:"Address",value:s},{label:"Health",value:e.gatewayHealthMessage||"OK"}];break}case"claude":{const s=e.authExpiresIn;let o="N/A";if(s!=null&&s>0)if(s>60){const r=Math.floor(s/60),a=s%60;o=a>0?`${r}h ${a}m`:`${r}h`}else o=`${s}m`;t="Claude",n=[{label:"Connected",value:e.authConnected?"Yes":"No"},{label:"Token Expiry",value:o},{label:"Renewal",value:"Automatic (tokens refresh on expiry)"},...e.authMessage?[{label:"Message",value:e.authMessage}]:[]];break}case"license":{const s=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"Key",value:s},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A"}];break}case"whatsapp":{const s=Bt(e),o=s?To(s,e):null;t="WhatsApp",n=[{label:"Account",value:(o==null?void 0:o.name)||(o==null?void 0:o.accountId)||"Default"},{label:"Phone",value:((i=o==null?void 0:o.self)==null?void 0:i.e164)||"Not paired"},{label:"Connected",value:o!=null&&o.connected?"Yes":"No"},{label:"Linked",value:o!=null&&o.linked?"Yes":"No"},...o!=null&&o.lastError?[{label:"Last Error",value:vc(o.lastError)}]:[]];break}case"imessage":{const{thisWsOwns:s}=_o(e);t="iMessage",n=[{label:"Connected",value:s&&e.imessageConnected?"Yes":"No"},{label:"Assigned To",value:e.imessageOwnerWorkspace??"Not assigned"},{label:"Mode",value:"Self-chat only"},...e.imessageLastError?[{label:"Last Error",value:e.imessageLastError}]:[]];break}case"update":{t="Software Update",n=[{label:"Current",value:e.currentVersion?`v${e.currentVersion}`:"Unknown"},{label:"Latest",value:e.latestVersion?`v${e.latestVersion}`:"Unknown"},{label:"Status",value:e.updateAvailable===null?"Not checked":e.updateAvailable?"Update available":"Up to date"},...e.updateMessage?[{label:"Message",value:e.updateMessage}]:[]];break}case"internet":{const s=e.tailscaleStatus,o=s?s.installed?s.loggedIn?s.funnelEnabled&&s.funnelActive?"Active":s.funnelEnabled&&!s.funnelActive?"Enabled but not active":"Connected (not public)":"Not connected":"Not installed":"Checking...";t="Internet Access",n=[{label:"Status",value:o},{label:"What",value:"Makes your public chat and API reachable from the internet, not just your local network"},{label:"How",value:"Uses Tailscale Funnel — a free, secure tunnel that gives your device a public HTTPS address"},{label:"Security",value:"Only the /public/* paths are exposed. The control panel stays LAN-only."},...s!=null&&s.publicUrl?[{label:"Public URL",value:s.publicUrl}]:[],...s!=null&&s.hostname?[{label:"Hostname",value:s.hostname}]:[]];break}case"public-chat":{t="Public Chat",n=[{label:"Status",value:e.publicChatEnabled?"Enabled":"Disabled"},{label:"What",value:"A chat widget anyone can use to message your business from a web browser"},{label:"Access mode",value:uf[e.publicChatAuthMode]??"Open access"},{label:"Open access",value:"Anyone can chat without identifying themselves"},{label:"WhatsApp OTP",value:"Visitors verify their phone number before chatting"},{label:"Visitor chooses",value:"Visitors can chat anonymously or verify via WhatsApp"}];break}case"account-pin":{t="Account PIN",n=[{label:"Status",value:e.accountHasPin?"Set":"Not set"},{label:"What",value:"A numeric PIN that protects this account on the control panel"},{label:"When needed",value:"Required when switching to this account or after the session expires"},{label:"Format",value:"4 to 6 digits"}];break}default:return k}return p`
415
+ `}function nf(e){var i;if(!e.infoModalOpen)return k;let t="",n=[];switch(e.infoModalOpen){case"gateway":{const s=typeof window<"u"?window.location.host:"unknown";t="Gateway",n=[{label:"Status",value:e.gatewayHealthy===!1?"Stopped":"Running"},{label:"Address",value:s},{label:"Health",value:e.gatewayHealthMessage||"OK"}];break}case"claude":{const s=e.authExpiresIn;let o="N/A";if(s!=null&&s>0)if(s>60){const r=Math.floor(s/60),a=s%60;o=a>0?`${r}h ${a}m`:`${r}h`}else o=`${s}m`;t="Claude",n=[{label:"Connected",value:e.authConnected?"Yes":"No"},{label:"Token Expiry",value:o},{label:"Renewal",value:"Automatic (tokens refresh on expiry)"},...e.authMessage?[{label:"Message",value:e.authMessage}]:[]];break}case"license":{const s=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"Key",value:s},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A"}];break}case"whatsapp":{const s=Wt(e),o=s?_o(s,e):null;t="WhatsApp",n=[{label:"Account",value:(o==null?void 0:o.name)||(o==null?void 0:o.accountId)||"Default"},{label:"Phone",value:((i=o==null?void 0:o.self)==null?void 0:i.e164)||"Not paired"},{label:"Connected",value:o!=null&&o.connected?"Yes":"No"},{label:"Linked",value:o!=null&&o.linked?"Yes":"No"},...o!=null&&o.lastError?[{label:"Last Error",value:vc(o.lastError)}]:[]];break}case"imessage":{const{thisWsOwns:s}=Mo(e);t="iMessage",n=[{label:"Connected",value:s&&e.imessageConnected?"Yes":"No"},{label:"Assigned To",value:e.imessageOwnerWorkspace??"Not assigned"},{label:"Mode",value:"Self-chat only"},...e.imessageLastError?[{label:"Last Error",value:e.imessageLastError}]:[]];break}case"update":{t="Software Update",n=[{label:"Current",value:e.currentVersion?`v${e.currentVersion}`:"Unknown"},{label:"Latest",value:e.latestVersion?`v${e.latestVersion}`:"Unknown"},{label:"Status",value:e.updateAvailable===null?"Not checked":e.updateAvailable?"Update available":"Up to date"},...e.updateMessage?[{label:"Message",value:e.updateMessage}]:[]];break}case"internet":{const s=e.tailscaleStatus,o=s?s.installed?s.loggedIn?s.funnelEnabled&&s.funnelActive?"Active":s.funnelEnabled&&!s.funnelActive?"Enabled but not active":"Connected (not public)":"Not connected":"Not installed":"Checking...";t="Internet Access",n=[{label:"Status",value:o},{label:"What",value:"Makes your public chat and API reachable from the internet, not just your local network"},{label:"How",value:"Uses Tailscale Funnel — a free, secure tunnel that gives your device a public HTTPS address"},{label:"Security",value:"Only the /public/* paths are exposed. The control panel stays LAN-only."},...s!=null&&s.publicUrl?[{label:"Public URL",value:s.publicUrl}]:[],...s!=null&&s.hostname?[{label:"Hostname",value:s.hostname}]:[]];break}case"public-chat":{t="Public Chat",n=[{label:"Status",value:e.publicChatEnabled?"Enabled":"Disabled"},{label:"What",value:"A chat widget anyone can use to message your business from a web browser"},{label:"Access mode",value:df[e.publicChatAuthMode]??"Open access"},{label:"Open access",value:"Anyone can chat without identifying themselves"},{label:"WhatsApp OTP",value:"Visitors verify their phone number before chatting"},{label:"Visitor chooses",value:"Visitors can chat anonymously or verify via WhatsApp"}];break}case"account-pin":{t="Account PIN",n=[{label:"Status",value:e.accountHasPin?"Set":"Not set"},{label:"What",value:"A numeric PIN that protects this account on the control panel"},{label:"When needed",value:"Required when switching to this account or after the session expires"},{label:"Format",value:"4 to 6 digits"}];break}default:return k}return p`
407
416
  <div class="setup-info-overlay" @click=${s=>{s.target.classList.contains("setup-info-overlay")&&e.onInfoModalClose()}}>
408
417
  <div class="setup-info-card">
409
418
  <h3>${t}</h3>
@@ -433,7 +442,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
433
442
  </div>
434
443
  `})}
435
444
  </div>
436
- `}function Br(e){const{licenseKey:t,licenseBusy:n,licenseValid:i,licenseMessage:s,licenseDeviceId:o,onLicenseKeyChange:r,onLicenseActivate:a}=e;return i===!0?p`
445
+ `}function Fr(e){const{licenseKey:t,licenseBusy:n,licenseValid:i,licenseMessage:s,licenseDeviceId:o,onLicenseKeyChange:r,onLicenseActivate:a}=e;return i===!0?p`
437
446
  <div class="setup-container">
438
447
  <div class="setup-card setup-success">
439
448
  ${we("license")}
@@ -502,7 +511,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
502
511
  </p>
503
512
  </div>
504
513
  </div>
505
- `}function nf(e){const{authConnected:t,authBusy:n,authMessage:i,authUrl:s,authCodeInput:o,authExpiresIn:r,onStartAuth:a,onSubmitAuthCode:u,onAuthCodeChange:c,onSkipToWhatsApp:l}=e;return t===!0?p`
514
+ `}function sf(e){const{authConnected:t,authBusy:n,authMessage:i,authUrl:s,authCodeInput:o,authExpiresIn:r,onStartAuth:a,onSubmitAuthCode:u,onAuthCodeChange:c,onSkipToWhatsApp:l}=e;return t===!0?p`
506
515
  <div class="setup-container">
507
516
  <div class="setup-card setup-success">
508
517
  ${we("auth")}
@@ -634,7 +643,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
634
643
  </p>
635
644
  </div>
636
645
  </div>
637
- `}function To(e,t){const n=new Map(t.whatsappAccounts.map(i=>[i.accountId,i]));return e.whatsappAccountId?n.get(e.whatsappAccountId)??null:e.isDefault&&t.whatsappAccounts.length===1?t.whatsappAccounts[0]??null:null}function Bt(e){var n;const t=(n=e.wsProps)==null?void 0:n.selectedWorkspace;return t?e.workspaces.find(i=>i.name===t)??null:e.workspaces[0]??null}function Fr(e){const t=Bt(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??Xe().name,i=e.whatsappBusy||e.gatewayHealthLoading;if(e.renamingWorkspace&&t){const s=()=>{const o=e.renameWorkspaceName.trim();o&&e.onWorkspaceRename(t.name,o)};return p`
646
+ `}function _o(e,t){const n=new Map(t.whatsappAccounts.map(i=>[i.accountId,i]));return e.whatsappAccountId?n.get(e.whatsappAccountId)??null:e.isDefault&&t.whatsappAccounts.length===1?t.whatsappAccounts[0]??null:null}function Wt(e){var n;const t=(n=e.wsProps)==null?void 0:n.selectedWorkspace;return t?e.workspaces.find(i=>i.name===t)??null:e.workspaces[0]??null}function Ur(e){const t=Wt(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??Xe().name,i=e.whatsappBusy||e.gatewayHealthLoading;if(e.renamingWorkspace&&t){const s=()=>{const o=e.renameWorkspaceName.trim();o&&e.onWorkspaceRename(t.name,o)};return p`
638
647
  <div style="display: flex; align-items: center; gap: 6px; margin-bottom: 4px;">
639
648
  <input
640
649
  type="text"
@@ -676,7 +685,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
676
685
  ${D.rotateCw}
677
686
  </button>
678
687
  </div>
679
- `}function Ur(e){return p`
688
+ `}function Wr(e){return p`
680
689
  <div class="setup-status-item">
681
690
  ${q(e.gatewayHealthy===!1?"bad":"good")}
682
691
  <div class="setup-status-info">
@@ -693,7 +702,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
693
702
  ${D.rotateCw}
694
703
  </button>
695
704
  </div>
696
- `}function Wr(e){const t=e.authConnected===!0;return p`
705
+ `}function Kr(e){const t=e.authConnected===!0;return p`
697
706
  <div class="setup-status-item">
698
707
  ${q(t?"good":"bad")}
699
708
  <div class="setup-status-info">
@@ -722,7 +731,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
722
731
  </button>
723
732
  `}
724
733
  </div>
725
- `}function Kr(e){return p`
734
+ `}function zr(e){return p`
726
735
  <div class="setup-status-item" style="flex-wrap: wrap;">
727
736
  ${q("good")}
728
737
  <div class="setup-status-info">
@@ -762,7 +771,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
762
771
  </div>
763
772
  `:k}
764
773
  </div>
765
- `}function vc(e){var t,n;try{const i=JSON.parse(e),s=(i==null?void 0:i.error)??i,o=((n=(t=s==null?void 0:s.output)==null?void 0:t.payload)==null?void 0:n.message)??(s==null?void 0:s.message)??(i==null?void 0:i.message);if(o&&typeof o=="string")return o}catch{}return e.length>80?e.slice(0,77)+"…":e}function zr(e){var d;const t=Bt(e);if(!t)return k;const n=To(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected),s=(n==null?void 0:n.linked)&&!i,o=!!n,r=i?"good":s?"partial":o?"bad":"unknown",a=i?"Connected":s?"Linked, not connected":o?n!=null&&n.lastError?vc(n.lastError):"Not connected":"Not paired",u=!(n!=null&&n.provider)||(n==null?void 0:n.provider)==="baileys",c=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(d=e.whatsappAccounts[0])==null?void 0:d.accountId:void 0),l=c!=null&&e.whatsappActiveQrAccountId===c;return p`
774
+ `}function vc(e){var t,n;try{const i=JSON.parse(e),s=(i==null?void 0:i.error)??i,o=((n=(t=s==null?void 0:s.output)==null?void 0:t.payload)==null?void 0:n.message)??(s==null?void 0:s.message)??(i==null?void 0:i.message);if(o&&typeof o=="string")return o}catch{}return e.length>80?e.slice(0,77)+"…":e}function jr(e){var d;const t=Wt(e);if(!t)return k;const n=_o(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected),s=(n==null?void 0:n.linked)&&!i,o=!!n,r=i?"good":s?"partial":o?"bad":"unknown",a=i?"Connected":s?"Linked, not connected":o?n!=null&&n.lastError?vc(n.lastError):"Not connected":"Not paired",u=!(n!=null&&n.provider)||(n==null?void 0:n.provider)==="baileys",c=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(d=e.whatsappAccounts[0])==null?void 0:d.accountId:void 0),l=c!=null&&e.whatsappActiveQrAccountId===c;return p`
766
775
  <div class="setup-status-item" style="flex-wrap: wrap;">
767
776
  ${q(r)}
768
777
  <div class="setup-status-info">
@@ -823,7 +832,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
823
832
  </div>
824
833
  `:k}
825
834
  </div>
826
- `}const sf=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],of="anthropic/claude-sonnet-4-5-20250929",rf=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function af(e){if(!e.whatsappSettingsOpen)return k;const t=Bt(e);if(!t)return k;const n=To(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected);if(!n||!i)return k;const s=()=>e.onWhatsAppSettingsClose(),o=e.whatsappModelCatalog??[],r=new Set(o.filter(l=>l.provider==="anthropic").map(l=>l.id)),a=sf.filter(l=>r.has(l.id)),u=e.whatsappModel??of,c=e.whatsappThinkingLevel??"off";return p`
835
+ `}const of=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],rf="anthropic/claude-sonnet-4-5-20250929",af=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function lf(e){if(!e.whatsappSettingsOpen)return k;const t=Wt(e);if(!t)return k;const n=_o(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected);if(!n||!i)return k;const s=()=>e.onWhatsAppSettingsClose(),o=e.whatsappModelCatalog??[],r=new Set(o.filter(l=>l.provider==="anthropic").map(l=>l.id)),a=of.filter(l=>r.has(l.id)),u=e.whatsappModel??rf,c=e.whatsappThinkingLevel??"off";return p`
827
836
  <div class="setup-info-overlay" @click=${l=>{l.target.classList.contains("setup-info-overlay")&&s()}}>
828
837
  <div class="setup-info-card" style="max-width: 360px;">
829
838
  <h3>Public Agent Settings</h3>
@@ -909,7 +918,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
909
918
  .value=${c}
910
919
  @change=${l=>{e.onWhatsAppThinkingChange(l.target.value)}}
911
920
  >
912
- ${rf.map(l=>p`
921
+ ${af.map(l=>p`
913
922
  <option value=${l.value} ?selected=${c===l.value}>
914
923
  ${l.label}
915
924
  </option>
@@ -926,7 +935,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
926
935
  </button>
927
936
  </div>
928
937
  </div>
929
- `}function _o(e){const t=Bt(e),n=e.imessageOwnerWorkspace,i=!!(t&&n===t.name),s=!!(n&&t&&n!==t.name);return{selectedWs:t,ownerWs:n,thisWsOwns:i,anotherWsOwns:s}}function jr(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=_o(e);let s,o;return i?(s="partial",o=`Connected to ${t}`):n&&e.imessageConnected?(s="good",o="Connected"):n&&e.imessageRunning?(s="partial",o="Running, not connected"):n?(s="bad",o="Not running"):e.imessageConfigured?(s="unknown",o="Not connected"):(s="bad",o="Not configured"),p`
938
+ `}function Mo(e){const t=Wt(e),n=e.imessageOwnerWorkspace,i=!!(t&&n===t.name),s=!!(n&&t&&n!==t.name);return{selectedWs:t,ownerWs:n,thisWsOwns:i,anotherWsOwns:s}}function Hr(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=Mo(e);let s,o;return i?(s="partial",o=`Connected to ${t}`):n&&e.imessageConnected?(s="good",o="Connected"):n&&e.imessageRunning?(s="partial",o="Running, not connected"):n?(s="bad",o="Not running"):e.imessageConfigured?(s="unknown",o="Not connected"):(s="bad",o="Not configured"),p`
930
939
  <div class="setup-status-item" style="flex-wrap: wrap;">
931
940
  ${q(s)}
932
941
  <div class="setup-status-info">
@@ -944,7 +953,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
944
953
  </button>
945
954
  ${k}
946
955
  </div>
947
- `}function lf(e){if(!e.imessageEnableConfirm)return k;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=_o(e),s=()=>{e.onIMessageEnableCancel()};return n?p`
956
+ `}function cf(e){if(!e.imessageEnableConfirm)return k;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=Mo(e),s=()=>{e.onIMessageEnableCancel()};return n?p`
948
957
  <div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&s()}}>
949
958
  <div class="setup-info-card" style="text-align: center;">
950
959
  <h3>iMessage</h3>
@@ -1020,7 +1029,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1020
1029
  </button>
1021
1030
  </div>
1022
1031
  </div>
1023
- `}function Hr(e){if(!e.isMaster)return k;const n=e.apiKeyProviders.filter(i=>i.hasKey).length;return p`
1032
+ `}function qr(e){if(!e.isMaster)return k;const n=e.apiKeyProviders.filter(i=>i.hasKey).length;return p`
1024
1033
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
1025
1034
  <div class="setup-status-item">
1026
1035
  ${q(n>0?"good":"bad")}
@@ -1034,8 +1043,8 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1034
1043
  >Manage</button>
1035
1044
  </div>
1036
1045
  </div>
1037
- ${cf(e)}
1038
- `}function cf(e){if(!e.apiKeyModalOpen)return k;const t=e.apiKeyProviders,n={};for(const c of t)c.key&&(n[c.id]=c.key);const i=(c,l)=>{const d=l==null?void 0:l.closest(".setup-apikey-input"),h=d==null?void 0:d.querySelector("input"),v=h==null?void 0:h.value.trim();!v||v===n[c]||e.onApiKeySave(c,v)},s=c=>{const l=c.currentTarget,d=l.closest(".setup-apikey-input"),h=d==null?void 0:d.querySelector("input");if(!h)return;const v=h.type==="text";h.type=v?"password":"text",l.classList.toggle("active",!v)},o=(c,l)=>{const d=l.target,h=d.closest(".setup-apikey-input"),v=d.value.trim(),f=v.length>0&&v!==n[c],b=h==null?void 0:h.querySelector(".setup-apikey-save");b&&(b.style.display=f?"":"none");const S=h==null?void 0:h.querySelector(".setup-apikey-eye");S&&(S.style.display=v.length>0?"":"none")},r=t.filter(c=>c.primary),a=t.filter(c=>!c.primary),u=c=>{const l=e.apiKeySavingProvider===c.id&&e.apiKeyBusy,d=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key saved`,h=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key removed`;return p`
1046
+ ${uf(e)}
1047
+ `}function uf(e){if(!e.apiKeyModalOpen)return k;const t=e.apiKeyProviders,n={};for(const c of t)c.key&&(n[c.id]=c.key);const i=(c,l)=>{const d=l==null?void 0:l.closest(".setup-apikey-input"),h=d==null?void 0:d.querySelector("input"),v=h==null?void 0:h.value.trim();!v||v===n[c]||e.onApiKeySave(c,v)},s=c=>{const l=c.currentTarget,d=l.closest(".setup-apikey-input"),h=d==null?void 0:d.querySelector("input");if(!h)return;const v=h.type==="text";h.type=v?"password":"text",l.classList.toggle("active",!v)},o=(c,l)=>{const d=l.target,h=d.closest(".setup-apikey-input"),v=d.value.trim(),f=v.length>0&&v!==n[c],b=h==null?void 0:h.querySelector(".setup-apikey-save");b&&(b.style.display=f?"":"none");const S=h==null?void 0:h.querySelector(".setup-apikey-eye");S&&(S.style.display=v.length>0?"":"none")},r=t.filter(c=>c.primary),a=t.filter(c=>!c.primary),u=c=>{const l=e.apiKeySavingProvider===c.id&&e.apiKeyBusy,d=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key saved`,h=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key removed`;return p`
1039
1048
  <div class="setup-apikey-row">
1040
1049
  <div class="setup-apikey-info">
1041
1050
  <strong>${c.name}</strong>
@@ -1090,7 +1099,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1090
1099
  </div>
1091
1100
  </div>
1092
1101
  </div>
1093
- `}function qr(e){const t=e.updateAvailable===null?"unknown":e.updateAvailable?"partial":"good",n=e.updateAvailable&&e.latestVersion?`v${e.currentVersion} → v${e.latestVersion}`:e.currentVersion?`v${e.currentVersion}`:"Unknown",i=e.updateChecking||e.updateRunning;return p`
1102
+ `}function Vr(e){const t=e.updateAvailable===null?"unknown":e.updateAvailable?"partial":"good",n=e.updateAvailable&&e.latestVersion?`v${e.currentVersion} → v${e.latestVersion}`:e.currentVersion?`v${e.currentVersion}`:"Unknown",i=e.updateChecking||e.updateRunning;return p`
1094
1103
  <div class="setup-status-item">
1095
1104
  ${q(t)}
1096
1105
  <div class="setup-status-info">
@@ -1118,7 +1127,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1118
1127
  </button>
1119
1128
  `}
1120
1129
  </div>
1121
- `}const uf={anonymous:"Open access",verified:"WhatsApp OTP",choice:"Visitor chooses"};function Vr(e){const t=e.publicChatEnabled;return p`
1130
+ `}const df={anonymous:"Open access",verified:"WhatsApp OTP",choice:"Visitor chooses"};function Gr(e){const t=e.publicChatEnabled;return p`
1122
1131
  <div class="setup-status-item">
1123
1132
  ${q(t?"good":"unknown")}
1124
1133
  <div class="setup-status-info">
@@ -1142,7 +1151,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1142
1151
  @click=${e.onPublicChatToggle}
1143
1152
  >${e.publicChatBusy?"...":t?"Disable":"Enable"}</button>
1144
1153
  </div>
1145
- `}function df(e){if(!e.isMaster)return k;const t=e.tailscaleStatus,n=e.tailscaleBusy,i=e.tailscaleAuthUrl;if(!t)return p`
1154
+ `}function pf(e){if(!e.isMaster)return k;const t=e.tailscaleStatus,n=e.tailscaleBusy,i=e.tailscaleAuthUrl;if(!t)return p`
1146
1155
  <div class="setup-status-item">
1147
1156
  ${q("unknown")}
1148
1157
  <div class="setup-status-info">
@@ -1289,7 +1298,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1289
1298
  @click=${e.onTailscaleFunnelDisable}
1290
1299
  >${n?"...":"Disable"}</button>
1291
1300
  </div>
1292
- `}function Gr(e){const t=e>=70?4:e>=50?3:e>=30?2:1;return p`
1301
+ `}function Qr(e){const t=e>=70?4:e>=50?3:e>=30?2:1;return p`
1293
1302
  <span style="display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; vertical-align: middle;">
1294
1303
  ${[4,7,10,14].map((i,s)=>p`<span style="
1295
1304
  width: 3px;
@@ -1298,7 +1307,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1298
1307
  background: ${s<t?"var(--tasker-accent, #00e5ff)":"rgba(255,255,255,0.15)"};
1299
1308
  "></span>`)}
1300
1309
  </span>
1301
- `}function Qr(e){var u;if(e.serverPlatform!=="linux")return k;const t=e.wifiStatus,n=e.wifiBusy;if(!t)return p`
1310
+ `}function Yr(e){var u;if(e.serverPlatform!=="linux")return k;const t=e.wifiStatus,n=e.wifiBusy;if(!t)return p`
1302
1311
  <div class="setup-status-item">
1303
1312
  ${q("unknown")}
1304
1313
  <div class="setup-status-info">
@@ -1314,7 +1323,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1314
1323
  <span>NetworkManager not available</span>
1315
1324
  </div>
1316
1325
  </div>
1317
- `;const i=e.wifiNetworks,s=e.wifiSelectedSsid,o=i.length>0,r=t.connected?"good":"partial",a=t.connected?p`${t.ssid} ${t.signal!=null?p`<span style="margin-left: 4px;">${Gr(t.signal)}</span>`:k}`:"Not connected";return p`
1326
+ `;const i=e.wifiNetworks,s=e.wifiSelectedSsid,o=i.length>0,r=t.connected?"good":"partial",a=t.connected?p`${t.ssid} ${t.signal!=null?p`<span style="margin-left: 4px;">${Qr(t.signal)}</span>`:k}`:"Not connected";return p`
1318
1327
  <div>
1319
1328
  <div class="setup-status-item">
1320
1329
  ${q(r)}
@@ -1372,7 +1381,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1372
1381
  </span>
1373
1382
  <span style="display: flex; align-items: center; gap: 8px;">
1374
1383
  ${c.security!=="Open"?p`<span style="opacity: 0.4; font-size: 11px;" title="${c.security}">\uD83D\uDD12</span>`:k}
1375
- <span title="Signal: ${c.signal}%">${Gr(c.signal)}</span>
1384
+ <span title="Signal: ${c.signal}%">${Qr(c.signal)}</span>
1376
1385
  </span>
1377
1386
  </button>
1378
1387
  `)}
@@ -1410,7 +1419,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1410
1419
  </div>
1411
1420
  `:k}
1412
1421
  </div>
1413
- `}function pf(e){var i,s,o;const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return k;if(t)return p`
1422
+ `}function hf(e){var i,s,o;const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return k;if(t)return p`
1414
1423
  <div class="setup-info-overlay">
1415
1424
  <div class="setup-info-card" style="max-width: 400px;">
1416
1425
  <h3>Software Update</h3>
@@ -1422,7 +1431,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1422
1431
  ${r.status==="running"?p`<span class="setup-update-spinner"></span>`:r.status==="done"?p`<span class="setup-update-icon-ok">${D.check}</span>`:p`<span class="setup-update-icon-fail">${D.x}</span>`}
1423
1432
  </span>
1424
1433
  <span class="setup-update-step-name">${r.name}</span>
1425
- ${r.durationMs!=null?p`<span class="setup-update-step-time">${Yr(r.durationMs)}</span>`:k}
1434
+ ${r.durationMs!=null?p`<span class="setup-update-step-time">${Xr(r.durationMs)}</span>`:k}
1426
1435
  </div>
1427
1436
  `)}
1428
1437
  </div>
@@ -1430,7 +1439,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1430
1439
  ${e.updateMessage?p`<p style="text-align: center; color: var(--tasker-text-grey); font-size: 13px; margin: 12px 0 0;">${e.updateMessage}</p>`:k}
1431
1440
  </div>
1432
1441
  </div>
1433
- `;if(n){const r=n.status==="ok";let a;if(r){const c=(i=n.before)==null?void 0:i.version,l=((s=n.after)==null?void 0:s.version)??n.currentVersion;a=c?`v${c} → v${l}`:`Updated to v${l}`}else a=n.reason??((o=n.failedStep)==null?void 0:o.name)??"unknown error";const u=n.durationMs!=null?Yr(n.durationMs):null;return p`
1442
+ `;if(n){const r=n.status==="ok";let a;if(r){const c=(i=n.before)==null?void 0:i.version,l=((s=n.after)==null?void 0:s.version)??n.currentVersion;a=c?`v${c} → v${l}`:`Updated to v${l}`}else a=n.reason??((o=n.failedStep)==null?void 0:o.name)??"unknown error";const u=n.durationMs!=null?Xr(n.durationMs):null;return p`
1434
1443
  <div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onUpdateDismissResult()}}>
1435
1444
  <div class="setup-info-card" style="max-width: 360px; text-align: center;">
1436
1445
  <div class="setup-update-result-icon ${r?"ok":"fail"}">${r?D.circleCheck:D.circleX}</div>
@@ -1450,7 +1459,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1450
1459
  </button>
1451
1460
  </div>
1452
1461
  </div>
1453
- `}return k}function Yr(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),i=t%60;return i>0?`${n}m ${i}s`:`${n}m`}function Xr(e){const t=e.accountHasPin;return p`
1462
+ `}return k}function Xr(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),i=t%60;return i>0?`${n}m ${i}s`:`${n}m`}function Zr(e){const t=e.accountHasPin;return p`
1454
1463
  <div class="setup-status-item">
1455
1464
  ${q(t?"good":"bad")}
1456
1465
  <div class="setup-status-info">
@@ -1463,7 +1472,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1463
1472
  @click=${()=>e.onAccountPinModalOpen()}
1464
1473
  >${t?"Change":"Set PIN"}</button>
1465
1474
  </div>
1466
- `}function Zr(e){if(!e.accountPinModalOpen)return k;const t=e.accountHasPin,n=e.accountPinBusy;let i="",s="",o="";const r=c=>l=>{const d=l.target;d.value=d.value.replace(/\D/g,"").slice(0,6),c(d.value)},a=(c,l)=>{var h;let d=c.querySelector(".pin-modal-validation");d||(d=document.createElement("p"),d.className="login-error pin-modal-validation",(h=c.querySelector("button[type=submit]"))==null||h.before(d)),d.textContent=l},u=c=>{c.preventDefault();const l=c.target;if(!n){if(t&&!i){a(l,"Enter your current PIN");return}if(!s){a(l,"Enter a new PIN");return}if(!o){a(l,"Confirm your new PIN");return}if(s!==o){a(l,"PINs do not match");return}if(s.length<4){a(l,"PIN must be 4–6 digits");return}e.onAccountPinSave(t?i:null,s)}};return p`
1475
+ `}function Jr(e){if(!e.accountPinModalOpen)return k;const t=e.accountHasPin,n=e.accountPinBusy;let i="",s="",o="";const r=c=>l=>{const d=l.target;d.value=d.value.replace(/\D/g,"").slice(0,6),c(d.value)},a=(c,l)=>{var h;let d=c.querySelector(".pin-modal-validation");d||(d=document.createElement("p"),d.className="login-error pin-modal-validation",(h=c.querySelector("button[type=submit]"))==null||h.before(d)),d.textContent=l},u=c=>{c.preventDefault();const l=c.target;if(!n){if(t&&!i){a(l,"Enter your current PIN");return}if(!s){a(l,"Enter a new PIN");return}if(!o){a(l,"Confirm your new PIN");return}if(s!==o){a(l,"PINs do not match");return}if(s.length<4){a(l,"PIN must be 4–6 digits");return}e.onAccountPinSave(t?i:null,s)}};return p`
1467
1476
  <div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onAccountPinModalClose()}}>
1468
1477
  <div class="setup-info-card" style="max-width: 340px;">
1469
1478
  <div class="setup-info-header">
@@ -1520,7 +1529,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1520
1529
  </form>
1521
1530
  </div>
1522
1531
  </div>
1523
- `}function Jr(e){if(!e.addingWorkspace)return k;const{workspaceSaving:t}=e;return p`
1532
+ `}function ea(e){if(!e.addingWorkspace)return k;const{workspaceSaving:t}=e;return p`
1524
1533
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
1525
1534
  <div class="setup-add-account">
1526
1535
  <strong>New Account</strong>
@@ -1573,7 +1582,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1573
1582
  </div>
1574
1583
  </div>
1575
1584
  </div>
1576
- `}function ea(e){const t=Bt(e);return!t||t.isDefault?k:e.workspaceRemoveConfirm===t.name?p`
1585
+ `}function ta(e){const t=Wt(e);return!t||t.isDefault?k:e.workspaceRemoveConfirm===t.name?p`
1577
1586
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 12px;">
1578
1587
  <div style="font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
1579
1588
  <span style="color: var(--tasker-danger, #ef4444);">Remove "${t.displayName??t.name}" and its WhatsApp account?</span>
@@ -1602,7 +1611,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1602
1611
  @click=${i=>{i.preventDefault(),e.onSetWorkspaceRemoveConfirm(t.name)}}
1603
1612
  >Remove Account</a>
1604
1613
  </p>
1605
- `}function ta(e){if(e.uninstallDone)return p`
1614
+ `}function na(e){if(e.uninstallDone)return p`
1606
1615
  <div style="margin-top: 24px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
1607
1616
  <p style="color: var(--tasker-danger, #ef4444); font-size: 13px; font-weight: 600; margin: 0 0 8px 0;">
1608
1617
  Taskmaster has been uninstalled.
@@ -1657,11 +1666,11 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1657
1666
  @click=${t=>{t.preventDefault(),e.onUninstallConfirm()}}
1658
1667
  >Uninstall Taskmaster</a>
1659
1668
  </p>
1660
- `}function na(){return p`
1669
+ `}function ia(){return p`
1661
1670
  <p class="setup-hint" style="margin-top: 4px; font-size: 12px; opacity: 0.6;">
1662
1671
  Need help? <a href="https://wa.me/447591215452" target="_blank" rel="noopener" style="color: var(--tasker-orange);">Message Dave on WhatsApp</a>
1663
1672
  </p>
1664
- `}function hf(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:i,whatsappLoginConnected:s,whatsappChannelStatus:o}=e;if(i)return p`
1673
+ `}function ff(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:i,whatsappLoginConnected:s,whatsappChannelStatus:o}=e;if(i)return p`
1665
1674
  <div class="setup-container">
1666
1675
  <div class="setup-card">
1667
1676
  <h1>Scan with WhatsApp</h1>
@@ -1698,51 +1707,51 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1698
1707
  `;const r=(o==null?void 0:o.running)&&(o==null?void 0:o.connected);return o?(e.whatsappAccounts.length>1?e.whatsappAccounts.every(l=>l.running&&l.connected):r)&&e.authConnected?p`
1699
1708
  <div class="setup-container">
1700
1709
  <div class="setup-card setup-success setup-dashboard-wide">
1701
- ${Fr(e)}
1710
+ ${Ur(e)}
1702
1711
  <div class="setup-status-dashboard">
1703
- ${Ur(e)}
1704
1712
  ${Wr(e)}
1705
1713
  ${Kr(e)}
1706
1714
  ${zr(e)}
1707
- ${e.serverPlatform==="darwin"?jr(e):k}
1708
- ${Xr(e)}
1709
- ${qr(e)}
1715
+ ${jr(e)}
1716
+ ${e.serverPlatform==="darwin"?Hr(e):k}
1717
+ ${Zr(e)}
1710
1718
  ${Vr(e)}
1711
- ${df(e)}
1712
- ${Qr(e)}
1719
+ ${Gr(e)}
1720
+ ${pf(e)}
1721
+ ${Yr(e)}
1713
1722
  </div>
1714
1723
 
1715
- ${Zr(e)}
1716
- ${Hr(e)}
1717
1724
  ${Jr(e)}
1725
+ ${qr(e)}
1718
1726
  ${ea(e)}
1719
1727
  ${ta(e)}
1720
- ${na()}
1728
+ ${na(e)}
1729
+ ${ia()}
1721
1730
  ${e.workspacesError?p`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:k}
1722
1731
  </div>
1723
1732
  </div>
1724
1733
  `:p`
1725
1734
  <div class="setup-container">
1726
1735
  <div class="setup-card setup-dashboard-wide">
1727
- ${Fr(e)}
1736
+ ${Ur(e)}
1728
1737
  <div class="setup-status-dashboard">
1729
- ${Ur(e)}
1730
1738
  ${Wr(e)}
1731
1739
  ${Kr(e)}
1732
1740
  ${zr(e)}
1733
- ${e.serverPlatform==="darwin"?jr(e):k}
1734
- ${Xr(e)}
1735
- ${qr(e)}
1741
+ ${jr(e)}
1742
+ ${e.serverPlatform==="darwin"?Hr(e):k}
1743
+ ${Zr(e)}
1736
1744
  ${Vr(e)}
1737
- ${Qr(e)}
1745
+ ${Gr(e)}
1746
+ ${Yr(e)}
1738
1747
  </div>
1739
1748
 
1740
- ${Zr(e)}
1741
- ${Hr(e)}
1742
1749
  ${Jr(e)}
1750
+ ${qr(e)}
1743
1751
  ${ea(e)}
1744
1752
  ${ta(e)}
1745
- ${na()}
1753
+ ${na(e)}
1754
+ ${ia()}
1746
1755
  ${e.workspacesError?p`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:k}
1747
1756
  </div>
1748
1757
  </div>
@@ -1787,7 +1796,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1787
1796
  </button>
1788
1797
  </div>
1789
1798
  </div>
1790
- `}function ff(e){const{connected:t,currentStep:n}=e;if(t&&ci()&&Co(),e.uninstallDone||!t&&ci())return p`
1799
+ `}function gf(e){const{connected:t,currentStep:n}=e;if(t&&ui()&&To(),e.uninstallDone||!t&&ui())return p`
1791
1800
  <div class="setup-container">
1792
1801
  <div class="setup-card">
1793
1802
  <p style="color: var(--tasker-danger, #ef4444); font-size: 16px; font-weight: 600; margin: 0 0 12px 0;">
@@ -1810,7 +1819,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1810
1819
  <p>${o?"Restarting gateway after update…":"Connecting to gateway..."}</p>
1811
1820
  </div>
1812
1821
  </div>
1813
- `}let i;switch(n){case"license":i=Br(e);break;case"auth":i=nf(e);break;case"whatsapp":case"complete":i=hf(e);break;default:i=Br(e)}const s=yt("Setup",e.wsProps);return p`${i}${tf(e)}${lf(e)}${af(e)}${pf(e)}${s}`}function gf(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return p`
1822
+ `}let i;switch(n){case"license":i=Fr(e);break;case"auth":i=sf(e);break;case"whatsapp":case"complete":i=ff(e);break;default:i=Fr(e)}const s=vt("Setup",e.wsProps);return p`${i}${nf(e)}${cf(e)}${lf(e)}${hf(e)}${s}`}function mf(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return p`
1814
1823
  <div class="sp-list-item">
1815
1824
  <div class="sp-list-item-main">
1816
1825
  <div class="sp-list-item-title">${e.phone}</div>
@@ -1825,7 +1834,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1825
1834
  Remove
1826
1835
  </button>`}
1827
1836
  </div>
1828
- `}function mf(e){if(!e.connected)return p`
1837
+ `}function yf(e){if(!e.connected)return p`
1829
1838
  <div class="setup-container">
1830
1839
  <div class="setup-card">
1831
1840
  <div class="setup-spinner"></div>
@@ -1834,7 +1843,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1834
1843
  </div>
1835
1844
  `;const t=n=>{n.preventDefault(),e.newPhone.trim()&&e.onAdd(e.newPhone)};return p`
1836
1845
  <div class="setup-container">
1837
- ${yt("Admins",e.wsProps)}
1846
+ ${vt("Admins",e.wsProps)}
1838
1847
  <div class="setup-card" style="max-width: 520px;">
1839
1848
  <h1>Admin Phones</h1>
1840
1849
  <p style="margin-bottom: 16px;">
@@ -1874,7 +1883,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1874
1883
  </form>
1875
1884
 
1876
1885
  <div class="sp-list" style="margin-top: 20px;">
1877
- ${e.phones.length===0?p`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>gf(n,e))}
1886
+ ${e.phones.length===0?p`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>mf(n,e))}
1878
1887
  </div>
1879
1888
 
1880
1889
  <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
@@ -1885,7 +1894,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1885
1894
 
1886
1895
  </div>
1887
1896
  </div>
1888
- `}function yf(e){return Object.keys(e.fields).length}function vf(e,t){const n=Object.entries(e.fields);return p`
1897
+ `}function vf(e){return Object.keys(e.fields).length}function bf(e,t){const n=Object.entries(e.fields);return p`
1889
1898
  <div class="contacts-record-fields">
1890
1899
  ${n.length===0?p`<div style="color: rgba(255,255,255,0.4); font-size: 13px; margin-top: 12px;">No fields yet. Add one below.</div>`:n.map(([i,s])=>p`
1891
1900
  <div class="contacts-field-row">
@@ -1932,7 +1941,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1932
1941
  </button>
1933
1942
  </div>
1934
1943
  </div>
1935
- `}function bf(e,t){const n=t.editingId===e.id,i=yf(e),s=i===0?"No fields":`${i} field${i>1?"s":""}`;return p`
1944
+ `}function wf(e,t){const n=t.editingId===e.id,i=vf(e),s=i===0?"No fields":`${i} field${i>1?"s":""}`;return p`
1936
1945
  <div class="contacts-record">
1937
1946
  <div
1938
1947
  class="contacts-record-header"
@@ -1944,9 +1953,9 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1944
1953
  </div>
1945
1954
  <span class="contacts-record-meta">${s}</span>
1946
1955
  </div>
1947
- ${n?vf(e,t):k}
1956
+ ${n?bf(e,t):k}
1948
1957
  </div>
1949
- `}function wf(e){if(!e.connected)return p`
1958
+ `}function kf(e){if(!e.connected)return p`
1950
1959
  <div class="setup-container">
1951
1960
  <div class="setup-card">
1952
1961
  <div class="setup-spinner"></div>
@@ -1955,7 +1964,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
1955
1964
  </div>
1956
1965
  `;const t=i=>{i.preventDefault(),e.onSearchSubmit()},n=i=>{i.preventDefault(),e.newRecordPhone.trim()&&e.newRecordName.trim()&&e.onAdd(e.newRecordPhone,e.newRecordName)};return p`
1957
1966
  <div class="setup-container">
1958
- ${yt("Contacts",e.wsProps)}
1967
+ ${vt("Contacts",e.wsProps)}
1959
1968
  <div class="setup-card" style="max-width: 620px;">
1960
1969
  <h1>Contact Records</h1>
1961
1970
  <p style="margin-bottom: 16px;">
@@ -2042,7 +2051,7 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
2042
2051
  <div style="margin-top: 16px;">
2043
2052
  ${e.records.length===0?p`<div class="contacts-empty">
2044
2053
  ${e.searchQuery.trim()?`No records matching "${e.searchQuery}".`:"No contact records yet. Add one to get started."}
2045
- </div>`:e.records.map(i=>bf(i,e))}
2054
+ </div>`:e.records.map(i=>wf(i,e))}
2046
2055
  </div>
2047
2056
 
2048
2057
  <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
@@ -2053,13 +2062,13 @@ ${o}`:o),e.chatStream="","working"}else if(t.state==="block"){const s=rn(t.messa
2053
2062
  </div>
2054
2063
  </div>
2055
2064
  </div>
2056
- `}const bc={CHILD:2},wc=e=>(...t)=>({_$litDirective$:e,values:t});let kc=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,i){this._$Ct=t,this._$AM=n,this._$Ci=i}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:kf}=ld,ia=e=>e,sa=()=>document.createComment(""),Ht=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const r=i.insertBefore(sa(),s),a=i.insertBefore(sa(),s);n=new kf(r,a,e,e.options)}else{const r=n._$AB.nextSibling,a=n._$AM,u=a!==e;if(u){let c;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==a._$AU&&n._$AP(c)}if(r!==s||u){let c=n._$AA;for(;c!==r;){const l=ia(c).nextSibling;ia(i).insertBefore(c,s),c=l}}}return n},it=(e,t,n=e)=>(e._$AI(t,n),e),Sf={},xf=(e,t=Sf)=>e._$AH=t,$f=e=>e._$AH,ss=e=>{e._$AR(),e._$AA.remove()};const oa=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},Af=wc(class extends kc{constructor(e){if(super(e),e.type!==bc.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let i;n===void 0?n=t:t!==void 0&&(i=t);const s=[],o=[];let r=0;for(const a of e)s[r]=i?i(a,r):r,o[r]=n(a,r),r++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=$f(e),{values:o,keys:r}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=r,o;const a=this.ut??(this.ut=[]),u=[];let c,l,d=0,h=s.length-1,v=0,f=o.length-1;for(;d<=h&&v<=f;)if(s[d]===null)d++;else if(s[h]===null)h--;else if(a[d]===r[v])u[v]=it(s[d],o[v]),d++,v++;else if(a[h]===r[f])u[f]=it(s[h],o[f]),h--,f--;else if(a[d]===r[f])u[f]=it(s[d],o[f]),Ht(e,u[f+1],s[d]),d++,f--;else if(a[h]===r[v])u[v]=it(s[h],o[v]),Ht(e,s[d],s[h]),h--,v++;else if(c===void 0&&(c=oa(r,v,f),l=oa(a,d,h)),c.has(a[d]))if(c.has(a[h])){const b=l.get(r[v]),S=b!==void 0?s[b]:null;if(S===null){const $=Ht(e,s[d]);it($,o[v]),u[v]=$}else u[v]=it(S,o[v]),Ht(e,s[d],S),s[b]=null;v++}else ss(s[h]),h--;else ss(s[d]),d++;for(;v<=f;){const b=Ht(e,u[f+1]);it(b,o[v]),u[v++]=b}for(;d<=h;){const b=s[d++];b!==null&&ss(b)}return this.ut=r,xf(e,u),Qe}});class Ds extends kc{constructor(t){if(super(t),this.it=k,t.type!==bc.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===Qe)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:[]}}}Ds.directiveName="unsafeHTML",Ds.resultType=1;const ui=wc(Ds);const{entries:Sc,setPrototypeOf:ra,isFrozen:Ef,getPrototypeOf:Cf,getOwnPropertyDescriptor:Tf}=Object;let{freeze:pe,seal:ge,create:Os}=Object,{apply:Bs,construct:Fs}=typeof Reflect<"u"&&Reflect;pe||(pe=function(t){return t});ge||(ge=function(t){return t});Bs||(Bs=function(t,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),o=2;o<i;o++)s[o-2]=arguments[o];return t.apply(n,s)});Fs||(Fs=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return new t(...i)});const Fn=he(Array.prototype.forEach),_f=he(Array.prototype.lastIndexOf),aa=he(Array.prototype.pop),qt=he(Array.prototype.push),Mf=he(Array.prototype.splice),Yn=he(String.prototype.toLowerCase),os=he(String.prototype.toString),rs=he(String.prototype.match),Vt=he(String.prototype.replace),Pf=he(String.prototype.indexOf),Lf=he(String.prototype.trim),ye=he(Object.prototype.hasOwnProperty),le=he(RegExp.prototype.test),Gt=If(TypeError);function he(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return Bs(e,t,i)}}function If(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Fs(e,n)}}function F(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Yn;ra&&ra(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(Ef(t)||(t[i]=o),s=o)}e[s]=!0}return e}function Rf(e){for(let t=0;t<e.length;t++)ye(e,t)||(e[t]=null);return e}function Ce(e){const t=Os(null);for(const[n,i]of Sc(e))ye(e,n)&&(Array.isArray(i)?t[n]=Rf(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Ce(i):t[n]=i);return t}function Qt(e,t){for(;e!==null;){const i=Tf(e,t);if(i){if(i.get)return he(i.get);if(typeof i.value=="function")return he(i.value)}e=Cf(e)}function n(){return null}return n}const la=pe(["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"]),as=pe(["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"]),ls=pe(["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"]),Nf=pe(["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"]),cs=pe(["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"]),Df=pe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ca=pe(["#text"]),ua=pe(["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"]),us=pe(["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"]),da=pe(["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"]),Un=pe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Of=ge(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Bf=ge(/<%[\w\W]*|[\w\W]*%>/gm),Ff=ge(/\$\{[\w\W]*/gm),Uf=ge(/^data-[\-\w.\u00B7-\uFFFF]+$/),Wf=ge(/^aria-[\-\w]+$/),xc=ge(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Kf=ge(/^(?:\w+script|data):/i),zf=ge(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$c=ge(/^html$/i),jf=ge(/^[a-z][.\w]*(-[.\w]+)+$/i);var pa=Object.freeze({__proto__:null,ARIA_ATTR:Wf,ATTR_WHITESPACE:zf,CUSTOM_ELEMENT:jf,DATA_ATTR:Uf,DOCTYPE_NAME:$c,ERB_EXPR:Bf,IS_ALLOWED_URI:xc,IS_SCRIPT_OR_DATA:Kf,MUSTACHE_EXPR:Of,TMPLIT_EXPR:Ff});const Yt={element:1,text:3,progressingInstruction:7,comment:8,document:9},Hf=function(){return typeof window>"u"?null:window},qf=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(i=n.getAttribute(s));const o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},ha=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ac(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Hf();const t=I=>Ac(I);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==Yt.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:r,Node:a,Element:u,NodeFilter:c,NamedNodeMap:l=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:h,trustedTypes:v}=e,f=u.prototype,b=Qt(f,"cloneNode"),S=Qt(f,"remove"),$=Qt(f,"nextSibling"),A=Qt(f,"childNodes"),C=Qt(f,"parentNode");if(typeof r=="function"){const I=n.createElement("template");I.content&&I.content.ownerDocument&&(n=I.content.ownerDocument)}let T,M="";const{implementation:R,createNodeIterator:B,createDocumentFragment:ee,getElementsByTagName:me}=n,{importNode:Ke}=i;let Z=ha();t.isSupported=typeof Sc=="function"&&typeof C=="function"&&R&&R.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Ut,ERB_EXPR:wt,TMPLIT_EXPR:Je,DATA_ATTR:Ii,ARIA_ATTR:Ri,IS_SCRIPT_OR_DATA:Ni,ATTR_WHITESPACE:kn,CUSTOM_ELEMENT:Di}=pa;let{IS_ALLOWED_URI:Sn}=pa,Q=null;const xn=F({},[...la,...as,...ls,...cs,...ca]);let Y=null;const $n=F({},[...ua,...us,...da,...Un]);let H=Object.seal(Os(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}})),et=null,Wt=null;const ze=Object.seal(Os(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let An=!0,x=!0,_=!1,N=!0,O=!1,V=!0,z=!1,ae=!1,je=!1,kt=!1,En=!1,Cn=!1,Go=!0,Qo=!1;const Pu="user-content-";let Oi=!0,Kt=!1,St={},xe=null;const Bi=F({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Yo=null;const Xo=F({},["audio","video","img","source","image","track"]);let Fi=null;const Zo=F({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Tn="http://www.w3.org/1998/Math/MathML",_n="http://www.w3.org/2000/svg",Ie="http://www.w3.org/1999/xhtml";let xt=Ie,Ui=!1,Wi=null;const Lu=F({},[Tn,_n,Ie],os);let Mn=F({},["mi","mo","mn","ms","mtext"]),Pn=F({},["annotation-xml"]);const Iu=F({},["title","style","font","a","script"]);let zt=null;const Ru=["application/xhtml+xml","text/html"],Nu="text/html";let J=null,$t=null;const Du=n.createElement("form"),Jo=function(w){return w instanceof RegExp||w instanceof Function},Ki=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!($t&&$t===w)){if((!w||typeof w!="object")&&(w={}),w=Ce(w),zt=Ru.indexOf(w.PARSER_MEDIA_TYPE)===-1?Nu:w.PARSER_MEDIA_TYPE,J=zt==="application/xhtml+xml"?os:Yn,Q=ye(w,"ALLOWED_TAGS")?F({},w.ALLOWED_TAGS,J):xn,Y=ye(w,"ALLOWED_ATTR")?F({},w.ALLOWED_ATTR,J):$n,Wi=ye(w,"ALLOWED_NAMESPACES")?F({},w.ALLOWED_NAMESPACES,os):Lu,Fi=ye(w,"ADD_URI_SAFE_ATTR")?F(Ce(Zo),w.ADD_URI_SAFE_ATTR,J):Zo,Yo=ye(w,"ADD_DATA_URI_TAGS")?F(Ce(Xo),w.ADD_DATA_URI_TAGS,J):Xo,xe=ye(w,"FORBID_CONTENTS")?F({},w.FORBID_CONTENTS,J):Bi,et=ye(w,"FORBID_TAGS")?F({},w.FORBID_TAGS,J):Ce({}),Wt=ye(w,"FORBID_ATTR")?F({},w.FORBID_ATTR,J):Ce({}),St=ye(w,"USE_PROFILES")?w.USE_PROFILES:!1,An=w.ALLOW_ARIA_ATTR!==!1,x=w.ALLOW_DATA_ATTR!==!1,_=w.ALLOW_UNKNOWN_PROTOCOLS||!1,N=w.ALLOW_SELF_CLOSE_IN_ATTR!==!1,O=w.SAFE_FOR_TEMPLATES||!1,V=w.SAFE_FOR_XML!==!1,z=w.WHOLE_DOCUMENT||!1,kt=w.RETURN_DOM||!1,En=w.RETURN_DOM_FRAGMENT||!1,Cn=w.RETURN_TRUSTED_TYPE||!1,je=w.FORCE_BODY||!1,Go=w.SANITIZE_DOM!==!1,Qo=w.SANITIZE_NAMED_PROPS||!1,Oi=w.KEEP_CONTENT!==!1,Kt=w.IN_PLACE||!1,Sn=w.ALLOWED_URI_REGEXP||xc,xt=w.NAMESPACE||Ie,Mn=w.MATHML_TEXT_INTEGRATION_POINTS||Mn,Pn=w.HTML_INTEGRATION_POINTS||Pn,H=w.CUSTOM_ELEMENT_HANDLING||{},w.CUSTOM_ELEMENT_HANDLING&&Jo(w.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(H.tagNameCheck=w.CUSTOM_ELEMENT_HANDLING.tagNameCheck),w.CUSTOM_ELEMENT_HANDLING&&Jo(w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(H.attributeNameCheck=w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),w.CUSTOM_ELEMENT_HANDLING&&typeof w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(H.allowCustomizedBuiltInElements=w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),O&&(x=!1),En&&(kt=!0),St&&(Q=F({},ca),Y=[],St.html===!0&&(F(Q,la),F(Y,ua)),St.svg===!0&&(F(Q,as),F(Y,us),F(Y,Un)),St.svgFilters===!0&&(F(Q,ls),F(Y,us),F(Y,Un)),St.mathMl===!0&&(F(Q,cs),F(Y,da),F(Y,Un))),w.ADD_TAGS&&(typeof w.ADD_TAGS=="function"?ze.tagCheck=w.ADD_TAGS:(Q===xn&&(Q=Ce(Q)),F(Q,w.ADD_TAGS,J))),w.ADD_ATTR&&(typeof w.ADD_ATTR=="function"?ze.attributeCheck=w.ADD_ATTR:(Y===$n&&(Y=Ce(Y)),F(Y,w.ADD_ATTR,J))),w.ADD_URI_SAFE_ATTR&&F(Fi,w.ADD_URI_SAFE_ATTR,J),w.FORBID_CONTENTS&&(xe===Bi&&(xe=Ce(xe)),F(xe,w.FORBID_CONTENTS,J)),w.ADD_FORBID_CONTENTS&&(xe===Bi&&(xe=Ce(xe)),F(xe,w.ADD_FORBID_CONTENTS,J)),Oi&&(Q["#text"]=!0),z&&F(Q,["html","head","body"]),Q.table&&(F(Q,["tbody"]),delete et.tbody),w.TRUSTED_TYPES_POLICY){if(typeof w.TRUSTED_TYPES_POLICY.createHTML!="function")throw Gt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof w.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Gt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');T=w.TRUSTED_TYPES_POLICY,M=T.createHTML("")}else T===void 0&&(T=qf(v,s)),T!==null&&typeof M=="string"&&(M=T.createHTML(""));pe&&pe(w),$t=w}},er=F({},[...as,...ls,...Nf]),tr=F({},[...cs,...Df]),Ou=function(w){let E=C(w);(!E||!E.tagName)&&(E={namespaceURI:xt,tagName:"template"});const L=Yn(w.tagName),j=Yn(E.tagName);return Wi[w.namespaceURI]?w.namespaceURI===_n?E.namespaceURI===Ie?L==="svg":E.namespaceURI===Tn?L==="svg"&&(j==="annotation-xml"||Mn[j]):!!er[L]:w.namespaceURI===Tn?E.namespaceURI===Ie?L==="math":E.namespaceURI===_n?L==="math"&&Pn[j]:!!tr[L]:w.namespaceURI===Ie?E.namespaceURI===_n&&!Pn[j]||E.namespaceURI===Tn&&!Mn[j]?!1:!tr[L]&&(Iu[L]||!er[L]):!!(zt==="application/xhtml+xml"&&Wi[w.namespaceURI]):!1},$e=function(w){qt(t.removed,{element:w});try{C(w).removeChild(w)}catch{S(w)}},tt=function(w,E){try{qt(t.removed,{attribute:E.getAttributeNode(w),from:E})}catch{qt(t.removed,{attribute:null,from:E})}if(E.removeAttribute(w),w==="is")if(kt||En)try{$e(E)}catch{}else try{E.setAttribute(w,"")}catch{}},nr=function(w){let E=null,L=null;if(je)w="<remove></remove>"+w;else{const X=rs(w,/^[\r\n\t ]+/);L=X&&X[0]}zt==="application/xhtml+xml"&&xt===Ie&&(w='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+w+"</body></html>");const j=T?T.createHTML(w):w;if(xt===Ie)try{E=new h().parseFromString(j,zt)}catch{}if(!E||!E.documentElement){E=R.createDocument(xt,"template",null);try{E.documentElement.innerHTML=Ui?M:j}catch{}}const se=E.body||E.documentElement;return w&&L&&se.insertBefore(n.createTextNode(L),se.childNodes[0]||null),xt===Ie?me.call(E,z?"html":"body")[0]:z?E.documentElement:se},ir=function(w){return B.call(w.ownerDocument||w,w,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},zi=function(w){return w instanceof d&&(typeof w.nodeName!="string"||typeof w.textContent!="string"||typeof w.removeChild!="function"||!(w.attributes instanceof l)||typeof w.removeAttribute!="function"||typeof w.setAttribute!="function"||typeof w.namespaceURI!="string"||typeof w.insertBefore!="function"||typeof w.hasChildNodes!="function")},sr=function(w){return typeof a=="function"&&w instanceof a};function Re(I,w,E){Fn(I,L=>{L.call(t,w,E,$t)})}const or=function(w){let E=null;if(Re(Z.beforeSanitizeElements,w,null),zi(w))return $e(w),!0;const L=J(w.nodeName);if(Re(Z.uponSanitizeElement,w,{tagName:L,allowedTags:Q}),V&&w.hasChildNodes()&&!sr(w.firstElementChild)&&le(/<[/\w!]/g,w.innerHTML)&&le(/<[/\w!]/g,w.textContent)||w.nodeType===Yt.progressingInstruction||V&&w.nodeType===Yt.comment&&le(/<[/\w]/g,w.data))return $e(w),!0;if(!(ze.tagCheck instanceof Function&&ze.tagCheck(L))&&(!Q[L]||et[L])){if(!et[L]&&ar(L)&&(H.tagNameCheck instanceof RegExp&&le(H.tagNameCheck,L)||H.tagNameCheck instanceof Function&&H.tagNameCheck(L)))return!1;if(Oi&&!xe[L]){const j=C(w)||w.parentNode,se=A(w)||w.childNodes;if(se&&j){const X=se.length;for(let fe=X-1;fe>=0;--fe){const Ne=b(se[fe],!0);Ne.__removalCount=(w.__removalCount||0)+1,j.insertBefore(Ne,$(w))}}}return $e(w),!0}return w instanceof u&&!Ou(w)||(L==="noscript"||L==="noembed"||L==="noframes")&&le(/<\/no(script|embed|frames)/i,w.innerHTML)?($e(w),!0):(O&&w.nodeType===Yt.text&&(E=w.textContent,Fn([Ut,wt,Je],j=>{E=Vt(E,j," ")}),w.textContent!==E&&(qt(t.removed,{element:w.cloneNode()}),w.textContent=E)),Re(Z.afterSanitizeElements,w,null),!1)},rr=function(w,E,L){if(Go&&(E==="id"||E==="name")&&(L in n||L in Du))return!1;if(!(x&&!Wt[E]&&le(Ii,E))){if(!(An&&le(Ri,E))){if(!(ze.attributeCheck instanceof Function&&ze.attributeCheck(E,w))){if(!Y[E]||Wt[E]){if(!(ar(w)&&(H.tagNameCheck instanceof RegExp&&le(H.tagNameCheck,w)||H.tagNameCheck instanceof Function&&H.tagNameCheck(w))&&(H.attributeNameCheck instanceof RegExp&&le(H.attributeNameCheck,E)||H.attributeNameCheck instanceof Function&&H.attributeNameCheck(E,w))||E==="is"&&H.allowCustomizedBuiltInElements&&(H.tagNameCheck instanceof RegExp&&le(H.tagNameCheck,L)||H.tagNameCheck instanceof Function&&H.tagNameCheck(L))))return!1}else if(!Fi[E]){if(!le(Sn,Vt(L,kn,""))){if(!((E==="src"||E==="xlink:href"||E==="href")&&w!=="script"&&Pf(L,"data:")===0&&Yo[w])){if(!(_&&!le(Ni,Vt(L,kn,"")))){if(L)return!1}}}}}}}return!0},ar=function(w){return w!=="annotation-xml"&&rs(w,Di)},lr=function(w){Re(Z.beforeSanitizeAttributes,w,null);const{attributes:E}=w;if(!E||zi(w))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Y,forceKeepAttr:void 0};let j=E.length;for(;j--;){const se=E[j],{name:X,namespaceURI:fe,value:Ne}=se,At=J(X),ji=Ne;let ne=X==="value"?ji:Lf(ji);if(L.attrName=At,L.attrValue=ne,L.keepAttr=!0,L.forceKeepAttr=void 0,Re(Z.uponSanitizeAttribute,w,L),ne=L.attrValue,Qo&&(At==="id"||At==="name")&&(tt(X,w),ne=Pu+ne),V&&le(/((--!?|])>)|<\/(style|title|textarea)/i,ne)){tt(X,w);continue}if(At==="attributename"&&rs(ne,"href")){tt(X,w);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){tt(X,w);continue}if(!N&&le(/\/>/i,ne)){tt(X,w);continue}O&&Fn([Ut,wt,Je],ur=>{ne=Vt(ne,ur," ")});const cr=J(w.nodeName);if(!rr(cr,At,ne)){tt(X,w);continue}if(T&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!fe)switch(v.getAttributeType(cr,At)){case"TrustedHTML":{ne=T.createHTML(ne);break}case"TrustedScriptURL":{ne=T.createScriptURL(ne);break}}if(ne!==ji)try{fe?w.setAttributeNS(fe,X,ne):w.setAttribute(X,ne),zi(w)?$e(w):aa(t.removed)}catch{tt(X,w)}}Re(Z.afterSanitizeAttributes,w,null)},Bu=function I(w){let E=null;const L=ir(w);for(Re(Z.beforeSanitizeShadowDOM,w,null);E=L.nextNode();)Re(Z.uponSanitizeShadowNode,E,null),or(E),lr(E),E.content instanceof o&&I(E.content);Re(Z.afterSanitizeShadowDOM,w,null)};return t.sanitize=function(I){let w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,L=null,j=null,se=null;if(Ui=!I,Ui&&(I="<!-->"),typeof I!="string"&&!sr(I))if(typeof I.toString=="function"){if(I=I.toString(),typeof I!="string")throw Gt("dirty is not a string, aborting")}else throw Gt("toString is not a function");if(!t.isSupported)return I;if(ae||Ki(w),t.removed=[],typeof I=="string"&&(Kt=!1),Kt){if(I.nodeName){const Ne=J(I.nodeName);if(!Q[Ne]||et[Ne])throw Gt("root node is forbidden and cannot be sanitized in-place")}}else if(I instanceof a)E=nr("<!---->"),L=E.ownerDocument.importNode(I,!0),L.nodeType===Yt.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?E=L:E.appendChild(L);else{if(!kt&&!O&&!z&&I.indexOf("<")===-1)return T&&Cn?T.createHTML(I):I;if(E=nr(I),!E)return kt?null:Cn?M:""}E&&je&&$e(E.firstChild);const X=ir(Kt?I:E);for(;j=X.nextNode();)or(j),lr(j),j.content instanceof o&&Bu(j.content);if(Kt)return I;if(kt){if(En)for(se=ee.call(E.ownerDocument);E.firstChild;)se.appendChild(E.firstChild);else se=E;return(Y.shadowroot||Y.shadowrootmode)&&(se=Ke.call(i,se,!0)),se}let fe=z?E.outerHTML:E.innerHTML;return z&&Q["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&le($c,E.ownerDocument.doctype.name)&&(fe="<!DOCTYPE "+E.ownerDocument.doctype.name+`>
2057
- `+fe),O&&Fn([Ut,wt,Je],Ne=>{fe=Vt(fe,Ne," ")}),T&&Cn?T.createHTML(fe):fe},t.setConfig=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ki(I),ae=!0},t.clearConfig=function(){$t=null,ae=!1},t.isValidAttribute=function(I,w,E){$t||Ki({});const L=J(I),j=J(w);return rr(L,j,E)},t.addHook=function(I,w){typeof w=="function"&&qt(Z[I],w)},t.removeHook=function(I,w){if(w!==void 0){const E=_f(Z[I],w);return E===-1?void 0:Mf(Z[I],E,1)[0]}return aa(Z[I])},t.removeHooks=function(I){Z[I]=[]},t.removeAllHooks=function(){Z=ha()},t}var Us=Ac();function Mo(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var vt=Mo();function Ec(e){vt=e}var ln={exec:()=>null};function W(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(s,o)=>{let r=typeof o=="string"?o:o.source;return r=r.replace(ue.caret,"$1"),n=n.replace(s,r),i},getRegex:()=>new RegExp(n,t)};return i}var Vf=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ue={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")},Gf=/^(?:[ \t]*(?:\n|$))+/,Qf=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Yf=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,bn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Xf=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Po=/(?:[*+-]|\d{1,9}[.)])/,Cc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Tc=W(Cc).replace(/bull/g,Po).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(),Zf=W(Cc).replace(/bull/g,Po).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(),Lo=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Jf=/^[^\n]+/,Io=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,eg=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Io).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),tg=W(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Po).getRegex(),_i="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",Ro=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ng=W("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Ro).replace("tag",_i).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),_c=W(Lo).replace("hr",bn).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",_i).getRegex(),ig=W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",_c).getRegex(),No={blockquote:ig,code:Qf,def:eg,fences:Yf,heading:Xf,hr:bn,html:ng,lheading:Tc,list:tg,newline:Gf,paragraph:_c,table:ln,text:Jf},fa=W("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",bn).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",_i).getRegex(),sg={...No,lheading:Zf,table:fa,paragraph:W(Lo).replace("hr",bn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",fa).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",_i).getRegex()},og={...No,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ro).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:ln,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(Lo).replace("hr",bn).replace("heading",` *#{1,6} *[^
2058
- ]`).replace("lheading",Tc).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},rg=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ag=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Mc=/^( {2,}|\\)\n(?!\s*$)/,lg=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Mi=/[\p{P}\p{S}]/u,Do=/[\s\p{P}\p{S}]/u,Pc=/[^\s\p{P}\p{S}]/u,cg=W(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Do).getRegex(),Lc=/(?!~)[\p{P}\p{S}]/u,ug=/(?!~)[\s\p{P}\p{S}]/u,dg=/(?:[^\s\p{P}\p{S}]|~)/u,pg=W(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Vf?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ic=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,hg=W(Ic,"u").replace(/punct/g,Mi).getRegex(),fg=W(Ic,"u").replace(/punct/g,Lc).getRegex(),Rc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",gg=W(Rc,"gu").replace(/notPunctSpace/g,Pc).replace(/punctSpace/g,Do).replace(/punct/g,Mi).getRegex(),mg=W(Rc,"gu").replace(/notPunctSpace/g,dg).replace(/punctSpace/g,ug).replace(/punct/g,Lc).getRegex(),yg=W("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Pc).replace(/punctSpace/g,Do).replace(/punct/g,Mi).getRegex(),vg=W(/\\(punct)/,"gu").replace(/punct/g,Mi).getRegex(),bg=W(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),wg=W(Ro).replace("(?:-->|$)","-->").getRegex(),kg=W("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",wg).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),di=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Sg=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",di).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Nc=W(/^!?\[(label)\]\[(ref)\]/).replace("label",di).replace("ref",Io).getRegex(),Dc=W(/^!?\[(ref)\](?:\[\])?/).replace("ref",Io).getRegex(),xg=W("reflink|nolink(?!\\()","g").replace("reflink",Nc).replace("nolink",Dc).getRegex(),ga=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Oo={_backpedal:ln,anyPunctuation:vg,autolink:bg,blockSkip:pg,br:Mc,code:ag,del:ln,emStrongLDelim:hg,emStrongRDelimAst:gg,emStrongRDelimUnd:yg,escape:rg,link:Sg,nolink:Dc,punctuation:cg,reflink:Nc,reflinkSearch:xg,tag:kg,text:lg,url:ln},$g={...Oo,link:W(/^!?\[(label)\]\((.*?)\)/).replace("label",di).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",di).getRegex()},Ws={...Oo,emStrongRDelimAst:mg,emStrongLDelim:fg,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ga).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:W(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ga).getRegex()},Ag={...Ws,br:W(Mc).replace("{2,}","*").getRegex(),text:W(Ws.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Wn={normal:No,gfm:sg,pedantic:og},Xt={normal:Oo,gfm:Ws,breaks:Ag,pedantic:$g},Eg={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ma=e=>Eg[e];function Oe(e,t){if(t){if(ue.escapeTest.test(e))return e.replace(ue.escapeReplace,ma)}else if(ue.escapeTestNoEncode.test(e))return e.replace(ue.escapeReplaceNoEncode,ma);return e}function ya(e){try{e=encodeURI(e).replace(ue.percentDecode,"%")}catch{return null}return e}function va(e,t){var o;let n=e.replace(ue.findPipe,(r,a,u)=>{let c=!1,l=a;for(;--l>=0&&u[l]==="\\";)c=!c;return c?"|":" |"}),i=n.split(ue.splitPipe),s=0;if(i[0].trim()||i.shift(),i.length>0&&!((o=i.at(-1))!=null&&o.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(ue.slashPipe,"|");return i}function Zt(e,t,n){let i=e.length;if(i===0)return"";let s=0;for(;s<i&&e.charAt(i-s-1)===t;)s++;return e.slice(0,i-s)}function Cg(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}function ba(e,t,n,i,s){let o=t.href,r=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let u={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:r,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,u}function Tg(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
2065
+ `}const bc={CHILD:2},wc=e=>(...t)=>({_$litDirective$:e,values:t});let kc=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,i){this._$Ct=t,this._$AM=n,this._$Ci=i}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:Sf}=ld,sa=e=>e,oa=()=>document.createComment(""),Gt=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const r=i.insertBefore(oa(),s),a=i.insertBefore(oa(),s);n=new Sf(r,a,e,e.options)}else{const r=n._$AB.nextSibling,a=n._$AM,u=a!==e;if(u){let c;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==a._$AU&&n._$AP(c)}if(r!==s||u){let c=n._$AA;for(;c!==r;){const l=sa(c).nextSibling;sa(i).insertBefore(c,s),c=l}}}return n},st=(e,t,n=e)=>(e._$AI(t,n),e),xf={},$f=(e,t=xf)=>e._$AH=t,Af=e=>e._$AH,os=e=>{e._$AR(),e._$AA.remove()};const ra=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},Ef=wc(class extends kc{constructor(e){if(super(e),e.type!==bc.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let i;n===void 0?n=t:t!==void 0&&(i=t);const s=[],o=[];let r=0;for(const a of e)s[r]=i?i(a,r):r,o[r]=n(a,r),r++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=Af(e),{values:o,keys:r}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=r,o;const a=this.ut??(this.ut=[]),u=[];let c,l,d=0,h=s.length-1,v=0,f=o.length-1;for(;d<=h&&v<=f;)if(s[d]===null)d++;else if(s[h]===null)h--;else if(a[d]===r[v])u[v]=st(s[d],o[v]),d++,v++;else if(a[h]===r[f])u[f]=st(s[h],o[f]),h--,f--;else if(a[d]===r[f])u[f]=st(s[d],o[f]),Gt(e,u[f+1],s[d]),d++,f--;else if(a[h]===r[v])u[v]=st(s[h],o[v]),Gt(e,s[d],s[h]),h--,v++;else if(c===void 0&&(c=ra(r,v,f),l=ra(a,d,h)),c.has(a[d]))if(c.has(a[h])){const b=l.get(r[v]),S=b!==void 0?s[b]:null;if(S===null){const $=Gt(e,s[d]);st($,o[v]),u[v]=$}else u[v]=st(S,o[v]),Gt(e,s[d],S),s[b]=null;v++}else os(s[h]),h--;else os(s[d]),d++;for(;v<=f;){const b=Gt(e,u[f+1]);st(b,o[v]),u[v++]=b}for(;d<=h;){const b=s[d++];b!==null&&os(b)}return this.ut=r,$f(e,u),Qe}});class Os extends kc{constructor(t){if(super(t),this.it=k,t.type!==bc.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===Qe)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:[]}}}Os.directiveName="unsafeHTML",Os.resultType=1;const di=wc(Os);const{entries:Sc,setPrototypeOf:aa,isFrozen:Cf,getPrototypeOf:Tf,getOwnPropertyDescriptor:_f}=Object;let{freeze:pe,seal:ge,create:Bs}=Object,{apply:Fs,construct:Us}=typeof Reflect<"u"&&Reflect;pe||(pe=function(t){return t});ge||(ge=function(t){return t});Fs||(Fs=function(t,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),o=2;o<i;o++)s[o-2]=arguments[o];return t.apply(n,s)});Us||(Us=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return new t(...i)});const Un=he(Array.prototype.forEach),Mf=he(Array.prototype.lastIndexOf),la=he(Array.prototype.pop),Qt=he(Array.prototype.push),Pf=he(Array.prototype.splice),Xn=he(String.prototype.toLowerCase),rs=he(String.prototype.toString),as=he(String.prototype.match),Yt=he(String.prototype.replace),Lf=he(String.prototype.indexOf),If=he(String.prototype.trim),ye=he(Object.prototype.hasOwnProperty),le=he(RegExp.prototype.test),Xt=Rf(TypeError);function he(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return Fs(e,t,i)}}function Rf(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Us(e,n)}}function F(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Xn;aa&&aa(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(Cf(t)||(t[i]=o),s=o)}e[s]=!0}return e}function Nf(e){for(let t=0;t<e.length;t++)ye(e,t)||(e[t]=null);return e}function Ce(e){const t=Bs(null);for(const[n,i]of Sc(e))ye(e,n)&&(Array.isArray(i)?t[n]=Nf(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Ce(i):t[n]=i);return t}function Zt(e,t){for(;e!==null;){const i=_f(e,t);if(i){if(i.get)return he(i.get);if(typeof i.value=="function")return he(i.value)}e=Tf(e)}function n(){return null}return n}const ca=pe(["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"]),ls=pe(["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"]),cs=pe(["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"]),Df=pe(["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"]),us=pe(["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"]),Of=pe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ua=pe(["#text"]),da=pe(["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"]),ds=pe(["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"]),pa=pe(["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"]),Wn=pe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Bf=ge(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ff=ge(/<%[\w\W]*|[\w\W]*%>/gm),Uf=ge(/\$\{[\w\W]*/gm),Wf=ge(/^data-[\-\w.\u00B7-\uFFFF]+$/),Kf=ge(/^aria-[\-\w]+$/),xc=ge(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),zf=ge(/^(?:\w+script|data):/i),jf=ge(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$c=ge(/^html$/i),Hf=ge(/^[a-z][.\w]*(-[.\w]+)+$/i);var ha=Object.freeze({__proto__:null,ARIA_ATTR:Kf,ATTR_WHITESPACE:jf,CUSTOM_ELEMENT:Hf,DATA_ATTR:Wf,DOCTYPE_NAME:$c,ERB_EXPR:Ff,IS_ALLOWED_URI:xc,IS_SCRIPT_OR_DATA:zf,MUSTACHE_EXPR:Bf,TMPLIT_EXPR:Uf});const Jt={element:1,text:3,progressingInstruction:7,comment:8,document:9},qf=function(){return typeof window>"u"?null:window},Vf=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(i=n.getAttribute(s));const o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},fa=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ac(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qf();const t=I=>Ac(I);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==Jt.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:r,Node:a,Element:u,NodeFilter:c,NamedNodeMap:l=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:h,trustedTypes:v}=e,f=u.prototype,b=Zt(f,"cloneNode"),S=Zt(f,"remove"),$=Zt(f,"nextSibling"),A=Zt(f,"childNodes"),C=Zt(f,"parentNode");if(typeof r=="function"){const I=n.createElement("template");I.content&&I.content.ownerDocument&&(n=I.content.ownerDocument)}let T,M="";const{implementation:R,createNodeIterator:B,createDocumentFragment:ee,getElementsByTagName:me}=n,{importNode:Ke}=i;let Z=fa();t.isSupported=typeof Sc=="function"&&typeof C=="function"&&R&&R.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:zt,ERB_EXPR:kt,TMPLIT_EXPR:Je,DATA_ATTR:Ri,ARIA_ATTR:Ni,IS_SCRIPT_OR_DATA:Di,ATTR_WHITESPACE:Sn,CUSTOM_ELEMENT:Oi}=ha;let{IS_ALLOWED_URI:xn}=ha,Q=null;const $n=F({},[...ca,...ls,...cs,...us,...ua]);let Y=null;const An=F({},[...da,...ds,...pa,...Wn]);let H=Object.seal(Bs(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}})),et=null,jt=null;const ze=Object.seal(Bs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let En=!0,x=!0,_=!1,N=!0,O=!1,V=!0,z=!1,ae=!1,je=!1,St=!1,Cn=!1,Tn=!1,Qo=!0,Yo=!1;const Pu="user-content-";let Bi=!0,Ht=!1,xt={},xe=null;const Fi=F({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Xo=null;const Zo=F({},["audio","video","img","source","image","track"]);let Ui=null;const Jo=F({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),_n="http://www.w3.org/1998/Math/MathML",Mn="http://www.w3.org/2000/svg",Re="http://www.w3.org/1999/xhtml";let $t=Re,Wi=!1,Ki=null;const Lu=F({},[_n,Mn,Re],rs);let Pn=F({},["mi","mo","mn","ms","mtext"]),Ln=F({},["annotation-xml"]);const Iu=F({},["title","style","font","a","script"]);let qt=null;const Ru=["application/xhtml+xml","text/html"],Nu="text/html";let J=null,At=null;const Du=n.createElement("form"),er=function(w){return w instanceof RegExp||w instanceof Function},zi=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(At&&At===w)){if((!w||typeof w!="object")&&(w={}),w=Ce(w),qt=Ru.indexOf(w.PARSER_MEDIA_TYPE)===-1?Nu:w.PARSER_MEDIA_TYPE,J=qt==="application/xhtml+xml"?rs:Xn,Q=ye(w,"ALLOWED_TAGS")?F({},w.ALLOWED_TAGS,J):$n,Y=ye(w,"ALLOWED_ATTR")?F({},w.ALLOWED_ATTR,J):An,Ki=ye(w,"ALLOWED_NAMESPACES")?F({},w.ALLOWED_NAMESPACES,rs):Lu,Ui=ye(w,"ADD_URI_SAFE_ATTR")?F(Ce(Jo),w.ADD_URI_SAFE_ATTR,J):Jo,Xo=ye(w,"ADD_DATA_URI_TAGS")?F(Ce(Zo),w.ADD_DATA_URI_TAGS,J):Zo,xe=ye(w,"FORBID_CONTENTS")?F({},w.FORBID_CONTENTS,J):Fi,et=ye(w,"FORBID_TAGS")?F({},w.FORBID_TAGS,J):Ce({}),jt=ye(w,"FORBID_ATTR")?F({},w.FORBID_ATTR,J):Ce({}),xt=ye(w,"USE_PROFILES")?w.USE_PROFILES:!1,En=w.ALLOW_ARIA_ATTR!==!1,x=w.ALLOW_DATA_ATTR!==!1,_=w.ALLOW_UNKNOWN_PROTOCOLS||!1,N=w.ALLOW_SELF_CLOSE_IN_ATTR!==!1,O=w.SAFE_FOR_TEMPLATES||!1,V=w.SAFE_FOR_XML!==!1,z=w.WHOLE_DOCUMENT||!1,St=w.RETURN_DOM||!1,Cn=w.RETURN_DOM_FRAGMENT||!1,Tn=w.RETURN_TRUSTED_TYPE||!1,je=w.FORCE_BODY||!1,Qo=w.SANITIZE_DOM!==!1,Yo=w.SANITIZE_NAMED_PROPS||!1,Bi=w.KEEP_CONTENT!==!1,Ht=w.IN_PLACE||!1,xn=w.ALLOWED_URI_REGEXP||xc,$t=w.NAMESPACE||Re,Pn=w.MATHML_TEXT_INTEGRATION_POINTS||Pn,Ln=w.HTML_INTEGRATION_POINTS||Ln,H=w.CUSTOM_ELEMENT_HANDLING||{},w.CUSTOM_ELEMENT_HANDLING&&er(w.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(H.tagNameCheck=w.CUSTOM_ELEMENT_HANDLING.tagNameCheck),w.CUSTOM_ELEMENT_HANDLING&&er(w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(H.attributeNameCheck=w.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),w.CUSTOM_ELEMENT_HANDLING&&typeof w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(H.allowCustomizedBuiltInElements=w.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),O&&(x=!1),Cn&&(St=!0),xt&&(Q=F({},ua),Y=[],xt.html===!0&&(F(Q,ca),F(Y,da)),xt.svg===!0&&(F(Q,ls),F(Y,ds),F(Y,Wn)),xt.svgFilters===!0&&(F(Q,cs),F(Y,ds),F(Y,Wn)),xt.mathMl===!0&&(F(Q,us),F(Y,pa),F(Y,Wn))),w.ADD_TAGS&&(typeof w.ADD_TAGS=="function"?ze.tagCheck=w.ADD_TAGS:(Q===$n&&(Q=Ce(Q)),F(Q,w.ADD_TAGS,J))),w.ADD_ATTR&&(typeof w.ADD_ATTR=="function"?ze.attributeCheck=w.ADD_ATTR:(Y===An&&(Y=Ce(Y)),F(Y,w.ADD_ATTR,J))),w.ADD_URI_SAFE_ATTR&&F(Ui,w.ADD_URI_SAFE_ATTR,J),w.FORBID_CONTENTS&&(xe===Fi&&(xe=Ce(xe)),F(xe,w.FORBID_CONTENTS,J)),w.ADD_FORBID_CONTENTS&&(xe===Fi&&(xe=Ce(xe)),F(xe,w.ADD_FORBID_CONTENTS,J)),Bi&&(Q["#text"]=!0),z&&F(Q,["html","head","body"]),Q.table&&(F(Q,["tbody"]),delete et.tbody),w.TRUSTED_TYPES_POLICY){if(typeof w.TRUSTED_TYPES_POLICY.createHTML!="function")throw Xt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof w.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Xt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');T=w.TRUSTED_TYPES_POLICY,M=T.createHTML("")}else T===void 0&&(T=Vf(v,s)),T!==null&&typeof M=="string"&&(M=T.createHTML(""));pe&&pe(w),At=w}},tr=F({},[...ls,...cs,...Df]),nr=F({},[...us,...Of]),Ou=function(w){let E=C(w);(!E||!E.tagName)&&(E={namespaceURI:$t,tagName:"template"});const L=Xn(w.tagName),j=Xn(E.tagName);return Ki[w.namespaceURI]?w.namespaceURI===Mn?E.namespaceURI===Re?L==="svg":E.namespaceURI===_n?L==="svg"&&(j==="annotation-xml"||Pn[j]):!!tr[L]:w.namespaceURI===_n?E.namespaceURI===Re?L==="math":E.namespaceURI===Mn?L==="math"&&Ln[j]:!!nr[L]:w.namespaceURI===Re?E.namespaceURI===Mn&&!Ln[j]||E.namespaceURI===_n&&!Pn[j]?!1:!nr[L]&&(Iu[L]||!tr[L]):!!(qt==="application/xhtml+xml"&&Ki[w.namespaceURI]):!1},$e=function(w){Qt(t.removed,{element:w});try{C(w).removeChild(w)}catch{S(w)}},tt=function(w,E){try{Qt(t.removed,{attribute:E.getAttributeNode(w),from:E})}catch{Qt(t.removed,{attribute:null,from:E})}if(E.removeAttribute(w),w==="is")if(St||Cn)try{$e(E)}catch{}else try{E.setAttribute(w,"")}catch{}},ir=function(w){let E=null,L=null;if(je)w="<remove></remove>"+w;else{const X=as(w,/^[\r\n\t ]+/);L=X&&X[0]}qt==="application/xhtml+xml"&&$t===Re&&(w='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+w+"</body></html>");const j=T?T.createHTML(w):w;if($t===Re)try{E=new h().parseFromString(j,qt)}catch{}if(!E||!E.documentElement){E=R.createDocument($t,"template",null);try{E.documentElement.innerHTML=Wi?M:j}catch{}}const se=E.body||E.documentElement;return w&&L&&se.insertBefore(n.createTextNode(L),se.childNodes[0]||null),$t===Re?me.call(E,z?"html":"body")[0]:z?E.documentElement:se},sr=function(w){return B.call(w.ownerDocument||w,w,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ji=function(w){return w instanceof d&&(typeof w.nodeName!="string"||typeof w.textContent!="string"||typeof w.removeChild!="function"||!(w.attributes instanceof l)||typeof w.removeAttribute!="function"||typeof w.setAttribute!="function"||typeof w.namespaceURI!="string"||typeof w.insertBefore!="function"||typeof w.hasChildNodes!="function")},or=function(w){return typeof a=="function"&&w instanceof a};function Ne(I,w,E){Un(I,L=>{L.call(t,w,E,At)})}const rr=function(w){let E=null;if(Ne(Z.beforeSanitizeElements,w,null),ji(w))return $e(w),!0;const L=J(w.nodeName);if(Ne(Z.uponSanitizeElement,w,{tagName:L,allowedTags:Q}),V&&w.hasChildNodes()&&!or(w.firstElementChild)&&le(/<[/\w!]/g,w.innerHTML)&&le(/<[/\w!]/g,w.textContent)||w.nodeType===Jt.progressingInstruction||V&&w.nodeType===Jt.comment&&le(/<[/\w]/g,w.data))return $e(w),!0;if(!(ze.tagCheck instanceof Function&&ze.tagCheck(L))&&(!Q[L]||et[L])){if(!et[L]&&lr(L)&&(H.tagNameCheck instanceof RegExp&&le(H.tagNameCheck,L)||H.tagNameCheck instanceof Function&&H.tagNameCheck(L)))return!1;if(Bi&&!xe[L]){const j=C(w)||w.parentNode,se=A(w)||w.childNodes;if(se&&j){const X=se.length;for(let fe=X-1;fe>=0;--fe){const De=b(se[fe],!0);De.__removalCount=(w.__removalCount||0)+1,j.insertBefore(De,$(w))}}}return $e(w),!0}return w instanceof u&&!Ou(w)||(L==="noscript"||L==="noembed"||L==="noframes")&&le(/<\/no(script|embed|frames)/i,w.innerHTML)?($e(w),!0):(O&&w.nodeType===Jt.text&&(E=w.textContent,Un([zt,kt,Je],j=>{E=Yt(E,j," ")}),w.textContent!==E&&(Qt(t.removed,{element:w.cloneNode()}),w.textContent=E)),Ne(Z.afterSanitizeElements,w,null),!1)},ar=function(w,E,L){if(Qo&&(E==="id"||E==="name")&&(L in n||L in Du))return!1;if(!(x&&!jt[E]&&le(Ri,E))){if(!(En&&le(Ni,E))){if(!(ze.attributeCheck instanceof Function&&ze.attributeCheck(E,w))){if(!Y[E]||jt[E]){if(!(lr(w)&&(H.tagNameCheck instanceof RegExp&&le(H.tagNameCheck,w)||H.tagNameCheck instanceof Function&&H.tagNameCheck(w))&&(H.attributeNameCheck instanceof RegExp&&le(H.attributeNameCheck,E)||H.attributeNameCheck instanceof Function&&H.attributeNameCheck(E,w))||E==="is"&&H.allowCustomizedBuiltInElements&&(H.tagNameCheck instanceof RegExp&&le(H.tagNameCheck,L)||H.tagNameCheck instanceof Function&&H.tagNameCheck(L))))return!1}else if(!Ui[E]){if(!le(xn,Yt(L,Sn,""))){if(!((E==="src"||E==="xlink:href"||E==="href")&&w!=="script"&&Lf(L,"data:")===0&&Xo[w])){if(!(_&&!le(Di,Yt(L,Sn,"")))){if(L)return!1}}}}}}}return!0},lr=function(w){return w!=="annotation-xml"&&as(w,Oi)},cr=function(w){Ne(Z.beforeSanitizeAttributes,w,null);const{attributes:E}=w;if(!E||ji(w))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Y,forceKeepAttr:void 0};let j=E.length;for(;j--;){const se=E[j],{name:X,namespaceURI:fe,value:De}=se,Et=J(X),Hi=De;let ne=X==="value"?Hi:If(Hi);if(L.attrName=Et,L.attrValue=ne,L.keepAttr=!0,L.forceKeepAttr=void 0,Ne(Z.uponSanitizeAttribute,w,L),ne=L.attrValue,Yo&&(Et==="id"||Et==="name")&&(tt(X,w),ne=Pu+ne),V&&le(/((--!?|])>)|<\/(style|title|textarea)/i,ne)){tt(X,w);continue}if(Et==="attributename"&&as(ne,"href")){tt(X,w);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){tt(X,w);continue}if(!N&&le(/\/>/i,ne)){tt(X,w);continue}O&&Un([zt,kt,Je],dr=>{ne=Yt(ne,dr," ")});const ur=J(w.nodeName);if(!ar(ur,Et,ne)){tt(X,w);continue}if(T&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!fe)switch(v.getAttributeType(ur,Et)){case"TrustedHTML":{ne=T.createHTML(ne);break}case"TrustedScriptURL":{ne=T.createScriptURL(ne);break}}if(ne!==Hi)try{fe?w.setAttributeNS(fe,X,ne):w.setAttribute(X,ne),ji(w)?$e(w):la(t.removed)}catch{tt(X,w)}}Ne(Z.afterSanitizeAttributes,w,null)},Bu=function I(w){let E=null;const L=sr(w);for(Ne(Z.beforeSanitizeShadowDOM,w,null);E=L.nextNode();)Ne(Z.uponSanitizeShadowNode,E,null),rr(E),cr(E),E.content instanceof o&&I(E.content);Ne(Z.afterSanitizeShadowDOM,w,null)};return t.sanitize=function(I){let w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,L=null,j=null,se=null;if(Wi=!I,Wi&&(I="<!-->"),typeof I!="string"&&!or(I))if(typeof I.toString=="function"){if(I=I.toString(),typeof I!="string")throw Xt("dirty is not a string, aborting")}else throw Xt("toString is not a function");if(!t.isSupported)return I;if(ae||zi(w),t.removed=[],typeof I=="string"&&(Ht=!1),Ht){if(I.nodeName){const De=J(I.nodeName);if(!Q[De]||et[De])throw Xt("root node is forbidden and cannot be sanitized in-place")}}else if(I instanceof a)E=ir("<!---->"),L=E.ownerDocument.importNode(I,!0),L.nodeType===Jt.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?E=L:E.appendChild(L);else{if(!St&&!O&&!z&&I.indexOf("<")===-1)return T&&Tn?T.createHTML(I):I;if(E=ir(I),!E)return St?null:Tn?M:""}E&&je&&$e(E.firstChild);const X=sr(Ht?I:E);for(;j=X.nextNode();)rr(j),cr(j),j.content instanceof o&&Bu(j.content);if(Ht)return I;if(St){if(Cn)for(se=ee.call(E.ownerDocument);E.firstChild;)se.appendChild(E.firstChild);else se=E;return(Y.shadowroot||Y.shadowrootmode)&&(se=Ke.call(i,se,!0)),se}let fe=z?E.outerHTML:E.innerHTML;return z&&Q["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&le($c,E.ownerDocument.doctype.name)&&(fe="<!DOCTYPE "+E.ownerDocument.doctype.name+`>
2066
+ `+fe),O&&Un([zt,kt,Je],De=>{fe=Yt(fe,De," ")}),T&&Tn?T.createHTML(fe):fe},t.setConfig=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};zi(I),ae=!0},t.clearConfig=function(){At=null,ae=!1},t.isValidAttribute=function(I,w,E){At||zi({});const L=J(I),j=J(w);return ar(L,j,E)},t.addHook=function(I,w){typeof w=="function"&&Qt(Z[I],w)},t.removeHook=function(I,w){if(w!==void 0){const E=Mf(Z[I],w);return E===-1?void 0:Pf(Z[I],E,1)[0]}return la(Z[I])},t.removeHooks=function(I){Z[I]=[]},t.removeAllHooks=function(){Z=fa()},t}var Ws=Ac();function Po(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var bt=Po();function Ec(e){bt=e}var dn={exec:()=>null};function W(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(s,o)=>{let r=typeof o=="string"?o:o.source;return r=r.replace(ue.caret,"$1"),n=n.replace(s,r),i},getRegex:()=>new RegExp(n,t)};return i}var Gf=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ue={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")},Qf=/^(?:[ \t]*(?:\n|$))+/,Yf=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Xf=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,wn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Zf=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Lo=/(?:[*+-]|\d{1,9}[.)])/,Cc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Tc=W(Cc).replace(/bull/g,Lo).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(),Jf=W(Cc).replace(/bull/g,Lo).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(),Io=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,eg=/^[^\n]+/,Ro=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,tg=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ro).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ng=W(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Lo).getRegex(),Mi="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",No=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ig=W("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",No).replace("tag",Mi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),_c=W(Io).replace("hr",wn).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",Mi).getRegex(),sg=W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",_c).getRegex(),Do={blockquote:sg,code:Yf,def:tg,fences:Xf,heading:Zf,hr:wn,html:ig,lheading:Tc,list:ng,newline:Qf,paragraph:_c,table:dn,text:eg},ga=W("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",wn).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",Mi).getRegex(),og={...Do,lheading:Jf,table:ga,paragraph:W(Io).replace("hr",wn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ga).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",Mi).getRegex()},rg={...Do,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",No).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:dn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(Io).replace("hr",wn).replace("heading",` *#{1,6} *[^
2067
+ ]`).replace("lheading",Tc).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ag=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,lg=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Mc=/^( {2,}|\\)\n(?!\s*$)/,cg=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Pi=/[\p{P}\p{S}]/u,Oo=/[\s\p{P}\p{S}]/u,Pc=/[^\s\p{P}\p{S}]/u,ug=W(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Oo).getRegex(),Lc=/(?!~)[\p{P}\p{S}]/u,dg=/(?!~)[\s\p{P}\p{S}]/u,pg=/(?:[^\s\p{P}\p{S}]|~)/u,hg=W(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Gf?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ic=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,fg=W(Ic,"u").replace(/punct/g,Pi).getRegex(),gg=W(Ic,"u").replace(/punct/g,Lc).getRegex(),Rc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",mg=W(Rc,"gu").replace(/notPunctSpace/g,Pc).replace(/punctSpace/g,Oo).replace(/punct/g,Pi).getRegex(),yg=W(Rc,"gu").replace(/notPunctSpace/g,pg).replace(/punctSpace/g,dg).replace(/punct/g,Lc).getRegex(),vg=W("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Pc).replace(/punctSpace/g,Oo).replace(/punct/g,Pi).getRegex(),bg=W(/\\(punct)/,"gu").replace(/punct/g,Pi).getRegex(),wg=W(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),kg=W(No).replace("(?:-->|$)","-->").getRegex(),Sg=W("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",kg).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),pi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,xg=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",pi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Nc=W(/^!?\[(label)\]\[(ref)\]/).replace("label",pi).replace("ref",Ro).getRegex(),Dc=W(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ro).getRegex(),$g=W("reflink|nolink(?!\\()","g").replace("reflink",Nc).replace("nolink",Dc).getRegex(),ma=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Bo={_backpedal:dn,anyPunctuation:bg,autolink:wg,blockSkip:hg,br:Mc,code:lg,del:dn,emStrongLDelim:fg,emStrongRDelimAst:mg,emStrongRDelimUnd:vg,escape:ag,link:xg,nolink:Dc,punctuation:ug,reflink:Nc,reflinkSearch:$g,tag:Sg,text:cg,url:dn},Ag={...Bo,link:W(/^!?\[(label)\]\((.*?)\)/).replace("label",pi).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pi).getRegex()},Ks={...Bo,emStrongRDelimAst:yg,emStrongLDelim:gg,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ma).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:W(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ma).getRegex()},Eg={...Ks,br:W(Mc).replace("{2,}","*").getRegex(),text:W(Ks.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Kn={normal:Do,gfm:og,pedantic:rg},en={normal:Bo,gfm:Ks,breaks:Eg,pedantic:Ag},Cg={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ya=e=>Cg[e];function Be(e,t){if(t){if(ue.escapeTest.test(e))return e.replace(ue.escapeReplace,ya)}else if(ue.escapeTestNoEncode.test(e))return e.replace(ue.escapeReplaceNoEncode,ya);return e}function va(e){try{e=encodeURI(e).replace(ue.percentDecode,"%")}catch{return null}return e}function ba(e,t){var o;let n=e.replace(ue.findPipe,(r,a,u)=>{let c=!1,l=a;for(;--l>=0&&u[l]==="\\";)c=!c;return c?"|":" |"}),i=n.split(ue.splitPipe),s=0;if(i[0].trim()||i.shift(),i.length>0&&!((o=i.at(-1))!=null&&o.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(ue.slashPipe,"|");return i}function tn(e,t,n){let i=e.length;if(i===0)return"";let s=0;for(;s<i&&e.charAt(i-s-1)===t;)s++;return e.slice(0,i-s)}function Tg(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}function wa(e,t,n,i,s){let o=t.href,r=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let u={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:r,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,u}function _g(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
2059
2068
  `).map(o=>{let r=o.match(n.other.beginningSpace);if(r===null)return o;let[a]=r;return a.length>=s.length?o.slice(s.length):o}).join(`
2060
- `)}var pi=class{constructor(e){U(this,"options");U(this,"rules");U(this,"lexer");this.options=e||vt}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:Zt(n,`
2061
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=Tg(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let i=Zt(n,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(n=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Zt(t[0],`
2062
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Zt(t[0],`
2069
+ `)}var hi=class{constructor(e){U(this,"options");U(this,"rules");U(this,"lexer");this.options=e||bt}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:tn(n,`
2070
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=_g(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let i=tn(n,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(n=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:tn(t[0],`
2071
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=tn(t[0],`
2063
2072
  `).split(`
2064
2073
  `),i="",s="",o=[];for(;n.length>0;){let r=!1,a=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))a.push(n[u]),r=!0;else if(!r)a.push(n[u]);else break;n=n.slice(u);let c=a.join(`
2065
2074
  `),l=c.replace(this.rules.other.blockquoteSetextReplace,`
@@ -2077,9 +2086,9 @@ ${l}`:l;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
2077
2086
  `,1)[0],B;if(f=R,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),B=f):B=f.replace(this.rules.other.tabCharGlobal," "),C.test(f)||T.test(f)||M.test(f)||$.test(f)||A.test(f))break;if(B.search(this.rules.other.nonSpaceChar)>=S||!f.trim())h+=`
2078
2087
  `+B.slice(S);else{if(b||v.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||C.test(v)||T.test(v)||A.test(v))break;h+=`
2079
2088
  `+f}!b&&!f.trim()&&(b=!0),d+=R+`
2080
- `,e=e.substring(R.length+1),v=B.slice(S)}}r.loose||(u?r.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(u=!0)),r.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),r.raw+=d}let c=r.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let l of r.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),((n=l.tokens[0])==null?void 0:n.type)==="text"||((i=l.tokens[0])==null?void 0:i.type)==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}}let d=this.rules.other.listTaskCheckbox.exec(l.raw);if(d){let h={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};l.checked=h.checked,r.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=h.raw+l.tokens[0].raw,l.tokens[0].text=h.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(h)):l.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):l.tokens.unshift(h)}}if(!r.loose){let d=l.tokens.filter(v=>v.type==="space"),h=d.length>0&&d.some(v=>this.rules.other.anyLine.test(v.raw));r.loose=h}}if(r.loose)for(let l of r.items){l.loose=!0;for(let d of l.tokens)d.type==="text"&&(d.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:i,title:s}}}table(e){var r;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=va(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(r=t[3])!=null&&r.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
2081
- `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let a of i)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of s)o.rows.push(va(a,o.header.length).map((u,c)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:o.align[c]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
2082
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=Zt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Cg(t[2],"()");if(o===-2)return;if(o>-1){let r=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,r).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(i);o&&(i=o[1],s=o[3])}else s=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?i=i.slice(1):i=i.slice(1,-1)),ba(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let i=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=t[i.toLowerCase()];if(!s){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return ba(n,s,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!n||this.rules.inline.punctuation.exec(n))){let s=[...i[0]].length-1,o,r,a=s,u=0,c=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+s);(i=c.exec(t))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(r=[...o].length,i[3]||i[4]){a+=r;continue}else if((i[5]||i[6])&&s%3&&!((s+r)%3)){u+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a+u);let l=[...i[0]][0].length,d=e.slice(0,s+i.index+l+r);if(Math.min(s,r)%2){let v=d.slice(1,-1);return{type:"em",raw:d,text:v,tokens:this.lexer.inlineTokens(v)}}let h=d.slice(2,-2);return{type:"strong",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return i&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,i;return t[2]==="@"?(n=t[1],i="mailto:"+n):(n=t[1],i=n),{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let i,s;if(t[2]==="@")i=t[0],s="mailto:"+i;else{let o;do o=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(o!==t[0]);i=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},ve=class Ks{constructor(t){U(this,"tokens");U(this,"options");U(this,"state");U(this,"inlineQueue");U(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||vt,this.options.tokenizer=this.options.tokenizer||new pi,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:ue,block:Wn.normal,inline:Xt.normal};this.options.pedantic?(n.block=Wn.pedantic,n.inline=Xt.pedantic):this.options.gfm&&(n.block=Wn.gfm,this.options.breaks?n.inline=Xt.breaks:n.inline=Xt.gfm),this.tokenizer.rules=n}static get rules(){return{block:Wn,inline:Xt}}static lex(t,n){return new Ks(n).lex(t)}static lexInline(t,n){return new Ks(n).inlineTokens(t)}lex(t){t=t.replace(ue.carriageReturn,`
2089
+ `,e=e.substring(R.length+1),v=B.slice(S)}}r.loose||(u?r.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(u=!0)),r.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),r.raw+=d}let c=r.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let l of r.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),((n=l.tokens[0])==null?void 0:n.type)==="text"||((i=l.tokens[0])==null?void 0:i.type)==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}}let d=this.rules.other.listTaskCheckbox.exec(l.raw);if(d){let h={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};l.checked=h.checked,r.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=h.raw+l.tokens[0].raw,l.tokens[0].text=h.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(h)):l.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):l.tokens.unshift(h)}}if(!r.loose){let d=l.tokens.filter(v=>v.type==="space"),h=d.length>0&&d.some(v=>this.rules.other.anyLine.test(v.raw));r.loose=h}}if(r.loose)for(let l of r.items){l.loose=!0;for(let d of l.tokens)d.type==="text"&&(d.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:i,title:s}}}table(e){var r;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=ba(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(r=t[3])!=null&&r.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
2090
+ `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let a of i)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of s)o.rows.push(ba(a,o.header.length).map((u,c)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:o.align[c]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
2091
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=tn(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Tg(t[2],"()");if(o===-2)return;if(o>-1){let r=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,r).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(i);o&&(i=o[1],s=o[3])}else s=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?i=i.slice(1):i=i.slice(1,-1)),wa(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let i=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=t[i.toLowerCase()];if(!s){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return wa(n,s,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!n||this.rules.inline.punctuation.exec(n))){let s=[...i[0]].length-1,o,r,a=s,u=0,c=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+s);(i=c.exec(t))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(r=[...o].length,i[3]||i[4]){a+=r;continue}else if((i[5]||i[6])&&s%3&&!((s+r)%3)){u+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a+u);let l=[...i[0]][0].length,d=e.slice(0,s+i.index+l+r);if(Math.min(s,r)%2){let v=d.slice(1,-1);return{type:"em",raw:d,text:v,tokens:this.lexer.inlineTokens(v)}}let h=d.slice(2,-2);return{type:"strong",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return i&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,i;return t[2]==="@"?(n=t[1],i="mailto:"+n):(n=t[1],i=n),{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let i,s;if(t[2]==="@")i=t[0],s="mailto:"+i;else{let o;do o=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(o!==t[0]);i=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},ve=class zs{constructor(t){U(this,"tokens");U(this,"options");U(this,"state");U(this,"inlineQueue");U(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||bt,this.options.tokenizer=this.options.tokenizer||new hi,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:ue,block:Kn.normal,inline:en.normal};this.options.pedantic?(n.block=Kn.pedantic,n.inline=en.pedantic):this.options.gfm&&(n.block=Kn.gfm,this.options.breaks?n.inline=en.breaks:n.inline=en.gfm),this.tokenizer.rules=n}static get rules(){return{block:Kn,inline:en}}static lex(t,n){return new zs(n).lex(t)}static lexInline(t,n){return new zs(n).inlineTokens(t)}lex(t){t=t.replace(ue.carriageReturn,`
2083
2092
  `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let i=this.inlineQueue[n];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],i=!1){var s,o,r;for(this.options.pedantic&&(t=t.replace(ue.tabCharGlobal," ").replace(ue.spaceLine,""));t;){let a;if((o=(s=this.options.extensions)==null?void 0:s.block)!=null&&o.some(c=>(a=c.call({lexer:this},t,n))?(t=t.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(t)){t=t.substring(a.raw.length);let c=n.at(-1);a.raw.length===1&&c!==void 0?c.raw+=`
2084
2093
  `: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(`
2085
2094
  `)?"":`
@@ -2093,9 +2102,9 @@ ${l}`:l;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
2093
2102
  `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a),i=u.length!==t.length,t=t.substring(a.raw.length);continue}if(a=this.tokenizer.text(t)){t=t.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
2094
2103
  `)?"":`
2095
2104
  `)+a.raw,c.text+=`
2096
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var u,c,l,d,h;let i=t,s=null;if(this.tokens.links){let v=Object.keys(this.tokens.links);if(v.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)v.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,s.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)o=s[2]?s[2].length:0,i=i.slice(0,s.index+o)+"["+"a".repeat(s[0].length-o-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=((c=(u=this.options.hooks)==null?void 0:u.emStrongMask)==null?void 0:c.call({lexer:this},i))??i;let r=!1,a="";for(;t;){r||(a=""),r=!1;let v;if((d=(l=this.options.extensions)==null?void 0:l.inline)!=null&&d.some(b=>(v=b.call({lexer:this},t,n))?(t=t.substring(v.raw.length),n.push(v),!0):!1))continue;if(v=this.tokenizer.escape(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.tag(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.link(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(v.raw.length);let b=n.at(-1);v.type==="text"&&(b==null?void 0:b.type)==="text"?(b.raw+=v.raw,b.text+=v.text):n.push(v);continue}if(v=this.tokenizer.emStrong(t,i,a)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.codespan(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.br(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.del(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.autolink(t)){t=t.substring(v.raw.length),n.push(v);continue}if(!this.state.inLink&&(v=this.tokenizer.url(t))){t=t.substring(v.raw.length),n.push(v);continue}let f=t;if((h=this.options.extensions)!=null&&h.startInline){let b=1/0,S=t.slice(1),$;this.options.extensions.startInline.forEach(A=>{$=A.call({lexer:this},S),typeof $=="number"&&$>=0&&(b=Math.min(b,$))}),b<1/0&&b>=0&&(f=t.substring(0,b+1))}if(v=this.tokenizer.inlineText(f)){t=t.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(a=v.raw.slice(-1)),r=!0;let b=n.at(-1);(b==null?void 0:b.type)==="text"?(b.raw+=v.raw,b.text+=v.text):n.push(v);continue}if(t){let b="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(b);break}else throw new Error(b)}}return n}},hi=class{constructor(e){U(this,"options");U(this,"parser");this.options=e||vt}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let i=(o=(t||"").match(ue.notSpaceStart))==null?void 0:o[0],s=e.replace(ue.endingNewline,"")+`
2097
- `;return i?'<pre><code class="language-'+Oe(i)+'">'+(n?s:Oe(s,!0))+`</code></pre>
2098
- `:"<pre><code>"+(n?s:Oe(s,!0))+`</code></pre>
2105
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var u,c,l,d,h;let i=t,s=null;if(this.tokens.links){let v=Object.keys(this.tokens.links);if(v.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)v.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,s.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)o=s[2]?s[2].length:0,i=i.slice(0,s.index+o)+"["+"a".repeat(s[0].length-o-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=((c=(u=this.options.hooks)==null?void 0:u.emStrongMask)==null?void 0:c.call({lexer:this},i))??i;let r=!1,a="";for(;t;){r||(a=""),r=!1;let v;if((d=(l=this.options.extensions)==null?void 0:l.inline)!=null&&d.some(b=>(v=b.call({lexer:this},t,n))?(t=t.substring(v.raw.length),n.push(v),!0):!1))continue;if(v=this.tokenizer.escape(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.tag(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.link(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(v.raw.length);let b=n.at(-1);v.type==="text"&&(b==null?void 0:b.type)==="text"?(b.raw+=v.raw,b.text+=v.text):n.push(v);continue}if(v=this.tokenizer.emStrong(t,i,a)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.codespan(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.br(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.del(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.autolink(t)){t=t.substring(v.raw.length),n.push(v);continue}if(!this.state.inLink&&(v=this.tokenizer.url(t))){t=t.substring(v.raw.length),n.push(v);continue}let f=t;if((h=this.options.extensions)!=null&&h.startInline){let b=1/0,S=t.slice(1),$;this.options.extensions.startInline.forEach(A=>{$=A.call({lexer:this},S),typeof $=="number"&&$>=0&&(b=Math.min(b,$))}),b<1/0&&b>=0&&(f=t.substring(0,b+1))}if(v=this.tokenizer.inlineText(f)){t=t.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(a=v.raw.slice(-1)),r=!0;let b=n.at(-1);(b==null?void 0:b.type)==="text"?(b.raw+=v.raw,b.text+=v.text):n.push(v);continue}if(t){let b="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(b);break}else throw new Error(b)}}return n}},fi=class{constructor(e){U(this,"options");U(this,"parser");this.options=e||bt}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let i=(o=(t||"").match(ue.notSpaceStart))==null?void 0:o[0],s=e.replace(ue.endingNewline,"")+`
2106
+ `;return i?'<pre><code class="language-'+Be(i)+'">'+(n?s:Be(s,!0))+`</code></pre>
2107
+ `:"<pre><code>"+(n?s:Be(s,!0))+`</code></pre>
2099
2108
  `}blockquote({tokens:e}){return`<blockquote>
2100
2109
  ${this.parser.parse(e)}</blockquote>
2101
2110
  `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
@@ -2111,23 +2120,23 @@ ${this.parser.parse(e)}</blockquote>
2111
2120
  `}tablerow({text:e}){return`<tr>
2112
2121
  ${e}</tr>
2113
2122
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
2114
- `}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>${Oe(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),s=ya(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+Oe(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=ya(e);if(s===null)return Oe(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Oe(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Oe(e.text)}},Bo=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}},be=class zs{constructor(t){U(this,"options");U(this,"renderer");U(this,"textRenderer");this.options=t||vt,this.options.renderer=this.options.renderer||new hi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Bo}static parse(t,n){return new zs(n).parse(t)}static parseInline(t,n){return new zs(n).parseInline(t)}parse(t){var i,s;let n="";for(let o=0;o<t.length;o++){let r=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[r.type]){let u=r,c=this.options.extensions.renderers[u.type].call({parser:this},u);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(u.type)){n+=c||"";continue}}let a=r;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let u='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}parseInline(t,n=this.renderer){var s,o;let i="";for(let r=0;r<t.length;r++){let a=t[r];if((o=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&o[a.type]){let c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){i+=c||"";continue}}let u=a;switch(u.type){case"escape":{i+=n.text(u);break}case"html":{i+=n.html(u);break}case"link":{i+=n.link(u);break}case"image":{i+=n.image(u);break}case"checkbox":{i+=n.checkbox(u);break}case"strong":{i+=n.strong(u);break}case"em":{i+=n.em(u);break}case"codespan":{i+=n.codespan(u);break}case"br":{i+=n.br(u);break}case"del":{i+=n.del(u);break}case"text":{i+=n.text(u);break}default:{let c='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},Vn,tn=(Vn=class{constructor(e){U(this,"options");U(this,"block");this.options=e||vt}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ve.lex:ve.lexInline}provideParser(){return this.block?be.parse:be.parseInline}},U(Vn,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),U(Vn,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Vn),_g=class{constructor(...e){U(this,"defaults",Mo());U(this,"options",this.setOptions);U(this,"parse",this.parseMarkdown(!0));U(this,"parseInline",this.parseMarkdown(!1));U(this,"Parser",be);U(this,"Renderer",hi);U(this,"TextRenderer",Bo);U(this,"Lexer",ve);U(this,"Tokenizer",pi);U(this,"Hooks",tn);this.use(...e)}walkTokens(e,t){var i,s;let n=[];for(let o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{let r=o;for(let a of r.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of r.rows)for(let u of a)n=n.concat(this.walkTokens(u.tokens,t));break}case"list":{let r=o;n=n.concat(this.walkTokens(r.items,t));break}default:{let r=o;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[r.type]?this.defaults.extensions.childTokens[r.type].forEach(a=>{let u=r[a].flat(1/0);n=n.concat(this.walkTokens(u,t))}):r.tokens&&(n=n.concat(this.walkTokens(r.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let o=t.renderers[s.name];o?t.renderers[s.name]=function(...r){let a=s.renderer.apply(this,r);return a===!1&&(a=o.apply(this,r)),a}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[s.level];o?o.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),i.extensions=t),n.renderer){let s=this.defaults.renderer||new hi(this.defaults);for(let o in n.renderer){if(!(o in s))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let r=o,a=n.renderer[r],u=s[r];s[r]=(...c)=>{let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new pi(this.defaults);for(let o in n.tokenizer){if(!(o in s))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let r=o,a=n.tokenizer[r],u=s[r];s[r]=(...c)=>{let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new tn;for(let o in n.hooks){if(!(o in s))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let r=o,a=n.hooks[r],u=s[r];tn.passThroughHooks.has(o)?s[r]=c=>{if(this.defaults.async&&tn.passThroughHooksRespectAsync.has(o))return(async()=>{let d=await a.call(s,c);return u.call(s,d)})();let l=a.call(s,c);return u.call(s,l)}:s[r]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await a.apply(s,c);return d===!1&&(d=await u.apply(s,c)),d})();let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l}}i.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,o=n.walkTokens;i.walkTokens=function(r){let a=[];return a.push(o.call(this,r)),s&&(a=a.concat(s.call(this,r))),a}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ve.lex(e,t??this.defaults)}parser(e,t){return be.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let r=s.hooks?await s.hooks.preprocess(t):t,a=await(s.hooks?await s.hooks.provideLexer():e?ve.lex:ve.lexInline)(r,s),u=s.hooks?await s.hooks.processAllTokens(a):a;s.walkTokens&&await Promise.all(this.walkTokens(u,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():e?be.parse:be.parseInline)(u,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let r=(s.hooks?s.hooks.provideLexer():e?ve.lex:ve.lexInline)(t,s);s.hooks&&(r=s.hooks.processAllTokens(r)),s.walkTokens&&this.walkTokens(r,s.walkTokens);let a=(s.hooks?s.hooks.provideParser():e?be.parse:be.parseInline)(r,s);return s.hooks&&(a=s.hooks.postprocess(a)),a}catch(r){return o(r)}}}onError(e,t){return n=>{if(n.message+=`
2115
- Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Oe(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},ft=new _g;function K(e,t){return ft.parse(e,t)}K.options=K.setOptions=function(e){return ft.setOptions(e),K.defaults=ft.defaults,Ec(K.defaults),K};K.getDefaults=Mo;K.defaults=vt;K.use=function(...e){return ft.use(...e),K.defaults=ft.defaults,Ec(K.defaults),K};K.walkTokens=function(e,t){return ft.walkTokens(e,t)};K.parseInline=ft.parseInline;K.Parser=be;K.parser=be.parse;K.Renderer=hi;K.TextRenderer=Bo;K.Lexer=ve;K.lexer=ve.lex;K.Tokenizer=pi;K.Hooks=tn;K.parse=K;K.options;K.setOptions;K.use;K.walkTokens;K.parseInline;be.parse;ve.lex;K.setOptions({gfm:!0,breaks:!0,mangle:!1});const wa=["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"],ka=["class","href","rel","target","title","start"];let Sa=!1;const Mg=14e4,Pg=4e4,Lg=200,ds=5e4,rt=new Map;function Ig(e){const t=rt.get(e);return t===void 0?null:(rt.delete(e),rt.set(e,t),t)}function xa(e,t){if(rt.set(e,t),rt.size<=Lg)return;const n=rt.keys().next().value;n&&rt.delete(n)}function Rg(){Sa||(Sa=!0,Us.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function fi(e){const t=e.trim();if(!t)return"";if(Rg(),t.length<=ds){const r=Ig(t);if(r!==null)return r}const n=fl(t,Mg),i=n.truncated?`
2123
+ `}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>${Be(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),s=va(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+Be(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=va(e);if(s===null)return Be(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Be(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Be(e.text)}},Fo=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}},be=class js{constructor(t){U(this,"options");U(this,"renderer");U(this,"textRenderer");this.options=t||bt,this.options.renderer=this.options.renderer||new fi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Fo}static parse(t,n){return new js(n).parse(t)}static parseInline(t,n){return new js(n).parseInline(t)}parse(t){var i,s;let n="";for(let o=0;o<t.length;o++){let r=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[r.type]){let u=r,c=this.options.extensions.renderers[u.type].call({parser:this},u);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(u.type)){n+=c||"";continue}}let a=r;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let u='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}parseInline(t,n=this.renderer){var s,o;let i="";for(let r=0;r<t.length;r++){let a=t[r];if((o=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&o[a.type]){let c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){i+=c||"";continue}}let u=a;switch(u.type){case"escape":{i+=n.text(u);break}case"html":{i+=n.html(u);break}case"link":{i+=n.link(u);break}case"image":{i+=n.image(u);break}case"checkbox":{i+=n.checkbox(u);break}case"strong":{i+=n.strong(u);break}case"em":{i+=n.em(u);break}case"codespan":{i+=n.codespan(u);break}case"br":{i+=n.br(u);break}case"del":{i+=n.del(u);break}case"text":{i+=n.text(u);break}default:{let c='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},Gn,on=(Gn=class{constructor(e){U(this,"options");U(this,"block");this.options=e||bt}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ve.lex:ve.lexInline}provideParser(){return this.block?be.parse:be.parseInline}},U(Gn,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),U(Gn,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Gn),Mg=class{constructor(...e){U(this,"defaults",Po());U(this,"options",this.setOptions);U(this,"parse",this.parseMarkdown(!0));U(this,"parseInline",this.parseMarkdown(!1));U(this,"Parser",be);U(this,"Renderer",fi);U(this,"TextRenderer",Fo);U(this,"Lexer",ve);U(this,"Tokenizer",hi);U(this,"Hooks",on);this.use(...e)}walkTokens(e,t){var i,s;let n=[];for(let o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{let r=o;for(let a of r.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of r.rows)for(let u of a)n=n.concat(this.walkTokens(u.tokens,t));break}case"list":{let r=o;n=n.concat(this.walkTokens(r.items,t));break}default:{let r=o;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[r.type]?this.defaults.extensions.childTokens[r.type].forEach(a=>{let u=r[a].flat(1/0);n=n.concat(this.walkTokens(u,t))}):r.tokens&&(n=n.concat(this.walkTokens(r.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let o=t.renderers[s.name];o?t.renderers[s.name]=function(...r){let a=s.renderer.apply(this,r);return a===!1&&(a=o.apply(this,r)),a}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[s.level];o?o.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),i.extensions=t),n.renderer){let s=this.defaults.renderer||new fi(this.defaults);for(let o in n.renderer){if(!(o in s))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let r=o,a=n.renderer[r],u=s[r];s[r]=(...c)=>{let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new hi(this.defaults);for(let o in n.tokenizer){if(!(o in s))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let r=o,a=n.tokenizer[r],u=s[r];s[r]=(...c)=>{let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new on;for(let o in n.hooks){if(!(o in s))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let r=o,a=n.hooks[r],u=s[r];on.passThroughHooks.has(o)?s[r]=c=>{if(this.defaults.async&&on.passThroughHooksRespectAsync.has(o))return(async()=>{let d=await a.call(s,c);return u.call(s,d)})();let l=a.call(s,c);return u.call(s,l)}:s[r]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await a.apply(s,c);return d===!1&&(d=await u.apply(s,c)),d})();let l=a.apply(s,c);return l===!1&&(l=u.apply(s,c)),l}}i.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,o=n.walkTokens;i.walkTokens=function(r){let a=[];return a.push(o.call(this,r)),s&&(a=a.concat(s.call(this,r))),a}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ve.lex(e,t??this.defaults)}parser(e,t){return be.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let r=s.hooks?await s.hooks.preprocess(t):t,a=await(s.hooks?await s.hooks.provideLexer():e?ve.lex:ve.lexInline)(r,s),u=s.hooks?await s.hooks.processAllTokens(a):a;s.walkTokens&&await Promise.all(this.walkTokens(u,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():e?be.parse:be.parseInline)(u,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let r=(s.hooks?s.hooks.provideLexer():e?ve.lex:ve.lexInline)(t,s);s.hooks&&(r=s.hooks.processAllTokens(r)),s.walkTokens&&this.walkTokens(r,s.walkTokens);let a=(s.hooks?s.hooks.provideParser():e?be.parse:be.parseInline)(r,s);return s.hooks&&(a=s.hooks.postprocess(a)),a}catch(r){return o(r)}}}onError(e,t){return n=>{if(n.message+=`
2124
+ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Be(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},gt=new Mg;function K(e,t){return gt.parse(e,t)}K.options=K.setOptions=function(e){return gt.setOptions(e),K.defaults=gt.defaults,Ec(K.defaults),K};K.getDefaults=Po;K.defaults=bt;K.use=function(...e){return gt.use(...e),K.defaults=gt.defaults,Ec(K.defaults),K};K.walkTokens=function(e,t){return gt.walkTokens(e,t)};K.parseInline=gt.parseInline;K.Parser=be;K.parser=be.parse;K.Renderer=fi;K.TextRenderer=Fo;K.Lexer=ve;K.lexer=ve.lex;K.Tokenizer=hi;K.Hooks=on;K.parse=K;K.options;K.setOptions;K.use;K.walkTokens;K.parseInline;be.parse;ve.lex;K.setOptions({gfm:!0,breaks:!0,mangle:!1});const ka=["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"],Sa=["class","href","rel","target","title","start"];let xa=!1;const Pg=14e4,Lg=4e4,Ig=200,ps=5e4,at=new Map;function Rg(e){const t=at.get(e);return t===void 0?null:(at.delete(e),at.set(e,t),t)}function $a(e,t){if(at.set(e,t),at.size<=Ig)return;const n=at.keys().next().value;n&&at.delete(n)}function Ng(){xa||(xa=!0,Ws.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function gi(e){const t=e.trim();if(!t)return"";if(Ng(),t.length<=ps){const r=Rg(t);if(r!==null)return r}const n=gl(t,Pg),i=n.truncated?`
2116
2125
 
2117
- … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Pg){const a=`<pre class="code-block">${Ng(`${n.text}${i}`)}</pre>`,u=Us.sanitize(a,{ALLOWED_TAGS:wa,ALLOWED_ATTR:ka});return t.length<=ds&&xa(t,u),u}const s=K.parse(`${n.text}${i}`),o=Us.sanitize(s,{ALLOWED_TAGS:wa,ALLOWED_ATTR:ka});return t.length<=ds&&xa(t,o),o}function Ng(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Dg=1500,Og=2e3,Oc="Copy as markdown",Bg="Copied",Fg="Copy failed";async function Ug(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 Kn(e,t){e.title=t,e.setAttribute("aria-label",t)}function Wg(e){const t=e.label??Oc;return p`
2126
+ … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Lg){const a=`<pre class="code-block">${Dg(`${n.text}${i}`)}</pre>`,u=Ws.sanitize(a,{ALLOWED_TAGS:ka,ALLOWED_ATTR:Sa});return t.length<=ps&&$a(t,u),u}const s=K.parse(`${n.text}${i}`),o=Ws.sanitize(s,{ALLOWED_TAGS:ka,ALLOWED_ATTR:Sa});return t.length<=ps&&$a(t,o),o}function Dg(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Og=1500,Bg=2e3,Oc="Copy as markdown",Fg="Copied",Ug="Copy failed";async function Wg(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 zn(e,t){e.title=t,e.setAttribute("aria-label",t)}function Kg(e){const t=e.label??Oc;return p`
2118
2127
  <button
2119
2128
  class="chat-copy-btn"
2120
2129
  type="button"
2121
2130
  title=${t}
2122
2131
  aria-label=${t}
2123
- @click=${async n=>{const i=n.currentTarget;if(i==null||i.querySelector(".chat-copy-btn__icon"),!i||i.dataset.copying==="1")return;i.dataset.copying="1",i.setAttribute("aria-busy","true"),i.disabled=!0;const s=await Ug(e.text());if(i.isConnected){if(delete i.dataset.copying,i.removeAttribute("aria-busy"),i.disabled=!1,!s){i.dataset.error="1",Kn(i,Fg),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.error,Kn(i,t))},Og);return}i.dataset.copied="1",Kn(i,Bg),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,Kn(i,t))},Dg)}}}
2132
+ @click=${async n=>{const i=n.currentTarget;if(i==null||i.querySelector(".chat-copy-btn__icon"),!i||i.dataset.copying==="1")return;i.dataset.copying="1",i.setAttribute("aria-busy","true"),i.disabled=!0;const s=await Wg(e.text());if(i.isConnected){if(delete i.dataset.copying,i.removeAttribute("aria-busy"),i.disabled=!1,!s){i.dataset.error="1",zn(i,Ug),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.error,zn(i,t))},Bg);return}i.dataset.copied="1",zn(i,Fg),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,zn(i,t))},Og)}}}
2124
2133
  >
2125
2134
  <span class="chat-copy-btn__icon" aria-hidden="true">
2126
2135
  <span class="chat-copy-btn__icon-copy">${D.copy}</span>
2127
2136
  <span class="chat-copy-btn__icon-check">${D.check}</span>
2128
2137
  </span>
2129
2138
  </button>
2130
- `}function Kg(e){return Wg({text:()=>e,label:Oc})}function zg(e){const t=e,n=jg(t.content),i=[];for(const s of n){const o=String(s.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(o)||typeof s.name=="string"&&s.arguments!=null)&&i.push({kind:"call",name:s.name??"tool",args:Hg(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const r=qg(s),a=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:a,text:r})}if(bl(e)&&!i.some(s=>s.kind==="result")){const s=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",o=gl(e)??void 0;i.push({kind:"result",name:s,text:o})}return i}function jg(e){return Array.isArray(e)?e.filter(Boolean):[]}function Hg(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 qg(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function Vg(e){var s;const n=e.content,i=[];if(Array.isArray(n))for(const o of n){if(typeof o!="object"||o===null)continue;const r=o;if(r.type==="image")if(((s=r.source)==null?void 0:s.type)==="base64"){const a=r.source,u=a.data,c=a.media_type||"image/png",l=u.startsWith("data:")?u:`data:${c};base64,${u}`;i.push({url:l})}else if(typeof r.data=="string"&&r.data){const a=r.data,u=r.mimeType||r.media_type||"image/png",c=a.startsWith("data:")?a:`data:${u};base64,${a}`;i.push({url:c})}else typeof r.url=="string"&&i.push({url:r.url});else if(r.type==="image_url"){const a=r.image_url;typeof(a==null?void 0:a.url)=="string"&&i.push({url:a.url})}}return i}function Gg(e){return p`
2139
+ `}function zg(e){return Kg({text:()=>e,label:Oc})}function jg(e){const t=e,n=Hg(t.content),i=[];for(const s of n){const o=String(s.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(o)||typeof s.name=="string"&&s.arguments!=null)&&i.push({kind:"call",name:s.name??"tool",args:qg(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const r=Vg(s),a=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:a,text:r})}if(wl(e)&&!i.some(s=>s.kind==="result")){const s=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",o=ml(e)??void 0;i.push({kind:"result",name:s,text:o})}return i}function Hg(e){return Array.isArray(e)?e.filter(Boolean):[]}function qg(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 Vg(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function Gg(e){var s;const n=e.content,i=[];if(Array.isArray(n))for(const o of n){if(typeof o!="object"||o===null)continue;const r=o;if(r.type==="image")if(((s=r.source)==null?void 0:s.type)==="base64"){const a=r.source,u=a.data,c=a.media_type||"image/png",l=u.startsWith("data:")?u:`data:${c};base64,${u}`;i.push({url:l})}else if(typeof r.data=="string"&&r.data){const a=r.data,u=r.mimeType||r.media_type||"image/png",c=a.startsWith("data:")?a:`data:${u};base64,${a}`;i.push({url:c})}else typeof r.url=="string"&&i.push({url:r.url});else if(r.type==="image_url"){const a=r.image_url;typeof(a==null?void 0:a.url)=="string"&&i.push({url:a.url})}}return i}function Qg(e){return p`
2131
2140
  <div class="chat-group assistant">
2132
2141
  <div class="chat-group-messages">
2133
2142
  <div class="chat-bubble chat-reading-indicator" aria-hidden="true">
@@ -2137,21 +2146,21 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2137
2146
  </div>
2138
2147
  </div>
2139
2148
  </div>
2140
- `}function Qg(e){return p`
2149
+ `}function Yg(e){return p`
2141
2150
  <div class="chat-group assistant">
2142
2151
  <div class="chat-group-messages">
2143
2152
  <div class="chat-interim fade-in">
2144
- ${ui(fi(e))}
2153
+ ${di(gi(e))}
2145
2154
  </div>
2146
2155
  </div>
2147
2156
  </div>
2148
- `}function Yg(e,t,n,i){return p`
2157
+ `}function Xg(e,t,n,i){return p`
2149
2158
  <div class="chat-group assistant">
2150
2159
  <div class="chat-group-messages">
2151
2160
  ${Bc({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
2152
2161
  </div>
2153
2162
  </div>
2154
- `}function Xg(e,t){const n=vl(e.role),i=n==="user"?"user":n==="assistant"?"assistant":"other",s=new Date(e.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"});return p`
2163
+ `}function Zg(e,t){const n=bl(e.role),i=n==="user"?"user":n==="assistant"?"assistant":"other",s=new Date(e.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"});return p`
2155
2164
  <div class="chat-group ${i}">
2156
2165
  <div class="chat-group-messages">
2157
2166
  ${e.messages.map((o,r)=>Bc(o.message,{isStreaming:e.isStreaming&&r===e.messages.length-1,showReasoning:t.showReasoning}))}
@@ -2160,7 +2169,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2160
2169
  </div>
2161
2170
  </div>
2162
2171
  </div>
2163
- `}function Zg(e){return e.length===0?k:p`
2172
+ `}function Jg(e){return e.length===0?k:p`
2164
2173
  <div class="chat-message-images">
2165
2174
  ${e.map(t=>p`
2166
2175
  <img
@@ -2171,14 +2180,14 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2171
2180
  />
2172
2181
  `)}
2173
2182
  </div>
2174
- `}function Bc(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=bl(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",a=zg(e).length>0,u=Vg(e),c=u.length>0,l=gl(e),d=t.showReasoning&&s==="assistant"?Ed(e):null,h=l!=null&&l.trim()?l:null,v=d?Td(d):null,f=h,b=(s==="assistant"||s==="user")&&!!(f!=null&&f.trim()),S=["chat-bubble",b?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!f&&(a||o)||!f&&!c?k:p`
2183
+ `}function Bc(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=wl(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",a=jg(e).length>0,u=Gg(e),c=u.length>0,l=ml(e),d=t.showReasoning&&s==="assistant"?Ed(e):null,h=l!=null&&l.trim()?l:null,v=d?Td(d):null,f=h,b=(s==="assistant"||s==="user")&&!!(f!=null&&f.trim()),S=["chat-bubble",b?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!f&&(a||o)||!f&&!c?k:p`
2175
2184
  <div class="${S}">
2176
- ${b?Kg(f):k}
2177
- ${Zg(u)}
2178
- ${v?p`<div class="chat-thinking">${ui(fi(v))}</div>`:k}
2179
- ${f?p`<div class="chat-text">${ui(fi(f))}</div>`:k}
2185
+ ${b?zg(f):k}
2186
+ ${Jg(u)}
2187
+ ${v?p`<div class="chat-thinking">${di(gi(v))}</div>`:k}
2188
+ ${f?p`<div class="chat-text">${di(gi(f))}</div>`:k}
2180
2189
  </div>
2181
- `}function Jg(e){return p`
2190
+ `}function em(e){return p`
2182
2191
  <div class="sidebar-panel">
2183
2192
  <div class="sidebar-header">
2184
2193
  <div class="sidebar-title">Tool Output</div>
@@ -2192,10 +2201,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2192
2201
  <button @click=${e.onViewRawText} class="btn" style="margin-top: 12px;">
2193
2202
  View Raw Text
2194
2203
  </button>
2195
- `:e.content?p`<div class="sidebar-markdown">${ui(fi(e.content))}</div>`:p`<div class="muted">No content available</div>`}
2204
+ `:e.content?p`<div class="sidebar-markdown">${di(gi(e.content))}</div>`:p`<div class="muted">No content available</div>`}
2196
2205
  </div>
2197
2206
  </div>
2198
- `}var em=Object.defineProperty,tm=Object.getOwnPropertyDescriptor,Pi=(e,t,n,i)=>{for(var s=i>1?void 0:i?tm(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(s=(i?r(t,n,s):r(s))||s);return i&&s&&em(t,n,s),s};let Rt=class extends _t{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,s=(e.clientX-this.startX)/n;let o=this.startRatio+s;o=Math.max(this.minRatio,Math.min(this.maxRatio,o)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:o},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return p``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};Rt.styles=ju`
2207
+ `}var tm=Object.defineProperty,nm=Object.getOwnPropertyDescriptor,Li=(e,t,n,i)=>{for(var s=i>1?void 0:i?nm(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(s=(i?r(t,n,s):r(s))||s);return i&&s&&tm(t,n,s),s};let Nt=class extends Mt{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,s=(e.clientX-this.startX)/n;let o=this.startRatio+s;o=Math.max(this.minRatio,Math.min(this.maxRatio,o)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:o},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return p``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};Nt.styles=ju`
2199
2208
  :host {
2200
2209
  width: 4px;
2201
2210
  cursor: col-resize;
@@ -2221,21 +2230,21 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2221
2230
  :host(.dragging) {
2222
2231
  background: var(--accent, #007bff);
2223
2232
  }
2224
- `;Pi([Si({type:Number})],Rt.prototype,"splitRatio",2);Pi([Si({type:Number})],Rt.prototype,"minRatio",2);Pi([Si({type:Number})],Rt.prototype,"maxRatio",2);Rt=Pi([cl("resizable-divider")],Rt);function zn(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function ps(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const nm=1,im=1,bt="emoji",Nt="keyvalue",Fo="favorites",sm="tokens",Fc="tokens",om="unicode",Uc="count",rm="group",am="order",Wc="group-order",js="eTag",gi="url",$a="skinTone",Ft="readonly",Uo="readwrite",Kc="skinUnicodes",lm="skinUnicodes",cm="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",um="en";function dm(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function Aa(e){return dm(e,t=>t.unicode)}function pm(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[r,[a,u]]of Object.entries(s))o.createIndex(r,a,{multiEntry:u});return o}t(Nt),t(bt,om,{[Fc]:[sm,!0],[Wc]:[[rm,am]],[Kc]:[lm,!0]}),t(Fo,void 0,{[Uc]:[""]})}const Hs={},Xn={},mi={};function zc(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function hm(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,nm);Hs[e]=s,s.onupgradeneeded=o=>{o.oldVersion<im&&pm(s.result)},zc(n,i,s)});return t.onclose=()=>Wo(e),t}function fm(e){return Xn[e]||(Xn[e]=hm(e)),Xn[e]}function We(e,t,n,i){return new Promise((s,o)=>{const r=e.transaction(t,n,{durability:"relaxed"}),a=typeof t=="string"?r.objectStore(t):t.map(c=>r.objectStore(c));let u;i(a,r,c=>{u=c}),r.oncomplete=()=>s(u),r.onerror=()=>o(r.error)})}function Wo(e){const t=Hs[e],n=t&&t.result;if(n){n.close();const i=mi[e];if(i)for(const s of i)s()}delete Hs[e],delete Xn[e],delete mi[e]}function gm(e){return new Promise((t,n)=>{Wo(e);const i=indexedDB.deleteDatabase(e);zc(t,n,i)})}function mm(e,t){let n=mi[e];n||(n=mi[e]=[]),n.push(t)}const ym=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 Pt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||ym.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const vm=2;function jc(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=vm)}function bm(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:r,skins:a,tags:u,emoji:c,version:l})=>{const d=[...new Set(jc([...(r||[]).map(Pt).flat(),...(u||[]).map(Pt).flat(),...Pt(n),i]))].sort(),h={annotation:n,group:s,order:o,tags:u,tokens:d,unicode:c,version:l};if(i&&(h.emoticon=i),r&&(h.shortcodes=r),a){h.skinTones=[],h.skinUnicodes=[],h.skinVersions=[];for(const{tone:v,emoji:f,version:b}of a)h.skinTones.push(v),h.skinUnicodes.push(f),h.skinVersions.push(b)}return h})}function Hc(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function gt(e,t,n){Hc(e,"get",t,n)}function qc(e,t,n){Hc(e,"getAll",t,n)}function Ko(e){e.commit&&e.commit()}function wm(e,t){let n=e[0];for(let i=1;i<e.length;i++){const s=e[i];t(n)>t(s)&&(n=s)}return n}function Vc(e,t){const n=wm(e,s=>s.length),i=[];for(const s of n)e.some(o=>o.findIndex(r=>t(r)===t(s))===-1)||i.push(s);return i}async function km(e){return!await zo(e,Nt,gi)}async function Sm(e,t,n){const[i,s]=await Promise.all([js,gi].map(o=>zo(e,Nt,o)));return i===n&&s===t}async function xm(e,t){return We(e,bt,Ft,(i,s,o)=>{let r;const a=()=>{i.getAll(r&&IDBKeyRange.lowerBound(r,!0),50).onsuccess=u=>{const c=u.target.result;for(const l of c)if(r=l.unicode,t(l))return o(l);if(c.length<50)return o();a()}};a()})}async function Gc(e,t,n,i){{const s=bm(t);await We(e,[bt,Nt],Uo,([o,r],a)=>{let u,c,l=0;function d(){++l===2&&h()}function h(){if(!(u===i&&c===n)){o.clear();for(const v of s)o.put(v);r.put(i,js),r.put(n,gi),Ko(a)}}gt(r,js,v=>{u=v,d()}),gt(r,gi,v=>{c=v,d()})})}}async function $m(e,t){return We(e,bt,Ft,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);qc(n.index(Wc),o,s)})}async function Qc(e,t){const n=jc(Pt(t));return n.length?We(e,bt,Ft,(i,s,o)=>{const r=[],a=()=>{r.length===n.length&&u()},u=()=>{const c=Vc(r,l=>l.unicode);o(c.sort((l,d)=>l.order<d.order?-1:1))};for(let c=0;c<n.length;c++){const l=n[c],d=c===n.length-1?IDBKeyRange.bound(l,l+"￿",!1,!0):IDBKeyRange.only(l);qc(i.index(Fc),d,h=>{r.push(h),a()})}}):[]}async function Am(e,t){const n=await Qc(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await xm(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function Em(e,t){return We(e,bt,Ft,(n,i,s)=>gt(n,t,o=>{if(o)return s(o);gt(n.index(Kc),t,r=>s(r||null))}))}function zo(e,t,n){return We(e,t,Ft,(i,s,o)=>gt(i,n,o))}function Cm(e,t,n,i){return We(e,t,Uo,(s,o)=>{s.put(i,n),Ko(o)})}function Tm(e,t){return We(e,Fo,Uo,(n,i)=>gt(n,t,s=>{n.put((s||0)+1,t),Ko(i)}))}function _m(e,t,n){return n===0?[]:We(e,[Fo,bt],Ft,([i,s],o,r)=>{const a=[];i.index(Uc).openCursor(void 0,"prev").onsuccess=u=>{const c=u.target.result;if(!c)return r(a);function l(v){if(a.push(v),a.length===n)return r(a);c.continue()}const d=c.primaryKey,h=t.byName(d);if(h)return l(h);gt(s,d,v=>{if(v)return l(v);c.continue()})}})}const jn="";function Mm(e,t){const n=new Map;for(const s of e){const o=t(s);for(const r of o){let a=n;for(let c=0;c<r.length;c++){const l=r.charAt(c);let d=a.get(l);d||(d=new Map,a.set(l,d)),a=d}let u=a.get(jn);u||(u=[],a.set(jn,u)),u.push(s)}}return(s,o)=>{let r=n;for(let c=0;c<s.length;c++){const l=s.charAt(c),d=r.get(l);if(d)r=d;else return[]}if(o)return r.get(jn)||[];const a=[],u=[r];for(;u.length;){const l=[...u.shift().entries()].sort((d,h)=>d[0]<h[0]?-1:1);for(const[d,h]of l)d===jn?a.push(...h):u.push(h)}return a}}const Pm=["name","url"];function Lm(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||Pm.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function Ea(e){Lm(e);const t=(h,v)=>h.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),s=Mm(e,h=>{const v=new Set;if(h.shortcodes)for(const f of h.shortcodes)for(const b of Pt(f))v.add(b);return v}),o=h=>s(h,!0),r=h=>s(h,!1),a=h=>{const v=Pt(h),f=v.map((b,S)=>(S<v.length-1?o:r)(b));return Vc(f,b=>b.name).sort(t)},u=new Map,c=new Map;for(const h of e){c.set(h.name.toLowerCase(),h);for(const v of h.shortcodes||[])u.set(v.toLowerCase(),h)}return{all:n,search:a,byShortcode:h=>u.get(h.toLowerCase()),byName:h=>c.get(h.toLowerCase())}}const Im=typeof wrappedJSObject<"u";function Jt(e){if(!e)return e;if(Im&&(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 Yc(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Rm=["annotation","emoji","group","order","version"];function Nm(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Rm.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function Xc(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Dm(e){const t=await fetch(e,{method:"HEAD"});Xc(t,e);const n=t.headers.get("etag");return Yc(n),n}async function qs(e){const t=await fetch(e);Xc(t,e);const n=t.headers.get("etag");Yc(n);const i=await t.json();return Nm(i),[n,i]}function Om(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Bm(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),s=-1;++s<t;)i[s]=e.charCodeAt(s);return n}async function Zc(e){const t=JSON.stringify(e);let n=Bm(t);const i=await crypto.subtle.digest("SHA-1",n),s=Om(i);return btoa(s)}async function Fm(e,t){let n,i=await Dm(t);if(!i){const s=await qs(t);i=s[0],n=s[1],i||(i=await Zc(n))}await Sm(e,t,i)||(n||(n=(await qs(t))[1]),await Gc(e,n,t,i))}async function Um(e,t){let[n,i]=await qs(t);n||(n=await Zc(i)),await Gc(e,i,t,n)}async function Wm(e,t){try{await Fm(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class Km{constructor({dataSource:t=cm,locale:n=um,customEmoji:i=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=Ea(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await fm(this._dbName);mm(this._dbName,this._clear);const n=this.dataSource;await km(t)?await Um(t,n):this._lazyUpdate=Wm(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 ps(t),await this.ready(),Aa(await $m(this._db,t)).map(Jt)}async getEmojiBySearchQuery(t){zn(t),await this.ready();const n=this._custom.search(t),i=Aa(await Qc(this._db,t)).map(Jt);return[...n,...i]}async getEmojiByShortcode(t){zn(t),await this.ready();const n=this._custom.byShortcode(t);return n||Jt(await Am(this._db,t))}async getEmojiByUnicodeOrName(t){zn(t),await this.ready();const n=this._custom.byName(t);return n||Jt(await Em(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await zo(this._db,Nt,$a)||0}async setPreferredSkinTone(t){return ps(t),await this.ready(),Cm(this._db,Nt,$a,t)}async incrementFavoriteEmojiCount(t){return zn(t),await this.ready(),Tm(this._db,t)}async getTopFavoriteEmoji(t){return ps(t),await this.ready(),(await _m(this._db,this._custom,t)).map(Jt)}set customEmoji(t){this._custom=Ea(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 Wo(this._dbName)}async delete(){await this._shutdown(),await gm(this._dbName)}}const Vs=[[-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})),hs=Vs.slice(1),zm=2,Ca=6,Jc=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function Ta(e){return e.unicode.includes("‍")}const jm={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},Hm=1e3,qm="🖐️",Vm=8,Gm=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],eu='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',Qm=(e,t)=>e<t?-1:e>t?1:0,_a=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const i=n.getContext("2d",{willReadFrequently:!0});return i.textBaseline="top",i.font=`100px ${eu}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},Ym=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function Xm(e){const t=_a(e,"#000"),n=_a(e,"#fff");return t&&n&&Ym(t,n)}function Zm(){const e=Object.entries(jm);try{for(const[t,n]of e)if(Xm(t))return n}catch{}return e[0][1]}let fs;const gs=()=>(fs||(fs=new Promise(e=>Jc(()=>e(Zm())))),fs),Gs=new Map,Jm="️",ey="\uD83C",ty="‍",ny=127995,iy=57339;function sy(e,t){if(t===0)return e;const n=e.indexOf(ty);return n!==-1?e.substring(0,n)+String.fromCodePoint(ny+t-1)+e.substring(n):(e.endsWith(Jm)&&(e=e.substring(0,e.length-1)),e+ey+String.fromCodePoint(iy+t-1))}function Ee(e){e.preventDefault(),e.stopPropagation()}function ms(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function tu(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function oy(e,t){const n=i=>{const s={};for(const o of i)typeof o.tone=="number"&&o.version<=t&&(s[o.tone]=o.unicode);return s};return e.map(({unicode:i,skins:s,shortcodes:o,url:r,name:a,category:u,annotation:c})=>({unicode:i,name:a,shortcodes:o,url:r,category:u,annotation:c,id:i||a,skins:s&&n(s)}))}const Zn=requestAnimationFrame;let ry=typeof ResizeObserver=="function";function ay(e,t,n){let i;ry?(i=new ResizeObserver(n),i.observe(e)):Zn(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function Ma(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let ys;function ly(e,t,n){let i=!0,s=!1;for(const o of e){const r=n(o);if(!r)continue;const a=Ma(r);a===0&&(s=!0),typeof ys>"u"&&(ys=Ma(t));const u=a/1.8<ys;Gs.set(o.unicode,u),u||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
2233
+ `;Li([xi({type:Number})],Nt.prototype,"splitRatio",2);Li([xi({type:Number})],Nt.prototype,"minRatio",2);Li([xi({type:Number})],Nt.prototype,"maxRatio",2);Nt=Li([ul("resizable-divider")],Nt);function jn(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function hs(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const im=1,sm=1,wt="emoji",Dt="keyvalue",Uo="favorites",om="tokens",Fc="tokens",rm="unicode",Uc="count",am="group",lm="order",Wc="group-order",Hs="eTag",mi="url",Aa="skinTone",Kt="readonly",Wo="readwrite",Kc="skinUnicodes",cm="skinUnicodes",um="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",dm="en";function pm(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function Ea(e){return pm(e,t=>t.unicode)}function hm(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[r,[a,u]]of Object.entries(s))o.createIndex(r,a,{multiEntry:u});return o}t(Dt),t(wt,rm,{[Fc]:[om,!0],[Wc]:[[am,lm]],[Kc]:[cm,!0]}),t(Uo,void 0,{[Uc]:[""]})}const qs={},Zn={},yi={};function zc(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function fm(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,im);qs[e]=s,s.onupgradeneeded=o=>{o.oldVersion<sm&&hm(s.result)},zc(n,i,s)});return t.onclose=()=>Ko(e),t}function gm(e){return Zn[e]||(Zn[e]=fm(e)),Zn[e]}function We(e,t,n,i){return new Promise((s,o)=>{const r=e.transaction(t,n,{durability:"relaxed"}),a=typeof t=="string"?r.objectStore(t):t.map(c=>r.objectStore(c));let u;i(a,r,c=>{u=c}),r.oncomplete=()=>s(u),r.onerror=()=>o(r.error)})}function Ko(e){const t=qs[e],n=t&&t.result;if(n){n.close();const i=yi[e];if(i)for(const s of i)s()}delete qs[e],delete Zn[e],delete yi[e]}function mm(e){return new Promise((t,n)=>{Ko(e);const i=indexedDB.deleteDatabase(e);zc(t,n,i)})}function ym(e,t){let n=yi[e];n||(n=yi[e]=[]),n.push(t)}const vm=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 Lt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||vm.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const bm=2;function jc(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=bm)}function wm(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:r,skins:a,tags:u,emoji:c,version:l})=>{const d=[...new Set(jc([...(r||[]).map(Lt).flat(),...(u||[]).map(Lt).flat(),...Lt(n),i]))].sort(),h={annotation:n,group:s,order:o,tags:u,tokens:d,unicode:c,version:l};if(i&&(h.emoticon=i),r&&(h.shortcodes=r),a){h.skinTones=[],h.skinUnicodes=[],h.skinVersions=[];for(const{tone:v,emoji:f,version:b}of a)h.skinTones.push(v),h.skinUnicodes.push(f),h.skinVersions.push(b)}return h})}function Hc(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function mt(e,t,n){Hc(e,"get",t,n)}function qc(e,t,n){Hc(e,"getAll",t,n)}function zo(e){e.commit&&e.commit()}function km(e,t){let n=e[0];for(let i=1;i<e.length;i++){const s=e[i];t(n)>t(s)&&(n=s)}return n}function Vc(e,t){const n=km(e,s=>s.length),i=[];for(const s of n)e.some(o=>o.findIndex(r=>t(r)===t(s))===-1)||i.push(s);return i}async function Sm(e){return!await jo(e,Dt,mi)}async function xm(e,t,n){const[i,s]=await Promise.all([Hs,mi].map(o=>jo(e,Dt,o)));return i===n&&s===t}async function $m(e,t){return We(e,wt,Kt,(i,s,o)=>{let r;const a=()=>{i.getAll(r&&IDBKeyRange.lowerBound(r,!0),50).onsuccess=u=>{const c=u.target.result;for(const l of c)if(r=l.unicode,t(l))return o(l);if(c.length<50)return o();a()}};a()})}async function Gc(e,t,n,i){{const s=wm(t);await We(e,[wt,Dt],Wo,([o,r],a)=>{let u,c,l=0;function d(){++l===2&&h()}function h(){if(!(u===i&&c===n)){o.clear();for(const v of s)o.put(v);r.put(i,Hs),r.put(n,mi),zo(a)}}mt(r,Hs,v=>{u=v,d()}),mt(r,mi,v=>{c=v,d()})})}}async function Am(e,t){return We(e,wt,Kt,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);qc(n.index(Wc),o,s)})}async function Qc(e,t){const n=jc(Lt(t));return n.length?We(e,wt,Kt,(i,s,o)=>{const r=[],a=()=>{r.length===n.length&&u()},u=()=>{const c=Vc(r,l=>l.unicode);o(c.sort((l,d)=>l.order<d.order?-1:1))};for(let c=0;c<n.length;c++){const l=n[c],d=c===n.length-1?IDBKeyRange.bound(l,l+"￿",!1,!0):IDBKeyRange.only(l);qc(i.index(Fc),d,h=>{r.push(h),a()})}}):[]}async function Em(e,t){const n=await Qc(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await $m(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function Cm(e,t){return We(e,wt,Kt,(n,i,s)=>mt(n,t,o=>{if(o)return s(o);mt(n.index(Kc),t,r=>s(r||null))}))}function jo(e,t,n){return We(e,t,Kt,(i,s,o)=>mt(i,n,o))}function Tm(e,t,n,i){return We(e,t,Wo,(s,o)=>{s.put(i,n),zo(o)})}function _m(e,t){return We(e,Uo,Wo,(n,i)=>mt(n,t,s=>{n.put((s||0)+1,t),zo(i)}))}function Mm(e,t,n){return n===0?[]:We(e,[Uo,wt],Kt,([i,s],o,r)=>{const a=[];i.index(Uc).openCursor(void 0,"prev").onsuccess=u=>{const c=u.target.result;if(!c)return r(a);function l(v){if(a.push(v),a.length===n)return r(a);c.continue()}const d=c.primaryKey,h=t.byName(d);if(h)return l(h);mt(s,d,v=>{if(v)return l(v);c.continue()})}})}const Hn="";function Pm(e,t){const n=new Map;for(const s of e){const o=t(s);for(const r of o){let a=n;for(let c=0;c<r.length;c++){const l=r.charAt(c);let d=a.get(l);d||(d=new Map,a.set(l,d)),a=d}let u=a.get(Hn);u||(u=[],a.set(Hn,u)),u.push(s)}}return(s,o)=>{let r=n;for(let c=0;c<s.length;c++){const l=s.charAt(c),d=r.get(l);if(d)r=d;else return[]}if(o)return r.get(Hn)||[];const a=[],u=[r];for(;u.length;){const l=[...u.shift().entries()].sort((d,h)=>d[0]<h[0]?-1:1);for(const[d,h]of l)d===Hn?a.push(...h):u.push(h)}return a}}const Lm=["name","url"];function Im(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||Lm.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function Ca(e){Im(e);const t=(h,v)=>h.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),s=Pm(e,h=>{const v=new Set;if(h.shortcodes)for(const f of h.shortcodes)for(const b of Lt(f))v.add(b);return v}),o=h=>s(h,!0),r=h=>s(h,!1),a=h=>{const v=Lt(h),f=v.map((b,S)=>(S<v.length-1?o:r)(b));return Vc(f,b=>b.name).sort(t)},u=new Map,c=new Map;for(const h of e){c.set(h.name.toLowerCase(),h);for(const v of h.shortcodes||[])u.set(v.toLowerCase(),h)}return{all:n,search:a,byShortcode:h=>u.get(h.toLowerCase()),byName:h=>c.get(h.toLowerCase())}}const Rm=typeof wrappedJSObject<"u";function nn(e){if(!e)return e;if(Rm&&(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 Yc(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Nm=["annotation","emoji","group","order","version"];function Dm(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Nm.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function Xc(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Om(e){const t=await fetch(e,{method:"HEAD"});Xc(t,e);const n=t.headers.get("etag");return Yc(n),n}async function Vs(e){const t=await fetch(e);Xc(t,e);const n=t.headers.get("etag");Yc(n);const i=await t.json();return Dm(i),[n,i]}function Bm(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Fm(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),s=-1;++s<t;)i[s]=e.charCodeAt(s);return n}async function Zc(e){const t=JSON.stringify(e);let n=Fm(t);const i=await crypto.subtle.digest("SHA-1",n),s=Bm(i);return btoa(s)}async function Um(e,t){let n,i=await Om(t);if(!i){const s=await Vs(t);i=s[0],n=s[1],i||(i=await Zc(n))}await xm(e,t,i)||(n||(n=(await Vs(t))[1]),await Gc(e,n,t,i))}async function Wm(e,t){let[n,i]=await Vs(t);n||(n=await Zc(i)),await Gc(e,i,t,n)}async function Km(e,t){try{await Um(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class zm{constructor({dataSource:t=um,locale:n=dm,customEmoji:i=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=Ca(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await gm(this._dbName);ym(this._dbName,this._clear);const n=this.dataSource;await Sm(t)?await Wm(t,n):this._lazyUpdate=Km(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 hs(t),await this.ready(),Ea(await Am(this._db,t)).map(nn)}async getEmojiBySearchQuery(t){jn(t),await this.ready();const n=this._custom.search(t),i=Ea(await Qc(this._db,t)).map(nn);return[...n,...i]}async getEmojiByShortcode(t){jn(t),await this.ready();const n=this._custom.byShortcode(t);return n||nn(await Em(this._db,t))}async getEmojiByUnicodeOrName(t){jn(t),await this.ready();const n=this._custom.byName(t);return n||nn(await Cm(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await jo(this._db,Dt,Aa)||0}async setPreferredSkinTone(t){return hs(t),await this.ready(),Tm(this._db,Dt,Aa,t)}async incrementFavoriteEmojiCount(t){return jn(t),await this.ready(),_m(this._db,t)}async getTopFavoriteEmoji(t){return hs(t),await this.ready(),(await Mm(this._db,this._custom,t)).map(nn)}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 Ko(this._dbName)}async delete(){await this._shutdown(),await mm(this._dbName)}}const Gs=[[-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})),fs=Gs.slice(1),jm=2,Ta=6,Jc=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function _a(e){return e.unicode.includes("‍")}const Hm={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},qm=1e3,Vm="🖐️",Gm=8,Qm=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],eu='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',Ym=(e,t)=>e<t?-1:e>t?1:0,Ma=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const i=n.getContext("2d",{willReadFrequently:!0});return i.textBaseline="top",i.font=`100px ${eu}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},Xm=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function Zm(e){const t=Ma(e,"#000"),n=Ma(e,"#fff");return t&&n&&Xm(t,n)}function Jm(){const e=Object.entries(Hm);try{for(const[t,n]of e)if(Zm(t))return n}catch{}return e[0][1]}let gs;const ms=()=>(gs||(gs=new Promise(e=>Jc(()=>e(Jm())))),gs),Qs=new Map,ey="️",ty="\uD83C",ny="‍",iy=127995,sy=57339;function oy(e,t){if(t===0)return e;const n=e.indexOf(ny);return n!==-1?e.substring(0,n)+String.fromCodePoint(iy+t-1)+e.substring(n):(e.endsWith(ey)&&(e=e.substring(0,e.length-1)),e+ty+String.fromCodePoint(sy+t-1))}function Ee(e){e.preventDefault(),e.stopPropagation()}function ys(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function tu(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function ry(e,t){const n=i=>{const s={};for(const o of i)typeof o.tone=="number"&&o.version<=t&&(s[o.tone]=o.unicode);return s};return e.map(({unicode:i,skins:s,shortcodes:o,url:r,name:a,category:u,annotation:c})=>({unicode:i,name:a,shortcodes:o,url:r,category:u,annotation:c,id:i||a,skins:s&&n(s)}))}const Jn=requestAnimationFrame;let ay=typeof ResizeObserver=="function";function ly(e,t,n){let i;ay?(i=new ResizeObserver(n),i.observe(e)):Jn(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function Pa(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let vs;function cy(e,t,n){let i=!0,s=!1;for(const o of e){const r=n(o);if(!r)continue;const a=Pa(r);a===0&&(s=!0),typeof vs>"u"&&(vs=Pa(t));const u=a/1.8<vs;Qs.set(o.unicode,u),u||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
2225
2234
  This is likely due to using \`display:none\` which is unsupported.
2226
2235
  If this is a Jest/Vitest environment, you can ignore this warning.
2227
- For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function cy(e){return tu(e,t=>t)}function uy(e){e&&(e.scrollTop=0)}function cn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function Pa(e){return""+e}function dy(e){const t=document.createElement("template");return t.innerHTML=e,t}const py=new WeakMap,hy=new WeakMap,fy=Symbol("un-keyed"),gy="replaceChildren"in Element.prototype;function my(e,t){gy?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function yy(e,t){let n=e.firstChild,i=0;for(;n;){if(t[i]!==n)return!0;n=n.nextSibling,i++}return i!==t.length}function vy(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=yy(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&my(i,e)}function by(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:r,attributeValuePre:a,attributeValuePost:u}}=n,c=e[o];if(s!==c)if(n.currentExpression=c,r)if(c===null)i.removeAttribute(r);else{const l=a+Pa(c)+u;i.setAttribute(r,l)}else{let l;Array.isArray(c)?vy(c,n):c instanceof Element?(l=c,i.replaceWith(l)):i.nodeValue=Pa(c),l&&(n.targetNode=l)}}}function wy(e){let t="",n=!1,i=!1,s=-1;const o=new Map,r=[];let a=0;for(let c=0,l=e.length;c<l;c++){const d=e[c];if(t+=d.slice(a),c===l-1)break;for(let A=0;A<d.length;A++)switch(d.charAt(A)){case"<":{d.charAt(A+1)==="/"?r.pop():(n=!0,r.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const h=r[r.length-1],v=cn(o,h,()=>[]);let f,b,S;if(i){const A=/(\S+)="?([^"=]*)$/.exec(d);f=A[1],b=A[2];const C=/^([^">]*)("?)/.exec(e[c+1]);S=C[1],t=t.slice(0,-1*A[0].length),a=C[0].length}else a=0;const $={attributeName:f,attributeValuePre:b,attributeValuePost:S,expressionIndex:c};v.push($),!n&&!i&&(t+=" ")}return{template:dy(t),elementsToBindings:o}}function La(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,r={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(r)}}function ky(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))La(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,r=-1;do{const a=t.get(++r);a&&La(a,o,n)}while(o=s.nextNode())}return n}function Sy(e){const{template:t,elementsToBindings:n}=cn(py,e,()=>wy(e)),i=t.cloneNode(!0).content.firstElementChild,s=ky(i,n);return function(r){return by(r,s),i}}function xy(e){const t=cn(hy,e,()=>new Map);let n=fy;function i(o,...r){const a=cn(t,o,()=>new Map);return cn(a,n,()=>Sy(o))(r)}function s(o,r,a){return o.map((u,c)=>{const l=n;n=a(u);try{return r(u,c)}finally{n=l}})}return{map:s,html:i}}function $y(e,t,n,i,s,o,r,a,u){const{labelWithSkin:c,titleForEmoji:l,unicodeWithSkin:d}=n,{html:h,map:v}=xy(t);function f(A,C,T){return v(A,(M,R)=>h`<button role="${C?"option":"menuitem"}" aria-selected="${C?R===t.activeSearchItem:null}" aria-label="${c(M,t.currentSkinTone)}" title="${l(M)}" class="${"emoji"+(C&&R===t.activeSearchItem?" active":"")+(M.unicode?"":" custom-emoji")}" id="${`${T}-${M.id}`}" style="${M.unicode?null:`--custom-emoji-background: url(${JSON.stringify(M.url)})`}">${M.unicode?d(M,t.currentSkinTone):""}</button>`,M=>`${T}-${M.id}`)}const S=h`<section data-ref="rootElement" class="picker" aria-label="${t.i18n.regionLabel}" style="${t.pickerStyle||""}"><div class="pad-top"></div><div class="search-row"><div class="search-wrapper"><input id="search" class="search" type="search" role="combobox" enterkeyhint="search" placeholder="${t.i18n.searchLabel}" autocapitalize="none" autocomplete="off" spellcheck="true" aria-expanded="${!!(t.searchMode&&t.currentEmojis.length)}" aria-controls="search-results" aria-describedby="search-description" aria-autocomplete="list" aria-activedescendant="${t.activeSearchItemId?`emo-${t.activeSearchItemId}`:null}" data-ref="searchElement" data-on-input="onSearchInput" data-on-keydown="onSearchKeydown"><label class="sr-only" for="search">${t.i18n.searchLabel}</label> <span id="search-description" class="sr-only">${t.i18n.searchDescription}</span></div><div class="skintone-button-wrapper ${t.skinTonePickerExpandedAfterAnimation?"expanded":""}"><button id="skintone-button" class="emoji ${t.skinTonePickerExpanded?"hide-focus":""}" aria-label="${t.skinToneButtonLabel}" title="${t.skinToneButtonLabel}" aria-describedby="skintone-description" aria-haspopup="listbox" aria-expanded="${t.skinTonePickerExpanded}" aria-controls="skintone-list" data-on-click="onClickSkinToneButton">${t.skinToneButtonText||""}</button></div><span id="skintone-description" class="sr-only">${t.i18n.skinToneDescription}</span><div data-ref="skinToneDropdown" id="skintone-list" class="skintone-list hide-focus ${t.skinTonePickerExpanded?"":"hidden no-animate"}" style="transform:translateY(${t.skinTonePickerExpanded?0:"calc(-1 * var(--num-skintones) * var(--total-emoji-size))"})" role="listbox" aria-label="${t.i18n.skinTonesLabel}" aria-activedescendant="skintone-${t.activeSkinTone}" aria-hidden="${!t.skinTonePickerExpanded}" tabIndex="-1" data-on-focusout="onSkinToneOptionsFocusOut" data-on-click="onSkinToneOptionsClick" data-on-keydown="onSkinToneOptionsKeydown" data-on-keyup="onSkinToneOptionsKeyup">${v(t.skinTones,(A,C)=>h`<div id="skintone-${C}" class="emoji ${C===t.activeSkinTone?"active":""}" aria-selected="${C===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[C]}" aria-label="${t.i18n.skinTones[C]}">${A}</div>`,A=>A)}</div></div><div class="nav" role="tablist" style="grid-template-columns:repeat(${t.groups.length},1fr)" aria-label="${t.i18n.categoriesLabel}" data-on-keydown="onNavKeydown" data-on-click="onNavClick">${v(t.groups,A=>h`<button role="tab" class="nav-button" aria-controls="tab-${A.id}" aria-label="${t.i18n.categories[A.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===A.id}" title="${t.i18n.categories[A.name]}" data-group-id="${A.id}"><div class="nav-emoji emoji">${A.emoji}</div></button>`,A=>A.id)}</div><div class="indicator-wrapper"><div class="indicator" style="transform:translateX(${(t.isRtl?-1:1)*t.currentGroupIndex*100}%)"></div></div><div class="message ${t.message?"":"gone"}" role="alert" aria-live="polite">${t.message||""}</div><div data-ref="tabpanelElement" class="tabpanel ${!t.databaseLoaded||t.message?"gone":""}" role="${t.searchMode?"region":"tabpanel"}" aria-label="${t.searchMode?t.i18n.searchResultsLabel:t.i18n.categories[t.currentGroup.name]}" id="${t.searchMode?null:`tab-${t.currentGroup.id}`}" tabIndex="0" data-on-click="onEmojiClick"><div data-action="calculateEmojiGridStyle">${v(t.currentEmojisWithCategories,(A,C)=>h`<div><div id="menu-label-${C}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:A.category?A.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${C!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(A.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${C}" id="${t.searchMode?"search-results":null}">${f(A.emojis,t.searchMode,"emo")}</div></div>`,A=>A.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${f(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,$=(A,C)=>{for(const T of e.querySelectorAll(`[${A}]`))C(T,T.getAttribute(A))};if(u){e.appendChild(S);for(const A of["click","focusout","input","keydown","keyup"])$(`data-on-${A}`,(C,T)=>{C.addEventListener(A,i[T])});$("data-ref",(A,C)=>{o[C]=A}),r.addEventListener("abort",()=>{e.removeChild(S)})}$("data-action",(A,C)=>{let T=a.get(C);T||a.set(C,T=new WeakSet),T.has(A)||(T.add(A),s[C](A))})}const yi=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Ay(e){let t=!1,n;const i=new Map,s=new Set;let o;const r=()=>{if(t)return;const c=[...s];s.clear();try{for(const l of c)l()}finally{o=!1,s.size&&(o=!0,yi(r))}},a=new Proxy({},{get(c,l){if(n){let d=i.get(l);d||(d=new Set,i.set(l,d)),d.add(n)}return c[l]},set(c,l,d){if(c[l]!==d){c[l]=d;const h=i.get(l);if(h){for(const v of h)s.add(v);o||(o=!0,yi(r))}}return!0}}),u=c=>{const l=()=>{const d=n;n=l;try{return c()}finally{n=d}};return l()};return e.addEventListener("abort",()=>{t=!0}),{state:a,createEffect:u}}function vs(e,t,n){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}const Ia=new WeakMap;function Ey(e,t,n){{const i=e.closest(".tabpanel");let s=Ia.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),Ia.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const bs=[],{assign:Hn}=Object;function Cy(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:r}=Ay(s),a=new Map;Hn(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),Hn(o,t),Hn(o,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:Vm,isRtl:!1,currentGroupIndex:0,groups:hs,databaseLoaded:!1,activeSearchItemId:void 0}),r(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const u=x=>{e.getElementById(x).focus()},c=x=>e.getElementById(`emo-${x.id}`),l=(x,_)=>{n.rootElement.dispatchEvent(new CustomEvent(x,{detail:_,bubbles:!0,composed:!0}))},d=(x,_)=>x.id===_.id,h=(x,_)=>{const{category:N,emojis:O}=x,{category:V,emojis:z}=_;return N!==V?!1:vs(O,z,d)},v=x=>{vs(o.currentEmojis,x,d)||(o.currentEmojis=x)},f=x=>{o.searchMode!==x&&(o.searchMode=x)},b=x=>{vs(o.currentEmojisWithCategories,x,h)||(o.currentEmojisWithCategories=x)},S=(x,_)=>_&&x.skins&&x.skins[_]||x.unicode,C={labelWithSkin:(x,_)=>cy([x.name||S(x,_),x.annotation,...x.shortcodes||bs].filter(Boolean)).join(", "),titleForEmoji:x=>x.annotation||(x.shortcodes||bs).join(", "),unicodeWithSkin:S},T={onClickSkinToneButton:H,onEmojiClick:xn,onNavClick:kn,onNavKeydown:Di,onSearchKeydown:Ni,onSkinToneOptionsClick:$n,onSkinToneOptionsFocusOut:ze,onSkinToneOptionsKeydown:et,onSkinToneOptionsKeyup:Wt,onSearchInput:An},M={calculateEmojiGridStyle:ee,updateOnIntersection:me};let R=!0;r(()=>{$y(e,o,C,T,M,n,s,a,R),R=!1}),o.emojiVersion||gs().then(x=>{x||(o.message=o.i18n.emojiUnsupportedMessage)}),r(()=>{async function x(){let _=!1;const N=setTimeout(()=>{_=!0,o.message=o.i18n.loadingMessage},Hm);try{await o.database.ready(),o.databaseLoaded=!0}catch(O){console.error(O),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(N),_&&(_=!1,o.message="")}}o.database&&x()}),r(()=>{o.pickerStyle=`
2236
+ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function uy(e){return tu(e,t=>t)}function dy(e){e&&(e.scrollTop=0)}function pn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function La(e){return""+e}function py(e){const t=document.createElement("template");return t.innerHTML=e,t}const hy=new WeakMap,fy=new WeakMap,gy=Symbol("un-keyed"),my="replaceChildren"in Element.prototype;function yy(e,t){my?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function vy(e,t){let n=e.firstChild,i=0;for(;n;){if(t[i]!==n)return!0;n=n.nextSibling,i++}return i!==t.length}function by(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=vy(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&yy(i,e)}function wy(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:r,attributeValuePre:a,attributeValuePost:u}}=n,c=e[o];if(s!==c)if(n.currentExpression=c,r)if(c===null)i.removeAttribute(r);else{const l=a+La(c)+u;i.setAttribute(r,l)}else{let l;Array.isArray(c)?by(c,n):c instanceof Element?(l=c,i.replaceWith(l)):i.nodeValue=La(c),l&&(n.targetNode=l)}}}function ky(e){let t="",n=!1,i=!1,s=-1;const o=new Map,r=[];let a=0;for(let c=0,l=e.length;c<l;c++){const d=e[c];if(t+=d.slice(a),c===l-1)break;for(let A=0;A<d.length;A++)switch(d.charAt(A)){case"<":{d.charAt(A+1)==="/"?r.pop():(n=!0,r.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const h=r[r.length-1],v=pn(o,h,()=>[]);let f,b,S;if(i){const A=/(\S+)="?([^"=]*)$/.exec(d);f=A[1],b=A[2];const C=/^([^">]*)("?)/.exec(e[c+1]);S=C[1],t=t.slice(0,-1*A[0].length),a=C[0].length}else a=0;const $={attributeName:f,attributeValuePre:b,attributeValuePost:S,expressionIndex:c};v.push($),!n&&!i&&(t+=" ")}return{template:py(t),elementsToBindings:o}}function Ia(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,r={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(r)}}function Sy(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))Ia(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,r=-1;do{const a=t.get(++r);a&&Ia(a,o,n)}while(o=s.nextNode())}return n}function xy(e){const{template:t,elementsToBindings:n}=pn(hy,e,()=>ky(e)),i=t.cloneNode(!0).content.firstElementChild,s=Sy(i,n);return function(r){return wy(r,s),i}}function $y(e){const t=pn(fy,e,()=>new Map);let n=gy;function i(o,...r){const a=pn(t,o,()=>new Map);return pn(a,n,()=>xy(o))(r)}function s(o,r,a){return o.map((u,c)=>{const l=n;n=a(u);try{return r(u,c)}finally{n=l}})}return{map:s,html:i}}function Ay(e,t,n,i,s,o,r,a,u){const{labelWithSkin:c,titleForEmoji:l,unicodeWithSkin:d}=n,{html:h,map:v}=$y(t);function f(A,C,T){return v(A,(M,R)=>h`<button role="${C?"option":"menuitem"}" aria-selected="${C?R===t.activeSearchItem:null}" aria-label="${c(M,t.currentSkinTone)}" title="${l(M)}" class="${"emoji"+(C&&R===t.activeSearchItem?" active":"")+(M.unicode?"":" custom-emoji")}" id="${`${T}-${M.id}`}" style="${M.unicode?null:`--custom-emoji-background: url(${JSON.stringify(M.url)})`}">${M.unicode?d(M,t.currentSkinTone):""}</button>`,M=>`${T}-${M.id}`)}const S=h`<section data-ref="rootElement" class="picker" aria-label="${t.i18n.regionLabel}" style="${t.pickerStyle||""}"><div class="pad-top"></div><div class="search-row"><div class="search-wrapper"><input id="search" class="search" type="search" role="combobox" enterkeyhint="search" placeholder="${t.i18n.searchLabel}" autocapitalize="none" autocomplete="off" spellcheck="true" aria-expanded="${!!(t.searchMode&&t.currentEmojis.length)}" aria-controls="search-results" aria-describedby="search-description" aria-autocomplete="list" aria-activedescendant="${t.activeSearchItemId?`emo-${t.activeSearchItemId}`:null}" data-ref="searchElement" data-on-input="onSearchInput" data-on-keydown="onSearchKeydown"><label class="sr-only" for="search">${t.i18n.searchLabel}</label> <span id="search-description" class="sr-only">${t.i18n.searchDescription}</span></div><div class="skintone-button-wrapper ${t.skinTonePickerExpandedAfterAnimation?"expanded":""}"><button id="skintone-button" class="emoji ${t.skinTonePickerExpanded?"hide-focus":""}" aria-label="${t.skinToneButtonLabel}" title="${t.skinToneButtonLabel}" aria-describedby="skintone-description" aria-haspopup="listbox" aria-expanded="${t.skinTonePickerExpanded}" aria-controls="skintone-list" data-on-click="onClickSkinToneButton">${t.skinToneButtonText||""}</button></div><span id="skintone-description" class="sr-only">${t.i18n.skinToneDescription}</span><div data-ref="skinToneDropdown" id="skintone-list" class="skintone-list hide-focus ${t.skinTonePickerExpanded?"":"hidden no-animate"}" style="transform:translateY(${t.skinTonePickerExpanded?0:"calc(-1 * var(--num-skintones) * var(--total-emoji-size))"})" role="listbox" aria-label="${t.i18n.skinTonesLabel}" aria-activedescendant="skintone-${t.activeSkinTone}" aria-hidden="${!t.skinTonePickerExpanded}" tabIndex="-1" data-on-focusout="onSkinToneOptionsFocusOut" data-on-click="onSkinToneOptionsClick" data-on-keydown="onSkinToneOptionsKeydown" data-on-keyup="onSkinToneOptionsKeyup">${v(t.skinTones,(A,C)=>h`<div id="skintone-${C}" class="emoji ${C===t.activeSkinTone?"active":""}" aria-selected="${C===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[C]}" aria-label="${t.i18n.skinTones[C]}">${A}</div>`,A=>A)}</div></div><div class="nav" role="tablist" style="grid-template-columns:repeat(${t.groups.length},1fr)" aria-label="${t.i18n.categoriesLabel}" data-on-keydown="onNavKeydown" data-on-click="onNavClick">${v(t.groups,A=>h`<button role="tab" class="nav-button" aria-controls="tab-${A.id}" aria-label="${t.i18n.categories[A.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===A.id}" title="${t.i18n.categories[A.name]}" data-group-id="${A.id}"><div class="nav-emoji emoji">${A.emoji}</div></button>`,A=>A.id)}</div><div class="indicator-wrapper"><div class="indicator" style="transform:translateX(${(t.isRtl?-1:1)*t.currentGroupIndex*100}%)"></div></div><div class="message ${t.message?"":"gone"}" role="alert" aria-live="polite">${t.message||""}</div><div data-ref="tabpanelElement" class="tabpanel ${!t.databaseLoaded||t.message?"gone":""}" role="${t.searchMode?"region":"tabpanel"}" aria-label="${t.searchMode?t.i18n.searchResultsLabel:t.i18n.categories[t.currentGroup.name]}" id="${t.searchMode?null:`tab-${t.currentGroup.id}`}" tabIndex="0" data-on-click="onEmojiClick"><div data-action="calculateEmojiGridStyle">${v(t.currentEmojisWithCategories,(A,C)=>h`<div><div id="menu-label-${C}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:A.category?A.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${C!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(A.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${C}" id="${t.searchMode?"search-results":null}">${f(A.emojis,t.searchMode,"emo")}</div></div>`,A=>A.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${f(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,$=(A,C)=>{for(const T of e.querySelectorAll(`[${A}]`))C(T,T.getAttribute(A))};if(u){e.appendChild(S);for(const A of["click","focusout","input","keydown","keyup"])$(`data-on-${A}`,(C,T)=>{C.addEventListener(A,i[T])});$("data-ref",(A,C)=>{o[C]=A}),r.addEventListener("abort",()=>{e.removeChild(S)})}$("data-action",(A,C)=>{let T=a.get(C);T||a.set(C,T=new WeakSet),T.has(A)||(T.add(A),s[C](A))})}const vi=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Ey(e){let t=!1,n;const i=new Map,s=new Set;let o;const r=()=>{if(t)return;const c=[...s];s.clear();try{for(const l of c)l()}finally{o=!1,s.size&&(o=!0,vi(r))}},a=new Proxy({},{get(c,l){if(n){let d=i.get(l);d||(d=new Set,i.set(l,d)),d.add(n)}return c[l]},set(c,l,d){if(c[l]!==d){c[l]=d;const h=i.get(l);if(h){for(const v of h)s.add(v);o||(o=!0,vi(r))}}return!0}}),u=c=>{const l=()=>{const d=n;n=l;try{return c()}finally{n=d}};return l()};return e.addEventListener("abort",()=>{t=!0}),{state:a,createEffect:u}}function bs(e,t,n){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}const Ra=new WeakMap;function Cy(e,t,n){{const i=e.closest(".tabpanel");let s=Ra.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),Ra.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const ws=[],{assign:qn}=Object;function Ty(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:r}=Ey(s),a=new Map;qn(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),qn(o,t),qn(o,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:Gm,isRtl:!1,currentGroupIndex:0,groups:fs,databaseLoaded:!1,activeSearchItemId:void 0}),r(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const u=x=>{e.getElementById(x).focus()},c=x=>e.getElementById(`emo-${x.id}`),l=(x,_)=>{n.rootElement.dispatchEvent(new CustomEvent(x,{detail:_,bubbles:!0,composed:!0}))},d=(x,_)=>x.id===_.id,h=(x,_)=>{const{category:N,emojis:O}=x,{category:V,emojis:z}=_;return N!==V?!1:bs(O,z,d)},v=x=>{bs(o.currentEmojis,x,d)||(o.currentEmojis=x)},f=x=>{o.searchMode!==x&&(o.searchMode=x)},b=x=>{bs(o.currentEmojisWithCategories,x,h)||(o.currentEmojisWithCategories=x)},S=(x,_)=>_&&x.skins&&x.skins[_]||x.unicode,C={labelWithSkin:(x,_)=>uy([x.name||S(x,_),x.annotation,...x.shortcodes||ws].filter(Boolean)).join(", "),titleForEmoji:x=>x.annotation||(x.shortcodes||ws).join(", "),unicodeWithSkin:S},T={onClickSkinToneButton:H,onEmojiClick:$n,onNavClick:Sn,onNavKeydown:Oi,onSearchKeydown:Di,onSkinToneOptionsClick:An,onSkinToneOptionsFocusOut:ze,onSkinToneOptionsKeydown:et,onSkinToneOptionsKeyup:jt,onSearchInput:En},M={calculateEmojiGridStyle:ee,updateOnIntersection:me};let R=!0;r(()=>{Ay(e,o,C,T,M,n,s,a,R),R=!1}),o.emojiVersion||ms().then(x=>{x||(o.message=o.i18n.emojiUnsupportedMessage)}),r(()=>{async function x(){let _=!1;const N=setTimeout(()=>{_=!0,o.message=o.i18n.loadingMessage},qm);try{await o.database.ready(),o.databaseLoaded=!0}catch(O){console.error(O),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(N),_&&(_=!1,o.message="")}}o.database&&x()}),r(()=>{o.pickerStyle=`
2228
2237
  --num-groups: ${o.groups.length};
2229
2238
  --indicator-opacity: ${o.searchMode?0:1};
2230
- --num-skintones: ${Ca};`}),r(()=>{o.customEmoji&&o.database&&B()}),r(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Vs&&(o.groups=Vs):o.groups!==hs&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=hs)}),r(()=>{async function x(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}x()}),r(()=>{o.skinTones=Array(Ca).fill().map((x,_)=>sy(o.skinToneEmoji,_))}),r(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),r(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),r(()=>{async function x(){const{database:_}=o,N=(await Promise.all(Gm.map(O=>_.getEmojiByUnicodeOrName(O)))).filter(Boolean);o.defaultFavoriteEmojis=N}o.databaseLoaded&&x()});function B(){const{customEmoji:x,database:_}=o,N=x||bs;_.customEmoji!==N&&(_.customEmoji=N)}r(()=>{async function x(){B();const{database:_,defaultFavoriteEmojis:N,numColumns:O}=o,V=await _.getTopFavoriteEmoji(O),z=await Je(tu([...V,...N],ae=>ae.unicode||ae.name).slice(0,O));o.currentFavorites=z}o.databaseLoaded&&o.defaultFavoriteEmojis&&x()});function ee(x){ay(x,s,()=>{{const _=getComputedStyle(n.rootElement),N=parseInt(_.getPropertyValue("--num-columns"),10),O=_.getPropertyValue("direction")==="rtl";o.numColumns=N,o.isRtl=O}})}function me(x){Ey(x,s,_=>{for(const{target:N,isIntersecting:O}of _)N.classList.toggle("onscreen",O)})}r(()=>{async function x(){const{searchText:_,currentGroup:N,databaseLoaded:O,customEmoji:V}=o;if(!O)o.currentEmojis=[],o.searchMode=!1;else if(_.length>=zm){const z=await Ri(_);o.searchText===_&&(v(z),f(!0))}else{const{id:z}=N;if(z!==-1||V&&V.length){const ae=await Ii(z);o.currentGroup.id===z&&(v(ae),f(!1))}}}x()});const Ke=()=>{Zn(()=>uy(n.tabpanelElement))};r(()=>{const{currentEmojis:x,emojiVersion:_}=o,N=x.filter(O=>O.unicode).filter(O=>Ta(O)&&!Gs.has(O.unicode));if(!_&&N.length)v(x),Zn(()=>Z(N));else{const O=_?x:x.filter(Ut);v(O),Ke()}});function Z(x){ly(x,n.baselineEmoji,c)?Ke():o.currentEmojis=[...o.currentEmojis]}function Ut(x){return!x.unicode||!Ta(x)||Gs.get(x.unicode)}async function wt(x){const _=o.emojiVersion||await gs();return x.filter(({version:N})=>!N||N<=_)}async function Je(x){return oy(x,o.emojiVersion||await gs())}async function Ii(x){const _=x===-1?o.customEmoji:await o.database.getEmojiByGroup(x);return Je(await wt(_))}async function Ri(x){return Je(await wt(await o.database.getEmojiBySearchQuery(x)))}r(()=>{}),r(()=>{function x(){const{searchMode:N,currentEmojis:O}=o;if(N)return[{category:"",emojis:O}];const V=new Map;for(const z of O){const ae=z.category||"";let je=V.get(ae);je||(je=[],V.set(ae,je)),je.push(z)}return[...V.entries()].map(([z,ae])=>({category:z,emojis:ae})).sort((z,ae)=>o.customCategorySorting(z.category,ae.category))}const _=x();b(_)}),r(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),r(()=>{const{rawSearchText:x}=o;Jc(()=>{o.searchText=(x||"").trim(),o.activeSearchItem=-1})});function Ni(x){if(!o.searchMode||!o.currentEmojis.length)return;const _=N=>{Ee(x),o.activeSearchItem=ms(N,o.activeSearchItem,o.currentEmojis)};switch(x.key){case"ArrowDown":return _(!1);case"ArrowUp":return _(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Ee(x),Q(o.currentEmojis[o.activeSearchItem].id)}}function kn(x){const{target:_}=x,N=_.closest(".nav-button");if(!N)return;const O=parseInt(N.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(V=>V.id===O)}function Di(x){const{target:_,key:N}=x,O=V=>{V&&(Ee(x),V.focus())};switch(N){case"ArrowLeft":return O(_.previousElementSibling);case"ArrowRight":return O(_.nextElementSibling);case"Home":return O(_.parentElement.firstElementChild);case"End":return O(_.parentElement.lastElementChild)}}async function Sn(x){const _=await o.database.getEmojiByUnicodeOrName(x),N=[...o.currentEmojis,...o.currentFavorites].find(V=>V.id===x),O=N.unicode&&S(N,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(x),{emoji:_,skinTone:o.currentSkinTone,...O&&{unicode:O},...N.name&&{name:N.name}}}async function Q(x){const _=Sn(x);l("emoji-click-sync",_),l("emoji-click",await _)}function xn(x){const{target:_}=x;if(!_.classList.contains("emoji"))return;Ee(x);const N=_.id.substring(4);Q(N)}function Y(x){o.currentSkinTone=x,o.skinTonePickerExpanded=!1,u("skintone-button"),l("skin-tone-change",{skinTone:x}),o.database.setPreferredSkinTone(x)}function $n(x){const{target:{id:_}}=x,N=_&&_.match(/^skintone-(\d)/);if(!N)return;Ee(x);const O=parseInt(N[1],10);Y(O)}function H(x){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Ee(x),Zn(()=>u("skintone-list")))}r(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function et(x){if(!o.skinTonePickerExpanded)return;const _=async N=>{Ee(x),o.activeSkinTone=N};switch(x.key){case"ArrowUp":return _(ms(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return _(ms(!1,o.activeSkinTone,o.skinTones));case"Home":return _(0);case"End":return _(o.skinTones.length-1);case"Enter":return Ee(x),Y(o.activeSkinTone);case"Escape":return Ee(x),o.skinTonePickerExpanded=!1,u("skintone-button")}}function Wt(x){if(o.skinTonePickerExpanded&&x.key===" ")return Ee(x),Y(o.activeSkinTone)}async function ze(x){const{relatedTarget:_}=x;(!_||_.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function An(x){o.rawSearchText=x.target.value}return{$set(x){Hn(o,x)},$destroy(){i.abort()}}}const Ty="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",_y="en";var My={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"}},Py=':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 nu=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Ly=`:host{--emoji-font-family:${eu}}`;class jo extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Py+Ly,this.shadowRoot.appendChild(n),this._ctx={locale:_y,dataSource:Ty,skinToneEmoji:qm,customCategorySorting:Qm,customEmoji:null,i18n:My,emojiVersion:null,...t};for(const i of nu)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){Ra(this),this._cmp||(this._cmp=Cy(this.shadowRoot,this._ctx))}disconnectedCallback(){Ra(this),yi(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:t}=this._ctx;t.close().catch(n=>console.error(n))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(t,n,i){this._set(t.replace(/-([a-z])/g,(s,o)=>o.toUpperCase()),t==="emoji-version"?parseFloat(i):i)}_set(t,n){this._ctx[t]=n,this._cmp&&this._cmp.$set({[t]:n}),["locale","dataSource"].includes(t)&&this._dbFlush()}_dbCreate(){const{locale:t,dataSource:n,database:i}=this._ctx;(!i||i.locale!==t||i.dataSource!==n)&&this._set("database",new Km({locale:t,dataSource:n}))}_dbFlush(){yi(()=>this._dbCreate())}}const iu={};for(const e of nu)iu[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(jo.prototype,iu);function Ra(e){e instanceof jo||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",jo);function Iy(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 Na(e){e.style.height="44px",e.style.overflowY="hidden"}const Ry=5e3;function Ny(e){return e?e.active?p`
2239
+ --num-skintones: ${Ta};`}),r(()=>{o.customEmoji&&o.database&&B()}),r(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Gs&&(o.groups=Gs):o.groups!==fs&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=fs)}),r(()=>{async function x(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}x()}),r(()=>{o.skinTones=Array(Ta).fill().map((x,_)=>oy(o.skinToneEmoji,_))}),r(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),r(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),r(()=>{async function x(){const{database:_}=o,N=(await Promise.all(Qm.map(O=>_.getEmojiByUnicodeOrName(O)))).filter(Boolean);o.defaultFavoriteEmojis=N}o.databaseLoaded&&x()});function B(){const{customEmoji:x,database:_}=o,N=x||ws;_.customEmoji!==N&&(_.customEmoji=N)}r(()=>{async function x(){B();const{database:_,defaultFavoriteEmojis:N,numColumns:O}=o,V=await _.getTopFavoriteEmoji(O),z=await Je(tu([...V,...N],ae=>ae.unicode||ae.name).slice(0,O));o.currentFavorites=z}o.databaseLoaded&&o.defaultFavoriteEmojis&&x()});function ee(x){ly(x,s,()=>{{const _=getComputedStyle(n.rootElement),N=parseInt(_.getPropertyValue("--num-columns"),10),O=_.getPropertyValue("direction")==="rtl";o.numColumns=N,o.isRtl=O}})}function me(x){Cy(x,s,_=>{for(const{target:N,isIntersecting:O}of _)N.classList.toggle("onscreen",O)})}r(()=>{async function x(){const{searchText:_,currentGroup:N,databaseLoaded:O,customEmoji:V}=o;if(!O)o.currentEmojis=[],o.searchMode=!1;else if(_.length>=jm){const z=await Ni(_);o.searchText===_&&(v(z),f(!0))}else{const{id:z}=N;if(z!==-1||V&&V.length){const ae=await Ri(z);o.currentGroup.id===z&&(v(ae),f(!1))}}}x()});const Ke=()=>{Jn(()=>dy(n.tabpanelElement))};r(()=>{const{currentEmojis:x,emojiVersion:_}=o,N=x.filter(O=>O.unicode).filter(O=>_a(O)&&!Qs.has(O.unicode));if(!_&&N.length)v(x),Jn(()=>Z(N));else{const O=_?x:x.filter(zt);v(O),Ke()}});function Z(x){cy(x,n.baselineEmoji,c)?Ke():o.currentEmojis=[...o.currentEmojis]}function zt(x){return!x.unicode||!_a(x)||Qs.get(x.unicode)}async function kt(x){const _=o.emojiVersion||await ms();return x.filter(({version:N})=>!N||N<=_)}async function Je(x){return ry(x,o.emojiVersion||await ms())}async function Ri(x){const _=x===-1?o.customEmoji:await o.database.getEmojiByGroup(x);return Je(await kt(_))}async function Ni(x){return Je(await kt(await o.database.getEmojiBySearchQuery(x)))}r(()=>{}),r(()=>{function x(){const{searchMode:N,currentEmojis:O}=o;if(N)return[{category:"",emojis:O}];const V=new Map;for(const z of O){const ae=z.category||"";let je=V.get(ae);je||(je=[],V.set(ae,je)),je.push(z)}return[...V.entries()].map(([z,ae])=>({category:z,emojis:ae})).sort((z,ae)=>o.customCategorySorting(z.category,ae.category))}const _=x();b(_)}),r(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),r(()=>{const{rawSearchText:x}=o;Jc(()=>{o.searchText=(x||"").trim(),o.activeSearchItem=-1})});function Di(x){if(!o.searchMode||!o.currentEmojis.length)return;const _=N=>{Ee(x),o.activeSearchItem=ys(N,o.activeSearchItem,o.currentEmojis)};switch(x.key){case"ArrowDown":return _(!1);case"ArrowUp":return _(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Ee(x),Q(o.currentEmojis[o.activeSearchItem].id)}}function Sn(x){const{target:_}=x,N=_.closest(".nav-button");if(!N)return;const O=parseInt(N.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(V=>V.id===O)}function Oi(x){const{target:_,key:N}=x,O=V=>{V&&(Ee(x),V.focus())};switch(N){case"ArrowLeft":return O(_.previousElementSibling);case"ArrowRight":return O(_.nextElementSibling);case"Home":return O(_.parentElement.firstElementChild);case"End":return O(_.parentElement.lastElementChild)}}async function xn(x){const _=await o.database.getEmojiByUnicodeOrName(x),N=[...o.currentEmojis,...o.currentFavorites].find(V=>V.id===x),O=N.unicode&&S(N,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(x),{emoji:_,skinTone:o.currentSkinTone,...O&&{unicode:O},...N.name&&{name:N.name}}}async function Q(x){const _=xn(x);l("emoji-click-sync",_),l("emoji-click",await _)}function $n(x){const{target:_}=x;if(!_.classList.contains("emoji"))return;Ee(x);const N=_.id.substring(4);Q(N)}function Y(x){o.currentSkinTone=x,o.skinTonePickerExpanded=!1,u("skintone-button"),l("skin-tone-change",{skinTone:x}),o.database.setPreferredSkinTone(x)}function An(x){const{target:{id:_}}=x,N=_&&_.match(/^skintone-(\d)/);if(!N)return;Ee(x);const O=parseInt(N[1],10);Y(O)}function H(x){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Ee(x),Jn(()=>u("skintone-list")))}r(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function et(x){if(!o.skinTonePickerExpanded)return;const _=async N=>{Ee(x),o.activeSkinTone=N};switch(x.key){case"ArrowUp":return _(ys(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return _(ys(!1,o.activeSkinTone,o.skinTones));case"Home":return _(0);case"End":return _(o.skinTones.length-1);case"Enter":return Ee(x),Y(o.activeSkinTone);case"Escape":return Ee(x),o.skinTonePickerExpanded=!1,u("skintone-button")}}function jt(x){if(o.skinTonePickerExpanded&&x.key===" ")return Ee(x),Y(o.activeSkinTone)}async function ze(x){const{relatedTarget:_}=x;(!_||_.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function En(x){o.rawSearchText=x.target.value}return{$set(x){qn(o,x)},$destroy(){i.abort()}}}const _y="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",My="en";var Py={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"}},Ly=':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 nu=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Iy=`:host{--emoji-font-family:${eu}}`;class Ho extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Ly+Iy,this.shadowRoot.appendChild(n),this._ctx={locale:My,dataSource:_y,skinToneEmoji:Vm,customCategorySorting:Ym,customEmoji:null,i18n:Py,emojiVersion:null,...t};for(const i of nu)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){Na(this),this._cmp||(this._cmp=Ty(this.shadowRoot,this._ctx))}disconnectedCallback(){Na(this),vi(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:t}=this._ctx;t.close().catch(n=>console.error(n))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(t,n,i){this._set(t.replace(/-([a-z])/g,(s,o)=>o.toUpperCase()),t==="emoji-version"?parseFloat(i):i)}_set(t,n){this._ctx[t]=n,this._cmp&&this._cmp.$set({[t]:n}),["locale","dataSource"].includes(t)&&this._dbFlush()}_dbCreate(){const{locale:t,dataSource:n,database:i}=this._ctx;(!i||i.locale!==t||i.dataSource!==n)&&this._set("database",new zm({locale:t,dataSource:n}))}_dbFlush(){vi(()=>this._dbCreate())}}const iu={};for(const e of nu)iu[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(Ho.prototype,iu);function Na(e){e instanceof Ho||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Ho);function Ry(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 Da(e){e.style.height="44px",e.style.overflowY="hidden"}const Ny=5e3;function Dy(e){return e?e.active?p`
2231
2240
  <div class="callout info compaction-indicator compaction-indicator--active">
2232
2241
  ${D.loader} Compacting context...
2233
2242
  </div>
2234
- `:e.completedAt&&Date.now()-e.completedAt<Ry?p`
2243
+ `:e.completedAt&&Date.now()-e.completedAt<Ny?p`
2235
2244
  <div class="callout success compaction-indicator compaction-indicator--complete">
2236
2245
  ${D.check} Context compacted
2237
2246
  </div>
2238
- `:k:k}const Be=5*1024*1024;function Fe(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function ke(e,t){var i,s,o;let n=(i=e.closest(".chat"))==null?void 0:i.querySelector(".chat-attachment-error");if(!n){n=document.createElement("div"),n.className="callout danger chat-attachment-error",n.style.cssText="margin: 8px 4px; animation: fade-in 200ms ease-out;";const r=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(o=r==null?void 0:r.parentElement)==null||o.insertBefore(n,r)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const Dy=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function su(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function ou(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||Dy.test(e.name)}function ru(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function au(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function Oy(e,t){if(!t.onAttachmentsChange)return;const n=document.querySelector(".chat");if(su(e)){if(e.size>Be){n&&ke(n,`Image too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Fe(),dataUrl:i.result,mimeType:e.type};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(ou(e)){if(e.size>Be){n&&ke(n,`File too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Fe(),dataUrl:"",mimeType:e.type||"text/plain",fileName:e.name,textContent:i.result};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsText(e)}else if(ru(e)){if(e.size>Be){n&&ke(n,`PDF too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Fe(),dataUrl:i.result,mimeType:"application/pdf",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(au(e)){if(e.size>Be){n&&ke(n,`Video too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Fe(),dataUrl:i.result,mimeType:e.type||"video/mp4",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else n&&ke(n,`Unsupported file type: ${e.name}. Use the Files page to upload to workspace.`)}function By(e,t){var s;e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const i=(s=e.dataTransfer)==null?void 0:s.files;if(!(!i||i.length===0))for(let o=0;o<i.length;o++){const r=i[o];if(su(r)){if(!t.onAttachmentsChange)continue;if(r.size>Be){ke(n,`Image too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const u=a.result,c={id:Fe(),dataUrl:u,mimeType:r.type},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,c])},a.readAsDataURL(r)}else if(ou(r)){if(!t.onAttachmentsChange)continue;if(r.size>Be){ke(n,`File too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const u=a.result,c={id:Fe(),dataUrl:"",mimeType:r.type||"text/plain",fileName:r.name,textContent:u},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,c])},a.readAsText(r)}else if(ru(r)){if(!t.onAttachmentsChange)continue;if(r.size>Be){ke(n,`PDF too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const u=a.result,c={id:Fe(),dataUrl:u,mimeType:"application/pdf",fileName:r.name},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,c])},a.readAsDataURL(r)}else if(au(r)){if(!t.onAttachmentsChange)continue;if(r.size>Be){ke(n,`Video too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const u=a.result,c={id:Fe(),dataUrl:u,mimeType:r.type||"video/mp4",fileName:r.name},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,c])},a.readAsDataURL(r)}else ke(n,`Unsupported file type: ${r.name}. Use the Files page to upload to workspace.`)}}function Fy(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Uy(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function Wy(e,t){var s,o,r;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n||!t.onAttachmentsChange)return;const i=[];for(let a=0;a<n.length;a++){const u=n[a];(u.type.startsWith("image/")||u.type.startsWith("video/"))&&i.push(u)}if(i.length!==0){e.preventDefault();for(const a of i){const u=a.getAsFile();if(!u)continue;const c=u.type.startsWith("video/")?"Video":"Image";if(u.size>Be){const d=((r=(o=e.target)==null?void 0:o.closest)==null?void 0:r.call(o,".chat"))??document.querySelector(".chat");d&&ke(d,`${c} too large (${(u.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const l=new FileReader;l.onload=()=>{var b;const d=l.result,h=u.type.startsWith("video/"),v={id:Fe(),dataUrl:d,mimeType:u.type,fileName:h?u.name||"video.mp4":void 0},f=t.attachments??[];(b=t.onAttachmentsChange)==null||b.call(t,[...f,v])},l.readAsDataURL(u)}}}function Ky(e){const t=e.currentTarget,n=t.closest(".chat-compose"),i=n==null?void 0:n.querySelector(".emoji-picker-popup");if(!i)return;const s=i.classList.toggle("active");if(t.classList.toggle("active",s),s){const o=r=>{i.contains(r.target)||t.contains(r.target)||(i.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",o,!0))};requestAnimationFrame(()=>document.addEventListener("click",o,!0))}}function zy(e,t){const n=e.detail,i=n==null?void 0:n.unicode;if(!i)return;const s=e.currentTarget.closest(".chat-compose"),o=s==null?void 0:s.querySelector("textarea");if(!o)return;const r=o.selectionStart??t.draft.length,a=o.selectionEnd??r,u=t.draft.slice(0,r),c=t.draft.slice(a);t.onDraftChange(u+i+c);const l=s==null?void 0:s.querySelector(".emoji-picker-popup"),d=s==null?void 0:s.querySelector(".chat-compose__emoji");l==null||l.classList.remove("active"),d==null||d.classList.remove("active"),requestAnimationFrame(()=>{o.focus();const h=r+i.length;o.setSelectionRange(h,h)})}function jy(e){const t=e.attachments??[];return t.length===0?k:p`
2247
+ `:k:k}const Fe=5*1024*1024;function Ue(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function ke(e,t){var i,s,o;let n=(i=e.closest(".chat"))==null?void 0:i.querySelector(".chat-attachment-error");if(!n){n=document.createElement("div"),n.className="callout danger chat-attachment-error",n.style.cssText="margin: 8px 4px; animation: fade-in 200ms ease-out;";const r=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(o=r==null?void 0:r.parentElement)==null||o.insertBefore(n,r)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const Oy=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function su(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function ou(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||Oy.test(e.name)}function ru(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function au(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function By(e,t){if(!t.onAttachmentsChange)return;const n=document.querySelector(".chat");if(su(e)){if(e.size>Fe){n&&ke(n,`Image too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Ue(),dataUrl:i.result,mimeType:e.type};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(ou(e)){if(e.size>Fe){n&&ke(n,`File too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Ue(),dataUrl:"",mimeType:e.type||"text/plain",fileName:e.name,textContent:i.result};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsText(e)}else if(ru(e)){if(e.size>Fe){n&&ke(n,`PDF too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Ue(),dataUrl:i.result,mimeType:"application/pdf",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(au(e)){if(e.size>Fe){n&&ke(n,`Video too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Ue(),dataUrl:i.result,mimeType:e.type||"video/mp4",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else n&&ke(n,`Unsupported file type: ${e.name}. Use the Files page to upload to workspace.`)}function Fy(e,t){var s;e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const i=(s=e.dataTransfer)==null?void 0:s.files;if(!(!i||i.length===0))for(let o=0;o<i.length;o++){const r=i[o];if(su(r)){if(!t.onAttachmentsChange)continue;if(r.size>Fe){ke(n,`Image too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const u=a.result,c={id:Ue(),dataUrl:u,mimeType:r.type},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,c])},a.readAsDataURL(r)}else if(ou(r)){if(!t.onAttachmentsChange)continue;if(r.size>Fe){ke(n,`File too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const u=a.result,c={id:Ue(),dataUrl:"",mimeType:r.type||"text/plain",fileName:r.name,textContent:u},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,c])},a.readAsText(r)}else if(ru(r)){if(!t.onAttachmentsChange)continue;if(r.size>Fe){ke(n,`PDF too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const u=a.result,c={id:Ue(),dataUrl:u,mimeType:"application/pdf",fileName:r.name},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,c])},a.readAsDataURL(r)}else if(au(r)){if(!t.onAttachmentsChange)continue;if(r.size>Fe){ke(n,`Video too large (${(r.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var d;const u=a.result,c={id:Ue(),dataUrl:u,mimeType:r.type||"video/mp4",fileName:r.name},l=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...l,c])},a.readAsDataURL(r)}else ke(n,`Unsupported file type: ${r.name}. Use the Files page to upload to workspace.`)}}function Uy(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Wy(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function Ky(e,t){var s,o,r;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n||!t.onAttachmentsChange)return;const i=[];for(let a=0;a<n.length;a++){const u=n[a];(u.type.startsWith("image/")||u.type.startsWith("video/"))&&i.push(u)}if(i.length!==0){e.preventDefault();for(const a of i){const u=a.getAsFile();if(!u)continue;const c=u.type.startsWith("video/")?"Video":"Image";if(u.size>Fe){const d=((r=(o=e.target)==null?void 0:o.closest)==null?void 0:r.call(o,".chat"))??document.querySelector(".chat");d&&ke(d,`${c} too large (${(u.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const l=new FileReader;l.onload=()=>{var b;const d=l.result,h=u.type.startsWith("video/"),v={id:Ue(),dataUrl:d,mimeType:u.type,fileName:h?u.name||"video.mp4":void 0},f=t.attachments??[];(b=t.onAttachmentsChange)==null||b.call(t,[...f,v])},l.readAsDataURL(u)}}}function zy(e){const t=e.currentTarget,n=t.closest(".chat-compose"),i=n==null?void 0:n.querySelector(".emoji-picker-popup");if(!i)return;const s=i.classList.toggle("active");if(t.classList.toggle("active",s),s){const o=r=>{i.contains(r.target)||t.contains(r.target)||(i.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",o,!0))};requestAnimationFrame(()=>document.addEventListener("click",o,!0))}}function jy(e,t){const n=e.detail,i=n==null?void 0:n.unicode;if(!i)return;const s=e.currentTarget.closest(".chat-compose"),o=s==null?void 0:s.querySelector("textarea");if(!o)return;const r=o.selectionStart??t.draft.length,a=o.selectionEnd??r,u=t.draft.slice(0,r),c=t.draft.slice(a);t.onDraftChange(u+i+c);const l=s==null?void 0:s.querySelector(".emoji-picker-popup"),d=s==null?void 0:s.querySelector(".chat-compose__emoji");l==null||l.classList.remove("active"),d==null||d.classList.remove("active"),requestAnimationFrame(()=>{o.focus();const h=r+i.length;o.setSelectionRange(h,h)})}function Hy(e){const t=e.attachments??[];return t.length===0?k:p`
2239
2248
  <div class="chat-attachments">
2240
2249
  ${t.map(n=>{var i;return n.fileName?p`
2241
2250
  <div class="chat-attachment chat-attachment--file">
@@ -2279,20 +2288,20 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
2279
2288
  ${e.loadingOlder?p`<span class="chat-load-more__spinner">${D.loader}</span> Loading older messages…`:p`<button class="chat-load-more__btn" type="button" @click=${e.onLoadOlder}>Load older messages</button>`}
2280
2289
  </div>`:k}
2281
2290
  ${e.loading?p`<div class="muted">Loading chat…</div>`:k}
2282
- ${Af(Xy(e),b=>b.key,b=>b.kind==="interim"?Qg(b.text):b.kind==="reading-indicator"?Gg():b.kind==="stream"?Yg(b.text,b.startedAt,e.onOpenSidebar):b.kind==="group"?Xg(b,{onOpenSidebar:e.onOpenSidebar,showReasoning:r,assistantName:e.assistantName}):k)}
2291
+ ${Ef(Zy(e),b=>b.key,b=>b.kind==="interim"?Yg(b.text):b.kind==="reading-indicator"?Qg():b.kind==="stream"?Xg(b.text,b.startedAt,e.onOpenSidebar):b.kind==="group"?Zg(b,{onOpenSidebar:e.onOpenSidebar,showReasoning:r,assistantName:e.assistantName}):k)}
2283
2292
  </div>
2284
2293
  `;return p`
2285
2294
  <section
2286
2295
  class="card chat"
2287
- @drop=${b=>By(b,e)}
2288
- @dragover=${Fy}
2289
- @dragleave=${Uy}
2296
+ @drop=${b=>Fy(b,e)}
2297
+ @dragover=${Uy}
2298
+ @dragleave=${Wy}
2290
2299
  >
2291
2300
  ${e.disabledReason?p`<div class="callout">${e.disabledReason}</div>`:k}
2292
2301
 
2293
2302
  ${e.error?p`<div class="callout danger">${e.error}</div>`:k}
2294
2303
 
2295
- ${Ny(e.compactionStatus)}
2304
+ ${Dy(e.compactionStatus)}
2296
2305
 
2297
2306
  ${e.focusMode?p`
2298
2307
  <button
@@ -2333,7 +2342,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
2333
2342
  @resize=${b=>{var S;return(S=e.onSplitRatioChange)==null?void 0:S.call(e,b.detail.splitRatio)}}
2334
2343
  ></resizable-divider>
2335
2344
  <div class="chat-sidebar">
2336
- ${Jg({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
2345
+ ${em({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
2337
2346
  ${e.sidebarContent}
2338
2347
  \`\`\``)}})}
2339
2348
  </div>
@@ -2353,12 +2362,12 @@ ${e.sidebarContent}
2353
2362
  `:k}
2354
2363
 
2355
2364
  <div class="chat-compose">
2356
- ${jy(e)}
2365
+ ${Hy(e)}
2357
2366
  <div class="chat-compose__row">
2358
2367
  <button
2359
2368
  class="chat-compose__emoji"
2360
2369
  type="button"
2361
- @click=${Ky}
2370
+ @click=${zy}
2362
2371
  aria-label="Emoji"
2363
2372
  title="Emoji"
2364
2373
  >
@@ -2379,16 +2388,16 @@ ${e.sidebarContent}
2379
2388
  multiple
2380
2389
  accept="image/*,video/*,.pdf,.md,.txt,.csv,.json,.xml,.html,.css,.js,.ts,.py,.sh,.yaml,.yml,.toml,.ini,.cfg,.log,.sql"
2381
2390
  style="display:none"
2382
- @change=${b=>{const S=b.target,$=S.files;if(!(!$||$.length===0||!e.onAttachmentsChange)){for(let A=0;A<$.length;A++)Oy($[A],e);S.value=""}}}
2391
+ @change=${b=>{const S=b.target,$=S.files;if(!(!$||$.length===0||!e.onAttachmentsChange)){for(let A=0;A<$.length;A++)By($[A],e);S.value=""}}}
2383
2392
  />
2384
2393
  <label class="field chat-compose__field">
2385
2394
  <span>Message</span>
2386
2395
  <textarea
2387
2396
  .value=${e.draft}
2388
2397
  ?disabled=${!e.connected}
2389
- @keydown=${b=>{b.key==="Enter"&&(b.isComposing||b.keyCode===229||b.shiftKey||e.connected&&(b.preventDefault(),t&&(e.onSend(),Na(b.target))))}}
2390
- @input=${b=>{const S=b.target;e.onDraftChange(S.value),Iy(S)}}
2391
- @paste=${b=>Wy(b,e)}
2398
+ @keydown=${b=>{b.key==="Enter"&&(b.isComposing||b.keyCode===229||b.shiftKey||e.connected&&(b.preventDefault(),t&&(e.onSend(),Da(b.target))))}}
2399
+ @input=${b=>{const S=b.target;e.onDraftChange(S.value),Ry(S)}}
2400
+ @paste=${b=>Ky(b,e)}
2392
2401
  placeholder=${u}
2393
2402
  ></textarea>
2394
2403
  </label>
@@ -2405,7 +2414,7 @@ ${e.sidebarContent}
2405
2414
  <button
2406
2415
  class="btn btn--icon chat-compose__send primary"
2407
2416
  ?disabled=${!e.connected}
2408
- @click=${b=>{var $;e.onSend();const S=($=b.target.closest(".chat-compose"))==null?void 0:$.querySelector("textarea");S&&Na(S)}}
2417
+ @click=${b=>{var $;e.onSend();const S=($=b.target.closest(".chat-compose"))==null?void 0:$.querySelector("textarea");S&&Da(S)}}
2409
2418
  aria-label="${n?"Queue":"Send"}"
2410
2419
  title="${n?"Queue message":"Send (Enter)"}"
2411
2420
  >
@@ -2414,13 +2423,13 @@ ${e.sidebarContent}
2414
2423
  </div>
2415
2424
  <div class="emoji-picker-popup">
2416
2425
  <emoji-picker
2417
- @emoji-click=${b=>zy(b,e)}
2426
+ @emoji-click=${b=>jy(b,e)}
2418
2427
  ></emoji-picker>
2419
2428
  </div>
2420
- ${e.publicMode?k:Qy(e)}
2429
+ ${e.publicMode?k:Yy(e)}
2421
2430
  </div>
2422
2431
  </section>
2423
- `}const Hy=[{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 qy(e){const t=new Set(e.filter(n=>n.provider==="anthropic").map(n=>n.id));return Hy.filter(n=>t.has(n.id)).map(n=>({key:`anthropic/${n.id}`,...n}))}const Vy=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function Gy(e){var s;const t=e.currentTarget,n=(s=t.closest(".chat-model-bar"))==null?void 0:s.querySelector(".chat-settings-menu");if(!n)return;const i=n.classList.contains("active");if(document.querySelectorAll(".chat-settings-menu.active").forEach(o=>o.classList.remove("active")),!i){n.classList.add("active");const o=r=>{!n.contains(r.target)&&r.target!==t&&!t.contains(r.target)&&(n.classList.remove("active"),document.removeEventListener("click",o))};requestAnimationFrame(()=>document.addEventListener("click",o))}}function Qy(e){if(!e.connected)return k;const t=e.modelCatalog??[],n=qy(t);if(n.length===0)return k;const i=e.modelProvider&&e.model?`${e.modelProvider}/${e.model}`:null,s=e.thinkingLevel??"off",o=e.verboseLevel==="on"||e.verboseLevel==="full",r=e.fillerEnabled===!0;return p`
2432
+ `}const qy=[{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 Vy(e){const t=new Set(e.filter(n=>n.provider==="anthropic").map(n=>n.id));return qy.filter(n=>t.has(n.id)).map(n=>({key:`anthropic/${n.id}`,...n}))}const Gy=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function Qy(e){var s;const t=e.currentTarget,n=(s=t.closest(".chat-model-bar"))==null?void 0:s.querySelector(".chat-settings-menu");if(!n)return;const i=n.classList.contains("active");if(document.querySelectorAll(".chat-settings-menu.active").forEach(o=>o.classList.remove("active")),!i){n.classList.add("active");const o=r=>{!n.contains(r.target)&&r.target!==t&&!t.contains(r.target)&&(n.classList.remove("active"),document.removeEventListener("click",o))};requestAnimationFrame(()=>document.addEventListener("click",o))}}function Yy(e){if(!e.connected)return k;const t=e.modelCatalog??[],n=Vy(t);if(n.length===0)return k;const i=e.modelProvider&&e.model?`${e.modelProvider}/${e.model}`:null,s=e.thinkingLevel??"off",o=e.verboseLevel==="on"||e.verboseLevel==="full",r=e.fillerEnabled===!0;return p`
2424
2433
  <div class="chat-model-bar">
2425
2434
  <div class="chat-model-bar__select">
2426
2435
  <select
@@ -2441,7 +2450,7 @@ ${e.sidebarContent}
2441
2450
  .value=${s}
2442
2451
  @change=${a=>{const u=a.target.value;e.onThinkingLevelChange&&e.onThinkingLevelChange(u)}}
2443
2452
  >
2444
- ${Vy.map(a=>p`
2453
+ ${Gy.map(a=>p`
2445
2454
  <option value=${a.value} ?selected=${a.value===s}>
2446
2455
  Thinking: ${a.label}
2447
2456
  </option>
@@ -2451,7 +2460,7 @@ ${e.sidebarContent}
2451
2460
  <button
2452
2461
  class="chat-model-bar__settings-btn"
2453
2462
  type="button"
2454
- @click=${Gy}
2463
+ @click=${Qy}
2455
2464
  aria-label="Message settings"
2456
2465
  title="Message settings"
2457
2466
  >
@@ -2478,9 +2487,9 @@ ${e.sidebarContent}
2478
2487
  </label>
2479
2488
  </div>
2480
2489
  </div>
2481
- `}function Yy(e){const t=[];let n=null;for(const i of e){if(i.kind!=="message"){n&&(t.push(n),n=null),t.push(i);continue}const s=yl(i.message),o=vl(s.role),r=s.timestamp||Date.now();!n||n.role!==o?(n&&t.push(n),n={kind:"group",key:`group:${o}:${i.key}`,role:o,messages:[{message:i.message,key:i.key}],timestamp:r,isStreaming:!1}):n.messages.push({message:i.message,key:i.key})}return n&&t.push(n),t}function Xy(e){var o;const t=[],n=Array.isArray(e.messages)?e.messages:[],i=Array.isArray(e.toolMessages)?e.toolMessages:[],s=e.showThinking||e.verboseLevel==="on"||e.verboseLevel==="full";for(let r=0;r<n.length;r++){const a=n[r],u=yl(a);if(!s&&u.role.toLowerCase()==="toolresult"){const c=a,d=(Array.isArray(c.content)?c.content:[]).filter(h=>h.type==="image");d.length>0&&t.push({kind:"message",key:ws(a,r),message:{role:"assistant",content:d,timestamp:u.timestamp}});continue}t.push({kind:"message",key:ws(a,r),message:a})}if(s)for(let r=0;r<i.length;r++)t.push({kind:"message",key:ws(i[r],r+n.length),message:i[r]});if(e.interimText&&t.push({kind:"interim",key:"interim:thinking",text:e.interimText}),e.stream!==null){const r=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:r,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:r})}for(const r of e.queue){const a=((o=r.attachments)==null?void 0:o.filter(c=>c.fileName).map(c=>c.fileName))??[],u=a.length>0?r.text?`${a.join(", ")}
2490
+ `}function Xy(e){const t=[];let n=null;for(const i of e){if(i.kind!=="message"){n&&(t.push(n),n=null),t.push(i);continue}const s=vl(i.message),o=bl(s.role),r=s.timestamp||Date.now();!n||n.role!==o?(n&&t.push(n),n={kind:"group",key:`group:${o}:${i.key}`,role:o,messages:[{message:i.message,key:i.key}],timestamp:r,isStreaming:!1}):n.messages.push({message:i.message,key:i.key})}return n&&t.push(n),t}function Zy(e){var o;const t=[],n=Array.isArray(e.messages)?e.messages:[],i=Array.isArray(e.toolMessages)?e.toolMessages:[],s=e.showThinking||e.verboseLevel==="on"||e.verboseLevel==="full";for(let r=0;r<n.length;r++){const a=n[r],u=vl(a);if(!s&&u.role.toLowerCase()==="toolresult"){const c=a,d=(Array.isArray(c.content)?c.content:[]).filter(h=>h.type==="image");d.length>0&&t.push({kind:"message",key:ks(a,r),message:{role:"assistant",content:d,timestamp:u.timestamp}});continue}t.push({kind:"message",key:ks(a,r),message:a})}if(s)for(let r=0;r<i.length;r++)t.push({kind:"message",key:ks(i[r],r+n.length),message:i[r]});if(e.interimText&&t.push({kind:"interim",key:"interim:thinking",text:e.interimText}),e.stream!==null){const r=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:r,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:r})}for(const r of e.queue){const a=((o=r.attachments)==null?void 0:o.filter(c=>c.fileName).map(c=>c.fileName))??[],u=a.length>0?r.text?`${a.join(", ")}
2482
2491
 
2483
- ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,message:{role:"user",content:[{type:"text",text:u}],timestamp:r.createdAt}})}return Yy(t)}function ws(e,t){const n=e,i=typeof n.toolCallId=="string"?n.toolCallId:"";if(i)return`tool:${i}`;const s=typeof n.id=="string"?n.id:"";if(s)return`msg:${s}`;const o=typeof n.messageId=="string"?n.messageId:"";if(o)return`msg:${o}`;const r=typeof n.timestamp=="number"?n.timestamp:null,a=typeof n.role=="string"?n.role:"unknown";return r!=null?`msg:${a}:${r}:${t}`:`msg:${a}:${t}`}const Zy=p`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>`;function Jy(e){if(!e.connected)return p`
2492
+ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,message:{role:"user",content:[{type:"text",text:u}],timestamp:r.createdAt}})}return Xy(t)}function ks(e,t){const n=e,i=typeof n.toolCallId=="string"?n.toolCallId:"";if(i)return`tool:${i}`;const s=typeof n.id=="string"?n.id:"";if(s)return`msg:${s}`;const o=typeof n.messageId=="string"?n.messageId:"";if(o)return`msg:${o}`;const r=typeof n.timestamp=="number"?n.timestamp:null,a=typeof n.role=="string"?n.role:"unknown";return r!=null?`msg:${a}:${r}:${t}`:`msg:${a}:${t}`}const Jy=p`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>`;function ev(e){if(!e.connected)return p`
2484
2493
  <div class="setup-container">
2485
2494
  <div class="setup-card">
2486
2495
  <div class="setup-spinner"></div>
@@ -2493,20 +2502,20 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2493
2502
  target="_blank"
2494
2503
  rel="noopener"
2495
2504
  title="Open public chat in new tab"
2496
- >Public ${Zy}</a>`:k;return p`
2505
+ >Public ${Jy}</a>`:k;return p`
2497
2506
  <div class="setup-container setup-container--full chat-page">
2498
- ${yt("Chat",e.wsProps)}
2507
+ ${vt("Chat",e.wsProps)}
2499
2508
  ${t}
2500
2509
  <div class="chat-viewport">
2501
2510
  ${lu(e)}
2502
2511
  </div>
2503
2512
  </div>
2504
- `}function ev(e){return e?`${pl(e)} (${xi(e)})`:"n/a"}function cu(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?xi(t.lastRunAtMs):"never";return`${n} · last ${i}`}function uu(e){const t=e.schedule;return t.kind==="at"?`One-time: ${pl(t.atMs)}`:t.kind==="every"?`Every ${hl(t.everyMs)}`:tv(t.expr,t.tz)}function tv(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,o,r,a]=n,u=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",c=(b,S)=>new Date(2e3,0,1,b,S).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),l=/^\d{1,2}$/.test(i)?parseInt(i,10):null,d=Da(s);if(l===null||!d)return`${e}${t?` (${t})`:""}`;const h=d.map(b=>c(b,l)),v=h.length<=3?h.join(" & "):`${h.slice(0,-1).join(", ")} & ${h[h.length-1]}`,f=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(o==="*"&&r==="*"){if(a==="*")return`Daily at ${v}${u}`;if(a==="1-5")return`Weekdays at ${v}${u}`;if(a==="0,6"||a==="6,0")return`Weekends at ${v}${u}`;const b=Da(a);if(b)return`${b.map($=>f[$%7]??String($)).join(", ")} at ${v}${u}`}return`${e}${t?` (${t})`:""}`}function Da(e){if(e==="*")return null;if(/^\d+(,\d+)*$/.test(e))return e.split(",").map(Number);if(/^\d+-\d+$/.test(e)){const[t,n]=e.split("-").map(Number);if(t>n)return null;const i=[];for(let s=t;s<=n;s++)i.push(s);return i}return null}function nv(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 Oa(e){const t=e.payload;if(t.kind!=="agentTurn")return null;const n=t.channel??t.provider,i=t.to;if(!i&&!n)return null;const s=[];return i&&s.push(i),n&&n!=="last"&&s.push(`via ${n}`),s.join(" ")||null}function iv(e){var s;const t=["last",...e.channels.filter(Boolean)],n=(s=e.form.channel)==null?void 0:s.trim();n&&!t.includes(n)&&t.push(n);const i=new Set;return t.filter(o=>i.has(o)?!1:(i.add(o),!0))}function sv(e,t){var i,s;if(t==="last")return"last";const n=(i=e.channelMeta)==null?void 0:i.find(o=>o.id===t);return n!=null&&n.label?n.label:((s=e.channelLabels)==null?void 0:s[t])??t}function ov(e){return e||"Default"}const Ba=p`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,rv=p`<svg viewBox="0 0 24 24"><rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/></svg>`,av=p`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,du=p`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,lv=p`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`;function Fa(e){const t=e.detailJobId?e.jobs.find(n=>n.id===e.detailJobId)??null:null;return p`
2505
- ${cv(e)}
2513
+ `}function tv(e){return e?`${hl(e)} (${$i(e)})`:"n/a"}function cu(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?$i(t.lastRunAtMs):"never";return`${n} · last ${i}`}function uu(e){const t=e.schedule;return t.kind==="at"?`One-time: ${hl(t.atMs)}`:t.kind==="every"?`Every ${fl(t.everyMs)}`:nv(t.expr,t.tz)}function nv(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,o,r,a]=n,u=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",c=(b,S)=>new Date(2e3,0,1,b,S).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),l=/^\d{1,2}$/.test(i)?parseInt(i,10):null,d=Oa(s);if(l===null||!d)return`${e}${t?` (${t})`:""}`;const h=d.map(b=>c(b,l)),v=h.length<=3?h.join(" & "):`${h.slice(0,-1).join(", ")} & ${h[h.length-1]}`,f=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(o==="*"&&r==="*"){if(a==="*")return`Daily at ${v}${u}`;if(a==="1-5")return`Weekdays at ${v}${u}`;if(a==="0,6"||a==="6,0")return`Weekends at ${v}${u}`;const b=Oa(a);if(b)return`${b.map($=>f[$%7]??String($)).join(", ")} at ${v}${u}`}return`${e}${t?` (${t})`:""}`}function Oa(e){if(e==="*")return null;if(/^\d+(,\d+)*$/.test(e))return e.split(",").map(Number);if(/^\d+-\d+$/.test(e)){const[t,n]=e.split("-").map(Number);if(t>n)return null;const i=[];for(let s=t;s<=n;s++)i.push(s);return i}return null}function iv(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 Ba(e){const t=e.payload;if(t.kind!=="agentTurn")return null;const n=t.channel??t.provider,i=t.to;if(!i&&!n)return null;const s=[];return i&&s.push(i),n&&n!=="last"&&s.push(`via ${n}`),s.join(" ")||null}function sv(e){var s;const t=["last",...e.channels.filter(Boolean)],n=(s=e.form.channel)==null?void 0:s.trim();n&&!t.includes(n)&&t.push(n);const i=new Set;return t.filter(o=>i.has(o)?!1:(i.add(o),!0))}function ov(e,t){var i,s;if(t==="last")return"last";const n=(i=e.channelMeta)==null?void 0:i.find(o=>o.id===t);return n!=null&&n.label?n.label:((s=e.channelLabels)==null?void 0:s[t])??t}function rv(e){return e||"Default"}const Fa=p`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,av=p`<svg viewBox="0 0 24 24"><rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/></svg>`,lv=p`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,du=p`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,cv=p`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`;function Ua(e){const t=e.detailJobId?e.jobs.find(n=>n.id===e.detailJobId)??null:null;return p`
2506
2514
  ${uv(e)}
2507
- ${e.newEventModalOpen?pv(e):k}
2508
- ${t?fv(t,e):k}
2509
- `}function cv(e){const t=e.status,n=(t==null?void 0:t.enabled)??!1,i=(t==null?void 0:t.jobs)??0,s=t==null?void 0:t.nextWakeAtMs;return p`
2515
+ ${dv(e)}
2516
+ ${e.newEventModalOpen?hv(e):k}
2517
+ ${t?gv(t,e):k}
2518
+ `}function uv(e){const t=e.status,n=(t==null?void 0:t.enabled)??!1,i=(t==null?void 0:t.jobs)??0,s=t==null?void 0:t.nextWakeAtMs;return p`
2510
2519
  <div class="event-status-bar">
2511
2520
  <div class="event-status-bar__info">
2512
2521
  <span class="statusDot ${n?"ok":""}"></span>
@@ -2515,7 +2524,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2515
2524
  <span>${i} event${i!==1?"s":""}</span>
2516
2525
  ${s?p`
2517
2526
  <span class="event-status-bar__sep">\u00b7</span>
2518
- <span>Next: ${xi(s)}</span>
2527
+ <span>Next: ${$i(s)}</span>
2519
2528
  `:k}
2520
2529
  <button
2521
2530
  class="btn btn--sm"
@@ -2528,14 +2537,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2528
2537
  ${e.error?p`<span class="muted">${e.error}</span>`:k}
2529
2538
  </div>
2530
2539
  <button class="btn primary btn--sm" @click=${e.onNewEventModalOpen}>
2531
- ${lv} New Event
2540
+ ${cv} New Event
2532
2541
  </button>
2533
2542
  </div>
2534
- `}function uv(e){return e.jobs.length===0?p`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:p`
2543
+ `}function dv(e){return e.jobs.length===0?p`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:p`
2535
2544
  <div class="event-grid">
2536
- ${e.jobs.map(t=>dv(t,e))}
2545
+ ${e.jobs.map(t=>pv(t,e))}
2537
2546
  </div>
2538
- `}function dv(e,t){return p`
2547
+ `}function pv(e,t){return p`
2539
2548
  <div
2540
2549
  class="event-card ${e.enabled?"":"disabled"}"
2541
2550
  @click=${()=>t.onDetailOpen(e)}
@@ -2547,8 +2556,8 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2547
2556
  </span>
2548
2557
  </div>
2549
2558
  <div class="event-card__schedule">${uu(e)}</div>
2550
- ${e.agentId?p`<div class="event-card__agent">${ov(e.agentId)}</div>`:k}
2551
- ${Oa(e)?p`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${Oa(e)}</div>`:k}
2559
+ ${e.agentId?p`<div class="event-card__agent">${rv(e.agentId)}</div>`:k}
2560
+ ${Ba(e)?p`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${Ba(e)}</div>`:k}
2552
2561
  <div class="event-card__footer">
2553
2562
  <div class="event-card__status">
2554
2563
  <span class="muted" style="font-size: 11px;">${cu(e)}</span>
@@ -2560,7 +2569,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2560
2569
  ?disabled=${t.busy}
2561
2570
  @click=${()=>t.onToggle(e,!e.enabled)}
2562
2571
  >
2563
- ${e.enabled?rv:Ba}
2572
+ ${e.enabled?av:Fa}
2564
2573
  </button>
2565
2574
  <button
2566
2575
  class="btn-icon"
@@ -2568,7 +2577,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2568
2577
  ?disabled=${t.busy}
2569
2578
  @click=${()=>t.onRun(e)}
2570
2579
  >
2571
- ${Ba}
2580
+ ${Fa}
2572
2581
  </button>
2573
2582
  <button
2574
2583
  class="btn-icon danger"
@@ -2576,12 +2585,12 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2576
2585
  ?disabled=${t.busy}
2577
2586
  @click=${()=>t.onRemove(e)}
2578
2587
  >
2579
- ${av}
2588
+ ${lv}
2580
2589
  </button>
2581
2590
  </div>
2582
2591
  </div>
2583
2592
  </div>
2584
- `}function pv(e){const t=iv(e);return p`
2593
+ `}function hv(e){const t=sv(e);return p`
2585
2594
  <div class="event-modal-overlay" @click=${e.onNewEventModalClose}>
2586
2595
  <div class="event-modal" @click=${n=>n.stopPropagation()}>
2587
2596
  <div class="event-modal__header">
@@ -2639,7 +2648,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2639
2648
  </label>
2640
2649
  </div>
2641
2650
 
2642
- ${hv(e)}
2651
+ ${fv(e)}
2643
2652
 
2644
2653
  <div class="form-grid" style="margin-top: 12px;">
2645
2654
  <label class="field">
@@ -2701,7 +2710,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2701
2710
  @change=${n=>e.onFormChange({channel:n.target.value})}
2702
2711
  >
2703
2712
  ${t.map(n=>p`<option value=${n}>
2704
- ${sv(e,n)}
2713
+ ${ov(e,n)}
2705
2714
  </option>`)}
2706
2715
  </select>
2707
2716
  </label>
@@ -2740,7 +2749,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2740
2749
  </div>
2741
2750
  </div>
2742
2751
  </div>
2743
- `}function hv(e){const t=e.form;return t.scheduleKind==="at"?p`
2752
+ `}function fv(e){const t=e.form;return t.scheduleKind==="at"?p`
2744
2753
  <label class="field" style="margin-top: 12px;">
2745
2754
  <span>Run at</span>
2746
2755
  <input
@@ -2789,7 +2798,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2789
2798
  />
2790
2799
  </label>
2791
2800
  </div>
2792
- `}function fv(e,t){var n;return p`
2801
+ `}function gv(e,t){var n;return p`
2793
2802
  <div class="event-modal-overlay" @click=${t.onDetailClose}>
2794
2803
  <div class="event-modal" @click=${i=>i.stopPropagation()}>
2795
2804
  <div class="event-modal__header">
@@ -2834,7 +2843,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2834
2843
  </div>
2835
2844
  <div class="event-detail-row" style="flex-direction: column; align-items: stretch; gap: 4px;">
2836
2845
  <span class="event-detail-label">Action</span>
2837
- <span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${nv(e,!1)}</span>
2846
+ <span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${iv(e,!1)}</span>
2838
2847
  </div>
2839
2848
  ${e.payload.kind==="agentTurn"&&e.payload.to?p`
2840
2849
  <div class="event-detail-row">
@@ -2864,7 +2873,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2864
2873
  ${(n=e.state)!=null&&n.nextRunAtMs?p`
2865
2874
  <div class="event-detail-row">
2866
2875
  <span class="event-detail-label">Next run</span>
2867
- <span class="event-detail-value">${ev(e.state.nextRunAtMs)}</span>
2876
+ <span class="event-detail-value">${tv(e.state.nextRunAtMs)}</span>
2868
2877
  </div>
2869
2878
  `:k}
2870
2879
  </div>
@@ -2875,7 +2884,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2875
2884
  </div>
2876
2885
  ${t.runs.length===0?p`<div class="muted" style="font-size: 13px;">No runs recorded yet.</div>`:p`
2877
2886
  <div class="list">
2878
- ${[...t.runs].sort((i,s)=>s.ts-i.ts).map(i=>mv(i))}
2887
+ ${[...t.runs].sort((i,s)=>s.ts-i.ts).map(i=>yv(i))}
2879
2888
  </div>
2880
2889
  `}
2881
2890
  </div>
@@ -2905,14 +2914,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2905
2914
  </div>
2906
2915
  </div>
2907
2916
  </div>
2908
- `}function gv(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"?"chip chip-warn":"chip"}function mv(e){return p`
2917
+ `}function mv(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"?"chip chip-warn":"chip"}function yv(e){return p`
2909
2918
  <div class="list-item" style="grid-template-columns: 1fr; gap: 6px;">
2910
2919
  <div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
2911
- <span class=${gv(e.status)} style="font-size: 11px; padding: 2px 8px;">
2920
+ <span class=${mv(e.status)} style="font-size: 11px; padding: 2px 8px;">
2912
2921
  ${e.status}
2913
2922
  </span>
2914
- <span class="muted" style="font-size: 12px;">${xi(e.ts)}</span>
2915
- <span class="muted" style="font-size: 12px;">${hl(e.durationMs)}</span>
2923
+ <span class="muted" style="font-size: 12px;">${$i(e.ts)}</span>
2924
+ <span class="muted" style="font-size: 12px;">${fl(e.durationMs)}</span>
2916
2925
  </div>
2917
2926
  ${e.summary?p`<div class="muted" style="font-size: 12px;">${e.summary}</div>`:k}
2918
2927
  ${e.error?p`
@@ -2922,7 +2931,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2922
2931
  </details>
2923
2932
  `:k}
2924
2933
  </div>
2925
- `}function yv(e){var s;const t=((s=e.report)==null?void 0:s.skills)??[],n=e.filter.trim().toLowerCase(),i=n?t.filter(o=>[o.name,o.description,o.source].join(" ").toLowerCase().includes(n)):t;return p`
2934
+ `}function vv(e){var s;const t=((s=e.report)==null?void 0:s.skills)??[],n=e.filter.trim().toLowerCase(),i=n?t.filter(o=>[o.name,o.description,o.source].join(" ").toLowerCase().includes(n)):t;return p`
2926
2935
  <section class="card">
2927
2936
  <div class="row" style="justify-content: space-between;">
2928
2937
  <div>
@@ -2950,11 +2959,11 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2950
2959
 
2951
2960
  ${i.length===0?p`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:p`
2952
2961
  <div class="list" style="margin-top: 16px;">
2953
- ${i.map(o=>vv(o,e))}
2962
+ ${i.map(o=>bv(o,e))}
2954
2963
  </div>
2955
2964
  `}
2956
2965
  </section>
2957
- `}function vv(e,t){const n=t.busyKey===e.skillKey,i=t.edits[e.skillKey]??"",s=t.messages[e.skillKey]??null,o=e.install.length>0&&e.missing.bins.length>0,r=[...e.missing.bins.map(u=>`bin:${u}`),...e.missing.env.map(u=>`env:${u}`),...e.missing.config.map(u=>`config:${u}`),...e.missing.os.map(u=>`os:${u}`)],a=[];return e.disabled&&a.push("disabled"),e.blockedByAllowlist&&a.push("blocked by allowlist"),p`
2966
+ `}function bv(e,t){const n=t.busyKey===e.skillKey,i=t.edits[e.skillKey]??"",s=t.messages[e.skillKey]??null,o=e.install.length>0&&e.missing.bins.length>0,r=[...e.missing.bins.map(u=>`bin:${u}`),...e.missing.env.map(u=>`env:${u}`),...e.missing.config.map(u=>`config:${u}`),...e.missing.os.map(u=>`os:${u}`)],a=[];return e.disabled&&a.push("disabled"),e.blockedByAllowlist&&a.push("blocked by allowlist"),p`
2958
2967
  <div class="list-item">
2959
2968
  <div class="list-main">
2960
2969
  <div class="list-title">
@@ -3022,7 +3031,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3022
3031
  `:k}
3023
3032
  </div>
3024
3033
  </div>
3025
- `}const Ua=["user","assistant","tool","thinking","error"],Wa={user:"User",assistant:"Assistant",tool:"Tool",thinking:"Thinking",error:"Error",system:"System"};function bv(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function wv(e){return e.split(":").slice(2).join(":")||e}function kv(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Sv(e,t=500){return e.length<=t?e:e.slice(0,t)+"..."}function xv(e){const t=e.filterText.trim().toLowerCase();Ua.some(i=>!e.typeFilters[i]),e.agents.some(i=>!e.agentFilters[i]);const n=e.entries.filter(i=>!e.typeFilters[i.type]||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:kv(i,t));return p`
3034
+ `}const Wa=["user","assistant","tool","thinking","error"],Ka={user:"User",assistant:"Assistant",tool:"Tool",thinking:"Thinking",error:"Error",system:"System"};function wv(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function kv(e){return e.split(":").slice(2).join(":")||e}function Sv(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function xv(e,t=500){return e.length<=t?e:e.slice(0,t)+"..."}function $v(e){const t=e.filterText.trim().toLowerCase();Wa.some(i=>!e.typeFilters[i]),e.agents.some(i=>!e.agentFilters[i]);const n=e.entries.filter(i=>!e.typeFilters[i.type]||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:Sv(i,t));return p`
3026
3035
  <div>
3027
3036
  <div class="filters" style="margin-top: 14px;">
3028
3037
  <label class="field" style="min-width: 220px;">
@@ -3036,14 +3045,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3036
3045
  </div>
3037
3046
 
3038
3047
  <div class="chip-row" style="margin-top: 12px;">
3039
- ${Ua.map(i=>p`
3048
+ ${Wa.map(i=>p`
3040
3049
  <label class="chip session-log-chip ${i}">
3041
3050
  <input
3042
3051
  type="checkbox"
3043
3052
  .checked=${e.typeFilters[i]}
3044
3053
  @change=${s=>e.onTypeToggle(i,s.target.checked)}
3045
3054
  />
3046
- <span>${Wa[i]}</span>
3055
+ <span>${Ka[i]}</span>
3047
3056
  </label>
3048
3057
  `)}
3049
3058
  </div>
@@ -3075,19 +3084,19 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3075
3084
  ${n.length===0?p`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map(i=>p`
3076
3085
  <div class="log-row session-entry ${i.type}">
3077
3086
  <div class="log-row-header">
3078
- <span class="log-time mono">${bv(i.timestamp)}</span>
3079
- <span class="session-log-type ${i.type}">${Wa[i.type]}</span>
3087
+ <span class="log-time mono">${wv(i.timestamp)}</span>
3088
+ <span class="session-log-type ${i.type}">${Ka[i.type]}</span>
3080
3089
  <span class="log-subsystem mono">${i.agentId}</span>
3081
- <span class="session-label mono">${wv(i.sessionKey)}</span>
3090
+ <span class="session-label mono">${kv(i.sessionKey)}</span>
3082
3091
  ${i.toolName?p`<span class="session-tool mono">${i.toolName}</span>`:k}
3083
3092
  ${i.model?p`<span class="session-model mono">${i.model}</span>`:k}
3084
3093
  </div>
3085
- <div class="log-message mono">${Sv(i.content)}</div>
3094
+ <div class="log-message mono">${xv(i.content)}</div>
3086
3095
  </div>
3087
3096
  `)}
3088
3097
  </div>
3089
3098
  </div>
3090
- `}const Qs=["trace","debug","info","warn","error","fatal"];function $v(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function pu(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Av(e){return p`
3099
+ `}const Ys=["trace","debug","info","warn","error","fatal"];function Av(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function pu(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Ev(e){return p`
3091
3100
  <section class="card">
3092
3101
  <div class="row" style="justify-content: space-between;">
3093
3102
  <div>
@@ -3102,7 +3111,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3102
3111
  <button
3103
3112
  class="btn"
3104
3113
  ?disabled=${e.entries.length===0}
3105
- @click=${()=>{const t=e.filterText.trim().toLowerCase(),n=Qs.some(o=>!e.levelFilters[o]),i=e.entries.filter(o=>o.level&&!e.levelFilters[o.level]?!1:pu(o,t)),s=t||n?"filtered":"visible";e.onExport(i.map(o=>o.raw),s)}}
3114
+ @click=${()=>{const t=e.filterText.trim().toLowerCase(),n=Ys.some(o=>!e.levelFilters[o]),i=e.entries.filter(o=>o.level&&!e.levelFilters[o.level]?!1:pu(o,t)),s=t||n?"filtered":"visible";e.onExport(i.map(o=>o.raw),s)}}
3106
3115
  >
3107
3116
  Export
3108
3117
  </button>
@@ -3132,9 +3141,9 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3132
3141
  </button>
3133
3142
  </div>
3134
3143
 
3135
- ${e.logsSubTab==="session"?xv(e.sessionLogsProps):Ev(e)}
3144
+ ${e.logsSubTab==="session"?$v(e.sessionLogsProps):Cv(e)}
3136
3145
  </section>
3137
- `}function Ev(e){const t=e.filterText.trim().toLowerCase();Qs.some(i=>!e.levelFilters[i]);const n=e.entries.filter(i=>i.level&&!e.levelFilters[i.level]?!1:pu(i,t));return p`
3146
+ `}function Cv(e){const t=e.filterText.trim().toLowerCase();Ys.some(i=>!e.levelFilters[i]);const n=e.entries.filter(i=>i.level&&!e.levelFilters[i.level]?!1:pu(i,t));return p`
3138
3147
  <div class="filters" style="margin-top: 14px;">
3139
3148
  <label class="field" style="min-width: 220px;">
3140
3149
  <span>Filter</span>
@@ -3155,7 +3164,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3155
3164
  </div>
3156
3165
 
3157
3166
  <div class="chip-row" style="margin-top: 12px;">
3158
- ${Qs.map(i=>p`
3167
+ ${Ys.map(i=>p`
3159
3168
  <label class="chip log-chip ${i}">
3160
3169
  <input
3161
3170
  type="checkbox"
@@ -3177,7 +3186,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3177
3186
  ${n.length===0?p`<div class="muted" style="padding: 12px;">No log entries.</div>`:[...n].reverse().map(i=>p`
3178
3187
  <div class="log-row">
3179
3188
  <div class="log-row-header">
3180
- <span class="log-time mono">${$v(i.time)}</span>
3189
+ <span class="log-time mono">${Av(i.time)}</span>
3181
3190
  <span class="log-level ${i.level??""}">${i.level??""}</span>
3182
3191
  <span class="log-subsystem mono">${i.subsystem??""}</span>
3183
3192
  </div>
@@ -3185,13 +3194,13 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3185
3194
  </div>
3186
3195
  `)}
3187
3196
  </div>
3188
- `}const Cv=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function Tv(e){switch(e.activeTab){case"cron":return Fa(e.cronProps);case"skills":return yv(e.skillsProps);case"logs":return Av(e.logsProps);default:return Fa(e.cronProps)}}function _v(e){return e.connected?p`
3197
+ `}const Tv=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function _v(e){switch(e.activeTab){case"cron":return Ua(e.cronProps);case"skills":return vv(e.skillsProps);case"logs":return Ev(e.logsProps);default:return Ua(e.cronProps)}}function Mv(e){return e.connected?p`
3189
3198
  <div class="setup-container">
3190
- ${yt("Advanced",e.wsProps)}
3199
+ ${vt("Advanced",e.wsProps)}
3191
3200
  <div class="setup-card sp-card-advanced" style="text-align: left;">
3192
3201
  <h1>Advanced</h1>
3193
3202
  <div class="sp-tabs">
3194
- ${Cv.map(t=>p`
3203
+ ${Tv.map(t=>p`
3195
3204
  <button
3196
3205
  class="sp-tab ${e.activeTab===t.id?"active":""}"
3197
3206
  @click=${()=>e.onTabChange(t.id)}
@@ -3200,7 +3209,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3200
3209
  </button>
3201
3210
  `)}
3202
3211
  </div>
3203
- ${Tv(e)}
3212
+ ${_v(e)}
3204
3213
  </div>
3205
3214
  </div>
3206
3215
  `:p`
@@ -3210,7 +3219,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3210
3219
  <p>Connecting to gateway...</p>
3211
3220
  </div>
3212
3221
  </div>
3213
- `}function Ka(e){if(!e.show)return k;const t=Xe(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const r=h=>{var f;o=h.target.value;const v=(f=h.target.closest(".login-card"))==null?void 0:f.querySelector(".login-change-pin");v&&(v.style.display=o==="__master__"?"":"none")},a=h=>v=>{const f=v.target;f.value=f.value.replace(/\D/g,"").slice(0,6),h(f.value)},u=!n&&e.accounts.length>1?p`
3222
+ `}function za(e){if(!e.show)return k;const t=Xe(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const r=h=>{var f;o=h.target.value;const v=(f=h.target.closest(".login-card"))==null?void 0:f.querySelector(".login-change-pin");v&&(v.style.display=o==="__master__"?"":"none")},a=h=>v=>{const f=v.target;f.value=f.value.replace(/\D/g,"").slice(0,6),h(f.value)},u=!n&&e.accounts.length>1?p`
3214
3223
  <select
3215
3224
  class="login-account-select"
3216
3225
  @change=${r}
@@ -3334,7 +3343,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3334
3343
  </p>`:k}
3335
3344
  </div>
3336
3345
  </div>
3337
- `}function Mv(e){if(!e.connected)return p`
3346
+ `}function Pv(e){if(!e.connected)return p`
3338
3347
  <div class="setup-container">
3339
3348
  <div class="setup-card">
3340
3349
  <div class="setup-spinner"></div>
@@ -3350,14 +3359,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3350
3359
  ${lu(t)}
3351
3360
  </div>
3352
3361
  </div>
3353
- `}async function Pv(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 wn(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 Lv(e,t){var i,s;if(!e.client||!e.connected||e.workspaceSaving)return;const n=t.name.trim();if(!n){e.workspacesError="Account name is required.";return}e.workspaceSaving=!0,e.workspacesError=null;try{const o=await e.client.request("config.get",{});e.configSnapshot=o;const r=o.hash;if(!r){e.workspacesError="Config hash missing; reload and retry.";return}const a={name:n,baseHash:r,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(a.workspaceDir=t.workspacePath.trim());const u=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await wn(e),(s=t.onCreated)==null||s.call(t,u)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function Iv(e,t){if(!(!e.client||!e.connected)&&!e.workspaceSaving){e.workspaceSaving=!0,e.workspacesError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=n.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:i}),e.workspaceRemoveConfirm=null,await wn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Rv(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:s}),await wn(e)}catch(i){e.workspacesError=String(i)}}}const qn=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Lv,loadWorkspaces:wn,removeWorkspace:Iv,renameWorkspace:Rv},Symbol.toStringTag,{value:"Module"})),hu={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"taskmaster-control-ui",SETUP_UI:"setup-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"taskmaster-macos",IOS_APP:"taskmaster-ios",ANDROID_APP:"taskmaster-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"taskmaster-probe",PUBLIC_CHAT:"public-chat"},za=hu,Ys={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(hu));new Set(Object.values(Ys));function Nv(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),i=e.token??"",s=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),i];return t==="v2"&&s.push(e.nonce??""),s.join("|")}const Dv=4008;class Ov{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{var i,s;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(s=(i=this.opts).onClose)==null||s.call(i,{code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){var d;if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=this.opts.role??"operator",n=this.opts.scopes??["operator.admin","operator.approvals","operator.pairing"],s=!(t!=="operator")&&typeof crypto<"u"&&!!crypto.subtle;let o=null,r=!1,a=this.opts.token;if(s){o=await Up();const h=(d=zp({deviceId:o.deviceId,role:t}))==null?void 0:d.token;a=h??this.opts.token,r=!!(h&&this.opts.token)}const u=a||this.opts.password?{token:a,password:this.opts.password}:void 0;let c;if(s&&o){const h=Date.now(),v=this.connectNonce??void 0,f=Nv({deviceId:o.deviceId,clientId:this.opts.clientName??za.CONTROL_UI,clientMode:this.opts.mode??Ys.WEBCHAT,role:t,scopes:n,signedAtMs:h,token:a??null,nonce:v}),b=await Wp(o.privateKey,f);c={id:o.deviceId,publicKey:o.publicKey,signature:b,signedAt:h,nonce:v}}const l={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??za.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Ys.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:c,caps:[],auth:u,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",l).then(h=>{var v,f,b;(v=h==null?void 0:h.auth)!=null&&v.deviceToken&&o&&jp({deviceId:o.deviceId,role:h.auth.role??t,token:h.auth.deviceToken,scopes:h.auth.scopes??[]}),this.backoffMs=800,(b=(f=this.opts).onHello)==null||b.call(f,h)}).catch(()=>{var h;r&&o&&Hp({deviceId:o.deviceId,role:t}),(h=this.ws)==null||h.close(Dv,"connect failed")})}handleMessage(t){var s,o,r,a,u,c;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const l=n;if(l.event==="connect.challenge"){const h=l.payload,v=h&&typeof h.nonce=="string"?h.nonce:null;v&&(this.connectNonce=v,this.sendConnect());return}const d=typeof l.seq=="number"?l.seq:null;d!==null&&(this.lastSeq!==null&&d>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:d})),this.lastSeq=d);try{(a=(r=this.opts).onEvent)==null||a.call(r,l)}catch(h){console.error("[gateway] event handler error:",h)}return}if(i.type==="res"){const l=n,d=this.pending.get(l.id);if(!d)return;if(this.pending.delete(l.id),l.ok)d.resolve(l.payload);else{const h=new Error(((u=l.error)==null?void 0:u.message)??"request failed");h.payload=l.payload,h.details=(c=l.error)==null?void 0:c.details,d.reject(h)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=so(),s={type:"req",id:i,method:t,params:n},o=new Promise((r,a)=>{this.pending.set(i,{resolve:u=>r(u),reject:a})});return this.ws.send(JSON.stringify(s)),o}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Xs(e){return typeof e=="object"&&e!==null}function Bv(e){if(!Xs(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Xs(n))return null;const i=typeof n.command=="string"?n.command.trim():"";if(!i)return null;const s=typeof e.createdAtMs=="number"?e.createdAtMs:0,o=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!s||!o?null:{id:t,request:{command:i,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:s,expiresAtMs:o}}function Fv(e){if(!Xs(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 fu(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Uv(e,t){const n=fu(e).filter(i=>i.id!==t.id);return n.push(t),n}function ja(e,t){return fu(e).filter(n=>n.id!==t)}class Wv{constructor(){this.canvas=null,this.ctx=null,this.img=new Image,this.pendingFrame=null,this.rafId=null,this.deviceWidth=1280,this.deviceHeight=720,this.lastMouseMoveAt=0,this.MOUSE_THROTTLE_MS=30}attach(t){this.canvas=t,this.ctx=t.getContext("2d")}detach(){this.rafId!=null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.canvas=null,this.ctx=null,this.pendingFrame=null}updateFrame(t,n){if(n!=null&&n.deviceWidth&&(this.deviceWidth=n.deviceWidth),n!=null&&n.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,!this.canvas){const i=document.getElementById("browser-screencast-canvas");i&&this.attach(i)}this.rafId==null&&(this.rafId=requestAnimationFrame(()=>this.renderFrame()))}renderFrame(){this.rafId=null;const t=this.pendingFrame;!t||!this.canvas||!this.ctx||(this.pendingFrame=null,this.img.onload=()=>{!this.canvas||!this.ctx||((this.canvas.width!==this.img.width||this.canvas.height!==this.img.height)&&(this.canvas.width=this.img.width,this.canvas.height=this.img.height),this.ctx.drawImage(this.img,0,0))},this.img.src=`data:image/jpeg;base64,${t}`)}translateCoordinates(t,n){if(!this.canvas)return{x:t,y:n};const i=this.canvas.getBoundingClientRect(),s=this.canvas.width/i.width,o=this.canvas.height/i.height,r=this.deviceWidth/this.canvas.width,a=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*r),y:Math.round(n*o*a)}}shouldThrottleMouseMove(){const t=performance.now();return t-this.lastMouseMoveAt<this.MOUSE_THROTTLE_MS?!0:(this.lastMouseMoveAt=t,!1)}getDeviceDimensions(){return{width:this.deviceWidth,height:this.deviceHeight}}}let ks=null;function un(){return ks||(ks=new Wv),ks}function Ho(e){return e instanceof Error?e.message:String(e)}async function Kv(e){if(!e.client){console.error("[browser] startScreencast: no client"),e.browserError="Not connected to gateway";return}if(!e.connected){console.error("[browser] startScreencast: client exists but not connected"),e.browserError="Not connected to gateway";return}console.log("[browser] startScreencast: sending request"),e.browserLoading=!0,e.browserError=null;try{const t=await e.client.request("browser.screencast.start",{quality:60,maxWidth:1280,maxHeight:720});console.log("[browser] startScreencast response:",t),t!=null&&t.ok?e.browserScreencastActive=!0:(console.warn("[browser] startScreencast: response did not have ok=true",t),e.browserError="Screencast start failed (no ok in response)")}catch(t){console.error("[browser] startScreencast error:",t),e.browserError=Ho(t)}finally{e.browserLoading=!1}}async function zv(e){if(!(!e.client||!e.connected)){e.browserLoading=!0,e.browserFullscreen=!1;try{await e.client.request("browser.screencast.stop",{}),e.browserScreencastActive=!1,e.browserScreencastFrame=null,e.browserScreencastMetadata=null}catch(t){e.browserError=Ho(t)}finally{e.browserLoading=!1}}}async function Ss(e,t,n,i,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:i,button:s??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function xs(e,t,n,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...i!=null&&i.text?{text:i.text}:{},...i!=null&&i.code?{code:i.code}:{},...i!=null&&i.modifiers?{modifiers:i.modifiers}:{}})}catch{}}async function jv(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=Ho(t)}}function Hv(e){e.browserInputMode=!e.browserInputMode}function qv(e){e.browserFullscreen=!e.browserFullscreen,un().detach()}function Vv(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,un().updateFrame(t.data,t.metadata)}function Gv(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function Qv(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function Zs(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),i=n?{sessionKey:n}:{};try{const s=await e.client.request("agent.identity.get",i);if(!s)return;const o=Ts(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function Js(e){return(await e.request("apikeys.list")).providers??[]}async function Ha(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function Yv(e,t){await e.request("apikeys.remove",{provider:t})}const vi="taskmaster_update_pending";async function gu(e){var t,n;if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("update.status",{});e.currentVersion=i.current,e.latestVersion=i.latest,e.updateAvailable=i.updateAvailable,e.updateMessage=i.updateAvailable?`v${i.latest} available`:"Up to date"}catch(i){e.updateMessage=`Check failed: ${String(i)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function Xv(e){var t,n,i,s;if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e);try{localStorage.setItem(vi,String(Date.now())),localStorage.removeItem(qo)}catch{}try{const o=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(o.ok&&o.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(o.ok&&o.result.status==="skipped")dn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw dn(),new Error(o.result.reason||"Update failed")}catch(o){dn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function Zv(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const r=t.name,a=t.index,u=t.total;e.updateMessage=`Updating: ${r} (${a+1}/${u})`;const c=e.updateProgressSteps.find(l=>l.index===a);c?(c.status="running",c.name=r):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:u,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const r=t.name,a=t.index,u=t.total,c=t.ok,l=t.durationMs,d=e.updateProgressSteps.find(v=>v.index===a);d?(d.status=c?"done":"failed",d.durationMs=l):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:u,status:c?"done":"failed",durationMs:l}];const h=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${r} done (${a+1}/${u})`:`Update step failed: ${r}${h}`,(s=e.requestUpdate)==null||s.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const a=t.reason;e.updateMessage=a?`Update failed: ${a}`:"Update failed",e.updateRunning=!1,dn()}(o=e.requestUpdate)==null||o.call(e)}}async function Jv(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=tb();dn();try{const r=await e.client.request("update.lastResult",{});if(!r.ok||!r.result)return;const a=5*6e4,u=Date.now()-r.result.ts<a;if(!t&&!u||nb(r.result.ts))return;e.updateLastResult=r.result;const c=(n=r.result.after)==null?void 0:n.version;if(r.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,r.result.status==="ok"){const l=(i=r.result.before)==null?void 0:i.version,d=c??r.result.currentVersion;e.updateMessage=l?`Updated: v${l} → v${d}`:`Updated to v${d}`}else{const l=r.result.reason??((s=r.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${l}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(o=e.requestUpdate)==null||o.call(e)}}const qo="taskmaster_update_dismissed";function eb(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(qo,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function tb(){try{const e=localStorage.getItem(vi);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(vi),!1):!0:!1}catch{return!1}}function dn(){try{localStorage.removeItem(vi)}catch{}}function nb(e){try{const t=localStorage.getItem(qo);return t?Number(t)>=e:!1}catch{return!1}}function $s(e,t){var a,u,c;const n=(e??"").trim(),i=(a=t.mainSessionKey)==null?void 0:a.trim();if(!i)return n;if(!n)return i;const s=((u=t.mainKey)==null?void 0:u.trim())||"main",o=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===s||o&&(n===`agent:${o}:main`||n===`agent:${o}:${s}`)?i:n}function ib(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=$s(e.sessionKey,t),i=$s(e.settings.sessionKey,t),s=$s(e.settings.lastActiveSessionKey,t),o=n||i||e.sessionKey,r={...e.settings,sessionKey:i||o,lastActiveSessionKey:s||o},a=r.sessionKey!==e.settings.sessionKey||r.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),a&&Ge(e,r)}function Te(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=!!e.publicChat,n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,i=t?"public-chat":n?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new Ov({url:e.settings.gatewayUrl,token:t?void 0:e.settings.token.trim()?e.settings.token:void 0,password:t?void 0:e.password.trim()?e.password:void 0,clientName:i,mode:"webchat",role:t?"public":void 0,scopes:t?[]:void 0,onHello:o=>{var r;if(e.connected=!0,e.lastError=null,e.hello=o,t){qa(e,o),Zs(e),(((r=e.publicChatConfig)==null?void 0:r.auth)??"anonymous")==="anonymous"&&ub(e);return}ci()&&(Co(),e.uninstallDone=!1),qa(e,o),e.handleAccessCheck(),Jv(e).then(()=>{gu(e)}),Zs(e),Pv(e),(e.chatPage||e.setup)&&rb(e),mo(e,{quiet:!0}),go(e,{quiet:!0}),wn(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Le(e),e.setup&&(ab(e),lb(e),cb(e)),ai(e)},onClose:({code:o,reason:r})=>{e.connected=!1,o!==1012&&(e.lastError=`disconnected (${o}): ${r||"no reason"}`)},onEvent:o=>sb(e,o),onGap:({expected:o,received:r})=>{console.warn(`[gateway] event gap: expected seq ${o}, got ${r}`),ai(e)}}),e.client.start()}function sb(e,t){try{ob(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function ob(e,t){var n;if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;qd(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&rc(e,i.sessionKey);const s=Sl(e,i);if((s==="final"||s==="error"||s==="aborted")&&(ro(e),Rh(e)),s==="final"){const o=e,r=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,Pe);Me(o,{limit:r})}return}if(t.event==="suggestions"){const i=t.payload;(i==null?void 0:i.sessionKey)===e.sessionKey&&Array.isArray(i.suggestions)&&i.suggestions.length>0&&(e.chatSuggestion=i.suggestions[0]);return}if(t.event==="presence"){const i=t.payload;i!=null&&i.presence&&Array.isArray(i.presence)&&(e.presenceEntries=i.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&Ao(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&go(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=Bv(t.payload);if(i){e.execApprovalQueue=Uv(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=ja(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){Vv(e,t.payload);return}if(t.event==="browser.handoff"){Gv(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){Qv(e);return}if(t.event==="exec.approval.resolved"){const i=Fv(t.payload);i&&(e.execApprovalQueue=ja(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){Zv(e,t.payload);return}}function qa(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&&ib(e,n.sessionDefaults)}async function rb(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 ab(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await Js(e.client)}catch{}}async function lb(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status")}catch{}}async function cb(e){if(!(!e.client||!e.connected))try{e.wifiStatus=await e.client.request("wifi.status")}catch{}}const Va="taskmaster_public_id";function mu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${Va}=`));if(t)return t.split("=")[1];const n=`anon-${((s=crypto.randomUUID)==null?void 0:s.call(crypto))??Math.random().toString(36).slice(2)}`,i=new Date(Date.now()+e*864e5).toUTCString();return document.cookie=`${Va}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function ub(e){var n,i;if(!e.client||!e.connected)return;const t=mu((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const s=(i=e.publicChatConfig)==null?void 0:i.accountId,o=await e.client.request("public.session",{cookieId:t,accountId:s});o!=null&&o.sessionKey&&(e.publicChatSessionKey=o.sessionKey,e.sessionKey=o.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready",Me(e))}catch(s){console.error("[public-chat] failed to resolve anonymous session:",s),e.lastError="Failed to start chat session"}}let Se=!1,de=null,Dt="",bi="";function yu(e){return e.replace(/[\s\-()]/g,"")}function vu(){Se=!1,de=null,Dt="",bi=""}async function db(e){if(!e.client||!e.connected)return;const t=mu(e.cookieTtlDays);try{const n=await e.client.request("public.session",{cookieId:t,accountId:e.accountId});n!=null&&n.sessionKey&&e.onAuthenticated(n.sessionKey)}catch(n){de=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function Ga(e){if(!e.client||Se)return;const t=yu(Dt);if(!t){de="Please enter your phone number",e.requestUpdate();return}Se=!0,de=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:bi.trim()||void 0});n!=null&&n.ok?e.onAuthStepChange("otp"):de=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){de=n instanceof Error?n.message:"Failed to send verification code"}finally{Se=!1,e.requestUpdate()}}async function Qa(e,t){if(!(!e.client||Se)){if(!t.trim()){de="Please enter the verification code",e.requestUpdate();return}Se=!0,de=null,e.requestUpdate();try{const n=await e.client.request("public.otp.verify",{phone:yu(Dt),code:t.trim(),accountId:e.accountId});n!=null&&n.ok&&n.sessionKey?(vu(),e.onAuthenticated(n.sessionKey)):de=(n==null?void 0:n.error)??"Invalid verification code"}catch(n){de=n instanceof Error?n.message:"Verification failed"}finally{Se=!1,e.requestUpdate()}}}function As(e){return k}function Ya(e){return p`
3362
+ `}async function Lv(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 kn(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 Iv(e,t){var i,s;if(!e.client||!e.connected||e.workspaceSaving)return;const n=t.name.trim();if(!n){e.workspacesError="Account name is required.";return}e.workspaceSaving=!0,e.workspacesError=null;try{const o=await e.client.request("config.get",{});e.configSnapshot=o;const r=o.hash;if(!r){e.workspacesError="Config hash missing; reload and retry.";return}const a={name:n,baseHash:r,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(a.workspaceDir=t.workspacePath.trim());const u=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await kn(e),(s=t.onCreated)==null||s.call(t,u)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function Rv(e,t){if(!(!e.client||!e.connected)&&!e.workspaceSaving){e.workspaceSaving=!0,e.workspacesError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=n.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:i}),e.workspaceRemoveConfirm=null,await kn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Nv(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:s}),await kn(e)}catch(i){e.workspacesError=String(i)}}}const Vn=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Iv,loadWorkspaces:kn,removeWorkspace:Rv,renameWorkspace:Nv},Symbol.toStringTag,{value:"Module"})),hu={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"taskmaster-control-ui",SETUP_UI:"setup-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"taskmaster-macos",IOS_APP:"taskmaster-ios",ANDROID_APP:"taskmaster-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"taskmaster-probe",PUBLIC_CHAT:"public-chat"},ja=hu,Xs={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(hu));new Set(Object.values(Xs));function Dv(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),i=e.token??"",s=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),i];return t==="v2"&&s.push(e.nonce??""),s.join("|")}const Ov=4008;class Bv{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{var i,s;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(s=(i=this.opts).onClose)==null||s.call(i,{code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){var d;if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=this.opts.role??"operator",n=this.opts.scopes??["operator.admin","operator.approvals","operator.pairing"],s=!(t!=="operator")&&typeof crypto<"u"&&!!crypto.subtle;let o=null,r=!1,a=this.opts.token;if(s){o=await Up();const h=(d=zp({deviceId:o.deviceId,role:t}))==null?void 0:d.token;a=h??this.opts.token,r=!!(h&&this.opts.token)}const u=a||this.opts.password?{token:a,password:this.opts.password}:void 0;let c;if(s&&o){const h=Date.now(),v=this.connectNonce??void 0,f=Dv({deviceId:o.deviceId,clientId:this.opts.clientName??ja.CONTROL_UI,clientMode:this.opts.mode??Xs.WEBCHAT,role:t,scopes:n,signedAtMs:h,token:a??null,nonce:v}),b=await Wp(o.privateKey,f);c={id:o.deviceId,publicKey:o.publicKey,signature:b,signedAt:h,nonce:v}}const l={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??ja.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Xs.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:c,caps:[],auth:u,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",l).then(h=>{var v,f,b;(v=h==null?void 0:h.auth)!=null&&v.deviceToken&&o&&jp({deviceId:o.deviceId,role:h.auth.role??t,token:h.auth.deviceToken,scopes:h.auth.scopes??[]}),this.backoffMs=800,(b=(f=this.opts).onHello)==null||b.call(f,h)}).catch(()=>{var h;r&&o&&Hp({deviceId:o.deviceId,role:t}),(h=this.ws)==null||h.close(Ov,"connect failed")})}handleMessage(t){var s,o,r,a,u,c;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const l=n;if(l.event==="connect.challenge"){const h=l.payload,v=h&&typeof h.nonce=="string"?h.nonce:null;v&&(this.connectNonce=v,this.sendConnect());return}const d=typeof l.seq=="number"?l.seq:null;d!==null&&(this.lastSeq!==null&&d>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:d})),this.lastSeq=d);try{(a=(r=this.opts).onEvent)==null||a.call(r,l)}catch(h){console.error("[gateway] event handler error:",h)}return}if(i.type==="res"){const l=n,d=this.pending.get(l.id);if(!d)return;if(this.pending.delete(l.id),l.ok)d.resolve(l.payload);else{const h=new Error(((u=l.error)==null?void 0:u.message)??"request failed");h.payload=l.payload,h.details=(c=l.error)==null?void 0:c.details,d.reject(h)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=oo(),s={type:"req",id:i,method:t,params:n},o=new Promise((r,a)=>{this.pending.set(i,{resolve:u=>r(u),reject:a})});return this.ws.send(JSON.stringify(s)),o}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Zs(e){return typeof e=="object"&&e!==null}function Fv(e){if(!Zs(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Zs(n))return null;const i=typeof n.command=="string"?n.command.trim():"";if(!i)return null;const s=typeof e.createdAtMs=="number"?e.createdAtMs:0,o=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!s||!o?null:{id:t,request:{command:i,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:s,expiresAtMs:o}}function Uv(e){if(!Zs(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 fu(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Wv(e,t){const n=fu(e).filter(i=>i.id!==t.id);return n.push(t),n}function Ha(e,t){return fu(e).filter(n=>n.id!==t)}class Kv{constructor(){this.canvas=null,this.ctx=null,this.img=new Image,this.pendingFrame=null,this.rafId=null,this.deviceWidth=1280,this.deviceHeight=720,this.lastMouseMoveAt=0,this.MOUSE_THROTTLE_MS=30}attach(t){this.canvas=t,this.ctx=t.getContext("2d")}detach(){this.rafId!=null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.canvas=null,this.ctx=null,this.pendingFrame=null}updateFrame(t,n){if(n!=null&&n.deviceWidth&&(this.deviceWidth=n.deviceWidth),n!=null&&n.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,!this.canvas){const i=document.getElementById("browser-screencast-canvas");i&&this.attach(i)}this.rafId==null&&(this.rafId=requestAnimationFrame(()=>this.renderFrame()))}renderFrame(){this.rafId=null;const t=this.pendingFrame;!t||!this.canvas||!this.ctx||(this.pendingFrame=null,this.img.onload=()=>{!this.canvas||!this.ctx||((this.canvas.width!==this.img.width||this.canvas.height!==this.img.height)&&(this.canvas.width=this.img.width,this.canvas.height=this.img.height),this.ctx.drawImage(this.img,0,0))},this.img.src=`data:image/jpeg;base64,${t}`)}translateCoordinates(t,n){if(!this.canvas)return{x:t,y:n};const i=this.canvas.getBoundingClientRect(),s=this.canvas.width/i.width,o=this.canvas.height/i.height,r=this.deviceWidth/this.canvas.width,a=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*r),y:Math.round(n*o*a)}}shouldThrottleMouseMove(){const t=performance.now();return t-this.lastMouseMoveAt<this.MOUSE_THROTTLE_MS?!0:(this.lastMouseMoveAt=t,!1)}getDeviceDimensions(){return{width:this.deviceWidth,height:this.deviceHeight}}}let Ss=null;function hn(){return Ss||(Ss=new Kv),Ss}function qo(e){return e instanceof Error?e.message:String(e)}async function zv(e){if(!e.client){console.error("[browser] startScreencast: no client"),e.browserError="Not connected to gateway";return}if(!e.connected){console.error("[browser] startScreencast: client exists but not connected"),e.browserError="Not connected to gateway";return}console.log("[browser] startScreencast: sending request"),e.browserLoading=!0,e.browserError=null;try{const t=await e.client.request("browser.screencast.start",{quality:60,maxWidth:1280,maxHeight:720});console.log("[browser] startScreencast response:",t),t!=null&&t.ok?e.browserScreencastActive=!0:(console.warn("[browser] startScreencast: response did not have ok=true",t),e.browserError="Screencast start failed (no ok in response)")}catch(t){console.error("[browser] startScreencast error:",t),e.browserError=qo(t)}finally{e.browserLoading=!1}}async function jv(e){if(!(!e.client||!e.connected)){e.browserLoading=!0,e.browserFullscreen=!1;try{await e.client.request("browser.screencast.stop",{}),e.browserScreencastActive=!1,e.browserScreencastFrame=null,e.browserScreencastMetadata=null}catch(t){e.browserError=qo(t)}finally{e.browserLoading=!1}}}async function xs(e,t,n,i,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:i,button:s??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function $s(e,t,n,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...i!=null&&i.text?{text:i.text}:{},...i!=null&&i.code?{code:i.code}:{},...i!=null&&i.modifiers?{modifiers:i.modifiers}:{}})}catch{}}async function Hv(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=qo(t)}}function qv(e){e.browserInputMode=!e.browserInputMode}function Vv(e){e.browserFullscreen=!e.browserFullscreen,hn().detach()}function Gv(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,hn().updateFrame(t.data,t.metadata)}function Qv(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function Yv(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function Js(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),i=n?{sessionKey:n}:{};try{const s=await e.client.request("agent.identity.get",i);if(!s)return;const o=_s(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function eo(e){return(await e.request("apikeys.list")).providers??[]}async function qa(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function Xv(e,t){await e.request("apikeys.remove",{provider:t})}const bi="taskmaster_update_pending";async function gu(e){var t,n;if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("update.status",{});e.currentVersion=i.current,e.latestVersion=i.latest,e.updateAvailable=i.updateAvailable,e.updateMessage=i.updateAvailable?`v${i.latest} available`:"Up to date"}catch(i){e.updateMessage=`Check failed: ${String(i)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function Zv(e){var t,n,i,s;if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e);try{localStorage.setItem(bi,String(Date.now())),localStorage.removeItem(Vo)}catch{}try{const o=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(o.ok&&o.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(o.ok&&o.result.status==="skipped")fn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw fn(),new Error(o.result.reason||"Update failed")}catch(o){fn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function Jv(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const r=t.name,a=t.index,u=t.total;e.updateMessage=`Updating: ${r} (${a+1}/${u})`;const c=e.updateProgressSteps.find(l=>l.index===a);c?(c.status="running",c.name=r):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:u,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const r=t.name,a=t.index,u=t.total,c=t.ok,l=t.durationMs,d=e.updateProgressSteps.find(v=>v.index===a);d?(d.status=c?"done":"failed",d.durationMs=l):e.updateProgressSteps=[...e.updateProgressSteps,{name:r,index:a,total:u,status:c?"done":"failed",durationMs:l}];const h=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${r} done (${a+1}/${u})`:`Update step failed: ${r}${h}`,(s=e.requestUpdate)==null||s.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const a=t.reason;e.updateMessage=a?`Update failed: ${a}`:"Update failed",e.updateRunning=!1,fn()}(o=e.requestUpdate)==null||o.call(e)}}async function eb(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=nb();fn();try{const r=await e.client.request("update.lastResult",{});if(!r.ok||!r.result)return;const a=5*6e4,u=Date.now()-r.result.ts<a;if(!t&&!u||ib(r.result.ts))return;e.updateLastResult=r.result;const c=(n=r.result.after)==null?void 0:n.version;if(r.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,r.result.status==="ok"){const l=(i=r.result.before)==null?void 0:i.version,d=c??r.result.currentVersion;e.updateMessage=l?`Updated: v${l} → v${d}`:`Updated to v${d}`}else{const l=r.result.reason??((s=r.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${l}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(o=e.requestUpdate)==null||o.call(e)}}const Vo="taskmaster_update_dismissed";function tb(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Vo,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function nb(){try{const e=localStorage.getItem(bi);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(bi),!1):!0:!1}catch{return!1}}function fn(){try{localStorage.removeItem(bi)}catch{}}function ib(e){try{const t=localStorage.getItem(Vo);return t?Number(t)>=e:!1}catch{return!1}}function As(e,t){var a,u,c;const n=(e??"").trim(),i=(a=t.mainSessionKey)==null?void 0:a.trim();if(!i)return n;if(!n)return i;const s=((u=t.mainKey)==null?void 0:u.trim())||"main",o=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===s||o&&(n===`agent:${o}:main`||n===`agent:${o}:${s}`)?i:n}function sb(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=As(e.sessionKey,t),i=As(e.settings.sessionKey,t),s=As(e.settings.lastActiveSessionKey,t),o=n||i||e.sessionKey,r={...e.settings,sessionKey:i||o,lastActiveSessionKey:s||o},a=r.sessionKey!==e.settings.sessionKey||r.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),a&&Ge(e,r)}function Te(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=!!e.publicChat,n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,i=t?"public-chat":n?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new Bv({url:e.settings.gatewayUrl,token:t?void 0:e.settings.token.trim()?e.settings.token:void 0,password:t?void 0:e.password.trim()?e.password:void 0,clientName:i,mode:"webchat",role:t?"public":void 0,scopes:t?[]:void 0,onHello:o=>{var r;if(e.connected=!0,e.lastError=null,e.hello=o,t){Va(e,o),Js(e),(((r=e.publicChatConfig)==null?void 0:r.auth)??"anonymous")==="anonymous"&&db(e);return}ui()&&(To(),e.uninstallDone=!1),Va(e,o),e.handleAccessCheck(),eb(e).then(()=>{gu(e)}),Js(e),Lv(e),(e.chatPage||e.setup)&&ab(e),yo(e,{quiet:!0}),mo(e,{quiet:!0}),kn(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Le(e),e.setup&&(lb(e),cb(e),ub(e)),li(e)},onClose:({code:o,reason:r})=>{e.connected=!1,o!==1012&&(e.lastError=`disconnected (${o}): ${r||"no reason"}`)},onEvent:o=>ob(e,o),onGap:({expected:o,received:r})=>{console.warn(`[gateway] event gap: expected seq ${o}, got ${r}`),li(e)}}),e.client.start()}function ob(e,t){try{rb(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function rb(e,t){var n;if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;qd(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&rc(e,i.sessionKey);const s=xl(e,i);if((s==="final"||s==="error"||s==="aborted")&&(ao(e),Dh(e)),s==="final"){const o=e,r=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,Pe);Me(o,{limit:r})}return}if(t.event==="suggestions"){const i=t.payload;(i==null?void 0:i.sessionKey)===e.sessionKey&&Array.isArray(i.suggestions)&&i.suggestions.length>0&&(e.chatSuggestion=i.suggestions[0]);return}if(t.event==="presence"){const i=t.payload;i!=null&&i.presence&&Array.isArray(i.presence)&&(e.presenceEntries=i.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&Eo(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&mo(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=Fv(t.payload);if(i){e.execApprovalQueue=Wv(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Ha(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){Gv(e,t.payload);return}if(t.event==="browser.handoff"){Qv(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){Yv(e);return}if(t.event==="exec.approval.resolved"){const i=Uv(t.payload);i&&(e.execApprovalQueue=Ha(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){Jv(e,t.payload);return}}function Va(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&&sb(e,n.sessionDefaults)}async function ab(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 lb(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await eo(e.client)}catch{}}async function cb(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status")}catch{}}async function ub(e){if(!(!e.client||!e.connected))try{e.wifiStatus=await e.client.request("wifi.status")}catch{}}const Ga="taskmaster_public_id";function mu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${Ga}=`));if(t)return t.split("=")[1];const n=`anon-${((s=crypto.randomUUID)==null?void 0:s.call(crypto))??Math.random().toString(36).slice(2)}`,i=new Date(Date.now()+e*864e5).toUTCString();return document.cookie=`${Ga}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function db(e){var n,i;if(!e.client||!e.connected)return;const t=mu((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const s=(i=e.publicChatConfig)==null?void 0:i.accountId,o=await e.client.request("public.session",{cookieId:t,accountId:s});o!=null&&o.sessionKey&&(e.publicChatSessionKey=o.sessionKey,e.sessionKey=o.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready",Me(e))}catch(s){console.error("[public-chat] failed to resolve anonymous session:",s),e.lastError="Failed to start chat session"}}let Se=!1,de=null,Ot="",wi="";function yu(e){return e.replace(/[\s\-()]/g,"")}function vu(){Se=!1,de=null,Ot="",wi=""}async function pb(e){if(!e.client||!e.connected)return;const t=mu(e.cookieTtlDays);try{const n=await e.client.request("public.session",{cookieId:t,accountId:e.accountId});n!=null&&n.sessionKey&&e.onAuthenticated(n.sessionKey)}catch(n){de=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function Qa(e){if(!e.client||Se)return;const t=yu(Ot);if(!t){de="Please enter your phone number",e.requestUpdate();return}Se=!0,de=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:wi.trim()||void 0});n!=null&&n.ok?e.onAuthStepChange("otp"):de=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){de=n instanceof Error?n.message:"Failed to send verification code"}finally{Se=!1,e.requestUpdate()}}async function Ya(e,t){if(!(!e.client||Se)){if(!t.trim()){de="Please enter the verification code",e.requestUpdate();return}Se=!0,de=null,e.requestUpdate();try{const n=await e.client.request("public.otp.verify",{phone:yu(Ot),code:t.trim(),accountId:e.accountId});n!=null&&n.ok&&n.sessionKey?(vu(),e.onAuthenticated(n.sessionKey)):de=(n==null?void 0:n.error)??"Invalid verification code"}catch(n){de=n instanceof Error?n.message:"Verification failed"}finally{Se=!1,e.requestUpdate()}}}function Es(e){return k}function Xa(e){return p`
3354
3363
  <div class="public-auth__form">
3355
3364
  <label class="field public-auth__field">
3356
3365
  <span>Your name (optional)</span>
3357
3366
  <input
3358
3367
  type="text"
3359
- .value=${bi}
3360
- @input=${t=>{bi=t.target.value}}
3368
+ .value=${wi}
3369
+ @input=${t=>{wi=t.target.value}}
3361
3370
  placeholder="Name"
3362
3371
  />
3363
3372
  </label>
@@ -3365,9 +3374,9 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3365
3374
  <span>WhatsApp number</span>
3366
3375
  <input
3367
3376
  type="tel"
3368
- .value=${Dt}
3369
- @input=${t=>{Dt=t.target.value}}
3370
- @keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),Ga(e))}}
3377
+ .value=${Ot}
3378
+ @input=${t=>{Ot=t.target.value}}
3379
+ @keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),Qa(e))}}
3371
3380
  placeholder="+44 7123 456789"
3372
3381
  required
3373
3382
  />
@@ -3376,15 +3385,15 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3376
3385
  <button
3377
3386
  class="btn primary public-auth__btn"
3378
3387
  ?disabled=${Se}
3379
- @click=${()=>{Ga(e)}}
3388
+ @click=${()=>{Qa(e)}}
3380
3389
  >
3381
3390
  ${Se?"Sending...":"Send verification code"}
3382
3391
  </button>
3383
3392
  </div>
3384
- `}function Xa(e){let t="";return p`
3393
+ `}function Za(e){let t="";return p`
3385
3394
  <div class="public-auth__form">
3386
3395
  <p class="public-auth__hint">
3387
- We sent a verification code to <strong>${Dt}</strong> via WhatsApp.
3396
+ We sent a verification code to <strong>${Ot}</strong> via WhatsApp.
3388
3397
  </p>
3389
3398
  <label class="field public-auth__field">
3390
3399
  <span>Verification code</span>
@@ -3393,7 +3402,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3393
3402
  inputmode="numeric"
3394
3403
  maxlength="6"
3395
3404
  @input=${n=>{t=n.target.value}}
3396
- @keydown=${n=>{n.key==="Enter"&&(n.preventDefault(),Qa(e,t))}}
3405
+ @keydown=${n=>{n.key==="Enter"&&(n.preventDefault(),Ya(e,t))}}
3397
3406
  placeholder="123456"
3398
3407
  required
3399
3408
  />
@@ -3402,7 +3411,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3402
3411
  <button
3403
3412
  class="btn primary public-auth__btn"
3404
3413
  ?disabled=${Se}
3405
- @click=${()=>{Qa(e,t)}}
3414
+ @click=${()=>{Ya(e,t)}}
3406
3415
  >
3407
3416
  ${Se?"Verifying...":"Verify"}
3408
3417
  </button>
@@ -3413,7 +3422,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3413
3422
  Use a different number
3414
3423
  </button>
3415
3424
  </div>
3416
- `}function pb(e){const{authMode:t,authStep:n}=e;return t==="anonymous"?p`
3425
+ `}function hb(e){const{authMode:t,authStep:n}=e;return t==="anonymous"?p`
3417
3426
  <div class="setup-container">
3418
3427
  <div class="setup-card">
3419
3428
  <div class="setup-spinner"></div>
@@ -3423,31 +3432,31 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3423
3432
  `:t==="verified"?p`
3424
3433
  <div class="setup-container">
3425
3434
  <div class="public-auth">
3426
- ${As()}
3435
+ ${Es()}
3427
3436
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
3428
3437
  <p class="public-auth__subtitle">Verify your WhatsApp number to get started.</p>
3429
- ${n==="otp"?Xa(e):Ya(e)}
3438
+ ${n==="otp"?Za(e):Xa(e)}
3430
3439
  </div>
3431
3440
  </div>
3432
3441
  `:n==="phone"||n==="otp"?p`
3433
3442
  <div class="setup-container">
3434
3443
  <div class="public-auth">
3435
- ${As()}
3444
+ ${Es()}
3436
3445
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
3437
3446
  <p class="public-auth__subtitle">Verify your WhatsApp number to continue your conversation across devices.</p>
3438
- ${n==="otp"?Xa(e):Ya(e)}
3447
+ ${n==="otp"?Za(e):Xa(e)}
3439
3448
  </div>
3440
3449
  </div>
3441
3450
  `:p`
3442
3451
  <div class="setup-container">
3443
3452
  <div class="public-auth">
3444
- ${As()}
3453
+ ${Es()}
3445
3454
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
3446
3455
  <p class="public-auth__subtitle">How would you like to get started?</p>
3447
3456
  <div class="public-auth__choices">
3448
3457
  <button
3449
3458
  class="btn primary public-auth__btn"
3450
- @click=${()=>{db(e)}}
3459
+ @click=${()=>{pb(e)}}
3451
3460
  >
3452
3461
  Chat now
3453
3462
  </button>
@@ -3463,7 +3472,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3463
3472
  </p>
3464
3473
  </div>
3465
3474
  </div>
3466
- `}const Vo="taskmaster-access-session",bu={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function wu(){try{return localStorage.getItem(Vo)}catch{return null}}function ku(e){try{localStorage.setItem(Vo,e)}catch{}}function hb(){try{localStorage.removeItem(Vo)}catch{}}async function Za(e){if(e.client)try{const t=wu(),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 fb(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const i=await e.client.request("access.verify",{account:t,pin:n});i.ok&&i.token?(ku(i.token),e.accessState={...e.accessState,authenticated:!0,workspace:i.workspace??null,master:i.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:i.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function gb(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?(ku(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 mb(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 yb(e){const t=wu();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}hb(),e.accessState={...bu,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function vb(e,t="admin"){var s;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const i=[];for(const o of n){if(!o||typeof o!="object"||o.agentId!==t&&o.agentId!=="management")continue;const r=o.match;if(!r||typeof r!="object"||(r.channel??"").toLowerCase()!=="whatsapp")continue;const u=r.peer;if(!u||typeof u!="object"||u.kind!=="dm")continue;const c=u.id??"";c&&i.push({phone:c,paired:((s=o.meta)==null?void 0:s.paired)===!0})}return i.sort((o,r)=>o.paired&&!r.paired?-1:!o.paired&&r.paired?1:0),i}function Su(e,t,n="admin",i){const s=c=>c===n||c==="management",o=new Map,r=new Map;for(const c of e){if(!c||typeof c!="object"||!s(c.agentId))continue;const l=c.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")continue;const h=l.peer;if(!h||typeof h!="object"||h.kind!=="dm")continue;const v=h.id??"";v&&(c.meta&&o.set(v,c.meta),l.accountId&&r.set(v,l.accountId))}const a=e.filter(c=>{if(!c||typeof c!="object"||!s(c.agentId))return!0;const l=c.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")return!0;const h=l.peer;return!h||typeof h!="object"?!0:h.kind!=="dm"}),u=t.map(c=>{const l=i??r.get(c.phone),d={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};l&&(d.accountId=l);const h={agentId:n,match:d},v=o.get(c.phone);return v?h.meta=v:c.paired&&(h.meta={paired:!0}),h});return[...a,...u]}async function Li(e,t){if(!e.client||!e.connected)return;if(!t){e.adminPhones=[];return}if(e.adminsLoading)return;e.adminsLoading=!0,e.adminsError=null;const n=t;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.config;e.configForm=Ye(s??{}),e.adminPhones=vb(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function xu(e,t,n,i){var r,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n;let o=t.replace(/[\s\-\(\)]/g,"");if(!o){e.adminsError="Phone number is required";return}if(o.startsWith("+")||(o="+"+o),!/^\+[1-9]\d{6,14}$/.test(o)){e.adminsError="Invalid phone number. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(u=>u.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const u=Ye(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=u.bindings??[],l=[...e.adminPhones,{phone:o}],d=Su(c,l,s,i);$l(u,["bindings"],d);const h=(a=e.configSnapshot)==null?void 0:a.hash;if(!h){e.adminsError="Config hash missing; reload and retry.";return}const v=ct(u);await e.client.request("config.set",{raw:v,baseHash:h}),await Li(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}async function $u(e,t,n,i){var r,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n,o=e.adminPhones.find(u=>u.phone===t);if(o!=null&&o.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const u=Ye(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=u.bindings??[],l=e.adminPhones.filter(f=>f.phone!==t),d=Su(c,l,s,i);$l(u,["bindings"],d);const h=(a=e.configSnapshot)==null?void 0:a.hash;if(!h){e.adminsError="Config hash missing; reload and retry.";return}const v=ct(u);await e.client.request("config.set",{raw:v,baseHash:h}),await Li(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}const bb=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:xu,loadAdmins:Li,removeAdmin:$u},Symbol.toStringTag,{value:"Module"}));async function mt(e,t){if(!(!e.client||!e.connected)){if(!t){e.contactsRecords=[];return}if(!e.contactsLoading){e.contactsLoading=!0,e.contactsError=null;try{const n=e.contactsSearchQuery.trim(),i=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.contactsRecords=i.records??[]}catch(n){e.contactsError=String(n)}finally{e.contactsLoading=!1}}}}async function Au(e,t,n,i){if(!e.client||!e.connected||e.contactsSaving)return;let s=t.replace(/[\s\-\(\)]/g,"");const o=n.trim();if(!s){e.contactsError="Phone number is required";return}if(!o){e.contactsError="Name is required";return}if(s.startsWith("+")||(s="+"+s),!/^\+[1-9]\d{6,14}$/.test(s)){e.contactsError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.set",{id:s,name:o,fields:{},workspace:i}),e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName="",await mt(e,i)}catch(r){e.contactsError=String(r)}finally{e.contactsSaving=!1}}async function Eu(e,t,n){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.delete",{id:t}),e.contactsEditingId===t&&(e.contactsEditingId=null),await mt(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function Cu(e,t,n,i,s){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.setField",{id:t,key:n,value:i}),await mt(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function Tu(e,t,n,i){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await mt(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const wb=Object.freeze(Object.defineProperty({__proto__:null,addContact:Au,deleteContact:Eu,deleteContactField:Tu,loadContacts:mt,setContactField:Cu},Symbol.toStringTag,{value:"Module"}));function en(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 kb(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 Sb(e){const t=oe(e);if(!t)return;const n=t.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return n==null?void 0:n.id}function xb(e){const t=oe(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function $b(e){var i;const t=oe(e);if(!t)return;const n=t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin");return(n==null?void 0:n.id)??((i=t.agents[0])==null?void 0:i.id)}function Ab(e){return e.selectedWorkspace??void 0}function oe(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const Eb=/^data:/i,Cb=/^https?:\/\//i;function Ja(e){var a,u;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=dl(e.sessionKey),i=(n==null?void 0:n.agentId)??((u=e.agentsList)==null?void 0:u.defaultId)??"main",s=t.find(c=>c.id===i),o=s==null?void 0:s.identity,r=(o==null?void 0:o.avatarUrl)??(o==null?void 0:o.avatar);if(r)return Eb.test(r)||Cb.test(r)?r:o==null?void 0:o.avatarUrl}function Tb(e){var i;if(!e)return null;const t=(i=e.channelAccounts)==null?void 0:i.whatsapp;if(!t||t.length===0)return null;const n=t[0];return{running:n.running??!1,connected:n.connected??!1,linked:n.linked??!1,lastError:n.lastError}}function _b(e){var r;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(r=e.channelAccounts)==null?void 0:r.imessage;if(!t||t.length===0)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const n=t[0],i=n.running??!1,s=n.probe,o=s!=null?s.ok===!0:i;return{configured:n.configured??!1,running:i,connected:o,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function Mb(e){var r;const t=(r=e.configSnapshot)==null?void 0:r.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(a=>{var u,c;return((u=a.match)==null?void 0:u.channel)==="imessage"&&((c=a.meta)==null?void 0:c.imessageOwner)});if(!i)return null;const s=i.agentId;for(const a of e.workspaces)if(a.agents.some(u=>u.id===s))return a.name;if(s==="admin"||s==="public"){const a=e.workspaces.find(u=>u.isDefault);return(a==null?void 0:a.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const a=e.workspaces.find(u=>u.name===o);return(a==null?void 0:a.name)??null}return null}function Pb(e){var t,n,i,s,o,r,a,u,c;if(e.embeddingDownloading&&!e.publicChat)return p`
3475
+ `}const Go="taskmaster-access-session",bu={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function wu(){try{return localStorage.getItem(Go)}catch{return null}}function ku(e){try{localStorage.setItem(Go,e)}catch{}}function fb(){try{localStorage.removeItem(Go)}catch{}}async function Ja(e){if(e.client)try{const t=wu(),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 gb(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const i=await e.client.request("access.verify",{account:t,pin:n});i.ok&&i.token?(ku(i.token),e.accessState={...e.accessState,authenticated:!0,workspace:i.workspace??null,master:i.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:i.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function mb(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?(ku(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 yb(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 vb(e){const t=wu();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}fb(),e.accessState={...bu,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function bb(e,t="admin"){var s;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const i=[];for(const o of n){if(!o||typeof o!="object"||o.agentId!==t&&o.agentId!=="management")continue;const r=o.match;if(!r||typeof r!="object"||(r.channel??"").toLowerCase()!=="whatsapp")continue;const u=r.peer;if(!u||typeof u!="object"||u.kind!=="dm")continue;const c=u.id??"";c&&i.push({phone:c,paired:((s=o.meta)==null?void 0:s.paired)===!0})}return i.sort((o,r)=>o.paired&&!r.paired?-1:!o.paired&&r.paired?1:0),i}function Su(e,t,n="admin",i){const s=c=>c===n||c==="management",o=new Map,r=new Map;for(const c of e){if(!c||typeof c!="object"||!s(c.agentId))continue;const l=c.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")continue;const h=l.peer;if(!h||typeof h!="object"||h.kind!=="dm")continue;const v=h.id??"";v&&(c.meta&&o.set(v,c.meta),l.accountId&&r.set(v,l.accountId))}const a=e.filter(c=>{if(!c||typeof c!="object"||!s(c.agentId))return!0;const l=c.match;if(!l||typeof l!="object"||(l.channel??"").toLowerCase()!=="whatsapp")return!0;const h=l.peer;return!h||typeof h!="object"?!0:h.kind!=="dm"}),u=t.map(c=>{const l=i??r.get(c.phone),d={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};l&&(d.accountId=l);const h={agentId:n,match:d},v=o.get(c.phone);return v?h.meta=v:c.paired&&(h.meta={paired:!0}),h});return[...a,...u]}async function Ii(e,t){if(!e.client||!e.connected)return;if(!t){e.adminPhones=[];return}if(e.adminsLoading)return;e.adminsLoading=!0,e.adminsError=null;const n=t;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.config;e.configForm=Ye(s??{}),e.adminPhones=bb(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function xu(e,t,n,i){var r,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n;let o=t.replace(/[\s\-\(\)]/g,"");if(!o){e.adminsError="Phone number is required";return}if(o.startsWith("+")||(o="+"+o),!/^\+[1-9]\d{6,14}$/.test(o)){e.adminsError="Invalid phone number. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(u=>u.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const u=Ye(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=u.bindings??[],l=[...e.adminPhones,{phone:o}],d=Su(c,l,s,i);Al(u,["bindings"],d);const h=(a=e.configSnapshot)==null?void 0:a.hash;if(!h){e.adminsError="Config hash missing; reload and retry.";return}const v=ut(u);await e.client.request("config.set",{raw:v,baseHash:h}),await Ii(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}async function $u(e,t,n,i){var r,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n,o=e.adminPhones.find(u=>u.phone===t);if(o!=null&&o.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const u=Ye(e.configForm??((r=e.configSnapshot)==null?void 0:r.config)??{}),c=u.bindings??[],l=e.adminPhones.filter(f=>f.phone!==t),d=Su(c,l,s,i);Al(u,["bindings"],d);const h=(a=e.configSnapshot)==null?void 0:a.hash;if(!h){e.adminsError="Config hash missing; reload and retry.";return}const v=ut(u);await e.client.request("config.set",{raw:v,baseHash:h}),await Ii(e,n)}catch(u){e.adminsError=String(u)}finally{e.adminsSaving=!1}}const wb=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:xu,loadAdmins:Ii,removeAdmin:$u},Symbol.toStringTag,{value:"Module"}));async function yt(e,t){if(!(!e.client||!e.connected)){if(!t){e.contactsRecords=[];return}if(!e.contactsLoading){e.contactsLoading=!0,e.contactsError=null;try{const n=e.contactsSearchQuery.trim(),i=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.contactsRecords=i.records??[]}catch(n){e.contactsError=String(n)}finally{e.contactsLoading=!1}}}}async function Au(e,t,n,i){if(!e.client||!e.connected||e.contactsSaving)return;let s=t.replace(/[\s\-\(\)]/g,"");const o=n.trim();if(!s){e.contactsError="Phone number is required";return}if(!o){e.contactsError="Name is required";return}if(s.startsWith("+")||(s="+"+s),!/^\+[1-9]\d{6,14}$/.test(s)){e.contactsError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.set",{id:s,name:o,fields:{},workspace:i}),e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName="",await yt(e,i)}catch(r){e.contactsError=String(r)}finally{e.contactsSaving=!1}}async function Eu(e,t,n){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.delete",{id:t}),e.contactsEditingId===t&&(e.contactsEditingId=null),await yt(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function Cu(e,t,n,i,s){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.setField",{id:t,key:n,value:i}),await yt(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function Tu(e,t,n,i){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await yt(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const kb=Object.freeze(Object.defineProperty({__proto__:null,addContact:Au,deleteContact:Eu,deleteContactField:Tu,loadContacts:yt,setContactField:Cu},Symbol.toStringTag,{value:"Module"}));function sn(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0}}}function Sb(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 xb(e){const t=oe(e);if(!t)return;const n=t.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return n==null?void 0:n.id}function $b(e){const t=oe(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function Ab(e){var i;const t=oe(e);if(!t)return;const n=t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin");return(n==null?void 0:n.id)??((i=t.agents[0])==null?void 0:i.id)}function Eb(e){return e.selectedWorkspace??void 0}function oe(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const Cb=/^data:/i,Tb=/^https?:\/\//i;function el(e){var a,u;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=pl(e.sessionKey),i=(n==null?void 0:n.agentId)??((u=e.agentsList)==null?void 0:u.defaultId)??"main",s=t.find(c=>c.id===i),o=s==null?void 0:s.identity,r=(o==null?void 0:o.avatarUrl)??(o==null?void 0:o.avatar);if(r)return Cb.test(r)||Tb.test(r)?r:o==null?void 0:o.avatarUrl}function _b(e){var i;if(!e)return null;const t=(i=e.channelAccounts)==null?void 0:i.whatsapp;if(!t||t.length===0)return null;const n=t[0];return{running:n.running??!1,connected:n.connected??!1,linked:n.linked??!1,lastError:n.lastError}}function Mb(e){var r;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(r=e.channelAccounts)==null?void 0:r.imessage;if(!t||t.length===0)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const n=t[0],i=n.running??!1,s=n.probe,o=s!=null?s.ok===!0:i;return{configured:n.configured??!1,running:i,connected:o,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function Pb(e){var r;const t=(r=e.configSnapshot)==null?void 0:r.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(a=>{var u,c;return((u=a.match)==null?void 0:u.channel)==="imessage"&&((c=a.meta)==null?void 0:c.imessageOwner)});if(!i)return null;const s=i.agentId;for(const a of e.workspaces)if(a.agents.some(u=>u.id===s))return a.name;if(s==="admin"||s==="public"){const a=e.workspaces.find(u=>u.isDefault);return(a==null?void 0:a.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const a=e.workspaces.find(u=>u.name===o);return(a==null?void 0:a.name)??null}return null}function Lb(e){var t,n,i,s,o,r,a,u,c;if(e.embeddingDownloading&&!e.publicChat)return p`
3467
3476
  <div class="setup-container">
3468
3477
  <div class="setup-card" style="text-align:center; max-width:420px;">
3469
3478
  <div class="setup-spinner"></div>
@@ -3477,14 +3486,14 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3477
3486
  </p>
3478
3487
  </div>
3479
3488
  </div>
3480
- `;if(e.publicChat)return e.connected?e.publicChatAuthenticated?Mv({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??Ja(e)??null,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,canAbort:!!e.chatRunId,disabledReason:e.connected?null:"Disconnected.",error:e.lastError,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,suggestion:e.chatSuggestion,onSuggestionClick:l=>{e.chatMessage=l,e.chatSuggestion=null,e.handleSendChat()},onRefresh:()=>(e.resetToolStream(),ie(async()=>{const{loadChatHistory:l}=await Promise.resolve().then(()=>si);return{loadChatHistory:l}},void 0,import.meta.url).then(({loadChatHistory:l})=>{l(e)})),onDraftChange:l=>e.chatMessage=l,attachments:e.chatAttachments,onAttachmentsChange:l=>e.chatAttachments=l,onSend:()=>e.handleSendChat(),onAbort:()=>{e.handleAbortChat()},onQueueRemove:l=>e.removeQueuedMessage(l),onChatScroll:l=>e.handleChatScroll(l),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()}}):pb({authMode:e.publicChatConfig.auth??"anonymous",authStep:e.publicChatAuthStep,connected:e.connected,client:e.client,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,accountId:e.publicChatConfig.accountId,cookieTtlDays:e.publicChatConfig.cookieTtlDays,onAuthenticated:l=>{e.publicChatSessionKey=l,e.sessionKey=l,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready",ie(async()=>{const{loadChatHistory:d}=await Promise.resolve().then(()=>si);return{loadChatHistory:d}},void 0,import.meta.url).then(({loadChatHistory:d})=>{d(e)})},onAuthStepChange:l=>{e.publicChatAuthStep=l},requestUpdate:()=>{e.requestUpdate()}}):p`
3489
+ `;if(e.publicChat)return e.connected?e.publicChatAuthenticated?Pv({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??el(e)??null,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,canAbort:!!e.chatRunId,disabledReason:e.connected?null:"Disconnected.",error:e.lastError,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,suggestion:e.chatSuggestion,onSuggestionClick:l=>{e.chatMessage=l,e.chatSuggestion=null,e.handleSendChat()},onRefresh:()=>(e.resetToolStream(),ie(async()=>{const{loadChatHistory:l}=await Promise.resolve().then(()=>oi);return{loadChatHistory:l}},void 0,import.meta.url).then(({loadChatHistory:l})=>{l(e)})),onDraftChange:l=>e.chatMessage=l,attachments:e.chatAttachments,onAttachmentsChange:l=>e.chatAttachments=l,onSend:()=>e.handleSendChat(),onAbort:()=>{e.handleAbortChat()},onQueueRemove:l=>e.removeQueuedMessage(l),onChatScroll:l=>e.handleChatScroll(l),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()}}):hb({authMode:e.publicChatConfig.auth??"anonymous",authStep:e.publicChatAuthStep,connected:e.connected,client:e.client,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,accountId:e.publicChatConfig.accountId,cookieTtlDays:e.publicChatConfig.cookieTtlDays,onAuthenticated:l=>{e.publicChatSessionKey=l,e.sessionKey=l,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready",ie(async()=>{const{loadChatHistory:d}=await Promise.resolve().then(()=>oi);return{loadChatHistory:d}},void 0,import.meta.url).then(({loadChatHistory:d})=>{d(e)})},onAuthStepChange:l=>{e.publicChatAuthStep=l},requestUpdate:()=>{e.requestUpdate()}}):p`
3481
3490
  <div class="setup-container">
3482
3491
  <div class="setup-card">
3483
3492
  <div class="setup-spinner"></div>
3484
3493
  <p>Connecting...</p>
3485
3494
  </div>
3486
3495
  </div>
3487
- `;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return Ka({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(d,h)=>{h!=null&&e.handlePinSubmit(d,h)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(d,h,v)=>e.handleChangePin(d,h,v)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return Ka({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:d=>e.handleSetMasterPin(d)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",k}if(e.setup){const l=Tb(e.channelsSnapshot),d=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],h=_b(e.channelsSnapshot),v=Mb(e);return ff({connected:e.connected,serverPlatform:((s=(i=e.hello)==null?void 0:i.server)==null?void 0:s.platform)??null,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:f=>e.handleLicenseKeyChange(f),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:l,whatsappAccounts:d,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:f=>e.handleUninstallConfirmTextChange(f),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:f=>e.handleAuthSubmitCode(f),onAuthCodeChange:f=>e.handleAuthCodeChange(f),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async f=>{await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await G(e,!0),e.requestUpdate())},onWhatsAppUnlink:async f=>{await e.handleWhatsAppLogout(f)},onWhatsAppReset:async f=>{await e.handleWhatsAppLogout(f),await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await G(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await G(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),G(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:f=>e.handleRemoveWhatsAppAccount(f),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:f=>{e.newWorkspacePin=f},onWorkspaceCreate:async(f,b)=>{const S=e.newWorkspacePin;await e.handleWorkspaceCreate(f,b),S.match(/^\d{4,6}$/)&&(await mb(e,f,S),e.newWorkspacePin="")},onWorkspaceRemove:f=>e.handleWorkspaceRemove(f),onSetAddingWorkspace:f=>{e.addingWorkspace=f},onSetNewWorkspaceName:f=>{e.newWorkspaceName=f},onSetNewWorkspacePath:f=>{e.newWorkspacePath=f},onSetWorkspaceRemoveConfirm:f=>{e.workspaceRemoveConfirm=f},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(f,b)=>e.handleWorkspaceRename(f,b),whatsappDmPolicy:(()=>{const f=oe(e),b=f==null?void 0:f.whatsappAccountId,S=b?d.find($=>$.accountId===b):d[0];return(S==null?void 0:S.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var T;const f=oe(e),b=f==null?void 0:f.whatsappAccountId,S=b?d.find(M=>M.accountId===b):d[0];if(!S)return;const A=S.dmPolicy!=null&&S.dmPolicy!=="disabled"?"disabled":"open",C=A==="open"?{dmPolicy:A,allowFrom:["*"]}:{dmPolicy:A};try{const M=await e.client.request("config.get"),R=M.config,B=(T=R==null?void 0:R.channels)==null?void 0:T.whatsapp,me=((B==null?void 0:B.accounts)??{})[S.accountId]?{channels:{whatsapp:{accounts:{[S.accountId]:C}}}}:{channels:{whatsapp:C}};await e.client.request("config.patch",{raw:JSON.stringify(me),baseHash:M.hash,note:`WhatsApp DM policy → ${A}`,skipRestart:!0}),await G(e,!1)}catch(M){console.error("DM toggle failed:",M)}},whatsappModel:(()=>{var T,M;const f=oe(e);if(!f)return null;const b=f.agents.find(R=>R.id.endsWith("-public")||R.id==="public");if(!b)return null;const S=(T=e.configSnapshot)==null?void 0:T.config,$=(M=S==null?void 0:S.agents)==null?void 0:M.list;if(!Array.isArray($))return null;const A=$.find(R=>R.id===b.id);if(!(A!=null&&A.model))return null;const C=typeof A.model=="string"?A.model:A.model.primary;return(C==null?void 0:C.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async f=>{const b=oe(e);if(!b)return;const S=b.agents.find($=>$.id.endsWith("-public")||$.id==="public");if(S)try{const $=await e.client.request("config.get"),A=$.config,C=(A==null?void 0:A.agents)??{},T=Array.isArray(C.list)?[...C.list]:[],M=T.findIndex(B=>B.id===S.id);if(f)M>=0?T[M]={...T[M],model:f}:T.push({id:S.id,model:f});else if(M>=0){const{model:B,...ee}=T[M];Object.keys(ee).length<=1?T.splice(M,1):T[M]=ee}const R=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(R),baseHash:$.hash,note:`Public agent model → ${f||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Model change failed:",$)}},whatsappThinkingLevel:(()=>{var C,T,M;const f=oe(e);if(!f)return null;const b=f.agents.find(R=>R.id.endsWith("-public")||R.id==="public");if(!b)return null;const S=(C=e.configSnapshot)==null?void 0:C.config,$=(T=S==null?void 0:S.agents)==null?void 0:T.list;if(!Array.isArray($))return null;const A=$.find(R=>R.id===b.id);return((M=A==null?void 0:A.thinkingLevel)==null?void 0:M.trim())||null})(),onWhatsAppThinkingChange:async f=>{const b=oe(e);if(!b)return;const S=b.agents.find($=>$.id.endsWith("-public")||$.id==="public");if(S)try{const $=await e.client.request("config.get"),A=$.config,C=(A==null?void 0:A.agents)??{},T=Array.isArray(C.list)?[...C.list]:[],M=T.findIndex(ee=>ee.id===S.id),R=f==="off"?void 0:f;if(R)M>=0?T[M]={...T[M],thinkingLevel:R}:T.push({id:S.id,thinkingLevel:R});else if(M>=0){const{thinkingLevel:ee,...me}=T[M];Object.keys(me).length<=1?T.splice(M,1):T[M]=me}const B=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(B),baseHash:$.hash,note:`Public agent thinking → ${R||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Thinking change failed:",$)}},whatsappGroupPolicy:(()=>{var M,R;const f=(M=e.configSnapshot)==null?void 0:M.config,b=(R=f==null?void 0:f.channels)==null?void 0:R.whatsapp,S=oe(e),$=S==null?void 0:S.whatsappAccountId,A=(b==null?void 0:b.accounts)??{},C=$?A[$]:void 0;return(C==null?void 0:C.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var R,B;const f=(R=e.configSnapshot)==null?void 0:R.config,b=(B=f==null?void 0:f.channels)==null?void 0:B.whatsapp,S=oe(e),$=S==null?void 0:S.whatsappAccountId,A=(b==null?void 0:b.accounts)??{},C=$?A[$]:void 0,M=((C==null?void 0:C.groups)??(b==null?void 0:b.groups)??{})["*"];return(M==null?void 0:M.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var S;const f=oe(e),b=f==null?void 0:f.whatsappAccountId;try{const $=await e.client.request("config.get"),A=$.config,C=((S=A==null?void 0:A.channels)==null?void 0:S.whatsapp)??{},T=C.accounts??{},M=b?T[b]:void 0,R=(M==null?void 0:M.groupPolicy)??C.groupPolicy??"allowlist",B=R==="disabled"||R==="allowlist",ee=B?"open":"disabled",me=B?{"*":{}}:void 0,Ke={groupPolicy:ee};me&&(Ke.groups=me);const Z=M?{channels:{whatsapp:{accounts:{[b]:Ke}}}}:{channels:{whatsapp:Ke}};await e.client.request("config.patch",{raw:JSON.stringify(Z),baseHash:$.hash,note:`WhatsApp groups → ${ee}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Group toggle failed:",$)}},onWhatsAppGroupMentionChange:async f=>{var $;const b=oe(e),S=b==null?void 0:b.whatsappAccountId;try{const A=await e.client.request("config.get"),C=A.config,M=((($=C==null?void 0:C.channels)==null?void 0:$.whatsapp)??{}).accounts??{},R=S?M[S]:void 0,B={"*":{requireMention:f}},ee=R?{channels:{whatsapp:{accounts:{[S]:{groups:B}}}}}:{channels:{whatsapp:{groups:B}}};await e.client.request("config.patch",{raw:JSON.stringify(ee),baseHash:A.hash,note:`WhatsApp group mention → ${f?"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:h.configured,imessageRunning:h.running,imessageConnected:h.connected,imessageLastError:h.lastError,imessageSelfChatMode:h.selfChatMode,imessageCliPath:h.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:v,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,S=(b==null?void 0:b.bindings)??[],$=oe(e),A=$==null?void 0:$.agents.find(B=>B.id.endsWith("-admin")||B.id==="admin"),C=(A==null?void 0:A.id)??"admin",T=S.filter(B=>{var ee;return((ee=B.match)==null?void 0:ee.channel)!=="imessage"}),M=[{agentId:C,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],R=[...T,...M];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:R}),baseHash:f.hash,note:"Enable iMessage (self-chat) for "+(($==null?void 0:$.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([G(e,!0),Le(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await G(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,$=((b==null?void 0:b.bindings)??[]).filter(A=>{var C;return((C=A.match)==null?void 0:C.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:$}),baseHash:f.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([G(e,!0),Le(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,S=(b==null?void 0:b.bindings)??[],$=oe(e),A=$==null?void 0:$.agents.find(R=>R.id.endsWith("-admin")||R.id==="admin"),C=(A==null?void 0:A.id)??"admin",T=S.filter(R=>{var B;return((B=R.match)==null?void 0:B.channel)!=="imessage"}),M=[{agentId:C,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:[...T,...M]}),baseHash:f.hash,note:"Reassign iMessage to "+(($==null?void 0:$.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([G(e,!0),Le(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:f=>{e.infoModalOpen=f},onInfoModalClose:()=>{e.infoModalOpen=null},isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,apiKeySavingProvider:e.apiKeySavingProvider,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeySave:async(f,b)=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ha(e.client,f,b);const S=`${f} key saved`;e.apiKeySuccess=S,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Js(e.client)}catch{}f==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===S&&(e.apiKeySuccess=null)},2500)}catch(S){e.apiKeyError=S instanceof Error?S.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async f=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Yv(e.client,f);const b=`${f} key removed`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Js(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:f=>{e.authApiKeyInput=f},onAuthApiKeySubmit:async()=>{const f=e.authApiKeyInput.trim();if(f){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await Ha(e.client,"anthropic",f),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(b){e.authApiKeyError=b instanceof Error?b.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var b;const f=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return f?e.accessState.accounts.some(S=>S.id===f):!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:(f,b)=>{var $;const S=e.selectedWorkspace??(($=e.workspaces[0])==null?void 0:$.name);S&&e.handleAccountPinSave(S,f,b)},publicChatEnabled:(()=>{var S;const f=(S=e.configSnapshot)==null?void 0:S.config,b=f==null?void 0:f.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var $;const f=($=e.configSnapshot)==null?void 0:$.config,b=f==null?void 0:f.publicChat,S=b==null?void 0:b.auth;return S==="verified"||S==="choice"?S:"anonymous"})(),publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var f;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),S=b.config,$=((f=S==null?void 0:S.publicChat)==null?void 0:f.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!$}}),baseHash:b.hash,note:`Public chat → ${$?"disabled":"enabled"}`}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Public chat toggle failed:",b)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async f=>{if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{auth:f}}),baseHash:b.hash,note:`Public chat auth → ${f}`}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Public chat auth mode change failed:",b)}finally{e.publicChatToggleBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null;try{const f=await e.client.request("tailscale.enable");if(f.authUrl){e.tailscaleAuthUrl=f.authUrl;const b=setInterval(async()=>{try{const S=await e.client.request("tailscale.status");e.tailscaleStatus=S,S.loggedIn&&(clearInterval(b),e.tailscaleAuthUrl=null,e.tailscaleBusy=!1)}catch{}},3e3);setTimeout(()=>{clearInterval(b),e.tailscaleBusy&&(e.tailscaleBusy=!1)},3e5)}else f.alreadyLoggedIn&&(e.tailscaleStatus=await e.client.request("tailscale.status")),e.tailscaleBusy=!1}catch(f){console.error("Tailscale enable failed:",f),e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var f;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable")}catch(b){console.error("Tailscale funnel enable failed:",b);const S=b;(f=S.payload)!=null&&f.enableUrl&&(e.tailscaleFunnelEnableUrl=S.payload.enableUrl),e.tailscaleError=S.message||"Failed to enable Funnel",e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable")}catch(f){console.error("Tailscale funnel disable failed:",f),e.tailscaleBusy=!1}}},wifiStatus:e.wifiStatus,wifiNetworks:e.wifiNetworks,wifiBusy:e.wifiBusy,wifiError:e.wifiError,wifiPassword:e.wifiPassword,wifiSelectedSsid:e.wifiSelectedSsid,onWifiScan:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[f,b]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);e.wifiNetworks=f.networks,e.wifiStatus=b}catch(f){console.error("WiFi scan failed:",f),e.wifiError=f.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{if(!(e.wifiBusy||!e.wifiSelectedSsid)){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.connect",{ssid:e.wifiSelectedSsid,password:e.wifiPassword}),e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[];const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi connect failed:",f),e.wifiError=f.message||"Failed to connect"}finally{e.wifiBusy=!1}}},onWifiDisconnect:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.disconnect"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi disconnect failed:",f),e.wifiError=f.message||"Failed to disconnect"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:f=>{e.wifiSelectedSsid=f,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:f=>{e.wifiPassword=f},wsProps:kb(e)})}if(e.filesPage){const l=$b(e);return Zh({connected:e.connected,wsProps:en(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:()=>vn(e,l),onReindex:()=>ch(e,l),onSelectFile:d=>ih(e,d,l),onToggleSelectFile:d=>sh(e,d,l),onToggleDir:d=>uh(e,d),onUpload:(d,h)=>ah(e,d,h,l),onDownload:d=>sc(e,d,l),onBulkDownload:()=>oh(e,l),onDelete:d=>lh(e,d,l),onMove:(d,h)=>oc(e,d,h,l),onMoveToDir:(d,h)=>rh(e,d,h,l),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:d=>{const h=e.filesSearchAgentId??l;dh(e,d,h)},onSearchAgentChange:d=>{e.filesSearchAgentId=d},onSearchClear:()=>{ph(e)},onSearchQueryChange:d=>{e.filesSearchQuery=d}})}if(e.browserPage)return Hh({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,fullscreen:e.browserFullscreen,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>Kv(e),onStop:()=>zv(e),onToggleInput:()=>Hv(e),onToggleFullscreen:()=>qv(e),onCompleteHandoff:()=>jv(e),onCanvasMouseDown:l=>{const h=l.target.getBoundingClientRect(),f=un().translateCoordinates(l.clientX-h.left,l.clientY-h.top);Ss(e,"mousePressed",f.x,f.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const h=l.target.getBoundingClientRect(),f=un().translateCoordinates(l.clientX-h.left,l.clientY-h.top);Ss(e,"mouseReleased",f.x,f.y)},onCanvasMouseMove:l=>{const d=un();if(d.shouldThrottleMouseMove())return;const v=l.target.getBoundingClientRect(),f=d.translateCoordinates(l.clientX-v.left,l.clientY-v.top);Ss(e,"mouseMoved",f.x,f.y)},onCanvasKeyDown:l=>{let d=0;l.altKey&&(d|=1),l.ctrlKey&&(d|=2),l.metaKey&&(d|=4),l.shiftKey&&(d|=8),xs(e,"keyDown",l.key,{code:l.code,modifiers:d||void 0}),l.key.length===1&&xs(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{xs(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=Sb(e),d=xb(e);return mf({connected:e.connected,wsProps:en(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>Li(e,l),onAdd:h=>{xu(e,h,l,d).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:h=>$u(e,h,l,d),onNewPhoneChange:h=>e.handleAdminsNewPhoneChange(h)})}if(e.contactsPage){const l=Ab(e);return wf({connected:e.connected,wsProps:en(e),loading:e.contactsLoading,saving:e.contactsSaving,records:e.contactsRecords,error:e.contactsError,searchQuery:e.contactsSearchQuery,editingId:e.contactsEditingId,showAddForm:e.contactsShowAddForm,newRecordPhone:e.contactsNewPhone,newRecordName:e.contactsNewName,onSearch:d=>e.contactsSearchQuery=d,onSearchSubmit:()=>mt(e,l),onAdd:(d,h)=>Au(e,d,h,l),onDelete:d=>Eu(e,d,l),onSetField:(d,h,v)=>Cu(e,d,h,v,l),onDeleteField:(d,h)=>Tu(e,d,h,l),onToggleExpand:d=>{e.contactsEditingId=e.contactsEditingId===d?null:d},onShowAddForm:()=>e.contactsShowAddForm=!0,onCancelAddForm:()=>{e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName=""},onNewRecordPhoneChange:d=>e.handleContactsNewPhoneChange(d),onNewRecordNameChange:d=>e.handleContactsNewNameChange(d),onRefresh:()=>mt(e,l)})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",d=Ja(e),h=e.chatAvatarUrl??d??null,v=(()=>{var S;const f=(S=e.configSnapshot)==null?void 0:S.config,b=f==null?void 0:f.publicChat;return(b==null?void 0:b.enabled)===!0})();return Jy({connected:e.connected,wsProps:en(e),publicChatEnabled:v,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:f=>{e.sessionKey=f,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestion=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:f,lastActiveSessionKey:f}),e.loadAssistantIdentity(),Me(e),Ns(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:f=>{const b=Math.max(e.chatMessages.length+10,Pe);In(e,e.sessionKey,{model:f}).then(()=>{Me(e,{limit:b})})},onThinkingLevelChange:f=>{const b=Math.max(e.chatMessages.length+10,Pe);In(e,e.sessionKey,{thinkingLevel:f==="off"?null:f}).then(()=>{Me(e,{limit:b})})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestion:e.chatSuggestion,onSuggestionClick:f=>{e.chatMessage=f,e.chatSuggestion=null,e.handleSendChat()},onVerboseChange:f=>{const b=Math.max(e.chatMessages.length+10,Pe);In(e,e.sessionKey,{verboseLevel:f==="off"?null:f}).then(()=>{Me(e,{limit:b})})},onFillerChange:f=>{const b=Math.max(e.chatMessages.length+10,Pe);In(e,e.sessionKey,{fillerEnabled:f}).then(()=>{Me(e,{limit:b})})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:h,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:l,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const f=Math.max(e.chatMessages.length+10,Pe);return Promise.all([Me(e,{limit:f}),Ns(e)])},onToggleFocusMode:()=>{},onChatScroll:f=>e.handleChatScroll(f),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:f=>e.chatMessage=f,attachments:e.chatAttachments,onAttachmentsChange:f=>e.chatAttachments=f,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:f=>e.removeQueuedMessage(f),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:f=>e.handleOpenSidebar(f),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:f=>e.handleSplitRatioChange(f),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?_v({connected:e.connected,wsProps:en(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&ht(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?an(e,{reset:!0}):Mt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(o=e.channelsSnapshot)==null?void 0:o.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((a=e.channelsSnapshot)==null?void 0:a.channelOrder)??[],channelLabels:((u=e.channelsSnapshot)==null?void 0:u.channelLabels)??{},channelMeta:((c=e.channelsSnapshot)==null?void 0:c.channelMeta)??[],agentIds:(()=>{var d;const l=oe(e);return((d=l==null?void 0:l.agents)==null?void 0:d.map(h=>h.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1},detailJobId:e.cronDetailJobId,onDetailOpen:l=>{e.cronDetailJobId=l.id,Ms(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{rp(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,d)=>ap(e,l,d),onRun:l=>lp(e,l),onRemove:l=>cp(e,l),onLoadRuns:l=>Ms(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:()=>ht(e,{clearMessages:!0}),onToggle:(l,d)=>Ql(e,l,d),onEdit:(l,d)=>Gl(e,l,d),onSaveKey:l=>Yl(e,l),onInstall:(l,d,h)=>Xl(e,l,d,h)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?an(e,{reset:!0}):Mt(e,{reset:!0})},sessionLogsProps:{loading:e.sessionLogsLoading,error:e.sessionLogsError,entries:e.sessionLogsEntries,agents:e.sessionLogsAgents,filterText:e.sessionLogsFilterText,typeFilters:e.sessionLogsTypeFilters,agentFilters:e.sessionLogsAgentFilters,autoFollow:e.sessionLogsAutoFollow,onFilterTextChange:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,d)=>{const h=e;h.sessionLogsTypeFilters={...h.sessionLogsTypeFilters,[l]:d}},onAgentToggle:(l,d)=>{const h=e;h.sessionLogsAgentFilters={...h.sessionLogsAgentFilters,[l]:d}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onRefresh:()=>{an(e,{reset:!0})},onExport:(l,d)=>e.exportSessionLogs(l,d),onScroll:l=>e.handleSessionLogsScroll(l)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,truncated:e.logsTruncated,onFilterTextChange:l=>e.logsFilterText=l,onLevelToggle:(l,d)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:d}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onRefresh:()=>Mt(e,{reset:!0}),onExport:(l,d)=>e.exportSessionLogs(l,d),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),p``)}function Lb(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${i}`}function el(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Ib(e,t,n){return p`
3496
+ `;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return za({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(d,h)=>{h!=null&&e.handlePinSubmit(d,h)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(d,h,v)=>e.handleChangePin(d,h,v)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return za({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:d=>e.handleSetMasterPin(d)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",k}if(e.setup){const l=_b(e.channelsSnapshot),d=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],h=Mb(e.channelsSnapshot),v=Pb(e);return gf({connected:e.connected,serverPlatform:((s=(i=e.hello)==null?void 0:i.server)==null?void 0:s.platform)??null,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:f=>e.handleLicenseKeyChange(f),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:l,whatsappAccounts:d,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:f=>e.handleUninstallConfirmTextChange(f),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:f=>e.handleAuthSubmitCode(f),onAuthCodeChange:f=>e.handleAuthCodeChange(f),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async f=>{await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await G(e,!0),e.requestUpdate())},onWhatsAppUnlink:async f=>{await e.handleWhatsAppLogout(f)},onWhatsAppReset:async f=>{await e.handleWhatsAppLogout(f),await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await G(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await G(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),G(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:f=>e.handleRemoveWhatsAppAccount(f),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:f=>{e.newWorkspacePin=f},onWorkspaceCreate:async(f,b)=>{const S=e.newWorkspacePin;await e.handleWorkspaceCreate(f,b),S.match(/^\d{4,6}$/)&&(await yb(e,f,S),e.newWorkspacePin="")},onWorkspaceRemove:f=>e.handleWorkspaceRemove(f),onSetAddingWorkspace:f=>{e.addingWorkspace=f},onSetNewWorkspaceName:f=>{e.newWorkspaceName=f},onSetNewWorkspacePath:f=>{e.newWorkspacePath=f},onSetWorkspaceRemoveConfirm:f=>{e.workspaceRemoveConfirm=f},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(f,b)=>e.handleWorkspaceRename(f,b),whatsappDmPolicy:(()=>{const f=oe(e),b=f==null?void 0:f.whatsappAccountId,S=b?d.find($=>$.accountId===b):d[0];return(S==null?void 0:S.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var T;const f=oe(e),b=f==null?void 0:f.whatsappAccountId,S=b?d.find(M=>M.accountId===b):d[0];if(!S)return;const A=S.dmPolicy!=null&&S.dmPolicy!=="disabled"?"disabled":"open",C=A==="open"?{dmPolicy:A,allowFrom:["*"]}:{dmPolicy:A};try{const M=await e.client.request("config.get"),R=M.config,B=(T=R==null?void 0:R.channels)==null?void 0:T.whatsapp,me=((B==null?void 0:B.accounts)??{})[S.accountId]?{channels:{whatsapp:{accounts:{[S.accountId]:C}}}}:{channels:{whatsapp:C}};await e.client.request("config.patch",{raw:JSON.stringify(me),baseHash:M.hash,note:`WhatsApp DM policy → ${A}`,skipRestart:!0}),await G(e,!1)}catch(M){console.error("DM toggle failed:",M)}},whatsappModel:(()=>{var T,M;const f=oe(e);if(!f)return null;const b=f.agents.find(R=>R.id.endsWith("-public")||R.id==="public");if(!b)return null;const S=(T=e.configSnapshot)==null?void 0:T.config,$=(M=S==null?void 0:S.agents)==null?void 0:M.list;if(!Array.isArray($))return null;const A=$.find(R=>R.id===b.id);if(!(A!=null&&A.model))return null;const C=typeof A.model=="string"?A.model:A.model.primary;return(C==null?void 0:C.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async f=>{const b=oe(e);if(!b)return;const S=b.agents.find($=>$.id.endsWith("-public")||$.id==="public");if(S)try{const $=await e.client.request("config.get"),A=$.config,C=(A==null?void 0:A.agents)??{},T=Array.isArray(C.list)?[...C.list]:[],M=T.findIndex(B=>B.id===S.id);if(f)M>=0?T[M]={...T[M],model:f}:T.push({id:S.id,model:f});else if(M>=0){const{model:B,...ee}=T[M];Object.keys(ee).length<=1?T.splice(M,1):T[M]=ee}const R=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(R),baseHash:$.hash,note:`Public agent model → ${f||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Model change failed:",$)}},whatsappThinkingLevel:(()=>{var C,T,M;const f=oe(e);if(!f)return null;const b=f.agents.find(R=>R.id.endsWith("-public")||R.id==="public");if(!b)return null;const S=(C=e.configSnapshot)==null?void 0:C.config,$=(T=S==null?void 0:S.agents)==null?void 0:T.list;if(!Array.isArray($))return null;const A=$.find(R=>R.id===b.id);return((M=A==null?void 0:A.thinkingLevel)==null?void 0:M.trim())||null})(),onWhatsAppThinkingChange:async f=>{const b=oe(e);if(!b)return;const S=b.agents.find($=>$.id.endsWith("-public")||$.id==="public");if(S)try{const $=await e.client.request("config.get"),A=$.config,C=(A==null?void 0:A.agents)??{},T=Array.isArray(C.list)?[...C.list]:[],M=T.findIndex(ee=>ee.id===S.id),R=f==="off"?void 0:f;if(R)M>=0?T[M]={...T[M],thinkingLevel:R}:T.push({id:S.id,thinkingLevel:R});else if(M>=0){const{thinkingLevel:ee,...me}=T[M];Object.keys(me).length<=1?T.splice(M,1):T[M]=me}const B=T.length>0?{agents:{list:T}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(B),baseHash:$.hash,note:`Public agent thinking → ${R||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Thinking change failed:",$)}},whatsappGroupPolicy:(()=>{var M,R;const f=(M=e.configSnapshot)==null?void 0:M.config,b=(R=f==null?void 0:f.channels)==null?void 0:R.whatsapp,S=oe(e),$=S==null?void 0:S.whatsappAccountId,A=(b==null?void 0:b.accounts)??{},C=$?A[$]:void 0;return(C==null?void 0:C.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var R,B;const f=(R=e.configSnapshot)==null?void 0:R.config,b=(B=f==null?void 0:f.channels)==null?void 0:B.whatsapp,S=oe(e),$=S==null?void 0:S.whatsappAccountId,A=(b==null?void 0:b.accounts)??{},C=$?A[$]:void 0,M=((C==null?void 0:C.groups)??(b==null?void 0:b.groups)??{})["*"];return(M==null?void 0:M.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var S;const f=oe(e),b=f==null?void 0:f.whatsappAccountId;try{const $=await e.client.request("config.get"),A=$.config,C=((S=A==null?void 0:A.channels)==null?void 0:S.whatsapp)??{},T=C.accounts??{},M=b?T[b]:void 0,R=(M==null?void 0:M.groupPolicy)??C.groupPolicy??"allowlist",B=R==="disabled"||R==="allowlist",ee=B?"open":"disabled",me=B?{"*":{}}:void 0,Ke={groupPolicy:ee};me&&(Ke.groups=me);const Z=M?{channels:{whatsapp:{accounts:{[b]:Ke}}}}:{channels:{whatsapp:Ke}};await e.client.request("config.patch",{raw:JSON.stringify(Z),baseHash:$.hash,note:`WhatsApp groups → ${ee}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch($){console.error("Group toggle failed:",$)}},onWhatsAppGroupMentionChange:async f=>{var $;const b=oe(e),S=b==null?void 0:b.whatsappAccountId;try{const A=await e.client.request("config.get"),C=A.config,M=((($=C==null?void 0:C.channels)==null?void 0:$.whatsapp)??{}).accounts??{},R=S?M[S]:void 0,B={"*":{requireMention:f}},ee=R?{channels:{whatsapp:{accounts:{[S]:{groups:B}}}}}:{channels:{whatsapp:{groups:B}}};await e.client.request("config.patch",{raw:JSON.stringify(ee),baseHash:A.hash,note:`WhatsApp group mention → ${f?"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:h.configured,imessageRunning:h.running,imessageConnected:h.connected,imessageLastError:h.lastError,imessageSelfChatMode:h.selfChatMode,imessageCliPath:h.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:v,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,S=(b==null?void 0:b.bindings)??[],$=oe(e),A=$==null?void 0:$.agents.find(B=>B.id.endsWith("-admin")||B.id==="admin"),C=(A==null?void 0:A.id)??"admin",T=S.filter(B=>{var ee;return((ee=B.match)==null?void 0:ee.channel)!=="imessage"}),M=[{agentId:C,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],R=[...T,...M];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:R}),baseHash:f.hash,note:"Enable iMessage (self-chat) for "+(($==null?void 0:$.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([G(e,!0),Le(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await G(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,$=((b==null?void 0:b.bindings)??[]).filter(A=>{var C;return((C=A.match)==null?void 0:C.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:$}),baseHash:f.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([G(e,!0),Le(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,S=(b==null?void 0:b.bindings)??[],$=oe(e),A=$==null?void 0:$.agents.find(R=>R.id.endsWith("-admin")||R.id==="admin"),C=(A==null?void 0:A.id)??"admin",T=S.filter(R=>{var B;return((B=R.match)==null?void 0:B.channel)!=="imessage"}),M=[{agentId:C,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:[...T,...M]}),baseHash:f.hash,note:"Reassign iMessage to "+(($==null?void 0:$.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([G(e,!0),Le(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:f=>{e.infoModalOpen=f},onInfoModalClose:()=>{e.infoModalOpen=null},isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,apiKeySavingProvider:e.apiKeySavingProvider,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeySave:async(f,b)=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await qa(e.client,f,b);const S=`${f} key saved`;e.apiKeySuccess=S,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await eo(e.client)}catch{}f==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===S&&(e.apiKeySuccess=null)},2500)}catch(S){e.apiKeyError=S instanceof Error?S.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async f=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Xv(e.client,f);const b=`${f} key removed`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await eo(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:f=>{e.authApiKeyInput=f},onAuthApiKeySubmit:async()=>{const f=e.authApiKeyInput.trim();if(f){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await qa(e.client,"anthropic",f),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(b){e.authApiKeyError=b instanceof Error?b.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var b;const f=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return f?e.accessState.accounts.some(S=>S.id===f):!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:(f,b)=>{var $;const S=e.selectedWorkspace??(($=e.workspaces[0])==null?void 0:$.name);S&&e.handleAccountPinSave(S,f,b)},publicChatEnabled:(()=>{var S;const f=(S=e.configSnapshot)==null?void 0:S.config,b=f==null?void 0:f.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var $;const f=($=e.configSnapshot)==null?void 0:$.config,b=f==null?void 0:f.publicChat,S=b==null?void 0:b.auth;return S==="verified"||S==="choice"?S:"anonymous"})(),publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var f;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),S=b.config,$=((f=S==null?void 0:S.publicChat)==null?void 0:f.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!$}}),baseHash:b.hash,note:`Public chat → ${$?"disabled":"enabled"}`}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Public chat toggle failed:",b)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async f=>{if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{auth:f}}),baseHash:b.hash,note:`Public chat auth → ${f}`}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Public chat auth mode change failed:",b)}finally{e.publicChatToggleBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null;try{const f=await e.client.request("tailscale.enable");if(f.authUrl){e.tailscaleAuthUrl=f.authUrl;const b=setInterval(async()=>{try{const S=await e.client.request("tailscale.status");e.tailscaleStatus=S,S.loggedIn&&(clearInterval(b),e.tailscaleAuthUrl=null,e.tailscaleBusy=!1)}catch{}},3e3);setTimeout(()=>{clearInterval(b),e.tailscaleBusy&&(e.tailscaleBusy=!1)},3e5)}else f.alreadyLoggedIn&&(e.tailscaleStatus=await e.client.request("tailscale.status")),e.tailscaleBusy=!1}catch(f){console.error("Tailscale enable failed:",f),e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var f;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable")}catch(b){console.error("Tailscale funnel enable failed:",b);const S=b;(f=S.payload)!=null&&f.enableUrl&&(e.tailscaleFunnelEnableUrl=S.payload.enableUrl),e.tailscaleError=S.message||"Failed to enable Funnel",e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable")}catch(f){console.error("Tailscale funnel disable failed:",f),e.tailscaleBusy=!1}}},wifiStatus:e.wifiStatus,wifiNetworks:e.wifiNetworks,wifiBusy:e.wifiBusy,wifiError:e.wifiError,wifiPassword:e.wifiPassword,wifiSelectedSsid:e.wifiSelectedSsid,onWifiScan:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[f,b]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);e.wifiNetworks=f.networks,e.wifiStatus=b}catch(f){console.error("WiFi scan failed:",f),e.wifiError=f.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{if(!(e.wifiBusy||!e.wifiSelectedSsid)){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.connect",{ssid:e.wifiSelectedSsid,password:e.wifiPassword}),e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[];const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi connect failed:",f),e.wifiError=f.message||"Failed to connect"}finally{e.wifiBusy=!1}}},onWifiDisconnect:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.disconnect"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi disconnect failed:",f),e.wifiError=f.message||"Failed to disconnect"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:f=>{e.wifiSelectedSsid=f,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:f=>{e.wifiPassword=f},wsProps:Sb(e)})}if(e.filesPage){const l=Ab(e);return Jh({connected:e.connected,wsProps:sn(e),loading:e.filesLoading,tree:e.filesTree,root:e.filesRoot,error:e.filesError,selectedPath:e.filesSelectedPath,selectedPaths:e.filesSelectedPaths,previewContent:e.filesPreviewContent,previewLoading:e.filesPreviewLoading,previewBinary:e.filesPreviewBinary,previewSize:e.filesPreviewSize,expandedDirs:e.filesExpandedDirs,currentDir:e.filesCurrentDir,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>Ut(e,l),onReindex:()=>dh(e,l),onSelectFile:d=>{e.filesPendingDeletePath=null,ih(e,d,l)},onToggleSelectFile:d=>sh(e,d,l),onToggleDir:d=>ph(e,d),onUpload:(d,h)=>ah(e,d,h,l),onNewFolder:(d,h)=>lh(e,d,h,l),onDownload:d=>oc(e,d,l),onBulkDownload:()=>oh(e,l),onDelete:d=>{e.filesPendingDeletePath=null,ch(e,d,l)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:d=>{e.filesPendingDeletePath=d||null},onMoveToDir:(d,h)=>rh(e,d,h,l),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:d=>{const h=e.filesSearchAgentId??l;hh(e,d,h)},onSearchAgentChange:d=>{e.filesSearchAgentId=d},onSearchClear:()=>{fh(e)},onSearchQueryChange:d=>{e.filesSearchQuery=d}})}if(e.browserPage)return Vh({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,fullscreen:e.browserFullscreen,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>zv(e),onStop:()=>jv(e),onToggleInput:()=>qv(e),onToggleFullscreen:()=>Vv(e),onCompleteHandoff:()=>Hv(e),onCanvasMouseDown:l=>{const h=l.target.getBoundingClientRect(),f=hn().translateCoordinates(l.clientX-h.left,l.clientY-h.top);xs(e,"mousePressed",f.x,f.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const h=l.target.getBoundingClientRect(),f=hn().translateCoordinates(l.clientX-h.left,l.clientY-h.top);xs(e,"mouseReleased",f.x,f.y)},onCanvasMouseMove:l=>{const d=hn();if(d.shouldThrottleMouseMove())return;const v=l.target.getBoundingClientRect(),f=d.translateCoordinates(l.clientX-v.left,l.clientY-v.top);xs(e,"mouseMoved",f.x,f.y)},onCanvasKeyDown:l=>{let d=0;l.altKey&&(d|=1),l.ctrlKey&&(d|=2),l.metaKey&&(d|=4),l.shiftKey&&(d|=8),$s(e,"keyDown",l.key,{code:l.code,modifiers:d||void 0}),l.key.length===1&&$s(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{$s(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=xb(e),d=$b(e);return yf({connected:e.connected,wsProps:sn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>Ii(e,l),onAdd:h=>{xu(e,h,l,d).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:h=>$u(e,h,l,d),onNewPhoneChange:h=>e.handleAdminsNewPhoneChange(h)})}if(e.contactsPage){const l=Eb(e);return kf({connected:e.connected,wsProps:sn(e),loading:e.contactsLoading,saving:e.contactsSaving,records:e.contactsRecords,error:e.contactsError,searchQuery:e.contactsSearchQuery,editingId:e.contactsEditingId,showAddForm:e.contactsShowAddForm,newRecordPhone:e.contactsNewPhone,newRecordName:e.contactsNewName,onSearch:d=>e.contactsSearchQuery=d,onSearchSubmit:()=>yt(e,l),onAdd:(d,h)=>Au(e,d,h,l),onDelete:d=>Eu(e,d,l),onSetField:(d,h,v)=>Cu(e,d,h,v,l),onDeleteField:(d,h)=>Tu(e,d,h,l),onToggleExpand:d=>{e.contactsEditingId=e.contactsEditingId===d?null:d},onShowAddForm:()=>e.contactsShowAddForm=!0,onCancelAddForm:()=>{e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName=""},onNewRecordPhoneChange:d=>e.handleContactsNewPhoneChange(d),onNewRecordNameChange:d=>e.handleContactsNewNameChange(d),onRefresh:()=>yt(e,l)})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",d=el(e),h=e.chatAvatarUrl??d??null,v=(()=>{var S;const f=(S=e.configSnapshot)==null?void 0:S.config,b=f==null?void 0:f.publicChat;return(b==null?void 0:b.enabled)===!0})();return ev({connected:e.connected,wsProps:sn(e),publicChatEnabled:v,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:f=>{e.sessionKey=f,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestion=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:f,lastActiveSessionKey:f}),e.loadAssistantIdentity(),Me(e),Ds(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:f=>{const b=Math.max(e.chatMessages.length+10,Pe);Rn(e,e.sessionKey,{model:f}).then(()=>{Me(e,{limit:b})})},onThinkingLevelChange:f=>{const b=Math.max(e.chatMessages.length+10,Pe);Rn(e,e.sessionKey,{thinkingLevel:f==="off"?null:f}).then(()=>{Me(e,{limit:b})})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestion:e.chatSuggestion,onSuggestionClick:f=>{e.chatMessage=f,e.chatSuggestion=null,e.handleSendChat()},onVerboseChange:f=>{const b=Math.max(e.chatMessages.length+10,Pe);Rn(e,e.sessionKey,{verboseLevel:f==="off"?null:f}).then(()=>{Me(e,{limit:b})})},onFillerChange:f=>{const b=Math.max(e.chatMessages.length+10,Pe);Rn(e,e.sessionKey,{fillerEnabled:f}).then(()=>{Me(e,{limit:b})})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:h,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:l,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const f=Math.max(e.chatMessages.length+10,Pe);return Promise.all([Me(e,{limit:f}),Ds(e)])},onToggleFocusMode:()=>{},onChatScroll:f=>e.handleChatScroll(f),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:f=>e.chatMessage=f,attachments:e.chatAttachments,onAttachmentsChange:f=>e.chatAttachments=f,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:f=>e.removeQueuedMessage(f),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:f=>e.handleOpenSidebar(f),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:f=>e.handleSplitRatioChange(f),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?Mv({connected:e.connected,wsProps:sn(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&ft(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?un(e,{reset:!0}):Pt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(o=e.channelsSnapshot)==null?void 0:o.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((a=e.channelsSnapshot)==null?void 0:a.channelOrder)??[],channelLabels:((u=e.channelsSnapshot)==null?void 0:u.channelLabels)??{},channelMeta:((c=e.channelsSnapshot)==null?void 0:c.channelMeta)??[],agentIds:(()=>{var d;const l=oe(e);return((d=l==null?void 0:l.agents)==null?void 0:d.map(h=>h.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1},detailJobId:e.cronDetailJobId,onDetailOpen:l=>{e.cronDetailJobId=l.id,Ps(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{rp(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,d)=>ap(e,l,d),onRun:l=>lp(e,l),onRemove:l=>cp(e,l),onLoadRuns:l=>Ps(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:()=>ft(e,{clearMessages:!0}),onToggle:(l,d)=>Yl(e,l,d),onEdit:(l,d)=>Ql(e,l,d),onSaveKey:l=>Xl(e,l),onInstall:(l,d,h)=>Zl(e,l,d,h)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?un(e,{reset:!0}):Pt(e,{reset:!0})},sessionLogsProps:{loading:e.sessionLogsLoading,error:e.sessionLogsError,entries:e.sessionLogsEntries,agents:e.sessionLogsAgents,filterText:e.sessionLogsFilterText,typeFilters:e.sessionLogsTypeFilters,agentFilters:e.sessionLogsAgentFilters,autoFollow:e.sessionLogsAutoFollow,onFilterTextChange:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,d)=>{const h=e;h.sessionLogsTypeFilters={...h.sessionLogsTypeFilters,[l]:d}},onAgentToggle:(l,d)=>{const h=e;h.sessionLogsAgentFilters={...h.sessionLogsAgentFilters,[l]:d}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onRefresh:()=>{un(e,{reset:!0})},onExport:(l,d)=>e.exportSessionLogs(l,d),onScroll:l=>e.handleSessionLogsScroll(l)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,truncated:e.logsTruncated,onFilterTextChange:l=>e.logsFilterText=l,onLevelToggle:(l,d)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:d}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onRefresh:()=>Pt(e,{reset:!0}),onExport:(l,d)=>e.exportSessionLogs(l,d),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),p``)}function Ib(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${i}`}function tl(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Rb(e,t,n){return p`
3488
3497
  <div class="audit-modal-overlay" @click=${s=>{s.target.classList.contains("audit-modal-overlay")&&n()}}>
3489
3498
  <div class="audit-modal-card">
3490
3499
  <div class="audit-modal-header">
@@ -3500,11 +3509,11 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3500
3509
  ${e.map(s=>p`
3501
3510
  <div class="audit-modal-entry">
3502
3511
  <div class="audit-modal-entry-path">
3503
- <span class="audit-modal-folder audit-modal-folder--${el(s.path)}">${el(s.path)}</span>
3512
+ <span class="audit-modal-folder audit-modal-folder--${tl(s.path)}">${tl(s.path)}</span>
3504
3513
  <a href="/files" class="audit-modal-path-link">${s.path}</a>
3505
3514
  </div>
3506
3515
  <div class="audit-modal-entry-meta">
3507
- ${Lb(s.timestamp)}
3516
+ ${Ib(s.timestamp)}
3508
3517
  <span class="audit-modal-agent">${s.agentId}</span>
3509
3518
  </div>
3510
3519
  </div>
@@ -3516,7 +3525,7 @@ ${r.text}`:a.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
3516
3525
  `}
3517
3526
  </div>
3518
3527
  </div>
3519
- `}const Rb={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Nb={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};function Db(e){e.basePath=Sh();const t=Xe();if(Uh(t.accentColor),window.scrollTo(0,0),gh(e),e.publicChat){const n=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,i=(n==null?void 0:n.accountId)??"",s=i?i.charAt(0).toUpperCase()+i.slice(1):"Assistant";document.title=`Chat with ${s}`,Te(e);return}if(e.setup){document.title=`${t.name} Setup`,Te(e);return}if(e.filesPage){document.title=`${t.name} Files`,yh(e),Te(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Te(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Te(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,Te(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Te(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Te(e);return}Eh(e,!0),xh(e),$h(e),window.addEventListener("popstate",e.popStateHandler),bh(e),Te(e),hh(e),e.tab==="logs"&&(e.logsSubTab==="session"?ko(e):bo(e)),e.tab==="debug"&&xo(e)}function Ob(e){ep(e)}function Bb(e){var t;window.removeEventListener("popstate",e.popStateHandler),fh(e),wo(e),So(e),$o(e),mh(e),vh(e),Ah(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function Fb(e,t){if(!e.publicChat){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.contactsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleContactsLoad&&e.handleContactsLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const i=t.has("setupStep")&&e.setupStep==="auth";(n||i)&&e.setupStep==="auth"&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="whatsapp"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(o=>{e.channelsSnapshot=o,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(s=>{e.channelsSnapshot=s,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),i=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;Ot(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&xl(e,t.has("tab")||t.has("logsAutoFollow"))}}function Ub(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 Wb(e,t,n){await ao(e,t,n),await G(e,!0)}async function Kb(e,t){await El(e,t),await G(e,!0)}async function zb(e,t){await Cl(e,t),await G(e,!0)}async function jb(e,t){await Tl(e,t)}async function Hb(e,t){await _l(e,t)}async function qb(e){await ip(e),await Le(e),await G(e,!0)}async function Vb(e){await Le(e),await G(e,!0)}function Gb(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[i,...s]=n.split(":");if(!i||s.length===0)continue;const o=i.trim(),r=s.join(":").trim();o&&r&&(t[o]=r)}return t}function _u(e){var n,i,s;return((s=(((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.nostr)??[])[0])==null?void 0:s.accountId)??e.nostrProfileAccountId??"default"}function Mu(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function Qb(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Ub(n??void 0)}function Yb(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function Xb(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function Zb(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function Jb(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=_u(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Mu(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const o=(s==null?void 0:s.error)??`Profile update failed (${i.status})`;e.nostrProfileFormState={...t,saving:!1,error:o,success:null,fieldErrors:Gb(s==null?void 0:s.details)};return}if(!s.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await G(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function ew(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=_u(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Mu(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const u=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:u,success:null};return}const o=s.merged??s.imported??null,r=o?{...t.values,...o}:t.values,a=!!(r.banner||r.website||r.nip05||r.lud16);e.nostrProfileFormState={...t,importing:!1,values:r,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:a},s.saved&&await G(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function tw(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 nw(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 iw(e,t){if(e.client){e.authBusy=!0,e.authMessage="Verifying code...";try{await e.client.request("auth.oauth.code",{code:t});const n=await e.client.request("auth.oauth.wait",{timeoutMs:3e4});n.connected?(e.authConnected=!0,e.authMessage=n.message??"Connected to Claude!",e.authUrl=null,e.authCodeInput=""):e.authMessage=n.message??"Still waiting for authorization..."}catch(n){e.authConnected=!1,e.authMessage=n instanceof Error?n.message:"Verification failed"}finally{e.authBusy=!1}}}function sw(e,t){e.authCodeInput=t}function ow(e){e.setupStep="whatsapp"}async function rw(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 aw(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 lw(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 cw(e,t){e.licenseKey=t}async function uw(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("health",{probe:!0});e.gatewayHealthy=i.ok===!0,e.gatewayHealthMessage=i.ok?`Healthy${i.durationMs?` (${i.durationMs}ms)`:""}`:"Unhealthy"}catch(i){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(i)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function dw(e){var t,n,i;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(s.ok&&((n=s.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(s){e.gatewayHealthMessage=`Restart failed: ${String(s)}`,e.gatewayRestartBusy=!1,(i=e.requestUpdate)==null||i.call(e)}}}var pw=Object.defineProperty,hw=Object.getOwnPropertyDescriptor,m=(e,t,n,i)=>{for(var s=i>1?void 0:i?hw(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(s=(i?r(t,n,s):r(s))||s);return i&&s&&pw(t,n,s),s};const Es=gd();function fw(){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 gw(){const e=window.location.pathname;if(e==="/setup"||e.endsWith("/setup"))return!0;if(!window.location.search)return!1;const n=new URLSearchParams(window.location.search).get("setup");if(!n)return!1;const i=n.trim().toLowerCase();return i==="1"||i==="true"||i==="yes"||i==="on"}function mw(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function yw(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function vw(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function bw(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function ww(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function kw(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends _t{constructor(){super(...arguments),this.settings=Qi(),this.password="",this.tab="chat",this.onboarding=fw(),this.setup=gw(),this.filesPage=mw(),this.browserPage=yw(),this.adminsPage=vw(),this.contactsPage=bw(),this.chatPage=ww(),this.advancedPage=kw(),this.advancedTab="cron",this.publicChat=!!window.__TASKMASTER_PUBLIC_CHAT__,this.publicChatConfig=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__??{},this.publicChatSessionKey=null,this.publicChatAuthenticated=!1,this.publicChatAuthStep="idle",this.connected=!1,this.accessState=bu,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=Es.name,this.assistantAvatar=Es.avatar,this.assistantAgentId=Es.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatHistoryTotal=0,this.chatHistoryHasMore=!1,this.chatLoadingOlder=!1,this.chatToolMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestion=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatModelProvider=null,this.chatModel=null,this.chatModelCatalog=[],this.chatVerboseLevel=null,this.chatFillerEnabled=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
3528
+ `}const Nb={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Db={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};function Ob(e){e.basePath=$h();const t=Xe();if(Kh(t.accentColor),window.scrollTo(0,0),yh(e),e.publicChat){const n=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,i=(n==null?void 0:n.accountId)??"",s=i?i.charAt(0).toUpperCase()+i.slice(1):"Assistant";document.title=`Chat with ${s}`,Te(e);return}if(e.setup){document.title=`${t.name} Setup`,Te(e);return}if(e.filesPage){document.title=`${t.name} Files`,bh(e),Te(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Te(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Te(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,Te(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Te(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Te(e);return}Th(e,!0),Ah(e),Eh(e),window.addEventListener("popstate",e.popStateHandler),kh(e),Te(e),gh(e),e.tab==="logs"&&(e.logsSubTab==="session"?So(e):wo(e)),e.tab==="debug"&&$o(e)}function Bb(e){ep(e)}function Fb(e){var t;window.removeEventListener("popstate",e.popStateHandler),mh(e),ko(e),xo(e),Ao(e),vh(e),wh(e),Ch(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function Ub(e,t){if(!e.publicChat){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.contactsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleContactsLoad&&e.handleContactsLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const i=t.has("setupStep")&&e.setupStep==="auth";(n||i)&&e.setupStep==="auth"&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="whatsapp"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(o=>{e.channelsSnapshot=o,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(s=>{e.channelsSnapshot=s,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),i=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;Bt(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&$l(e,t.has("tab")||t.has("logsAutoFollow"))}}function Wb(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 Kb(e,t,n){await lo(e,t,n),await G(e,!0)}async function zb(e,t){await Cl(e,t),await G(e,!0)}async function jb(e,t){await Tl(e,t),await G(e,!0)}async function Hb(e,t){await _l(e,t)}async function qb(e,t){await Ml(e,t)}async function Vb(e){await ip(e),await Le(e),await G(e,!0)}async function Gb(e){await Le(e),await G(e,!0)}function Qb(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[i,...s]=n.split(":");if(!i||s.length===0)continue;const o=i.trim(),r=s.join(":").trim();o&&r&&(t[o]=r)}return t}function _u(e){var n,i,s;return((s=(((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.nostr)??[])[0])==null?void 0:s.accountId)??e.nostrProfileAccountId??"default"}function Mu(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function Yb(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Wb(n??void 0)}function Xb(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function Zb(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function Jb(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function ew(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=_u(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Mu(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const o=(s==null?void 0:s.error)??`Profile update failed (${i.status})`;e.nostrProfileFormState={...t,saving:!1,error:o,success:null,fieldErrors:Qb(s==null?void 0:s.details)};return}if(!s.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await G(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function tw(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=_u(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Mu(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const u=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:u,success:null};return}const o=s.merged??s.imported??null,r=o?{...t.values,...o}:t.values,a=!!(r.banner||r.website||r.nip05||r.lud16);e.nostrProfileFormState={...t,importing:!1,values:r,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:a},s.saved&&await G(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function nw(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 iw(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 sw(e,t){if(e.client){e.authBusy=!0,e.authMessage="Verifying code...";try{await e.client.request("auth.oauth.code",{code:t});const n=await e.client.request("auth.oauth.wait",{timeoutMs:3e4});n.connected?(e.authConnected=!0,e.authMessage=n.message??"Connected to Claude!",e.authUrl=null,e.authCodeInput=""):e.authMessage=n.message??"Still waiting for authorization..."}catch(n){e.authConnected=!1,e.authMessage=n instanceof Error?n.message:"Verification failed"}finally{e.authBusy=!1}}}function ow(e,t){e.authCodeInput=t}function rw(e){e.setupStep="whatsapp"}async function aw(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 lw(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 cw(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 uw(e,t){e.licenseKey=t}async function dw(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("health",{probe:!0});e.gatewayHealthy=i.ok===!0,e.gatewayHealthMessage=i.ok?`Healthy${i.durationMs?` (${i.durationMs}ms)`:""}`:"Unhealthy"}catch(i){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(i)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function pw(e){var t,n,i;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(s.ok&&((n=s.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(s){e.gatewayHealthMessage=`Restart failed: ${String(s)}`,e.gatewayRestartBusy=!1,(i=e.requestUpdate)==null||i.call(e)}}}var hw=Object.defineProperty,fw=Object.getOwnPropertyDescriptor,m=(e,t,n,i)=>{for(var s=i>1?void 0:i?fw(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(s=(i?r(t,n,s):r(s))||s);return i&&s&&hw(t,n,s),s};const Cs=gd();function gw(){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 mw(){const e=window.location.pathname;if(e==="/setup"||e.endsWith("/setup"))return!0;if(!window.location.search)return!1;const n=new URLSearchParams(window.location.search).get("setup");if(!n)return!1;const i=n.trim().toLowerCase();return i==="1"||i==="true"||i==="yes"||i==="on"}function yw(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function vw(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function bw(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function ww(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function kw(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function Sw(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends Mt{constructor(){super(...arguments),this.settings=Yi(),this.password="",this.tab="chat",this.onboarding=gw(),this.setup=mw(),this.filesPage=yw(),this.browserPage=vw(),this.adminsPage=bw(),this.contactsPage=ww(),this.chatPage=kw(),this.advancedPage=Sw(),this.advancedTab="cron",this.publicChat=!!window.__TASKMASTER_PUBLIC_CHAT__,this.publicChatConfig=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__??{},this.publicChatSessionKey=null,this.publicChatAuthenticated=!1,this.publicChatAuthStep="idle",this.connected=!1,this.accessState=bu,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=Cs.name,this.assistantAvatar=Cs.avatar,this.assistantAgentId=Cs.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatHistoryTotal=0,this.chatHistoryHasMore=!1,this.chatLoadingOlder=!1,this.chatToolMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestion=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatModelProvider=null,this.chatModel=null,this.chatModelCatalog=[],this.chatVerboseLevel=null,this.chatFillerEnabled=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
3520
3529
  }
3521
- `,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.whatsappActiveQrAccountId=null,this.whatsappPairedPhone=null,this.addingWhatsAppAccount=!1,this.newWhatsAppAccountName="",this.whatsappAccountError=null,this.whatsappAccountSaving=!1,this.whatsappSettingsOpen=!1,this.publicChatToggleBusy=!1,this.tailscaleStatus=null,this.tailscaleBusy=!1,this.tailscaleAuthUrl=null,this.tailscaleError=null,this.tailscaleFunnelEnableUrl=null,this.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,this.licenseKey="",this.licenseBusy=!1,this.licenseValid=null,this.licenseMessage=null,this.licenseTier=null,this.licenseDeviceId=null,this.licenseStoredKey=null,this.licenseRemoveConfirm=!1,this.authConnected=null,this.authBusy=!1,this.authMessage=null,this.authUrl=null,this.authCodeInput="",this.authExpiresIn=null,this.setupStep="license",this.gatewayHealthy=null,this.gatewayHealthLoading=!1,this.gatewayHealthMessage=null,this.gatewayRestartBusy=!1,this.updateAvailable=null,this.currentVersion=null,this.latestVersion=null,this.updateChecking=!1,this.updateMessage=null,this.updateProgressSteps=[],this.updateLastResult=null,this.uninstallConfirm=!1,this.uninstallBusy=!1,this.uninstallDone=!1,this.uninstallError=null,this.uninstallConfirmText="",this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...Nb},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserFullscreen=!1,this.browserLoading=!1,this.browserError=null,this.filesLoading=!1,this.filesTree=[],this.filesRoot="",this.filesError=null,this.filesSelectedPath=null,this.filesSelectedPaths=new Set,this.filesPreviewContent=null,this.filesPreviewLoading=!1,this.filesPreviewBinary=!1,this.filesPreviewSize=null,this.filesExpandedDirs=new Set,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.embeddingDownloading=!1,this.embeddingPollTimer=null,this.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.filesResolvedAgentId=void 0,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.contactsLoading=!1,this.contactsSaving=!1,this.contactsRecords=[],this.contactsError=null,this.contactsSearchQuery="",this.contactsEditingId=null,this.contactsShowAddForm=!1,this.contactsNewPhone="",this.contactsNewName="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.infoModalOpen=null,this.workspaces=[],this.workspacesLoading=!1,this.workspacesError=null,this.selectedWorkspace=null,this.addingWorkspace=!1,this.newWorkspaceName="",this.newWorkspacePath="",this.newWorkspacePin="",this.accountPinModalOpen=!1,this.accountPinBusy=!1,this.accountPinError=null,this.accountPinSuccess=null,this.apiKeyProviders=[],this.apiKeyModalOpen=!1,this.apiKeyBusy=!1,this.apiKeyError=null,this.apiKeySuccess=null,this.apiKeySavingProvider=null,this.authApiKeyMode=!1,this.authApiKeyInput="",this.authApiKeyBusy=!1,this.authApiKeyError=null,this.pinChanging=null,this.pinChangeBusy=!1,this.pinChangeError=null,this.loginChangePinMode=!1,this.changePinBusy=!1,this.changePinError=null,this.changePinSuccess=null,this.workspaceSaving=!1,this.workspaceRemoveConfirm=null,this.renamingWorkspace=!1,this.renameWorkspaceName="",this.debugLoading=!1,this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugCallMethod="",this.debugCallParams="{}",this.debugCallResult=null,this.debugCallError=null,this.logsLoading=!1,this.logsError=null,this.logsFile=null,this.logsEntries=[],this.logsFilterText="",this.logsLevelFilters={...Rb},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsSubTab="session",this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.onLoadOlder=()=>this.handleLoadOlderChat(),this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>Ch(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),Db(this)}firstUpdated(){Ob(this)}disconnectedCallback(){this.stopEmbeddingPoll(),Bb(this),super.disconnectedCallback()}startEmbeddingPoll(){if(this.embeddingPollTimer!=null)return;const e=async()=>{if(!(!this.client||!this.connected)){try{const t=await this.client.request("memory.status",{});if((t==null?void 0:t.embeddingState)==="downloading")this.embeddingDownloading=!0;else{this.embeddingDownloading&&(this.embeddingDownloading=!1),this.stopEmbeddingPoll();return}}catch{this.embeddingDownloading=!1,this.stopEmbeddingPoll();return}this.embeddingPollTimer=window.setTimeout(e,3e3)}};e()}stopEmbeddingPoll(){this.embeddingPollTimer!=null&&(window.clearTimeout(this.embeddingPollTimer),this.embeddingPollTimer=null)}updated(e){Fb(this,e)}connect(){Te(this)}handleChatScroll(e){Vd(this,e)}handleLogsScroll(e){Qd(this,e)}handleSessionLogsScroll(e){Yd(this,e)}exportLogs(e,t){Zd(e,t)}exportSessionLogs(e,t){Jd(e,t)}resetToolStream(){ro(this)}resetChatScroll(){Xd(this)}async loadAssistantIdentity(){await Zs(this)}applySettings(e){Ge(this,e)}setTab(e){wh(this,e)}setTheme(e,t){kh(this,e,t)}async loadOverview(){await cc(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 Ao(this)}async handleAbortChat(){await dc(this)}removeQueuedMessage(e){Ph(this,e)}async handleSendChat(e,t){await Lh(this,e,t)}async handleWhatsAppStart(e,t){await Wb(this,e,t)}async handleWhatsAppWait(e){await Kb(this,e)}async handleWhatsAppLogout(e){await zb(this,e)}async handleAddWhatsAppAccount(e){await jb(this,e)}async handleRemoveWhatsAppAccount(e){await Hb(this,e)}async handleAccessCheck(){await Za(this)}async handlePinSubmit(e,t){await fb(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await gb(this,e)}async handleLogout(){await yb(this)}toggleChangePinMode(){this.loginChangePinMode=!this.loginChangePinMode,this.changePinError=null,this.changePinSuccess=null}async handleChangePin(e,t,n){if(this.client){this.changePinBusy=!0,this.changePinError=null,this.changePinSuccess=null;try{const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.changePinError=i.message??"Incorrect current PIN",this.changePinBusy=!1;return}e==="__master__"?await this.client.request("access.setMasterPin",{pin:n}):await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.changePinSuccess="PIN changed successfully",this.changePinBusy=!1,setTimeout(()=>{this.loginChangePinMode=!1,this.changePinSuccess=null},2e3)}catch{this.changePinError="Failed to change PIN",this.changePinBusy=!1}}}async handleAccountPinSave(e,t,n){if(this.client){this.accountPinBusy=!0,this.accountPinError=null,this.accountPinSuccess=null;try{if(t!==null){const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.accountPinError=i.message??"Incorrect current PIN",this.accountPinBusy=!1;return}}await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.accountPinSuccess="PIN saved",this.accountPinBusy=!1,await Za(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 rw(this)}async handleLicenseActivate(){await aw(this)}async handleLicenseRemove(){await lw(this)}handleLicenseKeyChange(e){cw(this,e)}async handleAuthStatusCheck(){await tw(this)}async handleAuthStart(){await nw(this)}async handleAuthSubmitCode(e){await iw(this,e)}handleAuthCodeChange(e){sw(this,e)}handleSkipToWhatsApp(){ow(this)}async handleGatewayHealthCheck(){await uw(this)}async handleGatewayRestart(){await dw(this)}async handleUpdateCheck(){await gu(this)}async handleUpdateRun(){await Xv(this)}handleUpdateDismissResult(){eb(this)}handleUninstallConfirm(){this.uninstallConfirm=!0,this.uninstallConfirmText=""}handleUninstallCancel(){this.uninstallConfirm=!1,this.uninstallConfirmText="",this.uninstallError=null}handleUninstallConfirmTextChange(e){this.uninstallConfirmText=e}async handleUninstallRun(){const{runUninstall:e}=await ie(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Or);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){ie(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Or);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await nc(this)}async clearAudit(){await nh(this),this.auditModalOpen=!1}handleFilesLoad(){var n;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((n=e==null?void 0:e.agents)==null?void 0:n.map(i=>i.id))??void 0;const t=this.resolveFilesAgentId();this.filesResolvedAgentId=t,vn(this,t),vo(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();ie(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>bb);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin");return t==null?void 0:t.id}resolveFilesAgentId(){var n;const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return(t==null?void 0:t.id)??((n=e.agents[0])==null?void 0:n.id)}handleChatLoad(){const e=this.resolveAdminAgentId();if(e){const t=`agent:${e}:main`;t!==this.sessionKey&&(this.sessionKey=t,this.chatMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatRunId=null,this.chatSuggestion=null,this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}ie(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>si);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{Ot(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=Gd(this),{loadOlderChatHistory:t}=await ie(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>si);return{loadOlderChatHistory:i}},void 0,import.meta.url);await t(this)&&e&&(await this.updateComplete,e())}handleAdvancedLoad(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.sessionLogsEntries=[],this.sessionLogsCursors={},this.sessionLogsAgents=[],this.advancedTab==="cron"&&this.loadCron(),this.advancedTab==="logs"&&(this.logsSubTab==="session"?ie(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>tc);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):ie(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>gp);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&ie(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>Qp);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await qb(this)}async handleChannelConfigReload(){await Vb(this)}handleNostrProfileEdit(e,t){Qb(this,e,t)}handleNostrProfileCancel(){Yb(this)}handleNostrProfileFieldChange(e,t){Xb(this,e,t)}async handleNostrProfileSave(){await Jb(this)}async handleNostrProfileImport(){await ew(this)}handleNostrProfileToggleAdvanced(){Zb(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleAdminsNewPhoneChange(e){this.adminsNewPhone=e,this.adminsError&&(this.adminsError=null)}handleContactsLoad(){const e=this.selectedWorkspace??void 0;ie(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>wb);return{loadContacts:t}},void 0,import.meta.url).then(({loadContacts:t})=>{t(this,e)})}handleContactsNewPhoneChange(e){this.contactsNewPhone=e,this.contactsError&&(this.contactsError=null)}handleContactsNewNameChange(e){this.contactsNewName=e,this.contactsError&&(this.contactsError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await ie(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>qn);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await ie(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>qn);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await ie(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>up);return{loadChannels:s}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:s=>{if(!s.whatsappAccountId)return;const o=s.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await i(this,!0),await this.handleWhatsAppStart(!0,o),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(o),await i(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await ie(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>qn);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=(e==null?void 0:e.displayName)??(e==null?void 0:e.name)??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await ie(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>qn);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){this.selectedWorkspace=e,localStorage.setItem("taskmaster-selected-workspace",e),$r(e),this.settings=Qi(),this.chatMessage="",this.chatAttachments=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestion=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.loadAuditEntries(),this.adminsPage?this.handleAdminsLoad():this.contactsPage?this.handleContactsLoad():this.filesPage?this.handleFilesLoad():this.chatPage?this.handleChatLoad():this.advancedPage&&this.handleAdvancedLoad()}initWorkspaceSelection(){if(this.workspaces.length===0){this.reloadCurrentPageData();return}const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(i=>i.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}$r(this.selectedWorkspace),this.settings=Qi(),this.reloadCurrentPageData()}render(){return p`${Pb(this)}${this.auditModalOpen?Ib(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):k}`}};m([y()],g.prototype,"settings",2);m([y()],g.prototype,"password",2);m([y()],g.prototype,"tab",2);m([y()],g.prototype,"onboarding",2);m([y()],g.prototype,"setup",2);m([y()],g.prototype,"filesPage",2);m([y()],g.prototype,"browserPage",2);m([y()],g.prototype,"adminsPage",2);m([y()],g.prototype,"contactsPage",2);m([y()],g.prototype,"chatPage",2);m([y()],g.prototype,"advancedPage",2);m([y()],g.prototype,"advancedTab",2);m([y()],g.prototype,"publicChat",2);m([y()],g.prototype,"publicChatConfig",2);m([y()],g.prototype,"publicChatSessionKey",2);m([y()],g.prototype,"publicChatAuthenticated",2);m([y()],g.prototype,"publicChatAuthStep",2);m([y()],g.prototype,"connected",2);m([y()],g.prototype,"accessState",2);m([y()],g.prototype,"theme",2);m([y()],g.prototype,"themeResolved",2);m([y()],g.prototype,"hello",2);m([y()],g.prototype,"lastError",2);m([y()],g.prototype,"eventLog",2);m([y()],g.prototype,"assistantName",2);m([y()],g.prototype,"assistantAvatar",2);m([y()],g.prototype,"assistantAgentId",2);m([y()],g.prototype,"sessionKey",2);m([y()],g.prototype,"chatLoading",2);m([y()],g.prototype,"chatSending",2);m([y()],g.prototype,"chatMessage",2);m([y()],g.prototype,"chatMessages",2);m([y()],g.prototype,"chatHistoryTotal",2);m([y()],g.prototype,"chatHistoryHasMore",2);m([y()],g.prototype,"chatLoadingOlder",2);m([y()],g.prototype,"chatToolMessages",2);m([y()],g.prototype,"chatStream",2);m([y()],g.prototype,"chatInterimText",2);m([y()],g.prototype,"chatSuggestion",2);m([y()],g.prototype,"chatStreamStartedAt",2);m([y()],g.prototype,"chatRunId",2);m([y()],g.prototype,"compactionStatus",2);m([y()],g.prototype,"chatAvatarUrl",2);m([y()],g.prototype,"chatThinkingLevel",2);m([y()],g.prototype,"chatModelProvider",2);m([y()],g.prototype,"chatModel",2);m([y()],g.prototype,"chatModelCatalog",2);m([y()],g.prototype,"chatVerboseLevel",2);m([y()],g.prototype,"chatFillerEnabled",2);m([y()],g.prototype,"chatQueue",2);m([y()],g.prototype,"chatAttachments",2);m([y()],g.prototype,"sidebarOpen",2);m([y()],g.prototype,"sidebarContent",2);m([y()],g.prototype,"sidebarError",2);m([y()],g.prototype,"splitRatio",2);m([y()],g.prototype,"nodesLoading",2);m([y()],g.prototype,"nodes",2);m([y()],g.prototype,"devicesLoading",2);m([y()],g.prototype,"devicesError",2);m([y()],g.prototype,"devicesList",2);m([y()],g.prototype,"execApprovalsLoading",2);m([y()],g.prototype,"execApprovalsSaving",2);m([y()],g.prototype,"execApprovalsDirty",2);m([y()],g.prototype,"execApprovalsSnapshot",2);m([y()],g.prototype,"execApprovalsForm",2);m([y()],g.prototype,"execApprovalsSelectedAgent",2);m([y()],g.prototype,"execApprovalsTarget",2);m([y()],g.prototype,"execApprovalsTargetNodeId",2);m([y()],g.prototype,"execApprovalQueue",2);m([y()],g.prototype,"execApprovalBusy",2);m([y()],g.prototype,"execApprovalError",2);m([y()],g.prototype,"configLoading",2);m([y()],g.prototype,"configRaw",2);m([y()],g.prototype,"configRawOriginal",2);m([y()],g.prototype,"configValid",2);m([y()],g.prototype,"configIssues",2);m([y()],g.prototype,"configSaving",2);m([y()],g.prototype,"configApplying",2);m([y()],g.prototype,"updateRunning",2);m([y()],g.prototype,"applySessionKey",2);m([y()],g.prototype,"configSnapshot",2);m([y()],g.prototype,"configSchema",2);m([y()],g.prototype,"configSchemaVersion",2);m([y()],g.prototype,"configSchemaLoading",2);m([y()],g.prototype,"configUiHints",2);m([y()],g.prototype,"configForm",2);m([y()],g.prototype,"configFormOriginal",2);m([y()],g.prototype,"configFormDirty",2);m([y()],g.prototype,"configFormMode",2);m([y()],g.prototype,"configSearchQuery",2);m([y()],g.prototype,"configActiveSection",2);m([y()],g.prototype,"configActiveSubsection",2);m([y()],g.prototype,"channelsLoading",2);m([y()],g.prototype,"channelsSnapshot",2);m([y()],g.prototype,"channelsError",2);m([y()],g.prototype,"channelsLastSuccess",2);m([y()],g.prototype,"whatsappLoginMessage",2);m([y()],g.prototype,"whatsappLoginQrDataUrl",2);m([y()],g.prototype,"whatsappLoginConnected",2);m([y()],g.prototype,"whatsappBusy",2);m([y()],g.prototype,"whatsappActiveQrAccountId",2);m([y()],g.prototype,"whatsappPairedPhone",2);m([y()],g.prototype,"addingWhatsAppAccount",2);m([y()],g.prototype,"newWhatsAppAccountName",2);m([y()],g.prototype,"whatsappAccountError",2);m([y()],g.prototype,"whatsappAccountSaving",2);m([y()],g.prototype,"whatsappSettingsOpen",2);m([y()],g.prototype,"publicChatToggleBusy",2);m([y()],g.prototype,"tailscaleStatus",2);m([y()],g.prototype,"tailscaleBusy",2);m([y()],g.prototype,"tailscaleAuthUrl",2);m([y()],g.prototype,"tailscaleError",2);m([y()],g.prototype,"tailscaleFunnelEnableUrl",2);m([y()],g.prototype,"wifiStatus",2);m([y()],g.prototype,"wifiNetworks",2);m([y()],g.prototype,"wifiBusy",2);m([y()],g.prototype,"wifiError",2);m([y()],g.prototype,"wifiPassword",2);m([y()],g.prototype,"wifiSelectedSsid",2);m([y()],g.prototype,"licenseKey",2);m([y()],g.prototype,"licenseBusy",2);m([y()],g.prototype,"licenseValid",2);m([y()],g.prototype,"licenseMessage",2);m([y()],g.prototype,"licenseTier",2);m([y()],g.prototype,"licenseDeviceId",2);m([y()],g.prototype,"licenseStoredKey",2);m([y()],g.prototype,"licenseRemoveConfirm",2);m([y()],g.prototype,"authConnected",2);m([y()],g.prototype,"authBusy",2);m([y()],g.prototype,"authMessage",2);m([y()],g.prototype,"authUrl",2);m([y()],g.prototype,"authCodeInput",2);m([y()],g.prototype,"authExpiresIn",2);m([y()],g.prototype,"setupStep",2);m([y()],g.prototype,"gatewayHealthy",2);m([y()],g.prototype,"gatewayHealthLoading",2);m([y()],g.prototype,"gatewayHealthMessage",2);m([y()],g.prototype,"gatewayRestartBusy",2);m([y()],g.prototype,"updateAvailable",2);m([y()],g.prototype,"currentVersion",2);m([y()],g.prototype,"latestVersion",2);m([y()],g.prototype,"updateChecking",2);m([y()],g.prototype,"updateMessage",2);m([y()],g.prototype,"updateProgressSteps",2);m([y()],g.prototype,"updateLastResult",2);m([y()],g.prototype,"uninstallConfirm",2);m([y()],g.prototype,"uninstallBusy",2);m([y()],g.prototype,"uninstallDone",2);m([y()],g.prototype,"uninstallError",2);m([y()],g.prototype,"uninstallConfirmText",2);m([y()],g.prototype,"nostrProfileFormState",2);m([y()],g.prototype,"nostrProfileAccountId",2);m([y()],g.prototype,"presenceLoading",2);m([y()],g.prototype,"presenceEntries",2);m([y()],g.prototype,"presenceError",2);m([y()],g.prototype,"presenceStatus",2);m([y()],g.prototype,"agentsLoading",2);m([y()],g.prototype,"agentsList",2);m([y()],g.prototype,"agentsError",2);m([y()],g.prototype,"sessionsLoading",2);m([y()],g.prototype,"sessionsResult",2);m([y()],g.prototype,"sessionsError",2);m([y()],g.prototype,"cronLoading",2);m([y()],g.prototype,"cronJobs",2);m([y()],g.prototype,"cronStatus",2);m([y()],g.prototype,"cronError",2);m([y()],g.prototype,"cronForm",2);m([y()],g.prototype,"cronRunsJobId",2);m([y()],g.prototype,"cronRuns",2);m([y()],g.prototype,"cronBusy",2);m([y()],g.prototype,"cronNewEventModal",2);m([y()],g.prototype,"cronDetailJobId",2);m([y()],g.prototype,"browserScreencastActive",2);m([y()],g.prototype,"browserScreencastFrame",2);m([y()],g.prototype,"browserScreencastMetadata",2);m([y()],g.prototype,"browserHandoffPending",2);m([y()],g.prototype,"browserHandoffReason",2);m([y()],g.prototype,"browserHandoffId",2);m([y()],g.prototype,"browserInputMode",2);m([y()],g.prototype,"browserFullscreen",2);m([y()],g.prototype,"browserLoading",2);m([y()],g.prototype,"browserError",2);m([y()],g.prototype,"filesLoading",2);m([y()],g.prototype,"filesTree",2);m([y()],g.prototype,"filesRoot",2);m([y()],g.prototype,"filesError",2);m([y()],g.prototype,"filesSelectedPath",2);m([y()],g.prototype,"filesSelectedPaths",2);m([y()],g.prototype,"filesPreviewContent",2);m([y()],g.prototype,"filesPreviewLoading",2);m([y()],g.prototype,"filesPreviewBinary",2);m([y()],g.prototype,"filesPreviewSize",2);m([y()],g.prototype,"filesExpandedDirs",2);m([y()],g.prototype,"filesMessage",2);m([y()],g.prototype,"filesUploadBusy",2);m([y()],g.prototype,"filesReindexBusy",2);m([y()],g.prototype,"filesMemoryStatus",2);m([y()],g.prototype,"embeddingDownloading",2);m([y()],g.prototype,"filesSearchQuery",2);m([y()],g.prototype,"filesSearchResults",2);m([y()],g.prototype,"filesSearchLoading",2);m([y()],g.prototype,"filesSearchAgentId",2);m([y()],g.prototype,"auditEntries",2);m([y()],g.prototype,"auditLoading",2);m([y()],g.prototype,"auditModalOpen",2);m([y()],g.prototype,"skillsLoading",2);m([y()],g.prototype,"skillsReport",2);m([y()],g.prototype,"skillsError",2);m([y()],g.prototype,"skillsFilter",2);m([y()],g.prototype,"skillEdits",2);m([y()],g.prototype,"skillsBusyKey",2);m([y()],g.prototype,"skillMessages",2);m([y()],g.prototype,"adminsLoading",2);m([y()],g.prototype,"adminPhones",2);m([y()],g.prototype,"adminsError",2);m([y()],g.prototype,"adminsSaving",2);m([y()],g.prototype,"adminsNewPhone",2);m([y()],g.prototype,"contactsLoading",2);m([y()],g.prototype,"contactsSaving",2);m([y()],g.prototype,"contactsRecords",2);m([y()],g.prototype,"contactsError",2);m([y()],g.prototype,"contactsSearchQuery",2);m([y()],g.prototype,"contactsEditingId",2);m([y()],g.prototype,"contactsShowAddForm",2);m([y()],g.prototype,"contactsNewPhone",2);m([y()],g.prototype,"contactsNewName",2);m([y()],g.prototype,"imessageEnableConfirm",2);m([y()],g.prototype,"imessageEnabling",2);m([y()],g.prototype,"infoModalOpen",2);m([y()],g.prototype,"workspaces",2);m([y()],g.prototype,"workspacesLoading",2);m([y()],g.prototype,"workspacesError",2);m([y()],g.prototype,"selectedWorkspace",2);m([y()],g.prototype,"addingWorkspace",2);m([y()],g.prototype,"newWorkspaceName",2);m([y()],g.prototype,"newWorkspacePath",2);m([y()],g.prototype,"newWorkspacePin",2);m([y()],g.prototype,"accountPinModalOpen",2);m([y()],g.prototype,"accountPinBusy",2);m([y()],g.prototype,"accountPinError",2);m([y()],g.prototype,"accountPinSuccess",2);m([y()],g.prototype,"apiKeyProviders",2);m([y()],g.prototype,"apiKeyModalOpen",2);m([y()],g.prototype,"apiKeyBusy",2);m([y()],g.prototype,"apiKeyError",2);m([y()],g.prototype,"apiKeySuccess",2);m([y()],g.prototype,"apiKeySavingProvider",2);m([y()],g.prototype,"authApiKeyMode",2);m([y()],g.prototype,"authApiKeyInput",2);m([y()],g.prototype,"authApiKeyBusy",2);m([y()],g.prototype,"authApiKeyError",2);m([y()],g.prototype,"pinChanging",2);m([y()],g.prototype,"pinChangeBusy",2);m([y()],g.prototype,"pinChangeError",2);m([y()],g.prototype,"loginChangePinMode",2);m([y()],g.prototype,"changePinBusy",2);m([y()],g.prototype,"changePinError",2);m([y()],g.prototype,"changePinSuccess",2);m([y()],g.prototype,"workspaceSaving",2);m([y()],g.prototype,"workspaceRemoveConfirm",2);m([y()],g.prototype,"renamingWorkspace",2);m([y()],g.prototype,"renameWorkspaceName",2);m([y()],g.prototype,"debugLoading",2);m([y()],g.prototype,"debugStatus",2);m([y()],g.prototype,"debugHealth",2);m([y()],g.prototype,"debugModels",2);m([y()],g.prototype,"debugHeartbeat",2);m([y()],g.prototype,"debugCallMethod",2);m([y()],g.prototype,"debugCallParams",2);m([y()],g.prototype,"debugCallResult",2);m([y()],g.prototype,"debugCallError",2);m([y()],g.prototype,"logsLoading",2);m([y()],g.prototype,"logsError",2);m([y()],g.prototype,"logsFile",2);m([y()],g.prototype,"logsEntries",2);m([y()],g.prototype,"logsFilterText",2);m([y()],g.prototype,"logsLevelFilters",2);m([y()],g.prototype,"logsAutoFollow",2);m([y()],g.prototype,"logsTruncated",2);m([y()],g.prototype,"logsCursor",2);m([y()],g.prototype,"logsLastFetchAt",2);m([y()],g.prototype,"logsLimit",2);m([y()],g.prototype,"logsMaxBytes",2);m([y()],g.prototype,"logsAtBottom",2);m([y()],g.prototype,"logsSubTab",2);m([y()],g.prototype,"sessionLogsLoading",2);m([y()],g.prototype,"sessionLogsError",2);m([y()],g.prototype,"sessionLogsEntries",2);m([y()],g.prototype,"sessionLogsFilterText",2);m([y()],g.prototype,"sessionLogsTypeFilters",2);m([y()],g.prototype,"sessionLogsAgentFilters",2);m([y()],g.prototype,"sessionLogsAgents",2);m([y()],g.prototype,"sessionLogsAutoFollow",2);m([y()],g.prototype,"sessionLogsCursors",2);m([y()],g.prototype,"sessionLogsLastFetchAt",2);m([y()],g.prototype,"sessionLogsAtBottom",2);m([y()],g.prototype,"chatUserNearBottom",2);g=m([cl("taskmaster-app")],g);
3522
- //# sourceMappingURL=index-BiXCzgVk.js.map
3530
+ `,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.whatsappActiveQrAccountId=null,this.whatsappPairedPhone=null,this.addingWhatsAppAccount=!1,this.newWhatsAppAccountName="",this.whatsappAccountError=null,this.whatsappAccountSaving=!1,this.whatsappSettingsOpen=!1,this.publicChatToggleBusy=!1,this.tailscaleStatus=null,this.tailscaleBusy=!1,this.tailscaleAuthUrl=null,this.tailscaleError=null,this.tailscaleFunnelEnableUrl=null,this.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,this.licenseKey="",this.licenseBusy=!1,this.licenseValid=null,this.licenseMessage=null,this.licenseTier=null,this.licenseDeviceId=null,this.licenseStoredKey=null,this.licenseRemoveConfirm=!1,this.authConnected=null,this.authBusy=!1,this.authMessage=null,this.authUrl=null,this.authCodeInput="",this.authExpiresIn=null,this.setupStep="license",this.gatewayHealthy=null,this.gatewayHealthLoading=!1,this.gatewayHealthMessage=null,this.gatewayRestartBusy=!1,this.updateAvailable=null,this.currentVersion=null,this.latestVersion=null,this.updateChecking=!1,this.updateMessage=null,this.updateProgressSteps=[],this.updateLastResult=null,this.uninstallConfirm=!1,this.uninstallBusy=!1,this.uninstallDone=!1,this.uninstallError=null,this.uninstallConfirmText="",this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...Db},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserFullscreen=!1,this.browserLoading=!1,this.browserError=null,this.filesLoading=!1,this.filesTree=[],this.filesRoot="",this.filesError=null,this.filesSelectedPath=null,this.filesSelectedPaths=new Set,this.filesPreviewContent=null,this.filesPreviewLoading=!1,this.filesPreviewBinary=!1,this.filesPreviewSize=null,this.filesExpandedDirs=new Set,this.filesCurrentDir=".",this.filesPendingDeletePath=null,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.embeddingDownloading=!1,this.embeddingPollTimer=null,this.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.filesResolvedAgentId=void 0,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.contactsLoading=!1,this.contactsSaving=!1,this.contactsRecords=[],this.contactsError=null,this.contactsSearchQuery="",this.contactsEditingId=null,this.contactsShowAddForm=!1,this.contactsNewPhone="",this.contactsNewName="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.infoModalOpen=null,this.workspaces=[],this.workspacesLoading=!1,this.workspacesError=null,this.selectedWorkspace=null,this.addingWorkspace=!1,this.newWorkspaceName="",this.newWorkspacePath="",this.newWorkspacePin="",this.accountPinModalOpen=!1,this.accountPinBusy=!1,this.accountPinError=null,this.accountPinSuccess=null,this.apiKeyProviders=[],this.apiKeyModalOpen=!1,this.apiKeyBusy=!1,this.apiKeyError=null,this.apiKeySuccess=null,this.apiKeySavingProvider=null,this.authApiKeyMode=!1,this.authApiKeyInput="",this.authApiKeyBusy=!1,this.authApiKeyError=null,this.pinChanging=null,this.pinChangeBusy=!1,this.pinChangeError=null,this.loginChangePinMode=!1,this.changePinBusy=!1,this.changePinError=null,this.changePinSuccess=null,this.workspaceSaving=!1,this.workspaceRemoveConfirm=null,this.renamingWorkspace=!1,this.renameWorkspaceName="",this.debugLoading=!1,this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugCallMethod="",this.debugCallParams="{}",this.debugCallResult=null,this.debugCallError=null,this.logsLoading=!1,this.logsError=null,this.logsFile=null,this.logsEntries=[],this.logsFilterText="",this.logsLevelFilters={...Nb},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsSubTab="session",this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.onLoadOlder=()=>this.handleLoadOlderChat(),this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>_h(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),Ob(this)}firstUpdated(){Bb(this)}disconnectedCallback(){this.stopEmbeddingPoll(),Fb(this),super.disconnectedCallback()}startEmbeddingPoll(){if(this.embeddingPollTimer!=null)return;const e=async()=>{if(!(!this.client||!this.connected)){try{const t=await this.client.request("memory.status",{});if((t==null?void 0:t.embeddingState)==="downloading")this.embeddingDownloading=!0;else{this.embeddingDownloading&&(this.embeddingDownloading=!1),this.stopEmbeddingPoll();return}}catch{this.embeddingDownloading=!1,this.stopEmbeddingPoll();return}this.embeddingPollTimer=window.setTimeout(e,3e3)}};e()}stopEmbeddingPoll(){this.embeddingPollTimer!=null&&(window.clearTimeout(this.embeddingPollTimer),this.embeddingPollTimer=null)}updated(e){Ub(this,e)}connect(){Te(this)}handleChatScroll(e){Vd(this,e)}handleLogsScroll(e){Qd(this,e)}handleSessionLogsScroll(e){Yd(this,e)}exportLogs(e,t){Zd(e,t)}exportSessionLogs(e,t){Jd(e,t)}resetToolStream(){ao(this)}resetChatScroll(){Xd(this)}async loadAssistantIdentity(){await Js(this)}applySettings(e){Ge(this,e)}setTab(e){Sh(this,e)}setTheme(e,t){xh(this,e,t)}async loadOverview(){await cc(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 Eo(this)}async handleAbortChat(){await dc(this)}removeQueuedMessage(e){Ih(this,e)}async handleSendChat(e,t){await Rh(this,e,t)}async handleWhatsAppStart(e,t){await Kb(this,e,t)}async handleWhatsAppWait(e){await zb(this,e)}async handleWhatsAppLogout(e){await jb(this,e)}async handleAddWhatsAppAccount(e){await Hb(this,e)}async handleRemoveWhatsAppAccount(e){await qb(this,e)}async handleAccessCheck(){await Ja(this)}async handlePinSubmit(e,t){await gb(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await mb(this,e)}async handleLogout(){await vb(this)}toggleChangePinMode(){this.loginChangePinMode=!this.loginChangePinMode,this.changePinError=null,this.changePinSuccess=null}async handleChangePin(e,t,n){if(this.client){this.changePinBusy=!0,this.changePinError=null,this.changePinSuccess=null;try{const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.changePinError=i.message??"Incorrect current PIN",this.changePinBusy=!1;return}e==="__master__"?await this.client.request("access.setMasterPin",{pin:n}):await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.changePinSuccess="PIN changed successfully",this.changePinBusy=!1,setTimeout(()=>{this.loginChangePinMode=!1,this.changePinSuccess=null},2e3)}catch{this.changePinError="Failed to change PIN",this.changePinBusy=!1}}}async handleAccountPinSave(e,t,n){if(this.client){this.accountPinBusy=!0,this.accountPinError=null,this.accountPinSuccess=null;try{if(t!==null){const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.accountPinError=i.message??"Incorrect current PIN",this.accountPinBusy=!1;return}}await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.accountPinSuccess="PIN saved",this.accountPinBusy=!1,await Ja(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 aw(this)}async handleLicenseActivate(){await lw(this)}async handleLicenseRemove(){await cw(this)}handleLicenseKeyChange(e){uw(this,e)}async handleAuthStatusCheck(){await nw(this)}async handleAuthStart(){await iw(this)}async handleAuthSubmitCode(e){await sw(this,e)}handleAuthCodeChange(e){ow(this,e)}handleSkipToWhatsApp(){rw(this)}async handleGatewayHealthCheck(){await dw(this)}async handleGatewayRestart(){await pw(this)}async handleUpdateCheck(){await gu(this)}async handleUpdateRun(){await Zv(this)}handleUpdateDismissResult(){tb(this)}handleUninstallConfirm(){this.uninstallConfirm=!0,this.uninstallConfirmText=""}handleUninstallCancel(){this.uninstallConfirm=!1,this.uninstallConfirmText="",this.uninstallError=null}handleUninstallConfirmTextChange(e){this.uninstallConfirmText=e}async handleUninstallRun(){const{runUninstall:e}=await ie(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Br);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){ie(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Br);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await ic(this)}async clearAudit(){await nh(this),this.auditModalOpen=!1}handleFilesLoad(){var n;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((n=e==null?void 0:e.agents)==null?void 0:n.map(i=>i.id))??void 0;const t=this.resolveFilesAgentId();this.filesResolvedAgentId=t,Ut(this,t),bo(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();ie(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>wb);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin");return t==null?void 0:t.id}resolveFilesAgentId(){var n;const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return(t==null?void 0:t.id)??((n=e.agents[0])==null?void 0:n.id)}handleChatLoad(){const e=this.resolveAdminAgentId();if(e){const t=`agent:${e}:main`;t!==this.sessionKey&&(this.sessionKey=t,this.chatMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatRunId=null,this.chatSuggestion=null,this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}ie(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>oi);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{Bt(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=Gd(this),{loadOlderChatHistory:t}=await ie(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>oi);return{loadOlderChatHistory:i}},void 0,import.meta.url);await t(this)&&e&&(await this.updateComplete,e())}handleAdvancedLoad(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.sessionLogsEntries=[],this.sessionLogsCursors={},this.sessionLogsAgents=[],this.advancedTab==="cron"&&this.loadCron(),this.advancedTab==="logs"&&(this.logsSubTab==="session"?ie(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>nc);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):ie(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>gp);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&ie(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>Qp);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await Vb(this)}async handleChannelConfigReload(){await Gb(this)}handleNostrProfileEdit(e,t){Yb(this,e,t)}handleNostrProfileCancel(){Xb(this)}handleNostrProfileFieldChange(e,t){Zb(this,e,t)}async handleNostrProfileSave(){await ew(this)}async handleNostrProfileImport(){await tw(this)}handleNostrProfileToggleAdvanced(){Jb(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleAdminsNewPhoneChange(e){this.adminsNewPhone=e,this.adminsError&&(this.adminsError=null)}handleContactsLoad(){const e=this.selectedWorkspace??void 0;ie(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>kb);return{loadContacts:t}},void 0,import.meta.url).then(({loadContacts:t})=>{t(this,e)})}handleContactsNewPhoneChange(e){this.contactsNewPhone=e,this.contactsError&&(this.contactsError=null)}handleContactsNewNameChange(e){this.contactsNewName=e,this.contactsError&&(this.contactsError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await ie(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>Vn);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await ie(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>Vn);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await ie(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>up);return{loadChannels:s}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:s=>{if(!s.whatsappAccountId)return;const o=s.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await i(this,!0),await this.handleWhatsAppStart(!0,o),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(o),await i(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await ie(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>Vn);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=(e==null?void 0:e.displayName)??(e==null?void 0:e.name)??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await ie(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>Vn);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){this.selectedWorkspace=e,localStorage.setItem("taskmaster-selected-workspace",e),Ar(e),this.settings=Yi(),this.chatMessage="",this.chatAttachments=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestion=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.loadAuditEntries(),this.adminsPage?this.handleAdminsLoad():this.contactsPage?this.handleContactsLoad():this.filesPage?this.handleFilesLoad():this.chatPage?this.handleChatLoad():this.advancedPage&&this.handleAdvancedLoad()}initWorkspaceSelection(){if(this.workspaces.length===0){this.reloadCurrentPageData();return}const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(i=>i.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}Ar(this.selectedWorkspace),this.settings=Yi(),this.reloadCurrentPageData()}render(){return p`${Lb(this)}${this.auditModalOpen?Rb(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):k}`}};m([y()],g.prototype,"settings",2);m([y()],g.prototype,"password",2);m([y()],g.prototype,"tab",2);m([y()],g.prototype,"onboarding",2);m([y()],g.prototype,"setup",2);m([y()],g.prototype,"filesPage",2);m([y()],g.prototype,"browserPage",2);m([y()],g.prototype,"adminsPage",2);m([y()],g.prototype,"contactsPage",2);m([y()],g.prototype,"chatPage",2);m([y()],g.prototype,"advancedPage",2);m([y()],g.prototype,"advancedTab",2);m([y()],g.prototype,"publicChat",2);m([y()],g.prototype,"publicChatConfig",2);m([y()],g.prototype,"publicChatSessionKey",2);m([y()],g.prototype,"publicChatAuthenticated",2);m([y()],g.prototype,"publicChatAuthStep",2);m([y()],g.prototype,"connected",2);m([y()],g.prototype,"accessState",2);m([y()],g.prototype,"theme",2);m([y()],g.prototype,"themeResolved",2);m([y()],g.prototype,"hello",2);m([y()],g.prototype,"lastError",2);m([y()],g.prototype,"eventLog",2);m([y()],g.prototype,"assistantName",2);m([y()],g.prototype,"assistantAvatar",2);m([y()],g.prototype,"assistantAgentId",2);m([y()],g.prototype,"sessionKey",2);m([y()],g.prototype,"chatLoading",2);m([y()],g.prototype,"chatSending",2);m([y()],g.prototype,"chatMessage",2);m([y()],g.prototype,"chatMessages",2);m([y()],g.prototype,"chatHistoryTotal",2);m([y()],g.prototype,"chatHistoryHasMore",2);m([y()],g.prototype,"chatLoadingOlder",2);m([y()],g.prototype,"chatToolMessages",2);m([y()],g.prototype,"chatStream",2);m([y()],g.prototype,"chatInterimText",2);m([y()],g.prototype,"chatSuggestion",2);m([y()],g.prototype,"chatStreamStartedAt",2);m([y()],g.prototype,"chatRunId",2);m([y()],g.prototype,"compactionStatus",2);m([y()],g.prototype,"chatAvatarUrl",2);m([y()],g.prototype,"chatThinkingLevel",2);m([y()],g.prototype,"chatModelProvider",2);m([y()],g.prototype,"chatModel",2);m([y()],g.prototype,"chatModelCatalog",2);m([y()],g.prototype,"chatVerboseLevel",2);m([y()],g.prototype,"chatFillerEnabled",2);m([y()],g.prototype,"chatQueue",2);m([y()],g.prototype,"chatAttachments",2);m([y()],g.prototype,"sidebarOpen",2);m([y()],g.prototype,"sidebarContent",2);m([y()],g.prototype,"sidebarError",2);m([y()],g.prototype,"splitRatio",2);m([y()],g.prototype,"nodesLoading",2);m([y()],g.prototype,"nodes",2);m([y()],g.prototype,"devicesLoading",2);m([y()],g.prototype,"devicesError",2);m([y()],g.prototype,"devicesList",2);m([y()],g.prototype,"execApprovalsLoading",2);m([y()],g.prototype,"execApprovalsSaving",2);m([y()],g.prototype,"execApprovalsDirty",2);m([y()],g.prototype,"execApprovalsSnapshot",2);m([y()],g.prototype,"execApprovalsForm",2);m([y()],g.prototype,"execApprovalsSelectedAgent",2);m([y()],g.prototype,"execApprovalsTarget",2);m([y()],g.prototype,"execApprovalsTargetNodeId",2);m([y()],g.prototype,"execApprovalQueue",2);m([y()],g.prototype,"execApprovalBusy",2);m([y()],g.prototype,"execApprovalError",2);m([y()],g.prototype,"configLoading",2);m([y()],g.prototype,"configRaw",2);m([y()],g.prototype,"configRawOriginal",2);m([y()],g.prototype,"configValid",2);m([y()],g.prototype,"configIssues",2);m([y()],g.prototype,"configSaving",2);m([y()],g.prototype,"configApplying",2);m([y()],g.prototype,"updateRunning",2);m([y()],g.prototype,"applySessionKey",2);m([y()],g.prototype,"configSnapshot",2);m([y()],g.prototype,"configSchema",2);m([y()],g.prototype,"configSchemaVersion",2);m([y()],g.prototype,"configSchemaLoading",2);m([y()],g.prototype,"configUiHints",2);m([y()],g.prototype,"configForm",2);m([y()],g.prototype,"configFormOriginal",2);m([y()],g.prototype,"configFormDirty",2);m([y()],g.prototype,"configFormMode",2);m([y()],g.prototype,"configSearchQuery",2);m([y()],g.prototype,"configActiveSection",2);m([y()],g.prototype,"configActiveSubsection",2);m([y()],g.prototype,"channelsLoading",2);m([y()],g.prototype,"channelsSnapshot",2);m([y()],g.prototype,"channelsError",2);m([y()],g.prototype,"channelsLastSuccess",2);m([y()],g.prototype,"whatsappLoginMessage",2);m([y()],g.prototype,"whatsappLoginQrDataUrl",2);m([y()],g.prototype,"whatsappLoginConnected",2);m([y()],g.prototype,"whatsappBusy",2);m([y()],g.prototype,"whatsappActiveQrAccountId",2);m([y()],g.prototype,"whatsappPairedPhone",2);m([y()],g.prototype,"addingWhatsAppAccount",2);m([y()],g.prototype,"newWhatsAppAccountName",2);m([y()],g.prototype,"whatsappAccountError",2);m([y()],g.prototype,"whatsappAccountSaving",2);m([y()],g.prototype,"whatsappSettingsOpen",2);m([y()],g.prototype,"publicChatToggleBusy",2);m([y()],g.prototype,"tailscaleStatus",2);m([y()],g.prototype,"tailscaleBusy",2);m([y()],g.prototype,"tailscaleAuthUrl",2);m([y()],g.prototype,"tailscaleError",2);m([y()],g.prototype,"tailscaleFunnelEnableUrl",2);m([y()],g.prototype,"wifiStatus",2);m([y()],g.prototype,"wifiNetworks",2);m([y()],g.prototype,"wifiBusy",2);m([y()],g.prototype,"wifiError",2);m([y()],g.prototype,"wifiPassword",2);m([y()],g.prototype,"wifiSelectedSsid",2);m([y()],g.prototype,"licenseKey",2);m([y()],g.prototype,"licenseBusy",2);m([y()],g.prototype,"licenseValid",2);m([y()],g.prototype,"licenseMessage",2);m([y()],g.prototype,"licenseTier",2);m([y()],g.prototype,"licenseDeviceId",2);m([y()],g.prototype,"licenseStoredKey",2);m([y()],g.prototype,"licenseRemoveConfirm",2);m([y()],g.prototype,"authConnected",2);m([y()],g.prototype,"authBusy",2);m([y()],g.prototype,"authMessage",2);m([y()],g.prototype,"authUrl",2);m([y()],g.prototype,"authCodeInput",2);m([y()],g.prototype,"authExpiresIn",2);m([y()],g.prototype,"setupStep",2);m([y()],g.prototype,"gatewayHealthy",2);m([y()],g.prototype,"gatewayHealthLoading",2);m([y()],g.prototype,"gatewayHealthMessage",2);m([y()],g.prototype,"gatewayRestartBusy",2);m([y()],g.prototype,"updateAvailable",2);m([y()],g.prototype,"currentVersion",2);m([y()],g.prototype,"latestVersion",2);m([y()],g.prototype,"updateChecking",2);m([y()],g.prototype,"updateMessage",2);m([y()],g.prototype,"updateProgressSteps",2);m([y()],g.prototype,"updateLastResult",2);m([y()],g.prototype,"uninstallConfirm",2);m([y()],g.prototype,"uninstallBusy",2);m([y()],g.prototype,"uninstallDone",2);m([y()],g.prototype,"uninstallError",2);m([y()],g.prototype,"uninstallConfirmText",2);m([y()],g.prototype,"nostrProfileFormState",2);m([y()],g.prototype,"nostrProfileAccountId",2);m([y()],g.prototype,"presenceLoading",2);m([y()],g.prototype,"presenceEntries",2);m([y()],g.prototype,"presenceError",2);m([y()],g.prototype,"presenceStatus",2);m([y()],g.prototype,"agentsLoading",2);m([y()],g.prototype,"agentsList",2);m([y()],g.prototype,"agentsError",2);m([y()],g.prototype,"sessionsLoading",2);m([y()],g.prototype,"sessionsResult",2);m([y()],g.prototype,"sessionsError",2);m([y()],g.prototype,"cronLoading",2);m([y()],g.prototype,"cronJobs",2);m([y()],g.prototype,"cronStatus",2);m([y()],g.prototype,"cronError",2);m([y()],g.prototype,"cronForm",2);m([y()],g.prototype,"cronRunsJobId",2);m([y()],g.prototype,"cronRuns",2);m([y()],g.prototype,"cronBusy",2);m([y()],g.prototype,"cronNewEventModal",2);m([y()],g.prototype,"cronDetailJobId",2);m([y()],g.prototype,"browserScreencastActive",2);m([y()],g.prototype,"browserScreencastFrame",2);m([y()],g.prototype,"browserScreencastMetadata",2);m([y()],g.prototype,"browserHandoffPending",2);m([y()],g.prototype,"browserHandoffReason",2);m([y()],g.prototype,"browserHandoffId",2);m([y()],g.prototype,"browserInputMode",2);m([y()],g.prototype,"browserFullscreen",2);m([y()],g.prototype,"browserLoading",2);m([y()],g.prototype,"browserError",2);m([y()],g.prototype,"filesLoading",2);m([y()],g.prototype,"filesTree",2);m([y()],g.prototype,"filesRoot",2);m([y()],g.prototype,"filesError",2);m([y()],g.prototype,"filesSelectedPath",2);m([y()],g.prototype,"filesSelectedPaths",2);m([y()],g.prototype,"filesPreviewContent",2);m([y()],g.prototype,"filesPreviewLoading",2);m([y()],g.prototype,"filesPreviewBinary",2);m([y()],g.prototype,"filesPreviewSize",2);m([y()],g.prototype,"filesExpandedDirs",2);m([y()],g.prototype,"filesCurrentDir",2);m([y()],g.prototype,"filesPendingDeletePath",2);m([y()],g.prototype,"filesMessage",2);m([y()],g.prototype,"filesUploadBusy",2);m([y()],g.prototype,"filesReindexBusy",2);m([y()],g.prototype,"filesMemoryStatus",2);m([y()],g.prototype,"embeddingDownloading",2);m([y()],g.prototype,"filesSearchQuery",2);m([y()],g.prototype,"filesSearchResults",2);m([y()],g.prototype,"filesSearchLoading",2);m([y()],g.prototype,"filesSearchAgentId",2);m([y()],g.prototype,"auditEntries",2);m([y()],g.prototype,"auditLoading",2);m([y()],g.prototype,"auditModalOpen",2);m([y()],g.prototype,"skillsLoading",2);m([y()],g.prototype,"skillsReport",2);m([y()],g.prototype,"skillsError",2);m([y()],g.prototype,"skillsFilter",2);m([y()],g.prototype,"skillEdits",2);m([y()],g.prototype,"skillsBusyKey",2);m([y()],g.prototype,"skillMessages",2);m([y()],g.prototype,"adminsLoading",2);m([y()],g.prototype,"adminPhones",2);m([y()],g.prototype,"adminsError",2);m([y()],g.prototype,"adminsSaving",2);m([y()],g.prototype,"adminsNewPhone",2);m([y()],g.prototype,"contactsLoading",2);m([y()],g.prototype,"contactsSaving",2);m([y()],g.prototype,"contactsRecords",2);m([y()],g.prototype,"contactsError",2);m([y()],g.prototype,"contactsSearchQuery",2);m([y()],g.prototype,"contactsEditingId",2);m([y()],g.prototype,"contactsShowAddForm",2);m([y()],g.prototype,"contactsNewPhone",2);m([y()],g.prototype,"contactsNewName",2);m([y()],g.prototype,"imessageEnableConfirm",2);m([y()],g.prototype,"imessageEnabling",2);m([y()],g.prototype,"infoModalOpen",2);m([y()],g.prototype,"workspaces",2);m([y()],g.prototype,"workspacesLoading",2);m([y()],g.prototype,"workspacesError",2);m([y()],g.prototype,"selectedWorkspace",2);m([y()],g.prototype,"addingWorkspace",2);m([y()],g.prototype,"newWorkspaceName",2);m([y()],g.prototype,"newWorkspacePath",2);m([y()],g.prototype,"newWorkspacePin",2);m([y()],g.prototype,"accountPinModalOpen",2);m([y()],g.prototype,"accountPinBusy",2);m([y()],g.prototype,"accountPinError",2);m([y()],g.prototype,"accountPinSuccess",2);m([y()],g.prototype,"apiKeyProviders",2);m([y()],g.prototype,"apiKeyModalOpen",2);m([y()],g.prototype,"apiKeyBusy",2);m([y()],g.prototype,"apiKeyError",2);m([y()],g.prototype,"apiKeySuccess",2);m([y()],g.prototype,"apiKeySavingProvider",2);m([y()],g.prototype,"authApiKeyMode",2);m([y()],g.prototype,"authApiKeyInput",2);m([y()],g.prototype,"authApiKeyBusy",2);m([y()],g.prototype,"authApiKeyError",2);m([y()],g.prototype,"pinChanging",2);m([y()],g.prototype,"pinChangeBusy",2);m([y()],g.prototype,"pinChangeError",2);m([y()],g.prototype,"loginChangePinMode",2);m([y()],g.prototype,"changePinBusy",2);m([y()],g.prototype,"changePinError",2);m([y()],g.prototype,"changePinSuccess",2);m([y()],g.prototype,"workspaceSaving",2);m([y()],g.prototype,"workspaceRemoveConfirm",2);m([y()],g.prototype,"renamingWorkspace",2);m([y()],g.prototype,"renameWorkspaceName",2);m([y()],g.prototype,"debugLoading",2);m([y()],g.prototype,"debugStatus",2);m([y()],g.prototype,"debugHealth",2);m([y()],g.prototype,"debugModels",2);m([y()],g.prototype,"debugHeartbeat",2);m([y()],g.prototype,"debugCallMethod",2);m([y()],g.prototype,"debugCallParams",2);m([y()],g.prototype,"debugCallResult",2);m([y()],g.prototype,"debugCallError",2);m([y()],g.prototype,"logsLoading",2);m([y()],g.prototype,"logsError",2);m([y()],g.prototype,"logsFile",2);m([y()],g.prototype,"logsEntries",2);m([y()],g.prototype,"logsFilterText",2);m([y()],g.prototype,"logsLevelFilters",2);m([y()],g.prototype,"logsAutoFollow",2);m([y()],g.prototype,"logsTruncated",2);m([y()],g.prototype,"logsCursor",2);m([y()],g.prototype,"logsLastFetchAt",2);m([y()],g.prototype,"logsLimit",2);m([y()],g.prototype,"logsMaxBytes",2);m([y()],g.prototype,"logsAtBottom",2);m([y()],g.prototype,"logsSubTab",2);m([y()],g.prototype,"sessionLogsLoading",2);m([y()],g.prototype,"sessionLogsError",2);m([y()],g.prototype,"sessionLogsEntries",2);m([y()],g.prototype,"sessionLogsFilterText",2);m([y()],g.prototype,"sessionLogsTypeFilters",2);m([y()],g.prototype,"sessionLogsAgentFilters",2);m([y()],g.prototype,"sessionLogsAgents",2);m([y()],g.prototype,"sessionLogsAutoFollow",2);m([y()],g.prototype,"sessionLogsCursors",2);m([y()],g.prototype,"sessionLogsLastFetchAt",2);m([y()],g.prototype,"sessionLogsAtBottom",2);m([y()],g.prototype,"chatUserNearBottom",2);g=m([ul("taskmaster-app")],g);
3531
+ //# sourceMappingURL=index-xpeRZhsZ.js.map