@rubytech/taskmaster 1.12.3 → 1.13.0

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.
Files changed (88) hide show
  1. package/dist/agents/auth-profiles/consolidate.js +72 -0
  2. package/dist/agents/auth-profiles/oauth.js +0 -24
  3. package/dist/agents/auth-profiles/paths.js +4 -4
  4. package/dist/agents/auth-profiles/store.js +8 -100
  5. package/dist/agents/model-fallback.js +26 -1
  6. package/dist/agents/pi-embedded-runner/run/payloads.js +8 -0
  7. package/dist/agents/session-transcript-repair.js +3 -2
  8. package/dist/agents/system-prompt.js +1 -0
  9. package/dist/agents/taskmaster-tools.js +2 -0
  10. package/dist/agents/tool-policy.js +2 -0
  11. package/dist/agents/tools/opening-hours-tool.js +92 -0
  12. package/dist/agents/tools/web-fetch.js +8 -3
  13. package/dist/agents/tools/web-search.js +7 -4
  14. package/dist/agents/workspace-migrations.js +47 -0
  15. package/dist/build-info.json +3 -3
  16. package/dist/commands/agents.commands.add.js +1 -32
  17. package/dist/config/defaults.js +1 -1
  18. package/dist/config/legacy.migrations.part-3.js +25 -4
  19. package/dist/config/sessions/transcript.js +31 -0
  20. package/dist/config/types.business.js +1 -0
  21. package/dist/config/zod-schema.js +33 -0
  22. package/dist/control-ui/assets/{index-CpaEIgQy.css → index-B8I8lMfz.css} +1 -1
  23. package/dist/control-ui/assets/{index-CP9IoaZp.js → index-BWqMMgRV.js} +537 -425
  24. package/dist/control-ui/assets/index-BWqMMgRV.js.map +1 -0
  25. package/dist/control-ui/index.html +2 -2
  26. package/dist/gateway/config-reload.js +1 -0
  27. package/dist/gateway/server-close.js +8 -0
  28. package/dist/gateway/server-methods/business.js +31 -0
  29. package/dist/gateway/server-methods/network.js +19 -6
  30. package/dist/gateway/server-methods.js +5 -1
  31. package/dist/gateway/server.impl.js +42 -0
  32. package/dist/infra/heartbeat-infra-alert.js +54 -0
  33. package/dist/memory/manager.js +5 -5
  34. package/dist/web/auto-reply/monitor/process-message.js +24 -0
  35. package/dist/web/inbound/access-control.js +2 -1
  36. package/dist/web/inbound/monitor.js +32 -10
  37. package/dist/web/inbound/owner-mirror.js +35 -0
  38. package/package.json +1 -1
  39. package/skills/anthropic/SKILL.md +30 -0
  40. package/skills/anthropic/references/setup-guide.md +146 -0
  41. package/skills/google-ai/SKILL.md +3 -2
  42. package/skills/google-ai/references/setup-guide.md +94 -0
  43. package/skills/log-review/SKILL.md +45 -0
  44. package/skills/log-review/cron-template.json +21 -0
  45. package/skills/log-review/references/review-protocol.md +65 -0
  46. package/skills/openai/SKILL.md +28 -0
  47. package/skills/openai/references/setup-guide.md +122 -0
  48. package/taskmaster-docs/USER-GUIDE.md +31 -2
  49. package/templates/beagle-taxi/memory/public/investors-knowledge-base.md +230 -0
  50. package/templates/beagle-taxi/skills/beagle-taxi/SKILL.md +3 -1
  51. package/templates/customer/agents/admin/BOOTSTRAP.md +14 -2
  52. package/templates/customer/agents/public/AGENTS.md +15 -0
  53. package/templates/education-hero/agents/admin/BOOTSTRAP.md +14 -2
  54. package/templates/real-agent/agents/admin/AGENTS.md +139 -0
  55. package/templates/real-agent/agents/admin/HEARTBEAT.md +12 -0
  56. package/templates/real-agent/agents/admin/IDENTITY.md +11 -0
  57. package/templates/real-agent/agents/admin/SOUL.md +38 -0
  58. package/templates/real-agent/agents/public/AGENTS.md +183 -0
  59. package/templates/real-agent/agents/public/IDENTITY.md +8 -0
  60. package/templates/real-agent/agents/public/SOUL.md +75 -0
  61. package/templates/real-agent/memory/admin/.gitkeep +0 -0
  62. package/templates/real-agent/memory/public/contributors/adam-mackay.md +7 -0
  63. package/templates/real-agent/memory/public/contributors/alex-pelosi-buchanan.md +7 -0
  64. package/templates/real-agent/memory/public/contributors/jamie-fisher.md +7 -0
  65. package/templates/real-agent/memory/public/contributors/john-savage.md +7 -0
  66. package/templates/real-agent/memory/public/contributors/melanie-attwater.md +7 -0
  67. package/templates/real-agent/memory/public/contributors/regina-mangan.md +7 -0
  68. package/templates/real-agent/memory/public/contributors/richard-rawlings.md +7 -0
  69. package/templates/real-agent/memory/public/contributors/roger-black.md +7 -0
  70. package/templates/real-agent/memory/public/contributors/steve-backley.md +7 -0
  71. package/templates/real-agent/memory/public/courses/agency-blueprint/.gitkeep +0 -0
  72. package/templates/real-agent/memory/public/courses/podcast/.gitkeep +0 -0
  73. package/templates/real-agent/memory/public/courses/real-business/.gitkeep +0 -0
  74. package/templates/real-agent/memory/public/courses/real-coaching/.gitkeep +0 -0
  75. package/templates/real-agent/memory/public/courses/real-marketing/.gitkeep +0 -0
  76. package/templates/real-agent/memory/public/resources/.gitkeep +0 -0
  77. package/templates/real-agent/memory/shared/.gitkeep +0 -0
  78. package/templates/real-agent/memory/users/.gitkeep +0 -0
  79. package/templates/real-agent/skills/bespoke-coaching/SKILL.md +29 -0
  80. package/templates/real-agent/skills/bespoke-coaching/references/coaching-boundaries.md +56 -0
  81. package/templates/real-agent/skills/bespoke-coaching/references/feedback-framework.md +61 -0
  82. package/templates/real-agent/skills/bootstrap/SKILL.md +27 -0
  83. package/templates/real-agent/skills/bootstrap/references/onboarding-flow.md +63 -0
  84. package/templates/real-agent/skills/content-directory/SKILL.md +40 -0
  85. package/templates/real-agent/skills/content-directory/references/module-delivery.md +65 -0
  86. package/templates/real-agent/skills/content-directory/references/progress-tracking.md +47 -0
  87. package/templates/tradesupport/agents/admin/BOOTSTRAP.md +14 -2
  88. package/dist/control-ui/assets/index-CP9IoaZp.js.map +0 -1
@@ -1,23 +1,23 @@
1
- var Bu=Object.defineProperty;var Nu=(e,t,n)=>t in e?Bu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var q=(e,t,n)=>Nu(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const Ou="modulepreload",Fu=function(e,t){return new URL(e,t).href},ir={},le=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let c=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};const a=document.getElementsByTagName("link"),r=document.querySelector("meta[property=csp-nonce]"),l=(r==null?void 0:r.nonce)||(r==null?void 0:r.getAttribute("nonce"));s=c(n.map(h=>{if(h=Fu(h,i),h in ir)return;ir[h]=!0;const d=h.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(i)for(let $=a.length-1;$>=0;$--){const S=a[$];if(S.href===h&&(!d||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${p}`))return;const g=document.createElement("link");if(g.rel=d?"stylesheet":Ou,d||(g.as="script"),g.crossOrigin="",g.href=h,l&&g.setAttribute("nonce",l),document.head.appendChild(g),d)return new Promise(($,S)=>{g.addEventListener("load",$),g.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(a){const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=a,window.dispatchEvent(r),!r.defaultPrevented)throw a}return s.then(a=>{for(const r of a||[])r.status==="rejected"&&o(r.reason);return t().catch(o)})};const Si=globalThis,Ho=Si.ShadowRoot&&(Si.ShadyCSS===void 0||Si.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,jo=Symbol(),sr=new WeakMap;let Rl=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==jo)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(Ho&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=sr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&sr.set(n,t))}return t}toString(){return this.cssText}};const Uu=e=>new Rl(typeof e=="string"?e:e+"",void 0,jo),Wu=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((i,s,o)=>i+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[o+1],e[0]);return new Rl(n,e,jo)},Ku=(e,t)=>{if(Ho)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=Si.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},or=Ho?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return Uu(n)})(e):e;const{is:zu,defineProperty:qu,getOwnPropertyDescriptor:Hu,getOwnPropertyNames:ju,getOwnPropertySymbols:Gu,getPrototypeOf:Vu}=Object,at=globalThis,ar=at.trustedTypes,Qu=ar?ar.emptyScript:"",Ts=at.reactiveElementPolyfillSupport,Cn=(e,t)=>e,Ii={toAttribute(e,t){switch(t){case Boolean:e=e?Qu: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}},Go=(e,t)=>!zu(e,t),rr={attribute:!0,type:String,converter:Ii,reflect:!1,useDefault:!1,hasChanged:Go};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),at.litPropertyMetadata??(at.litPropertyMetadata=new WeakMap);let qt=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=rr){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,n);s!==void 0&&qu(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=Hu(this.prototype,t)??{get(){return this[n]},set(a){this[n]=a}};return{get:s,set(a){const r=s==null?void 0:s.call(this);o==null||o.call(this,a),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??rr}static _$Ei(){if(this.hasOwnProperty(Cn("elementProperties")))return;const t=Vu(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Cn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Cn("properties"))){const n=this.properties,i=[...ju(n),...Gu(n)];for(const s of i)this.createProperty(s,n[s])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[i,s]of n)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[n,i]of this.elementProperties){const s=this._$Eu(n,i);s!==void 0&&this._$Eh.set(s,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)n.unshift(or(s))}else t!==void 0&&n.push(or(t));return n}static _$Eu(t,n){const i=n.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(n=>n(this))}addController(t){var n;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)==null||n.call(t))}removeController(t){var n;(n=this._$EO)==null||n.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const i of n.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Ku(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostConnected)==null?void 0:i.call(n)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostDisconnected)==null?void 0:i.call(n)})}attributeChangedCallback(t,n,i){this._$AK(t,i)}_$ET(t,n){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const a=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Ii).toAttribute(n,i.type);this._$Em=t,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$Em=null}}_$AK(t,n){var o,a;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const r=i.getPropertyOptions(s),l=typeof r.converter=="function"?{fromAttribute:r.converter}:((o=r.converter)==null?void 0:o.fromAttribute)!==void 0?r.converter:Ii;this._$Em=s;const c=l.fromAttribute(n,r.type);this[s]=c??((a=this._$Ej)==null?void 0:a.get(s))??c,this._$Em=null}}requestUpdate(t,n,i,s=!1,o){var a;if(t!==void 0){const r=this.constructor;if(s===!1&&(o=this[t]),i??(i=r.getPropertyOptions(t)),!((i.hasChanged??Go)(o,n)||i.useDefault&&i.reflect&&o===((a=this._$Ej)==null?void 0:a.get(t))&&!this.hasAttribute(r._$Eu(t,i))))return;this.C(t,n,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:i,reflect:s,wrapped:o},a){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,a??n??this[t]),o!==!0||a!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(n=void 0),this._$AL.set(t,n)),s===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,a]of this._$Ep)this[o]=a;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,a]of s){const{wrapped:r}=a,l=this[o];r!==!0||this._$AL.has(o)||l===void 0||this.C(o,void 0,a,l)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),(i=this._$EO)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){var n;(n=this._$EO)==null||n.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(n=>this._$ET(n,this[n]))),this._$EM()}updated(t){}firstUpdated(t){}};qt.elementStyles=[],qt.shadowRootOptions={mode:"open"},qt[Cn("elementProperties")]=new Map,qt[Cn("finalized")]=new Map,Ts==null||Ts({ReactiveElement:qt}),(at.reactiveElementVersions??(at.reactiveElementVersions=[])).push("2.1.2");const En=globalThis,lr=e=>e,Li=En.trustedTypes,cr=Li?Li.createPolicy("lit-html",{createHTML:e=>e}):void 0,Dl="$lit$",ot=`lit$${Math.random().toFixed(9).slice(2)}$`,Bl="?"+ot,Ju=`<${Bl}>`,Ct=document,Fn=()=>Ct.createComment(""),Un=e=>e===null||typeof e!="object"&&typeof e!="function",Vo=Array.isArray,Yu=e=>Vo(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",_s=`[
2
- \f\r]`,hn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,dr=/-->/g,ur=/>/g,ft=RegExp(`>|${_s}(?:([^\\s"'>=/]+)(${_s}*=${_s}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),pr=/'/g,hr=/"/g,Nl=/^(?:script|style|textarea|title)$/i,Xu=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),u=Xu(1),lt=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),fr=new WeakMap,bt=Ct.createTreeWalker(Ct,129);function Ol(e,t){if(!Vo(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return cr!==void 0?cr.createHTML(t):t}const Zu=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",a=hn;for(let r=0;r<n;r++){const l=e[r];let c,h,d=-1,p=0;for(;p<l.length&&(a.lastIndex=p,h=a.exec(l),h!==null);)p=a.lastIndex,a===hn?h[1]==="!--"?a=dr:h[1]!==void 0?a=ur:h[2]!==void 0?(Nl.test(h[2])&&(s=RegExp("</"+h[2],"g")),a=ft):h[3]!==void 0&&(a=ft):a===ft?h[0]===">"?(a=s??hn,d=-1):h[1]===void 0?d=-2:(d=a.lastIndex-h[2].length,c=h[1],a=h[3]===void 0?ft:h[3]==='"'?hr:pr):a===hr||a===pr?a=ft:a===dr||a===ur?a=hn:(a=ft,s=void 0);const g=a===ft&&e[r+1].startsWith("/>")?" ":"";o+=a===hn?l+Ju:d>=0?(i.push(c),l.slice(0,d)+Dl+l.slice(d)+ot+g):l+ot+(d===-2?r:g)}return[Ol(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let mo=class Fl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,a=0;const r=t.length-1,l=this.parts,[c,h]=Zu(t,n);if(this.el=Fl.createElement(c,i),bt.currentNode=this.el.content,n===2||n===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=bt.nextNode())!==null&&l.length<r;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith(Dl)){const p=h[a++],g=s.getAttribute(d).split(ot),$=/([.?@])?(.*)/.exec(p);l.push({type:1,index:o,name:$[2],strings:g,ctor:$[1]==="."?tp:$[1]==="?"?np:$[1]==="@"?ip:ns}),s.removeAttribute(d)}else d.startsWith(ot)&&(l.push({type:6,index:o}),s.removeAttribute(d));if(Nl.test(s.tagName)){const d=s.textContent.split(ot),p=d.length-1;if(p>0){s.textContent=Li?Li.emptyScript:"";for(let g=0;g<p;g++)s.append(d[g],Fn()),bt.nextNode(),l.push({type:2,index:++o});s.append(d[p],Fn())}}}else if(s.nodeType===8)if(s.data===Bl)l.push({type:2,index:o});else{let d=-1;for(;(d=s.data.indexOf(ot,d+1))!==-1;)l.push({type:7,index:o}),d+=ot.length-1}o++}}static createElement(t,n){const i=Ct.createElement("template");return i.innerHTML=t,i}};function Jt(e,t,n=e,i){var a,r;if(t===lt)return t;let s=i!==void 0?(a=n._$Co)==null?void 0:a[i]:n._$Cl;const o=Un(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((r=s==null?void 0:s._$AO)==null||r.call(s,!1),o===void 0?s=void 0:(s=new o(e),s._$AT(e,n,i)),i!==void 0?(n._$Co??(n._$Co=[]))[i]=s:n._$Cl=s),s!==void 0&&(t=Jt(e,s._$AS(e,t.values),s,i)),t}class ep{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??Ct).importNode(n,!0);bt.currentNode=s;let o=bt.nextNode(),a=0,r=0,l=i[0];for(;l!==void 0;){if(a===l.index){let c;l.type===2?c=new ts(o,o.nextSibling,this,t):l.type===1?c=new l.ctor(o,l.name,l.strings,this,t):l.type===6&&(c=new sp(o,this,t)),this._$AV.push(c),l=i[++r]}a!==(l==null?void 0:l.index)&&(o=bt.nextNode(),a++)}return bt.currentNode=Ct,s}p(t){let n=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,n),n+=i.strings.length-2):i._$AI(t[n])),n++}}let ts=class Ul{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,n,i,s){this.type=2,this._$AH=w,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=Jt(this,t,n),Un(t)?t===w||t==null||t===""?(this._$AH!==w&&this._$AR(),this._$AH=w):t!==this._$AH&&t!==lt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Yu(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==w&&Un(this._$AH)?this._$AA.nextSibling.data=t:this.T(Ct.createTextNode(t)),this._$AH=t}$(t){var o;const{values:n,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=mo.createElement(Ol(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(n);else{const a=new ep(s,this),r=a.u(this.options);a.p(n),this.T(r),this._$AH=a}}_$AC(t){let n=fr.get(t.strings);return n===void 0&&fr.set(t.strings,n=new mo(t)),n}k(t){Vo(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let i,s=0;for(const o of t)s===n.length?n.push(i=new Ul(this.O(Fn()),this.O(Fn()),this,this.options)):i=n[s],i._$AI(o),s++;s<n.length&&(this._$AR(i&&i._$AB.nextSibling,s),n.length=s)}_$AR(t=this._$AA.nextSibling,n){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,n);t!==this._$AB;){const s=lr(t).nextSibling;lr(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class ns{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=w,this._$AN=void 0,this.element=t,this.name=n,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=w}_$AI(t,n=this,i,s){const o=this.strings;let a=!1;if(o===void 0)t=Jt(this,t,n,0),a=!Un(t)||t!==this._$AH&&t!==lt,a&&(this._$AH=t);else{const r=t;let l,c;for(t=o[0],l=0;l<o.length-1;l++)c=Jt(this,r[i+l],n,l),c===lt&&(c=this._$AH[l]),a||(a=!Un(c)||c!==this._$AH[l]),c===w?t=w:t!==w&&(t+=(c??"")+o[l+1]),this._$AH[l]=c}a&&!s&&this.j(t)}j(t){t===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let tp=class extends ns{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===w?void 0:t}},np=class extends ns{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==w)}},ip=class extends ns{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=Jt(this,t,n,0)??w)===lt)return;const i=this._$AH,s=t===w&&i!==w||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==w&&(i===w||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,t):this._$AH.handleEvent(t)}},sp=class{constructor(t,n,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Jt(this,t)}};const op={I:ts},Ms=En.litHtmlPolyfillSupport;Ms==null||Ms(mo,ts),(En.litHtmlVersions??(En.litHtmlVersions=[])).push("3.3.2");const ap=(e,t,n)=>{const i=(n==null?void 0:n.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const o=(n==null?void 0:n.renderBefore)??null;i._$litPart$=s=new ts(t.insertBefore(Fn(),o),o,void 0,n??{})}return s._$AI(e),s};const $t=globalThis;let Gt=class extends qt{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=ap(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 lt}};var Ll;Gt._$litElement$=!0,Gt.finalized=!0,(Ll=$t.litElementHydrateSupport)==null||Ll.call($t,{LitElement:Gt});const Ps=$t.litElementPolyfillSupport;Ps==null||Ps({LitElement:Gt});($t.litElementVersions??($t.litElementVersions=[])).push("4.2.2");const Wl=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const rp={attribute:!0,type:String,converter:Ii,reflect:!1,hasChanged:Go},lp=(e=rp,t,n)=>{const{kind:i,metadata:s}=n;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(n.name,e),i==="accessor"){const{name:a}=n;return{set(r){const l=t.get.call(this);t.set.call(this,r),this.requestUpdate(a,l,e,!0,r)},init(r){return r!==void 0&&this.C(a,void 0,e,r),r}}}if(i==="setter"){const{name:a}=n;return function(r){const l=this[a];t.call(this,r),this.requestUpdate(a,l,e,!0,r)}}throw Error("Unsupported decorator location: "+i)};function is(e){return(t,n)=>typeof n=="object"?lp(e,t,n):((i,s,o)=>{const a=s.hasOwnProperty(o);return s.constructor.createProperty(o,i),a?Object.getOwnPropertyDescriptor(s,o):void 0})(e,t,n)}function v(e){return is({...e,state:!0,attribute:!1})}const cp=50,dp=200,up="Assistant";function gr(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function yo(e){const t=gr(e==null?void 0:e.name,cp)??up,n=gr((e==null?void 0:e.avatar)??void 0,dp)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function pp(){return yo(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const hp="Taskmaster",fp="/taskmaster-icon.png",gp="#00d4ff",mp="";let ai=null;function Ye(){return ai||(ai={name:window.__TASKMASTER_BRAND_NAME__||hp,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||fp,accentColor:window.__TASKMASTER_ACCENT_COLOR__||gp,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||mp},ai)}function Be(){return window.__TASKMASTER_WORKSPACE_BRANDS__??{}}function Kl(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);return t?`${parseInt(t[1],16)}, ${parseInt(t[2],16)}, ${parseInt(t[3],16)}`:null}function yp(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!t)return 0;const[n,i,s]=[t[1],t[2],t[3]].map(o=>{const a=parseInt(o,16)/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return .2126*n+.7152*i+.0722*s}function zl(e){const t=Kl(e);if(!t)return;const n=document.documentElement;n.style.setProperty("--accent",e),n.style.setProperty("--accent-hover",e),n.style.setProperty("--accent-muted",e),n.style.setProperty("--primary",e),n.style.setProperty("--ring",e),n.style.setProperty("--accent-subtle",`rgba(${t}, 0.15)`),n.style.setProperty("--accent-glow",`rgba(${t}, 0.25)`),n.style.setProperty("--tasker-orange",e),n.style.setProperty("--tasker-orange-hover",e),n.style.setProperty("--tasker-orange-glow",`rgba(${t}, 0.25)`);const i=yp(e)>.4?"#111111":"#ffffff";n.style.setProperty("--accent-foreground",i),n.style.setProperty("--primary-foreground",i)}function ri(e,t,n){const i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e),s=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!i||!s)return e;const o=(c,h)=>Math.round(parseInt(i[c],16)*(1-n)+parseInt(s[h],16)*n),a=o(1,1),r=o(2,2),l=o(3,3);return`#${a.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`}const fn={"--bg":"#12141a","--bg-muted":"#262a35","--card":"#181b22","--secondary":"#1e2028"};function ql(e){const t=document.documentElement;if(!e){for(const[i,s]of Object.entries(fn))t.style.setProperty(i,s);t.style.removeProperty("--brand-bg"),t.style.removeProperty("--brand-bg-subtle"),t.style.removeProperty("--brand-bg-card");return}const n=Kl(e);n&&(t.style.setProperty("--bg",ri(fn["--bg"],e,.08)),t.style.setProperty("--bg-muted",ri(fn["--bg-muted"],e,.1)),t.style.setProperty("--card",ri(fn["--card"],e,.12)),t.style.setProperty("--secondary",ri(fn["--secondary"],e,.1)),t.style.setProperty("--brand-bg",e),t.style.setProperty("--brand-bg-subtle",`rgba(${n}, 0.08)`),t.style.setProperty("--brand-bg-card",`rgba(${n}, 0.12)`))}function Tn(e){const t=Ye(),n=Be(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;zl(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;ql(o)}const Ri="taskmaster.control.settings.v1",Hl="taskmaster.account.settings.";function _n(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const Kt={gatewayUrl:_n(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},it={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function vp(){try{const e=localStorage.getItem(Ri);if(!e)return{...Kt,gatewayUrl:_n()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():_n(),token:typeof t.token=="string"?t.token:Kt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:Kt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:Kt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:Kt.navGroupsCollapsed}}catch{return{...Kt,gatewayUrl:_n()}}}function bp(e){if(!e)return{...it};try{const t=localStorage.getItem(Hl+e);if(!t)return{...it};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():it.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||it.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:it.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:it.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:it.splitRatio}}catch{return{...it}}}let Di=null;function mr(e){Di=e}function Is(){return{...vp(),...bp(Di)}}function wp(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Ri,JSON.stringify(t)),Di){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Hl+Di,JSON.stringify(n))}}const kp="taskmaster.draft.";function Qo(e,t){return kp+e+"."+t}function Wn(e,t,n){try{const i=Qo(e,t);n?localStorage.setItem(i,n):localStorage.removeItem(i)}catch{}}function Kn(e,t){try{return localStorage.getItem(Qo(e,t))??""}catch{return""}}function xp(e,t){try{localStorage.removeItem(Qo(e,t))}catch{}}let wt=null,Se=null;function yr(e,t,n){Se={workspace:e,sessionKey:t,text:n},wt!=null&&clearTimeout(wt),wt=setTimeout(()=>{Se&&Wn(Se.workspace,Se.sessionKey,Se.text),Se=null,wt=null},300)}function vo(){wt!=null&&clearTimeout(wt),wt=null,Se&&(Wn(Se.workspace,Se.sessionKey,Se.text),Se=null)}(function(){try{const t=localStorage.getItem(Ri);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:_n(),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(Ri,JSON.stringify(i))}catch{}})();function jl(e){var o;const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const i=(o=n[1])==null?void 0:o.trim(),s=n.slice(2).join(":");return!i||!s?null:{agentId:i,rest:s}}const $p=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,li=/<\s*\/?\s*final\b[^>]*>/gi,vr=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Sp(e,t){return e.trimStart()}function Ap(e,t){if(!e||!$p.test(e))return e;let n=e;li.test(n)?(li.lastIndex=0,n=n.replace(li,"")):li.lastIndex=0,vr.lastIndex=0;let i="",s=0,o=!1;for(const a of n.matchAll(vr)){const r=a.index??0,l=a[1]==="/";o?l&&(o=!1):(i+=n.slice(s,r),l||(o=!0)),s=r+a[0].length}return i+=n.slice(s),Sp(i)}function Gl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function ss(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const a=-t,r=Math.round(a/1e3);if(r<60)return`in ${r}s`;const l=Math.round(r/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 i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<48?`${s}h ago`:`${Math.round(s/24)}d ago`}function Jo(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const i=Math.round(n/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function Cp(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Vl(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 Bi(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Ls(e){return Ap(e)}const Ep=/^\[([^\]]+)\]\s*/,Tp=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Rs=new WeakMap,Ds=new WeakMap;function _p(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:Tp.some(t=>e.startsWith(`${t} `))}function Bs(e){const t=e.match(Ep);if(!t)return e;const n=t[1]??"";return _p(n)?e.slice(t[0].length):e}function Mn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?Ls(i):Bs(i);if(Array.isArray(i)){const s=i.map(o=>{const a=o;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(o=>typeof o=="string");if(s.length>0){const o=s.join(`
4
- `);return n==="assistant"?Ls(o):Bs(o)}}return typeof t.text=="string"?n==="assistant"?Ls(t.text):Bs(t.text):null}function Ql(e){if(!e||typeof e!="object")return Mn(e);const t=e;if(Rs.has(t))return Rs.get(t)??null;const n=Mn(e);return Rs.set(t,n),n}function br(e){const n=e.content,i=[];if(Array.isArray(n))for(const r of n){const l=r;if(l.type==="thinking"&&typeof l.thinking=="string"){const c=l.thinking.trim();c&&i.push(c)}}if(i.length>0)return i.join(`
5
- `);const s=Pp(e);if(!s)return null;const a=[...s.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(r=>(r[1]??"").trim()).filter(Boolean);return a.length>0?a.join(`
6
- `):null}function Mp(e){if(!e||typeof e!="object")return br(e);const t=e;if(Ds.has(t))return Ds.get(t)??null;const n=br(e);return Ds.set(t,n),n}function Pp(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const i=n.map(s=>{const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>typeof s=="string");if(i.length>0)return i.join(`
7
- `)}return typeof t.text=="string"?t.text:null}function Ip(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean).map(i=>`_${i}_`);return n.length?["_Reasoning:_",...n].join(`
8
- `):""}const Lp=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Rp=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Dp=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Bp=/^A new session was started via \/new or \/reset\./;function Np(e){const t=e,n=typeof t.role=="string"?t.role:"";let i="";typeof t.content=="string"?i=t.content:Array.isArray(t.content)?i=t.content.filter(o=>typeof o=="object"&&o!==null).map(o=>o.text??"").join(" "):typeof t.text=="string"&&(i=t.text);const s=i.trim();return s?!!(n==="user"&&Lp.test(s)||n==="assistant"&&Rp.test(s)||n==="user"&&Bp.test(s)||n==="assistant"&&Dp.test(s)):!1}function Jl(e){return e.filter(t=>!Np(t))}function Yl(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const i=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",s=t.content,o=Array.isArray(s)?s:null,a=Array.isArray(o)&&o.some(d=>{const g=String(d.type??"").toLowerCase();return g==="toolresult"||g==="tool_result"}),r=typeof t.toolName=="string"||typeof t.tool_name=="string";(i||a||r)&&(n="toolResult");let l=[];typeof t.content=="string"?l=[{type:"text",text:t.content}]:Array.isArray(t.content)?l=t.content.map(d=>({type:d.type||"text",text:d.text,name:d.name,args:d.args||d.arguments})):typeof t.text=="string"&&(l=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),h=typeof t.id=="string"?t.id:void 0;return{role:n,content:l,timestamp:c,id:h}}function Xl(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 Zl(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function wr(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,"0");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Op(){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 os(e=globalThis.crypto){if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),wr(t)}return wr(Op())}const Fe=50;async function Oe(e,t){if(!e.client||!e.connected)return;e.chatLoading=!0,e.lastError=null;const n=(t==null?void 0:t.limit)??Fe;try{const i=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:n}),s=Array.isArray(i.messages)?i.messages:[],o=typeof i.totalMessages=="number"?i.totalMessages:s.length,a=Jl(s);e.chatMessages=a,e.chatHistoryTotal=o,e.chatHistoryHasMore=o>s.length,e.chatThinkingLevel=i.thinkingLevel??null,e.chatModelProvider=typeof i.modelProvider=="string"?i.modelProvider:null,e.chatModel=typeof i.model=="string"?i.model:null,e.chatVerboseLevel=typeof i.verboseLevel=="string"?i.verboseLevel:null,e.chatFillerEnabled=typeof i.fillerEnabled=="boolean"?i.fillerEnabled:null}catch(i){e.lastError=String(i)}finally{e.chatLoading=!1}}async function Fp(e){if(!e.client||!e.connected||e.chatLoadingOlder||!e.chatHistoryHasMore)return!1;e.chatLoadingOlder=!0;try{const t=e.chatMessages.length,n=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:Fe,offset:t}),i=Array.isArray(n.messages)?n.messages:[],s=typeof n.totalMessages=="number"?n.totalMessages:0;if(i.length===0)return e.chatHistoryHasMore=!1,!1;const o=Jl(i);return e.chatMessages=[...o,...e.chatMessages],e.chatHistoryTotal=s,e.chatHistoryHasMore=s>t+i.length,!0}catch(t){return e.lastError=String(t),!1}finally{e.chatLoadingOlder=!1}}function Up(e){const t=/^data:(.+?);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function ec(e,t,n){if(e.chatSuggestions=[],!e.client||!e.connected)return!1;const i=t.trim(),s=n&&n.length>0;if(!i&&!s)return!1;const o=Date.now(),a=(n??[]).filter(g=>!g.fileName),r=(n??[]).filter(g=>g.fileName),l=[],c=r.map(g=>g.fileName).filter(Boolean);if(c.length>0){const g=i?`${c.join(", ")}
1
+ var Ku=Object.defineProperty;var zu=(e,t,n)=>t in e?Ku(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var H=(e,t,n)=>zu(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const Hu="modulepreload",qu=function(e,t){return new URL(e,t).href},ar={},ae=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let d=function(h){return Promise.all(h.map(l=>Promise.resolve(l).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};const a=document.getElementsByTagName("link"),r=document.querySelector("meta[property=csp-nonce]"),c=(r==null?void 0:r.nonce)||(r==null?void 0:r.getAttribute("nonce"));s=d(n.map(h=>{if(h=qu(h,i),h in ar)return;ar[h]=!0;const l=h.endsWith(".css"),p=l?'[rel="stylesheet"]':"";if(i)for(let $=a.length-1;$>=0;$--){const S=a[$];if(S.href===h&&(!l||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${p}`))return;const g=document.createElement("link");if(g.rel=l?"stylesheet":Hu,l||(g.as="script"),g.crossOrigin="",g.href=h,c&&g.setAttribute("nonce",c),document.head.appendChild(g),l)return new Promise(($,S)=>{g.addEventListener("load",$),g.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(a){const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=a,window.dispatchEvent(r),!r.defaultPrevented)throw a}return s.then(a=>{for(const r of a||[])r.status==="rejected"&&o(r.reason);return t().catch(o)})};const Ai=globalThis,jo=Ai.ShadowRoot&&(Ai.ShadyCSS===void 0||Ai.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Go=Symbol(),rr=new WeakMap;let Ol=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==Go)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(jo&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=rr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&rr.set(n,t))}return t}toString(){return this.cssText}};const ju=e=>new Ol(typeof e=="string"?e:e+"",void 0,Go),Gu=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((i,s,o)=>i+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[o+1],e[0]);return new Ol(n,e,Go)},Vu=(e,t)=>{if(jo)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=Ai.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},lr=jo?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return ju(n)})(e):e;const{is:Qu,defineProperty:Ju,getOwnPropertyDescriptor:Yu,getOwnPropertyNames:Xu,getOwnPropertySymbols:Zu,getPrototypeOf:ep}=Object,at=globalThis,cr=at.trustedTypes,tp=cr?cr.emptyScript:"",_s=at.reactiveElementPolyfillSupport,Cn=(e,t)=>e,Li={toAttribute(e,t){switch(t){case Boolean:e=e?tp:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},Vo=(e,t)=>!Qu(e,t),dr={attribute:!0,type:String,converter:Li,reflect:!1,useDefault:!1,hasChanged:Vo};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),at.litPropertyMetadata??(at.litPropertyMetadata=new WeakMap);let Ht=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=dr){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,n);s!==void 0&&Ju(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=Yu(this.prototype,t)??{get(){return this[n]},set(a){this[n]=a}};return{get:s,set(a){const r=s==null?void 0:s.call(this);o==null||o.call(this,a),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??dr}static _$Ei(){if(this.hasOwnProperty(Cn("elementProperties")))return;const t=ep(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Cn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Cn("properties"))){const n=this.properties,i=[...Xu(n),...Zu(n)];for(const s of i)this.createProperty(s,n[s])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[i,s]of n)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[n,i]of this.elementProperties){const s=this._$Eu(n,i);s!==void 0&&this._$Eh.set(s,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)n.unshift(lr(s))}else t!==void 0&&n.push(lr(t));return n}static _$Eu(t,n){const i=n.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(n=>n(this))}addController(t){var n;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)==null||n.call(t))}removeController(t){var n;(n=this._$EO)==null||n.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const i of n.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Vu(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostConnected)==null?void 0:i.call(n)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostDisconnected)==null?void 0:i.call(n)})}attributeChangedCallback(t,n,i){this._$AK(t,i)}_$ET(t,n){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const a=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Li).toAttribute(n,i.type);this._$Em=t,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$Em=null}}_$AK(t,n){var o,a;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const r=i.getPropertyOptions(s),c=typeof r.converter=="function"?{fromAttribute:r.converter}:((o=r.converter)==null?void 0:o.fromAttribute)!==void 0?r.converter:Li;this._$Em=s;const d=c.fromAttribute(n,r.type);this[s]=d??((a=this._$Ej)==null?void 0:a.get(s))??d,this._$Em=null}}requestUpdate(t,n,i,s=!1,o){var a;if(t!==void 0){const r=this.constructor;if(s===!1&&(o=this[t]),i??(i=r.getPropertyOptions(t)),!((i.hasChanged??Vo)(o,n)||i.useDefault&&i.reflect&&o===((a=this._$Ej)==null?void 0:a.get(t))&&!this.hasAttribute(r._$Eu(t,i))))return;this.C(t,n,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:i,reflect:s,wrapped:o},a){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,a??n??this[t]),o!==!0||a!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(n=void 0),this._$AL.set(t,n)),s===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,a]of this._$Ep)this[o]=a;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,a]of s){const{wrapped:r}=a,c=this[o];r!==!0||this._$AL.has(o)||c===void 0||this.C(o,void 0,a,c)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),(i=this._$EO)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){var n;(n=this._$EO)==null||n.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(n=>this._$ET(n,this[n]))),this._$EM()}updated(t){}firstUpdated(t){}};Ht.elementStyles=[],Ht.shadowRootOptions={mode:"open"},Ht[Cn("elementProperties")]=new Map,Ht[Cn("finalized")]=new Map,_s==null||_s({ReactiveElement:Ht}),(at.reactiveElementVersions??(at.reactiveElementVersions=[])).push("2.1.2");const En=globalThis,ur=e=>e,Ri=En.trustedTypes,pr=Ri?Ri.createPolicy("lit-html",{createHTML:e=>e}):void 0,Fl="$lit$",ot=`lit$${Math.random().toFixed(9).slice(2)}$`,Ul="?"+ot,np=`<${Ul}>`,Ct=document,Fn=()=>Ct.createComment(""),Un=e=>e===null||typeof e!="object"&&typeof e!="function",Qo=Array.isArray,ip=e=>Qo(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",Ms=`[
2
+ \f\r]`,hn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,hr=/-->/g,fr=/>/g,ft=RegExp(`>|${Ms}(?:([^\\s"'>=/]+)(${Ms}*=${Ms}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),gr=/'/g,mr=/"/g,Wl=/^(?:script|style|textarea|title)$/i,sp=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),u=sp(1),lt=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),yr=new WeakMap,bt=Ct.createTreeWalker(Ct,129);function Kl(e,t){if(!Qo(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return pr!==void 0?pr.createHTML(t):t}const op=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",a=hn;for(let r=0;r<n;r++){const c=e[r];let d,h,l=-1,p=0;for(;p<c.length&&(a.lastIndex=p,h=a.exec(c),h!==null);)p=a.lastIndex,a===hn?h[1]==="!--"?a=hr:h[1]!==void 0?a=fr:h[2]!==void 0?(Wl.test(h[2])&&(s=RegExp("</"+h[2],"g")),a=ft):h[3]!==void 0&&(a=ft):a===ft?h[0]===">"?(a=s??hn,l=-1):h[1]===void 0?l=-2:(l=a.lastIndex-h[2].length,d=h[1],a=h[3]===void 0?ft:h[3]==='"'?mr:gr):a===mr||a===gr?a=ft:a===hr||a===fr?a=hn:(a=ft,s=void 0);const g=a===ft&&e[r+1].startsWith("/>")?" ":"";o+=a===hn?c+np:l>=0?(i.push(d),c.slice(0,l)+Fl+c.slice(l)+ot+g):c+ot+(l===-2?r:g)}return[Kl(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let yo=class zl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,a=0;const r=t.length-1,c=this.parts,[d,h]=op(t,n);if(this.el=zl.createElement(d,i),bt.currentNode=this.el.content,n===2||n===3){const l=this.el.content.firstChild;l.replaceWith(...l.childNodes)}for(;(s=bt.nextNode())!==null&&c.length<r;){if(s.nodeType===1){if(s.hasAttributes())for(const l of s.getAttributeNames())if(l.endsWith(Fl)){const p=h[a++],g=s.getAttribute(l).split(ot),$=/([.?@])?(.*)/.exec(p);c.push({type:1,index:o,name:$[2],strings:g,ctor:$[1]==="."?rp:$[1]==="?"?lp:$[1]==="@"?cp:is}),s.removeAttribute(l)}else l.startsWith(ot)&&(c.push({type:6,index:o}),s.removeAttribute(l));if(Wl.test(s.tagName)){const l=s.textContent.split(ot),p=l.length-1;if(p>0){s.textContent=Ri?Ri.emptyScript:"";for(let g=0;g<p;g++)s.append(l[g],Fn()),bt.nextNode(),c.push({type:2,index:++o});s.append(l[p],Fn())}}}else if(s.nodeType===8)if(s.data===Ul)c.push({type:2,index:o});else{let l=-1;for(;(l=s.data.indexOf(ot,l+1))!==-1;)c.push({type:7,index:o}),l+=ot.length-1}o++}}static createElement(t,n){const i=Ct.createElement("template");return i.innerHTML=t,i}};function Jt(e,t,n=e,i){var a,r;if(t===lt)return t;let s=i!==void 0?(a=n._$Co)==null?void 0:a[i]:n._$Cl;const o=Un(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((r=s==null?void 0:s._$AO)==null||r.call(s,!1),o===void 0?s=void 0:(s=new o(e),s._$AT(e,n,i)),i!==void 0?(n._$Co??(n._$Co=[]))[i]=s:n._$Cl=s),s!==void 0&&(t=Jt(e,s._$AS(e,t.values),s,i)),t}class ap{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??Ct).importNode(n,!0);bt.currentNode=s;let o=bt.nextNode(),a=0,r=0,c=i[0];for(;c!==void 0;){if(a===c.index){let d;c.type===2?d=new ns(o,o.nextSibling,this,t):c.type===1?d=new c.ctor(o,c.name,c.strings,this,t):c.type===6&&(d=new dp(o,this,t)),this._$AV.push(d),c=i[++r]}a!==(c==null?void 0:c.index)&&(o=bt.nextNode(),a++)}return bt.currentNode=Ct,s}p(t){let n=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,n),n+=i.strings.length-2):i._$AI(t[n])),n++}}let ns=class Hl{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,n,i,s){this.type=2,this._$AH=w,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=Jt(this,t,n),Un(t)?t===w||t==null||t===""?(this._$AH!==w&&this._$AR(),this._$AH=w):t!==this._$AH&&t!==lt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):ip(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!==w&&Un(this._$AH)?this._$AA.nextSibling.data=t:this.T(Ct.createTextNode(t)),this._$AH=t}$(t){var o;const{values:n,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=yo.createElement(Kl(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(n);else{const a=new ap(s,this),r=a.u(this.options);a.p(n),this.T(r),this._$AH=a}}_$AC(t){let n=yr.get(t.strings);return n===void 0&&yr.set(t.strings,n=new yo(t)),n}k(t){Qo(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let i,s=0;for(const o of t)s===n.length?n.push(i=new Hl(this.O(Fn()),this.O(Fn()),this,this.options)):i=n[s],i._$AI(o),s++;s<n.length&&(this._$AR(i&&i._$AB.nextSibling,s),n.length=s)}_$AR(t=this._$AA.nextSibling,n){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,n);t!==this._$AB;){const s=ur(t).nextSibling;ur(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class is{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=w,this._$AN=void 0,this.element=t,this.name=n,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=w}_$AI(t,n=this,i,s){const o=this.strings;let a=!1;if(o===void 0)t=Jt(this,t,n,0),a=!Un(t)||t!==this._$AH&&t!==lt,a&&(this._$AH=t);else{const r=t;let c,d;for(t=o[0],c=0;c<o.length-1;c++)d=Jt(this,r[i+c],n,c),d===lt&&(d=this._$AH[c]),a||(a=!Un(d)||d!==this._$AH[c]),d===w?t=w:t!==w&&(t+=(d??"")+o[c+1]),this._$AH[c]=d}a&&!s&&this.j(t)}j(t){t===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let rp=class extends is{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===w?void 0:t}},lp=class extends is{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==w)}},cp=class extends is{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=Jt(this,t,n,0)??w)===lt)return;const i=this._$AH,s=t===w&&i!==w||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==w&&(i===w||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,t):this._$AH.handleEvent(t)}},dp=class{constructor(t,n,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Jt(this,t)}};const up={I:ns},Ps=En.litHtmlPolyfillSupport;Ps==null||Ps(yo,ns),(En.litHtmlVersions??(En.litHtmlVersions=[])).push("3.3.2");const pp=(e,t,n)=>{const i=(n==null?void 0:n.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const o=(n==null?void 0:n.renderBefore)??null;i._$litPart$=s=new ns(t.insertBefore(Fn(),o),o,void 0,n??{})}return s._$AI(e),s};const $t=globalThis;let Gt=class extends Ht{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=pp(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 lt}};var Nl;Gt._$litElement$=!0,Gt.finalized=!0,(Nl=$t.litElementHydrateSupport)==null||Nl.call($t,{LitElement:Gt});const Is=$t.litElementPolyfillSupport;Is==null||Is({LitElement:Gt});($t.litElementVersions??($t.litElementVersions=[])).push("4.2.2");const ql=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const hp={attribute:!0,type:String,converter:Li,reflect:!1,hasChanged:Vo},fp=(e=hp,t,n)=>{const{kind:i,metadata:s}=n;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(n.name,e),i==="accessor"){const{name:a}=n;return{set(r){const c=t.get.call(this);t.set.call(this,r),this.requestUpdate(a,c,e,!0,r)},init(r){return r!==void 0&&this.C(a,void 0,e,r),r}}}if(i==="setter"){const{name:a}=n;return function(r){const c=this[a];t.call(this,r),this.requestUpdate(a,c,e,!0,r)}}throw Error("Unsupported decorator location: "+i)};function ss(e){return(t,n)=>typeof n=="object"?fp(e,t,n):((i,s,o)=>{const a=s.hasOwnProperty(o);return s.constructor.createProperty(o,i),a?Object.getOwnPropertyDescriptor(s,o):void 0})(e,t,n)}function v(e){return ss({...e,state:!0,attribute:!1})}const gp=50,mp=200,yp="Assistant";function vr(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function vo(e){const t=vr(e==null?void 0:e.name,gp)??yp,n=vr((e==null?void 0:e.avatar)??void 0,mp)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function vp(){return vo(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const bp="Taskmaster",wp="/taskmaster-icon.png",kp="#00d4ff",xp="";let ai=null;function Ye(){return ai||(ai={name:window.__TASKMASTER_BRAND_NAME__||bp,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||wp,accentColor:window.__TASKMASTER_ACCENT_COLOR__||kp,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||xp},ai)}function Be(){return window.__TASKMASTER_WORKSPACE_BRANDS__??{}}function jl(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 $p(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!t)return 0;const[n,i,s]=[t[1],t[2],t[3]].map(o=>{const a=parseInt(o,16)/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return .2126*n+.7152*i+.0722*s}function Gl(e){const t=jl(e);if(!t)return;const n=document.documentElement;n.style.setProperty("--accent",e),n.style.setProperty("--accent-hover",e),n.style.setProperty("--accent-muted",e),n.style.setProperty("--primary",e),n.style.setProperty("--ring",e),n.style.setProperty("--accent-subtle",`rgba(${t}, 0.15)`),n.style.setProperty("--accent-glow",`rgba(${t}, 0.25)`),n.style.setProperty("--tasker-orange",e),n.style.setProperty("--tasker-orange-hover",e),n.style.setProperty("--tasker-orange-glow",`rgba(${t}, 0.25)`);const i=$p(e)>.4?"#111111":"#ffffff";n.style.setProperty("--accent-foreground",i),n.style.setProperty("--primary-foreground",i)}function ri(e,t,n){const i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e),s=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!i||!s)return e;const o=(d,h)=>Math.round(parseInt(i[d],16)*(1-n)+parseInt(s[h],16)*n),a=o(1,1),r=o(2,2),c=o(3,3);return`#${a.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}`}const fn={"--bg":"#12141a","--bg-muted":"#262a35","--card":"#181b22","--secondary":"#1e2028"};function Vl(e){const t=document.documentElement;if(!e){for(const[i,s]of Object.entries(fn))t.style.setProperty(i,s);t.style.removeProperty("--brand-bg"),t.style.removeProperty("--brand-bg-subtle"),t.style.removeProperty("--brand-bg-card");return}const n=jl(e);n&&(t.style.setProperty("--bg",ri(fn["--bg"],e,.08)),t.style.setProperty("--bg-muted",ri(fn["--bg-muted"],e,.1)),t.style.setProperty("--card",ri(fn["--card"],e,.12)),t.style.setProperty("--secondary",ri(fn["--secondary"],e,.1)),t.style.setProperty("--brand-bg",e),t.style.setProperty("--brand-bg-subtle",`rgba(${n}, 0.08)`),t.style.setProperty("--brand-bg-card",`rgba(${n}, 0.12)`))}function Tn(e){const t=Ye(),n=Be(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;Gl(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;Vl(o)}const Di="taskmaster.control.settings.v1",Ql="taskmaster.account.settings.";function _n(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const Kt={gatewayUrl:_n(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},it={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function Sp(){try{const e=localStorage.getItem(Di);if(!e)return{...Kt,gatewayUrl:_n()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():_n(),token:typeof t.token=="string"?t.token:Kt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:Kt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:Kt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:Kt.navGroupsCollapsed}}catch{return{...Kt,gatewayUrl:_n()}}}function Ap(e){if(!e)return{...it};try{const t=localStorage.getItem(Ql+e);if(!t)return{...it};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():it.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||it.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:it.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:it.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:it.splitRatio}}catch{return{...it}}}let Bi=null;function br(e){Bi=e}function Ls(){return{...Sp(),...Ap(Bi)}}function Cp(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Di,JSON.stringify(t)),Bi){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Ql+Bi,JSON.stringify(n))}}const Ep="taskmaster.draft.";function Jo(e,t){return Ep+e+"."+t}function Wn(e,t,n){try{const i=Jo(e,t);n?localStorage.setItem(i,n):localStorage.removeItem(i)}catch{}}function Kn(e,t){try{return localStorage.getItem(Jo(e,t))??""}catch{return""}}function Tp(e,t){try{localStorage.removeItem(Jo(e,t))}catch{}}let wt=null,Se=null;function wr(e,t,n){Se={workspace:e,sessionKey:t,text:n},wt!=null&&clearTimeout(wt),wt=setTimeout(()=>{Se&&Wn(Se.workspace,Se.sessionKey,Se.text),Se=null,wt=null},300)}function bo(){wt!=null&&clearTimeout(wt),wt=null,Se&&(Wn(Se.workspace,Se.sessionKey,Se.text),Se=null)}(function(){try{const t=localStorage.getItem(Di);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:_n(),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(Di,JSON.stringify(i))}catch{}})();function Jl(e){var o;const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const i=(o=n[1])==null?void 0:o.trim(),s=n.slice(2).join(":");return!i||!s?null:{agentId:i,rest:s}}const _p=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,li=/<\s*\/?\s*final\b[^>]*>/gi,kr=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Mp(e,t){return e.trimStart()}function Pp(e,t){if(!e||!_p.test(e))return e;let n=e;li.test(n)?(li.lastIndex=0,n=n.replace(li,"")):li.lastIndex=0,kr.lastIndex=0;let i="",s=0,o=!1;for(const a of n.matchAll(kr)){const r=a.index??0,c=a[1]==="/";o?c&&(o=!1):(i+=n.slice(s,r),c||(o=!0)),s=r+a[0].length}return i+=n.slice(s),Mp(i)}function Yl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function os(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const a=-t,r=Math.round(a/1e3);if(r<60)return`in ${r}s`;const c=Math.round(r/60);if(c<60)return`in ${c}m`;const d=Math.round(c/60);return d<48?`in ${d}h`:`in ${Math.round(d/24)}d`}const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<48?`${s}h ago`:`${Math.round(s/24)}d ago`}function Yo(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const i=Math.round(n/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function Ip(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Xl(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 Ni(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Rs(e){return Pp(e)}const Lp=/^\[([^\]]+)\]\s*/,Rp=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Ds=new WeakMap,Bs=new WeakMap;function Dp(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:Rp.some(t=>e.startsWith(`${t} `))}function Ns(e){const t=e.match(Lp);if(!t)return e;const n=t[1]??"";return Dp(n)?e.slice(t[0].length):e}function Mn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?Rs(i):Ns(i);if(Array.isArray(i)){const s=i.map(o=>{const a=o;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(o=>typeof o=="string");if(s.length>0){const o=s.join(`
4
+ `);return n==="assistant"?Rs(o):Ns(o)}}return typeof t.text=="string"?n==="assistant"?Rs(t.text):Ns(t.text):null}function Zl(e){if(!e||typeof e!="object")return Mn(e);const t=e;if(Ds.has(t))return Ds.get(t)??null;const n=Mn(e);return Ds.set(t,n),n}function xr(e){const n=e.content,i=[];if(Array.isArray(n))for(const r of n){const c=r;if(c.type==="thinking"&&typeof c.thinking=="string"){const d=c.thinking.trim();d&&i.push(d)}}if(i.length>0)return i.join(`
5
+ `);const s=Np(e);if(!s)return null;const a=[...s.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(r=>(r[1]??"").trim()).filter(Boolean);return a.length>0?a.join(`
6
+ `):null}function Bp(e){if(!e||typeof e!="object")return xr(e);const t=e;if(Bs.has(t))return Bs.get(t)??null;const n=xr(e);return Bs.set(t,n),n}function Np(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const i=n.map(s=>{const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>typeof s=="string");if(i.length>0)return i.join(`
7
+ `)}return typeof t.text=="string"?t.text:null}function Op(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean).map(i=>`_${i}_`);return n.length?["_Reasoning:_",...n].join(`
8
+ `):""}const Fp=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Up=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Wp=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Kp=/^A new session was started via \/new or \/reset\./;function zp(e){const t=e,n=typeof t.role=="string"?t.role:"";let i="";typeof t.content=="string"?i=t.content:Array.isArray(t.content)?i=t.content.filter(o=>typeof o=="object"&&o!==null).map(o=>o.text??"").join(" "):typeof t.text=="string"&&(i=t.text);const s=i.trim();return s?!!(n==="user"&&Fp.test(s)||n==="assistant"&&Up.test(s)||n==="user"&&Kp.test(s)||n==="assistant"&&Wp.test(s)):!1}function ec(e){return e.filter(t=>!zp(t))}function tc(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const i=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",s=t.content,o=Array.isArray(s)?s:null,a=Array.isArray(o)&&o.some(l=>{const g=String(l.type??"").toLowerCase();return g==="toolresult"||g==="tool_result"}),r=typeof t.toolName=="string"||typeof t.tool_name=="string";(i||a||r)&&(n="toolResult");let c=[];typeof t.content=="string"?c=[{type:"text",text:t.content}]:Array.isArray(t.content)?c=t.content.map(l=>({type:l.type||"text",text:l.text,name:l.name,args:l.args||l.arguments})):typeof t.text=="string"&&(c=[{type:"text",text:t.text}]);const d=typeof t.timestamp=="number"?t.timestamp:Date.now(),h=typeof t.id=="string"?t.id:void 0;return{role:n,content:c,timestamp:d,id:h}}function nc(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 ic(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function $r(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 Hp(){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 as(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),$r(t)}return $r(Hp())}const Fe=50;async function Oe(e,t){if(!e.client||!e.connected)return;e.chatLoading=!0,e.lastError=null;const n=(t==null?void 0:t.limit)??Fe;try{const i=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:n}),s=Array.isArray(i.messages)?i.messages:[],o=typeof i.totalMessages=="number"?i.totalMessages:s.length,a=ec(s);e.chatMessages=a,e.chatHistoryTotal=o,e.chatHistoryHasMore=o>s.length,e.chatThinkingLevel=i.thinkingLevel??null,e.chatModelProvider=typeof i.modelProvider=="string"?i.modelProvider:null,e.chatModel=typeof i.model=="string"?i.model:null,e.chatVerboseLevel=typeof i.verboseLevel=="string"?i.verboseLevel:null,e.chatFillerEnabled=typeof i.fillerEnabled=="boolean"?i.fillerEnabled:null}catch(i){e.lastError=String(i)}finally{e.chatLoading=!1}}async function qp(e){if(!e.client||!e.connected||e.chatLoadingOlder||!e.chatHistoryHasMore)return!1;e.chatLoadingOlder=!0;try{const t=e.chatMessages.length,n=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:Fe,offset:t}),i=Array.isArray(n.messages)?n.messages:[],s=typeof n.totalMessages=="number"?n.totalMessages:0;if(i.length===0)return e.chatHistoryHasMore=!1,!1;const o=ec(i);return e.chatMessages=[...o,...e.chatMessages],e.chatHistoryTotal=s,e.chatHistoryHasMore=s>t+i.length,!0}catch(t){return e.lastError=String(t),!1}finally{e.chatLoadingOlder=!1}}function jp(e){const t=/^data:(.+?);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function sc(e,t,n){if(e.chatSuggestions=[],!e.client||!e.connected)return!1;const i=t.trim(),s=n&&n.length>0;if(!i&&!s)return!1;const o=Date.now(),a=(n??[]).filter(g=>!g.fileName),r=(n??[]).filter(g=>g.fileName),c=[],d=r.map(g=>g.fileName).filter(Boolean);if(d.length>0){const g=i?`${d.join(", ")}
9
9
 
10
- ${i}`:c.join(", ");l.push({type:"text",text:g})}else i&&l.push({type:"text",text:i});for(const g of a)l.push({type:"image",source:{type:"base64",media_type:g.mimeType,data:g.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:l,timestamp:o}],e.chatSending=!0,e.lastError=null;const h=os();e.chatRunId=h,e.chatStream="",e.chatStreamStartedAt=o;const d=[...a,...r],p=d.length>0?d.map(g=>{if(g.textContent)return{type:"document",mimeType:g.mimeType||"text/plain",fileName:g.fileName,content:btoa(unescape(encodeURIComponent(g.textContent)))};const $=Up(g.dataUrl);return $?{type:g.fileName?"document":"image",mimeType:$.mimeType,fileName:g.fileName,content:$.content}:null}).filter(g=>g!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:h,attachments:p}),!0}catch(g){const $=String(g);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=$,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+$}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function tc(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 nc(e,t){var n,i;if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="working"){const o=(t.message?(n=Mn(t.message))==null?void 0:n.trim():void 0)||((i=e.chatStream)==null?void 0:i.trim());if(o)if(!e.chatInterimText)e.chatInterimText=o;else{const a=o.trim(),r=e.chatInterimText.trim();a===r||r.endsWith(a)||(a.startsWith(r)?e.chatInterimText=o:e.chatInterimText=`${e.chatInterimText}
10
+ ${i}`:d.join(", ");c.push({type:"text",text:g})}else i&&c.push({type:"text",text:i});for(const g of a)c.push({type:"image",source:{type:"base64",media_type:g.mimeType,data:g.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:c,timestamp:o}],e.chatSending=!0,e.lastError=null;const h=as();e.chatRunId=h,e.chatStream="",e.chatStreamStartedAt=o;const l=[...a,...r],p=l.length>0?l.map(g=>{if(g.textContent)return{type:"document",mimeType:g.mimeType||"text/plain",fileName:g.fileName,content:btoa(unescape(encodeURIComponent(g.textContent)))};const $=jp(g.dataUrl);return $?{type:g.fileName?"document":"image",mimeType:$.mimeType,fileName:g.fileName,content:$.content}:null}).filter(g=>g!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:h,attachments:p}),!0}catch(g){const $=String(g);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=$,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+$}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function oc(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 ac(e,t){var n,i;if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="working"){const o=(t.message?(n=Mn(t.message))==null?void 0:n.trim():void 0)||((i=e.chatStream)==null?void 0:i.trim());if(o)if(!e.chatInterimText)e.chatInterimText=o;else{const a=o.trim(),r=e.chatInterimText.trim();a===r||r.endsWith(a)||(a.startsWith(r)?e.chatInterimText=o:e.chatInterimText=`${e.chatInterimText}
11
11
 
12
- ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.message);return typeof s=="string"&&s.trim()&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:s.trim()}],timestamp:Date.now(),filler:!0}]),"block"}else if(t.state==="delta"){e.chatSuggestions=[];const s=Mn(t.message);if(typeof s=="string"){if(s.trim()==="NO_REPLY")return null;const o=e.chatStream??"";(!o||s.length>=o.length)&&(e.chatStream=s)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null,e.lastError=t.errorMessage??"chat error");return t.state}const Ni=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:Fe,abortChatRun:tc,handleChatEvent:nc,loadChatHistory:Oe,loadOlderChatHistory:Fp,sendChatMessage:ec},Symbol.toStringTag,{value:"Module"}));async function Yo(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=Bi(e.sessionsFilterActive??"",0),i=Bi(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),i>0&&(t.limit=i);const s=await e.client.request("sessions.list",t);s&&(e.sessionsResult=s)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function ci(e,t,n){if(!e.client||!e.connected)return;const i={key:t};"label"in n&&(i.label=n.label),"thinkingLevel"in n&&(i.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(i.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(i.reasoningLevel=n.reasoningLevel),"model"in n&&(i.model=n.model),"fillerEnabled"in n&&(i.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",i),await Yo(e)}catch(s){e.sessionsError=String(s)}}const kr=50,Wp=80,Kp=12e4;function zp(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const i=n.map(s=>{if(!s||typeof s!="object")return null;const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>!!s);return i.length===0?null:i.join(`
13
- `)}function xr(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=zp(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const i=Vl(n,Kp);return i.truncated?`${i.text}
12
+ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.message);return typeof s=="string"&&s.trim()&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:s.trim()}],timestamp:Date.now(),filler:!0}]),"block"}else if(t.state==="delta"){e.chatSuggestions=[];const s=Mn(t.message);if(typeof s=="string"){if(s.trim()==="NO_REPLY")return null;const o=e.chatStream??"";(!o||s.length>=o.length)&&(e.chatStream=s)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null,e.lastError=t.errorMessage??"chat error");return t.state}const Oi=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:Fe,abortChatRun:oc,handleChatEvent:ac,loadChatHistory:Oe,loadOlderChatHistory:qp,sendChatMessage:sc},Symbol.toStringTag,{value:"Module"}));async function Xo(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=Ni(e.sessionsFilterActive??"",0),i=Ni(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),i>0&&(t.limit=i);const s=await e.client.request("sessions.list",t);s&&(e.sessionsResult=s)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function ci(e,t,n){if(!e.client||!e.connected)return;const i={key:t};"label"in n&&(i.label=n.label),"thinkingLevel"in n&&(i.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(i.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(i.reasoningLevel=n.reasoningLevel),"model"in n&&(i.model=n.model),"fillerEnabled"in n&&(i.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",i),await Xo(e)}catch(s){e.sessionsError=String(s)}}const Sr=50,Gp=80,Vp=12e4;function Qp(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const i=n.map(s=>{if(!s||typeof s!="object")return null;const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>!!s);return i.length===0?null:i.join(`
13
+ `)}function Ar(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Qp(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const i=Xl(n,Vp);return i.truncated?`${i.text}
14
14
 
15
- … truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function qp(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 Hp(e){if(e.toolStreamOrder.length<=kr)return;const t=e.toolStreamOrder.length-kr,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function jp(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function bo(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),jp(e)}function Gp(e,t=!1){if(t){bo(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>bo(e),Wp))}function Xo(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],bo(e)}const Vp=5e3;function Qp(e,t){var s;const n=t.data??{},i=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),i==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:i==="end"&&(e.compactionStatus={active:!1,startedAt:((s=e.compactionStatus)==null?void 0:s.startedAt)??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},Vp))}function Jp(e,t){if(!t)return;if(t.stream==="compaction"){Qp(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const i=t.data??{},s=typeof i.toolCallId=="string"?i.toolCallId:"";if(!s)return;const o=typeof i.name=="string"?i.name:"tool",a=typeof i.phase=="string"?i.phase:"",r=a==="start"?i.args:void 0,l=a==="update"?xr(i.partialResult):a==="result"?xr(i.result):void 0,c=Date.now();let h=e.toolStreamById.get(s);h?(h.name=o,r!==void 0&&(h.args=r),l!==void 0&&(h.output=l),h.updatedAt=c):(h={toolCallId:s,runId:t.runId,sessionKey:n,name:o,args:r,output:l,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(s,h),e.toolStreamOrder.push(s)),h.message=qp(h),Hp(e),Gp(e,a==="result")}let di=0;function nn(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=++di,i=()=>{const s=e.querySelector(".chat-thread");if(s){const o=getComputedStyle(s).overflowY;if(o==="auto"||o==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{n===di&&(e.chatScrollFrame=requestAnimationFrame(()=>{if(e.chatScrollFrame=null,n!==di)return;const s=i();if(!s)return;const o=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||o<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const r=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{if(e.chatScrollTimeout=null,n!==di)return;const l=i();if(!l)return;const c=l.scrollHeight-l.scrollTop-l.clientHeight;(t||e.chatUserNearBottom||c<200)&&(l.scrollTop=l.scrollHeight,e.chatUserNearBottom=!0)},r)}))})}function ic(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 Yp(e,t){const n=t.currentTarget;if(!n)return;const i=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=i<200,n.scrollTop<100&&e.onLoadOlder&&e.onLoadOlder()}function Xp(e){const t=e.querySelector(".chat-thread");if(!t)return null;const n=t.scrollHeight,i=t.scrollTop;return()=>{const s=t.scrollHeight-n;t.scrollTop=i+s}}function Zp(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function eh(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function th(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function nh(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
15
+ … truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function Jp(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 Yp(e){if(e.toolStreamOrder.length<=Sr)return;const t=e.toolStreamOrder.length-Sr,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function Xp(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function wo(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Xp(e)}function Zp(e,t=!1){if(t){wo(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>wo(e),Gp))}function Zo(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],wo(e)}const eh=5e3;function th(e,t){var s;const n=t.data??{},i=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),i==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:i==="end"&&(e.compactionStatus={active:!1,startedAt:((s=e.compactionStatus)==null?void 0:s.startedAt)??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},eh))}function nh(e,t){if(!t)return;if(t.stream==="compaction"){th(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const i=t.data??{},s=typeof i.toolCallId=="string"?i.toolCallId:"";if(!s)return;const o=typeof i.name=="string"?i.name:"tool",a=typeof i.phase=="string"?i.phase:"",r=a==="start"?i.args:void 0,c=a==="update"?Ar(i.partialResult):a==="result"?Ar(i.result):void 0,d=Date.now();let h=e.toolStreamById.get(s);h?(h.name=o,r!==void 0&&(h.args=r),c!==void 0&&(h.output=c),h.updatedAt=d):(h={toolCallId:s,runId:t.runId,sessionKey:n,name:o,args:r,output:c,startedAt:typeof t.ts=="number"?t.ts:d,updatedAt:d,message:{}},e.toolStreamById.set(s,h),e.toolStreamOrder.push(s)),h.message=Jp(h),Yp(e),Zp(e,a==="result")}let di=0;function nn(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=++di,i=()=>{const s=e.querySelector(".chat-thread");if(s){const o=getComputedStyle(s).overflowY;if(o==="auto"||o==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{n===di&&(e.chatScrollFrame=requestAnimationFrame(()=>{if(e.chatScrollFrame=null,n!==di)return;const s=i();if(!s)return;const o=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||o<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const r=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{if(e.chatScrollTimeout=null,n!==di)return;const c=i();if(!c)return;const d=c.scrollHeight-c.scrollTop-c.clientHeight;(t||e.chatUserNearBottom||d<200)&&(c.scrollTop=c.scrollHeight,e.chatUserNearBottom=!0)},r)}))})}function rc(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 ih(e,t){const n=t.currentTarget;if(!n)return;const i=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=i<200,n.scrollTop<100&&e.onLoadOlder&&e.onLoadOlder()}function sh(e){const t=e.querySelector(".chat-thread");if(!t)return null;const n=t.scrollHeight,i=t.scrollTop;return()=>{const s=t.scrollHeight-n;t.scrollTop=i+s}}function oh(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function ah(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function rh(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function lh(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
16
16
  `)}
17
- `],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function ih(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
17
+ `],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function ch(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
18
18
  `)}
19
- `],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-session-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function sh(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:i}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${i}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function ct(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Et(e){return`${JSON.stringify(e,null,2).trimEnd()}
20
- `}function sc(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const a=t[o],r=t[o+1];if(typeof a=="number"){if(!Array.isArray(i))return;i[a]==null&&(i[a]=typeof r=="number"?[]:{}),i=i[a]}else{if(typeof i!="object"||i==null)return;const l=i;l[a]==null&&(l[a]=typeof r=="number"?[]:{}),i=l[a]}}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(i)&&(i[s]=n);return}typeof i=="object"&&i!=null&&(i[s]=n)}async function Ue(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});ah(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function oc(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});oh(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function oh(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function ah(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=ct(t.config??{}),e.configFormOriginal=ct(t.config??{}),e.configRawOriginal=n)}async function rh(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,i=(t=e.configSnapshot)==null?void 0:t.hash;if(!i){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:n,baseHash:i}),e.configFormDirty=!1,await Ue(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function sn(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 jn(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),e.accountId&&(t.accountId=e.accountId);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 ac(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=Bi(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const i=e.everyUnit;return{kind:"every",everyMs:n*(i==="minutes"?6e4:i==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function rc(e){if(e.payloadKind==="systemEvent"){const o=e.payloadText.trim();if(!o)throw new Error("System event text required.");return{kind:"systemEvent",text:o}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel);const i=[];e.toAdmins&&i.push("admins");for(const o of e.recipients){const a=o.trim();a&&i.push(a)}i.length>0&&(n.to=i.join(","));const s=Bi(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function lh(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=ac(e.cronForm),i=rc(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),a={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:o||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!a.name)throw new Error("Name required.");await e.client.request("cron.add",a),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await jn(e),await sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function ch(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 jn(e),await sn(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function dh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null,e.cronRunModalJobId=t.id,e.cronRunModalJobName=t.name||"Untitled",e.cronRunResult=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await wo(e,t.id)}catch(n){e.cronError=String(n),e.cronRunResult={status:"error",error:String(n)}}finally{e.cronBusy=!1}}}function uh(e,t){e.cronRunModalJobId&&t.jobId===e.cronRunModalJobId&&t.action==="finished"&&(e.cronRunResult={status:t.status??"unknown",durationMs:t.durationMs,summary:t.summary,error:t.error})}async function ph(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 jn(e),await sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function hh(e){var n;const t={name:e.name||"",description:e.description||"",agentId:e.agentId||"",enabled:e.enabled,scheduleKind:e.schedule.kind,scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"",cronTz:"",sessionTarget:e.sessionTarget||"main",wakeMode:e.wakeMode||"next-heartbeat",payloadKind:e.payload.kind,payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};if(e.schedule.kind==="at"){const i=new Date(e.schedule.atMs),s=o=>String(o).padStart(2,"0");t.scheduleAt=`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}T${s(i.getHours())}:${s(i.getMinutes())}`}else if(e.schedule.kind==="every"){const i=e.schedule.everyMs;i%864e5===0?(t.everyAmount=String(i/864e5),t.everyUnit="days"):i%36e5===0?(t.everyAmount=String(i/36e5),t.everyUnit="hours"):(t.everyAmount=String(i/6e4),t.everyUnit="minutes")}else e.schedule.kind==="cron"&&(t.cronExpr=e.schedule.expr,t.cronTz=e.schedule.tz||"");if(e.payload.kind==="systemEvent")t.payloadText=e.payload.text;else if(e.payload.kind==="agentTurn"){t.payloadText=e.payload.message,t.deliver=e.payload.deliver??!1,t.timeoutSeconds=e.payload.timeoutSeconds?String(e.payload.timeoutSeconds):"";const i=e.payload.channel??e.payload.provider;t.channel=i||"last";const s=e.payload.to||"";if(s){const o=s.split(",").map(a=>a.trim()).filter(Boolean);t.toAdmins=o.some(a=>a.toLowerCase()==="admins"),t.recipients=o.filter(a=>a.toLowerCase()!=="admins")}}return(n=e.isolation)!=null&&n.postToMainPrefix&&(t.postToMainPrefix=e.isolation.postToMainPrefix),t}async function fh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=ac(e.cronForm),i=rc(e.cronForm),s={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:e.cronForm.agentId.trim()||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i};if(e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?s.isolation={postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:s.isolation=void 0,!s.name)throw new Error("Name required.");await e.client.request("cron.update",{id:t,patch:s}),await jn(e),await sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function wo(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 ee(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 Zo(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const i=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=i.message??null,e.whatsappLoginQrDataUrl=i.qrDataUrl??null,e.whatsappLoginConnected=null}catch(i){e.whatsappLoginMessage=String(i),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function lc(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 cc(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 dc(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const i=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!i){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const o=ct(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const a=o.channels;(!a.whatsapp||typeof a.whatsapp!="object")&&(a.whatsapp={});const r=a.whatsapp;(!r.accounts||typeof r.accounts!="object")&&(r.accounts={});const l=r.accounts;if(l[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}l[i]={name:n,provider:"baileys"};const c=s.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const h=Et(o);await e.client.request("config.set",{raw:h,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await ee(e,!0),await Zo(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function uc(e,t){if(!(!e.client||!e.connected)&&!e.whatsappAccountSaving){e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=ct(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,a=o==null?void 0:o.accounts;if(!a){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(a).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!a[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete a[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(h=>{const d=h.match;return!d||d.channel!=="whatsapp"?!0:d.accountId!==t}));const l=n.hash;if(!l){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=Et(i);await e.client.request("config.set",{raw:c,baseHash:l}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await ee(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const gh=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:dc,loadChannels:ee,logoutWhatsApp:cc,removeWhatsAppAccount:uc,startWhatsAppLogin:Zo,waitWhatsAppLogin:lc},Symbol.toStringTag,{value:"Module"}));async function ea(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,i,s]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const o=i;e.debugModels=Array.isArray(o==null?void 0:o.models)?o==null?void 0:o.models:[],e.debugHeartbeat=s}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const mh=2e3,yh=new Set(["trace","debug","info","warn","error","fatal"]);function vh(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 bh(e){if(typeof e!="string")return null;const t=e.toLowerCase();return yh.has(t)?t:null}function pc(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,i=typeof t.time=="string"?t.time:typeof(n==null?void 0:n.date)=="string"?n==null?void 0:n.date:null,s=bh((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),o=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,a=vh(o);let r=null;a&&(typeof a.subsystem=="string"?r=a.subsystem:typeof a.module=="string"&&(r=a.module)),!r&&o&&o.length<120&&(r=o);let l=null;return typeof t[1]=="string"?l=t[1]:!a&&typeof t[0]=="string"?l=t[0]:typeof t.message=="string"&&(l=t.message),{raw:e,time:i,level:s,subsystem:r,message:l??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Vt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const i=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),o=(Array.isArray(i.lines)?i.lines.filter(r=>typeof r=="string"):[]).map(pc),a=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=a?o:[...e.logsEntries,...o].slice(-mh),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const wh=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Vt,parseLogLine:pc},Symbol.toStringTag,{value:"Module"}));const hc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:pe,n:Ai,Gx:$r,Gy:Sr,a:Ns,d:Os,h:kh}=hc,Tt=32,ta=64,xh=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},ae=(e="")=>{const t=new Error(e);throw xh(t,ae),t},$h=e=>typeof e=="bigint",Sh=e=>typeof e=="string",Ah=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",ut=(e,t,n="")=>{const i=Ah(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const a=n&&`"${n}" `,r=o?` of length ${t}`:"",l=i?`length=${s}`:`type=${typeof e}`;ae(a+"expected Uint8Array"+r+", got "+l)}return e},as=e=>new Uint8Array(e),fc=e=>Uint8Array.from(e),gc=(e,t)=>e.toString(16).padStart(t,"0"),mc=e=>Array.from(ut(e)).map(t=>gc(t,2)).join(""),je={_0:48,_9:57,A:65,F:70,a:97,f:102},Ar=e=>{if(e>=je._0&&e<=je._9)return e-je._0;if(e>=je.A&&e<=je.F)return e-(je.A-10);if(e>=je.a&&e<=je.f)return e-(je.a-10)},yc=e=>{const t="hex invalid";if(!Sh(e))return ae(t);const n=e.length,i=n/2;if(n%2)return ae(t);const s=as(i);for(let o=0,a=0;o<i;o++,a+=2){const r=Ar(e.charCodeAt(a)),l=Ar(e.charCodeAt(a+1));if(r===void 0||l===void 0)return ae(t);s[o]=r*16+l}return s},vc=()=>globalThis==null?void 0:globalThis.crypto,Ch=()=>{var e;return((e=vc())==null?void 0:e.subtle)??ae("crypto.subtle must be defined, consider polyfill")},zn=(...e)=>{const t=as(e.reduce((i,s)=>i+ut(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},Eh=(e=Tt)=>vc().getRandomValues(as(e)),Oi=BigInt,yt=(e,t,n,i="bad number: out of range")=>$h(e)&&t<=e&&e<n?e:ae(i),D=(e,t=pe)=>{const n=e%t;return n>=0n?n:t+n},bc=e=>D(e,Ai),Th=(e,t)=>{(e===0n||t<=0n)&&ae("no inverse n="+e+" mod="+t);let n=D(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const a=i/n,r=i%n,l=s-o*a;i=n,n=r,s=o,o=l}return i===1n?D(s,t):ae("no inverse")},_h=e=>{const t=$c[e];return typeof t!="function"&&ae("hashes."+e+" not set"),t},Fs=e=>e instanceof _t?e:ae("Point expected"),ko=2n**256n,Ne=class Ne{constructor(t,n,i,s){q(this,"X");q(this,"Y");q(this,"Z");q(this,"T");const o=ko;this.X=yt(t,0n,o),this.Y=yt(n,0n,o),this.Z=yt(i,1n,o),this.T=yt(s,0n,o),Object.freeze(this)}static CURVE(){return hc}static fromAffine(t){return new Ne(t.x,t.y,1n,D(t.x*t.y))}static fromBytes(t,n=!1){const i=Os,s=fc(ut(t,Tt)),o=t[31];s[31]=o&-129;const a=kc(s);yt(a,0n,n?ko:pe);const l=D(a*a),c=D(l-1n),h=D(i*l+1n);let{isValid:d,value:p}=Ph(c,h);d||ae("bad point: y not sqrt");const g=(p&1n)===1n,$=(o&128)!==0;return!n&&p===0n&&$&&ae("bad point: x==0, isLastByteOdd"),$!==g&&(p=D(-p)),new Ne(p,a,1n,D(p*a))}static fromHex(t,n){return Ne.fromBytes(yc(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Ns,n=Os,i=this;if(i.is0())return ae("bad point: ZERO");const{X:s,Y:o,Z:a,T:r}=i,l=D(s*s),c=D(o*o),h=D(a*a),d=D(h*h),p=D(l*t),g=D(h*D(p+c)),$=D(d+D(n*D(l*c)));if(g!==$)return ae("bad point: equation left != right (1)");const S=D(s*o),T=D(a*r);return S!==T?ae("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:a,Z:r}=Fs(t),l=D(n*r),c=D(o*s),h=D(i*r),d=D(a*s);return l===c&&h===d}is0(){return this.equals(jt)}negate(){return new Ne(D(-this.X),this.Y,this.Z,D(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=Ns,o=D(t*t),a=D(n*n),r=D(2n*D(i*i)),l=D(s*o),c=t+n,h=D(D(c*c)-o-a),d=l+a,p=d-r,g=l-a,$=D(h*p),S=D(d*g),T=D(h*g),f=D(p*d);return new Ne($,S,f,T)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:r,Z:l,T:c}=Fs(t),h=Ns,d=Os,p=D(n*a),g=D(i*r),$=D(o*d*c),S=D(s*l),T=D((n+i)*(a+r)-p-g),f=D(S-$),b=D(S+$),k=D(g-h*p),A=D(T*f),E=D(b*k),M=D(T*k),P=D(f*b);return new Ne(A,E,P,M)}subtract(t){return this.add(Fs(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return jt;if(yt(t,1n,Ai),t===1n)return this;if(this.equals(Mt))return Kh(t).p;let i=jt,s=Mt;for(let o=this;t>0n;o=o.double(),t>>=1n)t&1n?i=i.add(o):n&&(s=s.add(o));return i}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:i}=this;if(this.equals(jt))return{x:0n,y:1n};const s=Th(i,pe);D(i*s)!==1n&&ae("invalid inverse");const o=D(t*s),a=D(n*s);return{x:o,y:a}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=wc(n);return i[31]|=t&1n?128:0,i}toHex(){return mc(this.toBytes())}clearCofactor(){return this.multiply(Oi(kh),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Ai/2n,!1).double();return Ai%2n&&(t=t.add(this)),t.is0()}};q(Ne,"BASE"),q(Ne,"ZERO");let _t=Ne;const Mt=new _t($r,Sr,1n,D($r*Sr)),jt=new _t(0n,1n,1n,0n);_t.BASE=Mt;_t.ZERO=jt;const wc=e=>yc(gc(yt(e,0n,ko),ta)).reverse(),kc=e=>Oi("0x"+mc(fc(ut(e)).reverse())),Ie=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=pe;return n},Mh=e=>{const n=e*e%pe*e%pe,i=Ie(n,2n)*n%pe,s=Ie(i,1n)*e%pe,o=Ie(s,5n)*s%pe,a=Ie(o,10n)*o%pe,r=Ie(a,20n)*a%pe,l=Ie(r,40n)*r%pe,c=Ie(l,80n)*l%pe,h=Ie(c,80n)*l%pe,d=Ie(h,10n)*o%pe;return{pow_p_5_8:Ie(d,2n)*e%pe,b2:n}},Cr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Ph=(e,t)=>{const n=D(t*t*t),i=D(n*n*t),s=Mh(e*i).pow_p_5_8;let o=D(e*n*s);const a=D(t*o*o),r=o,l=D(o*Cr),c=a===e,h=a===D(-e),d=a===D(-e*Cr);return c&&(o=r),(h||d)&&(o=l),(D(o)&1n)===1n&&(o=D(-o)),{isValid:c||h,value:o}},xo=e=>bc(kc(e)),na=(...e)=>$c.sha512Async(zn(...e)),Ih=(...e)=>_h("sha512")(zn(...e)),xc=e=>{const t=e.slice(0,Tt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Tt,ta),i=xo(t),s=Mt.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},ia=e=>na(ut(e,Tt)).then(xc),Lh=e=>xc(Ih(ut(e,Tt))),Rh=e=>ia(e).then(t=>t.pointBytes),Dh=e=>na(e.hashable).then(e.finish),Bh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=xo(t),a=Mt.multiply(o).toBytes();return{hashable:zn(a,i,n),finish:c=>{const h=bc(o+xo(c)*s);return ut(zn(a,wc(h)),ta)}}},Nh=async(e,t)=>{const n=ut(e),i=await ia(t),s=await na(i.prefix,n);return Dh(Bh(i,s,n))},$c={sha512Async:async e=>{const t=Ch(),n=zn(e);return as(await t.digest("SHA-512",n.buffer))},sha512:void 0},Oh=(e=Eh(Tt))=>e,Fh={getExtendedPublicKeyAsync:ia,getExtendedPublicKey:Lh,randomSecretKey:Oh},Fi=8,Uh=256,Sc=Math.ceil(Uh/Fi)+1,$o=2**(Fi-1),Wh=()=>{const e=[];let t=Mt,n=t;for(let i=0;i<Sc;i++){n=t,e.push(n);for(let s=1;s<$o;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Er;const Tr=(e,t)=>{const n=t.negate();return e?n:t},Kh=e=>{const t=Er||(Er=Wh());let n=jt,i=Mt;const s=2**Fi,o=s,a=Oi(s-1),r=Oi(Fi);for(let l=0;l<Sc;l++){let c=Number(e&a);e>>=r,c>$o&&(c-=o,e+=1n);const h=l*$o,d=h,p=h+Math.abs(c)-1,g=l%2!==0,$=c<0;c===0?i=i.add(Tr(g,t[d])):n=n.add(Tr($,t[p]))}return e!==0n&&ae("invalid wnaf"),{p:n,f:i}},Us="taskmaster-device-identity-v1";function So(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Ac(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)s[o]=i.charCodeAt(o);return s}function zh(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Cc(e){const t=await crypto.subtle.digest("SHA-256",e);return zh(new Uint8Array(t))}async function qh(){const e=Fh.randomSecretKey(),t=await Rh(e);return{deviceId:await Cc(t),publicKey:So(t),privateKey:So(e)}}async function Hh(){try{const n=localStorage.getItem(Us);if(n){const i=JSON.parse(n);if((i==null?void 0:i.version)===1&&typeof i.deviceId=="string"&&typeof i.publicKey=="string"&&typeof i.privateKey=="string"){const s=await Cc(Ac(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(Us,JSON.stringify(o)),{deviceId:s,publicKey:i.publicKey,privateKey:i.privateKey}}return{deviceId:i.deviceId,publicKey:i.publicKey,privateKey:i.privateKey}}}}catch{}const e=await qh(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Us,JSON.stringify(t)),e}async function jh(e,t){const n=Ac(e),i=new TextEncoder().encode(t),s=await Nh(i,n);return So(s)}const Ec="taskmaster.device.auth.v1";function sa(e){return e.trim()}function Gh(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const i=n.trim();i&&t.add(i)}return[...t].sort()}function oa(){try{const e=window.localStorage.getItem(Ec);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 Tc(e){try{window.localStorage.setItem(Ec,JSON.stringify(e))}catch{}}function Vh(e){const t=oa();if(!t||t.deviceId!==e.deviceId)return null;const n=sa(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function Qh(e){const t=sa(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=oa();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:Gh(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Tc(n),s}function Jh(e){const t=oa();if(!t||t.deviceId!==e.deviceId)return;const n=sa(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Tc(i)}async function aa(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 ra(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 Yh(e){return{method:"exec.approvals.get",params:{}}}async function Xh(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Yh(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);Zh(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Zh(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=ct(t.file??{}))}async function _c(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 dt(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function Ze(e){return e instanceof Error?e.message:String(e)}function qn(){return{name:"",skillContent:"",references:[]}}async function Xe(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=Ze(n)}finally{e.skillsLoading=!1}}}function Mc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Pc(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 Xe(e),dt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=Ze(i);e.skillsError=s,dt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Ic(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 Xe(e),dt(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=Ze(n);e.skillsError=i,dt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Lc(e,t,n,i){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const s=await e.client.request("skills.install",{name:n,installId:i,timeoutMs:12e4});await Xe(e),dt(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=Ze(s);e.skillsError=o,dt(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}async function Rc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});n&&(e.skillDetail=n,e.skillDetailTab="SKILL.md")}catch(n){e.skillsError=Ze(n)}}function Dc(e){e.skillDetail=null,e.skillDetailTab=""}function Bc(e,t){e.skillDetailTab=t}async function Nc(e){if(e.skillAddModal=!0,e.skillAddForm=qn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[],!(!e.client||!e.connected))try{const t=await e.client.request("skills.drafts",{});t&&(e.skillDrafts=t.drafts)}catch{}}function Oc(e){e.skillAddModal=!1,e.skillAddForm=qn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[]}function Fc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))},e.skillAddFormSource="draft"}async function Uc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))},e.skillAddFormSource="installed",await la(e)}async function la(e){if(!e.client||!e.connected)return;const t=e.skillAddForm;if(!(!t.name.trim()||!t.skillContent.trim())){e.skillsBusyKey="__add__",e.skillsError=null;try{const n=t.references.filter(s=>s.name.trim()&&s.content.trim()).map(s=>({name:s.name.trim(),content:s.content})),i=t.name.trim();e.skillAddFormSource==="installed"?(await e.client.request("skills.create",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=qn(),e.skillAddFormSource="draft",e.skillDrafts=[],await Xe(e),dt(e,i,{kind:"success",message:"Skill saved — active on next message"})):(await e.client.request("skills.saveDraft",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=qn(),e.skillAddFormSource="draft",e.skillDrafts=[],dt(e,i,{kind:"success",message:"Draft saved"}))}catch(n){e.skillsError=Ze(n)}finally{e.skillsBusyKey=null}}}async function Wc(e,t){if(!(!e.client||!e.connected))try{await e.client.request("skills.deleteDraft",{name:t}),e.skillDrafts=e.skillDrafts.filter(n=>n.name!==t)}catch(n){e.skillsError=Ze(n)}}async function Kc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});if(!n)return;e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i}))},e.skillAddFormSource="installed",e.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=Ze(n)}}function zc(e,t){const n=e.skillDetail;n&&(e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i}))},e.skillAddFormSource="installed",e.skillEditTab=t&&t!=="SKILL.md"?t:"SKILL.md",e.skillDetail=null,e.skillDetailTab="",e.skillAddModal=!0,e.skillDrafts=[])}function qc(e,t,n){e.skillAddForm={...e.skillAddForm,references:e.skillAddForm.references.map(i=>i.name===t?{...i,content:n}:i)}}function Hc(e,t){e.skillEditTab=t}async function jc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await Xe(e)}catch(n){e.skillsError=Ze(n)}finally{e.skillsBusyKey=null}}}const ef=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:Oc,closeSkillDetail:Dc,deleteDraft:Wc,deleteSkill:jc,editDetailSkill:zc,editSkill:Kc,emptyAddForm:qn,importDraft:Fc,installDraft:Uc,installSkill:Lc,loadSkills:Xe,openAddSkillModal:Nc,saveNewSkill:la,saveSkillApiKey:Ic,setEditTab:Hc,setSkillDetailTab:Bc,updateFormReference:qc,updateSkillEdit:Mc,updateSkillEnabled:Pc,viewSkillDetail:Rc},Symbol.toStringTag,{value:"Module"})),Gc={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},Vc=new Map(Object.entries(Gc).map(([e,t])=>[t,e]));function rs(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function Hn(e){if(!e)return"/";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}function tf(e,t=""){const n=rs(t),i=Gc[e];return n?`${n}${i}`:i}function Qc(e,t=""){const n=rs(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=Hn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":Vc.get(s)??null}function nf(e){let t=Hn(e);if(t.endsWith("/index.html")&&(t=Hn(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let i=0;i<n.length;i++){const s=`/${n.slice(i).join("/")}`.toLowerCase();if(Vc.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function sf(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ca(e){return e==="system"?sf():e}const ui=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,of=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,pi=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},af=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var c;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,a=s,r=of();if(!!a.startViewTransition&&!r){let h=.5,d=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")h=ui(n.pointerClientX/window.innerWidth),d=ui(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(h=ui((p.left+p.width/2)/window.innerWidth),d=ui((p.top+p.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${h*100}%`),o.style.setProperty("--theme-switch-y",`${d*100}%`),o.classList.add("theme-transition");try{const p=(c=a.startViewTransition)==null?void 0:c.call(a,()=>{t()});p!=null&&p.finished?p.finished.finally(()=>pi(o)):pi(o)}catch{pi(o),t()}return}t(),pi(o)},rf=2e3;async function Pn(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const n={cursors:t!=null&&t.reset?void 0:e.sessionLogsCursors,limit:500};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(n.agents=e.workspaceAgentIds);const s=await e.client.request("sessions.transcript",n),o=Array.isArray(s.entries)?s.entries:[],a=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=a?o:[...e.sessionLogsEntries,...o].slice(-rf),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 Jc=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:Pn},Symbol.toStringTag,{value:"Module"}));async function Yc(e,t){if(!(!e.client||!e.connected))try{const n={},i=await e.client.request("memory.audit",n);i!=null&&i.ok&&(e.auditEntries=i.entries??[])}catch{}}async function lf(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function We(e){return e instanceof Error?e.message:String(e)}let hi=null;function on(e,t){hi&&clearTimeout(hi),e.filesMessage={kind:"success",text:t},hi=setTimeout(()=>{e.filesMessage=null,hi=null},3e3)}async function an(e,t){if(!(!e.client||!e.connected)){if(!t){e.filesTree=[],e.filesRoot="";return}if(!e.filesLoading){e.filesLoading=!0,e.filesError=null;try{const n={};t&&(n.agentId=t);const i=await e.client.request("files.tree",n);i!=null&&i.tree&&(e.filesTree=i.tree,e.filesRoot=i.root??"")}catch(n){e.filesError=We(n)}finally{e.filesLoading=!1}}}}async function cf(e,t,n){e.filesSelectedPaths=new Set([t]),await Xc(e,t,n)}async function df(e,t,n){const i=new Set(e.filesSelectedPaths);if(i.has(t)?i.delete(t):i.add(t),e.filesSelectedPaths=i,i.size===1){const s=[...i][0];await Xc(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function uf(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let i=0,s="";for(const o of n)try{await Zc(e,o,t),i++}catch(a){s=We(a)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:on(e,`${i} file${i!==1?"s":""} downloaded`)}async function pf(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await mf(e,t,o,i)}async function Xc(e,t,n){if(!(!e.client||!e.connected)){e.filesSelectedPath=t,e.filesPreviewLoading=!0,e.filesPreviewContent=null,e.filesPreviewBinary=!1,e.filesPreviewSize=null;try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.read",i);e.filesPreviewContent=(s==null?void 0:s.content)??null,e.filesPreviewBinary=(s==null?void 0:s.binary)??!1,e.filesPreviewSize=(s==null?void 0:s.size)??null}catch(i){e.filesError=We(i)}finally{e.filesPreviewLoading=!1}}}async function Zc(e,t,n){if(!(!e.client||!e.connected))try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.download",i);if(!(s!=null&&s.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(s.base64),c=>c.charCodeAt(0)),a=new Blob([o]),r=URL.createObjectURL(a),l=document.createElement("a");l.href=r,l.download=s.name??t.split("/").pop()??"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r)}catch(i){e.filesMessage={kind:"error",text:We(i)}}}async function hf(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const a of n)try{const r=await a.arrayBuffer(),l=btoa(new Uint8Array(r).reduce((h,d)=>h+String.fromCharCode(d),"")),c={path:t,name:a.name,data:l};i&&(c.agentId=i),await e.client.request("files.upload",c),s++}catch(r){o=We(r)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:on(e,`${s} file${s!==1?"s":""} uploaded`),await an(e,i)}async function ff(e,t,n,i){if(!e.client||!e.connected)return;e.filesMessage=null;const s=t==="."?n:`${t}/${n}`;try{const o={path:s};i&&(o.agentId=i),await e.client.request("files.mkdir",o),on(e,`Created ${s}`),await an(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:We(o)}}}async function gf(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={path:t};n&&(i.agentId=n),await e.client.request("files.delete",i),on(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await an(e,n)}catch(i){e.filesMessage={kind:"error",text:We(i)}}}}async function mf(e,t,n,i){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={from:t,to:n};i&&(s.agentId=i),await e.client.request("files.move",s),on(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await an(e,i)}catch(s){e.filesMessage={kind:"error",text:We(s)}}}}async function ls(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const i=await e.client.request("memory.status",n);i!=null&&i.ok&&(e.filesMemoryStatus={dirty:i.dirty??!1,syncing:i.syncing,syncProgress:i.syncProgress,files:i.files??0,chunks:i.chunks??0,model:i.model,embeddingState:i.embeddingState})}catch{}}async function yf(e,t){if(!(!e.client||!e.connected)&&!e.filesReindexBusy){e.filesReindexBusy=!0,e.filesMessage=null;try{const n={force:!0};t&&(n.agentId=t);const i=await e.client.request("memory.reindex",n),s=(i==null?void 0:i.files)??0,o=(i==null?void 0:i.chunks)??0;on(e,`Re-indexed: ${s} files, ${o} chunks`),await ls(e,t)}catch(n){e.filesMessage={kind:"error",text:We(n)}}finally{e.filesReindexBusy=!1}}}function vf(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n,e.filesCurrentDir=t}async function bf(e,t,n){if(!(!e.client||!e.connected)){if(!t.trim()){e.filesSearchResults=null;return}e.filesSearchLoading=!0,e.filesSearchResults=null;try{const i={query:t.trim(),maxResults:20};n&&(i.agentId=n);const s=await e.client.request("memory.search",i);e.filesSearchResults=(s==null?void 0:s.results)??[]}catch(i){e.filesMessage={kind:"error",text:We(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function wf(e){e.filesSearchQuery="",e.filesSearchResults=null}function kf(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{ra(e,{quiet:!0})},5e3))}function xf(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function da(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Vt(e,{quiet:!0})},2e3))}function ua(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function pa(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||Pn(e,{quiet:!0})},2e3))}function ha(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function fa(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ea(e)},3e3))}function ga(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function $f(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{Yc(e)},3e4))}function Sf(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function Af(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{const t=e;t.filesPage&&ls(t,t.filesResolvedAgentId)},3e3))}function Cf(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function rt(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,wp(n),t.theme!==e.theme&&(e.theme=t.theme,cs(e,ca(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function ed(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&rt(e,{...e.settings,lastActiveSessionKey:n})}function Ef(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),i=t.get("password"),s=t.get("session"),o=t.get("gatewayUrl");let a=!1;if(n!=null){const l=n.trim();l&&l!==e.settings.token&&rt(e,{...e.settings,token:l}),t.delete("token"),a=!0}if(i!=null){const l=i.trim();l&&(e.password=l),t.delete("password"),a=!0}if(s!=null){const l=s.trim();l&&(e.sessionKey=l,rt(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(o!=null){const l=o.trim();l&&l!==e.settings.gatewayUrl&&rt(e,{...e.settings,gatewayUrl:l}),t.delete("gatewayUrl"),a=!0}if(!a)return;const r=new URL(window.location.href);r.search=t.toString(),window.history.replaceState({},"",r.toString())}function Tf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?pa(e):da(e):(ua(e),ha(e)),t==="debug"?fa(e):ga(e),Ui(e),nd(e,t,!1)}function _f(e,t,n){af({nextTheme:t,applyTheme:()=>{e.theme=t,rt(e,{...e.settings,theme:t}),cs(e,ca(t))},context:n,currentTheme:e.theme})}async function Ui(e){if(e.tab==="overview"&&await id(e),e.tab==="channels"&&await Bf(e),e.tab==="instances"&&await _c(e),e.tab==="cron"&&await ma(e),e.tab==="skills"&&await Xe(e),e.tab==="nodes"&&(await ra(e),await aa(e),await Ue(e),await Xh(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await Wf(e),nn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await oc(e),await Ue(e)),e.tab==="debug"&&(await ea(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await le(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>Jc);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Vt(e,{reset:!0});ic(e,!0)}}function Mf(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?rs(e):nf(window.location.pathname)}function Pf(e){e.theme=e.settings.theme??"system",cs(e,ca(e.theme))}function cs(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function If(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"&&cs(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Lf(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 Rf(e,t){if(typeof window>"u")return;const n=Qc(window.location.pathname,e.basePath)??"chat";td(e,n),nd(e,n,t)}function Df(e){var s;if(typeof window>"u")return;const t=Qc(window.location.pathname,e.basePath);if(!t)return;const i=(s=new URL(window.location.href).searchParams.get("session"))==null?void 0:s.trim();i&&(e.sessionKey=i,rt(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),td(e,t)}function td(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?pa(e):da(e):(ua(e),ha(e)),t==="debug"?fa(e):ga(e),e.connected&&Ui(e)}function nd(e,t,n){if(typeof window>"u")return;const i=Hn(tf(t,e.basePath)),s=Hn(window.location.pathname),o=new URL(window.location.href);t==="chat"&&e.sessionKey?o.searchParams.set("session",e.sessionKey):o.searchParams.delete("session"),s!==i&&(o.pathname=i),n?window.history.replaceState({},"",o.toString()):window.history.pushState({},"",o.toString())}async function id(e){await Promise.all([ee(e,!1),_c(e),Yo(e),sn(e),ea(e)])}async function Bf(e){await Promise.all([ee(e,!0),oc(e),Ue(e)])}async function ma(e){await Promise.all([ee(e,!1),sn(e),jn(e)])}function sd(e){return e.chatSending||!!e.chatRunId}function Nf(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 od(e){e.connected&&(e.chatMessage="",await tc(e))}function Of(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:os(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],nn(e))}async function ad(e,t,n){var s,o;Xo(e);const i=await ec(e,t,n==null?void 0:n.attachments);return!i&&(n==null?void 0:n.previousDraft)!=null&&(e.chatMessage=n.previousDraft),!i&&(n!=null&&n.previousAttachments)&&(e.chatAttachments=n.previousAttachments),i&&ed(e,e.sessionKey),i&&(n!=null&&n.restoreDraft)&&((s=n.previousDraft)!=null&&s.trim())&&(e.chatMessage=n.previousDraft),i&&(n!=null&&n.restoreAttachments)&&((o=n.previousAttachments)!=null&&o.length)&&(e.chatAttachments=n.previousAttachments),nn(e),i&&!e.chatRunId&&rd(e),i}async function rd(e){if(!e.connected||sd(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await ad(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function Ff(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Uf(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],a=t==null?o:[],r=a.length>0;if(!(!s&&!r)){if(Nf(s)){await od(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[],xp(e.selectedWorkspace??"",e.sessionKey)),sd(e)){Of(e,s,a);return}await ad(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:r?a:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function Wf(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,Fe);await Promise.all([Oe(t,{limit:n}),Yo(t),Ao(e)]),nn(e,!0)}const Kf=rd;function zf(e){var s,o,a;const t=jl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((a=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:a.trim())||"main"}function qf(e,t){const n=rs(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Ao(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=zf(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=qf(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),o=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const L={messageSquare:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,unlink:u`<svg viewBox="0 0 24 24"><path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" x2="8" y1="2" y2="5"/><line x1="2" x2="5" y1="8" y2="8"/><line x1="16" x2="16" y1="19" y2="22"/><line x1="19" x2="22" y1="16" y2="16"/></svg>`,radio:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:u`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:u`<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:u`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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>`,globeOff:u`<svg viewBox="0 0 24 24"><path d="M21.54 15H17"/><path d="M7 3.34V5a3 3 0 0 0 3 3 2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17"/><path d="M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05"/><circle cx="12" cy="12" r="10"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,image:u`<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:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,puzzle:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,mic:u`<svg viewBox="0 0 24 24"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>`,chevronDown:u`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:u`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`,wifi:u`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M2 8.82a15 15 0 0 1 20 0"/><path d="M5 12.859a10 10 0 0 1 14 0"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/></svg>`,wifiOff:u`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/><path d="M5 12.859a10 10 0 0 1 5.17-2.69"/><path d="M13.41 10.28a10 10 0 0 1 5.59 2.58"/><path d="M2 8.82a15 15 0 0 1 4.17-2.65"/><path d="M10.66 5c4.01-.36 8.14.9 11.34 3.76"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,power:u`<svg viewBox="0 0 24 24"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"/><line x1="12" x2="12" y1="2" y2="12"/></svg>`,powerOff:u`<svg viewBox="0 0 24 24"><path d="M18.36 6.64A9 9 0 0 1 20.77 15"/><path d="M6.16 6.16a9 9 0 1 0 12.68 12.68"/><path d="M12 2v4"/><path d="m2 2 20 20"/></svg>`},Hf=u`<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>`,jf=u`<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>`,Gf=u`<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.36 6.64a9 9 0 1 1-12.73 0"></path><line x1="12" y1="2" x2="12" y2="12"></line></svg>`;let _r=!1;function Vf(){_r||(_r=!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 Rt(e,t){var d;const n=(p,g)=>p===e?u`<span class="sp-page-nav-current">${p}</span>`:u`<a href=${g}>${p}</a>`,i=u`
19
+ `],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-session-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function dh(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:i}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${i}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function ct(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Et(e){return`${JSON.stringify(e,null,2).trimEnd()}
20
+ `}function lc(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const a=t[o],r=t[o+1];if(typeof a=="number"){if(!Array.isArray(i))return;i[a]==null&&(i[a]=typeof r=="number"?[]:{}),i=i[a]}else{if(typeof i!="object"||i==null)return;const c=i;c[a]==null&&(c[a]=typeof r=="number"?[]:{}),i=c[a]}}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(i)&&(i[s]=n);return}typeof i=="object"&&i!=null&&(i[s]=n)}async function Ue(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});ph(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function cc(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});uh(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function uh(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function ph(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=ct(t.config??{}),e.configFormOriginal=ct(t.config??{}),e.configRawOriginal=n)}async function hh(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,i=(t=e.configSnapshot)==null?void 0:t.hash;if(!i){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:n,baseHash:i}),e.configFormDirty=!1,await Ue(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function sn(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 jn(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),e.accountId&&(t.accountId=e.accountId);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 dc(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=Ni(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const i=e.everyUnit;return{kind:"every",everyMs:n*(i==="minutes"?6e4:i==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function uc(e){if(e.payloadKind==="systemEvent"){const o=e.payloadText.trim();if(!o)throw new Error("System event text required.");return{kind:"systemEvent",text:o}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel);const i=[];e.toAdmins&&i.push("admins");for(const o of e.recipients){const a=o.trim();a&&i.push(a)}i.length>0&&(n.to=i.join(","));const s=Ni(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function fh(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=dc(e.cronForm),i=uc(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),a={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:o||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!a.name)throw new Error("Name required.");await e.client.request("cron.add",a),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await jn(e),await sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function gh(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 jn(e),await sn(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function mh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null,e.cronRunModalJobId=t.id,e.cronRunModalJobName=t.name||"Untitled",e.cronRunResult=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await ko(e,t.id)}catch(n){e.cronError=String(n),e.cronRunResult={status:"error",error:String(n)}}finally{e.cronBusy=!1}}}function yh(e,t){e.cronRunModalJobId&&t.jobId===e.cronRunModalJobId&&t.action==="finished"&&(e.cronRunResult={status:t.status??"unknown",durationMs:t.durationMs,summary:t.summary,error:t.error})}async function vh(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 jn(e),await sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function bh(e){var n;const t={name:e.name||"",description:e.description||"",agentId:e.agentId||"",enabled:e.enabled,scheduleKind:e.schedule.kind,scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"",cronTz:"",sessionTarget:e.sessionTarget||"main",wakeMode:e.wakeMode||"next-heartbeat",payloadKind:e.payload.kind,payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};if(e.schedule.kind==="at"){const i=new Date(e.schedule.atMs),s=o=>String(o).padStart(2,"0");t.scheduleAt=`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}T${s(i.getHours())}:${s(i.getMinutes())}`}else if(e.schedule.kind==="every"){const i=e.schedule.everyMs;i%864e5===0?(t.everyAmount=String(i/864e5),t.everyUnit="days"):i%36e5===0?(t.everyAmount=String(i/36e5),t.everyUnit="hours"):(t.everyAmount=String(i/6e4),t.everyUnit="minutes")}else e.schedule.kind==="cron"&&(t.cronExpr=e.schedule.expr,t.cronTz=e.schedule.tz||"");if(e.payload.kind==="systemEvent")t.payloadText=e.payload.text;else if(e.payload.kind==="agentTurn"){t.payloadText=e.payload.message,t.deliver=e.payload.deliver??!1,t.timeoutSeconds=e.payload.timeoutSeconds?String(e.payload.timeoutSeconds):"";const i=e.payload.channel??e.payload.provider;t.channel=i||"last";const s=e.payload.to||"";if(s){const o=s.split(",").map(a=>a.trim()).filter(Boolean);t.toAdmins=o.some(a=>a.toLowerCase()==="admins"),t.recipients=o.filter(a=>a.toLowerCase()!=="admins")}}return(n=e.isolation)!=null&&n.postToMainPrefix&&(t.postToMainPrefix=e.isolation.postToMainPrefix),t}async function wh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=dc(e.cronForm),i=uc(e.cronForm),s={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:e.cronForm.agentId.trim()||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i};if(e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?s.isolation={postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:s.isolation=void 0,!s.name)throw new Error("Name required.");await e.client.request("cron.update",{id:t,patch:s}),await jn(e),await sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function ko(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 ee(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 ea(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const i=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=i.message??null,e.whatsappLoginQrDataUrl=i.qrDataUrl??null,e.whatsappLoginConnected=null}catch(i){e.whatsappLoginMessage=String(i),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function pc(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 hc(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 fc(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const i=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!i){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const o=ct(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const a=o.channels;(!a.whatsapp||typeof a.whatsapp!="object")&&(a.whatsapp={});const r=a.whatsapp;(!r.accounts||typeof r.accounts!="object")&&(r.accounts={});const c=r.accounts;if(c[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}c[i]={name:n,provider:"baileys"};const d=s.hash;if(!d){e.whatsappAccountError="Config hash missing; reload and retry.";return}const h=Et(o);await e.client.request("config.set",{raw:h,baseHash:d}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await ee(e,!0),await ea(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function gc(e,t){if(!(!e.client||!e.connected)&&!e.whatsappAccountSaving){e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=ct(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,a=o==null?void 0:o.accounts;if(!a){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(a).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!a[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete a[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(h=>{const l=h.match;return!l||l.channel!=="whatsapp"?!0:l.accountId!==t}));const c=n.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const d=Et(i);await e.client.request("config.set",{raw:d,baseHash:c}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await ee(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const kh=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:fc,loadChannels:ee,logoutWhatsApp:hc,removeWhatsAppAccount:gc,startWhatsAppLogin:ea,waitWhatsAppLogin:pc},Symbol.toStringTag,{value:"Module"}));async function ta(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,i,s]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const o=i;e.debugModels=Array.isArray(o==null?void 0:o.models)?o==null?void 0:o.models:[],e.debugHeartbeat=s}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const xh=2e3,$h=new Set(["trace","debug","info","warn","error","fatal"]);function Sh(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 Ah(e){if(typeof e!="string")return null;const t=e.toLowerCase();return $h.has(t)?t:null}function mc(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,i=typeof t.time=="string"?t.time:typeof(n==null?void 0:n.date)=="string"?n==null?void 0:n.date:null,s=Ah((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),o=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,a=Sh(o);let r=null;a&&(typeof a.subsystem=="string"?r=a.subsystem:typeof a.module=="string"&&(r=a.module)),!r&&o&&o.length<120&&(r=o);let c=null;return typeof t[1]=="string"?c=t[1]:!a&&typeof t[0]=="string"?c=t[0]:typeof t.message=="string"&&(c=t.message),{raw:e,time:i,level:s,subsystem:r,message:c??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Vt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const i=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),o=(Array.isArray(i.lines)?i.lines.filter(r=>typeof r=="string"):[]).map(mc),a=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=a?o:[...e.logsEntries,...o].slice(-xh),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const Ch=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Vt,parseLogLine:mc},Symbol.toStringTag,{value:"Module"}));const yc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:pe,n:Ci,Gx:Cr,Gy:Er,a:Os,d:Fs,h:Eh}=yc,Tt=32,na=64,Th=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},re=(e="")=>{const t=new Error(e);throw Th(t,re),t},_h=e=>typeof e=="bigint",Mh=e=>typeof e=="string",Ph=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",ut=(e,t,n="")=>{const i=Ph(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const a=n&&`"${n}" `,r=o?` of length ${t}`:"",c=i?`length=${s}`:`type=${typeof e}`;re(a+"expected Uint8Array"+r+", got "+c)}return e},rs=e=>new Uint8Array(e),vc=e=>Uint8Array.from(e),bc=(e,t)=>e.toString(16).padStart(t,"0"),wc=e=>Array.from(ut(e)).map(t=>bc(t,2)).join(""),je={_0:48,_9:57,A:65,F:70,a:97,f:102},Tr=e=>{if(e>=je._0&&e<=je._9)return e-je._0;if(e>=je.A&&e<=je.F)return e-(je.A-10);if(e>=je.a&&e<=je.f)return e-(je.a-10)},kc=e=>{const t="hex invalid";if(!Mh(e))return re(t);const n=e.length,i=n/2;if(n%2)return re(t);const s=rs(i);for(let o=0,a=0;o<i;o++,a+=2){const r=Tr(e.charCodeAt(a)),c=Tr(e.charCodeAt(a+1));if(r===void 0||c===void 0)return re(t);s[o]=r*16+c}return s},xc=()=>globalThis==null?void 0:globalThis.crypto,Ih=()=>{var e;return((e=xc())==null?void 0:e.subtle)??re("crypto.subtle must be defined, consider polyfill")},zn=(...e)=>{const t=rs(e.reduce((i,s)=>i+ut(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},Lh=(e=Tt)=>xc().getRandomValues(rs(e)),Fi=BigInt,yt=(e,t,n,i="bad number: out of range")=>_h(e)&&t<=e&&e<n?e:re(i),D=(e,t=pe)=>{const n=e%t;return n>=0n?n:t+n},$c=e=>D(e,Ci),Rh=(e,t)=>{(e===0n||t<=0n)&&re("no inverse n="+e+" mod="+t);let n=D(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const a=i/n,r=i%n,c=s-o*a;i=n,n=r,s=o,o=c}return i===1n?D(s,t):re("no inverse")},Dh=e=>{const t=Ec[e];return typeof t!="function"&&re("hashes."+e+" not set"),t},Us=e=>e instanceof _t?e:re("Point expected"),xo=2n**256n,Ne=class Ne{constructor(t,n,i,s){H(this,"X");H(this,"Y");H(this,"Z");H(this,"T");const o=xo;this.X=yt(t,0n,o),this.Y=yt(n,0n,o),this.Z=yt(i,1n,o),this.T=yt(s,0n,o),Object.freeze(this)}static CURVE(){return yc}static fromAffine(t){return new Ne(t.x,t.y,1n,D(t.x*t.y))}static fromBytes(t,n=!1){const i=Fs,s=vc(ut(t,Tt)),o=t[31];s[31]=o&-129;const a=Ac(s);yt(a,0n,n?xo:pe);const c=D(a*a),d=D(c-1n),h=D(i*c+1n);let{isValid:l,value:p}=Nh(d,h);l||re("bad point: y not sqrt");const g=(p&1n)===1n,$=(o&128)!==0;return!n&&p===0n&&$&&re("bad point: x==0, isLastByteOdd"),$!==g&&(p=D(-p)),new Ne(p,a,1n,D(p*a))}static fromHex(t,n){return Ne.fromBytes(kc(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Os,n=Fs,i=this;if(i.is0())return re("bad point: ZERO");const{X:s,Y:o,Z:a,T:r}=i,c=D(s*s),d=D(o*o),h=D(a*a),l=D(h*h),p=D(c*t),g=D(h*D(p+d)),$=D(l+D(n*D(c*d)));if(g!==$)return re("bad point: equation left != right (1)");const S=D(s*o),T=D(a*r);return S!==T?re("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:a,Z:r}=Us(t),c=D(n*r),d=D(o*s),h=D(i*r),l=D(a*s);return c===d&&h===l}is0(){return this.equals(jt)}negate(){return new Ne(D(-this.X),this.Y,this.Z,D(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=Os,o=D(t*t),a=D(n*n),r=D(2n*D(i*i)),c=D(s*o),d=t+n,h=D(D(d*d)-o-a),l=c+a,p=l-r,g=c-a,$=D(h*p),S=D(l*g),T=D(h*g),f=D(p*l);return new Ne($,S,f,T)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:r,Z:c,T:d}=Us(t),h=Os,l=Fs,p=D(n*a),g=D(i*r),$=D(o*l*d),S=D(s*c),T=D((n+i)*(a+r)-p-g),f=D(S-$),b=D(S+$),k=D(g-h*p),A=D(T*f),E=D(b*k),M=D(T*k),P=D(f*b);return new Ne(A,E,P,M)}subtract(t){return this.add(Us(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return jt;if(yt(t,1n,Ci),t===1n)return this;if(this.equals(Mt))return Vh(t).p;let i=jt,s=Mt;for(let o=this;t>0n;o=o.double(),t>>=1n)t&1n?i=i.add(o):n&&(s=s.add(o));return i}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:i}=this;if(this.equals(jt))return{x:0n,y:1n};const s=Rh(i,pe);D(i*s)!==1n&&re("invalid inverse");const o=D(t*s),a=D(n*s);return{x:o,y:a}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=Sc(n);return i[31]|=t&1n?128:0,i}toHex(){return wc(this.toBytes())}clearCofactor(){return this.multiply(Fi(Eh),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Ci/2n,!1).double();return Ci%2n&&(t=t.add(this)),t.is0()}};H(Ne,"BASE"),H(Ne,"ZERO");let _t=Ne;const Mt=new _t(Cr,Er,1n,D(Cr*Er)),jt=new _t(0n,1n,1n,0n);_t.BASE=Mt;_t.ZERO=jt;const Sc=e=>kc(bc(yt(e,0n,xo),na)).reverse(),Ac=e=>Fi("0x"+wc(vc(ut(e)).reverse())),Ie=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=pe;return n},Bh=e=>{const n=e*e%pe*e%pe,i=Ie(n,2n)*n%pe,s=Ie(i,1n)*e%pe,o=Ie(s,5n)*s%pe,a=Ie(o,10n)*o%pe,r=Ie(a,20n)*a%pe,c=Ie(r,40n)*r%pe,d=Ie(c,80n)*c%pe,h=Ie(d,80n)*c%pe,l=Ie(h,10n)*o%pe;return{pow_p_5_8:Ie(l,2n)*e%pe,b2:n}},_r=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Nh=(e,t)=>{const n=D(t*t*t),i=D(n*n*t),s=Bh(e*i).pow_p_5_8;let o=D(e*n*s);const a=D(t*o*o),r=o,c=D(o*_r),d=a===e,h=a===D(-e),l=a===D(-e*_r);return d&&(o=r),(h||l)&&(o=c),(D(o)&1n)===1n&&(o=D(-o)),{isValid:d||h,value:o}},$o=e=>$c(Ac(e)),ia=(...e)=>Ec.sha512Async(zn(...e)),Oh=(...e)=>Dh("sha512")(zn(...e)),Cc=e=>{const t=e.slice(0,Tt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Tt,na),i=$o(t),s=Mt.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},sa=e=>ia(ut(e,Tt)).then(Cc),Fh=e=>Cc(Oh(ut(e,Tt))),Uh=e=>sa(e).then(t=>t.pointBytes),Wh=e=>ia(e.hashable).then(e.finish),Kh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=$o(t),a=Mt.multiply(o).toBytes();return{hashable:zn(a,i,n),finish:d=>{const h=$c(o+$o(d)*s);return ut(zn(a,Sc(h)),na)}}},zh=async(e,t)=>{const n=ut(e),i=await sa(t),s=await ia(i.prefix,n);return Wh(Kh(i,s,n))},Ec={sha512Async:async e=>{const t=Ih(),n=zn(e);return rs(await t.digest("SHA-512",n.buffer))},sha512:void 0},Hh=(e=Lh(Tt))=>e,qh={getExtendedPublicKeyAsync:sa,getExtendedPublicKey:Fh,randomSecretKey:Hh},Ui=8,jh=256,Tc=Math.ceil(jh/Ui)+1,So=2**(Ui-1),Gh=()=>{const e=[];let t=Mt,n=t;for(let i=0;i<Tc;i++){n=t,e.push(n);for(let s=1;s<So;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Mr;const Pr=(e,t)=>{const n=t.negate();return e?n:t},Vh=e=>{const t=Mr||(Mr=Gh());let n=jt,i=Mt;const s=2**Ui,o=s,a=Fi(s-1),r=Fi(Ui);for(let c=0;c<Tc;c++){let d=Number(e&a);e>>=r,d>So&&(d-=o,e+=1n);const h=c*So,l=h,p=h+Math.abs(d)-1,g=c%2!==0,$=d<0;d===0?i=i.add(Pr(g,t[l])):n=n.add(Pr($,t[p]))}return e!==0n&&re("invalid wnaf"),{p:n,f:i}},Ws="taskmaster-device-identity-v1";function Ao(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function _c(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)s[o]=i.charCodeAt(o);return s}function Qh(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Mc(e){const t=await crypto.subtle.digest("SHA-256",e);return Qh(new Uint8Array(t))}async function Jh(){const e=qh.randomSecretKey(),t=await Uh(e);return{deviceId:await Mc(t),publicKey:Ao(t),privateKey:Ao(e)}}async function Yh(){try{const n=localStorage.getItem(Ws);if(n){const i=JSON.parse(n);if((i==null?void 0:i.version)===1&&typeof i.deviceId=="string"&&typeof i.publicKey=="string"&&typeof i.privateKey=="string"){const s=await Mc(_c(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(Ws,JSON.stringify(o)),{deviceId:s,publicKey:i.publicKey,privateKey:i.privateKey}}return{deviceId:i.deviceId,publicKey:i.publicKey,privateKey:i.privateKey}}}}catch{}const e=await Jh(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Ws,JSON.stringify(t)),e}async function Xh(e,t){const n=_c(e),i=new TextEncoder().encode(t),s=await zh(i,n);return Ao(s)}const Pc="taskmaster.device.auth.v1";function oa(e){return e.trim()}function Zh(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const i=n.trim();i&&t.add(i)}return[...t].sort()}function aa(){try{const e=window.localStorage.getItem(Pc);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 Ic(e){try{window.localStorage.setItem(Pc,JSON.stringify(e))}catch{}}function ef(e){const t=aa();if(!t||t.deviceId!==e.deviceId)return null;const n=oa(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function tf(e){const t=oa(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=aa();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:Zh(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Ic(n),s}function nf(e){const t=aa();if(!t||t.deviceId!==e.deviceId)return;const n=oa(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Ic(i)}async function ra(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 la(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 sf(e){return{method:"exec.approvals.get",params:{}}}async function of(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=sf(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);af(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function af(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=ct(t.file??{}))}async function Lc(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 dt(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function Ze(e){return e instanceof Error?e.message:String(e)}function Hn(){return{name:"",skillContent:"",references:[]}}async function Xe(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=Ze(n)}finally{e.skillsLoading=!1}}}function Rc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Dc(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 Xe(e),dt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=Ze(i);e.skillsError=s,dt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Bc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const n=e.skillEdits[t]??"";await e.client.request("skills.update",{skillKey:t,apiKey:n}),await Xe(e),dt(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=Ze(n);e.skillsError=i,dt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Nc(e,t,n,i){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const s=await e.client.request("skills.install",{name:n,installId:i,timeoutMs:12e4});await Xe(e),dt(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=Ze(s);e.skillsError=o,dt(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}async function Oc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});n&&(e.skillDetail=n,e.skillDetailTab="SKILL.md")}catch(n){e.skillsError=Ze(n)}}function Fc(e){e.skillDetail=null,e.skillDetailTab=""}function Uc(e,t){e.skillDetailTab=t}async function Wc(e){if(e.skillAddModal=!0,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[],!(!e.client||!e.connected))try{const t=await e.client.request("skills.drafts",{});t&&(e.skillDrafts=t.drafts)}catch{}}function Kc(e){e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[]}function zc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))},e.skillAddFormSource="draft"}async function Hc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))},e.skillAddFormSource="installed",await ca(e)}async function ca(e){if(!e.client||!e.connected)return;const t=e.skillAddForm;if(!(!t.name.trim()||!t.skillContent.trim())){e.skillsBusyKey="__add__",e.skillsError=null;try{const n=t.references.filter(s=>s.name.trim()&&s.content.trim()).map(s=>({name:s.name.trim(),content:s.content})),i=t.name.trim();e.skillAddFormSource==="installed"?(await e.client.request("skills.create",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],await Xe(e),dt(e,i,{kind:"success",message:"Skill saved — active on next message"})):(await e.client.request("skills.saveDraft",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=Hn(),e.skillAddFormSource="draft",e.skillDrafts=[],dt(e,i,{kind:"success",message:"Draft saved"}))}catch(n){e.skillsError=Ze(n)}finally{e.skillsBusyKey=null}}}async function qc(e,t){if(!(!e.client||!e.connected))try{await e.client.request("skills.deleteDraft",{name:t}),e.skillDrafts=e.skillDrafts.filter(n=>n.name!==t)}catch(n){e.skillsError=Ze(n)}}async function jc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});if(!n)return;e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i}))},e.skillAddFormSource="installed",e.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=Ze(n)}}function Gc(e,t){const n=e.skillDetail;n&&(e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i}))},e.skillAddFormSource="installed",e.skillEditTab=t&&t!=="SKILL.md"?t:"SKILL.md",e.skillDetail=null,e.skillDetailTab="",e.skillAddModal=!0,e.skillDrafts=[])}function Vc(e,t,n){e.skillAddForm={...e.skillAddForm,references:e.skillAddForm.references.map(i=>i.name===t?{...i,content:n}:i)}}function Qc(e,t){e.skillEditTab=t}async function Jc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await Xe(e)}catch(n){e.skillsError=Ze(n)}finally{e.skillsBusyKey=null}}}const rf=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:Kc,closeSkillDetail:Fc,deleteDraft:qc,deleteSkill:Jc,editDetailSkill:Gc,editSkill:jc,emptyAddForm:Hn,importDraft:zc,installDraft:Hc,installSkill:Nc,loadSkills:Xe,openAddSkillModal:Wc,saveNewSkill:ca,saveSkillApiKey:Bc,setEditTab:Qc,setSkillDetailTab:Uc,updateFormReference:Vc,updateSkillEdit:Rc,updateSkillEnabled:Dc,viewSkillDetail:Oc},Symbol.toStringTag,{value:"Module"})),Yc={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},Xc=new Map(Object.entries(Yc).map(([e,t])=>[t,e]));function ls(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function qn(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 lf(e,t=""){const n=ls(t),i=Yc[e];return n?`${n}${i}`:i}function Zc(e,t=""){const n=ls(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=qn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":Xc.get(s)??null}function cf(e){let t=qn(e);if(t.endsWith("/index.html")&&(t=qn(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let i=0;i<n.length;i++){const s=`/${n.slice(i).join("/")}`.toLowerCase();if(Xc.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function df(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function da(e){return e==="system"?df():e}const ui=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,uf=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,pi=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},pf=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var d;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,a=s,r=uf();if(!!a.startViewTransition&&!r){let h=.5,l=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")h=ui(n.pointerClientX/window.innerWidth),l=ui(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(h=ui((p.left+p.width/2)/window.innerWidth),l=ui((p.top+p.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${h*100}%`),o.style.setProperty("--theme-switch-y",`${l*100}%`),o.classList.add("theme-transition");try{const p=(d=a.startViewTransition)==null?void 0:d.call(a,()=>{t()});p!=null&&p.finished?p.finished.finally(()=>pi(o)):pi(o)}catch{pi(o),t()}return}t(),pi(o)},hf=2e3;async function Pn(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const n={cursors:t!=null&&t.reset?void 0:e.sessionLogsCursors,limit:500};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(n.agents=e.workspaceAgentIds);const s=await e.client.request("sessions.transcript",n),o=Array.isArray(s.entries)?s.entries:[],a=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=a?o:[...e.sessionLogsEntries,...o].slice(-hf),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 ed=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:Pn},Symbol.toStringTag,{value:"Module"}));async function td(e,t){if(!(!e.client||!e.connected))try{const n={},i=await e.client.request("memory.audit",n);i!=null&&i.ok&&(e.auditEntries=i.entries??[])}catch{}}async function ff(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function We(e){return e instanceof Error?e.message:String(e)}let hi=null;function on(e,t){hi&&clearTimeout(hi),e.filesMessage={kind:"success",text:t},hi=setTimeout(()=>{e.filesMessage=null,hi=null},3e3)}async function an(e,t){if(!(!e.client||!e.connected)){if(!t){e.filesTree=[],e.filesRoot="";return}if(!e.filesLoading){e.filesLoading=!0,e.filesError=null;try{const n={};t&&(n.agentId=t);const i=await e.client.request("files.tree",n);i!=null&&i.tree&&(e.filesTree=i.tree,e.filesRoot=i.root??"")}catch(n){e.filesError=We(n)}finally{e.filesLoading=!1}}}}async function gf(e,t,n){e.filesSelectedPaths=new Set([t]),await nd(e,t,n)}async function mf(e,t,n){const i=new Set(e.filesSelectedPaths);if(i.has(t)?i.delete(t):i.add(t),e.filesSelectedPaths=i,i.size===1){const s=[...i][0];await nd(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function yf(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let i=0,s="";for(const o of n)try{await id(e,o,t),i++}catch(a){s=We(a)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:on(e,`${i} file${i!==1?"s":""} downloaded`)}async function vf(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await xf(e,t,o,i)}async function nd(e,t,n){if(!(!e.client||!e.connected)){e.filesSelectedPath=t,e.filesPreviewLoading=!0,e.filesPreviewContent=null,e.filesPreviewBinary=!1,e.filesPreviewSize=null;try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.read",i);e.filesPreviewContent=(s==null?void 0:s.content)??null,e.filesPreviewBinary=(s==null?void 0:s.binary)??!1,e.filesPreviewSize=(s==null?void 0:s.size)??null}catch(i){e.filesError=We(i)}finally{e.filesPreviewLoading=!1}}}async function id(e,t,n){if(!(!e.client||!e.connected))try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.download",i);if(!(s!=null&&s.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(s.base64),d=>d.charCodeAt(0)),a=new Blob([o]),r=URL.createObjectURL(a),c=document.createElement("a");c.href=r,c.download=s.name??t.split("/").pop()??"download",document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(r)}catch(i){e.filesMessage={kind:"error",text:We(i)}}}async function bf(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const a of n)try{const r=await a.arrayBuffer(),c=btoa(new Uint8Array(r).reduce((h,l)=>h+String.fromCharCode(l),"")),d={path:t,name:a.name,data:c};i&&(d.agentId=i),await e.client.request("files.upload",d),s++}catch(r){o=We(r)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:on(e,`${s} file${s!==1?"s":""} uploaded`),await an(e,i)}async function wf(e,t,n,i){if(!e.client||!e.connected)return;e.filesMessage=null;const s=t==="."?n:`${t}/${n}`;try{const o={path:s};i&&(o.agentId=i),await e.client.request("files.mkdir",o),on(e,`Created ${s}`),await an(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:We(o)}}}async function kf(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={path:t};n&&(i.agentId=n),await e.client.request("files.delete",i),on(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await an(e,n)}catch(i){e.filesMessage={kind:"error",text:We(i)}}}}async function xf(e,t,n,i){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={from:t,to:n};i&&(s.agentId=i),await e.client.request("files.move",s),on(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await an(e,i)}catch(s){e.filesMessage={kind:"error",text:We(s)}}}}async function cs(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const i=await e.client.request("memory.status",n);i!=null&&i.ok&&(e.filesMemoryStatus={dirty:i.dirty??!1,syncing:i.syncing,syncProgress:i.syncProgress,files:i.files??0,chunks:i.chunks??0,model:i.model,embeddingState:i.embeddingState})}catch{}}async function $f(e,t){if(!(!e.client||!e.connected)&&!e.filesReindexBusy){e.filesReindexBusy=!0,e.filesMessage=null;try{const n={force:!0};t&&(n.agentId=t);const i=await e.client.request("memory.reindex",n),s=(i==null?void 0:i.files)??0,o=(i==null?void 0:i.chunks)??0;on(e,`Re-indexed: ${s} files, ${o} chunks`),await cs(e,t)}catch(n){e.filesMessage={kind:"error",text:We(n)}}finally{e.filesReindexBusy=!1}}}function Sf(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n,e.filesCurrentDir=t}async function Af(e,t,n){if(!(!e.client||!e.connected)){if(!t.trim()){e.filesSearchResults=null;return}e.filesSearchLoading=!0,e.filesSearchResults=null;try{const i={query:t.trim(),maxResults:20};n&&(i.agentId=n);const s=await e.client.request("memory.search",i);e.filesSearchResults=(s==null?void 0:s.results)??[]}catch(i){e.filesMessage={kind:"error",text:We(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function Cf(e){e.filesSearchQuery="",e.filesSearchResults=null}function Ef(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{la(e,{quiet:!0})},5e3))}function Tf(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function ua(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Vt(e,{quiet:!0})},2e3))}function pa(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function ha(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||Pn(e,{quiet:!0})},2e3))}function fa(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function ga(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ta(e)},3e3))}function ma(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function _f(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{td(e)},3e4))}function Mf(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function Pf(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{const t=e;t.filesPage&&cs(t,t.filesResolvedAgentId)},3e3))}function If(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function rt(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,Cp(n),t.theme!==e.theme&&(e.theme=t.theme,ds(e,da(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function sd(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&rt(e,{...e.settings,lastActiveSessionKey:n})}function Lf(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),i=t.get("password"),s=t.get("session"),o=t.get("gatewayUrl");let a=!1;if(n!=null){const c=n.trim();c&&c!==e.settings.token&&rt(e,{...e.settings,token:c}),t.delete("token"),a=!0}if(i!=null){const c=i.trim();c&&(e.password=c),t.delete("password"),a=!0}if(s!=null){const c=s.trim();c&&(e.sessionKey=c,rt(e,{...e.settings,sessionKey:c,lastActiveSessionKey:c}))}if(o!=null){const c=o.trim();c&&c!==e.settings.gatewayUrl&&rt(e,{...e.settings,gatewayUrl:c}),t.delete("gatewayUrl"),a=!0}if(!a)return;const r=new URL(window.location.href);r.search=t.toString(),window.history.replaceState({},"",r.toString())}function Rf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ha(e):ua(e):(pa(e),fa(e)),t==="debug"?ga(e):ma(e),Wi(e),ad(e,t,!1)}function Df(e,t,n){pf({nextTheme:t,applyTheme:()=>{e.theme=t,rt(e,{...e.settings,theme:t}),ds(e,da(t))},context:n,currentTheme:e.theme})}async function Wi(e){if(e.tab==="overview"&&await rd(e),e.tab==="channels"&&await Kf(e),e.tab==="instances"&&await Lc(e),e.tab==="cron"&&await ya(e),e.tab==="skills"&&await Xe(e),e.tab==="nodes"&&(await la(e),await ra(e),await Ue(e),await of(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await Gf(e),nn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await cc(e),await Ue(e)),e.tab==="debug"&&(await ta(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await ae(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>ed);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Vt(e,{reset:!0});rc(e,!0)}}function Bf(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?ls(e):cf(window.location.pathname)}function Nf(e){e.theme=e.settings.theme??"system",ds(e,da(e.theme))}function ds(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function Of(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"&&ds(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Ff(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 Uf(e,t){if(typeof window>"u")return;const n=Zc(window.location.pathname,e.basePath)??"chat";od(e,n),ad(e,n,t)}function Wf(e){var s;if(typeof window>"u")return;const t=Zc(window.location.pathname,e.basePath);if(!t)return;const i=(s=new URL(window.location.href).searchParams.get("session"))==null?void 0:s.trim();i&&(e.sessionKey=i,rt(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),od(e,t)}function od(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?ha(e):ua(e):(pa(e),fa(e)),t==="debug"?ga(e):ma(e),e.connected&&Wi(e)}function ad(e,t,n){if(typeof window>"u")return;const i=qn(lf(t,e.basePath)),s=qn(window.location.pathname),o=new URL(window.location.href);t==="chat"&&e.sessionKey?o.searchParams.set("session",e.sessionKey):o.searchParams.delete("session"),s!==i&&(o.pathname=i),n?window.history.replaceState({},"",o.toString()):window.history.pushState({},"",o.toString())}async function rd(e){await Promise.all([ee(e,!1),Lc(e),Xo(e),sn(e),ta(e)])}async function Kf(e){await Promise.all([ee(e,!0),cc(e),Ue(e)])}async function ya(e){await Promise.all([ee(e,!1),sn(e),jn(e)])}function ld(e){return e.chatSending||!!e.chatRunId}function zf(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 cd(e){e.connected&&(e.chatMessage="",await oc(e))}function Hf(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:as(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],nn(e))}async function dd(e,t,n){var s,o;Zo(e);const i=await sc(e,t,n==null?void 0:n.attachments);return!i&&(n==null?void 0:n.previousDraft)!=null&&(e.chatMessage=n.previousDraft),!i&&(n!=null&&n.previousAttachments)&&(e.chatAttachments=n.previousAttachments),i&&sd(e,e.sessionKey),i&&(n!=null&&n.restoreDraft)&&((s=n.previousDraft)!=null&&s.trim())&&(e.chatMessage=n.previousDraft),i&&(n!=null&&n.restoreAttachments)&&((o=n.previousAttachments)!=null&&o.length)&&(e.chatAttachments=n.previousAttachments),nn(e),i&&!e.chatRunId&&ud(e),i}async function ud(e){if(!e.connected||ld(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await dd(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function qf(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function jf(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],a=t==null?o:[],r=a.length>0;if(!(!s&&!r)){if(zf(s)){await cd(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[],Tp(e.selectedWorkspace??"",e.sessionKey)),ld(e)){Hf(e,s,a);return}await dd(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:r?a:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function Gf(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,Fe);await Promise.all([Oe(t,{limit:n}),Xo(t),Co(e)]),nn(e,!0)}const Vf=ud;function Qf(e){var s,o,a;const t=Jl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((a=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:a.trim())||"main"}function Jf(e,t){const n=ls(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Co(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Qf(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Jf(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),o=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const L={messageSquare:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,unlink:u`<svg viewBox="0 0 24 24"><path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" x2="8" y1="2" y2="5"/><line x1="2" x2="5" y1="8" y2="8"/><line x1="16" x2="16" y1="19" y2="22"/><line x1="19" x2="22" y1="16" y2="16"/></svg>`,radio:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:u`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:u`<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:u`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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>`,globeOff:u`<svg viewBox="0 0 24 24"><path d="M21.54 15H17"/><path d="M7 3.34V5a3 3 0 0 0 3 3 2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17"/><path d="M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05"/><circle cx="12" cy="12" r="10"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,image:u`<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:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,puzzle:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,mic:u`<svg viewBox="0 0 24 24"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>`,chevronDown:u`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:u`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`,wifi:u`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M2 8.82a15 15 0 0 1 20 0"/><path d="M5 12.859a10 10 0 0 1 14 0"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/></svg>`,wifiOff:u`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/><path d="M5 12.859a10 10 0 0 1 5.17-2.69"/><path d="M13.41 10.28a10 10 0 0 1 5.59 2.58"/><path d="M2 8.82a15 15 0 0 1 4.17-2.65"/><path d="M10.66 5c4.01-.36 8.14.9 11.34 3.76"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,power:u`<svg viewBox="0 0 24 24"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"/><line x1="12" x2="12" y1="2" y2="12"/></svg>`,powerOff:u`<svg viewBox="0 0 24 24"><path d="M18.36 6.64A9 9 0 0 1 20.77 15"/><path d="M6.16 6.16a9 9 0 1 0 12.68 12.68"/><path d="M12 2v4"/><path d="m2 2 20 20"/></svg>`},Yf=u`<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>`,Xf=u`<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>`,Zf=u`<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.36 6.64a9 9 0 1 1-12.73 0"></path><line x1="12" y1="2" x2="12" y2="12"></line></svg>`;let Ir=!1;function eg(){Ir||(Ir=!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 Rt(e,t){var l;const n=(p,g)=>p===e?u`<span class="sp-page-nav-current">${p}</span>`:u`<a href=${g}>${p}</a>`,i=u`
21
21
  ${n("Setup","/setup")}
22
22
  ${n("Chat","/chat")}
23
23
  ${n("Admins","/admins")}
@@ -25,20 +25,20 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
25
25
  ${n("Files","/files")}
26
26
  ${n("Browser","/browser")}
27
27
  ${n("Advanced","/advanced")}
28
- `,o=t&&(t.isMaster!==!1||!t.hasPins)?Jf(t):w,a=t!=null&&t.hasPins&&t.onLogout?u`<button class="nav-logout-btn" @click=${t.onLogout} title="Lock">${Hf}</button>`:w,r=t!=null&&t.onRestartGateway?Qf(t.onRestartGateway):w,l=(t==null?void 0:t.auditCount)??0,c=l>0&&(t!=null&&t.onAuditClick)?u`<button class="nav-audit-btn" @click=${t.onAuditClick} title="Memory writes to review">
29
- ${jf}
30
- <span class="nav-audit-badge">${l>99?"99+":l}</span>
31
- </button>`:w,h=()=>{const p=document.getElementById("nav-burger-toggle");p&&(p.checked=!1)};return Vf(),u`
28
+ `,o=t&&(t.isMaster!==!1||!t.hasPins)?ng(t):w,a=t!=null&&t.hasPins&&t.onLogout?u`<button class="nav-logout-btn" @click=${t.onLogout} title="Lock">${Yf}</button>`:w,r=t!=null&&t.onRestartGateway?tg(t.onRestartGateway):w,c=(t==null?void 0:t.auditCount)??0,d=c>0&&(t!=null&&t.onAuditClick)?u`<button class="nav-audit-btn" @click=${t.onAuditClick} title="Memory writes to review">
29
+ ${Xf}
30
+ <span class="nav-audit-badge">${c>99?"99+":c}</span>
31
+ </button>`:w,h=()=>{const p=document.getElementById("nav-burger-toggle");p&&(p.checked=!1)};return eg(),u`
32
32
  <div class="setup-header">
33
33
  <input type="checkbox" id="nav-burger-toggle" class="nav-burger-checkbox" />
34
34
  <div class="setup-header-inner">
35
- <img class="setup-header-logo" src="${(t==null?void 0:t.selectedWorkspace)&&((d=Be()[t.selectedWorkspace])==null?void 0:d.logoUrl)||Ye().iconUrl}" alt="${Ye().name}" />
35
+ <img class="setup-header-logo" src="${(t==null?void 0:t.selectedWorkspace)&&((l=Be()[t.selectedWorkspace])==null?void 0:l.logoUrl)||Ye().iconUrl}" alt="${Ye().name}" />
36
36
  <nav class="setup-header-nav">
37
37
  ${i}
38
38
  </nav>
39
39
  <div class="setup-header-right">
40
40
  ${o!==w?u`<span class="nav-selector-inline">${o}</span>`:w}
41
- ${c}
41
+ ${d}
42
42
  ${a}
43
43
  ${r}
44
44
  <label for="nav-burger-toggle" class="nav-burger-button" aria-label="Toggle menu">
@@ -51,10 +51,10 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
51
51
  ${i}
52
52
  </nav>
53
53
  </div>
54
- `}function Qf(e){let t=!1;return u`
54
+ `}function tg(e){let t=!1;return u`
55
55
  <span class="nav-restart-container" style="position: relative;">
56
- <button class="nav-restart-btn" @click=${o=>{const r=o.currentTarget.closest(".nav-restart-container");if(!r)return;const l=r.querySelector(".nav-restart-confirm");l&&(t=!t,l.style.display=t?"flex":"none")}} title="Restart gateway">
57
- ${Gf}
56
+ <button class="nav-restart-btn" @click=${o=>{const r=o.currentTarget.closest(".nav-restart-container");if(!r)return;const c=r.querySelector(".nav-restart-confirm");c&&(t=!t,c.style.display=t?"flex":"none")}} title="Restart gateway">
57
+ ${Zf}
58
58
  </button>
59
59
  <div class="nav-restart-confirm" style="display: none;">
60
60
  <p>Restart the gateway?</p>
@@ -64,7 +64,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
64
64
  </div>
65
65
  </div>
66
66
  </span>
67
- `}function Jf(e){const{workspaces:t,selectedWorkspace:n,onWorkspaceSelect:i}=e;return u`
67
+ `}function ng(e){const{workspaces:t,selectedWorkspace:n,onWorkspaceSelect:i}=e;return u`
68
68
  <select
69
69
  class="sp-workspace-selector"
70
70
  .value=${n??""}
@@ -78,7 +78,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
78
78
  <option disabled>───</option>
79
79
  <option value="__add__">+ Add Account</option>
80
80
  </select>
81
- `}function Yf(e){return e.connected?e.fullscreen&&e.active?u`
81
+ `}function ig(e){return e.connected?e.fullscreen&&e.active?u`
82
82
  <div class="sp-fullscreen-overlay">
83
83
  <div class="sp-fullscreen-toolbar">
84
84
  <button
@@ -210,38 +210,38 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
210
210
  <p>Connecting to gateway...</p>
211
211
  </div>
212
212
  </div>
213
- `}const Wi="application/x-taskmaster-file-path";let gt=null;function ld(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function cd(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function Xf(e,t,n){var o,a;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const i=(o=e.dataTransfer)==null?void 0:o.getData(Wi);if(i){cd(i)!==t&&n.onMoveToDir(i,t);return}const s=(a=e.dataTransfer)==null?void 0:a.files;if(s&&s.length>0){const r=Array.from(s).filter(l=>l.name.toLowerCase().endsWith(".md"));r.length>0&&n.onUpload(t,r)}}function dd(e,t,n){var l;const i=e.type==="directory"||e.type==="symlink"&&e.children!=null,s=t.expandedDirs.has(e.path),o=t.selectedPaths.has(e.path),a=t.currentDir===e.path,r=n*20+12;return i?u`
213
+ `}const Ki="application/x-taskmaster-file-path";let gt=null;function pd(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function hd(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function sg(e,t,n){var o,a;e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const i=(o=e.dataTransfer)==null?void 0:o.getData(Ki);if(i){hd(i)!==t&&n.onMoveToDir(i,t);return}const s=(a=e.dataTransfer)==null?void 0:a.files;if(s&&s.length>0){const r=Array.from(s).filter(c=>c.name.toLowerCase().endsWith(".md"));r.length>0&&n.onUpload(t,r)}}function fd(e,t,n){var c;const i=e.type==="directory"||e.type==="symlink"&&e.children!=null,s=t.expandedDirs.has(e.path),o=t.selectedPaths.has(e.path),a=t.currentDir===e.path,r=n*20+12;return i?u`
214
214
  <div
215
215
  class="sp-tree-item sp-tree-dir ${s?"expanded":""} ${a?"current":""}"
216
216
  style="padding-left: ${r}px;"
217
217
  @click=${()=>t.onToggleDir(e.path)}
218
- @dragover=${c=>{c.preventDefault(),c.stopPropagation(),c.dataTransfer&&(c.dataTransfer.dropEffect="move"),c.currentTarget.classList.add("sp-drop-target")}}
219
- @dragleave=${c=>{c.currentTarget.classList.remove("sp-drop-target")}}
220
- @drop=${c=>Xf(c,e.path,t)}
218
+ @dragover=${d=>{d.preventDefault(),d.stopPropagation(),d.dataTransfer&&(d.dataTransfer.dropEffect="move"),d.currentTarget.classList.add("sp-drop-target")}}
219
+ @dragleave=${d=>{d.currentTarget.classList.remove("sp-drop-target")}}
220
+ @drop=${d=>sg(d,e.path,t)}
221
221
  >
222
222
  <span class="sp-tree-chevron">${s?"−":"+"}</span>
223
223
  <span class="sp-tree-icon">${L.folder}</span>
224
224
  <span class="sp-tree-name">${e.name}</span>
225
- ${s&&((l=e.children)==null?void 0:l.length)===0?u`<span
225
+ ${s&&((c=e.children)==null?void 0:c.length)===0?u`<span
226
226
  class="sp-tree-dir-delete"
227
227
  title="Delete empty folder"
228
- @click=${c=>{c.stopPropagation(),t.onDelete(e.path)}}
228
+ @click=${d=>{d.stopPropagation(),t.onDelete(e.path)}}
229
229
  >×</span>`:w}
230
230
  </div>
231
- ${s&&e.children?e.children.map(c=>dd(c,t,n+1)):w}
231
+ ${s&&e.children?e.children.map(d=>fd(d,t,n+1)):w}
232
232
  `:u`
233
233
  <div
234
234
  class="sp-tree-item sp-tree-file ${o?"selected":""}"
235
235
  style="padding-left: ${r}px;"
236
236
  draggable="true"
237
- @click=${c=>{c.metaKey||c.ctrlKey?t.onToggleSelectFile(e.path):t.onSelectFile(e.path)}}
238
- @dragstart=${c=>{c.dataTransfer&&(c.dataTransfer.effectAllowed="move",c.dataTransfer.setData(Wi,e.path),c.dataTransfer.setData("text/plain",e.name))}}
237
+ @click=${d=>{d.metaKey||d.ctrlKey?t.onToggleSelectFile(e.path):t.onSelectFile(e.path)}}
238
+ @dragstart=${d=>{d.dataTransfer&&(d.dataTransfer.effectAllowed="move",d.dataTransfer.setData(Ki,e.path),d.dataTransfer.setData("text/plain",e.name))}}
239
239
  >
240
240
  <span class="sp-tree-icon">${L.fileText}</span>
241
241
  <span class="sp-tree-name">${e.name}</span>
242
- <span class="sp-tree-size">${ld(e.size)}</span>
242
+ <span class="sp-tree-size">${pd(e.size)}</span>
243
243
  </div>
244
- `}function Zf(e){const t=e.selectedPaths.size;return t<2?w:u`
244
+ `}function og(e){const t=e.selectedPaths.size;return t<2?w:u`
245
245
  <div class="sp-bulk-actions">
246
246
  <span style="color: var(--tasker-muted-grey); font-size: 13px;">${t} files selected</span>
247
247
  <button
@@ -252,7 +252,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
252
252
  Download ${t} files
253
253
  </button>
254
254
  </div>
255
- `}function eg(e){if(e.selectedPaths.size!==1||!e.selectedPath)return w;if(e.previewLoading)return u`
255
+ `}function ag(e){if(e.selectedPaths.size!==1||!e.selectedPath)return w;if(e.previewLoading)return u`
256
256
  <div class="sp-file-preview">
257
257
  <div class="setup-spinner" style="width: 32px; height: 32px; margin: 24px auto;"></div>
258
258
  </div>
@@ -262,7 +262,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
262
262
  <div>
263
263
  <strong>${t}</strong>
264
264
  <div class="sp-file-preview-meta">
265
- ${e.selectedPath}${e.previewSize!=null?` — ${ld(e.previewSize)}`:""}
265
+ ${e.selectedPath}${e.previewSize!=null?` — ${pd(e.previewSize)}`:""}
266
266
  </div>
267
267
  </div>
268
268
  <div class="sp-file-actions">
@@ -276,7 +276,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
276
276
  </div>
277
277
  ${e.previewBinary?u`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">Binary file — use Download to view.</p></div>`:e.previewContent!=null?u`<div class="sp-file-preview-body"><pre class="sp-file-code">${e.previewContent}</pre></div>`:u`<div class="sp-file-preview-body"><p style="color: var(--tasker-muted-grey);">File too large for preview — use Download.</p></div>`}
278
278
  </div>
279
- `}function tg(e){return u`
279
+ `}function rg(e){return u`
280
280
  <div class="sp-search-bar">
281
281
  <input
282
282
  type="text"
@@ -308,7 +308,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
308
308
  Clear
309
309
  </button>`:w}
310
310
  </div>
311
- `}function ng(e){return e.searchResults?e.searchResults.length===0?u`<div class="sp-search-results">
311
+ `}function lg(e){return e.searchResults?e.searchResults.length===0?u`<div class="sp-search-results">
312
312
  <div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No results found.</div>
313
313
  </div>`:u`
314
314
  <div class="sp-search-results">
@@ -328,7 +328,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
328
328
  </div>
329
329
  `)}
330
330
  </div>
331
- `:w}function ig(e){const t=e.currentDir;return e.connected?u`
331
+ `:w}function cg(e){const t=e.currentDir;return e.connected?u`
332
332
  <div class="setup-container">
333
333
  ${Rt("Files",e.wsProps)}
334
334
  <div class="setup-card sp-card-wide">
@@ -380,7 +380,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
380
380
  class="setup-status-light"
381
381
  style="width: 10px; height: 10px; background: ${e.memoryStatus.syncing?"#f59e0b":e.memoryStatus.dirty?"#ef4444":"#22c55e"}"
382
382
  ></span>
383
- ${(()=>{var l;if(e.memoryStatus.syncing&&e.memoryStatus.syncProgress){const{completed:c,total:h,label:d}=e.memoryStatus.syncProgress;return d||(h>0?`Indexing ${c}/${h} files…`:"Indexing…")}const n=e.memoryStatus.files,i=e.memoryStatus.chunks,s=`${n} file${n!==1?"s":""}, ${i} chunks`,o=(l=e.memoryStatus)==null?void 0:l.model;if(!o)return s;const r=(o.includes("/")?o.split("/").pop():o).replace(/[-_]Q\d.*$/i,"").replace(/\.gguf$/i,"");return`${s} · ${r}`})()}
383
+ ${(()=>{var c;if(e.memoryStatus.syncing&&e.memoryStatus.syncProgress){const{completed:d,total:h,label:l}=e.memoryStatus.syncProgress;return l||(h>0?`Indexing ${d}/${h} files…`:"Indexing…")}const n=e.memoryStatus.files,i=e.memoryStatus.chunks,s=`${n} file${n!==1?"s":""}, ${i} chunks`,o=(c=e.memoryStatus)==null?void 0:c.model;if(!o)return s;const r=(o.includes("/")?o.split("/").pop():o).replace(/[-_]Q\d.*$/i,"").replace(/\.gguf$/i,"");return`${s} · ${r}`})()}
384
384
  </span>`:w}
385
385
  </div>
386
386
 
@@ -392,18 +392,18 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
392
392
 
393
393
  ${e.uploadBusy?u`<div style="margin-top: 12px; color: var(--tasker-orange); font-weight: 600; font-size: 14px;">Uploading...</div>`:w}
394
394
 
395
- ${tg(e)}
395
+ ${rg(e)}
396
396
 
397
- ${e.searchResults!==null?ng(e):u`<div
397
+ ${e.searchResults!==null?lg(e):u`<div
398
398
  class="sp-file-tree"
399
- @dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(Wi)?"move":"copy")}}
400
- @drop=${n=>{var o,a;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(Wi);if(i){cd(i)!=="."&&e.onMoveToDir(i,".");return}const s=(a=n.dataTransfer)==null?void 0:a.files;if(s&&s.length>0){const r=Array.from(s).filter(l=>l.name.toLowerCase().endsWith(".md"));r.length>0&&e.onUpload(t,r)}}}
399
+ @dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(Ki)?"move":"copy")}}
400
+ @drop=${n=>{var o,a;n.preventDefault();const i=(o=n.dataTransfer)==null?void 0:o.getData(Ki);if(i){hd(i)!=="."&&e.onMoveToDir(i,".");return}const s=(a=n.dataTransfer)==null?void 0:a.files;if(s&&s.length>0){const r=Array.from(s).filter(c=>c.name.toLowerCase().endsWith(".md"));r.length>0&&e.onUpload(t,r)}}}
401
401
  >
402
- ${e.tree.length===0&&!e.loading?u`<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=>dd(n,e,0))}
402
+ ${e.tree.length===0&&!e.loading?u`<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=>fd(n,e,0))}
403
403
  </div>`}
404
404
 
405
- ${Zf(e)}
406
- ${eg(e)}
405
+ ${og(e)}
406
+ ${ag(e)}
407
407
  </div>
408
408
  </div>
409
409
  `:u`
@@ -413,7 +413,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
413
413
  <p>Connecting to gateway...</p>
414
414
  </div>
415
415
  </div>
416
- `}const ya="taskmaster_uninstall_done";async function sg(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),og();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 Ki(){try{return localStorage.getItem(ya)==="1"}catch{return!1}}function va(){try{localStorage.removeItem(ya)}catch{}}function og(){try{localStorage.setItem(ya,"1")}catch{}}const Mr=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:Ki,clearUninstallDone:va,runUninstall:sg},Symbol.toStringTag,{value:"Module"}));function Q(e){return u`
416
+ `}const va="taskmaster_uninstall_done";async function dg(e){var t,n;if(!(!e.client||!e.connected)&&!e.uninstallBusy){e.uninstallBusy=!0,e.uninstallError=null,(t=e.requestUpdate)==null||t.call(e),ug();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 zi(){try{return localStorage.getItem(va)==="1"}catch{return!1}}function ba(){try{localStorage.removeItem(va)}catch{}}function ug(){try{localStorage.setItem(va,"1")}catch{}}const Lr=Object.freeze(Object.defineProperty({__proto__:null,checkUninstallDone:zi,clearUninstallDone:ba,runUninstall:dg},Symbol.toStringTag,{value:"Module"}));function Q(e){return u`
417
417
  <span
418
418
  class="setup-status-light"
419
419
  style="background: ${{good:"#22c55e",bad:"#ef4444",partial:"#eab308",unknown:"#6b7280"}[e]}"
@@ -426,7 +426,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
426
426
  >
427
427
  ${L.info}
428
428
  </button>
429
- `}function ag(e){var s;if(!e.infoModalOpen)return w;let t="",n=[],i=w;switch(e.infoModalOpen){case"gateway":{const o=typeof window<"u"?window.location.host:"unknown";t="Gateway",n=[{label:"Status",value:e.gatewayHealthy===!1?"Stopped":"Running"},{label:"What",value:"The core service that powers Taskmaster — handles AI conversations, message routing, and all connected channels"},{label:"Address",value:o},{label:"Health",value:e.gatewayHealthMessage||"OK"}];break}case"claude":{const o=e.authExpiresIn;let a="N/A";if(o!=null&&o>0)if(o>60){const r=Math.floor(o/60),l=o%60;a=l>0?`${r}h ${l}m`:`${r}h`}else a=`${o}m`;t="Claude",n=[{label:"Status",value:e.authConnected?"Connected":"Disconnected"},{label:"What",value:"Connection to Claude, the AI that powers natural conversation and tool use"},{label:"How",value:"Authenticated via OAuth — tokens refresh automatically when they expire"},{label:"Token Expiry",value:a},...e.authMessage?[{label:"Message",value:e.authMessage}]:[]];break}case"license":{const o=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"What",value:"Your Taskmaster license key, tied to this specific device"},{label:"Key",value:o},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A"}];break}case"whatsapp":{const o=rn(e),a=o?ba(o,e):null;t="WhatsApp",n=[{label:"Status",value:a!=null&&a.connected?"Connected":"Disconnected"},{label:"What",value:"WhatsApp integration — receive and respond to customer messages through WhatsApp"},{label:"How",value:"Links to your WhatsApp account by scanning a QR code, then routes messages to your AI assistant"},{label:"Account",value:(a==null?void 0:a.name)||(a==null?void 0:a.accountId)||"Default"},{label:"Phone",value:((s=a==null?void 0:a.self)==null?void 0:s.e164)||"Not paired"},{label:"Linked",value:a!=null&&a.linked?"Yes":"No"},...a!=null&&a.lastError?[{label:"Last Error",value:wa(a.lastError)}]:[]];break}case"imessage":{const{thisWsOwns:o}=ka(e);t="iMessage",n=[{label:"Status",value:o&&e.imessageConnected?"Connected":"Disconnected"},{label:"What",value:"iMessage integration — communicate with your AI assistant through Apple Messages"},{label:"How",value:"Uses the Mac's built-in Messages app; only one account can own the iMessage channel at a time"},{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:"Status",value:e.updateAvailable===null?"Not checked":e.updateAvailable?"Update available":"Up to date"},{label:"What",value:"Checks for new versions of Taskmaster and lets you update from the control panel"},{label:"Current",value:e.currentVersion?`v${e.currentVersion}`:"Unknown"},{label:"Latest",value:e.latestVersion?`v${e.latestVersion}`:"Unknown"},...e.updateMessage?[{label:"Message",value:e.updateMessage}]:[]];break}case"remote-access":{const o=e.tailscaleStatus,a=o?o.installed?o.loggedIn?o.serveEnabled&&o.serveActive?"Active":o.serveEnabled&&!o.serveActive?"Enabled but not active":"Off":"Not connected":"Not installed":"Checking...";if(t="Remote Access",n=[{label:"Status",value:a},{label:"What",value:"Access this control panel from anywhere — your phone, another computer, or while away from home"},{label:"How",value:"Uses Tailscale to create a private, encrypted connection with a trusted HTTPS certificate (no browser warnings)"},{label:"Requires",value:"Tailscale installed on this device and on any device you want to access the control panel from, all logged into the same Tailscale account"},{label:"Internet Access",value:"Enable internet access (globe icon) to make Public Chat reachable from the web"},{label:"Cost",value:"Tailscale is free for personal use (up to 100 devices)"}],o!=null&&o.tailnetUrl){const r=o.tailnetUrl;i=u`
429
+ `}function pg(e){var s;if(!e.infoModalOpen)return w;let t="",n=[],i=w;switch(e.infoModalOpen){case"gateway":{const o=typeof window<"u"?window.location.host:"unknown";t="Gateway",n=[{label:"Status",value:e.gatewayHealthy===!1?"Stopped":"Running"},{label:"What",value:"The core service that powers Taskmaster — handles AI conversations, message routing, and all connected channels"},{label:"Address",value:o},{label:"Health",value:e.gatewayHealthMessage||"OK"}];break}case"claude":{const o=e.authExpiresIn;let a="N/A";if(o!=null&&o>0)if(o>60){const r=Math.floor(o/60),c=o%60;a=c>0?`${r}h ${c}m`:`${r}h`}else a=`${o}m`;t="Claude",n=[{label:"Status",value:e.authConnected?"Connected":"Disconnected"},{label:"What",value:"Connection to Claude, the AI that powers natural conversation and tool use"},{label:"How",value:"Authenticated via OAuth — tokens refresh automatically when they expire"},{label:"Token Expiry",value:a},...e.authMessage?[{label:"Message",value:e.authMessage}]:[]];break}case"license":{const o=e.licenseStoredKey?`…${e.licenseStoredKey.slice(-12)}`:"N/A";t="License",n=[{label:"Status",value:e.licenseValid?"Active":"Inactive"},{label:"What",value:"Your Taskmaster license key, tied to this specific device"},{label:"Key",value:o},{label:"Tier",value:e.licenseTier||"Standard"},{label:"Device ID",value:e.licenseDeviceId||"N/A"}];break}case"whatsapp":{const o=rn(e),a=o?wa(o,e):null;t="WhatsApp",n=[{label:"Status",value:a!=null&&a.connected?"Connected":"Disconnected"},{label:"What",value:"WhatsApp integration — receive and respond to customer messages through WhatsApp"},{label:"How",value:"Links to your WhatsApp account by scanning a QR code, then routes messages to your AI assistant"},{label:"Account",value:(a==null?void 0:a.name)||(a==null?void 0:a.accountId)||"Default"},{label:"Phone",value:((s=a==null?void 0:a.self)==null?void 0:s.e164)||"Not paired"},{label:"Linked",value:a!=null&&a.linked?"Yes":"No"},...a!=null&&a.lastError?[{label:"Last Error",value:ka(a.lastError)}]:[]];break}case"imessage":{const{thisWsOwns:o}=xa(e);t="iMessage",n=[{label:"Status",value:o&&e.imessageConnected?"Connected":"Disconnected"},{label:"What",value:"iMessage integration — communicate with your AI assistant through Apple Messages"},{label:"How",value:"Uses the Mac's built-in Messages app; only one account can own the iMessage channel at a time"},{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:"Status",value:e.updateAvailable===null?"Not checked":e.updateAvailable?"Update available":"Up to date"},{label:"What",value:"Checks for new versions of Taskmaster and lets you update from the control panel"},{label:"Current",value:e.currentVersion?`v${e.currentVersion}`:"Unknown"},{label:"Latest",value:e.latestVersion?`v${e.latestVersion}`:"Unknown"},...e.updateMessage?[{label:"Message",value:e.updateMessage}]:[]];break}case"remote-access":{const o=e.tailscaleStatus,a=o?o.installed?o.loggedIn?o.serveEnabled&&o.serveActive?"Active":o.serveEnabled&&!o.serveActive?"Enabled but not active":"Off":"Not connected":"Not installed":"Checking...";if(t="Remote Access",n=[{label:"Status",value:a},{label:"What",value:"Access this control panel from anywhere — your phone, another computer, or while away from home"},{label:"How",value:"Uses Tailscale to create a private, encrypted connection with a trusted HTTPS certificate (no browser warnings)"},{label:"Requires",value:"Tailscale installed on this device and on any device you want to access the control panel from, all logged into the same Tailscale account"},{label:"Internet Access",value:"Enable internet access (globe icon) to make Public Chat reachable from the web"},{label:"Cost",value:"Tailscale is free for personal use (up to 100 devices)"}],o!=null&&o.tailnetUrl){const r=o.tailnetUrl;i=u`
430
430
  ${e.remoteAccessQrDataUrl?u`<div style="text-align: center; padding: 12px 0;">
431
431
  <img src=${e.remoteAccessQrDataUrl} alt="QR code for remote access URL" style="width: 180px; height: 180px; image-rendering: pixelated; border-radius: 8px;" />
432
432
  </div>`:w}
@@ -434,9 +434,9 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
434
434
  <a href="${r}" target="_blank" rel="noopener"
435
435
  style="color: var(--tasker-link, #60a5fa); font-size: 13px; word-break: break-all;"
436
436
  >${r}</a>
437
- <button class="setup-info-btn" title="Copy URL" @click=${async l=>{const c=l.currentTarget;try{await navigator.clipboard.writeText(r)}catch{const h=document.createElement("textarea");h.value=r,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h)}c.classList.add("copied"),setTimeout(()=>c.classList.remove("copied"),1500)}}>${L.copy}</button>
437
+ <button class="setup-info-btn" title="Copy URL" @click=${async c=>{const d=c.currentTarget;try{await navigator.clipboard.writeText(r)}catch{const h=document.createElement("textarea");h.value=r,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h)}d.classList.add("copied"),setTimeout(()=>d.classList.remove("copied"),1500)}}>${L.copy}</button>
438
438
  </div>
439
- `}break}case"public-chat":{if(t="Public Chat",n=[{label:"Status",value:e.publicChatEnabled?"Enabled":"Disabled"},{label:"What",value:"A chat widget anyone can use to message your business from a web browser"},{label:"Requires",value:"Remote Access with internet access enabled — this gives your device a public URL that visitors can reach"},{label:"Access mode",value:xg[e.publicChatAuthMode]??"Open access"},{label:"WhatsApp",value:"Sends verification codes via WhatsApp. Requires a connected WhatsApp account."},{label:"SMS",value:"Sends verification codes via text message. Uses Brevo — same API key as email. Requires prepaid SMS credits in your Brevo account."},{label:"Email",value:"Sends verification codes via email. Uses Brevo (free, 300 emails/day). Sender address is auto-detected from your verified sender in Brevo."},{label:"Provider",value:"SMS and email both use Brevo — one API key, configured in API Keys above. WhatsApp uses your connected account."}],e.publicChatEnabled&&e.publicChatFullUrl){const o=e.publicChatFullUrl;i=u`
439
+ `}break}case"public-chat":{if(t="Public Chat",n=[{label:"Status",value:e.publicChatEnabled?"Enabled":"Disabled"},{label:"What",value:"A chat widget anyone can use to message your business from a web browser"},{label:"Requires",value:"Remote Access with internet access enabled — this gives your device a public URL that visitors can reach"},{label:"Access mode",value:Tg[e.publicChatAuthMode]??"Open access"},{label:"WhatsApp",value:"Sends verification codes via WhatsApp. Requires a connected WhatsApp account."},{label:"SMS",value:"Sends verification codes via text message. Uses Brevo — same API key as email. Requires prepaid SMS credits in your Brevo account."},{label:"Email",value:"Sends verification codes via email. Uses Brevo (free, 300 emails/day). Sender address is auto-detected from your verified sender in Brevo."},{label:"Provider",value:"SMS and email both use Brevo — one API key, configured in API Keys above. WhatsApp uses your connected account."}],e.publicChatEnabled&&e.publicChatFullUrl){const o=e.publicChatFullUrl;i=u`
440
440
  ${e.publicChatQrDataUrl?u`<div style="text-align: center; padding: 12px 0;">
441
441
  <img src=${e.publicChatQrDataUrl} alt="QR code for public chat URL" style="width: 180px; height: 180px; image-rendering: pixelated; border-radius: 8px;" />
442
442
  </div>`:w}
@@ -444,7 +444,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
444
444
  <a href="${o}" target="_blank" rel="noopener"
445
445
  style="color: var(--tasker-link, #60a5fa); font-size: 13px; word-break: break-all;"
446
446
  >${o}</a>
447
- <button class="setup-info-btn" title="Copy URL" @click=${async a=>{const r=a.currentTarget;try{await navigator.clipboard.writeText(o)}catch{const l=document.createElement("textarea");l.value=o,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select(),document.execCommand("copy"),document.body.removeChild(l)}r.classList.add("copied"),setTimeout(()=>r.classList.remove("copied"),1500)}}>${L.copy}</button>
447
+ <button class="setup-info-btn" title="Copy URL" @click=${async a=>{const r=a.currentTarget;try{await navigator.clipboard.writeText(o)}catch{const c=document.createElement("textarea");c.value=o,c.style.position="fixed",c.style.opacity="0",document.body.appendChild(c),c.select(),document.execCommand("copy"),document.body.removeChild(c)}r.classList.add("copied"),setTimeout(()=>r.classList.remove("copied"),1500)}}>${L.copy}</button>
448
448
  </div>
449
449
  `}break}case"sms-fallback":{t="SMS Fallback",n=[{label:"What",value:"When WhatsApp is not connected, verification codes are sent via SMS instead"},{label:"Provider",value:"Brevo — uses the same API key as email verification"},{label:"When used",value:"Only when a visitor requests phone verification and WhatsApp is unavailable"},{label:"Setup",value:"Add your Brevo API key in API Keys above, then purchase SMS credits in the Brevo dashboard"}];break}case"account-pin":{t="Account PIN",n=[{label:"Status",value:e.accountHasPin?"Set":"Not set"},{label:"What",value:"A numeric PIN that protects this account on the control panel"},{label:"When needed",value:"Required when switching to this account or after the session expires"},{label:"Format",value:"4 to 6 digits"}];break}case"branding":{const o=!!(e.brandAccentColor||e.brandBackgroundColor||e.brandHasLogo);t="Branding",n=[{label:"Status",value:o?"Customised":"Default"},{label:"What",value:"Your business logo and colour scheme, displayed on the control panel and public chat pages"},{label:"Logo",value:"Shown on public chat pages alongside your business name"},{label:"Accent colour",value:"Used for buttons, links, and interactive elements"},{label:"Background tint",value:"A subtle colour wash applied to page and card backgrounds"},{label:"Scope",value:"Each account has its own branding — switch accounts to customise each one separately"}];break}case"api-keys":{const a=e.apiKeyProviders.filter(r=>r.hasKey).length;t="API Keys",n=[{label:"Status",value:a>0?`${a} configured`:"None configured"},{label:"What",value:"API keys let Taskmaster connect to AI providers (Google, OpenAI, etc.) and services (Tavily search, Brave search)"},{label:"Required",value:"At least one AI provider key is needed for the assistant to work"},{label:"Scope",value:"API keys are shared across all accounts on this device"}];break}case"network":{t="Network",n=[{label:"Address",value:e.networkHostname?`${e.networkHostname}.local:${e.networkPort}`:`Port ${e.networkPort}`},{label:"What",value:"The hostname and port this device uses on your local network"},{label:"When to change",value:"If you have multiple devices on the same network, give each a unique hostname and port so they don't conflict"},{label:"After saving",value:"The gateway restarts and your browser redirects to the new address"}];break}default:return w}return u`
450
450
  <div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&e.onInfoModalClose()}}>
@@ -477,7 +477,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
477
477
  </div>
478
478
  `})}
479
479
  </div>
480
- `}function Pr(e){const{licenseKey:t,licenseBusy:n,licenseValid:i,licenseMessage:s,licenseDeviceId:o,onLicenseKeyChange:a,onLicenseActivate:r}=e;return i===!0?u`
480
+ `}function Rr(e){const{licenseKey:t,licenseBusy:n,licenseValid:i,licenseMessage:s,licenseDeviceId:o,onLicenseKeyChange:a,onLicenseActivate:r}=e;return i===!0?u`
481
481
  <div class="setup-container">
482
482
  <div class="setup-card setup-success">
483
483
  ${Ee("license")}
@@ -512,7 +512,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
512
512
  <button
513
513
  class="setup-device-id-copy"
514
514
  title="Copy Device ID"
515
- @click=${async l=>{const c=l.currentTarget;try{await navigator.clipboard.writeText(o),c.textContent="Copied!",setTimeout(()=>{c.textContent="Copy"},1500)}catch{const h=document.createElement("textarea");h.value=o,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h),c.textContent="Copied!",setTimeout(()=>{c.textContent="Copy"},1500)}}}
515
+ @click=${async c=>{const d=c.currentTarget;try{await navigator.clipboard.writeText(o),d.textContent="Copied!",setTimeout(()=>{d.textContent="Copy"},1500)}catch{const h=document.createElement("textarea");h.value=o,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h),d.textContent="Copied!",setTimeout(()=>{d.textContent="Copy"},1500)}}}
516
516
  >Copy</button>
517
517
  </div>
518
518
  `:w}
@@ -521,8 +521,8 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
521
521
  type="text"
522
522
  placeholder="Paste your license key here"
523
523
  .value=${t}
524
- @input=${l=>a(l.target.value)}
525
- @keydown=${l=>{l.key==="Enter"&&t.trim()&&r()}}
524
+ @input=${c=>a(c.target.value)}
525
+ @keydown=${c=>{c.key==="Enter"&&t.trim()&&r()}}
526
526
  />
527
527
  <button
528
528
  class="setup-button"
@@ -546,7 +546,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
546
546
  </p>
547
547
  </div>
548
548
  </div>
549
- `}function rg(e){const{authConnected:t,authBusy:n,authMessage:i,authUrl:s,authCodeInput:o,authExpiresIn:a,onStartAuth:r,onSubmitAuthCode:l,onAuthCodeChange:c,onSkipToWhatsApp:h}=e;return t===!0?u`
549
+ `}function hg(e){const{authConnected:t,authBusy:n,authMessage:i,authUrl:s,authCodeInput:o,authExpiresIn:a,onStartAuth:r,onSubmitAuthCode:c,onAuthCodeChange:d,onSkipToWhatsApp:h}=e;return t===!0?u`
550
550
  <div class="setup-container">
551
551
  <div class="setup-card setup-success">
552
552
  ${Ee("auth")}
@@ -598,20 +598,20 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
598
598
  type="text"
599
599
  placeholder="Enter authorization code"
600
600
  .value=${o}
601
- @input=${d=>c(d.target.value)}
602
- @keydown=${d=>{d.key==="Enter"&&o.trim()&&l(o.trim())}}
601
+ @input=${l=>d(l.target.value)}
602
+ @keydown=${l=>{l.key==="Enter"&&o.trim()&&c(o.trim())}}
603
603
  />
604
604
  <button
605
605
  class="setup-button"
606
606
  ?disabled=${!o.trim()||n}
607
- @click=${()=>l(o.trim())}
607
+ @click=${()=>c(o.trim())}
608
608
  >
609
609
  ${n?"Verifying...":"Submit"}
610
610
  </button>
611
611
  </div>
612
612
  ${i?u`<p class="setup-hint">${i}</p>`:w}
613
613
  <p class="setup-hint" style="margin-top: 16px;">
614
- <a href="#" class="setup-link" @click=${d=>{d.preventDefault(),e.onAuthApiKeyToggle()}}>
614
+ <a href="#" class="setup-link" @click=${l=>{l.preventDefault(),e.onAuthApiKeyToggle()}}>
615
615
  Or use an API key instead
616
616
  </a>
617
617
  </p>
@@ -628,8 +628,8 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
628
628
  type="password"
629
629
  placeholder="sk-ant-..."
630
630
  .value=${e.authApiKeyInput}
631
- @input=${d=>e.onAuthApiKeyChange(d.target.value)}
632
- @keydown=${d=>{d.key==="Enter"&&e.authApiKeyInput.trim()&&e.onAuthApiKeySubmit()}}
631
+ @input=${l=>e.onAuthApiKeyChange(l.target.value)}
632
+ @keydown=${l=>{l.key==="Enter"&&e.authApiKeyInput.trim()&&e.onAuthApiKeySubmit()}}
633
633
  ?disabled=${e.authApiKeyBusy}
634
634
  autofocus
635
635
  />
@@ -641,7 +641,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
641
641
  </div>
642
642
  ${e.authApiKeyError?u`<p class="setup-error">${e.authApiKeyError}</p>`:w}
643
643
  <p class="setup-hint" style="margin-top: 16px;">
644
- <a href="#" class="setup-link" @click=${d=>{d.preventDefault(),e.onAuthApiKeyToggle()}}>
644
+ <a href="#" class="setup-link" @click=${l=>{l.preventDefault(),e.onAuthApiKeyToggle()}}>
645
645
  Use OAuth instead
646
646
  </a>
647
647
  </p>
@@ -666,7 +666,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
666
666
  Connect to Claude →
667
667
  </button>
668
668
  <p class="setup-hint" style="margin-top: 8px;">
669
- <a href="#" class="setup-link" @click=${d=>{d.preventDefault(),e.onAuthApiKeyToggle()}}>
669
+ <a href="#" class="setup-link" @click=${l=>{l.preventDefault(),e.onAuthApiKeyToggle()}}>
670
670
  Or enter your API key
671
671
  </a>
672
672
  </p>
@@ -678,7 +678,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
678
678
  </p>
679
679
  </div>
680
680
  </div>
681
- `}function ba(e,t){const n=new Map(t.whatsappAccounts.map(i=>[i.accountId,i]));return e.whatsappAccountId?n.get(e.whatsappAccountId)??null:e.isDefault&&t.whatsappAccounts.length===1?t.whatsappAccounts[0]??null:null}function rn(e){var n;const t=(n=e.wsProps)==null?void 0:n.selectedWorkspace;return t?e.workspaces.find(i=>i.name===t)??null:e.workspaces[0]??null}function lg(e){const t=rn(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??Ye().name,i=e.whatsappBusy||e.gatewayHealthLoading;if(e.renamingWorkspace&&t){const s=()=>{const o=e.renameWorkspaceName.trim();o&&e.onWorkspaceRename(t.name,o)};return u`
681
+ `}function wa(e,t){const n=new Map(t.whatsappAccounts.map(i=>[i.accountId,i]));return e.whatsappAccountId?n.get(e.whatsappAccountId)??null:e.isDefault&&t.whatsappAccounts.length===1?t.whatsappAccounts[0]??null:null}function rn(e){var n;const t=(n=e.wsProps)==null?void 0:n.selectedWorkspace;return t?e.workspaces.find(i=>i.name===t)??null:e.workspaces[0]??null}function fg(e){const t=rn(e),n=(t==null?void 0:t.displayName)??(t==null?void 0:t.name)??Ye().name,i=e.whatsappBusy||e.gatewayHealthLoading;if(e.renamingWorkspace&&t){const s=()=>{const o=e.renameWorkspaceName.trim();o&&e.onWorkspaceRename(t.name,o)};return u`
682
682
  <div style="display: flex; align-items: center; gap: 6px; margin-bottom: 4px;">
683
683
  <input
684
684
  type="text"
@@ -720,7 +720,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
720
720
  ${L.rotateCw}
721
721
  </button>
722
722
  </div>
723
- `}function cg(e){return u`
723
+ `}function gg(e){return u`
724
724
  <div class="setup-status-item">
725
725
  ${Q(e.gatewayHealthy===!1?"bad":"good")}
726
726
  <div class="setup-status-info">
@@ -737,7 +737,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
737
737
  ${L.rotateCw}
738
738
  </button>
739
739
  </div>
740
- `}function dg(e){const t=e.authConnected===!0;return u`
740
+ `}function mg(e){const t=e.authConnected===!0;return u`
741
741
  <div class="setup-status-item">
742
742
  ${Q(t?"good":"bad")}
743
743
  <div class="setup-status-info">
@@ -766,7 +766,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
766
766
  </button>
767
767
  `}
768
768
  </div>
769
- `}function ug(e){return u`
769
+ `}function yg(e){return u`
770
770
  <div class="setup-status-item" style="flex-wrap: wrap;">
771
771
  ${Q("good")}
772
772
  <div class="setup-status-info">
@@ -806,7 +806,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
806
806
  </div>
807
807
  `:w}
808
808
  </div>
809
- `}function wa(e){var t,n;try{const i=JSON.parse(e),s=(i==null?void 0:i.error)??i,o=((n=(t=s==null?void 0:s.output)==null?void 0:t.payload)==null?void 0:n.message)??(s==null?void 0:s.message)??(i==null?void 0:i.message);if(o&&typeof o=="string")return o}catch{}return e.length>80?e.slice(0,77)+"…":e}function pg(e){var d;const t=rn(e);if(!t)return w;const n=ba(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected),s=(n==null?void 0:n.linked)&&!i,o=!!n,a=i?"good":s?"partial":o?"bad":"unknown",r=i?"Connected":s?"Linked, not connected":o?n!=null&&n.lastError?wa(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?(d=e.whatsappAccounts[0])==null?void 0:d.accountId:void 0),h=c!=null&&e.whatsappActiveQrAccountId===c;return u`
809
+ `}function ka(e){var t,n;try{const i=JSON.parse(e),s=(i==null?void 0:i.error)??i,o=((n=(t=s==null?void 0:s.output)==null?void 0:t.payload)==null?void 0:n.message)??(s==null?void 0:s.message)??(i==null?void 0:i.message);if(o&&typeof o=="string")return o}catch{}return e.length>80?e.slice(0,77)+"…":e}function vg(e){var l;const t=rn(e);if(!t)return w;const n=wa(t,e),i=(n==null?void 0:n.running)&&(n==null?void 0:n.connected),s=(n==null?void 0:n.linked)&&!i,o=!!n,a=i?"good":s?"partial":o?"bad":"unknown",r=i?"Connected":s?"Linked, not connected":o?n!=null&&n.lastError?ka(n.lastError):"Not connected":"Not paired",c=!(n!=null&&n.provider)||(n==null?void 0:n.provider)==="baileys",d=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(l=e.whatsappAccounts[0])==null?void 0:l.accountId:void 0),h=d!=null&&e.whatsappActiveQrAccountId===d;return u`
810
810
  <div class="setup-status-item" style="flex-wrap: wrap;">
811
811
  ${Q(a)}
812
812
  <div class="setup-status-info">
@@ -819,7 +819,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
819
819
  @click=${e.onWhatsAppSettingsOpen}
820
820
  title="WhatsApp settings"
821
821
  >${L.settings}</button>`:w}
822
- ${l&&c?u`<button
822
+ ${c&&d?u`<button
823
823
  class="setup-status-action"
824
824
  @click=${e.onRefreshStatus}
825
825
  title="Refresh status"
@@ -837,7 +837,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
837
837
  </div>
838
838
  `:w}
839
839
  </div>
840
- `}const hg=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],fg="anthropic/claude-sonnet-4-5-20250929",gg=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function mg(e){var S,T;if(!e.whatsappSettingsOpen)return w;const t=rn(e);if(!t)return w;const n=ba(t,e);if(!n)return w;const i=n.running&&n.connected,s=!n.provider||n.provider==="baileys",o=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(S=e.whatsappAccounts[0])==null?void 0:S.accountId:void 0),a=()=>e.onWhatsAppSettingsClose(),r=e.whatsappModelCatalog??[],l=new Set(r.filter(f=>f.provider==="anthropic").map(f=>f.id)),c=hg.filter(f=>l.has(f.id)),h=e.whatsappModel??fg,d=e.whatsappThinkingLevel??"off",p="display: flex; justify-content: space-between; font-size: 13px;",g="color: var(--tasker-text-grey);",$="color: var(--tasker-white); text-align: right;";return u`
840
+ `}const bg=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],wg="anthropic/claude-sonnet-4-5-20250929",kg=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function xg(e){var S,T;if(!e.whatsappSettingsOpen)return w;const t=rn(e);if(!t)return w;const n=wa(t,e);if(!n)return w;const i=n.running&&n.connected,s=!n.provider||n.provider==="baileys",o=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(S=e.whatsappAccounts[0])==null?void 0:S.accountId:void 0),a=()=>e.onWhatsAppSettingsClose(),r=e.whatsappModelCatalog??[],c=new Set(r.filter(f=>f.provider==="anthropic").map(f=>f.id)),d=bg.filter(f=>c.has(f.id)),h=e.whatsappModel??wg,l=e.whatsappThinkingLevel??"off",p="display: flex; justify-content: space-between; font-size: 13px;",g="color: var(--tasker-text-grey);",$="color: var(--tasker-white); text-align: right;";return u`
841
841
  <div class="setup-info-overlay" @click=${f=>{f.target.classList.contains("setup-info-overlay")&&a()}}>
842
842
  <div class="setup-info-card" style="max-width: 360px;">
843
843
  <h3>WhatsApp</h3>
@@ -846,7 +846,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
846
846
  <div style="${p}"><span style="${g}">Phone</span><span style="${$}">${((T=n.self)==null?void 0:T.e164)||"Not paired"}</span></div>
847
847
  <div style="${p}"><span style="${g}">Connected</span><span style="${$}">${i?"Yes":"No"}</span></div>
848
848
  <div style="${p}"><span style="${g}">Linked</span><span style="${$}">${n.linked?"Yes":"No"}</span></div>
849
- ${n.lastError?u`<div style="${p}"><span style="${g}">Error</span><span style="${$}; color: #ef4444;">${wa(n.lastError)}</span></div>`:w}
849
+ ${n.lastError?u`<div style="${p}"><span style="${g}">Error</span><span style="${$}; color: #ef4444;">${ka(n.lastError)}</span></div>`:w}
850
850
  </div>
851
851
  ${s&&o?u`
852
852
  <div style="border-top: 1px solid rgba(255,255,255,0.08); margin: 16px 0 12px;"></div>
@@ -921,7 +921,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
921
921
  </div>
922
922
  `:w}
923
923
  <div style="border-top: 1px solid rgba(255,255,255,0.08); margin: 4px 0;"></div>
924
- ${c.length>0?u`
924
+ ${d.length>0?u`
925
925
  <div style="display: flex; align-items: center; gap: 8px;">
926
926
  <div style="font-size: 13px; color: var(--tasker-text-grey); min-width: 60px;">Model</div>
927
927
  <select
@@ -930,7 +930,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
930
930
  .value=${h}
931
931
  @change=${f=>{e.onWhatsAppModelChange(f.target.value)}}
932
932
  >
933
- ${c.map(f=>u`
933
+ ${d.map(f=>u`
934
934
  <option value=${"anthropic/"+f.id} ?selected=${h==="anthropic/"+f.id}>
935
935
  ${f.shortName}
936
936
  </option>
@@ -943,11 +943,11 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
943
943
  <select
944
944
  class="setup-model-select"
945
945
  style="flex: 1;"
946
- .value=${d}
946
+ .value=${l}
947
947
  @change=${f=>{e.onWhatsAppThinkingChange(f.target.value)}}
948
948
  >
949
- ${gg.map(f=>u`
950
- <option value=${f.value} ?selected=${d===f.value}>
949
+ ${kg.map(f=>u`
950
+ <option value=${f.value} ?selected=${l===f.value}>
951
951
  ${f.label}
952
952
  </option>
953
953
  `)}
@@ -964,7 +964,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
964
964
  </button>
965
965
  </div>
966
966
  </div>
967
- `}function ka(e){const t=rn(e),n=e.imessageOwnerWorkspace,i=!!(t&&n===t.name),s=!!(n&&t&&n!==t.name);return{selectedWs:t,ownerWs:n,thisWsOwns:i,anotherWsOwns:s}}function yg(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=ka(e);let s,o;return i?(s="partial",o=`Connected to ${t}`):n&&e.imessageConnected?(s="good",o="Connected"):n&&e.imessageRunning?(s="partial",o="Running, not connected"):n?(s="bad",o="Not running"):e.imessageConfigured?(s="unknown",o="Not connected"):(s="bad",o="Not configured"),u`
967
+ `}function xa(e){const t=rn(e),n=e.imessageOwnerWorkspace,i=!!(t&&n===t.name),s=!!(n&&t&&n!==t.name);return{selectedWs:t,ownerWs:n,thisWsOwns:i,anotherWsOwns:s}}function $g(e){const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=xa(e);let s,o;return i?(s="partial",o=`Connected to ${t}`):n&&e.imessageConnected?(s="good",o="Connected"):n&&e.imessageRunning?(s="partial",o="Running, not connected"):n?(s="bad",o="Not running"):e.imessageConfigured?(s="unknown",o="Not connected"):(s="bad",o="Not configured"),u`
968
968
  <div class="setup-status-item" style="flex-wrap: wrap;">
969
969
  ${Q(s)}
970
970
  <div class="setup-status-info">
@@ -982,7 +982,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
982
982
  </button>
983
983
  ${w}
984
984
  </div>
985
- `}function vg(e){if(!e.imessageEnableConfirm)return w;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=ka(e),s=()=>{e.onIMessageEnableCancel()};return n?u`
985
+ `}function Sg(e){if(!e.imessageEnableConfirm)return w;const{ownerWs:t,thisWsOwns:n,anotherWsOwns:i}=xa(e),s=()=>{e.onIMessageEnableCancel()};return n?u`
986
986
  <div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&s()}}>
987
987
  <div class="setup-info-card" style="text-align: center;">
988
988
  <h3>iMessage</h3>
@@ -1058,7 +1058,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1058
1058
  </button>
1059
1059
  </div>
1060
1060
  </div>
1061
- `}function bg(e){if(!e.isMaster)return w;const n=e.apiKeyProviders.filter(i=>i.hasKey).length;return u`
1061
+ `}function Ag(e){if(!e.isMaster)return w;const n=e.apiKeyProviders.filter(i=>i.hasKey).length;return u`
1062
1062
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
1063
1063
  <div class="setup-status-item">
1064
1064
  ${Q(n>0?"good":"bad")}
@@ -1073,30 +1073,30 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1073
1073
  >Manage</button>
1074
1074
  </div>
1075
1075
  </div>
1076
- ${wg(e)}
1077
- `}function wg(e){if(!e.apiKeyModalOpen)return w;const t=e.apiKeyProviders,n={};for(const c of t)c.key&&(n[c.id]=c.key);const i=(c,h)=>{const d=h==null?void 0:h.closest(".setup-apikey-input"),p=d==null?void 0:d.querySelector("input"),g=p==null?void 0:p.value.trim();!g||g===n[c]||e.onApiKeySave(c,g)},s=c=>{const h=c.currentTarget,d=h.closest(".setup-apikey-input"),p=d==null?void 0:d.querySelector("input");if(!p)return;const g=p.type==="text";p.type=g?"password":"text",h.classList.toggle("active",!g)},o=(c,h)=>{const d=h.target,p=d.closest(".setup-apikey-input"),g=d.value.trim(),$=g.length>0&&g!==n[c],S=p==null?void 0:p.querySelector(".setup-apikey-save");S&&(S.style.display=$?"":"none");const T=p==null?void 0:p.querySelector(".setup-apikey-eye");T&&(T.style.display=g.length>0?"":"none")},a=t.filter(c=>c.primary),r=t.filter(c=>!c.primary),l=c=>{const h=e.apiKeySavingProvider===c.id&&e.apiKeyBusy,d=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key saved`,p=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key removed`,g=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} disabled`,$=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} enabled`;return u`
1078
- <div class="setup-apikey-row ${c.disabled?"disabled":""}">
1076
+ ${Cg(e)}
1077
+ `}function Cg(e){if(!e.apiKeyModalOpen)return w;const t=e.apiKeyProviders,n={};for(const d of t)d.key&&(n[d.id]=d.key);const i=(d,h)=>{const l=h==null?void 0:h.closest(".setup-apikey-input"),p=l==null?void 0:l.querySelector("input"),g=p==null?void 0:p.value.trim();!g||g===n[d]||e.onApiKeySave(d,g)},s=d=>{const h=d.currentTarget,l=h.closest(".setup-apikey-input"),p=l==null?void 0:l.querySelector("input");if(!p)return;const g=p.type==="text";p.type=g?"password":"text",h.classList.toggle("active",!g)},o=(d,h)=>{const l=h.target,p=l.closest(".setup-apikey-input"),g=l.value.trim(),$=g.length>0&&g!==n[d],S=p==null?void 0:p.querySelector(".setup-apikey-save");S&&(S.style.display=$?"":"none");const T=p==null?void 0:p.querySelector(".setup-apikey-eye");T&&(T.style.display=g.length>0?"":"none")},a=t.filter(d=>d.primary),r=t.filter(d=>!d.primary),c=d=>{const h=e.apiKeySavingProvider===d.id&&e.apiKeyBusy,l=!e.apiKeyBusy&&e.apiKeySuccess===`${d.id} key saved`,p=!e.apiKeyBusy&&e.apiKeySuccess===`${d.id} key removed`,g=!e.apiKeyBusy&&e.apiKeySuccess===`${d.id} disabled`,$=!e.apiKeyBusy&&e.apiKeySuccess===`${d.id} enabled`;return u`
1078
+ <div class="setup-apikey-row ${d.disabled?"disabled":""}">
1079
1079
  <div class="setup-apikey-info">
1080
- <strong>${c.name}</strong>
1081
- <span class="setup-apikey-category">${c.category}</span>
1082
- ${d?u`<span class="setup-apikey-badge saved">Saved</span>`:w}
1080
+ <strong>${d.name}</strong>
1081
+ <span class="setup-apikey-category">${d.category}</span>
1082
+ ${l?u`<span class="setup-apikey-badge saved">Saved</span>`:w}
1083
1083
  ${p?u`<span class="setup-apikey-badge removed">Removed</span>`:w}
1084
1084
  ${g?u`<span class="setup-apikey-badge removed">Disabled</span>`:w}
1085
1085
  ${$?u`<span class="setup-apikey-badge saved">Enabled</span>`:w}
1086
- ${c.disabled&&!$?u`<span class="setup-apikey-badge apikey-disabled">Off</span>`:w}
1086
+ ${d.disabled&&!$?u`<span class="setup-apikey-badge apikey-disabled">Off</span>`:w}
1087
1087
  </div>
1088
1088
  <div class="setup-apikey-input">
1089
1089
  <input
1090
1090
  type="password"
1091
- .value=${c.key??""}
1091
+ .value=${d.key??""}
1092
1092
  placeholder="Enter key"
1093
- ?disabled=${e.apiKeyBusy||c.disabled}
1094
- @input=${S=>o(c.id,S)}
1095
- @keydown=${S=>{S.key==="Enter"&&i(c.id,S.target)}}
1093
+ ?disabled=${e.apiKeyBusy||d.disabled}
1094
+ @input=${S=>o(d.id,S)}
1095
+ @keydown=${S=>{S.key==="Enter"&&i(d.id,S.target)}}
1096
1096
  />
1097
1097
  <button
1098
1098
  class="setup-apikey-icon-btn setup-apikey-eye"
1099
- style=${c.hasKey?"":"display: none;"}
1099
+ style=${d.hasKey?"":"display: none;"}
1100
1100
  title="Toggle visibility"
1101
1101
  @click=${s}
1102
1102
  >${L.eye}</button>
@@ -1104,41 +1104,41 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1104
1104
  class="setup-apikey-save setup-button"
1105
1105
  style="display: none;"
1106
1106
  ?disabled=${e.apiKeyBusy}
1107
- @click=${S=>i(c.id,S.currentTarget)}
1107
+ @click=${S=>i(d.id,S.currentTarget)}
1108
1108
  >Save</button>`}
1109
- ${c.hasKey&&!h?u`
1109
+ ${d.hasKey&&!h?u`
1110
1110
  <button
1111
- class="setup-apikey-icon-btn ${c.disabled?"":"active"}"
1112
- title="${c.disabled?"Enable":"Disable"}"
1111
+ class="setup-apikey-icon-btn ${d.disabled?"":"active"}"
1112
+ title="${d.disabled?"Enable":"Disable"}"
1113
1113
  ?disabled=${e.apiKeyBusy}
1114
- @click=${()=>e.onApiKeyDisable(c.id,!c.disabled)}
1114
+ @click=${()=>e.onApiKeyDisable(d.id,!d.disabled)}
1115
1115
  >${L.power}</button>
1116
1116
  <button
1117
1117
  class="setup-apikey-icon-btn danger"
1118
1118
  title="Remove key"
1119
1119
  ?disabled=${e.apiKeyBusy}
1120
- @click=${()=>e.onApiKeyRemove(c.id)}
1120
+ @click=${()=>e.onApiKeyRemove(d.id)}
1121
1121
  >${L.trash}</button>
1122
1122
  `:w}
1123
1123
  </div>
1124
1124
  </div>
1125
1125
  `};return u`
1126
- <div class="setup-info-overlay" style="align-items: flex-start; padding-top: 72px;" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onApiKeyModalClose()}}>
1126
+ <div class="setup-info-overlay" style="align-items: flex-start; padding-top: 72px;" @click=${d=>{d.target.classList.contains("setup-info-overlay")&&e.onApiKeyModalClose()}}>
1127
1127
  <div class="setup-info-card" style="max-width: 480px;">
1128
1128
  <h3 style="margin: 0 0 4px; text-align: center;">API Keys</h3>
1129
1129
  <div class="setup-apikey-list">
1130
1130
  ${e.apiKeyError?u`<p class="setup-error" style="margin: 0;">${e.apiKeyError}</p>`:w}
1131
- ${a.map(l)}
1131
+ ${a.map(c)}
1132
1132
  ${r.length>0?u`
1133
1133
  <details class="setup-apikey-advanced">
1134
1134
  <summary>Additional keys</summary>
1135
- ${r.map(l)}
1135
+ ${r.map(c)}
1136
1136
  </details>
1137
1137
  `:w}
1138
1138
  </div>
1139
1139
  </div>
1140
1140
  </div>
1141
- `}function kg(e){const t=e.updateAvailable===null?"unknown":e.updateAvailable?"partial":"good",n=e.updateAvailable&&e.latestVersion?`v${e.currentVersion} → v${e.latestVersion}`:e.currentVersion?`v${e.currentVersion}`:"Unknown",i=e.updateChecking||e.updateRunning;return u`
1141
+ `}function Eg(e){const t=e.updateAvailable===null?"unknown":e.updateAvailable?"partial":"good",n=e.updateAvailable&&e.latestVersion?`v${e.currentVersion} → v${e.latestVersion}`:e.currentVersion?`v${e.currentVersion}`:"Unknown",i=e.updateChecking||e.updateRunning;return u`
1142
1142
  <div class="setup-status-item">
1143
1143
  ${Q(t)}
1144
1144
  <div class="setup-status-info">
@@ -1166,7 +1166,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1166
1166
  </button>
1167
1167
  `}
1168
1168
  </div>
1169
- `}const xg={anonymous:"Open access",verified:"Phone OTP",choice:"Visitor chooses"};function $g(e){const t=e.publicChatEnabled;return u`
1169
+ `}const Tg={anonymous:"Open access",verified:"Phone OTP",choice:"Visitor chooses"};function _g(e){const t=e.publicChatEnabled;return u`
1170
1170
  <div class="setup-status-item">
1171
1171
  ${Q(t?"good":"unknown")}
1172
1172
  <div class="setup-status-info">
@@ -1186,8 +1186,8 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1186
1186
  @click=${e.onPublicChatToggle}
1187
1187
  >${t?L.powerOff:L.power}</button>
1188
1188
  </div>
1189
- `}function Sg(e){var c,h;if(!e.publicChatSettingsOpen)return w;const t=()=>e.onPublicChatSettingsClose(),n=!!e.publicChatGreeting,i=e.publicChatAuthMode==="verified"||e.publicChatAuthMode==="choice",s=e.publicChatVerifyMethods.length>0?e.publicChatVerifyMethods:["whatsapp","sms"],o=s.includes("whatsapp"),a=s.includes("sms"),r=s.includes("email"),l=!!((c=e.whatsappChannelStatus)!=null&&c.running&&((h=e.whatsappChannelStatus)!=null&&h.connected));return u`
1190
- <div class="setup-info-overlay" @click=${d=>{d.target.classList.contains("setup-info-overlay")&&t()}}>
1189
+ `}function Mg(e){var d,h;if(!e.publicChatSettingsOpen)return w;const t=()=>e.onPublicChatSettingsClose(),n=!!e.publicChatGreeting,i=e.publicChatAuthMode==="verified"||e.publicChatAuthMode==="choice",s=e.publicChatVerifyMethods.length>0?e.publicChatVerifyMethods:["whatsapp","sms"],o=s.includes("whatsapp"),a=s.includes("sms"),r=s.includes("email"),c=!!((d=e.whatsappChannelStatus)!=null&&d.running&&((h=e.whatsappChannelStatus)!=null&&h.connected));return u`
1190
+ <div class="setup-info-overlay" @click=${l=>{l.target.classList.contains("setup-info-overlay")&&t()}}>
1191
1191
  <div class="setup-info-card" style="max-width: 380px; max-height: 80vh; overflow-y: auto;">
1192
1192
  <h3 style="margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between;">
1193
1193
  Public Chat
@@ -1206,7 +1206,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1206
1206
  class="setup-select-sm"
1207
1207
  style="width: 100%;"
1208
1208
  ?disabled=${e.publicChatBusy}
1209
- @change=${d=>{const p=d.target.value;e.onPublicChatAuthModeChange(p)}}
1209
+ @change=${l=>{const p=l.target.value;e.onPublicChatAuthModeChange(p)}}
1210
1210
  >
1211
1211
  <option value="anonymous" ?selected=${e.publicChatAuthMode==="anonymous"}>Open access</option>
1212
1212
  <option value="verified" ?selected=${e.publicChatAuthMode==="verified"}>Identity verification</option>
@@ -1241,7 +1241,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1241
1241
  style="width: 100%; margin-top: 8px; font-size: 12px; padding: 8px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.2); color: var(--tasker-white); resize: vertical; min-height: 60px; font-family: inherit; box-sizing: border-box;"
1242
1242
  ?disabled=${e.publicChatGreetingBusy}
1243
1243
  .value=${e.publicChatGreetingBusy?"Generating...":e.publicChatGreeting}
1244
- @blur=${d=>{const p=d.target.value.trim();p&&p!==e.publicChatGreeting&&e.onPublicChatGreetingSave(p)}}
1244
+ @blur=${l=>{const p=l.target.value.trim();p&&p!==e.publicChatGreeting&&e.onPublicChatGreetingSave(p)}}
1245
1245
  ></textarea>
1246
1246
  `:u`
1247
1247
  <div style="font-size: 12px; color: var(--tasker-text-grey); opacity: 0.7; margin-top: 4px;">
@@ -1257,18 +1257,18 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1257
1257
  <div>
1258
1258
  <div style="font-size: 13px; color: var(--tasker-white); margin-bottom: 6px;">Verification methods</div>
1259
1259
  <div style="display: flex; flex-direction: column; gap: 8px; text-align: left;">
1260
- <label style="display: flex; align-items: flex-start; gap: 6px; ${l?"cursor: pointer;":"cursor: not-allowed; opacity: 0.5;"}">
1260
+ <label style="display: flex; align-items: flex-start; gap: 6px; ${c?"cursor: pointer;":"cursor: not-allowed; opacity: 0.5;"}">
1261
1261
  <input
1262
1262
  type="checkbox"
1263
- .checked=${o&&l}
1264
- ?disabled=${!l||e.publicChatEmailBusy||!a&&!r&&o}
1265
- @change=${d=>{const g=d.target.checked?[...s.filter($=>$!=="whatsapp"),"whatsapp"]:s.filter($=>$!=="whatsapp");g.length>0&&e.onPublicChatEmailSave(e.publicChatEmailFrom,g)}}
1263
+ .checked=${o&&c}
1264
+ ?disabled=${!c||e.publicChatEmailBusy||!a&&!r&&o}
1265
+ @change=${l=>{const g=l.target.checked?[...s.filter($=>$!=="whatsapp"),"whatsapp"]:s.filter($=>$!=="whatsapp");g.length>0&&e.onPublicChatEmailSave(e.publicChatEmailFrom,g)}}
1266
1266
  style="accent-color: #22c55e; margin-top: 2px;"
1267
1267
  />
1268
1268
  <div>
1269
1269
  <span style="font-size: 12px; color: var(--tasker-white);">WhatsApp</span>
1270
1270
  <div style="font-size: 11px; color: var(--tasker-text-grey); opacity: 0.7;">
1271
- ${l?"Phone OTP via WhatsApp":"No WhatsApp account connected on this account"}
1271
+ ${c?"Phone OTP via WhatsApp":"No WhatsApp account connected on this account"}
1272
1272
  </div>
1273
1273
  </div>
1274
1274
  </label>
@@ -1277,7 +1277,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1277
1277
  type="checkbox"
1278
1278
  .checked=${a}
1279
1279
  ?disabled=${e.publicChatEmailBusy||!o&&!r&&a}
1280
- @change=${d=>{const g=d.target.checked?[...s.filter($=>$!=="sms"),"sms"]:s.filter($=>$!=="sms");g.length>0&&e.onPublicChatEmailSave(e.publicChatEmailFrom,g)}}
1280
+ @change=${l=>{const g=l.target.checked?[...s.filter($=>$!=="sms"),"sms"]:s.filter($=>$!=="sms");g.length>0&&e.onPublicChatEmailSave(e.publicChatEmailFrom,g)}}
1281
1281
  style="accent-color: #22c55e; margin-top: 2px;"
1282
1282
  />
1283
1283
  <div>
@@ -1290,7 +1290,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1290
1290
  type="checkbox"
1291
1291
  .checked=${r}
1292
1292
  ?disabled=${e.publicChatEmailBusy||!o&&!a&&r}
1293
- @change=${d=>{const g=d.target.checked?[...s.filter($=>$!=="email"),"email"]:s.filter($=>$!=="email");g.length>0&&e.onPublicChatEmailSave(e.publicChatEmailFrom,g)}}
1293
+ @change=${l=>{const g=l.target.checked?[...s.filter($=>$!=="email"),"email"]:s.filter($=>$!=="email");g.length>0&&e.onPublicChatEmailSave(e.publicChatEmailFrom,g)}}
1294
1294
  style="accent-color: #22c55e; margin-top: 2px;"
1295
1295
  />
1296
1296
  <div>
@@ -1314,14 +1314,14 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1314
1314
  </div>
1315
1315
  </div>
1316
1316
  </div>
1317
- `}function Ag(e){var r,l;if(!e.publicChatWidgetModalOpen)return w;const t=((r=e.tailscaleStatus)==null?void 0:r.publicUrl)??((l=e.tailscaleStatus)==null?void 0:l.tailnetUrl)??null,n=e.publicChatAccountId??"your-account-id",i=t??"https://YOUR-PUBLIC-URL",s=`<script src="${i}/public/widget.js"><\/script>
1317
+ `}function Pg(e){var r,c;if(!e.publicChatWidgetModalOpen)return w;const t=((r=e.tailscaleStatus)==null?void 0:r.publicUrl)??((c=e.tailscaleStatus)==null?void 0:c.tailnetUrl)??null,n=e.publicChatAccountId??"your-account-id",i=t??"https://YOUR-PUBLIC-URL",s=`<script src="${i}/public/widget.js"><\/script>
1318
1318
  <script>
1319
1319
  Taskmaster.init({
1320
1320
  server: "${i}",
1321
1321
  accountId: "${n}"
1322
1322
  });
1323
- <\/script>`,o=async c=>{const h=c.currentTarget;try{await navigator.clipboard.writeText(s)}catch{const p=document.createElement("textarea");p.value=s,p.style.position="fixed",p.style.opacity="0",document.body.appendChild(p),p.select(),document.execCommand("copy"),document.body.removeChild(p)}const d=h.textContent;h.textContent="Copied!",setTimeout(()=>{h.textContent=d},1500)},a=()=>{const c=document.createElement("a");c.href="data:text/plain;charset=utf-8,"+encodeURIComponent(s),c.download="taskmaster-widget.txt",c.click()};return u`
1324
- <div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onPublicChatWidgetModalClose()}}>
1323
+ <\/script>`,o=async d=>{const h=d.currentTarget;try{await navigator.clipboard.writeText(s)}catch{const p=document.createElement("textarea");p.value=s,p.style.position="fixed",p.style.opacity="0",document.body.appendChild(p),p.select(),document.execCommand("copy"),document.body.removeChild(p)}const l=h.textContent;h.textContent="Copied!",setTimeout(()=>{h.textContent=l},1500)},a=()=>{const d=document.createElement("a");d.href="data:text/plain;charset=utf-8,"+encodeURIComponent(s),d.download="taskmaster-widget.txt",d.click()};return u`
1324
+ <div class="setup-info-overlay" @click=${d=>{d.target.classList.contains("setup-info-overlay")&&e.onPublicChatWidgetModalClose()}}>
1325
1325
  <div class="setup-info-card" style="max-width: 480px; position: relative;">
1326
1326
  <h3 style="margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between;">
1327
1327
  Widget Code Snippet
@@ -1344,7 +1344,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1344
1344
  </div>
1345
1345
  </div>
1346
1346
  </div>
1347
- `}function Cg(e){const t=!!(e.brandAccentColor||e.brandBackgroundColor||e.brandHasLogo),n=t?"good":"unknown",i=e.brandingBusy;return u`
1347
+ `}function Ig(e){const t=!!(e.brandAccentColor||e.brandBackgroundColor||e.brandHasLogo),n=t?"good":"unknown",i=e.brandingBusy;return u`
1348
1348
  <div class="setup-status-item">
1349
1349
  ${Q(n)}
1350
1350
  <div class="setup-status-info">
@@ -1358,7 +1358,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1358
1358
  @click=${e.onBrandingToggle}
1359
1359
  >${i?"...":"Edit"}</button>
1360
1360
  </div>
1361
- `}function Eg(e){var s;if(!e.brandingExpanded)return w;const t=e.brandingBusy,n=(s=e.wsProps)==null?void 0:s.selectedWorkspace,i=e.brandHasLogo&&n?`/brand-logo/${encodeURIComponent(n)}`:"";return u`
1361
+ `}function Lg(e){var s;if(!e.brandingExpanded)return w;const t=e.brandingBusy,n=(s=e.wsProps)==null?void 0:s.selectedWorkspace,i=e.brandHasLogo&&n?`/brand-logo/${encodeURIComponent(n)}`:"";return u`
1362
1362
  <div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&e.onBrandingToggle()}}>
1363
1363
  <div class="setup-info-card" style="max-width: 400px; position: relative;">
1364
1364
  <h3 style="margin-right: 24px;">Branding</h3>
@@ -1379,7 +1379,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1379
1379
  accept="image/png,image/jpeg,image/svg+xml,image/webp"
1380
1380
  style="display: none;"
1381
1381
  ?disabled=${t}
1382
- @change=${o=>{var l;const a=o.target,r=(l=a.files)==null?void 0:l[0];r&&e.onBrandLogoUpload(r),a.value=""}}
1382
+ @change=${o=>{var c;const a=o.target,r=(c=a.files)==null?void 0:c[0];r&&e.onBrandLogoUpload(r),a.value=""}}
1383
1383
  />
1384
1384
  </label>
1385
1385
  </div>
@@ -1439,7 +1439,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1439
1439
 
1440
1440
  </div>
1441
1441
  </div>
1442
- `}function Tg(e){const t=e.tailscaleBusy,n=e.tailscaleAuthUrl,i=e.tailscaleError,s=e.tailscaleConnectSuccess,o=e.tailscaleConnectProgress,a=e.tailscaleConnectMessage;return!t&&!s&&!i?w:i&&!t?u`
1442
+ `}function Rg(e){const t=e.tailscaleBusy,n=e.tailscaleAuthUrl,i=e.tailscaleError,s=e.tailscaleConnectSuccess,o=e.tailscaleConnectProgress,a=e.tailscaleConnectMessage;return!t&&!s&&!i?w:i&&!t?u`
1443
1443
  <div class="setup-info-overlay" @click=${r=>{r.target.classList.contains("setup-info-overlay")&&e.onTailscaleErrorDismiss()}}>
1444
1444
  <div class="setup-info-card" style="max-width: 380px; text-align: center;">
1445
1445
  <h3>Remote Access</h3>
@@ -1506,7 +1506,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1506
1506
  <p style="font-size: 14px; color: var(--tasker-text-grey); margin: 12px 0 0;">${a}</p>
1507
1507
  </div>
1508
1508
  </div>
1509
- `}function _g(e){if(!e.isMaster)return w;const t=e.tailscaleStatus,n=e.tailscaleBusy,i=e.tailscaleAuthUrl;if(!t)return u`
1509
+ `}function Dg(e){if(!e.isMaster)return w;const t=e.tailscaleStatus,n=e.tailscaleBusy,i=e.tailscaleAuthUrl;if(!t)return u`
1510
1510
  <div class="setup-status-item">
1511
1511
  ${Q("unknown")}
1512
1512
  <div class="setup-status-info">
@@ -1628,7 +1628,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1628
1628
  >${L.powerOff}</button>
1629
1629
  ${o}
1630
1630
  </div>
1631
- `}function Co(e){const t=e>=70?4:e>=50?3:e>=30?2:1;return u`
1631
+ `}function Eo(e){const t=e>=70?4:e>=50?3:e>=30?2:1;return u`
1632
1632
  <span style="display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; vertical-align: middle;">
1633
1633
  ${[4,7,10,14].map((i,s)=>u`<span style="
1634
1634
  width: 3px;
@@ -1637,7 +1637,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1637
1637
  background: ${s<t?"var(--tasker-accent, #00e5ff)":"rgba(255,255,255,0.15)"};
1638
1638
  "></span>`)}
1639
1639
  </span>
1640
- `}function Mg(e){if(e.serverPlatform!=="linux")return w;const t=e.wifiStatus,n=e.wifiBusy;if(!t)return u`
1640
+ `}function Bg(e){if(e.serverPlatform!=="linux")return w;const t=e.wifiStatus,n=e.wifiBusy;if(!t)return u`
1641
1641
  <div class="setup-status-item">
1642
1642
  ${Q("unknown")}
1643
1643
  <div class="setup-status-info">
@@ -1653,7 +1653,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1653
1653
  <span>NetworkManager not available</span>
1654
1654
  </div>
1655
1655
  </div>
1656
- `;const i=!!t.savedSsid&&!t.connected,s=t.connected?"good":"partial",o=t.connected?u`${t.ssid} ${t.signal!=null?u`<span style="margin-left: 4px;">${Co(t.signal)}</span>`:w}`:i?u`${t.savedSsid} <span style="opacity: 0.4;">\u2014 reconnecting\u2026</span>`:"Not connected";return u`
1656
+ `;const i=!!t.savedSsid&&!t.connected,s=t.connected?"good":"partial",o=t.connected?u`${t.ssid} ${t.signal!=null?u`<span style="margin-left: 4px;">${Eo(t.signal)}</span>`:w}`:i?u`${t.savedSsid} <span style="opacity: 0.4;">\u2014 reconnecting\u2026</span>`:"Not connected";return u`
1657
1657
  <div class="setup-status-item">
1658
1658
  ${Q(s)}
1659
1659
  <div class="setup-status-info">
@@ -1667,7 +1667,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1667
1667
  @click=${e.onWifiModalToggle}
1668
1668
  >${n?"...":"Edit"}</button>
1669
1669
  </div>
1670
- `}function Pg(e){if(!e.wifiModalOpen)return w;const t=e.wifiStatus,n=e.wifiBusy,i=e.wifiNetworks,s=e.wifiSelectedSsid;return u`
1670
+ `}function Ng(e){if(!e.wifiModalOpen)return w;const t=e.wifiStatus,n=e.wifiBusy,i=e.wifiNetworks,s=e.wifiSelectedSsid;return u`
1671
1671
  <div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&e.onWifiModalToggle()}}>
1672
1672
  <div class="setup-info-card" style="max-width: 420px; position: relative;">
1673
1673
  <h3 style="margin-right: 24px;">WiFi</h3>
@@ -1677,7 +1677,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1677
1677
  ${t!=null&&t.connected?u`
1678
1678
  <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 12px;">
1679
1679
  <span style="color: #22c55e;">${L.wifi}</span>
1680
- <span style="font-size: 13px;">${t.ssid}${t.signal!=null?u` ${Co(t.signal)}`:w}${t.ip?u` <span style="opacity: 0.5;">(${t.ip})</span>`:w}</span>
1680
+ <span style="font-size: 13px;">${t.ssid}${t.signal!=null?u` ${Eo(t.signal)}`:w}${t.ip?u` <span style="opacity: 0.5;">(${t.ip})</span>`:w}</span>
1681
1681
  <button
1682
1682
  class="setup-link-btn"
1683
1683
  style="margin-left: auto; font-size: 12px;"
@@ -1735,7 +1735,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1735
1735
  </span>
1736
1736
  <span style="display: flex; align-items: center; gap: 8px;">
1737
1737
  ${o.security!=="Open"?u`<span style="opacity: 0.4; font-size: 11px;" title="${o.security}">\uD83D\uDD12</span>`:w}
1738
- <span title="Signal: ${o.signal}%">${Co(o.signal)}</span>
1738
+ <span title="Signal: ${o.signal}%">${Eo(o.signal)}</span>
1739
1739
  </span>
1740
1740
  </button>
1741
1741
  `})}
@@ -1743,13 +1743,13 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1743
1743
 
1744
1744
  ${s&&!i.find(o=>o.ssid===s&&o.active)?u`
1745
1745
  <div style="display: flex; gap: 8px; align-items: center;">
1746
- ${(()=>{const o=i.find(l=>l.ssid===s),a=(o==null?void 0:o.security)!=="Open",r=(t==null?void 0:t.savedSsid)===s;return a&&!r?u`
1746
+ ${(()=>{const o=i.find(c=>c.ssid===s),a=(o==null?void 0:o.security)!=="Open",r=(t==null?void 0:t.savedSsid)===s;return a&&!r?u`
1747
1747
  <input
1748
1748
  type="password"
1749
1749
  placeholder="Password"
1750
1750
  .value=${e.wifiPassword}
1751
- @input=${l=>e.onWifiPasswordChange(l.target.value)}
1752
- @keydown=${l=>{l.key==="Enter"&&e.onWifiConnect()}}
1751
+ @input=${c=>e.onWifiPasswordChange(c.target.value)}
1752
+ @keydown=${c=>{c.key==="Enter"&&e.onWifiConnect()}}
1753
1753
  ?disabled=${n}
1754
1754
  style="
1755
1755
  flex: 1;
@@ -1779,7 +1779,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1779
1779
  `:w}
1780
1780
  </div>
1781
1781
  </div>
1782
- `}function Ig(e){return e.isMaster?e.networkPort==null?u`
1782
+ `}function Og(e){return e.isMaster?e.networkPort==null?u`
1783
1783
  <div class="setup-status-item">
1784
1784
  ${Q("unknown")}
1785
1785
  <div class="setup-status-info">
@@ -1800,7 +1800,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1800
1800
  @click=${e.onNetworkModalToggle}
1801
1801
  >Edit</button>
1802
1802
  </div>
1803
- `:w}function Lg(e){if(!e.networkModalOpen)return w;const t=e.networkBusy,n=e.networkPortInput!==String(e.networkPort),i=e.networkHostnameInput!==e.networkHostname,s=n||i;return u`
1803
+ `:w}function Fg(e){if(!e.networkModalOpen)return w;const t=e.networkBusy,n=e.networkPortInput!==String(e.networkPort),i=e.networkHostnameInput!==e.networkHostname,s=n||i;return u`
1804
1804
  <div class="setup-info-overlay" @click=${o=>{o.target.classList.contains("setup-info-overlay")&&e.onNetworkModalToggle()}}>
1805
1805
  <div class="setup-info-card" style="max-width: 400px; position: relative;">
1806
1806
  <h3 style="margin-right: 24px;">Network</h3>
@@ -1868,7 +1868,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1868
1868
  </div>
1869
1869
  </div>
1870
1870
  </div>
1871
- `}function Rg(e){var i,s,o;const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return w;if(t)return u`
1871
+ `}function Ug(e){var i,s,o;const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return w;if(t)return u`
1872
1872
  <div class="setup-info-overlay">
1873
1873
  <div class="setup-info-card" style="max-width: 400px;">
1874
1874
  <h3>Software Update</h3>
@@ -1880,7 +1880,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1880
1880
  ${a.status==="running"?u`<span class="setup-update-spinner"></span>`:a.status==="done"?u`<span class="setup-update-icon-ok">${L.check}</span>`:u`<span class="setup-update-icon-fail">${L.x}</span>`}
1881
1881
  </span>
1882
1882
  <span class="setup-update-step-name">${a.name}</span>
1883
- ${a.durationMs!=null?u`<span class="setup-update-step-time">${Ir(a.durationMs)}</span>`:w}
1883
+ ${a.durationMs!=null?u`<span class="setup-update-step-time">${Dr(a.durationMs)}</span>`:w}
1884
1884
  </div>
1885
1885
  `)}
1886
1886
  </div>
@@ -1888,8 +1888,8 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1888
1888
  ${e.updateMessage?u`<p style="text-align: center; color: var(--tasker-text-grey); font-size: 13px; margin: 12px 0 0;">${e.updateMessage}</p>`:w}
1889
1889
  </div>
1890
1890
  </div>
1891
- `;if(n){const a=n.status==="ok";let r;if(a){const c=(i=n.before)==null?void 0:i.version,h=((s=n.after)==null?void 0:s.version)??n.currentVersion;r=c?`v${c} → v${h}`:`Updated to v${h}`}else r=n.reason??((o=n.failedStep)==null?void 0:o.name)??"unknown error";const l=n.durationMs!=null?Ir(n.durationMs):null;return u`
1892
- <div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onUpdateDismissResult()}}>
1891
+ `;if(n){const a=n.status==="ok";let r;if(a){const d=(i=n.before)==null?void 0:i.version,h=((s=n.after)==null?void 0:s.version)??n.currentVersion;r=d?`v${d} → v${h}`:`Updated to v${h}`}else r=n.reason??((o=n.failedStep)==null?void 0:o.name)??"unknown error";const c=n.durationMs!=null?Dr(n.durationMs):null;return u`
1892
+ <div class="setup-info-overlay" @click=${d=>{d.target.classList.contains("setup-info-overlay")&&e.onUpdateDismissResult()}}>
1893
1893
  <div class="setup-info-card" style="max-width: 360px; text-align: center;">
1894
1894
  <div class="setup-update-result-icon ${a?"ok":"fail"}">${a?L.circleCheck:L.circleX}</div>
1895
1895
  <h3 style="color: ${a?"#22c55e":"#ef4444"};">
@@ -1898,7 +1898,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1898
1898
  <p style="color: var(--tasker-text-grey); font-size: 14px; margin: 8px 0;">
1899
1899
  ${r}
1900
1900
  </p>
1901
- ${l?u`<p style="color: rgba(255,255,255,0.3); font-size: 12px; margin: 4px 0 0;">${l}</p>`:w}
1901
+ ${c?u`<p style="color: rgba(255,255,255,0.3); font-size: 12px; margin: 4px 0 0;">${c}</p>`:w}
1902
1902
  <button
1903
1903
  class="setup-button secondary"
1904
1904
  style="margin-top: 20px; width: 100%; padding: 10px;"
@@ -1908,7 +1908,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1908
1908
  </button>
1909
1909
  </div>
1910
1910
  </div>
1911
- `}return w}function Ir(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),i=t%60;return i>0?`${n}m ${i}s`:`${n}m`}function Dg(e){const t=e.accountHasPin;return u`
1911
+ `}return w}function Dr(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),i=t%60;return i>0?`${n}m ${i}s`:`${n}m`}function Wg(e){const t=e.accountHasPin;return u`
1912
1912
  <div class="setup-status-item">
1913
1913
  ${Q(t?"good":"bad")}
1914
1914
  <div class="setup-status-info">
@@ -1921,8 +1921,8 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1921
1921
  @click=${()=>e.onAccountPinModalOpen()}
1922
1922
  >${t?"Change":"Set PIN"}</button>
1923
1923
  </div>
1924
- `}function Bg(e){if(!e.accountPinModalOpen)return w;const t=e.accountHasPin,n=e.accountPinBusy;let i="",s="",o="";const a=c=>h=>{const d=h.target;d.value=d.value.replace(/\D/g,"").slice(0,6),c(d.value)},r=(c,h)=>{var p;let d=c.querySelector(".pin-modal-validation");d||(d=document.createElement("p"),d.className="login-error pin-modal-validation",(p=c.querySelector("button[type=submit]"))==null||p.before(d)),d.textContent=h},l=c=>{c.preventDefault();const h=c.target;if(!n){if(t&&!i){r(h,"Enter your current PIN");return}if(!s){r(h,"Enter a new PIN");return}if(!o){r(h,"Confirm your new PIN");return}if(s!==o){r(h,"PINs do not match");return}if(s.length<4){r(h,"PIN must be 4–6 digits");return}e.onAccountPinSave(t?i:null,s)}};return u`
1925
- <div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onAccountPinModalClose()}}>
1924
+ `}function Kg(e){if(!e.accountPinModalOpen)return w;const t=e.accountHasPin,n=e.accountPinBusy;let i="",s="",o="";const a=d=>h=>{const l=h.target;l.value=l.value.replace(/\D/g,"").slice(0,6),d(l.value)},r=(d,h)=>{var p;let l=d.querySelector(".pin-modal-validation");l||(l=document.createElement("p"),l.className="login-error pin-modal-validation",(p=d.querySelector("button[type=submit]"))==null||p.before(l)),l.textContent=h},c=d=>{d.preventDefault();const h=d.target;if(!n){if(t&&!i){r(h,"Enter your current PIN");return}if(!s){r(h,"Enter a new PIN");return}if(!o){r(h,"Confirm your new PIN");return}if(s!==o){r(h,"PINs do not match");return}if(s.length<4){r(h,"PIN must be 4–6 digits");return}e.onAccountPinSave(t?i:null,s)}};return u`
1925
+ <div class="setup-info-overlay" @click=${d=>{d.target.classList.contains("setup-info-overlay")&&e.onAccountPinModalClose()}}>
1926
1926
  <div class="setup-info-card" style="max-width: 340px;">
1927
1927
  <div class="setup-info-header">
1928
1928
  <h3>${t?"Change Account PIN":"Set Account PIN"}</h3>
@@ -1930,7 +1930,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1930
1930
  ${L.close}
1931
1931
  </button>
1932
1932
  </div>
1933
- <form @submit=${l} style="display: flex; flex-direction: column; gap: 12px; padding: 16px 0 8px;">
1933
+ <form @submit=${c} style="display: flex; flex-direction: column; gap: 12px; padding: 16px 0 8px;">
1934
1934
  ${t?u`
1935
1935
  <input
1936
1936
  class="login-pin-input"
@@ -1941,7 +1941,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1941
1941
  maxlength="6"
1942
1942
  placeholder="Current PIN"
1943
1943
  ?disabled=${n}
1944
- @input=${a(c=>{i=c})}
1944
+ @input=${a(d=>{i=d})}
1945
1945
  autofocus
1946
1946
  />
1947
1947
  `:w}
@@ -1954,7 +1954,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1954
1954
  maxlength="6"
1955
1955
  placeholder="New PIN (4–6 digits)"
1956
1956
  ?disabled=${n}
1957
- @input=${a(c=>{s=c})}
1957
+ @input=${a(d=>{s=d})}
1958
1958
  ${t?w:u`autofocus`}
1959
1959
  />
1960
1960
  <input
@@ -1966,7 +1966,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1966
1966
  maxlength="6"
1967
1967
  placeholder="Confirm PIN"
1968
1968
  ?disabled=${n}
1969
- @input=${a(c=>{o=c})}
1969
+ @input=${a(d=>{o=d})}
1970
1970
  />
1971
1971
  ${e.accountPinError?u`<p class="login-error">${e.accountPinError}</p>`:w}
1972
1972
  ${e.accountPinSuccess?u`<p class="login-success">${e.accountPinSuccess}</p>`:w}
@@ -1978,7 +1978,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
1978
1978
  </form>
1979
1979
  </div>
1980
1980
  </div>
1981
- `}function Ng(e){if(!e.addingWorkspace)return w;const{workspaceSaving:t}=e,n=()=>{e.newWorkspaceName.trim()&&e.newWorkspacePin.match(/^\d{4,6}$/)&&e.onWorkspaceCreate(e.newWorkspaceName,e.newWorkspacePath||void 0)},i=s=>{const o=s.currentTarget,a=o.closest(".login-pin-wrapper"),r=a==null?void 0:a.querySelector("input");if(!r)return;const l=r.type==="text";r.type=l?"password":"text",o.classList.toggle("active",!l)};return u`
1981
+ `}function zg(e){if(!e.addingWorkspace)return w;const{workspaceSaving:t}=e,n=()=>{e.newWorkspaceName.trim()&&e.newWorkspacePin.match(/^\d{4,6}$/)&&e.onWorkspaceCreate(e.newWorkspaceName,e.newWorkspacePath||void 0)},i=s=>{const o=s.currentTarget,a=o.closest(".login-pin-wrapper"),r=a==null?void 0:a.querySelector("input");if(!r)return;const c=r.type==="text";r.type=c?"password":"text",o.classList.toggle("active",!c)};return u`
1982
1982
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
1983
1983
  <div class="setup-add-account">
1984
1984
  <strong>New Account</strong>
@@ -2041,7 +2041,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2041
2041
  </div>
2042
2042
  </div>
2043
2043
  </div>
2044
- `}function Og(e){const t=rn(e);return!t||t.isDefault?w:e.workspaceRemoveConfirm===t.name?u`
2044
+ `}function Hg(e){const t=rn(e);return!t||t.isDefault?w:e.workspaceRemoveConfirm===t.name?u`
2045
2045
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 12px;">
2046
2046
  <div style="font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
2047
2047
  <span style="color: var(--tasker-danger, #ef4444);">Remove "${t.displayName??t.name}" and its WhatsApp account?</span>
@@ -2070,7 +2070,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2070
2070
  @click=${i=>{i.preventDefault(),e.onSetWorkspaceRemoveConfirm(t.name)}}
2071
2071
  >Remove Account</a>
2072
2072
  </p>
2073
- `}function Fg(e){if(e.uninstallDone)return u`
2073
+ `}function qg(e){if(e.uninstallDone)return u`
2074
2074
  <div style="margin-top: 24px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
2075
2075
  <p style="color: var(--tasker-danger, #ef4444); font-size: 13px; font-weight: 600; margin: 0 0 8px 0;">
2076
2076
  Taskmaster has been uninstalled.
@@ -2125,11 +2125,11 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2125
2125
  @click=${t=>{t.preventDefault(),e.onUninstallConfirm()}}
2126
2126
  >Uninstall Taskmaster</a>
2127
2127
  </p>
2128
- `}function Ug(){return u`
2128
+ `}function jg(){return u`
2129
2129
  <p class="setup-hint" style="margin-top: 4px; font-size: 12px; opacity: 0.6;">
2130
2130
  Need help? <a href="https://wa.me/447591215452" target="_blank" rel="noopener" style="color: var(--tasker-orange);">Message Tuesday on WhatsApp</a>
2131
2131
  </p>
2132
- `}function Wg(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:i,whatsappLoginConnected:s,whatsappChannelStatus:o}=e;if(i)return u`
2132
+ `}function Gg(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:i,whatsappLoginConnected:s,whatsappChannelStatus:o}=e;if(i)return u`
2133
2133
  <div class="setup-container">
2134
2134
  <div class="setup-card">
2135
2135
  <h1>Scan with WhatsApp</h1>
@@ -2163,36 +2163,36 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2163
2163
  <p>${n||"Connecting to WhatsApp..."}</p>
2164
2164
  </div>
2165
2165
  </div>
2166
- `;const a=(o==null?void 0:o.running)&&(o==null?void 0:o.connected);if(o){const h=(e.whatsappAccounts.length>1?e.whatsappAccounts.every(d=>d.running&&d.connected):a)&&e.authConnected;return u`
2166
+ `;const a=(o==null?void 0:o.running)&&(o==null?void 0:o.connected);if(o){const h=(e.whatsappAccounts.length>1?e.whatsappAccounts.every(l=>l.running&&l.connected):a)&&e.authConnected;return u`
2167
2167
  <div class="setup-container">
2168
2168
  <div class="setup-card ${h?"setup-success":""} setup-dashboard-wide">
2169
- ${lg(e)}
2169
+ ${fg(e)}
2170
2170
  <div class="setup-status-dashboard">
2171
- ${cg(e)}
2172
- ${dg(e)}
2173
- ${ug(e)}
2174
- ${pg(e)}
2175
- ${e.serverPlatform==="darwin"?yg(e):w}
2176
- ${Dg(e)}
2177
- ${kg(e)}
2178
- ${$g(e)}
2179
- ${Cg(e)}
2171
+ ${gg(e)}
2172
+ ${mg(e)}
2173
+ ${yg(e)}
2174
+ ${vg(e)}
2175
+ ${e.serverPlatform==="darwin"?$g(e):w}
2176
+ ${Wg(e)}
2177
+ ${Eg(e)}
2180
2178
  ${_g(e)}
2181
2179
  ${Ig(e)}
2182
- ${Mg(e)}
2180
+ ${Dg(e)}
2181
+ ${Og(e)}
2182
+ ${Bg(e)}
2183
2183
  </div>
2184
2184
 
2185
- ${Bg(e)}
2186
- ${Eg(e)}
2187
- ${Sg(e)}
2185
+ ${Kg(e)}
2188
2186
  ${Lg(e)}
2189
- ${Pg(e)}
2190
- ${Tg(e)}
2191
- ${bg(e)}
2192
- ${Ng(e)}
2193
- ${Og(e)}
2187
+ ${Mg(e)}
2194
2188
  ${Fg(e)}
2195
- ${Ug()}
2189
+ ${Ng(e)}
2190
+ ${Rg(e)}
2191
+ ${Ag(e)}
2192
+ ${zg(e)}
2193
+ ${Hg(e)}
2194
+ ${qg(e)}
2195
+ ${jg()}
2196
2196
  ${e.workspacesError?u`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:w}
2197
2197
  </div>
2198
2198
  </div>
@@ -2237,7 +2237,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2237
2237
  </button>
2238
2238
  </div>
2239
2239
  </div>
2240
- `}function Kg(e){const{connected:t,currentStep:n}=e;if(t&&Ki()&&va(),e.uninstallDone||!t&&Ki())return u`
2240
+ `}function Vg(e){const{connected:t,currentStep:n}=e;if(t&&zi()&&ba(),e.uninstallDone||!t&&zi())return u`
2241
2241
  <div class="setup-container">
2242
2242
  <div class="setup-card">
2243
2243
  <p style="color: var(--tasker-danger, #ef4444); font-size: 16px; font-weight: 600; margin: 0 0 12px 0;">
@@ -2260,7 +2260,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2260
2260
  <p>${o?"Restarting gateway after update…":"Connecting to gateway..."}</p>
2261
2261
  </div>
2262
2262
  </div>
2263
- `}let i;switch(n){case"license":i=Pr(e);break;case"auth":i=rg(e);break;case"whatsapp":case"complete":i=Wg(e);break;default:i=Pr(e)}const s=Rt("Setup",e.wsProps);return u`${i}${ag(e)}${vg(e)}${mg(e)}${Rg(e)}${Ag(e)}${s}`}function zg(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return u`
2263
+ `}let i;switch(n){case"license":i=Rr(e);break;case"auth":i=hg(e);break;case"whatsapp":case"complete":i=Gg(e);break;default:i=Rr(e)}const s=Rt("Setup",e.wsProps);return u`${i}${pg(e)}${Sg(e)}${xg(e)}${Ug(e)}${Pg(e)}${s}`}function Qg(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return u`
2264
2264
  <div class="sp-list-item">
2265
2265
  <div class="sp-list-item-main">
2266
2266
  <div class="sp-list-item-title">${e.phone}</div>
@@ -2275,7 +2275,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2275
2275
  Remove
2276
2276
  </button>`}
2277
2277
  </div>
2278
- `}function qg(e){if(!e.connected)return u`
2278
+ `}function Jg(e){if(!e.connected)return u`
2279
2279
  <div class="setup-container">
2280
2280
  <div class="setup-card">
2281
2281
  <div class="setup-spinner"></div>
@@ -2324,7 +2324,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2324
2324
  </form>
2325
2325
 
2326
2326
  <div class="sp-list" style="margin-top: 20px;">
2327
- ${e.phones.length===0?u`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>zg(n,e))}
2327
+ ${e.phones.length===0?u`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>Qg(n,e))}
2328
2328
  </div>
2329
2329
 
2330
2330
  <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
@@ -2335,13 +2335,13 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2335
2335
 
2336
2336
  </div>
2337
2337
  </div>
2338
- `}const ud=u`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`;function Hg(e){return Object.keys(e.fields).length}function jg(e,t){return u`
2338
+ `}const gd=u`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`;function Yg(e){return Object.keys(e.fields).length}function Xg(e,t){return u`
2339
2339
  <div class="event-modal-overlay" @click=${t.onDeleteConfirmClose}>
2340
2340
  <div class="event-modal" style="width: min(400px, 100%);" @click=${n=>n.stopPropagation()}>
2341
2341
  <div class="event-modal__header">
2342
2342
  <div class="event-modal__title">Delete Contact</div>
2343
2343
  <button class="event-modal__close" @click=${t.onDeleteConfirmClose}>
2344
- ${ud}
2344
+ ${gd}
2345
2345
  </button>
2346
2346
  </div>
2347
2347
  <p style="margin: 0 0 8px; color: rgba(255,255,255,0.7); font-size: 14px; line-height: 1.5;">
@@ -2367,13 +2367,13 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2367
2367
  </div>
2368
2368
  </div>
2369
2369
  </div>
2370
- `}function Gg(e,t){const n=t.addFieldKey.trim().length>0,i=s=>{s.preventDefault(),n&&t.onAddFieldSubmit()};return u`
2370
+ `}function Zg(e,t){const n=t.addFieldKey.trim().length>0,i=s=>{s.preventDefault(),n&&t.onAddFieldSubmit()};return u`
2371
2371
  <div class="event-modal-overlay" @click=${t.onAddFieldClose}>
2372
2372
  <div class="event-modal" style="width: min(400px, 100%);" @click=${s=>s.stopPropagation()}>
2373
2373
  <div class="event-modal__header">
2374
2374
  <div class="event-modal__title">Add Field</div>
2375
2375
  <button class="event-modal__close" @click=${t.onAddFieldClose}>
2376
- ${ud}
2376
+ ${gd}
2377
2377
  </button>
2378
2378
  </div>
2379
2379
  <p style="margin: 0 0 16px; color: rgba(255,255,255,0.5); font-size: 13px;">
@@ -2418,7 +2418,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2418
2418
  </form>
2419
2419
  </div>
2420
2420
  </div>
2421
- `}function Vg(e,t){const n=Object.entries(e.fields);return u`
2421
+ `}function em(e,t){const n=Object.entries(e.fields);return u`
2422
2422
  <div class="contacts-record-fields">
2423
2423
  ${n.length===0?u`<div style="color: rgba(255,255,255,0.4); font-size: 13px; margin-top: 12px;">No fields yet. Add one below.</div>`:n.map(([i,s])=>u`
2424
2424
  <div class="contacts-field-row">
@@ -2465,7 +2465,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2465
2465
  </button>
2466
2466
  </div>
2467
2467
  </div>
2468
- `}function Qg(e,t){const n=t.editingId===e.id,i=Hg(e),s=i===0?"No fields":`${i} field${i>1?"s":""}`;return u`
2468
+ `}function tm(e,t){const n=t.editingId===e.id,i=Yg(e),s=i===0?"No fields":`${i} field${i>1?"s":""}`;return u`
2469
2469
  <div class="contacts-record">
2470
2470
  <div
2471
2471
  class="contacts-record-header"
@@ -2477,9 +2477,9 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2477
2477
  </div>
2478
2478
  <span class="contacts-record-meta">${s}</span>
2479
2479
  </div>
2480
- ${n?Vg(e,t):w}
2480
+ ${n?em(e,t):w}
2481
2481
  </div>
2482
- `}function Jg(e){if(!e.connected)return u`
2482
+ `}function nm(e){if(!e.connected)return u`
2483
2483
  <div class="setup-container">
2484
2484
  <div class="setup-card">
2485
2485
  <div class="setup-spinner"></div>
@@ -2575,7 +2575,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2575
2575
  <div style="margin-top: 16px;">
2576
2576
  ${e.records.length===0?u`<div class="contacts-empty">
2577
2577
  ${e.searchQuery.trim()?`No records matching "${e.searchQuery}".`:"No contact records yet. Add one to get started."}
2578
- </div>`:e.records.map(o=>Qg(o,e))}
2578
+ </div>`:e.records.map(o=>tm(o,e))}
2579
2579
  </div>
2580
2580
 
2581
2581
  <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
@@ -2587,49 +2587,49 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
2587
2587
  </div>
2588
2588
  </div>
2589
2589
 
2590
- ${i?jg(i,e):w}
2591
- ${s?Gg(s,e):w}
2592
- `}const pd={CHILD:2},hd=e=>(...t)=>({_$litDirective$:e,values:t});let fd=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,i){this._$Ct=t,this._$AM=n,this._$Ci=i}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:Yg}=op,Lr=e=>e,Rr=()=>document.createComment(""),gn=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const a=i.insertBefore(Rr(),s),r=i.insertBefore(Rr(),s);n=new Yg(a,r,e,e.options)}else{const a=n._$AB.nextSibling,r=n._$AM,l=r!==e;if(l){let c;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==r._$AU&&n._$AP(c)}if(a!==s||l){let c=n._$AA;for(;c!==a;){const h=Lr(c).nextSibling;Lr(i).insertBefore(c,s),c=h}}}return n},mt=(e,t,n=e)=>(e._$AI(t,n),e),Xg={},Zg=(e,t=Xg)=>e._$AH=t,em=e=>e._$AH,Ws=e=>{e._$AR(),e._$AA.remove()};const Dr=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},tm=hd(class extends fd{constructor(e){if(super(e),e.type!==pd.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let i;n===void 0?n=t:t!==void 0&&(i=t);const s=[],o=[];let a=0;for(const r of e)s[a]=i?i(r,a):a,o[a]=n(r,a),a++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=em(e),{values:o,keys:a}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=a,o;const r=this.ut??(this.ut=[]),l=[];let c,h,d=0,p=s.length-1,g=0,$=o.length-1;for(;d<=p&&g<=$;)if(s[d]===null)d++;else if(s[p]===null)p--;else if(r[d]===a[g])l[g]=mt(s[d],o[g]),d++,g++;else if(r[p]===a[$])l[$]=mt(s[p],o[$]),p--,$--;else if(r[d]===a[$])l[$]=mt(s[d],o[$]),gn(e,l[$+1],s[d]),d++,$--;else if(r[p]===a[g])l[g]=mt(s[p],o[g]),gn(e,s[d],s[p]),p--,g++;else if(c===void 0&&(c=Dr(a,g,$),h=Dr(r,d,p)),c.has(r[d]))if(c.has(r[p])){const S=h.get(a[g]),T=S!==void 0?s[S]:null;if(T===null){const f=gn(e,s[d]);mt(f,o[g]),l[g]=f}else l[g]=mt(T,o[g]),gn(e,s[d],T),s[S]=null;g++}else Ws(s[p]),p--;else Ws(s[d]),d++;for(;g<=$;){const S=gn(e,l[$+1]);mt(S,o[g]),l[g++]=S}for(;d<=p;){const S=s[d++];S!==null&&Ws(S)}return this.ut=a,Zg(e,l),lt}});class Eo extends fd{constructor(t){if(super(t),this.it=w,t.type!==pd.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===w||t==null)return this._t=void 0,this.it=t;if(t===lt)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:[]}}}Eo.directiveName="unsafeHTML",Eo.resultType=1;const zi=hd(Eo);const{entries:gd,setPrototypeOf:Br,isFrozen:nm,getPrototypeOf:im,getOwnPropertyDescriptor:sm}=Object;let{freeze:ye,seal:xe,create:To}=Object,{apply:_o,construct:Mo}=typeof Reflect<"u"&&Reflect;ye||(ye=function(t){return t});xe||(xe=function(t){return t});_o||(_o=function(t,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),o=2;o<i;o++)s[o-2]=arguments[o];return t.apply(n,s)});Mo||(Mo=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return new t(...i)});const fi=ve(Array.prototype.forEach),om=ve(Array.prototype.lastIndexOf),Nr=ve(Array.prototype.pop),mn=ve(Array.prototype.push),am=ve(Array.prototype.splice),Ci=ve(String.prototype.toLowerCase),Ks=ve(String.prototype.toString),zs=ve(String.prototype.match),yn=ve(String.prototype.replace),rm=ve(String.prototype.indexOf),lm=ve(String.prototype.trim),$e=ve(Object.prototype.hasOwnProperty),ge=ve(RegExp.prototype.test),vn=cm(TypeError);function ve(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return _o(e,t,i)}}function cm(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Mo(e,n)}}function K(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ci;Br&&Br(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(nm(t)||(t[i]=o),s=o)}e[s]=!0}return e}function dm(e){for(let t=0;t<e.length;t++)$e(e,t)||(e[t]=null);return e}function Re(e){const t=To(null);for(const[n,i]of gd(e))$e(e,n)&&(Array.isArray(i)?t[n]=dm(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Re(i):t[n]=i);return t}function bn(e,t){for(;e!==null;){const i=sm(e,t);if(i){if(i.get)return ve(i.get);if(typeof i.value=="function")return ve(i.value)}e=im(e)}function n(){return null}return n}const Or=ye(["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"]),qs=ye(["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"]),Hs=ye(["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"]),um=ye(["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=ye(["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"]),pm=ye(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Fr=ye(["#text"]),Ur=ye(["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"]),Gs=ye(["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"]),Wr=ye(["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"]),gi=ye(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),hm=xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),fm=xe(/<%[\w\W]*|[\w\W]*%>/gm),gm=xe(/\$\{[\w\W]*/gm),mm=xe(/^data-[\-\w.\u00B7-\uFFFF]+$/),ym=xe(/^aria-[\-\w]+$/),md=xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),vm=xe(/^(?:\w+script|data):/i),bm=xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),yd=xe(/^html$/i),wm=xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var Kr=Object.freeze({__proto__:null,ARIA_ATTR:ym,ATTR_WHITESPACE:bm,CUSTOM_ELEMENT:wm,DATA_ATTR:mm,DOCTYPE_NAME:yd,ERB_EXPR:fm,IS_ALLOWED_URI:md,IS_SCRIPT_OR_DATA:vm,MUSTACHE_EXPR:hm,TMPLIT_EXPR:gm});const wn={element:1,text:3,progressingInstruction:7,comment:8,document:9},km=function(){return typeof window>"u"?null:window},xm=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(i=n.getAttribute(s));const o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},zr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function vd(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:km();const t=N=>vd(N);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==wn.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:r,Element:l,NodeFilter:c,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:p,trustedTypes:g}=e,$=l.prototype,S=bn($,"cloneNode"),T=bn($,"remove"),f=bn($,"nextSibling"),b=bn($,"childNodes"),k=bn($,"parentNode");if(typeof a=="function"){const N=n.createElement("template");N.content&&N.content.ownerDocument&&(n=N.content.ownerDocument)}let A,E="";const{implementation:M,createNodeIterator:P,createDocumentFragment:R,getElementsByTagName:F}=n,{importNode:H}=i;let z=zr();t.isSupported=typeof gd=="function"&&typeof k=="function"&&M&&M.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ke,ERB_EXPR:_e,TMPLIT_EXPR:Ke,DATA_ATTR:ms,ARIA_ATTR:ys,IS_SCRIPT_OR_DATA:vs,ATTR_WHITESPACE:Qn,CUSTOM_ELEMENT:bs}=Kr;let{IS_ALLOWED_URI:Jn}=Kr,te=null;const Yn=K({},[...Or,...qs,...Hs,...js,...Fr]);let ne=null;const Xn=K({},[...Ur,...Gs,...Wr,...gi]);let X=Object.seal(To(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}})),pt=null,dn=null;const tt=Object.seal(To(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Zn=!0,C=!0,I=!1,U=!0,W=!1,Z=!0,J=!1,fe=!1,nt=!1,Nt=!1,ei=!1,ti=!1,Ua=!0,Wa=!1;const Tu="user-content-";let ws=!0,un=!1,Ot={},Me=null;const ks=K({},["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 Ka=null;const za=K({},["audio","video","img","source","image","track"]);let xs=null;const qa=K({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ni="http://www.w3.org/1998/Math/MathML",ii="http://www.w3.org/2000/svg",ze="http://www.w3.org/1999/xhtml";let Ft=ze,$s=!1,Ss=null;const _u=K({},[ni,ii,ze],Ks);let si=K({},["mi","mo","mn","ms","mtext"]),oi=K({},["annotation-xml"]);const Mu=K({},["title","style","font","a","script"]);let pn=null;const Pu=["application/xhtml+xml","text/html"],Iu="text/html";let oe=null,Ut=null;const Lu=n.createElement("form"),Ha=function(x){return x instanceof RegExp||x instanceof Function},As=function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ut&&Ut===x)){if((!x||typeof x!="object")&&(x={}),x=Re(x),pn=Pu.indexOf(x.PARSER_MEDIA_TYPE)===-1?Iu:x.PARSER_MEDIA_TYPE,oe=pn==="application/xhtml+xml"?Ks:Ci,te=$e(x,"ALLOWED_TAGS")?K({},x.ALLOWED_TAGS,oe):Yn,ne=$e(x,"ALLOWED_ATTR")?K({},x.ALLOWED_ATTR,oe):Xn,Ss=$e(x,"ALLOWED_NAMESPACES")?K({},x.ALLOWED_NAMESPACES,Ks):_u,xs=$e(x,"ADD_URI_SAFE_ATTR")?K(Re(qa),x.ADD_URI_SAFE_ATTR,oe):qa,Ka=$e(x,"ADD_DATA_URI_TAGS")?K(Re(za),x.ADD_DATA_URI_TAGS,oe):za,Me=$e(x,"FORBID_CONTENTS")?K({},x.FORBID_CONTENTS,oe):ks,pt=$e(x,"FORBID_TAGS")?K({},x.FORBID_TAGS,oe):Re({}),dn=$e(x,"FORBID_ATTR")?K({},x.FORBID_ATTR,oe):Re({}),Ot=$e(x,"USE_PROFILES")?x.USE_PROFILES:!1,Zn=x.ALLOW_ARIA_ATTR!==!1,C=x.ALLOW_DATA_ATTR!==!1,I=x.ALLOW_UNKNOWN_PROTOCOLS||!1,U=x.ALLOW_SELF_CLOSE_IN_ATTR!==!1,W=x.SAFE_FOR_TEMPLATES||!1,Z=x.SAFE_FOR_XML!==!1,J=x.WHOLE_DOCUMENT||!1,Nt=x.RETURN_DOM||!1,ei=x.RETURN_DOM_FRAGMENT||!1,ti=x.RETURN_TRUSTED_TYPE||!1,nt=x.FORCE_BODY||!1,Ua=x.SANITIZE_DOM!==!1,Wa=x.SANITIZE_NAMED_PROPS||!1,ws=x.KEEP_CONTENT!==!1,un=x.IN_PLACE||!1,Jn=x.ALLOWED_URI_REGEXP||md,Ft=x.NAMESPACE||ze,si=x.MATHML_TEXT_INTEGRATION_POINTS||si,oi=x.HTML_INTEGRATION_POINTS||oi,X=x.CUSTOM_ELEMENT_HANDLING||{},x.CUSTOM_ELEMENT_HANDLING&&Ha(x.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(X.tagNameCheck=x.CUSTOM_ELEMENT_HANDLING.tagNameCheck),x.CUSTOM_ELEMENT_HANDLING&&Ha(x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(X.attributeNameCheck=x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),x.CUSTOM_ELEMENT_HANDLING&&typeof x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(X.allowCustomizedBuiltInElements=x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),W&&(C=!1),ei&&(Nt=!0),Ot&&(te=K({},Fr),ne=[],Ot.html===!0&&(K(te,Or),K(ne,Ur)),Ot.svg===!0&&(K(te,qs),K(ne,Gs),K(ne,gi)),Ot.svgFilters===!0&&(K(te,Hs),K(ne,Gs),K(ne,gi)),Ot.mathMl===!0&&(K(te,js),K(ne,Wr),K(ne,gi))),x.ADD_TAGS&&(typeof x.ADD_TAGS=="function"?tt.tagCheck=x.ADD_TAGS:(te===Yn&&(te=Re(te)),K(te,x.ADD_TAGS,oe))),x.ADD_ATTR&&(typeof x.ADD_ATTR=="function"?tt.attributeCheck=x.ADD_ATTR:(ne===Xn&&(ne=Re(ne)),K(ne,x.ADD_ATTR,oe))),x.ADD_URI_SAFE_ATTR&&K(xs,x.ADD_URI_SAFE_ATTR,oe),x.FORBID_CONTENTS&&(Me===ks&&(Me=Re(Me)),K(Me,x.FORBID_CONTENTS,oe)),x.ADD_FORBID_CONTENTS&&(Me===ks&&(Me=Re(Me)),K(Me,x.ADD_FORBID_CONTENTS,oe)),ws&&(te["#text"]=!0),J&&K(te,["html","head","body"]),te.table&&(K(te,["tbody"]),delete pt.tbody),x.TRUSTED_TYPES_POLICY){if(typeof x.TRUSTED_TYPES_POLICY.createHTML!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof x.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=x.TRUSTED_TYPES_POLICY,E=A.createHTML("")}else A===void 0&&(A=xm(g,s)),A!==null&&typeof E=="string"&&(E=A.createHTML(""));ye&&ye(x),Ut=x}},ja=K({},[...qs,...Hs,...um]),Ga=K({},[...js,...pm]),Ru=function(x){let _=k(x);(!_||!_.tagName)&&(_={namespaceURI:Ft,tagName:"template"});const B=Ci(x.tagName),Y=Ci(_.tagName);return Ss[x.namespaceURI]?x.namespaceURI===ii?_.namespaceURI===ze?B==="svg":_.namespaceURI===ni?B==="svg"&&(Y==="annotation-xml"||si[Y]):!!ja[B]:x.namespaceURI===ni?_.namespaceURI===ze?B==="math":_.namespaceURI===ii?B==="math"&&oi[Y]:!!Ga[B]:x.namespaceURI===ze?_.namespaceURI===ii&&!oi[Y]||_.namespaceURI===ni&&!si[Y]?!1:!Ga[B]&&(Mu[B]||!ja[B]):!!(pn==="application/xhtml+xml"&&Ss[x.namespaceURI]):!1},Pe=function(x){mn(t.removed,{element:x});try{k(x).removeChild(x)}catch{T(x)}},ht=function(x,_){try{mn(t.removed,{attribute:_.getAttributeNode(x),from:_})}catch{mn(t.removed,{attribute:null,from:_})}if(_.removeAttribute(x),x==="is")if(Nt||ei)try{Pe(_)}catch{}else try{_.setAttribute(x,"")}catch{}},Va=function(x){let _=null,B=null;if(nt)x="<remove></remove>"+x;else{const se=zs(x,/^[\r\n\t ]+/);B=se&&se[0]}pn==="application/xhtml+xml"&&Ft===ze&&(x='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+x+"</body></html>");const Y=A?A.createHTML(x):x;if(Ft===ze)try{_=new p().parseFromString(Y,pn)}catch{}if(!_||!_.documentElement){_=M.createDocument(Ft,"template",null);try{_.documentElement.innerHTML=$s?E:Y}catch{}}const de=_.body||_.documentElement;return x&&B&&de.insertBefore(n.createTextNode(B),de.childNodes[0]||null),Ft===ze?F.call(_,J?"html":"body")[0]:J?_.documentElement:de},Qa=function(x){return P.call(x.ownerDocument||x,x,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Cs=function(x){return x instanceof d&&(typeof x.nodeName!="string"||typeof x.textContent!="string"||typeof x.removeChild!="function"||!(x.attributes instanceof h)||typeof x.removeAttribute!="function"||typeof x.setAttribute!="function"||typeof x.namespaceURI!="string"||typeof x.insertBefore!="function"||typeof x.hasChildNodes!="function")},Ja=function(x){return typeof r=="function"&&x instanceof r};function qe(N,x,_){fi(N,B=>{B.call(t,x,_,Ut)})}const Ya=function(x){let _=null;if(qe(z.beforeSanitizeElements,x,null),Cs(x))return Pe(x),!0;const B=oe(x.nodeName);if(qe(z.uponSanitizeElement,x,{tagName:B,allowedTags:te}),Z&&x.hasChildNodes()&&!Ja(x.firstElementChild)&&ge(/<[/\w!]/g,x.innerHTML)&&ge(/<[/\w!]/g,x.textContent)||x.nodeType===wn.progressingInstruction||Z&&x.nodeType===wn.comment&&ge(/<[/\w]/g,x.data))return Pe(x),!0;if(!(tt.tagCheck instanceof Function&&tt.tagCheck(B))&&(!te[B]||pt[B])){if(!pt[B]&&Za(B)&&(X.tagNameCheck instanceof RegExp&&ge(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B)))return!1;if(ws&&!Me[B]){const Y=k(x)||x.parentNode,de=b(x)||x.childNodes;if(de&&Y){const se=de.length;for(let be=se-1;be>=0;--be){const He=S(de[be],!0);He.__removalCount=(x.__removalCount||0)+1,Y.insertBefore(He,f(x))}}}return Pe(x),!0}return x instanceof l&&!Ru(x)||(B==="noscript"||B==="noembed"||B==="noframes")&&ge(/<\/no(script|embed|frames)/i,x.innerHTML)?(Pe(x),!0):(W&&x.nodeType===wn.text&&(_=x.textContent,fi([ke,_e,Ke],Y=>{_=yn(_,Y," ")}),x.textContent!==_&&(mn(t.removed,{element:x.cloneNode()}),x.textContent=_)),qe(z.afterSanitizeElements,x,null),!1)},Xa=function(x,_,B){if(Ua&&(_==="id"||_==="name")&&(B in n||B in Lu))return!1;if(!(C&&!dn[_]&&ge(ms,_))){if(!(Zn&&ge(ys,_))){if(!(tt.attributeCheck instanceof Function&&tt.attributeCheck(_,x))){if(!ne[_]||dn[_]){if(!(Za(x)&&(X.tagNameCheck instanceof RegExp&&ge(X.tagNameCheck,x)||X.tagNameCheck instanceof Function&&X.tagNameCheck(x))&&(X.attributeNameCheck instanceof RegExp&&ge(X.attributeNameCheck,_)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(_,x))||_==="is"&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&ge(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B))))return!1}else if(!xs[_]){if(!ge(Jn,yn(B,Qn,""))){if(!((_==="src"||_==="xlink:href"||_==="href")&&x!=="script"&&rm(B,"data:")===0&&Ka[x])){if(!(I&&!ge(vs,yn(B,Qn,"")))){if(B)return!1}}}}}}}return!0},Za=function(x){return x!=="annotation-xml"&&zs(x,bs)},er=function(x){qe(z.beforeSanitizeAttributes,x,null);const{attributes:_}=x;if(!_||Cs(x))return;const B={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let Y=_.length;for(;Y--;){const de=_[Y],{name:se,namespaceURI:be,value:He}=de,Wt=oe(se),Es=He;let re=se==="value"?Es:lm(Es);if(B.attrName=Wt,B.attrValue=re,B.keepAttr=!0,B.forceKeepAttr=void 0,qe(z.uponSanitizeAttribute,x,B),re=B.attrValue,Wa&&(Wt==="id"||Wt==="name")&&(ht(se,x),re=Tu+re),Z&&ge(/((--!?|])>)|<\/(style|title|textarea)/i,re)){ht(se,x);continue}if(Wt==="attributename"&&zs(re,"href")){ht(se,x);continue}if(B.forceKeepAttr)continue;if(!B.keepAttr){ht(se,x);continue}if(!U&&ge(/\/>/i,re)){ht(se,x);continue}W&&fi([ke,_e,Ke],nr=>{re=yn(re,nr," ")});const tr=oe(x.nodeName);if(!Xa(tr,Wt,re)){ht(se,x);continue}if(A&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!be)switch(g.getAttributeType(tr,Wt)){case"TrustedHTML":{re=A.createHTML(re);break}case"TrustedScriptURL":{re=A.createScriptURL(re);break}}if(re!==Es)try{be?x.setAttributeNS(be,se,re):x.setAttribute(se,re),Cs(x)?Pe(x):Nr(t.removed)}catch{ht(se,x)}}qe(z.afterSanitizeAttributes,x,null)},Du=function N(x){let _=null;const B=Qa(x);for(qe(z.beforeSanitizeShadowDOM,x,null);_=B.nextNode();)qe(z.uponSanitizeShadowNode,_,null),Ya(_),er(_),_.content instanceof o&&N(_.content);qe(z.afterSanitizeShadowDOM,x,null)};return t.sanitize=function(N){let x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=null,B=null,Y=null,de=null;if($s=!N,$s&&(N="<!-->"),typeof N!="string"&&!Ja(N))if(typeof N.toString=="function"){if(N=N.toString(),typeof N!="string")throw vn("dirty is not a string, aborting")}else throw vn("toString is not a function");if(!t.isSupported)return N;if(fe||As(x),t.removed=[],typeof N=="string"&&(un=!1),un){if(N.nodeName){const He=oe(N.nodeName);if(!te[He]||pt[He])throw vn("root node is forbidden and cannot be sanitized in-place")}}else if(N instanceof r)_=Va("<!---->"),B=_.ownerDocument.importNode(N,!0),B.nodeType===wn.element&&B.nodeName==="BODY"||B.nodeName==="HTML"?_=B:_.appendChild(B);else{if(!Nt&&!W&&!J&&N.indexOf("<")===-1)return A&&ti?A.createHTML(N):N;if(_=Va(N),!_)return Nt?null:ti?E:""}_&&nt&&Pe(_.firstChild);const se=Qa(un?N:_);for(;Y=se.nextNode();)Ya(Y),er(Y),Y.content instanceof o&&Du(Y.content);if(un)return N;if(Nt){if(ei)for(de=R.call(_.ownerDocument);_.firstChild;)de.appendChild(_.firstChild);else de=_;return(ne.shadowroot||ne.shadowrootmode)&&(de=H.call(i,de,!0)),de}let be=J?_.outerHTML:_.innerHTML;return J&&te["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&ge(yd,_.ownerDocument.doctype.name)&&(be="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
2593
- `+be),W&&fi([ke,_e,Ke],He=>{be=yn(be,He," ")}),A&&ti?A.createHTML(be):be},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};As(N),fe=!0},t.clearConfig=function(){Ut=null,fe=!1},t.isValidAttribute=function(N,x,_){Ut||As({});const B=oe(N),Y=oe(x);return Xa(B,Y,_)},t.addHook=function(N,x){typeof x=="function"&&mn(z[N],x)},t.removeHook=function(N,x){if(x!==void 0){const _=om(z[N],x);return _===-1?void 0:am(z[N],_,1)[0]}return Nr(z[N])},t.removeHooks=function(N){z[N]=[]},t.removeAllHooks=function(){z=zr()},t}var Po=vd();function xa(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Dt=xa();function bd(e){Dt=e}var In={exec:()=>null};function j(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(s,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(me.caret,"$1"),n=n.replace(s,a),i},getRegex:()=>new RegExp(n,t)};return i}var $m=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),me={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")},Sm=/^(?:[ \t]*(?:\n|$))+/,Am=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Cm=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Gn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Em=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,$a=/(?:[*+-]|\d{1,9}[.)])/,wd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,kd=j(wd).replace(/bull/g,$a).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(),Tm=j(wd).replace(/bull/g,$a).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(),Sa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,_m=/^[^\n]+/,Aa=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Mm=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Aa).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Pm=j(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,$a).getRegex(),ds="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",Ca=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Im=j("^ {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",Ca).replace("tag",ds).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),xd=j(Sa).replace("hr",Gn).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",ds).getRegex(),Lm=j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",xd).getRegex(),Ea={blockquote:Lm,code:Am,def:Mm,fences:Cm,heading:Em,hr:Gn,html:Im,lheading:kd,list:Pm,newline:Sm,paragraph:xd,table:In,text:_m},qr=j("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Gn).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",ds).getRegex(),Rm={...Ea,lheading:Tm,table:qr,paragraph:j(Sa).replace("hr",Gn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",qr).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",ds).getRegex()},Dm={...Ea,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ca).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:In,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(Sa).replace("hr",Gn).replace("heading",` *#{1,6} *[^
2594
- ]`).replace("lheading",kd).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Bm=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Nm=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$d=/^( {2,}|\\)\n(?!\s*$)/,Om=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,us=/[\p{P}\p{S}]/u,Ta=/[\s\p{P}\p{S}]/u,Sd=/[^\s\p{P}\p{S}]/u,Fm=j(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ta).getRegex(),Ad=/(?!~)[\p{P}\p{S}]/u,Um=/(?!~)[\s\p{P}\p{S}]/u,Wm=/(?:[^\s\p{P}\p{S}]|~)/u,Km=j(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",$m?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Cd=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,zm=j(Cd,"u").replace(/punct/g,us).getRegex(),qm=j(Cd,"u").replace(/punct/g,Ad).getRegex(),Ed="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Hm=j(Ed,"gu").replace(/notPunctSpace/g,Sd).replace(/punctSpace/g,Ta).replace(/punct/g,us).getRegex(),jm=j(Ed,"gu").replace(/notPunctSpace/g,Wm).replace(/punctSpace/g,Um).replace(/punct/g,Ad).getRegex(),Gm=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Sd).replace(/punctSpace/g,Ta).replace(/punct/g,us).getRegex(),Vm=j(/\\(punct)/,"gu").replace(/punct/g,us).getRegex(),Qm=j(/^<(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(),Jm=j(Ca).replace("(?:-->|$)","-->").getRegex(),Ym=j("^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",Jm).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Xm=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",qi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Td=j(/^!?\[(label)\]\[(ref)\]/).replace("label",qi).replace("ref",Aa).getRegex(),_d=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",Aa).getRegex(),Zm=j("reflink|nolink(?!\\()","g").replace("reflink",Td).replace("nolink",_d).getRegex(),Hr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,_a={_backpedal:In,anyPunctuation:Vm,autolink:Qm,blockSkip:Km,br:$d,code:Nm,del:In,emStrongLDelim:zm,emStrongRDelimAst:Hm,emStrongRDelimUnd:Gm,escape:Bm,link:Xm,nolink:_d,punctuation:Fm,reflink:Td,reflinkSearch:Zm,tag:Ym,text:Om,url:In},ey={..._a,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",qi).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qi).getRegex()},Io={..._a,emStrongRDelimAst:jm,emStrongLDelim:qm,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Hr).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:j(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Hr).getRegex()},ty={...Io,br:j($d).replace("{2,}","*").getRegex(),text:j(Io.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},mi={normal:Ea,gfm:Rm,pedantic:Dm},kn={normal:_a,gfm:Io,breaks:ty,pedantic:ey},ny={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},jr=e=>ny[e];function Ve(e,t){if(t){if(me.escapeTest.test(e))return e.replace(me.escapeReplace,jr)}else if(me.escapeTestNoEncode.test(e))return e.replace(me.escapeReplaceNoEncode,jr);return e}function Gr(e){try{e=encodeURI(e).replace(me.percentDecode,"%")}catch{return null}return e}function Vr(e,t){var o;let n=e.replace(me.findPipe,(a,r,l)=>{let c=!1,h=r;for(;--h>=0&&l[h]==="\\";)c=!c;return c?"|":" |"}),i=n.split(me.splitPipe),s=0;if(i[0].trim()||i.shift(),i.length>0&&!((o=i.at(-1))!=null&&o.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(me.slashPipe,"|");return i}function xn(e,t,n){let i=e.length;if(i===0)return"";let s=0;for(;s<i&&e.charAt(i-s-1)===t;)s++;return e.slice(0,i-s)}function iy(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}function Qr(e,t,n,i,s){let o=t.href,a=t.title||null,r=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:r,tokens:i.inlineTokens(r)};return i.state.inLink=!1,l}function sy(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
2590
+ ${i?Xg(i,e):w}
2591
+ ${s?Zg(s,e):w}
2592
+ `}const md={CHILD:2},yd=e=>(...t)=>({_$litDirective$:e,values:t});let vd=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,i){this._$Ct=t,this._$AM=n,this._$Ci=i}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:im}=up,Br=e=>e,Nr=()=>document.createComment(""),gn=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const a=i.insertBefore(Nr(),s),r=i.insertBefore(Nr(),s);n=new im(a,r,e,e.options)}else{const a=n._$AB.nextSibling,r=n._$AM,c=r!==e;if(c){let d;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(d=e._$AU)!==r._$AU&&n._$AP(d)}if(a!==s||c){let d=n._$AA;for(;d!==a;){const h=Br(d).nextSibling;Br(i).insertBefore(d,s),d=h}}}return n},mt=(e,t,n=e)=>(e._$AI(t,n),e),sm={},om=(e,t=sm)=>e._$AH=t,am=e=>e._$AH,Ks=e=>{e._$AR(),e._$AA.remove()};const Or=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},rm=yd(class extends vd{constructor(e){if(super(e),e.type!==md.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let i;n===void 0?n=t:t!==void 0&&(i=t);const s=[],o=[];let a=0;for(const r of e)s[a]=i?i(r,a):a,o[a]=n(r,a),a++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=am(e),{values:o,keys:a}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=a,o;const r=this.ut??(this.ut=[]),c=[];let d,h,l=0,p=s.length-1,g=0,$=o.length-1;for(;l<=p&&g<=$;)if(s[l]===null)l++;else if(s[p]===null)p--;else if(r[l]===a[g])c[g]=mt(s[l],o[g]),l++,g++;else if(r[p]===a[$])c[$]=mt(s[p],o[$]),p--,$--;else if(r[l]===a[$])c[$]=mt(s[l],o[$]),gn(e,c[$+1],s[l]),l++,$--;else if(r[p]===a[g])c[g]=mt(s[p],o[g]),gn(e,s[l],s[p]),p--,g++;else if(d===void 0&&(d=Or(a,g,$),h=Or(r,l,p)),d.has(r[l]))if(d.has(r[p])){const S=h.get(a[g]),T=S!==void 0?s[S]:null;if(T===null){const f=gn(e,s[l]);mt(f,o[g]),c[g]=f}else c[g]=mt(T,o[g]),gn(e,s[l],T),s[S]=null;g++}else Ks(s[p]),p--;else Ks(s[l]),l++;for(;g<=$;){const S=gn(e,c[$+1]);mt(S,o[g]),c[g++]=S}for(;l<=p;){const S=s[l++];S!==null&&Ks(S)}return this.ut=a,om(e,c),lt}});class To extends vd{constructor(t){if(super(t),this.it=w,t.type!==md.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===w||t==null)return this._t=void 0,this.it=t;if(t===lt)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:[]}}}To.directiveName="unsafeHTML",To.resultType=1;const Hi=yd(To);const{entries:bd,setPrototypeOf:Fr,isFrozen:lm,getPrototypeOf:cm,getOwnPropertyDescriptor:dm}=Object;let{freeze:ye,seal:xe,create:_o}=Object,{apply:Mo,construct:Po}=typeof Reflect<"u"&&Reflect;ye||(ye=function(t){return t});xe||(xe=function(t){return t});Mo||(Mo=function(t,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),o=2;o<i;o++)s[o-2]=arguments[o];return t.apply(n,s)});Po||(Po=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return new t(...i)});const fi=ve(Array.prototype.forEach),um=ve(Array.prototype.lastIndexOf),Ur=ve(Array.prototype.pop),mn=ve(Array.prototype.push),pm=ve(Array.prototype.splice),Ei=ve(String.prototype.toLowerCase),zs=ve(String.prototype.toString),Hs=ve(String.prototype.match),yn=ve(String.prototype.replace),hm=ve(String.prototype.indexOf),fm=ve(String.prototype.trim),$e=ve(Object.prototype.hasOwnProperty),ge=ve(RegExp.prototype.test),vn=gm(TypeError);function ve(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return Mo(e,t,i)}}function gm(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Po(e,n)}}function K(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ei;Fr&&Fr(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(lm(t)||(t[i]=o),s=o)}e[s]=!0}return e}function mm(e){for(let t=0;t<e.length;t++)$e(e,t)||(e[t]=null);return e}function Re(e){const t=_o(null);for(const[n,i]of bd(e))$e(e,n)&&(Array.isArray(i)?t[n]=mm(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Re(i):t[n]=i);return t}function bn(e,t){for(;e!==null;){const i=dm(e,t);if(i){if(i.get)return ve(i.get);if(typeof i.value=="function")return ve(i.value)}e=cm(e)}function n(){return null}return n}const Wr=ye(["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"]),qs=ye(["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=ye(["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"]),ym=ye(["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"]),Gs=ye(["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"]),vm=ye(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Kr=ye(["#text"]),zr=ye(["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"]),Vs=ye(["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"]),Hr=ye(["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"]),gi=ye(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),bm=xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),wm=xe(/<%[\w\W]*|[\w\W]*%>/gm),km=xe(/\$\{[\w\W]*/gm),xm=xe(/^data-[\-\w.\u00B7-\uFFFF]+$/),$m=xe(/^aria-[\-\w]+$/),wd=xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Sm=xe(/^(?:\w+script|data):/i),Am=xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),kd=xe(/^html$/i),Cm=xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var qr=Object.freeze({__proto__:null,ARIA_ATTR:$m,ATTR_WHITESPACE:Am,CUSTOM_ELEMENT:Cm,DATA_ATTR:xm,DOCTYPE_NAME:kd,ERB_EXPR:wm,IS_ALLOWED_URI:wd,IS_SCRIPT_OR_DATA:Sm,MUSTACHE_EXPR:bm,TMPLIT_EXPR:km});const wn={element:1,text:3,progressingInstruction:7,comment:8,document:9},Em=function(){return typeof window>"u"?null:window},Tm=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(i=n.getAttribute(s));const o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},jr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function xd(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Em();const t=N=>xd(N);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==wn.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:r,Element:c,NodeFilter:d,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:l,DOMParser:p,trustedTypes:g}=e,$=c.prototype,S=bn($,"cloneNode"),T=bn($,"remove"),f=bn($,"nextSibling"),b=bn($,"childNodes"),k=bn($,"parentNode");if(typeof a=="function"){const N=n.createElement("template");N.content&&N.content.ownerDocument&&(n=N.content.ownerDocument)}let A,E="";const{implementation:M,createNodeIterator:P,createDocumentFragment:R,getElementsByTagName:F}=n,{importNode:q}=i;let z=jr();t.isSupported=typeof bd=="function"&&typeof k=="function"&&M&&M.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ke,ERB_EXPR:_e,TMPLIT_EXPR:Ke,DATA_ATTR:ys,ARIA_ATTR:vs,IS_SCRIPT_OR_DATA:bs,ATTR_WHITESPACE:Qn,CUSTOM_ELEMENT:ws}=qr;let{IS_ALLOWED_URI:Jn}=qr,te=null;const Yn=K({},[...Wr,...qs,...js,...Gs,...Kr]);let ne=null;const Xn=K({},[...zr,...Vs,...Hr,...gi]);let X=Object.seal(_o(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}})),pt=null,dn=null;const tt=Object.seal(_o(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Zn=!0,C=!0,I=!1,U=!0,W=!1,Z=!0,J=!1,fe=!1,nt=!1,Nt=!1,ei=!1,ti=!1,za=!0,Ha=!1;const Ru="user-content-";let ks=!0,un=!1,Ot={},Me=null;const xs=K({},["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 qa=null;const ja=K({},["audio","video","img","source","image","track"]);let $s=null;const Ga=K({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ni="http://www.w3.org/1998/Math/MathML",ii="http://www.w3.org/2000/svg",ze="http://www.w3.org/1999/xhtml";let Ft=ze,Ss=!1,As=null;const Du=K({},[ni,ii,ze],zs);let si=K({},["mi","mo","mn","ms","mtext"]),oi=K({},["annotation-xml"]);const Bu=K({},["title","style","font","a","script"]);let pn=null;const Nu=["application/xhtml+xml","text/html"],Ou="text/html";let oe=null,Ut=null;const Fu=n.createElement("form"),Va=function(x){return x instanceof RegExp||x instanceof Function},Cs=function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ut&&Ut===x)){if((!x||typeof x!="object")&&(x={}),x=Re(x),pn=Nu.indexOf(x.PARSER_MEDIA_TYPE)===-1?Ou:x.PARSER_MEDIA_TYPE,oe=pn==="application/xhtml+xml"?zs:Ei,te=$e(x,"ALLOWED_TAGS")?K({},x.ALLOWED_TAGS,oe):Yn,ne=$e(x,"ALLOWED_ATTR")?K({},x.ALLOWED_ATTR,oe):Xn,As=$e(x,"ALLOWED_NAMESPACES")?K({},x.ALLOWED_NAMESPACES,zs):Du,$s=$e(x,"ADD_URI_SAFE_ATTR")?K(Re(Ga),x.ADD_URI_SAFE_ATTR,oe):Ga,qa=$e(x,"ADD_DATA_URI_TAGS")?K(Re(ja),x.ADD_DATA_URI_TAGS,oe):ja,Me=$e(x,"FORBID_CONTENTS")?K({},x.FORBID_CONTENTS,oe):xs,pt=$e(x,"FORBID_TAGS")?K({},x.FORBID_TAGS,oe):Re({}),dn=$e(x,"FORBID_ATTR")?K({},x.FORBID_ATTR,oe):Re({}),Ot=$e(x,"USE_PROFILES")?x.USE_PROFILES:!1,Zn=x.ALLOW_ARIA_ATTR!==!1,C=x.ALLOW_DATA_ATTR!==!1,I=x.ALLOW_UNKNOWN_PROTOCOLS||!1,U=x.ALLOW_SELF_CLOSE_IN_ATTR!==!1,W=x.SAFE_FOR_TEMPLATES||!1,Z=x.SAFE_FOR_XML!==!1,J=x.WHOLE_DOCUMENT||!1,Nt=x.RETURN_DOM||!1,ei=x.RETURN_DOM_FRAGMENT||!1,ti=x.RETURN_TRUSTED_TYPE||!1,nt=x.FORCE_BODY||!1,za=x.SANITIZE_DOM!==!1,Ha=x.SANITIZE_NAMED_PROPS||!1,ks=x.KEEP_CONTENT!==!1,un=x.IN_PLACE||!1,Jn=x.ALLOWED_URI_REGEXP||wd,Ft=x.NAMESPACE||ze,si=x.MATHML_TEXT_INTEGRATION_POINTS||si,oi=x.HTML_INTEGRATION_POINTS||oi,X=x.CUSTOM_ELEMENT_HANDLING||{},x.CUSTOM_ELEMENT_HANDLING&&Va(x.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(X.tagNameCheck=x.CUSTOM_ELEMENT_HANDLING.tagNameCheck),x.CUSTOM_ELEMENT_HANDLING&&Va(x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(X.attributeNameCheck=x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),x.CUSTOM_ELEMENT_HANDLING&&typeof x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(X.allowCustomizedBuiltInElements=x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),W&&(C=!1),ei&&(Nt=!0),Ot&&(te=K({},Kr),ne=[],Ot.html===!0&&(K(te,Wr),K(ne,zr)),Ot.svg===!0&&(K(te,qs),K(ne,Vs),K(ne,gi)),Ot.svgFilters===!0&&(K(te,js),K(ne,Vs),K(ne,gi)),Ot.mathMl===!0&&(K(te,Gs),K(ne,Hr),K(ne,gi))),x.ADD_TAGS&&(typeof x.ADD_TAGS=="function"?tt.tagCheck=x.ADD_TAGS:(te===Yn&&(te=Re(te)),K(te,x.ADD_TAGS,oe))),x.ADD_ATTR&&(typeof x.ADD_ATTR=="function"?tt.attributeCheck=x.ADD_ATTR:(ne===Xn&&(ne=Re(ne)),K(ne,x.ADD_ATTR,oe))),x.ADD_URI_SAFE_ATTR&&K($s,x.ADD_URI_SAFE_ATTR,oe),x.FORBID_CONTENTS&&(Me===xs&&(Me=Re(Me)),K(Me,x.FORBID_CONTENTS,oe)),x.ADD_FORBID_CONTENTS&&(Me===xs&&(Me=Re(Me)),K(Me,x.ADD_FORBID_CONTENTS,oe)),ks&&(te["#text"]=!0),J&&K(te,["html","head","body"]),te.table&&(K(te,["tbody"]),delete pt.tbody),x.TRUSTED_TYPES_POLICY){if(typeof x.TRUSTED_TYPES_POLICY.createHTML!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof x.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=x.TRUSTED_TYPES_POLICY,E=A.createHTML("")}else A===void 0&&(A=Tm(g,s)),A!==null&&typeof E=="string"&&(E=A.createHTML(""));ye&&ye(x),Ut=x}},Qa=K({},[...qs,...js,...ym]),Ja=K({},[...Gs,...vm]),Uu=function(x){let _=k(x);(!_||!_.tagName)&&(_={namespaceURI:Ft,tagName:"template"});const B=Ei(x.tagName),Y=Ei(_.tagName);return As[x.namespaceURI]?x.namespaceURI===ii?_.namespaceURI===ze?B==="svg":_.namespaceURI===ni?B==="svg"&&(Y==="annotation-xml"||si[Y]):!!Qa[B]:x.namespaceURI===ni?_.namespaceURI===ze?B==="math":_.namespaceURI===ii?B==="math"&&oi[Y]:!!Ja[B]:x.namespaceURI===ze?_.namespaceURI===ii&&!oi[Y]||_.namespaceURI===ni&&!si[Y]?!1:!Ja[B]&&(Bu[B]||!Qa[B]):!!(pn==="application/xhtml+xml"&&As[x.namespaceURI]):!1},Pe=function(x){mn(t.removed,{element:x});try{k(x).removeChild(x)}catch{T(x)}},ht=function(x,_){try{mn(t.removed,{attribute:_.getAttributeNode(x),from:_})}catch{mn(t.removed,{attribute:null,from:_})}if(_.removeAttribute(x),x==="is")if(Nt||ei)try{Pe(_)}catch{}else try{_.setAttribute(x,"")}catch{}},Ya=function(x){let _=null,B=null;if(nt)x="<remove></remove>"+x;else{const se=Hs(x,/^[\r\n\t ]+/);B=se&&se[0]}pn==="application/xhtml+xml"&&Ft===ze&&(x='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+x+"</body></html>");const Y=A?A.createHTML(x):x;if(Ft===ze)try{_=new p().parseFromString(Y,pn)}catch{}if(!_||!_.documentElement){_=M.createDocument(Ft,"template",null);try{_.documentElement.innerHTML=Ss?E:Y}catch{}}const de=_.body||_.documentElement;return x&&B&&de.insertBefore(n.createTextNode(B),de.childNodes[0]||null),Ft===ze?F.call(_,J?"html":"body")[0]:J?_.documentElement:de},Xa=function(x){return P.call(x.ownerDocument||x,x,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Es=function(x){return x instanceof l&&(typeof x.nodeName!="string"||typeof x.textContent!="string"||typeof x.removeChild!="function"||!(x.attributes instanceof h)||typeof x.removeAttribute!="function"||typeof x.setAttribute!="function"||typeof x.namespaceURI!="string"||typeof x.insertBefore!="function"||typeof x.hasChildNodes!="function")},Za=function(x){return typeof r=="function"&&x instanceof r};function He(N,x,_){fi(N,B=>{B.call(t,x,_,Ut)})}const er=function(x){let _=null;if(He(z.beforeSanitizeElements,x,null),Es(x))return Pe(x),!0;const B=oe(x.nodeName);if(He(z.uponSanitizeElement,x,{tagName:B,allowedTags:te}),Z&&x.hasChildNodes()&&!Za(x.firstElementChild)&&ge(/<[/\w!]/g,x.innerHTML)&&ge(/<[/\w!]/g,x.textContent)||x.nodeType===wn.progressingInstruction||Z&&x.nodeType===wn.comment&&ge(/<[/\w]/g,x.data))return Pe(x),!0;if(!(tt.tagCheck instanceof Function&&tt.tagCheck(B))&&(!te[B]||pt[B])){if(!pt[B]&&nr(B)&&(X.tagNameCheck instanceof RegExp&&ge(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B)))return!1;if(ks&&!Me[B]){const Y=k(x)||x.parentNode,de=b(x)||x.childNodes;if(de&&Y){const se=de.length;for(let be=se-1;be>=0;--be){const qe=S(de[be],!0);qe.__removalCount=(x.__removalCount||0)+1,Y.insertBefore(qe,f(x))}}}return Pe(x),!0}return x instanceof c&&!Uu(x)||(B==="noscript"||B==="noembed"||B==="noframes")&&ge(/<\/no(script|embed|frames)/i,x.innerHTML)?(Pe(x),!0):(W&&x.nodeType===wn.text&&(_=x.textContent,fi([ke,_e,Ke],Y=>{_=yn(_,Y," ")}),x.textContent!==_&&(mn(t.removed,{element:x.cloneNode()}),x.textContent=_)),He(z.afterSanitizeElements,x,null),!1)},tr=function(x,_,B){if(za&&(_==="id"||_==="name")&&(B in n||B in Fu))return!1;if(!(C&&!dn[_]&&ge(ys,_))){if(!(Zn&&ge(vs,_))){if(!(tt.attributeCheck instanceof Function&&tt.attributeCheck(_,x))){if(!ne[_]||dn[_]){if(!(nr(x)&&(X.tagNameCheck instanceof RegExp&&ge(X.tagNameCheck,x)||X.tagNameCheck instanceof Function&&X.tagNameCheck(x))&&(X.attributeNameCheck instanceof RegExp&&ge(X.attributeNameCheck,_)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(_,x))||_==="is"&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&ge(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B))))return!1}else if(!$s[_]){if(!ge(Jn,yn(B,Qn,""))){if(!((_==="src"||_==="xlink:href"||_==="href")&&x!=="script"&&hm(B,"data:")===0&&qa[x])){if(!(I&&!ge(bs,yn(B,Qn,"")))){if(B)return!1}}}}}}}return!0},nr=function(x){return x!=="annotation-xml"&&Hs(x,ws)},ir=function(x){He(z.beforeSanitizeAttributes,x,null);const{attributes:_}=x;if(!_||Es(x))return;const B={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let Y=_.length;for(;Y--;){const de=_[Y],{name:se,namespaceURI:be,value:qe}=de,Wt=oe(se),Ts=qe;let le=se==="value"?Ts:fm(Ts);if(B.attrName=Wt,B.attrValue=le,B.keepAttr=!0,B.forceKeepAttr=void 0,He(z.uponSanitizeAttribute,x,B),le=B.attrValue,Ha&&(Wt==="id"||Wt==="name")&&(ht(se,x),le=Ru+le),Z&&ge(/((--!?|])>)|<\/(style|title|textarea)/i,le)){ht(se,x);continue}if(Wt==="attributename"&&Hs(le,"href")){ht(se,x);continue}if(B.forceKeepAttr)continue;if(!B.keepAttr){ht(se,x);continue}if(!U&&ge(/\/>/i,le)){ht(se,x);continue}W&&fi([ke,_e,Ke],or=>{le=yn(le,or," ")});const sr=oe(x.nodeName);if(!tr(sr,Wt,le)){ht(se,x);continue}if(A&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!be)switch(g.getAttributeType(sr,Wt)){case"TrustedHTML":{le=A.createHTML(le);break}case"TrustedScriptURL":{le=A.createScriptURL(le);break}}if(le!==Ts)try{be?x.setAttributeNS(be,se,le):x.setAttribute(se,le),Es(x)?Pe(x):Ur(t.removed)}catch{ht(se,x)}}He(z.afterSanitizeAttributes,x,null)},Wu=function N(x){let _=null;const B=Xa(x);for(He(z.beforeSanitizeShadowDOM,x,null);_=B.nextNode();)He(z.uponSanitizeShadowNode,_,null),er(_),ir(_),_.content instanceof o&&N(_.content);He(z.afterSanitizeShadowDOM,x,null)};return t.sanitize=function(N){let x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=null,B=null,Y=null,de=null;if(Ss=!N,Ss&&(N="<!-->"),typeof N!="string"&&!Za(N))if(typeof N.toString=="function"){if(N=N.toString(),typeof N!="string")throw vn("dirty is not a string, aborting")}else throw vn("toString is not a function");if(!t.isSupported)return N;if(fe||Cs(x),t.removed=[],typeof N=="string"&&(un=!1),un){if(N.nodeName){const qe=oe(N.nodeName);if(!te[qe]||pt[qe])throw vn("root node is forbidden and cannot be sanitized in-place")}}else if(N instanceof r)_=Ya("<!---->"),B=_.ownerDocument.importNode(N,!0),B.nodeType===wn.element&&B.nodeName==="BODY"||B.nodeName==="HTML"?_=B:_.appendChild(B);else{if(!Nt&&!W&&!J&&N.indexOf("<")===-1)return A&&ti?A.createHTML(N):N;if(_=Ya(N),!_)return Nt?null:ti?E:""}_&&nt&&Pe(_.firstChild);const se=Xa(un?N:_);for(;Y=se.nextNode();)er(Y),ir(Y),Y.content instanceof o&&Wu(Y.content);if(un)return N;if(Nt){if(ei)for(de=R.call(_.ownerDocument);_.firstChild;)de.appendChild(_.firstChild);else de=_;return(ne.shadowroot||ne.shadowrootmode)&&(de=q.call(i,de,!0)),de}let be=J?_.outerHTML:_.innerHTML;return J&&te["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&ge(kd,_.ownerDocument.doctype.name)&&(be="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
2593
+ `+be),W&&fi([ke,_e,Ke],qe=>{be=yn(be,qe," ")}),A&&ti?A.createHTML(be):be},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Cs(N),fe=!0},t.clearConfig=function(){Ut=null,fe=!1},t.isValidAttribute=function(N,x,_){Ut||Cs({});const B=oe(N),Y=oe(x);return tr(B,Y,_)},t.addHook=function(N,x){typeof x=="function"&&mn(z[N],x)},t.removeHook=function(N,x){if(x!==void 0){const _=um(z[N],x);return _===-1?void 0:pm(z[N],_,1)[0]}return Ur(z[N])},t.removeHooks=function(N){z[N]=[]},t.removeAllHooks=function(){z=jr()},t}var Io=xd();function $a(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Dt=$a();function $d(e){Dt=e}var In={exec:()=>null};function j(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(s,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(me.caret,"$1"),n=n.replace(s,a),i},getRegex:()=>new RegExp(n,t)};return i}var _m=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),me={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")},Mm=/^(?:[ \t]*(?:\n|$))+/,Pm=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Im=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Gn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Lm=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Sa=/(?:[*+-]|\d{1,9}[.)])/,Sd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ad=j(Sd).replace(/bull/g,Sa).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(),Rm=j(Sd).replace(/bull/g,Sa).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(),Aa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Dm=/^[^\n]+/,Ca=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Bm=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ca).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Nm=j(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Sa).getRegex(),us="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",Ea=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Om=j("^ {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",Ea).replace("tag",us).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Cd=j(Aa).replace("hr",Gn).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",us).getRegex(),Fm=j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Cd).getRegex(),Ta={blockquote:Fm,code:Pm,def:Bm,fences:Im,heading:Lm,hr:Gn,html:Om,lheading:Ad,list:Nm,newline:Mm,paragraph:Cd,table:In,text:Dm},Gr=j("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Gn).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",us).getRegex(),Um={...Ta,lheading:Rm,table:Gr,paragraph:j(Aa).replace("hr",Gn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Gr).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",us).getRegex()},Wm={...Ta,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ea).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:In,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(Aa).replace("hr",Gn).replace("heading",` *#{1,6} *[^
2594
+ ]`).replace("lheading",Ad).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Km=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,zm=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ed=/^( {2,}|\\)\n(?!\s*$)/,Hm=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ps=/[\p{P}\p{S}]/u,_a=/[\s\p{P}\p{S}]/u,Td=/[^\s\p{P}\p{S}]/u,qm=j(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,_a).getRegex(),_d=/(?!~)[\p{P}\p{S}]/u,jm=/(?!~)[\s\p{P}\p{S}]/u,Gm=/(?:[^\s\p{P}\p{S}]|~)/u,Vm=j(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",_m?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Md=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Qm=j(Md,"u").replace(/punct/g,ps).getRegex(),Jm=j(Md,"u").replace(/punct/g,_d).getRegex(),Pd="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Ym=j(Pd,"gu").replace(/notPunctSpace/g,Td).replace(/punctSpace/g,_a).replace(/punct/g,ps).getRegex(),Xm=j(Pd,"gu").replace(/notPunctSpace/g,Gm).replace(/punctSpace/g,jm).replace(/punct/g,_d).getRegex(),Zm=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Td).replace(/punctSpace/g,_a).replace(/punct/g,ps).getRegex(),ey=j(/\\(punct)/,"gu").replace(/punct/g,ps).getRegex(),ty=j(/^<(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(),ny=j(Ea).replace("(?:-->|$)","-->").getRegex(),iy=j("^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",ny).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,sy=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",qi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Id=j(/^!?\[(label)\]\[(ref)\]/).replace("label",qi).replace("ref",Ca).getRegex(),Ld=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ca).getRegex(),oy=j("reflink|nolink(?!\\()","g").replace("reflink",Id).replace("nolink",Ld).getRegex(),Vr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ma={_backpedal:In,anyPunctuation:ey,autolink:ty,blockSkip:Vm,br:Ed,code:zm,del:In,emStrongLDelim:Qm,emStrongRDelimAst:Ym,emStrongRDelimUnd:Zm,escape:Km,link:sy,nolink:Ld,punctuation:qm,reflink:Id,reflinkSearch:oy,tag:iy,text:Hm,url:In},ay={...Ma,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",qi).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qi).getRegex()},Lo={...Ma,emStrongRDelimAst:Xm,emStrongLDelim:Jm,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Vr).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:j(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Vr).getRegex()},ry={...Lo,br:j(Ed).replace("{2,}","*").getRegex(),text:j(Lo.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},mi={normal:Ta,gfm:Um,pedantic:Wm},kn={normal:Ma,gfm:Lo,breaks:ry,pedantic:ay},ly={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Qr=e=>ly[e];function Ve(e,t){if(t){if(me.escapeTest.test(e))return e.replace(me.escapeReplace,Qr)}else if(me.escapeTestNoEncode.test(e))return e.replace(me.escapeReplaceNoEncode,Qr);return e}function Jr(e){try{e=encodeURI(e).replace(me.percentDecode,"%")}catch{return null}return e}function Yr(e,t){var o;let n=e.replace(me.findPipe,(a,r,c)=>{let d=!1,h=r;for(;--h>=0&&c[h]==="\\";)d=!d;return d?"|":" |"}),i=n.split(me.splitPipe),s=0;if(i[0].trim()||i.shift(),i.length>0&&!((o=i.at(-1))!=null&&o.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(me.slashPipe,"|");return i}function xn(e,t,n){let i=e.length;if(i===0)return"";let s=0;for(;s<i&&e.charAt(i-s-1)===t;)s++;return e.slice(0,i-s)}function cy(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}function Xr(e,t,n,i,s){let o=t.href,a=t.title||null,r=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let c={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:r,tokens:i.inlineTokens(r)};return i.state.inLink=!1,c}function dy(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
2595
2595
  `).map(o=>{let a=o.match(n.other.beginningSpace);if(a===null)return o;let[r]=a;return r.length>=s.length?o.slice(s.length):o}).join(`
2596
- `)}var Hi=class{constructor(e){q(this,"options");q(this,"rules");q(this,"lexer");this.options=e||Dt}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:xn(n,`
2597
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=sy(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let i=xn(n,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(n=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:xn(t[0],`
2596
+ `)}var ji=class{constructor(e){H(this,"options");H(this,"rules");H(this,"lexer");this.options=e||Dt}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:xn(n,`
2597
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=dy(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let i=xn(n,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(n=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:xn(t[0],`
2598
2598
  `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=xn(t[0],`
2599
2599
  `).split(`
2600
- `),i="",s="",o=[];for(;n.length>0;){let a=!1,r=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))r.push(n[l]),a=!0;else if(!a)r.push(n[l]);else break;n=n.slice(l);let c=r.join(`
2601
- `),h=c.replace(this.rules.other.blockquoteSetextReplace,`
2600
+ `),i="",s="",o=[];for(;n.length>0;){let a=!1,r=[],c;for(c=0;c<n.length;c++)if(this.rules.other.blockquoteStart.test(n[c]))r.push(n[c]),a=!0;else if(!a)r.push(n[c]);else break;n=n.slice(c);let d=r.join(`
2601
+ `),h=d.replace(this.rules.other.blockquoteSetextReplace,`
2602
2602
  $1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
2603
- ${c}`:c,s=s?`${s}
2604
- ${h}`:h;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,o,!0),this.lexer.state.top=d,n.length===0)break;let p=o.at(-1);if((p==null?void 0:p.type)==="code")break;if((p==null?void 0:p.type)==="blockquote"){let g=p,$=g.raw+`
2603
+ ${d}`:d,s=s?`${s}
2604
+ ${h}`:h;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,o,!0),this.lexer.state.top=l,n.length===0)break;let p=o.at(-1);if((p==null?void 0:p.type)==="code")break;if((p==null?void 0:p.type)==="blockquote"){let g=p,$=g.raw+`
2605
2605
  `+n.join(`
2606
2606
  `),S=this.blockquote($);o[o.length-1]=S,i=i.substring(0,i.length-g.raw.length)+S.raw,s=s.substring(0,s.length-g.text.length)+S.text;break}else if((p==null?void 0:p.type)==="list"){let g=p,$=g.raw+`
2607
2607
  `+n.join(`
2608
2608
  `),S=this.list($);o[o.length-1]=S,i=i.substring(0,i.length-p.raw.length)+S.raw,s=s.substring(0,s.length-g.raw.length)+S.raw,n=$.substring(o.at(-1).raw.length).split(`
2609
- `);continue}}return{type:"blockquote",raw:i,tokens:o,text:s}}}list(e){var n,i;let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),o=s.length>1,a={type:"list",raw:"",ordered:o,start:o?+s.slice(0,-1):"",loose:!1,items:[]};s=o?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=o?s:"[*+-]");let r=this.rules.other.listItemRegex(s),l=!1;for(;e;){let h=!1,d="",p="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;d=t[0],e=e.substring(d.length);let g=t[2].split(`
2609
+ `);continue}}return{type:"blockquote",raw:i,tokens:o,text:s}}}list(e){var n,i;let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),o=s.length>1,a={type:"list",raw:"",ordered:o,start:o?+s.slice(0,-1):"",loose:!1,items:[]};s=o?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=o?s:"[*+-]");let r=this.rules.other.listItemRegex(s),c=!1;for(;e;){let h=!1,l="",p="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;l=t[0],e=e.substring(l.length);let g=t[2].split(`
2610
2610
  `,1)[0].replace(this.rules.other.listReplaceTabs,f=>" ".repeat(3*f.length)),$=e.split(`
2611
- `,1)[0],S=!g.trim(),T=0;if(this.options.pedantic?(T=2,p=g.trimStart()):S?T=t[1].length+1:(T=t[2].search(this.rules.other.nonSpaceChar),T=T>4?1:T,p=g.slice(T),T+=t[1].length),S&&this.rules.other.blankLine.test($)&&(d+=$+`
2611
+ `,1)[0],S=!g.trim(),T=0;if(this.options.pedantic?(T=2,p=g.trimStart()):S?T=t[1].length+1:(T=t[2].search(this.rules.other.nonSpaceChar),T=T>4?1:T,p=g.slice(T),T+=t[1].length),S&&this.rules.other.blankLine.test($)&&(l+=$+`
2612
2612
  `,e=e.substring($.length+1),h=!0),!h){let f=this.rules.other.nextBulletRegex(T),b=this.rules.other.hrRegex(T),k=this.rules.other.fencesBeginRegex(T),A=this.rules.other.headingBeginRegex(T),E=this.rules.other.htmlBeginRegex(T);for(;e;){let M=e.split(`
2613
2613
  `,1)[0],P;if($=M,this.options.pedantic?($=$.replace(this.rules.other.listReplaceNesting," "),P=$):P=$.replace(this.rules.other.tabCharGlobal," "),k.test($)||A.test($)||E.test($)||f.test($)||b.test($))break;if(P.search(this.rules.other.nonSpaceChar)>=T||!$.trim())p+=`
2614
2614
  `+P.slice(T);else{if(S||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||k.test(g)||A.test(g)||b.test(g))break;p+=`
2615
- `+$}!S&&!$.trim()&&(S=!0),d+=M+`
2616
- `,e=e.substring(M.length+1),g=P.slice(T)}}a.loose||(l?a.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(l=!0)),a.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),a.raw+=d}let c=a.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;a.raw=a.raw.trimEnd();for(let h of a.items){if(this.lexer.state.top=!1,h.tokens=this.lexer.blockTokens(h.text,[]),h.task){if(h.text=h.text.replace(this.rules.other.listReplaceTask,""),((n=h.tokens[0])==null?void 0:n.type)==="text"||((i=h.tokens[0])==null?void 0:i.type)==="paragraph"){h.tokens[0].raw=h.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),h.tokens[0].text=h.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let p=this.lexer.inlineQueue.length-1;p>=0;p--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)){this.lexer.inlineQueue[p].src=this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask,"");break}}let d=this.rules.other.listTaskCheckbox.exec(h.raw);if(d){let p={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};h.checked=p.checked,a.loose?h.tokens[0]&&["paragraph","text"].includes(h.tokens[0].type)&&"tokens"in h.tokens[0]&&h.tokens[0].tokens?(h.tokens[0].raw=p.raw+h.tokens[0].raw,h.tokens[0].text=p.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(p)):h.tokens.unshift({type:"paragraph",raw:p.raw,text:p.raw,tokens:[p]}):h.tokens.unshift(p)}}if(!a.loose){let d=h.tokens.filter(g=>g.type==="space"),p=d.length>0&&d.some(g=>this.rules.other.anyLine.test(g.raw));a.loose=p}}if(a.loose)for(let h of a.items){h.loose=!0;for(let d of h.tokens)d.type==="text"&&(d.type="paragraph")}return a}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:i,title:s}}}table(e){var a;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Vr(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(a=t[3])!=null&&a.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
2617
- `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let r of i)this.rules.other.tableAlignRight.test(r)?o.align.push("right"):this.rules.other.tableAlignCenter.test(r)?o.align.push("center"):this.rules.other.tableAlignLeft.test(r)?o.align.push("left"):o.align.push(null);for(let r=0;r<n.length;r++)o.header.push({text:n[r],tokens:this.lexer.inline(n[r]),header:!0,align:o.align[r]});for(let r of s)o.rows.push(Vr(r,o.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:o.align[c]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
2618
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=xn(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=iy(t[2],"()");if(o===-2)return;if(o>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(i);o&&(i=o[1],s=o[3])}else s=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?i=i.slice(1):i=i.slice(1,-1)),Qr(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let i=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=t[i.toLowerCase()];if(!s){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return Qr(n,s,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!n||this.rules.inline.punctuation.exec(n))){let s=[...i[0]].length-1,o,a,r=s,l=0,c=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+s);(i=c.exec(t))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(a=[...o].length,i[3]||i[4]){r+=a;continue}else if((i[5]||i[6])&&s%3&&!((s+a)%3)){l+=a;continue}if(r-=a,r>0)continue;a=Math.min(a,a+r+l);let h=[...i[0]][0].length,d=e.slice(0,s+i.index+h+a);if(Math.min(s,a)%2){let g=d.slice(1,-1);return{type:"em",raw:d,text:g,tokens:this.lexer.inlineTokens(g)}}let p=d.slice(2,-2);return{type:"strong",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return i&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,i;return t[2]==="@"?(n=t[1],i="mailto:"+n):(n=t[1],i=n),{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let i,s;if(t[2]==="@")i=t[0],s="mailto:"+i;else{let o;do o=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(o!==t[0]);i=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},Ae=class Lo{constructor(t){q(this,"tokens");q(this,"options");q(this,"state");q(this,"inlineQueue");q(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Dt,this.options.tokenizer=this.options.tokenizer||new Hi,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:me,block:mi.normal,inline:kn.normal};this.options.pedantic?(n.block=mi.pedantic,n.inline=kn.pedantic):this.options.gfm&&(n.block=mi.gfm,this.options.breaks?n.inline=kn.breaks:n.inline=kn.gfm),this.tokenizer.rules=n}static get rules(){return{block:mi,inline:kn}}static lex(t,n){return new Lo(n).lex(t)}static lexInline(t,n){return new Lo(n).inlineTokens(t)}lex(t){t=t.replace(me.carriageReturn,`
2619
- `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let i=this.inlineQueue[n];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],i=!1){var s,o,a;for(this.options.pedantic&&(t=t.replace(me.tabCharGlobal," ").replace(me.spaceLine,""));t;){let r;if((o=(s=this.options.extensions)==null?void 0:s.block)!=null&&o.some(c=>(r=c.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))continue;if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length);let c=n.at(-1);r.raw.length===1&&c!==void 0?c.raw+=`
2620
- `:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.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(`
2615
+ `+$}!S&&!$.trim()&&(S=!0),l+=M+`
2616
+ `,e=e.substring(M.length+1),g=P.slice(T)}}a.loose||(c?a.loose=!0:this.rules.other.doubleBlankLine.test(l)&&(c=!0)),a.items.push({type:"list_item",raw:l,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),a.raw+=l}let d=a.items.at(-1);if(d)d.raw=d.raw.trimEnd(),d.text=d.text.trimEnd();else return;a.raw=a.raw.trimEnd();for(let h of a.items){if(this.lexer.state.top=!1,h.tokens=this.lexer.blockTokens(h.text,[]),h.task){if(h.text=h.text.replace(this.rules.other.listReplaceTask,""),((n=h.tokens[0])==null?void 0:n.type)==="text"||((i=h.tokens[0])==null?void 0:i.type)==="paragraph"){h.tokens[0].raw=h.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),h.tokens[0].text=h.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let p=this.lexer.inlineQueue.length-1;p>=0;p--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)){this.lexer.inlineQueue[p].src=this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask,"");break}}let l=this.rules.other.listTaskCheckbox.exec(h.raw);if(l){let p={type:"checkbox",raw:l[0]+" ",checked:l[0]!=="[ ]"};h.checked=p.checked,a.loose?h.tokens[0]&&["paragraph","text"].includes(h.tokens[0].type)&&"tokens"in h.tokens[0]&&h.tokens[0].tokens?(h.tokens[0].raw=p.raw+h.tokens[0].raw,h.tokens[0].text=p.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(p)):h.tokens.unshift({type:"paragraph",raw:p.raw,text:p.raw,tokens:[p]}):h.tokens.unshift(p)}}if(!a.loose){let l=h.tokens.filter(g=>g.type==="space"),p=l.length>0&&l.some(g=>this.rules.other.anyLine.test(g.raw));a.loose=p}}if(a.loose)for(let h of a.items){h.loose=!0;for(let l of h.tokens)l.type==="text"&&(l.type="paragraph")}return a}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:i,title:s}}}table(e){var a;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Yr(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(a=t[3])!=null&&a.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
2617
+ `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let r of i)this.rules.other.tableAlignRight.test(r)?o.align.push("right"):this.rules.other.tableAlignCenter.test(r)?o.align.push("center"):this.rules.other.tableAlignLeft.test(r)?o.align.push("left"):o.align.push(null);for(let r=0;r<n.length;r++)o.header.push({text:n[r],tokens:this.lexer.inline(n[r]),header:!0,align:o.align[r]});for(let r of s)o.rows.push(Yr(r,o.header.length).map((c,d)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:o.align[d]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
2618
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=xn(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=cy(t[2],"()");if(o===-2)return;if(o>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(i);o&&(i=o[1],s=o[3])}else s=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?i=i.slice(1):i=i.slice(1,-1)),Xr(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let i=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=t[i.toLowerCase()];if(!s){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return Xr(n,s,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!n||this.rules.inline.punctuation.exec(n))){let s=[...i[0]].length-1,o,a,r=s,c=0,d=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+s);(i=d.exec(t))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(a=[...o].length,i[3]||i[4]){r+=a;continue}else if((i[5]||i[6])&&s%3&&!((s+a)%3)){c+=a;continue}if(r-=a,r>0)continue;a=Math.min(a,a+r+c);let h=[...i[0]][0].length,l=e.slice(0,s+i.index+h+a);if(Math.min(s,a)%2){let g=l.slice(1,-1);return{type:"em",raw:l,text:g,tokens:this.lexer.inlineTokens(g)}}let p=l.slice(2,-2);return{type:"strong",raw:l,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return i&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,i;return t[2]==="@"?(n=t[1],i="mailto:"+n):(n=t[1],i=n),{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let i,s;if(t[2]==="@")i=t[0],s="mailto:"+i;else{let o;do o=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(o!==t[0]);i=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},Ae=class Ro{constructor(t){H(this,"tokens");H(this,"options");H(this,"state");H(this,"inlineQueue");H(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Dt,this.options.tokenizer=this.options.tokenizer||new ji,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:me,block:mi.normal,inline:kn.normal};this.options.pedantic?(n.block=mi.pedantic,n.inline=kn.pedantic):this.options.gfm&&(n.block=mi.gfm,this.options.breaks?n.inline=kn.breaks:n.inline=kn.gfm),this.tokenizer.rules=n}static get rules(){return{block:mi,inline:kn}}static lex(t,n){return new Ro(n).lex(t)}static lexInline(t,n){return new Ro(n).inlineTokens(t)}lex(t){t=t.replace(me.carriageReturn,`
2619
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let i=this.inlineQueue[n];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],i=!1){var s,o,a;for(this.options.pedantic&&(t=t.replace(me.tabCharGlobal," ").replace(me.spaceLine,""));t;){let r;if((o=(s=this.options.extensions)==null?void 0:s.block)!=null&&o.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))continue;if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length);let d=n.at(-1);r.raw.length===1&&d!==void 0?d.raw+=`
2620
+ `:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length);let d=n.at(-1);(d==null?void 0:d.type)==="paragraph"||(d==null?void 0:d.type)==="text"?(d.raw+=(d.raw.endsWith(`
2621
2621
  `)?"":`
2622
- `)+r.raw,c.text+=`
2623
- `+r.text,this.inlineQueue.at(-1).src=c.text):n.push(r);continue}if(r=this.tokenizer.fences(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(t)){t=t.substring(r.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(`
2622
+ `)+r.raw,d.text+=`
2623
+ `+r.text,this.inlineQueue.at(-1).src=d.text):n.push(r);continue}if(r=this.tokenizer.fences(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(t)){t=t.substring(r.raw.length);let d=n.at(-1);(d==null?void 0:d.type)==="paragraph"||(d==null?void 0:d.type)==="text"?(d.raw+=(d.raw.endsWith(`
2624
2624
  `)?"":`
2625
- `)+r.raw,c.text+=`
2626
- `+r.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},n.push(r));continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}let l=t;if((a=this.options.extensions)!=null&&a.startBlock){let c=1/0,h=t.slice(1),d;this.options.extensions.startBlock.forEach(p=>{d=p.call({lexer:this},h),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(l=t.substring(0,c+1))}if(this.state.top&&(r=this.tokenizer.paragraph(l))){let c=n.at(-1);i&&(c==null?void 0:c.type)==="paragraph"?(c.raw+=(c.raw.endsWith(`
2625
+ `)+r.raw,d.text+=`
2626
+ `+r.raw,this.inlineQueue.at(-1).src=d.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},n.push(r));continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}let c=t;if((a=this.options.extensions)!=null&&a.startBlock){let d=1/0,h=t.slice(1),l;this.options.extensions.startBlock.forEach(p=>{l=p.call({lexer:this},h),typeof l=="number"&&l>=0&&(d=Math.min(d,l))}),d<1/0&&d>=0&&(c=t.substring(0,d+1))}if(this.state.top&&(r=this.tokenizer.paragraph(c))){let d=n.at(-1);i&&(d==null?void 0:d.type)==="paragraph"?(d.raw+=(d.raw.endsWith(`
2627
2627
  `)?"":`
2628
- `)+r.raw,c.text+=`
2629
- `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(r),i=l.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
2628
+ `)+r.raw,d.text+=`
2629
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=d.text):n.push(r),i=c.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length);let d=n.at(-1);(d==null?void 0:d.type)==="text"?(d.raw+=(d.raw.endsWith(`
2630
2630
  `)?"":`
2631
- `)+r.raw,c.text+=`
2632
- `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(r);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,h,d,p;let i=t,s=null;if(this.tokens.links){let g=Object.keys(this.tokens.links);if(g.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)g.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,s.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)o=s[2]?s[2].length:0,i=i.slice(0,s.index+o)+"["+"a".repeat(s[0].length-o-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=((c=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:c.call({lexer:this},i))??i;let a=!1,r="";for(;t;){a||(r=""),a=!1;let g;if((d=(h=this.options.extensions)==null?void 0:h.inline)!=null&&d.some(S=>(g=S.call({lexer:this},t,n))?(t=t.substring(g.raw.length),n.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);let S=n.at(-1);g.type==="text"&&(S==null?void 0:S.type)==="text"?(S.raw+=g.raw,S.text+=g.text):n.push(g);continue}if(g=this.tokenizer.emStrong(t,i,r)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.del(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),n.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),n.push(g);continue}let $=t;if((p=this.options.extensions)!=null&&p.startInline){let S=1/0,T=t.slice(1),f;this.options.extensions.startInline.forEach(b=>{f=b.call({lexer:this},T),typeof f=="number"&&f>=0&&(S=Math.min(S,f))}),S<1/0&&S>=0&&($=t.substring(0,S+1))}if(g=this.tokenizer.inlineText($)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(r=g.raw.slice(-1)),a=!0;let S=n.at(-1);(S==null?void 0:S.type)==="text"?(S.raw+=g.raw,S.text+=g.text):n.push(g);continue}if(t){let S="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(S);break}else throw new Error(S)}}return n}},ji=class{constructor(e){q(this,"options");q(this,"parser");this.options=e||Dt}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let i=(o=(t||"").match(me.notSpaceStart))==null?void 0:o[0],s=e.replace(me.endingNewline,"")+`
2631
+ `)+r.raw,d.text+=`
2632
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=d.text):n.push(r);continue}if(t){let d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var c,d,h,l,p;let i=t,s=null;if(this.tokens.links){let g=Object.keys(this.tokens.links);if(g.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)g.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,s.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)o=s[2]?s[2].length:0,i=i.slice(0,s.index+o)+"["+"a".repeat(s[0].length-o-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=((d=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:d.call({lexer:this},i))??i;let a=!1,r="";for(;t;){a||(r=""),a=!1;let g;if((l=(h=this.options.extensions)==null?void 0:h.inline)!=null&&l.some(S=>(g=S.call({lexer:this},t,n))?(t=t.substring(g.raw.length),n.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);let S=n.at(-1);g.type==="text"&&(S==null?void 0:S.type)==="text"?(S.raw+=g.raw,S.text+=g.text):n.push(g);continue}if(g=this.tokenizer.emStrong(t,i,r)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.del(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),n.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),n.push(g);continue}let $=t;if((p=this.options.extensions)!=null&&p.startInline){let S=1/0,T=t.slice(1),f;this.options.extensions.startInline.forEach(b=>{f=b.call({lexer:this},T),typeof f=="number"&&f>=0&&(S=Math.min(S,f))}),S<1/0&&S>=0&&($=t.substring(0,S+1))}if(g=this.tokenizer.inlineText($)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(r=g.raw.slice(-1)),a=!0;let S=n.at(-1);(S==null?void 0:S.type)==="text"?(S.raw+=g.raw,S.text+=g.text):n.push(g);continue}if(t){let S="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(S);break}else throw new Error(S)}}return n}},Gi=class{constructor(e){H(this,"options");H(this,"parser");this.options=e||Dt}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let i=(o=(t||"").match(me.notSpaceStart))==null?void 0:o[0],s=e.replace(me.endingNewline,"")+`
2633
2633
  `;return i?'<pre><code class="language-'+Ve(i)+'">'+(n?s:Ve(s,!0))+`</code></pre>
2634
2634
  `:"<pre><code>"+(n?s:Ve(s,!0))+`</code></pre>
2635
2635
  `}blockquote({tokens:e}){return`<blockquote>
@@ -2647,26 +2647,26 @@ ${this.parser.parse(e)}</blockquote>
2647
2647
  `}tablerow({text:e}){return`<tr>
2648
2648
  ${e}</tr>
2649
2649
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
2650
- `}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>${Ve(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),s=Gr(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+Ve(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=Gr(e);if(s===null)return Ve(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Ve(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ve(e.text)}},Ma=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}},Ce=class Ro{constructor(t){q(this,"options");q(this,"renderer");q(this,"textRenderer");this.options=t||Dt,this.options.renderer=this.options.renderer||new ji,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ma}static parse(t,n){return new Ro(n).parse(t)}static parseInline(t,n){return new Ro(n).parseInline(t)}parse(t){var i,s;let n="";for(let o=0;o<t.length;o++){let a=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let l=a,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 r=a;switch(r.type){case"space":{n+=this.renderer.space(r);break}case"hr":{n+=this.renderer.hr(r);break}case"heading":{n+=this.renderer.heading(r);break}case"code":{n+=this.renderer.code(r);break}case"table":{n+=this.renderer.table(r);break}case"blockquote":{n+=this.renderer.blockquote(r);break}case"list":{n+=this.renderer.list(r);break}case"checkbox":{n+=this.renderer.checkbox(r);break}case"html":{n+=this.renderer.html(r);break}case"def":{n+=this.renderer.def(r);break}case"paragraph":{n+=this.renderer.paragraph(r);break}case"text":{n+=this.renderer.text(r);break}default:{let l='Token with "'+r.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 s,o;let i="";for(let a=0;a<t.length;a++){let r=t[a];if((o=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&o[r.type]){let c=this.options.extensions.renderers[r.type].call({parser:this},r);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){i+=c||"";continue}}let l=r;switch(l.type){case"escape":{i+=n.text(l);break}case"html":{i+=n.html(l);break}case"link":{i+=n.link(l);break}case"image":{i+=n.image(l);break}case"checkbox":{i+=n.checkbox(l);break}case"strong":{i+=n.strong(l);break}case"em":{i+=n.em(l);break}case"codespan":{i+=n.codespan(l);break}case"br":{i+=n.br(l);break}case"del":{i+=n.del(l);break}case"text":{i+=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 i}},$i,An=($i=class{constructor(e){q(this,"options");q(this,"block");this.options=e||Dt}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Ae.lex:Ae.lexInline}provideParser(){return this.block?Ce.parse:Ce.parseInline}},q($i,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),q($i,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),$i),oy=class{constructor(...e){q(this,"defaults",xa());q(this,"options",this.setOptions);q(this,"parse",this.parseMarkdown(!0));q(this,"parseInline",this.parseMarkdown(!1));q(this,"Parser",Ce);q(this,"Renderer",ji);q(this,"TextRenderer",Ma);q(this,"Lexer",Ae);q(this,"Tokenizer",Hi);q(this,"Hooks",An);this.use(...e)}walkTokens(e,t){var i,s;let n=[];for(let o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{let a=o;for(let r of a.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of a.rows)for(let l of r)n=n.concat(this.walkTokens(l.tokens,t));break}case"list":{let a=o;n=n.concat(this.walkTokens(a.items,t));break}default:{let a=o;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[a.type]?this.defaults.extensions.childTokens[a.type].forEach(r=>{let l=a[r].flat(1/0);n=n.concat(this.walkTokens(l,t))}):a.tokens&&(n=n.concat(this.walkTokens(a.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let o=t.renderers[s.name];o?t.renderers[s.name]=function(...a){let r=s.renderer.apply(this,a);return r===!1&&(r=o.apply(this,a)),r}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[s.level];o?o.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),i.extensions=t),n.renderer){let s=this.defaults.renderer||new ji(this.defaults);for(let o in n.renderer){if(!(o in s))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,r=n.renderer[a],l=s[a];s[a]=(...c)=>{let h=r.apply(s,c);return h===!1&&(h=l.apply(s,c)),h||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new Hi(this.defaults);for(let o in n.tokenizer){if(!(o in s))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,r=n.tokenizer[a],l=s[a];s[a]=(...c)=>{let h=r.apply(s,c);return h===!1&&(h=l.apply(s,c)),h}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new An;for(let o in n.hooks){if(!(o in s))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,r=n.hooks[a],l=s[a];An.passThroughHooks.has(o)?s[a]=c=>{if(this.defaults.async&&An.passThroughHooksRespectAsync.has(o))return(async()=>{let d=await r.call(s,c);return l.call(s,d)})();let h=r.call(s,c);return l.call(s,h)}:s[a]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await r.apply(s,c);return d===!1&&(d=await l.apply(s,c)),d})();let h=r.apply(s,c);return h===!1&&(h=l.apply(s,c)),h}}i.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,o=n.walkTokens;i.walkTokens=function(a){let r=[];return r.push(o.call(this,a)),s&&(r=r.concat(s.call(this,a))),r}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ae.lex(e,t??this.defaults)}parser(e,t){return Ce.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let a=s.hooks?await s.hooks.preprocess(t):t,r=await(s.hooks?await s.hooks.provideLexer():e?Ae.lex:Ae.lexInline)(a,s),l=s.hooks?await s.hooks.processAllTokens(r):r;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():e?Ce.parse:Ce.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let a=(s.hooks?s.hooks.provideLexer():e?Ae.lex:Ae.lexInline)(t,s);s.hooks&&(a=s.hooks.processAllTokens(a)),s.walkTokens&&this.walkTokens(a,s.walkTokens);let r=(s.hooks?s.hooks.provideParser():e?Ce.parse:Ce.parseInline)(a,s);return s.hooks&&(r=s.hooks.postprocess(r)),r}catch(a){return o(a)}}}onError(e,t){return n=>{if(n.message+=`
2651
- Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Ve(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},Pt=new oy;function V(e,t){return Pt.parse(e,t)}V.options=V.setOptions=function(e){return Pt.setOptions(e),V.defaults=Pt.defaults,bd(V.defaults),V};V.getDefaults=xa;V.defaults=Dt;V.use=function(...e){return Pt.use(...e),V.defaults=Pt.defaults,bd(V.defaults),V};V.walkTokens=function(e,t){return Pt.walkTokens(e,t)};V.parseInline=Pt.parseInline;V.Parser=Ce;V.parser=Ce.parse;V.Renderer=ji;V.TextRenderer=Ma;V.Lexer=Ae;V.lexer=Ae.lex;V.Tokenizer=Hi;V.Hooks=An;V.parse=V;V.options;V.setOptions;V.use;V.walkTokens;V.parseInline;Ce.parse;Ae.lex;V.setOptions({gfm:!0,breaks:!0,mangle:!1});const Jr=["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"],Yr=["class","href","rel","target","title","start"];let Xr=!1;const ay=14e4,ry=4e4,ly=200,Vs=5e4,kt=new Map;function cy(e){const t=kt.get(e);return t===void 0?null:(kt.delete(e),kt.set(e,t),t)}function Zr(e,t){if(kt.set(e,t),kt.size<=ly)return;const n=kt.keys().next().value;n&&kt.delete(n)}function dy(){Xr||(Xr=!0,Po.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Gi(e){const t=e.trim();if(!t)return"";if(dy(),t.length<=Vs){const a=cy(t);if(a!==null)return a}const n=Vl(t,ay),i=n.truncated?`
2650
+ `}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>${Ve(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),s=Jr(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+Ve(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=Jr(e);if(s===null)return Ve(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Ve(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ve(e.text)}},Pa=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}},Ce=class Do{constructor(t){H(this,"options");H(this,"renderer");H(this,"textRenderer");this.options=t||Dt,this.options.renderer=this.options.renderer||new Gi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Pa}static parse(t,n){return new Do(n).parse(t)}static parseInline(t,n){return new Do(n).parseInline(t)}parse(t){var i,s;let n="";for(let o=0;o<t.length;o++){let a=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let c=a,d=this.options.extensions.renderers[c.type].call({parser:this},c);if(d!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){n+=d||"";continue}}let r=a;switch(r.type){case"space":{n+=this.renderer.space(r);break}case"hr":{n+=this.renderer.hr(r);break}case"heading":{n+=this.renderer.heading(r);break}case"code":{n+=this.renderer.code(r);break}case"table":{n+=this.renderer.table(r);break}case"blockquote":{n+=this.renderer.blockquote(r);break}case"list":{n+=this.renderer.list(r);break}case"checkbox":{n+=this.renderer.checkbox(r);break}case"html":{n+=this.renderer.html(r);break}case"def":{n+=this.renderer.def(r);break}case"paragraph":{n+=this.renderer.paragraph(r);break}case"text":{n+=this.renderer.text(r);break}default:{let c='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return n}parseInline(t,n=this.renderer){var s,o;let i="";for(let a=0;a<t.length;a++){let r=t[a];if((o=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&o[r.type]){let d=this.options.extensions.renderers[r.type].call({parser:this},r);if(d!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){i+=d||"";continue}}let c=r;switch(c.type){case"escape":{i+=n.text(c);break}case"html":{i+=n.html(c);break}case"link":{i+=n.link(c);break}case"image":{i+=n.image(c);break}case"checkbox":{i+=n.checkbox(c);break}case"strong":{i+=n.strong(c);break}case"em":{i+=n.em(c);break}case"codespan":{i+=n.codespan(c);break}case"br":{i+=n.br(c);break}case"del":{i+=n.del(c);break}case"text":{i+=n.text(c);break}default:{let d='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return i}},Si,An=(Si=class{constructor(e){H(this,"options");H(this,"block");this.options=e||Dt}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Ae.lex:Ae.lexInline}provideParser(){return this.block?Ce.parse:Ce.parseInline}},H(Si,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),H(Si,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Si),uy=class{constructor(...e){H(this,"defaults",$a());H(this,"options",this.setOptions);H(this,"parse",this.parseMarkdown(!0));H(this,"parseInline",this.parseMarkdown(!1));H(this,"Parser",Ce);H(this,"Renderer",Gi);H(this,"TextRenderer",Pa);H(this,"Lexer",Ae);H(this,"Tokenizer",ji);H(this,"Hooks",An);this.use(...e)}walkTokens(e,t){var i,s;let n=[];for(let o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{let a=o;for(let r of a.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of a.rows)for(let c of r)n=n.concat(this.walkTokens(c.tokens,t));break}case"list":{let a=o;n=n.concat(this.walkTokens(a.items,t));break}default:{let a=o;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[a.type]?this.defaults.extensions.childTokens[a.type].forEach(r=>{let c=a[r].flat(1/0);n=n.concat(this.walkTokens(c,t))}):a.tokens&&(n=n.concat(this.walkTokens(a.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let o=t.renderers[s.name];o?t.renderers[s.name]=function(...a){let r=s.renderer.apply(this,a);return r===!1&&(r=o.apply(this,a)),r}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[s.level];o?o.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),i.extensions=t),n.renderer){let s=this.defaults.renderer||new Gi(this.defaults);for(let o in n.renderer){if(!(o in s))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,r=n.renderer[a],c=s[a];s[a]=(...d)=>{let h=r.apply(s,d);return h===!1&&(h=c.apply(s,d)),h||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new ji(this.defaults);for(let o in n.tokenizer){if(!(o in s))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,r=n.tokenizer[a],c=s[a];s[a]=(...d)=>{let h=r.apply(s,d);return h===!1&&(h=c.apply(s,d)),h}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new An;for(let o in n.hooks){if(!(o in s))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,r=n.hooks[a],c=s[a];An.passThroughHooks.has(o)?s[a]=d=>{if(this.defaults.async&&An.passThroughHooksRespectAsync.has(o))return(async()=>{let l=await r.call(s,d);return c.call(s,l)})();let h=r.call(s,d);return c.call(s,h)}:s[a]=(...d)=>{if(this.defaults.async)return(async()=>{let l=await r.apply(s,d);return l===!1&&(l=await c.apply(s,d)),l})();let h=r.apply(s,d);return h===!1&&(h=c.apply(s,d)),h}}i.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,o=n.walkTokens;i.walkTokens=function(a){let r=[];return r.push(o.call(this,a)),s&&(r=r.concat(s.call(this,a))),r}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ae.lex(e,t??this.defaults)}parser(e,t){return Ce.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let a=s.hooks?await s.hooks.preprocess(t):t,r=await(s.hooks?await s.hooks.provideLexer():e?Ae.lex:Ae.lexInline)(a,s),c=s.hooks?await s.hooks.processAllTokens(r):r;s.walkTokens&&await Promise.all(this.walkTokens(c,s.walkTokens));let d=await(s.hooks?await s.hooks.provideParser():e?Ce.parse:Ce.parseInline)(c,s);return s.hooks?await s.hooks.postprocess(d):d})().catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let a=(s.hooks?s.hooks.provideLexer():e?Ae.lex:Ae.lexInline)(t,s);s.hooks&&(a=s.hooks.processAllTokens(a)),s.walkTokens&&this.walkTokens(a,s.walkTokens);let r=(s.hooks?s.hooks.provideParser():e?Ce.parse:Ce.parseInline)(a,s);return s.hooks&&(r=s.hooks.postprocess(r)),r}catch(a){return o(a)}}}onError(e,t){return n=>{if(n.message+=`
2651
+ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Ve(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},Pt=new uy;function V(e,t){return Pt.parse(e,t)}V.options=V.setOptions=function(e){return Pt.setOptions(e),V.defaults=Pt.defaults,$d(V.defaults),V};V.getDefaults=$a;V.defaults=Dt;V.use=function(...e){return Pt.use(...e),V.defaults=Pt.defaults,$d(V.defaults),V};V.walkTokens=function(e,t){return Pt.walkTokens(e,t)};V.parseInline=Pt.parseInline;V.Parser=Ce;V.parser=Ce.parse;V.Renderer=Gi;V.TextRenderer=Pa;V.Lexer=Ae;V.lexer=Ae.lex;V.Tokenizer=ji;V.Hooks=An;V.parse=V;V.options;V.setOptions;V.use;V.walkTokens;V.parseInline;Ce.parse;Ae.lex;V.setOptions({gfm:!0,breaks:!0,mangle:!1});const Zr=["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"],el=["class","href","rel","target","title","start"];let tl=!1;const py=14e4,hy=4e4,fy=200,Qs=5e4,kt=new Map;function gy(e){const t=kt.get(e);return t===void 0?null:(kt.delete(e),kt.set(e,t),t)}function nl(e,t){if(kt.set(e,t),kt.size<=fy)return;const n=kt.keys().next().value;n&&kt.delete(n)}function my(){tl||(tl=!0,Io.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Vi(e){const t=e.trim();if(!t)return"";if(my(),t.length<=Qs){const a=gy(t);if(a!==null)return a}const n=Xl(t,py),i=n.truncated?`
2652
2652
 
2653
- … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>ry){const r=`<pre class="code-block">${uy(`${n.text}${i}`)}</pre>`,l=Po.sanitize(r,{ALLOWED_TAGS:Jr,ALLOWED_ATTR:Yr});return t.length<=Vs&&Zr(t,l),l}const s=V.parse(`${n.text}${i}`),o=Po.sanitize(s,{ALLOWED_TAGS:Jr,ALLOWED_ATTR:Yr});return t.length<=Vs&&Zr(t,o),o}function uy(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const py=1500,hy=2e3,Md="Copy as markdown",fy="Copied",gy="Copy failed";async function my(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 yi(e,t){e.title=t,e.setAttribute("aria-label",t)}function yy(e){const t=e.label??Md;return u`
2653
+ … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>hy){const r=`<pre class="code-block">${yy(`${n.text}${i}`)}</pre>`,c=Io.sanitize(r,{ALLOWED_TAGS:Zr,ALLOWED_ATTR:el});return t.length<=Qs&&nl(t,c),c}const s=V.parse(`${n.text}${i}`),o=Io.sanitize(s,{ALLOWED_TAGS:Zr,ALLOWED_ATTR:el});return t.length<=Qs&&nl(t,o),o}function yy(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const vy=1500,by=2e3,Rd="Copy as markdown",wy="Copied",ky="Copy failed";async function xy(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 yi(e,t){e.title=t,e.setAttribute("aria-label",t)}function $y(e){const t=e.label??Rd;return u`
2654
2654
  <button
2655
2655
  class="chat-copy-btn"
2656
2656
  type="button"
2657
2657
  title=${t}
2658
2658
  aria-label=${t}
2659
- @click=${async n=>{const i=n.currentTarget;if(i==null||i.querySelector(".chat-copy-btn__icon"),!i||i.dataset.copying==="1")return;i.dataset.copying="1",i.setAttribute("aria-busy","true"),i.disabled=!0;const s=await my(e.text());if(i.isConnected){if(delete i.dataset.copying,i.removeAttribute("aria-busy"),i.disabled=!1,!s){i.dataset.error="1",yi(i,gy),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.error,yi(i,t))},hy);return}i.dataset.copied="1",yi(i,fy),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,yi(i,t))},py)}}}
2659
+ @click=${async n=>{const i=n.currentTarget;if(i==null||i.querySelector(".chat-copy-btn__icon"),!i||i.dataset.copying==="1")return;i.dataset.copying="1",i.setAttribute("aria-busy","true"),i.disabled=!0;const s=await xy(e.text());if(i.isConnected){if(delete i.dataset.copying,i.removeAttribute("aria-busy"),i.disabled=!1,!s){i.dataset.error="1",yi(i,ky),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.error,yi(i,t))},by);return}i.dataset.copied="1",yi(i,wy),window.setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,yi(i,t))},vy)}}}
2660
2660
  >
2661
2661
  <span class="chat-copy-btn__icon" aria-hidden="true">
2662
2662
  <span class="chat-copy-btn__icon-copy">${L.copy}</span>
2663
2663
  <span class="chat-copy-btn__icon-check">${L.check}</span>
2664
2664
  </span>
2665
2665
  </button>
2666
- `}function vy(e){return yy({text:()=>e,label:Md})}function by(e){const t=e,n=wy(t.content),i=[];for(const s of n){const o=String(s.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(o)||typeof s.name=="string"&&s.arguments!=null)&&i.push({kind:"call",name:s.name??"tool",args:ky(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const a=xy(s),r=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:r,text:a})}if(Zl(e)&&!i.some(s=>s.kind==="result")){const s=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",o=Ql(e)??void 0;i.push({kind:"result",name:s,text:o})}return i}function wy(e){return Array.isArray(e)?e.filter(Boolean):[]}function ky(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 xy(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}const Qs=40,Js=new Map;async function $y(e){const t=Js.get(e);if(t)return t;try{const n=new(window.AudioContext||window.webkitAudioContext),s=await(await fetch(e)).arrayBuffer(),a=(await n.decodeAudioData(s)).getChannelData(0),r=Math.floor(a.length/Qs),l=[];for(let d=0;d<Qs;d++){let p=0;const g=d*r,$=Math.min(g+r,a.length);for(let S=g;S<$;S++){const T=Math.abs(a[S]);T>p&&(p=T)}l.push(p)}const c=Math.max(...l,.01),h=l.map(d=>Math.max(d/c,.08));return Js.set(e,h),n.close(),h}catch{const n=Array.from(e).reduce((s,o)=>(s<<5)-s+o.charCodeAt(0)|0,0),i=[];for(let s=0;s<Qs;s++){const o=Math.abs((n*(s+1)*9301+49297)%233280/233280);i.push(.15+o*.85)}return Js.set(e,i),i}}const Ys=[1,1.5,2],Vi=new Map;function Sy(e){let t=Vi.get(e);if(t)return t;const n=new Audio;return n.preload="metadata",n.src=e,t={audio:n,playing:!1,currentTime:0,duration:0,speed:1,waveform:[]},Vi.set(e,t),$y(e).then(i=>{t.waveform=i,Pd(e)}),t}const Ln="http://www.w3.org/2000/svg";function Ay(){const e=document.createElementNS(Ln,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Ln,"polygon");return t.setAttribute("points","6,3 20,12 6,21"),e.appendChild(t),e}function Cy(){const e=document.createElementNS(Ln,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Ln,"rect");t.setAttribute("x","5"),t.setAttribute("y","3"),t.setAttribute("width","4"),t.setAttribute("height","18"),t.setAttribute("rx","1");const n=document.createElementNS(Ln,"rect");return n.setAttribute("x","15"),n.setAttribute("y","3"),n.setAttribute("width","4"),n.setAttribute("height","18"),n.setAttribute("rx","1"),e.append(t,n),e}function Ht(e){return document.querySelector(`.vnp[data-url="${CSS.escape(e)}"]`)}function Pd(e){const t=Ht(e);if(!t)return;const n=Vi.get(e);if(!n||n.waveform.length===0)return;const i=t.querySelector(".vnp__waveform");if(i){if(i.children.length===0){const s=document.createDocumentFragment();for(const o of n.waveform){const a=document.createElement("span");a.className="vnp__bar",a.style.height=`${Math.round(o*100)}%`,s.appendChild(a)}i.appendChild(s)}Rn(t,n)}}function Rn(e,t){const n=t.duration>0?t.currentTime/t.duration:0,i=e.querySelectorAll(".vnp__bar"),s=i.length;i.forEach((a,r)=>{a.classList.toggle("vnp__bar--active",r/s<n)});const o=e.querySelector(".vnp__time");o&&(o.textContent=t.playing||t.currentTime>0?Qi(t.currentTime):Qi(t.duration))}function Xs(e,t){const n=e.querySelector(".vnp__play");if(!n)return;const i=n.querySelector("svg"),s=t?Cy():Ay();i?n.replaceChild(s,i):n.appendChild(s)}function Qi(e){if(!isFinite(e)||e<0)return"0:00";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${n.toString().padStart(2,"0")}`}const el=new Set;function Ey(e){if(el.has(e))return;el.add(e);const t=Vi.get(e);if(!t)return;const{audio:n}=t;n.addEventListener("loadedmetadata",()=>{t.duration=n.duration;const i=Ht(e);i&&Rn(i,t)}),n.addEventListener("timeupdate",()=>{t.currentTime=n.currentTime;const i=Ht(e);i&&Rn(i,t)}),n.addEventListener("ended",()=>{t.playing=!1,n.currentTime=0,t.currentTime=0;const i=Ht(e);i&&(Rn(i,t),Xs(i,!1))}),n.addEventListener("pause",()=>{t.playing=!1;const i=Ht(e);i&&Xs(i,!1)}),n.addEventListener("play",()=>{t.playing=!0;const i=Ht(e);i&&Xs(i,!0)})}function Ty(e,t){const n=Sy(e);Ey(e);const i=r=>{r.stopPropagation(),n.playing?n.audio.pause():n.audio.play()},s=r=>{r.stopPropagation();const l=Ys.indexOf(n.speed),c=Ys[(l+1)%Ys.length];n.speed=c,n.audio.playbackRate=c;const h=r.target.closest(".vnp__speed");h&&(h.textContent=`${c}×`)},o=r=>{r.stopPropagation();const l=r.target.closest(".vnp__waveform");if(!l)return;const c=l.getBoundingClientRect(),h=Math.max(0,Math.min(1,(r.clientX-c.left)/c.width));if(n.duration>0){n.audio.currentTime=h*n.duration,n.currentTime=n.audio.currentTime;const d=l.closest(".vnp");d&&Rn(d,n)}},a=n.playing||n.currentTime>0?Qi(n.currentTime):Qi(n.duration);return queueMicrotask(()=>Pd(e)),u`
2666
+ `}function Sy(e){return $y({text:()=>e,label:Rd})}function Ay(e){const t=e,n=Cy(t.content),i=[];for(const s of n){const o=String(s.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(o)||typeof s.name=="string"&&s.arguments!=null)&&i.push({kind:"call",name:s.name??"tool",args:Ey(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const a=Ty(s),r=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:r,text:a})}if(ic(e)&&!i.some(s=>s.kind==="result")){const s=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",o=Zl(e)??void 0;i.push({kind:"result",name:s,text:o})}return i}function Cy(e){return Array.isArray(e)?e.filter(Boolean):[]}function Ey(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 Ty(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}const Js=40,Ys=new Map;async function _y(e){const t=Ys.get(e);if(t)return t;try{const n=new(window.AudioContext||window.webkitAudioContext),s=await(await fetch(e)).arrayBuffer(),a=(await n.decodeAudioData(s)).getChannelData(0),r=Math.floor(a.length/Js),c=[];for(let l=0;l<Js;l++){let p=0;const g=l*r,$=Math.min(g+r,a.length);for(let S=g;S<$;S++){const T=Math.abs(a[S]);T>p&&(p=T)}c.push(p)}const d=Math.max(...c,.01),h=c.map(l=>Math.max(l/d,.08));return Ys.set(e,h),n.close(),h}catch{const n=Array.from(e).reduce((s,o)=>(s<<5)-s+o.charCodeAt(0)|0,0),i=[];for(let s=0;s<Js;s++){const o=Math.abs((n*(s+1)*9301+49297)%233280/233280);i.push(.15+o*.85)}return Ys.set(e,i),i}}const Xs=[1,1.5,2],Qi=new Map;function My(e){let t=Qi.get(e);if(t)return t;const n=new Audio;return n.preload="metadata",n.src=e,t={audio:n,playing:!1,currentTime:0,duration:0,speed:1,waveform:[]},Qi.set(e,t),_y(e).then(i=>{t.waveform=i,Dd(e)}),t}const Ln="http://www.w3.org/2000/svg";function Py(){const e=document.createElementNS(Ln,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Ln,"polygon");return t.setAttribute("points","6,3 20,12 6,21"),e.appendChild(t),e}function Iy(){const e=document.createElementNS(Ln,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Ln,"rect");t.setAttribute("x","5"),t.setAttribute("y","3"),t.setAttribute("width","4"),t.setAttribute("height","18"),t.setAttribute("rx","1");const n=document.createElementNS(Ln,"rect");return n.setAttribute("x","15"),n.setAttribute("y","3"),n.setAttribute("width","4"),n.setAttribute("height","18"),n.setAttribute("rx","1"),e.append(t,n),e}function qt(e){return document.querySelector(`.vnp[data-url="${CSS.escape(e)}"]`)}function Dd(e){const t=qt(e);if(!t)return;const n=Qi.get(e);if(!n||n.waveform.length===0)return;const i=t.querySelector(".vnp__waveform");if(i){if(i.children.length===0){const s=document.createDocumentFragment();for(const o of n.waveform){const a=document.createElement("span");a.className="vnp__bar",a.style.height=`${Math.round(o*100)}%`,s.appendChild(a)}i.appendChild(s)}Rn(t,n)}}function Rn(e,t){const n=t.duration>0?t.currentTime/t.duration:0,i=e.querySelectorAll(".vnp__bar"),s=i.length;i.forEach((a,r)=>{a.classList.toggle("vnp__bar--active",r/s<n)});const o=e.querySelector(".vnp__time");o&&(o.textContent=t.playing||t.currentTime>0?Ji(t.currentTime):Ji(t.duration))}function Zs(e,t){const n=e.querySelector(".vnp__play");if(!n)return;const i=n.querySelector("svg"),s=t?Iy():Py();i?n.replaceChild(s,i):n.appendChild(s)}function Ji(e){if(!isFinite(e)||e<0)return"0:00";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${n.toString().padStart(2,"0")}`}const il=new Set;function Ly(e){if(il.has(e))return;il.add(e);const t=Qi.get(e);if(!t)return;const{audio:n}=t;n.addEventListener("loadedmetadata",()=>{t.duration=n.duration;const i=qt(e);i&&Rn(i,t)}),n.addEventListener("timeupdate",()=>{t.currentTime=n.currentTime;const i=qt(e);i&&Rn(i,t)}),n.addEventListener("ended",()=>{t.playing=!1,n.currentTime=0,t.currentTime=0;const i=qt(e);i&&(Rn(i,t),Zs(i,!1))}),n.addEventListener("pause",()=>{t.playing=!1;const i=qt(e);i&&Zs(i,!1)}),n.addEventListener("play",()=>{t.playing=!0;const i=qt(e);i&&Zs(i,!0)})}function Ry(e,t){const n=My(e);Ly(e);const i=r=>{r.stopPropagation(),n.playing?n.audio.pause():n.audio.play()},s=r=>{r.stopPropagation();const c=Xs.indexOf(n.speed),d=Xs[(c+1)%Xs.length];n.speed=d,n.audio.playbackRate=d;const h=r.target.closest(".vnp__speed");h&&(h.textContent=`${d}×`)},o=r=>{r.stopPropagation();const c=r.target.closest(".vnp__waveform");if(!c)return;const d=c.getBoundingClientRect(),h=Math.max(0,Math.min(1,(r.clientX-d.left)/d.width));if(n.duration>0){n.audio.currentTime=h*n.duration,n.currentTime=n.audio.currentTime;const l=c.closest(".vnp");l&&Rn(l,n)}},a=n.playing||n.currentTime>0?Ji(n.currentTime):Ji(n.duration);return queueMicrotask(()=>Dd(e)),u`
2667
2667
  <div class="vnp" data-url=${e} @click=${r=>r.stopPropagation()}>
2668
2668
  <button class="vnp__play" @click=${i} aria-label=${n.playing?"Pause":"Play"}>
2669
- ${n.playing?My():_y()}
2669
+ ${n.playing?By():Dy()}
2670
2670
  </button>
2671
2671
 
2672
2672
  <div class="vnp__body">
@@ -2679,7 +2679,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2679
2679
  </div>
2680
2680
  </div>
2681
2681
  </div>
2682
- `}function _y(){return u`<svg viewBox="0 0 24 24" fill="currentColor"><polygon points="6,3 20,12 6,21" /></svg>`}function My(){return u`<svg viewBox="0 0 24 24" fill="currentColor"><rect x="5" y="3" width="4" height="18" rx="1"/><rect x="15" y="3" width="4" height="18" rx="1"/></svg>`}function Py(e){var s;const n=e.content,i=[];if(Array.isArray(n))for(const o of n){if(typeof o!="object"||o===null)continue;const a=o;if(a.type==="image")if(((s=a.source)==null?void 0:s.type)==="base64"){const r=a.source,l=r.data,c=r.media_type||"image/png",h=l.startsWith("data:")?l:`data:${c};base64,${l}`;i.push({url:h})}else if(typeof a.data=="string"&&a.data){const r=a.data,l=a.mimeType||a.media_type||"image/png",c=r.startsWith("data:")?r:`data:${l};base64,${r}`;i.push({url:c})}else typeof a.url=="string"&&i.push({url:a.url});else if(a.type==="image_url"){const r=a.image_url;typeof(r==null?void 0:r.url)=="string"&&i.push({url:r.url})}}return i}function Iy(e){const n=e.content,i=[];if(Array.isArray(n))for(const s of n){if(typeof s!="object"||s===null)continue;const o=s;o.type==="file"&&typeof o.url=="string"&&typeof o.name=="string"&&i.push({url:o.url,name:o.name,mimeType:o.mimeType??"application/octet-stream"})}return i}function Ly(e){return e==="application/pdf"?"📄":e.startsWith("audio/")?"🎵":"📎"}function Ry(e){return u`
2682
+ `}function Dy(){return u`<svg viewBox="0 0 24 24" fill="currentColor"><polygon points="6,3 20,12 6,21" /></svg>`}function By(){return u`<svg viewBox="0 0 24 24" fill="currentColor"><rect x="5" y="3" width="4" height="18" rx="1"/><rect x="15" y="3" width="4" height="18" rx="1"/></svg>`}function Ny(e){var s;const n=e.content,i=[];if(Array.isArray(n))for(const o of n){if(typeof o!="object"||o===null)continue;const a=o;if(a.type==="image")if(((s=a.source)==null?void 0:s.type)==="base64"){const r=a.source,c=r.data,d=r.media_type||"image/png",h=c.startsWith("data:")?c:`data:${d};base64,${c}`;i.push({url:h})}else if(typeof a.data=="string"&&a.data){const r=a.data,c=a.mimeType||a.media_type||"image/png",d=r.startsWith("data:")?r:`data:${c};base64,${r}`;i.push({url:d})}else typeof a.url=="string"&&i.push({url:a.url});else if(a.type==="image_url"){const r=a.image_url;typeof(r==null?void 0:r.url)=="string"&&i.push({url:r.url})}}return i}function Oy(e){const n=e.content,i=[];if(Array.isArray(n))for(const s of n){if(typeof s!="object"||s===null)continue;const o=s;o.type==="file"&&typeof o.url=="string"&&typeof o.name=="string"&&i.push({url:o.url,name:o.name,mimeType:o.mimeType??"application/octet-stream"})}return i}function Fy(e){return e==="application/pdf"?"📄":e.startsWith("audio/")?"🎵":"📎"}function Uy(e){return u`
2683
2683
  <div class="chat-group assistant">
2684
2684
  <div class="chat-group-messages">
2685
2685
  <div class="chat-bubble chat-reading-indicator" aria-hidden="true">
@@ -2689,30 +2689,30 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2689
2689
  </div>
2690
2690
  </div>
2691
2691
  </div>
2692
- `}function Dy(e){return u`
2692
+ `}function Wy(e){return u`
2693
2693
  <div class="chat-group assistant">
2694
2694
  <div class="chat-group-messages">
2695
2695
  <div class="chat-interim fade-in">
2696
- ${zi(Gi(e))}
2696
+ ${Hi(Vi(e))}
2697
2697
  </div>
2698
2698
  </div>
2699
2699
  </div>
2700
- `}function By(e,t,n,i){return u`
2700
+ `}function Ky(e,t,n,i){return u`
2701
2701
  <div class="chat-group assistant">
2702
2702
  <div class="chat-group-messages">
2703
- ${Id({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
2703
+ ${Bd({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
2704
2704
  </div>
2705
2705
  </div>
2706
- `}function Ny(e,t){const n=Xl(e.role),i=n==="user"?"user":n==="assistant"?"assistant":"other",s=new Date(e.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"});return u`
2706
+ `}function zy(e,t){const n=nc(e.role),i=n==="user"?"user":n==="assistant"?"assistant":"other",s=new Date(e.timestamp).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"});return u`
2707
2707
  <div class="chat-group ${i}">
2708
2708
  <div class="chat-group-messages">
2709
- ${e.messages.map((o,a)=>Id(o.message,{isStreaming:e.isStreaming&&a===e.messages.length-1,showReasoning:t.showReasoning}))}
2709
+ ${e.messages.map((o,a)=>Bd(o.message,{isStreaming:e.isStreaming&&a===e.messages.length-1,showReasoning:t.showReasoning}))}
2710
2710
  <div class="chat-group-footer">
2711
2711
  <span class="chat-group-timestamp">${s}</span>
2712
2712
  </div>
2713
2713
  </div>
2714
2714
  </div>
2715
- `}function Oy(e){return e.length===0?w:u`
2715
+ `}function Hy(e){return e.length===0?w:u`
2716
2716
  <div class="chat-message-images">
2717
2717
  ${e.map(t=>u`
2718
2718
  <img
@@ -2723,12 +2723,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2723
2723
  />
2724
2724
  `)}
2725
2725
  </div>
2726
- `}function Fy(e){return e.length===0?w:u`
2726
+ `}function qy(e){return e.length===0?w:u`
2727
2727
  <div class="chat-message-files">
2728
- ${e.map(t=>t.mimeType==="application/pdf"?Wy(t):t.mimeType.startsWith("audio/")?Ty(t.url,t.name):Ky(t))}
2728
+ ${e.map(t=>t.mimeType==="application/pdf"?Gy(t):t.mimeType.startsWith("audio/")?Ry(t.url,t.name):Vy(t))}
2729
2729
  </div>
2730
- `}function Uy(e,t){const n=document.createElement("div");n.className="chat-pdf-modal-overlay";const i=document.createElement("div");i.className="chat-pdf-modal";const s=document.createElement("div");s.className="chat-pdf-modal__header";const o=document.createElement("span");o.className="chat-pdf-modal__title",o.textContent=t;const a=document.createElement("a");a.className="chat-pdf-modal__open",a.href=e,a.target="_blank",a.rel="noreferrer noopener",a.textContent="Open in new tab";const r=document.createElement("button");r.className="chat-pdf-modal__close",r.setAttribute("aria-label","Close");const l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("viewBox","0 0 24 24");const c=document.createElementNS("http://www.w3.org/2000/svg","line");c.setAttribute("x1","18"),c.setAttribute("y1","6"),c.setAttribute("x2","6"),c.setAttribute("y2","18");const h=document.createElementNS("http://www.w3.org/2000/svg","line");h.setAttribute("x1","6"),h.setAttribute("y1","6"),h.setAttribute("x2","18"),h.setAttribute("y2","18"),l.append(c,h),r.appendChild(l),s.append(o,a,r);const d=document.createElement("iframe");d.className="chat-pdf-modal__frame",d.src=e,d.title=t,i.append(s,d),n.appendChild(i),n.addEventListener("click",p=>{p.target===n&&n.remove()}),r.addEventListener("click",()=>n.remove()),document.body.appendChild(n)}function Wy(e){return u`
2731
- <div class="chat-pdf-preview" @click=${()=>Uy(e.url,e.name)}>
2730
+ `}function jy(e,t){const n=document.createElement("div");n.className="chat-pdf-modal-overlay";const i=document.createElement("div");i.className="chat-pdf-modal";const s=document.createElement("div");s.className="chat-pdf-modal__header";const o=document.createElement("span");o.className="chat-pdf-modal__title",o.textContent=t;const a=document.createElement("a");a.className="chat-pdf-modal__open",a.href=e,a.target="_blank",a.rel="noreferrer noopener",a.textContent="Open in new tab";const r=document.createElement("button");r.className="chat-pdf-modal__close",r.setAttribute("aria-label","Close");const c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttribute("viewBox","0 0 24 24");const d=document.createElementNS("http://www.w3.org/2000/svg","line");d.setAttribute("x1","18"),d.setAttribute("y1","6"),d.setAttribute("x2","6"),d.setAttribute("y2","18");const h=document.createElementNS("http://www.w3.org/2000/svg","line");h.setAttribute("x1","6"),h.setAttribute("y1","6"),h.setAttribute("x2","18"),h.setAttribute("y2","18"),c.append(d,h),r.appendChild(c),s.append(o,a,r);const l=document.createElement("iframe");l.className="chat-pdf-modal__frame",l.src=e,l.title=t,i.append(s,l),n.appendChild(i),n.addEventListener("click",p=>{p.target===n&&n.remove()}),r.addEventListener("click",()=>n.remove()),document.body.appendChild(n)}function Gy(e){return u`
2731
+ <div class="chat-pdf-preview" @click=${()=>jy(e.url,e.name)}>
2732
2732
  <iframe
2733
2733
  src=${e.url}
2734
2734
  class="chat-pdf-preview__frame"
@@ -2742,39 +2742,39 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2742
2742
  @click=${t=>t.stopPropagation()}
2743
2743
  >${e.name}</a>
2744
2744
  </div>
2745
- `}function Ky(e){return u`
2745
+ `}function Vy(e){return u`
2746
2746
  <a
2747
2747
  class="chat-file-card"
2748
2748
  href=${e.url}
2749
2749
  target="_blank"
2750
2750
  rel="noreferrer noopener"
2751
2751
  >
2752
- <span class="chat-file-card__icon">${Ly(e.mimeType)}</span>
2752
+ <span class="chat-file-card__icon">${Fy(e.mimeType)}</span>
2753
2753
  <span class="chat-file-card__name">${e.name}</span>
2754
2754
  </a>
2755
- `}function Id(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=Zl(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",r=by(e).length>0,l=Py(e),c=l.length>0,h=Iy(e),d=h.length>0,p=Ql(e),g=t.showReasoning&&s==="assistant"?Mp(e):null,$=p!=null&&p.trim()?p:null,S=g?Ip(g):null,T=$,f=(s==="assistant"||s==="user")&&!!(T!=null&&T.trim()),b=["chat-bubble",f?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!T&&(r||o)||!T&&!c&&!d?w:u`
2755
+ `}function Bd(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=ic(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",r=Ay(e).length>0,c=Ny(e),d=c.length>0,h=Oy(e),l=h.length>0,p=Zl(e),g=t.showReasoning&&s==="assistant"?Bp(e):null,$=p!=null&&p.trim()?p:null,S=g?Op(g):null,T=$,f=(s==="assistant"||s==="user")&&!!(T!=null&&T.trim()),b=["chat-bubble",f?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!T&&(r||o)||!T&&!d&&!l?w:u`
2756
2756
  <div class="${b}">
2757
- ${f?vy(T):w}
2758
- ${Oy(l)}
2759
- ${Fy(h)}
2760
- ${S?u`<div class="chat-thinking">${zi(Gi(S))}</div>`:w}
2761
- ${T?u`<div class="chat-text">${zi(Gi(T))}</div>`:w}
2757
+ ${f?Sy(T):w}
2758
+ ${Hy(c)}
2759
+ ${qy(h)}
2760
+ ${S?u`<div class="chat-thinking">${Hi(Vi(S))}</div>`:w}
2761
+ ${T?u`<div class="chat-text">${Hi(Vi(T))}</div>`:w}
2762
2762
  </div>
2763
- `}const O={active:!1,mode:"tap",startTime:0,elapsed:0,mediaRecorder:null,audioChunks:[],stream:null,timerId:null,startX:0,cancelled:!1};let G=null,St=null,At=!1;function tl(e){const t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}function vt(){if(O.timerId&&(clearInterval(O.timerId),O.timerId=null),O.stream){for(const e of O.stream.getTracks())e.stop();O.stream=null}St&&(clearTimeout(St),St=null),Ji(),O.mediaRecorder=null,O.audioChunks=[],O.active=!1,O.cancelled=!1,At=!1}async function Ld(e){var t;try{if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia))return console.warn("[voice] getUserMedia unavailable (requires secure context)"),vt(),!1;const n=await navigator.mediaDevices.getUserMedia({audio:!0});O.stream=n;const i=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",s=i?new MediaRecorder(n,{mimeType:i}):new MediaRecorder(n);return O.mediaRecorder=s,O.audioChunks=[],O.mode=e,O.startTime=Date.now(),O.elapsed=0,O.active=!0,O.cancelled=!1,s.ondataavailable=o=>{o.data.size>0&&O.audioChunks.push(o.data)},s.onstop=()=>{if(O.cancelled){vt(),G==null||G.onRequestRender();return}const o=new Blob(O.audioChunks,{type:s.mimeType});if(o.size===0){vt(),G==null||G.onRequestRender();return}const a=new FileReader;a.onload=()=>{const r=a.result,l=s.mimeType.includes("mp4")?"m4a":"webm",c={id:os(),dataUrl:r,mimeType:s.mimeType||"audio/webm",fileName:`voice-note-${Date.now()}.${l}`};vt(),G==null||G.onSend(c),G==null||G.onRequestRender()},a.onerror=()=>{vt(),G==null||G.onRequestRender()},a.readAsDataURL(o)},s.start(250),O.timerId=setInterval(()=>{O.elapsed=Math.floor((Date.now()-O.startTime)/1e3),G==null||G.onRequestRender()},1e3),G==null||G.onRequestRender(),!0}catch(n){return console.warn("[voice] startRecording failed:",n),vt(),!1}}function Rd(){!O.active||!O.mediaRecorder||(O.cancelled=!1,O.mediaRecorder.state==="recording"&&O.mediaRecorder.stop())}function Dd(){!O.active||!O.mediaRecorder||(O.cancelled=!0,O.mediaRecorder.state==="recording"?O.mediaRecorder.stop():(vt(),G==null||G.onRequestRender()))}function zy(){document.addEventListener("pointerup",Bd)}function Ji(){document.removeEventListener("pointerup",Bd)}function Bd(e){if(!At&&!O.active){Ji();return}if(At=!1,Ji(),St&&(clearTimeout(St),St=null,!O.active)){Ld("tap");return}O.active&&O.mode==="hold"&&(O.cancelled?Dd():Rd()),e.preventDefault()}function qy(e){O.active||(At=!0,O.startX=e.clientX,zy(),St=setTimeout(async()=>{if(!At)return;await Ld("hold")||(At=!1,Ji())},300))}function nl(e){if(!O.active||O.mode!=="hold"||!At)return;const t=O.startX-e.clientX;t>80?(O.cancelled=!0,G==null||G.onRequestRender()):O.cancelled&&t<=60&&(O.cancelled=!1,G==null||G.onRequestRender())}function Hy(){return O.active}function jy(e){G=e}function Gy(e){return u`
2763
+ `}const O={active:!1,mode:"tap",startTime:0,elapsed:0,mediaRecorder:null,audioChunks:[],stream:null,timerId:null,startX:0,cancelled:!1};let G=null,St=null,At=!1;function sl(e){const t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}function vt(){if(O.timerId&&(clearInterval(O.timerId),O.timerId=null),O.stream){for(const e of O.stream.getTracks())e.stop();O.stream=null}St&&(clearTimeout(St),St=null),Yi(),O.mediaRecorder=null,O.audioChunks=[],O.active=!1,O.cancelled=!1,At=!1}async function Nd(e){var t;try{if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia))return console.warn("[voice] getUserMedia unavailable (requires secure context)"),vt(),!1;const n=await navigator.mediaDevices.getUserMedia({audio:!0});O.stream=n;const i=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",s=i?new MediaRecorder(n,{mimeType:i}):new MediaRecorder(n);return O.mediaRecorder=s,O.audioChunks=[],O.mode=e,O.startTime=Date.now(),O.elapsed=0,O.active=!0,O.cancelled=!1,s.ondataavailable=o=>{o.data.size>0&&O.audioChunks.push(o.data)},s.onstop=()=>{if(O.cancelled){vt(),G==null||G.onRequestRender();return}const o=new Blob(O.audioChunks,{type:s.mimeType});if(o.size===0){vt(),G==null||G.onRequestRender();return}const a=new FileReader;a.onload=()=>{const r=a.result,c=s.mimeType.includes("mp4")?"m4a":"webm",d={id:as(),dataUrl:r,mimeType:s.mimeType||"audio/webm",fileName:`voice-note-${Date.now()}.${c}`};vt(),G==null||G.onSend(d),G==null||G.onRequestRender()},a.onerror=()=>{vt(),G==null||G.onRequestRender()},a.readAsDataURL(o)},s.start(250),O.timerId=setInterval(()=>{O.elapsed=Math.floor((Date.now()-O.startTime)/1e3),G==null||G.onRequestRender()},1e3),G==null||G.onRequestRender(),!0}catch(n){return console.warn("[voice] startRecording failed:",n),vt(),!1}}function Od(){!O.active||!O.mediaRecorder||(O.cancelled=!1,O.mediaRecorder.state==="recording"&&O.mediaRecorder.stop())}function Fd(){!O.active||!O.mediaRecorder||(O.cancelled=!0,O.mediaRecorder.state==="recording"?O.mediaRecorder.stop():(vt(),G==null||G.onRequestRender()))}function Qy(){document.addEventListener("pointerup",Ud)}function Yi(){document.removeEventListener("pointerup",Ud)}function Ud(e){if(!At&&!O.active){Yi();return}if(At=!1,Yi(),St&&(clearTimeout(St),St=null,!O.active)){Nd("tap");return}O.active&&O.mode==="hold"&&(O.cancelled?Fd():Od()),e.preventDefault()}function Jy(e){O.active||(At=!0,O.startX=e.clientX,Qy(),St=setTimeout(async()=>{if(!At)return;await Nd("hold")||(At=!1,Yi())},300))}function ol(e){if(!O.active||O.mode!=="hold"||!At)return;const t=O.startX-e.clientX;t>80?(O.cancelled=!0,G==null||G.onRequestRender()):O.cancelled&&t<=60&&(O.cancelled=!1,G==null||G.onRequestRender())}function Yy(){return O.active}function Xy(e){G=e}function Zy(e){return u`
2764
2764
  <button
2765
2765
  class="btn btn--icon chat-compose__mic"
2766
2766
  ?disabled=${!e}
2767
- @pointerdown=${qy}
2767
+ @pointerdown=${Jy}
2768
2768
  aria-label="Record voice note"
2769
2769
  title="Tap to record, hold to send on release"
2770
2770
  >
2771
2771
  ${L.mic}
2772
2772
  </button>
2773
- `}function Vy(){return O.active?O.mode==="tap"?u`
2774
- <div class="chat-voice-recording" @pointermove=${nl}>
2773
+ `}function ev(){return O.active?O.mode==="tap"?u`
2774
+ <div class="chat-voice-recording" @pointermove=${ol}>
2775
2775
  <button
2776
2776
  class="btn btn--icon chat-voice-recording__trash"
2777
- @click=${Dd}
2777
+ @click=${Fd}
2778
2778
  aria-label="Cancel recording"
2779
2779
  title="Discard"
2780
2780
  >
@@ -2782,11 +2782,11 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2782
2782
  </button>
2783
2783
  <div class="chat-voice-recording__indicator">
2784
2784
  <span class="chat-voice-recording__dot"></span>
2785
- <span class="chat-voice-recording__timer">${tl(O.elapsed)}</span>
2785
+ <span class="chat-voice-recording__timer">${sl(O.elapsed)}</span>
2786
2786
  </div>
2787
2787
  <button
2788
2788
  class="btn btn--icon chat-voice-recording__send primary"
2789
- @click=${Rd}
2789
+ @click=${Od}
2790
2790
  aria-label="Send voice note"
2791
2791
  title="Send"
2792
2792
  >
@@ -2794,16 +2794,16 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2794
2794
  </button>
2795
2795
  </div>
2796
2796
  `:u`
2797
- <div class="chat-voice-recording hold" @pointermove=${nl}>
2797
+ <div class="chat-voice-recording hold" @pointermove=${ol}>
2798
2798
  <div class="chat-voice-recording__indicator">
2799
2799
  <span class="chat-voice-recording__dot"></span>
2800
- <span class="chat-voice-recording__timer">${tl(O.elapsed)}</span>
2800
+ <span class="chat-voice-recording__timer">${sl(O.elapsed)}</span>
2801
2801
  <span class="chat-voice-recording__slide ${O.cancelled?"cancelled":""}">
2802
2802
  ${O.cancelled?"Release to cancel":"← Slide to cancel"}
2803
2803
  </span>
2804
2804
  </div>
2805
2805
  </div>
2806
- `:w}function Qy(e){return u`
2806
+ `:w}function tv(e){return u`
2807
2807
  <div class="sidebar-panel">
2808
2808
  <div class="sidebar-header">
2809
2809
  <div class="sidebar-title">Tool Output</div>
@@ -2817,10 +2817,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2817
2817
  <button @click=${e.onViewRawText} class="btn" style="margin-top: 12px;">
2818
2818
  View Raw Text
2819
2819
  </button>
2820
- `:e.content?u`<div class="sidebar-markdown">${zi(Gi(e.content))}</div>`:u`<div class="muted">No content available</div>`}
2820
+ `:e.content?u`<div class="sidebar-markdown">${Hi(Vi(e.content))}</div>`:u`<div class="muted">No content available</div>`}
2821
2821
  </div>
2822
2822
  </div>
2823
- `}var Jy=Object.defineProperty,Yy=Object.getOwnPropertyDescriptor,ps=(e,t,n,i)=>{for(var s=i>1?void 0:i?Yy(t,n):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(i?a(t,n,s):a(s))||s);return i&&s&&Jy(t,n,s),s};let Yt=class extends Gt{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,s=(e.clientX-this.startX)/n;let o=this.startRatio+s;o=Math.max(this.minRatio,Math.min(this.maxRatio,o)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:o},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return u``}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)}};Yt.styles=Wu`
2823
+ `}var nv=Object.defineProperty,iv=Object.getOwnPropertyDescriptor,hs=(e,t,n,i)=>{for(var s=i>1?void 0:i?iv(t,n):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(i?a(t,n,s):a(s))||s);return i&&s&&nv(t,n,s),s};let Yt=class extends Gt{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,s=(e.clientX-this.startX)/n;let o=this.startRatio+s;o=Math.max(this.minRatio,Math.min(this.maxRatio,o)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:o},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return u``}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)}};Yt.styles=Gu`
2824
2824
  :host {
2825
2825
  width: 4px;
2826
2826
  cursor: col-resize;
@@ -2846,21 +2846,21 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
2846
2846
  :host(.dragging) {
2847
2847
  background: var(--accent, #007bff);
2848
2848
  }
2849
- `;ps([is({type:Number})],Yt.prototype,"splitRatio",2);ps([is({type:Number})],Yt.prototype,"minRatio",2);ps([is({type:Number})],Yt.prototype,"maxRatio",2);Yt=ps([Wl("resizable-divider")],Yt);function vi(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function Zs(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const Xy=1,Zy=1,Bt="emoji",Xt="keyvalue",Pa="favorites",ev="tokens",Nd="tokens",tv="unicode",Od="count",nv="group",iv="order",Fd="group-order",Do="eTag",Yi="url",il="skinTone",ln="readonly",Ia="readwrite",Ud="skinUnicodes",sv="skinUnicodes",ov="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",av="en";function rv(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function sl(e){return rv(e,t=>t.unicode)}function lv(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[a,[r,l]]of Object.entries(s))o.createIndex(a,r,{multiEntry:l});return o}t(Xt),t(Bt,tv,{[Nd]:[ev,!0],[Fd]:[[nv,iv]],[Ud]:[sv,!0]}),t(Pa,void 0,{[Od]:[""]})}const Bo={},Ei={},Xi={};function Wd(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function cv(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,Xy);Bo[e]=s,s.onupgradeneeded=o=>{o.oldVersion<Zy&&lv(s.result)},Wd(n,i,s)});return t.onclose=()=>La(e),t}function dv(e){return Ei[e]||(Ei[e]=cv(e)),Ei[e]}function et(e,t,n,i){return new Promise((s,o)=>{const a=e.transaction(t,n,{durability:"relaxed"}),r=typeof t=="string"?a.objectStore(t):t.map(c=>a.objectStore(c));let l;i(r,a,c=>{l=c}),a.oncomplete=()=>s(l),a.onerror=()=>o(a.error)})}function La(e){const t=Bo[e],n=t&&t.result;if(n){n.close();const i=Xi[e];if(i)for(const s of i)s()}delete Bo[e],delete Ei[e],delete Xi[e]}function uv(e){return new Promise((t,n)=>{La(e);const i=indexedDB.deleteDatabase(e);Wd(t,n,i)})}function pv(e,t){let n=Xi[e];n||(n=Xi[e]=[]),n.push(t)}const hv=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 Qt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||hv.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const fv=2;function Kd(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=fv)}function gv(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:a,skins:r,tags:l,emoji:c,version:h})=>{const d=[...new Set(Kd([...(a||[]).map(Qt).flat(),...(l||[]).map(Qt).flat(),...Qt(n),i]))].sort(),p={annotation:n,group:s,order:o,tags:l,tokens:d,unicode:c,version:h};if(i&&(p.emoticon=i),a&&(p.shortcodes=a),r){p.skinTones=[],p.skinUnicodes=[],p.skinVersions=[];for(const{tone:g,emoji:$,version:S}of r)p.skinTones.push(g),p.skinUnicodes.push($),p.skinVersions.push(S)}return p})}function zd(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function It(e,t,n){zd(e,"get",t,n)}function qd(e,t,n){zd(e,"getAll",t,n)}function Ra(e){e.commit&&e.commit()}function mv(e,t){let n=e[0];for(let i=1;i<e.length;i++){const s=e[i];t(n)>t(s)&&(n=s)}return n}function Hd(e,t){const n=mv(e,s=>s.length),i=[];for(const s of n)e.some(o=>o.findIndex(a=>t(a)===t(s))===-1)||i.push(s);return i}async function yv(e){return!await Da(e,Xt,Yi)}async function vv(e,t,n){const[i,s]=await Promise.all([Do,Yi].map(o=>Da(e,Xt,o)));return i===n&&s===t}async function bv(e,t){return et(e,Bt,ln,(i,s,o)=>{let a;const r=()=>{i.getAll(a&&IDBKeyRange.lowerBound(a,!0),50).onsuccess=l=>{const c=l.target.result;for(const h of c)if(a=h.unicode,t(h))return o(h);if(c.length<50)return o();r()}};r()})}async function jd(e,t,n,i){{const s=gv(t);await et(e,[Bt,Xt],Ia,([o,a],r)=>{let l,c,h=0;function d(){++h===2&&p()}function p(){if(!(l===i&&c===n)){o.clear();for(const g of s)o.put(g);a.put(i,Do),a.put(n,Yi),Ra(r)}}It(a,Do,g=>{l=g,d()}),It(a,Yi,g=>{c=g,d()})})}}async function wv(e,t){return et(e,Bt,ln,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);qd(n.index(Fd),o,s)})}async function Gd(e,t){const n=Kd(Qt(t));return n.length?et(e,Bt,ln,(i,s,o)=>{const a=[],r=()=>{a.length===n.length&&l()},l=()=>{const c=Hd(a,h=>h.unicode);o(c.sort((h,d)=>h.order<d.order?-1:1))};for(let c=0;c<n.length;c++){const h=n[c],d=c===n.length-1?IDBKeyRange.bound(h,h+"￿",!1,!0):IDBKeyRange.only(h);qd(i.index(Nd),d,p=>{a.push(p),r()})}}):[]}async function kv(e,t){const n=await Gd(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await bv(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function xv(e,t){return et(e,Bt,ln,(n,i,s)=>It(n,t,o=>{if(o)return s(o);It(n.index(Ud),t,a=>s(a||null))}))}function Da(e,t,n){return et(e,t,ln,(i,s,o)=>It(i,n,o))}function $v(e,t,n,i){return et(e,t,Ia,(s,o)=>{s.put(i,n),Ra(o)})}function Sv(e,t){return et(e,Pa,Ia,(n,i)=>It(n,t,s=>{n.put((s||0)+1,t),Ra(i)}))}function Av(e,t,n){return n===0?[]:et(e,[Pa,Bt],ln,([i,s],o,a)=>{const r=[];i.index(Od).openCursor(void 0,"prev").onsuccess=l=>{const c=l.target.result;if(!c)return a(r);function h(g){if(r.push(g),r.length===n)return a(r);c.continue()}const d=c.primaryKey,p=t.byName(d);if(p)return h(p);It(s,d,g=>{if(g)return h(g);c.continue()})}})}const bi="";function Cv(e,t){const n=new Map;for(const s of e){const o=t(s);for(const a of o){let r=n;for(let c=0;c<a.length;c++){const h=a.charAt(c);let d=r.get(h);d||(d=new Map,r.set(h,d)),r=d}let l=r.get(bi);l||(l=[],r.set(bi,l)),l.push(s)}}return(s,o)=>{let a=n;for(let c=0;c<s.length;c++){const h=s.charAt(c),d=a.get(h);if(d)a=d;else return[]}if(o)return a.get(bi)||[];const r=[],l=[a];for(;l.length;){const h=[...l.shift().entries()].sort((d,p)=>d[0]<p[0]?-1:1);for(const[d,p]of h)d===bi?r.push(...p):l.push(p)}return r}}const Ev=["name","url"];function Tv(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||Ev.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function ol(e){Tv(e);const t=(p,g)=>p.name.toLowerCase()<g.name.toLowerCase()?-1:1,n=e.sort(t),s=Cv(e,p=>{const g=new Set;if(p.shortcodes)for(const $ of p.shortcodes)for(const S of Qt($))g.add(S);return g}),o=p=>s(p,!0),a=p=>s(p,!1),r=p=>{const g=Qt(p),$=g.map((S,T)=>(T<g.length-1?o:a)(S));return Hd($,S=>S.name).sort(t)},l=new Map,c=new Map;for(const p of e){c.set(p.name.toLowerCase(),p);for(const g of p.shortcodes||[])l.set(g.toLowerCase(),p)}return{all:n,search:r,byShortcode:p=>l.get(p.toLowerCase()),byName:p=>c.get(p.toLowerCase())}}const _v=typeof wrappedJSObject<"u";function $n(e){if(!e)return e;if(_v&&(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 Vd(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Mv=["annotation","emoji","group","order","version"];function Pv(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Mv.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function Qd(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Iv(e){const t=await fetch(e,{method:"HEAD"});Qd(t,e);const n=t.headers.get("etag");return Vd(n),n}async function No(e){const t=await fetch(e);Qd(t,e);const n=t.headers.get("etag");Vd(n);const i=await t.json();return Pv(i),[n,i]}function Lv(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Rv(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),s=-1;++s<t;)i[s]=e.charCodeAt(s);return n}async function Jd(e){const t=JSON.stringify(e);let n=Rv(t);const i=await crypto.subtle.digest("SHA-1",n),s=Lv(i);return btoa(s)}async function Dv(e,t){let n,i=await Iv(t);if(!i){const s=await No(t);i=s[0],n=s[1],i||(i=await Jd(n))}await vv(e,t,i)||(n||(n=(await No(t))[1]),await jd(e,n,t,i))}async function Bv(e,t){let[n,i]=await No(t);n||(n=await Jd(i)),await jd(e,i,t,n)}async function Nv(e,t){try{await Dv(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class Ov{constructor({dataSource:t=ov,locale:n=av,customEmoji:i=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=ol(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await dv(this._dbName);pv(this._dbName,this._clear);const n=this.dataSource;await yv(t)?await Bv(t,n):this._lazyUpdate=Nv(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 Zs(t),await this.ready(),sl(await wv(this._db,t)).map($n)}async getEmojiBySearchQuery(t){vi(t),await this.ready();const n=this._custom.search(t),i=sl(await Gd(this._db,t)).map($n);return[...n,...i]}async getEmojiByShortcode(t){vi(t),await this.ready();const n=this._custom.byShortcode(t);return n||$n(await kv(this._db,t))}async getEmojiByUnicodeOrName(t){vi(t),await this.ready();const n=this._custom.byName(t);return n||$n(await xv(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Da(this._db,Xt,il)||0}async setPreferredSkinTone(t){return Zs(t),await this.ready(),$v(this._db,Xt,il,t)}async incrementFavoriteEmojiCount(t){return vi(t),await this.ready(),Sv(this._db,t)}async getTopFavoriteEmoji(t){return Zs(t),await this.ready(),(await Av(this._db,this._custom,t)).map($n)}set customEmoji(t){this._custom=ol(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 La(this._dbName)}async delete(){await this._shutdown(),await uv(this._dbName)}}const Oo=[[-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})),eo=Oo.slice(1),Fv=2,al=6,Yd=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function rl(e){return e.unicode.includes("‍")}const Uv={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},Wv=1e3,Kv="🖐️",zv=8,qv=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],Xd='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',Hv=(e,t)=>e<t?-1:e>t?1:0,ll=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const i=n.getContext("2d",{willReadFrequently:!0});return i.textBaseline="top",i.font=`100px ${Xd}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},jv=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function Gv(e){const t=ll(e,"#000"),n=ll(e,"#fff");return t&&n&&jv(t,n)}function Vv(){const e=Object.entries(Uv);try{for(const[t,n]of e)if(Gv(t))return n}catch{}return e[0][1]}let to;const no=()=>(to||(to=new Promise(e=>Yd(()=>e(Vv())))),to),Fo=new Map,Qv="️",Jv="\uD83C",Yv="‍",Xv=127995,Zv=57339;function eb(e,t){if(t===0)return e;const n=e.indexOf(Yv);return n!==-1?e.substring(0,n)+String.fromCodePoint(Xv+t-1)+e.substring(n):(e.endsWith(Qv)&&(e=e.substring(0,e.length-1)),e+Jv+String.fromCodePoint(Zv+t-1))}function Le(e){e.preventDefault(),e.stopPropagation()}function io(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function Zd(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function tb(e,t){const n=i=>{const s={};for(const o of i)typeof o.tone=="number"&&o.version<=t&&(s[o.tone]=o.unicode);return s};return e.map(({unicode:i,skins:s,shortcodes:o,url:a,name:r,category:l,annotation:c})=>({unicode:i,name:r,shortcodes:o,url:a,category:l,annotation:c,id:i||r,skins:s&&n(s)}))}const Ti=requestAnimationFrame;let nb=typeof ResizeObserver=="function";function ib(e,t,n){let i;nb?(i=new ResizeObserver(n),i.observe(e)):Ti(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function cl(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let so;function sb(e,t,n){let i=!0,s=!1;for(const o of e){const a=n(o);if(!a)continue;const r=cl(a);r===0&&(s=!0),typeof so>"u"&&(so=cl(t));const l=r/1.8<so;Fo.set(o.unicode,l),l||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
2849
+ `;hs([ss({type:Number})],Yt.prototype,"splitRatio",2);hs([ss({type:Number})],Yt.prototype,"minRatio",2);hs([ss({type:Number})],Yt.prototype,"maxRatio",2);Yt=hs([ql("resizable-divider")],Yt);function vi(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function eo(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const sv=1,ov=1,Bt="emoji",Xt="keyvalue",Ia="favorites",av="tokens",Wd="tokens",rv="unicode",Kd="count",lv="group",cv="order",zd="group-order",Bo="eTag",Xi="url",al="skinTone",ln="readonly",La="readwrite",Hd="skinUnicodes",dv="skinUnicodes",uv="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",pv="en";function hv(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function rl(e){return hv(e,t=>t.unicode)}function fv(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[a,[r,c]]of Object.entries(s))o.createIndex(a,r,{multiEntry:c});return o}t(Xt),t(Bt,rv,{[Wd]:[av,!0],[zd]:[[lv,cv]],[Hd]:[dv,!0]}),t(Ia,void 0,{[Kd]:[""]})}const No={},Ti={},Zi={};function qd(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function gv(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,sv);No[e]=s,s.onupgradeneeded=o=>{o.oldVersion<ov&&fv(s.result)},qd(n,i,s)});return t.onclose=()=>Ra(e),t}function mv(e){return Ti[e]||(Ti[e]=gv(e)),Ti[e]}function et(e,t,n,i){return new Promise((s,o)=>{const a=e.transaction(t,n,{durability:"relaxed"}),r=typeof t=="string"?a.objectStore(t):t.map(d=>a.objectStore(d));let c;i(r,a,d=>{c=d}),a.oncomplete=()=>s(c),a.onerror=()=>o(a.error)})}function Ra(e){const t=No[e],n=t&&t.result;if(n){n.close();const i=Zi[e];if(i)for(const s of i)s()}delete No[e],delete Ti[e],delete Zi[e]}function yv(e){return new Promise((t,n)=>{Ra(e);const i=indexedDB.deleteDatabase(e);qd(t,n,i)})}function vv(e,t){let n=Zi[e];n||(n=Zi[e]=[]),n.push(t)}const bv=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 Qt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||bv.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const wv=2;function jd(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=wv)}function kv(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:a,skins:r,tags:c,emoji:d,version:h})=>{const l=[...new Set(jd([...(a||[]).map(Qt).flat(),...(c||[]).map(Qt).flat(),...Qt(n),i]))].sort(),p={annotation:n,group:s,order:o,tags:c,tokens:l,unicode:d,version:h};if(i&&(p.emoticon=i),a&&(p.shortcodes=a),r){p.skinTones=[],p.skinUnicodes=[],p.skinVersions=[];for(const{tone:g,emoji:$,version:S}of r)p.skinTones.push(g),p.skinUnicodes.push($),p.skinVersions.push(S)}return p})}function Gd(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function It(e,t,n){Gd(e,"get",t,n)}function Vd(e,t,n){Gd(e,"getAll",t,n)}function Da(e){e.commit&&e.commit()}function xv(e,t){let n=e[0];for(let i=1;i<e.length;i++){const s=e[i];t(n)>t(s)&&(n=s)}return n}function Qd(e,t){const n=xv(e,s=>s.length),i=[];for(const s of n)e.some(o=>o.findIndex(a=>t(a)===t(s))===-1)||i.push(s);return i}async function $v(e){return!await Ba(e,Xt,Xi)}async function Sv(e,t,n){const[i,s]=await Promise.all([Bo,Xi].map(o=>Ba(e,Xt,o)));return i===n&&s===t}async function Av(e,t){return et(e,Bt,ln,(i,s,o)=>{let a;const r=()=>{i.getAll(a&&IDBKeyRange.lowerBound(a,!0),50).onsuccess=c=>{const d=c.target.result;for(const h of d)if(a=h.unicode,t(h))return o(h);if(d.length<50)return o();r()}};r()})}async function Jd(e,t,n,i){{const s=kv(t);await et(e,[Bt,Xt],La,([o,a],r)=>{let c,d,h=0;function l(){++h===2&&p()}function p(){if(!(c===i&&d===n)){o.clear();for(const g of s)o.put(g);a.put(i,Bo),a.put(n,Xi),Da(r)}}It(a,Bo,g=>{c=g,l()}),It(a,Xi,g=>{d=g,l()})})}}async function Cv(e,t){return et(e,Bt,ln,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);Vd(n.index(zd),o,s)})}async function Yd(e,t){const n=jd(Qt(t));return n.length?et(e,Bt,ln,(i,s,o)=>{const a=[],r=()=>{a.length===n.length&&c()},c=()=>{const d=Qd(a,h=>h.unicode);o(d.sort((h,l)=>h.order<l.order?-1:1))};for(let d=0;d<n.length;d++){const h=n[d],l=d===n.length-1?IDBKeyRange.bound(h,h+"￿",!1,!0):IDBKeyRange.only(h);Vd(i.index(Wd),l,p=>{a.push(p),r()})}}):[]}async function Ev(e,t){const n=await Yd(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await Av(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function Tv(e,t){return et(e,Bt,ln,(n,i,s)=>It(n,t,o=>{if(o)return s(o);It(n.index(Hd),t,a=>s(a||null))}))}function Ba(e,t,n){return et(e,t,ln,(i,s,o)=>It(i,n,o))}function _v(e,t,n,i){return et(e,t,La,(s,o)=>{s.put(i,n),Da(o)})}function Mv(e,t){return et(e,Ia,La,(n,i)=>It(n,t,s=>{n.put((s||0)+1,t),Da(i)}))}function Pv(e,t,n){return n===0?[]:et(e,[Ia,Bt],ln,([i,s],o,a)=>{const r=[];i.index(Kd).openCursor(void 0,"prev").onsuccess=c=>{const d=c.target.result;if(!d)return a(r);function h(g){if(r.push(g),r.length===n)return a(r);d.continue()}const l=d.primaryKey,p=t.byName(l);if(p)return h(p);It(s,l,g=>{if(g)return h(g);d.continue()})}})}const bi="";function Iv(e,t){const n=new Map;for(const s of e){const o=t(s);for(const a of o){let r=n;for(let d=0;d<a.length;d++){const h=a.charAt(d);let l=r.get(h);l||(l=new Map,r.set(h,l)),r=l}let c=r.get(bi);c||(c=[],r.set(bi,c)),c.push(s)}}return(s,o)=>{let a=n;for(let d=0;d<s.length;d++){const h=s.charAt(d),l=a.get(h);if(l)a=l;else return[]}if(o)return a.get(bi)||[];const r=[],c=[a];for(;c.length;){const h=[...c.shift().entries()].sort((l,p)=>l[0]<p[0]?-1:1);for(const[l,p]of h)l===bi?r.push(...p):c.push(p)}return r}}const Lv=["name","url"];function Rv(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||Lv.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function ll(e){Rv(e);const t=(p,g)=>p.name.toLowerCase()<g.name.toLowerCase()?-1:1,n=e.sort(t),s=Iv(e,p=>{const g=new Set;if(p.shortcodes)for(const $ of p.shortcodes)for(const S of Qt($))g.add(S);return g}),o=p=>s(p,!0),a=p=>s(p,!1),r=p=>{const g=Qt(p),$=g.map((S,T)=>(T<g.length-1?o:a)(S));return Qd($,S=>S.name).sort(t)},c=new Map,d=new Map;for(const p of e){d.set(p.name.toLowerCase(),p);for(const g of p.shortcodes||[])c.set(g.toLowerCase(),p)}return{all:n,search:r,byShortcode:p=>c.get(p.toLowerCase()),byName:p=>d.get(p.toLowerCase())}}const Dv=typeof wrappedJSObject<"u";function $n(e){if(!e)return e;if(Dv&&(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 Xd(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Bv=["annotation","emoji","group","order","version"];function Nv(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Bv.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function Zd(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Ov(e){const t=await fetch(e,{method:"HEAD"});Zd(t,e);const n=t.headers.get("etag");return Xd(n),n}async function Oo(e){const t=await fetch(e);Zd(t,e);const n=t.headers.get("etag");Xd(n);const i=await t.json();return Nv(i),[n,i]}function Fv(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Uv(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),s=-1;++s<t;)i[s]=e.charCodeAt(s);return n}async function eu(e){const t=JSON.stringify(e);let n=Uv(t);const i=await crypto.subtle.digest("SHA-1",n),s=Fv(i);return btoa(s)}async function Wv(e,t){let n,i=await Ov(t);if(!i){const s=await Oo(t);i=s[0],n=s[1],i||(i=await eu(n))}await Sv(e,t,i)||(n||(n=(await Oo(t))[1]),await Jd(e,n,t,i))}async function Kv(e,t){let[n,i]=await Oo(t);n||(n=await eu(i)),await Jd(e,i,t,n)}async function zv(e,t){try{await Wv(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class Hv{constructor({dataSource:t=uv,locale:n=pv,customEmoji:i=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=ll(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await mv(this._dbName);vv(this._dbName,this._clear);const n=this.dataSource;await $v(t)?await Kv(t,n):this._lazyUpdate=zv(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 eo(t),await this.ready(),rl(await Cv(this._db,t)).map($n)}async getEmojiBySearchQuery(t){vi(t),await this.ready();const n=this._custom.search(t),i=rl(await Yd(this._db,t)).map($n);return[...n,...i]}async getEmojiByShortcode(t){vi(t),await this.ready();const n=this._custom.byShortcode(t);return n||$n(await Ev(this._db,t))}async getEmojiByUnicodeOrName(t){vi(t),await this.ready();const n=this._custom.byName(t);return n||$n(await Tv(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Ba(this._db,Xt,al)||0}async setPreferredSkinTone(t){return eo(t),await this.ready(),_v(this._db,Xt,al,t)}async incrementFavoriteEmojiCount(t){return vi(t),await this.ready(),Mv(this._db,t)}async getTopFavoriteEmoji(t){return eo(t),await this.ready(),(await Pv(this._db,this._custom,t)).map($n)}set customEmoji(t){this._custom=ll(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 Ra(this._dbName)}async delete(){await this._shutdown(),await yv(this._dbName)}}const Fo=[[-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})),to=Fo.slice(1),qv=2,cl=6,tu=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function dl(e){return e.unicode.includes("‍")}const jv={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},Gv=1e3,Vv="🖐️",Qv=8,Jv=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],nu='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',Yv=(e,t)=>e<t?-1:e>t?1:0,ul=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const i=n.getContext("2d",{willReadFrequently:!0});return i.textBaseline="top",i.font=`100px ${nu}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},Xv=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function Zv(e){const t=ul(e,"#000"),n=ul(e,"#fff");return t&&n&&Xv(t,n)}function eb(){const e=Object.entries(jv);try{for(const[t,n]of e)if(Zv(t))return n}catch{}return e[0][1]}let no;const io=()=>(no||(no=new Promise(e=>tu(()=>e(eb())))),no),Uo=new Map,tb="️",nb="\uD83C",ib="‍",sb=127995,ob=57339;function ab(e,t){if(t===0)return e;const n=e.indexOf(ib);return n!==-1?e.substring(0,n)+String.fromCodePoint(sb+t-1)+e.substring(n):(e.endsWith(tb)&&(e=e.substring(0,e.length-1)),e+nb+String.fromCodePoint(ob+t-1))}function Le(e){e.preventDefault(),e.stopPropagation()}function so(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function iu(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function rb(e,t){const n=i=>{const s={};for(const o of i)typeof o.tone=="number"&&o.version<=t&&(s[o.tone]=o.unicode);return s};return e.map(({unicode:i,skins:s,shortcodes:o,url:a,name:r,category:c,annotation:d})=>({unicode:i,name:r,shortcodes:o,url:a,category:c,annotation:d,id:i||r,skins:s&&n(s)}))}const _i=requestAnimationFrame;let lb=typeof ResizeObserver=="function";function cb(e,t,n){let i;lb?(i=new ResizeObserver(n),i.observe(e)):_i(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function pl(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let oo;function db(e,t,n){let i=!0,s=!1;for(const o of e){const a=n(o);if(!a)continue;const r=pl(a);r===0&&(s=!0),typeof oo>"u"&&(oo=pl(t));const c=r/1.8<oo;Uo.set(o.unicode,c),c||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
2850
2850
  This is likely due to using \`display:none\` which is unsupported.
2851
2851
  If this is a Jest/Vitest environment, you can ignore this warning.
2852
- For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function ob(e){return Zd(e,t=>t)}function ab(e){e&&(e.scrollTop=0)}function Dn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function dl(e){return""+e}function rb(e){const t=document.createElement("template");return t.innerHTML=e,t}const lb=new WeakMap,cb=new WeakMap,db=Symbol("un-keyed"),ub="replaceChildren"in Element.prototype;function pb(e,t){ub?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function hb(e,t){let n=e.firstChild,i=0;for(;n;){if(t[i]!==n)return!0;n=n.nextSibling,i++}return i!==t.length}function fb(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=hb(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&pb(i,e)}function gb(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:a,attributeValuePre:r,attributeValuePost:l}}=n,c=e[o];if(s!==c)if(n.currentExpression=c,a)if(c===null)i.removeAttribute(a);else{const h=r+dl(c)+l;i.setAttribute(a,h)}else{let h;Array.isArray(c)?fb(c,n):c instanceof Element?(h=c,i.replaceWith(h)):i.nodeValue=dl(c),h&&(n.targetNode=h)}}}function mb(e){let t="",n=!1,i=!1,s=-1;const o=new Map,a=[];let r=0;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(t+=d.slice(r),c===h-1)break;for(let b=0;b<d.length;b++)switch(d.charAt(b)){case"<":{d.charAt(b+1)==="/"?a.pop():(n=!0,a.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const p=a[a.length-1],g=Dn(o,p,()=>[]);let $,S,T;if(i){const b=/(\S+)="?([^"=]*)$/.exec(d);$=b[1],S=b[2];const k=/^([^">]*)("?)/.exec(e[c+1]);T=k[1],t=t.slice(0,-1*b[0].length),r=k[0].length}else r=0;const f={attributeName:$,attributeValuePre:S,attributeValuePost:T,expressionIndex:c};g.push(f),!n&&!i&&(t+=" ")}return{template:rb(t),elementsToBindings:o}}function ul(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,a={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(a)}}function yb(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))ul(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,a=-1;do{const r=t.get(++a);r&&ul(r,o,n)}while(o=s.nextNode())}return n}function vb(e){const{template:t,elementsToBindings:n}=Dn(lb,e,()=>mb(e)),i=t.cloneNode(!0).content.firstElementChild,s=yb(i,n);return function(a){return gb(a,s),i}}function bb(e){const t=Dn(cb,e,()=>new Map);let n=db;function i(o,...a){const r=Dn(t,o,()=>new Map);return Dn(r,n,()=>vb(o))(a)}function s(o,a,r){return o.map((l,c)=>{const h=n;n=r(l);try{return a(l,c)}finally{n=h}})}return{map:s,html:i}}function wb(e,t,n,i,s,o,a,r,l){const{labelWithSkin:c,titleForEmoji:h,unicodeWithSkin:d}=n,{html:p,map:g}=bb(t);function $(b,k,A){return g(b,(E,M)=>p`<button role="${k?"option":"menuitem"}" aria-selected="${k?M===t.activeSearchItem:null}" aria-label="${c(E,t.currentSkinTone)}" title="${h(E)}" class="${"emoji"+(k&&M===t.activeSearchItem?" active":"")+(E.unicode?"":" custom-emoji")}" id="${`${A}-${E.id}`}" style="${E.unicode?null:`--custom-emoji-background: url(${JSON.stringify(E.url)})`}">${E.unicode?d(E,t.currentSkinTone):""}</button>`,E=>`${A}-${E.id}`)}const T=p`<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">${g(t.skinTones,(b,k)=>p`<div id="skintone-${k}" class="emoji ${k===t.activeSkinTone?"active":""}" aria-selected="${k===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[k]}" aria-label="${t.i18n.skinTones[k]}">${b}</div>`,b=>b)}</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">${g(t.groups,b=>p`<button role="tab" class="nav-button" aria-controls="tab-${b.id}" aria-label="${t.i18n.categories[b.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===b.id}" title="${t.i18n.categories[b.name]}" data-group-id="${b.id}"><div class="nav-emoji emoji">${b.emoji}</div></button>`,b=>b.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">${g(t.currentEmojisWithCategories,(b,k)=>p`<div><div id="menu-label-${k}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:b.category?b.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${k!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(b.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${k}" id="${t.searchMode?"search-results":null}">${$(b.emojis,t.searchMode,"emo")}</div></div>`,b=>b.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${$(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,f=(b,k)=>{for(const A of e.querySelectorAll(`[${b}]`))k(A,A.getAttribute(b))};if(l){e.appendChild(T);for(const b of["click","focusout","input","keydown","keyup"])f(`data-on-${b}`,(k,A)=>{k.addEventListener(b,i[A])});f("data-ref",(b,k)=>{o[k]=b}),a.addEventListener("abort",()=>{e.removeChild(T)})}f("data-action",(b,k)=>{let A=r.get(k);A||r.set(k,A=new WeakSet),A.has(b)||(A.add(b),s[k](b))})}const Zi=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function kb(e){let t=!1,n;const i=new Map,s=new Set;let o;const a=()=>{if(t)return;const c=[...s];s.clear();try{for(const h of c)h()}finally{o=!1,s.size&&(o=!0,Zi(a))}},r=new Proxy({},{get(c,h){if(n){let d=i.get(h);d||(d=new Set,i.set(h,d)),d.add(n)}return c[h]},set(c,h,d){if(c[h]!==d){c[h]=d;const p=i.get(h);if(p){for(const g of p)s.add(g);o||(o=!0,Zi(a))}}return!0}}),l=c=>{const h=()=>{const d=n;n=h;try{return c()}finally{n=d}};return h()};return e.addEventListener("abort",()=>{t=!0}),{state:r,createEffect:l}}function oo(e,t,n){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}const pl=new WeakMap;function xb(e,t,n){{const i=e.closest(".tabpanel");let s=pl.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),pl.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const ao=[],{assign:wi}=Object;function $b(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:a}=kb(s),r=new Map;wi(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),wi(o,t),wi(o,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:zv,isRtl:!1,currentGroupIndex:0,groups:eo,databaseLoaded:!1,activeSearchItemId:void 0}),a(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const l=C=>{e.getElementById(C).focus()},c=C=>e.getElementById(`emo-${C.id}`),h=(C,I)=>{n.rootElement.dispatchEvent(new CustomEvent(C,{detail:I,bubbles:!0,composed:!0}))},d=(C,I)=>C.id===I.id,p=(C,I)=>{const{category:U,emojis:W}=C,{category:Z,emojis:J}=I;return U!==Z?!1:oo(W,J,d)},g=C=>{oo(o.currentEmojis,C,d)||(o.currentEmojis=C)},$=C=>{o.searchMode!==C&&(o.searchMode=C)},S=C=>{oo(o.currentEmojisWithCategories,C,p)||(o.currentEmojisWithCategories=C)},T=(C,I)=>I&&C.skins&&C.skins[I]||C.unicode,k={labelWithSkin:(C,I)=>ob([C.name||T(C,I),C.annotation,...C.shortcodes||ao].filter(Boolean)).join(", "),titleForEmoji:C=>C.annotation||(C.shortcodes||ao).join(", "),unicodeWithSkin:T},A={onClickSkinToneButton:X,onEmojiClick:Yn,onNavClick:Qn,onNavKeydown:bs,onSearchKeydown:vs,onSkinToneOptionsClick:Xn,onSkinToneOptionsFocusOut:tt,onSkinToneOptionsKeydown:pt,onSkinToneOptionsKeyup:dn,onSearchInput:Zn},E={calculateEmojiGridStyle:R,updateOnIntersection:F};let M=!0;a(()=>{wb(e,o,k,A,E,n,s,r,M),M=!1}),o.emojiVersion||no().then(C=>{C||(o.message=o.i18n.emojiUnsupportedMessage)}),a(()=>{async function C(){let I=!1;const U=setTimeout(()=>{I=!0,o.message=o.i18n.loadingMessage},Wv);try{await o.database.ready(),o.databaseLoaded=!0}catch(W){console.error(W),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(U),I&&(I=!1,o.message="")}}o.database&&C()}),a(()=>{o.pickerStyle=`
2852
+ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function ub(e){return iu(e,t=>t)}function pb(e){e&&(e.scrollTop=0)}function Dn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function hl(e){return""+e}function hb(e){const t=document.createElement("template");return t.innerHTML=e,t}const fb=new WeakMap,gb=new WeakMap,mb=Symbol("un-keyed"),yb="replaceChildren"in Element.prototype;function vb(e,t){yb?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function bb(e,t){let n=e.firstChild,i=0;for(;n;){if(t[i]!==n)return!0;n=n.nextSibling,i++}return i!==t.length}function wb(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=bb(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&vb(i,e)}function kb(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:a,attributeValuePre:r,attributeValuePost:c}}=n,d=e[o];if(s!==d)if(n.currentExpression=d,a)if(d===null)i.removeAttribute(a);else{const h=r+hl(d)+c;i.setAttribute(a,h)}else{let h;Array.isArray(d)?wb(d,n):d instanceof Element?(h=d,i.replaceWith(h)):i.nodeValue=hl(d),h&&(n.targetNode=h)}}}function xb(e){let t="",n=!1,i=!1,s=-1;const o=new Map,a=[];let r=0;for(let d=0,h=e.length;d<h;d++){const l=e[d];if(t+=l.slice(r),d===h-1)break;for(let b=0;b<l.length;b++)switch(l.charAt(b)){case"<":{l.charAt(b+1)==="/"?a.pop():(n=!0,a.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const p=a[a.length-1],g=Dn(o,p,()=>[]);let $,S,T;if(i){const b=/(\S+)="?([^"=]*)$/.exec(l);$=b[1],S=b[2];const k=/^([^">]*)("?)/.exec(e[d+1]);T=k[1],t=t.slice(0,-1*b[0].length),r=k[0].length}else r=0;const f={attributeName:$,attributeValuePre:S,attributeValuePost:T,expressionIndex:d};g.push(f),!n&&!i&&(t+=" ")}return{template:hb(t),elementsToBindings:o}}function fl(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,a={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(a)}}function $b(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))fl(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,a=-1;do{const r=t.get(++a);r&&fl(r,o,n)}while(o=s.nextNode())}return n}function Sb(e){const{template:t,elementsToBindings:n}=Dn(fb,e,()=>xb(e)),i=t.cloneNode(!0).content.firstElementChild,s=$b(i,n);return function(a){return kb(a,s),i}}function Ab(e){const t=Dn(gb,e,()=>new Map);let n=mb;function i(o,...a){const r=Dn(t,o,()=>new Map);return Dn(r,n,()=>Sb(o))(a)}function s(o,a,r){return o.map((c,d)=>{const h=n;n=r(c);try{return a(c,d)}finally{n=h}})}return{map:s,html:i}}function Cb(e,t,n,i,s,o,a,r,c){const{labelWithSkin:d,titleForEmoji:h,unicodeWithSkin:l}=n,{html:p,map:g}=Ab(t);function $(b,k,A){return g(b,(E,M)=>p`<button role="${k?"option":"menuitem"}" aria-selected="${k?M===t.activeSearchItem:null}" aria-label="${d(E,t.currentSkinTone)}" title="${h(E)}" class="${"emoji"+(k&&M===t.activeSearchItem?" active":"")+(E.unicode?"":" custom-emoji")}" id="${`${A}-${E.id}`}" style="${E.unicode?null:`--custom-emoji-background: url(${JSON.stringify(E.url)})`}">${E.unicode?l(E,t.currentSkinTone):""}</button>`,E=>`${A}-${E.id}`)}const T=p`<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">${g(t.skinTones,(b,k)=>p`<div id="skintone-${k}" class="emoji ${k===t.activeSkinTone?"active":""}" aria-selected="${k===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[k]}" aria-label="${t.i18n.skinTones[k]}">${b}</div>`,b=>b)}</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">${g(t.groups,b=>p`<button role="tab" class="nav-button" aria-controls="tab-${b.id}" aria-label="${t.i18n.categories[b.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===b.id}" title="${t.i18n.categories[b.name]}" data-group-id="${b.id}"><div class="nav-emoji emoji">${b.emoji}</div></button>`,b=>b.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">${g(t.currentEmojisWithCategories,(b,k)=>p`<div><div id="menu-label-${k}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:b.category?b.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${k!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(b.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${k}" id="${t.searchMode?"search-results":null}">${$(b.emojis,t.searchMode,"emo")}</div></div>`,b=>b.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${$(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,f=(b,k)=>{for(const A of e.querySelectorAll(`[${b}]`))k(A,A.getAttribute(b))};if(c){e.appendChild(T);for(const b of["click","focusout","input","keydown","keyup"])f(`data-on-${b}`,(k,A)=>{k.addEventListener(b,i[A])});f("data-ref",(b,k)=>{o[k]=b}),a.addEventListener("abort",()=>{e.removeChild(T)})}f("data-action",(b,k)=>{let A=r.get(k);A||r.set(k,A=new WeakSet),A.has(b)||(A.add(b),s[k](b))})}const es=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Eb(e){let t=!1,n;const i=new Map,s=new Set;let o;const a=()=>{if(t)return;const d=[...s];s.clear();try{for(const h of d)h()}finally{o=!1,s.size&&(o=!0,es(a))}},r=new Proxy({},{get(d,h){if(n){let l=i.get(h);l||(l=new Set,i.set(h,l)),l.add(n)}return d[h]},set(d,h,l){if(d[h]!==l){d[h]=l;const p=i.get(h);if(p){for(const g of p)s.add(g);o||(o=!0,es(a))}}return!0}}),c=d=>{const h=()=>{const l=n;n=h;try{return d()}finally{n=l}};return h()};return e.addEventListener("abort",()=>{t=!0}),{state:r,createEffect:c}}function ao(e,t,n){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}const gl=new WeakMap;function Tb(e,t,n){{const i=e.closest(".tabpanel");let s=gl.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),gl.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const ro=[],{assign:wi}=Object;function _b(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:a}=Eb(s),r=new Map;wi(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),wi(o,t),wi(o,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:Qv,isRtl:!1,currentGroupIndex:0,groups:to,databaseLoaded:!1,activeSearchItemId:void 0}),a(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const c=C=>{e.getElementById(C).focus()},d=C=>e.getElementById(`emo-${C.id}`),h=(C,I)=>{n.rootElement.dispatchEvent(new CustomEvent(C,{detail:I,bubbles:!0,composed:!0}))},l=(C,I)=>C.id===I.id,p=(C,I)=>{const{category:U,emojis:W}=C,{category:Z,emojis:J}=I;return U!==Z?!1:ao(W,J,l)},g=C=>{ao(o.currentEmojis,C,l)||(o.currentEmojis=C)},$=C=>{o.searchMode!==C&&(o.searchMode=C)},S=C=>{ao(o.currentEmojisWithCategories,C,p)||(o.currentEmojisWithCategories=C)},T=(C,I)=>I&&C.skins&&C.skins[I]||C.unicode,k={labelWithSkin:(C,I)=>ub([C.name||T(C,I),C.annotation,...C.shortcodes||ro].filter(Boolean)).join(", "),titleForEmoji:C=>C.annotation||(C.shortcodes||ro).join(", "),unicodeWithSkin:T},A={onClickSkinToneButton:X,onEmojiClick:Yn,onNavClick:Qn,onNavKeydown:ws,onSearchKeydown:bs,onSkinToneOptionsClick:Xn,onSkinToneOptionsFocusOut:tt,onSkinToneOptionsKeydown:pt,onSkinToneOptionsKeyup:dn,onSearchInput:Zn},E={calculateEmojiGridStyle:R,updateOnIntersection:F};let M=!0;a(()=>{Cb(e,o,k,A,E,n,s,r,M),M=!1}),o.emojiVersion||io().then(C=>{C||(o.message=o.i18n.emojiUnsupportedMessage)}),a(()=>{async function C(){let I=!1;const U=setTimeout(()=>{I=!0,o.message=o.i18n.loadingMessage},Gv);try{await o.database.ready(),o.databaseLoaded=!0}catch(W){console.error(W),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(U),I&&(I=!1,o.message="")}}o.database&&C()}),a(()=>{o.pickerStyle=`
2853
2853
  --num-groups: ${o.groups.length};
2854
2854
  --indicator-opacity: ${o.searchMode?0:1};
2855
- --num-skintones: ${al};`}),a(()=>{o.customEmoji&&o.database&&P()}),a(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Oo&&(o.groups=Oo):o.groups!==eo&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=eo)}),a(()=>{async function C(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}C()}),a(()=>{o.skinTones=Array(al).fill().map((C,I)=>eb(o.skinToneEmoji,I))}),a(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),a(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),a(()=>{async function C(){const{database:I}=o,U=(await Promise.all(qv.map(W=>I.getEmojiByUnicodeOrName(W)))).filter(Boolean);o.defaultFavoriteEmojis=U}o.databaseLoaded&&C()});function P(){const{customEmoji:C,database:I}=o,U=C||ao;I.customEmoji!==U&&(I.customEmoji=U)}a(()=>{async function C(){P();const{database:I,defaultFavoriteEmojis:U,numColumns:W}=o,Z=await I.getTopFavoriteEmoji(W),J=await Ke(Zd([...Z,...U],fe=>fe.unicode||fe.name).slice(0,W));o.currentFavorites=J}o.databaseLoaded&&o.defaultFavoriteEmojis&&C()});function R(C){ib(C,s,()=>{{const I=getComputedStyle(n.rootElement),U=parseInt(I.getPropertyValue("--num-columns"),10),W=I.getPropertyValue("direction")==="rtl";o.numColumns=U,o.isRtl=W}})}function F(C){xb(C,s,I=>{for(const{target:U,isIntersecting:W}of I)U.classList.toggle("onscreen",W)})}a(()=>{async function C(){const{searchText:I,currentGroup:U,databaseLoaded:W,customEmoji:Z}=o;if(!W)o.currentEmojis=[],o.searchMode=!1;else if(I.length>=Fv){const J=await ys(I);o.searchText===I&&(g(J),$(!0))}else{const{id:J}=U;if(J!==-1||Z&&Z.length){const fe=await ms(J);o.currentGroup.id===J&&(g(fe),$(!1))}}}C()});const H=()=>{Ti(()=>ab(n.tabpanelElement))};a(()=>{const{currentEmojis:C,emojiVersion:I}=o,U=C.filter(W=>W.unicode).filter(W=>rl(W)&&!Fo.has(W.unicode));if(!I&&U.length)g(C),Ti(()=>z(U));else{const W=I?C:C.filter(ke);g(W),H()}});function z(C){sb(C,n.baselineEmoji,c)?H():o.currentEmojis=[...o.currentEmojis]}function ke(C){return!C.unicode||!rl(C)||Fo.get(C.unicode)}async function _e(C){const I=o.emojiVersion||await no();return C.filter(({version:U})=>!U||U<=I)}async function Ke(C){return tb(C,o.emojiVersion||await no())}async function ms(C){const I=C===-1?o.customEmoji:await o.database.getEmojiByGroup(C);return Ke(await _e(I))}async function ys(C){return Ke(await _e(await o.database.getEmojiBySearchQuery(C)))}a(()=>{}),a(()=>{function C(){const{searchMode:U,currentEmojis:W}=o;if(U)return[{category:"",emojis:W}];const Z=new Map;for(const J of W){const fe=J.category||"";let nt=Z.get(fe);nt||(nt=[],Z.set(fe,nt)),nt.push(J)}return[...Z.entries()].map(([J,fe])=>({category:J,emojis:fe})).sort((J,fe)=>o.customCategorySorting(J.category,fe.category))}const I=C();S(I)}),a(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),a(()=>{const{rawSearchText:C}=o;Yd(()=>{o.searchText=(C||"").trim(),o.activeSearchItem=-1})});function vs(C){if(!o.searchMode||!o.currentEmojis.length)return;const I=U=>{Le(C),o.activeSearchItem=io(U,o.activeSearchItem,o.currentEmojis)};switch(C.key){case"ArrowDown":return I(!1);case"ArrowUp":return I(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Le(C),te(o.currentEmojis[o.activeSearchItem].id)}}function Qn(C){const{target:I}=C,U=I.closest(".nav-button");if(!U)return;const W=parseInt(U.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(Z=>Z.id===W)}function bs(C){const{target:I,key:U}=C,W=Z=>{Z&&(Le(C),Z.focus())};switch(U){case"ArrowLeft":return W(I.previousElementSibling);case"ArrowRight":return W(I.nextElementSibling);case"Home":return W(I.parentElement.firstElementChild);case"End":return W(I.parentElement.lastElementChild)}}async function Jn(C){const I=await o.database.getEmojiByUnicodeOrName(C),U=[...o.currentEmojis,...o.currentFavorites].find(Z=>Z.id===C),W=U.unicode&&T(U,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(C),{emoji:I,skinTone:o.currentSkinTone,...W&&{unicode:W},...U.name&&{name:U.name}}}async function te(C){const I=Jn(C);h("emoji-click-sync",I),h("emoji-click",await I)}function Yn(C){const{target:I}=C;if(!I.classList.contains("emoji"))return;Le(C);const U=I.id.substring(4);te(U)}function ne(C){o.currentSkinTone=C,o.skinTonePickerExpanded=!1,l("skintone-button"),h("skin-tone-change",{skinTone:C}),o.database.setPreferredSkinTone(C)}function Xn(C){const{target:{id:I}}=C,U=I&&I.match(/^skintone-(\d)/);if(!U)return;Le(C);const W=parseInt(U[1],10);ne(W)}function X(C){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Le(C),Ti(()=>l("skintone-list")))}a(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function pt(C){if(!o.skinTonePickerExpanded)return;const I=async U=>{Le(C),o.activeSkinTone=U};switch(C.key){case"ArrowUp":return I(io(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return I(io(!1,o.activeSkinTone,o.skinTones));case"Home":return I(0);case"End":return I(o.skinTones.length-1);case"Enter":return Le(C),ne(o.activeSkinTone);case"Escape":return Le(C),o.skinTonePickerExpanded=!1,l("skintone-button")}}function dn(C){if(o.skinTonePickerExpanded&&C.key===" ")return Le(C),ne(o.activeSkinTone)}async function tt(C){const{relatedTarget:I}=C;(!I||I.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function Zn(C){o.rawSearchText=C.target.value}return{$set(C){wi(o,C)},$destroy(){i.abort()}}}const Sb="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Ab="en";var Cb={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"}},Eb=':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 eu=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Tb=`:host{--emoji-font-family:${Xd}}`;class Ba extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Eb+Tb,this.shadowRoot.appendChild(n),this._ctx={locale:Ab,dataSource:Sb,skinToneEmoji:Kv,customCategorySorting:Hv,customEmoji:null,i18n:Cb,emojiVersion:null,...t};for(const i of eu)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){hl(this),this._cmp||(this._cmp=$b(this.shadowRoot,this._ctx))}disconnectedCallback(){hl(this),Zi(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:t}=this._ctx;t.close().catch(n=>console.error(n))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(t,n,i){this._set(t.replace(/-([a-z])/g,(s,o)=>o.toUpperCase()),t==="emoji-version"?parseFloat(i):i)}_set(t,n){this._ctx[t]=n,this._cmp&&this._cmp.$set({[t]:n}),["locale","dataSource"].includes(t)&&this._dbFlush()}_dbCreate(){const{locale:t,dataSource:n,database:i}=this._ctx;(!i||i.locale!==t||i.dataSource!==n)&&this._set("database",new Ov({locale:t,dataSource:n}))}_dbFlush(){Zi(()=>this._dbCreate())}}const tu={};for(const e of eu)tu[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(Ba.prototype,tu);function hl(e){e instanceof Ba||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Ba);function _b(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 fl(e){e.style.height="44px",e.style.overflowY="hidden"}const Mb=5e3;function Pb(e){return e?e.active?u`
2855
+ --num-skintones: ${cl};`}),a(()=>{o.customEmoji&&o.database&&P()}),a(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Fo&&(o.groups=Fo):o.groups!==to&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=to)}),a(()=>{async function C(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}C()}),a(()=>{o.skinTones=Array(cl).fill().map((C,I)=>ab(o.skinToneEmoji,I))}),a(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),a(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),a(()=>{async function C(){const{database:I}=o,U=(await Promise.all(Jv.map(W=>I.getEmojiByUnicodeOrName(W)))).filter(Boolean);o.defaultFavoriteEmojis=U}o.databaseLoaded&&C()});function P(){const{customEmoji:C,database:I}=o,U=C||ro;I.customEmoji!==U&&(I.customEmoji=U)}a(()=>{async function C(){P();const{database:I,defaultFavoriteEmojis:U,numColumns:W}=o,Z=await I.getTopFavoriteEmoji(W),J=await Ke(iu([...Z,...U],fe=>fe.unicode||fe.name).slice(0,W));o.currentFavorites=J}o.databaseLoaded&&o.defaultFavoriteEmojis&&C()});function R(C){cb(C,s,()=>{{const I=getComputedStyle(n.rootElement),U=parseInt(I.getPropertyValue("--num-columns"),10),W=I.getPropertyValue("direction")==="rtl";o.numColumns=U,o.isRtl=W}})}function F(C){Tb(C,s,I=>{for(const{target:U,isIntersecting:W}of I)U.classList.toggle("onscreen",W)})}a(()=>{async function C(){const{searchText:I,currentGroup:U,databaseLoaded:W,customEmoji:Z}=o;if(!W)o.currentEmojis=[],o.searchMode=!1;else if(I.length>=qv){const J=await vs(I);o.searchText===I&&(g(J),$(!0))}else{const{id:J}=U;if(J!==-1||Z&&Z.length){const fe=await ys(J);o.currentGroup.id===J&&(g(fe),$(!1))}}}C()});const q=()=>{_i(()=>pb(n.tabpanelElement))};a(()=>{const{currentEmojis:C,emojiVersion:I}=o,U=C.filter(W=>W.unicode).filter(W=>dl(W)&&!Uo.has(W.unicode));if(!I&&U.length)g(C),_i(()=>z(U));else{const W=I?C:C.filter(ke);g(W),q()}});function z(C){db(C,n.baselineEmoji,d)?q():o.currentEmojis=[...o.currentEmojis]}function ke(C){return!C.unicode||!dl(C)||Uo.get(C.unicode)}async function _e(C){const I=o.emojiVersion||await io();return C.filter(({version:U})=>!U||U<=I)}async function Ke(C){return rb(C,o.emojiVersion||await io())}async function ys(C){const I=C===-1?o.customEmoji:await o.database.getEmojiByGroup(C);return Ke(await _e(I))}async function vs(C){return Ke(await _e(await o.database.getEmojiBySearchQuery(C)))}a(()=>{}),a(()=>{function C(){const{searchMode:U,currentEmojis:W}=o;if(U)return[{category:"",emojis:W}];const Z=new Map;for(const J of W){const fe=J.category||"";let nt=Z.get(fe);nt||(nt=[],Z.set(fe,nt)),nt.push(J)}return[...Z.entries()].map(([J,fe])=>({category:J,emojis:fe})).sort((J,fe)=>o.customCategorySorting(J.category,fe.category))}const I=C();S(I)}),a(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),a(()=>{const{rawSearchText:C}=o;tu(()=>{o.searchText=(C||"").trim(),o.activeSearchItem=-1})});function bs(C){if(!o.searchMode||!o.currentEmojis.length)return;const I=U=>{Le(C),o.activeSearchItem=so(U,o.activeSearchItem,o.currentEmojis)};switch(C.key){case"ArrowDown":return I(!1);case"ArrowUp":return I(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Le(C),te(o.currentEmojis[o.activeSearchItem].id)}}function Qn(C){const{target:I}=C,U=I.closest(".nav-button");if(!U)return;const W=parseInt(U.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(Z=>Z.id===W)}function ws(C){const{target:I,key:U}=C,W=Z=>{Z&&(Le(C),Z.focus())};switch(U){case"ArrowLeft":return W(I.previousElementSibling);case"ArrowRight":return W(I.nextElementSibling);case"Home":return W(I.parentElement.firstElementChild);case"End":return W(I.parentElement.lastElementChild)}}async function Jn(C){const I=await o.database.getEmojiByUnicodeOrName(C),U=[...o.currentEmojis,...o.currentFavorites].find(Z=>Z.id===C),W=U.unicode&&T(U,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(C),{emoji:I,skinTone:o.currentSkinTone,...W&&{unicode:W},...U.name&&{name:U.name}}}async function te(C){const I=Jn(C);h("emoji-click-sync",I),h("emoji-click",await I)}function Yn(C){const{target:I}=C;if(!I.classList.contains("emoji"))return;Le(C);const U=I.id.substring(4);te(U)}function ne(C){o.currentSkinTone=C,o.skinTonePickerExpanded=!1,c("skintone-button"),h("skin-tone-change",{skinTone:C}),o.database.setPreferredSkinTone(C)}function Xn(C){const{target:{id:I}}=C,U=I&&I.match(/^skintone-(\d)/);if(!U)return;Le(C);const W=parseInt(U[1],10);ne(W)}function X(C){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Le(C),_i(()=>c("skintone-list")))}a(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function pt(C){if(!o.skinTonePickerExpanded)return;const I=async U=>{Le(C),o.activeSkinTone=U};switch(C.key){case"ArrowUp":return I(so(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return I(so(!1,o.activeSkinTone,o.skinTones));case"Home":return I(0);case"End":return I(o.skinTones.length-1);case"Enter":return Le(C),ne(o.activeSkinTone);case"Escape":return Le(C),o.skinTonePickerExpanded=!1,c("skintone-button")}}function dn(C){if(o.skinTonePickerExpanded&&C.key===" ")return Le(C),ne(o.activeSkinTone)}async function tt(C){const{relatedTarget:I}=C;(!I||I.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function Zn(C){o.rawSearchText=C.target.value}return{$set(C){wi(o,C)},$destroy(){i.abort()}}}const Mb="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Pb="en";var Ib={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"}},Lb=':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 su=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Rb=`:host{--emoji-font-family:${nu}}`;class Na extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Lb+Rb,this.shadowRoot.appendChild(n),this._ctx={locale:Pb,dataSource:Mb,skinToneEmoji:Vv,customCategorySorting:Yv,customEmoji:null,i18n:Ib,emojiVersion:null,...t};for(const i of su)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){ml(this),this._cmp||(this._cmp=_b(this.shadowRoot,this._ctx))}disconnectedCallback(){ml(this),es(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:t}=this._ctx;t.close().catch(n=>console.error(n))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(t,n,i){this._set(t.replace(/-([a-z])/g,(s,o)=>o.toUpperCase()),t==="emoji-version"?parseFloat(i):i)}_set(t,n){this._ctx[t]=n,this._cmp&&this._cmp.$set({[t]:n}),["locale","dataSource"].includes(t)&&this._dbFlush()}_dbCreate(){const{locale:t,dataSource:n,database:i}=this._ctx;(!i||i.locale!==t||i.dataSource!==n)&&this._set("database",new Hv({locale:t,dataSource:n}))}_dbFlush(){es(()=>this._dbCreate())}}const ou={};for(const e of su)ou[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(Na.prototype,ou);function ml(e){e instanceof Na||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Na);function Db(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 yl(e){e.style.height="44px",e.style.overflowY="hidden"}const Bb=5e3;function Nb(e){return e?e.active?u`
2856
2856
  <div class="callout info compaction-indicator compaction-indicator--active">
2857
2857
  ${L.loader} Compacting context...
2858
2858
  </div>
2859
- `:e.completedAt&&Date.now()-e.completedAt<Mb?u`
2859
+ `:e.completedAt&&Date.now()-e.completedAt<Bb?u`
2860
2860
  <div class="callout success compaction-indicator compaction-indicator--complete">
2861
2861
  ${L.check} Context compacted
2862
2862
  </div>
2863
- `:w:w}const Qe=5*1024*1024;function Je(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Te(e,t){var i,s,o;let n=(i=e.closest(".chat"))==null?void 0:i.querySelector(".chat-attachment-error");if(!n){n=document.createElement("div"),n.className="callout danger chat-attachment-error",n.style.cssText="margin: 8px 4px; animation: fade-in 200ms ease-out;";const a=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(o=a==null?void 0:a.parentElement)==null||o.insertBefore(n,a)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const Ib=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function nu(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function iu(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||Ib.test(e.name)}function su(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function ou(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function Lb(e,t){if(!t.onAttachmentsChange)return;const n=document.querySelector(".chat");if(nu(e)){if(e.size>Qe){n&&Te(n,`Image too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:i.result,mimeType:e.type};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(iu(e)){if(e.size>Qe){n&&Te(n,`File too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:"",mimeType:e.type||"text/plain",fileName:e.name,textContent:i.result};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsText(e)}else if(su(e)){if(e.size>Qe){n&&Te(n,`PDF too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:i.result,mimeType:"application/pdf",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(ou(e)){if(e.size>Qe){n&&Te(n,`Video too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:i.result,mimeType:e.type||"video/mp4",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else n&&Te(n,`Unsupported file type: ${e.name}. Use the Files page to upload to workspace.`)}function Rb(e,t){var s;e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const i=(s=e.dataTransfer)==null?void 0:s.files;if(!(!i||i.length===0))for(let o=0;o<i.length;o++){const a=i[o];if(nu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`Image too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const l=r.result,c={id:Je(),dataUrl:l,mimeType:a.type},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else if(iu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`File too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const l=r.result,c={id:Je(),dataUrl:"",mimeType:a.type||"text/plain",fileName:a.name,textContent:l},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsText(a)}else if(su(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`PDF too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const l=r.result,c={id:Je(),dataUrl:l,mimeType:"application/pdf",fileName:a.name},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else if(ou(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`Video too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const l=r.result,c={id:Je(),dataUrl:l,mimeType:a.type||"video/mp4",fileName:a.name},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else Te(n,`Unsupported file type: ${a.name}. Use the Files page to upload to workspace.`)}}function Db(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Bb(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function Nb(e,t){var s,o,a;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n||!t.onAttachmentsChange)return;const i=[];for(let r=0;r<n.length;r++){const l=n[r];(l.type.startsWith("image/")||l.type.startsWith("video/"))&&i.push(l)}if(i.length!==0){e.preventDefault();for(const r of i){const l=r.getAsFile();if(!l)continue;const c=l.type.startsWith("video/")?"Video":"Image";if(l.size>Qe){const d=((a=(o=e.target)==null?void 0:o.closest)==null?void 0:a.call(o,".chat"))??document.querySelector(".chat");d&&Te(d,`${c} too large (${(l.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const h=new FileReader;h.onload=()=>{var S;const d=h.result,p=l.type.startsWith("video/"),g={id:Je(),dataUrl:d,mimeType:l.type,fileName:p?l.name||"video.mp4":void 0},$=t.attachments??[];(S=t.onAttachmentsChange)==null||S.call(t,[...$,g])},h.readAsDataURL(l)}}}function Ob(e){const t=e.currentTarget,n=t.closest(".chat-compose"),i=n==null?void 0:n.querySelector(".emoji-picker-popup");if(!i)return;const s=i.classList.toggle("active");if(t.classList.toggle("active",s),s){const o=a=>{i.contains(a.target)||t.contains(a.target)||(i.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",o,!0))};requestAnimationFrame(()=>document.addEventListener("click",o,!0))}}function Fb(e,t){const n=e.detail,i=n==null?void 0:n.unicode;if(!i)return;const s=e.currentTarget.closest(".chat-compose"),o=s==null?void 0:s.querySelector("textarea");if(!o)return;const a=o.selectionStart??t.draft.length,r=o.selectionEnd??a,l=t.draft.slice(0,a),c=t.draft.slice(r);t.onDraftChange(l+i+c);const h=s==null?void 0:s.querySelector(".emoji-picker-popup"),d=s==null?void 0:s.querySelector(".chat-compose__emoji");h==null||h.classList.remove("active"),d==null||d.classList.remove("active"),requestAnimationFrame(()=>{o.focus();const p=a+i.length;o.setSelectionRange(p,p)})}function Ub(e){const t=e.attachments??[];return t.length===0?w:u`
2863
+ `:w:w}const Qe=5*1024*1024;function Je(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Te(e,t){var i,s,o;let n=(i=e.closest(".chat"))==null?void 0:i.querySelector(".chat-attachment-error");if(!n){n=document.createElement("div"),n.className="callout danger chat-attachment-error",n.style.cssText="margin: 8px 4px; animation: fade-in 200ms ease-out;";const a=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(o=a==null?void 0:a.parentElement)==null||o.insertBefore(n,a)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const Ob=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function au(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function ru(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||Ob.test(e.name)}function lu(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function cu(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function Fb(e,t){if(!t.onAttachmentsChange)return;const n=document.querySelector(".chat");if(au(e)){if(e.size>Qe){n&&Te(n,`Image too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:i.result,mimeType:e.type};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(ru(e)){if(e.size>Qe){n&&Te(n,`File too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:"",mimeType:e.type||"text/plain",fileName:e.name,textContent:i.result};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsText(e)}else if(lu(e)){if(e.size>Qe){n&&Te(n,`PDF too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:i.result,mimeType:"application/pdf",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(cu(e)){if(e.size>Qe){n&&Te(n,`Video too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:i.result,mimeType:e.type||"video/mp4",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else n&&Te(n,`Unsupported file type: ${e.name}. Use the Files page to upload to workspace.`)}function Ub(e,t){var s;e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const i=(s=e.dataTransfer)==null?void 0:s.files;if(!(!i||i.length===0))for(let o=0;o<i.length;o++){const a=i[o];if(au(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`Image too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var l;const c=r.result,d={id:Je(),dataUrl:c,mimeType:a.type},h=t.attachments??[];(l=t.onAttachmentsChange)==null||l.call(t,[...h,d])},r.readAsDataURL(a)}else if(ru(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`File too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var l;const c=r.result,d={id:Je(),dataUrl:"",mimeType:a.type||"text/plain",fileName:a.name,textContent:c},h=t.attachments??[];(l=t.onAttachmentsChange)==null||l.call(t,[...h,d])},r.readAsText(a)}else if(lu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`PDF too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var l;const c=r.result,d={id:Je(),dataUrl:c,mimeType:"application/pdf",fileName:a.name},h=t.attachments??[];(l=t.onAttachmentsChange)==null||l.call(t,[...h,d])},r.readAsDataURL(a)}else if(cu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`Video too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var l;const c=r.result,d={id:Je(),dataUrl:c,mimeType:a.type||"video/mp4",fileName:a.name},h=t.attachments??[];(l=t.onAttachmentsChange)==null||l.call(t,[...h,d])},r.readAsDataURL(a)}else Te(n,`Unsupported file type: ${a.name}. Use the Files page to upload to workspace.`)}}function Wb(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Kb(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function zb(e,t){var s,o,a;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n||!t.onAttachmentsChange)return;const i=[];for(let r=0;r<n.length;r++){const c=n[r];(c.type.startsWith("image/")||c.type.startsWith("video/"))&&i.push(c)}if(i.length!==0){e.preventDefault();for(const r of i){const c=r.getAsFile();if(!c)continue;const d=c.type.startsWith("video/")?"Video":"Image";if(c.size>Qe){const l=((a=(o=e.target)==null?void 0:o.closest)==null?void 0:a.call(o,".chat"))??document.querySelector(".chat");l&&Te(l,`${d} too large (${(c.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const h=new FileReader;h.onload=()=>{var S;const l=h.result,p=c.type.startsWith("video/"),g={id:Je(),dataUrl:l,mimeType:c.type,fileName:p?c.name||"video.mp4":void 0},$=t.attachments??[];(S=t.onAttachmentsChange)==null||S.call(t,[...$,g])},h.readAsDataURL(c)}}}function Hb(e){const t=e.currentTarget,n=t.closest(".chat-compose"),i=n==null?void 0:n.querySelector(".emoji-picker-popup");if(!i)return;const s=i.classList.toggle("active");if(t.classList.toggle("active",s),s){const o=a=>{i.contains(a.target)||t.contains(a.target)||(i.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",o,!0))};requestAnimationFrame(()=>document.addEventListener("click",o,!0))}}function qb(e,t){const n=e.detail,i=n==null?void 0:n.unicode;if(!i)return;const s=e.currentTarget.closest(".chat-compose"),o=s==null?void 0:s.querySelector("textarea");if(!o)return;const a=o.selectionStart??t.draft.length,r=o.selectionEnd??a,c=t.draft.slice(0,a),d=t.draft.slice(r);t.onDraftChange(c+i+d);const h=s==null?void 0:s.querySelector(".emoji-picker-popup"),l=s==null?void 0:s.querySelector(".chat-compose__emoji");h==null||h.classList.remove("active"),l==null||l.classList.remove("active"),requestAnimationFrame(()=>{o.focus();const p=a+i.length;o.setSelectionRange(p,p)})}function jb(e){const t=e.attachments??[];return t.length===0?w:u`
2864
2864
  <div class="chat-attachments">
2865
2865
  ${t.map(n=>{var i;return n.fileName?u`
2866
2866
  <div class="chat-attachment chat-attachment--file">
@@ -2893,7 +2893,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
2893
2893
  </div>
2894
2894
  `})}
2895
2895
  </div>
2896
- `}function au(e){var $,S,T;const t=e.connected,n=e.sending||e.stream!==null,i=!!(e.canAbort&&e.onAbort),s=(S=($=e.sessions)==null?void 0:$.sessions)==null?void 0:S.find(f=>f.key===e.sessionKey),o=(s==null?void 0:s.reasoningLevel)??"off",a=e.showThinking&&o!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const r=(((T=e.attachments)==null?void 0:T.length)??0)>0,l=e.connected?r?"Add a message...":"Message...":"Connecting…";jy({onSend:f=>{e.onAttachmentsChange&&e.onAttachmentsChange([...e.attachments??[],f]),requestAnimationFrame(()=>e.onSend())},onRequestRender:()=>{var f;(f=e.requestUpdate)==null||f.call(e)}});const c=Hy(),h=!c&&!e.draft.trim()&&!r&&!n,d=e.splitRatio??.6,p=!!(e.sidebarOpen&&e.onCloseSidebar),g=u`
2896
+ `}function du(e){var $,S,T;const t=e.connected,n=e.sending||e.stream!==null,i=!!(e.canAbort&&e.onAbort),s=(S=($=e.sessions)==null?void 0:$.sessions)==null?void 0:S.find(f=>f.key===e.sessionKey),o=(s==null?void 0:s.reasoningLevel)??"off",a=e.showThinking&&o!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const r=(((T=e.attachments)==null?void 0:T.length)??0)>0,c=e.connected?r?"Add a message...":"Message...":"Connecting…";Xy({onSend:f=>{e.onAttachmentsChange&&e.onAttachmentsChange([...e.attachments??[],f]),requestAnimationFrame(()=>e.onSend())},onRequestRender:()=>{var f;(f=e.requestUpdate)==null||f.call(e)}});const d=Yy(),h=!d&&!e.draft.trim()&&!r&&!n,l=e.splitRatio??.6,p=!!(e.sidebarOpen&&e.onCloseSidebar),g=u`
2897
2897
  <div
2898
2898
  class="chat-thread"
2899
2899
  role="log"
@@ -2904,20 +2904,20 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
2904
2904
  ${e.loadingOlder?u`<span class="chat-load-more__spinner">${L.loader}</span> Loading older messages…`:u`<button class="chat-load-more__btn" type="button" @click=${e.onLoadOlder}>Load older messages</button>`}
2905
2905
  </div>`:w}
2906
2906
  ${e.loading?u`<div class="muted">Loading chat…</div>`:w}
2907
- ${tm(Gb(e),f=>f.key,f=>f.kind==="interim"?Dy(f.text):f.kind==="reading-indicator"?Ry():f.kind==="stream"?By(f.text,f.startedAt,e.onOpenSidebar):f.kind==="group"?Ny(f,{onOpenSidebar:e.onOpenSidebar,showReasoning:a,assistantName:e.assistantName}):w)}
2907
+ ${rm(Zb(e),f=>f.key,f=>f.kind==="interim"?Wy(f.text):f.kind==="reading-indicator"?Uy():f.kind==="stream"?Ky(f.text,f.startedAt,e.onOpenSidebar):f.kind==="group"?zy(f,{onOpenSidebar:e.onOpenSidebar,showReasoning:a,assistantName:e.assistantName}):w)}
2908
2908
  </div>
2909
2909
  `;return u`
2910
2910
  <section
2911
2911
  class="card chat"
2912
- @drop=${f=>Rb(f,e)}
2913
- @dragover=${Db}
2914
- @dragleave=${Bb}
2912
+ @drop=${f=>Ub(f,e)}
2913
+ @dragover=${Wb}
2914
+ @dragleave=${Kb}
2915
2915
  >
2916
2916
  ${e.disabledReason?u`<div class="callout">${e.disabledReason}</div>`:w}
2917
2917
 
2918
2918
  ${e.error?u`<div class="callout danger">${e.error}</div>`:w}
2919
2919
 
2920
- ${Pb(e.compactionStatus)}
2920
+ ${Nb(e.compactionStatus)}
2921
2921
 
2922
2922
  ${e.focusMode?u`
2923
2923
  <button
@@ -2936,7 +2936,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
2936
2936
  >
2937
2937
  <div
2938
2938
  class="chat-main"
2939
- style="flex: ${p?`0 0 ${d*100}%`:"1 1 100%"}"
2939
+ style="flex: ${p?`0 0 ${l*100}%`:"1 1 100%"}"
2940
2940
  >
2941
2941
  ${g}
2942
2942
  ${e.nearBottom===!1?u`
@@ -2954,11 +2954,11 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
2954
2954
 
2955
2955
  ${p?u`
2956
2956
  <resizable-divider
2957
- .splitRatio=${d}
2957
+ .splitRatio=${l}
2958
2958
  @resize=${f=>{var b;return(b=e.onSplitRatioChange)==null?void 0:b.call(e,f.detail.splitRatio)}}
2959
2959
  ></resizable-divider>
2960
2960
  <div class="chat-sidebar">
2961
- ${Qy({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
2961
+ ${tv({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
2962
2962
  ${e.sidebarContent}
2963
2963
  \`\`\``)}})}
2964
2964
  </div>
@@ -2980,13 +2980,13 @@ ${e.sidebarContent}
2980
2980
  `:w}
2981
2981
 
2982
2982
  <div class="chat-compose">
2983
- ${Ub(e)}
2984
- ${c?Vy():u`
2983
+ ${jb(e)}
2984
+ ${d?ev():u`
2985
2985
  <div class="chat-compose__row">
2986
2986
  <button
2987
2987
  class="chat-compose__emoji"
2988
2988
  type="button"
2989
- @click=${Ob}
2989
+ @click=${Hb}
2990
2990
  aria-label="Emoji"
2991
2991
  title="Emoji"
2992
2992
  >
@@ -3007,17 +3007,17 @@ ${e.sidebarContent}
3007
3007
  multiple
3008
3008
  accept="image/*,video/*,.pdf,.md,.txt,.csv,.json,.xml,.html,.css,.js,.ts,.py,.sh,.yaml,.yml,.toml,.ini,.cfg,.log,.sql"
3009
3009
  style="display:none"
3010
- @change=${f=>{const b=f.target,k=b.files;if(!(!k||k.length===0||!e.onAttachmentsChange)){for(let A=0;A<k.length;A++)Lb(k[A],e);b.value=""}}}
3010
+ @change=${f=>{const b=f.target,k=b.files;if(!(!k||k.length===0||!e.onAttachmentsChange)){for(let A=0;A<k.length;A++)Fb(k[A],e);b.value=""}}}
3011
3011
  />
3012
3012
  <label class="field chat-compose__field">
3013
3013
  <span>Message</span>
3014
3014
  <textarea
3015
3015
  .value=${e.draft}
3016
3016
  ?disabled=${!e.connected}
3017
- @keydown=${f=>{f.key==="Enter"&&(f.isComposing||f.keyCode===229||f.shiftKey||e.connected&&(f.preventDefault(),t&&(e.onSend(),fl(f.target))))}}
3018
- @input=${f=>{const b=f.target;e.onDraftChange(b.value),_b(b)}}
3019
- @paste=${f=>Nb(f,e)}
3020
- placeholder=${l}
3017
+ @keydown=${f=>{f.key==="Enter"&&(f.isComposing||f.keyCode===229||f.shiftKey||e.connected&&(f.preventDefault(),t&&(e.onSend(),yl(f.target))))}}
3018
+ @input=${f=>{const b=f.target;e.onDraftChange(b.value),Db(b)}}
3019
+ @paste=${f=>zb(f,e)}
3020
+ placeholder=${c}
3021
3021
  ></textarea>
3022
3022
  </label>
3023
3023
  ${i?u`
@@ -3030,11 +3030,11 @@ ${e.sidebarContent}
3030
3030
  ${L.square}
3031
3031
  </button>
3032
3032
  `:w}
3033
- ${h?Gy(e.connected):u`
3033
+ ${h?Zy(e.connected):u`
3034
3034
  <button
3035
3035
  class="btn btn--icon chat-compose__send primary"
3036
3036
  ?disabled=${!e.connected}
3037
- @click=${f=>{var k;e.onSend();const b=(k=f.target.closest(".chat-compose"))==null?void 0:k.querySelector("textarea");b&&fl(b)}}
3037
+ @click=${f=>{var k;e.onSend();const b=(k=f.target.closest(".chat-compose"))==null?void 0:k.querySelector("textarea");b&&yl(b)}}
3038
3038
  aria-label="${n?"Queue":"Send"}"
3039
3039
  title="${n?"Queue message":"Send (Enter)"}"
3040
3040
  >
@@ -3043,19 +3043,19 @@ ${e.sidebarContent}
3043
3043
  </div>`}
3044
3044
  <div class="emoji-picker-popup">
3045
3045
  <emoji-picker
3046
- @emoji-click=${f=>Fb(f,e)}
3046
+ @emoji-click=${f=>qb(f,e)}
3047
3047
  ></emoji-picker>
3048
3048
  </div>
3049
- ${e.publicMode?w:Hb(e)}
3049
+ ${e.publicMode?w:Yb(e)}
3050
3050
  </div>
3051
3051
  </section>
3052
- `}const Wb=[{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 Kb(e,t){const n=new Set(e.filter(s=>s.provider==="anthropic").map(s=>s.id)),i=Wb.filter(s=>n.has(s.id)).map(s=>({key:`anthropic/${s.id}`,...s}));if(t&&!i.some(s=>s.key===t)){const[s,...o]=t.split("/"),a=o.join("/"),r=e.find(l=>l.provider===s&&l.id===a);r&&i.unshift({key:t,id:r.id,shortName:r.name,description:s})}return i}const zb=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function qb(e){var s;const t=e.currentTarget,n=(s=t.closest(".chat-model-bar"))==null?void 0:s.querySelector(".chat-settings-menu");if(!n)return;const i=n.classList.contains("active");if(document.querySelectorAll(".chat-settings-menu.active").forEach(o=>o.classList.remove("active")),!i){n.classList.add("active");const o=a=>{!n.contains(a.target)&&a.target!==t&&!t.contains(a.target)&&(n.classList.remove("active"),document.removeEventListener("click",o))};requestAnimationFrame(()=>document.addEventListener("click",o))}}function Hb(e){if(!e.connected)return w;const t=e.modelCatalog??[],n=e.modelProvider&&e.model?`${e.modelProvider}/${e.model}`:null,i=Kb(t,n);if(i.length===0)return w;const s=e.thinkingLevel??"off",o=e.verboseLevel==="on"||e.verboseLevel==="full",a=e.fillerEnabled===!0;return u`
3052
+ `}const Gb=[{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 Vb(e,t){const n=new Set(e.filter(s=>s.provider==="anthropic").map(s=>s.id)),i=Gb.filter(s=>n.has(s.id)).map(s=>({key:`anthropic/${s.id}`,...s}));if(t&&!i.some(s=>s.key===t)){const[s,...o]=t.split("/"),a=o.join("/"),r=e.find(c=>c.provider===s&&c.id===a);r&&i.unshift({key:t,id:r.id,shortName:r.name,description:s})}return i}const Qb=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function Jb(e){var s;const t=e.currentTarget,n=(s=t.closest(".chat-model-bar"))==null?void 0:s.querySelector(".chat-settings-menu");if(!n)return;const i=n.classList.contains("active");if(document.querySelectorAll(".chat-settings-menu.active").forEach(o=>o.classList.remove("active")),!i){n.classList.add("active");const o=a=>{!n.contains(a.target)&&a.target!==t&&!t.contains(a.target)&&(n.classList.remove("active"),document.removeEventListener("click",o))};requestAnimationFrame(()=>document.addEventListener("click",o))}}function Yb(e){if(!e.connected)return w;const t=e.modelCatalog??[],n=e.modelProvider&&e.model?`${e.modelProvider}/${e.model}`:null,i=Vb(t,n);if(i.length===0)return w;const s=e.thinkingLevel??"off",o=e.verboseLevel==="on"||e.verboseLevel==="full",a=e.fillerEnabled===!0;return u`
3053
3053
  <div class="chat-model-bar">
3054
3054
  <div class="chat-model-bar__select">
3055
3055
  <select
3056
3056
  class="chat-model-bar__dropdown"
3057
3057
  .value=${n??""}
3058
- @change=${r=>{const l=r.target.value;l&&e.onModelChange&&e.onModelChange(l)}}
3058
+ @change=${r=>{const c=r.target.value;c&&e.onModelChange&&e.onModelChange(c)}}
3059
3059
  >
3060
3060
  ${i.map(r=>u`
3061
3061
  <option value=${r.key} ?selected=${r.key===n}>
@@ -3068,9 +3068,9 @@ ${e.sidebarContent}
3068
3068
  <select
3069
3069
  class="chat-model-bar__dropdown"
3070
3070
  .value=${s}
3071
- @change=${r=>{const l=r.target.value;e.onThinkingLevelChange&&e.onThinkingLevelChange(l)}}
3071
+ @change=${r=>{const c=r.target.value;e.onThinkingLevelChange&&e.onThinkingLevelChange(c)}}
3072
3072
  >
3073
- ${zb.map(r=>u`
3073
+ ${Qb.map(r=>u`
3074
3074
  <option value=${r.value} ?selected=${r.value===s}>
3075
3075
  Thinking: ${r.label}
3076
3076
  </option>
@@ -3080,7 +3080,7 @@ ${e.sidebarContent}
3080
3080
  <button
3081
3081
  class="chat-model-bar__settings-btn"
3082
3082
  type="button"
3083
- @click=${qb}
3083
+ @click=${Jb}
3084
3084
  aria-label="Message settings"
3085
3085
  title="Message settings"
3086
3086
  >
@@ -3091,7 +3091,7 @@ ${e.sidebarContent}
3091
3091
  <input
3092
3092
  type="checkbox"
3093
3093
  .checked=${o}
3094
- @change=${r=>{const l=r.target.checked;e.onVerboseChange&&e.onVerboseChange(l?"on":"off")}}
3094
+ @change=${r=>{const c=r.target.checked;e.onVerboseChange&&e.onVerboseChange(c?"on":"off")}}
3095
3095
  />
3096
3096
  <span>Verbose</span>
3097
3097
  <span class="chat-settings-menu__hint">Detailed responses</span>
@@ -3100,16 +3100,16 @@ ${e.sidebarContent}
3100
3100
  <input
3101
3101
  type="checkbox"
3102
3102
  .checked=${a}
3103
- @change=${r=>{const l=r.target.checked;e.onFillerChange&&e.onFillerChange(l)}}
3103
+ @change=${r=>{const c=r.target.checked;e.onFillerChange&&e.onFillerChange(c)}}
3104
3104
  />
3105
3105
  <span>Filler</span>
3106
3106
  <span class="chat-settings-menu__hint">Quick acks while thinking</span>
3107
3107
  </label>
3108
3108
  </div>
3109
3109
  </div>
3110
- `}function jb(e){const t=[];let n=null;for(const i of e){if(i.kind!=="message"){n&&(t.push(n),n=null),t.push(i);continue}const s=Yl(i.message),o=Xl(s.role),a=s.timestamp||Date.now();!n||n.role!==o?(n&&t.push(n),n={kind:"group",key:`group:${o}:${i.key}`,role:o,messages:[{message:i.message,key:i.key}],timestamp:a,isStreaming:!1}):n.messages.push({message:i.message,key:i.key})}return n&&t.push(n),t}function Gb(e){var o;const t=[],n=Array.isArray(e.messages)?e.messages:[],i=Array.isArray(e.toolMessages)?e.toolMessages:[],s=e.showThinking||e.verboseLevel==="on"||e.verboseLevel==="full";for(let a=0;a<n.length;a++){const r=n[a],l=Yl(r);if(!s&&l.role.toLowerCase()==="toolresult"){const c=r,d=(Array.isArray(c.content)?c.content:[]).filter(p=>{const g=p.type;return g==="image"||g==="file"});d.length>0&&t.push({kind:"message",key:ro(r,a),message:{role:"assistant",content:d,timestamp:l.timestamp}});continue}t.push({kind:"message",key:ro(r,a),message:r})}if(s)for(let a=0;a<i.length;a++)t.push({kind:"message",key:ro(i[a],a+n.length),message:i[a]});if(e.interimText&&t.push({kind:"interim",key:"interim:thinking",text:e.interimText}),e.stream!==null){const a=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:a,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:a})}for(const a of e.queue){const r=((o=a.attachments)==null?void 0:o.filter(c=>c.fileName).map(c=>c.fileName))??[],l=r.length>0?a.text?`${r.join(", ")}
3110
+ `}function Xb(e){const t=[];let n=null;for(const i of e){if(i.kind!=="message"){n&&(t.push(n),n=null),t.push(i);continue}const s=tc(i.message),o=nc(s.role),a=s.timestamp||Date.now();!n||n.role!==o?(n&&t.push(n),n={kind:"group",key:`group:${o}:${i.key}`,role:o,messages:[{message:i.message,key:i.key}],timestamp:a,isStreaming:!1}):n.messages.push({message:i.message,key:i.key})}return n&&t.push(n),t}function Zb(e){var o;const t=[],n=Array.isArray(e.messages)?e.messages:[],i=Array.isArray(e.toolMessages)?e.toolMessages:[],s=e.showThinking||e.verboseLevel==="on"||e.verboseLevel==="full";for(let a=0;a<n.length;a++){const r=n[a],c=tc(r);if(!s&&c.role.toLowerCase()==="toolresult"){const d=r,l=(Array.isArray(d.content)?d.content:[]).filter(p=>{const g=p.type;return g==="image"||g==="file"});l.length>0&&t.push({kind:"message",key:lo(r,a),message:{role:"assistant",content:l,timestamp:c.timestamp}});continue}t.push({kind:"message",key:lo(r,a),message:r})}if(s)for(let a=0;a<i.length;a++)t.push({kind:"message",key:lo(i[a],a+n.length),message:i[a]});if(e.interimText&&t.push({kind:"interim",key:"interim:thinking",text:e.interimText}),e.stream!==null){const a=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:a,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:a})}for(const a of e.queue){const r=((o=a.attachments)==null?void 0:o.filter(d=>d.fileName).map(d=>d.fileName))??[],c=r.length>0?a.text?`${r.join(", ")}
3111
3111
 
3112
- ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,message:{role:"user",content:[{type:"text",text:l}],timestamp:a.createdAt}})}return jb(t)}function ro(e,t){const n=e,i=typeof n.toolCallId=="string"?n.toolCallId:"";if(i)return`tool:${i}`;const s=typeof n.id=="string"?n.id:"";if(s)return`msg:${s}`;const o=typeof n.messageId=="string"?n.messageId:"";if(o)return`msg:${o}`;const a=typeof n.timestamp=="number"?n.timestamp:null,r=typeof n.role=="string"?n.role:"unknown";return a!=null?`msg:${r}:${a}:${t}`:`msg:${r}:${t}`}const Vb=u`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>`;function Qb(e){if(!e.connected)return u`
3112
+ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,message:{role:"user",content:[{type:"text",text:c}],timestamp:a.createdAt}})}return Xb(t)}function lo(e,t){const n=e,i=typeof n.toolCallId=="string"?n.toolCallId:"";if(i)return`tool:${i}`;const s=typeof n.id=="string"?n.id:"";if(s)return`msg:${s}`;const o=typeof n.messageId=="string"?n.messageId:"";if(o)return`msg:${o}`;const a=typeof n.timestamp=="number"?n.timestamp:null,r=typeof n.role=="string"?n.role:"unknown";return a!=null?`msg:${r}:${a}:${t}`:`msg:${r}:${t}`}const ew=u`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>`;function tw(e){if(!e.connected)return u`
3113
3113
  <div class="setup-container">
3114
3114
  <div class="setup-card">
3115
3115
  <div class="setup-spinner"></div>
@@ -3122,21 +3122,21 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3122
3122
  target="_blank"
3123
3123
  rel="noopener"
3124
3124
  title="Open public chat in new tab"
3125
- >Public ${Vb}</a>`:w;return u`
3125
+ >Public ${ew}</a>`:w;return u`
3126
3126
  <div class="setup-container setup-container--full chat-page">
3127
3127
  ${Rt("Chat",e.wsProps)}
3128
3128
  ${t}
3129
3129
  <div class="chat-viewport">
3130
- ${au(e)}
3130
+ ${du(e)}
3131
3131
  </div>
3132
3132
  </div>
3133
- `}function Jb(e){return e?`${Gl(e)} (${ss(e)})`:"n/a"}function ru(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?ss(t.lastRunAtMs):"never";return`${n} · last ${i}`}function lu(e){const t=e.schedule;return t.kind==="at"?`One-time: ${Gl(t.atMs)}`:t.kind==="every"?`Every ${Jo(t.everyMs)}`:Yb(t.expr,t.tz)}function Yb(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,o,a,r]=n,l=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",c=(S,T)=>new Date(2e3,0,1,S,T).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),h=/^\d{1,2}$/.test(i)?parseInt(i,10):null,d=gl(s);if(h===null||!d)return`${e}${t?` (${t})`:""}`;const p=d.map(S=>c(S,h)),g=p.length<=3?p.join(" & "):`${p.slice(0,-1).join(", ")} & ${p[p.length-1]}`,$=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(o==="*"&&a==="*"){if(r==="*")return`Daily at ${g}${l}`;if(r==="1-5")return`Weekdays at ${g}${l}`;if(r==="0,6"||r==="6,0")return`Weekends at ${g}${l}`;const S=gl(r);if(S)return`${S.map(f=>$[f%7]??String(f)).join(", ")} at ${g}${l}`}return`${e}${t?` (${t})`:""}`}function gl(e){if(e==="*")return null;if(/^\d+(,\d+)*$/.test(e))return e.split(",").map(Number);if(/^\d+-\d+$/.test(e)){const[t,n]=e.split("-").map(Number);if(t>n)return null;const i=[];for(let s=t;s<=n;s++)i.push(s);return i}return null}function Xb(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 ml(e){const t=e.payload;if(t.kind!=="agentTurn")return null;const n=t.channel??t.provider,i=t.to;if(!i&&!n)return null;const s=[];if(i){const a=i.split(",").map(r=>r.trim()).filter(Boolean).map(r=>r.toLowerCase()==="admins"?"All admins":r);s.push(a.join(", "))}return n&&n!=="last"&&s.push(`via ${n}`),s.join(" ")||null}let we=null;function Zb(e){var s;const t=["last",...e.channels.filter(Boolean)],n=(s=e.form.channel)==null?void 0:s.trim();n&&!t.includes(n)&&t.push(n);const i=new Set;return t.filter(o=>i.has(o)?!1:(i.add(o),!0))}function ew(e,t){var i,s;if(t==="last")return"last";const n=(i=e.channelMeta)==null?void 0:i.find(o=>o.id===t);return n!=null&&n.label?n.label:((s=e.channelLabels)==null?void 0:s[t])??t}function tw(e){return e.split(",").map(n=>n.trim()).filter(Boolean).map(n=>n.toLowerCase()==="admins"?"All admins":n).join(", ")}function nw(e){return e||"Default"}const iw=u`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,sw=u`<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>`,ow=u`<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>`,hs=u`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,aw=u`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,cu=u`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`,rw=u`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`;function yl(e){const t=e.detailJobId?e.jobs.find(i=>i.id===e.detailJobId)??null:null,n=e.newEventModalOpen||!!e.editJobId;return u`
3134
- ${lw(e)}
3135
- ${cw(e)}
3136
- ${n?uw(e):w}
3137
- ${t?fw(t,e):w}
3138
- ${e.runModalJobId?gw(e):w}
3139
- `}function lw(e){const t=e.status,n=(t==null?void 0:t.enabled)??!1,i=(t==null?void 0:t.jobs)??0,s=t==null?void 0:t.nextWakeAtMs;return u`
3133
+ `}function nw(e){return e?`${Yl(e)} (${os(e)})`:"n/a"}function uu(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?os(t.lastRunAtMs):"never";return`${n} · last ${i}`}function pu(e){const t=e.schedule;return t.kind==="at"?`One-time: ${Yl(t.atMs)}`:t.kind==="every"?`Every ${Yo(t.everyMs)}`:iw(t.expr,t.tz)}function iw(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,o,a,r]=n,c=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",d=(S,T)=>new Date(2e3,0,1,S,T).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),h=/^\d{1,2}$/.test(i)?parseInt(i,10):null,l=vl(s);if(h===null||!l)return`${e}${t?` (${t})`:""}`;const p=l.map(S=>d(S,h)),g=p.length<=3?p.join(" & "):`${p.slice(0,-1).join(", ")} & ${p[p.length-1]}`,$=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(o==="*"&&a==="*"){if(r==="*")return`Daily at ${g}${c}`;if(r==="1-5")return`Weekdays at ${g}${c}`;if(r==="0,6"||r==="6,0")return`Weekends at ${g}${c}`;const S=vl(r);if(S)return`${S.map(f=>$[f%7]??String(f)).join(", ")} at ${g}${c}`}return`${e}${t?` (${t})`:""}`}function vl(e){if(e==="*")return null;if(/^\d+(,\d+)*$/.test(e))return e.split(",").map(Number);if(/^\d+-\d+$/.test(e)){const[t,n]=e.split("-").map(Number);if(t>n)return null;const i=[];for(let s=t;s<=n;s++)i.push(s);return i}return null}function sw(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 bl(e){const t=e.payload;if(t.kind!=="agentTurn")return null;const n=t.channel??t.provider,i=t.to;if(!i&&!n)return null;const s=[];if(i){const a=i.split(",").map(r=>r.trim()).filter(Boolean).map(r=>r.toLowerCase()==="admins"?"All admins":r);s.push(a.join(", "))}return n&&n!=="last"&&s.push(`via ${n}`),s.join(" ")||null}let we=null;function ow(e){var s;const t=["last",...e.channels.filter(Boolean)],n=(s=e.form.channel)==null?void 0:s.trim();n&&!t.includes(n)&&t.push(n);const i=new Set;return t.filter(o=>i.has(o)?!1:(i.add(o),!0))}function aw(e,t){var i,s;if(t==="last")return"last";const n=(i=e.channelMeta)==null?void 0:i.find(o=>o.id===t);return n!=null&&n.label?n.label:((s=e.channelLabels)==null?void 0:s[t])??t}function rw(e){return e.split(",").map(n=>n.trim()).filter(Boolean).map(n=>n.toLowerCase()==="admins"?"All admins":n).join(", ")}function lw(e){return e||"Default"}const cw=u`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,dw=u`<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>`,uw=u`<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>`,fs=u`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,pw=u`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,hu=u`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`,hw=u`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`;function wl(e){const t=e.detailJobId?e.jobs.find(i=>i.id===e.detailJobId)??null:null,n=e.newEventModalOpen||!!e.editJobId;return u`
3134
+ ${fw(e)}
3135
+ ${gw(e)}
3136
+ ${n?yw(e):w}
3137
+ ${t?ww(t,e):w}
3138
+ ${e.runModalJobId?kw(e):w}
3139
+ `}function fw(e){const t=e.status,n=(t==null?void 0:t.enabled)??!1,i=(t==null?void 0:t.jobs)??0,s=t==null?void 0:t.nextWakeAtMs;return u`
3140
3140
  <div class="event-status-bar">
3141
3141
  <div class="event-status-bar__info">
3142
3142
  <span class="statusDot ${n?"ok":""}"></span>
@@ -3145,7 +3145,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3145
3145
  <span>${i} event${i!==1?"s":""}</span>
3146
3146
  ${s?u`
3147
3147
  <span class="event-status-bar__sep">\u00b7</span>
3148
- <span>Next: ${ss(s)}</span>
3148
+ <span>Next: ${os(s)}</span>
3149
3149
  `:w}
3150
3150
  <button
3151
3151
  class="btn btn--sm"
@@ -3158,14 +3158,14 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3158
3158
  ${e.error?u`<span class="muted">${e.error}</span>`:w}
3159
3159
  </div>
3160
3160
  <button class="btn primary btn--sm" @click=${e.onNewEventModalOpen}>
3161
- ${cu} New Event
3161
+ ${hu} New Event
3162
3162
  </button>
3163
3163
  </div>
3164
- `}function cw(e){return e.jobs.length===0?u`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:u`
3164
+ `}function gw(e){return e.jobs.length===0?u`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:u`
3165
3165
  <div class="event-grid">
3166
- ${e.jobs.map(t=>dw(t,e))}
3166
+ ${e.jobs.map(t=>mw(t,e))}
3167
3167
  </div>
3168
- `}function dw(e,t){return u`
3168
+ `}function mw(e,t){return u`
3169
3169
  <div
3170
3170
  class="event-card ${e.enabled?"":"disabled"}"
3171
3171
  @click=${()=>t.onDetailOpen(e)}
@@ -3176,12 +3176,12 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3176
3176
  ${e.enabled?"On":"Off"}
3177
3177
  </span>
3178
3178
  </div>
3179
- <div class="event-card__schedule">${lu(e)}</div>
3180
- ${e.agentId?u`<div class="event-card__agent">${nw(e.agentId)}</div>`:w}
3181
- ${ml(e)?u`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${ml(e)}</div>`:w}
3179
+ <div class="event-card__schedule">${pu(e)}</div>
3180
+ ${e.agentId?u`<div class="event-card__agent">${lw(e.agentId)}</div>`:w}
3181
+ ${bl(e)?u`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${bl(e)}</div>`:w}
3182
3182
  <div class="event-card__footer">
3183
3183
  <div class="event-card__status">
3184
- <span class="muted" style="font-size: 11px;">${ru(e)}</span>
3184
+ <span class="muted" style="font-size: 11px;">${uu(e)}</span>
3185
3185
  </div>
3186
3186
  <div class="event-card__actions" @click=${n=>n.stopPropagation()}>
3187
3187
  <button
@@ -3190,7 +3190,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3190
3190
  ?disabled=${t.busy}
3191
3191
  @click=${()=>t.onToggle(e,!e.enabled)}
3192
3192
  >
3193
- ${e.enabled?sw:iw}
3193
+ ${e.enabled?dw:cw}
3194
3194
  </button>
3195
3195
  <button
3196
3196
  class="btn-icon"
@@ -3198,7 +3198,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3198
3198
  ?disabled=${t.busy}
3199
3199
  @click=${()=>t.onRun(e)}
3200
3200
  >
3201
- ${aw}
3201
+ ${pw}
3202
3202
  </button>
3203
3203
  ${t.pendingDeleteId===e.id?u`<button
3204
3204
  class="btn danger btn--sm"
@@ -3209,17 +3209,17 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3209
3209
  title="Delete"
3210
3210
  ?disabled=${t.busy}
3211
3211
  @click=${()=>{t.onArmDelete(e.id),we&&clearTimeout(we),we=setTimeout(()=>{t.onArmDelete(""),we=null},3e3)}}
3212
- >${ow}</button>`}
3212
+ >${uw}</button>`}
3213
3213
  </div>
3214
3214
  </div>
3215
3215
  </div>
3216
- `}function uw(e){const t=!!e.editJobId,n=Zb(e),i=()=>{e.onNewEventModalClose()};return u`
3216
+ `}function yw(e){const t=!!e.editJobId,n=ow(e),i=()=>{e.onNewEventModalClose()};return u`
3217
3217
  <div class="event-modal-overlay" @click=${i}>
3218
3218
  <div class="event-modal" @click=${s=>s.stopPropagation()}>
3219
3219
  <div class="event-modal__header">
3220
3220
  <div class="event-modal__title">${t?"Edit Event":"New Event"}</div>
3221
3221
  <button class="event-modal__close" @click=${i}>
3222
- ${hs}
3222
+ ${fs}
3223
3223
  </button>
3224
3224
  </div>
3225
3225
 
@@ -3271,7 +3271,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3271
3271
  </label>
3272
3272
  </div>
3273
3273
 
3274
- ${hw(e)}
3274
+ ${bw(e)}
3275
3275
 
3276
3276
  <div class="form-grid" style="margin-top: 12px;">
3277
3277
  <label class="field">
@@ -3333,7 +3333,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3333
3333
  @change=${s=>e.onFormChange({channel:s.target.value})}
3334
3334
  >
3335
3335
  ${n.map(s=>u`<option value=${s}>
3336
- ${ew(e,s)}
3336
+ ${aw(e,s)}
3337
3337
  </option>`)}
3338
3338
  </select>
3339
3339
  </label>
@@ -3346,7 +3346,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3346
3346
  />
3347
3347
  </label>
3348
3348
  </div>
3349
- ${pw(e)}
3349
+ ${vw(e)}
3350
3350
  <div class="form-grid" style="margin-top: 12px;">
3351
3351
  <label class="field">
3352
3352
  <span>Timeout (seconds)</span>
@@ -3377,7 +3377,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3377
3377
  </div>
3378
3378
  </div>
3379
3379
  </div>
3380
- `}function pw(e){const t=e.form.recipients;return u`
3380
+ `}function vw(e){const t=e.form.recipients;return u`
3381
3381
  <div style="margin-top: 8px;">
3382
3382
  <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
3383
3383
  <span style="font-size: 13px; color: var(--muted);">Recipients</span>
@@ -3385,7 +3385,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3385
3385
  class="btn btn--sm"
3386
3386
  @click=${()=>{e.onFormChange({recipients:[...t,""]})}}
3387
3387
  >
3388
- ${cu} Add
3388
+ ${hu} Add
3389
3389
  </button>
3390
3390
  </div>
3391
3391
  ${t.length===0&&!e.form.toAdmins?u`<div class="muted" style="font-size: 12px; padding: 4px 0;">No recipients. Add a phone number or enable "All admins".</div>`:w}
@@ -3402,12 +3402,12 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3402
3402
  title="Remove"
3403
3403
  @click=${()=>{const s=t.filter((o,a)=>a!==i);e.onFormChange({recipients:s})}}
3404
3404
  >
3405
- ${hs}
3405
+ ${fs}
3406
3406
  </button>
3407
3407
  </div>
3408
3408
  `)}
3409
3409
  </div>
3410
- `}function hw(e){const t=e.form;return t.scheduleKind==="at"?u`
3410
+ `}function bw(e){const t=e.form;return t.scheduleKind==="at"?u`
3411
3411
  <label class="field" style="margin-top: 12px;">
3412
3412
  <span>Run at</span>
3413
3413
  <input
@@ -3456,13 +3456,13 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3456
3456
  />
3457
3457
  </label>
3458
3458
  </div>
3459
- `}function fw(e,t){var n;return u`
3459
+ `}function ww(e,t){var n;return u`
3460
3460
  <div class="event-modal-overlay" @click=${t.onDetailClose}>
3461
3461
  <div class="event-modal" @click=${i=>i.stopPropagation()}>
3462
3462
  <div class="event-modal__header">
3463
3463
  <div class="event-modal__title">${e.name||"Untitled Event"}</div>
3464
3464
  <button class="event-modal__close" @click=${t.onDetailClose}>
3465
- ${hs}
3465
+ ${fs}
3466
3466
  </button>
3467
3467
  </div>
3468
3468
 
@@ -3474,7 +3474,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3474
3474
  ?disabled=${t.busy}
3475
3475
  @click=${()=>t.onEdit(e)}
3476
3476
  >
3477
- ${rw} Edit
3477
+ ${hw} Edit
3478
3478
  </button>
3479
3479
  <button
3480
3480
  class="btn"
@@ -3510,7 +3510,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3510
3510
  </div>
3511
3511
  <div class="event-detail-row">
3512
3512
  <span class="event-detail-label">Schedule</span>
3513
- <span class="event-detail-value">${lu(e)}</span>
3513
+ <span class="event-detail-value">${pu(e)}</span>
3514
3514
  </div>
3515
3515
  ${e.agentId?u`
3516
3516
  <div class="event-detail-row">
@@ -3532,12 +3532,12 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3532
3532
  </div>
3533
3533
  <div class="event-detail-row" style="flex-direction: column; align-items: stretch; gap: 4px;">
3534
3534
  <span class="event-detail-label">Action</span>
3535
- <span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${Xb(e,!1)}</span>
3535
+ <span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${sw(e,!1)}</span>
3536
3536
  </div>
3537
3537
  ${e.payload.kind==="agentTurn"&&e.payload.to?u`
3538
3538
  <div class="event-detail-row">
3539
3539
  <span class="event-detail-label">Send to</span>
3540
- <span class="event-detail-value mono">${tw(e.payload.to)}</span>
3540
+ <span class="event-detail-value mono">${rw(e.payload.to)}</span>
3541
3541
  </div>
3542
3542
  `:w}
3543
3543
  ${e.payload.kind==="agentTurn"&&(e.payload.channel??e.payload.provider)?u`
@@ -3557,12 +3557,12 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3557
3557
  <div class="event-detail-section">
3558
3558
  <div class="event-detail-row">
3559
3559
  <span class="event-detail-label">Last run</span>
3560
- <span class="event-detail-value">${ru(e)}</span>
3560
+ <span class="event-detail-value">${uu(e)}</span>
3561
3561
  </div>
3562
3562
  ${(n=e.state)!=null&&n.nextRunAtMs?u`
3563
3563
  <div class="event-detail-row">
3564
3564
  <span class="event-detail-label">Next run</span>
3565
- <span class="event-detail-value">${Jb(e.state.nextRunAtMs)}</span>
3565
+ <span class="event-detail-value">${nw(e.state.nextRunAtMs)}</span>
3566
3566
  </div>
3567
3567
  `:w}
3568
3568
  </div>
@@ -3573,20 +3573,20 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3573
3573
  </div>
3574
3574
  ${t.runs.length===0?u`<div class="muted" style="font-size: 13px;">No runs recorded yet.</div>`:u`
3575
3575
  <div class="list">
3576
- ${[...t.runs].sort((i,s)=>s.ts-i.ts).map(i=>yw(i))}
3576
+ ${[...t.runs].sort((i,s)=>s.ts-i.ts).map(i=>$w(i))}
3577
3577
  </div>
3578
3578
  `}
3579
3579
  </div>
3580
3580
 
3581
3581
  </div>
3582
3582
  </div>
3583
- `}function gw(e){const t=e.runResult,n=!t,i=(t==null?void 0:t.status)==="ok"?"Completed":(t==null?void 0:t.status)==="error"?"Error":(t==null?void 0:t.status)??"";return u`
3583
+ `}function kw(e){const t=e.runResult,n=!t,i=(t==null?void 0:t.status)==="ok"?"Completed":(t==null?void 0:t.status)==="error"?"Error":(t==null?void 0:t.status)??"";return u`
3584
3584
  <div class="event-modal-overlay" @click=${e.onRunModalClose}>
3585
3585
  <div class="event-modal" style="max-width: 480px;" @click=${s=>s.stopPropagation()}>
3586
3586
  <div class="event-modal__header">
3587
3587
  <div class="event-modal__title">${e.runModalJobName}</div>
3588
3588
  <button class="event-modal__close" @click=${e.onRunModalClose}>
3589
- ${hs}
3589
+ ${fs}
3590
3590
  </button>
3591
3591
  </div>
3592
3592
 
@@ -3606,7 +3606,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3606
3606
  >
3607
3607
  ${i}
3608
3608
  </span>
3609
- ${t.durationMs!=null?u`<span class="muted" style="font-size: 13px;">${Jo(t.durationMs)}</span>`:w}
3609
+ ${t.durationMs!=null?u`<span class="muted" style="font-size: 13px;">${Yo(t.durationMs)}</span>`:w}
3610
3610
  </div>
3611
3611
  ${t.summary?u`
3612
3612
  <div style="white-space: pre-wrap; font-size: 13px; line-height: 1.6; max-height: 400px; overflow-y: auto; color: var(--fg);">
@@ -3627,14 +3627,14 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3627
3627
  `}
3628
3628
  </div>
3629
3629
  </div>
3630
- `}function mw(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"?"chip chip-warn":"chip"}function yw(e){return u`
3630
+ `}function xw(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"?"chip chip-warn":"chip"}function $w(e){return u`
3631
3631
  <div class="list-item" style="grid-template-columns: 1fr; gap: 6px;">
3632
3632
  <div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
3633
- <span class=${mw(e.status)} style="font-size: 11px; padding: 2px 8px;">
3633
+ <span class=${xw(e.status)} style="font-size: 11px; padding: 2px 8px;">
3634
3634
  ${e.status}
3635
3635
  </span>
3636
- <span class="muted" style="font-size: 12px;">${ss(e.ts)}</span>
3637
- <span class="muted" style="font-size: 12px;">${Jo(e.durationMs)}</span>
3636
+ <span class="muted" style="font-size: 12px;">${os(e.ts)}</span>
3637
+ <span class="muted" style="font-size: 12px;">${Yo(e.durationMs)}</span>
3638
3638
  </div>
3639
3639
  ${e.summary?u`<div class="muted" style="font-size: 12px;">${e.summary}</div>`:w}
3640
3640
  ${e.error?u`
@@ -3644,11 +3644,11 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3644
3644
  </details>
3645
3645
  `:w}
3646
3646
  </div>
3647
- `}function vw(e){var a;const t=((a=e.report)==null?void 0:a.skills)??[],n=e.filter.trim().toLowerCase(),i=e.typeFilter,s=t.filter(r=>i==="preloaded"&&!r.preloaded||i==="user"&&r.preloaded?!1:n?[r.name,r.description].join(" ").toLowerCase().includes(n):!0),o=(r,l)=>u`
3647
+ `}function Sw(e){var a;const t=((a=e.report)==null?void 0:a.skills)??[],n=e.filter.trim().toLowerCase(),i=e.typeFilter,s=t.filter(r=>i==="preloaded"&&!r.preloaded||i==="user"&&r.preloaded?!1:n?[r.name,r.description].join(" ").toLowerCase().includes(n):!0),o=(r,c)=>u`
3648
3648
  <button
3649
- class="chip ${i===l?"chip-ok":""}"
3650
- style="cursor: pointer; border: none; background: ${i===l?"var(--accent, #3b82f6)":"var(--bg-hover, rgba(255,255,255,0.06))"}; color: ${i===l?"#fff":"var(--text)"}; padding: 4px 10px; border-radius: 4px; font-size: 12px;"
3651
- @click=${()=>e.onTypeFilterChange(l)}
3649
+ class="chip ${i===c?"chip-ok":""}"
3650
+ style="cursor: pointer; border: none; background: ${i===c?"var(--accent, #3b82f6)":"var(--bg-hover, rgba(255,255,255,0.06))"}; color: ${i===c?"#fff":"var(--text)"}; padding: 4px 10px; border-radius: 4px; font-size: 12px;"
3651
+ @click=${()=>e.onTypeFilterChange(c)}
3652
3652
  >${r}</button>
3653
3653
  `;return u`
3654
3654
  <section class="card">
@@ -3686,20 +3686,20 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3686
3686
 
3687
3687
  ${s.length===0?u`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:u`
3688
3688
  <div class="list" style="margin-top: 16px;">
3689
- ${s.map(r=>bw(r,e))}
3689
+ ${s.map(r=>Aw(r,e))}
3690
3690
  </div>
3691
3691
  `}
3692
3692
  </section>
3693
3693
 
3694
- ${e.detail?ww(e):w}
3695
- ${e.addModal?kw(e):w}
3696
- `}function bw(e,t){const n=t.busyKey===e.skillKey,i=t.edits[e.skillKey]??"",s=t.messages[e.skillKey]??null,o=e.install.length>0&&e.missing.bins.length>0,a=[...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}`)],r=[];return e.disabled&&r.push("disabled"),e.blockedByAllowlist&&r.push("blocked by allowlist"),u`
3694
+ ${e.detail?Cw(e):w}
3695
+ ${e.addModal?Ew(e):w}
3696
+ `}function Aw(e,t){const n=t.busyKey===e.skillKey,i=t.edits[e.skillKey]??"",s=t.messages[e.skillKey]??null,o=e.install.length>0&&e.missing.bins.length>0,a=[...e.missing.bins.map(c=>`bin:${c}`),...e.missing.env.map(c=>`env:${c}`),...e.missing.config.map(c=>`config:${c}`),...e.missing.os.map(c=>`os:${c}`)],r=[];return e.disabled&&r.push("disabled"),e.blockedByAllowlist&&r.push("blocked by allowlist"),u`
3697
3697
  <div class="list-item" style="cursor: pointer;" @click=${()=>t.onViewDetail(e.name)}>
3698
3698
  <div class="list-main">
3699
3699
  <div class="list-title">
3700
3700
  ${e.emoji?`${e.emoji} `:""}${e.name}
3701
3701
  </div>
3702
- <div class="list-sub">${Cp(e.description,140)}</div>
3702
+ <div class="list-sub">${Ip(e.description,140)}</div>
3703
3703
  <div class="chip-row" style="margin-top: 6px;">
3704
3704
  <span class="chip ${e.preloaded?"chip-ok":""}">
3705
3705
  ${e.preloaded?"Preloaded":"User"}
@@ -3717,7 +3717,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3717
3717
  </div>
3718
3718
  `:w}
3719
3719
  </div>
3720
- <div class="list-meta" @click=${l=>l.stopPropagation()}>
3720
+ <div class="list-meta" @click=${c=>c.stopPropagation()}>
3721
3721
  <div class="row" style="justify-content: flex-end; flex-wrap: wrap; gap: 6px;">
3722
3722
  ${e.preloaded?w:u`<button
3723
3723
  class="btn"
@@ -3760,7 +3760,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3760
3760
  <input
3761
3761
  type="password"
3762
3762
  .value=${i}
3763
- @input=${l=>t.onEdit(e.skillKey,l.target.value)}
3763
+ @input=${c=>t.onEdit(e.skillKey,c.target.value)}
3764
3764
  />
3765
3765
  </div>
3766
3766
  <button
@@ -3774,9 +3774,9 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3774
3774
  `:w}
3775
3775
  </div>
3776
3776
  </div>
3777
- `}function ww(e){var l,c,h;const t=e.detail,n=["SKILL.md",...t.references.map(d=>d.name)],i=e.detailTab||"SKILL.md",s=i==="SKILL.md"?t.content:((l=t.references.find(d=>d.name===i))==null?void 0:l.content)??"",o=d=>{d.target.classList.contains("event-modal-overlay")&&e.onDetailClose()},a=(h=(c=e.report)==null?void 0:c.skills)==null?void 0:h.find(d=>d.name===t.name),r=a?!a.preloaded:!1;return u`
3777
+ `}function Cw(e){var c,d,h;const t=e.detail,n=["SKILL.md",...t.references.map(l=>l.name)],i=e.detailTab||"SKILL.md",s=i==="SKILL.md"?t.content:((c=t.references.find(l=>l.name===i))==null?void 0:c.content)??"",o=l=>{l.target.classList.contains("event-modal-overlay")&&e.onDetailClose()},a=(h=(d=e.report)==null?void 0:d.skills)==null?void 0:h.find(l=>l.name===t.name),r=a?!a.preloaded:!1;return u`
3778
3778
  <div class="event-modal-overlay" @click=${o}>
3779
- <div class="event-modal" style="width: min(720px, 100%);" @click=${d=>d.stopPropagation()}>
3779
+ <div class="event-modal" style="width: min(720px, 100%);" @click=${l=>l.stopPropagation()}>
3780
3780
  <div class="event-modal__header">
3781
3781
  <div class="event-modal__title">${t.name}</div>
3782
3782
  <div class="row" style="gap: 8px;">
@@ -3786,13 +3786,13 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3786
3786
  </div>
3787
3787
  ${n.length>1?u`
3788
3788
  <div class="chip-row" style="margin-bottom: 12px; flex-wrap: wrap;">
3789
- ${n.map(d=>u`
3789
+ ${n.map(l=>u`
3790
3790
  <button
3791
- class="chip ${d===i?"chip-ok":""}"
3792
- style="cursor: pointer; border: none; background: ${d===i?"var(--accent, #3b82f6)":"var(--bg-hover, rgba(255,255,255,0.06))"}; color: ${d===i?"#fff":"var(--text)"}; padding: 4px 10px; border-radius: 4px; font-size: 12px;"
3793
- @click=${()=>e.onDetailTab(d)}
3791
+ class="chip ${l===i?"chip-ok":""}"
3792
+ style="cursor: pointer; border: none; background: ${l===i?"var(--accent, #3b82f6)":"var(--bg-hover, rgba(255,255,255,0.06))"}; color: ${l===i?"#fff":"var(--text)"}; padding: 4px 10px; border-radius: 4px; font-size: 12px;"
3793
+ @click=${()=>e.onDetailTab(l)}
3794
3794
  >
3795
- ${d}
3795
+ ${l}
3796
3796
  </button>
3797
3797
  `)}
3798
3798
  </div>
@@ -3800,7 +3800,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3800
3800
  <pre style="white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.5; max-height: 60vh; overflow-y: auto; background: var(--bg, #111); padding: 16px; border-radius: 8px; border: 1px solid var(--border);">${s}</pre>
3801
3801
  </div>
3802
3802
  </div>
3803
- `}function kw(e){const t=e.drafts.length>0,n=e.busyKey==="__add__",i=e.addForm.name.trim()!=="",s=e.formSource==="installed",o=r=>{r.target.classList.contains("event-modal-overlay")&&e.onAddClose()},a=i?s?`Edit Skill: ${e.addForm.name}`:`Edit Draft: ${e.addForm.name}`:"Skill Drafts";return u`
3803
+ `}function Ew(e){const t=e.drafts.length>0,n=e.busyKey==="__add__",i=e.addForm.name.trim()!=="",s=e.formSource==="installed",o=r=>{r.target.classList.contains("event-modal-overlay")&&e.onAddClose()},a=i?s?`Edit Skill: ${e.addForm.name}`:`Edit Draft: ${e.addForm.name}`:"Skill Drafts";return u`
3804
3804
  <div class="event-modal-overlay" @click=${o}>
3805
3805
  <div class="event-modal" style="width: min(620px, 100%);" @click=${r=>r.stopPropagation()}>
3806
3806
  <div class="event-modal__header">
@@ -3808,32 +3808,32 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3808
3808
  <button class="event-modal__close" @click=${e.onAddClose}>&times;</button>
3809
3809
  </div>
3810
3810
 
3811
- ${i?xw(e,n):t?$w(e,n):u`
3811
+ ${i?Tw(e,n):t?_w(e,n):u`
3812
3812
  <div class="muted" style="text-align: center; padding: 32px 16px;">
3813
3813
  No drafts available. Ask your assistant to create a skill and it will appear here.
3814
3814
  </div>
3815
3815
  `}
3816
3816
  </div>
3817
3817
  </div>
3818
- `}function xw(e,t){const n=e.addForm,s=e.formSource==="installed"?"Save Skill":"Save Draft",o=n.references.length>0,a=e.editTab||"SKILL.md",r=n.references.find(c=>c.name===a),l=c=>u`
3818
+ `}function Tw(e,t){const n=e.addForm,s=e.formSource==="installed"?"Save Skill":"Save Draft",o=n.references.length>0,a=e.editTab||"SKILL.md",r=n.references.find(d=>d.name===a),c=d=>u`
3819
3819
  <button
3820
- class="chip ${c===a?"chip-ok":""}"
3821
- style="cursor: pointer; border: none; background: ${c===a?"var(--accent, #3b82f6)":"var(--bg-hover, rgba(255,255,255,0.06))"}; color: ${c===a?"#fff":"var(--text)"}; padding: 4px 10px; border-radius: 4px; font-size: 12px;"
3822
- @click=${()=>e.onEditTab(c)}
3823
- >${c}</button>
3820
+ class="chip ${d===a?"chip-ok":""}"
3821
+ style="cursor: pointer; border: none; background: ${d===a?"var(--accent, #3b82f6)":"var(--bg-hover, rgba(255,255,255,0.06))"}; color: ${d===a?"#fff":"var(--text)"}; padding: 4px 10px; border-radius: 4px; font-size: 12px;"
3822
+ @click=${()=>e.onEditTab(d)}
3823
+ >${d}</button>
3824
3824
  `;return u`
3825
3825
  <label class="field" style="margin-bottom: 12px;">
3826
3826
  <span>Name</span>
3827
3827
  <input
3828
3828
  .value=${n.name}
3829
- @input=${c=>e.onAddFormUpdate("name",c.target.value)}
3829
+ @input=${d=>e.onAddFormUpdate("name",d.target.value)}
3830
3830
  placeholder="my-skill"
3831
3831
  />
3832
3832
  </label>
3833
3833
  ${o?u`
3834
3834
  <div class="chip-row" style="margin-bottom: 12px; flex-wrap: wrap; gap: 4px;">
3835
- ${l("SKILL.md")}
3836
- ${n.references.map(c=>l(c.name))}
3835
+ ${c("SKILL.md")}
3836
+ ${n.references.map(d=>c(d.name))}
3837
3837
  </div>
3838
3838
  `:w}
3839
3839
  ${r?u`
@@ -3841,7 +3841,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3841
3841
  <span>${r.name}</span>
3842
3842
  <textarea
3843
3843
  .value=${r.content}
3844
- @input=${c=>e.onRefUpdate(r.name,c.target.value)}
3844
+ @input=${d=>e.onRefUpdate(r.name,d.target.value)}
3845
3845
  style="min-height: 260px; font-family: monospace; font-size: 12px; line-height: 1.5; resize: vertical; overflow-wrap: break-word; white-space: pre-wrap;"
3846
3846
  ></textarea>
3847
3847
  </label>
@@ -3850,7 +3850,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3850
3850
  <span>SKILL.md</span>
3851
3851
  <textarea
3852
3852
  .value=${n.skillContent}
3853
- @input=${c=>e.onAddFormUpdate("skillContent",c.target.value)}
3853
+ @input=${d=>e.onAddFormUpdate("skillContent",d.target.value)}
3854
3854
  style="min-height: 260px; font-family: monospace; font-size: 12px; line-height: 1.5; resize: vertical; overflow-wrap: break-word; white-space: pre-wrap;"
3855
3855
  placeholder="---\nname: my-skill\ndescription: What this skill does\n---\n\n# My Skill\n..."
3856
3856
  ></textarea>
@@ -3866,7 +3866,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3866
3866
  ${t?"Saving…":s}
3867
3867
  </button>
3868
3868
  </div>
3869
- `}function $w(e,t){return u`
3869
+ `}function _w(e,t){return u`
3870
3870
  <div class="card-sub" style="margin-bottom: 16px;">
3871
3871
  Skills prepared by your assistant. Review, install, or delete.
3872
3872
  </div>
@@ -3907,7 +3907,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3907
3907
  </div>
3908
3908
  `})}
3909
3909
  </div>
3910
- `}const Sw=["user","assistant","tool_call","tool_result","thinking","error"],vl={user:"User",assistant:"Assistant",tool:"Tool",tool_call:"Call",tool_result:"Result",thinking:"Thinking",error:"Error",system:"System"};function du(e){return e==="tool"?"tool_call":e}function Aw(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 Cw(e){return e.split(":").slice(2).join(":")||e}function Ew(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName,e.toolCallId].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Tw(e,t){return`${e.sessionId}:${e.timestamp}:${t}`}const bl=300;function _w(e,t){const n=du(e);return t[n]??!0}function Mw(e){const t=e.filterText.trim().toLowerCase(),n=e.entries.filter(i=>!_w(i.type,e.typeFilters)||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:Ew(i,t));return u`
3910
+ `}const Mw=["user","assistant","tool_call","tool_result","thinking","error"],kl={user:"User",assistant:"Assistant",tool:"Tool",tool_call:"Call",tool_result:"Result",thinking:"Thinking",error:"Error",system:"System"};function fu(e){return e==="tool"?"tool_call":e}function Pw(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 Iw(e){return e.split(":").slice(2).join(":")||e}function Lw(e,t){return t?[e.content,e.agentId,e.sessionKey,e.sessionId,e.toolName,e.toolCallId].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Rw(e,t){return`${e.sessionId}:${e.timestamp}:${t}`}const xl=300;function Dw(e,t){const n=fu(e);return t[n]??!0}function Bw(e){const t=e.filterText.trim().toLowerCase(),n=e.entries.filter(i=>!Dw(i.type,e.typeFilters)||e.agents.length>0&&!(e.agentFilters[i.agentId]??!0)?!1:Lw(i,t));return u`
3911
3911
  <div>
3912
3912
  <button class="chips-toggle" style="margin-top: 10px;" @click=${e.onToggleChips}>
3913
3913
  <span class="chips-toggle-icon ${e.chipsExpanded?"expanded":""}">${L.chevronDown}</span>
@@ -3915,14 +3915,14 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3915
3915
  </button>
3916
3916
  ${e.chipsExpanded?u`
3917
3917
  <div class="chip-row" style="margin-top: 6px;">
3918
- ${Sw.map(i=>u`
3918
+ ${Mw.map(i=>u`
3919
3919
  <label class="chip session-log-chip ${i}">
3920
3920
  <input
3921
3921
  type="checkbox"
3922
3922
  .checked=${e.typeFilters[i]}
3923
3923
  @change=${s=>e.onTypeToggle(i,s.target.checked)}
3924
3924
  />
3925
- <span>${vl[i]}</span>
3925
+ <span>${kl[i]}</span>
3926
3926
  </label>
3927
3927
  `)}
3928
3928
  ${e.agents.map(i=>u`
@@ -3949,19 +3949,19 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3949
3949
  ${e.error?u`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:w}
3950
3950
 
3951
3951
  <div class="log-stream" style="margin-top: 10px;" @scroll=${e.onScroll}>
3952
- ${n.length===0?u`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map((i,s)=>{const o=du(i.type),a=Tw(i,s),r=e.expandedIds.has(a),l=i.content.length>bl,c=r||!l?i.content:i.content.slice(0,bl)+"…";return u`
3952
+ ${n.length===0?u`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map((i,s)=>{const o=fu(i.type),a=Rw(i,s),r=e.expandedIds.has(a),c=i.content.length>xl,d=r||!c?i.content:i.content.slice(0,xl)+"…";return u`
3953
3953
  <div class="log-row session-entry ${o}">
3954
3954
  <div class="log-row-header">
3955
- <span class="log-time mono">${Aw(i.timestamp)}</span>
3956
- <span class="session-log-type ${o}">${vl[o]}</span>
3955
+ <span class="log-time mono">${Pw(i.timestamp)}</span>
3956
+ <span class="session-log-type ${o}">${kl[o]}</span>
3957
3957
  <span class="log-subsystem mono">${i.agentId}</span>
3958
- <span class="session-label mono">${Cw(i.sessionKey)}</span>
3958
+ <span class="session-label mono">${Iw(i.sessionKey)}</span>
3959
3959
  ${i.toolName?u`<span class="session-tool mono">${i.toolName}</span>`:w}
3960
3960
  ${i.toolCallId?u`<span class="session-call-id mono">${i.toolCallId.slice(0,12)}</span>`:w}
3961
3961
  ${i.model?u`<span class="session-model mono">${i.model}</span>`:w}
3962
3962
  </div>
3963
- <div class="log-message mono">${c}</div>
3964
- ${l?u`<button
3963
+ <div class="log-message mono">${d}</div>
3964
+ ${c?u`<button
3965
3965
  class="log-expand-btn"
3966
3966
  @click=${()=>e.onToggleExpand(a)}
3967
3967
  >${r?"Collapse":"Expand"}</button>`:w}
@@ -3969,7 +3969,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
3969
3969
  `})}
3970
3970
  </div>
3971
3971
  </div>
3972
- `}const Uo=["trace","debug","info","warn","error","fatal"];function Pw(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function uu(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Iw(e){const t=e.logsSubTab==="session";return u`
3972
+ `}const Wo=["trace","debug","info","warn","error","fatal"];function Nw(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function gu(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Ow(e){const t=e.logsSubTab==="session";return u`
3973
3973
  <section class="card">
3974
3974
  <div class="logs-toolbar">
3975
3975
  <div class="sp-tabs" style="margin: 0;">
@@ -4018,7 +4018,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4018
4018
  <button
4019
4019
  class="btn btn-sm"
4020
4020
  ?disabled=${e.entries.length===0}
4021
- @click=${()=>{const n=e.filterText.trim().toLowerCase(),i=Uo.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:uu(a,n)),o=n||i?"filtered":"visible";e.onExport(s.map(a=>a.raw),o)}}
4021
+ @click=${()=>{const n=e.filterText.trim().toLowerCase(),i=Wo.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:gu(a,n)),o=n||i?"filtered":"visible";e.onExport(s.map(a=>a.raw),o)}}
4022
4022
  >
4023
4023
  Export
4024
4024
  </button>
@@ -4026,16 +4026,16 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4026
4026
  </div>
4027
4027
  </div>
4028
4028
 
4029
- ${t?Mw(e.sessionLogsProps):Lw(e)}
4029
+ ${t?Bw(e.sessionLogsProps):Fw(e)}
4030
4030
  </section>
4031
- `}function Lw(e){const t=e.filterText.trim().toLowerCase();Uo.some(i=>!e.levelFilters[i]);const n=e.entries.filter(i=>i.level&&!e.levelFilters[i.level]?!1:uu(i,t));return u`
4031
+ `}function Fw(e){const t=e.filterText.trim().toLowerCase();Wo.some(i=>!e.levelFilters[i]);const n=e.entries.filter(i=>i.level&&!e.levelFilters[i.level]?!1:gu(i,t));return u`
4032
4032
  <button class="chips-toggle" @click=${e.onToggleChips}>
4033
4033
  <span class="chips-toggle-icon ${e.chipsExpanded?"expanded":""}">${L.chevronDown}</span>
4034
4034
  Filters
4035
4035
  </button>
4036
4036
  ${e.chipsExpanded?u`
4037
4037
  <div class="chip-row" style="margin-top: 6px; align-items: center;">
4038
- ${Uo.map(i=>u`
4038
+ ${Wo.map(i=>u`
4039
4039
  <label class="chip log-chip ${i}">
4040
4040
  <input
4041
4041
  type="checkbox"
@@ -4066,7 +4066,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4066
4066
  ${n.length===0?u`<div class="muted" style="padding: 12px;">No log entries.</div>`:[...n].reverse().map(i=>u`
4067
4067
  <div class="log-row">
4068
4068
  <div class="log-row-header">
4069
- <span class="log-time mono">${Pw(i.time)}</span>
4069
+ <span class="log-time mono">${Nw(i.time)}</span>
4070
4070
  <span class="log-level ${i.level??""}">${i.level??""}</span>
4071
4071
  <span class="log-subsystem mono">${i.subsystem??""}</span>
4072
4072
  </div>
@@ -4074,12 +4074,124 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4074
4074
  </div>
4075
4075
  `)}
4076
4076
  </div>
4077
- `}const Rw=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function Dw(e){switch(e.activeTab){case"cron":return yl(e.cronProps);case"skills":return vw(e.skillsProps);case"logs":return Iw(e.logsProps);default:return yl(e.cronProps)}}function Bw(e){return e.connected?u`
4077
+ `}const Uw=[{key:"monday",label:"Monday"},{key:"tuesday",label:"Tuesday"},{key:"wednesday",label:"Wednesday"},{key:"thursday",label:"Thursday"},{key:"friday",label:"Friday"},{key:"saturday",label:"Saturday"},{key:"sunday",label:"Sunday"}],Ww=u`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,Kw=u`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`;function zw(e){return u`
4078
+ ${Hw(e)}
4079
+ ${qw(e)}
4080
+ ${jw(e)}
4081
+ ${Vw(e)}
4082
+ ${Qw(e)}
4083
+ `}function Hw(e){return u`
4084
+ <label class="field checkbox" style="margin: 16px 0;">
4085
+ <input
4086
+ type="checkbox"
4087
+ .checked=${e.form.enabled}
4088
+ @change=${t=>e.onFormChange({enabled:t.target.checked})}
4089
+ />
4090
+ <span style="margin-left: 8px;">
4091
+ Enable opening hours
4092
+ <span class="muted" style="font-size: 12px; display: block; margin-top: 2px;">
4093
+ When enabled, the public assistant does not respond outside the scheduled hours below.
4094
+ </span>
4095
+ </span>
4096
+ </label>
4097
+ `}function qw(e){const t=e.form.enabled;return u`
4098
+ <label
4099
+ class="field checkbox"
4100
+ style="margin: 0 0 16px; ${t?"":"opacity: 0.4; pointer-events: none;"}"
4101
+ >
4102
+ <input
4103
+ type="checkbox"
4104
+ .checked=${e.form.publicAgentEnabled}
4105
+ ?disabled=${!t}
4106
+ @change=${n=>e.onFormChange({publicAgentEnabled:n.target.checked})}
4107
+ />
4108
+ <span style="margin-left: 8px;">
4109
+ Public agent responds during opening hours
4110
+ <span class="muted" style="font-size: 12px; display: block; margin-top: 2px;">
4111
+ ${t?"When disabled, the assistant is silenced during opening hours — useful as a temporary override without changing the schedule.":"Enable opening hours first."}
4112
+ </span>
4113
+ </span>
4114
+ </label>
4115
+ `}function jw(e){return u`
4116
+ <div style="margin-bottom: 20px;">
4117
+ <div style="font-size: 14px; font-weight: 500; margin-bottom: 12px;">Weekly Schedule</div>
4118
+ <div class="oh-schedule">
4119
+ ${Uw.map(t=>Gw(t,e))}
4120
+ </div>
4121
+ </div>
4122
+ `}function Gw(e,t){const n=t.form.days[e.key];if(!n)return w;const i=n.closed;return u`
4123
+ <div class="oh-day-row">
4124
+ <div class="oh-day-label">${e.label}</div>
4125
+ <div class="oh-day-times" style="${i?"opacity: 0.35; pointer-events: none;":""}">
4126
+ <input
4127
+ type="time"
4128
+ .value=${n.start}
4129
+ @input=${s=>t.onDayChange(e.key,"start",s.target.value)}
4130
+ />
4131
+ <span class="oh-time-sep">&ndash;</span>
4132
+ <input
4133
+ type="time"
4134
+ .value=${n.end}
4135
+ @input=${s=>t.onDayChange(e.key,"end",s.target.value)}
4136
+ />
4137
+ </div>
4138
+ <label class="oh-closed-toggle">
4139
+ <input
4140
+ type="checkbox"
4141
+ .checked=${i}
4142
+ @change=${s=>t.onDayChange(e.key,"closed",s.target.checked)}
4143
+ />
4144
+ <span>Closed</span>
4145
+ </label>
4146
+ </div>
4147
+ `}let ki="";function Vw(e){const t=e.form.closedDates;return u`
4148
+ <div style="margin-bottom: 20px;">
4149
+ <div style="font-size: 14px; font-weight: 500; margin-bottom: 10px;">Closed Dates</div>
4150
+ <div style="display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;">
4151
+ ${t.length===0?u`<span class="muted" style="font-size: 13px;">No closed dates.</span>`:t.map(n=>u`
4152
+ <span class="chip chip-warn" style="display: inline-flex; align-items: center; gap: 4px;">
4153
+ ${n}
4154
+ <button
4155
+ class="btn-icon"
4156
+ style="width: 16px; height: 16px; padding: 0;"
4157
+ @click=${()=>e.onRemoveClosedDate(n)}
4158
+ >
4159
+ ${Ww}
4160
+ </button>
4161
+ </span>
4162
+ `)}
4163
+ </div>
4164
+ <div style="display: flex; align-items: center; gap: 8px;">
4165
+ <input
4166
+ type="date"
4167
+ id="oh-new-closed-date"
4168
+ class="oh-date-input"
4169
+ @change=${n=>{ki=n.target.value}}
4170
+ />
4171
+ <button
4172
+ class="btn btn--sm"
4173
+ @click=${()=>{if(ki){e.onAddClosedDate(ki);const n=document.getElementById("oh-new-closed-date");n&&(n.value=""),ki=""}}}
4174
+ >
4175
+ ${Kw} Add
4176
+ </button>
4177
+ </div>
4178
+ </div>
4179
+ `}function Qw(e){return u`
4180
+ <div style="display: flex; justify-content: flex-end; padding-top: 8px;">
4181
+ <button
4182
+ class="btn primary"
4183
+ ?disabled=${e.busy}
4184
+ @click=${e.onSave}
4185
+ >
4186
+ ${e.busy?"Saving…":"Save"}
4187
+ </button>
4188
+ </div>
4189
+ `}const Jw=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"opening-hours",label:"Opening Hours"},{id:"logs",label:"Logs"}];function Yw(e){switch(e.activeTab){case"cron":return wl(e.cronProps);case"skills":return Sw(e.skillsProps);case"opening-hours":return zw(e.openingHoursProps);case"logs":return Ow(e.logsProps);default:return wl(e.cronProps)}}function Xw(e){return e.connected?u`
4078
4190
  <div class="setup-container">
4079
4191
  ${Rt("Advanced",e.wsProps)}
4080
4192
  <div class="setup-card sp-card-advanced" style="text-align: left;">
4081
4193
  <div class="sp-tabs">
4082
- ${Rw.map(t=>u`
4194
+ ${Jw.map(t=>u`
4083
4195
  <button
4084
4196
  class="sp-tab ${e.activeTab===t.id?"active":""}"
4085
4197
  @click=${()=>e.onTabChange(t.id)}
@@ -4088,7 +4200,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4088
4200
  </button>
4089
4201
  `)}
4090
4202
  </div>
4091
- ${Dw(e)}
4203
+ ${Yw(e)}
4092
4204
  </div>
4093
4205
  </div>
4094
4206
  `:u`
@@ -4098,7 +4210,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4098
4210
  <p>Connecting to gateway...</p>
4099
4211
  </div>
4100
4212
  </div>
4101
- `}function wl(e){if(!e.show)return w;const t=Ye(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const a=g=>{var S;o=g.target.value;const $=(S=g.target.closest(".login-card"))==null?void 0:S.querySelector(".login-change-pin");$&&($.style.display=o==="__master__"?"":"none")},r=g=>$=>{const S=$.target;S.value=S.value.replace(/\D/g,"").slice(0,6),g(S.value)},l=g=>{const $=g.currentTarget,S=$.closest(".login-pin-wrapper"),T=S==null?void 0:S.querySelector("input");if(!T)return;const f=T.type==="text";T.type=f?"password":"text",$.classList.toggle("active",!f)},c=!n&&e.accounts.length>1?u`
4213
+ `}function $l(e){if(!e.show)return w;const t=Ye(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const a=g=>{var S;o=g.target.value;const $=(S=g.target.closest(".login-card"))==null?void 0:S.querySelector(".login-change-pin");$&&($.style.display=o==="__master__"?"":"none")},r=g=>$=>{const S=$.target;S.value=S.value.replace(/\D/g,"").slice(0,6),g(S.value)},c=g=>{const $=g.currentTarget,S=$.closest(".login-pin-wrapper"),T=S==null?void 0:S.querySelector("input");if(!T)return;const f=T.type==="text";T.type=f?"password":"text",$.classList.toggle("active",!f)},d=!n&&e.accounts.length>1?u`
4102
4214
  <select
4103
4215
  class="login-account-select"
4104
4216
  @change=${a}
@@ -4117,7 +4229,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4117
4229
  <h2 class="login-title">Change PIN</h2>
4118
4230
  <p class="login-subtitle">Enter your current PIN, then choose a new one</p>
4119
4231
  <form class="login-form" @submit=${T}>
4120
- ${c}
4232
+ ${d}
4121
4233
  <div class="login-pin-wrapper">
4122
4234
  <input
4123
4235
  class="login-pin-input"
@@ -4131,7 +4243,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4131
4243
  @input=${r(f=>{g=f})}
4132
4244
  autofocus
4133
4245
  />
4134
- <button class="login-pin-toggle" type="button" @click=${l}>
4246
+ <button class="login-pin-toggle" type="button" @click=${c}>
4135
4247
  <span class="pin-eye-show">${L.eye}</span>
4136
4248
  <span class="pin-eye-hide">${L.eyeOff}</span>
4137
4249
  </button>
@@ -4148,7 +4260,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4148
4260
  ?disabled=${s}
4149
4261
  @input=${r(f=>{$=f})}
4150
4262
  />
4151
- <button class="login-pin-toggle" type="button" @click=${l}>
4263
+ <button class="login-pin-toggle" type="button" @click=${c}>
4152
4264
  <span class="pin-eye-show">${L.eye}</span>
4153
4265
  <span class="pin-eye-hide">${L.eyeOff}</span>
4154
4266
  </button>
@@ -4165,7 +4277,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4165
4277
  ?disabled=${s}
4166
4278
  @input=${r(f=>{S=f})}
4167
4279
  />
4168
- <button class="login-pin-toggle" type="button" @click=${l}>
4280
+ <button class="login-pin-toggle" type="button" @click=${c}>
4169
4281
  <span class="pin-eye-show">${L.eye}</span>
4170
4282
  <span class="pin-eye-hide">${L.eyeOff}</span>
4171
4283
  </button>
@@ -4187,7 +4299,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4187
4299
  </p>
4188
4300
  </div>
4189
4301
  </div>
4190
- `}let h="",d="";const p=g=>{if(g.preventDefault(),!e.busy)if(n){if(!h||!d||h!==d)return;e.onSubmit(h)}else{if(!h||!o)return;e.onSubmit(o,h)}};return u`
4302
+ `}let h="",l="";const p=g=>{if(g.preventDefault(),!e.busy)if(n){if(!h||!l||h!==l)return;e.onSubmit(h)}else{if(!h||!o)return;e.onSubmit(o,h)}};return u`
4191
4303
  <div class="login-overlay">
4192
4304
  <div class="login-card">
4193
4305
  <img class="login-logo" src="${t.iconUrl}" alt="${t.name}" />
@@ -4196,7 +4308,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4196
4308
  ${n?"Set a PIN to protect this device":"Enter your PIN to continue"}
4197
4309
  </p>
4198
4310
  <form class="login-form" @submit=${p}>
4199
- ${c}
4311
+ ${d}
4200
4312
  <div class="login-pin-wrapper">
4201
4313
  <input
4202
4314
  class="login-pin-input"
@@ -4210,7 +4322,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4210
4322
  @input=${r(g=>{h=g})}
4211
4323
  autofocus
4212
4324
  />
4213
- <button class="login-pin-toggle" type="button" @click=${l}>
4325
+ <button class="login-pin-toggle" type="button" @click=${c}>
4214
4326
  <span class="pin-eye-show">${L.eye}</span>
4215
4327
  <span class="pin-eye-hide">${L.eyeOff}</span>
4216
4328
  </button>
@@ -4226,9 +4338,9 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4226
4338
  maxlength="6"
4227
4339
  placeholder="Confirm PIN"
4228
4340
  ?disabled=${e.busy}
4229
- @input=${r(g=>{d=g})}
4341
+ @input=${r(g=>{l=g})}
4230
4342
  />
4231
- <button class="login-pin-toggle" type="button" @click=${l}>
4343
+ <button class="login-pin-toggle" type="button" @click=${c}>
4232
4344
  <span class="pin-eye-show">${L.eye}</span>
4233
4345
  <span class="pin-eye-hide">${L.eyeOff}</span>
4234
4346
  </button>
@@ -4252,7 +4364,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4252
4364
  </p>`:w}
4253
4365
  </div>
4254
4366
  </div>
4255
- `}function Nw(e){if(!e.connected)return u`
4367
+ `}function Zw(e){if(!e.connected)return u`
4256
4368
  <div class="setup-container">
4257
4369
  <div class="setup-card">
4258
4370
  <div class="setup-spinner"></div>
@@ -4265,10 +4377,10 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4265
4377
  <span class="public-chat-header__name">${n}</span>
4266
4378
  </div>
4267
4379
  <div class="chat-viewport">
4268
- ${au(t)}
4380
+ ${du(t)}
4269
4381
  </div>
4270
4382
  </div>
4271
- `}async function Ow(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 Vn(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 Fw(e,t){var i,s;if(!e.client||!e.connected||e.workspaceSaving)return;const n=t.name.trim();if(!n){e.workspacesError="Account name is required.";return}e.workspaceSaving=!0,e.workspacesError=null;try{const o=await e.client.request("config.get",{});e.configSnapshot=o;const a=o.hash;if(!a){e.workspacesError="Config hash missing; reload and retry.";return}const r={name:n,baseHash:a,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(r.workspaceDir=t.workspacePath.trim());const l=await e.client.request("workspaces.create",r);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await Vn(e),(s=t.onCreated)==null||s.call(t,l)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function Uw(e,t){if(!(!e.client||!e.connected)&&!e.workspaceSaving){e.workspaceSaving=!0,e.workspacesError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=n.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:i}),e.workspaceRemoveConfirm=null,await Vn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Ww(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:s}),await Vn(e)}catch(i){e.workspacesError=String(i)}}}const ki=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Fw,loadWorkspaces:Vn,removeWorkspace:Uw,renameWorkspace:Ww},Symbol.toStringTag,{value:"Module"})),pu={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"taskmaster-control-ui",SETUP_UI:"setup-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"taskmaster-macos",IOS_APP:"taskmaster-ios",ANDROID_APP:"taskmaster-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"taskmaster-probe",PUBLIC_CHAT:"public-chat"},kl=pu,Wo={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(pu));new Set(Object.values(Wo));function Kw(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),i=e.token??"",s=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),i];return t==="v2"&&s.push(e.nonce??""),s.join("|")}const zw=4008;class qw{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{var i,s;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(s=(i=this.opts).onClose)==null||s.call(i,{code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){var d;if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=this.opts.role??"operator",n=this.opts.scopes??["operator.admin","operator.approvals","operator.pairing"],s=!(t!=="operator")&&typeof crypto<"u"&&!!crypto.subtle;let o=null,a=!1,r=this.opts.token;if(s){o=await Hh();const p=(d=Vh({deviceId:o.deviceId,role:t}))==null?void 0:d.token;r=p??this.opts.token,a=!!(p&&this.opts.token)}const l=r||this.opts.password?{token:r,password:this.opts.password}:void 0;let c;if(s&&o){const p=Date.now(),g=this.connectNonce??void 0,$=Kw({deviceId:o.deviceId,clientId:this.opts.clientName??kl.CONTROL_UI,clientMode:this.opts.mode??Wo.WEBCHAT,role:t,scopes:n,signedAtMs:p,token:r??null,nonce:g}),S=await jh(o.privateKey,$);c={id:o.deviceId,publicKey:o.publicKey,signature:S,signedAt:p,nonce:g}}const h={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??kl.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Wo.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:c,caps:[],auth:l,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",h).then(p=>{var g,$,S;(g=p==null?void 0:p.auth)!=null&&g.deviceToken&&o&&Qh({deviceId:o.deviceId,role:p.auth.role??t,token:p.auth.deviceToken,scopes:p.auth.scopes??[]}),this.backoffMs=800,(S=($=this.opts).onHello)==null||S.call($,p)}).catch(()=>{var p;a&&o&&Jh({deviceId:o.deviceId,role:t}),(p=this.ws)==null||p.close(zw,"connect failed")})}handleMessage(t){var s,o,a,r,l,c;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const h=n;if(h.event==="connect.challenge"){const p=h.payload,g=p&&typeof p.nonce=="string"?p.nonce:null;g&&(this.connectNonce=g,this.sendConnect());return}const d=typeof h.seq=="number"?h.seq:null;d!==null&&(this.lastSeq!==null&&d>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:d})),this.lastSeq=d);try{(r=(a=this.opts).onEvent)==null||r.call(a,h)}catch(p){console.error("[gateway] event handler error:",p)}return}if(i.type==="res"){const h=n,d=this.pending.get(h.id);if(!d)return;if(this.pending.delete(h.id),h.ok)d.resolve(h.payload);else{const p=new Error(((l=h.error)==null?void 0:l.message)??"request failed");p.payload=h.payload,p.details=(c=h.error)==null?void 0:c.details,d.reject(p)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=os(),s={type:"req",id:i,method:t,params:n},o=new Promise((a,r)=>{this.pending.set(i,{resolve:l=>a(l),reject:r})});return this.ws.send(JSON.stringify(s)),o}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ko(e){return typeof e=="object"&&e!==null}function Hw(e){if(!Ko(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ko(n))return null;const i=typeof n.command=="string"?n.command.trim():"";if(!i)return null;const s=typeof e.createdAtMs=="number"?e.createdAtMs:0,o=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!s||!o?null:{id:t,request:{command:i,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:s,expiresAtMs:o}}function jw(e){if(!Ko(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 hu(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Gw(e,t){const n=hu(e).filter(i=>i.id!==t.id);return n.push(t),n}function xl(e,t){return hu(e).filter(n=>n.id!==t)}class Vw{constructor(){this.canvas=null,this.ctx=null,this.img=new Image,this.pendingFrame=null,this.rafId=null,this.deviceWidth=1280,this.deviceHeight=720,this.lastMouseMoveAt=0,this.MOUSE_THROTTLE_MS=30}attach(t){this.canvas=t,this.ctx=t.getContext("2d")}detach(){this.rafId!=null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.canvas=null,this.ctx=null,this.pendingFrame=null}updateFrame(t,n){if(n!=null&&n.deviceWidth&&(this.deviceWidth=n.deviceWidth),n!=null&&n.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,!this.canvas){const i=document.getElementById("browser-screencast-canvas");i&&this.attach(i)}this.rafId==null&&(this.rafId=requestAnimationFrame(()=>this.renderFrame()))}renderFrame(){this.rafId=null;const t=this.pendingFrame;!t||!this.canvas||!this.ctx||(this.pendingFrame=null,this.img.onload=()=>{!this.canvas||!this.ctx||((this.canvas.width!==this.img.width||this.canvas.height!==this.img.height)&&(this.canvas.width=this.img.width,this.canvas.height=this.img.height),this.ctx.drawImage(this.img,0,0))},this.img.src=`data:image/jpeg;base64,${t}`)}translateCoordinates(t,n){if(!this.canvas)return{x:t,y:n};const i=this.canvas.getBoundingClientRect(),s=this.canvas.width/i.width,o=this.canvas.height/i.height,a=this.deviceWidth/this.canvas.width,r=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*a),y:Math.round(n*o*r)}}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 lo=null;function Bn(){return lo||(lo=new Vw),lo}function Na(e){return e instanceof Error?e.message:String(e)}async function Qw(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=Na(t)}finally{e.browserLoading=!1}}async function Jw(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=Na(t)}finally{e.browserLoading=!1}}}async function co(e,t,n,i,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:i,button:s??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function uo(e,t,n,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...i!=null&&i.text?{text:i.text}:{},...i!=null&&i.code?{code:i.code}:{},...i!=null&&i.modifiers?{modifiers:i.modifiers}:{}})}catch{}}async function Yw(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=Na(t)}}function Xw(e){e.browserInputMode=!e.browserInputMode}function Zw(e){e.browserFullscreen=!e.browserFullscreen,Bn().detach()}function ek(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,Bn().updateFrame(t.data,t.metadata)}function tk(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function nk(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function zo(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),i=n?{sessionKey:n}:{};try{const s=await e.client.request("agent.identity.get",i);if(!s)return;const o=yo(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function _i(e){return(await e.request("apikeys.list")).providers??[]}async function $l(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function ik(e,t){await e.request("apikeys.remove",{provider:t})}async function sk(e,t,n){await e.request("apikeys.disable",{provider:t,disabled:n})}const es="taskmaster_update_pending";async function fu(e){var t,n;if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("update.status",{});e.currentVersion=i.current,e.latestVersion=i.latest,e.updateAvailable=i.updateAvailable,e.updateMessage=i.updateAvailable?`v${i.latest} available`:"Up to date"}catch(i){e.updateMessage=`Check failed: ${String(i)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function ok(e){var t,n,i,s;if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e);try{localStorage.setItem(es,String(Date.now())),localStorage.removeItem(Oa)}catch{}try{const o=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(o.ok&&o.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(o.ok&&o.result.status==="skipped")Nn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw Nn(),new Error(o.result.reason||"Update failed")}catch(o){Nn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function ak(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const a=t.name,r=t.index,l=t.total;e.updateMessage=`Updating: ${a} (${r+1}/${l})`;const c=e.updateProgressSteps.find(h=>h.index===r);c?(c.status="running",c.name=a):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:l,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const a=t.name,r=t.index,l=t.total,c=t.ok,h=t.durationMs,d=e.updateProgressSteps.find(g=>g.index===r);d?(d.status=c?"done":"failed",d.durationMs=h):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:l,status:c?"done":"failed",durationMs:h}];const p=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${a} done (${r+1}/${l})`:`Update step failed: ${a}${p}`,(s=e.requestUpdate)==null||s.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const r=t.reason;e.updateMessage=r?`Update failed: ${r}`:"Update failed",e.updateRunning=!1,Nn()}(o=e.requestUpdate)==null||o.call(e)}}async function rk(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=ck();Nn();try{const a=await e.client.request("update.lastResult",{});if(!a.ok||!a.result)return;const r=5*6e4,l=Date.now()-a.result.ts<r;if(!t&&!l||dk(a.result.ts))return;e.updateLastResult=a.result;const c=(n=a.result.after)==null?void 0:n.version;if(a.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,a.result.status==="ok"){const h=(i=a.result.before)==null?void 0:i.version,d=c??a.result.currentVersion;e.updateMessage=h?`Updated: v${h} → v${d}`:`Updated to v${d}`}else{const h=a.result.reason??((s=a.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${h}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(o=e.requestUpdate)==null||o.call(e)}}const Oa="taskmaster_update_dismissed";function lk(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Oa,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function ck(){try{const e=localStorage.getItem(es);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(es),!1):!0:!1}catch{return!1}}function Nn(){try{localStorage.removeItem(es)}catch{}}function dk(e){try{const t=localStorage.getItem(Oa);return t?Number(t)>=e:!1}catch{return!1}}function po(e,t){var r,l,c;const n=(e??"").trim(),i=(r=t.mainSessionKey)==null?void 0:r.trim();if(!i)return n;if(!n)return i;const s=((l=t.mainKey)==null?void 0:l.trim())||"main",o=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===s||o&&(n===`agent:${o}:main`||n===`agent:${o}:${s}`)?i:n}function uk(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=po(e.sessionKey,t),i=po(e.settings.sessionKey,t),s=po(e.settings.lastActiveSessionKey,t),o=n||i||e.sessionKey,a={...e.settings,sessionKey:i||o,lastActiveSessionKey:s||o},r=a.sessionKey!==e.settings.sessionKey||a.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),r&&rt(e,a)}function De(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=!!e.publicChat,n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,i=t?"public-chat":n?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new qw({url:e.settings.gatewayUrl,token:t?void 0:e.settings.token.trim()?e.settings.token:void 0,password:t?void 0:e.password.trim()?e.password:void 0,clientName:i,mode:"webchat",role:t?"public":void 0,scopes:t?[]:void 0,onHello:o=>{var a;if(e.connected=!0,e.lastError=null,e.hello=o,t){Sl(e,o),zo(e),(((a=e.publicChatConfig)==null?void 0:a.auth)??"anonymous")==="anonymous"&&bk(e);return}Ki()&&(va(),e.uninstallDone=!1),Sl(e,o),e.handleAccessCheck(),rk(e).then(()=>{fu(e)}),zo(e),Ow(e),(e.chatPage||e.setup)&&fk(e),ra(e,{quiet:!0}),aa(e,{quiet:!0}),Vn(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Ue(e),e.setup&&(gk(e),mk(e),yk(e),vk(e)),Ui(e)},onClose:({code:o,reason:a})=>{e.connected=!1,o!==1012&&(e.lastError=`disconnected (${o}): ${a||"no reason"}`)},onEvent:o=>pk(e,o),onGap:({expected:o,received:a})=>{console.warn(`[gateway] event gap: expected seq ${o}, got ${a}`),Ui(e)}}),e.client.start()}function pk(e,t){try{hk(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function hk(e,t){var n;if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;Jp(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&ed(e,i.sessionKey);const s=nc(e,i);if((s==="final"||s==="error"||s==="aborted")&&(Xo(e),Kf(e)),s==="final"){const o=e,a=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,Fe);Oe(o,{limit:a})}return}if(t.event==="suggestions"){const i=t.payload;(i==null?void 0:i.sessionKey)===e.sessionKey&&Array.isArray(i.suggestions)&&i.suggestions.length>0&&(e.chatSuggestions=i.suggestions);return}if(t.event==="presence"){const i=t.payload;i!=null&&i.presence&&Array.isArray(i.presence)&&(e.presenceEntries=i.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"){const i=t.payload;i&&uh(e,i),e.tab==="cron"&&ma(e)}if((t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&aa(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=Hw(t.payload);if(i){e.execApprovalQueue=Gw(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=xl(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){ek(e,t.payload);return}if(t.event==="browser.handoff"){tk(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){nk(e);return}if(t.event==="exec.approval.resolved"){const i=jw(t.payload);i&&(e.execApprovalQueue=xl(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){ak(e,t.payload);return}}function Sl(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&&uk(e,n.sessionDefaults)}async function fk(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 gk(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await _i(e.client)}catch{}}async function mk(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null}catch{}}async function yk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("wifi.status");if(e.wifiStatus=t,t!=null&&t.connected&&t.signal==null)try{const[n,i]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiStatus=i,i.signal==null&&n.networks){const s=n.networks.find(o=>o.active);s&&(e.wifiStatus={...i,signal:s.signal})}}catch{}}catch{}}async function vk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("network.status");e.networkPort=t.port,e.networkHostname=t.hostname,e.networkPortInput=String(t.port),e.networkHostnameInput=t.hostname}catch{}}const Al="taskmaster_public_id";function gu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${Al}=`));if(t)return t.split("=")[1];const n=`anon-${((s=crypto.randomUUID)==null?void 0:s.call(crypto))??Math.random().toString(36).slice(2)}`,i=new Date(Date.now()+e*864e5).toUTCString();return document.cookie=`${Al}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function bk(e){var n,i,s;if(!e.client||!e.connected)return;const t=gu((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const o=(i=e.publicChatConfig)==null?void 0:i.accountId,a=await e.client.request("public.session",{cookieId:t,accountId:o});if(a!=null&&a.sessionKey){e.publicChatSessionKey=a.sessionKey,e.sessionKey=a.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const r=((s=e.publicChatConfig)==null?void 0:s.accountId)??"";e.chatMessage=Kn(r,a.sessionKey),Oe(e)}}catch(o){console.error("[public-chat] failed to resolve anonymous session:",o),e.lastError="Failed to start chat session"}}let he=!1,ie=null,Zt="",en="",tn="",fs="",cn="phone",On="";function mu(e){return e.replace(/[\s\-()]/g,"")}function st(){he=!1,ie=null,Zt="",en="",tn="",fs="",cn="phone",On=""}async function wk(e){if(!e.client||!e.connected)return;const t=gu(e.cookieTtlDays);try{const n=await e.client.request("public.session",{cookieId:t,accountId:e.accountId});n!=null&&n.sessionKey&&e.onAuthenticated(n.sessionKey)}catch(n){ie=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function Cl(e){if(!e.client||he)return;const t=mu(Zt);if(!t){ie="Please enter your phone number",e.requestUpdate();return}he=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:tn.trim()||void 0,accountId:e.accountId,channel:On||void 0});n!=null&&n.ok?(fs=n.channel??"",cn="phone",e.onAuthStepChange("otp")):ie=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ie=n instanceof Error?n.message:"Failed to send verification code"}finally{he=!1,e.requestUpdate()}}async function El(e){if(!e.client||he)return;const t=en.trim().toLowerCase();if(!t||!t.includes("@")){ie="Please enter a valid email address",e.requestUpdate();return}he=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{identifier:t,accountId:e.accountId});n!=null&&n.ok?(fs=n.channel??"email",cn="email",e.onAuthStepChange("otp")):ie=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ie=n instanceof Error?n.message:"Failed to send verification code"}finally{he=!1,e.requestUpdate()}}async function Tl(e,t){if(!(!e.client||he)){if(!t.trim()){ie="Please enter the verification code",e.requestUpdate();return}he=!0,ie=null,e.requestUpdate();try{const n=cn==="email"?en.trim().toLowerCase():mu(Zt),i=await e.client.request("public.otp.verify",{identifier:n,code:t.trim(),accountId:e.accountId});i!=null&&i.ok&&i.sessionKey?(st(),e.onAuthenticated(i.sessionKey)):ie=(i==null?void 0:i.error)??"Invalid verification code"}catch(n){ie=n instanceof Error?n.message:"Verification failed"}finally{he=!1,e.requestUpdate()}}}function Ge(e){return w}function xi(e){return u`
4383
+ `}async function ek(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 Vn(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 tk(e,t){var i,s;if(!e.client||!e.connected||e.workspaceSaving)return;const n=t.name.trim();if(!n){e.workspacesError="Account name is required.";return}e.workspaceSaving=!0,e.workspacesError=null;try{const o=await e.client.request("config.get",{});e.configSnapshot=o;const a=o.hash;if(!a){e.workspacesError="Config hash missing; reload and retry.";return}const r={name:n,baseHash:a,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(r.workspaceDir=t.workspacePath.trim());const c=await e.client.request("workspaces.create",r);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await Vn(e),(s=t.onCreated)==null||s.call(t,c)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function nk(e,t){if(!(!e.client||!e.connected)&&!e.workspaceSaving){e.workspaceSaving=!0,e.workspacesError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const i=n.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:i}),e.workspaceRemoveConfirm=null,await Vn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function ik(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:s}),await Vn(e)}catch(i){e.workspacesError=String(i)}}}const xi=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:tk,loadWorkspaces:Vn,removeWorkspace:nk,renameWorkspace:ik},Symbol.toStringTag,{value:"Module"})),mu={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"taskmaster-control-ui",SETUP_UI:"setup-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"taskmaster-macos",IOS_APP:"taskmaster-ios",ANDROID_APP:"taskmaster-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"taskmaster-probe",PUBLIC_CHAT:"public-chat"},Sl=mu,Ko={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(mu));new Set(Object.values(Ko));function sk(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),i=e.token??"",s=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),i];return t==="v2"&&s.push(e.nonce??""),s.join("|")}const ok=4008;class ak{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{var i,s;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(s=(i=this.opts).onClose)==null||s.call(i,{code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){var l;if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=this.opts.role??"operator",n=this.opts.scopes??["operator.admin","operator.approvals","operator.pairing"],s=!(t!=="operator")&&typeof crypto<"u"&&!!crypto.subtle;let o=null,a=!1,r=this.opts.token;if(s){o=await Yh();const p=(l=ef({deviceId:o.deviceId,role:t}))==null?void 0:l.token;r=p??this.opts.token,a=!!(p&&this.opts.token)}const c=r||this.opts.password?{token:r,password:this.opts.password}:void 0;let d;if(s&&o){const p=Date.now(),g=this.connectNonce??void 0,$=sk({deviceId:o.deviceId,clientId:this.opts.clientName??Sl.CONTROL_UI,clientMode:this.opts.mode??Ko.WEBCHAT,role:t,scopes:n,signedAtMs:p,token:r??null,nonce:g}),S=await Xh(o.privateKey,$);d={id:o.deviceId,publicKey:o.publicKey,signature:S,signedAt:p,nonce:g}}const h={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Sl.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Ko.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:d,caps:[],auth:c,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",h).then(p=>{var g,$,S;(g=p==null?void 0:p.auth)!=null&&g.deviceToken&&o&&tf({deviceId:o.deviceId,role:p.auth.role??t,token:p.auth.deviceToken,scopes:p.auth.scopes??[]}),this.backoffMs=800,(S=($=this.opts).onHello)==null||S.call($,p)}).catch(()=>{var p;a&&o&&nf({deviceId:o.deviceId,role:t}),(p=this.ws)==null||p.close(ok,"connect failed")})}handleMessage(t){var s,o,a,r,c,d;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const h=n;if(h.event==="connect.challenge"){const p=h.payload,g=p&&typeof p.nonce=="string"?p.nonce:null;g&&(this.connectNonce=g,this.sendConnect());return}const l=typeof h.seq=="number"?h.seq:null;l!==null&&(this.lastSeq!==null&&l>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:l})),this.lastSeq=l);try{(r=(a=this.opts).onEvent)==null||r.call(a,h)}catch(p){console.error("[gateway] event handler error:",p)}return}if(i.type==="res"){const h=n,l=this.pending.get(h.id);if(!l)return;if(this.pending.delete(h.id),h.ok)l.resolve(h.payload);else{const p=new Error(((c=h.error)==null?void 0:c.message)??"request failed");p.payload=h.payload,p.details=(d=h.error)==null?void 0:d.details,l.reject(p)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=as(),s={type:"req",id:i,method:t,params:n},o=new Promise((a,r)=>{this.pending.set(i,{resolve:c=>a(c),reject:r})});return this.ws.send(JSON.stringify(s)),o}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function zo(e){return typeof e=="object"&&e!==null}function rk(e){if(!zo(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!zo(n))return null;const i=typeof n.command=="string"?n.command.trim():"";if(!i)return null;const s=typeof e.createdAtMs=="number"?e.createdAtMs:0,o=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!s||!o?null:{id:t,request:{command:i,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:s,expiresAtMs:o}}function lk(e){if(!zo(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 yu(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function ck(e,t){const n=yu(e).filter(i=>i.id!==t.id);return n.push(t),n}function Al(e,t){return yu(e).filter(n=>n.id!==t)}class dk{constructor(){this.canvas=null,this.ctx=null,this.img=new Image,this.pendingFrame=null,this.rafId=null,this.deviceWidth=1280,this.deviceHeight=720,this.lastMouseMoveAt=0,this.MOUSE_THROTTLE_MS=30}attach(t){this.canvas=t,this.ctx=t.getContext("2d")}detach(){this.rafId!=null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.canvas=null,this.ctx=null,this.pendingFrame=null}updateFrame(t,n){if(n!=null&&n.deviceWidth&&(this.deviceWidth=n.deviceWidth),n!=null&&n.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,!this.canvas){const i=document.getElementById("browser-screencast-canvas");i&&this.attach(i)}this.rafId==null&&(this.rafId=requestAnimationFrame(()=>this.renderFrame()))}renderFrame(){this.rafId=null;const t=this.pendingFrame;!t||!this.canvas||!this.ctx||(this.pendingFrame=null,this.img.onload=()=>{!this.canvas||!this.ctx||((this.canvas.width!==this.img.width||this.canvas.height!==this.img.height)&&(this.canvas.width=this.img.width,this.canvas.height=this.img.height),this.ctx.drawImage(this.img,0,0))},this.img.src=`data:image/jpeg;base64,${t}`)}translateCoordinates(t,n){if(!this.canvas)return{x:t,y:n};const i=this.canvas.getBoundingClientRect(),s=this.canvas.width/i.width,o=this.canvas.height/i.height,a=this.deviceWidth/this.canvas.width,r=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*a),y:Math.round(n*o*r)}}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 co=null;function Bn(){return co||(co=new dk),co}function Oa(e){return e instanceof Error?e.message:String(e)}async function uk(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=Oa(t)}finally{e.browserLoading=!1}}async function pk(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=Oa(t)}finally{e.browserLoading=!1}}}async function uo(e,t,n,i,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:i,button:s??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function po(e,t,n,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...i!=null&&i.text?{text:i.text}:{},...i!=null&&i.code?{code:i.code}:{},...i!=null&&i.modifiers?{modifiers:i.modifiers}:{}})}catch{}}async function hk(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=Oa(t)}}function fk(e){e.browserInputMode=!e.browserInputMode}function gk(e){e.browserFullscreen=!e.browserFullscreen,Bn().detach()}function mk(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,Bn().updateFrame(t.data,t.metadata)}function yk(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function vk(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function Ho(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),i=n?{sessionKey:n}:{};try{const s=await e.client.request("agent.identity.get",i);if(!s)return;const o=vo(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function Mi(e){return(await e.request("apikeys.list")).providers??[]}async function Cl(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function bk(e,t){await e.request("apikeys.remove",{provider:t})}async function wk(e,t,n){await e.request("apikeys.disable",{provider:t,disabled:n})}const ts="taskmaster_update_pending";async function vu(e){var t,n;if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("update.status",{});e.currentVersion=i.current,e.latestVersion=i.latest,e.updateAvailable=i.updateAvailable,e.updateMessage=i.updateAvailable?`v${i.latest} available`:"Up to date"}catch(i){e.updateMessage=`Check failed: ${String(i)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function kk(e){var t,n,i,s;if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e);try{localStorage.setItem(ts,String(Date.now())),localStorage.removeItem(Fa)}catch{}try{const o=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(o.ok&&o.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(o.ok&&o.result.status==="skipped")Nn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw Nn(),new Error(o.result.reason||"Update failed")}catch(o){Nn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function xk(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const a=t.name,r=t.index,c=t.total;e.updateMessage=`Updating: ${a} (${r+1}/${c})`;const d=e.updateProgressSteps.find(h=>h.index===r);d?(d.status="running",d.name=a):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:c,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const a=t.name,r=t.index,c=t.total,d=t.ok,h=t.durationMs,l=e.updateProgressSteps.find(g=>g.index===r);l?(l.status=d?"done":"failed",l.durationMs=h):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:c,status:d?"done":"failed",durationMs:h}];const p=!d&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=d?`Updating: ${a} done (${r+1}/${c})`:`Update step failed: ${a}${p}`,(s=e.requestUpdate)==null||s.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const r=t.reason;e.updateMessage=r?`Update failed: ${r}`:"Update failed",e.updateRunning=!1,Nn()}(o=e.requestUpdate)==null||o.call(e)}}async function $k(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=Ak();Nn();try{const a=await e.client.request("update.lastResult",{});if(!a.ok||!a.result)return;const r=5*6e4,c=Date.now()-a.result.ts<r;if(!t&&!c||Ck(a.result.ts))return;e.updateLastResult=a.result;const d=(n=a.result.after)==null?void 0:n.version;if(a.result.status==="ok"&&d&&(e.currentVersion=d),e.updateAvailable=!1,a.result.status==="ok"){const h=(i=a.result.before)==null?void 0:i.version,l=d??a.result.currentVersion;e.updateMessage=h?`Updated: v${h} → v${l}`:`Updated to v${l}`}else{const h=a.result.reason??((s=a.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${h}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(o=e.requestUpdate)==null||o.call(e)}}const Fa="taskmaster_update_dismissed";function Sk(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Fa,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function Ak(){try{const e=localStorage.getItem(ts);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(ts),!1):!0:!1}catch{return!1}}function Nn(){try{localStorage.removeItem(ts)}catch{}}function Ck(e){try{const t=localStorage.getItem(Fa);return t?Number(t)>=e:!1}catch{return!1}}const El="notification-banner";function Ek(e){const t=document.getElementById(El);if(!e){t==null||t.remove();return}t&&t.remove();const n=document.createElement("div");n.id=El,Object.assign(n.style,{background:"rgba(255, 180, 50, 0.15)",border:"1px solid rgba(255, 180, 50, 0.3)",borderRadius:"8px",padding:"12px 16px",margin:"0 0 16px 0",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"12px",color:"rgba(255, 255, 255, 0.9)",fontSize:"14px"});const i=document.createElement("span");i.textContent=e.message,n.appendChild(i);const s=document.createElement("button");s.setAttribute("aria-label","Dismiss"),s.textContent="×",Object.assign(s.style,{background:"none",border:"none",color:"rgba(255, 255, 255, 0.7)",cursor:"pointer",fontSize:"18px",padding:"0 4px"}),s.addEventListener("click",()=>n.remove()),n.appendChild(s),(document.querySelector("main")??document.body).prepend(n)}function ho(e,t){var r,c,d;const n=(e??"").trim(),i=(r=t.mainSessionKey)==null?void 0:r.trim();if(!i)return n;if(!n)return i;const s=((c=t.mainKey)==null?void 0:c.trim())||"main",o=(d=t.defaultAgentId)==null?void 0:d.trim();return n==="main"||n===s||o&&(n===`agent:${o}:main`||n===`agent:${o}:${s}`)?i:n}function Tk(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=ho(e.sessionKey,t),i=ho(e.settings.sessionKey,t),s=ho(e.settings.lastActiveSessionKey,t),o=n||i||e.sessionKey,a={...e.settings,sessionKey:i||o,lastActiveSessionKey:s||o},r=a.sessionKey!==e.settings.sessionKey||a.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),r&&rt(e,a)}function De(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=!!e.publicChat,n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,i=t?"public-chat":n?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new ak({url:e.settings.gatewayUrl,token:t?void 0:e.settings.token.trim()?e.settings.token:void 0,password:t?void 0:e.password.trim()?e.password:void 0,clientName:i,mode:"webchat",role:t?"public":void 0,scopes:t?[]:void 0,onHello:o=>{var a;if(e.connected=!0,e.lastError=null,e.hello=o,t){Tl(e,o),Ho(e),(((a=e.publicChatConfig)==null?void 0:a.auth)??"anonymous")==="anonymous"&&Bk(e);return}zi()&&(ba(),e.uninstallDone=!1),Tl(e,o),e.handleAccessCheck(),$k(e).then(()=>{vu(e)}),Ho(e),ek(e),(e.chatPage||e.setup)&&Pk(e),la(e,{quiet:!0}),ra(e,{quiet:!0}),Vn(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Ue(e),e.setup&&(Ik(e),Lk(e),Rk(e),Dk(e)),Wi(e)},onClose:({code:o,reason:a})=>{e.connected=!1,o!==1012&&(e.lastError=`disconnected (${o}): ${a||"no reason"}`)},onEvent:o=>_k(e,o),onGap:({expected:o,received:a})=>{console.warn(`[gateway] event gap: expected seq ${o}, got ${a}`),Wi(e)}}),e.client.start()}function _k(e,t){try{Mk(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Mk(e,t){var n;if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;nh(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&sd(e,i.sessionKey);const s=ac(e,i);if((s==="final"||s==="error"||s==="aborted")&&(Zo(e),Vf(e)),s==="final"){const o=e,a=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,Fe);Oe(o,{limit:a})}return}if(t.event==="suggestions"){const i=t.payload;(i==null?void 0:i.sessionKey)===e.sessionKey&&Array.isArray(i.suggestions)&&i.suggestions.length>0&&(e.chatSuggestions=i.suggestions);return}if(t.event==="presence"){const i=t.payload;i!=null&&i.presence&&Array.isArray(i.presence)&&(e.presenceEntries=i.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"){const i=t.payload;i&&yh(e,i),e.tab==="cron"&&ya(e)}if((t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&ra(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=rk(t.payload);if(i){e.execApprovalQueue=ck(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Al(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){mk(e,t.payload);return}if(t.event==="browser.handoff"){yk(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){vk(e);return}if(t.event==="exec.approval.resolved"){const i=lk(t.payload);i&&(e.execApprovalQueue=Al(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){xk(e,t.payload);return}if(t.event==="notification"){const i=t.payload;(i==null?void 0:i.category)==="model-fallback"&&Ek(i);return}}function Tl(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&&Tk(e,n.sessionDefaults)}async function Pk(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 Ik(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await Mi(e.client)}catch{}}async function Lk(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null}catch{}}async function Rk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("wifi.status");if(e.wifiStatus=t,t!=null&&t.connected&&t.signal==null)try{const[n,i]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiStatus=i,i.signal==null&&n.networks){const s=n.networks.find(o=>o.active);s&&(e.wifiStatus={...i,signal:s.signal})}}catch{}}catch{}}async function Dk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("network.status");e.networkPort=t.port,e.networkHostname=t.hostname,e.networkPortInput=String(t.port),e.networkHostnameInput=t.hostname}catch{}}const _l="taskmaster_public_id";function bu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${_l}=`));if(t)return t.split("=")[1];const n=`anon-${((s=crypto.randomUUID)==null?void 0:s.call(crypto))??Math.random().toString(36).slice(2)}`,i=new Date(Date.now()+e*864e5).toUTCString();return document.cookie=`${_l}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function Bk(e){var n,i,s;if(!e.client||!e.connected)return;const t=bu((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const o=(i=e.publicChatConfig)==null?void 0:i.accountId,a=await e.client.request("public.session",{cookieId:t,accountId:o});if(a!=null&&a.sessionKey){e.publicChatSessionKey=a.sessionKey,e.sessionKey=a.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const r=((s=e.publicChatConfig)==null?void 0:s.accountId)??"";e.chatMessage=Kn(r,a.sessionKey),Oe(e)}}catch(o){console.error("[public-chat] failed to resolve anonymous session:",o),e.lastError="Failed to start chat session"}}let he=!1,ie=null,Zt="",en="",tn="",gs="",cn="phone",On="";function wu(e){return e.replace(/[\s\-()]/g,"")}function st(){he=!1,ie=null,Zt="",en="",tn="",gs="",cn="phone",On=""}async function Nk(e){if(!e.client||!e.connected)return;const t=bu(e.cookieTtlDays);try{const n=await e.client.request("public.session",{cookieId:t,accountId:e.accountId});n!=null&&n.sessionKey&&e.onAuthenticated(n.sessionKey)}catch(n){ie=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function Ml(e){if(!e.client||he)return;const t=wu(Zt);if(!t){ie="Please enter your phone number",e.requestUpdate();return}he=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:tn.trim()||void 0,accountId:e.accountId,channel:On||void 0});n!=null&&n.ok?(gs=n.channel??"",cn="phone",e.onAuthStepChange("otp")):ie=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ie=n instanceof Error?n.message:"Failed to send verification code"}finally{he=!1,e.requestUpdate()}}async function Pl(e){if(!e.client||he)return;const t=en.trim().toLowerCase();if(!t||!t.includes("@")){ie="Please enter a valid email address",e.requestUpdate();return}he=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{identifier:t,accountId:e.accountId});n!=null&&n.ok?(gs=n.channel??"email",cn="email",e.onAuthStepChange("otp")):ie=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ie=n instanceof Error?n.message:"Failed to send verification code"}finally{he=!1,e.requestUpdate()}}async function Il(e,t){if(!(!e.client||he)){if(!t.trim()){ie="Please enter the verification code",e.requestUpdate();return}he=!0,ie=null,e.requestUpdate();try{const n=cn==="email"?en.trim().toLowerCase():wu(Zt),i=await e.client.request("public.otp.verify",{identifier:n,code:t.trim(),accountId:e.accountId});i!=null&&i.ok&&i.sessionKey?(st(),e.onAuthenticated(i.sessionKey)):ie=(i==null?void 0:i.error)??"Invalid verification code"}catch(n){ie=n instanceof Error?n.message:"Verification failed"}finally{he=!1,e.requestUpdate()}}}function Ge(e){return w}function $i(e){return u`
4272
4384
  <div class="public-auth__form">
4273
4385
  <label class="field public-auth__field">
4274
4386
  <span>Your name (optional)</span>
@@ -4285,7 +4397,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4285
4397
  type="tel"
4286
4398
  .value=${Zt}
4287
4399
  @input=${t=>{Zt=t.target.value}}
4288
- @keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),Cl(e))}}
4400
+ @keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),Ml(e))}}
4289
4401
  placeholder="+44 7123 456789"
4290
4402
  required
4291
4403
  />
@@ -4294,12 +4406,12 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4294
4406
  <button
4295
4407
  class="btn primary public-auth__btn"
4296
4408
  ?disabled=${he}
4297
- @click=${()=>{Cl(e)}}
4409
+ @click=${()=>{Ml(e)}}
4298
4410
  >
4299
4411
  ${he?"Sending...":"Send verification code"}
4300
4412
  </button>
4301
4413
  </div>
4302
- `}function ho(e){return u`
4414
+ `}function fo(e){return u`
4303
4415
  <div class="public-auth__form">
4304
4416
  <label class="field public-auth__field">
4305
4417
  <span>Your name (optional)</span>
@@ -4316,7 +4428,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4316
4428
  type="email"
4317
4429
  .value=${en}
4318
4430
  @input=${t=>{en=t.target.value}}
4319
- @keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),El(e))}}
4431
+ @keydown=${t=>{t.key==="Enter"&&(t.preventDefault(),Pl(e))}}
4320
4432
  placeholder="you@example.com"
4321
4433
  required
4322
4434
  />
@@ -4325,12 +4437,12 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4325
4437
  <button
4326
4438
  class="btn primary public-auth__btn"
4327
4439
  ?disabled=${he}
4328
- @click=${()=>{El(e)}}
4440
+ @click=${()=>{Pl(e)}}
4329
4441
  >
4330
4442
  ${he?"Sending...":"Send verification code"}
4331
4443
  </button>
4332
4444
  </div>
4333
- `}function _l(e){let t="";const n=cn==="email",i=n?"email":fs==="sms"?"SMS":"WhatsApp",s=n?en:Zt,o=n?"email":"phone";return u`
4445
+ `}function Ll(e){let t="";const n=cn==="email",i=n?"email":gs==="sms"?"SMS":"WhatsApp",s=n?en:Zt,o=n?"email":"phone";return u`
4334
4446
  <div class="public-auth__form">
4335
4447
  <p class="public-auth__hint">
4336
4448
  We sent a verification code to <strong>${s}</strong> via ${i}.
@@ -4342,7 +4454,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4342
4454
  inputmode="numeric"
4343
4455
  maxlength="6"
4344
4456
  @input=${a=>{t=a.target.value}}
4345
- @keydown=${a=>{a.key==="Enter"&&(a.preventDefault(),Tl(e,t))}}
4457
+ @keydown=${a=>{a.key==="Enter"&&(a.preventDefault(),Il(e,t))}}
4346
4458
  placeholder="123456"
4347
4459
  required
4348
4460
  />
@@ -4351,7 +4463,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4351
4463
  <button
4352
4464
  class="btn primary public-auth__btn"
4353
4465
  ?disabled=${he}
4354
- @click=${()=>{Tl(e,t)}}
4466
+ @click=${()=>{Il(e,t)}}
4355
4467
  >
4356
4468
  ${he?"Verifying...":"Verify"}
4357
4469
  </button>
@@ -4362,14 +4474,14 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4362
4474
  ${n?"Use a different email":"Use a different number"}
4363
4475
  </button>
4364
4476
  </div>
4365
- `}function kk(e){const{authMode:t,authStep:n}=e,i=!e.otpChannels||e.otpChannels.length>0;if(t==="anonymous")return u`
4477
+ `}function Ok(e){const{authMode:t,authStep:n}=e,i=!e.otpChannels||e.otpChannels.length>0;if(t==="anonymous")return u`
4366
4478
  <div class="setup-container">
4367
4479
  <div class="setup-card">
4368
4480
  <div class="setup-spinner"></div>
4369
4481
  <p>Starting chat...</p>
4370
4482
  </div>
4371
4483
  </div>
4372
- `;if(t==="verified"){const h=e.verifyMethods??["whatsapp","sms"],d=h.includes("whatsapp")||h.includes("sms")||h.includes("phone"),p=h.includes("email");return!i&&!p?u`
4484
+ `;if(t==="verified"){const h=e.verifyMethods??["whatsapp","sms"],l=h.includes("whatsapp")||h.includes("sms")||h.includes("phone"),p=h.includes("email");return!i&&!p?u`
4373
4485
  <div class="setup-container">
4374
4486
  <div class="public-auth">
4375
4487
  ${Ge()}
@@ -4382,7 +4494,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4382
4494
  <div class="public-auth">
4383
4495
  ${Ge()}
4384
4496
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4385
- ${_l(e)}
4497
+ ${Ll(e)}
4386
4498
  </div>
4387
4499
  </div>
4388
4500
  `:n==="email"?u`
@@ -4391,8 +4503,8 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4391
4503
  ${Ge()}
4392
4504
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4393
4505
  <p class="public-auth__subtitle">Verify your email address to get started.</p>
4394
- ${ho(e)}
4395
- ${d?u`
4506
+ ${fo(e)}
4507
+ ${l?u`
4396
4508
  <button class="btn public-auth__btn public-auth__btn--link"
4397
4509
  @click=${()=>{st(),e.onAuthStepChange("phone")}}>
4398
4510
  Use phone number instead
@@ -4406,7 +4518,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4406
4518
  ${Ge()}
4407
4519
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4408
4520
  <p class="public-auth__subtitle">Verify your phone number to get started.</p>
4409
- ${xi(e)}
4521
+ ${$i(e)}
4410
4522
  ${p?u`
4411
4523
  <button class="btn public-auth__btn public-auth__btn--link"
4412
4524
  @click=${()=>{st(),e.onAuthStepChange("email")}}>
@@ -4415,13 +4527,13 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4415
4527
  `:w}
4416
4528
  </div>
4417
4529
  </div>
4418
- `:d&&p?u`
4530
+ `:l&&p?u`
4419
4531
  <div class="setup-container">
4420
4532
  <div class="public-auth">
4421
4533
  ${Ge()}
4422
4534
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4423
4535
  <p class="public-auth__subtitle">Authenticate to get started.</p>
4424
- ${xi(e)}
4536
+ ${$i(e)}
4425
4537
  <button class="btn public-auth__btn public-auth__btn--link"
4426
4538
  @click=${()=>{st(),e.onAuthStepChange("email")}}>
4427
4539
  Use email instead
@@ -4434,7 +4546,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4434
4546
  ${Ge()}
4435
4547
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4436
4548
  <p class="public-auth__subtitle">Verify your email address to get started.</p>
4437
- ${ho(e)}
4549
+ ${fo(e)}
4438
4550
  </div>
4439
4551
  </div>
4440
4552
  `:u`
@@ -4443,16 +4555,16 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4443
4555
  ${Ge()}
4444
4556
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4445
4557
  <p class="public-auth__subtitle">Verify your phone number to get started.</p>
4446
- ${xi(e)}
4558
+ ${$i(e)}
4447
4559
  </div>
4448
4560
  </div>
4449
- `}const s=e.verifyMethods??["whatsapp","sms"],o=s.includes("whatsapp")&&(!e.otpChannels||e.otpChannels.includes("whatsapp")),a=s.includes("sms"),r=s.includes("email"),c=o||a||s.includes("phone")||r;if(n==="phone"||n==="email"||n==="otp"){const h=n==="email"||n==="otp"&&cn==="email",p=h?"Verify your email address to continue your conversation across devices.":`Verify your phone number to receive a code via ${h?"email":On==="sms"?"SMS":"WhatsApp"}.`;return u`
4561
+ `}const s=e.verifyMethods??["whatsapp","sms"],o=s.includes("whatsapp")&&(!e.otpChannels||e.otpChannels.includes("whatsapp")),a=s.includes("sms"),r=s.includes("email"),d=o||a||s.includes("phone")||r;if(n==="phone"||n==="email"||n==="otp"){const h=n==="email"||n==="otp"&&cn==="email",p=h?"Verify your email address to continue your conversation across devices.":`Verify your phone number to receive a code via ${h?"email":On==="sms"?"SMS":"WhatsApp"}.`;return u`
4450
4562
  <div class="setup-container">
4451
4563
  <div class="public-auth">
4452
4564
  ${Ge()}
4453
4565
  <h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
4454
4566
  <p class="public-auth__subtitle">${p}</p>
4455
- ${n==="otp"?_l(e):n==="email"?ho(e):xi(e)}
4567
+ ${n==="otp"?Ll(e):n==="email"?fo(e):$i(e)}
4456
4568
  ${n!=="otp"?u`
4457
4569
  <button class="btn public-auth__btn public-auth__btn--link"
4458
4570
  @click=${()=>{st(),e.onAuthStepChange("idle")}}>
@@ -4470,7 +4582,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4470
4582
  <div class="public-auth__choices">
4471
4583
  <button
4472
4584
  class="btn primary public-auth__btn"
4473
- @click=${()=>{wk(e)}}
4585
+ @click=${()=>{Nk(e)}}
4474
4586
  >
4475
4587
  Chat now
4476
4588
  </button>
@@ -4499,14 +4611,14 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4499
4611
  </button>
4500
4612
  `:w}
4501
4613
  </div>
4502
- ${c?u`
4614
+ ${d?u`
4503
4615
  <p class="public-auth__hint">
4504
4616
  Verifying your identity lets you continue your conversation across devices.
4505
4617
  </p>
4506
4618
  `:w}
4507
4619
  </div>
4508
4620
  </div>
4509
- `}const Fa="taskmaster-access-session",yu={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function vu(){try{return localStorage.getItem(Fa)}catch{return null}}function bu(e){try{localStorage.setItem(Fa,e)}catch{}}function xk(){try{localStorage.removeItem(Fa)}catch{}}async function Ml(e){if(e.client)try{const t=vu(),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 $k(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const i=await e.client.request("access.verify",{account:t,pin:n});i.ok&&i.token?(bu(i.token),e.accessState={...e.accessState,authenticated:!0,workspace:i.workspace??null,master:i.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:i.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function Sk(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?(bu(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 Ak(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 Ck(e){const t=vu();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}xk(),e.accessState={...yu,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function Ek(e,t="admin"){var s;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const i=[];for(const o of n){if(!o||typeof o!="object"||o.agentId!==t&&o.agentId!=="management")continue;const a=o.match;if(!a||typeof a!="object"||(a.channel??"").toLowerCase()!=="whatsapp")continue;const l=a.peer;if(!l||typeof l!="object"||l.kind!=="dm")continue;const c=l.id??"";c&&i.push({phone:c,paired:((s=o.meta)==null?void 0:s.paired)===!0})}return i.sort((o,a)=>o.paired&&!a.paired?-1:!o.paired&&a.paired?1:0),i}function wu(e,t,n="admin",i){const s=c=>c===n||c==="management",o=new Map,a=new Map;for(const c of e){if(!c||typeof c!="object"||!s(c.agentId))continue;const h=c.match;if(!h||typeof h!="object"||(h.channel??"").toLowerCase()!=="whatsapp")continue;const p=h.peer;if(!p||typeof p!="object"||p.kind!=="dm")continue;const g=p.id??"";g&&(c.meta&&o.set(g,c.meta),h.accountId&&a.set(g,h.accountId))}const r=e.filter(c=>{if(!c||typeof c!="object"||!s(c.agentId))return!0;const h=c.match;if(!h||typeof h!="object"||(h.channel??"").toLowerCase()!=="whatsapp")return!0;const p=h.peer;return!p||typeof p!="object"?!0:p.kind!=="dm"}),l=t.map(c=>{const h=i??a.get(c.phone),d={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};h&&(d.accountId=h);const p={agentId:n,match:d},g=o.get(c.phone);return g?p.meta=g:c.paired&&(p.meta={paired:!0}),p});return[...r,...l]}async function gs(e,t){if(!e.client||!e.connected)return;if(!t){e.adminPhones=[];return}if(e.adminsLoading)return;e.adminsLoading=!0,e.adminsError=null;const n=t;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.config;e.configForm=ct(s??{}),e.adminPhones=Ek(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function ku(e,t,n,i){var a,r;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n;let o=t.replace(/[\s\-\(\)]/g,"");if(!o){e.adminsError="Phone number is required";return}if(o.startsWith("+")||(o="+"+o),!/^\+[1-9]\d{6,14}$/.test(o)){e.adminsError="Invalid phone number. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(l=>l.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const l=ct(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),c=l.bindings??[],h=[...e.adminPhones,{phone:o}],d=wu(c,h,s,i);sc(l,["bindings"],d);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const g=Et(l);await e.client.request("config.set",{raw:g,baseHash:p}),await gs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}async function xu(e,t,n,i){var a,r;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n,o=e.adminPhones.find(l=>l.phone===t);if(o!=null&&o.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const l=ct(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),c=l.bindings??[],h=e.adminPhones.filter($=>$.phone!==t),d=wu(c,h,s,i);sc(l,["bindings"],d);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const g=Et(l);await e.client.request("config.set",{raw:g,baseHash:p}),await gs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}const Tk=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:ku,loadAdmins:gs,removeAdmin:xu},Symbol.toStringTag,{value:"Module"}));async function Lt(e,t){if(!(!e.client||!e.connected)){if(!t){e.contactsRecords=[];return}if(!e.contactsLoading){e.contactsLoading=!0,e.contactsError=null;try{const n=e.contactsSearchQuery.trim(),i=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.contactsRecords=i.records??[]}catch(n){e.contactsError=String(n)}finally{e.contactsLoading=!1}}}}async function $u(e,t,n,i){if(!e.client||!e.connected||e.contactsSaving)return;let s=t.replace(/[\s\-\(\)]/g,"");const o=n.trim();if(!s){e.contactsError="Phone number is required";return}if(!o){e.contactsError="Name is required";return}if(s.startsWith("+")||(s="+"+s),!/^\+[1-9]\d{6,14}$/.test(s)){e.contactsError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.set",{id:s,name:o,fields:{},workspace:i}),e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName="",await Lt(e,i)}catch(a){e.contactsError=String(a)}finally{e.contactsSaving=!1}}async function Su(e,t,n){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.delete",{id:t}),e.contactsEditingId===t&&(e.contactsEditingId=null),await Lt(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function qo(e,t,n,i,s){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.setField",{id:t,key:n,value:i}),await Lt(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function Au(e,t,n,i){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await Lt(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const _k=Object.freeze(Object.defineProperty({__proto__:null,addContact:$u,deleteContact:Su,deleteContactField:Au,loadContacts:Lt,setContactField:qo},Symbol.toStringTag,{value:"Module"}));let xt=null,Mi=null,Pi=null;const fo=[[0,"Checking Tailscale service..."],[5,"Starting login..."],[15,"Requesting authentication link..."],[40,"Setting up secure connection..."],[70,"Almost ready..."]];function zt(){xt&&(clearInterval(xt),xt=null),Mi&&(clearInterval(Mi),Mi=null),Pi&&(clearTimeout(Pi),Pi=null)}function Sn(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0},onRestartGateway:()=>e.handleGatewayRestart()}}function Mk(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},onRestartGateway:()=>e.handleGatewayRestart()}}function Pk(e){const t=ue(e);if(!t)return;const n=t.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return n==null?void 0:n.id}function Ik(e){const t=ue(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function Lk(e){var i;const t=ue(e);if(!t)return;const n=t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin");return(n==null?void 0:n.id)??((i=t.agents[0])==null?void 0:i.id)}function Rk(e){return e.selectedWorkspace??void 0}function ue(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const Dk=/^data:/i,Bk=/^https?:\/\//i;function Pl(e){var r,l;const t=((r=e.agentsList)==null?void 0:r.agents)??[],n=jl(e.sessionKey),i=(n==null?void 0:n.agentId)??((l=e.agentsList)==null?void 0:l.defaultId)??"main",s=t.find(c=>c.id===i),o=s==null?void 0:s.identity,a=(o==null?void 0:o.avatarUrl)??(o==null?void 0:o.avatar);if(a)return Dk.test(a)||Bk.test(a)?a:o==null?void 0:o.avatarUrl}function Nk(e){var i;if(!e)return null;const t=(i=e.channelAccounts)==null?void 0:i.whatsapp;if(!t||t.length===0)return null;const n=t[0];return{running:n.running??!1,connected:n.connected??!1,linked:n.linked??!1,lastError:n.lastError}}function Ok(e){var a;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(a=e.channelAccounts)==null?void 0:a.imessage;if(!t||t.length===0)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const n=t[0],i=n.running??!1,s=n.probe,o=s!=null?s.ok===!0:i;return{configured:n.configured??!1,running:i,connected:o,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function Fk(e){var a;const t=(a=e.configSnapshot)==null?void 0:a.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(r=>{var l,c;return((l=r.match)==null?void 0:l.channel)==="imessage"&&((c=r.meta)==null?void 0:c.imessageOwner)});if(!i)return null;const s=i.agentId;for(const r of e.workspaces)if(r.agents.some(l=>l.id===s))return r.name;if(s==="admin"||s==="public"){const r=e.workspaces.find(l=>l.isDefault);return(r==null?void 0:r.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const r=e.workspaces.find(l=>l.name===o);return(r==null?void 0:r.name)??null}return null}function Uk(e){var t,n,i,s,o,a,r,l,c,h;if(e.embeddingDownloading&&!e.publicChat)return u`
4621
+ `}const Ua="taskmaster-access-session",ku={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function xu(){try{return localStorage.getItem(Ua)}catch{return null}}function $u(e){try{localStorage.setItem(Ua,e)}catch{}}function Fk(){try{localStorage.removeItem(Ua)}catch{}}async function Rl(e){if(e.client)try{const t=xu(),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 Uk(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const i=await e.client.request("access.verify",{account:t,pin:n});i.ok&&i.token?($u(i.token),e.accessState={...e.accessState,authenticated:!0,workspace:i.workspace??null,master:i.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:i.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function Wk(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?($u(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 Kk(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 zk(e){const t=xu();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}Fk(),e.accessState={...ku,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function Wa(){return{enabled:!1,publicAgentEnabled:!0,days:{monday:{start:"09:00",end:"17:00",closed:!1},tuesday:{start:"09:00",end:"17:00",closed:!1},wednesday:{start:"09:00",end:"17:00",closed:!1},thursday:{start:"09:00",end:"17:00",closed:!1},friday:{start:"09:00",end:"17:00",closed:!1},saturday:{start:"09:00",end:"17:00",closed:!0},sunday:{start:"09:00",end:"17:00",closed:!0}},closedDates:[]}}const Su=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];async function Ka(e){if(!(!e.client||!e.connected)&&!e.openingHoursLoading){e.openingHoursLoading=!0,e.openingHoursError=null;try{const t=await e.client.request("business.openingHours.get",{});if(t.openingHours){const n=t.openingHours,i={};for(const s of Su){const o=n.schedule[s];o==null?i[s]={start:"09:00",end:"17:00",closed:!0}:i[s]={start:o.start,end:o.end,closed:!1}}e.openingHoursForm={enabled:n.enabled,publicAgentEnabled:t.publicAgentEnabled,days:i,closedDates:[...n.closedDates??[]].sort()}}else{const n=Wa();n.publicAgentEnabled=t.publicAgentEnabled,e.openingHoursForm=n}}catch(t){e.openingHoursError=String(t)}finally{e.openingHoursLoading=!1}}}async function Au(e){if(!(!e.client||!e.connected||e.openingHoursBusy)){e.openingHoursBusy=!0,e.openingHoursError=null;try{const t=e.openingHoursForm,n={};for(const a of Su){const r=t.days[a];n[a]=r!=null&&r.closed?null:{start:r.start,end:r.end}}const i=Intl.DateTimeFormat().resolvedOptions().timeZone,s={enabled:t.enabled,timezone:i,schedule:n,closedDates:t.closedDates.length>0?[...t.closedDates].sort():void 0},o=await e.client.request("config.get",{});await e.client.request("config.patch",{raw:JSON.stringify({business:{openingHours:s,publicAgentEnabled:t.publicAgentEnabled}}),baseHash:o.hash,note:"Opening hours updated"}),await Ka(e)}catch(t){e.openingHoursError=String(t)}finally{e.openingHoursBusy=!1}}}const Hk=Object.freeze(Object.defineProperty({__proto__:null,defaultOpeningHoursForm:Wa,loadOpeningHours:Ka,saveOpeningHours:Au},Symbol.toStringTag,{value:"Module"}));function qk(e,t="admin"){var s;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const i=[];for(const o of n){if(!o||typeof o!="object"||o.agentId!==t&&o.agentId!=="management")continue;const a=o.match;if(!a||typeof a!="object"||(a.channel??"").toLowerCase()!=="whatsapp")continue;const c=a.peer;if(!c||typeof c!="object"||c.kind!=="dm")continue;const d=c.id??"";d&&i.push({phone:d,paired:((s=o.meta)==null?void 0:s.paired)===!0})}return i.sort((o,a)=>o.paired&&!a.paired?-1:!o.paired&&a.paired?1:0),i}function Cu(e,t,n="admin",i){const s=d=>d===n||d==="management",o=new Map,a=new Map;for(const d of e){if(!d||typeof d!="object"||!s(d.agentId))continue;const h=d.match;if(!h||typeof h!="object"||(h.channel??"").toLowerCase()!=="whatsapp")continue;const p=h.peer;if(!p||typeof p!="object"||p.kind!=="dm")continue;const g=p.id??"";g&&(d.meta&&o.set(g,d.meta),h.accountId&&a.set(g,h.accountId))}const r=e.filter(d=>{if(!d||typeof d!="object"||!s(d.agentId))return!0;const h=d.match;if(!h||typeof h!="object"||(h.channel??"").toLowerCase()!=="whatsapp")return!0;const p=h.peer;return!p||typeof p!="object"?!0:p.kind!=="dm"}),c=t.map(d=>{const h=i??a.get(d.phone),l={channel:"whatsapp",peer:{kind:"dm",id:d.phone}};h&&(l.accountId=h);const p={agentId:n,match:l},g=o.get(d.phone);return g?p.meta=g:d.paired&&(p.meta={paired:!0}),p});return[...r,...c]}async function ms(e,t){if(!e.client||!e.connected)return;if(!t){e.adminPhones=[];return}if(e.adminsLoading)return;e.adminsLoading=!0,e.adminsError=null;const n=t;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.config;e.configForm=ct(s??{}),e.adminPhones=qk(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function Eu(e,t,n,i){var a,r;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n;let o=t.replace(/[\s\-\(\)]/g,"");if(!o){e.adminsError="Phone number is required";return}if(o.startsWith("+")||(o="+"+o),!/^\+[1-9]\d{6,14}$/.test(o)){e.adminsError="Invalid phone number. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(c=>c.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const c=ct(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),d=c.bindings??[],h=[...e.adminPhones,{phone:o}],l=Cu(d,h,s,i);lc(c,["bindings"],l);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const g=Et(c);await e.client.request("config.set",{raw:g,baseHash:p}),await ms(e,n)}catch(c){e.adminsError=String(c)}finally{e.adminsSaving=!1}}async function Tu(e,t,n,i){var a,r;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n,o=e.adminPhones.find(c=>c.phone===t);if(o!=null&&o.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const c=ct(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),d=c.bindings??[],h=e.adminPhones.filter($=>$.phone!==t),l=Cu(d,h,s,i);lc(c,["bindings"],l);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const g=Et(c);await e.client.request("config.set",{raw:g,baseHash:p}),await ms(e,n)}catch(c){e.adminsError=String(c)}finally{e.adminsSaving=!1}}const jk=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:Eu,loadAdmins:ms,removeAdmin:Tu},Symbol.toStringTag,{value:"Module"}));async function Lt(e,t){if(!(!e.client||!e.connected)){if(!t){e.contactsRecords=[];return}if(!e.contactsLoading){e.contactsLoading=!0,e.contactsError=null;try{const n=e.contactsSearchQuery.trim(),i=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.contactsRecords=i.records??[]}catch(n){e.contactsError=String(n)}finally{e.contactsLoading=!1}}}}async function _u(e,t,n,i){if(!e.client||!e.connected||e.contactsSaving)return;let s=t.replace(/[\s\-\(\)]/g,"");const o=n.trim();if(!s){e.contactsError="Phone number is required";return}if(!o){e.contactsError="Name is required";return}if(s.startsWith("+")||(s="+"+s),!/^\+[1-9]\d{6,14}$/.test(s)){e.contactsError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.set",{id:s,name:o,fields:{},workspace:i}),e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName="",await Lt(e,i)}catch(a){e.contactsError=String(a)}finally{e.contactsSaving=!1}}async function Mu(e,t,n){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.delete",{id:t}),e.contactsEditingId===t&&(e.contactsEditingId=null),await Lt(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function qo(e,t,n,i,s){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.setField",{id:t,key:n,value:i}),await Lt(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function Pu(e,t,n,i){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await Lt(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const Gk=Object.freeze(Object.defineProperty({__proto__:null,addContact:_u,deleteContact:Mu,deleteContactField:Pu,loadContacts:Lt,setContactField:qo},Symbol.toStringTag,{value:"Module"}));let xt=null,Pi=null,Ii=null;const go=[[0,"Checking Tailscale service..."],[5,"Starting login..."],[15,"Requesting authentication link..."],[40,"Setting up secure connection..."],[70,"Almost ready..."]];function zt(){xt&&(clearInterval(xt),xt=null),Pi&&(clearInterval(Pi),Pi=null),Ii&&(clearTimeout(Ii),Ii=null)}function Sn(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0},onRestartGateway:()=>e.handleGatewayRestart()}}function Vk(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},onRestartGateway:()=>e.handleGatewayRestart()}}function Qk(e){const t=ue(e);if(!t)return;const n=t.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return n==null?void 0:n.id}function Jk(e){const t=ue(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function Yk(e){var i;const t=ue(e);if(!t)return;const n=t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin");return(n==null?void 0:n.id)??((i=t.agents[0])==null?void 0:i.id)}function Xk(e){return e.selectedWorkspace??void 0}function ue(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const Zk=/^data:/i,e0=/^https?:\/\//i;function Dl(e){var r,c;const t=((r=e.agentsList)==null?void 0:r.agents)??[],n=Jl(e.sessionKey),i=(n==null?void 0:n.agentId)??((c=e.agentsList)==null?void 0:c.defaultId)??"main",s=t.find(d=>d.id===i),o=s==null?void 0:s.identity,a=(o==null?void 0:o.avatarUrl)??(o==null?void 0:o.avatar);if(a)return Zk.test(a)||e0.test(a)?a:o==null?void 0:o.avatarUrl}function t0(e){var i;if(!e)return null;const t=(i=e.channelAccounts)==null?void 0:i.whatsapp;if(!t||t.length===0)return null;const n=t[0];return{running:n.running??!1,connected:n.connected??!1,linked:n.linked??!1,lastError:n.lastError}}function n0(e){var a;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(a=e.channelAccounts)==null?void 0:a.imessage;if(!t||t.length===0)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const n=t[0],i=n.running??!1,s=n.probe,o=s!=null?s.ok===!0:i;return{configured:n.configured??!1,running:i,connected:o,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function i0(e){var a;const t=(a=e.configSnapshot)==null?void 0:a.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(r=>{var c,d;return((c=r.match)==null?void 0:c.channel)==="imessage"&&((d=r.meta)==null?void 0:d.imessageOwner)});if(!i)return null;const s=i.agentId;for(const r of e.workspaces)if(r.agents.some(c=>c.id===s))return r.name;if(s==="admin"||s==="public"){const r=e.workspaces.find(c=>c.isDefault);return(r==null?void 0:r.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const r=e.workspaces.find(c=>c.name===o);return(r==null?void 0:r.name)??null}return null}function s0(e){var t,n,i,s,o,a,r,c,d,h;if(e.embeddingDownloading&&!e.publicChat)return u`
4510
4622
  <div class="setup-container">
4511
4623
  <div class="setup-card" style="text-align:center; max-width:420px;">
4512
4624
  <div class="setup-spinner"></div>
@@ -4527,7 +4639,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4527
4639
  <p>Connecting...</p>
4528
4640
  </div>
4529
4641
  </div>
4530
- `;if(!e.publicChatAuthenticated)return kk({authMode:e.publicChatConfig.auth??"anonymous",authStep:e.publicChatAuthStep,connected:e.connected,client:e.client,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,accountId:e.publicChatConfig.accountId,cookieTtlDays:e.publicChatConfig.cookieTtlDays,otpChannels:e.publicChatConfig.otpChannels,verifyMethods:e.publicChatConfig.verifyMethods,onAuthenticated:$=>{var T;e.publicChatSessionKey=$,e.sessionKey=$,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const S=((T=e.publicChatConfig)==null?void 0:T.accountId)??"";e.chatMessage=Kn(S,$),le(async()=>{const{loadChatHistory:f}=await Promise.resolve().then(()=>Ni);return{loadChatHistory:f}},void 0,import.meta.url).then(({loadChatHistory:f})=>{f(e)})},onAuthStepChange:$=>{e.publicChatAuthStep=$},requestUpdate:()=>{e.requestUpdate()}});const d=(t=e.publicChatConfig)==null?void 0:t.greeting,p=e.chatMessages,g=!e.chatLoading&&d?[{role:"assistant",content:[{type:"text",text:d}],timestamp:0},...Array.isArray(p)?p:[]]:p;return Nw({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:g,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??Pl(e)??null,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,canAbort:!!e.chatRunId,disabledReason:e.connected?null:"Disconnected.",error:e.lastError,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,suggestions:e.chatSuggestions,onSuggestionClick:$=>{e.chatMessage=$,e.chatSuggestions=[],e.handleSendChat()},onRefresh:()=>(e.resetToolStream(),le(async()=>{const{loadChatHistory:$}=await Promise.resolve().then(()=>Ni);return{loadChatHistory:$}},void 0,import.meta.url).then(({loadChatHistory:$})=>{$(e)})),onDraftChange:$=>{var T;e.chatMessage=$;const S=((T=e.publicChatConfig)==null?void 0:T.accountId)??"";yr(S,e.sessionKey,$)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:$=>e.chatAttachments=$,onSend:()=>e.handleSendChat(),onAbort:()=>{e.handleAbortChat()},onQueueRemove:$=>e.removeQueuedMessage($),onChatScroll:$=>e.handleChatScroll($),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()}})}if(e.connected&&e.accessState.checked){const{accessState:d}=e;if(d.hasPins&&!d.authenticated)return wl({show:!0,isFirstTime:!1,accounts:d.accounts,error:d.error,busy:d.busy,onSubmit:(p,g)=>{g!=null&&e.handlePinSubmit(p,g)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(p,g,$)=>e.handleChangePin(p,g,$)});if(!d.hasMasterPin&&!d.authenticated&&e.setup)return wl({show:!0,isFirstTime:!0,accounts:[],error:d.error,busy:d.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!d.hasMasterPin&&!d.authenticated&&!e.setup)return window.location.href="/setup",w}if(e.setup){const d=Nk(e.channelsSnapshot),p=((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.whatsapp)??[],g=Ok(e.channelsSnapshot),$=Fk(e),S=async()=>{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null},T=()=>{const f=Date.now();e.tailscaleConnectProgress=0,e.tailscaleConnectMessage=fo[0][1],e.tailscaleConnectSuccess=!1,e.tailscaleError=null,zt(),xt=setInterval(()=>{const b=(Date.now()-f)/1e3,k=Math.min(95,95*(1-Math.exp(-b/30)));e.tailscaleConnectProgress=Math.round(k);let A=fo[0][1];for(const[E,M]of fo)b>=E&&(A=M);e.tailscaleConnectMessage=A},500)};return Kg({connected:e.connected,serverPlatform:((o=(s=e.hello)==null?void 0:s.server)==null?void 0:o.platform)??null,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:f=>e.handleLicenseKeyChange(f),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:d,whatsappAccounts:p,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:f=>e.handleUninstallConfirmTextChange(f),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:f=>e.handleAuthSubmitCode(f),onAuthCodeChange:f=>e.handleAuthCodeChange(f),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async f=>{await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await ee(e,!0),e.requestUpdate())},onWhatsAppUnlink:async f=>{await e.handleWhatsAppLogout(f)},onWhatsAppReset:async f=>{await e.handleWhatsAppLogout(f),await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await ee(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await ee(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),ee(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:f=>e.handleRemoveWhatsAppAccount(f),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:f=>{e.newWorkspacePin=f},onWorkspaceCreate:async(f,b)=>{const k=e.newWorkspacePin;await e.handleWorkspaceCreate(f,b),k.match(/^\d{4,6}$/)&&(await Ak(e,f,k),e.newWorkspacePin="")},onWorkspaceRemove:f=>e.handleWorkspaceRemove(f),onSetAddingWorkspace:f=>{e.addingWorkspace=f},onSetNewWorkspaceName:f=>{e.newWorkspaceName=f},onSetNewWorkspacePath:f=>{e.newWorkspacePath=f},onSetWorkspaceRemoveConfirm:f=>{e.workspaceRemoveConfirm=f},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(f,b)=>e.handleWorkspaceRename(f,b),whatsappDmPolicy:(()=>{const f=ue(e),b=f==null?void 0:f.whatsappAccountId,k=b?p.find(A=>A.accountId===b):p[0];return(k==null?void 0:k.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var P;const f=ue(e),b=f==null?void 0:f.whatsappAccountId,k=b?p.find(R=>R.accountId===b):p[0];if(!k)return;const E=k.dmPolicy!=null&&k.dmPolicy!=="disabled"?"disabled":"open",M=E==="open"?{dmPolicy:E,allowFrom:["*"]}:{dmPolicy:E};try{const R=await e.client.request("config.get"),F=R.config,H=(P=F==null?void 0:F.channels)==null?void 0:P.whatsapp,ke=((H==null?void 0:H.accounts)??{})[k.accountId]?{channels:{whatsapp:{accounts:{[k.accountId]:M}}}}:{channels:{whatsapp:M}};await e.client.request("config.patch",{raw:JSON.stringify(ke),baseHash:R.hash,note:`WhatsApp DM policy → ${E}`,skipRestart:!0}),await ee(e,!1)}catch(R){console.error("DM toggle failed:",R)}},whatsappModel:(()=>{var P,R;const f=ue(e);if(!f)return null;const b=f.agents.find(F=>F.id.endsWith("-public")||F.id==="public");if(!b)return null;const k=(P=e.configSnapshot)==null?void 0:P.config,A=(R=k==null?void 0:k.agents)==null?void 0:R.list;if(!Array.isArray(A))return null;const E=A.find(F=>F.id===b.id);if(!(E!=null&&E.model))return null;const M=typeof E.model=="string"?E.model:E.model.primary;return(M==null?void 0:M.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async f=>{const b=ue(e);if(!b)return;const k=b.agents.find(A=>A.id.endsWith("-public")||A.id==="public");if(k)try{const A=await e.client.request("config.get"),E=A.config,M=(E==null?void 0:E.agents)??{},P=Array.isArray(M.list)?[...M.list]:[],R=P.findIndex(H=>H.id===k.id);if(f)R>=0?P[R]={...P[R],model:f}:P.push({id:k.id,model:f});else if(R>=0){const{model:H,...z}=P[R];Object.keys(z).length<=1?P.splice(R,1):P[R]=z}const F=P.length>0?{agents:{list:P}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(F),baseHash:A.hash,note:`Public agent model → ${f||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Model change failed:",A)}},whatsappThinkingLevel:(()=>{var M,P,R;const f=ue(e);if(!f)return null;const b=f.agents.find(F=>F.id.endsWith("-public")||F.id==="public");if(!b)return null;const k=(M=e.configSnapshot)==null?void 0:M.config,A=(P=k==null?void 0:k.agents)==null?void 0:P.list;if(!Array.isArray(A))return null;const E=A.find(F=>F.id===b.id);return((R=E==null?void 0:E.thinkingLevel)==null?void 0:R.trim())||null})(),onWhatsAppThinkingChange:async f=>{const b=ue(e);if(!b)return;const k=b.agents.find(A=>A.id.endsWith("-public")||A.id==="public");if(k)try{const A=await e.client.request("config.get"),E=A.config,M=(E==null?void 0:E.agents)??{},P=Array.isArray(M.list)?[...M.list]:[],R=P.findIndex(z=>z.id===k.id),F=f==="off"?void 0:f;if(F)R>=0?P[R]={...P[R],thinkingLevel:F}:P.push({id:k.id,thinkingLevel:F});else if(R>=0){const{thinkingLevel:z,...ke}=P[R];Object.keys(ke).length<=1?P.splice(R,1):P[R]=ke}const H=P.length>0?{agents:{list:P}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(H),baseHash:A.hash,note:`Public agent thinking → ${F||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Thinking change failed:",A)}},whatsappGroupPolicy:(()=>{var R,F;const f=(R=e.configSnapshot)==null?void 0:R.config,b=(F=f==null?void 0:f.channels)==null?void 0:F.whatsapp,k=ue(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},M=A?E[A]:void 0;return(M==null?void 0:M.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var F,H;const f=(F=e.configSnapshot)==null?void 0:F.config,b=(H=f==null?void 0:f.channels)==null?void 0:H.whatsapp,k=ue(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},M=A?E[A]:void 0,R=((M==null?void 0:M.groups)??(b==null?void 0:b.groups)??{})["*"];return(R==null?void 0:R.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var k;const f=ue(e),b=f==null?void 0:f.whatsappAccountId;try{const A=await e.client.request("config.get"),E=A.config,M=((k=E==null?void 0:E.channels)==null?void 0:k.whatsapp)??{},P=M.accounts??{},R=b?P[b]:void 0,F=(R==null?void 0:R.groupPolicy)??M.groupPolicy??"allowlist",H=F==="disabled"||F==="allowlist",z=H?"open":"disabled",ke=H?{"*":{}}:void 0,_e={groupPolicy:z};ke&&(_e.groups=ke);const Ke=R?{channels:{whatsapp:{accounts:{[b]:_e}}}}:{channels:{whatsapp:_e}};await e.client.request("config.patch",{raw:JSON.stringify(Ke),baseHash:A.hash,note:`WhatsApp groups → ${z}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group toggle failed:",A)}},onWhatsAppGroupMentionChange:async f=>{var A;const b=ue(e),k=b==null?void 0:b.whatsappAccountId;try{const E=await e.client.request("config.get"),M=E.config,R=(((A=M==null?void 0:M.channels)==null?void 0:A.whatsapp)??{}).accounts??{},F=k?R[k]:void 0,H={"*":{requireMention:f}},z=F?{channels:{whatsapp:{accounts:{[k]:{groups:H}}}}}:{channels:{whatsapp:{groups:H}}};await e.client.request("config.patch",{raw:JSON.stringify(z),baseHash:E.hash,note:`WhatsApp group mention → ${f?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(E){console.error("Group mention change failed:",E)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:g.configured,imessageRunning:g.running,imessageConnected:g.connected,imessageLastError:g.lastError,imessageSelfChatMode:g.selfChatMode,imessageCliPath:g.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:$,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,k=(b==null?void 0:b.bindings)??[],A=ue(e),E=A==null?void 0:A.agents.find(H=>H.id.endsWith("-admin")||H.id==="admin"),M=(E==null?void 0:E.id)??"admin",P=k.filter(H=>{var z;return((z=H.match)==null?void 0:z.channel)!=="imessage"}),R=[{agentId:M,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],F=[...P,...R];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:F}),baseHash:f.hash,note:"Enable iMessage (self-chat) for "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Ue(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await ee(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,A=((b==null?void 0:b.bindings)??[]).filter(E=>{var M;return((M=E.match)==null?void 0:M.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:A}),baseHash:f.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Ue(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,k=(b==null?void 0:b.bindings)??[],A=ue(e),E=A==null?void 0:A.agents.find(F=>F.id.endsWith("-admin")||F.id==="admin"),M=(E==null?void 0:E.id)??"admin",P=k.filter(F=>{var H;return((H=F.match)==null?void 0:H.channel)!=="imessage"}),R=[{agentId:M,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:[...P,...R]}),baseHash:f.hash,note:"Reassign iMessage to "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Ue(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:f=>{var b,k,A,E;if(e.infoModalOpen=f,f==="remote-access"){const M=((b=e.tailscaleStatus)==null?void 0:b.tailnetUrl)??((k=e.tailscaleStatus)!=null&&k.hostname?`https://${e.tailscaleStatus.hostname}`:null);M&&!e.remoteAccessQrDataUrl&&e.client.request("qr.generate",{url:M}).then(P=>{e.remoteAccessQrDataUrl=(P==null?void 0:P.dataUrl)??null}).catch(()=>{})}else if(f==="public-chat"){const M=((A=e.tailscaleStatus)==null?void 0:A.publicUrl)??((E=e.tailscaleStatus)==null?void 0:E.tailnetUrl)??null,P=e.selectedWorkspace??null;if(M&&P){const R=`${M}/public/chat/${encodeURIComponent(P)}`;e.publicChatQrDataUrl||e.client.request("qr.generate",{url:R}).then(F=>{e.publicChatQrDataUrl=(F==null?void 0:F.dataUrl)??null}).catch(()=>{})}}},onInfoModalClose:()=>{e.infoModalOpen=null},remoteAccessQrDataUrl:e.remoteAccessQrDataUrl??null,publicChatQrDataUrl:e.publicChatQrDataUrl??null,publicChatFullUrl:(()=>{var k,A;const f=((k=e.tailscaleStatus)==null?void 0:k.publicUrl)??((A=e.tailscaleStatus)==null?void 0:A.tailnetUrl)??null,b=e.selectedWorkspace??null;return!f||!b?null:`${f}/public/chat/${encodeURIComponent(b)}`})(),isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,apiKeySavingProvider:e.apiKeySavingProvider,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeySave:async(f,b)=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await $l(e.client,f,b);const k=`${f} key saved`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}f==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async f=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await ik(e.client,f);const b=`${f} key removed`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyDisable:async(f,b)=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await sk(e.client,f,b);const k=`${f} ${b?"disabled":"enabled"}`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:`Failed to ${b?"disable":"enable"} key`,e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:f=>{e.authApiKeyInput=f},onAuthApiKeySubmit:async()=>{const f=e.authApiKeyInput.trim();if(f){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await $l(e.client,"anthropic",f),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(b){e.authApiKeyError=b instanceof Error?b.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var b;const f=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return f?e.accessState.accounts.some(k=>k.id===f):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(f,b)=>{var A;const k=e.selectedWorkspace??((A=e.workspaces[0])==null?void 0:A.name);k&&e.handleAccountPinSave(k,f,b)},publicChatAccountId:e.selectedWorkspace??null,publicChatSettingsOpen:e.publicChatSettingsOpen,onPublicChatSettingsOpen:()=>{e.publicChatSettingsOpen=!0},onPublicChatSettingsClose:()=>{e.publicChatSettingsOpen=!1},publicChatWidgetModalOpen:e.publicChatWidgetModalOpen,onPublicChatWidgetModalOpen:()=>{e.publicChatWidgetModalOpen=!0},onPublicChatWidgetModalClose:()=>{e.publicChatWidgetModalOpen=!1},publicChatEnabled:(()=>{var k;const f=(k=e.configSnapshot)==null?void 0:k.config,b=f==null?void 0:f.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var M,P;const f=(M=e.configSnapshot)==null?void 0:M.config,b=f==null?void 0:f.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.auth)??(b==null?void 0:b.auth);return E==="verified"||E==="choice"?E:"anonymous"})(),publicChatGreeting:(()=>{var E;const f=(E=e.configSnapshot)==null?void 0:E.config,b=f==null?void 0:f.publicChat,k=b==null?void 0:b.greetings,A=e.selectedWorkspace??"";return(A&&(k==null?void 0:k[A]))??""})(),publicChatGreetingBusy:e.publicChatGreetingBusy,onPublicChatGreetingToggle:async()=>{var b;if(e.publicChatGreetingBusy)return;const f=e.selectedWorkspace??"";if(f){e.publicChatGreetingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=(b=A==null?void 0:A.publicChat)==null?void 0:b.greetings;if(E==null?void 0:E[f]){const P={publicChat:{greetings:{[f]:null}}};await e.client.request("config.patch",{raw:JSON.stringify(P),baseHash:k.hash,note:`Public chat greeting → disabled (${f})`,skipRestart:!0})}else{const P=await e.client.request("public.greeting.generate",{accountId:f});if(P!=null&&P.ok&&P.greeting){const R=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[f]:P.greeting}}}),baseHash:R.hash,note:`Public chat greeting → enabled (${f})`,skipRestart:!0})}}e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting toggle failed:",k)}finally{e.publicChatGreetingBusy=!1}}},onPublicChatGreetingSave:async f=>{const b=e.selectedWorkspace??"";if(b)try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[b]:f}}}),baseHash:k.hash,note:`Public chat greeting text updated (${b})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting save failed:",k)}},onPublicChatGreetingRegenerate:async()=>{if(e.publicChatGreetingBusy)return;const f=e.selectedWorkspace??"";if(f){e.publicChatGreetingBusy=!0;try{const b=await e.client.request("public.greeting.generate",{accountId:f});if(b!=null&&b.ok&&b.greeting){const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[f]:b.greeting}}}),baseHash:k.hash,note:`Public chat greeting regenerated (${f})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}}catch(b){console.error("Public chat greeting regeneration failed:",b)}finally{e.publicChatGreetingBusy=!1}}},publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var f;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),k=b.config,A=((f=k==null?void 0:k.publicChat)==null?void 0:f.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!A}}),baseHash:b.hash,note:`Public chat → ${A?"disabled":"enabled"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get"),e.publicChatQrDataUrl=null}catch(b){console.error("Public chat toggle failed:",b)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async f=>{if(e.publicChatToggleBusy)return;const b=e.selectedWorkspace??"";if(b){e.publicChatToggleBusy=!0;try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{accountSettings:{[b]:{auth:f}}}}),baseHash:k.hash,note:`Public chat auth → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat auth mode change failed:",k)}finally{e.publicChatToggleBusy=!1}}},publicChatEmailFrom:(()=>{var k,A;const f=(k=e.configSnapshot)==null?void 0:k.config,b=(A=f==null?void 0:f.publicChat)==null?void 0:A.email;return(b==null?void 0:b.from)??""})(),publicChatEmailBusy:e.publicChatEmailBusy,publicChatVerifyMethods:(()=>{var M,P;const f=(M=e.configSnapshot)==null?void 0:M.config,b=f==null?void 0:f.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.verifyMethods)??(b==null?void 0:b.verifyMethods);return Array.isArray(E)?E:["whatsapp","sms"]})(),onPublicChatEmailSave:async(f,b)=>{if(e.publicChatEmailBusy)return;const k=e.selectedWorkspace??"";if(k){e.publicChatEmailBusy=!0;try{const A=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{email:{from:f||void 0},accountSettings:{[k]:{verifyMethods:b}}}}),baseHash:A.hash,note:"Update email verification settings for public chat",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Email verification save failed:",A)}finally{e.publicChatEmailBusy=!1}}},brandAccentColor:(()=>{var k;const f=e.selectedWorkspace;return f?((k=Be()[f])==null?void 0:k.accentColor)??"":""})(),brandBackgroundColor:(()=>{var k;const f=e.selectedWorkspace;return f?((k=Be()[f])==null?void 0:k.backgroundColor)??"":""})(),brandHasLogo:(()=>{var k;const f=e.selectedWorkspace;return f?!!((k=Be()[f])!=null&&k.logoUrl):!1})(),brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async f=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,M=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=M.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...M,brand:{...P,accentColor:f}}}}),baseHash:A.hash,note:`Brand accent → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const R=Be();R[b]||(R[b]={}),R[b].accentColor=f,Tn(b)}catch(A){console.error("Brand accent change failed:",A)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async f=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,M=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=M.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...M,brand:{...P,backgroundColor:f}}}}),baseHash:A.hash,note:`Brand background → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const R=Be();R[b]||(R[b]={}),R[b].backgroundColor=f,Tn(b)}catch(A){console.error("Brand background change failed:",A)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async f=>{const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const k=await f.arrayBuffer(),A=new Uint8Array(k);let E="";for(let R=0;R<A.length;R++)E+=String.fromCharCode(A[R]);const M=btoa(E);await e.client.request("brand.uploadLogo",{workspace:b,data:M,mimeType:f.type});const P=Be();P[b]||(P[b]={}),P[b].logoUrl=`/brand-logo/${encodeURIComponent(b)}`}catch(k){console.error("Brand logo upload failed:",k)}finally{e.brandingBusy=!1}}},onBrandLogoRemove:async()=>{const f=e.selectedWorkspace;if(!(!f||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:f});const b=Be();b[f]&&delete b[f].logoUrl}catch(b){console.error("Brand logo remove failed:",b)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var b;const f=e.selectedWorkspace;if(!(!f||e.brandingBusy)){e.brandingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=((b=A==null?void 0:A.workspaces)==null?void 0:b[f])??{},{brand:M,...P}=E;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[f]:{...P,brand:null}}}),baseHash:k.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:f})}catch{}const R=Be();delete R[f],Tn(f)}catch(k){console.error("Brand reset failed:",k)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleServeEnableUrl:e.tailscaleServeEnableUrl,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,tailscaleDisableConfirm:e.tailscaleDisableConfirm,tailscaleConnectProgress:e.tailscaleConnectProgress,tailscaleConnectMessage:e.tailscaleConnectMessage,tailscaleConnectSuccess:e.tailscaleConnectSuccess,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null,T();try{const f=await e.client.request("tailscale.enable");f.authUrl?(xt&&(clearInterval(xt),xt=null),e.tailscaleConnectProgress=100,e.tailscaleConnectMessage="Waiting for authentication...",e.tailscaleAuthUrl=f.authUrl,Mi=setInterval(async()=>{try{const b=await e.client.request("tailscale.status");e.tailscaleStatus=b,e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,b.loggedIn&&(zt(),e.tailscaleAuthUrl=null,e.tailscaleConnectSuccess=!0,e.tailscaleConnectMessage="Connected!",setTimeout(()=>{e.tailscaleConnectSuccess=!1,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1},1500))}catch{}},3e3),Pi=setTimeout(()=>{zt(),e.tailscaleBusy&&(e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)},3e5)):f.alreadyLoggedIn?(zt(),e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1):(zt(),e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)}catch(f){console.error("Tailscale enable failed:",f),zt(),e.tailscaleError=f.message||"Failed to enable Remote Access",e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1}}},onTailscaleErrorDismiss:()=>{e.tailscaleError=null},onTailscaleServeEnable:async()=>{var f;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleServeEnableUrl=null;try{await e.client.request("tailscale.serve.enable"),await S()}catch(b){console.error("Tailscale serve enable failed:",b);const k=b;(f=k.payload)!=null&&f.enableUrl&&(e.tailscaleServeEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Remote Access"}finally{e.tailscaleBusy=!1}}},onTailscaleServeDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.serve.disable"),await S()}catch(f){console.error("Tailscale serve disable failed:",f)}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var f;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable"),await S()}catch(b){console.error("Tailscale funnel enable failed:",b);const k=b;(f=k.payload)!=null&&f.enableUrl&&(e.tailscaleFunnelEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Funnel"}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable"),await S()}catch(f){console.error("Tailscale funnel disable failed:",f)}finally{e.tailscaleBusy=!1}}},onTailscaleDisableConfirmToggle:()=>{e.tailscaleDisableConfirm=!e.tailscaleDisableConfirm},wifiModalOpen:e.wifiModalOpen,onWifiModalToggle:()=>{e.wifiModalOpen=!e.wifiModalOpen,e.wifiModalOpen||(e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null)},wifiStatus:e.wifiStatus,wifiNetworks:e.wifiNetworks,wifiBusy:e.wifiBusy,wifiError:e.wifiError,wifiPassword:e.wifiPassword,wifiSelectedSsid:e.wifiSelectedSsid,onWifiScan:async()=>{var f;if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[b,k]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiNetworks=b.networks,k.connected&&k.signal==null&&((f=b.networks)!=null&&f.length)){const A=b.networks.find(E=>E.active)||b.networks.find(E=>E.ssid===k.ssid);A&&(k.signal=A.signal)}e.wifiStatus=k}catch(b){console.error("WiFi scan failed:",b),e.wifiError=b.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{var b;if(e.wifiBusy||!e.wifiSelectedSsid)return;const f=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const k=await e.client.request("wifi.connect",{ssid:f,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:k.connected,ssid:k.ssid,signal:null,ip:k.ip,savedSsid:k.ssid,autoconnect:!0},e.wifiBusy=!1;try{const[A,E]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(E.connected&&E.signal==null&&((b=A.networks)!=null&&b.length)){const M=A.networks.find(P=>P.active)||A.networks.find(P=>P.ssid===E.ssid);M&&(E.signal=M.signal)}e.wifiStatus=E}catch{}}catch(k){console.error("WiFi connect failed:",k),e.wifiError=k.message||"Failed to connect",e.wifiBusy=!1}},onWifiDisconnect:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.disconnect"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi disconnect failed:",f),e.wifiError=f.message||"Failed to disconnect"}finally{e.wifiBusy=!1}}},onWifiForget:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.forget"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi forget failed:",f),e.wifiError=f.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:f=>{e.wifiSelectedSsid=f,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:f=>{e.wifiPassword=f},networkPort:e.networkPort,networkHostname:e.networkHostname,networkPortInput:e.networkPortInput,networkHostnameInput:e.networkHostnameInput,networkModalOpen:e.networkModalOpen,networkBusy:e.networkBusy,networkError:e.networkError,networkSuccess:e.networkSuccess,onNetworkModalToggle:()=>{e.networkModalOpen=!e.networkModalOpen,e.networkModalOpen&&(e.networkPortInput=String(e.networkPort??""),e.networkHostnameInput=e.networkHostname,e.networkError=null,e.networkSuccess=null)},onNetworkPortChange:f=>{e.networkPortInput=f,e.networkError=null,e.networkSuccess=null},onNetworkHostnameChange:f=>{e.networkHostnameInput=f,e.networkError=null,e.networkSuccess=null},onNetworkSave:async()=>{if(e.networkBusy)return;e.networkBusy=!0,e.networkError=null,e.networkSuccess=null;const f=e.networkPortInput.trim(),b=Number.parseInt(f,10),k=e.networkHostnameInput.trim();if(!f||!Number.isFinite(b)||b<1024||b>65535){e.networkError="Port must be a number between 1024 and 65535",e.networkBusy=!1;return}const A=b!==e.networkPort,E=k!==e.networkHostname;if(!A&&!E){e.networkBusy=!1;return}try{E&&await e.client.request("network.setHostname",{hostname:k});const M={};A&&(M.gateway={port:b}),E&&(M.discovery={bonjourHostname:k});const P=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify(M),baseHash:P.hash,note:[A?`Port → ${b}`:null,E?`Hostname → ${k}`:null].filter(Boolean).join(", "),restartDelayMs:2e3}),e.networkSuccess="Saved — redirecting...";const R=window.location.protocol,F=E?`${k}.local`:window.location.hostname,H=A?b:e.networkPort,z=`${R}//${F}:${H}/setup`;setTimeout(()=>{window.location.href=z},1500)}catch(M){console.error("Network save failed:",M),e.networkError=M.message||"Failed to save network settings",e.networkBusy=!1}},wsProps:Mk(e)})}if(e.filesPage){const d=Lk(e);return ig({connected:e.connected,wsProps:Sn(e),loading:e.filesLoading,tree:e.filesTree,root:e.filesRoot,error:e.filesError,selectedPath:e.filesSelectedPath,selectedPaths:e.filesSelectedPaths,previewContent:e.filesPreviewContent,previewLoading:e.filesPreviewLoading,previewBinary:e.filesPreviewBinary,previewSize:e.filesPreviewSize,expandedDirs:e.filesExpandedDirs,currentDir:e.filesCurrentDir,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>{an(e,d),ls(e,d)},onReindex:()=>yf(e,d),onSelectFile:p=>{e.filesPendingDeletePath=null,cf(e,p,d)},onToggleSelectFile:p=>df(e,p,d),onToggleDir:p=>vf(e,p),onUpload:(p,g)=>hf(e,p,g,d),onNewFolder:(p,g)=>ff(e,p,g,d),onDownload:p=>Zc(e,p,d),onBulkDownload:()=>uf(e,d),onDelete:p=>{e.filesPendingDeletePath=null,gf(e,p,d)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,g)=>pf(e,p,g,d),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const g=e.filesSearchAgentId??d;bf(e,p,g)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{wf(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return Yf({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:()=>Qw(e),onStop:()=>Jw(e),onToggleInput:()=>Xw(e),onToggleFullscreen:()=>Zw(e),onCompleteHandoff:()=>Yw(e),onCanvasMouseDown:d=>{const g=d.target.getBoundingClientRect(),S=Bn().translateCoordinates(d.clientX-g.left,d.clientY-g.top);co(e,"mousePressed",S.x,S.y,d.button===2?"right":d.button===1?"middle":"left")},onCanvasMouseUp:d=>{const g=d.target.getBoundingClientRect(),S=Bn().translateCoordinates(d.clientX-g.left,d.clientY-g.top);co(e,"mouseReleased",S.x,S.y)},onCanvasMouseMove:d=>{const p=Bn();if(p.shouldThrottleMouseMove())return;const $=d.target.getBoundingClientRect(),S=p.translateCoordinates(d.clientX-$.left,d.clientY-$.top);co(e,"mouseMoved",S.x,S.y)},onCanvasKeyDown:d=>{let p=0;d.altKey&&(p|=1),d.ctrlKey&&(p|=2),d.metaKey&&(p|=4),d.shiftKey&&(p|=8),uo(e,"keyDown",d.key,{code:d.code,modifiers:p||void 0}),d.key.length===1&&uo(e,"char",d.key,{text:d.key})},onCanvasKeyUp:d=>{uo(e,"keyUp",d.key,{code:d.code})}});if(e.adminsPage){const d=Pk(e),p=Ik(e);return qg({connected:e.connected,wsProps:Sn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>gs(e,d),onAdd:g=>{ku(e,g,d,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:g=>xu(e,g,d,p),onNewPhoneChange:g=>e.handleAdminsNewPhoneChange(g)})}if(e.contactsPage){const d=Rk(e);return Jg({connected:e.connected,wsProps:Sn(e),loading:e.contactsLoading,saving:e.contactsSaving,records:e.contactsRecords,error:e.contactsError,searchQuery:e.contactsSearchQuery,editingId:e.contactsEditingId,showAddForm:e.contactsShowAddForm,newRecordPhone:e.contactsNewPhone,newRecordName:e.contactsNewName,deleteConfirmId:e.contactsDeleteConfirmId,addFieldForId:e.contactsAddFieldForId,addFieldKey:e.contactsAddFieldKey,addFieldValue:e.contactsAddFieldValue,onSearch:p=>e.contactsSearchQuery=p,onSearchSubmit:()=>Lt(e,d),onAdd:(p,g)=>$u(e,p,g,d),onDelete:p=>Su(e,p,d),onSetField:(p,g,$)=>qo(e,p,g,$,d),onDeleteField:(p,g)=>Au(e,p,g,d),onToggleExpand:p=>{e.contactsEditingId=e.contactsEditingId===p?null:p},onShowAddForm:()=>e.contactsShowAddForm=!0,onCancelAddForm:()=>{e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName=""},onNewRecordPhoneChange:p=>e.handleContactsNewPhoneChange(p),onNewRecordNameChange:p=>e.handleContactsNewNameChange(p),onRefresh:()=>Lt(e,d),onDeleteConfirmOpen:p=>e.contactsDeleteConfirmId=p,onDeleteConfirmClose:()=>e.contactsDeleteConfirmId=null,onAddFieldOpen:p=>{e.contactsAddFieldForId=p,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldClose:()=>{e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldKeyChange:p=>e.contactsAddFieldKey=p,onAddFieldValueChange:p=>e.contactsAddFieldValue=p,onAddFieldSubmit:()=>{const p=e.contactsAddFieldForId,g=e.contactsAddFieldKey.trim();!p||!g||(qo(e,p,g,e.contactsAddFieldValue,d),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const d=e.connected?null:"Disconnected from gateway.",p=Pl(e),g=e.chatAvatarUrl??p??null,$=(()=>{var f;const S=(f=e.configSnapshot)==null?void 0:f.config,T=S==null?void 0:S.publicChat;return(T==null?void 0:T.enabled)===!0})();return Qb({connected:e.connected,wsProps:Sn(e),publicChatEnabled:$,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:S=>{const T=e.selectedWorkspace??"";vo(),Wn(T,e.sessionKey,e.chatMessage),e.sessionKey=S,e.chatMessage=Kn(T,S),e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestions=[],e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:S,lastActiveSessionKey:S}),e.loadAssistantIdentity(),Oe(e),Ao(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:S=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{model:S}).then(()=>{Oe(e,{limit:T})})},onThinkingLevelChange:S=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{thinkingLevel:S==="off"?null:S}).then(()=>{Oe(e,{limit:T})})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestions:e.chatSuggestions,onSuggestionClick:S=>{e.chatMessage=S,e.chatSuggestions=[],e.handleSendChat()},onVerboseChange:S=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{verboseLevel:S==="off"?null:S}).then(()=>{Oe(e,{limit:T})})},onFillerChange:S=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{fillerEnabled:S}).then(()=>{Oe(e,{limit:T})})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:g,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:d,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const S=Math.max(e.chatMessages.length+10,Fe);return Promise.all([Oe(e,{limit:S}),Ao(e)])},onToggleFocusMode:()=>{},onChatScroll:S=>e.handleChatScroll(S),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:S=>{e.chatMessage=S,yr(e.selectedWorkspace??"",e.sessionKey,S)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:S=>e.chatAttachments=S,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:S=>e.removeQueuedMessage(S),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:S=>e.handleOpenSidebar(S),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:S=>e.handleSplitRatioChange(S),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?Bw({connected:e.connected,wsProps:Sn(e),activeTab:e.advancedTab,onTabChange:d=>{e.advancedTab=d,d==="cron"&&e.loadCron(),d==="skills"&&Xe(e,{clearMessages:!0}),d==="logs"&&(e.logsSubTab==="session"?Pn(e,{reset:!0}):Vt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(a=e.channelsSnapshot)==null?void 0:a.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(d=>d.id):((l=e.channelsSnapshot)==null?void 0:l.channelOrder)??[],channelLabels:((c=e.channelsSnapshot)==null?void 0:c.channelLabels)??{},channelMeta:((h=e.channelsSnapshot)==null?void 0:h.channelMeta)??[],agentIds:(()=>{var p;const d=ue(e);return((p=d==null?void 0:d.agents)==null?void 0:p.map(g=>g.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1,e.cronEditJobId=null},detailJobId:e.cronDetailJobId,editJobId:e.cronEditJobId,onDetailOpen:d=>{e.cronDetailJobId=d.id,wo(e,d.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:d=>{e.cronForm=hh(d),e.cronEditJobId=d.id,e.cronDetailJobId=null},onEditSave:()=>{const d=e.cronEditJobId;d&&fh(e,d).then(()=>{e.cronEditJobId=null})},onFormChange:d=>e.cronForm={...e.cronForm,...d},onRefresh:()=>e.loadCron(),onAdd:()=>{lh(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(d,p)=>ch(e,d,p),onRun:d=>dh(e,d),onRemove:d=>{e.cronPendingDeleteId=null,ph(e,d)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:d=>{e.cronPendingDeleteId=d||null},onLoadRuns:d=>wo(e,d),runModalJobId:e.cronRunModalJobId,runModalJobName:e.cronRunModalJobName,runResult:e.cronRunResult,onRunModalClose:()=>{e.cronRunModalJobId=null,e.cronRunModalJobName="",e.cronRunResult=null}},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,typeFilter:e.skillsTypeFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,detail:e.skillDetail,detailTab:e.skillDetailTab,addModal:e.skillAddModal,addForm:e.skillAddForm,formSource:e.skillAddFormSource,editTab:e.skillEditTab,drafts:e.skillDrafts,onFilterChange:d=>e.skillsFilter=d,onTypeFilterChange:d=>e.skillsTypeFilter=d,onRefresh:()=>Xe(e,{clearMessages:!0}),onToggle:(d,p)=>Pc(e,d,p),onEdit:(d,p)=>Mc(e,d,p),onSaveKey:d=>Ic(e,d),onInstall:(d,p,g)=>Lc(e,d,p,g),onViewDetail:d=>Rc(e,d),onDetailClose:()=>Dc(e),onDetailTab:d=>Bc(e,d),onAddOpen:()=>Nc(e),onAddClose:()=>Oc(e),onImportDraft:d=>Fc(e,d),onInstallDraft:d=>Uc(e,d),onDeleteDraft:d=>Wc(e,d),onAddSave:()=>la(e),onAddFormUpdate:(d,p)=>{e.skillAddForm={...e.skillAddForm,[d]:p}},onDelete:d=>jc(e,d),onEditSkill:d=>Kc(e,d),onEditDetail:d=>zc(e,d),onRefUpdate:(d,p)=>qc(e,d,p),onEditTab:d=>Hc(e,d)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:d=>{e.logsSubTab=d,d==="session"?Pn(e,{reset:!0}):Vt(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,chipsExpanded:e.sessionLogsChipsExpanded,expandedIds:e.sessionLogsExpandedIds,onFilterTextChange:d=>e.sessionLogsFilterText=d,onTypeToggle:(d,p)=>{const g=e;g.sessionLogsTypeFilters={...g.sessionLogsTypeFilters,[d]:p}},onAgentToggle:(d,p)=>{const g=e;g.sessionLogsAgentFilters={...g.sessionLogsAgentFilters,[d]:p}},onToggleAutoFollow:d=>e.sessionLogsAutoFollow=d,onToggleChips:()=>{const d=e;d.sessionLogsChipsExpanded=!d.sessionLogsChipsExpanded},onToggleExpand:d=>{const p=e,g=new Set(p.sessionLogsExpandedIds);g.has(d)?g.delete(d):g.add(d),p.sessionLogsExpandedIds=g,p.requestUpdate()},onRefresh:()=>{Pn(e,{reset:!0})},onExport:(d,p)=>e.exportSessionLogs(d,p),onScroll:d=>e.handleSessionLogsScroll(d)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,chipsExpanded:e.logsChipsExpanded,truncated:e.logsTruncated,onFilterTextChange:d=>e.logsFilterText=d,onLevelToggle:(d,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[d]:p}},onToggleAutoFollow:d=>e.logsAutoFollow=d,onToggleChips:()=>{const d=e;d.logsChipsExpanded=!d.logsChipsExpanded},onRefresh:()=>Vt(e,{reset:!0}),onExport:(d,p)=>e.exportSessionLogs(d,p),onScroll:d=>e.handleLogsScroll(d)}}):(window.location.replace("/chat"),u``)}function Wk(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${i}`}function Il(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Kk(e,t,n){return u`
4642
+ `;if(!e.publicChatAuthenticated)return Ok({authMode:e.publicChatConfig.auth??"anonymous",authStep:e.publicChatAuthStep,connected:e.connected,client:e.client,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,accountId:e.publicChatConfig.accountId,cookieTtlDays:e.publicChatConfig.cookieTtlDays,otpChannels:e.publicChatConfig.otpChannels,verifyMethods:e.publicChatConfig.verifyMethods,onAuthenticated:$=>{var T;e.publicChatSessionKey=$,e.sessionKey=$,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const S=((T=e.publicChatConfig)==null?void 0:T.accountId)??"";e.chatMessage=Kn(S,$),ae(async()=>{const{loadChatHistory:f}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:f}},void 0,import.meta.url).then(({loadChatHistory:f})=>{f(e)})},onAuthStepChange:$=>{e.publicChatAuthStep=$},requestUpdate:()=>{e.requestUpdate()}});const l=(t=e.publicChatConfig)==null?void 0:t.greeting,p=e.chatMessages,g=!e.chatLoading&&l?[{role:"assistant",content:[{type:"text",text:l}],timestamp:0},...Array.isArray(p)?p:[]]:p;return Zw({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:g,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??Dl(e)??null,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,canAbort:!!e.chatRunId,disabledReason:e.connected?null:"Disconnected.",error:e.lastError,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,suggestions:e.chatSuggestions,onSuggestionClick:$=>{e.chatMessage=$,e.chatSuggestions=[],e.handleSendChat()},onRefresh:()=>(e.resetToolStream(),ae(async()=>{const{loadChatHistory:$}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:$}},void 0,import.meta.url).then(({loadChatHistory:$})=>{$(e)})),onDraftChange:$=>{var T;e.chatMessage=$;const S=((T=e.publicChatConfig)==null?void 0:T.accountId)??"";wr(S,e.sessionKey,$)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:$=>e.chatAttachments=$,onSend:()=>e.handleSendChat(),onAbort:()=>{e.handleAbortChat()},onQueueRemove:$=>e.removeQueuedMessage($),onChatScroll:$=>e.handleChatScroll($),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()}})}if(e.connected&&e.accessState.checked){const{accessState:l}=e;if(l.hasPins&&!l.authenticated)return $l({show:!0,isFirstTime:!1,accounts:l.accounts,error:l.error,busy:l.busy,onSubmit:(p,g)=>{g!=null&&e.handlePinSubmit(p,g)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(p,g,$)=>e.handleChangePin(p,g,$)});if(!l.hasMasterPin&&!l.authenticated&&e.setup)return $l({show:!0,isFirstTime:!0,accounts:[],error:l.error,busy:l.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!l.hasMasterPin&&!l.authenticated&&!e.setup)return window.location.href="/setup",w}if(e.setup){const l=t0(e.channelsSnapshot),p=((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.whatsapp)??[],g=n0(e.channelsSnapshot),$=i0(e),S=async()=>{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null},T=()=>{const f=Date.now();e.tailscaleConnectProgress=0,e.tailscaleConnectMessage=go[0][1],e.tailscaleConnectSuccess=!1,e.tailscaleError=null,zt(),xt=setInterval(()=>{const b=(Date.now()-f)/1e3,k=Math.min(95,95*(1-Math.exp(-b/30)));e.tailscaleConnectProgress=Math.round(k);let A=go[0][1];for(const[E,M]of go)b>=E&&(A=M);e.tailscaleConnectMessage=A},500)};return Vg({connected:e.connected,serverPlatform:((o=(s=e.hello)==null?void 0:s.server)==null?void 0:o.platform)??null,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:f=>e.handleLicenseKeyChange(f),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:l,whatsappAccounts:p,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:f=>e.handleUninstallConfirmTextChange(f),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:f=>e.handleAuthSubmitCode(f),onAuthCodeChange:f=>e.handleAuthCodeChange(f),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async f=>{await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await ee(e,!0),e.requestUpdate())},onWhatsAppUnlink:async f=>{await e.handleWhatsAppLogout(f)},onWhatsAppReset:async f=>{await e.handleWhatsAppLogout(f),await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await ee(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await ee(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),ee(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:f=>e.handleRemoveWhatsAppAccount(f),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:f=>{e.newWorkspacePin=f},onWorkspaceCreate:async(f,b)=>{const k=e.newWorkspacePin;await e.handleWorkspaceCreate(f,b),k.match(/^\d{4,6}$/)&&(await Kk(e,f,k),e.newWorkspacePin="")},onWorkspaceRemove:f=>e.handleWorkspaceRemove(f),onSetAddingWorkspace:f=>{e.addingWorkspace=f},onSetNewWorkspaceName:f=>{e.newWorkspaceName=f},onSetNewWorkspacePath:f=>{e.newWorkspacePath=f},onSetWorkspaceRemoveConfirm:f=>{e.workspaceRemoveConfirm=f},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(f,b)=>e.handleWorkspaceRename(f,b),whatsappDmPolicy:(()=>{const f=ue(e),b=f==null?void 0:f.whatsappAccountId,k=b?p.find(A=>A.accountId===b):p[0];return(k==null?void 0:k.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var P;const f=ue(e),b=f==null?void 0:f.whatsappAccountId,k=b?p.find(R=>R.accountId===b):p[0];if(!k)return;const E=k.dmPolicy!=null&&k.dmPolicy!=="disabled"?"disabled":"open",M=E==="open"?{dmPolicy:E,allowFrom:["*"]}:{dmPolicy:E};try{const R=await e.client.request("config.get"),F=R.config,q=(P=F==null?void 0:F.channels)==null?void 0:P.whatsapp,ke=((q==null?void 0:q.accounts)??{})[k.accountId]?{channels:{whatsapp:{accounts:{[k.accountId]:M}}}}:{channels:{whatsapp:M}};await e.client.request("config.patch",{raw:JSON.stringify(ke),baseHash:R.hash,note:`WhatsApp DM policy → ${E}`,skipRestart:!0}),await ee(e,!1)}catch(R){console.error("DM toggle failed:",R)}},whatsappModel:(()=>{var P,R;const f=ue(e);if(!f)return null;const b=f.agents.find(F=>F.id.endsWith("-public")||F.id==="public");if(!b)return null;const k=(P=e.configSnapshot)==null?void 0:P.config,A=(R=k==null?void 0:k.agents)==null?void 0:R.list;if(!Array.isArray(A))return null;const E=A.find(F=>F.id===b.id);if(!(E!=null&&E.model))return null;const M=typeof E.model=="string"?E.model:E.model.primary;return(M==null?void 0:M.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async f=>{const b=ue(e);if(!b)return;const k=b.agents.find(A=>A.id.endsWith("-public")||A.id==="public");if(k)try{const A=await e.client.request("config.get"),E=A.config,M=(E==null?void 0:E.agents)??{},P=Array.isArray(M.list)?[...M.list]:[],R=P.findIndex(q=>q.id===k.id);if(f)R>=0?P[R]={...P[R],model:f}:P.push({id:k.id,model:f});else if(R>=0){const{model:q,...z}=P[R];Object.keys(z).length<=1?P.splice(R,1):P[R]=z}const F=P.length>0?{agents:{list:P}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(F),baseHash:A.hash,note:`Public agent model → ${f||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Model change failed:",A)}},whatsappThinkingLevel:(()=>{var M,P,R;const f=ue(e);if(!f)return null;const b=f.agents.find(F=>F.id.endsWith("-public")||F.id==="public");if(!b)return null;const k=(M=e.configSnapshot)==null?void 0:M.config,A=(P=k==null?void 0:k.agents)==null?void 0:P.list;if(!Array.isArray(A))return null;const E=A.find(F=>F.id===b.id);return((R=E==null?void 0:E.thinkingLevel)==null?void 0:R.trim())||null})(),onWhatsAppThinkingChange:async f=>{const b=ue(e);if(!b)return;const k=b.agents.find(A=>A.id.endsWith("-public")||A.id==="public");if(k)try{const A=await e.client.request("config.get"),E=A.config,M=(E==null?void 0:E.agents)??{},P=Array.isArray(M.list)?[...M.list]:[],R=P.findIndex(z=>z.id===k.id),F=f==="off"?void 0:f;if(F)R>=0?P[R]={...P[R],thinkingLevel:F}:P.push({id:k.id,thinkingLevel:F});else if(R>=0){const{thinkingLevel:z,...ke}=P[R];Object.keys(ke).length<=1?P.splice(R,1):P[R]=ke}const q=P.length>0?{agents:{list:P}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(q),baseHash:A.hash,note:`Public agent thinking → ${F||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Thinking change failed:",A)}},whatsappGroupPolicy:(()=>{var R,F;const f=(R=e.configSnapshot)==null?void 0:R.config,b=(F=f==null?void 0:f.channels)==null?void 0:F.whatsapp,k=ue(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},M=A?E[A]:void 0;return(M==null?void 0:M.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var F,q;const f=(F=e.configSnapshot)==null?void 0:F.config,b=(q=f==null?void 0:f.channels)==null?void 0:q.whatsapp,k=ue(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},M=A?E[A]:void 0,R=((M==null?void 0:M.groups)??(b==null?void 0:b.groups)??{})["*"];return(R==null?void 0:R.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var k;const f=ue(e),b=f==null?void 0:f.whatsappAccountId;try{const A=await e.client.request("config.get"),E=A.config,M=((k=E==null?void 0:E.channels)==null?void 0:k.whatsapp)??{},P=M.accounts??{},R=b?P[b]:void 0,F=(R==null?void 0:R.groupPolicy)??M.groupPolicy??"allowlist",q=F==="disabled"||F==="allowlist",z=q?"open":"disabled",ke=q?{"*":{}}:void 0,_e={groupPolicy:z};ke&&(_e.groups=ke);const Ke=R?{channels:{whatsapp:{accounts:{[b]:_e}}}}:{channels:{whatsapp:_e}};await e.client.request("config.patch",{raw:JSON.stringify(Ke),baseHash:A.hash,note:`WhatsApp groups → ${z}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group toggle failed:",A)}},onWhatsAppGroupMentionChange:async f=>{var A;const b=ue(e),k=b==null?void 0:b.whatsappAccountId;try{const E=await e.client.request("config.get"),M=E.config,R=(((A=M==null?void 0:M.channels)==null?void 0:A.whatsapp)??{}).accounts??{},F=k?R[k]:void 0,q={"*":{requireMention:f}},z=F?{channels:{whatsapp:{accounts:{[k]:{groups:q}}}}}:{channels:{whatsapp:{groups:q}}};await e.client.request("config.patch",{raw:JSON.stringify(z),baseHash:E.hash,note:`WhatsApp group mention → ${f?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(E){console.error("Group mention change failed:",E)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:g.configured,imessageRunning:g.running,imessageConnected:g.connected,imessageLastError:g.lastError,imessageSelfChatMode:g.selfChatMode,imessageCliPath:g.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:$,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,k=(b==null?void 0:b.bindings)??[],A=ue(e),E=A==null?void 0:A.agents.find(q=>q.id.endsWith("-admin")||q.id==="admin"),M=(E==null?void 0:E.id)??"admin",P=k.filter(q=>{var z;return((z=q.match)==null?void 0:z.channel)!=="imessage"}),R=[{agentId:M,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],F=[...P,...R];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:F}),baseHash:f.hash,note:"Enable iMessage (self-chat) for "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Ue(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await ee(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,A=((b==null?void 0:b.bindings)??[]).filter(E=>{var M;return((M=E.match)==null?void 0:M.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:A}),baseHash:f.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Ue(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,k=(b==null?void 0:b.bindings)??[],A=ue(e),E=A==null?void 0:A.agents.find(F=>F.id.endsWith("-admin")||F.id==="admin"),M=(E==null?void 0:E.id)??"admin",P=k.filter(F=>{var q;return((q=F.match)==null?void 0:q.channel)!=="imessage"}),R=[{agentId:M,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:[...P,...R]}),baseHash:f.hash,note:"Reassign iMessage to "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Ue(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:f=>{var b,k,A,E;if(e.infoModalOpen=f,f==="remote-access"){const M=((b=e.tailscaleStatus)==null?void 0:b.tailnetUrl)??((k=e.tailscaleStatus)!=null&&k.hostname?`https://${e.tailscaleStatus.hostname}`:null);M&&!e.remoteAccessQrDataUrl&&e.client.request("qr.generate",{url:M}).then(P=>{e.remoteAccessQrDataUrl=(P==null?void 0:P.dataUrl)??null}).catch(()=>{})}else if(f==="public-chat"){const M=((A=e.tailscaleStatus)==null?void 0:A.publicUrl)??((E=e.tailscaleStatus)==null?void 0:E.tailnetUrl)??null,P=e.selectedWorkspace??null;if(M&&P){const R=`${M}/public/chat/${encodeURIComponent(P)}`;e.publicChatQrDataUrl||e.client.request("qr.generate",{url:R}).then(F=>{e.publicChatQrDataUrl=(F==null?void 0:F.dataUrl)??null}).catch(()=>{})}}},onInfoModalClose:()=>{e.infoModalOpen=null},remoteAccessQrDataUrl:e.remoteAccessQrDataUrl??null,publicChatQrDataUrl:e.publicChatQrDataUrl??null,publicChatFullUrl:(()=>{var k,A;const f=((k=e.tailscaleStatus)==null?void 0:k.publicUrl)??((A=e.tailscaleStatus)==null?void 0:A.tailnetUrl)??null,b=e.selectedWorkspace??null;return!f||!b?null:`${f}/public/chat/${encodeURIComponent(b)}`})(),isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,apiKeySavingProvider:e.apiKeySavingProvider,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeySave:async(f,b)=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Cl(e.client,f,b);const k=`${f} key saved`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Mi(e.client)}catch{}f==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async f=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await bk(e.client,f);const b=`${f} key removed`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Mi(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyDisable:async(f,b)=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await wk(e.client,f,b);const k=`${f} ${b?"disabled":"enabled"}`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await Mi(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:`Failed to ${b?"disable":"enable"} key`,e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:f=>{e.authApiKeyInput=f},onAuthApiKeySubmit:async()=>{const f=e.authApiKeyInput.trim();if(f){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await Cl(e.client,"anthropic",f),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(b){e.authApiKeyError=b instanceof Error?b.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var b;const f=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return f?e.accessState.accounts.some(k=>k.id===f):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(f,b)=>{var A;const k=e.selectedWorkspace??((A=e.workspaces[0])==null?void 0:A.name);k&&e.handleAccountPinSave(k,f,b)},publicChatAccountId:e.selectedWorkspace??null,publicChatSettingsOpen:e.publicChatSettingsOpen,onPublicChatSettingsOpen:()=>{e.publicChatSettingsOpen=!0},onPublicChatSettingsClose:()=>{e.publicChatSettingsOpen=!1},publicChatWidgetModalOpen:e.publicChatWidgetModalOpen,onPublicChatWidgetModalOpen:()=>{e.publicChatWidgetModalOpen=!0},onPublicChatWidgetModalClose:()=>{e.publicChatWidgetModalOpen=!1},publicChatEnabled:(()=>{var k;const f=(k=e.configSnapshot)==null?void 0:k.config,b=f==null?void 0:f.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var M,P;const f=(M=e.configSnapshot)==null?void 0:M.config,b=f==null?void 0:f.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.auth)??(b==null?void 0:b.auth);return E==="verified"||E==="choice"?E:"anonymous"})(),publicChatGreeting:(()=>{var E;const f=(E=e.configSnapshot)==null?void 0:E.config,b=f==null?void 0:f.publicChat,k=b==null?void 0:b.greetings,A=e.selectedWorkspace??"";return(A&&(k==null?void 0:k[A]))??""})(),publicChatGreetingBusy:e.publicChatGreetingBusy,onPublicChatGreetingToggle:async()=>{var b;if(e.publicChatGreetingBusy)return;const f=e.selectedWorkspace??"";if(f){e.publicChatGreetingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=(b=A==null?void 0:A.publicChat)==null?void 0:b.greetings;if(E==null?void 0:E[f]){const P={publicChat:{greetings:{[f]:null}}};await e.client.request("config.patch",{raw:JSON.stringify(P),baseHash:k.hash,note:`Public chat greeting → disabled (${f})`,skipRestart:!0})}else{const P=await e.client.request("public.greeting.generate",{accountId:f});if(P!=null&&P.ok&&P.greeting){const R=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[f]:P.greeting}}}),baseHash:R.hash,note:`Public chat greeting → enabled (${f})`,skipRestart:!0})}}e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting toggle failed:",k)}finally{e.publicChatGreetingBusy=!1}}},onPublicChatGreetingSave:async f=>{const b=e.selectedWorkspace??"";if(b)try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[b]:f}}}),baseHash:k.hash,note:`Public chat greeting text updated (${b})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting save failed:",k)}},onPublicChatGreetingRegenerate:async()=>{if(e.publicChatGreetingBusy)return;const f=e.selectedWorkspace??"";if(f){e.publicChatGreetingBusy=!0;try{const b=await e.client.request("public.greeting.generate",{accountId:f});if(b!=null&&b.ok&&b.greeting){const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[f]:b.greeting}}}),baseHash:k.hash,note:`Public chat greeting regenerated (${f})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}}catch(b){console.error("Public chat greeting regeneration failed:",b)}finally{e.publicChatGreetingBusy=!1}}},publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var f;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),k=b.config,A=((f=k==null?void 0:k.publicChat)==null?void 0:f.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!A}}),baseHash:b.hash,note:`Public chat → ${A?"disabled":"enabled"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get"),e.publicChatQrDataUrl=null}catch(b){console.error("Public chat toggle failed:",b)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async f=>{if(e.publicChatToggleBusy)return;const b=e.selectedWorkspace??"";if(b){e.publicChatToggleBusy=!0;try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{accountSettings:{[b]:{auth:f}}}}),baseHash:k.hash,note:`Public chat auth → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat auth mode change failed:",k)}finally{e.publicChatToggleBusy=!1}}},publicChatEmailFrom:(()=>{var k,A;const f=(k=e.configSnapshot)==null?void 0:k.config,b=(A=f==null?void 0:f.publicChat)==null?void 0:A.email;return(b==null?void 0:b.from)??""})(),publicChatEmailBusy:e.publicChatEmailBusy,publicChatVerifyMethods:(()=>{var M,P;const f=(M=e.configSnapshot)==null?void 0:M.config,b=f==null?void 0:f.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.verifyMethods)??(b==null?void 0:b.verifyMethods);return Array.isArray(E)?E:["whatsapp","sms"]})(),onPublicChatEmailSave:async(f,b)=>{if(e.publicChatEmailBusy)return;const k=e.selectedWorkspace??"";if(k){e.publicChatEmailBusy=!0;try{const A=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{email:{from:f||void 0},accountSettings:{[k]:{verifyMethods:b}}}}),baseHash:A.hash,note:"Update email verification settings for public chat",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Email verification save failed:",A)}finally{e.publicChatEmailBusy=!1}}},brandAccentColor:(()=>{var k;const f=e.selectedWorkspace;return f?((k=Be()[f])==null?void 0:k.accentColor)??"":""})(),brandBackgroundColor:(()=>{var k;const f=e.selectedWorkspace;return f?((k=Be()[f])==null?void 0:k.backgroundColor)??"":""})(),brandHasLogo:(()=>{var k;const f=e.selectedWorkspace;return f?!!((k=Be()[f])!=null&&k.logoUrl):!1})(),brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async f=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,M=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=M.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...M,brand:{...P,accentColor:f}}}}),baseHash:A.hash,note:`Brand accent → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const R=Be();R[b]||(R[b]={}),R[b].accentColor=f,Tn(b)}catch(A){console.error("Brand accent change failed:",A)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async f=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,M=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=M.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...M,brand:{...P,backgroundColor:f}}}}),baseHash:A.hash,note:`Brand background → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const R=Be();R[b]||(R[b]={}),R[b].backgroundColor=f,Tn(b)}catch(A){console.error("Brand background change failed:",A)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async f=>{const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const k=await f.arrayBuffer(),A=new Uint8Array(k);let E="";for(let R=0;R<A.length;R++)E+=String.fromCharCode(A[R]);const M=btoa(E);await e.client.request("brand.uploadLogo",{workspace:b,data:M,mimeType:f.type});const P=Be();P[b]||(P[b]={}),P[b].logoUrl=`/brand-logo/${encodeURIComponent(b)}`}catch(k){console.error("Brand logo upload failed:",k)}finally{e.brandingBusy=!1}}},onBrandLogoRemove:async()=>{const f=e.selectedWorkspace;if(!(!f||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:f});const b=Be();b[f]&&delete b[f].logoUrl}catch(b){console.error("Brand logo remove failed:",b)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var b;const f=e.selectedWorkspace;if(!(!f||e.brandingBusy)){e.brandingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=((b=A==null?void 0:A.workspaces)==null?void 0:b[f])??{},{brand:M,...P}=E;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[f]:{...P,brand:null}}}),baseHash:k.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:f})}catch{}const R=Be();delete R[f],Tn(f)}catch(k){console.error("Brand reset failed:",k)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleServeEnableUrl:e.tailscaleServeEnableUrl,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,tailscaleDisableConfirm:e.tailscaleDisableConfirm,tailscaleConnectProgress:e.tailscaleConnectProgress,tailscaleConnectMessage:e.tailscaleConnectMessage,tailscaleConnectSuccess:e.tailscaleConnectSuccess,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null,T();try{const f=await e.client.request("tailscale.enable");f.authUrl?(xt&&(clearInterval(xt),xt=null),e.tailscaleConnectProgress=100,e.tailscaleConnectMessage="Waiting for authentication...",e.tailscaleAuthUrl=f.authUrl,Pi=setInterval(async()=>{try{const b=await e.client.request("tailscale.status");e.tailscaleStatus=b,e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,b.loggedIn&&(zt(),e.tailscaleAuthUrl=null,e.tailscaleConnectSuccess=!0,e.tailscaleConnectMessage="Connected!",setTimeout(()=>{e.tailscaleConnectSuccess=!1,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1},1500))}catch{}},3e3),Ii=setTimeout(()=>{zt(),e.tailscaleBusy&&(e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)},3e5)):f.alreadyLoggedIn?(zt(),e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1):(zt(),e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)}catch(f){console.error("Tailscale enable failed:",f),zt(),e.tailscaleError=f.message||"Failed to enable Remote Access",e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1}}},onTailscaleErrorDismiss:()=>{e.tailscaleError=null},onTailscaleServeEnable:async()=>{var f;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleServeEnableUrl=null;try{await e.client.request("tailscale.serve.enable"),await S()}catch(b){console.error("Tailscale serve enable failed:",b);const k=b;(f=k.payload)!=null&&f.enableUrl&&(e.tailscaleServeEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Remote Access"}finally{e.tailscaleBusy=!1}}},onTailscaleServeDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.serve.disable"),await S()}catch(f){console.error("Tailscale serve disable failed:",f)}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var f;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable"),await S()}catch(b){console.error("Tailscale funnel enable failed:",b);const k=b;(f=k.payload)!=null&&f.enableUrl&&(e.tailscaleFunnelEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Funnel"}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable"),await S()}catch(f){console.error("Tailscale funnel disable failed:",f)}finally{e.tailscaleBusy=!1}}},onTailscaleDisableConfirmToggle:()=>{e.tailscaleDisableConfirm=!e.tailscaleDisableConfirm},wifiModalOpen:e.wifiModalOpen,onWifiModalToggle:()=>{e.wifiModalOpen=!e.wifiModalOpen,e.wifiModalOpen||(e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null)},wifiStatus:e.wifiStatus,wifiNetworks:e.wifiNetworks,wifiBusy:e.wifiBusy,wifiError:e.wifiError,wifiPassword:e.wifiPassword,wifiSelectedSsid:e.wifiSelectedSsid,onWifiScan:async()=>{var f;if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[b,k]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiNetworks=b.networks,k.connected&&k.signal==null&&((f=b.networks)!=null&&f.length)){const A=b.networks.find(E=>E.active)||b.networks.find(E=>E.ssid===k.ssid);A&&(k.signal=A.signal)}e.wifiStatus=k}catch(b){console.error("WiFi scan failed:",b),e.wifiError=b.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{var b;if(e.wifiBusy||!e.wifiSelectedSsid)return;const f=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const k=await e.client.request("wifi.connect",{ssid:f,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:k.connected,ssid:k.ssid,signal:null,ip:k.ip,savedSsid:k.ssid,autoconnect:!0},e.wifiBusy=!1;try{const[A,E]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(E.connected&&E.signal==null&&((b=A.networks)!=null&&b.length)){const M=A.networks.find(P=>P.active)||A.networks.find(P=>P.ssid===E.ssid);M&&(E.signal=M.signal)}e.wifiStatus=E}catch{}}catch(k){console.error("WiFi connect failed:",k),e.wifiError=k.message||"Failed to connect",e.wifiBusy=!1}},onWifiDisconnect:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.disconnect"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi disconnect failed:",f),e.wifiError=f.message||"Failed to disconnect"}finally{e.wifiBusy=!1}}},onWifiForget:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.forget"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi forget failed:",f),e.wifiError=f.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:f=>{e.wifiSelectedSsid=f,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:f=>{e.wifiPassword=f},networkPort:e.networkPort,networkHostname:e.networkHostname,networkPortInput:e.networkPortInput,networkHostnameInput:e.networkHostnameInput,networkModalOpen:e.networkModalOpen,networkBusy:e.networkBusy,networkError:e.networkError,networkSuccess:e.networkSuccess,onNetworkModalToggle:()=>{e.networkModalOpen=!e.networkModalOpen,e.networkModalOpen&&(e.networkPortInput=String(e.networkPort??""),e.networkHostnameInput=e.networkHostname,e.networkError=null,e.networkSuccess=null)},onNetworkPortChange:f=>{e.networkPortInput=f,e.networkError=null,e.networkSuccess=null},onNetworkHostnameChange:f=>{e.networkHostnameInput=f,e.networkError=null,e.networkSuccess=null},onNetworkSave:async()=>{if(e.networkBusy)return;e.networkBusy=!0,e.networkError=null,e.networkSuccess=null;const f=e.networkPortInput.trim(),b=Number.parseInt(f,10),k=e.networkHostnameInput.trim();if(!f||!Number.isFinite(b)||b<1024||b>65535){e.networkError="Port must be a number between 1024 and 65535",e.networkBusy=!1;return}const A=b!==e.networkPort,E=k!==e.networkHostname;if(!A&&!E){e.networkBusy=!1;return}try{E&&await e.client.request("network.setHostname",{hostname:k});const M={};A&&(M.gateway={port:b}),E&&(M.discovery={bonjourHostname:k});const P=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify(M),baseHash:P.hash,note:[A?`Port → ${b}`:null,E?`Hostname → ${k}`:null].filter(Boolean).join(", "),restartDelayMs:2e3}),e.networkSuccess="Saved — redirecting...";const R=window.location.protocol,F=E?`${k}.local`:window.location.hostname,q=A?b:e.networkPort,z=`${R}//${F}:${q}/setup`;setTimeout(()=>{window.location.href=z},1500)}catch(M){console.error("Network save failed:",M),e.networkError=M.message||"Failed to save network settings",e.networkBusy=!1}},wsProps:Vk(e)})}if(e.filesPage){const l=Yk(e);return cg({connected:e.connected,wsProps:Sn(e),loading:e.filesLoading,tree:e.filesTree,root:e.filesRoot,error:e.filesError,selectedPath:e.filesSelectedPath,selectedPaths:e.filesSelectedPaths,previewContent:e.filesPreviewContent,previewLoading:e.filesPreviewLoading,previewBinary:e.filesPreviewBinary,previewSize:e.filesPreviewSize,expandedDirs:e.filesExpandedDirs,currentDir:e.filesCurrentDir,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>{an(e,l),cs(e,l)},onReindex:()=>$f(e,l),onSelectFile:p=>{e.filesPendingDeletePath=null,gf(e,p,l)},onToggleSelectFile:p=>mf(e,p,l),onToggleDir:p=>Sf(e,p),onUpload:(p,g)=>bf(e,p,g,l),onNewFolder:(p,g)=>wf(e,p,g,l),onDownload:p=>id(e,p,l),onBulkDownload:()=>yf(e,l),onDelete:p=>{e.filesPendingDeletePath=null,kf(e,p,l)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,g)=>vf(e,p,g,l),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const g=e.filesSearchAgentId??l;Af(e,p,g)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{Cf(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return ig({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:()=>uk(e),onStop:()=>pk(e),onToggleInput:()=>fk(e),onToggleFullscreen:()=>gk(e),onCompleteHandoff:()=>hk(e),onCanvasMouseDown:l=>{const g=l.target.getBoundingClientRect(),S=Bn().translateCoordinates(l.clientX-g.left,l.clientY-g.top);uo(e,"mousePressed",S.x,S.y,l.button===2?"right":l.button===1?"middle":"left")},onCanvasMouseUp:l=>{const g=l.target.getBoundingClientRect(),S=Bn().translateCoordinates(l.clientX-g.left,l.clientY-g.top);uo(e,"mouseReleased",S.x,S.y)},onCanvasMouseMove:l=>{const p=Bn();if(p.shouldThrottleMouseMove())return;const $=l.target.getBoundingClientRect(),S=p.translateCoordinates(l.clientX-$.left,l.clientY-$.top);uo(e,"mouseMoved",S.x,S.y)},onCanvasKeyDown:l=>{let p=0;l.altKey&&(p|=1),l.ctrlKey&&(p|=2),l.metaKey&&(p|=4),l.shiftKey&&(p|=8),po(e,"keyDown",l.key,{code:l.code,modifiers:p||void 0}),l.key.length===1&&po(e,"char",l.key,{text:l.key})},onCanvasKeyUp:l=>{po(e,"keyUp",l.key,{code:l.code})}});if(e.adminsPage){const l=Qk(e),p=Jk(e);return Jg({connected:e.connected,wsProps:Sn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>ms(e,l),onAdd:g=>{Eu(e,g,l,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:g=>Tu(e,g,l,p),onNewPhoneChange:g=>e.handleAdminsNewPhoneChange(g)})}if(e.contactsPage){const l=Xk(e);return nm({connected:e.connected,wsProps:Sn(e),loading:e.contactsLoading,saving:e.contactsSaving,records:e.contactsRecords,error:e.contactsError,searchQuery:e.contactsSearchQuery,editingId:e.contactsEditingId,showAddForm:e.contactsShowAddForm,newRecordPhone:e.contactsNewPhone,newRecordName:e.contactsNewName,deleteConfirmId:e.contactsDeleteConfirmId,addFieldForId:e.contactsAddFieldForId,addFieldKey:e.contactsAddFieldKey,addFieldValue:e.contactsAddFieldValue,onSearch:p=>e.contactsSearchQuery=p,onSearchSubmit:()=>Lt(e,l),onAdd:(p,g)=>_u(e,p,g,l),onDelete:p=>Mu(e,p,l),onSetField:(p,g,$)=>qo(e,p,g,$,l),onDeleteField:(p,g)=>Pu(e,p,g,l),onToggleExpand:p=>{e.contactsEditingId=e.contactsEditingId===p?null:p},onShowAddForm:()=>e.contactsShowAddForm=!0,onCancelAddForm:()=>{e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName=""},onNewRecordPhoneChange:p=>e.handleContactsNewPhoneChange(p),onNewRecordNameChange:p=>e.handleContactsNewNameChange(p),onRefresh:()=>Lt(e,l),onDeleteConfirmOpen:p=>e.contactsDeleteConfirmId=p,onDeleteConfirmClose:()=>e.contactsDeleteConfirmId=null,onAddFieldOpen:p=>{e.contactsAddFieldForId=p,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldClose:()=>{e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldKeyChange:p=>e.contactsAddFieldKey=p,onAddFieldValueChange:p=>e.contactsAddFieldValue=p,onAddFieldSubmit:()=>{const p=e.contactsAddFieldForId,g=e.contactsAddFieldKey.trim();!p||!g||(qo(e,p,g,e.contactsAddFieldValue,l),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const l=e.connected?null:"Disconnected from gateway.",p=Dl(e),g=e.chatAvatarUrl??p??null,$=(()=>{var f;const S=(f=e.configSnapshot)==null?void 0:f.config,T=S==null?void 0:S.publicChat;return(T==null?void 0:T.enabled)===!0})();return tw({connected:e.connected,wsProps:Sn(e),publicChatEnabled:$,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:S=>{const T=e.selectedWorkspace??"";bo(),Wn(T,e.sessionKey,e.chatMessage),e.sessionKey=S,e.chatMessage=Kn(T,S),e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestions=[],e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:S,lastActiveSessionKey:S}),e.loadAssistantIdentity(),Oe(e),Co(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:S=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{model:S}).then(()=>{Oe(e,{limit:T})})},onThinkingLevelChange:S=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{thinkingLevel:S==="off"?null:S}).then(()=>{Oe(e,{limit:T})})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestions:e.chatSuggestions,onSuggestionClick:S=>{e.chatMessage=S,e.chatSuggestions=[],e.handleSendChat()},onVerboseChange:S=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{verboseLevel:S==="off"?null:S}).then(()=>{Oe(e,{limit:T})})},onFillerChange:S=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{fillerEnabled:S}).then(()=>{Oe(e,{limit:T})})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:g,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:l,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const S=Math.max(e.chatMessages.length+10,Fe);return Promise.all([Oe(e,{limit:S}),Co(e)])},onToggleFocusMode:()=>{},onChatScroll:S=>e.handleChatScroll(S),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:S=>{e.chatMessage=S,wr(e.selectedWorkspace??"",e.sessionKey,S)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:S=>e.chatAttachments=S,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:S=>e.removeQueuedMessage(S),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:S=>e.handleOpenSidebar(S),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:S=>e.handleSplitRatioChange(S),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?Xw({connected:e.connected,wsProps:Sn(e),activeTab:e.advancedTab,onTabChange:l=>{e.advancedTab=l,l==="cron"&&e.loadCron(),l==="skills"&&Xe(e,{clearMessages:!0}),l==="opening-hours"&&Ka(e),l==="logs"&&(e.logsSubTab==="session"?Pn(e,{reset:!0}):Vt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(a=e.channelsSnapshot)==null?void 0:a.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(l=>l.id):((c=e.channelsSnapshot)==null?void 0:c.channelOrder)??[],channelLabels:((d=e.channelsSnapshot)==null?void 0:d.channelLabels)??{},channelMeta:((h=e.channelsSnapshot)==null?void 0:h.channelMeta)??[],agentIds:(()=>{var p;const l=ue(e);return((p=l==null?void 0:l.agents)==null?void 0:p.map(g=>g.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1,e.cronEditJobId=null},detailJobId:e.cronDetailJobId,editJobId:e.cronEditJobId,onDetailOpen:l=>{e.cronDetailJobId=l.id,ko(e,l.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:l=>{e.cronForm=bh(l),e.cronEditJobId=l.id,e.cronDetailJobId=null},onEditSave:()=>{const l=e.cronEditJobId;l&&wh(e,l).then(()=>{e.cronEditJobId=null})},onFormChange:l=>e.cronForm={...e.cronForm,...l},onRefresh:()=>e.loadCron(),onAdd:()=>{fh(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(l,p)=>gh(e,l,p),onRun:l=>mh(e,l),onRemove:l=>{e.cronPendingDeleteId=null,vh(e,l)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:l=>{e.cronPendingDeleteId=l||null},onLoadRuns:l=>ko(e,l),runModalJobId:e.cronRunModalJobId,runModalJobName:e.cronRunModalJobName,runResult:e.cronRunResult,onRunModalClose:()=>{e.cronRunModalJobId=null,e.cronRunModalJobName="",e.cronRunResult=null}},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,typeFilter:e.skillsTypeFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,detail:e.skillDetail,detailTab:e.skillDetailTab,addModal:e.skillAddModal,addForm:e.skillAddForm,formSource:e.skillAddFormSource,editTab:e.skillEditTab,drafts:e.skillDrafts,onFilterChange:l=>e.skillsFilter=l,onTypeFilterChange:l=>e.skillsTypeFilter=l,onRefresh:()=>Xe(e,{clearMessages:!0}),onToggle:(l,p)=>Dc(e,l,p),onEdit:(l,p)=>Rc(e,l,p),onSaveKey:l=>Bc(e,l),onInstall:(l,p,g)=>Nc(e,l,p,g),onViewDetail:l=>Oc(e,l),onDetailClose:()=>Fc(e),onDetailTab:l=>Uc(e,l),onAddOpen:()=>Wc(e),onAddClose:()=>Kc(e),onImportDraft:l=>zc(e,l),onInstallDraft:l=>Hc(e,l),onDeleteDraft:l=>qc(e,l),onAddSave:()=>ca(e),onAddFormUpdate:(l,p)=>{e.skillAddForm={...e.skillAddForm,[l]:p}},onDelete:l=>Jc(e,l),onEditSkill:l=>jc(e,l),onEditDetail:l=>Gc(e,l),onRefUpdate:(l,p)=>Vc(e,l,p),onEditTab:l=>Qc(e,l)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:l=>{e.logsSubTab=l,l==="session"?Pn(e,{reset:!0}):Vt(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,chipsExpanded:e.sessionLogsChipsExpanded,expandedIds:e.sessionLogsExpandedIds,onFilterTextChange:l=>e.sessionLogsFilterText=l,onTypeToggle:(l,p)=>{const g=e;g.sessionLogsTypeFilters={...g.sessionLogsTypeFilters,[l]:p}},onAgentToggle:(l,p)=>{const g=e;g.sessionLogsAgentFilters={...g.sessionLogsAgentFilters,[l]:p}},onToggleAutoFollow:l=>e.sessionLogsAutoFollow=l,onToggleChips:()=>{const l=e;l.sessionLogsChipsExpanded=!l.sessionLogsChipsExpanded},onToggleExpand:l=>{const p=e,g=new Set(p.sessionLogsExpandedIds);g.has(l)?g.delete(l):g.add(l),p.sessionLogsExpandedIds=g,p.requestUpdate()},onRefresh:()=>{Pn(e,{reset:!0})},onExport:(l,p)=>e.exportSessionLogs(l,p),onScroll:l=>e.handleSessionLogsScroll(l)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,chipsExpanded:e.logsChipsExpanded,truncated:e.logsTruncated,onFilterTextChange:l=>e.logsFilterText=l,onLevelToggle:(l,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[l]:p}},onToggleAutoFollow:l=>e.logsAutoFollow=l,onToggleChips:()=>{const l=e;l.logsChipsExpanded=!l.logsChipsExpanded},onRefresh:()=>Vt(e,{reset:!0}),onExport:(l,p)=>e.exportSessionLogs(l,p),onScroll:l=>e.handleLogsScroll(l)},openingHoursProps:{loading:e.openingHoursLoading,error:e.openingHoursError,busy:e.openingHoursBusy,form:e.openingHoursForm,onFormChange:l=>{const p=e;p.openingHoursForm={...p.openingHoursForm,...l}},onDayChange:(l,p,g)=>{const $=e,S={...$.openingHoursForm.days};S[l]={...S[l],[p]:g},$.openingHoursForm={...$.openingHoursForm,days:S}},onAddClosedDate:l=>{const p=e;p.openingHoursForm.closedDates.includes(l)||(p.openingHoursForm={...p.openingHoursForm,closedDates:[...p.openingHoursForm.closedDates,l].sort()})},onRemoveClosedDate:l=>{const p=e;p.openingHoursForm={...p.openingHoursForm,closedDates:p.openingHoursForm.closedDates.filter(g=>g!==l)}},onSave:()=>{Au(e)}}}):(window.location.replace("/chat"),u``)}function o0(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${i}`}function Bl(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function a0(e,t,n){return u`
4531
4643
  <div class="audit-modal-overlay" @click=${s=>{s.target.classList.contains("audit-modal-overlay")&&n()}}>
4532
4644
  <div class="audit-modal-card">
4533
4645
  <div class="audit-modal-header">
@@ -4543,11 +4655,11 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4543
4655
  ${e.map(s=>u`
4544
4656
  <div class="audit-modal-entry">
4545
4657
  <div class="audit-modal-entry-path">
4546
- <span class="audit-modal-folder audit-modal-folder--${Il(s.path)}">${Il(s.path)}</span>
4658
+ <span class="audit-modal-folder audit-modal-folder--${Bl(s.path)}">${Bl(s.path)}</span>
4547
4659
  <a href="/files" class="audit-modal-path-link">${s.path}</a>
4548
4660
  </div>
4549
4661
  <div class="audit-modal-entry-meta">
4550
- ${Wk(s.timestamp)}
4662
+ ${o0(s.timestamp)}
4551
4663
  <span class="audit-modal-agent">${s.agentId}</span>
4552
4664
  </div>
4553
4665
  </div>
@@ -4559,7 +4671,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
4559
4671
  `}
4560
4672
  </div>
4561
4673
  </div>
4562
- `}const zk={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},qk={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};function Hk(e){e.basePath=Mf();const t=Ye();zl(t.accentColor),ql(t.backgroundColor);const n=document.querySelector('link[rel="icon"]');if(n&&(n.href=t.iconUrl),window.scrollTo(0,0),$f(e),e.publicChat){const i=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,s=(i==null?void 0:i.accountId)??"",o=s?s.charAt(0).toUpperCase()+s.slice(1):"Assistant";document.title=`Chat with ${o}`,De(e);return}if(e.setup){document.title=`${t.name} Setup`,De(e);return}if(e.filesPage){document.title=`${t.name} Files`,Af(e),De(e);return}if(e.browserPage){document.title=`${t.name} Browser`,De(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,De(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,De(e);return}if(e.chatPage){document.title=`${t.name} Chat`,De(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,De(e);return}Rf(e,!0),Pf(e),If(e),window.addEventListener("popstate",e.popStateHandler),Ef(e),De(e),kf(e),e.tab==="logs"&&(e.logsSubTab==="session"?pa(e):da(e)),e.tab==="debug"&&fa(e)}function jk(e){sh(e)}function Gk(e){var t;window.removeEventListener("popstate",e.popStateHandler),xf(e),ua(e),ha(e),ga(e),Sf(e),Cf(e),Lf(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function Vk(e,t){if(!e.publicChat){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.contactsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleContactsLoad&&e.handleContactsLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const i=t.has("setupStep")&&e.setupStep==="auth";(n||i)&&e.setupStep==="auth"&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="whatsapp"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(o=>{e.channelsSnapshot=o,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(s=>{e.channelsSnapshot=s,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),i=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;nn(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&ic(e,t.has("tab")||t.has("logsAutoFollow"))}}function Qk(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 Jk(e,t,n){await Zo(e,t,n),await ee(e,!0)}async function Yk(e,t){await lc(e,t),await ee(e,!0)}async function Xk(e,t){await cc(e,t),await ee(e,!0)}async function Zk(e,t){await dc(e,t)}async function e0(e,t){await uc(e,t)}async function t0(e){await rh(e),await Ue(e),await ee(e,!0)}async function n0(e){await Ue(e),await ee(e,!0)}function i0(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[i,...s]=n.split(":");if(!i||s.length===0)continue;const o=i.trim(),a=s.join(":").trim();o&&a&&(t[o]=a)}return t}function Cu(e){var n,i,s;return((s=(((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.nostr)??[])[0])==null?void 0:s.accountId)??e.nostrProfileAccountId??"default"}function Eu(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function s0(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Qk(n??void 0)}function o0(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function a0(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function r0(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function l0(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Cu(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Eu(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const o=(s==null?void 0:s.error)??`Profile update failed (${i.status})`;e.nostrProfileFormState={...t,saving:!1,error:o,success:null,fieldErrors:i0(s==null?void 0:s.details)};return}if(!s.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await ee(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function c0(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Cu(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Eu(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const l=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const o=s.merged??s.imported??null,a=o?{...t.values,...o}:t.values,r=!!(a.banner||a.website||a.nip05||a.lud16);e.nostrProfileFormState={...t,importing:!1,values:a,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:r},s.saved&&await ee(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function d0(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 u0(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 p0(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 h0(e,t){e.authCodeInput=t}function f0(e){e.setupStep="whatsapp"}async function g0(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 m0(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 y0(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 v0(e,t){e.licenseKey=t}async function b0(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("health",{probe:!0});e.gatewayHealthy=i.ok===!0,e.gatewayHealthMessage=i.ok?`Healthy${i.durationMs?` (${i.durationMs}ms)`:""}`:"Unhealthy"}catch(i){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(i)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function w0(e){var t,n,i;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(s.ok&&((n=s.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(s){e.gatewayHealthMessage=`Restart failed: ${String(s)}`,e.gatewayRestartBusy=!1,(i=e.requestUpdate)==null||i.call(e)}}}var k0=Object.defineProperty,x0=Object.getOwnPropertyDescriptor,y=(e,t,n,i)=>{for(var s=i>1?void 0:i?x0(t,n):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(i?a(t,n,s):a(s))||s);return i&&s&&k0(t,n,s),s};const go=pp();function $0(){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 S0(){const e=window.location.pathname;if(e==="/setup"||e.endsWith("/setup"))return!0;if(!window.location.search)return!1;const n=new URLSearchParams(window.location.search).get("setup");if(!n)return!1;const i=n.trim().toLowerCase();return i==="1"||i==="true"||i==="yes"||i==="on"}function A0(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function C0(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function E0(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function T0(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function _0(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function M0(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let m=class extends Gt{constructor(){super(...arguments),this.settings=Is(),this.password="",this.tab="chat",this.onboarding=$0(),this.setup=S0(),this.filesPage=A0(),this.browserPage=C0(),this.adminsPage=E0(),this.contactsPage=T0(),this.chatPage=_0(),this.advancedPage=M0(),this.advancedTab="cron",this.publicChat=!!window.__TASKMASTER_PUBLIC_CHAT__,this.publicChatConfig=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__??{},this.publicChatSessionKey=null,this.publicChatAuthenticated=!1,this.publicChatAuthStep="idle",this.connected=!1,this.accessState=yu,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=go.name,this.assistantAvatar=go.avatar,this.assistantAgentId=go.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatHistoryTotal=0,this.chatHistoryHasMore=!1,this.chatLoadingOlder=!1,this.chatToolMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],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=`{
4674
+ `}const r0={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},l0={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};function c0(e){e.basePath=Bf();const t=Ye();Gl(t.accentColor),Vl(t.backgroundColor);const n=document.querySelector('link[rel="icon"]');if(n&&(n.href=t.iconUrl),window.scrollTo(0,0),_f(e),e.publicChat){const i=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,s=(i==null?void 0:i.accountId)??"",o=s?s.charAt(0).toUpperCase()+s.slice(1):"Assistant";document.title=`Chat with ${o}`,De(e);return}if(e.setup){document.title=`${t.name} Setup`,De(e);return}if(e.filesPage){document.title=`${t.name} Files`,Pf(e),De(e);return}if(e.browserPage){document.title=`${t.name} Browser`,De(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,De(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,De(e);return}if(e.chatPage){document.title=`${t.name} Chat`,De(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,De(e);return}Uf(e,!0),Nf(e),Of(e),window.addEventListener("popstate",e.popStateHandler),Lf(e),De(e),Ef(e),e.tab==="logs"&&(e.logsSubTab==="session"?ha(e):ua(e)),e.tab==="debug"&&ga(e)}function d0(e){dh(e)}function u0(e){var t;window.removeEventListener("popstate",e.popStateHandler),Tf(e),pa(e),fa(e),ma(e),Mf(e),If(e),Ff(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function p0(e,t){if(!e.publicChat){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.contactsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleContactsLoad&&e.handleContactsLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const i=t.has("setupStep")&&e.setupStep==="auth";(n||i)&&e.setupStep==="auth"&&e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck(),e.setupStep==="whatsapp"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(o=>{e.channelsSnapshot=o,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(s=>{e.channelsSnapshot=s,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),i=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;nn(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&rc(e,t.has("tab")||t.has("logsAutoFollow"))}}function h0(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 f0(e,t,n){await ea(e,t,n),await ee(e,!0)}async function g0(e,t){await pc(e,t),await ee(e,!0)}async function m0(e,t){await hc(e,t),await ee(e,!0)}async function y0(e,t){await fc(e,t)}async function v0(e,t){await gc(e,t)}async function b0(e){await hh(e),await Ue(e),await ee(e,!0)}async function w0(e){await Ue(e),await ee(e,!0)}function k0(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[i,...s]=n.split(":");if(!i||s.length===0)continue;const o=i.trim(),a=s.join(":").trim();o&&a&&(t[o]=a)}return t}function Iu(e){var n,i,s;return((s=(((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.nostr)??[])[0])==null?void 0:s.accountId)??e.nostrProfileAccountId??"default"}function Lu(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function x0(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=h0(n??void 0)}function $0(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function S0(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function A0(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function C0(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Iu(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Lu(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const o=(s==null?void 0:s.error)??`Profile update failed (${i.status})`;e.nostrProfileFormState={...t,saving:!1,error:o,success:null,fieldErrors:k0(s==null?void 0:s.details)};return}if(!s.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await ee(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function E0(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Iu(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Lu(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const c=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:c,success:null};return}const o=s.merged??s.imported??null,a=o?{...t.values,...o}:t.values,r=!!(a.banner||a.website||a.nip05||a.lud16);e.nostrProfileFormState={...t,importing:!1,values:a,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:r},s.saved&&await ee(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function T0(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 _0(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 M0(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 P0(e,t){e.authCodeInput=t}function I0(e){e.setupStep="whatsapp"}async function L0(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 R0(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 D0(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 B0(e,t){e.licenseKey=t}async function N0(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("health",{probe:!0});e.gatewayHealthy=i.ok===!0,e.gatewayHealthMessage=i.ok?`Healthy${i.durationMs?` (${i.durationMs}ms)`:""}`:"Unhealthy"}catch(i){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(i)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function O0(e){var t,n,i;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(s.ok&&((n=s.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(s){e.gatewayHealthMessage=`Restart failed: ${String(s)}`,e.gatewayRestartBusy=!1,(i=e.requestUpdate)==null||i.call(e)}}}var F0=Object.defineProperty,U0=Object.getOwnPropertyDescriptor,y=(e,t,n,i)=>{for(var s=i>1?void 0:i?U0(t,n):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(i?a(t,n,s):a(s))||s);return i&&s&&F0(t,n,s),s};const mo=vp();function W0(){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 K0(){const e=window.location.pathname;if(e==="/setup"||e.endsWith("/setup"))return!0;if(!window.location.search)return!1;const n=new URLSearchParams(window.location.search).get("setup");if(!n)return!1;const i=n.trim().toLowerCase();return i==="1"||i==="true"||i==="yes"||i==="on"}function z0(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function H0(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function q0(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function j0(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function G0(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function V0(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let m=class extends Gt{constructor(){super(...arguments),this.settings=Ls(),this.password="",this.tab="chat",this.onboarding=W0(),this.setup=K0(),this.filesPage=z0(),this.browserPage=H0(),this.adminsPage=q0(),this.contactsPage=j0(),this.chatPage=G0(),this.advancedPage=V0(),this.advancedTab="cron",this.publicChat=!!window.__TASKMASTER_PUBLIC_CHAT__,this.publicChatConfig=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__??{},this.publicChatSessionKey=null,this.publicChatAuthenticated=!1,this.publicChatAuthStep="idle",this.connected=!1,this.accessState=ku,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=mo.name,this.assistantAvatar=mo.avatar,this.assistantAgentId=mo.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatHistoryTotal=0,this.chatHistoryHasMore=!1,this.chatLoadingOlder=!1,this.chatToolMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],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=`{
4563
4675
  }
4564
- `,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.whatsappActiveQrAccountId=null,this.whatsappPairedPhone=null,this.addingWhatsAppAccount=!1,this.newWhatsAppAccountName="",this.whatsappAccountError=null,this.whatsappAccountSaving=!1,this.whatsappSettingsOpen=!1,this.publicChatToggleBusy=!1,this.publicChatGreetingBusy=!1,this.publicChatEmailBusy=!1,this.publicChatSettingsOpen=!1,this.publicChatWidgetModalOpen=!1,this.brandingBusy=!1,this.brandingExpanded=!1,this.tailscaleStatus=null,this.tailscaleBusy=!1,this.tailscaleAuthUrl=null,this.tailscaleError=null,this.tailscaleServeEnableUrl=null,this.tailscaleFunnelEnableUrl=null,this.tailscaleDisableConfirm=!1,this.tailscaleConnectProgress=0,this.tailscaleConnectMessage="",this.tailscaleConnectSuccess=!1,this.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,this.networkPort=null,this.networkHostname="",this.networkPortInput="",this.networkHostnameInput="",this.networkModalOpen=!1,this.networkBusy=!1,this.networkError=null,this.networkSuccess=null,this.wifiModalOpen=!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={...qk},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.cronEditJobId=null,this.cronPendingDeleteId=null,this.cronRunModalJobId=null,this.cronRunModalJobName="",this.cronRunResult=null,this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserFullscreen=!1,this.browserLoading=!1,this.browserError=null,this.filesLoading=!1,this.filesTree=[],this.filesRoot="",this.filesError=null,this.filesSelectedPath=null,this.filesSelectedPaths=new Set,this.filesPreviewContent=null,this.filesPreviewLoading=!1,this.filesPreviewBinary=!1,this.filesPreviewSize=null,this.filesExpandedDirs=new Set,this.filesCurrentDir=".",this.filesPendingDeletePath=null,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.embeddingDownloading=!1,this.embeddingPollTimer=null,this.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.filesResolvedAgentId=void 0,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillsTypeFilter="all",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillDetail=null,this.skillDetailTab="",this.skillAddModal=!1,this.skillAddForm={name:"",skillContent:"",references:[]},this.skillAddFormSource="draft",this.skillEditTab="SKILL.md",this.skillDrafts=[],this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.contactsLoading=!1,this.contactsSaving=!1,this.contactsRecords=[],this.contactsError=null,this.contactsSearchQuery="",this.contactsEditingId=null,this.contactsShowAddForm=!1,this.contactsNewPhone="",this.contactsNewName="",this.contactsDeleteConfirmId=null,this.contactsAddFieldForId=null,this.contactsAddFieldKey="",this.contactsAddFieldValue="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.infoModalOpen=null,this.remoteAccessQrDataUrl=null,this.publicChatQrDataUrl=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={...zk},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.logsChipsExpanded=!1,this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,tool_call:!0,tool_result:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsChipsExpanded=!1,this.sessionLogsExpandedIds=new Set,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.onLoadOlder=()=>this.handleLoadOlderChat(),this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>Df(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null,this._beforeUnloadHandler=()=>{var t;vo();const e=this.selectedWorkspace??((t=this.publicChatConfig)==null?void 0:t.accountId)??"";e&&Wn(e,this.sessionKey,this.chatMessage)}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),Hk(this),window.addEventListener("beforeunload",this._beforeUnloadHandler)}firstUpdated(){jk(this)}disconnectedCallback(){window.removeEventListener("beforeunload",this._beforeUnloadHandler),this.stopEmbeddingPoll(),Gk(this),super.disconnectedCallback()}startEmbeddingPoll(){if(this.embeddingPollTimer!=null)return;const e=async()=>{if(!(!this.client||!this.connected)){try{const t=await this.client.request("memory.status",{});if((t==null?void 0:t.embeddingState)==="downloading")this.embeddingDownloading=!0;else{this.embeddingDownloading&&(this.embeddingDownloading=!1),this.stopEmbeddingPoll();return}}catch{this.embeddingDownloading=!1,this.stopEmbeddingPoll();return}this.embeddingPollTimer=window.setTimeout(e,3e3)}};e()}stopEmbeddingPoll(){this.embeddingPollTimer!=null&&(window.clearTimeout(this.embeddingPollTimer),this.embeddingPollTimer=null)}updated(e){Vk(this,e)}connect(){De(this)}handleChatScroll(e){Yp(this,e)}handleLogsScroll(e){Zp(this,e)}handleSessionLogsScroll(e){eh(this,e)}exportLogs(e,t){nh(e,t)}exportSessionLogs(e,t){ih(e,t)}resetToolStream(){Xo(this)}resetChatScroll(){th(this)}async loadAssistantIdentity(){await zo(this)}applySettings(e){rt(this,e)}setTab(e){Tf(this,e)}setTheme(e,t){_f(this,e,t)}async loadOverview(){await id(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.accountId=(e==null?void 0:e.whatsappAccountId)??void 0,this.cronForm={...this.cronForm,accountId:(e==null?void 0:e.whatsappAccountId)??void 0},await ma(this)}async handleAbortChat(){await od(this)}removeQueuedMessage(e){Ff(this,e)}async handleSendChat(e,t){await Uf(this,e,t)}async handleWhatsAppStart(e,t){await Jk(this,e,t)}async handleWhatsAppWait(e){await Yk(this,e)}async handleWhatsAppLogout(e){await Xk(this,e)}async handleAddWhatsAppAccount(e){await Zk(this,e)}async handleRemoveWhatsAppAccount(e){await e0(this,e)}async handleAccessCheck(){await Ml(this)}async handlePinSubmit(e,t){await $k(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await Sk(this,e)}async handleLogout(){await Ck(this)}toggleChangePinMode(){this.loginChangePinMode=!this.loginChangePinMode,this.changePinError=null,this.changePinSuccess=null}async handleChangePin(e,t,n){if(this.client){this.changePinBusy=!0,this.changePinError=null,this.changePinSuccess=null;try{const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.changePinError=i.message??"Incorrect current PIN",this.changePinBusy=!1;return}e==="__master__"?await this.client.request("access.setMasterPin",{pin:n}):await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.changePinSuccess="PIN changed successfully",this.changePinBusy=!1,setTimeout(()=>{this.loginChangePinMode=!1,this.changePinSuccess=null},2e3)}catch{this.changePinError="Failed to change PIN",this.changePinBusy=!1}}}async handleAccountPinSave(e,t,n){if(this.client){this.accountPinBusy=!0,this.accountPinError=null,this.accountPinSuccess=null;try{if(t!==null){const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.accountPinError=i.message??"Incorrect current PIN",this.accountPinBusy=!1;return}}await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.accountPinSuccess="PIN saved",this.accountPinBusy=!1,await Ml(this),setTimeout(()=>{this.accountPinModalOpen=!1,this.accountPinSuccess=null,this.accountPinError=null},1500)}catch{this.accountPinError="Failed to save PIN",this.accountPinBusy=!1}}}async handleLicenseStatusCheck(){await g0(this)}async handleLicenseActivate(){await m0(this)}async handleLicenseRemove(){await y0(this)}handleLicenseKeyChange(e){v0(this,e)}async handleAuthStatusCheck(){await d0(this)}async handleAuthStart(){await u0(this)}async handleAuthSubmitCode(e){await p0(this,e)}handleAuthCodeChange(e){h0(this,e)}handleSkipToWhatsApp(){f0(this)}async handleGatewayHealthCheck(){await b0(this)}async handleGatewayRestart(){await w0(this)}async handleUpdateCheck(){await fu(this)}async handleUpdateRun(){await ok(this)}handleUpdateDismissResult(){lk(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 le(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Mr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){le(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Mr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await Yc(this)}async clearAudit(){await lf(this),this.auditModalOpen=!1}handleFilesLoad(){var n;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((n=e==null?void 0:e.agents)==null?void 0:n.map(i=>i.id))??void 0;const t=this.resolveFilesAgentId();this.filesResolvedAgentId=t,an(this,t),ls(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();le(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>Tk);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin");return t==null?void 0:t.id}resolveFilesAgentId(){var n;const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return(t==null?void 0:t.id)??((n=e.agents[0])==null?void 0:n.id)}handleChatLoad(){const e=this.resolveAdminAgentId();if(e){const t=`agent:${e}:main`;t!==this.sessionKey&&(this.sessionKey=t,this.chatMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatRunId=null,this.chatSuggestions=[],this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}le(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>Ni);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{nn(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=Xp(this),{loadOlderChatHistory:t}=await le(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>Ni);return{loadOlderChatHistory:i}},void 0,import.meta.url);await t(this)&&e&&(await this.updateComplete,e())}handleAdvancedLoad(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.sessionLogsEntries=[],this.sessionLogsCursors={},this.sessionLogsAgents=[],this.advancedTab==="cron"&&this.loadCron(),this.advancedTab==="logs"&&(this.logsSubTab==="session"?le(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>Jc);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):le(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>wh);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&le(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>ef);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await t0(this)}async handleChannelConfigReload(){await n0(this)}handleNostrProfileEdit(e,t){s0(this,e,t)}handleNostrProfileCancel(){o0(this)}handleNostrProfileFieldChange(e,t){a0(this,e,t)}async handleNostrProfileSave(){await l0(this)}async handleNostrProfileImport(){await c0(this)}handleNostrProfileToggleAdvanced(){r0(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleAdminsNewPhoneChange(e){this.adminsNewPhone=e,this.adminsError&&(this.adminsError=null)}handleContactsLoad(){const e=this.selectedWorkspace??void 0;le(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>_k);return{loadContacts:t}},void 0,import.meta.url).then(({loadContacts:t})=>{t(this,e)})}handleContactsNewPhoneChange(e){this.contactsNewPhone=e,this.contactsError&&(this.contactsError=null)}handleContactsNewNameChange(e){this.contactsNewName=e,this.contactsError&&(this.contactsError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await le(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>ki);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await le(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>ki);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await le(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>gh);return{loadChannels:s}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:s=>{if(!s.whatsappAccountId)return;const o=s.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await i(this,!0),await this.handleWhatsAppStart(!0,o),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(o),await i(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await le(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>ki);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 le(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>ki);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){vo(),this.selectedWorkspace&&Wn(this.selectedWorkspace,this.sessionKey,this.chatMessage),this.selectedWorkspace=e,this.publicChatQrDataUrl=null,localStorage.setItem("taskmaster-selected-workspace",e),Tn(e),mr(e),this.settings=Is(),this.chatMessage=Kn(e,this.settings.sessionKey),this.chatAttachments=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.loadAuditEntries(),this.adminsPage?this.handleAdminsLoad():this.contactsPage?this.handleContactsLoad():this.filesPage?this.handleFilesLoad():this.chatPage?this.handleChatLoad():this.advancedPage&&this.handleAdvancedLoad()}initWorkspaceSelection(){if(this.workspaces.length===0){this.reloadCurrentPageData();return}const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(i=>i.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}Tn(this.selectedWorkspace),mr(this.selectedWorkspace),this.settings=Is(),this.chatMessage=Kn(this.selectedWorkspace,this.settings.sessionKey),this.reloadCurrentPageData()}render(){return u`${Uk(this)}${this.auditModalOpen?Kk(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):w}`}};y([v()],m.prototype,"settings",2);y([v()],m.prototype,"password",2);y([v()],m.prototype,"tab",2);y([v()],m.prototype,"onboarding",2);y([v()],m.prototype,"setup",2);y([v()],m.prototype,"filesPage",2);y([v()],m.prototype,"browserPage",2);y([v()],m.prototype,"adminsPage",2);y([v()],m.prototype,"contactsPage",2);y([v()],m.prototype,"chatPage",2);y([v()],m.prototype,"advancedPage",2);y([v()],m.prototype,"advancedTab",2);y([v()],m.prototype,"publicChat",2);y([v()],m.prototype,"publicChatConfig",2);y([v()],m.prototype,"publicChatSessionKey",2);y([v()],m.prototype,"publicChatAuthenticated",2);y([v()],m.prototype,"publicChatAuthStep",2);y([v()],m.prototype,"connected",2);y([v()],m.prototype,"accessState",2);y([v()],m.prototype,"theme",2);y([v()],m.prototype,"themeResolved",2);y([v()],m.prototype,"hello",2);y([v()],m.prototype,"lastError",2);y([v()],m.prototype,"eventLog",2);y([v()],m.prototype,"assistantName",2);y([v()],m.prototype,"assistantAvatar",2);y([v()],m.prototype,"assistantAgentId",2);y([v()],m.prototype,"sessionKey",2);y([v()],m.prototype,"chatLoading",2);y([v()],m.prototype,"chatSending",2);y([v()],m.prototype,"chatMessage",2);y([v()],m.prototype,"chatMessages",2);y([v()],m.prototype,"chatHistoryTotal",2);y([v()],m.prototype,"chatHistoryHasMore",2);y([v()],m.prototype,"chatLoadingOlder",2);y([v()],m.prototype,"chatToolMessages",2);y([v()],m.prototype,"chatStream",2);y([v()],m.prototype,"chatInterimText",2);y([v()],m.prototype,"chatSuggestions",2);y([v()],m.prototype,"chatStreamStartedAt",2);y([v()],m.prototype,"chatRunId",2);y([v()],m.prototype,"compactionStatus",2);y([v()],m.prototype,"chatAvatarUrl",2);y([v()],m.prototype,"chatThinkingLevel",2);y([v()],m.prototype,"chatModelProvider",2);y([v()],m.prototype,"chatModel",2);y([v()],m.prototype,"chatModelCatalog",2);y([v()],m.prototype,"chatVerboseLevel",2);y([v()],m.prototype,"chatFillerEnabled",2);y([v()],m.prototype,"chatQueue",2);y([v()],m.prototype,"chatAttachments",2);y([v()],m.prototype,"sidebarOpen",2);y([v()],m.prototype,"sidebarContent",2);y([v()],m.prototype,"sidebarError",2);y([v()],m.prototype,"splitRatio",2);y([v()],m.prototype,"nodesLoading",2);y([v()],m.prototype,"nodes",2);y([v()],m.prototype,"devicesLoading",2);y([v()],m.prototype,"devicesError",2);y([v()],m.prototype,"devicesList",2);y([v()],m.prototype,"execApprovalsLoading",2);y([v()],m.prototype,"execApprovalsSaving",2);y([v()],m.prototype,"execApprovalsDirty",2);y([v()],m.prototype,"execApprovalsSnapshot",2);y([v()],m.prototype,"execApprovalsForm",2);y([v()],m.prototype,"execApprovalsSelectedAgent",2);y([v()],m.prototype,"execApprovalsTarget",2);y([v()],m.prototype,"execApprovalsTargetNodeId",2);y([v()],m.prototype,"execApprovalQueue",2);y([v()],m.prototype,"execApprovalBusy",2);y([v()],m.prototype,"execApprovalError",2);y([v()],m.prototype,"configLoading",2);y([v()],m.prototype,"configRaw",2);y([v()],m.prototype,"configRawOriginal",2);y([v()],m.prototype,"configValid",2);y([v()],m.prototype,"configIssues",2);y([v()],m.prototype,"configSaving",2);y([v()],m.prototype,"configApplying",2);y([v()],m.prototype,"updateRunning",2);y([v()],m.prototype,"applySessionKey",2);y([v()],m.prototype,"configSnapshot",2);y([v()],m.prototype,"configSchema",2);y([v()],m.prototype,"configSchemaVersion",2);y([v()],m.prototype,"configSchemaLoading",2);y([v()],m.prototype,"configUiHints",2);y([v()],m.prototype,"configForm",2);y([v()],m.prototype,"configFormOriginal",2);y([v()],m.prototype,"configFormDirty",2);y([v()],m.prototype,"configFormMode",2);y([v()],m.prototype,"configSearchQuery",2);y([v()],m.prototype,"configActiveSection",2);y([v()],m.prototype,"configActiveSubsection",2);y([v()],m.prototype,"channelsLoading",2);y([v()],m.prototype,"channelsSnapshot",2);y([v()],m.prototype,"channelsError",2);y([v()],m.prototype,"channelsLastSuccess",2);y([v()],m.prototype,"whatsappLoginMessage",2);y([v()],m.prototype,"whatsappLoginQrDataUrl",2);y([v()],m.prototype,"whatsappLoginConnected",2);y([v()],m.prototype,"whatsappBusy",2);y([v()],m.prototype,"whatsappActiveQrAccountId",2);y([v()],m.prototype,"whatsappPairedPhone",2);y([v()],m.prototype,"addingWhatsAppAccount",2);y([v()],m.prototype,"newWhatsAppAccountName",2);y([v()],m.prototype,"whatsappAccountError",2);y([v()],m.prototype,"whatsappAccountSaving",2);y([v()],m.prototype,"whatsappSettingsOpen",2);y([v()],m.prototype,"publicChatToggleBusy",2);y([v()],m.prototype,"publicChatGreetingBusy",2);y([v()],m.prototype,"publicChatEmailBusy",2);y([v()],m.prototype,"publicChatSettingsOpen",2);y([v()],m.prototype,"publicChatWidgetModalOpen",2);y([v()],m.prototype,"brandingBusy",2);y([v()],m.prototype,"brandingExpanded",2);y([v()],m.prototype,"tailscaleStatus",2);y([v()],m.prototype,"tailscaleBusy",2);y([v()],m.prototype,"tailscaleAuthUrl",2);y([v()],m.prototype,"tailscaleError",2);y([v()],m.prototype,"tailscaleServeEnableUrl",2);y([v()],m.prototype,"tailscaleFunnelEnableUrl",2);y([v()],m.prototype,"tailscaleDisableConfirm",2);y([v()],m.prototype,"tailscaleConnectProgress",2);y([v()],m.prototype,"tailscaleConnectMessage",2);y([v()],m.prototype,"tailscaleConnectSuccess",2);y([v()],m.prototype,"wifiStatus",2);y([v()],m.prototype,"wifiNetworks",2);y([v()],m.prototype,"wifiBusy",2);y([v()],m.prototype,"wifiError",2);y([v()],m.prototype,"wifiPassword",2);y([v()],m.prototype,"wifiSelectedSsid",2);y([v()],m.prototype,"networkPort",2);y([v()],m.prototype,"networkHostname",2);y([v()],m.prototype,"networkPortInput",2);y([v()],m.prototype,"networkHostnameInput",2);y([v()],m.prototype,"networkModalOpen",2);y([v()],m.prototype,"networkBusy",2);y([v()],m.prototype,"networkError",2);y([v()],m.prototype,"networkSuccess",2);y([v()],m.prototype,"wifiModalOpen",2);y([v()],m.prototype,"licenseKey",2);y([v()],m.prototype,"licenseBusy",2);y([v()],m.prototype,"licenseValid",2);y([v()],m.prototype,"licenseMessage",2);y([v()],m.prototype,"licenseTier",2);y([v()],m.prototype,"licenseDeviceId",2);y([v()],m.prototype,"licenseStoredKey",2);y([v()],m.prototype,"licenseRemoveConfirm",2);y([v()],m.prototype,"authConnected",2);y([v()],m.prototype,"authBusy",2);y([v()],m.prototype,"authMessage",2);y([v()],m.prototype,"authUrl",2);y([v()],m.prototype,"authCodeInput",2);y([v()],m.prototype,"authExpiresIn",2);y([v()],m.prototype,"setupStep",2);y([v()],m.prototype,"gatewayHealthy",2);y([v()],m.prototype,"gatewayHealthLoading",2);y([v()],m.prototype,"gatewayHealthMessage",2);y([v()],m.prototype,"gatewayRestartBusy",2);y([v()],m.prototype,"updateAvailable",2);y([v()],m.prototype,"currentVersion",2);y([v()],m.prototype,"latestVersion",2);y([v()],m.prototype,"updateChecking",2);y([v()],m.prototype,"updateMessage",2);y([v()],m.prototype,"updateProgressSteps",2);y([v()],m.prototype,"updateLastResult",2);y([v()],m.prototype,"uninstallConfirm",2);y([v()],m.prototype,"uninstallBusy",2);y([v()],m.prototype,"uninstallDone",2);y([v()],m.prototype,"uninstallError",2);y([v()],m.prototype,"uninstallConfirmText",2);y([v()],m.prototype,"nostrProfileFormState",2);y([v()],m.prototype,"nostrProfileAccountId",2);y([v()],m.prototype,"presenceLoading",2);y([v()],m.prototype,"presenceEntries",2);y([v()],m.prototype,"presenceError",2);y([v()],m.prototype,"presenceStatus",2);y([v()],m.prototype,"agentsLoading",2);y([v()],m.prototype,"agentsList",2);y([v()],m.prototype,"agentsError",2);y([v()],m.prototype,"sessionsLoading",2);y([v()],m.prototype,"sessionsResult",2);y([v()],m.prototype,"sessionsError",2);y([v()],m.prototype,"cronLoading",2);y([v()],m.prototype,"cronJobs",2);y([v()],m.prototype,"cronStatus",2);y([v()],m.prototype,"cronError",2);y([v()],m.prototype,"cronForm",2);y([v()],m.prototype,"cronRunsJobId",2);y([v()],m.prototype,"cronRuns",2);y([v()],m.prototype,"cronBusy",2);y([v()],m.prototype,"cronNewEventModal",2);y([v()],m.prototype,"cronDetailJobId",2);y([v()],m.prototype,"cronEditJobId",2);y([v()],m.prototype,"cronPendingDeleteId",2);y([v()],m.prototype,"cronRunModalJobId",2);y([v()],m.prototype,"cronRunModalJobName",2);y([v()],m.prototype,"cronRunResult",2);y([v()],m.prototype,"browserScreencastActive",2);y([v()],m.prototype,"browserScreencastFrame",2);y([v()],m.prototype,"browserScreencastMetadata",2);y([v()],m.prototype,"browserHandoffPending",2);y([v()],m.prototype,"browserHandoffReason",2);y([v()],m.prototype,"browserHandoffId",2);y([v()],m.prototype,"browserInputMode",2);y([v()],m.prototype,"browserFullscreen",2);y([v()],m.prototype,"browserLoading",2);y([v()],m.prototype,"browserError",2);y([v()],m.prototype,"filesLoading",2);y([v()],m.prototype,"filesTree",2);y([v()],m.prototype,"filesRoot",2);y([v()],m.prototype,"filesError",2);y([v()],m.prototype,"filesSelectedPath",2);y([v()],m.prototype,"filesSelectedPaths",2);y([v()],m.prototype,"filesPreviewContent",2);y([v()],m.prototype,"filesPreviewLoading",2);y([v()],m.prototype,"filesPreviewBinary",2);y([v()],m.prototype,"filesPreviewSize",2);y([v()],m.prototype,"filesExpandedDirs",2);y([v()],m.prototype,"filesCurrentDir",2);y([v()],m.prototype,"filesPendingDeletePath",2);y([v()],m.prototype,"filesMessage",2);y([v()],m.prototype,"filesUploadBusy",2);y([v()],m.prototype,"filesReindexBusy",2);y([v()],m.prototype,"filesMemoryStatus",2);y([v()],m.prototype,"embeddingDownloading",2);y([v()],m.prototype,"filesSearchQuery",2);y([v()],m.prototype,"filesSearchResults",2);y([v()],m.prototype,"filesSearchLoading",2);y([v()],m.prototype,"filesSearchAgentId",2);y([v()],m.prototype,"auditEntries",2);y([v()],m.prototype,"auditLoading",2);y([v()],m.prototype,"auditModalOpen",2);y([v()],m.prototype,"skillsLoading",2);y([v()],m.prototype,"skillsReport",2);y([v()],m.prototype,"skillsError",2);y([v()],m.prototype,"skillsFilter",2);y([v()],m.prototype,"skillsTypeFilter",2);y([v()],m.prototype,"skillEdits",2);y([v()],m.prototype,"skillsBusyKey",2);y([v()],m.prototype,"skillMessages",2);y([v()],m.prototype,"skillDetail",2);y([v()],m.prototype,"skillDetailTab",2);y([v()],m.prototype,"skillAddModal",2);y([v()],m.prototype,"skillAddForm",2);y([v()],m.prototype,"skillAddFormSource",2);y([v()],m.prototype,"skillEditTab",2);y([v()],m.prototype,"skillDrafts",2);y([v()],m.prototype,"adminsLoading",2);y([v()],m.prototype,"adminPhones",2);y([v()],m.prototype,"adminsError",2);y([v()],m.prototype,"adminsSaving",2);y([v()],m.prototype,"adminsNewPhone",2);y([v()],m.prototype,"contactsLoading",2);y([v()],m.prototype,"contactsSaving",2);y([v()],m.prototype,"contactsRecords",2);y([v()],m.prototype,"contactsError",2);y([v()],m.prototype,"contactsSearchQuery",2);y([v()],m.prototype,"contactsEditingId",2);y([v()],m.prototype,"contactsShowAddForm",2);y([v()],m.prototype,"contactsNewPhone",2);y([v()],m.prototype,"contactsNewName",2);y([v()],m.prototype,"contactsDeleteConfirmId",2);y([v()],m.prototype,"contactsAddFieldForId",2);y([v()],m.prototype,"contactsAddFieldKey",2);y([v()],m.prototype,"contactsAddFieldValue",2);y([v()],m.prototype,"imessageEnableConfirm",2);y([v()],m.prototype,"imessageEnabling",2);y([v()],m.prototype,"infoModalOpen",2);y([v()],m.prototype,"remoteAccessQrDataUrl",2);y([v()],m.prototype,"publicChatQrDataUrl",2);y([v()],m.prototype,"workspaces",2);y([v()],m.prototype,"workspacesLoading",2);y([v()],m.prototype,"workspacesError",2);y([v()],m.prototype,"selectedWorkspace",2);y([v()],m.prototype,"addingWorkspace",2);y([v()],m.prototype,"newWorkspaceName",2);y([v()],m.prototype,"newWorkspacePath",2);y([v()],m.prototype,"newWorkspacePin",2);y([v()],m.prototype,"accountPinModalOpen",2);y([v()],m.prototype,"accountPinBusy",2);y([v()],m.prototype,"accountPinError",2);y([v()],m.prototype,"accountPinSuccess",2);y([v()],m.prototype,"apiKeyProviders",2);y([v()],m.prototype,"apiKeyModalOpen",2);y([v()],m.prototype,"apiKeyBusy",2);y([v()],m.prototype,"apiKeyError",2);y([v()],m.prototype,"apiKeySuccess",2);y([v()],m.prototype,"apiKeySavingProvider",2);y([v()],m.prototype,"authApiKeyMode",2);y([v()],m.prototype,"authApiKeyInput",2);y([v()],m.prototype,"authApiKeyBusy",2);y([v()],m.prototype,"authApiKeyError",2);y([v()],m.prototype,"pinChanging",2);y([v()],m.prototype,"pinChangeBusy",2);y([v()],m.prototype,"pinChangeError",2);y([v()],m.prototype,"loginChangePinMode",2);y([v()],m.prototype,"changePinBusy",2);y([v()],m.prototype,"changePinError",2);y([v()],m.prototype,"changePinSuccess",2);y([v()],m.prototype,"workspaceSaving",2);y([v()],m.prototype,"workspaceRemoveConfirm",2);y([v()],m.prototype,"renamingWorkspace",2);y([v()],m.prototype,"renameWorkspaceName",2);y([v()],m.prototype,"debugLoading",2);y([v()],m.prototype,"debugStatus",2);y([v()],m.prototype,"debugHealth",2);y([v()],m.prototype,"debugModels",2);y([v()],m.prototype,"debugHeartbeat",2);y([v()],m.prototype,"debugCallMethod",2);y([v()],m.prototype,"debugCallParams",2);y([v()],m.prototype,"debugCallResult",2);y([v()],m.prototype,"debugCallError",2);y([v()],m.prototype,"logsLoading",2);y([v()],m.prototype,"logsError",2);y([v()],m.prototype,"logsFile",2);y([v()],m.prototype,"logsEntries",2);y([v()],m.prototype,"logsFilterText",2);y([v()],m.prototype,"logsLevelFilters",2);y([v()],m.prototype,"logsAutoFollow",2);y([v()],m.prototype,"logsTruncated",2);y([v()],m.prototype,"logsCursor",2);y([v()],m.prototype,"logsLastFetchAt",2);y([v()],m.prototype,"logsLimit",2);y([v()],m.prototype,"logsMaxBytes",2);y([v()],m.prototype,"logsAtBottom",2);y([v()],m.prototype,"logsSubTab",2);y([v()],m.prototype,"logsChipsExpanded",2);y([v()],m.prototype,"sessionLogsLoading",2);y([v()],m.prototype,"sessionLogsError",2);y([v()],m.prototype,"sessionLogsEntries",2);y([v()],m.prototype,"sessionLogsFilterText",2);y([v()],m.prototype,"sessionLogsTypeFilters",2);y([v()],m.prototype,"sessionLogsAgentFilters",2);y([v()],m.prototype,"sessionLogsAgents",2);y([v()],m.prototype,"sessionLogsAutoFollow",2);y([v()],m.prototype,"sessionLogsChipsExpanded",2);y([v()],m.prototype,"sessionLogsCursors",2);y([v()],m.prototype,"sessionLogsLastFetchAt",2);y([v()],m.prototype,"sessionLogsAtBottom",2);y([v()],m.prototype,"chatUserNearBottom",2);m=y([Wl("taskmaster-app")],m);
4565
- //# sourceMappingURL=index-CP9IoaZp.js.map
4676
+ `,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.whatsappActiveQrAccountId=null,this.whatsappPairedPhone=null,this.addingWhatsAppAccount=!1,this.newWhatsAppAccountName="",this.whatsappAccountError=null,this.whatsappAccountSaving=!1,this.whatsappSettingsOpen=!1,this.publicChatToggleBusy=!1,this.publicChatGreetingBusy=!1,this.publicChatEmailBusy=!1,this.publicChatSettingsOpen=!1,this.publicChatWidgetModalOpen=!1,this.brandingBusy=!1,this.brandingExpanded=!1,this.tailscaleStatus=null,this.tailscaleBusy=!1,this.tailscaleAuthUrl=null,this.tailscaleError=null,this.tailscaleServeEnableUrl=null,this.tailscaleFunnelEnableUrl=null,this.tailscaleDisableConfirm=!1,this.tailscaleConnectProgress=0,this.tailscaleConnectMessage="",this.tailscaleConnectSuccess=!1,this.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,this.networkPort=null,this.networkHostname="",this.networkPortInput="",this.networkHostnameInput="",this.networkModalOpen=!1,this.networkBusy=!1,this.networkError=null,this.networkSuccess=null,this.wifiModalOpen=!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={...l0},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.cronEditJobId=null,this.cronPendingDeleteId=null,this.cronRunModalJobId=null,this.cronRunModalJobName="",this.cronRunResult=null,this.openingHoursLoading=!1,this.openingHoursError=null,this.openingHoursBusy=!1,this.openingHoursForm=Wa(),this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserFullscreen=!1,this.browserLoading=!1,this.browserError=null,this.filesLoading=!1,this.filesTree=[],this.filesRoot="",this.filesError=null,this.filesSelectedPath=null,this.filesSelectedPaths=new Set,this.filesPreviewContent=null,this.filesPreviewLoading=!1,this.filesPreviewBinary=!1,this.filesPreviewSize=null,this.filesExpandedDirs=new Set,this.filesCurrentDir=".",this.filesPendingDeletePath=null,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.embeddingDownloading=!1,this.embeddingPollTimer=null,this.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.filesResolvedAgentId=void 0,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillsTypeFilter="all",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillDetail=null,this.skillDetailTab="",this.skillAddModal=!1,this.skillAddForm={name:"",skillContent:"",references:[]},this.skillAddFormSource="draft",this.skillEditTab="SKILL.md",this.skillDrafts=[],this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.contactsLoading=!1,this.contactsSaving=!1,this.contactsRecords=[],this.contactsError=null,this.contactsSearchQuery="",this.contactsEditingId=null,this.contactsShowAddForm=!1,this.contactsNewPhone="",this.contactsNewName="",this.contactsDeleteConfirmId=null,this.contactsAddFieldForId=null,this.contactsAddFieldKey="",this.contactsAddFieldValue="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.infoModalOpen=null,this.remoteAccessQrDataUrl=null,this.publicChatQrDataUrl=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={...r0},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.logsChipsExpanded=!1,this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,tool_call:!0,tool_result:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsChipsExpanded=!1,this.sessionLogsExpandedIds=new Set,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.onLoadOlder=()=>this.handleLoadOlderChat(),this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>Wf(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null,this._beforeUnloadHandler=()=>{var t;bo();const e=this.selectedWorkspace??((t=this.publicChatConfig)==null?void 0:t.accountId)??"";e&&Wn(e,this.sessionKey,this.chatMessage)}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),c0(this),window.addEventListener("beforeunload",this._beforeUnloadHandler)}firstUpdated(){d0(this)}disconnectedCallback(){window.removeEventListener("beforeunload",this._beforeUnloadHandler),this.stopEmbeddingPoll(),u0(this),super.disconnectedCallback()}startEmbeddingPoll(){if(this.embeddingPollTimer!=null)return;const e=async()=>{if(!(!this.client||!this.connected)){try{const t=await this.client.request("memory.status",{});if((t==null?void 0:t.embeddingState)==="downloading")this.embeddingDownloading=!0;else{this.embeddingDownloading&&(this.embeddingDownloading=!1),this.stopEmbeddingPoll();return}}catch{this.embeddingDownloading=!1,this.stopEmbeddingPoll();return}this.embeddingPollTimer=window.setTimeout(e,3e3)}};e()}stopEmbeddingPoll(){this.embeddingPollTimer!=null&&(window.clearTimeout(this.embeddingPollTimer),this.embeddingPollTimer=null)}updated(e){p0(this,e)}connect(){De(this)}handleChatScroll(e){ih(this,e)}handleLogsScroll(e){oh(this,e)}handleSessionLogsScroll(e){ah(this,e)}exportLogs(e,t){lh(e,t)}exportSessionLogs(e,t){ch(e,t)}resetToolStream(){Zo(this)}resetChatScroll(){rh(this)}async loadAssistantIdentity(){await Ho(this)}applySettings(e){rt(this,e)}setTab(e){Rf(this,e)}setTheme(e,t){Df(this,e,t)}async loadOverview(){await rd(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.accountId=(e==null?void 0:e.whatsappAccountId)??void 0,this.cronForm={...this.cronForm,accountId:(e==null?void 0:e.whatsappAccountId)??void 0},await ya(this)}async handleAbortChat(){await cd(this)}removeQueuedMessage(e){qf(this,e)}async handleSendChat(e,t){await jf(this,e,t)}async handleWhatsAppStart(e,t){await f0(this,e,t)}async handleWhatsAppWait(e){await g0(this,e)}async handleWhatsAppLogout(e){await m0(this,e)}async handleAddWhatsAppAccount(e){await y0(this,e)}async handleRemoveWhatsAppAccount(e){await v0(this,e)}async handleAccessCheck(){await Rl(this)}async handlePinSubmit(e,t){await Uk(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await Wk(this,e)}async handleLogout(){await zk(this)}toggleChangePinMode(){this.loginChangePinMode=!this.loginChangePinMode,this.changePinError=null,this.changePinSuccess=null}async handleChangePin(e,t,n){if(this.client){this.changePinBusy=!0,this.changePinError=null,this.changePinSuccess=null;try{const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.changePinError=i.message??"Incorrect current PIN",this.changePinBusy=!1;return}e==="__master__"?await this.client.request("access.setMasterPin",{pin:n}):await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.changePinSuccess="PIN changed successfully",this.changePinBusy=!1,setTimeout(()=>{this.loginChangePinMode=!1,this.changePinSuccess=null},2e3)}catch{this.changePinError="Failed to change PIN",this.changePinBusy=!1}}}async handleAccountPinSave(e,t,n){if(this.client){this.accountPinBusy=!0,this.accountPinError=null,this.accountPinSuccess=null;try{if(t!==null){const i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.accountPinError=i.message??"Incorrect current PIN",this.accountPinBusy=!1;return}}await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.accountPinSuccess="PIN saved",this.accountPinBusy=!1,await Rl(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 L0(this)}async handleLicenseActivate(){await R0(this)}async handleLicenseRemove(){await D0(this)}handleLicenseKeyChange(e){B0(this,e)}async handleAuthStatusCheck(){await T0(this)}async handleAuthStart(){await _0(this)}async handleAuthSubmitCode(e){await M0(this,e)}handleAuthCodeChange(e){P0(this,e)}handleSkipToWhatsApp(){I0(this)}async handleGatewayHealthCheck(){await N0(this)}async handleGatewayRestart(){await O0(this)}async handleUpdateCheck(){await vu(this)}async handleUpdateRun(){await kk(this)}handleUpdateDismissResult(){Sk(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 ae(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Lr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){ae(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Lr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await td(this)}async clearAudit(){await ff(this),this.auditModalOpen=!1}handleFilesLoad(){var n;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((n=e==null?void 0:e.agents)==null?void 0:n.map(i=>i.id))??void 0;const t=this.resolveFilesAgentId();this.filesResolvedAgentId=t,an(this,t),cs(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();ae(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>jk);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin");return t==null?void 0:t.id}resolveFilesAgentId(){var n;const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return(t==null?void 0:t.id)??((n=e.agents[0])==null?void 0:n.id)}handleChatLoad(){const e=this.resolveAdminAgentId();if(e){const t=`agent:${e}:main`;t!==this.sessionKey&&(this.sessionKey=t,this.chatMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatRunId=null,this.chatSuggestions=[],this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}ae(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>Oi);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{nn(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=sh(this),{loadOlderChatHistory:t}=await ae(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>Oi);return{loadOlderChatHistory:i}},void 0,import.meta.url);await t(this)&&e&&(await this.updateComplete,e())}handleAdvancedLoad(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.sessionLogsEntries=[],this.sessionLogsCursors={},this.sessionLogsAgents=[],this.advancedTab==="cron"&&this.loadCron(),this.advancedTab==="opening-hours"&&ae(async()=>{const{loadOpeningHours:n}=await Promise.resolve().then(()=>Hk);return{loadOpeningHours:n}},void 0,import.meta.url).then(({loadOpeningHours:n})=>{n(this)}),this.advancedTab==="logs"&&(this.logsSubTab==="session"?ae(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>ed);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):ae(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>Ch);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&ae(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>rf);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await b0(this)}async handleChannelConfigReload(){await w0(this)}handleNostrProfileEdit(e,t){x0(this,e,t)}handleNostrProfileCancel(){$0(this)}handleNostrProfileFieldChange(e,t){S0(this,e,t)}async handleNostrProfileSave(){await C0(this)}async handleNostrProfileImport(){await E0(this)}handleNostrProfileToggleAdvanced(){A0(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleAdminsNewPhoneChange(e){this.adminsNewPhone=e,this.adminsError&&(this.adminsError=null)}handleContactsLoad(){const e=this.selectedWorkspace??void 0;ae(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>Gk);return{loadContacts:t}},void 0,import.meta.url).then(({loadContacts:t})=>{t(this,e)})}handleContactsNewPhoneChange(e){this.contactsNewPhone=e,this.contactsError&&(this.contactsError=null)}handleContactsNewNameChange(e){this.contactsNewName=e,this.contactsError&&(this.contactsError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await ae(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>xi);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await ae(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>xi);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await ae(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>kh);return{loadChannels:s}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:s=>{if(!s.whatsappAccountId)return;const o=s.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await i(this,!0),await this.handleWhatsAppStart(!0,o),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(o),await i(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await ae(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>xi);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 ae(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>xi);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){bo(),this.selectedWorkspace&&Wn(this.selectedWorkspace,this.sessionKey,this.chatMessage),this.selectedWorkspace=e,this.publicChatQrDataUrl=null,localStorage.setItem("taskmaster-selected-workspace",e),Tn(e),br(e),this.settings=Ls(),this.chatMessage=Kn(e,this.settings.sessionKey),this.chatAttachments=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.loadAuditEntries(),this.adminsPage?this.handleAdminsLoad():this.contactsPage?this.handleContactsLoad():this.filesPage?this.handleFilesLoad():this.chatPage?this.handleChatLoad():this.advancedPage&&this.handleAdvancedLoad()}initWorkspaceSelection(){if(this.workspaces.length===0){this.reloadCurrentPageData();return}const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(i=>i.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}Tn(this.selectedWorkspace),br(this.selectedWorkspace),this.settings=Ls(),this.chatMessage=Kn(this.selectedWorkspace,this.settings.sessionKey),this.reloadCurrentPageData()}render(){return u`${s0(this)}${this.auditModalOpen?a0(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):w}`}};y([v()],m.prototype,"settings",2);y([v()],m.prototype,"password",2);y([v()],m.prototype,"tab",2);y([v()],m.prototype,"onboarding",2);y([v()],m.prototype,"setup",2);y([v()],m.prototype,"filesPage",2);y([v()],m.prototype,"browserPage",2);y([v()],m.prototype,"adminsPage",2);y([v()],m.prototype,"contactsPage",2);y([v()],m.prototype,"chatPage",2);y([v()],m.prototype,"advancedPage",2);y([v()],m.prototype,"advancedTab",2);y([v()],m.prototype,"publicChat",2);y([v()],m.prototype,"publicChatConfig",2);y([v()],m.prototype,"publicChatSessionKey",2);y([v()],m.prototype,"publicChatAuthenticated",2);y([v()],m.prototype,"publicChatAuthStep",2);y([v()],m.prototype,"connected",2);y([v()],m.prototype,"accessState",2);y([v()],m.prototype,"theme",2);y([v()],m.prototype,"themeResolved",2);y([v()],m.prototype,"hello",2);y([v()],m.prototype,"lastError",2);y([v()],m.prototype,"eventLog",2);y([v()],m.prototype,"assistantName",2);y([v()],m.prototype,"assistantAvatar",2);y([v()],m.prototype,"assistantAgentId",2);y([v()],m.prototype,"sessionKey",2);y([v()],m.prototype,"chatLoading",2);y([v()],m.prototype,"chatSending",2);y([v()],m.prototype,"chatMessage",2);y([v()],m.prototype,"chatMessages",2);y([v()],m.prototype,"chatHistoryTotal",2);y([v()],m.prototype,"chatHistoryHasMore",2);y([v()],m.prototype,"chatLoadingOlder",2);y([v()],m.prototype,"chatToolMessages",2);y([v()],m.prototype,"chatStream",2);y([v()],m.prototype,"chatInterimText",2);y([v()],m.prototype,"chatSuggestions",2);y([v()],m.prototype,"chatStreamStartedAt",2);y([v()],m.prototype,"chatRunId",2);y([v()],m.prototype,"compactionStatus",2);y([v()],m.prototype,"chatAvatarUrl",2);y([v()],m.prototype,"chatThinkingLevel",2);y([v()],m.prototype,"chatModelProvider",2);y([v()],m.prototype,"chatModel",2);y([v()],m.prototype,"chatModelCatalog",2);y([v()],m.prototype,"chatVerboseLevel",2);y([v()],m.prototype,"chatFillerEnabled",2);y([v()],m.prototype,"chatQueue",2);y([v()],m.prototype,"chatAttachments",2);y([v()],m.prototype,"sidebarOpen",2);y([v()],m.prototype,"sidebarContent",2);y([v()],m.prototype,"sidebarError",2);y([v()],m.prototype,"splitRatio",2);y([v()],m.prototype,"nodesLoading",2);y([v()],m.prototype,"nodes",2);y([v()],m.prototype,"devicesLoading",2);y([v()],m.prototype,"devicesError",2);y([v()],m.prototype,"devicesList",2);y([v()],m.prototype,"execApprovalsLoading",2);y([v()],m.prototype,"execApprovalsSaving",2);y([v()],m.prototype,"execApprovalsDirty",2);y([v()],m.prototype,"execApprovalsSnapshot",2);y([v()],m.prototype,"execApprovalsForm",2);y([v()],m.prototype,"execApprovalsSelectedAgent",2);y([v()],m.prototype,"execApprovalsTarget",2);y([v()],m.prototype,"execApprovalsTargetNodeId",2);y([v()],m.prototype,"execApprovalQueue",2);y([v()],m.prototype,"execApprovalBusy",2);y([v()],m.prototype,"execApprovalError",2);y([v()],m.prototype,"configLoading",2);y([v()],m.prototype,"configRaw",2);y([v()],m.prototype,"configRawOriginal",2);y([v()],m.prototype,"configValid",2);y([v()],m.prototype,"configIssues",2);y([v()],m.prototype,"configSaving",2);y([v()],m.prototype,"configApplying",2);y([v()],m.prototype,"updateRunning",2);y([v()],m.prototype,"applySessionKey",2);y([v()],m.prototype,"configSnapshot",2);y([v()],m.prototype,"configSchema",2);y([v()],m.prototype,"configSchemaVersion",2);y([v()],m.prototype,"configSchemaLoading",2);y([v()],m.prototype,"configUiHints",2);y([v()],m.prototype,"configForm",2);y([v()],m.prototype,"configFormOriginal",2);y([v()],m.prototype,"configFormDirty",2);y([v()],m.prototype,"configFormMode",2);y([v()],m.prototype,"configSearchQuery",2);y([v()],m.prototype,"configActiveSection",2);y([v()],m.prototype,"configActiveSubsection",2);y([v()],m.prototype,"channelsLoading",2);y([v()],m.prototype,"channelsSnapshot",2);y([v()],m.prototype,"channelsError",2);y([v()],m.prototype,"channelsLastSuccess",2);y([v()],m.prototype,"whatsappLoginMessage",2);y([v()],m.prototype,"whatsappLoginQrDataUrl",2);y([v()],m.prototype,"whatsappLoginConnected",2);y([v()],m.prototype,"whatsappBusy",2);y([v()],m.prototype,"whatsappActiveQrAccountId",2);y([v()],m.prototype,"whatsappPairedPhone",2);y([v()],m.prototype,"addingWhatsAppAccount",2);y([v()],m.prototype,"newWhatsAppAccountName",2);y([v()],m.prototype,"whatsappAccountError",2);y([v()],m.prototype,"whatsappAccountSaving",2);y([v()],m.prototype,"whatsappSettingsOpen",2);y([v()],m.prototype,"publicChatToggleBusy",2);y([v()],m.prototype,"publicChatGreetingBusy",2);y([v()],m.prototype,"publicChatEmailBusy",2);y([v()],m.prototype,"publicChatSettingsOpen",2);y([v()],m.prototype,"publicChatWidgetModalOpen",2);y([v()],m.prototype,"brandingBusy",2);y([v()],m.prototype,"brandingExpanded",2);y([v()],m.prototype,"tailscaleStatus",2);y([v()],m.prototype,"tailscaleBusy",2);y([v()],m.prototype,"tailscaleAuthUrl",2);y([v()],m.prototype,"tailscaleError",2);y([v()],m.prototype,"tailscaleServeEnableUrl",2);y([v()],m.prototype,"tailscaleFunnelEnableUrl",2);y([v()],m.prototype,"tailscaleDisableConfirm",2);y([v()],m.prototype,"tailscaleConnectProgress",2);y([v()],m.prototype,"tailscaleConnectMessage",2);y([v()],m.prototype,"tailscaleConnectSuccess",2);y([v()],m.prototype,"wifiStatus",2);y([v()],m.prototype,"wifiNetworks",2);y([v()],m.prototype,"wifiBusy",2);y([v()],m.prototype,"wifiError",2);y([v()],m.prototype,"wifiPassword",2);y([v()],m.prototype,"wifiSelectedSsid",2);y([v()],m.prototype,"networkPort",2);y([v()],m.prototype,"networkHostname",2);y([v()],m.prototype,"networkPortInput",2);y([v()],m.prototype,"networkHostnameInput",2);y([v()],m.prototype,"networkModalOpen",2);y([v()],m.prototype,"networkBusy",2);y([v()],m.prototype,"networkError",2);y([v()],m.prototype,"networkSuccess",2);y([v()],m.prototype,"wifiModalOpen",2);y([v()],m.prototype,"licenseKey",2);y([v()],m.prototype,"licenseBusy",2);y([v()],m.prototype,"licenseValid",2);y([v()],m.prototype,"licenseMessage",2);y([v()],m.prototype,"licenseTier",2);y([v()],m.prototype,"licenseDeviceId",2);y([v()],m.prototype,"licenseStoredKey",2);y([v()],m.prototype,"licenseRemoveConfirm",2);y([v()],m.prototype,"authConnected",2);y([v()],m.prototype,"authBusy",2);y([v()],m.prototype,"authMessage",2);y([v()],m.prototype,"authUrl",2);y([v()],m.prototype,"authCodeInput",2);y([v()],m.prototype,"authExpiresIn",2);y([v()],m.prototype,"setupStep",2);y([v()],m.prototype,"gatewayHealthy",2);y([v()],m.prototype,"gatewayHealthLoading",2);y([v()],m.prototype,"gatewayHealthMessage",2);y([v()],m.prototype,"gatewayRestartBusy",2);y([v()],m.prototype,"updateAvailable",2);y([v()],m.prototype,"currentVersion",2);y([v()],m.prototype,"latestVersion",2);y([v()],m.prototype,"updateChecking",2);y([v()],m.prototype,"updateMessage",2);y([v()],m.prototype,"updateProgressSteps",2);y([v()],m.prototype,"updateLastResult",2);y([v()],m.prototype,"uninstallConfirm",2);y([v()],m.prototype,"uninstallBusy",2);y([v()],m.prototype,"uninstallDone",2);y([v()],m.prototype,"uninstallError",2);y([v()],m.prototype,"uninstallConfirmText",2);y([v()],m.prototype,"nostrProfileFormState",2);y([v()],m.prototype,"nostrProfileAccountId",2);y([v()],m.prototype,"presenceLoading",2);y([v()],m.prototype,"presenceEntries",2);y([v()],m.prototype,"presenceError",2);y([v()],m.prototype,"presenceStatus",2);y([v()],m.prototype,"agentsLoading",2);y([v()],m.prototype,"agentsList",2);y([v()],m.prototype,"agentsError",2);y([v()],m.prototype,"sessionsLoading",2);y([v()],m.prototype,"sessionsResult",2);y([v()],m.prototype,"sessionsError",2);y([v()],m.prototype,"cronLoading",2);y([v()],m.prototype,"cronJobs",2);y([v()],m.prototype,"cronStatus",2);y([v()],m.prototype,"cronError",2);y([v()],m.prototype,"cronForm",2);y([v()],m.prototype,"cronRunsJobId",2);y([v()],m.prototype,"cronRuns",2);y([v()],m.prototype,"cronBusy",2);y([v()],m.prototype,"cronNewEventModal",2);y([v()],m.prototype,"cronDetailJobId",2);y([v()],m.prototype,"cronEditJobId",2);y([v()],m.prototype,"cronPendingDeleteId",2);y([v()],m.prototype,"cronRunModalJobId",2);y([v()],m.prototype,"cronRunModalJobName",2);y([v()],m.prototype,"cronRunResult",2);y([v()],m.prototype,"openingHoursLoading",2);y([v()],m.prototype,"openingHoursError",2);y([v()],m.prototype,"openingHoursBusy",2);y([v()],m.prototype,"openingHoursForm",2);y([v()],m.prototype,"browserScreencastActive",2);y([v()],m.prototype,"browserScreencastFrame",2);y([v()],m.prototype,"browserScreencastMetadata",2);y([v()],m.prototype,"browserHandoffPending",2);y([v()],m.prototype,"browserHandoffReason",2);y([v()],m.prototype,"browserHandoffId",2);y([v()],m.prototype,"browserInputMode",2);y([v()],m.prototype,"browserFullscreen",2);y([v()],m.prototype,"browserLoading",2);y([v()],m.prototype,"browserError",2);y([v()],m.prototype,"filesLoading",2);y([v()],m.prototype,"filesTree",2);y([v()],m.prototype,"filesRoot",2);y([v()],m.prototype,"filesError",2);y([v()],m.prototype,"filesSelectedPath",2);y([v()],m.prototype,"filesSelectedPaths",2);y([v()],m.prototype,"filesPreviewContent",2);y([v()],m.prototype,"filesPreviewLoading",2);y([v()],m.prototype,"filesPreviewBinary",2);y([v()],m.prototype,"filesPreviewSize",2);y([v()],m.prototype,"filesExpandedDirs",2);y([v()],m.prototype,"filesCurrentDir",2);y([v()],m.prototype,"filesPendingDeletePath",2);y([v()],m.prototype,"filesMessage",2);y([v()],m.prototype,"filesUploadBusy",2);y([v()],m.prototype,"filesReindexBusy",2);y([v()],m.prototype,"filesMemoryStatus",2);y([v()],m.prototype,"embeddingDownloading",2);y([v()],m.prototype,"filesSearchQuery",2);y([v()],m.prototype,"filesSearchResults",2);y([v()],m.prototype,"filesSearchLoading",2);y([v()],m.prototype,"filesSearchAgentId",2);y([v()],m.prototype,"auditEntries",2);y([v()],m.prototype,"auditLoading",2);y([v()],m.prototype,"auditModalOpen",2);y([v()],m.prototype,"skillsLoading",2);y([v()],m.prototype,"skillsReport",2);y([v()],m.prototype,"skillsError",2);y([v()],m.prototype,"skillsFilter",2);y([v()],m.prototype,"skillsTypeFilter",2);y([v()],m.prototype,"skillEdits",2);y([v()],m.prototype,"skillsBusyKey",2);y([v()],m.prototype,"skillMessages",2);y([v()],m.prototype,"skillDetail",2);y([v()],m.prototype,"skillDetailTab",2);y([v()],m.prototype,"skillAddModal",2);y([v()],m.prototype,"skillAddForm",2);y([v()],m.prototype,"skillAddFormSource",2);y([v()],m.prototype,"skillEditTab",2);y([v()],m.prototype,"skillDrafts",2);y([v()],m.prototype,"adminsLoading",2);y([v()],m.prototype,"adminPhones",2);y([v()],m.prototype,"adminsError",2);y([v()],m.prototype,"adminsSaving",2);y([v()],m.prototype,"adminsNewPhone",2);y([v()],m.prototype,"contactsLoading",2);y([v()],m.prototype,"contactsSaving",2);y([v()],m.prototype,"contactsRecords",2);y([v()],m.prototype,"contactsError",2);y([v()],m.prototype,"contactsSearchQuery",2);y([v()],m.prototype,"contactsEditingId",2);y([v()],m.prototype,"contactsShowAddForm",2);y([v()],m.prototype,"contactsNewPhone",2);y([v()],m.prototype,"contactsNewName",2);y([v()],m.prototype,"contactsDeleteConfirmId",2);y([v()],m.prototype,"contactsAddFieldForId",2);y([v()],m.prototype,"contactsAddFieldKey",2);y([v()],m.prototype,"contactsAddFieldValue",2);y([v()],m.prototype,"imessageEnableConfirm",2);y([v()],m.prototype,"imessageEnabling",2);y([v()],m.prototype,"infoModalOpen",2);y([v()],m.prototype,"remoteAccessQrDataUrl",2);y([v()],m.prototype,"publicChatQrDataUrl",2);y([v()],m.prototype,"workspaces",2);y([v()],m.prototype,"workspacesLoading",2);y([v()],m.prototype,"workspacesError",2);y([v()],m.prototype,"selectedWorkspace",2);y([v()],m.prototype,"addingWorkspace",2);y([v()],m.prototype,"newWorkspaceName",2);y([v()],m.prototype,"newWorkspacePath",2);y([v()],m.prototype,"newWorkspacePin",2);y([v()],m.prototype,"accountPinModalOpen",2);y([v()],m.prototype,"accountPinBusy",2);y([v()],m.prototype,"accountPinError",2);y([v()],m.prototype,"accountPinSuccess",2);y([v()],m.prototype,"apiKeyProviders",2);y([v()],m.prototype,"apiKeyModalOpen",2);y([v()],m.prototype,"apiKeyBusy",2);y([v()],m.prototype,"apiKeyError",2);y([v()],m.prototype,"apiKeySuccess",2);y([v()],m.prototype,"apiKeySavingProvider",2);y([v()],m.prototype,"authApiKeyMode",2);y([v()],m.prototype,"authApiKeyInput",2);y([v()],m.prototype,"authApiKeyBusy",2);y([v()],m.prototype,"authApiKeyError",2);y([v()],m.prototype,"pinChanging",2);y([v()],m.prototype,"pinChangeBusy",2);y([v()],m.prototype,"pinChangeError",2);y([v()],m.prototype,"loginChangePinMode",2);y([v()],m.prototype,"changePinBusy",2);y([v()],m.prototype,"changePinError",2);y([v()],m.prototype,"changePinSuccess",2);y([v()],m.prototype,"workspaceSaving",2);y([v()],m.prototype,"workspaceRemoveConfirm",2);y([v()],m.prototype,"renamingWorkspace",2);y([v()],m.prototype,"renameWorkspaceName",2);y([v()],m.prototype,"debugLoading",2);y([v()],m.prototype,"debugStatus",2);y([v()],m.prototype,"debugHealth",2);y([v()],m.prototype,"debugModels",2);y([v()],m.prototype,"debugHeartbeat",2);y([v()],m.prototype,"debugCallMethod",2);y([v()],m.prototype,"debugCallParams",2);y([v()],m.prototype,"debugCallResult",2);y([v()],m.prototype,"debugCallError",2);y([v()],m.prototype,"logsLoading",2);y([v()],m.prototype,"logsError",2);y([v()],m.prototype,"logsFile",2);y([v()],m.prototype,"logsEntries",2);y([v()],m.prototype,"logsFilterText",2);y([v()],m.prototype,"logsLevelFilters",2);y([v()],m.prototype,"logsAutoFollow",2);y([v()],m.prototype,"logsTruncated",2);y([v()],m.prototype,"logsCursor",2);y([v()],m.prototype,"logsLastFetchAt",2);y([v()],m.prototype,"logsLimit",2);y([v()],m.prototype,"logsMaxBytes",2);y([v()],m.prototype,"logsAtBottom",2);y([v()],m.prototype,"logsSubTab",2);y([v()],m.prototype,"logsChipsExpanded",2);y([v()],m.prototype,"sessionLogsLoading",2);y([v()],m.prototype,"sessionLogsError",2);y([v()],m.prototype,"sessionLogsEntries",2);y([v()],m.prototype,"sessionLogsFilterText",2);y([v()],m.prototype,"sessionLogsTypeFilters",2);y([v()],m.prototype,"sessionLogsAgentFilters",2);y([v()],m.prototype,"sessionLogsAgents",2);y([v()],m.prototype,"sessionLogsAutoFollow",2);y([v()],m.prototype,"sessionLogsChipsExpanded",2);y([v()],m.prototype,"sessionLogsCursors",2);y([v()],m.prototype,"sessionLogsLastFetchAt",2);y([v()],m.prototype,"sessionLogsAtBottom",2);y([v()],m.prototype,"chatUserNearBottom",2);m=y([ql("taskmaster-app")],m);
4677
+ //# sourceMappingURL=index-BWqMMgRV.js.map