ccdeck 3.30.0 → 3.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/web/assets/{BrowserWatchModal-DP3YMtEi.js → BrowserWatchModal-h_p7Ym4c.js} +1 -1
- package/dist/web/assets/{UsageHistoryModal-CcdPVXAw.js → UsageHistoryModal-F84RRMyC.js} +1 -1
- package/dist/web/assets/index-DKn7nc15.css +1 -0
- package/dist/web/assets/index-DiTUBs9l.js +299 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/release-notes.json +24 -0
- package/src/server/claude-dir.mjs +5 -1
- package/src/server/deck-home.mjs +1 -1
- package/src/server/deck-prefs.mjs +7 -0
- package/src/server/index.mjs +4 -2
- package/src/server/pinned-build.mjs +2 -0
- package/src/server/prefs-give-back.mjs +206 -0
- package/src/server/prefs-refusal.mjs +12 -3
- package/src/server/prefs-routes.mjs +24 -1
- package/src/server/prefs-state.mjs +21 -2
- package/src/server/provider-status.mjs +307 -0
- package/src/server/usage-routes.mjs +17 -2
- package/dist/web/assets/index-3vS6A0vt.css +0 -1
- package/dist/web/assets/index-BVTWHDta.js +0 -298
package/README.md
CHANGED
|
@@ -191,7 +191,7 @@ Quota is the one thing that is not just reading. It needs a live token, so when
|
|
|
191
191
|
|
|
192
192
|
It never steers an agent or edits your code, but it is not read-only either — besides the hook entry and its own event log, it manages the two tools it leans on, and it refreshes the Codex token it reads quota with, rewriting `~/.codex/auth.json` the way `codex` itself does. It also reads your browser's history, because Browser Watch is on unless you switch it off; that is its own section below, because it is the one thing here that is about you rather than about an agent.
|
|
193
193
|
|
|
194
|
-
What does go out is short and ordinary: a ~20-byte version check against the npm registry (plus one small request to confirm a version it has not seen before), installs and daily version checks for the two tools the deck manages (claude-swap from PyPI, ccusage from npm), on an Apple Silicon Mac whose sensors stay silent one release lookup and one binary download from GitHub for `macmon`, and, while the page is open, quota reads to Anthropic and OpenAI signed with your own credentials — that is where those numbers live. The [desktop app](#desktop-app) also asks this repository's GitHub releases for its own updates. With **Local network** on, which it is unless you switch it off, the deck also announces itself to other decks on your local network over UDP (port 45317) and pairs with the ones that answer — see [Local network](#local-network). `AGENTS_DECK_NO_INSTALL=1` turns off everything but the quota reads; `AGENTS_DECK_NO_DOWNLOAD=1` is the narrower version — no `uv` binary is fetched, the managed installs stay.
|
|
194
|
+
What does go out is short and ordinary: a ~20-byte version check against the npm registry (plus one small request to confirm a version it has not seen before), installs and daily version checks for the two tools the deck manages (claude-swap from PyPI, ccusage from npm), on an Apple Silicon Mac whose sensors stay silent one release lookup and one binary download from GitHub for `macmon`, and, while the page is open, quota reads to Anthropic and OpenAI signed with your own credentials — that is where those numbers live. While the page is open, and while the desktop app has a session running or waiting, it also reads Anthropic's and OpenAI's public status pages (`status.claude.com`, `status.openai.com`), unsigned, about every three minutes, and once a minute at most while a page is not answering, so an outage on their side shows as a chip in the topbar instead of looking like a fault on yours. The [desktop app](#desktop-app) also asks this repository's GitHub releases for its own updates. With **Local network** on, which it is unless you switch it off, the deck also announces itself to other decks on your local network over UDP (port 45317) and pairs with the ones that answer — see [Local network](#local-network). `AGENTS_DECK_NO_INSTALL=1` turns off everything but the quota reads; `AGENTS_DECK_NO_DOWNLOAD=1` is the narrower version — no `uv` binary is fetched, the managed installs stay.
|
|
195
195
|
|
|
196
196
|
## Browser Watch
|
|
197
197
|
|
|
@@ -376,9 +376,10 @@ Environment:
|
|
|
376
376
|
|---|---|
|
|
377
377
|
| `AGENT_DAG_PORT` | Default port, same as `-p` |
|
|
378
378
|
| `CODEX_HOME` | Override `~/.codex` |
|
|
379
|
-
| `AGENTS_DECK_NO_INSTALL=1` | Never install or update claude-swap / ccusage,
|
|
379
|
+
| `AGENTS_DECK_NO_INSTALL=1` | Never install or update claude-swap / ccusage, never ask npm about releases, and never read the status pages |
|
|
380
380
|
| `AGENTS_DECK_NO_DOWNLOAD=1` | Never download the `uv` binary, but keep the managed installs |
|
|
381
381
|
| `AGENTS_DECK_NO_UPDATE_CHECK=1` | Don't ask npm about releases, but keep everything else |
|
|
382
|
+
| `AGENTS_DECK_NO_STATUS=1` | Don't read Anthropic's and OpenAI's status pages, so no incident chip appears |
|
|
382
383
|
| `AGENTS_DECK_NO_FRESHEN=1` | Never nudge claude-swap to collect usage early |
|
|
383
384
|
| `AGENTS_DECK_NO_NOTIFY=1` | Never raise a desktop notification: not when a session blocks and no page is open, and not when Browser Watch finds something |
|
|
384
385
|
| `AGENTS_DECK_NO_LAN=1` | Keep **Local network** off, whatever its switch in the panel says |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r as h,i as Q,k as _,s as V,u as Y,e as z}from"./index-BVTWHDta.js";function X({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}`))})]})}function Z(s){const t=o=>new Date(o).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 ee(s){return new Date(s).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function K(s){const t=Math.round((s.endMs-s.startMs)/6e4);return t<1?"":`${t} min`}function se({snap:s,dismiss:t}){const[o,r]=h.useState(null),d=h.useMemo(()=>{const i=[];for(const n of s.episodes){const a=ee(n.startMs),l=i[i.length-1];l&&l.label===a?l.episodes.push(n):i.push({label:a,episodes:[n]})}return i},[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:d.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."})]}):d.map(i=>e.jsxs("div",{className:"bw-day",children:[e.jsx("h4",{className:"bw-sec-head",children:i.label}),i.episodes.map(n=>{const a=`${n.host}-${n.startMs}`,l=o===a;return e.jsxs("div",{className:`bw-ep${l?" open":""}`,children:[e.jsxs("div",{className:"bw-ep-row",children:[e.jsxs("button",{className:"bw-ep-head",onClick:()=>r(l?null:a),"aria-expanded":l,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:l?"▾":"▸"}),e.jsx("span",{className:"bw-ep-host",children:n.host}),e.jsxs("span",{className:"bw-ep-meta",children:[Z(n),K(n)&&e.jsxs(e.Fragment,{children:[" · ",K(n)]})]}),e.jsxs("span",{className:"bw-ep-count",children:[n.count," ",n.count===1?"page":"pages"]})]}),e.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>void t(n),"aria-label":`Dismiss ${n.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),l&&e.jsx("ul",{className:"bw-urls",children:n.urls.map((u,c)=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-url-time",children:new Date(u.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),e.jsx("span",{className:"bw-url",children:u.url})]},`${u.url}-${u.timeMs}-${c}`))})]},a)})]},i.label))})]})}function te(s){const t=/^#?([0-9a-f]{6})$/i.exec((s??"").trim());if(!t)return!1;const o=parseInt(t[1],16),r=[o>>16&255,o>>8&255,o&255].map(d=>{const i=d/255;return i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4)});return .2126*r[0]+.7152*r[1]+.0722*r[2]>.5}const U=1e4,ne=12e3;function ae({browsers:s,findings:t,watching:o,palette:r}){const d=h.useRef(null),i=h.useRef(null);return i.current={browsers:s,findings:t,watching:o},h.useEffect(()=>{var R;const n=d.current;if(!n)return;const a=n.getContext("2d");if(!a)return;const l=((R=window.matchMedia)==null?void 0:R.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let u=0,c=!1;const N=()=>{var F;if(c)return;const P=i.current;if(!P)return;const{browsers:k,findings:m,watching:$}=P,C=r["--accent"]||"#7dd3fc",b=r["--line"]||"#1f2229",g=r["--text-dim"]||"#6e727c",M=te(r["--bg"]),f=M?42:26,y=M?.85:.65,W=Date.now(),S=Math.min(window.devicePixelRatio||1,2),p=n.clientWidth,A=n.clientHeight;(n.width!==p*S||n.height!==A*S)&&(n.width=p*S,n.height=A*S),a.setTransform(S,0,0,S,0,0),a.clearRect(0,0,p,A);const x=p/2,j=A/2,v=Math.min(p,A)/2-6;a.strokeStyle=b,a.lineWidth=1,a.globalAlpha=M?1:.9;for(const w of[.4,.7,1])a.beginPath(),a.arc(x,j,v*w,0,Math.PI*2),a.stroke();a.beginPath(),a.moveTo(x-v,j),a.lineTo(x+v,j),a.moveTo(x,j-v),a.lineTo(x,j+v),a.stroke(),a.globalAlpha=1;const T=($&&!l?W%U/U:0)*Math.PI*2-Math.PI/2;if($){const w=(F=a.createConicGradient)==null?void 0:F.call(a,T-.85,x,j);w&&(w.addColorStop(0,"transparent"),w.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${C} ${f}%, transparent)`),w.addColorStop(1,"transparent"),a.fillStyle=w,a.beginPath(),a.moveTo(x,j),a.arc(x,j,v,T-.85,T),a.closePath(),a.fill()),a.strokeStyle=C,a.globalAlpha=y,a.beginPath(),a.moveTo(x,j),a.lineTo(x+Math.cos(T)*v,j+Math.sin(T)*v),a.stroke(),a.globalAlpha=1}k.forEach((w,I)=>{const B=I/Math.max(k.length,1)*Math.PI*2-Math.PI/2,E=w.lastReadMs===null?1:Math.min(1,(W-w.lastReadMs)/12e4),D=v*(.42+E*.5),O=x+Math.cos(B)*D,L=j+Math.sin(B)*D,J=Math.abs((T-B+Math.PI*3)%(Math.PI*2)-Math.PI),q=$?Math.max(0,1-J/.55):0;a.beginPath(),a.arc(O,L,3+q*1.6,0,Math.PI*2),a.fillStyle=w.running?C:g,a.globalAlpha=w.running?.55+q*.45:.35,a.fill(),a.globalAlpha=1});for(const w of m){const I=(W-w.atMs)/ne;if(I<0||I>1)continue;const E=Math.max(0,k.findIndex(L=>L.key===w.browser))/Math.max(k.length,1)*Math.PI*2-Math.PI/2,D=x+Math.cos(E)*v*.6,O=j+Math.sin(E)*v*.6;a.beginPath(),a.arc(D,O,4+I*22,0,Math.PI*2),a.strokeStyle=C,a.globalAlpha=(1-I)*.8,a.lineWidth=1.5,a.stroke(),a.globalAlpha=1}u=requestAnimationFrame(N)};return N(),()=>{c=!0,cancelAnimationFrame(u)}},[r]),e.jsx("canvas",{ref:d,className:"bw-radar",role:"img","aria-label":o?`Watching ${s.length} browser${s.length===1?"":"s"}`:"Not watching"})}function re(s,t,o){if(s===null)return null;const r=s+t-o;return r>0?r:null}function ie(s){const t=Math.ceil(s/1e3),o=Math.floor(t/60),r=t%60;return o>0?`${o}m ${r}s`:`${r}s`}function H(s){return(s??[]).filter(t=>t.installed&&t.profiles>0)}function oe(s){return!Number.isFinite(s)||s<=0?"empty":Q(s)}function le(s,t){return s.map(o=>({key:o.key,name:o.name,running:o.running,visits:t.filter(r=>r.browser===o.key).reduce((r,d)=>r+d.programVisits,0)}))}function ce(s,t){if(s===null)return null;const o=Math.max(0,Math.round((t-s)/1e3));if(o<5)return"just now";if(o<60)return`${o} sec ago`;const r=Math.round(o/60);return r<60?`${r} min ago`:`${Math.round(r/60)} hr ago`}function de(s){const t=s.profiles.filter(r=>r.degraded);if(t.length>0){const r=t[0],d=t.length-1;return{kind:"unreadable",text:`${r.name}/${r.profile} could not be read — ${r.reason??"no reason given"}`+(d>0?`, and ${d} more`:"")+". The watch continues on the profiles it can read."}}const o=H(s.browsers);return o.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."}:o.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 he({snap:s,watching:t,palette:o}){const[r,d]=h.useState(!1),[i,n]=h.useState(()=>Date.now());h.useEffect(()=>{const l=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(l)},[]);const a=re(s.coverage.lastHumanMs,s.coverage.quietMs,i);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:()=>d(l=>!l),"aria-expanded":r,"aria-label":"What the sweep and the dots mean",children:"?"})]}),e.jsxs("div",{className:"bw-glance",children:[e.jsx(ae,{browsers:t.map(l=>{var u;return{key:l.key,name:l.name,running:l.running,lastReadMs:((u=s.profiles.find(c=>c.browser===l.key))==null?void 0:u.lastWrittenMs)??null}}),findings:s.episodes.slice(0,6).map(l=>({browser:l.browser??null,atMs:l.endMs})),watching:s.settings.enabled,palette:o}),e.jsx("ul",{className:"bw-counts",children:le(t,s.profiles).map(l=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-count-n",children:l.visits.toLocaleString("en-US")}),e.jsx("span",{className:"bw-count-of",children:l.name})]},l.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 ",ce(s.coverage.checkedMs,i),s.coverage.checks>0&&e.jsxs(e.Fragment,{children:[" · ",s.coverage.checks.toLocaleString("en-US")," ",s.coverage.checks===1?"check":"checks"]})]}),a!==null&&e.jsxs("p",{className:"bw-gate",children:["You are browsing — a program page would count in ",ie(a)]}),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 ue({watching:s,rest:t}){const[o,r]=h.useState(!1),[d,i]=h.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(n=>!n),"aria-expanded":o,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),o&&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(n=>e.jsxs("li",{children:[e.jsx("span",{className:`bw-prof-dot${n.running?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-prof-name",children:n.name}),e.jsx("span",{className:"bw-prof-state",children:n.running?"running":"idle"}),n.running&&n.relay.state==="live"&&e.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},n.key))}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>i(n=>!n),"aria-expanded":d,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:d?"▾":"▸"})," ",t.length," not watched"]}),d&&e.jsxs("p",{className:"bw-rest",children:[t.map(n=>n.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]})}function we({snap:s,quiet:t,setQuiet:o,save:r,access:d,setAccess:i}){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:n=>{o(Number(n.target.value)),r({quietMinutes:Number(n.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:n=>void r({reaction:n.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(n=>e.jsx("option",{value:n,children:n==="notify"?"notify me":n==="close-tab"?"close the tab":"quit the browser"},n))})]}),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:()=>i(n=>!n),"aria-expanded":d,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:d?"▾":"▸"})," What Browser Watch can access"]}),d&&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"?` (${oe(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 G(s,t){return t?{kind:"saving",word:"Saving"}:s.settings.enabled?{kind:"on",word:"Watching"}:{kind:"off",word:"Paused"}}function me({snap:s,saving:t,save:o,why:r,setWhy:d}){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:G(s,t).word},G(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:()=>d(i=>!i),"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 o({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 be({relay:s}){const[t,o]=h.useState(!1),[r,d]=h.useState(!1),i=s.killswitch.blocked?"unblock":"block",n=s.command[i],a=h.useCallback(async()=>{await _(n.command)&&(d(!0),window.setTimeout(()=>d(!1),1600))},[n.command]),l=s.profiles.filter(c=>{var N;return(N=c.report)==null?void 0:N.present}),u=s.profiles.filter(c=>c.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(c=>e.jsx("code",{className:"bw-path",children:c},c))]}),e.jsxs("button",{className:"bw-why",onClick:()=>o(c=>!c),"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:[l.length>0&&e.jsx("dl",{className:"bw-key",children:l.map(c=>e.jsxs(h.Fragment,{children:[e.jsxs("dt",{children:[c.name,c.profile==="Default"?"":` · ${c.profile}`]}),e.jsxs("dd",{children:[c.report.enabled?"enabled":"installed but switched off",c.report.allUrls?", can act on every site":", limited to the sites it was granted",c.report.sensitiveApis.length>0&&e.jsxs(e.Fragment,{children:[" — ",c.report.sensitiveApis.join(", ")]})]})]},`${c.browser}/${c.profile}`))}),u.length>0&&e.jsxs("p",{className:"bw-rc-note",children:[u.map(c=>c.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."]}),l.some(c=>c.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:n.command}),e.jsx("button",{className:"btn bw-rc-copy",onClick:a,children:r?"Copied":"Copy"})]}),e.jsx("p",{className:"bw-rc-note",children:n.note})]})]})}function ge(s){const[t,o]=h.useState(null),[r,d]=h.useState(null),[i,n]=h.useState(null),[a,l]=h.useState(!1),u=h.useRef(!1),[c,N]=h.useState(null),[R,P]=h.useState(!1),k=h.useRef(!1),m=h.useCallback(async b=>{var g,M;if(!(b&&!V(u.current))){u.current=b,l(!0);try{const f=await fetch(`/api/browser-watch${b?"?refresh=1":""}`);if(!f.ok)throw new Error(`the deck answered ${f.status}`);const y=await f.json();o(y),k.current||N(((g=y==null?void 0:y.settings)==null?void 0:g.quietMinutes)??15),s(((M=y==null?void 0:y.settings)==null?void 0:M.enabled)===!0),d(null)}catch(f){d(f instanceof Error?f.message:String(f))}finally{u.current=!1,l(!1)}}},[s]);h.useEffect(()=>{m(!1)},[m]),h.useEffect(()=>{const b=setInterval(()=>{m(!1)},1e4);return()=>clearInterval(b)},[m]);const $=h.useCallback(async b=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:b.host,startMs:b.startMs})})}finally{await m(!1)}},[m]),C=h.useCallback(async b=>{k.current=!0,P(!0);try{const g=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(b)});if(!g.ok)throw new Error(`the deck answered ${g.status}`);await m(!1),n(null)}catch(g){n(g instanceof Error?g.message:String(g))}finally{k.current=!1,P(!1)}},[m]);return{snap:t,error:r,writeError:i,setWriteError:n,busy:a,quiet:c,setQuiet:N,saving:R,load:m,dismiss:$,save:C}}function xe({onClose:s,onSeen:t,onWatching:o,palette:r}){const d=Y(s),{snap:i,error:n,writeError:a,setWriteError:l,busy:u,quiet:c,setQuiet:N,saving:R,load:P,dismiss:k,save:m}=ge(o),[$,C]=h.useState(!1),[b,g]=h.useState(!1),M=h.useRef(t);M.current=t,h.useEffect(()=>()=>M.current(Date.now()),[]);const f=H(i==null?void 0:i.browsers),y=((i==null?void 0:i.browsers)??[]).filter(p=>!(p.installed&&p.profiles>0)),W=i?de(i):null,S=f.reduce((p,A)=>p+A.profiles,0);return e.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:e.jsxs("div",{ref:d,className:"modal bw-modal",onClick:p=>p.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:i?`${S} ${S===1?"profile":"profiles"} · local only`:"local only"})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"glyph-btn",onClick:()=>void P(!0),...z(u),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:u?"…":"↻"}),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:[!i&&!n&&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."})]}),n&&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:n})]})}),i&&W&&e.jsx("p",{className:`bw-trouble ${W.kind}`,role:"status",children:W.text}),i&&e.jsxs("div",{className:"bw-work",children:[e.jsxs("aside",{className:"bw-side",children:[e.jsx(he,{snap:i,watching:f,palette:r}),e.jsx(ue,{watching:f,rest:y}),i.relay&&e.jsx(be,{relay:i.relay})]}),e.jsxs("div",{className:"bw-main",children:[e.jsx(se,{snap:i,dismiss:k}),e.jsx(X,{snap:i})]})]}),i&&$&&e.jsx(we,{snap:i,quiet:c,setQuiet:N,save:m,access:b,setAccess:g}),a&&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:[a," — the switches below show what is stored, not what you pressed."]}),e.jsx("button",{className:"glyph-btn bw-write-err-x",onClick:()=>l(null),"aria-label":"Dismiss",title:"Dismiss",children:"×"})]})}),i&&e.jsx(me,{snap:i,saving:R,save:m,why:$,setWhy:C})]})]})})}export{xe as default};
|
|
1
|
+
import{j as e,r as h,i as Q,k as _,s as V,u as Y,e as z}from"./index-DiTUBs9l.js";function X({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}`))})]})}function Z(s){const t=o=>new Date(o).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 ee(s){return new Date(s).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function K(s){const t=Math.round((s.endMs-s.startMs)/6e4);return t<1?"":`${t} min`}function se({snap:s,dismiss:t}){const[o,r]=h.useState(null),d=h.useMemo(()=>{const i=[];for(const n of s.episodes){const a=ee(n.startMs),l=i[i.length-1];l&&l.label===a?l.episodes.push(n):i.push({label:a,episodes:[n]})}return i},[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:d.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."})]}):d.map(i=>e.jsxs("div",{className:"bw-day",children:[e.jsx("h4",{className:"bw-sec-head",children:i.label}),i.episodes.map(n=>{const a=`${n.host}-${n.startMs}`,l=o===a;return e.jsxs("div",{className:`bw-ep${l?" open":""}`,children:[e.jsxs("div",{className:"bw-ep-row",children:[e.jsxs("button",{className:"bw-ep-head",onClick:()=>r(l?null:a),"aria-expanded":l,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:l?"▾":"▸"}),e.jsx("span",{className:"bw-ep-host",children:n.host}),e.jsxs("span",{className:"bw-ep-meta",children:[Z(n),K(n)&&e.jsxs(e.Fragment,{children:[" · ",K(n)]})]}),e.jsxs("span",{className:"bw-ep-count",children:[n.count," ",n.count===1?"page":"pages"]})]}),e.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>void t(n),"aria-label":`Dismiss ${n.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),l&&e.jsx("ul",{className:"bw-urls",children:n.urls.map((u,c)=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-url-time",children:new Date(u.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),e.jsx("span",{className:"bw-url",children:u.url})]},`${u.url}-${u.timeMs}-${c}`))})]},a)})]},i.label))})]})}function te(s){const t=/^#?([0-9a-f]{6})$/i.exec((s??"").trim());if(!t)return!1;const o=parseInt(t[1],16),r=[o>>16&255,o>>8&255,o&255].map(d=>{const i=d/255;return i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4)});return .2126*r[0]+.7152*r[1]+.0722*r[2]>.5}const U=1e4,ne=12e3;function ae({browsers:s,findings:t,watching:o,palette:r}){const d=h.useRef(null),i=h.useRef(null);return i.current={browsers:s,findings:t,watching:o},h.useEffect(()=>{var R;const n=d.current;if(!n)return;const a=n.getContext("2d");if(!a)return;const l=((R=window.matchMedia)==null?void 0:R.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let u=0,c=!1;const N=()=>{var F;if(c)return;const P=i.current;if(!P)return;const{browsers:k,findings:m,watching:$}=P,C=r["--accent"]||"#7dd3fc",b=r["--line"]||"#1f2229",g=r["--text-dim"]||"#6e727c",M=te(r["--bg"]),f=M?42:26,y=M?.85:.65,W=Date.now(),S=Math.min(window.devicePixelRatio||1,2),p=n.clientWidth,A=n.clientHeight;(n.width!==p*S||n.height!==A*S)&&(n.width=p*S,n.height=A*S),a.setTransform(S,0,0,S,0,0),a.clearRect(0,0,p,A);const x=p/2,j=A/2,v=Math.min(p,A)/2-6;a.strokeStyle=b,a.lineWidth=1,a.globalAlpha=M?1:.9;for(const w of[.4,.7,1])a.beginPath(),a.arc(x,j,v*w,0,Math.PI*2),a.stroke();a.beginPath(),a.moveTo(x-v,j),a.lineTo(x+v,j),a.moveTo(x,j-v),a.lineTo(x,j+v),a.stroke(),a.globalAlpha=1;const T=($&&!l?W%U/U:0)*Math.PI*2-Math.PI/2;if($){const w=(F=a.createConicGradient)==null?void 0:F.call(a,T-.85,x,j);w&&(w.addColorStop(0,"transparent"),w.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${C} ${f}%, transparent)`),w.addColorStop(1,"transparent"),a.fillStyle=w,a.beginPath(),a.moveTo(x,j),a.arc(x,j,v,T-.85,T),a.closePath(),a.fill()),a.strokeStyle=C,a.globalAlpha=y,a.beginPath(),a.moveTo(x,j),a.lineTo(x+Math.cos(T)*v,j+Math.sin(T)*v),a.stroke(),a.globalAlpha=1}k.forEach((w,I)=>{const B=I/Math.max(k.length,1)*Math.PI*2-Math.PI/2,E=w.lastReadMs===null?1:Math.min(1,(W-w.lastReadMs)/12e4),D=v*(.42+E*.5),O=x+Math.cos(B)*D,L=j+Math.sin(B)*D,J=Math.abs((T-B+Math.PI*3)%(Math.PI*2)-Math.PI),q=$?Math.max(0,1-J/.55):0;a.beginPath(),a.arc(O,L,3+q*1.6,0,Math.PI*2),a.fillStyle=w.running?C:g,a.globalAlpha=w.running?.55+q*.45:.35,a.fill(),a.globalAlpha=1});for(const w of m){const I=(W-w.atMs)/ne;if(I<0||I>1)continue;const E=Math.max(0,k.findIndex(L=>L.key===w.browser))/Math.max(k.length,1)*Math.PI*2-Math.PI/2,D=x+Math.cos(E)*v*.6,O=j+Math.sin(E)*v*.6;a.beginPath(),a.arc(D,O,4+I*22,0,Math.PI*2),a.strokeStyle=C,a.globalAlpha=(1-I)*.8,a.lineWidth=1.5,a.stroke(),a.globalAlpha=1}u=requestAnimationFrame(N)};return N(),()=>{c=!0,cancelAnimationFrame(u)}},[r]),e.jsx("canvas",{ref:d,className:"bw-radar",role:"img","aria-label":o?`Watching ${s.length} browser${s.length===1?"":"s"}`:"Not watching"})}function re(s,t,o){if(s===null)return null;const r=s+t-o;return r>0?r:null}function ie(s){const t=Math.ceil(s/1e3),o=Math.floor(t/60),r=t%60;return o>0?`${o}m ${r}s`:`${r}s`}function H(s){return(s??[]).filter(t=>t.installed&&t.profiles>0)}function oe(s){return!Number.isFinite(s)||s<=0?"empty":Q(s)}function le(s,t){return s.map(o=>({key:o.key,name:o.name,running:o.running,visits:t.filter(r=>r.browser===o.key).reduce((r,d)=>r+d.programVisits,0)}))}function ce(s,t){if(s===null)return null;const o=Math.max(0,Math.round((t-s)/1e3));if(o<5)return"just now";if(o<60)return`${o} sec ago`;const r=Math.round(o/60);return r<60?`${r} min ago`:`${Math.round(r/60)} hr ago`}function de(s){const t=s.profiles.filter(r=>r.degraded);if(t.length>0){const r=t[0],d=t.length-1;return{kind:"unreadable",text:`${r.name}/${r.profile} could not be read — ${r.reason??"no reason given"}`+(d>0?`, and ${d} more`:"")+". The watch continues on the profiles it can read."}}const o=H(s.browsers);return o.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."}:o.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 he({snap:s,watching:t,palette:o}){const[r,d]=h.useState(!1),[i,n]=h.useState(()=>Date.now());h.useEffect(()=>{const l=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(l)},[]);const a=re(s.coverage.lastHumanMs,s.coverage.quietMs,i);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:()=>d(l=>!l),"aria-expanded":r,"aria-label":"What the sweep and the dots mean",children:"?"})]}),e.jsxs("div",{className:"bw-glance",children:[e.jsx(ae,{browsers:t.map(l=>{var u;return{key:l.key,name:l.name,running:l.running,lastReadMs:((u=s.profiles.find(c=>c.browser===l.key))==null?void 0:u.lastWrittenMs)??null}}),findings:s.episodes.slice(0,6).map(l=>({browser:l.browser??null,atMs:l.endMs})),watching:s.settings.enabled,palette:o}),e.jsx("ul",{className:"bw-counts",children:le(t,s.profiles).map(l=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-count-n",children:l.visits.toLocaleString("en-US")}),e.jsx("span",{className:"bw-count-of",children:l.name})]},l.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 ",ce(s.coverage.checkedMs,i),s.coverage.checks>0&&e.jsxs(e.Fragment,{children:[" · ",s.coverage.checks.toLocaleString("en-US")," ",s.coverage.checks===1?"check":"checks"]})]}),a!==null&&e.jsxs("p",{className:"bw-gate",children:["You are browsing — a program page would count in ",ie(a)]}),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 ue({watching:s,rest:t}){const[o,r]=h.useState(!1),[d,i]=h.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(n=>!n),"aria-expanded":o,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),o&&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(n=>e.jsxs("li",{children:[e.jsx("span",{className:`bw-prof-dot${n.running?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-prof-name",children:n.name}),e.jsx("span",{className:"bw-prof-state",children:n.running?"running":"idle"}),n.running&&n.relay.state==="live"&&e.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},n.key))}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>i(n=>!n),"aria-expanded":d,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:d?"▾":"▸"})," ",t.length," not watched"]}),d&&e.jsxs("p",{className:"bw-rest",children:[t.map(n=>n.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]})}function we({snap:s,quiet:t,setQuiet:o,save:r,access:d,setAccess:i}){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:n=>{o(Number(n.target.value)),r({quietMinutes:Number(n.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:n=>void r({reaction:n.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(n=>e.jsx("option",{value:n,children:n==="notify"?"notify me":n==="close-tab"?"close the tab":"quit the browser"},n))})]}),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:()=>i(n=>!n),"aria-expanded":d,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:d?"▾":"▸"})," What Browser Watch can access"]}),d&&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"?` (${oe(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 G(s,t){return t?{kind:"saving",word:"Saving"}:s.settings.enabled?{kind:"on",word:"Watching"}:{kind:"off",word:"Paused"}}function me({snap:s,saving:t,save:o,why:r,setWhy:d}){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:G(s,t).word},G(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:()=>d(i=>!i),"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 o({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 be({relay:s}){const[t,o]=h.useState(!1),[r,d]=h.useState(!1),i=s.killswitch.blocked?"unblock":"block",n=s.command[i],a=h.useCallback(async()=>{await _(n.command)&&(d(!0),window.setTimeout(()=>d(!1),1600))},[n.command]),l=s.profiles.filter(c=>{var N;return(N=c.report)==null?void 0:N.present}),u=s.profiles.filter(c=>c.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(c=>e.jsx("code",{className:"bw-path",children:c},c))]}),e.jsxs("button",{className:"bw-why",onClick:()=>o(c=>!c),"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:[l.length>0&&e.jsx("dl",{className:"bw-key",children:l.map(c=>e.jsxs(h.Fragment,{children:[e.jsxs("dt",{children:[c.name,c.profile==="Default"?"":` · ${c.profile}`]}),e.jsxs("dd",{children:[c.report.enabled?"enabled":"installed but switched off",c.report.allUrls?", can act on every site":", limited to the sites it was granted",c.report.sensitiveApis.length>0&&e.jsxs(e.Fragment,{children:[" — ",c.report.sensitiveApis.join(", ")]})]})]},`${c.browser}/${c.profile}`))}),u.length>0&&e.jsxs("p",{className:"bw-rc-note",children:[u.map(c=>c.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."]}),l.some(c=>c.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:n.command}),e.jsx("button",{className:"btn bw-rc-copy",onClick:a,children:r?"Copied":"Copy"})]}),e.jsx("p",{className:"bw-rc-note",children:n.note})]})]})}function ge(s){const[t,o]=h.useState(null),[r,d]=h.useState(null),[i,n]=h.useState(null),[a,l]=h.useState(!1),u=h.useRef(!1),[c,N]=h.useState(null),[R,P]=h.useState(!1),k=h.useRef(!1),m=h.useCallback(async b=>{var g,M;if(!(b&&!V(u.current))){u.current=b,l(!0);try{const f=await fetch(`/api/browser-watch${b?"?refresh=1":""}`);if(!f.ok)throw new Error(`the deck answered ${f.status}`);const y=await f.json();o(y),k.current||N(((g=y==null?void 0:y.settings)==null?void 0:g.quietMinutes)??15),s(((M=y==null?void 0:y.settings)==null?void 0:M.enabled)===!0),d(null)}catch(f){d(f instanceof Error?f.message:String(f))}finally{u.current=!1,l(!1)}}},[s]);h.useEffect(()=>{m(!1)},[m]),h.useEffect(()=>{const b=setInterval(()=>{m(!1)},1e4);return()=>clearInterval(b)},[m]);const $=h.useCallback(async b=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:b.host,startMs:b.startMs})})}finally{await m(!1)}},[m]),C=h.useCallback(async b=>{k.current=!0,P(!0);try{const g=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(b)});if(!g.ok)throw new Error(`the deck answered ${g.status}`);await m(!1),n(null)}catch(g){n(g instanceof Error?g.message:String(g))}finally{k.current=!1,P(!1)}},[m]);return{snap:t,error:r,writeError:i,setWriteError:n,busy:a,quiet:c,setQuiet:N,saving:R,load:m,dismiss:$,save:C}}function xe({onClose:s,onSeen:t,onWatching:o,palette:r}){const d=Y(s),{snap:i,error:n,writeError:a,setWriteError:l,busy:u,quiet:c,setQuiet:N,saving:R,load:P,dismiss:k,save:m}=ge(o),[$,C]=h.useState(!1),[b,g]=h.useState(!1),M=h.useRef(t);M.current=t,h.useEffect(()=>()=>M.current(Date.now()),[]);const f=H(i==null?void 0:i.browsers),y=((i==null?void 0:i.browsers)??[]).filter(p=>!(p.installed&&p.profiles>0)),W=i?de(i):null,S=f.reduce((p,A)=>p+A.profiles,0);return e.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:e.jsxs("div",{ref:d,className:"modal bw-modal",onClick:p=>p.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:i?`${S} ${S===1?"profile":"profiles"} · local only`:"local only"})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"glyph-btn",onClick:()=>void P(!0),...z(u),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:u?"…":"↻"}),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:[!i&&!n&&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."})]}),n&&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:n})]})}),i&&W&&e.jsx("p",{className:`bw-trouble ${W.kind}`,role:"status",children:W.text}),i&&e.jsxs("div",{className:"bw-work",children:[e.jsxs("aside",{className:"bw-side",children:[e.jsx(he,{snap:i,watching:f,palette:r}),e.jsx(ue,{watching:f,rest:y}),i.relay&&e.jsx(be,{relay:i.relay})]}),e.jsxs("div",{className:"bw-main",children:[e.jsx(se,{snap:i,dismiss:k}),e.jsx(X,{snap:i})]})]}),i&&$&&e.jsx(we,{snap:i,quiet:c,setQuiet:N,save:m,access:b,setAccess:g}),a&&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:[a," — the switches below show what is stored, not what you pressed."]}),e.jsx("button",{className:"glyph-btn bw-write-err-x",onClick:()=>l(null),"aria-label":"Dismiss",title:"Dismiss",children:"×"})]})}),i&&e.jsx(me,{snap:i,saving:R,save:m,why:$,setWhy:C})]})]})})}export{xe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as F,f as p,r as c,s as X,p as Y,j as a,b as g,c as O,u as Z,d as _,e as E,g as D,h as ee}from"./index-
|
|
1
|
+
import{a as F,f as p,r as c,s as X,p as Y,j as a,b as g,c as O,u as Z,d as _,e as E,g as D,h as ee}from"./index-DiTUBs9l.js";function se(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 ae(s){const e=I([{agents:s}]);return e.length<2?null:e.map(n=>`${F(n.id)} ${p(n.cost)}`).join(" · ")}function P(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 te(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:"",U=s=>Array.isArray(s)?s.filter(e=>typeof e=="string"):[];function ne(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 oe(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:U(e.modelsUsed),modelBreakdowns:Array.isArray(e.modelBreakdowns)?e.modelBreakdowns.map(ne):[],...n?{agents:n}:{},...e.metadata&&typeof e.metadata=="object"?{metadata:{agents:U(e.metadata.agents)}}:{}}}function le(s){const e=s??{};return{...e,ok:e.ok===!0,days:Array.isArray(e.days)?e.days.map(oe):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 re(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 ce(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 ie(s){var n,o;return ae(s.agents)??((o=(n=s.metadata)==null?void 0:n.agents)!=null&&o.length?s.metadata.agents.join(" · "):null)}function ue(){let s=0;return{begin(){const e=++s;return()=>e===s},cancel(){s++}}}function de(s){const[e,n]=c.useState(null),[o,r]=c.useState(!1),m=c.useState(ue)[0],l=c.useRef(!1),d=(f=!1)=>{if(f&&!X(l.current))return;const x=m.begin();l.current=f;const j=s;r(!0);const i=`/api/ccusage?since=${Y(j)}${f?"&refresh=1":""}`;fetch(i).then(k=>k.json()).then(k=>{x()&&n({range:j,resp:le(k)})}).catch(()=>{x()&&n({range:j,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 he({selectedDay:s}){const e=ie(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 me=[7,14,30,90];function ge({onClose:s,providers:e}){var B;const[n,o]=c.useState(30),[r,m]=c.useState(null),{landed:l,loading:d,reload:f}=de(n),x=c.useRef(null),j=Z(s,{focusRef:x}),h=se({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??[]:[],k=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:G,inOut:H,cacheRead:V,modelCosts:A}=c.useMemo(()=>re(i),[i]),W=c.useMemo(()=>ce(A),[A]),b=c.useMemo(()=>I(i),[i]),z=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:j,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…":_(e,b.map(t=>t.id))})]}),a.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:me.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",{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:ee(l.resp)||void 0,children:[D(l.resp,"ccusage did not report usage"),a.jsx("div",{children:a.jsx("button",{className:"btn uh-retry",onClick: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(G)}),a.jsx(v,{label:"input+output",val:g(H)}),a.jsx(v,{label:"cache reads",val:g(V)})]}),z&&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:P(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:P(t.id)}}),F(t.id),a.jsx("span",{className:"uh-agent-cost",children:p(t.cost)}),a.jsx("span",{className:"uh-agent-share",children:te(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 J=C(t.totalCost,k),R=t.period===r,K=`${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":K,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(J,t.totalCost>0?2:0)}%`},children:q(t.modelBreakdowns).map($=>{const Q=C($.cost,t.totalCost);return a.jsx("div",{className:"uh-bar-seg",style:{height:`${Q}%`,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:W.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(he,{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{ge as default};
|