@heylemon/lemonade 0.6.8 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/model-fallback.js +7 -2
- package/dist/agents/pi-tool-definition-adapter.js +83 -10
- package/dist/agents/system-prompt.js +20 -1
- package/dist/auto-reply/reply/session.js +34 -8
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui/.bundle.hash +1 -0
- package/dist/canvas-host/a2ui/a2ui.bundle.js +17775 -0
- package/dist/canvas-host/a2ui/index.html +307 -0
- package/dist/control-ui/assets/{index-0MsyRFLD.js → index-D5pbk0Cx.js} +261 -261
- package/dist/control-ui/assets/index-D5pbk0Cx.js.map +1 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/gateway/auth-rate-limit.js +121 -0
- package/dist/gateway/auth.js +26 -8
- package/dist/gateway/openai-http.js +12 -8
- package/dist/gateway/server-http.js +7 -4
- package/dist/gateway/session-utils.fs.js +18 -0
- package/dist/gateway/skills-http.js +65 -0
- package/dist/security/secret-equal.js +13 -0
- package/extensions/diagnostics-otel/node_modules/.bin/acorn +2 -2
- package/extensions/googlechat/node_modules/.bin/lemonade +2 -2
- package/extensions/line/node_modules/.bin/lemonade +2 -2
- package/extensions/matrix/node_modules/.bin/lemonade +2 -2
- package/extensions/matrix/node_modules/.bin/markdown-it +2 -2
- package/extensions/memory-core/node_modules/.bin/lemonade +2 -2
- package/extensions/memory-lancedb/node_modules/.bin/arrow2csv +2 -2
- package/extensions/memory-lancedb/node_modules/.bin/openai +2 -2
- package/extensions/msteams/node_modules/.bin/lemonade +2 -2
- package/extensions/nostr/node_modules/.bin/lemonade +2 -2
- package/extensions/nostr/node_modules/.bin/tsc +2 -2
- package/extensions/nostr/node_modules/.bin/tsserver +2 -2
- package/extensions/twitch/node_modules/.bin/lemonade +2 -2
- package/extensions/zalo/node_modules/.bin/lemonade +2 -2
- package/extensions/zalouser/node_modules/.bin/lemonade +2 -2
- package/package.json +1 -1
- package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +178 -0
- package/skills/travel-agent-persona/SKILL.md +89 -0
- package/dist/control-ui/assets/index-0MsyRFLD.js.map +0 -1
- package/extensions/googlechat/node_modules/.bin/lemon-calendar +0 -21
- package/extensions/googlechat/node_modules/.bin/lemon-cron +0 -21
- package/extensions/googlechat/node_modules/.bin/lemon-docs +0 -21
- package/extensions/googlechat/node_modules/.bin/lemon-drive +0 -21
- package/extensions/googlechat/node_modules/.bin/lemon-gmail +0 -21
- package/extensions/googlechat/node_modules/.bin/lemon-jira +0 -21
- package/extensions/googlechat/node_modules/.bin/lemon-notion +0 -21
- package/extensions/googlechat/node_modules/.bin/lemon-sheets +0 -21
- package/extensions/googlechat/node_modules/.bin/lemon-slack +0 -21
- package/extensions/googlechat/node_modules/.bin/lemon-slides +0 -21
- package/extensions/googlechat/node_modules/.bin/lemon-twitter +0 -21
- package/extensions/googlechat/node_modules/.bin/lemon-youtube +0 -21
- package/extensions/line/node_modules/.bin/lemon-calendar +0 -21
- package/extensions/line/node_modules/.bin/lemon-cron +0 -21
- package/extensions/line/node_modules/.bin/lemon-docs +0 -21
- package/extensions/line/node_modules/.bin/lemon-drive +0 -21
- package/extensions/line/node_modules/.bin/lemon-gmail +0 -21
- package/extensions/line/node_modules/.bin/lemon-jira +0 -21
- package/extensions/line/node_modules/.bin/lemon-notion +0 -21
- package/extensions/line/node_modules/.bin/lemon-sheets +0 -21
- package/extensions/line/node_modules/.bin/lemon-slack +0 -21
- package/extensions/line/node_modules/.bin/lemon-slides +0 -21
- package/extensions/line/node_modules/.bin/lemon-twitter +0 -21
- package/extensions/line/node_modules/.bin/lemon-youtube +0 -21
- package/extensions/matrix/node_modules/.bin/lemon-calendar +0 -21
- package/extensions/matrix/node_modules/.bin/lemon-cron +0 -21
- package/extensions/matrix/node_modules/.bin/lemon-docs +0 -21
- package/extensions/matrix/node_modules/.bin/lemon-drive +0 -21
- package/extensions/matrix/node_modules/.bin/lemon-gmail +0 -21
- package/extensions/matrix/node_modules/.bin/lemon-jira +0 -21
- package/extensions/matrix/node_modules/.bin/lemon-notion +0 -21
- package/extensions/matrix/node_modules/.bin/lemon-sheets +0 -21
- package/extensions/matrix/node_modules/.bin/lemon-slack +0 -21
- package/extensions/matrix/node_modules/.bin/lemon-slides +0 -21
- package/extensions/matrix/node_modules/.bin/lemon-twitter +0 -21
- package/extensions/matrix/node_modules/.bin/lemon-youtube +0 -21
- package/extensions/memory-core/node_modules/.bin/lemon-calendar +0 -21
- package/extensions/memory-core/node_modules/.bin/lemon-cron +0 -21
- package/extensions/memory-core/node_modules/.bin/lemon-docs +0 -21
- package/extensions/memory-core/node_modules/.bin/lemon-drive +0 -21
- package/extensions/memory-core/node_modules/.bin/lemon-gmail +0 -21
- package/extensions/memory-core/node_modules/.bin/lemon-jira +0 -21
- package/extensions/memory-core/node_modules/.bin/lemon-notion +0 -21
- package/extensions/memory-core/node_modules/.bin/lemon-sheets +0 -21
- package/extensions/memory-core/node_modules/.bin/lemon-slack +0 -21
- package/extensions/memory-core/node_modules/.bin/lemon-slides +0 -21
- package/extensions/memory-core/node_modules/.bin/lemon-twitter +0 -21
- package/extensions/memory-core/node_modules/.bin/lemon-youtube +0 -21
- package/extensions/msteams/node_modules/.bin/lemon-calendar +0 -21
- package/extensions/msteams/node_modules/.bin/lemon-cron +0 -21
- package/extensions/msteams/node_modules/.bin/lemon-docs +0 -21
- package/extensions/msteams/node_modules/.bin/lemon-drive +0 -21
- package/extensions/msteams/node_modules/.bin/lemon-gmail +0 -21
- package/extensions/msteams/node_modules/.bin/lemon-jira +0 -21
- package/extensions/msteams/node_modules/.bin/lemon-notion +0 -21
- package/extensions/msteams/node_modules/.bin/lemon-sheets +0 -21
- package/extensions/msteams/node_modules/.bin/lemon-slack +0 -21
- package/extensions/msteams/node_modules/.bin/lemon-slides +0 -21
- package/extensions/msteams/node_modules/.bin/lemon-twitter +0 -21
- package/extensions/msteams/node_modules/.bin/lemon-youtube +0 -21
- package/extensions/nostr/node_modules/.bin/lemon-calendar +0 -21
- package/extensions/nostr/node_modules/.bin/lemon-cron +0 -21
- package/extensions/nostr/node_modules/.bin/lemon-docs +0 -21
- package/extensions/nostr/node_modules/.bin/lemon-drive +0 -21
- package/extensions/nostr/node_modules/.bin/lemon-gmail +0 -21
- package/extensions/nostr/node_modules/.bin/lemon-jira +0 -21
- package/extensions/nostr/node_modules/.bin/lemon-notion +0 -21
- package/extensions/nostr/node_modules/.bin/lemon-sheets +0 -21
- package/extensions/nostr/node_modules/.bin/lemon-slack +0 -21
- package/extensions/nostr/node_modules/.bin/lemon-slides +0 -21
- package/extensions/nostr/node_modules/.bin/lemon-twitter +0 -21
- package/extensions/nostr/node_modules/.bin/lemon-youtube +0 -21
- package/extensions/twitch/node_modules/.bin/lemon-calendar +0 -21
- package/extensions/twitch/node_modules/.bin/lemon-cron +0 -21
- package/extensions/twitch/node_modules/.bin/lemon-docs +0 -21
- package/extensions/twitch/node_modules/.bin/lemon-drive +0 -21
- package/extensions/twitch/node_modules/.bin/lemon-gmail +0 -21
- package/extensions/twitch/node_modules/.bin/lemon-jira +0 -21
- package/extensions/twitch/node_modules/.bin/lemon-notion +0 -21
- package/extensions/twitch/node_modules/.bin/lemon-sheets +0 -21
- package/extensions/twitch/node_modules/.bin/lemon-slack +0 -21
- package/extensions/twitch/node_modules/.bin/lemon-slides +0 -21
- package/extensions/twitch/node_modules/.bin/lemon-twitter +0 -21
- package/extensions/twitch/node_modules/.bin/lemon-youtube +0 -21
- package/extensions/zalo/node_modules/.bin/lemon-calendar +0 -21
- package/extensions/zalo/node_modules/.bin/lemon-cron +0 -21
- package/extensions/zalo/node_modules/.bin/lemon-docs +0 -21
- package/extensions/zalo/node_modules/.bin/lemon-drive +0 -21
- package/extensions/zalo/node_modules/.bin/lemon-gmail +0 -21
- package/extensions/zalo/node_modules/.bin/lemon-jira +0 -21
- package/extensions/zalo/node_modules/.bin/lemon-notion +0 -21
- package/extensions/zalo/node_modules/.bin/lemon-sheets +0 -21
- package/extensions/zalo/node_modules/.bin/lemon-slack +0 -21
- package/extensions/zalo/node_modules/.bin/lemon-slides +0 -21
- package/extensions/zalo/node_modules/.bin/lemon-twitter +0 -21
- package/extensions/zalo/node_modules/.bin/lemon-youtube +0 -21
- package/extensions/zalouser/node_modules/.bin/lemon-calendar +0 -21
- package/extensions/zalouser/node_modules/.bin/lemon-cron +0 -21
- package/extensions/zalouser/node_modules/.bin/lemon-docs +0 -21
- package/extensions/zalouser/node_modules/.bin/lemon-drive +0 -21
- package/extensions/zalouser/node_modules/.bin/lemon-gmail +0 -21
- package/extensions/zalouser/node_modules/.bin/lemon-jira +0 -21
- package/extensions/zalouser/node_modules/.bin/lemon-notion +0 -21
- package/extensions/zalouser/node_modules/.bin/lemon-sheets +0 -21
- package/extensions/zalouser/node_modules/.bin/lemon-slack +0 -21
- package/extensions/zalouser/node_modules/.bin/lemon-slides +0 -21
- package/extensions/zalouser/node_modules/.bin/lemon-twitter +0 -21
- package/extensions/zalouser/node_modules/.bin/lemon-youtube +0 -21
- /package/skills/pdf/{FORMS.md → forms.md} +0 -0
- /package/skills/pdf/{REFERENCE.md → reference.md} +0 -0
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();const
|
|
2
|
-
\f\r]`,
|
|
3
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Vi=/'/g,Yi=/"/g,io=/^(?:script|style|textarea|title)$/i,il=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),c=il(1),ke=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),Qi=new WeakMap,Ne=De.createTreeWalker(De,129);function ao(e,t){if(!Ns(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return qi!==void 0?qi.createHTML(t):t}const al=(e,t)=>{const n=e.length-1,s=[];let i,a=t===2?"<svg>":t===3?"<math>":"",o=rt;for(let r=0;r<n;r++){const l=e[r];let p,d,u=-1,g=0;for(;g<l.length&&(o.lastIndex=g,d=o.exec(l),d!==null);)g=o.lastIndex,o===rt?d[1]==="!--"?o=Gi:d[1]!==void 0?o=Wi:d[2]!==void 0?(io.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=Me):d[3]!==void 0&&(o=Me):o===Me?d[0]===">"?(o=i??rt,u=-1):d[1]===void 0?u=-2:(u=o.lastIndex-d[2].length,p=d[1],o=d[3]===void 0?Me:d[3]==='"'?Yi:Vi):o===Yi||o===Vi?o=Me:o===Gi||o===Wi?o=rt:(o=Me,i=void 0);const v=o===Me&&e[r+1].startsWith("/>")?" ":"";a+=o===rt?l+nl:u>=0?(s.push(p),l.slice(0,u)+no+l.slice(u)+xe+v):l+xe+(u===-2?r:v)}return[ao(e,a+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class At{constructor({strings:t,_$litType$:n},s){let i;this.parts=[];let a=0,o=0;const r=t.length-1,l=this.parts,[p,d]=al(t,n);if(this.el=At.createElement(p,s),Ne.currentNode=this.el.content,n===2||n===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(i=Ne.nextNode())!==null&&l.length<r;){if(i.nodeType===1){if(i.hasAttributes())for(const u of i.getAttributeNames())if(u.endsWith(no)){const g=d[o++],v=i.getAttribute(u).split(xe),m=/([.?@])?(.*)/.exec(g);l.push({type:1,index:a,name:m[2],strings:v,ctor:m[1]==="."?rl:m[1]==="?"?ll:m[1]==="@"?cl:ln}),i.removeAttribute(u)}else u.startsWith(xe)&&(l.push({type:6,index:a}),i.removeAttribute(u));if(io.test(i.tagName)){const u=i.textContent.split(xe),g=u.length-1;if(g>0){i.textContent=Zt?Zt.emptyScript:"";for(let v=0;v<g;v++)i.append(u[v],$t()),Ne.nextNode(),l.push({type:2,index:++a});i.append(u[g],$t())}}}else if(i.nodeType===8)if(i.data===so)l.push({type:2,index:a});else{let u=-1;for(;(u=i.data.indexOf(xe,u+1))!==-1;)l.push({type:7,index:a}),u+=xe.length-1}a++}}static createElement(t,n){const s=De.createElement("template");return s.innerHTML=t,s}}function et(e,t,n=e,s){if(t===ke)return t;let i=s!==void 0?n._$Co?.[s]:n._$Cl;const a=xt(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,s)),s!==void 0?(n._$Co??=[])[s]=i:n._$Cl=i),i!==void 0&&(t=et(e,i._$AS(e,t.values),i,s)),t}class ol{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:s}=this._$AD,i=(t?.creationScope??De).importNode(n,!0);Ne.currentNode=i;let a=Ne.nextNode(),o=0,r=0,l=s[0];for(;l!==void 0;){if(o===l.index){let p;l.type===2?p=new rn(a,a.nextSibling,this,t):l.type===1?p=new l.ctor(a,l.name,l.strings,this,t):l.type===6&&(p=new dl(a,this,t)),this._$AV.push(p),l=s[++r]}o!==l?.index&&(a=Ne.nextNode(),o++)}return Ne.currentNode=De,i}p(t){let n=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,n),n+=s.strings.length-2):s._$AI(t[n])),n++}}let rn=class oo{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,n,s,i){this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&t?.nodeType===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=et(this,t,n),xt(t)?t===f||t==null||t===""?(this._$AH!==f&&this._$AR(),this._$AH=f):t!==this._$AH&&t!==ke&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):sl(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!==f&&xt(this._$AH)?this._$AA.nextSibling.data=t:this.T(De.createTextNode(t)),this._$AH=t}$(t){const{values:n,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=At.createElement(ao(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(n);else{const a=new ol(i,this),o=a.u(this.options);a.p(n),this.T(o),this._$AH=a}}_$AC(t){let n=Qi.get(t.strings);return n===void 0&&Qi.set(t.strings,n=new At(t)),n}k(t){Ns(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let s,i=0;for(const a of t)i===n.length?n.push(s=new oo(this.O($t()),this.O($t()),this,this.options)):s=n[i],s._$AI(a),i++;i<n.length&&(this._$AR(s&&s._$AB.nextSibling,i),n.length=i)}_$AR(t=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);t!==this._$AB;){const s=ji(t).nextSibling;ji(t).remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},ln=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,s,i,a){this.type=1,this._$AH=f,this._$AN=void 0,this.element=t,this.name=n,this._$AM=i,this.options=a,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=f}_$AI(t,n=this,s,i){const a=this.strings;let o=!1;if(a===void 0)t=et(this,t,n,0),o=!xt(t)||t!==this._$AH&&t!==ke,o&&(this._$AH=t);else{const r=t;let l,p;for(t=a[0],l=0;l<a.length-1;l++)p=et(this,r[s+l],n,l),p===ke&&(p=this._$AH[l]),o||=!xt(p)||p!==this._$AH[l],p===f?t=f:t!==f&&(t+=(p??"")+a[l+1]),this._$AH[l]=p}o&&!i&&this.j(t)}j(t){t===f?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},rl=class extends ln{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===f?void 0:t}},ll=class extends ln{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==f)}},cl=class extends ln{constructor(t,n,s,i,a){super(t,n,s,i,a),this.type=5}_$AI(t,n=this){if((t=et(this,t,n,0)??f)===ke)return;const s=this._$AH,i=t===f&&s!==f||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,a=t!==f&&(s===f||i);i&&this.element.removeEventListener(this.name,this,s),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},dl=class{constructor(t,n,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){et(this,t)}};const ul={I:rn},pl=Ps.litHtmlPolyfillSupport;pl?.(At,rn),(Ps.litHtmlVersions??=[]).push("3.3.2");const hl=(e,t,n)=>{const s=n?.renderBefore??t;let i=s._$litPart$;if(i===void 0){const a=n?.renderBefore??null;s._$litPart$=i=new rn(t.insertBefore($t(),a),a,void 0,n??{})}return i._$AI(e),i};const Os=globalThis;let Xe=class extends Ze{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=hl(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ke}};Xe._$litElement$=!0,Xe.finalized=!0,Os.litElementHydrateSupport?.({LitElement:Xe});const fl=Os.litElementPolyfillSupport;fl?.({LitElement:Xe});(Os.litElementVersions??=[]).push("4.2.2");const ro=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const gl={attribute:!0,type:String,converter:Qt,reflect:!1,hasChanged:Is},vl=(e=gl,t,n)=>{const{kind:s,metadata:i}=n;let a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),s==="setter"&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),s==="accessor"){const{name:o}=n;return{set(r){const l=t.get.call(this);t.set.call(this,r),this.requestUpdate(o,l,e,!0,r)},init(r){return r!==void 0&&this.C(o,void 0,e,r),r}}}if(s==="setter"){const{name:o}=n;return function(r){const l=this[o];t.call(this,r),this.requestUpdate(o,l,e,!0,r)}}throw Error("Unsupported decorator location: "+s)};function cn(e){return(t,n)=>typeof n=="object"?vl(e,t,n):((s,i,a)=>{const o=i.hasOwnProperty(a);return i.constructor.createProperty(a,s),o?Object.getOwnPropertyDescriptor(i,a):void 0})(e,t,n)}function w(e){return cn({...e,state:!0,attribute:!1})}const ml=50,yl=200,bl="Assistant";function Zi(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function os(e){const t=Zi(e?.name,ml)??bl,n=Zi(e?.avatar??void 0,yl)??null;return{agentId:typeof e?.agentId=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function wl(){return os(typeof window>"u"?{}:{name:window.__LEMONADE_ASSISTANT_NAME__,avatar:window.__LEMONADE_ASSISTANT_AVATAR__})}const lo="lemonade.control.settings.v1";function $l(){const t={gatewayUrl:`${location.protocol==="https:"?"wss":"ws"}://${location.host}`,token:"",sessionKey:"main",lastActiveSessionKey:"main",theme:"system",chatFocusMode:!1,chatShowThinking:!0,splitRatio:.6,navCollapsed:!1,navGroupsCollapsed:{}};try{const n=localStorage.getItem(lo);if(!n)return t;const s=JSON.parse(n);return{gatewayUrl:typeof s.gatewayUrl=="string"&&s.gatewayUrl.trim()?s.gatewayUrl.trim():t.gatewayUrl,token:typeof s.token=="string"?s.token:t.token,sessionKey:typeof s.sessionKey=="string"&&s.sessionKey.trim()?s.sessionKey.trim():t.sessionKey,lastActiveSessionKey:typeof s.lastActiveSessionKey=="string"&&s.lastActiveSessionKey.trim()?s.lastActiveSessionKey.trim():typeof s.sessionKey=="string"&&s.sessionKey.trim()||t.lastActiveSessionKey,theme:s.theme==="light"||s.theme==="dark"||s.theme==="system"?s.theme:t.theme,chatFocusMode:typeof s.chatFocusMode=="boolean"?s.chatFocusMode:t.chatFocusMode,chatShowThinking:typeof s.chatShowThinking=="boolean"?s.chatShowThinking:t.chatShowThinking,splitRatio:typeof s.splitRatio=="number"&&s.splitRatio>=.4&&s.splitRatio<=.7?s.splitRatio:t.splitRatio,navCollapsed:typeof s.navCollapsed=="boolean"?s.navCollapsed:t.navCollapsed,navGroupsCollapsed:typeof s.navGroupsCollapsed=="object"&&s.navGroupsCollapsed!==null?s.navGroupsCollapsed:t.navGroupsCollapsed}}catch{return t}}function xl(e){localStorage.setItem(lo,JSON.stringify(e))}function co(e){const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const s=n[1]?.trim(),i=n.slice(2).join(":");return!s||!i?null:{agentId:s,rest:i}}const Al=[{label:"Chat",tabs:["chat"]},{label:"Control",tabs:["overview","channels","instances","sessions","cron"]},{label:"Agent",tabs:["skills","nodes"]},{label:"Settings",tabs:["config","debug","logs"]}],uo={overview:"/overview",channels:"/channels",instances:"/instances",sessions:"/sessions",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",config:"/config",debug:"/debug",logs:"/logs"},po=new Map(Object.entries(uo).map(([e,t])=>[t,e]));function dn(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function kt(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 Ds(e,t=""){const n=dn(t),s=uo[e];return n?`${n}${s}`:s}function ho(e,t=""){const n=dn(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=kt(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":po.get(i)??null}function kl(e){let t=kt(e);if(t.endsWith("/index.html")&&(t=kt(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let s=0;s<n.length;s++){const i=`/${n.slice(s).join("/")}`.toLowerCase();if(po.has(i)){const a=n.slice(0,s);return a.length?`/${a.join("/")}`:""}}return`/${n.join("/")}`}function Sl(e){switch(e){case"chat":return"messageSquare";case"overview":return"barChart";case"channels":return"link";case"instances":return"radio";case"sessions":return"fileText";case"cron":return"loader";case"skills":return"zap";case"nodes":return"monitor";case"config":return"settings";case"debug":return"bug";case"logs":return"scrollText";default:return"folder"}}function rs(e){switch(e){case"overview":return"Overview";case"channels":return"Channels";case"instances":return"Instances";case"sessions":return"Sessions";case"cron":return"Cron Jobs";case"skills":return"Skills";case"nodes":return"Nodes";case"chat":return"Chat";case"config":return"Config";case"debug":return"Debug";case"logs":return"Logs";default:return"Control"}}function _l(e){switch(e){case"overview":return"Gateway status, entry points, and a fast health read.";case"channels":return"Manage channels and settings.";case"instances":return"Presence beacons from connected clients and nodes.";case"sessions":return"Inspect active sessions and adjust per-session defaults.";case"cron":return"Schedule wakeups and recurring agent runs.";case"skills":return"Manage skill availability and API key injection.";case"nodes":return"Paired devices, capabilities, and command exposure.";case"chat":return"Direct gateway chat session for quick interventions.";case"config":return"Edit ~/.lemonade/lemonade.json safely.";case"debug":return"Gateway snapshots, events, and manual RPC calls.";case"logs":return"Live tail of the gateway file logs.";default:return""}}const W={messageSquare:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,radio:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:c`<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:c`<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:c`<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:c`<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:c`<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>`,menu:c`<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:c`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:c`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:c`<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:c`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:c`<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:c`<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:c`<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>`,wrench:c`<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:c`<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:c`<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:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,image:c`<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:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,puzzle:c`<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>`},Cl=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Ft=/<\s*\/?\s*final\b[^<>]*>/gi,Ji=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^<>]*>/gi;function Xi(e){const t=[],n=/(^|\n)(```|~~~)[^\n]*\n[\s\S]*?(?:\n\2(?:\n|$)|$)/g;for(const i of e.matchAll(n)){const a=(i.index??0)+i[1].length;t.push({start:a,end:a+i[0].length-i[1].length})}const s=/`+[^`]+`+/g;for(const i of e.matchAll(s)){const a=i.index??0,o=a+i[0].length;t.some(l=>a>=l.start&&o<=l.end)||t.push({start:a,end:o})}return t.sort((i,a)=>i.start-a.start),t}function ea(e,t){return t.some(n=>e>=n.start&&e<n.end)}function Tl(e,t){return e.trimStart()}function El(e,t){if(!e||!Cl.test(e))return e;let n=e;if(Ft.test(n)){Ft.lastIndex=0;const r=[],l=Xi(n);for(const p of n.matchAll(Ft)){const d=p.index??0;r.push({start:d,length:p[0].length,inCode:ea(d,l)})}for(let p=r.length-1;p>=0;p--){const d=r[p];d.inCode||(n=n.slice(0,d.start)+n.slice(d.start+d.length))}}else Ft.lastIndex=0;const s=Xi(n);Ji.lastIndex=0;let i="",a=0,o=!1;for(const r of n.matchAll(Ji)){const l=r.index??0,p=r[1]==="/";ea(l,s)||(o?p&&(o=!1):(i+=n.slice(a,l),p||(o=!0)),a=l+r[0].length)}return i+=n.slice(a),Tl(i)}function St(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString()}function O(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0)return"just now";const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const s=Math.round(n/60);if(s<60)return`${s}m ago`;const i=Math.round(s/60);return i<48?`${i}h ago`:`${Math.round(i/24)}d ago`}function fo(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const s=Math.round(n/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function ls(e){return!e||e.length===0?"none":e.filter(t=>!!(t&&t.trim())).join(", ")}function cs(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function go(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 Jt(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Kn(e){return El(e)}const Ml=/^\[([^\]]+)\]\s*/,Ll=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Hn=new WeakMap,zn=new WeakMap;function Rl(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:Ll.some(t=>e.startsWith(`${t} `))}function jn(e){const t=e.match(Ml);if(!t)return e;const n=t[1]??"";return Rl(n)?e.slice(t[0].length):e}function ds(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?Kn(s):jn(s);if(Array.isArray(s)){const i=s.map(a=>{const o=a;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(a=>typeof a=="string");if(i.length>0){const a=i.join(`
|
|
4
|
-
`);return n==="assistant"?
|
|
1
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();const Gt=globalThis,Ls=Gt.ShadowRoot&&(Gt.ShadyCSS===void 0||Gt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Is=Symbol(),Ui=new WeakMap;let to=class{constructor(t,n,s){if(this._$cssResult$=!0,s!==Is)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(Ls&&t===void 0){const s=n!==void 0&&n.length===1;s&&(t=Ui.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&Ui.set(n,t))}return t}toString(){return this.cssText}};const qr=e=>new to(typeof e=="string"?e:e+"",void 0,Is),Gr=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((s,i,a)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[a+1],e[0]);return new to(n,e,Is)},Wr=(e,t)=>{if(Ls)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const s=document.createElement("style"),i=Gt.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=n.cssText,e.appendChild(s)}},Ki=Ls?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const s of t.cssRules)n+=s.cssText;return qr(n)})(e):e;const{is:Vr,defineProperty:Yr,getOwnPropertyDescriptor:Qr,getOwnPropertyNames:Zr,getOwnPropertySymbols:Jr,getPrototypeOf:Xr}=Object,an=globalThis,Hi=an.trustedTypes,el=Hi?Hi.emptyScript:"",tl=an.reactiveElementPolyfillSupport,mt=(e,t)=>e,Yt={toAttribute(e,t){switch(t){case Boolean:e=e?el: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}},Rs=(e,t)=>!Vr(e,t),zi={attribute:!0,type:String,converter:Yt,reflect:!1,useDefault:!1,hasChanged:Rs};Symbol.metadata??=Symbol("metadata"),an.litPropertyMetadata??=new WeakMap;let Qe=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,n=zi){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,n);i!==void 0&&Yr(this.prototype,t,i)}}static getPropertyDescriptor(t,n,s){const{get:i,set:a}=Qr(this.prototype,t)??{get(){return this[n]},set(o){this[n]=o}};return{get:i,set(o){const r=i?.call(this);a?.call(this,o),this.requestUpdate(t,r,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??zi}static _$Ei(){if(this.hasOwnProperty(mt("elementProperties")))return;const t=Xr(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(mt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(mt("properties"))){const n=this.properties,s=[...Zr(n),...Jr(n)];for(const i of s)this.createProperty(i,n[i])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[s,i]of n)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[n,s]of this.elementProperties){const i=this._$Eu(n,s);i!==void 0&&this._$Eh.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)n.unshift(Ki(i))}else t!==void 0&&n.push(Ki(t));return n}static _$Eu(t,n){const s=n.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const s of n.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Wr(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,n,s){this._$AK(t,s)}_$ET(t,n){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const a=(s.converter?.toAttribute!==void 0?s.converter:Yt).toAttribute(n,s.type);this._$Em=t,a==null?this.removeAttribute(i):this.setAttribute(i,a),this._$Em=null}}_$AK(t,n){const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const a=s.getPropertyOptions(i),o=typeof a.converter=="function"?{fromAttribute:a.converter}:a.converter?.fromAttribute!==void 0?a.converter:Yt;this._$Em=i;const r=o.fromAttribute(n,a.type);this[i]=r??this._$Ej?.get(i)??r,this._$Em=null}}requestUpdate(t,n,s,i=!1,a){if(t!==void 0){const o=this.constructor;if(i===!1&&(a=this[t]),s??=o.getPropertyOptions(t),!((s.hasChanged??Rs)(a,n)||s.useDefault&&s.reflect&&a===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,s))))return;this.C(t,n,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:s,reflect:i,wrapped:a},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??n??this[t]),a!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(n=void 0),this._$AL.set(t,n)),i===!0&&this._$Em!==t&&(this._$Eq??=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(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,a]of this._$Ep)this[i]=a;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,a]of s){const{wrapped:o}=a,r=this[i];o!==!0||this._$AL.has(i)||r===void 0||this.C(i,void 0,a,r)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),this._$EO?.forEach(s=>s.hostUpdate?.()),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){this._$EO?.forEach(n=>n.hostUpdated?.()),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.forEach(n=>this._$ET(n,this[n])),this._$EM()}updated(t){}firstUpdated(t){}};Qe.elementStyles=[],Qe.shadowRootOptions={mode:"open"},Qe[mt("elementProperties")]=new Map,Qe[mt("finalized")]=new Map,tl?.({ReactiveElement:Qe}),(an.reactiveElementVersions??=[]).push("2.1.2");const Ps=globalThis,ji=e=>e,Qt=Ps.trustedTypes,qi=Qt?Qt.createPolicy("lit-html",{createHTML:e=>e}):void 0,no="$lit$",xe=`lit$${Math.random().toFixed(9).slice(2)}$`,so="?"+xe,nl=`<${so}>`,Oe=document,$t=()=>Oe.createComment(""),xt=e=>e===null||typeof e!="object"&&typeof e!="function",Ns=Array.isArray,sl=e=>Ns(e)||typeof e?.[Symbol.iterator]=="function",Fn=`[
|
|
2
|
+
\f\r]`,ot=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Gi=/-->/g,Wi=/>/g,Me=RegExp(`>|${Fn}(?:([^\\s"'>=/]+)(${Fn}*=${Fn}*(?:[^
|
|
3
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Vi=/'/g,Yi=/"/g,io=/^(?:script|style|textarea|title)$/i,il=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),c=il(1),ke=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),Qi=new WeakMap,Pe=Oe.createTreeWalker(Oe,129);function ao(e,t){if(!Ns(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return qi!==void 0?qi.createHTML(t):t}const al=(e,t)=>{const n=e.length-1,s=[];let i,a=t===2?"<svg>":t===3?"<math>":"",o=ot;for(let r=0;r<n;r++){const l=e[r];let p,d,u=-1,g=0;for(;g<l.length&&(o.lastIndex=g,d=o.exec(l),d!==null);)g=o.lastIndex,o===ot?d[1]==="!--"?o=Gi:d[1]!==void 0?o=Wi:d[2]!==void 0?(io.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=Me):d[3]!==void 0&&(o=Me):o===Me?d[0]===">"?(o=i??ot,u=-1):d[1]===void 0?u=-2:(u=o.lastIndex-d[2].length,p=d[1],o=d[3]===void 0?Me:d[3]==='"'?Yi:Vi):o===Yi||o===Vi?o=Me:o===Gi||o===Wi?o=ot:(o=Me,i=void 0);const v=o===Me&&e[r+1].startsWith("/>")?" ":"";a+=o===ot?l+nl:u>=0?(s.push(p),l.slice(0,u)+no+l.slice(u)+xe+v):l+xe+(u===-2?r:v)}return[ao(e,a+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};let as=class oo{constructor({strings:t,_$litType$:n},s){let i;this.parts=[];let a=0,o=0;const r=t.length-1,l=this.parts,[p,d]=al(t,n);if(this.el=oo.createElement(p,s),Pe.currentNode=this.el.content,n===2||n===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(i=Pe.nextNode())!==null&&l.length<r;){if(i.nodeType===1){if(i.hasAttributes())for(const u of i.getAttributeNames())if(u.endsWith(no)){const g=d[o++],v=i.getAttribute(u).split(xe),y=/([.?@])?(.*)/.exec(g);l.push({type:1,index:a,name:y[2],strings:v,ctor:y[1]==="."?rl:y[1]==="?"?ll:y[1]==="@"?cl:rn}),i.removeAttribute(u)}else u.startsWith(xe)&&(l.push({type:6,index:a}),i.removeAttribute(u));if(io.test(i.tagName)){const u=i.textContent.split(xe),g=u.length-1;if(g>0){i.textContent=Qt?Qt.emptyScript:"";for(let v=0;v<g;v++)i.append(u[v],$t()),Pe.nextNode(),l.push({type:2,index:++a});i.append(u[g],$t())}}}else if(i.nodeType===8)if(i.data===so)l.push({type:2,index:a});else{let u=-1;for(;(u=i.data.indexOf(xe,u+1))!==-1;)l.push({type:7,index:a}),u+=xe.length-1}a++}}static createElement(t,n){const s=Oe.createElement("template");return s.innerHTML=t,s}};function Xe(e,t,n=e,s){if(t===ke)return t;let i=s!==void 0?n._$Co?.[s]:n._$Cl;const a=xt(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,s)),s!==void 0?(n._$Co??=[])[s]=i:n._$Cl=i),i!==void 0&&(t=Xe(e,i._$AS(e,t.values),i,s)),t}class ol{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:s}=this._$AD,i=(t?.creationScope??Oe).importNode(n,!0);Pe.currentNode=i;let a=Pe.nextNode(),o=0,r=0,l=s[0];for(;l!==void 0;){if(o===l.index){let p;l.type===2?p=new on(a,a.nextSibling,this,t):l.type===1?p=new l.ctor(a,l.name,l.strings,this,t):l.type===6&&(p=new dl(a,this,t)),this._$AV.push(p),l=s[++r]}o!==l?.index&&(a=Pe.nextNode(),o++)}return Pe.currentNode=Oe,i}p(t){let n=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,n),n+=s.strings.length-2):s._$AI(t[n])),n++}}let on=class ro{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,n,s,i){this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&t?.nodeType===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=Xe(this,t,n),xt(t)?t===f||t==null||t===""?(this._$AH!==f&&this._$AR(),this._$AH=f):t!==this._$AH&&t!==ke&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):sl(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!==f&&xt(this._$AH)?this._$AA.nextSibling.data=t:this.T(Oe.createTextNode(t)),this._$AH=t}$(t){const{values:n,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=as.createElement(ao(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(n);else{const a=new ol(i,this),o=a.u(this.options);a.p(n),this.T(o),this._$AH=a}}_$AC(t){let n=Qi.get(t.strings);return n===void 0&&Qi.set(t.strings,n=new as(t)),n}k(t){Ns(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let s,i=0;for(const a of t)i===n.length?n.push(s=new ro(this.O($t()),this.O($t()),this,this.options)):s=n[i],s._$AI(a),i++;i<n.length&&(this._$AR(s&&s._$AB.nextSibling,i),n.length=i)}_$AR(t=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);t!==this._$AB;){const s=ji(t).nextSibling;ji(t).remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}};class rn{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,s,i,a){this.type=1,this._$AH=f,this._$AN=void 0,this.element=t,this.name=n,this._$AM=i,this.options=a,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=f}_$AI(t,n=this,s,i){const a=this.strings;let o=!1;if(a===void 0)t=Xe(this,t,n,0),o=!xt(t)||t!==this._$AH&&t!==ke,o&&(this._$AH=t);else{const r=t;let l,p;for(t=a[0],l=0;l<a.length-1;l++)p=Xe(this,r[s+l],n,l),p===ke&&(p=this._$AH[l]),o||=!xt(p)||p!==this._$AH[l],p===f?t=f:t!==f&&(t+=(p??"")+a[l+1]),this._$AH[l]=p}o&&!i&&this.j(t)}j(t){t===f?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let rl=class extends rn{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===f?void 0:t}},ll=class extends rn{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==f)}},cl=class extends rn{constructor(t,n,s,i,a){super(t,n,s,i,a),this.type=5}_$AI(t,n=this){if((t=Xe(this,t,n,0)??f)===ke)return;const s=this._$AH,i=t===f&&s!==f||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,a=t!==f&&(s===f||i);i&&this.element.removeEventListener(this.name,this,s),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},dl=class{constructor(t,n,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Xe(this,t)}};const ul={I:on},pl=Ps.litHtmlPolyfillSupport;pl?.(as,on),(Ps.litHtmlVersions??=[]).push("3.3.2");const hl=(e,t,n)=>{const s=n?.renderBefore??t;let i=s._$litPart$;if(i===void 0){const a=n?.renderBefore??null;s._$litPart$=i=new on(t.insertBefore($t(),a),a,void 0,n??{})}return i._$AI(e),i};const Os=globalThis;let Je=class extends Qe{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=hl(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ke}};Je._$litElement$=!0,Je.finalized=!0,Os.litElementHydrateSupport?.({LitElement:Je});const fl=Os.litElementPolyfillSupport;fl?.({LitElement:Je});(Os.litElementVersions??=[]).push("4.2.2");const lo=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const gl={attribute:!0,type:String,converter:Yt,reflect:!1,hasChanged:Rs},vl=(e=gl,t,n)=>{const{kind:s,metadata:i}=n;let a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),s==="setter"&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),s==="accessor"){const{name:o}=n;return{set(r){const l=t.get.call(this);t.set.call(this,r),this.requestUpdate(o,l,e,!0,r)},init(r){return r!==void 0&&this.C(o,void 0,e,r),r}}}if(s==="setter"){const{name:o}=n;return function(r){const l=this[o];t.call(this,r),this.requestUpdate(o,l,e,!0,r)}}throw Error("Unsupported decorator location: "+s)};function ln(e){return(t,n)=>typeof n=="object"?vl(e,t,n):((s,i,a)=>{const o=i.hasOwnProperty(a);return i.constructor.createProperty(a,s),o?Object.getOwnPropertyDescriptor(i,a):void 0})(e,t,n)}function w(e){return ln({...e,state:!0,attribute:!1})}const ml=50,yl=200,bl="Assistant";function Zi(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function os(e){const t=Zi(e?.name,ml)??bl,n=Zi(e?.avatar??void 0,yl)??null;return{agentId:typeof e?.agentId=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function wl(){return os(typeof window>"u"?{}:{name:window.__LEMONADE_ASSISTANT_NAME__,avatar:window.__LEMONADE_ASSISTANT_AVATAR__})}const co="lemonade.control.settings.v1";function $l(){const t={gatewayUrl:`${location.protocol==="https:"?"wss":"ws"}://${location.host}`,token:"",sessionKey:"main",lastActiveSessionKey:"main",theme:"system",chatFocusMode:!1,chatShowThinking:!0,splitRatio:.6,navCollapsed:!1,navGroupsCollapsed:{}};try{const n=localStorage.getItem(co);if(!n)return t;const s=JSON.parse(n);return{gatewayUrl:typeof s.gatewayUrl=="string"&&s.gatewayUrl.trim()?s.gatewayUrl.trim():t.gatewayUrl,token:typeof s.token=="string"?s.token:t.token,sessionKey:typeof s.sessionKey=="string"&&s.sessionKey.trim()?s.sessionKey.trim():t.sessionKey,lastActiveSessionKey:typeof s.lastActiveSessionKey=="string"&&s.lastActiveSessionKey.trim()?s.lastActiveSessionKey.trim():typeof s.sessionKey=="string"&&s.sessionKey.trim()||t.lastActiveSessionKey,theme:s.theme==="light"||s.theme==="dark"||s.theme==="system"?s.theme:t.theme,chatFocusMode:typeof s.chatFocusMode=="boolean"?s.chatFocusMode:t.chatFocusMode,chatShowThinking:typeof s.chatShowThinking=="boolean"?s.chatShowThinking:t.chatShowThinking,splitRatio:typeof s.splitRatio=="number"&&s.splitRatio>=.4&&s.splitRatio<=.7?s.splitRatio:t.splitRatio,navCollapsed:typeof s.navCollapsed=="boolean"?s.navCollapsed:t.navCollapsed,navGroupsCollapsed:typeof s.navGroupsCollapsed=="object"&&s.navGroupsCollapsed!==null?s.navGroupsCollapsed:t.navGroupsCollapsed}}catch{return t}}function xl(e){localStorage.setItem(co,JSON.stringify(e))}function uo(e){const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const s=n[1]?.trim(),i=n.slice(2).join(":");return!s||!i?null:{agentId:s,rest:i}}const Al=[{label:"Chat",tabs:["chat"]},{label:"Control",tabs:["overview","channels","instances","sessions","cron"]},{label:"Agent",tabs:["skills","nodes"]},{label:"Settings",tabs:["config","debug","logs"]}],po={overview:"/overview",channels:"/channels",instances:"/instances",sessions:"/sessions",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",config:"/config",debug:"/debug",logs:"/logs"},ho=new Map(Object.entries(po).map(([e,t])=>[t,e]));function cn(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function At(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 Ds(e,t=""){const n=cn(t),s=po[e];return n?`${n}${s}`:s}function fo(e,t=""){const n=cn(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=At(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":ho.get(i)??null}function kl(e){let t=At(e);if(t.endsWith("/index.html")&&(t=At(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let s=0;s<n.length;s++){const i=`/${n.slice(s).join("/")}`.toLowerCase();if(ho.has(i)){const a=n.slice(0,s);return a.length?`/${a.join("/")}`:""}}return`/${n.join("/")}`}function Sl(e){switch(e){case"chat":return"messageSquare";case"overview":return"barChart";case"channels":return"link";case"instances":return"radio";case"sessions":return"fileText";case"cron":return"loader";case"skills":return"zap";case"nodes":return"monitor";case"config":return"settings";case"debug":return"bug";case"logs":return"scrollText";default:return"folder"}}function rs(e){switch(e){case"overview":return"Overview";case"channels":return"Channels";case"instances":return"Instances";case"sessions":return"Sessions";case"cron":return"Cron Jobs";case"skills":return"Skills";case"nodes":return"Nodes";case"chat":return"Chat";case"config":return"Config";case"debug":return"Debug";case"logs":return"Logs";default:return"Control"}}function _l(e){switch(e){case"overview":return"Gateway status, entry points, and a fast health read.";case"channels":return"Manage channels and settings.";case"instances":return"Presence beacons from connected clients and nodes.";case"sessions":return"Inspect active sessions and adjust per-session defaults.";case"cron":return"Schedule wakeups and recurring agent runs.";case"skills":return"Manage skill availability and API key injection.";case"nodes":return"Paired devices, capabilities, and command exposure.";case"chat":return"Direct gateway chat session for quick interventions.";case"config":return"Edit ~/.lemonade/lemonade.json safely.";case"debug":return"Gateway snapshots, events, and manual RPC calls.";case"logs":return"Live tail of the gateway file logs.";default:return""}}const W={messageSquare:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,radio:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:c`<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:c`<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:c`<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:c`<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:c`<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>`,menu:c`<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:c`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:c`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:c`<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:c`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:c`<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:c`<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:c`<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>`,wrench:c`<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:c`<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:c`<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:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,image:c`<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:c`<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:c`<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:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,puzzle:c`<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>`},Cl=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Bt=/<\s*\/?\s*final\b[^<>]*>/gi,Ji=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^<>]*>/gi;function Xi(e){const t=[],n=/(^|\n)(```|~~~)[^\n]*\n[\s\S]*?(?:\n\2(?:\n|$)|$)/g;for(const i of e.matchAll(n)){const a=(i.index??0)+i[1].length;t.push({start:a,end:a+i[0].length-i[1].length})}const s=/`+[^`]+`+/g;for(const i of e.matchAll(s)){const a=i.index??0,o=a+i[0].length;t.some(l=>a>=l.start&&o<=l.end)||t.push({start:a,end:o})}return t.sort((i,a)=>i.start-a.start),t}function ea(e,t){return t.some(n=>e>=n.start&&e<n.end)}function Tl(e,t){return e.trimStart()}function El(e,t){if(!e||!Cl.test(e))return e;let n=e;if(Bt.test(n)){Bt.lastIndex=0;const r=[],l=Xi(n);for(const p of n.matchAll(Bt)){const d=p.index??0;r.push({start:d,length:p[0].length,inCode:ea(d,l)})}for(let p=r.length-1;p>=0;p--){const d=r[p];d.inCode||(n=n.slice(0,d.start)+n.slice(d.start+d.length))}}else Bt.lastIndex=0;const s=Xi(n);Ji.lastIndex=0;let i="",a=0,o=!1;for(const r of n.matchAll(Ji)){const l=r.index??0,p=r[1]==="/";ea(l,s)||(o?p&&(o=!1):(i+=n.slice(a,l),p||(o=!0)),a=l+r[0].length)}return i+=n.slice(a),Tl(i)}function kt(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString()}function O(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0)return"just now";const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const s=Math.round(n/60);if(s<60)return`${s}m ago`;const i=Math.round(s/60);return i<48?`${i}h ago`:`${Math.round(i/24)}d ago`}function go(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const s=Math.round(n/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function ls(e){return!e||e.length===0?"none":e.filter(t=>!!(t&&t.trim())).join(", ")}function cs(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function vo(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 Zt(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Un(e){return El(e)}const Ml=/^\[([^\]]+)\]\s*/,Ll=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Kn=new WeakMap,Hn=new WeakMap;function Il(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:Ll.some(t=>e.startsWith(`${t} `))}function zn(e){const t=e.match(Ml);if(!t)return e;const n=t[1]??"";return Il(n)?e.slice(t[0].length):e}function ds(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?Un(s):zn(s);if(Array.isArray(s)){const i=s.map(a=>{const o=a;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(a=>typeof a=="string");if(i.length>0){const a=i.join(`
|
|
4
|
+
`);return n==="assistant"?Un(a):zn(a)}}return typeof t.text=="string"?n==="assistant"?Un(t.text):zn(t.text):null}function mo(e){if(!e||typeof e!="object")return ds(e);const t=e;if(Kn.has(t))return Kn.get(t)??null;const n=ds(e);return Kn.set(t,n),n}function ta(e){const n=e.content,s=[];if(Array.isArray(n))for(const r of n){const l=r;if(l.type==="thinking"&&typeof l.thinking=="string"){const p=l.thinking.trim();p&&s.push(p)}}if(s.length>0)return s.join(`
|
|
5
5
|
`);const i=Pl(e);if(!i)return null;const o=[...i.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(r=>(r[1]??"").trim()).filter(Boolean);return o.length>0?o.join(`
|
|
6
|
-
`):null}function
|
|
6
|
+
`):null}function Rl(e){if(!e||typeof e!="object")return ta(e);const t=e;if(Hn.has(t))return Hn.get(t)??null;const n=ta(e);return Hn.set(t,n),n}function Pl(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const s=n.map(i=>{const a=i;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(i=>typeof i=="string");if(s.length>0)return s.join(`
|
|
7
7
|
`)}return typeof t.text=="string"?t.text:null}function Nl(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean).map(s=>`_${s}_`);return n.length?["_Reasoning:_",...n].join(`
|
|
8
|
-
`):""}let na=!1;function sa(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 Ol(){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 Dl(){na||(na=!0,console.warn("[uuid] crypto API missing; falling back to weak randomness"))}function Bs(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),sa(t)}return Dl(),sa(Ol())}async function
|
|
8
|
+
`):""}let na=!1;function sa(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 Ol(){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 Dl(){na||(na=!0,console.warn("[uuid] crypto API missing; falling back to weak randomness"))}function Bs(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),sa(t)}return Dl(),sa(Ol())}async function St(e){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{const t=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:200});e.chatMessages=Array.isArray(t.messages)?t.messages:[],e.chatThinkingLevel=t.thinkingLevel??null}catch(t){e.lastError=String(t)}finally{e.chatLoading=!1}}}function Bl(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function Fl(e,t,n){if(!e.client||!e.connected)return!1;const s=t.trim(),i=n&&n.length>0;if(!s&&!i)return!1;const a=Date.now(),o=[];if(s&&o.push({type:"text",text:s}),i)for(const p of n)o.push({type:"image",source:{type:"base64",media_type:p.mimeType,data:p.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:o,timestamp:a}],e.chatSending=!0,e.lastError=null;const r=Bs();e.chatRunId=r,e.chatStream="",e.chatStreamStartedAt=a;const l=i?n.map(p=>{const d=Bl(p.dataUrl);return d?{type:"image",mimeType:d.mimeType,content:d.content}:null}).filter(p=>p!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:s,deliver:!1,idempotencyKey:r,attachments:l}),!0}catch(p){const d=String(p);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=d,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+d}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function Ul(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 Kl(e,t){if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="delta"){const n=ds(t.message);if(typeof n=="string"){const s=e.chatStream??"";(!s||n.length>=s.length)&&(e.chatStream=n)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.lastError=t.errorMessage??"chat error");return t.state}async function Ke(e,t){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const n=t?.includeGlobal??e.sessionsIncludeGlobal,s=t?.includeUnknown??e.sessionsIncludeUnknown,i=t?.activeMinutes??Zt(e.sessionsFilterActive,0),a=t?.limit??Zt(e.sessionsFilterLimit,0),o={includeGlobal:n,includeUnknown:s};i>0&&(o.activeMinutes=i),a>0&&(o.limit=a);const r=await e.client.request("sessions.list",o);r&&(e.sessionsResult=r)}catch(n){e.sessionsError=String(n)}finally{e.sessionsLoading=!1}}}async function Hl(e,t,n){if(!e.client||!e.connected)return;const s={key:t};"label"in n&&(s.label=n.label),"thinkingLevel"in n&&(s.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(s.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(s.reasoningLevel=n.reasoningLevel);try{await e.client.request("sessions.patch",s),await Ke(e)}catch(i){e.sessionsError=String(i)}}async function zl(e,t){if(!(!e.client||!e.connected||e.sessionsLoading||!window.confirm(`Delete session "${t}"?
|
|
9
9
|
|
|
10
|
-
Deletes the session entry and archives its transcript.`))){e.sessionsLoading=!0,e.sessionsError=null;try{await e.client.request("sessions.delete",{key:t,deleteTranscript:!0}),await
|
|
11
|
-
`)}function aa(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Gl(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const s=
|
|
10
|
+
Deletes the session entry and archives its transcript.`))){e.sessionsLoading=!0,e.sessionsError=null;try{await e.client.request("sessions.delete",{key:t,deleteTranscript:!0}),await Ke(e)}catch(s){e.sessionsError=String(s)}finally{e.sessionsLoading=!1}}}const ia=50,jl=80,ql=12e4;function Gl(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const s=n.map(i=>{if(!i||typeof i!="object")return null;const a=i;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(i=>!!i);return s.length===0?null:s.join(`
|
|
11
|
+
`)}function aa(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Gl(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const s=vo(n,ql);return s.truncated?`${s.text}
|
|
12
12
|
|
|
13
|
-
… truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function Wl(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 Vl(e){if(e.toolStreamOrder.length<=ia)return;const t=e.toolStreamOrder.length-ia,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function Yl(e){e.chatToolMessages=e.toolStreamOrder.map(t=>e.toolStreamById.get(t)?.message).filter(t=>!!t)}function us(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Yl(e)}function Ql(e,t=!1){if(t){us(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>us(e),jl))}function
|
|
13
|
+
… truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function Wl(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 Vl(e){if(e.toolStreamOrder.length<=ia)return;const t=e.toolStreamOrder.length-ia,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function Yl(e){e.chatToolMessages=e.toolStreamOrder.map(t=>e.toolStreamById.get(t)?.message).filter(t=>!!t)}function us(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Yl(e)}function Ql(e,t=!1){if(t){us(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>us(e),jl))}function dn(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],us(e)}const Zl=5e3;function Jl(e,t){const n=t.data??{},s=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),s==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:s==="end"&&(e.compactionStatus={active:!1,startedAt:e.compactionStatus?.startedAt??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},Zl))}function Xl(e,t){if(!t)return;if(t.stream==="compaction"){Jl(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const s=t.data??{},i=typeof s.toolCallId=="string"?s.toolCallId:"";if(!i)return;const a=typeof s.name=="string"?s.name:"tool",o=typeof s.phase=="string"?s.phase:"",r=o==="start"?s.args:void 0,l=o==="update"?aa(s.partialResult):o==="result"?aa(s.result):void 0,p=Date.now();let d=e.toolStreamById.get(i);d?(d.name=a,r!==void 0&&(d.args=r),l!==void 0&&(d.output=l),d.updatedAt=p):(d={toolCallId:i,runId:t.runId,sessionKey:n,name:a,args:r,output:l,startedAt:typeof t.ts=="number"?t.ts:p,updatedAt:p,message:{}},e.toolStreamById.set(i,d),e.toolStreamOrder.push(i)),d.message=Wl(d),Vl(e),Ql(e,o==="result")}function un(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=()=>{const s=e.querySelector(".chat-thread");if(s){const i=getComputedStyle(s).overflowY;if(i==="auto"||i==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;const s=n();if(!s)return;const i=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||i<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const o=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;const r=n();if(!r)return;const l=r.scrollHeight-r.scrollTop-r.clientHeight;(t||e.chatUserNearBottom||l<200)&&(r.scrollTop=r.scrollHeight,e.chatUserNearBottom=!0)},o)})})}function yo(e,t=!1){e.logsScrollFrame&&cancelAnimationFrame(e.logsScrollFrame),e.updateComplete.then(()=>{e.logsScrollFrame=requestAnimationFrame(()=>{e.logsScrollFrame=null;const n=e.querySelector(".log-stream");if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;(t||s<80)&&(n.scrollTop=n.scrollHeight)})})}function ec(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<200}function tc(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.logsAtBottom=s<80}function nc(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function sc(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
|
|
14
14
|
`)}
|
|
15
|
-
`],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),a=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`lemonade-logs-${t}-${a}.log`,i.click(),URL.revokeObjectURL(s)}function ic(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:s}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${s}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function
|
|
16
|
-
`}function yo(e,t,n){if(t.length===0)return;let s=e;for(let a=0;a<t.length-1;a+=1){const o=t[a],r=t[a+1];if(typeof o=="number"){if(!Array.isArray(s))return;s[o]==null&&(s[o]=typeof r=="number"?[]:{}),s=s[o]}else{if(typeof s!="object"||s==null)return;const l=s;l[o]==null&&(l[o]=typeof r=="number"?[]:{}),s=l[o]}}const i=t[t.length-1];if(typeof i=="number"){Array.isArray(s)&&(s[i]=n);return}typeof s=="object"&&s!=null&&(s[i]=n)}function bo(e,t){if(t.length===0)return;let n=e;for(let i=0;i<t.length-1;i+=1){const a=t[i];if(typeof a=="number"){if(!Array.isArray(n))return;n=n[a]}else{if(typeof n!="object"||n==null)return;n=n[a]}if(n==null)return}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(n)&&n.splice(s,1);return}typeof n=="object"&&n!=null&&delete n[s]}async function ye(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});oc(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function wo(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});ac(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function ac(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function oc(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?tt(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=tt(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=Be(t.config??{}),e.configFormOriginal=Be(t.config??{}),e.configRawOriginal=n)}async function ps(e){if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?tt(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:t,baseHash:n}),e.configFormDirty=!1,await ye(e)}catch(t){e.lastError=String(t)}finally{e.configSaving=!1}}}async function rc(e){if(!(!e.client||!e.connected)){e.configApplying=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?tt(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.apply",{raw:t,baseHash:n,sessionKey:e.applySessionKey}),e.configFormDirty=!1,await ye(e)}catch(t){e.lastError=String(t)}finally{e.configApplying=!1}}}async function lc(e){if(!(!e.client||!e.connected)){e.updateRunning=!0,e.lastError=null;try{await e.client.request("update.run",{sessionKey:e.applySessionKey})}catch(t){e.lastError=String(t)}finally{e.updateRunning=!1}}}function Ut(e,t,n){const s=Be(e.configForm??e.configSnapshot?.config??{});yo(s,t,n),e.configForm=s,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=tt(s))}function oa(e,t){const n=Be(e.configForm??e.configSnapshot?.config??{});bo(n,t),e.configForm=n,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=tt(n))}async function Et(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 hn(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t=await e.client.request("cron.list",{includeDisabled:!0});e.cronJobs=Array.isArray(t.jobs)?t.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function cc(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=Jt(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const s=e.everyUnit;return{kind:"every",everyMs:n*(s==="minutes"?6e4:s==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function dc(e){if(e.payloadKind==="systemEvent"){const i=e.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel),e.to.trim()&&(n.to=e.to.trim());const s=Jt(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function uc(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const t=cc(e.cronForm),n=dc(e.cronForm),s=e.cronForm.agentId.trim(),i={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,enabled:e.cronForm.enabled,schedule:t,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:n,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!i.name)throw new Error("Name required.");await e.client.request("cron.add",i),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await hn(e),await Et(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function pc(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 hn(e),await Et(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function hc(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await $o(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function fc(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 hn(e),await Et(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function $o(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 oe(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 gc(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const n=await e.client.request("web.login.start",{force:t,timeoutMs:3e4});e.whatsappLoginMessage=n.message??null,e.whatsappLoginQrDataUrl=n.qrDataUrl??null,e.whatsappLoginConnected=null}catch(n){e.whatsappLoginMessage=String(n),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function vc(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const t=await e.client.request("web.login.wait",{timeoutMs:12e4});e.whatsappLoginMessage=t.message??null,e.whatsappLoginConnected=t.connected??null,t.connected&&(e.whatsappLoginQrDataUrl=null)}catch(t){e.whatsappLoginMessage=String(t),e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function mc(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request("channels.logout",{channel:"whatsapp"}),e.whatsappLoginMessage="Logged out.",e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}catch(t){e.whatsappLoginMessage=String(t)}finally{e.whatsappBusy=!1}}}async function fn(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,s,i]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const a=s;e.debugModels=Array.isArray(a?.models)?a?.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}async function yc(e){if(!(!e.client||!e.connected)){e.debugCallError=null,e.debugCallResult=null;try{const t=e.debugCallParams.trim()?JSON.parse(e.debugCallParams):{},n=await e.client.request(e.debugCallMethod.trim(),t);e.debugCallResult=JSON.stringify(n,null,2)}catch(t){e.debugCallError=String(t)}}}const bc=2e3,wc=new Set(["trace","debug","info","warn","error","fatal"]);function $c(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 xc(e){if(typeof e!="string")return null;const t=e.toLowerCase();return wc.has(t)?t:null}function Ac(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,s=typeof t.time=="string"?t.time:typeof n?.date=="string"?n?.date:null,i=xc(n?.logLevelName??n?.level),a=typeof t[0]=="string"?t[0]:typeof n?.name=="string"?n?.name:null,o=$c(a);let r=null;o&&(typeof o.subsystem=="string"?r=o.subsystem:typeof o.module=="string"&&(r=o.module)),!r&&a&&a.length<120&&(r=a);let l=null;return typeof t[1]=="string"?l=t[1]:!o&&typeof t[0]=="string"?l=t[0]:typeof t.message=="string"&&(l=t.message),{raw:e,time:s,level:i,subsystem:r,message:l??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Fs(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!t?.quiet)){t?.quiet||(e.logsLoading=!0),e.logsError=null;try{const s=await e.client.request("logs.tail",{cursor:t?.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),a=(Array.isArray(s.lines)?s.lines.filter(r=>typeof r=="string"):[]).map(Ac),o=!!(t?.reset||s.reset||e.logsCursor==null);e.logsEntries=o?a:[...e.logsEntries,...a].slice(-bc),typeof s.cursor=="number"&&(e.logsCursor=s.cursor),typeof s.file=="string"&&(e.logsFile=s.file),e.logsTruncated=!!s.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t?.quiet||(e.logsLoading=!1)}}}const xo={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:G,n:Vt,Gx:ra,Gy:la,a:qn,d:Gn,h:kc}=xo,Fe=32,Us=64,Sc=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},H=(e="")=>{const t=new Error(e);throw Sc(t,H),t},_c=e=>typeof e=="bigint",Cc=e=>typeof e=="string",Tc=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",_e=(e,t,n="")=>{const s=Tc(e),i=e?.length,a=t!==void 0;if(!s||a&&i!==t){const o=n&&`"${n}" `,r=a?` of length ${t}`:"",l=s?`length=${i}`:`type=${typeof e}`;H(o+"expected Uint8Array"+r+", got "+l)}return e},gn=e=>new Uint8Array(e),Ao=e=>Uint8Array.from(e),ko=(e,t)=>e.toString(16).padStart(t,"0"),So=e=>Array.from(_e(e)).map(t=>ko(t,2)).join(""),me={_0:48,_9:57,A:65,F:70,a:97,f:102},ca=e=>{if(e>=me._0&&e<=me._9)return e-me._0;if(e>=me.A&&e<=me.F)return e-(me.A-10);if(e>=me.a&&e<=me.f)return e-(me.a-10)},_o=e=>{const t="hex invalid";if(!Cc(e))return H(t);const n=e.length,s=n/2;if(n%2)return H(t);const i=gn(s);for(let a=0,o=0;a<s;a++,o+=2){const r=ca(e.charCodeAt(o)),l=ca(e.charCodeAt(o+1));if(r===void 0||l===void 0)return H(t);i[a]=r*16+l}return i},Co=()=>globalThis?.crypto,Ec=()=>Co()?.subtle??H("crypto.subtle must be defined, consider polyfill"),Ct=(...e)=>{const t=gn(e.reduce((s,i)=>s+_e(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},Mc=(e=Fe)=>Co().getRandomValues(gn(e)),Xt=BigInt,Ie=(e,t,n,s="bad number: out of range")=>_c(e)&&t<=e&&e<n?e:H(s),k=(e,t=G)=>{const n=e%t;return n>=0n?n:t+n},To=e=>k(e,Vt),Lc=(e,t)=>{(e===0n||t<=0n)&&H("no inverse n="+e+" mod="+t);let n=k(e,t),s=t,i=0n,a=1n;for(;n!==0n;){const o=s/n,r=s%n,l=i-a*o;s=n,n=r,i=a,a=l}return s===1n?k(i,t):H("no inverse")},Rc=e=>{const t=Ro[e];return typeof t!="function"&&H("hashes."+e+" not set"),t},Wn=e=>e instanceof ee?e:H("Point expected"),hs=2n**256n;class ee{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,s,i){const a=hs;this.X=Ie(t,0n,a),this.Y=Ie(n,0n,a),this.Z=Ie(s,1n,a),this.T=Ie(i,0n,a),Object.freeze(this)}static CURVE(){return xo}static fromAffine(t){return new ee(t.x,t.y,1n,k(t.x*t.y))}static fromBytes(t,n=!1){const s=Gn,i=Ao(_e(t,Fe)),a=t[31];i[31]=a&-129;const o=Mo(i);Ie(o,0n,n?hs:G);const l=k(o*o),p=k(l-1n),d=k(s*l+1n);let{isValid:u,value:g}=Pc(p,d);u||H("bad point: y not sqrt");const v=(g&1n)===1n,m=(a&128)!==0;return!n&&g===0n&&m&&H("bad point: x==0, isLastByteOdd"),m!==v&&(g=k(-g)),new ee(g,o,1n,k(g*o))}static fromHex(t,n){return ee.fromBytes(_o(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=qn,n=Gn,s=this;if(s.is0())return H("bad point: ZERO");const{X:i,Y:a,Z:o,T:r}=s,l=k(i*i),p=k(a*a),d=k(o*o),u=k(d*d),g=k(l*t),v=k(d*k(g+p)),m=k(u+k(n*k(l*p)));if(v!==m)return H("bad point: equation left != right (1)");const $=k(i*a),A=k(o*r);return $!==A?H("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:a,Y:o,Z:r}=Wn(t),l=k(n*r),p=k(a*i),d=k(s*r),u=k(o*i);return l===p&&d===u}is0(){return this.equals(Je)}negate(){return new ee(k(-this.X),this.Y,this.Z,k(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=qn,a=k(t*t),o=k(n*n),r=k(2n*k(s*s)),l=k(i*a),p=t+n,d=k(k(p*p)-a-o),u=l+o,g=u-r,v=l-o,m=k(d*g),$=k(u*v),A=k(d*v),_=k(g*u);return new ee(m,$,_,A)}add(t){const{X:n,Y:s,Z:i,T:a}=this,{X:o,Y:r,Z:l,T:p}=Wn(t),d=qn,u=Gn,g=k(n*o),v=k(s*r),m=k(a*u*p),$=k(i*l),A=k((n+s)*(o+r)-g-v),_=k($-m),L=k($+m),P=k(v-d*g),M=k(A*_),E=k(L*P),C=k(A*P),he=k(_*L);return new ee(M,E,he,C)}subtract(t){return this.add(Wn(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Je;if(Ie(t,1n,Vt),t===1n)return this;if(this.equals(Ue))return qc(t).p;let s=Je,i=Ue;for(let a=this;t>0n;a=a.double(),t>>=1n)t&1n?s=s.add(a):n&&(i=i.add(a));return s}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:s}=this;if(this.equals(Je))return{x:0n,y:1n};const i=Lc(s,G);k(s*i)!==1n&&H("invalid inverse");const a=k(t*i),o=k(n*i);return{x:a,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=Eo(n);return s[31]|=t&1n?128:0,s}toHex(){return So(this.toBytes())}clearCofactor(){return this.multiply(Xt(kc),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Vt/2n,!1).double();return Vt%2n&&(t=t.add(this)),t.is0()}}const Ue=new ee(ra,la,1n,k(ra*la)),Je=new ee(0n,1n,1n,0n);ee.BASE=Ue;ee.ZERO=Je;const Eo=e=>_o(ko(Ie(e,0n,hs),Us)).reverse(),Mo=e=>Xt("0x"+So(Ao(_e(e)).reverse())),ce=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=G;return n},Ic=e=>{const n=e*e%G*e%G,s=ce(n,2n)*n%G,i=ce(s,1n)*e%G,a=ce(i,5n)*i%G,o=ce(a,10n)*a%G,r=ce(o,20n)*o%G,l=ce(r,40n)*r%G,p=ce(l,80n)*l%G,d=ce(p,80n)*l%G,u=ce(d,10n)*a%G;return{pow_p_5_8:ce(u,2n)*e%G,b2:n}},da=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Pc=(e,t)=>{const n=k(t*t*t),s=k(n*n*t),i=Ic(e*s).pow_p_5_8;let a=k(e*n*i);const o=k(t*a*a),r=a,l=k(a*da),p=o===e,d=o===k(-e),u=o===k(-e*da);return p&&(a=r),(d||u)&&(a=l),(k(a)&1n)===1n&&(a=k(-a)),{isValid:p||d,value:a}},fs=e=>To(Mo(e)),Ks=(...e)=>Ro.sha512Async(Ct(...e)),Nc=(...e)=>Rc("sha512")(Ct(...e)),Lo=e=>{const t=e.slice(0,Fe);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Fe,Us),s=fs(t),i=Ue.multiply(s),a=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:a}},Hs=e=>Ks(_e(e,Fe)).then(Lo),Oc=e=>Lo(Nc(_e(e,Fe))),Dc=e=>Hs(e).then(t=>t.pointBytes),Bc=e=>Ks(e.hashable).then(e.finish),Fc=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,a=fs(t),o=Ue.multiply(a).toBytes();return{hashable:Ct(o,s,n),finish:p=>{const d=To(a+fs(p)*i);return _e(Ct(o,Eo(d)),Us)}}},Uc=async(e,t)=>{const n=_e(e),s=await Hs(t),i=await Ks(s.prefix,n);return Bc(Fc(s,i,n))},Ro={sha512Async:async e=>{const t=Ec(),n=Ct(e);return gn(await t.digest("SHA-512",n.buffer))},sha512:void 0},Kc=(e=Mc(Fe))=>e,Hc={getExtendedPublicKeyAsync:Hs,getExtendedPublicKey:Oc,randomSecretKey:Kc},en=8,zc=256,Io=Math.ceil(zc/en)+1,gs=2**(en-1),jc=()=>{const e=[];let t=Ue,n=t;for(let s=0;s<Io;s++){n=t,e.push(n);for(let i=1;i<gs;i++)n=n.add(t),e.push(n);t=n.double()}return e};let ua;const pa=(e,t)=>{const n=t.negate();return e?n:t},qc=e=>{const t=ua||(ua=jc());let n=Je,s=Ue;const i=2**en,a=i,o=Xt(i-1),r=Xt(en);for(let l=0;l<Io;l++){let p=Number(e&o);e>>=r,p>gs&&(p-=a,e+=1n);const d=l*gs,u=d,g=d+Math.abs(p)-1,v=l%2!==0,m=p<0;p===0?s=s.add(pa(v,t[u])):n=n.add(pa(m,t[g]))}return e!==0n&&H("invalid wnaf"),{p:n,f:s}},Vn="lemonade-device-identity-v1";function vs(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replaceAll("+","-").replaceAll("/","_").replace(/=+$/g,"")}function Po(e){const t=e.replaceAll("-","+").replaceAll("_","/"),n=t+"=".repeat((4-t.length%4)%4),s=atob(n),i=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)i[a]=s.charCodeAt(a);return i}function Gc(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function No(e){const t=await crypto.subtle.digest("SHA-256",e);return Gc(new Uint8Array(t))}async function Wc(){const e=Hc.randomSecretKey(),t=await Dc(e);return{deviceId:await No(t),publicKey:vs(t),privateKey:vs(e)}}async function zs(){try{const n=localStorage.getItem(Vn);if(n){const s=JSON.parse(n);if(s?.version===1&&typeof s.deviceId=="string"&&typeof s.publicKey=="string"&&typeof s.privateKey=="string"){const i=await No(Po(s.publicKey));if(i!==s.deviceId){const a={...s,deviceId:i};return localStorage.setItem(Vn,JSON.stringify(a)),{deviceId:i,publicKey:s.publicKey,privateKey:s.privateKey}}return{deviceId:s.deviceId,publicKey:s.publicKey,privateKey:s.privateKey}}}}catch{}const e=await Wc(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Vn,JSON.stringify(t)),e}async function Vc(e,t){const n=Po(e),s=new TextEncoder().encode(t),i=await Uc(s,n);return vs(i)}const Oo="lemonade.device.auth.v1";function js(e){return e.trim()}function Yc(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const s=n.trim();s&&t.add(s)}return[...t].sort()}function qs(){try{const e=window.localStorage.getItem(Oo);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 Do(e){try{window.localStorage.setItem(Oo,JSON.stringify(e))}catch{}}function Qc(e){const t=qs();if(!t||t.deviceId!==e.deviceId)return null;const n=js(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function Bo(e){const t=js(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=qs();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:Yc(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,Do(n),i}function Fo(e){const t=qs();if(!t||t.deviceId!==e.deviceId)return;const n=js(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],Do(s)}async function Ce(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t?.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n?.pending)?n.pending:[],paired:Array.isArray(n?.paired)?n.paired:[]}}catch(n){t?.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function Zc(e,t){if(!(!e.client||!e.connected))try{await e.client.request("device.pair.approve",{requestId:t}),await Ce(e)}catch(n){e.devicesError=String(n)}}async function Jc(e,t){if(!(!e.client||!e.connected||!window.confirm("Reject this device pairing request?")))try{await e.client.request("device.pair.reject",{requestId:t}),await Ce(e)}catch(s){e.devicesError=String(s)}}async function Xc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("device.token.rotate",t);if(n?.token){const s=await zs(),i=n.role??t.role;(n.deviceId===s.deviceId||t.deviceId===s.deviceId)&&Bo({deviceId:s.deviceId,role:i,token:n.token,scopes:n.scopes??t.scopes??[]}),window.prompt("New device token (copy and store securely):",n.token)}await Ce(e)}catch(n){e.devicesError=String(n)}}async function ed(e,t){if(!(!e.client||!e.connected||!window.confirm(`Revoke token for ${t.deviceId} (${t.role})?`)))try{await e.client.request("device.token.revoke",t);const s=await zs();t.deviceId===s.deviceId&&Fo({deviceId:s.deviceId,role:t.role}),await Ce(e)}catch(s){e.devicesError=String(s)}}async function vn(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,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?.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function td(e){if(!e||e.kind==="gateway")return{method:"exec.approvals.get",params:{}};const t=e.nodeId.trim();return t?{method:"exec.approvals.node.get",params:{nodeId:t}}:null}function nd(e,t){if(!e||e.kind==="gateway")return{method:"exec.approvals.set",params:t};const n=e.nodeId.trim();return n?{method:"exec.approvals.node.set",params:{...t,nodeId:n}}:null}async function Gs(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=td(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);sd(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function sd(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=Be(t.file??{}))}async function id(e,t){if(!(!e.client||!e.connected)){e.execApprovalsSaving=!0,e.lastError=null;try{const n=e.execApprovalsSnapshot?.hash;if(!n){e.lastError="Exec approvals hash missing; reload and retry.";return}const s=e.execApprovalsForm??e.execApprovalsSnapshot?.file??{},i=nd(t,{file:s,baseHash:n});if(!i){e.lastError="Select a node before saving exec approvals.";return}await e.client.request(i.method,i.params),e.execApprovalsDirty=!1,await Gs(e,t)}catch(n){e.lastError=String(n)}finally{e.execApprovalsSaving=!1}}}function ad(e,t,n){const s=Be(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});yo(s,t,n),e.execApprovalsForm=s,e.execApprovalsDirty=!0}function od(e,t){const n=Be(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});bo(n,t),e.execApprovalsForm=n,e.execApprovalsDirty=!0}async function Ws(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 nt(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function mn(e){return e instanceof Error?e.message:String(e)}async function Mt(e,t){if(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=mn(n)}finally{e.skillsLoading=!1}}}function rd(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function ld(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 Mt(e),nt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=mn(s);e.skillsError=i,nt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function cd(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 Mt(e),nt(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=mn(n);e.skillsError=s,nt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function dd(e,t,n,s){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.install",{name:n,installId:s,timeoutMs:12e4});await Mt(e),nt(e,t,{kind:"success",message:i?.message??"Installed"})}catch(i){const a=mn(i);e.skillsError=a,nt(e,t,{kind:"error",message:a})}finally{e.skillsBusyKey=null}}}function ud(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Vs(e){return e==="system"?ud():e}const Kt=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,pd=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Ht=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},hd=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const a=i.documentElement,o=i,r=pd();if(!!o.startViewTransition&&!r){let p=.5,d=.5;if(n?.pointerClientX!==void 0&&n?.pointerClientY!==void 0&&typeof window<"u")p=Kt(n.pointerClientX/window.innerWidth),d=Kt(n.pointerClientY/window.innerHeight);else if(n?.element){const u=n.element.getBoundingClientRect();u.width>0&&u.height>0&&typeof window<"u"&&(p=Kt((u.left+u.width/2)/window.innerWidth),d=Kt((u.top+u.height/2)/window.innerHeight))}a.style.setProperty("--theme-switch-x",`${p*100}%`),a.style.setProperty("--theme-switch-y",`${d*100}%`),a.classList.add("theme-transition");try{const u=o.startViewTransition?.(()=>{t()});u?.finished?u.finished.finally(()=>Ht(a)):Ht(a)}catch{Ht(a),t()}return}t(),Ht(a)};function fd(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{vn(e,{quiet:!0})},5e3))}function gd(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Ys(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Fs(e,{quiet:!0})},2e3))}function Qs(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Zs(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&fn(e)},3e3))}function Js(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Se(e,t){const n={...t,lastActiveSessionKey:t.lastActiveSessionKey?.trim()||t.sessionKey.trim()||"main"};e.settings=n,xl(n),t.theme!==e.theme&&(e.theme=t.theme,yn(e,Vs(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function Uo(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Se(e,{...e.settings,lastActiveSessionKey:n})}function vd(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),s=t.get("password"),i=t.get("session"),a=t.get("gatewayUrl");let o=!1;if(n!=null){const l=n.trim();l&&l!==e.settings.token&&Se(e,{...e.settings,token:l}),t.delete("token"),o=!0}if(s!=null){const l=s.trim();l&&(e.password=l),t.delete("password"),o=!0}if(i!=null){const l=i.trim();l&&(e.sessionKey=l,Se(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(a!=null){const l=a.trim();l&&l!==e.settings.gatewayUrl&&(e.pendingGatewayUrl=l),t.delete("gatewayUrl"),o=!0}if(!o)return;const r=new URL(window.location.href);r.search=t.toString(),window.history.replaceState({},"",r.toString())}function md(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?Ys(e):Qs(e),t==="debug"?Zs(e):Js(e),Xs(e),Ho(e,t,!1)}function yd(e,t,n){hd({nextTheme:t,applyTheme:()=>{e.theme=t,Se(e,{...e.settings,theme:t}),yn(e,Vs(t))},context:n,currentTheme:e.theme})}async function Xs(e){e.tab==="overview"&&await zo(e),e.tab==="channels"&&await _d(e),e.tab==="instances"&&await Ws(e),e.tab==="sessions"&&await He(e),e.tab==="cron"&&await ei(e),e.tab==="skills"&&await Mt(e),e.tab==="nodes"&&(await vn(e),await Ce(e),await ye(e),await Gs(e)),e.tab==="chat"&&(await Vo(e),pn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await wo(e),await ye(e)),e.tab==="debug"&&(await fn(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"&&(e.logsAtBottom=!0,await Fs(e,{reset:!0}),mo(e,!0))}function bd(){if(typeof window>"u")return"";const e=window.__LEMONADE_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?dn(e):kl(window.location.pathname)}function wd(e){e.theme=e.settings.theme??"system",yn(e,Vs(e.theme))}function yn(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function $d(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"&&yn(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function xd(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 Ad(e,t){if(typeof window>"u")return;const n=ho(window.location.pathname,e.basePath)??"chat";Ko(e,n),Ho(e,n,t)}function kd(e){if(typeof window>"u")return;const t=ho(window.location.pathname,e.basePath);if(!t)return;const s=new URL(window.location.href).searchParams.get("session")?.trim();s&&(e.sessionKey=s,Se(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s})),Ko(e,t)}function Ko(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?Ys(e):Qs(e),t==="debug"?Zs(e):Js(e),e.connected&&Xs(e)}function Ho(e,t,n){if(typeof window>"u")return;const s=kt(Ds(t,e.basePath)),i=kt(window.location.pathname),a=new URL(window.location.href);t==="chat"&&e.sessionKey?a.searchParams.set("session",e.sessionKey):a.searchParams.delete("session"),i!==s&&(a.pathname=s),n?window.history.replaceState({},"",a.toString()):window.history.pushState({},"",a.toString())}function Sd(e,t,n){if(typeof window>"u")return;const s=new URL(window.location.href);s.searchParams.set("session",t),window.history.replaceState({},"",s.toString())}async function zo(e){await Promise.all([oe(e,!1),Ws(e),He(e),Et(e),fn(e)])}async function _d(e){await Promise.all([oe(e,!0),wo(e),ye(e)])}async function ei(e){await Promise.all([oe(e,!1),Et(e),hn(e)])}function jo(e){return e.chatSending||!!e.chatRunId}function Cd(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"}function Td(e){const t=e.trim();if(!t)return!1;const n=t.toLowerCase();return n==="/new"||n==="/reset"?!0:n.startsWith("/new ")||n.startsWith("/reset ")}async function qo(e){e.connected&&(e.chatMessage="",await Ul(e))}function Ed(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);!s&&!i||(e.chatQueue=[...e.chatQueue,{id:Bs(),text:s,createdAt:Date.now(),attachments:i?n?.map(a=>({...a})):void 0}])}async function Go(e,t,n){un(e);const s=await Fl(e,t,n?.attachments);return!s&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!s&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),s&&Uo(e,e.sessionKey),s&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),s&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),pn(e),s&&!e.chatRunId&&Wo(e),s&&n?.refreshSessions&&(e.refreshSessionsAfterChat=!0),s}async function Wo(e){if(!e.connected||jo(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await Go(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function Md(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Ld(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),a=e.chatAttachments??[],o=t==null?a:[],r=o.length>0;if(!i&&!r)return;if(Cd(i)){await qo(e);return}const l=Td(i);if(t==null&&(e.chatMessage="",e.chatAttachments=[]),jo(e)){Ed(e,i,o);return}await Go(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&n?.restoreDraft),attachments:r?o:void 0,previousAttachments:t==null?a:void 0,restoreAttachments:!!(t&&n?.restoreDraft),refreshSessions:l})}async function Vo(e){await Promise.all([_t(e),He(e,{activeMinutes:0}),ms(e)]),pn(e,!0)}const Rd=Wo;function Id(e){const t=co(e.sessionKey);return t?.agentId?t.agentId:e.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim()||"main"}function Pd(e,t){const n=dn(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function ms(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Id(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Pd(e.basePath,t);try{const s=await fetch(n,{method:"GET"});if(!s.ok){e.chatAvatarUrl=null;return}const i=await s.json(),a=typeof i.avatarUrl=="string"?i.avatarUrl.trim():"";e.chatAvatarUrl=a||null}catch{e.chatAvatarUrl=null}}const{I:Nd}=ul,ha=e=>e,Od=e=>e.strings===void 0,fa=()=>document.createComment(""),lt=(e,t,n)=>{const s=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0){const a=s.insertBefore(fa(),i),o=s.insertBefore(fa(),i);n=new Nd(a,o,e,e.options)}else{const a=n._$AB.nextSibling,o=n._$AM,r=o!==e;if(r){let l;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(l=e._$AU)!==o._$AU&&n._$AP(l)}if(a!==i||r){let l=n._$AA;for(;l!==a;){const p=ha(l).nextSibling;ha(s).insertBefore(l,i),l=p}}}return n},Le=(e,t,n=e)=>(e._$AI(t,n),e),Dd={},Bd=(e,t=Dd)=>e._$AH=t,Fd=e=>e._$AH,Yn=e=>{e._$AR(),e._$AA.remove()};const ti={CHILD:2},ni=e=>(...t)=>({_$litDirective$:e,values:t});class si{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,s){this._$Ct=t,this._$AM=n,this._$Ci=s}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}}const bt=(e,t)=>{const n=e._$AN;if(n===void 0)return!1;for(const s of n)s._$AO?.(t,!1),bt(s,t);return!0},tn=e=>{let t,n;do{if((t=e._$AM)===void 0)break;n=t._$AN,n.delete(e),e=t}while(n?.size===0)},Yo=e=>{for(let t;t=e._$AM;e=t){let n=t._$AN;if(n===void 0)t._$AN=n=new Set;else if(n.has(e))break;n.add(e),Hd(t)}};function Ud(e){this._$AN!==void 0?(tn(this),this._$AM=e,Yo(this)):this._$AM=e}function Kd(e,t=!1,n=0){const s=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(s))for(let a=n;a<s.length;a++)bt(s[a],!1),tn(s[a]);else s!=null&&(bt(s,!1),tn(s));else bt(this,e)}const Hd=e=>{e.type==ti.CHILD&&(e._$AP??=Kd,e._$AQ??=Ud)};class zd extends si{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,n,s){super._$AT(t,n,s),Yo(this),this.isConnected=t._$AU}_$AO(t,n=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),n&&(bt(this,t),tn(this))}setValue(t){if(Od(this._$Ct))this._$Ct._$AI(t,this);else{const n=[...this._$Ct._$AH];n[this._$Ci]=t,this._$Ct._$AI(n,this,0)}}disconnected(){}reconnected(){}}const Qn=new WeakMap,jd=ni(class extends zd{render(e){return f}update(e,[t]){const n=t!==this.G;return n&&this.G!==void 0&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=t,this.ht=e.options?.host,this.rt(this.ct=e.element)),f}rt(e){if(this.isConnected||(e=void 0),typeof this.G=="function"){const t=this.ht??globalThis;let n=Qn.get(t);n===void 0&&(n=new WeakMap,Qn.set(t,n)),n.get(this.G)!==void 0&&this.G.call(this.ht,void 0),n.set(this.G,e),e!==void 0&&this.G.call(this.ht,e)}else this.G.value=e}get lt(){return typeof this.G=="function"?Qn.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});const ga=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s},Qo=ni(class extends si{constructor(e){if(super(e),e.type!==ti.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let s;n===void 0?n=t:t!==void 0&&(s=t);const i=[],a=[];let o=0;for(const r of e)i[o]=s?s(r,o):o,a[o]=n(r,o),o++;return{values:a,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,s]){const i=Fd(e),{values:a,keys:o}=this.dt(t,n,s);if(!Array.isArray(i))return this.ut=o,a;const r=this.ut??=[],l=[];let p,d,u=0,g=i.length-1,v=0,m=a.length-1;for(;u<=g&&v<=m;)if(i[u]===null)u++;else if(i[g]===null)g--;else if(r[u]===o[v])l[v]=Le(i[u],a[v]),u++,v++;else if(r[g]===o[m])l[m]=Le(i[g],a[m]),g--,m--;else if(r[u]===o[m])l[m]=Le(i[u],a[m]),lt(e,l[m+1],i[u]),u++,m--;else if(r[g]===o[v])l[v]=Le(i[g],a[v]),lt(e,i[u],i[g]),g--,v++;else if(p===void 0&&(p=ga(o,v,m),d=ga(r,u,g)),p.has(r[u]))if(p.has(r[g])){const $=d.get(o[v]),A=$!==void 0?i[$]:null;if(A===null){const _=lt(e,i[u]);Le(_,a[v]),l[v]=_}else l[v]=Le(A,a[v]),lt(e,i[u],A),i[$]=null;v++}else Yn(i[g]),g--;else Yn(i[u]),u++;for(;v<=m;){const $=lt(e,l[m+1]);Le($,a[v]),l[v++]=$}for(;u<=g;){const $=i[u++];$!==null&&Yn($)}return this.ut=o,Bd(e,l),ke}});function Zo(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const s=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",i=t.content,a=Array.isArray(i)?i:null,o=Array.isArray(a)&&a.some(u=>{const v=String(u.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),r=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||r)&&(n="toolResult");let l=[];typeof t.content=="string"?l=[{type:"text",text:t.content}]:Array.isArray(t.content)?l=t.content.map(u=>({type:u.type||"text",text:u.text,name:u.name,args:u.args||u.arguments})):typeof t.text=="string"&&(l=[{type:"text",text:t.text}]);const p=typeof t.timestamp=="number"?t.timestamp:Date.now(),d=typeof t.id=="string"?t.id:void 0;return{role:n,content:l,timestamp:p,id:d}}function ii(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 Jo(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}class ys extends si{constructor(t){if(super(t),this.it=f,t.type!==ti.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===f||t==null)return this._t=void 0,this.it=t;if(t===ke)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:[]}}}ys.directiveName="unsafeHTML",ys.resultType=1;const bs=ni(ys);const{entries:Xo,setPrototypeOf:va,isFrozen:qd,getPrototypeOf:Gd,getOwnPropertyDescriptor:Wd}=Object;let{freeze:Z,seal:ne,create:ws}=Object,{apply:$s,construct:xs}=typeof Reflect<"u"&&Reflect;Z||(Z=function(t){return t});ne||(ne=function(t){return t});$s||($s=function(t,n){for(var s=arguments.length,i=new Array(s>2?s-2:0),a=2;a<s;a++)i[a-2]=arguments[a];return t.apply(n,i)});xs||(xs=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return new t(...s)});const zt=J(Array.prototype.forEach),Vd=J(Array.prototype.lastIndexOf),ma=J(Array.prototype.pop),ct=J(Array.prototype.push),Yd=J(Array.prototype.splice),Yt=J(String.prototype.toLowerCase),Zn=J(String.prototype.toString),Jn=J(String.prototype.match),dt=J(String.prototype.replace),Qd=J(String.prototype.indexOf),Zd=J(String.prototype.trim),se=J(Object.prototype.hasOwnProperty),Y=J(RegExp.prototype.test),ut=Jd(TypeError);function J(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return $s(e,t,s)}}function Jd(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return xs(e,n)}}function R(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Yt;va&&va(e,null);let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){const a=n(i);a!==i&&(qd(t)||(t[s]=a),i=a)}e[i]=!0}return e}function Xd(e){for(let t=0;t<e.length;t++)se(e,t)||(e[t]=null);return e}function de(e){const t=ws(null);for(const[n,s]of Xo(e))se(e,n)&&(Array.isArray(s)?t[n]=Xd(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=de(s):t[n]=s);return t}function pt(e,t){for(;e!==null;){const s=Wd(e,t);if(s){if(s.get)return J(s.get);if(typeof s.value=="function")return J(s.value)}e=Gd(e)}function n(){return null}return n}const ya=Z(["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"]),Xn=Z(["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"]),es=Z(["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"]),eu=Z(["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"]),ts=Z(["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"]),tu=Z(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ba=Z(["#text"]),wa=Z(["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"]),ns=Z(["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"]),$a=Z(["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"]),jt=Z(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),nu=ne(/\{\{[\w\W]*|[\w\W]*\}\}/gm),su=ne(/<%[\w\W]*|[\w\W]*%>/gm),iu=ne(/\$\{[\w\W]*/gm),au=ne(/^data-[\-\w.\u00B7-\uFFFF]+$/),ou=ne(/^aria-[\-\w]+$/),er=ne(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ru=ne(/^(?:\w+script|data):/i),lu=ne(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),tr=ne(/^html$/i),cu=ne(/^[a-z][.\w]*(-[.\w]+)+$/i);var xa=Object.freeze({__proto__:null,ARIA_ATTR:ou,ATTR_WHITESPACE:lu,CUSTOM_ELEMENT:cu,DATA_ATTR:au,DOCTYPE_NAME:tr,ERB_EXPR:su,IS_ALLOWED_URI:er,IS_SCRIPT_OR_DATA:ru,MUSTACHE_EXPR:nu,TMPLIT_EXPR:iu});const ht={element:1,text:3,progressingInstruction:7,comment:8,document:9},du=function(){return typeof window>"u"?null:window},uu=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(s=n.getAttribute(i));const a="dompurify"+(s?"#"+s:"");try{return t.createPolicy(a,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Aa=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function nr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:du();const t=T=>nr(T);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==ht.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,i=s.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:r,Element:l,NodeFilter:p,NamedNodeMap:d=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:u,DOMParser:g,trustedTypes:v}=e,m=l.prototype,$=pt(m,"cloneNode"),A=pt(m,"remove"),_=pt(m,"nextSibling"),L=pt(m,"childNodes"),P=pt(m,"parentNode");if(typeof o=="function"){const T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let M,E="";const{implementation:C,createNodeIterator:he,createDocumentFragment:An,getElementsByTagName:kn}=n,{importNode:Rr}=s;let V=Aa();t.isSupported=typeof Xo=="function"&&typeof P=="function"&&C&&C.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Sn,ERB_EXPR:_n,TMPLIT_EXPR:Cn,DATA_ATTR:Ir,ARIA_ATTR:Pr,IS_SCRIPT_OR_DATA:Nr,ATTR_WHITESPACE:vi,CUSTOM_ELEMENT:Or}=xa;let{IS_ALLOWED_URI:mi}=xa,K=null;const yi=R({},[...ya,...Xn,...es,...ts,...ba]);let z=null;const bi=R({},[...wa,...ns,...$a,...jt]);let B=Object.seal(ws(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}})),it=null,Tn=null;const je=Object.seal(ws(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let wi=!0,En=!0,$i=!1,xi=!0,qe=!1,Rt=!0,Te=!1,Mn=!1,Ln=!1,Ge=!1,It=!1,Pt=!1,Ai=!0,ki=!1;const Dr="user-content-";let Rn=!0,at=!1,We={},re=null;const In=R({},["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 Si=null;const _i=R({},["audio","video","img","source","image","track"]);let Pn=null;const Ci=R({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Nt="http://www.w3.org/1998/Math/MathML",Ot="http://www.w3.org/2000/svg",fe="http://www.w3.org/1999/xhtml";let Ve=fe,Nn=!1,On=null;const Br=R({},[Nt,Ot,fe],Zn);let Dt=R({},["mi","mo","mn","ms","mtext"]),Bt=R({},["annotation-xml"]);const Fr=R({},["title","style","font","a","script"]);let ot=null;const Ur=["application/xhtml+xml","text/html"],Kr="text/html";let U=null,Ye=null;const Hr=n.createElement("form"),Ti=function(h){return h instanceof RegExp||h instanceof Function},Dn=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ye&&Ye===h)){if((!h||typeof h!="object")&&(h={}),h=de(h),ot=Ur.indexOf(h.PARSER_MEDIA_TYPE)===-1?Kr:h.PARSER_MEDIA_TYPE,U=ot==="application/xhtml+xml"?Zn:Yt,K=se(h,"ALLOWED_TAGS")?R({},h.ALLOWED_TAGS,U):yi,z=se(h,"ALLOWED_ATTR")?R({},h.ALLOWED_ATTR,U):bi,On=se(h,"ALLOWED_NAMESPACES")?R({},h.ALLOWED_NAMESPACES,Zn):Br,Pn=se(h,"ADD_URI_SAFE_ATTR")?R(de(Ci),h.ADD_URI_SAFE_ATTR,U):Ci,Si=se(h,"ADD_DATA_URI_TAGS")?R(de(_i),h.ADD_DATA_URI_TAGS,U):_i,re=se(h,"FORBID_CONTENTS")?R({},h.FORBID_CONTENTS,U):In,it=se(h,"FORBID_TAGS")?R({},h.FORBID_TAGS,U):de({}),Tn=se(h,"FORBID_ATTR")?R({},h.FORBID_ATTR,U):de({}),We=se(h,"USE_PROFILES")?h.USE_PROFILES:!1,wi=h.ALLOW_ARIA_ATTR!==!1,En=h.ALLOW_DATA_ATTR!==!1,$i=h.ALLOW_UNKNOWN_PROTOCOLS||!1,xi=h.ALLOW_SELF_CLOSE_IN_ATTR!==!1,qe=h.SAFE_FOR_TEMPLATES||!1,Rt=h.SAFE_FOR_XML!==!1,Te=h.WHOLE_DOCUMENT||!1,Ge=h.RETURN_DOM||!1,It=h.RETURN_DOM_FRAGMENT||!1,Pt=h.RETURN_TRUSTED_TYPE||!1,Ln=h.FORCE_BODY||!1,Ai=h.SANITIZE_DOM!==!1,ki=h.SANITIZE_NAMED_PROPS||!1,Rn=h.KEEP_CONTENT!==!1,at=h.IN_PLACE||!1,mi=h.ALLOWED_URI_REGEXP||er,Ve=h.NAMESPACE||fe,Dt=h.MATHML_TEXT_INTEGRATION_POINTS||Dt,Bt=h.HTML_INTEGRATION_POINTS||Bt,B=h.CUSTOM_ELEMENT_HANDLING||{},h.CUSTOM_ELEMENT_HANDLING&&Ti(h.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(B.tagNameCheck=h.CUSTOM_ELEMENT_HANDLING.tagNameCheck),h.CUSTOM_ELEMENT_HANDLING&&Ti(h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(B.attributeNameCheck=h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),h.CUSTOM_ELEMENT_HANDLING&&typeof h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(B.allowCustomizedBuiltInElements=h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),qe&&(En=!1),It&&(Ge=!0),We&&(K=R({},ba),z=[],We.html===!0&&(R(K,ya),R(z,wa)),We.svg===!0&&(R(K,Xn),R(z,ns),R(z,jt)),We.svgFilters===!0&&(R(K,es),R(z,ns),R(z,jt)),We.mathMl===!0&&(R(K,ts),R(z,$a),R(z,jt))),h.ADD_TAGS&&(typeof h.ADD_TAGS=="function"?je.tagCheck=h.ADD_TAGS:(K===yi&&(K=de(K)),R(K,h.ADD_TAGS,U))),h.ADD_ATTR&&(typeof h.ADD_ATTR=="function"?je.attributeCheck=h.ADD_ATTR:(z===bi&&(z=de(z)),R(z,h.ADD_ATTR,U))),h.ADD_URI_SAFE_ATTR&&R(Pn,h.ADD_URI_SAFE_ATTR,U),h.FORBID_CONTENTS&&(re===In&&(re=de(re)),R(re,h.FORBID_CONTENTS,U)),h.ADD_FORBID_CONTENTS&&(re===In&&(re=de(re)),R(re,h.ADD_FORBID_CONTENTS,U)),Rn&&(K["#text"]=!0),Te&&R(K,["html","head","body"]),K.table&&(R(K,["tbody"]),delete it.tbody),h.TRUSTED_TYPES_POLICY){if(typeof h.TRUSTED_TYPES_POLICY.createHTML!="function")throw ut('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof h.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ut('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');M=h.TRUSTED_TYPES_POLICY,E=M.createHTML("")}else M===void 0&&(M=uu(v,i)),M!==null&&typeof E=="string"&&(E=M.createHTML(""));Z&&Z(h),Ye=h}},Ei=R({},[...Xn,...es,...eu]),Mi=R({},[...ts,...tu]),zr=function(h){let x=P(h);(!x||!x.tagName)&&(x={namespaceURI:Ve,tagName:"template"});const S=Yt(h.tagName),D=Yt(x.tagName);return On[h.namespaceURI]?h.namespaceURI===Ot?x.namespaceURI===fe?S==="svg":x.namespaceURI===Nt?S==="svg"&&(D==="annotation-xml"||Dt[D]):!!Ei[S]:h.namespaceURI===Nt?x.namespaceURI===fe?S==="math":x.namespaceURI===Ot?S==="math"&&Bt[D]:!!Mi[S]:h.namespaceURI===fe?x.namespaceURI===Ot&&!Bt[D]||x.namespaceURI===Nt&&!Dt[D]?!1:!Mi[S]&&(Fr[S]||!Ei[S]):!!(ot==="application/xhtml+xml"&&On[h.namespaceURI]):!1},le=function(h){ct(t.removed,{element:h});try{P(h).removeChild(h)}catch{A(h)}},Ee=function(h,x){try{ct(t.removed,{attribute:x.getAttributeNode(h),from:x})}catch{ct(t.removed,{attribute:null,from:x})}if(x.removeAttribute(h),h==="is")if(Ge||It)try{le(x)}catch{}else try{x.setAttribute(h,"")}catch{}},Li=function(h){let x=null,S=null;if(Ln)h="<remove></remove>"+h;else{const F=Jn(h,/^[\r\n\t ]+/);S=F&&F[0]}ot==="application/xhtml+xml"&&Ve===fe&&(h='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+h+"</body></html>");const D=M?M.createHTML(h):h;if(Ve===fe)try{x=new g().parseFromString(D,ot)}catch{}if(!x||!x.documentElement){x=C.createDocument(Ve,"template",null);try{x.documentElement.innerHTML=Nn?E:D}catch{}}const q=x.body||x.documentElement;return h&&S&&q.insertBefore(n.createTextNode(S),q.childNodes[0]||null),Ve===fe?kn.call(x,Te?"html":"body")[0]:Te?x.documentElement:q},Ri=function(h){return he.call(h.ownerDocument||h,h,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Bn=function(h){return h instanceof u&&(typeof h.nodeName!="string"||typeof h.textContent!="string"||typeof h.removeChild!="function"||!(h.attributes instanceof d)||typeof h.removeAttribute!="function"||typeof h.setAttribute!="function"||typeof h.namespaceURI!="string"||typeof h.insertBefore!="function"||typeof h.hasChildNodes!="function")},Ii=function(h){return typeof r=="function"&&h instanceof r};function ge(T,h,x){zt(T,S=>{S.call(t,h,x,Ye)})}const Pi=function(h){let x=null;if(ge(V.beforeSanitizeElements,h,null),Bn(h))return le(h),!0;const S=U(h.nodeName);if(ge(V.uponSanitizeElement,h,{tagName:S,allowedTags:K}),Rt&&h.hasChildNodes()&&!Ii(h.firstElementChild)&&Y(/<[/\w!]/g,h.innerHTML)&&Y(/<[/\w!]/g,h.textContent)||h.nodeType===ht.progressingInstruction||Rt&&h.nodeType===ht.comment&&Y(/<[/\w]/g,h.data))return le(h),!0;if(!(je.tagCheck instanceof Function&&je.tagCheck(S))&&(!K[S]||it[S])){if(!it[S]&&Oi(S)&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,S)||B.tagNameCheck instanceof Function&&B.tagNameCheck(S)))return!1;if(Rn&&!re[S]){const D=P(h)||h.parentNode,q=L(h)||h.childNodes;if(q&&D){const F=q.length;for(let X=F-1;X>=0;--X){const ve=$(q[X],!0);ve.__removalCount=(h.__removalCount||0)+1,D.insertBefore(ve,_(h))}}}return le(h),!0}return h instanceof l&&!zr(h)||(S==="noscript"||S==="noembed"||S==="noframes")&&Y(/<\/no(script|embed|frames)/i,h.innerHTML)?(le(h),!0):(qe&&h.nodeType===ht.text&&(x=h.textContent,zt([Sn,_n,Cn],D=>{x=dt(x,D," ")}),h.textContent!==x&&(ct(t.removed,{element:h.cloneNode()}),h.textContent=x)),ge(V.afterSanitizeElements,h,null),!1)},Ni=function(h,x,S){if(Ai&&(x==="id"||x==="name")&&(S in n||S in Hr))return!1;if(!(En&&!Tn[x]&&Y(Ir,x))){if(!(wi&&Y(Pr,x))){if(!(je.attributeCheck instanceof Function&&je.attributeCheck(x,h))){if(!z[x]||Tn[x]){if(!(Oi(h)&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,h)||B.tagNameCheck instanceof Function&&B.tagNameCheck(h))&&(B.attributeNameCheck instanceof RegExp&&Y(B.attributeNameCheck,x)||B.attributeNameCheck instanceof Function&&B.attributeNameCheck(x,h))||x==="is"&&B.allowCustomizedBuiltInElements&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,S)||B.tagNameCheck instanceof Function&&B.tagNameCheck(S))))return!1}else if(!Pn[x]){if(!Y(mi,dt(S,vi,""))){if(!((x==="src"||x==="xlink:href"||x==="href")&&h!=="script"&&Qd(S,"data:")===0&&Si[h])){if(!($i&&!Y(Nr,dt(S,vi,"")))){if(S)return!1}}}}}}}return!0},Oi=function(h){return h!=="annotation-xml"&&Jn(h,Or)},Di=function(h){ge(V.beforeSanitizeAttributes,h,null);const{attributes:x}=h;if(!x||Bn(h))return;const S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:z,forceKeepAttr:void 0};let D=x.length;for(;D--;){const q=x[D],{name:F,namespaceURI:X,value:ve}=q,Qe=U(F),Fn=ve;let j=F==="value"?Fn:Zd(Fn);if(S.attrName=Qe,S.attrValue=j,S.keepAttr=!0,S.forceKeepAttr=void 0,ge(V.uponSanitizeAttribute,h,S),j=S.attrValue,ki&&(Qe==="id"||Qe==="name")&&(Ee(F,h),j=Dr+j),Rt&&Y(/((--!?|])>)|<\/(style|title|textarea)/i,j)){Ee(F,h);continue}if(Qe==="attributename"&&Jn(j,"href")){Ee(F,h);continue}if(S.forceKeepAttr)continue;if(!S.keepAttr){Ee(F,h);continue}if(!xi&&Y(/\/>/i,j)){Ee(F,h);continue}qe&&zt([Sn,_n,Cn],Fi=>{j=dt(j,Fi," ")});const Bi=U(h.nodeName);if(!Ni(Bi,Qe,j)){Ee(F,h);continue}if(M&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!X)switch(v.getAttributeType(Bi,Qe)){case"TrustedHTML":{j=M.createHTML(j);break}case"TrustedScriptURL":{j=M.createScriptURL(j);break}}if(j!==Fn)try{X?h.setAttributeNS(X,F,j):h.setAttribute(F,j),Bn(h)?le(h):ma(t.removed)}catch{Ee(F,h)}}ge(V.afterSanitizeAttributes,h,null)},jr=function T(h){let x=null;const S=Ri(h);for(ge(V.beforeSanitizeShadowDOM,h,null);x=S.nextNode();)ge(V.uponSanitizeShadowNode,x,null),Pi(x),Di(x),x.content instanceof a&&T(x.content);ge(V.afterSanitizeShadowDOM,h,null)};return t.sanitize=function(T){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,S=null,D=null,q=null;if(Nn=!T,Nn&&(T="<!-->"),typeof T!="string"&&!Ii(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw ut("dirty is not a string, aborting")}else throw ut("toString is not a function");if(!t.isSupported)return T;if(Mn||Dn(h),t.removed=[],typeof T=="string"&&(at=!1),at){if(T.nodeName){const ve=U(T.nodeName);if(!K[ve]||it[ve])throw ut("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof r)x=Li("<!---->"),S=x.ownerDocument.importNode(T,!0),S.nodeType===ht.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?x=S:x.appendChild(S);else{if(!Ge&&!qe&&!Te&&T.indexOf("<")===-1)return M&&Pt?M.createHTML(T):T;if(x=Li(T),!x)return Ge?null:Pt?E:""}x&&Ln&&le(x.firstChild);const F=Ri(at?T:x);for(;D=F.nextNode();)Pi(D),Di(D),D.content instanceof a&&jr(D.content);if(at)return T;if(Ge){if(It)for(q=An.call(x.ownerDocument);x.firstChild;)q.appendChild(x.firstChild);else q=x;return(z.shadowroot||z.shadowrootmode)&&(q=Rr.call(s,q,!0)),q}let X=Te?x.outerHTML:x.innerHTML;return Te&&K["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&Y(tr,x.ownerDocument.doctype.name)&&(X="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
|
|
17
|
-
`+X),
|
|
18
|
-
]`).replace("lheading",
|
|
15
|
+
`],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),a=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`lemonade-logs-${t}-${a}.log`,i.click(),URL.revokeObjectURL(s)}function ic(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:s}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${s}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function De(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function et(e){return`${JSON.stringify(e,null,2).trimEnd()}
|
|
16
|
+
`}function bo(e,t,n){if(t.length===0)return;let s=e;for(let a=0;a<t.length-1;a+=1){const o=t[a],r=t[a+1];if(typeof o=="number"){if(!Array.isArray(s))return;s[o]==null&&(s[o]=typeof r=="number"?[]:{}),s=s[o]}else{if(typeof s!="object"||s==null)return;const l=s;l[o]==null&&(l[o]=typeof r=="number"?[]:{}),s=l[o]}}const i=t[t.length-1];if(typeof i=="number"){Array.isArray(s)&&(s[i]=n);return}typeof s=="object"&&s!=null&&(s[i]=n)}function wo(e,t){if(t.length===0)return;let n=e;for(let i=0;i<t.length-1;i+=1){const a=t[i];if(typeof a=="number"){if(!Array.isArray(n))return;n=n[a]}else{if(typeof n!="object"||n==null)return;n=n[a]}if(n==null)return}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(n)&&n.splice(s,1);return}typeof n=="object"&&n!=null&&delete n[s]}async function ye(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});oc(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function $o(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});ac(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function ac(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function oc(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=De(t.config??{}),e.configFormOriginal=De(t.config??{}),e.configRawOriginal=n)}async function ps(e){if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?et(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:t,baseHash:n}),e.configFormDirty=!1,await ye(e)}catch(t){e.lastError=String(t)}finally{e.configSaving=!1}}}async function rc(e){if(!(!e.client||!e.connected)){e.configApplying=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?et(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.apply",{raw:t,baseHash:n,sessionKey:e.applySessionKey}),e.configFormDirty=!1,await ye(e)}catch(t){e.lastError=String(t)}finally{e.configApplying=!1}}}async function lc(e){if(!(!e.client||!e.connected)){e.updateRunning=!0,e.lastError=null;try{await e.client.request("update.run",{sessionKey:e.applySessionKey})}catch(t){e.lastError=String(t)}finally{e.updateRunning=!1}}}function Ft(e,t,n){const s=De(e.configForm??e.configSnapshot?.config??{});bo(s,t,n),e.configForm=s,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=et(s))}function oa(e,t){const n=De(e.configForm??e.configSnapshot?.config??{});wo(n,t),e.configForm=n,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=et(n))}async function Tt(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 pn(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t=await e.client.request("cron.list",{includeDisabled:!0});e.cronJobs=Array.isArray(t.jobs)?t.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function cc(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=Zt(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const s=e.everyUnit;return{kind:"every",everyMs:n*(s==="minutes"?6e4:s==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function dc(e){if(e.payloadKind==="systemEvent"){const i=e.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel),e.to.trim()&&(n.to=e.to.trim());const s=Zt(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function uc(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const t=cc(e.cronForm),n=dc(e.cronForm),s=e.cronForm.agentId.trim(),i={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,enabled:e.cronForm.enabled,schedule:t,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:n,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!i.name)throw new Error("Name required.");await e.client.request("cron.add",i),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await pn(e),await Tt(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function pc(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 pn(e),await Tt(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function hc(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await xo(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function fc(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 pn(e),await Tt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function xo(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 oe(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 gc(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const n=await e.client.request("web.login.start",{force:t,timeoutMs:3e4});e.whatsappLoginMessage=n.message??null,e.whatsappLoginQrDataUrl=n.qrDataUrl??null,e.whatsappLoginConnected=null}catch(n){e.whatsappLoginMessage=String(n),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function vc(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const t=await e.client.request("web.login.wait",{timeoutMs:12e4});e.whatsappLoginMessage=t.message??null,e.whatsappLoginConnected=t.connected??null,t.connected&&(e.whatsappLoginQrDataUrl=null)}catch(t){e.whatsappLoginMessage=String(t),e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function mc(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request("channels.logout",{channel:"whatsapp"}),e.whatsappLoginMessage="Logged out.",e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}catch(t){e.whatsappLoginMessage=String(t)}finally{e.whatsappBusy=!1}}}async function hn(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,s,i]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const a=s;e.debugModels=Array.isArray(a?.models)?a?.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}async function yc(e){if(!(!e.client||!e.connected)){e.debugCallError=null,e.debugCallResult=null;try{const t=e.debugCallParams.trim()?JSON.parse(e.debugCallParams):{},n=await e.client.request(e.debugCallMethod.trim(),t);e.debugCallResult=JSON.stringify(n,null,2)}catch(t){e.debugCallError=String(t)}}}const bc=2e3,wc=new Set(["trace","debug","info","warn","error","fatal"]);function $c(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 xc(e){if(typeof e!="string")return null;const t=e.toLowerCase();return wc.has(t)?t:null}function Ac(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,s=typeof t.time=="string"?t.time:typeof n?.date=="string"?n?.date:null,i=xc(n?.logLevelName??n?.level),a=typeof t[0]=="string"?t[0]:typeof n?.name=="string"?n?.name:null,o=$c(a);let r=null;o&&(typeof o.subsystem=="string"?r=o.subsystem:typeof o.module=="string"&&(r=o.module)),!r&&a&&a.length<120&&(r=a);let l=null;return typeof t[1]=="string"?l=t[1]:!o&&typeof t[0]=="string"?l=t[0]:typeof t.message=="string"&&(l=t.message),{raw:e,time:s,level:i,subsystem:r,message:l??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Fs(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!t?.quiet)){t?.quiet||(e.logsLoading=!0),e.logsError=null;try{const s=await e.client.request("logs.tail",{cursor:t?.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),a=(Array.isArray(s.lines)?s.lines.filter(r=>typeof r=="string"):[]).map(Ac),o=!!(t?.reset||s.reset||e.logsCursor==null);e.logsEntries=o?a:[...e.logsEntries,...a].slice(-bc),typeof s.cursor=="number"&&(e.logsCursor=s.cursor),typeof s.file=="string"&&(e.logsFile=s.file),e.logsTruncated=!!s.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t?.quiet||(e.logsLoading=!1)}}}const Ao={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:G,n:Wt,Gx:ra,Gy:la,a:jn,d:qn,h:kc}=Ao,Be=32,Us=64,Sc=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},H=(e="")=>{const t=new Error(e);throw Sc(t,H),t},_c=e=>typeof e=="bigint",Cc=e=>typeof e=="string",Tc=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",_e=(e,t,n="")=>{const s=Tc(e),i=e?.length,a=t!==void 0;if(!s||a&&i!==t){const o=n&&`"${n}" `,r=a?` of length ${t}`:"",l=s?`length=${i}`:`type=${typeof e}`;H(o+"expected Uint8Array"+r+", got "+l)}return e},fn=e=>new Uint8Array(e),ko=e=>Uint8Array.from(e),So=(e,t)=>e.toString(16).padStart(t,"0"),_o=e=>Array.from(_e(e)).map(t=>So(t,2)).join(""),ve={_0:48,_9:57,A:65,F:70,a:97,f:102},ca=e=>{if(e>=ve._0&&e<=ve._9)return e-ve._0;if(e>=ve.A&&e<=ve.F)return e-(ve.A-10);if(e>=ve.a&&e<=ve.f)return e-(ve.a-10)},Co=e=>{const t="hex invalid";if(!Cc(e))return H(t);const n=e.length,s=n/2;if(n%2)return H(t);const i=fn(s);for(let a=0,o=0;a<s;a++,o+=2){const r=ca(e.charCodeAt(o)),l=ca(e.charCodeAt(o+1));if(r===void 0||l===void 0)return H(t);i[a]=r*16+l}return i},To=()=>globalThis?.crypto,Ec=()=>To()?.subtle??H("crypto.subtle must be defined, consider polyfill"),_t=(...e)=>{const t=fn(e.reduce((s,i)=>s+_e(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},Mc=(e=Be)=>To().getRandomValues(fn(e)),Jt=BigInt,Re=(e,t,n,s="bad number: out of range")=>_c(e)&&t<=e&&e<n?e:H(s),k=(e,t=G)=>{const n=e%t;return n>=0n?n:t+n},Eo=e=>k(e,Wt),Lc=(e,t)=>{(e===0n||t<=0n)&&H("no inverse n="+e+" mod="+t);let n=k(e,t),s=t,i=0n,a=1n;for(;n!==0n;){const o=s/n,r=s%n,l=i-a*o;s=n,n=r,i=a,a=l}return s===1n?k(i,t):H("no inverse")},Ic=e=>{const t=Ro[e];return typeof t!="function"&&H("hashes."+e+" not set"),t},Gn=e=>e instanceof ee?e:H("Point expected"),hs=2n**256n;class ee{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,s,i){const a=hs;this.X=Re(t,0n,a),this.Y=Re(n,0n,a),this.Z=Re(s,1n,a),this.T=Re(i,0n,a),Object.freeze(this)}static CURVE(){return Ao}static fromAffine(t){return new ee(t.x,t.y,1n,k(t.x*t.y))}static fromBytes(t,n=!1){const s=qn,i=ko(_e(t,Be)),a=t[31];i[31]=a&-129;const o=Lo(i);Re(o,0n,n?hs:G);const l=k(o*o),p=k(l-1n),d=k(s*l+1n);let{isValid:u,value:g}=Pc(p,d);u||H("bad point: y not sqrt");const v=(g&1n)===1n,y=(a&128)!==0;return!n&&g===0n&&y&&H("bad point: x==0, isLastByteOdd"),y!==v&&(g=k(-g)),new ee(g,o,1n,k(g*o))}static fromHex(t,n){return ee.fromBytes(Co(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=jn,n=qn,s=this;if(s.is0())return H("bad point: ZERO");const{X:i,Y:a,Z:o,T:r}=s,l=k(i*i),p=k(a*a),d=k(o*o),u=k(d*d),g=k(l*t),v=k(d*k(g+p)),y=k(u+k(n*k(l*p)));if(v!==y)return H("bad point: equation left != right (1)");const $=k(i*a),A=k(o*r);return $!==A?H("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:a,Y:o,Z:r}=Gn(t),l=k(n*r),p=k(a*i),d=k(s*r),u=k(o*i);return l===p&&d===u}is0(){return this.equals(Ze)}negate(){return new ee(k(-this.X),this.Y,this.Z,k(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=jn,a=k(t*t),o=k(n*n),r=k(2n*k(s*s)),l=k(i*a),p=t+n,d=k(k(p*p)-a-o),u=l+o,g=u-r,v=l-o,y=k(d*g),$=k(u*v),A=k(d*v),_=k(g*u);return new ee(y,$,_,A)}add(t){const{X:n,Y:s,Z:i,T:a}=this,{X:o,Y:r,Z:l,T:p}=Gn(t),d=jn,u=qn,g=k(n*o),v=k(s*r),y=k(a*u*p),$=k(i*l),A=k((n+s)*(o+r)-g-v),_=k($-y),L=k($+y),P=k(v-d*g),M=k(A*_),T=k(L*P),E=k(A*P),pe=k(_*L);return new ee(M,T,pe,E)}subtract(t){return this.add(Gn(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Ze;if(Re(t,1n,Wt),t===1n)return this;if(this.equals(Fe))return qc(t).p;let s=Ze,i=Fe;for(let a=this;t>0n;a=a.double(),t>>=1n)t&1n?s=s.add(a):n&&(i=i.add(a));return s}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:s}=this;if(this.equals(Ze))return{x:0n,y:1n};const i=Lc(s,G);k(s*i)!==1n&&H("invalid inverse");const a=k(t*i),o=k(n*i);return{x:a,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=Mo(n);return s[31]|=t&1n?128:0,s}toHex(){return _o(this.toBytes())}clearCofactor(){return this.multiply(Jt(kc),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Wt/2n,!1).double();return Wt%2n&&(t=t.add(this)),t.is0()}}const Fe=new ee(ra,la,1n,k(ra*la)),Ze=new ee(0n,1n,1n,0n);ee.BASE=Fe;ee.ZERO=Ze;const Mo=e=>Co(So(Re(e,0n,hs),Us)).reverse(),Lo=e=>Jt("0x"+_o(ko(_e(e)).reverse())),ce=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=G;return n},Rc=e=>{const n=e*e%G*e%G,s=ce(n,2n)*n%G,i=ce(s,1n)*e%G,a=ce(i,5n)*i%G,o=ce(a,10n)*a%G,r=ce(o,20n)*o%G,l=ce(r,40n)*r%G,p=ce(l,80n)*l%G,d=ce(p,80n)*l%G,u=ce(d,10n)*a%G;return{pow_p_5_8:ce(u,2n)*e%G,b2:n}},da=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Pc=(e,t)=>{const n=k(t*t*t),s=k(n*n*t),i=Rc(e*s).pow_p_5_8;let a=k(e*n*i);const o=k(t*a*a),r=a,l=k(a*da),p=o===e,d=o===k(-e),u=o===k(-e*da);return p&&(a=r),(d||u)&&(a=l),(k(a)&1n)===1n&&(a=k(-a)),{isValid:p||d,value:a}},fs=e=>Eo(Lo(e)),Ks=(...e)=>Ro.sha512Async(_t(...e)),Nc=(...e)=>Ic("sha512")(_t(...e)),Io=e=>{const t=e.slice(0,Be);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Be,Us),s=fs(t),i=Fe.multiply(s),a=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:a}},Hs=e=>Ks(_e(e,Be)).then(Io),Oc=e=>Io(Nc(_e(e,Be))),Dc=e=>Hs(e).then(t=>t.pointBytes),Bc=e=>Ks(e.hashable).then(e.finish),Fc=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,a=fs(t),o=Fe.multiply(a).toBytes();return{hashable:_t(o,s,n),finish:p=>{const d=Eo(a+fs(p)*i);return _e(_t(o,Mo(d)),Us)}}},Uc=async(e,t)=>{const n=_e(e),s=await Hs(t),i=await Ks(s.prefix,n);return Bc(Fc(s,i,n))},Ro={sha512Async:async e=>{const t=Ec(),n=_t(e);return fn(await t.digest("SHA-512",n.buffer))},sha512:void 0},Kc=(e=Mc(Be))=>e,Hc={getExtendedPublicKeyAsync:Hs,getExtendedPublicKey:Oc,randomSecretKey:Kc},Xt=8,zc=256,Po=Math.ceil(zc/Xt)+1,gs=2**(Xt-1),jc=()=>{const e=[];let t=Fe,n=t;for(let s=0;s<Po;s++){n=t,e.push(n);for(let i=1;i<gs;i++)n=n.add(t),e.push(n);t=n.double()}return e};let ua;const pa=(e,t)=>{const n=t.negate();return e?n:t},qc=e=>{const t=ua||(ua=jc());let n=Ze,s=Fe;const i=2**Xt,a=i,o=Jt(i-1),r=Jt(Xt);for(let l=0;l<Po;l++){let p=Number(e&o);e>>=r,p>gs&&(p-=a,e+=1n);const d=l*gs,u=d,g=d+Math.abs(p)-1,v=l%2!==0,y=p<0;p===0?s=s.add(pa(v,t[u])):n=n.add(pa(y,t[g]))}return e!==0n&&H("invalid wnaf"),{p:n,f:s}},Wn="lemonade-device-identity-v1";function vs(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replaceAll("+","-").replaceAll("/","_").replace(/=+$/g,"")}function No(e){const t=e.replaceAll("-","+").replaceAll("_","/"),n=t+"=".repeat((4-t.length%4)%4),s=atob(n),i=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)i[a]=s.charCodeAt(a);return i}function Gc(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Oo(e){const t=await crypto.subtle.digest("SHA-256",e);return Gc(new Uint8Array(t))}async function Wc(){const e=Hc.randomSecretKey(),t=await Dc(e);return{deviceId:await Oo(t),publicKey:vs(t),privateKey:vs(e)}}async function zs(){try{const n=localStorage.getItem(Wn);if(n){const s=JSON.parse(n);if(s?.version===1&&typeof s.deviceId=="string"&&typeof s.publicKey=="string"&&typeof s.privateKey=="string"){const i=await Oo(No(s.publicKey));if(i!==s.deviceId){const a={...s,deviceId:i};return localStorage.setItem(Wn,JSON.stringify(a)),{deviceId:i,publicKey:s.publicKey,privateKey:s.privateKey}}return{deviceId:s.deviceId,publicKey:s.publicKey,privateKey:s.privateKey}}}}catch{}const e=await Wc(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Wn,JSON.stringify(t)),e}async function Vc(e,t){const n=No(e),s=new TextEncoder().encode(t),i=await Uc(s,n);return vs(i)}const Do="lemonade.device.auth.v1";function js(e){return e.trim()}function Yc(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const s=n.trim();s&&t.add(s)}return[...t].sort()}function qs(){try{const e=window.localStorage.getItem(Do);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 Bo(e){try{window.localStorage.setItem(Do,JSON.stringify(e))}catch{}}function Qc(e){const t=qs();if(!t||t.deviceId!==e.deviceId)return null;const n=js(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function Fo(e){const t=js(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=qs();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:Yc(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,Bo(n),i}function Uo(e){const t=qs();if(!t||t.deviceId!==e.deviceId)return;const n=js(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],Bo(s)}async function Ce(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t?.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n?.pending)?n.pending:[],paired:Array.isArray(n?.paired)?n.paired:[]}}catch(n){t?.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function Zc(e,t){if(!(!e.client||!e.connected))try{await e.client.request("device.pair.approve",{requestId:t}),await Ce(e)}catch(n){e.devicesError=String(n)}}async function Jc(e,t){if(!(!e.client||!e.connected||!window.confirm("Reject this device pairing request?")))try{await e.client.request("device.pair.reject",{requestId:t}),await Ce(e)}catch(s){e.devicesError=String(s)}}async function Xc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("device.token.rotate",t);if(n?.token){const s=await zs(),i=n.role??t.role;(n.deviceId===s.deviceId||t.deviceId===s.deviceId)&&Fo({deviceId:s.deviceId,role:i,token:n.token,scopes:n.scopes??t.scopes??[]}),window.prompt("New device token (copy and store securely):",n.token)}await Ce(e)}catch(n){e.devicesError=String(n)}}async function ed(e,t){if(!(!e.client||!e.connected||!window.confirm(`Revoke token for ${t.deviceId} (${t.role})?`)))try{await e.client.request("device.token.revoke",t);const s=await zs();t.deviceId===s.deviceId&&Uo({deviceId:s.deviceId,role:t.role}),await Ce(e)}catch(s){e.devicesError=String(s)}}async function gn(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,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?.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function td(e){if(!e||e.kind==="gateway")return{method:"exec.approvals.get",params:{}};const t=e.nodeId.trim();return t?{method:"exec.approvals.node.get",params:{nodeId:t}}:null}function nd(e,t){if(!e||e.kind==="gateway")return{method:"exec.approvals.set",params:t};const n=e.nodeId.trim();return n?{method:"exec.approvals.node.set",params:{...t,nodeId:n}}:null}async function Gs(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=td(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);sd(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function sd(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=De(t.file??{}))}async function id(e,t){if(!(!e.client||!e.connected)){e.execApprovalsSaving=!0,e.lastError=null;try{const n=e.execApprovalsSnapshot?.hash;if(!n){e.lastError="Exec approvals hash missing; reload and retry.";return}const s=e.execApprovalsForm??e.execApprovalsSnapshot?.file??{},i=nd(t,{file:s,baseHash:n});if(!i){e.lastError="Select a node before saving exec approvals.";return}await e.client.request(i.method,i.params),e.execApprovalsDirty=!1,await Gs(e,t)}catch(n){e.lastError=String(n)}finally{e.execApprovalsSaving=!1}}}function ad(e,t,n){const s=De(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});bo(s,t,n),e.execApprovalsForm=s,e.execApprovalsDirty=!0}function od(e,t){const n=De(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});wo(n,t),e.execApprovalsForm=n,e.execApprovalsDirty=!0}async function Ws(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 tt(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function vn(e){return e instanceof Error?e.message:String(e)}async function Et(e,t){if(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=vn(n)}finally{e.skillsLoading=!1}}}function rd(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function ld(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 Et(e),tt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=vn(s);e.skillsError=i,tt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function cd(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 Et(e),tt(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=vn(n);e.skillsError=s,tt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function dd(e,t,n,s){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.install",{name:n,installId:s,timeoutMs:12e4});await Et(e),tt(e,t,{kind:"success",message:i?.message??"Installed"})}catch(i){const a=vn(i);e.skillsError=a,tt(e,t,{kind:"error",message:a})}finally{e.skillsBusyKey=null}}}function ud(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Vs(e){return e==="system"?ud():e}const Ut=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,pd=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Kt=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},hd=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const a=i.documentElement,o=i,r=pd();if(!!o.startViewTransition&&!r){let p=.5,d=.5;if(n?.pointerClientX!==void 0&&n?.pointerClientY!==void 0&&typeof window<"u")p=Ut(n.pointerClientX/window.innerWidth),d=Ut(n.pointerClientY/window.innerHeight);else if(n?.element){const u=n.element.getBoundingClientRect();u.width>0&&u.height>0&&typeof window<"u"&&(p=Ut((u.left+u.width/2)/window.innerWidth),d=Ut((u.top+u.height/2)/window.innerHeight))}a.style.setProperty("--theme-switch-x",`${p*100}%`),a.style.setProperty("--theme-switch-y",`${d*100}%`),a.classList.add("theme-transition");try{const u=o.startViewTransition?.(()=>{t()});u?.finished?u.finished.finally(()=>Kt(a)):Kt(a)}catch{Kt(a),t()}return}t(),Kt(a)};function fd(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{gn(e,{quiet:!0})},5e3))}function gd(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Ys(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Fs(e,{quiet:!0})},2e3))}function Qs(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Zs(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&hn(e)},3e3))}function Js(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Se(e,t){const n={...t,lastActiveSessionKey:t.lastActiveSessionKey?.trim()||t.sessionKey.trim()||"main"};e.settings=n,xl(n),t.theme!==e.theme&&(e.theme=t.theme,mn(e,Vs(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function Ko(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Se(e,{...e.settings,lastActiveSessionKey:n})}function vd(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),s=t.get("password"),i=t.get("session"),a=t.get("gatewayUrl");let o=!1;if(n!=null){const l=n.trim();l&&l!==e.settings.token&&Se(e,{...e.settings,token:l}),t.delete("token"),o=!0}if(s!=null){const l=s.trim();l&&(e.password=l),t.delete("password"),o=!0}if(i!=null){const l=i.trim();l&&(e.sessionKey=l,Se(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(a!=null){const l=a.trim();l&&l!==e.settings.gatewayUrl&&(e.pendingGatewayUrl=l),t.delete("gatewayUrl"),o=!0}if(!o)return;const r=new URL(window.location.href);r.search=t.toString(),window.history.replaceState({},"",r.toString())}function md(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?Ys(e):Qs(e),t==="debug"?Zs(e):Js(e),Xs(e),zo(e,t,!1)}function yd(e,t,n){hd({nextTheme:t,applyTheme:()=>{e.theme=t,Se(e,{...e.settings,theme:t}),mn(e,Vs(t))},context:n,currentTheme:e.theme})}async function Xs(e){e.tab==="overview"&&await jo(e),e.tab==="channels"&&await _d(e),e.tab==="instances"&&await Ws(e),e.tab==="sessions"&&await Ke(e),e.tab==="cron"&&await ei(e),e.tab==="skills"&&await Et(e),e.tab==="nodes"&&(await gn(e),await Ce(e),await ye(e),await Gs(e)),e.tab==="chat"&&(await Yo(e),un(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await $o(e),await ye(e)),e.tab==="debug"&&(await hn(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"&&(e.logsAtBottom=!0,await Fs(e,{reset:!0}),yo(e,!0))}function bd(){if(typeof window>"u")return"";const e=window.__LEMONADE_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?cn(e):kl(window.location.pathname)}function wd(e){e.theme=e.settings.theme??"system",mn(e,Vs(e.theme))}function mn(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function $d(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"&&mn(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function xd(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 Ad(e,t){if(typeof window>"u")return;const n=fo(window.location.pathname,e.basePath)??"chat";Ho(e,n),zo(e,n,t)}function kd(e){if(typeof window>"u")return;const t=fo(window.location.pathname,e.basePath);if(!t)return;const s=new URL(window.location.href).searchParams.get("session")?.trim();s&&(e.sessionKey=s,Se(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s})),Ho(e,t)}function Ho(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?Ys(e):Qs(e),t==="debug"?Zs(e):Js(e),e.connected&&Xs(e)}function zo(e,t,n){if(typeof window>"u")return;const s=At(Ds(t,e.basePath)),i=At(window.location.pathname),a=new URL(window.location.href);t==="chat"&&e.sessionKey?a.searchParams.set("session",e.sessionKey):a.searchParams.delete("session"),i!==s&&(a.pathname=s),n?window.history.replaceState({},"",a.toString()):window.history.pushState({},"",a.toString())}function Sd(e,t,n){if(typeof window>"u")return;const s=new URL(window.location.href);s.searchParams.set("session",t),window.history.replaceState({},"",s.toString())}async function jo(e){await Promise.all([oe(e,!1),Ws(e),Ke(e),Tt(e),hn(e)])}async function _d(e){await Promise.all([oe(e,!0),$o(e),ye(e)])}async function ei(e){await Promise.all([oe(e,!1),Tt(e),pn(e)])}function qo(e){return e.chatSending||!!e.chatRunId}function Cd(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"}function Td(e){const t=e.trim();if(!t)return!1;const n=t.toLowerCase();return n==="/new"||n==="/reset"?!0:n.startsWith("/new ")||n.startsWith("/reset ")}async function Go(e){e.connected&&(e.chatMessage="",await Ul(e))}function Ed(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);!s&&!i||(e.chatQueue=[...e.chatQueue,{id:Bs(),text:s,createdAt:Date.now(),attachments:i?n?.map(a=>({...a})):void 0}])}async function Wo(e,t,n){dn(e);const s=await Fl(e,t,n?.attachments);return!s&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!s&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),s&&Ko(e,e.sessionKey),s&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),s&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),un(e),s&&!e.chatRunId&&Vo(e),s&&n?.refreshSessions&&(e.refreshSessionsAfterChat=!0),s}async function Vo(e){if(!e.connected||qo(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await Wo(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function Md(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Ld(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),a=e.chatAttachments??[],o=t==null?a:[],r=o.length>0;if(!i&&!r)return;if(Cd(i)){await Go(e);return}const l=Td(i);if(t==null&&(e.chatMessage="",e.chatAttachments=[]),qo(e)){Ed(e,i,o);return}await Wo(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&n?.restoreDraft),attachments:r?o:void 0,previousAttachments:t==null?a:void 0,restoreAttachments:!!(t&&n?.restoreDraft),refreshSessions:l})}async function Yo(e){await Promise.all([St(e),Ke(e,{activeMinutes:0}),ms(e)]),un(e,!0)}const Id=Vo;function Rd(e){const t=uo(e.sessionKey);return t?.agentId?t.agentId:e.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim()||"main"}function Pd(e,t){const n=cn(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function ms(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Rd(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Pd(e.basePath,t);try{const s=await fetch(n,{method:"GET"});if(!s.ok){e.chatAvatarUrl=null;return}const i=await s.json(),a=typeof i.avatarUrl=="string"?i.avatarUrl.trim():"";e.chatAvatarUrl=a||null}catch{e.chatAvatarUrl=null}}const{I:Nd}=ul,ha=e=>e,Od=e=>e.strings===void 0,fa=()=>document.createComment(""),rt=(e,t,n)=>{const s=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0){const a=s.insertBefore(fa(),i),o=s.insertBefore(fa(),i);n=new Nd(a,o,e,e.options)}else{const a=n._$AB.nextSibling,o=n._$AM,r=o!==e;if(r){let l;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(l=e._$AU)!==o._$AU&&n._$AP(l)}if(a!==i||r){let l=n._$AA;for(;l!==a;){const p=ha(l).nextSibling;ha(s).insertBefore(l,i),l=p}}}return n},Le=(e,t,n=e)=>(e._$AI(t,n),e),Dd={},Bd=(e,t=Dd)=>e._$AH=t,Fd=e=>e._$AH,Vn=e=>{e._$AR(),e._$AA.remove()};const ti={CHILD:2},ni=e=>(...t)=>({_$litDirective$:e,values:t});class si{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,s){this._$Ct=t,this._$AM=n,this._$Ci=s}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}}const yt=(e,t)=>{const n=e._$AN;if(n===void 0)return!1;for(const s of n)s._$AO?.(t,!1),yt(s,t);return!0},en=e=>{let t,n;do{if((t=e._$AM)===void 0)break;n=t._$AN,n.delete(e),e=t}while(n?.size===0)},Qo=e=>{for(let t;t=e._$AM;e=t){let n=t._$AN;if(n===void 0)t._$AN=n=new Set;else if(n.has(e))break;n.add(e),Hd(t)}};function Ud(e){this._$AN!==void 0?(en(this),this._$AM=e,Qo(this)):this._$AM=e}function Kd(e,t=!1,n=0){const s=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(s))for(let a=n;a<s.length;a++)yt(s[a],!1),en(s[a]);else s!=null&&(yt(s,!1),en(s));else yt(this,e)}const Hd=e=>{e.type==ti.CHILD&&(e._$AP??=Kd,e._$AQ??=Ud)};class zd extends si{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,n,s){super._$AT(t,n,s),Qo(this),this.isConnected=t._$AU}_$AO(t,n=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),n&&(yt(this,t),en(this))}setValue(t){if(Od(this._$Ct))this._$Ct._$AI(t,this);else{const n=[...this._$Ct._$AH];n[this._$Ci]=t,this._$Ct._$AI(n,this,0)}}disconnected(){}reconnected(){}}const Yn=new WeakMap,jd=ni(class extends zd{render(e){return f}update(e,[t]){const n=t!==this.G;return n&&this.G!==void 0&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=t,this.ht=e.options?.host,this.rt(this.ct=e.element)),f}rt(e){if(this.isConnected||(e=void 0),typeof this.G=="function"){const t=this.ht??globalThis;let n=Yn.get(t);n===void 0&&(n=new WeakMap,Yn.set(t,n)),n.get(this.G)!==void 0&&this.G.call(this.ht,void 0),n.set(this.G,e),e!==void 0&&this.G.call(this.ht,e)}else this.G.value=e}get lt(){return typeof this.G=="function"?Yn.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});const ga=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s},Zo=ni(class extends si{constructor(e){if(super(e),e.type!==ti.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let s;n===void 0?n=t:t!==void 0&&(s=t);const i=[],a=[];let o=0;for(const r of e)i[o]=s?s(r,o):o,a[o]=n(r,o),o++;return{values:a,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,s]){const i=Fd(e),{values:a,keys:o}=this.dt(t,n,s);if(!Array.isArray(i))return this.ut=o,a;const r=this.ut??=[],l=[];let p,d,u=0,g=i.length-1,v=0,y=a.length-1;for(;u<=g&&v<=y;)if(i[u]===null)u++;else if(i[g]===null)g--;else if(r[u]===o[v])l[v]=Le(i[u],a[v]),u++,v++;else if(r[g]===o[y])l[y]=Le(i[g],a[y]),g--,y--;else if(r[u]===o[y])l[y]=Le(i[u],a[y]),rt(e,l[y+1],i[u]),u++,y--;else if(r[g]===o[v])l[v]=Le(i[g],a[v]),rt(e,i[u],i[g]),g--,v++;else if(p===void 0&&(p=ga(o,v,y),d=ga(r,u,g)),p.has(r[u]))if(p.has(r[g])){const $=d.get(o[v]),A=$!==void 0?i[$]:null;if(A===null){const _=rt(e,i[u]);Le(_,a[v]),l[v]=_}else l[v]=Le(A,a[v]),rt(e,i[u],A),i[$]=null;v++}else Vn(i[g]),g--;else Vn(i[u]),u++;for(;v<=y;){const $=rt(e,l[y+1]);Le($,a[v]),l[v++]=$}for(;u<=g;){const $=i[u++];$!==null&&Vn($)}return this.ut=o,Bd(e,l),ke}});function Jo(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const s=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",i=t.content,a=Array.isArray(i)?i:null,o=Array.isArray(a)&&a.some(u=>{const v=String(u.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),r=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||r)&&(n="toolResult");let l=[];typeof t.content=="string"?l=[{type:"text",text:t.content}]:Array.isArray(t.content)?l=t.content.map(u=>({type:u.type||"text",text:u.text,name:u.name,args:u.args||u.arguments})):typeof t.text=="string"&&(l=[{type:"text",text:t.text}]);const p=typeof t.timestamp=="number"?t.timestamp:Date.now(),d=typeof t.id=="string"?t.id:void 0;return{role:n,content:l,timestamp:p,id:d}}function ii(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 Xo(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}class ys extends si{constructor(t){if(super(t),this.it=f,t.type!==ti.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===f||t==null)return this._t=void 0,this.it=t;if(t===ke)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:[]}}}ys.directiveName="unsafeHTML",ys.resultType=1;const bs=ni(ys);const{entries:er,setPrototypeOf:va,isFrozen:qd,getPrototypeOf:Gd,getOwnPropertyDescriptor:Wd}=Object;let{freeze:Z,seal:ne,create:ws}=Object,{apply:$s,construct:xs}=typeof Reflect<"u"&&Reflect;Z||(Z=function(t){return t});ne||(ne=function(t){return t});$s||($s=function(t,n){for(var s=arguments.length,i=new Array(s>2?s-2:0),a=2;a<s;a++)i[a-2]=arguments[a];return t.apply(n,i)});xs||(xs=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return new t(...s)});const Ht=J(Array.prototype.forEach),Vd=J(Array.prototype.lastIndexOf),ma=J(Array.prototype.pop),lt=J(Array.prototype.push),Yd=J(Array.prototype.splice),Vt=J(String.prototype.toLowerCase),Qn=J(String.prototype.toString),Zn=J(String.prototype.match),ct=J(String.prototype.replace),Qd=J(String.prototype.indexOf),Zd=J(String.prototype.trim),se=J(Object.prototype.hasOwnProperty),Y=J(RegExp.prototype.test),dt=Jd(TypeError);function J(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return $s(e,t,s)}}function Jd(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return xs(e,n)}}function I(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Vt;va&&va(e,null);let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){const a=n(i);a!==i&&(qd(t)||(t[s]=a),i=a)}e[i]=!0}return e}function Xd(e){for(let t=0;t<e.length;t++)se(e,t)||(e[t]=null);return e}function de(e){const t=ws(null);for(const[n,s]of er(e))se(e,n)&&(Array.isArray(s)?t[n]=Xd(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=de(s):t[n]=s);return t}function ut(e,t){for(;e!==null;){const s=Wd(e,t);if(s){if(s.get)return J(s.get);if(typeof s.value=="function")return J(s.value)}e=Gd(e)}function n(){return null}return n}const ya=Z(["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"]),Jn=Z(["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"]),Xn=Z(["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"]),eu=Z(["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"]),es=Z(["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"]),tu=Z(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ba=Z(["#text"]),wa=Z(["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"]),ts=Z(["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"]),$a=Z(["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"]),zt=Z(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),nu=ne(/\{\{[\w\W]*|[\w\W]*\}\}/gm),su=ne(/<%[\w\W]*|[\w\W]*%>/gm),iu=ne(/\$\{[\w\W]*/gm),au=ne(/^data-[\-\w.\u00B7-\uFFFF]+$/),ou=ne(/^aria-[\-\w]+$/),tr=ne(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ru=ne(/^(?:\w+script|data):/i),lu=ne(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),nr=ne(/^html$/i),cu=ne(/^[a-z][.\w]*(-[.\w]+)+$/i);var xa=Object.freeze({__proto__:null,ARIA_ATTR:ou,ATTR_WHITESPACE:lu,CUSTOM_ELEMENT:cu,DATA_ATTR:au,DOCTYPE_NAME:nr,ERB_EXPR:su,IS_ALLOWED_URI:tr,IS_SCRIPT_OR_DATA:ru,MUSTACHE_EXPR:nu,TMPLIT_EXPR:iu});const pt={element:1,text:3,progressingInstruction:7,comment:8,document:9},du=function(){return typeof window>"u"?null:window},uu=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(s=n.getAttribute(i));const a="dompurify"+(s?"#"+s:"");try{return t.createPolicy(a,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Aa=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function sr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:du();const t=C=>sr(C);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==pt.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,i=s.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:r,Element:l,NodeFilter:p,NamedNodeMap:d=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:u,DOMParser:g,trustedTypes:v}=e,y=l.prototype,$=ut(y,"cloneNode"),A=ut(y,"remove"),_=ut(y,"nextSibling"),L=ut(y,"childNodes"),P=ut(y,"parentNode");if(typeof o=="function"){const C=n.createElement("template");C.content&&C.content.ownerDocument&&(n=C.content.ownerDocument)}let M,T="";const{implementation:E,createNodeIterator:pe,createDocumentFragment:xn,getElementsByTagName:An}=n,{importNode:Ir}=s;let V=Aa();t.isSupported=typeof er=="function"&&typeof P=="function"&&E&&E.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:kn,ERB_EXPR:Sn,TMPLIT_EXPR:_n,DATA_ATTR:Rr,ARIA_ATTR:Pr,IS_SCRIPT_OR_DATA:Nr,ATTR_WHITESPACE:vi,CUSTOM_ELEMENT:Or}=xa;let{IS_ALLOWED_URI:mi}=xa,K=null;const yi=I({},[...ya,...Jn,...Xn,...es,...ba]);let z=null;const bi=I({},[...wa,...ts,...$a,...zt]);let B=Object.seal(ws(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}})),st=null,Cn=null;const ze=Object.seal(ws(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let wi=!0,Tn=!0,$i=!1,xi=!0,je=!1,Lt=!0,Te=!1,En=!1,Mn=!1,qe=!1,It=!1,Rt=!1,Ai=!0,ki=!1;const Dr="user-content-";let Ln=!0,it=!1,Ge={},re=null;const In=I({},["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 Si=null;const _i=I({},["audio","video","img","source","image","track"]);let Rn=null;const Ci=I({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Pt="http://www.w3.org/1998/Math/MathML",Nt="http://www.w3.org/2000/svg",he="http://www.w3.org/1999/xhtml";let We=he,Pn=!1,Nn=null;const Br=I({},[Pt,Nt,he],Qn);let Ot=I({},["mi","mo","mn","ms","mtext"]),Dt=I({},["annotation-xml"]);const Fr=I({},["title","style","font","a","script"]);let at=null;const Ur=["application/xhtml+xml","text/html"],Kr="text/html";let U=null,Ve=null;const Hr=n.createElement("form"),Ti=function(h){return h instanceof RegExp||h instanceof Function},On=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ve&&Ve===h)){if((!h||typeof h!="object")&&(h={}),h=de(h),at=Ur.indexOf(h.PARSER_MEDIA_TYPE)===-1?Kr:h.PARSER_MEDIA_TYPE,U=at==="application/xhtml+xml"?Qn:Vt,K=se(h,"ALLOWED_TAGS")?I({},h.ALLOWED_TAGS,U):yi,z=se(h,"ALLOWED_ATTR")?I({},h.ALLOWED_ATTR,U):bi,Nn=se(h,"ALLOWED_NAMESPACES")?I({},h.ALLOWED_NAMESPACES,Qn):Br,Rn=se(h,"ADD_URI_SAFE_ATTR")?I(de(Ci),h.ADD_URI_SAFE_ATTR,U):Ci,Si=se(h,"ADD_DATA_URI_TAGS")?I(de(_i),h.ADD_DATA_URI_TAGS,U):_i,re=se(h,"FORBID_CONTENTS")?I({},h.FORBID_CONTENTS,U):In,st=se(h,"FORBID_TAGS")?I({},h.FORBID_TAGS,U):de({}),Cn=se(h,"FORBID_ATTR")?I({},h.FORBID_ATTR,U):de({}),Ge=se(h,"USE_PROFILES")?h.USE_PROFILES:!1,wi=h.ALLOW_ARIA_ATTR!==!1,Tn=h.ALLOW_DATA_ATTR!==!1,$i=h.ALLOW_UNKNOWN_PROTOCOLS||!1,xi=h.ALLOW_SELF_CLOSE_IN_ATTR!==!1,je=h.SAFE_FOR_TEMPLATES||!1,Lt=h.SAFE_FOR_XML!==!1,Te=h.WHOLE_DOCUMENT||!1,qe=h.RETURN_DOM||!1,It=h.RETURN_DOM_FRAGMENT||!1,Rt=h.RETURN_TRUSTED_TYPE||!1,Mn=h.FORCE_BODY||!1,Ai=h.SANITIZE_DOM!==!1,ki=h.SANITIZE_NAMED_PROPS||!1,Ln=h.KEEP_CONTENT!==!1,it=h.IN_PLACE||!1,mi=h.ALLOWED_URI_REGEXP||tr,We=h.NAMESPACE||he,Ot=h.MATHML_TEXT_INTEGRATION_POINTS||Ot,Dt=h.HTML_INTEGRATION_POINTS||Dt,B=h.CUSTOM_ELEMENT_HANDLING||{},h.CUSTOM_ELEMENT_HANDLING&&Ti(h.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(B.tagNameCheck=h.CUSTOM_ELEMENT_HANDLING.tagNameCheck),h.CUSTOM_ELEMENT_HANDLING&&Ti(h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(B.attributeNameCheck=h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),h.CUSTOM_ELEMENT_HANDLING&&typeof h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(B.allowCustomizedBuiltInElements=h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),je&&(Tn=!1),It&&(qe=!0),Ge&&(K=I({},ba),z=[],Ge.html===!0&&(I(K,ya),I(z,wa)),Ge.svg===!0&&(I(K,Jn),I(z,ts),I(z,zt)),Ge.svgFilters===!0&&(I(K,Xn),I(z,ts),I(z,zt)),Ge.mathMl===!0&&(I(K,es),I(z,$a),I(z,zt))),h.ADD_TAGS&&(typeof h.ADD_TAGS=="function"?ze.tagCheck=h.ADD_TAGS:(K===yi&&(K=de(K)),I(K,h.ADD_TAGS,U))),h.ADD_ATTR&&(typeof h.ADD_ATTR=="function"?ze.attributeCheck=h.ADD_ATTR:(z===bi&&(z=de(z)),I(z,h.ADD_ATTR,U))),h.ADD_URI_SAFE_ATTR&&I(Rn,h.ADD_URI_SAFE_ATTR,U),h.FORBID_CONTENTS&&(re===In&&(re=de(re)),I(re,h.FORBID_CONTENTS,U)),h.ADD_FORBID_CONTENTS&&(re===In&&(re=de(re)),I(re,h.ADD_FORBID_CONTENTS,U)),Ln&&(K["#text"]=!0),Te&&I(K,["html","head","body"]),K.table&&(I(K,["tbody"]),delete st.tbody),h.TRUSTED_TYPES_POLICY){if(typeof h.TRUSTED_TYPES_POLICY.createHTML!="function")throw dt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof h.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw dt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');M=h.TRUSTED_TYPES_POLICY,T=M.createHTML("")}else M===void 0&&(M=uu(v,i)),M!==null&&typeof T=="string"&&(T=M.createHTML(""));Z&&Z(h),Ve=h}},Ei=I({},[...Jn,...Xn,...eu]),Mi=I({},[...es,...tu]),zr=function(h){let x=P(h);(!x||!x.tagName)&&(x={namespaceURI:We,tagName:"template"});const S=Vt(h.tagName),D=Vt(x.tagName);return Nn[h.namespaceURI]?h.namespaceURI===Nt?x.namespaceURI===he?S==="svg":x.namespaceURI===Pt?S==="svg"&&(D==="annotation-xml"||Ot[D]):!!Ei[S]:h.namespaceURI===Pt?x.namespaceURI===he?S==="math":x.namespaceURI===Nt?S==="math"&&Dt[D]:!!Mi[S]:h.namespaceURI===he?x.namespaceURI===Nt&&!Dt[D]||x.namespaceURI===Pt&&!Ot[D]?!1:!Mi[S]&&(Fr[S]||!Ei[S]):!!(at==="application/xhtml+xml"&&Nn[h.namespaceURI]):!1},le=function(h){lt(t.removed,{element:h});try{P(h).removeChild(h)}catch{A(h)}},Ee=function(h,x){try{lt(t.removed,{attribute:x.getAttributeNode(h),from:x})}catch{lt(t.removed,{attribute:null,from:x})}if(x.removeAttribute(h),h==="is")if(qe||It)try{le(x)}catch{}else try{x.setAttribute(h,"")}catch{}},Li=function(h){let x=null,S=null;if(Mn)h="<remove></remove>"+h;else{const F=Zn(h,/^[\r\n\t ]+/);S=F&&F[0]}at==="application/xhtml+xml"&&We===he&&(h='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+h+"</body></html>");const D=M?M.createHTML(h):h;if(We===he)try{x=new g().parseFromString(D,at)}catch{}if(!x||!x.documentElement){x=E.createDocument(We,"template",null);try{x.documentElement.innerHTML=Pn?T:D}catch{}}const q=x.body||x.documentElement;return h&&S&&q.insertBefore(n.createTextNode(S),q.childNodes[0]||null),We===he?An.call(x,Te?"html":"body")[0]:Te?x.documentElement:q},Ii=function(h){return pe.call(h.ownerDocument||h,h,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Dn=function(h){return h instanceof u&&(typeof h.nodeName!="string"||typeof h.textContent!="string"||typeof h.removeChild!="function"||!(h.attributes instanceof d)||typeof h.removeAttribute!="function"||typeof h.setAttribute!="function"||typeof h.namespaceURI!="string"||typeof h.insertBefore!="function"||typeof h.hasChildNodes!="function")},Ri=function(h){return typeof r=="function"&&h instanceof r};function fe(C,h,x){Ht(C,S=>{S.call(t,h,x,Ve)})}const Pi=function(h){let x=null;if(fe(V.beforeSanitizeElements,h,null),Dn(h))return le(h),!0;const S=U(h.nodeName);if(fe(V.uponSanitizeElement,h,{tagName:S,allowedTags:K}),Lt&&h.hasChildNodes()&&!Ri(h.firstElementChild)&&Y(/<[/\w!]/g,h.innerHTML)&&Y(/<[/\w!]/g,h.textContent)||h.nodeType===pt.progressingInstruction||Lt&&h.nodeType===pt.comment&&Y(/<[/\w]/g,h.data))return le(h),!0;if(!(ze.tagCheck instanceof Function&&ze.tagCheck(S))&&(!K[S]||st[S])){if(!st[S]&&Oi(S)&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,S)||B.tagNameCheck instanceof Function&&B.tagNameCheck(S)))return!1;if(Ln&&!re[S]){const D=P(h)||h.parentNode,q=L(h)||h.childNodes;if(q&&D){const F=q.length;for(let X=F-1;X>=0;--X){const ge=$(q[X],!0);ge.__removalCount=(h.__removalCount||0)+1,D.insertBefore(ge,_(h))}}}return le(h),!0}return h instanceof l&&!zr(h)||(S==="noscript"||S==="noembed"||S==="noframes")&&Y(/<\/no(script|embed|frames)/i,h.innerHTML)?(le(h),!0):(je&&h.nodeType===pt.text&&(x=h.textContent,Ht([kn,Sn,_n],D=>{x=ct(x,D," ")}),h.textContent!==x&&(lt(t.removed,{element:h.cloneNode()}),h.textContent=x)),fe(V.afterSanitizeElements,h,null),!1)},Ni=function(h,x,S){if(Ai&&(x==="id"||x==="name")&&(S in n||S in Hr))return!1;if(!(Tn&&!Cn[x]&&Y(Rr,x))){if(!(wi&&Y(Pr,x))){if(!(ze.attributeCheck instanceof Function&&ze.attributeCheck(x,h))){if(!z[x]||Cn[x]){if(!(Oi(h)&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,h)||B.tagNameCheck instanceof Function&&B.tagNameCheck(h))&&(B.attributeNameCheck instanceof RegExp&&Y(B.attributeNameCheck,x)||B.attributeNameCheck instanceof Function&&B.attributeNameCheck(x,h))||x==="is"&&B.allowCustomizedBuiltInElements&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,S)||B.tagNameCheck instanceof Function&&B.tagNameCheck(S))))return!1}else if(!Rn[x]){if(!Y(mi,ct(S,vi,""))){if(!((x==="src"||x==="xlink:href"||x==="href")&&h!=="script"&&Qd(S,"data:")===0&&Si[h])){if(!($i&&!Y(Nr,ct(S,vi,"")))){if(S)return!1}}}}}}}return!0},Oi=function(h){return h!=="annotation-xml"&&Zn(h,Or)},Di=function(h){fe(V.beforeSanitizeAttributes,h,null);const{attributes:x}=h;if(!x||Dn(h))return;const S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:z,forceKeepAttr:void 0};let D=x.length;for(;D--;){const q=x[D],{name:F,namespaceURI:X,value:ge}=q,Ye=U(F),Bn=ge;let j=F==="value"?Bn:Zd(Bn);if(S.attrName=Ye,S.attrValue=j,S.keepAttr=!0,S.forceKeepAttr=void 0,fe(V.uponSanitizeAttribute,h,S),j=S.attrValue,ki&&(Ye==="id"||Ye==="name")&&(Ee(F,h),j=Dr+j),Lt&&Y(/((--!?|])>)|<\/(style|title|textarea)/i,j)){Ee(F,h);continue}if(Ye==="attributename"&&Zn(j,"href")){Ee(F,h);continue}if(S.forceKeepAttr)continue;if(!S.keepAttr){Ee(F,h);continue}if(!xi&&Y(/\/>/i,j)){Ee(F,h);continue}je&&Ht([kn,Sn,_n],Fi=>{j=ct(j,Fi," ")});const Bi=U(h.nodeName);if(!Ni(Bi,Ye,j)){Ee(F,h);continue}if(M&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!X)switch(v.getAttributeType(Bi,Ye)){case"TrustedHTML":{j=M.createHTML(j);break}case"TrustedScriptURL":{j=M.createScriptURL(j);break}}if(j!==Bn)try{X?h.setAttributeNS(X,F,j):h.setAttribute(F,j),Dn(h)?le(h):ma(t.removed)}catch{Ee(F,h)}}fe(V.afterSanitizeAttributes,h,null)},jr=function C(h){let x=null;const S=Ii(h);for(fe(V.beforeSanitizeShadowDOM,h,null);x=S.nextNode();)fe(V.uponSanitizeShadowNode,x,null),Pi(x),Di(x),x.content instanceof a&&C(x.content);fe(V.afterSanitizeShadowDOM,h,null)};return t.sanitize=function(C){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,S=null,D=null,q=null;if(Pn=!C,Pn&&(C="<!-->"),typeof C!="string"&&!Ri(C))if(typeof C.toString=="function"){if(C=C.toString(),typeof C!="string")throw dt("dirty is not a string, aborting")}else throw dt("toString is not a function");if(!t.isSupported)return C;if(En||On(h),t.removed=[],typeof C=="string"&&(it=!1),it){if(C.nodeName){const ge=U(C.nodeName);if(!K[ge]||st[ge])throw dt("root node is forbidden and cannot be sanitized in-place")}}else if(C instanceof r)x=Li("<!---->"),S=x.ownerDocument.importNode(C,!0),S.nodeType===pt.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?x=S:x.appendChild(S);else{if(!qe&&!je&&!Te&&C.indexOf("<")===-1)return M&&Rt?M.createHTML(C):C;if(x=Li(C),!x)return qe?null:Rt?T:""}x&&Mn&&le(x.firstChild);const F=Ii(it?C:x);for(;D=F.nextNode();)Pi(D),Di(D),D.content instanceof a&&jr(D.content);if(it)return C;if(qe){if(It)for(q=xn.call(x.ownerDocument);x.firstChild;)q.appendChild(x.firstChild);else q=x;return(z.shadowroot||z.shadowrootmode)&&(q=Ir.call(s,q,!0)),q}let X=Te?x.outerHTML:x.innerHTML;return Te&&K["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&Y(nr,x.ownerDocument.doctype.name)&&(X="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
|
|
17
|
+
`+X),je&&Ht([kn,Sn,_n],ge=>{X=ct(X,ge," ")}),M&&Rt?M.createHTML(X):X},t.setConfig=function(){let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};On(C),En=!0},t.clearConfig=function(){Ve=null,En=!1},t.isValidAttribute=function(C,h,x){Ve||On({});const S=U(C),D=U(h);return Ni(S,D,x)},t.addHook=function(C,h){typeof h=="function"&<(V[C],h)},t.removeHook=function(C,h){if(h!==void 0){const x=Vd(V[C],h);return x===-1?void 0:Yd(V[C],x,1)[0]}return ma(V[C])},t.removeHooks=function(C){V[C]=[]},t.removeAllHooks=function(){V=Aa()},t}var As=sr();function ai(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var He=ai();function ir(e){He=e}var bt={exec:()=>null};function R(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(i,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(Q.caret,"$1"),n=n.replace(i,o),s},getRegex:()=>new RegExp(n,t)};return s}var pu=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Q={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")},hu=/^(?:[ \t]*(?:\n|$))+/,fu=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,gu=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Mt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,vu=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,oi=/(?:[*+-]|\d{1,9}[.)])/,ar=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,or=R(ar).replace(/bull/g,oi).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(),mu=R(ar).replace(/bull/g,oi).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(),ri=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,yu=/^[^\n]+/,li=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,bu=R(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",li).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),wu=R(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,oi).getRegex(),yn="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",ci=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$u=R("^ {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",ci).replace("tag",yn).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),rr=R(ri).replace("hr",Mt).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",yn).getRegex(),xu=R(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",rr).getRegex(),di={blockquote:xu,code:fu,def:bu,fences:gu,heading:vu,hr:Mt,html:$u,lheading:or,list:wu,newline:hu,paragraph:rr,table:bt,text:yu},ka=R("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Mt).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",yn).getRegex(),Au={...di,lheading:mu,table:ka,paragraph:R(ri).replace("hr",Mt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ka).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",yn).getRegex()},ku={...di,html:R(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ci).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:bt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:R(ri).replace("hr",Mt).replace("heading",` *#{1,6} *[^
|
|
18
|
+
]`).replace("lheading",or).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Su=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,_u=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,lr=/^( {2,}|\\)\n(?!\s*$)/,Cu=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,bn=/[\p{P}\p{S}]/u,ui=/[\s\p{P}\p{S}]/u,cr=/[^\s\p{P}\p{S}]/u,Tu=R(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ui).getRegex(),dr=/(?!~)[\p{P}\p{S}]/u,Eu=/(?!~)[\s\p{P}\p{S}]/u,Mu=/(?:[^\s\p{P}\p{S}]|~)/u,Lu=R(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",pu?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ur=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Iu=R(ur,"u").replace(/punct/g,bn).getRegex(),Ru=R(ur,"u").replace(/punct/g,dr).getRegex(),pr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Pu=R(pr,"gu").replace(/notPunctSpace/g,cr).replace(/punctSpace/g,ui).replace(/punct/g,bn).getRegex(),Nu=R(pr,"gu").replace(/notPunctSpace/g,Mu).replace(/punctSpace/g,Eu).replace(/punct/g,dr).getRegex(),Ou=R("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,cr).replace(/punctSpace/g,ui).replace(/punct/g,bn).getRegex(),Du=R(/\\(punct)/,"gu").replace(/punct/g,bn).getRegex(),Bu=R(/^<(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(),Fu=R(ci).replace("(?:-->|$)","-->").getRegex(),Uu=R("^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",Fu).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),tn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Ku=R(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",tn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),hr=R(/^!?\[(label)\]\[(ref)\]/).replace("label",tn).replace("ref",li).getRegex(),fr=R(/^!?\[(ref)\](?:\[\])?/).replace("ref",li).getRegex(),Hu=R("reflink|nolink(?!\\()","g").replace("reflink",hr).replace("nolink",fr).getRegex(),Sa=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,pi={_backpedal:bt,anyPunctuation:Du,autolink:Bu,blockSkip:Lu,br:lr,code:_u,del:bt,emStrongLDelim:Iu,emStrongRDelimAst:Pu,emStrongRDelimUnd:Ou,escape:Su,link:Ku,nolink:fr,punctuation:Tu,reflink:hr,reflinkSearch:Hu,tag:Uu,text:Cu,url:bt},zu={...pi,link:R(/^!?\[(label)\]\((.*?)\)/).replace("label",tn).getRegex(),reflink:R(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",tn).getRegex()},ks={...pi,emStrongRDelimAst:Nu,emStrongLDelim:Ru,url:R(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Sa).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:R(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Sa).getRegex()},ju={...ks,br:R(lr).replace("{2,}","*").getRegex(),text:R(ks.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},jt={normal:di,gfm:Au,pedantic:ku},ht={normal:pi,gfm:ks,breaks:ju,pedantic:zu},qu={"&":"&","<":"<",">":">",'"':""","'":"'"},_a=e=>qu[e];function me(e,t){if(t){if(Q.escapeTest.test(e))return e.replace(Q.escapeReplace,_a)}else if(Q.escapeTestNoEncode.test(e))return e.replace(Q.escapeReplaceNoEncode,_a);return e}function Ca(e){try{e=encodeURI(e).replace(Q.percentDecode,"%")}catch{return null}return e}function Ta(e,t){let n=e.replace(Q.findPipe,(a,o,r)=>{let l=!1,p=o;for(;--p>=0&&r[p]==="\\";)l=!l;return l?"|":" |"}),s=n.split(Q.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(Q.slashPipe,"|");return s}function ft(e,t,n){let s=e.length;if(s===0)return"";let i=0;for(;i<s&&e.charAt(s-i-1)===t;)i++;return e.slice(0,s-i)}function Gu(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function Ea(e,t,n,s,i){let a=t.href,o=t.title||null,r=e[1].replace(i.other.outputLinkReplace,"$1");s.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:a,title:o,text:r,tokens:s.inlineTokens(r)};return s.state.inLink=!1,l}function Wu(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let i=s[1];return t.split(`
|
|
19
19
|
`).map(a=>{let o=a.match(n.other.beginningSpace);if(o===null)return a;let[r]=o;return r.length>=i.length?a.slice(i.length):a}).join(`
|
|
20
|
-
`)}var
|
|
21
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=
|
|
22
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=
|
|
20
|
+
`)}var nn=class{options;rules;lexer;constructor(e){this.options=e||He}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:ft(n,`
|
|
21
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=Wu(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=ft(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ft(t[0],`
|
|
22
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=ft(t[0],`
|
|
23
23
|
`).split(`
|
|
24
24
|
`),s="",i="",a=[];for(;n.length>0;){let o=!1,r=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))r.push(n[l]),o=!0;else if(!o)r.push(n[l]);else break;n=n.slice(l);let p=r.join(`
|
|
25
25
|
`),d=p.replace(this.rules.other.blockquoteSetextReplace,`
|
|
26
26
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
27
27
|
${p}`:p,i=i?`${i}
|
|
28
|
-
${d}`:d;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,a,!0),this.lexer.state.top=u,n.length===0)break;let g=a.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let v=g,
|
|
28
|
+
${d}`:d;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,a,!0),this.lexer.state.top=u,n.length===0)break;let g=a.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let v=g,y=v.raw+`
|
|
29
29
|
`+n.join(`
|
|
30
|
-
`),$=this.blockquote(
|
|
30
|
+
`),$=this.blockquote(y);a[a.length-1]=$,s=s.substring(0,s.length-v.raw.length)+$.raw,i=i.substring(0,i.length-v.text.length)+$.text;break}else if(g?.type==="list"){let v=g,y=v.raw+`
|
|
31
31
|
`+n.join(`
|
|
32
|
-
`),$=this.list(
|
|
33
|
-
`);continue}}return{type:"blockquote",raw:s,tokens:a,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),s=n.length>1,i={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let l=!1,p="",d="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let u=
|
|
34
|
-
`,1)[0]
|
|
35
|
-
`,1)[0],v=!u.trim(),
|
|
36
|
-
`,e=e.substring(g.length+1),l=!0),!l){let $=this.rules.other.nextBulletRegex(
|
|
37
|
-
`,1)[0],
|
|
38
|
-
`+
|
|
39
|
-
`+g}v
|
|
40
|
-
`,e=e.substring(
|
|
32
|
+
`),$=this.list(y);a[a.length-1]=$,s=s.substring(0,s.length-g.raw.length)+$.raw,i=i.substring(0,i.length-v.raw.length)+$.raw,n=y.substring(a.at(-1).raw.length).split(`
|
|
33
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:a,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),s=n.length>1,i={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let l=!1,p="",d="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let u=t[2].split(`
|
|
34
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,$=>" ".repeat(3*$.length)),g=e.split(`
|
|
35
|
+
`,1)[0],v=!u.trim(),y=0;if(this.options.pedantic?(y=2,d=u.trimStart()):v?y=t[1].length+1:(y=t[2].search(this.rules.other.nonSpaceChar),y=y>4?1:y,d=u.slice(y),y+=t[1].length),v&&this.rules.other.blankLine.test(g)&&(p+=g+`
|
|
36
|
+
`,e=e.substring(g.length+1),l=!0),!l){let $=this.rules.other.nextBulletRegex(y),A=this.rules.other.hrRegex(y),_=this.rules.other.fencesBeginRegex(y),L=this.rules.other.headingBeginRegex(y),P=this.rules.other.htmlBeginRegex(y);for(;e;){let M=e.split(`
|
|
37
|
+
`,1)[0],T;if(g=M,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),T=g):T=g.replace(this.rules.other.tabCharGlobal," "),_.test(g)||L.test(g)||P.test(g)||$.test(g)||A.test(g))break;if(T.search(this.rules.other.nonSpaceChar)>=y||!g.trim())d+=`
|
|
38
|
+
`+T.slice(y);else{if(v||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_.test(u)||L.test(u)||A.test(u))break;d+=`
|
|
39
|
+
`+g}!v&&!g.trim()&&(v=!0),p+=M+`
|
|
40
|
+
`,e=e.substring(M.length+1),u=T.slice(y)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(o=!0)),i.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),i.raw+=p}let r=i.items.at(-1);if(r)r.raw=r.raw.trimEnd(),r.text=r.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l of i.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),l.tokens[0]?.type==="text"||l.tokens[0]?.type==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(l.raw);if(p){let d={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};l.checked=d.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=d.raw+l.tokens[0].raw,l.tokens[0].text=d.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(d)):l.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):l.tokens.unshift(d)}}if(!i.loose){let p=l.tokens.filter(u=>u.type==="space"),d=p.length>0&&p.some(u=>this.rules.other.anyLine.test(u.raw));i.loose=d}}if(i.loose)for(let l of i.items){l.loose=!0;for(let p of l.tokens)p.type==="text"&&(p.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Ta(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
41
41
|
`):[],a={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let o of s)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<n.length;o++)a.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:a.align[o]});for(let o of i)a.rows.push(Ta(o,a.header.length).map((r,l)=>({text:r,tokens:this.lexer.inline(r),header:!1,align:a.align[l]})));return a}}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)===`
|
|
42
|
-
`?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 a=
|
|
42
|
+
`?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 a=ft(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{let a=Gu(t[2],"()");if(a===-2)return;if(a>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(s);a&&(s=a[1],i=a[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),Ea(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[s.toLowerCase()];if(!i){let a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return Ea(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||s[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...s[0]].length-1,a,o,r=i,l=0,p=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,t=t.slice(-1*e.length+i);(s=p.exec(t))!=null;){if(a=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!a)continue;if(o=[...a].length,s[3]||s[4]){r+=o;continue}else if((s[5]||s[6])&&i%3&&!((i+o)%3)){l+=o;continue}if(r-=o,r>0)continue;o=Math.min(o,o+r+l);let d=[...s[0]][0].length,u=e.slice(0,i+s.index+d+o);if(Math.min(i,o)%2){let v=u.slice(1,-1);return{type:"em",raw:u,text:v,tokens:this.lexer.inlineTokens(v)}}let g=u.slice(2,-2);return{type:"strong",raw:u,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=t[0],s="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}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}}}},ie=class Ss{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||He,this.options.tokenizer=this.options.tokenizer||new nn,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:Q,block:jt.normal,inline:ht.normal};this.options.pedantic?(n.block=jt.pedantic,n.inline=ht.pedantic):this.options.gfm&&(n.block=jt.gfm,this.options.breaks?n.inline=ht.breaks:n.inline=ht.gfm),this.tokenizer.rules=n}static get rules(){return{block:jt,inline:ht}}static lex(t,n){return new Ss(n).lex(t)}static lexInline(t,n){return new Ss(n).inlineTokens(t)}lex(t){t=t.replace(Q.carriageReturn,`
|
|
43
43
|
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],s=!1){for(this.options.pedantic&&(t=t.replace(Q.tabCharGlobal," ").replace(Q.spaceLine,""));t;){let i;if(this.options.extensions?.block?.some(o=>(i=o.call({lexer:this},t,n))?(t=t.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(t)){t=t.substring(i.raw.length);let o=n.at(-1);i.raw.length===1&&o!==void 0?o.raw+=`
|
|
44
44
|
`:n.push(i);continue}if(i=this.tokenizer.code(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
45
45
|
`)?"":`
|
|
@@ -53,9 +53,9 @@ ${d}`:d;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
53
53
|
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i),s=a.length!==t.length,t=t.substring(i.raw.length);continue}if(i=this.tokenizer.text(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
54
54
|
`)?"":`
|
|
55
55
|
`)+i.raw,o.text+=`
|
|
56
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(t){let o="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let s=t,i=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)l.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,i.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let a;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)a=i[2]?i[2].length:0,s=s.slice(0,i.index+a)+"["+"a".repeat(i[0].length-a-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let o=!1,r="";for(;t;){o||(r=""),o=!1;let l;if(this.options.extensions?.inline?.some(d=>(l=d.call({lexer:this},t,n))?(t=t.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(l.raw.length);let d=n.at(-1);l.type==="text"&&d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(t,s,r)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(t
|
|
57
|
-
`;return s?'<pre><code class="language-'+
|
|
58
|
-
`:"<pre><code>"+(n?i:
|
|
56
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(t){let o="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let s=t,i=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)l.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,i.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let a;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)a=i[2]?i[2].length:0,s=s.slice(0,i.index+a)+"["+"a".repeat(i[0].length-a-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let o=!1,r="";for(;t;){o||(r=""),o=!1;let l;if(this.options.extensions?.inline?.some(d=>(l=d.call({lexer:this},t,n))?(t=t.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(l.raw.length);let d=n.at(-1);l.type==="text"&&d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(t,s,r)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(t)){t=t.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(t))){t=t.substring(l.raw.length),n.push(l);continue}let p=t;if(this.options.extensions?.startInline){let d=1/0,u=t.slice(1),g;this.options.extensions.startInline.forEach(v=>{g=v.call({lexer:this},u),typeof g=="number"&&g>=0&&(d=Math.min(d,g))}),d<1/0&&d>=0&&(p=t.substring(0,d+1))}if(l=this.tokenizer.inlineText(p)){t=t.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(r=l.raw.slice(-1)),o=!0;let d=n.at(-1);d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):n.push(l);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 n}},sn=class{options;parser;constructor(e){this.options=e||He}space(e){return""}code({text:e,lang:t,escaped:n}){let s=(t||"").match(Q.notSpaceStart)?.[0],i=e.replace(Q.endingNewline,"")+`
|
|
57
|
+
`;return s?'<pre><code class="language-'+me(s)+'">'+(n?i:me(i,!0))+`</code></pre>
|
|
58
|
+
`:"<pre><code>"+(n?i:me(i,!0))+`</code></pre>
|
|
59
59
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
60
60
|
${this.parser.parse(e)}</blockquote>
|
|
61
61
|
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
@@ -71,29 +71,29 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
71
71
|
`}tablerow({text:e}){return`<tr>
|
|
72
72
|
${e}</tr>
|
|
73
73
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
74
|
-
`}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>${
|
|
75
|
-
Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+
|
|
74
|
+
`}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>${me(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),i=Ca(e);if(i===null)return s;e=i;let a='<a href="'+e+'"';return t&&(a+=' title="'+me(t)+'"'),a+=">"+s+"</a>",a}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let i=Ca(e);if(i===null)return me(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${me(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:me(e.text)}},hi=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}},ae=class _s{options;renderer;textRenderer;constructor(t){this.options=t||He,this.options.renderer=this.options.renderer||new sn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new hi}static parse(t,n){return new _s(n).parse(t)}static parseInline(t,n){return new _s(n).parseInline(t)}parse(t){let n="";for(let s=0;s<t.length;s++){let i=t[s];if(this.options.extensions?.renderers?.[i.type]){let o=i,r=this.options.extensions.renderers[o.type].call({parser:this},o);if(r!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=r||"";continue}}let a=i;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,n=this.renderer){let s="";for(let i=0;i<t.length;i++){let a=t[i];if(this.options.extensions?.renderers?.[a.type]){let r=this.options.extensions.renderers[a.type].call({parser:this},a);if(r!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=r||"";continue}}let o=a;switch(o.type){case"escape":{s+=n.text(o);break}case"html":{s+=n.html(o);break}case"link":{s+=n.link(o);break}case"image":{s+=n.image(o);break}case"checkbox":{s+=n.checkbox(o);break}case"strong":{s+=n.strong(o);break}case"em":{s+=n.em(o);break}case"codespan":{s+=n.codespan(o);break}case"br":{s+=n.br(o);break}case"del":{s+=n.del(o);break}case"text":{s+=n.text(o);break}default:{let r='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(r),"";throw new Error(r)}}}return s}},gt=class{options;block;constructor(e){this.options=e||He}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ie.lex:ie.lexInline}provideParser(){return this.block?ae.parse:ae.parseInline}},Vu=class{defaults=ai();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ae;Renderer=sn;TextRenderer=hi;Lexer=ie;Tokenizer=nn;Hooks=gt;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let i=s;for(let a of i.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of i.rows)for(let o of a)n=n.concat(this.walkTokens(o.tokens,t));break}case"list":{let i=s;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=s;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(a=>{let o=i[a].flat(1/0);n=n.concat(this.walkTokens(o,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let a=t.renderers[i.name];a?t.renderers[i.name]=function(...o){let r=i.renderer.apply(this,o);return r===!1&&(r=a.apply(this,o)),r}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=t[i.level];a?a.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),s.extensions=t),n.renderer){let i=this.defaults.renderer||new sn(this.defaults);for(let a in n.renderer){if(!(a in i))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,r=n.renderer[o],l=i[o];i[o]=(...p)=>{let d=r.apply(i,p);return d===!1&&(d=l.apply(i,p)),d||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new nn(this.defaults);for(let a in n.tokenizer){if(!(a in i))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,r=n.tokenizer[o],l=i[o];i[o]=(...p)=>{let d=r.apply(i,p);return d===!1&&(d=l.apply(i,p)),d}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new gt;for(let a in n.hooks){if(!(a in i))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,r=n.hooks[o],l=i[o];gt.passThroughHooks.has(a)?i[o]=p=>{if(this.defaults.async&>.passThroughHooksRespectAsync.has(a))return(async()=>{let u=await r.call(i,p);return l.call(i,u)})();let d=r.call(i,p);return l.call(i,d)}:i[o]=(...p)=>{if(this.defaults.async)return(async()=>{let u=await r.apply(i,p);return u===!1&&(u=await l.apply(i,p)),u})();let d=r.apply(i,p);return d===!1&&(d=l.apply(i,p)),d}}s.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,a=n.walkTokens;s.walkTokens=function(o){let r=[];return r.push(a.call(this,o)),i&&(r=r.concat(i.call(this,o))),r}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ie.lex(e,t??this.defaults)}parser(e,t){return ae.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},i={...this.defaults,...s},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&s.async===!1)return a(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 a(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?ie.lex:ie.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let p=await(i.hooks?await i.hooks.provideParser():e?ae.parse:ae.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(p):p})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():e?ie.lex:ie.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?ae.parse:ae.parseInline)(o,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(o){return a(o)}}}onError(e,t){return n=>{if(n.message+=`
|
|
75
|
+
Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+me(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},Ue=new Vu;function N(e,t){return Ue.parse(e,t)}N.options=N.setOptions=function(e){return Ue.setOptions(e),N.defaults=Ue.defaults,ir(N.defaults),N};N.getDefaults=ai;N.defaults=He;N.use=function(...e){return Ue.use(...e),N.defaults=Ue.defaults,ir(N.defaults),N};N.walkTokens=function(e,t){return Ue.walkTokens(e,t)};N.parseInline=Ue.parseInline;N.Parser=ae;N.parser=ae.parse;N.Renderer=sn;N.TextRenderer=hi;N.Lexer=ie;N.lexer=ie.lex;N.Tokenizer=nn;N.Hooks=gt;N.parse=N;N.options;N.setOptions;N.use;N.walkTokens;N.parseInline;ae.parse;ie.lex;N.setOptions({gfm:!0,breaks:!0,mangle:!1});const Ma=["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"],La=["class","href","rel","target","title","start"];let Ia=!1;const Yu=14e4,Qu=4e4,Zu=200,ns=5e4,Ne=new Map;function Ju(e){const t=Ne.get(e);return t===void 0?null:(Ne.delete(e),Ne.set(e,t),t)}function Ra(e,t){if(Ne.set(e,t),Ne.size<=Zu)return;const n=Ne.keys().next().value;n&&Ne.delete(n)}function Xu(){Ia||(Ia=!0,As.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Cs(e){const t=e.trim();if(!t)return"";if(Xu(),t.length<=ns){const o=Ju(t);if(o!==null)return o}const n=vo(t,Yu),s=n.truncated?`
|
|
76
76
|
|
|
77
|
-
… truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>
|
|
77
|
+
… truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Qu){const r=`<pre class="code-block">${ep(`${n.text}${s}`)}</pre>`,l=As.sanitize(r,{ALLOWED_TAGS:Ma,ALLOWED_ATTR:La});return t.length<=ns&&Ra(t,l),l}const i=N.parse(`${n.text}${s}`),a=As.sanitize(i,{ALLOWED_TAGS:Ma,ALLOWED_ATTR:La});return t.length<=ns&&Ra(t,a),a}function ep(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const tp=1500,np=2e3,gr="Copy as markdown",sp="Copied",ip="Copy failed";async function ap(e){if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function qt(e,t){e.title=t,e.setAttribute("aria-label",t)}function op(e){const t=e.label??gr;return c`
|
|
78
78
|
<button
|
|
79
79
|
class="chat-copy-btn"
|
|
80
80
|
type="button"
|
|
81
81
|
title=${t}
|
|
82
82
|
aria-label=${t}
|
|
83
|
-
@click=${async n=>{const s=n.currentTarget;if(s?.querySelector(".chat-copy-btn__icon"),!s||s.dataset.copying==="1")return;s.dataset.copying="1",s.setAttribute("aria-busy","true"),s.disabled=!0;const i=await
|
|
83
|
+
@click=${async n=>{const s=n.currentTarget;if(s?.querySelector(".chat-copy-btn__icon"),!s||s.dataset.copying==="1")return;s.dataset.copying="1",s.setAttribute("aria-busy","true"),s.disabled=!0;const i=await ap(e.text());if(s.isConnected){if(delete s.dataset.copying,s.removeAttribute("aria-busy"),s.disabled=!1,!i){s.dataset.error="1",qt(s,ip),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.error,qt(s,t))},np);return}s.dataset.copied="1",qt(s,sp),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,qt(s,t))},tp)}}}
|
|
84
84
|
>
|
|
85
85
|
<span class="chat-copy-btn__icon" aria-hidden="true">
|
|
86
86
|
<span class="chat-copy-btn__icon-copy">${W.copy}</span>
|
|
87
87
|
<span class="chat-copy-btn__icon-check">${W.check}</span>
|
|
88
88
|
</span>
|
|
89
89
|
</button>
|
|
90
|
-
`}function
|
|
91
|
-
`),n=t.slice(0,
|
|
92
|
-
`);return s.length>Na?s.slice(0,Na)+"…":n.length<t.length?s+"…":s}function
|
|
90
|
+
`}function rp(e){return op({text:()=>e,label:gr})}const lp={icon:"puzzle",detailKeys:["command","path","url","targetUrl","targetId","ref","element","node","nodeId","id","requestId","to","channelId","guildId","userId","name","query","pattern","messageId"]},cp={bash:{icon:"wrench",title:"Bash",detailKeys:["command"]},process:{icon:"wrench",title:"Process",detailKeys:["sessionId"]},read:{icon:"fileText",title:"Read",detailKeys:["path"]},write:{icon:"edit",title:"Write",detailKeys:["path"]},edit:{icon:"penLine",title:"Edit",detailKeys:["path"]},attach:{icon:"paperclip",title:"Attach",detailKeys:["path","url","fileName"]},browser:{icon:"globe",title:"Browser",actions:{status:{label:"status"},start:{label:"start"},stop:{label:"stop"},tabs:{label:"tabs"},open:{label:"open",detailKeys:["targetUrl"]},focus:{label:"focus",detailKeys:["targetId"]},close:{label:"close",detailKeys:["targetId"]},snapshot:{label:"snapshot",detailKeys:["targetUrl","targetId","ref","element","format"]},screenshot:{label:"screenshot",detailKeys:["targetUrl","targetId","ref","element"]},navigate:{label:"navigate",detailKeys:["targetUrl","targetId"]},console:{label:"console",detailKeys:["level","targetId"]},pdf:{label:"pdf",detailKeys:["targetId"]},upload:{label:"upload",detailKeys:["paths","ref","inputRef","element","targetId"]},dialog:{label:"dialog",detailKeys:["accept","promptText","targetId"]},act:{label:"act",detailKeys:["request.kind","request.ref","request.selector","request.text","request.value"]}}},canvas:{icon:"image",title:"Canvas",actions:{present:{label:"present",detailKeys:["target","node","nodeId"]},hide:{label:"hide",detailKeys:["node","nodeId"]},navigate:{label:"navigate",detailKeys:["url","node","nodeId"]},eval:{label:"eval",detailKeys:["javaScript","node","nodeId"]},snapshot:{label:"snapshot",detailKeys:["format","node","nodeId"]},a2ui_push:{label:"A2UI push",detailKeys:["jsonlPath","node","nodeId"]},a2ui_reset:{label:"A2UI reset",detailKeys:["node","nodeId"]}}},nodes:{icon:"smartphone",title:"Nodes",actions:{status:{label:"status"},describe:{label:"describe",detailKeys:["node","nodeId"]},pending:{label:"pending"},approve:{label:"approve",detailKeys:["requestId"]},reject:{label:"reject",detailKeys:["requestId"]},notify:{label:"notify",detailKeys:["node","nodeId","title","body"]},camera_snap:{label:"camera snap",detailKeys:["node","nodeId","facing","deviceId"]},camera_list:{label:"camera list",detailKeys:["node","nodeId"]},camera_clip:{label:"camera clip",detailKeys:["node","nodeId","facing","duration","durationMs"]},screen_record:{label:"screen record",detailKeys:["node","nodeId","duration","durationMs","fps","screenIndex"]}}},cron:{icon:"loader",title:"Cron",actions:{status:{label:"status"},list:{label:"list"},add:{label:"add",detailKeys:["job.name","job.id","job.schedule","job.cron"]},update:{label:"update",detailKeys:["id"]},remove:{label:"remove",detailKeys:["id"]},run:{label:"run",detailKeys:["id"]},runs:{label:"runs",detailKeys:["id"]},wake:{label:"wake",detailKeys:["text","mode"]}}},gateway:{icon:"plug",title:"Gateway",actions:{restart:{label:"restart",detailKeys:["reason","delayMs"]},"config.get":{label:"config get"},"config.schema":{label:"config schema"},"config.apply":{label:"config apply",detailKeys:["restartDelayMs"]},"update.run":{label:"update run",detailKeys:["restartDelayMs"]}}},whatsapp_login:{icon:"circle",title:"WhatsApp Login",actions:{start:{label:"start"},wait:{label:"wait"}}},discord:{icon:"messageSquare",title:"Discord",actions:{react:{label:"react",detailKeys:["channelId","messageId","emoji"]},reactions:{label:"reactions",detailKeys:["channelId","messageId"]},sticker:{label:"sticker",detailKeys:["to","stickerIds"]},poll:{label:"poll",detailKeys:["question","to"]},permissions:{label:"permissions",detailKeys:["channelId"]},readMessages:{label:"read messages",detailKeys:["channelId","limit"]},sendMessage:{label:"send",detailKeys:["to","content"]},editMessage:{label:"edit",detailKeys:["channelId","messageId"]},deleteMessage:{label:"delete",detailKeys:["channelId","messageId"]},threadCreate:{label:"thread create",detailKeys:["channelId","name"]},threadList:{label:"thread list",detailKeys:["guildId","channelId"]},threadReply:{label:"thread reply",detailKeys:["channelId","content"]},pinMessage:{label:"pin",detailKeys:["channelId","messageId"]},unpinMessage:{label:"unpin",detailKeys:["channelId","messageId"]},listPins:{label:"list pins",detailKeys:["channelId"]},searchMessages:{label:"search",detailKeys:["guildId","content"]},memberInfo:{label:"member",detailKeys:["guildId","userId"]},roleInfo:{label:"roles",detailKeys:["guildId"]},emojiList:{label:"emoji list",detailKeys:["guildId"]},roleAdd:{label:"role add",detailKeys:["guildId","userId","roleId"]},roleRemove:{label:"role remove",detailKeys:["guildId","userId","roleId"]},channelInfo:{label:"channel",detailKeys:["channelId"]},channelList:{label:"channels",detailKeys:["guildId"]},voiceStatus:{label:"voice",detailKeys:["guildId","userId"]},eventList:{label:"events",detailKeys:["guildId"]},eventCreate:{label:"event create",detailKeys:["guildId","name"]},timeout:{label:"timeout",detailKeys:["guildId","userId"]},kick:{label:"kick",detailKeys:["guildId","userId"]},ban:{label:"ban",detailKeys:["guildId","userId"]}}},slack:{icon:"messageSquare",title:"Slack",actions:{react:{label:"react",detailKeys:["channelId","messageId","emoji"]},reactions:{label:"reactions",detailKeys:["channelId","messageId"]},sendMessage:{label:"send",detailKeys:["to","content"]},editMessage:{label:"edit",detailKeys:["channelId","messageId"]},deleteMessage:{label:"delete",detailKeys:["channelId","messageId"]},readMessages:{label:"read messages",detailKeys:["channelId","limit"]},pinMessage:{label:"pin",detailKeys:["channelId","messageId"]},unpinMessage:{label:"unpin",detailKeys:["channelId","messageId"]},listPins:{label:"list pins",detailKeys:["channelId"]},memberInfo:{label:"member",detailKeys:["userId"]},emojiList:{label:"emoji list"}}}},dp={fallback:lp,tools:cp},vr=dp,Pa=vr.fallback??{icon:"puzzle"},up=vr.tools??{};function pp(e){return(e??"tool").trim()}function hp(e){const t=e.replace(/_/g," ").trim();return t?t.split(/\s+/).map(n=>n.length<=2&&n.toUpperCase()===n?n:`${n.at(0)?.toUpperCase()??""}${n.slice(1)}`).join(" "):"Tool"}function fp(e){const t=e?.trim();if(t)return t.replace(/_/g," ")}function mr(e){if(e!=null){if(typeof e=="string"){const t=e.trim();if(!t)return;const n=t.split(/\r?\n/)[0]?.trim()??"";return n?n.length>160?`${n.slice(0,157)}…`:n:void 0}if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const t=e.map(s=>mr(s)).filter(s=>!!s);if(t.length===0)return;const n=t.slice(0,3).join(", ");return t.length>3?`${n}…`:n}}}function gp(e,t){if(!e||typeof e!="object")return;let n=e;for(const s of t.split(".")){if(!s||!n||typeof n!="object")return;n=n[s]}return n}function vp(e,t){for(const n of t){const s=gp(e,n),i=mr(s);if(i)return i}}function mp(e){if(!e||typeof e!="object")return;const t=e,n=typeof t.path=="string"?t.path:void 0;if(!n)return;const s=typeof t.offset=="number"?t.offset:void 0,i=typeof t.limit=="number"?t.limit:void 0;return s!==void 0&&i!==void 0?`${n}:${s}-${s+i}`:n}function yp(e){if(!e||typeof e!="object")return;const t=e;return typeof t.path=="string"?t.path:void 0}function bp(e,t){if(!(!e||!t))return e.actions?.[t]??void 0}function wp(e){const t=pp(e.name),n=t.toLowerCase(),s=up[n],i=s?.icon??Pa.icon??"puzzle",a=s?.title??hp(t),o=s?.label??t,r=e.args&&typeof e.args=="object"?e.args.action:void 0,l=typeof r=="string"?r.trim():void 0,p=bp(s,l),d=fp(p?.label??l);let u;n==="read"&&(u=mp(e.args)),!u&&(n==="write"||n==="edit"||n==="attach")&&(u=yp(e.args));const g=p?.detailKeys??s?.detailKeys??Pa.detailKeys??[];return!u&&g.length>0&&(u=vp(e.args,g)),!u&&e.meta&&(u=e.meta),u&&(u=xp(u)),{name:t,icon:i,title:a,label:o,verb:d,detail:u}}function $p(e){const t=[];if(e.verb&&t.push(e.verb),e.detail&&t.push(e.detail),t.length!==0)return t.join(" · ")}function xp(e){return e&&e.replace(/\/Users\/[^/]+/g,"~").replace(/\/home\/[^/]+/g,"~")}const Ap=80,kp=2,Na=100;function Sp(e){const t=e.trim();if(t.startsWith("{")||t.startsWith("["))try{const n=JSON.parse(t);return"```json\n"+JSON.stringify(n,null,2)+"\n```"}catch{}return e}function _p(e){const t=e.split(`
|
|
91
|
+
`),n=t.slice(0,kp),s=n.join(`
|
|
92
|
+
`);return s.length>Na?s.slice(0,Na)+"…":n.length<t.length?s+"…":s}function Cp(e){const t=e,n=Tp(t.content),s=[];for(const i of n){const a=String(i.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(a)||typeof i.name=="string"&&i.arguments!=null)&&s.push({kind:"call",name:i.name??"tool",args:Ep(i.arguments??i.args)})}for(const i of n){const a=String(i.type??"").toLowerCase();if(a!=="toolresult"&&a!=="tool_result")continue;const o=Mp(i),r=typeof i.name=="string"?i.name:"tool";s.push({kind:"result",name:r,text:o})}if(Xo(e)&&!s.some(i=>i.kind==="result")){const i=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",a=mo(e)??void 0;s.push({kind:"result",name:i,text:a})}return s}function Oa(e,t){const n=wp({name:e.name,args:e.args}),s=$p(n),i=!!e.text?.trim(),a=!!t,o=a?()=>{if(i){t(Sp(e.text));return}const u=`## ${n.label}
|
|
93
93
|
|
|
94
94
|
${s?`**Command:** \`${s}\`
|
|
95
95
|
|
|
96
|
-
`:""}*No output — tool completed successfully.*`;t(u)}:void 0,r=i&&(e.text?.length??0)<=
|
|
96
|
+
`:""}*No output — tool completed successfully.*`;t(u)}:void 0,r=i&&(e.text?.length??0)<=Ap,l=i&&!r,p=i&&r,d=!i;return c`
|
|
97
97
|
<div
|
|
98
98
|
class="chat-tool-card ${a?"chat-tool-card--clickable":""}"
|
|
99
99
|
@click=${o}
|
|
@@ -111,10 +111,10 @@ ${s?`**Command:** \`${s}\`
|
|
|
111
111
|
</div>
|
|
112
112
|
${s?c`<div class="chat-tool-card__detail">${s}</div>`:f}
|
|
113
113
|
${d?c`<div class="chat-tool-card__status-text muted">Completed</div>`:f}
|
|
114
|
-
${l?c`<div class="chat-tool-card__preview mono">${
|
|
114
|
+
${l?c`<div class="chat-tool-card__preview mono">${_p(e.text)}</div>`:f}
|
|
115
115
|
${p?c`<div class="chat-tool-card__inline mono">${e.text}</div>`:f}
|
|
116
116
|
</div>
|
|
117
|
-
`}function
|
|
117
|
+
`}function Tp(e){return Array.isArray(e)?e.filter(Boolean):[]}function Ep(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 Mp(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function Lp(e){const n=e.content,s=[];if(Array.isArray(n))for(const i of n){if(typeof i!="object"||i===null)continue;const a=i;if(a.type==="image"){const o=a.source;if(o?.type==="base64"&&typeof o.data=="string"){const r=o.data,l=o.media_type||"image/png",p=r.startsWith("data:")?r:`data:${l};base64,${r}`;s.push({url:p})}else typeof a.url=="string"&&s.push({url:a.url})}else if(a.type==="image_url"){const o=a.image_url;typeof o?.url=="string"&&s.push({url:o.url})}}return s}function Ip(e){return c`
|
|
118
118
|
<div class="chat-group assistant">
|
|
119
119
|
${fi("assistant",e)}
|
|
120
120
|
<div class="chat-group-messages">
|
|
@@ -125,7 +125,7 @@ ${s?`**Command:** \`${s}\`
|
|
|
125
125
|
</div>
|
|
126
126
|
</div>
|
|
127
127
|
</div>
|
|
128
|
-
`}function
|
|
128
|
+
`}function Rp(e,t,n,s){const i=new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),a=s?.name??"Assistant";return c`
|
|
129
129
|
<div class="chat-group assistant">
|
|
130
130
|
${fi("assistant",s)}
|
|
131
131
|
<div class="chat-group-messages">
|
|
@@ -136,7 +136,7 @@ ${s?`**Command:** \`${s}\`
|
|
|
136
136
|
</div>
|
|
137
137
|
</div>
|
|
138
138
|
</div>
|
|
139
|
-
`}function
|
|
139
|
+
`}function Pp(e,t){const n=ii(e.role),s=t.assistantName??"Assistant",i=n==="user"?"You":n==="assistant"?s:n,a=n==="user"?"user":n==="assistant"?"assistant":"other",o=new Date(e.timestamp).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return c`
|
|
140
140
|
<div class="chat-group ${a}">
|
|
141
141
|
${fi(e.role,{name:s,avatar:t.assistantAvatar??null})}
|
|
142
142
|
<div class="chat-group-messages">
|
|
@@ -147,11 +147,11 @@ ${s?`**Command:** \`${s}\`
|
|
|
147
147
|
</div>
|
|
148
148
|
</div>
|
|
149
149
|
</div>
|
|
150
|
-
`}function fi(e,t){const n=ii(e),s=t?.name?.trim()||"Assistant",i=t?.avatar?.trim()||"",a=n==="user"?"U":n==="assistant"?s.charAt(0).toUpperCase()||"A":n==="tool"?"⚙":"?",o=n==="user"?"user":n==="assistant"?"assistant":n==="tool"?"tool":"other";return i&&n==="assistant"?
|
|
150
|
+
`}function fi(e,t){const n=ii(e),s=t?.name?.trim()||"Assistant",i=t?.avatar?.trim()||"",a=n==="user"?"U":n==="assistant"?s.charAt(0).toUpperCase()||"A":n==="tool"?"⚙":"?",o=n==="user"?"user":n==="assistant"?"assistant":n==="tool"?"tool":"other";return i&&n==="assistant"?Np(i)?c`<img
|
|
151
151
|
class="chat-avatar ${o}"
|
|
152
152
|
src="${i}"
|
|
153
153
|
alt="${s}"
|
|
154
|
-
/>`:c`<div class="chat-avatar ${o}">${i}</div>`:c`<div class="chat-avatar ${o}">${a}</div>`}function
|
|
154
|
+
/>`:c`<div class="chat-avatar ${o}">${i}</div>`:c`<div class="chat-avatar ${o}">${a}</div>`}function Np(e){return/^https?:\/\//i.test(e)||/^data:image\//i.test(e)||/^\//.test(e)}function Op(e){return e.length===0?f:c`
|
|
155
155
|
<div class="chat-message-images">
|
|
156
156
|
${e.map(t=>c`
|
|
157
157
|
<img
|
|
@@ -162,15 +162,15 @@ ${s?`**Command:** \`${s}\`
|
|
|
162
162
|
/>
|
|
163
163
|
`)}
|
|
164
164
|
</div>
|
|
165
|
-
`}function yr(e,t,n){const s=e,i=typeof s.role=="string"?s.role:"unknown",a=
|
|
165
|
+
`}function yr(e,t,n){const s=e,i=typeof s.role=="string"?s.role:"unknown",a=Xo(e)||i.toLowerCase()==="toolresult"||i.toLowerCase()==="tool_result"||typeof s.toolCallId=="string"||typeof s.tool_call_id=="string",o=Cp(e),r=o.length>0,l=Lp(e),p=l.length>0,d=mo(e),u=t.showReasoning&&i==="assistant"?Rl(e):null,g=d?.trim()?d:null,v=u?Nl(u):null,y=g,$=i==="assistant"&&!!y?.trim(),A=["chat-bubble",$?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!y&&r&&a?c`${o.map(_=>Oa(_,n))}`:!y&&!r&&!p?f:c`
|
|
166
166
|
<div class="${A}">
|
|
167
|
-
${$?
|
|
168
|
-
${
|
|
167
|
+
${$?rp(y):f}
|
|
168
|
+
${Op(l)}
|
|
169
169
|
${v?c`<div class="chat-thinking">${bs(Cs(v))}</div>`:f}
|
|
170
|
-
${
|
|
170
|
+
${y?c`<div class="chat-text">${bs(Cs(y))}</div>`:f}
|
|
171
171
|
${o.map(_=>Oa(_,n))}
|
|
172
172
|
</div>
|
|
173
|
-
`}function
|
|
173
|
+
`}function Dp(e){return c`
|
|
174
174
|
<div class="sidebar-panel">
|
|
175
175
|
<div class="sidebar-header">
|
|
176
176
|
<div class="sidebar-title">Tool Output</div>
|
|
@@ -187,7 +187,7 @@ ${s?`**Command:** \`${s}\`
|
|
|
187
187
|
`:e.content?c`<div class="sidebar-markdown">${bs(Cs(e.content))}</div>`:c`<div class="muted">No content available</div>`}
|
|
188
188
|
</div>
|
|
189
189
|
</div>
|
|
190
|
-
`}var
|
|
190
|
+
`}var Bp=Object.defineProperty,Fp=Object.getOwnPropertyDescriptor,wn=(e,t,n,s)=>{for(var i=s>1?void 0:s?Fp(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&Bp(t,n,i),i};let nt=class extends Je{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,i=(e.clientX-this.startX)/n;let a=this.startRatio+i;a=Math.max(this.minRatio,Math.min(this.maxRatio,a)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:a},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 c``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};nt.styles=Gr`
|
|
191
191
|
:host {
|
|
192
192
|
width: 4px;
|
|
193
193
|
cursor: col-resize;
|
|
@@ -213,15 +213,15 @@ ${s?`**Command:** \`${s}\`
|
|
|
213
213
|
:host(.dragging) {
|
|
214
214
|
background: var(--accent, #007bff);
|
|
215
215
|
}
|
|
216
|
-
|
|
216
|
+
`;wn([ln({type:Number})],nt.prototype,"splitRatio",2);wn([ln({type:Number})],nt.prototype,"minRatio",2);wn([ln({type:Number})],nt.prototype,"maxRatio",2);nt=wn([lo("resizable-divider")],nt);const Up=5e3;function Da(e){e.style.height="auto",e.style.height=`${e.scrollHeight}px`}function Kp(e){return e?e.active?c`
|
|
217
217
|
<div class="callout info compaction-indicator compaction-indicator--active">
|
|
218
218
|
${W.loader} Compacting context...
|
|
219
219
|
</div>
|
|
220
|
-
`:e.completedAt&&Date.now()-e.completedAt<
|
|
220
|
+
`:e.completedAt&&Date.now()-e.completedAt<Up?c`
|
|
221
221
|
<div class="callout success compaction-indicator compaction-indicator--complete">
|
|
222
222
|
${W.check} Context compacted
|
|
223
223
|
</div>
|
|
224
|
-
`:f:f}function
|
|
224
|
+
`:f:f}function Hp(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function zp(e,t){const n=e.clipboardData?.items;if(!n||!t.onAttachmentsChange)return;const s=[];for(let i=0;i<n.length;i++){const a=n[i];a.type.startsWith("image/")&&s.push(a)}if(s.length!==0){e.preventDefault();for(const i of s){const a=i.getAsFile();if(!a)continue;const o=new FileReader;o.onload=()=>{const r=o.result,l={id:Hp(),dataUrl:r,mimeType:a.type},p=t.attachments??[];t.onAttachmentsChange?.([...p,l])},o.readAsDataURL(a)}}}function jp(e){const t=e.attachments??[];return t.length===0?f:c`
|
|
225
225
|
<div class="chat-attachments">
|
|
226
226
|
${t.map(n=>c`
|
|
227
227
|
<div class="chat-attachment">
|
|
@@ -241,7 +241,7 @@ ${s?`**Command:** \`${s}\`
|
|
|
241
241
|
</div>
|
|
242
242
|
`)}
|
|
243
243
|
</div>
|
|
244
|
-
`}function
|
|
244
|
+
`}function qp(e){const t=e.connected,n=e.sending||e.stream!==null,s=!!(e.canAbort&&e.onAbort),a=e.sessions?.sessions?.find(v=>v.key===e.sessionKey)?.reasoningLevel??"off",o=e.showThinking&&a!=="off",r={name:e.assistantName,avatar:e.assistantAvatar??e.assistantAvatarUrl??null},l=(e.attachments?.length??0)>0,p=e.connected?l?"Add a message or paste more images...":"Message (↩ to send, Shift+↩ for line breaks, paste images)":"Connect to the gateway to start chatting…",d=e.splitRatio??.6,u=!!(e.sidebarOpen&&e.onCloseSidebar),g=c`
|
|
245
245
|
<div
|
|
246
246
|
class="chat-thread"
|
|
247
247
|
role="log"
|
|
@@ -249,7 +249,7 @@ ${s?`**Command:** \`${s}\`
|
|
|
249
249
|
@scroll=${e.onChatScroll}
|
|
250
250
|
>
|
|
251
251
|
${e.loading?c`<div class="muted">Loading chat…</div>`:f}
|
|
252
|
-
${
|
|
252
|
+
${Zo(Wp(e),v=>v.key,v=>v.kind==="reading-indicator"?Ip(r):v.kind==="stream"?Rp(v.text,v.startedAt,e.onOpenSidebar,r):v.kind==="group"?Pp(v,{onOpenSidebar:e.onOpenSidebar,showReasoning:o,assistantName:e.assistantName,assistantAvatar:r.avatar}):f)}
|
|
253
253
|
</div>
|
|
254
254
|
`;return c`
|
|
255
255
|
<section class="card chat">
|
|
@@ -257,7 +257,7 @@ ${s?`**Command:** \`${s}\`
|
|
|
257
257
|
|
|
258
258
|
${e.error?c`<div class="callout danger">${e.error}</div>`:f}
|
|
259
259
|
|
|
260
|
-
${
|
|
260
|
+
${Kp(e.compactionStatus)}
|
|
261
261
|
|
|
262
262
|
${e.focusMode?c`
|
|
263
263
|
<button
|
|
@@ -287,7 +287,7 @@ ${s?`**Command:** \`${s}\`
|
|
|
287
287
|
@resize=${v=>e.onSplitRatioChange?.(v.detail.splitRatio)}
|
|
288
288
|
></resizable-divider>
|
|
289
289
|
<div class="chat-sidebar">
|
|
290
|
-
${
|
|
290
|
+
${Dp({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
|
|
291
291
|
${e.sidebarContent}
|
|
292
292
|
\`\`\``)}})}
|
|
293
293
|
</div>
|
|
@@ -318,7 +318,7 @@ ${e.sidebarContent}
|
|
|
318
318
|
`:f}
|
|
319
319
|
|
|
320
320
|
<div class="chat-compose">
|
|
321
|
-
${
|
|
321
|
+
${jp(e)}
|
|
322
322
|
<div class="chat-compose__row">
|
|
323
323
|
<label class="field chat-compose__field">
|
|
324
324
|
<span>Message</span>
|
|
@@ -327,8 +327,8 @@ ${e.sidebarContent}
|
|
|
327
327
|
.value=${e.draft}
|
|
328
328
|
?disabled=${!e.connected}
|
|
329
329
|
@keydown=${v=>{v.key==="Enter"&&(v.isComposing||v.keyCode===229||v.shiftKey||e.connected&&(v.preventDefault(),t&&e.onSend()))}}
|
|
330
|
-
@input=${v=>{const
|
|
331
|
-
@paste=${v=>
|
|
330
|
+
@input=${v=>{const y=v.target;Da(y),e.onDraftChange(y.value)}}
|
|
331
|
+
@paste=${v=>zp(v,e)}
|
|
332
332
|
placeholder=${p}
|
|
333
333
|
></textarea>
|
|
334
334
|
</label>
|
|
@@ -351,32 +351,32 @@ ${e.sidebarContent}
|
|
|
351
351
|
</div>
|
|
352
352
|
</div>
|
|
353
353
|
</section>
|
|
354
|
-
`}const Ba=200;function
|
|
354
|
+
`}const Ba=200;function Gp(e){const t=[];let n=null;for(const s of e){if(s.kind!=="message"){n&&(t.push(n),n=null),t.push(s);continue}const i=Jo(s.message),a=ii(i.role),o=i.timestamp||Date.now();!n||n.role!==a?(n&&t.push(n),n={kind:"group",key:`group:${a}:${s.key}`,role:a,messages:[{message:s.message,key:s.key}],timestamp:o,isStreaming:!1}):n.messages.push({message:s.message,key:s.key})}return n&&t.push(n),t}function Wp(e){const t=[],n=Array.isArray(e.messages)?e.messages:[],s=Array.isArray(e.toolMessages)?e.toolMessages:[],i=Math.max(0,n.length-Ba);i>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${Ba} messages (${i} hidden).`,timestamp:Date.now()}});for(let a=i;a<n.length;a++){const o=n[a],r=Jo(o);!e.showThinking&&r.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:Fa(o,a),message:o})}if(e.showThinking)for(let a=0;a<s.length;a++)t.push({kind:"message",key:Fa(s[a],a+n.length),message:s[a]});if(e.stream!==null){const a=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:a,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:a})}return Gp(t)}function Fa(e,t){const n=e,s=typeof n.toolCallId=="string"?n.toolCallId:"";if(s)return`tool:${s}`;const i=typeof n.id=="string"?n.id:"";if(i)return`msg:${i}`;const a=typeof n.messageId=="string"?n.messageId:"";if(a)return`msg:${a}`;const o=typeof n.timestamp=="number"?n.timestamp:null,r=typeof n.role=="string"?n.role:"unknown";return o!=null?`msg:${r}:${o}:${t}`:`msg:${r}:${t}`}function ue(e){if(e)return Array.isArray(e.type)?e.type.filter(n=>n!=="null")[0]??e.type[0]:e.type}function br(e){if(!e)return"";if(e.default!==void 0)return e.default;switch(ue(e)){case"object":return{};case"array":return[];case"boolean":return!1;case"number":case"integer":return 0;case"string":return"";default:return""}}function $n(e){return e.filter(t=>typeof t=="string").join(".")}function te(e,t){const n=$n(e),s=t[n];if(s)return s;const i=n.split(".");for(const[a,o]of Object.entries(t)){if(!a.includes("*"))continue;const r=a.split(".");if(r.length!==i.length)continue;let l=!0;for(let p=0;p<i.length;p+=1)if(r[p]!=="*"&&r[p]!==i[p]){l=!1;break}if(l)return o}}function we(e){return e.replace(/_/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/\s+/g," ").replace(/^./,t=>t.toUpperCase())}function Vp(e){const t=$n(e).toLowerCase();return t.includes("token")||t.includes("password")||t.includes("secret")||t.includes("apikey")||t.endsWith("key")}const Yp=new Set(["title","description","default","nullable"]);function Qp(e){return Object.keys(e??{}).filter(n=>!Yp.has(n)).length===0}function Zp(e){if(e===void 0)return"";try{return JSON.stringify(e,null,2)??""}catch{return""}}const Ct={chevronDown:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>`,plus:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>`,minus:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg>`,trash:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>`,edit:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg>`};function be(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:r}=e,l=e.showLabel??!0,p=ue(t),d=te(s,i),u=d?.label??t.title??we(String(s.at(-1))),g=d?.help??t.description,v=$n(s);if(a.has(v))return c`<div class="cfg-field cfg-field--error">
|
|
355
355
|
<div class="cfg-field__label">${u}</div>
|
|
356
356
|
<div class="cfg-field__error">Unsupported schema node. Use Raw mode.</div>
|
|
357
|
-
</div>`;if(t.anyOf||t.oneOf){const $=(t.anyOf??t.oneOf??[]).filter(
|
|
357
|
+
</div>`;if(t.anyOf||t.oneOf){const $=(t.anyOf??t.oneOf??[]).filter(T=>!(T.type==="null"||Array.isArray(T.type)&&T.type.includes("null")));if($.length===1)return be({...e,schema:$[0]});const A=T=>{if(T.const!==void 0)return T.const;if(T.enum&&T.enum.length===1)return T.enum[0]},_=$.map(A),L=_.every(T=>T!==void 0);if(L&&_.length>0&&_.length<=5){const T=n??t.default;return c`
|
|
358
358
|
<div class="cfg-field">
|
|
359
359
|
${l?c`<label class="cfg-field__label">${u}</label>`:f}
|
|
360
360
|
${g?c`<div class="cfg-field__help">${g}</div>`:f}
|
|
361
361
|
<div class="cfg-segmented">
|
|
362
|
-
${_.map((
|
|
362
|
+
${_.map((E,pe)=>c`
|
|
363
363
|
<button
|
|
364
364
|
type="button"
|
|
365
|
-
class="cfg-segmented__btn ${
|
|
365
|
+
class="cfg-segmented__btn ${E===T||String(E)===String(T)?"active":""}"
|
|
366
366
|
?disabled=${o}
|
|
367
|
-
@click=${()=>r(s,
|
|
367
|
+
@click=${()=>r(s,E)}
|
|
368
368
|
>
|
|
369
|
-
${String(
|
|
369
|
+
${String(E)}
|
|
370
370
|
</button>
|
|
371
371
|
`)}
|
|
372
372
|
</div>
|
|
373
373
|
</div>
|
|
374
|
-
`}if(L&&_.length>5)return Ka({...e,options:_,value:n??t.default});const P=new Set($.map(
|
|
374
|
+
`}if(L&&_.length>5)return Ka({...e,options:_,value:n??t.default});const P=new Set($.map(T=>ue(T)).filter(Boolean)),M=new Set([...P].map(T=>T==="integer"?"number":T));if([...M].every(T=>["string","number","boolean"].includes(T))){const T=M.has("string"),E=M.has("number");if(M.has("boolean")&&M.size===1)return be({...e,schema:{...t,type:"boolean",anyOf:void 0,oneOf:void 0}});if(T||E)return Ua({...e,inputType:E&&!T?"number":"text"})}}if(t.enum){const y=t.enum;if(y.length<=5){const $=n??t.default;return c`
|
|
375
375
|
<div class="cfg-field">
|
|
376
376
|
${l?c`<label class="cfg-field__label">${u}</label>`:f}
|
|
377
377
|
${g?c`<div class="cfg-field__help">${g}</div>`:f}
|
|
378
378
|
<div class="cfg-segmented">
|
|
379
|
-
${
|
|
379
|
+
${y.map(A=>c`
|
|
380
380
|
<button
|
|
381
381
|
type="button"
|
|
382
382
|
class="cfg-segmented__btn ${A===$||String(A)===String($)?"active":""}"
|
|
@@ -388,7 +388,7 @@ ${e.sidebarContent}
|
|
|
388
388
|
`)}
|
|
389
389
|
</div>
|
|
390
390
|
</div>
|
|
391
|
-
`}return Ka({...e,options:
|
|
391
|
+
`}return Ka({...e,options:y,value:n??t.default})}if(p==="object")return Xp(e);if(p==="array")return eh(e);if(p==="boolean"){const y=typeof n=="boolean"?n:typeof t.default=="boolean"?t.default:!1;return c`
|
|
392
392
|
<label class="cfg-toggle-row ${o?"disabled":""}">
|
|
393
393
|
<div class="cfg-toggle-row__content">
|
|
394
394
|
<span class="cfg-toggle-row__label">${u}</span>
|
|
@@ -397,19 +397,19 @@ ${e.sidebarContent}
|
|
|
397
397
|
<div class="cfg-toggle">
|
|
398
398
|
<input
|
|
399
399
|
type="checkbox"
|
|
400
|
-
.checked=${
|
|
400
|
+
.checked=${y}
|
|
401
401
|
?disabled=${o}
|
|
402
402
|
@change=${$=>r(s,$.target.checked)}
|
|
403
403
|
/>
|
|
404
404
|
<span class="cfg-toggle__track"></span>
|
|
405
405
|
</div>
|
|
406
406
|
</label>
|
|
407
|
-
`}return p==="number"||p==="integer"?
|
|
407
|
+
`}return p==="number"||p==="integer"?Jp(e):p==="string"?Ua({...e,inputType:"text"}):c`
|
|
408
408
|
<div class="cfg-field cfg-field--error">
|
|
409
409
|
<div class="cfg-field__label">${u}</div>
|
|
410
410
|
<div class="cfg-field__error">Unsupported type: ${p}. Use Raw mode.</div>
|
|
411
411
|
</div>
|
|
412
|
-
`}function Ua(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o,inputType:r}=e,l=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,g=p?.sensitive??
|
|
412
|
+
`}function Ua(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o,inputType:r}=e,l=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,g=p?.sensitive??Vp(s),v=p?.placeholder??(g?"••••":t.default!==void 0?`Default: ${t.default}`:""),y=n??"";return c`
|
|
413
413
|
<div class="cfg-field">
|
|
414
414
|
${l?c`<label class="cfg-field__label">${d}</label>`:f}
|
|
415
415
|
${u?c`<div class="cfg-field__help">${u}</div>`:f}
|
|
@@ -418,7 +418,7 @@ ${e.sidebarContent}
|
|
|
418
418
|
type=${g?"password":r}
|
|
419
419
|
class="cfg-input"
|
|
420
420
|
placeholder=${v}
|
|
421
|
-
.value=${
|
|
421
|
+
.value=${y==null?"":String(y)}
|
|
422
422
|
?disabled=${a}
|
|
423
423
|
@input=${$=>{const A=$.target.value;if(r==="number"){if(A.trim()===""){o(s,void 0);return}const _=Number(A);o(s,Number.isNaN(_)?A:_);return}o(s,A)}}
|
|
424
424
|
@change=${$=>{if(r==="number")return;const A=$.target.value;o(s,A.trim())}}
|
|
@@ -434,7 +434,7 @@ ${e.sidebarContent}
|
|
|
434
434
|
`:f}
|
|
435
435
|
</div>
|
|
436
436
|
</div>
|
|
437
|
-
`}function
|
|
437
|
+
`}function Jp(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o}=e,r=e.showLabel??!0,l=te(s,i),p=l?.label??t.title??we(String(s.at(-1))),d=l?.help??t.description,u=n??t.default??"",g=typeof u=="number"?u:0;return c`
|
|
438
438
|
<div class="cfg-field">
|
|
439
439
|
${r?c`<label class="cfg-field__label">${p}</label>`:f}
|
|
440
440
|
${d?c`<div class="cfg-field__help">${d}</div>`:f}
|
|
@@ -450,7 +450,7 @@ ${e.sidebarContent}
|
|
|
450
450
|
class="cfg-number__input"
|
|
451
451
|
.value=${u==null?"":String(u)}
|
|
452
452
|
?disabled=${a}
|
|
453
|
-
@input=${v=>{const
|
|
453
|
+
@input=${v=>{const y=v.target.value,$=y===""?void 0:Number(y);o(s,$)}}
|
|
454
454
|
/>
|
|
455
455
|
<button
|
|
456
456
|
type="button"
|
|
@@ -460,23 +460,23 @@ ${e.sidebarContent}
|
|
|
460
460
|
>+</button>
|
|
461
461
|
</div>
|
|
462
462
|
</div>
|
|
463
|
-
`}function Ka(e){const{schema:t,value:n,path:s,hints:i,disabled:a,options:o,onPatch:r}=e,l=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,g=n??t.default,v=o.findIndex($=>$===g||String($)===String(g)),
|
|
463
|
+
`}function Ka(e){const{schema:t,value:n,path:s,hints:i,disabled:a,options:o,onPatch:r}=e,l=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,g=n??t.default,v=o.findIndex($=>$===g||String($)===String(g)),y="__unset__";return c`
|
|
464
464
|
<div class="cfg-field">
|
|
465
465
|
${l?c`<label class="cfg-field__label">${d}</label>`:f}
|
|
466
466
|
${u?c`<div class="cfg-field__help">${u}</div>`:f}
|
|
467
467
|
<select
|
|
468
468
|
class="cfg-select"
|
|
469
469
|
?disabled=${a}
|
|
470
|
-
.value=${v>=0?String(v):
|
|
471
|
-
@change=${$=>{const A=$.target.value;r(s,A===
|
|
470
|
+
.value=${v>=0?String(v):y}
|
|
471
|
+
@change=${$=>{const A=$.target.value;r(s,A===y?void 0:o[Number(A)])}}
|
|
472
472
|
>
|
|
473
|
-
<option value=${
|
|
473
|
+
<option value=${y}>Select...</option>
|
|
474
474
|
${o.map(($,A)=>c`
|
|
475
475
|
<option value=${String(A)}>${String($)}</option>
|
|
476
476
|
`)}
|
|
477
477
|
</select>
|
|
478
478
|
</div>
|
|
479
|
-
`}function
|
|
479
|
+
`}function Xp(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:r}=e;e.showLabel;const l=te(s,i),p=l?.label??t.title??we(String(s.at(-1))),d=l?.help??t.description,u=n??t.default,g=u&&typeof u=="object"&&!Array.isArray(u)?u:{},v=t.properties??{},$=Object.entries(v).sort((P,M)=>{const T=te([...s,P[0]],i)?.order??0,E=te([...s,M[0]],i)?.order??0;return T!==E?T-E:P[0].localeCompare(M[0])}),A=new Set(Object.keys(v)),_=t.additionalProperties,L=!!_&&typeof _=="object";return s.length===1?c`
|
|
480
480
|
<div class="cfg-fields">
|
|
481
481
|
${$.map(([P,M])=>be({schema:M,value:g[P],path:[...s,P],hints:i,unsupported:a,disabled:o,onPatch:r}))}
|
|
482
482
|
${L?Ha({schema:_,value:g,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:A,onPatch:r}):f}
|
|
@@ -485,7 +485,7 @@ ${e.sidebarContent}
|
|
|
485
485
|
<details class="cfg-object" open>
|
|
486
486
|
<summary class="cfg-object__header">
|
|
487
487
|
<span class="cfg-object__title">${p}</span>
|
|
488
|
-
<span class="cfg-object__chevron">${
|
|
488
|
+
<span class="cfg-object__chevron">${Ct.chevronDown}</span>
|
|
489
489
|
</summary>
|
|
490
490
|
${d?c`<div class="cfg-object__help">${d}</div>`:f}
|
|
491
491
|
<div class="cfg-object__content">
|
|
@@ -493,7 +493,7 @@ ${e.sidebarContent}
|
|
|
493
493
|
${L?Ha({schema:_,value:g,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:A,onPatch:r}):f}
|
|
494
494
|
</div>
|
|
495
495
|
</details>
|
|
496
|
-
`}function
|
|
496
|
+
`}function eh(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:r}=e,l=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,g=Array.isArray(t.items)?t.items[0]:t.items;if(!g)return c`
|
|
497
497
|
<div class="cfg-field cfg-field--error">
|
|
498
498
|
<div class="cfg-field__label">${d}</div>
|
|
499
499
|
<div class="cfg-field__error">Unsupported array schema. Use Raw mode.</div>
|
|
@@ -507,9 +507,9 @@ ${e.sidebarContent}
|
|
|
507
507
|
type="button"
|
|
508
508
|
class="cfg-array__add"
|
|
509
509
|
?disabled=${o}
|
|
510
|
-
@click=${()=>{const
|
|
510
|
+
@click=${()=>{const y=[...v,br(g)];r(s,y)}}
|
|
511
511
|
>
|
|
512
|
-
<span class="cfg-array__add-icon">${
|
|
512
|
+
<span class="cfg-array__add-icon">${Ct.plus}</span>
|
|
513
513
|
Add
|
|
514
514
|
</button>
|
|
515
515
|
</div>
|
|
@@ -521,7 +521,7 @@ ${e.sidebarContent}
|
|
|
521
521
|
</div>
|
|
522
522
|
`:c`
|
|
523
523
|
<div class="cfg-array__items">
|
|
524
|
-
${v.map((
|
|
524
|
+
${v.map((y,$)=>c`
|
|
525
525
|
<div class="cfg-array__item">
|
|
526
526
|
<div class="cfg-array__item-header">
|
|
527
527
|
<span class="cfg-array__item-index">#${$+1}</span>
|
|
@@ -532,18 +532,18 @@ ${e.sidebarContent}
|
|
|
532
532
|
?disabled=${o}
|
|
533
533
|
@click=${()=>{const A=[...v];A.splice($,1),r(s,A)}}
|
|
534
534
|
>
|
|
535
|
-
${
|
|
535
|
+
${Ct.trash}
|
|
536
536
|
</button>
|
|
537
537
|
</div>
|
|
538
538
|
<div class="cfg-array__item-content">
|
|
539
|
-
${be({schema:g,value:
|
|
539
|
+
${be({schema:g,value:y,path:[...s,$],hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:r})}
|
|
540
540
|
</div>
|
|
541
541
|
</div>
|
|
542
542
|
`)}
|
|
543
543
|
</div>
|
|
544
544
|
`}
|
|
545
545
|
</div>
|
|
546
|
-
`}function Ha(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:r,onPatch:l}=e,p=
|
|
546
|
+
`}function Ha(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:r,onPatch:l}=e,p=Qp(t),d=Object.entries(n??{}).filter(([u])=>!r.has(u));return c`
|
|
547
547
|
<div class="cfg-map">
|
|
548
548
|
<div class="cfg-map__header">
|
|
549
549
|
<span class="cfg-map__label">Custom entries</span>
|
|
@@ -553,7 +553,7 @@ ${e.sidebarContent}
|
|
|
553
553
|
?disabled=${o}
|
|
554
554
|
@click=${()=>{const u={...n??{}};let g=1,v=`custom-${g}`;for(;v in u;)g+=1,v=`custom-${g}`;u[v]=p?{}:br(t),l(s,u)}}
|
|
555
555
|
>
|
|
556
|
-
<span class="cfg-map__add-icon">${
|
|
556
|
+
<span class="cfg-map__add-icon">${Ct.plus}</span>
|
|
557
557
|
Add Entry
|
|
558
558
|
</button>
|
|
559
559
|
</div>
|
|
@@ -562,7 +562,7 @@ ${e.sidebarContent}
|
|
|
562
562
|
<div class="cfg-map__empty">No custom entries.</div>
|
|
563
563
|
`:c`
|
|
564
564
|
<div class="cfg-map__items">
|
|
565
|
-
${d.map(([u,g])=>{const v=[...s,u],
|
|
565
|
+
${d.map(([u,g])=>{const v=[...s,u],y=Zp(g);return c`
|
|
566
566
|
<div class="cfg-map__item">
|
|
567
567
|
<div class="cfg-map__item-key">
|
|
568
568
|
<input
|
|
@@ -580,9 +580,9 @@ ${e.sidebarContent}
|
|
|
580
580
|
class="cfg-textarea cfg-textarea--sm"
|
|
581
581
|
placeholder="JSON value"
|
|
582
582
|
rows="2"
|
|
583
|
-
.value=${
|
|
583
|
+
.value=${y}
|
|
584
584
|
?disabled=${o}
|
|
585
|
-
@change=${$=>{const A=$.target,_=A.value.trim();if(!_){l(v,void 0);return}try{l(v,JSON.parse(_))}catch{A.value=
|
|
585
|
+
@change=${$=>{const A=$.target,_=A.value.trim();if(!_){l(v,void 0);return}try{l(v,JSON.parse(_))}catch{A.value=y}}}
|
|
586
586
|
></textarea>
|
|
587
587
|
`:be({schema:t,value:g,path:v,hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:l})}
|
|
588
588
|
</div>
|
|
@@ -593,14 +593,14 @@ ${e.sidebarContent}
|
|
|
593
593
|
?disabled=${o}
|
|
594
594
|
@click=${()=>{const $={...n??{}};delete $[u],l(s,$)}}
|
|
595
595
|
>
|
|
596
|
-
${
|
|
596
|
+
${Ct.trash}
|
|
597
597
|
</button>
|
|
598
598
|
</div>
|
|
599
599
|
`})}
|
|
600
600
|
</div>
|
|
601
601
|
`}
|
|
602
602
|
</div>
|
|
603
|
-
`}const za={env:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>`,update:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>`,agents:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"></path><circle cx="8" cy="14" r="1"></circle><circle cx="16" cy="14" r="1"></circle></svg>`,auth:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><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>`,channels:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>`,messages:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>`,commands:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`,hooks:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><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><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>`,skills:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>`,tools:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><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"></path></svg>`,gateway:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,wizard:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M15 4V2"></path><path d="M15 16v-2"></path><path d="M8 9h2"></path><path d="M20 9h2"></path><path d="M17.8 11.8 19 13"></path><path d="M15 9h0"></path><path d="M17.8 6.2 19 5"></path><path d="m3 21 9-9"></path><path d="M12.2 6.2 11 5"></path></svg>`,meta:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path></svg>`,logging:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,browser:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4"></circle><line x1="21.17" y1="8" x2="12" y2="8"></line><line x1="3.95" y1="6.06" x2="8.54" y2="14"></line><line x1="10.88" y1="21.94" x2="15.46" y2="14"></line></svg>`,ui:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>`,models:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>`,bindings:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>`,broadcast:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path><circle cx="12" cy="12" r="2"></circle><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path></svg>`,audio:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>`,session:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>`,cron:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`,web:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,discovery:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>`,canvasHost:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>`,talk:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>`,plugins:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2v6"></path><path d="m4.93 10.93 4.24 4.24"></path><path d="M2 12h6"></path><path d="m4.93 13.07 4.24-4.24"></path><path d="M12 22v-6"></path><path d="m19.07 13.07-4.24-4.24"></path><path d="M22 12h-6"></path><path d="m19.07 10.93-4.24 4.24"></path></svg>`,default:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>`},gi={env:{label:"Environment Variables",description:"Environment variables passed to the gateway process"},update:{label:"Updates",description:"Auto-update settings and release channel"},agents:{label:"Agents",description:"Agent configurations, models, and identities"},auth:{label:"Authentication",description:"API keys and authentication profiles"},channels:{label:"Channels",description:"Messaging channels (Telegram, Discord, Slack, etc.)"},messages:{label:"Messages",description:"Message handling and routing settings"},commands:{label:"Commands",description:"Custom slash commands"},hooks:{label:"Hooks",description:"Webhooks and event hooks"},skills:{label:"Skills",description:"Skill packs and capabilities"},tools:{label:"Tools",description:"Tool configurations (browser, search, etc.)"},gateway:{label:"Gateway",description:"Gateway server settings (port, auth, binding)"},wizard:{label:"Setup Wizard",description:"Setup wizard state and history"},meta:{label:"Metadata",description:"Gateway metadata and version information"},logging:{label:"Logging",description:"Log levels and output configuration"},browser:{label:"Browser",description:"Browser automation settings"},ui:{label:"UI",description:"User interface preferences"},models:{label:"Models",description:"AI model configurations and providers"},bindings:{label:"Bindings",description:"Key bindings and shortcuts"},broadcast:{label:"Broadcast",description:"Broadcast and notification settings"},audio:{label:"Audio",description:"Audio input/output settings"},session:{label:"Session",description:"Session management and persistence"},cron:{label:"Cron",description:"Scheduled tasks and automation"},web:{label:"Web",description:"Web server and API settings"},discovery:{label:"Discovery",description:"Service discovery and networking"},canvasHost:{label:"Canvas Host",description:"Canvas rendering and display"},talk:{label:"Talk",description:"Voice and speech settings"},plugins:{label:"Plugins",description:"Plugin management and extensions"}};function ja(e){return za[e]??za.default}function rh(e,t,n){if(!n)return!0;const s=n.toLowerCase(),i=gi[e];return e.toLowerCase().includes(s)||i&&(i.label.toLowerCase().includes(s)||i.description.toLowerCase().includes(s))?!0:mt(t,s)}function mt(e,t){if(e.title?.toLowerCase().includes(t)||e.description?.toLowerCase().includes(t)||e.enum?.some(s=>String(s).toLowerCase().includes(t)))return!0;if(e.properties){for(const[s,i]of Object.entries(e.properties))if(s.toLowerCase().includes(t)||mt(i,t))return!0}if(e.items){const s=Array.isArray(e.items)?e.items:[e.items];for(const i of s)if(i&&mt(i,t))return!0}if(e.additionalProperties&&typeof e.additionalProperties=="object"&&mt(e.additionalProperties,t))return!0;const n=e.anyOf??e.oneOf??e.allOf;if(n){for(const s of n)if(s&&mt(s,t))return!0}return!1}function lh(e){if(!e.schema)return c`<div class="muted">Schema unavailable.</div>`;const t=e.schema,n=e.value??{};if(pe(t)!=="object"||!t.properties)return c`<div class="callout danger">Unsupported schema. Use Raw.</div>`;const s=new Set(e.unsupportedPaths??[]),i=t.properties,a=e.searchQuery??"",o=e.activeSection,r=e.activeSubsection??null,p=Object.entries(i).sort((u,g)=>{const v=te([u[0]],e.uiHints)?.order??50,m=te([g[0]],e.uiHints)?.order??50;return v!==m?v-m:u[0].localeCompare(g[0])}).filter(([u,g])=>!(o&&u!==o||a&&!rh(u,g,a)));let d=null;if(o&&r&&p.length===1){const u=p[0]?.[1];u&&pe(u)==="object"&&u.properties&&u.properties[r]&&(d={sectionKey:o,subsectionKey:r,schema:u.properties[r]})}return p.length===0?c`
|
|
603
|
+
`}const za={env:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>`,update:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>`,agents:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"></path><circle cx="8" cy="14" r="1"></circle><circle cx="16" cy="14" r="1"></circle></svg>`,auth:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><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>`,channels:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>`,messages:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>`,commands:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`,hooks:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><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><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>`,skills:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>`,tools:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><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"></path></svg>`,gateway:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,wizard:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M15 4V2"></path><path d="M15 16v-2"></path><path d="M8 9h2"></path><path d="M20 9h2"></path><path d="M17.8 11.8 19 13"></path><path d="M15 9h0"></path><path d="M17.8 6.2 19 5"></path><path d="m3 21 9-9"></path><path d="M12.2 6.2 11 5"></path></svg>`,meta:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path></svg>`,logging:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,browser:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4"></circle><line x1="21.17" y1="8" x2="12" y2="8"></line><line x1="3.95" y1="6.06" x2="8.54" y2="14"></line><line x1="10.88" y1="21.94" x2="15.46" y2="14"></line></svg>`,ui:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>`,models:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>`,bindings:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>`,broadcast:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path><circle cx="12" cy="12" r="2"></circle><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path></svg>`,audio:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>`,session:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>`,cron:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`,web:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,discovery:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>`,canvasHost:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>`,talk:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>`,plugins:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2v6"></path><path d="m4.93 10.93 4.24 4.24"></path><path d="M2 12h6"></path><path d="m4.93 13.07 4.24-4.24"></path><path d="M12 22v-6"></path><path d="m19.07 13.07-4.24-4.24"></path><path d="M22 12h-6"></path><path d="m19.07 10.93-4.24 4.24"></path></svg>`,default:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>`},gi={env:{label:"Environment Variables",description:"Environment variables passed to the gateway process"},update:{label:"Updates",description:"Auto-update settings and release channel"},agents:{label:"Agents",description:"Agent configurations, models, and identities"},auth:{label:"Authentication",description:"API keys and authentication profiles"},channels:{label:"Channels",description:"Messaging channels (Telegram, Discord, Slack, etc.)"},messages:{label:"Messages",description:"Message handling and routing settings"},commands:{label:"Commands",description:"Custom slash commands"},hooks:{label:"Hooks",description:"Webhooks and event hooks"},skills:{label:"Skills",description:"Skill packs and capabilities"},tools:{label:"Tools",description:"Tool configurations (browser, search, etc.)"},gateway:{label:"Gateway",description:"Gateway server settings (port, auth, binding)"},wizard:{label:"Setup Wizard",description:"Setup wizard state and history"},meta:{label:"Metadata",description:"Gateway metadata and version information"},logging:{label:"Logging",description:"Log levels and output configuration"},browser:{label:"Browser",description:"Browser automation settings"},ui:{label:"UI",description:"User interface preferences"},models:{label:"Models",description:"AI model configurations and providers"},bindings:{label:"Bindings",description:"Key bindings and shortcuts"},broadcast:{label:"Broadcast",description:"Broadcast and notification settings"},audio:{label:"Audio",description:"Audio input/output settings"},session:{label:"Session",description:"Session management and persistence"},cron:{label:"Cron",description:"Scheduled tasks and automation"},web:{label:"Web",description:"Web server and API settings"},discovery:{label:"Discovery",description:"Service discovery and networking"},canvasHost:{label:"Canvas Host",description:"Canvas rendering and display"},talk:{label:"Talk",description:"Voice and speech settings"},plugins:{label:"Plugins",description:"Plugin management and extensions"}};function ja(e){return za[e]??za.default}function th(e,t,n){if(!n)return!0;const s=n.toLowerCase(),i=gi[e];return e.toLowerCase().includes(s)||i&&(i.label.toLowerCase().includes(s)||i.description.toLowerCase().includes(s))?!0:vt(t,s)}function vt(e,t){if(e.title?.toLowerCase().includes(t)||e.description?.toLowerCase().includes(t)||e.enum?.some(s=>String(s).toLowerCase().includes(t)))return!0;if(e.properties){for(const[s,i]of Object.entries(e.properties))if(s.toLowerCase().includes(t)||vt(i,t))return!0}if(e.items){const s=Array.isArray(e.items)?e.items:[e.items];for(const i of s)if(i&&vt(i,t))return!0}if(e.additionalProperties&&typeof e.additionalProperties=="object"&&vt(e.additionalProperties,t))return!0;const n=e.anyOf??e.oneOf??e.allOf;if(n){for(const s of n)if(s&&vt(s,t))return!0}return!1}function nh(e){if(!e.schema)return c`<div class="muted">Schema unavailable.</div>`;const t=e.schema,n=e.value??{};if(ue(t)!=="object"||!t.properties)return c`<div class="callout danger">Unsupported schema. Use Raw.</div>`;const s=new Set(e.unsupportedPaths??[]),i=t.properties,a=e.searchQuery??"",o=e.activeSection,r=e.activeSubsection??null,p=Object.entries(i).sort((u,g)=>{const v=te([u[0]],e.uiHints)?.order??50,y=te([g[0]],e.uiHints)?.order??50;return v!==y?v-y:u[0].localeCompare(g[0])}).filter(([u,g])=>!(o&&u!==o||a&&!th(u,g,a)));let d=null;if(o&&r&&p.length===1){const u=p[0]?.[1];u&&ue(u)==="object"&&u.properties&&u.properties[r]&&(d={sectionKey:o,subsectionKey:r,schema:u.properties[r]})}return p.length===0?c`
|
|
604
604
|
<div class="config-empty">
|
|
605
605
|
<div class="config-empty__icon">${W.search}</div>
|
|
606
606
|
<div class="config-empty__text">
|
|
@@ -609,7 +609,7 @@ ${e.sidebarContent}
|
|
|
609
609
|
</div>
|
|
610
610
|
`:c`
|
|
611
611
|
<div class="config-form config-form--modern">
|
|
612
|
-
${d?(()=>{const{sectionKey:u,subsectionKey:g,schema:v}=d,
|
|
612
|
+
${d?(()=>{const{sectionKey:u,subsectionKey:g,schema:v}=d,y=te([u,g],e.uiHints),$=y?.label??v.title??we(g),A=y?.help??v.description??"",_=n[u],L=_&&typeof _=="object"?_[g]:void 0,P=`config-section-${u}-${g}`;return c`
|
|
613
613
|
<section class="config-section-card" id=${P}>
|
|
614
614
|
<div class="config-section-card__header">
|
|
615
615
|
<span class="config-section-card__icon">${ja(u)}</span>
|
|
@@ -637,7 +637,7 @@ ${e.sidebarContent}
|
|
|
637
637
|
</section>
|
|
638
638
|
`})}
|
|
639
639
|
</div>
|
|
640
|
-
`}const ch=new Set(["title","description","default","nullable"]);function dh(e){return Object.keys(e??{}).filter(n=>!ch.has(n)).length===0}function wr(e){const t=e.filter(i=>i!=null),n=t.length!==e.length,s=[];for(const i of t)s.some(a=>Object.is(a,i))||s.push(i);return{enumValues:s,nullable:n}}function $r(e){return!e||typeof e!="object"?{schema:null,unsupportedPaths:["<root>"]}:wt(e,[])}function wt(e,t){const n=new Set,s={...e},i=xn(t)||"<root>";if(e.anyOf||e.oneOf||e.allOf){const r=uh(e,t);return r||{schema:e,unsupportedPaths:[i]}}const a=Array.isArray(e.type)&&e.type.includes("null"),o=pe(e)??(e.properties||e.additionalProperties?"object":void 0);if(s.type=o??e.type,s.nullable=a||e.nullable,s.enum){const{enumValues:r,nullable:l}=wr(s.enum);s.enum=r,l&&(s.nullable=!0),r.length===0&&n.add(i)}if(o==="object"){const r=e.properties??{},l={};for(const[p,d]of Object.entries(r)){const u=wt(d,[...t,p]);u.schema&&(l[p]=u.schema);for(const g of u.unsupportedPaths)n.add(g)}if(s.properties=l,e.additionalProperties===!0)n.add(i);else if(e.additionalProperties===!1)s.additionalProperties=!1;else if(e.additionalProperties&&typeof e.additionalProperties=="object"&&!dh(e.additionalProperties)){const p=wt(e.additionalProperties,[...t,"*"]);s.additionalProperties=p.schema??e.additionalProperties,p.unsupportedPaths.length>0&&n.add(i)}}else if(o==="array"){const r=Array.isArray(e.items)?e.items[0]:e.items;if(!r)n.add(i);else{const l=wt(r,[...t,"*"]);s.items=l.schema??r,l.unsupportedPaths.length>0&&n.add(i)}}else o!=="string"&&o!=="number"&&o!=="integer"&&o!=="boolean"&&!s.enum&&n.add(i);return{schema:s,unsupportedPaths:Array.from(n)}}function uh(e,t){if(e.allOf)return null;const n=e.anyOf??e.oneOf;if(!n)return null;const s=[],i=[];let a=!1;for(const r of n){if(!r||typeof r!="object")return null;if(Array.isArray(r.enum)){const{enumValues:l,nullable:p}=wr(r.enum);s.push(...l),p&&(a=!0);continue}if("const"in r){if(r.const==null){a=!0;continue}s.push(r.const);continue}if(pe(r)==="null"){a=!0;continue}i.push(r)}if(s.length>0&&i.length===0){const r=[];for(const l of s)r.some(p=>Object.is(p,l))||r.push(l);return{schema:{...e,enum:r,nullable:a,anyOf:void 0,oneOf:void 0,allOf:void 0},unsupportedPaths:[]}}if(i.length===1){const r=wt(i[0],t);return r.schema&&(r.schema.nullable=a||r.schema.nullable),r}const o=["string","number","integer","boolean"];return i.length>0&&s.length===0&&i.every(r=>r.type&&o.includes(String(r.type)))?{schema:{...e,nullable:a},unsupportedPaths:[]}:null}const Ts={all:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>`,env:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>`,update:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>`,agents:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"></path><circle cx="8" cy="14" r="1"></circle><circle cx="16" cy="14" r="1"></circle></svg>`,auth:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><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>`,channels:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>`,messages:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>`,commands:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`,hooks:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><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><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>`,skills:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>`,tools:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><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"></path></svg>`,gateway:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,wizard:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 4V2"></path><path d="M15 16v-2"></path><path d="M8 9h2"></path><path d="M20 9h2"></path><path d="M17.8 11.8 19 13"></path><path d="M15 9h0"></path><path d="M17.8 6.2 19 5"></path><path d="m3 21 9-9"></path><path d="M12.2 6.2 11 5"></path></svg>`,meta:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path></svg>`,logging:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,browser:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4"></circle><line x1="21.17" y1="8" x2="12" y2="8"></line><line x1="3.95" y1="6.06" x2="8.54" y2="14"></line><line x1="10.88" y1="21.94" x2="15.46" y2="14"></line></svg>`,ui:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>`,models:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>`,bindings:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>`,broadcast:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path><circle cx="12" cy="12" r="2"></circle><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path></svg>`,audio:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>`,session:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>`,cron:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`,web:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,discovery:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>`,canvasHost:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>`,talk:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>`,plugins:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2v6"></path><path d="m4.93 10.93 4.24 4.24"></path><path d="M2 12h6"></path><path d="m4.93 13.07 4.24-4.24"></path><path d="M12 22v-6"></path><path d="m19.07 13.07-4.24-4.24"></path><path d="M22 12h-6"></path><path d="m19.07 10.93-4.24 4.24"></path></svg>`,default:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>`},qa=[{key:"env",label:"Environment"},{key:"update",label:"Updates"},{key:"agents",label:"Agents"},{key:"auth",label:"Authentication"},{key:"channels",label:"Channels"},{key:"messages",label:"Messages"},{key:"commands",label:"Commands"},{key:"hooks",label:"Hooks"},{key:"skills",label:"Skills"},{key:"tools",label:"Tools"},{key:"gateway",label:"Gateway"},{key:"wizard",label:"Setup Wizard"}],Ga="__all__";function Wa(e){return Ts[e]??Ts.default}function ph(e,t){const n=gi[e];return n||{label:t?.title??we(e),description:t?.description??""}}function hh(e){const{key:t,schema:n,uiHints:s}=e;if(!n||pe(n)!=="object"||!n.properties)return[];const i=Object.entries(n.properties).map(([a,o])=>{const r=te([t,a],s),l=r?.label??o.title??we(a),p=r?.help??o.description??"",d=r?.order??50;return{key:a,label:l,description:p,order:d}});return i.sort((a,o)=>a.order!==o.order?a.order-o.order:a.key.localeCompare(o.key)),i}function fh(e,t){if(!e||!t)return[];const n=[];function s(i,a,o){if(i===a)return;if(typeof i!=typeof a){n.push({path:o,from:i,to:a});return}if(typeof i!="object"||i===null||a===null){i!==a&&n.push({path:o,from:i,to:a});return}if(Array.isArray(i)&&Array.isArray(a)){JSON.stringify(i)!==JSON.stringify(a)&&n.push({path:o,from:i,to:a});return}const r=i,l=a,p=new Set([...Object.keys(r),...Object.keys(l)]);for(const d of p)s(r[d],l[d],o?`${o}.${d}`:d)}return s(e,t,""),n}function Va(e,t=40){let n;try{n=JSON.stringify(e)??String(e)}catch{n=String(e)}return n.length<=t?n:n.slice(0,t-3)+"..."}function gh(e){const t=e.valid==null?"unknown":e.valid?"valid":"invalid",n=$r(e.schema),s=n.schema?n.unsupportedPaths.length>0:!1,i=n.schema?.properties??{},a=qa.filter(C=>C.key in i),o=new Set(qa.map(C=>C.key)),r=Object.keys(i).filter(C=>!o.has(C)).map(C=>({key:C,label:C.charAt(0).toUpperCase()+C.slice(1)})),l=[...a,...r],p=e.activeSection&&n.schema&&pe(n.schema)==="object"?n.schema.properties?.[e.activeSection]:void 0,d=e.activeSection?ph(e.activeSection,p):null,u=e.activeSection?hh({key:e.activeSection,schema:p,uiHints:e.uiHints}):[],g=e.formMode==="form"&&!!e.activeSection&&u.length>0,v=e.activeSubsection===Ga,m=e.searchQuery||v?null:e.activeSubsection??u[0]?.key??null,$=e.formMode==="form"?fh(e.originalValue,e.formValue):[],A=e.formMode==="raw"&&e.raw!==e.originalRaw,_=e.formMode==="form"?$.length>0:A,L=!!e.formValue&&!e.loading&&!!n.schema,P=e.connected&&!e.saving&&_&&(e.formMode==="raw"?!0:L),M=e.connected&&!e.applying&&!e.updating&&_&&(e.formMode==="raw"?!0:L),E=e.connected&&!e.applying&&!e.updating;return c`
|
|
640
|
+
`}const sh=new Set(["title","description","default","nullable"]);function ih(e){return Object.keys(e??{}).filter(n=>!sh.has(n)).length===0}function wr(e){const t=e.filter(i=>i!=null),n=t.length!==e.length,s=[];for(const i of t)s.some(a=>Object.is(a,i))||s.push(i);return{enumValues:s,nullable:n}}function $r(e){return!e||typeof e!="object"?{schema:null,unsupportedPaths:["<root>"]}:wt(e,[])}function wt(e,t){const n=new Set,s={...e},i=$n(t)||"<root>";if(e.anyOf||e.oneOf||e.allOf){const r=ah(e,t);return r||{schema:e,unsupportedPaths:[i]}}const a=Array.isArray(e.type)&&e.type.includes("null"),o=ue(e)??(e.properties||e.additionalProperties?"object":void 0);if(s.type=o??e.type,s.nullable=a||e.nullable,s.enum){const{enumValues:r,nullable:l}=wr(s.enum);s.enum=r,l&&(s.nullable=!0),r.length===0&&n.add(i)}if(o==="object"){const r=e.properties??{},l={};for(const[p,d]of Object.entries(r)){const u=wt(d,[...t,p]);u.schema&&(l[p]=u.schema);for(const g of u.unsupportedPaths)n.add(g)}if(s.properties=l,e.additionalProperties===!0)n.add(i);else if(e.additionalProperties===!1)s.additionalProperties=!1;else if(e.additionalProperties&&typeof e.additionalProperties=="object"&&!ih(e.additionalProperties)){const p=wt(e.additionalProperties,[...t,"*"]);s.additionalProperties=p.schema??e.additionalProperties,p.unsupportedPaths.length>0&&n.add(i)}}else if(o==="array"){const r=Array.isArray(e.items)?e.items[0]:e.items;if(!r)n.add(i);else{const l=wt(r,[...t,"*"]);s.items=l.schema??r,l.unsupportedPaths.length>0&&n.add(i)}}else o!=="string"&&o!=="number"&&o!=="integer"&&o!=="boolean"&&!s.enum&&n.add(i);return{schema:s,unsupportedPaths:Array.from(n)}}function ah(e,t){if(e.allOf)return null;const n=e.anyOf??e.oneOf;if(!n)return null;const s=[],i=[];let a=!1;for(const r of n){if(!r||typeof r!="object")return null;if(Array.isArray(r.enum)){const{enumValues:l,nullable:p}=wr(r.enum);s.push(...l),p&&(a=!0);continue}if("const"in r){if(r.const==null){a=!0;continue}s.push(r.const);continue}if(ue(r)==="null"){a=!0;continue}i.push(r)}if(s.length>0&&i.length===0){const r=[];for(const l of s)r.some(p=>Object.is(p,l))||r.push(l);return{schema:{...e,enum:r,nullable:a,anyOf:void 0,oneOf:void 0,allOf:void 0},unsupportedPaths:[]}}if(i.length===1){const r=wt(i[0],t);return r.schema&&(r.schema.nullable=a||r.schema.nullable),r}const o=["string","number","integer","boolean"];return i.length>0&&s.length===0&&i.every(r=>r.type&&o.includes(String(r.type)))?{schema:{...e,nullable:a},unsupportedPaths:[]}:null}const Ts={all:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>`,env:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>`,update:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>`,agents:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"></path><circle cx="8" cy="14" r="1"></circle><circle cx="16" cy="14" r="1"></circle></svg>`,auth:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><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>`,channels:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>`,messages:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>`,commands:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`,hooks:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><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><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>`,skills:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>`,tools:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><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"></path></svg>`,gateway:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,wizard:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 4V2"></path><path d="M15 16v-2"></path><path d="M8 9h2"></path><path d="M20 9h2"></path><path d="M17.8 11.8 19 13"></path><path d="M15 9h0"></path><path d="M17.8 6.2 19 5"></path><path d="m3 21 9-9"></path><path d="M12.2 6.2 11 5"></path></svg>`,meta:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path></svg>`,logging:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,browser:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4"></circle><line x1="21.17" y1="8" x2="12" y2="8"></line><line x1="3.95" y1="6.06" x2="8.54" y2="14"></line><line x1="10.88" y1="21.94" x2="15.46" y2="14"></line></svg>`,ui:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>`,models:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>`,bindings:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>`,broadcast:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path><circle cx="12" cy="12" r="2"></circle><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path></svg>`,audio:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>`,session:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>`,cron:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`,web:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,discovery:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>`,canvasHost:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>`,talk:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>`,plugins:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2v6"></path><path d="m4.93 10.93 4.24 4.24"></path><path d="M2 12h6"></path><path d="m4.93 13.07 4.24-4.24"></path><path d="M12 22v-6"></path><path d="m19.07 13.07-4.24-4.24"></path><path d="M22 12h-6"></path><path d="m19.07 10.93-4.24 4.24"></path></svg>`,default:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>`},qa=[{key:"env",label:"Environment"},{key:"update",label:"Updates"},{key:"agents",label:"Agents"},{key:"auth",label:"Authentication"},{key:"channels",label:"Channels"},{key:"messages",label:"Messages"},{key:"commands",label:"Commands"},{key:"hooks",label:"Hooks"},{key:"skills",label:"Skills"},{key:"tools",label:"Tools"},{key:"gateway",label:"Gateway"},{key:"wizard",label:"Setup Wizard"}],Ga="__all__";function Wa(e){return Ts[e]??Ts.default}function oh(e,t){const n=gi[e];return n||{label:t?.title??we(e),description:t?.description??""}}function rh(e){const{key:t,schema:n,uiHints:s}=e;if(!n||ue(n)!=="object"||!n.properties)return[];const i=Object.entries(n.properties).map(([a,o])=>{const r=te([t,a],s),l=r?.label??o.title??we(a),p=r?.help??o.description??"",d=r?.order??50;return{key:a,label:l,description:p,order:d}});return i.sort((a,o)=>a.order!==o.order?a.order-o.order:a.key.localeCompare(o.key)),i}function lh(e,t){if(!e||!t)return[];const n=[];function s(i,a,o){if(i===a)return;if(typeof i!=typeof a){n.push({path:o,from:i,to:a});return}if(typeof i!="object"||i===null||a===null){i!==a&&n.push({path:o,from:i,to:a});return}if(Array.isArray(i)&&Array.isArray(a)){JSON.stringify(i)!==JSON.stringify(a)&&n.push({path:o,from:i,to:a});return}const r=i,l=a,p=new Set([...Object.keys(r),...Object.keys(l)]);for(const d of p)s(r[d],l[d],o?`${o}.${d}`:d)}return s(e,t,""),n}function Va(e,t=40){let n;try{n=JSON.stringify(e)??String(e)}catch{n=String(e)}return n.length<=t?n:n.slice(0,t-3)+"..."}function ch(e){const t=e.valid==null?"unknown":e.valid?"valid":"invalid",n=$r(e.schema),s=n.schema?n.unsupportedPaths.length>0:!1,i=n.schema?.properties??{},a=qa.filter(E=>E.key in i),o=new Set(qa.map(E=>E.key)),r=Object.keys(i).filter(E=>!o.has(E)).map(E=>({key:E,label:E.charAt(0).toUpperCase()+E.slice(1)})),l=[...a,...r],p=e.activeSection&&n.schema&&ue(n.schema)==="object"?n.schema.properties?.[e.activeSection]:void 0,d=e.activeSection?oh(e.activeSection,p):null,u=e.activeSection?rh({key:e.activeSection,schema:p,uiHints:e.uiHints}):[],g=e.formMode==="form"&&!!e.activeSection&&u.length>0,v=e.activeSubsection===Ga,y=e.searchQuery||v?null:e.activeSubsection??u[0]?.key??null,$=e.formMode==="form"?lh(e.originalValue,e.formValue):[],A=e.formMode==="raw"&&e.raw!==e.originalRaw,_=e.formMode==="form"?$.length>0:A,L=!!e.formValue&&!e.loading&&!!n.schema,P=e.connected&&!e.saving&&_&&(e.formMode==="raw"?!0:L),M=e.connected&&!e.applying&&!e.updating&&_&&(e.formMode==="raw"?!0:L),T=e.connected&&!e.applying&&!e.updating;return c`
|
|
641
641
|
<div class="config-layout">
|
|
642
642
|
<!-- Sidebar -->
|
|
643
643
|
<aside class="config-sidebar">
|
|
@@ -657,7 +657,7 @@ ${e.sidebarContent}
|
|
|
657
657
|
class="config-search__input"
|
|
658
658
|
placeholder="Search settings..."
|
|
659
659
|
.value=${e.searchQuery}
|
|
660
|
-
@input=${
|
|
660
|
+
@input=${E=>e.onSearchChange(E.target.value)}
|
|
661
661
|
/>
|
|
662
662
|
${e.searchQuery?c`
|
|
663
663
|
<button
|
|
@@ -676,13 +676,13 @@ ${e.sidebarContent}
|
|
|
676
676
|
<span class="config-nav__icon">${Ts.all}</span>
|
|
677
677
|
<span class="config-nav__label">All Settings</span>
|
|
678
678
|
</button>
|
|
679
|
-
${l.map(
|
|
679
|
+
${l.map(E=>c`
|
|
680
680
|
<button
|
|
681
|
-
class="config-nav__item ${e.activeSection===
|
|
682
|
-
@click=${()=>e.onSectionChange(
|
|
681
|
+
class="config-nav__item ${e.activeSection===E.key?"active":""}"
|
|
682
|
+
@click=${()=>e.onSectionChange(E.key)}
|
|
683
683
|
>
|
|
684
|
-
<span class="config-nav__icon">${Wa(
|
|
685
|
-
<span class="config-nav__label">${
|
|
684
|
+
<span class="config-nav__icon">${Wa(E.key)}</span>
|
|
685
|
+
<span class="config-nav__label">${E.label}</span>
|
|
686
686
|
</button>
|
|
687
687
|
`)}
|
|
688
688
|
</nav>
|
|
@@ -738,7 +738,7 @@ ${e.sidebarContent}
|
|
|
738
738
|
</button>
|
|
739
739
|
<button
|
|
740
740
|
class="btn btn--sm"
|
|
741
|
-
?disabled=${!
|
|
741
|
+
?disabled=${!T}
|
|
742
742
|
@click=${e.onUpdate}
|
|
743
743
|
>
|
|
744
744
|
${e.updating?"Updating…":"Update"}
|
|
@@ -756,13 +756,13 @@ ${e.sidebarContent}
|
|
|
756
756
|
</svg>
|
|
757
757
|
</summary>
|
|
758
758
|
<div class="config-diff__content">
|
|
759
|
-
${$.map(
|
|
759
|
+
${$.map(E=>c`
|
|
760
760
|
<div class="config-diff__item">
|
|
761
|
-
<div class="config-diff__path">${
|
|
761
|
+
<div class="config-diff__path">${E.path}</div>
|
|
762
762
|
<div class="config-diff__values">
|
|
763
|
-
<span class="config-diff__from">${Va(
|
|
763
|
+
<span class="config-diff__from">${Va(E.from)}</span>
|
|
764
764
|
<span class="config-diff__arrow">→</span>
|
|
765
|
-
<span class="config-diff__to">${Va(
|
|
765
|
+
<span class="config-diff__to">${Va(E.to)}</span>
|
|
766
766
|
</div>
|
|
767
767
|
</div>
|
|
768
768
|
`)}
|
|
@@ -783,18 +783,18 @@ ${e.sidebarContent}
|
|
|
783
783
|
${g?c`
|
|
784
784
|
<div class="config-subnav">
|
|
785
785
|
<button
|
|
786
|
-
class="config-subnav__item ${
|
|
786
|
+
class="config-subnav__item ${y===null?"active":""}"
|
|
787
787
|
@click=${()=>e.onSubsectionChange(Ga)}
|
|
788
788
|
>
|
|
789
789
|
All
|
|
790
790
|
</button>
|
|
791
|
-
${u.map(
|
|
791
|
+
${u.map(E=>c`
|
|
792
792
|
<button
|
|
793
|
-
class="config-subnav__item ${
|
|
794
|
-
title=${
|
|
795
|
-
@click=${()=>e.onSubsectionChange(
|
|
793
|
+
class="config-subnav__item ${y===E.key?"active":""}"
|
|
794
|
+
title=${E.description||E.label}
|
|
795
|
+
@click=${()=>e.onSubsectionChange(E.key)}
|
|
796
796
|
>
|
|
797
|
-
${
|
|
797
|
+
${E.label}
|
|
798
798
|
</button>
|
|
799
799
|
`)}
|
|
800
800
|
</div>
|
|
@@ -806,7 +806,7 @@ ${e.sidebarContent}
|
|
|
806
806
|
${e.schemaLoading?c`<div class="config-loading">
|
|
807
807
|
<div class="config-loading__spinner"></div>
|
|
808
808
|
<span>Loading schema…</span>
|
|
809
|
-
</div>`:
|
|
809
|
+
</div>`:nh({schema:n.schema,uiHints:e.uiHints,value:e.formValue,disabled:e.loading||!e.formValue,unsupportedPaths:n.unsupportedPaths,onPatch:e.onFormPatch,searchQuery:e.searchQuery,activeSection:e.activeSection,activeSubsection:y})}
|
|
810
810
|
${s?c`<div class="callout danger" style="margin-top: 12px;">
|
|
811
811
|
Form view can't safely edit some fields.
|
|
812
812
|
Use Raw to avoid losing config entries.
|
|
@@ -816,7 +816,7 @@ ${e.sidebarContent}
|
|
|
816
816
|
<span>Raw JSON5</span>
|
|
817
817
|
<textarea
|
|
818
818
|
.value=${e.raw}
|
|
819
|
-
@input=${
|
|
819
|
+
@input=${E=>e.onRawChange(E.target.value)}
|
|
820
820
|
></textarea>
|
|
821
821
|
</label>
|
|
822
822
|
`}
|
|
@@ -827,13 +827,13 @@ ${e.sidebarContent}
|
|
|
827
827
|
</div>`:f}
|
|
828
828
|
</main>
|
|
829
829
|
</div>
|
|
830
|
-
`}function
|
|
830
|
+
`}function dh(e){if(!e&&e!==0)return"n/a";const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);return n<60?`${n}m`:`${Math.round(n/60)}h`}function uh(e,t){const n=t.snapshot,s=n?.channels;if(!n||!s)return!1;const i=s[e],a=typeof i?.configured=="boolean"&&i.configured,o=typeof i?.running=="boolean"&&i.running,r=typeof i?.connected=="boolean"&&i.connected,p=(n.channelAccounts?.[e]??[]).some(d=>d.configured||d.running||d.connected);return a||o||r||p}function ph(e,t){return t?.[e]?.length??0}function xr(e,t){const n=ph(e,t);return n<2?f:c`<div class="account-count">Accounts (${n})</div>`}function hh(e,t){let n=e;for(const s of t){if(!n)return null;const i=ue(n);if(i==="object"){const a=n.properties??{};if(typeof s=="string"&&a[s]){n=a[s];continue}const o=n.additionalProperties;if(typeof s=="string"&&o&&typeof o=="object"){n=o;continue}return null}if(i==="array"){if(typeof s!="number")return null;n=(Array.isArray(n.items)?n.items[0]:n.items)??null;continue}return null}return n}function fh(e,t){const s=(e.channels??{})[t],i=e[t];return(s&&typeof s=="object"?s:null)??(i&&typeof i=="object"?i:null)??{}}function gh(e){const t=$r(e.schema),n=t.schema;if(!n)return c`<div class="callout danger">Schema unavailable. Use Raw.</div>`;const s=hh(n,["channels",e.channelId]);if(!s)return c`<div class="callout danger">Channel config schema unavailable.</div>`;const i=e.configValue??{},a=fh(i,e.channelId);return c`
|
|
831
831
|
<div class="config-form">
|
|
832
832
|
${be({schema:s,value:a,path:["channels",e.channelId],hints:e.uiHints,unsupported:new Set(t.unsupportedPaths),disabled:e.disabled,showLabel:!1,onPatch:e.onPatch})}
|
|
833
833
|
</div>
|
|
834
834
|
`}function $e(e){const{channelId:t,props:n}=e,s=n.configSaving||n.configSchemaLoading;return c`
|
|
835
835
|
<div style="margin-top: 16px;">
|
|
836
|
-
${n.configSchemaLoading?c`<div class="muted">Loading config schema…</div
|
|
836
|
+
${n.configSchemaLoading?c`<div class="muted">Loading config schema…</div>`:gh({channelId:t,configValue:n.configForm,schema:n.configSchema,uiHints:n.configUiHints,disabled:s,onPatch:n.onConfigPatch})}
|
|
837
837
|
<div class="row" style="margin-top: 12px;">
|
|
838
838
|
<button
|
|
839
839
|
class="btn primary"
|
|
@@ -851,7 +851,7 @@ ${e.sidebarContent}
|
|
|
851
851
|
</button>
|
|
852
852
|
</div>
|
|
853
853
|
</div>
|
|
854
|
-
`}function
|
|
854
|
+
`}function vh(e){const{props:t,discord:n,accountCountLabel:s}=e;return c`
|
|
855
855
|
<div class="card">
|
|
856
856
|
<div class="card-title">Discord</div>
|
|
857
857
|
<div class="card-sub">Bot status and channel configuration.</div>
|
|
@@ -893,7 +893,7 @@ ${e.sidebarContent}
|
|
|
893
893
|
</button>
|
|
894
894
|
</div>
|
|
895
895
|
</div>
|
|
896
|
-
`}function
|
|
896
|
+
`}function mh(e){const{props:t,googleChat:n,accountCountLabel:s}=e;return c`
|
|
897
897
|
<div class="card">
|
|
898
898
|
<div class="card-title">Google Chat</div>
|
|
899
899
|
<div class="card-sub">Chat API webhook status and channel configuration.</div>
|
|
@@ -945,7 +945,7 @@ ${e.sidebarContent}
|
|
|
945
945
|
</button>
|
|
946
946
|
</div>
|
|
947
947
|
</div>
|
|
948
|
-
`}function
|
|
948
|
+
`}function yh(e){const{props:t,imessage:n,accountCountLabel:s}=e;return c`
|
|
949
949
|
<div class="card">
|
|
950
950
|
<div class="card-title">iMessage</div>
|
|
951
951
|
<div class="card-sub">macOS bridge status and channel configuration.</div>
|
|
@@ -987,14 +987,14 @@ ${e.sidebarContent}
|
|
|
987
987
|
</button>
|
|
988
988
|
</div>
|
|
989
989
|
</div>
|
|
990
|
-
`}function
|
|
990
|
+
`}function bh(e){const{values:t,original:n}=e;return t.name!==n.name||t.displayName!==n.displayName||t.about!==n.about||t.picture!==n.picture||t.banner!==n.banner||t.website!==n.website||t.nip05!==n.nip05||t.lud16!==n.lud16}function wh(e){const{state:t,callbacks:n,accountId:s}=e,i=bh(t),a=(r,l,p={})=>{const{type:d="text",placeholder:u,maxLength:g,help:v}=p,y=t.values[r]??"",$=t.fieldErrors[r],A=`nostr-profile-${r}`;return d==="textarea"?c`
|
|
991
991
|
<div class="form-field" style="margin-bottom: 12px;">
|
|
992
992
|
<label for="${A}" style="display: block; margin-bottom: 4px; font-weight: 500;">
|
|
993
993
|
${l}
|
|
994
994
|
</label>
|
|
995
995
|
<textarea
|
|
996
996
|
id="${A}"
|
|
997
|
-
.value=${
|
|
997
|
+
.value=${y}
|
|
998
998
|
placeholder=${u??""}
|
|
999
999
|
maxlength=${g??2e3}
|
|
1000
1000
|
rows="3"
|
|
@@ -1013,7 +1013,7 @@ ${e.sidebarContent}
|
|
|
1013
1013
|
<input
|
|
1014
1014
|
id="${A}"
|
|
1015
1015
|
type=${d}
|
|
1016
|
-
.value=${
|
|
1016
|
+
.value=${y}
|
|
1017
1017
|
placeholder=${u??""}
|
|
1018
1018
|
maxlength=${g??256}
|
|
1019
1019
|
style="width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px;"
|
|
@@ -1105,10 +1105,10 @@ ${e.sidebarContent}
|
|
|
1105
1105
|
You have unsaved changes
|
|
1106
1106
|
</div>`:f}
|
|
1107
1107
|
</div>
|
|
1108
|
-
`}function
|
|
1108
|
+
`}function $h(e){const t={name:e?.name??"",displayName:e?.displayName??"",about:e?.about??"",picture:e?.picture??"",banner:e?.banner??"",website:e?.website??"",nip05:e?.nip05??"",lud16:e?.lud16??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e?.banner||e?.website||e?.nip05||e?.lud16)}}function Ya(e){return e?e.length<=20?e:`${e.slice(0,8)}...${e.slice(-8)}`:"n/a"}function xh(e){const{props:t,nostr:n,nostrAccounts:s,accountCountLabel:i,profileFormState:a,profileFormCallbacks:o,onEditProfile:r}=e,l=s[0],p=n?.configured??l?.configured??!1,d=n?.running??l?.running??!1,u=n?.publicKey??l?.publicKey,g=n?.lastStartAt??l?.lastStartAt??null,v=n?.lastError??l?.lastError??null,y=s.length>1,$=a!=null,A=L=>{const P=L.publicKey,M=L.profile,T=M?.displayName??M?.name??L.name??L.accountId;return c`
|
|
1109
1109
|
<div class="account-card">
|
|
1110
1110
|
<div class="account-card-header">
|
|
1111
|
-
<div class="account-card-title">${
|
|
1111
|
+
<div class="account-card-title">${T}</div>
|
|
1112
1112
|
<div class="account-card-id">${L.accountId}</div>
|
|
1113
1113
|
</div>
|
|
1114
1114
|
<div class="status-list account-card-status">
|
|
@@ -1133,7 +1133,7 @@ ${e.sidebarContent}
|
|
|
1133
1133
|
`:f}
|
|
1134
1134
|
</div>
|
|
1135
1135
|
</div>
|
|
1136
|
-
`},_=()=>{if($&&o)return
|
|
1136
|
+
`},_=()=>{if($&&o)return wh({state:a,callbacks:o,accountId:s[0]?.accountId??"default"});const L=l?.profile??n?.profile,{name:P,displayName:M,about:T,picture:E,nip05:pe}=L??{},xn=P||M||T||E||pe;return c`
|
|
1137
1137
|
<div style="margin-top: 16px; padding: 12px; background: var(--bg-secondary); border-radius: 8px;">
|
|
1138
1138
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
|
|
1139
1139
|
<div style="font-weight: 500;">Profile</div>
|
|
@@ -1147,22 +1147,22 @@ ${e.sidebarContent}
|
|
|
1147
1147
|
</button>
|
|
1148
1148
|
`:f}
|
|
1149
1149
|
</div>
|
|
1150
|
-
${
|
|
1150
|
+
${xn?c`
|
|
1151
1151
|
<div class="status-list">
|
|
1152
|
-
${
|
|
1152
|
+
${E?c`
|
|
1153
1153
|
<div style="margin-bottom: 8px;">
|
|
1154
1154
|
<img
|
|
1155
|
-
src=${
|
|
1155
|
+
src=${E}
|
|
1156
1156
|
alt="Profile picture"
|
|
1157
1157
|
style="width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color);"
|
|
1158
|
-
@error=${
|
|
1158
|
+
@error=${An=>{An.target.style.display="none"}}
|
|
1159
1159
|
/>
|
|
1160
1160
|
</div>
|
|
1161
1161
|
`:f}
|
|
1162
1162
|
${P?c`<div><span class="label">Name</span><span>${P}</span></div>`:f}
|
|
1163
1163
|
${M?c`<div><span class="label">Display Name</span><span>${M}</span></div>`:f}
|
|
1164
|
-
${
|
|
1165
|
-
${
|
|
1164
|
+
${T?c`<div><span class="label">About</span><span style="max-width: 300px; overflow: hidden; text-overflow: ellipsis;">${T}</span></div>`:f}
|
|
1165
|
+
${pe?c`<div><span class="label">NIP-05</span><span>${pe}</span></div>`:f}
|
|
1166
1166
|
</div>
|
|
1167
1167
|
`:c`
|
|
1168
1168
|
<div style="color: var(--text-muted); font-size: 13px;">
|
|
@@ -1176,7 +1176,7 @@ ${e.sidebarContent}
|
|
|
1176
1176
|
<div class="card-sub">Decentralized DMs via Nostr relays (NIP-04).</div>
|
|
1177
1177
|
${i}
|
|
1178
1178
|
|
|
1179
|
-
${
|
|
1179
|
+
${y?c`
|
|
1180
1180
|
<div class="account-card-list">
|
|
1181
1181
|
${s.map(L=>A(L))}
|
|
1182
1182
|
</div>
|
|
@@ -1213,7 +1213,7 @@ ${e.sidebarContent}
|
|
|
1213
1213
|
<button class="btn" @click=${()=>t.onRefresh(!1)}>Refresh</button>
|
|
1214
1214
|
</div>
|
|
1215
1215
|
</div>
|
|
1216
|
-
`}function
|
|
1216
|
+
`}function Ah(e){const{props:t,signal:n,accountCountLabel:s}=e;return c`
|
|
1217
1217
|
<div class="card">
|
|
1218
1218
|
<div class="card-title">Signal</div>
|
|
1219
1219
|
<div class="card-sub">signal-cli status and channel configuration.</div>
|
|
@@ -1259,7 +1259,7 @@ ${e.sidebarContent}
|
|
|
1259
1259
|
</button>
|
|
1260
1260
|
</div>
|
|
1261
1261
|
</div>
|
|
1262
|
-
`}function
|
|
1262
|
+
`}function kh(e){const{props:t,slack:n,accountCountLabel:s}=e;return c`
|
|
1263
1263
|
<div class="card">
|
|
1264
1264
|
<div class="card-title">Slack</div>
|
|
1265
1265
|
<div class="card-sub">Socket mode status and channel configuration.</div>
|
|
@@ -1301,7 +1301,7 @@ ${e.sidebarContent}
|
|
|
1301
1301
|
</button>
|
|
1302
1302
|
</div>
|
|
1303
1303
|
</div>
|
|
1304
|
-
`}function
|
|
1304
|
+
`}function Sh(e){const{props:t,telegram:n,telegramAccounts:s,accountCountLabel:i}=e,a=s.length>1,o=r=>{const p=r.probe?.bot?.username,d=r.name||r.accountId;return c`
|
|
1305
1305
|
<div class="account-card">
|
|
1306
1306
|
<div class="account-card-header">
|
|
1307
1307
|
<div class="account-card-title">
|
|
@@ -1381,7 +1381,7 @@ ${e.sidebarContent}
|
|
|
1381
1381
|
</button>
|
|
1382
1382
|
</div>
|
|
1383
1383
|
</div>
|
|
1384
|
-
`}function
|
|
1384
|
+
`}function _h(e){const{props:t,whatsapp:n,accountCountLabel:s}=e;return c`
|
|
1385
1385
|
<div class="card">
|
|
1386
1386
|
<div class="card-title">WhatsApp</div>
|
|
1387
1387
|
<div class="card-sub">Link WhatsApp Web and monitor connection health.</div>
|
|
@@ -1419,7 +1419,7 @@ ${e.sidebarContent}
|
|
|
1419
1419
|
<div>
|
|
1420
1420
|
<span class="label">Auth age</span>
|
|
1421
1421
|
<span>
|
|
1422
|
-
${n?.authAgeMs!=null?
|
|
1422
|
+
${n?.authAgeMs!=null?dh(n.authAgeMs):"n/a"}
|
|
1423
1423
|
</span>
|
|
1424
1424
|
</div>
|
|
1425
1425
|
</div>
|
|
@@ -1472,9 +1472,9 @@ ${e.sidebarContent}
|
|
|
1472
1472
|
|
|
1473
1473
|
${$e({channelId:"whatsapp",props:t})}
|
|
1474
1474
|
</div>
|
|
1475
|
-
`}function
|
|
1475
|
+
`}function Ch(e){const t=e.snapshot?.channels,n=t?.whatsapp??void 0,s=t?.telegram??void 0,i=t?.discord??null;t?.googlechat;const a=t?.slack??null,o=t?.signal??null,r=t?.imessage??null,l=t?.nostr??null,d=Th(e.snapshot).map((u,g)=>({key:u,enabled:uh(u,e),order:g})).sort((u,g)=>u.enabled!==g.enabled?u.enabled?-1:1:u.order-g.order);return c`
|
|
1476
1476
|
<section class="grid grid-cols-2">
|
|
1477
|
-
${d.map(u=>
|
|
1477
|
+
${d.map(u=>Eh(u.key,e,{whatsapp:n,telegram:s,discord:i,slack:a,signal:o,imessage:r,nostr:l,channelAccounts:e.snapshot?.channelAccounts??null}))}
|
|
1478
1478
|
</section>
|
|
1479
1479
|
|
|
1480
1480
|
<section class="card" style="margin-top: 18px;">
|
|
@@ -1492,7 +1492,7 @@ ${e.sidebarContent}
|
|
|
1492
1492
|
${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
1493
1493
|
</pre>
|
|
1494
1494
|
</section>
|
|
1495
|
-
`}function
|
|
1495
|
+
`}function Th(e){return e?.channelMeta?.length?e.channelMeta.map(t=>t.id):e?.channelOrder?.length?e.channelOrder:["whatsapp","telegram","discord","googlechat","slack","signal","imessage","nostr"]}function Eh(e,t,n){const s=xr(e,n.channelAccounts);switch(e){case"whatsapp":return _h({props:t,whatsapp:n.whatsapp,accountCountLabel:s});case"telegram":return Sh({props:t,telegram:n.telegram,telegramAccounts:n.channelAccounts?.telegram??[],accountCountLabel:s});case"discord":return vh({props:t,discord:n.discord,accountCountLabel:s});case"googlechat":return mh({props:t,accountCountLabel:s});case"slack":return kh({props:t,slack:n.slack,accountCountLabel:s});case"signal":return Ah({props:t,signal:n.signal,accountCountLabel:s});case"imessage":return yh({props:t,imessage:n.imessage,accountCountLabel:s});case"nostr":{const i=n.channelAccounts?.nostr??[],a=i[0],o=a?.accountId??"default",r=a?.profile??null,l=t.nostrProfileAccountId===o?t.nostrProfileFormState:null,p=l?{onFieldChange:t.onNostrProfileFieldChange,onSave:t.onNostrProfileSave,onImport:t.onNostrProfileImport,onCancel:t.onNostrProfileCancel,onToggleAdvanced:t.onNostrProfileToggleAdvanced}:null;return xh({props:t,nostr:n.nostr,nostrAccounts:i,accountCountLabel:s,profileFormState:l,profileFormCallbacks:p,onEditProfile:()=>t.onNostrProfileEdit(o,r)})}default:return Mh(e,t,n.channelAccounts??{})}}function Mh(e,t,n){const s=Ih(t.snapshot,e),i=t.snapshot?.channels?.[e],a=typeof i?.configured=="boolean"?i.configured:void 0,o=typeof i?.running=="boolean"?i.running:void 0,r=typeof i?.connected=="boolean"?i.connected:void 0,l=typeof i?.lastError=="string"?i.lastError:void 0,p=n[e]??[],d=xr(e,n);return c`
|
|
1496
1496
|
<div class="card">
|
|
1497
1497
|
<div class="card-title">${s}</div>
|
|
1498
1498
|
<div class="card-sub">Channel status and configuration.</div>
|
|
@@ -1500,7 +1500,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1500
1500
|
|
|
1501
1501
|
${p.length>0?c`
|
|
1502
1502
|
<div class="account-card-list">
|
|
1503
|
-
${p.map(u=>
|
|
1503
|
+
${p.map(u=>Oh(u))}
|
|
1504
1504
|
</div>
|
|
1505
1505
|
`:c`
|
|
1506
1506
|
<div class="status-list" style="margin-top: 16px;">
|
|
@@ -1525,7 +1525,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1525
1525
|
|
|
1526
1526
|
${$e({channelId:e,props:t})}
|
|
1527
1527
|
</div>
|
|
1528
|
-
`}function
|
|
1528
|
+
`}function Lh(e){return e?.channelMeta?.length?Object.fromEntries(e.channelMeta.map(t=>[t.id,t])):{}}function Ih(e,t){return Lh(e)[t]?.label??e?.channelLabels?.[t]??t}const Rh=600*1e3;function Ar(e){return e.lastInboundAt?Date.now()-e.lastInboundAt<Rh:!1}function Ph(e){return e.running?"Yes":Ar(e)?"Active":"No"}function Nh(e){return e.connected===!0?"Yes":e.connected===!1?"No":Ar(e)?"Active":"n/a"}function Oh(e){const t=Ph(e),n=Nh(e);return c`
|
|
1529
1529
|
<div class="account-card">
|
|
1530
1530
|
<div class="account-card-header">
|
|
1531
1531
|
<div class="account-card-title">${e.name||e.accountId}</div>
|
|
@@ -1555,7 +1555,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1555
1555
|
`:f}
|
|
1556
1556
|
</div>
|
|
1557
1557
|
</div>
|
|
1558
|
-
`}function
|
|
1558
|
+
`}function Dh(e){const t=e.host??"unknown",n=e.ip?`(${e.ip})`:"",s=e.mode??"",i=e.version??"";return`${t} ${n} ${s} ${i}`.trim()}function Bh(e){const t=e.ts??null;return t?O(t):"n/a"}function kr(e){return e?`${kt(e)} (${O(e)})`:"n/a"}function Fh(e){if(e.totalTokens==null)return"n/a";const t=e.totalTokens??0,n=e.contextTokens??0;return n?`${t} / ${n}`:String(t)}function Uh(e){if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Kh(e){const t=e.state??{},n=t.nextRunAtMs?kt(t.nextRunAtMs):"n/a",s=t.lastRunAtMs?kt(t.lastRunAtMs):"n/a";return`${t.lastStatus??"n/a"} · next ${n} · last ${s}`}function Hh(e){const t=e.schedule;return t.kind==="at"?`At ${kt(t.atMs)}`:t.kind==="every"?`Every ${go(t.everyMs)}`:`Cron ${t.expr}${t.tz?` (${t.tz})`:""}`}function zh(e){const t=e.payload;return t.kind==="systemEvent"?`System: ${t.text}`:`Agent: ${t.message}`}function jh(e){const t=["last",...e.channels.filter(Boolean)],n=e.form.channel?.trim();n&&!t.includes(n)&&t.push(n);const s=new Set;return t.filter(i=>s.has(i)?!1:(s.add(i),!0))}function qh(e,t){if(t==="last")return"last";const n=e.channelMeta?.find(s=>s.id===t);return n?.label?n.label:e.channelLabels?.[t]??t}function Gh(e){const t=jh(e);return c`
|
|
1559
1559
|
<section class="grid grid-cols-2">
|
|
1560
1560
|
<div class="card">
|
|
1561
1561
|
<div class="card-title">Scheduler</div>
|
|
@@ -1630,7 +1630,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1630
1630
|
</select>
|
|
1631
1631
|
</label>
|
|
1632
1632
|
</div>
|
|
1633
|
-
${
|
|
1633
|
+
${Wh(e)}
|
|
1634
1634
|
<div class="form-grid" style="margin-top: 12px;">
|
|
1635
1635
|
<label class="field">
|
|
1636
1636
|
<span>Session</span>
|
|
@@ -1688,7 +1688,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1688
1688
|
@change=${n=>e.onFormChange({channel:n.target.value})}
|
|
1689
1689
|
>
|
|
1690
1690
|
${t.map(n=>c`<option value=${n}>
|
|
1691
|
-
${
|
|
1691
|
+
${qh(e,n)}
|
|
1692
1692
|
</option>`)}
|
|
1693
1693
|
</select>
|
|
1694
1694
|
</label>
|
|
@@ -1731,7 +1731,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1731
1731
|
<div class="card-sub">All scheduled jobs stored in the gateway.</div>
|
|
1732
1732
|
${e.jobs.length===0?c`<div class="muted" style="margin-top: 12px;">No jobs yet.</div>`:c`
|
|
1733
1733
|
<div class="list" style="margin-top: 12px;">
|
|
1734
|
-
${e.jobs.map(n=>
|
|
1734
|
+
${e.jobs.map(n=>Vh(n,e))}
|
|
1735
1735
|
</div>
|
|
1736
1736
|
`}
|
|
1737
1737
|
</section>
|
|
@@ -1745,11 +1745,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1745
1745
|
</div>
|
|
1746
1746
|
`:e.runs.length===0?c`<div class="muted" style="margin-top: 12px;">No runs yet.</div>`:c`
|
|
1747
1747
|
<div class="list" style="margin-top: 12px;">
|
|
1748
|
-
${e.runs.map(n=>
|
|
1748
|
+
${e.runs.map(n=>Yh(n))}
|
|
1749
1749
|
</div>
|
|
1750
1750
|
`}
|
|
1751
1751
|
</section>
|
|
1752
|
-
`}function
|
|
1752
|
+
`}function Wh(e){const t=e.form;return t.scheduleKind==="at"?c`
|
|
1753
1753
|
<label class="field" style="margin-top: 12px;">
|
|
1754
1754
|
<span>Run at</span>
|
|
1755
1755
|
<input
|
|
@@ -1796,12 +1796,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1796
1796
|
/>
|
|
1797
1797
|
</label>
|
|
1798
1798
|
</div>
|
|
1799
|
-
`}function
|
|
1799
|
+
`}function Vh(e,t){const s=`list-item list-item-clickable${t.runsJobId===e.id?" list-item-selected":""}`;return c`
|
|
1800
1800
|
<div class=${s} @click=${()=>t.onLoadRuns(e.id)}>
|
|
1801
1801
|
<div class="list-main">
|
|
1802
1802
|
<div class="list-title">${e.name}</div>
|
|
1803
|
-
<div class="list-sub">${
|
|
1804
|
-
<div class="muted">${
|
|
1803
|
+
<div class="list-sub">${Hh(e)}</div>
|
|
1804
|
+
<div class="muted">${zh(e)}</div>
|
|
1805
1805
|
${e.agentId?c`<div class="muted">Agent: ${e.agentId}</div>`:f}
|
|
1806
1806
|
<div class="chip-row" style="margin-top: 6px;">
|
|
1807
1807
|
<span class="chip">${e.enabled?"enabled":"disabled"}</span>
|
|
@@ -1810,7 +1810,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1810
1810
|
</div>
|
|
1811
1811
|
</div>
|
|
1812
1812
|
<div class="list-meta">
|
|
1813
|
-
<div>${
|
|
1813
|
+
<div>${Kh(e)}</div>
|
|
1814
1814
|
<div class="row" style="justify-content: flex-end; margin-top: 8px;">
|
|
1815
1815
|
<button
|
|
1816
1816
|
class="btn"
|
|
@@ -1843,19 +1843,19 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1843
1843
|
</div>
|
|
1844
1844
|
</div>
|
|
1845
1845
|
</div>
|
|
1846
|
-
`}function
|
|
1846
|
+
`}function Yh(e){return c`
|
|
1847
1847
|
<div class="list-item">
|
|
1848
1848
|
<div class="list-main">
|
|
1849
1849
|
<div class="list-title">${e.status}</div>
|
|
1850
1850
|
<div class="list-sub">${e.summary??""}</div>
|
|
1851
1851
|
</div>
|
|
1852
1852
|
<div class="list-meta">
|
|
1853
|
-
<div>${
|
|
1853
|
+
<div>${kt(e.ts)}</div>
|
|
1854
1854
|
<div class="muted">${e.durationMs??0}ms</div>
|
|
1855
1855
|
${e.error?c`<div class="muted">${e.error}</div>`:f}
|
|
1856
1856
|
</div>
|
|
1857
1857
|
</div>
|
|
1858
|
-
`}function
|
|
1858
|
+
`}function Qh(e){const n=(e.status&&typeof e.status=="object"?e.status.securityAudit:null)?.summary??null,s=n?.critical??0,i=n?.warn??0,a=n?.info??0,o=s>0?"danger":i>0?"warn":"success",r=s>0?`${s} critical`:i>0?`${i} warnings`:"No critical issues";return c`
|
|
1859
1859
|
<section class="grid grid-cols-2">
|
|
1860
1860
|
<div class="card">
|
|
1861
1861
|
<div class="row" style="justify-content: space-between;">
|
|
@@ -1936,14 +1936,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1936
1936
|
<div class="list-sub">${new Date(l.ts).toLocaleTimeString()}</div>
|
|
1937
1937
|
</div>
|
|
1938
1938
|
<div class="list-meta">
|
|
1939
|
-
<pre class="code-block">${
|
|
1939
|
+
<pre class="code-block">${Uh(l.payload)}</pre>
|
|
1940
1940
|
</div>
|
|
1941
1941
|
</div>
|
|
1942
1942
|
`)}
|
|
1943
1943
|
</div>
|
|
1944
1944
|
`}
|
|
1945
1945
|
</section>
|
|
1946
|
-
`}function
|
|
1946
|
+
`}function Zh(e){return c`
|
|
1947
1947
|
<section class="card">
|
|
1948
1948
|
<div class="row" style="justify-content: space-between;">
|
|
1949
1949
|
<div>
|
|
@@ -1961,14 +1961,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1961
1961
|
${e.statusMessage}
|
|
1962
1962
|
</div>`:f}
|
|
1963
1963
|
<div class="list" style="margin-top: 16px;">
|
|
1964
|
-
${e.entries.length===0?c`<div class="muted">No instances reported yet.</div>`:e.entries.map(t=>
|
|
1964
|
+
${e.entries.length===0?c`<div class="muted">No instances reported yet.</div>`:e.entries.map(t=>Jh(t))}
|
|
1965
1965
|
</div>
|
|
1966
1966
|
</section>
|
|
1967
|
-
`}function
|
|
1967
|
+
`}function Jh(e){const t=e.lastInputSeconds!=null?`${e.lastInputSeconds}s ago`:"n/a",n=e.mode??"unknown",s=Array.isArray(e.roles)?e.roles.filter(Boolean):[],i=Array.isArray(e.scopes)?e.scopes.filter(Boolean):[],a=i.length>0?i.length>3?`${i.length} scopes`:`scopes: ${i.join(", ")}`:null;return c`
|
|
1968
1968
|
<div class="list-item">
|
|
1969
1969
|
<div class="list-main">
|
|
1970
1970
|
<div class="list-title">${e.host??"unknown host"}</div>
|
|
1971
|
-
<div class="list-sub">${
|
|
1971
|
+
<div class="list-sub">${Dh(e)}</div>
|
|
1972
1972
|
<div class="chip-row">
|
|
1973
1973
|
<span class="chip">${n}</span>
|
|
1974
1974
|
${s.map(o=>c`<span class="chip">${o}</span>`)}
|
|
@@ -1980,12 +1980,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
1980
1980
|
</div>
|
|
1981
1981
|
</div>
|
|
1982
1982
|
<div class="list-meta">
|
|
1983
|
-
<div>${
|
|
1983
|
+
<div>${Bh(e)}</div>
|
|
1984
1984
|
<div class="muted">Last input ${t}</div>
|
|
1985
1985
|
<div class="muted">Reason ${e.reason??""}</div>
|
|
1986
1986
|
</div>
|
|
1987
1987
|
</div>
|
|
1988
|
-
`}const Qa=["trace","debug","info","warn","error","fatal"];function
|
|
1988
|
+
`}const Qa=["trace","debug","info","warn","error","fatal"];function Xh(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function ef(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function tf(e){const t=e.filterText.trim().toLowerCase(),n=Qa.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:ef(a,t)),i=t||n?"filtered":"visible";return c`
|
|
1989
1989
|
<section class="card">
|
|
1990
1990
|
<div class="row" style="justify-content: space-between;">
|
|
1991
1991
|
<div>
|
|
@@ -2047,7 +2047,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2047
2047
|
<div class="log-stream" style="margin-top: 12px;" @scroll=${e.onScroll}>
|
|
2048
2048
|
${s.length===0?c`<div class="muted" style="padding: 12px;">No log entries.</div>`:s.map(a=>c`
|
|
2049
2049
|
<div class="log-row">
|
|
2050
|
-
<div class="log-time mono">${
|
|
2050
|
+
<div class="log-time mono">${Xh(a.time)}</div>
|
|
2051
2051
|
<div class="log-level ${a.level??""}">${a.level??""}</div>
|
|
2052
2052
|
<div class="log-subsystem mono">${a.subsystem??""}</div>
|
|
2053
2053
|
<div class="log-message mono">${a.message??a.raw}</div>
|
|
@@ -2055,10 +2055,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2055
2055
|
`)}
|
|
2056
2056
|
</div>
|
|
2057
2057
|
</section>
|
|
2058
|
-
`}function
|
|
2059
|
-
${
|
|
2060
|
-
${
|
|
2061
|
-
${
|
|
2058
|
+
`}function nf(e){const t=cf(e),n=gf(e);return c`
|
|
2059
|
+
${mf(n)}
|
|
2060
|
+
${vf(t)}
|
|
2061
|
+
${sf(e)}
|
|
2062
2062
|
<section class="card">
|
|
2063
2063
|
<div class="row" style="justify-content: space-between;">
|
|
2064
2064
|
<div>
|
|
@@ -2070,10 +2070,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2070
2070
|
</button>
|
|
2071
2071
|
</div>
|
|
2072
2072
|
<div class="list" style="margin-top: 16px;">
|
|
2073
|
-
${e.nodes.length===0?c`<div class="muted">No nodes found.</div>`:e.nodes.map(s=>
|
|
2073
|
+
${e.nodes.length===0?c`<div class="muted">No nodes found.</div>`:e.nodes.map(s=>Cf(s))}
|
|
2074
2074
|
</div>
|
|
2075
2075
|
</section>
|
|
2076
|
-
`}function
|
|
2076
|
+
`}function sf(e){const t=e.devicesList??{pending:[],paired:[]},n=Array.isArray(t.pending)?t.pending:[],s=Array.isArray(t.paired)?t.paired:[];return c`
|
|
2077
2077
|
<section class="card">
|
|
2078
2078
|
<div class="row" style="justify-content: space-between;">
|
|
2079
2079
|
<div>
|
|
@@ -2088,16 +2088,16 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2088
2088
|
<div class="list" style="margin-top: 16px;">
|
|
2089
2089
|
${n.length>0?c`
|
|
2090
2090
|
<div class="muted" style="margin-bottom: 8px;">Pending</div>
|
|
2091
|
-
${n.map(i=>
|
|
2091
|
+
${n.map(i=>af(i,e))}
|
|
2092
2092
|
`:f}
|
|
2093
2093
|
${s.length>0?c`
|
|
2094
2094
|
<div class="muted" style="margin-top: 12px; margin-bottom: 8px;">Paired</div>
|
|
2095
|
-
${s.map(i=>
|
|
2095
|
+
${s.map(i=>of(i,e))}
|
|
2096
2096
|
`:f}
|
|
2097
2097
|
${n.length===0&&s.length===0?c`<div class="muted">No paired devices.</div>`:f}
|
|
2098
2098
|
</div>
|
|
2099
2099
|
</section>
|
|
2100
|
-
`}function
|
|
2100
|
+
`}function af(e,t){const n=e.displayName?.trim()||e.deviceId,s=typeof e.ts=="number"?O(e.ts):"n/a",i=e.role?.trim()?`role: ${e.role}`:"role: -",a=e.isRepair?" · repair":"",o=e.remoteIp?` · ${e.remoteIp}`:"";return c`
|
|
2101
2101
|
<div class="list-item">
|
|
2102
2102
|
<div class="list-main">
|
|
2103
2103
|
<div class="list-title">${n}</div>
|
|
@@ -2117,7 +2117,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2117
2117
|
</div>
|
|
2118
2118
|
</div>
|
|
2119
2119
|
</div>
|
|
2120
|
-
`}function
|
|
2120
|
+
`}function of(e,t){const n=e.displayName?.trim()||e.deviceId,s=e.remoteIp?` · ${e.remoteIp}`:"",i=`roles: ${ls(e.roles)}`,a=`scopes: ${ls(e.scopes)}`,o=Array.isArray(e.tokens)?e.tokens:[];return c`
|
|
2121
2121
|
<div class="list-item">
|
|
2122
2122
|
<div class="list-main">
|
|
2123
2123
|
<div class="list-title">${n}</div>
|
|
@@ -2126,12 +2126,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2126
2126
|
${o.length===0?c`<div class="muted" style="margin-top: 6px;">Tokens: none</div>`:c`
|
|
2127
2127
|
<div class="muted" style="margin-top: 10px;">Tokens</div>
|
|
2128
2128
|
<div style="display: flex; flex-direction: column; gap: 8px; margin-top: 6px;">
|
|
2129
|
-
${o.map(r=>
|
|
2129
|
+
${o.map(r=>rf(e.deviceId,r,t))}
|
|
2130
2130
|
</div>
|
|
2131
2131
|
`}
|
|
2132
2132
|
</div>
|
|
2133
2133
|
</div>
|
|
2134
|
-
`}function
|
|
2134
|
+
`}function rf(e,t,n){const s=t.revokedAtMs?"revoked":"active",i=`scopes: ${ls(t.scopes)}`,a=O(t.rotatedAtMs??t.createdAtMs??t.lastUsedAtMs??null);return c`
|
|
2135
2135
|
<div class="row" style="justify-content: space-between; gap: 8px;">
|
|
2136
2136
|
<div class="list-sub">${t.role} · ${s} · ${i} · ${a}</div>
|
|
2137
2137
|
<div class="row" style="justify-content: flex-end; gap: 6px; flex-wrap: wrap;">
|
|
@@ -2151,7 +2151,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2151
2151
|
`}
|
|
2152
2152
|
</div>
|
|
2153
2153
|
</div>
|
|
2154
|
-
`}const Ae="__defaults__",Za=[{value:"deny",label:"Deny"},{value:"allowlist",label:"Allowlist"},{value:"full",label:"Full"}],
|
|
2154
|
+
`}const Ae="__defaults__",Za=[{value:"deny",label:"Deny"},{value:"allowlist",label:"Allowlist"},{value:"full",label:"Full"}],lf=[{value:"off",label:"Off"},{value:"on-miss",label:"On miss"},{value:"always",label:"Always"}];function cf(e){const t=e.configForm,n=kf(e.nodes),{defaultBinding:s,agents:i}=_f(t),a=!!t,o=e.configSaving||e.configFormMode==="raw";return{ready:a,disabled:o,configDirty:e.configDirty,configLoading:e.configLoading,configSaving:e.configSaving,defaultBinding:s,agents:i,nodes:n,onBindDefault:e.onBindDefault,onBindAgent:e.onBindAgent,onSave:e.onSaveBindings,onLoadConfig:e.onLoadConfig,formMode:e.configFormMode}}function Ja(e){return e==="allowlist"||e==="full"||e==="deny"?e:"deny"}function df(e){return e==="always"||e==="off"||e==="on-miss"?e:"on-miss"}function uf(e){const t=e?.defaults??{};return{security:Ja(t.security),ask:df(t.ask),askFallback:Ja(t.askFallback??"deny"),autoAllowSkills:!!(t.autoAllowSkills??!1)}}function pf(e){const t=e?.agents??{},n=Array.isArray(t.list)?t.list:[],s=[];return n.forEach(i=>{if(!i||typeof i!="object")return;const a=i,o=typeof a.id=="string"?a.id.trim():"";if(!o)return;const r=typeof a.name=="string"?a.name.trim():void 0,l=a.default===!0;s.push({id:o,name:r||void 0,isDefault:l})}),s}function hf(e,t){const n=pf(e),s=Object.keys(t?.agents??{}),i=new Map;n.forEach(o=>i.set(o.id,o)),s.forEach(o=>{i.has(o)||i.set(o,{id:o})});const a=Array.from(i.values());return a.length===0&&a.push({id:"main",isDefault:!0}),a.sort((o,r)=>{if(o.isDefault&&!r.isDefault)return-1;if(!o.isDefault&&r.isDefault)return 1;const l=o.name?.trim()?o.name:o.id,p=r.name?.trim()?r.name:r.id;return l.localeCompare(p)}),a}function ff(e,t){return e===Ae?Ae:e&&t.some(n=>n.id===e)?e:Ae}function gf(e){const t=e.execApprovalsForm??e.execApprovalsSnapshot?.file??null,n=!!t,s=uf(t),i=hf(e.configForm,t),a=Sf(e.nodes),o=e.execApprovalsTarget;let r=o==="node"&&e.execApprovalsTargetNodeId?e.execApprovalsTargetNodeId:null;o==="node"&&r&&!a.some(u=>u.id===r)&&(r=null);const l=ff(e.execApprovalsSelectedAgent,i),p=l!==Ae?(t?.agents??{})[l]??null:null,d=Array.isArray(p?.allowlist)?p.allowlist??[]:[];return{ready:n,disabled:e.execApprovalsSaving||e.execApprovalsLoading,dirty:e.execApprovalsDirty,loading:e.execApprovalsLoading,saving:e.execApprovalsSaving,form:t,defaults:s,selectedScope:l,selectedAgent:p,agents:i,allowlist:d,target:o,targetNodeId:r,targetNodes:a,onSelectScope:e.onExecApprovalsSelectAgent,onSelectTarget:e.onExecApprovalsTargetChange,onPatch:e.onExecApprovalsPatch,onRemove:e.onExecApprovalsRemove,onLoad:e.onLoadExecApprovals,onSave:e.onSaveExecApprovals}}function vf(e){const t=e.nodes.length>0,n=e.defaultBinding??"";return c`
|
|
2155
2155
|
<section class="card">
|
|
2156
2156
|
<div class="row" style="justify-content: space-between; align-items: center;">
|
|
2157
2157
|
<div>
|
|
@@ -2200,7 +2200,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2200
2200
|
</div>
|
|
2201
2201
|
</div>
|
|
2202
2202
|
|
|
2203
|
-
${e.agents.length===0?c`<div class="muted">No agents found.</div>`:e.agents.map(s=>
|
|
2203
|
+
${e.agents.length===0?c`<div class="muted">No agents found.</div>`:e.agents.map(s=>Af(s,e))}
|
|
2204
2204
|
</div>
|
|
2205
2205
|
`:c`<div class="row" style="margin-top: 12px; gap: 12px;">
|
|
2206
2206
|
<div class="muted">Load config to edit bindings.</div>
|
|
@@ -2209,7 +2209,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2209
2209
|
</button>
|
|
2210
2210
|
</div>`}
|
|
2211
2211
|
</section>
|
|
2212
|
-
`}function
|
|
2212
|
+
`}function mf(e){const t=e.ready,n=e.target!=="node"||!!e.targetNodeId;return c`
|
|
2213
2213
|
<section class="card">
|
|
2214
2214
|
<div class="row" style="justify-content: space-between; align-items: center;">
|
|
2215
2215
|
<div>
|
|
@@ -2227,12 +2227,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2227
2227
|
</button>
|
|
2228
2228
|
</div>
|
|
2229
2229
|
|
|
2230
|
-
${
|
|
2230
|
+
${yf(e)}
|
|
2231
2231
|
|
|
2232
2232
|
${t?c`
|
|
2233
|
-
${
|
|
2234
|
-
${
|
|
2235
|
-
${e.selectedScope===Ae?f
|
|
2233
|
+
${bf(e)}
|
|
2234
|
+
${wf(e)}
|
|
2235
|
+
${e.selectedScope===Ae?f:$f(e)}
|
|
2236
2236
|
`:c`<div class="row" style="margin-top: 12px; gap: 12px;">
|
|
2237
2237
|
<div class="muted">Load exec approvals to edit allowlists.</div>
|
|
2238
2238
|
<button class="btn" ?disabled=${e.loading||!n} @click=${e.onLoad}>
|
|
@@ -2240,7 +2240,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2240
2240
|
</button>
|
|
2241
2241
|
</div>`}
|
|
2242
2242
|
</section>
|
|
2243
|
-
`}function
|
|
2243
|
+
`}function yf(e){const t=e.targetNodes.length>0,n=e.targetNodeId??"";return c`
|
|
2244
2244
|
<div class="list" style="margin-top: 12px;">
|
|
2245
2245
|
<div class="list-item">
|
|
2246
2246
|
<div class="list-main">
|
|
@@ -2281,7 +2281,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2281
2281
|
</div>
|
|
2282
2282
|
${e.target==="node"&&!t?c`<div class="muted">No nodes advertise exec approvals yet.</div>`:f}
|
|
2283
2283
|
</div>
|
|
2284
|
-
`}function
|
|
2284
|
+
`}function bf(e){return c`
|
|
2285
2285
|
<div class="row" style="margin-top: 12px; gap: 8px; flex-wrap: wrap;">
|
|
2286
2286
|
<span class="label">Scope</span>
|
|
2287
2287
|
<div class="row" style="gap: 8px; flex-wrap: wrap;">
|
|
@@ -2301,7 +2301,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2301
2301
|
`})}
|
|
2302
2302
|
</div>
|
|
2303
2303
|
</div>
|
|
2304
|
-
`}function
|
|
2304
|
+
`}function wf(e){const t=e.selectedScope===Ae,n=e.defaults,s=e.selectedAgent??{},i=t?["defaults"]:["agents",e.selectedScope],a=typeof s.security=="string"?s.security:void 0,o=typeof s.ask=="string"?s.ask:void 0,r=typeof s.askFallback=="string"?s.askFallback:void 0,l=t?n.security:a??"__default__",p=t?n.ask:o??"__default__",d=t?n.askFallback:r??"__default__",u=typeof s.autoAllowSkills=="boolean"?s.autoAllowSkills:void 0,g=u??n.autoAllowSkills,v=u==null;return c`
|
|
2305
2305
|
<div class="list" style="margin-top: 16px;">
|
|
2306
2306
|
<div class="list-item">
|
|
2307
2307
|
<div class="list-main">
|
|
@@ -2315,16 +2315,16 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2315
2315
|
<span>Mode</span>
|
|
2316
2316
|
<select
|
|
2317
2317
|
?disabled=${e.disabled}
|
|
2318
|
-
@change=${
|
|
2318
|
+
@change=${y=>{const A=y.target.value;!t&&A==="__default__"?e.onRemove([...i,"security"]):e.onPatch([...i,"security"],A)}}
|
|
2319
2319
|
>
|
|
2320
2320
|
${t?f:c`<option value="__default__" ?selected=${l==="__default__"}>
|
|
2321
2321
|
Use default (${n.security})
|
|
2322
2322
|
</option>`}
|
|
2323
|
-
${Za.map(
|
|
2324
|
-
value=${
|
|
2325
|
-
?selected=${l===
|
|
2323
|
+
${Za.map(y=>c`<option
|
|
2324
|
+
value=${y.value}
|
|
2325
|
+
?selected=${l===y.value}
|
|
2326
2326
|
>
|
|
2327
|
-
${
|
|
2327
|
+
${y.label}
|
|
2328
2328
|
</option>`)}
|
|
2329
2329
|
</select>
|
|
2330
2330
|
</label>
|
|
@@ -2343,16 +2343,16 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2343
2343
|
<span>Mode</span>
|
|
2344
2344
|
<select
|
|
2345
2345
|
?disabled=${e.disabled}
|
|
2346
|
-
@change=${
|
|
2346
|
+
@change=${y=>{const A=y.target.value;!t&&A==="__default__"?e.onRemove([...i,"ask"]):e.onPatch([...i,"ask"],A)}}
|
|
2347
2347
|
>
|
|
2348
2348
|
${t?f:c`<option value="__default__" ?selected=${p==="__default__"}>
|
|
2349
2349
|
Use default (${n.ask})
|
|
2350
2350
|
</option>`}
|
|
2351
|
-
${
|
|
2352
|
-
value=${
|
|
2353
|
-
?selected=${p===
|
|
2351
|
+
${lf.map(y=>c`<option
|
|
2352
|
+
value=${y.value}
|
|
2353
|
+
?selected=${p===y.value}
|
|
2354
2354
|
>
|
|
2355
|
-
${
|
|
2355
|
+
${y.label}
|
|
2356
2356
|
</option>`)}
|
|
2357
2357
|
</select>
|
|
2358
2358
|
</label>
|
|
@@ -2371,16 +2371,16 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2371
2371
|
<span>Fallback</span>
|
|
2372
2372
|
<select
|
|
2373
2373
|
?disabled=${e.disabled}
|
|
2374
|
-
@change=${
|
|
2374
|
+
@change=${y=>{const A=y.target.value;!t&&A==="__default__"?e.onRemove([...i,"askFallback"]):e.onPatch([...i,"askFallback"],A)}}
|
|
2375
2375
|
>
|
|
2376
2376
|
${t?f:c`<option value="__default__" ?selected=${d==="__default__"}>
|
|
2377
2377
|
Use default (${n.askFallback})
|
|
2378
2378
|
</option>`}
|
|
2379
|
-
${Za.map(
|
|
2380
|
-
value=${
|
|
2381
|
-
?selected=${d===
|
|
2379
|
+
${Za.map(y=>c`<option
|
|
2380
|
+
value=${y.value}
|
|
2381
|
+
?selected=${d===y.value}
|
|
2382
2382
|
>
|
|
2383
|
-
${
|
|
2383
|
+
${y.label}
|
|
2384
2384
|
</option>`)}
|
|
2385
2385
|
</select>
|
|
2386
2386
|
</label>
|
|
@@ -2401,7 +2401,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2401
2401
|
type="checkbox"
|
|
2402
2402
|
?disabled=${e.disabled}
|
|
2403
2403
|
.checked=${g}
|
|
2404
|
-
@change=${
|
|
2404
|
+
@change=${y=>{const $=y.target;e.onPatch([...i,"autoAllowSkills"],$.checked)}}
|
|
2405
2405
|
/>
|
|
2406
2406
|
</label>
|
|
2407
2407
|
${!t&&!v?c`<button
|
|
@@ -2414,7 +2414,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2414
2414
|
</div>
|
|
2415
2415
|
</div>
|
|
2416
2416
|
</div>
|
|
2417
|
-
`}function
|
|
2417
|
+
`}function $f(e){const t=["agents",e.selectedScope,"allowlist"],n=e.allowlist;return c`
|
|
2418
2418
|
<div class="row" style="margin-top: 18px; justify-content: space-between;">
|
|
2419
2419
|
<div>
|
|
2420
2420
|
<div class="card-title">Allowlist</div>
|
|
@@ -2429,9 +2429,9 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2429
2429
|
</button>
|
|
2430
2430
|
</div>
|
|
2431
2431
|
<div class="list" style="margin-top: 12px;">
|
|
2432
|
-
${n.length===0?c`<div class="muted">No allowlist entries yet.</div>`:n.map((s,i)=>
|
|
2432
|
+
${n.length===0?c`<div class="muted">No allowlist entries yet.</div>`:n.map((s,i)=>xf(e,s,i))}
|
|
2433
2433
|
</div>
|
|
2434
|
-
`}function
|
|
2434
|
+
`}function xf(e,t,n){const s=t.lastUsedAt?O(t.lastUsedAt):"never",i=t.lastUsedCommand?cs(t.lastUsedCommand,120):null,a=t.lastResolvedPath?cs(t.lastResolvedPath,120):null;return c`
|
|
2435
2435
|
<div class="list-item">
|
|
2436
2436
|
<div class="list-main">
|
|
2437
2437
|
<div class="list-title">${t.pattern?.trim()?t.pattern:"New pattern"}</div>
|
|
@@ -2458,7 +2458,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2458
2458
|
</button>
|
|
2459
2459
|
</div>
|
|
2460
2460
|
</div>
|
|
2461
|
-
`}function
|
|
2461
|
+
`}function Af(e,t){const n=e.binding??"__default__",s=e.name?.trim()?`${e.name} (${e.id})`:e.id,i=t.nodes.length>0;return c`
|
|
2462
2462
|
<div class="list-item">
|
|
2463
2463
|
<div class="list-main">
|
|
2464
2464
|
<div class="list-title">${s}</div>
|
|
@@ -2487,7 +2487,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2487
2487
|
</label>
|
|
2488
2488
|
</div>
|
|
2489
2489
|
</div>
|
|
2490
|
-
`}function
|
|
2490
|
+
`}function kf(e){const t=[];for(const n of e){if(!(Array.isArray(n.commands)?n.commands:[]).some(r=>String(r)==="system.run"))continue;const a=typeof n.nodeId=="string"?n.nodeId.trim():"";if(!a)continue;const o=typeof n.displayName=="string"&&n.displayName.trim()?n.displayName.trim():a;t.push({id:a,label:o===a?a:`${o} · ${a}`})}return t.sort((n,s)=>n.label.localeCompare(s.label)),t}function Sf(e){const t=[];for(const n of e){if(!(Array.isArray(n.commands)?n.commands:[]).some(r=>String(r)==="system.execApprovals.get"||String(r)==="system.execApprovals.set"))continue;const a=typeof n.nodeId=="string"?n.nodeId.trim():"";if(!a)continue;const o=typeof n.displayName=="string"&&n.displayName.trim()?n.displayName.trim():a;t.push({id:a,label:o===a?a:`${o} · ${a}`})}return t.sort((n,s)=>n.label.localeCompare(s.label)),t}function _f(e){const t={id:"main",name:void 0,index:0,isDefault:!0,binding:null};if(!e||typeof e!="object")return{defaultBinding:null,agents:[t]};const s=(e.tools??{}).exec??{},i=typeof s.node=="string"&&s.node.trim()?s.node.trim():null,a=e.agents??{},o=Array.isArray(a.list)?a.list:[];if(o.length===0)return{defaultBinding:i,agents:[t]};const r=[];return o.forEach((l,p)=>{if(!l||typeof l!="object")return;const d=l,u=typeof d.id=="string"?d.id.trim():"";if(!u)return;const g=typeof d.name=="string"?d.name.trim():void 0,v=d.default===!0,$=(d.tools??{}).exec??{},A=typeof $.node=="string"&&$.node.trim()?$.node.trim():null;r.push({id:u,name:g||void 0,index:p,isDefault:v,binding:A})}),r.length===0&&r.push(t),{defaultBinding:i,agents:r}}function Cf(e){const t=!!e.connected,n=!!e.paired,s=typeof e.displayName=="string"&&e.displayName.trim()||(typeof e.nodeId=="string"?e.nodeId:"unknown"),i=Array.isArray(e.caps)?e.caps:[],a=Array.isArray(e.commands)?e.commands:[];return c`
|
|
2491
2491
|
<div class="list-item">
|
|
2492
2492
|
<div class="list-main">
|
|
2493
2493
|
<div class="list-title">${s}</div>
|
|
@@ -2506,7 +2506,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2506
2506
|
</div>
|
|
2507
2507
|
</div>
|
|
2508
2508
|
</div>
|
|
2509
|
-
`}function
|
|
2509
|
+
`}function Tf(e){const t=e.hello?.snapshot,n=t?.uptimeMs?go(t.uptimeMs):"n/a",s=t?.policy?.tickIntervalMs?`${t.policy.tickIntervalMs}ms`:"n/a",i=(()=>{if(e.connected||!e.lastError)return null;const o=e.lastError.toLowerCase();if(!(o.includes("unauthorized")||o.includes("connect failed")))return null;const l=!!e.settings.token.trim(),p=!!e.password.trim();return!l&&!p?c`
|
|
2510
2510
|
<div class="muted" style="margin-top: 8px;">
|
|
2511
2511
|
This gateway requires auth. Add a token or password, then click Connect.
|
|
2512
2512
|
<div style="margin-top: 6px;">
|
|
@@ -2689,7 +2689,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2689
2689
|
</div>
|
|
2690
2690
|
</div>
|
|
2691
2691
|
</section>
|
|
2692
|
-
`}const
|
|
2692
|
+
`}const Ef=["","off","minimal","low","medium","high"],Mf=["","off","on"],Lf=[{value:"",label:"inherit"},{value:"off",label:"off (explicit)"},{value:"on",label:"on"}],If=["","off","on","stream"];function Rf(e){if(!e)return"";const t=e.trim().toLowerCase();return t==="z.ai"||t==="z-ai"?"zai":t}function Sr(e){return Rf(e)==="zai"}function Pf(e){return Sr(e)?Mf:Ef}function Nf(e,t){return!t||!e||e==="off"?e:"on"}function Of(e,t){return e?t&&e==="on"?"low":e:null}function Df(e){const t=e.result?.sessions??[];return c`
|
|
2693
2693
|
<section class="card">
|
|
2694
2694
|
<div class="row" style="justify-content: space-between;">
|
|
2695
2695
|
<div>
|
|
@@ -2752,12 +2752,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2752
2752
|
<div>Reasoning</div>
|
|
2753
2753
|
<div>Actions</div>
|
|
2754
2754
|
</div>
|
|
2755
|
-
${t.length===0?c`<div class="muted">No sessions found.</div>`:t.map(n=>
|
|
2755
|
+
${t.length===0?c`<div class="muted">No sessions found.</div>`:t.map(n=>Bf(n,e.basePath,e.onPatch,e.onDelete,e.loading))}
|
|
2756
2756
|
</div>
|
|
2757
2757
|
</section>
|
|
2758
|
-
`}function
|
|
2758
|
+
`}function Bf(e,t,n,s,i){const a=e.updatedAt?O(e.updatedAt):"n/a",o=e.thinkingLevel??"",r=Sr(e.modelProvider),l=Nf(o,r),p=Pf(e.modelProvider),d=e.verboseLevel??"",u=e.reasoningLevel??"",g=e.displayName??e.key,v=e.kind!=="global",y=v?`${Ds("chat",t)}?session=${encodeURIComponent(e.key)}`:null;return c`
|
|
2759
2759
|
<div class="table-row">
|
|
2760
|
-
<div class="mono">${v?c`<a href=${
|
|
2760
|
+
<div class="mono">${v?c`<a href=${y} class="session-link">${g}</a>`:g}</div>
|
|
2761
2761
|
<div>
|
|
2762
2762
|
<input
|
|
2763
2763
|
.value=${e.label??""}
|
|
@@ -2768,12 +2768,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2768
2768
|
</div>
|
|
2769
2769
|
<div>${e.kind}</div>
|
|
2770
2770
|
<div>${a}</div>
|
|
2771
|
-
<div>${
|
|
2771
|
+
<div>${Fh(e)}</div>
|
|
2772
2772
|
<div>
|
|
2773
2773
|
<select
|
|
2774
2774
|
.value=${l}
|
|
2775
2775
|
?disabled=${i}
|
|
2776
|
-
@change=${$=>{const A=$.target.value;n(e.key,{thinkingLevel:
|
|
2776
|
+
@change=${$=>{const A=$.target.value;n(e.key,{thinkingLevel:Of(A,r)})}}
|
|
2777
2777
|
>
|
|
2778
2778
|
${p.map($=>c`<option value=${$}>${$||"inherit"}</option>`)}
|
|
2779
2779
|
</select>
|
|
@@ -2784,7 +2784,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2784
2784
|
?disabled=${i}
|
|
2785
2785
|
@change=${$=>{const A=$.target.value;n(e.key,{verboseLevel:A||null})}}
|
|
2786
2786
|
>
|
|
2787
|
-
${
|
|
2787
|
+
${Lf.map($=>c`<option value=${$.value}>${$.label}</option>`)}
|
|
2788
2788
|
</select>
|
|
2789
2789
|
</div>
|
|
2790
2790
|
<div>
|
|
@@ -2793,7 +2793,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2793
2793
|
?disabled=${i}
|
|
2794
2794
|
@change=${$=>{const A=$.target.value;n(e.key,{reasoningLevel:A||null})}}
|
|
2795
2795
|
>
|
|
2796
|
-
${
|
|
2796
|
+
${If.map($=>c`<option value=${$}>${$||"inherit"}</option>`)}
|
|
2797
2797
|
</select>
|
|
2798
2798
|
</div>
|
|
2799
2799
|
<div>
|
|
@@ -2802,7 +2802,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2802
2802
|
</button>
|
|
2803
2803
|
</div>
|
|
2804
2804
|
</div>
|
|
2805
|
-
`}function
|
|
2805
|
+
`}function Ff(e){const t=Math.max(0,e),n=Math.floor(t/1e3);if(n<60)return`${n}s`;const s=Math.floor(n/60);return s<60?`${s}m`:`${Math.floor(s/60)}h`}function Ie(e,t){return t?c`<div class="exec-approval-meta-row"><span>${e}</span><span>${t}</span></div>`:f}function Uf(e){const t=e.execApprovalQueue[0];if(!t)return f;const n=t.request,s=t.expiresAtMs-Date.now(),i=s>0?`expires in ${Ff(s)}`:"expired",a=e.execApprovalQueue.length;return c`
|
|
2806
2806
|
<div class="exec-approval-overlay" role="dialog" aria-live="polite">
|
|
2807
2807
|
<div class="exec-approval-card">
|
|
2808
2808
|
<div class="exec-approval-header">
|
|
@@ -2814,13 +2814,13 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2814
2814
|
</div>
|
|
2815
2815
|
<div class="exec-approval-command mono">${n.command}</div>
|
|
2816
2816
|
<div class="exec-approval-meta">
|
|
2817
|
-
${
|
|
2818
|
-
${
|
|
2819
|
-
${
|
|
2820
|
-
${
|
|
2821
|
-
${
|
|
2822
|
-
${
|
|
2823
|
-
${
|
|
2817
|
+
${Ie("Host",n.host)}
|
|
2818
|
+
${Ie("Agent",n.agentId)}
|
|
2819
|
+
${Ie("Session",n.sessionKey)}
|
|
2820
|
+
${Ie("CWD",n.cwd)}
|
|
2821
|
+
${Ie("Resolved",n.resolvedPath)}
|
|
2822
|
+
${Ie("Security",n.security)}
|
|
2823
|
+
${Ie("Ask",n.ask)}
|
|
2824
2824
|
</div>
|
|
2825
2825
|
${e.execApprovalError?c`<div class="exec-approval-error">${e.execApprovalError}</div>`:f}
|
|
2826
2826
|
<div class="exec-approval-actions">
|
|
@@ -2848,7 +2848,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2848
2848
|
</div>
|
|
2849
2849
|
</div>
|
|
2850
2850
|
</div>
|
|
2851
|
-
`}function
|
|
2851
|
+
`}function Kf(e){const{pendingGatewayUrl:t}=e;return t?c`
|
|
2852
2852
|
<div class="exec-approval-overlay" role="dialog" aria-modal="true" aria-live="polite">
|
|
2853
2853
|
<div class="exec-approval-card">
|
|
2854
2854
|
<div class="exec-approval-header">
|
|
@@ -2877,7 +2877,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2877
2877
|
</div>
|
|
2878
2878
|
</div>
|
|
2879
2879
|
</div>
|
|
2880
|
-
`:f}function
|
|
2880
|
+
`:f}function Hf(e){const t=e.report?.skills??[],n=e.filter.trim().toLowerCase(),s=n?t.filter(i=>[i.name,i.description,i.source].join(" ").toLowerCase().includes(n)):t;return c`
|
|
2881
2881
|
<section class="card">
|
|
2882
2882
|
<div class="row" style="justify-content: space-between;">
|
|
2883
2883
|
<div>
|
|
@@ -2905,11 +2905,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2905
2905
|
|
|
2906
2906
|
${s.length===0?c`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:c`
|
|
2907
2907
|
<div class="list" style="margin-top: 16px;">
|
|
2908
|
-
${s.map(i=>
|
|
2908
|
+
${s.map(i=>zf(i,e))}
|
|
2909
2909
|
</div>
|
|
2910
2910
|
`}
|
|
2911
2911
|
</section>
|
|
2912
|
-
`}function
|
|
2912
|
+
`}function zf(e,t){const n=t.busyKey===e.skillKey,s=t.edits[e.skillKey]??"",i=t.messages[e.skillKey]??null,a=e.install.length>0&&e.missing.bins.length>0,o=[...e.missing.bins.map(l=>`bin:${l}`),...e.missing.env.map(l=>`env:${l}`),...e.missing.config.map(l=>`config:${l}`),...e.missing.os.map(l=>`os:${l}`)],r=[];return e.disabled&&r.push("disabled"),e.blockedByAllowlist&&r.push("blocked by allowlist"),c`
|
|
2913
2913
|
<div class="list-item">
|
|
2914
2914
|
<div class="list-main">
|
|
2915
2915
|
<div class="list-title">
|
|
@@ -2977,7 +2977,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2977
2977
|
`:f}
|
|
2978
2978
|
</div>
|
|
2979
2979
|
</div>
|
|
2980
|
-
`}function
|
|
2980
|
+
`}function jf(e,t){const n=Ds(t,e.basePath);return c`
|
|
2981
2981
|
<a
|
|
2982
2982
|
href=${n}
|
|
2983
2983
|
class="nav-item ${e.tab===t?"active":""}"
|
|
@@ -2987,15 +2987,15 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
2987
2987
|
<span class="nav-item__icon" aria-hidden="true">${W[Sl(t)]}</span>
|
|
2988
2988
|
<span class="nav-item__text">${rs(t)}</span>
|
|
2989
2989
|
</a>
|
|
2990
|
-
`}function
|
|
2990
|
+
`}function qf(e){const t=Gf(e.hello,e.sessionsResult),n=Wf(e.sessionKey,e.sessionsResult,t),s=e.onboarding,i=e.onboarding,a=e.onboarding?!1:e.settings.chatShowThinking,o=e.onboarding?!0:e.settings.chatFocusMode,r=c`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path></svg>`,l=c`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7V4h3"></path><path d="M20 7V4h-3"></path><path d="M4 17v3h3"></path><path d="M20 17v3h-3"></path><circle cx="12" cy="12" r="3"></circle></svg>`;return c`
|
|
2991
2991
|
<div class="chat-controls">
|
|
2992
2992
|
<label class="field chat-controls__session">
|
|
2993
2993
|
<select
|
|
2994
2994
|
.value=${e.sessionKey}
|
|
2995
2995
|
?disabled=${!e.connected}
|
|
2996
|
-
@change=${p=>{const d=p.target.value;e.sessionKey=d,e.chatMessage="",e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:d,lastActiveSessionKey:d}),e.loadAssistantIdentity(),Sd(e,d),
|
|
2996
|
+
@change=${p=>{const d=p.target.value;e.sessionKey=d,e.chatMessage="",e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:d,lastActiveSessionKey:d}),e.loadAssistantIdentity(),Sd(e,d),St(e)}}
|
|
2997
2997
|
>
|
|
2998
|
-
${
|
|
2998
|
+
${Zo(n,p=>p.key,p=>c`<option value=${p.key}>
|
|
2999
2999
|
${p.displayName??p.key}
|
|
3000
3000
|
</option>`)}
|
|
3001
3001
|
</select>
|
|
@@ -3003,7 +3003,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3003
3003
|
<button
|
|
3004
3004
|
class="btn btn--sm btn--icon"
|
|
3005
3005
|
?disabled=${e.chatLoading||!e.connected}
|
|
3006
|
-
@click=${()=>{e.resetToolStream(),
|
|
3006
|
+
@click=${()=>{e.resetToolStream(),Yo(e)}}
|
|
3007
3007
|
title="Refresh chat data"
|
|
3008
3008
|
>
|
|
3009
3009
|
${r}
|
|
@@ -3028,7 +3028,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3028
3028
|
${l}
|
|
3029
3029
|
</button>
|
|
3030
3030
|
</div>
|
|
3031
|
-
`}function
|
|
3031
|
+
`}function Gf(e,t){const n=e?.snapshot,s=n?.sessionDefaults?.mainSessionKey?.trim();if(s)return s;const i=n?.sessionDefaults?.mainKey?.trim();return i||(t?.sessions?.some(a=>a.key==="main")?"main":null)}function Wf(e,t,n){const s=new Set,i=[],a=n&&t?.sessions?.find(r=>r.key===n),o=t?.sessions?.find(r=>r.key===e);if(n&&(s.add(n),i.push({key:n,displayName:a?.displayName})),s.has(e)||(s.add(e),i.push({key:e,displayName:o?.displayName})),t?.sessions)for(const r of t.sessions)s.has(r.key)||(s.add(r.key),i.push({key:r.key,displayName:r.displayName}));return i}const Vf=["system","light","dark"];function Yf(e){const t=Math.max(0,Vf.indexOf(e.theme)),n=s=>i=>{const o={element:i.currentTarget};(i.clientX||i.clientY)&&(o.pointerClientX=i.clientX,o.pointerClientY=i.clientY),e.setTheme(s,o)};return c`
|
|
3032
3032
|
<div class="theme-toggle" style="--theme-index: ${t};">
|
|
3033
3033
|
<div class="theme-toggle__track" role="group" aria-label="Theme">
|
|
3034
3034
|
<span class="theme-toggle__indicator"></span>
|
|
@@ -3039,7 +3039,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3039
3039
|
aria-label="System theme"
|
|
3040
3040
|
title="System"
|
|
3041
3041
|
>
|
|
3042
|
-
${
|
|
3042
|
+
${Jf()}
|
|
3043
3043
|
</button>
|
|
3044
3044
|
<button
|
|
3045
3045
|
class="theme-toggle__button ${e.theme==="light"?"active":""}"
|
|
@@ -3048,7 +3048,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3048
3048
|
aria-label="Light theme"
|
|
3049
3049
|
title="Light"
|
|
3050
3050
|
>
|
|
3051
|
-
${
|
|
3051
|
+
${Qf()}
|
|
3052
3052
|
</button>
|
|
3053
3053
|
<button
|
|
3054
3054
|
class="theme-toggle__button ${e.theme==="dark"?"active":""}"
|
|
@@ -3057,11 +3057,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3057
3057
|
aria-label="Dark theme"
|
|
3058
3058
|
title="Dark"
|
|
3059
3059
|
>
|
|
3060
|
-
${
|
|
3060
|
+
${Zf()}
|
|
3061
3061
|
</button>
|
|
3062
3062
|
</div>
|
|
3063
3063
|
</div>
|
|
3064
|
-
`}function
|
|
3064
|
+
`}function Qf(){return c`
|
|
3065
3065
|
<svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
|
|
3066
3066
|
<circle cx="12" cy="12" r="4"></circle>
|
|
3067
3067
|
<path d="M12 2v2"></path>
|
|
@@ -3073,19 +3073,19 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3073
3073
|
<path d="m6.34 17.66-1.41 1.41"></path>
|
|
3074
3074
|
<path d="m19.07 4.93-1.41 1.41"></path>
|
|
3075
3075
|
</svg>
|
|
3076
|
-
`}function
|
|
3076
|
+
`}function Zf(){return c`
|
|
3077
3077
|
<svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
|
|
3078
3078
|
<path
|
|
3079
3079
|
d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"
|
|
3080
3080
|
></path>
|
|
3081
3081
|
</svg>
|
|
3082
|
-
`}function
|
|
3082
|
+
`}function Jf(){return c`
|
|
3083
3083
|
<svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
|
|
3084
3084
|
<rect width="20" height="14" x="2" y="3" rx="2"></rect>
|
|
3085
3085
|
<line x1="8" x2="16" y1="21" y2="21"></line>
|
|
3086
3086
|
<line x1="12" x2="12" y1="17" y2="21"></line>
|
|
3087
3087
|
</svg>
|
|
3088
|
-
`}const
|
|
3088
|
+
`}const Xf=/^data:/i,eg=/^https?:\/\//i;function tg(e){const t=e.agentsList?.agents??[],s=uo(e.sessionKey)?.agentId??e.agentsList?.defaultId??"main",a=t.find(r=>r.id===s)?.identity,o=a?.avatarUrl??a?.avatar;if(o)return Xf.test(o)||eg.test(o)?o:a?.avatarUrl}function ng(e){const t=e.presenceEntries.length,n=e.sessionsResult?.count??null,s=e.cronStatus?.nextWakeAtMs??null,i=e.connected?null:"Disconnected from gateway.",a=e.tab==="chat",o=a&&(e.settings.chatFocusMode||e.onboarding),r=e.onboarding?!1:e.settings.chatShowThinking,l=tg(e),p=e.chatAvatarUrl??l??null;return c`
|
|
3089
3089
|
<div class="shell ${a?"shell--chat":""} ${o?"shell--chat-focus":""} ${e.settings.navCollapsed?"shell--nav-collapsed":""} ${e.onboarding?"shell--onboarding":""}">
|
|
3090
3090
|
<header class="topbar">
|
|
3091
3091
|
<div class="topbar-left">
|
|
@@ -3113,7 +3113,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3113
3113
|
<span>Health</span>
|
|
3114
3114
|
<span class="mono">${e.connected?"OK":"Offline"}</span>
|
|
3115
3115
|
</div>
|
|
3116
|
-
${
|
|
3116
|
+
${Yf(e)}
|
|
3117
3117
|
</div>
|
|
3118
3118
|
</header>
|
|
3119
3119
|
<aside class="nav ${e.settings.navCollapsed?"nav--collapsed":""}">
|
|
@@ -3128,7 +3128,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3128
3128
|
<span class="nav-label__chevron">${u?"+":"−"}</span>
|
|
3129
3129
|
</button>
|
|
3130
3130
|
<div class="nav-group__items">
|
|
3131
|
-
${d.tabs.map(v=>
|
|
3131
|
+
${d.tabs.map(v=>jf(e,v))}
|
|
3132
3132
|
</div>
|
|
3133
3133
|
</div>
|
|
3134
3134
|
`})}
|
|
@@ -3158,36 +3158,36 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
|
|
|
3158
3158
|
</div>
|
|
3159
3159
|
<div class="page-meta">
|
|
3160
3160
|
${e.lastError?c`<div class="pill danger">${e.lastError}</div>`:f}
|
|
3161
|
-
${a?
|
|
3161
|
+
${a?qf(e):f}
|
|
3162
3162
|
</div>
|
|
3163
3163
|
</section>
|
|
3164
3164
|
|
|
3165
|
-
${e.tab==="overview"?
|
|
3165
|
+
${e.tab==="overview"?Tf({connected:e.connected,hello:e.hello,settings:e.settings,password:e.password,lastError:e.lastError,presenceCount:t,sessionsCount:n,cronEnabled:e.cronStatus?.enabled??null,cronNext:s,lastChannelsRefresh:e.channelsLastSuccess,onSettingsChange:d=>e.applySettings(d),onPasswordChange:d=>e.password=d,onSessionKeyChange:d=>{e.sessionKey=d,e.chatMessage="",e.resetToolStream(),e.applySettings({...e.settings,sessionKey:d,lastActiveSessionKey:d}),e.loadAssistantIdentity()},onConnect:()=>e.connect(),onRefresh:()=>e.loadOverview()}):f}
|
|
3166
3166
|
|
|
3167
|
-
${e.tab==="channels"?
|
|
3167
|
+
${e.tab==="channels"?Ch({connected:e.connected,loading:e.channelsLoading,snapshot:e.channelsSnapshot,lastError:e.channelsError,lastSuccessAt:e.channelsLastSuccess,whatsappMessage:e.whatsappLoginMessage,whatsappQrDataUrl:e.whatsappLoginQrDataUrl,whatsappConnected:e.whatsappLoginConnected,whatsappBusy:e.whatsappBusy,configSchema:e.configSchema,configSchemaLoading:e.configSchemaLoading,configForm:e.configForm,configUiHints:e.configUiHints,configSaving:e.configSaving,configFormDirty:e.configFormDirty,nostrProfileFormState:e.nostrProfileFormState,nostrProfileAccountId:e.nostrProfileAccountId,onRefresh:d=>oe(e,d),onWhatsAppStart:d=>e.handleWhatsAppStart(d),onWhatsAppWait:()=>e.handleWhatsAppWait(),onWhatsAppLogout:()=>e.handleWhatsAppLogout(),onConfigPatch:(d,u)=>Ft(e,d,u),onConfigSave:()=>e.handleChannelConfigSave(),onConfigReload:()=>e.handleChannelConfigReload(),onNostrProfileEdit:(d,u)=>e.handleNostrProfileEdit(d,u),onNostrProfileCancel:()=>e.handleNostrProfileCancel(),onNostrProfileFieldChange:(d,u)=>e.handleNostrProfileFieldChange(d,u),onNostrProfileSave:()=>e.handleNostrProfileSave(),onNostrProfileImport:()=>e.handleNostrProfileImport(),onNostrProfileToggleAdvanced:()=>e.handleNostrProfileToggleAdvanced()}):f}
|
|
3168
3168
|
|
|
3169
|
-
${e.tab==="instances"?
|
|
3169
|
+
${e.tab==="instances"?Zh({loading:e.presenceLoading,entries:e.presenceEntries,lastError:e.presenceError,statusMessage:e.presenceStatus,onRefresh:()=>Ws(e)}):f}
|
|
3170
3170
|
|
|
3171
|
-
${e.tab==="sessions"?
|
|
3171
|
+
${e.tab==="sessions"?Df({loading:e.sessionsLoading,result:e.sessionsResult,error:e.sessionsError,activeMinutes:e.sessionsFilterActive,limit:e.sessionsFilterLimit,includeGlobal:e.sessionsIncludeGlobal,includeUnknown:e.sessionsIncludeUnknown,basePath:e.basePath,onFiltersChange:d=>{e.sessionsFilterActive=d.activeMinutes,e.sessionsFilterLimit=d.limit,e.sessionsIncludeGlobal=d.includeGlobal,e.sessionsIncludeUnknown=d.includeUnknown},onRefresh:()=>Ke(e),onPatch:(d,u)=>Hl(e,d,u),onDelete:d=>zl(e,d)}):f}
|
|
3172
3172
|
|
|
3173
|
-
${e.tab==="cron"?
|
|
3173
|
+
${e.tab==="cron"?Gh({loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:e.channelsSnapshot?.channelMeta?.length?e.channelsSnapshot.channelMeta.map(d=>d.id):e.channelsSnapshot?.channelOrder??[],channelLabels:e.channelsSnapshot?.channelLabels??{},channelMeta:e.channelsSnapshot?.channelMeta??[],runsJobId:e.cronRunsJobId,runs:e.cronRuns,onFormChange:d=>e.cronForm={...e.cronForm,...d},onRefresh:()=>e.loadCron(),onAdd:()=>uc(e),onToggle:(d,u)=>pc(e,d,u),onRun:d=>hc(e,d),onRemove:d=>fc(e,d),onLoadRuns:d=>xo(e,d)}):f}
|
|
3174
3174
|
|
|
3175
|
-
${e.tab==="skills"?
|
|
3175
|
+
${e.tab==="skills"?Hf({loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:d=>e.skillsFilter=d,onRefresh:()=>Et(e,{clearMessages:!0}),onToggle:(d,u)=>ld(e,d,u),onEdit:(d,u)=>rd(e,d,u),onSaveKey:d=>cd(e,d),onInstall:(d,u,g)=>dd(e,d,u,g)}):f}
|
|
3176
3176
|
|
|
3177
|
-
${e.tab==="nodes"?
|
|
3177
|
+
${e.tab==="nodes"?nf({loading:e.nodesLoading,nodes:e.nodes,devicesLoading:e.devicesLoading,devicesError:e.devicesError,devicesList:e.devicesList,configForm:e.configForm??e.configSnapshot?.config,configLoading:e.configLoading,configSaving:e.configSaving,configDirty:e.configFormDirty,configFormMode:e.configFormMode,execApprovalsLoading:e.execApprovalsLoading,execApprovalsSaving:e.execApprovalsSaving,execApprovalsDirty:e.execApprovalsDirty,execApprovalsSnapshot:e.execApprovalsSnapshot,execApprovalsForm:e.execApprovalsForm,execApprovalsSelectedAgent:e.execApprovalsSelectedAgent,execApprovalsTarget:e.execApprovalsTarget,execApprovalsTargetNodeId:e.execApprovalsTargetNodeId,onRefresh:()=>gn(e),onDevicesRefresh:()=>Ce(e),onDeviceApprove:d=>Zc(e,d),onDeviceReject:d=>Jc(e,d),onDeviceRotate:(d,u,g)=>Xc(e,{deviceId:d,role:u,scopes:g}),onDeviceRevoke:(d,u)=>ed(e,{deviceId:d,role:u}),onLoadConfig:()=>ye(e),onLoadExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return Gs(e,d)},onBindDefault:d=>{d?Ft(e,["tools","exec","node"],d):oa(e,["tools","exec","node"])},onBindAgent:(d,u)=>{const g=["agents","list",d,"tools","exec","node"];u?Ft(e,g,u):oa(e,g)},onSaveBindings:()=>ps(e),onExecApprovalsTargetChange:(d,u)=>{e.execApprovalsTarget=d,e.execApprovalsTargetNodeId=u,e.execApprovalsSnapshot=null,e.execApprovalsForm=null,e.execApprovalsDirty=!1,e.execApprovalsSelectedAgent=null},onExecApprovalsSelectAgent:d=>{e.execApprovalsSelectedAgent=d},onExecApprovalsPatch:(d,u)=>ad(e,d,u),onExecApprovalsRemove:d=>od(e,d),onSaveExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return id(e,d)}}):f}
|
|
3178
3178
|
|
|
3179
|
-
${e.tab==="chat"?
|
|
3179
|
+
${e.tab==="chat"?qp({sessionKey:e.sessionKey,onSessionKeyChange:d=>{e.sessionKey=d,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:d,lastActiveSessionKey:d}),e.loadAssistantIdentity(),St(e),ms(e)},thinkingLevel:e.chatThinkingLevel,showThinking:r,loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:p,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,connected:e.connected,canSend:e.connected,disabledReason:i,error:e.lastError,sessions:e.sessionsResult,focusMode:o,onRefresh:()=>(e.resetToolStream(),Promise.all([St(e),ms(e)])),onToggleFocusMode:()=>{e.onboarding||e.applySettings({...e.settings,chatFocusMode:!e.settings.chatFocusMode})},onChatScroll:d=>e.handleChatScroll(d),onDraftChange:d=>e.chatMessage=d,attachments:e.chatAttachments,onAttachmentsChange:d=>e.chatAttachments=d,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:d=>e.removeQueuedMessage(d),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:d=>e.handleOpenSidebar(d),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:d=>e.handleSplitRatioChange(d),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar}):f}
|
|
3180
3180
|
|
|
3181
|
-
${e.tab==="config"?
|
|
3181
|
+
${e.tab==="config"?ch({raw:e.configRaw,originalRaw:e.configRawOriginal,valid:e.configValid,issues:e.configIssues,loading:e.configLoading,saving:e.configSaving,applying:e.configApplying,updating:e.updateRunning,connected:e.connected,schema:e.configSchema,schemaLoading:e.configSchemaLoading,uiHints:e.configUiHints,formMode:e.configFormMode,formValue:e.configForm,originalValue:e.configFormOriginal,searchQuery:e.configSearchQuery,activeSection:e.configActiveSection,activeSubsection:e.configActiveSubsection,onRawChange:d=>{e.configRaw=d},onFormModeChange:d=>e.configFormMode=d,onFormPatch:(d,u)=>Ft(e,d,u),onSearchChange:d=>e.configSearchQuery=d,onSectionChange:d=>{e.configActiveSection=d,e.configActiveSubsection=null},onSubsectionChange:d=>e.configActiveSubsection=d,onReload:()=>ye(e),onSave:()=>ps(e),onApply:()=>rc(e),onUpdate:()=>lc(e)}):f}
|
|
3182
3182
|
|
|
3183
|
-
${e.tab==="debug"?
|
|
3183
|
+
${e.tab==="debug"?Qh({loading:e.debugLoading,status:e.debugStatus,health:e.debugHealth,models:e.debugModels,heartbeat:e.debugHeartbeat,eventLog:e.eventLog,callMethod:e.debugCallMethod,callParams:e.debugCallParams,callResult:e.debugCallResult,callError:e.debugCallError,onCallMethodChange:d=>e.debugCallMethod=d,onCallParamsChange:d=>e.debugCallParams=d,onRefresh:()=>hn(e),onCall:()=>yc(e)}):f}
|
|
3184
3184
|
|
|
3185
|
-
${e.tab==="logs"?
|
|
3185
|
+
${e.tab==="logs"?tf({loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,truncated:e.logsTruncated,onFilterTextChange:d=>e.logsFilterText=d,onLevelToggle:(d,u)=>{e.logsLevelFilters={...e.logsLevelFilters,[d]:u}},onToggleAutoFollow:d=>e.logsAutoFollow=d,onRefresh:()=>Fs(e,{reset:!0}),onExport:(d,u)=>e.exportLogs(d,u),onScroll:d=>e.handleLogsScroll(d)}):f}
|
|
3186
3186
|
</main>
|
|
3187
|
-
${
|
|
3188
|
-
${
|
|
3187
|
+
${Uf(e)}
|
|
3188
|
+
${Kf(e)}
|
|
3189
3189
|
</div>
|
|
3190
|
-
`}const cg={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},dg={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};async function ug(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}}}const _r={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"lemonade-control-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"lemonade-macos",IOS_APP:"lemonade-ios",ANDROID_APP:"lemonade-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"lemonade-probe"},Xa=_r,Es={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(_r));new Set(Object.values(Es));function pg(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),s=e.token??"",i=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),s];return t==="v2"&&i.push(e.nonce??""),i.join("|")}const hg=4008;class fg{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(){this.closed=!0,this.ws?.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){return this.ws?.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=>{const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),this.opts.onClose?.({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(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.approvals","operator.pairing"],s="operator";let i=null,a=!1,o=this.opts.token;if(t){i=await zs();const d=Qc({deviceId:i.deviceId,role:s})?.token;o=d??this.opts.token,a=!!(d&&this.opts.token)}const r=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let l;if(t&&i){const d=Date.now(),u=this.connectNonce??void 0,g=pg({deviceId:i.deviceId,clientId:this.opts.clientName??Xa.CONTROL_UI,clientMode:this.opts.mode??Es.WEBCHAT,role:s,scopes:n,signedAtMs:d,token:o??null,nonce:u}),v=await Vc(i.privateKey,g);l={id:i.deviceId,publicKey:i.publicKey,signature:v,signedAt:d,nonce:u}}const p={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Xa.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Es.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:l,caps:[],auth:r,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",p).then(d=>{d?.auth?.deviceToken&&i&&Bo({deviceId:i.deviceId,role:d.auth.role??s,token:d.auth.deviceToken,scopes:d.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(d)}).catch(()=>{a&&i&&Fo({deviceId:i.deviceId,role:s}),this.ws?.close(hg,"connect failed")})}handleMessage(t){let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const i=n;if(i.event==="connect.challenge"){const o=i.payload,r=o&&typeof o.nonce=="string"?o.nonce:null;r&&(this.connectNonce=r,this.sendConnect());return}const a=typeof i.seq=="number"?i.seq:null;a!==null&&(this.lastSeq!==null&&a>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:a}),this.lastSeq=a);try{this.opts.onEvent?.(i)}catch(o){console.error("[gateway] event handler error:",o)}return}if(s.type==="res"){const i=n,a=this.pending.get(i.id);if(!a)return;this.pending.delete(i.id),i.ok?a.resolve(i.payload):a.reject(new Error(i.error?.message??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const s=Bs(),i={type:"req",id:s,method:t,params:n},a=new Promise((o,r)=>{this.pending.set(s,{resolve:l=>o(l),reject:r})});return this.ws.send(JSON.stringify(i)),a}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ms(e){return typeof e=="object"&&e!==null}function gg(e){if(!Ms(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ms(n))return null;const s=typeof n.command=="string"?n.command.trim():"";if(!s)return null;const i=typeof e.createdAtMs=="number"?e.createdAtMs:0,a=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!a?null:{id:t,request:{command:s,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:i,expiresAtMs:a}}function vg(e){if(!Ms(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 Cr(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function mg(e,t){const n=Cr(e).filter(s=>s.id!==t.id);return n.push(t),n}function eo(e,t){return Cr(e).filter(n=>n.id!==t)}async function Tr(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),s=n?{sessionKey:n}:{};try{const i=await e.client.request("agent.identity.get",s);if(!i)return;const a=os(i);e.assistantName=a.name,e.assistantAvatar=a.avatar,e.assistantAgentId=a.agentId??null}catch{}}function is(e,t){const n=(e??"").trim(),s=t.mainSessionKey?.trim();if(!s)return n;if(!n)return s;const i=t.mainKey?.trim()||"main",a=t.defaultAgentId?.trim();return n==="main"||n===i||a&&(n===`agent:${a}:main`||n===`agent:${a}:${i}`)?s:n}function yg(e,t){if(!t?.mainSessionKey)return;const n=is(e.sessionKey,t),s=is(e.settings.sessionKey,t),i=is(e.settings.lastActiveSessionKey,t),a=n||s||e.sessionKey,o={...e.settings,sessionKey:s||a,lastActiveSessionKey:i||a},r=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;a!==e.sessionKey&&(e.sessionKey=a),r&&Se(e,o)}function Er(e){e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null,e.client?.stop(),e.client=new fg({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:"lemonade-control-ui",mode:"webchat",onHello:t=>{e.connected=!0,e.lastError=null,e.hello=t,$g(e,t),e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,un(e),Tr(e),ug(e),vn(e,{quiet:!0}),Ce(e,{quiet:!0}),Xs(e)},onClose:({code:t,reason:n})=>{e.connected=!1,t!==1012&&(e.lastError=`disconnected (${t}): ${n||"no reason"}`)},onEvent:t=>bg(e,t),onGap:({expected:t,received:n})=>{e.lastError=`event gap detected (expected seq ${t}, got ${n}); refresh recommended`}}),e.client.start()}function bg(e,t){try{wg(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function wg(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;Xl(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n?.sessionKey&&Uo(e,n.sessionKey);const s=Kl(e,n);(s==="final"||s==="error"||s==="aborted")&&(un(e),Rd(e),e.refreshSessionsAfterChat&&(e.refreshSessionsAfterChat=!1,s==="final"&&He(e,{activeMinutes:0}))),s==="final"&&_t(e);return}if(t.event==="presence"){const n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&ei(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Ce(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=gg(t.payload);if(n){e.execApprovalQueue=mg(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=eo(e.execApprovalQueue,n.id)},s)}return}if(t.event==="exec.approval.resolved"){const n=vg(t.payload);n&&(e.execApprovalQueue=eo(e.execApprovalQueue,n.id))}}function $g(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&yg(e,n.sessionDefaults)}function xg(e){e.basePath=bd(),vd(e),Ad(e,!0),wd(e),$d(e),window.addEventListener("popstate",e.popStateHandler),Er(e),fd(e),e.tab==="logs"&&Ys(e),e.tab==="debug"&&Zs(e)}function Ag(e){ic(e)}function kg(e){window.removeEventListener("popstate",e.popStateHandler),gd(e),Qs(e),Js(e),xd(e),e.topbarObserver?.disconnect(),e.topbarObserver=null}function Sg(e,t){if(e.tab==="chat"&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),s=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;pn(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&mo(e,t.has("tab")||t.has("logsAutoFollow"))}async function _g(e,t){await gc(e,t),await oe(e,!0)}async function Cg(e){await vc(e),await oe(e,!0)}async function Tg(e){await mc(e),await oe(e,!0)}async function Eg(e){await ps(e),await ye(e),await oe(e,!0)}async function Mg(e){await ye(e),await oe(e,!0)}function Lg(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[s,...i]=n.split(":");if(!s||i.length===0)continue;const a=s.trim(),o=i.join(":").trim();a&&o&&(t[a]=o)}return t}function Mr(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??"default"}function Lr(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function Rg(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Ch(n??void 0)}function Ig(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function Pg(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function Ng(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function Og(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Mr(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Lr(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const a=i?.error??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:a,success:null,fieldErrors:Lg(i?.details)};return}if(!i.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await oe(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function Dg(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Mr(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Lr(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const l=i?.error??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const a=i.merged??i.imported??null,o=a?{...t.values,...a}:t.values,r=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:r},i.saved&&await oe(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}var Bg=Object.defineProperty,Fg=Object.getOwnPropertyDescriptor,b=(e,t,n,s)=>{for(var i=s>1?void 0:s?Fg(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&Bg(t,n,i),i};const as=wl();function Ug(){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"}let y=class extends Xe{constructor(){super(...arguments),this.settings=$l(),this.password="",this.tab="chat",this.onboarding=Ug(),this.connected=!1,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=as.name,this.assistantAvatar=as.avatar,this.assistantAgentId=as.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.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.pendingGatewayUrl=null,this.configLoading=!1,this.configRaw=`{
|
|
3190
|
+
`}const sg={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},ig={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};async function ag(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}}}const _r={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"lemonade-control-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"lemonade-macos",IOS_APP:"lemonade-ios",ANDROID_APP:"lemonade-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"lemonade-probe"},Xa=_r,Es={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(_r));new Set(Object.values(Es));function og(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),s=e.token??"",i=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),s];return t==="v2"&&i.push(e.nonce??""),i.join("|")}const rg=4008;class lg{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(){this.closed=!0,this.ws?.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){return this.ws?.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=>{const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),this.opts.onClose?.({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(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.approvals","operator.pairing"],s="operator";let i=null,a=!1,o=this.opts.token;if(t){i=await zs();const d=Qc({deviceId:i.deviceId,role:s})?.token;o=d??this.opts.token,a=!!(d&&this.opts.token)}const r=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let l;if(t&&i){const d=Date.now(),u=this.connectNonce??void 0,g=og({deviceId:i.deviceId,clientId:this.opts.clientName??Xa.CONTROL_UI,clientMode:this.opts.mode??Es.WEBCHAT,role:s,scopes:n,signedAtMs:d,token:o??null,nonce:u}),v=await Vc(i.privateKey,g);l={id:i.deviceId,publicKey:i.publicKey,signature:v,signedAt:d,nonce:u}}const p={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??Xa.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Es.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:l,caps:[],auth:r,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",p).then(d=>{d?.auth?.deviceToken&&i&&Fo({deviceId:i.deviceId,role:d.auth.role??s,token:d.auth.deviceToken,scopes:d.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(d)}).catch(()=>{a&&i&&Uo({deviceId:i.deviceId,role:s}),this.ws?.close(rg,"connect failed")})}handleMessage(t){let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const i=n;if(i.event==="connect.challenge"){const o=i.payload,r=o&&typeof o.nonce=="string"?o.nonce:null;r&&(this.connectNonce=r,this.sendConnect());return}const a=typeof i.seq=="number"?i.seq:null;a!==null&&(this.lastSeq!==null&&a>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:a}),this.lastSeq=a);try{this.opts.onEvent?.(i)}catch(o){console.error("[gateway] event handler error:",o)}return}if(s.type==="res"){const i=n,a=this.pending.get(i.id);if(!a)return;this.pending.delete(i.id),i.ok?a.resolve(i.payload):a.reject(new Error(i.error?.message??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const s=Bs(),i={type:"req",id:s,method:t,params:n},a=new Promise((o,r)=>{this.pending.set(s,{resolve:l=>o(l),reject:r})});return this.ws.send(JSON.stringify(i)),a}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ms(e){return typeof e=="object"&&e!==null}function cg(e){if(!Ms(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ms(n))return null;const s=typeof n.command=="string"?n.command.trim():"";if(!s)return null;const i=typeof e.createdAtMs=="number"?e.createdAtMs:0,a=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!a?null:{id:t,request:{command:s,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:i,expiresAtMs:a}}function dg(e){if(!Ms(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 Cr(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function ug(e,t){const n=Cr(e).filter(s=>s.id!==t.id);return n.push(t),n}function eo(e,t){return Cr(e).filter(n=>n.id!==t)}async function Tr(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),s=n?{sessionKey:n}:{};try{const i=await e.client.request("agent.identity.get",s);if(!i)return;const a=os(i);e.assistantName=a.name,e.assistantAvatar=a.avatar,e.assistantAgentId=a.agentId??null}catch{}}function ss(e,t){const n=(e??"").trim(),s=t.mainSessionKey?.trim();if(!s)return n;if(!n)return s;const i=t.mainKey?.trim()||"main",a=t.defaultAgentId?.trim();return n==="main"||n===i||a&&(n===`agent:${a}:main`||n===`agent:${a}:${i}`)?s:n}function pg(e,t){if(!t?.mainSessionKey)return;const n=ss(e.sessionKey,t),s=ss(e.settings.sessionKey,t),i=ss(e.settings.lastActiveSessionKey,t),a=n||s||e.sessionKey,o={...e.settings,sessionKey:s||a,lastActiveSessionKey:i||a},r=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;a!==e.sessionKey&&(e.sessionKey=a),r&&Se(e,o)}function Er(e){e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null,e.client?.stop(),e.client=new lg({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:"lemonade-control-ui",mode:"webchat",onHello:t=>{e.connected=!0,e.lastError=null,e.hello=t,gg(e,t),e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,dn(e),Tr(e),ag(e),gn(e,{quiet:!0}),Ce(e,{quiet:!0}),Xs(e)},onClose:({code:t,reason:n})=>{e.connected=!1,t!==1012&&(e.lastError=`disconnected (${t}): ${n||"no reason"}`)},onEvent:t=>hg(e,t),onGap:({expected:t,received:n})=>{e.lastError=`event gap detected (expected seq ${t}, got ${n}); refresh recommended`}}),e.client.start()}function hg(e,t){try{fg(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function fg(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;Xl(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n?.sessionKey&&Ko(e,n.sessionKey);const s=Kl(e,n);(s==="final"||s==="error"||s==="aborted")&&(dn(e),Id(e),e.refreshSessionsAfterChat&&(e.refreshSessionsAfterChat=!1,s==="final"&&Ke(e,{activeMinutes:0}))),s==="final"&&St(e);return}if(t.event==="presence"){const n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&ei(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Ce(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=cg(t.payload);if(n){e.execApprovalQueue=ug(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=eo(e.execApprovalQueue,n.id)},s)}return}if(t.event==="exec.approval.resolved"){const n=dg(t.payload);n&&(e.execApprovalQueue=eo(e.execApprovalQueue,n.id))}}function gg(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&pg(e,n.sessionDefaults)}function vg(e){e.basePath=bd(),vd(e),Ad(e,!0),wd(e),$d(e),window.addEventListener("popstate",e.popStateHandler),Er(e),fd(e),e.tab==="logs"&&Ys(e),e.tab==="debug"&&Zs(e)}function mg(e){ic(e)}function yg(e){window.removeEventListener("popstate",e.popStateHandler),gd(e),Qs(e),Js(e),xd(e),e.topbarObserver?.disconnect(),e.topbarObserver=null}function bg(e,t){if(e.tab==="chat"&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),s=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;un(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&yo(e,t.has("tab")||t.has("logsAutoFollow"))}async function wg(e,t){await gc(e,t),await oe(e,!0)}async function $g(e){await vc(e),await oe(e,!0)}async function xg(e){await mc(e),await oe(e,!0)}async function Ag(e){await ps(e),await ye(e),await oe(e,!0)}async function kg(e){await ye(e),await oe(e,!0)}function Sg(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[s,...i]=n.split(":");if(!s||i.length===0)continue;const a=s.trim(),o=i.join(":").trim();a&&o&&(t[a]=o)}return t}function Mr(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??"default"}function Lr(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function _g(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=$h(n??void 0)}function Cg(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function Tg(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function Eg(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function Mg(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Mr(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Lr(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const a=i?.error??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:a,success:null,fieldErrors:Sg(i?.details)};return}if(!i.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await oe(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function Lg(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Mr(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Lr(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const l=i?.error??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const a=i.merged??i.imported??null,o=a?{...t.values,...a}:t.values,r=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:r},i.saved&&await oe(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}var Ig=Object.defineProperty,Rg=Object.getOwnPropertyDescriptor,b=(e,t,n,s)=>{for(var i=s>1?void 0:s?Rg(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&Ig(t,n,i),i};const is=wl();function Pg(){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"}let m=class extends Je{constructor(){super(...arguments),this.settings=$l(),this.password="",this.tab="chat",this.onboarding=Pg(),this.connected=!1,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=is.name,this.assistantAvatar=is.avatar,this.assistantAgentId=is.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.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.pendingGatewayUrl=null,this.configLoading=!1,this.configRaw=`{
|
|
3191
3191
|
}
|
|
3192
|
-
`,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.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.sessionsFilterActive="",this.sessionsFilterLimit="120",this.sessionsIncludeGlobal=!0,this.sessionsIncludeUnknown=!1,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...
|
|
3193
|
-
//# sourceMappingURL=index-
|
|
3192
|
+
`,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.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.sessionsFilterActive="",this.sessionsFilterLimit="120",this.sessionsIncludeGlobal=!0,this.sessionsIncludeUnknown=!1,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...ig},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},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={...sg},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.nodesPollInterval=null,this.logsPollInterval=null,this.debugPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.refreshSessionsAfterChat=!1,this.basePath="",this.popStateHandler=()=>kd(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),vg(this)}firstUpdated(){mg(this)}disconnectedCallback(){yg(this),super.disconnectedCallback()}updated(e){bg(this,e)}connect(){Er(this)}handleChatScroll(e){ec(this,e)}handleLogsScroll(e){tc(this,e)}exportLogs(e,t){sc(e,t)}resetToolStream(){dn(this)}resetChatScroll(){nc(this)}async loadAssistantIdentity(){await Tr(this)}applySettings(e){Se(this,e)}setTab(e){md(this,e)}setTheme(e,t){yd(this,e,t)}async loadOverview(){await jo(this)}async loadCron(){await ei(this)}async handleAbortChat(){await Go(this)}removeQueuedMessage(e){Md(this,e)}async handleSendChat(e,t){await Ld(this,e,t)}async handleWhatsAppStart(e){await wg(this,e)}async handleWhatsAppWait(){await $g(this)}async handleWhatsAppLogout(){await xg(this)}async handleChannelConfigSave(){await Ag(this)}async handleChannelConfigReload(){await kg(this)}handleNostrProfileEdit(e,t){_g(this,e,t)}handleNostrProfileCancel(){Cg(this)}handleNostrProfileFieldChange(e,t){Tg(this,e,t)}async handleNostrProfileSave(){await Mg(this)}async handleNostrProfileImport(){await Lg(this)}handleNostrProfileToggleAdvanced(){Eg(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}}}handleGatewayUrlConfirm(){const e=this.pendingGatewayUrl;e&&(this.pendingGatewayUrl=null,Se(this,{...this.settings,gatewayUrl:e}),this.connect())}handleGatewayUrlCancel(){this.pendingGatewayUrl=null}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})}render(){return ng(this)}};b([w()],m.prototype,"settings",2);b([w()],m.prototype,"password",2);b([w()],m.prototype,"tab",2);b([w()],m.prototype,"onboarding",2);b([w()],m.prototype,"connected",2);b([w()],m.prototype,"theme",2);b([w()],m.prototype,"themeResolved",2);b([w()],m.prototype,"hello",2);b([w()],m.prototype,"lastError",2);b([w()],m.prototype,"eventLog",2);b([w()],m.prototype,"assistantName",2);b([w()],m.prototype,"assistantAvatar",2);b([w()],m.prototype,"assistantAgentId",2);b([w()],m.prototype,"sessionKey",2);b([w()],m.prototype,"chatLoading",2);b([w()],m.prototype,"chatSending",2);b([w()],m.prototype,"chatMessage",2);b([w()],m.prototype,"chatMessages",2);b([w()],m.prototype,"chatToolMessages",2);b([w()],m.prototype,"chatStream",2);b([w()],m.prototype,"chatStreamStartedAt",2);b([w()],m.prototype,"chatRunId",2);b([w()],m.prototype,"compactionStatus",2);b([w()],m.prototype,"chatAvatarUrl",2);b([w()],m.prototype,"chatThinkingLevel",2);b([w()],m.prototype,"chatQueue",2);b([w()],m.prototype,"chatAttachments",2);b([w()],m.prototype,"sidebarOpen",2);b([w()],m.prototype,"sidebarContent",2);b([w()],m.prototype,"sidebarError",2);b([w()],m.prototype,"splitRatio",2);b([w()],m.prototype,"nodesLoading",2);b([w()],m.prototype,"nodes",2);b([w()],m.prototype,"devicesLoading",2);b([w()],m.prototype,"devicesError",2);b([w()],m.prototype,"devicesList",2);b([w()],m.prototype,"execApprovalsLoading",2);b([w()],m.prototype,"execApprovalsSaving",2);b([w()],m.prototype,"execApprovalsDirty",2);b([w()],m.prototype,"execApprovalsSnapshot",2);b([w()],m.prototype,"execApprovalsForm",2);b([w()],m.prototype,"execApprovalsSelectedAgent",2);b([w()],m.prototype,"execApprovalsTarget",2);b([w()],m.prototype,"execApprovalsTargetNodeId",2);b([w()],m.prototype,"execApprovalQueue",2);b([w()],m.prototype,"execApprovalBusy",2);b([w()],m.prototype,"execApprovalError",2);b([w()],m.prototype,"pendingGatewayUrl",2);b([w()],m.prototype,"configLoading",2);b([w()],m.prototype,"configRaw",2);b([w()],m.prototype,"configRawOriginal",2);b([w()],m.prototype,"configValid",2);b([w()],m.prototype,"configIssues",2);b([w()],m.prototype,"configSaving",2);b([w()],m.prototype,"configApplying",2);b([w()],m.prototype,"updateRunning",2);b([w()],m.prototype,"applySessionKey",2);b([w()],m.prototype,"configSnapshot",2);b([w()],m.prototype,"configSchema",2);b([w()],m.prototype,"configSchemaVersion",2);b([w()],m.prototype,"configSchemaLoading",2);b([w()],m.prototype,"configUiHints",2);b([w()],m.prototype,"configForm",2);b([w()],m.prototype,"configFormOriginal",2);b([w()],m.prototype,"configFormDirty",2);b([w()],m.prototype,"configFormMode",2);b([w()],m.prototype,"configSearchQuery",2);b([w()],m.prototype,"configActiveSection",2);b([w()],m.prototype,"configActiveSubsection",2);b([w()],m.prototype,"channelsLoading",2);b([w()],m.prototype,"channelsSnapshot",2);b([w()],m.prototype,"channelsError",2);b([w()],m.prototype,"channelsLastSuccess",2);b([w()],m.prototype,"whatsappLoginMessage",2);b([w()],m.prototype,"whatsappLoginQrDataUrl",2);b([w()],m.prototype,"whatsappLoginConnected",2);b([w()],m.prototype,"whatsappBusy",2);b([w()],m.prototype,"nostrProfileFormState",2);b([w()],m.prototype,"nostrProfileAccountId",2);b([w()],m.prototype,"presenceLoading",2);b([w()],m.prototype,"presenceEntries",2);b([w()],m.prototype,"presenceError",2);b([w()],m.prototype,"presenceStatus",2);b([w()],m.prototype,"agentsLoading",2);b([w()],m.prototype,"agentsList",2);b([w()],m.prototype,"agentsError",2);b([w()],m.prototype,"sessionsLoading",2);b([w()],m.prototype,"sessionsResult",2);b([w()],m.prototype,"sessionsError",2);b([w()],m.prototype,"sessionsFilterActive",2);b([w()],m.prototype,"sessionsFilterLimit",2);b([w()],m.prototype,"sessionsIncludeGlobal",2);b([w()],m.prototype,"sessionsIncludeUnknown",2);b([w()],m.prototype,"cronLoading",2);b([w()],m.prototype,"cronJobs",2);b([w()],m.prototype,"cronStatus",2);b([w()],m.prototype,"cronError",2);b([w()],m.prototype,"cronForm",2);b([w()],m.prototype,"cronRunsJobId",2);b([w()],m.prototype,"cronRuns",2);b([w()],m.prototype,"cronBusy",2);b([w()],m.prototype,"skillsLoading",2);b([w()],m.prototype,"skillsReport",2);b([w()],m.prototype,"skillsError",2);b([w()],m.prototype,"skillsFilter",2);b([w()],m.prototype,"skillEdits",2);b([w()],m.prototype,"skillsBusyKey",2);b([w()],m.prototype,"skillMessages",2);b([w()],m.prototype,"debugLoading",2);b([w()],m.prototype,"debugStatus",2);b([w()],m.prototype,"debugHealth",2);b([w()],m.prototype,"debugModels",2);b([w()],m.prototype,"debugHeartbeat",2);b([w()],m.prototype,"debugCallMethod",2);b([w()],m.prototype,"debugCallParams",2);b([w()],m.prototype,"debugCallResult",2);b([w()],m.prototype,"debugCallError",2);b([w()],m.prototype,"logsLoading",2);b([w()],m.prototype,"logsError",2);b([w()],m.prototype,"logsFile",2);b([w()],m.prototype,"logsEntries",2);b([w()],m.prototype,"logsFilterText",2);b([w()],m.prototype,"logsLevelFilters",2);b([w()],m.prototype,"logsAutoFollow",2);b([w()],m.prototype,"logsTruncated",2);b([w()],m.prototype,"logsCursor",2);b([w()],m.prototype,"logsLastFetchAt",2);b([w()],m.prototype,"logsLimit",2);b([w()],m.prototype,"logsMaxBytes",2);b([w()],m.prototype,"logsAtBottom",2);m=b([lo("lemonade-app")],m);
|
|
3193
|
+
//# sourceMappingURL=index-D5pbk0Cx.js.map
|