ccdeck 3.33.0 → 3.33.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.
@@ -1 +1 @@
1
- import{j as e,r as c,k as _,l as V,m as Y,n as z,s as X,u as Z,g as ee}from"./index-OLDoLpOW.js";function se({snap:s}){return e.jsxs("section",{className:"bw-feed",children:[e.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Live activity",e.jsxs("span",{className:"bw-feed-count",children:[s.log.length," ",s.log.length===1?"event":"events"]})]}),e.jsx("p",{className:"bw-since bw-feed-note",children:"Pages you opened yourself — counted to run the rule, never written down. Addresses appear under Findings, and only for pages a program opened."}),e.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:s.log.length===0?e.jsx("p",{className:"bw-note",children:"The deck writes a line here each time it looks at a profile."}):s.log.map(t=>e.jsxs("div",{className:`bw-log-line ${t.level}${t.parts?"":" sys"}`,children:[e.jsx("span",{className:"bw-log-time",children:new Date(t.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),t.parts?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bw-log-browser",children:t.parts.browser}),e.jsx("span",{className:"bw-log-profile",title:t.parts.profile,children:t.parts.profile}),e.jsxs("span",{className:"bw-log-value",children:[t.parts.value,t.parts.flagged>0&&e.jsxs("span",{className:"bw-log-flag",children:[" · ",t.parts.flagged," flagged"]})]})]}):e.jsx("span",{className:"bw-log-sys",children:t.text})]},`${t.atMs}-${t.level}-${t.text}`))})]})}const E=s=>`${s.host}-${s.startMs}`;function te(s){const t=l=>new Date(l).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1});return s.count===1||s.endMs-s.startMs<6e4?t(s.startMs):`${t(s.startMs)} → ${t(s.endMs)}`}function ne(s){return new Date(s).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function U(s){const t=Math.round((s.endMs-s.startMs)/6e4);return t<1?"":`${t} min`}function ae({snap:s,dismiss:t,refreshRef:l}){const[r,h]=c.useState(null),o=c.useRef(new Map),a=c.useRef(null);c.useEffect(()=>{var i,w;const d=a.current;!d||s.episodes.some(m=>E(m)===d.id)||(a.current=null,_(((i=document.activeElement)==null?void 0:i.tagName)??null)&&((w=(d.next?o.current.get(d.next):void 0)??l.current)==null||w.focus()))},[s]);const n=d=>{a.current={id:E(d),next:V(s.episodes.map(E),E(d))},t(d)},u=c.useMemo(()=>{const d=[];for(const i of s.episodes){const w=ne(i.startMs),m=d[d.length-1];m&&m.label===w?m.episodes.push(i):d.push({label:w,episodes:[i]})}return d},[s]);return e.jsxs("section",{className:"bw-findings",children:[e.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Findings",s.episodes.length>0&&e.jsxs("span",{className:"bw-feed-count",children:[s.episodes.length," ",s.episodes.length===1?"episode":"episodes"]})]}),e.jsx("div",{className:"bw-eps",children:u.length===0?e.jsxs("div",{className:"bw-empty",children:[e.jsx("p",{className:"bw-empty-head",children:"Nothing found yet"}),e.jsxs("p",{className:"bw-empty-note",children:["An episode lands here when a program opens pages in a browser nobody has touched for"," ",s.settings.quietMinutes," ",s.settings.quietMinutes===1?"minute":"minutes",". On most machines that is rare, so an empty list is the ordinary result rather than a sign something is wrong."]}),!s.settings.enabled&&e.jsx("p",{className:"bw-empty-note",children:"Watching is off, so this shows only what this deck has seen since it started. Anything an earlier run recorded comes back when you switch it on."})]}):u.map(d=>e.jsxs("div",{className:"bw-day",children:[e.jsx("h4",{className:"bw-sec-head",children:d.label}),d.episodes.map(i=>{const w=E(i),m=r===w;return e.jsxs("div",{className:`bw-ep${m?" open":""}`,children:[e.jsxs("div",{className:"bw-ep-row",children:[e.jsxs("button",{className:"bw-ep-head",ref:b=>{b?o.current.set(w,b):o.current.delete(w)},onClick:()=>h(m?null:w),"aria-expanded":m,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:m?"▾":"▸"}),e.jsx("span",{className:"bw-ep-host",children:i.host}),e.jsxs("span",{className:"bw-ep-meta",children:[te(i),U(i)&&e.jsxs(e.Fragment,{children:[" · ",U(i)]}),i.provisional&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{title:"Its quiet window has not closed yet. If somebody used the browser in the minutes after it, it is withdrawn; until then it is not written down and no reaction runs.",children:"provisional"})]})]}),e.jsxs("span",{className:"bw-ep-count",children:[i.count," ",i.count===1?"page":"pages"]})]}),e.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>n(i),"aria-label":`Dismiss ${i.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),m&&e.jsx("ul",{className:"bw-urls",children:i.urls.map((b,y)=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-url-time",children:new Date(b.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),e.jsx("span",{className:"bw-url",children:b.url})]},`${b.url}-${b.timeMs}-${y}`))})]},w)})]},d.label))})]})}function re(s){const t=/^#?([0-9a-f]{6})$/i.exec((s??"").trim());if(!t)return!1;const l=parseInt(t[1],16),r=[l>>16&255,l>>8&255,l&255].map(h=>{const o=h/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)});return .2126*r[0]+.7152*r[1]+.0722*r[2]>.5}const G=1e4,ie=12e3;function oe({browsers:s,findings:t,watching:l,palette:r}){const h=c.useRef(null),o=c.useRef(null);return o.current={browsers:s,findings:t,watching:l},c.useEffect(()=>{var m;const a=h.current;if(!a)return;const n=a.getContext("2d");if(!n)return;const u=((m=window.matchMedia)==null?void 0:m.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let d=0,i=!1;const w=()=>{var q;if(i)return;const b=o.current;if(!b)return;const{browsers:y,findings:p,watching:P}=b,R=r["--accent"]||"#7dd3fc",f=r["--line"]||"#1f2229",j=r["--text-dim"]||"#6e727c",C=re(r["--bg"]),N=C?42:26,v=C?.85:.65,I=Date.now(),$=Math.min(window.devicePixelRatio||1,2),W=a.clientWidth,k=a.clientHeight;(a.width!==W*$||a.height!==k*$)&&(a.width=W*$,a.height=k*$),n.setTransform($,0,0,$,0,0),n.clearRect(0,0,W,k);const x=W/2,M=k/2,S=Math.min(W,k)/2-6;n.strokeStyle=f,n.lineWidth=1,n.globalAlpha=C?1:.9;for(const g of[.4,.7,1])n.beginPath(),n.arc(x,M,S*g,0,Math.PI*2),n.stroke();n.beginPath(),n.moveTo(x-S,M),n.lineTo(x+S,M),n.moveTo(x,M-S),n.lineTo(x,M+S),n.stroke(),n.globalAlpha=1;const A=(P&&!u?I%G/G:0)*Math.PI*2-Math.PI/2;if(P){const g=(q=n.createConicGradient)==null?void 0:q.call(n,A-.85,x,M);g&&(g.addColorStop(0,"transparent"),g.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${R} ${N}%, transparent)`),g.addColorStop(1,"transparent"),n.fillStyle=g,n.beginPath(),n.moveTo(x,M),n.arc(x,M,S,A-.85,A),n.closePath(),n.fill()),n.strokeStyle=R,n.globalAlpha=v,n.beginPath(),n.moveTo(x,M),n.lineTo(x+Math.cos(A)*S,M+Math.sin(A)*S),n.stroke(),n.globalAlpha=1}y.forEach((g,T)=>{const B=T/Math.max(y.length,1)*Math.PI*2-Math.PI/2,D=g.lastReadMs===null?1:Math.min(1,(I-g.lastReadMs)/12e4),O=S*(.42+D*.5),F=x+Math.cos(B)*O,L=M+Math.sin(B)*O,Q=Math.abs((A-B+Math.PI*3)%(Math.PI*2)-Math.PI),K=P?Math.max(0,1-Q/.55):0;n.beginPath(),n.arc(F,L,3+K*1.6,0,Math.PI*2),n.fillStyle=g.running?R:j,n.globalAlpha=g.running?.55+K*.45:.35,n.fill(),n.globalAlpha=1});for(const g of p){const T=(I-g.atMs)/ie;if(T<0||T>1)continue;const D=Math.max(0,y.findIndex(L=>L.key===g.browser))/Math.max(y.length,1)*Math.PI*2-Math.PI/2,O=x+Math.cos(D)*S*.6,F=M+Math.sin(D)*S*.6;n.beginPath(),n.arc(O,F,4+T*22,0,Math.PI*2),n.strokeStyle=R,n.globalAlpha=(1-T)*.8,n.lineWidth=1.5,n.stroke(),n.globalAlpha=1}d=requestAnimationFrame(w)};return w(),()=>{i=!0,cancelAnimationFrame(d)}},[r]),e.jsx("canvas",{ref:h,className:"bw-radar",role:"img","aria-label":l?`Watching ${s.length} browser${s.length===1?"":"s"}`:"Not watching"})}function le(s,t,l){if(s===null)return null;const r=s+t-l;return r>0?r:null}function ce(s){const t=Math.ceil(s/1e3),l=Math.floor(t/60),r=t%60;return l>0?`${l}m ${r}s`:`${r}s`}function J(s){return(s??[]).filter(t=>t.installed&&t.profiles>0)}function de(s){return!Number.isFinite(s)||s<=0?"empty":Y(s)}function he(s,t){return s.map(l=>({key:l.key,name:l.name,running:l.running,visits:t.filter(r=>r.browser===l.key).reduce((r,h)=>r+h.programVisits,0)}))}function ue(s,t){if(s===null)return null;const l=Math.max(0,Math.round((t-s)/1e3));if(l<5)return"just now";if(l<60)return`${l} sec ago`;const r=Math.round(l/60);return r<60?`${r} min ago`:`${Math.round(r/60)} hr ago`}function we(s){const t=s.profiles.filter(r=>r.degraded);if(t.length>0){const r=t[0],h=t.length-1;return{kind:"unreadable",text:`${r.name}/${r.profile} could not be read — ${r.reason??"no reason given"}`+(h>0?`, and ${h} more`:"")+". The watch continues on the profiles it can read."}}const l=J(s.browsers);return l.length===0?{kind:"no-profiles",text:"No browser on this machine has a profile to read. Open one of the browsers below once and it will be watched from then on."}:l.some(r=>r.running)?null:{kind:"none-running",text:"No watched browser is running, so nothing can be navigated right now. Their history is still read, and anything found while they were open is still here."}}function me({snap:s,watching:t,palette:l}){const[r,h]=c.useState(!1),[o,a]=c.useState(()=>Date.now());c.useEffect(()=>{const u=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(u)},[]);const n=le(s.coverage.lastHumanMs,s.coverage.quietMs,o);return e.jsxs("section",{className:"bw-sec",children:[e.jsxs("h4",{className:"bw-sec-head",children:["Activity overview",e.jsx("button",{className:"bw-help",onClick:()=>h(u=>!u),"aria-expanded":r,"aria-label":"What the sweep and the dots mean",children:"?"})]}),e.jsxs("div",{className:"bw-glance",children:[e.jsx(oe,{browsers:t.map(u=>{var d;return{key:u.key,name:u.name,running:u.running,lastReadMs:((d=s.profiles.find(i=>i.browser===u.key))==null?void 0:d.lastWrittenMs)??null}}),findings:s.episodes.slice(0,6).map(u=>({browser:u.browser??null,atMs:u.endMs})),watching:s.settings.enabled,palette:l}),e.jsx("ul",{className:"bw-counts",children:he(t,s.profiles).map(u=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-count-n",children:u.visits.toLocaleString("en-US")}),e.jsx("span",{className:"bw-count-of",children:u.name})]},u.key))})]}),e.jsx("p",{className:"bw-since",children:"Pages a program opened, since this deck started"}),s.coverage.checkedMs>0&&e.jsxs("p",{className:"bw-since",children:["Last checked ",ue(s.coverage.checkedMs,o),s.coverage.checks>0&&e.jsxs(e.Fragment,{children:[" · ",s.coverage.checks.toLocaleString("en-US")," ",s.coverage.checks===1?"check":"checks"]})]}),n!==null&&e.jsxs("p",{className:"bw-gate",children:["You are browsing — a program page would count in ",ce(n)]}),r&&e.jsxs("dl",{className:"bw-key",children:[e.jsx("dt",{children:"Sweep"}),e.jsx("dd",{children:"one poll of every watched profile"}),e.jsx("dt",{children:"Dot"}),e.jsx("dd",{children:"a browser, further out the longer since it last wrote history"}),e.jsx("dt",{children:"Ring"}),e.jsx("dd",{children:"a finding, leaving the browser it came from"})]})]})}function be({watching:s,rest:t}){const[l,r]=c.useState(!1),[h,o]=c.useState(!1);return e.jsxs("section",{className:"bw-sec",children:[e.jsxs("h4",{className:"bw-sec-head",children:["Watched profiles",e.jsx("button",{className:"bw-help",onClick:()=>r(a=>!a),"aria-expanded":l,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),l&&e.jsxs("dl",{className:"bw-key",children:[e.jsx("dt",{children:"Running"}),e.jsx("dd",{children:"the browser has a process on this machine right now"}),e.jsx("dt",{children:"Connected"}),e.jsx("dd",{children:"an open connection to an address Anthropic's relay uses — which it shares with claude.ai, so an open tab looks the same as an agent channel"})]}),e.jsx("ul",{className:"bw-profiles",children:s.map(a=>e.jsxs("li",{children:[e.jsx("span",{className:`bw-prof-dot${a.running?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-prof-name",children:a.name}),e.jsx("span",{className:"bw-prof-state",children:a.running?"running":"idle"}),a.running&&a.relay.state==="live"&&e.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},a.key))}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>o(a=>!a),"aria-expanded":h,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:h?"▾":"▸"})," ",t.length," not watched"]}),h&&e.jsxs("p",{className:"bw-rest",children:[t.map(a=>a.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]})}function fe({snap:s,quiet:t,setQuiet:l,save:r,access:h,setAccess:o}){return e.jsxs("div",{className:"bw-settings",children:[e.jsxs("label",{title:"A program opening a page counts as a finding only if nobody had touched the browser for this long. Shorter catches more and reports more of your own work; longer is quieter.",children:[e.jsx("span",{children:"Nobody browsing for"}),e.jsxs("select",{value:t??s.settings.quietMinutes,onChange:a=>{l(Number(a.target.value)),r({quietMinutes:Number(a.target.value)})},children:[e.jsx("option",{value:1,children:"1 min"}),e.jsx("option",{value:5,children:"5 min"}),e.jsx("option",{value:15,children:"15 min"}),e.jsx("option",{value:30,children:"30 min"}),e.jsx("option",{value:60,children:"60 min"})]})]}),e.jsxs("label",{children:[e.jsx("span",{children:"When it finds one"}),e.jsx("select",{value:s.settings.reaction,onChange:a=>void r({reaction:a.target.value}),disabled:!s.settings.enabled,title:s.settings.enabled?"What to do besides writing it down.":"Turn watching on to arm a reaction.",children:(s.reactions??["notify"]).map(a=>e.jsx("option",{value:a,children:a==="notify"?"notify me":a==="close-tab"?"close the tab":"quit the browser"},a))})]}),e.jsxs("div",{className:"bw-settings-note",children:[e.jsxs("p",{children:["Chrome marks a navigation that came from an extension or a command rather than from a click. These are the ones that happened while nobody had touched the browser for the time above. ",e.jsx("strong",{children:"Usually that is your own agent doing what you asked."})]}),e.jsxs("button",{className:"bw-why",onClick:()=>o(a=>!a),"aria-expanded":h,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:h?"▾":"▸"})," What Browser Watch can access"]}),h&&e.jsxs("dl",{className:"bw-access",children:[e.jsx("dt",{children:"Reads"}),e.jsxs("dd",{children:["A copy of each browser's own history database — the live file is locked while the browser holds it. Only rows newer than the moment this deck started:"," ",new Date(s.coverage.startedMs).toLocaleString(),"."]}),e.jsx("dt",{children:"Keeps"}),e.jsxs("dd",{children:["Only while the switch is on, and only the episodes it flagged — never your ordinary browsing. In ",e.jsx("code",{className:"bw-path",children:s.coverage.logPath}),typeof s.coverage.logBytes=="number"?` (${de(s.coverage.logBytes)})`:"",", with every address written in full so you can check it yourself."]}),e.jsx("dt",{children:"Sends"}),e.jsx("dd",{children:"Nothing. No part of this reads or writes over the network; the deck serves on 127.0.0.1 and this panel talks only to it."}),e.jsx("dt",{children:"Never reads"}),e.jsx("dd",{children:"Anything from before this deck started, cookies, saved passwords, page contents, or any browser profile with no history file."})]})]})]})}function H(s,t){return t?{kind:"saving",word:"Saving"}:s.settings.enabled?{kind:"on",word:"Watching"}:{kind:"off",word:"Paused"}}function ge({snap:s,saving:t,save:l,why:r,setWhy:h}){return e.jsxs("footer",{className:"bw-status",children:[e.jsx("span",{className:`bw-mode-dot${s.settings.enabled?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-mode-word",children:H(s,t).word},H(s,t).kind),e.jsx("span",{className:"bw-status-text",children:s.coverage.archived===0?s.settings.enabled?"No episodes recorded yet":"No episodes on disk":`${s.coverage.archived} ${s.coverage.archived===1?"episode":"episodes"} on disk`}),e.jsx("button",{className:`glyph-btn bw-gear${r?" on":""}`,onClick:()=>h(o=>!o),"aria-expanded":r,"aria-label":"Settings",title:"Settings",children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[e.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),e.jsx("path",{d:"M7 1.2v1.6M7 11.2v1.6M1.2 7h1.6M11.2 7h1.6M2.9 2.9l1.1 1.1M10 10l1.1 1.1M11.1 2.9L10 4M4 10l-1.1 1.1"})]})}),e.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[e.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:"Watch browser activity"}),e.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":s.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"switch",onClick:()=>void l({enabled:!s.settings.enabled}),title:s.settings.enabled?"On — every episode it finds is written down, so the list outlives the browsing history being cleared":"Off — showing only what this deck has seen since it started. Anything an earlier run archived is hidden until you switch back on, and nothing new is kept",children:e.jsx("span",{className:"switch-knob"})})]})]})}function pe({relay:s}){const[t,l]=c.useState(!1),[r,h]=c.useState(!1),o=s.killswitch.blocked?"unblock":"block",a=s.command[o],n=c.useCallback(async()=>{await z(a.command)&&(h(!0),window.setTimeout(()=>h(!1),1600))},[a.command]),u=s.profiles.filter(i=>{var w;return(w=i.report)==null?void 0:w.present}),d=s.profiles.filter(i=>i.report===null);return e.jsxs("section",{className:"bw-sec",children:[e.jsx("h4",{className:"bw-sec-head",children:"Remote control"}),e.jsx("p",{className:`bw-rc-verdict ${s.verdict}`,role:"status",children:s.verdict==="exposed"?"Claude in Chrome is live here, so any Claude Code session signed in to your Anthropic account can drive this browser — from any machine, with no prompt on this one.":s.verdict==="protected"?`The relay is black-holed in ${s.hostsPath}, so no new connection to it can be made from this machine.`:"Claude in Chrome is not installed and enabled in any profile here, so there is nothing for the relay to drive."}),s.killswitch.foreign.length>0&&e.jsxs("p",{className:"bw-rc-foreign",children:["Another entry for this host is already in ",s.hostsPath,", and ccdeck will not touch it:",s.killswitch.foreign.map(i=>e.jsx("code",{className:"bw-path",children:i},i))]}),e.jsxs("button",{className:"bw-why",onClick:()=>l(i=>!i),"aria-expanded":t,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:t?"▾":"▸"})," ",s.verdict==="protected"?"How to undo the block":"What it can reach, and how to stop it"]}),t&&e.jsxs("div",{className:"bw-rc-body",children:[u.length>0&&e.jsx("dl",{className:"bw-key",children:u.map(i=>e.jsxs(c.Fragment,{children:[e.jsxs("dt",{children:[i.name,i.profile==="Default"?"":` · ${i.profile}`]}),e.jsxs("dd",{children:[i.report.enabled?"enabled":"installed but switched off",i.report.allUrls?", can act on every site":", limited to the sites it was granted",i.report.sensitiveApis.length>0&&e.jsxs(e.Fragment,{children:[" — ",i.report.sensitiveApis.join(", ")]})]})]},`${i.browser}/${i.profile}`))}),d.length>0&&e.jsxs("p",{className:"bw-rc-note",children:[d.map(i=>i.name).join(", ")," — its settings file could not be read, so nothing is claimed about it either way."]}),!s.hostsRead&&e.jsxs("p",{className:"bw-rc-note",children:[s.hostsPath," could not be read, so whether the relay is already blocked is unknown."]}),u.some(i=>i.report.allUrls)&&e.jsxs("p",{className:"bw-rc-note",children:["Narrowing the sites in ",e.jsx("code",{className:"bw-path",children:"chrome://extensions"})," does not change this: the grant is held at the browser level and the per-site list is enforced inside the extension, by the extension."]}),e.jsxs("div",{className:"bw-rc-cmd",children:[e.jsx("code",{children:a.command}),e.jsx("button",{className:"btn bw-rc-copy",onClick:n,children:r?"Copied":"Copy"})]}),e.jsx("p",{className:"bw-rc-note",children:a.note})]})]})}function xe(s){const[t,l]=c.useState(null),[r,h]=c.useState(null),[o,a]=c.useState(null),[n,u]=c.useState(!1),d=c.useRef(!1),[i,w]=c.useState(null),[m,b]=c.useState(!1),y=c.useRef(!1),p=c.useCallback(async f=>{var j,C;if(!(f&&!X(d.current))){f&&(d.current=!0,u(!0));try{const N=await fetch(`/api/browser-watch${f?"?refresh=1":""}`);if(!N.ok)throw new Error(`the deck answered ${N.status}`);const v=await N.json();l(v),y.current||w(((j=v==null?void 0:v.settings)==null?void 0:j.quietMinutes)??15),s(((C=v==null?void 0:v.settings)==null?void 0:C.enabled)===!0),h(null)}catch(N){h(N instanceof Error?N.message:String(N))}finally{f&&(d.current=!1,u(!1))}}},[s]);c.useEffect(()=>{p(!1)},[p]),c.useEffect(()=>{const f=setInterval(()=>{p(!1)},1e4);return()=>clearInterval(f)},[p]);const P=c.useCallback(async f=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:f.host,startMs:f.startMs})})}finally{await p(!1)}},[p]),R=c.useCallback(async f=>{y.current=!0,b(!0);try{const j=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(f)});if(!j.ok)throw new Error(`the deck answered ${j.status}`);await p(!1),a(null)}catch(j){a(j instanceof Error?j.message:String(j))}finally{y.current=!1,b(!1)}},[p]);return{snap:t,error:r,writeError:o,setWriteError:a,busy:n,quiet:i,setQuiet:w,saving:m,load:p,dismiss:P,save:R}}function ye({onClose:s,onSeen:t,onWatching:l,palette:r}){const h=Z(s),{snap:o,error:a,writeError:n,setWriteError:u,busy:d,quiet:i,setQuiet:w,saving:m,load:b,dismiss:y,save:p}=xe(l),[P,R]=c.useState(!1),[f,j]=c.useState(!1),C=c.useRef(null),N=c.useRef(t);N.current=t,c.useEffect(()=>()=>N.current(Date.now()),[]);const v=J(o==null?void 0:o.browsers),I=((o==null?void 0:o.browsers)??[]).filter(k=>!(k.installed&&k.profiles>0)),$=o?we(o):null,W=v.reduce((k,x)=>k+x.profiles,0);return e.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:e.jsxs("div",{ref:h,className:"modal bw-modal",onClick:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bw-title",children:[e.jsxs("header",{className:"modal-head",children:[e.jsxs("div",{className:"modal-title",children:[e.jsx("span",{className:"modal-tool-name",id:"bw-title",children:"Browser watch"}),e.jsx("span",{className:"modal-tool-id",children:o?`${W} ${W===1?"profile":"profiles"} · local only`:"local only"})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{ref:C,className:"glyph-btn",onClick:()=>void b(!0),...ee(d),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:d?"…":"↻"}),e.jsx("button",{className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),e.jsxs("div",{className:"modal-body bw-body",children:[!o&&!a&&e.jsxs("div",{className:"bw-loading",children:[e.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),e.jsx("p",{children:"Reading each browser's history. The first look copies the file, which takes a moment."})]}),a&&e.jsx("div",{className:"bw-state",children:e.jsxs("div",{className:"bw-row err",children:[e.jsx("span",{className:"bw-dot","aria-hidden":!0}),e.jsx("span",{className:"bw-row-label",children:"Could not read"}),e.jsx("span",{className:"bw-row-detail",children:a})]})}),o&&$&&e.jsx("p",{className:`bw-trouble ${$.kind}`,role:"status",children:$.text}),o&&e.jsxs("div",{className:"bw-work",children:[e.jsxs("aside",{className:"bw-side",children:[e.jsx(me,{snap:o,watching:v,palette:r}),e.jsx(be,{watching:v,rest:I}),o.relay&&e.jsx(pe,{relay:o.relay})]}),e.jsxs("div",{className:"bw-main",children:[e.jsx(ae,{snap:o,dismiss:y,refreshRef:C}),e.jsx(se,{snap:o})]})]}),o&&P&&e.jsx(fe,{snap:o,quiet:i,setQuiet:w,save:p,access:f,setAccess:j}),n&&e.jsx("div",{className:"bw-state bw-write-err",role:"alert",children:e.jsxs("div",{className:"bw-row err",children:[e.jsx("span",{className:"bw-dot","aria-hidden":!0}),e.jsx("span",{className:"bw-row-label",children:"Could not save that setting"}),e.jsxs("span",{className:"bw-row-detail",children:[n," — the switches below show what is stored, not what you pressed."]}),e.jsx("button",{className:"glyph-btn bw-write-err-x",onClick:()=>u(null),"aria-label":"Dismiss",title:"Dismiss",children:"×"})]})}),o&&e.jsx(ge,{snap:o,saving:m,save:p,why:P,setWhy:R})]})]})})}export{ye as default};
1
+ import{j as e,r as c,k as _,l as V,m as Y,n as z,s as X,u as Z,g as ee}from"./index-D7ddxIpC.js";function se({snap:s}){return e.jsxs("section",{className:"bw-feed",children:[e.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Live activity",e.jsxs("span",{className:"bw-feed-count",children:[s.log.length," ",s.log.length===1?"event":"events"]})]}),e.jsx("p",{className:"bw-since bw-feed-note",children:"Pages you opened yourself — counted to run the rule, never written down. Addresses appear under Findings, and only for pages a program opened."}),e.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:s.log.length===0?e.jsx("p",{className:"bw-note",children:"The deck writes a line here each time it looks at a profile."}):s.log.map(t=>e.jsxs("div",{className:`bw-log-line ${t.level}${t.parts?"":" sys"}`,children:[e.jsx("span",{className:"bw-log-time",children:new Date(t.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),t.parts?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bw-log-browser",children:t.parts.browser}),e.jsx("span",{className:"bw-log-profile",title:t.parts.profile,children:t.parts.profile}),e.jsxs("span",{className:"bw-log-value",children:[t.parts.value,t.parts.flagged>0&&e.jsxs("span",{className:"bw-log-flag",children:[" · ",t.parts.flagged," flagged"]})]})]}):e.jsx("span",{className:"bw-log-sys",children:t.text})]},`${t.atMs}-${t.level}-${t.text}`))})]})}const E=s=>`${s.host}-${s.startMs}`;function te(s){const t=l=>new Date(l).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1});return s.count===1||s.endMs-s.startMs<6e4?t(s.startMs):`${t(s.startMs)} → ${t(s.endMs)}`}function ne(s){return new Date(s).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function U(s){const t=Math.round((s.endMs-s.startMs)/6e4);return t<1?"":`${t} min`}function ae({snap:s,dismiss:t,refreshRef:l}){const[r,h]=c.useState(null),o=c.useRef(new Map),a=c.useRef(null);c.useEffect(()=>{var i,w;const d=a.current;!d||s.episodes.some(m=>E(m)===d.id)||(a.current=null,_(((i=document.activeElement)==null?void 0:i.tagName)??null)&&((w=(d.next?o.current.get(d.next):void 0)??l.current)==null||w.focus()))},[s]);const n=d=>{a.current={id:E(d),next:V(s.episodes.map(E),E(d))},t(d)},u=c.useMemo(()=>{const d=[];for(const i of s.episodes){const w=ne(i.startMs),m=d[d.length-1];m&&m.label===w?m.episodes.push(i):d.push({label:w,episodes:[i]})}return d},[s]);return e.jsxs("section",{className:"bw-findings",children:[e.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Findings",s.episodes.length>0&&e.jsxs("span",{className:"bw-feed-count",children:[s.episodes.length," ",s.episodes.length===1?"episode":"episodes"]})]}),e.jsx("div",{className:"bw-eps",children:u.length===0?e.jsxs("div",{className:"bw-empty",children:[e.jsx("p",{className:"bw-empty-head",children:"Nothing found yet"}),e.jsxs("p",{className:"bw-empty-note",children:["An episode lands here when a program opens pages in a browser nobody has touched for"," ",s.settings.quietMinutes," ",s.settings.quietMinutes===1?"minute":"minutes",". On most machines that is rare, so an empty list is the ordinary result rather than a sign something is wrong."]}),!s.settings.enabled&&e.jsx("p",{className:"bw-empty-note",children:"Watching is off, so this shows only what this deck has seen since it started. Anything an earlier run recorded comes back when you switch it on."})]}):u.map(d=>e.jsxs("div",{className:"bw-day",children:[e.jsx("h4",{className:"bw-sec-head",children:d.label}),d.episodes.map(i=>{const w=E(i),m=r===w;return e.jsxs("div",{className:`bw-ep${m?" open":""}`,children:[e.jsxs("div",{className:"bw-ep-row",children:[e.jsxs("button",{className:"bw-ep-head",ref:b=>{b?o.current.set(w,b):o.current.delete(w)},onClick:()=>h(m?null:w),"aria-expanded":m,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:m?"▾":"▸"}),e.jsx("span",{className:"bw-ep-host",children:i.host}),e.jsxs("span",{className:"bw-ep-meta",children:[te(i),U(i)&&e.jsxs(e.Fragment,{children:[" · ",U(i)]}),i.provisional&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{title:"Its quiet window has not closed yet. If somebody used the browser in the minutes after it, it is withdrawn; until then it is not written down and no reaction runs.",children:"provisional"})]})]}),e.jsxs("span",{className:"bw-ep-count",children:[i.count," ",i.count===1?"page":"pages"]})]}),e.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>n(i),"aria-label":`Dismiss ${i.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),m&&e.jsx("ul",{className:"bw-urls",children:i.urls.map((b,y)=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-url-time",children:new Date(b.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),e.jsx("span",{className:"bw-url",children:b.url})]},`${b.url}-${b.timeMs}-${y}`))})]},w)})]},d.label))})]})}function re(s){const t=/^#?([0-9a-f]{6})$/i.exec((s??"").trim());if(!t)return!1;const l=parseInt(t[1],16),r=[l>>16&255,l>>8&255,l&255].map(h=>{const o=h/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)});return .2126*r[0]+.7152*r[1]+.0722*r[2]>.5}const G=1e4,ie=12e3;function oe({browsers:s,findings:t,watching:l,palette:r}){const h=c.useRef(null),o=c.useRef(null);return o.current={browsers:s,findings:t,watching:l},c.useEffect(()=>{var m;const a=h.current;if(!a)return;const n=a.getContext("2d");if(!n)return;const u=((m=window.matchMedia)==null?void 0:m.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let d=0,i=!1;const w=()=>{var q;if(i)return;const b=o.current;if(!b)return;const{browsers:y,findings:p,watching:P}=b,R=r["--accent"]||"#7dd3fc",f=r["--line"]||"#1f2229",j=r["--text-dim"]||"#6e727c",C=re(r["--bg"]),N=C?42:26,v=C?.85:.65,I=Date.now(),$=Math.min(window.devicePixelRatio||1,2),W=a.clientWidth,k=a.clientHeight;(a.width!==W*$||a.height!==k*$)&&(a.width=W*$,a.height=k*$),n.setTransform($,0,0,$,0,0),n.clearRect(0,0,W,k);const x=W/2,M=k/2,S=Math.min(W,k)/2-6;n.strokeStyle=f,n.lineWidth=1,n.globalAlpha=C?1:.9;for(const g of[.4,.7,1])n.beginPath(),n.arc(x,M,S*g,0,Math.PI*2),n.stroke();n.beginPath(),n.moveTo(x-S,M),n.lineTo(x+S,M),n.moveTo(x,M-S),n.lineTo(x,M+S),n.stroke(),n.globalAlpha=1;const A=(P&&!u?I%G/G:0)*Math.PI*2-Math.PI/2;if(P){const g=(q=n.createConicGradient)==null?void 0:q.call(n,A-.85,x,M);g&&(g.addColorStop(0,"transparent"),g.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${R} ${N}%, transparent)`),g.addColorStop(1,"transparent"),n.fillStyle=g,n.beginPath(),n.moveTo(x,M),n.arc(x,M,S,A-.85,A),n.closePath(),n.fill()),n.strokeStyle=R,n.globalAlpha=v,n.beginPath(),n.moveTo(x,M),n.lineTo(x+Math.cos(A)*S,M+Math.sin(A)*S),n.stroke(),n.globalAlpha=1}y.forEach((g,T)=>{const B=T/Math.max(y.length,1)*Math.PI*2-Math.PI/2,D=g.lastReadMs===null?1:Math.min(1,(I-g.lastReadMs)/12e4),O=S*(.42+D*.5),F=x+Math.cos(B)*O,L=M+Math.sin(B)*O,Q=Math.abs((A-B+Math.PI*3)%(Math.PI*2)-Math.PI),K=P?Math.max(0,1-Q/.55):0;n.beginPath(),n.arc(F,L,3+K*1.6,0,Math.PI*2),n.fillStyle=g.running?R:j,n.globalAlpha=g.running?.55+K*.45:.35,n.fill(),n.globalAlpha=1});for(const g of p){const T=(I-g.atMs)/ie;if(T<0||T>1)continue;const D=Math.max(0,y.findIndex(L=>L.key===g.browser))/Math.max(y.length,1)*Math.PI*2-Math.PI/2,O=x+Math.cos(D)*S*.6,F=M+Math.sin(D)*S*.6;n.beginPath(),n.arc(O,F,4+T*22,0,Math.PI*2),n.strokeStyle=R,n.globalAlpha=(1-T)*.8,n.lineWidth=1.5,n.stroke(),n.globalAlpha=1}d=requestAnimationFrame(w)};return w(),()=>{i=!0,cancelAnimationFrame(d)}},[r]),e.jsx("canvas",{ref:h,className:"bw-radar",role:"img","aria-label":l?`Watching ${s.length} browser${s.length===1?"":"s"}`:"Not watching"})}function le(s,t,l){if(s===null)return null;const r=s+t-l;return r>0?r:null}function ce(s){const t=Math.ceil(s/1e3),l=Math.floor(t/60),r=t%60;return l>0?`${l}m ${r}s`:`${r}s`}function J(s){return(s??[]).filter(t=>t.installed&&t.profiles>0)}function de(s){return!Number.isFinite(s)||s<=0?"empty":Y(s)}function he(s,t){return s.map(l=>({key:l.key,name:l.name,running:l.running,visits:t.filter(r=>r.browser===l.key).reduce((r,h)=>r+h.programVisits,0)}))}function ue(s,t){if(s===null)return null;const l=Math.max(0,Math.round((t-s)/1e3));if(l<5)return"just now";if(l<60)return`${l} sec ago`;const r=Math.round(l/60);return r<60?`${r} min ago`:`${Math.round(r/60)} hr ago`}function we(s){const t=s.profiles.filter(r=>r.degraded);if(t.length>0){const r=t[0],h=t.length-1;return{kind:"unreadable",text:`${r.name}/${r.profile} could not be read — ${r.reason??"no reason given"}`+(h>0?`, and ${h} more`:"")+". The watch continues on the profiles it can read."}}const l=J(s.browsers);return l.length===0?{kind:"no-profiles",text:"No browser on this machine has a profile to read. Open one of the browsers below once and it will be watched from then on."}:l.some(r=>r.running)?null:{kind:"none-running",text:"No watched browser is running, so nothing can be navigated right now. Their history is still read, and anything found while they were open is still here."}}function me({snap:s,watching:t,palette:l}){const[r,h]=c.useState(!1),[o,a]=c.useState(()=>Date.now());c.useEffect(()=>{const u=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(u)},[]);const n=le(s.coverage.lastHumanMs,s.coverage.quietMs,o);return e.jsxs("section",{className:"bw-sec",children:[e.jsxs("h4",{className:"bw-sec-head",children:["Activity overview",e.jsx("button",{className:"bw-help",onClick:()=>h(u=>!u),"aria-expanded":r,"aria-label":"What the sweep and the dots mean",children:"?"})]}),e.jsxs("div",{className:"bw-glance",children:[e.jsx(oe,{browsers:t.map(u=>{var d;return{key:u.key,name:u.name,running:u.running,lastReadMs:((d=s.profiles.find(i=>i.browser===u.key))==null?void 0:d.lastWrittenMs)??null}}),findings:s.episodes.slice(0,6).map(u=>({browser:u.browser??null,atMs:u.endMs})),watching:s.settings.enabled,palette:l}),e.jsx("ul",{className:"bw-counts",children:he(t,s.profiles).map(u=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-count-n",children:u.visits.toLocaleString("en-US")}),e.jsx("span",{className:"bw-count-of",children:u.name})]},u.key))})]}),e.jsx("p",{className:"bw-since",children:"Pages a program opened, since this deck started"}),s.coverage.checkedMs>0&&e.jsxs("p",{className:"bw-since",children:["Last checked ",ue(s.coverage.checkedMs,o),s.coverage.checks>0&&e.jsxs(e.Fragment,{children:[" · ",s.coverage.checks.toLocaleString("en-US")," ",s.coverage.checks===1?"check":"checks"]})]}),n!==null&&e.jsxs("p",{className:"bw-gate",children:["You are browsing — a program page would count in ",ce(n)]}),r&&e.jsxs("dl",{className:"bw-key",children:[e.jsx("dt",{children:"Sweep"}),e.jsx("dd",{children:"one poll of every watched profile"}),e.jsx("dt",{children:"Dot"}),e.jsx("dd",{children:"a browser, further out the longer since it last wrote history"}),e.jsx("dt",{children:"Ring"}),e.jsx("dd",{children:"a finding, leaving the browser it came from"})]})]})}function be({watching:s,rest:t}){const[l,r]=c.useState(!1),[h,o]=c.useState(!1);return e.jsxs("section",{className:"bw-sec",children:[e.jsxs("h4",{className:"bw-sec-head",children:["Watched profiles",e.jsx("button",{className:"bw-help",onClick:()=>r(a=>!a),"aria-expanded":l,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),l&&e.jsxs("dl",{className:"bw-key",children:[e.jsx("dt",{children:"Running"}),e.jsx("dd",{children:"the browser has a process on this machine right now"}),e.jsx("dt",{children:"Connected"}),e.jsx("dd",{children:"an open connection to an address Anthropic's relay uses — which it shares with claude.ai, so an open tab looks the same as an agent channel"})]}),e.jsx("ul",{className:"bw-profiles",children:s.map(a=>e.jsxs("li",{children:[e.jsx("span",{className:`bw-prof-dot${a.running?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-prof-name",children:a.name}),e.jsx("span",{className:"bw-prof-state",children:a.running?"running":"idle"}),a.running&&a.relay.state==="live"&&e.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},a.key))}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>o(a=>!a),"aria-expanded":h,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:h?"▾":"▸"})," ",t.length," not watched"]}),h&&e.jsxs("p",{className:"bw-rest",children:[t.map(a=>a.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]})}function fe({snap:s,quiet:t,setQuiet:l,save:r,access:h,setAccess:o}){return e.jsxs("div",{className:"bw-settings",children:[e.jsxs("label",{title:"A program opening a page counts as a finding only if nobody had touched the browser for this long. Shorter catches more and reports more of your own work; longer is quieter.",children:[e.jsx("span",{children:"Nobody browsing for"}),e.jsxs("select",{value:t??s.settings.quietMinutes,onChange:a=>{l(Number(a.target.value)),r({quietMinutes:Number(a.target.value)})},children:[e.jsx("option",{value:1,children:"1 min"}),e.jsx("option",{value:5,children:"5 min"}),e.jsx("option",{value:15,children:"15 min"}),e.jsx("option",{value:30,children:"30 min"}),e.jsx("option",{value:60,children:"60 min"})]})]}),e.jsxs("label",{children:[e.jsx("span",{children:"When it finds one"}),e.jsx("select",{value:s.settings.reaction,onChange:a=>void r({reaction:a.target.value}),disabled:!s.settings.enabled,title:s.settings.enabled?"What to do besides writing it down.":"Turn watching on to arm a reaction.",children:(s.reactions??["notify"]).map(a=>e.jsx("option",{value:a,children:a==="notify"?"notify me":a==="close-tab"?"close the tab":"quit the browser"},a))})]}),e.jsxs("div",{className:"bw-settings-note",children:[e.jsxs("p",{children:["Chrome marks a navigation that came from an extension or a command rather than from a click. These are the ones that happened while nobody had touched the browser for the time above. ",e.jsx("strong",{children:"Usually that is your own agent doing what you asked."})]}),e.jsxs("button",{className:"bw-why",onClick:()=>o(a=>!a),"aria-expanded":h,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:h?"▾":"▸"})," What Browser Watch can access"]}),h&&e.jsxs("dl",{className:"bw-access",children:[e.jsx("dt",{children:"Reads"}),e.jsxs("dd",{children:["A copy of each browser's own history database — the live file is locked while the browser holds it. Only rows newer than the moment this deck started:"," ",new Date(s.coverage.startedMs).toLocaleString(),"."]}),e.jsx("dt",{children:"Keeps"}),e.jsxs("dd",{children:["Only while the switch is on, and only the episodes it flagged — never your ordinary browsing. In ",e.jsx("code",{className:"bw-path",children:s.coverage.logPath}),typeof s.coverage.logBytes=="number"?` (${de(s.coverage.logBytes)})`:"",", with every address written in full so you can check it yourself."]}),e.jsx("dt",{children:"Sends"}),e.jsx("dd",{children:"Nothing. No part of this reads or writes over the network; the deck serves on 127.0.0.1 and this panel talks only to it."}),e.jsx("dt",{children:"Never reads"}),e.jsx("dd",{children:"Anything from before this deck started, cookies, saved passwords, page contents, or any browser profile with no history file."})]})]})]})}function H(s,t){return t?{kind:"saving",word:"Saving"}:s.settings.enabled?{kind:"on",word:"Watching"}:{kind:"off",word:"Paused"}}function ge({snap:s,saving:t,save:l,why:r,setWhy:h}){return e.jsxs("footer",{className:"bw-status",children:[e.jsx("span",{className:`bw-mode-dot${s.settings.enabled?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-mode-word",children:H(s,t).word},H(s,t).kind),e.jsx("span",{className:"bw-status-text",children:s.coverage.archived===0?s.settings.enabled?"No episodes recorded yet":"No episodes on disk":`${s.coverage.archived} ${s.coverage.archived===1?"episode":"episodes"} on disk`}),e.jsx("button",{className:`glyph-btn bw-gear${r?" on":""}`,onClick:()=>h(o=>!o),"aria-expanded":r,"aria-label":"Settings",title:"Settings",children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[e.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),e.jsx("path",{d:"M7 1.2v1.6M7 11.2v1.6M1.2 7h1.6M11.2 7h1.6M2.9 2.9l1.1 1.1M10 10l1.1 1.1M11.1 2.9L10 4M4 10l-1.1 1.1"})]})}),e.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[e.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:"Watch browser activity"}),e.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":s.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"switch",onClick:()=>void l({enabled:!s.settings.enabled}),title:s.settings.enabled?"On — every episode it finds is written down, so the list outlives the browsing history being cleared":"Off — showing only what this deck has seen since it started. Anything an earlier run archived is hidden until you switch back on, and nothing new is kept",children:e.jsx("span",{className:"switch-knob"})})]})]})}function pe({relay:s}){const[t,l]=c.useState(!1),[r,h]=c.useState(!1),o=s.killswitch.blocked?"unblock":"block",a=s.command[o],n=c.useCallback(async()=>{await z(a.command)&&(h(!0),window.setTimeout(()=>h(!1),1600))},[a.command]),u=s.profiles.filter(i=>{var w;return(w=i.report)==null?void 0:w.present}),d=s.profiles.filter(i=>i.report===null);return e.jsxs("section",{className:"bw-sec",children:[e.jsx("h4",{className:"bw-sec-head",children:"Remote control"}),e.jsx("p",{className:`bw-rc-verdict ${s.verdict}`,role:"status",children:s.verdict==="exposed"?"Claude in Chrome is live here, so any Claude Code session signed in to your Anthropic account can drive this browser — from any machine, with no prompt on this one.":s.verdict==="protected"?`The relay is black-holed in ${s.hostsPath}, so no new connection to it can be made from this machine.`:"Claude in Chrome is not installed and enabled in any profile here, so there is nothing for the relay to drive."}),s.killswitch.foreign.length>0&&e.jsxs("p",{className:"bw-rc-foreign",children:["Another entry for this host is already in ",s.hostsPath,", and ccdeck will not touch it:",s.killswitch.foreign.map(i=>e.jsx("code",{className:"bw-path",children:i},i))]}),e.jsxs("button",{className:"bw-why",onClick:()=>l(i=>!i),"aria-expanded":t,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:t?"▾":"▸"})," ",s.verdict==="protected"?"How to undo the block":"What it can reach, and how to stop it"]}),t&&e.jsxs("div",{className:"bw-rc-body",children:[u.length>0&&e.jsx("dl",{className:"bw-key",children:u.map(i=>e.jsxs(c.Fragment,{children:[e.jsxs("dt",{children:[i.name,i.profile==="Default"?"":` · ${i.profile}`]}),e.jsxs("dd",{children:[i.report.enabled?"enabled":"installed but switched off",i.report.allUrls?", can act on every site":", limited to the sites it was granted",i.report.sensitiveApis.length>0&&e.jsxs(e.Fragment,{children:[" — ",i.report.sensitiveApis.join(", ")]})]})]},`${i.browser}/${i.profile}`))}),d.length>0&&e.jsxs("p",{className:"bw-rc-note",children:[d.map(i=>i.name).join(", ")," — its settings file could not be read, so nothing is claimed about it either way."]}),!s.hostsRead&&e.jsxs("p",{className:"bw-rc-note",children:[s.hostsPath," could not be read, so whether the relay is already blocked is unknown."]}),u.some(i=>i.report.allUrls)&&e.jsxs("p",{className:"bw-rc-note",children:["Narrowing the sites in ",e.jsx("code",{className:"bw-path",children:"chrome://extensions"})," does not change this: the grant is held at the browser level and the per-site list is enforced inside the extension, by the extension."]}),e.jsxs("div",{className:"bw-rc-cmd",children:[e.jsx("code",{children:a.command}),e.jsx("button",{className:"btn bw-rc-copy",onClick:n,children:r?"Copied":"Copy"})]}),e.jsx("p",{className:"bw-rc-note",children:a.note})]})]})}function xe(s){const[t,l]=c.useState(null),[r,h]=c.useState(null),[o,a]=c.useState(null),[n,u]=c.useState(!1),d=c.useRef(!1),[i,w]=c.useState(null),[m,b]=c.useState(!1),y=c.useRef(!1),p=c.useCallback(async f=>{var j,C;if(!(f&&!X(d.current))){f&&(d.current=!0,u(!0));try{const N=await fetch(`/api/browser-watch${f?"?refresh=1":""}`);if(!N.ok)throw new Error(`the deck answered ${N.status}`);const v=await N.json();l(v),y.current||w(((j=v==null?void 0:v.settings)==null?void 0:j.quietMinutes)??15),s(((C=v==null?void 0:v.settings)==null?void 0:C.enabled)===!0),h(null)}catch(N){h(N instanceof Error?N.message:String(N))}finally{f&&(d.current=!1,u(!1))}}},[s]);c.useEffect(()=>{p(!1)},[p]),c.useEffect(()=>{const f=setInterval(()=>{p(!1)},1e4);return()=>clearInterval(f)},[p]);const P=c.useCallback(async f=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:f.host,startMs:f.startMs})})}finally{await p(!1)}},[p]),R=c.useCallback(async f=>{y.current=!0,b(!0);try{const j=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(f)});if(!j.ok)throw new Error(`the deck answered ${j.status}`);await p(!1),a(null)}catch(j){a(j instanceof Error?j.message:String(j))}finally{y.current=!1,b(!1)}},[p]);return{snap:t,error:r,writeError:o,setWriteError:a,busy:n,quiet:i,setQuiet:w,saving:m,load:p,dismiss:P,save:R}}function ye({onClose:s,onSeen:t,onWatching:l,palette:r}){const h=Z(s),{snap:o,error:a,writeError:n,setWriteError:u,busy:d,quiet:i,setQuiet:w,saving:m,load:b,dismiss:y,save:p}=xe(l),[P,R]=c.useState(!1),[f,j]=c.useState(!1),C=c.useRef(null),N=c.useRef(t);N.current=t,c.useEffect(()=>()=>N.current(Date.now()),[]);const v=J(o==null?void 0:o.browsers),I=((o==null?void 0:o.browsers)??[]).filter(k=>!(k.installed&&k.profiles>0)),$=o?we(o):null,W=v.reduce((k,x)=>k+x.profiles,0);return e.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:e.jsxs("div",{ref:h,className:"modal bw-modal",onClick:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bw-title",children:[e.jsxs("header",{className:"modal-head",children:[e.jsxs("div",{className:"modal-title",children:[e.jsx("span",{className:"modal-tool-name",id:"bw-title",children:"Browser watch"}),e.jsx("span",{className:"modal-tool-id",children:o?`${W} ${W===1?"profile":"profiles"} · local only`:"local only"})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{ref:C,className:"glyph-btn",onClick:()=>void b(!0),...ee(d),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:d?"…":"↻"}),e.jsx("button",{className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),e.jsxs("div",{className:"modal-body bw-body",children:[!o&&!a&&e.jsxs("div",{className:"bw-loading",children:[e.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),e.jsx("p",{children:"Reading each browser's history. The first look copies the file, which takes a moment."})]}),a&&e.jsx("div",{className:"bw-state",children:e.jsxs("div",{className:"bw-row err",children:[e.jsx("span",{className:"bw-dot","aria-hidden":!0}),e.jsx("span",{className:"bw-row-label",children:"Could not read"}),e.jsx("span",{className:"bw-row-detail",children:a})]})}),o&&$&&e.jsx("p",{className:`bw-trouble ${$.kind}`,role:"status",children:$.text}),o&&e.jsxs("div",{className:"bw-work",children:[e.jsxs("aside",{className:"bw-side",children:[e.jsx(me,{snap:o,watching:v,palette:r}),e.jsx(be,{watching:v,rest:I}),o.relay&&e.jsx(pe,{relay:o.relay})]}),e.jsxs("div",{className:"bw-main",children:[e.jsx(ae,{snap:o,dismiss:y,refreshRef:C}),e.jsx(se,{snap:o})]})]}),o&&P&&e.jsx(fe,{snap:o,quiet:i,setQuiet:w,save:p,access:f,setAccess:j}),n&&e.jsx("div",{className:"bw-state bw-write-err",role:"alert",children:e.jsxs("div",{className:"bw-row err",children:[e.jsx("span",{className:"bw-dot","aria-hidden":!0}),e.jsx("span",{className:"bw-row-label",children:"Could not save that setting"}),e.jsxs("span",{className:"bw-row-detail",children:[n," — the switches below show what is stored, not what you pressed."]}),e.jsx("button",{className:"glyph-btn bw-write-err-x",onClick:()=>u(null),"aria-label":"Dismiss",title:"Dismiss",children:"×"})]})}),o&&e.jsx(ge,{snap:o,saving:m,save:p,why:P,setWhy:R})]})]})})}export{ye as default};
@@ -1 +1 @@
1
- import{a as U,f as p,r as c,s as Z,p as _,j as a,b as g,c as O,u as D,d as ee,e as se,g as E,h as ae,i as te}from"./index-OLDoLpOW.js";function ne(s){return!s.answer||s.answer.range!==s.want?{phase:"busy",stale:!1}:s.answer.ok?{phase:s.answer.days>0?"chart":"empty",stale:s.loading}:{phase:"error",stale:s.loading}}function I(s){const e=new Map;for(const n of s)for(const o of n.agents??[]){if(!o||typeof o.agent!="string"||o.agent==="")continue;const r=e.get(o.agent)??{id:o.agent,cost:0,tokens:0};r.cost+=Number.isFinite(o.totalCost)?o.totalCost:0,r.tokens+=Number.isFinite(o.totalTokens)?o.totalTokens:0,e.set(o.agent,r)}return[...e.values()].sort((n,o)=>o.cost-n.cost||n.id.localeCompare(o.id))}function oe(s){const e=I([{agents:s}]);return e.length<2?null:e.map(n=>`${U(n.id)} ${p(n.cost)}`).join(" · ")}function F(s){switch(s.toLowerCase()){case"claude":return"var(--model-opus)";case"codex":return"var(--model-codex)";case"gemini":return"var(--model-gemini)";case"copilot":return"var(--model-haiku)";default:return"var(--model-other)"}}function le(s,e){if(!(e>0)||!(s>0))return"0%";const n=s/e*100;return n<.1?"<0.1%":`${n.toFixed(1)}%`}const u=s=>typeof s=="number"&&Number.isFinite(s)?s:0,M=s=>typeof s=="string"?s:"",P=s=>Array.isArray(s)?s.filter(e=>typeof e=="string"):[];function re(s){const e=s??{};return{modelName:M(e.modelName),cost:u(e.cost),inputTokens:u(e.inputTokens),outputTokens:u(e.outputTokens),cacheCreationTokens:u(e.cacheCreationTokens),cacheReadTokens:u(e.cacheReadTokens)}}function ce(s){const e=s??{},n=Array.isArray(e.agents)?e.agents.map(o=>{const r=o??{};return{agent:M(r.agent),totalCost:u(r.totalCost),totalTokens:u(r.totalTokens)}}):void 0;return{period:M(e.period),totalCost:u(e.totalCost),totalTokens:u(e.totalTokens),inputTokens:u(e.inputTokens),outputTokens:u(e.outputTokens),cacheCreationTokens:u(e.cacheCreationTokens),cacheReadTokens:u(e.cacheReadTokens),modelsUsed:P(e.modelsUsed),modelBreakdowns:Array.isArray(e.modelBreakdowns)?e.modelBreakdowns.map(re):[],...n?{agents:n}:{},...e.metadata&&typeof e.metadata=="object"?{metadata:{agents:P(e.metadata.agents)}}:{}}}function ie(s){const e=s??{};return{...e,ok:e.ok===!0,days:Array.isArray(e.days)?e.days.map(ce):void 0}}function T(s){const e=s.toLowerCase();return e.includes("opus")?"var(--model-opus)":e.includes("sonnet")?"var(--model-sonnet)":e.includes("haiku")?"var(--model-haiku)":e.includes("gpt-5")||e.includes("gpt5")?"var(--model-gpt5)":e.includes("gpt")?"var(--model-gpt)":e.includes("gemini")?"var(--model-gemini)":e.includes("codex")?"var(--model-codex)":e.includes("fable")||e.includes("mythos")?"var(--model-fable)":"var(--model-other)"}function ue(s){let e=0,n=0,o=0,r=0;const m=new Map;for(const l of s){e+=l.totalCost,n+=l.totalTokens,o+=l.inputTokens+l.outputTokens,r+=l.cacheReadTokens;for(const d of l.modelBreakdowns)m.set(d.modelName,(m.get(d.modelName)??0)+d.cost)}return{totalCost:e,totalTok:n,inOut:o,cacheRead:r,modelCosts:m}}function de(s){return Array.from(s.entries()).sort((e,n)=>n[1]-e[1])}function q(s){return s.slice().sort((e,n)=>n.cost-e.cost)}function C(s,e){return e>0?s/e*100:0}function he(s){var n,o;return oe(s.agents)??((o=(n=s.metadata)==null?void 0:n.agents)!=null&&o.length?s.metadata.agents.join(" · "):null)}function me(){let s=0;return{begin(){const e=++s;return()=>e===s},cancel(){s++}}}function pe(s){const[e,n]=c.useState(null),[o,r]=c.useState(!1),m=c.useState(me)[0],l=c.useRef(!1),d=(f=!1)=>{if(f&&!Z(l.current))return;const x=m.begin();l.current=f;const k=s;r(!0);const i=`/api/ccusage?since=${_(k)}${f?"&refresh=1":""}`;fetch(i).then(j=>j.json()).then(j=>{x()&&n({range:k,resp:ie(j)})}).catch(()=>{x()&&n({range:k,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{x()&&(l.current=!1,r(!1))})};return c.useEffect(()=>(d(!1),()=>m.cancel()),[s]),{landed:e,loading:o,reload:()=>d(!0)}}function ge({selectedDay:s}){const e=he(s);return a.jsxs("div",{className:"uh-detail",children:[a.jsxs("div",{className:"uh-detail-head",children:[a.jsx("span",{className:"uh-detail-date",children:s.period}),a.jsx("span",{className:"uh-detail-cost",children:p(s.totalCost)}),e&&a.jsx("span",{className:"uh-detail-agents",title:e,children:e})]}),a.jsxs("div",{className:"uh-detail-mini",children:[a.jsx(y,{label:"input",val:g(s.inputTokens)}),a.jsx(y,{label:"output",val:g(s.outputTokens)}),a.jsx(y,{label:"cache write",val:g(s.cacheCreationTokens)}),a.jsx(y,{label:"cache read",val:g(s.cacheReadTokens)})]}),a.jsx("div",{className:"uh-detail-models",children:q(s.modelBreakdowns).map(n=>{const o=C(n.cost,s.totalCost);return a.jsxs("div",{className:"uh-model-row",title:n.modelName,children:[a.jsxs("span",{className:"uh-model-name",children:[a.jsx("span",{className:"uh-legend-dot",style:{background:T(n.modelName)}}),a.jsx("span",{className:"uh-model-label",children:O(n.modelName)})]}),a.jsx("span",{className:"uh-model-bar",children:a.jsx("span",{className:"uh-model-bar-fill",style:{width:`${o}%`,background:T(n.modelName)}})}),a.jsx("span",{className:"uh-model-cost",children:p(n.cost)})]},n.modelName)})})]})}function y({label:s,val:e}){return a.jsxs("div",{className:"uh-ministat",children:[a.jsx("span",{className:"uh-ministat-val",children:e}),a.jsx("span",{className:"uh-ministat-label",children:s})]})}const fe=[7,14,30,90];function je({onClose:s,providers:e}){var B;const[n,o]=c.useState(30),[r,m]=c.useState(null),{landed:l,loading:d,reload:f}=pe(n),x=c.useRef(null),k=D(s,{focusRef:x}),h=ne({loading:d,want:n,answer:l&&{range:l.range,ok:l.resp.ok===!0,days:((B=l.resp.days)==null?void 0:B.length)??0}}),i=h.phase==="chart"?l.resp.days??[]:[],j=c.useRef(null),G=ee(h.phase!=="error",j),H=c.useMemo(()=>i.reduce((t,N)=>Math.max(t,N.totalCost),0),[i]),S=c.useRef(null);c.useLayoutEffect(()=>{const t=S.current;t&&(t.scrollLeft=t.scrollWidth)},[i]);const{totalCost:w,totalTok:V,inOut:W,cacheRead:z,modelCosts:A}=c.useMemo(()=>ue(i),[i]),J=c.useMemo(()=>de(A),[A]),b=c.useMemo(()=>I(i),[i]),K=b.length>1,L=r?i.find(t=>t.period===r)??null:null;return a.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:a.jsxs("div",{ref:k,className:"modal uh-modal",onClick:t=>t.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[a.jsxs("header",{className:"uh-head",children:[a.jsxs("div",{className:"uh-titlewrap",children:[a.jsx("div",{className:"uh-title",children:"Usage history"}),a.jsx("div",{className:"uh-sub",children:h.stale?"running ccusage…":se(e,b.map(t=>t.id))})]}),a.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:fe.map(t=>a.jsxs("button",{type:"button","aria-pressed":n===t,className:"uh-range-btn",onClick:()=>{o(t),m(null)},children:[t,"d"]},t))}),a.jsx("button",{ref:j,className:"glyph-btn uh-reload",onClick:f,...E(d),title:"Re-run ccusage","aria-label":"Reload",children:d?"…":"↻"}),a.jsx("button",{ref:x,className:"glyph-btn uh-close",onClick:s,"aria-label":"Close",children:"×"})]}),h.phase==="busy"?a.jsxs("div",{className:"uh-status uh-status-wait","aria-busy":"true",children:[a.jsx("span",{className:"uh-wait-word",children:l?"running ccusage…":"running ccusage… (first run downloads the package)"}),a.jsx("span",{className:"uh-wait-axis","aria-hidden":!0})]}):h.phase==="error"?a.jsxs("div",{className:"uh-status uh-err",title:te(l.resp)||void 0,children:[ae(l.resp,"ccusage did not report usage"),a.jsx("div",{children:a.jsx("button",{className:"btn uh-retry",onClick:()=>{G(),f()},...E(d),children:d?"trying…":"Try again"})})]}):h.phase==="empty"?a.jsx("div",{className:`uh-status${h.stale?" uh-stale":""}`,"aria-busy":h.stale||void 0,children:"no usage in this range"}):a.jsxs("div",{className:h.stale?"uh-stale":void 0,"aria-busy":h.stale||void 0,children:[a.jsxs("div",{className:"uh-totals",children:[a.jsx(v,{label:"total cost",val:p(w),accent:!0}),a.jsx(v,{label:"tokens",val:g(V)}),a.jsx(v,{label:"input+output",val:g(W)}),a.jsx(v,{label:"cache reads",val:g(z)})]}),K&&a.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[a.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:b.map(t=>a.jsx("span",{className:"uh-agent-seg",style:{width:`${C(t.cost,w)}%`,background:F(t.id)}},t.id))}),a.jsx("div",{className:"uh-agent-keys",children:b.map(t=>a.jsxs("span",{className:"uh-agent-key",title:`${t.id} · ${g(t.tokens)} tokens`,children:[a.jsx("span",{className:"uh-legend-dot",style:{background:F(t.id)}}),U(t.id),a.jsx("span",{className:"uh-agent-cost",children:p(t.cost)}),a.jsx("span",{className:"uh-agent-share",children:le(t.cost,w)})]},t.id))})]}),a.jsx("div",{ref:S,className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:i.map((t,N)=>{const Q=C(t.totalCost,H),R=t.period===r,X=`${t.period}, ${p(t.totalCost)}`;return a.jsxs("button",{className:`uh-bar-col${R?" sel":""}`,onClick:()=>m(R?null:t.period),"aria-pressed":R,"aria-label":X,title:`${t.period} · ${p(t.totalCost)}`,style:{flexBasis:`${100/i.length}%`,"--uh-i":N,"--uh-step":`${Math.min(10,200/Math.max(i.length,1))}ms`},children:[a.jsx("div",{className:"uh-bar",style:{height:`${Math.max(Q,t.totalCost>0?2:0)}%`},children:q(t.modelBreakdowns).map($=>{const Y=C($.cost,t.totalCost);return a.jsx("div",{className:"uh-bar-seg",style:{height:`${Y}%`,background:T($.modelName)}},$.modelName)})}),a.jsx("span",{className:"uh-bar-label",children:t.period.slice(5)})]},t.period)})}),a.jsx("div",{className:"uh-legend",children:J.map(([t,N])=>a.jsxs("span",{className:"uh-legend-item",title:t,children:[a.jsx("span",{className:"uh-legend-dot",style:{background:T(t)}}),O(t)," ",a.jsx("span",{className:"uh-legend-cost",children:p(N)})]},t))}),L&&a.jsx(ge,{selectedDay:L})]})]})})}function v({label:s,val:e,accent:n}){return a.jsxs("div",{className:"uh-stat",children:[a.jsx("span",{className:`uh-stat-val${n?" accent":""}`,children:e}),a.jsx("span",{className:"uh-stat-label",children:s})]})}export{je as default};
1
+ import{a as U,f as p,r as c,s as Z,p as _,j as a,b as g,c as O,u as D,d as ee,e as se,g as E,h as ae,i as te}from"./index-D7ddxIpC.js";function ne(s){return!s.answer||s.answer.range!==s.want?{phase:"busy",stale:!1}:s.answer.ok?{phase:s.answer.days>0?"chart":"empty",stale:s.loading}:{phase:"error",stale:s.loading}}function I(s){const e=new Map;for(const n of s)for(const o of n.agents??[]){if(!o||typeof o.agent!="string"||o.agent==="")continue;const r=e.get(o.agent)??{id:o.agent,cost:0,tokens:0};r.cost+=Number.isFinite(o.totalCost)?o.totalCost:0,r.tokens+=Number.isFinite(o.totalTokens)?o.totalTokens:0,e.set(o.agent,r)}return[...e.values()].sort((n,o)=>o.cost-n.cost||n.id.localeCompare(o.id))}function oe(s){const e=I([{agents:s}]);return e.length<2?null:e.map(n=>`${U(n.id)} ${p(n.cost)}`).join(" · ")}function F(s){switch(s.toLowerCase()){case"claude":return"var(--model-opus)";case"codex":return"var(--model-codex)";case"gemini":return"var(--model-gemini)";case"copilot":return"var(--model-haiku)";default:return"var(--model-other)"}}function le(s,e){if(!(e>0)||!(s>0))return"0%";const n=s/e*100;return n<.1?"<0.1%":`${n.toFixed(1)}%`}const u=s=>typeof s=="number"&&Number.isFinite(s)?s:0,M=s=>typeof s=="string"?s:"",P=s=>Array.isArray(s)?s.filter(e=>typeof e=="string"):[];function re(s){const e=s??{};return{modelName:M(e.modelName),cost:u(e.cost),inputTokens:u(e.inputTokens),outputTokens:u(e.outputTokens),cacheCreationTokens:u(e.cacheCreationTokens),cacheReadTokens:u(e.cacheReadTokens)}}function ce(s){const e=s??{},n=Array.isArray(e.agents)?e.agents.map(o=>{const r=o??{};return{agent:M(r.agent),totalCost:u(r.totalCost),totalTokens:u(r.totalTokens)}}):void 0;return{period:M(e.period),totalCost:u(e.totalCost),totalTokens:u(e.totalTokens),inputTokens:u(e.inputTokens),outputTokens:u(e.outputTokens),cacheCreationTokens:u(e.cacheCreationTokens),cacheReadTokens:u(e.cacheReadTokens),modelsUsed:P(e.modelsUsed),modelBreakdowns:Array.isArray(e.modelBreakdowns)?e.modelBreakdowns.map(re):[],...n?{agents:n}:{},...e.metadata&&typeof e.metadata=="object"?{metadata:{agents:P(e.metadata.agents)}}:{}}}function ie(s){const e=s??{};return{...e,ok:e.ok===!0,days:Array.isArray(e.days)?e.days.map(ce):void 0}}function T(s){const e=s.toLowerCase();return e.includes("opus")?"var(--model-opus)":e.includes("sonnet")?"var(--model-sonnet)":e.includes("haiku")?"var(--model-haiku)":e.includes("gpt-5")||e.includes("gpt5")?"var(--model-gpt5)":e.includes("gpt")?"var(--model-gpt)":e.includes("gemini")?"var(--model-gemini)":e.includes("codex")?"var(--model-codex)":e.includes("fable")||e.includes("mythos")?"var(--model-fable)":"var(--model-other)"}function ue(s){let e=0,n=0,o=0,r=0;const m=new Map;for(const l of s){e+=l.totalCost,n+=l.totalTokens,o+=l.inputTokens+l.outputTokens,r+=l.cacheReadTokens;for(const d of l.modelBreakdowns)m.set(d.modelName,(m.get(d.modelName)??0)+d.cost)}return{totalCost:e,totalTok:n,inOut:o,cacheRead:r,modelCosts:m}}function de(s){return Array.from(s.entries()).sort((e,n)=>n[1]-e[1])}function q(s){return s.slice().sort((e,n)=>n.cost-e.cost)}function C(s,e){return e>0?s/e*100:0}function he(s){var n,o;return oe(s.agents)??((o=(n=s.metadata)==null?void 0:n.agents)!=null&&o.length?s.metadata.agents.join(" · "):null)}function me(){let s=0;return{begin(){const e=++s;return()=>e===s},cancel(){s++}}}function pe(s){const[e,n]=c.useState(null),[o,r]=c.useState(!1),m=c.useState(me)[0],l=c.useRef(!1),d=(f=!1)=>{if(f&&!Z(l.current))return;const x=m.begin();l.current=f;const k=s;r(!0);const i=`/api/ccusage?since=${_(k)}${f?"&refresh=1":""}`;fetch(i).then(j=>j.json()).then(j=>{x()&&n({range:k,resp:ie(j)})}).catch(()=>{x()&&n({range:k,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{x()&&(l.current=!1,r(!1))})};return c.useEffect(()=>(d(!1),()=>m.cancel()),[s]),{landed:e,loading:o,reload:()=>d(!0)}}function ge({selectedDay:s}){const e=he(s);return a.jsxs("div",{className:"uh-detail",children:[a.jsxs("div",{className:"uh-detail-head",children:[a.jsx("span",{className:"uh-detail-date",children:s.period}),a.jsx("span",{className:"uh-detail-cost",children:p(s.totalCost)}),e&&a.jsx("span",{className:"uh-detail-agents",title:e,children:e})]}),a.jsxs("div",{className:"uh-detail-mini",children:[a.jsx(y,{label:"input",val:g(s.inputTokens)}),a.jsx(y,{label:"output",val:g(s.outputTokens)}),a.jsx(y,{label:"cache write",val:g(s.cacheCreationTokens)}),a.jsx(y,{label:"cache read",val:g(s.cacheReadTokens)})]}),a.jsx("div",{className:"uh-detail-models",children:q(s.modelBreakdowns).map(n=>{const o=C(n.cost,s.totalCost);return a.jsxs("div",{className:"uh-model-row",title:n.modelName,children:[a.jsxs("span",{className:"uh-model-name",children:[a.jsx("span",{className:"uh-legend-dot",style:{background:T(n.modelName)}}),a.jsx("span",{className:"uh-model-label",children:O(n.modelName)})]}),a.jsx("span",{className:"uh-model-bar",children:a.jsx("span",{className:"uh-model-bar-fill",style:{width:`${o}%`,background:T(n.modelName)}})}),a.jsx("span",{className:"uh-model-cost",children:p(n.cost)})]},n.modelName)})})]})}function y({label:s,val:e}){return a.jsxs("div",{className:"uh-ministat",children:[a.jsx("span",{className:"uh-ministat-val",children:e}),a.jsx("span",{className:"uh-ministat-label",children:s})]})}const fe=[7,14,30,90];function je({onClose:s,providers:e}){var B;const[n,o]=c.useState(30),[r,m]=c.useState(null),{landed:l,loading:d,reload:f}=pe(n),x=c.useRef(null),k=D(s,{focusRef:x}),h=ne({loading:d,want:n,answer:l&&{range:l.range,ok:l.resp.ok===!0,days:((B=l.resp.days)==null?void 0:B.length)??0}}),i=h.phase==="chart"?l.resp.days??[]:[],j=c.useRef(null),G=ee(h.phase!=="error",j),H=c.useMemo(()=>i.reduce((t,N)=>Math.max(t,N.totalCost),0),[i]),S=c.useRef(null);c.useLayoutEffect(()=>{const t=S.current;t&&(t.scrollLeft=t.scrollWidth)},[i]);const{totalCost:w,totalTok:V,inOut:W,cacheRead:z,modelCosts:A}=c.useMemo(()=>ue(i),[i]),J=c.useMemo(()=>de(A),[A]),b=c.useMemo(()=>I(i),[i]),K=b.length>1,L=r?i.find(t=>t.period===r)??null:null;return a.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:a.jsxs("div",{ref:k,className:"modal uh-modal",onClick:t=>t.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[a.jsxs("header",{className:"uh-head",children:[a.jsxs("div",{className:"uh-titlewrap",children:[a.jsx("div",{className:"uh-title",children:"Usage history"}),a.jsx("div",{className:"uh-sub",children:h.stale?"running ccusage…":se(e,b.map(t=>t.id))})]}),a.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:fe.map(t=>a.jsxs("button",{type:"button","aria-pressed":n===t,className:"uh-range-btn",onClick:()=>{o(t),m(null)},children:[t,"d"]},t))}),a.jsx("button",{ref:j,className:"glyph-btn uh-reload",onClick:f,...E(d),title:"Re-run ccusage","aria-label":"Reload",children:d?"…":"↻"}),a.jsx("button",{ref:x,className:"glyph-btn uh-close",onClick:s,"aria-label":"Close",children:"×"})]}),h.phase==="busy"?a.jsxs("div",{className:"uh-status uh-status-wait","aria-busy":"true",children:[a.jsx("span",{className:"uh-wait-word",children:l?"running ccusage…":"running ccusage… (first run downloads the package)"}),a.jsx("span",{className:"uh-wait-axis","aria-hidden":!0})]}):h.phase==="error"?a.jsxs("div",{className:"uh-status uh-err",title:te(l.resp)||void 0,children:[ae(l.resp,"ccusage did not report usage"),a.jsx("div",{children:a.jsx("button",{className:"btn uh-retry",onClick:()=>{G(),f()},...E(d),children:d?"trying…":"Try again"})})]}):h.phase==="empty"?a.jsx("div",{className:`uh-status${h.stale?" uh-stale":""}`,"aria-busy":h.stale||void 0,children:"no usage in this range"}):a.jsxs("div",{className:h.stale?"uh-stale":void 0,"aria-busy":h.stale||void 0,children:[a.jsxs("div",{className:"uh-totals",children:[a.jsx(v,{label:"total cost",val:p(w),accent:!0}),a.jsx(v,{label:"tokens",val:g(V)}),a.jsx(v,{label:"input+output",val:g(W)}),a.jsx(v,{label:"cache reads",val:g(z)})]}),K&&a.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[a.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:b.map(t=>a.jsx("span",{className:"uh-agent-seg",style:{width:`${C(t.cost,w)}%`,background:F(t.id)}},t.id))}),a.jsx("div",{className:"uh-agent-keys",children:b.map(t=>a.jsxs("span",{className:"uh-agent-key",title:`${t.id} · ${g(t.tokens)} tokens`,children:[a.jsx("span",{className:"uh-legend-dot",style:{background:F(t.id)}}),U(t.id),a.jsx("span",{className:"uh-agent-cost",children:p(t.cost)}),a.jsx("span",{className:"uh-agent-share",children:le(t.cost,w)})]},t.id))})]}),a.jsx("div",{ref:S,className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:i.map((t,N)=>{const Q=C(t.totalCost,H),R=t.period===r,X=`${t.period}, ${p(t.totalCost)}`;return a.jsxs("button",{className:`uh-bar-col${R?" sel":""}`,onClick:()=>m(R?null:t.period),"aria-pressed":R,"aria-label":X,title:`${t.period} · ${p(t.totalCost)}`,style:{flexBasis:`${100/i.length}%`,"--uh-i":N,"--uh-step":`${Math.min(10,200/Math.max(i.length,1))}ms`},children:[a.jsx("div",{className:"uh-bar",style:{height:`${Math.max(Q,t.totalCost>0?2:0)}%`},children:q(t.modelBreakdowns).map($=>{const Y=C($.cost,t.totalCost);return a.jsx("div",{className:"uh-bar-seg",style:{height:`${Y}%`,background:T($.modelName)}},$.modelName)})}),a.jsx("span",{className:"uh-bar-label",children:t.period.slice(5)})]},t.period)})}),a.jsx("div",{className:"uh-legend",children:J.map(([t,N])=>a.jsxs("span",{className:"uh-legend-item",title:t,children:[a.jsx("span",{className:"uh-legend-dot",style:{background:T(t)}}),O(t)," ",a.jsx("span",{className:"uh-legend-cost",children:p(N)})]},t))}),L&&a.jsx(ge,{selectedDay:L})]})]})})}function v({label:s,val:e,accent:n}){return a.jsxs("div",{className:"uh-stat",children:[a.jsx("span",{className:`uh-stat-val${n?" accent":""}`,children:e}),a.jsx("span",{className:"uh-stat-label",children:s})]})}export{je as default};
@@ -93,7 +93,7 @@ ${e.map(s=>` ${s.label}: ${Jo(s.waiting)} (${ed(r-s.waiting.since)})`).join(`
93
93
  `)}`,"aria-label":`${e.length} session${e.length===1?"":"s"} waiting for you`,children:[a.jsx("span",{className:"ap-pulse","aria-hidden":!0}),a.jsx("b",{children:e.length})," ",a.jsx("span",{className:"ws-word",children:"waiting"})]})}const Fx={on:"The deck will raise a system notification when a session blocks on you and this tab is in the background",blocked:"Notifications are blocked for this page. Only your browser can undo that — its site settings for this address"};function Jee(e){return e==="on"?`Notifications on. ${Fx.on}.`:e==="blocked"?`${Fx.blocked}.`:""}function Qee({notifySaid:e}){return a.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:Fx[e],children:e==="on"?"notifications on":"notifications blocked"})}function ete({versionCheck:e,welcome:t,desktopUpdate:n,pause:r,monthly:s,announcements:i,notify:l,waitingSessions:u,waitingCursorRef:d,focusSession:f,live:h,now:p,incidents:g}){const{version:w,notice:k,noticeOpen:x,showNotice:b,versionChecking:j,loadVersion:S}=e,{chipVersion:_,openReleaseNotes:E}=t,{readyAppUpdate:T}=n,{paused:R,pauseGate:A}=r,{monthlyUsage:U,monthlyUsageUnavailable:I,monthUsageRef:q}=s,{blockedSaid:P,watchSaid:O,incidentSaid:V}=i,{notifySaid:$}=l;return a.jsxs("div",{className:"readout",children:[a.jsxs("div",{className:"brand",children:[a.jsx("span",{className:"logo"}),a.jsx("h1",{children:vt}),a.jsx(Yee,{readyAppUpdate:T,notice:k,noticeOpen:x,version:w,chipVersion:_,versionChecking:j,now:p,openReleaseNotes:E,showNotice:b,loadVersion:S})]}),a.jsx(Xee,{live:h,paused:R,pauseGate:A,monthUsageRef:q,monthlyUsage:U,monthlyUsageUnavailable:I}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:P}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:O}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:V}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Jee($)}),a.jsx(Ez,{incidents:g}),u.length>0&&a.jsx(Zee,{waitingSessions:u,waitingCursorRef:d,focusSession:f,now:p}),$&&a.jsx(Qee,{notifySaid:$})]})}function tte({selected:e,now:t,selectedIds:n,focusAgent:r,clearSelection:s}){const i=un(e),l=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),u=e.state==="active"?h0(i.total,l):null,d=n.size-1;return a.jsxs("button",{type:"button",className:"selected-ribbon",title:`Zoom to ${e.label} and its session (Z)${i.total>0?`
94
94
  ${Be(i.total)} spent${u?` · ${u}`:""}`:""}`,onClick:()=>{try{r(e.id)}catch{}},children:[a.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),a.jsx("span",{className:"selected-label",children:e.label}),i.total>0&&a.jsxs("span",{className:"selected-cost",children:[Be(i.total),u?a.jsxs("span",{className:"selected-rate",children:[" · ",u]}):null]}),d>0&&a.jsxs("span",{className:"selected-extra",children:["+",d]}),a.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:f=>{f.stopPropagation(),s()},children:"×"})]})}function nte({catBarRef:e,catBarOccluded:t,presentCats:n,hiddenCats:r,toggleCat:s}){return a.jsx("div",{ref:e,className:`cat-filter-bar${t?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:n.map(i=>{const l=r.has(i);return a.jsxs("button",{type:"button",className:`cat-filter${l?" off":""}`,onClick:()=>s(i),"aria-pressed":!l,title:`${l?"Show":"Hide"} ${md[i]} tools`,children:[a.jsx(ZQ,{cat:i}),a.jsx("span",{className:"cat-name",children:md[i]})]},i)})})}const rte=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function ste(e){var n,r;const t=e.target;!(t!=null&&t.closest)||t.closest(rte)!==e.currentTarget||(e.preventDefault(),(r=(n=document.activeElement)==null?void 0:n.blur)==null||r.call(n))}function ate({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:r}){return a.jsxs("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:[a.jsx("svg",{className:"drag-trash-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{d:"M8 7V5.8C8 4.8 8.8 4 9.8 4h4.4c1 0 1.8.8 1.8 1.8V7m-10 0h12M8 10v8m4-8v8m4-8v8M7 7l.7 13h8.6L17 7"})}),a.jsxs("span",{className:"drag-trash-copy",children:[a.jsx("span",{className:"drag-trash-text",children:t==="over"?a.jsxs(a.Fragment,{children:["Release to remove ",a.jsx("strong",{className:"drag-trash-name",children:r||"this card"})]}):"Drop here to remove from the board"}),a.jsx("span",{className:"drag-trash-hint",children:t==="over"?"The session list (L) brings it back":"The session keeps running"})]})]})}function ote({canvasRef:e,bubbling:t,dragging:n,trash:r,zoom:s,viewport:i,stateRef:l,peek:u,children:d}){const{trashDragging:f,trashState:h,trashPhase:p,trashZoneRef:g,trashLabel:w}=r,{lod:k,lodRef:x}=s,{markCanvasInput:b}=i,{peekAgent:j,peekLabel:S,peekRecap:_,peekBounds:E}=u;return a.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${f&&h==="over"?" trash-hover":""}`,"data-lod":k,ref:e,onMouseDownCapture:ste,onPointerDownCapture:b,onPointerUpCapture:b,onWheelCapture:b,onFocusCapture:T=>{const R=T.target;if(!sb(R)||x.current==null||x.current==="detail")return;const A=R.getAttribute("data-id");A&&l.current.agents.has(A)&&R.matches(":focus-visible")&&HI(A,R,"focus")},onBlurCapture:T=>{var A,U;const R=(U=(A=T.target).getAttribute)==null?void 0:U.call(A,"data-id");R&&Gs(R)},children:[d,Au(p)&&a.jsx(ate,{trashZoneRef:g,trashState:h,trashPhase:p,trashLabel:w}),a.jsx(MJ,{agentFor:j,recapFor:_,labelFor:S,bounds:E})]})}function ite({restarting:e,restartMode:t,live:n,paused:r}){return a.jsxs("div",{className:"conn-banner",role:"alert",children:[a.jsx("span",{className:"conn-dot"}),e?t==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${vt}…`:(()=>{const s=c8({connected:n,paused:r});return a.jsxs(a.Fragment,{children:[`Lost connection to the ${vt} server. Reconnecting…`,s&&a.jsx("span",{className:"conn-sub",children:s})]})})()]})}function lte({oldName:e,version:t,dismissOldName:n}){return a.jsxs("div",{className:"ver-banner",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:[e," still works — the deck is called ",vt," now."]}),t!=null&&t.renameFix?a.jsx("span",{className:"ver-sub",children:t.renameFix}):null,a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}const cte=3e4;function ute({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function dte({bundle:e,running:t,pending:n,lastTried:r}){return t?ute({bundle:e,running:t,lastTried:r})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function hte(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function fte({asked:e,reported:t}){return t?t!==e:!1}function aO(e){const t=e.thresholdMs??cte;return!e.enabled||e.kind!=="restart"||!e.canRestart||!e.noticeOpen||!e.visible||e.busy?null:e.idleSince==null||e.now<e.idleSince?t:Math.max(0,t-(e.now-e.idleSince))}function pte(e){const t=Math.max(0,Math.ceil(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function mte(e,t){return e?t==null?"auto when idle":`auto in ${pte(t)}`:"auto-restart off"}function OR(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function gte(e,t=!1){return e<=0&&t?{label:"Restart anyway",clause:"the canvas is paused — running agents cannot be seen"}:e<=0?{label:"Restart now",clause:"nothing is running"}:{label:"Restart anyway",clause:`${e===1?"1 agent is running":`${e} agents are running`} — their events during the restart are lost`}}function yte(e){const t=aO(e);return t==null?{idleSince:null,restart:!1,remainingMs:null}:e.idleSince==null||e.now<e.idleSince?{idleSince:e.now,restart:!1,remainingMs:t}:{idleSince:e.idleSince,restart:t===0,remainingMs:t}}const LR={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:",retired_name:"this install came from a name that is no longer published — run:"};function wte({notice:e,version:t,dismissNotice:n,upgradeState:r,startUpgrade:s,copyCommand:i,cmdCopied:l,autoRestart:u,toggleAutoRestart:d,askRestart:f,restartCopy:h,restartFuseMs:p,restarting:g}){var w,k,x;return a.jsxs("div",{className:`ver-banner ${e.kind}`,role:"status",children:[a.jsx("span",{className:`ver-dot${p==null?"":" armed"}`}),e.kind==="restart"?a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:["v",e.to," is installed — this deck still runs v",e.from,"."]}),t!=null&&t.canRestart?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"ver-act",onClick:()=>f(),...Jr(g),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
95
95
 
96
- Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.`,children:g?"restarting…":h.label}),!g&&a.jsx("span",{className:"ver-sub",children:h.clause}),a.jsxs("label",{className:"ver-auto",children:[a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":u,onClick:d,"aria-label":"Auto-restart when idle",title:u?"Updates on its own. While you are here it restarts once nothing has been running for 30 seconds; while you are away it also installs the new version first. Click to require a click instead.":"Only updates when you click. Click to let it update itself when idle or while you are away.",children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{"aria-hidden":!0,children:mte(u,p)})]})]}):a.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:[vt," v",e.to," is out — you are on v",e.from,"."]}),(t==null?void 0:t.upgradeMode)==="install"&&r!=="failed"&&a.jsx("button",{type:"button",className:"ver-act",onClick:s,...Jr(r==="running",r==="done"),title:`Runs ${((w=t==null?void 0:t.upgrade)==null?void 0:w.command)??(t==null?void 0:t.command)??"npm i -g"} here, then restarts once nothing is running.`,children:r==="running"?"installing…":r==="done"?"installed":"Update now"}),(t==null?void 0:t.upgradeMode)==="npx"&&(t==null?void 0:t.canRestart)&&a.jsx("button",{type:"button",className:"ver-act",onClick:()=>f({upgrade:!0}),...Jr(g),title:`Runs ${t==null?void 0:t.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:g?"fetching…":r==="failed"?"Retry update":"Update & restart"}),r==="failed"?a.jsxs("span",{className:"ver-sub fail",title:((k=t==null?void 0:t.upgrade)==null?void 0:k.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((x=t==null?void 0:t.upgrade)==null?void 0:x.error)??"unknown error"," — run it yourself:"]}):(t==null?void 0:t.upgradeMode)==="npx"?a.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?"npx cannot upgrade in place, so the deck re-runs:":LR.npx}):t!=null&&t.upgradeBlocked?a.jsx("span",{className:"ver-sub",children:It(LR,t.upgradeBlocked)??"cannot install from here"}):null,a.jsxs("button",{type:"button",className:"ver-cmd",onClick:i,title:"Copy to clipboard",children:[a.jsx("code",{children:t==null?void 0:t.command}),a.jsx("span",{className:"ver-cmd-hint",children:l?"copied":"copy"})]})]}),a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}function vte({restart:e,versionCheck:t,upgrade:n,oldNameNotice:r,everConnected:s,live:i,paused:l}){const{autoRestart:u,toggleAutoRestart:d,restarting:f,restartMode:h,restartedTo:p,askRestart:g,restartCopy:w,restartFuseMs:k}=e,{version:x,notice:b,noticeOpen:j,dismissNotice:S}=t,{upgradeState:_,startUpgrade:E,copyCommand:T,cmdCopied:R}=n,{oldName:A,oldNameOpen:U,dismissOldName:I}=r;return p?a.jsxs("div",{className:"ver-banner done",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:["Restarted — now running v",p,"."]}),a.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):s&&!i?a.jsx(ite,{restarting:f,restartMode:h,live:i,paused:l}):j&&b?a.jsx(wte,{notice:b,version:x,dismissNotice:S,upgradeState:_,startUpgrade:E,copyCommand:T,cmdCopied:R,autoRestart:u,toggleAutoRestart:d,askRestart:g,restartCopy:w,restartFuseMs:k,restarting:f}):U&&A?a.jsx(lte,{oldName:A,version:x,dismissOldName:I}):null}function xte(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function bte(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.decks!="number"||typeof t.mine!="boolean")return null;const n=t.owner&&typeof t.owner=="object"?t.owner.port:null;return{path:typeof t.path=="string"&&t.path!==""?t.path:null,decks:t.decks,mine:t.mine,ownerPort:typeof n=="number"?n:null}}function kte(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Nte(e,t){const n=kte(e),r=(...l)=>[n?`${n} on the canvas`:null,...l,"layout, pins and selection"].filter(u=>u!==null),s="This cannot be undone.";if(!t)return{goes:r("the event log on disk — the file a restarted deck replays to rebuild what you see, and the file every deck on this machine shares unless one was told otherwise"),stays:[],final:s,confirm:"Clear everything"};if(!t.path)return{goes:r(),stays:[],final:`This deck keeps no event log, so nothing on disk changes — and nothing can bring the canvas back. ${s}`,confirm:"Clear everything"};if(!t.mine){const l=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,u=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:r(),stays:[`the event log — ${l}${u}`,"restart this deck and the log replays back onto it"],final:null,confirm:"Clear this canvas"}}if(t.decks<=1)return{goes:r("this deck's event log — the file a restarted deck replays to rebuild what you see"),stays:[],final:s,confirm:"Clear everything"};const i=t.decks-1;return{goes:r(`the event log ${i===1?"1 other running deck shares":`${i} other running decks share`} with this one — every session recorded in it, not just the ones drawn here`),stays:[i===1?"what that deck shows, until it restarts — then it is gone there too":"what those decks show, until they restart — then it is gone there too"],final:s,confirm:"Clear everything"}}function jte({agentCount:e,onConfirm:t,onCancel:n}){const r=v.useRef(null),s=mt(n,{focusRef:r,layer:Fq}),[i,l]=v.useState(null);v.useEffect(()=>{let p=!1;return fetch("/api/clear").then(g=>g.ok?g.json():null).then(g=>{p||l(bte(g))}).catch(()=>{}),()=>{p=!0}},[]);const{goes:u,stays:d,final:f,confirm:h}=Nte(e,i);return a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal clear-confirm",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"status-dot err","aria-hidden":!0}),a.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("dl",{className:"cc-plan",children:[a.jsx("dt",{children:"Goes"}),a.jsx("dd",{children:u.map(p=>a.jsx("span",{children:p},p))}),a.jsx("dt",{children:"Stays"}),a.jsx("dd",{children:d.length>0?d.map(p=>a.jsx("span",{children:p},p)):a.jsx("span",{children:"nothing"})})]}),f&&a.jsx("p",{className:"cc-final",children:f}),a.jsxs("div",{className:"cc-actions",children:[a.jsx("button",{type:"button",ref:r,className:"btn",onClick:n,children:"Cancel"}),a.jsx("button",{type:"button",className:"btn danger",onClick:t,children:h})]})]})]})})}const Ste="Press Esc first if a key does nothing.",_te=[{title:"Canvas",rows:[{cap:"Space",action:"pause or resume the stream",binds:[" "]},{cap:"J",action:"next agent",binds:["j","J"]},{cap:"K",action:"previous agent",binds:["k","K"]},{cap:"W",action:"the session waiting on you — oldest first, again for the next",binds:["w","W"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"Z",action:"zoom to the selected agent and its session",binds:["z","Z"]},{cap:"Delete",action:"take the selected card off the board — Undo brings it back",binds:["Delete"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"D",action:"detail panel",binds:["d","D"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"S",action:"this machine — cores, memory, temperature",binds:["s","S"]},{cap:"B",action:"Browser Watch",binds:["b","B"]},{cap:"V",action:"the sound menu — volume, tones, notifications",binds:["v","V"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"a card: go to it and its session",binds:[]},{cap:"double-click",action:"a card: its prompt, every tool call, tokens and timing",binds:[]},{cap:"hover",action:"zoomed out, a card's name, state and numbers",binds:[]},{cap:"click",action:"the topbar speaker opens volume and sound settings",binds:[]}]}];function Ete({onClose:e,onTour:t}){const n=mt(e);return a.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal key-help",onClick:r=>r.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[t&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),a.jsx("div",{className:"shortcuts",children:_te.map(r=>a.jsxs(v.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:r.title}),r.rows.map(s=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:s.cap}),a.jsx("span",{children:s.action})]},`${r.title}:${s.cap}:${s.action}`))]},r.title))}),a.jsx("p",{className:"kh-foot",children:Ste})]})]})})}function Cte(e,t){const n=(e??[]).filter(s=>s&&typeof s.fp=="string"&&!t.has(s.fp));if(!n.length)return{request:null,waiting:0};const r=[...n].sort((s,i)=>(s.at??0)-(i.at??0));return{request:r[0],waiting:r.length-1}}function Tte({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:i,onLater:l}){const u=v.useRef(null),d=mt(l,{focusRef:u}),f=Vs(n,"accept"),h=Vs(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",onClick:l,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title","aria-describedby":"lan-ask-who",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0}),a.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:l,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{id:"lan-ask-who",className:"lan-ask-who",children:[a.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",a.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",$0(e.at,r)]}),a.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),a.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",a.jsx("code",{className:"ap-lan-code",children:e.fp})," — that machine shows its own under This deck on the network; the two should match."]}),t>0&&a.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),a.jsxs("div",{className:"lan-ask-acts",children:[a.jsx("button",{type:"button",ref:u,className:"btn",disabled:h.disabled,"aria-busy":h.busy,onClick:i,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),a.jsx("button",{type:"button",className:"btn primary",disabled:f.disabled,"aria-busy":f.busy,onClick:s,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function Rte({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:r,deferLanPair:s}){const{request:i,waiting:l}=Cte(e,t.current);return i?a.jsx(Tte,{request:i,waiting:l,busy:n,now:Date.now(),onAccept:()=>void r("accept",i.fp),onDecline:()=>void r("dismiss",i.fp),onLater:()=>s(i.fp)},i.fp):null}const Ate={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is a","note to the author and never a release."],"//nothing-to-say":["3.23.1","3.23.2","3.23.3","3.23.4","3.26.0","3.26.1","3.26.3","3.26.4","3.26.5","3.27.6","3.27.7","3.28.0","3.28.1","3.29.3","3.29.4","3.29.6","3.29.7","3.29.9"],"3.33.0":[{title:"🪝 Hooks you add in Claude Code are no longer removed",body:"Claude Code's hook editor often files a new hook into the same group as the deck's own. Starting the deck, or uninstalling it, then removed the whole group, and your hook went with it without a word. The deck now takes out only its own command and leaves yours where it was, and the same goes for the old finish-sound hook. `ccdeck --uninstall` also stops the decks that are running, so an update in the background cannot put the hooks back."},{title:"🧵 Resumed Codex sessions show up again",body:"A Codex session picked up with `codex resume`, or one that ran for days, could go dark on the canvas and drop out of the 5-hour and 7-day usage, because the deck only looked in the two newest day folders. It now follows those sessions and counts their tokens. Two Codex sessions in the same folder get different id suffixes, and a `bash -lc` call shows the command it runs."},{title:"🤝 A deck paired by the accept switch brings in less",body:'A deck that paired through the automatic accept switch, and not through an invite, now brings in only the logins you have ticked on this deck, and nothing from it is ticked for sharing onward. Its dialog says "paired automatically — pair by invite to take it". Pairing by invite works as before. A typed address is no longer dropped after one failed round, and the sync port stays the same after a rename.'},{title:"⬆️ Desktop updates install when you expect them",body:'On Windows and Linux a downloaded update now installs when you quit. On a Mac, Quit installs it and the app stays closed. The Linux .deb needs an administrator password to install, so it no longer does that by itself: it waits for "Restart to update" and says a password is coming. "Start at login" now works on Linux, and "Restart ccdeck" stops a deck that has hung.'},{title:"🕵️ Browser Watch waits before it acts, and quits only its own browser",body:"A program's visit is now logged and reacted to once its quiet window has closed, about 16 minutes after it, and not on the first poll, so a visit that is withdrawn no longer quits the browser. On Linux the quit reaction ends only the browser that holds the watched profile; other Chrome channels and headless browsers keep running. When it cannot tell which process that is, it does nothing and says so, which includes a Flatpak Brave."},{title:"🧮 Figures that were off are right",body:`Spend by labelled and workflow subagents counts toward a session's tokens and cost. The Projects report prices 1-hour cache writes the way ccusage does, so its dollars match the Usage panel. After a restart the deck rebuilds its whole event history, where it used to rebuild about a third. On Linux the process list shows what each process is using now, not its lifetime average. A count near a boundary reads "1.00M", and a full quota window says "used up".`},{title:"🔑 The Usage panel's reads answer the deck's own page only",body:"The routes behind the Usage panel (/api/quota, /api/ccusage, /api/codex-usage, /api/codex-quota and /api/cswap-auto) now answer the deck's own page, or a client that sends the deck's token. A script that read them with a plain request gets 401 from this version on. The hook, the desktop app and the `ccdeck` command are not affected."},{title:"🛠️ Smaller fixes you may notice",body:"With the canvas paused, an update no longer restarts the server while an agent is working: it waits until no turn is open. `ccdeck --stop -p4317` stops that one deck. A deck started at login can update itself on Homebrew and nvm setups. Dialogs keep keyboard focus after a button goes away, screen readers hear pairing requests by deck name and the machine panel's readings, dim text is readable in both themes, Windows High Contrast shows what is selected, and below 640px the detail panel opens over the canvas."}],"3.32.2":[{title:"🔒 Self-updates wait until your screen is unlocked",body:"On Linux with GNOME, the app installs an update by itself when you leave it alone, which is often while your screen is locked. GNOME switches the panel's tray off under the lock screen, and a version that started then never showed its icon. The app now waits until you are back before restarting by itself, so its icon comes back with it."}],"3.32.1":[{title:"🔔 The tray icon comes back on Linux",body:"On Linux the app could lose its icon in the panel, after it updated itself or when the panel restarted, and stay without it until it was quit. It now notices within a minute and restarts by itself the next time you are away from its window, the way it installs an update. It does this at most once every six hours, and not again if a restart did not help."},{title:"🔕 A window you closed stays closed after a self-update",body:"When the app restarted by itself to install an update, it opened its window again even if you had closed it, and while that window was open the deck held back its notifications. A window you closed now stays closed."},{title:"🪟 No empty icon when ccdeck is already open",body:'Opening ccdeck again while it was running flashed an empty "…" icon in the Linux panel before bringing the window forward. It now only brings the window forward.'}],"3.32.0":[{title:"🗺️ A map of your network",body:"A new button on the Local network row, and in its view's header, opens a map of every deck around this one. This deck is at the centre and the paired decks that are on stand around it. Further out are the quiet ones, the machines nearby and any deck asking to pair. Wires are solid on your local network and dashed over Tailscale. Pointing at a deck says how it is reached, what it runs and which logins the two share, and pressing it opens that deck's own dialog."}],"3.31.0":[{title:"📊 Account capacity",body:"A gauge button in the accounts panel's header opens Account capacity: how many of your Claude accounts are ready now, what the 5-hour and 7-day windows have left across all of them, and a row for each account with its use, its state (Ready, Limited, Exhausted or Stale) and when it was last read. Each window also says whose reset comes next."},{title:"🚦 Claude and Codex incidents",body:"When Anthropic's or OpenAI's status page reports an incident on something your sessions use, the deck says so in the topbar, the Usage panel and the tray, and every mark links to the status page. A provider with nothing wrong draws nothing."},{title:"↕️ Order your other accounts",body:"The Other accounts row can sort the list by slot, by how full a window is, or by most room, and open every account at once. Both stay as you left them after a reload."},{title:"🔐 A settings folder left by sudo can be given back",body:'On a Mac, running ccdeck once with sudo left its settings folder owned by another user, and every settings change was refused, sharing an account included. The message now offers "give it back": macOS asks for your password, the folder is yours again, and the deck reads its settings back without a restart.'}],"3.30.0":[{title:"🧮 Token counts and costs are no longer doubled",body:"Claude Code writes a reply that has thinking, text and tool calls as several transcript lines, each carrying the whole request's usage. The deck added up every line, so a session's tokens and cost on its card came out close to twice what it was billed, and the context panel counted each part of a reply as its own message. Each request is now counted once. Expect the totals on your cards to come down."},{title:"⏳ Claude's saved limit resets on the Usage panel",body:`When your Claude account has free limit resets to spend ("Reset for free" in Claude's Settings → Usage), the Claude card now says how many there are and when the first one expires, the way the Codex card already did. The deck only reports them; you spend them in Claude's own settings.`},{title:"🔑 LAN invites need the other deck updated",body:`An invite's code is now a long random secret instead of six digits, so nobody else on the network can work it out and pair in your place, and a wrong code is refused by name. An invite made on this version can only be joined from a deck on this version or later: an older deck answers "That is not an invite". Update that deck, or make the invite on the older one and join it here.`},{title:"🔕 AGENTS_DECK_NO_NOTIFY keeps Browser Watch quiet too",body:"A deck started with AGENTS_DECK_NO_NOTIFY=1 still raised a desktop notification for every new Browser Watch finding. It no longer does. The finding is still in the Browser Watch panel and its log, which says why no notification came."},{title:"🛠️ Smaller fixes",body:'Delete removes the card you just clicked. A LAN address you typed stays in the list when a round cannot reach it, and the status line under the LAN switch now agrees with the rows below it. In the desktop app, a dismissed "update is ready" notice stays dismissed after you answer the first-launch question. Sizes read the same in every panel ("1.1 KB"). Faded text stays readable, a keyboard can see the scrollbar, and numbers use a monospaced font on Windows and Linux as well.'}],"3.29.11":[{title:"💲 Claude Sonnet 5.5 has a price",body:`Sessions on Claude Sonnet 5.5 showed "not priced" on the board, and the Projects report could only show a minimum for them. They are now priced at Anthropic's published rate, the same as Sonnet 5: $2 per million input tokens and $10 per million output tokens.`}],"3.29.10":[{title:"💲 Claude Opus 5.5 has a price",body:`Sessions on Claude Opus 5.5 showed "not priced" on the board, and the Projects report counted them as costing nothing, so its totals read far too low. They are now priced at Anthropic's published rate. If a model still has no price, Projects shows its total as a minimum, like $11.19+, and names the model, instead of a total that looks complete.`}],"3.29.8":[{title:"🔁 Removed cards come back when their agent works again",body:"Remove from board is for finished work. If the agent behind a card you removed starts a tool call, gets a new prompt or starts a subagent, the card returns on its own, together with the card it hangs from, and it stays back after a reload. Cards whose agents stay idle stay removed."}],"3.29.1":[{title:"🗂️ One row per project in Projects",body:"The Projects report now counts a session's work under the folder you started it in, the same name its card has on the canvas, instead of adding a row for every folder the agent moved into. The first start after updating re-reads your transcripts once to regroup the report."},{title:"🔔 Tidier custom sounds",body:"Importing a sound, recording one and choosing a spoken voice now sit in compact cards that respond to clicks and focus like the rest of the deck."}],"3.29.0":[{title:"🎵 Your own stations in Claude FM",body:"Add any YouTube live link or radio stream as a station in Appearance, next to the built-in ones, and mute the music without losing your volume. When a station is not live, the picker now says so instead of staying silent."},{title:"🔔 Notification sounds and voices of your own",body:"Pick a local audio file or a spoken voice for each alert, so the sound that means an agent is waiting is one you will recognise."},{title:"🗑️ Drag a card off the board to remove it",body:"Drag a card to the target at the bottom of the canvas to take it off the board, or use Remove from board in the detail panel (Delete). The session keeps running, and the session list (L) brings it back."},{title:"🔐 Optional invite-only pairing",body:"Pairing works as before, with or without an invite. If you want, Local network can now be set to accept only decks that join with an invite you created, so a nearby machine cannot ask to pair on its own."},{title:"🌐 Account sharing between your machines is more reliable",body:"A locked macOS Keychain is explained instead of failing silently, a login that is broken or belongs to another account is never shared, and a sync that stops partway keeps what already arrived."},{title:"📅 Projects opens on Today",body:"The Projects report per account starts with today's work, and an empty window offers the next wider one. The topbar also shows this month's usage, and the desktop app can restart into an update from its own window."}],"3.27.0":[{title:"📊 Projects: where each account spent its work",body:"Each account card's ⋯ menu now breaks its cost down by project, over 7d / 30d / all."}],"3.27.1":[{title:"🎨 Make Appearance easier to tune",body:"The Appearance dialog now has clearer sections, stronger selection states, and a calmer layout for choosing a theme and configuring music. Your existing settings and keyboard shortcuts continue to work."}],"3.27.2":[{title:"💰 Project costs now match Usage",body:"Project cost totals no longer count the same Claude request once for every content block. Existing project history is rebuilt automatically so the totals align with the Usage panel."}],"3.27.3":[{title:"🎵 Station selection works in the desktop app",body:"The music station picker now opens inside ccdeck instead of relying on the operating system popup, so choosing a station works reliably in the Electron app."}],"3.27.4":[{title:"✅ Desktop picker release checks are green",body:"The station picker now keeps the same keyboard, motion, focus, and layout behavior as the rest of ccdeck across desktop and browser builds."}],"3.27.5":[{title:"🧭 The welcome tour stays dismissed",body:"Electron now remembers that you completed the onboarding tour at the deck level, so an update or loopback port change no longer shows the same tour again."},{title:"🎵 The station picker has a clearer finish",body:"The music selector has a tighter trigger, a purposeful chevron, and more deliberate option spacing so it reads like a native part of Appearance."}],"3.25.0":[{title:"🖱️ A click goes to the session, a double-click opens the details",body:"Clicking a card frames it with the rest of its session and leaves the detail panel shut. Double-click a card to open its details; `j`/`k`, the session list, Enter and `D` still open them too."},{title:"🔭 Cards stay readable when you zoom out",body:"At every zoom a card shows its name, its state and anything waiting on you, instead of shrinking to a coloured pill. Hover or focus a card to see it whole. Recap notes read at a distance too, and show the full recap on hover."},{title:"🌐 The Machine panel shows your network",body:"A new Network section shows download, upload and the round trip to Claude's API, and names the route when traffic goes through a VPN or a Tailscale exit node. Those checks run only while the panel is open. The panel is regrouped into CPU, Memory, Network and Thermal, with a flag at the top when something needs attention."},{title:"🎨 See each theme before you pick it",body:"The Appearance menu shows a small preview of the deck in Light and in Dark. Claude FM also keeps its volume when a notification chime plays, instead of dipping under it."}],"3.24.1":[{title:"🎛️ Appearance is one small menu now",body:"The topbar's appearance control opens a compact menu where you can choose Light or Dark and show or hide the character. The character stays on by default, and your choice is remembered."}],"3.24.0":[{title:"🎧 Claude FM plays from the minimap",body:"A small character stands on the minimap's top edge. Press it and the Claude channel's live stream plays; press it again and it stops. It only turns up when the channel is actually broadcasting, so a deck with no network never shows it at all."},{title:"🤠 And it gets on with its day",body:"It walks that edge, tidies up what it finds, kicks a ball along it, sits with its legs over the side, and watches the board through a scope. Now and then it drops onto the canvas and ropes its way back up. Headphones on while the music plays, a hat when it does not."}],"3.23.5":[{title:"🧭 The accounts panel opens on the account you are on",body:"Its windows, its resets and how old the numbers are — whole, at the top of the column. Every other account stands behind one row that says how many of them a switch could actually reach; press it to see them, or rest on it to be shown their names and how much room each has left."},{title:"⚙️ Auto-switch moved in there with them",body:"It is behind that same row now, after the accounts it switches between, rather than at the foot of the panel. The row says `auto 90%` or `auto off` so you can tell what the policy is doing without opening it — and says so in amber when it is armed with nowhere left to go."}],"3.23.0":[{title:"🧭 The accounts column leads with accounts",body:`The live account is the open row: its windows as bars, when each one resets, and how old the numbers are. Every other account rests on the two figures a switch is decided by, and opens with a click when you want the rest.
96
+ Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.`,children:g?"restarting…":h.label}),!g&&a.jsx("span",{className:"ver-sub",children:h.clause}),a.jsxs("label",{className:"ver-auto",children:[a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":u,onClick:d,"aria-label":"Auto-restart when idle",title:u?"Updates on its own. While you are here it restarts once nothing has been running for 30 seconds; while you are away it also installs the new version first. Click to require a click instead.":"Only updates when you click. Click to let it update itself when idle or while you are away.",children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{"aria-hidden":!0,children:mte(u,p)})]})]}):a.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:[vt," v",e.to," is out — you are on v",e.from,"."]}),(t==null?void 0:t.upgradeMode)==="install"&&r!=="failed"&&a.jsx("button",{type:"button",className:"ver-act",onClick:s,...Jr(r==="running",r==="done"),title:`Runs ${((w=t==null?void 0:t.upgrade)==null?void 0:w.command)??(t==null?void 0:t.command)??"npm i -g"} here, then restarts once nothing is running.`,children:r==="running"?"installing…":r==="done"?"installed":"Update now"}),(t==null?void 0:t.upgradeMode)==="npx"&&(t==null?void 0:t.canRestart)&&a.jsx("button",{type:"button",className:"ver-act",onClick:()=>f({upgrade:!0}),...Jr(g),title:`Runs ${t==null?void 0:t.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:g?"fetching…":r==="failed"?"Retry update":"Update & restart"}),r==="failed"?a.jsxs("span",{className:"ver-sub fail",title:((k=t==null?void 0:t.upgrade)==null?void 0:k.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((x=t==null?void 0:t.upgrade)==null?void 0:x.error)??"unknown error"," — run it yourself:"]}):(t==null?void 0:t.upgradeMode)==="npx"?a.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?"npx cannot upgrade in place, so the deck re-runs:":LR.npx}):t!=null&&t.upgradeBlocked?a.jsx("span",{className:"ver-sub",children:It(LR,t.upgradeBlocked)??"cannot install from here"}):null,a.jsxs("button",{type:"button",className:"ver-cmd",onClick:i,title:"Copy to clipboard",children:[a.jsx("code",{children:t==null?void 0:t.command}),a.jsx("span",{className:"ver-cmd-hint",children:l?"copied":"copy"})]})]}),a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}function vte({restart:e,versionCheck:t,upgrade:n,oldNameNotice:r,everConnected:s,live:i,paused:l}){const{autoRestart:u,toggleAutoRestart:d,restarting:f,restartMode:h,restartedTo:p,askRestart:g,restartCopy:w,restartFuseMs:k}=e,{version:x,notice:b,noticeOpen:j,dismissNotice:S}=t,{upgradeState:_,startUpgrade:E,copyCommand:T,cmdCopied:R}=n,{oldName:A,oldNameOpen:U,dismissOldName:I}=r;return p?a.jsxs("div",{className:"ver-banner done",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:["Restarted — now running v",p,"."]}),a.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):s&&!i?a.jsx(ite,{restarting:f,restartMode:h,live:i,paused:l}):j&&b?a.jsx(wte,{notice:b,version:x,dismissNotice:S,upgradeState:_,startUpgrade:E,copyCommand:T,cmdCopied:R,autoRestart:u,toggleAutoRestart:d,askRestart:g,restartCopy:w,restartFuseMs:k,restarting:f}):U&&A?a.jsx(lte,{oldName:A,version:x,dismissOldName:I}):null}function xte(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function bte(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.decks!="number"||typeof t.mine!="boolean")return null;const n=t.owner&&typeof t.owner=="object"?t.owner.port:null;return{path:typeof t.path=="string"&&t.path!==""?t.path:null,decks:t.decks,mine:t.mine,ownerPort:typeof n=="number"?n:null}}function kte(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Nte(e,t){const n=kte(e),r=(...l)=>[n?`${n} on the canvas`:null,...l,"layout, pins and selection"].filter(u=>u!==null),s="This cannot be undone.";if(!t)return{goes:r("the event log on disk — the file a restarted deck replays to rebuild what you see, and the file every deck on this machine shares unless one was told otherwise"),stays:[],final:s,confirm:"Clear everything"};if(!t.path)return{goes:r(),stays:[],final:`This deck keeps no event log, so nothing on disk changes — and nothing can bring the canvas back. ${s}`,confirm:"Clear everything"};if(!t.mine){const l=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,u=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:r(),stays:[`the event log — ${l}${u}`,"restart this deck and the log replays back onto it"],final:null,confirm:"Clear this canvas"}}if(t.decks<=1)return{goes:r("this deck's event log — the file a restarted deck replays to rebuild what you see"),stays:[],final:s,confirm:"Clear everything"};const i=t.decks-1;return{goes:r(`the event log ${i===1?"1 other running deck shares":`${i} other running decks share`} with this one — every session recorded in it, not just the ones drawn here`),stays:[i===1?"what that deck shows, until it restarts — then it is gone there too":"what those decks show, until they restart — then it is gone there too"],final:s,confirm:"Clear everything"}}function jte({agentCount:e,onConfirm:t,onCancel:n}){const r=v.useRef(null),s=mt(n,{focusRef:r,layer:Fq}),[i,l]=v.useState(null);v.useEffect(()=>{let p=!1;return fetch("/api/clear").then(g=>g.ok?g.json():null).then(g=>{p||l(bte(g))}).catch(()=>{}),()=>{p=!0}},[]);const{goes:u,stays:d,final:f,confirm:h}=Nte(e,i);return a.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal clear-confirm",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"status-dot err","aria-hidden":!0}),a.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("dl",{className:"cc-plan",children:[a.jsx("dt",{children:"Goes"}),a.jsx("dd",{children:u.map(p=>a.jsx("span",{children:p},p))}),a.jsx("dt",{children:"Stays"}),a.jsx("dd",{children:d.length>0?d.map(p=>a.jsx("span",{children:p},p)):a.jsx("span",{children:"nothing"})})]}),f&&a.jsx("p",{className:"cc-final",children:f}),a.jsxs("div",{className:"cc-actions",children:[a.jsx("button",{type:"button",ref:r,className:"btn",onClick:n,children:"Cancel"}),a.jsx("button",{type:"button",className:"btn danger",onClick:t,children:h})]})]})]})})}const Ste="Press Esc first if a key does nothing.",_te=[{title:"Canvas",rows:[{cap:"Space",action:"pause or resume the stream",binds:[" "]},{cap:"J",action:"next agent",binds:["j","J"]},{cap:"K",action:"previous agent",binds:["k","K"]},{cap:"W",action:"the session waiting on you — oldest first, again for the next",binds:["w","W"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"Z",action:"zoom to the selected agent and its session",binds:["z","Z"]},{cap:"Delete",action:"take the selected card off the board — Undo brings it back",binds:["Delete"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"D",action:"detail panel",binds:["d","D"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"S",action:"this machine — cores, memory, temperature",binds:["s","S"]},{cap:"B",action:"Browser Watch",binds:["b","B"]},{cap:"V",action:"the sound menu — volume, tones, notifications",binds:["v","V"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"a card: go to it and its session",binds:[]},{cap:"double-click",action:"a card: its prompt, every tool call, tokens and timing",binds:[]},{cap:"hover",action:"zoomed out, a card's name, state and numbers",binds:[]},{cap:"click",action:"the topbar speaker opens volume and sound settings",binds:[]}]}];function Ete({onClose:e,onTour:t}){const n=mt(e);return a.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal key-help",onClick:r=>r.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[t&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),a.jsx("div",{className:"shortcuts",children:_te.map(r=>a.jsxs(v.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:r.title}),r.rows.map(s=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:s.cap}),a.jsx("span",{children:s.action})]},`${r.title}:${s.cap}:${s.action}`))]},r.title))}),a.jsx("p",{className:"kh-foot",children:Ste})]})]})})}function Cte(e,t){const n=(e??[]).filter(s=>s&&typeof s.fp=="string"&&!t.has(s.fp));if(!n.length)return{request:null,waiting:0};const r=[...n].sort((s,i)=>(s.at??0)-(i.at??0));return{request:r[0],waiting:r.length-1}}function Tte({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:i,onLater:l}){const u=v.useRef(null),d=mt(l,{focusRef:u}),f=Vs(n,"accept"),h=Vs(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",onClick:l,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title","aria-describedby":"lan-ask-who",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0}),a.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:l,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{id:"lan-ask-who",className:"lan-ask-who",children:[a.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",a.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",$0(e.at,r)]}),a.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),a.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",a.jsx("code",{className:"ap-lan-code",children:e.fp})," — that machine shows its own under This deck on the network; the two should match."]}),t>0&&a.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),a.jsxs("div",{className:"lan-ask-acts",children:[a.jsx("button",{type:"button",ref:u,className:"btn",disabled:h.disabled,"aria-busy":h.busy,onClick:i,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),a.jsx("button",{type:"button",className:"btn primary",disabled:f.disabled,"aria-busy":f.busy,onClick:s,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function Rte({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:r,deferLanPair:s}){const{request:i,waiting:l}=Cte(e,t.current);return i?a.jsx(Tte,{request:i,waiting:l,busy:n,now:Date.now(),onAccept:()=>void r("accept",i.fp),onDecline:()=>void r("dismiss",i.fp),onLater:()=>s(i.fp)},i.fp):null}const Ate={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is a","note to the author and never a release."],"//nothing-to-say":["3.23.1","3.23.2","3.23.3","3.23.4","3.26.0","3.26.1","3.26.3","3.26.4","3.26.5","3.27.6","3.27.7","3.28.0","3.28.1","3.29.3","3.29.4","3.29.6","3.29.7","3.29.9","3.33.1"],"3.33.0":[{title:"🪝 Hooks you add in Claude Code are no longer removed",body:"Claude Code's hook editor often files a new hook into the same group as the deck's own. Starting the deck, or uninstalling it, then removed the whole group, and your hook went with it without a word. The deck now takes out only its own command and leaves yours where it was, and the same goes for the old finish-sound hook. `ccdeck --uninstall` also stops the decks that are running, so an update in the background cannot put the hooks back."},{title:"🧵 Resumed Codex sessions show up again",body:"A Codex session picked up with `codex resume`, or one that ran for days, could go dark on the canvas and drop out of the 5-hour and 7-day usage, because the deck only looked in the two newest day folders. It now follows those sessions and counts their tokens. Two Codex sessions in the same folder get different id suffixes, and a `bash -lc` call shows the command it runs."},{title:"🤝 A deck paired by the accept switch brings in less",body:'A deck that paired through the automatic accept switch, and not through an invite, now brings in only the logins you have ticked on this deck, and nothing from it is ticked for sharing onward. Its dialog says "paired automatically — pair by invite to take it". Pairing by invite works as before. A typed address is no longer dropped after one failed round, and the sync port stays the same after a rename.'},{title:"⬆️ Desktop updates install when you expect them",body:'On Windows and Linux a downloaded update now installs when you quit. On a Mac, Quit installs it and the app stays closed. The Linux .deb needs an administrator password to install, so it no longer does that by itself: it waits for "Restart to update" and says a password is coming. "Start at login" now works on Linux, and "Restart ccdeck" stops a deck that has hung.'},{title:"🕵️ Browser Watch waits before it acts, and quits only its own browser",body:"A program's visit is now logged and reacted to once its quiet window has closed, about 16 minutes after it, and not on the first poll, so a visit that is withdrawn no longer quits the browser. On Linux the quit reaction ends only the browser that holds the watched profile; other Chrome channels and headless browsers keep running. When it cannot tell which process that is, it does nothing and says so, which includes a Flatpak Brave."},{title:"🧮 Figures that were off are right",body:`Spend by labelled and workflow subagents counts toward a session's tokens and cost. The Projects report prices 1-hour cache writes the way ccusage does, so its dollars match the Usage panel. After a restart the deck rebuilds its whole event history, where it used to rebuild about a third. On Linux the process list shows what each process is using now, not its lifetime average. A count near a boundary reads "1.00M", and a full quota window says "used up".`},{title:"🔑 The Usage panel's reads answer the deck's own page only",body:"The routes behind the Usage panel (/api/quota, /api/ccusage, /api/codex-usage, /api/codex-quota and /api/cswap-auto) now answer the deck's own page, or a client that sends the deck's token. A script that read them with a plain request gets 401 from this version on. The hook, the desktop app and the `ccdeck` command are not affected."},{title:"🛠️ Smaller fixes you may notice",body:"With the canvas paused, an update no longer restarts the server while an agent is working: it waits until no turn is open. `ccdeck --stop -p4317` stops that one deck. A deck started at login can update itself on Homebrew and nvm setups. Dialogs keep keyboard focus after a button goes away, screen readers hear pairing requests by deck name and the machine panel's readings, dim text is readable in both themes, Windows High Contrast shows what is selected, and below 640px the detail panel opens over the canvas."}],"3.32.2":[{title:"🔒 Self-updates wait until your screen is unlocked",body:"On Linux with GNOME, the app installs an update by itself when you leave it alone, which is often while your screen is locked. GNOME switches the panel's tray off under the lock screen, and a version that started then never showed its icon. The app now waits until you are back before restarting by itself, so its icon comes back with it."}],"3.32.1":[{title:"🔔 The tray icon comes back on Linux",body:"On Linux the app could lose its icon in the panel, after it updated itself or when the panel restarted, and stay without it until it was quit. It now notices within a minute and restarts by itself the next time you are away from its window, the way it installs an update. It does this at most once every six hours, and not again if a restart did not help."},{title:"🔕 A window you closed stays closed after a self-update",body:"When the app restarted by itself to install an update, it opened its window again even if you had closed it, and while that window was open the deck held back its notifications. A window you closed now stays closed."},{title:"🪟 No empty icon when ccdeck is already open",body:'Opening ccdeck again while it was running flashed an empty "…" icon in the Linux panel before bringing the window forward. It now only brings the window forward.'}],"3.32.0":[{title:"🗺️ A map of your network",body:"A new button on the Local network row, and in its view's header, opens a map of every deck around this one. This deck is at the centre and the paired decks that are on stand around it. Further out are the quiet ones, the machines nearby and any deck asking to pair. Wires are solid on your local network and dashed over Tailscale. Pointing at a deck says how it is reached, what it runs and which logins the two share, and pressing it opens that deck's own dialog."}],"3.31.0":[{title:"📊 Account capacity",body:"A gauge button in the accounts panel's header opens Account capacity: how many of your Claude accounts are ready now, what the 5-hour and 7-day windows have left across all of them, and a row for each account with its use, its state (Ready, Limited, Exhausted or Stale) and when it was last read. Each window also says whose reset comes next."},{title:"🚦 Claude and Codex incidents",body:"When Anthropic's or OpenAI's status page reports an incident on something your sessions use, the deck says so in the topbar, the Usage panel and the tray, and every mark links to the status page. A provider with nothing wrong draws nothing."},{title:"↕️ Order your other accounts",body:"The Other accounts row can sort the list by slot, by how full a window is, or by most room, and open every account at once. Both stay as you left them after a reload."},{title:"🔐 A settings folder left by sudo can be given back",body:'On a Mac, running ccdeck once with sudo left its settings folder owned by another user, and every settings change was refused, sharing an account included. The message now offers "give it back": macOS asks for your password, the folder is yours again, and the deck reads its settings back without a restart.'}],"3.30.0":[{title:"🧮 Token counts and costs are no longer doubled",body:"Claude Code writes a reply that has thinking, text and tool calls as several transcript lines, each carrying the whole request's usage. The deck added up every line, so a session's tokens and cost on its card came out close to twice what it was billed, and the context panel counted each part of a reply as its own message. Each request is now counted once. Expect the totals on your cards to come down."},{title:"⏳ Claude's saved limit resets on the Usage panel",body:`When your Claude account has free limit resets to spend ("Reset for free" in Claude's Settings → Usage), the Claude card now says how many there are and when the first one expires, the way the Codex card already did. The deck only reports them; you spend them in Claude's own settings.`},{title:"🔑 LAN invites need the other deck updated",body:`An invite's code is now a long random secret instead of six digits, so nobody else on the network can work it out and pair in your place, and a wrong code is refused by name. An invite made on this version can only be joined from a deck on this version or later: an older deck answers "That is not an invite". Update that deck, or make the invite on the older one and join it here.`},{title:"🔕 AGENTS_DECK_NO_NOTIFY keeps Browser Watch quiet too",body:"A deck started with AGENTS_DECK_NO_NOTIFY=1 still raised a desktop notification for every new Browser Watch finding. It no longer does. The finding is still in the Browser Watch panel and its log, which says why no notification came."},{title:"🛠️ Smaller fixes",body:'Delete removes the card you just clicked. A LAN address you typed stays in the list when a round cannot reach it, and the status line under the LAN switch now agrees with the rows below it. In the desktop app, a dismissed "update is ready" notice stays dismissed after you answer the first-launch question. Sizes read the same in every panel ("1.1 KB"). Faded text stays readable, a keyboard can see the scrollbar, and numbers use a monospaced font on Windows and Linux as well.'}],"3.29.11":[{title:"💲 Claude Sonnet 5.5 has a price",body:`Sessions on Claude Sonnet 5.5 showed "not priced" on the board, and the Projects report could only show a minimum for them. They are now priced at Anthropic's published rate, the same as Sonnet 5: $2 per million input tokens and $10 per million output tokens.`}],"3.29.10":[{title:"💲 Claude Opus 5.5 has a price",body:`Sessions on Claude Opus 5.5 showed "not priced" on the board, and the Projects report counted them as costing nothing, so its totals read far too low. They are now priced at Anthropic's published rate. If a model still has no price, Projects shows its total as a minimum, like $11.19+, and names the model, instead of a total that looks complete.`}],"3.29.8":[{title:"🔁 Removed cards come back when their agent works again",body:"Remove from board is for finished work. If the agent behind a card you removed starts a tool call, gets a new prompt or starts a subagent, the card returns on its own, together with the card it hangs from, and it stays back after a reload. Cards whose agents stay idle stay removed."}],"3.29.1":[{title:"🗂️ One row per project in Projects",body:"The Projects report now counts a session's work under the folder you started it in, the same name its card has on the canvas, instead of adding a row for every folder the agent moved into. The first start after updating re-reads your transcripts once to regroup the report."},{title:"🔔 Tidier custom sounds",body:"Importing a sound, recording one and choosing a spoken voice now sit in compact cards that respond to clicks and focus like the rest of the deck."}],"3.29.0":[{title:"🎵 Your own stations in Claude FM",body:"Add any YouTube live link or radio stream as a station in Appearance, next to the built-in ones, and mute the music without losing your volume. When a station is not live, the picker now says so instead of staying silent."},{title:"🔔 Notification sounds and voices of your own",body:"Pick a local audio file or a spoken voice for each alert, so the sound that means an agent is waiting is one you will recognise."},{title:"🗑️ Drag a card off the board to remove it",body:"Drag a card to the target at the bottom of the canvas to take it off the board, or use Remove from board in the detail panel (Delete). The session keeps running, and the session list (L) brings it back."},{title:"🔐 Optional invite-only pairing",body:"Pairing works as before, with or without an invite. If you want, Local network can now be set to accept only decks that join with an invite you created, so a nearby machine cannot ask to pair on its own."},{title:"🌐 Account sharing between your machines is more reliable",body:"A locked macOS Keychain is explained instead of failing silently, a login that is broken or belongs to another account is never shared, and a sync that stops partway keeps what already arrived."},{title:"📅 Projects opens on Today",body:"The Projects report per account starts with today's work, and an empty window offers the next wider one. The topbar also shows this month's usage, and the desktop app can restart into an update from its own window."}],"3.27.0":[{title:"📊 Projects: where each account spent its work",body:"Each account card's ⋯ menu now breaks its cost down by project, over 7d / 30d / all."}],"3.27.1":[{title:"🎨 Make Appearance easier to tune",body:"The Appearance dialog now has clearer sections, stronger selection states, and a calmer layout for choosing a theme and configuring music. Your existing settings and keyboard shortcuts continue to work."}],"3.27.2":[{title:"💰 Project costs now match Usage",body:"Project cost totals no longer count the same Claude request once for every content block. Existing project history is rebuilt automatically so the totals align with the Usage panel."}],"3.27.3":[{title:"🎵 Station selection works in the desktop app",body:"The music station picker now opens inside ccdeck instead of relying on the operating system popup, so choosing a station works reliably in the Electron app."}],"3.27.4":[{title:"✅ Desktop picker release checks are green",body:"The station picker now keeps the same keyboard, motion, focus, and layout behavior as the rest of ccdeck across desktop and browser builds."}],"3.27.5":[{title:"🧭 The welcome tour stays dismissed",body:"Electron now remembers that you completed the onboarding tour at the deck level, so an update or loopback port change no longer shows the same tour again."},{title:"🎵 The station picker has a clearer finish",body:"The music selector has a tighter trigger, a purposeful chevron, and more deliberate option spacing so it reads like a native part of Appearance."}],"3.25.0":[{title:"🖱️ A click goes to the session, a double-click opens the details",body:"Clicking a card frames it with the rest of its session and leaves the detail panel shut. Double-click a card to open its details; `j`/`k`, the session list, Enter and `D` still open them too."},{title:"🔭 Cards stay readable when you zoom out",body:"At every zoom a card shows its name, its state and anything waiting on you, instead of shrinking to a coloured pill. Hover or focus a card to see it whole. Recap notes read at a distance too, and show the full recap on hover."},{title:"🌐 The Machine panel shows your network",body:"A new Network section shows download, upload and the round trip to Claude's API, and names the route when traffic goes through a VPN or a Tailscale exit node. Those checks run only while the panel is open. The panel is regrouped into CPU, Memory, Network and Thermal, with a flag at the top when something needs attention."},{title:"🎨 See each theme before you pick it",body:"The Appearance menu shows a small preview of the deck in Light and in Dark. Claude FM also keeps its volume when a notification chime plays, instead of dipping under it."}],"3.24.1":[{title:"🎛️ Appearance is one small menu now",body:"The topbar's appearance control opens a compact menu where you can choose Light or Dark and show or hide the character. The character stays on by default, and your choice is remembered."}],"3.24.0":[{title:"🎧 Claude FM plays from the minimap",body:"A small character stands on the minimap's top edge. Press it and the Claude channel's live stream plays; press it again and it stops. It only turns up when the channel is actually broadcasting, so a deck with no network never shows it at all."},{title:"🤠 And it gets on with its day",body:"It walks that edge, tidies up what it finds, kicks a ball along it, sits with its legs over the side, and watches the board through a scope. Now and then it drops onto the canvas and ropes its way back up. Headphones on while the music plays, a hat when it does not."}],"3.23.5":[{title:"🧭 The accounts panel opens on the account you are on",body:"Its windows, its resets and how old the numbers are — whole, at the top of the column. Every other account stands behind one row that says how many of them a switch could actually reach; press it to see them, or rest on it to be shown their names and how much room each has left."},{title:"⚙️ Auto-switch moved in there with them",body:"It is behind that same row now, after the accounts it switches between, rather than at the foot of the panel. The row says `auto 90%` or `auto off` so you can tell what the policy is doing without opening it — and says so in amber when it is armed with nowhere left to go."}],"3.23.0":[{title:"🧭 The accounts column leads with accounts",body:`The live account is the open row: its windows as bars, when each one resets, and how old the numbers are. Every other account rests on the two figures a switch is decided by, and opens with a click when you want the rest.
97
97
 
98
98
  A problem stays on the row — an expired login, one that was never stored, a keychain the deck cannot open — with the reason and the sign-in one press away. Auto-switch is one row now: its threshold and its switch. Local network moved out of the column into a view of its own, reached from a row at the foot that says how many of the paired machines are on right now, and shows which ones when you hover it.`},{title:"💬 A resting session shows Claude Code's recap beside its card",body:"When a session stops, Claude Code's own recap of what it did is drawn beside the card — so a board you come back to says what happened without opening anything."},{title:"🪟 The chrome went quiet",body:`The topbar is borderless, one set of corners runs through the app, the canvas ground is flat, and the minimap, the zoom controls, the type filter and the Machine and Usage panels read as tooling rather than as cards.
99
99
 
@@ -295,5 +295,5 @@ Nothing was added to the card and nothing new is polled. The deck already reads
295
295
  `).map(n=>({text:`+ ${n}`,tone:"add"}))]}function tne(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!Tr(n)||!Array.isArray(n.lines))return null;t.push({text:`@@ -${n.oldStart},${n.oldLines} +${n.newStart},${n.newLines} @@`,tone:"ctx"});for(const r of n.lines){const s=String(r);t.push(s.startsWith("+")?{text:s,tone:"add"}:s.startsWith("-")?{text:s,tone:"del"}:{text:s})}}return t}function FR(e){if(typeof e=="string")return[Qt(void 0,e)];if(!Tr(e))return[Qt(void 0,Fa(e))];const t=[],n=yn(e.type);n==="create"&&t.push(wn("result","created the file"));const r=tne(e.structuredPatch);return r&&t.push(dO("applied",r)),e.userModified===!0&&t.push(wn("note","the user changed it before it was applied")),t.length?t:[wn("result",n==="update"?"updated the file":"done")]}function nne(e){const t=typeof e.offset=="number"?e.offset:null,n=typeof e.limit=="number"?e.limit:null;if(t==null&&n==null)return null;const r=t??1;return n!=null?`${r}–${r+n-1}`:`from ${r}`}function rne(e){if(typeof e=="string")return[Qt(void 0,e)];const t=Tr(e)&&Tr(e.file)?e.file:null,n=yn(t==null?void 0:t.content);if(t&&n!=null){const s=[],i=Number(t.numLines),l=Number(t.totalLines),u=Number(t.startLine);return Number.isFinite(i)&&Number.isFinite(l)&&l>0&&s.push(wn("lines",i>=l?`all ${l}`:Number.isFinite(u)?`${u}–${u+i-1} of ${l}`:`${i} of ${l}`)),s.push(Qt("content",n)),s}const r=Tr(e)?yn(e.type):null;return r&&r!=="text"?[wn("result",`${/^[aeiou]/i.test(r)?"an":"a"} ${r} file`)]:[Qt(void 0,Fa(e))]}function sne(e){if(typeof e=="string")return[Qt("output",e)];if(!Tr(e))return[Qt(void 0,Fa(e))];const t=yn(e.stdout),n=yn(e.stderr);if(t==null&&n==null)return[Qt(void 0,Fa(e))];const r=[];return t&&r.push(Qt("output",t.replace(/\n$/,""))),n&&r.push(Qt("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&r.push(wn("note","interrupted before it finished")),r.length?r:[wn("output","none")]}function ane(e,t,n){const r=Tr(t)?t:null;if(r&&(e==="Edit"||e==="MultiEdit")){const s=yn(r.file_path),i=(e==="MultiEdit"?Array.isArray(r.edits)?r.edits:[]:[r]).filter(Tr).filter(l=>yn(l.old_string)!=null&&yn(l.new_string)!=null);if(s&&i.length){const l=[wn("file",s)];return i.forEach((u,d)=>{const f=u.replace_all===!0?", every occurrence":"";l.push(dO(i.length>1?`change ${d+1}${f}`:`change${f}`,ene(u.old_string,u.new_string)))}),{input:l,response:FR(n)}}}if(r&&e==="Write"){const s=yn(r.file_path),i=yn(r.content);if(s&&i!=null)return{input:[wn("file",s),Qt("content",i)],response:FR(n)}}if(r&&e==="Read"){const s=yn(r.file_path);if(s){const i=nne(r);return{input:i?[wn("file",s),wn("lines",i)]:[wn("file",s)],response:rne(n)}}}if(r&&e==="Bash"){const s=yn(r.command);if(s!=null){const i=yn(r.description);return{input:i?[Qt("command",s),wn("why",i)]:[Qt("command",s)],response:sne(n)}}}return{input:[Qt(void 0,Fa(t))],response:[Qt(void 0,Fa(n))]}}function qR(e,t,n){if(n==null)return"";if(typeof n=="string")return n;if(Tr(n)){if(e==="Bash"&&t==="input"&&typeof n.command=="string")return n.command;if(e==="Bash"&&t==="response"&&(typeof n.stdout=="string"||typeof n.stderr=="string"))return[n.stdout,n.stderr].filter(r=>typeof r=="string"&&r!=="").join(`
296
296
  `);if(e==="Read"&&t==="response"&&Tr(n.file)&&typeof n.file.content=="string")return n.file.content}try{return JSON.stringify(n,null,2)??String(n)}catch{return String(n)}}function one({tool:e,onClose:t}){const n=mt(t),r=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=e.input??e.inputPreview,i=e.response??e.errorPreview,l=ane(e.name,s,i);return a.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:`status-dot ${r}`,"aria-hidden":!0}),a.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),a.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",children:H2(e,"in-flight…")}),a.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("section",{className:"modal-body",children:[e.trimmed&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsx("h4",{children:"Input"}),a.jsx(UR,{text:qR(e.name,"input",s),what:"input"})]}),l.input.map((u,d)=>a.jsx(BR,{block:u},d))]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsxs("h4",{children:["Response ",r==="err"&&a.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&a.jsx(UR,{text:qR(e.name,"response",i),what:"response"})]}),e.endedAt==null?a.jsx("pre",{children:"(waiting…)"}):l.response.map((u,d)=>a.jsx(BR,{block:u},d))]})]})]})})}const ine={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function BR({block:e}){const[t,n]=v.useState(!1);if(e.inline)return a.jsxs("p",{className:"tm-inline",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("code",{children:e.text})]});const r=Jte(e),{shown:s}=uO(r,t),i=Qte(r,t);return a.jsxs("div",{className:"tm-block",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?s.map((l,u)=>a.jsxs("span",{className:l.tone?ine[l.tone]:void 0,children:[l.text,u<s.length-1?`
297
297
  `:""]},u)):s.map(l=>l.text).join(`
298
- `)}),i&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":i.expanded,onClick:()=>n(l=>!l),children:i.label})]})}function UR({text:e,what:t}){const[n,r]=v.useState(!1),s=v.useRef(!0);return v.useEffect(()=>()=>{s.current=!1},[]),a.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void Ba(e).then(i=>{!i||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const lne=v.lazy(()=>x0(()=>import("./UsageHistoryModal-DxNI8gR6.js"),[])),cne=v.lazy(()=>x0(()=>import("./BrowserWatchModal-B3UjvY82.js"),[]));function une({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:r,restart:s,lanPairs:i,clearFlow:l,watchBadge:u,announcements:d,appearance:f,providers:h,stateRef:p,agentCount:g}){const{openedTool:w,setOpenedToolKey:k,usageHistoryOpen:x,setUsageHistoryOpen:b,browserWatchOpen:j,setBrowserWatchOpen:S,contextAgent:_,setContextFor:E,summaryFor:T,setSummaryFor:R,keyHelpOpen:A,setKeyHelpOpen:U}=e,{tourOpen:I,openTour:q,closeTour:P,releaseNotes:O,closeReleaseNotes:V,chipVersion:$}=t,{desktopUpdateRestarting:M,desktopUpdateFailure:L,readyAppUpdate:Y,askDesktopUpdateRestart:K}=n,{version:D}=r,{askRestart:z}=s,{clearConfirmOpen:F,setClearConfirmOpen:H,requestClear:J}=l,{setWatchOn:W,markWatchSeen:G}=u,{setWatchSaid:X}=d,{palette:Z}=f;return a.jsxs(a.Fragment,{children:[w&&a.jsx(one,{tool:w,onClose:()=>k(null)}),x&&a.jsx(v.Suspense,{fallback:null,children:a.jsx(lne,{providers:h,onClose:()=>b(!1)})}),j&&a.jsx(v.Suspense,{fallback:null,children:a.jsx(cne,{onClose:()=>S(!1),onSeen:ee=>{X(""),G(ee)},onWatching:W,palette:Z})}),_&&a.jsx(sB,{agent:_,onClose:()=>E(null)}),T&&a.jsx(Kte,{state:p.current,sessionId:T,onClose:()=>R(null)}),O&&a.jsx(Gte,{entries:O.entries,since:O.since,firstRun:O.firstRun,running:$,onClose:V,onTour:()=>{V(),q()},updateVersion:Y==null?void 0:Y.version,updateBusy:M,updateFailure:L&&(!Y||Y.version===L.version)?zee(L.failure,L.version):void 0,onUpdateRestart:Y?()=>{K(Y.version)}:void 0,onRestart:!Y&&(D!=null&&D.canRestart)?()=>{V(),z()}:void 0}),a.jsx(Rte,{...i}),A&&a.jsx(Ete,{onClose:()=>U(!1),onTour:()=>{U(!1),q()}}),I&&a.jsx(c$,{title:"What the deck shows you",steps:$9,onClose:P}),F&&a.jsx(jte,{agentCount:g,onConfirm:()=>J("confirmation"),onCancel:()=>H(!1)})]})}const dne=1e3;function hne(e={}){const t=Math.max(1,Math.floor(e.limit??dne)),n=e.protect;let r=!1,s=[],i=new Set,l=0,u=0,d=null;return{get paused(){return r},get size(){return s.length},get dropped(){return l},get overflowed(){return l>0},get through(){return u},accept(f){const h=typeof(f==null?void 0:f.seq)=="number"?f.seq:null,p=(f==null?void 0:f.epoch)??null,g=p!==null&&p!==d;g&&(d=p,u=0);const w=h!==null&&!g&&h<=u;if(h!==null&&h>u&&(u=h),!r)return!0;if(w)return!1;if(s.push(f),n!=null&&n(f)&&i.add(f),s.length>t){let k=0;if(i.size<s.length)for(;i.has(s[k]);)k++;const[x]=s.splice(k,1);i.delete(x),l++}return!1},setPaused(f){if(r=f,f)return[];const h=s;return s=[],i=new Set,l=0,h}}}function fne(e){const t=v.useState(()=>hne({protect:i=>L6(e.current,i)}))[0],[n,r]=v.useState(!1),s=v.useCallback(()=>{const i=t.paused&&t.dropped>0,l=t.setPaused(!t.paused);i&&hq(e.current);for(const u of l)e.current=D2(e.current,u);r(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:s}}const qx={kind:"assumed",claude:!0,codex:!0};function pne(e){if(!e||typeof e!="object")return qx;const t=e.providers;if(!t||typeof t!="object")return qx;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function mne(e){const[t,n]=v.useState(null),[r,s]=v.useState(qx);v.useEffect(()=>{let l=!1;return fetch("/api/health").then(u=>u.ok?u.json():null).then(u=>{l||(s(pne(u)),!(!u||typeof u.workspace!="string")&&n(u.workspace))}).catch(()=>{}),()=>{l=!0}},[e]);const i=xn(r);return{workspace:t,providers:r,providersRef:i}}const hO=3*6e4,gne=2e4;function yne({fetchReport:e,visible:t,now:n,onReport:r}){let s=0,i=!0;const l=async()=>{if(!t())return;const u=await e();!i||!u||(s=n(),r(u))};return{tick:l,wake:async()=>{t()&&n()-s>=hO&&await l()},stop:()=>{i=!1}}}async function wne(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(gne)});return e.ok?await e.json():null}catch{return null}}function vne(e){const[t,n]=v.useState(null);return v.useEffect(()=>{if(!e){n(null);return}const r=yne({fetchReport:wne,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});r.tick();const s=window.setInterval(r.tick,hO),i=()=>{r.wake()};return document.addEventListener("visibilitychange",i),()=>{r.stop(),window.clearInterval(s),document.removeEventListener("visibilitychange",i)}},[e]),t}const xne={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},bne={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},kne={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},Nne={claude:"Claude",codex:"Codex"},jne=new Set(["status.claude.com","status.openai.com"]),Sne=30*6e4,_ne=10*6e4;function Ene(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&jne.has(t.hostname)?t:null}catch{return null}}function zR(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function Cne(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function Tne(e,t){if(!e||typeof e!="object")return null;const n=It(xne,e.state),r=It(Nne,e.provider);if(!n||!r||typeof e.checkedAt!="number"||t-e.checkedAt>Sne)return null;const s=Ene(e.statusPageUrl);if(!s)return null;const i=Array.isArray(e.components)?e.components:[],l=e.stale===!0||t-e.checkedAt>_ne,u=[`${r}: ${n}${e.summary?` — ${e.summary}`:""}`,i.length>0?`Affected: ${i.join(", ")}`:null,e.scope==="page"?`The page's overall status: it names none of ${r}'s components`:null,l?`Last read from ${s.hostname} at ${zR(e.checkedAt)}; this is the last thing it said`:`Reported by ${s.hostname}, checked ${Cne(t-e.checkedAt)}`,"Opens the status page"],d=l?zR(e.checkedAt):null;return{provider:e.provider,state:e.state,name:r,label:`${r} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:It(bne,e.state)??n,shortWords:It(kne,e.state)??n,asOf:d,what:e.summary||(i.length>0?i.join(", "):null),href:s.href,host:s.hostname,stale:l,detail:u.filter(Boolean).join(`
299
- `)}}function Rne(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>Tne(n,t)).filter(n=>n!==null)}function Ane(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const Mne="The providers' status pages report no incident.";function $ne({version:e,loadVersion:t}){var f;const[n,r]=v.useState(!1),s=((f=e==null?void 0:e.upgrade)==null?void 0:f.state)??"idle",i=hte(e==null?void 0:e.upgrade),l=v.useRef(!1),u=v.useCallback(async()=>{if(Sr(l.current||s==="running")){l.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),l.current=!1}},[s,t]);v.useEffect(()=>{if(s!=="running")return;const h=window.setInterval(t,3e3);return()=>window.clearInterval(h)},[s,t]);const d=v.useCallback(async()=>{const h=e==null?void 0:e.command;!h||!await Ba(h)||(r(!0),window.setTimeout(()=>r(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:s,upgradeFailure:i,startUpgrade:u,copyCommand:d,cmdCopied:n}}const HR="agent-dag.browserWatch.seenMs";function Ine(e,t){return e.filter(n=>n.startMs>t)}function One(){const[e,t]=v.useState(()=>Number(Qe(HR))||0),[n,r]=v.useState([]),[s,i]=v.useState(!1);v.useEffect(()=>{let d=!0;const f=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var g;!d||!(p!=null&&p.ok)||(r(p.episodes??[]),i(((g=p.settings)==null?void 0:g.enabled)===!0))}).catch(()=>{})};f();const h=setInterval(f,5*6e4);return()=>{d=!1,clearInterval(h)}},[]);const l=v.useMemo(()=>Ine(n,e).length,[n,e]),u=v.useCallback(d=>{t(d),Xe(HR,String(d))},[]);return{watchOn:s,setWatchOn:i,watchUnseen:l,markWatchSeen:u}}const fO=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function WR(e){const t={};for(const n of fO)t[n]=e(n);return t}function Lne(e){return t=>e[t]??""}function Pne(e,t){return fO.every(n=>e[n]===t[n])}const pO="agent-dag.theme";function Dne(e,t=!1){return e==="light"||e==="dark"?e:t?"light":"dark"}function Fne(){try{return window.matchMedia("(prefers-color-scheme: light)").matches}catch{return!1}}function qne(){return Dne(Qe(pO),Fne())}function VR(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function Bne(){const[e,t]=v.useState(qne),[n,r]=v.useState(iee),[s,i]=v.useState(()=>WR(VR)),l=v.useMemo(()=>Lne(s),[s]),u=v.useCallback(d=>hQ(d,l),[l]);return v.useEffect(()=>{document.documentElement.dataset.theme=e,Xe(pO,e),i(d=>{const f=WR(VR);return Pne(d,f)?d:f})},[e]),v.useEffect(()=>{Xe(tO,n?"1":"0")},[n]),v.useEffect(()=>{const d=document.querySelector('meta[name="theme-color"]'),f=s["--panel"];d&&f&&d.setAttribute("content",f)},[s]),{theme:e,setTheme:t,characterEnabled:n,setCharacterEnabled:r,palette:s,minimapNodeFill:u}}function Une(e){const t=v.useRef(null),[n,r]=v.useState(!1),[s,i]=v.useState(()=>new Set),l=v.useMemo(()=>{const d=new Set;for(const f of e.current.agents.values())for(const h of f.tools)d.add(QI(h.name));return Object.keys(JI).filter(f=>d.has(f))},[e.current,e.current.revision]);v.useEffect(()=>{if(l.length<=1){r(!1);return}let d=0;const f=()=>{const h=t.current;if(h&&!document.hidden){const p=h.getBoundingClientRect(),g=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(k=>k.getBoundingClientRect()),w=nQ(p,g,8);r(k=>k===w?k:w)}d=window.setTimeout(f,300)};return f(),()=>window.clearTimeout(d)},[l.length]);const u=v.useCallback(d=>{i(f=>{const h=new Set(f);return h.has(d)?h.delete(d):h.add(d),h})},[]);return{presentCats:l,hiddenCats:s,toggleCat:u,catBarRef:t,catBarOccluded:n}}function zne(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const r=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",s=()=>{var h;return(h=e.onState)==null?void 0:h.call(e,r())};function i(){var h,p;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(h=n.addEventListener)==null||h.call(n,"statechange",s)),(p=n.resume)==null||p.call(n).then(s,()=>{}),s()}catch{}}function l(h,p,g=p.figure){if(!n||n.state!=="running")return!1;const w=Tx(h,g),k=fK(p.level,w),x=n.currentTime;for(const b of w.notes){const j=n.createOscillator(),S=n.createGain();j.type=w.type??"sine",j.frequency.value=b.hz;const _=x+b.at,E=_+b.ms/1e3;S.gain.setValueAtTime(Qj,_),S.gain.exponentialRampToValueAtTime(k,_+pK),S.gain.exponentialRampToValueAtTime(Qj,E),j.connect(S).connect(n.destination),j.start(_),j.stop(E+.02)}return!0}async function u(h,p){if(!e.loadCustom)return"unavailable";let g;try{g=await e.loadCustom(h)}catch{return"unavailable"}if(!g)return"missing";if(g.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const k=new SpeechSynthesisUtterance(g.text),x=window.speechSynthesis.getVoices();k.voice=x.find(b=>b.voiceURI===g.voiceURI)??null,k.rate=g.rate,k.pitch=g.pitch,k.volume=mK(p.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(k),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let w;try{w=await n.decodeAudioData(g.bytes.slice(0))}catch{return"broken"}try{const k=n.createBufferSource(),x=n.createGain();return k.buffer=w,x.gain.setValueAtTime(gK(g.normalizationGain,p.level),n.currentTime),k.connect(x).connect(n.destination),k.start(n.currentTime),"played"}catch{return"unavailable"}}function d(h,p=!1){var k,x;if(!p&&!e.enabled())return!1;const g=NK((k=e.prefs)==null?void 0:k.call(e),h),w=((x=e.customSelection)==null?void 0:x.call(e)[h])??null;return w&&e.loadCustom?(u(w,g).then(b=>{var j;b==="played"||b==="locked"||((b==="missing"||b==="broken")&&((j=e.onCustomFailure)==null||j.call(e,h,w)),l(h,{...g,figure:vn},vn))}),!0):!n||n.state!=="running"?!1:l(h,g)}function f(h,p=Da){return u(h,{level:ri(p),figure:vn}),!0}return{unlock:i,play:d,previewCustom:f,state:r,get context(){return n}}}function Hne({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:r,fallbackCustomRef:s}){const[i,l]=v.useState("locked");return v.useEffect(()=>{const u=zne({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>r.current,loadCustom:lK,onCustomFailure:(p,g)=>s.current(p,g),onState:l});e.current=u,l(u.state());const d=["pointerdown","pointerup","keydown"],f=()=>{for(const p of d)window.removeEventListener(p,h,{capture:!0})},h=()=>{var p;u.unlock(),((p=u.context)==null?void 0:p.state)==="running"&&f()};for(const p of d)window.addEventListener(p,h,{capture:!0});return f},[]),{chimeState:i}}function Wne(){const[e,t]=v.useState(cee),[n,r]=v.useState(()=>l6(Qe(jN))),[s,i]=v.useState(()=>i6(Qe(SN))),[l,u]=v.useState(()=>c6(Qe(ER),n,aee)),[d,f]=v.useState(()=>new Set),[h,p]=v.useState(0);v.useEffect(()=>{Xe(nO,String(e))},[e]),v.useEffect(()=>{Xe(SN,s?"1":"0")},[s]),v.useEffect(()=>{Xe(jN,JSON.stringify(n))},[n]),v.useEffect(()=>{Xe(ER,l)},[l]);const g=v.useCallback(j=>{r(S=>S.some(_=>_.id===j.id)?S:[...S,j]),f(S=>{if(!S.has(j.id))return S;const _=new Set(S);return _.delete(j.id),_})},[]),w=v.useCallback((j,S)=>{const _=S.trim();!_||_.length>jl||r(E=>E.map(T=>T.id===j?{...T,name:_}:T))},[]),k=v.useCallback(j=>{r(S=>S.filter(_=>_.id!==j)),u(S=>u6(S,j)),f(S=>{if(!S.has(j))return S;const _=new Set(S);return _.delete(j),_})},[]),x=v.useCallback(j=>{const S=_N(j),_=d.has(S);j===l&&!_||(_&&f(E=>{const T=new Set(E);return T.delete(S),T}),u(j),p(E=>E+1))},[l,d]),b=v.useCallback((j,S)=>{const _=_N(j);f(E=>{if(E.has(_)===S)return E;const R=new Set(E);return S?R.add(_):R.delete(_),R})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:i,fmSource:l,customFmStations:n,unavailableFmStations:d,fmPlayRequest:h,addFmStation:g,renameFmStation:w,removeFmStation:k,pickFmSource:x,markFmStationAvailability:b}}function Vne(e){const[t,n]=v.useState(null),[r,s]=v.useState(!1),[i,l]=v.useState(null),u=v.useRef(0);v.useEffect(()=>{if(!e||!Ll())return;let k=!1;const x=u.current;return fetch("/api/desktop-update").then(b=>b.ok?b.json():null).then(b=>{if(k||u.current!==x)return;const j=IR(b);j&&n(j)}).catch(()=>{}),()=>{k=!0}},[e]);const d=Dee(t),f=v.useRef(!1),h=v.useRef(0),p=v.useRef(0);v.useEffect(()=>()=>window.clearTimeout(h.current),[]);const g=v.useCallback(async k=>{if(!Sr(f.current))return;const x=++p.current;window.clearTimeout(h.current),f.current=!0,s(!0),l(null);const b=j=>{x===p.current&&(window.clearTimeout(h.current),f.current=!1,s(!1),l({failure:j,version:k}))};try{const j=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:k})});if(!j.ok)return b(Uee(await j.json().catch(()=>null)))}catch{return b("unreachable")}x===p.current&&(h.current=window.setTimeout(()=>b("timeout"),rO))},[]),w=v.useCallback(k=>{if(Ll())try{const x=IR(JSON.parse(k));x&&(u.current++,n(x),x.status!=="ready"&&(p.current++,window.clearTimeout(h.current),f.current=!1,s(!1)))}catch{}},[]);return{desktopUpdateRestarting:r,desktopUpdateFailure:i,readyAppUpdate:d,askDesktopUpdateRestart:g,onDesktopUpdateEvent:w}}const _u="agent-dag.autoRestart",GR="agent-dag.bundleReloadedFor";function Gne({now:e,stateRef:t,version:n,notice:r,noticeOpen:s,upgradeFailure:i,paused:l}){const[u,d]=v.useState(()=>Qe(_u)!=="0"),f=v.useRef(!1),h=v.useCallback(()=>{const q=!u;f.current=!0,Zr(_u),d(q),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:q})}).then(P=>P.ok?P.json():null).then(P=>{var O;P!=null&&P.ok&&d(((O=P.prefs)==null?void 0:O.autoUpdate)!==!1)}).catch(()=>{})},[u]),[p,g]=v.useState(!1),[w,k]=v.useState("restart"),[x,b]=v.useState(null),j=v.useRef(!1),S=v.useRef(null),_=v.useRef(0),E=v.useRef(null),T=v.useCallback(async q=>{if(!Sr(j.current))return;const P=(q==null?void 0:q.upgrade)===!0,O=(q==null?void 0:q.whenIdle)===!0;j.current=!0,S.current=i;const V=++_.current,$=()=>{k(P?"npx":"restart"),g(!0)};O||$();try{window.sessionStorage.setItem("agent-dag.restartPending",(r==null?void 0:r.to)??"")}catch{}let M=!1;try{const L=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O?{upgrade:P,whenIdle:O}:{upgrade:P})});M=O&&L.status===409}catch{}if(M){j.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}O&&$(),window.setTimeout(()=>{if(_.current===V&&j.current){j.current=!1,g(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},P?18e4:3e4)},[r==null?void 0:r.to,i]);v.useEffect(()=>{const q=OR(t.current.agents.values())>0,P=yte({enabled:u,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:q,idleSince:E.current,now:e});E.current=P.idleSince,P.restart&&T({whenIdle:!0})},[u,r==null?void 0:r.kind,n==null?void 0:n.canRestart,s,e,T]);const R=OR(t.current.agents.values()),A=gte(R,l),U=aO({enabled:u,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:R>0,idleSince:E.current,now:e});v.useEffect(()=>{const q=n==null?void 0:n.running;let P=null,O=null;try{P=window.sessionStorage.getItem("agent-dag.restartPending"),O=window.sessionStorage.getItem(GR)}catch{return}const V=dte({bundle:"3.33.0",running:q,pending:P,lastTried:O});if(V==="reload"){try{window.sessionStorage.setItem(GR,q??"")}catch{return}window.location.reload();return}if(V!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}j.current=!1,g(!1),b(q??null);const $=window.setTimeout(()=>b(null),6e3);return()=>window.clearTimeout($)},[n==null?void 0:n.running]),v.useEffect(()=>{if(p&&fte({asked:S.current,reported:i})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}j.current=!1,g(!1)}},[p,i]);const I=v.useCallback(q=>{var P,O;if(!f.current){const V=Qe(_u)==="0";Zr(_u),V&&((P=q.prefs)==null?void 0:P.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((O=q.prefs)==null?void 0:O.autoUpdate)!==!1)}},[]);return{autoRestart:u,toggleAutoRestart:h,restarting:p,restartMode:w,restartedTo:x,askRestart:T,restartCopy:A,restartFuseMs:U,loadAutoRestartPrefs:I}}function Kne(){const[e,t]=v.useState([]),n=v.useRef(new Set),[r,s]=v.useState(null);v.useEffect(()=>{let u=!0,d=0;const f=()=>{fetch("/api/lan").then(h=>h.ok?h.json():null).then(h=>u?(h!=null&&h.ok&&t(Oj(Array.isArray(h.pending)?h.pending:[],h.aliases)),h):null).catch(()=>null).then(h=>{u&&(d=window.setTimeout(f,(h==null?void 0:h.enabled)===!0?Nx:l$))})};return f(),()=>{u=!1,window.clearTimeout(d)}},[]);const i=v.useCallback(async(u,d)=>{if(!r){s(u);try{const h=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:u,fp:d})})).json().catch(()=>null);h&&Array.isArray(h.pending)?t(Oj(h.pending,h.aliases)):t(p=>p.filter(g=>g.fp!==d))}catch{}finally{s(null)}}},[r]),l=v.useCallback(u=>{r||(n.current.add(u),t(d=>[...d]))},[r]);return{lanPending:e,lanDeferred:n,lanBusy:r,answerLanPair:i,deferLanPair:l}}const mO="agent-dag.sessionListOpen",gO="agent-dag.accountsPanelOpen";function Yne(){return Qe(mO)==="1"}function Xne(e){Xe(mO,e?"1":"0")}function Zne(){const e=Qe(gO);return e===null?!0:e==="1"}function Jne(){const[e,t]=v.useState(Yne);v.useEffect(()=>{Xne(e)},[e]);const n=v.useRef(!1),[r,s]=v.useState(()=>{const f=Zne();return f&&e?(n.current=!0,!1):f});v.useEffect(()=>{!r&&n.current||Xe(gO,r?"1":"0")},[r]),v.useEffect(()=>{!e&&n.current&&(n.current=!1,s(!0))},[e]);const i=v.useCallback(()=>{t(f=>(f||s(h=>(h&&(n.current=!0),!1)),!f))},[]),l=v.useCallback(()=>{n.current=!1,s(f=>(f||t(!1),!f))},[]),u=v.useCallback(()=>t(!1),[]),d=v.useCallback(()=>s(!1),[]);return{sessionListOpen:e,accountsPanelOpen:r,toggleSessionList:i,toggleAccountsPanel:l,closeSessionList:u,closeAccountsPanel:d}}const yO="agent-dag.detailOpen",wO="agent-dag.usagePanelOpen",vO="agent-dag.systemPanelOpen";function Qne(){return Qe(yO)==="1"}function ere(e){Xe(yO,e?"1":"0")}function tre(){const e=Qe(wO);return e===null?!0:e==="1"}function nre(e){Xe(wO,e?"1":"0")}function rre(){const e=Qe(vO);return e===null?!0:e==="1"}function sre(e){Xe(vO,e?"1":"0")}function are(){const[e,t]=v.useState(Qne);v.useEffect(()=>{ere(e)},[e]);const[n,r]=v.useState(tre);v.useEffect(()=>{nre(n)},[n]);const[s,i]=v.useState(rre);return v.useEffect(()=>{sre(s)},[s]),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:r,machinePanelOpen:s,setMachinePanelOpen:i}}const ore={permission:"your permission",asked:"your answer"},ire="No sessions are waiting for you.";function lre(e){if(e.length===0)return"";const[t,...n]=e,r=t.waiting.kind,s=n.every(l=>l.waiting.kind===r)?ore[r]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${s}.`;const i=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${i} are waiting for ${s}.`}function Iv(e,t,n=ire){return t!==""?t:e===""?"":n}function cre({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[r,s]=v.useState(""),i=lre(e);v.useEffect(()=>{s(g=>Iv(g,i))},[i]);const[l,u]=v.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";v.useEffect(()=>{u(g=>Iv(g,d,"Browser watch has no unread findings."))},[d]);const[f,h]=v.useState(""),p=Ane(n);return v.useEffect(()=>{h(g=>Iv(g,p,Mne))},[p]),{blockedSaid:r,watchSaid:l,setWatchSaid:u,incidentSaid:f}}function ure({waitingSessions:e,liveSince:t,focusSession:n}){const[r,s]=v.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[i,l]=v.useState(null),[u,d]=v.useState(!1),[f,h]=v.useState(!1),p=v.useRef(()=>{}),g=v.useRef(new Set),w=xn(e),k=v.useCallback(()=>{const T=!u;d(T),T&&(g.current=fu(w.current)),T&&typeof Notification<"u"&&Notification.permission==="default"&&p.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:T})}).then(R=>R.ok?R.json():null).then(R=>{var A;R!=null&&R.ok&&(d(((A=R.prefs)==null?void 0:A.notifications)===!0),h(R.notificationsVetoed===!0))}).catch(()=>{})},[u]),x=typeof Notification<"u";v.useEffect(()=>{if(!i)return;const R=setTimeout(()=>l(null),i==="blocked"?8e3:4e3);return()=>clearTimeout(R)},[i]);const b=v.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(T=>{const R=T;s(R),R==="granted"?l("on"):R==="denied"&&l("blocked")})},[]);p.current=b;const j=v.useRef(null),S=e.map(T=>Sd(T.id,T.waiting)).join("|");v.useEffect(()=>{Tq(j.current,r)&&(j.current=r,g.current=fu(e))},[r]);const _=v.useRef(!1);v.useEffect(()=>{Rq(_.current,t)&&(_.current=!0,g.current=fu(e))},[t]),v.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!Aq(j.current,t))return;const T=typeof document>"u"||!document.hidden,R=Eq(e,g.current,T,u);for(const A of R)try{const U=new Notification(A.title,{body:A.body,tag:A.key});U.onclick=()=>{window.focus(),n(A.sessionId),U.close()}}catch{}g.current=T?fu(e):Cq(e,R,g.current)},[S,t]);const E=v.useCallback(T=>{var R;d(((R=T.prefs)==null?void 0:R.notifications)===!0),h(T.notificationsVetoed===!0)},[]);return{notifyPermission:r,notifySaid:i,notifyOn:u,notifyVetoed:f,toggleNotify:k,notifySupported:x,askForNotifications:b,loadNotifyPrefs:E}}function dre({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:r,summaryFor:s,browserWatchOpen:i,keyHelpOpen:l,releaseNotes:u}){const d=xn(l),f=v.useRef(!1);return f.current=e!=null||t||n!=null||r||s!=null||i||l||u!=null,{keyHelpOpenRef:d,modalOpenRef:f}}function hre({stateRef:e,tourOpen:t,releaseNotes:n}){const[r,s]=v.useState(null),i=v.useCallback((T,R)=>s({agentId:T,toolId:R}),[]),[l,u]=v.useState(null),[d,f]=v.useState(null),h=v.useCallback(T=>f(T),[]),[p,g]=v.useState(!1),[w,k]=v.useState(!1),[x,b]=v.useState(!1),j=r?A6(e.current.agents,r.agentId,r.toolId):null,S=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:_,modalOpenRef:E}=dre({openedTool:j,usageHistoryOpen:w,contextFor:d,tourOpen:t,summaryFor:l,browserWatchOpen:x,keyHelpOpen:p,releaseNotes:n});return{setOpenedToolKey:s,openTool:i,openedTool:j,summaryFor:l,setSummaryFor:u,contextFor:d,setContextFor:f,openContext:h,contextAgent:S,keyHelpOpen:p,setKeyHelpOpen:g,usageHistoryOpen:w,setUsageHistoryOpen:k,browserWatchOpen:x,setBrowserWatchOpen:b,keyHelpOpenRef:_,modalOpenRef:E}}function fre({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:r,lastLayoutSigRef:s,forgetRemovals:i,clearSelection:l,rerender:u,modalOpenRef:d}){const[f,h]=v.useState(!1),p=v.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=l0(),t.current.clear(),n.current.clear(),r.current.clear(),s.current="",YI(),i(),l(),u()},[u,l,i]),g=xn(f),w=v.useCallback(k=>{const x=xte(k,{confirmOpen:g.current,modalOpen:d.current});x==="confirm"?h(!0):x==="clear"&&(h(!1),p())},[p]);return{clearConfirmOpen:f,setClearConfirmOpen:h,requestClear:w}}const KR="agent-dag.oldNameNoticeDismissed";function pre(e){const[t,n]=v.useState(()=>Qe(KR)??""),r=e!=null&&e.invokedAs&&e.invokedAs!==vt?e.invokedAs:null,s=r!=null&&t!==r,i=v.useCallback(()=>{r&&(n(r),Xe(KR,r))},[r]);return{oldName:r,oldNameOpen:s,dismissOldName:i}}function mre({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:r}){const[s,i]=v.useState(()=>XG(Qe)),l=xn(s),[u,d]=v.useState([]),f=v.useCallback(S=>{i(_=>{const E={..._,[S]:null};return l.current=E,E}),Zr(ml[S])},[]),h=v.useCallback((S,_)=>{const E=l.current[S];_&&E!==_||(f(S),t(T=>{const R={...T,[S]:{...T[S],figure:vn}};return n.current=R,R}),Xe(cd[S],vn))},[f]),p=xn(h);v.useEffect(()=>{let S=!0;return iK().then(_=>{if(!S)return;d(_);const E=new Set(_.map(T=>T.id));for(const T of Lu){const R=l.current[T];R&&!E.has(R)&&p.current(T,R)}},()=>{}),()=>{S=!1}},[]);const g=v.useCallback((S,_)=>{if(!u.some(T=>T.id===_))return;const E={...l.current,[S]:_};l.current=E,i(E),Xe(ml[S],_),r(S,!0)},[u,r]),w=v.useCallback(async S=>{var R;const _=Cx(u.length);if(_)throw new Error(_);const E=window.AudioContext??window.webkitAudioContext;if(!E)throw new Error("This browser cannot decode audio files.");const T=new E;try{const A=await nK(S,I=>T.decodeAudioData(I));await Zj(A);const U=$l(A);d(I=>[...I.filter(q=>q.id!==U.id),U])}finally{(R=T.close)==null||R.call(T)}},[u.length]),k=v.useCallback(async S=>{const _=Cx(u.length);if(_)throw new Error(_);const E=rK(S);await Zj(E);const T=$l(E);d(R=>[...R.filter(A=>A.id!==T.id),T])},[u.length]),x=v.useCallback(async(S,_)=>{const E=u.find(R=>R.id===S),T=_.trim().slice(0,80);!E||!T||T===E.name||(await cK(S,T),d(R=>R.map(A=>A.id===S?{...A,name:T}:A)))},[u]),b=v.useCallback(async S=>{await uK(S),d(R=>R.filter(A=>A.id!==S));const _=l.current,E=ZG(_,S);l.current=E,i(E);const T=Lu.filter(R=>_[R]===S);for(const R of T)Zr(ml[R]),Xe(cd[R],vn);T.length>0&&t(R=>{const A={...R};for(const U of T)A[U]={...A[U],figure:vn};return n.current=A,A})},[]),j=v.useCallback(S=>{var T,R;const _=Lu.find(A=>l.current[A]===S),E=_?n.current[_].level:Da;(T=e.current)==null||T.unlock(),(R=e.current)==null||R.previewCustom(S,E)},[]);return{customSelections:s,customSelectionsRef:l,customAssets:u,clearCustomOnly:f,fallbackCustomRef:p,selectCustomTone:g,importNotificationAudio:w,createNotificationVoice:k,renameCustomAsset:x,deleteCustomAsset:b,previewCustomAsset:j}}function gre(e){const[t,n]=v.useState(()=>kK(Qe)),r=xn(t),s=v.useRef(null),i=v.useCallback((u,d=!1)=>{var f,h;if((f=e.current)==null||f.unlock(),s.current!==null&&clearTimeout(s.current),s.current=null,!d){(h=e.current)==null||h.play(u,!0);return}s.current=setTimeout(()=>{var p;s.current=null,(p=e.current)==null||p.play(u,!0)},yK)},[]),l=v.useCallback((u,d)=>{n(f=>{const h={level:ri(d.level??f[u].level),figure:$$(u,d.figure??f[u].figure)};return Xe(L$[u],String(h.level)),Xe(cd[u],h.figure),{...f,[u]:h}}),i(u,!0)},[i]);return v.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:r,previewTone:i,changeTone:l}}const yre=15e3;function wre(e){return e.visibilityState==="visible"&&e.hasFocus()}function vre(e,t){return t||e===!0}function xre(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function bre(){v.useEffect(()=>{const e=xre();let t=null;const n=l=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:l}),keepalive:!0}).catch(()=>{})},r=()=>{const l=wre(document);vre(t,l)&&n(l),t=l},s=()=>{t&&n(!1),t=!1};r();const i=window.setInterval(r,yre);return window.addEventListener("focus",r),window.addEventListener("blur",r),document.addEventListener("visibilitychange",r),window.addEventListener("pagehide",s),()=>{window.clearInterval(i),window.removeEventListener("focus",r),window.removeEventListener("blur",r),document.removeEventListener("visibilitychange",r),window.removeEventListener("pagehide",s),s()}},[])}function kre({loadAutoRestartPrefs:e,loadNotifyPrefs:t}){v.useEffect(()=>{let n=!0;return fetch("/api/prefs").then(r=>r.ok?r.json():null).then(r=>{!n||!(r!=null&&r.ok)||(e(r),t(r))}).catch(()=>{}),()=>{n=!1}},[])}const Ov="agent-dag.versionNoticeDismissed",Nre=15*6e4;function jre(e){const[t,n]=v.useState(null),[r,s]=v.useState(()=>Qe(Ov)??""),i=v.useRef(0),[l,u]=v.useState(!1),d=v.useCallback((x=!1)=>(x&&(i.current=Date.now(),u(!0)),fetch(x?"/api/version?refresh=1":"/api/version").then(b=>b.ok?b.json():null).then(b=>{b&&n(b)}).catch(()=>{}).finally(()=>{x&&u(!1)})),[]),f=v.useCallback(()=>{d(Date.now()-i.current>=Nre)},[d]);v.useEffect(()=>{d();const x=window.setInterval(f,5*6e4),b=()=>{document.visibilityState==="visible"&&f()};return document.addEventListener("visibilitychange",b),()=>{window.clearInterval(x),document.removeEventListener("visibilitychange",b)}},[d,f]),v.useEffect(()=>{e&&d()},[e,d]);const h=(t==null?void 0:t.notice)??null,p=sO(h),g=Kee(h,r),w=v.useCallback(()=>{s(""),Xe(Ov,"")},[]),k=v.useCallback(()=>{h&&(s(p),Xe(Ov,p))},[h,p]);return{version:t,notice:h,noticeOpen:g,showNotice:w,dismissNotice:k,versionChecking:l,loadVersion:d}}function Sre({version:e,readyAppUpdate:t}){const[n,r]=v.useState(!1),s=v.useRef(null),[i,l]=v.useState(null),u=i&&t?t.version:null,d=v.useRef(null);v.useEffect(()=>{!u||d.current===u||(d.current=u,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:u})}).catch(()=>{}))},[u]);const f=v.useRef(!1);v.useEffect(()=>{if(f.current)return;const b=fl(),j=Fte(b),S=Wte({stored:j,running:(e==null?void 0:e.running)??null,notes:DR,remembers:qte(b)});if(S.reason==="no-version")return;f.current=!0,S.record&&Bte(b,S.record);let _=!0;return(async()=>{var U;let T=Ute(b);if(Ll())try{const I=await fetch("/api/prefs");if(!I.ok)throw new Error("desktop tour preferences unavailable");const q=await I.json();if(!(q!=null&&q.ok))throw new Error("desktop tour preferences unavailable");const P=((U=q.prefs)==null?void 0:U.tourSeen)===!0;T&&!P&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),T=T||P}catch{T=!0}if(!_)return;const R=Hte({tourSeen:T,decision:S}),A=S.show.length?{entries:S.show,since:j,firstRun:!1}:null;R.tour&&r(!0),R.notes==="now"?l(A):R.notes==="after"&&(s.current=A)})(),()=>{_=!1}},[e==null?void 0:e.running]);const h=(e==null?void 0:e.running)??"3.33.0",p=v.useMemo(()=>oO(DR,null,h),[h]),g=v.useCallback(()=>{l({entries:p,since:null,firstRun:!1})},[p]),w=v.useCallback(()=>r(!0),[]),k=v.useCallback(()=>l(null),[]),x=v.useCallback(()=>{r(!1),zte(fl()),Ll()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const b=s.current;s.current=null,b&&l(b)},[]);return{tourOpen:n,openTour:w,closeTour:x,releaseNotes:i,closeReleaseNotes:k,chipVersion:h,openReleaseNotes:g}}function _re(){const[e,t]=v.useState(null),[n,r]=v.useState(!1),s=v.useRef(null);return v.useEffect(()=>{let i=!0,l=!1,u=null,d=null,f="";const h=x=>{i&&(r(!0),x!==f&&t(null))},p=()=>{if(l)return;l=!0,u=Date.now();const x=MR();d=x,fetch(`/api/ccusage?since=${x}`).then(b=>b.ok?b.json():null).then(b=>{if(i){if(!(b!=null&&b.ok)){h(x);return}f=x,t(Lee(b)),r(!1)}}).catch(()=>h(x)).finally(()=>{l=!1})},g=()=>{const x=s.current;Oee({shown:!!x&&x.getClientRects().length>0,tabVisible:document.visibilityState==="visible",lastSince:d,since:MR(),lastReadAt:u,now:Date.now()})&&p()};g();const w=window.setInterval(g,Iee);document.addEventListener("visibilitychange",g);let k=null;return s.current&&typeof ResizeObserver<"u"&&(k=new ResizeObserver(g),k.observe(s.current)),()=>{i=!1,window.clearInterval(w),document.removeEventListener("visibilitychange",g),k==null||k.disconnect()}},[]),{monthlyUsage:e,monthlyUsageUnavailable:n,monthUsageRef:s}}function Ere(e){const[t,n]=v.useState(null);v.useEffect(()=>{const u=Qe("agent-dag.sound");n(u===null?!0:u==="on")},[]);const r=v.useCallback(()=>{n(u=>{var f;const d=u!==!0;return Xe("agent-dag.sound",d?"on":"off"),d&&((f=e.current)==null||f.unlock()),d})},[]),s=v.useCallback(u=>{r()},[r]),i=xn(s),l=xn(t);return{soundOn:t,toggleSound:r,activateSoundRef:i,soundOnRef:l}}function Cre(){const[e,t]=v.useState(!1),n=v.useRef(null),[r,s]=v.useState(!1),i=v.useRef(null);return v.useEffect(()=>{e&&s(!1)},[e]),{soundMenuOpen:e,setSoundMenuOpen:t,soundButtonRef:n,appearanceMenuOpen:r,setAppearanceMenuOpen:s,appearanceButtonRef:i}}const Tre="agent-dag.autoFitDisabled";function Rre(e){const t=v.useRef(!1),[n,r]=v.useState(!1);v.useEffect(()=>{Zr(Tre)},[]);const s=v.useCallback(()=>{t.current||(t.current=!0,r(!0))},[]),i=v.useCallback(()=>{t.current=!1,r(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:i}}function Are(){return a.jsx(a0,{children:a.jsx(Mre,{})})}function Mre(){const e=oi(),t=v.useState(l0)[0],n=v.useRef(t),[,r]=v.useState(0),s=v.useCallback(()=>r(Fr=>Fr+1),[]),{detailOpen:i,setDetailOpen:l,usagePanelOpen:u,setUsagePanelOpen:d,machinePanelOpen:f,setMachinePanelOpen:h}=are(),{selectedIds:p,primarySelectedId:g,selectAgent:w,clearSelection:k,pruneSelectionToBoard:x}=qK(n,l),{sessionListOpen:b,accountsPanelOpen:j,toggleSessionList:S,toggleAccountsPanel:_,closeSessionList:E,closeAccountsPanel:T}=Jne(),R=_re(),A=Mu(j,200),U=Mu(u,130),I=Mu(f,130),q=v.useRef(null),P=Ere(q),{activateSoundRef:O,soundOnRef:V}=P,$=gre(q),{setTonePrefs:M,tonePrefsRef:L,previewTone:Y}=$,K=mre({chimesRef:q,setTonePrefs:M,tonePrefsRef:L,previewTone:Y}),{customSelectionsRef:D,fallbackCustomRef:z}=K,F=Cre(),{setSoundMenuOpen:H}=F,{chimeState:J}=Hne({chimesRef:q,soundOnRef:V,tonePrefsRef:L,customSelectionsRef:D,fallbackCustomRef:z}),W=fne(n),{pauseGate:G,paused:X,togglePause:Z}=W,ee=v.useRef(()=>{}),{live:re,tabCapped:ce,everConnected:ie,liveSince:fe}=RK({stateRef:n,rerender:s,pauseGate:G,chimesRef:q,desktopUpdateRef:ee}),de=jre(re),{version:we,notice:xe,noticeOpen:$e,loadVersion:be}=de,he=Vne(re),{readyAppUpdate:se,onDesktopUpdateEvent:ke}=he;ee.current=ke,bre();const Ce=Sre({version:we,readyAppUpdate:se}),{tourOpen:Oe,openTour:Le,releaseNotes:Pe}=Ce,{workspace:qe,providers:Ue,providersRef:et}=mne(re),ze=pre(we),at=$ne({version:we,loadVersion:be}),{upgradeFailure:gt}=at,Ie=hre({stateRef:n,tourOpen:Oe,releaseNotes:Pe}),{openTool:ot,setSummaryFor:Je,setContextFor:it,openContext:Ft,setKeyHelpOpen:kt,setUsageHistoryOpen:Nt,setBrowserWatchOpen:qt,keyHelpOpenRef:kn,modalOpenRef:Gt}=Ie,Bt=One(),{watchOn:dn,watchUnseen:Kt}=Bt,as=Kne(),[$r,os]=v.useState(0),{presentCats:ur,hiddenCats:Bn,toggleCat:is,catBarRef:Nn,catBarOccluded:dr}=Une(n),hn=v.useRef(null),[ls,jn]=v.useState(0),yt=BK({stateRef:n,rerender:s,pruneSelectionToBoard:x,setContextFor:it,setSummaryFor:Je}),Un=vne(Ue.claude||Ue.codex),ge=Rne(Un,yt),He=Gne({now:yt,stateRef:n,version:we,notice:xe,noticeOpen:$e,upgradeFailure:gt,paused:W.paused}),{askRestart:Ze,loadAutoRestartPrefs:fn}=He,Ut=Bne(),{setTheme:hr,palette:Xs}=Ut,cs=Wne(),zn=DJ(),{applyViewport:Va,moveCamera:Ga,fitLeft:fr,cameraEpochRef:Ka,lastFitTimeRef:Ya}=zn,Ye=XJ(fr),{pinnedRef:us,positionsRef:pr,lastLayoutSigRef:Xa,handleRelayout:ds}=Ye,Zs=v.useRef(null),Js=v.useRef(()=>{}),hs=fe!==null,Yt=v.useRef(0),fs=v.useCallback(()=>{Yt.current=Date.now()},[]),{canvasRef:jt,canvasSize:oh,paneSizeRef:ih}=RQ(),Zl=Rre(fr),{autoFitDisabledRef:Qs,disableAutoFit:ps}=Zl,Ir=v.useRef(!1),{measuredRef:Sn,measuredVersionRef:lh,sizeVersion:ch,domSizeVersion:gi}=AQ(Ir),{removedNodes:yi,removedAgentIds:mr,removeNode:ea,removeSelectedNode:Jl,removalNotice:Za,bringBack:We,bringBackAll:Ql,forgetRemovals:ec}=bQ({stateRef:n,pinnedRef:us,positionsRef:pr,canvasRef:jt,clearSelection:k,primarySelectedId:g}),ta=gQ({stateRef:n,now:yt,removedAgentIds:mr,sizeVersion:ch,domSizeVersion:gi});ZJ(ta,Ye),xQ({layoutSig:ta,rf:e,stateRef:n,measuredRef:Sn,pinnedRef:us,positionsRef:pr,paneSizeRef:ih,lastInteractRef:Yt,autoFitDisabledRef:Qs,lastFitTimeRef:Ya,fitLeft:fr});const wi=MQ(),{bubbling:tc,endBubble:nc,onBubble:vi}=IG(),[ms,gr]=v.useState(!1),Hn=MG(),{beginTrashDrag:yr,trackTrashDrag:na,endTrashDrag:ra}=Hn,Wn=zG({stateRef:n,measuredRef:Sn,measuredVersionRef:lh,canvasRef:jt}),{lodRef:uh,applyZoom:rc}=Wn,gs=CQ({applyViewport:Va,lastFitTimeRef:Ya,cameraEpochRef:Ka,disableAutoFit:ps,markInteract:fs,canvasRef:jt,applyZoom:rc}),sa=g?n.current.agents.get(g):null,xi=i&&sa!=null,{railInsetRef:aa,availableWidth:bi,availableHeight:sc}=PJ({canvasRef:jt,canvasSize:oh,machinePhase:I,usagePhase:U,usagePanelOpen:u,detailShown:xi}),ys=yQ({stateRef:n,now:yt,availableWidth:bi,availableHeight:sc,layout:Ye,measuredRef:Sn,onBubble:vi,settled:wi,dragging:ms,layoutSig:ta,selectedIds:p,openContext:Ft,historyReplayed:hs,removedNodes:yi,removedAgentIds:mr,dragTick:$r,dragPatchRef:hn,dragMoveTick:ls}),{nodes:Or,edges:ws}=ys,vs=xn(g);JJ({nodes:Or,edges:ws,settled:wi,dragging:ms,availableWidth:bi,availableHeight:sc,layout:Ye,camera:zn,rf:e,measuredRef:Sn,stateRef:n,lastFocusRef:Zs,primarySelectedIdRef:vs,focusAgentRef:Js,autoFitDisabledRef:Qs});const ac=fre({stateRef:n,pinnedRef:us,measuredRef:Sn,positionsRef:pr,lastLayoutSigRef:Xa,forgetRemovals:ec,clearSelection:k,rerender:s,modalOpenRef:Gt}),{requestClear:oc}=ac,ki=OQ({nodes:Or,stateRef:n,pinnedRef:us,positionsRef:pr,draggingRef:Ir,dragPatchRef:hn,setDragging:gr,setDragMoveTick:jn,setDragTick:os,endBubble:nc,markInteract:fs,disableAutoFit:ps,beginTrashDrag:yr,trackTrashDrag:na,endTrashDrag:ra,removeNode:ea}),Ja=v.useCallback(()=>fr(500),[fr]),oa=xn(Or),{focusAgent:ia,stepAgent:wr,focusSession:Lr}=qJ({canvasRef:jt,stateRef:n,measuredRef:Sn,nodesRef:oa,railInsetRef:aa,moveCamera:Ga,disableAutoFit:ps,lastFocusRef:Zs,focusAgentRef:Js,selectAgent:w,primarySelectedIdRef:vs}),Qa=TQ({clearSelection:k,selectAgent:w,detailOpen:i,setDetailOpen:l,detailShown:xi,focusAgent:ia,draggingRef:Ir,lodRef:uh}),ic=BJ({nodesRef:oa,stateRef:n,canvasRef:jt,railInsetRef:aa}),eo=xn(Jl),la=v.useRef(null),lc=v.useCallback(Fr=>{mr.has(Fr)&&We([Fr]),Lr(Fr)},[mr,We,Lr]),Xt=$Q();IQ({pointerFocusRef:Xt,nodesRef:oa,stateRef:n,primarySelectedIdRef:vs,providersRef:et,soundOnRef:V,keyHelpOpenRef:kn,modalOpenRef:Gt,waitingCursorRef:la,removeSelectedRef:eo,activateSoundRef:O,clearSelection:k,selectAgent:w,focusAgent:ia,stepAgent:wr,focusSession:Lr,requestClear:oc,handleRelayout:ds,handleFit:Ja,togglePause:Z,toggleSessionList:S,toggleAccountsPanel:_,setDetailOpen:l,setUsageHistoryOpen:Nt,setUsagePanelOpen:d,setMachinePanelOpen:h,setBrowserWatchOpen:qt,setSoundMenuOpen:H,setKeyHelpOpen:kt,setTheme:hr});const Pr=n.current.agents.size,Dr=v.useMemo(()=>ex(n.current.agents.values()),[n.current,n.current.revision]);kQ({stateRef:n,waitingSessions:Dr,removedAgentIds:mr,removedNodes:yi,bringBack:We}),SQ({stateRef:n,waitingSessions:Dr,live:re});const xs=cre({waitingSessions:Dr,watchUnseen:Kt,incidents:ge}),Ni=ure({waitingSessions:Dr,liveSince:fe,focusSession:Lr}),{loadNotifyPrefs:ji}=Ni;return kre({loadAutoRestartPrefs:fn,loadNotifyPrefs:ji}),a.jsxs("div",{className:"app",children:[a.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),a.jsxs("header",{className:"topbar",children:[a.jsx(ete,{versionCheck:de,welcome:Ce,desktopUpdate:he,pause:W,monthly:R,announcements:xs,notify:Ni,waitingSessions:Dr,waitingCursorRef:la,focusSession:Lr,live:re,now:yt,incidents:ge}),sa&&a.jsx(tte,{selected:sa,now:yt,selectedIds:p,focusAgent:ia,clearSelection:k}),a.jsxs("div",{className:"actions",children:[a.jsx(Ree,{sessionListOpen:b,toggleSessionList:S,usagePanelOpen:u,setUsagePanelOpen:d,setUsageHistoryOpen:Nt}),a.jsx(Aee,{providers:Ue,accountsPanelOpen:j,toggleAccountsPanel:_,machinePanelOpen:f,setMachinePanelOpen:h,watchOn:dn,watchUnseen:Kt,setBrowserWatchOpen:qt}),a.jsx(Mee,{providers:Ue,sound:P,tones:$,customTones:K,notify:Ni,chimeState:J,menus:F,appearance:Ut,fm:cs})]})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Za?`${Za.label} removed from the board.`:""}),a.jsx(vte,{restart:He,versionCheck:de,upgrade:at,oldNameNotice:ze,everConnected:ie,live:re,paused:X}),Au(A)&&Ue.claude&&a.jsx(SG,{leaving:A==="leaving",onClose:T}),b&&a.jsx(hz,{state:n.current,now:yt,selectedIds:p,onSelect:lc,onClose:E,removedIds:mr,onBringBackAll:Ql}),a.jsxs(ote,{canvasRef:jt,bubbling:tc,dragging:ms,trash:Hn,zoom:Wn,viewport:gs,stateRef:n,peek:ic,children:[Pr===0&&(!re&&ce?a.jsx(zQ,{}):a.jsx(HQ,{live:re,everConnected:ie,providers:Ue,workspace:qe,onTour:Le})),(ur.length>1||Bn.size>0)&&a.jsx(nte,{catBarRef:Nn,catBarOccluded:dr,presentCats:ur,hiddenCats:Bn,toggleCat:is}),a.jsx(sz,{graph:ys,layout:Ye,viewport:gs,clicks:Qa,drag:ki,appearance:Ut,fm:cs,autoFit:Zl,pause:W,stateRef:n,measuredRef:Sn,hiddenCats:Bn,now:yt,openTool:ot,focusAgent:ia,requestClear:oc,setKeyHelpOpen:kt})]}),Au(U)&&a.jsx(sH,{state:n.current,now:yt,providers:Ue,incidents:ge,liveSince:fe,leaving:U==="leaving",onClose:()=>d(!1)}),Au(I)&&a.jsx(UH,{usageOpen:u,leaving:I==="leaving",onClose:()=>h(!1)}),i&&sa?a.jsx(ree,{selected:sa,now:yt,openTool:ot,setSummaryFor:Je,setDetailOpen:l,stateRef:n,removeSelectedNode:Jl}):null,a.jsx(une,{dialogs:Ie,welcome:Ce,desktopUpdate:he,versionCheck:de,restart:He,lanPairs:as,clearFlow:ac,watchBadge:Bt,announcements:xs,appearance:Ut,providers:Ue,stateRef:n,agentCount:Pr})]})}try{uB(window.localStorage)}catch{}const $re=QL.createRoot(document.getElementById("root"));$re.render(a.jsx(Are,{}));export{DQ as a,st as b,Ws as c,id as d,Ore as e,Be as f,Jr as g,Ire as h,Ml as i,a as j,ns as k,eK as l,Na as m,Ba as n,hx as p,v as r,Sr as s,mt as u};
298
+ `)}),i&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":i.expanded,onClick:()=>n(l=>!l),children:i.label})]})}function UR({text:e,what:t}){const[n,r]=v.useState(!1),s=v.useRef(!0);return v.useEffect(()=>()=>{s.current=!1},[]),a.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void Ba(e).then(i=>{!i||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const lne=v.lazy(()=>x0(()=>import("./UsageHistoryModal-CIDpgHTW.js"),[])),cne=v.lazy(()=>x0(()=>import("./BrowserWatchModal-BTNOQdp5.js"),[]));function une({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:r,restart:s,lanPairs:i,clearFlow:l,watchBadge:u,announcements:d,appearance:f,providers:h,stateRef:p,agentCount:g}){const{openedTool:w,setOpenedToolKey:k,usageHistoryOpen:x,setUsageHistoryOpen:b,browserWatchOpen:j,setBrowserWatchOpen:S,contextAgent:_,setContextFor:E,summaryFor:T,setSummaryFor:R,keyHelpOpen:A,setKeyHelpOpen:U}=e,{tourOpen:I,openTour:q,closeTour:P,releaseNotes:O,closeReleaseNotes:V,chipVersion:$}=t,{desktopUpdateRestarting:M,desktopUpdateFailure:L,readyAppUpdate:Y,askDesktopUpdateRestart:K}=n,{version:D}=r,{askRestart:z}=s,{clearConfirmOpen:F,setClearConfirmOpen:H,requestClear:J}=l,{setWatchOn:W,markWatchSeen:G}=u,{setWatchSaid:X}=d,{palette:Z}=f;return a.jsxs(a.Fragment,{children:[w&&a.jsx(one,{tool:w,onClose:()=>k(null)}),x&&a.jsx(v.Suspense,{fallback:null,children:a.jsx(lne,{providers:h,onClose:()=>b(!1)})}),j&&a.jsx(v.Suspense,{fallback:null,children:a.jsx(cne,{onClose:()=>S(!1),onSeen:ee=>{X(""),G(ee)},onWatching:W,palette:Z})}),_&&a.jsx(sB,{agent:_,onClose:()=>E(null)}),T&&a.jsx(Kte,{state:p.current,sessionId:T,onClose:()=>R(null)}),O&&a.jsx(Gte,{entries:O.entries,since:O.since,firstRun:O.firstRun,running:$,onClose:V,onTour:()=>{V(),q()},updateVersion:Y==null?void 0:Y.version,updateBusy:M,updateFailure:L&&(!Y||Y.version===L.version)?zee(L.failure,L.version):void 0,onUpdateRestart:Y?()=>{K(Y.version)}:void 0,onRestart:!Y&&(D!=null&&D.canRestart)?()=>{V(),z()}:void 0}),a.jsx(Rte,{...i}),A&&a.jsx(Ete,{onClose:()=>U(!1),onTour:()=>{U(!1),q()}}),I&&a.jsx(c$,{title:"What the deck shows you",steps:$9,onClose:P}),F&&a.jsx(jte,{agentCount:g,onConfirm:()=>J("confirmation"),onCancel:()=>H(!1)})]})}const dne=1e3;function hne(e={}){const t=Math.max(1,Math.floor(e.limit??dne)),n=e.protect;let r=!1,s=[],i=new Set,l=0,u=0,d=null;return{get paused(){return r},get size(){return s.length},get dropped(){return l},get overflowed(){return l>0},get through(){return u},accept(f){const h=typeof(f==null?void 0:f.seq)=="number"?f.seq:null,p=(f==null?void 0:f.epoch)??null,g=p!==null&&p!==d;g&&(d=p,u=0);const w=h!==null&&!g&&h<=u;if(h!==null&&h>u&&(u=h),!r)return!0;if(w)return!1;if(s.push(f),n!=null&&n(f)&&i.add(f),s.length>t){let k=0;if(i.size<s.length)for(;i.has(s[k]);)k++;const[x]=s.splice(k,1);i.delete(x),l++}return!1},setPaused(f){if(r=f,f)return[];const h=s;return s=[],i=new Set,l=0,h}}}function fne(e){const t=v.useState(()=>hne({protect:i=>L6(e.current,i)}))[0],[n,r]=v.useState(!1),s=v.useCallback(()=>{const i=t.paused&&t.dropped>0,l=t.setPaused(!t.paused);i&&hq(e.current);for(const u of l)e.current=D2(e.current,u);r(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:s}}const qx={kind:"assumed",claude:!0,codex:!0};function pne(e){if(!e||typeof e!="object")return qx;const t=e.providers;if(!t||typeof t!="object")return qx;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function mne(e){const[t,n]=v.useState(null),[r,s]=v.useState(qx);v.useEffect(()=>{let l=!1;return fetch("/api/health").then(u=>u.ok?u.json():null).then(u=>{l||(s(pne(u)),!(!u||typeof u.workspace!="string")&&n(u.workspace))}).catch(()=>{}),()=>{l=!0}},[e]);const i=xn(r);return{workspace:t,providers:r,providersRef:i}}const hO=3*6e4,gne=2e4;function yne({fetchReport:e,visible:t,now:n,onReport:r}){let s=0,i=!0;const l=async()=>{if(!t())return;const u=await e();!i||!u||(s=n(),r(u))};return{tick:l,wake:async()=>{t()&&n()-s>=hO&&await l()},stop:()=>{i=!1}}}async function wne(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(gne)});return e.ok?await e.json():null}catch{return null}}function vne(e){const[t,n]=v.useState(null);return v.useEffect(()=>{if(!e){n(null);return}const r=yne({fetchReport:wne,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});r.tick();const s=window.setInterval(r.tick,hO),i=()=>{r.wake()};return document.addEventListener("visibilitychange",i),()=>{r.stop(),window.clearInterval(s),document.removeEventListener("visibilitychange",i)}},[e]),t}const xne={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},bne={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},kne={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},Nne={claude:"Claude",codex:"Codex"},jne=new Set(["status.claude.com","status.openai.com"]),Sne=30*6e4,_ne=10*6e4;function Ene(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&jne.has(t.hostname)?t:null}catch{return null}}function zR(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function Cne(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function Tne(e,t){if(!e||typeof e!="object")return null;const n=It(xne,e.state),r=It(Nne,e.provider);if(!n||!r||typeof e.checkedAt!="number"||t-e.checkedAt>Sne)return null;const s=Ene(e.statusPageUrl);if(!s)return null;const i=Array.isArray(e.components)?e.components:[],l=e.stale===!0||t-e.checkedAt>_ne,u=[`${r}: ${n}${e.summary?` — ${e.summary}`:""}`,i.length>0?`Affected: ${i.join(", ")}`:null,e.scope==="page"?`The page's overall status: it names none of ${r}'s components`:null,l?`Last read from ${s.hostname} at ${zR(e.checkedAt)}; this is the last thing it said`:`Reported by ${s.hostname}, checked ${Cne(t-e.checkedAt)}`,"Opens the status page"],d=l?zR(e.checkedAt):null;return{provider:e.provider,state:e.state,name:r,label:`${r} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:It(bne,e.state)??n,shortWords:It(kne,e.state)??n,asOf:d,what:e.summary||(i.length>0?i.join(", "):null),href:s.href,host:s.hostname,stale:l,detail:u.filter(Boolean).join(`
299
+ `)}}function Rne(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>Tne(n,t)).filter(n=>n!==null)}function Ane(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const Mne="The providers' status pages report no incident.";function $ne({version:e,loadVersion:t}){var f;const[n,r]=v.useState(!1),s=((f=e==null?void 0:e.upgrade)==null?void 0:f.state)??"idle",i=hte(e==null?void 0:e.upgrade),l=v.useRef(!1),u=v.useCallback(async()=>{if(Sr(l.current||s==="running")){l.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),l.current=!1}},[s,t]);v.useEffect(()=>{if(s!=="running")return;const h=window.setInterval(t,3e3);return()=>window.clearInterval(h)},[s,t]);const d=v.useCallback(async()=>{const h=e==null?void 0:e.command;!h||!await Ba(h)||(r(!0),window.setTimeout(()=>r(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:s,upgradeFailure:i,startUpgrade:u,copyCommand:d,cmdCopied:n}}const HR="agent-dag.browserWatch.seenMs";function Ine(e,t){return e.filter(n=>n.startMs>t)}function One(){const[e,t]=v.useState(()=>Number(Qe(HR))||0),[n,r]=v.useState([]),[s,i]=v.useState(!1);v.useEffect(()=>{let d=!0;const f=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var g;!d||!(p!=null&&p.ok)||(r(p.episodes??[]),i(((g=p.settings)==null?void 0:g.enabled)===!0))}).catch(()=>{})};f();const h=setInterval(f,5*6e4);return()=>{d=!1,clearInterval(h)}},[]);const l=v.useMemo(()=>Ine(n,e).length,[n,e]),u=v.useCallback(d=>{t(d),Xe(HR,String(d))},[]);return{watchOn:s,setWatchOn:i,watchUnseen:l,markWatchSeen:u}}const fO=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function WR(e){const t={};for(const n of fO)t[n]=e(n);return t}function Lne(e){return t=>e[t]??""}function Pne(e,t){return fO.every(n=>e[n]===t[n])}const pO="agent-dag.theme";function Dne(e,t=!1){return e==="light"||e==="dark"?e:t?"light":"dark"}function Fne(){try{return window.matchMedia("(prefers-color-scheme: light)").matches}catch{return!1}}function qne(){return Dne(Qe(pO),Fne())}function VR(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function Bne(){const[e,t]=v.useState(qne),[n,r]=v.useState(iee),[s,i]=v.useState(()=>WR(VR)),l=v.useMemo(()=>Lne(s),[s]),u=v.useCallback(d=>hQ(d,l),[l]);return v.useEffect(()=>{document.documentElement.dataset.theme=e,Xe(pO,e),i(d=>{const f=WR(VR);return Pne(d,f)?d:f})},[e]),v.useEffect(()=>{Xe(tO,n?"1":"0")},[n]),v.useEffect(()=>{const d=document.querySelector('meta[name="theme-color"]'),f=s["--panel"];d&&f&&d.setAttribute("content",f)},[s]),{theme:e,setTheme:t,characterEnabled:n,setCharacterEnabled:r,palette:s,minimapNodeFill:u}}function Une(e){const t=v.useRef(null),[n,r]=v.useState(!1),[s,i]=v.useState(()=>new Set),l=v.useMemo(()=>{const d=new Set;for(const f of e.current.agents.values())for(const h of f.tools)d.add(QI(h.name));return Object.keys(JI).filter(f=>d.has(f))},[e.current,e.current.revision]);v.useEffect(()=>{if(l.length<=1){r(!1);return}let d=0;const f=()=>{const h=t.current;if(h&&!document.hidden){const p=h.getBoundingClientRect(),g=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(k=>k.getBoundingClientRect()),w=nQ(p,g,8);r(k=>k===w?k:w)}d=window.setTimeout(f,300)};return f(),()=>window.clearTimeout(d)},[l.length]);const u=v.useCallback(d=>{i(f=>{const h=new Set(f);return h.has(d)?h.delete(d):h.add(d),h})},[]);return{presentCats:l,hiddenCats:s,toggleCat:u,catBarRef:t,catBarOccluded:n}}function zne(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const r=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",s=()=>{var h;return(h=e.onState)==null?void 0:h.call(e,r())};function i(){var h,p;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(h=n.addEventListener)==null||h.call(n,"statechange",s)),(p=n.resume)==null||p.call(n).then(s,()=>{}),s()}catch{}}function l(h,p,g=p.figure){if(!n||n.state!=="running")return!1;const w=Tx(h,g),k=fK(p.level,w),x=n.currentTime;for(const b of w.notes){const j=n.createOscillator(),S=n.createGain();j.type=w.type??"sine",j.frequency.value=b.hz;const _=x+b.at,E=_+b.ms/1e3;S.gain.setValueAtTime(Qj,_),S.gain.exponentialRampToValueAtTime(k,_+pK),S.gain.exponentialRampToValueAtTime(Qj,E),j.connect(S).connect(n.destination),j.start(_),j.stop(E+.02)}return!0}async function u(h,p){if(!e.loadCustom)return"unavailable";let g;try{g=await e.loadCustom(h)}catch{return"unavailable"}if(!g)return"missing";if(g.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const k=new SpeechSynthesisUtterance(g.text),x=window.speechSynthesis.getVoices();k.voice=x.find(b=>b.voiceURI===g.voiceURI)??null,k.rate=g.rate,k.pitch=g.pitch,k.volume=mK(p.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(k),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let w;try{w=await n.decodeAudioData(g.bytes.slice(0))}catch{return"broken"}try{const k=n.createBufferSource(),x=n.createGain();return k.buffer=w,x.gain.setValueAtTime(gK(g.normalizationGain,p.level),n.currentTime),k.connect(x).connect(n.destination),k.start(n.currentTime),"played"}catch{return"unavailable"}}function d(h,p=!1){var k,x;if(!p&&!e.enabled())return!1;const g=NK((k=e.prefs)==null?void 0:k.call(e),h),w=((x=e.customSelection)==null?void 0:x.call(e)[h])??null;return w&&e.loadCustom?(u(w,g).then(b=>{var j;b==="played"||b==="locked"||((b==="missing"||b==="broken")&&((j=e.onCustomFailure)==null||j.call(e,h,w)),l(h,{...g,figure:vn},vn))}),!0):!n||n.state!=="running"?!1:l(h,g)}function f(h,p=Da){return u(h,{level:ri(p),figure:vn}),!0}return{unlock:i,play:d,previewCustom:f,state:r,get context(){return n}}}function Hne({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:r,fallbackCustomRef:s}){const[i,l]=v.useState("locked");return v.useEffect(()=>{const u=zne({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>r.current,loadCustom:lK,onCustomFailure:(p,g)=>s.current(p,g),onState:l});e.current=u,l(u.state());const d=["pointerdown","pointerup","keydown"],f=()=>{for(const p of d)window.removeEventListener(p,h,{capture:!0})},h=()=>{var p;u.unlock(),((p=u.context)==null?void 0:p.state)==="running"&&f()};for(const p of d)window.addEventListener(p,h,{capture:!0});return f},[]),{chimeState:i}}function Wne(){const[e,t]=v.useState(cee),[n,r]=v.useState(()=>l6(Qe(jN))),[s,i]=v.useState(()=>i6(Qe(SN))),[l,u]=v.useState(()=>c6(Qe(ER),n,aee)),[d,f]=v.useState(()=>new Set),[h,p]=v.useState(0);v.useEffect(()=>{Xe(nO,String(e))},[e]),v.useEffect(()=>{Xe(SN,s?"1":"0")},[s]),v.useEffect(()=>{Xe(jN,JSON.stringify(n))},[n]),v.useEffect(()=>{Xe(ER,l)},[l]);const g=v.useCallback(j=>{r(S=>S.some(_=>_.id===j.id)?S:[...S,j]),f(S=>{if(!S.has(j.id))return S;const _=new Set(S);return _.delete(j.id),_})},[]),w=v.useCallback((j,S)=>{const _=S.trim();!_||_.length>jl||r(E=>E.map(T=>T.id===j?{...T,name:_}:T))},[]),k=v.useCallback(j=>{r(S=>S.filter(_=>_.id!==j)),u(S=>u6(S,j)),f(S=>{if(!S.has(j))return S;const _=new Set(S);return _.delete(j),_})},[]),x=v.useCallback(j=>{const S=_N(j),_=d.has(S);j===l&&!_||(_&&f(E=>{const T=new Set(E);return T.delete(S),T}),u(j),p(E=>E+1))},[l,d]),b=v.useCallback((j,S)=>{const _=_N(j);f(E=>{if(E.has(_)===S)return E;const R=new Set(E);return S?R.add(_):R.delete(_),R})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:i,fmSource:l,customFmStations:n,unavailableFmStations:d,fmPlayRequest:h,addFmStation:g,renameFmStation:w,removeFmStation:k,pickFmSource:x,markFmStationAvailability:b}}function Vne(e){const[t,n]=v.useState(null),[r,s]=v.useState(!1),[i,l]=v.useState(null),u=v.useRef(0);v.useEffect(()=>{if(!e||!Ll())return;let k=!1;const x=u.current;return fetch("/api/desktop-update").then(b=>b.ok?b.json():null).then(b=>{if(k||u.current!==x)return;const j=IR(b);j&&n(j)}).catch(()=>{}),()=>{k=!0}},[e]);const d=Dee(t),f=v.useRef(!1),h=v.useRef(0),p=v.useRef(0);v.useEffect(()=>()=>window.clearTimeout(h.current),[]);const g=v.useCallback(async k=>{if(!Sr(f.current))return;const x=++p.current;window.clearTimeout(h.current),f.current=!0,s(!0),l(null);const b=j=>{x===p.current&&(window.clearTimeout(h.current),f.current=!1,s(!1),l({failure:j,version:k}))};try{const j=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:k})});if(!j.ok)return b(Uee(await j.json().catch(()=>null)))}catch{return b("unreachable")}x===p.current&&(h.current=window.setTimeout(()=>b("timeout"),rO))},[]),w=v.useCallback(k=>{if(Ll())try{const x=IR(JSON.parse(k));x&&(u.current++,n(x),x.status!=="ready"&&(p.current++,window.clearTimeout(h.current),f.current=!1,s(!1)))}catch{}},[]);return{desktopUpdateRestarting:r,desktopUpdateFailure:i,readyAppUpdate:d,askDesktopUpdateRestart:g,onDesktopUpdateEvent:w}}const _u="agent-dag.autoRestart",GR="agent-dag.bundleReloadedFor";function Gne({now:e,stateRef:t,version:n,notice:r,noticeOpen:s,upgradeFailure:i,paused:l}){const[u,d]=v.useState(()=>Qe(_u)!=="0"),f=v.useRef(!1),h=v.useCallback(()=>{const q=!u;f.current=!0,Zr(_u),d(q),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:q})}).then(P=>P.ok?P.json():null).then(P=>{var O;P!=null&&P.ok&&d(((O=P.prefs)==null?void 0:O.autoUpdate)!==!1)}).catch(()=>{})},[u]),[p,g]=v.useState(!1),[w,k]=v.useState("restart"),[x,b]=v.useState(null),j=v.useRef(!1),S=v.useRef(null),_=v.useRef(0),E=v.useRef(null),T=v.useCallback(async q=>{if(!Sr(j.current))return;const P=(q==null?void 0:q.upgrade)===!0,O=(q==null?void 0:q.whenIdle)===!0;j.current=!0,S.current=i;const V=++_.current,$=()=>{k(P?"npx":"restart"),g(!0)};O||$();try{window.sessionStorage.setItem("agent-dag.restartPending",(r==null?void 0:r.to)??"")}catch{}let M=!1;try{const L=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O?{upgrade:P,whenIdle:O}:{upgrade:P})});M=O&&L.status===409}catch{}if(M){j.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}O&&$(),window.setTimeout(()=>{if(_.current===V&&j.current){j.current=!1,g(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},P?18e4:3e4)},[r==null?void 0:r.to,i]);v.useEffect(()=>{const q=OR(t.current.agents.values())>0,P=yte({enabled:u,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:q,idleSince:E.current,now:e});E.current=P.idleSince,P.restart&&T({whenIdle:!0})},[u,r==null?void 0:r.kind,n==null?void 0:n.canRestart,s,e,T]);const R=OR(t.current.agents.values()),A=gte(R,l),U=aO({enabled:u,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:R>0,idleSince:E.current,now:e});v.useEffect(()=>{const q=n==null?void 0:n.running;let P=null,O=null;try{P=window.sessionStorage.getItem("agent-dag.restartPending"),O=window.sessionStorage.getItem(GR)}catch{return}const V=dte({bundle:"3.33.1",running:q,pending:P,lastTried:O});if(V==="reload"){try{window.sessionStorage.setItem(GR,q??"")}catch{return}window.location.reload();return}if(V!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}j.current=!1,g(!1),b(q??null);const $=window.setTimeout(()=>b(null),6e3);return()=>window.clearTimeout($)},[n==null?void 0:n.running]),v.useEffect(()=>{if(p&&fte({asked:S.current,reported:i})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}j.current=!1,g(!1)}},[p,i]);const I=v.useCallback(q=>{var P,O;if(!f.current){const V=Qe(_u)==="0";Zr(_u),V&&((P=q.prefs)==null?void 0:P.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((O=q.prefs)==null?void 0:O.autoUpdate)!==!1)}},[]);return{autoRestart:u,toggleAutoRestart:h,restarting:p,restartMode:w,restartedTo:x,askRestart:T,restartCopy:A,restartFuseMs:U,loadAutoRestartPrefs:I}}function Kne(){const[e,t]=v.useState([]),n=v.useRef(new Set),[r,s]=v.useState(null);v.useEffect(()=>{let u=!0,d=0;const f=()=>{fetch("/api/lan").then(h=>h.ok?h.json():null).then(h=>u?(h!=null&&h.ok&&t(Oj(Array.isArray(h.pending)?h.pending:[],h.aliases)),h):null).catch(()=>null).then(h=>{u&&(d=window.setTimeout(f,(h==null?void 0:h.enabled)===!0?Nx:l$))})};return f(),()=>{u=!1,window.clearTimeout(d)}},[]);const i=v.useCallback(async(u,d)=>{if(!r){s(u);try{const h=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:u,fp:d})})).json().catch(()=>null);h&&Array.isArray(h.pending)?t(Oj(h.pending,h.aliases)):t(p=>p.filter(g=>g.fp!==d))}catch{}finally{s(null)}}},[r]),l=v.useCallback(u=>{r||(n.current.add(u),t(d=>[...d]))},[r]);return{lanPending:e,lanDeferred:n,lanBusy:r,answerLanPair:i,deferLanPair:l}}const mO="agent-dag.sessionListOpen",gO="agent-dag.accountsPanelOpen";function Yne(){return Qe(mO)==="1"}function Xne(e){Xe(mO,e?"1":"0")}function Zne(){const e=Qe(gO);return e===null?!0:e==="1"}function Jne(){const[e,t]=v.useState(Yne);v.useEffect(()=>{Xne(e)},[e]);const n=v.useRef(!1),[r,s]=v.useState(()=>{const f=Zne();return f&&e?(n.current=!0,!1):f});v.useEffect(()=>{!r&&n.current||Xe(gO,r?"1":"0")},[r]),v.useEffect(()=>{!e&&n.current&&(n.current=!1,s(!0))},[e]);const i=v.useCallback(()=>{t(f=>(f||s(h=>(h&&(n.current=!0),!1)),!f))},[]),l=v.useCallback(()=>{n.current=!1,s(f=>(f||t(!1),!f))},[]),u=v.useCallback(()=>t(!1),[]),d=v.useCallback(()=>s(!1),[]);return{sessionListOpen:e,accountsPanelOpen:r,toggleSessionList:i,toggleAccountsPanel:l,closeSessionList:u,closeAccountsPanel:d}}const yO="agent-dag.detailOpen",wO="agent-dag.usagePanelOpen",vO="agent-dag.systemPanelOpen";function Qne(){return Qe(yO)==="1"}function ere(e){Xe(yO,e?"1":"0")}function tre(){const e=Qe(wO);return e===null?!0:e==="1"}function nre(e){Xe(wO,e?"1":"0")}function rre(){const e=Qe(vO);return e===null?!0:e==="1"}function sre(e){Xe(vO,e?"1":"0")}function are(){const[e,t]=v.useState(Qne);v.useEffect(()=>{ere(e)},[e]);const[n,r]=v.useState(tre);v.useEffect(()=>{nre(n)},[n]);const[s,i]=v.useState(rre);return v.useEffect(()=>{sre(s)},[s]),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:r,machinePanelOpen:s,setMachinePanelOpen:i}}const ore={permission:"your permission",asked:"your answer"},ire="No sessions are waiting for you.";function lre(e){if(e.length===0)return"";const[t,...n]=e,r=t.waiting.kind,s=n.every(l=>l.waiting.kind===r)?ore[r]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${s}.`;const i=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${i} are waiting for ${s}.`}function Iv(e,t,n=ire){return t!==""?t:e===""?"":n}function cre({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[r,s]=v.useState(""),i=lre(e);v.useEffect(()=>{s(g=>Iv(g,i))},[i]);const[l,u]=v.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";v.useEffect(()=>{u(g=>Iv(g,d,"Browser watch has no unread findings."))},[d]);const[f,h]=v.useState(""),p=Ane(n);return v.useEffect(()=>{h(g=>Iv(g,p,Mne))},[p]),{blockedSaid:r,watchSaid:l,setWatchSaid:u,incidentSaid:f}}function ure({waitingSessions:e,liveSince:t,focusSession:n}){const[r,s]=v.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[i,l]=v.useState(null),[u,d]=v.useState(!1),[f,h]=v.useState(!1),p=v.useRef(()=>{}),g=v.useRef(new Set),w=xn(e),k=v.useCallback(()=>{const T=!u;d(T),T&&(g.current=fu(w.current)),T&&typeof Notification<"u"&&Notification.permission==="default"&&p.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:T})}).then(R=>R.ok?R.json():null).then(R=>{var A;R!=null&&R.ok&&(d(((A=R.prefs)==null?void 0:A.notifications)===!0),h(R.notificationsVetoed===!0))}).catch(()=>{})},[u]),x=typeof Notification<"u";v.useEffect(()=>{if(!i)return;const R=setTimeout(()=>l(null),i==="blocked"?8e3:4e3);return()=>clearTimeout(R)},[i]);const b=v.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(T=>{const R=T;s(R),R==="granted"?l("on"):R==="denied"&&l("blocked")})},[]);p.current=b;const j=v.useRef(null),S=e.map(T=>Sd(T.id,T.waiting)).join("|");v.useEffect(()=>{Tq(j.current,r)&&(j.current=r,g.current=fu(e))},[r]);const _=v.useRef(!1);v.useEffect(()=>{Rq(_.current,t)&&(_.current=!0,g.current=fu(e))},[t]),v.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!Aq(j.current,t))return;const T=typeof document>"u"||!document.hidden,R=Eq(e,g.current,T,u);for(const A of R)try{const U=new Notification(A.title,{body:A.body,tag:A.key});U.onclick=()=>{window.focus(),n(A.sessionId),U.close()}}catch{}g.current=T?fu(e):Cq(e,R,g.current)},[S,t]);const E=v.useCallback(T=>{var R;d(((R=T.prefs)==null?void 0:R.notifications)===!0),h(T.notificationsVetoed===!0)},[]);return{notifyPermission:r,notifySaid:i,notifyOn:u,notifyVetoed:f,toggleNotify:k,notifySupported:x,askForNotifications:b,loadNotifyPrefs:E}}function dre({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:r,summaryFor:s,browserWatchOpen:i,keyHelpOpen:l,releaseNotes:u}){const d=xn(l),f=v.useRef(!1);return f.current=e!=null||t||n!=null||r||s!=null||i||l||u!=null,{keyHelpOpenRef:d,modalOpenRef:f}}function hre({stateRef:e,tourOpen:t,releaseNotes:n}){const[r,s]=v.useState(null),i=v.useCallback((T,R)=>s({agentId:T,toolId:R}),[]),[l,u]=v.useState(null),[d,f]=v.useState(null),h=v.useCallback(T=>f(T),[]),[p,g]=v.useState(!1),[w,k]=v.useState(!1),[x,b]=v.useState(!1),j=r?A6(e.current.agents,r.agentId,r.toolId):null,S=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:_,modalOpenRef:E}=dre({openedTool:j,usageHistoryOpen:w,contextFor:d,tourOpen:t,summaryFor:l,browserWatchOpen:x,keyHelpOpen:p,releaseNotes:n});return{setOpenedToolKey:s,openTool:i,openedTool:j,summaryFor:l,setSummaryFor:u,contextFor:d,setContextFor:f,openContext:h,contextAgent:S,keyHelpOpen:p,setKeyHelpOpen:g,usageHistoryOpen:w,setUsageHistoryOpen:k,browserWatchOpen:x,setBrowserWatchOpen:b,keyHelpOpenRef:_,modalOpenRef:E}}function fre({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:r,lastLayoutSigRef:s,forgetRemovals:i,clearSelection:l,rerender:u,modalOpenRef:d}){const[f,h]=v.useState(!1),p=v.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=l0(),t.current.clear(),n.current.clear(),r.current.clear(),s.current="",YI(),i(),l(),u()},[u,l,i]),g=xn(f),w=v.useCallback(k=>{const x=xte(k,{confirmOpen:g.current,modalOpen:d.current});x==="confirm"?h(!0):x==="clear"&&(h(!1),p())},[p]);return{clearConfirmOpen:f,setClearConfirmOpen:h,requestClear:w}}const KR="agent-dag.oldNameNoticeDismissed";function pre(e){const[t,n]=v.useState(()=>Qe(KR)??""),r=e!=null&&e.invokedAs&&e.invokedAs!==vt?e.invokedAs:null,s=r!=null&&t!==r,i=v.useCallback(()=>{r&&(n(r),Xe(KR,r))},[r]);return{oldName:r,oldNameOpen:s,dismissOldName:i}}function mre({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:r}){const[s,i]=v.useState(()=>XG(Qe)),l=xn(s),[u,d]=v.useState([]),f=v.useCallback(S=>{i(_=>{const E={..._,[S]:null};return l.current=E,E}),Zr(ml[S])},[]),h=v.useCallback((S,_)=>{const E=l.current[S];_&&E!==_||(f(S),t(T=>{const R={...T,[S]:{...T[S],figure:vn}};return n.current=R,R}),Xe(cd[S],vn))},[f]),p=xn(h);v.useEffect(()=>{let S=!0;return iK().then(_=>{if(!S)return;d(_);const E=new Set(_.map(T=>T.id));for(const T of Lu){const R=l.current[T];R&&!E.has(R)&&p.current(T,R)}},()=>{}),()=>{S=!1}},[]);const g=v.useCallback((S,_)=>{if(!u.some(T=>T.id===_))return;const E={...l.current,[S]:_};l.current=E,i(E),Xe(ml[S],_),r(S,!0)},[u,r]),w=v.useCallback(async S=>{var R;const _=Cx(u.length);if(_)throw new Error(_);const E=window.AudioContext??window.webkitAudioContext;if(!E)throw new Error("This browser cannot decode audio files.");const T=new E;try{const A=await nK(S,I=>T.decodeAudioData(I));await Zj(A);const U=$l(A);d(I=>[...I.filter(q=>q.id!==U.id),U])}finally{(R=T.close)==null||R.call(T)}},[u.length]),k=v.useCallback(async S=>{const _=Cx(u.length);if(_)throw new Error(_);const E=rK(S);await Zj(E);const T=$l(E);d(R=>[...R.filter(A=>A.id!==T.id),T])},[u.length]),x=v.useCallback(async(S,_)=>{const E=u.find(R=>R.id===S),T=_.trim().slice(0,80);!E||!T||T===E.name||(await cK(S,T),d(R=>R.map(A=>A.id===S?{...A,name:T}:A)))},[u]),b=v.useCallback(async S=>{await uK(S),d(R=>R.filter(A=>A.id!==S));const _=l.current,E=ZG(_,S);l.current=E,i(E);const T=Lu.filter(R=>_[R]===S);for(const R of T)Zr(ml[R]),Xe(cd[R],vn);T.length>0&&t(R=>{const A={...R};for(const U of T)A[U]={...A[U],figure:vn};return n.current=A,A})},[]),j=v.useCallback(S=>{var T,R;const _=Lu.find(A=>l.current[A]===S),E=_?n.current[_].level:Da;(T=e.current)==null||T.unlock(),(R=e.current)==null||R.previewCustom(S,E)},[]);return{customSelections:s,customSelectionsRef:l,customAssets:u,clearCustomOnly:f,fallbackCustomRef:p,selectCustomTone:g,importNotificationAudio:w,createNotificationVoice:k,renameCustomAsset:x,deleteCustomAsset:b,previewCustomAsset:j}}function gre(e){const[t,n]=v.useState(()=>kK(Qe)),r=xn(t),s=v.useRef(null),i=v.useCallback((u,d=!1)=>{var f,h;if((f=e.current)==null||f.unlock(),s.current!==null&&clearTimeout(s.current),s.current=null,!d){(h=e.current)==null||h.play(u,!0);return}s.current=setTimeout(()=>{var p;s.current=null,(p=e.current)==null||p.play(u,!0)},yK)},[]),l=v.useCallback((u,d)=>{n(f=>{const h={level:ri(d.level??f[u].level),figure:$$(u,d.figure??f[u].figure)};return Xe(L$[u],String(h.level)),Xe(cd[u],h.figure),{...f,[u]:h}}),i(u,!0)},[i]);return v.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:r,previewTone:i,changeTone:l}}const yre=15e3;function wre(e){return e.visibilityState==="visible"&&e.hasFocus()}function vre(e,t){return t||e===!0}function xre(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function bre(){v.useEffect(()=>{const e=xre();let t=null;const n=l=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:l}),keepalive:!0}).catch(()=>{})},r=()=>{const l=wre(document);vre(t,l)&&n(l),t=l},s=()=>{t&&n(!1),t=!1};r();const i=window.setInterval(r,yre);return window.addEventListener("focus",r),window.addEventListener("blur",r),document.addEventListener("visibilitychange",r),window.addEventListener("pagehide",s),()=>{window.clearInterval(i),window.removeEventListener("focus",r),window.removeEventListener("blur",r),document.removeEventListener("visibilitychange",r),window.removeEventListener("pagehide",s),s()}},[])}function kre({loadAutoRestartPrefs:e,loadNotifyPrefs:t}){v.useEffect(()=>{let n=!0;return fetch("/api/prefs").then(r=>r.ok?r.json():null).then(r=>{!n||!(r!=null&&r.ok)||(e(r),t(r))}).catch(()=>{}),()=>{n=!1}},[])}const Ov="agent-dag.versionNoticeDismissed",Nre=15*6e4;function jre(e){const[t,n]=v.useState(null),[r,s]=v.useState(()=>Qe(Ov)??""),i=v.useRef(0),[l,u]=v.useState(!1),d=v.useCallback((x=!1)=>(x&&(i.current=Date.now(),u(!0)),fetch(x?"/api/version?refresh=1":"/api/version").then(b=>b.ok?b.json():null).then(b=>{b&&n(b)}).catch(()=>{}).finally(()=>{x&&u(!1)})),[]),f=v.useCallback(()=>{d(Date.now()-i.current>=Nre)},[d]);v.useEffect(()=>{d();const x=window.setInterval(f,5*6e4),b=()=>{document.visibilityState==="visible"&&f()};return document.addEventListener("visibilitychange",b),()=>{window.clearInterval(x),document.removeEventListener("visibilitychange",b)}},[d,f]),v.useEffect(()=>{e&&d()},[e,d]);const h=(t==null?void 0:t.notice)??null,p=sO(h),g=Kee(h,r),w=v.useCallback(()=>{s(""),Xe(Ov,"")},[]),k=v.useCallback(()=>{h&&(s(p),Xe(Ov,p))},[h,p]);return{version:t,notice:h,noticeOpen:g,showNotice:w,dismissNotice:k,versionChecking:l,loadVersion:d}}function Sre({version:e,readyAppUpdate:t}){const[n,r]=v.useState(!1),s=v.useRef(null),[i,l]=v.useState(null),u=i&&t?t.version:null,d=v.useRef(null);v.useEffect(()=>{!u||d.current===u||(d.current=u,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:u})}).catch(()=>{}))},[u]);const f=v.useRef(!1);v.useEffect(()=>{if(f.current)return;const b=fl(),j=Fte(b),S=Wte({stored:j,running:(e==null?void 0:e.running)??null,notes:DR,remembers:qte(b)});if(S.reason==="no-version")return;f.current=!0,S.record&&Bte(b,S.record);let _=!0;return(async()=>{var U;let T=Ute(b);if(Ll())try{const I=await fetch("/api/prefs");if(!I.ok)throw new Error("desktop tour preferences unavailable");const q=await I.json();if(!(q!=null&&q.ok))throw new Error("desktop tour preferences unavailable");const P=((U=q.prefs)==null?void 0:U.tourSeen)===!0;T&&!P&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),T=T||P}catch{T=!0}if(!_)return;const R=Hte({tourSeen:T,decision:S}),A=S.show.length?{entries:S.show,since:j,firstRun:!1}:null;R.tour&&r(!0),R.notes==="now"?l(A):R.notes==="after"&&(s.current=A)})(),()=>{_=!1}},[e==null?void 0:e.running]);const h=(e==null?void 0:e.running)??"3.33.1",p=v.useMemo(()=>oO(DR,null,h),[h]),g=v.useCallback(()=>{l({entries:p,since:null,firstRun:!1})},[p]),w=v.useCallback(()=>r(!0),[]),k=v.useCallback(()=>l(null),[]),x=v.useCallback(()=>{r(!1),zte(fl()),Ll()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const b=s.current;s.current=null,b&&l(b)},[]);return{tourOpen:n,openTour:w,closeTour:x,releaseNotes:i,closeReleaseNotes:k,chipVersion:h,openReleaseNotes:g}}function _re(){const[e,t]=v.useState(null),[n,r]=v.useState(!1),s=v.useRef(null);return v.useEffect(()=>{let i=!0,l=!1,u=null,d=null,f="";const h=x=>{i&&(r(!0),x!==f&&t(null))},p=()=>{if(l)return;l=!0,u=Date.now();const x=MR();d=x,fetch(`/api/ccusage?since=${x}`).then(b=>b.ok?b.json():null).then(b=>{if(i){if(!(b!=null&&b.ok)){h(x);return}f=x,t(Lee(b)),r(!1)}}).catch(()=>h(x)).finally(()=>{l=!1})},g=()=>{const x=s.current;Oee({shown:!!x&&x.getClientRects().length>0,tabVisible:document.visibilityState==="visible",lastSince:d,since:MR(),lastReadAt:u,now:Date.now()})&&p()};g();const w=window.setInterval(g,Iee);document.addEventListener("visibilitychange",g);let k=null;return s.current&&typeof ResizeObserver<"u"&&(k=new ResizeObserver(g),k.observe(s.current)),()=>{i=!1,window.clearInterval(w),document.removeEventListener("visibilitychange",g),k==null||k.disconnect()}},[]),{monthlyUsage:e,monthlyUsageUnavailable:n,monthUsageRef:s}}function Ere(e){const[t,n]=v.useState(null);v.useEffect(()=>{const u=Qe("agent-dag.sound");n(u===null?!0:u==="on")},[]);const r=v.useCallback(()=>{n(u=>{var f;const d=u!==!0;return Xe("agent-dag.sound",d?"on":"off"),d&&((f=e.current)==null||f.unlock()),d})},[]),s=v.useCallback(u=>{r()},[r]),i=xn(s),l=xn(t);return{soundOn:t,toggleSound:r,activateSoundRef:i,soundOnRef:l}}function Cre(){const[e,t]=v.useState(!1),n=v.useRef(null),[r,s]=v.useState(!1),i=v.useRef(null);return v.useEffect(()=>{e&&s(!1)},[e]),{soundMenuOpen:e,setSoundMenuOpen:t,soundButtonRef:n,appearanceMenuOpen:r,setAppearanceMenuOpen:s,appearanceButtonRef:i}}const Tre="agent-dag.autoFitDisabled";function Rre(e){const t=v.useRef(!1),[n,r]=v.useState(!1);v.useEffect(()=>{Zr(Tre)},[]);const s=v.useCallback(()=>{t.current||(t.current=!0,r(!0))},[]),i=v.useCallback(()=>{t.current=!1,r(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:i}}function Are(){return a.jsx(a0,{children:a.jsx(Mre,{})})}function Mre(){const e=oi(),t=v.useState(l0)[0],n=v.useRef(t),[,r]=v.useState(0),s=v.useCallback(()=>r(Fr=>Fr+1),[]),{detailOpen:i,setDetailOpen:l,usagePanelOpen:u,setUsagePanelOpen:d,machinePanelOpen:f,setMachinePanelOpen:h}=are(),{selectedIds:p,primarySelectedId:g,selectAgent:w,clearSelection:k,pruneSelectionToBoard:x}=qK(n,l),{sessionListOpen:b,accountsPanelOpen:j,toggleSessionList:S,toggleAccountsPanel:_,closeSessionList:E,closeAccountsPanel:T}=Jne(),R=_re(),A=Mu(j,200),U=Mu(u,130),I=Mu(f,130),q=v.useRef(null),P=Ere(q),{activateSoundRef:O,soundOnRef:V}=P,$=gre(q),{setTonePrefs:M,tonePrefsRef:L,previewTone:Y}=$,K=mre({chimesRef:q,setTonePrefs:M,tonePrefsRef:L,previewTone:Y}),{customSelectionsRef:D,fallbackCustomRef:z}=K,F=Cre(),{setSoundMenuOpen:H}=F,{chimeState:J}=Hne({chimesRef:q,soundOnRef:V,tonePrefsRef:L,customSelectionsRef:D,fallbackCustomRef:z}),W=fne(n),{pauseGate:G,paused:X,togglePause:Z}=W,ee=v.useRef(()=>{}),{live:re,tabCapped:ce,everConnected:ie,liveSince:fe}=RK({stateRef:n,rerender:s,pauseGate:G,chimesRef:q,desktopUpdateRef:ee}),de=jre(re),{version:we,notice:xe,noticeOpen:$e,loadVersion:be}=de,he=Vne(re),{readyAppUpdate:se,onDesktopUpdateEvent:ke}=he;ee.current=ke,bre();const Ce=Sre({version:we,readyAppUpdate:se}),{tourOpen:Oe,openTour:Le,releaseNotes:Pe}=Ce,{workspace:qe,providers:Ue,providersRef:et}=mne(re),ze=pre(we),at=$ne({version:we,loadVersion:be}),{upgradeFailure:gt}=at,Ie=hre({stateRef:n,tourOpen:Oe,releaseNotes:Pe}),{openTool:ot,setSummaryFor:Je,setContextFor:it,openContext:Ft,setKeyHelpOpen:kt,setUsageHistoryOpen:Nt,setBrowserWatchOpen:qt,keyHelpOpenRef:kn,modalOpenRef:Gt}=Ie,Bt=One(),{watchOn:dn,watchUnseen:Kt}=Bt,as=Kne(),[$r,os]=v.useState(0),{presentCats:ur,hiddenCats:Bn,toggleCat:is,catBarRef:Nn,catBarOccluded:dr}=Une(n),hn=v.useRef(null),[ls,jn]=v.useState(0),yt=BK({stateRef:n,rerender:s,pruneSelectionToBoard:x,setContextFor:it,setSummaryFor:Je}),Un=vne(Ue.claude||Ue.codex),ge=Rne(Un,yt),He=Gne({now:yt,stateRef:n,version:we,notice:xe,noticeOpen:$e,upgradeFailure:gt,paused:W.paused}),{askRestart:Ze,loadAutoRestartPrefs:fn}=He,Ut=Bne(),{setTheme:hr,palette:Xs}=Ut,cs=Wne(),zn=DJ(),{applyViewport:Va,moveCamera:Ga,fitLeft:fr,cameraEpochRef:Ka,lastFitTimeRef:Ya}=zn,Ye=XJ(fr),{pinnedRef:us,positionsRef:pr,lastLayoutSigRef:Xa,handleRelayout:ds}=Ye,Zs=v.useRef(null),Js=v.useRef(()=>{}),hs=fe!==null,Yt=v.useRef(0),fs=v.useCallback(()=>{Yt.current=Date.now()},[]),{canvasRef:jt,canvasSize:oh,paneSizeRef:ih}=RQ(),Zl=Rre(fr),{autoFitDisabledRef:Qs,disableAutoFit:ps}=Zl,Ir=v.useRef(!1),{measuredRef:Sn,measuredVersionRef:lh,sizeVersion:ch,domSizeVersion:gi}=AQ(Ir),{removedNodes:yi,removedAgentIds:mr,removeNode:ea,removeSelectedNode:Jl,removalNotice:Za,bringBack:We,bringBackAll:Ql,forgetRemovals:ec}=bQ({stateRef:n,pinnedRef:us,positionsRef:pr,canvasRef:jt,clearSelection:k,primarySelectedId:g}),ta=gQ({stateRef:n,now:yt,removedAgentIds:mr,sizeVersion:ch,domSizeVersion:gi});ZJ(ta,Ye),xQ({layoutSig:ta,rf:e,stateRef:n,measuredRef:Sn,pinnedRef:us,positionsRef:pr,paneSizeRef:ih,lastInteractRef:Yt,autoFitDisabledRef:Qs,lastFitTimeRef:Ya,fitLeft:fr});const wi=MQ(),{bubbling:tc,endBubble:nc,onBubble:vi}=IG(),[ms,gr]=v.useState(!1),Hn=MG(),{beginTrashDrag:yr,trackTrashDrag:na,endTrashDrag:ra}=Hn,Wn=zG({stateRef:n,measuredRef:Sn,measuredVersionRef:lh,canvasRef:jt}),{lodRef:uh,applyZoom:rc}=Wn,gs=CQ({applyViewport:Va,lastFitTimeRef:Ya,cameraEpochRef:Ka,disableAutoFit:ps,markInteract:fs,canvasRef:jt,applyZoom:rc}),sa=g?n.current.agents.get(g):null,xi=i&&sa!=null,{railInsetRef:aa,availableWidth:bi,availableHeight:sc}=PJ({canvasRef:jt,canvasSize:oh,machinePhase:I,usagePhase:U,usagePanelOpen:u,detailShown:xi}),ys=yQ({stateRef:n,now:yt,availableWidth:bi,availableHeight:sc,layout:Ye,measuredRef:Sn,onBubble:vi,settled:wi,dragging:ms,layoutSig:ta,selectedIds:p,openContext:Ft,historyReplayed:hs,removedNodes:yi,removedAgentIds:mr,dragTick:$r,dragPatchRef:hn,dragMoveTick:ls}),{nodes:Or,edges:ws}=ys,vs=xn(g);JJ({nodes:Or,edges:ws,settled:wi,dragging:ms,availableWidth:bi,availableHeight:sc,layout:Ye,camera:zn,rf:e,measuredRef:Sn,stateRef:n,lastFocusRef:Zs,primarySelectedIdRef:vs,focusAgentRef:Js,autoFitDisabledRef:Qs});const ac=fre({stateRef:n,pinnedRef:us,measuredRef:Sn,positionsRef:pr,lastLayoutSigRef:Xa,forgetRemovals:ec,clearSelection:k,rerender:s,modalOpenRef:Gt}),{requestClear:oc}=ac,ki=OQ({nodes:Or,stateRef:n,pinnedRef:us,positionsRef:pr,draggingRef:Ir,dragPatchRef:hn,setDragging:gr,setDragMoveTick:jn,setDragTick:os,endBubble:nc,markInteract:fs,disableAutoFit:ps,beginTrashDrag:yr,trackTrashDrag:na,endTrashDrag:ra,removeNode:ea}),Ja=v.useCallback(()=>fr(500),[fr]),oa=xn(Or),{focusAgent:ia,stepAgent:wr,focusSession:Lr}=qJ({canvasRef:jt,stateRef:n,measuredRef:Sn,nodesRef:oa,railInsetRef:aa,moveCamera:Ga,disableAutoFit:ps,lastFocusRef:Zs,focusAgentRef:Js,selectAgent:w,primarySelectedIdRef:vs}),Qa=TQ({clearSelection:k,selectAgent:w,detailOpen:i,setDetailOpen:l,detailShown:xi,focusAgent:ia,draggingRef:Ir,lodRef:uh}),ic=BJ({nodesRef:oa,stateRef:n,canvasRef:jt,railInsetRef:aa}),eo=xn(Jl),la=v.useRef(null),lc=v.useCallback(Fr=>{mr.has(Fr)&&We([Fr]),Lr(Fr)},[mr,We,Lr]),Xt=$Q();IQ({pointerFocusRef:Xt,nodesRef:oa,stateRef:n,primarySelectedIdRef:vs,providersRef:et,soundOnRef:V,keyHelpOpenRef:kn,modalOpenRef:Gt,waitingCursorRef:la,removeSelectedRef:eo,activateSoundRef:O,clearSelection:k,selectAgent:w,focusAgent:ia,stepAgent:wr,focusSession:Lr,requestClear:oc,handleRelayout:ds,handleFit:Ja,togglePause:Z,toggleSessionList:S,toggleAccountsPanel:_,setDetailOpen:l,setUsageHistoryOpen:Nt,setUsagePanelOpen:d,setMachinePanelOpen:h,setBrowserWatchOpen:qt,setSoundMenuOpen:H,setKeyHelpOpen:kt,setTheme:hr});const Pr=n.current.agents.size,Dr=v.useMemo(()=>ex(n.current.agents.values()),[n.current,n.current.revision]);kQ({stateRef:n,waitingSessions:Dr,removedAgentIds:mr,removedNodes:yi,bringBack:We}),SQ({stateRef:n,waitingSessions:Dr,live:re});const xs=cre({waitingSessions:Dr,watchUnseen:Kt,incidents:ge}),Ni=ure({waitingSessions:Dr,liveSince:fe,focusSession:Lr}),{loadNotifyPrefs:ji}=Ni;return kre({loadAutoRestartPrefs:fn,loadNotifyPrefs:ji}),a.jsxs("div",{className:"app",children:[a.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),a.jsxs("header",{className:"topbar",children:[a.jsx(ete,{versionCheck:de,welcome:Ce,desktopUpdate:he,pause:W,monthly:R,announcements:xs,notify:Ni,waitingSessions:Dr,waitingCursorRef:la,focusSession:Lr,live:re,now:yt,incidents:ge}),sa&&a.jsx(tte,{selected:sa,now:yt,selectedIds:p,focusAgent:ia,clearSelection:k}),a.jsxs("div",{className:"actions",children:[a.jsx(Ree,{sessionListOpen:b,toggleSessionList:S,usagePanelOpen:u,setUsagePanelOpen:d,setUsageHistoryOpen:Nt}),a.jsx(Aee,{providers:Ue,accountsPanelOpen:j,toggleAccountsPanel:_,machinePanelOpen:f,setMachinePanelOpen:h,watchOn:dn,watchUnseen:Kt,setBrowserWatchOpen:qt}),a.jsx(Mee,{providers:Ue,sound:P,tones:$,customTones:K,notify:Ni,chimeState:J,menus:F,appearance:Ut,fm:cs})]})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Za?`${Za.label} removed from the board.`:""}),a.jsx(vte,{restart:He,versionCheck:de,upgrade:at,oldNameNotice:ze,everConnected:ie,live:re,paused:X}),Au(A)&&Ue.claude&&a.jsx(SG,{leaving:A==="leaving",onClose:T}),b&&a.jsx(hz,{state:n.current,now:yt,selectedIds:p,onSelect:lc,onClose:E,removedIds:mr,onBringBackAll:Ql}),a.jsxs(ote,{canvasRef:jt,bubbling:tc,dragging:ms,trash:Hn,zoom:Wn,viewport:gs,stateRef:n,peek:ic,children:[Pr===0&&(!re&&ce?a.jsx(zQ,{}):a.jsx(HQ,{live:re,everConnected:ie,providers:Ue,workspace:qe,onTour:Le})),(ur.length>1||Bn.size>0)&&a.jsx(nte,{catBarRef:Nn,catBarOccluded:dr,presentCats:ur,hiddenCats:Bn,toggleCat:is}),a.jsx(sz,{graph:ys,layout:Ye,viewport:gs,clicks:Qa,drag:ki,appearance:Ut,fm:cs,autoFit:Zl,pause:W,stateRef:n,measuredRef:Sn,hiddenCats:Bn,now:yt,openTool:ot,focusAgent:ia,requestClear:oc,setKeyHelpOpen:kt})]}),Au(U)&&a.jsx(sH,{state:n.current,now:yt,providers:Ue,incidents:ge,liveSince:fe,leaving:U==="leaving",onClose:()=>d(!1)}),Au(I)&&a.jsx(UH,{usageOpen:u,leaving:I==="leaving",onClose:()=>h(!1)}),i&&sa?a.jsx(ree,{selected:sa,now:yt,openTool:ot,setSummaryFor:Je,setDetailOpen:l,stateRef:n,removeSelectedNode:Jl}):null,a.jsx(une,{dialogs:Ie,welcome:Ce,desktopUpdate:he,versionCheck:de,restart:He,lanPairs:as,clearFlow:ac,watchBadge:Bt,announcements:xs,appearance:Ut,providers:Ue,stateRef:n,agentCount:Pr})]})}try{uB(window.localStorage)}catch{}const $re=QL.createRoot(document.getElementById("root"));$re.render(a.jsx(Are,{}));export{DQ as a,st as b,Ws as c,id as d,Ore as e,Be as f,Jr as g,Ire as h,Ml as i,a as j,ns as k,eK as l,Na as m,Ba as n,hx as p,v as r,Sr as s,mt as u};
@@ -62,7 +62,7 @@
62
62
  stored === "light" || (stored !== "dark" && light) ? "light" : "dark");
63
63
  })();
64
64
  </script>
65
- <script type="module" crossorigin src="/assets/index-OLDoLpOW.js"></script>
65
+ <script type="module" crossorigin src="/assets/index-D7ddxIpC.js"></script>
66
66
  <link rel="stylesheet" crossorigin href="/assets/index-BIANlQ9A.css">
67
67
  </head>
68
68
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccdeck",
3
- "version": "3.33.0",
3
+ "version": "3.33.1",
4
4
  "description": "Live dashboard for Claude Code and Codex — which agent is waiting on you, tool calls, token spend and every Claude Code subagent on one calm canvas. Run it with npx ccdeck.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -57,7 +57,8 @@
57
57
  "3.29.4",
58
58
  "3.29.6",
59
59
  "3.29.7",
60
- "3.29.9"
60
+ "3.29.9",
61
+ "3.33.1"
61
62
  ],
62
63
  "3.33.0": [
63
64
  {