diff --git a/ui/dist/assets/index.js b/ui/dist/assets/index.js index 32eb3c52b..f01a35244 100644 --- a/ui/dist/assets/index.js +++ b/ui/dist/assets/index.js @@ -1,16 +1,16 @@ (function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function e(e=globalThis.crypto){if(typeof e?.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues==`function`)e.getRandomValues(t);else for(let e=0;ee.toString(16).padStart(2,`0`));return`${n.slice(0,4).join(``)}-${n.slice(4,6).join(``)}-${n.slice(6,8).join(``)}-${n.slice(8,10).join(``)}-${n.slice(10).join(``)}`}async function t(e){let t=await fetch(e,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(15e3)});if(t.status===401)throw new i(`unauthorised`,401);if(!t.ok)throw new i(`${t.status} ${t.statusText}`,t.status);return t.json()}function n(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e||{}))r!==``&&r!=null&&t.set(n,r);let n=t.toString();return n?`?${n}`:``}async function r(e){try{let t=(await e.text()).trim();if(t)return t.split(` -`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var i=class extends Error{constructor(e,t){super(e),this.status=t}},a={summary:()=>t(`/api/summary`),tasks:()=>t(`/api/tasks`),taskMeta:()=>t(`/api/task-meta`),task:e=>t(`/api/tasks/${e}`),taskAction:async(e,t)=>{let n=await fetch(`/api/tasks/${e}/action`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({action:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},setup:()=>t(`/api/setup`),workflows:()=>t(`/api/workflows`),workRequest:async e=>{let t=await fetch(`/api/work-requests`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},skills:()=>t(`/api/skills`),channels:()=>t(`/api/channels`),curators:()=>t(`/api/curators`),channelReload:async e=>{let t=await fetch(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:`{}`,signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},config:()=>t(`/api/config`),version:()=>t(`/api/version`),configUpdate:async e=>{let t=await fetch(`/api/config`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({updates:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},configRepoUpdate:async(e,t,n,a)=>{let o=await fetch(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({field:n,value:a}),signal:AbortSignal.timeout(15e3)});if(!o.ok)throw new i(await r(o),o.status);return o.json()},configReset:async e=>{let t=await fetch(`/api/config/reset`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({key:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},logs:e=>t(`/api/logs`+n(e)),taskLogs:(e,r)=>t(`/api/tasks/${e}/logs`+n(r)),captures:e=>t(`/api/captures`+n({limit:e})),mappings:()=>t(`/api/mappings`),mappingCreate:async e=>{let t=await fetch(`/api/mappings`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},mappingUpdate:async(e,t)=>{let n=await fetch(`/api/mappings/${e}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},mappingDelete:async e=>{let t=await fetch(`/api/mappings/${e}`,{method:`DELETE`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status)},mappingPreview:async(e,t)=>{let n=await fetch(`/api/mappings/preview`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({capture_id:e,fields:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},memory:()=>t(`/api/memory`),chatSessions:()=>t(`/api/chat/sessions`),chatMessages:e=>t(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>t(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:async e=>{let t=await fetch(`/api/chat/cancel`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatMessage:async(t,n)=>{let a=await fetch(`/api/chat/message`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({channel_id:t,source_id:e(),text:n,page:location.hash.slice(1)||`/`}),signal:AbortSignal.timeout(15e3)});if(!a.ok)throw new i(await r(a),a.status);return a.json()},chatPersona:async(e,t)=>{let n=await fetch(`/api/chat/persona`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e,name:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},chatUpdate:()=>t(`/api/chat/update`),chatUpdateDefer:async e=>{let t=await fetch(`/api/chat/update/defer`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({snapshot:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatUpdateInstall:async e=>{let t=await fetch(`/api/chat/update/install`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({snapshot:e}),signal:AbortSignal.timeout(12e4)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatDangerous:()=>t(`/api/chat/dangerous`),chatDangerousRequest:async(e,t)=>{let n=await fetch(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({spec:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},chatDangerousDecision:async(e,t)=>{let n=await fetch(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({decision:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()}};function o(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function s(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}var c=[{id:`queued`,label:`Queued`,kind:`idle`},{id:`running`,label:`Working`,kind:`info`},{id:`waiting_human`,label:`Waiting for you`,kind:`warn`,needs_you:!0},{id:`pr_open`,label:`In review`,kind:`ok`},{id:`merged`,label:`Merged`,kind:`ok`},{id:`parked`,label:`Parked`,kind:`warn`,needs_you:!0},{id:`dead`,label:`Stopped (too many retries)`,kind:`danger`},{id:`rejected`,label:`Rejected`,kind:`danger`},{id:`closed_wont_do`,label:`Won't do`,kind:`idle`}],l=[{id:`cancel`,label:`Cancel`,kind:`quiet`,confirm:`Cancel "{title}"? This closes the forge issue.`},{id:`stop`,label:`Stop`,kind:`primary`,confirm:`Stop "{title}"? Recoverable work will remain parked.`},{id:`approve`,label:`Approve`,kind:`primary`},{id:`reject`,label:`Reject`,kind:`quiet`,confirm:`Reject "{title}"? This closes the forge issue.`},{id:`retry`,label:`Retry`,kind:`primary`},{id:`abandon`,label:`Abandon`,kind:`quiet`,confirm:`Abandon "{title}"? This closes the forge issue.`},{id:`archive`,label:`Archive`,kind:`quiet`,confirm:`Archive the local record for "{title}"?`},{id:`open_pr`,label:`Open PR`,kind:`link`},{id:`open_issue`,label:`Open issue`,kind:`link`}],u=[...c],d=[...l],f=new Map(u.map(e=>[e.id,e])),p=new Map(d.map(e=>[e.id,e]));function m(e){return f.get(e)?.label||e||`Unknown`}function h(e){return f.get(e)?.kind||`idle`}function g(){return u.map(e=>e.id)}function _(){return new Set(u.filter(e=>e.needs_you).map(e=>e.id))}function v(e){return p.get(e)||null}function y(e,t,...n){let[r,...i]=e.split(`.`),a=document.createElement(r||`div`);i.length&&(a.className=i.join(` `)),t!==void 0&&(typeof t!=`object`||t instanceof Node)&&(n.unshift(t),t=null);for(let[e,n]of Object.entries(t||{}))n!=null&&n!==!1&&(e.startsWith(`on`)&&typeof n==`function`?a.addEventListener(e.slice(2).toLowerCase(),n):e===`class`?a.className=[a.className,n].filter(Boolean).join(` `):e===`html`?a.innerHTML=n:a.setAttribute(e,n===!0?``:String(n)));return b(a,n),a}function b(e,t){for(let n of t.flat(1/0))n!=null&&n!==!1&&e.append(n instanceof Node?n:document.createTextNode(String(n)))}function x(e,...t){return e.replaceChildren(),b(e,t),e}function S(e,t=`idle`){return y(`span.pill.pill-${t}`,e)}function C(e){if(!e)return`—`;let t=e instanceof Date?e:new Date(e),n=Math.floor((Date.now()-t.getTime())/1e3);if(!Number.isFinite(n))return`—`;if(n<45)return`just now`;let r=[[`min`,60],[`hr`,3600],[`day`,86400],[`wk`,604800]],i=`min`,a=60;for(let[e,t]of r)n>=t&&([i,a]=[e,t]);let o=Math.floor(n/a);return`${o} ${i}${o===1?``:`s`} ago`}function w(e){return e==null||Number.isNaN(e)?`—`:new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e)}function T(e,t){return y(`div.empty`,y(`div.empty-title`,e),t&&y(`div`,t))}var E={dashboard:``,chat:``,tasks:``,logs:``,skills:``,workflows:``,memory:``,channels:``,curators:``,captures:``,mappings:``,settings:``,search:``,moon:``,sun:``,refresh:``,bell:``,trendUp:``,trendDown:``,check:``,close:``,help:``};function D(e,{size:t=18,className:n=``}={}){let r=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);return r.setAttribute(`viewBox`,`0 0 24 24`),r.setAttribute(`width`,String(t)),r.setAttribute(`height`,String(t)),r.setAttribute(`fill`,`none`),r.setAttribute(`stroke`,`currentColor`),r.setAttribute(`stroke-width`,`1.6`),r.setAttribute(`stroke-linecap`,`round`),r.setAttribute(`stroke-linejoin`,`round`),r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`class`,`ico ${n}`.trim()),r.innerHTML=E[e]||E.dashboard,r}var O,k,A,j,M,N,ee,P,te,F,ne,I,L,R,z={},B=[],re=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ie=Array.isArray;function V(e,t){for(var n in t)e[n]=t[n];return e}function ae(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function oe(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?O.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return se(e,o,r,i,null)}function se(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++A,__i:-1,__u:0};return i==null&&k.vnode!=null&&k.vnode(a),a}function H(e){return e.children}function ce(e,t){this.props=e,this.context=t}function U(e,t){if(t==null)return e.__?U(e.__,e.__i+1):null;for(var n;tt&&j.sort(ee),e=j.shift(),t=j.length,le(e)}finally{j.length=W.__r=0}}function fe(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r&&r.__k||B,v=t.length;for(c=pe(n,t,_,c,v),d=0;d0?o=e.__k[a]=se(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=he(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:ic?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a+!!u){for(i=n-1,a=n+1;i>=0||a=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ge(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||re.test(t)?n:n+`px`}function _e(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ge(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ge(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(ne,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[F]=r[F]:(n[F]=I,e.addEventListener(t,a?R:L,a)):e.removeEventListener(t,a?R:L,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function ve(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[te]==null)t[te]=I++;else if(t[te]0?e:ie(e)?e.map(xe):e.constructor===void 0?V({},e):null}function Se(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h,g=n.props||z,_=t.props,v=t.type;if(v==`svg`?i=`http://www.w3.org/2000/svg`:v==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l=n.__.length&&n.__.push({}),n.__[e]}function J(e){return Ae=1,ze(qe,e)}function ze(e,t,n){var r=Re(De++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):qe(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=K,!K.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};K.__f=!0;var a=K.shouldComponentUpdate,o=K.componentWillUpdate;K.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},K.shouldComponentUpdate=i}return r.__N||r.__}function Y(e,t){var n=Re(De++,3);!q.__s&&Ke(n.__H,t)&&(n.__=e,n.u=t,K.__H.__h.push(n))}function X(e){return Ae=5,Be(function(){return{current:e}},[])}function Be(e,t){var n=Re(De++,7);return Ke(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ve(){for(var e;e=je.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(We),t.__h.some(Ge),t.__h=[]}catch(n){t.__h=[],q.__e(n,e.__v)}}}q.__b=function(e){K=null,Me&&Me(e)},q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Le&&Le(e,t)},q.__r=function(e){Ne&&Ne(e),De=0;var t=(K=e.__c).__H;t&&(Oe===K?(t.__h=[],K.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(We),t.__h.some(Ge),t.__h=[],De=0)),Oe=K},q.diffed=function(e){Pe&&Pe(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(je.push(t)!==1&&ke===q.requestAnimationFrame||((ke=q.requestAnimationFrame)||Ue)(Ve)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),Oe=K=null},q.__c=function(e,t){t.some(function(e){try{e.__h.some(We),e.__h=e.__h.filter(function(e){return!e.__||Ge(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],q.__e(n,e.__v)}}),Fe&&Fe(e,t)},q.unmount=function(e){Ie&&Ie(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{We(e)}catch(e){t=e}}),n.__H=void 0,t&&q.__e(t,n.__v))};var He=typeof requestAnimationFrame==`function`;function Ue(e){var t,n=function(){clearTimeout(r),He&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);He&&(t=requestAnimationFrame(n))}function We(e){var t=K,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),K=t}function Ge(e){var t=K;e.__c=e.__(),K=t}function Ke(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function qe(e,t){return typeof t==`function`?t(e):t}function Je({label:e,value:t,unit:n,trend:r,compare:i,series:a=[],goodDirection:o=`up`}){let s=r==null?null:r>=0?`up`:`down`,c=s==null?null:s===o;return y(`div.card.stat`,y(`div.stat-head`,y(`span.stat-label`,e),s&&y(`span.stat-trend.${c?`up`:`down`}`,D(s===`up`?`trendUp`:`trendDown`,{size:13}),`${Math.abs(r).toFixed(1)}%`)),y(`div.stat-value`,t,n&&y(`span.stat-unit`,n)),i&&y(`div.stat-compare`,i),a.length>1&&Ye(a,c===!1?`var(--danger)`:`var(--ok)`))}function Ye(e,t=`var(--ok)`,{width:n=220,height:r=34}={}){let i=Math.max(...e,1),a=Math.min(...e,0),o=i-a||1,s=e.length>1?n/(e.length-1):n,c=e.map((e,t)=>`${(t*s).toFixed(1)},${(r-(e-a)/o*r).toFixed(1)}`).join(` `),l=y(`svg.spark`,{viewBox:`0 0 ${n} ${r}`,preserveAspectRatio:`none`,"aria-hidden":`true`});return l.innerHTML=``,l}function Xe({value:e,label:t,size:n=168}){let r=Math.max(0,Math.min(100,Number(e)||0)),i=r>=90?`var(--ok)`:r>=70?`var(--warn)`:`var(--danger)`,a=n/2,o=n/2,s=2*Math.PI*62*(240/360),c=(e,t)=>{let n=e*Math.PI/180,r=(e+t)*Math.PI/180,i=+(t>180);return[`M ${a+62*Math.cos(n)} ${o+62*Math.sin(n)}`,`A 62 62 0 ${i} 1 ${a+62*Math.cos(r)} ${o+62*Math.sin(r)}`].join(` `)},l=y(`svg.gauge`,{viewBox:`0 0 ${n} ${n*.78}`,role:`img`,"aria-label":`${t}: ${r}%`});return l.innerHTML=` +`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var i=class extends Error{constructor(e,t){super(e),this.status=t}},a={summary:()=>t(`/api/summary`),tasks:()=>t(`/api/tasks`),taskMeta:()=>t(`/api/task-meta`),task:e=>t(`/api/tasks/${e}`),taskAction:async(e,t)=>{let n=await fetch(`/api/tasks/${e}/action`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({action:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},setup:()=>t(`/api/setup`),workflows:()=>t(`/api/workflows`),workRequest:async e=>{let t=await fetch(`/api/work-requests`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},skills:()=>t(`/api/skills`),channels:()=>t(`/api/channels`),curators:()=>t(`/api/curators`),channelReload:async e=>{let t=await fetch(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:`{}`,signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},config:()=>t(`/api/config`),version:()=>t(`/api/version`),configUpdate:async e=>{let t=await fetch(`/api/config`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({updates:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},configRepoUpdate:async(e,t,n,a)=>{let o=await fetch(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({field:n,value:a}),signal:AbortSignal.timeout(15e3)});if(!o.ok)throw new i(await r(o),o.status);return o.json()},configReset:async e=>{let t=await fetch(`/api/config/reset`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({key:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},logs:e=>t(`/api/logs`+n(e)),taskLogs:(e,r)=>t(`/api/tasks/${e}/logs`+n(r)),captures:e=>t(`/api/captures`+n({limit:e})),mappings:()=>t(`/api/mappings`),mappingCreate:async e=>{let t=await fetch(`/api/mappings`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},mappingUpdate:async(e,t)=>{let n=await fetch(`/api/mappings/${e}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},mappingDelete:async e=>{let t=await fetch(`/api/mappings/${e}`,{method:`DELETE`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status)},mappingPreview:async(e,t)=>{let n=await fetch(`/api/mappings/preview`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({capture_id:e,fields:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},memory:()=>t(`/api/memory`),chatSessions:()=>t(`/api/chat/sessions`),chatMessages:e=>t(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>t(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:async e=>{let t=await fetch(`/api/chat/cancel`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatMessage:async(t,n)=>{let a=await fetch(`/api/chat/message`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({channel_id:t,source_id:e(),text:n,page:location.hash.slice(1)||`/`}),signal:AbortSignal.timeout(15e3)});if(!a.ok)throw new i(await r(a),a.status);return a.json()},chatPersona:async(e,t)=>{let n=await fetch(`/api/chat/persona`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e,name:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},chatUpdate:()=>t(`/api/chat/update`),chatUpdateDefer:async e=>{let t=await fetch(`/api/chat/update/defer`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({snapshot:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatUpdateInstall:async e=>{let t=await fetch(`/api/chat/update/install`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({snapshot:e}),signal:AbortSignal.timeout(12e4)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatDangerous:()=>t(`/api/chat/dangerous`),chatDangerousRequest:async(e,t)=>{let n=await fetch(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({spec:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},chatDangerousDecision:async(e,t)=>{let n=await fetch(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({decision:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()}};function o(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function s(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}var c=[{id:`queued`,label:`Queued`,kind:`idle`},{id:`running`,label:`Working`,kind:`info`},{id:`waiting_human`,label:`Waiting for you`,kind:`warn`,needs_you:!0},{id:`pr_open`,label:`In review`,kind:`ok`},{id:`merged`,label:`Merged`,kind:`ok`},{id:`parked`,label:`Parked`,kind:`warn`,needs_you:!0},{id:`dead`,label:`Stopped (too many retries)`,kind:`danger`},{id:`rejected`,label:`Rejected`,kind:`danger`},{id:`closed_wont_do`,label:`Won't do`,kind:`idle`}],l=[{id:`cancel`,label:`Cancel`,kind:`quiet`,confirm:`Cancel "{title}"? This closes the forge issue.`},{id:`stop`,label:`Stop`,kind:`primary`,confirm:`Stop "{title}"? Recoverable work will remain parked.`},{id:`approve`,label:`Approve`,kind:`primary`},{id:`reject`,label:`Reject`,kind:`quiet`,confirm:`Reject "{title}"? This closes the forge issue.`},{id:`retry`,label:`Retry`,kind:`primary`},{id:`abandon`,label:`Abandon`,kind:`quiet`,confirm:`Abandon "{title}"? This closes the forge issue.`},{id:`archive`,label:`Archive`,kind:`quiet`,confirm:`Archive the local record for "{title}"?`},{id:`open_pr`,label:`Open PR`,kind:`link`},{id:`open_issue`,label:`Open issue`,kind:`link`}],u=[...c],d=[...l],f=new Map(u.map(e=>[e.id,e])),p=new Map(d.map(e=>[e.id,e]));function m(e){return f.get(e)?.label||e||`Unknown`}function h(e){return f.get(e)?.kind||`idle`}function g(){return u.map(e=>e.id)}function _(){return new Set(u.filter(e=>e.needs_you).map(e=>e.id))}function v(e){return p.get(e)||null}function y(e,t,...n){let[r,...i]=e.split(`.`),a=document.createElement(r||`div`);i.length&&(a.className=i.join(` `)),t!==void 0&&(typeof t!=`object`||t instanceof Node)&&(n.unshift(t),t=null);for(let[e,n]of Object.entries(t||{}))n!=null&&n!==!1&&(e.startsWith(`on`)&&typeof n==`function`?a.addEventListener(e.slice(2).toLowerCase(),n):e===`class`?a.className=[a.className,n].filter(Boolean).join(` `):e===`html`?a.innerHTML=n:a.setAttribute(e,n===!0?``:String(n)));return b(a,n),a}function b(e,t){for(let n of t.flat(1/0))n!=null&&n!==!1&&e.append(n instanceof Node?n:document.createTextNode(String(n)))}function x(e,...t){return e.replaceChildren(),b(e,t),e}function S(e){if(!e)return`—`;let t=e instanceof Date?e:new Date(e),n=Math.floor((Date.now()-t.getTime())/1e3);if(!Number.isFinite(n))return`—`;if(n<45)return`just now`;let r=[[`min`,60],[`hr`,3600],[`day`,86400],[`wk`,604800]],i=`min`,a=60;for(let[e,t]of r)n>=t&&([i,a]=[e,t]);let o=Math.floor(n/a);return`${o} ${i}${o===1?``:`s`} ago`}function C(e){return e==null||Number.isNaN(e)?`—`:new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e)}var w={dashboard:``,chat:``,tasks:``,logs:``,skills:``,workflows:``,memory:``,channels:``,curators:``,captures:``,mappings:``,settings:``,search:``,moon:``,sun:``,refresh:``,bell:``,trendUp:``,trendDown:``,check:``,close:``,help:``};function T(e,{size:t=18,className:n=``}={}){let r=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);return r.setAttribute(`viewBox`,`0 0 24 24`),r.setAttribute(`width`,String(t)),r.setAttribute(`height`,String(t)),r.setAttribute(`fill`,`none`),r.setAttribute(`stroke`,`currentColor`),r.setAttribute(`stroke-width`,`1.6`),r.setAttribute(`stroke-linecap`,`round`),r.setAttribute(`stroke-linejoin`,`round`),r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`class`,`ico ${n}`.trim()),r.innerHTML=w[e]||w.dashboard,r}var E,D,O,k,A,j,M,N,ee,P,te,ne,re,F,I={},L=[],R=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,z=Array.isArray;function B(e,t){for(var n in t)e[n]=t[n];return e}function ie(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function ae(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?E.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return oe(e,o,r,i,null)}function oe(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++O,__i:-1,__u:0};return i==null&&D.vnode!=null&&D.vnode(a),a}function V(e){return e.children}function se(e,t){this.props=e,this.context=t}function H(e,t){if(t==null)return e.__?H(e.__,e.__i+1):null;for(var n;tt&&k.sort(M),e=k.shift(),t=k.length,ce(e)}finally{k.length=U.__r=0}}function de(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r&&r.__k||L,v=t.length;for(c=fe(n,t,_,c,v),d=0;d0?o=e.__k[a]=oe(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=me(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:ic?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a+!!u){for(i=n-1,a=n+1;i>=0||a=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function he(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||R.test(t)?n:n+`px`}function ge(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||he(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||he(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(te,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[P]=r[P]:(n[P]=ne,e.addEventListener(t,a?F:re,a)):e.removeEventListener(t,a?F:re,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function _e(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[ee]==null)t[ee]=ne++;else if(t[ee]0?e:z(e)?e.map(xe):e.constructor===void 0?B({},e):null}function W(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h,g=n.props||I,_=t.props,v=t.type;if(v==`svg`?i=`http://www.w3.org/2000/svg`:v==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l=n.__.length&&n.__.push({}),n.__[e]}function q(e){return ke=1,Re(Ke,e)}function Re(e,t,n){var r=Le(Ee++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ke(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=G,!G.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};G.__f=!0;var a=G.shouldComponentUpdate,o=G.componentWillUpdate;G.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},G.shouldComponentUpdate=i}return r.__N||r.__}function J(e,t){var n=Le(Ee++,3);!K.__s&&Ge(n.__H,t)&&(n.__=e,n.u=t,G.__H.__h.push(n))}function Y(e){return ke=5,ze(function(){return{current:e}},[])}function ze(e,t){var n=Le(Ee++,7);return Ge(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Be(){for(var e;e=Ae.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ue),t.__h.some(We),t.__h=[]}catch(n){t.__h=[],K.__e(n,e.__v)}}}K.__b=function(e){G=null,je&&je(e)},K.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ie&&Ie(e,t)},K.__r=function(e){Me&&Me(e),Ee=0;var t=(G=e.__c).__H;t&&(De===G?(t.__h=[],G.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Ue),t.__h.some(We),t.__h=[],Ee=0)),De=G},K.diffed=function(e){Ne&&Ne(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ae.push(t)!==1&&Oe===K.requestAnimationFrame||((Oe=K.requestAnimationFrame)||He)(Be)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),De=G=null},K.__c=function(e,t){t.some(function(e){try{e.__h.some(Ue),e.__h=e.__h.filter(function(e){return!e.__||We(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],K.__e(n,e.__v)}}),Pe&&Pe(e,t)},K.unmount=function(e){Fe&&Fe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Ue(e)}catch(e){t=e}}),n.__H=void 0,t&&K.__e(t,n.__v))};var Ve=typeof requestAnimationFrame==`function`;function He(e){var t,n=function(){clearTimeout(r),Ve&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ve&&(t=requestAnimationFrame(n))}function Ue(e){var t=G,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),G=t}function We(e){var t=G;e.__c=e.__(),G=t}function Ge(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ke(e,t){return typeof t==`function`?t(e):t}function qe({label:e,value:t,unit:n,trend:r,compare:i,series:a=[],goodDirection:o=`up`}){let s=r==null?null:r>=0?`up`:`down`,c=s==null?null:s===o;return y(`div.card.stat`,y(`div.stat-head`,y(`span.stat-label`,e),s&&y(`span.stat-trend.${c?`up`:`down`}`,T(s===`up`?`trendUp`:`trendDown`,{size:13}),`${Math.abs(r).toFixed(1)}%`)),y(`div.stat-value`,t,n&&y(`span.stat-unit`,n)),i&&y(`div.stat-compare`,i),a.length>1&&Je(a,c===!1?`var(--danger)`:`var(--ok)`))}function Je(e,t=`var(--ok)`,{width:n=220,height:r=34}={}){let i=Math.max(...e,1),a=Math.min(...e,0),o=i-a||1,s=e.length>1?n/(e.length-1):n,c=e.map((e,t)=>`${(t*s).toFixed(1)},${(r-(e-a)/o*r).toFixed(1)}`).join(` `),l=y(`svg.spark`,{viewBox:`0 0 ${n} ${r}`,preserveAspectRatio:`none`,"aria-hidden":`true`});return l.innerHTML=``,l}function Ye({value:e,label:t,size:n=168}){let r=Math.max(0,Math.min(100,Number(e)||0)),i=r>=90?`var(--ok)`:r>=70?`var(--warn)`:`var(--danger)`,a=n/2,o=n/2,s=2*Math.PI*62*(240/360),c=(e,t)=>{let n=e*Math.PI/180,r=(e+t)*Math.PI/180,i=+(t>180);return[`M ${a+62*Math.cos(n)} ${o+62*Math.sin(n)}`,`A 62 62 0 ${i} 1 ${a+62*Math.cos(r)} ${o+62*Math.sin(r)}`].join(` `)},l=y(`svg.gauge`,{viewBox:`0 0 ${n} ${n*.78}`,role:`img`,"aria-label":`${t}: ${r}%`});return l.innerHTML=` `,y(`div.gauge-wrap`,l,y(`div.gauge-center`,y(`div.gauge-pct`,`${Math.round(r)}%`),y(`div.gauge-label`,t)))}function Ze(e){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return y(`div`,y(`div.segbar`,...e.filter(e=>e.value>0).map(e=>y(`span`,{class:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`}))),y(`div.segbar-legend`,...e.map(e=>y(`span.segbar-key`,y(`span`,{class:`segbar-dot segbar-${e.kind||`idle`}`}),e.label))))}var Qe=`archie.setup-complete.dismissed.v1`;function $e(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(Qe),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function et(e=globalThis.localStorage){e?.setItem?.(Qe,`1`)}var tt=new Set([`waiting_human`,`parked`]);function nt(e=[]){let t=e.filter(e=>tt.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}var rt=0;Array.isArray;function Z(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--rt,__i:-1,__u:0,__source:i,__self:a};if(typeof e==`function`&&(o=e.defaultProps))for(s in o)c[s]===void 0&&(c[s]=o[s]);return k.vnode&&k.vnode(l),l}function it({node:e}){let t=X();return Y(()=>{t.current&&e&&t.current.replaceChildren(e)},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function at(e){return Z(it,{node:Je(e)})}function ot(e){return Z(it,{node:Xe(e)})}function st({segments:e}){return Z(it,{node:Ze(e)})}function ct({name:e,opts:t}){return Z(it,{node:D(e,t)})}function lt({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function ut({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}function dt(e,t){return Number(e.task_id)>0?Number(e.task_id):!e.repo||!e.issue?0:Number(t.get(`${e.repo}#${e.issue}`))||0}function ft(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function pt(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0),r=e.slice(t).reduce((e,t)=>e+t,0);return n?(r-n)/n*100:null}function mt(){let[e,t]=J([]),[n,r]=J(`connecting`),[i,s]=J(`idle`),[c,l]=J(new Map),[u,d]=J(null),[f,p]=J(null),[m,h]=J(null),[g,_]=J(null),[v,y]=J(null),[,b]=J(!1),x=async()=>{y(null);try{let[e,t,n,r]=await Promise.all([a.summary(),a.setup().catch(()=>null),a.workflows().catch(()=>null),a.tasks().catch(()=>[])]),i=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&i.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);l(i),d(e),p(t),h(n),_(r)}catch(e){y(String(e.message||e))}};Y(()=>(x(),o(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),s(e===`live`?`ok`:`warn`)})),[]);let S=()=>{et(),b(e=>!e)},T=f?.operator?`${ft()}, ${f.operator}`:ft(),E=null;if(v)E=Z(`button`,{className:`btn btn-primary`,onClick:x,children:[Z(ct,{name:`refresh`,opts:{size:15}}),` Retry`]});else if(g!==null){let e=nt(g),t=e.attention.count,n=e.running.count;E=Z(H,{children:[t>0&&Z(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[Z(ct,{name:`tasks`,opts:{size:15}}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&Z(`a`,{className:`btn`,href:e.running.href,children:[Z(ct,{name:`workflows`,opts:{size:15}}),` `,n,` running`]}),Z(`a`,{className:`btn`,href:`#/logs`,children:[Z(ct,{name:`logs`,opts:{size:15}}),` Logs`]}),Z(`button`,{className:`btn btn-primary`,onClick:x,children:[Z(ct,{name:`refresh`,opts:{size:15}}),` Refresh`]})]})}let D=null;if(v)D=Z(`div`,{className:`card`,children:Z(lt,{title:`Cannot reach archied`,detail:v})});else if(u){let e=u?.statuses||{},t=(e.merged||0)+(e.pr_open||0),n=(e.parked||0)+(e.waiting_human||0),r=Object.values(e).reduce((e,t)=>e+t,0),i=u?.tokens_by_day||[];D=Z(H,{children:[Z(at,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),Z(at,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),Z(at,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),Z(at,{label:`Tokens used`,value:w(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:pt(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let O=null,k=$e(f),A=k.kind===`omit`||k.kind===`dismissed`;if(!A){let e=k.remaining;if(e.length){let t=Math.round((f.steps.length-e.length)/f.steps.length*100);O=Z(`div`,{className:`card setup`,children:[Z(`div`,{className:`card-head`,children:[Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:`Finish setting up`}),Z(`p`,{className:`card-sub`,children:`Archie needs these before it can work on its own.`})]}),Z(`span`,{className:`setup-pct`,children:[t,`%`]})]}),Z(`div`,{className:`setup-bar`,children:Z(`div`,{className:`setup-bar-fill`,style:{width:`${t}%`}})}),Z(`ul`,{className:`setup-list`,children:f.steps.map((e,t)=>Z(`li`,{className:`setup-step ${e.done?`done`:``}`,children:[Z(`span`,{className:`setup-check`,children:e.done?Z(ct,{name:`check`,opts:{size:12}}):``}),Z(`div`,{children:[Z(`div`,{className:`setup-step-title`,children:e.title}),e.detail&&Z(`div`,{className:`setup-step-detail`,children:e.detail})]})]},t))})]})}else O=Z(`div`,{className:`card setup setup-done`,children:Z(`div`,{className:`card-head`,children:[Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:`Setup complete`}),Z(`p`,{className:`card-sub`,children:`Archie is configured and ready to work.`})]}),Z(`div`,{className:`setup-complete-actions`,children:[Z(`span`,{className:`setup-pct`,children:Z(ct,{name:`check`,opts:{size:16}})}),Z(`button`,{className:`icon-btn setup-dismiss`,type:`button`,title:`Dismiss setup complete`,"aria-label":`Dismiss setup complete`,onClick:S,children:`×`})]})]})})}let j=null;if(u){let e=m?.workflows||[],t=e.reduce((e,t)=>e+(t.runs||0),0),n=e.reduce((e,t)=>e+(t.merged||0)+(t.pr_open||0),0),r=e.reduce((e,t)=>e+(t.parked||0),0);if(!t)j=Z(`div`,{className:`card`,children:[Z(`div`,{className:`card-head`,children:Z(`h2`,{className:`card-title`,children:`Gate pulse`})}),Z(lt,{title:`No completed runs yet`,detail:`Once Archie finishes a task, its gate pass rate appears here.`})]});else{let i=n/t*100;j=Z(`div`,{className:`card`,children:[Z(`div`,{className:`card-head`,children:Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:`Gate pulse`}),Z(`p`,{className:`card-sub`,children:`Work that passed its quality gates`})]})}),Z(ot,{value:i,label:`pass rate`}),Z(`ul`,{className:`pulse-list`,children:[e.slice(0,3).map((e,t)=>Z(`li`,{className:`pulse-item`,children:[Z(`span`,{className:`pulse-name`,children:e.workflow||`workflow`}),Z(ut,{text:`${e.merged||0}/${e.runs||0}`,kind:(e.merged||0)===(e.runs||0)?`ok`:(e.parked||0)>0?`warn`:`info`})]},t)),r>0&&Z(`li`,{className:`pulse-item`,children:[Z(`span`,{className:`pulse-name`,children:`Parked, awaiting you`}),Z(ut,{text:String(r),kind:`warn`})]})]})]})}}let M=null;if(u){let e=u?.tokens_by_day||[],t=e.reduce((e,t)=>e+(t.tokens||0),0);if(!e.length)M=Z(`div`,{className:`card`,children:[Z(`div`,{className:`card-head`,children:Z(`h2`,{className:`card-title`,children:`Token outlook`})}),Z(lt,{title:`Nothing spent yet`,detail:`Usage appears here once Archie runs its first task.`})]});else{let n=t/e.length,r=Math.round(n*30),i=e.slice(-7).reduce((e,t)=>e+(t.tokens||0),0);M=Z(`div`,{className:`card`,children:[Z(`div`,{className:`card-head`,children:Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:`Token outlook`}),Z(`p`,{className:`card-sub`,children:`Next 30 days at the current rate`})]})}),Z(`div`,{className:`forecast-value`,children:w(r)}),Z(`div`,{className:`forecast-note`,children:[`Based on `,w(Math.round(n)),` per day over `,e.length,` days`]}),Z(st,{segments:[{label:`Last 7 days (${w(i)})`,value:i,kind:`info`},{label:`Earlier (${w(t-i)})`,value:Math.max(t-i,0),kind:`idle`}]})]})}}return Z(H,{children:[Z(`div`,{className:`hero`,children:[Z(`div`,{children:[Z(`h1`,{className:`hero-title`,children:T}),Z(`p`,{className:`hero-sub`,children:`Your agent's control room — what it is working on, what needs you, and what it is spending.`})]}),Z(`div`,{className:`hero-actions`,children:Z(`div`,{className:`hero-actions-inner`,children:E})})]}),Z(`div`,{className:`dash-section`,children:[Z(`div`,{className:`dash-section-head`,children:Z(`h2`,{className:`dash-section-title`,children:`Health`})}),Z(`div`,{className:`dash-top ${A?`dash-top-standalone`:``}`,children:[Z(`div`,{children:O}),Z(`div`,{children:j})]})]}),Z(`div`,{className:`dash-section`,children:[Z(`div`,{className:`dash-section-head`,children:[Z(`h2`,{className:`dash-section-title`,children:`Throughput`}),Z(`span`,{className:`dash-section-note`,children:`Across all repositories`})]}),Z(`div`,{className:`grid grid-4`,children:D})]}),Z(`div`,{className:`dash-section`,children:[Z(`div`,{className:`dash-section-head`,children:Z(`h2`,{className:`dash-section-title`,children:`Right now`})}),Z(`div`,{className:`dash-split`,children:[Z(`div`,{children:M}),Z(`div`,{className:`card`,children:[Z(`div`,{className:`card-head`,children:[Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:`Live activity`}),Z(`p`,{className:`card-sub`,children:`Last 50, newest first`})]}),Z(ut,{text:n,kind:i})]}),Z(`div`,{className:`table-scroll`,children:Z(`table`,{className:`table`,children:[Z(`thead`,{children:Z(`tr`,{children:[Z(`th`,{children:`Event`}),Z(`th`,{children:`Task`}),Z(`th`,{children:`Detail`}),Z(`th`,{children:`When`})]})}),Z(`tbody`,{children:e.length?e.map((e,t)=>{let n=dt(e,c),r=n>0,i=()=>{r&&(location.hash=`#/tasks?task=${encodeURIComponent(n)}`)};return Z(`tr`,{className:r?`activity-row`:``,role:r?`link`:void 0,tabIndex:r?`0`:void 0,title:r?`Open task details`:void 0,onClick:r?i:void 0,onKeyDown:r?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())}:void 0,children:[Z(`td`,{className:`strong`,children:Z(`span`,{children:e.kind||e.type||`event`})}),Z(`td`,{className:`mono`,children:r?`#${n}`:`—`}),Z(`td`,{children:e.detail||e.message||``}),Z(`td`,{children:C(e.at||Date.now())})]},t)}):Z(`tr`,{children:Z(`td`,{colSpan:`4`,children:Z(lt,{title:`Waiting for activity`,detail:`Events appear here as Archie works.`})})})})]})})]})]})]})]})}function ht(){return Z(mt,{})}function gt(e,t){let n=e.title||`untitled task`;return{"aria-expanded":String(t),"aria-controls":`task-timeline-${e.id}`,"aria-label":`${t?`Collapse`:`Expand`} timeline for ${n}`}}var _t=_(),vt=new Set([`needs_you`,...g()]);function yt(e){let t=e?.get?.(`status`)||``;return vt.has(t)?t:``}function bt(e,t){return t?t===`needs_you`?_t.has(e.status):e.status===t:!0}function xt(e){return String(e||`event`).replaceAll(`_`,` `).replace(/\b\w/g,e=>e.toUpperCase())}function St(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return``;if(t<1e3)return`${Math.round(t)} ms`;let n=t/1e3;if(n<60)return`${n.toFixed(+(n<10))} s`;let r=Math.round(n),i=Math.floor(r/60),a=r%60;if(i<60)return a===0?`${i} min`:`${i} min ${a} s`;let o=Math.floor(i/60),s=i-o*60;return s===0?`${o} h`:`${o} h ${s} min`}function Ct(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:t.toLocaleString(`en-US`)}function wt(e={}){let t=e.data||{},n=e.stage||`unknown stage`,r=e.workflow?`${e.workflow} workflow`:``;if(e.kind===`stage_start`)return{title:`Started stage: ${n}`,detail:r};if(e.kind===`stage_finish`){let e=St(t.duration_ms),i=[r,e&&`ran for ${e}`].filter(Boolean).join(` · `);return{title:t.interrupted?`Stage interrupted: ${n}`:t.error?`Stage failed: ${n}`:`Finished stage: ${n}`,detail:[i,t.error].filter(Boolean).join(` — `)}}if(e.kind===`task_retried`){let n=Number(t.retry_count);return{title:Number.isFinite(n)&&n>0?`Retry ${n}`:`Retry requested`,detail:[t.previous_stage&&`after ${t.previous_stage}`,t.previous_reason].filter(Boolean).join(`: `)||e.detail||``}}if(e.kind===`agent_finish`){let r=Ct(t.iterations),i=Ct(t.tokens),a=Number(t.cached_tokens)||0,o=Ct((Number(t.prompt_tokens)||0)-a),s=Ct(t.completion_tokens),c=Ct(t.cached_tokens),l=[r&&`${r} iterations`,i&&`${i} tokens`,o&&`${o} fresh prompt`,s&&`${s} completion`,c&&`${c} cached`,t.model].filter(Boolean);return{title:`Agent ${t.status||`finished`}: ${n}`,detail:l.join(` · `)||e.detail||``}}return{title:xt(e.kind||e.type),detail:e.detail||``}}function Tt(e){switch((e||``).toUpperCase()){case`ERROR`:return`danger`;case`WARN`:return`warn`;case`DEBUG`:return`idle`;default:return`info`}}function Et(e){let t=e.fields||{};return y(`div.log-row.log-${Tt(e.level)}`,y(`span.log-time.mono`,Ot(e.time)),y(`span.log-level`,(e.level||`info`).toUpperCase()),y(`span.log-body`,y(`span.log-msg`,e.message||e.msg||``),...Object.entries(t).map(([e,t])=>y(`span.log-field`,y(`span.log-field-key`,e),String(Dt(t))))))}function Dt(e){return e==null?``:typeof e==`object`?JSON.stringify(e):e}function Ot(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`--:--:--`:t.toTimeString().slice(0,8)}function kt({entry:e}){let t=X(null);return Y(()=>{t.current&&t.current.replaceChildren(Et(e))},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function At({state:e,onRetry:t}){if(e===void 0)return Z(`div`,{className:`task-log-loading`,children:`Loading attempt log…`});if(e===null)return Z(`div`,{className:`task-log-error`,children:[Z(`div`,{className:`task-timeline-detail`,children:`Could not load this attempt's log.`}),Z(`button`,{className:`btn`,onClick:t,children:`Retry`})]});if(e.disabled)return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:`No persisted log for this attempt`}),Z(`div`,{children:`Task logging is optional and was not enabled for this run.`})]});let n=e.entries||[];return n.length?Z(`div`,{className:`log-list task-log-list`,children:n.map((e,t)=>Z(kt,{entry:e},t))}):Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:`Nothing recorded`}),Z(`div`,{children:`This attempt's log file has no entries matching the current filter.`})]})}function jt(e){let t=X(null);return Y(()=>{t.current&&t.current.replaceChildren(Je(e))},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function Mt({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}function Nt({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function Pt({query:e}){let[t,n]=J(null),[r,i]=J(null),[o,s]=J(()=>yt(e)),[c,l]=J(``),u=Number(e.get(`task`)),d=Number.isFinite(u)&&u>0?u:null,[f,p]=J(d),[_,y]=J(d!==null),[b,x]=J(new Map),[S,w]=J(new Map),[T,E]=J(new Set),[D,O]=J(new Map),[k,A]=J(new Set),j=async()=>{try{i(null);let e=await a.tasks();n(e),f&&e.some(e=>String(e.id)===String(f))&&(b.has(f)||M(f))}catch(e){i(String(e.message||e)),n(null)}};Y(()=>{j()},[]);let M=async e=>{try{let t=await a.task(e);x(n=>new Map(n).set(e,t||[]))}catch{x(t=>new Map(t).set(e,null))}},N=async e=>{w(t=>{let n=new Map(t);return n.delete(e),n});try{let t=await a.taskLogs(e,{limit:500});w(n=>new Map(n).set(e,t))}catch{w(t=>new Map(t).set(e,null))}},ee=async(e,t)=>{O(t=>{let n=new Map(t);return n.delete(e),n}),A(t=>new Set(t).add(e));try{await a.taskAction(e,t),A(t=>{let n=new Set(t);return n.delete(e),n}),t===`archive`&&p(null),await j()}catch(t){A(t=>{let n=new Set(t);return n.delete(e),n}),O(n=>new Map(n).set(e,t.message||`Action failed`))}};Y(()=>{_&&f&&t&&(y(!1),requestAnimationFrame(()=>{let e=document.getElementById(`task-row-${f}`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`center`,behavior:`smooth`}))}))},[_,f,t]);let P=(e,t)=>{t&&t.stopPropagation();let n=f!==e;p(n?e:null),n&&M(e)},te=e=>{E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),S.has(e)||N(e)),n})},F=()=>{if(!t)return null;let e=t.length,n={};for(let e of t)n[e.status]=(n[e.status]||0)+1;let r=n.running||0,i=(n.waiting_human||0)+(n.parked||0),a=(n.merged||0)+(n.pr_open||0);return Z(`div`,{className:`grid grid-4 task-summary`,children:[Z(jt,{label:`Total tasks`,value:e,compare:e?`Everything archied has ever picked up`:`No tasks yet`}),Z(jt,{label:`Working now`,value:r,compare:e?`${r} of ${e} in progress`:`Nothing running`}),Z(jt,{label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),Z(jt,{label:`Delivered`,value:a,compare:e?`${Math.round(a/e*100)}% of all tasks`:`No tasks yet`})]})},ne=e=>{let t=D.get(e.id),n=t?Z(`span`,{className:`task-action-error`,children:t}):null,r=k.has(e.id),i=e=>e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``,a=(e.actions||[]).map(t=>{let n=v(t);if(!n)return null;let a=e.title||`this task`,o=n.confirm?n.confirm.replaceAll(`{title}`,a):void 0,s=[`button`,`btn`,`btn-small`,i(n.kind)].filter(Boolean).join(` `);if(n.kind===`link`){if(t===`open_pr`)return I(e,`pull_request`,e.pr_number,n.label);if(t===`open_issue`)return I(e,`issue`,e.issue_number,n.label)}return Z(`button`,{className:s,type:`button`,disabled:r,onClick:n=>{n.stopPropagation(),!(o&&!window.confirm(o))&&ee(e.id,t)},children:n.label},t)}).filter(Boolean);return!a.length&&!n?`—`:Z(`div`,{className:`task-actions`,children:[n,a]})},I=(e,t,n,r)=>{let i=t===`issue`?e.issue_url:e.pr_url;return!i||!n||t===`issue`&&e.source===`chat`?Z(`button`,{className:`btn btn-small`,type:`button`,disabled:!0,title:`${r} is unavailable`,children:r}):Z(`a`,{className:`btn btn-small`,href:i,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:r})},L=e=>{let t=e.repo_url;return t?Z(`a`,{className:`task-source-link`,href:t,target:`_blank`,rel:`noreferrer`,title:`Open ${e.owner}/${e.repo} on the forge`,onClick:e=>e.stopPropagation(),children:[e.owner,`/`,e.repo]}):null},R=e=>{let t=e.issue_url;return e.source===`chat`||!t||!e.issue_number?null:Z(`a`,{className:`task-source-link`,href:t,target:`_blank`,rel:`noreferrer`,title:`Open issue #${e.issue_number} on the forge`,onClick:e=>e.stopPropagation(),children:[`#`,e.issue_number]})},z=e=>{let t=b.get(e.id),n=T.has(e.id);return Z(`tr`,{className:`task-timeline-row`,id:`task-timeline-${e.id}`,children:Z(`td`,{colSpan:8,children:[Z(`div`,{className:`task-detail-actions`,children:[Z(`div`,{className:`task-decision-title`,children:`Available actions`}),ne(e)]}),e.status===`waiting_human`&&e.plan&&Z(`div`,{className:`task-decision`,children:[Z(`div`,{className:`task-decision-title`,children:`Decision required`}),Z(`div`,{className:`task-decision-plan`,children:e.plan})]}),e.status===`parked`&&e.park_reason&&Z(`div`,{className:`task-decision`,children:[Z(`div`,{className:`task-decision-title`,children:`Park reason`}),Z(`div`,{className:`task-decision-plan`,children:e.park_reason})]}),t===void 0?Z(`div`,{className:`task-timeline-loading`,children:`Loading timeline…`}):t===null?Z(`div`,{className:`task-timeline-error`,children:[Z(`div`,{className:`task-timeline-title`,children:`Could not load timeline`}),Z(`div`,{className:`task-timeline-detail`,children:`archied did not answer for this task's events. It may be restarting — retry, or check the daemon.`}),Z(`button`,{className:`btn`,onClick:()=>M(e.id),children:`Retry`})]}):t.length?Z(`ul`,{className:`task-timeline`,children:t.map((e,t)=>{let n=wt(e);return Z(`li`,{className:`task-timeline-entry`,children:[Z(`span`,{className:`task-timeline-dot`}),Z(`div`,{children:[Z(`div`,{className:`task-timeline-kind`,children:n.title}),n.detail&&Z(`div`,{className:`task-timeline-detail`,children:n.detail}),Z(`div`,{className:`task-timeline-when`,children:C(e.at)})]})]},t)})}):Z(Nt,{title:`No events yet`,detail:`This task has not recorded any transitions.`}),Z(`div`,{className:`task-logs-section`,children:[Z(`div`,{className:`task-decision-title`,children:[`Attempt log`,Z(`button`,{className:`btn btn-small`,onClick:()=>te(e.id),style:{marginLeft:`10px`},children:n?`Hide`:`Show`})]}),n&&Z(At,{state:S.get(e.id),onRetry:()=>N(e.id)})]})]})})};return Z(`div`,{children:[Z(`div`,{className:`page-head`,children:[Z(`div`,{children:[Z(`h1`,{className:`page-title`,children:`Tasks`}),Z(`p`,{className:`page-sub`,children:`Every issue archied has picked up, and where it stands.`})]}),Z(`div`,{className:`page-actions`,children:Z(`button`,{className:`btn`,onClick:j,children:`Refresh`})})]}),r?Z(`div`,{className:`grid grid-4 task-summary`,children:Z(`div`,{className:`card`,children:Z(Nt,{title:`Cannot reach archied`,detail:r})})}):F(),Z(`div`,{className:`card`,children:[Z(`div`,{className:`card-head`,children:[Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:`All tasks`}),Z(`p`,{className:`card-sub`,children:`Click a row for its timeline`})]}),Z(`div`,{className:`task-filters`,children:[Z(`input`,{className:`task-search`,type:`search`,placeholder:`Search by title or repo…`,value:c,onInput:e=>l(e.target.value.trim().toLowerCase())}),Z(`select`,{className:`task-filter`,value:o,onChange:e=>s(e.target.value),children:[Z(`option`,{value:``,children:`All statuses`}),Z(`option`,{value:`needs_you`,children:`Needs you`}),g().map(e=>Z(`option`,{value:e,children:m(e)},e))]})]})]}),Z(`div`,{className:`table-scroll`,children:Z(`table`,{className:`table`,children:[Z(`thead`,{children:Z(`tr`,{children:[`Repo`,`Issue`,`Title`,`Status`,`Workflow`,`Stage`,`Last activity`,`Action`].map(e=>Z(`th`,{children:e},e))})}),Z(`tbody`,{children:(()=>{if(r)return Z(`tr`,{children:Z(`td`,{colSpan:8,children:Z(Nt,{title:`Cannot reach archied`,detail:r})})});if(!t)return Z(`tr`,{children:Z(`td`,{colSpan:8,children:Z(`div`,{className:`task-timeline-loading`,children:`Loading tasks...`})})});if(!t.length)return Z(`tr`,{children:Z(`td`,{colSpan:8,children:Z(Nt,{title:`No tasks yet`,detail:`Tasks appear here once archied picks up an issue to work.`})})});let e=t.filter(e=>bt(e,o)?!c||`${e.title} ${e.repo}`.toLowerCase().includes(c):!1);return e.length?e.map(e=>{let t=f===e.id,n=`task-timeline-${e.id}`;return Z(oe.Fragment,{children:[Z(`tr`,{className:`task-row`,id:`task-row-${e.id}`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),P(e.id,t))},onClick:t=>P(e.id,t),...gt(e,t),children:[Z(`td`,{className:`mono`,"data-label":`Repository`,children:[Z(`button`,{className:`task-expand`,type:`button`,"aria-expanded":String(t),"aria-controls":n,"aria-label":`${t?`Collapse`:`Expand`} timeline for ${e.title||`untitled task`}`,onClick:t=>P(e.id,t),children:t?`−`:`+`}),L(e)??`${e.owner}/${e.repo}`]}),Z(`td`,{className:`mono`,"data-label":`Issue`,children:R(e)??`#${e.issue_number}`}),Z(`td`,{className:`strong`,"data-label":`Title`,children:e.title||`(untitled)`}),Z(`td`,{"data-label":`Status`,children:Z(Mt,{text:m(e.status),kind:h(e.status)})}),Z(`td`,{"data-label":`Workflow`,children:e.workflow||`—`}),Z(`td`,{"data-label":`Stage`,children:e.stage||`—`}),Z(`td`,{"data-label":`Last activity`,title:e.created_at?`Created ${C(e.created_at)}`:``,children:C(e.updated_at)}),Z(`td`,{"data-label":`Actions`,children:ne(e)})]}),t&&z(e)]},e.id)}):Z(`tr`,{children:Z(`td`,{colSpan:8,children:Z(Nt,{title:`No matching tasks`,detail:`Try a different search or status filter.`})})})})()})]})})]})]})}function Ft(e){return Z(Pt,{query:e})}function It({title:e,detail:t}){return Z(`div`,{class:`empty`,children:[Z(`div`,{class:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function Lt({text:e,kind:t=`idle`}){return Z(`span`,{class:`pill pill-${t}`,children:e})}function Rt(e){return Z(zt,{query:e})}function zt(){let[e,t]=J([]),[n,r]=J(``),[i,o]=J(null),s=async()=>{try{let e=await a.skills();t(e?.skills||[]),o(null)}catch(e){t([]),o(String(e.message||e))}};Y(()=>{s()},[]);let c=(e,t)=>!t||`${e.name} ${e.description}`.toLowerCase().includes(t),l=Be(()=>e.filter(e=>c(e,n)),[e,n]);return Z(`div`,{children:[Z(`div`,{class:`page-head`,children:[Z(`div`,{children:[Z(`h1`,{class:`page-title`,children:`Skills`}),Z(`p`,{class:`page-sub`,children:`What Archie can do, in plain language.`})]}),Z(`div`,{class:`page-actions`,children:Z(`button`,{class:`btn`,onClick:s,children:`Refresh`})})]}),Z(`div`,{class:`card`,children:[Z(`div`,{class:`card-head`,children:[Z(`div`,{children:[Z(`h2`,{class:`card-title`,children:`Catalogue`}),Z(`p`,{class:`card-sub`,children:`Project, shared, and user-global skills`})]}),Z(`input`,{class:`skill-search`,type:`search`,placeholder:`Search skills…`,onInput:e=>r(e.target.value.trim().toLowerCase())})]}),Z(`div`,{class:`grid grid-2`,children:i?Z(It,{title:`Cannot reach archied`,detail:i}):e.length?l.length?l.map(e=>Z(`div`,{class:`card skill-card`,children:[Z(`div`,{class:`card-head`,children:[Z(`h3`,{class:`card-title`,children:e.name||`Untitled skill`}),e.workflow&&Z(Lt,{text:e.workflow,kind:`info`})]}),Z(`p`,{class:`skill-desc`,children:e.description||`No description provided.`}),Z(`div`,{class:`skill-source`,children:e.source||`Unknown source`})]},e.name)):Z(It,{title:`No skills match`,detail:`Nothing found for "${n}".`}):Z(It,{title:`No skills discovered yet`,detail:`Skills live as SKILL.md files under project, shared, or user-global .agents/skills// directories. Add one and refresh to make it available.`})})]})]})}var Bt={bootstrap:`Bootstrap`,implement:`Implement`,tdd:`TDD`,feasibility:`Feasibility check`};function Vt(e){return Bt[e]?Bt[e]:e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown`}function Ht(e,t){return t?Math.round(e/t*100):0}function Ut(e){if(!e)return`—`;if(e<1e3)return`${e} ms`;let t=e/1e3;return t<60?`${t.toFixed(1)} s`:`${(t/60).toFixed(1)} min`}function Wt({title:e,detail:t}){return Z(`div`,{class:`empty`,children:[Z(`div`,{class:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function Gt({fraction:e,kind:t=`ok`}){let n=Math.min(100,Math.max(0,e));return Z(`div`,{class:`wf-bar`,children:Z(`div`,{class:`wf-bar-fill wf-bar-${t}`,style:{width:`${n}%`}})})}function Kt(e){return Z(qt,{query:e})}function qt(){let[e,t]=J([]),[n,r]=J([]),[i,o]=J([]),[s,c]=J(null),l=async()=>{try{let e=await a.workflows();t(e?.definitions||[]),r(e?.workflows||[]),o(e?.stages||[]),c(null)}catch(e){c(String(e.message||e))}};return Y(()=>{l()},[]),Z(`div`,{children:[Z(`div`,{class:`page-head`,children:[Z(`div`,{children:[Z(`h1`,{class:`page-title`,children:`Workflows`}),Z(`p`,{class:`page-sub`,children:`Run outcomes and spend per workflow, and where stages get stuck.`})]}),Z(`div`,{class:`page-actions`,children:Z(`button`,{class:`btn`,onClick:l,children:`Refresh`})})]}),Z(Jt,{definitions:e}),s?Z(`div`,{class:`card`,children:Z(Wt,{title:`Cannot reach archied`,detail:s})}):Z(H,{children:[Z(Yt,{workflows:n,definitions:e}),Z(Xt,{stages:i})]})]})}function Jt({definitions:e}){if(!e.length)return null;let t=e.filter(e=>e.enabled)[0]?.id||``,[n,r]=J(``),[i,o]=J(``),[s,c]=J(t),[l,u]=J(``),[d,f]=J(``),[p,m]=J(!1),[h,g]=J(``);return Y(()=>{!s&&t&&c(t)},[t,s]),Z(`div`,{class:`card`,children:[Z(`div`,{class:`card-head`,children:Z(`div`,{children:[Z(`h2`,{class:`card-title`,children:`Start work`}),Z(`p`,{class:`card-sub`,children:`This enters Archie’s normal admitted task queue.`})]})}),Z(`form`,{class:`wf-form`,onSubmit:async e=>{e.preventDefault(),m(!0),g(``);try{let e=await a.workRequest({identity:n,repository:i,workflow:s,title:l,instructions:d});g(`Queued task #${e.task_id}.`),r(``),o(``),c(t),u(``),f(``)}catch(e){g(String(e.message||e))}finally{m(!1)}},children:[Z(`input`,{placeholder:`Identity`,required:!0,value:n,onInput:e=>r(e.target.value)}),Z(`input`,{placeholder:`owner/repository`,required:!0,value:i,onInput:e=>o(e.target.value)}),Z(`select`,{required:!0,value:s,onInput:e=>c(e.target.value),children:e.filter(e=>e.enabled).map(e=>Z(`option`,{value:e.id,children:Vt(e.name||e.id)},e.id))}),Z(`input`,{placeholder:`Short task title`,required:!0,value:l,onInput:e=>u(e.target.value)}),Z(`textarea`,{placeholder:`Instructions for the work`,required:!0,rows:3,value:d,onInput:e=>f(e.target.value)}),Z(`button`,{class:`btn`,type:`submit`,disabled:p,children:`Start work`}),h&&Z(`p`,{class:`card-sub`,children:h})]})]})}function Yt({workflows:e,definitions:t}){let n=new Map(e.map(e=>[e.workflow,e])),r=t.map(e=>({...e,...n.get(e.id)||{workflow:e.id,runs:0,merged:0}}));return r.length?Z(`div`,{class:`card`,children:[Z(`div`,{class:`card-head`,children:Z(`div`,{children:[Z(`h2`,{class:`card-title`,children:`Per workflow`}),Z(`p`,{class:`card-sub`,children:`Success rate is merged tasks over all runs`})]})}),Z(`div`,{class:`table-scroll`,children:Z(`table`,{class:`table`,children:[Z(`thead`,{children:Z(`tr`,{children:[Z(`th`,{children:`Workflow`}),Z(`th`,{children:`Origin`}),Z(`th`,{children:`Runs`}),Z(`th`,{children:`Success rate`}),Z(`th`,{children:`Avg tokens`}),Z(`th`,{children:`Avg steps`})]})}),Z(`tbody`,{children:r.map(e=>{let t=Ht(e.merged,e.runs);return Z(`tr`,{children:[Z(`td`,{class:`strong`,children:Vt(e.workflow)}),Z(`td`,{class:`mono`,children:e.origin||`registry`}),Z(`td`,{children:`${e.runs} run${e.runs===1?``:`s`}`}),Z(`td`,{children:[Z(`div`,{class:`wf-rate`,children:[t,`%`,Z(`span`,{class:`wf-rate-sub`,children:[e.merged,` of `,e.runs,` merged`]})]}),Z(Gt,{fraction:t,kind:t>=50?`ok`:`warn`})]}),Z(`td`,{class:`mono`,children:e.avg_tokens?e.avg_tokens.toLocaleString():`—`}),Z(`td`,{class:`mono`,children:e.avg_steps?e.avg_steps.toFixed(1):`—`})]},e.workflow)})})]})})]}):Z(`div`,{class:`card`,children:[Z(`div`,{class:`card-head`,children:Z(`div`,{children:Z(`h2`,{class:`card-title`,children:`Per workflow`})})}),Z(Wt,{title:`No workflow runs yet`,detail:`Stats appear here once a task has run through a workflow.`})]})}function Xt({stages:e}){if(!e.length)return Z(`div`,{class:`card wf-stage-card`,children:[Z(`div`,{class:`card-head`,children:Z(`div`,{children:Z(`h2`,{class:`card-title`,children:`Per stage`})})}),Z(Wt,{title:`No stage data yet`,detail:`Stage timing and failures appear here once workflows have run.`})]});let t=Math.max(...e.map(e=>e.avg_ms||0),1),n=[...e].sort((e,t)=>(t.avg_ms||0)-(e.avg_ms||0)),r=[...e].filter(e=>e.errors>0).sort((e,t)=>t.errors-e.errors);return Z(`div`,{class:`grid grid-2 wf-stage-card`,children:[Z(`div`,{class:`card`,children:[Z(`div`,{class:`card-head`,children:Z(`div`,{children:[Z(`h2`,{class:`card-title`,children:`Slowest stages`}),Z(`p`,{class:`card-sub`,children:`Average duration, this workflow's stages`})]})}),Z(`div`,{class:`table-scroll`,children:Z(`table`,{class:`table`,children:[Z(`thead`,{children:Z(`tr`,{children:[Z(`th`,{children:`Workflow`}),Z(`th`,{children:`Stage`}),Z(`th`,{children:`Runs`}),Z(`th`,{children:`Avg duration`})]})}),Z(`tbody`,{children:n.map((e,n)=>Z(`tr`,{children:[Z(`td`,{children:Vt(e.workflow)}),Z(`td`,{class:`strong`,children:e.stage}),Z(`td`,{children:e.runs}),Z(`td`,{children:[Z(`div`,{class:`wf-rate`,children:Ut(e.avg_ms)}),Z(Gt,{fraction:Ht(e.avg_ms,t),kind:`info`})]})]},n))})]})})]}),Z(`div`,{class:`card`,children:[Z(`div`,{class:`card-head`,children:Z(`div`,{children:[Z(`h2`,{class:`card-title`,children:`Most failures`}),Z(`p`,{class:`card-sub`,children:`Stages that error out, over their runs`})]})}),r.length?Z(`div`,{class:`table-scroll`,children:Z(`table`,{class:`table`,children:[Z(`thead`,{children:Z(`tr`,{children:[Z(`th`,{children:`Workflow`}),Z(`th`,{children:`Stage`}),Z(`th`,{children:`Failures`})]})}),Z(`tbody`,{children:r.map((e,t)=>Z(`tr`,{children:[Z(`td`,{children:Vt(e.workflow)}),Z(`td`,{class:`strong`,children:e.stage}),Z(`td`,{children:[Z(`div`,{class:`wf-rate`,children:[e.errors,` of `,e.runs]}),Z(Gt,{fraction:Ht(e.errors,e.runs),kind:`danger`})]})]},t))})]})}):Z(Wt,{title:`No failures recorded`,detail:`Every stage has completed cleanly so far.`})]})]})}function Zt({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}function Qt({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function $t(e,t){return e===`running`?`ok`:e===`failed`||e===`degraded`?`warn`:`idle`}function en(){let[e,t]=J([]),[n,r]=J(null),i=async()=>{try{let e=await a.channels();t(e?.channels||[]),r(null)}catch(e){r(String(e.message||e))}};return Y(()=>{i()},[]),Z(`div`,{children:[Z(`div`,{className:`page-head`,children:[Z(`div`,{children:[Z(`h1`,{className:`page-title`,children:`Channels`}),Z(`p`,{className:`page-sub`,children:`The conversational front-ends Archie can be reached through.`})]}),Z(`div`,{className:`page-actions`,children:Z(`button`,{className:`btn`,onClick:i,children:`Refresh`})})]}),Z(`div`,{className:`grid grid-2`,children:n?Z(Qt,{title:`Cannot reach archied`,detail:n}):e.length===0?Z(Qt,{title:`No channels configured`,detail:`Configure [chat.telegram] or [chat.webhook_addr] in config.toml to talk to Archie outside the dashboard.`}):e.map(e=>Z(`div`,{className:`card channel-card`,children:[Z(`div`,{className:`card-head`,children:[Z(`h3`,{className:`card-title`,children:e.name}),Z(Zt,{text:e.state||(e.configured?`configured`:`stopped`),kind:$t(e.state,e.configured)})]}),Z(`p`,{className:`channel-desc`,children:e.description}),Z(`p`,{className:`channel-detail`,children:e.detail}),e.reload_supported?Z(`button`,{className:`btn`,onClick:async t=>{t.currentTarget.disabled=!0;try{await a.channelReload(e.id||e.name.toLowerCase()),await i()}catch{}finally{t.currentTarget&&(t.currentTarget.disabled=!1)}},children:`Reload`}):Z(`p`,{className:`channel-detail`,children:`Reload requires a daemon restart for this adapter.`})]},e.id||e.name))})]})}function tn(e){return Z(en,{query:e})}function nn(){let e=y(`div`),t=y(`div.grid.grid-2`);n(),r();function n(){x(e,y(`div.page-head`,y(`div`,y(`h1.page-title`,`Curators`),y(`p.page-sub`,`Background agents that maintain memory and skills: what ran, and why.`)),y(`div.page-actions`,y(`button.btn`,{onclick:r},`Refresh`))),t)}async function r(){try{i((await a.curators())?.curators||[])}catch(e){x(t,T(`Cannot reach archied`,String(e.message||e)))}}function i(e){if(!e.length){x(t,T(`No curators registered`,`Curators are background agent loops that maintain memory and skills. None are registered on this daemon.`));return}x(t,...e.map(s))}function o(e){switch(e){case`healthy`:return`ok`;case`degraded`:return`warn`;case`unhealthy`:return`danger`;default:return`idle`}}function s(e){let t=e.recent_actions||[];return y(`div.card.curator-card`,y(`div.card-head`,y(`h3.card-title`,e.name),S(e.health?.status||`unknown`,o(e.health?.status))),e.health?.message&&y(`p.curator-health-message`,e.health.message),y(`p.curator-meta`,e.last_run_at?`Last ran ${C(e.last_run_at)} · ${e.last_run_actions} action${e.last_run_actions===1?``:`s`}`:`Has not run yet`),t.length?y(`ul.curator-actions`,...t.map(e=>y(`li.curator-action`,y(`div.curator-action-head`,y(`span.curator-action-type`,e.type||`action`),y(`span.curator-action-time`,C(e.at))),e.detail&&y(`p.curator-action-detail`,e.detail),e.reason&&y(`p.curator-action-reason`,`Why: ${e.reason}`)))):y(`p.curator-meta`,`No recorded activity yet.`))}return e}function rn(e){return e==null||e===``?`—`:String(e)}function an({label:e,value:t,opts:n}){let r=rn(t),[i,o]=J(!1),[s,c]=J(``),[l,u]=J(null),[d,f]=J(!1),[p,m]=J(!1),h=n?.key;if(!h)return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,title:n?.hint,children:e}),Z(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let g=n.locked?.[h];if(g)return Z(`div`,{className:`kv is-locked`,children:[Z(`span`,{className:`kv-label`,title:n.hint,children:e}),Z(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),Z(`span`,{className:`kv-note`,children:g})]});if(n.editable===!1)return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,title:n.hint,children:e}),Z(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let _=n.overridden?.includes(h),v=()=>{c(String(n.raw??``)),u(null),o(!0)},y=async()=>{m(!0),u(null);try{await a.configReset(h),n.onSaved?.()}catch(e){u(String(e.message||e))}finally{m(!1)}},b=async()=>{let e=on(n.type,s);if(e.error){u(e.error);return}f(!0),u(null);try{await(n.save||(e=>a.configUpdate({[h]:e})))(e.value),o(!1),n.onSaved?.()}catch(e){u(String(e.message||e))}finally{f(!1)}};if(i){let t=X(null);Y(()=>{t.current&&t.current.focus()},[]);let r=e=>{e.key===`Enter`&&(e.preventDefault(),b()),e.key===`Escape`&&o(!1)},i;return i=n.type===`bool`?Z(`select`,{className:`kv-input`,value:s,onChange:e=>c(e.target.value),onKeyDown:r,ref:t,children:[Z(`option`,{value:`true`,children:`true`}),Z(`option`,{value:`false`,children:`false`})]}):n.type===`enum`?Z(`select`,{className:`kv-input`,value:s,onChange:e=>c(e.target.value),onKeyDown:r,ref:t,children:(n.options||[]).map(e=>Z(`option`,{value:e,children:e},e))}):Z(`input`,{className:`kv-input`,type:`text`,value:s,onInput:e=>c(e.target.value),onKeyDown:r,ref:t}),Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,title:n.hint,children:e}),i,Z(`div`,{className:`kv-actions`,children:[Z(`button`,{className:`kv-save`,type:`button`,onClick:b,disabled:d,children:`Save`}),Z(`button`,{className:`kv-cancel`,type:`button`,onClick:()=>o(!1),disabled:d,children:`Cancel`})]}),l&&Z(`span`,{className:`kv-note is-error`,children:l})]})}return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,title:n.hint,children:e}),Z(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),Z(`div`,{className:`kv-actions`,children:[_&&Z(`span`,{className:`kv-flag`,title:`Set from the dashboard; this shadows the value in the config file`,children:`overridden`}),Z(`button`,{className:`kv-btn`,type:`button`,title:`Edit ${e}`,onClick:v,children:`Edit`}),_&&Z(`button`,{className:`kv-btn`,type:`button`,title:`Discard the dashboard value and fall back to the config file`,onClick:y,disabled:p,children:`Reset`})]}),l&&Z(`span`,{className:`kv-note is-error`,children:l})]})}function on(e,t){switch(e){case`int`:{let e=parseInt(t,10);return Number.isNaN(e)?{error:`Enter a whole number`}:{value:e}}case`bool`:return{value:t===`true`};default:return{value:t}}}function sn({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}function cn({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function ln({sub:e,title:t,children:n}){return Z(`div`,{className:`card cfg-section`,children:[Z(`div`,{className:`card-head`,children:Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:t||`Update status`}),Z(`p`,{className:`card-sub`,children:e})]})}),n]})}var un={ok:`OK`,update_available:`Update available`,drift:`Drift`,unknown:`Unknown`},dn={ok:`ok`,update_available:`info`,drift:`danger`,unknown:`idle`};function fn({components:e}){return!e||!e.length?Z(ln,{sub:`How each component is deployed, and whether what's running matches what's installed.`,children:Z(cn,{title:`No components reported`,detail:`The configured update-check command returned nothing.`})}):Z(ln,{sub:`How each component is deployed, and whether what's running matches what's installed. Hover a row for the exact versions compared.`,children:Z(`div`,{className:`table-scroll`,children:Z(`table`,{className:`table`,children:[Z(`thead`,{children:Z(`tr`,{children:[Z(`th`,{children:`Component`}),Z(`th`,{children:`Install type`}),Z(`th`,{children:`Running`}),Z(`th`,{children:`Latest available`}),Z(`th`,{children:`Status`})]})}),Z(`tbody`,{children:e.map(e=>Z(`tr`,{title:[`Installed claim: ${e.installed_claim||`unknown`}`,`Running: ${e.running_version||`not observed`}`,e.reference?`Reference: ${e.reference}`:null].filter(Boolean).join(` -`),children:[Z(`td`,{className:`strong`,children:e.label||e.id}),Z(`td`,{className:`mono`,children:e.install_type||`—`}),Z(`td`,{className:`mono`,children:e.running_version||`—`}),Z(`td`,{className:`mono`,children:e.latest_available||`—`}),Z(`td`,{children:Z(sn,{text:un[e.status]||e.status,kind:dn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function pn({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}function Q({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function $({title:e,sub:t,children:n}){return Z(`div`,{className:`card cfg-section`,children:[Z(`div`,{className:`card-head`,children:Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:e}),Z(`p`,{className:`card-sub`,children:t})]})}),n]})}function mn({origins:e}){return e?.length?Z($,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:Z(`div`,{className:`kv-list`,children:e.map((e,t)=>Z(an,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):Z($,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:Z(Q,{title:`Source provenance is unavailable.`})})}function hn(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function gn({data:e,error:t}){if(t)return Z($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:Z(Q,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return Z($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[Z(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?Z(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??m(e.id),n=e.kind??h(e.id);return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,children:e.id}),Z(`span`,{className:`kv-value`,children:Z(pn,{text:t,kind:n})})]},e.id)})}):Z(Q,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),Z(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?Z(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=hn(e.kind);return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,children:e.id}),Z(`span`,{className:`kv-value`,children:Z(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):Z(Q,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function _n({r:e,field:t,onSaved:n}){let[r,i]=J(!1),[o,s]=J(null),[c,l]=J(!!e[t]);return Z(`td`,{children:[Z(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let o=r.target.checked;l(o),i(!0),s(null);try{await a.configRepoUpdate(e.owner,e.name,t,o),n?.()}catch(e){l(!o),s(String(e.message||e))}finally{i(!1)}},disabled:r}),o&&Z(`span`,{className:`kv-note is-error`,children:o})]})}function vn({r:e,field:t,onSaved:n}){let[r,i]=J(String(e[t]??0)),[o,s]=J(null),[c,l]=J(!1);return Z(`td`,{children:[Z(`input`,{className:`kv-input`,type:`text`,value:r,onChange:e=>i(e.target.value),onBlur:async()=>{let i=parseInt(r,10);if(Number.isNaN(i)){s(`Enter a whole number`);return}l(!0),s(null);try{await a.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){s(String(e.message||e))}finally{l(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:c}),o&&Z(`span`,{className:`kv-note is-error`,children:o})]})}function yn({repos:e,onSaved:t}){if(!e?.length)return Z($,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:Z(Q,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let n=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return Z($,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:Z(`div`,{className:`table-scroll`,children:Z(`table`,{className:`table`,children:[Z(`thead`,{children:Z(`tr`,{children:[Z(`th`,{children:`Repository`}),Z(`th`,{children:`Base branch`}),Z(`th`,{children:`Ecosystem`}),Z(`th`,{children:`Quality gate`}),Z(`th`,{children:`Protected paths`}),Z(`th`,{children:`Concurrent`}),Z(`th`,{children:`Max retries`}),Z(`th`,{children:`Self-review`})]})}),Z(`tbody`,{children:e.map((e,r)=>Z(`tr`,{children:[Z(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),Z(`td`,{className:`mono`,children:e.base}),Z(`td`,{children:e.ecosystem||`go`}),Z(`td`,{className:`mono`,children:n(e.gate)}),Z(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),Z(_n,{r:e,field:`allow_concurrent`,onSaved:t}),Z(vn,{r:e,field:`max_retries`,onSaved:t}),Z(_n,{r:e,field:`review_enabled`,onSaved:t})]},r))})]})})})}function bn(e){return e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown role`}function xn({models:e,providers:t}){let n=Object.entries(e||{}),r=Object.entries(t||{});return Z($,{title:`Models & providers`,sub:`Which model handles each stage of work, and which LLM providers are wired up. Only the environment variable NAME is shown, never its value.`,children:[Z(`h3`,{className:`cfg-subhead`,children:`Model roles`}),n.length?Z(`div`,{className:`kv-list`,children:n.map(([e,t])=>Z(an,{label:bn(e),value:t},e))}):Z(Q,{title:`No model roles configured`,detail:`Assign a model to at least one role (e.g. "builder") in [models].`}),Z(`h3`,{className:`cfg-subhead`,children:`Providers`}),r.length?Z(`div`,{className:`table-scroll`,children:Z(`table`,{className:`table`,children:[Z(`thead`,{children:Z(`tr`,{children:[Z(`th`,{children:`Provider`}),Z(`th`,{children:`Class`}),Z(`th`,{children:`Base URL`}),Z(`th`,{children:`API key env var`}),Z(`th`,{children:`Status`})]})}),Z(`tbody`,{children:r.map(([e,t])=>Z(`tr`,{children:[Z(`td`,{className:`strong`,children:e}),Z(`td`,{children:t.class}),Z(`td`,{className:`mono`,children:t.base_url||`default`}),Z(`td`,{className:`mono`,children:t.api_key_env||`—`}),Z(`td`,{children:t.configured?Z(pn,{text:`configured`,kind:`ok`}):Z(pn,{text:`missing credentials`,kind:`warn`})})]},e))})]})}):Z(Q,{title:`No providers configured`,detail:`Add a [providers.] entry so a model role above has something to run on.`})]})}function Sn(){let[e,t]=J(null),[n,r]=J(null),[i,o]=J(null),[s,c]=J(null),[l,u]=J(!1),[d,f]=J(null),[p,m]=J(null),h=()=>{g(),_(),v()},g=async()=>{try{let e=await a.config();t(e),r(null)}catch(e){r(String(e.message||e))}},_=async()=>{try{let e=await a.version();o(e?.components||[]),c(null),u(!1)}catch(e){e?.status===501?u(!0):c(String(e.message||e))}},v=async()=>{try{let e=await a.taskMeta();f(e),m(null)}catch(e){m(String(e.message||e))}};return Y(()=>{h()},[]),Z(`div`,{className:`cfg-page`,children:[Z(`div`,{className:`page-head`,children:[Z(`div`,{children:[Z(`h1`,{className:`page-title`,children:`Configuration`}),Z(`p`,{className:`page-sub`,children:`What archied is actually running with right now.`})]}),Z(`div`,{className:`page-actions`,children:Z(`button`,{className:`btn`,onClick:h,children:`Refresh`})})]}),Z(`div`,{children:!l&&(s?Z(`div`,{className:`card`,children:Z(Q,{title:`Update status unavailable`,detail:s})}):i?Z(fn,{components:i}):null)}),Z(`div`,{children:Z(gn,{data:d,error:p})}),Z(`div`,{children:n?Z(`div`,{className:`card`,children:Z(Q,{title:`Cannot reach archied`,detail:n})}):!e||Object.keys(e).length===0?Z(`div`,{className:`card`,children:Z(Q,{title:`No configuration loaded`,detail:`archied is running without a config file wired into the dashboard, so there is nothing to show.`})}):Z(H,{children:[e.reload?.overlay_unavailable&&Z(`div`,{className:`card cfg-notice`,children:Z(`p`,{children:[`The runtime config overlay is not in effect: `,e.reload.overlay_unavailable]})}),e.reload?.last_error&&Z(`div`,{className:`card cfg-notice`,children:Z(`p`,{children:[`The last config reload failed; the running config is unchanged: `,e.reload.last_error]})}),(e.schema||[]).map((t,n)=>{let r=t.fields.filter(e=>e.type!==`structured`);return r.length?Z($,{title:t.label,sub:t.description,children:Z(`div`,{className:`kv-list`,children:r.map(t=>Z(an,{label:t.label,value:t.value,opts:{key:t.key,type:t.type,options:t.options,raw:t.value,hint:t.description,editable:t.editable,locked:e.locked||{},overridden:e.overridden||[],onSaved:g}},t.key))})},n):null}),Z(yn,{repos:e.repositories,onSaved:g}),Z(xn,{models:e.models,providers:e.providers}),Z(mn,{origins:e.provenance})]})})]})}function Cn(e){return Z(Sn,{query:e})}function wn({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}function Tn({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function En(e){switch((e||``).toUpperCase()){case`ERROR`:return`danger`;case`WARN`:return`warn`;case`DEBUG`:return`idle`;default:return`info`}}function Dn(e){return e==null?``:typeof e==`object`?JSON.stringify(e):e}function On(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`--:--:--`:t.toTimeString().slice(0,8)}function kn({entry:e}){let t=e.fields||{};return Z(`div`,{className:`log-row log-${En(e.level)}`,children:[Z(`span`,{className:`log-time mono`,children:On(e.time)}),Z(`span`,{className:`log-level`,children:(e.level||`info`).toUpperCase()}),Z(`span`,{className:`log-body`,children:[Z(`span`,{className:`log-msg`,children:e.message||e.msg||``}),Object.entries(t).map(([e,t])=>Z(`span`,{className:`log-field`,children:[Z(`span`,{className:`log-field-key`,children:e}),String(Dn(t))]},e))]})]})}var An=[{value:``,label:`All levels`},{value:`ERROR`,label:`Errors`},{value:`WARN,ERROR`,label:`Warnings and errors`},{value:`INFO,WARN,ERROR`,label:`Info and above`},{value:`DEBUG`,label:`Debug only`}];function jn(e){return`${e.time||``}|${e.level||``}|${e.message||e.msg||``}|${JSON.stringify(e.fields||{})}`}function Mn(){let[e,t]=J({level:``,component:``,q:``}),[n,r]=J(!1),[i,o]=J([]),[c,l]=J([]),u=X(new Map),[d,f]=J(0),[p,m]=J(!1),[h,g]=J(`connecting`),[_,v]=J(`Refreshing…`),y=X(null),b=X(null),x=async()=>{v(`Refreshing…`);try{let t=await a.logs({level:e.level,component:e.component,q:e.q,limit:500});o(e=>{let n=t.components||[];return e.length===n.length&&e.every((e,t)=>e===n[t])?e:n}),m(!!t.disabled);let n=t.disabled?`Durable history unavailable; live daemon logs continue.`:t.truncated?`showing the most recent matches from ${t.file}`:t.file||``;v(n),l(t.entries||[])}catch{v(`Cannot read logs`)}};Y(()=>{x()},[e]),Y(()=>{let e=s(e=>{if(S.current)return;let t=e;w.current(t)&&(u.current.set(jn(t),t),t.fields?.component&&o(e=>e.includes(t.fields.component)?e:[...e,t.fields.component]),f(e=>e+1))},e=>{g(e)});return()=>e()},[]);let S=X(n);S.current=n;let C=t=>{if(e.level&&!e.level.split(`,`).includes((t.level||``).toUpperCase())||e.component&&t.fields?.component!==e.component)return!1;if(e.q){let n=e.q.toLowerCase();if(!`${t.message||t.msg||``} ${JSON.stringify(t.fields||{})}`.toLowerCase().includes(n))return!1}return!0},w=X(C);w.current=C;let T=Be(()=>{let e=new Map;for(let t of c)e.set(jn(t),t);for(let[t,n]of u.current)e.set(t,n);return[...e.values()].filter(C).slice(-1e3)},[c,d,e]);return Y(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},[T]),Z(`div`,{children:[Z(`div`,{className:`page-head`,children:[Z(`div`,{children:[Z(`h1`,{className:`page-title`,children:`Logs`}),Z(`p`,{className:`page-sub`,children:`What Archie has been doing, newest last.`})]}),Z(`div`,{className:`page-actions`,children:[Z(`button`,{className:`btn ${n?`btn-primary`:``}`,onClick:()=>r(!n),children:n?`Resume`:`Pause`}),Z(`button`,{className:`btn`,onClick:x,children:`Refresh`})]})]}),Z(`div`,{className:`card`,children:[Z(`div`,{className:`card-head`,children:[Z(`div`,{className:`log-filters`,children:[Z(`select`,{className:`log-select`,value:e.level,onChange:e=>t(t=>({...t,level:e.target.value})),children:An.map(e=>Z(`option`,{value:e.value,children:e.label},e.value))}),Z(`select`,{className:`log-select`,value:e.component,onChange:e=>t(t=>({...t,component:e.target.value})),children:[Z(`option`,{value:``,children:`All components`}),i.map(e=>Z(`option`,{value:e,children:e},e))]}),Z(`input`,{className:`log-search`,type:`search`,placeholder:`Search messages and fields…`,onInput:e=>{let n=e.target.value;b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{t(e=>({...e,q:n}))},250)}})]}),Z(`div`,{className:`log-status`,children:[Z(`span`,{className:`log-meta`,children:_}),Z(wn,{text:h,kind:h===`live`?`ok`:`warn`})]})]}),Z(`div`,{className:`log-list`,ref:y,children:_===`Cannot read logs`?Z(Tn,{title:`Cannot read logs`}):T.length?T.map(e=>Z(kn,{entry:e},jn(e))):Z(Tn,{title:p?`Durable history unavailable`:`Nothing matches`,detail:p?`Live daemon logs will appear here while this page is open.`:`Try a wider level or clear the search.`})})]})]})}function Nn(e){return Z(Mn,{query:e})}function Pn(e,{expanded:t,onToggle:n}){let r=y(`tr.capture-row`,{tabindex:`0`,"aria-expanded":String(t),onclick:n,onkeydown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e))}},y(`td.mono`,e.source||`(unknown)`),y(`td`,{title:e.received_at||``},C(e.received_at)),y(`td`,S(`Unbound`,`idle`)),y(`td.mono`,e.content_type||`—`),y(`td`,y(`button.btn.btn-small`,{type:`button`},t?`Hide`:`View`)));return t?[r,Fn(e)]:[r]}function Fn(e){return y(`tr.capture-detail-row`,y(`td`,{colspan:5},y(`div.capture-detail`,y(`div.capture-detail-section`,y(`div.capture-detail-title`,`Payload`),In(e.body)),y(`div.capture-detail-section`,y(`div.capture-detail-title`,`Headers`),In(e.headers)))))}function In(e){return e?y(`pre.capture-payload`,Ln(e)):y(`div.capture-empty`,`(empty)`)}function Ln(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Rn(){let e=y(`div`),t=y(`div.card`),n=S(`connecting`,`idle`),r=[],i=null,s=null,c=!0;d(),u();let l=o(e=>{e.kind===`capture`&&u()},e=>{n.className=`pill pill-${e===`live`?`ok`:`warn`}`,n.textContent=e});e.addEventListener(`archie:teardown`,l);async function u(){try{let e=await a.captures(100);c=e.enabled!==!1,r=e.captures||[],s=null}catch(e){s=String(e.message||e)}f()}function d(){x(e,y(`div.page-head`,y(`div`,y(`h1.page-title`,`Event inspector`),y(`p.page-sub`,`Real inbound payloads archie has captured, most recent first.`)),y(`div.page-actions`,n,y(`button.btn`,{onclick:u},`Refresh`))),t),f()}function f(){if(s){x(t,T(`Cannot reach archied`,s));return}if(!c){x(t,T(`Capture is not configured`,`This deployment has no capture storage wired up.`));return}if(!r.length){x(t,T(`No captures yet`,`Point a webhook at /webhooks/capture/ and it will show up here.`));return}x(t,y(`div.table-scroll`,y(`table.table`,y(`thead`,y(`tr`,...[`Source`,`Received`,`Binding`,`Content type`,``].map(e=>y(`th`,e)))),y(`tbody`,...r.flatMap(e=>Pn(e,{expanded:i===e.id,onToggle:()=>{i=i===e.id?null:e.id,f()}}))))))}return e}var zn=[`string`,`number`,`bool`,`object`,`array`,`any`];function Bn(e){if(e==null)return`any`;if(Array.isArray(e))return`array`;switch(typeof e){case`string`:return`string`;case`number`:return`number`;case`boolean`:return`bool`;case`object`:return`object`;default:return`any`}}function Vn(e,t){return e?`${e}.${t}`:t}function Hn(e,t){return`${e}[${t}]`}function Un(e,{path:t=``,name:n=``,onPick:r}={}){return typeof e==`object`&&e?y(`ul.mapping-tree-list`,...(Array.isArray(e)?e.map((e,n)=>[String(n),e,Hn(t,n)]):Object.entries(e).map(([e,n])=>[e,n,Vn(t,e)])).map(([e,t,n])=>y(`li.mapping-tree-item`,y(`span.mapping-tree-key`,{onclick:i=>{i.stopPropagation(),r?.({path:n,type:Bn(t),name:e})}},e),Un(t,{path:n,name:e,onPick:r})))):y(`span.mapping-tree-value`,{onclick:i=>{i.stopPropagation(),r?.({path:t,type:Bn(e),name:n})}},JSON.stringify(e))}function Wn(e,{preview:t,onRemove:n,onNameChange:r,onTypeChange:i,onRequiredChange:a}={}){if(!e.length)return y(`div.mapping-empty-fields`,`Click a value in the payload to bind a field.`);let o=new Map((t?.failures||[]).map(e=>[e.field_name,e]));return y(`table.table.mapping-fields-table`,y(`thead`,y(`tr`,...[`Field name`,`Path`,`Type`,`Required`,`Preview`,``].map(e=>y(`th`,e)))),y(`tbody`,...e.map((e,s)=>y(`tr`,y(`td`,y(`input.mapping-input`,{value:e.name,oninput:e=>r?.(s,e.target.value)})),y(`td.mono`,e.path),y(`td`,y(`select.mapping-select`,{onchange:e=>i?.(s,e.target.value)},...zn.map(t=>y(`option`,{value:t,selected:t===e.type},t)))),y(`td`,y(`input`,{type:`checkbox`,checked:e.required,onchange:e=>a?.(s,e.target.checked)})),y(`td`,Gn(e,t,o)),y(`td`,y(`button.btn.btn-small`,{type:`button`,onclick:()=>n?.(s)},`Remove`))))))}function Gn(e,t,n){if(!t)return S(`not previewed`,`idle`);let r=n.get(e.name);return r?S(r.reason,`danger`):Object.prototype.hasOwnProperty.call(t.values||{},e.name)?S(JSON.stringify(t.values[e.name]),`ok`):S(`skipped (optional)`,`idle`)}function Kn(e,{onEdit:t,onDelete:n}){return y(`tr`,y(`td`,e.name),y(`td.mono`,e.source_hint||`—`),y(`td`,String(e.fields?.length??0)),y(`td`,y(`button.btn.btn-small`,{type:`button`,onclick:()=>t?.(e)},`Edit`),y(`button.btn.btn-small`,{type:`button`,onclick:()=>n?.(e)},`Delete`)))}function qn(){let e=y(`div`),t=[],n=[],r=null,i=null;S(),o();async function o(){try{let[e,i]=await Promise.all([a.mappings(),a.captures(100)]);t=e.mappings||[],n=i.captures||[],r=null}catch(e){r=String(e.message||e)}S()}function s(){i={id:null,name:``,sourceHint:``,fields:[],captureId:null,payload:null,payloadError:null,preview:null,actionError:null},S()}function c(e){i={id:e.id,name:e.name,sourceHint:e.source_hint||``,fields:(e.fields||[]).map(e=>({...e})),captureId:null,payload:null,payloadError:null,preview:null,actionError:null},S()}async function l(e){if(window.confirm(`Delete mapping "${e.name}"?`))try{await a.mappingDelete(e.id),await o()}catch(e){r=String(e.message||e),S()}}function u(e){let t=n.find(t=>String(t.id)===String(e));if(i.captureId=t?t.id:null,i.preview=null,!t)i.payload=null,i.payloadError=null;else try{i.payload=JSON.parse(t.body),i.payloadError=null}catch{i.payload=null,i.payloadError=`This capture's body is not valid JSON, so its fields cannot be mapped by path.`}S()}function d({path:e,type:t,name:n}){let r=new Set(i.fields.map(e=>e.name)),a=n||`field`,o=1;for(;r.has(a);)a=`${n||`field`}_${++o}`;i.fields.push({name:a,path:e,type:t,required:!0}),i.preview=null,S()}function f(e){i.fields.splice(e,1),i.preview=null,S()}function p(e,t){Object.assign(i.fields[e],t),i.preview=null,S()}let m=(e,t)=>p(e,{name:t}),h=(e,t)=>p(e,{type:t}),g=(e,t)=>p(e,{required:t});async function _(){if(!i.captureId){i.actionError=`Pick a captured event to preview against.`,S();return}try{i.preview=await a.mappingPreview(i.captureId,i.fields),i.actionError=null}catch(e){i.actionError=String(e.message||e)}S()}async function v(){let e={name:i.name,source_hint:i.sourceHint,fields:i.fields};try{i.id?await a.mappingUpdate(i.id,e):await a.mappingCreate(e),i=null,await o()}catch(e){i.actionError=String(e.message||e),S()}}function b(){i=null,S()}function S(){x(e,i?w():C())}function C(){return y(`div`,y(`div.page-head`,y(`div`,y(`h1.page-title`,`Field mappings`),y(`p.page-sub`,`Bind named fields to JSON paths from a real captured event, ready for a playbook binding.`)),y(`div.page-actions`,y(`button.btn.btn-primary`,{type:`button`,onclick:s},`New mapping`))),r?T(`Cannot reach archied`,r):t.length?y(`div.card`,y(`div.table-scroll`,y(`table.table`,y(`thead`,y(`tr`,...[`Name`,`Source hint`,`Fields`,``].map(e=>y(`th`,e)))),y(`tbody`,...t.map(e=>Kn(e,{onEdit:c,onDelete:l})))))):T(`No mappings yet`,`Create one from a captured event to reuse fields in a future playbook binding.`))}function w(){return y(`div`,y(`div.page-head`,y(`div`,y(`h1.page-title`,i.id?`Edit mapping`:`New mapping`)),y(`div.page-actions`,y(`button.btn`,{type:`button`,onclick:b},`Cancel`),y(`button.btn.btn-primary`,{type:`button`,onclick:v},`Save`))),i.actionError?y(`div.mapping-error`,i.actionError):null,y(`div.card.mapping-form`,y(`label.mapping-form-row`,`Name`,y(`input.mapping-input`,{value:i.name,oninput:e=>{i.name=e.target.value}})),y(`label.mapping-form-row`,`Source hint (organisational only)`,y(`input.mapping-input`,{value:i.sourceHint,oninput:e=>{i.sourceHint=e.target.value}})),y(`label.mapping-form-row`,`Preview against captured event`,y(`select.mapping-select`,{onchange:e=>u(e.target.value)},y(`option`,{value:``},`— pick a captured event —`),...n.map(e=>y(`option`,{value:e.id,selected:String(i.captureId)===String(e.id)},`${e.source||`(unknown)`} — ${e.received_at||``}`))))),y(`div.card.mapping-fields`,y(`div.mapping-section-title`,`Bound fields`),Wn(i.fields,{preview:i.preview,onRemove:f,onNameChange:m,onTypeChange:h,onRequiredChange:g}),y(`button.btn`,{type:`button`,onclick:_},`Preview`)),y(`div.card.mapping-payload`,y(`div.mapping-section-title`,`Payload — click a value to bind it`),i.payloadError?y(`div.mapping-error`,i.payloadError):i.payload===null?y(`div.mapping-empty-fields`,`Pick a captured event above to see its payload.`):Un(i.payload,{onPick:d})))}return e}function Jn({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}function Yn({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function Xn(e){return e===`external`?`Added by you — an external store Archie was given`:`Built in — always available to Archie`}function Zn({provider:e}){let t=e.tools||[];return Z(`div`,{className:`card`,children:[Z(`div`,{className:`card-head`,children:[Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:e.name||`provider`}),Z(`p`,{className:`card-sub`,children:Xn(e.role)})]}),e.available?Z(Jn,{text:`ready`,kind:`ok`}):Z(Jn,{text:`unavailable`,kind:`danger`})]}),!e.available&&Z(`p`,{className:`mem-warning`,children:`Configured but not usable right now — a required binary or connection may be missing.`}),t.length?Z(`ul`,{className:`mem-tools`,children:t.map((e,t)=>Z(`li`,{className:`mem-tool`,children:[Z(`div`,{className:`mem-tool-name mono`,children:e.name}),e.description&&Z(`div`,{className:`mem-tool-desc`,children:e.description})]},t))}):Z(`p`,{className:`mem-warning`,children:`This provider exposes no tools, so the agent cannot use it.`})]})}function Qn(){let[e,t]=J(null),[n,r]=J(!0),[i,o]=J(null),[s,c]=J(!0),l=async()=>{c(!0),o(null);try{let e=await a.memory();r(!!e.enabled),t(e.providers||[])}catch(e){o(String(e.message||e))}finally{c(!1)}};return Y(()=>{l()},[]),Z(`div`,{children:[Z(`div`,{className:`page-head`,children:[Z(`div`,{children:[Z(`h1`,{className:`page-title`,children:`Memory`}),Z(`p`,{className:`page-sub`,children:`What Archie can recall between conversations, and the tools it uses to do it.`})]}),Z(`div`,{className:`page-actions`,children:Z(`button`,{className:`btn`,onClick:l,children:`Refresh`})})]}),Z(`div`,{children:s?Z(`div`,{className:`card`,children:Z(`div`,{className:`mem-loading`,children:`Loading…`})}):i?Z(`div`,{className:`card`,children:Z(Yn,{title:`Cannot read memory providers`,detail:i})}):!n||!e.length?Z(`div`,{className:`card`,children:Z(Yn,{title:`Memory is not configured`,detail:`Without a provider, Archie starts every conversation with no recollection of earlier ones.`})}):Z(`div`,{className:`grid grid-2`,children:e.map((e,t)=>Z(Zn,{provider:e},t))})})]})}function $n(e){return Z(Qn,{query:e})}function er(e){let t=document.createDocumentFragment(),n=/(!\[[^\]]*\]\((?:https?:\/\/[^\s)]+|data:image\/[^\s)]+|\/[^\s)]+)\)|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|`[^`]+`|\[[^\]]+\]\((?:https?:\/\/[^\s)]+|\/[^\s)]+)\)|\*[^*]+\*|_[^_]+_)/g,r=0;for(let i of e.matchAll(n)){i.index>r&&t.append(document.createTextNode(e.slice(r,i.index)));let n=i[0];if(n.startsWith(`![`)){let e=n.match(/^!\[([^\]]*)\]\((.+)\)$/);e&&t.append(y(`img.chat-media-img`,{src:e[2],alt:e[1]||`Image`,loading:`lazy`}))}else if(n.startsWith(`~~`))t.append(y(`del`,n.slice(2,-2)));else if(n.startsWith(`**`)||n.startsWith(`__`))t.append(y(`strong`,n.slice(2,-2)));else if(n.startsWith("`"))t.append(y(`code`,n.slice(1,-1)));else if(n.startsWith(`[`)){let e=n.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+|\/[^\s)]+)\)$/);t.append(y(`a`,{href:e[2],target:`_blank`,rel:`noreferrer`},e[1]))}else t.append(y(`em`,n.slice(1,-1)));r=i.index+n.length}return r{r.length&&(t.append(y(`p`,er(r.join(` `)))),r=[])},s=()=>{i&&t.append(i),i=null};for(let e=0;ey(`td`,er(e)))));t.append(y(`table`,y(`thead`,y(`tr`,...l.map(e=>y(`th`,er(e))))),i));continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.append(y(`h${d[1].length}`,er(d[2])));continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tagName.toLowerCase()!==e)&&(s(),i=y(e)),i.append(y(`li`,er((f||p)[1])));continue}if(c.startsWith(`>`)){o(),s(),t.append(y(`blockquote`,er(c.replace(/^>\s?/,``))));continue}r.push(c)}return o(),s(),a&&t.append(y(`pre`,y(`code`,a.join(` -`)))),t}function nr(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function rr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var ir=`archie.web.chat.channel`;function ar(){let t=localStorage.getItem(ir);return t||(t=e(),localStorage.setItem(ir,t)),t}function or(t){return{text:t,sourceID:e()}}function sr(e){return{...e}}function cr(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?sr(e.turn):or(r),isRetry:n}}function lr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function ur(e){return e?.status===501?null:`Could not check for updates.`}function dr(){return location.hash.slice(1)||`/`}function fr({text:e}){let t=X(null);return Y(()=>{t.current&&t.current.replaceChildren(tr(e||``))},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function pr(){let[e,t]=J([]),[n,r]=J(``),[i,o]=J([]),[s,c]=J(``),[l,u]=J(`Ready`),[d,f]=J(!1),[p,m]=J({}),[h,g]=J(``),[_,v]=J(``),[y,b]=J(``),[x,S]=J([]),[C,w]=J([]),[T,E]=J(0),[D,O]=J(!1),[k,A]=J(null),[j,M]=J(null),[N,ee]=J(null),[P,te]=J(``),[F,ne]=J(``),[I,L]=J(null),R=X(null),z=X(null),B=X(null),re=X(null),ie=X(null),V=X(d);V.current=d,Y(()=>{R.current&&(R.current.scrollTop=R.current.scrollHeight)},[i,I]),Y(()=>{ue().catch(e=>{u(e.message||`Chat unavailable`)}),ae();let e=()=>{B.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),B.current?.abort()}},[]);async function ae(){try{let e=await a.chatUpdate();M(e?.snapshot||null),A(e)}catch(e){let t=ur(e);A(t?{error:t}:null)}}async function oe(){if(j)try{await a.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),u(`Update deferred`)}catch(e){u(e.message||`Could not defer update`)}}async function se(){if(j)try{u(`Installing…`);let e=await a.chatUpdateInstall(j);M(null),A({snapshot:{},available:[]}),u(e?.result?.restart_requested?`Update installed; restart queued`:`Update complete`)}catch(e){u(e.message||`Update install failed`)}}async function ce(){try{let e=await a.chatDangerous();ee(e)}catch(e){ee({error:e.message||`Dangerous actions unavailable`})}}async function U(e,t){if(t)try{await a.chatDangerousRequest(e,t),u(`Approval requested`),await ce()}catch(e){u(e.message||`Could not request action`)}}async function le(e,t){try{await a.chatDangerousDecision(e,t),u(t===`deny`?`Action denied`:`Action approved`),await ce()}catch(e){u(e.message||`Approval failed`)}}async function ue(){let e=await a.chatSessions(),r=e.sessions||[];t(r),m(e),g(e.active_persona||``);let i=e.providers||[],o=e.active_provider||i[0]||``;v(o),b(e.active_model||``);let s=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);S(s),e.dangerous_available&&await ce(),!n&&r[0]&&await de(r[0].session_id,e,r)}async function de(e,t,n){let i=t||p;r(e),o([]),L(null);let s=i.active_personas?.[e]||i.active_persona||``;g(s);try{await a.chatMessage(ar(),`/resume ${e}`);let[t,n]=await Promise.all([a.chatMessages(e),a.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});o(i)}catch(e){u(e.message||`Could not load session messages`)}}async function W(e){if(n)try{u(`Working…`);let t=await a.chatMessage(ar(),e);t.session_id&&r(t.session_id),u(t.reply||`Session updated`),await ue(),(t.session_id||n)&&await de(t.session_id||n),re.current&&(re.current.open=!1)}catch(e){u(e.message||`Session action failed`)}}function fe(e,t){let n=window.prompt(t);n?.trim()&&W(`${e} ${n.trim()}`)}function pe(e){let t=e.target.value;g(t),!(!n||!t)&&a.chatPersona(n,t).then(()=>{m(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),u(`Personality: ${t}`)}).catch(e=>{u(e.message||`Failed to set personality`)})}async function me(e){let t=e.target.value;if(v(t),t)try{let e=await a.chatMessage(ar(),`/model --provider ${t}`);u(e.reply||`Provider updated`),await ue()}catch(e){u(`Provider update failed: ${e.message||e}`)}}async function he(e){let t=e.target.value;if(b(t),t)try{let e=await a.chatMessage(ar(),`/model ${t}`);u(e.reply||`Model updated`),await ue()}catch(e){u(`Model update failed: ${e.message||e}`)}}function ge(){window.confirm(`Reload the Telegram chat adapter?`)&&(c(`/restart`),G({textOverride:`/restart`}))}function _e(){c(`/new`),G({textOverride:`/new`})}function ve(e){let t=e.target.value;c(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=x.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function ye(e){let t=C[e];if(!t||!z.current)return;let n=z.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.search(/(?:^|\s)\/[^\s]*$/),o=a<0?r.length:a+ +(r[a]===` `),s=`${r.slice(0,o)}${t.command} ${i}`;c(s),O(!1);let l=o+t.command.length+1;setTimeout(()=>{n.focus(),n.setSelectionRange(l,l)},0)}function be(e){if(D&&C.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&C.some(e=>e.command===s.trim())){e.preventDefault(),O(!1),G();return}if(e.key===`ArrowDown`){e.preventDefault(),E(e=>(e+1)%C.length);return}if(e.key===`ArrowUp`){e.preventDefault(),E(e=>(e+C.length-1)%C.length);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),ye(T);return}if(e.key===`Escape`){e.preventDefault(),O(!1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),G())}async function G(e=null){let t=e?.textOverride,{text:n,turn:i,isRetry:a}=cr(e,t===void 0?s:t);if(!n||V.current)return;O(!1),f(!0),u(a?`Retrying…`:`Thinking…`),a||(o(e=>[...e,{from:`web`,text:n}]),c(``));let l=[];L({text:``,tools:[],isError:!1,turn:i,isRetry:a});let d=``,p=!1,m=!1,h=null;try{let e=new AbortController;B.current=e,h=setTimeout(()=>{m=!0,e.abort()},12e4);let t=await fetch(`/api/chat/stream`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`text/event-stream`},body:JSON.stringify({channel_id:ar(),source_id:i.sourceID,text:i.text,page:dr()}),signal:e.signal});if(!t.ok)throw Error(await t.text()||`${t.status} ${t.statusText}`);let n=t.body.getReader(),a=new TextDecoder,s=``;for(;;){let{value:e,done:t}=await n.read();s+=a.decode(e||new Uint8Array,{stream:!t});let i=s.split(` + class="gauge-value"/>`,y(`div.gauge-wrap`,l,y(`div.gauge-center`,y(`div.gauge-pct`,`${Math.round(r)}%`),y(`div.gauge-label`,t)))}function Xe(e){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return y(`div`,y(`div.segbar`,...e.filter(e=>e.value>0).map(e=>y(`span`,{class:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`}))),y(`div.segbar-legend`,...e.map(e=>y(`span.segbar-key`,y(`span`,{class:`segbar-dot segbar-${e.kind||`idle`}`}),e.label))))}var Ze=`archie.setup-complete.dismissed.v1`;function Qe(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(Ze),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function $e(e=globalThis.localStorage){e?.setItem?.(Ze,`1`)}var et=new Set([`waiting_human`,`parked`]);function tt(e=[]){let t=e.filter(e=>et.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}var nt=0;Array.isArray;function X(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--nt,__i:-1,__u:0,__source:i,__self:a};if(typeof e==`function`&&(o=e.defaultProps))for(s in o)c[s]===void 0&&(c[s]=o[s]);return D.vnode&&D.vnode(l),l}function rt({node:e}){let t=Y();return J(()=>{t.current&&e&&t.current.replaceChildren(e)},[e]),X(`div`,{ref:t,style:{display:`contents`}})}function it(e){return X(rt,{node:qe(e)})}function at(e){return X(rt,{node:Ye(e)})}function ot({segments:e}){return X(rt,{node:Xe(e)})}function Z({name:e,opts:t}){return X(rt,{node:T(e,t)})}function st({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function ct({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}function lt(e,t){return Number(e.task_id)>0?Number(e.task_id):!e.repo||!e.issue?0:Number(t.get(`${e.repo}#${e.issue}`))||0}function ut(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function dt(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0),r=e.slice(t).reduce((e,t)=>e+t,0);return n?(r-n)/n*100:null}function ft(){let[e,t]=q([]),[n,r]=q(`connecting`),[i,s]=q(`idle`),[c,l]=q(new Map),[u,d]=q(null),[f,p]=q(null),[m,h]=q(null),[g,_]=q(null),[v,y]=q(null),[,b]=q(!1),x=async()=>{y(null);try{let[e,t,n,r]=await Promise.all([a.summary(),a.setup().catch(()=>null),a.workflows().catch(()=>null),a.tasks().catch(()=>[])]),i=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&i.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);l(i),d(e),p(t),h(n),_(r)}catch(e){y(String(e.message||e))}};J(()=>(x(),o(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),s(e===`live`?`ok`:`warn`)})),[]);let w=()=>{$e(),b(e=>!e)},T=f?.operator?`${ut()}, ${f.operator}`:ut(),E=null;if(v)E=X(`button`,{className:`btn btn-primary`,onClick:x,children:[X(Z,{name:`refresh`,opts:{size:15}}),` Retry`]});else if(g!==null){let e=tt(g),t=e.attention.count,n=e.running.count;E=X(V,{children:[t>0&&X(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[X(Z,{name:`tasks`,opts:{size:15}}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&X(`a`,{className:`btn`,href:e.running.href,children:[X(Z,{name:`workflows`,opts:{size:15}}),` `,n,` running`]}),X(`a`,{className:`btn`,href:`#/logs`,children:[X(Z,{name:`logs`,opts:{size:15}}),` Logs`]}),X(`button`,{className:`btn btn-primary`,onClick:x,children:[X(Z,{name:`refresh`,opts:{size:15}}),` Refresh`]})]})}let D=null;if(v)D=X(`div`,{className:`card`,children:X(st,{title:`Cannot reach archied`,detail:v})});else if(u){let e=u?.statuses||{},t=(e.merged||0)+(e.pr_open||0),n=(e.parked||0)+(e.waiting_human||0),r=Object.values(e).reduce((e,t)=>e+t,0),i=u?.tokens_by_day||[];D=X(V,{children:[X(it,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),X(it,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),X(it,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),X(it,{label:`Tokens used`,value:C(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:dt(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let O=null,k=Qe(f),A=k.kind===`omit`||k.kind===`dismissed`;if(!A){let e=k.remaining;if(e.length){let t=Math.round((f.steps.length-e.length)/f.steps.length*100);O=X(`div`,{className:`card setup`,children:[X(`div`,{className:`card-head`,children:[X(`div`,{children:[X(`h2`,{className:`card-title`,children:`Finish setting up`}),X(`p`,{className:`card-sub`,children:`Archie needs these before it can work on its own.`})]}),X(`span`,{className:`setup-pct`,children:[t,`%`]})]}),X(`div`,{className:`setup-bar`,children:X(`div`,{className:`setup-bar-fill`,style:{width:`${t}%`}})}),X(`ul`,{className:`setup-list`,children:f.steps.map((e,t)=>X(`li`,{className:`setup-step ${e.done?`done`:``}`,children:[X(`span`,{className:`setup-check`,children:e.done?X(Z,{name:`check`,opts:{size:12}}):``}),X(`div`,{children:[X(`div`,{className:`setup-step-title`,children:e.title}),e.detail&&X(`div`,{className:`setup-step-detail`,children:e.detail})]})]},t))})]})}else O=X(`div`,{className:`card setup setup-done`,children:X(`div`,{className:`card-head`,children:[X(`div`,{children:[X(`h2`,{className:`card-title`,children:`Setup complete`}),X(`p`,{className:`card-sub`,children:`Archie is configured and ready to work.`})]}),X(`div`,{className:`setup-complete-actions`,children:[X(`span`,{className:`setup-pct`,children:X(Z,{name:`check`,opts:{size:16}})}),X(`button`,{className:`icon-btn setup-dismiss`,type:`button`,title:`Dismiss setup complete`,"aria-label":`Dismiss setup complete`,onClick:w,children:`×`})]})]})})}let j=null;if(u){let e=m?.workflows||[],t=e.reduce((e,t)=>e+(t.runs||0),0),n=e.reduce((e,t)=>e+(t.merged||0)+(t.pr_open||0),0),r=e.reduce((e,t)=>e+(t.parked||0),0);if(!t)j=X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:X(`h2`,{className:`card-title`,children:`Gate pulse`})}),X(st,{title:`No completed runs yet`,detail:`Once Archie finishes a task, its gate pass rate appears here.`})]});else{let i=n/t*100;j=X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:X(`div`,{children:[X(`h2`,{className:`card-title`,children:`Gate pulse`}),X(`p`,{className:`card-sub`,children:`Work that passed its quality gates`})]})}),X(at,{value:i,label:`pass rate`}),X(`ul`,{className:`pulse-list`,children:[e.slice(0,3).map((e,t)=>X(`li`,{className:`pulse-item`,children:[X(`span`,{className:`pulse-name`,children:e.workflow||`workflow`}),X(ct,{text:`${e.merged||0}/${e.runs||0}`,kind:(e.merged||0)===(e.runs||0)?`ok`:(e.parked||0)>0?`warn`:`info`})]},t)),r>0&&X(`li`,{className:`pulse-item`,children:[X(`span`,{className:`pulse-name`,children:`Parked, awaiting you`}),X(ct,{text:String(r),kind:`warn`})]})]})]})}}let M=null;if(u){let e=u?.tokens_by_day||[],t=e.reduce((e,t)=>e+(t.tokens||0),0);if(!e.length)M=X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:X(`h2`,{className:`card-title`,children:`Token outlook`})}),X(st,{title:`Nothing spent yet`,detail:`Usage appears here once Archie runs its first task.`})]});else{let n=t/e.length,r=Math.round(n*30),i=e.slice(-7).reduce((e,t)=>e+(t.tokens||0),0);M=X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:X(`div`,{children:[X(`h2`,{className:`card-title`,children:`Token outlook`}),X(`p`,{className:`card-sub`,children:`Next 30 days at the current rate`})]})}),X(`div`,{className:`forecast-value`,children:C(r)}),X(`div`,{className:`forecast-note`,children:[`Based on `,C(Math.round(n)),` per day over `,e.length,` days`]}),X(ot,{segments:[{label:`Last 7 days (${C(i)})`,value:i,kind:`info`},{label:`Earlier (${C(t-i)})`,value:Math.max(t-i,0),kind:`idle`}]})]})}}return X(V,{children:[X(`div`,{className:`hero`,children:[X(`div`,{children:[X(`h1`,{className:`hero-title`,children:T}),X(`p`,{className:`hero-sub`,children:`Your agent's control room — what it is working on, what needs you, and what it is spending.`})]}),X(`div`,{className:`hero-actions`,children:X(`div`,{className:`hero-actions-inner`,children:E})})]}),X(`div`,{className:`dash-section`,children:[X(`div`,{className:`dash-section-head`,children:X(`h2`,{className:`dash-section-title`,children:`Health`})}),X(`div`,{className:`dash-top ${A?`dash-top-standalone`:``}`,children:[X(`div`,{children:O}),X(`div`,{children:j})]})]}),X(`div`,{className:`dash-section`,children:[X(`div`,{className:`dash-section-head`,children:[X(`h2`,{className:`dash-section-title`,children:`Throughput`}),X(`span`,{className:`dash-section-note`,children:`Across all repositories`})]}),X(`div`,{className:`grid grid-4`,children:D})]}),X(`div`,{className:`dash-section`,children:[X(`div`,{className:`dash-section-head`,children:X(`h2`,{className:`dash-section-title`,children:`Right now`})}),X(`div`,{className:`dash-split`,children:[X(`div`,{children:M}),X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:[X(`div`,{children:[X(`h2`,{className:`card-title`,children:`Live activity`}),X(`p`,{className:`card-sub`,children:`Last 50, newest first`})]}),X(ct,{text:n,kind:i})]}),X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Event`}),X(`th`,{children:`Task`}),X(`th`,{children:`Detail`}),X(`th`,{children:`When`})]})}),X(`tbody`,{children:e.length?e.map((e,t)=>{let n=lt(e,c),r=n>0,i=()=>{r&&(location.hash=`#/tasks?task=${encodeURIComponent(n)}`)};return X(`tr`,{className:r?`activity-row`:``,role:r?`link`:void 0,tabIndex:r?`0`:void 0,title:r?`Open task details`:void 0,onClick:r?i:void 0,onKeyDown:r?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())}:void 0,children:[X(`td`,{className:`strong`,children:X(`span`,{children:e.kind||e.type||`event`})}),X(`td`,{className:`mono`,children:r?`#${n}`:`—`}),X(`td`,{children:e.detail||e.message||``}),X(`td`,{children:S(e.at||Date.now())})]},t)}):X(`tr`,{children:X(`td`,{colSpan:`4`,children:X(st,{title:`Waiting for activity`,detail:`Events appear here as Archie works.`})})})})]})})]})]})]})]})}function pt(){return X(ft,{})}function mt(e,t){let n=e.title||`untitled task`;return{"aria-expanded":String(t),"aria-controls":`task-timeline-${e.id}`,"aria-label":`${t?`Collapse`:`Expand`} timeline for ${n}`}}var ht=_(),gt=new Set([`needs_you`,...g()]);function _t(e){let t=e?.get?.(`status`)||``;return gt.has(t)?t:``}function vt(e,t){return t?t===`needs_you`?ht.has(e.status):e.status===t:!0}function yt(e){return String(e||`event`).replaceAll(`_`,` `).replace(/\b\w/g,e=>e.toUpperCase())}function bt(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return``;if(t<1e3)return`${Math.round(t)} ms`;let n=t/1e3;if(n<60)return`${n.toFixed(+(n<10))} s`;let r=Math.round(n),i=Math.floor(r/60),a=r%60;if(i<60)return a===0?`${i} min`:`${i} min ${a} s`;let o=Math.floor(i/60),s=i-o*60;return s===0?`${o} h`:`${o} h ${s} min`}function xt(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:t.toLocaleString(`en-US`)}function St(e={}){let t=e.data||{},n=e.stage||`unknown stage`,r=e.workflow?`${e.workflow} workflow`:``;if(e.kind===`stage_start`)return{title:`Started stage: ${n}`,detail:r};if(e.kind===`stage_finish`){let e=bt(t.duration_ms),i=[r,e&&`ran for ${e}`].filter(Boolean).join(` · `);return{title:t.interrupted?`Stage interrupted: ${n}`:t.error?`Stage failed: ${n}`:`Finished stage: ${n}`,detail:[i,t.error].filter(Boolean).join(` — `)}}if(e.kind===`task_retried`){let n=Number(t.retry_count);return{title:Number.isFinite(n)&&n>0?`Retry ${n}`:`Retry requested`,detail:[t.previous_stage&&`after ${t.previous_stage}`,t.previous_reason].filter(Boolean).join(`: `)||e.detail||``}}if(e.kind===`agent_finish`){let r=xt(t.iterations),i=xt(t.tokens),a=Number(t.cached_tokens)||0,o=xt((Number(t.prompt_tokens)||0)-a),s=xt(t.completion_tokens),c=xt(t.cached_tokens),l=[r&&`${r} iterations`,i&&`${i} tokens`,o&&`${o} fresh prompt`,s&&`${s} completion`,c&&`${c} cached`,t.model].filter(Boolean);return{title:`Agent ${t.status||`finished`}: ${n}`,detail:l.join(` · `)||e.detail||``}}return{title:yt(e.kind||e.type),detail:e.detail||``}}function Ct(e){switch((e||``).toUpperCase()){case`ERROR`:return`danger`;case`WARN`:return`warn`;case`DEBUG`:return`idle`;default:return`info`}}function wt(e){let t=e.fields||{};return y(`div.log-row.log-${Ct(e.level)}`,y(`span.log-time.mono`,Et(e.time)),y(`span.log-level`,(e.level||`info`).toUpperCase()),y(`span.log-body`,y(`span.log-msg`,e.message||e.msg||``),...Object.entries(t).map(([e,t])=>y(`span.log-field`,y(`span.log-field-key`,e),String(Tt(t))))))}function Tt(e){return e==null?``:typeof e==`object`?JSON.stringify(e):e}function Et(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`--:--:--`:t.toTimeString().slice(0,8)}function Dt({entry:e}){let t=Y(null);return J(()=>{t.current&&t.current.replaceChildren(wt(e))},[e]),X(`div`,{ref:t,style:{display:`contents`}})}function Ot({state:e,onRetry:t}){if(e===void 0)return X(`div`,{className:`task-log-loading`,children:`Loading attempt log…`});if(e===null)return X(`div`,{className:`task-log-error`,children:[X(`div`,{className:`task-timeline-detail`,children:`Could not load this attempt's log.`}),X(`button`,{className:`btn`,onClick:t,children:`Retry`})]});if(e.disabled)return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:`No persisted log for this attempt`}),X(`div`,{children:`Task logging is optional and was not enabled for this run.`})]});let n=e.entries||[];return n.length?X(`div`,{className:`log-list task-log-list`,children:n.map((e,t)=>X(Dt,{entry:e},t))}):X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:`Nothing recorded`}),X(`div`,{children:`This attempt's log file has no entries matching the current filter.`})]})}function kt(e){let t=Y(null);return J(()=>{t.current&&t.current.replaceChildren(qe(e))},[e]),X(`div`,{ref:t,style:{display:`contents`}})}function At({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}function jt({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Mt({query:e}){let[t,n]=q(null),[r,i]=q(null),[o,s]=q(()=>_t(e)),[c,l]=q(``),u=Number(e.get(`task`)),d=Number.isFinite(u)&&u>0?u:null,[f,p]=q(d),[_,y]=q(d!==null),[b,x]=q(new Map),[C,w]=q(new Map),[T,E]=q(new Set),[D,O]=q(new Map),[k,A]=q(new Set),j=async()=>{try{i(null);let e=await a.tasks();n(e),f&&e.some(e=>String(e.id)===String(f))&&(b.has(f)||M(f))}catch(e){i(String(e.message||e)),n(null)}};J(()=>{j()},[]);let M=async e=>{try{let t=await a.task(e);x(n=>new Map(n).set(e,t||[]))}catch{x(t=>new Map(t).set(e,null))}},N=async e=>{w(t=>{let n=new Map(t);return n.delete(e),n});try{let t=await a.taskLogs(e,{limit:500});w(n=>new Map(n).set(e,t))}catch{w(t=>new Map(t).set(e,null))}},ee=async(e,t)=>{O(t=>{let n=new Map(t);return n.delete(e),n}),A(t=>new Set(t).add(e));try{await a.taskAction(e,t),A(t=>{let n=new Set(t);return n.delete(e),n}),t===`archive`&&p(null),await j()}catch(t){A(t=>{let n=new Set(t);return n.delete(e),n}),O(n=>new Map(n).set(e,t.message||`Action failed`))}};J(()=>{_&&f&&t&&(y(!1),requestAnimationFrame(()=>{let e=document.getElementById(`task-row-${f}`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`center`,behavior:`smooth`}))}))},[_,f,t]);let P=(e,t)=>{t&&t.stopPropagation();let n=f!==e;p(n?e:null),n&&M(e)},te=e=>{E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),C.has(e)||N(e)),n})},ne=()=>{if(!t)return null;let e=t.length,n={};for(let e of t)n[e.status]=(n[e.status]||0)+1;let r=n.running||0,i=(n.waiting_human||0)+(n.parked||0),a=(n.merged||0)+(n.pr_open||0);return X(`div`,{className:`grid grid-4 task-summary`,children:[X(kt,{label:`Total tasks`,value:e,compare:e?`Everything archied has ever picked up`:`No tasks yet`}),X(kt,{label:`Working now`,value:r,compare:e?`${r} of ${e} in progress`:`Nothing running`}),X(kt,{label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),X(kt,{label:`Delivered`,value:a,compare:e?`${Math.round(a/e*100)}% of all tasks`:`No tasks yet`})]})},re=e=>{let t=D.get(e.id),n=t?X(`span`,{className:`task-action-error`,children:t}):null,r=k.has(e.id),i=e=>e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``,a=(e.actions||[]).map(t=>{let n=v(t);if(!n)return null;let a=e.title||`this task`,o=n.confirm?n.confirm.replaceAll(`{title}`,a):void 0,s=[`button`,`btn`,`btn-small`,i(n.kind)].filter(Boolean).join(` `);if(n.kind===`link`){if(t===`open_pr`)return F(e,`pull_request`,e.pr_number,n.label);if(t===`open_issue`)return F(e,`issue`,e.issue_number,n.label)}return X(`button`,{className:s,type:`button`,disabled:r,onClick:n=>{n.stopPropagation(),!(o&&!window.confirm(o))&&ee(e.id,t)},children:n.label},t)}).filter(Boolean);return!a.length&&!n?`—`:X(`div`,{className:`task-actions`,children:[n,a]})},F=(e,t,n,r)=>{let i=t===`issue`?e.issue_url:e.pr_url;return!i||!n||t===`issue`&&e.source===`chat`?X(`button`,{className:`btn btn-small`,type:`button`,disabled:!0,title:`${r} is unavailable`,children:r}):X(`a`,{className:`btn btn-small`,href:i,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:r})},I=e=>{let t=e.repo_url;return t?X(`a`,{className:`task-source-link`,href:t,target:`_blank`,rel:`noreferrer`,title:`Open ${e.owner}/${e.repo} on the forge`,onClick:e=>e.stopPropagation(),children:[e.owner,`/`,e.repo]}):null},L=e=>{let t=e.issue_url;return e.source===`chat`||!t||!e.issue_number?null:X(`a`,{className:`task-source-link`,href:t,target:`_blank`,rel:`noreferrer`,title:`Open issue #${e.issue_number} on the forge`,onClick:e=>e.stopPropagation(),children:[`#`,e.issue_number]})},R=e=>{let t=b.get(e.id),n=T.has(e.id);return X(`tr`,{className:`task-timeline-row`,id:`task-timeline-${e.id}`,children:X(`td`,{colSpan:8,children:[X(`div`,{className:`task-detail-actions`,children:[X(`div`,{className:`task-decision-title`,children:`Available actions`}),re(e)]}),e.status===`waiting_human`&&e.plan&&X(`div`,{className:`task-decision`,children:[X(`div`,{className:`task-decision-title`,children:`Decision required`}),X(`div`,{className:`task-decision-plan`,children:e.plan})]}),e.status===`parked`&&e.park_reason&&X(`div`,{className:`task-decision`,children:[X(`div`,{className:`task-decision-title`,children:`Park reason`}),X(`div`,{className:`task-decision-plan`,children:e.park_reason})]}),t===void 0?X(`div`,{className:`task-timeline-loading`,children:`Loading timeline…`}):t===null?X(`div`,{className:`task-timeline-error`,children:[X(`div`,{className:`task-timeline-title`,children:`Could not load timeline`}),X(`div`,{className:`task-timeline-detail`,children:`archied did not answer for this task's events. It may be restarting — retry, or check the daemon.`}),X(`button`,{className:`btn`,onClick:()=>M(e.id),children:`Retry`})]}):t.length?X(`ul`,{className:`task-timeline`,children:t.map((e,t)=>{let n=St(e);return X(`li`,{className:`task-timeline-entry`,children:[X(`span`,{className:`task-timeline-dot`}),X(`div`,{children:[X(`div`,{className:`task-timeline-kind`,children:n.title}),n.detail&&X(`div`,{className:`task-timeline-detail`,children:n.detail}),X(`div`,{className:`task-timeline-when`,children:S(e.at)})]})]},t)})}):X(jt,{title:`No events yet`,detail:`This task has not recorded any transitions.`}),X(`div`,{className:`task-logs-section`,children:[X(`div`,{className:`task-decision-title`,children:[`Attempt log`,X(`button`,{className:`btn btn-small`,onClick:()=>te(e.id),style:{marginLeft:`10px`},children:n?`Hide`:`Show`})]}),n&&X(Ot,{state:C.get(e.id),onRetry:()=>N(e.id)})]})]})})};return X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Tasks`}),X(`p`,{className:`page-sub`,children:`Every issue archied has picked up, and where it stands.`})]}),X(`div`,{className:`page-actions`,children:X(`button`,{className:`btn`,onClick:j,children:`Refresh`})})]}),r?X(`div`,{className:`grid grid-4 task-summary`,children:X(`div`,{className:`card`,children:X(jt,{title:`Cannot reach archied`,detail:r})})}):ne(),X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:[X(`div`,{children:[X(`h2`,{className:`card-title`,children:`All tasks`}),X(`p`,{className:`card-sub`,children:`Click a row for its timeline`})]}),X(`div`,{className:`task-filters`,children:[X(`input`,{className:`task-search`,type:`search`,placeholder:`Search by title or repo…`,value:c,onInput:e=>l(e.target.value.trim().toLowerCase())}),X(`select`,{className:`task-filter`,value:o,onChange:e=>s(e.target.value),children:[X(`option`,{value:``,children:`All statuses`}),X(`option`,{value:`needs_you`,children:`Needs you`}),g().map(e=>X(`option`,{value:e,children:m(e)},e))]})]})]}),X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[`Repo`,`Issue`,`Title`,`Status`,`Workflow`,`Stage`,`Last activity`,`Action`].map(e=>X(`th`,{children:e},e))})}),X(`tbody`,{children:(()=>{if(r)return X(`tr`,{children:X(`td`,{colSpan:8,children:X(jt,{title:`Cannot reach archied`,detail:r})})});if(!t)return X(`tr`,{children:X(`td`,{colSpan:8,children:X(`div`,{className:`task-timeline-loading`,children:`Loading tasks...`})})});if(!t.length)return X(`tr`,{children:X(`td`,{colSpan:8,children:X(jt,{title:`No tasks yet`,detail:`Tasks appear here once archied picks up an issue to work.`})})});let e=t.filter(e=>vt(e,o)?!c||`${e.title} ${e.repo}`.toLowerCase().includes(c):!1);return e.length?e.map(e=>{let t=f===e.id,n=`task-timeline-${e.id}`;return X(V,{children:[X(`tr`,{className:`task-row`,id:`task-row-${e.id}`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),P(e.id,t))},onClick:t=>P(e.id,t),...mt(e,t),children:[X(`td`,{className:`mono`,"data-label":`Repository`,children:[X(`button`,{className:`task-expand`,type:`button`,"aria-expanded":String(t),"aria-controls":n,"aria-label":`${t?`Collapse`:`Expand`} timeline for ${e.title||`untitled task`}`,onClick:t=>P(e.id,t),children:t?`−`:`+`}),I(e)??`${e.owner}/${e.repo}`]}),X(`td`,{className:`mono`,"data-label":`Issue`,children:L(e)??`#${e.issue_number}`}),X(`td`,{className:`strong`,"data-label":`Title`,children:e.title||`(untitled)`}),X(`td`,{"data-label":`Status`,children:X(At,{text:m(e.status),kind:h(e.status)})}),X(`td`,{"data-label":`Workflow`,children:e.workflow||`—`}),X(`td`,{"data-label":`Stage`,children:e.stage||`—`}),X(`td`,{"data-label":`Last activity`,title:e.created_at?`Created ${S(e.created_at)}`:``,children:S(e.updated_at)}),X(`td`,{"data-label":`Actions`,children:re(e)})]}),t&&R(e)]},e.id)}):X(`tr`,{children:X(`td`,{colSpan:8,children:X(jt,{title:`No matching tasks`,detail:`Try a different search or status filter.`})})})})()})]})})]})]})}function Nt(e){return X(Mt,{query:e})}function Pt({title:e,detail:t}){return X(`div`,{class:`empty`,children:[X(`div`,{class:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Ft({text:e,kind:t=`idle`}){return X(`span`,{class:`pill pill-${t}`,children:e})}function It(e){return X(Lt,{query:e})}function Lt(){let[e,t]=q([]),[n,r]=q(``),[i,o]=q(null),s=async()=>{try{let e=await a.skills();t(e?.skills||[]),o(null)}catch(e){t([]),o(String(e.message||e))}};J(()=>{s()},[]);let c=(e,t)=>!t||`${e.name} ${e.description}`.toLowerCase().includes(t),l=ze(()=>e.filter(e=>c(e,n)),[e,n]);return X(`div`,{children:[X(`div`,{class:`page-head`,children:[X(`div`,{children:[X(`h1`,{class:`page-title`,children:`Skills`}),X(`p`,{class:`page-sub`,children:`What Archie can do, in plain language.`})]}),X(`div`,{class:`page-actions`,children:X(`button`,{class:`btn`,onClick:s,children:`Refresh`})})]}),X(`div`,{class:`card`,children:[X(`div`,{class:`card-head`,children:[X(`div`,{children:[X(`h2`,{class:`card-title`,children:`Catalogue`}),X(`p`,{class:`card-sub`,children:`Project, shared, and user-global skills`})]}),X(`input`,{class:`skill-search`,type:`search`,placeholder:`Search skills…`,onInput:e=>r(e.target.value.trim().toLowerCase())})]}),X(`div`,{class:`grid grid-2`,children:i?X(Pt,{title:`Cannot reach archied`,detail:i}):e.length?l.length?l.map(e=>X(`div`,{class:`card skill-card`,children:[X(`div`,{class:`card-head`,children:[X(`h3`,{class:`card-title`,children:e.name||`Untitled skill`}),e.workflow&&X(Ft,{text:e.workflow,kind:`info`})]}),X(`p`,{class:`skill-desc`,children:e.description||`No description provided.`}),X(`div`,{class:`skill-source`,children:e.source||`Unknown source`})]},e.name)):X(Pt,{title:`No skills match`,detail:`Nothing found for "${n}".`}):X(Pt,{title:`No skills discovered yet`,detail:`Skills live as SKILL.md files under project, shared, or user-global .agents/skills// directories. Add one and refresh to make it available.`})})]})]})}var Rt={bootstrap:`Bootstrap`,implement:`Implement`,tdd:`TDD`,feasibility:`Feasibility check`};function zt(e){return Rt[e]?Rt[e]:e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown`}function Bt(e,t){return t?Math.round(e/t*100):0}function Vt(e){if(!e)return`—`;if(e<1e3)return`${e} ms`;let t=e/1e3;return t<60?`${t.toFixed(1)} s`:`${(t/60).toFixed(1)} min`}function Ht({title:e,detail:t}){return X(`div`,{class:`empty`,children:[X(`div`,{class:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Ut({fraction:e,kind:t=`ok`}){let n=Math.min(100,Math.max(0,e));return X(`div`,{class:`wf-bar`,children:X(`div`,{class:`wf-bar-fill wf-bar-${t}`,style:{width:`${n}%`}})})}function Wt(e){return X(Gt,{query:e})}function Gt(){let[e,t]=q([]),[n,r]=q([]),[i,o]=q([]),[s,c]=q(null),l=async()=>{try{let e=await a.workflows();t(e?.definitions||[]),r(e?.workflows||[]),o(e?.stages||[]),c(null)}catch(e){c(String(e.message||e))}};return J(()=>{l()},[]),X(`div`,{children:[X(`div`,{class:`page-head`,children:[X(`div`,{children:[X(`h1`,{class:`page-title`,children:`Workflows`}),X(`p`,{class:`page-sub`,children:`Run outcomes and spend per workflow, and where stages get stuck.`})]}),X(`div`,{class:`page-actions`,children:X(`button`,{class:`btn`,onClick:l,children:`Refresh`})})]}),X(Kt,{definitions:e}),s?X(`div`,{class:`card`,children:X(Ht,{title:`Cannot reach archied`,detail:s})}):X(V,{children:[X(qt,{workflows:n,definitions:e}),X(Jt,{stages:i})]})]})}function Kt({definitions:e}){if(!e.length)return null;let t=e.filter(e=>e.enabled)[0]?.id||``,[n,r]=q(``),[i,o]=q(``),[s,c]=q(t),[l,u]=q(``),[d,f]=q(``),[p,m]=q(!1),[h,g]=q(``);return J(()=>{!s&&t&&c(t)},[t,s]),X(`div`,{class:`card`,children:[X(`div`,{class:`card-head`,children:X(`div`,{children:[X(`h2`,{class:`card-title`,children:`Start work`}),X(`p`,{class:`card-sub`,children:`This enters Archie’s normal admitted task queue.`})]})}),X(`form`,{class:`wf-form`,onSubmit:async e=>{e.preventDefault(),m(!0),g(``);try{let e=await a.workRequest({identity:n,repository:i,workflow:s,title:l,instructions:d});g(`Queued task #${e.task_id}.`),r(``),o(``),c(t),u(``),f(``)}catch(e){g(String(e.message||e))}finally{m(!1)}},children:[X(`input`,{placeholder:`Identity`,required:!0,value:n,onInput:e=>r(e.target.value)}),X(`input`,{placeholder:`owner/repository`,required:!0,value:i,onInput:e=>o(e.target.value)}),X(`select`,{required:!0,value:s,onInput:e=>c(e.target.value),children:e.filter(e=>e.enabled).map(e=>X(`option`,{value:e.id,children:zt(e.name||e.id)},e.id))}),X(`input`,{placeholder:`Short task title`,required:!0,value:l,onInput:e=>u(e.target.value)}),X(`textarea`,{placeholder:`Instructions for the work`,required:!0,rows:3,value:d,onInput:e=>f(e.target.value)}),X(`button`,{class:`btn`,type:`submit`,disabled:p,children:`Start work`}),h&&X(`p`,{class:`card-sub`,children:h})]})]})}function qt({workflows:e,definitions:t}){let n=new Map(e.map(e=>[e.workflow,e])),r=t.map(e=>({...e,...n.get(e.id)||{workflow:e.id,runs:0,merged:0}}));return r.length?X(`div`,{class:`card`,children:[X(`div`,{class:`card-head`,children:X(`div`,{children:[X(`h2`,{class:`card-title`,children:`Per workflow`}),X(`p`,{class:`card-sub`,children:`Success rate is merged tasks over all runs`})]})}),X(`div`,{class:`table-scroll`,children:X(`table`,{class:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Workflow`}),X(`th`,{children:`Origin`}),X(`th`,{children:`Runs`}),X(`th`,{children:`Success rate`}),X(`th`,{children:`Avg tokens`}),X(`th`,{children:`Avg steps`})]})}),X(`tbody`,{children:r.map(e=>{let t=Bt(e.merged,e.runs);return X(`tr`,{children:[X(`td`,{class:`strong`,children:zt(e.workflow)}),X(`td`,{class:`mono`,children:e.origin||`registry`}),X(`td`,{children:`${e.runs} run${e.runs===1?``:`s`}`}),X(`td`,{children:[X(`div`,{class:`wf-rate`,children:[t,`%`,X(`span`,{class:`wf-rate-sub`,children:[e.merged,` of `,e.runs,` merged`]})]}),X(Ut,{fraction:t,kind:t>=50?`ok`:`warn`})]}),X(`td`,{class:`mono`,children:e.avg_tokens?e.avg_tokens.toLocaleString():`—`}),X(`td`,{class:`mono`,children:e.avg_steps?e.avg_steps.toFixed(1):`—`})]},e.workflow)})})]})})]}):X(`div`,{class:`card`,children:[X(`div`,{class:`card-head`,children:X(`div`,{children:X(`h2`,{class:`card-title`,children:`Per workflow`})})}),X(Ht,{title:`No workflow runs yet`,detail:`Stats appear here once a task has run through a workflow.`})]})}function Jt({stages:e}){if(!e.length)return X(`div`,{class:`card wf-stage-card`,children:[X(`div`,{class:`card-head`,children:X(`div`,{children:X(`h2`,{class:`card-title`,children:`Per stage`})})}),X(Ht,{title:`No stage data yet`,detail:`Stage timing and failures appear here once workflows have run.`})]});let t=Math.max(...e.map(e=>e.avg_ms||0),1),n=[...e].sort((e,t)=>(t.avg_ms||0)-(e.avg_ms||0)),r=[...e].filter(e=>e.errors>0).sort((e,t)=>t.errors-e.errors);return X(`div`,{class:`grid grid-2 wf-stage-card`,children:[X(`div`,{class:`card`,children:[X(`div`,{class:`card-head`,children:X(`div`,{children:[X(`h2`,{class:`card-title`,children:`Slowest stages`}),X(`p`,{class:`card-sub`,children:`Average duration, this workflow's stages`})]})}),X(`div`,{class:`table-scroll`,children:X(`table`,{class:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Workflow`}),X(`th`,{children:`Stage`}),X(`th`,{children:`Runs`}),X(`th`,{children:`Avg duration`})]})}),X(`tbody`,{children:n.map((e,n)=>X(`tr`,{children:[X(`td`,{children:zt(e.workflow)}),X(`td`,{class:`strong`,children:e.stage}),X(`td`,{children:e.runs}),X(`td`,{children:[X(`div`,{class:`wf-rate`,children:Vt(e.avg_ms)}),X(Ut,{fraction:Bt(e.avg_ms,t),kind:`info`})]})]},n))})]})})]}),X(`div`,{class:`card`,children:[X(`div`,{class:`card-head`,children:X(`div`,{children:[X(`h2`,{class:`card-title`,children:`Most failures`}),X(`p`,{class:`card-sub`,children:`Stages that error out, over their runs`})]})}),r.length?X(`div`,{class:`table-scroll`,children:X(`table`,{class:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Workflow`}),X(`th`,{children:`Stage`}),X(`th`,{children:`Failures`})]})}),X(`tbody`,{children:r.map((e,t)=>X(`tr`,{children:[X(`td`,{children:zt(e.workflow)}),X(`td`,{class:`strong`,children:e.stage}),X(`td`,{children:[X(`div`,{class:`wf-rate`,children:[e.errors,` of `,e.runs]}),X(Ut,{fraction:Bt(e.errors,e.runs),kind:`danger`})]})]},t))})]})}):X(Ht,{title:`No failures recorded`,detail:`Every stage has completed cleanly so far.`})]})]})}function Yt({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}function Xt({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Zt(e,t){return e===`running`?`ok`:e===`failed`||e===`degraded`?`warn`:`idle`}function Qt(){let[e,t]=q([]),[n,r]=q(null),i=async()=>{try{let e=await a.channels();t(e?.channels||[]),r(null)}catch(e){r(String(e.message||e))}};return J(()=>{i()},[]),X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Channels`}),X(`p`,{className:`page-sub`,children:`The conversational front-ends Archie can be reached through.`})]}),X(`div`,{className:`page-actions`,children:X(`button`,{className:`btn`,onClick:i,children:`Refresh`})})]}),X(`div`,{className:`grid grid-2`,children:n?X(Xt,{title:`Cannot reach archied`,detail:n}):e.length===0?X(Xt,{title:`No channels configured`,detail:`Configure [chat.telegram] or [chat.webhook_addr] in config.toml to talk to Archie outside the dashboard.`}):e.map(e=>X(`div`,{className:`card channel-card`,children:[X(`div`,{className:`card-head`,children:[X(`h3`,{className:`card-title`,children:e.name}),X(Yt,{text:e.state||(e.configured?`configured`:`stopped`),kind:Zt(e.state,e.configured)})]}),X(`p`,{className:`channel-desc`,children:e.description}),X(`p`,{className:`channel-detail`,children:e.detail}),e.reload_supported?X(`button`,{className:`btn`,onClick:async t=>{t.currentTarget.disabled=!0;try{await a.channelReload(e.id||e.name.toLowerCase()),await i()}catch{}finally{t.currentTarget&&(t.currentTarget.disabled=!1)}},children:`Reload`}):X(`p`,{className:`channel-detail`,children:`Reload requires a daemon restart for this adapter.`})]},e.id||e.name))})]})}function $t(e){return X(Qt,{query:e})}function en({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}function tn({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function nn(e){return X(rn,{query:e})}function rn({query:e}){let[t,n]=q([]),[r,i]=q(null),o=async()=>{try{let e=await a.curators();n(e?.curators||[]),i(null)}catch(e){i(String(e.message||e))}};return J(()=>{o()},[]),X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Curators`}),X(`p`,{className:`page-sub`,children:`Background agents that maintain memory and skills: what ran, and why.`})]}),X(`div`,{className:`page-actions`,children:X(`button`,{className:`btn`,onClick:o,children:`Refresh`})})]}),X(`div`,{className:`grid grid-2`,children:r?X(tn,{title:`Cannot reach archied`,detail:r}):t.length?t.map(e=>X(on,{curator:e},e.name)):X(tn,{title:`No curators registered`,detail:`Curators are background agent loops that maintain memory and skills. None are registered on this daemon.`})})]})}function an(e){switch(e){case`healthy`:return`ok`;case`degraded`:return`warn`;case`unhealthy`:return`danger`;default:return`idle`}}function on({curator:e}){let t=e.recent_actions||[];return X(`div`,{className:`card curator-card`,children:[X(`div`,{className:`card-head`,children:[X(`h3`,{className:`card-title`,children:e.name}),X(en,{text:e.health?.status||`unknown`,kind:an(e.health?.status)})]}),e.health?.message&&X(`p`,{className:`curator-health-message`,children:e.health.message}),X(`p`,{className:`curator-meta`,children:e.last_run_at?`Last ran ${S(e.last_run_at)} · ${e.last_run_actions} action${e.last_run_actions===1?``:`s`}`:`Has not run yet`}),t.length?X(`ul`,{className:`curator-actions`,children:t.map((e,t)=>X(`li`,{className:`curator-action`,children:[X(`div`,{className:`curator-action-head`,children:[X(`span`,{className:`curator-action-type`,children:e.type||`action`}),X(`span`,{className:`curator-action-time`,children:S(e.at)})]}),e.detail&&X(`p`,{className:`curator-action-detail`,children:e.detail}),e.reason&&X(`p`,{className:`curator-action-reason`,children:[`Why: `,e.reason]})]},t))}):X(`p`,{className:`curator-meta`,children:`No recorded activity yet.`})]})}function sn(e){return e==null||e===``?`—`:String(e)}function cn({label:e,value:t,opts:n}){let r=sn(t),[i,o]=q(!1),[s,c]=q(``),[l,u]=q(null),[d,f]=q(!1),[p,m]=q(!1),h=n?.key;if(!h)return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,title:n?.hint,children:e}),X(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let g=n.locked?.[h];if(g)return X(`div`,{className:`kv is-locked`,children:[X(`span`,{className:`kv-label`,title:n.hint,children:e}),X(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),X(`span`,{className:`kv-note`,children:g})]});if(n.editable===!1)return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,title:n.hint,children:e}),X(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let _=n.overridden?.includes(h),v=()=>{c(String(n.raw??``)),u(null),o(!0)},y=async()=>{m(!0),u(null);try{await a.configReset(h),n.onSaved?.()}catch(e){u(String(e.message||e))}finally{m(!1)}},b=async()=>{let e=ln(n.type,s);if(e.error){u(e.error);return}f(!0),u(null);try{await(n.save||(e=>a.configUpdate({[h]:e})))(e.value),o(!1),n.onSaved?.()}catch(e){u(String(e.message||e))}finally{f(!1)}};if(i){let t=Y(null);J(()=>{t.current&&t.current.focus()},[]);let r=e=>{e.key===`Enter`&&(e.preventDefault(),b()),e.key===`Escape`&&o(!1)},i;return i=n.type===`bool`?X(`select`,{className:`kv-input`,value:s,onChange:e=>c(e.target.value),onKeyDown:r,ref:t,children:[X(`option`,{value:`true`,children:`true`}),X(`option`,{value:`false`,children:`false`})]}):n.type===`enum`?X(`select`,{className:`kv-input`,value:s,onChange:e=>c(e.target.value),onKeyDown:r,ref:t,children:(n.options||[]).map(e=>X(`option`,{value:e,children:e},e))}):X(`input`,{className:`kv-input`,type:`text`,value:s,onInput:e=>c(e.target.value),onKeyDown:r,ref:t}),X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,title:n.hint,children:e}),i,X(`div`,{className:`kv-actions`,children:[X(`button`,{className:`kv-save`,type:`button`,onClick:b,disabled:d,children:`Save`}),X(`button`,{className:`kv-cancel`,type:`button`,onClick:()=>o(!1),disabled:d,children:`Cancel`})]}),l&&X(`span`,{className:`kv-note is-error`,children:l})]})}return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,title:n.hint,children:e}),X(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),X(`div`,{className:`kv-actions`,children:[_&&X(`span`,{className:`kv-flag`,title:`Set from the dashboard; this shadows the value in the config file`,children:`overridden`}),X(`button`,{className:`kv-btn`,type:`button`,title:`Edit ${e}`,onClick:v,children:`Edit`}),_&&X(`button`,{className:`kv-btn`,type:`button`,title:`Discard the dashboard value and fall back to the config file`,onClick:y,disabled:p,children:`Reset`})]}),l&&X(`span`,{className:`kv-note is-error`,children:l})]})}function ln(e,t){switch(e){case`int`:{let e=parseInt(t,10);return Number.isNaN(e)?{error:`Enter a whole number`}:{value:e}}case`bool`:return{value:t===`true`};default:return{value:t}}}function un({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}function dn({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function fn({sub:e,title:t,children:n}){return X(`div`,{className:`card cfg-section`,children:[X(`div`,{className:`card-head`,children:X(`div`,{children:[X(`h2`,{className:`card-title`,children:t||`Update status`}),X(`p`,{className:`card-sub`,children:e})]})}),n]})}var pn={ok:`OK`,update_available:`Update available`,drift:`Drift`,unknown:`Unknown`},mn={ok:`ok`,update_available:`info`,drift:`danger`,unknown:`idle`};function hn({components:e}){return!e||!e.length?X(fn,{sub:`How each component is deployed, and whether what's running matches what's installed.`,children:X(dn,{title:`No components reported`,detail:`The configured update-check command returned nothing.`})}):X(fn,{sub:`How each component is deployed, and whether what's running matches what's installed. Hover a row for the exact versions compared.`,children:X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Component`}),X(`th`,{children:`Install type`}),X(`th`,{children:`Running`}),X(`th`,{children:`Latest available`}),X(`th`,{children:`Status`})]})}),X(`tbody`,{children:e.map(e=>X(`tr`,{title:[`Installed claim: ${e.installed_claim||`unknown`}`,`Running: ${e.running_version||`not observed`}`,e.reference?`Reference: ${e.reference}`:null].filter(Boolean).join(` +`),children:[X(`td`,{className:`strong`,children:e.label||e.id}),X(`td`,{className:`mono`,children:e.install_type||`—`}),X(`td`,{className:`mono`,children:e.running_version||`—`}),X(`td`,{className:`mono`,children:e.latest_available||`—`}),X(`td`,{children:X(un,{text:pn[e.status]||e.status,kind:mn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function gn({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}function Q({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function $({title:e,sub:t,children:n}){return X(`div`,{className:`card cfg-section`,children:[X(`div`,{className:`card-head`,children:X(`div`,{children:[X(`h2`,{className:`card-title`,children:e}),X(`p`,{className:`card-sub`,children:t})]})}),n]})}function _n({origins:e}){return e?.length?X($,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:X(`div`,{className:`kv-list`,children:e.map((e,t)=>X(cn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):X($,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:X(Q,{title:`Source provenance is unavailable.`})})}function vn(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function yn({data:e,error:t}){if(t)return X($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:X(Q,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return X($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[X(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?X(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??m(e.id),n=e.kind??h(e.id);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(gn,{text:t,kind:n})})]},e.id)})}):X(Q,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),X(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?X(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=vn(e.kind);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):X(Q,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function bn({r:e,field:t,onSaved:n}){let[r,i]=q(!1),[o,s]=q(null),[c,l]=q(!!e[t]);return X(`td`,{children:[X(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let o=r.target.checked;l(o),i(!0),s(null);try{await a.configRepoUpdate(e.owner,e.name,t,o),n?.()}catch(e){l(!o),s(String(e.message||e))}finally{i(!1)}},disabled:r}),o&&X(`span`,{className:`kv-note is-error`,children:o})]})}function xn({r:e,field:t,onSaved:n}){let[r,i]=q(String(e[t]??0)),[o,s]=q(null),[c,l]=q(!1);return X(`td`,{children:[X(`input`,{className:`kv-input`,type:`text`,value:r,onChange:e=>i(e.target.value),onBlur:async()=>{let i=parseInt(r,10);if(Number.isNaN(i)){s(`Enter a whole number`);return}l(!0),s(null);try{await a.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){s(String(e.message||e))}finally{l(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:c}),o&&X(`span`,{className:`kv-note is-error`,children:o})]})}function Sn({repos:e,onSaved:t}){if(!e?.length)return X($,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:X(Q,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let n=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return X($,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Repository`}),X(`th`,{children:`Base branch`}),X(`th`,{children:`Ecosystem`}),X(`th`,{children:`Quality gate`}),X(`th`,{children:`Protected paths`}),X(`th`,{children:`Concurrent`}),X(`th`,{children:`Max retries`}),X(`th`,{children:`Self-review`})]})}),X(`tbody`,{children:e.map((e,r)=>X(`tr`,{children:[X(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),X(`td`,{className:`mono`,children:e.base}),X(`td`,{children:e.ecosystem||`go`}),X(`td`,{className:`mono`,children:n(e.gate)}),X(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),X(bn,{r:e,field:`allow_concurrent`,onSaved:t}),X(xn,{r:e,field:`max_retries`,onSaved:t}),X(bn,{r:e,field:`review_enabled`,onSaved:t})]},r))})]})})})}function Cn(e){return e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown role`}function wn({models:e,providers:t}){let n=Object.entries(e||{}),r=Object.entries(t||{});return X($,{title:`Models & providers`,sub:`Which model handles each stage of work, and which LLM providers are wired up. Only the environment variable NAME is shown, never its value.`,children:[X(`h3`,{className:`cfg-subhead`,children:`Model roles`}),n.length?X(`div`,{className:`kv-list`,children:n.map(([e,t])=>X(cn,{label:Cn(e),value:t},e))}):X(Q,{title:`No model roles configured`,detail:`Assign a model to at least one role (e.g. "builder") in [models].`}),X(`h3`,{className:`cfg-subhead`,children:`Providers`}),r.length?X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Provider`}),X(`th`,{children:`Class`}),X(`th`,{children:`Base URL`}),X(`th`,{children:`API key env var`}),X(`th`,{children:`Status`})]})}),X(`tbody`,{children:r.map(([e,t])=>X(`tr`,{children:[X(`td`,{className:`strong`,children:e}),X(`td`,{children:t.class}),X(`td`,{className:`mono`,children:t.base_url||`default`}),X(`td`,{className:`mono`,children:t.api_key_env||`—`}),X(`td`,{children:t.configured?X(gn,{text:`configured`,kind:`ok`}):X(gn,{text:`missing credentials`,kind:`warn`})})]},e))})]})}):X(Q,{title:`No providers configured`,detail:`Add a [providers.] entry so a model role above has something to run on.`})]})}function Tn(){let[e,t]=q(null),[n,r]=q(null),[i,o]=q(null),[s,c]=q(null),[l,u]=q(!1),[d,f]=q(null),[p,m]=q(null),h=()=>{g(),_(),v()},g=async()=>{try{let e=await a.config();t(e),r(null)}catch(e){r(String(e.message||e))}},_=async()=>{try{let e=await a.version();o(e?.components||[]),c(null),u(!1)}catch(e){e?.status===501?u(!0):c(String(e.message||e))}},v=async()=>{try{let e=await a.taskMeta();f(e),m(null)}catch(e){m(String(e.message||e))}};return J(()=>{h()},[]),X(`div`,{className:`cfg-page`,children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Configuration`}),X(`p`,{className:`page-sub`,children:`What archied is actually running with right now.`})]}),X(`div`,{className:`page-actions`,children:X(`button`,{className:`btn`,onClick:h,children:`Refresh`})})]}),X(`div`,{children:!l&&(s?X(`div`,{className:`card`,children:X(Q,{title:`Update status unavailable`,detail:s})}):i?X(hn,{components:i}):null)}),X(`div`,{children:X(yn,{data:d,error:p})}),X(`div`,{children:n?X(`div`,{className:`card`,children:X(Q,{title:`Cannot reach archied`,detail:n})}):!e||Object.keys(e).length===0?X(`div`,{className:`card`,children:X(Q,{title:`No configuration loaded`,detail:`archied is running without a config file wired into the dashboard, so there is nothing to show.`})}):X(V,{children:[e.reload?.overlay_unavailable&&X(`div`,{className:`card cfg-notice`,children:X(`p`,{children:[`The runtime config overlay is not in effect: `,e.reload.overlay_unavailable]})}),e.reload?.last_error&&X(`div`,{className:`card cfg-notice`,children:X(`p`,{children:[`The last config reload failed; the running config is unchanged: `,e.reload.last_error]})}),(e.schema||[]).map((t,n)=>{let r=t.fields.filter(e=>e.type!==`structured`);return r.length?X($,{title:t.label,sub:t.description,children:X(`div`,{className:`kv-list`,children:r.map(t=>X(cn,{label:t.label,value:t.value,opts:{key:t.key,type:t.type,options:t.options,raw:t.value,hint:t.description,editable:t.editable,locked:e.locked||{},overridden:e.overridden||[],onSaved:g}},t.key))})},n):null}),X(Sn,{repos:e.repositories,onSaved:g}),X(wn,{models:e.models,providers:e.providers}),X(_n,{origins:e.provenance})]})})]})}function En(e){return X(Tn,{query:e})}function Dn({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}function On({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function kn(e){switch((e||``).toUpperCase()){case`ERROR`:return`danger`;case`WARN`:return`warn`;case`DEBUG`:return`idle`;default:return`info`}}function An(e){return e==null?``:typeof e==`object`?JSON.stringify(e):e}function jn(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`--:--:--`:t.toTimeString().slice(0,8)}function Mn({entry:e}){let t=e.fields||{};return X(`div`,{className:`log-row log-${kn(e.level)}`,children:[X(`span`,{className:`log-time mono`,children:jn(e.time)}),X(`span`,{className:`log-level`,children:(e.level||`info`).toUpperCase()}),X(`span`,{className:`log-body`,children:[X(`span`,{className:`log-msg`,children:e.message||e.msg||``}),Object.entries(t).map(([e,t])=>X(`span`,{className:`log-field`,children:[X(`span`,{className:`log-field-key`,children:e}),String(An(t))]},e))]})]})}var Nn=[{value:``,label:`All levels`},{value:`ERROR`,label:`Errors`},{value:`WARN,ERROR`,label:`Warnings and errors`},{value:`INFO,WARN,ERROR`,label:`Info and above`},{value:`DEBUG`,label:`Debug only`}];function Pn(e){return`${e.time||``}|${e.level||``}|${e.message||e.msg||``}|${JSON.stringify(e.fields||{})}`}function Fn(){let[e,t]=q({level:``,component:``,q:``}),[n,r]=q(!1),[i,o]=q([]),[c,l]=q([]),u=Y(new Map),[d,f]=q(0),[p,m]=q(!1),[h,g]=q(`connecting`),[_,v]=q(`Refreshing…`),y=Y(null),b=Y(null),x=async()=>{v(`Refreshing…`);try{let t=await a.logs({level:e.level,component:e.component,q:e.q,limit:500});o(e=>{let n=t.components||[];return e.length===n.length&&e.every((e,t)=>e===n[t])?e:n}),m(!!t.disabled);let n=t.disabled?`Durable history unavailable; live daemon logs continue.`:t.truncated?`showing the most recent matches from ${t.file}`:t.file||``;v(n),l(t.entries||[])}catch{v(`Cannot read logs`)}};J(()=>{x()},[e]),J(()=>{let e=s(e=>{if(S.current)return;let t=e;w.current(t)&&(u.current.set(Pn(t),t),t.fields?.component&&o(e=>e.includes(t.fields.component)?e:[...e,t.fields.component]),f(e=>e+1))},e=>{g(e)});return()=>e()},[]);let S=Y(n);S.current=n;let C=t=>{if(e.level&&!e.level.split(`,`).includes((t.level||``).toUpperCase())||e.component&&t.fields?.component!==e.component)return!1;if(e.q){let n=e.q.toLowerCase();if(!`${t.message||t.msg||``} ${JSON.stringify(t.fields||{})}`.toLowerCase().includes(n))return!1}return!0},w=Y(C);w.current=C;let T=ze(()=>{let e=new Map;for(let t of c)e.set(Pn(t),t);for(let[t,n]of u.current)e.set(t,n);return[...e.values()].filter(C).slice(-1e3)},[c,d,e]);return J(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},[T]),X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Logs`}),X(`p`,{className:`page-sub`,children:`What Archie has been doing, newest last.`})]}),X(`div`,{className:`page-actions`,children:[X(`button`,{className:`btn ${n?`btn-primary`:``}`,onClick:()=>r(!n),children:n?`Resume`:`Pause`}),X(`button`,{className:`btn`,onClick:x,children:`Refresh`})]})]}),X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:[X(`div`,{className:`log-filters`,children:[X(`select`,{className:`log-select`,value:e.level,onChange:e=>t(t=>({...t,level:e.target.value})),children:Nn.map(e=>X(`option`,{value:e.value,children:e.label},e.value))}),X(`select`,{className:`log-select`,value:e.component,onChange:e=>t(t=>({...t,component:e.target.value})),children:[X(`option`,{value:``,children:`All components`}),i.map(e=>X(`option`,{value:e,children:e},e))]}),X(`input`,{className:`log-search`,type:`search`,placeholder:`Search messages and fields…`,onInput:e=>{let n=e.target.value;b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{t(e=>({...e,q:n}))},250)}})]}),X(`div`,{className:`log-status`,children:[X(`span`,{className:`log-meta`,children:_}),X(Dn,{text:h,kind:h===`live`?`ok`:`warn`})]})]}),X(`div`,{className:`log-list`,ref:y,children:_===`Cannot read logs`?X(On,{title:`Cannot read logs`}):T.length?T.map(e=>X(Mn,{entry:e},Pn(e))):X(On,{title:p?`Durable history unavailable`:`Nothing matches`,detail:p?`Live daemon logs will appear here while this page is open.`:`Try a wider level or clear the search.`})})]})]})}function In(e){return X(Fn,{query:e})}function Ln({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}function Rn({capture:e,expanded:t,onToggle:n}){return X(V,{children:[X(`tr`,{className:`capture-row`,tabIndex:`0`,"aria-expanded":String(t),onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e))},children:[X(`td`,{className:`mono`,children:e.source||`(unknown)`}),X(`td`,{title:e.received_at||``,children:S(e.received_at)}),X(`td`,{children:X(Ln,{text:`Unbound`,kind:`idle`})}),X(`td`,{className:`mono`,children:e.content_type||`—`}),X(`td`,{children:X(`button`,{className:`btn btn-small`,type:`button`,children:t?`Hide`:`View`})})]}),t&&X(zn,{capture:e})]})}function zn({capture:e}){return X(`tr`,{className:`capture-detail-row`,children:X(`td`,{colSpan:`5`,children:X(`div`,{className:`capture-detail`,children:[X(`div`,{className:`capture-detail-section`,children:[X(`div`,{className:`capture-detail-title`,children:`Payload`}),X(Bn,{raw:e.body})]}),X(`div`,{className:`capture-detail-section`,children:[X(`div`,{className:`capture-detail-title`,children:`Headers`}),X(Bn,{raw:e.headers})]})]})})})}function Bn({raw:e}){return e?X(`pre`,{className:`capture-payload`,children:Vn(e)}):X(`div`,{className:`capture-empty`,children:`(empty)`})}function Vn(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Hn({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Un(e){return X(Wn,{query:e})}function Wn({query:e}){let[t,n]=q([]),[r,i]=q(null),[s,c]=q(null),[l,u]=q(!0),[d,f]=q({text:`connecting`,kind:`idle`}),p=async()=>{try{let e=await a.captures(100);u(e.enabled!==!1),n(e.captures||[]),c(null)}catch(e){c(String(e.message||e))}};return J(()=>{p();let e=o(e=>{e.kind===`capture`&&p()},e=>{f({text:e,kind:e===`live`?`ok`:`warn`})});return()=>e()},[]),X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Event inspector`}),X(`p`,{className:`page-sub`,children:`Real inbound payloads archie has captured, most recent first.`})]}),X(`div`,{className:`page-actions`,children:[X(Ln,{text:d.text,kind:d.kind}),X(`button`,{className:`btn`,onClick:p,children:`Refresh`})]})]}),X(`div`,{className:`card`,children:s?X(Hn,{title:`Cannot reach archied`,detail:s}):l?t.length?X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[`Source`,`Received`,`Binding`,`Content type`,``].map((e,t)=>X(`th`,{children:e},t))})}),X(`tbody`,{children:t.map(e=>X(Rn,{capture:e,expanded:r===e.id,onToggle:()=>i(r===e.id?null:e.id)},e.id))})]})}):X(Hn,{title:`No captures yet`,detail:`Point a webhook at /webhooks/capture/ and it will show up here.`}):X(Hn,{title:`Capture is not configured`,detail:`This deployment has no capture storage wired up.`})})]})}function Gn({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}var Kn=[`string`,`number`,`bool`,`object`,`array`,`any`];function qn(e){if(e==null)return`any`;if(Array.isArray(e))return`array`;switch(typeof e){case`string`:return`string`;case`number`:return`number`;case`boolean`:return`bool`;case`object`:return`object`;default:return`any`}}function Jn(e,t){return e?`${e}.${t}`:t}function Yn(e,t){return`${e}[${t}]`}function Xn({value:e,path:t=``,name:n=``,onPick:r}){return typeof e==`object`&&e?X(`ul`,{className:`mapping-tree-list`,children:(Array.isArray(e)?e.map((e,n)=>[String(n),e,Yn(t,n)]):Object.entries(e).map(([e,n])=>[e,n,Jn(t,e)])).map(([e,t,n])=>X(`li`,{className:`mapping-tree-item`,children:[X(`span`,{className:`mapping-tree-key`,onClick:i=>{i.stopPropagation(),r&&r({path:n,type:qn(t),name:e})},children:e}),X(Xn,{value:t,path:n,name:e,onPick:r})]},n))}):X(`span`,{className:`mapping-tree-value`,onClick:i=>{i.stopPropagation(),r&&r({path:t,type:qn(e),name:n})},children:JSON.stringify(e)})}function Zn({fields:e,preview:t,onRemove:n,onNameChange:r,onTypeChange:i,onRequiredChange:a}){if(!e.length)return X(`div`,{className:`mapping-empty-fields`,children:`Click a value in the payload to bind a field.`});let o=new Map((t?.failures||[]).map(e=>[e.field_name,e]));return X(`table`,{className:`table mapping-fields-table`,children:[X(`thead`,{children:X(`tr`,{children:[`Field name`,`Path`,`Type`,`Required`,`Preview`,``].map((e,t)=>X(`th`,{children:e},t))})}),X(`tbody`,{children:e.map((e,s)=>X(`tr`,{children:[X(`td`,{children:X(`input`,{className:`mapping-input`,value:e.name,onInput:e=>r?.(s,e.target.value)})}),X(`td`,{className:`mono`,children:e.path}),X(`td`,{children:X(`select`,{className:`mapping-select`,value:e.type,onChange:e=>i?.(s,e.target.value),children:Kn.map(e=>X(`option`,{value:e,children:e},e))})}),X(`td`,{children:X(`input`,{type:`checkbox`,checked:e.required,onChange:e=>a?.(s,e.target.checked)})}),X(`td`,{children:X(Qn,{field:e,preview:t,failureByField:o})}),X(`td`,{children:X(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(s),children:`Remove`})})]},s))})]})}function Qn({field:e,preview:t,failureByField:n}){if(!t)return X(Gn,{text:`not previewed`,kind:`idle`});let r=n.get(e.name);return r?X(Gn,{text:r.reason,kind:`danger`}):Object.prototype.hasOwnProperty.call(t.values||{},e.name)?X(Gn,{text:JSON.stringify(t.values[e.name]),kind:`ok`}):X(Gn,{text:`skipped (optional)`,kind:`idle`})}function $n({mapping:e,onEdit:t,onDelete:n}){return X(`tr`,{children:[X(`td`,{children:e.name}),X(`td`,{className:`mono`,children:e.source_hint||`—`}),X(`td`,{children:String(e.fields?.length??0)}),X(`td`,{children:[X(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>t?.(e),children:`Edit`}),X(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(e),children:`Delete`})]})]})}function er({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function tr(e){return X(nr,{query:e})}function nr({query:e}){let[t,n]=q([]),[r,i]=q([]),[o,s]=q(null),[c,l]=q(null),u=async()=>{try{let[e,t]=await Promise.all([a.mappings(),a.captures(100)]);n(e.mappings||[]),i(t.captures||[]),s(null)}catch(e){s(String(e.message||e))}};J(()=>{u()},[]);let d=()=>{l({id:null,name:``,sourceHint:``,fields:[],captureId:null,payload:null,payloadError:null,preview:null,actionError:null})},f=e=>{l({id:e.id,name:e.name,sourceHint:e.source_hint||``,fields:(e.fields||[]).map(e=>({...e})),captureId:null,payload:null,payloadError:null,preview:null,actionError:null})},p=async e=>{if(window.confirm(`Delete mapping "${e.name}"?`))try{await a.mappingDelete(e.id),await u()}catch(e){s(String(e.message||e))}},m=e=>{let t=r.find(t=>String(t.id)===String(e));l(e=>{let n={...e,captureId:t?t.id:null,preview:null};if(!t)n.payload=null,n.payloadError=null;else try{n.payload=JSON.parse(t.body),n.payloadError=null}catch{n.payload=null,n.payloadError=`This capture's body is not valid JSON, so its fields cannot be mapped by path.`}return n})},h=({path:e,type:t,name:n})=>{l(r=>{let i=new Set(r.fields.map(e=>e.name)),a=n||`field`,o=1;for(;i.has(a);)a=`${n||`field`}_${++o}`;let s=[...r.fields,{name:a,path:e,type:t,required:!0}];return{...r,fields:s,preview:null}})},g=e=>{l(t=>{let n=t.fields.slice();return n.splice(e,1),{...t,fields:n,preview:null}})},_=(e,t)=>{l(n=>{let r=n.fields.slice();return r[e]={...r[e],...t},{...n,fields:r,preview:null}})};return c?X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:X(`h1`,{className:`page-title`,children:c.id?`Edit mapping`:`New mapping`})}),X(`div`,{className:`page-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:()=>{l(null)},children:`Cancel`}),X(`button`,{className:`btn btn-primary`,type:`button`,onClick:async()=>{let e={name:c.name,source_hint:c.sourceHint,fields:c.fields};try{c.id?await a.mappingUpdate(c.id,e):await a.mappingCreate(e),l(null),await u()}catch(e){l(t=>({...t,actionError:String(e.message||e)}))}},children:`Save`})]})]}),c.actionError&&X(`div`,{className:`mapping-error`,children:c.actionError}),X(`div`,{className:`card mapping-form`,children:[X(`label`,{className:`mapping-form-row`,children:[`Name`,X(`input`,{className:`mapping-input`,value:c.name,onInput:e=>l(t=>({...t,name:e.target.value}))})]}),X(`label`,{className:`mapping-form-row`,children:[`Source hint (organisational only)`,X(`input`,{className:`mapping-input`,value:c.sourceHint,onInput:e=>l(t=>({...t,sourceHint:e.target.value}))})]}),X(`label`,{className:`mapping-form-row`,children:[`Preview against captured event`,X(`select`,{className:`mapping-select`,value:c.captureId||``,onChange:e=>m(e.target.value),children:[X(`option`,{value:``,children:`— pick a captured event —`}),r.map(e=>X(`option`,{value:e.id,children:[e.source||`(unknown)`,` — `,e.received_at||``]},e.id))]})]})]}),X(`div`,{className:`card mapping-fields`,children:[X(`div`,{className:`mapping-section-title`,children:`Bound fields`}),X(Zn,{fields:c.fields,preview:c.preview,onRemove:g,onNameChange:(e,t)=>_(e,{name:t}),onTypeChange:(e,t)=>_(e,{type:t}),onRequiredChange:(e,t)=>_(e,{required:t})}),X(`button`,{className:`btn`,type:`button`,onClick:async()=>{if(!c.captureId){l(e=>({...e,actionError:`Pick a captured event to preview against.`}));return}try{let e=await a.mappingPreview(c.captureId,c.fields);l(t=>({...t,preview:e,actionError:null}))}catch(e){l(t=>({...t,actionError:String(e.message||e)}))}},children:`Preview`})]}),X(`div`,{className:`card mapping-payload`,children:[X(`div`,{className:`mapping-section-title`,children:`Payload — click a value to bind it`}),c.payloadError?X(`div`,{className:`mapping-error`,children:c.payloadError}):c.payload===null?X(`div`,{className:`mapping-empty-fields`,children:`Pick a captured event above to see its payload.`}):X(Xn,{value:c.payload,onPick:h})]})]}):X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Field mappings`}),X(`p`,{className:`page-sub`,children:`Bind named fields to JSON paths from a real captured event, ready for a playbook binding.`})]}),X(`div`,{className:`page-actions`,children:X(`button`,{className:`btn btn-primary`,type:`button`,onClick:d,children:`New mapping`})})]}),o?X(er,{title:`Cannot reach archied`,detail:o}):t.length?X(`div`,{className:`card`,children:X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[`Name`,`Source hint`,`Fields`,``].map((e,t)=>X(`th`,{children:e},t))})}),X(`tbody`,{children:t.map(e=>X($n,{mapping:e,onEdit:()=>f(e),onDelete:()=>p(e)},e.id))})]})})}):X(er,{title:`No mappings yet`,detail:`Create one from a captured event to reuse fields in a future playbook binding.`})]})}function rr({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}function ir({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function ar(e){return e===`external`?`Added by you — an external store Archie was given`:`Built in — always available to Archie`}function or({provider:e}){let t=e.tools||[];return X(`div`,{className:`card`,children:[X(`div`,{className:`card-head`,children:[X(`div`,{children:[X(`h2`,{className:`card-title`,children:e.name||`provider`}),X(`p`,{className:`card-sub`,children:ar(e.role)})]}),e.available?X(rr,{text:`ready`,kind:`ok`}):X(rr,{text:`unavailable`,kind:`danger`})]}),!e.available&&X(`p`,{className:`mem-warning`,children:`Configured but not usable right now — a required binary or connection may be missing.`}),t.length?X(`ul`,{className:`mem-tools`,children:t.map((e,t)=>X(`li`,{className:`mem-tool`,children:[X(`div`,{className:`mem-tool-name mono`,children:e.name}),e.description&&X(`div`,{className:`mem-tool-desc`,children:e.description})]},t))}):X(`p`,{className:`mem-warning`,children:`This provider exposes no tools, so the agent cannot use it.`})]})}function sr(){let[e,t]=q(null),[n,r]=q(!0),[i,o]=q(null),[s,c]=q(!0),l=async()=>{c(!0),o(null);try{let e=await a.memory();r(!!e.enabled),t(e.providers||[])}catch(e){o(String(e.message||e))}finally{c(!1)}};return J(()=>{l()},[]),X(`div`,{children:[X(`div`,{className:`page-head`,children:[X(`div`,{children:[X(`h1`,{className:`page-title`,children:`Memory`}),X(`p`,{className:`page-sub`,children:`What Archie can recall between conversations, and the tools it uses to do it.`})]}),X(`div`,{className:`page-actions`,children:X(`button`,{className:`btn`,onClick:l,children:`Refresh`})})]}),X(`div`,{children:s?X(`div`,{className:`card`,children:X(`div`,{className:`mem-loading`,children:`Loading…`})}):i?X(`div`,{className:`card`,children:X(ir,{title:`Cannot read memory providers`,detail:i})}):!n||!e.length?X(`div`,{className:`card`,children:X(ir,{title:`Memory is not configured`,detail:`Without a provider, Archie starts every conversation with no recollection of earlier ones.`})}):X(`div`,{className:`grid grid-2`,children:e.map((e,t)=>X(or,{provider:e},t))})})]})}function cr(e){return X(sr,{query:e})}function lr(e){let t=document.createDocumentFragment(),n=/(!\[[^\]]*\]\((?:https?:\/\/[^\s)]+|data:image\/[^\s)]+|\/[^\s)]+)\)|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|`[^`]+`|\[[^\]]+\]\((?:https?:\/\/[^\s)]+|\/[^\s)]+)\)|\*[^*]+\*|_[^_]+_)/g,r=0;for(let i of e.matchAll(n)){i.index>r&&t.append(document.createTextNode(e.slice(r,i.index)));let n=i[0];if(n.startsWith(`![`)){let e=n.match(/^!\[([^\]]*)\]\((.+)\)$/);e&&t.append(y(`img.chat-media-img`,{src:e[2],alt:e[1]||`Image`,loading:`lazy`}))}else if(n.startsWith(`~~`))t.append(y(`del`,n.slice(2,-2)));else if(n.startsWith(`**`)||n.startsWith(`__`))t.append(y(`strong`,n.slice(2,-2)));else if(n.startsWith("`"))t.append(y(`code`,n.slice(1,-1)));else if(n.startsWith(`[`)){let e=n.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+|\/[^\s)]+)\)$/);t.append(y(`a`,{href:e[2],target:`_blank`,rel:`noreferrer`},e[1]))}else t.append(y(`em`,n.slice(1,-1)));r=i.index+n.length}return r{r.length&&(t.append(y(`p`,lr(r.join(` `)))),r=[])},s=()=>{i&&t.append(i),i=null};for(let e=0;ey(`td`,lr(e)))));t.append(y(`table`,y(`thead`,y(`tr`,...l.map(e=>y(`th`,lr(e))))),i));continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.append(y(`h${d[1].length}`,lr(d[2])));continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tagName.toLowerCase()!==e)&&(s(),i=y(e)),i.append(y(`li`,lr((f||p)[1])));continue}if(c.startsWith(`>`)){o(),s(),t.append(y(`blockquote`,lr(c.replace(/^>\s?/,``))));continue}r.push(c)}return o(),s(),a&&t.append(y(`pre`,y(`code`,a.join(` +`)))),t}function dr(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function fr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var pr=`archie.web.chat.channel`;function mr(){let t=localStorage.getItem(pr);return t||(t=e(),localStorage.setItem(pr,t)),t}function hr(t){return{text:t,sourceID:e()}}function gr(e){return{...e}}function _r(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?gr(e.turn):hr(r),isRetry:n}}function vr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function yr(e){return e?.status===501?null:`Could not check for updates.`}function br(){return location.hash.slice(1)||`/`}function xr({text:e}){let t=Y(null);return J(()=>{t.current&&t.current.replaceChildren(ur(e||``))},[e]),X(`div`,{ref:t,style:{display:`contents`}})}function Sr(){let[e,t]=q([]),[n,r]=q(``),[i,o]=q([]),[s,c]=q(``),[l,u]=q(`Ready`),[d,f]=q(!1),[p,m]=q({}),[h,g]=q(``),[_,v]=q(``),[y,b]=q(``),[x,S]=q([]),[C,w]=q([]),[T,E]=q(0),[D,O]=q(!1),[k,A]=q(null),[j,M]=q(null),[N,ee]=q(null),[P,te]=q(``),[ne,re]=q(``),[F,I]=q(null),L=Y(null),R=Y(null),z=Y(null),B=Y(null),ie=Y(null),ae=Y(d);ae.current=d,J(()=>{L.current&&(L.current.scrollTop=L.current.scrollHeight)},[i,F]),J(()=>{U().catch(e=>{u(e.message||`Chat unavailable`)}),oe();let e=()=>{z.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),z.current?.abort()}},[]);async function oe(){try{let e=await a.chatUpdate();M(e?.snapshot||null),A(e)}catch(e){let t=yr(e);A(t?{error:t}:null)}}async function se(){if(j)try{await a.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),u(`Update deferred`)}catch(e){u(e.message||`Could not defer update`)}}async function H(){if(j)try{u(`Installing…`);let e=await a.chatUpdateInstall(j);M(null),A({snapshot:{},available:[]}),u(e?.result?.restart_requested?`Update installed; restart queued`:`Update complete`)}catch(e){u(e.message||`Update install failed`)}}async function ce(){try{let e=await a.chatDangerous();ee(e)}catch(e){ee({error:e.message||`Dangerous actions unavailable`})}}async function le(e,t){if(t)try{await a.chatDangerousRequest(e,t),u(`Approval requested`),await ce()}catch(e){u(e.message||`Could not request action`)}}async function ue(e,t){try{await a.chatDangerousDecision(e,t),u(t===`deny`?`Action denied`:`Action approved`),await ce()}catch(e){u(e.message||`Approval failed`)}}async function U(){let e=await a.chatSessions(),r=e.sessions||[];t(r),m(e),g(e.active_persona||``);let i=e.providers||[],o=e.active_provider||i[0]||``;v(o),b(e.active_model||``);let s=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);S(s),e.dangerous_available&&await ce(),!n&&r[0]&&await de(r[0].session_id,e,r)}async function de(e,t,n){let i=t||p;r(e),o([]),I(null);let s=i.active_personas?.[e]||i.active_persona||``;g(s);try{await a.chatMessage(mr(),`/resume ${e}`);let[t,n]=await Promise.all([a.chatMessages(e),a.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});o(i)}catch(e){u(e.message||`Could not load session messages`)}}async function fe(e){if(n)try{u(`Working…`);let t=await a.chatMessage(mr(),e);t.session_id&&r(t.session_id),u(t.reply||`Session updated`),await U(),(t.session_id||n)&&await de(t.session_id||n),B.current&&(B.current.open=!1)}catch(e){u(e.message||`Session action failed`)}}function pe(e,t){let n=window.prompt(t);n?.trim()&&fe(`${e} ${n.trim()}`)}function me(e){let t=e.target.value;g(t),!(!n||!t)&&a.chatPersona(n,t).then(()=>{m(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),u(`Personality: ${t}`)}).catch(e=>{u(e.message||`Failed to set personality`)})}async function he(e){let t=e.target.value;if(v(t),t)try{let e=await a.chatMessage(mr(),`/model --provider ${t}`);u(e.reply||`Provider updated`),await U()}catch(e){u(`Provider update failed: ${e.message||e}`)}}async function ge(e){let t=e.target.value;if(b(t),t)try{let e=await a.chatMessage(mr(),`/model ${t}`);u(e.reply||`Model updated`),await U()}catch(e){u(`Model update failed: ${e.message||e}`)}}function _e(){window.confirm(`Reload the Telegram chat adapter?`)&&(c(`/restart`),W({textOverride:`/restart`}))}function ve(){c(`/new`),W({textOverride:`/new`})}function ye(e){let t=e.target.value;c(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=x.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function be(e){let t=C[e];if(!t||!R.current)return;let n=R.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.search(/(?:^|\s)\/[^\s]*$/),o=a<0?r.length:a+ +(r[a]===` `),s=`${r.slice(0,o)}${t.command} ${i}`;c(s),O(!1);let l=o+t.command.length+1;setTimeout(()=>{n.focus(),n.setSelectionRange(l,l)},0)}function xe(e){if(D&&C.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&C.some(e=>e.command===s.trim())){e.preventDefault(),O(!1),W();return}if(e.key===`ArrowDown`){e.preventDefault(),E(e=>(e+1)%C.length);return}if(e.key===`ArrowUp`){e.preventDefault(),E(e=>(e+C.length-1)%C.length);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),be(T);return}if(e.key===`Escape`){e.preventDefault(),O(!1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),W())}async function W(e=null){let t=e?.textOverride,{text:n,turn:i,isRetry:a}=_r(e,t===void 0?s:t);if(!n||ae.current)return;O(!1),f(!0),u(a?`Retrying…`:`Thinking…`),a||(o(e=>[...e,{from:`web`,text:n}]),c(``));let l=[];I({text:``,tools:[],isError:!1,turn:i,isRetry:a});let d=``,p=!1,m=!1,h=null;try{let e=new AbortController;z.current=e,h=setTimeout(()=>{m=!0,e.abort()},12e4);let t=await fetch(`/api/chat/stream`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`text/event-stream`},body:JSON.stringify({channel_id:mr(),source_id:i.sourceID,text:i.text,page:br()}),signal:e.signal});if(!t.ok)throw Error(await t.text()||`${t.status} ${t.statusText}`);let n=t.body.getReader(),a=new TextDecoder,s=``;for(;;){let{value:e,done:t}=await n.read();s+=a.decode(e||new Uint8Array,{stream:!t});let i=s.split(` `);s=i.pop()||``;for(let e of i){let t=e.split(` -`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&r(n.session_id),n.type===`delta`&&(d+=n.text,L(e=>e?{...e,text:d}:null)),n.type===`tool`&&(l=[...l,n],L(e=>e?{...e,tools:l}:null)),n.type===`navigate`&&(l=[...l,n],L(e=>e?{...e,tools:l}:null)),n.type===`done`&&(p=!0,d||=n.text),n.type===`error`)throw Error(n.text)}if(t)break}if(!p)throw Error(`chat stream ended before completion`);o(e=>[...e,{from:`assistant`,text:d,tool_calls:l}]),L(null),u(`Ready`),await ue()}catch(e){if(e.name===`AbortError`&&!m)L({text:`Turn stopped.`,tools:l,isError:!1,turn:i,isRetry:a}),u(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;L({text:t,tools:l,isError:!0,turn:sr(i),isRetry:a}),u(`Error — retry available`)}}finally{clearTimeout(h),B.current=null,f(!1),z.current&&z.current.focus()}}function xe(){u(`Stopping…`),n&&a.chatCancel(n).catch(()=>{}),B.current?.abort()}let Se=p.models_by_provider||{},Ce=_&&Se[_]?Se[_]:p.models||[];return Z(`div`,{className:`chat-page-content`,children:[Z(`header`,{className:`chat-topbar`,children:[Z(`div`,{children:[Z(`span`,{className:`chat-kicker`,children:`ARCHIE WORKSPACE`}),Z(`h1`,{className:`page-title`,children:`Chat`})]}),Z(`div`,{className:`chat-topbar-actions`,children:[Z(`span`,{className:`chat-status`,children:l}),p.restart_available&&Z(`button`,{className:`btn`,type:`button`,onClick:ge,children:`Reload Telegram`}),Z(`button`,{className:`btn`,type:`button`,onClick:ae,children:`Check updates`}),Z(`select`,{className:`chat-select`,"aria-label":`Personality`,value:h,onChange:pe,children:[Z(`option`,{value:``,children:`Personality`}),(p.personas||[]).map(e=>Z(`option`,{value:e,children:e},e))]}),(p.providers||[]).length>0&&Z(`select`,{className:`chat-select`,"aria-label":`Provider`,value:_,onChange:me,children:[Z(`option`,{value:``,children:`Provider`}),(p.providers||[]).map(e=>Z(`option`,{value:e,children:e},e))]}),Z(`select`,{className:`chat-select`,"aria-label":`Model`,value:y,onChange:he,children:[Z(`option`,{value:``,children:`Model`}),Ce.map(e=>Z(`option`,{value:e,children:e},e))]})]})]}),k&&Z(`div`,{className:`chat-update-panel`,children:k.error?Z(`span`,{children:k.error}):k.available?.length?Z(H,{children:[Z(`div`,{children:[Z(`strong`,{children:`Update available`}),Z(`span`,{children:k.available.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)})]}),Z(`div`,{className:`chat-update-actions`,children:[Z(`button`,{className:`btn`,type:`button`,onClick:oe,children:`Defer`}),k.can_install&&Z(`button`,{className:`btn btn-primary`,type:`button`,onClick:se,children:`Install update`})]})]}):Z(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),p.dangerous_available&&N&&Z(`div`,{className:`chat-dangerous-panel`,children:[Z(`div`,{className:`chat-dangerous-head`,children:[Z(`strong`,{children:`Dangerous actions`}),Z(`span`,{className:`chat-hint`,children:`Every action requires approval.`})]}),Z(`div`,{className:`chat-dangerous-controls`,children:[Z(`div`,{children:[Z(`select`,{className:`chat-select`,"aria-label":`Checkpoint`,value:P,onChange:e=>te(e.target.value),children:[Z(`option`,{value:``,children:`Select checkpoint`}),(N.checkpoints||[]).map(e=>Z(`option`,{value:e.Number??e.number,children:[e.Number??e.number,` — `,e.Label??e.label??`checkpoint`]},e.Number??e.number))]}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>U(`rollback`,P),children:`Request rollback`})]}),Z(`div`,{children:[Z(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:F,onInput:e=>ne(e.target.value)}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>U(`stop`,F),children:`Request stop`})]})]}),Z(`div`,{className:`chat-dangerous-pending-list`,children:(N.pending||[]).length?N.pending.map(e=>Z(`div`,{className:`chat-dangerous-pending`,children:[Z(`span`,{children:e.description}),Z(`div`,{className:`chat-update-actions`,children:[Z(`button`,{className:`btn`,type:`button`,onClick:()=>le(e.id,`approve`),children:`Approve`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>le(e.id,`permanent`),children:`Approve for 24h`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>le(e.id,`deny`),children:`Deny`})]})]},e.id)):Z(`span`,{className:`chat-hint`,children:`No pending dangerous actions.`})})]}),Z(`div`,{className:`chat-layout`,children:[Z(`aside`,{className:`chat-sidebar`,children:[Z(`div`,{className:`chat-sidebar-head`,children:[Z(`strong`,{children:`Conversations`}),Z(`button`,{className:`btn btn-primary`,type:`button`,onClick:_e,children:`+ New chat`})]}),Z(`div`,{className:`chat-session-list`,children:e.length?e.map(e=>Z(`button`,{className:`chat-session ${n===e.session_id?`active`:``}`,type:`button`,onClick:()=>de(e.session_id),children:[Z(`strong`,{children:lr(e)}),Z(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):Z(`div`,{className:`chat-empty`,children:`Your conversations will appear here.`})})]}),Z(`section`,{className:`chat-workspace`,children:[Z(`div`,{className:`chat-workspace-head`,children:[Z(`span`,{className:`chat-workspace-label`,children:`PERSONAL ASSISTANT`}),Z(`details`,{className:`chat-command-help`,children:[Z(`summary`,{children:[`Available commands (`,x.length,`)`]}),Z(`div`,{className:`chat-command-list`,children:x.length?x.map(e=>Z(`div`,{className:`chat-command-item`,children:[Z(`code`,{children:e.usage||e.command}),Z(`span`,{children:e.description||``})]},e.command)):Z(`span`,{children:`Send a message to begin.`})})]}),Z(`details`,{className:`chat-session-tools`,ref:re,hidden:!n,children:[Z(`summary`,{children:`Session actions`}),Z(`div`,{className:`chat-session-tool-list`,children:[Z(`button`,{className:`btn`,type:`button`,onClick:()=>W(`/retry`),children:`Retry`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>W(`/undo`),children:`Undo`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>fe(`/title`,`Session title`),children:`Rename`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>fe(`/branch`,`Branch name (optional)`),children:`Branch`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>W(`/compress --preview`),children:`Preview compression`})]})]})]}),Z(`div`,{className:`chat-transcript`,ref:R,children:!i.length&&!I?Z(`div`,{className:`chat-empty-state`,children:[Z(`span`,{className:`chat-empty-mark`,children:`A`}),Z(`h2`,{children:`What are we working on?`}),Z(`p`,{children:`Ask Archie anything, or start with one of these prompts.`}),Z(`div`,{className:`chat-prompt-grid`,children:[Z(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Summarise active tasks`),z.current?.focus()},children:`Summarise active tasks`}),Z(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Show running agents`),z.current?.focus()},children:`Show running agents`}),Z(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Check system status`),z.current?.focus()},children:`Check system status`})]})]}):Z(H,{children:[i.map((e,t)=>{let n=e.from??e.From??``,r=e.text??e.Text??``,i=n!==`web`,a=e.tool_calls||e.ToolCalls||[];return Z(`div`,{className:`chat-bubble-row ${i?`assistant`:`user`}`,children:Z(`div`,{className:`chat-bubble`,children:[Z(`div`,{className:`chat-bubble-meta`,children:i?`Archie`:`You`}),i?Z(H,{children:[a.length>0&&Z(`div`,{className:`chat-tools`,children:a.map((e,t)=>{if(e.path)return Z(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[Z(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),Z(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.Name||e.tool||`tool`,r=e.parameters||e.Parameters||``,i=e.summary||e.Summary||e.text||e.err||e.Err||`done`;return Z(`div`,{className:`chat-tool ${e.err||e.Err||e.failed?`failed`:``}`,children:[Z(`span`,{className:`chat-tool-icon`,children:`🔧`}),Z(`span`,{className:`chat-tool-name`,children:n}),r&&Z(`code`,{className:`chat-tool-parameters`,children:r}),Z(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),Z(fr,{text:r})]}):Z(`div`,{className:`chat-bubble-text`,children:r})]})},t)}),I&&Z(`div`,{className:`chat-bubble-row assistant`,children:Z(`div`,{className:`chat-bubble`,children:[Z(`div`,{className:`chat-bubble-meta`,children:`Archie`}),I.tools?.length>0&&Z(`div`,{className:`chat-tools`,children:I.tools.map((e,t)=>{if(e.path)return Z(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[Z(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),Z(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.tool||`tool`,r=e.parameters||``,i=e.summary||e.text||(e.failed?`failed`:`running…`);return Z(`div`,{className:`chat-tool ${e.failed?`failed`:``}`,children:[Z(`span`,{className:`chat-tool-icon`,children:`🔧`}),Z(`span`,{className:`chat-tool-name`,children:n}),r&&Z(`code`,{className:`chat-tool-parameters`,children:r}),Z(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),Z(fr,{text:I.text||`…`}),I.isError&&Z(`button`,{className:`btn chat-retry`,type:`button`,onClick:()=>G({turn:I.turn}),children:`Retry`})]})})]})}),Z(`div`,{className:`chat-compose`,children:Z(`div`,{className:`chat-composer-shell`,children:[Z(`textarea`,{ref:z,className:`chat-composer`,rows:3,placeholder:`Message Archie… (commands like /status and /new work here)`,"aria-label":`Message Archie`,disabled:d,value:s,onInput:ve,onKeyDown:be}),D&&C.length>0&&Z(`div`,{className:`chat-command-menu`,ref:ie,role:`listbox`,"aria-label":`Commands`,children:C.map((e,t)=>Z(`button`,{type:`button`,role:`option`,"aria-selected":String(t===T),className:`chat-command-option`,onMouseDown:e=>e.preventDefault(),onClick:()=>ye(t),children:[Z(`code`,{children:e.command}),Z(`span`,{children:e.description||e.usage||``})]},e.command))}),Z(`div`,{className:`chat-compose-actions`,children:[Z(`span`,{className:`chat-hint`,children:`Enter to send · Shift+Enter for a new line`}),Z(`button`,{className:`btn`,type:`button`,disabled:!d,onClick:xe,children:`Stop`}),Z(`button`,{className:`btn btn-primary`,type:`button`,disabled:d||!s.trim(),onClick:()=>G(),children:`Send`})]})]})})]})]})]})}function mr(){let e=document.createElement(`div`);return e.className=`chat-page`,Ee(Z(pr,{}),e),e}var hr=[{path:`/`,label:`Dashboard`,icon:`dashboard`,view:ht},{path:`/chat`,label:`Chat`,icon:`chat`,view:mr},{path:`/tasks`,label:`Tasks`,icon:`tasks`,view:Ft},{path:`/logs`,label:`Logs`,icon:`logs`,view:Nn},{path:`/captures`,label:`Event inspector`,icon:`captures`,view:Rn},{path:`/mappings`,label:`Field mappings`,icon:`mappings`,view:qn},{path:`/skills`,label:`Skills`,icon:`skills`,view:Rt},{path:`/workflows`,label:`Workflows`,icon:`workflows`,view:Kt},{path:`/memory`,label:`Memory`,icon:`memory`,view:$n},{path:`/curators`,label:`Curators`,icon:`curators`,view:nn},{path:`/channels`,label:`Channels`,icon:`channels`,view:tn},{path:`/settings`,label:`Configuration`,icon:`settings`,view:Cn}],gr=`archie.theme`;function _r(e){document.documentElement.dataset.theme=e,localStorage.setItem(gr,e)}function vr(){return localStorage.getItem(gr)||`dark`}function yr(e,t){let n=new Map,r=y(`nav.nav`,...[null].flatMap(()=>[...hr.map(t=>{let r=y(`a.nav-item`,{href:`#${t.path}`,onclick:n=>{t.soon?n.preventDefault():e(t.path)},"aria-disabled":t.soon||void 0,title:t.soon?`Coming soon`:void 0},D(t.icon),y(`span.nav-label`,t.label),t.soon&&y(`span.nav-soon`,`soon`));return n.set(t.path,r),r})])),i=y(`button.icon-btn`,{title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onclick:()=>{_r(vr()===`dark`?`light`:`dark`),x(i,D(vr()===`dark`?`moon`:`sun`))}});x(i,D(vr()===`dark`?`moon`:`sun`));let a,o=()=>{a?.classList.remove(`is-open`),s.setAttribute(`aria-expanded`,`false`)},s=y(`button.icon-btn.mobile-search-toggle`,{type:`button`,"aria-label":`Open Jump to navigation`,"aria-expanded":`false`,onclick:()=>{a.classList.add(`is-open`),s.setAttribute(`aria-expanded`,`true`),c.focus()}},D(`search`,{size:15})),c=y(`input`,{type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onkeydown:t=>{if(t.key===`Escape`){t.preventDefault(),o(),t.target.blur();return}if(t.key!==`Enter`)return;let n=t.target.value.trim().toLowerCase(),r=hr.find(e=>!e.soon&&e.label.toLowerCase().startsWith(n));r&&(e(r.path),t.target.value=``,t.target.blur(),o())}});return a=y(`div.topbar-search`,y(`span.topbar-search-icon`,{"aria-hidden":`true`},D(`search`,{size:15})),s,c),{node:y(`header.topbar`,y(`div.brand`,y(`span.brand-mark`,`A`),`Archie`),r,y(`div.topbar-end`,a,y(`button.icon-btn.icon-btn-chat`,{"aria-label":`Open chat`,title:`Chat with Archie`,"aria-expanded":`false`,onclick:()=>t?.()},D(`chat`)),y(`button.icon-btn`,{title:`Documentation`,"aria-label":`Documentation`},D(`help`)),i,y(`div.avatar`,{title:`Signed in locally`},`A`))),highlight(e){for(let[t,r]of n)t===e?r.setAttribute(`aria-current`,`page`):r.removeAttribute(`aria-current`)}}}function br(){_r(vr());let e=y(`main.main`),t=y(`aside.chat-drawer`,{"aria-label":`Chat with Archie`}),n=y(`button.icon-btn.chat-drawer-close`,{"aria-label":`Close chat`,title:`Close chat`,onclick:()=>o(!1)},D(`close`)),r=y(`div.chat-drawer-head`,y(`strong`,`Archie`),n);t.append(y(`div.chat-drawer-panel`,r,mr()),y(`div.chat-scrim`,{onclick:()=>o(!1)}));let i=yr(s,()=>o()),a=y(`div.shell`,i.node,e,t);x(document.getElementById(`app`),a);function o(e){let n=e===void 0?!t.classList.contains(`is-open`):e;t.classList.toggle(`is-open`,n),document.body.classList.toggle(`chat-open`,n);let r=a.querySelector(`.icon-btn-chat`);r&&r.setAttribute(`aria-expanded`,String(n))}window.__archieToggleChat=o;function s(e){location.hash===`#`+e?c(e):location.hash=e}function c(t){e.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`));let[n,r=``]=t.split(`?`,2),a=hr.find(e=>e.path===n)||hr[0];if(i.highlight(a.path),a.path===`/chat`){x(e),o(!0);return}x(e,a.view?a.view(new URLSearchParams(r)):xr(a)),o(!1)}window.addEventListener(`hashchange`,()=>c(location.hash.slice(1)||`/`)),window.addEventListener(`keydown`,e=>{e.defaultPrevented||e.key===`Escape`&&t.classList.contains(`is-open`)&&o(!1)}),c(location.hash.slice(1)||`/`)}function xr(e){return y(`div`,y(`div.page-head`,y(`div`,y(`h1.page-title`,e.label))),y(`div.card`,y(`div.empty`,y(`div.empty-title`,`${e.label} is not built yet`),y(`div`,`This section is next up. Nothing is broken.`))))}br(); \ No newline at end of file +`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&r(n.session_id),n.type===`delta`&&(d+=n.text,I(e=>e?{...e,text:d}:null)),n.type===`tool`&&(l=[...l,n],I(e=>e?{...e,tools:l}:null)),n.type===`navigate`&&(l=[...l,n],I(e=>e?{...e,tools:l}:null)),n.type===`done`&&(p=!0,d||=n.text),n.type===`error`)throw Error(n.text)}if(t)break}if(!p)throw Error(`chat stream ended before completion`);o(e=>[...e,{from:`assistant`,text:d,tool_calls:l}]),I(null),u(`Ready`),await U()}catch(e){if(e.name===`AbortError`&&!m)I({text:`Turn stopped.`,tools:l,isError:!1,turn:i,isRetry:a}),u(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;I({text:t,tools:l,isError:!0,turn:gr(i),isRetry:a}),u(`Error — retry available`)}}finally{clearTimeout(h),z.current=null,f(!1),R.current&&R.current.focus()}}function Se(){u(`Stopping…`),n&&a.chatCancel(n).catch(()=>{}),z.current?.abort()}let Ce=p.models_by_provider||{},we=_&&Ce[_]?Ce[_]:p.models||[];return X(`div`,{className:`chat-page-content`,children:[X(`header`,{className:`chat-topbar`,children:[X(`div`,{children:[X(`span`,{className:`chat-kicker`,children:`ARCHIE WORKSPACE`}),X(`h1`,{className:`page-title`,children:`Chat`})]}),X(`div`,{className:`chat-topbar-actions`,children:[X(`span`,{className:`chat-status`,children:l}),p.restart_available&&X(`button`,{className:`btn`,type:`button`,onClick:_e,children:`Reload Telegram`}),X(`button`,{className:`btn`,type:`button`,onClick:oe,children:`Check updates`}),X(`select`,{className:`chat-select`,"aria-label":`Personality`,value:h,onChange:me,children:[X(`option`,{value:``,children:`Personality`}),(p.personas||[]).map(e=>X(`option`,{value:e,children:e},e))]}),(p.providers||[]).length>0&&X(`select`,{className:`chat-select`,"aria-label":`Provider`,value:_,onChange:he,children:[X(`option`,{value:``,children:`Provider`}),(p.providers||[]).map(e=>X(`option`,{value:e,children:e},e))]}),X(`select`,{className:`chat-select`,"aria-label":`Model`,value:y,onChange:ge,children:[X(`option`,{value:``,children:`Model`}),we.map(e=>X(`option`,{value:e,children:e},e))]})]})]}),k&&X(`div`,{className:`chat-update-panel`,children:k.error?X(`span`,{children:k.error}):k.available?.length?X(V,{children:[X(`div`,{children:[X(`strong`,{children:`Update available`}),X(`span`,{children:k.available.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)})]}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:se,children:`Defer`}),k.can_install&&X(`button`,{className:`btn btn-primary`,type:`button`,onClick:H,children:`Install update`})]})]}):X(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),p.dangerous_available&&N&&X(`div`,{className:`chat-dangerous-panel`,children:[X(`div`,{className:`chat-dangerous-head`,children:[X(`strong`,{children:`Dangerous actions`}),X(`span`,{className:`chat-hint`,children:`Every action requires approval.`})]}),X(`div`,{className:`chat-dangerous-controls`,children:[X(`div`,{children:[X(`select`,{className:`chat-select`,"aria-label":`Checkpoint`,value:P,onChange:e=>te(e.target.value),children:[X(`option`,{value:``,children:`Select checkpoint`}),(N.checkpoints||[]).map(e=>X(`option`,{value:e.Number??e.number,children:[e.Number??e.number,` — `,e.Label??e.label??`checkpoint`]},e.Number??e.number))]}),X(`button`,{className:`btn`,type:`button`,onClick:()=>le(`rollback`,P),children:`Request rollback`})]}),X(`div`,{children:[X(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:ne,onInput:e=>re(e.target.value)}),X(`button`,{className:`btn`,type:`button`,onClick:()=>le(`stop`,ne),children:`Request stop`})]})]}),X(`div`,{className:`chat-dangerous-pending-list`,children:(N.pending||[]).length?N.pending.map(e=>X(`div`,{className:`chat-dangerous-pending`,children:[X(`span`,{children:e.description}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:()=>ue(e.id,`approve`),children:`Approve`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ue(e.id,`permanent`),children:`Approve for 24h`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ue(e.id,`deny`),children:`Deny`})]})]},e.id)):X(`span`,{className:`chat-hint`,children:`No pending dangerous actions.`})})]}),X(`div`,{className:`chat-layout`,children:[X(`aside`,{className:`chat-sidebar`,children:[X(`div`,{className:`chat-sidebar-head`,children:[X(`strong`,{children:`Conversations`}),X(`button`,{className:`btn btn-primary`,type:`button`,onClick:ve,children:`+ New chat`})]}),X(`div`,{className:`chat-session-list`,children:e.length?e.map(e=>X(`button`,{className:`chat-session ${n===e.session_id?`active`:``}`,type:`button`,onClick:()=>de(e.session_id),children:[X(`strong`,{children:vr(e)}),X(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):X(`div`,{className:`chat-empty`,children:`Your conversations will appear here.`})})]}),X(`section`,{className:`chat-workspace`,children:[X(`div`,{className:`chat-workspace-head`,children:[X(`span`,{className:`chat-workspace-label`,children:`PERSONAL ASSISTANT`}),X(`details`,{className:`chat-command-help`,children:[X(`summary`,{children:[`Available commands (`,x.length,`)`]}),X(`div`,{className:`chat-command-list`,children:x.length?x.map(e=>X(`div`,{className:`chat-command-item`,children:[X(`code`,{children:e.usage||e.command}),X(`span`,{children:e.description||``})]},e.command)):X(`span`,{children:`Send a message to begin.`})})]}),X(`details`,{className:`chat-session-tools`,ref:B,hidden:!n,children:[X(`summary`,{children:`Session actions`}),X(`div`,{className:`chat-session-tool-list`,children:[X(`button`,{className:`btn`,type:`button`,onClick:()=>fe(`/retry`),children:`Retry`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>fe(`/undo`),children:`Undo`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>pe(`/title`,`Session title`),children:`Rename`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>pe(`/branch`,`Branch name (optional)`),children:`Branch`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>fe(`/compress --preview`),children:`Preview compression`})]})]})]}),X(`div`,{className:`chat-transcript`,ref:L,children:!i.length&&!F?X(`div`,{className:`chat-empty-state`,children:[X(`span`,{className:`chat-empty-mark`,children:`A`}),X(`h2`,{children:`What are we working on?`}),X(`p`,{children:`Ask Archie anything, or start with one of these prompts.`}),X(`div`,{className:`chat-prompt-grid`,children:[X(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Summarise active tasks`),R.current?.focus()},children:`Summarise active tasks`}),X(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Show running agents`),R.current?.focus()},children:`Show running agents`}),X(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Check system status`),R.current?.focus()},children:`Check system status`})]})]}):X(V,{children:[i.map((e,t)=>{let n=e.from??e.From??``,r=e.text??e.Text??``,i=n!==`web`,a=e.tool_calls||e.ToolCalls||[];return X(`div`,{className:`chat-bubble-row ${i?`assistant`:`user`}`,children:X(`div`,{className:`chat-bubble`,children:[X(`div`,{className:`chat-bubble-meta`,children:i?`Archie`:`You`}),i?X(V,{children:[a.length>0&&X(`div`,{className:`chat-tools`,children:a.map((e,t)=>{if(e.path)return X(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[X(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),X(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.Name||e.tool||`tool`,r=e.parameters||e.Parameters||``,i=e.summary||e.Summary||e.text||e.err||e.Err||`done`;return X(`div`,{className:`chat-tool ${e.err||e.Err||e.failed?`failed`:``}`,children:[X(`span`,{className:`chat-tool-icon`,children:`🔧`}),X(`span`,{className:`chat-tool-name`,children:n}),r&&X(`code`,{className:`chat-tool-parameters`,children:r}),X(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),X(xr,{text:r})]}):X(`div`,{className:`chat-bubble-text`,children:r})]})},t)}),F&&X(`div`,{className:`chat-bubble-row assistant`,children:X(`div`,{className:`chat-bubble`,children:[X(`div`,{className:`chat-bubble-meta`,children:`Archie`}),F.tools?.length>0&&X(`div`,{className:`chat-tools`,children:F.tools.map((e,t)=>{if(e.path)return X(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[X(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),X(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.tool||`tool`,r=e.parameters||``,i=e.summary||e.text||(e.failed?`failed`:`running…`);return X(`div`,{className:`chat-tool ${e.failed?`failed`:``}`,children:[X(`span`,{className:`chat-tool-icon`,children:`🔧`}),X(`span`,{className:`chat-tool-name`,children:n}),r&&X(`code`,{className:`chat-tool-parameters`,children:r}),X(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),X(xr,{text:F.text||`…`}),F.isError&&X(`button`,{className:`btn chat-retry`,type:`button`,onClick:()=>W({turn:F.turn}),children:`Retry`})]})})]})}),X(`div`,{className:`chat-compose`,children:X(`div`,{className:`chat-composer-shell`,children:[X(`textarea`,{ref:R,className:`chat-composer`,rows:3,placeholder:`Message Archie… (commands like /status and /new work here)`,"aria-label":`Message Archie`,disabled:d,value:s,onInput:ye,onKeyDown:xe}),D&&C.length>0&&X(`div`,{className:`chat-command-menu`,ref:ie,role:`listbox`,"aria-label":`Commands`,children:C.map((e,t)=>X(`button`,{type:`button`,role:`option`,"aria-selected":String(t===T),className:`chat-command-option`,onMouseDown:e=>e.preventDefault(),onClick:()=>be(t),children:[X(`code`,{children:e.command}),X(`span`,{children:e.description||e.usage||``})]},e.command))}),X(`div`,{className:`chat-compose-actions`,children:[X(`span`,{className:`chat-hint`,children:`Enter to send · Shift+Enter for a new line`}),X(`button`,{className:`btn`,type:`button`,disabled:!d,onClick:Se,children:`Stop`}),X(`button`,{className:`btn btn-primary`,type:`button`,disabled:d||!s.trim(),onClick:()=>W(),children:`Send`})]})]})})]})]})]})}function Cr(){let e=document.createElement(`div`);return e.className=`chat-page`,Te(X(Sr,{}),e),e}var wr=[{path:`/`,label:`Dashboard`,icon:`dashboard`,view:pt},{path:`/chat`,label:`Chat`,icon:`chat`,view:Cr},{path:`/tasks`,label:`Tasks`,icon:`tasks`,view:Nt},{path:`/logs`,label:`Logs`,icon:`logs`,view:In},{path:`/captures`,label:`Event inspector`,icon:`captures`,view:Un},{path:`/mappings`,label:`Field mappings`,icon:`mappings`,view:tr},{path:`/skills`,label:`Skills`,icon:`skills`,view:It},{path:`/workflows`,label:`Workflows`,icon:`workflows`,view:Wt},{path:`/memory`,label:`Memory`,icon:`memory`,view:cr},{path:`/curators`,label:`Curators`,icon:`curators`,view:nn},{path:`/channels`,label:`Channels`,icon:`channels`,view:$t},{path:`/settings`,label:`Configuration`,icon:`settings`,view:En}],Tr=`archie.theme`;function Er(e){document.documentElement.dataset.theme=e,localStorage.setItem(Tr,e)}function Dr(){return localStorage.getItem(Tr)||`dark`}function Or(e,t){let n=new Map,r=y(`nav.nav`,...[null].flatMap(()=>[...wr.map(t=>{let r=y(`a.nav-item`,{href:`#${t.path}`,onclick:n=>{t.soon?n.preventDefault():e(t.path)},"aria-disabled":t.soon||void 0,title:t.soon?`Coming soon`:void 0},T(t.icon),y(`span.nav-label`,t.label),t.soon&&y(`span.nav-soon`,`soon`));return n.set(t.path,r),r})])),i=y(`button.icon-btn`,{title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onclick:()=>{Er(Dr()===`dark`?`light`:`dark`),x(i,T(Dr()===`dark`?`moon`:`sun`))}});x(i,T(Dr()===`dark`?`moon`:`sun`));let a,o=()=>{a?.classList.remove(`is-open`),s.setAttribute(`aria-expanded`,`false`)},s=y(`button.icon-btn.mobile-search-toggle`,{type:`button`,"aria-label":`Open Jump to navigation`,"aria-expanded":`false`,onclick:()=>{a.classList.add(`is-open`),s.setAttribute(`aria-expanded`,`true`),c.focus()}},T(`search`,{size:15})),c=y(`input`,{type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onkeydown:t=>{if(t.key===`Escape`){t.preventDefault(),o(),t.target.blur();return}if(t.key!==`Enter`)return;let n=t.target.value.trim().toLowerCase(),r=wr.find(e=>!e.soon&&e.label.toLowerCase().startsWith(n));r&&(e(r.path),t.target.value=``,t.target.blur(),o())}});return a=y(`div.topbar-search`,y(`span.topbar-search-icon`,{"aria-hidden":`true`},T(`search`,{size:15})),s,c),{node:y(`header.topbar`,y(`div.brand`,y(`span.brand-mark`,`A`),`Archie`),r,y(`div.topbar-end`,a,y(`button.icon-btn.icon-btn-chat`,{"aria-label":`Open chat`,title:`Chat with Archie`,"aria-expanded":`false`,onclick:()=>t?.()},T(`chat`)),y(`button.icon-btn`,{title:`Documentation`,"aria-label":`Documentation`},T(`help`)),i,y(`div.avatar`,{title:`Signed in locally`},`A`))),highlight(e){for(let[t,r]of n)t===e?r.setAttribute(`aria-current`,`page`):r.removeAttribute(`aria-current`)}}}function kr(){Er(Dr());let e=y(`main.main`),t=y(`aside.chat-drawer`,{"aria-label":`Chat with Archie`}),n=y(`button.icon-btn.chat-drawer-close`,{"aria-label":`Close chat`,title:`Close chat`,onclick:()=>o(!1)},T(`close`)),r=y(`div.chat-drawer-head`,y(`strong`,`Archie`),n);t.append(y(`div.chat-drawer-panel`,r,Cr()),y(`div.chat-scrim`,{onclick:()=>o(!1)}));let i=Or(s,()=>o()),a=y(`div.shell`,i.node,e,t);x(document.getElementById(`app`),a);function o(e){let n=e===void 0?!t.classList.contains(`is-open`):e;t.classList.toggle(`is-open`,n),document.body.classList.toggle(`chat-open`,n);let r=a.querySelector(`.icon-btn-chat`);r&&r.setAttribute(`aria-expanded`,String(n))}window.__archieToggleChat=o;function s(e){location.hash===`#`+e?c(e):location.hash=e}function c(t){e.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`));let[n,r=``]=t.split(`?`,2),a=wr.find(e=>e.path===n)||wr[0];if(i.highlight(a.path),a.path===`/chat`){x(e),o(!0);return}x(e,a.view?a.view(new URLSearchParams(r)):Ar(a)),o(!1)}window.addEventListener(`hashchange`,()=>c(location.hash.slice(1)||`/`)),window.addEventListener(`keydown`,e=>{e.defaultPrevented||e.key===`Escape`&&t.classList.contains(`is-open`)&&o(!1)}),c(location.hash.slice(1)||`/`)}function Ar(e){return y(`div`,y(`div.page-head`,y(`div`,y(`h1.page-title`,e.label))),y(`div.card`,y(`div.empty`,y(`div.empty-title`,`${e.label} is not built yet`),y(`div`,`This section is next up. Nothing is broken.`))))}kr(); \ No newline at end of file diff --git a/ui/package-lock.json b/ui/package-lock.json index 076666144..169c239bd 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -10,9 +10,64 @@ }, "devDependencies": { "@preact/preset-vite": "^2.10.0", + "@testing-library/preact": "^3.2.4", + "jsdom": "^30.0.1", "vite": "^8.0.0" } }, + "node_modules/@asamuzakjp/css-color": { + "version": "6.0.7", + "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-6.0.7.tgz", + "integrity": "sha512-vC/bk1Lz7Tn/EfU9/apOTBk80/8dyGyWMowPoV1tJ52muDGsDqt2HPT2klrFUiY60MQmQv9q8yIht15JnBgDGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@csstools/css-calc": "^3.3.0", + "@csstools/css-color-parser": "^4.1.10", + "@csstools/css-parser-algorithms": "^4.0.0", + "@csstools/css-tokenizer": "^4.0.0", + "lru-cache": "^11.5.2" + }, + "engines": { + "node": "^22.13.0 || >=24.0.0" + } + }, + "node_modules/@asamuzakjp/css-color/node_modules/lru-cache": { + "version": "11.5.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", + "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@asamuzakjp/dom-selector": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-8.3.2.tgz", + "integrity": "sha512-93Z1N+BQNXysodoicpOIyNh2drHfz/CTf9nnT0FEx72GJcIiwgydD7tGAr78j41LsYn3hlRn+LdGPuBLn1Bl8Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "bidi-js": "^1.0.3", + "css-tree": "^3.2.1", + "is-potential-custom-element-name": "^1.0.1", + "lru-cache": "^11.5.2" + }, + "engines": { + "node": "^22.13.0 || >=24.0.0" + } + }, + "node_modules/@asamuzakjp/dom-selector/node_modules/lru-cache": { + "version": "11.5.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", + "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, "node_modules/@babel/code-frame": { "version": "7.29.7", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", @@ -280,6 +335,16 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/runtime": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz", + "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/template": { "version": "7.29.7", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", @@ -328,6 +393,177 @@ "node": ">=6.9.0" } }, + "node_modules/@bramus/specificity": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.2.tgz", + "integrity": "sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "css-tree": "^3.0.0" + }, + "bin": { + "specificity": "bin/cli.js" + } + }, + "node_modules/@csstools/color-helpers": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-6.1.1.tgz", + "integrity": "sha512-gLNsunvwf3mCi5u5o46/Z/JcJMnhbHSaZ69rkgPzNM3J4s8hWwpPUQB6/tt0EDFyCiWzxANlx+2LJwpYj4zS1w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/@csstools/css-calc": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.3.0.tgz", + "integrity": "sha512-c5ihYsPkdG6JCkU2zTMm4+k6r7RXuGxtWYhu5DHMIiF1FHzrfmHL5so11AoFpUv/tu61xfcmT4AmKoFfMPoqdQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^4.0.0", + "@csstools/css-tokenizer": "^4.0.0" + } + }, + "node_modules/@csstools/css-color-parser": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-4.2.2.tgz", + "integrity": "sha512-3QKjR/vxyjcSXBLgb6lP0S3MGdvwbmqSsvLPbYdVORqPDc8FX1HAJ0Spk38bxaRXgvENTA47tlhhbb5Z2e8hEg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/color-helpers": "^6.1.1", + "@csstools/css-calc": "^3.3.0" + }, + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^4.0.0", + "@csstools/css-tokenizer": "^4.0.0" + } + }, + "node_modules/@csstools/css-parser-algorithms": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-4.0.0.tgz", + "integrity": "sha512-+B87qS7fIG3L5h3qwJ/IFbjoVoOe/bpOdh9hAjXbvx0o8ImEmUsGXN0inFOnk2ChCFgqkkGFQ+TpM5rbhkKe4w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-tokenizer": "^4.0.0" + } + }, + "node_modules/@csstools/css-syntax-patches-for-csstree": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.12.tgz", + "integrity": "sha512-3vLQK+dXxhBMR2Wx99PTCifE+vHtW2ndZWyla8yK813ev6oGhyn8Lja8jCyGAWTJ+LEYZK7EVtJxrDj8ztevJw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "peerDependencies": { + "css-tree": "^3.2.1" + }, + "peerDependenciesMeta": { + "css-tree": { + "optional": true + } + } + }, + "node_modules/@csstools/css-tokenizer": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-4.0.0.tgz", + "integrity": "sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/@exodus/bytes": { + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/@exodus/bytes/-/bytes-1.15.1.tgz", + "integrity": "sha512-S6mL0yNB/Abt9Ei4tq8gDhcczc4S3+vQ4ra7vxnAf+YHC02srtqxKKZghx2Dq6p0e66THKwR6r8N6P95wEty7Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@noble/hashes": "^1.8.0 || ^2.0.0" + }, + "peerDependenciesMeta": { + "@noble/hashes": { + "optional": true + } + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.13", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", @@ -748,6 +984,49 @@ } } }, + "node_modules/@testing-library/dom": { + "version": "8.20.1", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-8.20.1.tgz", + "integrity": "sha512-/DiOQ5xBxgdYRC8LNk7U+RWat0S3qRLeIw3ZIkMQ9kkVlRmwD/Eg8k8CqIpD6GW7u20JIUOfMKbxtiLutpjQ4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.10.4", + "@babel/runtime": "^7.12.5", + "@types/aria-query": "^5.0.1", + "aria-query": "5.1.3", + "chalk": "^4.1.0", + "dom-accessibility-api": "^0.5.9", + "lz-string": "^1.5.0", + "pretty-format": "^27.0.2" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@testing-library/preact": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@testing-library/preact/-/preact-3.2.4.tgz", + "integrity": "sha512-F+kJ243LP6VmEK1M809unzTE/ijg+bsMNuiRN0JEDIJBELKKDNhdgC/WrUSZ7klwJvtlO3wQZ9ix+jhObG07Fg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@testing-library/dom": "^8.11.1" + }, + "engines": { + "node": ">= 12" + }, + "peerDependencies": { + "preact": ">=10 || ^10.0.0-alpha.0 || ^10.0.0-beta.0" + } + }, + "node_modules/@types/aria-query": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", + "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/estree": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", @@ -755,6 +1034,75 @@ "dev": true, "license": "MIT" }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/aria-query": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz", + "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "deep-equal": "^2.0.5" + } + }, + "node_modules/array-buffer-byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.2.tgz", + "integrity": "sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "is-array-buffer": "^3.0.5" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/available-typed-arrays": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", + "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "possible-typed-array-names": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/babel-plugin-transform-hook-names": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/babel-plugin-transform-hook-names/-/babel-plugin-transform-hook-names-1.0.2.tgz", @@ -778,6 +1126,16 @@ "node": ">=6.0.0" } }, + "node_modules/bidi-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.0.3.tgz", + "integrity": "sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==", + "dev": true, + "license": "MIT", + "dependencies": { + "require-from-string": "^2.0.2" + } + }, "node_modules/boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", @@ -819,6 +1177,56 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/call-bind": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.9.tgz", + "integrity": "sha512-a/hy+pNsFUTR+Iz8TCJvXudKVLAnz/DyeSUo10I5yvFDQJBFU2s9uqQpoSrJlroHUKoKqzg+epxyP9lqFdzfBQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "get-intrinsic": "^1.3.0", + "set-function-length": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/caniuse-lite": { "version": "1.0.30001810", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz", @@ -840,6 +1248,43 @@ ], "license": "CC-BY-4.0" }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", @@ -864,6 +1309,20 @@ "url": "https://github.com/sponsors/fb55" } }, + "node_modules/css-tree": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz", + "integrity": "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "mdn-data": "2.27.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" + } + }, "node_modules/css-what": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.2.2.tgz", @@ -877,6 +1336,35 @@ "url": "https://github.com/sponsors/fb55" } }, + "node_modules/data-urls": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-7.0.0.tgz", + "integrity": "sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^16.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "node_modules/data-urls/node_modules/whatwg-url": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-16.0.1.tgz", + "integrity": "sha512-1to4zXBxmXHV3IiSSEInrreIlu02vUOvrhxJJH5vcxYTBDAx51cqZiKdyTxlecdKNSjj8EcxGBxNf6Vg+945gw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.11.0", + "tr46": "^6.0.0", + "webidl-conversions": "^8.0.1" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, "node_modules/debug": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", @@ -895,6 +1383,82 @@ } } }, + "node_modules/decimal.js": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", + "dev": true, + "license": "MIT" + }, + "node_modules/deep-equal": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.3.tgz", + "integrity": "sha512-ZIwpnevOurS8bpT4192sqAowWM76JDKSHYzMLty3BZGSswgq6pBaH3DhCSW5xVAZICZyKdOBPjwww5wfgT/6PA==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-buffer-byte-length": "^1.0.0", + "call-bind": "^1.0.5", + "es-get-iterator": "^1.1.3", + "get-intrinsic": "^1.2.2", + "is-arguments": "^1.1.1", + "is-array-buffer": "^3.0.2", + "is-date-object": "^1.0.5", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.2", + "isarray": "^2.0.5", + "object-is": "^1.1.5", + "object-keys": "^1.1.1", + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.5.1", + "side-channel": "^1.0.4", + "which-boxed-primitive": "^1.0.2", + "which-collection": "^1.0.1", + "which-typed-array": "^1.1.13" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/detect-libc": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", @@ -905,6 +1469,13 @@ "node": ">=8" } }, + "node_modules/dom-accessibility-api": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", + "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", + "dev": true, + "license": "MIT" + }, "node_modules/dom-serializer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", @@ -964,6 +1535,21 @@ "url": "https://github.com/fb55/domutils?sponsor=1" } }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/electron-to-chromium": { "version": "1.5.420", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.420.tgz", @@ -984,6 +1570,60 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-get-iterator": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz", + "integrity": "sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.3", + "has-symbols": "^1.0.3", + "is-arguments": "^1.1.1", + "is-map": "^2.0.2", + "is-set": "^2.0.2", + "is-string": "^1.0.7", + "isarray": "^2.0.5", + "stop-iteration-iterator": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", @@ -1019,6 +1659,22 @@ } } }, + "node_modules/for-each": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", + "integrity": "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-callable": "^1.2.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -1034,6 +1690,26 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -1044,6 +1720,136 @@ "node": ">=6.9.0" } }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-bigints": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.1.0.tgz", + "integrity": "sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", @@ -1054,6 +1860,289 @@ "he": "bin/he" } }, + "node_modules/html-encoding-sniffer": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-6.0.0.tgz", + "integrity": "sha512-CV9TW3Y3f8/wT0BRFc1/KAVQ3TUHiXmaAb6VW9vtiMFf7SLoMd1PdAc4W3KFOFETBJUb90KatHqlsZMWV+R9Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.6.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "node_modules/internal-slot": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz", + "integrity": "sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "hasown": "^2.0.2", + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-arguments": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.2.0.tgz", + "integrity": "sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-array-buffer": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", + "integrity": "sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-bigint": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.1.0.tgz", + "integrity": "sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-bigints": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-boolean-object": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.2.2.tgz", + "integrity": "sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-date-object": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.1.0.tgz", + "integrity": "sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz", + "integrity": "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-number-object": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.1.1.tgz", + "integrity": "sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-regex": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", + "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-set": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.3.tgz", + "integrity": "sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-shared-array-buffer": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.4.tgz", + "integrity": "sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-string": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.1.1.tgz", + "integrity": "sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-symbol": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.1.1.tgz", + "integrity": "sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-symbols": "^1.1.0", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakmap": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz", + "integrity": "sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakset": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.4.tgz", + "integrity": "sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true, + "license": "MIT" + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -1061,6 +2150,57 @@ "dev": true, "license": "MIT" }, + "node_modules/jsdom": { + "version": "30.0.1", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-30.0.1.tgz", + "integrity": "sha512-52v7mUVUfNQVYYqE1lcdaymWL0njO7lTLUog6ZvW2U5KsbiLk/GnZlVJ+qx0xfNJZ6Gn+KSpPNE52vurbxZwrA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@asamuzakjp/css-color": "^6.0.5", + "@asamuzakjp/dom-selector": "^8.3.0", + "@bramus/specificity": "^2.4.2", + "@csstools/css-syntax-patches-for-csstree": "^1.1.7", + "@exodus/bytes": "^1.15.1", + "css-tree": "^3.2.1", + "data-urls": "^7.0.0", + "decimal.js": "^10.6.0", + "html-encoding-sniffer": "^6.0.0", + "is-potential-custom-element-name": "^1.0.1", + "lru-cache": "^11.5.2", + "parse5": "^8.0.1", + "saxes": "^6.0.0", + "symbol-tree": "^3.2.4", + "tough-cookie": "^6.0.2", + "undici": "^8.9.0", + "w3c-xmlserializer": "^5.0.0", + "webidl-conversions": "^8.0.1", + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^17.1.0", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" + }, + "peerDependencies": { + "canvas": "^3.2.3" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, + "node_modules/jsdom/node_modules/lru-cache": { + "version": "11.5.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", + "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, "node_modules/jsesc": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", @@ -1365,6 +2505,16 @@ "yallist": "^3.0.2" } }, + "node_modules/lz-string": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", + "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", + "dev": true, + "license": "MIT", + "bin": { + "lz-string": "bin/bin.js" + } + }, "node_modules/magic-string": { "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", @@ -1375,6 +2525,23 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mdn-data": { + "version": "2.27.1", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.27.1.tgz", + "integrity": "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==", + "dev": true, + "license": "CC0-1.0" + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -1435,6 +2602,93 @@ "url": "https://github.com/fb55/nth-check?sponsor=1" } }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-is": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.6.tgz", + "integrity": "sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.7.tgz", + "integrity": "sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0", + "has-symbols": "^1.1.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/parse5": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.1.tgz", + "integrity": "sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^8.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5/node_modules/entities": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-8.0.0.tgz", + "integrity": "sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -1455,6 +2709,16 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/possible-typed-array-names": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", + "integrity": "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/postcss": { "version": "8.5.25", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.25.tgz", @@ -1502,6 +2766,82 @@ } } }, + "node_modules/pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", + "dev": true, + "license": "MIT" + }, + "node_modules/regexp.prototype.flags": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz", + "integrity": "sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-errors": "^1.3.0", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "set-function-name": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/rolldown": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.2.tgz", @@ -1535,6 +2875,37 @@ "@rolldown/binding-win32-x64-msvc": "1.2.2" } }, + "node_modules/safe-regex-test": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.1.0.tgz", + "integrity": "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-regex": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/saxes": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "dev": true, + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, "node_modules/semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", @@ -1545,6 +2916,116 @@ "semver": "bin/semver.js" } }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-function-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.2.tgz", + "integrity": "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/side-channel": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/simple-code-frame": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/simple-code-frame/-/simple-code-frame-1.3.0.tgz", @@ -1585,6 +3066,40 @@ "node": ">=20.0.0" } }, + "node_modules/stop-iteration-iterator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz", + "integrity": "sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "internal-slot": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/symbol-tree": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", + "dev": true, + "license": "MIT" + }, "node_modules/tinyglobby": { "version": "0.2.17", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", @@ -1602,6 +3117,62 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, + "node_modules/tldts": { + "version": "7.4.11", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.4.11.tgz", + "integrity": "sha512-aBiNayCfTQxuIJBm06M+xR14cYaYlDlSXZbgsnKzKNxDKUVq7KFwTjwBSsb7m9Y5xO8WfPnBc63WaYFMTGlvqw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tldts-core": "^7.4.11" + }, + "bin": { + "tldts": "bin/cli.js" + } + }, + "node_modules/tldts-core": { + "version": "7.4.11", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.4.11.tgz", + "integrity": "sha512-CW3WN2rIIE/Of21mulhgnGOwoDyEFNygyIBOONSdyAuSATgMMUCpLeUlB+E8sAwA5xRV9hYPl+kyZ9citHCaKg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tough-cookie": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.2.tgz", + "integrity": "sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tldts": "^7.0.5" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/tr46": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-6.0.0.tgz", + "integrity": "sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/undici": { + "version": "8.10.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-8.10.1.tgz", + "integrity": "sha512-YQ3WlbqjYMmNpdvDH64jAgLjxuAR9+649calDWhbshYaeQGO2bR4nI94ORJmwI3J9YhoKQnpyGOK+0zlWS5N5Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22.19.0" + } + }, "node_modules/update-browserslist-db": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz", @@ -1729,6 +3300,132 @@ "vite": "5.x || 6.x || 7.x || 8.x" } }, + "node_modules/w3c-xmlserializer": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", + "integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/webidl-conversions": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz", + "integrity": "sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-mimetype": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-5.0.0.tgz", + "integrity": "sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-url": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-17.1.0.tgz", + "integrity": "sha512-3GeworPmc2ZfEEHP7lEbUfBX/L75wdEsi0rLNhXcXxnoN5jyq0SL5gCy06SGW2cyTIZdTvWIDQNQoza++vKeaw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.15.1", + "tr46": "^6.0.0", + "webidl-conversions": "^8.0.1" + }, + "engines": { + "node": "^22.14.0 || >=24.0.0" + } + }, + "node_modules/which-boxed-primitive": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.1.1.tgz", + "integrity": "sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-bigint": "^1.1.0", + "is-boolean-object": "^1.2.1", + "is-number-object": "^1.1.1", + "is-string": "^1.1.1", + "is-symbol": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-collection": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.2.tgz", + "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-map": "^2.0.3", + "is-set": "^2.0.3", + "is-weakmap": "^2.0.2", + "is-weakset": "^2.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.22", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.22.tgz", + "integrity": "sha512-fvO4ExWMFsqyhG3AiPAObMuY1lxaqgYcxbc49CNdWDDECOJNgQyvsOWVwbZc+qf3rzRtxojBK+CMEv0Ld5CYpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "for-each": "^0.3.5", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", + "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true, + "license": "MIT" + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", diff --git a/ui/package.json b/ui/package.json index 9f3b81448..9fcefaf48 100644 --- a/ui/package.json +++ b/ui/package.json @@ -12,6 +12,8 @@ }, "devDependencies": { "@preact/preset-vite": "^2.10.0", + "@testing-library/preact": "^3.2.4", + "jsdom": "^30.0.1", "vite": "^8.0.0" } } diff --git a/ui/src/tasks/tasks.jsx b/ui/src/tasks/tasks.jsx index feaae1293..c07bde187 100644 --- a/ui/src/tasks/tasks.jsx +++ b/ui/src/tasks/tasks.jsx @@ -1,4 +1,4 @@ -import { h } from "preact"; +import { Fragment } from "preact"; import { useState, useEffect, useRef } from "preact/hooks"; import "./tasks.css"; import { api } from "../base/api.jsx"; @@ -398,7 +398,7 @@ function TasksApp({ query }) { const expanded = expandedId === t.id; const timelineID = `task-timeline-${t.id}`; return ( - + {renderTaskActions(t)} {expanded && renderTimelineRow(t)} - + ); }); }; diff --git a/ui/test/captures.test.js b/ui/test/captures.test.js index 6542336a7..7e6c31816 100644 --- a/ui/test/captures.test.js +++ b/ui/test/captures.test.js @@ -1,7 +1,16 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -import "./shim.js"; -import { captureRow, captureDetailRow, prettyPrint } from "../src/captures/capture-row.js"; +import { h } from "preact"; +import { render, cleanup } from "@testing-library/preact"; +import { CaptureRow, CaptureDetailRow, prettyPrint } from "../src/captures/capture-row.jsx"; + +let container; +const afterRender = (cb) => { + const r = render(cb()); + container = r.container; + return container; +}; +const reset = () => cleanup(); test("prettyPrint indents valid JSON", () => { const out = prettyPrint('{"action":"opened","n":1}'); @@ -12,54 +21,91 @@ test("prettyPrint returns non-JSON payloads unchanged rather than failing", () = assert.equal(prettyPrint("not json"), "not json"); }); +function renderRow(capture, opts = {}) { + afterRender(() => ( + + + + +
+ )); + return container.querySelector("tbody"); +} + test("collapsed capture row renders only the summary row", () => { - const nodes = captureRow( + const tbody = renderRow( { id: 1, source: "github", content_type: "application/json" }, { expanded: false, onToggle: () => {} }, ); - assert.equal(nodes.length, 1); + assert.equal(tbody.children.length, 1); + reset(); }); test("expanded capture row appends a detail row", () => { - const nodes = captureRow( + const tbody = renderRow( { id: 1, source: "github", content_type: "application/json" }, { expanded: true, onToggle: () => {} }, ); - assert.equal(nodes.length, 2); + assert.equal(tbody.children.length, 2); + reset(); }); test("capture row reflects expanded state via aria-expanded", () => { - const [collapsedRow] = captureRow({ id: 1 }, { expanded: false, onToggle: () => {} }); - const [expandedRow] = captureRow({ id: 1 }, { expanded: true, onToggle: () => {} }); - assert.equal(collapsedRow.getAttribute("aria-expanded"), "false"); - assert.equal(expandedRow.getAttribute("aria-expanded"), "true"); + const coll = renderRow({ id: 1 }, { expanded: false, onToggle: () => {} }); + assert.equal(coll.querySelector(".capture-row").getAttribute("aria-expanded"), "false"); + reset(); + const exp = renderRow({ id: 1 }, { expanded: true, onToggle: () => {} }); + assert.equal(exp.querySelector(".capture-row").getAttribute("aria-expanded"), "true"); + reset(); }); test("capture row shows the source and content type", () => { - const [row] = captureRow( + const tbody = renderRow( { id: 1, source: "github", content_type: "application/json" }, { expanded: false, onToggle: () => {} }, ); + const row = tbody.querySelector(".capture-row"); assert.match(row.textContent, /github/); assert.match(row.textContent, /application\/json/); + reset(); }); test("capture row shows an unknown source as a placeholder rather than blank", () => { - const [row] = captureRow({ id: 1 }, { expanded: false, onToggle: () => {} }); + const tbody = renderRow({ id: 1 }, { expanded: false, onToggle: () => {} }); + const row = tbody.querySelector(".capture-row"); assert.match(row.textContent, /\(unknown\)/); + reset(); }); test("every capture row shows Unbound: no binding data model exists yet (t2db.4)", () => { - const [row] = captureRow({ id: 1, source: "github" }, { expanded: false, onToggle: () => {} }); + const tbody = renderRow({ id: 1, source: "github" }, { expanded: false, onToggle: () => {} }); + const row = tbody.querySelector(".capture-row"); assert.match(row.textContent, /Unbound/); + reset(); }); test("capture detail row pretty-prints a JSON payload", () => { - const detail = captureDetailRow({ body: '{"a":1}', headers: "{}" }); + afterRender(() => ( + + + + +
+ )); + const detail = container.querySelector(".capture-detail-row"); assert.match(detail.textContent, /"a": 1/); + reset(); }); test("capture detail row shows a placeholder for an empty payload", () => { - const detail = captureDetailRow({ body: "", headers: "" }); + afterRender(() => ( + + + + +
+ )); + const detail = container.querySelector(".capture-detail-row"); assert.match(detail.textContent, /\(empty\)/); + reset(); }); diff --git a/ui/test/chat-app.test.js b/ui/test/chat-app.test.js index f5f21cbc0..408b48aec 100644 --- a/ui/test/chat-app.test.js +++ b/ui/test/chat-app.test.js @@ -1,33 +1,34 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -import "./shim.js"; -import { h, render } from "preact"; -import { ChatApp, ChatPage, chatPage } from "../src/chat/chat.jsx"; +import { render, cleanup } from "@testing-library/preact"; +import { ChatApp, chatPage } from "../src/chat/chat.jsx"; test("ChatApp renders structure with topbar, sidebar, transcript and composer", () => { - const container = document.createElement("div"); - render(h(ChatApp, null), container); + const { container, unmount } = render(); assert.ok(container.querySelector(".chat-topbar"), "topbar should render"); assert.ok(container.querySelector(".chat-sidebar"), "sidebar should render"); assert.ok(container.querySelector(".chat-transcript"), "transcript should render"); assert.ok(container.querySelector(".chat-composer"), "composer textarea should render"); assert.ok(container.querySelector(".chat-sidebar button"), "+ New chat button should exist"); + unmount(); }); test("ChatApp renders empty state with prompt chips when messages are empty", () => { - const container = document.createElement("div"); - render(h(ChatApp, null), container); + const { container, unmount } = render(); const emptyState = container.querySelector(".chat-empty-state"); assert.ok(emptyState, "empty state should be present"); const prompts = container.querySelectorAll(".chat-prompt"); assert.ok(prompts.length >= 3, "should have prompt buttons"); + unmount(); }); test("chatPage bridge function returns a DOM element containing the ChatApp", () => { + // chatPage() renders a Preact ChatApp into a container and returns that + // container as a real DOM node (used by the chat drawer / router). const node = chatPage(); - assert.ok(node instanceof Element, "chatPage should return an Element"); - assert.equal(node.className, "chat-page"); + assert.ok(node instanceof HTMLElement, "chatPage should return a DOM element"); assert.ok(node.querySelector(".chat-page-content"), "chat-page-content should be inside node"); + cleanup(); }); diff --git a/ui/test/config-row.test.js b/ui/test/config-row.test.js index 101daac14..21c759d61 100644 --- a/ui/test/config-row.test.js +++ b/ui/test/config-row.test.js @@ -1,14 +1,15 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -import "./shim.js"; -import { row, valueText, parseEdit } from "../src/settings/config-row.js"; +import { h } from "preact"; +import { render, cleanup } from "@testing-library/preact"; +import { Row, valueText, parseEdit } from "../src/settings/config-row.jsx"; // Walks a rendered row and returns the concatenated text of each direct // child, so a test can assert on the row's *structure* rather than on a // flattened string. The bugs this file guards against were all cases of // two fields rendering as one visual run. function cells(rowEl) { - return rowEl.childNodes.map((child) => text(child)); + return Array.from(rowEl.childNodes).map((child) => text(child)); } function text(node) { @@ -16,7 +17,18 @@ function text(node) { } function classOf(node) { - return node.className || ""; + return (node && node.className) || ""; +} + +function titleOf(node) { + return node && node.getAttribute ? node.getAttribute("title") : undefined; +} + +// Render a Row component and return its rendered .kv element. +function renderRow(label, value, opts = {}) { + const { container, unmount } = render(); + const el = container.querySelector(".kv"); + return { el, unmount }; } test("a locked row keeps its reason in a separate element from the value", () => { @@ -25,7 +37,7 @@ test("a locked row keeps its reason in a separate element from the value", () => // working layout". Assert on the cell count and per-cell text, never on // the row's flattened text, so a future layout change cannot pass by // merging them back into one node. - const rowEl = row("Work directory", "/home/sam/.local/share/archie/work", { + const { el: rowEl } = renderRow("Work directory", "/home/sam/.local/share/archie/work", { key: "work_dir", locked: { work_dir: "pins the daemon's working layout; cannot be changed at runtime" }, }); @@ -39,18 +51,18 @@ test("a locked row keeps its reason in a separate element from the value", () => }); test("a locked row offers no edit control", () => { - const rowEl = row("State path prefix", "/home/sam/.local/share/archie/archie.db", { + const { el: rowEl } = renderRow("State path prefix", "/home/sam/.local/share/archie/archie.db", { key: "db_path", locked: { db_path: "required for bootstrap" }, }); - assert.equal(rowEl.childNodes.filter((c) => classOf(c).includes("kv-actions")).length, 0); + assert.equal(Array.from(rowEl.childNodes).filter((c) => classOf(c).includes("kv-actions")).length, 0); }); test("an editable row separates value from its actions", () => { // Regression: the value overflowed into the action column, so "400" // rendered as "40" with Edit sitting on top of the last digit. Assert // the value and the actions are distinct children. - const rowEl = row("Max diff size (lines)", 400, { key: "diff_cap_lines", type: "int", raw: 400 }); + const { el: rowEl } = renderRow("Max diff size (lines)", 400, { key: "diff_cap_lines", type: "int", raw: 400 }); const parts = cells(rowEl); assert.equal(parts.length, 3); assert.equal(parts[1], "400", "the value must not be merged with the action label"); @@ -58,21 +70,21 @@ test("an editable row separates value from its actions", () => { }); test("an overridden row shows the marker and a reset alongside edit", () => { - const rowEl = row("Max steps", 90, { + const { el: rowEl } = renderRow("Max steps", 90, { key: "budgets.max_steps", type: "int", raw: 90, overridden: ["budgets.max_steps"], }); - const actions = rowEl.childNodes.find((c) => classOf(c).includes("kv-actions")); - assert.deepEqual(actions.childNodes.map(text), ["overridden", "Edit", "Reset"]); + const actions = Array.from(rowEl.childNodes).find((c) => classOf(c).includes("kv-actions")); + assert.deepEqual(Array.from(actions.childNodes).map(text), ["overridden", "Edit", "Reset"]); }); test("the full value is recoverable from the title when the column truncates", () => { const long = "go vet ./... → go build ./... → go test ./... -count=1"; - const rowEl = row("Quality gate", long); - const value = rowEl.childNodes.find((c) => classOf(c).includes("kv-value")); - assert.equal(value.attrs.title, long); + const { el: rowEl } = renderRow("Quality gate", long); + const value = Array.from(rowEl.childNodes).find((c) => classOf(c).includes("kv-value")); + assert.equal(titleOf(value), long); }); test("zero and false are real values, not missing ones", () => { @@ -99,7 +111,7 @@ test("int edits reject a non-numeric entry before the round trip", () => { // though it has a key -- distinct from a locked row, which does have a key // and a reason. test("a field marked editable: false renders read-only with no note", () => { - const rowEl = row("Model roles", "{...}", { key: "models", type: "structured", editable: false }); + const { el: rowEl } = renderRow("Model roles", "{...}", { key: "models", type: "structured", editable: false }); const parts = cells(rowEl); assert.equal(parts.length, 2, "expected only label and value, no actions or note"); assert.ok(!classOf(rowEl).includes("is-locked")); @@ -108,7 +120,7 @@ test("a field marked editable: false renders read-only with no note", () => { // A locked reason still takes priority over editable: true -- the runtime // state (overlay.DeniedKeys) wins over the schema's static claim. test("a locked reason is shown even when the field claims editable: true", () => { - const rowEl = row("Work directory", "/work/archie", { + const { el: rowEl } = renderRow("Work directory", "/work/archie", { key: "work_dir", editable: true, locked: { work_dir: "pins the daemon's working layout; cannot be changed at runtime" }, @@ -120,13 +132,13 @@ test("a locked reason is shown even when the field claims editable: true", () => // tooltip on the label, so a generic renderer can carry "0 means // unlimited." without any field-specific frontend code. test("a field's hint becomes the label's title attribute", () => { - const rowEl = row("Max steps", 0, { hint: "0 means unlimited." }); - const label = rowEl.childNodes.find((c) => classOf(c).includes("kv-label")); - assert.equal(label.attrs.title, "0 means unlimited."); + const { el: rowEl } = renderRow("Max steps", 0, { hint: "0 means unlimited." }); + const label = Array.from(rowEl.childNodes).find((c) => classOf(c).includes("kv-label")); + assert.equal(titleOf(label), "0 means unlimited."); }); test("a field with no hint renders a plain label with no title", () => { - const rowEl = row("Max steps", 0, {}); - const label = rowEl.childNodes.find((c) => classOf(c).includes("kv-label")); - assert.equal(label.attrs.title, undefined); + const { el: rowEl } = renderRow("Max steps", 0, {}); + const label = Array.from(rowEl.childNodes).find((c) => classOf(c).includes("kv-label")); + assert.equal(titleOf(label), null); }); diff --git a/ui/test/hooks.js b/ui/test/hooks.js index 6e7dfa73f..384872d89 100644 --- a/ui/test/hooks.js +++ b/ui/test/hooks.js @@ -27,14 +27,21 @@ export async function load(url, context, nextLoad) { return { format: "module", source: 'export default "";', shortCircuit: true }; } } - if (url.endsWith(".jsx")) { + if (url.endsWith(".jsx") || url.endsWith(".test.js")) { const result = await nextLoad(url, { ...context, format: "module" }); let source = result.source; if (typeof source !== "string") { source = new TextDecoder().decode(source); } const transformed = babel.transformSync(source, { - plugins: [["@babel/plugin-transform-react-jsx", { pragma: "h", pragmaFrag: "Fragment" }]], + plugins: [[ + "@babel/plugin-transform-react-jsx", + // The automatic runtime matches @preact/preset-vite, so JSX compiles + // to `import { jsx } from "preact/jsx-runtime"` rather than a bare `h`. + // This lets source files shadow `h` (e.g. a .map((h, i) => ...) in + // mapping-editor.jsx) without breaking, exactly as the Vite build does. + { runtime: "automatic", importSource: "preact" }, + ]], filename: fileURLToPath(url), configFile: false, babelrc: false, diff --git a/ui/test/mappings.test.js b/ui/test/mappings.test.js index 0ac018ca8..0b5f697f8 100644 --- a/ui/test/mappings.test.js +++ b/ui/test/mappings.test.js @@ -1,14 +1,15 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -import "./shim.js"; +import { h } from "preact"; +import { render } from "@testing-library/preact"; import { fieldTypeFromValue, - fieldsTable, - mappingRow, + FieldsTable, + MappingRow, pathAppendIndex, pathAppendKey, - payloadTree, -} from "../src/mappings/mapping-editor.js"; + PayloadTree, +} from "../src/mappings/mapping-editor.jsx"; test("fieldTypeFromValue infers a FieldType from an example value", () => { assert.equal(fieldTypeFromValue("x"), "string"); @@ -31,44 +32,42 @@ test("pathAppendIndex appends a bracketed index", () => { }); test("payloadTree renders every object key", () => { - const tree = payloadTree({ issue: { title: "bug found" }, count: 3 }); - assert.match(tree.textContent, /issue/); - assert.match(tree.textContent, /title/); - assert.match(tree.textContent, /"bug found"/); - assert.match(tree.textContent, /count/); - assert.match(tree.textContent, /3/); + const { container } = render(h(PayloadTree, { value: { issue: { title: "bug found" }, count: 3 } })); + assert.match(container.textContent, /issue/); + assert.match(container.textContent, /title/); + assert.match(container.textContent, /"bug found"/); + assert.match(container.textContent, /count/); + assert.match(container.textContent, /3/); }); test("payloadTree renders array indices", () => { - const tree = payloadTree({ items: [{ id: 1 }, { id: 2 }] }); - assert.match(tree.textContent, /items/); - assert.match(tree.textContent, /id/); + const { container } = render(h(PayloadTree, { value: { items: [{ id: 1 }, { id: 2 }] } })); + assert.match(container.textContent, /items/); + assert.match(container.textContent, /id/); }); test("fieldsTable shows a hint instead of a table when there are no fields", () => { - const node = fieldsTable([], {}); - assert.match(node.textContent, /Click a value in the payload/); + const { container } = render(h(FieldsTable, { fields: [], preview: null })); + assert.match(container.textContent, /Click a value in the payload/); }); test("fieldsTable shows 'not previewed' for every field before a preview runs", () => { const fields = [{ name: "title", path: "issue.title", type: "string", required: true }]; - const node = fieldsTable(fields, { preview: null }); - assert.match(node.textContent, /not previewed/); + const { container } = render(h(FieldsTable, { fields, preview: null })); + assert.match(container.textContent, /not previewed/); }); test("fieldsTable surfaces a resolved value after a successful preview", () => { const fields = [{ name: "title", path: "issue.title", type: "string", required: true }]; - const node = fieldsTable(fields, { preview: { values: { title: "bug found" }, failures: [] } }); - assert.match(node.textContent, /bug found/); - assert.doesNotMatch(node.textContent, /not previewed/); + const { container } = render(h(FieldsTable, { fields, preview: { values: { title: "bug found" }, failures: [] } })); + assert.match(container.textContent, /bug found/); + assert.doesNotMatch(container.textContent, /not previewed/); }); test("fieldsTable surfaces a failure reason loudly, never a blank value", () => { const fields = [{ name: "title", path: "issue.title", type: "string", required: true }]; - const node = fieldsTable(fields, { - preview: { values: {}, failures: [{ field_name: "title", path: "issue.title", reason: "missing" }] }, - }); - assert.match(node.textContent, /missing/); + const { container } = render(h(FieldsTable, { fields, preview: { values: {}, failures: [{ field_name: "title", path: "issue.title", reason: "missing" }] } })); + assert.match(container.textContent, /missing/); }); test("fieldsTable shows every bound field's name and path", () => { @@ -76,22 +75,23 @@ test("fieldsTable shows every bound field's name and path", () => { { name: "title", path: "issue.title", type: "string", required: true }, { name: "count", path: "count", type: "number", required: false }, ]; - const node = fieldsTable(fields, { preview: null }); - assert.match(node.textContent, /issue\.title/); - assert.match(node.textContent, /count/); + const { container } = render(h(FieldsTable, { fields, preview: null })); + assert.match(container.textContent, /issue\.title/); + assert.match(container.textContent, /count/); }); test("mappingRow shows name, source hint, and field count", () => { - const row = mappingRow( - { id: 1, name: "sentry issue opened", source_hint: "sentry", fields: [{}, {}] }, - { onEdit: () => {}, onDelete: () => {} }, - ); - assert.match(row.textContent, /sentry issue opened/); - assert.match(row.textContent, /sentry/); - assert.match(row.textContent, /2/); + const { container } = render(h(MappingRow, { + mapping: { id: 1, name: "sentry issue opened", source_hint: "sentry", fields: [{}, {}] }, + onEdit: () => {}, + onDelete: () => {}, + })); + assert.match(container.textContent, /sentry issue opened/); + assert.match(container.textContent, /sentry/); + assert.match(container.textContent, /2/); }); test("mappingRow shows a placeholder when there is no source hint", () => { - const row = mappingRow({ id: 1, name: "m", fields: [] }, { onEdit: () => {}, onDelete: () => {} }); - assert.match(row.textContent, /—/); + const { container } = render(h(MappingRow, { mapping: { id: 1, name: "m", fields: [] }, onEdit: () => {}, onDelete: () => {} })); + assert.match(container.textContent, /—/); }); diff --git a/ui/test/register.js b/ui/test/register.js index 2225ac215..758c01424 100644 --- a/ui/test/register.js +++ b/ui/test/register.js @@ -1,2 +1,45 @@ import { register } from "node:module"; +import { JSDOM } from "jsdom"; + register("./hooks.js", import.meta.url); + +// A real DOM for @testing-library/preact. The custom shim in shim.js covers +// only the el() DOM-building primitives; the testing library needs full DOM +// globals (document, window, getComputedStyle, MutationObserver, ...), which +// jsdom provides. Applied here so every test file sees them before importing +// source modules. +const dom = new JSDOM("", { url: "http://localhost/" }); +const { window } = dom; + +// Some globals (navigator, location) are read-only accessors on Node's +// globalThis, so assign via defineProperty rather than direct assignment. +const setGlobal = (key, value) => { + Object.defineProperty(globalThis, key, { value, configurable: true, writable: true }); +}; + +setGlobal("window", window); +setGlobal("document", window.document); +setGlobal("navigator", window.navigator); +setGlobal("HTMLElement", window.HTMLElement); +setGlobal("Element", window.Element); +setGlobal("Node", window.Node); +setGlobal("Text", window.Text); +setGlobal("TextNode", window.TextNode); +setGlobal("DocumentFragment", window.DocumentFragment); +setGlobal("CustomEvent", window.CustomEvent); +setGlobal("Event", window.Event); +setGlobal("AbortController", window.AbortController); +setGlobal("getComputedStyle", window.getComputedStyle.bind(window)); +setGlobal("MutationObserver", window.MutationObserver); +if (typeof window.requestAnimationFrame === "function") { + setGlobal("requestAnimationFrame", window.requestAnimationFrame.bind(window)); +} else { + setGlobal("requestAnimationFrame", (cb) => setTimeout(() => cb(Date.now()), 0)); +} +if (typeof window.cancelAnimationFrame === "function") { + setGlobal("cancelAnimationFrame", window.cancelAnimationFrame.bind(window)); +} else { + setGlobal("cancelAnimationFrame", (id) => clearTimeout(id)); +} +setGlobal("localStorage", window.localStorage); +setGlobal("location", window.location); diff --git a/ui/test/settings-lifecycle.test.js b/ui/test/settings-lifecycle.test.js index 1f98dd627..686be4043 100644 --- a/ui/test/settings-lifecycle.test.js +++ b/ui/test/settings-lifecycle.test.js @@ -1,12 +1,8 @@ import { test } from "node:test"; import assert from "node:assert/strict"; import { register } from "node:module"; -import "./shim.js"; +import { render } from "@testing-library/preact"; -// settings.js imports ./settings.css, which Node's ESM loader cannot parse. -// Install a runtime loader hook (inline via a data: URL, as tasks-actions.test.js -// does for tasks.css) that stubs .css imports to an empty module, then load -// settings.js so the page can be driven under plain node --test. const cssLoad = "data:text/javascript," + encodeURIComponent(` export async function load(url, context, nextLoad) { if (url.endsWith(".css")) { @@ -17,21 +13,19 @@ const cssLoad = "data:text/javascript," + encodeURIComponent(` `); register(cssLoad, import.meta.url); -const { api } = await import("../src/base/api.js"); -const { settingsPage } = await import("../src/settings/settings.js"); +const { api } = await import("../src/base/api.jsx"); +const { settingsPage } = await import("../src/settings/settings.jsx"); -// renderSettings builds the settings page with config/version/taskMeta stubbed -// to canned payloads, then returns the root once the background loads settle. -// The stubs are restored in a finally so they never leak. async function renderSettings(meta) { const original = { config: api.config, version: api.version, taskMeta: api.taskMeta }; api.config = async () => ({}); api.version = async () => ({ components: [] }); api.taskMeta = async () => meta; try { - const root = settingsPage(); + const vnode = settingsPage(new URLSearchParams()); + const { container } = render(vnode); await new Promise((resolve) => setTimeout(resolve, 0)); - return root; + return container; } finally { api.config = original.config; api.version = original.version; @@ -54,13 +48,11 @@ test("work lifecycle card renders a status pill and an action button from /api/t const text = root.textContent; assert.ok(text.includes("Work lifecycle"), "the lifecycle card should be present"); - // Statuses render as pills carrying their severity token. const warnPill = root.querySelector(".pill-warn"); assert.ok(warnPill, "a warn-kind status should render a warn pill"); assert.equal(warnPill.textContent, "Waiting for you"); assert.ok(text.includes("Queued"), "a second status should render its label"); - // Actions render as buttons carrying their variant token. const cancelBtn = root.querySelector(".btn-quiet"); assert.ok(cancelBtn, "a quiet action should render a quiet-variant button"); assert.equal(cancelBtn.textContent, "Cancel"); @@ -75,7 +67,8 @@ test("work lifecycle card shows a quiet empty state when the catalog fetch fails throw new Error("boom"); }; try { - const root = settingsPage(); + const vnode = settingsPage(new URLSearchParams()); + const { container: root } = render(vnode); await new Promise((resolve) => setTimeout(resolve, 0)); assert.ok(root.textContent.includes("Work lifecycle"), "the card should still render"); assert.ok(root.textContent.includes("Lifecycle unavailable"), "a failure should show the empty/error state"); diff --git a/ui/test/settings-schema.test.js b/ui/test/settings-schema.test.js index 60081fdfe..c55c59e19 100644 --- a/ui/test/settings-schema.test.js +++ b/ui/test/settings-schema.test.js @@ -3,10 +3,8 @@ import assert from "node:assert/strict"; import { register } from "node:module"; import { readFileSync } from "node:fs"; import { fileURLToPath } from "node:url"; -import "./shim.js"; +import { render } from "@testing-library/preact"; -// settings.js imports ./settings.css, which Node's ESM loader cannot parse. -// Same stub as settings-lifecycle.test.js. const cssLoad = "data:text/javascript," + encodeURIComponent(` export async function load(url, context, nextLoad) { if (url.endsWith(".css")) { @@ -17,16 +15,12 @@ const cssLoad = "data:text/javascript," + encodeURIComponent(` `); register(cssLoad, import.meta.url); -const { api } = await import("../src/base/api.js"); -const { settingsPage } = await import("../src/settings/settings.js"); +const { api } = await import("../src/base/api.jsx"); +const { settingsPage } = await import("../src/settings/settings.jsx"); -const settingsJsPath = fileURLToPath(new URL("../src/settings/settings.js", import.meta.url)); +const settingsJsPath = fileURLToPath(new URL("../src/settings/settings.jsx", import.meta.url)); const settingsJsSource = readFileSync(settingsJsPath, "utf8"); -// A schema fixture with a field settings.js has never heard of. If the -// renderer needed a field-specific branch to show it correctly, this key -// would render blank, mislabeled, or not at all -- proving genericity -// requires a field the source code cannot possibly special-case. const FIXTURE_SCHEMA = [ { id: "budgets", @@ -68,9 +62,10 @@ async function renderSettings(cfg) { api.version = async () => ({ components: [] }); api.taskMeta = async () => ({ statuses: [], actions: [] }); try { - const root = settingsPage(); + const vnode = settingsPage(new URLSearchParams()); + const { container } = render(vnode); await new Promise((resolve) => setTimeout(resolve, 0)); - return root; + return container; } finally { api.config = original.config; api.version = original.version; @@ -86,34 +81,15 @@ test("a field the renderer has never seen still renders its label, value, and ed }); test("an enum field's options reach the row's opts rather than being dropped", async () => { - // The row itself is exercised directly in config-row.test.js; here the - // point is that settings.js's schema-walking code passes opts.options - // through at all, for a field type settings.js does not special-case. const root = await renderSettings({ schema: FIXTURE_SCHEMA }); assert.ok(root.textContent.includes("How images are refreshed")); }); test("a structured field in a schema section renders no card of its own here", async () => { - // "repos" is type=structured; the generic renderer must skip it (the - // dedicated repositories card, built from cfg.repositories, owns that - // display). If the generic path accidentally rendered it too, "[]" - // would appear as the field's value text. const root = await renderSettings({ schema: FIXTURE_SCHEMA, repositories: [] }); assert.ok(!root.textContent.includes("Repositories\n[]"), "a structured field should not get a generic value row"); }); -// The real contract: settings.js must not know any individual field key by -// name for the sections the generic renderer owns (identity, budgets, -// storage, web). A literal key string in the source is exactly the -// regression archie-core-b6ew.3 removed -- a hardcoded row(...) call -// re-appearing for one field while the rest stay generic. -// archie-core-b6ew.6: repositories gained inline editors for -// allow_concurrent/max_retries/review_enabled. The shim's addEventListener -// is a no-op (see ui/test/shim.js), so the save round trip itself is not -// exercisable here -- this pins the structural half: the right initial -// control with the right initial value renders per repo, matching the -// existing config-row.test.js convention of testing structure, not the -// live event round trip. test("repositories render a checkbox and a text input reflecting each repo's current field values", async () => { const root = await renderSettings({ repositories: [ @@ -121,27 +97,19 @@ test("repositories render a checkbox and a text input reflecting each repo's cur ], }); - const checkboxes = []; - const textInputs = []; - const walk = (node) => { - for (const c of node.childNodes || []) { - if (c.tagName === "INPUT" && c.attrs.type === "checkbox") checkboxes.push(c); - if (c.tagName === "INPUT" && c.attrs.type === "text") textInputs.push(c); - walk(c); - } - }; - walk(root); + const checkboxes = Array.from(root.querySelectorAll('input[type="checkbox"]')); + const textInputs = Array.from(root.querySelectorAll('input[type="text"]')); assert.equal(checkboxes.length, 2, "allow_concurrent and review_enabled should each render a checkbox"); - assert.equal(checkboxes[0].attrs.checked, "", "allow_concurrent=true should render checked"); - assert.equal(checkboxes[1].attrs.checked, undefined, "review_enabled=false should render unchecked"); + assert.ok(checkboxes[0].checked, "allow_concurrent=true should render checked"); + assert.equal(checkboxes[1].checked, false, "review_enabled=false should render unchecked"); assert.ok( - textInputs.some((i) => i.attrs.value === "3"), + textInputs.some((i) => String(i.value) === "3"), "max_retries' current value should populate a text input", ); }); -test("settings.js contains no literal field-specific branch for the generically-rendered sections", () => { +test("settings.jsx contains no literal field-specific branch for the generically-rendered sections", () => { const genericFieldKeys = [ "bot_user", "bot_email", "\"label\"", "forge.type", "forge.host", "diff_cap_lines", "budgets.max_steps", "budgets.wall_clock", "budgets.gate_max_failures", @@ -153,7 +121,7 @@ test("settings.js contains no literal field-specific branch for the generically- for (const key of genericFieldKeys) { assert.ok( !settingsJsSource.includes(key), - `settings.js still references ${key} literally -- the generic renderer must not need per-field knowledge`, + `settings.jsx still references ${key} literally -- the generic renderer must not need per-field knowledge`, ); } }); diff --git a/ui/test/settings-update-status.test.js b/ui/test/settings-update-status.test.js index 57935424f..dbb4088bd 100644 --- a/ui/test/settings-update-status.test.js +++ b/ui/test/settings-update-status.test.js @@ -1,19 +1,24 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -import "./shim.js"; -import { updateStatusCard } from "../src/settings/update-status.js"; +import { render, cleanup } from "@testing-library/preact"; +import { UpdateStatusCard } from "../src/settings/update-status.jsx"; + +function renderCard(components) { + const { container, unmount } = render(); + return { root: container, unmount }; +} test("update status card shows an empty state with no components", () => { - const card = updateStatusCard([]); - assert.equal(card.querySelector("table"), null); + const { root } = renderCard([]); + assert.equal(root.querySelector("table"), null); }); test("update status card renders one row per component with its status pill", () => { - const card = updateStatusCard([ + const { root } = renderCard([ { id: "daemon", label: "Gateway", install_type: "binary", running_version: "1.0.0", latest_available: "1.1.0", status: "update_available" }, { id: "agent", label: "Runtime", install_type: "container", running_version: "1.0.0", status: "ok" }, ]); - const rows = card.querySelector("tbody").children; + const rows = root.querySelector("tbody").children; assert.equal(rows.length, 2); assert.match(rows[0].textContent, /Gateway/); assert.match(rows[0].textContent, /Update available/); @@ -21,17 +26,17 @@ test("update status card renders one row per component with its status pill", () }); test("update status card's row title carries the comparison basis", () => { - const card = updateStatusCard([ + const { root } = renderCard([ { id: "agent", label: "Runtime", installed_claim: "1.1.0", running_version: "1.0.0", reference: "img@sha256:abc", status: "drift" }, ]); - const row = card.querySelector("tbody").children[0]; - assert.match(row.attrs.title, /Installed claim: 1\.1\.0/); - assert.match(row.attrs.title, /Running: 1\.0\.0/); - assert.match(row.attrs.title, /Reference: img@sha256:abc/); + const row = root.querySelector("tbody").children[0]; + assert.match(row.getAttribute("title"), /Installed claim: 1\.1\.0/); + assert.match(row.getAttribute("title"), /Running: 1\.0\.0/); + assert.match(row.getAttribute("title"), /Reference: img@sha256:abc/); }); test("update status card shows an unrecognised status as its own label rather than crashing", () => { - const card = updateStatusCard([{ id: "x", status: "something-new" }]); - const row = card.querySelector("tbody").children[0]; + const { root } = renderCard([{ id: "x", status: "something-new" }]); + const row = root.querySelector("tbody").children[0]; assert.match(row.textContent, /something-new/); }); diff --git a/ui/test/task-logs.test.js b/ui/test/task-logs.test.js index 7ba5eb355..b3685ca1b 100644 --- a/ui/test/task-logs.test.js +++ b/ui/test/task-logs.test.js @@ -1,34 +1,43 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -import "./shim.js"; -import { taskLogPanel } from "../src/tasks/task-logs.js"; +import { render, cleanup } from "@testing-library/preact"; +import { TaskLogPanel } from "../src/tasks/task-logs.jsx"; + +function renderPanel(state, opts = {}) { + const { container, unmount } = render(); + return { root: container, unmount }; +} test("loading state renders a loading placeholder", () => { - const node = taskLogPanel(undefined, {}); - assert.match(node.className, /task-log-loading/); - assert.match(node.textContent, /Loading/); + const { root, unmount } = renderPanel(undefined); + assert.match(root.querySelector(".task-log-loading")?.className || "", /task-log-loading/); + assert.match(root.textContent, /Loading/); + unmount(); }); test("fetch failure renders a retry control", () => { - const node = taskLogPanel(null, { onRetry: () => {} }); - assert.match(node.className, /task-log-error/); - const btn = node.querySelector("button"); + const { root, unmount } = renderPanel(null, { onRetry: () => {} }); + assert.match(root.querySelector(".task-log-error")?.className || "", /task-log-error/); + const btn = root.querySelector("button"); assert.ok(btn, "a retry button should render"); assert.equal(btn.textContent, "Retry"); + unmount(); }); test("disabled response (task logging not enabled) renders a placeholder, not a crash", () => { - const node = taskLogPanel({ disabled: true, entries: [] }); - assert.match(node.textContent, /No persisted log/); + const { root, unmount } = renderPanel({ disabled: true, entries: [] }); + assert.match(root.textContent, /No persisted log/); + unmount(); }); test("empty entries render a placeholder distinct from the disabled state", () => { - const node = taskLogPanel({ disabled: false, entries: [] }); - assert.match(node.textContent, /Nothing recorded/); + const { root, unmount } = renderPanel({ disabled: false, entries: [] }); + assert.match(root.textContent, /Nothing recorded/); + unmount(); }); test("entries render one row per entry with fields visible, surfacing stage/token detail", () => { - const node = taskLogPanel({ + const { root, unmount } = renderPanel({ entries: [ { time: "2026-01-01T00:00:00Z", @@ -44,11 +53,14 @@ test("entries render one row per entry with fields visible, surfacing stage/toke }, ], }); - assert.equal(node.children.length, 2, "one .log-row per entry"); - assert.match(node.textContent, /stage complete/); - assert.match(node.textContent, /implement/); - assert.match(node.textContent, /1234/); - assert.match(node.textContent, /sonnet/); - assert.match(node.textContent, /agent failed/); - assert.match(node.textContent, /iteration/); + const list = root.querySelector(".log-list"); + assert.ok(list, "the log list wrapper should render"); + assert.equal(list.children.length, 2, "one .log-row per entry"); + assert.match(root.textContent, /stage complete/); + assert.match(root.textContent, /implement/); + assert.match(root.textContent, /1234/); + assert.match(root.textContent, /sonnet/); + assert.match(root.textContent, /agent failed/); + assert.match(root.textContent, /iteration/); + unmount(); }); diff --git a/ui/test/tasks-actions.test.js b/ui/test/tasks-actions.test.js index fab49be03..a1e67c599 100644 --- a/ui/test/tasks-actions.test.js +++ b/ui/test/tasks-actions.test.js @@ -1,11 +1,8 @@ import { test } from "node:test"; import assert from "node:assert/strict"; import { register } from "node:module"; -import "./shim.js"; +import { render, waitFor } from "@testing-library/preact"; -// tasks.js imports "./tasks.css", which Node's ESM loader cannot parse. Install -// a runtime loader hook (inline, via a data: URL so nothing extra is written to -// disk) that stubs .css imports to an empty module, then load tasks.js. const cssLoad = "data:text/javascript," + encodeURIComponent(` export async function load(url, context, nextLoad) { if (url.endsWith(".css")) { @@ -16,19 +13,19 @@ const cssLoad = "data:text/javascript," + encodeURIComponent(` `); register(cssLoad, import.meta.url); -const { api } = await import("../src/base/api.js"); -const { tasksPage } = await import("../src/tasks/tasks.js"); +const { api } = await import("../src/base/api.jsx"); +const { tasksPage } = await import("../src/tasks/tasks.jsx"); -// renderTask builds a page with a single task by stubbing api.tasks to a fake -// task, then returns the rendered root once tasksPage's background load() has -// settled. api.tasks is restored in a finally so the stub never leaks. async function renderTask(task) { const original = api.tasks; api.tasks = async () => [task]; try { - const root = tasksPage(new URLSearchParams()); - await new Promise((resolve) => setTimeout(resolve, 0)); - return root; + const vnode = tasksPage(new URLSearchParams()); + const { container } = render(vnode); + await waitFor(() => { + assert.ok(container.querySelector(".task-row"), "Wait for task to render"); + }); + return container; } finally { api.tasks = original; } @@ -62,7 +59,6 @@ test("an id NOT in the catalog renders nothing", async () => { actions: ["teleport"], }; const root = await renderTask(task); - // Unknown id -> no control renders, so no .task-actions container appears. assert.equal(root.querySelector(".task-actions"), null, "unknown action renders nothing"); });