@rubytech/taskmaster 1.0.52 → 1.0.54
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.
- package/dist/agents/tools/authorize-admin-tool.js +6 -5
- package/dist/build-info.json +3 -3
- package/dist/control-ui/assets/{index-T2LR9kFg.js → index-DC6oJyqi.js} +376 -374
- package/dist/control-ui/assets/index-DC6oJyqi.js.map +1 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/gateway/server-methods/sessions-transcript.js +46 -32
- package/dist/gateway/server-methods/update.js +4 -0
- package/package.json +1 -1
- package/templates/customer/agents/admin/BOOTSTRAP.md +3 -1
- package/dist/control-ui/assets/index-T2LR9kFg.js.map +0 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var iu=Object.defineProperty;var ru=(e,t,n)=>t in e?iu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var B=(e,t,n)=>ru(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(i){if(i.ep)return;i.ep=!0;const r=n(i);fetch(i.href,r)}})();const ou="modulepreload",au=function(e,t){return new URL(e,t).href},eo={},pe=function(t,n,s){let i=Promise.resolve();if(n&&n.length>0){let c=function(u){return Promise.all(u.map(p=>Promise.resolve(p).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const o=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=c(n.map(u=>{if(u=au(u,s),u in eo)return;eo[u]=!0;const p=u.endsWith(".css"),d=p?'[rel="stylesheet"]':"";if(s)for(let b=o.length-1;b>=0;b--){const w=o[b];if(w.href===u&&(!p||w.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${d}`))return;const f=document.createElement("link");if(f.rel=p?"stylesheet":ou,p||(f.as="script"),f.crossOrigin="",f.href=u,l&&f.setAttribute("nonce",l),document.head.appendChild(f),p)return new Promise((b,w)=>{f.addEventListener("load",b),f.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${u}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return t().catch(r)})};const Kn=globalThis,zi=Kn.ShadowRoot&&(Kn.ShadyCSS===void 0||Kn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ji=Symbol(),to=new WeakMap;let Da=class{constructor(t,n,s){if(this._$cssResult$=!0,s!==ji)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=n}get styleSheet(){let t=this.o;const n=this.t;if(zi&&t===void 0){const s=n!==void 0&&n.length===1;s&&(t=to.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&to.set(n,t))}return t}toString(){return this.cssText}};const lu=e=>new Da(typeof e=="string"?e:e+"",void 0,ji),cu=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((s,i,r)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[r+1],e[0]);return new Da(n,e,ji)},uu=(e,t)=>{if(zi)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const s=document.createElement("style"),i=Kn.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=n.cssText,e.appendChild(s)}},no=zi?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const s of t.cssRules)n+=s.cssText;return lu(n)})(e):e;const{is:du,defineProperty:pu,getOwnPropertyDescriptor:hu,getOwnPropertyNames:fu,getOwnPropertySymbols:gu,getPrototypeOf:mu}=Object,Oe=globalThis,so=Oe.trustedTypes,yu=so?so.emptyScript:"",Ns=Oe.reactiveElementPolyfillSupport,Yt=(e,t)=>e,Gn={toAttribute(e,t){switch(t){case Boolean:e=e?yu:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},Hi=(e,t)=>!du(e,t),io={attribute:!0,type:String,converter:Gn,reflect:!1,useDefault:!1,hasChanged:Hi};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Oe.litPropertyMetadata??(Oe.litPropertyMetadata=new WeakMap);let yt=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,n=io){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,n);i!==void 0&&pu(this.prototype,t,i)}}static getPropertyDescriptor(t,n,s){const{get:i,set:r}=hu(this.prototype,t)??{get(){return this[n]},set(o){this[n]=o}};return{get:i,set(o){const a=i==null?void 0:i.call(this);r==null||r.call(this,o),this.requestUpdate(t,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??io}static _$Ei(){if(this.hasOwnProperty(Yt("elementProperties")))return;const t=mu(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Yt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Yt("properties"))){const n=this.properties,s=[...fu(n),...gu(n)];for(const i of s)this.createProperty(i,n[i])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[s,i]of n)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[n,s]of this.elementProperties){const i=this._$Eu(n,s);i!==void 0&&this._$Eh.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)n.unshift(no(i))}else t!==void 0&&n.push(no(t));return n}static _$Eu(t,n){const s=n.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(n=>n(this))}addController(t){var n;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)==null||n.call(t))}removeController(t){var n;(n=this._$EO)==null||n.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const s of n.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return uu(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(n=>{var s;return(s=n.hostConnected)==null?void 0:s.call(n)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(n=>{var s;return(s=n.hostDisconnected)==null?void 0:s.call(n)})}attributeChangedCallback(t,n,s){this._$AK(t,s)}_$ET(t,n){var r;const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const o=(((r=s.converter)==null?void 0:r.toAttribute)!==void 0?s.converter:Gn).toAttribute(n,s.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,n){var r,o;const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const a=s.getPropertyOptions(i),l=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)==null?void 0:r.fromAttribute)!==void 0?a.converter:Gn;this._$Em=i;const c=l.fromAttribute(n,a.type);this[i]=c??((o=this._$Ej)==null?void 0:o.get(i))??c,this._$Em=null}}requestUpdate(t,n,s,i=!1,r){var o;if(t!==void 0){const a=this.constructor;if(i===!1&&(r=this[t]),s??(s=a.getPropertyOptions(t)),!((s.hasChanged??Hi)(r,n)||s.useDefault&&s.reflect&&r===((o=this._$Ej)==null?void 0:o.get(t))&&!this.hasAttribute(a._$Eu(t,s))))return;this.C(t,n,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:s,reflect:i,wrapped:r},o){s&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,o??n??this[t]),r!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(n=void 0),this._$AL.set(t,n)),i===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var s;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[r,o]of i){const{wrapped:a}=o,l=this[r];a!==!0||this._$AL.has(r)||l===void 0||this.C(r,void 0,o,l)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),(s=this._$EO)==null||s.forEach(i=>{var r;return(r=i.hostUpdate)==null?void 0:r.call(i)}),this.update(n)):this._$EM()}catch(i){throw t=!1,this._$EM(),i}t&&this._$AE(n)}willUpdate(t){}_$AE(t){var n;(n=this._$EO)==null||n.forEach(s=>{var i;return(i=s.hostUpdated)==null?void 0:i.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(n=>this._$ET(n,this[n]))),this._$EM()}updated(t){}firstUpdated(t){}};yt.elementStyles=[],yt.shadowRootOptions={mode:"open"},yt[Yt("elementProperties")]=new Map,yt[Yt("finalized")]=new Map,Ns==null||Ns({ReactiveElement:yt}),(Oe.reactiveElementVersions??(Oe.reactiveElementVersions=[])).push("2.1.2");const Xt=globalThis,ro=e=>e,Vn=Xt.trustedTypes,oo=Vn?Vn.createPolicy("lit-html",{createHTML:e=>e}):void 0,Oa="$lit$",De=`lit$${Math.random().toFixed(9).slice(2)}$`,Ba="?"+De,vu=`<${Ba}>`,Je=document,rn=()=>Je.createComment(""),on=e=>e===null||typeof e!="object"&&typeof e!="function",qi=Array.isArray,bu=e=>qi(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Ds=`[
|
|
2
|
-
\f\r]`,Dt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,
|
|
3
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),co=/'/g,uo=/"/g,Fa=/^(?:script|style|textarea|title)$/i,wu=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),h=wu(1),Fe=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),po=new WeakMap,Ye=Je.createTreeWalker(Je,129);function Ua(e,t){if(!qi(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return oo!==void 0?oo.createHTML(t):t}const ku=(e,t)=>{const n=e.length-1,s=[];let i,r=t===2?"<svg>":t===3?"<math>":"",o=Dt;for(let a=0;a<n;a++){const l=e[a];let c,u,p=-1,d=0;for(;d<l.length&&(o.lastIndex=d,u=o.exec(l),u!==null);)d=o.lastIndex,o===Dt?u[1]==="!--"?o=ao:u[1]!==void 0?o=lo:u[2]!==void 0?(Fa.test(u[2])&&(i=RegExp("</"+u[2],"g")),o=Ge):u[3]!==void 0&&(o=Ge):o===Ge?u[0]===">"?(o=i??Dt,p=-1):u[1]===void 0?p=-2:(p=o.lastIndex-u[2].length,c=u[1],o=u[3]===void 0?Ge:u[3]==='"'?uo:co):o===uo||o===co?o=Ge:o===ao||o===lo?o=Dt:(o=Ge,i=void 0);const f=o===Ge&&e[a+1].startsWith("/>")?" ":"";r+=o===Dt?l+vu:p>=0?(s.push(c),l.slice(0,p)+Oa+l.slice(p)+De+f):l+De+(p===-2?a:f)}return[Ua(e,r+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};let gi=class Wa{constructor({strings:t,_$litType$:n},s){let i;this.parts=[];let r=0,o=0;const a=t.length-1,l=this.parts,[c,u]=ku(t,n);if(this.el=Wa.createElement(c,s),Ye.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Ye.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(Oa)){const d=u[o++],f=i.getAttribute(p).split(De),b=/([.?@])?(.*)/.exec(d);l.push({type:1,index:r,name:b[2],strings:f,ctor:b[1]==="."?xu:b[1]==="?"?Au:b[1]==="@"?$u:ds}),i.removeAttribute(p)}else p.startsWith(De)&&(l.push({type:6,index:r}),i.removeAttribute(p));if(Fa.test(i.tagName)){const p=i.textContent.split(De),d=p.length-1;if(d>0){i.textContent=Vn?Vn.emptyScript:"";for(let f=0;f<d;f++)i.append(p[f],rn()),Ye.nextNode(),l.push({type:2,index:++r});i.append(p[d],rn())}}}else if(i.nodeType===8)if(i.data===Ba)l.push({type:2,index:r});else{let p=-1;for(;(p=i.data.indexOf(De,p+1))!==-1;)l.push({type:7,index:r}),p+=De.length-1}r++}}static createElement(t,n){const s=Je.createElement("template");return s.innerHTML=t,s}};function xt(e,t,n=e,s){var o,a;if(t===Fe)return t;let i=s!==void 0?(o=n._$Co)==null?void 0:o[s]:n._$Cl;const r=on(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==r&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),r===void 0?i=void 0:(i=new r(e),i._$AT(e,n,s)),s!==void 0?(n._$Co??(n._$Co=[]))[s]=i:n._$Cl=i),i!==void 0&&(t=xt(e,i._$AS(e,t.values),i,s)),t}class Su{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:s}=this._$AD,i=((t==null?void 0:t.creationScope)??Je).importNode(n,!0);Ye.currentNode=i;let r=Ye.nextNode(),o=0,a=0,l=s[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new us(r,r.nextSibling,this,t):l.type===1?c=new l.ctor(r,l.name,l.strings,this,t):l.type===6&&(c=new Eu(r,this,t)),this._$AV.push(c),l=s[++a]}o!==(l==null?void 0:l.index)&&(r=Ye.nextNode(),o++)}return Ye.currentNode=Je,i}p(t){let n=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,n),n+=s.strings.length-2):s._$AI(t[n])),n++}}let us=class Ka{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,n,s,i){this.type=2,this._$AH=k,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=s,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=xt(this,t,n),on(t)?t===k||t==null||t===""?(this._$AH!==k&&this._$AR(),this._$AH=k):t!==this._$AH&&t!==Fe&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):bu(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&&on(this._$AH)?this._$AA.nextSibling.data=t:this.T(Je.createTextNode(t)),this._$AH=t}$(t){var r;const{values:n,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=gi.createElement(Ua(s.h,s.h[0]),this.options)),s);if(((r=this._$AH)==null?void 0:r._$AD)===i)this._$AH.p(n);else{const o=new Su(i,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(t){let n=po.get(t.strings);return n===void 0&&po.set(t.strings,n=new gi(t)),n}k(t){qi(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let s,i=0;for(const r of t)i===n.length?n.push(s=new Ka(this.O(rn()),this.O(rn()),this,this.options)):s=n[i],s._$AI(r),i++;i<n.length&&(this._$AR(s&&s._$AB.nextSibling,i),n.length=i)}_$AR(t=this._$AA.nextSibling,n){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,n);t!==this._$AB;){const i=ro(t).nextSibling;ro(t).remove(),t=i}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class ds{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,s,i,r){this.type=1,this._$AH=k,this._$AN=void 0,this.element=t,this.name=n,this._$AM=i,this.options=r,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=k}_$AI(t,n=this,s,i){const r=this.strings;let o=!1;if(r===void 0)t=xt(this,t,n,0),o=!on(t)||t!==this._$AH&&t!==Fe,o&&(this._$AH=t);else{const a=t;let l,c;for(t=r[0],l=0;l<r.length-1;l++)c=xt(this,a[s+l],n,l),c===Fe&&(c=this._$AH[l]),o||(o=!on(c)||c!==this._$AH[l]),c===k?t=k:t!==k&&(t+=(c??"")+r[l+1]),this._$AH[l]=c}o&&!i&&this.j(t)}j(t){t===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let xu=class extends ds{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===k?void 0:t}},Au=class extends ds{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==k)}},$u=class extends ds{constructor(t,n,s,i,r){super(t,n,s,i,r),this.type=5}_$AI(t,n=this){if((t=xt(this,t,n,0)??k)===Fe)return;const s=this._$AH,i=t===k&&s!==k||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==k&&(s===k||i);i&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,t):this._$AH.handleEvent(t)}},Eu=class{constructor(t,n,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){xt(this,t)}};const Tu={I:us},Os=Xt.litHtmlPolyfillSupport;Os==null||Os(gi,us),(Xt.litHtmlVersions??(Xt.litHtmlVersions=[])).push("3.3.2");const Cu=(e,t,n)=>{const s=(n==null?void 0:n.renderBefore)??t;let i=s._$litPart$;if(i===void 0){const r=(n==null?void 0:n.renderBefore)??null;s._$litPart$=i=new us(t.insertBefore(rn(),r),r,void 0,n??{})}return i._$AI(e),i};const Ze=globalThis;let kt=class extends yt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var n;const t=super.createRenderRoot();return(n=this.renderOptions).renderBefore??(n.renderBefore=t.firstChild),t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Cu(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 Fe}};var Na;kt._$litElement$=!0,kt.finalized=!0,(Na=Ze.litElementHydrateSupport)==null||Na.call(Ze,{LitElement:kt});const Bs=Ze.litElementPolyfillSupport;Bs==null||Bs({LitElement:kt});(Ze.litElementVersions??(Ze.litElementVersions=[])).push("4.2.2");const za=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const _u={attribute:!0,type:String,converter:Gn,reflect:!1,hasChanged:Hi},Mu=(e=_u,t,n)=>{const{kind:s,metadata:i}=n;let r=globalThis.litPropertyMetadata.get(i);if(r===void 0&&globalThis.litPropertyMetadata.set(i,r=new Map),s==="setter"&&((e=Object.create(e)).wrapped=!0),r.set(n.name,e),s==="accessor"){const{name:o}=n;return{set(a){const l=t.get.call(this);t.set.call(this,a),this.requestUpdate(o,l,e,!0,a)},init(a){return a!==void 0&&this.C(o,void 0,e,a),a}}}if(s==="setter"){const{name:o}=n;return function(a){const l=this[o];t.call(this,a),this.requestUpdate(o,l,e,!0,a)}}throw Error("Unsupported decorator location: "+s)};function ps(e){return(t,n)=>typeof n=="object"?Mu(e,t,n):((s,i,r)=>{const o=i.hasOwnProperty(r);return i.constructor.createProperty(r,s),o?Object.getOwnPropertyDescriptor(i,r):void 0})(e,t,n)}function y(e){return ps({...e,state:!0,attribute:!1})}const Lu=50,Pu=200,Ru="Assistant";function ho(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function mi(e){const t=ho(e==null?void 0:e.name,Lu)??Ru,n=ho((e==null?void 0:e.avatar)??void 0,Pu)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function Iu(){return mi(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Qn="taskmaster.control.settings.v1",ja="taskmaster.account.settings.";function Zt(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const mt={gatewayUrl:Zt(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},Ne={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function Nu(){try{const e=localStorage.getItem(Qn);if(!e)return{...mt,gatewayUrl:Zt()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():Zt(),token:typeof t.token=="string"?t.token:mt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:mt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:mt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:mt.navGroupsCollapsed}}catch{return{...mt,gatewayUrl:Zt()}}}function Du(e){if(!e)return{...Ne};try{const t=localStorage.getItem(ja+e);if(!t)return{...Ne};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():Ne.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||Ne.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:Ne.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:Ne.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:Ne.splitRatio}}catch{return{...Ne}}}let Yn=null;function fo(e){Yn=e}function Fs(){return{...Nu(),...Du(Yn)}}function Ou(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Qn,JSON.stringify(t)),Yn){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(ja+Yn,JSON.stringify(n))}}(function(){try{const t=localStorage.getItem(Qn);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const s={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:Zt(),token:typeof n.token=="string"?n.token:"",theme:n.theme==="light"||n.theme==="dark"||n.theme==="system"?n.theme:"system",navCollapsed:typeof n.navCollapsed=="boolean"?n.navCollapsed:!1,navGroupsCollapsed:typeof n.navGroupsCollapsed=="object"&&n.navGroupsCollapsed!==null?n.navGroupsCollapsed:{}};localStorage.setItem(Qn,JSON.stringify(s))}catch{}})();function Ha(e){var r;const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const s=(r=n[1])==null?void 0:r.trim(),i=n.slice(2).join(":");return!s||!i?null:{agentId:s,rest:i}}const Bu=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Tn=/<\s*\/?\s*final\b[^>]*>/gi,go=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Fu(e,t){return e.trimStart()}function Uu(e,t){if(!e||!Bu.test(e))return e;let n=e;Tn.test(n)?(Tn.lastIndex=0,n=n.replace(Tn,"")):Tn.lastIndex=0,go.lastIndex=0;let s="",i=0,r=!1;for(const o of n.matchAll(go)){const a=o.index??0,l=o[1]==="/";r?l&&(r=!1):(s+=n.slice(i,a),l||(r=!0)),i=a+o[0].length}return s+=n.slice(i),Fu(s)}function qa(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function hs(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const o=-t,a=Math.round(o/1e3);if(a<60)return`in ${a}s`;const l=Math.round(a/60);if(l<60)return`in ${l}m`;const c=Math.round(l/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 s=Math.round(n/60);if(s<60)return`${s}m ago`;const i=Math.round(s/60);return i<48?`${i}h ago`:`${Math.round(i/24)}d ago`}function Ga(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const s=Math.round(n/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function Wu(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Va(e,t){return e.length<=t?{text:e,truncated:!1,total:e.length}:{text:e.slice(0,Math.max(0,t)),truncated:!0,total:e.length}}function Xn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Us(e){return Uu(e)}const Ku=/^\[([^\]]+)\]\s*/,zu=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Ws=new WeakMap,Ks=new WeakMap;function ju(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:zu.some(t=>e.startsWith(`${t} `))}function zs(e){const t=e.match(Ku);if(!t)return e;const n=t[1]??"";return ju(n)?e.slice(t[0].length):e}function Zn(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?Us(s):zs(s);if(Array.isArray(s)){const i=s.map(r=>{const o=r;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(r=>typeof r=="string");if(i.length>0){const r=i.join(`
|
|
4
|
-
`);return n==="assistant"?
|
|
5
|
-
`);const i=
|
|
6
|
-
`):null}function
|
|
7
|
-
`)}return typeof t.text=="string"?t.text:null}function
|
|
8
|
-
`):""}const
|
|
1
|
+
var au=Object.defineProperty;var lu=(e,t,n)=>t in e?au(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var B=(e,t,n)=>lu(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(i){if(i.ep)return;i.ep=!0;const r=n(i);fetch(i.href,r)}})();const cu="modulepreload",uu=function(e,t){return new URL(e,t).href},to={},pe=function(t,n,s){let i=Promise.resolve();if(n&&n.length>0){let c=function(u){return Promise.all(u.map(p=>Promise.resolve(p).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const o=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=c(n.map(u=>{if(u=uu(u,s),u in to)return;to[u]=!0;const p=u.endsWith(".css"),d=p?'[rel="stylesheet"]':"";if(s)for(let b=o.length-1;b>=0;b--){const w=o[b];if(w.href===u&&(!p||w.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${d}`))return;const h=document.createElement("link");if(h.rel=p?"stylesheet":cu,p||(h.as="script"),h.crossOrigin="",h.href=u,l&&h.setAttribute("nonce",l),document.head.appendChild(h),p)return new Promise((b,w)=>{h.addEventListener("load",b),h.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${u}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return t().catch(r)})};const Kn=globalThis,ji=Kn.ShadowRoot&&(Kn.ShadyCSS===void 0||Kn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Hi=Symbol(),no=new WeakMap;let Fa=class{constructor(t,n,s){if(this._$cssResult$=!0,s!==Hi)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(ji&&t===void 0){const s=n!==void 0&&n.length===1;s&&(t=no.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&no.set(n,t))}return t}toString(){return this.cssText}};const du=e=>new Fa(typeof e=="string"?e:e+"",void 0,Hi),pu=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((s,i,r)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[r+1],e[0]);return new Fa(n,e,Hi)},hu=(e,t)=>{if(ji)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const s=document.createElement("style"),i=Kn.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=n.cssText,e.appendChild(s)}},so=ji?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const s of t.cssRules)n+=s.cssText;return du(n)})(e):e;const{is:fu,defineProperty:gu,getOwnPropertyDescriptor:mu,getOwnPropertyNames:yu,getOwnPropertySymbols:vu,getPrototypeOf:bu}=Object,Oe=globalThis,io=Oe.trustedTypes,wu=io?io.emptyScript:"",Ds=Oe.reactiveElementPolyfillSupport,Yt=(e,t)=>e,Gn={toAttribute(e,t){switch(t){case Boolean:e=e?wu: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}},qi=(e,t)=>!fu(e,t),ro={attribute:!0,type:String,converter:Gn,reflect:!1,useDefault:!1,hasChanged:qi};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Oe.litPropertyMetadata??(Oe.litPropertyMetadata=new WeakMap);let yt=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,n=ro){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,n);i!==void 0&&gu(this.prototype,t,i)}}static getPropertyDescriptor(t,n,s){const{get:i,set:r}=mu(this.prototype,t)??{get(){return this[n]},set(o){this[n]=o}};return{get:i,set(o){const a=i==null?void 0:i.call(this);r==null||r.call(this,o),this.requestUpdate(t,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??ro}static _$Ei(){if(this.hasOwnProperty(Yt("elementProperties")))return;const t=bu(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Yt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Yt("properties"))){const n=this.properties,s=[...yu(n),...vu(n)];for(const i of s)this.createProperty(i,n[i])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[s,i]of n)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[n,s]of this.elementProperties){const i=this._$Eu(n,s);i!==void 0&&this._$Eh.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)n.unshift(so(i))}else t!==void 0&&n.push(so(t));return n}static _$Eu(t,n){const s=n.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(n=>n(this))}addController(t){var n;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)==null||n.call(t))}removeController(t){var n;(n=this._$EO)==null||n.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const s of n.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return 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 s;return(s=n.hostConnected)==null?void 0:s.call(n)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(n=>{var s;return(s=n.hostDisconnected)==null?void 0:s.call(n)})}attributeChangedCallback(t,n,s){this._$AK(t,s)}_$ET(t,n){var r;const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const o=(((r=s.converter)==null?void 0:r.toAttribute)!==void 0?s.converter:Gn).toAttribute(n,s.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,n){var r,o;const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const a=s.getPropertyOptions(i),l=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)==null?void 0:r.fromAttribute)!==void 0?a.converter:Gn;this._$Em=i;const c=l.fromAttribute(n,a.type);this[i]=c??((o=this._$Ej)==null?void 0:o.get(i))??c,this._$Em=null}}requestUpdate(t,n,s,i=!1,r){var o;if(t!==void 0){const a=this.constructor;if(i===!1&&(r=this[t]),s??(s=a.getPropertyOptions(t)),!((s.hasChanged??qi)(r,n)||s.useDefault&&s.reflect&&r===((o=this._$Ej)==null?void 0:o.get(t))&&!this.hasAttribute(a._$Eu(t,s))))return;this.C(t,n,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:s,reflect:i,wrapped:r},o){s&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,o??n??this[t]),r!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(n=void 0),this._$AL.set(t,n)),i===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var s;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[r,o]of i){const{wrapped:a}=o,l=this[r];a!==!0||this._$AL.has(r)||l===void 0||this.C(r,void 0,o,l)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),(s=this._$EO)==null||s.forEach(i=>{var r;return(r=i.hostUpdate)==null?void 0:r.call(i)}),this.update(n)):this._$EM()}catch(i){throw t=!1,this._$EM(),i}t&&this._$AE(n)}willUpdate(t){}_$AE(t){var n;(n=this._$EO)==null||n.forEach(s=>{var i;return(i=s.hostUpdated)==null?void 0:i.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(n=>this._$ET(n,this[n]))),this._$EM()}updated(t){}firstUpdated(t){}};yt.elementStyles=[],yt.shadowRootOptions={mode:"open"},yt[Yt("elementProperties")]=new Map,yt[Yt("finalized")]=new Map,Ds==null||Ds({ReactiveElement:yt}),(Oe.reactiveElementVersions??(Oe.reactiveElementVersions=[])).push("2.1.2");const Xt=globalThis,oo=e=>e,Vn=Xt.trustedTypes,ao=Vn?Vn.createPolicy("lit-html",{createHTML:e=>e}):void 0,Ua="$lit$",De=`lit$${Math.random().toFixed(9).slice(2)}$`,Wa="?"+De,ku=`<${Wa}>`,Je=document,rn=()=>Je.createComment(""),on=e=>e===null||typeof e!="object"&&typeof e!="function",Gi=Array.isArray,Su=e=>Gi(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Os=`[
|
|
2
|
+
\f\r]`,Dt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,lo=/-->/g,co=/>/g,Ge=RegExp(`>|${Os}(?:([^\\s"'>=/]+)(${Os}*=${Os}*(?:[^
|
|
3
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),uo=/'/g,po=/"/g,Ka=/^(?:script|style|textarea|title)$/i,xu=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),f=xu(1),Fe=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),ho=new WeakMap,Ye=Je.createTreeWalker(Je,129);function za(e,t){if(!Gi(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return ao!==void 0?ao.createHTML(t):t}const Au=(e,t)=>{const n=e.length-1,s=[];let i,r=t===2?"<svg>":t===3?"<math>":"",o=Dt;for(let a=0;a<n;a++){const l=e[a];let c,u,p=-1,d=0;for(;d<l.length&&(o.lastIndex=d,u=o.exec(l),u!==null);)d=o.lastIndex,o===Dt?u[1]==="!--"?o=lo:u[1]!==void 0?o=co:u[2]!==void 0?(Ka.test(u[2])&&(i=RegExp("</"+u[2],"g")),o=Ge):u[3]!==void 0&&(o=Ge):o===Ge?u[0]===">"?(o=i??Dt,p=-1):u[1]===void 0?p=-2:(p=o.lastIndex-u[2].length,c=u[1],o=u[3]===void 0?Ge:u[3]==='"'?po:uo):o===po||o===uo?o=Ge:o===lo||o===co?o=Dt:(o=Ge,i=void 0);const h=o===Ge&&e[a+1].startsWith("/>")?" ":"";r+=o===Dt?l+ku:p>=0?(s.push(c),l.slice(0,p)+Ua+l.slice(p)+De+h):l+De+(p===-2?a:h)}return[za(e,r+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};let mi=class ja{constructor({strings:t,_$litType$:n},s){let i;this.parts=[];let r=0,o=0;const a=t.length-1,l=this.parts,[c,u]=Au(t,n);if(this.el=ja.createElement(c,s),Ye.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=Ye.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(Ua)){const d=u[o++],h=i.getAttribute(p).split(De),b=/([.?@])?(.*)/.exec(d);l.push({type:1,index:r,name:b[2],strings:h,ctor:b[1]==="."?Eu:b[1]==="?"?Tu:b[1]==="@"?Cu:ps}),i.removeAttribute(p)}else p.startsWith(De)&&(l.push({type:6,index:r}),i.removeAttribute(p));if(Ka.test(i.tagName)){const p=i.textContent.split(De),d=p.length-1;if(d>0){i.textContent=Vn?Vn.emptyScript:"";for(let h=0;h<d;h++)i.append(p[h],rn()),Ye.nextNode(),l.push({type:2,index:++r});i.append(p[d],rn())}}}else if(i.nodeType===8)if(i.data===Wa)l.push({type:2,index:r});else{let p=-1;for(;(p=i.data.indexOf(De,p+1))!==-1;)l.push({type:7,index:r}),p+=De.length-1}r++}}static createElement(t,n){const s=Je.createElement("template");return s.innerHTML=t,s}};function xt(e,t,n=e,s){var o,a;if(t===Fe)return t;let i=s!==void 0?(o=n._$Co)==null?void 0:o[s]:n._$Cl;const r=on(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==r&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),r===void 0?i=void 0:(i=new r(e),i._$AT(e,n,s)),s!==void 0?(n._$Co??(n._$Co=[]))[s]=i:n._$Cl=i),i!==void 0&&(t=xt(e,i._$AS(e,t.values),i,s)),t}class $u{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:s}=this._$AD,i=((t==null?void 0:t.creationScope)??Je).importNode(n,!0);Ye.currentNode=i;let r=Ye.nextNode(),o=0,a=0,l=s[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new ds(r,r.nextSibling,this,t):l.type===1?c=new l.ctor(r,l.name,l.strings,this,t):l.type===6&&(c=new _u(r,this,t)),this._$AV.push(c),l=s[++a]}o!==(l==null?void 0:l.index)&&(r=Ye.nextNode(),o++)}return Ye.currentNode=Je,i}p(t){let n=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,n),n+=s.strings.length-2):s._$AI(t[n])),n++}}let ds=class Ha{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,n,s,i){this.type=2,this._$AH=k,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=s,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=xt(this,t,n),on(t)?t===k||t==null||t===""?(this._$AH!==k&&this._$AR(),this._$AH=k):t!==this._$AH&&t!==Fe&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Su(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&&on(this._$AH)?this._$AA.nextSibling.data=t:this.T(Je.createTextNode(t)),this._$AH=t}$(t){var r;const{values:n,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=mi.createElement(za(s.h,s.h[0]),this.options)),s);if(((r=this._$AH)==null?void 0:r._$AD)===i)this._$AH.p(n);else{const o=new $u(i,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}_$AC(t){let n=ho.get(t.strings);return n===void 0&&ho.set(t.strings,n=new mi(t)),n}k(t){Gi(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let s,i=0;for(const r of t)i===n.length?n.push(s=new Ha(this.O(rn()),this.O(rn()),this,this.options)):s=n[i],s._$AI(r),i++;i<n.length&&(this._$AR(s&&s._$AB.nextSibling,i),n.length=i)}_$AR(t=this._$AA.nextSibling,n){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,n);t!==this._$AB;){const i=oo(t).nextSibling;oo(t).remove(),t=i}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class ps{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,s,i,r){this.type=1,this._$AH=k,this._$AN=void 0,this.element=t,this.name=n,this._$AM=i,this.options=r,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=k}_$AI(t,n=this,s,i){const r=this.strings;let o=!1;if(r===void 0)t=xt(this,t,n,0),o=!on(t)||t!==this._$AH&&t!==Fe,o&&(this._$AH=t);else{const a=t;let l,c;for(t=r[0],l=0;l<r.length-1;l++)c=xt(this,a[s+l],n,l),c===Fe&&(c=this._$AH[l]),o||(o=!on(c)||c!==this._$AH[l]),c===k?t=k:t!==k&&(t+=(c??"")+r[l+1]),this._$AH[l]=c}o&&!i&&this.j(t)}j(t){t===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let Eu=class extends ps{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===k?void 0:t}},Tu=class extends ps{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==k)}},Cu=class extends ps{constructor(t,n,s,i,r){super(t,n,s,i,r),this.type=5}_$AI(t,n=this){if((t=xt(this,t,n,0)??k)===Fe)return;const s=this._$AH,i=t===k&&s!==k||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==k&&(s===k||i);i&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,t):this._$AH.handleEvent(t)}},_u=class{constructor(t,n,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){xt(this,t)}};const Mu={I:ds},Bs=Xt.litHtmlPolyfillSupport;Bs==null||Bs(mi,ds),(Xt.litHtmlVersions??(Xt.litHtmlVersions=[])).push("3.3.2");const Lu=(e,t,n)=>{const s=(n==null?void 0:n.renderBefore)??t;let i=s._$litPart$;if(i===void 0){const r=(n==null?void 0:n.renderBefore)??null;s._$litPart$=i=new ds(t.insertBefore(rn(),r),r,void 0,n??{})}return i._$AI(e),i};const Ze=globalThis;let kt=class extends yt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var n;const t=super.createRenderRoot();return(n=this.renderOptions).renderBefore??(n.renderBefore=t.firstChild),t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Lu(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 Fe}};var Ba;kt._$litElement$=!0,kt.finalized=!0,(Ba=Ze.litElementHydrateSupport)==null||Ba.call(Ze,{LitElement:kt});const Fs=Ze.litElementPolyfillSupport;Fs==null||Fs({LitElement:kt});(Ze.litElementVersions??(Ze.litElementVersions=[])).push("4.2.2");const qa=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const Pu={attribute:!0,type:String,converter:Gn,reflect:!1,hasChanged:qi},Ru=(e=Pu,t,n)=>{const{kind:s,metadata:i}=n;let r=globalThis.litPropertyMetadata.get(i);if(r===void 0&&globalThis.litPropertyMetadata.set(i,r=new Map),s==="setter"&&((e=Object.create(e)).wrapped=!0),r.set(n.name,e),s==="accessor"){const{name:o}=n;return{set(a){const l=t.get.call(this);t.set.call(this,a),this.requestUpdate(o,l,e,!0,a)},init(a){return a!==void 0&&this.C(o,void 0,e,a),a}}}if(s==="setter"){const{name:o}=n;return function(a){const l=this[o];t.call(this,a),this.requestUpdate(o,l,e,!0,a)}}throw Error("Unsupported decorator location: "+s)};function hs(e){return(t,n)=>typeof n=="object"?Ru(e,t,n):((s,i,r)=>{const o=i.hasOwnProperty(r);return i.constructor.createProperty(r,s),o?Object.getOwnPropertyDescriptor(i,r):void 0})(e,t,n)}function y(e){return hs({...e,state:!0,attribute:!1})}const Iu=50,Nu=200,Du="Assistant";function fo(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function yi(e){const t=fo(e==null?void 0:e.name,Iu)??Du,n=fo((e==null?void 0:e.avatar)??void 0,Nu)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function Ou(){return yi(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Qn="taskmaster.control.settings.v1",Ga="taskmaster.account.settings.";function Zt(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const mt={gatewayUrl:Zt(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},Ne={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function Bu(){try{const e=localStorage.getItem(Qn);if(!e)return{...mt,gatewayUrl:Zt()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():Zt(),token:typeof t.token=="string"?t.token:mt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:mt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:mt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:mt.navGroupsCollapsed}}catch{return{...mt,gatewayUrl:Zt()}}}function Fu(e){if(!e)return{...Ne};try{const t=localStorage.getItem(Ga+e);if(!t)return{...Ne};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():Ne.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||Ne.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:Ne.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:Ne.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:Ne.splitRatio}}catch{return{...Ne}}}let Yn=null;function go(e){Yn=e}function Us(){return{...Bu(),...Fu(Yn)}}function Uu(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Qn,JSON.stringify(t)),Yn){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Ga+Yn,JSON.stringify(n))}}(function(){try{const t=localStorage.getItem(Qn);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const s={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:Zt(),token:typeof n.token=="string"?n.token:"",theme:n.theme==="light"||n.theme==="dark"||n.theme==="system"?n.theme:"system",navCollapsed:typeof n.navCollapsed=="boolean"?n.navCollapsed:!1,navGroupsCollapsed:typeof n.navGroupsCollapsed=="object"&&n.navGroupsCollapsed!==null?n.navGroupsCollapsed:{}};localStorage.setItem(Qn,JSON.stringify(s))}catch{}})();function Va(e){var r;const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const s=(r=n[1])==null?void 0:r.trim(),i=n.slice(2).join(":");return!s||!i?null:{agentId:s,rest:i}}const Wu=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Tn=/<\s*\/?\s*final\b[^>]*>/gi,mo=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Ku(e,t){return e.trimStart()}function zu(e,t){if(!e||!Wu.test(e))return e;let n=e;Tn.test(n)?(Tn.lastIndex=0,n=n.replace(Tn,"")):Tn.lastIndex=0,mo.lastIndex=0;let s="",i=0,r=!1;for(const o of n.matchAll(mo)){const a=o.index??0,l=o[1]==="/";r?l&&(r=!1):(s+=n.slice(i,a),l||(r=!0)),i=a+o[0].length}return s+=n.slice(i),Ku(s)}function Qa(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function fs(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const o=-t,a=Math.round(o/1e3);if(a<60)return`in ${a}s`;const l=Math.round(a/60);if(l<60)return`in ${l}m`;const c=Math.round(l/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 s=Math.round(n/60);if(s<60)return`${s}m ago`;const i=Math.round(s/60);return i<48?`${i}h ago`:`${Math.round(i/24)}d ago`}function Ya(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const s=Math.round(n/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function ju(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Xa(e,t){return e.length<=t?{text:e,truncated:!1,total:e.length}:{text:e.slice(0,Math.max(0,t)),truncated:!0,total:e.length}}function Xn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Ws(e){return zu(e)}const Hu=/^\[([^\]]+)\]\s*/,qu=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Ks=new WeakMap,zs=new WeakMap;function Gu(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:qu.some(t=>e.startsWith(`${t} `))}function js(e){const t=e.match(Hu);if(!t)return e;const n=t[1]??"";return Gu(n)?e.slice(t[0].length):e}function Zn(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?Ws(s):js(s);if(Array.isArray(s)){const i=s.map(r=>{const o=r;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(r=>typeof r=="string");if(i.length>0){const r=i.join(`
|
|
4
|
+
`);return n==="assistant"?Ws(r):js(r)}}return typeof t.text=="string"?n==="assistant"?Ws(t.text):js(t.text):null}function Za(e){if(!e||typeof e!="object")return Zn(e);const t=e;if(Ks.has(t))return Ks.get(t)??null;const n=Zn(e);return Ks.set(t,n),n}function yo(e){const n=e.content,s=[];if(Array.isArray(n))for(const a of n){const l=a;if(l.type==="thinking"&&typeof l.thinking=="string"){const c=l.thinking.trim();c&&s.push(c)}}if(s.length>0)return s.join(`
|
|
5
|
+
`);const i=Qu(e);if(!i)return null;const o=[...i.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(a=>(a[1]??"").trim()).filter(Boolean);return o.length>0?o.join(`
|
|
6
|
+
`):null}function Vu(e){if(!e||typeof e!="object")return yo(e);const t=e;if(zs.has(t))return zs.get(t)??null;const n=yo(e);return zs.set(t,n),n}function Qu(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const s=n.map(i=>{const r=i;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(i=>typeof i=="string");if(s.length>0)return s.join(`
|
|
7
|
+
`)}return typeof t.text=="string"?t.text:null}function Yu(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean).map(s=>`_${s}_`);return n.length?["_Reasoning:_",...n].join(`
|
|
8
|
+
`):""}const Xu=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Zu=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Ju=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,ed=/^A new session was started via \/new or \/reset\./;function td(e){const t=e,n=typeof t.role=="string"?t.role:"";let s="";typeof t.content=="string"?s=t.content:Array.isArray(t.content)?s=t.content.filter(r=>typeof r=="object"&&r!==null).map(r=>r.text??"").join(" "):typeof t.text=="string"&&(s=t.text);const i=s.trim();return i?!!(n==="user"&&Xu.test(i)||n==="assistant"&&Zu.test(i)||n==="user"&&ed.test(i)||n==="assistant"&&Ju.test(i)):!1}function nd(e){return e.filter(t=>!td(t))}function Ja(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const s=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",i=t.content,r=Array.isArray(i)?i:null,o=Array.isArray(r)&&r.some(p=>{const h=String(p.type??"").toLowerCase();return h==="toolresult"||h==="tool_result"}),a=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||a)&&(n="toolResult");let l=[];typeof t.content=="string"?l=[{type:"text",text:t.content}]:Array.isArray(t.content)?l=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(l=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),u=typeof t.id=="string"?t.id:void 0;return{role:n,content:l,timestamp:c,id:u}}function el(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 tl(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function vo(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 sd(){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 Vi(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),vo(t)}return vo(sd())}async function Me(e){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{const t=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:200}),n=Array.isArray(t.messages)?t.messages:[];e.chatMessages=nd(n),e.chatThinkingLevel=t.thinkingLevel??null,e.chatModelProvider=typeof t.modelProvider=="string"?t.modelProvider:null,e.chatModel=typeof t.model=="string"?t.model:null,e.chatVerboseLevel=typeof t.verboseLevel=="string"?t.verboseLevel:null,e.chatFillerEnabled=typeof t.fillerEnabled=="boolean"?t.fillerEnabled:null}catch(t){e.lastError=String(t)}finally{e.chatLoading=!1}}}function id(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function nl(e,t,n){if(!e.client||!e.connected)return!1;const s=t.trim(),i=n&&n.length>0;if(!s&&!i)return!1;const r=Date.now(),o=(n??[]).filter(h=>!h.fileName),a=(n??[]).filter(h=>h.fileName),l=[],c=a.map(h=>h.fileName).filter(Boolean);if(c.length>0){const h=s?`${c.join(", ")}
|
|
9
9
|
|
|
10
|
-
${s}`:c.join(", ");l.push({type:"text",text:
|
|
11
|
-
`)}function
|
|
10
|
+
${s}`:c.join(", ");l.push({type:"text",text:h})}else s&&l.push({type:"text",text:s});for(const h of o)l.push({type:"image",source:{type:"base64",media_type:h.mimeType,data:h.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:l,timestamp:r}],e.chatSending=!0,e.lastError=null;const u=Vi();e.chatRunId=u,e.chatStream="",e.chatStreamStartedAt=r;const p=[...o,...a],d=p.length>0?p.map(h=>{if(h.textContent)return{type:"document",mimeType:h.mimeType||"text/plain",fileName:h.fileName,content:btoa(unescape(encodeURIComponent(h.textContent)))};const b=id(h.dataUrl);return b?{type:h.fileName?"document":"image",mimeType:b.mimeType,fileName:h.fileName,content:b.content}:null}).filter(h=>h!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:s,deliver:!1,idempotencyKey:u,attachments:d}),!0}catch(h){const b=String(h);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=b,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+b}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function 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 il(e,t){if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="block"){const n=Zn(t.message);return typeof n=="string"&&n.trim()&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:n.trim()}],timestamp:Date.now(),filler:!0}]),"block"}else if(t.state==="delta"){const n=Zn(t.message);if(typeof n=="string"){if(n.trim()==="NO_REPLY")return null;const s=e.chatStream??"";(!s||n.length>=s.length)&&(e.chatStream=n)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.lastError=t.errorMessage??"chat error");return t.state}const rd=Object.freeze(Object.defineProperty({__proto__:null,abortChatRun:sl,handleChatEvent:il,loadChatHistory:Me,sendChatMessage:nl},Symbol.toStringTag,{value:"Module"}));async function Qi(e){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const t={includeGlobal:e.sessionsIncludeGlobal??!0,includeUnknown:e.sessionsIncludeUnknown??!1},n=Xn(e.sessionsFilterActive??"",0),s=Xn(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),s>0&&(t.limit=s);const i=await e.client.request("sessions.list",t);i&&(e.sessionsResult=i)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function Cn(e,t,n){if(!e.client||!e.connected)return;const s={key:t};"label"in n&&(s.label=n.label),"thinkingLevel"in n&&(s.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(s.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(s.reasoningLevel=n.reasoningLevel),"model"in n&&(s.model=n.model),"fillerEnabled"in n&&(s.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",s),await Qi(e)}catch(i){e.sessionsError=String(i)}}const bo=50,od=80,ad=12e4;function ld(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const s=n.map(i=>{if(!i||typeof i!="object")return null;const r=i;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(i=>!!i);return s.length===0?null:s.join(`
|
|
11
|
+
`)}function wo(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=ld(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const s=Xa(n,ad);return s.truncated?`${s.text}
|
|
12
12
|
|
|
13
|
-
… truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function
|
|
13
|
+
… truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function cd(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 ud(e){if(e.toolStreamOrder.length<=bo)return;const t=e.toolStreamOrder.length-bo,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function dd(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function vi(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),dd(e)}function pd(e,t=!1){if(t){vi(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>vi(e),od))}function Yi(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],vi(e)}const hd=5e3;function fd(e,t){var i;const n=t.data??{},s=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),s==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:s==="end"&&(e.compactionStatus={active:!1,startedAt:((i=e.compactionStatus)==null?void 0:i.startedAt)??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},hd))}function gd(e,t){if(!t)return;if(t.stream==="compaction"){fd(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const s=t.data??{},i=typeof s.toolCallId=="string"?s.toolCallId:"";if(!i)return;const r=typeof s.name=="string"?s.name:"tool",o=typeof s.phase=="string"?s.phase:"",a=o==="start"?s.args:void 0,l=o==="update"?wo(s.partialResult):o==="result"?wo(s.result):void 0,c=Date.now();let u=e.toolStreamById.get(i);u?(u.name=r,a!==void 0&&(u.args=a),l!==void 0&&(u.output=l),u.updatedAt=c):(u={toolCallId:i,runId:t.runId,sessionKey:n,name:r,args:a,output:l,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(i,u),e.toolStreamOrder.push(i)),u.message=cd(u),ud(e),pd(e,o==="result")}function cn(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=()=>{const s=e.querySelector(".chat-thread");if(s){const i=getComputedStyle(s).overflowY;if(i==="auto"||i==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;const s=n();if(!s)return;const i=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||i<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const o=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;const a=n();if(!a)return;const l=a.scrollHeight-a.scrollTop-a.clientHeight;(t||e.chatUserNearBottom||l<200)&&(a.scrollTop=a.scrollHeight,e.chatUserNearBottom=!0)},o)})})}function rl(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 md(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<200}function yd(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function vd(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function bd(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function wd(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
|
|
14
14
|
`)}
|
|
15
|
-
`],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),r=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`taskmaster-logs-${t}-${r}.log`,i.click(),URL.revokeObjectURL(s)}function
|
|
15
|
+
`],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),r=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`taskmaster-logs-${t}-${r}.log`,i.click(),URL.revokeObjectURL(s)}function kd(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
|
|
16
16
|
`)}
|
|
17
|
-
`],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),r=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`taskmaster-session-logs-${t}-${r}.log`,i.click(),URL.revokeObjectURL(s)}function
|
|
18
|
-
`}function sl(e,t,n){if(t.length===0)return;let s=e;for(let r=0;r<t.length-1;r+=1){const o=t[r],a=t[r+1];if(typeof o=="number"){if(!Array.isArray(s))return;s[o]==null&&(s[o]=typeof a=="number"?[]:{}),s=s[o]}else{if(typeof s!="object"||s==null)return;const l=s;l[o]==null&&(l[o]=typeof a=="number"?[]:{}),s=l[o]}}const i=t[t.length-1];if(typeof i=="number"){Array.isArray(s)&&(s[i]=n);return}typeof s=="object"&&s!=null&&(s[i]=n)}async function xe(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});kd(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function il(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});wd(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function wd(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function kd(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?et(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=et(e.configForm):e.configRaw=n,e.configValid=typeof t.valid=="boolean"?t.valid:null,e.configIssues=Array.isArray(t.issues)?t.issues:[],e.configFormDirty||(e.configForm=Ue(t.config??{}),e.configFormOriginal=Ue(t.config??{}),e.configRawOriginal=n)}async function Sd(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?et(e.configForm):e.configRaw,s=(t=e.configSnapshot)==null?void 0:t.hash;if(!s){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:n,baseHash:s}),e.configFormDirty=!1,await xe(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function un(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("cron.status",{});e.cronStatus=t}catch(t){e.cronError=String(t)}}async function fs(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t={includeDisabled:!0};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(t.agentIds=e.workspaceAgentIds);const n=await e.client.request("cron.list",t);e.cronJobs=Array.isArray(n.jobs)?n.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function xd(e){if(e.scheduleKind==="at"){const n=Date.parse(e.scheduleAt);if(!Number.isFinite(n))throw new Error("Invalid run time.");return{kind:"at",atMs:n}}if(e.scheduleKind==="every"){const n=Xn(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const s=e.everyUnit;return{kind:"every",everyMs:n*(s==="minutes"?6e4:s==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function Ad(e){if(e.payloadKind==="systemEvent"){const i=e.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel),e.to.trim()&&(n.to=e.to.trim());const s=Xn(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function $d(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=xd(e.cronForm),s=Ad(e.cronForm),i=e.cronForm.agentId.trim(),r=(t=e.cronForm.accountId)==null?void 0:t.trim(),o={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:i||void 0,accountId:r||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:s,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!o.name)throw new Error("Name required.");await e.client.request("cron.add",o),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await fs(e),await un(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Ed(e,t,n){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.update",{id:t.id,patch:{enabled:n}}),await fs(e),await un(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function Td(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await vi(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Cd(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.remove",{id:t.id}),e.cronRunsJobId===t.id&&(e.cronRunsJobId=null,e.cronRuns=[]),await fs(e),await un(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function vi(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("cron.runs",{id:t,limit:50});e.cronRunsJobId=t,e.cronRuns=Array.isArray(n.entries)?n.entries:[]}catch(n){e.cronError=String(n)}}async function q(e,t){if(!(!e.client||!e.connected)&&!e.channelsLoading){e.channelsLoading=!0,e.channelsError=null;try{const n=await e.client.request("channels.status",{probe:t,timeoutMs:8e3});e.channelsSnapshot=n,e.channelsLastSuccess=Date.now()}catch(n){e.channelsError=String(n)}finally{e.channelsLoading=!1}}}async function Yi(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const s=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=s.message??null,e.whatsappLoginQrDataUrl=s.qrDataUrl??null,e.whatsappLoginConnected=null}catch(s){e.whatsappLoginMessage=String(s),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function rl(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 ol(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 al(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const s=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!s){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const r=Ue(i.config??{});(!r.channels||typeof r.channels!="object")&&(r.channels={});const o=r.channels;(!o.whatsapp||typeof o.whatsapp!="object")&&(o.whatsapp={});const a=o.whatsapp;(!a.accounts||typeof a.accounts!="object")&&(a.accounts={});const l=a.accounts;if(l[s]){e.whatsappAccountError=`Account "${s}" already exists.`;return}l[s]={name:n,provider:"baileys"};const c=i.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const u=et(r);await e.client.request("config.set",{raw:u,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await q(e,!0),await Yi(e,!0,s)}catch(i){e.whatsappAccountError=String(i)}finally{e.whatsappAccountSaving=!1}}async function ll(e,t){if(!(!e.client||!e.connected)&&!e.whatsappAccountSaving){e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const s=Ue(n.config??{}),i=s.channels,r=i==null?void 0:i.whatsapp,o=r==null?void 0:r.accounts;if(!o){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(o).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!o[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete o[t],Array.isArray(s.bindings)&&(s.bindings=s.bindings.filter(u=>{const p=u.match;return!p||p.channel!=="whatsapp"?!0:p.accountId!==t}));const l=n.hash;if(!l){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=et(s);await e.client.request("config.set",{raw:c,baseHash:l}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await q(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const _d=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:al,loadChannels:q,logoutWhatsApp:ol,removeWhatsAppAccount:ll,startWhatsAppLogin:Yi,waitWhatsAppLogin:rl},Symbol.toStringTag,{value:"Module"}));async function Xi(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,s,i]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const r=s;e.debugModels=Array.isArray(r==null?void 0:r.models)?r==null?void 0:r.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const Md=2e3,Ld=new Set(["trace","debug","info","warn","error","fatal"]);function Pd(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 Rd(e){if(typeof e!="string")return null;const t=e.toLowerCase();return Ld.has(t)?t:null}function Id(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,s=typeof t.time=="string"?t.time:typeof(n==null?void 0:n.date)=="string"?n==null?void 0:n.date:null,i=Rd((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),r=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,o=Pd(r);let a=null;o&&(typeof o.subsystem=="string"?a=o.subsystem:typeof o.module=="string"&&(a=o.module)),!a&&r&&r.length<120&&(a=r);let l=null;return typeof t[1]=="string"?l=t[1]:!o&&typeof t[0]=="string"?l=t[0]:typeof t.message=="string"&&(l=t.message),{raw:e,time:s,level:i,subsystem:a,message:l??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Jt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const s=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),r=(Array.isArray(s.lines)?s.lines.filter(a=>typeof a=="string"):[]).map(Id),o=!!(t!=null&&t.reset||s.reset||e.logsCursor==null);e.logsEntries=o?r:[...e.logsEntries,...r].slice(-Md),typeof s.cursor=="number"&&(e.logsCursor=s.cursor),typeof s.file=="string"&&(e.logsFile=s.file),e.logsTruncated=!!s.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const cl={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:se,n:zn,Gx:wo,Gy:ko,a:js,d:Hs,h:Nd}=cl,tt=32,Zi=64,Dd=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},Z=(e="")=>{const t=new Error(e);throw Dd(t,Z),t},Od=e=>typeof e=="bigint",Bd=e=>typeof e=="string",Fd=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",Ke=(e,t,n="")=>{const s=Fd(e),i=e==null?void 0:e.length,r=t!==void 0;if(!s||r&&i!==t){const o=n&&`"${n}" `,a=r?` of length ${t}`:"",l=s?`length=${i}`:`type=${typeof e}`;Z(o+"expected Uint8Array"+a+", got "+l)}return e},gs=e=>new Uint8Array(e),ul=e=>Uint8Array.from(e),dl=(e,t)=>e.toString(16).padStart(t,"0"),pl=e=>Array.from(Ke(e)).map(t=>dl(t,2)).join(""),Te={_0:48,_9:57,A:65,F:70,a:97,f:102},So=e=>{if(e>=Te._0&&e<=Te._9)return e-Te._0;if(e>=Te.A&&e<=Te.F)return e-(Te.A-10);if(e>=Te.a&&e<=Te.f)return e-(Te.a-10)},hl=e=>{const t="hex invalid";if(!Bd(e))return Z(t);const n=e.length,s=n/2;if(n%2)return Z(t);const i=gs(s);for(let r=0,o=0;r<s;r++,o+=2){const a=So(e.charCodeAt(o)),l=So(e.charCodeAt(o+1));if(a===void 0||l===void 0)return Z(t);i[r]=a*16+l}return i},fl=()=>globalThis==null?void 0:globalThis.crypto,Ud=()=>{var e;return((e=fl())==null?void 0:e.subtle)??Z("crypto.subtle must be defined, consider polyfill")},an=(...e)=>{const t=gs(e.reduce((s,i)=>s+Ke(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},Wd=(e=tt)=>fl().getRandomValues(gs(e)),Jn=BigInt,Qe=(e,t,n,s="bad number: out of range")=>Od(e)&&t<=e&&e<n?e:Z(s),M=(e,t=se)=>{const n=e%t;return n>=0n?n:t+n},gl=e=>M(e,zn),Kd=(e,t)=>{(e===0n||t<=0n)&&Z("no inverse n="+e+" mod="+t);let n=M(e,t),s=t,i=0n,r=1n;for(;n!==0n;){const o=s/n,a=s%n,l=i-r*o;s=n,n=a,i=r,r=l}return s===1n?M(i,t):Z("no inverse")},zd=e=>{const t=bl[e];return typeof t!="function"&&Z("hashes."+e+" not set"),t},qs=e=>e instanceof nt?e:Z("Point expected"),bi=2n**256n,Se=class Se{constructor(t,n,s,i){B(this,"X");B(this,"Y");B(this,"Z");B(this,"T");const r=bi;this.X=Qe(t,0n,r),this.Y=Qe(n,0n,r),this.Z=Qe(s,1n,r),this.T=Qe(i,0n,r),Object.freeze(this)}static CURVE(){return cl}static fromAffine(t){return new Se(t.x,t.y,1n,M(t.x*t.y))}static fromBytes(t,n=!1){const s=Hs,i=ul(Ke(t,tt)),r=t[31];i[31]=r&-129;const o=yl(i);Qe(o,0n,n?bi:se);const l=M(o*o),c=M(l-1n),u=M(s*l+1n);let{isValid:p,value:d}=Hd(c,u);p||Z("bad point: y not sqrt");const f=(d&1n)===1n,b=(r&128)!==0;return!n&&d===0n&&b&&Z("bad point: x==0, isLastByteOdd"),b!==f&&(d=M(-d)),new Se(d,o,1n,M(d*o))}static fromHex(t,n){return Se.fromBytes(hl(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=js,n=Hs,s=this;if(s.is0())return Z("bad point: ZERO");const{X:i,Y:r,Z:o,T:a}=s,l=M(i*i),c=M(r*r),u=M(o*o),p=M(u*u),d=M(l*t),f=M(u*M(d+c)),b=M(p+M(n*M(l*c)));if(f!==b)return Z("bad point: equation left != right (1)");const w=M(i*r),S=M(o*a);return w!==S?Z("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:r,Y:o,Z:a}=qs(t),l=M(n*a),c=M(r*i),u=M(s*a),p=M(o*i);return l===c&&u===p}is0(){return this.equals(bt)}negate(){return new Se(M(-this.X),this.Y,this.Z,M(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=js,r=M(t*t),o=M(n*n),a=M(2n*M(s*s)),l=M(i*r),c=t+n,u=M(M(c*c)-r-o),p=l+o,d=p-a,f=l-o,b=M(u*d),w=M(p*f),S=M(u*f),T=M(d*p);return new Se(b,w,T,S)}add(t){const{X:n,Y:s,Z:i,T:r}=this,{X:o,Y:a,Z:l,T:c}=qs(t),u=js,p=Hs,d=M(n*o),f=M(s*a),b=M(r*p*c),w=M(i*l),S=M((n+s)*(o+a)-d-f),T=M(w-b),A=M(w+b),E=M(f-u*d),C=M(S*T),R=M(A*E),U=M(S*E),Q=M(T*A);return new Se(C,R,Q,U)}subtract(t){return this.add(qs(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return bt;if(Qe(t,1n,zn),t===1n)return this;if(this.equals(st))return np(t).p;let s=bt,i=st;for(let r=this;t>0n;r=r.double(),t>>=1n)t&1n?s=s.add(r):n&&(i=i.add(r));return s}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:s}=this;if(this.equals(bt))return{x:0n,y:1n};const i=Kd(s,se);M(s*i)!==1n&&Z("invalid inverse");const r=M(t*i),o=M(n*i);return{x:r,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=ml(n);return s[31]|=t&1n?128:0,s}toHex(){return pl(this.toBytes())}clearCofactor(){return this.multiply(Jn(Nd),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(zn/2n,!1).double();return zn%2n&&(t=t.add(this)),t.is0()}};B(Se,"BASE"),B(Se,"ZERO");let nt=Se;const st=new nt(wo,ko,1n,M(wo*ko)),bt=new nt(0n,1n,1n,0n);nt.BASE=st;nt.ZERO=bt;const ml=e=>hl(dl(Qe(e,0n,bi),Zi)).reverse(),yl=e=>Jn("0x"+pl(ul(Ke(e)).reverse())),be=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=se;return n},jd=e=>{const n=e*e%se*e%se,s=be(n,2n)*n%se,i=be(s,1n)*e%se,r=be(i,5n)*i%se,o=be(r,10n)*r%se,a=be(o,20n)*o%se,l=be(a,40n)*a%se,c=be(l,80n)*l%se,u=be(c,80n)*l%se,p=be(u,10n)*r%se;return{pow_p_5_8:be(p,2n)*e%se,b2:n}},xo=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Hd=(e,t)=>{const n=M(t*t*t),s=M(n*n*t),i=jd(e*s).pow_p_5_8;let r=M(e*n*i);const o=M(t*r*r),a=r,l=M(r*xo),c=o===e,u=o===M(-e),p=o===M(-e*xo);return c&&(r=a),(u||p)&&(r=l),(M(r)&1n)===1n&&(r=M(-r)),{isValid:c||u,value:r}},wi=e=>gl(yl(e)),Ji=(...e)=>bl.sha512Async(an(...e)),qd=(...e)=>zd("sha512")(an(...e)),vl=e=>{const t=e.slice(0,tt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(tt,Zi),s=wi(t),i=st.multiply(s),r=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:r}},er=e=>Ji(Ke(e,tt)).then(vl),Gd=e=>vl(qd(Ke(e,tt))),Vd=e=>er(e).then(t=>t.pointBytes),Qd=e=>Ji(e.hashable).then(e.finish),Yd=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,r=wi(t),o=st.multiply(r).toBytes();return{hashable:an(o,s,n),finish:c=>{const u=gl(r+wi(c)*i);return Ke(an(o,ml(u)),Zi)}}},Xd=async(e,t)=>{const n=Ke(e),s=await er(t),i=await Ji(s.prefix,n);return Qd(Yd(s,i,n))},bl={sha512Async:async e=>{const t=Ud(),n=an(e);return gs(await t.digest("SHA-512",n.buffer))},sha512:void 0},Zd=(e=Wd(tt))=>e,Jd={getExtendedPublicKeyAsync:er,getExtendedPublicKey:Gd,randomSecretKey:Zd},es=8,ep=256,wl=Math.ceil(ep/es)+1,ki=2**(es-1),tp=()=>{const e=[];let t=st,n=t;for(let s=0;s<wl;s++){n=t,e.push(n);for(let i=1;i<ki;i++)n=n.add(t),e.push(n);t=n.double()}return e};let Ao;const $o=(e,t)=>{const n=t.negate();return e?n:t},np=e=>{const t=Ao||(Ao=tp());let n=bt,s=st;const i=2**es,r=i,o=Jn(i-1),a=Jn(es);for(let l=0;l<wl;l++){let c=Number(e&o);e>>=a,c>ki&&(c-=r,e+=1n);const u=l*ki,p=u,d=u+Math.abs(c)-1,f=l%2!==0,b=c<0;c===0?s=s.add($o(f,t[p])):n=n.add($o(b,t[d]))}return e!==0n&&Z("invalid wnaf"),{p:n,f:s}},Gs="taskmaster-device-identity-v1";function Si(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function kl(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),s=atob(n),i=new Uint8Array(s.length);for(let r=0;r<s.length;r+=1)i[r]=s.charCodeAt(r);return i}function sp(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Sl(e){const t=await crypto.subtle.digest("SHA-256",e);return sp(new Uint8Array(t))}async function ip(){const e=Jd.randomSecretKey(),t=await Vd(e);return{deviceId:await Sl(t),publicKey:Si(t),privateKey:Si(e)}}async function rp(){try{const n=localStorage.getItem(Gs);if(n){const s=JSON.parse(n);if((s==null?void 0:s.version)===1&&typeof s.deviceId=="string"&&typeof s.publicKey=="string"&&typeof s.privateKey=="string"){const i=await Sl(kl(s.publicKey));if(i!==s.deviceId){const r={...s,deviceId:i};return localStorage.setItem(Gs,JSON.stringify(r)),{deviceId:i,publicKey:s.publicKey,privateKey:s.privateKey}}return{deviceId:s.deviceId,publicKey:s.publicKey,privateKey:s.privateKey}}}}catch{}const e=await ip(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Gs,JSON.stringify(t)),e}async function op(e,t){const n=kl(e),s=new TextEncoder().encode(t),i=await Xd(s,n);return Si(i)}const xl="taskmaster.device.auth.v1";function tr(e){return e.trim()}function ap(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const s=n.trim();s&&t.add(s)}return[...t].sort()}function nr(){try{const e=window.localStorage.getItem(xl);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 Al(e){try{window.localStorage.setItem(xl,JSON.stringify(e))}catch{}}function lp(e){const t=nr();if(!t||t.deviceId!==e.deviceId)return null;const n=tr(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function cp(e){const t=tr(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=nr();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:ap(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,Al(n),i}function up(e){const t=nr();if(!t||t.deviceId!==e.deviceId)return;const n=tr(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],Al(s)}async function sr(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t!=null&&t.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n==null?void 0:n.pending)?n.pending:[],paired:Array.isArray(n==null?void 0:n.paired)?n.paired:[]}}catch(n){t!=null&&t.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function ir(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t!=null&&t.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t!=null&&t.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function dp(e){return{method:"exec.approvals.get",params:{}}}async function pp(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=dp(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);hp(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function hp(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=Ue(t.file??{}))}async function $l(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 At(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function ms(e){return e instanceof Error?e.message:String(e)}async function $t(e,t){if(t!=null&&t.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{const n=await e.client.request("skills.status",{});n&&(e.skillsReport=n)}catch(n){e.skillsError=ms(n)}finally{e.skillsLoading=!1}}}function fp(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function gp(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,enabled:n}),await $t(e),At(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=ms(s);e.skillsError=i,At(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function mp(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const n=e.skillEdits[t]??"";await e.client.request("skills.update",{skillKey:t,apiKey:n}),await $t(e),At(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=ms(n);e.skillsError=s,At(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function yp(e,t,n,s){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.install",{name:n,installId:s,timeoutMs:12e4});await $t(e),At(e,t,{kind:"success",message:(i==null?void 0:i.message)??"Installed"})}catch(i){const r=ms(i);e.skillsError=r,At(e,t,{kind:"error",message:r})}finally{e.skillsBusyKey=null}}}const El={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},Tl=new Map(Object.entries(El).map(([e,t])=>[t,e]));function ys(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function ln(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 vp(e,t=""){const n=ys(t),s=El[e];return n?`${n}${s}`:s}function Cl(e,t=""){const n=ys(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=ln(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":Tl.get(i)??null}function bp(e){let t=ln(e);if(t.endsWith("/index.html")&&(t=ln(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let s=0;s<n.length;s++){const i=`/${n.slice(s).join("/")}`.toLowerCase();if(Tl.has(i)){const r=n.slice(0,s);return r.length?`/${r.join("/")}`:""}}return`/${n.join("/")}`}function wp(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function rr(e){return e==="system"?wp():e}const _n=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,kp=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Mn=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},Sp=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{var c;if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const r=i.documentElement,o=i,a=kp();if(!!o.startViewTransition&&!a){let u=.5,p=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")u=_n(n.pointerClientX/window.innerWidth),p=_n(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const d=n.element.getBoundingClientRect();d.width>0&&d.height>0&&typeof window<"u"&&(u=_n((d.left+d.width/2)/window.innerWidth),p=_n((d.top+d.height/2)/window.innerHeight))}r.style.setProperty("--theme-switch-x",`${u*100}%`),r.style.setProperty("--theme-switch-y",`${p*100}%`),r.classList.add("theme-transition");try{const d=(c=o.startViewTransition)==null?void 0:c.call(o,()=>{t()});d!=null&&d.finished?d.finished.finally(()=>Mn(r)):Mn(r)}catch{Mn(r),t()}return}t(),Mn(r)},xp=2e3;async function wt(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const s=await e.client.request("sessions.transcript",{cursors:t!=null&&t.reset?void 0:e.sessionLogsCursors,limit:200,maxBytesPerFile:e.sessionLogsFull?25e4:5e4,...e.sessionLogsFull?{full:!0}:{}}),i=Array.isArray(s.entries)?s.entries:[],r=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=r?i:[...e.sessionLogsEntries,...i].slice(-xp),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 Ap=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:wt},Symbol.toStringTag,{value:"Module"}));async function _l(e,t){if(!(!e.client||!e.connected))try{const n={},s=await e.client.request("memory.audit",n);s!=null&&s.ok&&(e.auditEntries=s.entries??[])}catch{}}async function $p(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function Le(e){return e instanceof Error?e.message:String(e)}let Ln=null;function dn(e,t){Ln&&clearTimeout(Ln),e.filesMessage={kind:"success",text:t},Ln=setTimeout(()=>{e.filesMessage=null,Ln=null},3e3)}async function pn(e,t){if(!(!e.client||!e.connected)){if(!t){e.filesTree=[],e.filesRoot="";return}if(!e.filesLoading){e.filesLoading=!0,e.filesError=null;try{const n={};t&&(n.agentId=t);const s=await e.client.request("files.tree",n);s!=null&&s.tree&&(e.filesTree=s.tree,e.filesRoot=s.root??"")}catch(n){e.filesError=Le(n)}finally{e.filesLoading=!1}}}}async function Ep(e,t,n){e.filesSelectedPaths=new Set([t]),await Ml(e,t,n)}async function Tp(e,t,n){const s=new Set(e.filesSelectedPaths);if(s.has(t)?s.delete(t):s.add(t),e.filesSelectedPaths=s,s.size===1){const i=[...s][0];await Ml(e,i,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Cp(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let s=0,i="";for(const r of n)try{await Ll(e,r,t),s++}catch(o){i=Le(o)}i?e.filesMessage={kind:"error",text:`${s} downloaded, error: ${i}`}:dn(e,`${s} file${s!==1?"s":""} downloaded`)}async function _p(e,t,n,s){const i=t.split("/").pop()??t,r=n==="."?i:`${n}/${i}`;r!==t&&await Pl(e,t,r,s)}async function Ml(e,t,n){if(!(!e.client||!e.connected)){e.filesSelectedPath=t,e.filesPreviewLoading=!0,e.filesPreviewContent=null,e.filesPreviewBinary=!1,e.filesPreviewSize=null;try{const s={path:t};n&&(s.agentId=n);const i=await e.client.request("files.read",s);e.filesPreviewContent=(i==null?void 0:i.content)??null,e.filesPreviewBinary=(i==null?void 0:i.binary)??!1,e.filesPreviewSize=(i==null?void 0:i.size)??null}catch(s){e.filesError=Le(s)}finally{e.filesPreviewLoading=!1}}}async function Ll(e,t,n){if(!(!e.client||!e.connected))try{const s={path:t};n&&(s.agentId=n);const i=await e.client.request("files.download",s);if(!(i!=null&&i.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const r=Uint8Array.from(atob(i.base64),c=>c.charCodeAt(0)),o=new Blob([r]),a=URL.createObjectURL(o),l=document.createElement("a");l.href=a,l.download=i.name??t.split("/").pop()??"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)}catch(s){e.filesMessage={kind:"error",text:Le(s)}}}async function Mp(e,t,n,s){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let i=0,r="";for(const o of n)try{const a=await o.arrayBuffer(),l=btoa(new Uint8Array(a).reduce((u,p)=>u+String.fromCharCode(p),"")),c={path:t,name:o.name,data:l};s&&(c.agentId=s),await e.client.request("files.upload",c),i++}catch(a){r=Le(a)}e.filesUploadBusy=!1,r?e.filesMessage={kind:"error",text:i>0?`${i} uploaded, error: ${r}`:r}:dn(e,`${i} file${i!==1?"s":""} uploaded`),await pn(e,s)}async function Lp(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={path:t};n&&(s.agentId=n),await e.client.request("files.delete",s),dn(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await pn(e,n)}catch(s){e.filesMessage={kind:"error",text:Le(s)}}}}async function Pl(e,t,n,s){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={from:t,to:n};s&&(i.agentId=s),await e.client.request("files.move",i),dn(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await pn(e,s)}catch(i){e.filesMessage={kind:"error",text:Le(i)}}}}async function or(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const s=await e.client.request("memory.status",n);s!=null&&s.ok&&(e.filesMemoryStatus={dirty:s.dirty??!1,files:s.files??0,chunks:s.chunks??0})}catch{}}async function Pp(e,t){if(!(!e.client||!e.connected)&&!e.filesReindexBusy){e.filesReindexBusy=!0,e.filesMessage=null;try{const n={force:!0};t&&(n.agentId=t);const s=await e.client.request("memory.reindex",n),i=(s==null?void 0:s.files)??0,r=(s==null?void 0:s.chunks)??0;dn(e,`Re-indexed: ${i} files, ${r} chunks`),await or(e,t)}catch(n){e.filesMessage={kind:"error",text:Le(n)}}finally{e.filesReindexBusy=!1}}}function Rp(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n}async function Ip(e,t,n){if(!(!e.client||!e.connected)){if(!t.trim()){e.filesSearchResults=null;return}e.filesSearchLoading=!0,e.filesSearchResults=null;try{const s={query:t.trim(),maxResults:20};n&&(s.agentId=n);const i=await e.client.request("memory.search",s);e.filesSearchResults=(i==null?void 0:i.results)??[]}catch(s){e.filesMessage={kind:"error",text:Le(s)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Np(e){e.filesSearchQuery="",e.filesSearchResults=null}function Dp(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{ir(e,{quiet:!0})},5e3))}function Op(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function ar(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Jt(e,{quiet:!0})},2e3))}function lr(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function cr(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{e.tab!=="logs"||e.logsSubTab!=="session"||wt(e,{quiet:!0})},2e3))}function ur(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function dr(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&Xi(e)},3e3))}function pr(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Bp(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{_l(e)},3e4))}function Fp(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function Up(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{e.tab==="files"&&or(e)},1e4))}function Wp(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function Be(e,t){var s;const n={...t,lastActiveSessionKey:((s=t.lastActiveSessionKey)==null?void 0:s.trim())||t.sessionKey.trim()||"main"};e.settings=n,Ou(n),t.theme!==e.theme&&(e.theme=t.theme,vs(e,rr(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function Rl(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Be(e,{...e.settings,lastActiveSessionKey:n})}function Kp(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),s=t.get("password"),i=t.get("session"),r=t.get("gatewayUrl");let o=!1;if(n!=null){const l=n.trim();l&&l!==e.settings.token&&Be(e,{...e.settings,token:l}),t.delete("token"),o=!0}if(s!=null){const l=s.trim();l&&(e.password=l),t.delete("password"),o=!0}if(i!=null){const l=i.trim();l&&(e.sessionKey=l,Be(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(r!=null){const l=r.trim();l&&l!==e.settings.gatewayUrl&&Be(e,{...e.settings,gatewayUrl:l}),t.delete("gatewayUrl"),o=!0}if(!o)return;const a=new URL(window.location.href);a.search=t.toString(),window.history.replaceState({},"",a.toString())}function zp(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?cr(e):ar(e):(lr(e),ur(e)),t==="debug"?dr(e):pr(e),hr(e),Nl(e,t,!1)}function jp(e,t,n){Sp({nextTheme:t,applyTheme:()=>{e.theme=t,Be(e,{...e.settings,theme:t}),vs(e,rr(t))},context:n,currentTheme:e.theme})}async function hr(e){if(e.tab==="overview"&&await Dl(e),e.tab==="channels"&&await Xp(e),e.tab==="instances"&&await $l(e),e.tab==="cron"&&await fr(e),e.tab==="skills"&&await $t(e),e.tab==="nodes"&&(await ir(e),await sr(e),await xe(e),await pp(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await nh(e),cn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await il(e),await xe(e)),e.tab==="debug"&&(await Xi(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await pe(async()=>{const{loadSessionLogs:s}=await Promise.resolve().then(()=>Ap);return{loadSessionLogs:s}},void 0,import.meta.url);await n(e,{reset:!0})}else await Jt(e,{reset:!0});nl(e,!0)}}function Hp(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?ys(e):bp(window.location.pathname)}function qp(e){e.theme=e.settings.theme??"system",vs(e,rr(e.theme))}function vs(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Gp(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;if(e.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaHandler=n=>{e.theme==="system"&&vs(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Vp(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 Qp(e,t){if(typeof window>"u")return;const n=Cl(window.location.pathname,e.basePath)??"chat";Il(e,n),Nl(e,n,t)}function Yp(e){var i;if(typeof window>"u")return;const t=Cl(window.location.pathname,e.basePath);if(!t)return;const s=(i=new URL(window.location.href).searchParams.get("session"))==null?void 0:i.trim();s&&(e.sessionKey=s,Be(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s})),Il(e,t)}function Il(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?cr(e):ar(e):(lr(e),ur(e)),t==="debug"?dr(e):pr(e),e.connected&&hr(e)}function Nl(e,t,n){if(typeof window>"u")return;const s=ln(vp(t,e.basePath)),i=ln(window.location.pathname),r=new URL(window.location.href);t==="chat"&&e.sessionKey?r.searchParams.set("session",e.sessionKey):r.searchParams.delete("session"),i!==s&&(r.pathname=s),n?window.history.replaceState({},"",r.toString()):window.history.pushState({},"",r.toString())}async function Dl(e){await Promise.all([q(e,!1),$l(e),Vi(e),un(e),Xi(e)])}async function Xp(e){await Promise.all([q(e,!0),il(e),xe(e)])}async function fr(e){await Promise.all([q(e,!1),un(e),fs(e)])}function Ol(e){return e.chatSending||!!e.chatRunId}function Zp(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 Bl(e){e.connected&&(e.chatMessage="",await el(e))}function Jp(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);!s&&!i||(e.chatQueue=[...e.chatQueue,{id:Gi(),text:s,createdAt:Date.now(),attachments:i?n==null?void 0:n.map(r=>({...r})):void 0}],cn(e))}async function Fl(e,t,n){var i,r;Qi(e);const s=await Ja(e,t,n==null?void 0:n.attachments);return!s&&(n==null?void 0:n.previousDraft)!=null&&(e.chatMessage=n.previousDraft),!s&&(n!=null&&n.previousAttachments)&&(e.chatAttachments=n.previousAttachments),s&&Rl(e,e.sessionKey),s&&(n!=null&&n.restoreDraft)&&((i=n.previousDraft)!=null&&i.trim())&&(e.chatMessage=n.previousDraft),s&&(n!=null&&n.restoreAttachments)&&((r=n.previousAttachments)!=null&&r.length)&&(e.chatAttachments=n.previousAttachments),cn(e),s&&!e.chatRunId&&Ul(e),s}async function Ul(e){if(!e.connected||Ol(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await Fl(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function eh(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function th(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),r=e.chatAttachments??[],o=t==null?r:[],a=o.length>0;if(!(!i&&!a)){if(Zp(i)){await Bl(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),Ol(e)){Jp(e,i,o);return}await Fl(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:a?o:void 0,previousAttachments:t==null?r:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function nh(e){await Promise.all([Me(e),Vi(e),xi(e)]),cn(e,!0)}const sh=Ul;function ih(e){var i,r,o;const t=Ha(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(i=e.hello)==null?void 0:i.snapshot;return((o=(r=n==null?void 0:n.sessionDefaults)==null?void 0:r.defaultAgentId)==null?void 0:o.trim())||"main"}function rh(e,t){const n=ys(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function xi(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=ih(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=rh(e.basePath,t);try{const s=await fetch(n,{method:"GET"});if(!s.ok){e.chatAvatarUrl=null;return}const i=await s.json(),r=typeof i.avatarUrl=="string"?i.avatarUrl.trim():"";e.chatAvatarUrl=r||null}catch{e.chatAvatarUrl=null}}const O={messageSquare:h`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:h`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:h`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,radio:h`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:h`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:h`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:h`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:h`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:h`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:h`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:h`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,users:h`<svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,menu:h`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:h`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:h`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:h`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:h`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:h`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:h`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:h`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,rotateCw:h`<svg viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,download:h`<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wrench:h`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:h`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:h`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:h`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:h`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:h`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,image:h`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:h`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:h`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:h`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,puzzle:h`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`,info:h`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,send:h`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:h`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`,slidersHorizontal:h`<svg viewBox="0 0 24 24"><line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/></svg>`,square:h`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:h`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:h`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,trash:h`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,chevronDown:h`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:h`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`},oh="Taskmaster",ah="/taskmaster-icon.png",Wl="#00d4ff";let Pn=null;function We(){return Pn||(Pn={name:window.__TASKMASTER_BRAND_NAME__||oh,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||ah,accentColor:window.__TASKMASTER_ACCENT_COLOR__||Wl},Pn)}function lh(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 ch(e){if(e===Wl)return;const t=lh(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 uh=h`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,dh=h`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="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 Eo=!1;function ph(){Eo||(Eo=!0,document.addEventListener("click",e=>{const t=document.getElementById("nav-burger-toggle");if(!(t!=null&&t.checked))return;const n=t.closest(".setup-header");n!=null&&n.contains(e.target)||(t.checked=!1)}))}function at(e,t){const n=(u,p)=>u===e?h`<span class="sp-page-nav-current">${u}</span>`:h`<a href=${p}>${u}</a>`,s=h`
|
|
17
|
+
`],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),r=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`taskmaster-session-logs-${t}-${r}.log`,i.click(),URL.revokeObjectURL(s)}function Sd(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:s}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${s}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function Ue(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function et(e){return`${JSON.stringify(e,null,2).trimEnd()}
|
|
18
|
+
`}function ol(e,t,n){if(t.length===0)return;let s=e;for(let r=0;r<t.length-1;r+=1){const o=t[r],a=t[r+1];if(typeof o=="number"){if(!Array.isArray(s))return;s[o]==null&&(s[o]=typeof a=="number"?[]:{}),s=s[o]}else{if(typeof s!="object"||s==null)return;const l=s;l[o]==null&&(l[o]=typeof a=="number"?[]:{}),s=l[o]}}const i=t[t.length-1];if(typeof i=="number"){Array.isArray(s)&&(s[i]=n);return}typeof s=="object"&&s!=null&&(s[i]=n)}async function xe(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});Ad(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",{});xd(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function xd(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function Ad(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?et(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=et(e.configForm):e.configRaw=n,e.configValid=typeof t.valid=="boolean"?t.valid:null,e.configIssues=Array.isArray(t.issues)?t.issues:[],e.configFormDirty||(e.configForm=Ue(t.config??{}),e.configFormOriginal=Ue(t.config??{}),e.configRawOriginal=n)}async function $d(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?et(e.configForm):e.configRaw,s=(t=e.configSnapshot)==null?void 0:t.hash;if(!s){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:n,baseHash:s}),e.configFormDirty=!1,await xe(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function un(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 gs(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 Ed(e){if(e.scheduleKind==="at"){const n=Date.parse(e.scheduleAt);if(!Number.isFinite(n))throw new Error("Invalid run time.");return{kind:"at",atMs:n}}if(e.scheduleKind==="every"){const n=Xn(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const s=e.everyUnit;return{kind:"every",everyMs:n*(s==="minutes"?6e4:s==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function Td(e){if(e.payloadKind==="systemEvent"){const i=e.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel),e.to.trim()&&(n.to=e.to.trim());const s=Xn(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function Cd(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=Ed(e.cronForm),s=Td(e.cronForm),i=e.cronForm.agentId.trim(),r=(t=e.cronForm.accountId)==null?void 0:t.trim(),o={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:i||void 0,accountId:r||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:s,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!o.name)throw new Error("Name required.");await e.client.request("cron.add",o),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await gs(e),await un(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function _d(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 gs(e),await un(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function Md(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 bi(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function Ld(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 gs(e),await un(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function bi(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("cron.runs",{id:t,limit:50});e.cronRunsJobId=t,e.cronRuns=Array.isArray(n.entries)?n.entries:[]}catch(n){e.cronError=String(n)}}async function q(e,t){if(!(!e.client||!e.connected)&&!e.channelsLoading){e.channelsLoading=!0,e.channelsError=null;try{const n=await e.client.request("channels.status",{probe:t,timeoutMs:8e3});e.channelsSnapshot=n,e.channelsLastSuccess=Date.now()}catch(n){e.channelsError=String(n)}finally{e.channelsLoading=!1}}}async function Xi(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const s=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=s.message??null,e.whatsappLoginQrDataUrl=s.qrDataUrl??null,e.whatsappLoginConnected=null}catch(s){e.whatsappLoginMessage=String(s),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function ll(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 ul(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const s=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!s){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const r=Ue(i.config??{});(!r.channels||typeof r.channels!="object")&&(r.channels={});const o=r.channels;(!o.whatsapp||typeof o.whatsapp!="object")&&(o.whatsapp={});const a=o.whatsapp;(!a.accounts||typeof a.accounts!="object")&&(a.accounts={});const l=a.accounts;if(l[s]){e.whatsappAccountError=`Account "${s}" already exists.`;return}l[s]={name:n,provider:"baileys"};const c=i.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const u=et(r);await e.client.request("config.set",{raw:u,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await q(e,!0),await Xi(e,!0,s)}catch(i){e.whatsappAccountError=String(i)}finally{e.whatsappAccountSaving=!1}}async function dl(e,t){if(!(!e.client||!e.connected)&&!e.whatsappAccountSaving){e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const s=Ue(n.config??{}),i=s.channels,r=i==null?void 0:i.whatsapp,o=r==null?void 0:r.accounts;if(!o){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(o).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!o[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete o[t],Array.isArray(s.bindings)&&(s.bindings=s.bindings.filter(u=>{const p=u.match;return!p||p.channel!=="whatsapp"?!0:p.accountId!==t}));const l=n.hash;if(!l){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=et(s);await e.client.request("config.set",{raw:c,baseHash:l}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await q(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const Pd=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:ul,loadChannels:q,logoutWhatsApp:cl,removeWhatsAppAccount:dl,startWhatsAppLogin:Xi,waitWhatsAppLogin:ll},Symbol.toStringTag,{value:"Module"}));async function Zi(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,s,i]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const r=s;e.debugModels=Array.isArray(r==null?void 0:r.models)?r==null?void 0:r.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const Rd=2e3,Id=new Set(["trace","debug","info","warn","error","fatal"]);function Nd(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 Dd(e){if(typeof e!="string")return null;const t=e.toLowerCase();return Id.has(t)?t:null}function Od(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,s=typeof t.time=="string"?t.time:typeof(n==null?void 0:n.date)=="string"?n==null?void 0:n.date:null,i=Dd((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),r=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,o=Nd(r);let a=null;o&&(typeof o.subsystem=="string"?a=o.subsystem:typeof o.module=="string"&&(a=o.module)),!a&&r&&r.length<120&&(a=r);let l=null;return typeof t[1]=="string"?l=t[1]:!o&&typeof t[0]=="string"?l=t[0]:typeof t.message=="string"&&(l=t.message),{raw:e,time:s,level:i,subsystem:a,message:l??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Jt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const s=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),r=(Array.isArray(s.lines)?s.lines.filter(a=>typeof a=="string"):[]).map(Od),o=!!(t!=null&&t.reset||s.reset||e.logsCursor==null);e.logsEntries=o?r:[...e.logsEntries,...r].slice(-Rd),typeof s.cursor=="number"&&(e.logsCursor=s.cursor),typeof s.file=="string"&&(e.logsFile=s.file),e.logsTruncated=!!s.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const pl={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:se,n:zn,Gx:ko,Gy:So,a:Hs,d:qs,h:Bd}=pl,tt=32,Ji=64,Fd=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},Z=(e="")=>{const t=new Error(e);throw Fd(t,Z),t},Ud=e=>typeof e=="bigint",Wd=e=>typeof e=="string",Kd=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",Ke=(e,t,n="")=>{const s=Kd(e),i=e==null?void 0:e.length,r=t!==void 0;if(!s||r&&i!==t){const o=n&&`"${n}" `,a=r?` of length ${t}`:"",l=s?`length=${i}`:`type=${typeof e}`;Z(o+"expected Uint8Array"+a+", got "+l)}return e},ms=e=>new Uint8Array(e),hl=e=>Uint8Array.from(e),fl=(e,t)=>e.toString(16).padStart(t,"0"),gl=e=>Array.from(Ke(e)).map(t=>fl(t,2)).join(""),Te={_0:48,_9:57,A:65,F:70,a:97,f:102},xo=e=>{if(e>=Te._0&&e<=Te._9)return e-Te._0;if(e>=Te.A&&e<=Te.F)return e-(Te.A-10);if(e>=Te.a&&e<=Te.f)return e-(Te.a-10)},ml=e=>{const t="hex invalid";if(!Wd(e))return Z(t);const n=e.length,s=n/2;if(n%2)return Z(t);const i=ms(s);for(let r=0,o=0;r<s;r++,o+=2){const a=xo(e.charCodeAt(o)),l=xo(e.charCodeAt(o+1));if(a===void 0||l===void 0)return Z(t);i[r]=a*16+l}return i},yl=()=>globalThis==null?void 0:globalThis.crypto,zd=()=>{var e;return((e=yl())==null?void 0:e.subtle)??Z("crypto.subtle must be defined, consider polyfill")},an=(...e)=>{const t=ms(e.reduce((s,i)=>s+Ke(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},jd=(e=tt)=>yl().getRandomValues(ms(e)),Jn=BigInt,Qe=(e,t,n,s="bad number: out of range")=>Ud(e)&&t<=e&&e<n?e:Z(s),M=(e,t=se)=>{const n=e%t;return n>=0n?n:t+n},vl=e=>M(e,zn),Hd=(e,t)=>{(e===0n||t<=0n)&&Z("no inverse n="+e+" mod="+t);let n=M(e,t),s=t,i=0n,r=1n;for(;n!==0n;){const o=s/n,a=s%n,l=i-r*o;s=n,n=a,i=r,r=l}return s===1n?M(i,t):Z("no inverse")},qd=e=>{const t=Sl[e];return typeof t!="function"&&Z("hashes."+e+" not set"),t},Gs=e=>e instanceof nt?e:Z("Point expected"),wi=2n**256n,Se=class Se{constructor(t,n,s,i){B(this,"X");B(this,"Y");B(this,"Z");B(this,"T");const r=wi;this.X=Qe(t,0n,r),this.Y=Qe(n,0n,r),this.Z=Qe(s,1n,r),this.T=Qe(i,0n,r),Object.freeze(this)}static CURVE(){return pl}static fromAffine(t){return new Se(t.x,t.y,1n,M(t.x*t.y))}static fromBytes(t,n=!1){const s=qs,i=hl(Ke(t,tt)),r=t[31];i[31]=r&-129;const o=wl(i);Qe(o,0n,n?wi:se);const l=M(o*o),c=M(l-1n),u=M(s*l+1n);let{isValid:p,value:d}=Vd(c,u);p||Z("bad point: y not sqrt");const h=(d&1n)===1n,b=(r&128)!==0;return!n&&d===0n&&b&&Z("bad point: x==0, isLastByteOdd"),b!==h&&(d=M(-d)),new Se(d,o,1n,M(d*o))}static fromHex(t,n){return Se.fromBytes(ml(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Hs,n=qs,s=this;if(s.is0())return Z("bad point: ZERO");const{X:i,Y:r,Z:o,T:a}=s,l=M(i*i),c=M(r*r),u=M(o*o),p=M(u*u),d=M(l*t),h=M(u*M(d+c)),b=M(p+M(n*M(l*c)));if(h!==b)return Z("bad point: equation left != right (1)");const w=M(i*r),S=M(o*a);return w!==S?Z("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:r,Y:o,Z:a}=Gs(t),l=M(n*a),c=M(r*i),u=M(s*a),p=M(o*i);return l===c&&u===p}is0(){return this.equals(bt)}negate(){return new Se(M(-this.X),this.Y,this.Z,M(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=Hs,r=M(t*t),o=M(n*n),a=M(2n*M(s*s)),l=M(i*r),c=t+n,u=M(M(c*c)-r-o),p=l+o,d=p-a,h=l-o,b=M(u*d),w=M(p*h),S=M(u*h),T=M(d*p);return new Se(b,w,T,S)}add(t){const{X:n,Y:s,Z:i,T:r}=this,{X:o,Y:a,Z:l,T:c}=Gs(t),u=Hs,p=qs,d=M(n*o),h=M(s*a),b=M(r*p*c),w=M(i*l),S=M((n+s)*(o+a)-d-h),T=M(w-b),A=M(w+b),E=M(h-u*d),C=M(S*T),R=M(A*E),U=M(S*E),Q=M(T*A);return new Se(C,R,Q,U)}subtract(t){return this.add(Gs(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return bt;if(Qe(t,1n,zn),t===1n)return this;if(this.equals(st))return rp(t).p;let s=bt,i=st;for(let r=this;t>0n;r=r.double(),t>>=1n)t&1n?s=s.add(r):n&&(i=i.add(r));return s}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:s}=this;if(this.equals(bt))return{x:0n,y:1n};const i=Hd(s,se);M(s*i)!==1n&&Z("invalid inverse");const r=M(t*i),o=M(n*i);return{x:r,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=bl(n);return s[31]|=t&1n?128:0,s}toHex(){return gl(this.toBytes())}clearCofactor(){return this.multiply(Jn(Bd),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(zn/2n,!1).double();return zn%2n&&(t=t.add(this)),t.is0()}};B(Se,"BASE"),B(Se,"ZERO");let nt=Se;const st=new nt(ko,So,1n,M(ko*So)),bt=new nt(0n,1n,1n,0n);nt.BASE=st;nt.ZERO=bt;const bl=e=>ml(fl(Qe(e,0n,wi),Ji)).reverse(),wl=e=>Jn("0x"+gl(hl(Ke(e)).reverse())),be=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=se;return n},Gd=e=>{const n=e*e%se*e%se,s=be(n,2n)*n%se,i=be(s,1n)*e%se,r=be(i,5n)*i%se,o=be(r,10n)*r%se,a=be(o,20n)*o%se,l=be(a,40n)*a%se,c=be(l,80n)*l%se,u=be(c,80n)*l%se,p=be(u,10n)*r%se;return{pow_p_5_8:be(p,2n)*e%se,b2:n}},Ao=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Vd=(e,t)=>{const n=M(t*t*t),s=M(n*n*t),i=Gd(e*s).pow_p_5_8;let r=M(e*n*i);const o=M(t*r*r),a=r,l=M(r*Ao),c=o===e,u=o===M(-e),p=o===M(-e*Ao);return c&&(r=a),(u||p)&&(r=l),(M(r)&1n)===1n&&(r=M(-r)),{isValid:c||u,value:r}},ki=e=>vl(wl(e)),er=(...e)=>Sl.sha512Async(an(...e)),Qd=(...e)=>qd("sha512")(an(...e)),kl=e=>{const t=e.slice(0,tt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(tt,Ji),s=ki(t),i=st.multiply(s),r=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:r}},tr=e=>er(Ke(e,tt)).then(kl),Yd=e=>kl(Qd(Ke(e,tt))),Xd=e=>tr(e).then(t=>t.pointBytes),Zd=e=>er(e.hashable).then(e.finish),Jd=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,r=ki(t),o=st.multiply(r).toBytes();return{hashable:an(o,s,n),finish:c=>{const u=vl(r+ki(c)*i);return Ke(an(o,bl(u)),Ji)}}},ep=async(e,t)=>{const n=Ke(e),s=await tr(t),i=await er(s.prefix,n);return Zd(Jd(s,i,n))},Sl={sha512Async:async e=>{const t=zd(),n=an(e);return ms(await t.digest("SHA-512",n.buffer))},sha512:void 0},tp=(e=jd(tt))=>e,np={getExtendedPublicKeyAsync:tr,getExtendedPublicKey:Yd,randomSecretKey:tp},es=8,sp=256,xl=Math.ceil(sp/es)+1,Si=2**(es-1),ip=()=>{const e=[];let t=st,n=t;for(let s=0;s<xl;s++){n=t,e.push(n);for(let i=1;i<Si;i++)n=n.add(t),e.push(n);t=n.double()}return e};let $o;const Eo=(e,t)=>{const n=t.negate();return e?n:t},rp=e=>{const t=$o||($o=ip());let n=bt,s=st;const i=2**es,r=i,o=Jn(i-1),a=Jn(es);for(let l=0;l<xl;l++){let c=Number(e&o);e>>=a,c>Si&&(c-=r,e+=1n);const u=l*Si,p=u,d=u+Math.abs(c)-1,h=l%2!==0,b=c<0;c===0?s=s.add(Eo(h,t[p])):n=n.add(Eo(b,t[d]))}return e!==0n&&Z("invalid wnaf"),{p:n,f:s}},Vs="taskmaster-device-identity-v1";function xi(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Al(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),s=atob(n),i=new Uint8Array(s.length);for(let r=0;r<s.length;r+=1)i[r]=s.charCodeAt(r);return i}function op(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function $l(e){const t=await crypto.subtle.digest("SHA-256",e);return op(new Uint8Array(t))}async function ap(){const e=np.randomSecretKey(),t=await Xd(e);return{deviceId:await $l(t),publicKey:xi(t),privateKey:xi(e)}}async function lp(){try{const n=localStorage.getItem(Vs);if(n){const s=JSON.parse(n);if((s==null?void 0:s.version)===1&&typeof s.deviceId=="string"&&typeof s.publicKey=="string"&&typeof s.privateKey=="string"){const i=await $l(Al(s.publicKey));if(i!==s.deviceId){const r={...s,deviceId:i};return localStorage.setItem(Vs,JSON.stringify(r)),{deviceId:i,publicKey:s.publicKey,privateKey:s.privateKey}}return{deviceId:s.deviceId,publicKey:s.publicKey,privateKey:s.privateKey}}}}catch{}const e=await ap(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Vs,JSON.stringify(t)),e}async function cp(e,t){const n=Al(e),s=new TextEncoder().encode(t),i=await ep(s,n);return xi(i)}const El="taskmaster.device.auth.v1";function nr(e){return e.trim()}function up(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const s=n.trim();s&&t.add(s)}return[...t].sort()}function sr(){try{const e=window.localStorage.getItem(El);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 Tl(e){try{window.localStorage.setItem(El,JSON.stringify(e))}catch{}}function dp(e){const t=sr();if(!t||t.deviceId!==e.deviceId)return null;const n=nr(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function pp(e){const t=nr(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=sr();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:up(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,Tl(n),i}function hp(e){const t=sr();if(!t||t.deviceId!==e.deviceId)return;const n=nr(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],Tl(s)}async function ir(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 rr(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 fp(e){return{method:"exec.approvals.get",params:{}}}async function gp(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=fp(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);mp(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function mp(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=Ue(t.file??{}))}async function Cl(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 At(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function ys(e){return e instanceof Error?e.message:String(e)}async function $t(e,t){if(t!=null&&t.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{const n=await e.client.request("skills.status",{});n&&(e.skillsReport=n)}catch(n){e.skillsError=ys(n)}finally{e.skillsLoading=!1}}}function yp(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function vp(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,enabled:n}),await $t(e),At(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=ys(s);e.skillsError=i,At(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function bp(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const n=e.skillEdits[t]??"";await e.client.request("skills.update",{skillKey:t,apiKey:n}),await $t(e),At(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=ys(n);e.skillsError=s,At(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function wp(e,t,n,s){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.install",{name:n,installId:s,timeoutMs:12e4});await $t(e),At(e,t,{kind:"success",message:(i==null?void 0:i.message)??"Installed"})}catch(i){const r=ys(i);e.skillsError=r,At(e,t,{kind:"error",message:r})}finally{e.skillsBusyKey=null}}}const _l={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},Ml=new Map(Object.entries(_l).map(([e,t])=>[t,e]));function vs(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function ln(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 kp(e,t=""){const n=vs(t),s=_l[e];return n?`${n}${s}`:s}function Ll(e,t=""){const n=vs(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=ln(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":Ml.get(i)??null}function Sp(e){let t=ln(e);if(t.endsWith("/index.html")&&(t=ln(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let s=0;s<n.length;s++){const i=`/${n.slice(s).join("/")}`.toLowerCase();if(Ml.has(i)){const r=n.slice(0,s);return r.length?`/${r.join("/")}`:""}}return`/${n.join("/")}`}function xp(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function or(e){return e==="system"?xp():e}const _n=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,Ap=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Mn=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},$p=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{var c;if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const r=i.documentElement,o=i,a=Ap();if(!!o.startViewTransition&&!a){let u=.5,p=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")u=_n(n.pointerClientX/window.innerWidth),p=_n(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const d=n.element.getBoundingClientRect();d.width>0&&d.height>0&&typeof window<"u"&&(u=_n((d.left+d.width/2)/window.innerWidth),p=_n((d.top+d.height/2)/window.innerHeight))}r.style.setProperty("--theme-switch-x",`${u*100}%`),r.style.setProperty("--theme-switch-y",`${p*100}%`),r.classList.add("theme-transition");try{const d=(c=o.startViewTransition)==null?void 0:c.call(o,()=>{t()});d!=null&&d.finished?d.finished.finally(()=>Mn(r)):Mn(r)}catch{Mn(r),t()}return}t(),Mn(r)},Ep=2e3;async function wt(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const s=await e.client.request("sessions.transcript",{cursors:t!=null&&t.reset?void 0:e.sessionLogsCursors,limit:200,maxBytesPerFile:e.sessionLogsFull?25e4:5e4,...e.sessionLogsFull?{full:!0}:{}}),i=Array.isArray(s.entries)?s.entries:[],r=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=r?i:[...e.sessionLogsEntries,...i].slice(-Ep),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 Tp=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:wt},Symbol.toStringTag,{value:"Module"}));async function Pl(e,t){if(!(!e.client||!e.connected))try{const n={},s=await e.client.request("memory.audit",n);s!=null&&s.ok&&(e.auditEntries=s.entries??[])}catch{}}async function Cp(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function Le(e){return e instanceof Error?e.message:String(e)}let Ln=null;function dn(e,t){Ln&&clearTimeout(Ln),e.filesMessage={kind:"success",text:t},Ln=setTimeout(()=>{e.filesMessage=null,Ln=null},3e3)}async function pn(e,t){if(!(!e.client||!e.connected)){if(!t){e.filesTree=[],e.filesRoot="";return}if(!e.filesLoading){e.filesLoading=!0,e.filesError=null;try{const n={};t&&(n.agentId=t);const s=await e.client.request("files.tree",n);s!=null&&s.tree&&(e.filesTree=s.tree,e.filesRoot=s.root??"")}catch(n){e.filesError=Le(n)}finally{e.filesLoading=!1}}}}async function _p(e,t,n){e.filesSelectedPaths=new Set([t]),await Rl(e,t,n)}async function Mp(e,t,n){const s=new Set(e.filesSelectedPaths);if(s.has(t)?s.delete(t):s.add(t),e.filesSelectedPaths=s,s.size===1){const i=[...s][0];await Rl(e,i,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Lp(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let s=0,i="";for(const r of n)try{await Il(e,r,t),s++}catch(o){i=Le(o)}i?e.filesMessage={kind:"error",text:`${s} downloaded, error: ${i}`}:dn(e,`${s} file${s!==1?"s":""} downloaded`)}async function Pp(e,t,n,s){const i=t.split("/").pop()??t,r=n==="."?i:`${n}/${i}`;r!==t&&await Nl(e,t,r,s)}async function Rl(e,t,n){if(!(!e.client||!e.connected)){e.filesSelectedPath=t,e.filesPreviewLoading=!0,e.filesPreviewContent=null,e.filesPreviewBinary=!1,e.filesPreviewSize=null;try{const s={path:t};n&&(s.agentId=n);const i=await e.client.request("files.read",s);e.filesPreviewContent=(i==null?void 0:i.content)??null,e.filesPreviewBinary=(i==null?void 0:i.binary)??!1,e.filesPreviewSize=(i==null?void 0:i.size)??null}catch(s){e.filesError=Le(s)}finally{e.filesPreviewLoading=!1}}}async function Il(e,t,n){if(!(!e.client||!e.connected))try{const s={path:t};n&&(s.agentId=n);const i=await e.client.request("files.download",s);if(!(i!=null&&i.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const r=Uint8Array.from(atob(i.base64),c=>c.charCodeAt(0)),o=new Blob([r]),a=URL.createObjectURL(o),l=document.createElement("a");l.href=a,l.download=i.name??t.split("/").pop()??"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)}catch(s){e.filesMessage={kind:"error",text:Le(s)}}}async function Rp(e,t,n,s){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let i=0,r="";for(const o of n)try{const a=await o.arrayBuffer(),l=btoa(new Uint8Array(a).reduce((u,p)=>u+String.fromCharCode(p),"")),c={path:t,name:o.name,data:l};s&&(c.agentId=s),await e.client.request("files.upload",c),i++}catch(a){r=Le(a)}e.filesUploadBusy=!1,r?e.filesMessage={kind:"error",text:i>0?`${i} uploaded, error: ${r}`:r}:dn(e,`${i} file${i!==1?"s":""} uploaded`),await pn(e,s)}async function Ip(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={path:t};n&&(s.agentId=n),await e.client.request("files.delete",s),dn(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await pn(e,n)}catch(s){e.filesMessage={kind:"error",text:Le(s)}}}}async function Nl(e,t,n,s){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={from:t,to:n};s&&(i.agentId=s),await e.client.request("files.move",i),dn(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await pn(e,s)}catch(i){e.filesMessage={kind:"error",text:Le(i)}}}}async function ar(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const s=await e.client.request("memory.status",n);s!=null&&s.ok&&(e.filesMemoryStatus={dirty:s.dirty??!1,files:s.files??0,chunks:s.chunks??0})}catch{}}async function Np(e,t){if(!(!e.client||!e.connected)&&!e.filesReindexBusy){e.filesReindexBusy=!0,e.filesMessage=null;try{const n={force:!0};t&&(n.agentId=t);const s=await e.client.request("memory.reindex",n),i=(s==null?void 0:s.files)??0,r=(s==null?void 0:s.chunks)??0;dn(e,`Re-indexed: ${i} files, ${r} chunks`),await ar(e,t)}catch(n){e.filesMessage={kind:"error",text:Le(n)}}finally{e.filesReindexBusy=!1}}}function Dp(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n}async function Op(e,t,n){if(!(!e.client||!e.connected)){if(!t.trim()){e.filesSearchResults=null;return}e.filesSearchLoading=!0,e.filesSearchResults=null;try{const s={query:t.trim(),maxResults:20};n&&(s.agentId=n);const i=await e.client.request("memory.search",s);e.filesSearchResults=(i==null?void 0:i.results)??[]}catch(s){e.filesMessage={kind:"error",text:Le(s)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Bp(e){e.filesSearchQuery="",e.filesSearchResults=null}function Fp(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{rr(e,{quiet:!0})},5e3))}function Up(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function lr(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Jt(e,{quiet:!0})},2e3))}function cr(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function ur(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{e.tab!=="logs"||e.logsSubTab!=="session"||wt(e,{quiet:!0})},2e3))}function dr(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function pr(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&Zi(e)},3e3))}function hr(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Wp(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{Pl(e)},3e4))}function Kp(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function zp(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{e.tab==="files"&&ar(e)},1e4))}function jp(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function Be(e,t){var s;const n={...t,lastActiveSessionKey:((s=t.lastActiveSessionKey)==null?void 0:s.trim())||t.sessionKey.trim()||"main"};e.settings=n,Uu(n),t.theme!==e.theme&&(e.theme=t.theme,bs(e,or(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function Dl(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Be(e,{...e.settings,lastActiveSessionKey:n})}function Hp(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),s=t.get("password"),i=t.get("session"),r=t.get("gatewayUrl");let o=!1;if(n!=null){const l=n.trim();l&&l!==e.settings.token&&Be(e,{...e.settings,token:l}),t.delete("token"),o=!0}if(s!=null){const l=s.trim();l&&(e.password=l),t.delete("password"),o=!0}if(i!=null){const l=i.trim();l&&(e.sessionKey=l,Be(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(r!=null){const l=r.trim();l&&l!==e.settings.gatewayUrl&&Be(e,{...e.settings,gatewayUrl:l}),t.delete("gatewayUrl"),o=!0}if(!o)return;const a=new URL(window.location.href);a.search=t.toString(),window.history.replaceState({},"",a.toString())}function qp(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ur(e):lr(e):(cr(e),dr(e)),t==="debug"?pr(e):hr(e),ts(e),Bl(e,t,!1)}function Gp(e,t,n){$p({nextTheme:t,applyTheme:()=>{e.theme=t,Be(e,{...e.settings,theme:t}),bs(e,or(t))},context:n,currentTheme:e.theme})}async function ts(e){if(e.tab==="overview"&&await Fl(e),e.tab==="channels"&&await eh(e),e.tab==="instances"&&await Cl(e),e.tab==="cron"&&await fr(e),e.tab==="skills"&&await $t(e),e.tab==="nodes"&&(await rr(e),await ir(e),await xe(e),await gp(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await rh(e),cn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await al(e),await xe(e)),e.tab==="debug"&&(await Zi(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await pe(async()=>{const{loadSessionLogs:s}=await Promise.resolve().then(()=>Tp);return{loadSessionLogs:s}},void 0,import.meta.url);await n(e,{reset:!0})}else await Jt(e,{reset:!0});rl(e,!0)}}function Vp(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?vs(e):Sp(window.location.pathname)}function Qp(e){e.theme=e.settings.theme??"system",bs(e,or(e.theme))}function bs(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Yp(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"&&bs(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Xp(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 Zp(e,t){if(typeof window>"u")return;const n=Ll(window.location.pathname,e.basePath)??"chat";Ol(e,n),Bl(e,n,t)}function Jp(e){var i;if(typeof window>"u")return;const t=Ll(window.location.pathname,e.basePath);if(!t)return;const s=(i=new URL(window.location.href).searchParams.get("session"))==null?void 0:i.trim();s&&(e.sessionKey=s,Be(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s})),Ol(e,t)}function Ol(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ur(e):lr(e):(cr(e),dr(e)),t==="debug"?pr(e):hr(e),e.connected&&ts(e)}function Bl(e,t,n){if(typeof window>"u")return;const s=ln(kp(t,e.basePath)),i=ln(window.location.pathname),r=new URL(window.location.href);t==="chat"&&e.sessionKey?r.searchParams.set("session",e.sessionKey):r.searchParams.delete("session"),i!==s&&(r.pathname=s),n?window.history.replaceState({},"",r.toString()):window.history.pushState({},"",r.toString())}async function Fl(e){await Promise.all([q(e,!1),Cl(e),Qi(e),un(e),Zi(e)])}async function eh(e){await Promise.all([q(e,!0),al(e),xe(e)])}async function fr(e){await Promise.all([q(e,!1),un(e),gs(e)])}function Ul(e){return e.chatSending||!!e.chatRunId}function th(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 Wl(e){e.connected&&(e.chatMessage="",await sl(e))}function nh(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);!s&&!i||(e.chatQueue=[...e.chatQueue,{id:Vi(),text:s,createdAt:Date.now(),attachments:i?n==null?void 0:n.map(r=>({...r})):void 0}],cn(e))}async function Kl(e,t,n){var i,r;Yi(e);const s=await nl(e,t,n==null?void 0:n.attachments);return!s&&(n==null?void 0:n.previousDraft)!=null&&(e.chatMessage=n.previousDraft),!s&&(n!=null&&n.previousAttachments)&&(e.chatAttachments=n.previousAttachments),s&&Dl(e,e.sessionKey),s&&(n!=null&&n.restoreDraft)&&((i=n.previousDraft)!=null&&i.trim())&&(e.chatMessage=n.previousDraft),s&&(n!=null&&n.restoreAttachments)&&((r=n.previousAttachments)!=null&&r.length)&&(e.chatAttachments=n.previousAttachments),cn(e),s&&!e.chatRunId&&zl(e),s}async function zl(e){if(!e.connected||Ul(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await Kl(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function sh(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function ih(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),r=e.chatAttachments??[],o=t==null?r:[],a=o.length>0;if(!(!i&&!a)){if(th(i)){await Wl(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),Ul(e)){nh(e,i,o);return}await Kl(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:a?o:void 0,previousAttachments:t==null?r:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function rh(e){await Promise.all([Me(e),Qi(e),Ai(e)]),cn(e,!0)}const oh=zl;function ah(e){var i,r,o;const t=Va(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(i=e.hello)==null?void 0:i.snapshot;return((o=(r=n==null?void 0:n.sessionDefaults)==null?void 0:r.defaultAgentId)==null?void 0:o.trim())||"main"}function lh(e,t){const n=vs(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function Ai(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=ah(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=lh(e.basePath,t);try{const s=await fetch(n,{method:"GET"});if(!s.ok){e.chatAvatarUrl=null;return}const i=await s.json(),r=typeof i.avatarUrl=="string"?i.avatarUrl.trim():"";e.chatAvatarUrl=r||null}catch{e.chatAvatarUrl=null}}const O={messageSquare:f`<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:f`<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:f`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,radio:f`<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:f`<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:f`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:f`<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:f`<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:f`<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:f`<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:f`<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:f`<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:f`<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:f`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:f`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:f`<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:f`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:f`<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:f`<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:f`<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:f`<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:f`<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:f`<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:f`<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:f`<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:f`<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:f`<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:f`<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:f`<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:f`<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:f`<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:f`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,puzzle:f`<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:f`<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:f`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:f`<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:f`<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:f`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:f`<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:f`<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:f`<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:f`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:f`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`},ch="Taskmaster",uh="/taskmaster-icon.png",jl="#00d4ff";let Pn=null;function We(){return Pn||(Pn={name:window.__TASKMASTER_BRAND_NAME__||ch,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||uh,accentColor:window.__TASKMASTER_ACCENT_COLOR__||jl},Pn)}function dh(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 ph(e){if(e===jl)return;const t=dh(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 hh=f`<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>`,fh=f`<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 To=!1;function gh(){To||(To=!0,document.addEventListener("click",e=>{const t=document.getElementById("nav-burger-toggle");if(!(t!=null&&t.checked))return;const n=t.closest(".setup-header");n!=null&&n.contains(e.target)||(t.checked=!1)}))}function at(e,t){const n=(u,p)=>u===e?f`<span class="sp-page-nav-current">${u}</span>`:f`<a href=${p}>${u}</a>`,s=f`
|
|
19
19
|
${n("Setup","/setup")}
|
|
20
20
|
${n("Chat","/chat")}
|
|
21
21
|
${n("Admins","/admins")}
|
|
@@ -23,10 +23,10 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
23
23
|
${n("Files","/files")}
|
|
24
24
|
${n("Browser","/browser")}
|
|
25
25
|
${n("Advanced","/advanced")}
|
|
26
|
-
`,r=t&&(t.isMaster!==!1||!t.hasPins)?
|
|
27
|
-
${
|
|
26
|
+
`,r=t&&(t.isMaster!==!1||!t.hasPins)?mh(t):k,o=t!=null&&t.hasPins&&t.onLogout?f`<button class="nav-logout-btn" @click=${t.onLogout} title="Lock">${hh}</button>`:k,a=(t==null?void 0:t.auditCount)??0,l=a>0&&(t!=null&&t.onAuditClick)?f`<button class="nav-audit-btn" @click=${t.onAuditClick} title="Memory writes to review">
|
|
27
|
+
${fh}
|
|
28
28
|
<span class="nav-audit-badge">${a>99?"99+":a}</span>
|
|
29
|
-
</button>`:k,c=()=>{const u=document.getElementById("nav-burger-toggle");u&&(u.checked=!1)};return
|
|
29
|
+
</button>`:k,c=()=>{const u=document.getElementById("nav-burger-toggle");u&&(u.checked=!1)};return gh(),f`
|
|
30
30
|
<div class="setup-header">
|
|
31
31
|
<input type="checkbox" id="nav-burger-toggle" class="nav-burger-checkbox" />
|
|
32
32
|
<div class="setup-header-inner">
|
|
@@ -35,7 +35,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
35
35
|
${s}
|
|
36
36
|
</nav>
|
|
37
37
|
<div class="setup-header-right">
|
|
38
|
-
${r!==k?
|
|
38
|
+
${r!==k?f`<span class="nav-selector-inline">${r}</span>`:k}
|
|
39
39
|
${l}
|
|
40
40
|
${o}
|
|
41
41
|
<label for="nav-burger-toggle" class="nav-burger-button" aria-label="Toggle menu">
|
|
@@ -44,17 +44,17 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
44
44
|
</div>
|
|
45
45
|
</div>
|
|
46
46
|
<nav class="setup-header-dropdown" @click=${c}>
|
|
47
|
-
${r!==k?
|
|
47
|
+
${r!==k?f`<div class="nav-selector-mobile">${r}</div>`:k}
|
|
48
48
|
${s}
|
|
49
49
|
</nav>
|
|
50
50
|
</div>
|
|
51
|
-
`}function
|
|
51
|
+
`}function mh(e){const{workspaces:t,selectedWorkspace:n,onWorkspaceSelect:s}=e;return f`
|
|
52
52
|
<select
|
|
53
53
|
class="sp-workspace-selector"
|
|
54
54
|
.value=${n??""}
|
|
55
55
|
@change=${r=>{const o=r.target,a=o.value;if(a==="__add__"){o.value=n??"",e.onAddAccount?e.onAddAccount():window.location.href="/setup";return}s(a)}}
|
|
56
56
|
>
|
|
57
|
-
${t.map(r=>
|
|
57
|
+
${t.map(r=>f`
|
|
58
58
|
<option value=${r.name} ?selected=${r.name===n}>
|
|
59
59
|
${r.displayName??r.name}
|
|
60
60
|
</option>
|
|
@@ -62,7 +62,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
62
62
|
<option disabled>───</option>
|
|
63
63
|
<option value="__add__">+ Add Account</option>
|
|
64
64
|
</select>
|
|
65
|
-
`}function
|
|
65
|
+
`}function yh(e){return e.connected?e.fullscreen&&e.active?f`
|
|
66
66
|
<div class="sp-fullscreen-overlay">
|
|
67
67
|
<div class="sp-fullscreen-toolbar">
|
|
68
68
|
<button
|
|
@@ -102,7 +102,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
102
102
|
></canvas>
|
|
103
103
|
</div>
|
|
104
104
|
</div>
|
|
105
|
-
`:
|
|
105
|
+
`:f`
|
|
106
106
|
<div class="setup-container">
|
|
107
107
|
${at("Browser")}
|
|
108
108
|
<div class="setup-card sp-card-wide">
|
|
@@ -110,7 +110,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
110
110
|
<p style="margin-bottom: 16px;">Live view of the headless Chrome instance.</p>
|
|
111
111
|
|
|
112
112
|
<div class="sp-toolbar">
|
|
113
|
-
${e.active?
|
|
113
|
+
${e.active?f`
|
|
114
114
|
<button
|
|
115
115
|
class="setup-button ${e.inputMode?"primary":"secondary"}"
|
|
116
116
|
style="padding: 10px 20px; font-size: 14px;"
|
|
@@ -133,7 +133,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
133
133
|
>
|
|
134
134
|
Stop
|
|
135
135
|
</button>
|
|
136
|
-
`:
|
|
136
|
+
`:f`
|
|
137
137
|
<button
|
|
138
138
|
class="setup-button primary"
|
|
139
139
|
style="padding: 10px 20px; font-size: 14px;"
|
|
@@ -145,9 +145,9 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
145
145
|
`}
|
|
146
146
|
</div>
|
|
147
147
|
|
|
148
|
-
${e.error?
|
|
148
|
+
${e.error?f`<div class="setup-error" style="margin-top: 16px;">${e.error}</div>`:k}
|
|
149
149
|
|
|
150
|
-
${e.handoffPending?
|
|
150
|
+
${e.handoffPending?f`
|
|
151
151
|
<div class="setup-warning" style="margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left;">
|
|
152
152
|
<div>
|
|
153
153
|
<strong>Action required:</strong> ${e.handoffReason??"The agent needs you to complete an action in the browser."}
|
|
@@ -159,7 +159,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
159
159
|
`:k}
|
|
160
160
|
|
|
161
161
|
<div class="sp-canvas-area" style="margin-top: 16px;">
|
|
162
|
-
${e.active?
|
|
162
|
+
${e.active?f`
|
|
163
163
|
<div class="sp-canvas-wrap ${e.inputMode?"sp-input-active":""}">
|
|
164
164
|
<canvas
|
|
165
165
|
id="browser-screencast-canvas"
|
|
@@ -173,7 +173,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
173
173
|
@contextmenu=${t=>t.preventDefault()}
|
|
174
174
|
></canvas>
|
|
175
175
|
</div>
|
|
176
|
-
`:
|
|
176
|
+
`:f`
|
|
177
177
|
<div class="sp-canvas-placeholder">
|
|
178
178
|
<div class="sp-canvas-placeholder-icon">${O.globe}</div>
|
|
179
179
|
<p>Click Start to begin streaming the Chrome viewport.</p>
|
|
@@ -181,46 +181,46 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
181
181
|
`}
|
|
182
182
|
</div>
|
|
183
183
|
|
|
184
|
-
${e.active&&e.inputMode?
|
|
184
|
+
${e.active&&e.inputMode?f`<p class="setup-hint" style="margin-top: 12px;">
|
|
185
185
|
Click the canvas to focus, then interact with the browser. Mouse and keyboard input are forwarded.
|
|
186
186
|
</p>`:k}
|
|
187
187
|
|
|
188
188
|
</div>
|
|
189
189
|
</div>
|
|
190
|
-
`:
|
|
190
|
+
`:f`
|
|
191
191
|
<div class="setup-container">
|
|
192
192
|
<div class="setup-card">
|
|
193
193
|
<div class="setup-spinner"></div>
|
|
194
194
|
<p>Connecting to gateway...</p>
|
|
195
195
|
</div>
|
|
196
196
|
</div>
|
|
197
|
-
`}const
|
|
197
|
+
`}const ns="application/x-taskmaster-file-path";function gr(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Hl(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function vh(e,t,n){var r,o;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const s=(r=e.dataTransfer)==null?void 0:r.getData(ns);if(s){Hl(s)!==t&&n.onMoveToDir(s,t);return}const i=(o=e.dataTransfer)==null?void 0:o.files;if(i&&i.length>0){const a=Array.from(i).filter(l=>l.name.toLowerCase().endsWith(".md"));a.length>0&&n.onUpload(t,a)}}function ql(e,t,n){const s=e.type==="directory"||e.type==="symlink"&&e.children!=null,i=t.expandedDirs.has(e.path),r=t.selectedPaths.has(e.path),o=n*20+12;return s?f`
|
|
198
198
|
<div
|
|
199
199
|
class="sp-tree-item sp-tree-dir ${i?"expanded":""}"
|
|
200
200
|
style="padding-left: ${o}px;"
|
|
201
201
|
@click=${()=>t.onToggleDir(e.path)}
|
|
202
202
|
@dragover=${a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&(a.dataTransfer.dropEffect="move"),a.currentTarget.classList.add("sp-drop-target")}}
|
|
203
203
|
@dragleave=${a=>{a.currentTarget.classList.remove("sp-drop-target")}}
|
|
204
|
-
@drop=${a=>
|
|
204
|
+
@drop=${a=>vh(a,e.path,t)}
|
|
205
205
|
>
|
|
206
206
|
<span class="sp-tree-chevron">${i?"−":"+"}</span>
|
|
207
207
|
<span class="sp-tree-icon">${O.folder}</span>
|
|
208
208
|
<span class="sp-tree-name">${e.name}</span>
|
|
209
209
|
</div>
|
|
210
|
-
${i&&e.children?e.children.map(a=>
|
|
211
|
-
`:
|
|
210
|
+
${i&&e.children?e.children.map(a=>ql(a,t,n+1)):k}
|
|
211
|
+
`:f`
|
|
212
212
|
<div
|
|
213
213
|
class="sp-tree-item sp-tree-file ${r?"selected":""}"
|
|
214
214
|
style="padding-left: ${o}px;"
|
|
215
215
|
draggable="true"
|
|
216
216
|
@click=${a=>{a.metaKey||a.ctrlKey?t.onToggleSelectFile(e.path):t.onSelectFile(e.path)}}
|
|
217
|
-
@dragstart=${a=>{a.dataTransfer&&(a.dataTransfer.effectAllowed="move",a.dataTransfer.setData(
|
|
217
|
+
@dragstart=${a=>{a.dataTransfer&&(a.dataTransfer.effectAllowed="move",a.dataTransfer.setData(ns,e.path),a.dataTransfer.setData("text/plain",e.name))}}
|
|
218
218
|
>
|
|
219
219
|
<span class="sp-tree-icon">${O.fileText}</span>
|
|
220
220
|
<span class="sp-tree-name">${e.name}</span>
|
|
221
221
|
<span class="sp-tree-size">${gr(e.size)}</span>
|
|
222
222
|
</div>
|
|
223
|
-
`}function
|
|
223
|
+
`}function bh(e){const t=e.selectedPaths.size;return t<2?k:f`
|
|
224
224
|
<div class="sp-bulk-actions">
|
|
225
225
|
<span style="color: var(--tasker-muted-grey); font-size: 13px;">${t} files selected</span>
|
|
226
226
|
<button
|
|
@@ -231,11 +231,11 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
231
231
|
Download ${t} files
|
|
232
232
|
</button>
|
|
233
233
|
</div>
|
|
234
|
-
`}function
|
|
234
|
+
`}function wh(e){if(e.selectedPaths.size!==1||!e.selectedPath)return k;if(e.previewLoading)return f`
|
|
235
235
|
<div class="sp-file-preview">
|
|
236
236
|
<div class="setup-spinner" style="width: 32px; height: 32px; margin: 24px auto;"></div>
|
|
237
237
|
</div>
|
|
238
|
-
`;const t=e.selectedPath.split("/").pop()??e.selectedPath;return
|
|
238
|
+
`;const t=e.selectedPath.split("/").pop()??e.selectedPath;return f`
|
|
239
239
|
<div class="sp-file-preview">
|
|
240
240
|
<div class="sp-file-preview-header">
|
|
241
241
|
<div>
|
|
@@ -256,9 +256,9 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
256
256
|
</button>
|
|
257
257
|
</div>
|
|
258
258
|
</div>
|
|
259
|
-
${e.previewBinary?
|
|
259
|
+
${e.previewBinary?f`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">Binary file — use Download to view.</p></div>`:e.previewContent!=null?f`<div class="sp-file-preview-body"><pre class="sp-file-code">${e.previewContent}</pre></div>`:f`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">File too large for preview — use Download.</p></div>`}
|
|
260
260
|
</div>
|
|
261
|
-
`}function
|
|
261
|
+
`}function kh(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 Gl(e){let t=0,n=0;for(const s of e)if(s.children){const i=Gl(s.children);t+=i.count,n+=i.bytes}else t++,n+=s.size??0;return{count:t,bytes:n}}function Sh(e){return f`
|
|
262
262
|
<div class="sp-search-bar">
|
|
263
263
|
<input
|
|
264
264
|
type="text"
|
|
@@ -268,11 +268,11 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
268
268
|
@input=${t=>e.onSearchQueryChange(t.target.value)}
|
|
269
269
|
@keydown=${t=>{t.key==="Enter"&&e.onSearch(e.searchQuery)}}
|
|
270
270
|
/>
|
|
271
|
-
${e.agentIds.length>1?
|
|
271
|
+
${e.agentIds.length>1?f`<select
|
|
272
272
|
class="sp-search-agent-select"
|
|
273
273
|
@change=${t=>e.onSearchAgentChange(t.target.value)}
|
|
274
274
|
>
|
|
275
|
-
${e.agentIds.map(t=>
|
|
275
|
+
${e.agentIds.map(t=>f`<option value=${t} ?selected=${t===e.searchAgentId}>${t}</option>`)}
|
|
276
276
|
</select>`:k}
|
|
277
277
|
<button
|
|
278
278
|
class="setup-button secondary"
|
|
@@ -282,7 +282,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
282
282
|
>
|
|
283
283
|
${e.searchLoading?"Searching...":"Search"}
|
|
284
284
|
</button>
|
|
285
|
-
${e.searchResults!==null?
|
|
285
|
+
${e.searchResults!==null?f`<button
|
|
286
286
|
class="setup-button secondary"
|
|
287
287
|
style="padding: 8px 16px; font-size: 13px;"
|
|
288
288
|
@click=${e.onSearchClear}
|
|
@@ -290,11 +290,11 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
290
290
|
Clear
|
|
291
291
|
</button>`:k}
|
|
292
292
|
</div>
|
|
293
|
-
`}function
|
|
293
|
+
`}function xh(e){return e.searchResults?e.searchResults.length===0?f`<div class="sp-search-results">
|
|
294
294
|
<div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No results found.</div>
|
|
295
|
-
</div>`:
|
|
295
|
+
</div>`:f`
|
|
296
296
|
<div class="sp-search-results">
|
|
297
|
-
${e.searchResults.map(t=>
|
|
297
|
+
${e.searchResults.map(t=>f`
|
|
298
298
|
<div
|
|
299
299
|
class="sp-search-result ${e.selectedPath===t.path?"selected":""}"
|
|
300
300
|
@click=${()=>e.onSelectFile(t.path)}
|
|
@@ -310,7 +310,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
310
310
|
</div>
|
|
311
311
|
`)}
|
|
312
312
|
</div>
|
|
313
|
-
`:k}function
|
|
313
|
+
`:k}function Ah(e){const t=kh(e);return e.connected?f`
|
|
314
314
|
<div class="setup-container">
|
|
315
315
|
${at("Files",e.wsProps)}
|
|
316
316
|
<div class="setup-card sp-card-wide">
|
|
@@ -344,50 +344,50 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
344
344
|
>
|
|
345
345
|
${e.reindexBusy?"Re-indexing...":"Re-index"}
|
|
346
346
|
</button>
|
|
347
|
-
${e.memoryStatus?
|
|
347
|
+
${e.memoryStatus?f`<span style="display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--tasker-text-grey);">
|
|
348
348
|
<span
|
|
349
349
|
class="setup-status-light"
|
|
350
350
|
style="width: 10px; height: 10px; background: ${e.memoryStatus.dirty?"#ef4444":"#22c55e"}"
|
|
351
351
|
></span>
|
|
352
|
-
${(()=>{const n=
|
|
352
|
+
${(()=>{const n=Gl(e.tree);return`${n.count} file${n.count!==1?"s":""}, ${gr(n.bytes)}`})()}
|
|
353
353
|
</span>`:k}
|
|
354
354
|
</div>
|
|
355
355
|
|
|
356
|
-
${e.error?
|
|
356
|
+
${e.error?f`<div class="setup-error" style="margin-top: 16px;">${e.error}</div>`:k}
|
|
357
357
|
|
|
358
|
-
${e.message?
|
|
358
|
+
${e.message?f`<div class="${e.message.kind==="error"?"setup-error":"setup-success-message"}" style="margin-top: 12px;">
|
|
359
359
|
${e.message.text}
|
|
360
360
|
</div>`:k}
|
|
361
361
|
|
|
362
|
-
${e.uploadBusy?
|
|
362
|
+
${e.uploadBusy?f`<div style="margin-top: 12px; color: var(--tasker-orange); font-weight: 600; font-size: 14px;">Uploading...</div>`:k}
|
|
363
363
|
|
|
364
|
-
${
|
|
364
|
+
${Sh(e)}
|
|
365
365
|
|
|
366
|
-
${e.searchResults!==null?
|
|
366
|
+
${e.searchResults!==null?xh(e):f`<div
|
|
367
367
|
class="sp-file-tree"
|
|
368
|
-
@dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(
|
|
369
|
-
@drop=${n=>{var r,o;n.preventDefault();const s=(r=n.dataTransfer)==null?void 0:r.getData(
|
|
368
|
+
@dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(ns)?"move":"copy")}}
|
|
369
|
+
@drop=${n=>{var r,o;n.preventDefault();const s=(r=n.dataTransfer)==null?void 0:r.getData(ns);if(s){Hl(s)!=="."&&e.onMoveToDir(s,".");return}const i=(o=n.dataTransfer)==null?void 0:o.files;if(i&&i.length>0){const a=Array.from(i).filter(l=>l.name.toLowerCase().endsWith(".md"));a.length>0&&e.onUpload(t,a)}}}
|
|
370
370
|
>
|
|
371
|
-
${e.tree.length===0&&!e.loading?
|
|
371
|
+
${e.tree.length===0&&!e.loading?f`<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=>ql(n,e,0))}
|
|
372
372
|
</div>`}
|
|
373
373
|
|
|
374
|
-
${
|
|
375
|
-
${
|
|
374
|
+
${bh(e)}
|
|
375
|
+
${wh(e)}
|
|
376
376
|
</div>
|
|
377
377
|
</div>
|
|
378
|
-
`:
|
|
378
|
+
`:f`
|
|
379
379
|
<div class="setup-container">
|
|
380
380
|
<div class="setup-card">
|
|
381
381
|
<div class="setup-spinner"></div>
|
|
382
382
|
<p>Connecting to gateway...</p>
|
|
383
383
|
</div>
|
|
384
384
|
</div>
|
|
385
|
-
`}const mr="taskmaster_uninstall_done";async function
|
|
385
|
+
`}const mr="taskmaster_uninstall_done";async function $h(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),Eh();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 ss(){try{return localStorage.getItem(mr)==="1"}catch{return!1}}function yr(){try{localStorage.removeItem(mr)}catch{}}function Eh(){try{localStorage.setItem(mr,"1")}catch{}}const Co=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:ss,clearUninstallDone:yr,runUninstall:$h},Symbol.toStringTag,{value:"Module"}));function ue(e){return f`
|
|
386
386
|
<span
|
|
387
387
|
class="setup-status-light"
|
|
388
388
|
style="background: ${{good:"#22c55e",bad:"#ef4444",partial:"#eab308",unknown:"#6b7280"}[e]}"
|
|
389
389
|
></span>
|
|
390
|
-
`}function Ct(e,t){return
|
|
390
|
+
`}function Ct(e,t){return f`
|
|
391
391
|
<button
|
|
392
392
|
class="setup-info-btn"
|
|
393
393
|
@click=${()=>t.onInfoModalOpen(e)}
|
|
@@ -395,11 +395,11 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
395
395
|
>
|
|
396
396
|
${O.info}
|
|
397
397
|
</button>
|
|
398
|
-
`}function
|
|
398
|
+
`}function Th(e){var s;if(!e.infoModalOpen)return k;let t="",n=[];switch(e.infoModalOpen){case"gateway":{const i=typeof window<"u"?window.location.host:"unknown";t="Gateway",n=[{label:"Status",value:e.gatewayHealthy===!1?"Stopped":"Running"},{label:"Address",value:i},{label:"Health",value:e.gatewayHealthMessage||"OK"}];break}case"claude":{const i=e.authExpiresIn;let r="N/A";if(i!=null&&i>0)if(i>60){const o=Math.floor(i/60),a=i%60;r=a>0?`${o}h ${a}m`:`${o}h`}else r=`${i}m`;t="Claude",n=[{label:"Connected",value:e.authConnected?"Yes":"No"},{label:"Token Expiry",value:r},{label:"Renewal",value:"Automatic (tokens refresh on expiry)"},...e.authMessage?[{label:"Message",value:e.authMessage}]:[]];break}case"license":{const i=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"Key",value:i},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A"}];break}case"whatsapp":{const i=_t(e),r=i?vr(i,e):null;t="WhatsApp",n=[{label:"Account",value:(r==null?void 0:r.name)||(r==null?void 0:r.accountId)||"Default"},{label:"Phone",value:((s=r==null?void 0:r.self)==null?void 0:s.e164)||"Not paired"},{label:"Connected",value:r!=null&&r.connected?"Yes":"No"},{label:"Linked",value:r!=null&&r.linked?"Yes":"No"},...r!=null&&r.lastError?[{label:"Last Error",value:r.lastError}]:[]];break}case"imessage":{const{thisWsOwns:i}=br(e);t="iMessage",n=[{label:"Connected",value:i&&e.imessageConnected?"Yes":"No"},{label:"Assigned To",value:e.imessageOwnerWorkspace??"Not assigned"},{label:"Mode",value:"Self-chat only"},...e.imessageLastError?[{label:"Last Error",value:e.imessageLastError}]:[]];break}case"update":{t="Software Update",n=[{label:"Current",value:e.currentVersion?`v${e.currentVersion}`:"Unknown"},{label:"Latest",value:e.latestVersion?`v${e.latestVersion}`:"Unknown"},{label:"Status",value:e.updateAvailable===null?"Not checked":e.updateAvailable?"Update available":"Up to date"},...e.updateMessage?[{label:"Message",value:e.updateMessage}]:[]];break}default:return k}return f`
|
|
399
399
|
<div class="setup-info-overlay" @click=${i=>{i.target.classList.contains("setup-info-overlay")&&e.onInfoModalClose()}}>
|
|
400
400
|
<div class="setup-info-card">
|
|
401
401
|
<h3>${t}</h3>
|
|
402
|
-
${n.map(i=>
|
|
402
|
+
${n.map(i=>f`
|
|
403
403
|
<div class="setup-info-row">
|
|
404
404
|
<span class="setup-info-label">${i.label}</span>
|
|
405
405
|
<span class="setup-info-value">${i.value}</span>
|
|
@@ -414,9 +414,9 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
414
414
|
</button>
|
|
415
415
|
</div>
|
|
416
416
|
</div>
|
|
417
|
-
`}function me(e){const t=[{id:"license",label:"1. Activate License"},{id:"auth",label:"2. Connect Claude"},{id:"whatsapp",label:"3. Link WhatsApp"}],n=["license","auth","whatsapp","complete"],s=n.indexOf(e);return
|
|
417
|
+
`}function me(e){const t=[{id:"license",label:"1. Activate License"},{id:"auth",label:"2. Connect Claude"},{id:"whatsapp",label:"3. Link WhatsApp"}],n=["license","auth","whatsapp","complete"],s=n.indexOf(e);return f`
|
|
418
418
|
<div class="setup-steps">
|
|
419
|
-
${t.map(i=>{const r=n.indexOf(i.id),o=e===i.id,a=s>r;return
|
|
419
|
+
${t.map(i=>{const r=n.indexOf(i.id),o=e===i.id,a=s>r;return f`
|
|
420
420
|
<div
|
|
421
421
|
class="setup-step ${o?"active":""} ${a?"completed":""}"
|
|
422
422
|
>
|
|
@@ -425,7 +425,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
425
425
|
</div>
|
|
426
426
|
`})}
|
|
427
427
|
</div>
|
|
428
|
-
`}function
|
|
428
|
+
`}function _o(e){const{licenseKey:t,licenseBusy:n,licenseValid:s,licenseMessage:i,licenseDeviceId:r,onLicenseKeyChange:o,onLicenseActivate:a}=e;return s===!0?f`
|
|
429
429
|
<div class="setup-container">
|
|
430
430
|
<div class="setup-card setup-success">
|
|
431
431
|
${me("license")}
|
|
@@ -436,7 +436,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
436
436
|
<p>${i??"Your license is active."}</p>
|
|
437
437
|
</div>
|
|
438
438
|
</div>
|
|
439
|
-
`:n&&!t?
|
|
439
|
+
`:n&&!t?f`
|
|
440
440
|
<div class="setup-container">
|
|
441
441
|
<div class="setup-card">
|
|
442
442
|
${me("license")}
|
|
@@ -444,13 +444,13 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
444
444
|
<p>Checking license...</p>
|
|
445
445
|
</div>
|
|
446
446
|
</div>
|
|
447
|
-
`:
|
|
447
|
+
`:f`
|
|
448
448
|
<div class="setup-container">
|
|
449
449
|
<div class="setup-card">
|
|
450
450
|
${me("license")}
|
|
451
451
|
<h1>Activate License</h1>
|
|
452
452
|
<p>Enter your license key to get started.</p>
|
|
453
|
-
${r?
|
|
453
|
+
${r?f`
|
|
454
454
|
<div class="setup-device-id">
|
|
455
455
|
<span class="setup-device-id-label">Your Device ID</span>
|
|
456
456
|
<code class="setup-device-id-value">${r}</code>
|
|
@@ -480,7 +480,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
480
480
|
${n?"Activating...":"Activate"}
|
|
481
481
|
</button>
|
|
482
482
|
</div>
|
|
483
|
-
${s===!1&&i?
|
|
483
|
+
${s===!1&&i?f`
|
|
484
484
|
<div class="setup-status-row" style="margin-top: 12px;">
|
|
485
485
|
${ue("bad")}
|
|
486
486
|
<span class="setup-error">${i}</span>
|
|
@@ -494,7 +494,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
494
494
|
</p>
|
|
495
495
|
</div>
|
|
496
496
|
</div>
|
|
497
|
-
`}function
|
|
497
|
+
`}function Ch(e){const{authConnected:t,authBusy:n,authMessage:s,authUrl:i,authCodeInput:r,authExpiresIn:o,onStartAuth:a,onSubmitAuthCode:l,onAuthCodeChange:c,onSkipToWhatsApp:u}=e;return t===!0?f`
|
|
498
498
|
<div class="setup-container">
|
|
499
499
|
<div class="setup-card setup-success">
|
|
500
500
|
${me("auth")}
|
|
@@ -504,7 +504,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
504
504
|
</div>
|
|
505
505
|
<p>
|
|
506
506
|
Your Claude Pro subscription is linked.
|
|
507
|
-
${o?
|
|
507
|
+
${o?f`<br /><span class="setup-hint"
|
|
508
508
|
>Expires in ${o} minutes</span
|
|
509
509
|
>`:k}
|
|
510
510
|
</p>
|
|
@@ -516,7 +516,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
516
516
|
</a>
|
|
517
517
|
</div>
|
|
518
518
|
</div>
|
|
519
|
-
`:n&&!i?
|
|
519
|
+
`:n&&!i?f`
|
|
520
520
|
<div class="setup-container">
|
|
521
521
|
<div class="setup-card">
|
|
522
522
|
${me("auth")}
|
|
@@ -524,7 +524,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
524
524
|
<p>Starting Claude connection...</p>
|
|
525
525
|
</div>
|
|
526
526
|
</div>
|
|
527
|
-
`:i?
|
|
527
|
+
`:i?f`
|
|
528
528
|
<div class="setup-container">
|
|
529
529
|
<div class="setup-card">
|
|
530
530
|
${me("auth")}
|
|
@@ -557,7 +557,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
557
557
|
${n?"Verifying...":"Submit"}
|
|
558
558
|
</button>
|
|
559
559
|
</div>
|
|
560
|
-
${s?
|
|
560
|
+
${s?f`<p class="setup-hint">${s}</p>`:k}
|
|
561
561
|
<p class="setup-hint" style="margin-top: 16px;">
|
|
562
562
|
<a href="#" class="setup-link" @click=${p=>{p.preventDefault(),e.onAuthApiKeyToggle()}}>
|
|
563
563
|
Or use an API key instead
|
|
@@ -565,7 +565,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
565
565
|
</p>
|
|
566
566
|
</div>
|
|
567
567
|
</div>
|
|
568
|
-
`:e.authApiKeyMode?
|
|
568
|
+
`:e.authApiKeyMode?f`
|
|
569
569
|
<div class="setup-container">
|
|
570
570
|
<div class="setup-card">
|
|
571
571
|
${me("auth")}
|
|
@@ -587,7 +587,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
587
587
|
@click=${()=>e.onAuthApiKeySubmit()}
|
|
588
588
|
>${e.authApiKeyBusy?"Saving...":"Save"}</button>
|
|
589
589
|
</div>
|
|
590
|
-
${e.authApiKeyError?
|
|
590
|
+
${e.authApiKeyError?f`<p class="setup-error">${e.authApiKeyError}</p>`:k}
|
|
591
591
|
<p class="setup-hint" style="margin-top: 16px;">
|
|
592
592
|
<a href="#" class="setup-link" @click=${p=>{p.preventDefault(),e.onAuthApiKeyToggle()}}>
|
|
593
593
|
Use OAuth instead
|
|
@@ -601,12 +601,12 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
601
601
|
</p>
|
|
602
602
|
</div>
|
|
603
603
|
</div>
|
|
604
|
-
`:
|
|
604
|
+
`:f`
|
|
605
605
|
<div class="setup-container">
|
|
606
606
|
<div class="setup-card">
|
|
607
607
|
${me("auth")}
|
|
608
608
|
<h1>Connect to Claude</h1>
|
|
609
|
-
${t===!1&&s?
|
|
609
|
+
${t===!1&&s?f`<p class="setup-error">${s}</p>`:f`<p>
|
|
610
610
|
First, let's connect your Claude Pro subscription.<br />
|
|
611
611
|
This powers your AI assistant.
|
|
612
612
|
</p>`}
|
|
@@ -626,7 +626,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
626
626
|
</p>
|
|
627
627
|
</div>
|
|
628
628
|
</div>
|
|
629
|
-
`}function vr(e,t){const n=new Map(t.whatsappAccounts.map(s=>[s.accountId,s]));return e.whatsappAccountId?n.get(e.whatsappAccountId)??null:e.isDefault&&t.whatsappAccounts.length===1?t.whatsappAccounts[0]??null:null}function _t(e){var n;const t=(n=e.wsProps)==null?void 0:n.selectedWorkspace;return t?e.workspaces.find(s=>s.name===t)??null:e.workspaces[0]??null}function
|
|
629
|
+
`}function vr(e,t){const n=new Map(t.whatsappAccounts.map(s=>[s.accountId,s]));return e.whatsappAccountId?n.get(e.whatsappAccountId)??null:e.isDefault&&t.whatsappAccounts.length===1?t.whatsappAccounts[0]??null:null}function _t(e){var n;const t=(n=e.wsProps)==null?void 0:n.selectedWorkspace;return t?e.workspaces.find(s=>s.name===t)??null:e.workspaces[0]??null}function Mo(e){const t=_t(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??We().name,s=e.whatsappBusy||e.gatewayHealthLoading;if(e.renamingWorkspace&&t){const i=()=>{const r=e.renameWorkspaceName.trim();r&&e.onWorkspaceRename(t.name,r)};return f`
|
|
630
630
|
<div style="display: flex; align-items: center; gap: 6px; margin-bottom: 4px;">
|
|
631
631
|
<input
|
|
632
632
|
type="text"
|
|
@@ -648,7 +648,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
648
648
|
title="Cancel"
|
|
649
649
|
>${O.x}</button>
|
|
650
650
|
</div>
|
|
651
|
-
`}return
|
|
651
|
+
`}return f`
|
|
652
652
|
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px;">
|
|
653
653
|
<div style="display: flex; align-items: center; gap: 6px;">
|
|
654
654
|
<h2 style="margin: 0; font-size: 20px; font-weight: 600; color: var(--tasker-white);">${n}</h2>
|
|
@@ -668,7 +668,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
668
668
|
${O.rotateCw}
|
|
669
669
|
</button>
|
|
670
670
|
</div>
|
|
671
|
-
`}function
|
|
671
|
+
`}function Lo(e){return f`
|
|
672
672
|
<div class="setup-status-item">
|
|
673
673
|
${ue(e.gatewayHealthy===!1?"bad":"good")}
|
|
674
674
|
<div class="setup-status-info">
|
|
@@ -685,17 +685,17 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
685
685
|
${O.rotateCw}
|
|
686
686
|
</button>
|
|
687
687
|
</div>
|
|
688
|
-
`}function
|
|
688
|
+
`}function Po(e){const t=e.authConnected===!0;return f`
|
|
689
689
|
<div class="setup-status-item">
|
|
690
690
|
${ue(t?"good":"bad")}
|
|
691
691
|
<div class="setup-status-info">
|
|
692
692
|
<strong>Claude</strong>
|
|
693
693
|
<span>
|
|
694
|
-
${t?"Connected":"Not connected"}${t&&e.authExpiresIn?
|
|
694
|
+
${t?"Connected":"Not connected"}${t&&e.authExpiresIn?f` <span style="color: var(--tasker-text-grey); font-size: 12px;">(${e.authExpiresIn>60?`${Math.floor(e.authExpiresIn/60)}h ${e.authExpiresIn%60}m`:`${e.authExpiresIn}m`})</span>`:k}
|
|
695
695
|
</span>
|
|
696
696
|
</div>
|
|
697
697
|
${Ct("claude",e)}
|
|
698
|
-
${t?
|
|
698
|
+
${t?f`
|
|
699
699
|
<button
|
|
700
700
|
class="setup-status-action ${e.authBusy?"spinning":""}"
|
|
701
701
|
?disabled=${e.authBusy}
|
|
@@ -704,7 +704,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
704
704
|
>
|
|
705
705
|
${O.rotateCw}
|
|
706
706
|
</button>
|
|
707
|
-
`:
|
|
707
|
+
`:f`
|
|
708
708
|
<button
|
|
709
709
|
class="setup-status-action"
|
|
710
710
|
@click=${e.onStartAuth}
|
|
@@ -714,7 +714,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
714
714
|
</button>
|
|
715
715
|
`}
|
|
716
716
|
</div>
|
|
717
|
-
`}function
|
|
717
|
+
`}function Ro(e){return f`
|
|
718
718
|
<div class="setup-status-item" style="flex-wrap: wrap;">
|
|
719
719
|
${ue("good")}
|
|
720
720
|
<div class="setup-status-info">
|
|
@@ -729,7 +729,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
729
729
|
>
|
|
730
730
|
${O.rotateCw}
|
|
731
731
|
</button>
|
|
732
|
-
${e.licenseRemoveConfirm?
|
|
732
|
+
${e.licenseRemoveConfirm?f`
|
|
733
733
|
<div style="width: 100%; margin-top: 8px; margin-left: 30px;">
|
|
734
734
|
<p style="color: var(--tasker-text-grey); font-size: 13px; margin: 0 0 8px;">
|
|
735
735
|
Removing your license will disable ${We().name} until you enter a new key.
|
|
@@ -754,13 +754,13 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
754
754
|
</div>
|
|
755
755
|
`:k}
|
|
756
756
|
</div>
|
|
757
|
-
`}function
|
|
757
|
+
`}function Io(e){var p;const t=_t(e);if(!t)return k;const n=vr(t,e),s=(n==null?void 0:n.running)&&(n==null?void 0:n.connected),i=(n==null?void 0:n.linked)&&!s,r=!!n,o=s?"good":i?"partial":r?"bad":"unknown",a=s?"Connected":i?"Linked, not connected":r?(n==null?void 0:n.lastError)||"Not connected":"Not paired",l=!(n!=null&&n.provider)||(n==null?void 0:n.provider)==="baileys",c=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(p=e.whatsappAccounts[0])==null?void 0:p.accountId:void 0),u=c!=null&&e.whatsappActiveQrAccountId===c;return f`
|
|
758
758
|
<div class="setup-status-item" style="flex-wrap: wrap;">
|
|
759
759
|
${ue(o)}
|
|
760
760
|
<div class="setup-status-info">
|
|
761
761
|
<div style="display: flex; align-items: center; gap: 4px;">
|
|
762
762
|
<strong>WhatsApp</strong>
|
|
763
|
-
${r&&s?
|
|
763
|
+
${r&&s?f`
|
|
764
764
|
<button
|
|
765
765
|
class="setup-status-action"
|
|
766
766
|
@click=${e.onWhatsAppSettingsOpen}
|
|
@@ -774,7 +774,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
774
774
|
<span>${a}</span>
|
|
775
775
|
</div>
|
|
776
776
|
${Ct("whatsapp",e)}
|
|
777
|
-
${l&&c?
|
|
777
|
+
${l&&c?f`
|
|
778
778
|
<button
|
|
779
779
|
class="setup-status-action ${e.whatsappBusy&&u?"spinning":""}"
|
|
780
780
|
?disabled=${e.whatsappBusy}
|
|
@@ -784,7 +784,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
784
784
|
${O.rotateCw}
|
|
785
785
|
</button>
|
|
786
786
|
`:k}
|
|
787
|
-
${u&&e.whatsappLoginQrDataUrl?
|
|
787
|
+
${u&&e.whatsappLoginQrDataUrl?f`
|
|
788
788
|
<div style="width: 100%; margin-top: 8px; margin-left: 30px;">
|
|
789
789
|
<div class="setup-qr" style="display: inline-flex;">
|
|
790
790
|
<img
|
|
@@ -793,11 +793,11 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
793
793
|
style="width: 140px; height: 140px;"
|
|
794
794
|
/>
|
|
795
795
|
</div>
|
|
796
|
-
${e.whatsappLoginMessage?
|
|
796
|
+
${e.whatsappLoginMessage?f`<p class="setup-hint" style="margin-top: 4px;">${e.whatsappLoginMessage}</p>`:k}
|
|
797
797
|
</div>
|
|
798
798
|
`:k}
|
|
799
799
|
</div>
|
|
800
|
-
`}const
|
|
800
|
+
`}const _h=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],Mh="anthropic/claude-sonnet-4-5-20250929",Lh=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function Ph(e){if(!e.whatsappSettingsOpen)return k;const t=_t(e);if(!t)return k;const n=vr(t,e),s=(n==null?void 0:n.running)&&(n==null?void 0:n.connected);if(!n||!s)return k;const i=()=>e.onWhatsAppSettingsClose(),r=e.whatsappModelCatalog??[],o=new Set(r.filter(u=>u.provider==="anthropic").map(u=>u.id)),a=_h.filter(u=>o.has(u.id)),l=e.whatsappModel??Mh,c=e.whatsappThinkingLevel??"off";return f`
|
|
801
801
|
<div class="setup-info-overlay" @click=${u=>{u.target.classList.contains("setup-info-overlay")&&i()}}>
|
|
802
802
|
<div class="setup-info-card" style="max-width: 360px;">
|
|
803
803
|
<h3>Public Agent Settings</h3>
|
|
@@ -827,7 +827,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
827
827
|
<div style="font-size: 12px; color: var(--tasker-text-grey); opacity: 0.7;">Agent responds in WhatsApp groups</div>
|
|
828
828
|
</div>
|
|
829
829
|
</label>
|
|
830
|
-
${e.whatsappGroupPolicy==="open"?
|
|
830
|
+
${e.whatsappGroupPolicy==="open"?f`
|
|
831
831
|
<div style="display: flex; flex-direction: column; gap: 6px; padding-left: 24px;">
|
|
832
832
|
<label style="display: flex; align-items: center; gap: 8px; cursor: pointer;">
|
|
833
833
|
<input
|
|
@@ -858,7 +858,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
858
858
|
</div>
|
|
859
859
|
`:k}
|
|
860
860
|
<div style="border-top: 1px solid rgba(255,255,255,0.08); margin: 4px 0;"></div>
|
|
861
|
-
${a.length>0?
|
|
861
|
+
${a.length>0?f`
|
|
862
862
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
863
863
|
<div style="font-size: 13px; color: var(--tasker-text-grey); min-width: 60px;">Model</div>
|
|
864
864
|
<select
|
|
@@ -867,7 +867,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
867
867
|
.value=${l}
|
|
868
868
|
@change=${u=>{e.onWhatsAppModelChange(u.target.value)}}
|
|
869
869
|
>
|
|
870
|
-
${a.map(u=>
|
|
870
|
+
${a.map(u=>f`
|
|
871
871
|
<option value=${"anthropic/"+u.id} ?selected=${l==="anthropic/"+u.id}>
|
|
872
872
|
${u.shortName}
|
|
873
873
|
</option>
|
|
@@ -883,7 +883,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
883
883
|
.value=${c}
|
|
884
884
|
@change=${u=>{e.onWhatsAppThinkingChange(u.target.value)}}
|
|
885
885
|
>
|
|
886
|
-
${
|
|
886
|
+
${Lh.map(u=>f`
|
|
887
887
|
<option value=${u.value} ?selected=${c===u.value}>
|
|
888
888
|
${u.label}
|
|
889
889
|
</option>
|
|
@@ -900,7 +900,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
900
900
|
</button>
|
|
901
901
|
</div>
|
|
902
902
|
</div>
|
|
903
|
-
`}function br(e){const t=_t(e),n=e.imessageOwnerWorkspace,s=!!(t&&n===t.name),i=!!(n&&t&&n!==t.name);return{selectedWs:t,ownerWs:n,thisWsOwns:s,anotherWsOwns:i}}function
|
|
903
|
+
`}function br(e){const t=_t(e),n=e.imessageOwnerWorkspace,s=!!(t&&n===t.name),i=!!(n&&t&&n!==t.name);return{selectedWs:t,ownerWs:n,thisWsOwns:s,anotherWsOwns:i}}function No(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:s}=br(e);let i,r;return s?(i="partial",r=`Connected to ${t}`):n&&e.imessageConnected?(i="good",r="Connected"):n&&e.imessageRunning?(i="partial",r="Running, not connected"):n?(i="bad",r="Not running"):e.imessageConfigured?(i="unknown",r="Not connected"):(i="bad",r="Not configured"),f`
|
|
904
904
|
<div class="setup-status-item" style="flex-wrap: wrap;">
|
|
905
905
|
${ue(i)}
|
|
906
906
|
<div class="setup-status-info">
|
|
@@ -918,7 +918,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
918
918
|
</button>
|
|
919
919
|
${k}
|
|
920
920
|
</div>
|
|
921
|
-
`}function
|
|
921
|
+
`}function Rh(e){if(!e.imessageEnableConfirm)return k;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:s}=br(e),i=()=>{e.onIMessageEnableCancel()};return n?f`
|
|
922
922
|
<div class="setup-info-overlay" @click=${r=>{r.target.classList.contains("setup-info-overlay")&&i()}}>
|
|
923
923
|
<div class="setup-info-card" style="text-align: center;">
|
|
924
924
|
<h3>iMessage</h3>
|
|
@@ -945,7 +945,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
945
945
|
</button>
|
|
946
946
|
</div>
|
|
947
947
|
</div>
|
|
948
|
-
`:s?
|
|
948
|
+
`:s?f`
|
|
949
949
|
<div class="setup-info-overlay" @click=${r=>{r.target.classList.contains("setup-info-overlay")&&i()}}>
|
|
950
950
|
<div class="setup-info-card" style="text-align: center;">
|
|
951
951
|
<h3>Connect iMessage</h3>
|
|
@@ -970,7 +970,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
970
970
|
</button>
|
|
971
971
|
</div>
|
|
972
972
|
</div>
|
|
973
|
-
`:
|
|
973
|
+
`:f`
|
|
974
974
|
<div class="setup-info-overlay" @click=${r=>{r.target.classList.contains("setup-info-overlay")&&i()}}>
|
|
975
975
|
<div class="setup-info-card" style="text-align: center;">
|
|
976
976
|
<h3>Enable iMessage</h3>
|
|
@@ -994,7 +994,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
994
994
|
</button>
|
|
995
995
|
</div>
|
|
996
996
|
</div>
|
|
997
|
-
`}function
|
|
997
|
+
`}function Do(e){if(!e.isMaster)return k;const n=e.apiKeyProviders.filter(s=>s.hasKey).length;return f`
|
|
998
998
|
<div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
|
|
999
999
|
<div class="setup-status-item">
|
|
1000
1000
|
${ue(n>0?"good":"bad")}
|
|
@@ -1008,14 +1008,14 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1008
1008
|
>Manage</button>
|
|
1009
1009
|
</div>
|
|
1010
1010
|
</div>
|
|
1011
|
-
${
|
|
1012
|
-
`}function
|
|
1011
|
+
${Ih(e)}
|
|
1012
|
+
`}function Ih(e){if(!e.apiKeyModalOpen)return k;const t=e.apiKeyProviders,n={};for(const c of t)c.key&&(n[c.id]=c.key);const s=(c,u)=>{const p=u==null?void 0:u.closest(".setup-apikey-input"),d=p==null?void 0:p.querySelector("input"),h=d==null?void 0:d.value.trim();!h||h===n[c]||e.onApiKeySave(c,h)},i=c=>{const u=c.currentTarget,p=u.closest(".setup-apikey-input"),d=p==null?void 0:p.querySelector("input");if(!d)return;const h=d.type==="text";d.type=h?"password":"text",u.classList.toggle("active",!h)},r=(c,u)=>{const p=u.target,d=p.closest(".setup-apikey-input"),h=p.value.trim(),b=h.length>0&&h!==n[c],w=d==null?void 0:d.querySelector(".setup-apikey-save");w&&(w.style.display=b?"":"none");const S=d==null?void 0:d.querySelector(".setup-apikey-eye");S&&(S.style.display=h.length>0?"":"none")},o=t.filter(c=>c.primary),a=t.filter(c=>!c.primary),l=c=>{const u=e.apiKeySavingProvider===c.id&&e.apiKeyBusy,p=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key saved`,d=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key removed`;return f`
|
|
1013
1013
|
<div class="setup-apikey-row">
|
|
1014
1014
|
<div class="setup-apikey-info">
|
|
1015
1015
|
<strong>${c.name}</strong>
|
|
1016
1016
|
<span class="setup-apikey-category">${c.category}</span>
|
|
1017
|
-
${p?
|
|
1018
|
-
${d?
|
|
1017
|
+
${p?f`<span class="setup-apikey-badge saved">Saved</span>`:k}
|
|
1018
|
+
${d?f`<span class="setup-apikey-badge removed">Removed</span>`:k}
|
|
1019
1019
|
</div>
|
|
1020
1020
|
<div class="setup-apikey-input">
|
|
1021
1021
|
<input
|
|
@@ -1023,8 +1023,8 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1023
1023
|
.value=${c.key??""}
|
|
1024
1024
|
placeholder="Enter key"
|
|
1025
1025
|
?disabled=${e.apiKeyBusy}
|
|
1026
|
-
@input=${
|
|
1027
|
-
@keydown=${
|
|
1026
|
+
@input=${h=>r(c.id,h)}
|
|
1027
|
+
@keydown=${h=>{h.key==="Enter"&&s(c.id,h.target)}}
|
|
1028
1028
|
/>
|
|
1029
1029
|
<button
|
|
1030
1030
|
class="setup-apikey-icon-btn setup-apikey-eye"
|
|
@@ -1032,13 +1032,13 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1032
1032
|
title="Toggle visibility"
|
|
1033
1033
|
@click=${i}
|
|
1034
1034
|
>${O.eye}</button>
|
|
1035
|
-
${u?
|
|
1035
|
+
${u?f`<span class="setup-apikey-badge saving">Saving\u2026</span>`:f`<button
|
|
1036
1036
|
class="setup-apikey-save setup-button"
|
|
1037
1037
|
style="display: none;"
|
|
1038
1038
|
?disabled=${e.apiKeyBusy}
|
|
1039
|
-
@click=${
|
|
1039
|
+
@click=${h=>s(c.id,h.currentTarget)}
|
|
1040
1040
|
>Save</button>`}
|
|
1041
|
-
${c.hasKey&&!u?
|
|
1041
|
+
${c.hasKey&&!u?f`
|
|
1042
1042
|
<button
|
|
1043
1043
|
class="setup-apikey-icon-btn danger"
|
|
1044
1044
|
title="Remove key"
|
|
@@ -1048,14 +1048,14 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1048
1048
|
`:k}
|
|
1049
1049
|
</div>
|
|
1050
1050
|
</div>
|
|
1051
|
-
`};return
|
|
1051
|
+
`};return f`
|
|
1052
1052
|
<div class="setup-info-overlay" style="align-items: flex-start; padding-top: 72px;" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onApiKeyModalClose()}}>
|
|
1053
1053
|
<div class="setup-info-card" style="max-width: 480px;">
|
|
1054
1054
|
<h3 style="margin: 0 0 4px; text-align: center;">API Keys</h3>
|
|
1055
1055
|
<div class="setup-apikey-list">
|
|
1056
|
-
${e.apiKeyError?
|
|
1056
|
+
${e.apiKeyError?f`<p class="setup-error" style="margin: 0;">${e.apiKeyError}</p>`:k}
|
|
1057
1057
|
${o.map(l)}
|
|
1058
|
-
${a.length>0?
|
|
1058
|
+
${a.length>0?f`
|
|
1059
1059
|
<details class="setup-apikey-advanced">
|
|
1060
1060
|
<summary>Additional keys</summary>
|
|
1061
1061
|
${a.map(l)}
|
|
@@ -1064,7 +1064,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1064
1064
|
</div>
|
|
1065
1065
|
</div>
|
|
1066
1066
|
</div>
|
|
1067
|
-
`}function
|
|
1067
|
+
`}function Oo(e){const t=e.updateAvailable===null?"unknown":e.updateAvailable?"partial":"good",n=e.updateAvailable&&e.latestVersion?`v${e.currentVersion} → v${e.latestVersion}`:e.currentVersion?`v${e.currentVersion}`:"Unknown",s=e.updateChecking||e.updateRunning;return f`
|
|
1068
1068
|
<div class="setup-status-item">
|
|
1069
1069
|
${ue(t)}
|
|
1070
1070
|
<div class="setup-status-info">
|
|
@@ -1072,7 +1072,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1072
1072
|
<span>${n}</span>
|
|
1073
1073
|
</div>
|
|
1074
1074
|
${Ct("update",e)}
|
|
1075
|
-
${e.updateAvailable?
|
|
1075
|
+
${e.updateAvailable?f`
|
|
1076
1076
|
<button
|
|
1077
1077
|
class="setup-status-action ${s?"spinning":""}"
|
|
1078
1078
|
?disabled=${s}
|
|
@@ -1081,7 +1081,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1081
1081
|
>
|
|
1082
1082
|
${O.download}
|
|
1083
1083
|
</button>
|
|
1084
|
-
`:
|
|
1084
|
+
`:f`
|
|
1085
1085
|
<button
|
|
1086
1086
|
class="setup-status-action ${s?"spinning":""}"
|
|
1087
1087
|
?disabled=${s}
|
|
@@ -1092,27 +1092,27 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1092
1092
|
</button>
|
|
1093
1093
|
`}
|
|
1094
1094
|
</div>
|
|
1095
|
-
`}function
|
|
1095
|
+
`}function Nh(e){var s,i,r;const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return k;if(t)return f`
|
|
1096
1096
|
<div class="setup-info-overlay">
|
|
1097
1097
|
<div class="setup-info-card" style="max-width: 400px;">
|
|
1098
1098
|
<h3>Software Update</h3>
|
|
1099
|
-
${e.updateProgressSteps.length>0?
|
|
1099
|
+
${e.updateProgressSteps.length>0?f`
|
|
1100
1100
|
<div class="setup-update-progress">
|
|
1101
|
-
${e.updateProgressSteps.map(o=>
|
|
1101
|
+
${e.updateProgressSteps.map(o=>f`
|
|
1102
1102
|
<div class="setup-update-step ${o.status}">
|
|
1103
1103
|
<span class="setup-update-step-icon">
|
|
1104
|
-
${o.status==="running"?
|
|
1104
|
+
${o.status==="running"?f`<span class="setup-update-spinner"></span>`:o.status==="done"?f`<span class="setup-update-check">✓</span>`:f`<span class="setup-update-cross">✗</span>`}
|
|
1105
1105
|
</span>
|
|
1106
1106
|
<span class="setup-update-step-name">${o.name}</span>
|
|
1107
|
-
${o.durationMs!=null?
|
|
1107
|
+
${o.durationMs!=null?f`<span class="setup-update-step-time">${Bo(o.durationMs)}</span>`:k}
|
|
1108
1108
|
</div>
|
|
1109
1109
|
`)}
|
|
1110
1110
|
</div>
|
|
1111
|
-
`:
|
|
1112
|
-
${e.updateMessage?
|
|
1111
|
+
`:f`<div class="setup-spinner" style="margin: 16px auto;"></div>`}
|
|
1112
|
+
${e.updateMessage?f`<p style="text-align: center; color: var(--tasker-text-grey); font-size: 13px; margin: 12px 0 0;">${e.updateMessage}</p>`:k}
|
|
1113
1113
|
</div>
|
|
1114
1114
|
</div>
|
|
1115
|
-
`;if(n){const o=n.status==="ok";let a;if(o){const c=(s=n.before)==null?void 0:s.version,u=((i=n.after)==null?void 0:i.version)??n.currentVersion;a=c?`v${c} → v${u}`:`Updated to v${u}`}else a=n.reason??((r=n.failedStep)==null?void 0:r.name)??"unknown error";const l=n.durationMs!=null?
|
|
1115
|
+
`;if(n){const o=n.status==="ok";let a;if(o){const c=(s=n.before)==null?void 0:s.version,u=((i=n.after)==null?void 0:i.version)??n.currentVersion;a=c?`v${c} → v${u}`:`Updated to v${u}`}else a=n.reason??((r=n.failedStep)==null?void 0:r.name)??"unknown error";const l=n.durationMs!=null?Bo(n.durationMs):null;return f`
|
|
1116
1116
|
<div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onUpdateDismissResult()}}>
|
|
1117
1117
|
<div class="setup-info-card" style="max-width: 360px; text-align: center;">
|
|
1118
1118
|
<div style="font-size: 40px; margin-bottom: 8px;">${o?"✓":"✗"}</div>
|
|
@@ -1122,7 +1122,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1122
1122
|
<p style="color: var(--tasker-text-grey); font-size: 14px; margin: 8px 0;">
|
|
1123
1123
|
${a}
|
|
1124
1124
|
</p>
|
|
1125
|
-
${l?
|
|
1125
|
+
${l?f`<p style="color: rgba(255,255,255,0.3); font-size: 12px; margin: 4px 0 0;">${l}</p>`:k}
|
|
1126
1126
|
<button
|
|
1127
1127
|
class="setup-button secondary"
|
|
1128
1128
|
style="margin-top: 20px; width: 100%; padding: 10px;"
|
|
@@ -1132,7 +1132,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1132
1132
|
</button>
|
|
1133
1133
|
</div>
|
|
1134
1134
|
</div>
|
|
1135
|
-
`}return k}function
|
|
1135
|
+
`}return k}function Bo(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return s>0?`${n}m ${s}s`:`${n}m`}function Fo(e){const t=e.accountHasPin;return f`
|
|
1136
1136
|
<div class="setup-status-item">
|
|
1137
1137
|
${ue(t?"good":"bad")}
|
|
1138
1138
|
<div class="setup-status-info">
|
|
@@ -1144,7 +1144,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1144
1144
|
@click=${()=>e.onAccountPinModalOpen()}
|
|
1145
1145
|
>${t?"Change":"Set PIN"}</button>
|
|
1146
1146
|
</div>
|
|
1147
|
-
`}function
|
|
1147
|
+
`}function Uo(e){if(!e.accountPinModalOpen)return k;const t=e.accountHasPin,n=e.accountPinBusy;let s="",i="",r="";const o=c=>u=>{const p=u.target;p.value=p.value.replace(/\D/g,"").slice(0,6),c(p.value)},a=(c,u)=>{var d;let p=c.querySelector(".pin-modal-validation");p||(p=document.createElement("p"),p.className="login-error pin-modal-validation",(d=c.querySelector("button[type=submit]"))==null||d.before(p)),p.textContent=u},l=c=>{c.preventDefault();const u=c.target;if(!n){if(t&&!s){a(u,"Enter your current PIN");return}if(!i){a(u,"Enter a new PIN");return}if(!r){a(u,"Confirm your new PIN");return}if(i!==r){a(u,"PINs do not match");return}if(i.length<4){a(u,"PIN must be 4–6 digits");return}e.onAccountPinSave(t?s:null,i)}};return f`
|
|
1148
1148
|
<div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onAccountPinModalClose()}}>
|
|
1149
1149
|
<div class="setup-info-card" style="max-width: 340px;">
|
|
1150
1150
|
<div class="setup-info-header">
|
|
@@ -1154,7 +1154,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1154
1154
|
</button>
|
|
1155
1155
|
</div>
|
|
1156
1156
|
<form @submit=${l} style="display: flex; flex-direction: column; gap: 12px; padding: 16px 0 8px;">
|
|
1157
|
-
${t?
|
|
1157
|
+
${t?f`
|
|
1158
1158
|
<input
|
|
1159
1159
|
class="login-pin-input"
|
|
1160
1160
|
type="password"
|
|
@@ -1178,7 +1178,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1178
1178
|
placeholder="New PIN (4–6 digits)"
|
|
1179
1179
|
?disabled=${n}
|
|
1180
1180
|
@input=${o(c=>{i=c})}
|
|
1181
|
-
${t?k:
|
|
1181
|
+
${t?k:f`autofocus`}
|
|
1182
1182
|
/>
|
|
1183
1183
|
<input
|
|
1184
1184
|
class="login-pin-input"
|
|
@@ -1191,17 +1191,17 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1191
1191
|
?disabled=${n}
|
|
1192
1192
|
@input=${o(c=>{r=c})}
|
|
1193
1193
|
/>
|
|
1194
|
-
${e.accountPinError?
|
|
1195
|
-
${e.accountPinSuccess?
|
|
1194
|
+
${e.accountPinError?f`<p class="login-error">${e.accountPinError}</p>`:k}
|
|
1195
|
+
${e.accountPinSuccess?f`<p class="login-success">${e.accountPinSuccess}</p>`:k}
|
|
1196
1196
|
<button
|
|
1197
1197
|
class="login-submit"
|
|
1198
1198
|
type="submit"
|
|
1199
1199
|
?disabled=${n}
|
|
1200
|
-
>${n?
|
|
1200
|
+
>${n?f`<span class="login-spinner"></span>`:t?"Change PIN":"Set PIN"}</button>
|
|
1201
1201
|
</form>
|
|
1202
1202
|
</div>
|
|
1203
1203
|
</div>
|
|
1204
|
-
`}function
|
|
1204
|
+
`}function Wo(e){if(!e.addingWorkspace)return k;const{workspaceSaving:t}=e;return f`
|
|
1205
1205
|
<div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
|
|
1206
1206
|
<div class="setup-add-account">
|
|
1207
1207
|
<strong>New Account</strong>
|
|
@@ -1254,7 +1254,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1254
1254
|
</div>
|
|
1255
1255
|
</div>
|
|
1256
1256
|
</div>
|
|
1257
|
-
`}function
|
|
1257
|
+
`}function Ko(e){const t=_t(e);return!t||t.isDefault?k:e.workspaceRemoveConfirm===t.name?f`
|
|
1258
1258
|
<div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 12px;">
|
|
1259
1259
|
<div style="font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
|
|
1260
1260
|
<span style="color: var(--tasker-danger, #ef4444);">Remove "${t.displayName??t.name}" and its WhatsApp account?</span>
|
|
@@ -1275,7 +1275,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1275
1275
|
</button>
|
|
1276
1276
|
</div>
|
|
1277
1277
|
</div>
|
|
1278
|
-
`:
|
|
1278
|
+
`:f`
|
|
1279
1279
|
<p class="setup-hint" style="margin-top: 12px;">
|
|
1280
1280
|
<a
|
|
1281
1281
|
href="#"
|
|
@@ -1283,7 +1283,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1283
1283
|
@click=${s=>{s.preventDefault(),e.onSetWorkspaceRemoveConfirm(t.name)}}
|
|
1284
1284
|
>Remove Account</a>
|
|
1285
1285
|
</p>
|
|
1286
|
-
`}function
|
|
1286
|
+
`}function zo(e){if(e.uninstallDone)return f`
|
|
1287
1287
|
<div style="margin-top: 24px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
|
|
1288
1288
|
<p style="color: var(--tasker-danger, #ef4444); font-size: 13px; font-weight: 600; margin: 0 0 8px 0;">
|
|
1289
1289
|
Taskmaster has been uninstalled.
|
|
@@ -1293,7 +1293,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1293
1293
|
<code style="font-size: 11px; background: rgba(255,255,255,0.06); padding: 2px 6px; border-radius: 3px;">sudo npm uninstall -g @rubytech/taskmaster</code>
|
|
1294
1294
|
</p>
|
|
1295
1295
|
</div>
|
|
1296
|
-
`;if(e.uninstallConfirm){const t=e.uninstallConfirmText==="UNINSTALL";return
|
|
1296
|
+
`;if(e.uninstallConfirm){const t=e.uninstallConfirmText==="UNINSTALL";return f`
|
|
1297
1297
|
<div style="margin-top: 24px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
|
|
1298
1298
|
<p style="color: var(--tasker-danger, #ef4444); font-size: 13px; font-weight: 600; margin: 0 0 8px 0;">
|
|
1299
1299
|
Uninstall Taskmaster
|
|
@@ -1328,9 +1328,9 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1328
1328
|
Cancel
|
|
1329
1329
|
</button>
|
|
1330
1330
|
</div>
|
|
1331
|
-
${e.uninstallError?
|
|
1331
|
+
${e.uninstallError?f`<p class="setup-error" style="margin-top: 8px; font-size: 12px;">${e.uninstallError}</p>`:k}
|
|
1332
1332
|
</div>
|
|
1333
|
-
`}return
|
|
1333
|
+
`}return f`
|
|
1334
1334
|
<p class="setup-hint" style="margin-top: 8px;">
|
|
1335
1335
|
<a
|
|
1336
1336
|
href="#"
|
|
@@ -1338,11 +1338,11 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1338
1338
|
@click=${t=>{t.preventDefault(),e.onUninstallConfirm()}}
|
|
1339
1339
|
>Uninstall Taskmaster</a>
|
|
1340
1340
|
</p>
|
|
1341
|
-
`}function
|
|
1341
|
+
`}function jo(){return f`
|
|
1342
1342
|
<p class="setup-hint" style="margin-top: 4px; font-size: 12px; opacity: 0.6;">
|
|
1343
1343
|
Need help? <a href="https://wa.me/447591215452" target="_blank" rel="noopener" style="color: var(--tasker-orange);">Message Dave on WhatsApp</a>
|
|
1344
1344
|
</p>
|
|
1345
|
-
`}function
|
|
1345
|
+
`}function Dh(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:s,whatsappLoginConnected:i,whatsappChannelStatus:r}=e;if(s)return f`
|
|
1346
1346
|
<div class="setup-container">
|
|
1347
1347
|
<div class="setup-card">
|
|
1348
1348
|
<h1>Scan with WhatsApp</h1>
|
|
@@ -1352,7 +1352,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1352
1352
|
<div class="setup-qr">
|
|
1353
1353
|
<img src=${s} alt="WhatsApp QR Code" />
|
|
1354
1354
|
</div>
|
|
1355
|
-
${t?
|
|
1355
|
+
${t?f`<p class="setup-waiting">Waiting for scan...</p>`:f`<p class="setup-hint">
|
|
1356
1356
|
Scan the code above with your phone
|
|
1357
1357
|
</p>`}
|
|
1358
1358
|
<p class="setup-hint" style="margin-top: 16px;">
|
|
@@ -1369,58 +1369,60 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1369
1369
|
</div>
|
|
1370
1370
|
</div>
|
|
1371
1371
|
</div>
|
|
1372
|
-
`;if(t)return
|
|
1372
|
+
`;if(t)return f`
|
|
1373
1373
|
<div class="setup-container">
|
|
1374
1374
|
<div class="setup-card">
|
|
1375
1375
|
<div class="setup-spinner"></div>
|
|
1376
1376
|
<p>${n||"Connecting to WhatsApp..."}</p>
|
|
1377
1377
|
</div>
|
|
1378
1378
|
</div>
|
|
1379
|
-
`;const o=(r==null?void 0:r.running)&&(r==null?void 0:r.connected);return r?(e.whatsappAccounts.length>1?e.whatsappAccounts.every(u=>u.running&&u.connected):o)&&e.authConnected?
|
|
1379
|
+
`;const o=(r==null?void 0:r.running)&&(r==null?void 0:r.connected);return r?(e.whatsappAccounts.length>1?e.whatsappAccounts.every(u=>u.running&&u.connected):o)&&e.authConnected?f`
|
|
1380
1380
|
<div class="setup-container">
|
|
1381
1381
|
<div class="setup-card setup-success">
|
|
1382
|
-
${
|
|
1382
|
+
${Mo(e)}
|
|
1383
1383
|
<div class="setup-status-dashboard">
|
|
1384
|
-
${Mo(e)}
|
|
1385
1384
|
${Lo(e)}
|
|
1386
1385
|
${Po(e)}
|
|
1387
1386
|
${Ro(e)}
|
|
1388
1387
|
${Io(e)}
|
|
1389
|
-
${
|
|
1390
|
-
${
|
|
1388
|
+
${No(e)}
|
|
1389
|
+
${Fo(e)}
|
|
1390
|
+
${Oo(e)}
|
|
1391
1391
|
</div>
|
|
1392
1392
|
|
|
1393
|
-
${Ih(e)}
|
|
1394
|
-
${No(e)}
|
|
1395
|
-
${Bo(e)}
|
|
1396
|
-
${Fo(e)}
|
|
1397
1393
|
${Uo(e)}
|
|
1398
|
-
${
|
|
1399
|
-
${e
|
|
1394
|
+
${Do(e)}
|
|
1395
|
+
${Wo(e)}
|
|
1396
|
+
${Ko(e)}
|
|
1397
|
+
${zo(e)}
|
|
1398
|
+
${jo()}
|
|
1399
|
+
${e.workspacesError?f`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:k}
|
|
1400
1400
|
</div>
|
|
1401
1401
|
</div>
|
|
1402
|
-
`:
|
|
1402
|
+
`:f`
|
|
1403
1403
|
<div class="setup-container">
|
|
1404
1404
|
<div class="setup-card">
|
|
1405
|
-
${
|
|
1405
|
+
${Mo(e)}
|
|
1406
1406
|
<div class="setup-status-dashboard">
|
|
1407
|
-
${Mo(e)}
|
|
1408
1407
|
${Lo(e)}
|
|
1409
1408
|
${Po(e)}
|
|
1410
1409
|
${Ro(e)}
|
|
1411
1410
|
${Io(e)}
|
|
1412
|
-
${
|
|
1411
|
+
${No(e)}
|
|
1412
|
+
${Fo(e)}
|
|
1413
|
+
${Oo(e)}
|
|
1413
1414
|
</div>
|
|
1414
1415
|
|
|
1415
|
-
${No(e)}
|
|
1416
|
-
${Bo(e)}
|
|
1417
|
-
${Fo(e)}
|
|
1418
1416
|
${Uo(e)}
|
|
1419
|
-
${
|
|
1420
|
-
${e
|
|
1417
|
+
${Do(e)}
|
|
1418
|
+
${Wo(e)}
|
|
1419
|
+
${Ko(e)}
|
|
1420
|
+
${zo(e)}
|
|
1421
|
+
${jo()}
|
|
1422
|
+
${e.workspacesError?f`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:k}
|
|
1421
1423
|
</div>
|
|
1422
1424
|
</div>
|
|
1423
|
-
`:r?i===!1&&n&&!t?
|
|
1425
|
+
`:r?i===!1&&n&&!t?f`
|
|
1424
1426
|
<div class="setup-container">
|
|
1425
1427
|
<div class="setup-card">
|
|
1426
1428
|
${me("whatsapp")}
|
|
@@ -1438,15 +1440,15 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1438
1440
|
</button>
|
|
1439
1441
|
</div>
|
|
1440
1442
|
</div>
|
|
1441
|
-
`:
|
|
1443
|
+
`:f`
|
|
1442
1444
|
<div class="setup-container">
|
|
1443
1445
|
<div class="setup-card">
|
|
1444
1446
|
${me("whatsapp")}
|
|
1445
|
-
${n?
|
|
1447
|
+
${n?f`<p class="setup-error">${n}</p>`:f`<div class="setup-spinner"></div>
|
|
1446
1448
|
<p>Preparing...</p>`}
|
|
1447
1449
|
</div>
|
|
1448
1450
|
</div>
|
|
1449
|
-
`:
|
|
1451
|
+
`:f`
|
|
1450
1452
|
<div class="setup-container">
|
|
1451
1453
|
<div class="setup-card">
|
|
1452
1454
|
${me("whatsapp")}
|
|
@@ -1461,7 +1463,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1461
1463
|
</button>
|
|
1462
1464
|
</div>
|
|
1463
1465
|
</div>
|
|
1464
|
-
`}function
|
|
1466
|
+
`}function Oh(e){const{connected:t,currentStep:n}=e;if(t&&ss()&&yr(),e.uninstallDone||!t&&ss())return f`
|
|
1465
1467
|
<div class="setup-container">
|
|
1466
1468
|
<div class="setup-card">
|
|
1467
1469
|
<p style="color: var(--tasker-danger, #ef4444); font-size: 16px; font-weight: 600; margin: 0 0 12px 0;">
|
|
@@ -1477,20 +1479,20 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1477
1479
|
<p style="font-size: 12px; color: var(--tasker-text-grey); margin: 0;">You can close this tab.</p>
|
|
1478
1480
|
</div>
|
|
1479
1481
|
</div>
|
|
1480
|
-
`;if(!t){const r=e.updateRunning;return
|
|
1482
|
+
`;if(!t){const r=e.updateRunning;return f`
|
|
1481
1483
|
<div class="setup-container">
|
|
1482
1484
|
<div class="setup-card">
|
|
1483
1485
|
<div class="setup-spinner"></div>
|
|
1484
1486
|
<p>${r?"Restarting gateway after update…":"Connecting to gateway..."}</p>
|
|
1485
1487
|
</div>
|
|
1486
1488
|
</div>
|
|
1487
|
-
`}let s;switch(n){case"license":s=
|
|
1489
|
+
`}let s;switch(n){case"license":s=_o(e);break;case"auth":s=Ch(e);break;case"whatsapp":case"complete":s=Dh(e);break;default:s=_o(e)}const i=at("Setup",e.wsProps);return f`${s}${Th(e)}${Rh(e)}${Ph(e)}${Nh(e)}${i}`}function Bh(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return f`
|
|
1488
1490
|
<div class="sp-list-item">
|
|
1489
1491
|
<div class="sp-list-item-main">
|
|
1490
1492
|
<div class="sp-list-item-title">${e.phone}</div>
|
|
1491
1493
|
<div class="sp-list-item-sub">${n}</div>
|
|
1492
1494
|
</div>
|
|
1493
|
-
${e.paired?
|
|
1495
|
+
${e.paired?f`<span style="color: var(--tasker-orange); font-size: 13px; padding: 8px 16px;">Primary</span>`:f`<button
|
|
1494
1496
|
class="setup-button danger"
|
|
1495
1497
|
style="padding: 8px 16px; font-size: 13px;"
|
|
1496
1498
|
?disabled=${t.saving}
|
|
@@ -1499,14 +1501,14 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1499
1501
|
Remove
|
|
1500
1502
|
</button>`}
|
|
1501
1503
|
</div>
|
|
1502
|
-
`}function
|
|
1504
|
+
`}function Fh(e){if(!e.connected)return f`
|
|
1503
1505
|
<div class="setup-container">
|
|
1504
1506
|
<div class="setup-card">
|
|
1505
1507
|
<div class="setup-spinner"></div>
|
|
1506
1508
|
<p>Connecting to gateway...</p>
|
|
1507
1509
|
</div>
|
|
1508
1510
|
</div>
|
|
1509
|
-
`;const t=n=>{n.preventDefault(),e.newPhone.trim()&&e.onAdd(e.newPhone)};return
|
|
1511
|
+
`;const t=n=>{n.preventDefault(),e.newPhone.trim()&&e.onAdd(e.newPhone)};return f`
|
|
1510
1512
|
<div class="setup-container">
|
|
1511
1513
|
${at("Admins",e.wsProps)}
|
|
1512
1514
|
<div class="setup-card" style="max-width: 520px;">
|
|
@@ -1526,7 +1528,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1526
1528
|
</button>
|
|
1527
1529
|
</div>
|
|
1528
1530
|
|
|
1529
|
-
${e.error?
|
|
1531
|
+
${e.error?f`<div class="setup-error" style="margin-top: 16px;">${e.error}</div>`:k}
|
|
1530
1532
|
|
|
1531
1533
|
<form style="display: flex; flex-direction: row; gap: 12px; margin-top: 20px; align-items: stretch;" @submit=${t}>
|
|
1532
1534
|
<input
|
|
@@ -1548,7 +1550,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1548
1550
|
</form>
|
|
1549
1551
|
|
|
1550
1552
|
<div class="sp-list" style="margin-top: 20px;">
|
|
1551
|
-
${e.phones.length===0?
|
|
1553
|
+
${e.phones.length===0?f`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>Bh(n,e))}
|
|
1552
1554
|
</div>
|
|
1553
1555
|
|
|
1554
1556
|
<div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
|
|
@@ -1559,9 +1561,9 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1559
1561
|
|
|
1560
1562
|
</div>
|
|
1561
1563
|
</div>
|
|
1562
|
-
`}function
|
|
1564
|
+
`}function Uh(e){return Object.keys(e.fields).length}function Wh(e,t){const n=Object.entries(e.fields);return f`
|
|
1563
1565
|
<div class="customers-record-fields">
|
|
1564
|
-
${n.length===0?
|
|
1566
|
+
${n.length===0?f`<div style="color: rgba(255,255,255,0.4); font-size: 13px; margin-top: 12px;">No fields yet. Add one below.</div>`:n.map(([s,i])=>f`
|
|
1565
1567
|
<div class="customers-field-row">
|
|
1566
1568
|
<input
|
|
1567
1569
|
class="field-key"
|
|
@@ -1606,7 +1608,7 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1606
1608
|
</button>
|
|
1607
1609
|
</div>
|
|
1608
1610
|
</div>
|
|
1609
|
-
`}function
|
|
1611
|
+
`}function Kh(e,t){const n=t.editingId===e.id,s=Uh(e),i=s===0?"No fields":`${s} field${s>1?"s":""}`;return f`
|
|
1610
1612
|
<div class="customers-record">
|
|
1611
1613
|
<div
|
|
1612
1614
|
class="customers-record-header"
|
|
@@ -1618,16 +1620,16 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1618
1620
|
</div>
|
|
1619
1621
|
<span class="customers-record-meta">${i}</span>
|
|
1620
1622
|
</div>
|
|
1621
|
-
${n?
|
|
1623
|
+
${n?Wh(e,t):k}
|
|
1622
1624
|
</div>
|
|
1623
|
-
`}function
|
|
1625
|
+
`}function zh(e){if(!e.connected)return f`
|
|
1624
1626
|
<div class="setup-container">
|
|
1625
1627
|
<div class="setup-card">
|
|
1626
1628
|
<div class="setup-spinner"></div>
|
|
1627
1629
|
<p>Connecting to gateway...</p>
|
|
1628
1630
|
</div>
|
|
1629
1631
|
</div>
|
|
1630
|
-
`;const t=s=>{s.preventDefault(),e.onSearchSubmit()},n=s=>{s.preventDefault(),e.newRecordPhone.trim()&&e.newRecordName.trim()&&e.onAdd(e.newRecordPhone,e.newRecordName)};return
|
|
1632
|
+
`;const t=s=>{s.preventDefault(),e.onSearchSubmit()},n=s=>{s.preventDefault(),e.newRecordPhone.trim()&&e.newRecordName.trim()&&e.onAdd(e.newRecordPhone,e.newRecordName)};return f`
|
|
1631
1633
|
<div class="setup-container">
|
|
1632
1634
|
${at("Customers",e.wsProps)}
|
|
1633
1635
|
<div class="setup-card" style="max-width: 620px;">
|
|
@@ -1654,9 +1656,9 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1654
1656
|
</button>
|
|
1655
1657
|
</div>
|
|
1656
1658
|
|
|
1657
|
-
${e.error?
|
|
1659
|
+
${e.error?f`<div class="setup-error" style="margin-top: 16px;">${e.error}</div>`:k}
|
|
1658
1660
|
|
|
1659
|
-
${e.showAddForm?
|
|
1661
|
+
${e.showAddForm?f`
|
|
1660
1662
|
<form class="customers-add-form" @submit=${n}>
|
|
1661
1663
|
<input
|
|
1662
1664
|
type="tel"
|
|
@@ -1714,9 +1716,9 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1714
1716
|
</form>
|
|
1715
1717
|
|
|
1716
1718
|
<div style="margin-top: 16px;">
|
|
1717
|
-
${e.records.length===0?
|
|
1719
|
+
${e.records.length===0?f`<div class="customers-empty">
|
|
1718
1720
|
${e.searchQuery.trim()?`No records matching "${e.searchQuery}".`:"No customer records yet. Add one to get started."}
|
|
1719
|
-
</div>`:e.records.map(s=>
|
|
1721
|
+
</div>`:e.records.map(s=>Kh(s,e))}
|
|
1720
1722
|
</div>
|
|
1721
1723
|
|
|
1722
1724
|
<div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
|
|
@@ -1727,33 +1729,33 @@ ${s}`:c.join(", ");l.push({type:"text",text:f})}else s&&l.push({type:"text",text
|
|
|
1727
1729
|
</div>
|
|
1728
1730
|
</div>
|
|
1729
1731
|
</div>
|
|
1730
|
-
`}const Hl={CHILD:2},ql=e=>(...t)=>({_$litDirective$:e,values:t});let Gl=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,s){this._$Ct=t,this._$AM=n,this._$Ci=s}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:zh}=Tu,Ko=e=>e,zo=()=>document.createComment(""),Ot=(e,t,n)=>{var r;const s=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0){const o=s.insertBefore(zo(),i),a=s.insertBefore(zo(),i);n=new zh(o,a,e,e.options)}else{const o=n._$AB.nextSibling,a=n._$AM,l=a!==e;if(l){let c;(r=n._$AQ)==null||r.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==a._$AU&&n._$AP(c)}if(o!==i||l){let c=n._$AA;for(;c!==o;){const u=Ko(c).nextSibling;Ko(s).insertBefore(c,i),c=u}}}return n},Ve=(e,t,n=e)=>(e._$AI(t,n),e),jh={},Hh=(e,t=jh)=>e._$AH=t,qh=e=>e._$AH,Vs=e=>{e._$AR(),e._$AA.remove()};const jo=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s},Gh=ql(class extends Gl{constructor(e){if(super(e),e.type!==Hl.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let s;n===void 0?n=t:t!==void 0&&(s=t);const i=[],r=[];let o=0;for(const a of e)i[o]=s?s(a,o):o,r[o]=n(a,o),o++;return{values:r,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,s]){const i=qh(e),{values:r,keys:o}=this.dt(t,n,s);if(!Array.isArray(i))return this.ut=o,r;const a=this.ut??(this.ut=[]),l=[];let c,u,p=0,d=i.length-1,f=0,b=r.length-1;for(;p<=d&&f<=b;)if(i[p]===null)p++;else if(i[d]===null)d--;else if(a[p]===o[f])l[f]=Ve(i[p],r[f]),p++,f++;else if(a[d]===o[b])l[b]=Ve(i[d],r[b]),d--,b--;else if(a[p]===o[b])l[b]=Ve(i[p],r[b]),Ot(e,l[b+1],i[p]),p++,b--;else if(a[d]===o[f])l[f]=Ve(i[d],r[f]),Ot(e,i[p],i[d]),d--,f++;else if(c===void 0&&(c=jo(o,f,b),u=jo(a,p,d)),c.has(a[p]))if(c.has(a[d])){const w=u.get(o[f]),S=w!==void 0?i[w]:null;if(S===null){const T=Ot(e,i[p]);Ve(T,r[f]),l[f]=T}else l[f]=Ve(S,r[f]),Ot(e,i[p],S),i[w]=null;f++}else Vs(i[d]),d--;else Vs(i[p]),p++;for(;f<=b;){const w=Ot(e,l[b+1]);Ve(w,r[f]),l[f++]=w}for(;p<=d;){const w=i[p++];w!==null&&Vs(w)}return this.ut=o,Hh(e,l),Fe}});class Ai extends Gl{constructor(t){if(super(t),this.it=k,t.type!==Hl.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===Fe)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:[]}}}Ai.directiveName="unsafeHTML",Ai.resultType=1;const $i=ql(Ai);const{entries:Vl,setPrototypeOf:Ho,isFrozen:Vh,getPrototypeOf:Qh,getOwnPropertyDescriptor:Yh}=Object;let{freeze:ae,seal:de,create:Ei}=Object,{apply:Ti,construct:Ci}=typeof Reflect<"u"&&Reflect;ae||(ae=function(t){return t});de||(de=function(t){return t});Ti||(Ti=function(t,n){for(var s=arguments.length,i=new Array(s>2?s-2:0),r=2;r<s;r++)i[r-2]=arguments[r];return t.apply(n,i)});Ci||(Ci=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return new t(...s)});const Rn=le(Array.prototype.forEach),Xh=le(Array.prototype.lastIndexOf),qo=le(Array.prototype.pop),Bt=le(Array.prototype.push),Zh=le(Array.prototype.splice),jn=le(String.prototype.toLowerCase),Qs=le(String.prototype.toString),Ys=le(String.prototype.match),Ft=le(String.prototype.replace),Jh=le(String.prototype.indexOf),ef=le(String.prototype.trim),he=le(Object.prototype.hasOwnProperty),re=le(RegExp.prototype.test),Ut=tf(TypeError);function le(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return Ti(e,t,s)}}function tf(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return Ci(e,n)}}function D(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:jn;Ho&&Ho(e,null);let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){const r=n(i);r!==i&&(Vh(t)||(t[s]=r),i=r)}e[i]=!0}return e}function nf(e){for(let t=0;t<e.length;t++)he(e,t)||(e[t]=null);return e}function ke(e){const t=Ei(null);for(const[n,s]of Vl(e))he(e,n)&&(Array.isArray(s)?t[n]=nf(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=ke(s):t[n]=s);return t}function Wt(e,t){for(;e!==null;){const s=Yh(e,t);if(s){if(s.get)return le(s.get);if(typeof s.value=="function")return le(s.value)}e=Qh(e)}function n(){return null}return n}const Go=ae(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Xs=ae(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Zs=ae(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),sf=ae(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Js=ae(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),rf=ae(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Vo=ae(["#text"]),Qo=ae(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),ei=ae(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Yo=ae(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),In=ae(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),of=de(/\{\{[\w\W]*|[\w\W]*\}\}/gm),af=de(/<%[\w\W]*|[\w\W]*%>/gm),lf=de(/\$\{[\w\W]*/gm),cf=de(/^data-[\-\w.\u00B7-\uFFFF]+$/),uf=de(/^aria-[\-\w]+$/),Ql=de(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),df=de(/^(?:\w+script|data):/i),pf=de(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Yl=de(/^html$/i),hf=de(/^[a-z][.\w]*(-[.\w]+)+$/i);var Xo=Object.freeze({__proto__:null,ARIA_ATTR:uf,ATTR_WHITESPACE:pf,CUSTOM_ELEMENT:hf,DATA_ATTR:cf,DOCTYPE_NAME:Yl,ERB_EXPR:af,IS_ALLOWED_URI:Ql,IS_SCRIPT_OR_DATA:df,MUSTACHE_EXPR:of,TMPLIT_EXPR:lf});const Kt={element:1,text:3,progressingInstruction:7,comment:8,document:9},ff=function(){return typeof window>"u"?null:window},gf=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(s=n.getAttribute(i));const r="dompurify"+(s?"#"+s:"");try{return t.createPolicy(r,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},Zo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Xl(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ff();const t=P=>Xl(P);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==Kt.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,i=s.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:d,trustedTypes:f}=e,b=l.prototype,w=Wt(b,"cloneNode"),S=Wt(b,"remove"),T=Wt(b,"nextSibling"),A=Wt(b,"childNodes"),E=Wt(b,"parentNode");if(typeof o=="function"){const P=n.createElement("template");P.content&&P.content.ownerDocument&&(n=P.content.ownerDocument)}let C,R="";const{implementation:U,createNodeIterator:Q,createDocumentFragment:ze,getElementsByTagName:Lt}=n,{importNode:gn}=s;let J=Zo();t.isSupported=typeof Vl=="function"&&typeof E=="function"&&U&&U.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Pt,ERB_EXPR:ut,TMPLIT_EXPR:je,DATA_ATTR:xs,ARIA_ATTR:As,IS_SCRIPT_OR_DATA:$s,ATTR_WHITESPACE:mn,CUSTOM_ELEMENT:Es}=Xo;let{IS_ALLOWED_URI:yn}=Xo,G=null;const vn=D({},[...Go,...Xs,...Zs,...Js,...Vo]);let V=null;const bn=D({},[...Qo,...ei,...Yo,...In]);let j=Object.seal(Ei(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),He=null,Rt=null;const Re=Object.seal(Ei(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let wn=!0,x=!0,_=!1,I=!0,N=!1,H=!0,K=!1,ie=!1,Ie=!1,dt=!1,kn=!1,Sn=!1,Or=!0,Br=!1;const Yc="user-content-";let Ts=!0,It=!1,pt={},ye=null;const Cs=D({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Fr=null;const Ur=D({},["audio","video","img","source","image","track"]);let _s=null;const Wr=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),xn="http://www.w3.org/1998/Math/MathML",An="http://www.w3.org/2000/svg",Ae="http://www.w3.org/1999/xhtml";let ht=Ae,Ms=!1,Ls=null;const Xc=D({},[xn,An,Ae],Qs);let $n=D({},["mi","mo","mn","ms","mtext"]),En=D({},["annotation-xml"]);const Zc=D({},["title","style","font","a","script"]);let Nt=null;const Jc=["application/xhtml+xml","text/html"],eu="text/html";let X=null,ft=null;const tu=n.createElement("form"),Kr=function(v){return v instanceof RegExp||v instanceof Function},Ps=function(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ft&&ft===v)){if((!v||typeof v!="object")&&(v={}),v=ke(v),Nt=Jc.indexOf(v.PARSER_MEDIA_TYPE)===-1?eu:v.PARSER_MEDIA_TYPE,X=Nt==="application/xhtml+xml"?Qs:jn,G=he(v,"ALLOWED_TAGS")?D({},v.ALLOWED_TAGS,X):vn,V=he(v,"ALLOWED_ATTR")?D({},v.ALLOWED_ATTR,X):bn,Ls=he(v,"ALLOWED_NAMESPACES")?D({},v.ALLOWED_NAMESPACES,Qs):Xc,_s=he(v,"ADD_URI_SAFE_ATTR")?D(ke(Wr),v.ADD_URI_SAFE_ATTR,X):Wr,Fr=he(v,"ADD_DATA_URI_TAGS")?D(ke(Ur),v.ADD_DATA_URI_TAGS,X):Ur,ye=he(v,"FORBID_CONTENTS")?D({},v.FORBID_CONTENTS,X):Cs,He=he(v,"FORBID_TAGS")?D({},v.FORBID_TAGS,X):ke({}),Rt=he(v,"FORBID_ATTR")?D({},v.FORBID_ATTR,X):ke({}),pt=he(v,"USE_PROFILES")?v.USE_PROFILES:!1,wn=v.ALLOW_ARIA_ATTR!==!1,x=v.ALLOW_DATA_ATTR!==!1,_=v.ALLOW_UNKNOWN_PROTOCOLS||!1,I=v.ALLOW_SELF_CLOSE_IN_ATTR!==!1,N=v.SAFE_FOR_TEMPLATES||!1,H=v.SAFE_FOR_XML!==!1,K=v.WHOLE_DOCUMENT||!1,dt=v.RETURN_DOM||!1,kn=v.RETURN_DOM_FRAGMENT||!1,Sn=v.RETURN_TRUSTED_TYPE||!1,Ie=v.FORCE_BODY||!1,Or=v.SANITIZE_DOM!==!1,Br=v.SANITIZE_NAMED_PROPS||!1,Ts=v.KEEP_CONTENT!==!1,It=v.IN_PLACE||!1,yn=v.ALLOWED_URI_REGEXP||Ql,ht=v.NAMESPACE||Ae,$n=v.MATHML_TEXT_INTEGRATION_POINTS||$n,En=v.HTML_INTEGRATION_POINTS||En,j=v.CUSTOM_ELEMENT_HANDLING||{},v.CUSTOM_ELEMENT_HANDLING&&Kr(v.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(j.tagNameCheck=v.CUSTOM_ELEMENT_HANDLING.tagNameCheck),v.CUSTOM_ELEMENT_HANDLING&&Kr(v.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(j.attributeNameCheck=v.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),v.CUSTOM_ELEMENT_HANDLING&&typeof v.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(j.allowCustomizedBuiltInElements=v.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),N&&(x=!1),kn&&(dt=!0),pt&&(G=D({},Vo),V=[],pt.html===!0&&(D(G,Go),D(V,Qo)),pt.svg===!0&&(D(G,Xs),D(V,ei),D(V,In)),pt.svgFilters===!0&&(D(G,Zs),D(V,ei),D(V,In)),pt.mathMl===!0&&(D(G,Js),D(V,Yo),D(V,In))),v.ADD_TAGS&&(typeof v.ADD_TAGS=="function"?Re.tagCheck=v.ADD_TAGS:(G===vn&&(G=ke(G)),D(G,v.ADD_TAGS,X))),v.ADD_ATTR&&(typeof v.ADD_ATTR=="function"?Re.attributeCheck=v.ADD_ATTR:(V===bn&&(V=ke(V)),D(V,v.ADD_ATTR,X))),v.ADD_URI_SAFE_ATTR&&D(_s,v.ADD_URI_SAFE_ATTR,X),v.FORBID_CONTENTS&&(ye===Cs&&(ye=ke(ye)),D(ye,v.FORBID_CONTENTS,X)),v.ADD_FORBID_CONTENTS&&(ye===Cs&&(ye=ke(ye)),D(ye,v.ADD_FORBID_CONTENTS,X)),Ts&&(G["#text"]=!0),K&&D(G,["html","head","body"]),G.table&&(D(G,["tbody"]),delete He.tbody),v.TRUSTED_TYPES_POLICY){if(typeof v.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ut('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof v.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ut('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');C=v.TRUSTED_TYPES_POLICY,R=C.createHTML("")}else C===void 0&&(C=gf(f,i)),C!==null&&typeof R=="string"&&(R=C.createHTML(""));ae&&ae(v),ft=v}},zr=D({},[...Xs,...Zs,...sf]),jr=D({},[...Js,...rf]),nu=function(v){let $=E(v);(!$||!$.tagName)&&($={namespaceURI:ht,tagName:"template"});const L=jn(v.tagName),z=jn($.tagName);return Ls[v.namespaceURI]?v.namespaceURI===An?$.namespaceURI===Ae?L==="svg":$.namespaceURI===xn?L==="svg"&&(z==="annotation-xml"||$n[z]):!!zr[L]:v.namespaceURI===xn?$.namespaceURI===Ae?L==="math":$.namespaceURI===An?L==="math"&&En[z]:!!jr[L]:v.namespaceURI===Ae?$.namespaceURI===An&&!En[z]||$.namespaceURI===xn&&!$n[z]?!1:!jr[L]&&(Zc[L]||!zr[L]):!!(Nt==="application/xhtml+xml"&&Ls[v.namespaceURI]):!1},ve=function(v){Bt(t.removed,{element:v});try{E(v).removeChild(v)}catch{S(v)}},qe=function(v,$){try{Bt(t.removed,{attribute:$.getAttributeNode(v),from:$})}catch{Bt(t.removed,{attribute:null,from:$})}if($.removeAttribute(v),v==="is")if(dt||kn)try{ve($)}catch{}else try{$.setAttribute(v,"")}catch{}},Hr=function(v){let $=null,L=null;if(Ie)v="<remove></remove>"+v;else{const Y=Ys(v,/^[\r\n\t ]+/);L=Y&&Y[0]}Nt==="application/xhtml+xml"&&ht===Ae&&(v='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+v+"</body></html>");const z=C?C.createHTML(v):v;if(ht===Ae)try{$=new d().parseFromString(z,Nt)}catch{}if(!$||!$.documentElement){$=U.createDocument(ht,"template",null);try{$.documentElement.innerHTML=Ms?R:z}catch{}}const te=$.body||$.documentElement;return v&&L&&te.insertBefore(n.createTextNode(L),te.childNodes[0]||null),ht===Ae?Lt.call($,K?"html":"body")[0]:K?$.documentElement:te},qr=function(v){return Q.call(v.ownerDocument||v,v,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Rs=function(v){return v instanceof p&&(typeof v.nodeName!="string"||typeof v.textContent!="string"||typeof v.removeChild!="function"||!(v.attributes instanceof u)||typeof v.removeAttribute!="function"||typeof v.setAttribute!="function"||typeof v.namespaceURI!="string"||typeof v.insertBefore!="function"||typeof v.hasChildNodes!="function")},Gr=function(v){return typeof a=="function"&&v instanceof a};function $e(P,v,$){Rn(P,L=>{L.call(t,v,$,ft)})}const Vr=function(v){let $=null;if($e(J.beforeSanitizeElements,v,null),Rs(v))return ve(v),!0;const L=X(v.nodeName);if($e(J.uponSanitizeElement,v,{tagName:L,allowedTags:G}),H&&v.hasChildNodes()&&!Gr(v.firstElementChild)&&re(/<[/\w!]/g,v.innerHTML)&&re(/<[/\w!]/g,v.textContent)||v.nodeType===Kt.progressingInstruction||H&&v.nodeType===Kt.comment&&re(/<[/\w]/g,v.data))return ve(v),!0;if(!(Re.tagCheck instanceof Function&&Re.tagCheck(L))&&(!G[L]||He[L])){if(!He[L]&&Yr(L)&&(j.tagNameCheck instanceof RegExp&&re(j.tagNameCheck,L)||j.tagNameCheck instanceof Function&&j.tagNameCheck(L)))return!1;if(Ts&&!ye[L]){const z=E(v)||v.parentNode,te=A(v)||v.childNodes;if(te&&z){const Y=te.length;for(let ce=Y-1;ce>=0;--ce){const Ee=w(te[ce],!0);Ee.__removalCount=(v.__removalCount||0)+1,z.insertBefore(Ee,T(v))}}}return ve(v),!0}return v instanceof l&&!nu(v)||(L==="noscript"||L==="noembed"||L==="noframes")&&re(/<\/no(script|embed|frames)/i,v.innerHTML)?(ve(v),!0):(N&&v.nodeType===Kt.text&&($=v.textContent,Rn([Pt,ut,je],z=>{$=Ft($,z," ")}),v.textContent!==$&&(Bt(t.removed,{element:v.cloneNode()}),v.textContent=$)),$e(J.afterSanitizeElements,v,null),!1)},Qr=function(v,$,L){if(Or&&($==="id"||$==="name")&&(L in n||L in tu))return!1;if(!(x&&!Rt[$]&&re(xs,$))){if(!(wn&&re(As,$))){if(!(Re.attributeCheck instanceof Function&&Re.attributeCheck($,v))){if(!V[$]||Rt[$]){if(!(Yr(v)&&(j.tagNameCheck instanceof RegExp&&re(j.tagNameCheck,v)||j.tagNameCheck instanceof Function&&j.tagNameCheck(v))&&(j.attributeNameCheck instanceof RegExp&&re(j.attributeNameCheck,$)||j.attributeNameCheck instanceof Function&&j.attributeNameCheck($,v))||$==="is"&&j.allowCustomizedBuiltInElements&&(j.tagNameCheck instanceof RegExp&&re(j.tagNameCheck,L)||j.tagNameCheck instanceof Function&&j.tagNameCheck(L))))return!1}else if(!_s[$]){if(!re(yn,Ft(L,mn,""))){if(!(($==="src"||$==="xlink:href"||$==="href")&&v!=="script"&&Jh(L,"data:")===0&&Fr[v])){if(!(_&&!re($s,Ft(L,mn,"")))){if(L)return!1}}}}}}}return!0},Yr=function(v){return v!=="annotation-xml"&&Ys(v,Es)},Xr=function(v){$e(J.beforeSanitizeAttributes,v,null);const{attributes:$}=v;if(!$||Rs(v))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:V,forceKeepAttr:void 0};let z=$.length;for(;z--;){const te=$[z],{name:Y,namespaceURI:ce,value:Ee}=te,gt=X(Y),Is=Ee;let ee=Y==="value"?Is:ef(Is);if(L.attrName=gt,L.attrValue=ee,L.keepAttr=!0,L.forceKeepAttr=void 0,$e(J.uponSanitizeAttribute,v,L),ee=L.attrValue,Br&&(gt==="id"||gt==="name")&&(qe(Y,v),ee=Yc+ee),H&&re(/((--!?|])>)|<\/(style|title|textarea)/i,ee)){qe(Y,v);continue}if(gt==="attributename"&&Ys(ee,"href")){qe(Y,v);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){qe(Y,v);continue}if(!I&&re(/\/>/i,ee)){qe(Y,v);continue}N&&Rn([Pt,ut,je],Jr=>{ee=Ft(ee,Jr," ")});const Zr=X(v.nodeName);if(!Qr(Zr,gt,ee)){qe(Y,v);continue}if(C&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!ce)switch(f.getAttributeType(Zr,gt)){case"TrustedHTML":{ee=C.createHTML(ee);break}case"TrustedScriptURL":{ee=C.createScriptURL(ee);break}}if(ee!==Is)try{ce?v.setAttributeNS(ce,Y,ee):v.setAttribute(Y,ee),Rs(v)?ve(v):qo(t.removed)}catch{qe(Y,v)}}$e(J.afterSanitizeAttributes,v,null)},su=function P(v){let $=null;const L=qr(v);for($e(J.beforeSanitizeShadowDOM,v,null);$=L.nextNode();)$e(J.uponSanitizeShadowNode,$,null),Vr($),Xr($),$.content instanceof r&&P($.content);$e(J.afterSanitizeShadowDOM,v,null)};return t.sanitize=function(P){let v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},$=null,L=null,z=null,te=null;if(Ms=!P,Ms&&(P="<!-->"),typeof P!="string"&&!Gr(P))if(typeof P.toString=="function"){if(P=P.toString(),typeof P!="string")throw Ut("dirty is not a string, aborting")}else throw Ut("toString is not a function");if(!t.isSupported)return P;if(ie||Ps(v),t.removed=[],typeof P=="string"&&(It=!1),It){if(P.nodeName){const Ee=X(P.nodeName);if(!G[Ee]||He[Ee])throw Ut("root node is forbidden and cannot be sanitized in-place")}}else if(P instanceof a)$=Hr("<!---->"),L=$.ownerDocument.importNode(P,!0),L.nodeType===Kt.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?$=L:$.appendChild(L);else{if(!dt&&!N&&!K&&P.indexOf("<")===-1)return C&&Sn?C.createHTML(P):P;if($=Hr(P),!$)return dt?null:Sn?R:""}$&&Ie&&ve($.firstChild);const Y=qr(It?P:$);for(;z=Y.nextNode();)Vr(z),Xr(z),z.content instanceof r&&su(z.content);if(It)return P;if(dt){if(kn)for(te=ze.call($.ownerDocument);$.firstChild;)te.appendChild($.firstChild);else te=$;return(V.shadowroot||V.shadowrootmode)&&(te=gn.call(s,te,!0)),te}let ce=K?$.outerHTML:$.innerHTML;return K&&G["!doctype"]&&$.ownerDocument&&$.ownerDocument.doctype&&$.ownerDocument.doctype.name&&re(Yl,$.ownerDocument.doctype.name)&&(ce="<!DOCTYPE "+$.ownerDocument.doctype.name+`>
|
|
1731
|
-
`+ce),N&&Rn([Pt,ut,je],Ee=>{ce=Ft(ce,Ee," ")}),C&&Sn?C.createHTML(ce):ce},t.setConfig=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};
|
|
1732
|
-
]`).replace("lheading",
|
|
1732
|
+
`}const Vl={CHILD:2},Ql=e=>(...t)=>({_$litDirective$:e,values:t});let Yl=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,s){this._$Ct=t,this._$AM=n,this._$Ci=s}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:jh}=Mu,Ho=e=>e,qo=()=>document.createComment(""),Ot=(e,t,n)=>{var r;const s=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0){const o=s.insertBefore(qo(),i),a=s.insertBefore(qo(),i);n=new jh(o,a,e,e.options)}else{const o=n._$AB.nextSibling,a=n._$AM,l=a!==e;if(l){let c;(r=n._$AQ)==null||r.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==a._$AU&&n._$AP(c)}if(o!==i||l){let c=n._$AA;for(;c!==o;){const u=Ho(c).nextSibling;Ho(s).insertBefore(c,i),c=u}}}return n},Ve=(e,t,n=e)=>(e._$AI(t,n),e),Hh={},qh=(e,t=Hh)=>e._$AH=t,Gh=e=>e._$AH,Qs=e=>{e._$AR(),e._$AA.remove()};const Go=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s},Vh=Ql(class extends Yl{constructor(e){if(super(e),e.type!==Vl.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let s;n===void 0?n=t:t!==void 0&&(s=t);const i=[],r=[];let o=0;for(const a of e)i[o]=s?s(a,o):o,r[o]=n(a,o),o++;return{values:r,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,s]){const i=Gh(e),{values:r,keys:o}=this.dt(t,n,s);if(!Array.isArray(i))return this.ut=o,r;const a=this.ut??(this.ut=[]),l=[];let c,u,p=0,d=i.length-1,h=0,b=r.length-1;for(;p<=d&&h<=b;)if(i[p]===null)p++;else if(i[d]===null)d--;else if(a[p]===o[h])l[h]=Ve(i[p],r[h]),p++,h++;else if(a[d]===o[b])l[b]=Ve(i[d],r[b]),d--,b--;else if(a[p]===o[b])l[b]=Ve(i[p],r[b]),Ot(e,l[b+1],i[p]),p++,b--;else if(a[d]===o[h])l[h]=Ve(i[d],r[h]),Ot(e,i[p],i[d]),d--,h++;else if(c===void 0&&(c=Go(o,h,b),u=Go(a,p,d)),c.has(a[p]))if(c.has(a[d])){const w=u.get(o[h]),S=w!==void 0?i[w]:null;if(S===null){const T=Ot(e,i[p]);Ve(T,r[h]),l[h]=T}else l[h]=Ve(S,r[h]),Ot(e,i[p],S),i[w]=null;h++}else Qs(i[d]),d--;else Qs(i[p]),p++;for(;h<=b;){const w=Ot(e,l[b+1]);Ve(w,r[h]),l[h++]=w}for(;p<=d;){const w=i[p++];w!==null&&Qs(w)}return this.ut=o,qh(e,l),Fe}});class $i extends Yl{constructor(t){if(super(t),this.it=k,t.type!==Vl.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===Fe)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:[]}}}$i.directiveName="unsafeHTML",$i.resultType=1;const Ei=Ql($i);const{entries:Xl,setPrototypeOf:Vo,isFrozen:Qh,getPrototypeOf:Yh,getOwnPropertyDescriptor:Xh}=Object;let{freeze:ae,seal:de,create:Ti}=Object,{apply:Ci,construct:_i}=typeof Reflect<"u"&&Reflect;ae||(ae=function(t){return t});de||(de=function(t){return t});Ci||(Ci=function(t,n){for(var s=arguments.length,i=new Array(s>2?s-2:0),r=2;r<s;r++)i[r-2]=arguments[r];return t.apply(n,i)});_i||(_i=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return new t(...s)});const Rn=le(Array.prototype.forEach),Zh=le(Array.prototype.lastIndexOf),Qo=le(Array.prototype.pop),Bt=le(Array.prototype.push),Jh=le(Array.prototype.splice),jn=le(String.prototype.toLowerCase),Ys=le(String.prototype.toString),Xs=le(String.prototype.match),Ft=le(String.prototype.replace),ef=le(String.prototype.indexOf),tf=le(String.prototype.trim),he=le(Object.prototype.hasOwnProperty),re=le(RegExp.prototype.test),Ut=nf(TypeError);function le(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return Ci(e,t,s)}}function nf(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return _i(e,n)}}function D(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:jn;Vo&&Vo(e,null);let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){const r=n(i);r!==i&&(Qh(t)||(t[s]=r),i=r)}e[i]=!0}return e}function sf(e){for(let t=0;t<e.length;t++)he(e,t)||(e[t]=null);return e}function ke(e){const t=Ti(null);for(const[n,s]of Xl(e))he(e,n)&&(Array.isArray(s)?t[n]=sf(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=ke(s):t[n]=s);return t}function Wt(e,t){for(;e!==null;){const s=Xh(e,t);if(s){if(s.get)return le(s.get);if(typeof s.value=="function")return le(s.value)}e=Yh(e)}function n(){return null}return n}const Yo=ae(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Zs=ae(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Js=ae(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),rf=ae(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ei=ae(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),of=ae(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Xo=ae(["#text"]),Zo=ae(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),ti=ae(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Jo=ae(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),In=ae(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),af=de(/\{\{[\w\W]*|[\w\W]*\}\}/gm),lf=de(/<%[\w\W]*|[\w\W]*%>/gm),cf=de(/\$\{[\w\W]*/gm),uf=de(/^data-[\-\w.\u00B7-\uFFFF]+$/),df=de(/^aria-[\-\w]+$/),Zl=de(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),pf=de(/^(?:\w+script|data):/i),hf=de(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Jl=de(/^html$/i),ff=de(/^[a-z][.\w]*(-[.\w]+)+$/i);var ea=Object.freeze({__proto__:null,ARIA_ATTR:df,ATTR_WHITESPACE:hf,CUSTOM_ELEMENT:ff,DATA_ATTR:uf,DOCTYPE_NAME:Jl,ERB_EXPR:lf,IS_ALLOWED_URI:Zl,IS_SCRIPT_OR_DATA:pf,MUSTACHE_EXPR:af,TMPLIT_EXPR:cf});const Kt={element:1,text:3,progressingInstruction:7,comment:8,document:9},gf=function(){return typeof window>"u"?null:window},mf=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(s=n.getAttribute(i));const r="dompurify"+(s?"#"+s:"");try{return t.createPolicy(r,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},ta=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ec(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:gf();const t=P=>ec(P);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==Kt.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,i=s.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:d,trustedTypes:h}=e,b=l.prototype,w=Wt(b,"cloneNode"),S=Wt(b,"remove"),T=Wt(b,"nextSibling"),A=Wt(b,"childNodes"),E=Wt(b,"parentNode");if(typeof o=="function"){const P=n.createElement("template");P.content&&P.content.ownerDocument&&(n=P.content.ownerDocument)}let C,R="";const{implementation:U,createNodeIterator:Q,createDocumentFragment:ze,getElementsByTagName:Lt}=n,{importNode:gn}=s;let J=ta();t.isSupported=typeof Xl=="function"&&typeof E=="function"&&U&&U.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Pt,ERB_EXPR:ut,TMPLIT_EXPR:je,DATA_ATTR:As,ARIA_ATTR:$s,IS_SCRIPT_OR_DATA:Es,ATTR_WHITESPACE:mn,CUSTOM_ELEMENT:Ts}=ea;let{IS_ALLOWED_URI:yn}=ea,G=null;const vn=D({},[...Yo,...Zs,...Js,...ei,...Xo]);let V=null;const bn=D({},[...Zo,...ti,...Jo,...In]);let j=Object.seal(Ti(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),He=null,Rt=null;const Re=Object.seal(Ti(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let wn=!0,x=!0,_=!1,I=!0,N=!1,H=!0,K=!1,ie=!1,Ie=!1,dt=!1,kn=!1,Sn=!1,Br=!0,Fr=!1;const Jc="user-content-";let Cs=!0,It=!1,pt={},ye=null;const _s=D({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ur=null;const Wr=D({},["audio","video","img","source","image","track"]);let Ms=null;const Kr=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),xn="http://www.w3.org/1998/Math/MathML",An="http://www.w3.org/2000/svg",Ae="http://www.w3.org/1999/xhtml";let ht=Ae,Ls=!1,Ps=null;const eu=D({},[xn,An,Ae],Ys);let $n=D({},["mi","mo","mn","ms","mtext"]),En=D({},["annotation-xml"]);const tu=D({},["title","style","font","a","script"]);let Nt=null;const nu=["application/xhtml+xml","text/html"],su="text/html";let X=null,ft=null;const iu=n.createElement("form"),zr=function(v){return v instanceof RegExp||v instanceof Function},Rs=function(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ft&&ft===v)){if((!v||typeof v!="object")&&(v={}),v=ke(v),Nt=nu.indexOf(v.PARSER_MEDIA_TYPE)===-1?su:v.PARSER_MEDIA_TYPE,X=Nt==="application/xhtml+xml"?Ys:jn,G=he(v,"ALLOWED_TAGS")?D({},v.ALLOWED_TAGS,X):vn,V=he(v,"ALLOWED_ATTR")?D({},v.ALLOWED_ATTR,X):bn,Ps=he(v,"ALLOWED_NAMESPACES")?D({},v.ALLOWED_NAMESPACES,Ys):eu,Ms=he(v,"ADD_URI_SAFE_ATTR")?D(ke(Kr),v.ADD_URI_SAFE_ATTR,X):Kr,Ur=he(v,"ADD_DATA_URI_TAGS")?D(ke(Wr),v.ADD_DATA_URI_TAGS,X):Wr,ye=he(v,"FORBID_CONTENTS")?D({},v.FORBID_CONTENTS,X):_s,He=he(v,"FORBID_TAGS")?D({},v.FORBID_TAGS,X):ke({}),Rt=he(v,"FORBID_ATTR")?D({},v.FORBID_ATTR,X):ke({}),pt=he(v,"USE_PROFILES")?v.USE_PROFILES:!1,wn=v.ALLOW_ARIA_ATTR!==!1,x=v.ALLOW_DATA_ATTR!==!1,_=v.ALLOW_UNKNOWN_PROTOCOLS||!1,I=v.ALLOW_SELF_CLOSE_IN_ATTR!==!1,N=v.SAFE_FOR_TEMPLATES||!1,H=v.SAFE_FOR_XML!==!1,K=v.WHOLE_DOCUMENT||!1,dt=v.RETURN_DOM||!1,kn=v.RETURN_DOM_FRAGMENT||!1,Sn=v.RETURN_TRUSTED_TYPE||!1,Ie=v.FORCE_BODY||!1,Br=v.SANITIZE_DOM!==!1,Fr=v.SANITIZE_NAMED_PROPS||!1,Cs=v.KEEP_CONTENT!==!1,It=v.IN_PLACE||!1,yn=v.ALLOWED_URI_REGEXP||Zl,ht=v.NAMESPACE||Ae,$n=v.MATHML_TEXT_INTEGRATION_POINTS||$n,En=v.HTML_INTEGRATION_POINTS||En,j=v.CUSTOM_ELEMENT_HANDLING||{},v.CUSTOM_ELEMENT_HANDLING&&zr(v.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(j.tagNameCheck=v.CUSTOM_ELEMENT_HANDLING.tagNameCheck),v.CUSTOM_ELEMENT_HANDLING&&zr(v.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(j.attributeNameCheck=v.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),v.CUSTOM_ELEMENT_HANDLING&&typeof v.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(j.allowCustomizedBuiltInElements=v.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),N&&(x=!1),kn&&(dt=!0),pt&&(G=D({},Xo),V=[],pt.html===!0&&(D(G,Yo),D(V,Zo)),pt.svg===!0&&(D(G,Zs),D(V,ti),D(V,In)),pt.svgFilters===!0&&(D(G,Js),D(V,ti),D(V,In)),pt.mathMl===!0&&(D(G,ei),D(V,Jo),D(V,In))),v.ADD_TAGS&&(typeof v.ADD_TAGS=="function"?Re.tagCheck=v.ADD_TAGS:(G===vn&&(G=ke(G)),D(G,v.ADD_TAGS,X))),v.ADD_ATTR&&(typeof v.ADD_ATTR=="function"?Re.attributeCheck=v.ADD_ATTR:(V===bn&&(V=ke(V)),D(V,v.ADD_ATTR,X))),v.ADD_URI_SAFE_ATTR&&D(Ms,v.ADD_URI_SAFE_ATTR,X),v.FORBID_CONTENTS&&(ye===_s&&(ye=ke(ye)),D(ye,v.FORBID_CONTENTS,X)),v.ADD_FORBID_CONTENTS&&(ye===_s&&(ye=ke(ye)),D(ye,v.ADD_FORBID_CONTENTS,X)),Cs&&(G["#text"]=!0),K&&D(G,["html","head","body"]),G.table&&(D(G,["tbody"]),delete He.tbody),v.TRUSTED_TYPES_POLICY){if(typeof v.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ut('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof v.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ut('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');C=v.TRUSTED_TYPES_POLICY,R=C.createHTML("")}else C===void 0&&(C=mf(h,i)),C!==null&&typeof R=="string"&&(R=C.createHTML(""));ae&&ae(v),ft=v}},jr=D({},[...Zs,...Js,...rf]),Hr=D({},[...ei,...of]),ru=function(v){let $=E(v);(!$||!$.tagName)&&($={namespaceURI:ht,tagName:"template"});const L=jn(v.tagName),z=jn($.tagName);return Ps[v.namespaceURI]?v.namespaceURI===An?$.namespaceURI===Ae?L==="svg":$.namespaceURI===xn?L==="svg"&&(z==="annotation-xml"||$n[z]):!!jr[L]:v.namespaceURI===xn?$.namespaceURI===Ae?L==="math":$.namespaceURI===An?L==="math"&&En[z]:!!Hr[L]:v.namespaceURI===Ae?$.namespaceURI===An&&!En[z]||$.namespaceURI===xn&&!$n[z]?!1:!Hr[L]&&(tu[L]||!jr[L]):!!(Nt==="application/xhtml+xml"&&Ps[v.namespaceURI]):!1},ve=function(v){Bt(t.removed,{element:v});try{E(v).removeChild(v)}catch{S(v)}},qe=function(v,$){try{Bt(t.removed,{attribute:$.getAttributeNode(v),from:$})}catch{Bt(t.removed,{attribute:null,from:$})}if($.removeAttribute(v),v==="is")if(dt||kn)try{ve($)}catch{}else try{$.setAttribute(v,"")}catch{}},qr=function(v){let $=null,L=null;if(Ie)v="<remove></remove>"+v;else{const Y=Xs(v,/^[\r\n\t ]+/);L=Y&&Y[0]}Nt==="application/xhtml+xml"&&ht===Ae&&(v='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+v+"</body></html>");const z=C?C.createHTML(v):v;if(ht===Ae)try{$=new d().parseFromString(z,Nt)}catch{}if(!$||!$.documentElement){$=U.createDocument(ht,"template",null);try{$.documentElement.innerHTML=Ls?R:z}catch{}}const te=$.body||$.documentElement;return v&&L&&te.insertBefore(n.createTextNode(L),te.childNodes[0]||null),ht===Ae?Lt.call($,K?"html":"body")[0]:K?$.documentElement:te},Gr=function(v){return Q.call(v.ownerDocument||v,v,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Is=function(v){return v instanceof p&&(typeof v.nodeName!="string"||typeof v.textContent!="string"||typeof v.removeChild!="function"||!(v.attributes instanceof u)||typeof v.removeAttribute!="function"||typeof v.setAttribute!="function"||typeof v.namespaceURI!="string"||typeof v.insertBefore!="function"||typeof v.hasChildNodes!="function")},Vr=function(v){return typeof a=="function"&&v instanceof a};function $e(P,v,$){Rn(P,L=>{L.call(t,v,$,ft)})}const Qr=function(v){let $=null;if($e(J.beforeSanitizeElements,v,null),Is(v))return ve(v),!0;const L=X(v.nodeName);if($e(J.uponSanitizeElement,v,{tagName:L,allowedTags:G}),H&&v.hasChildNodes()&&!Vr(v.firstElementChild)&&re(/<[/\w!]/g,v.innerHTML)&&re(/<[/\w!]/g,v.textContent)||v.nodeType===Kt.progressingInstruction||H&&v.nodeType===Kt.comment&&re(/<[/\w]/g,v.data))return ve(v),!0;if(!(Re.tagCheck instanceof Function&&Re.tagCheck(L))&&(!G[L]||He[L])){if(!He[L]&&Xr(L)&&(j.tagNameCheck instanceof RegExp&&re(j.tagNameCheck,L)||j.tagNameCheck instanceof Function&&j.tagNameCheck(L)))return!1;if(Cs&&!ye[L]){const z=E(v)||v.parentNode,te=A(v)||v.childNodes;if(te&&z){const Y=te.length;for(let ce=Y-1;ce>=0;--ce){const Ee=w(te[ce],!0);Ee.__removalCount=(v.__removalCount||0)+1,z.insertBefore(Ee,T(v))}}}return ve(v),!0}return v instanceof l&&!ru(v)||(L==="noscript"||L==="noembed"||L==="noframes")&&re(/<\/no(script|embed|frames)/i,v.innerHTML)?(ve(v),!0):(N&&v.nodeType===Kt.text&&($=v.textContent,Rn([Pt,ut,je],z=>{$=Ft($,z," ")}),v.textContent!==$&&(Bt(t.removed,{element:v.cloneNode()}),v.textContent=$)),$e(J.afterSanitizeElements,v,null),!1)},Yr=function(v,$,L){if(Br&&($==="id"||$==="name")&&(L in n||L in iu))return!1;if(!(x&&!Rt[$]&&re(As,$))){if(!(wn&&re($s,$))){if(!(Re.attributeCheck instanceof Function&&Re.attributeCheck($,v))){if(!V[$]||Rt[$]){if(!(Xr(v)&&(j.tagNameCheck instanceof RegExp&&re(j.tagNameCheck,v)||j.tagNameCheck instanceof Function&&j.tagNameCheck(v))&&(j.attributeNameCheck instanceof RegExp&&re(j.attributeNameCheck,$)||j.attributeNameCheck instanceof Function&&j.attributeNameCheck($,v))||$==="is"&&j.allowCustomizedBuiltInElements&&(j.tagNameCheck instanceof RegExp&&re(j.tagNameCheck,L)||j.tagNameCheck instanceof Function&&j.tagNameCheck(L))))return!1}else if(!Ms[$]){if(!re(yn,Ft(L,mn,""))){if(!(($==="src"||$==="xlink:href"||$==="href")&&v!=="script"&&ef(L,"data:")===0&&Ur[v])){if(!(_&&!re(Es,Ft(L,mn,"")))){if(L)return!1}}}}}}}return!0},Xr=function(v){return v!=="annotation-xml"&&Xs(v,Ts)},Zr=function(v){$e(J.beforeSanitizeAttributes,v,null);const{attributes:$}=v;if(!$||Is(v))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:V,forceKeepAttr:void 0};let z=$.length;for(;z--;){const te=$[z],{name:Y,namespaceURI:ce,value:Ee}=te,gt=X(Y),Ns=Ee;let ee=Y==="value"?Ns:tf(Ns);if(L.attrName=gt,L.attrValue=ee,L.keepAttr=!0,L.forceKeepAttr=void 0,$e(J.uponSanitizeAttribute,v,L),ee=L.attrValue,Fr&&(gt==="id"||gt==="name")&&(qe(Y,v),ee=Jc+ee),H&&re(/((--!?|])>)|<\/(style|title|textarea)/i,ee)){qe(Y,v);continue}if(gt==="attributename"&&Xs(ee,"href")){qe(Y,v);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){qe(Y,v);continue}if(!I&&re(/\/>/i,ee)){qe(Y,v);continue}N&&Rn([Pt,ut,je],eo=>{ee=Ft(ee,eo," ")});const Jr=X(v.nodeName);if(!Yr(Jr,gt,ee)){qe(Y,v);continue}if(C&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!ce)switch(h.getAttributeType(Jr,gt)){case"TrustedHTML":{ee=C.createHTML(ee);break}case"TrustedScriptURL":{ee=C.createScriptURL(ee);break}}if(ee!==Ns)try{ce?v.setAttributeNS(ce,Y,ee):v.setAttribute(Y,ee),Is(v)?ve(v):Qo(t.removed)}catch{qe(Y,v)}}$e(J.afterSanitizeAttributes,v,null)},ou=function P(v){let $=null;const L=Gr(v);for($e(J.beforeSanitizeShadowDOM,v,null);$=L.nextNode();)$e(J.uponSanitizeShadowNode,$,null),Qr($),Zr($),$.content instanceof r&&P($.content);$e(J.afterSanitizeShadowDOM,v,null)};return t.sanitize=function(P){let v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},$=null,L=null,z=null,te=null;if(Ls=!P,Ls&&(P="<!-->"),typeof P!="string"&&!Vr(P))if(typeof P.toString=="function"){if(P=P.toString(),typeof P!="string")throw Ut("dirty is not a string, aborting")}else throw Ut("toString is not a function");if(!t.isSupported)return P;if(ie||Rs(v),t.removed=[],typeof P=="string"&&(It=!1),It){if(P.nodeName){const Ee=X(P.nodeName);if(!G[Ee]||He[Ee])throw Ut("root node is forbidden and cannot be sanitized in-place")}}else if(P instanceof a)$=qr("<!---->"),L=$.ownerDocument.importNode(P,!0),L.nodeType===Kt.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?$=L:$.appendChild(L);else{if(!dt&&!N&&!K&&P.indexOf("<")===-1)return C&&Sn?C.createHTML(P):P;if($=qr(P),!$)return dt?null:Sn?R:""}$&&Ie&&ve($.firstChild);const Y=Gr(It?P:$);for(;z=Y.nextNode();)Qr(z),Zr(z),z.content instanceof r&&ou(z.content);if(It)return P;if(dt){if(kn)for(te=ze.call($.ownerDocument);$.firstChild;)te.appendChild($.firstChild);else te=$;return(V.shadowroot||V.shadowrootmode)&&(te=gn.call(s,te,!0)),te}let ce=K?$.outerHTML:$.innerHTML;return K&&G["!doctype"]&&$.ownerDocument&&$.ownerDocument.doctype&&$.ownerDocument.doctype.name&&re(Jl,$.ownerDocument.doctype.name)&&(ce="<!DOCTYPE "+$.ownerDocument.doctype.name+`>
|
|
1733
|
+
`+ce),N&&Rn([Pt,ut,je],Ee=>{ce=Ft(ce,Ee," ")}),C&&Sn?C.createHTML(ce):ce},t.setConfig=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Rs(P),ie=!0},t.clearConfig=function(){ft=null,ie=!1},t.isValidAttribute=function(P,v,$){ft||Rs({});const L=X(P),z=X(v);return Yr(L,z,$)},t.addHook=function(P,v){typeof v=="function"&&Bt(J[P],v)},t.removeHook=function(P,v){if(v!==void 0){const $=Zh(J[P],v);return $===-1?void 0:Jh(J[P],$,1)[0]}return Qo(J[P])},t.removeHooks=function(P){J[P]=[]},t.removeAllHooks=function(){J=ta()},t}var Mi=ec();function wr(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var lt=wr();function tc(e){lt=e}var en={exec:()=>null};function F(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(i,r)=>{let o=typeof r=="string"?r:r.source;return o=o.replace(oe.caret,"$1"),n=n.replace(i,o),s},getRegex:()=>new RegExp(n,t)};return s}var yf=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),oe={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},vf=/^(?:[ \t]*(?:\n|$))+/,bf=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,wf=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,kf=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,kr=/(?:[*+-]|\d{1,9}[.)])/,nc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,sc=F(nc).replace(/bull/g,kr).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(),Sf=F(nc).replace(/bull/g,kr).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(),Sr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,xf=/^[^\n]+/,xr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Af=F(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",xr).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),$f=F(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,kr).getRegex(),ws="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Ar=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ef=F("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Ar).replace("tag",ws).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ic=F(Sr).replace("hr",hn).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",ws).getRegex(),Tf=F(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ic).getRegex(),$r={blockquote:Tf,code:bf,def:Af,fences:wf,heading:kf,hr:hn,html:Ef,lheading:sc,list:$f,newline:vf,paragraph:ic,table:en,text:xf},na=F("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",hn).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",ws).getRegex(),Cf={...$r,lheading:Sf,table:na,paragraph:F(Sr).replace("hr",hn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",na).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",ws).getRegex()},_f={...$r,html:F(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ar).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:en,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:F(Sr).replace("hr",hn).replace("heading",` *#{1,6} *[^
|
|
1734
|
+
]`).replace("lheading",sc).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Mf=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Lf=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,rc=/^( {2,}|\\)\n(?!\s*$)/,Pf=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ks=/[\p{P}\p{S}]/u,Er=/[\s\p{P}\p{S}]/u,oc=/[^\s\p{P}\p{S}]/u,Rf=F(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Er).getRegex(),ac=/(?!~)[\p{P}\p{S}]/u,If=/(?!~)[\s\p{P}\p{S}]/u,Nf=/(?:[^\s\p{P}\p{S}]|~)/u,Df=F(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",yf?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),lc=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Of=F(lc,"u").replace(/punct/g,ks).getRegex(),Bf=F(lc,"u").replace(/punct/g,ac).getRegex(),cc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Ff=F(cc,"gu").replace(/notPunctSpace/g,oc).replace(/punctSpace/g,Er).replace(/punct/g,ks).getRegex(),Uf=F(cc,"gu").replace(/notPunctSpace/g,Nf).replace(/punctSpace/g,If).replace(/punct/g,ac).getRegex(),Wf=F("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,oc).replace(/punctSpace/g,Er).replace(/punct/g,ks).getRegex(),Kf=F(/\\(punct)/,"gu").replace(/punct/g,ks).getRegex(),zf=F(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),jf=F(Ar).replace("(?:-->|$)","-->").getRegex(),Hf=F("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",jf).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),is=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,qf=F(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",is).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),uc=F(/^!?\[(label)\]\[(ref)\]/).replace("label",is).replace("ref",xr).getRegex(),dc=F(/^!?\[(ref)\](?:\[\])?/).replace("ref",xr).getRegex(),Gf=F("reflink|nolink(?!\\()","g").replace("reflink",uc).replace("nolink",dc).getRegex(),sa=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Tr={_backpedal:en,anyPunctuation:Kf,autolink:zf,blockSkip:Df,br:rc,code:Lf,del:en,emStrongLDelim:Of,emStrongRDelimAst:Ff,emStrongRDelimUnd:Wf,escape:Mf,link:qf,nolink:dc,punctuation:Rf,reflink:uc,reflinkSearch:Gf,tag:Hf,text:Pf,url:en},Vf={...Tr,link:F(/^!?\[(label)\]\((.*?)\)/).replace("label",is).getRegex(),reflink:F(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",is).getRegex()},Li={...Tr,emStrongRDelimAst:Uf,emStrongLDelim:Bf,url:F(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",sa).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:F(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",sa).getRegex()},Qf={...Li,br:F(rc).replace("{2,}","*").getRegex(),text:F(Li.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Nn={normal:$r,gfm:Cf,pedantic:_f},zt={normal:Tr,gfm:Li,breaks:Qf,pedantic:Vf},Yf={"&":"&","<":"<",">":">",'"':""","'":"'"},ia=e=>Yf[e];function Ce(e,t){if(t){if(oe.escapeTest.test(e))return e.replace(oe.escapeReplace,ia)}else if(oe.escapeTestNoEncode.test(e))return e.replace(oe.escapeReplaceNoEncode,ia);return e}function ra(e){try{e=encodeURI(e).replace(oe.percentDecode,"%")}catch{return null}return e}function oa(e,t){var r;let n=e.replace(oe.findPipe,(o,a,l)=>{let c=!1,u=a;for(;--u>=0&&l[u]==="\\";)c=!c;return c?"|":" |"}),s=n.split(oe.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!((r=s.at(-1))!=null&&r.trim())&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(oe.slashPipe,"|");return s}function jt(e,t,n){let s=e.length;if(s===0)return"";let i=0;for(;i<s&&e.charAt(s-i-1)===t;)i++;return e.slice(0,s-i)}function Xf(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function aa(e,t,n,s,i){let r=t.href,o=t.title||null,a=e[1].replace(i.other.outputLinkReplace,"$1");s.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:o,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,l}function Zf(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let i=s[1];return t.split(`
|
|
1733
1735
|
`).map(r=>{let o=r.match(n.other.beginningSpace);if(o===null)return r;let[a]=o;return a.length>=i.length?r.slice(i.length):r}).join(`
|
|
1734
|
-
`)}var
|
|
1735
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=
|
|
1736
|
+
`)}var rs=class{constructor(e){B(this,"options");B(this,"rules");B(this,"lexer");this.options=e||lt}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:jt(n,`
|
|
1737
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=Zf(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=jt(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:jt(t[0],`
|
|
1736
1738
|
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=jt(t[0],`
|
|
1737
1739
|
`).split(`
|
|
1738
1740
|
`),s="",i="",r=[];for(;n.length>0;){let o=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=!0;else if(!o)a.push(n[l]);else break;n=n.slice(l);let c=a.join(`
|
|
1739
1741
|
`),u=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
1740
1742
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
1741
1743
|
${c}`:c,i=i?`${i}
|
|
1742
|
-
${u}`:u;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,r,!0),this.lexer.state.top=p,n.length===0)break;let d=r.at(-1);if((d==null?void 0:d.type)==="code")break;if((d==null?void 0:d.type)==="blockquote"){let
|
|
1744
|
+
${u}`:u;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,r,!0),this.lexer.state.top=p,n.length===0)break;let d=r.at(-1);if((d==null?void 0:d.type)==="code")break;if((d==null?void 0:d.type)==="blockquote"){let h=d,b=h.raw+`
|
|
1743
1745
|
`+n.join(`
|
|
1744
|
-
`),w=this.blockquote(b);r[r.length-1]=w,s=s.substring(0,s.length-
|
|
1746
|
+
`),w=this.blockquote(b);r[r.length-1]=w,s=s.substring(0,s.length-h.raw.length)+w.raw,i=i.substring(0,i.length-h.text.length)+w.text;break}else if((d==null?void 0:d.type)==="list"){let h=d,b=h.raw+`
|
|
1745
1747
|
`+n.join(`
|
|
1746
|
-
`),w=this.list(b);r[r.length-1]=w,s=s.substring(0,s.length-d.raw.length)+w.raw,i=i.substring(0,i.length-
|
|
1747
|
-
`);continue}}return{type:"blockquote",raw:s,tokens:r,text:i}}}list(e){var n,s;let t=this.rules.block.list.exec(e);if(t){let i=t[1].trim(),r=i.length>1,o={type:"list",raw:"",ordered:r,start:r?+i.slice(0,-1):"",loose:!1,items:[]};i=r?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=r?i:"[*+-]");let a=this.rules.other.listItemRegex(i),l=!1;for(;e;){let u=!1,p="",d="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let
|
|
1748
|
+
`),w=this.list(b);r[r.length-1]=w,s=s.substring(0,s.length-d.raw.length)+w.raw,i=i.substring(0,i.length-h.raw.length)+w.raw,n=b.substring(r.at(-1).raw.length).split(`
|
|
1749
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:r,text:i}}}list(e){var n,s;let t=this.rules.block.list.exec(e);if(t){let i=t[1].trim(),r=i.length>1,o={type:"list",raw:"",ordered:r,start:r?+i.slice(0,-1):"",loose:!1,items:[]};i=r?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=r?i:"[*+-]");let a=this.rules.other.listItemRegex(i),l=!1;for(;e;){let u=!1,p="",d="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let h=t[2].split(`
|
|
1748
1750
|
`,1)[0].replace(this.rules.other.listReplaceTabs,T=>" ".repeat(3*T.length)),b=e.split(`
|
|
1749
|
-
`,1)[0],w=!
|
|
1751
|
+
`,1)[0],w=!h.trim(),S=0;if(this.options.pedantic?(S=2,d=h.trimStart()):w?S=t[1].length+1:(S=t[2].search(this.rules.other.nonSpaceChar),S=S>4?1:S,d=h.slice(S),S+=t[1].length),w&&this.rules.other.blankLine.test(b)&&(p+=b+`
|
|
1750
1752
|
`,e=e.substring(b.length+1),u=!0),!u){let T=this.rules.other.nextBulletRegex(S),A=this.rules.other.hrRegex(S),E=this.rules.other.fencesBeginRegex(S),C=this.rules.other.headingBeginRegex(S),R=this.rules.other.htmlBeginRegex(S);for(;e;){let U=e.split(`
|
|
1751
1753
|
`,1)[0],Q;if(b=U,this.options.pedantic?(b=b.replace(this.rules.other.listReplaceNesting," "),Q=b):Q=b.replace(this.rules.other.tabCharGlobal," "),E.test(b)||C.test(b)||R.test(b)||T.test(b)||A.test(b))break;if(Q.search(this.rules.other.nonSpaceChar)>=S||!b.trim())d+=`
|
|
1752
|
-
`+Q.slice(S);else{if(w||
|
|
1754
|
+
`+Q.slice(S);else{if(w||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||E.test(h)||C.test(h)||A.test(h))break;d+=`
|
|
1753
1755
|
`+b}!w&&!b.trim()&&(w=!0),p+=U+`
|
|
1754
|
-
`,e=e.substring(U.length+1),
|
|
1755
|
-
`):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let a of s)this.rules.other.tableAlignRight.test(a)?r.align.push("right"):this.rules.other.tableAlignCenter.test(a)?r.align.push("center"):this.rules.other.tableAlignLeft.test(a)?r.align.push("left"):r.align.push(null);for(let a=0;a<n.length;a++)r.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:r.align[a]});for(let a of i)r.rows.push(
|
|
1756
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let r=jt(n.slice(0,-1),"\\");if((n.length-r.length)%2===0)return}else{let r=
|
|
1756
|
+
`,e=e.substring(U.length+1),h=Q.slice(S)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(l=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),o.raw+=p}let c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let u of o.items){if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),u.task){if(u.text=u.text.replace(this.rules.other.listReplaceTask,""),((n=u.tokens[0])==null?void 0:n.type)==="text"||((s=u.tokens[0])==null?void 0:s.type)==="paragraph"){u.tokens[0].raw=u.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),u.tokens[0].text=u.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(u.raw);if(p){let d={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};u.checked=d.checked,o.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=d.raw+u.tokens[0].raw,u.tokens[0].text=d.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(d)):u.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):u.tokens.unshift(d)}}if(!o.loose){let p=u.tokens.filter(h=>h.type==="space"),d=p.length>0&&p.some(h=>this.rules.other.anyLine.test(h.raw));o.loose=d}}if(o.loose)for(let u of o.items){u.loose=!0;for(let p of u.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:i}}}table(e){var o;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=oa(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=t[3])!=null&&o.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
1757
|
+
`):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let a of s)this.rules.other.tableAlignRight.test(a)?r.align.push("right"):this.rules.other.tableAlignCenter.test(a)?r.align.push("center"):this.rules.other.tableAlignLeft.test(a)?r.align.push("left"):r.align.push(null);for(let a=0;a<n.length;a++)r.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:r.align[a]});for(let a of i)r.rows.push(oa(a,r.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:r.align[c]})));return r}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
1758
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let r=jt(n.slice(0,-1),"\\");if((n.length-r.length)%2===0)return}else{let r=Xf(t[2],"()");if(r===-2)return;if(r>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+r;t[2]=t[2].substring(0,r),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let r=this.rules.other.pedanticHrefTitle.exec(s);r&&(s=r[1],i=r[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),aa(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[s.toLowerCase()];if(!i){let r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return aa(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||s[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...s[0]].length-1,r,o,a=i,l=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+i);(s=c.exec(t))!=null;){if(r=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!r)continue;if(o=[...r].length,s[3]||s[4]){a+=o;continue}else if((s[5]||s[6])&&i%3&&!((i+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let u=[...s[0]][0].length,p=e.slice(0,i+s.index+u+o);if(Math.min(i,o)%2){let h=p.slice(1,-1);return{type:"em",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}let d=p.slice(2,-2);return{type:"strong",raw:p,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let s,i;if(t[2]==="@")s=t[0],i="mailto:"+s;else{let r;do r=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(r!==t[0]);s=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:s,href:i,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},fe=class Pi{constructor(t){B(this,"tokens");B(this,"options");B(this,"state");B(this,"inlineQueue");B(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||lt,this.options.tokenizer=this.options.tokenizer||new rs,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:oe,block:Nn.normal,inline:zt.normal};this.options.pedantic?(n.block=Nn.pedantic,n.inline=zt.pedantic):this.options.gfm&&(n.block=Nn.gfm,this.options.breaks?n.inline=zt.breaks:n.inline=zt.gfm),this.tokenizer.rules=n}static get rules(){return{block:Nn,inline:zt}}static lex(t,n){return new Pi(n).lex(t)}static lexInline(t,n){return new Pi(n).inlineTokens(t)}lex(t){t=t.replace(oe.carriageReturn,`
|
|
1757
1759
|
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],s=!1){var i,r,o;for(this.options.pedantic&&(t=t.replace(oe.tabCharGlobal," ").replace(oe.spaceLine,""));t;){let a;if((r=(i=this.options.extensions)==null?void 0:i.block)!=null&&r.some(c=>(a=c.call({lexer:this},t,n))?(t=t.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(t)){t=t.substring(a.raw.length);let c=n.at(-1);a.raw.length===1&&c!==void 0?c.raw+=`
|
|
1758
1760
|
`: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(`
|
|
1759
1761
|
`)?"":`
|
|
@@ -1767,7 +1769,7 @@ ${u}`:u;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
1767
1769
|
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a),s=l.length!==t.length,t=t.substring(a.raw.length);continue}if(a=this.tokenizer.text(t)){t=t.substring(a.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
1768
1770
|
`)?"":`
|
|
1769
1771
|
`)+a.raw,c.text+=`
|
|
1770
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var l,c,u,p,d;let s=t,i=null;if(this.tokens.links){let
|
|
1772
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(a);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var l,c,u,p,d;let s=t,i=null;if(this.tokens.links){let h=Object.keys(this.tokens.links);if(h.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)h.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,i.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let r;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)r=i[2]?i[2].length:0,s=s.slice(0,i.index+r)+"["+"a".repeat(i[0].length-r-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=((c=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:c.call({lexer:this},s))??s;let o=!1,a="";for(;t;){o||(a=""),o=!1;let h;if((p=(u=this.options.extensions)==null?void 0:u.inline)!=null&&p.some(w=>(h=w.call({lexer:this},t,n))?(t=t.substring(h.raw.length),n.push(h),!0):!1))continue;if(h=this.tokenizer.escape(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.tag(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.link(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(h.raw.length);let w=n.at(-1);h.type==="text"&&(w==null?void 0:w.type)==="text"?(w.raw+=h.raw,w.text+=h.text):n.push(h);continue}if(h=this.tokenizer.emStrong(t,s,a)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.codespan(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.br(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.del(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.autolink(t)){t=t.substring(h.raw.length),n.push(h);continue}if(!this.state.inLink&&(h=this.tokenizer.url(t))){t=t.substring(h.raw.length),n.push(h);continue}let b=t;if((d=this.options.extensions)!=null&&d.startInline){let w=1/0,S=t.slice(1),T;this.options.extensions.startInline.forEach(A=>{T=A.call({lexer:this},S),typeof T=="number"&&T>=0&&(w=Math.min(w,T))}),w<1/0&&w>=0&&(b=t.substring(0,w+1))}if(h=this.tokenizer.inlineText(b)){t=t.substring(h.raw.length),h.raw.slice(-1)!=="_"&&(a=h.raw.slice(-1)),o=!0;let w=n.at(-1);(w==null?void 0:w.type)==="text"?(w.raw+=h.raw,w.text+=h.text):n.push(h);continue}if(t){let w="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(w);break}else throw new Error(w)}}return n}},os=class{constructor(e){B(this,"options");B(this,"parser");this.options=e||lt}space(e){return""}code({text:e,lang:t,escaped:n}){var r;let s=(r=(t||"").match(oe.notSpaceStart))==null?void 0:r[0],i=e.replace(oe.endingNewline,"")+`
|
|
1771
1773
|
`;return s?'<pre><code class="language-'+Ce(s)+'">'+(n?i:Ce(i,!0))+`</code></pre>
|
|
1772
1774
|
`:"<pre><code>"+(n?i:Ce(i,!0))+`</code></pre>
|
|
1773
1775
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
@@ -1785,23 +1787,23 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
1785
1787
|
`}tablerow({text:e}){return`<tr>
|
|
1786
1788
|
${e}</tr>
|
|
1787
1789
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
1788
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Ce(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),i=
|
|
1789
|
-
Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+Ce(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},it=new
|
|
1790
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Ce(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),i=ra(e);if(i===null)return s;e=i;let r='<a href="'+e+'"';return t&&(r+=' title="'+Ce(t)+'"'),r+=">"+s+"</a>",r}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let i=ra(e);if(i===null)return Ce(n);e=i;let r=`<img src="${e}" alt="${n}"`;return t&&(r+=` title="${Ce(t)}"`),r+=">",r}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ce(e.text)}},Cr=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ge=class Ri{constructor(t){B(this,"options");B(this,"renderer");B(this,"textRenderer");this.options=t||lt,this.options.renderer=this.options.renderer||new os,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Cr}static parse(t,n){return new Ri(n).parse(t)}static parseInline(t,n){return new Ri(n).parseInline(t)}parse(t){var s,i;let n="";for(let r=0;r<t.length;r++){let o=t[r];if((i=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&i[o.type]){let l=o,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=c||"";continue}}let a=o;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(t,n=this.renderer){var i,r;let s="";for(let o=0;o<t.length;o++){let a=t[o];if((r=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&r[a.type]){let c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=c||"";continue}}let l=a;switch(l.type){case"escape":{s+=n.text(l);break}case"html":{s+=n.html(l);break}case"link":{s+=n.link(l);break}case"image":{s+=n.image(l);break}case"checkbox":{s+=n.checkbox(l);break}case"strong":{s+=n.strong(l);break}case"em":{s+=n.em(l);break}case"codespan":{s+=n.codespan(l);break}case"br":{s+=n.br(l);break}case"del":{s+=n.del(l);break}case"text":{s+=n.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}},Wn,Gt=(Wn=class{constructor(e){B(this,"options");B(this,"block");this.options=e||lt}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?fe.lex:fe.lexInline}provideParser(){return this.block?ge.parse:ge.parseInline}},B(Wn,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),B(Wn,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Wn),Jf=class{constructor(...e){B(this,"defaults",wr());B(this,"options",this.setOptions);B(this,"parse",this.parseMarkdown(!0));B(this,"parseInline",this.parseMarkdown(!1));B(this,"Parser",ge);B(this,"Renderer",os);B(this,"TextRenderer",Cr);B(this,"Lexer",fe);B(this,"Tokenizer",rs);B(this,"Hooks",Gt);this.use(...e)}walkTokens(e,t){var s,i;let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let o=r;for(let a of o.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of o.rows)for(let l of a)n=n.concat(this.walkTokens(l.tokens,t));break}case"list":{let o=r;n=n.concat(this.walkTokens(o.items,t));break}default:{let o=r;(i=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let l=o[a].flat(1/0);n=n.concat(this.walkTokens(l,t))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let r=t.renderers[i.name];r?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=r.apply(this,o)),a}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let r=t[i.level];r?r.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),s.extensions=t),n.renderer){let i=this.defaults.renderer||new os(this.defaults);for(let r in n.renderer){if(!(r in i))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;let o=r,a=n.renderer[o],l=i[o];i[o]=(...c)=>{let u=a.apply(i,c);return u===!1&&(u=l.apply(i,c)),u||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new rs(this.defaults);for(let r in n.tokenizer){if(!(r in i))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let o=r,a=n.tokenizer[o],l=i[o];i[o]=(...c)=>{let u=a.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Gt;for(let r in n.hooks){if(!(r in i))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;let o=r,a=n.hooks[o],l=i[o];Gt.passThroughHooks.has(r)?i[o]=c=>{if(this.defaults.async&&Gt.passThroughHooksRespectAsync.has(r))return(async()=>{let p=await a.call(i,c);return l.call(i,p)})();let u=a.call(i,c);return l.call(i,u)}:i[o]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(i,c);return p===!1&&(p=await l.apply(i,c)),p})();let u=a.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}s.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,r=n.walkTokens;s.walkTokens=function(o){let a=[];return a.push(r.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return fe.lex(e,t??this.defaults)}parser(e,t){return ge.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},i={...this.defaults,...s},r=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&s.async===!1)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return r(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,a=await(i.hooks?await i.hooks.provideLexer():e?fe.lex:fe.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let c=await(i.hooks?await i.hooks.provideParser():e?ge.parse:ge.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(c):c})().catch(r);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():e?fe.lex:fe.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():e?ge.parse:ge.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return r(o)}}}onError(e,t){return n=>{if(n.message+=`
|
|
1791
|
+
Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+Ce(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},it=new Jf;function W(e,t){return it.parse(e,t)}W.options=W.setOptions=function(e){return it.setOptions(e),W.defaults=it.defaults,tc(W.defaults),W};W.getDefaults=wr;W.defaults=lt;W.use=function(...e){return it.use(...e),W.defaults=it.defaults,tc(W.defaults),W};W.walkTokens=function(e,t){return it.walkTokens(e,t)};W.parseInline=it.parseInline;W.Parser=ge;W.parser=ge.parse;W.Renderer=os;W.TextRenderer=Cr;W.Lexer=fe;W.lexer=fe.lex;W.Tokenizer=rs;W.Hooks=Gt;W.parse=W;W.options;W.setOptions;W.use;W.walkTokens;W.parseInline;ge.parse;fe.lex;W.setOptions({gfm:!0,breaks:!0,mangle:!1});const la=["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"],ca=["class","href","rel","target","title","start"];let ua=!1;const eg=14e4,tg=4e4,ng=200,ni=5e4,Xe=new Map;function sg(e){const t=Xe.get(e);return t===void 0?null:(Xe.delete(e),Xe.set(e,t),t)}function da(e,t){if(Xe.set(e,t),Xe.size<=ng)return;const n=Xe.keys().next().value;n&&Xe.delete(n)}function ig(){ua||(ua=!0,Mi.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Ii(e){const t=e.trim();if(!t)return"";if(ig(),t.length<=ni){const o=sg(t);if(o!==null)return o}const n=Xa(t,eg),s=n.truncated?`
|
|
1790
1792
|
|
|
1791
|
-
… truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>
|
|
1793
|
+
… truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>tg){const a=`<pre class="code-block">${rg(`${n.text}${s}`)}</pre>`,l=Mi.sanitize(a,{ALLOWED_TAGS:la,ALLOWED_ATTR:ca});return t.length<=ni&&da(t,l),l}const i=W.parse(`${n.text}${s}`),r=Mi.sanitize(i,{ALLOWED_TAGS:la,ALLOWED_ATTR:ca});return t.length<=ni&&da(t,r),r}function rg(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const og=1500,ag=2e3,pc="Copy as markdown",lg="Copied",cg="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 Dn(e,t){e.title=t,e.setAttribute("aria-label",t)}function dg(e){const t=e.label??pc;return f`
|
|
1792
1794
|
<button
|
|
1793
1795
|
class="chat-copy-btn"
|
|
1794
1796
|
type="button"
|
|
1795
1797
|
title=${t}
|
|
1796
1798
|
aria-label=${t}
|
|
1797
|
-
@click=${async n=>{const s=n.currentTarget;if(s==null||s.querySelector(".chat-copy-btn__icon"),!s||s.dataset.copying==="1")return;s.dataset.copying="1",s.setAttribute("aria-busy","true"),s.disabled=!0;const i=await
|
|
1799
|
+
@click=${async n=>{const s=n.currentTarget;if(s==null||s.querySelector(".chat-copy-btn__icon"),!s||s.dataset.copying==="1")return;s.dataset.copying="1",s.setAttribute("aria-busy","true"),s.disabled=!0;const i=await ug(e.text());if(s.isConnected){if(delete s.dataset.copying,s.removeAttribute("aria-busy"),s.disabled=!1,!i){s.dataset.error="1",Dn(s,cg),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.error,Dn(s,t))},ag);return}s.dataset.copied="1",Dn(s,lg),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,Dn(s,t))},og)}}}
|
|
1798
1800
|
>
|
|
1799
1801
|
<span class="chat-copy-btn__icon" aria-hidden="true">
|
|
1800
1802
|
<span class="chat-copy-btn__icon-copy">${O.copy}</span>
|
|
1801
1803
|
<span class="chat-copy-btn__icon-check">${O.check}</span>
|
|
1802
1804
|
</span>
|
|
1803
1805
|
</button>
|
|
1804
|
-
`}function
|
|
1806
|
+
`}function pg(e){return dg({text:()=>e,label:pc})}function hg(e){const t=e,n=fg(t.content),s=[];for(const i of n){const r=String(i.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(r)||typeof i.name=="string"&&i.arguments!=null)&&s.push({kind:"call",name:i.name??"tool",args:gg(i.arguments??i.args)})}for(const i of n){const r=String(i.type??"").toLowerCase();if(r!=="toolresult"&&r!=="tool_result")continue;const o=mg(i),a=typeof i.name=="string"?i.name:"tool";s.push({kind:"result",name:a,text:o})}if(tl(e)&&!s.some(i=>i.kind==="result")){const i=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",r=Za(e)??void 0;s.push({kind:"result",name:i,text:r})}return s}function fg(e){return Array.isArray(e)?e.filter(Boolean):[]}function gg(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 mg(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function yg(e){var i;const n=e.content,s=[];if(Array.isArray(n))for(const r of n){if(typeof r!="object"||r===null)continue;const o=r;if(o.type==="image")if(((i=o.source)==null?void 0:i.type)==="base64"){const a=o.source,l=a.data,c=a.media_type||"image/png",u=l.startsWith("data:")?l:`data:${c};base64,${l}`;s.push({url:u})}else if(typeof o.data=="string"&&o.data){const a=o.data,l=o.mimeType||o.media_type||"image/png",c=a.startsWith("data:")?a:`data:${l};base64,${a}`;s.push({url:c})}else typeof o.url=="string"&&s.push({url:o.url});else if(o.type==="image_url"){const a=o.image_url;typeof(a==null?void 0:a.url)=="string"&&s.push({url:a.url})}}return s}function vg(e){return f`
|
|
1805
1807
|
<div class="chat-group assistant">
|
|
1806
1808
|
<div class="chat-group-messages">
|
|
1807
1809
|
<div class="chat-bubble chat-reading-indicator" aria-hidden="true">
|
|
@@ -1811,24 +1813,24 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
1811
1813
|
</div>
|
|
1812
1814
|
</div>
|
|
1813
1815
|
</div>
|
|
1814
|
-
`}function
|
|
1816
|
+
`}function bg(e,t,n,s){return f`
|
|
1815
1817
|
<div class="chat-group assistant">
|
|
1816
1818
|
<div class="chat-group-messages">
|
|
1817
|
-
${
|
|
1819
|
+
${hc({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
|
|
1818
1820
|
</div>
|
|
1819
1821
|
</div>
|
|
1820
|
-
`}function
|
|
1822
|
+
`}function wg(e,t){const n=el(e.role),s=n==="user"?"user":n==="assistant"?"assistant":"other",i=new Date(e.timestamp).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return f`
|
|
1821
1823
|
<div class="chat-group ${s}">
|
|
1822
1824
|
<div class="chat-group-messages">
|
|
1823
|
-
${e.messages.map((r,o)=>
|
|
1825
|
+
${e.messages.map((r,o)=>hc(r.message,{isStreaming:e.isStreaming&&o===e.messages.length-1,showReasoning:t.showReasoning}))}
|
|
1824
1826
|
<div class="chat-group-footer">
|
|
1825
1827
|
<span class="chat-group-timestamp">${i}</span>
|
|
1826
1828
|
</div>
|
|
1827
1829
|
</div>
|
|
1828
1830
|
</div>
|
|
1829
|
-
`}function
|
|
1831
|
+
`}function kg(e){return e.length===0?k:f`
|
|
1830
1832
|
<div class="chat-message-images">
|
|
1831
|
-
${e.map(t=>
|
|
1833
|
+
${e.map(t=>f`
|
|
1832
1834
|
<img
|
|
1833
1835
|
src=${t.url}
|
|
1834
1836
|
alt=${t.alt??"Attached image"}
|
|
@@ -1837,14 +1839,14 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
1837
1839
|
/>
|
|
1838
1840
|
`)}
|
|
1839
1841
|
</div>
|
|
1840
|
-
`}function
|
|
1842
|
+
`}function hc(e,t,n){const s=e,i=typeof s.role=="string"?s.role:"unknown",r=tl(e)||i.toLowerCase()==="toolresult"||i.toLowerCase()==="tool_result"||typeof s.toolCallId=="string"||typeof s.tool_call_id=="string",a=hg(e).length>0,l=yg(e),c=l.length>0,u=Za(e),p=t.showReasoning&&i==="assistant"?Vu(e):null,d=u!=null&&u.trim()?u:null,h=p?Yu(p):null,b=d,w=(i==="assistant"||i==="user")&&!!(b!=null&&b.trim()),S=["chat-bubble",w?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!b&&(a||r)||!b&&!c?k:f`
|
|
1841
1843
|
<div class="${S}">
|
|
1842
|
-
${w?
|
|
1843
|
-
${
|
|
1844
|
-
${f
|
|
1845
|
-
${b?
|
|
1844
|
+
${w?pg(b):k}
|
|
1845
|
+
${kg(l)}
|
|
1846
|
+
${h?f`<div class="chat-thinking">${Ei(Ii(h))}</div>`:k}
|
|
1847
|
+
${b?f`<div class="chat-text">${Ei(Ii(b))}</div>`:k}
|
|
1846
1848
|
</div>
|
|
1847
|
-
`}function
|
|
1849
|
+
`}function Sg(e){return f`
|
|
1848
1850
|
<div class="sidebar-panel">
|
|
1849
1851
|
<div class="sidebar-header">
|
|
1850
1852
|
<div class="sidebar-title">Tool Output</div>
|
|
@@ -1853,15 +1855,15 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
1853
1855
|
</button>
|
|
1854
1856
|
</div>
|
|
1855
1857
|
<div class="sidebar-content">
|
|
1856
|
-
${e.error?
|
|
1858
|
+
${e.error?f`
|
|
1857
1859
|
<div class="callout danger">${e.error}</div>
|
|
1858
1860
|
<button @click=${e.onViewRawText} class="btn" style="margin-top: 12px;">
|
|
1859
1861
|
View Raw Text
|
|
1860
1862
|
</button>
|
|
1861
|
-
`:e.content?
|
|
1863
|
+
`:e.content?f`<div class="sidebar-markdown">${Ei(Ii(e.content))}</div>`:f`<div class="muted">No content available</div>`}
|
|
1862
1864
|
</div>
|
|
1863
1865
|
</div>
|
|
1864
|
-
`}var
|
|
1866
|
+
`}var xg=Object.defineProperty,Ag=Object.getOwnPropertyDescriptor,Ss=(e,t,n,s)=>{for(var i=s>1?void 0:s?Ag(t,n):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&xg(t,n,i),i};let Et=class extends kt{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,i=(e.clientX-this.startX)/n;let r=this.startRatio+i;r=Math.max(this.minRatio,Math.min(this.maxRatio,r)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:r},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return f``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};Et.styles=pu`
|
|
1865
1867
|
:host {
|
|
1866
1868
|
width: 4px;
|
|
1867
1869
|
cursor: col-resize;
|
|
@@ -1887,23 +1889,23 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
1887
1889
|
:host(.dragging) {
|
|
1888
1890
|
background: var(--accent, #007bff);
|
|
1889
1891
|
}
|
|
1890
|
-
`;ks([ps({type:Number})],Et.prototype,"splitRatio",2);ks([ps({type:Number})],Et.prototype,"minRatio",2);ks([ps({type:Number})],Et.prototype,"maxRatio",2);Et=ks([za("resizable-divider")],Et);function On(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function ni(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const Ag=1,$g=1,ct="emoji",Tt="keyvalue",_r="favorites",Eg="tokens",dc="tokens",Tg="unicode",pc="count",Cg="group",_g="order",hc="group-order",Ii="eTag",os="url",ca="skinTone",Mt="readonly",Mr="readwrite",fc="skinUnicodes",Mg="skinUnicodes",Lg="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Pg="en";function Rg(e,t){const n=new Set,s=[];for(const i of e){const r=t(i);n.has(r)||(n.add(r),s.push(i))}return s}function ua(e){return Rg(e,t=>t.unicode)}function Ig(e){function t(n,s,i){const r=s?e.createObjectStore(n,{keyPath:s}):e.createObjectStore(n);if(i)for(const[o,[a,l]]of Object.entries(i))r.createIndex(o,a,{multiEntry:l});return r}t(Tt),t(ct,Tg,{[dc]:[Eg,!0],[hc]:[[Cg,_g]],[fc]:[Mg,!0]}),t(_r,void 0,{[pc]:[""]})}const Ni={},Hn={},as={};function gc(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function Ng(e){const t=await new Promise((n,s)=>{const i=indexedDB.open(e,Ag);Ni[e]=i,i.onupgradeneeded=r=>{r.oldVersion<$g&&Ig(i.result)},gc(n,s,i)});return t.onclose=()=>Lr(e),t}function Dg(e){return Hn[e]||(Hn[e]=Ng(e)),Hn[e]}function Pe(e,t,n,s){return new Promise((i,r)=>{const o=e.transaction(t,n,{durability:"relaxed"}),a=typeof t=="string"?o.objectStore(t):t.map(c=>o.objectStore(c));let l;s(a,o,c=>{l=c}),o.oncomplete=()=>i(l),o.onerror=()=>r(o.error)})}function Lr(e){const t=Ni[e],n=t&&t.result;if(n){n.close();const s=as[e];if(s)for(const i of s)i()}delete Ni[e],delete Hn[e],delete as[e]}function Og(e){return new Promise((t,n)=>{Lr(e);const s=indexedDB.deleteDatabase(e);gc(t,n,s)})}function Bg(e,t){let n=as[e];n||(n=as[e]=[]),n.push(t)}const Fg=new Set([":D","XD",":'D","O:)",":X",":P",";P","XP",":L",":Z",":j","8D","XO","8)",":B",":O",":S",":'o","Dx","X(","D:",":C",">0)",":3","</3","<3","\\M/",":E","8#"]);function St(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||Fg.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const Ug=2;function mc(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=Ug)}function Wg(e){return e.map(({annotation:n,emoticon:s,group:i,order:r,shortcodes:o,skins:a,tags:l,emoji:c,version:u})=>{const p=[...new Set(mc([...(o||[]).map(St).flat(),...(l||[]).map(St).flat(),...St(n),s]))].sort(),d={annotation:n,group:i,order:r,tags:l,tokens:p,unicode:c,version:u};if(s&&(d.emoticon=s),o&&(d.shortcodes=o),a){d.skinTones=[],d.skinUnicodes=[],d.skinVersions=[];for(const{tone:f,emoji:b,version:w}of a)d.skinTones.push(f),d.skinUnicodes.push(b),d.skinVersions.push(w)}return d})}function yc(e,t,n,s){e[t](n).onsuccess=i=>s&&s(i.target.result)}function rt(e,t,n){yc(e,"get",t,n)}function vc(e,t,n){yc(e,"getAll",t,n)}function Pr(e){e.commit&&e.commit()}function Kg(e,t){let n=e[0];for(let s=1;s<e.length;s++){const i=e[s];t(n)>t(i)&&(n=i)}return n}function bc(e,t){const n=Kg(e,i=>i.length),s=[];for(const i of n)e.some(r=>r.findIndex(o=>t(o)===t(i))===-1)||s.push(i);return s}async function zg(e){return!await Rr(e,Tt,os)}async function jg(e,t,n){const[s,i]=await Promise.all([Ii,os].map(r=>Rr(e,Tt,r)));return s===n&&i===t}async function Hg(e,t){return Pe(e,ct,Mt,(s,i,r)=>{let o;const a=()=>{s.getAll(o&&IDBKeyRange.lowerBound(o,!0),50).onsuccess=l=>{const c=l.target.result;for(const u of c)if(o=u.unicode,t(u))return r(u);if(c.length<50)return r();a()}};a()})}async function wc(e,t,n,s){{const i=Wg(t);await Pe(e,[ct,Tt],Mr,([r,o],a)=>{let l,c,u=0;function p(){++u===2&&d()}function d(){if(!(l===s&&c===n)){r.clear();for(const f of i)r.put(f);o.put(s,Ii),o.put(n,os),Pr(a)}}rt(o,Ii,f=>{l=f,p()}),rt(o,os,f=>{c=f,p()})})}}async function qg(e,t){return Pe(e,ct,Mt,(n,s,i)=>{const r=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);vc(n.index(hc),r,i)})}async function kc(e,t){const n=mc(St(t));return n.length?Pe(e,ct,Mt,(s,i,r)=>{const o=[],a=()=>{o.length===n.length&&l()},l=()=>{const c=bc(o,u=>u.unicode);r(c.sort((u,p)=>u.order<p.order?-1:1))};for(let c=0;c<n.length;c++){const u=n[c],p=c===n.length-1?IDBKeyRange.bound(u,u+"",!1,!0):IDBKeyRange.only(u);vc(s.index(dc),p,d=>{o.push(d),a()})}}):[]}async function Gg(e,t){const n=await kc(e,t);return n.length?n.filter(s=>(s.shortcodes||[]).map(r=>r.toLowerCase()).includes(t.toLowerCase()))[0]||null:await Hg(e,i=>(i.shortcodes||[]).includes(t.toLowerCase()))||null}async function Vg(e,t){return Pe(e,ct,Mt,(n,s,i)=>rt(n,t,r=>{if(r)return i(r);rt(n.index(fc),t,o=>i(o||null))}))}function Rr(e,t,n){return Pe(e,t,Mt,(s,i,r)=>rt(s,n,r))}function Qg(e,t,n,s){return Pe(e,t,Mr,(i,r)=>{i.put(s,n),Pr(r)})}function Yg(e,t){return Pe(e,_r,Mr,(n,s)=>rt(n,t,i=>{n.put((i||0)+1,t),Pr(s)}))}function Xg(e,t,n){return n===0?[]:Pe(e,[_r,ct],Mt,([s,i],r,o)=>{const a=[];s.index(pc).openCursor(void 0,"prev").onsuccess=l=>{const c=l.target.result;if(!c)return o(a);function u(f){if(a.push(f),a.length===n)return o(a);c.continue()}const p=c.primaryKey,d=t.byName(p);if(d)return u(d);rt(i,p,f=>{if(f)return u(f);c.continue()})}})}const Bn="";function Zg(e,t){const n=new Map;for(const i of e){const r=t(i);for(const o of r){let a=n;for(let c=0;c<o.length;c++){const u=o.charAt(c);let p=a.get(u);p||(p=new Map,a.set(u,p)),a=p}let l=a.get(Bn);l||(l=[],a.set(Bn,l)),l.push(i)}}return(i,r)=>{let o=n;for(let c=0;c<i.length;c++){const u=i.charAt(c),p=o.get(u);if(p)o=p;else return[]}if(r)return o.get(Bn)||[];const a=[],l=[o];for(;l.length;){const u=[...l.shift().entries()].sort((p,d)=>p[0]<d[0]?-1:1);for(const[p,d]of u)p===Bn?a.push(...d):l.push(d)}return a}}const Jg=["name","url"];function em(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||Jg.some(s=>!(s in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function da(e){em(e);const t=(d,f)=>d.name.toLowerCase()<f.name.toLowerCase()?-1:1,n=e.sort(t),i=Zg(e,d=>{const f=new Set;if(d.shortcodes)for(const b of d.shortcodes)for(const w of St(b))f.add(w);return f}),r=d=>i(d,!0),o=d=>i(d,!1),a=d=>{const f=St(d),b=f.map((w,S)=>(S<f.length-1?r:o)(w));return bc(b,w=>w.name).sort(t)},l=new Map,c=new Map;for(const d of e){c.set(d.name.toLowerCase(),d);for(const f of d.shortcodes||[])l.set(f.toLowerCase(),d)}return{all:n,search:a,byShortcode:d=>l.get(d.toLowerCase()),byName:d=>c.get(d.toLowerCase())}}const tm=typeof wrappedJSObject<"u";function Ht(e){if(!e)return e;if(tm&&(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 Sc(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 sm(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 im(e){const t=await fetch(e,{method:"HEAD"});xc(t,e);const n=t.headers.get("etag");return Sc(n),n}async function Di(e){const t=await fetch(e);xc(t,e);const n=t.headers.get("etag");Sc(n);const s=await t.json();return sm(s),[n,s]}function rm(e){for(var t="",n=new Uint8Array(e),s=n.byteLength,i=-1;++i<s;)t+=String.fromCharCode(n[i]);return t}function om(e){for(var t=e.length,n=new ArrayBuffer(t),s=new Uint8Array(n),i=-1;++i<t;)s[i]=e.charCodeAt(i);return n}async function Ac(e){const t=JSON.stringify(e);let n=om(t);const s=await crypto.subtle.digest("SHA-1",n),i=rm(s);return btoa(i)}async function am(e,t){let n,s=await im(t);if(!s){const i=await Di(t);s=i[0],n=i[1],s||(s=await Ac(n))}await jg(e,t,s)||(n||(n=(await Di(t))[1]),await wc(e,n,t,s))}async function lm(e,t){let[n,s]=await Di(t);n||(n=await Ac(s)),await wc(e,s,t,n)}async function cm(e,t){try{await am(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class um{constructor({dataSource:t=Lg,locale:n=Pg,customEmoji:s=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=da(s),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await Dg(this._dbName);Bg(this._dbName,this._clear);const n=this.dataSource;await zg(t)?await lm(t,n):this._lazyUpdate=cm(t,n)}async ready(){const t=async()=>(this._ready||(this._ready=this._init()),this._ready);await t(),this._db||await t()}async getEmojiByGroup(t){return ni(t),await this.ready(),ua(await qg(this._db,t)).map(Ht)}async getEmojiBySearchQuery(t){On(t),await this.ready();const n=this._custom.search(t),s=ua(await kc(this._db,t)).map(Ht);return[...n,...s]}async getEmojiByShortcode(t){On(t),await this.ready();const n=this._custom.byShortcode(t);return n||Ht(await Gg(this._db,t))}async getEmojiByUnicodeOrName(t){On(t),await this.ready();const n=this._custom.byName(t);return n||Ht(await Vg(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Rr(this._db,Tt,ca)||0}async setPreferredSkinTone(t){return ni(t),await this.ready(),Qg(this._db,Tt,ca,t)}async incrementFavoriteEmojiCount(t){return On(t),await this.ready(),Yg(this._db,t)}async getTopFavoriteEmoji(t){return ni(t),await this.ready(),(await Xg(this._db,this._custom,t)).map(Ht)}set customEmoji(t){this._custom=da(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 Lr(this._dbName)}async delete(){await this._shutdown(),await Og(this._dbName)}}const Oi=[[-1,"✨","custom"],[0,"😀","smileys-emotion"],[1,"👋","people-body"],[3,"🐱","animals-nature"],[4,"🍎","food-drink"],[5,"🏠️","travel-places"],[6,"⚽","activities"],[7,"📝","objects"],[8,"⛔️","symbols"],[9,"🏁","flags"]].map(([e,t,n])=>({id:e,emoji:t,name:n})),si=Oi.slice(1),dm=2,pa=6,$c=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function ha(e){return e.unicode.includes("")}const pm={"":17,"":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱♀️":4,"🤣":3,"👁️🗨️":2,"😀":1,"😐️":.7,"😃":.6},hm=1e3,fm="🖐️",gm=8,mm=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],Ec='"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,fa=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const s=n.getContext("2d",{willReadFrequently:!0});return s.textBaseline="top",s.font=`100px ${Ec}`,s.fillStyle=t,s.scale(.01,.01),s.fillText(e,0,0),s.getImageData(0,0,1,1).data},vm=(e,t)=>{const n=[...e].join(","),s=[...t].join(",");return n===s&&!n.startsWith("0,0,0,")};function bm(e){const t=fa(e,"#000"),n=fa(e,"#fff");return t&&n&&vm(t,n)}function wm(){const e=Object.entries(pm);try{for(const[t,n]of e)if(bm(t))return n}catch{}return e[0][1]}let ii;const ri=()=>(ii||(ii=new Promise(e=>$c(()=>e(wm())))),ii),Bi=new Map,km="️",Sm="\uD83C",xm="",Am=127995,$m=57339;function Em(e,t){if(t===0)return e;const n=e.indexOf(xm);return n!==-1?e.substring(0,n)+String.fromCodePoint(Am+t-1)+e.substring(n):(e.endsWith(km)&&(e=e.substring(0,e.length-1)),e+Sm+String.fromCodePoint($m+t-1))}function we(e){e.preventDefault(),e.stopPropagation()}function oi(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function Tc(e,t){const n=new Set,s=[];for(const i of e){const r=t(i);n.has(r)||(n.add(r),s.push(i))}return s}function Tm(e,t){const n=s=>{const i={};for(const r of s)typeof r.tone=="number"&&r.version<=t&&(i[r.tone]=r.unicode);return i};return e.map(({unicode:s,skins:i,shortcodes:r,url:o,name:a,category:l,annotation:c})=>({unicode:s,name:a,shortcodes:r,url:o,category:l,annotation:c,id:s||a,skins:i&&n(i)}))}const qn=requestAnimationFrame;let Cm=typeof ResizeObserver=="function";function _m(e,t,n){let s;Cm?(s=new ResizeObserver(n),s.observe(e)):qn(n),t.addEventListener("abort",()=>{s&&s.disconnect()})}function ga(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let ai;function Mm(e,t,n){let s=!0,i=!1;for(const r of e){const o=n(r);if(!o)continue;const a=ga(o);a===0&&(i=!0),typeof ai>"u"&&(ai=ga(t));const l=a/1.8<ai;Bi.set(r.unicode,l),l||(s=!1)}return i&&console.warn(`Emoji support detection failed - emoji character is 0 width.
|
|
1892
|
+
`;Ss([hs({type:Number})],Et.prototype,"splitRatio",2);Ss([hs({type:Number})],Et.prototype,"minRatio",2);Ss([hs({type:Number})],Et.prototype,"maxRatio",2);Et=Ss([qa("resizable-divider")],Et);function On(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function si(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const $g=1,Eg=1,ct="emoji",Tt="keyvalue",_r="favorites",Tg="tokens",fc="tokens",Cg="unicode",gc="count",_g="group",Mg="order",mc="group-order",Ni="eTag",as="url",pa="skinTone",Mt="readonly",Mr="readwrite",yc="skinUnicodes",Lg="skinUnicodes",Pg="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Rg="en";function Ig(e,t){const n=new Set,s=[];for(const i of e){const r=t(i);n.has(r)||(n.add(r),s.push(i))}return s}function ha(e){return Ig(e,t=>t.unicode)}function Ng(e){function t(n,s,i){const r=s?e.createObjectStore(n,{keyPath:s}):e.createObjectStore(n);if(i)for(const[o,[a,l]]of Object.entries(i))r.createIndex(o,a,{multiEntry:l});return r}t(Tt),t(ct,Cg,{[fc]:[Tg,!0],[mc]:[[_g,Mg]],[yc]:[Lg,!0]}),t(_r,void 0,{[gc]:[""]})}const Di={},Hn={},ls={};function vc(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function Dg(e){const t=await new Promise((n,s)=>{const i=indexedDB.open(e,$g);Di[e]=i,i.onupgradeneeded=r=>{r.oldVersion<Eg&&Ng(i.result)},vc(n,s,i)});return t.onclose=()=>Lr(e),t}function Og(e){return Hn[e]||(Hn[e]=Dg(e)),Hn[e]}function Pe(e,t,n,s){return new Promise((i,r)=>{const o=e.transaction(t,n,{durability:"relaxed"}),a=typeof t=="string"?o.objectStore(t):t.map(c=>o.objectStore(c));let l;s(a,o,c=>{l=c}),o.oncomplete=()=>i(l),o.onerror=()=>r(o.error)})}function Lr(e){const t=Di[e],n=t&&t.result;if(n){n.close();const s=ls[e];if(s)for(const i of s)i()}delete Di[e],delete Hn[e],delete ls[e]}function Bg(e){return new Promise((t,n)=>{Lr(e);const s=indexedDB.deleteDatabase(e);vc(t,n,s)})}function Fg(e,t){let n=ls[e];n||(n=ls[e]=[]),n.push(t)}const Ug=new Set([":D","XD",":'D","O:)",":X",":P",";P","XP",":L",":Z",":j","8D","XO","8)",":B",":O",":S",":'o","Dx","X(","D:",":C",">0)",":3","</3","<3","\\M/",":E","8#"]);function St(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||Ug.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const Wg=2;function bc(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=Wg)}function Kg(e){return e.map(({annotation:n,emoticon:s,group:i,order:r,shortcodes:o,skins:a,tags:l,emoji:c,version:u})=>{const p=[...new Set(bc([...(o||[]).map(St).flat(),...(l||[]).map(St).flat(),...St(n),s]))].sort(),d={annotation:n,group:i,order:r,tags:l,tokens:p,unicode:c,version:u};if(s&&(d.emoticon=s),o&&(d.shortcodes=o),a){d.skinTones=[],d.skinUnicodes=[],d.skinVersions=[];for(const{tone:h,emoji:b,version:w}of a)d.skinTones.push(h),d.skinUnicodes.push(b),d.skinVersions.push(w)}return d})}function wc(e,t,n,s){e[t](n).onsuccess=i=>s&&s(i.target.result)}function rt(e,t,n){wc(e,"get",t,n)}function kc(e,t,n){wc(e,"getAll",t,n)}function Pr(e){e.commit&&e.commit()}function zg(e,t){let n=e[0];for(let s=1;s<e.length;s++){const i=e[s];t(n)>t(i)&&(n=i)}return n}function Sc(e,t){const n=zg(e,i=>i.length),s=[];for(const i of n)e.some(r=>r.findIndex(o=>t(o)===t(i))===-1)||s.push(i);return s}async function jg(e){return!await Rr(e,Tt,as)}async function Hg(e,t,n){const[s,i]=await Promise.all([Ni,as].map(r=>Rr(e,Tt,r)));return s===n&&i===t}async function qg(e,t){return Pe(e,ct,Mt,(s,i,r)=>{let o;const a=()=>{s.getAll(o&&IDBKeyRange.lowerBound(o,!0),50).onsuccess=l=>{const c=l.target.result;for(const u of c)if(o=u.unicode,t(u))return r(u);if(c.length<50)return r();a()}};a()})}async function xc(e,t,n,s){{const i=Kg(t);await Pe(e,[ct,Tt],Mr,([r,o],a)=>{let l,c,u=0;function p(){++u===2&&d()}function d(){if(!(l===s&&c===n)){r.clear();for(const h of i)r.put(h);o.put(s,Ni),o.put(n,as),Pr(a)}}rt(o,Ni,h=>{l=h,p()}),rt(o,as,h=>{c=h,p()})})}}async function Gg(e,t){return Pe(e,ct,Mt,(n,s,i)=>{const r=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);kc(n.index(mc),r,i)})}async function Ac(e,t){const n=bc(St(t));return n.length?Pe(e,ct,Mt,(s,i,r)=>{const o=[],a=()=>{o.length===n.length&&l()},l=()=>{const c=Sc(o,u=>u.unicode);r(c.sort((u,p)=>u.order<p.order?-1:1))};for(let c=0;c<n.length;c++){const u=n[c],p=c===n.length-1?IDBKeyRange.bound(u,u+"",!1,!0):IDBKeyRange.only(u);kc(s.index(fc),p,d=>{o.push(d),a()})}}):[]}async function Vg(e,t){const n=await Ac(e,t);return n.length?n.filter(s=>(s.shortcodes||[]).map(r=>r.toLowerCase()).includes(t.toLowerCase()))[0]||null:await qg(e,i=>(i.shortcodes||[]).includes(t.toLowerCase()))||null}async function Qg(e,t){return Pe(e,ct,Mt,(n,s,i)=>rt(n,t,r=>{if(r)return i(r);rt(n.index(yc),t,o=>i(o||null))}))}function Rr(e,t,n){return Pe(e,t,Mt,(s,i,r)=>rt(s,n,r))}function Yg(e,t,n,s){return Pe(e,t,Mr,(i,r)=>{i.put(s,n),Pr(r)})}function Xg(e,t){return Pe(e,_r,Mr,(n,s)=>rt(n,t,i=>{n.put((i||0)+1,t),Pr(s)}))}function Zg(e,t,n){return n===0?[]:Pe(e,[_r,ct],Mt,([s,i],r,o)=>{const a=[];s.index(gc).openCursor(void 0,"prev").onsuccess=l=>{const c=l.target.result;if(!c)return o(a);function u(h){if(a.push(h),a.length===n)return o(a);c.continue()}const p=c.primaryKey,d=t.byName(p);if(d)return u(d);rt(i,p,h=>{if(h)return u(h);c.continue()})}})}const Bn="";function Jg(e,t){const n=new Map;for(const i of e){const r=t(i);for(const o of r){let a=n;for(let c=0;c<o.length;c++){const u=o.charAt(c);let p=a.get(u);p||(p=new Map,a.set(u,p)),a=p}let l=a.get(Bn);l||(l=[],a.set(Bn,l)),l.push(i)}}return(i,r)=>{let o=n;for(let c=0;c<i.length;c++){const u=i.charAt(c),p=o.get(u);if(p)o=p;else return[]}if(r)return o.get(Bn)||[];const a=[],l=[o];for(;l.length;){const u=[...l.shift().entries()].sort((p,d)=>p[0]<d[0]?-1:1);for(const[p,d]of u)p===Bn?a.push(...d):l.push(d)}return a}}const em=["name","url"];function tm(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||em.some(s=>!(s in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function fa(e){tm(e);const t=(d,h)=>d.name.toLowerCase()<h.name.toLowerCase()?-1:1,n=e.sort(t),i=Jg(e,d=>{const h=new Set;if(d.shortcodes)for(const b of d.shortcodes)for(const w of St(b))h.add(w);return h}),r=d=>i(d,!0),o=d=>i(d,!1),a=d=>{const h=St(d),b=h.map((w,S)=>(S<h.length-1?r:o)(w));return Sc(b,w=>w.name).sort(t)},l=new Map,c=new Map;for(const d of e){c.set(d.name.toLowerCase(),d);for(const h of d.shortcodes||[])l.set(h.toLowerCase(),d)}return{all:n,search:a,byShortcode:d=>l.get(d.toLowerCase()),byName:d=>c.get(d.toLowerCase())}}const nm=typeof wrappedJSObject<"u";function Ht(e){if(!e)return e;if(nm&&(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 $c(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const sm=["annotation","emoji","group","order","version"];function im(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||sm.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function Ec(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function rm(e){const t=await fetch(e,{method:"HEAD"});Ec(t,e);const n=t.headers.get("etag");return $c(n),n}async function Oi(e){const t=await fetch(e);Ec(t,e);const n=t.headers.get("etag");$c(n);const s=await t.json();return im(s),[n,s]}function om(e){for(var t="",n=new Uint8Array(e),s=n.byteLength,i=-1;++i<s;)t+=String.fromCharCode(n[i]);return t}function am(e){for(var t=e.length,n=new ArrayBuffer(t),s=new Uint8Array(n),i=-1;++i<t;)s[i]=e.charCodeAt(i);return n}async function Tc(e){const t=JSON.stringify(e);let n=am(t);const s=await crypto.subtle.digest("SHA-1",n),i=om(s);return btoa(i)}async function lm(e,t){let n,s=await rm(t);if(!s){const i=await Oi(t);s=i[0],n=i[1],s||(s=await Tc(n))}await Hg(e,t,s)||(n||(n=(await Oi(t))[1]),await xc(e,n,t,s))}async function cm(e,t){let[n,s]=await Oi(t);n||(n=await Tc(s)),await xc(e,s,t,n)}async function um(e,t){try{await lm(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class dm{constructor({dataSource:t=Pg,locale:n=Rg,customEmoji:s=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=fa(s),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await Og(this._dbName);Fg(this._dbName,this._clear);const n=this.dataSource;await jg(t)?await cm(t,n):this._lazyUpdate=um(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 si(t),await this.ready(),ha(await Gg(this._db,t)).map(Ht)}async getEmojiBySearchQuery(t){On(t),await this.ready();const n=this._custom.search(t),s=ha(await Ac(this._db,t)).map(Ht);return[...n,...s]}async getEmojiByShortcode(t){On(t),await this.ready();const n=this._custom.byShortcode(t);return n||Ht(await Vg(this._db,t))}async getEmojiByUnicodeOrName(t){On(t),await this.ready();const n=this._custom.byName(t);return n||Ht(await Qg(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Rr(this._db,Tt,pa)||0}async setPreferredSkinTone(t){return si(t),await this.ready(),Yg(this._db,Tt,pa,t)}async incrementFavoriteEmojiCount(t){return On(t),await this.ready(),Xg(this._db,t)}async getTopFavoriteEmoji(t){return si(t),await this.ready(),(await Zg(this._db,this._custom,t)).map(Ht)}set customEmoji(t){this._custom=fa(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 Lr(this._dbName)}async delete(){await this._shutdown(),await Bg(this._dbName)}}const Bi=[[-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})),ii=Bi.slice(1),pm=2,ga=6,Cc=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function ma(e){return e.unicode.includes("")}const hm={"":17,"":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱♀️":4,"🤣":3,"👁️🗨️":2,"😀":1,"😐️":.7,"😃":.6},fm=1e3,gm="🖐️",mm=8,ym=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],_c='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',vm=(e,t)=>e<t?-1:e>t?1:0,ya=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const s=n.getContext("2d",{willReadFrequently:!0});return s.textBaseline="top",s.font=`100px ${_c}`,s.fillStyle=t,s.scale(.01,.01),s.fillText(e,0,0),s.getImageData(0,0,1,1).data},bm=(e,t)=>{const n=[...e].join(","),s=[...t].join(",");return n===s&&!n.startsWith("0,0,0,")};function wm(e){const t=ya(e,"#000"),n=ya(e,"#fff");return t&&n&&bm(t,n)}function km(){const e=Object.entries(hm);try{for(const[t,n]of e)if(wm(t))return n}catch{}return e[0][1]}let ri;const oi=()=>(ri||(ri=new Promise(e=>Cc(()=>e(km())))),ri),Fi=new Map,Sm="️",xm="\uD83C",Am="",$m=127995,Em=57339;function Tm(e,t){if(t===0)return e;const n=e.indexOf(Am);return n!==-1?e.substring(0,n)+String.fromCodePoint($m+t-1)+e.substring(n):(e.endsWith(Sm)&&(e=e.substring(0,e.length-1)),e+xm+String.fromCodePoint(Em+t-1))}function we(e){e.preventDefault(),e.stopPropagation()}function ai(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function Mc(e,t){const n=new Set,s=[];for(const i of e){const r=t(i);n.has(r)||(n.add(r),s.push(i))}return s}function Cm(e,t){const n=s=>{const i={};for(const r of s)typeof r.tone=="number"&&r.version<=t&&(i[r.tone]=r.unicode);return i};return e.map(({unicode:s,skins:i,shortcodes:r,url:o,name:a,category:l,annotation:c})=>({unicode:s,name:a,shortcodes:r,url:o,category:l,annotation:c,id:s||a,skins:i&&n(i)}))}const qn=requestAnimationFrame;let _m=typeof ResizeObserver=="function";function Mm(e,t,n){let s;_m?(s=new ResizeObserver(n),s.observe(e)):qn(n),t.addEventListener("abort",()=>{s&&s.disconnect()})}function va(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let li;function Lm(e,t,n){let s=!0,i=!1;for(const r of e){const o=n(r);if(!o)continue;const a=va(o);a===0&&(i=!0),typeof li>"u"&&(li=va(t));const l=a/1.8<li;Fi.set(r.unicode,l),l||(s=!1)}return i&&console.warn(`Emoji support detection failed - emoji character is 0 width.
|
|
1891
1893
|
This is likely due to using \`display:none\` which is unsupported.
|
|
1892
1894
|
If this is a Jest/Vitest environment, you can ignore this warning.
|
|
1893
|
-
For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),s}function Lm(e){return Tc(e,t=>t)}function Pm(e){e&&(e.scrollTop=0)}function tn(e,t,n){let s=e.get(t);return s||(s=n(),e.set(t,s)),s}function ma(e){return""+e}function Rm(e){const t=document.createElement("template");return t.innerHTML=e,t}const Im=new WeakMap,Nm=new WeakMap,Dm=Symbol("un-keyed"),Om="replaceChildren"in Element.prototype;function Bm(e,t){Om?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function Fm(e,t){let n=e.firstChild,s=0;for(;n;){if(t[s]!==n)return!0;n=n.nextSibling,s++}return s!==t.length}function Um(e,t){const{targetNode:n}=t;let{targetParentNode:s}=t,i=!1;s?i=Fm(s,e):(i=!0,t.targetNode=void 0,t.targetParentNode=s=n.parentNode),i&&Bm(s,e)}function Wm(e,t){for(const n of t){const{targetNode:s,currentExpression:i,binding:{expressionIndex:r,attributeName:o,attributeValuePre:a,attributeValuePost:l}}=n,c=e[r];if(i!==c)if(n.currentExpression=c,o)if(c===null)s.removeAttribute(o);else{const u=a+ma(c)+l;s.setAttribute(o,u)}else{let u;Array.isArray(c)?Um(c,n):c instanceof Element?(u=c,s.replaceWith(u)):s.nodeValue=ma(c),u&&(n.targetNode=u)}}}function Km(e){let t="",n=!1,s=!1,i=-1;const r=new Map,o=[];let a=0;for(let c=0,u=e.length;c<u;c++){const p=e[c];if(t+=p.slice(a),c===u-1)break;for(let A=0;A<p.length;A++)switch(p.charAt(A)){case"<":{p.charAt(A+1)==="/"?o.pop():(n=!0,o.push(++i));break}case">":{n=!1,s=!1;break}case"=":{s=!0;break}}const d=o[o.length-1],f=tn(r,d,()=>[]);let b,w,S;if(s){const A=/(\S+)="?([^"=]*)$/.exec(p);b=A[1],w=A[2];const E=/^([^">]*)("?)/.exec(e[c+1]);S=E[1],t=t.slice(0,-1*A[0].length),a=E[0].length}else a=0;const T={attributeName:b,attributeValuePre:w,attributeValuePost:S,expressionIndex:c};f.push(T),!n&&!s&&(t+=" ")}return{template:Rm(t),elementsToBindings:r}}function ya(e,t,n){for(let s=0;s<e.length;s++){const i=e[s],r=i.attributeName?t:t.firstChild,o={binding:i,targetNode:r,targetParentNode:void 0,currentExpression:void 0};n.push(o)}}function zm(e,t){const n=[];let s;if(t.size===1&&(s=t.get(0)))ya(s,e,n);else{const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let r=e,o=-1;do{const a=t.get(++o);a&&ya(a,r,n)}while(r=i.nextNode())}return n}function jm(e){const{template:t,elementsToBindings:n}=tn(Im,e,()=>Km(e)),s=t.cloneNode(!0).content.firstElementChild,i=zm(s,n);return function(o){return Wm(o,i),s}}function Hm(e){const t=tn(Nm,e,()=>new Map);let n=Dm;function s(r,...o){const a=tn(t,r,()=>new Map);return tn(a,n,()=>jm(r))(o)}function i(r,o,a){return r.map((l,c)=>{const u=n;n=a(l);try{return o(l,c)}finally{n=u}})}return{map:i,html:s}}function qm(e,t,n,s,i,r,o,a,l){const{labelWithSkin:c,titleForEmoji:u,unicodeWithSkin:p}=n,{html:d,map:f}=Hm(t);function b(A,E,C){return f(A,(R,U)=>d`<button role="${E?"option":"menuitem"}" aria-selected="${E?U===t.activeSearchItem:null}" aria-label="${c(R,t.currentSkinTone)}" title="${u(R)}" class="${"emoji"+(E&&U===t.activeSearchItem?" active":"")+(R.unicode?"":" custom-emoji")}" id="${`${C}-${R.id}`}" style="${R.unicode?null:`--custom-emoji-background: url(${JSON.stringify(R.url)})`}">${R.unicode?p(R,t.currentSkinTone):""}</button>`,R=>`${C}-${R.id}`)}const S=d`<section data-ref="rootElement" class="picker" aria-label="${t.i18n.regionLabel}" style="${t.pickerStyle||""}"><div class="pad-top"></div><div class="search-row"><div class="search-wrapper"><input id="search" class="search" type="search" role="combobox" enterkeyhint="search" placeholder="${t.i18n.searchLabel}" autocapitalize="none" autocomplete="off" spellcheck="true" aria-expanded="${!!(t.searchMode&&t.currentEmojis.length)}" aria-controls="search-results" aria-describedby="search-description" aria-autocomplete="list" aria-activedescendant="${t.activeSearchItemId?`emo-${t.activeSearchItemId}`:null}" data-ref="searchElement" data-on-input="onSearchInput" data-on-keydown="onSearchKeydown"><label class="sr-only" for="search">${t.i18n.searchLabel}</label> <span id="search-description" class="sr-only">${t.i18n.searchDescription}</span></div><div class="skintone-button-wrapper ${t.skinTonePickerExpandedAfterAnimation?"expanded":""}"><button id="skintone-button" class="emoji ${t.skinTonePickerExpanded?"hide-focus":""}" aria-label="${t.skinToneButtonLabel}" title="${t.skinToneButtonLabel}" aria-describedby="skintone-description" aria-haspopup="listbox" aria-expanded="${t.skinTonePickerExpanded}" aria-controls="skintone-list" data-on-click="onClickSkinToneButton">${t.skinToneButtonText||""}</button></div><span id="skintone-description" class="sr-only">${t.i18n.skinToneDescription}</span><div data-ref="skinToneDropdown" id="skintone-list" class="skintone-list hide-focus ${t.skinTonePickerExpanded?"":"hidden no-animate"}" style="transform:translateY(${t.skinTonePickerExpanded?0:"calc(-1 * var(--num-skintones) * var(--total-emoji-size))"})" role="listbox" aria-label="${t.i18n.skinTonesLabel}" aria-activedescendant="skintone-${t.activeSkinTone}" aria-hidden="${!t.skinTonePickerExpanded}" tabIndex="-1" data-on-focusout="onSkinToneOptionsFocusOut" data-on-click="onSkinToneOptionsClick" data-on-keydown="onSkinToneOptionsKeydown" data-on-keyup="onSkinToneOptionsKeyup">${f(t.skinTones,(A,E)=>d`<div id="skintone-${E}" class="emoji ${E===t.activeSkinTone?"active":""}" aria-selected="${E===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[E]}" aria-label="${t.i18n.skinTones[E]}">${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">${f(t.groups,A=>d`<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">${f(t.currentEmojisWithCategories,(A,E)=>d`<div><div id="menu-label-${E}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:A.category?A.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${E!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(A.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${E}" id="${t.searchMode?"search-results":null}">${b(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">${b(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,T=(A,E)=>{for(const C of e.querySelectorAll(`[${A}]`))E(C,C.getAttribute(A))};if(l){e.appendChild(S);for(const A of["click","focusout","input","keydown","keyup"])T(`data-on-${A}`,(E,C)=>{E.addEventListener(A,s[C])});T("data-ref",(A,E)=>{r[E]=A}),o.addEventListener("abort",()=>{e.removeChild(S)})}T("data-action",(A,E)=>{let C=a.get(E);C||a.set(E,C=new WeakSet),C.has(A)||(C.add(A),i[E](A))})}const ls=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Gm(e){let t=!1,n;const s=new Map,i=new Set;let r;const o=()=>{if(t)return;const c=[...i];i.clear();try{for(const u of c)u()}finally{r=!1,i.size&&(r=!0,ls(o))}},a=new Proxy({},{get(c,u){if(n){let p=s.get(u);p||(p=new Set,s.set(u,p)),p.add(n)}return c[u]},set(c,u,p){if(c[u]!==p){c[u]=p;const d=s.get(u);if(d){for(const f of d)i.add(f);r||(r=!0,ls(o))}}return!0}}),l=c=>{const u=()=>{const p=n;n=u;try{return c()}finally{n=p}};return u()};return e.addEventListener("abort",()=>{t=!0}),{state:a,createEffect:l}}function li(e,t,n){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!n(e[s],t[s]))return!1;return!0}const va=new WeakMap;function Vm(e,t,n){{const s=e.closest(".tabpanel");let i=va.get(s);i||(i=new IntersectionObserver(n,{root:s,rootMargin:"50% 0px 50% 0px",threshold:0}),va.set(s,i),t.addEventListener("abort",()=>{i.disconnect()})),i.observe(e)}}const ci=[],{assign:Fn}=Object;function Qm(e,t){const n={},s=new AbortController,i=s.signal,{state:r,createEffect:o}=Gm(i),a=new Map;Fn(r,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),Fn(r,t),Fn(r,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:gm,isRtl:!1,currentGroupIndex:0,groups:si,databaseLoaded:!1,activeSearchItemId:void 0}),o(()=>{r.currentGroup!==r.groups[r.currentGroupIndex]&&(r.currentGroup=r.groups[r.currentGroupIndex])});const l=x=>{e.getElementById(x).focus()},c=x=>e.getElementById(`emo-${x.id}`),u=(x,_)=>{n.rootElement.dispatchEvent(new CustomEvent(x,{detail:_,bubbles:!0,composed:!0}))},p=(x,_)=>x.id===_.id,d=(x,_)=>{const{category:I,emojis:N}=x,{category:H,emojis:K}=_;return I!==H?!1:li(N,K,p)},f=x=>{li(r.currentEmojis,x,p)||(r.currentEmojis=x)},b=x=>{r.searchMode!==x&&(r.searchMode=x)},w=x=>{li(r.currentEmojisWithCategories,x,d)||(r.currentEmojisWithCategories=x)},S=(x,_)=>_&&x.skins&&x.skins[_]||x.unicode,E={labelWithSkin:(x,_)=>Lm([x.name||S(x,_),x.annotation,...x.shortcodes||ci].filter(Boolean)).join(", "),titleForEmoji:x=>x.annotation||(x.shortcodes||ci).join(", "),unicodeWithSkin:S},C={onClickSkinToneButton:j,onEmojiClick:vn,onNavClick:mn,onNavKeydown:Es,onSearchKeydown:$s,onSkinToneOptionsClick:bn,onSkinToneOptionsFocusOut:Re,onSkinToneOptionsKeydown:He,onSkinToneOptionsKeyup:Rt,onSearchInput:wn},R={calculateEmojiGridStyle:ze,updateOnIntersection:Lt};let U=!0;o(()=>{qm(e,r,E,C,R,n,i,a,U),U=!1}),r.emojiVersion||ri().then(x=>{x||(r.message=r.i18n.emojiUnsupportedMessage)}),o(()=>{async function x(){let _=!1;const I=setTimeout(()=>{_=!0,r.message=r.i18n.loadingMessage},hm);try{await r.database.ready(),r.databaseLoaded=!0}catch(N){console.error(N),r.message=r.i18n.networkErrorMessage}finally{clearTimeout(I),_&&(_=!1,r.message="")}}r.database&&x()}),o(()=>{r.pickerStyle=`
|
|
1895
|
+
For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),s}function Pm(e){return Mc(e,t=>t)}function Rm(e){e&&(e.scrollTop=0)}function tn(e,t,n){let s=e.get(t);return s||(s=n(),e.set(t,s)),s}function ba(e){return""+e}function Im(e){const t=document.createElement("template");return t.innerHTML=e,t}const Nm=new WeakMap,Dm=new WeakMap,Om=Symbol("un-keyed"),Bm="replaceChildren"in Element.prototype;function Fm(e,t){Bm?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function Um(e,t){let n=e.firstChild,s=0;for(;n;){if(t[s]!==n)return!0;n=n.nextSibling,s++}return s!==t.length}function Wm(e,t){const{targetNode:n}=t;let{targetParentNode:s}=t,i=!1;s?i=Um(s,e):(i=!0,t.targetNode=void 0,t.targetParentNode=s=n.parentNode),i&&Fm(s,e)}function Km(e,t){for(const n of t){const{targetNode:s,currentExpression:i,binding:{expressionIndex:r,attributeName:o,attributeValuePre:a,attributeValuePost:l}}=n,c=e[r];if(i!==c)if(n.currentExpression=c,o)if(c===null)s.removeAttribute(o);else{const u=a+ba(c)+l;s.setAttribute(o,u)}else{let u;Array.isArray(c)?Wm(c,n):c instanceof Element?(u=c,s.replaceWith(u)):s.nodeValue=ba(c),u&&(n.targetNode=u)}}}function zm(e){let t="",n=!1,s=!1,i=-1;const r=new Map,o=[];let a=0;for(let c=0,u=e.length;c<u;c++){const p=e[c];if(t+=p.slice(a),c===u-1)break;for(let A=0;A<p.length;A++)switch(p.charAt(A)){case"<":{p.charAt(A+1)==="/"?o.pop():(n=!0,o.push(++i));break}case">":{n=!1,s=!1;break}case"=":{s=!0;break}}const d=o[o.length-1],h=tn(r,d,()=>[]);let b,w,S;if(s){const A=/(\S+)="?([^"=]*)$/.exec(p);b=A[1],w=A[2];const E=/^([^">]*)("?)/.exec(e[c+1]);S=E[1],t=t.slice(0,-1*A[0].length),a=E[0].length}else a=0;const T={attributeName:b,attributeValuePre:w,attributeValuePost:S,expressionIndex:c};h.push(T),!n&&!s&&(t+=" ")}return{template:Im(t),elementsToBindings:r}}function wa(e,t,n){for(let s=0;s<e.length;s++){const i=e[s],r=i.attributeName?t:t.firstChild,o={binding:i,targetNode:r,targetParentNode:void 0,currentExpression:void 0};n.push(o)}}function jm(e,t){const n=[];let s;if(t.size===1&&(s=t.get(0)))wa(s,e,n);else{const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let r=e,o=-1;do{const a=t.get(++o);a&&wa(a,r,n)}while(r=i.nextNode())}return n}function Hm(e){const{template:t,elementsToBindings:n}=tn(Nm,e,()=>zm(e)),s=t.cloneNode(!0).content.firstElementChild,i=jm(s,n);return function(o){return Km(o,i),s}}function qm(e){const t=tn(Dm,e,()=>new Map);let n=Om;function s(r,...o){const a=tn(t,r,()=>new Map);return tn(a,n,()=>Hm(r))(o)}function i(r,o,a){return r.map((l,c)=>{const u=n;n=a(l);try{return o(l,c)}finally{n=u}})}return{map:i,html:s}}function Gm(e,t,n,s,i,r,o,a,l){const{labelWithSkin:c,titleForEmoji:u,unicodeWithSkin:p}=n,{html:d,map:h}=qm(t);function b(A,E,C){return h(A,(R,U)=>d`<button role="${E?"option":"menuitem"}" aria-selected="${E?U===t.activeSearchItem:null}" aria-label="${c(R,t.currentSkinTone)}" title="${u(R)}" class="${"emoji"+(E&&U===t.activeSearchItem?" active":"")+(R.unicode?"":" custom-emoji")}" id="${`${C}-${R.id}`}" style="${R.unicode?null:`--custom-emoji-background: url(${JSON.stringify(R.url)})`}">${R.unicode?p(R,t.currentSkinTone):""}</button>`,R=>`${C}-${R.id}`)}const S=d`<section data-ref="rootElement" class="picker" aria-label="${t.i18n.regionLabel}" style="${t.pickerStyle||""}"><div class="pad-top"></div><div class="search-row"><div class="search-wrapper"><input id="search" class="search" type="search" role="combobox" enterkeyhint="search" placeholder="${t.i18n.searchLabel}" autocapitalize="none" autocomplete="off" spellcheck="true" aria-expanded="${!!(t.searchMode&&t.currentEmojis.length)}" aria-controls="search-results" aria-describedby="search-description" aria-autocomplete="list" aria-activedescendant="${t.activeSearchItemId?`emo-${t.activeSearchItemId}`:null}" data-ref="searchElement" data-on-input="onSearchInput" data-on-keydown="onSearchKeydown"><label class="sr-only" for="search">${t.i18n.searchLabel}</label> <span id="search-description" class="sr-only">${t.i18n.searchDescription}</span></div><div class="skintone-button-wrapper ${t.skinTonePickerExpandedAfterAnimation?"expanded":""}"><button id="skintone-button" class="emoji ${t.skinTonePickerExpanded?"hide-focus":""}" aria-label="${t.skinToneButtonLabel}" title="${t.skinToneButtonLabel}" aria-describedby="skintone-description" aria-haspopup="listbox" aria-expanded="${t.skinTonePickerExpanded}" aria-controls="skintone-list" data-on-click="onClickSkinToneButton">${t.skinToneButtonText||""}</button></div><span id="skintone-description" class="sr-only">${t.i18n.skinToneDescription}</span><div data-ref="skinToneDropdown" id="skintone-list" class="skintone-list hide-focus ${t.skinTonePickerExpanded?"":"hidden no-animate"}" style="transform:translateY(${t.skinTonePickerExpanded?0:"calc(-1 * var(--num-skintones) * var(--total-emoji-size))"})" role="listbox" aria-label="${t.i18n.skinTonesLabel}" aria-activedescendant="skintone-${t.activeSkinTone}" aria-hidden="${!t.skinTonePickerExpanded}" tabIndex="-1" data-on-focusout="onSkinToneOptionsFocusOut" data-on-click="onSkinToneOptionsClick" data-on-keydown="onSkinToneOptionsKeydown" data-on-keyup="onSkinToneOptionsKeyup">${h(t.skinTones,(A,E)=>d`<div id="skintone-${E}" class="emoji ${E===t.activeSkinTone?"active":""}" aria-selected="${E===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[E]}" aria-label="${t.i18n.skinTones[E]}">${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">${h(t.groups,A=>d`<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">${h(t.currentEmojisWithCategories,(A,E)=>d`<div><div id="menu-label-${E}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:A.category?A.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${E!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(A.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${E}" id="${t.searchMode?"search-results":null}">${b(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">${b(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,T=(A,E)=>{for(const C of e.querySelectorAll(`[${A}]`))E(C,C.getAttribute(A))};if(l){e.appendChild(S);for(const A of["click","focusout","input","keydown","keyup"])T(`data-on-${A}`,(E,C)=>{E.addEventListener(A,s[C])});T("data-ref",(A,E)=>{r[E]=A}),o.addEventListener("abort",()=>{e.removeChild(S)})}T("data-action",(A,E)=>{let C=a.get(E);C||a.set(E,C=new WeakSet),C.has(A)||(C.add(A),i[E](A))})}const cs=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Vm(e){let t=!1,n;const s=new Map,i=new Set;let r;const o=()=>{if(t)return;const c=[...i];i.clear();try{for(const u of c)u()}finally{r=!1,i.size&&(r=!0,cs(o))}},a=new Proxy({},{get(c,u){if(n){let p=s.get(u);p||(p=new Set,s.set(u,p)),p.add(n)}return c[u]},set(c,u,p){if(c[u]!==p){c[u]=p;const d=s.get(u);if(d){for(const h of d)i.add(h);r||(r=!0,cs(o))}}return!0}}),l=c=>{const u=()=>{const p=n;n=u;try{return c()}finally{n=p}};return u()};return e.addEventListener("abort",()=>{t=!0}),{state:a,createEffect:l}}function ci(e,t,n){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!n(e[s],t[s]))return!1;return!0}const ka=new WeakMap;function Qm(e,t,n){{const s=e.closest(".tabpanel");let i=ka.get(s);i||(i=new IntersectionObserver(n,{root:s,rootMargin:"50% 0px 50% 0px",threshold:0}),ka.set(s,i),t.addEventListener("abort",()=>{i.disconnect()})),i.observe(e)}}const ui=[],{assign:Fn}=Object;function Ym(e,t){const n={},s=new AbortController,i=s.signal,{state:r,createEffect:o}=Vm(i),a=new Map;Fn(r,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),Fn(r,t),Fn(r,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:mm,isRtl:!1,currentGroupIndex:0,groups:ii,databaseLoaded:!1,activeSearchItemId:void 0}),o(()=>{r.currentGroup!==r.groups[r.currentGroupIndex]&&(r.currentGroup=r.groups[r.currentGroupIndex])});const l=x=>{e.getElementById(x).focus()},c=x=>e.getElementById(`emo-${x.id}`),u=(x,_)=>{n.rootElement.dispatchEvent(new CustomEvent(x,{detail:_,bubbles:!0,composed:!0}))},p=(x,_)=>x.id===_.id,d=(x,_)=>{const{category:I,emojis:N}=x,{category:H,emojis:K}=_;return I!==H?!1:ci(N,K,p)},h=x=>{ci(r.currentEmojis,x,p)||(r.currentEmojis=x)},b=x=>{r.searchMode!==x&&(r.searchMode=x)},w=x=>{ci(r.currentEmojisWithCategories,x,d)||(r.currentEmojisWithCategories=x)},S=(x,_)=>_&&x.skins&&x.skins[_]||x.unicode,E={labelWithSkin:(x,_)=>Pm([x.name||S(x,_),x.annotation,...x.shortcodes||ui].filter(Boolean)).join(", "),titleForEmoji:x=>x.annotation||(x.shortcodes||ui).join(", "),unicodeWithSkin:S},C={onClickSkinToneButton:j,onEmojiClick:vn,onNavClick:mn,onNavKeydown:Ts,onSearchKeydown:Es,onSkinToneOptionsClick:bn,onSkinToneOptionsFocusOut:Re,onSkinToneOptionsKeydown:He,onSkinToneOptionsKeyup:Rt,onSearchInput:wn},R={calculateEmojiGridStyle:ze,updateOnIntersection:Lt};let U=!0;o(()=>{Gm(e,r,E,C,R,n,i,a,U),U=!1}),r.emojiVersion||oi().then(x=>{x||(r.message=r.i18n.emojiUnsupportedMessage)}),o(()=>{async function x(){let _=!1;const I=setTimeout(()=>{_=!0,r.message=r.i18n.loadingMessage},fm);try{await r.database.ready(),r.databaseLoaded=!0}catch(N){console.error(N),r.message=r.i18n.networkErrorMessage}finally{clearTimeout(I),_&&(_=!1,r.message="")}}r.database&&x()}),o(()=>{r.pickerStyle=`
|
|
1894
1896
|
--num-groups: ${r.groups.length};
|
|
1895
1897
|
--indicator-opacity: ${r.searchMode?0:1};
|
|
1896
|
-
--num-skintones: ${pa};`}),o(()=>{r.customEmoji&&r.database&&Q()}),o(()=>{r.customEmoji&&r.customEmoji.length?r.groups!==Oi&&(r.groups=Oi):r.groups!==si&&(r.currentGroupIndex&&r.currentGroupIndex--,r.groups=si)}),o(()=>{async function x(){r.databaseLoaded&&(r.currentSkinTone=await r.database.getPreferredSkinTone())}x()}),o(()=>{r.skinTones=Array(pa).fill().map((x,_)=>Em(r.skinToneEmoji,_))}),o(()=>{r.skinToneButtonText=r.skinTones[r.currentSkinTone]}),o(()=>{r.skinToneButtonLabel=r.i18n.skinToneLabel.replace("{skinTone}",r.i18n.skinTones[r.currentSkinTone])}),o(()=>{async function x(){const{database:_}=r,I=(await Promise.all(mm.map(N=>_.getEmojiByUnicodeOrName(N)))).filter(Boolean);r.defaultFavoriteEmojis=I}r.databaseLoaded&&x()});function Q(){const{customEmoji:x,database:_}=r,I=x||ci;_.customEmoji!==I&&(_.customEmoji=I)}o(()=>{async function x(){Q();const{database:_,defaultFavoriteEmojis:I,numColumns:N}=r,H=await _.getTopFavoriteEmoji(N),K=await je(Tc([...H,...I],ie=>ie.unicode||ie.name).slice(0,N));r.currentFavorites=K}r.databaseLoaded&&r.defaultFavoriteEmojis&&x()});function ze(x){_m(x,i,()=>{{const _=getComputedStyle(n.rootElement),I=parseInt(_.getPropertyValue("--num-columns"),10),N=_.getPropertyValue("direction")==="rtl";r.numColumns=I,r.isRtl=N}})}function Lt(x){Vm(x,i,_=>{for(const{target:I,isIntersecting:N}of _)I.classList.toggle("onscreen",N)})}o(()=>{async function x(){const{searchText:_,currentGroup:I,databaseLoaded:N,customEmoji:H}=r;if(!N)r.currentEmojis=[],r.searchMode=!1;else if(_.length>=dm){const K=await As(_);r.searchText===_&&(f(K),b(!0))}else{const{id:K}=I;if(K!==-1||H&&H.length){const ie=await xs(K);r.currentGroup.id===K&&(f(ie),b(!1))}}}x()});const gn=()=>{qn(()=>Pm(n.tabpanelElement))};o(()=>{const{currentEmojis:x,emojiVersion:_}=r,I=x.filter(N=>N.unicode).filter(N=>ha(N)&&!Bi.has(N.unicode));if(!_&&I.length)f(x),qn(()=>J(I));else{const N=_?x:x.filter(Pt);f(N),gn()}});function J(x){Mm(x,n.baselineEmoji,c)?gn():r.currentEmojis=[...r.currentEmojis]}function Pt(x){return!x.unicode||!ha(x)||Bi.get(x.unicode)}async function ut(x){const _=r.emojiVersion||await ri();return x.filter(({version:I})=>!I||I<=_)}async function je(x){return Tm(x,r.emojiVersion||await ri())}async function xs(x){const _=x===-1?r.customEmoji:await r.database.getEmojiByGroup(x);return je(await ut(_))}async function As(x){return je(await ut(await r.database.getEmojiBySearchQuery(x)))}o(()=>{}),o(()=>{function x(){const{searchMode:I,currentEmojis:N}=r;if(I)return[{category:"",emojis:N}];const H=new Map;for(const K of N){const ie=K.category||"";let Ie=H.get(ie);Ie||(Ie=[],H.set(ie,Ie)),Ie.push(K)}return[...H.entries()].map(([K,ie])=>({category:K,emojis:ie})).sort((K,ie)=>r.customCategorySorting(K.category,ie.category))}const _=x();w(_)}),o(()=>{r.activeSearchItemId=r.activeSearchItem!==-1&&r.currentEmojis[r.activeSearchItem].id}),o(()=>{const{rawSearchText:x}=r;$c(()=>{r.searchText=(x||"").trim(),r.activeSearchItem=-1})});function $s(x){if(!r.searchMode||!r.currentEmojis.length)return;const _=I=>{we(x),r.activeSearchItem=oi(I,r.activeSearchItem,r.currentEmojis)};switch(x.key){case"ArrowDown":return _(!1);case"ArrowUp":return _(!0);case"Enter":if(r.activeSearchItem===-1)r.activeSearchItem=0;else return we(x),G(r.currentEmojis[r.activeSearchItem].id)}}function mn(x){const{target:_}=x,I=_.closest(".nav-button");if(!I)return;const N=parseInt(I.dataset.groupId,10);n.searchElement.value="",r.rawSearchText="",r.searchText="",r.activeSearchItem=-1,r.currentGroupIndex=r.groups.findIndex(H=>H.id===N)}function Es(x){const{target:_,key:I}=x,N=H=>{H&&(we(x),H.focus())};switch(I){case"ArrowLeft":return N(_.previousElementSibling);case"ArrowRight":return N(_.nextElementSibling);case"Home":return N(_.parentElement.firstElementChild);case"End":return N(_.parentElement.lastElementChild)}}async function yn(x){const _=await r.database.getEmojiByUnicodeOrName(x),I=[...r.currentEmojis,...r.currentFavorites].find(H=>H.id===x),N=I.unicode&&S(I,r.currentSkinTone);return await r.database.incrementFavoriteEmojiCount(x),{emoji:_,skinTone:r.currentSkinTone,...N&&{unicode:N},...I.name&&{name:I.name}}}async function G(x){const _=yn(x);u("emoji-click-sync",_),u("emoji-click",await _)}function vn(x){const{target:_}=x;if(!_.classList.contains("emoji"))return;we(x);const I=_.id.substring(4);G(I)}function V(x){r.currentSkinTone=x,r.skinTonePickerExpanded=!1,l("skintone-button"),u("skin-tone-change",{skinTone:x}),r.database.setPreferredSkinTone(x)}function bn(x){const{target:{id:_}}=x,I=_&&_.match(/^skintone-(\d)/);if(!I)return;we(x);const N=parseInt(I[1],10);V(N)}function j(x){r.skinTonePickerExpanded=!r.skinTonePickerExpanded,r.activeSkinTone=r.currentSkinTone,r.skinTonePickerExpanded&&(we(x),qn(()=>l("skintone-list")))}o(()=>{r.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{r.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):r.skinTonePickerExpandedAfterAnimation=!1});function He(x){if(!r.skinTonePickerExpanded)return;const _=async I=>{we(x),r.activeSkinTone=I};switch(x.key){case"ArrowUp":return _(oi(!0,r.activeSkinTone,r.skinTones));case"ArrowDown":return _(oi(!1,r.activeSkinTone,r.skinTones));case"Home":return _(0);case"End":return _(r.skinTones.length-1);case"Enter":return we(x),V(r.activeSkinTone);case"Escape":return we(x),r.skinTonePickerExpanded=!1,l("skintone-button")}}function Rt(x){if(r.skinTonePickerExpanded&&x.key===" ")return we(x),V(r.activeSkinTone)}async function Re(x){const{relatedTarget:_}=x;(!_||_.id!=="skintone-list")&&(r.skinTonePickerExpanded=!1)}function wn(x){r.rawSearchText=x.target.value}return{$set(x){Fn(r,x)},$destroy(){s.abort()}}}const Ym="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Xm="en";var Zm={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"}},Jm=':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 Cc=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],ey=`:host{--emoji-font-family:${Ec}}`;class Ir extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Jm+ey,this.shadowRoot.appendChild(n),this._ctx={locale:Xm,dataSource:Ym,skinToneEmoji:fm,customCategorySorting:ym,customEmoji:null,i18n:Zm,emojiVersion:null,...t};for(const s of Cc)s!=="database"&&Object.prototype.hasOwnProperty.call(this,s)&&(this._ctx[s]=this[s],delete this[s]);this._dbFlush()}connectedCallback(){ba(this),this._cmp||(this._cmp=Qm(this.shadowRoot,this._ctx))}disconnectedCallback(){ba(this),ls(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:t}=this._ctx;t.close().catch(n=>console.error(n))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(t,n,s){this._set(t.replace(/-([a-z])/g,(i,r)=>r.toUpperCase()),t==="emoji-version"?parseFloat(s):s)}_set(t,n){this._ctx[t]=n,this._cmp&&this._cmp.$set({[t]:n}),["locale","dataSource"].includes(t)&&this._dbFlush()}_dbCreate(){const{locale:t,dataSource:n,database:s}=this._ctx;(!s||s.locale!==t||s.dataSource!==n)&&this._set("database",new um({locale:t,dataSource:n}))}_dbFlush(){ls(()=>this._dbCreate())}}const _c={};for(const e of Cc)_c[e]={get(){return e==="database"&&this._dbCreate(),this._ctx[e]},set(t){if(e==="database")throw new Error("database is read-only");this._set(e,t)}};Object.defineProperties(Ir.prototype,_c);function ba(e){e instanceof Ir||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Ir);function ty(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 wa(e){e.style.height="44px",e.style.overflowY="hidden"}const ny=5e3;function sy(e){return e?e.active?h`
|
|
1898
|
+
--num-skintones: ${ga};`}),o(()=>{r.customEmoji&&r.database&&Q()}),o(()=>{r.customEmoji&&r.customEmoji.length?r.groups!==Bi&&(r.groups=Bi):r.groups!==ii&&(r.currentGroupIndex&&r.currentGroupIndex--,r.groups=ii)}),o(()=>{async function x(){r.databaseLoaded&&(r.currentSkinTone=await r.database.getPreferredSkinTone())}x()}),o(()=>{r.skinTones=Array(ga).fill().map((x,_)=>Tm(r.skinToneEmoji,_))}),o(()=>{r.skinToneButtonText=r.skinTones[r.currentSkinTone]}),o(()=>{r.skinToneButtonLabel=r.i18n.skinToneLabel.replace("{skinTone}",r.i18n.skinTones[r.currentSkinTone])}),o(()=>{async function x(){const{database:_}=r,I=(await Promise.all(ym.map(N=>_.getEmojiByUnicodeOrName(N)))).filter(Boolean);r.defaultFavoriteEmojis=I}r.databaseLoaded&&x()});function Q(){const{customEmoji:x,database:_}=r,I=x||ui;_.customEmoji!==I&&(_.customEmoji=I)}o(()=>{async function x(){Q();const{database:_,defaultFavoriteEmojis:I,numColumns:N}=r,H=await _.getTopFavoriteEmoji(N),K=await je(Mc([...H,...I],ie=>ie.unicode||ie.name).slice(0,N));r.currentFavorites=K}r.databaseLoaded&&r.defaultFavoriteEmojis&&x()});function ze(x){Mm(x,i,()=>{{const _=getComputedStyle(n.rootElement),I=parseInt(_.getPropertyValue("--num-columns"),10),N=_.getPropertyValue("direction")==="rtl";r.numColumns=I,r.isRtl=N}})}function Lt(x){Qm(x,i,_=>{for(const{target:I,isIntersecting:N}of _)I.classList.toggle("onscreen",N)})}o(()=>{async function x(){const{searchText:_,currentGroup:I,databaseLoaded:N,customEmoji:H}=r;if(!N)r.currentEmojis=[],r.searchMode=!1;else if(_.length>=pm){const K=await $s(_);r.searchText===_&&(h(K),b(!0))}else{const{id:K}=I;if(K!==-1||H&&H.length){const ie=await As(K);r.currentGroup.id===K&&(h(ie),b(!1))}}}x()});const gn=()=>{qn(()=>Rm(n.tabpanelElement))};o(()=>{const{currentEmojis:x,emojiVersion:_}=r,I=x.filter(N=>N.unicode).filter(N=>ma(N)&&!Fi.has(N.unicode));if(!_&&I.length)h(x),qn(()=>J(I));else{const N=_?x:x.filter(Pt);h(N),gn()}});function J(x){Lm(x,n.baselineEmoji,c)?gn():r.currentEmojis=[...r.currentEmojis]}function Pt(x){return!x.unicode||!ma(x)||Fi.get(x.unicode)}async function ut(x){const _=r.emojiVersion||await oi();return x.filter(({version:I})=>!I||I<=_)}async function je(x){return Cm(x,r.emojiVersion||await oi())}async function As(x){const _=x===-1?r.customEmoji:await r.database.getEmojiByGroup(x);return je(await ut(_))}async function $s(x){return je(await ut(await r.database.getEmojiBySearchQuery(x)))}o(()=>{}),o(()=>{function x(){const{searchMode:I,currentEmojis:N}=r;if(I)return[{category:"",emojis:N}];const H=new Map;for(const K of N){const ie=K.category||"";let Ie=H.get(ie);Ie||(Ie=[],H.set(ie,Ie)),Ie.push(K)}return[...H.entries()].map(([K,ie])=>({category:K,emojis:ie})).sort((K,ie)=>r.customCategorySorting(K.category,ie.category))}const _=x();w(_)}),o(()=>{r.activeSearchItemId=r.activeSearchItem!==-1&&r.currentEmojis[r.activeSearchItem].id}),o(()=>{const{rawSearchText:x}=r;Cc(()=>{r.searchText=(x||"").trim(),r.activeSearchItem=-1})});function Es(x){if(!r.searchMode||!r.currentEmojis.length)return;const _=I=>{we(x),r.activeSearchItem=ai(I,r.activeSearchItem,r.currentEmojis)};switch(x.key){case"ArrowDown":return _(!1);case"ArrowUp":return _(!0);case"Enter":if(r.activeSearchItem===-1)r.activeSearchItem=0;else return we(x),G(r.currentEmojis[r.activeSearchItem].id)}}function mn(x){const{target:_}=x,I=_.closest(".nav-button");if(!I)return;const N=parseInt(I.dataset.groupId,10);n.searchElement.value="",r.rawSearchText="",r.searchText="",r.activeSearchItem=-1,r.currentGroupIndex=r.groups.findIndex(H=>H.id===N)}function Ts(x){const{target:_,key:I}=x,N=H=>{H&&(we(x),H.focus())};switch(I){case"ArrowLeft":return N(_.previousElementSibling);case"ArrowRight":return N(_.nextElementSibling);case"Home":return N(_.parentElement.firstElementChild);case"End":return N(_.parentElement.lastElementChild)}}async function yn(x){const _=await r.database.getEmojiByUnicodeOrName(x),I=[...r.currentEmojis,...r.currentFavorites].find(H=>H.id===x),N=I.unicode&&S(I,r.currentSkinTone);return await r.database.incrementFavoriteEmojiCount(x),{emoji:_,skinTone:r.currentSkinTone,...N&&{unicode:N},...I.name&&{name:I.name}}}async function G(x){const _=yn(x);u("emoji-click-sync",_),u("emoji-click",await _)}function vn(x){const{target:_}=x;if(!_.classList.contains("emoji"))return;we(x);const I=_.id.substring(4);G(I)}function V(x){r.currentSkinTone=x,r.skinTonePickerExpanded=!1,l("skintone-button"),u("skin-tone-change",{skinTone:x}),r.database.setPreferredSkinTone(x)}function bn(x){const{target:{id:_}}=x,I=_&&_.match(/^skintone-(\d)/);if(!I)return;we(x);const N=parseInt(I[1],10);V(N)}function j(x){r.skinTonePickerExpanded=!r.skinTonePickerExpanded,r.activeSkinTone=r.currentSkinTone,r.skinTonePickerExpanded&&(we(x),qn(()=>l("skintone-list")))}o(()=>{r.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{r.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):r.skinTonePickerExpandedAfterAnimation=!1});function He(x){if(!r.skinTonePickerExpanded)return;const _=async I=>{we(x),r.activeSkinTone=I};switch(x.key){case"ArrowUp":return _(ai(!0,r.activeSkinTone,r.skinTones));case"ArrowDown":return _(ai(!1,r.activeSkinTone,r.skinTones));case"Home":return _(0);case"End":return _(r.skinTones.length-1);case"Enter":return we(x),V(r.activeSkinTone);case"Escape":return we(x),r.skinTonePickerExpanded=!1,l("skintone-button")}}function Rt(x){if(r.skinTonePickerExpanded&&x.key===" ")return we(x),V(r.activeSkinTone)}async function Re(x){const{relatedTarget:_}=x;(!_||_.id!=="skintone-list")&&(r.skinTonePickerExpanded=!1)}function wn(x){r.rawSearchText=x.target.value}return{$set(x){Fn(r,x)},$destroy(){s.abort()}}}const Xm="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Zm="en";var Jm={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"}},ey=':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 Lc=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],ty=`:host{--emoji-font-family:${_c}}`;class Ir extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=ey+ty,this.shadowRoot.appendChild(n),this._ctx={locale:Zm,dataSource:Xm,skinToneEmoji:gm,customCategorySorting:vm,customEmoji:null,i18n:Jm,emojiVersion:null,...t};for(const s of Lc)s!=="database"&&Object.prototype.hasOwnProperty.call(this,s)&&(this._ctx[s]=this[s],delete this[s]);this._dbFlush()}connectedCallback(){Sa(this),this._cmp||(this._cmp=Ym(this.shadowRoot,this._ctx))}disconnectedCallback(){Sa(this),cs(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:t}=this._ctx;t.close().catch(n=>console.error(n))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(t,n,s){this._set(t.replace(/-([a-z])/g,(i,r)=>r.toUpperCase()),t==="emoji-version"?parseFloat(s):s)}_set(t,n){this._ctx[t]=n,this._cmp&&this._cmp.$set({[t]:n}),["locale","dataSource"].includes(t)&&this._dbFlush()}_dbCreate(){const{locale:t,dataSource:n,database:s}=this._ctx;(!s||s.locale!==t||s.dataSource!==n)&&this._set("database",new dm({locale:t,dataSource:n}))}_dbFlush(){cs(()=>this._dbCreate())}}const Pc={};for(const e of Lc)Pc[e]={get(){return e==="database"&&this._dbCreate(),this._ctx[e]},set(t){if(e==="database")throw new Error("database is read-only");this._set(e,t)}};Object.defineProperties(Ir.prototype,Pc);function Sa(e){e instanceof Ir||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Ir);function ny(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 xa(e){e.style.height="44px",e.style.overflowY="hidden"}const sy=5e3;function iy(e){return e?e.active?f`
|
|
1897
1899
|
<div class="callout info compaction-indicator compaction-indicator--active">
|
|
1898
1900
|
${O.loader} Compacting context...
|
|
1899
1901
|
</div>
|
|
1900
|
-
`:e.completedAt&&Date.now()-e.completedAt<
|
|
1902
|
+
`:e.completedAt&&Date.now()-e.completedAt<sy?f`
|
|
1901
1903
|
<div class="callout success compaction-indicator compaction-indicator--complete">
|
|
1902
1904
|
${O.check} Context compacted
|
|
1903
1905
|
</div>
|
|
1904
|
-
`:k:k}const Vt=5*1024*1024;function Qt(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function vt(e,t){var s,i,r;let n=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-attachment-error");if(!n){n=document.createElement("div"),n.className="callout danger chat-attachment-error",n.style.cssText="margin: 8px 4px; animation: fade-in 200ms ease-out;";const o=(i=e.closest(".chat"))==null?void 0:i.querySelector(".chat-compose");(r=o==null?void 0:o.parentElement)==null||r.insertBefore(n,o)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const
|
|
1906
|
+
`:k:k}const Vt=5*1024*1024;function Qt(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function vt(e,t){var s,i,r;let n=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-attachment-error");if(!n){n=document.createElement("div"),n.className="callout danger chat-attachment-error",n.style.cssText="margin: 8px 4px; animation: fade-in 200ms ease-out;";const o=(i=e.closest(".chat"))==null?void 0:i.querySelector(".chat-compose");(r=o==null?void 0:o.parentElement)==null||r.insertBefore(n,o)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const ry=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function oy(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function ay(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||ry.test(e.name)}function ly(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function cy(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function uy(e,t){var i;e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const s=(i=e.dataTransfer)==null?void 0:i.files;if(!(!s||s.length===0))for(let r=0;r<s.length;r++){const o=s[r];if(oy(o)){if(!t.onAttachmentsChange)continue;if(o.size>Vt){vt(n,`Image too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const l=a.result,c={id:Qt(),dataUrl:l,mimeType:o.type},u=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...u,c])},a.readAsDataURL(o)}else if(ay(o)){if(!t.onAttachmentsChange)continue;if(o.size>Vt){vt(n,`File too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const l=a.result,c={id:Qt(),dataUrl:"",mimeType:o.type||"text/plain",fileName:o.name,textContent:l},u=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...u,c])},a.readAsText(o)}else if(ly(o)){if(!t.onAttachmentsChange)continue;if(o.size>Vt){vt(n,`PDF too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const l=a.result,c={id:Qt(),dataUrl:l,mimeType:"application/pdf",fileName:o.name},u=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...u,c])},a.readAsDataURL(o)}else if(cy(o)){if(!t.onAttachmentsChange)continue;if(o.size>Vt){vt(n,`Video too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const a=new FileReader;a.onload=()=>{var p;const l=a.result,c={id:Qt(),dataUrl:l,mimeType:o.type||"video/mp4",fileName:o.name},u=t.attachments??[];(p=t.onAttachmentsChange)==null||p.call(t,[...u,c])},a.readAsDataURL(o)}else vt(n,`Unsupported file type: ${o.name}. Use the Files page to upload to workspace.`)}}function dy(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function py(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function hy(e,t){var i,r,o;const n=(i=e.clipboardData)==null?void 0:i.items;if(!n||!t.onAttachmentsChange)return;const s=[];for(let a=0;a<n.length;a++){const l=n[a];(l.type.startsWith("image/")||l.type.startsWith("video/"))&&s.push(l)}if(s.length!==0){e.preventDefault();for(const a of s){const l=a.getAsFile();if(!l)continue;const c=l.type.startsWith("video/")?"Video":"Image";if(l.size>Vt){const p=((o=(r=e.target)==null?void 0:r.closest)==null?void 0:o.call(r,".chat"))??document.querySelector(".chat");p&&vt(p,`${c} too large (${(l.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const u=new FileReader;u.onload=()=>{var w;const p=u.result,d=l.type.startsWith("video/"),h={id:Qt(),dataUrl:p,mimeType:l.type,fileName:d?l.name||"video.mp4":void 0},b=t.attachments??[];(w=t.onAttachmentsChange)==null||w.call(t,[...b,h])},u.readAsDataURL(l)}}}function fy(e){const t=e.currentTarget,n=t.closest(".chat-compose"),s=n==null?void 0:n.querySelector(".emoji-picker-popup");if(!s)return;const i=s.classList.toggle("active");if(t.classList.toggle("active",i),i){const r=o=>{s.contains(o.target)||t.contains(o.target)||(s.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",r,!0))};requestAnimationFrame(()=>document.addEventListener("click",r,!0))}}function gy(e,t){const n=e.detail,s=n==null?void 0:n.unicode;if(!s)return;const i=e.currentTarget.closest(".chat-compose"),r=i==null?void 0:i.querySelector("textarea");if(!r)return;const o=r.selectionStart??t.draft.length,a=r.selectionEnd??o,l=t.draft.slice(0,o),c=t.draft.slice(a);t.onDraftChange(l+s+c);const u=i==null?void 0:i.querySelector(".emoji-picker-popup"),p=i==null?void 0:i.querySelector(".chat-compose__emoji");u==null||u.classList.remove("active"),p==null||p.classList.remove("active"),requestAnimationFrame(()=>{r.focus();const d=o+s.length;r.setSelectionRange(d,d)})}function my(e){const t=e.attachments??[];return t.length===0?k:f`
|
|
1905
1907
|
<div class="chat-attachments">
|
|
1906
|
-
${t.map(n=>{var s;return n.fileName?
|
|
1908
|
+
${t.map(n=>{var s;return n.fileName?f`
|
|
1907
1909
|
<div class="chat-attachment chat-attachment--file">
|
|
1908
1910
|
<span class="chat-attachment__icon">${(s=n.mimeType)!=null&&s.startsWith("video/")?O.film:O.fileText}</span>
|
|
1909
1911
|
<span class="chat-attachment__name" title=${n.fileName}>${n.fileName}</span>
|
|
@@ -1916,7 +1918,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
1916
1918
|
${O.x}
|
|
1917
1919
|
</button>
|
|
1918
1920
|
</div>
|
|
1919
|
-
`:
|
|
1921
|
+
`:f`
|
|
1920
1922
|
<div class="chat-attachment">
|
|
1921
1923
|
<img
|
|
1922
1924
|
src=${n.dataUrl}
|
|
@@ -1934,30 +1936,30 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
1934
1936
|
</div>
|
|
1935
1937
|
`})}
|
|
1936
1938
|
</div>
|
|
1937
|
-
`}function
|
|
1939
|
+
`}function yy(e){var d,h,b;const t=e.connected,n=e.sending||e.stream!==null,s=!!(e.canAbort&&e.onAbort),i=(h=(d=e.sessions)==null?void 0:d.sessions)==null?void 0:h.find(w=>w.key===e.sessionKey),r=(i==null?void 0:i.reasoningLevel)??"off",o=e.showThinking&&r!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const a=(((b=e.attachments)==null?void 0:b.length)??0)>0,l=e.connected?a?"Add a message...":"Message...":"Connecting…",c=e.splitRatio??.6,u=!!(e.sidebarOpen&&e.onCloseSidebar),p=f`
|
|
1938
1940
|
<div
|
|
1939
1941
|
class="chat-thread"
|
|
1940
1942
|
role="log"
|
|
1941
1943
|
aria-live="polite"
|
|
1942
1944
|
@scroll=${e.onChatScroll}
|
|
1943
1945
|
>
|
|
1944
|
-
${e.loading?
|
|
1945
|
-
${
|
|
1946
|
+
${e.loading?f`<div class="muted">Loading chat…</div>`:k}
|
|
1947
|
+
${Vh(Ay(e),w=>w.key,w=>w.kind==="reading-indicator"?vg():w.kind==="stream"?bg(w.text,w.startedAt,e.onOpenSidebar):w.kind==="group"?wg(w,{onOpenSidebar:e.onOpenSidebar,showReasoning:o,assistantName:e.assistantName}):k)}
|
|
1946
1948
|
</div>
|
|
1947
|
-
`;return
|
|
1949
|
+
`;return f`
|
|
1948
1950
|
<section
|
|
1949
1951
|
class="card chat"
|
|
1950
|
-
@drop=${w=>
|
|
1951
|
-
@dragover=${
|
|
1952
|
-
@dragleave=${
|
|
1952
|
+
@drop=${w=>uy(w,e)}
|
|
1953
|
+
@dragover=${dy}
|
|
1954
|
+
@dragleave=${py}
|
|
1953
1955
|
>
|
|
1954
|
-
${e.disabledReason?
|
|
1956
|
+
${e.disabledReason?f`<div class="callout">${e.disabledReason}</div>`:k}
|
|
1955
1957
|
|
|
1956
|
-
${e.error?
|
|
1958
|
+
${e.error?f`<div class="callout danger">${e.error}</div>`:k}
|
|
1957
1959
|
|
|
1958
|
-
${
|
|
1960
|
+
${iy(e.compactionStatus)}
|
|
1959
1961
|
|
|
1960
|
-
${e.focusMode?
|
|
1962
|
+
${e.focusMode?f`
|
|
1961
1963
|
<button
|
|
1962
1964
|
class="chat-focus-exit"
|
|
1963
1965
|
type="button"
|
|
@@ -1977,7 +1979,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
1977
1979
|
style="flex: ${u?`0 0 ${c*100}%`:"1 1 100%"}"
|
|
1978
1980
|
>
|
|
1979
1981
|
${p}
|
|
1980
|
-
${e.nearBottom===!1?
|
|
1982
|
+
${e.nearBottom===!1?f`
|
|
1981
1983
|
<button
|
|
1982
1984
|
class="chat-scroll-bottom"
|
|
1983
1985
|
type="button"
|
|
@@ -1990,13 +1992,13 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
1990
1992
|
`:k}
|
|
1991
1993
|
</div>
|
|
1992
1994
|
|
|
1993
|
-
${u?
|
|
1995
|
+
${u?f`
|
|
1994
1996
|
<resizable-divider
|
|
1995
1997
|
.splitRatio=${c}
|
|
1996
1998
|
@resize=${w=>{var S;return(S=e.onSplitRatioChange)==null?void 0:S.call(e,w.detail.splitRatio)}}
|
|
1997
1999
|
></resizable-divider>
|
|
1998
2000
|
<div class="chat-sidebar">
|
|
1999
|
-
${
|
|
2001
|
+
${Sg({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
|
|
2000
2002
|
${e.sidebarContent}
|
|
2001
2003
|
\`\`\``)}})}
|
|
2002
2004
|
</div>
|
|
@@ -2004,12 +2006,12 @@ ${e.sidebarContent}
|
|
|
2004
2006
|
</div>
|
|
2005
2007
|
|
|
2006
2008
|
<div class="chat-compose">
|
|
2007
|
-
${
|
|
2009
|
+
${my(e)}
|
|
2008
2010
|
<div class="chat-compose__row">
|
|
2009
2011
|
<button
|
|
2010
2012
|
class="chat-compose__emoji"
|
|
2011
2013
|
type="button"
|
|
2012
|
-
@click=${
|
|
2014
|
+
@click=${fy}
|
|
2013
2015
|
aria-label="Emoji"
|
|
2014
2016
|
title="Emoji"
|
|
2015
2017
|
>
|
|
@@ -2020,13 +2022,13 @@ ${e.sidebarContent}
|
|
|
2020
2022
|
<textarea
|
|
2021
2023
|
.value=${e.draft}
|
|
2022
2024
|
?disabled=${!e.connected}
|
|
2023
|
-
@keydown=${w=>{w.key==="Enter"&&(w.isComposing||w.keyCode===229||w.shiftKey||e.connected&&(w.preventDefault(),t&&(e.onSend(),
|
|
2024
|
-
@input=${w=>{const S=w.target;e.onDraftChange(S.value),
|
|
2025
|
-
@paste=${w=>
|
|
2025
|
+
@keydown=${w=>{w.key==="Enter"&&(w.isComposing||w.keyCode===229||w.shiftKey||e.connected&&(w.preventDefault(),t&&(e.onSend(),xa(w.target))))}}
|
|
2026
|
+
@input=${w=>{const S=w.target;e.onDraftChange(S.value),ny(S)}}
|
|
2027
|
+
@paste=${w=>hy(w,e)}
|
|
2026
2028
|
placeholder=${l}
|
|
2027
2029
|
></textarea>
|
|
2028
2030
|
</label>
|
|
2029
|
-
${s?
|
|
2031
|
+
${s?f`
|
|
2030
2032
|
<button
|
|
2031
2033
|
class="btn btn--icon chat-compose__send"
|
|
2032
2034
|
@click=${e.onAbort}
|
|
@@ -2039,7 +2041,7 @@ ${e.sidebarContent}
|
|
|
2039
2041
|
<button
|
|
2040
2042
|
class="btn btn--icon chat-compose__send primary"
|
|
2041
2043
|
?disabled=${!e.connected}
|
|
2042
|
-
@click=${w=>{var T;e.onSend();const S=(T=w.target.closest(".chat-compose"))==null?void 0:T.querySelector("textarea");S&&
|
|
2044
|
+
@click=${w=>{var T;e.onSend();const S=(T=w.target.closest(".chat-compose"))==null?void 0:T.querySelector("textarea");S&&xa(S)}}
|
|
2043
2045
|
aria-label="${n?"Queue":"Send"}"
|
|
2044
2046
|
title="${n?"Queue message":"Send (Enter)"}"
|
|
2045
2047
|
>
|
|
@@ -2048,13 +2050,13 @@ ${e.sidebarContent}
|
|
|
2048
2050
|
</div>
|
|
2049
2051
|
<div class="emoji-picker-popup">
|
|
2050
2052
|
<emoji-picker
|
|
2051
|
-
@emoji-click=${w=>
|
|
2053
|
+
@emoji-click=${w=>gy(w,e)}
|
|
2052
2054
|
></emoji-picker>
|
|
2053
2055
|
</div>
|
|
2054
|
-
${
|
|
2056
|
+
${Sy(e)}
|
|
2055
2057
|
</div>
|
|
2056
2058
|
</section>
|
|
2057
|
-
`}const
|
|
2059
|
+
`}const vy=[{id:"claude-opus-4-6",shortName:"Opus",description:"Most capable"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet",description:"Fast & capable"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku",description:"Fastest"}];function by(e){const t=new Set(e.filter(n=>n.provider==="anthropic").map(n=>n.id));return vy.filter(n=>t.has(n.id)).map(n=>({key:`anthropic/${n.id}`,...n}))}const wy=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function ky(e){var i;const t=e.currentTarget,n=(i=t.closest(".chat-model-bar"))==null?void 0:i.querySelector(".chat-settings-menu");if(!n)return;const s=n.classList.contains("active");if(document.querySelectorAll(".chat-settings-menu.active").forEach(r=>r.classList.remove("active")),!s){n.classList.add("active");const r=o=>{!n.contains(o.target)&&o.target!==t&&!t.contains(o.target)&&(n.classList.remove("active"),document.removeEventListener("click",r))};requestAnimationFrame(()=>document.addEventListener("click",r))}}function Sy(e){if(!e.connected)return k;const t=e.modelCatalog??[],n=by(t);if(n.length===0)return k;const s=e.modelProvider&&e.model?`${e.modelProvider}/${e.model}`:null,i=e.thinkingLevel??"off",r=e.verboseLevel==="on"||e.verboseLevel==="full",o=e.fillerEnabled===!0;return f`
|
|
2058
2060
|
<div class="chat-model-bar">
|
|
2059
2061
|
<div class="chat-model-bar__select">
|
|
2060
2062
|
<select
|
|
@@ -2062,7 +2064,7 @@ ${e.sidebarContent}
|
|
|
2062
2064
|
.value=${s??""}
|
|
2063
2065
|
@change=${a=>{const l=a.target.value;l&&e.onModelChange&&e.onModelChange(l)}}
|
|
2064
2066
|
>
|
|
2065
|
-
${n.map(a=>
|
|
2067
|
+
${n.map(a=>f`
|
|
2066
2068
|
<option value=${a.key} ?selected=${a.key===s}>
|
|
2067
2069
|
${a.shortName} — ${a.description}
|
|
2068
2070
|
</option>
|
|
@@ -2075,7 +2077,7 @@ ${e.sidebarContent}
|
|
|
2075
2077
|
.value=${i}
|
|
2076
2078
|
@change=${a=>{const l=a.target.value;e.onThinkingLevelChange&&e.onThinkingLevelChange(l)}}
|
|
2077
2079
|
>
|
|
2078
|
-
${
|
|
2080
|
+
${wy.map(a=>f`
|
|
2079
2081
|
<option value=${a.value} ?selected=${a.value===i}>
|
|
2080
2082
|
Thinking: ${a.label}
|
|
2081
2083
|
</option>
|
|
@@ -2085,7 +2087,7 @@ ${e.sidebarContent}
|
|
|
2085
2087
|
<button
|
|
2086
2088
|
class="chat-model-bar__settings-btn"
|
|
2087
2089
|
type="button"
|
|
2088
|
-
@click=${
|
|
2090
|
+
@click=${ky}
|
|
2089
2091
|
aria-label="Message settings"
|
|
2090
2092
|
title="Message settings"
|
|
2091
2093
|
>
|
|
@@ -2112,37 +2114,37 @@ ${e.sidebarContent}
|
|
|
2112
2114
|
</label>
|
|
2113
2115
|
</div>
|
|
2114
2116
|
</div>
|
|
2115
|
-
`}const
|
|
2117
|
+
`}const Aa=200;function xy(e){const t=[];let n=null;for(const s of e){if(s.kind!=="message"){n&&(t.push(n),n=null),t.push(s);continue}const i=Ja(s.message),r=el(i.role),o=i.timestamp||Date.now();!n||n.role!==r?(n&&t.push(n),n={kind:"group",key:`group:${r}:${s.key}`,role:r,messages:[{message:s.message,key:s.key}],timestamp:o,isStreaming:!1}):n.messages.push({message:s.message,key:s.key})}return n&&t.push(n),t}function Ay(e){var o;const t=[],n=Array.isArray(e.messages)?e.messages:[],s=Array.isArray(e.toolMessages)?e.toolMessages:[],i=e.showThinking||e.verboseLevel==="on"||e.verboseLevel==="full",r=Math.max(0,n.length-Aa);r>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${Aa} messages (${r} hidden).`,timestamp:Date.now()}});for(let a=r;a<n.length;a++){const l=n[a],c=Ja(l);!i&&c.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:$a(l,a),message:l})}if(i)for(let a=0;a<s.length;a++)t.push({kind:"message",key:$a(s[a],a+n.length),message:s[a]});if(e.stream!==null){const a=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:a,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:a})}for(const a of e.queue){const l=((o=a.attachments)==null?void 0:o.filter(u=>u.fileName).map(u=>u.fileName))??[],c=l.length>0?a.text?`${l.join(", ")}
|
|
2116
2118
|
|
|
2117
|
-
${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,message:{role:"user",content:[{type:"text",text:c}],timestamp:a.createdAt}})}return
|
|
2119
|
+
${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,message:{role:"user",content:[{type:"text",text:c}],timestamp:a.createdAt}})}return xy(t)}function $a(e,t){const n=e,s=typeof n.toolCallId=="string"?n.toolCallId:"";if(s)return`tool:${s}`;const i=typeof n.id=="string"?n.id:"";if(i)return`msg:${i}`;const r=typeof n.messageId=="string"?n.messageId:"";if(r)return`msg:${r}`;const o=typeof n.timestamp=="number"?n.timestamp:null,a=typeof n.role=="string"?n.role:"unknown";return o!=null?`msg:${a}:${o}:${t}`:`msg:${a}:${t}`}function $y(e){return e.connected?f`
|
|
2118
2120
|
<div class="setup-container setup-container--full chat-page">
|
|
2119
2121
|
${at("Chat",e.wsProps)}
|
|
2120
2122
|
<div class="chat-viewport">
|
|
2121
|
-
${
|
|
2123
|
+
${yy(e)}
|
|
2122
2124
|
</div>
|
|
2123
2125
|
</div>
|
|
2124
|
-
`:
|
|
2126
|
+
`:f`
|
|
2125
2127
|
<div class="setup-container">
|
|
2126
2128
|
<div class="setup-card">
|
|
2127
2129
|
<div class="setup-spinner"></div>
|
|
2128
2130
|
<p>Connecting to gateway...</p>
|
|
2129
2131
|
</div>
|
|
2130
2132
|
</div>
|
|
2131
|
-
`}function
|
|
2132
|
-
${Iy(e)}
|
|
2133
|
+
`}function Ey(e){return e?`${Qa(e)} (${fs(e)})`:"n/a"}function Rc(e){const t=e.state??{},n=t.lastStatus??"n/a",s=t.lastRunAtMs?fs(t.lastRunAtMs):"never";return`${n} · last ${s}`}function Ic(e){const t=e.schedule;return t.kind==="at"?`One-time: ${Qa(t.atMs)}`:t.kind==="every"?`Every ${Ya(t.everyMs)}`:Ty(t.expr,t.tz)}function Ty(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[s,i,r,o,a]=n,l=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",c=(w,S)=>new Date(2e3,0,1,w,S).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),u=/^\d{1,2}$/.test(s)?parseInt(s,10):null,p=Ea(i);if(u===null||!p)return`${e}${t?` (${t})`:""}`;const d=p.map(w=>c(w,u)),h=d.length<=3?d.join(" & "):`${d.slice(0,-1).join(", ")} & ${d[d.length-1]}`,b=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(r==="*"&&o==="*"){if(a==="*")return`Daily at ${h}${l}`;if(a==="1-5")return`Weekdays at ${h}${l}`;if(a==="0,6"||a==="6,0")return`Weekends at ${h}${l}`;const w=Ea(a);if(w)return`${w.map(T=>b[T%7]??String(T)).join(", ")} at ${h}${l}`}return`${e}${t?` (${t})`:""}`}function Ea(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 s=[];for(let i=t;i<=n;i++)s.push(i);return s}return null}function Cy(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 Ta(e){const t=e.payload;if(t.kind!=="agentTurn")return null;const n=t.channel??t.provider,s=t.to;if(!s&&!n)return null;const i=[];return s&&i.push(s),n&&n!=="last"&&i.push(`via ${n}`),i.join(" ")||null}function _y(e){var i;const t=["last",...e.channels.filter(Boolean)],n=(i=e.form.channel)==null?void 0:i.trim();n&&!t.includes(n)&&t.push(n);const s=new Set;return t.filter(r=>s.has(r)?!1:(s.add(r),!0))}function My(e,t){var s,i;if(t==="last")return"last";const n=(s=e.channelMeta)==null?void 0:s.find(r=>r.id===t);return n!=null&&n.label?n.label:((i=e.channelLabels)==null?void 0:i[t])??t}function Ly(e){return e||"Default"}const Ca=f`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,Py=f`<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>`,Ry=f`<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>`,Nc=f`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,Iy=f`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`;function _a(e){const t=e.detailJobId?e.jobs.find(n=>n.id===e.detailJobId)??null:null;return f`
|
|
2133
2134
|
${Ny(e)}
|
|
2134
|
-
${
|
|
2135
|
-
${
|
|
2136
|
-
|
|
2135
|
+
${Dy(e)}
|
|
2136
|
+
${e.newEventModalOpen?By(e):k}
|
|
2137
|
+
${t?Uy(t,e):k}
|
|
2138
|
+
`}function Ny(e){const t=e.status,n=(t==null?void 0:t.enabled)??!1,s=(t==null?void 0:t.jobs)??0,i=t==null?void 0:t.nextWakeAtMs;return f`
|
|
2137
2139
|
<div class="event-status-bar">
|
|
2138
2140
|
<div class="event-status-bar__info">
|
|
2139
2141
|
<span class="statusDot ${n?"ok":""}"></span>
|
|
2140
2142
|
<span>${n?"Active":"Inactive"}</span>
|
|
2141
2143
|
<span class="event-status-bar__sep">\u00b7</span>
|
|
2142
2144
|
<span>${s} event${s!==1?"s":""}</span>
|
|
2143
|
-
${i?
|
|
2145
|
+
${i?f`
|
|
2144
2146
|
<span class="event-status-bar__sep">\u00b7</span>
|
|
2145
|
-
<span>Next: ${
|
|
2147
|
+
<span>Next: ${fs(i)}</span>
|
|
2146
2148
|
`:k}
|
|
2147
2149
|
<button
|
|
2148
2150
|
class="btn btn--sm"
|
|
@@ -2152,17 +2154,17 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2152
2154
|
>
|
|
2153
2155
|
${e.loading?"Refreshing…":"Refresh"}
|
|
2154
2156
|
</button>
|
|
2155
|
-
${e.error?
|
|
2157
|
+
${e.error?f`<span class="muted">${e.error}</span>`:k}
|
|
2156
2158
|
</div>
|
|
2157
2159
|
<button class="btn primary btn--sm" @click=${e.onNewEventModalOpen}>
|
|
2158
|
-
${
|
|
2160
|
+
${Iy} New Event
|
|
2159
2161
|
</button>
|
|
2160
2162
|
</div>
|
|
2161
|
-
`}function
|
|
2163
|
+
`}function Dy(e){return e.jobs.length===0?f`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:f`
|
|
2162
2164
|
<div class="event-grid">
|
|
2163
|
-
${e.jobs.map(t=>
|
|
2165
|
+
${e.jobs.map(t=>Oy(t,e))}
|
|
2164
2166
|
</div>
|
|
2165
|
-
`}function
|
|
2167
|
+
`}function Oy(e,t){return f`
|
|
2166
2168
|
<div
|
|
2167
2169
|
class="event-card ${e.enabled?"":"disabled"}"
|
|
2168
2170
|
@click=${()=>t.onDetailOpen(e)}
|
|
@@ -2173,12 +2175,12 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2173
2175
|
${e.enabled?"On":"Off"}
|
|
2174
2176
|
</span>
|
|
2175
2177
|
</div>
|
|
2176
|
-
<div class="event-card__schedule">${
|
|
2177
|
-
${e.agentId?
|
|
2178
|
-
${
|
|
2178
|
+
<div class="event-card__schedule">${Ic(e)}</div>
|
|
2179
|
+
${e.agentId?f`<div class="event-card__agent">${Ly(e.agentId)}</div>`:k}
|
|
2180
|
+
${Ta(e)?f`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${Ta(e)}</div>`:k}
|
|
2179
2181
|
<div class="event-card__footer">
|
|
2180
2182
|
<div class="event-card__status">
|
|
2181
|
-
<span class="muted" style="font-size: 11px;">${
|
|
2183
|
+
<span class="muted" style="font-size: 11px;">${Rc(e)}</span>
|
|
2182
2184
|
</div>
|
|
2183
2185
|
<div class="event-card__actions" @click=${n=>n.stopPropagation()}>
|
|
2184
2186
|
<button
|
|
@@ -2187,7 +2189,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2187
2189
|
?disabled=${t.busy}
|
|
2188
2190
|
@click=${()=>t.onToggle(e,!e.enabled)}
|
|
2189
2191
|
>
|
|
2190
|
-
${e.enabled?
|
|
2192
|
+
${e.enabled?Py:Ca}
|
|
2191
2193
|
</button>
|
|
2192
2194
|
<button
|
|
2193
2195
|
class="btn-icon"
|
|
@@ -2195,7 +2197,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2195
2197
|
?disabled=${t.busy}
|
|
2196
2198
|
@click=${()=>t.onRun(e)}
|
|
2197
2199
|
>
|
|
2198
|
-
${
|
|
2200
|
+
${Ca}
|
|
2199
2201
|
</button>
|
|
2200
2202
|
<button
|
|
2201
2203
|
class="btn-icon danger"
|
|
@@ -2203,18 +2205,18 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2203
2205
|
?disabled=${t.busy}
|
|
2204
2206
|
@click=${()=>t.onRemove(e)}
|
|
2205
2207
|
>
|
|
2206
|
-
${
|
|
2208
|
+
${Ry}
|
|
2207
2209
|
</button>
|
|
2208
2210
|
</div>
|
|
2209
2211
|
</div>
|
|
2210
2212
|
</div>
|
|
2211
|
-
`}function
|
|
2213
|
+
`}function By(e){const t=_y(e);return f`
|
|
2212
2214
|
<div class="event-modal-overlay" @click=${e.onNewEventModalClose}>
|
|
2213
2215
|
<div class="event-modal" @click=${n=>n.stopPropagation()}>
|
|
2214
2216
|
<div class="event-modal__header">
|
|
2215
2217
|
<div class="event-modal__title">New Event</div>
|
|
2216
2218
|
<button class="event-modal__close" @click=${e.onNewEventModalClose}>
|
|
2217
|
-
${
|
|
2219
|
+
${Nc}
|
|
2218
2220
|
</button>
|
|
2219
2221
|
</div>
|
|
2220
2222
|
|
|
@@ -2242,7 +2244,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2242
2244
|
@change=${n=>e.onFormChange({agentId:n.target.value})}
|
|
2243
2245
|
>
|
|
2244
2246
|
<option value="">Default</option>
|
|
2245
|
-
${e.agentIds.map(n=>
|
|
2247
|
+
${e.agentIds.map(n=>f`<option value=${n}>${n}</option>`)}
|
|
2246
2248
|
</select>
|
|
2247
2249
|
</label>
|
|
2248
2250
|
<label class="field checkbox">
|
|
@@ -2266,7 +2268,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2266
2268
|
</label>
|
|
2267
2269
|
</div>
|
|
2268
2270
|
|
|
2269
|
-
${
|
|
2271
|
+
${Fy(e)}
|
|
2270
2272
|
|
|
2271
2273
|
<div class="form-grid" style="margin-top: 12px;">
|
|
2272
2274
|
<label class="field">
|
|
@@ -2311,7 +2313,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2311
2313
|
></textarea>
|
|
2312
2314
|
</label>
|
|
2313
2315
|
|
|
2314
|
-
${e.form.payloadKind==="agentTurn"?
|
|
2316
|
+
${e.form.payloadKind==="agentTurn"?f`
|
|
2315
2317
|
<div class="form-grid" style="margin-top: 12px;">
|
|
2316
2318
|
<label class="field checkbox">
|
|
2317
2319
|
<span>Deliver response</span>
|
|
@@ -2327,8 +2329,8 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2327
2329
|
.value=${e.form.channel||"last"}
|
|
2328
2330
|
@change=${n=>e.onFormChange({channel:n.target.value})}
|
|
2329
2331
|
>
|
|
2330
|
-
${t.map(n=>
|
|
2331
|
-
${
|
|
2332
|
+
${t.map(n=>f`<option value=${n}>
|
|
2333
|
+
${My(e,n)}
|
|
2332
2334
|
</option>`)}
|
|
2333
2335
|
</select>
|
|
2334
2336
|
</label>
|
|
@@ -2347,7 +2349,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2347
2349
|
@input=${n=>e.onFormChange({timeoutSeconds:n.target.value})}
|
|
2348
2350
|
/>
|
|
2349
2351
|
</label>
|
|
2350
|
-
${e.form.sessionTarget==="isolated"?
|
|
2352
|
+
${e.form.sessionTarget==="isolated"?f`
|
|
2351
2353
|
<label class="field">
|
|
2352
2354
|
<span>Summary prefix</span>
|
|
2353
2355
|
<input
|
|
@@ -2367,7 +2369,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2367
2369
|
</div>
|
|
2368
2370
|
</div>
|
|
2369
2371
|
</div>
|
|
2370
|
-
`}function
|
|
2372
|
+
`}function Fy(e){const t=e.form;return t.scheduleKind==="at"?f`
|
|
2371
2373
|
<label class="field" style="margin-top: 12px;">
|
|
2372
2374
|
<span>Run at</span>
|
|
2373
2375
|
<input
|
|
@@ -2376,7 +2378,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2376
2378
|
@input=${n=>e.onFormChange({scheduleAt:n.target.value})}
|
|
2377
2379
|
/>
|
|
2378
2380
|
</label>
|
|
2379
|
-
`:t.scheduleKind==="every"?
|
|
2381
|
+
`:t.scheduleKind==="every"?f`
|
|
2380
2382
|
<div class="form-grid" style="margin-top: 12px;">
|
|
2381
2383
|
<label class="field">
|
|
2382
2384
|
<span>Repeat every</span>
|
|
@@ -2397,7 +2399,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2397
2399
|
</select>
|
|
2398
2400
|
</label>
|
|
2399
2401
|
</div>
|
|
2400
|
-
`:
|
|
2402
|
+
`:f`
|
|
2401
2403
|
<div class="form-grid" style="margin-top: 12px;">
|
|
2402
2404
|
<label class="field">
|
|
2403
2405
|
<span>Cron expression</span>
|
|
@@ -2416,17 +2418,17 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2416
2418
|
/>
|
|
2417
2419
|
</label>
|
|
2418
2420
|
</div>
|
|
2419
|
-
`}function
|
|
2421
|
+
`}function Uy(e,t){var n;return f`
|
|
2420
2422
|
<div class="event-modal-overlay" @click=${t.onDetailClose}>
|
|
2421
2423
|
<div class="event-modal" @click=${s=>s.stopPropagation()}>
|
|
2422
2424
|
<div class="event-modal__header">
|
|
2423
2425
|
<div class="event-modal__title">${e.name||"Untitled Event"}</div>
|
|
2424
2426
|
<button class="event-modal__close" @click=${t.onDetailClose}>
|
|
2425
|
-
${
|
|
2427
|
+
${Nc}
|
|
2426
2428
|
</button>
|
|
2427
2429
|
</div>
|
|
2428
2430
|
|
|
2429
|
-
${e.description?
|
|
2431
|
+
${e.description?f`<div style="color: var(--muted); font-size: 13px; margin-bottom: 16px;">${e.description}</div>`:k}
|
|
2430
2432
|
|
|
2431
2433
|
<div class="event-detail-section">
|
|
2432
2434
|
<div class="event-detail-row">
|
|
@@ -2439,9 +2441,9 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2439
2441
|
</div>
|
|
2440
2442
|
<div class="event-detail-row">
|
|
2441
2443
|
<span class="event-detail-label">Schedule</span>
|
|
2442
|
-
<span class="event-detail-value">${
|
|
2444
|
+
<span class="event-detail-value">${Ic(e)}</span>
|
|
2443
2445
|
</div>
|
|
2444
|
-
${e.agentId?
|
|
2446
|
+
${e.agentId?f`
|
|
2445
2447
|
<div class="event-detail-row">
|
|
2446
2448
|
<span class="event-detail-label">Agent</span>
|
|
2447
2449
|
<span class="event-detail-value mono">${e.agentId}</span>
|
|
@@ -2461,21 +2463,21 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2461
2463
|
</div>
|
|
2462
2464
|
<div class="event-detail-row" style="flex-direction: column; align-items: stretch; gap: 4px;">
|
|
2463
2465
|
<span class="event-detail-label">Action</span>
|
|
2464
|
-
<span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${
|
|
2466
|
+
<span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${Cy(e,!1)}</span>
|
|
2465
2467
|
</div>
|
|
2466
|
-
${e.payload.kind==="agentTurn"&&e.payload.to?
|
|
2468
|
+
${e.payload.kind==="agentTurn"&&e.payload.to?f`
|
|
2467
2469
|
<div class="event-detail-row">
|
|
2468
2470
|
<span class="event-detail-label">Send to</span>
|
|
2469
2471
|
<span class="event-detail-value mono">${e.payload.to}</span>
|
|
2470
2472
|
</div>
|
|
2471
2473
|
`:k}
|
|
2472
|
-
${e.payload.kind==="agentTurn"&&(e.payload.channel??e.payload.provider)?
|
|
2474
|
+
${e.payload.kind==="agentTurn"&&(e.payload.channel??e.payload.provider)?f`
|
|
2473
2475
|
<div class="event-detail-row">
|
|
2474
2476
|
<span class="event-detail-label">Channel</span>
|
|
2475
2477
|
<span class="event-detail-value">${e.payload.channel??e.payload.provider}</span>
|
|
2476
2478
|
</div>
|
|
2477
2479
|
`:k}
|
|
2478
|
-
${e.payload.kind==="agentTurn"?
|
|
2480
|
+
${e.payload.kind==="agentTurn"?f`
|
|
2479
2481
|
<div class="event-detail-row">
|
|
2480
2482
|
<span class="event-detail-label">Auto-deliver</span>
|
|
2481
2483
|
<span class="event-detail-value">${e.payload.deliver?"Yes":"No"}</span>
|
|
@@ -2486,12 +2488,12 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2486
2488
|
<div class="event-detail-section">
|
|
2487
2489
|
<div class="event-detail-row">
|
|
2488
2490
|
<span class="event-detail-label">Last run</span>
|
|
2489
|
-
<span class="event-detail-value">${
|
|
2491
|
+
<span class="event-detail-value">${Rc(e)}</span>
|
|
2490
2492
|
</div>
|
|
2491
|
-
${(n=e.state)!=null&&n.nextRunAtMs?
|
|
2493
|
+
${(n=e.state)!=null&&n.nextRunAtMs?f`
|
|
2492
2494
|
<div class="event-detail-row">
|
|
2493
2495
|
<span class="event-detail-label">Next run</span>
|
|
2494
|
-
<span class="event-detail-value">${
|
|
2496
|
+
<span class="event-detail-value">${Ey(e.state.nextRunAtMs)}</span>
|
|
2495
2497
|
</div>
|
|
2496
2498
|
`:k}
|
|
2497
2499
|
</div>
|
|
@@ -2500,9 +2502,9 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2500
2502
|
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;">
|
|
2501
2503
|
<span class="event-detail-label" style="font-size: 14px;">Recent Activity</span>
|
|
2502
2504
|
</div>
|
|
2503
|
-
${t.runs.length===0?
|
|
2505
|
+
${t.runs.length===0?f`<div class="muted" style="font-size: 13px;">No runs recorded yet.</div>`:f`
|
|
2504
2506
|
<div class="list">
|
|
2505
|
-
${[...t.runs].sort((s,i)=>i.ts-s.ts).map(s=>
|
|
2507
|
+
${[...t.runs].sort((s,i)=>i.ts-s.ts).map(s=>Ky(s))}
|
|
2506
2508
|
</div>
|
|
2507
2509
|
`}
|
|
2508
2510
|
</div>
|
|
@@ -2532,24 +2534,24 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2532
2534
|
</div>
|
|
2533
2535
|
</div>
|
|
2534
2536
|
</div>
|
|
2535
|
-
`}function
|
|
2537
|
+
`}function Wy(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"?"chip chip-warn":"chip"}function Ky(e){return f`
|
|
2536
2538
|
<div class="list-item" style="grid-template-columns: 1fr; gap: 6px;">
|
|
2537
2539
|
<div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
|
|
2538
|
-
<span class=${
|
|
2540
|
+
<span class=${Wy(e.status)} style="font-size: 11px; padding: 2px 8px;">
|
|
2539
2541
|
${e.status}
|
|
2540
2542
|
</span>
|
|
2541
|
-
<span class="muted" style="font-size: 12px;">${
|
|
2542
|
-
<span class="muted" style="font-size: 12px;">${
|
|
2543
|
+
<span class="muted" style="font-size: 12px;">${fs(e.ts)}</span>
|
|
2544
|
+
<span class="muted" style="font-size: 12px;">${Ya(e.durationMs)}</span>
|
|
2543
2545
|
</div>
|
|
2544
|
-
${e.summary?
|
|
2545
|
-
${e.error?
|
|
2546
|
+
${e.summary?f`<div class="muted" style="font-size: 12px;">${e.summary}</div>`:k}
|
|
2547
|
+
${e.error?f`
|
|
2546
2548
|
<details style="margin-top: 2px;">
|
|
2547
2549
|
<summary class="muted" style="cursor: pointer; font-size: 12px;">Error details</summary>
|
|
2548
2550
|
<div class="muted" style="margin-top: 4px; white-space: pre-wrap; font-size: 12px;">${e.error}</div>
|
|
2549
2551
|
</details>
|
|
2550
2552
|
`:k}
|
|
2551
2553
|
</div>
|
|
2552
|
-
`}function
|
|
2554
|
+
`}function zy(e){var i;const t=((i=e.report)==null?void 0:i.skills)??[],n=e.filter.trim().toLowerCase(),s=n?t.filter(r=>[r.name,r.description,r.source].join(" ").toLowerCase().includes(n)):t;return f`
|
|
2553
2555
|
<section class="card">
|
|
2554
2556
|
<div class="row" style="justify-content: space-between;">
|
|
2555
2557
|
<div>
|
|
@@ -2573,34 +2575,34 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2573
2575
|
<div class="muted">${s.length} shown</div>
|
|
2574
2576
|
</div>
|
|
2575
2577
|
|
|
2576
|
-
${e.error?
|
|
2578
|
+
${e.error?f`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:k}
|
|
2577
2579
|
|
|
2578
|
-
${s.length===0?
|
|
2580
|
+
${s.length===0?f`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:f`
|
|
2579
2581
|
<div class="list" style="margin-top: 16px;">
|
|
2580
|
-
${s.map(r=>
|
|
2582
|
+
${s.map(r=>jy(r,e))}
|
|
2581
2583
|
</div>
|
|
2582
2584
|
`}
|
|
2583
2585
|
</section>
|
|
2584
|
-
`}function
|
|
2586
|
+
`}function jy(e,t){const n=t.busyKey===e.skillKey,s=t.edits[e.skillKey]??"",i=t.messages[e.skillKey]??null,r=e.install.length>0&&e.missing.bins.length>0,o=[...e.missing.bins.map(l=>`bin:${l}`),...e.missing.env.map(l=>`env:${l}`),...e.missing.config.map(l=>`config:${l}`),...e.missing.os.map(l=>`os:${l}`)],a=[];return e.disabled&&a.push("disabled"),e.blockedByAllowlist&&a.push("blocked by allowlist"),f`
|
|
2585
2587
|
<div class="list-item">
|
|
2586
2588
|
<div class="list-main">
|
|
2587
2589
|
<div class="list-title">
|
|
2588
2590
|
${e.emoji?`${e.emoji} `:""}${e.name}
|
|
2589
2591
|
</div>
|
|
2590
|
-
<div class="list-sub">${
|
|
2592
|
+
<div class="list-sub">${ju(e.description,140)}</div>
|
|
2591
2593
|
<div class="chip-row" style="margin-top: 6px;">
|
|
2592
2594
|
<span class="chip">${e.source}</span>
|
|
2593
2595
|
<span class="chip ${e.eligible?"chip-ok":"chip-warn"}">
|
|
2594
2596
|
${e.eligible?"eligible":"blocked"}
|
|
2595
2597
|
</span>
|
|
2596
|
-
${e.disabled?
|
|
2598
|
+
${e.disabled?f`<span class="chip chip-warn">disabled</span>`:k}
|
|
2597
2599
|
</div>
|
|
2598
|
-
${o.length>0?
|
|
2600
|
+
${o.length>0?f`
|
|
2599
2601
|
<div class="muted" style="margin-top: 6px;">
|
|
2600
2602
|
Missing: ${o.join(", ")}
|
|
2601
2603
|
</div>
|
|
2602
2604
|
`:k}
|
|
2603
|
-
${a.length>0?
|
|
2605
|
+
${a.length>0?f`
|
|
2604
2606
|
<div class="muted" style="margin-top: 6px;">
|
|
2605
2607
|
Reason: ${a.join(", ")}
|
|
2606
2608
|
</div>
|
|
@@ -2615,7 +2617,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2615
2617
|
>
|
|
2616
2618
|
${e.disabled?"Enable":"Disable"}
|
|
2617
2619
|
</button>
|
|
2618
|
-
${r?
|
|
2620
|
+
${r?f`<button
|
|
2619
2621
|
class="btn"
|
|
2620
2622
|
?disabled=${n}
|
|
2621
2623
|
@click=${()=>t.onInstall(e.skillKey,e.name,e.install[0].id)}
|
|
@@ -2623,13 +2625,13 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2623
2625
|
${n?"Installing…":e.install[0].label}
|
|
2624
2626
|
</button>`:k}
|
|
2625
2627
|
</div>
|
|
2626
|
-
${i?
|
|
2628
|
+
${i?f`<div
|
|
2627
2629
|
class="muted"
|
|
2628
2630
|
style="margin-top: 8px; color: ${i.kind==="error"?"var(--danger-color, #d14343)":"var(--success-color, #0a7f5a)"};"
|
|
2629
2631
|
>
|
|
2630
2632
|
${i.message}
|
|
2631
2633
|
</div>`:k}
|
|
2632
|
-
${e.primaryEnv?
|
|
2634
|
+
${e.primaryEnv?f`
|
|
2633
2635
|
<div class="field" style="margin-top: 10px;">
|
|
2634
2636
|
<span>API key</span>
|
|
2635
2637
|
<input
|
|
@@ -2649,7 +2651,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2649
2651
|
`:k}
|
|
2650
2652
|
</div>
|
|
2651
2653
|
</div>
|
|
2652
|
-
`}const
|
|
2654
|
+
`}const Ma=["user","assistant","tool","thinking","error"],La={user:"User",assistant:"Assistant",tool:"Tool",thinking:"Thinking",error:"Error",system:"System"};function Hy(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 qy(e){return e.split(":").slice(2).join(":")||e}function Gy(e,t){return t?[e.content,e.agentId,e.sessionKey,e.toolName].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Vy(e,t=500){return e.length<=t?e:e.slice(0,t)+"..."}function Qy(e){const t=e.filterText.trim().toLowerCase();Ma.some(s=>!e.typeFilters[s]),e.agents.some(s=>!e.agentFilters[s]);const n=e.entries.filter(s=>!e.typeFilters[s.type]||e.agents.length>0&&!(e.agentFilters[s.agentId]??!0)?!1:Gy(s,t));return f`
|
|
2653
2655
|
<div>
|
|
2654
2656
|
<div class="filters" style="margin-top: 14px;">
|
|
2655
2657
|
<label class="field" style="min-width: 220px;">
|
|
@@ -2663,20 +2665,20 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2663
2665
|
</div>
|
|
2664
2666
|
|
|
2665
2667
|
<div class="chip-row" style="margin-top: 12px;">
|
|
2666
|
-
${
|
|
2668
|
+
${Ma.map(s=>f`
|
|
2667
2669
|
<label class="chip session-log-chip ${s}">
|
|
2668
2670
|
<input
|
|
2669
2671
|
type="checkbox"
|
|
2670
2672
|
.checked=${e.typeFilters[s]}
|
|
2671
2673
|
@change=${i=>e.onTypeToggle(s,i.target.checked)}
|
|
2672
2674
|
/>
|
|
2673
|
-
<span>${
|
|
2675
|
+
<span>${La[s]}</span>
|
|
2674
2676
|
</label>
|
|
2675
2677
|
`)}
|
|
2676
2678
|
</div>
|
|
2677
2679
|
|
|
2678
2680
|
<div class="chip-row" style="margin-top: 8px; align-items: center;">
|
|
2679
|
-
${e.agents.map(s=>
|
|
2681
|
+
${e.agents.map(s=>f`
|
|
2680
2682
|
<label class="chip agent-chip">
|
|
2681
2683
|
<input
|
|
2682
2684
|
type="checkbox"
|
|
@@ -2704,25 +2706,25 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2704
2706
|
</label>
|
|
2705
2707
|
</div>
|
|
2706
2708
|
|
|
2707
|
-
${e.error?
|
|
2709
|
+
${e.error?f`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:k}
|
|
2708
2710
|
|
|
2709
2711
|
<div class="log-stream" style="margin-top: 12px;" @scroll=${e.onScroll}>
|
|
2710
|
-
${n.length===0?
|
|
2712
|
+
${n.length===0?f`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map(s=>f`
|
|
2711
2713
|
<div class="log-row session-entry ${s.type}">
|
|
2712
2714
|
<div class="log-row-header">
|
|
2713
|
-
<span class="log-time mono">${
|
|
2714
|
-
<span class="session-log-type ${s.type}">${
|
|
2715
|
+
<span class="log-time mono">${Hy(s.timestamp)}</span>
|
|
2716
|
+
<span class="session-log-type ${s.type}">${La[s.type]}</span>
|
|
2715
2717
|
<span class="log-subsystem mono">${s.agentId}</span>
|
|
2716
|
-
<span class="session-label mono">${
|
|
2717
|
-
${s.toolName?
|
|
2718
|
-
${s.model?
|
|
2718
|
+
<span class="session-label mono">${qy(s.sessionKey)}</span>
|
|
2719
|
+
${s.toolName?f`<span class="session-tool mono">${s.toolName}</span>`:k}
|
|
2720
|
+
${s.model?f`<span class="session-model mono">${s.model}</span>`:k}
|
|
2719
2721
|
</div>
|
|
2720
|
-
<div class="log-message mono">${e.full?s.content:
|
|
2722
|
+
<div class="log-message mono">${e.full?s.content:Vy(s.content)}</div>
|
|
2721
2723
|
</div>
|
|
2722
2724
|
`)}
|
|
2723
2725
|
</div>
|
|
2724
2726
|
</div>
|
|
2725
|
-
`}const
|
|
2727
|
+
`}const Ui=["trace","debug","info","warn","error","fatal"];function Yy(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function Dc(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Xy(e){return f`
|
|
2726
2728
|
<section class="card">
|
|
2727
2729
|
<div class="row" style="justify-content: space-between;">
|
|
2728
2730
|
<div>
|
|
@@ -2730,18 +2732,18 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2730
2732
|
<div class="card-sub">Session transcripts and system logs.</div>
|
|
2731
2733
|
</div>
|
|
2732
2734
|
<div class="row" style="gap: 8px;">
|
|
2733
|
-
${e.logsSubTab==="system"?
|
|
2735
|
+
${e.logsSubTab==="system"?f`
|
|
2734
2736
|
<button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
|
|
2735
2737
|
${e.loading?"Loading…":"Refresh"}
|
|
2736
2738
|
</button>
|
|
2737
2739
|
<button
|
|
2738
2740
|
class="btn"
|
|
2739
2741
|
?disabled=${e.entries.length===0}
|
|
2740
|
-
@click=${()=>{const t=e.filterText.trim().toLowerCase(),n=
|
|
2742
|
+
@click=${()=>{const t=e.filterText.trim().toLowerCase(),n=Ui.some(r=>!e.levelFilters[r]),s=e.entries.filter(r=>r.level&&!e.levelFilters[r.level]?!1:Dc(r,t)),i=t||n?"filtered":"visible";e.onExport(s.map(r=>r.raw),i)}}
|
|
2741
2743
|
>
|
|
2742
2744
|
Export
|
|
2743
2745
|
</button>
|
|
2744
|
-
`:
|
|
2746
|
+
`:f`
|
|
2745
2747
|
<button class="btn" ?disabled=${e.sessionLogsProps.loading} @click=${e.sessionLogsProps.onRefresh}>
|
|
2746
2748
|
${e.sessionLogsProps.loading?"Loading…":"Refresh"}
|
|
2747
2749
|
</button>
|
|
@@ -2767,9 +2769,9 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2767
2769
|
</button>
|
|
2768
2770
|
</div>
|
|
2769
2771
|
|
|
2770
|
-
${e.logsSubTab==="session"?
|
|
2772
|
+
${e.logsSubTab==="session"?Qy(e.sessionLogsProps):Zy(e)}
|
|
2771
2773
|
</section>
|
|
2772
|
-
`}function
|
|
2774
|
+
`}function Zy(e){const t=e.filterText.trim().toLowerCase();Ui.some(s=>!e.levelFilters[s]);const n=e.entries.filter(s=>s.level&&!e.levelFilters[s.level]?!1:Dc(s,t));return f`
|
|
2773
2775
|
<div class="filters" style="margin-top: 14px;">
|
|
2774
2776
|
<label class="field" style="min-width: 220px;">
|
|
2775
2777
|
<span>Filter</span>
|
|
@@ -2790,7 +2792,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2790
2792
|
</div>
|
|
2791
2793
|
|
|
2792
2794
|
<div class="chip-row" style="margin-top: 12px;">
|
|
2793
|
-
${
|
|
2795
|
+
${Ui.map(s=>f`
|
|
2794
2796
|
<label class="chip log-chip ${s}">
|
|
2795
2797
|
<input
|
|
2796
2798
|
type="checkbox"
|
|
@@ -2802,17 +2804,17 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2802
2804
|
`)}
|
|
2803
2805
|
</div>
|
|
2804
2806
|
|
|
2805
|
-
${e.file?
|
|
2806
|
-
${e.truncated?
|
|
2807
|
+
${e.file?f`<div class="muted" style="margin-top: 10px;">File: ${e.file}</div>`:k}
|
|
2808
|
+
${e.truncated?f`<div class="callout" style="margin-top: 10px;">
|
|
2807
2809
|
Log output truncated; showing latest chunk.
|
|
2808
2810
|
</div>`:k}
|
|
2809
|
-
${e.error?
|
|
2811
|
+
${e.error?f`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:k}
|
|
2810
2812
|
|
|
2811
2813
|
<div class="log-stream" style="margin-top: 12px;" @scroll=${e.onScroll}>
|
|
2812
|
-
${n.length===0?
|
|
2814
|
+
${n.length===0?f`<div class="muted" style="padding: 12px;">No log entries.</div>`:[...n].reverse().map(s=>f`
|
|
2813
2815
|
<div class="log-row">
|
|
2814
2816
|
<div class="log-row-header">
|
|
2815
|
-
<span class="log-time mono">${
|
|
2817
|
+
<span class="log-time mono">${Yy(s.time)}</span>
|
|
2816
2818
|
<span class="log-level ${s.level??""}">${s.level??""}</span>
|
|
2817
2819
|
<span class="log-subsystem mono">${s.subsystem??""}</span>
|
|
2818
2820
|
</div>
|
|
@@ -2820,13 +2822,13 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2820
2822
|
</div>
|
|
2821
2823
|
`)}
|
|
2822
2824
|
</div>
|
|
2823
|
-
`}const
|
|
2825
|
+
`}const Jy=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function ev(e){switch(e.activeTab){case"cron":return _a(e.cronProps);case"skills":return zy(e.skillsProps);case"logs":return Xy(e.logsProps);default:return _a(e.cronProps)}}function tv(e){return e.connected?f`
|
|
2824
2826
|
<div class="setup-container">
|
|
2825
2827
|
${at("Advanced",e.wsProps)}
|
|
2826
2828
|
<div class="setup-card sp-card-advanced" style="text-align: left;">
|
|
2827
2829
|
<h1>Advanced</h1>
|
|
2828
2830
|
<div class="sp-tabs">
|
|
2829
|
-
${
|
|
2831
|
+
${Jy.map(t=>f`
|
|
2830
2832
|
<button
|
|
2831
2833
|
class="sp-tab ${e.activeTab===t.id?"active":""}"
|
|
2832
2834
|
@click=${()=>e.onTabChange(t.id)}
|
|
@@ -2835,29 +2837,29 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2835
2837
|
</button>
|
|
2836
2838
|
`)}
|
|
2837
2839
|
</div>
|
|
2838
|
-
${
|
|
2840
|
+
${ev(e)}
|
|
2839
2841
|
</div>
|
|
2840
2842
|
</div>
|
|
2841
|
-
`:
|
|
2843
|
+
`:f`
|
|
2842
2844
|
<div class="setup-container">
|
|
2843
2845
|
<div class="setup-card">
|
|
2844
2846
|
<div class="setup-spinner"></div>
|
|
2845
2847
|
<p>Connecting to gateway...</p>
|
|
2846
2848
|
</div>
|
|
2847
2849
|
</div>
|
|
2848
|
-
`}function
|
|
2850
|
+
`}function Pa(e){if(!e.show)return k;const t=We(),n=e.isFirstTime,s=e.changePinMode===!0&&!n,i=e.changePinBusy===!0;let r=e.accounts.length>0?e.accounts[0].id:"";const o=d=>{var b;r=d.target.value;const h=(b=d.target.closest(".login-card"))==null?void 0:b.querySelector(".login-change-pin");h&&(h.style.display=r==="__master__"?"":"none")},a=d=>h=>{const b=h.target;b.value=b.value.replace(/\D/g,"").slice(0,6),d(b.value)},l=!n&&e.accounts.length>1?f`
|
|
2849
2851
|
<select
|
|
2850
2852
|
class="login-account-select"
|
|
2851
2853
|
@change=${o}
|
|
2852
2854
|
?disabled=${e.busy||i}
|
|
2853
2855
|
>
|
|
2854
|
-
${e.accounts.map((d,
|
|
2855
|
-
<option value=${d.id} ?selected=${
|
|
2856
|
+
${e.accounts.map((d,h)=>f`
|
|
2857
|
+
<option value=${d.id} ?selected=${h===0}>
|
|
2856
2858
|
${d.displayName}
|
|
2857
2859
|
</option>
|
|
2858
2860
|
`)}
|
|
2859
2861
|
</select>
|
|
2860
|
-
`:k;if(s){let d="",
|
|
2862
|
+
`:k;if(s){let d="",h="",b="";const w=S=>{var T;S.preventDefault(),!i&&(!d||!h||!b||h===b&&r&&((T=e.onChangePin)==null||T.call(e,r,d,h)))};return f`
|
|
2861
2863
|
<div class="login-overlay">
|
|
2862
2864
|
<div class="login-card">
|
|
2863
2865
|
<img class="login-logo" src="${t.iconUrl}" alt="${t.name}" />
|
|
@@ -2886,7 +2888,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2886
2888
|
maxlength="6"
|
|
2887
2889
|
placeholder="New PIN (4-6 digits)"
|
|
2888
2890
|
?disabled=${i}
|
|
2889
|
-
@input=${a(S=>{
|
|
2891
|
+
@input=${a(S=>{h=S})}
|
|
2890
2892
|
/>
|
|
2891
2893
|
<input
|
|
2892
2894
|
class="login-pin-input"
|
|
@@ -2899,13 +2901,13 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2899
2901
|
?disabled=${i}
|
|
2900
2902
|
@input=${a(S=>{b=S})}
|
|
2901
2903
|
/>
|
|
2902
|
-
${e.changePinError?
|
|
2903
|
-
${e.changePinSuccess?
|
|
2904
|
+
${e.changePinError?f`<p class="login-error">${e.changePinError}</p>`:k}
|
|
2905
|
+
${e.changePinSuccess?f`<p class="login-success">${e.changePinSuccess}</p>`:k}
|
|
2904
2906
|
<button
|
|
2905
2907
|
class="login-submit"
|
|
2906
2908
|
type="submit"
|
|
2907
2909
|
?disabled=${i}
|
|
2908
|
-
>${i?
|
|
2910
|
+
>${i?f`<span class="login-spinner"></span>`:"Change PIN"}</button>
|
|
2909
2911
|
</form>
|
|
2910
2912
|
<p class="login-hint" style="margin-top: 16px;">
|
|
2911
2913
|
<a
|
|
@@ -2916,7 +2918,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2916
2918
|
</p>
|
|
2917
2919
|
</div>
|
|
2918
2920
|
</div>
|
|
2919
|
-
`}let c="",u="";const p=d=>{if(d.preventDefault(),!e.busy)if(n){if(!c||!u||c!==u)return;e.onSubmit(c)}else{if(!c||!r)return;e.onSubmit(r,c)}};return
|
|
2921
|
+
`}let c="",u="";const p=d=>{if(d.preventDefault(),!e.busy)if(n){if(!c||!u||c!==u)return;e.onSubmit(c)}else{if(!c||!r)return;e.onSubmit(r,c)}};return f`
|
|
2920
2922
|
<div class="login-overlay">
|
|
2921
2923
|
<div class="login-card">
|
|
2922
2924
|
<img class="login-logo" src="${t.iconUrl}" alt="${t.name}" />
|
|
@@ -2938,7 +2940,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2938
2940
|
@input=${a(d=>{c=d})}
|
|
2939
2941
|
autofocus
|
|
2940
2942
|
/>
|
|
2941
|
-
${n?
|
|
2943
|
+
${n?f`
|
|
2942
2944
|
<input
|
|
2943
2945
|
class="login-pin-input"
|
|
2944
2946
|
type="password"
|
|
@@ -2951,25 +2953,25 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2951
2953
|
@input=${a(d=>{u=d})}
|
|
2952
2954
|
/>
|
|
2953
2955
|
`:k}
|
|
2954
|
-
${e.error?
|
|
2956
|
+
${e.error?f`<p class="login-error">${e.error}</p>`:k}
|
|
2955
2957
|
<button
|
|
2956
2958
|
class="login-submit"
|
|
2957
2959
|
type="submit"
|
|
2958
2960
|
?disabled=${e.busy}
|
|
2959
2961
|
>
|
|
2960
|
-
${e.busy?
|
|
2962
|
+
${e.busy?f`<span class="login-spinner"></span>`:n?"Set PIN":"Unlock"}
|
|
2961
2963
|
</button>
|
|
2962
2964
|
</form>
|
|
2963
|
-
${n?
|
|
2965
|
+
${n?f`<p class="login-hint">This PIN protects all accounts on this device. You'll need it every time you open the dashboard.</p>`:e.accounts.some(d=>d.id==="__master__")?f`<p class="login-hint login-change-pin" style="margin-top: 16px;${r!=="__master__"?" display: none;":""}">
|
|
2964
2966
|
<a
|
|
2965
2967
|
class="login-link"
|
|
2966
2968
|
href="#"
|
|
2967
|
-
@click=${d=>{var
|
|
2969
|
+
@click=${d=>{var h;d.preventDefault(),(h=e.onToggleChangePinMode)==null||h.call(e)}}
|
|
2968
2970
|
>Change PIN</a>
|
|
2969
2971
|
</p>`:k}
|
|
2970
2972
|
</div>
|
|
2971
2973
|
</div>
|
|
2972
|
-
`}const Nr="taskmaster-access-session",Ic={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function Nc(){try{return localStorage.getItem(Nr)}catch{return null}}function Dc(e){try{localStorage.setItem(Nr,e)}catch{}}function tv(){try{localStorage.removeItem(Nr)}catch{}}async function Ma(e){if(e.client)try{const t=Nc(),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 nv(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const s=await e.client.request("access.verify",{account:t,pin:n});s.ok&&s.token?(Dc(s.token),e.accessState={...e.accessState,authenticated:!0,workspace:s.workspace??null,master:s.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:s.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function sv(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?(Dc(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 iv(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 rv(e){const t=Nc();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}tv(),e.accessState={...Ic,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}async function Ui(e){return(await e.request("apikeys.list")).providers??[]}async function La(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function ov(e,t){await e.request("apikeys.remove",{provider:t})}class av{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 s=document.getElementById("browser-screencast-canvas");s&&this.attach(s)}this.rafId==null&&(this.rafId=requestAnimationFrame(()=>this.renderFrame()))}renderFrame(){this.rafId=null;const t=this.pendingFrame;!t||!this.canvas||!this.ctx||(this.pendingFrame=null,this.img.onload=()=>{!this.canvas||!this.ctx||((this.canvas.width!==this.img.width||this.canvas.height!==this.img.height)&&(this.canvas.width=this.img.width,this.canvas.height=this.img.height),this.ctx.drawImage(this.img,0,0))},this.img.src=`data:image/jpeg;base64,${t}`)}translateCoordinates(t,n){if(!this.canvas)return{x:t,y:n};const s=this.canvas.getBoundingClientRect(),i=this.canvas.width/s.width,r=this.canvas.height/s.height,o=this.deviceWidth/this.canvas.width,a=this.deviceHeight/this.canvas.height;return{x:Math.round(t*i*o),y:Math.round(n*r*a)}}shouldThrottleMouseMove(){const t=performance.now();return t-this.lastMouseMoveAt<this.MOUSE_THROTTLE_MS?!0:(this.lastMouseMoveAt=t,!1)}getDeviceDimensions(){return{width:this.deviceWidth,height:this.deviceHeight}}}let ui=null;function nn(){return ui||(ui=new av),ui}function Dr(e){return e instanceof Error?e.message:String(e)}async function lv(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=Dr(t)}finally{e.browserLoading=!1}}async function cv(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=Dr(t)}finally{e.browserLoading=!1}}}async function di(e,t,n,s,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:s,button:i??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function pi(e,t,n,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...s!=null&&s.text?{text:s.text}:{},...s!=null&&s.code?{code:s.code}:{},...s!=null&&s.modifiers?{modifiers:s.modifiers}:{}})}catch{}}async function uv(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=Dr(t)}}function dv(e){e.browserInputMode=!e.browserInputMode}function pv(e){e.browserFullscreen=!e.browserFullscreen,nn().detach()}function hv(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,nn().updateFrame(t.data,t.metadata)}function fv(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function gv(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}function mv(e,t="admin"){var i;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const s=[];for(const r of n){if(!r||typeof r!="object"||r.agentId!==t)continue;const o=r.match;if(!o||typeof o!="object"||(o.channel??"").toLowerCase()!=="whatsapp")continue;const l=o.peer;if(!l||typeof l!="object"||l.kind!=="dm")continue;const c=l.id??"";c&&s.push({phone:c,paired:((i=r.meta)==null?void 0:i.paired)===!0})}return s.sort((r,o)=>r.paired&&!o.paired?-1:!r.paired&&o.paired?1:0),s}function Oc(e,t,n="admin",s){const i=new Map,r=new Map;for(const l of e){if(!l||typeof l!="object"||l.agentId!==n)continue;const c=l.match;if(!c||typeof c!="object"||(c.channel??"").toLowerCase()!=="whatsapp")continue;const p=c.peer;if(!p||typeof p!="object"||p.kind!=="dm")continue;const d=p.id??"";d&&(l.meta&&i.set(d,l.meta),c.accountId&&r.set(d,c.accountId))}const o=e.filter(l=>{if(!l||typeof l!="object"||l.agentId!==n)return!0;const c=l.match;if(!c||typeof c!="object"||(c.channel??"").toLowerCase()!=="whatsapp")return!0;const p=c.peer;return!p||typeof p!="object"?!0:p.kind!=="dm"}),a=t.map(l=>{const c=s??r.get(l.phone),u={channel:"whatsapp",peer:{kind:"dm",id:l.phone}};c&&(u.accountId=c);const p={agentId:n,match:u},d=i.get(l.phone);return d?p.meta=d:l.paired&&(p.meta={paired:!0}),p});return[...o,...a]}async function Ss(e,t){if(!e.client||!e.connected)return;if(!t){e.adminPhones=[];return}if(e.adminsLoading)return;e.adminsLoading=!0,e.adminsError=null;const n=t;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.config;e.configForm=Ue(i??{}),e.adminPhones=mv(i,n),e.configFormDirty=!1}catch(s){e.adminsError=String(s)}finally{e.adminsLoading=!1}}async function Bc(e,t,n,s){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n;let r=t.replace(/[\s\-\(\)]/g,"");if(!r){e.adminsError="Phone number is required";return}if(r.startsWith("+")||(r="+"+r),!/^\+[1-9]\d{6,14}$/.test(r)){e.adminsError="Invalid phone number. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(l=>l.phone===r)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const l=Ue(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),c=l.bindings??[],u=[...e.adminPhones,{phone:r}],p=Oc(c,u,i,s);sl(l,["bindings"],p);const d=(a=e.configSnapshot)==null?void 0:a.hash;if(!d){e.adminsError="Config hash missing; reload and retry.";return}const f=et(l);await e.client.request("config.set",{raw:f,baseHash:d}),await Ss(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}async function Fc(e,t,n,s){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n,r=e.adminPhones.find(l=>l.phone===t);if(r!=null&&r.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const l=Ue(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),c=l.bindings??[],u=e.adminPhones.filter(b=>b.phone!==t),p=Oc(c,u,i,s);sl(l,["bindings"],p);const d=(a=e.configSnapshot)==null?void 0:a.hash;if(!d){e.adminsError="Config hash missing; reload and retry.";return}const f=et(l);await e.client.request("config.set",{raw:f,baseHash:d}),await Ss(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}const yv=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:Bc,loadAdmins:Ss,removeAdmin:Fc},Symbol.toStringTag,{value:"Module"}));async function ot(e,t){if(!(!e.client||!e.connected)){if(!t){e.customersRecords=[];return}if(!e.customersLoading){e.customersLoading=!0,e.customersError=null;try{const n=e.customersSearchQuery.trim(),s=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.customersRecords=s.records??[]}catch(n){e.customersError=String(n)}finally{e.customersLoading=!1}}}}async function Uc(e,t,n,s){if(!e.client||!e.connected||e.customersSaving)return;let i=t.replace(/[\s\-\(\)]/g,"");const r=n.trim();if(!i){e.customersError="Phone number is required";return}if(!r){e.customersError="Name is required";return}if(i.startsWith("+")||(i="+"+i),!/^\+[1-9]\d{6,14}$/.test(i)){e.customersError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.set",{id:i,name:r,fields:{},workspace:s}),e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName="",await ot(e,s)}catch(o){e.customersError=String(o)}finally{e.customersSaving=!1}}async function Wc(e,t,n){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.delete",{id:t}),e.customersEditingId===t&&(e.customersEditingId=null),await ot(e,n)}catch(s){e.customersError=String(s)}finally{e.customersSaving=!1}}}async function Kc(e,t,n,s,i){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.setField",{id:t,key:n,value:s}),await ot(e,i)}catch(r){e.customersError=String(r)}finally{e.customersSaving=!1}}}async function zc(e,t,n,s){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await ot(e,s)}catch(i){e.customersError=String(i)}finally{e.customersSaving=!1}}}const vv=Object.freeze(Object.defineProperty({__proto__:null,addCustomer:Uc,deleteCustomer:Wc,deleteCustomerField:zc,loadCustomers:ot,setCustomerField:Kc},Symbol.toStringTag,{value:"Module"}));function qt(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0}}}function bv(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 wv(e){const t=ne(e);if(!t)return;const n=t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin");return n==null?void 0:n.id}function kv(e){const t=ne(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function Sv(e){var n;const t=ne(e);if(t)return(n=t.agents[0])==null?void 0:n.id}function xv(e){return e.selectedWorkspace??void 0}function ne(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const Av=/^data:/i,$v=/^https?:\/\//i;function Ev(e){var a,l;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=Ha(e.sessionKey),s=(n==null?void 0:n.agentId)??((l=e.agentsList)==null?void 0:l.defaultId)??"main",i=t.find(c=>c.id===s),r=i==null?void 0:i.identity,o=(r==null?void 0:r.avatarUrl)??(r==null?void 0:r.avatar);if(o)return Av.test(o)||$v.test(o)?o:r==null?void 0:r.avatarUrl}function Tv(e){var s;if(!e)return null;const t=(s=e.channelAccounts)==null?void 0:s.whatsapp;if(!t||t.length===0)return null;const n=t[0];return{running:n.running??!1,connected:n.connected??!1,linked:n.linked??!1,lastError:n.lastError}}function Cv(e){var o;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(o=e.channelAccounts)==null?void 0:o.imessage;if(!t||t.length===0)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const n=t[0],s=n.running??!1,i=n.probe,r=i!=null?i.ok===!0:s;return{configured:n.configured??!1,running:s,connected:r,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function _v(e){var o;const t=(o=e.configSnapshot)==null?void 0:o.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const s=n.find(a=>{var l,c;return((l=a.match)==null?void 0:l.channel)==="imessage"&&((c=a.meta)==null?void 0:c.imessageOwner)});if(!s)return null;const i=s.agentId;for(const a of e.workspaces)if(a.agents.some(l=>l.id===i))return a.name;if(i==="admin"||i==="public"){const a=e.workspaces.find(l=>l.isDefault);return(a==null?void 0:a.name)??null}const r=i.replace(/-(admin|public)$/,"");if(r!==i){const a=e.workspaces.find(l=>l.name===r);return(a==null?void 0:a.name)??null}return null}function Mv(e){var t,n,s,i,r,o,a;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return _a({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(c,u)=>{u!=null&&e.handlePinSubmit(c,u)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(c,u,p)=>e.handleChangePin(c,u,p)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return _a({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:c=>e.handleSetMasterPin(c)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",k}if(e.setup){const l=Tv(e.channelsSnapshot),c=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],u=Cv(e.channelsSnapshot),p=_v(e);return Dh({connected:e.connected,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:d=>e.handleLicenseKeyChange(d),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:l,whatsappAccounts:c,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:d=>e.handleUninstallConfirmTextChange(d),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:d=>e.handleAuthSubmitCode(d),onAuthCodeChange:d=>e.handleAuthCodeChange(d),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async d=>{await e.handleWhatsAppStart(!0,d),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(d),await q(e,!0),e.requestUpdate())},onWhatsAppReset:async d=>{await e.handleWhatsAppLogout(d),await e.handleWhatsAppStart(!0,d),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(d),await q(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await q(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),q(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:d=>e.handleRemoveWhatsAppAccount(d),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:d=>{e.newWorkspacePin=d},onWorkspaceCreate:async(d,f)=>{const b=e.newWorkspacePin;await e.handleWorkspaceCreate(d,f),b.match(/^\d{4,6}$/)&&(await iv(e,d,b),e.newWorkspacePin="")},onWorkspaceRemove:d=>e.handleWorkspaceRemove(d),onSetAddingWorkspace:d=>{e.addingWorkspace=d},onSetNewWorkspaceName:d=>{e.newWorkspaceName=d},onSetNewWorkspacePath:d=>{e.newWorkspacePath=d},onSetWorkspaceRemoveConfirm:d=>{e.workspaceRemoveConfirm=d},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(d,f)=>e.handleWorkspaceRename(d,f),whatsappDmPolicy:(()=>{const d=ne(e),f=d==null?void 0:d.whatsappAccountId,b=f?c.find(w=>w.accountId===f):c[0];return(b==null?void 0:b.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var A;const d=ne(e),f=d==null?void 0:d.whatsappAccountId,b=f?c.find(E=>E.accountId===f):c[0];if(!b)return;const S=b.dmPolicy!=null&&b.dmPolicy!=="disabled"?"disabled":"open",T=S==="open"?{dmPolicy:S,allowFrom:["*"]}:{dmPolicy:S};try{const E=await e.client.request("config.get"),C=E.config,R=(A=C==null?void 0:C.channels)==null?void 0:A.whatsapp,Q=((R==null?void 0:R.accounts)??{})[b.accountId]?{channels:{whatsapp:{accounts:{[b.accountId]:T}}}}:{channels:{whatsapp:T}};await e.client.request("config.patch",{raw:JSON.stringify(Q),baseHash:E.hash,note:`WhatsApp DM policy → ${S}`,skipRestart:!0}),await q(e,!1)}catch(E){console.error("DM toggle failed:",E)}},whatsappModel:(()=>{var A,E;const d=ne(e);if(!d)return null;const f=d.agents.find(C=>C.id.endsWith("-public")||C.id==="public");if(!f)return null;const b=(A=e.configSnapshot)==null?void 0:A.config,w=(E=b==null?void 0:b.agents)==null?void 0:E.list;if(!Array.isArray(w))return null;const S=w.find(C=>C.id===f.id);if(!(S!=null&&S.model))return null;const T=typeof S.model=="string"?S.model:S.model.primary;return(T==null?void 0:T.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async d=>{const f=ne(e);if(!f)return;const b=f.agents.find(w=>w.id.endsWith("-public")||w.id==="public");if(b)try{const w=await e.client.request("config.get"),S=w.config,T=(S==null?void 0:S.agents)??{},A=Array.isArray(T.list)?[...T.list]:[],E=A.findIndex(R=>R.id===b.id);if(d)E>=0?A[E]={...A[E],model:d}:A.push({id:b.id,model:d});else if(E>=0){const{model:R,...U}=A[E];Object.keys(U).length<=1?A.splice(E,1):A[E]=U}const C=A.length>0?{agents:{list:A}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(C),baseHash:w.hash,note:`Public agent model → ${d||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Model change failed:",w)}},whatsappThinkingLevel:(()=>{var T,A,E;const d=ne(e);if(!d)return null;const f=d.agents.find(C=>C.id.endsWith("-public")||C.id==="public");if(!f)return null;const b=(T=e.configSnapshot)==null?void 0:T.config,w=(A=b==null?void 0:b.agents)==null?void 0:A.list;if(!Array.isArray(w))return null;const S=w.find(C=>C.id===f.id);return((E=S==null?void 0:S.thinkingLevel)==null?void 0:E.trim())||null})(),onWhatsAppThinkingChange:async d=>{const f=ne(e);if(!f)return;const b=f.agents.find(w=>w.id.endsWith("-public")||w.id==="public");if(b)try{const w=await e.client.request("config.get"),S=w.config,T=(S==null?void 0:S.agents)??{},A=Array.isArray(T.list)?[...T.list]:[],E=A.findIndex(U=>U.id===b.id),C=d==="off"?void 0:d;if(C)E>=0?A[E]={...A[E],thinkingLevel:C}:A.push({id:b.id,thinkingLevel:C});else if(E>=0){const{thinkingLevel:U,...Q}=A[E];Object.keys(Q).length<=1?A.splice(E,1):A[E]=Q}const R=A.length>0?{agents:{list:A}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(R),baseHash:w.hash,note:`Public agent thinking → ${C||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Thinking change failed:",w)}},whatsappGroupPolicy:(()=>{var E,C;const d=(E=e.configSnapshot)==null?void 0:E.config,f=(C=d==null?void 0:d.channels)==null?void 0:C.whatsapp,b=ne(e),w=b==null?void 0:b.whatsappAccountId,S=(f==null?void 0:f.accounts)??{},T=w?S[w]:void 0;return(T==null?void 0:T.groupPolicy)??(f==null?void 0:f.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var C,R;const d=(C=e.configSnapshot)==null?void 0:C.config,f=(R=d==null?void 0:d.channels)==null?void 0:R.whatsapp,b=ne(e),w=b==null?void 0:b.whatsappAccountId,S=(f==null?void 0:f.accounts)??{},T=w?S[w]:void 0,E=((T==null?void 0:T.groups)??(f==null?void 0:f.groups)??{})["*"];return(E==null?void 0:E.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var b;const d=ne(e),f=d==null?void 0:d.whatsappAccountId;try{const w=await e.client.request("config.get"),S=w.config,T=((b=S==null?void 0:S.channels)==null?void 0:b.whatsapp)??{},A=T.accounts??{},E=f?A[f]:void 0,C=(E==null?void 0:E.groupPolicy)??T.groupPolicy??"allowlist",R=C==="disabled"||C==="allowlist",U=R?"open":"disabled",Q=R?{"*":{}}:void 0,ze={groupPolicy:U};Q&&(ze.groups=Q);const Lt=E?{channels:{whatsapp:{accounts:{[f]:ze}}}}:{channels:{whatsapp:ze}};await e.client.request("config.patch",{raw:JSON.stringify(Lt),baseHash:w.hash,note:`WhatsApp groups → ${U}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Group toggle failed:",w)}},onWhatsAppGroupMentionChange:async d=>{var w;const f=ne(e),b=f==null?void 0:f.whatsappAccountId;try{const S=await e.client.request("config.get"),T=S.config,E=(((w=T==null?void 0:T.channels)==null?void 0:w.whatsapp)??{}).accounts??{},C=b?E[b]:void 0,R={"*":{requireMention:d}},U=C?{channels:{whatsapp:{accounts:{[b]:{groups:R}}}}}:{channels:{whatsapp:{groups:R}}};await e.client.request("config.patch",{raw:JSON.stringify(U),baseHash:S.hash,note:`WhatsApp group mention → ${d?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(S){console.error("Group mention change failed:",S)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:u.configured,imessageRunning:u.running,imessageConnected:u.connected,imessageLastError:u.lastError,imessageSelfChatMode:u.selfChatMode,imessageCliPath:u.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:p,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),f=d.config,b=(f==null?void 0:f.bindings)??[],w=ne(e),S=w==null?void 0:w.agents.find(R=>R.id.endsWith("-admin")||R.id==="admin"),T=(S==null?void 0:S.id)??"admin",A=b.filter(R=>{var U;return((U=R.match)==null?void 0:U.channel)!=="imessage"}),E=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],C=[...A,...E];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:C}),baseHash:d.hash,note:"Enable iMessage (self-chat) for "+((w==null?void 0:w.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),xe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await q(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),f=d.config,w=((f==null?void 0:f.bindings)??[]).filter(S=>{var T;return((T=S.match)==null?void 0:T.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:w}),baseHash:d.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),xe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),f=d.config,b=(f==null?void 0:f.bindings)??[],w=ne(e),S=w==null?void 0:w.agents.find(C=>C.id.endsWith("-admin")||C.id==="admin"),T=(S==null?void 0:S.id)??"admin",A=b.filter(C=>{var R;return((R=C.match)==null?void 0:R.channel)!=="imessage"}),E=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:[...A,...E]}),baseHash:d.hash,note:"Reassign iMessage to "+((w==null?void 0:w.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),xe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:d=>{e.infoModalOpen=d},onInfoModalClose:()=>{e.infoModalOpen=null},isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,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(d,f)=>{e.apiKeySavingProvider=d,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await La(e.client,d,f);const b=`${d} key saved`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Ui(e.client)}catch{}d==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async d=>{e.apiKeySavingProvider=d,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await ov(e.client,d);const f=`${d} key removed`;e.apiKeySuccess=f,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Ui(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===f&&(e.apiKeySuccess=null)},2500)}catch(f){e.apiKeyError=f instanceof Error?f.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:d=>{e.authApiKeyInput=d},onAuthApiKeySubmit:async()=>{const d=e.authApiKeyInput.trim();if(d){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await La(e.client,"anthropic",d),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(f){e.authApiKeyError=f instanceof Error?f.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var f;const d=e.selectedWorkspace??((f=e.workspaces[0])==null?void 0:f.name);return d?e.accessState.accounts.some(b=>b.id===d):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(d,f)=>{var w;const b=e.selectedWorkspace??((w=e.workspaces[0])==null?void 0:w.name);b&&e.handleAccountPinSave(b,d,f)},wsProps:bv(e)})}if(e.filesPage){const l=Sv(e);return kh({connected:e.connected,wsProps:qt(e),loading:e.filesLoading,tree:e.filesTree,root:e.filesRoot,error:e.filesError,selectedPath:e.filesSelectedPath,selectedPaths:e.filesSelectedPaths,previewContent:e.filesPreviewContent,previewLoading:e.filesPreviewLoading,previewBinary:e.filesPreviewBinary,previewSize:e.filesPreviewSize,expandedDirs:e.filesExpandedDirs,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>pn(e,l),onReindex:()=>Pp(e,l),onSelectFile:c=>Ep(e,c,l),onToggleSelectFile:c=>Tp(e,c,l),onToggleDir:c=>Rp(e,c),onUpload:(c,u)=>Mp(e,c,u,l),onDownload:c=>Ll(e,c,l),onBulkDownload:()=>Cp(e,l),onDelete:c=>Lp(e,c,l),onMove:(c,u)=>Pl(e,c,u,l),onMoveToDir:(c,u)=>_p(e,c,u,l),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:c=>{const u=e.filesSearchAgentId??l;Ip(e,c,u)},onSearchAgentChange:c=>{e.filesSearchAgentId=c},onSearchClear:()=>{Np(e)},onSearchQueryChange:c=>{e.filesSearchQuery=c}})}if(e.browserPage)return fh({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:()=>lv(e),onStop:()=>cv(e),onToggleInput:()=>dv(e),onToggleFullscreen:()=>pv(e),onCompleteHandoff:()=>uv(e),onCanvasMouseDown:l=>{const u=l.target.getBoundingClientRect(),d=nn().translateCoordinates(l.clientX-u.left,l.clientY-u.top);di(e,"mousePressed",d.x,d.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const u=l.target.getBoundingClientRect(),d=nn().translateCoordinates(l.clientX-u.left,l.clientY-u.top);di(e,"mouseReleased",d.x,d.y)},onCanvasMouseMove:l=>{const c=nn();if(c.shouldThrottleMouseMove())return;const p=l.target.getBoundingClientRect(),d=c.translateCoordinates(l.clientX-p.left,l.clientY-p.top);di(e,"mouseMoved",d.x,d.y)},onCanvasKeyDown:l=>{let c=0;l.altKey&&(c|=1),l.ctrlKey&&(c|=2),l.metaKey&&(c|=4),l.shiftKey&&(c|=8),pi(e,"keyDown",l.key,{code:l.code,modifiers:c||void 0}),l.key.length===1&&pi(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{pi(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=wv(e),c=kv(e);return Bh({connected:e.connected,wsProps:qt(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>Ss(e,l),onAdd:u=>{Bc(e,u,l,c).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:u=>Fc(e,u,l,c),onNewPhoneChange:u=>e.handleAdminsNewPhoneChange(u)})}if(e.customersPage){const l=xv(e);return Kh({connected:e.connected,wsProps:qt(e),loading:e.customersLoading,saving:e.customersSaving,records:e.customersRecords,error:e.customersError,searchQuery:e.customersSearchQuery,editingId:e.customersEditingId,showAddForm:e.customersShowAddForm,newRecordPhone:e.customersNewPhone,newRecordName:e.customersNewName,onSearch:c=>e.customersSearchQuery=c,onSearchSubmit:()=>ot(e,l),onAdd:(c,u)=>Uc(e,c,u,l),onDelete:c=>Wc(e,c,l),onSetField:(c,u,p)=>Kc(e,c,u,p,l),onDeleteField:(c,u)=>zc(e,c,u,l),onToggleExpand:c=>{e.customersEditingId=e.customersEditingId===c?null:c},onShowAddForm:()=>e.customersShowAddForm=!0,onCancelAddForm:()=>{e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName=""},onNewRecordPhoneChange:c=>e.handleCustomersNewPhoneChange(c),onNewRecordNameChange:c=>e.handleCustomersNewNameChange(c),onRefresh:()=>ot(e,l)})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",c=Ev(e),u=e.chatAvatarUrl??c??null;return Ay({connected:e.connected,wsProps:qt(e),sessionKey:e.sessionKey,onSessionKeyChange:p=>{e.sessionKey=p,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:p,lastActiveSessionKey:p}),e.loadAssistantIdentity(),Me(e),xi(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:p=>{Cn(e,e.sessionKey,{model:p}).then(()=>{Me(e)})},onThinkingLevelChange:p=>{Cn(e,e.sessionKey,{thinkingLevel:p==="off"?null:p}).then(()=>{Me(e)})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,onVerboseChange:p=>{Cn(e,e.sessionKey,{verboseLevel:p==="off"?null:p}).then(()=>{Me(e)})},onFillerChange:p=>{Cn(e,e.sessionKey,{fillerEnabled:p}).then(()=>{Me(e)})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:u,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:l,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>(e.resetToolStream(),Promise.all([Me(e),xi(e)])),onToggleFocusMode:()=>{},onChatScroll:p=>e.handleChatScroll(p),nearBottom:e.chatUserNearBottom,onDraftChange:p=>e.chatMessage=p,attachments:e.chatAttachments,onAttachmentsChange:p=>e.chatAttachments=p,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:p=>e.removeQueuedMessage(p),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:p=>e.handleOpenSidebar(p),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:p=>e.handleSplitRatioChange(p),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?ev({connected:e.connected,wsProps:qt(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&$t(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?wt(e,{reset:!0}):Jt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(i=(s=e.channelsSnapshot)==null?void 0:s.channelMeta)!=null&&i.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((r=e.channelsSnapshot)==null?void 0:r.channelOrder)??[],channelLabels:((o=e.channelsSnapshot)==null?void 0:o.channelLabels)??{},channelMeta:((a=e.channelsSnapshot)==null?void 0:a.channelMeta)??[],agentIds:(()=>{var c;const l=ne(e);return((c=l==null?void 0:l.agents)==null?void 0:c.map(u=>u.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1},detailJobId:e.cronDetailJobId,onDetailOpen:l=>{e.cronDetailJobId=l.id,vi(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{$d(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,c)=>Ed(e,l,c),onRun:l=>Td(e,l),onRemove:l=>Cd(e,l),onLoadRuns:l=>vi(e,l)},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:l=>e.skillsFilter=l,onRefresh:()=>$t(e,{clearMessages:!0}),onToggle:(l,c)=>gp(e,l,c),onEdit:(l,c)=>fp(e,l,c),onSaveKey:l=>mp(e,l),onInstall:(l,c,u)=>yp(e,l,c,u)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?wt(e,{reset:!0}):Jt(e,{reset:!0})},sessionLogsProps:{loading:e.sessionLogsLoading,error:e.sessionLogsError,entries:e.sessionLogsEntries,agents:e.sessionLogsAgents,filterText:e.sessionLogsFilterText,typeFilters:e.sessionLogsTypeFilters,agentFilters:e.sessionLogsAgentFilters,autoFollow:e.sessionLogsAutoFollow,full:e.sessionLogsFull,onFilterTextChange:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,c)=>{const u=e;u.sessionLogsTypeFilters={...u.sessionLogsTypeFilters,[l]:c}},onAgentToggle:(l,c)=>{const u=e;u.sessionLogsAgentFilters={...u.sessionLogsAgentFilters,[l]:c}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onToggleFull:l=>{e.sessionLogsFull=l,wt(e,{reset:!0})},onRefresh:()=>{wt(e,{reset:!0})},onExport:(l,c)=>e.exportSessionLogs(l,c),onScroll:l=>e.handleSessionLogsScroll(l)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,truncated:e.logsTruncated,onFilterTextChange:l=>e.logsFilterText=l,onLevelToggle:(l,c)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:c}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onRefresh:()=>Jt(e,{reset:!0}),onExport:(l,c)=>e.exportSessionLogs(l,c),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),h``)}function Lv(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),s=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${s}`}function Pa(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Pv(e,t,n){return h`
|
|
2974
|
+
`}const Nr="taskmaster-access-session",Oc={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function Bc(){try{return localStorage.getItem(Nr)}catch{return null}}function Fc(e){try{localStorage.setItem(Nr,e)}catch{}}function nv(){try{localStorage.removeItem(Nr)}catch{}}async function Ra(e){if(e.client)try{const t=Bc(),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 sv(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const s=await e.client.request("access.verify",{account:t,pin:n});s.ok&&s.token?(Fc(s.token),e.accessState={...e.accessState,authenticated:!0,workspace:s.workspace??null,master:s.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:s.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function iv(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?(Fc(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 rv(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 ov(e){const t=Bc();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}nv(),e.accessState={...Oc,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}async function Wi(e){return(await e.request("apikeys.list")).providers??[]}async function Ia(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function av(e,t){await e.request("apikeys.remove",{provider:t})}class lv{constructor(){this.canvas=null,this.ctx=null,this.img=new Image,this.pendingFrame=null,this.rafId=null,this.deviceWidth=1280,this.deviceHeight=720,this.lastMouseMoveAt=0,this.MOUSE_THROTTLE_MS=30}attach(t){this.canvas=t,this.ctx=t.getContext("2d")}detach(){this.rafId!=null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.canvas=null,this.ctx=null,this.pendingFrame=null}updateFrame(t,n){if(n!=null&&n.deviceWidth&&(this.deviceWidth=n.deviceWidth),n!=null&&n.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,!this.canvas){const s=document.getElementById("browser-screencast-canvas");s&&this.attach(s)}this.rafId==null&&(this.rafId=requestAnimationFrame(()=>this.renderFrame()))}renderFrame(){this.rafId=null;const t=this.pendingFrame;!t||!this.canvas||!this.ctx||(this.pendingFrame=null,this.img.onload=()=>{!this.canvas||!this.ctx||((this.canvas.width!==this.img.width||this.canvas.height!==this.img.height)&&(this.canvas.width=this.img.width,this.canvas.height=this.img.height),this.ctx.drawImage(this.img,0,0))},this.img.src=`data:image/jpeg;base64,${t}`)}translateCoordinates(t,n){if(!this.canvas)return{x:t,y:n};const s=this.canvas.getBoundingClientRect(),i=this.canvas.width/s.width,r=this.canvas.height/s.height,o=this.deviceWidth/this.canvas.width,a=this.deviceHeight/this.canvas.height;return{x:Math.round(t*i*o),y:Math.round(n*r*a)}}shouldThrottleMouseMove(){const t=performance.now();return t-this.lastMouseMoveAt<this.MOUSE_THROTTLE_MS?!0:(this.lastMouseMoveAt=t,!1)}getDeviceDimensions(){return{width:this.deviceWidth,height:this.deviceHeight}}}let di=null;function nn(){return di||(di=new lv),di}function Dr(e){return e instanceof Error?e.message:String(e)}async function cv(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=Dr(t)}finally{e.browserLoading=!1}}async function uv(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=Dr(t)}finally{e.browserLoading=!1}}}async function pi(e,t,n,s,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:s,button:i??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function hi(e,t,n,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...s!=null&&s.text?{text:s.text}:{},...s!=null&&s.code?{code:s.code}:{},...s!=null&&s.modifiers?{modifiers:s.modifiers}:{}})}catch{}}async function dv(e){if(!(!e.client||!e.connected))try{await e.client.request("browser.handoff.complete",{}),e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}catch(t){e.browserError=Dr(t)}}function pv(e){e.browserInputMode=!e.browserInputMode}function hv(e){e.browserFullscreen=!e.browserFullscreen,nn().detach()}function fv(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,nn().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 mv(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}function yv(e,t="admin"){var i;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const s=[];for(const r of n){if(!r||typeof r!="object"||r.agentId!==t&&r.agentId!=="management")continue;const o=r.match;if(!o||typeof o!="object"||(o.channel??"").toLowerCase()!=="whatsapp")continue;const l=o.peer;if(!l||typeof l!="object"||l.kind!=="dm")continue;const c=l.id??"";c&&s.push({phone:c,paired:((i=r.meta)==null?void 0:i.paired)===!0})}return s.sort((r,o)=>r.paired&&!o.paired?-1:!r.paired&&o.paired?1:0),s}function Uc(e,t,n="admin",s){const i=c=>c===n||c==="management",r=new Map,o=new Map;for(const c of e){if(!c||typeof c!="object"||!i(c.agentId))continue;const u=c.match;if(!u||typeof u!="object"||(u.channel??"").toLowerCase()!=="whatsapp")continue;const d=u.peer;if(!d||typeof d!="object"||d.kind!=="dm")continue;const h=d.id??"";h&&(c.meta&&r.set(h,c.meta),u.accountId&&o.set(h,u.accountId))}const a=e.filter(c=>{if(!c||typeof c!="object"||!i(c.agentId))return!0;const u=c.match;if(!u||typeof u!="object"||(u.channel??"").toLowerCase()!=="whatsapp")return!0;const d=u.peer;return!d||typeof d!="object"?!0:d.kind!=="dm"}),l=t.map(c=>{const u=s??o.get(c.phone),p={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};u&&(p.accountId=u);const d={agentId:n,match:p},h=r.get(c.phone);return h?d.meta=h:c.paired&&(d.meta={paired:!0}),d});return[...a,...l]}async function xs(e,t){if(!e.client||!e.connected)return;if(!t){e.adminPhones=[];return}if(e.adminsLoading)return;e.adminsLoading=!0,e.adminsError=null;const n=t;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.config;e.configForm=Ue(i??{}),e.adminPhones=yv(i,n),e.configFormDirty=!1}catch(s){e.adminsError=String(s)}finally{e.adminsLoading=!1}}async function Wc(e,t,n,s){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n;let r=t.replace(/[\s\-\(\)]/g,"");if(!r){e.adminsError="Phone number is required";return}if(r.startsWith("+")||(r="+"+r),!/^\+[1-9]\d{6,14}$/.test(r)){e.adminsError="Invalid phone number. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(l=>l.phone===r)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const l=Ue(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),c=l.bindings??[],u=[...e.adminPhones,{phone:r}],p=Uc(c,u,i,s);ol(l,["bindings"],p);const d=(a=e.configSnapshot)==null?void 0:a.hash;if(!d){e.adminsError="Config hash missing; reload and retry.";return}const h=et(l);await e.client.request("config.set",{raw:h,baseHash:d}),await xs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}async function Kc(e,t,n,s){var o,a;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n,r=e.adminPhones.find(l=>l.phone===t);if(r!=null&&r.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const l=Ue(e.configForm??((o=e.configSnapshot)==null?void 0:o.config)??{}),c=l.bindings??[],u=e.adminPhones.filter(b=>b.phone!==t),p=Uc(c,u,i,s);ol(l,["bindings"],p);const d=(a=e.configSnapshot)==null?void 0:a.hash;if(!d){e.adminsError="Config hash missing; reload and retry.";return}const h=et(l);await e.client.request("config.set",{raw:h,baseHash:d}),await xs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}const vv=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:Wc,loadAdmins:xs,removeAdmin:Kc},Symbol.toStringTag,{value:"Module"}));async function ot(e,t){if(!(!e.client||!e.connected)){if(!t){e.customersRecords=[];return}if(!e.customersLoading){e.customersLoading=!0,e.customersError=null;try{const n=e.customersSearchQuery.trim(),s=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.customersRecords=s.records??[]}catch(n){e.customersError=String(n)}finally{e.customersLoading=!1}}}}async function zc(e,t,n,s){if(!e.client||!e.connected||e.customersSaving)return;let i=t.replace(/[\s\-\(\)]/g,"");const r=n.trim();if(!i){e.customersError="Phone number is required";return}if(!r){e.customersError="Name is required";return}if(i.startsWith("+")||(i="+"+i),!/^\+[1-9]\d{6,14}$/.test(i)){e.customersError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.set",{id:i,name:r,fields:{},workspace:s}),e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName="",await ot(e,s)}catch(o){e.customersError=String(o)}finally{e.customersSaving=!1}}async function jc(e,t,n){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.delete",{id:t}),e.customersEditingId===t&&(e.customersEditingId=null),await ot(e,n)}catch(s){e.customersError=String(s)}finally{e.customersSaving=!1}}}async function Hc(e,t,n,s,i){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.setField",{id:t,key:n,value:s}),await ot(e,i)}catch(r){e.customersError=String(r)}finally{e.customersSaving=!1}}}async function qc(e,t,n,s){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await ot(e,s)}catch(i){e.customersError=String(i)}finally{e.customersSaving=!1}}}const bv=Object.freeze(Object.defineProperty({__proto__:null,addCustomer:zc,deleteCustomer:jc,deleteCustomerField:qc,loadCustomers:ot,setCustomerField:Hc},Symbol.toStringTag,{value:"Module"}));function qt(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0}}}function wv(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 kv(e){const t=ne(e);if(!t)return;const n=t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin");return n==null?void 0:n.id}function Sv(e){const t=ne(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function xv(e){var n;const t=ne(e);if(t)return(n=t.agents[0])==null?void 0:n.id}function Av(e){return e.selectedWorkspace??void 0}function ne(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const $v=/^data:/i,Ev=/^https?:\/\//i;function Tv(e){var a,l;const t=((a=e.agentsList)==null?void 0:a.agents)??[],n=Va(e.sessionKey),s=(n==null?void 0:n.agentId)??((l=e.agentsList)==null?void 0:l.defaultId)??"main",i=t.find(c=>c.id===s),r=i==null?void 0:i.identity,o=(r==null?void 0:r.avatarUrl)??(r==null?void 0:r.avatar);if(o)return $v.test(o)||Ev.test(o)?o:r==null?void 0:r.avatarUrl}function Cv(e){var s;if(!e)return null;const t=(s=e.channelAccounts)==null?void 0:s.whatsapp;if(!t||t.length===0)return null;const n=t[0];return{running:n.running??!1,connected:n.connected??!1,linked:n.linked??!1,lastError:n.lastError}}function _v(e){var o;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(o=e.channelAccounts)==null?void 0:o.imessage;if(!t||t.length===0)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const n=t[0],s=n.running??!1,i=n.probe,r=i!=null?i.ok===!0:s;return{configured:n.configured??!1,running:s,connected:r,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function Mv(e){var o;const t=(o=e.configSnapshot)==null?void 0:o.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const s=n.find(a=>{var l,c;return((l=a.match)==null?void 0:l.channel)==="imessage"&&((c=a.meta)==null?void 0:c.imessageOwner)});if(!s)return null;const i=s.agentId;for(const a of e.workspaces)if(a.agents.some(l=>l.id===i))return a.name;if(i==="admin"||i==="public"){const a=e.workspaces.find(l=>l.isDefault);return(a==null?void 0:a.name)??null}const r=i.replace(/-(admin|public)$/,"");if(r!==i){const a=e.workspaces.find(l=>l.name===r);return(a==null?void 0:a.name)??null}return null}function Lv(e){var t,n,s,i,r,o,a;if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return Pa({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(c,u)=>{u!=null&&e.handlePinSubmit(c,u)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(c,u,p)=>e.handleChangePin(c,u,p)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return Pa({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:c=>e.handleSetMasterPin(c)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",k}if(e.setup){const l=Cv(e.channelsSnapshot),c=((n=(t=e.channelsSnapshot)==null?void 0:t.channelAccounts)==null?void 0:n.whatsapp)??[],u=_v(e.channelsSnapshot),p=Mv(e);return Oh({connected:e.connected,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:d=>e.handleLicenseKeyChange(d),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:l,whatsappAccounts:c,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:d=>e.handleUninstallConfirmTextChange(d),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:d=>e.handleAuthSubmitCode(d),onAuthCodeChange:d=>e.handleAuthCodeChange(d),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async d=>{await e.handleWhatsAppStart(!0,d),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(d),await q(e,!0),e.requestUpdate())},onWhatsAppReset:async d=>{await e.handleWhatsAppLogout(d),await e.handleWhatsAppStart(!0,d),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(d),await q(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await q(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),q(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:d=>e.handleRemoveWhatsAppAccount(d),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:d=>{e.newWorkspacePin=d},onWorkspaceCreate:async(d,h)=>{const b=e.newWorkspacePin;await e.handleWorkspaceCreate(d,h),b.match(/^\d{4,6}$/)&&(await rv(e,d,b),e.newWorkspacePin="")},onWorkspaceRemove:d=>e.handleWorkspaceRemove(d),onSetAddingWorkspace:d=>{e.addingWorkspace=d},onSetNewWorkspaceName:d=>{e.newWorkspaceName=d},onSetNewWorkspacePath:d=>{e.newWorkspacePath=d},onSetWorkspaceRemoveConfirm:d=>{e.workspaceRemoveConfirm=d},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(d,h)=>e.handleWorkspaceRename(d,h),whatsappDmPolicy:(()=>{const d=ne(e),h=d==null?void 0:d.whatsappAccountId,b=h?c.find(w=>w.accountId===h):c[0];return(b==null?void 0:b.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var A;const d=ne(e),h=d==null?void 0:d.whatsappAccountId,b=h?c.find(E=>E.accountId===h):c[0];if(!b)return;const S=b.dmPolicy!=null&&b.dmPolicy!=="disabled"?"disabled":"open",T=S==="open"?{dmPolicy:S,allowFrom:["*"]}:{dmPolicy:S};try{const E=await e.client.request("config.get"),C=E.config,R=(A=C==null?void 0:C.channels)==null?void 0:A.whatsapp,Q=((R==null?void 0:R.accounts)??{})[b.accountId]?{channels:{whatsapp:{accounts:{[b.accountId]:T}}}}:{channels:{whatsapp:T}};await e.client.request("config.patch",{raw:JSON.stringify(Q),baseHash:E.hash,note:`WhatsApp DM policy → ${S}`,skipRestart:!0}),await q(e,!1)}catch(E){console.error("DM toggle failed:",E)}},whatsappModel:(()=>{var A,E;const d=ne(e);if(!d)return null;const h=d.agents.find(C=>C.id.endsWith("-public")||C.id==="public");if(!h)return null;const b=(A=e.configSnapshot)==null?void 0:A.config,w=(E=b==null?void 0:b.agents)==null?void 0:E.list;if(!Array.isArray(w))return null;const S=w.find(C=>C.id===h.id);if(!(S!=null&&S.model))return null;const T=typeof S.model=="string"?S.model:S.model.primary;return(T==null?void 0:T.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async d=>{const h=ne(e);if(!h)return;const b=h.agents.find(w=>w.id.endsWith("-public")||w.id==="public");if(b)try{const w=await e.client.request("config.get"),S=w.config,T=(S==null?void 0:S.agents)??{},A=Array.isArray(T.list)?[...T.list]:[],E=A.findIndex(R=>R.id===b.id);if(d)E>=0?A[E]={...A[E],model:d}:A.push({id:b.id,model:d});else if(E>=0){const{model:R,...U}=A[E];Object.keys(U).length<=1?A.splice(E,1):A[E]=U}const C=A.length>0?{agents:{list:A}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(C),baseHash:w.hash,note:`Public agent model → ${d||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Model change failed:",w)}},whatsappThinkingLevel:(()=>{var T,A,E;const d=ne(e);if(!d)return null;const h=d.agents.find(C=>C.id.endsWith("-public")||C.id==="public");if(!h)return null;const b=(T=e.configSnapshot)==null?void 0:T.config,w=(A=b==null?void 0:b.agents)==null?void 0:A.list;if(!Array.isArray(w))return null;const S=w.find(C=>C.id===h.id);return((E=S==null?void 0:S.thinkingLevel)==null?void 0:E.trim())||null})(),onWhatsAppThinkingChange:async d=>{const h=ne(e);if(!h)return;const b=h.agents.find(w=>w.id.endsWith("-public")||w.id==="public");if(b)try{const w=await e.client.request("config.get"),S=w.config,T=(S==null?void 0:S.agents)??{},A=Array.isArray(T.list)?[...T.list]:[],E=A.findIndex(U=>U.id===b.id),C=d==="off"?void 0:d;if(C)E>=0?A[E]={...A[E],thinkingLevel:C}:A.push({id:b.id,thinkingLevel:C});else if(E>=0){const{thinkingLevel:U,...Q}=A[E];Object.keys(Q).length<=1?A.splice(E,1):A[E]=Q}const R=A.length>0?{agents:{list:A}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(R),baseHash:w.hash,note:`Public agent thinking → ${C||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Thinking change failed:",w)}},whatsappGroupPolicy:(()=>{var E,C;const d=(E=e.configSnapshot)==null?void 0:E.config,h=(C=d==null?void 0:d.channels)==null?void 0:C.whatsapp,b=ne(e),w=b==null?void 0:b.whatsappAccountId,S=(h==null?void 0:h.accounts)??{},T=w?S[w]:void 0;return(T==null?void 0:T.groupPolicy)??(h==null?void 0:h.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var C,R;const d=(C=e.configSnapshot)==null?void 0:C.config,h=(R=d==null?void 0:d.channels)==null?void 0:R.whatsapp,b=ne(e),w=b==null?void 0:b.whatsappAccountId,S=(h==null?void 0:h.accounts)??{},T=w?S[w]:void 0,E=((T==null?void 0:T.groups)??(h==null?void 0:h.groups)??{})["*"];return(E==null?void 0:E.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var b;const d=ne(e),h=d==null?void 0:d.whatsappAccountId;try{const w=await e.client.request("config.get"),S=w.config,T=((b=S==null?void 0:S.channels)==null?void 0:b.whatsapp)??{},A=T.accounts??{},E=h?A[h]:void 0,C=(E==null?void 0:E.groupPolicy)??T.groupPolicy??"allowlist",R=C==="disabled"||C==="allowlist",U=R?"open":"disabled",Q=R?{"*":{}}:void 0,ze={groupPolicy:U};Q&&(ze.groups=Q);const Lt=E?{channels:{whatsapp:{accounts:{[h]:ze}}}}:{channels:{whatsapp:ze}};await e.client.request("config.patch",{raw:JSON.stringify(Lt),baseHash:w.hash,note:`WhatsApp groups → ${U}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(w){console.error("Group toggle failed:",w)}},onWhatsAppGroupMentionChange:async d=>{var w;const h=ne(e),b=h==null?void 0:h.whatsappAccountId;try{const S=await e.client.request("config.get"),T=S.config,E=(((w=T==null?void 0:T.channels)==null?void 0:w.whatsapp)??{}).accounts??{},C=b?E[b]:void 0,R={"*":{requireMention:d}},U=C?{channels:{whatsapp:{accounts:{[b]:{groups:R}}}}}:{channels:{whatsapp:{groups:R}}};await e.client.request("config.patch",{raw:JSON.stringify(U),baseHash:S.hash,note:`WhatsApp group mention → ${d?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(S){console.error("Group mention change failed:",S)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:u.configured,imessageRunning:u.running,imessageConnected:u.connected,imessageLastError:u.lastError,imessageSelfChatMode:u.selfChatMode,imessageCliPath:u.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:p,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),h=d.config,b=(h==null?void 0:h.bindings)??[],w=ne(e),S=w==null?void 0:w.agents.find(R=>R.id.endsWith("-admin")||R.id==="admin"),T=(S==null?void 0:S.id)??"admin",A=b.filter(R=>{var U;return((U=R.match)==null?void 0:U.channel)!=="imessage"}),E=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],C=[...A,...E];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:C}),baseHash:d.hash,note:"Enable iMessage (self-chat) for "+((w==null?void 0:w.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),xe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await q(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),h=d.config,w=((h==null?void 0:h.bindings)??[]).filter(S=>{var T;return((T=S.match)==null?void 0:T.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:w}),baseHash:d.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),xe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const d=await e.client.request("config.get"),h=d.config,b=(h==null?void 0:h.bindings)??[],w=ne(e),S=w==null?void 0:w.agents.find(C=>C.id.endsWith("-admin")||C.id==="admin"),T=(S==null?void 0:S.id)??"admin",A=b.filter(C=>{var R;return((R=C.match)==null?void 0:R.channel)!=="imessage"}),E=[{agentId:T,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:[...A,...E]}),baseHash:d.hash,note:"Reassign iMessage to "+((w==null?void 0:w.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([q(e,!0),xe(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:d=>{e.infoModalOpen=d},onInfoModalClose:()=>{e.infoModalOpen=null},isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,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(d,h)=>{e.apiKeySavingProvider=d,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ia(e.client,d,h);const b=`${d} key saved`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Wi(e.client)}catch{}d==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async d=>{e.apiKeySavingProvider=d,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await av(e.client,d);const h=`${d} key removed`;e.apiKeySuccess=h,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Wi(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===h&&(e.apiKeySuccess=null)},2500)}catch(h){e.apiKeyError=h instanceof Error?h.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:d=>{e.authApiKeyInput=d},onAuthApiKeySubmit:async()=>{const d=e.authApiKeyInput.trim();if(d){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await Ia(e.client,"anthropic",d),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(h){e.authApiKeyError=h instanceof Error?h.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var h;const d=e.selectedWorkspace??((h=e.workspaces[0])==null?void 0:h.name);return d?e.accessState.accounts.some(b=>b.id===d):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(d,h)=>{var w;const b=e.selectedWorkspace??((w=e.workspaces[0])==null?void 0:w.name);b&&e.handleAccountPinSave(b,d,h)},wsProps:wv(e)})}if(e.filesPage){const l=xv(e);return Ah({connected:e.connected,wsProps:qt(e),loading:e.filesLoading,tree:e.filesTree,root:e.filesRoot,error:e.filesError,selectedPath:e.filesSelectedPath,selectedPaths:e.filesSelectedPaths,previewContent:e.filesPreviewContent,previewLoading:e.filesPreviewLoading,previewBinary:e.filesPreviewBinary,previewSize:e.filesPreviewSize,expandedDirs:e.filesExpandedDirs,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>pn(e,l),onReindex:()=>Np(e,l),onSelectFile:c=>_p(e,c,l),onToggleSelectFile:c=>Mp(e,c,l),onToggleDir:c=>Dp(e,c),onUpload:(c,u)=>Rp(e,c,u,l),onDownload:c=>Il(e,c,l),onBulkDownload:()=>Lp(e,l),onDelete:c=>Ip(e,c,l),onMove:(c,u)=>Nl(e,c,u,l),onMoveToDir:(c,u)=>Pp(e,c,u,l),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:c=>{const u=e.filesSearchAgentId??l;Op(e,c,u)},onSearchAgentChange:c=>{e.filesSearchAgentId=c},onSearchClear:()=>{Bp(e)},onSearchQueryChange:c=>{e.filesSearchQuery=c}})}if(e.browserPage)return yh({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:()=>cv(e),onStop:()=>uv(e),onToggleInput:()=>pv(e),onToggleFullscreen:()=>hv(e),onCompleteHandoff:()=>dv(e),onCanvasMouseDown:l=>{const u=l.target.getBoundingClientRect(),d=nn().translateCoordinates(l.clientX-u.left,l.clientY-u.top);pi(e,"mousePressed",d.x,d.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const u=l.target.getBoundingClientRect(),d=nn().translateCoordinates(l.clientX-u.left,l.clientY-u.top);pi(e,"mouseReleased",d.x,d.y)},onCanvasMouseMove:l=>{const c=nn();if(c.shouldThrottleMouseMove())return;const p=l.target.getBoundingClientRect(),d=c.translateCoordinates(l.clientX-p.left,l.clientY-p.top);pi(e,"mouseMoved",d.x,d.y)},onCanvasKeyDown:l=>{let c=0;l.altKey&&(c|=1),l.ctrlKey&&(c|=2),l.metaKey&&(c|=4),l.shiftKey&&(c|=8),hi(e,"keyDown",l.key,{code:l.code,modifiers:c||void 0}),l.key.length===1&&hi(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{hi(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=kv(e),c=Sv(e);return Fh({connected:e.connected,wsProps:qt(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>xs(e,l),onAdd:u=>{Wc(e,u,l,c).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:u=>Kc(e,u,l,c),onNewPhoneChange:u=>e.handleAdminsNewPhoneChange(u)})}if(e.customersPage){const l=Av(e);return zh({connected:e.connected,wsProps:qt(e),loading:e.customersLoading,saving:e.customersSaving,records:e.customersRecords,error:e.customersError,searchQuery:e.customersSearchQuery,editingId:e.customersEditingId,showAddForm:e.customersShowAddForm,newRecordPhone:e.customersNewPhone,newRecordName:e.customersNewName,onSearch:c=>e.customersSearchQuery=c,onSearchSubmit:()=>ot(e,l),onAdd:(c,u)=>zc(e,c,u,l),onDelete:c=>jc(e,c,l),onSetField:(c,u,p)=>Hc(e,c,u,p,l),onDeleteField:(c,u)=>qc(e,c,u,l),onToggleExpand:c=>{e.customersEditingId=e.customersEditingId===c?null:c},onShowAddForm:()=>e.customersShowAddForm=!0,onCancelAddForm:()=>{e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName=""},onNewRecordPhoneChange:c=>e.handleCustomersNewPhoneChange(c),onNewRecordNameChange:c=>e.handleCustomersNewNameChange(c),onRefresh:()=>ot(e,l)})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",c=Tv(e),u=e.chatAvatarUrl??c??null;return $y({connected:e.connected,wsProps:qt(e),sessionKey:e.sessionKey,onSessionKeyChange:p=>{e.sessionKey=p,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:p,lastActiveSessionKey:p}),e.loadAssistantIdentity(),Me(e),Ai(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:p=>{Cn(e,e.sessionKey,{model:p}).then(()=>{Me(e)})},onThinkingLevelChange:p=>{Cn(e,e.sessionKey,{thinkingLevel:p==="off"?null:p}).then(()=>{Me(e)})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,onVerboseChange:p=>{Cn(e,e.sessionKey,{verboseLevel:p==="off"?null:p}).then(()=>{Me(e)})},onFillerChange:p=>{Cn(e,e.sessionKey,{fillerEnabled:p}).then(()=>{Me(e)})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:u,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:l,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>(e.resetToolStream(),Promise.all([Me(e),Ai(e)])),onToggleFocusMode:()=>{},onChatScroll:p=>e.handleChatScroll(p),nearBottom:e.chatUserNearBottom,onDraftChange:p=>e.chatMessage=p,attachments:e.chatAttachments,onAttachmentsChange:p=>e.chatAttachments=p,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:p=>e.removeQueuedMessage(p),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:p=>e.handleOpenSidebar(p),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:p=>e.handleSplitRatioChange(p),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?tv({connected:e.connected,wsProps:qt(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&$t(e,{clearMessages:!0}),l==="logs"&&(e.logsSubTab==="session"?wt(e,{reset:!0}):Jt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(i=(s=e.channelsSnapshot)==null?void 0:s.channelMeta)!=null&&i.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((r=e.channelsSnapshot)==null?void 0:r.channelOrder)??[],channelLabels:((o=e.channelsSnapshot)==null?void 0:o.channelLabels)??{},channelMeta:((a=e.channelsSnapshot)==null?void 0:a.channelMeta)??[],agentIds:(()=>{var c;const l=ne(e);return((c=l==null?void 0:l.agents)==null?void 0:c.map(u=>u.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1},detailJobId:e.cronDetailJobId,onDetailOpen:l=>{e.cronDetailJobId=l.id,bi(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{Cd(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,c)=>_d(e,l,c),onRun:l=>Md(e,l),onRemove:l=>Ld(e,l),onLoadRuns:l=>bi(e,l)},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:l=>e.skillsFilter=l,onRefresh:()=>$t(e,{clearMessages:!0}),onToggle:(l,c)=>vp(e,l,c),onEdit:(l,c)=>yp(e,l,c),onSaveKey:l=>bp(e,l),onInstall:(l,c,u)=>wp(e,l,c,u)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?wt(e,{reset:!0}):Jt(e,{reset:!0})},sessionLogsProps:{loading:e.sessionLogsLoading,error:e.sessionLogsError,entries:e.sessionLogsEntries,agents:e.sessionLogsAgents,filterText:e.sessionLogsFilterText,typeFilters:e.sessionLogsTypeFilters,agentFilters:e.sessionLogsAgentFilters,autoFollow:e.sessionLogsAutoFollow,full:e.sessionLogsFull,onFilterTextChange:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,c)=>{const u=e;u.sessionLogsTypeFilters={...u.sessionLogsTypeFilters,[l]:c}},onAgentToggle:(l,c)=>{const u=e;u.sessionLogsAgentFilters={...u.sessionLogsAgentFilters,[l]:c}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onToggleFull:l=>{e.sessionLogsFull=l,wt(e,{reset:!0})},onRefresh:()=>{wt(e,{reset:!0})},onExport:(l,c)=>e.exportSessionLogs(l,c),onScroll:l=>e.handleSessionLogsScroll(l)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,truncated:e.logsTruncated,onFilterTextChange:l=>e.logsFilterText=l,onLevelToggle:(l,c)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:c}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onRefresh:()=>Jt(e,{reset:!0}),onExport:(l,c)=>e.exportSessionLogs(l,c),onScroll:l=>e.handleLogsScroll(l)}}):(window.location.replace("/chat"),f``)}function Pv(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),s=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${s}`}function Na(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Rv(e,t,n){return f`
|
|
2973
2975
|
<div class="audit-modal-overlay" @click=${i=>{i.target.classList.contains("audit-modal-overlay")&&n()}}>
|
|
2974
2976
|
<div class="audit-modal-card">
|
|
2975
2977
|
<div class="audit-modal-header">
|
|
@@ -2980,16 +2982,16 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
2980
2982
|
These files were written to shared or public folders by the agent.
|
|
2981
2983
|
Review to ensure no sensitive data was misplaced.
|
|
2982
2984
|
</p>
|
|
2983
|
-
${e.length===0?
|
|
2985
|
+
${e.length===0?f`<p class="audit-modal-empty">No unreviewed writes.</p>`:f`
|
|
2984
2986
|
<div class="audit-modal-list">
|
|
2985
|
-
${e.map(i=>
|
|
2987
|
+
${e.map(i=>f`
|
|
2986
2988
|
<div class="audit-modal-entry">
|
|
2987
2989
|
<div class="audit-modal-entry-path">
|
|
2988
|
-
<span class="audit-modal-folder audit-modal-folder--${
|
|
2990
|
+
<span class="audit-modal-folder audit-modal-folder--${Na(i.path)}">${Na(i.path)}</span>
|
|
2989
2991
|
<a href="/files" class="audit-modal-path-link">${i.path}</a>
|
|
2990
2992
|
</div>
|
|
2991
2993
|
<div class="audit-modal-entry-meta">
|
|
2992
|
-
${
|
|
2994
|
+
${Pv(i.timestamp)}
|
|
2993
2995
|
<span class="audit-modal-agent">${i.agentId}</span>
|
|
2994
2996
|
</div>
|
|
2995
2997
|
</div>
|
|
@@ -3001,7 +3003,7 @@ ${a.text}`:l.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
3001
3003
|
`}
|
|
3002
3004
|
</div>
|
|
3003
3005
|
</div>
|
|
3004
|
-
`}const Rv={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Iv={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};async function Nv(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 fn(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 Dv(e,t){var s,i;if(!e.client||!e.connected||e.workspaceSaving)return;const n=t.name.trim();if(!n){e.workspacesError="Account name is required.";return}e.workspaceSaving=!0,e.workspacesError=null;try{const r=await e.client.request("config.get",{});e.configSnapshot=r;const o=r.hash;if(!o){e.workspacesError="Config hash missing; reload and retry.";return}const a={name:n,baseHash:o,whatsappAccountName:n};(s=t.workspacePath)!=null&&s.trim()&&(a.workspaceDir=t.workspacePath.trim());const l=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await fn(e),(i=t.onCreated)==null||i.call(t,l)}catch(r){e.workspacesError=String(r)}finally{e.workspaceSaving=!1}}async function Ov(e,t){if(!(!e.client||!e.connected)&&!e.workspaceSaving){e.workspaceSaving=!0,e.workspacesError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const s=n.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:s}),e.workspaceRemoveConfirm=null,await fn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Bv(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:i}),await fn(e)}catch(s){e.workspacesError=String(s)}}}const Un=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Dv,loadWorkspaces:fn,removeWorkspace:Ov,renameWorkspace:Bv},Symbol.toStringTag,{value:"Module"})),jc={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"},Ra=jc,Wi={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(jc));new Set(Object.values(Wi));function Fv(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),s=e.token??"",i=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),s];return t==="v2"&&i.push(e.nonce??""),i.join("|")}const Uv=4008;class Wv{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{var s,i;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(i=(s=this.opts).onClose)==null||i.call(s,{code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){var u;if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.approvals","operator.pairing"],s="operator";let i=null,r=!1,o=this.opts.token;if(t){i=await rp();const p=(u=lp({deviceId:i.deviceId,role:s}))==null?void 0:u.token;o=p??this.opts.token,r=!!(p&&this.opts.token)}const a=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let l;if(t&&i){const p=Date.now(),d=this.connectNonce??void 0,f=Fv({deviceId:i.deviceId,clientId:this.opts.clientName??Ra.CONTROL_UI,clientMode:this.opts.mode??Wi.WEBCHAT,role:s,scopes:n,signedAtMs:p,token:o??null,nonce:d}),b=await op(i.privateKey,f);l={id:i.deviceId,publicKey:i.publicKey,signature:b,signedAt:p,nonce:d}}const c={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Ra.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Wi.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:l,caps:[],auth:a,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",c).then(p=>{var d,f,b;(d=p==null?void 0:p.auth)!=null&&d.deviceToken&&i&&cp({deviceId:i.deviceId,role:p.auth.role??s,token:p.auth.deviceToken,scopes:p.auth.scopes??[]}),this.backoffMs=800,(b=(f=this.opts).onHello)==null||b.call(f,p)}).catch(()=>{var p;r&&i&&up({deviceId:i.deviceId,role:s}),(p=this.ws)==null||p.close(Uv,"connect failed")})}handleMessage(t){var i,r,o,a,l;let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const c=n;if(c.event==="connect.challenge"){const p=c.payload,d=p&&typeof p.nonce=="string"?p.nonce:null;d&&(this.connectNonce=d,this.sendConnect());return}const u=typeof c.seq=="number"?c.seq:null;u!==null&&(this.lastSeq!==null&&u>this.lastSeq+1&&((r=(i=this.opts).onGap)==null||r.call(i,{expected:this.lastSeq+1,received:u})),this.lastSeq=u);try{(a=(o=this.opts).onEvent)==null||a.call(o,c)}catch(p){console.error("[gateway] event handler error:",p)}return}if(s.type==="res"){const c=n,u=this.pending.get(c.id);if(!u)return;this.pending.delete(c.id),c.ok?u.resolve(c.payload):u.reject(new Error(((l=c.error)==null?void 0:l.message)??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const s=Gi(),i={type:"req",id:s,method:t,params:n},r=new Promise((o,a)=>{this.pending.set(s,{resolve:l=>o(l),reject:a})});return this.ws.send(JSON.stringify(i)),r}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ki(e){return typeof e=="object"&&e!==null}function Kv(e){if(!Ki(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ki(n))return null;const s=typeof n.command=="string"?n.command.trim():"";if(!s)return null;const i=typeof e.createdAtMs=="number"?e.createdAtMs:0,r=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!r?null:{id:t,request:{command:s,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:i,expiresAtMs:r}}function zv(e){if(!Ki(e))return null;const t=typeof e.id=="string"?e.id.trim():"";return t?{id:t,decision:typeof e.decision=="string"?e.decision:null,resolvedBy:typeof e.resolvedBy=="string"?e.resolvedBy:null,ts:typeof e.ts=="number"?e.ts:null}:null}function Hc(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function jv(e,t){const n=Hc(e).filter(s=>s.id!==t.id);return n.push(t),n}function Ia(e,t){return Hc(e).filter(n=>n.id!==t)}async function qc(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),s=n?{sessionKey:n}:{};try{const i=await e.client.request("agent.identity.get",s);if(!i)return;const r=mi(i);e.assistantName=r.name,e.assistantAvatar=r.avatar,e.assistantAgentId=r.agentId??null}catch{}}const cs="taskmaster_update_pending";async function Gc(e){var t,n;if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("update.status",{});e.currentVersion=s.current,e.latestVersion=s.latest,e.updateAvailable=s.updateAvailable,e.updateMessage=s.updateAvailable?`v${s.latest} available`:"Up to date"}catch(s){e.updateMessage=`Check failed: ${String(s)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function Hv(e){var t,n,s,i;if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e);try{localStorage.setItem(cs,String(Date.now()))}catch{}try{const r=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(r.ok&&r.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(r.ok&&r.result.status==="skipped")sn(),e.updateMessage=r.result.reason||"Update skipped",e.updateRunning=!1,(s=e.requestUpdate)==null||s.call(e);else throw sn(),new Error(r.result.reason||"Update failed")}catch(r){sn(),e.updateMessage=`Update failed: ${String(r)}`,e.updateRunning=!1,e.updateProgressSteps=[],(i=e.requestUpdate)==null||i.call(e)}}}function qv(e,t){var s,i,r;const n=t.phase;if(n==="step-start"){const o=t.name,a=t.index,l=t.total;e.updateMessage=`Updating: ${o} (${a+1}/${l})`;const c=e.updateProgressSteps.find(u=>u.index===a);c?(c.status="running",c.name=o):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:l,status:"running"}],(s=e.requestUpdate)==null||s.call(e)}else if(n==="step-done"){const o=t.name,a=t.index,l=t.total,c=t.ok,u=t.durationMs,p=e.updateProgressSteps.find(d=>d.index===a);p?(p.status=c?"done":"failed",p.durationMs=u):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:l,status:c?"done":"failed",durationMs:u}],e.updateMessage=c?`Updating: ${o} done (${a+1}/${l})`:`Update step failed: ${o}`,(i=e.requestUpdate)==null||i.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const a=t.reason;e.updateMessage=a?`Update failed: ${a}`:"Update failed",e.updateRunning=!1,sn()}(r=e.requestUpdate)==null||r.call(e)}}async function Gv(e){var n,s,i,r;if(!e.client||!e.connected)return;const t=Qv();sn();try{const o=await e.client.request("update.lastResult",{});if(!o.ok||!o.result)return;const a=5*6e4,l=Date.now()-o.result.ts<a;if(!t&&!l)return;e.updateLastResult=o.result;const c=(n=o.result.after)==null?void 0:n.version;if(o.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,o.result.status==="ok"){const u=(s=o.result.before)==null?void 0:s.version,p=c??o.result.currentVersion;e.updateMessage=u?`Updated: v${u} → v${p}`:`Updated to v${p}`}else{const u=o.result.reason??((i=o.result.failedStep)==null?void 0:i.name)??"unknown error";e.updateMessage=`Update failed: ${u}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(r=e.requestUpdate)==null||r.call(e)}}function Vv(e){var t;e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e)}function Qv(){try{const e=localStorage.getItem(cs);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(cs),!1):!0:!1}catch{return!1}}function sn(){try{localStorage.removeItem(cs)}catch{}}function hi(e,t){var a,l,c;const n=(e??"").trim(),s=(a=t.mainSessionKey)==null?void 0:a.trim();if(!s)return n;if(!n)return s;const i=((l=t.mainKey)==null?void 0:l.trim())||"main",r=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===i||r&&(n===`agent:${r}:main`||n===`agent:${r}:${i}`)?s:n}function Yv(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=hi(e.sessionKey,t),s=hi(e.settings.sessionKey,t),i=hi(e.settings.lastActiveSessionKey,t),r=n||s||e.sessionKey,o={...e.settings,sessionKey:s||r,lastActiveSessionKey:i||r},a=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;r!==e.sessionKey&&(e.sessionKey=r),a&&Be(e,o)}function _e(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.customersPage||e.advancedPage?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new Wv({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:n,mode:"webchat",onHello:i=>{e.connected=!0,e.lastError=null,e.hello=i,ns()&&(yr(),e.uninstallDone=!1),Jv(e,i),e.handleAccessCheck(),Gv(e).then(()=>{Gc(e)}),qc(e),Nv(e),(e.chatPage||e.setup)&&eb(e),ir(e,{quiet:!0}),sr(e,{quiet:!0}),fn(e).then(()=>{e.initWorkspaceSelection()}),e.setup&&(xe(e),tb(e)),hr(e)},onClose:({code:i,reason:r})=>{e.connected=!1,i!==1012&&(e.lastError=`disconnected (${i}): ${r||"no reason"}`)},onEvent:i=>Xv(e,i),onGap:({expected:i,received:r})=>{e.lastError=`event gap detected (expected seq ${i}, got ${r}); refresh recommended`}}),e.client.start()}function Xv(e,t){try{Zv(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Zv(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;pd(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n!=null&&n.sessionKey&&Rl(e,n.sessionKey);const s=tl(e,n);(s==="final"||s==="error"||s==="aborted")&&(Qi(e),sh(e)),s==="final"&&Me(e);return}if(t.event==="presence"){const n=t.payload;n!=null&&n.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&fr(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&sr(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=Kv(t.payload);if(n){e.execApprovalQueue=jv(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Ia(e.execApprovalQueue,n.id)},s)}return}if(t.event==="browser.screencast.frame"){hv(e,t.payload);return}if(t.event==="browser.handoff"){fv(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){gv(e);return}if(t.event==="exec.approval.resolved"){const n=zv(t.payload);n&&(e.execApprovalQueue=Ia(e.execApprovalQueue,n.id));return}if(t.event==="update.progress"){qv(e,t.payload);return}}function Jv(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&&Yv(e,n.sessionDefaults)}async function eb(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 tb(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await Ui(e.client)}catch{}}function nb(e){e.basePath=Hp();const t=We();if(ch(t.accentColor),window.scrollTo(0,0),Bp(e),e.setup){document.title=`${t.name} Setup`,_e(e);return}if(e.filesPage){document.title=`${t.name} Files`,Up(e),_e(e);return}if(e.browserPage){document.title=`${t.name} Browser`,_e(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,_e(e);return}if(e.customersPage){document.title=`${t.name} Customers`,_e(e);return}if(e.chatPage){document.title=`${t.name} Chat`,_e(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,_e(e);return}Qp(e,!0),qp(e),Gp(e),window.addEventListener("popstate",e.popStateHandler),Kp(e),_e(e),Dp(e),e.tab==="logs"&&(e.logsSubTab==="session"?cr(e):ar(e)),e.tab==="debug"&&dr(e)}function sb(e){bd(e)}function ib(e){var t;window.removeEventListener("popstate",e.popStateHandler),Op(e),lr(e),ur(e),pr(e),Fp(e),Wp(e),Vp(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function rb(e,t){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.customersPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleCustomersLoad&&e.handleCustomersLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const s=t.has("setupStep")&&e.setupStep==="auth";(n||s)&&e.setupStep==="auth"&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="whatsapp"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(r=>{e.channelsSnapshot=r,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(i=>{e.channelsSnapshot=i,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),s=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;cn(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&nl(e,t.has("tab")||t.has("logsAutoFollow"))}function ob(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 ab(e,t,n){await Yi(e,t,n),await q(e,!0)}async function lb(e,t){await rl(e,t),await q(e,!0)}async function cb(e,t){await ol(e,t),await q(e,!0)}async function ub(e,t){await al(e,t)}async function db(e,t){await ll(e,t)}async function pb(e){await Sd(e),await xe(e),await q(e,!0)}async function hb(e){await xe(e),await q(e,!0)}function fb(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[s,...i]=n.split(":");if(!s||i.length===0)continue;const r=s.trim(),o=i.join(":").trim();r&&o&&(t[r]=o)}return t}function Vc(e){var n,s,i;return((i=(((s=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:s.nostr)??[])[0])==null?void 0:i.accountId)??e.nostrProfileAccountId??"default"}function Qc(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function gb(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=ob(n??void 0)}function mb(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function yb(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function vb(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function bb(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Vc(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Qc(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||(i==null?void 0:i.ok)===!1||!i){const r=(i==null?void 0:i.error)??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:r,success:null,fieldErrors:fb(i==null?void 0:i.details)};return}if(!i.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await q(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function wb(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Vc(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Qc(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||(i==null?void 0:i.ok)===!1||!i){const l=(i==null?void 0:i.error)??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const r=i.merged??i.imported??null,o=r?{...t.values,...r}:t.values,a=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:a},i.saved&&await q(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}async function kb(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 Sb(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 xb(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 Ab(e,t){e.authCodeInput=t}function $b(e){e.setupStep="whatsapp"}async function Eb(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 Tb(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 Cb(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 _b(e,t){e.licenseKey=t}async function Mb(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("health",{probe:!0});e.gatewayHealthy=s.ok===!0,e.gatewayHealthMessage=s.ok?`Healthy${s.durationMs?` (${s.durationMs}ms)`:""}`:"Unhealthy"}catch(s){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(s)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function Lb(e){var t,n,s;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(i.ok&&((n=i.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(i){e.gatewayHealthMessage=`Restart failed: ${String(i)}`,e.gatewayRestartBusy=!1,(s=e.requestUpdate)==null||s.call(e)}}}var Pb=Object.defineProperty,Rb=Object.getOwnPropertyDescriptor,m=(e,t,n,s)=>{for(var i=s>1?void 0:s?Rb(t,n):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&Pb(t,n,i),i};const fi=Iu();function Ib(){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 Nb(){const e=window.location.pathname;if(e==="/setup"||e.endsWith("/setup"))return!0;if(!window.location.search)return!1;const n=new URLSearchParams(window.location.search).get("setup");if(!n)return!1;const s=n.trim().toLowerCase();return s==="1"||s==="true"||s==="yes"||s==="on"}function Db(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function Ob(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function Bb(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function Fb(){const e=window.location.pathname;return e==="/customers"||e.endsWith("/customers")}function Ub(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function Wb(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends kt{constructor(){super(...arguments),this.settings=Fs(),this.password="",this.tab="chat",this.onboarding=Ib(),this.setup=Nb(),this.filesPage=Db(),this.browserPage=Ob(),this.adminsPage=Bb(),this.customersPage=Fb(),this.chatPage=Ub(),this.advancedPage=Wb(),this.advancedTab="cron",this.connected=!1,this.accessState=Ic,this.theme=this.settings.theme??"system",this.themeResolved="dark",this.hello=null,this.lastError=null,this.eventLog=[],this.eventLogBuffer=[],this.toolStreamSyncTimer=null,this.sidebarCloseTimer=null,this.assistantName=fi.name,this.assistantAvatar=fi.avatar,this.assistantAgentId=fi.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatModelProvider=null,this.chatModel=null,this.chatModelCatalog=[],this.chatVerboseLevel=null,this.chatFillerEnabled=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
|
|
3006
|
+
`}const Iv={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Nv={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};async function Dv(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 fn(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 Ov(e,t){var s,i;if(!e.client||!e.connected||e.workspaceSaving)return;const n=t.name.trim();if(!n){e.workspacesError="Account name is required.";return}e.workspaceSaving=!0,e.workspacesError=null;try{const r=await e.client.request("config.get",{});e.configSnapshot=r;const o=r.hash;if(!o){e.workspacesError="Config hash missing; reload and retry.";return}const a={name:n,baseHash:o,whatsappAccountName:n};(s=t.workspacePath)!=null&&s.trim()&&(a.workspaceDir=t.workspacePath.trim());const l=await e.client.request("workspaces.create",a);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await fn(e),(i=t.onCreated)==null||i.call(t,l)}catch(r){e.workspacesError=String(r)}finally{e.workspaceSaving=!1}}async function Bv(e,t){if(!(!e.client||!e.connected)&&!e.workspaceSaving){e.workspaceSaving=!0,e.workspacesError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const s=n.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:s}),e.workspaceRemoveConfirm=null,await fn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Fv(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:i}),await fn(e)}catch(s){e.workspacesError=String(s)}}}const Un=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Ov,loadWorkspaces:fn,removeWorkspace:Bv,renameWorkspace:Fv},Symbol.toStringTag,{value:"Module"})),Gc={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"},Da=Gc,Ki={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Gc));new Set(Object.values(Ki));function Uv(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),s=e.token??"",i=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),s];return t==="v2"&&i.push(e.nonce??""),i.join("|")}const Wv=4008;class Kv{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{var s,i;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(i=(s=this.opts).onClose)==null||i.call(s,{code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){var u;if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.approvals","operator.pairing"],s="operator";let i=null,r=!1,o=this.opts.token;if(t){i=await lp();const p=(u=dp({deviceId:i.deviceId,role:s}))==null?void 0:u.token;o=p??this.opts.token,r=!!(p&&this.opts.token)}const a=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let l;if(t&&i){const p=Date.now(),d=this.connectNonce??void 0,h=Uv({deviceId:i.deviceId,clientId:this.opts.clientName??Da.CONTROL_UI,clientMode:this.opts.mode??Ki.WEBCHAT,role:s,scopes:n,signedAtMs:p,token:o??null,nonce:d}),b=await cp(i.privateKey,h);l={id:i.deviceId,publicKey:i.publicKey,signature:b,signedAt:p,nonce:d}}const c={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Da.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Ki.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:l,caps:[],auth:a,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",c).then(p=>{var d,h,b;(d=p==null?void 0:p.auth)!=null&&d.deviceToken&&i&&pp({deviceId:i.deviceId,role:p.auth.role??s,token:p.auth.deviceToken,scopes:p.auth.scopes??[]}),this.backoffMs=800,(b=(h=this.opts).onHello)==null||b.call(h,p)}).catch(()=>{var p;r&&i&&hp({deviceId:i.deviceId,role:s}),(p=this.ws)==null||p.close(Wv,"connect failed")})}handleMessage(t){var i,r,o,a,l;let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const c=n;if(c.event==="connect.challenge"){const p=c.payload,d=p&&typeof p.nonce=="string"?p.nonce:null;d&&(this.connectNonce=d,this.sendConnect());return}const u=typeof c.seq=="number"?c.seq:null;u!==null&&(this.lastSeq!==null&&u>this.lastSeq+1&&((r=(i=this.opts).onGap)==null||r.call(i,{expected:this.lastSeq+1,received:u})),this.lastSeq=u);try{(a=(o=this.opts).onEvent)==null||a.call(o,c)}catch(p){console.error("[gateway] event handler error:",p)}return}if(s.type==="res"){const c=n,u=this.pending.get(c.id);if(!u)return;this.pending.delete(c.id),c.ok?u.resolve(c.payload):u.reject(new Error(((l=c.error)==null?void 0:l.message)??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const s=Vi(),i={type:"req",id:s,method:t,params:n},r=new Promise((o,a)=>{this.pending.set(s,{resolve:l=>o(l),reject:a})});return this.ws.send(JSON.stringify(i)),r}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function zi(e){return typeof e=="object"&&e!==null}function zv(e){if(!zi(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!zi(n))return null;const s=typeof n.command=="string"?n.command.trim():"";if(!s)return null;const i=typeof e.createdAtMs=="number"?e.createdAtMs:0,r=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!r?null:{id:t,request:{command:s,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:i,expiresAtMs:r}}function jv(e){if(!zi(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 Vc(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Hv(e,t){const n=Vc(e).filter(s=>s.id!==t.id);return n.push(t),n}function Oa(e,t){return Vc(e).filter(n=>n.id!==t)}async function Qc(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),s=n?{sessionKey:n}:{};try{const i=await e.client.request("agent.identity.get",s);if(!i)return;const r=yi(i);e.assistantName=r.name,e.assistantAvatar=r.avatar,e.assistantAgentId=r.agentId??null}catch{}}const us="taskmaster_update_pending";async function Yc(e){var t,n;if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("update.status",{});e.currentVersion=s.current,e.latestVersion=s.latest,e.updateAvailable=s.updateAvailable,e.updateMessage=s.updateAvailable?`v${s.latest} available`:"Up to date"}catch(s){e.updateMessage=`Check failed: ${String(s)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function qv(e){var t,n,s,i;if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e);try{localStorage.setItem(us,String(Date.now())),localStorage.removeItem(Or)}catch{}try{const r=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(r.ok&&r.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(r.ok&&r.result.status==="skipped")sn(),e.updateMessage=r.result.reason||"Update skipped",e.updateRunning=!1,(s=e.requestUpdate)==null||s.call(e);else throw sn(),new Error(r.result.reason||"Update failed")}catch(r){sn(),e.updateMessage=`Update failed: ${String(r)}`,e.updateRunning=!1,e.updateProgressSteps=[],(i=e.requestUpdate)==null||i.call(e)}}}function Gv(e,t){var s,i,r;const n=t.phase;if(n==="step-start"){const o=t.name,a=t.index,l=t.total;e.updateMessage=`Updating: ${o} (${a+1}/${l})`;const c=e.updateProgressSteps.find(u=>u.index===a);c?(c.status="running",c.name=o):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:l,status:"running"}],(s=e.requestUpdate)==null||s.call(e)}else if(n==="step-done"){const o=t.name,a=t.index,l=t.total,c=t.ok,u=t.durationMs,p=e.updateProgressSteps.find(h=>h.index===a);p?(p.status=c?"done":"failed",p.durationMs=u):e.updateProgressSteps=[...e.updateProgressSteps,{name:o,index:a,total:l,status:c?"done":"failed",durationMs:u}];const d=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${o} done (${a+1}/${l})`:`Update step failed: ${o}${d}`,(i=e.requestUpdate)==null||i.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const a=t.reason;e.updateMessage=a?`Update failed: ${a}`:"Update failed",e.updateRunning=!1,sn()}(r=e.requestUpdate)==null||r.call(e)}}async function Vv(e){var n,s,i,r;if(!e.client||!e.connected)return;const t=Yv();sn();try{const o=await e.client.request("update.lastResult",{});if(!o.ok||!o.result)return;const a=5*6e4,l=Date.now()-o.result.ts<a;if(!t&&!l||Xv(o.result.ts))return;e.updateLastResult=o.result;const c=(n=o.result.after)==null?void 0:n.version;if(o.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,o.result.status==="ok"){const u=(s=o.result.before)==null?void 0:s.version,p=c??o.result.currentVersion;e.updateMessage=u?`Updated: v${u} → v${p}`:`Updated to v${p}`}else{const u=o.result.reason??((i=o.result.failedStep)==null?void 0:i.name)??"unknown error";e.updateMessage=`Update failed: ${u}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(r=e.requestUpdate)==null||r.call(e)}}const Or="taskmaster_update_dismissed";function Qv(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Or,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function Yv(){try{const e=localStorage.getItem(us);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(us),!1):!0:!1}catch{return!1}}function sn(){try{localStorage.removeItem(us)}catch{}}function Xv(e){try{const t=localStorage.getItem(Or);return t?Number(t)>=e:!1}catch{return!1}}function fi(e,t){var a,l,c;const n=(e??"").trim(),s=(a=t.mainSessionKey)==null?void 0:a.trim();if(!s)return n;if(!n)return s;const i=((l=t.mainKey)==null?void 0:l.trim())||"main",r=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===i||r&&(n===`agent:${r}:main`||n===`agent:${r}:${i}`)?s:n}function Zv(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=fi(e.sessionKey,t),s=fi(e.settings.sessionKey,t),i=fi(e.settings.lastActiveSessionKey,t),r=n||s||e.sessionKey,o={...e.settings,sessionKey:s||r,lastActiveSessionKey:i||r},a=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;r!==e.sessionKey&&(e.sessionKey=r),a&&Be(e,o)}function _e(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.customersPage||e.advancedPage?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new Kv({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:n,mode:"webchat",onHello:i=>{e.connected=!0,e.lastError=null,e.hello=i,ss()&&(yr(),e.uninstallDone=!1),tb(e,i),e.handleAccessCheck(),Vv(e).then(()=>{Yc(e)}),Qc(e),Dv(e),(e.chatPage||e.setup)&&nb(e),rr(e,{quiet:!0}),ir(e,{quiet:!0}),fn(e).then(()=>{e.initWorkspaceSelection()}),e.setup&&(xe(e),sb(e)),ts(e)},onClose:({code:i,reason:r})=>{e.connected=!1,i!==1012&&(e.lastError=`disconnected (${i}): ${r||"no reason"}`)},onEvent:i=>Jv(e,i),onGap:({expected:i,received:r})=>{console.warn(`[gateway] event gap: expected seq ${i}, got ${r}`),ts(e)}}),e.client.start()}function Jv(e,t){try{eb(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function eb(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;gd(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n!=null&&n.sessionKey&&Dl(e,n.sessionKey);const s=il(e,n);(s==="final"||s==="error"||s==="aborted")&&(Yi(e),oh(e)),s==="final"&&Me(e);return}if(t.event==="presence"){const n=t.payload;n!=null&&n.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&fr(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&ir(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=zv(t.payload);if(n){e.execApprovalQueue=Hv(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Oa(e.execApprovalQueue,n.id)},s)}return}if(t.event==="browser.screencast.frame"){fv(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"){mv(e);return}if(t.event==="exec.approval.resolved"){const n=jv(t.payload);n&&(e.execApprovalQueue=Oa(e.execApprovalQueue,n.id));return}if(t.event==="update.progress"){Gv(e,t.payload);return}}function tb(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&&Zv(e,n.sessionDefaults)}async function nb(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 sb(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await Wi(e.client)}catch{}}function ib(e){e.basePath=Vp();const t=We();if(ph(t.accentColor),window.scrollTo(0,0),Wp(e),e.setup){document.title=`${t.name} Setup`,_e(e);return}if(e.filesPage){document.title=`${t.name} Files`,zp(e),_e(e);return}if(e.browserPage){document.title=`${t.name} Browser`,_e(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,_e(e);return}if(e.customersPage){document.title=`${t.name} Customers`,_e(e);return}if(e.chatPage){document.title=`${t.name} Chat`,_e(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,_e(e);return}Zp(e,!0),Qp(e),Yp(e),window.addEventListener("popstate",e.popStateHandler),Hp(e),_e(e),Fp(e),e.tab==="logs"&&(e.logsSubTab==="session"?ur(e):lr(e)),e.tab==="debug"&&pr(e)}function rb(e){Sd(e)}function ob(e){var t;window.removeEventListener("popstate",e.popStateHandler),Up(e),cr(e),dr(e),hr(e),Kp(e),jp(e),Xp(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function ab(e,t){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.customersPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleCustomersLoad&&e.handleCustomersLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const s=t.has("setupStep")&&e.setupStep==="auth";(n||s)&&e.setupStep==="auth"&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="whatsapp"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(r=>{e.channelsSnapshot=r,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(i=>{e.channelsSnapshot=i,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),s=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;cn(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&rl(e,t.has("tab")||t.has("logsAutoFollow"))}function lb(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 cb(e,t,n){await Xi(e,t,n),await q(e,!0)}async function ub(e,t){await ll(e,t),await q(e,!0)}async function db(e,t){await cl(e,t),await q(e,!0)}async function pb(e,t){await ul(e,t)}async function hb(e,t){await dl(e,t)}async function fb(e){await $d(e),await xe(e),await q(e,!0)}async function gb(e){await xe(e),await q(e,!0)}function mb(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[s,...i]=n.split(":");if(!s||i.length===0)continue;const r=s.trim(),o=i.join(":").trim();r&&o&&(t[r]=o)}return t}function Xc(e){var n,s,i;return((i=(((s=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:s.nostr)??[])[0])==null?void 0:i.accountId)??e.nostrProfileAccountId??"default"}function Zc(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function yb(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=lb(n??void 0)}function vb(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function bb(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function wb(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function kb(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Xc(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Zc(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||(i==null?void 0:i.ok)===!1||!i){const r=(i==null?void 0:i.error)??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:r,success:null,fieldErrors:mb(i==null?void 0:i.details)};return}if(!i.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await q(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function Sb(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Xc(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Zc(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||(i==null?void 0:i.ok)===!1||!i){const l=(i==null?void 0:i.error)??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const r=i.merged??i.imported??null,o=r?{...t.values,...r}:t.values,a=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:a},i.saved&&await q(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}async function xb(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 Ab(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 $b(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 Eb(e,t){e.authCodeInput=t}function Tb(e){e.setupStep="whatsapp"}async function Cb(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 _b(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 Mb(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 Lb(e,t){e.licenseKey=t}async function Pb(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("health",{probe:!0});e.gatewayHealthy=s.ok===!0,e.gatewayHealthMessage=s.ok?`Healthy${s.durationMs?` (${s.durationMs}ms)`:""}`:"Unhealthy"}catch(s){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(s)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function Rb(e){var t,n,s;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(i.ok&&((n=i.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(i){e.gatewayHealthMessage=`Restart failed: ${String(i)}`,e.gatewayRestartBusy=!1,(s=e.requestUpdate)==null||s.call(e)}}}var Ib=Object.defineProperty,Nb=Object.getOwnPropertyDescriptor,m=(e,t,n,s)=>{for(var i=s>1?void 0:s?Nb(t,n):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&Ib(t,n,i),i};const gi=Ou();function Db(){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 Ob(){const e=window.location.pathname;if(e==="/setup"||e.endsWith("/setup"))return!0;if(!window.location.search)return!1;const n=new URLSearchParams(window.location.search).get("setup");if(!n)return!1;const s=n.trim().toLowerCase();return s==="1"||s==="true"||s==="yes"||s==="on"}function Bb(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function Fb(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function Ub(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function Wb(){const e=window.location.pathname;return e==="/customers"||e.endsWith("/customers")}function Kb(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function zb(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends kt{constructor(){super(...arguments),this.settings=Us(),this.password="",this.tab="chat",this.onboarding=Db(),this.setup=Ob(),this.filesPage=Bb(),this.browserPage=Fb(),this.adminsPage=Ub(),this.customersPage=Wb(),this.chatPage=Kb(),this.advancedPage=zb(),this.advancedTab="cron",this.connected=!1,this.accessState=Oc,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=gi.name,this.assistantAvatar=gi.avatar,this.assistantAgentId=gi.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatModelProvider=null,this.chatModel=null,this.chatModelCatalog=[],this.chatVerboseLevel=null,this.chatFillerEnabled=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
|
|
3005
3007
|
}
|
|
3006
|
-
`,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.whatsappActiveQrAccountId=null,this.whatsappPairedPhone=null,this.addingWhatsAppAccount=!1,this.newWhatsAppAccountName="",this.whatsappAccountError=null,this.whatsappAccountSaving=!1,this.whatsappSettingsOpen=!1,this.licenseKey="",this.licenseBusy=!1,this.licenseValid=null,this.licenseMessage=null,this.licenseTier=null,this.licenseDeviceId=null,this.licenseStoredKey=null,this.licenseRemoveConfirm=!1,this.authConnected=null,this.authBusy=!1,this.authMessage=null,this.authUrl=null,this.authCodeInput="",this.authExpiresIn=null,this.setupStep="license",this.gatewayHealthy=null,this.gatewayHealthLoading=!1,this.gatewayHealthMessage=null,this.gatewayRestartBusy=!1,this.updateAvailable=null,this.currentVersion=null,this.latestVersion=null,this.updateChecking=!1,this.updateMessage=null,this.updateProgressSteps=[],this.updateLastResult=null,this.uninstallConfirm=!1,this.uninstallBusy=!1,this.uninstallDone=!1,this.uninstallError=null,this.uninstallConfirmText="",this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...Iv},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.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.customersLoading=!1,this.customersSaving=!1,this.customersRecords=[],this.customersError=null,this.customersSearchQuery="",this.customersEditingId=null,this.customersShowAddForm=!1,this.customersNewPhone="",this.customersNewName="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.infoModalOpen=null,this.workspaces=[],this.workspacesLoading=!1,this.workspacesError=null,this.selectedWorkspace=null,this.addingWorkspace=!1,this.newWorkspaceName="",this.newWorkspacePath="",this.newWorkspacePin="",this.accountPinModalOpen=!1,this.accountPinBusy=!1,this.accountPinError=null,this.accountPinSuccess=null,this.apiKeyProviders=[],this.apiKeyModalOpen=!1,this.apiKeyBusy=!1,this.apiKeyError=null,this.apiKeySuccess=null,this.apiKeySavingProvider=null,this.authApiKeyMode=!1,this.authApiKeyInput="",this.authApiKeyBusy=!1,this.authApiKeyError=null,this.pinChanging=null,this.pinChangeBusy=!1,this.pinChangeError=null,this.loginChangePinMode=!1,this.changePinBusy=!1,this.changePinError=null,this.changePinSuccess=null,this.workspaceSaving=!1,this.workspaceRemoveConfirm=null,this.renamingWorkspace=!1,this.renameWorkspaceName="",this.debugLoading=!1,this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugCallMethod="",this.debugCallParams="{}",this.debugCallResult=null,this.debugCallError=null,this.logsLoading=!1,this.logsError=null,this.logsFile=null,this.logsEntries=[],this.logsFilterText="",this.logsLevelFilters={...Rv},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsSubTab="session",this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsFull=!1,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>Yp(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),nb(this)}firstUpdated(){sb(this)}disconnectedCallback(){ib(this),super.disconnectedCallback()}updated(e){rb(this,e)}connect(){_e(this)}handleChatScroll(e){hd(this,e)}handleLogsScroll(e){fd(this,e)}handleSessionLogsScroll(e){gd(this,e)}exportLogs(e,t){yd(e,t)}exportSessionLogs(e,t){vd(e,t)}resetToolStream(){Qi(this)}resetChatScroll(){md(this)}async loadAssistantIdentity(){await qc(this)}applySettings(e){Be(this,e)}setTab(e){zp(this,e)}setTheme(e,t){jp(this,e,t)}async loadOverview(){await Dl(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 fr(this)}async handleAbortChat(){await Bl(this)}removeQueuedMessage(e){eh(this,e)}async handleSendChat(e,t){await th(this,e,t)}async handleWhatsAppStart(e,t){await ab(this,e,t)}async handleWhatsAppWait(e){await lb(this,e)}async handleWhatsAppLogout(e){await cb(this,e)}async handleAddWhatsAppAccount(e){await ub(this,e)}async handleRemoveWhatsAppAccount(e){await db(this,e)}async handleAccessCheck(){await Ma(this)}async handlePinSubmit(e,t){await nv(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await sv(this,e)}async handleLogout(){await rv(this)}toggleChangePinMode(){this.loginChangePinMode=!this.loginChangePinMode,this.changePinError=null,this.changePinSuccess=null}async handleChangePin(e,t,n){if(this.client){this.changePinBusy=!0,this.changePinError=null,this.changePinSuccess=null;try{const s=await this.client.request("access.verify",{account:e,pin:t});if(!s.ok){this.changePinError=s.message??"Incorrect current PIN",this.changePinBusy=!1;return}e==="__master__"?await this.client.request("access.setMasterPin",{pin:n}):await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.changePinSuccess="PIN changed successfully",this.changePinBusy=!1,setTimeout(()=>{this.loginChangePinMode=!1,this.changePinSuccess=null},2e3)}catch{this.changePinError="Failed to change PIN",this.changePinBusy=!1}}}async handleAccountPinSave(e,t,n){if(this.client){this.accountPinBusy=!0,this.accountPinError=null,this.accountPinSuccess=null;try{if(t!==null){const s=await this.client.request("access.verify",{account:e,pin:t});if(!s.ok){this.accountPinError=s.message??"Incorrect current PIN",this.accountPinBusy=!1;return}}await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.accountPinSuccess="PIN saved",this.accountPinBusy=!1,await Ma(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 Eb(this)}async handleLicenseActivate(){await Tb(this)}async handleLicenseRemove(){await Cb(this)}handleLicenseKeyChange(e){_b(this,e)}async handleAuthStatusCheck(){await kb(this)}async handleAuthStart(){await Sb(this)}async handleAuthSubmitCode(e){await xb(this,e)}handleAuthCodeChange(e){Ab(this,e)}handleSkipToWhatsApp(){$b(this)}async handleGatewayHealthCheck(){await Mb(this)}async handleGatewayRestart(){await Lb(this)}async handleUpdateCheck(){await Gc(this)}async handleUpdateRun(){await Hv(this)}handleUpdateDismissResult(){Vv(this)}handleUninstallConfirm(){this.uninstallConfirm=!0,this.uninstallConfirmText=""}handleUninstallCancel(){this.uninstallConfirm=!1,this.uninstallConfirmText="",this.uninstallError=null}handleUninstallConfirmTextChange(e){this.uninstallConfirmText=e}async handleUninstallRun(){const{runUninstall:e}=await pe(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>To);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){pe(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>To);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await _l(this)}async clearAudit(){await $p(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(s=>s.id))??void 0;const t=this.resolveFilesAgentId();pn(this,t),or(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();pe(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>yv);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin");return t==null?void 0:t.id}resolveFilesAgentId(){var t;const e=this.getSelectedWorkspaceInfo();if(e)return(t=e.agents[0])==null?void 0:t.id}handleChatLoad(){const e=this.resolveAdminAgentId();if(e){const t=`agent:${e}:main`;t!==this.sessionKey&&(this.sessionKey=t,this.chatMessages=[],this.chatStream=null,this.chatRunId=null,this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}pe(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>nd);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this)})}handleAdvancedLoad(){this.loadCron()}async handleChannelConfigSave(){await pb(this)}async handleChannelConfigReload(){await hb(this)}handleNostrProfileEdit(e,t){gb(this,e,t)}handleNostrProfileCancel(){mb(this)}handleNostrProfileFieldChange(e,t){yb(this,e,t)}async handleNostrProfileSave(){await bb(this)}async handleNostrProfileImport(){await wb(this)}handleNostrProfileToggleAdvanced(){vb(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleAdminsNewPhoneChange(e){this.adminsNewPhone=e,this.adminsError&&(this.adminsError=null)}handleCustomersLoad(){const e=this.selectedWorkspace??void 0;pe(async()=>{const{loadCustomers:t}=await Promise.resolve().then(()=>vv);return{loadCustomers:t}},void 0,import.meta.url).then(({loadCustomers:t})=>{t(this,e)})}handleCustomersNewPhoneChange(e){this.customersNewPhone=e,this.customersError&&(this.customersError=null)}handleCustomersNewNameChange(e){this.customersNewName=e,this.customersError&&(this.customersError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await pe(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>Un);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await pe(async()=>{const{createWorkspace:i}=await Promise.resolve().then(()=>Un);return{createWorkspace:i}},void 0,import.meta.url),{loadChannels:s}=await pe(async()=>{const{loadChannels:i}=await Promise.resolve().then(()=>_d);return{loadChannels:i}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:i=>{if(!i.whatsappAccountId)return;const r=i.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await s(this,!0),await this.handleWhatsAppStart(!0,r),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(r),await s(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await pe(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>Un);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=(e==null?void 0:e.displayName)??(e==null?void 0:e.name)??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await pe(async()=>{const{renameWorkspace:s}=await Promise.resolve().then(()=>Un);return{renameWorkspace:s}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){this.selectedWorkspace=e,localStorage.setItem("taskmaster-selected-workspace",e),fo(e),this.settings=Fs(),this.chatMessage="",this.chatAttachments=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.loadAuditEntries(),this.adminsPage?this.handleAdminsLoad():this.customersPage?this.handleCustomersLoad():this.filesPage?this.handleFilesLoad():this.chatPage?this.handleChatLoad():this.advancedPage&&this.handleAdvancedLoad()}initWorkspaceSelection(){if(this.workspaces.length===0)return;const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(s=>s.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}fo(this.selectedWorkspace),this.settings=Fs(),this.reloadCurrentPageData()}render(){return h`${Mv(this)}${this.auditModalOpen?Pv(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):k}`}};m([y()],g.prototype,"settings",2);m([y()],g.prototype,"password",2);m([y()],g.prototype,"tab",2);m([y()],g.prototype,"onboarding",2);m([y()],g.prototype,"setup",2);m([y()],g.prototype,"filesPage",2);m([y()],g.prototype,"browserPage",2);m([y()],g.prototype,"adminsPage",2);m([y()],g.prototype,"customersPage",2);m([y()],g.prototype,"chatPage",2);m([y()],g.prototype,"advancedPage",2);m([y()],g.prototype,"advancedTab",2);m([y()],g.prototype,"connected",2);m([y()],g.prototype,"accessState",2);m([y()],g.prototype,"theme",2);m([y()],g.prototype,"themeResolved",2);m([y()],g.prototype,"hello",2);m([y()],g.prototype,"lastError",2);m([y()],g.prototype,"eventLog",2);m([y()],g.prototype,"assistantName",2);m([y()],g.prototype,"assistantAvatar",2);m([y()],g.prototype,"assistantAgentId",2);m([y()],g.prototype,"sessionKey",2);m([y()],g.prototype,"chatLoading",2);m([y()],g.prototype,"chatSending",2);m([y()],g.prototype,"chatMessage",2);m([y()],g.prototype,"chatMessages",2);m([y()],g.prototype,"chatToolMessages",2);m([y()],g.prototype,"chatStream",2);m([y()],g.prototype,"chatStreamStartedAt",2);m([y()],g.prototype,"chatRunId",2);m([y()],g.prototype,"compactionStatus",2);m([y()],g.prototype,"chatAvatarUrl",2);m([y()],g.prototype,"chatThinkingLevel",2);m([y()],g.prototype,"chatModelProvider",2);m([y()],g.prototype,"chatModel",2);m([y()],g.prototype,"chatModelCatalog",2);m([y()],g.prototype,"chatVerboseLevel",2);m([y()],g.prototype,"chatFillerEnabled",2);m([y()],g.prototype,"chatQueue",2);m([y()],g.prototype,"chatAttachments",2);m([y()],g.prototype,"sidebarOpen",2);m([y()],g.prototype,"sidebarContent",2);m([y()],g.prototype,"sidebarError",2);m([y()],g.prototype,"splitRatio",2);m([y()],g.prototype,"nodesLoading",2);m([y()],g.prototype,"nodes",2);m([y()],g.prototype,"devicesLoading",2);m([y()],g.prototype,"devicesError",2);m([y()],g.prototype,"devicesList",2);m([y()],g.prototype,"execApprovalsLoading",2);m([y()],g.prototype,"execApprovalsSaving",2);m([y()],g.prototype,"execApprovalsDirty",2);m([y()],g.prototype,"execApprovalsSnapshot",2);m([y()],g.prototype,"execApprovalsForm",2);m([y()],g.prototype,"execApprovalsSelectedAgent",2);m([y()],g.prototype,"execApprovalsTarget",2);m([y()],g.prototype,"execApprovalsTargetNodeId",2);m([y()],g.prototype,"execApprovalQueue",2);m([y()],g.prototype,"execApprovalBusy",2);m([y()],g.prototype,"execApprovalError",2);m([y()],g.prototype,"configLoading",2);m([y()],g.prototype,"configRaw",2);m([y()],g.prototype,"configRawOriginal",2);m([y()],g.prototype,"configValid",2);m([y()],g.prototype,"configIssues",2);m([y()],g.prototype,"configSaving",2);m([y()],g.prototype,"configApplying",2);m([y()],g.prototype,"updateRunning",2);m([y()],g.prototype,"applySessionKey",2);m([y()],g.prototype,"configSnapshot",2);m([y()],g.prototype,"configSchema",2);m([y()],g.prototype,"configSchemaVersion",2);m([y()],g.prototype,"configSchemaLoading",2);m([y()],g.prototype,"configUiHints",2);m([y()],g.prototype,"configForm",2);m([y()],g.prototype,"configFormOriginal",2);m([y()],g.prototype,"configFormDirty",2);m([y()],g.prototype,"configFormMode",2);m([y()],g.prototype,"configSearchQuery",2);m([y()],g.prototype,"configActiveSection",2);m([y()],g.prototype,"configActiveSubsection",2);m([y()],g.prototype,"channelsLoading",2);m([y()],g.prototype,"channelsSnapshot",2);m([y()],g.prototype,"channelsError",2);m([y()],g.prototype,"channelsLastSuccess",2);m([y()],g.prototype,"whatsappLoginMessage",2);m([y()],g.prototype,"whatsappLoginQrDataUrl",2);m([y()],g.prototype,"whatsappLoginConnected",2);m([y()],g.prototype,"whatsappBusy",2);m([y()],g.prototype,"whatsappActiveQrAccountId",2);m([y()],g.prototype,"whatsappPairedPhone",2);m([y()],g.prototype,"addingWhatsAppAccount",2);m([y()],g.prototype,"newWhatsAppAccountName",2);m([y()],g.prototype,"whatsappAccountError",2);m([y()],g.prototype,"whatsappAccountSaving",2);m([y()],g.prototype,"whatsappSettingsOpen",2);m([y()],g.prototype,"licenseKey",2);m([y()],g.prototype,"licenseBusy",2);m([y()],g.prototype,"licenseValid",2);m([y()],g.prototype,"licenseMessage",2);m([y()],g.prototype,"licenseTier",2);m([y()],g.prototype,"licenseDeviceId",2);m([y()],g.prototype,"licenseStoredKey",2);m([y()],g.prototype,"licenseRemoveConfirm",2);m([y()],g.prototype,"authConnected",2);m([y()],g.prototype,"authBusy",2);m([y()],g.prototype,"authMessage",2);m([y()],g.prototype,"authUrl",2);m([y()],g.prototype,"authCodeInput",2);m([y()],g.prototype,"authExpiresIn",2);m([y()],g.prototype,"setupStep",2);m([y()],g.prototype,"gatewayHealthy",2);m([y()],g.prototype,"gatewayHealthLoading",2);m([y()],g.prototype,"gatewayHealthMessage",2);m([y()],g.prototype,"gatewayRestartBusy",2);m([y()],g.prototype,"updateAvailable",2);m([y()],g.prototype,"currentVersion",2);m([y()],g.prototype,"latestVersion",2);m([y()],g.prototype,"updateChecking",2);m([y()],g.prototype,"updateMessage",2);m([y()],g.prototype,"updateProgressSteps",2);m([y()],g.prototype,"updateLastResult",2);m([y()],g.prototype,"uninstallConfirm",2);m([y()],g.prototype,"uninstallBusy",2);m([y()],g.prototype,"uninstallDone",2);m([y()],g.prototype,"uninstallError",2);m([y()],g.prototype,"uninstallConfirmText",2);m([y()],g.prototype,"nostrProfileFormState",2);m([y()],g.prototype,"nostrProfileAccountId",2);m([y()],g.prototype,"presenceLoading",2);m([y()],g.prototype,"presenceEntries",2);m([y()],g.prototype,"presenceError",2);m([y()],g.prototype,"presenceStatus",2);m([y()],g.prototype,"agentsLoading",2);m([y()],g.prototype,"agentsList",2);m([y()],g.prototype,"agentsError",2);m([y()],g.prototype,"sessionsLoading",2);m([y()],g.prototype,"sessionsResult",2);m([y()],g.prototype,"sessionsError",2);m([y()],g.prototype,"cronLoading",2);m([y()],g.prototype,"cronJobs",2);m([y()],g.prototype,"cronStatus",2);m([y()],g.prototype,"cronError",2);m([y()],g.prototype,"cronForm",2);m([y()],g.prototype,"cronRunsJobId",2);m([y()],g.prototype,"cronRuns",2);m([y()],g.prototype,"cronBusy",2);m([y()],g.prototype,"cronNewEventModal",2);m([y()],g.prototype,"cronDetailJobId",2);m([y()],g.prototype,"browserScreencastActive",2);m([y()],g.prototype,"browserScreencastFrame",2);m([y()],g.prototype,"browserScreencastMetadata",2);m([y()],g.prototype,"browserHandoffPending",2);m([y()],g.prototype,"browserHandoffReason",2);m([y()],g.prototype,"browserHandoffId",2);m([y()],g.prototype,"browserInputMode",2);m([y()],g.prototype,"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,"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,"customersLoading",2);m([y()],g.prototype,"customersSaving",2);m([y()],g.prototype,"customersRecords",2);m([y()],g.prototype,"customersError",2);m([y()],g.prototype,"customersSearchQuery",2);m([y()],g.prototype,"customersEditingId",2);m([y()],g.prototype,"customersShowAddForm",2);m([y()],g.prototype,"customersNewPhone",2);m([y()],g.prototype,"customersNewName",2);m([y()],g.prototype,"imessageEnableConfirm",2);m([y()],g.prototype,"imessageEnabling",2);m([y()],g.prototype,"infoModalOpen",2);m([y()],g.prototype,"workspaces",2);m([y()],g.prototype,"workspacesLoading",2);m([y()],g.prototype,"workspacesError",2);m([y()],g.prototype,"selectedWorkspace",2);m([y()],g.prototype,"addingWorkspace",2);m([y()],g.prototype,"newWorkspaceName",2);m([y()],g.prototype,"newWorkspacePath",2);m([y()],g.prototype,"newWorkspacePin",2);m([y()],g.prototype,"accountPinModalOpen",2);m([y()],g.prototype,"accountPinBusy",2);m([y()],g.prototype,"accountPinError",2);m([y()],g.prototype,"accountPinSuccess",2);m([y()],g.prototype,"apiKeyProviders",2);m([y()],g.prototype,"apiKeyModalOpen",2);m([y()],g.prototype,"apiKeyBusy",2);m([y()],g.prototype,"apiKeyError",2);m([y()],g.prototype,"apiKeySuccess",2);m([y()],g.prototype,"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,"sessionLogsFull",2);m([y()],g.prototype,"sessionLogsCursors",2);m([y()],g.prototype,"sessionLogsLastFetchAt",2);m([y()],g.prototype,"sessionLogsAtBottom",2);m([y()],g.prototype,"chatUserNearBottom",2);g=m([za("taskmaster-app")],g);
|
|
3007
|
-
//# sourceMappingURL=index-
|
|
3008
|
+
`,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.whatsappActiveQrAccountId=null,this.whatsappPairedPhone=null,this.addingWhatsAppAccount=!1,this.newWhatsAppAccountName="",this.whatsappAccountError=null,this.whatsappAccountSaving=!1,this.whatsappSettingsOpen=!1,this.licenseKey="",this.licenseBusy=!1,this.licenseValid=null,this.licenseMessage=null,this.licenseTier=null,this.licenseDeviceId=null,this.licenseStoredKey=null,this.licenseRemoveConfirm=!1,this.authConnected=null,this.authBusy=!1,this.authMessage=null,this.authUrl=null,this.authCodeInput="",this.authExpiresIn=null,this.setupStep="license",this.gatewayHealthy=null,this.gatewayHealthLoading=!1,this.gatewayHealthMessage=null,this.gatewayRestartBusy=!1,this.updateAvailable=null,this.currentVersion=null,this.latestVersion=null,this.updateChecking=!1,this.updateMessage=null,this.updateProgressSteps=[],this.updateLastResult=null,this.uninstallConfirm=!1,this.uninstallBusy=!1,this.uninstallDone=!1,this.uninstallError=null,this.uninstallConfirmText="",this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...Nv},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.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.customersLoading=!1,this.customersSaving=!1,this.customersRecords=[],this.customersError=null,this.customersSearchQuery="",this.customersEditingId=null,this.customersShowAddForm=!1,this.customersNewPhone="",this.customersNewName="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.infoModalOpen=null,this.workspaces=[],this.workspacesLoading=!1,this.workspacesError=null,this.selectedWorkspace=null,this.addingWorkspace=!1,this.newWorkspaceName="",this.newWorkspacePath="",this.newWorkspacePin="",this.accountPinModalOpen=!1,this.accountPinBusy=!1,this.accountPinError=null,this.accountPinSuccess=null,this.apiKeyProviders=[],this.apiKeyModalOpen=!1,this.apiKeyBusy=!1,this.apiKeyError=null,this.apiKeySuccess=null,this.apiKeySavingProvider=null,this.authApiKeyMode=!1,this.authApiKeyInput="",this.authApiKeyBusy=!1,this.authApiKeyError=null,this.pinChanging=null,this.pinChangeBusy=!1,this.pinChangeError=null,this.loginChangePinMode=!1,this.changePinBusy=!1,this.changePinError=null,this.changePinSuccess=null,this.workspaceSaving=!1,this.workspaceRemoveConfirm=null,this.renamingWorkspace=!1,this.renameWorkspaceName="",this.debugLoading=!1,this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugCallMethod="",this.debugCallParams="{}",this.debugCallResult=null,this.debugCallError=null,this.logsLoading=!1,this.logsError=null,this.logsFile=null,this.logsEntries=[],this.logsFilterText="",this.logsLevelFilters={...Iv},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsSubTab="session",this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsFull=!1,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>Jp(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),ib(this)}firstUpdated(){rb(this)}disconnectedCallback(){ob(this),super.disconnectedCallback()}updated(e){ab(this,e)}connect(){_e(this)}handleChatScroll(e){md(this,e)}handleLogsScroll(e){yd(this,e)}handleSessionLogsScroll(e){vd(this,e)}exportLogs(e,t){wd(e,t)}exportSessionLogs(e,t){kd(e,t)}resetToolStream(){Yi(this)}resetChatScroll(){bd(this)}async loadAssistantIdentity(){await Qc(this)}applySettings(e){Be(this,e)}setTab(e){qp(this,e)}setTheme(e,t){Gp(this,e,t)}async loadOverview(){await Fl(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 fr(this)}async handleAbortChat(){await Wl(this)}removeQueuedMessage(e){sh(this,e)}async handleSendChat(e,t){await ih(this,e,t)}async handleWhatsAppStart(e,t){await cb(this,e,t)}async handleWhatsAppWait(e){await ub(this,e)}async handleWhatsAppLogout(e){await db(this,e)}async handleAddWhatsAppAccount(e){await pb(this,e)}async handleRemoveWhatsAppAccount(e){await hb(this,e)}async handleAccessCheck(){await Ra(this)}async handlePinSubmit(e,t){await sv(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await iv(this,e)}async handleLogout(){await ov(this)}toggleChangePinMode(){this.loginChangePinMode=!this.loginChangePinMode,this.changePinError=null,this.changePinSuccess=null}async handleChangePin(e,t,n){if(this.client){this.changePinBusy=!0,this.changePinError=null,this.changePinSuccess=null;try{const s=await this.client.request("access.verify",{account:e,pin:t});if(!s.ok){this.changePinError=s.message??"Incorrect current PIN",this.changePinBusy=!1;return}e==="__master__"?await this.client.request("access.setMasterPin",{pin:n}):await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.changePinSuccess="PIN changed successfully",this.changePinBusy=!1,setTimeout(()=>{this.loginChangePinMode=!1,this.changePinSuccess=null},2e3)}catch{this.changePinError="Failed to change PIN",this.changePinBusy=!1}}}async handleAccountPinSave(e,t,n){if(this.client){this.accountPinBusy=!0,this.accountPinError=null,this.accountPinSuccess=null;try{if(t!==null){const s=await this.client.request("access.verify",{account:e,pin:t});if(!s.ok){this.accountPinError=s.message??"Incorrect current PIN",this.accountPinBusy=!1;return}}await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.accountPinSuccess="PIN saved",this.accountPinBusy=!1,await Ra(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 Cb(this)}async handleLicenseActivate(){await _b(this)}async handleLicenseRemove(){await Mb(this)}handleLicenseKeyChange(e){Lb(this,e)}async handleAuthStatusCheck(){await xb(this)}async handleAuthStart(){await Ab(this)}async handleAuthSubmitCode(e){await $b(this,e)}handleAuthCodeChange(e){Eb(this,e)}handleSkipToWhatsApp(){Tb(this)}async handleGatewayHealthCheck(){await Pb(this)}async handleGatewayRestart(){await Rb(this)}async handleUpdateCheck(){await Yc(this)}async handleUpdateRun(){await qv(this)}handleUpdateDismissResult(){Qv(this)}handleUninstallConfirm(){this.uninstallConfirm=!0,this.uninstallConfirmText=""}handleUninstallCancel(){this.uninstallConfirm=!1,this.uninstallConfirmText="",this.uninstallError=null}handleUninstallConfirmTextChange(e){this.uninstallConfirmText=e}async handleUninstallRun(){const{runUninstall:e}=await pe(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Co);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){pe(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Co);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await Pl(this)}async clearAudit(){await Cp(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(s=>s.id))??void 0;const t=this.resolveFilesAgentId();pn(this,t),ar(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();pe(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>vv);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin");return t==null?void 0:t.id}resolveFilesAgentId(){var t;const e=this.getSelectedWorkspaceInfo();if(e)return(t=e.agents[0])==null?void 0:t.id}handleChatLoad(){const e=this.resolveAdminAgentId();if(e){const t=`agent:${e}:main`;t!==this.sessionKey&&(this.sessionKey=t,this.chatMessages=[],this.chatStream=null,this.chatRunId=null,this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}pe(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>rd);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this)})}handleAdvancedLoad(){this.loadCron()}async handleChannelConfigSave(){await fb(this)}async handleChannelConfigReload(){await gb(this)}handleNostrProfileEdit(e,t){yb(this,e,t)}handleNostrProfileCancel(){vb(this)}handleNostrProfileFieldChange(e,t){bb(this,e,t)}async handleNostrProfileSave(){await kb(this)}async handleNostrProfileImport(){await Sb(this)}handleNostrProfileToggleAdvanced(){wb(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleAdminsNewPhoneChange(e){this.adminsNewPhone=e,this.adminsError&&(this.adminsError=null)}handleCustomersLoad(){const e=this.selectedWorkspace??void 0;pe(async()=>{const{loadCustomers:t}=await Promise.resolve().then(()=>bv);return{loadCustomers:t}},void 0,import.meta.url).then(({loadCustomers:t})=>{t(this,e)})}handleCustomersNewPhoneChange(e){this.customersNewPhone=e,this.customersError&&(this.customersError=null)}handleCustomersNewNameChange(e){this.customersNewName=e,this.customersError&&(this.customersError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await pe(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>Un);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await pe(async()=>{const{createWorkspace:i}=await Promise.resolve().then(()=>Un);return{createWorkspace:i}},void 0,import.meta.url),{loadChannels:s}=await pe(async()=>{const{loadChannels:i}=await Promise.resolve().then(()=>Pd);return{loadChannels:i}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:i=>{if(!i.whatsappAccountId)return;const r=i.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await s(this,!0),await this.handleWhatsAppStart(!0,r),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(r),await s(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await pe(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>Un);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=(e==null?void 0:e.displayName)??(e==null?void 0:e.name)??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await pe(async()=>{const{renameWorkspace:s}=await Promise.resolve().then(()=>Un);return{renameWorkspace:s}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){this.selectedWorkspace=e,localStorage.setItem("taskmaster-selected-workspace",e),go(e),this.settings=Us(),this.chatMessage="",this.chatAttachments=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.loadAuditEntries(),this.adminsPage?this.handleAdminsLoad():this.customersPage?this.handleCustomersLoad():this.filesPage?this.handleFilesLoad():this.chatPage?this.handleChatLoad():this.advancedPage&&this.handleAdvancedLoad()}initWorkspaceSelection(){if(this.workspaces.length===0)return;const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(s=>s.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}go(this.selectedWorkspace),this.settings=Us(),this.reloadCurrentPageData()}render(){return f`${Lv(this)}${this.auditModalOpen?Rv(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):k}`}};m([y()],g.prototype,"settings",2);m([y()],g.prototype,"password",2);m([y()],g.prototype,"tab",2);m([y()],g.prototype,"onboarding",2);m([y()],g.prototype,"setup",2);m([y()],g.prototype,"filesPage",2);m([y()],g.prototype,"browserPage",2);m([y()],g.prototype,"adminsPage",2);m([y()],g.prototype,"customersPage",2);m([y()],g.prototype,"chatPage",2);m([y()],g.prototype,"advancedPage",2);m([y()],g.prototype,"advancedTab",2);m([y()],g.prototype,"connected",2);m([y()],g.prototype,"accessState",2);m([y()],g.prototype,"theme",2);m([y()],g.prototype,"themeResolved",2);m([y()],g.prototype,"hello",2);m([y()],g.prototype,"lastError",2);m([y()],g.prototype,"eventLog",2);m([y()],g.prototype,"assistantName",2);m([y()],g.prototype,"assistantAvatar",2);m([y()],g.prototype,"assistantAgentId",2);m([y()],g.prototype,"sessionKey",2);m([y()],g.prototype,"chatLoading",2);m([y()],g.prototype,"chatSending",2);m([y()],g.prototype,"chatMessage",2);m([y()],g.prototype,"chatMessages",2);m([y()],g.prototype,"chatToolMessages",2);m([y()],g.prototype,"chatStream",2);m([y()],g.prototype,"chatStreamStartedAt",2);m([y()],g.prototype,"chatRunId",2);m([y()],g.prototype,"compactionStatus",2);m([y()],g.prototype,"chatAvatarUrl",2);m([y()],g.prototype,"chatThinkingLevel",2);m([y()],g.prototype,"chatModelProvider",2);m([y()],g.prototype,"chatModel",2);m([y()],g.prototype,"chatModelCatalog",2);m([y()],g.prototype,"chatVerboseLevel",2);m([y()],g.prototype,"chatFillerEnabled",2);m([y()],g.prototype,"chatQueue",2);m([y()],g.prototype,"chatAttachments",2);m([y()],g.prototype,"sidebarOpen",2);m([y()],g.prototype,"sidebarContent",2);m([y()],g.prototype,"sidebarError",2);m([y()],g.prototype,"splitRatio",2);m([y()],g.prototype,"nodesLoading",2);m([y()],g.prototype,"nodes",2);m([y()],g.prototype,"devicesLoading",2);m([y()],g.prototype,"devicesError",2);m([y()],g.prototype,"devicesList",2);m([y()],g.prototype,"execApprovalsLoading",2);m([y()],g.prototype,"execApprovalsSaving",2);m([y()],g.prototype,"execApprovalsDirty",2);m([y()],g.prototype,"execApprovalsSnapshot",2);m([y()],g.prototype,"execApprovalsForm",2);m([y()],g.prototype,"execApprovalsSelectedAgent",2);m([y()],g.prototype,"execApprovalsTarget",2);m([y()],g.prototype,"execApprovalsTargetNodeId",2);m([y()],g.prototype,"execApprovalQueue",2);m([y()],g.prototype,"execApprovalBusy",2);m([y()],g.prototype,"execApprovalError",2);m([y()],g.prototype,"configLoading",2);m([y()],g.prototype,"configRaw",2);m([y()],g.prototype,"configRawOriginal",2);m([y()],g.prototype,"configValid",2);m([y()],g.prototype,"configIssues",2);m([y()],g.prototype,"configSaving",2);m([y()],g.prototype,"configApplying",2);m([y()],g.prototype,"updateRunning",2);m([y()],g.prototype,"applySessionKey",2);m([y()],g.prototype,"configSnapshot",2);m([y()],g.prototype,"configSchema",2);m([y()],g.prototype,"configSchemaVersion",2);m([y()],g.prototype,"configSchemaLoading",2);m([y()],g.prototype,"configUiHints",2);m([y()],g.prototype,"configForm",2);m([y()],g.prototype,"configFormOriginal",2);m([y()],g.prototype,"configFormDirty",2);m([y()],g.prototype,"configFormMode",2);m([y()],g.prototype,"configSearchQuery",2);m([y()],g.prototype,"configActiveSection",2);m([y()],g.prototype,"configActiveSubsection",2);m([y()],g.prototype,"channelsLoading",2);m([y()],g.prototype,"channelsSnapshot",2);m([y()],g.prototype,"channelsError",2);m([y()],g.prototype,"channelsLastSuccess",2);m([y()],g.prototype,"whatsappLoginMessage",2);m([y()],g.prototype,"whatsappLoginQrDataUrl",2);m([y()],g.prototype,"whatsappLoginConnected",2);m([y()],g.prototype,"whatsappBusy",2);m([y()],g.prototype,"whatsappActiveQrAccountId",2);m([y()],g.prototype,"whatsappPairedPhone",2);m([y()],g.prototype,"addingWhatsAppAccount",2);m([y()],g.prototype,"newWhatsAppAccountName",2);m([y()],g.prototype,"whatsappAccountError",2);m([y()],g.prototype,"whatsappAccountSaving",2);m([y()],g.prototype,"whatsappSettingsOpen",2);m([y()],g.prototype,"licenseKey",2);m([y()],g.prototype,"licenseBusy",2);m([y()],g.prototype,"licenseValid",2);m([y()],g.prototype,"licenseMessage",2);m([y()],g.prototype,"licenseTier",2);m([y()],g.prototype,"licenseDeviceId",2);m([y()],g.prototype,"licenseStoredKey",2);m([y()],g.prototype,"licenseRemoveConfirm",2);m([y()],g.prototype,"authConnected",2);m([y()],g.prototype,"authBusy",2);m([y()],g.prototype,"authMessage",2);m([y()],g.prototype,"authUrl",2);m([y()],g.prototype,"authCodeInput",2);m([y()],g.prototype,"authExpiresIn",2);m([y()],g.prototype,"setupStep",2);m([y()],g.prototype,"gatewayHealthy",2);m([y()],g.prototype,"gatewayHealthLoading",2);m([y()],g.prototype,"gatewayHealthMessage",2);m([y()],g.prototype,"gatewayRestartBusy",2);m([y()],g.prototype,"updateAvailable",2);m([y()],g.prototype,"currentVersion",2);m([y()],g.prototype,"latestVersion",2);m([y()],g.prototype,"updateChecking",2);m([y()],g.prototype,"updateMessage",2);m([y()],g.prototype,"updateProgressSteps",2);m([y()],g.prototype,"updateLastResult",2);m([y()],g.prototype,"uninstallConfirm",2);m([y()],g.prototype,"uninstallBusy",2);m([y()],g.prototype,"uninstallDone",2);m([y()],g.prototype,"uninstallError",2);m([y()],g.prototype,"uninstallConfirmText",2);m([y()],g.prototype,"nostrProfileFormState",2);m([y()],g.prototype,"nostrProfileAccountId",2);m([y()],g.prototype,"presenceLoading",2);m([y()],g.prototype,"presenceEntries",2);m([y()],g.prototype,"presenceError",2);m([y()],g.prototype,"presenceStatus",2);m([y()],g.prototype,"agentsLoading",2);m([y()],g.prototype,"agentsList",2);m([y()],g.prototype,"agentsError",2);m([y()],g.prototype,"sessionsLoading",2);m([y()],g.prototype,"sessionsResult",2);m([y()],g.prototype,"sessionsError",2);m([y()],g.prototype,"cronLoading",2);m([y()],g.prototype,"cronJobs",2);m([y()],g.prototype,"cronStatus",2);m([y()],g.prototype,"cronError",2);m([y()],g.prototype,"cronForm",2);m([y()],g.prototype,"cronRunsJobId",2);m([y()],g.prototype,"cronRuns",2);m([y()],g.prototype,"cronBusy",2);m([y()],g.prototype,"cronNewEventModal",2);m([y()],g.prototype,"cronDetailJobId",2);m([y()],g.prototype,"browserScreencastActive",2);m([y()],g.prototype,"browserScreencastFrame",2);m([y()],g.prototype,"browserScreencastMetadata",2);m([y()],g.prototype,"browserHandoffPending",2);m([y()],g.prototype,"browserHandoffReason",2);m([y()],g.prototype,"browserHandoffId",2);m([y()],g.prototype,"browserInputMode",2);m([y()],g.prototype,"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,"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,"customersLoading",2);m([y()],g.prototype,"customersSaving",2);m([y()],g.prototype,"customersRecords",2);m([y()],g.prototype,"customersError",2);m([y()],g.prototype,"customersSearchQuery",2);m([y()],g.prototype,"customersEditingId",2);m([y()],g.prototype,"customersShowAddForm",2);m([y()],g.prototype,"customersNewPhone",2);m([y()],g.prototype,"customersNewName",2);m([y()],g.prototype,"imessageEnableConfirm",2);m([y()],g.prototype,"imessageEnabling",2);m([y()],g.prototype,"infoModalOpen",2);m([y()],g.prototype,"workspaces",2);m([y()],g.prototype,"workspacesLoading",2);m([y()],g.prototype,"workspacesError",2);m([y()],g.prototype,"selectedWorkspace",2);m([y()],g.prototype,"addingWorkspace",2);m([y()],g.prototype,"newWorkspaceName",2);m([y()],g.prototype,"newWorkspacePath",2);m([y()],g.prototype,"newWorkspacePin",2);m([y()],g.prototype,"accountPinModalOpen",2);m([y()],g.prototype,"accountPinBusy",2);m([y()],g.prototype,"accountPinError",2);m([y()],g.prototype,"accountPinSuccess",2);m([y()],g.prototype,"apiKeyProviders",2);m([y()],g.prototype,"apiKeyModalOpen",2);m([y()],g.prototype,"apiKeyBusy",2);m([y()],g.prototype,"apiKeyError",2);m([y()],g.prototype,"apiKeySuccess",2);m([y()],g.prototype,"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,"sessionLogsFull",2);m([y()],g.prototype,"sessionLogsCursors",2);m([y()],g.prototype,"sessionLogsLastFetchAt",2);m([y()],g.prototype,"sessionLogsAtBottom",2);m([y()],g.prototype,"chatUserNearBottom",2);g=m([qa("taskmaster-app")],g);
|
|
3009
|
+
//# sourceMappingURL=index-DC6oJyqi.js.map
|