@ashlr/hub 3.9.0 → 3.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/build-identity.json +2 -2
  3. package/dist/core/resources/claude-account-usage.d.ts +19 -0
  4. package/dist/core/resources/claude-account-usage.js +22 -1
  5. package/dist/core/resources/claude-account-usage.js.map +1 -1
  6. package/dist/core/verse/accounts.d.ts +6 -5
  7. package/dist/core/verse/accounts.js +9 -8
  8. package/dist/core/verse/accounts.js.map +1 -1
  9. package/dist/core/web/public/next/assets/{App-XURmiAAp.js → App-D2P1AJiD.js} +2 -2
  10. package/dist/core/web/public/next/assets/{App-XURmiAAp.js.map → App-D2P1AJiD.js.map} +1 -1
  11. package/dist/core/web/public/next/assets/{ApprovalsSection-BriUzoZc.js → ApprovalsSection-Dq66NMfx.js} +2 -2
  12. package/dist/core/web/public/next/assets/{ApprovalsSection-BriUzoZc.js.map → ApprovalsSection-Dq66NMfx.js.map} +1 -1
  13. package/dist/core/web/public/next/assets/{AutonomySection-C4GBsQVc.js → AutonomySection-DyxpeR5I.js} +2 -2
  14. package/dist/core/web/public/next/assets/{AutonomySection-C4GBsQVc.js.map → AutonomySection-DyxpeR5I.js.map} +1 -1
  15. package/dist/core/web/public/next/assets/{ChatSection-hlgPBRco.js → ChatSection-bzwFdbdw.js} +2 -2
  16. package/dist/core/web/public/next/assets/{ChatSection-hlgPBRco.js.map → ChatSection-bzwFdbdw.js.map} +1 -1
  17. package/dist/core/web/public/next/assets/{ConfirmDialog-BdQYI-Ng.js → ConfirmDialog-DkR0z5_a.js} +2 -2
  18. package/dist/core/web/public/next/assets/{ConfirmDialog-BdQYI-Ng.js.map → ConfirmDialog-DkR0z5_a.js.map} +1 -1
  19. package/dist/core/web/public/next/assets/{Dialog-BxdIfmFH.js → Dialog-CIjlQZqc.js} +2 -2
  20. package/dist/core/web/public/next/assets/{Dialog-BxdIfmFH.js.map → Dialog-CIjlQZqc.js.map} +1 -1
  21. package/dist/core/web/public/next/assets/{DiffViewer-DmeRWuc4.js → DiffViewer-BjQZAm5L.js} +2 -2
  22. package/dist/core/web/public/next/assets/{DiffViewer-DmeRWuc4.js.map → DiffViewer-BjQZAm5L.js.map} +1 -1
  23. package/dist/core/web/public/next/assets/{McpSection-q34T7Tho.js → McpSection-D2FySMy3.js} +2 -2
  24. package/dist/core/web/public/next/assets/{McpSection-q34T7Tho.js.map → McpSection-D2FySMy3.js.map} +1 -1
  25. package/dist/core/web/public/next/assets/{MutationTokenDialog-CFAkwOEt.js → MutationTokenDialog-QBPrD1UE.js} +2 -2
  26. package/dist/core/web/public/next/assets/{MutationTokenDialog-CFAkwOEt.js.map → MutationTokenDialog-QBPrD1UE.js.map} +1 -1
  27. package/dist/core/web/public/next/assets/{ResourcePoolConsoleApp-DHc8GFOY.js → ResourcePoolConsoleApp-Dzq9Ufq_.js} +2 -2
  28. package/dist/core/web/public/next/assets/{ResourcePoolConsoleApp-DHc8GFOY.js.map → ResourcePoolConsoleApp-Dzq9Ufq_.js.map} +1 -1
  29. package/dist/core/web/public/next/assets/{RouteErrorBoundary-ZL9F4qUn.js → RouteErrorBoundary-Chd-wt6w.js} +2 -2
  30. package/dist/core/web/public/next/assets/{RouteErrorBoundary-ZL9F4qUn.js.map → RouteErrorBoundary-Chd-wt6w.js.map} +1 -1
  31. package/dist/core/web/public/next/assets/{Segmented-DbRjVye3.js → Segmented-DhGh7Y1s.js} +2 -2
  32. package/dist/core/web/public/next/assets/{Segmented-DbRjVye3.js.map → Segmented-DhGh7Y1s.js.map} +1 -1
  33. package/dist/core/web/public/next/assets/{SettingsSection-nJGGGYqv.js → SettingsSection-Bqimu_Mg.js} +2 -2
  34. package/dist/core/web/public/next/assets/{SettingsSection-nJGGGYqv.js.map → SettingsSection-Bqimu_Mg.js.map} +1 -1
  35. package/dist/core/web/public/next/assets/{UniverseConsoleApp-6GJydgo4.js → UniverseConsoleApp-DzAyrE-A.js} +2 -2
  36. package/dist/core/web/public/next/assets/{UniverseConsoleApp-6GJydgo4.js.map → UniverseConsoleApp-DzAyrE-A.js.map} +1 -1
  37. package/dist/core/web/public/next/assets/{UniverseView-DLDtNYL8.js → UniverseView-BGl3DRV7.js} +2 -2
  38. package/dist/core/web/public/next/assets/{UniverseView-DLDtNYL8.js.map → UniverseView-BGl3DRV7.js.map} +1 -1
  39. package/dist/core/web/public/next/assets/{UsageSection-Cf9d9iFH.js → UsageSection-PaaJ1L90.js} +2 -2
  40. package/dist/core/web/public/next/assets/{UsageSection-Cf9d9iFH.js.map → UsageSection-PaaJ1L90.js.map} +1 -1
  41. package/dist/core/web/public/next/assets/{VerseConsoleApp-y0uOHixd.js → VerseConsoleApp-DYH7ottg.js} +3 -3
  42. package/dist/core/web/public/next/assets/{VerseConsoleApp-y0uOHixd.js.map → VerseConsoleApp-DYH7ottg.js.map} +1 -1
  43. package/dist/core/web/public/next/assets/{charts-CVooqJWN.js → charts-CnMDT08S.js} +2 -2
  44. package/dist/core/web/public/next/assets/{charts-CVooqJWN.js.map → charts-CnMDT08S.js.map} +1 -1
  45. package/dist/core/web/public/next/assets/{context-model-Bqv8DVuH.js → context-model-DTvb2uZy.js} +2 -2
  46. package/dist/core/web/public/next/assets/{context-model-Bqv8DVuH.js.map → context-model-DTvb2uZy.js.map} +1 -1
  47. package/dist/core/web/public/next/assets/{global-eaY9GyX3.js → global-F2K14nNo.js} +2 -2
  48. package/dist/core/web/public/next/assets/{global-eaY9GyX3.js.map → global-F2K14nNo.js.map} +1 -1
  49. package/dist/core/web/public/next/assets/{icons-vex8rclC.js → icons-B2fa40k6.js} +2 -2
  50. package/dist/core/web/public/next/assets/{icons-vex8rclC.js.map → icons-B2fa40k6.js.map} +1 -1
  51. package/dist/core/web/public/next/assets/{index-D2Eik-zt.js → index-DO9a5IaB.js} +3 -3
  52. package/dist/core/web/public/next/assets/{index-D2Eik-zt.js.map → index-DO9a5IaB.js.map} +1 -1
  53. package/dist/core/web/public/next/assets/{queries-bAYU0VNy.js → queries-BdSsWYSu.js} +2 -2
  54. package/dist/core/web/public/next/assets/{queries-bAYU0VNy.js.map → queries-BdSsWYSu.js.map} +1 -1
  55. package/dist/core/web/public/next/assets/{use-guarded-action-C7QrP7Yp.js → use-guarded-action-BrlIU0jJ.js} +2 -2
  56. package/dist/core/web/public/next/assets/{use-guarded-action-C7QrP7Yp.js.map → use-guarded-action-BrlIU0jJ.js.map} +1 -1
  57. package/dist/core/web/public/next/assets/{verse-model-TfDk9cky.js → verse-model-GWqHIjMG.js} +2 -2
  58. package/dist/core/web/public/next/assets/{verse-model-TfDk9cky.js.map → verse-model-GWqHIjMG.js.map} +1 -1
  59. package/dist/core/web/public/next/assets/{workspace-model-CHol5RVp.js → workspace-model-4yzB--1h.js} +2 -2
  60. package/dist/core/web/public/next/assets/{workspace-model-CHol5RVp.js.map → workspace-model-4yzB--1h.js.map} +1 -1
  61. package/dist/core/web/public/next/index.html +1 -1
  62. package/dist/release-dependency-inventory.json +1 -1
  63. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{a as e,n as t,o as n}from"./index-D2Eik-zt.js";import{$ as r,A as i,B as a,F as o,G as s,H as c,K as l,L as u,M as d,N as f,Q as p,R as m,U as h,V as g,W as _,Y as v,Z as ee,_ as y,at as b,b as x,c as S,ct as C,d as w,et as T,i as E,j as D,k as te,nt as ne,o as O,p as re,q as k,rt as A,s as j,st as M,tt as N,u as P,v as ie,y as F,z as ae}from"./global-eaY9GyX3.js";import{t as oe}from"./Dialog-BxdIfmFH.js";import{r as se}from"./RouteErrorBoundary-ZL9F4qUn.js";import{t as ce}from"./MutationTokenDialog-CFAkwOEt.js";import{i as le,n as ue,r as de,t as fe}from"./DiffViewer-DmeRWuc4.js";import{n as pe,r as I,t as L}from"./Segmented-DbRjVye3.js";import{B as R,F as me,G as he,I as ge,J as _e,K as z,L as ve,M as ye,N as be,P as xe,Q as Se,R as Ce,X as we,Y as Te,Z as Ee,_ as De,a as Oe,b as ke,c as Ae,d as je,f as Me,h as Ne,i as Pe,l as Fe,m as Ie,n as Le,o as Re,p as ze,q as Be,r as Ve,s as He,t as Ue,u as We,v as Ge,x as Ke,y as qe}from"./VerseConsoleApp-y0uOHixd.js";import{C as Je,S as Ye,T as Xe,_ as Ze,a as Qe,b as $e,c as et,d as tt,g as nt,h as rt,i as it,l as at,n as ot,o as st,p as ct,r as lt,s as ut,t as dt,u as ft,v as pt,w as mt,x as ht,y as gt}from"./verse-model-TfDk9cky.js";import{_ as _t,a as vt,c as yt,d as bt,f as xt,g as St,h as Ct,i as wt,l as Tt,m as Et,n as Dt,o as Ot,p as kt,r as At,s as jt,t as Mt,u as Nt,v as Pt}from"./workspace-model-CHol5RVp.js";import{A as Ft,C as It,D as Lt,E as Rt,F as zt,I as Bt,L as Vt,M as Ht,N as Ut,O as Wt,P as Gt,R as Kt,T as qt,_ as Jt,a as Yt,b as Xt,c as Zt,d as Qt,f as $t,g as en,h as tn,i as nn,j as rn,k as B,l as an,m as on,n as sn,o as cn,p as ln,r as un,s as dn,t as fn,u as pn,v as mn,w as hn,x as gn,y as _n}from"./context-model-Bqv8DVuH.js";var V=n(e(),1),vn=`verse-preferences`,yn=`verse-memory:`;async function bn(e){try{let t=await e.json();if(typeof t.error==`string`&&t.error)return t.error;if(typeof t.note==`string`&&t.note)return t.note}catch{}return null}async function xn(e,t){let n=await fetch(e,{method:`GET`,credentials:`same-origin`,headers:{"x-ashlr-read-client":d()},signal:t});if(n.status===401)throw o(),new j(`Read session expired.`,401,e);if(!n.ok){let t=await bn(n);throw new j(`GET ${e} failed (HTTP ${n.status})${t?`: ${t}`:``}.`,n.status,e,t)}return await n.json()}async function Sn(e,t){let n=D();if(!n)throw new Le;let r=await P(e,t,n);return u(),r}function Cn(e,t){let n=t.toString();return n?`${e}?${n}`:e}async function wn(e,t){let n={mode:t},r=await Sn(Ge(e,`/context-mode`),n);return zt(e,r),M(Ue),r}async function Tn(e,t={}){let n={};t.includeLastAssistant===!0&&(n.includeLastAssistant=!0);let r=typeof t.focus==`string`?t.focus.trim().slice(0,500):``;return r&&(n.focus=r),Sn(Ge(e,`/handoff-preview`),n)}async function En(e){let{source:t}=e,n={projectPath:t.projectPath,seatId:e.seatId,handoffFromSessionId:t.id},r=(t.extraRoots??[]).filter(e=>typeof e==`string`&&e.length>0&&e!==t.projectPath);r.length>0&&(n.extraRoots=r),e.model&&(n.model=e.model),e.contextMode&&(n.contextMode=e.contextMode);let i=e.title?.trim();i&&(n.title=i);let a=await Sn(`/api/verse/sessions`,n);return We(),a}function Dn(e){return xn(`/api/verse/preferences`,e)}var On={key:vn,fetch:e=>Dn(e)};async function kn(e){let t=await Sn(`/api/verse/preferences`,e);return M(vn),C(yn),t}function An(e){let t=new URLSearchParams,n=e.workspaceId?.trim()??``,r=e.projectPath?.trim()??``,i=(e.extraRoots??[]).map(e=>e.trim()).filter(e=>e.length>0);if(n){if(r||i.length>0)throw Error(`Estimate a workspace or a folder set, not both.`);t.set(`workspaceId`,n)}else if(r){t.set(`projectPath`,r);for(let e of i)t.append(`extraRoots`,e)}else throw Error(`Pick a project or a workspace to estimate.`);return Cn(`/api/verse/context-fit`,t)}function jn(e,t){return xn(An(e),t)}function Mn(e,t,n){let r=new URLSearchParams({q:e});return typeof t==`number`&&Number.isFinite(t)&&r.set(`limit`,String(Math.max(1,Math.min(50,Math.floor(t))))),xn(Cn(`/api/verse/search`,r),n)}function Nn(e){return`${yn}${e}`}function Pn(e,t){return xn(Cn(`/api/verse/memory`,new URLSearchParams({projectPath:e})),t)}function Fn(e){return{key:Nn(e),fetch:t=>Pn(e,t)}}async function In(e,t){let n=await Sn(`/api/verse/memory`,{projectPath:e,content:t});return M(Nn(e)),n}var Ln={ready:`ready`,tight:`tight`,exhausted:`blocked`,"signed-out":`blocked`,unknown:`unread`};function Rn(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return null;let n=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return new Date().toDateString()===t.toDateString()?`resets ${n}`:`resets ${t.toLocaleDateString([],{month:`short`,day:`numeric`})} at ${n}`}function zn(e,t){let n=`${e}_`,r=t;for(;r.startsWith(n)&&r.length>n.length;)r=r.slice(n.length);return Ye(r)}function Bn(e,t){let n=t.resetDescription??(t.resetsAt===null?null:Rn(t.resetsAt));return{id:t.id,label:zn(e,t.id),usedPercent:t.limitReached||!t.measured?null:t.usedPercent,limitReached:t.limitReached,resetText:n,resetsAt:t.resetsAt}}function Vn(e){let t=typeof e.usedPercent==`number`&&Number.isFinite(e.usedPercent)?Math.max(0,Math.min(100,e.usedPercent)):null,n=t!==null&&t>=100;return{id:e.id,label:Ye(e.id),usedPercent:n?null:t,limitReached:n,resetText:e.resetsAt===null?null:Rn(e.resetsAt),resetsAt:e.resetsAt}}function Hn(e){if(e===null)return{phrase:null,title:null};if(e.unlimited)return{phrase:`credits unlimited`,title:null};if(!e.hasCredits)return{phrase:null,title:null};if(e.balance===null)return{phrase:`credits available`,title:null};let t=Number.parseFloat(e.balance);return Number.isFinite(t)?{phrase:`${t.toFixed(2)} credits left`,title:e.balance}:{phrase:`credits available`,title:e.balance}}function Un(e){let t=ht(e),n=e.health.state===`ready`,r=t===null?n?`ready`:`unread`:`blocked`;return{kind:`local`,plan:null,cls:r,word:lt[r],summary:t??(n?`runs on this machine`:`readiness not reported`),binding:null,others:[],credits:null,creditsTitle:null,notes:e.health.summary===null?[]:[e.health.summary],evidenceSource:null,observedAt:e.health.observedAt,extended:!1}}function Wn(e){let t=pt(e),n=e.health.windows.map(Vn),r=n.find(e=>e.limitReached)??null,i=n.filter(e=>e.usedPercent!==null),a=i.length===0?null:i.reduce((e,t)=>(t.usedPercent??0)>(e.usedPercent??0)?t:e),o=r??a,s=ht(e),c=s===null?t.cls:`blocked`;return{kind:`subscription`,plan:null,cls:c,word:lt[c],summary:s??t.text,binding:o,others:o===null?n:n.filter(e=>e.id!==o.id),credits:null,creditsTitle:null,notes:[],evidenceSource:null,observedAt:e.health.observedAt,extended:!1}}function Gn(e){if(e.engine===`local`)return Un(e);let t=e.capacity;if(t===void 0)return Wn(e);let n=t.windows.map(t=>Bn(e.engine,t)),r=t.binding,i=r===null?null:n.find(e=>e.id===r.id)??Bn(e.engine,r),a=i===null?n:n.filter(e=>e.id!==i.id),o=Hn(t.credits),s=ht(e),c=s===null?Ln[t.usability]:`blocked`,l;return l=t.usability===`signed-out`?`signed out — reconnect this account`:s===null?i===null?`no capacity reading`:i.limitReached?t.usability===`tight`&&o.phrase!==null?`${i.label} limit reached · credits still spendable`:`${i.label} limit reached`:i.usedPercent===null?`no capacity reading`:`${Math.round(i.usedPercent)}% of ${i.label} used`:s,{kind:`subscription`,plan:t.planType,cls:c,word:lt[c],summary:l,binding:i,others:a,credits:o.phrase,creditsTitle:o.title,notes:[...t.notes],evidenceSource:t.evidenceSource,observedAt:t.observedAt??e.health.observedAt,extended:!0}}function Kn(e){switch(e){case`collector`:return null;case`shared-evidence`:return`read from another collector’s shared evidence, not probed here`;case`baseline`:return`operator-seeded baseline, not a live reading`;case`none`:return`no evidence source — nothing here was measured`;default:return null}}function qn(e,t){let n=[e.label];return t.plan!==null&&n.push(t.plan),n.push(t.word),n.push(t.summary),t.credits!==null&&n.push(t.credits),t.binding?.resetText!=null&&n.push(t.binding.resetText),n.join(` · `)}function Jn(e){return e===`tight`||e===`blocked`}var Yn={chip:`_chip_rrd6q_8`,chipGlyph:`_chipGlyph_rrd6q_22`,window:`_window_rrd6q_35`,windowLead:`_windowLead_rrd6q_36`,windowLabel:`_windowLabel_rrd6q_43`,pct:`_pct_rrd6q_44`,flag:`_flag_rrd6q_60`,unknownHead:`_unknownHead_rrd6q_69`,unknownValue:`_unknownValue_rrd6q_76`,unknownRule:`_unknownRule_rrd6q_85`,reset:`_reset_rrd6q_93`,note:`_note_rrd6q_104`,noteHead:`_noteHead_rrd6q_110`,plan:`_plan_rrd6q_117`,noteSummary:`_noteSummary_rrd6q_130`,credits:`_credits_rrd6q_137`},H=t(),Xn={ready:`✓`,tight:`◑`,blocked:`▮`,unread:`?`};function Zn({view:e,title:t}){return(0,H.jsxs)(`span`,{className:Yn.chip,"data-capacity":e.cls,title:t??e.summary,children:[(0,H.jsx)(`span`,{className:Yn.chipGlyph,"aria-hidden":`true`,children:Xn[e.cls]}),e.word]})}function Qn({windowView:e,ariaPrefix:t,prominent:n=!1}){let r=`${t} ${e.label}`;if(e.limitReached)return(0,H.jsxs)(`div`,{className:n?Yn.windowLead:Yn.window,children:[(0,H.jsx)(pe,{value:100,max:100,tone:`danger`,label:(0,H.jsx)(`span`,{className:Yn.windowLabel,children:e.label}),valueText:(0,H.jsx)(`span`,{className:Yn.flag,children:`limit reached`}),"aria-label":`${r}: the provider flagged this window as rate-limited, so no percentage was measured`}),e.resetText===null?null:(0,H.jsx)(`p`,{className:Yn.reset,children:e.resetText})]});if(e.usedPercent===null)return(0,H.jsxs)(`div`,{className:n?Yn.windowLead:Yn.window,children:[(0,H.jsxs)(`div`,{className:Yn.unknownHead,children:[(0,H.jsx)(`span`,{className:Yn.windowLabel,children:e.label}),(0,H.jsx)(`span`,{className:Yn.unknownValue,children:`no reading`})]}),(0,H.jsx)(`hr`,{className:Yn.unknownRule,"aria-hidden":`true`}),e.resetText===null?null:(0,H.jsx)(`p`,{className:Yn.reset,children:e.resetText})]});let i=Math.round(e.usedPercent);return(0,H.jsxs)(`div`,{className:n?Yn.windowLead:Yn.window,children:[(0,H.jsx)(pe,{value:i,max:100,label:(0,H.jsx)(`span`,{className:Yn.windowLabel,children:e.label}),valueText:(0,H.jsxs)(`span`,{className:Yn.pct,children:[i,`%`]}),"aria-label":`${r} used`}),e.resetText===null?null:(0,H.jsx)(`p`,{className:Yn.reset,children:e.resetText})]})}function $n({seat:e,className:t}){let n=Gn(e);return(0,H.jsxs)(`div`,{className:`${Yn.note} ${t??``}`,"data-capacity":n.cls,children:[(0,H.jsxs)(`div`,{className:Yn.noteHead,children:[(0,H.jsx)(Zn,{view:n}),n.plan===null?null:(0,H.jsx)(`span`,{className:Yn.plan,children:n.plan}),(0,H.jsx)(`span`,{className:Yn.noteSummary,children:n.summary})]}),n.binding===null?null:(0,H.jsx)(Qn,{windowView:n.binding,ariaPrefix:e.label,prominent:!0}),n.credits===null?null:(0,H.jsxs)(`p`,{className:Yn.credits,title:n.creditsTitle??void 0,children:[n.credits,` — credits are independent of the window`]})]})}var U={composer:`_composer_um1gd_5`,box:`_box_um1gd_10`,textarea:`_textarea_um1gd_21`,boxListening:`_boxListening_um1gd_28`,row:`_row_um1gd_47`,spacer:`_spacer_um1gd_53`,"engine-claude":`_engine-claude_um1gd_56`,"engine-codex":`_engine-codex_um1gd_57`,"engine-grok":`_engine-grok_um1gd_58`,"engine-local":`_engine-local_um1gd_59`,engineDot:`_engineDot_um1gd_60`,seatField:`_seatField_um1gd_69`,seatFieldCompact:`_seatFieldCompact_um1gd_70`,fieldLabel:`_fieldLabel_um1gd_71`,seatSelect:`_seatSelect_um1gd_72`,seatPillWrap:`_seatPillWrap_um1gd_89`,seatPill:`_seatPill_um1gd_89`,seatPillText:`_seatPillText_um1gd_107`,seatMenu:`_seatMenu_um1gd_109`,seatMenuHeading:`_seatMenuHeading_um1gd_126`,seatMenuEmpty:`_seatMenuEmpty_um1gd_134`,seatMenuItem:`_seatMenuItem_um1gd_135`,seatMenuText:`_seatMenuText_um1gd_148`,seatMenuPrimary:`_seatMenuPrimary_um1gd_149`,seatMenuSecondary:`_seatMenuSecondary_um1gd_150`,seatMenuCapacity:`_seatMenuCapacity_um1gd_156`,dictationWrap:`_dictationWrap_um1gd_167`,dictation:`_dictation_um1gd_167`,dictationLive:`_dictationLive_um1gd_182`,dictationPulse:`_dictationPulse_um1gd_183`,"verse-ring":`_verse-ring_um1gd_1`,dictationError:`_dictationError_um1gd_197`,send:`_send_um1gd_200`,stop:`_stop_um1gd_201`,stopIcon:`_stopIcon_um1gd_220`,help:`_help_um1gd_223`,helpQuiet:`_helpQuiet_um1gd_231`,helpError:`_helpError_um1gd_240`,cost:`_cost_um1gd_268`,costFigure:`_costFigure_um1gd_280`};function er(e){return JSON.stringify([e.seatId,e.model])}function tr(e){try{let t=JSON.parse(e);if(!Array.isArray(t)||t.length!==2)return null;let[n,r]=t;return typeof n!=`string`||typeof r!=`string`?null:{seatId:n,model:r}}catch{return null}}function nr(e){for(let t of ft(e))for(let e of t.seats){if(e.health.state===`unavailable`)continue;let t=e.models.find(t=>en(e,t)===null);if(t)return{seatId:e.id,model:t.id}}return null}function rr(e){let t=tn(e.workingSetTokens,e.model,e.mode,e.seat.engine),n=t===null?``:` · ${un[t]}`,r=e.note===null?``:` (${e.note})`;return`${e.seat.label} — ${e.model.label} · ${ln(e.model,e.mode)}${n}${r}`}function ir(e,t,n){let r=[];n!==null&&r.push(n.charAt(0).toUpperCase()+n.slice(1)),r.push(on(t));let i=Xt(e);return i!==null&&r.push(`Runs ${i}.`),r.push(...gn(e)),r.join(`
1
+ import{a as e,n as t,o as n}from"./index-DO9a5IaB.js";import{$ as r,A as i,B as a,F as o,G as s,H as c,K as l,L as u,M as d,N as f,Q as p,R as m,U as h,V as g,W as _,Y as v,Z as ee,_ as y,at as b,b as x,c as S,ct as C,d as w,et as T,i as E,j as D,k as te,nt as ne,o as O,p as re,q as k,rt as A,s as j,st as M,tt as N,u as P,v as ie,y as F,z as ae}from"./global-F2K14nNo.js";import{t as oe}from"./Dialog-CIjlQZqc.js";import{r as se}from"./RouteErrorBoundary-Chd-wt6w.js";import{t as ce}from"./MutationTokenDialog-QBPrD1UE.js";import{i as le,n as ue,r as de,t as fe}from"./DiffViewer-BjQZAm5L.js";import{n as pe,r as I,t as L}from"./Segmented-DhGh7Y1s.js";import{B as R,F as me,G as he,I as ge,J as _e,K as z,L as ve,M as ye,N as be,P as xe,Q as Se,R as Ce,X as we,Y as Te,Z as Ee,_ as De,a as Oe,b as ke,c as Ae,d as je,f as Me,h as Ne,i as Pe,l as Fe,m as Ie,n as Le,o as Re,p as ze,q as Be,r as Ve,s as He,t as Ue,u as We,v as Ge,x as Ke,y as qe}from"./VerseConsoleApp-DYH7ottg.js";import{C as Je,S as Ye,T as Xe,_ as Ze,a as Qe,b as $e,c as et,d as tt,g as nt,h as rt,i as it,l as at,n as ot,o as st,p as ct,r as lt,s as ut,t as dt,u as ft,v as pt,w as mt,x as ht,y as gt}from"./verse-model-GWqHIjMG.js";import{_ as _t,a as vt,c as yt,d as bt,f as xt,g as St,h as Ct,i as wt,l as Tt,m as Et,n as Dt,o as Ot,p as kt,r as At,s as jt,t as Mt,u as Nt,v as Pt}from"./workspace-model-4yzB--1h.js";import{A as Ft,C as It,D as Lt,E as Rt,F as zt,I as Bt,L as Vt,M as Ht,N as Ut,O as Wt,P as Gt,R as Kt,T as qt,_ as Jt,a as Yt,b as Xt,c as Zt,d as Qt,f as $t,g as en,h as tn,i as nn,j as rn,k as B,l as an,m as on,n as sn,o as cn,p as ln,r as un,s as dn,t as fn,u as pn,v as mn,w as hn,x as gn,y as _n}from"./context-model-DTvb2uZy.js";var V=n(e(),1),vn=`verse-preferences`,yn=`verse-memory:`;async function bn(e){try{let t=await e.json();if(typeof t.error==`string`&&t.error)return t.error;if(typeof t.note==`string`&&t.note)return t.note}catch{}return null}async function xn(e,t){let n=await fetch(e,{method:`GET`,credentials:`same-origin`,headers:{"x-ashlr-read-client":d()},signal:t});if(n.status===401)throw o(),new j(`Read session expired.`,401,e);if(!n.ok){let t=await bn(n);throw new j(`GET ${e} failed (HTTP ${n.status})${t?`: ${t}`:``}.`,n.status,e,t)}return await n.json()}async function Sn(e,t){let n=D();if(!n)throw new Le;let r=await P(e,t,n);return u(),r}function Cn(e,t){let n=t.toString();return n?`${e}?${n}`:e}async function wn(e,t){let n={mode:t},r=await Sn(Ge(e,`/context-mode`),n);return zt(e,r),M(Ue),r}async function Tn(e,t={}){let n={};t.includeLastAssistant===!0&&(n.includeLastAssistant=!0);let r=typeof t.focus==`string`?t.focus.trim().slice(0,500):``;return r&&(n.focus=r),Sn(Ge(e,`/handoff-preview`),n)}async function En(e){let{source:t}=e,n={projectPath:t.projectPath,seatId:e.seatId,handoffFromSessionId:t.id},r=(t.extraRoots??[]).filter(e=>typeof e==`string`&&e.length>0&&e!==t.projectPath);r.length>0&&(n.extraRoots=r),e.model&&(n.model=e.model),e.contextMode&&(n.contextMode=e.contextMode);let i=e.title?.trim();i&&(n.title=i);let a=await Sn(`/api/verse/sessions`,n);return We(),a}function Dn(e){return xn(`/api/verse/preferences`,e)}var On={key:vn,fetch:e=>Dn(e)};async function kn(e){let t=await Sn(`/api/verse/preferences`,e);return M(vn),C(yn),t}function An(e){let t=new URLSearchParams,n=e.workspaceId?.trim()??``,r=e.projectPath?.trim()??``,i=(e.extraRoots??[]).map(e=>e.trim()).filter(e=>e.length>0);if(n){if(r||i.length>0)throw Error(`Estimate a workspace or a folder set, not both.`);t.set(`workspaceId`,n)}else if(r){t.set(`projectPath`,r);for(let e of i)t.append(`extraRoots`,e)}else throw Error(`Pick a project or a workspace to estimate.`);return Cn(`/api/verse/context-fit`,t)}function jn(e,t){return xn(An(e),t)}function Mn(e,t,n){let r=new URLSearchParams({q:e});return typeof t==`number`&&Number.isFinite(t)&&r.set(`limit`,String(Math.max(1,Math.min(50,Math.floor(t))))),xn(Cn(`/api/verse/search`,r),n)}function Nn(e){return`${yn}${e}`}function Pn(e,t){return xn(Cn(`/api/verse/memory`,new URLSearchParams({projectPath:e})),t)}function Fn(e){return{key:Nn(e),fetch:t=>Pn(e,t)}}async function In(e,t){let n=await Sn(`/api/verse/memory`,{projectPath:e,content:t});return M(Nn(e)),n}var Ln={ready:`ready`,tight:`tight`,exhausted:`blocked`,"signed-out":`blocked`,unknown:`unread`};function Rn(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return null;let n=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return new Date().toDateString()===t.toDateString()?`resets ${n}`:`resets ${t.toLocaleDateString([],{month:`short`,day:`numeric`})} at ${n}`}function zn(e,t){let n=`${e}_`,r=t;for(;r.startsWith(n)&&r.length>n.length;)r=r.slice(n.length);return Ye(r)}function Bn(e,t){let n=t.resetDescription??(t.resetsAt===null?null:Rn(t.resetsAt));return{id:t.id,label:zn(e,t.id),usedPercent:t.limitReached||!t.measured?null:t.usedPercent,limitReached:t.limitReached,resetText:n,resetsAt:t.resetsAt}}function Vn(e){let t=typeof e.usedPercent==`number`&&Number.isFinite(e.usedPercent)?Math.max(0,Math.min(100,e.usedPercent)):null,n=t!==null&&t>=100;return{id:e.id,label:Ye(e.id),usedPercent:n?null:t,limitReached:n,resetText:e.resetsAt===null?null:Rn(e.resetsAt),resetsAt:e.resetsAt}}function Hn(e){if(e===null)return{phrase:null,title:null};if(e.unlimited)return{phrase:`credits unlimited`,title:null};if(!e.hasCredits)return{phrase:null,title:null};if(e.balance===null)return{phrase:`credits available`,title:null};let t=Number.parseFloat(e.balance);return Number.isFinite(t)?{phrase:`${t.toFixed(2)} credits left`,title:e.balance}:{phrase:`credits available`,title:e.balance}}function Un(e){let t=ht(e),n=e.health.state===`ready`,r=t===null?n?`ready`:`unread`:`blocked`;return{kind:`local`,plan:null,cls:r,word:lt[r],summary:t??(n?`runs on this machine`:`readiness not reported`),binding:null,others:[],credits:null,creditsTitle:null,notes:e.health.summary===null?[]:[e.health.summary],evidenceSource:null,observedAt:e.health.observedAt,extended:!1}}function Wn(e){let t=pt(e),n=e.health.windows.map(Vn),r=n.find(e=>e.limitReached)??null,i=n.filter(e=>e.usedPercent!==null),a=i.length===0?null:i.reduce((e,t)=>(t.usedPercent??0)>(e.usedPercent??0)?t:e),o=r??a,s=ht(e),c=s===null?t.cls:`blocked`;return{kind:`subscription`,plan:null,cls:c,word:lt[c],summary:s??t.text,binding:o,others:o===null?n:n.filter(e=>e.id!==o.id),credits:null,creditsTitle:null,notes:[],evidenceSource:null,observedAt:e.health.observedAt,extended:!1}}function Gn(e){if(e.engine===`local`)return Un(e);let t=e.capacity;if(t===void 0)return Wn(e);let n=t.windows.map(t=>Bn(e.engine,t)),r=t.binding,i=r===null?null:n.find(e=>e.id===r.id)??Bn(e.engine,r),a=i===null?n:n.filter(e=>e.id!==i.id),o=Hn(t.credits),s=ht(e),c=s===null?Ln[t.usability]:`blocked`,l;return l=t.usability===`signed-out`?`signed out — reconnect this account`:s===null?i===null?`no capacity reading`:i.limitReached?t.usability===`tight`&&o.phrase!==null?`${i.label} limit reached · credits still spendable`:`${i.label} limit reached`:i.usedPercent===null?`no capacity reading`:`${Math.round(i.usedPercent)}% of ${i.label} used`:s,{kind:`subscription`,plan:t.planType,cls:c,word:lt[c],summary:l,binding:i,others:a,credits:o.phrase,creditsTitle:o.title,notes:[...t.notes],evidenceSource:t.evidenceSource,observedAt:t.observedAt??e.health.observedAt,extended:!0}}function Kn(e){switch(e){case`collector`:return null;case`shared-evidence`:return`read from another collector’s shared evidence, not probed here`;case`baseline`:return`operator-seeded baseline, not a live reading`;case`none`:return`no evidence source — nothing here was measured`;default:return null}}function qn(e,t){let n=[e.label];return t.plan!==null&&n.push(t.plan),n.push(t.word),n.push(t.summary),t.credits!==null&&n.push(t.credits),t.binding?.resetText!=null&&n.push(t.binding.resetText),n.join(` · `)}function Jn(e){return e===`tight`||e===`blocked`}var Yn={chip:`_chip_rrd6q_8`,chipGlyph:`_chipGlyph_rrd6q_22`,window:`_window_rrd6q_35`,windowLead:`_windowLead_rrd6q_36`,windowLabel:`_windowLabel_rrd6q_43`,pct:`_pct_rrd6q_44`,flag:`_flag_rrd6q_60`,unknownHead:`_unknownHead_rrd6q_69`,unknownValue:`_unknownValue_rrd6q_76`,unknownRule:`_unknownRule_rrd6q_85`,reset:`_reset_rrd6q_93`,note:`_note_rrd6q_104`,noteHead:`_noteHead_rrd6q_110`,plan:`_plan_rrd6q_117`,noteSummary:`_noteSummary_rrd6q_130`,credits:`_credits_rrd6q_137`},H=t(),Xn={ready:`✓`,tight:`◑`,blocked:`▮`,unread:`?`};function Zn({view:e,title:t}){return(0,H.jsxs)(`span`,{className:Yn.chip,"data-capacity":e.cls,title:t??e.summary,children:[(0,H.jsx)(`span`,{className:Yn.chipGlyph,"aria-hidden":`true`,children:Xn[e.cls]}),e.word]})}function Qn({windowView:e,ariaPrefix:t,prominent:n=!1}){let r=`${t} ${e.label}`;if(e.limitReached)return(0,H.jsxs)(`div`,{className:n?Yn.windowLead:Yn.window,children:[(0,H.jsx)(pe,{value:100,max:100,tone:`danger`,label:(0,H.jsx)(`span`,{className:Yn.windowLabel,children:e.label}),valueText:(0,H.jsx)(`span`,{className:Yn.flag,children:`limit reached`}),"aria-label":`${r}: the provider flagged this window as rate-limited, so no percentage was measured`}),e.resetText===null?null:(0,H.jsx)(`p`,{className:Yn.reset,children:e.resetText})]});if(e.usedPercent===null)return(0,H.jsxs)(`div`,{className:n?Yn.windowLead:Yn.window,children:[(0,H.jsxs)(`div`,{className:Yn.unknownHead,children:[(0,H.jsx)(`span`,{className:Yn.windowLabel,children:e.label}),(0,H.jsx)(`span`,{className:Yn.unknownValue,children:`no reading`})]}),(0,H.jsx)(`hr`,{className:Yn.unknownRule,"aria-hidden":`true`}),e.resetText===null?null:(0,H.jsx)(`p`,{className:Yn.reset,children:e.resetText})]});let i=Math.round(e.usedPercent);return(0,H.jsxs)(`div`,{className:n?Yn.windowLead:Yn.window,children:[(0,H.jsx)(pe,{value:i,max:100,label:(0,H.jsx)(`span`,{className:Yn.windowLabel,children:e.label}),valueText:(0,H.jsxs)(`span`,{className:Yn.pct,children:[i,`%`]}),"aria-label":`${r} used`}),e.resetText===null?null:(0,H.jsx)(`p`,{className:Yn.reset,children:e.resetText})]})}function $n({seat:e,className:t}){let n=Gn(e);return(0,H.jsxs)(`div`,{className:`${Yn.note} ${t??``}`,"data-capacity":n.cls,children:[(0,H.jsxs)(`div`,{className:Yn.noteHead,children:[(0,H.jsx)(Zn,{view:n}),n.plan===null?null:(0,H.jsx)(`span`,{className:Yn.plan,children:n.plan}),(0,H.jsx)(`span`,{className:Yn.noteSummary,children:n.summary})]}),n.binding===null?null:(0,H.jsx)(Qn,{windowView:n.binding,ariaPrefix:e.label,prominent:!0}),n.credits===null?null:(0,H.jsxs)(`p`,{className:Yn.credits,title:n.creditsTitle??void 0,children:[n.credits,` — credits are independent of the window`]})]})}var U={composer:`_composer_um1gd_5`,box:`_box_um1gd_10`,textarea:`_textarea_um1gd_21`,boxListening:`_boxListening_um1gd_28`,row:`_row_um1gd_47`,spacer:`_spacer_um1gd_53`,"engine-claude":`_engine-claude_um1gd_56`,"engine-codex":`_engine-codex_um1gd_57`,"engine-grok":`_engine-grok_um1gd_58`,"engine-local":`_engine-local_um1gd_59`,engineDot:`_engineDot_um1gd_60`,seatField:`_seatField_um1gd_69`,seatFieldCompact:`_seatFieldCompact_um1gd_70`,fieldLabel:`_fieldLabel_um1gd_71`,seatSelect:`_seatSelect_um1gd_72`,seatPillWrap:`_seatPillWrap_um1gd_89`,seatPill:`_seatPill_um1gd_89`,seatPillText:`_seatPillText_um1gd_107`,seatMenu:`_seatMenu_um1gd_109`,seatMenuHeading:`_seatMenuHeading_um1gd_126`,seatMenuEmpty:`_seatMenuEmpty_um1gd_134`,seatMenuItem:`_seatMenuItem_um1gd_135`,seatMenuText:`_seatMenuText_um1gd_148`,seatMenuPrimary:`_seatMenuPrimary_um1gd_149`,seatMenuSecondary:`_seatMenuSecondary_um1gd_150`,seatMenuCapacity:`_seatMenuCapacity_um1gd_156`,dictationWrap:`_dictationWrap_um1gd_167`,dictation:`_dictation_um1gd_167`,dictationLive:`_dictationLive_um1gd_182`,dictationPulse:`_dictationPulse_um1gd_183`,"verse-ring":`_verse-ring_um1gd_1`,dictationError:`_dictationError_um1gd_197`,send:`_send_um1gd_200`,stop:`_stop_um1gd_201`,stopIcon:`_stopIcon_um1gd_220`,help:`_help_um1gd_223`,helpQuiet:`_helpQuiet_um1gd_231`,helpError:`_helpError_um1gd_240`,cost:`_cost_um1gd_268`,costFigure:`_costFigure_um1gd_280`};function er(e){return JSON.stringify([e.seatId,e.model])}function tr(e){try{let t=JSON.parse(e);if(!Array.isArray(t)||t.length!==2)return null;let[n,r]=t;return typeof n!=`string`||typeof r!=`string`?null:{seatId:n,model:r}}catch{return null}}function nr(e){for(let t of ft(e))for(let e of t.seats){if(e.health.state===`unavailable`)continue;let t=e.models.find(t=>en(e,t)===null);if(t)return{seatId:e.id,model:t.id}}return null}function rr(e){let t=tn(e.workingSetTokens,e.model,e.mode,e.seat.engine),n=t===null?``:` · ${un[t]}`,r=e.note===null?``:` (${e.note})`;return`${e.seat.label} — ${e.model.label} · ${ln(e.model,e.mode)}${n}${r}`}function ir(e,t,n){let r=[];n!==null&&r.push(n.charAt(0).toUpperCase()+n.slice(1)),r.push(on(t));let i=Xt(e);return i!==null&&r.push(`Runs ${i}.`),r.push(...gn(e)),r.join(`
2
2
  `)}function ar({seats:e,value:t,onChange:n,disabled:r=!1,label:i=`Seat and model`,id:a,compact:o=!1,workingSetTokens:s=null,modeFor:c}){let l=(0,V.useId)(),u=a??l,d=ft(e),f=t?er(t):``,p=t&&e.some(e=>e.id===t.seatId&&e.models.some(e=>e.id===t.model));return(0,H.jsxs)(`label`,{className:`${U.seatField} ${o?U.seatFieldCompact:``}`,htmlFor:u,children:[(0,H.jsx)(`span`,{className:o?`visually-hidden`:U.fieldLabel,children:i}),(0,H.jsxs)(`select`,{id:u,className:U.seatSelect,value:p?f:``,disabled:r||d.length===0,"aria-label":o?i:void 0,onChange:e=>{let t=tr(e.target.value);t&&n(t)},children:[p?null:(0,H.jsx)(`option`,{value:``,disabled:!0,children:d.length===0?`No seats discovered`:`Choose a seat…`}),d.map(e=>(0,H.jsx)(`optgroup`,{label:ot[e.engine],children:e.seats.flatMap(e=>{let t=ht(e),n=Gn(e),r=n.cls===`unread`||n.kind===`local`?null:`${n.plan===null?``:`${n.plan} · `}${n.word} · ${n.summary}`;return e.models.map(n=>{let i=t??en(e,n),a=i===null?r:`unavailable: ${i}`,o=c?.(e,n)??`standard`,l=er({seatId:e.id,model:n.id});return(0,H.jsx)(`option`,{value:l,disabled:i!==null,title:ir(e,n,a),children:rr({seat:e,model:n,mode:o,workingSetTokens:s,note:a})},l)})})},e.engine))]})]})}var or=`plugin:dialog|open`,sr=`Choose a project folder`;function cr(){let e=globalThis,t=e.__TAURI_INTERNALS__?.invoke;if(typeof t==`function`)return{invoke:t};let n=e.__TAURI__?.core?.invoke;return typeof n==`function`?{invoke:n}:null}function lr(){return cr()!==null}async function ur(){let e=cr();if(!e)return null;try{return fr(await e.invoke(or,{options:{directory:!0,multiple:!1,recursive:!1,title:sr}}))}catch{return null}}var dr=4;function fr(e,t=0){if(t>dr)return null;if(Array.isArray(e))return e.length>0?fr(e[0],t+1):null;if(typeof e==`object`&&e){let n=e.path;return typeof n==`string`?fr(n,t+1):null}if(typeof e!=`string`)return null;let n=pr(e.trim());return!n||n.includes(`\0`)?null:mr(n)?n:null}function pr(e){if(e===``)return null;if(!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e)||/^[A-Za-z]:[\\/]/.test(e))return e;if(!/^file:\/\//i.test(e))return null;let t;try{t=new URL(e).pathname}catch{return null}let n;try{n=decodeURIComponent(t)}catch{return null}return/^\/[A-Za-z]:[\\/]/.test(n)?n.slice(1):n}function mr(e){return e.startsWith(`\\\\`)||e.startsWith(`/`)?!0:/^[A-Za-z]:[\\/]/.test(e)}var W={width:`_width_stwix_1`,form:`_form_stwix_3`,field:`_field_stwix_4`,label:`_label_stwix_5`,optional:`_optional_stwix_13`,select:`_select_stwix_15`,input:`_input_stwix_16`,hint:`_hint_stwix_40`,error:`_error_stwix_41`,actions:`_actions_stwix_49`,cancel:`_cancel_stwix_50`,create:`_create_stwix_51`,capacity:`_capacity_stwix_72`,rootRow:`_rootRow_stwix_78`,removeRoot:`_removeRoot_stwix_87`,addRoot:`_addRoot_stwix_88`,context:`_context_stwix_108`,contextHead:`_contextHead_stwix_115`,contextBudget:`_contextBudget_stwix_122`,warn:`_warn_stwix_130`,fit:`_fit_stwix_137`,fitLine:`_fitLine_stwix_138`,fitBadge:`_fitBadge_stwix_147`,seatFacts:`_seatFacts_stwix_165`},hr=`\0workspace:`,gr=`\0other`,_r=(e,t)=>t();function vr(e,t){return e?.seats[t]?.contextMode??`standard`}function yr(e,t,n){return e?ne(e)?_n(e,t):n!==`standard`&&k(e,`standard`)!==null?`standard`:null:null}function br(e){return e instanceof Le?`Unlock actions with the mutation token to save a default.`:e instanceof j?e.detail??e.message:e instanceof Error?e.message:String(e)}function xr({open:e,onClose:t,projects:n,seats:r,workspaces:i=[],initialProjectPath:a,initialSeat:o,busy:s=!1,error:c,onCreate:l,runMutation:u=_r}){let d=(0,V.useId)(),f=(0,V.useId)(),p=(0,V.useId)(),m=(0,V.useId)(),h=(0,V.useId)(),g=(0,V.useRef)(null),[_,v]=(0,V.useState)(``),[ee,y]=(0,V.useState)(``),[b,x]=(0,V.useState)(null),[S,C]=(0,V.useState)(``),[w,T]=(0,V.useState)(null),[E,D]=(0,V.useState)([]),[te,O]=(0,V.useState)([]),[re,k]=(0,V.useState)(!1),[A,j]=(0,V.useState)(null),[M,N]=(0,V.useState)(null),[P,ie]=(0,V.useState)(null),[ae,se]=(0,V.useState)(null),[ce,le]=(0,V.useState)(!1),[ue,de]=(0,V.useState)(null),[fe,pe]=(0,V.useState)({status:`idle`}),I=(0,V.useRef)(new Map),L=(0,V.useMemo)(()=>[...n].sort((e,t)=>Number(t.enrolled)-Number(e.enrolled)||e.name.localeCompare(t.name)),[n]),R=(0,V.useRef)({initialProjectPath:a,initialSeat:o,projects:n,seats:r,sortedProjects:L});R.current={initialProjectPath:a,initialSeat:o,projects:n,seats:r,sortedProjects:L},(0,V.useEffect)(()=>{if(!e)return;let{initialProjectPath:t,initialSeat:n,projects:r,seats:i,sortedProjects:a}=R.current,o=t&&r.some(e=>e.path===t)?t:null;v(o??(t?gr:a[0]?.path??gr)),y(o?``:t??``),x(Sr(n??null,i)??nr(i)),C(``),T(null),D([]),j(null),k(!1),O([]),se(null),de(null),le(!1),I.current=new Map},[e]),(0,V.useEffect)(()=>{if(!e)return;let t=!1;return ie(null),Dn().then(e=>{t||N(e)}).catch(e=>{t||(N(null),ie(br(e)))}),()=>{t=!0}},[e]),(0,V.useEffect)(()=>{e&&b===null&&r.length!==0&&x(Sr(o??null,r)??nr(r))},[e,b,r,o]);let me=F(De);(0,V.useEffect)(()=>{e&&me()},[e,me]);let he=(0,V.useMemo)(()=>{let e=new Map;for(let t of i)e.set(t.id,t);for(let t of te)e.has(t.id)||e.set(t.id,t);return[...e.values()]},[i,te]),ge=_.startsWith(hr),_e=ge?_.slice(11):null,z=ge?``:_===gr?ee.trim():_,ve=b===null?null:r.find(e=>e.id===b.seatId)??null,ye=ve===null||b===null?null:It(ve,b.model),be=ve?.health.state===`unavailable`,xe=ve!==null&&ye!==null?en(ve,ye):null,Se=!s&&(ge||z.length>0)&&b!==null&&!be&&ye!==null&&xe===null,Ce=_e===null?null:he.find(e=>e.id===_e)??null,we=b===null?`standard`:vr(M,b.seatId),Te=_n(ye,ae??we),Ee=ne(ye),ke=_n(ye,we),Ae=(0,V.useCallback)((e,t)=>b!==null&&e.id===b.seatId&&t.id===b.model?Te:_n(t,vr(M,e.id)),[b,Te,M]);function je(e){x(e),se(null),de(null)}async function Me(){if(b===null||ve===null)return;let e=Te;le(!0),de(null);try{let t=await u(`Saving ${fn[e]} as the default context mode for ${ve.label}.`,()=>kn({seatId:b.seatId,contextMode:e}).then(e=>({ok:!0,prefs:e}),e=>({ok:!1,error:e})));if(t===null)return;if(!t.ok){de({ok:!1,text:br(t.error)});return}N(t.prefs),se(null),de({ok:!0,text:`New chats on ${ve.label} now start in ${fn[e]}.`})}catch(e){de({ok:!1,text:br(e)})}finally{le(!1)}}let Ne=(0,V.useMemo)(()=>{if(_e!==null)return{key:`w:${_e}`,query:{workspaceId:_e}};if(ge)return null;let e=Et(z,E);if(!e.ok)return null;let[t,...n]=e.roots;return{key:`p:${e.roots.join(`
3
3
  `)}`,query:n.length>0?{projectPath:t,extraRoots:n}:{projectPath:t}}},[_e,ge,z,E]),Pe=(0,V.useRef)(Ne);Pe.current=Ne;let Fe=Ne?.key??null;(0,V.useEffect)(()=>{let t=Pe.current;if(!e||Fe===null||t===null){pe({status:`idle`});return}let n=I.current.get(Fe);if(n){pe({status:`ready`,key:Fe,fit:n});return}let r=!1;pe({status:`loading`,key:Fe});let i=setTimeout(()=>{jn(t.query).then(e=>{I.current.set(Fe,e),r||pe({status:`ready`,key:Fe,fit:e})}).catch(e=>{r||pe({status:`error`,key:Fe,message:br(e)})})},350);return()=>{r=!0,clearTimeout(i)}},[e,Fe]);let Ie=Fe===null?{status:`idle`}:fe.status!==`idle`&&fe.key===Fe?fe:{status:`loading`,key:Fe},Le=Ie.status===`ready`?Ie.fit:null,Re=jt(ve?.engine??null,1+E.length),ze=Ot(ve?.engine??null,Ce?.roots.length??0),Be=lr();async function Ve(){let e=await ur();e!==null&&e.length>0&&(v(gr),y(e))}async function He(e){let t=await ur();t!==null&&t.length>0&&D(E.map((n,r)=>r===e?t:n))}async function Ue(){let e=Et(z,E);if(!e.ok){T(e.error);return}k(!0),T(null),j(null);try{let t=vt(e.roots[0]),n=await Oe({name:t,roots:e.roots});O(e=>[...e,n]),v(`${hr}${n.id}`),j(`Saved. “${n.name}” is in this list from now on.`)}catch(e){T(e instanceof Error?e.message:String(e))}finally{k(!1)}}function We(e){if(e.preventDefault(),!b){T(`Pick a seat first.`);return}if(ye===null){T(`Pick a model this seat offers.`);return}if(xe!==null){T(`${ye.label} cannot run on this seat: ${xe}.`);return}if(_e!==null){T(null);let e={workspaceId:_e,seatId:b.seatId,model:b.model};delete e.projectPath;let t=S.trim();t&&(e.title=t);let n=yr(ye,Te,we);n!==null&&(e.contextMode=n),l(e);return}let t=Et(z,E);if(!t.ok){T(t.error);return}T(null);let[n,...r]=t.roots,i={projectPath:n,seatId:b.seatId,model:b.model};r.length>0&&(i.extraRoots=r);let a=S.trim();a&&(i.title=a);let o=yr(ye,Te,we);o!==null&&(i.contextMode=o),l(i)}let Ge=w??c??null;return(0,H.jsx)(oe,{open:e,onClose:t,titleId:d,title:`New chat`,initialFocusRef:g,widthClassName:W.width,children:(0,H.jsxs)(`form`,{className:W.form,onSubmit:We,noValidate:!0,children:[(0,H.jsxs)(`label`,{className:W.field,htmlFor:f,children:[(0,H.jsx)(`span`,{className:W.label,children:`Project`}),(0,H.jsxs)(`select`,{id:f,ref:g,value:_,onChange:e=>v(e.target.value),className:W.select,children:[he.length>0?(0,H.jsx)(`optgroup`,{label:`Saved projects`,children:he.map(e=>(0,H.jsxs)(`option`,{value:`${hr}${e.id}`,children:[e.name,` — `,Pt(e)]},e.id))}):null,L.map(e=>(0,H.jsxs)(`option`,{value:e.path,children:[e.name,e.enrolled?``:` (recent)`,` — `,e.path]},e.path)),(0,H.jsx)(`option`,{value:gr,children:`Other folder…`})]})]}),_===gr&&!ge?(0,H.jsxs)(`label`,{className:W.field,htmlFor:p,children:[(0,H.jsx)(`span`,{className:W.label,children:`Folder path`}),(0,H.jsxs)(`div`,{className:W.rootRow,children:[(0,H.jsx)(`input`,{id:p,className:W.input,value:ee,onChange:e=>y(e.target.value),placeholder:`/absolute/path/to/project`,autoComplete:`off`,spellCheck:!1}),Be?(0,H.jsx)(`button`,{type:`button`,className:W.addRoot,onClick:()=>void Ve(),children:`Choose folder…`}):null]})]}):null,ze?(0,H.jsx)(`p`,{className:W.hint,children:ze}):null,ge?null:(0,H.jsxs)(`div`,{className:W.field,children:[(0,H.jsxs)(`span`,{className:W.label,children:[`Also include `,(0,H.jsx)(`span`,{className:W.optional,children:`optional`})]}),E.map((e,t)=>(0,H.jsxs)(`div`,{className:W.rootRow,children:[(0,H.jsx)(`input`,{className:W.input,value:e,onChange:e=>D(E.map((n,r)=>r===t?e.target.value:n)),placeholder:`/absolute/path/to/another/folder`,"aria-label":`Additional folder ${t+1}`,autoComplete:`off`,spellCheck:!1}),Be?(0,H.jsx)(`button`,{type:`button`,className:W.removeRoot,onClick:()=>void He(t),"aria-label":`Choose additional folder ${t+1}`,children:`Choose folder…`}):null,(0,H.jsx)(`button`,{type:`button`,className:W.removeRoot,onClick:()=>D(E.filter((e,n)=>n!==t)),"aria-label":`Remove additional folder ${t+1}`,children:`Remove`})]},t)),E.length+1<8?(0,H.jsx)(`button`,{type:`button`,className:W.addRoot,onClick:()=>D([...E,``]),children:`Add a folder`}):null,Re?(0,H.jsx)(`p`,{className:W.hint,children:Re}):null,(0,H.jsxs)(`div`,{className:W.rootRow,children:[(0,H.jsx)(`button`,{type:`button`,className:W.addRoot,onClick:()=>void Ue(),disabled:re||z.length===0,children:re?`Saving…`:`Save as a project`}),(0,H.jsx)(`span`,{className:W.hint,children:`Keeps these folders in the list above. No chat needed first.`})]})]}),A?(0,H.jsx)(`p`,{role:`status`,className:W.hint,children:A}):null,(0,H.jsx)(ar,{id:h,seats:r,value:b,onChange:je,workingSetTokens:Le?.totalEstTokens??null,modeFor:Ae}),ve===null?null:(0,H.jsx)($n,{seat:ve,className:W.capacity}),ve===null||ye===null?null:(0,H.jsx)(Cr,{seat:ve,option:ye,unavailableReason:xe,mode:Te,offersModes:Ee,savedDefault:ke,prefsLoaded:M!==null,prefsError:P,onMode:e=>{se(e),de(null)},savingDefault:ce,defaultNote:ue,onMakeDefault:()=>void Me(),fitState:Ie}),r.length===0?(0,H.jsx)(`p`,{className:W.hint,children:`No seats yet — connect an account or start Ollama, then reload.`}):null,(0,H.jsxs)(`label`,{className:W.field,htmlFor:m,children:[(0,H.jsxs)(`span`,{className:W.label,children:[`Title `,(0,H.jsx)(`span`,{className:W.optional,children:`optional`})]}),(0,H.jsx)(`input`,{id:m,className:W.input,value:S,onChange:e=>C(e.target.value),placeholder:`Defaults to your first message`,maxLength:120})]}),Ge?(0,H.jsx)(`p`,{role:`alert`,className:W.error,children:Ge}):null,(0,H.jsxs)(`div`,{className:W.actions,children:[(0,H.jsx)(`button`,{type:`button`,className:W.cancel,onClick:t,children:`Cancel`}),(0,H.jsx)(`button`,{type:`submit`,className:W.create,disabled:!Se,children:s?`Creating…`:`Start chat`})]})]})})}function Sr(e,t){if(e===null)return null;let n=t.find(t=>t.id===e.seatId),r=It(n,e.model);return r===null?e:{seatId:e.seatId,model:r.id}}function Cr({seat:e,option:t,unavailableReason:n,mode:r,offersModes:i,savedDefault:a,prefsLoaded:o,prefsError:s,onMode:c,savingDefault:l,defaultNote:u,onMakeDefault:d,fitState:f}){let p=(0,V.useId)(),m=Yt(t,r),h=Xt(e),g=gn(e),_=f.status===`ready`?tn(f.fit.totalEstTokens,t,r,e.engine):null;return(0,H.jsxs)(`div`,{className:W.context,role:`group`,"aria-labelledby":p,children:[(0,H.jsxs)(`div`,{className:W.contextHead,children:[(0,H.jsx)(`span`,{id:p,className:W.label,children:`Context`}),(0,H.jsx)(`span`,{className:W.contextBudget,children:m===null?`Window unknown`:`${B(m.contextWindow)} window${m.autoCompactAt===null?``:` · compacts ≈${B(m.autoCompactAt)}`}`})]}),m!==null&&t.windowSource?(0,H.jsxs)(`p`,{className:W.hint,children:[`Window `,it[t.windowSource],`.`]}):null,n===null?null:(0,H.jsxs)(`p`,{className:W.warn,children:[t.label,` cannot run on this seat: `,n,`. Pick another model.`]}),i?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(L,{"aria-label":`Context mode`,size:`sm`,value:r,onChange:c,options:[`standard`,`expansive`].map(e=>{let n=k(t,e);return{value:e,label:n===null?fn[e]:`${fn[e]} · ≈${B(n.autoCompactAt??n.contextWindow)}`,ariaLabel:fn[e]}})}),(0,H.jsx)(`p`,{className:W.hint,children:nn(e.engine,t,r)}),o&&r!==a?(0,H.jsx)(`div`,{className:W.rootRow,children:(0,H.jsx)(`button`,{type:`button`,className:W.addRoot,onClick:d,disabled:l,children:l?`Saving…`:`Make ${fn[r]} the default for ${e.label}`})}):null,u===null?null:(0,H.jsx)(`p`,{role:u.ok?`status`:`alert`,className:u.ok?W.hint:W.error,children:u.text}),s===null?null:(0,H.jsxs)(`p`,{className:W.hint,children:[`Saved defaults could not be read (`,s,`); this chat starts in `,fn[r],` unless you pick otherwise.`]})]}):(0,H.jsx)(`p`,{className:W.hint,children:Jt(e.engine,t)}),(0,H.jsx)(`div`,{className:W.fit,"aria-live":`polite`,children:f.status===`idle`?null:f.status===`loading`?(0,H.jsx)(`p`,{className:W.hint,children:`Sizing the chosen folders…`}):f.status===`error`?(0,H.jsxs)(`p`,{className:W.hint,children:[`Could not size the chosen folders: `,f.message]}):_===null?(0,H.jsxs)(`p`,{className:W.hint,children:[`~`,B(f.fit.totalEstTokens),` tokens of tracked code; this model’s budget is unknown, so no fit is claimed.`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`p`,{className:W.fitLine,children:[(0,H.jsx)(`span`,{className:W.fitBadge,"data-fit":_,children:sn[_]}),(0,H.jsx)(`span`,{children:Zt({verdict:_,tokens:f.fit.totalEstTokens,option:t,mode:r,floor:an(f.fit)})})]}),(0,H.jsx)(`p`,{className:W.hint,children:pn(e.engine)})]})}),h===null&&g.length===0?null:(0,H.jsxs)(`ul`,{className:W.seatFacts,"aria-label":`${e.label} facts`,children:[h===null?null:(0,H.jsxs)(`li`,{children:[`Runs `,h,`.`]}),g.map(e=>(0,H.jsx)(`li`,{children:e},e))]})]})}var wr={width:`_width_k2wwr_1`,input:`_input_k2wwr_3`,list:`_list_k2wwr_19`,row:`_row_k2wwr_27`,rowActive:`_rowActive_k2wwr_41`,marker:`_marker_k2wwr_44`,"engine-claude":`_engine-claude_k2wwr_45`,"engine-codex":`_engine-codex_k2wwr_46`,"engine-grok":`_engine-grok_k2wwr_47`,"engine-local":`_engine-local_k2wwr_48`,rowText:`_rowText_k2wwr_50`,rowPrimary:`_rowPrimary_k2wwr_51`,rowSecondary:`_rowSecondary_k2wwr_58`,rowTrailing:`_rowTrailing_k2wwr_67`,emptyRow:`_emptyRow_k2wwr_76`};function Tr({open:e,onClose:t,sessions:n,seats:r,projects:i,onSelectSession:a,onNewChat:o}){let s=(0,V.useId)(),c=(0,V.useId)(),l=(0,V.useRef)(null),[u,d]=(0,V.useState)(``),[f,p]=(0,V.useState)(0);(0,V.useEffect)(()=>{e&&(d(``),p(0))},[e]);let m=(0,V.useMemo)(()=>{let e=u.trim().toLowerCase(),s=[...n].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)).map(e=>({id:`session:${e.id}`,kind:`session`,engine:e.engine,primary:e.title||`Untitled chat`,secondary:`${nt(e.projectPath,i)} · ${gt(r,e)} · ${e.model}`,trailing:at(e.updatedAt),run:()=>{a(e.id),t()}})),c=r.filter(e=>e.health.state!==`unavailable`&&e.models.length>0).map(e=>({id:`seat:${e.id}`,kind:`seat`,engine:e.engine,primary:`New chat on ${e.label}`,secondary:e.models[0].label,trailing:`⌘N`,run:()=>{o({seatId:e.id,model:e.models[0].id}),t()}})),l=[...s,...c];return e?l.filter(t=>t.primary.toLowerCase().includes(e)||t.secondary.toLowerCase().includes(e)):l},[u,n,r,i,a,o,t]);(0,V.useEffect)(()=>{f>=m.length&&p(0)},[m.length,f]);function h(e){e.key===`ArrowDown`?(e.preventDefault(),p(e=>m.length?(e+1)%m.length:0)):e.key===`ArrowUp`?(e.preventDefault(),p(e=>m.length?(e-1+m.length)%m.length:0)):e.key===`Enter`&&(e.preventDefault(),m[f]?.run())}return(0,H.jsxs)(oe,{open:e,onClose:t,titleId:s,title:`Switch chat`,initialFocusRef:l,widthClassName:wr.width,children:[(0,H.jsx)(`input`,{ref:l,className:wr.input,value:u,placeholder:`Search chats or start one on a seat…`,role:`combobox`,"aria-expanded":`true`,"aria-controls":c,"aria-activedescendant":m[f]?`${c}-${f}`:void 0,"aria-autocomplete":`list`,autoComplete:`off`,onChange:e=>{d(e.target.value),p(0)},onKeyDown:h}),(0,H.jsx)(`ul`,{id:c,role:`listbox`,className:wr.list,"aria-label":`Chats and seats`,children:m.length===0?(0,H.jsx)(`li`,{className:wr.emptyRow,children:`Nothing matches.`}):m.map((e,t)=>(0,H.jsxs)(`li`,{id:`${c}-${t}`,role:`option`,"aria-selected":t===f,className:`${wr.row} ${wr[`engine-${e.engine}`]??``} ${t===f?wr.rowActive:``}`,"data-kind":e.kind,onMouseEnter:()=>p(t),onMouseDown:e=>e.preventDefault(),onClick:e.run,children:[(0,H.jsx)(`span`,{className:wr.marker,"aria-hidden":`true`}),(0,H.jsxs)(`span`,{className:wr.rowText,children:[(0,H.jsx)(`span`,{className:wr.rowPrimary,children:e.primary}),(0,H.jsx)(`span`,{className:wr.rowSecondary,children:e.secondary})]}),(0,H.jsx)(`span`,{className:wr.rowTrailing,"aria-hidden":`true`,children:e.trailing})]},e.id))})]})}var Er=12e3,Dr=[`This conversation is about to continue in a fresh session that has none of its context.`,`Write the handoff note that new session should start from. Do not edit files or run commands for this — only write the note.`,``,`Cover, concretely:`,`- The goal, and what "done" looks like.`,`- Decisions made so far, each with the reason it was made.`,`- Current state: what is finished, what is half-done, what is untested.`,`- Files changed and anything not yet committed.`,`- How to verify the work (exact commands).`,`- Open questions, risks, and approaches already tried that did not work.`,``,`Keep it under 600 words. Prefer file paths and commands over prose.`].join(`
4
4
  `),Or=65536,kr=139264,Ar=6144,jr=/\s·\spart\s(\d+)$/;function Mr(e){let t=e.replace(/\s+/g,` `).trim(),n=jr.exec(t),r=(n?t.slice(0,n.index):t)||`Untitled chat`,i=` · part ${n?Number.parseInt(n[1],10)+1:2}`,a=120-i.length;return`${r.length>a?`${r.slice(0,a-1).trimEnd()}…`:r}${i}`}function Nr(e,t){if(!e)return null;let n=e.models.find(e=>e.id===t);if(n)return n;let r=v(t);return e.models.find(e=>v(e.id)===r)??null}function Pr(e,t){return e?e.health.state===`unavailable`?`${e.label} is unavailable: ${e.health.summary??`no reason given`}.`:t?t.unavailableReason?`${t.label} cannot run on ${e.label}: ${t.unavailableReason}.`:null:`Pick a model on this seat.`:`Pick a seat to continue on.`}function Fr(e,t){let n=e.find(e=>e.id===t.seatId);if(n&&n.health.state!==`unavailable`){let e=Nr(n,t.model);if(e&&!e.unavailableReason)return{seatId:n.id,model:e.id};let r=n.models.find(e=>!e.unavailableReason);if(r)return{seatId:n.id,model:r.id}}for(let t of e){if(t.health.state===`unavailable`)continue;let e=t.models.find(e=>!e.unavailableReason);if(e)return{seatId:t.id,model:e.id}}return null}function Ir(e){let{option:t,target:n,source:r,preferences:i}=e,a=e=>e!==void 0&&k(t,e)!==null;if(n!==null&&n.seatId===r.seatId&&v(n.model)===v(r.model)&&a(r.contextMode??`standard`))return r.contextMode??`standard`;let o=n?i?.seats[n.seatId]?.contextMode:void 0;return a(o)?o:`standard`}function Lr(e,t){return k(e,t)===null?void 0:t}function Rr(e,t){let n=k(e,t);if(!n)return null;let r=`${B(n.contextWindow)} window`;return n.autoCompactAt===null?r:`${r} · compacts ≈${B(n.autoCompactAt)}`}function zr(e,t,n,r){let i=p(e),a=b(r),o=i+a,s=T(i,t,a),c=`~${B(i)} tokens of handoff + an estimated ~${B(a)} of fixed prompt`,l=k(t,`standard`),u=l?l.autoCompactAt??l.contextWindow:null,d={verdict:s,handoffTokens:i,overheadTokens:a,needTokens:o};switch(s){case`fits`:return{...d,tone:`ok`,text:`Fits: ${c} leaves most of the budget before the first compaction.`};case`tight`:return{...d,tone:`warn`,text:`Tight: ${c} is ${Math.round(o/(u??o)*100)}% of where this model compacts — the new chat will compact early.`};case`expansive`:return n===`expansive`?{...d,tone:`warn`,text:`Fits only the expansive budget: ${c}.`}:{...d,tone:`danger`,text:`Too big for the standard budget (${c}). Switch to Expansive, or trim the handoff.`};case`split`:return{...d,tone:`danger`,text:`Too big for one context on this model (${c}). Trim the handoff or pick a seat with a larger window.`};default:return{...d,verdict:null,tone:`unknown`,text:`This model’s window is not known, so there is no fit estimate.`}}}function Br(e){return ne(e)}function Vr(e,t){return e===`local`?`Runs on this machine with ${t}; it spends no subscription usage.`:`Sends one turn to ${t} and spends from its usage. The automatic preview costs nothing.`}var Hr=typeof TextEncoder==`function`?new TextEncoder:null;function Ur(e){if(Hr)return Hr.encode(e).length;let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=e<128?1:e<2048?2:e<65536?3:4}return t}var Wr=kr;function Gr(e){return Ur(JSON.stringify(e)??``)}function Kr(e){if(!Number.isFinite(e)||e<0)return`—`;if(e<1024)return`${e} B`;let t=e/1024;return`${t<10?t.toFixed(1).replace(/\.0$/,``):Math.round(t)} KB`}function qr(e,t=Date.now()){if(!e)return null;let n=at(e,t);return n?n===`now`?`just now`:/^\d/.test(n)?`${n} ago`:`on ${n}`:null}var Jr=[{label:`a private key`,re:/-----BEGIN [A-Z ]*PRIVATE KEY-----/},{label:`an Anthropic API key`,re:/\bsk-ant-[A-Za-z0-9_-]{20,}/},{label:`an OpenAI-style API key`,re:/\bsk-(?:proj-)?[A-Za-z0-9_-]{32,}/},{label:`an xAI API key`,re:/\bxai-[A-Za-z0-9]{32,}/},{label:`a GitHub token`,re:/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{30,}|\bgithub_pat_[A-Za-z0-9_]{40,}/},{label:`an AWS access key`,re:/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/},{label:`a Slack token`,re:/\bxox[abprs]-[A-Za-z0-9-]{10,}/},{label:`a Google API key`,re:/\bAIza[0-9A-Za-z_-]{35}\b/},{label:`a Stripe secret key`,re:/\b(?:sk|rk)_live_[0-9A-Za-z]{20,}/}],Yr=Ar,Xr=`Reading and editing memory here spends nothing. On a paid seat it is not free to use: each new chat’s system prompt carries a memory block of up to ${Yr/1024} KB, re-sent every turn (cached after the first), and the agent reads and updates MEMORY.md as it works. Local seats spend nothing.`;function Zr(e){for(let{label:t,re:n}of Jr)if(n.test(e))return t;return null}var Qr=`[REDACTED]`;function $r(e){return e.split(Qr).length-1}function ei(e){let t=[];for(let n of e.toLowerCase().split(/\s+/))n&&!t.includes(n)&&t.push(n);return t}function ti(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ni(e,t){let n=[...t].filter(e=>e.length>0).sort((e,t)=>t.length-e.length);if(n.length===0||e.length===0)return e?[{text:e,match:!1}]:[];let r=new RegExp(n.map(ti).join(`|`),`gi`),i=[],a=0;for(let t of e.matchAll(r)){let n=t.index??0;t[0].length!==0&&(n>a&&i.push({text:e.slice(a,n),match:!1}),i.push({text:t[0],match:!0}),a=n+t[0].length)}return a<e.length&&i.push({text:e.slice(a),match:!1}),i}function ri(e){let t=new Map;for(let n of e){let e=t.get(n.sessionId);if(!e){t.set(n.sessionId,{sessionId:n.sessionId,title:n.title,projectPath:n.projectPath,engine:n.engine,top:n,count:1,latestAt:n.at});continue}e.count+=1,n.at>e.latestAt&&(e.latestAt=n.at)}return[...t.values()]}function ii(){let[e,t]=(0,V.useState)({open:!1,reason:``}),n=(0,V.useRef)(null),r=(0,V.useCallback)((e,r)=>f()?r():(n.current?.cancel(),new Promise((i,a)=>{n.current={run:()=>{r().then(i,a)},cancel:()=>i(null)},t({open:!0,reason:e})})),[]),i=(0,V.useCallback)(()=>{t({open:!1,reason:``});let e=n.current;e&&setTimeout(()=>{n.current===e&&(n.current=null,e.cancel())},0)},[]),a=(0,V.useCallback)(()=>{let e=n.current;n.current=null,e?.run()},[]);return{run:r,dialog:{open:e.open,reason:e.reason,onClose:i,onUnlocked:a}}}function ai(e){return e instanceof S?"This server is read-only (started without dispatch — run `ashlr verse`), or older than this console.":e instanceof Le?`Unlock actions with the mutation token first.`:e instanceof j?e.status===401?"The mutation token was rejected. Unlock again with the token `ashlr verse` printed.":e.code===`VERSE_SESSION_NOT_FOUND`?`This chat no longer exists on the server — it may have been deleted. Refresh the chat list.`:e.detail?e.detail:e.status===404?"This server does not have that route yet — update Ashlr and restart `ashlr verse`.":e.status===409?`A turn is already running in this chat. Wait for it or stop it first.`:e.message:e instanceof Error&&e.message?e.message:`Something went wrong.`}var G={label:`_label_1j3uu_14`,optional:`_optional_1j3uu_23`,field:`_field_1j3uu_25`,row:`_row_1j3uu_26`,input:`_input_1j3uu_27`,textarea:`_textarea_1j3uu_30`,hint:`_hint_1j3uu_59`,locked:`_locked_1j3uu_61`,warn:`_warn_1j3uu_62`,error:`_error_1j3uu_70`,primary:`_primary_1j3uu_80`,secondary:`_secondary_1j3uu_81`,cancel:`_cancel_1j3uu_82`,link:`_link_1j3uu_109`,small:`_small_1j3uu_121`,pending:`_pending_1j3uu_124`,"context-pulse":`_context-pulse_1j3uu_1`,dialogWidth:`_dialogWidth_1j3uu_145`,form:`_form_1j3uu_146`,aside:`_aside_1j3uu_150`,fit:`_fit_1j3uu_172`,"fit-ok":`_fit-ok_1j3uu_180`,"fit-warn":`_fit-warn_1j3uu_181`,"fit-danger":`_fit-danger_1j3uu_182`,"fit-unknown":`_fit-unknown_1j3uu_183`,cost:`_cost_1j3uu_185`,actions:`_actions_1j3uu_192`,blocked:`_blocked_1j3uu_193`,memory:`_memory_1j3uu_207`,memoryHead:`_memoryHead_1j3uu_215`,memoryState:`_memoryState_1j3uu_228`,memoryHeadAction:`_memoryHeadAction_1j3uu_229`,memoryBody:`_memoryBody_1j3uu_242`,memoryMeta:`_memoryMeta_1j3uu_257`,memoryFiles:`_memoryFiles_1j3uu_258`,memoryActions:`_memoryActions_1j3uu_265`,spacer:`_spacer_1j3uu_266`,danger:`_danger_1j3uu_267`,counter:`_counter_1j3uu_269`,counterOver:`_counterOver_1j3uu_270`,search:`_search_1j3uu_276`,searchBox:`_searchBox_1j3uu_277`,searchHead:`_searchHead_1j3uu_284`,searchCount:`_searchCount_1j3uu_298`,searchNote:`_searchNote_1j3uu_304`,searchError:`_searchError_1j3uu_305`,hits:`_hits_1j3uu_315`,hit:`_hit_1j3uu_315`,hitMarker:`_hitMarker_1j3uu_332`,hitTitle:`_hitTitle_1j3uu_339`,hitTime:`_hitTime_1j3uu_348`,hitSnippet:`_hitSnippet_1j3uu_355`,hitWho:`_hitWho_1j3uu_365`,"engine-claude":`_engine-claude_1j3uu_374`,"engine-codex":`_engine-codex_1j3uu_375`,"engine-grok":`_engine-grok_1j3uu_376`,"engine-local":`_engine-local_1j3uu_377`};function oi({projectPath:e,refreshKey:t}){let n=(0,V.useId)();return e?(0,H.jsx)(di,{projectPath:e,refreshKey:t},e):(0,H.jsxs)(`section`,{className:G.memory,"aria-labelledby":n,children:[(0,H.jsx)(`h3`,{id:n,className:G.memoryHead,children:`Project memory`}),(0,H.jsx)(`p`,{className:G.hint,children:`Open a chat to see the memory its project shares across seats.`})]})}var si=`Saving writes MEMORY.md for this project. Every seat on it reads this file.`,ci=`Clearing empties MEMORY.md for every chat on this project.`,li=`This changes whether new chats on this project are given shared memory.`,ui=`This changes whether new chats on ANY project are given shared memory.`;function di({projectPath:e,refreshKey:t}){let n=(0,V.useId)(),r=(0,V.useId)(),i=(0,V.useId)(),a=(0,V.useMemo)(()=>Fn(e),[e]),o=ie(a),s=x(a),c=ie(On),l=ii(),u=nt(e),[d,f]=(0,V.useState)(`view`),[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(``),[_,v]=(0,V.useState)(!1),[ee,y]=(0,V.useState)(null),[b,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(null),[T,D]=(0,V.useState)(null),te=(0,V.useRef)(null),ne=(0,V.useRef)(t);(0,V.useEffect)(()=>{t!==ne.current&&(ne.current=t,s())},[t,s]),(0,V.useEffect)(()=>{let e=te.current;d===`edit`&&e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[d]);let[O,re]=(0,V.useState)(null);(0,V.useEffect)(()=>{O!==null&&o.status===`success`&&re(null)},[O,o.status]);let k=O!==null&&o.status!==`success`?O:o.data,A=o.error instanceof j&&o.error.status===404,M=c.data?!c.data.memory.enabled:!1,N=(0,V.useMemo)(()=>Ur(p),[p]),P=N>Or,F=(0,V.useMemo)(()=>Gr({projectPath:e,content:p}),[e,p]),ae=!P&&F>Wr,oe=d===`edit`?Zr(p):null,se=d===`edit`&&_?$r(p):0;function le(e,t){m(e),g(e),v(t),y(null),w(null),D(null),f(`edit`)}async function ue(t=!1){if(!b){S(`saving`),w(null);try{let n=await Pn(e);if(!t&&n.content!==h){y(n);return}let r=await l.run(si,()=>In(e,p));if(r===null)return;re(r),y(null),f(`view`),D(r.content.length===0?`Saved — MEMORY.md is now empty.`:`Saved.`)}catch(e){w(ai(e))}finally{S(null)}}}async function de(){if(!b){S(`clearing`),w(null);try{let t=await l.run(ci,()=>In(e,``));if(t===null)return;re(t),f(`view`),D(`Cleared. Agents start MEMORY.md afresh on their next write.`)}catch(e){w(ai(e))}finally{S(null)}}}async function fe(t){if(!b){S(`toggling`),w(null),D(null);try{await l.run(li,()=>kn({projectPath:e,memoryEnabled:t}))!==null&&D(t?`New chats on ${u} will get shared memory. Chats already open keep what they started with.`:`New chats on ${u} will start without shared memory. The file is kept.`)}catch(e){w(ai(e))}finally{S(null)}}}async function pe(e){if(!b){S(`toggling`),w(null),D(null);try{await l.run(ui,()=>kn({memoryEnabled:e}))}catch(e){w(ai(e))}finally{S(null)}}}let I=k?M?`off everywhere`:k.enabled?`on`:`off`:null;return(0,H.jsxs)(`section`,{className:G.memory,"aria-labelledby":n,"data-project":e,children:[(0,H.jsxs)(`h3`,{id:n,className:G.memoryHead,children:[(0,H.jsx)(`span`,{children:`Project memory`}),I?(0,H.jsx)(`span`,{className:G.memoryState,children:I}):null,A?null:(0,H.jsx)(`button`,{type:`button`,className:G.memoryHeadAction,onClick:s,"aria-label":`Refresh project memory`,children:`Refresh`})]}),(0,H.jsxs)(`p`,{className:G.hint,children:[`One `,(0,H.jsx)(`code`,{children:`MEMORY.md`}),` shared by every chat on `,(0,H.jsx)(`strong`,{children:u}),`, whichever seat runs it. Agents keep it current — decisions and why, conventions, gotchas, plan status.`]}),A?(0,H.jsxs)(`p`,{className:G.hint,children:[`This server has no project memory yet — update Ashlr and restart `,(0,H.jsx)(`code`,{children:`ashlr verse`}),`.`]}):o.status===`loading`||o.status===`idle`&&!k?(0,H.jsxs)(`div`,{"aria-busy":`true`,children:[(0,H.jsx)(E,{width:`80%`}),(0,H.jsx)(E,{width:`60%`}),(0,H.jsx)(E,{width:`70%`})]}):k?(0,H.jsxs)(H.Fragment,{children:[M?(0,H.jsxs)(`div`,{className:G.field,children:[(0,H.jsx)(`p`,{className:G.hint,children:`Shared memory is off for every project, so new chats start without it.`}),(0,H.jsx)(`div`,{className:G.memoryActions,children:(0,H.jsx)(`button`,{type:`button`,className:`${G.secondary} ${G.small}`,disabled:b!==null,onClick:()=>void pe(!0),children:`Turn memory on`})})]}):(0,H.jsx)(R,{checked:k.enabled,disabled:b!==null||!c.data,onChange:e=>void fe(e),label:`Give new chats on ${u} this memory`}),d===`edit`?(0,H.jsxs)(`div`,{className:G.field,children:[(0,H.jsx)(`label`,{className:G.label,htmlFor:r,children:`Edit MEMORY.md`}),(0,H.jsx)(`textarea`,{id:r,ref:te,className:G.textarea,value:p,rows:12,spellCheck:!1,"aria-describedby":i,"aria-invalid":P||ae?!0:void 0,onChange:e=>m(e.target.value)}),(0,H.jsxs)(`p`,{id:i,className:`${G.hint} ${G.counter} ${P||ae?G.counterOver:``}`,children:[Kr(N),` of `,Kr(Or),P?` — over the limit; trim it to save.`:``,ae?` — ${Kr(F)} once line breaks and quotes are encoded for sending, over the ${Kr(Wr)} request limit; trim it to save.`:``]}),oe?(0,H.jsxs)(`p`,{className:G.warn,role:`alert`,children:[`This looks like it contains `,oe,`. MEMORY.md is sent to every seat’s model — remove it before saving.`]}):null,se>0?(0,H.jsxs)(`p`,{className:G.warn,role:`alert`,children:[se===1?`One`:se,` `,(0,H.jsx)(`code`,{children:Qr}),` placeholder`,se===1?` stands`:`s stand`,` in for secret-looking text that is still in MEMORY.md. Saving `,se===1?`it`:`them`,` would replace the real value`,se===1?``:`s`,`, so Save stays off until `,se===1?`it is`:`they are`,` gone. Deleting a placeholder drops that value from the file; to keep it, edit MEMORY.md directly under `,(0,H.jsx)(`code`,{children:`~/.ashlr/verse/memory`}),`.`]}):_?(0,H.jsxs)(`p`,{className:G.hint,children:[`This copy was sanitized for the browser, so a home-folder path appears as `,(0,H.jsx)(`code`,{children:`~`}),`. Saving writes the text as shown; `,(0,H.jsx)(`code`,{children:`~`}),` names the same folder for every reader.`]}):null,ee?(0,H.jsxs)(`div`,{className:G.warn,role:`alert`,children:[(0,H.jsxs)(`p`,{className:G.hint,children:[`An agent changed MEMORY.md while you were editing`,qr(ee.updatedAt)?` (${qr(ee.updatedAt)})`:``,`.`]}),(0,H.jsxs)(`div`,{className:G.memoryActions,children:[(0,H.jsx)(`button`,{type:`button`,className:`${G.secondary} ${G.small}`,disabled:b!==null||se>0,onClick:()=>void ue(!0),children:`Overwrite with mine`}),(0,H.jsx)(`button`,{type:`button`,className:`${G.cancel} ${G.small}`,disabled:b!==null,onClick:()=>le(ee.content,ee.contentSanitized===!0),children:`Start over from theirs`})]})]}):null,(0,H.jsxs)(`div`,{className:G.memoryActions,children:[(0,H.jsx)(`button`,{type:`button`,className:`${G.primary} ${G.small}`,disabled:b!==null||P||ae||p===h||ee!==null||se>0,onClick:()=>void ue(!1),children:b===`saving`?`Saving…`:`Save`}),(0,H.jsx)(`button`,{type:`button`,className:`${G.cancel} ${G.small}`,disabled:b===`saving`,onClick:()=>{f(`view`),y(null),w(null)},children:`Cancel`})]})]}):k.content.length===0?(0,H.jsxs)(`div`,{className:G.field,children:[(0,H.jsx)(`p`,{className:G.hint,children:`MEMORY.md is empty. Agents add to it as they work, or write the first entries yourself.`}),(0,H.jsx)(`div`,{className:G.memoryActions,children:(0,H.jsx)(`button`,{type:`button`,className:`${G.secondary} ${G.small}`,onClick:()=>le(``,!1),children:`Write it`})})]}):(0,H.jsxs)(`div`,{className:G.field,children:[(0,H.jsx)(`pre`,{className:G.memoryBody,tabIndex:0,"aria-label":`MEMORY.md for ${u}`,children:k.content}),(0,H.jsxs)(`p`,{className:`${G.hint} ${G.memoryMeta}`,children:[(0,H.jsx)(`span`,{children:Kr(k.bytes)}),qr(k.updatedAt)?(0,H.jsxs)(`span`,{children:[`updated `,qr(k.updatedAt)]}):null]}),k.contentSanitized?(0,H.jsxs)(`p`,{className:G.hint,children:[`Shown sanitized for the browser: a home-folder path appears as `,(0,H.jsx)(`code`,{children:`~`}),` and secret-looking text as`,` `,(0,H.jsx)(`code`,{children:Qr}),`.`,$r(k.content)>0?` The real values are still in the file.`:``]}):null,d===`confirm-clear`?(0,H.jsxs)(`div`,{className:G.warn,role:`alert`,children:[(0,H.jsxs)(`p`,{className:G.hint,children:[`Clear MEMORY.md for `,u,`? Every chat on this project loses what it says. Other files in the folder stay.`]}),(0,H.jsxs)(`div`,{className:G.memoryActions,children:[(0,H.jsx)(`button`,{type:`button`,className:`${G.secondary} ${G.small} ${G.danger}`,disabled:b!==null,onClick:()=>void de(),children:b===`clearing`?`Clearing…`:`Clear it`}),(0,H.jsx)(`button`,{type:`button`,className:`${G.cancel} ${G.small}`,onClick:()=>f(`view`),children:`Keep`})]})]}):(0,H.jsxs)(`div`,{className:G.memoryActions,children:[(0,H.jsx)(`button`,{type:`button`,className:`${G.secondary} ${G.small}`,onClick:()=>le(k.content,k.contentSanitized===!0),children:`Edit`}),(0,H.jsx)(`button`,{type:`button`,className:`${G.cancel} ${G.small}`,onClick:()=>{D(null),f(`confirm-clear`)},children:`Clear…`})]})]}),k.files.length>0?(0,H.jsxs)(`div`,{className:G.field,children:[(0,H.jsx)(`span`,{className:G.label,children:`Also in this folder`}),(0,H.jsx)(`ul`,{className:G.memoryFiles,children:k.files.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(`code`,{children:e})},e))})]}):null,T?(0,H.jsx)(`p`,{className:G.hint,role:`status`,children:T}):null,C?(0,H.jsx)(`p`,{className:G.error,role:`alert`,children:C}):null,(0,H.jsxs)(`details`,{children:[(0,H.jsx)(`summary`,{className:G.hint,children:`How project memory works`}),(0,H.jsxs)(`div`,{className:G.field,children:[(0,H.jsx)(`p`,{className:G.hint,children:`Claude, Codex and local seats can read and edit the file. Grok’s CLI can reach only its working folder, so a Grok seat is given the text and can only read it.`}),(0,H.jsx)(`p`,{className:G.hint,children:`A chat copies the memory into its instructions when it starts, so every turn re-sends the same prefix and the provider’s prompt cache keeps working. Chats already open see your edits when they next read the file; the switch above applies to new chats.`}),(0,H.jsxs)(`p`,{className:G.hint,children:[`It lives on this machine under `,(0,H.jsx)(`code`,{children:`~/.ashlr/verse/memory`}),`, readable only by you. It is sent to every seat’s model, so never put secrets in it.`]}),(0,H.jsx)(`p`,{className:G.hint,children:Xr}),M?null:(0,H.jsxs)(`p`,{className:G.hint,children:[`Memory is on for every project unless switched off per project.`,` `,(0,H.jsx)(`button`,{type:`button`,className:G.link,disabled:b!==null,onClick:()=>void pe(!1),children:`Turn it off for every project`})]})]})]})]}):(0,H.jsxs)(`div`,{className:G.searchError,role:`alert`,children:[(0,H.jsxs)(`span`,{children:[`Could not read this project’s memory: `,ai(o.error)]}),(0,H.jsx)(`button`,{type:`button`,className:`${G.secondary} ${G.small}`,onClick:s,children:`Retry`})]}),(0,H.jsx)(ce,{open:l.dialog.open,reason:l.dialog.reason,tokenLabel:`Mutation token`,tokenHelp:`the mutation token ashlr verse printed`,onClose:l.dialog.onClose,onUnlocked:l.dialog.onUnlocked})]})}var fi={roots:`_roots_afeac_8`,title:`_title_afeac_10`,count:`_count_afeac_22`,workspace:`_workspace_afeac_30`,list:`_list_afeac_36`,root:`_root_afeac_8`,rootHead:`_rootHead_afeac_57`,name:`_name_afeac_64`,badge:`_badge_afeac_72`,path:`_path_afeac_84`,git:`_git_afeac_97`,remote:`_remote_afeac_98`,caveat:`_caveat_afeac_99`,note:`_note_afeac_116`,error:`_error_afeac_117`};function pi({session:e,refreshKey:t=0}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),o=e?.id??null;return(0,V.useEffect)(()=>{if(!o){r(null);return}let e=new AbortController;return a(null),Fe(o,e.signal).then(e=>r(e)).catch(t=>{e.signal.aborted||(r(null),a(t instanceof Error?t.message:`could not read this chat’s folders`))}),()=>e.abort()},[o,t]),!e||n!==null&&n.roots.length<=1&&n.workspaceId===null?null:(0,H.jsxs)(`section`,{className:fi.roots,"aria-labelledby":`verse-res-roots`,children:[(0,H.jsxs)(`h3`,{id:`verse-res-roots`,className:fi.title,children:[`Folders`,n?(0,H.jsx)(`span`,{className:fi.count,children:n.roots.length}):null]}),n?.workspaceName?(0,H.jsxs)(`p`,{className:fi.workspace,children:[`Workspace `,(0,H.jsx)(`strong`,{children:n.workspaceName})]}):null,i?(0,H.jsx)(`p`,{role:`alert`,className:fi.error,children:i}):null,(0,H.jsx)(`ul`,{className:fi.list,children:(n?.roots??[]).map(e=>{let t=bt(e),n=Nt(e);return(0,H.jsxs)(`li`,{className:fi.root,"data-tone":kt(e),children:[(0,H.jsxs)(`div`,{className:fi.rootHead,children:[(0,H.jsx)(`span`,{className:fi.name,children:e.name}),(0,H.jsx)(`span`,{className:fi.badge,children:e.primary?`primary`:`added`})]}),(0,H.jsx)(`p`,{className:fi.path,children:e.path}),(0,H.jsx)(`p`,{className:fi.git,children:t??`not a git repo`}),e.git?.remote?(0,H.jsx)(`p`,{className:fi.remote,children:e.git.remote}):null,n?(0,H.jsx)(`p`,{className:fi.caveat,children:n}):null]},e.path)})}),(n?.notes??[]).map(e=>(0,H.jsx)(`p`,{className:fi.note,children:e},e))]})}var mi=`ashlr.verse.resources.v1`,hi=80,gi=200;function _i(){return{collapsedGroups:[],seats:{}}}function vi(e){return e!==`blocked`}function yi(e,t){return!e.collapsedGroups.includes(t)}function bi(e,t,n){let r=e.seats[t];return typeof r==`boolean`?r:vi(n)}function xi(e,t){let n=e.collapsedGroups.includes(t)?e.collapsedGroups.filter(e=>e!==t):[...e.collapsedGroups,t];return{...e,collapsedGroups:n}}function Si(e,t,n){if(!wi(t))return e;let r={...e.seats,[t]:!bi(e,t,n)};return{...e,seats:Ti(r)}}function Ci(e){return e.kind===`local`?[]:e.binding===null?[...e.others]:[e.binding,...e.others.filter(t=>t.id!==e.binding.id)]}function wi(e){return e.length>0&&e.length<=gi&&e!==`__proto__`&&e!==`constructor`&&e!==`prototype`}function Ti(e){let t=Object.entries(e);return t.length<=hi?{...e}:Object.fromEntries(t.slice(t.length-hi))}function Ei(e){if(e===null||e===``)return _i();let t;try{t=JSON.parse(e)}catch{return _i()}if(!t||typeof t!=`object`||Array.isArray(t))return _i();let n=t,r=[];if(Array.isArray(n.collapsedGroups))for(let e of n.collapsedGroups)typeof e==`string`&&ct(e)&&!r.includes(e)&&r.push(e);let i={},a=n.seats;if(a&&typeof a==`object`&&!Array.isArray(a)){for(let[e,t]of Object.entries(a))if(wi(e)&&typeof t==`boolean`){if(Object.keys(i).length>=hi)break;Object.defineProperty(i,e,{value:t,enumerable:!0,writable:!0,configurable:!0})}}return{collapsedGroups:r,seats:i}}function Di(){try{return Ei(localStorage.getItem(mi))}catch{return _i()}}function Oi(e){try{localStorage.setItem(mi,JSON.stringify({collapsedGroups:e.collapsedGroups,seats:e.seats}))}catch{}}var K={panel:`_panel_1mz40_3`,head:`_head_1mz40_10`,title:`_title_1mz40_22`,close:`_close_1mz40_30`,scroll:`_scroll_1mz40_45`,section:`_section_1mz40_46`,sectionTitle:`_sectionTitle_1mz40_48`,asOf:`_asOf_1mz40_64`,refresh:`_refresh_1mz40_73`,count:`_count_1mz40_89`,skeleton:`_skeleton_1mz40_90`,muted:`_muted_1mz40_91`,engineGroup:`_engineGroup_1mz40_95`,engineTitle:`_engineTitle_1mz40_96`,groupToggle:`_groupToggle_1mz40_105`,seatToggle:`_seatToggle_1mz40_106`,twist:`_twist_1mz40_126`,seatList:`_seatList_1mz40_137`,models:`_models_1mz40_137`,runningList:`_runningList_1mz40_137`,seat:`_seat_1mz40_106`,"engine-claude":`_engine-claude_1mz40_154`,"engine-codex":`_engine-codex_1mz40_155`,"engine-grok":`_engine-grok_1mz40_156`,"engine-local":`_engine-local_1mz40_157`,seatHead:`_seatHead_1mz40_159`,seatLabel:`_seatLabel_1mz40_160`,seatMeta:`_seatMeta_1mz40_169`,seatSummary:`_seatSummary_1mz40_177`,plan:`_plan_1mz40_180`,num:`_num_1mz40_181`,notes:`_notes_1mz40_185`,seatWindows:`_seatWindows_1mz40_202`,credits:`_credits_1mz40_203`,local:`_local_1mz40_206`,mono:`_mono_1mz40_207`,runningRow:`_runningRow_1mz40_220`,runningOpen:`_runningOpen_1mz40_221`,runningMeta:`_runningMeta_1mz40_241`,runningDot:`_runningDot_1mz40_243`,"verse-pulse-res":`_verse-pulse-res_1mz40_1`,runningTitle:`_runningTitle_1mz40_250`,stop:`_stop_1mz40_266`,usage:`_usage_1mz40_281`,subTitle:`_subTitle_1mz40_300`,idleWarn:`_idleWarn_1mz40_313`},ki=3e4;function Ai(e,t=1e3){let[n,r]=(0,V.useState)(()=>Date.now());return(0,V.useEffect)(()=>{if(!e)return;r(Date.now());let n=setInterval(()=>r(Date.now()),t);return()=>clearInterval(n)},[e,t]),n}function ji(e){let t=null;for(let n of e){let e=Gn(n).observedAt;e!==null&&(t===null||e>t)&&(t=e)}return t}function Mi(){let[e,t]=(0,V.useState)(Di),n=e=>{t(t=>{let n=e(t);return Oi(n),n})};return{state:e,toggleGroup:e=>n(t=>xi(t,e)),toggleSeat:(e,t)=>n(n=>Si(n,e.id,t.cls))}}function Ni({seat:e,view:t}){let n=Ci(t),r=qn(e,t),i=e.contextWindow===null?`ctx n/a`:`${B(e.contextWindow)} ctx`,a=e.health.state===`unavailable`?0:e.models.filter(t=>en(e,t)!==null).length,o=`${e.models.length} model${e.models.length===1?``:`s`}${a>0?`, ${a} unavailable`:``}`,s=Xt(e),c=Kn(t.evidenceSource),l=[...gn(e),...t.notes,...c===null?[]:[c]];return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:K.seatMeta,children:[(0,H.jsx)(`span`,{children:ot[e.engine]}),t.plan===null?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,H.jsx)(`span`,{className:K.plan,children:t.plan})]}),(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,H.jsx)(`span`,{children:o}),(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,H.jsx)(`span`,{className:K.num,children:i}),s===null?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,H.jsx)(`span`,{className:K.num,children:s})]})]}),t.kind===`local`||n.length===0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:K.seatSummary,children:t.summary}),t.kind===`local`||e.health.summary===null||e.health.summary===t.summary?null:(0,H.jsx)(`p`,{className:K.seatSummary,children:e.health.summary})]}):(0,H.jsx)(`div`,{className:K.seatWindows,children:n.map(n=>(0,H.jsx)(Qn,{windowView:n,ariaPrefix:e.label,prominent:t.binding?.id===n.id},n.id))}),t.credits===null?null:(0,H.jsx)(`p`,{className:K.credits,title:t.creditsTitle??r,children:t.credits}),l.length===0?null:(0,H.jsx)(`ul`,{className:K.notes,children:l.map(e=>(0,H.jsx)(`li`,{children:e},e))})]})}function Pi({seat:e,open:t,onToggle:n}){let r=Gn(e),i=qn(e,r),a=`verse-seat-${e.id.replace(/[^A-Za-z0-9_-]/g,`-`)}`;return(0,H.jsxs)(`li`,{className:`${K.seat} ${K[`engine-${e.engine}`]??``}`,"data-engine":e.engine,"data-capacity":r.cls,"data-open":t?`true`:`false`,children:[(0,H.jsx)(I,{label:i,placement:`left`,children:(0,H.jsxs)(`button`,{type:`button`,className:K.seatToggle,"aria-expanded":t,"aria-controls":a,"aria-label":e.label,onClick:n,children:[(0,H.jsx)(`span`,{className:K.twist,"data-open":t?``:void 0,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:K.seatLabel,children:e.label}),r.kind===`local`?(0,H.jsx)(re,{status:e.health.state,tone:e.health.state===`ready`?`success`:e.health.state===`unavailable`?`danger`:`unknown`}):(0,H.jsx)(Zn,{view:r})]})}),t?(0,H.jsx)(`div`,{id:a,children:(0,H.jsx)(Ni,{seat:e,view:r})}):(0,H.jsx)(`p`,{id:a,className:K.seatSummary,children:r.summary})]})}function Fi({session:e,seats:t,events:n,now:r}){let i=e.usage,a=hn(e,t),o=qt(n??[]),s=i.inputTokens+i.cacheReadTokens+i.cacheCreationTokens,c=mn(i),l=e.compactionCount??o.compactions,u=$t(e,a.tokens,r,Ht(n??[])),d=a.exact?``:`≤`,f=o.exact?``:`≤`;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`dl`,{className:K.usage,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`Input`}),(0,H.jsx)(`dd`,{children:B(i.inputTokens)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`Output`}),(0,H.jsx)(`dd`,{children:B(i.outputTokens)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`Cache read`}),(0,H.jsx)(`dd`,{children:B(i.cacheReadTokens)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`Cache write`}),(0,H.jsx)(`dd`,{children:B(i.cacheCreationTokens)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`Turns`}),(0,H.jsx)(`dd`,{children:e.turnCount})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`Context`}),(0,H.jsxs)(`dd`,{title:a.exact?void 0:`An upper bound: the CLI reported only the turn total, which sums every call.`,children:[d,B(a.tokens),a.window===null?``:` / ${B(a.window)}`]})]})]}),(0,H.jsx)(`h4`,{className:K.subTitle,children:`Efficiency`}),(0,H.jsxs)(`dl`,{className:K.usage,"aria-label":`Context efficiency`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`Cache hit`}),(0,H.jsx)(`dd`,{title:`Share of prompt tokens served from the provider's cache: cache read ÷ (input + cache read + cache write).`,children:c===null?s>0?`none reported`:`—`:Qt(c)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`Compactions`}),(0,H.jsx)(`dd`,{children:l})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`Avg context / turn`}),(0,H.jsx)(`dd`,{children:o.average===null?`—`:`${f}${B(o.average)}`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`Peak context`}),(0,H.jsx)(`dd`,{children:o.peak===null?`—`:`${f}${B(o.peak)}`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`Mode`}),(0,H.jsx)(`dd`,{children:fn[a.mode]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`Compacts at`}),(0,H.jsx)(`dd`,{children:a.autoCompactAt===null?`—`:`≈${B(a.autoCompactAt)}`})]})]}),(0,H.jsxs)(`p`,{className:K.muted,children:[a.source===null?a.window===null?`Window unknown for this chat.`:`Window as stored when this chat was created; how it was known was not recorded.`:`Window ${Xe(a.source,e.engine)}.`,o.turns>0&&!o.exact?` Figures marked ≤ are upper bounds: the CLI reported only turn totals.`:``]}),(0,H.jsx)(`p`,{className:K.muted,children:e.memoryEnabled===!0?e.engine===`local`?`Shared project memory was given to this chat’s agent when it started.`:`Shared project memory was given to this chat’s agent when it started: a block of up to ${Yr/1024} KB in its system prompt, re-sent every turn (cached after the first), plus the agent’s own reads and updates of MEMORY.md — a little of this seat’s usage.`:`This chat started without shared project memory.`}),u===null?null:(0,H.jsx)(`p`,{role:`status`,className:K.idleWarn,children:u.local?`Idle for ${et(u.idleMs)}: the local model has likely dropped this chat from its cache, so the next turn re-processes ~${B(u.tokens)} tokens before it replies — time, not spend.`:`Idle for ${et(u.idleMs)}, past the ~1 h prompt-cache lifetime: the next turn likely re-reads ~${B(u.tokens)} tokens uncached, at full price.`})]})}function Ii({bootstrap:e,sessions:t,current:n,onStop:r,onOpen:i,onClose:a,events:o}){let s=t.filter(e=>e.status===`running`),c=Ai(s.length>0),l=Ai(n!==null,ki),u=e?ft(e.seats):[],d=e?.localRuntime.ollama,f=ie(De),p=x(De),m=e?ji(e.seats):null,h=m===null?null:st(m),g=Mi();return(0,H.jsxs)(`aside`,{className:K.panel,"aria-label":`Resources`,children:[(0,H.jsxs)(`header`,{className:K.head,children:[(0,H.jsx)(`h2`,{className:K.title,children:`Resources`}),(0,H.jsx)(`button`,{type:`button`,className:K.close,onClick:a,"aria-label":`Hide resources`,children:`×`})]}),(0,H.jsxs)(`div`,{className:K.scroll,children:[(0,H.jsxs)(`section`,{className:K.section,"aria-labelledby":`verse-res-seats`,children:[(0,H.jsxs)(`h3`,{id:`verse-res-seats`,className:K.sectionTitle,children:[(0,H.jsx)(`span`,{children:`Seats`}),(0,H.jsx)(`span`,{className:K.asOf,children:h===null?`no reading yet`:`as of ${h}`}),f.status===`refreshing`?(0,H.jsx)(O,{label:`Refreshing seats`}):null,(0,H.jsx)(`button`,{type:`button`,className:K.refresh,onClick:p,children:`Refresh`})]}),e?u.length===0?(0,H.jsxs)(`p`,{className:K.muted,children:[`No seats discovered. Connect an account with `,(0,H.jsx)(`code`,{children:`ashlr accounts`}),` or start Ollama.`]}):u.map(e=>{let t=yi(g.state,e.engine),n=`verse-res-group-${e.engine}`;return(0,H.jsxs)(`div`,{className:K.engineGroup,children:[(0,H.jsx)(`h4`,{className:K.engineTitle,children:(0,H.jsxs)(`button`,{type:`button`,className:K.groupToggle,"aria-expanded":t,"aria-controls":n,"aria-label":`${ot[e.engine]} seats`,onClick:()=>g.toggleGroup(e.engine),children:[(0,H.jsx)(`span`,{className:K.twist,"data-open":t?``:void 0,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:ot[e.engine]}),(0,H.jsx)(`span`,{className:K.count,children:e.seats.length})]})}),t?(0,H.jsx)(`ul`,{id:n,className:K.seatList,children:e.seats.map(e=>{let t=Gn(e);return(0,H.jsx)(Pi,{seat:e,open:bi(g.state,e.id,t.cls),onToggle:()=>g.toggleSeat(e,t)},e.id)})}):(0,H.jsx)(`ul`,{id:n,className:K.seatList,hidden:!0})]},e.engine)}):(0,H.jsxs)(`div`,{className:K.skeleton,children:[(0,H.jsx)(E,{width:`70%`}),(0,H.jsx)(E,{width:`50%`}),(0,H.jsx)(E,{width:`64%`})]})]}),(0,H.jsxs)(`section`,{className:K.section,"aria-labelledby":`verse-res-local`,children:[(0,H.jsx)(`h3`,{id:`verse-res-local`,className:K.sectionTitle,children:`Local runtime`}),d?(0,H.jsxs)(`div`,{className:K.local,children:[(0,H.jsxs)(`div`,{className:K.seatHead,children:[(0,H.jsx)(`span`,{className:K.seatLabel,children:`Ollama`}),(0,H.jsx)(re,{status:d.reachable?`ready`:`unavailable`,tone:d.reachable?`success`:`danger`,children:d.reachable?`reachable`:`unreachable`})]}),(0,H.jsx)(`p`,{className:K.mono,title:d.baseUrl,children:d.baseUrl}),d.reachable?d.models.length>0?(0,H.jsx)(`ul`,{className:K.models,children:d.models.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(`code`,{children:e})},e))}):(0,H.jsx)(`p`,{className:K.muted,children:`No models pulled yet.`}):(0,H.jsx)(`p`,{className:K.muted,children:`Start Ollama to enable local seats.`})]}):(0,H.jsx)(E,{width:`60%`})]}),(0,H.jsxs)(`section`,{className:K.section,"aria-labelledby":`verse-res-running`,children:[(0,H.jsxs)(`h3`,{id:`verse-res-running`,className:K.sectionTitle,children:[`Running `,(0,H.jsx)(`span`,{className:K.count,children:s.length})]}),s.length===0?(0,H.jsx)(`p`,{className:K.muted,children:`Nothing running.`}):(0,H.jsx)(`ul`,{className:K.runningList,children:s.map(t=>(0,H.jsxs)(`li`,{className:K.runningRow,children:[(0,H.jsxs)(`button`,{type:`button`,className:K.runningOpen,onClick:()=>i(t.id),title:t.title,children:[(0,H.jsx)(`span`,{className:K.runningDot,role:`img`,"aria-label":`Running`}),(0,H.jsx)(`span`,{className:K.runningTitle,children:t.title||`Untitled chat`}),(0,H.jsxs)(`span`,{className:K.runningMeta,children:[nt(t.projectPath,e?.projects??[]),` · `,et(c-new Date(t.updatedAt).getTime())]})]}),(0,H.jsx)(`button`,{type:`button`,className:K.stop,onClick:()=>r(t.id),"aria-label":`Stop ${t.title||`chat`}`,children:`Stop`})]},t.id))})]}),(0,H.jsx)(pi,{session:n,refreshKey:n?.turnCount??0}),(0,H.jsxs)(`section`,{className:K.section,"aria-labelledby":`verse-res-usage`,children:[(0,H.jsx)(`h3`,{id:`verse-res-usage`,className:K.sectionTitle,children:`This chat`}),n?(0,H.jsx)(Fi,{session:n,seats:e?.seats??[],events:o,now:l}):(0,H.jsx)(`p`,{className:K.muted,children:`Select a chat to see its usage.`})]}),(0,H.jsx)(oi,{projectPath:n?.projectPath??null,refreshKey:n?.turnCount??0})]})]})}var q={width:`_width_jrygt_4`,form:`_form_jrygt_6`,field:`_field_jrygt_7`,label:`_label_jrygt_8`,select:`_select_jrygt_17`,input:`_input_jrygt_18`,hint:`_hint_jrygt_36`,error:`_error_jrygt_37`,rootRow:`_rootRow_jrygt_47`,rowButton:`_rowButton_jrygt_56`,addRoot:`_addRoot_jrygt_57`,checkbox:`_checkbox_jrygt_74`,priorityRow:`_priorityRow_jrygt_82`,priorityPath:`_priorityPath_jrygt_88`,actions:`_actions_jrygt_99`,spacer:`_spacer_jrygt_100`,confirm:`_confirm_jrygt_101`,cancel:`_cancel_jrygt_103`,save:`_save_jrygt_104`,remove:`_remove_jrygt_105`,danger:`_danger_jrygt_106`};function Li(e){let{open:t,workspace:n,initialRoots:r,priorities:i,focusSectionId:a=null,onClose:o,onSaved:s,onDeleted:c}=e,l=(0,V.useId)(),u=(0,V.useId)(),[d,f]=(0,V.useState)(``),[p,m]=(0,V.useState)([``]),[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(!1),[ee,y]=(0,V.useState)({}),[b,x]=(0,V.useState)(!1),[S,C]=(0,V.useState)(!1),[w,T]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(!t)return;let e=n;f(e?.name??``),m(e?_t(e):[...r??[]].filter(e=>e.length>0)),g(e?.section??!1),v(e!==null&&a===e.id),y({}),x(!1),C(!1),T(null)},[t]);let E=p.length===0?[``]:p,D=lr();function te(e,t){m(E.map((n,r)=>r===e?t:n))}async function ne(e){let t=await ur();t!==null&&t.length>0&&te(e,t)}function O(e){return ee[e]??Tt(e,i)}async function re(e){e.preventDefault();let t=Ct(d,E);if(!t.ok){T(t.error);return}C(!0),T(null);try{let e=n===null?await Oe({name:t.name,roots:t.roots,section:h}):await Ne(n.id,{name:t.name,roots:t.roots,section:h});for(let e of t.roots){let t=ee[e];t!==void 0&&t!==Tt(e,i)&&await Ie(e,t)}let r=n!==null&&a===n.id;h&&_!==r&&await ze(_?e.id:null),s?.(e),o()}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1)}}async function k(){if(n!==null){C(!0),T(null);try{await He(n.id),c?.(n.id),o()}catch(e){T(e instanceof Error?e.message:String(e)),C(!1)}}}return(0,H.jsx)(oe,{open:t,onClose:o,titleId:l,title:n===null?`Save a project`:`Edit project`,description:`Saved projects stay in the picker — they do not need a chat on them first.`,widthClassName:q.width,children:(0,H.jsxs)(`form`,{className:q.form,onSubmit:e=>void re(e),noValidate:!0,children:[(0,H.jsxs)(`label`,{className:q.field,htmlFor:u,children:[(0,H.jsx)(`span`,{className:q.label,children:`Name`}),(0,H.jsx)(`input`,{id:u,className:q.input,value:d,onChange:e=>f(e.target.value),placeholder:`Defaults to the folder’s own name`,maxLength:120,autoComplete:`off`})]}),(0,H.jsxs)(`div`,{className:q.field,children:[(0,H.jsx)(`span`,{className:q.label,children:`Folders`}),(0,H.jsx)(`p`,{className:q.hint,children:`The first folder is the primary: it is the chat’s working directory. Move a folder to the top to make it the primary.`}),E.map((e,t)=>(0,H.jsxs)(`div`,{className:q.rootRow,children:[(0,H.jsx)(`input`,{className:q.input,value:e,onChange:e=>te(t,e.target.value),placeholder:`/absolute/path/to/folder`,"aria-label":xt(t),autoComplete:`off`,spellCheck:!1}),D?(0,H.jsx)(`button`,{type:`button`,className:q.rowButton,onClick:()=>void ne(t),"aria-label":`Choose ${xt(t).toLowerCase()}`,children:`Choose folder…`}):null,(0,H.jsx)(`button`,{type:`button`,className:q.rowButton,disabled:t===0,onClick:()=>m(yt(E,t,`up`)),"aria-label":`Move ${xt(t).toLowerCase()} up`,children:`↑`}),(0,H.jsx)(`button`,{type:`button`,className:q.rowButton,disabled:t===E.length-1,onClick:()=>m(yt(E,t,`down`)),"aria-label":`Move ${xt(t).toLowerCase()} down`,children:`↓`}),(0,H.jsx)(`button`,{type:`button`,className:q.rowButton,disabled:E.length===1,onClick:()=>m(E.filter((e,n)=>n!==t)),"aria-label":`Remove ${xt(t).toLowerCase()}`,children:`Remove`})]},t)),E.length<8?(0,H.jsx)(`button`,{type:`button`,className:q.addRoot,onClick:()=>m([...E,``]),children:`Add a folder`}):null,E.length>1?(0,H.jsx)(`p`,{className:q.hint,children:Mt}):null]}),(0,H.jsxs)(`div`,{className:q.field,children:[(0,H.jsxs)(`label`,{className:q.checkbox,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),(0,H.jsx)(`span`,{children:`Offer this project to the autonomous lane as a section`})]}),h?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`label`,{className:q.checkbox,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),(0,H.jsx)(`span`,{children:`Focus the fleet on this section`})]}),(0,H.jsx)(`p`,{className:q.hint,children:At}),E.filter(e=>e.trim().length>0).map((e,t)=>(0,H.jsxs)(`div`,{className:q.priorityRow,children:[(0,H.jsx)(`span`,{className:q.priorityPath,title:e,children:e}),(0,H.jsx)(`select`,{className:q.select,"aria-label":`Priority for ${e}`,value:O(e.trim()),onChange:t=>y({...ee,[e.trim()]:t.target.value}),children:wt.map(e=>(0,H.jsx)(`option`,{value:e,children:Dt[e]},e))})]},`${e}-${t}`))]}):null]}),w?(0,H.jsx)(`p`,{role:`alert`,className:q.error,children:w}):null,(0,H.jsxs)(`div`,{className:q.actions,children:[n===null?null:b?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:q.confirm,children:`Forget this project? Chats already on it are untouched.`}),(0,H.jsx)(`button`,{type:`button`,className:q.danger,onClick:()=>void k(),disabled:S,children:`Forget`}),(0,H.jsx)(`button`,{type:`button`,className:q.cancel,onClick:()=>x(!1),children:`Keep`})]}):(0,H.jsx)(`button`,{type:`button`,className:q.remove,onClick:()=>x(!0),disabled:S,children:`Forget project`}),(0,H.jsx)(`span`,{className:q.spacer}),(0,H.jsx)(`button`,{type:`button`,className:q.cancel,onClick:o,children:`Cancel`}),(0,H.jsx)(`button`,{type:`submit`,className:q.save,disabled:S,children:S?`Saving…`:`Save project`})]})]})})}var Ri={projects:`_projects_izay2_4`,head:`_head_izay2_10`,headText:`_headText_izay2_23`,add:`_add_izay2_25`,list:`_list_izay2_39`,project:`_project_izay2_4`,name:`_name_izay2_55`,summary:`_summary_izay2_64`,empty:`_empty_izay2_72`};function zi(){let e=ie(ke),t=e.data?.workspaces??[],[n,r]=(0,V.useState)({open:!1,workspace:null});return(0,H.jsxs)(`section`,{className:Ri.projects,"aria-label":`Saved projects`,children:[(0,H.jsxs)(`h2`,{className:Ri.head,children:[(0,H.jsx)(`span`,{className:Ri.headText,children:`Projects`}),(0,H.jsx)(`button`,{type:`button`,className:Ri.add,title:`Save a project`,"aria-label":`Save a project`,onClick:()=>r({open:!0,workspace:null}),children:(0,H.jsx)(_e,{})})]}),t.length>0?(0,H.jsx)(`ul`,{className:Ri.list,children:t.map(e=>{let t=St(e)??``;return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`button`,{type:`button`,className:Ri.project,title:t,"aria-label":`Edit project ${e.name}`,onClick:()=>r({open:!0,workspace:e}),children:[(0,H.jsx)(`span`,{className:Ri.name,children:e.name}),(0,H.jsx)(`span`,{className:Ri.summary,children:Pt(e)})]})},e.id)})}):e.status===`error`?null:(0,H.jsx)(`p`,{className:Ri.empty,children:`No saved projects yet.`}),(0,H.jsx)(Li,{open:n.open,workspace:n.workspace,priorities:e.data?.priorities,focusSectionId:e.data?.focusSectionId??null,onClose:()=>r({open:!1,workspace:null})})]})}function Bi({onOpenSession:e,query:t,selectedId:n=null}){let r=(0,V.useId)(),i=(0,V.useId)(),a=t===void 0,[o,s]=(0,V.useState)(``),c=(a?o:t).trim(),[l,u]=(0,V.useState)({status:`idle`}),[d,f]=(0,V.useState)(0),p=(0,V.useRef)(!1);(0,V.useEffect)(()=>{if(p.current)return;if(c.length<2){u({status:`idle`});return}let e=new AbortController;u(e=>({status:`loading`,previous:e.status===`ready`?e.response:e.status===`loading`?e.previous:null}));let t=setTimeout(()=>{Mn(c,30,e.signal).then(t=>{e.signal.aborted||u({status:`ready`,response:t})}).catch(t=>{e.signal.aborted||(t instanceof j&&t.status===404?(p.current=!0,u({status:`unsupported`})):u({status:`error`,message:ai(t)}))})},250);return()=>{clearTimeout(t),e.abort()}},[c,d]);let m=a?(0,H.jsxs)(`label`,{className:G.searchBox,htmlFor:r,children:[(0,H.jsx)(`span`,{className:`visually-hidden`,children:`Search messages in every chat`}),(0,H.jsx)(`input`,{id:r,type:`search`,className:G.input,value:o,placeholder:`Search messages`,autoComplete:`off`,spellCheck:!1,onChange:e=>s(e.target.value)})]}):null;if(l.status===`unsupported`)return a?(0,H.jsxs)(`div`,{className:G.search,children:[m,(0,H.jsxs)(`p`,{className:`${G.hint} ${G.searchNote}`,children:[`This server cannot search messages yet — update Ashlr and restart `,(0,H.jsx)(`code`,{children:`ashlr verse`}),`.`]})]}):null;if(l.status===`idle`&&!a)return null;let h=l.status===`ready`?l.response:l.status===`loading`?l.previous:null,g=h?ri(h.hits):[],_=ei(h?.query??c),v=l.status===`loading`;return(0,H.jsxs)(`section`,{className:G.search,"aria-labelledby":i,"aria-busy":v?!0:void 0,children:[m,(0,H.jsxs)(`h2`,{id:i,className:G.searchHead,children:[(0,H.jsx)(`span`,{children:`In messages`}),h&&!v?(0,H.jsx)(`span`,{className:G.searchCount,"aria-hidden":`true`,children:g.length}):null]}),(0,H.jsx)(`p`,{className:`visually-hidden`,role:`status`,"aria-live":`polite`,children:l.status===`ready`?g.length===0?`No messages match ${c}.`:`${g.length} ${g.length===1?`chat has`:`chats have`} matching messages.`:``}),l.status===`idle`?(0,H.jsx)(`p`,{className:`${G.hint} ${G.searchNote}`,children:`Searches what was said in every chat on this machine. Nothing is sent to a model.`}):l.status===`error`?(0,H.jsxs)(`div`,{className:G.searchError,role:`alert`,children:[(0,H.jsxs)(`span`,{children:[`Could not search messages: `,l.message]}),(0,H.jsx)(`button`,{type:`button`,className:`${G.secondary} ${G.small}`,onClick:()=>f(e=>e+1),children:`Retry`})]}):v&&!h?(0,H.jsx)(`p`,{className:`${G.hint} ${G.searchNote}`,children:`Searching messages…`}):g.length===0?(0,H.jsxs)(`p`,{className:`${G.hint} ${G.searchNote}`,children:[`No messages match “`,c,`”.`]}):(0,H.jsx)(`ul`,{className:G.hits,children:g.map(t=>{let r=ni(t.top.snippet,_),i=t.top.kind===`user`?`You`:`Agent`,a=t.count>1?` · ${t.count} matches`:``;return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`button`,{type:`button`,className:`${G.hit} ${G[`engine-${t.engine}`]??``}`,"aria-current":t.sessionId===n?`true`:void 0,"data-session":t.sessionId,"data-engine":t.engine,onClick:()=>e(t.sessionId),children:[(0,H.jsx)(`span`,{className:G.hitMarker,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:G.hitTitle,children:t.title||`Untitled chat`}),(0,H.jsx)(`time`,{className:G.hitTime,dateTime:t.latestAt,children:at(t.latestAt)}),(0,H.jsxs)(`span`,{className:G.hitSnippet,children:[(0,H.jsxs)(`span`,{className:G.hitWho,children:[i,a,`: `]}),r.map((e,t)=>e.match?(0,H.jsx)(`mark`,{children:e.text},t):(0,H.jsx)(`span`,{children:e.text},t))]})]})},t.sessionId)})}),h&&l.status!==`error`?(0,H.jsxs)(`p`,{className:`${G.hint} ${G.searchNote}`,children:[`Searched `,h.scannedSessions.toLocaleString(),` `,h.scannedSessions===1?`chat`:`chats`,h.truncated?` — the most recent ones only; older chats were not searched.`:`.`]}):null]})}var J={sidebar:`_sidebar_5kf7h_1`,head:`_head_5kf7h_9`,headDragStrip:`_headDragStrip_5kf7h_40`,search:`_search_5kf7h_51`,searchIcon:`_searchIcon_5kf7h_58`,iconButton:`_iconButton_5kf7h_80`,scroll:`_scroll_5kf7h_98`,skeleton:`_skeleton_5kf7h_105`,error:`_error_5kf7h_106`,empty:`_empty_5kf7h_125`,emptyTitle:`_emptyTitle_5kf7h_131`,emptyCompact:`_emptyCompact_5kf7h_135`,emptyAction:`_emptyAction_5kf7h_138`,emptyKey:`_emptyKey_5kf7h_153`,group:`_group_5kf7h_163`,groupTitle:`_groupTitle_5kf7h_164`,groupName:`_groupName_5kf7h_177`,enrolled:`_enrolled_5kf7h_178`,groupCount:`_groupCount_5kf7h_182`,list:`_list_5kf7h_191`,session:`_session_5kf7h_194`,marker:`_marker_5kf7h_246`,"engine-claude":`_engine-claude_5kf7h_252`,"engine-codex":`_engine-codex_5kf7h_253`,"engine-grok":`_engine-grok_5kf7h_254`,"engine-local":`_engine-local_5kf7h_255`,sessionText:`_sessionText_5kf7h_194`,running:`_running_5kf7h_266`,"verse-pulse":`_verse-pulse_5kf7h_1`,errored:`_errored_5kf7h_273`,seatSpent:`_seatSpent_5kf7h_288`,time:`_time_5kf7h_300`,footer:`_footer_5kf7h_319`,footerButton:`_footerButton_5kf7h_327`};function Vi(e){let{sessions:t,sessionsStatus:n,sessionsError:r,projects:i,seats:a,selectedId:o,query:s,onQuery:c,onSelect:l,onNew:u,onRetry:d,onCollapse:f,onDisconnect:p}=e,m=(0,V.useId)(),h=tt(t,i,s),g=n===`loading`||n===`idle`&&t.length===0;return(0,H.jsxs)(`nav`,{className:J.sidebar,"aria-label":`Chats`,children:[(0,H.jsxs)(`div`,{className:J.head,children:[(0,H.jsx)(`div`,{className:J.headDragStrip,"aria-hidden":`true`}),(0,H.jsxs)(`label`,{className:J.search,htmlFor:m,children:[(0,H.jsx)(`span`,{className:J.searchIcon,"aria-hidden":`true`,children:(0,H.jsx)(Te,{})}),(0,H.jsx)(`span`,{className:`visually-hidden`,children:`Search chats and messages`}),(0,H.jsx)(`input`,{id:m,type:`search`,value:s,placeholder:`Search chats`,autoComplete:`off`,onChange:e=>c(e.target.value)})]}),(0,H.jsx)(I,{label:`New chat`,shortcut:`⌘N`,placement:`bottom`,children:(0,H.jsx)(`button`,{type:`button`,className:J.iconButton,onClick:u,"aria-label":`New chat`,children:(0,H.jsx)(_e,{})})}),(0,H.jsx)(I,{label:`Hide chat list`,placement:`bottom`,children:(0,H.jsx)(`button`,{type:`button`,className:J.iconButton,onClick:f,"aria-label":`Hide chat list`,children:(0,H.jsx)(we,{})})}),n===`refreshing`?(0,H.jsx)(O,{label:`Refreshing chats`}):null]}),(0,H.jsxs)(`div`,{className:J.scroll,children:[(0,H.jsx)(zi,{}),g?(0,H.jsxs)(`div`,{className:J.skeleton,"aria-busy":`true`,children:[(0,H.jsx)(E,{width:`48%`}),(0,H.jsx)(E,{width:`86%`}),(0,H.jsx)(E,{width:`74%`}),(0,H.jsx)(E,{width:`40%`}),(0,H.jsx)(E,{width:`80%`})]}):n===`error`&&t.length===0?(0,H.jsxs)(`div`,{role:`alert`,className:J.error,children:[(0,H.jsx)(`p`,{children:r??`Could not load chats.`}),(0,H.jsx)(`button`,{type:`button`,onClick:d,children:`Retry`})]}):h.length===0?(0,H.jsx)(`div`,{className:s?`${J.empty} ${J.emptyCompact}`:J.empty,children:s?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`p`,{className:J.emptyTitle,children:[`No chat titles match “`,s,`”`]}),(0,H.jsx)(`p`,{children:`Titles and projects match as you type. Chats whose messages match, if any, are listed below.`}),(0,H.jsx)(`button`,{type:`button`,className:J.emptyAction,onClick:()=>c(``),children:`Clear search`})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:J.emptyTitle,children:`No chats yet`}),(0,H.jsx)(`p`,{children:`Start one on any project with any seat.`}),(0,H.jsxs)(`button`,{type:`button`,className:J.emptyAction,onClick:u,children:[`Start your first chat `,(0,H.jsx)(`kbd`,{className:J.emptyKey,children:`⌘N`})]})]})}):h.map(e=>(0,H.jsxs)(`section`,{className:J.group,"aria-label":e.name,children:[(0,H.jsxs)(`h2`,{className:J.groupTitle,title:e.projectPath,children:[(0,H.jsx)(`span`,{className:J.groupName,children:e.name}),e.enrolled?(0,H.jsx)(`span`,{className:J.enrolled,children:`enrolled`}):null,(0,H.jsx)(`span`,{className:J.groupCount,"aria-hidden":`true`,children:e.sessions.length})]}),(0,H.jsx)(`ul`,{className:J.list,children:e.sessions.map(e=>{let t=Ze(a,e.seatId),n=t===void 0?null:Gn(t),r=e.status===`running`&&n?.cls===`blocked`,i=n===null||n.cls===`ready`||n.cls===`unread`?`${e.title} · ${$e(a,e)}`:`${e.title} · ${$e(a,e)} · ${n.summary}`;return(0,H.jsx)(`li`,{children:(0,H.jsx)(I,{label:i,placement:`right`,children:(0,H.jsxs)(`button`,{type:`button`,className:`${J.session} ${J[`engine-${e.engine}`]??``}`,"aria-current":e.id===o?`true`:void 0,"data-focus-key":`verse-session:${e.id}`,"data-engine":e.engine,onClick:()=>l(e.id),children:[(0,H.jsx)(`span`,{className:J.marker,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:J.sessionText,children:e.title||`Untitled chat`}),r&&n!==null?(0,H.jsx)(`span`,{className:J.seatSpent,role:`img`,"aria-label":`Seat limit reached: ${n.summary}`,children:`▮`}):null,e.status===`running`?(0,H.jsx)(`span`,{className:J.running,role:`img`,"aria-label":`Running`}):e.status===`error`?(0,H.jsx)(`span`,{className:J.errored,role:`img`,"aria-label":`Last turn failed`,children:`!`}):null,(0,H.jsx)(`time`,{className:J.time,dateTime:e.updatedAt,children:at(e.updatedAt)})]})})},e.id)})})]},e.projectPath)),s.trim()?(0,H.jsx)(Bi,{query:s,onOpenSession:l,selectedId:o}):null]}),(0,H.jsx)(`footer`,{className:J.footer,children:(0,H.jsx)(`button`,{type:`button`,onClick:p,className:J.footerButton,children:`Disconnect`})})]})}var Hi=[`user-message`,`turn-started`,`text-delta`,`assistant-message`,`thinking`,`tool-use`,`tool-result`,`usage`,`turn-done`,`error`,`cancelled`,`compaction`,`context`];function Ui(e){return`${Ge(e,`/events`)}?client=${encodeURIComponent(d())}`}function Wi(e){return Math.min(1e3*2**e,15e3)}var Gi=e=>e===null||typeof e==`number`&&Number.isFinite(e)&&e>=0;function Ki(e){return e.type===`context`?typeof e.contextTokens==`number`&&Number.isFinite(e.contextTokens)&&e.contextTokens>=0&&typeof e.exact==`boolean`&&Gi(e.contextWindow)&&(e.autoCompactAt===void 0||Gi(e.autoCompactAt)):e.type!==`compaction`||(e.trigger===`auto`||e.trigger===`manual`)&&Gi(e.preTokens)&&Gi(e.postTokens)&&Gi(e.durationMs)}function qi(e){try{let t=JSON.parse(e);if(!t||typeof t!=`object`)return null;let n=t;return typeof n.seq!=`number`||typeof n.type!=`string`||!Ki(t)?null:t}catch{return null}}function Ji(e){let t=null,n=null,r=0,a=!1,o=()=>{if(a||typeof EventSource>`u`||i().phase!==`authenticated`)return;Vt(e,r===0?`connecting`:`reconnecting`);let s=new EventSource(Ui(e),{withCredentials:!0});t=s,s.onopen=()=>{r=0,Vt(e,`open`)};for(let t of Hi)s.addEventListener(t,t=>{let n=qi(t.data);n&&(Rt(e,n),(n.type===`turn-done`||n.type===`cancelled`||n.type===`error`)&&We())});s.onerror=c=>{typeof MessageEvent<`u`&&c instanceof MessageEvent||(s.close(),t===s&&(t=null),!a&&(Vt(e,`reconnecting`),i().phase===`authenticated`&&(n=setTimeout(()=>{n=null,r+=1,o()},Wi(r)))))}};return o(),()=>{a=!0,n&&clearTimeout(n),n=null,t?.close(),t=null,Vt(e,`closed`)}}function Yi(){let e=null,t=null,n=0,r=!1,a=()=>{if(r||typeof EventSource>`u`||i().phase!==`authenticated`)return;let o=new EventSource(w(),{withCredentials:!0});e=o,o.onopen=()=>{n=0},o.addEventListener(`verse-sessions`,()=>We()),o.onerror=()=>{o.close(),e===o&&(e=null),!(r||i().phase!==`authenticated`)&&(t=setTimeout(()=>{t=null,n+=1,a()},Wi(n)))}};return a(),()=>{r=!0,t&&clearTimeout(t),t=null,e?.close(),e=null}}function Xi(e,t=0){let n=(0,V.useSyncExternalStore)(Kt,()=>Ft(e),()=>Ft(e));(0,V.useEffect)(()=>{if(!e)return;let t=new AbortController;Ae(e,t.signal).then(n=>{t.signal.aborted||Ut(e,n.session,n.events)}).catch(n=>{t.signal.aborted||Gt(e,n instanceof Error?n.message:`Could not load this chat.`)});let n=Ji(e);return()=>{t.abort(),n()}},[e,t]);let r=(0,V.useMemo)(()=>Lt(n.events),[n.events]);return(0,V.useMemo)(()=>({...n,transcript:r}),[n,r])}var Zi={sidebar:{min:220,max:420,def:264},resources:{min:240,max:520,def:320}},Qi=1,$i=`ashlr.verse.panels.v1`,ea=`ashlr.verse.ui.v2`,ta={containerWidth:0,sidebarVisible:!0,resourcesVisible:!0};function na(e,t){let n=Zi[e],r=Number(t);return!Number.isFinite(r)||r<=0?n.def:Math.max(n.min,Math.min(n.max,Math.round(r)))}function ra(e,t){let n=na(`sidebar`,e.sidebar),r=na(`resources`,e.resources);if(!Number.isFinite(t.containerWidth)||t.containerWidth<=0)return{sidebar:n,resources:r};let i=(t.sidebarVisible?Qi:0)+(t.resourcesVisible?Qi:0),a=t.containerWidth-480-i,o=(t.sidebarVisible?n:0)+(t.resourcesVisible?r:0)-a;if(o<=0)return{sidebar:n,resources:r};if(t.resourcesVisible){let e=Math.min(o,r-Zi.resources.min);r-=e,o-=e}if(o>0&&t.sidebarVisible){let e=Math.min(o,n-Zi.sidebar.min);n-=e}return{sidebar:n,resources:r}}function ia(){return{sidebar:Zi.sidebar.def,resources:Zi.resources.def}}function aa(e){if(e===null||e===``)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r=n.sidebar??n.sidebarWidth,i=n.resources??n.resourcesWidth;return r===void 0&&i===void 0?null:{sidebar:na(`sidebar`,r),resources:na(`resources`,i)}}function oa(){try{return aa(localStorage.getItem($i))||(aa(localStorage.getItem(ea))??ia())}catch{return ia()}}function sa(e){try{localStorage.setItem($i,JSON.stringify({sidebar:e.sidebar,resources:e.resources}))}catch{}}var ca=oa(),la=ta,ua={desired:ca,effective:ra(ca,la)},da=new Set;function fa(e,t){return e.sidebar===t.sidebar&&e.resources===t.resources}function pa(){let e=ra(ca,la);if(!(fa(ua.desired,ca)&&fa(ua.effective,e))){ua={desired:ca,effective:e};for(let e of da)e()}}function ma(e){return da.add(e),()=>{da.delete(e)}}function ha(){return ua}function ga(e){(la.containerWidth!==e.containerWidth||la.sidebarVisible!==e.sidebarVisible||la.resourcesVisible!==e.resourcesVisible)&&(la=e,pa())}function _a(e){fa(ca,e)||(ca=e,sa(ca),pa())}function va(e,t){_a({...ca,[e]:na(e,t)})}function ya(e,t){va(e,ua.effective[e]+t)}function ba(e){va(e,Zi[e].def)}function xa(){return(0,V.useSyncExternalStore)(ma,ha,ha)}var Sa=`verseResizing`;function Ca(e){try{e?document.body.dataset[Sa]=`true`:delete document.body.dataset[Sa]}catch{}}function wa({side:e,label:t,className:n}){let r=xa(),i=Zi[e],a=r.effective[e],o=(0,V.useRef)(null),[s,c]=(0,V.useState)(!1),l=(0,V.useCallback)(()=>{o.current&&(o.current=null,c(!1),Ca(!1))},[]),u=(0,V.useCallback)(e=>{if(e.button===0){e.preventDefault(),o.current={pointerId:e.pointerId,originX:e.clientX,startWidth:a},c(!0),Ca(!0);try{e.currentTarget.setPointerCapture?.(e.pointerId)}catch{}}},[a]);(0,V.useEffect)(()=>{if(!s)return;let t=t=>{let n=o.current;if(!n||t.pointerId!==n.pointerId)return;let r=t.clientX-n.originX;va(e,e===`sidebar`?n.startWidth+r:n.startWidth-r)},n=e=>{let t=o.current;t&&e.pointerId!==t.pointerId||l()},r=t=>{let n=o.current;n&&t.key===`Escape`&&(va(e,n.startWidth),l())},i=()=>l();return window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,n),window.addEventListener(`keydown`,r),window.addEventListener(`blur`,i),()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,n),window.removeEventListener(`keydown`,r),window.removeEventListener(`blur`,i),Ca(!1)}},[s,e,l]);let d=(0,V.useCallback)(t=>{let n=t.shiftKey?64:16,r=e===`sidebar`?1:-1;switch(t.key){case`ArrowRight`:ya(e,n*r);break;case`ArrowLeft`:ya(e,-n*r);break;case`Home`:va(e,i.min);break;case`End`:va(e,i.max);break;case`Enter`:ba(e);break;default:return}t.preventDefault()},[e,i.min,i.max]);return(0,H.jsx)(`div`,{className:n,"data-verse-resizer":e,"data-dragging":s?`true`:void 0,role:`separator`,"aria-orientation":`vertical`,"aria-label":t,"aria-valuemin":i.min,"aria-valuemax":i.max,"aria-valuenow":a,"aria-valuetext":`${a} pixels`,tabIndex:0,onPointerDown:u,onPointerUp:l,onPointerCancel:l,onLostPointerCapture:l,onKeyDown:d,onDoubleClick:()=>ba(e)})}var Ta=`Use Wispr Flow / Superwhisper — system dictation works in this box`;function Ea(){let e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function Da({disabled:e=!1,onInterim:t,onFinal:n,onListeningChange:r}){let i=Ea(),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(null),l=(0,V.useRef)(null),u=(0,V.useRef)({onInterim:t,onFinal:n,onListeningChange:r});u.current={onInterim:t,onFinal:n,onListeningChange:r};let d=(0,V.useCallback)(()=>{let e=l.current;if(l.current=null,e){e.onresult=null,e.onend=null,e.onerror=null;try{e.stop()}catch{}}o(!1),u.current.onInterim(``),u.current.onListeningChange?.(!1)},[]),f=(0,V.useCallback)(()=>{if(!i||l.current)return;let e;try{e=new i}catch{c(`Dictation could not start in this browser.`);return}e.lang=navigator.language||`en-US`,e.continuous=!0,e.interimResults=!0,e.onresult=e=>{let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r+=1){let i=e.results[r];if(!i)continue;let a=i[0]?.transcript??``;i.isFinal?n+=a:t+=a}n&&u.current.onFinal(n.trim()),u.current.onInterim(t)},e.onerror=e=>{let t=e.error??`unknown`;t===`not-allowed`||t===`service-not-allowed`?c(`Microphone access was denied.`):t!==`aborted`&&t!==`no-speech`&&c(`Dictation stopped (${t}).`),d()},e.onend=()=>{l.current===e&&d()},l.current=e,c(null);try{e.start()}catch{l.current=null,c(`Dictation could not start in this browser.`);return}o(!0),u.current.onListeningChange?.(!0)},[i,d]);return(0,V.useEffect)(()=>{if(!a)return;function e(e){e.key===`Escape`&&(e.preventDefault(),d())}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a,d]),(0,V.useEffect)(()=>()=>{let e=l.current;l.current=null;try{e?.abort()}catch{}},[]),i?(0,H.jsxs)(`span`,{className:U.dictationWrap,children:[(0,H.jsx)(I,{label:a?`Stop dictation`:`Dictate`,shortcut:a?`Esc`:void 0,placement:`top`,children:(0,H.jsxs)(`button`,{type:`button`,className:`${U.dictation} ${a?U.dictationLive:``}`,disabled:e&&!a,"aria-pressed":a,"aria-label":a?`Stop dictation (Esc)`:`Start dictation`,onClick:()=>a?d():f(),children:[(0,H.jsx)(Oa,{}),a?(0,H.jsx)(`span`,{className:U.dictationPulse,"aria-hidden":`true`}):null]})}),s?(0,H.jsx)(`span`,{role:`alert`,className:U.dictationError,children:s}):null]}):(0,H.jsx)(`span`,{className:U.dictationWrap,children:(0,H.jsx)(I,{label:Ta,placement:`top`,children:(0,H.jsxs)(`button`,{type:`button`,className:U.dictation,disabled:!0,"aria-disabled":`true`,children:[(0,H.jsx)(Oa,{}),(0,H.jsx)(`span`,{className:`visually-hidden`,children:`Dictation unavailable`})]})})})}function Oa(){return(0,H.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,"aria-hidden":`true`,focusable:`false`,children:[(0,H.jsx)(`rect`,{x:`7`,y:`2`,width:`6`,height:`10`,rx:`3`,fill:`currentColor`}),(0,H.jsx)(`path`,{d:`M4.5 9.5a5.5 5.5 0 0 0 11 0M10 15v3M7 18h6`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`})]})}var ka=65536,Aa=400,ja=.4,Ma=320;function Na({sessionId:e=null,seats:t,seat:n,engine:r,running:i,disabled:o,disabledReason:s,locked:l,hintSeen:u=!1,contextTokens:d=null,contextWindow:f=null,autoCompactAt:p=null,contextExact:_=!0,handoffDraft:v=!1,onSend:ee,onStop:y,onSeatChange:b,autoFocus:x=!1}){let[S,C]=(0,V.useState)(()=>a(e)),[w,T]=(0,V.useState)(``),[E,D]=(0,V.useState)(!1),[te,ne]=(0,V.useState)(!1),[O,re]=(0,V.useState)(!1),[k,A]=(0,V.useState)(-1),[j]=(0,V.useState)(()=>g(e)),M=(0,V.useRef)(j),N=(0,V.useRef)(``),P=(0,V.useRef)(null),ie=(0,V.useRef)(null),F=(0,V.useId)(),ae=w?`${S}${S&&!S.endsWith(` `)?` `:``}${w}`:S,oe=(0,V.useMemo)(()=>new TextEncoder().encode(ae).length>ka,[ae]),se=!o&&!i&&!E&&ae.trim().length>0&&!oe,ce=!u&&!O,le=v&&!O&&ae.trim().length>0,ue=(0,V.useMemo)(()=>m(ae,{contextTokens:d,contextWindow:f,autoCompactAt:p,exact:_}),[ae,d,f,p,_]),de=(0,V.useRef)(S),fe=(0,V.useRef)(S);fe.current=S;let pe=(0,V.useCallback)(()=>{de.current!==fe.current&&(de.current=fe.current,h(e,fe.current))},[e]);(0,V.useEffect)(()=>{if(de.current===S)return;let e=setTimeout(pe,Aa);return()=>clearTimeout(e)},[S,pe]),(0,V.useEffect)(()=>(window.addEventListener(`beforeunload`,pe),()=>{window.removeEventListener(`beforeunload`,pe),pe()}),[pe]),(0,V.useEffect)(()=>{x&&P.current?.focus()},[x]),(0,V.useEffect)(()=>{if(!i)return;let e=e=>{e.key!==`.`||!e.metaKey&&!e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),y())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,y]),(0,V.useEffect)(()=>{if(i||!x)return;let e=document.activeElement,t=e!==null&&e!==P.current&&ie.current?.contains(e)===!0;(e===null||e===document.body||!e.isConnected||t)&&P.current?.focus()},[i,x]),(0,V.useEffect)(()=>{let e=P.current;if(!e)return;let t=typeof window>`u`?0:window.innerHeight,n=t>0?Math.round(t*ja):Ma;e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,n)}px`},[ae]);let I=(0,V.useCallback)(async()=>{if(!se)return;let t=ae.trim();D(!0);try{await ee(t)&&(M.current[M.current.length-1]!==t&&(M.current=[...M.current,t]),c(e,t),A(-1),N.current=``,C(``),de.current=``,fe.current=``,h(e,``),T(``),re(!0))}finally{D(!1),P.current?.focus()}},[se,ae,ee,e]);function L(e){let t=M.current;if(t.length===0)return!1;if(k===-1){if(e>0)return!1;N.current=S;let n=t.length-1;return A(n),C(t[n]),T(``),!0}let n=k+e;return n<0?!0:n>=t.length?(A(-1),C(N.current),!0):(A(n),C(t[n]),!0)}function R(e){let t=e.currentTarget,n=t.selectionStart===t.selectionEnd;if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){e.preventDefault(),I();return}if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.nativeEvent.isComposing){e.preventDefault(),I();return}if(e.key===`ArrowUp`&&n&&(k!==-1||t.selectionStart===0&&!w)){L(-1)&&e.preventDefault();return}e.key===`ArrowDown`&&n&&k!==-1&&L(1)&&e.preventDefault()}let me=o?s??`Sending is disabled`:i?`Draft your next message…`:`Message the agent…`;return(0,H.jsxs)(`form`,{ref:ie,className:U.composer,onSubmit:e=>{e.preventDefault(),I()},"aria-describedby":F,children:[(0,H.jsxs)(`div`,{className:`${U.box} ${te?U.boxListening:``}`,children:[(0,H.jsx)(`textarea`,{ref:P,className:U.textarea,value:ae,rows:1,placeholder:me,"aria-label":`Message`,disabled:o,onChange:e=>{T(``),A(-1),C(e.target.value)},onKeyDown:R}),(0,H.jsxs)(`div`,{className:U.row,children:[(0,H.jsx)(Fa,{seats:t,seat:n,engine:r,disabled:o,onNewChat:b}),(0,H.jsx)(`div`,{className:U.spacer}),(0,H.jsx)(Da,{disabled:o,onInterim:T,onFinal:e=>C(t=>t&&!t.endsWith(` `)?`${t} ${e}`:`${t}${e}`),onListeningChange:ne}),i?(0,H.jsxs)(`button`,{type:`button`,className:U.stop,onClick:y,title:`Stop the running turn (⌘.)`,"aria-label":`Stop the running turn`,children:[(0,H.jsx)(`span`,{className:U.stopIcon,"aria-hidden":`true`}),`Stop`]},`stop`):(0,H.jsx)(`button`,{type:`submit`,className:U.send,disabled:!se,"aria-label":l?`Send (unlocks first)`:`Send message`,children:E?`Sending…`:l?`Unlock & send`:`Send`},`send`)]})]}),ue?(0,H.jsxs)(`p`,{className:U.cost,"data-tone":ue.tone,role:`status`,children:[(0,H.jsxs)(`span`,{className:U.costFigure,children:[`≈`,B(ue.draftTokens)]}),` tokens for this message — sending would reach `,(0,H.jsxs)(`span`,{className:U.costFigure,children:[ue.projectedPercent,`%`]}),` of the context window.`,Pa(ue),(0,H.jsx)(`span`,{className:`visually-hidden`,children:` This is an estimate; the provider counts the real total.`})]}):null,(0,H.jsx)(`p`,{id:F,className:`${U.help} ${ce||oe||te||i||o||k!==-1||le?``:U.helpQuiet}`,children:oe?(0,H.jsx)(`span`,{role:`alert`,className:U.helpError,children:`Message is over 64 KB — trim it before sending.`}):te?`Listening… Esc stops dictation.`:o&&s?s:i?(0,H.jsxs)(H.Fragment,{children:[`Reply in progress — your draft stays here · `,(0,H.jsx)(`kbd`,{children:`⌘.`}),` or Stop interrupts the turn`]}):le?(0,H.jsx)(H.Fragment,{children:`Handoff note drafted from the previous chat — review or edit it; nothing is spent until you press Send.`}):k===-1?ce?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`kbd`,{children:`Enter`}),` sends · `,(0,H.jsx)(`kbd`,{children:`Shift`}),`+`,(0,H.jsx)(`kbd`,{children:`Enter`}),` new line · `,(0,H.jsx)(`kbd`,{children:`↑`}),` recalls · `,(0,H.jsx)(`kbd`,{children:`⌘N`}),` new chat · `,(0,H.jsx)(`kbd`,{children:`⌘K`}),` switch`]}):null:(0,H.jsxs)(H.Fragment,{children:[`Recalled message `,k+1,` of `,M.current.length,` · `,(0,H.jsx)(`kbd`,{children:`↓`}),` returns to your draft`]})})]})}function Pa(e){let t=e.exact?``:` (The current size is an upper bound, so this may overstate it.)`;if(e.tone===`over`)return` That is past the whole window — the CLI must compact first, or the turn fails. Continue in a fresh chat.${t}`;if(e.pastCompaction)return` That reaches the auto-compaction point, so the CLI will summarise earlier turns during this reply. Continue in a fresh chat to keep full detail.${t}`;if(e.autoCompactAt!==null){let n=Math.max(0,e.autoCompactAt-e.projectedTokens);return` About ${B(n)} left before the CLI auto-compacts.${e.tone===`danger`?` Start a new chat to keep the agent sharp.`:``}${t}`}return`${e.tone===`danger`?` Start a new chat to keep the agent sharp.`:``}${t}`}function Fa({seats:e,seat:t,engine:n,disabled:r,onNewChat:i}){let[a,o]=(0,V.useState)(!1),s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useId)(),u=Ia(e,t.seatId),d=n??u?.engine,f=$e(e,{seatId:t.seatId,engine:d??`claude`,model:t.model}),p=e.filter(e=>e.health.state!==`unavailable`&&Qe(e)!==null);(0,V.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&(e.preventDefault(),o(!1),c.current?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]),(0,V.useEffect)(()=>{a&&s.current?.querySelector(`[role="menuitem"]`)?.focus()},[a]);function m(e){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=Array.from(s.current?.querySelectorAll(`[role="menuitem"]`)??[]);if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`ArrowDown`?(n+1)%t.length:(n-1+t.length)%t.length]?.focus()}return(0,H.jsxs)(`div`,{ref:s,className:`${U.seatPillWrap} ${d?U[`engine-${d}`]??``:``}`,children:[(0,H.jsxs)(`button`,{ref:c,type:`button`,className:U.seatPill,"data-engine":d,"aria-haspopup":`menu`,"aria-expanded":a,"aria-controls":a?l:void 0,disabled:r,title:`This chat is bound to one seat — open to start a new chat on another`,onClick:()=>o(e=>!e),children:[(0,H.jsx)(`span`,{className:U.engineDot,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:U.seatPillText,children:f})]}),a?(0,H.jsxs)(`div`,{id:l,role:`menu`,"aria-label":`Seat`,className:U.seatMenu,onKeyDown:m,children:[(0,H.jsxs)(`p`,{className:U.seatMenuHeading,children:[`This chat runs on `,(0,H.jsx)(`strong`,{children:f})]}),p.length===0?(0,H.jsx)(`p`,{className:U.seatMenuEmpty,children:`No other seats are available right now.`}):null,p.map(e=>{let n=pt(e),r=Qe(e);return(0,H.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`${U.seatMenuItem} ${U[`engine-${e.engine}`]??``}`,"data-capacity":n.cls,onClick:()=>{o(!1),i({seatId:e.id,model:r.id})},children:[(0,H.jsx)(`span`,{className:U.engineDot,"aria-hidden":`true`}),(0,H.jsxs)(`span`,{className:U.seatMenuText,children:[(0,H.jsxs)(`span`,{className:U.seatMenuPrimary,children:[`New chat on `,e.label]}),(0,H.jsxs)(`span`,{className:U.seatMenuSecondary,children:[r.label,e.id===t.seatId?` · same seat`:``]}),n.cls===`unread`?null:(0,H.jsxs)(`span`,{className:U.seatMenuCapacity,children:[lt[n.cls],` · `,n.text]})]})]},e.id)})]}):null]})}function Ia(e,t){return e.find(e=>e.id===t)}var La=4e3,Ra="Building the handoff reads this chat’s log and runs `git diff --stat` on its folders. It spends nothing.",za=`Asking for a summary sends one turn to this chat’s seat.`,Ba=`Stopping the summary turn.`,Va=`Creating the chat records a new session on this machine. Nothing is sent to a model until you press Send in it.`;function Ha(e,t){let n=null,r=!1;for(let i of e)if(`turnId`in i&&i.turnId===t){if(i.type===`error`)n=i.message;else if(i.type===`assistant-message`||i.type===`text-delta`&&i.text.trim().length>0)r=!0;else if(i.type===`cancelled`)return{kind:`cancelled`};else if(i.type===`turn-done`)return i.ok?r?{kind:`ok`}:{kind:`empty`}:{kind:`failed`,message:n}}return null}function Ua(e){return e.open?(0,H.jsx)(Wa,{...e}):null}function Wa({session:e,seats:t,onClose:n,onCreated:r}){let i=(0,V.useId)(),a=(0,V.useId)(),o=(0,V.useId)(),s=(0,V.useId)(),c=(0,V.useId)(),l=(0,V.useId)(),u=(0,V.useId)(),d=(0,V.useRef)(null),p=ii(),m=ie(On),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(`idle`),[ee,y]=(0,V.useState)(null),[b,x]=(0,V.useState)(``),[S,C]=(0,V.useState)(``),[w,T]=(0,V.useState)(!1),E=(0,V.useRef)(0),D=(0,V.useRef)(!0);(0,V.useEffect)(()=>(D.current=!0,()=>{D.current=!1}),[]);let te=(0,V.useRef)(null);te.current=h;let ne=p.run,O=(0,V.useCallback)(async t=>{let n=E.current+=1;v(`loading`),y(null);try{let r=await ne(Ra,()=>Tn(e.id,t));if(!D.current||n!==E.current)return;if(r===null){v(te.current?`ready`:`locked`);return}g(r),x(r.text),v(`ready`)}catch(e){if(!D.current||n!==E.current)return;y(ai(e)),v(`error`)}},[ne,e.id]);(0,V.useEffect)(()=>{f()?O({includeLastAssistant:!1,focus:``}):v(`locked`)},[]);let re=h!==null&&b!==h.text,k=(0,V.useMemo)(()=>Ur(b)>65536||Gr({text:b})>65536,[b]),A=b.length>Er,[j,M]=(0,V.useState)(()=>Fr(t,e));(0,V.useEffect)(()=>{j===null&&t.length>0&&M(Fr(t,e))},[j,t,e]);let N=j?Ze(t,j.seatId)??null:null,P=j?Nr(N,j.model):null,[F,ae]=(0,V.useState)(null),se=Ir({option:P,target:j,source:e,preferences:m.data}),le=F!==null&&Lr(P,F)!==void 0?F:se,ue=Br(P),de=Pr(N,P),fe=zr(b.length,P,le,N?.engine??null),pe=[dn(P),cn(N?.engine)].filter(Boolean).join(` `),I=1+(e.extraRoots?.filter(t=>t&&t!==e.projectPath).length??0),R=Ot(N?.engine??null,I);function me(e){M({seatId:e.seatId,model:e.model}),ae(null)}let[he,_e]=(0,V.useState)(()=>Mr(e.title)),[z,ve]=(0,V.useState)({phase:`idle`}),ye=Ze(t,e.seatId)?.label??ot[e.engine],be=z.phase===`sending`||z.phase===`waiting`||z.phase===`cancelling`,xe=e.status===`running`?`A turn is running in this chat. Wait for it to finish first.`:e.turnCount===0?`This chat has no turns yet, so there is nothing to summarize.`:null;async function Se(){ve({phase:`sending`});try{let t=await p.run(za,async()=>{Bt(e.id,`running`);try{let t=await Me(e.id,Dr);return zt(e.id,t.session,t.turnId),t.turnId}catch(t){throw Bt(e.id,`idle`),t}});if(!D.current)return;ve(t===null?{phase:`idle`}:{phase:`waiting`,turnId:t})}catch(e){D.current&&ve({phase:`failed`,message:ai(e)})}}async function Ce(){if(z.phase!==`waiting`)return;let t=z.turnId;ve({phase:`cancelling`,turnId:t});try{await p.run(Ba,()=>Ve(e.id))===null&&D.current&&ve({phase:`waiting`,turnId:t})}catch(e){D.current&&ve({phase:`failed`,message:ai(e)})}}let we=(0,V.useRef)(S);we.current=S,(0,V.useEffect)(()=>{if(z.phase!==`waiting`&&z.phase!==`cancelling`)return;let t=z.turnId,n=!1,r=()=>{if(n)return;let r=Ha(Ft(e.id).events,t);if(r!==null)switch(n=!0,r.kind){case`ok`:ve({phase:`done`}),T(!0),O({includeLastAssistant:!0,focus:we.current});break;case`cancelled`:ve({phase:`failed`,message:`Summary stopped. The automatic preview is unchanged.`});break;case`empty`:ve({phase:`failed`,message:`${ye} finished without writing a summary. The automatic preview is unchanged.`});break;default:ve({phase:`failed`,message:`The summary turn failed${r.message?`: ${r.message}`:``}. The automatic preview is unchanged.`})}};r();let i=Kt(r),a=setInterval(()=>{let t=Ft(e.id).stream;t!==`open`&&t!==`connecting`&&t!==`reconnecting`&&Ae(e.id).then(t=>Ut(e.id,t.session,t.events)).catch(()=>{})},La);return()=>{n=!0,i(),clearInterval(a)}},[z,e.id]);let[Te,Ee]=(0,V.useState)(!1),[De,Oe]=(0,V.useState)(null),ke=b.trim().length>0,je=de??(h?null:`Build the handoff first.`)??(ke?null:`The handoff is empty — rebuild it or write one.`)??(k?`The handoff is over the 64 KB limit for one message. Trim it first.`:null)??(be?`Wait for the summary to finish, or stop it.`:null);async function Ne(){if(!j||je!==null||Te)return;Ee(!0),Oe(null);let t=b;try{let i=await p.run(Va,()=>En({source:e,seatId:j.seatId,model:j.model,contextMode:Lr(P,le),title:he.trim()||void 0}));if(i===null)return;zt(i.id,i),ge(i.projectPath,{seatId:i.seatId,model:i.model}),r(i,t),n()}catch(e){D.current&&Oe(ai(e))}finally{D.current&&Ee(!1)}}let Pe=()=>{p.dialog.open||n()},Fe=Math.ceil(b.length/4),Ie=()=>void O({includeLastAssistant:w,focus:S});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(oe,{open:!0,onClose:Pe,titleId:i,title:`Continue in a fresh chat`,initialFocusRef:d,widthClassName:G.dialogWidth,description:(0,H.jsxs)(H.Fragment,{children:[`Start a new chat from a written handoff of “`,e.title||`Untitled chat`,`” instead of its full history.`]}),children:(0,H.jsxs)(`form`,{className:G.form,noValidate:!0,onSubmit:e=>{e.preventDefault(),Ne()},children:[(0,H.jsxs)(`div`,{className:G.field,children:[(0,H.jsxs)(`label`,{className:G.label,htmlFor:a,children:[`Focus for the next chat `,(0,H.jsx)(`span`,{className:G.optional,children:`optional`})]}),(0,H.jsxs)(`div`,{className:G.row,children:[(0,H.jsx)(`input`,{id:a,ref:d,className:G.input,value:S,maxLength:500,placeholder:`e.g. finish the migration, then run the full test suite`,autoComplete:`off`,onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),_!==`loading`&&Ie())}}),(0,H.jsx)(`button`,{type:`button`,className:G.secondary,onClick:Ie,disabled:_===`loading`||be,children:re?`Rebuild (replaces your edits)`:`Rebuild`})]})]}),(0,H.jsxs)(`div`,{className:G.field,children:[(0,H.jsx)(`label`,{className:G.label,htmlFor:o,children:`Handoff — becomes the new chat’s first message`}),_===`locked`&&!h?(0,H.jsxs)(`div`,{className:G.locked,role:`status`,children:[(0,H.jsxs)(`p`,{children:[`Building the handoff needs the mutation token: it reads this chat’s log and runs `,(0,H.jsx)(`code`,{children:`git diff --stat`}),`. It spends nothing.`]}),(0,H.jsx)(`button`,{type:`button`,className:G.secondary,onClick:Ie,children:`Unlock and build the handoff`})]}):(0,H.jsx)(`textarea`,{id:o,className:G.textarea,value:b,rows:12,spellCheck:!1,"aria-describedby":s,"aria-busy":_===`loading`||void 0,disabled:!h,placeholder:_===`loading`?`Building the handoff from this chat’s log…`:``,onChange:e=>x(e.target.value)}),(0,H.jsx)(`p`,{id:s,className:G.hint,"aria-live":`polite`,children:_===`loading`?h?`Rebuilding…`:`Reading this chat’s log…`:h?(0,H.jsxs)(H.Fragment,{children:[b.length.toLocaleString(),` chars · ~`,Fe.toLocaleString(),` tokens`,` · `,h.stats.turnsCovered,` `,h.stats.turnsCovered===1?`turn`:`turns`,` · `,h.stats.filesTouched,` `,h.stats.filesTouched===1?`file`:`files`,` touched`,re?` · edited`:``,w?` · includes ${ye}’s own summary`:``]}):null}),h&&h.stats.truncated.length>0?(0,H.jsxs)(`p`,{className:G.hint,children:[`To stay under `,Er.toLocaleString(),` characters these sections were left out: `,h.stats.truncated.join(`, `),`.`]}):null,k?(0,H.jsx)(`p`,{className:G.error,role:`alert`,children:`Over the 64 KB limit for one message (counted as it is sent, line breaks and quotes encoded) — the new chat could not send it. Trim it first.`}):A?(0,H.jsxs)(`p`,{className:G.warn,children:[`Longer than the `,Er.toLocaleString(),`-character handoff budget. It can still be sent; the new chat just starts bigger.`]}):null,_===`error`&&ee?(0,H.jsxs)(`p`,{className:G.error,role:`alert`,children:[`Could not build the handoff: `,ee,` `,(0,H.jsx)(`button`,{type:`button`,className:G.link,onClick:Ie,children:`Try again`})]}):null]}),(0,H.jsxs)(`section`,{className:G.aside,"aria-labelledby":`${i}-summary`,children:[(0,H.jsxs)(`h3`,{id:`${i}-summary`,className:G.label,children:[`Better summary `,(0,H.jsx)(`span`,{className:G.optional,children:`optional, spends`})]}),(0,H.jsxs)(`p`,{className:G.hint,children:[`The handoff above is assembled from this chat’s log. For one in the agent’s own words, ask `,ye,` to write it first — its reply is added to the handoff. `,Vr(e.engine,ye)]}),z.phase===`waiting`||z.phase===`cancelling`?(0,H.jsxs)(`div`,{className:G.row,role:`status`,children:[(0,H.jsx)(`span`,{className:G.pending,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:G.hint,children:z.phase===`cancelling`?`Stopping the summary…`:`Waiting for ${ye} to finish its summary…`}),(0,H.jsx)(`button`,{type:`button`,className:G.secondary,onClick:()=>void Ce(),disabled:z.phase===`cancelling`,children:`Stop the summary`})]}):(0,H.jsxs)(`div`,{className:G.row,children:[(0,H.jsx)(`button`,{type:`button`,className:G.secondary,onClick:()=>void Se(),disabled:xe!==null||z.phase===`sending`,children:z.phase===`sending`?`Sending…`:z.phase===`done`?`Ask ${ye} again`:`Ask ${ye} to summarize first`}),z.phase===`done`?(0,H.jsx)(`span`,{className:G.hint,role:`status`,children:`Summary added.`}):null]}),xe!==null&&!be?(0,H.jsx)(`p`,{className:G.hint,children:xe}):null,xe===null&&z.phase===`idle`&&re?(0,H.jsx)(`p`,{className:G.hint,children:`The handoff is rebuilt with the summary, which replaces your edits above.`}):null,z.phase===`failed`?(0,H.jsx)(`p`,{className:G.error,role:`alert`,children:z.message}):null]}),(0,H.jsxs)(`div`,{className:G.field,children:[(0,H.jsx)(ar,{id:c,seats:t,value:j,onChange:me,label:`Continue on`,modeFor:(e,t)=>j&&e.id===j.seatId&&t.id===j.model?le:`standard`}),de?(0,H.jsx)(`p`,{className:G.error,role:`alert`,children:de}):null,R?(0,H.jsx)(`p`,{className:G.hint,children:R}):null]}),P&&!de?(0,H.jsxs)(`div`,{className:G.field,children:[ue?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{id:u,className:G.label,children:`Context mode`}),(0,H.jsx)(L,{"aria-labelledby":u,size:`sm`,value:le,onChange:e=>ae(e),options:[{value:`standard`,label:`Standard`},{value:`expansive`,label:`Expansive`}]}),(0,H.jsxs)(`p`,{className:G.hint,children:[Rr(P,le),`.`,` `,le===`expansive`?`Expansive keeps far more of the conversation before compacting, but every turn re-sends all of it — each turn costs more usage.${pe?` ${pe}`:``}`:`Standard compacts sooner and keeps each turn cheaper. Expansive is one click away if the work needs it.`]})]}):Rr(P,`standard`)?(0,H.jsxs)(`p`,{className:G.hint,children:[Rr(P,`standard`),`.`]}):null,(0,H.jsx)(`p`,{className:`${G.fit} ${G[`fit-${fe.tone}`]??``}`,"data-verdict":fe.verdict??`unknown`,children:fe.text})]}):null,(0,H.jsxs)(`div`,{className:G.field,children:[(0,H.jsx)(`label`,{className:G.label,htmlFor:l,children:`Title`}),(0,H.jsx)(`input`,{id:l,className:G.input,value:he,maxLength:120,autoComplete:`off`,onChange:e=>_e(e.target.value)})]}),De?(0,H.jsx)(`p`,{className:G.error,role:`alert`,children:De}):null,(0,H.jsx)(`p`,{className:G.cost,children:`Creating the chat is free — nothing is sent to a model. The handoff goes into the new chat’s composer; read it, then press Send. That first turn is the first thing spent.`}),(0,H.jsxs)(`div`,{className:G.actions,children:[je&&h?(0,H.jsx)(`span`,{className:G.blocked,children:je}):null,(0,H.jsx)(`button`,{type:`button`,className:G.cancel,onClick:n,children:`Cancel`}),(0,H.jsx)(`button`,{type:`submit`,className:G.primary,disabled:je!==null||Te,children:Te?`Creating…`:`Create chat`})]})]})}),(0,H.jsx)(ce,{open:p.dialog.open,reason:p.dialog.reason,tokenLabel:`Mutation token`,tokenHelp:`the mutation token ashlr verse printed`,onClose:p.dialog.onClose,onUnlocked:p.dialog.onUnlocked})]})}var Y={workspace:`_workspace_rqetq_1`,header:`_header_rqetq_14`,headerSpacer:`_headerSpacer_rqetq_14`,identity:`_identity_rqetq_41`,eyebrow:`_eyebrow_rqetq_50`,eyebrowSkeleton:`_eyebrowSkeleton_rqetq_60`,title:`_title_rqetq_68`,titleStatic:`_titleStatic_rqetq_69`,titleButton:`_titleButton_rqetq_94`,titleInput:`_titleInput_rqetq_119`,titleSkeleton:`_titleSkeleton_rqetq_137`,seatPill:`_seatPill_rqetq_147`,engineDot:`_engineDot_rqetq_168`,seatText:`_seatText_rqetq_151`,"engine-claude":`_engine-claude_rqetq_182`,"engine-codex":`_engine-codex_rqetq_183`,"engine-grok":`_engine-grok_rqetq_184`,"engine-local":`_engine-local_rqetq_185`,streamState:`_streamState_rqetq_187`,actions:`_actions_rqetq_195`,actionDivider:`_actionDivider_rqetq_204`,toggles:`_toggles_rqetq_213`,ghost:`_ghost_rqetq_220`,ghostIcon:`_ghostIcon_rqetq_221`,danger:`_danger_rqetq_222`,confirm:`_confirm_rqetq_254`,confirmText:`_confirmText_rqetq_255`,meter:`_meter_rqetq_266`,"meter-warn":`_meter-warn_rqetq_274`,"meter-danger":`_meter-danger_rqetq_275`,"meter-unknown":`_meter-unknown_rqetq_276`,"meter-over":`_meter-over_rqetq_279`,meterTrack:`_meterTrack_rqetq_282`,meterFill:`_meterFill_rqetq_290`,meterTick:`_meterTick_rqetq_299`,meterInline:`_meterInline_rqetq_309`,meterText:`_meterText_rqetq_317`,meterTokens:`_meterTokens_rqetq_326`,meterCompact:`_meterCompact_rqetq_327`,meterPercent:`_meterPercent_rqetq_331`,modeWrap:`_modeWrap_rqetq_337`,modeChip:`_modeChip_rqetq_338`,modeMenu:`_modeMenu_rqetq_355`,modeMenuHeading:`_modeMenuHeading_rqetq_376`,modeItem:`_modeItem_rqetq_382`,modeItemPrimary:`_modeItemPrimary_rqetq_397`,modeItemSecondary:`_modeItemSecondary_rqetq_398`,modeMenuNote:`_modeMenuNote_rqetq_399`,modeMenuWarn:`_modeMenuWarn_rqetq_407`,modeMenuError:`_modeMenuError_rqetq_415`,advice:`_advice_rqetq_425`,adviceNote:`_adviceNote_rqetq_437`,compactForm:`_compactForm_rqetq_451`,compactLabel:`_compactLabel_rqetq_452`,compactInput:`_compactInput_rqetq_453`,modeItemAction:`_modeItemAction_rqetq_465`,adviceBody:`_adviceBody_rqetq_466`,adviceTitle:`_adviceTitle_rqetq_467`,adviceReasons:`_adviceReasons_rqetq_468`,adviceFine:`_adviceFine_rqetq_476`,adviceActions:`_adviceActions_rqetq_477`,adviceAction:`_adviceAction_rqetq_477`,adviceStatus:`_adviceStatus_rqetq_496`,emptyState:`_emptyState_rqetq_505`,emptyMark:`_emptyMark_rqetq_516`,emptyTitle:`_emptyTitle_rqetq_517`,emptyBody:`_emptyBody_rqetq_524`,emptyButton:`_emptyButton_rqetq_525`,emptyWarn:`_emptyWarn_rqetq_541`};Math.round(l*100),Math.round(s*100);var Ga={standard:`Standard`,expansive:`Expansive`},Ka={claude:`Claude Code`,local:`Claude Code (driving the local model)`,codex:`Codex`,grok:`Grok`};function qa(e){return Math.round(e).toLocaleString(`en-US`)}function Ja(e){let t=A({contextTokens:typeof e.contextTokens==`number`&&Number.isFinite(e.contextTokens)?e.contextTokens:0,contextWindow:e.contextWindow??null,autoCompactAt:e.autoCompactAt??null,contextTokensExact:e.exact}),n=t.exact?``:`≤`,r=!t.exact&&t.untilCompaction===0,i=`${n}${B(t.tokens)} / ${t.window===null?`n/a`:B(t.window)}`,a=t.autoCompactAt===null?null:`compacts ≈${B(t.autoCompactAt)}`,o=t.ofWindow===null?null:Math.round(t.ofWindow*100),s=t.window!==null&&t.autoCompactAt!==null&&t.autoCompactAt<t.window?t.autoCompactAt/t.window*100:null,c=t.ofWindow===null?0:Math.min(100,Math.max(0,t.ofWindow*100)),l=[];l.push(t.window===null?`Context: ${n}${qa(t.tokens)} tokens — the window is unknown, so no percentage is shown.`:`Context: ${n}${qa(t.tokens)} of ${qa(t.window)} tokens (${o}%).`),t.exact||l.push(`Upper bound: this CLI reported only the turn total so far; the exact last-call size replaces it once its session log is read.`),t.tone===`over`&&l.push(`Past the window: the next turn will fail or force the CLI to compact first. Continue in a fresh chat.`);let u=e.mode?` (${Ga[e.mode]} mode)`:``;if(t.autoCompactAt!==null){let n=r?`the upper bound is past that point, which does not mean the real prompt is`:t.untilCompaction===0?`at or past that point now`:`${t.exact?``:`at least `}≈${qa(t.untilCompaction??0)} left`;l.push(`Auto-compacts at ≈${qa(t.autoCompactAt)} tokens${u} — ${n}.`);let i=e.engine?Ka[e.engine]:`The CLI`;l.push(`When it compacts, ${i} replaces the earlier conversation with a summary and carries on; early detail then survives only as that summary.`)}else t.window!==null&&l.push(`The compaction point is unknown${u}; the colour is measured against the whole window.`);if((e.compactionCount??0)>0){let t=e.compactionCount??0;l.push(`Compacted ${t} time${t===1?``:`s`} so far.`)}return t.window!==null&&l.push(`Window: ${e.source?Xe(e.source,e.engine):`source not recorded (an older session)`}.`),{tone:t.tone,label:i,compactLabel:a,percent:o,percentLabel:o===null?`n/a`:`${n}${o}%`,tickPercent:s,fillPercent:c,title:l.join(`
@@ -81,4 +81,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
81
81
  `):e}function Bu(e){return zu(Ru(e)).replace(/[ \t]+$/gm,``).replace(/\n+$/,``)}function Vu(e){if(e.length===0)return 0;let t=1;for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t++;return t}function Hu(e,t){let n=e.split(`
82
82
  `);return n.length<=t?{head:e,hidden:0}:{head:n.slice(0,t).join(`
83
83
  `),hidden:n.length-t}}var Uu=20,Wu=2e5;function Gu({command:e,output:t,isError:n,pending:r,body:i}){let[a,o]=(0,V.useState)(!1),s=(0,V.useMemo)(()=>{let e=Bu(t);return e.length>Wu?`${e.slice(0,Wu)}\n… (${e.length-Wu} more characters not shown)`:e},[t]),{head:c,hidden:l}=(0,V.useMemo)(()=>Hu(s,Uu),[s]),u=a?s:c,d=e?.exitCode??null;return(0,H.jsxs)(`div`,{className:X.command,"data-failed":n?`true`:void 0,children:[e?(0,H.jsxs)(`div`,{className:X.commandLine,children:[(0,H.jsx)(`span`,{className:X.commandPrompt,"aria-hidden":`true`,children:`$`}),(0,H.jsx)(`code`,{className:X.commandText,children:e.command})]}):null,(0,H.jsxs)(`div`,{className:X.commandStatus,children:[(0,H.jsx)(`span`,{className:X.commandStatusText,"data-tone":r?`pending`:n?`bad`:`ok`,children:r?`running…`:d===null?n?`failed — no exit code reported`:`completed — no exit code reported`:`exit ${d}`}),!r&&!i&&s.length===0?(0,H.jsx)(`span`,{className:X.commandMeta,children:`no output`}):null,!r&&!i&&s.length>0?(0,H.jsxs)(`span`,{className:X.commandMeta,children:[Vu(s),` line`,Vu(s)===1?``:`s`,Lu(t)?` · colour codes stripped`:``]}):null]}),r?(0,H.jsx)(`p`,{className:X.commandPending,children:`Waiting for the command to finish…`}):i||(s.length>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`pre`,{className:X.commandPre,children:u}),l>0?(0,H.jsx)(`button`,{type:`button`,className:X.commandMore,"aria-expanded":a,onClick:()=>o(e=>!e),children:a?`Collapse output`:`Show ${l} more line${l===1?``:`s`}`}):null]}):null)]})}var Ku=28,qu=18,Ju=4e3;function Yu({diff:e,path:t=null}){let n=(0,V.useMemo)(()=>le(e.text),[e.text]);if(n.files.length===0)return null;if(e.multiFile||n.files.length>1)return(0,H.jsx)(`div`,{className:X.diffMulti,children:(0,H.jsx)(fe,{diff:e.text,proposalKind:`tool call`})});let r=n.files[0];return(0,H.jsx)(Zu,{file:r,anchored:e.anchored,path:t??r.displayPath})}function Xu(e){switch(e.status){case`renamed`:return`Renamed. The contents did not change, so there are no lines to show.`;case`added`:return`New file. It was added with no contents to diff against.`;case`deleted`:return`Deleted. The file is gone, so there are no lines to show.`;default:return null}}function Zu({file:e,anchored:t,path:n}){let[r,i]=(0,V.useState)(!1),a=ue(n),o=(0,V.useMemo)(()=>Qu(e.hunks),[e.hunks]),s=o.length>Ku,c=s&&!r?o.slice(0,qu):o,l=o.length-c.length,u=e.status===`renamed`?e.oldPath:null,d=Xu(e);return(0,H.jsxs)(`div`,{className:X.diff,"data-anchored":t?`true`:`false`,"data-status":e.status,children:[(0,H.jsxs)(`div`,{className:X.diffHead,children:[u?(0,H.jsxs)(`span`,{className:X.diffOldPath,title:u,children:[u,(0,H.jsx)(`span`,{className:X.visuallyHidden,children:` renamed to`})]}):null,(0,H.jsx)(`span`,{className:X.diffPath,title:n,children:n}),e.status===`modified`?null:(0,H.jsx)(`span`,{className:X.diffStatus,children:e.status}),(0,H.jsxs)(`span`,{className:X.diffStats,children:[e.additions>0?(0,H.jsxs)(`span`,{className:X.diffAdd,children:[`+`,e.additions]}):null,e.deletions>0?(0,H.jsxs)(`span`,{className:X.diffDel,children:[`−`,e.deletions]}):null]})]}),e.unparsedNotice?(0,H.jsx)(`pre`,{className:X.diffNotice,children:e.unparsedNotice}):null,o.length===0?(0,H.jsx)(`p`,{className:X.diffEmpty,children:d??`No line-level changes in this call.`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`table`,{className:X.diffTable,children:(0,H.jsx)(`tbody`,{children:c.map(e=>e.kind===`hunk`?(0,H.jsxs)(`tr`,{className:X.diffHunkRow,children:[t?(0,H.jsx)(`td`,{className:X.diffNo,"aria-hidden":`true`}):null,(0,H.jsx)(`td`,{className:X.diffMarker,"aria-hidden":`true`}),(0,H.jsx)(`td`,{className:X.diffHunkHead,children:e.label})]},e.key):(0,H.jsxs)(`tr`,{className:X[`diffRow_${e.line.kind}`],children:[t?(0,H.jsx)(`td`,{className:X.diffNo,children:e.line.newLineNo??e.line.oldLineNo??``}):null,(0,H.jsx)(`td`,{className:X.diffMarker,"aria-hidden":`true`,children:e.line.kind===`add`?`+`:e.line.kind===`del`?`−`:``}),(0,H.jsx)(`td`,{className:X.diffText,children:(0,H.jsx)($u,{text:e.line.text,lang:a})})]},e.key))})}),s?(0,H.jsx)(`button`,{type:`button`,className:X.diffMore,onClick:()=>i(e=>!e),"aria-expanded":r,children:r?`Collapse diff`:`Show ${l} more line${l===1?``:`s`}`}):null]}),t?null:(0,H.jsx)(`p`,{className:X.diffUnanchored,children:`Line numbers are not shown — this tool call reported what it replaced, not where in the file.`})]})}function Qu(e){let t=[],n=!1;return e.forEach((r,i)=>{if(n)return;let a=r.header.replace(/^@@[^@]*@@/,``).trim();(a||e.length>1)&&t.push({kind:`hunk`,key:`h${i}`,label:a||`hunk ${i+1}`});for(let e=0;e<r.lines.length;e++){if(t.length>=Ju){n=!0,t.push({kind:`hunk`,key:`truncated`,label:`diff truncated at ${Ju} lines`});return}t.push({kind:`line`,key:`h${i}l${e}`,line:r.lines[e]})}}),t}function $u({text:e,lang:t}){let n=de(e,t);return(0,H.jsx)(`code`,{className:X.diffCode,children:n.map((e,t)=>(0,H.jsx)(`span`,{className:X[`tok_${e.kind}`],children:e.text},t))})}var ed=2e4;function td({name:e,input:t,result:n,toolUseId:r,durationMs:i=null,facts:a}){let o=(0,V.useMemo)(()=>a??Ho({name:e,input:t,result:n}),[a,e,t,n]),s=mt(t),c=o.failed||n?.isError===!0,l=n===null,u=l?`running`:c?`error`:i!==null&&i>0?ut(i):`done`,d=(0,V.useMemo)(()=>o.diff?Yo(o.diff.text):null,[o.diff]),f=n?n.output.length>ed?`${n.output.slice(0,ed)}\n… (${n.output.length-ed} more characters)`:n.output:``;return(0,H.jsxs)(`details`,{id:Uo(r),className:`${$.tool} ${c?$.toolFailed:``}`,"data-state-key":`tool:${r}`,"data-action":o.action,children:[(0,H.jsxs)(`summary`,{className:$.toolLine,"aria-label":`${e}${s?`: ${s}`:``} (${u})`,children:[(0,H.jsx)(`span`,{className:$.toolGlyph,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:$.toolName,children:e}),s?(0,H.jsx)(`span`,{className:$.toolArg,title:s,children:s}):null,d&&(d.additions>0||d.deletions>0)?(0,H.jsxs)(`span`,{className:$.toolDelta,"aria-hidden":`true`,children:[d.additions>0?(0,H.jsxs)(`span`,{className:$.toolAdd,children:[`+`,d.additions]}):null,d.deletions>0?(0,H.jsxs)(`span`,{className:$.toolDel,children:[`−`,d.deletions]}):null]}):null,(0,H.jsx)(`span`,{className:$.toolState,children:u})]}),(0,H.jsx)(`div`,{className:$.toolBody,children:(0,H.jsx)(nd,{input:t,output:f,facts:o,pending:l,isError:c})})]})}function nd({input:e,output:t,facts:n,pending:r,isError:i}){return n.command?(0,H.jsx)(Gu,{command:n.command,output:t,isError:i,pending:r,body:n.diff?(0,H.jsx)(Yu,{diff:n.diff,path:n.paths[0]??null}):void 0}):n.diff?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Yu,{diff:n.diff,path:n.paths[0]??null}),r?(0,H.jsx)(`p`,{className:$.toolPending,children:`Waiting for the tool to finish…`}):null,i&&t?(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h4`,{className:$.toolLabel,children:`Error`}),(0,H.jsx)(`pre`,{className:$.toolPre,children:t})]}):null]}):n.written?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`section`,{children:[(0,H.jsxs)(`h4`,{className:$.toolLabel,children:[`Contents written to `,n.written.path]}),(0,H.jsx)(`pre`,{className:$.toolPre,children:n.written.text}),(0,H.jsx)(`p`,{className:$.toolNote,children:`The previous contents were not in this tool call, so there is nothing to diff against.`})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h4`,{className:$.toolLabel,children:i?`Error`:`Result`}),r?(0,H.jsx)(`p`,{className:$.toolPending,children:`Waiting for the tool to finish…`}):(0,H.jsx)(`pre`,{className:$.toolPre,children:t||`(empty)`})]})]}):(0,H.jsxs)(H.Fragment,{children:[e==null?null:(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h4`,{className:$.toolLabel,children:`Input`}),(0,H.jsx)(`pre`,{className:$.toolPre,children:rt(e)})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h4`,{className:$.toolLabel,children:i?`Error`:`Result`}),r?(0,H.jsx)(`p`,{className:$.toolPending,children:`Waiting for the tool to finish…`}):(0,H.jsx)(`pre`,{className:$.toolPre,children:t||`(empty)`})]})]})}function rd(e,t){let n=e.trigger===`manual`?`Compacted on request`:`Auto-compacted`,r=e.durationMs!==null&&e.durationMs>0?` in ${ut(e.durationMs)}`:``;return e.preTokens!==null&&e.postTokens!==null?`${n} ${B(e.preTokens)} → ${B(e.postTokens)}${r}`:e.preTokens===null?`${t?ot[t]:`The CLI`} compacted its context${r}`:`${n} at ${B(e.preTokens)}${r}`}var id=48,ad=3,od=1400;function sd({transcript:e,loaded:t,loadError:n,onRetry:r,emptyHint:i,engine:a,handoffFrom:o=null,onOpenSession:s}){let c=(0,V.useRef)(null),l=(0,V.useRef)(new Map),u=(0,V.useRef)(null),[d,f]=(0,V.useState)(!0),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(``),[_,v]=(0,V.useState)(-1),[ee,y]=(0,V.useState)(0),b=(0,V.useRef)(0),x=(0,V.useRef)(Wo()),S=(0,V.useMemo)(()=>rn(e.items),[e.items]),C=(0,V.useMemo)(()=>Qo(S,x.current),[S]),w=(0,V.useMemo)(()=>os(C.turns,h,x.current),[C.turns,h]),T=(0,V.useMemo)(()=>new Set(w.map(e=>e.turnKey)),[w]),D=(0,V.useMemo)(()=>{let t=new Set,n=null;for(let r of e.items)r.kind!==`compaction`&&(r.kind===`turn-done`&&!r.ok&&n&&n.turnId===r.turnId&&(n.kind===`cancelled`||n.kind===`error`)&&t.add(r.key),n={turnId:r.turnId,kind:r.kind});return t},[e.items]),te=(0,V.useCallback)((e=`auto`)=>{let t=c.current;t&&(typeof t.scrollTo==`function`?t.scrollTo({top:t.scrollHeight,behavior:e}):t.scrollTop=t.scrollHeight)},[]);function ne(){let e=c.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<=id;f(t),t&&m(!1)}let O=(0,V.useCallback)(e=>{e&&(f(!1),typeof e.scrollIntoView==`function`&&e.scrollIntoView({block:`center`,behavior:`smooth`}),typeof e.focus==`function`&&e.focus({preventScroll:!0}),e.setAttribute(`data-flash`,`true`),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>e.removeAttribute(`data-flash`),od))},[]);(0,V.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]);let re=(0,V.useCallback)(e=>{O(l.current.get(e)??null)},[O]),k=(0,V.useCallback)(e=>{let t=c.current?.ownerDocument?.getElementById(e)??null;if(t){for(let e=t;e&&(e instanceof HTMLDetailsElement&&(e.open=!0),e!==c.current);e=e.parentElement);O(t)}},[O]),A=(0,V.useCallback)(e=>k(Uo(e)),[k]),j=(0,V.useCallback)(()=>{let e=C.errorAnchors[0];e&&k(e)},[C.errorAnchors,k]),M=(0,V.useCallback)(e=>{if(w.length===0)return;let t=_<0?e>0?0:w.length-1:(_+e+w.length)%w.length;v(t),re(w[t].turnKey)},[w,_,re]);(0,V.useEffect)(()=>{v(-1)},[h]);let N=(0,V.useCallback)(e=>{let t=C.turns;if(t.length===0)return;let n=c.current?.ownerDocument?.activeElement,r=n instanceof HTMLElement?n.getAttribute(`data-turn-key`):null,i=r?t.findIndex(e=>e.key===r):-1,a=i<0?e>0?0:t.length-1:Math.max(0,Math.min(t.length-1,i+e));re(t[a].key)},[C.turns,re]);(0,V.useEffect)(()=>{if(C.turns.length===0)return;let e=e=>{let t=e.target,n=t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement||t?.isContentEditable===!0;if((e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()===`f`){if(C.turns.length<ad)return;e.preventDefault(),y(e=>e+1);return}e.altKey&&!e.metaKey&&!e.ctrlKey&&!n&&(e.key===`ArrowDown`?(e.preventDefault(),N(1)):e.key===`ArrowUp`&&(e.preventDefault(),N(-1)))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[C.turns.length,N]);function P(e){e.target?.hasAttribute(`data-turn-key`)&&(e.key===`ArrowDown`?(e.preventDefault(),N(1)):e.key===`ArrowUp`?(e.preventDefault(),N(-1)):e.key===`Home`?(e.preventDefault(),re(C.turns[0].key)):e.key===`End`&&(e.preventDefault(),re(C.turns[C.turns.length-1].key)))}if((0,V.useLayoutEffect)(()=>{let t=e.items.length,n=e.items[t-1],r=t!==b.current||n?.kind===`assistant`&&n.streaming;b.current=t,r&&(d?te():m(!0))},[e,d,te]),(0,V.useEffect)(()=>{t&&te()},[t,te]),!t&&!n)return(0,H.jsx)(`div`,{className:$.transcript,"aria-busy":`true`,children:(0,H.jsxs)(`div`,{className:$.skeleton,children:[(0,H.jsx)(`div`,{className:$.skeletonUser,children:(0,H.jsx)(E,{width:`42%`})}),(0,H.jsx)(E,{width:`88%`}),(0,H.jsx)(E,{width:`72%`}),(0,H.jsx)(E,{width:`80%`}),(0,H.jsx)(`div`,{className:$.skeletonUser,children:(0,H.jsx)(E,{width:`30%`})}),(0,H.jsx)(E,{width:`64%`})]})});if(n)return(0,H.jsx)(`div`,{className:$.transcript,children:(0,H.jsxs)(`div`,{role:`alert`,className:$.loadError,children:[(0,H.jsx)(`p`,{children:n}),r?(0,H.jsx)(`button`,{type:`button`,onClick:r,children:`Retry`}):null]})});let ie=_>=0?w[_]?.turnKey??null:null;return(0,H.jsxs)(`div`,{className:$.transcriptWrap,children:[C.turns.length>=ad?(0,H.jsx)(ps,{turns:C.turns,query:h,onQuery:g,matches:w,matchIndex:_,onStepMatch:M,errorCount:C.errorAnchors.length,onJumpError:j,onJumpTurn:re,focusToken:ee}):null,(0,H.jsxs)(`div`,{ref:c,className:$.transcript,onScroll:ne,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,children:[o?(0,H.jsxs)(`p`,{className:$.continued,"data-kind":`handoff-from`,children:[(0,H.jsx)(`span`,{className:$.continuedLabel,children:`Continued from`}),` `,s?(0,H.jsx)(`button`,{type:`button`,className:$.continuedLink,onClick:()=>s(o.sessionId),title:`Open the chat this one continues`,children:o.title||`Untitled chat`}):(0,H.jsx)(`span`,{className:$.continuedTitle,children:o.title||`Untitled chat`})]}):null,e.items.length===0?(0,H.jsxs)(`div`,{className:$.empty,children:[(0,H.jsx)(`p`,{className:$.emptyTitle,children:o?`Review the handoff, then send it.`:`Say something to begin.`}),(0,H.jsx)(`p`,{className:$.emptyBody,children:i??(o?`The note in the message box was drafted from the previous chat's log. Edit it freely — nothing is sent until you press Send.`:`The agent can read and edit this project. Ask for a change, a review, or an explanation.`)})]}):null,(0,H.jsxs)(`ol`,{className:$.list,onKeyDown:P,children:[C.turns.map((e,t)=>(0,H.jsxs)(`li`,{id:qo(e.key),ref:t=>{t?l.current.set(e.key,t):l.current.delete(e.key)},className:$.turn,"data-turn-key":e.key,"data-status":e.status,"data-match":T.has(e.key)?e.key===ie?`active`:`true`:void 0,tabIndex:-1,"aria-label":`Turn ${t+1} of ${C.turns.length}`,children:[(0,H.jsx)(`ol`,{className:$.turnItems,children:e.items.map(e=>cd(e,C.facts,D,a))}),e.files.length>0?(0,H.jsx)(us,{files:e.files,onJump:A}):null,e.errorCount>0&&e.firstErrorAnchor?(0,H.jsxs)(`button`,{type:`button`,className:$.turnErrorJump,onClick:()=>k(e.firstErrorAnchor),children:[e.errorCount,` failure`,e.errorCount===1?``:`s`,` in this turn — jump to the first`]}):null]},e.key)),e.live&&!e.items.some(e=>e.kind===`assistant`&&e.streaming)?(0,H.jsx)(`li`,{className:`${$.item} ${$.assistant}`,"data-kind":`pending`,"aria-label":`Waiting for the agent`,children:(0,H.jsx)(`span`,{className:$.caret,"aria-hidden":`true`})}):null]})]}),d?null:(0,H.jsxs)(`button`,{type:`button`,className:`${$.jump} ${p?$.jumpUnseen:``}`,onClick:()=>{f(!0),m(!1),te(`smooth`)},children:[(0,H.jsx)(he,{size:12}),` Jump to latest`]})]})}function cd(e,t,n,r){switch(e.kind){case`user`:return(0,H.jsx)(`li`,{className:`${$.item} ${$.user}`,"data-kind":`user`,children:(0,H.jsx)(`div`,{className:$.userText,children:e.text})},e.key);case`assistant`:return(0,H.jsx)(`li`,{className:`${$.item} ${$.assistant}`,"data-kind":`assistant`,"data-streaming":e.streaming||void 0,children:(0,H.jsx)(ju,{text:e.text,streaming:e.streaming})},e.key);case`thinking`:return(0,H.jsx)(`li`,{className:$.item,"data-kind":`thinking`,children:(0,H.jsx)(ld,{item:e})},e.key);case`tool`:return(0,H.jsx)(`li`,{className:$.item,"data-kind":`tool`,children:(0,H.jsx)(td,{name:e.name,input:e.input,result:e.result,toolUseId:e.toolUseId,durationMs:e.durationMs,facts:t.get(e.toolUseId)})},e.key);case`toolGroup`:return(0,H.jsx)(`li`,{className:$.item,"data-kind":`tool-group`,children:(0,H.jsx)(ud,{item:e,facts:t})},e.key);case`error`:return(0,H.jsx)(`li`,{className:$.item,"data-kind":`error`,children:(0,H.jsx)(`div`,{id:Ko(e.key),role:`alert`,className:`${$.note} ${$.noteError}`,children:e.message})},e.key);case`compaction`:return(0,H.jsxs)(`li`,{className:`${$.item} ${$.compaction}`,"data-kind":`compaction`,children:[(0,H.jsx)(`span`,{className:$.compactionRule,"aria-hidden":`true`}),(0,H.jsxs)(`span`,{className:$.compactionText,children:[(0,H.jsx)(`span`,{className:$.compactionTitle,children:rd(e,r)}),(0,H.jsx)(`span`,{className:$.compactionNote,children:`Earlier turns now reach the agent only as a summary; the full transcript stays here.`})]}),(0,H.jsx)(`span`,{className:$.compactionRule,"aria-hidden":`true`})]},e.key);case`cancelled`:return(0,H.jsx)(`li`,{className:$.item,"data-kind":`cancelled`,children:(0,H.jsx)(`div`,{className:$.note,children:`Stopped.`})},e.key);case`turn-done`:return e.ok||n.has(e.key)?e.durationMs>0?(0,H.jsx)(`li`,{className:`${$.item} ${$.meta}`,"data-kind":`turn-done`,children:(0,H.jsx)(`span`,{className:$.metaText,children:ut(e.durationMs)})},e.key):null:(0,H.jsx)(`li`,{className:$.item,"data-kind":`turn-done`,children:(0,H.jsxs)(`div`,{id:Ko(e.key),className:`${$.note} ${$.noteError}`,children:[`Turn ended without a result (`,(0,H.jsx)(`span`,{className:$.noteDuration,children:ut(e.durationMs)}),`).`]})},e.key);default:return null}}function ld({item:e}){return(0,H.jsxs)(`details`,{className:$.thinking,"data-state-key":`thinking:${e.key}`,children:[(0,H.jsx)(`summary`,{className:$.thinkingSummary,children:`Thinking`}),(0,H.jsx)(`div`,{className:$.thinkingBody,children:e.text})]})}function ud({item:e,facts:t}){let n=e.pending?`running`:e.errorCount>0?`${e.errorCount} failed`:e.spanMs!==null&&e.spanMs>0?ut(e.spanMs):`done`,r=`${e.toolCount} tool${e.toolCount===1?``:`s`}`;return(0,H.jsxs)(`details`,{className:`${$.toolRun} ${e.errorCount>0?$.toolFailed:``}`,"data-state-key":`toolgroup:${e.key}`,children:[(0,H.jsxs)(`summary`,{className:$.toolLine,"aria-label":`${r}: ${e.summary} (${n})`,children:[(0,H.jsx)(`span`,{className:$.toolGlyph,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:$.toolName,children:r}),e.summary?(0,H.jsx)(`span`,{className:$.toolArg,title:e.summary,children:e.summary}):null,(0,H.jsx)(`span`,{className:$.toolState,children:n})]}),(0,H.jsx)(`div`,{className:$.toolRunBody,children:(0,H.jsx)(`ol`,{className:$.toolRunList,children:e.items.map(e=>(0,H.jsx)(`li`,{"data-member":e.kind,children:e.kind===`tool`?(0,H.jsx)(td,{name:e.name,input:e.input,result:e.result,toolUseId:e.toolUseId,durationMs:e.durationMs,facts:t.get(e.toolUseId)}):(0,H.jsx)(ld,{item:e})},e.key))})})]})}var dd=3e4;function fd(e=!0){let t=F(De);(0,V.useEffect)(()=>{if(!e)return;let n=()=>{(typeof document>`u`||document.visibilityState!==`hidden`)&&t()},r=window.setInterval(n,dd);return document.addEventListener(`visibilitychange`,n),()=>{window.clearInterval(r),document.removeEventListener(`visibilitychange`,n)}},[e,t])}function pd(e){let{view:t,seats:n,projects:r,dispatchEnabled:i,locked:a,hasAnySessions:o,onSend:s,onStop:c,onRename:l,onDelete:u,onSeatChange:d,onNew:f,onRetry:p,sidebarCollapsed:m,onToggleSidebar:g,resourcesOpen:_,onToggleResources:v,onOpenSession:y}=e,b=t.session,[x,S]=(0,V.useState)(!1),[C,w]=(0,V.useState)(``),[T,E]=(0,V.useState)(!1),[D,te]=(0,V.useState)(!1),[O,re]=(0,V.useState)({busy:!1,error:null}),[k,A]=(0,V.useState)(!1),[j,M]=(0,V.useState)(!1),[N,P]=(0,V.useState)(null),ie=(0,V.useRef)(null),F=(0,V.useId)();fd(),(0,V.useEffect)(()=>{S(!1),E(!1),re({busy:!1,error:null}),A(!1),M(!1),P(null)},[t.sessionId]);let ae=ii(),oe=ae.run,se=t.session?.id??null,le=(0,V.useCallback)(async e=>{if(se){re({busy:!0,error:null});try{let t=await oe(`Changing the context mode changes the compaction flag this chat runs with from its next turn.`,()=>wn(se,e));t&&zt(t.id,t),re({busy:!1,error:null})}catch(e){re({busy:!1,error:ai(e)})}}},[se,oe]),ue=(0,V.useCallback)((e,t)=>{h(e.id,t),ge(e.projectPath,{seatId:e.seatId,model:e.model}),zt(e.id,e),We(),A(!1),y?y(e.id):P({title:e.title})},[y]);(0,V.useEffect)(()=>{x&&ie.current?.select()},[x]);let de=(0,H.jsxs)(`div`,{className:Y.toggles,role:`group`,"aria-label":`Panels`,children:[(0,H.jsx)(hd,{collapsed:m,onToggle:g}),(0,H.jsx)(gd,{open:_,onToggle:v})]});if(!t.sessionId)return(0,H.jsxs)(`section`,{className:Y.workspace,"aria-label":`Chat`,children:[(0,H.jsxs)(`header`,{className:Y.header,"data-app-region":`drag`,children:[(0,H.jsx)(md,{eyebrow:(0,H.jsx)(`span`,{className:Y.eyebrow,children:`Chat`}),title:(0,H.jsx)(`span`,{className:Y.titleStatic,"data-state":`empty`,children:o?`No chat selected`:`No chats yet`})}),(0,H.jsx)(`div`,{className:Y.headerSpacer}),(0,H.jsx)(`div`,{className:Y.actions,children:de})]}),(0,H.jsxs)(`div`,{className:Y.emptyState,children:[(0,H.jsx)(`span`,{className:Y.emptyMark,"aria-hidden":`true`,children:(0,H.jsx)(Se,{size:36})}),(0,H.jsx)(`h1`,{className:Y.emptyTitle,children:o?`Pick a chat, or start a new one`:`No chats yet — ⌘N`}),(0,H.jsx)(`p`,{className:Y.emptyBody,children:`Open a project, choose a seat — a Claude or Codex account, Grok, or a local Ollama model — and talk to an agent that can edit that project.`}),(0,H.jsxs)(`button`,{type:`button`,className:Y.emptyButton,onClick:f,children:[`New chat `,(0,H.jsx)(`kbd`,{children:`⌘N`})]}),i?null:(0,H.jsxs)(`p`,{className:Y.emptyWarn,role:`status`,children:[`This server was started without dispatch, so chats are read-only here. Run `,(0,H.jsx)(`code`,{children:`ashlr verse`}),` to enable sending.`]})]})]});async function fe(){let e=C.trim();if(S(!1),b&&e&&e!==b.title){te(!0);try{await l(e)}finally{te(!1)}}}function pe(e){e.key===`Enter`?(e.preventDefault(),fe()):e.key===`Escape`&&(e.preventDefault(),S(!1))}let I=b?.status===`running`,L=b?Je(n,b):null,R=b?.contextMode??`standard`,me=b!==null&&L!==null&&ee(b.engine)&&(ne(L.option)||R===`expansive`),he=b?Ze(n,b.seatId)??null:null,_e=he===null?null:Gn(he),z=b===null?``:`${he===null||_e===null?$e(n,b):qn(he,_e)} · ${b.projectPath}`,ve=i?null:`Sending is disabled: this server was started without dispatch.`,ye=ve??(I?`Available when the current turn finishes — the mode cannot change mid-turn.`:null),be=b!==null&&so(b.engine),xe=be?()=>{P(null),M(!0)}:void 0,Ce=b!==null&&b.turnCount===0?`nothing to compact yet — this chat has no turns`:null,we=Ht(t.events);return(0,H.jsxs)(`section`,{className:Y.workspace,"aria-labelledby":F,children:[(0,H.jsxs)(`header`,{className:Y.header,"data-app-region":`drag`,children:[(0,H.jsx)(md,{eyebrow:b?(0,H.jsx)(`span`,{className:Y.eyebrow,title:b.projectPath,children:nt(b.projectPath,r)}):(0,H.jsx)(`span`,{className:`${Y.eyebrow} skeleton ${Y.eyebrowSkeleton}`,"aria-hidden":`true`}),title:b?x?(0,H.jsx)(`input`,{ref:ie,className:Y.titleInput,value:C,"aria-label":`Chat title`,onChange:e=>w(e.target.value),onBlur:()=>{fe()},onKeyDown:pe,maxLength:120}):(0,H.jsx)(`h1`,{id:F,className:Y.title,children:(0,H.jsx)(`button`,{type:`button`,className:Y.titleButton,title:`Rename chat`,disabled:D||!i,onClick:()=>{w(b.title),S(!0)},children:b.title||`Untitled chat`})}):(0,H.jsx)(`h1`,{id:F,className:`${Y.titleStatic} skeleton ${Y.titleSkeleton}`,"aria-label":`Loading chat`})}),b?(0,H.jsxs)(`span`,{className:`${Y.seatPill} ${Y[`engine-${b.engine}`]??``}`,"data-engine":b.engine,"data-seat-capacity":_e!==null&&Jn(_e.cls)?_e.cls:void 0,title:z,children:[(0,H.jsx)(`span`,{className:Y.engineDot,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:Y.seatText,children:$e(n,b)}),_e!==null&&Jn(_e.cls)?(0,H.jsx)(Zn,{view:_e}):null]}):null,(0,H.jsx)(`div`,{className:Y.headerSpacer}),(0,H.jsxs)(`div`,{className:Y.actions,children:[t.stream===`reconnecting`?(0,H.jsx)(`span`,{className:Y.streamState,role:`status`,children:`reconnecting…`}):null,b&&L?(0,H.jsx)(Ya,{contextTokens:L.contextTokens,contextWindow:L.contextWindow,autoCompactAt:L.autoCompactAt,exact:L.exact,source:L.source,mode:me?R:null,engine:b.engine,compactionCount:b.compactionCount??0}):null,b&&L&&(me||be)?(0,H.jsx)(no,{mode:R,option:L.option,busy:O.busy,error:O.error,disabled:!i||I,disabledReason:ye,modesAvailable:me,engine:b.engine,budget:L,compactUnavailableReason:Ce,onChange:e=>{le(e)},onCompact:xe}):null,b?T?(0,H.jsxs)(`span`,{className:Y.confirm,role:`group`,"aria-label":`Confirm delete`,children:[(0,H.jsx)(`span`,{className:Y.confirmText,children:`Delete this chat?`}),(0,H.jsx)(`button`,{type:`button`,className:Y.danger,disabled:D,onClick:async()=>{te(!0);try{await u()||E(!1)}finally{te(!1)}},children:`Delete`}),(0,H.jsx)(`button`,{type:`button`,className:Y.ghost,onClick:()=>E(!1),children:`Keep`})]}):(0,H.jsx)(`button`,{type:`button`,className:Y.ghostIcon,onClick:()=>E(!0),disabled:!i||I,"aria-label":`Delete chat`,title:I?`Stop the turn before deleting`:`Delete chat`,children:(0,H.jsx)(Ee,{})}):null,(0,H.jsx)(`span`,{className:Y.actionDivider,"aria-hidden":`true`}),de]})]}),b&&L?(0,H.jsx)(oo,{session:b,budget:L,modesAvailable:me,dispatchEnabled:i,modeBusy:O.busy,onHandoff:()=>{P(null),A(!0)},onSwitchExpansive:()=>{le(`expansive`)},onCompact:xe,lastTurnAt:we}):null,b&&L&&be&&j?(0,H.jsx)(`div`,{className:Y.advice,children:(0,H.jsx)(uo,{engine:b.engine,budget:L,running:I,dispatchEnabled:i,empty:b.turnCount===0,onSend:s,onClose:()=>M(!1)})}):null,N?(0,H.jsx)(`div`,{className:Y.advice,children:(0,H.jsxs)(`p`,{className:Y.adviceStatus,role:`status`,children:[`Started “`,N.title,`” — open it from the chat list; the handoff note is waiting in its message box.`]})}):null,(0,H.jsx)(sd,{transcript:t.transcript,loaded:t.loaded,loadError:t.loadError,onRetry:p,engine:b?.engine,handoffFrom:b?.handoffFrom??null,onOpenSession:y}),b?(0,H.jsx)(Na,{sessionId:b.id,seats:n,seat:{seatId:b.seatId,model:b.model},engine:b.engine,running:I,disabled:!i,disabledReason:ve,locked:a,hintSeen:b.turnCount>0,contextTokens:L?.contextTokens??null,contextWindow:L?.contextWindow??null,autoCompactAt:L?.autoCompactAt??null,contextExact:L?.exact??!0,handoffDraft:b.handoffFrom!==void 0&&b.turnCount===0,onSend:s,onStop:c,onSeatChange:d,autoFocus:!0},b.id):null,b&&k?(0,H.jsx)(Ua,{session:b,seats:n,open:!0,onClose:()=>A(!1),onCreated:ue}):null,(0,H.jsx)(ce,{...ae.dialog,tokenLabel:`Mutation token`,tokenHelp:`the mutation token ashlr verse printed`})]})}function md({eyebrow:e,title:t}){return(0,H.jsxs)(`div`,{className:Y.identity,children:[e,t]})}function hd({collapsed:e,onToggle:t}){return(0,H.jsx)(`button`,{type:`button`,className:Y.ghostIcon,onClick:t,"aria-pressed":!e,title:e?`Show chat list`:`Hide chat list`,"aria-label":e?`Show chat list`:`Chat list`,children:(0,H.jsx)(we,{})})}function gd({open:e,onToggle:t}){return(0,H.jsx)(`button`,{type:`button`,className:Y.ghostIcon,onClick:t,"aria-pressed":e,title:e?`Hide resources`:`Show resources`,"aria-label":`Resources`,children:(0,H.jsx)(Be,{})})}var _d={chat:`_chat_ei2ma_14`,main:`_main_ei2ma_44`,banner:`_banner_ei2ma_54`,bannerWarn:`_bannerWarn_ei2ma_55`,resize:`_resize_ei2ma_98`,scrim:`_scrim_ei2ma_12`},vd=`ashlr.verse.selected.v1`;function yd(){try{return localStorage.getItem(vd)}catch{return null}}function bd(e){return e instanceof S?"This server was started without dispatch — run `ashlr verse` to chat.":e instanceof j?e.code===`VERSE_MODEL_UNAVAILABLE`?`${(e.detail??`This chat's model cannot run on its seat.`).replace(/\.?$/,`.`)} Continue in a fresh chat on a model this seat can run, or re-pin the seat's CLI (\`ashlr resources profile repin\`).`:e.status===409&&(e.code===null||e.code===`VERSE_SESSION_BUSY`)?`A turn is already running in this chat. Stop it first.`:e.status===413?`That message is too large (64 KB max).`:e.status===401?`Mutation token was rejected. Unlock again with the token ashlr verse printed.`:e.detail??e.message:e instanceof Error?e.message:`Something went wrong.`}function xd(){let e=ie(De),t=ie(qe),n=x(qe),r=x(De),i=y(),a=se(),o=Ke(),[s,c]=(0,V.useState)(yd),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)({open:!1}),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(!1),[ee,b]=(0,V.useState)(0),[S,C]=(0,V.useState)({open:!1,reason:``}),w=(0,V.useRef)(null),T=(0,V.useRef)(null),E=xa(),D=(0,V.useMemo)(()=>e.data?.seats??[],[e.data]),ne=(0,V.useMemo)(()=>e.data?.projects??[],[e.data]),O=ie(ke),re=(0,V.useMemo)(()=>O.data?.workspaces??[],[O.data]),k=e.data?.dispatchEnabled??!0,A=Xi(s,ee),j=(0,V.useMemo)(()=>{let n=t.data??e.data?.sessions??[];if(!A.session)return n;let r=A.session;return n.some(e=>e.id===r.id)?n.map(e=>e.id===r.id?r:e):[r,...n]},[t.data,e.data,A.session]),M=(0,V.useCallback)(e=>{c(e);try{e?localStorage.setItem(vd,e):localStorage.removeItem(vd)}catch{}},[]);(0,V.useEffect)(()=>{s&&t.data&&!t.data.some(e=>e.id===s)&&!A.session&&M(null)},[s,t.data,A.session,M]),(0,V.useEffect)(()=>Yi(),[]);let N=(0,V.useCallback)((e,t)=>i.hasHold?t():new Promise((n,r)=>{w.current={run:()=>{t().then(n,r)},cancel:()=>n(null)},C({open:!0,reason:e})}),[i.hasHold]),P=(0,V.useCallback)(e=>{e instanceof Le||a.show(bd(e),`danger`)},[a]),F=(0,V.useCallback)((e={})=>{g(null);let t=A.session,n=e.projectPath===void 0?t?.projectPath??null:e.projectPath,r=t&&n===t.projectPath?{seatId:t.seatId,model:t.model}:null,i=e.seat??r??me(n);f({open:!0,projectPath:n,seat:i})},[A.session]),oe=(0,V.useCallback)(async e=>{await N(`Starting a chat spawns an agent process for this project.`,async()=>{m(!0),g(null);try{let t=await Pe(e);ge(t.projectPath,{seatId:t.seatId,model:t.model}),zt(t.id,t),f({open:!1}),M(t.id),a.show(`Started “${t.title}”`,`success`)}catch(e){g(bd(e))}finally{m(!1)}})},[N,M,a]),le=(0,V.useCallback)(async e=>{let t=s;return t?await N(`Sending a message runs the agent against this project.`,async()=>{Bt(t,`running`);try{let n=await Me(t,e);return zt(t,n.session,n.turnId),!0}catch(e){return Bt(t,`idle`),P(e),!1}})===!0:!1},[s,N,P]),ue=(0,V.useCallback)((e=s)=>{e&&N(`Stopping the running turn.`,async()=>{try{await Ve(e)}catch(e){P(e)}})},[s,N,P]),de=(0,V.useCallback)(async e=>{let t=s;return t?await N(`Renaming a chat.`,async()=>{try{let n=await je(t,e);return zt(t,n),!0}catch(e){return P(e),!1}})===!0:!1},[s,N,P]),fe=(0,V.useCallback)(async()=>{let e=s;return e?await N(`Deleting a chat removes its transcript from disk.`,async()=>{try{return await Re(e),Wt(e),ae(e),M(null),a.show(`Chat deleted.`,`neutral`),!0}catch(e){return P(e),!1}})===!0:!1},[s,N,P,M,a]),pe=(0,V.useCallback)(e=>{let t=A.session;t&&(F({projectPath:t.projectPath,seat:e}),a.show(`Chats are bound to one seat — starting a new chat on the same project.`,`neutral`))},[A.session,F,a]),I=(0,V.useRef)(0);(0,V.useEffect)(()=>{let e=o.command;e&&e.nonce!==I.current&&(I.current=e.nonce,e.name===`quick-switcher`?v(!0):F(),ye())},[o.command,A.session,F]);let L=e.data?!e.data.dispatchEnabled:!1,R=o.resourcesOpen,he=o.sidebarCollapsed;(0,V.useEffect)(()=>{let e=T.current;if(!e)return;let t=()=>ga({containerWidth:e.clientWidth,sidebarVisible:!he,resourcesVisible:R});t();let n=typeof ResizeObserver==`function`?new ResizeObserver(t):null;return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[he,R]);let _e={"--verse-sidebar-width":`${E.effective.sidebar}px`,"--verse-resources-width":`${E.effective.resources}px`};return(0,H.jsxs)(`div`,{ref:T,className:_d.chat,style:_e,"data-sidebar":he?`collapsed`:`open`,"data-resources":R?`open`:`closed`,children:[(0,H.jsx)(Vi,{sessions:j,sessionsStatus:t.status,sessionsError:t.error?.message??null,projects:ne,seats:D,selectedId:s,query:l,onQuery:u,onSelect:e=>{M(e),window.matchMedia?.(`(max-width: 760px)`)?.matches===!0&&Ce(!0)},onNew:()=>F(),onRetry:()=>{n(),r()},onCollapse:()=>Ce(!0),onDisconnect:()=>{te()}}),he?null:(0,H.jsx)(wa,{side:`sidebar`,label:`Resize chat list`,className:_d.resize}),(0,H.jsx)(`button`,{type:`button`,className:_d.scrim,"aria-label":`Close chat list`,tabIndex:-1,onClick:()=>Ce(!0)}),(0,H.jsxs)(`div`,{className:_d.main,children:[e.status===`error`&&!e.data?(0,H.jsxs)(`div`,{role:`alert`,className:_d.banner,children:[(0,H.jsx)(`span`,{children:e.error?.message??`Could not load Verse.`}),(0,H.jsx)(`button`,{type:`button`,onClick:r,children:`Retry`})]}):L?(0,H.jsxs)(`div`,{role:`status`,className:_d.bannerWarn,children:[`Read-only: this server was started without dispatch. Run `,(0,H.jsx)(`code`,{children:`ashlr verse`}),` to send messages.`]}):null,(0,H.jsx)(pd,{view:A,seats:D,projects:ne,dispatchEnabled:k,locked:!i.hasHold,hasAnySessions:j.length>0,onSend:le,onStop:()=>ue(),onRename:de,onDelete:fe,onSeatChange:pe,onNew:()=>F(),onRetry:()=>b(e=>e+1),sidebarCollapsed:he,onToggleSidebar:()=>Ce(!he),resourcesOpen:R,onToggleResources:()=>ve(!R),onOpenSession:M})]}),R?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(wa,{side:`resources`,label:`Resize resources panel`,className:_d.resize}),(0,H.jsx)(Ii,{bootstrap:e.data,sessions:j,current:A.session,events:A.events,onStop:e=>ue(e),onOpen:M,onClose:()=>ve(!1)})]}):null,(0,H.jsx)(xr,{open:d.open,onClose:()=>f({open:!1}),projects:ne,seats:D,workspaces:re,initialProjectPath:d.projectPath??null,initialSeat:d.seat??null,busy:p,error:h,onCreate:oe,runMutation:N}),(0,H.jsx)(Tr,{open:_,onClose:()=>v(!1),sessions:j,seats:D,projects:ne,onSelectSession:M,onNewChat:e=>F({projectPath:A.session?.projectPath??null,seat:e})}),(0,H.jsx)(ce,{open:S.open,reason:S.reason,tokenLabel:`Mutation token`,tokenHelp:`the mutation token ashlr verse printed`,onClose:()=>{C({open:!1,reason:``});let e=w.current;e&&setTimeout(()=>{w.current===e&&(w.current=null,e.cancel())},0)},onUnlocked:()=>{let e=w.current;w.current=null,e?.run()}})]})}export{xd as ChatSection,bd as describeChatError};
84
- //# sourceMappingURL=ChatSection-hlgPBRco.js.map
84
+ //# sourceMappingURL=ChatSection-bzwFdbdw.js.map