ccdeck 3.40.0 → 3.40.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.
@@ -79,7 +79,7 @@ ${e.sessionTitle}`:e.sessionTitle:e.cwd,d=lk(e),h=d.length>0?`${e.model}
79
79
  spend on this card also covers:
80
80
  ${d.join(`
81
81
  `)}`:e.model,f=ck(e.sessionName,e.sessionTitle),p=Kh(e),g=p?p.key:null,w=KW(g),N=p!=null&&!w,k=(p==null?void 0:p.kind)==="recap",x=JH(e);return a.jsxs("div",{className:t,style:{"--session-hue":s},children:[a.jsx("span",{className:"accent-stripe"}),a.jsx(yo,{type:"target",position:Oe.Left,style:{background:"transparent",border:"none"}}),a.jsxs("div",{className:"head",children:[a.jsxs("div",{className:"title",children:[a.jsx(Bz,{state:e.state}),a.jsx("span",{className:"label",title:c,children:e.label}),e.synthetic&&a.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"}),p&&g&&a.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":k?"Claude Code's recap":`Session note: ${xa(p.kind)}`,"aria-expanded":N,title:k?N?"Hide the recap":"Show Claude Code's recap":N?"Hide this note":"Show what this session is doing",onClick:S=>{S.stopPropagation(),GW(g)},children:a.jsx(oh,{recap:k})})]}),a.jsx("div",{className:"head-right",children:i&&e.onOpenContext&&a.jsx(LW,{currentContextTokens:o,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)})})]}),a.jsxs("div",{className:"sub",title:uW(e),children:[a.jsxs("span",{className:"sub-details",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&a.jsxs("span",{className:"spawn-badge",title:cW(e.childCount),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?a.jsxs("span",{className:"model-chip","data-family":zh(e.model),title:h,children:[es(e.model),d.length>0?` +${d.length}`:""]}):e.provider==="codex"?a.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),a.jsxs("span",{className:"time",title:e.synthetic?`The deck joined this session after it began, so it has run at least this long — first seen ${new Date(e.startedAt).toLocaleTimeString()}`:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:[e.synthetic?"≥ ":"",a.jsx(Fz,{start:e.startedAt,end:e.endedAt})]})]}),e.kind==="root"&&f.face&&a.jsx("div",{className:"session-name",title:f.tooltip,children:f.face}),e.waiting&&a.jsx(qz,{waiting:e.waiting}),(()=>{const S=vO(e);return S?a.jsxs("div",{className:"approval-blind-row",title:S.detail,children:[a.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),a.jsx("span",{className:"approval-blind-said",children:S.label})]}):null})(),(e.tools.length>0||(((j=e.outputs)==null?void 0:j.length)??0)>0)&&a.jsx(Uz,{tools:e.tools,outputs:e.outputs}),a.jsxs("div",{className:"meta",children:[a.jsxs("span",{children:[a.jsx("b",{children:e.toolCount})," ",e.toolCount===1?"tool":"tools"]}),r>0&&a.jsxs("span",{className:"failed-meta",title:`${r} tool ${r===1?"call":"calls"} returned an error`,children:[a.jsx("b",{children:r})," err"]}),n>0&&a.jsxs("span",{className:"inflight-meta",children:[a.jsx("b",{children:n})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&a.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[a.jsx("b",{children:at(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),(x==null?void 0:x.kind)==="unpriced"&&a.jsx("span",{className:"cost-unpriced",title:x.tt,children:$s}),(x==null?void 0:x.kind)==="spent"&&a.jsx("span",{className:"cost-meta",title:x.tt,children:a.jsxs("b",{children:[Ve(x.total),x.floor?"+":""]})})]}),a.jsx(Dz,{data:e,title:e.kind==="root"?f.face:void 0}),a.jsx(yo,{type:"source",position:Oe.Right,style:{background:"transparent",border:"none"}})]})}const Pz=y.memo(Lz);function Dz({data:e,title:t}){const n=e.kind==="root"&&Pn(e.waiting),r=nz(e,e.branch,{sayWaiting:ah,describeCall:s=>({name:fk(s.name).label,subject:Cz(s.name,s.input)})});return a.jsxs("div",{className:"lod-face","data-kind":e.kind,"data-alarm":n?"":void 0,"data-signal":r?"":void 0,"aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsx(DO,{kind:Hb(e.state)}),a.jsx("span",{className:"lod-name",children:e.label}),r&&a.jsx("span",{className:"lod-inline","data-tone":r.tone,children:r.short}),n&&a.jsx(pk,{})]}),t&&a.jsx("div",{className:"lod-title",children:t}),r&&a.jsxs("div",{className:"lod-signal","data-tone":r.tone,children:[a.jsx("span",{className:"lod-long",children:r.long}),a.jsx("span",{className:"lod-short",children:r.short})]})]})}function Fz({start:e,end:t}){const n=jo(1e3);return a.jsx(a.Fragment,{children:Fi(e,t,n)})}function Bz({state:e}){return a.jsx("span",{className:`state-pill state-${e}`,children:Pi(e)})}function qz({waiting:e}){const t=jo(1e3),n=Pn(e),r=Di(e);return a.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${r}
82
- Blocked for ${Fi(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?a.jsx("span",{className:"ap-pulse","aria-hidden":!0}):a.jsx("span",{className:"waiting-dot","aria-hidden":!0}),a.jsx("span",{className:"waiting-said",children:ah(e)}),a.jsx("b",{children:Fi(e.since,void 0,t)})]})}function Uz({tools:e,outputs:t}){const n=jo(1e3),{counts:r,title:s}=$z(e,t,n),o=Om/Ri;return a.jsxs("div",{className:"tool-spark-row",title:s,children:[a.jsx("svg",{className:"tool-spark",width:Om,height:qd,viewBox:`0 0 ${Om} ${qd}`,"aria-hidden":!0,children:r.map((i,c)=>{const d=Oz(i),h=c===Ri-1&&i>0,p=`tool-spark-bar${i>0?" active":""}${h?" latest":""}`;return a.jsx("rect",{x:c*o+.4,y:qd-d,width:Math.max(.5,o-1),height:d,rx:.8,className:p},h?`landed:${i}`:c)})}),a.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function Hz({enableAutoFitAndRefit:e}){return a.jsxs("div",{className:"autofit-chip",children:[a.jsx("span",{className:"autofit-state",title:"New sessions are not brought into view while you are moving it yourself",children:"Auto-fit off"}),a.jsx("button",{type:"button",className:"autofit-resume",onClick:e,title:"Bring new sessions into view again","aria-label":"Resume auto-fit",children:"Resume"})]})}const mk="agent-dag.single-key-shortcuts";function BO(e){return e!=="0"}function qO(e){return e.length===1}function UO(e,t){return!t&&qO(e)}function un(e,t,n){return n?`${e} (${t})`:e}let ho=null;const Xl=new Set;function HO(){for(const e of Xl)e()}function zb(){return ho===null&&(ho=BO(Ke(mk))),ho}function Wz(e){ho!==e&&(ho=e,Ge(mk,e?"1":"0"),HO())}function QS(e){if(e.key!==mk)return;const t=BO(e.newValue);t!==ho&&(ho=t,HO())}function zz(e){var t;return Xl.add(e),Xl.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",QS)),()=>{var n;Xl.delete(e),Xl.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",QS))}}function ih(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const e_=99;function Vz(e){const t=Math.max(0,Math.floor(e));return t>e_?`${e_}+`:String(t)}const Gz="Pause the canvas";function Kz(e){const t=e.singleKeys??!0;if(!e.paused)return un("Pause live updates — events keep arriving and are applied when you resume","Space",t);const n=Math.max(0,Math.floor(e.dropped??0));return n>0?un(`The pause is full — ${ih(e.held)} held and ${n} older ${n===1?"one":"ones"} already dropped. Resume to follow the canvas again`,"Space",t):e.held<=0?un("Nothing has arrived since you paused. Resume to follow the canvas again","Space",t):un(`${ih(e.held)} arrived while paused and will be applied in order when you resume`,"Space",t)}function Yz(e){return e.connected||!e.paused?null:"The canvas is paused as well — Space resumes it, but nothing new arrives until the stream is back."}const WO="paused · full",Xz=(e,t)=>t>0?WO:e>0?`paused · ${Vz(e)}`:"paused";function Zz(e){const t=Math.max(0,Math.floor(e.dropped??0)),n=e.singleKeys??!0;return e.connected?e.paused?{tone:"paused",resting:!1,label:Xz(e.held,t),widest:WO,title:un(t>0?`Connected — the pause is full at ${ih(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up`:e.held>0?`Connected — ${ih(e.held)} held until you resume`:"Connected — updates held until you resume","Space",n)}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function Sn(){return y.useSyncExternalStore(zz,zb,zb)}const Jz=e=>e.transform[2]>=e.maxZoom,Qz=e=>e.transform[2]<=e.minZoom;function e7({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:r,togglePause:s,handleRelayout:o,requestClear:i,setKeyHelpOpen:c}){const d=zi(),h=Je(Jz),f=Je(Qz),p=Sn();return a.jsxs(NU,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[a.jsx(er,{onClick:()=>{h||d.zoomIn()},title:"Zoom in","aria-label":"Zoom in","aria-disabled":h||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(er,{onClick:()=>{f||d.zoomOut()},title:"Zoom out","aria-label":"Zoom out","aria-disabled":f||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(er,{onClick:t,title:e?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view","data-nudge":e?"":void 0,children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(er,{"data-group-start":"",onClick:s,title:Kz({paused:n,held:r.size,dropped:r.dropped,singleKeys:p}),"aria-label":Gz,"aria-pressed":n,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(er,{onClick:o,title:un("Auto-arrange — clear pins","R",p),"aria-label":"Re-arrange the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),a.jsx(er,{"data-group-start":"","data-danger":"",onClick:()=>i("button"),title:un("Clear the canvas and the server's event log — asks first","C",p),"aria-label":"Clear the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),a.jsx("path",{d:"M9 6.2V4.4a1.6 1.6 0 0 1 1.6-1.6h2.8a1.6 1.6 0 0 1 1.6 1.6v1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M17.4 6.4 16.7 20a2 2 0 0 1-2 1.9H9.3a2 2 0 0 1-2-1.9L6.6 6.4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(er,{"data-group-start":"",onClick:()=>c(g=>!g),title:p?un("Keyboard shortcuts","?",!0):"Keyboard shortcuts — the single-key ones are off","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M8.6 8.4a3.5 3.5 0 1 1 4.6 3.35c-.85.3-1.2 1-1.2 1.85v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const t7="modulepreload",n7=function(e){return"/"+e},t_={},Uc=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let i=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));s=i(n.map(h=>{if(h=n7(h),h in t_)return;t_[h]=!0;const f=h.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const g=document.createElement("link");if(g.rel=f?"stylesheet":t7,f||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),f)return new Promise((w,N)=>{g.addEventListener("load",w),g.addEventListener("error",()=>N(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return s.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})},n_="agent-dag.fm-custom-stations",r_="agent-dag.fm-muted",Vb="custom:",r7=/^UC[A-Za-z0-9_-]{22}$/,s7=/^[A-Za-z0-9_-]{11}$/,gk=/^[A-Za-z0-9_-]{1,80}$/,a7=/\.(mp3|aac|ogg)$/i,o7=/\.m3u8$/i,zO=2048,kc=80;function ka(e){return`${Vb}${e}`}function qi(e){if(!e.startsWith(Vb))return null;const t=e.slice(Vb.length);return gk.test(t)?t:null}function s_(e){return qi(e)??e}function i7(e){return e?"This station could not be played. Check its link, pick another, or pick it again to retry.":"This station is not live right now. Pick another, or pick it again later to retry."}function Zh(e){var i,c;const t=e.trim();if(t.length>zO)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password)return null;const r=n.toString(),s=n.hostname.toLowerCase();if(s==="youtube.com"||s==="www.youtube.com"||s==="m.youtube.com"){if(n.port)return null;const d=(i=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:i[1];if(d&&r7.test(d))return{kind:"youtube-channel",url:r,channel:d};const h=(c=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:c[1];if(h&&/^[A-Za-z0-9._-]{1,64}$/.test(h))return{kind:"youtube-handle",url:r,handle:h};if(n.pathname==="/watch"){const f=n.searchParams.get("v")??"";if(s7.test(f))return{kind:"youtube-video",url:r,video:f}}return null}return o7.test(n.pathname)?{kind:"direct-audio",url:r,format:"hls"}:a7.test(n.pathname)?{kind:"direct-audio",url:r,format:"audio"}:/\.(html?|pls|m3u)$/i.test(n.pathname)?null:{kind:"direct-audio",url:r,format:"audio"}}function l7(e){return e==="1"}function c7(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=new Set,r=[];for(const s of t){if(!s||typeof s!="object")continue;const o=typeof s.id=="string"?s.id:"",i=typeof s.name=="string"?s.name.trim():"",c=typeof s.url=="string"?s.url.trim():"",d=Zh(c);if(!gk.test(o)||n.has(o)||!i||i.length>kc||!d)continue;n.add(o);const h=VO(s.radio);r.push({id:o,name:i,url:d.url,...h?{radio:h}:{}})}return r}function u7(e,t,n){const r=qi(e??"");return r&&t.some(s=>s.id===r)?ka(r):n(e)}function d7(e,t){return e===ka(t)?"claude-fm":e}function h7(){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 f7(e,t,n=h7()){const r=e.trim(),s=Zh(t);return!r||r.length>kc||!gk.test(n)||!s?null:{id:n,name:r,url:s.url}}function VO(e){if(!e||typeof e!="object")return null;const t=e,n=(s,o)=>typeof t[s]=="string"?t[s].slice(0,o):"",r=(s,o)=>typeof t[s]=="number"&&Number.isFinite(t[s])&&Math.abs(t[s])<=o?t[s]:null;return{...t.hls===!0?{hls:!0}:{},country:n("country",80),countryCode:n("countryCode",2),region:n("region",80),tags:n("tags",180),language:n("language",80),codec:n("codec",12),bitrate:typeof t.bitrate=="number"&&Number.isFinite(t.bitrate)?Math.max(0,Math.min(1e3,t.bitrate)):0,lat:r("lat",90),lon:r("lon",180)}}const Gb="https://www.youtube-nocookie.com";function p7(e,t,n){const r=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${Gb}/embed/${n?encodeURIComponent(n):"live_stream"}?${r.toString()}`}function ci(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function m7(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const g7=[1,3],y7=[0,2],w7=[2,5,100,101,150];function v7(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const{event:n,info:r}=t;if(n==="onReady")return{kind:"ready"};if(n==="onError"){const s=typeof r=="number"?r:Number(r==null?void 0:r.errorCode);return Number.isFinite(s)?{kind:"error",code:s}:null}if(n==="onStateChange"||n==="infoDelivery"){const s=typeof r=="number"?r:r==null?void 0:r.playerState;return typeof s!="number"||!Number.isFinite(s)?null:g7.includes(s)?{kind:"playing",playing:!0}:y7.includes(s)?{kind:"playing",playing:!1}:null}return null}const Ul=new Set;let a_="";function o_(e){const t=new Date().toISOString().slice(0,10);if(t!==a_&&(Ul.clear(),a_=t),!Ul.has(e)){Ul.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&Ul.delete(e)}catch{Ul.delete(e)}}}const i_=864e5,x7=6e4;function Qt(e,t=!0){y.useEffect(()=>{if(!t)return;o_(e);let n;const r=()=>{n=setTimeout(()=>{o_(e),r()},i_-Date.now()%i_+x7)};return r(),()=>clearTimeout(n)},[e,t])}const b7={"claude-fm":null,"lofi-relax":null,"lofi-game":null,"lofi-vibe":null,"lofi-sleep":null,"radio-mix":"/api/live-radio-mix","best-of-nostalgia":"/api/best-of-nostalgia","good-life-radio":"/api/good-life-radio","cafe-music-bgm":"/api/cafe-music-bgm"};function k7({fetchImpl:e,enabled:t=!0,volume:n,muted:r,source:s,playRequest:o,customStation:i,onAvailabilityChange:c}){var B;const[d,h]=y.useState(null),[f,p]=y.useState(!1),[g,w]=y.useState(!1),[N,k]=y.useState(!1),[x,b]=y.useState(!1);Qt("claude-fm",N);const j=y.useRef(o),S=y.useRef(null),E=y.useRef(null),T=y.useRef(void 0),I=y.useRef(null),A=y.useCallback(()=>{var F;clearTimeout(T.current),(F=E.current)==null||F.destroy(),E.current=null;const R=S.current;R&&(R.pause(),R.removeAttribute("src"),R.load(),S.current=null)},[]),D=y.useCallback(R=>{var F,O;(O=(F=I.current)==null?void 0:F.contentWindow)==null||O.postMessage(R,Gb)},[]),L=y.useRef(n);L.current=n;const U=y.useRef(r);U.current=r;const P=y.useCallback((R,F,O)=>{A();const G=new Audio;G.preload="none",G.volume=L.current/100,G.muted=U.current,S.current=G,w(!0),k(!1),b(!1);let Y=!1;const V=()=>S.current===G,q=()=>{clearTimeout(T.current),A(),w(!1),k(!1),b(!1)},M=()=>{V()&&(q(),p(!0),c==null||c(O,!0))},z=H=>{if(V()){if(H instanceof DOMException&&H.name==="NotAllowedError"){q();return}M()}};T.current=setTimeout(()=>{V()&&!Y&&M()},15e3),G.addEventListener("playing",()=>{V()&&(clearTimeout(T.current),Y=!0,k(!0),b(!1),c==null||c(O,!1))});const Z=()=>{V()&&(k(!1),b(Y),clearTimeout(T.current),T.current=setTimeout(()=>{V()&&M()},15e3))};G.addEventListener("waiting",Z),G.addEventListener("stalled",Z),G.addEventListener("ended",()=>{V()&&q()}),G.addEventListener("error",M,{once:!0}),F&&!G.canPlayType("application/vnd.apple.mpegurl")?Uc(async()=>{const{default:H}=await import("./hls-BFpXDghs.js");return{default:H}},[]).then(({default:H})=>{if(!V())return;if(!H.isSupported()){M();return}const X=new H;E.current=X,X.on(H.Events.ERROR,(K,Q)=>{Q.fatal&&M()}),X.on(H.Events.MEDIA_ATTACHED,()=>X.loadSource(R)),X.on(H.Events.MANIFEST_PARSED,()=>{G.play().catch(z)}),X.attachMedia(G)},M):(G.src=R,G.play().catch(z))},[c,A]);y.useEffect(()=>{g&&(D(ci("setVolume",[n])),D(ci(r?"mute":"unMute")),S.current&&(S.current.volume=n/100,S.current.muted=r))},[n,r,g,D]),y.useEffect(()=>{var q;let R=!0;const F=e??fetch,O=j.current!==o;if(j.current=o,h(null),p(!1),b(!1),w(O),k(O),A(),!t){w(!1),k(!1);return}const G=i&&ka(i.id)===s?Zh(i.url):null;if(G){if(G.kind==="direct-audio"){const M=G.format==="hls"||((q=i==null?void 0:i.radio)==null?void 0:q.hls)===!0;return h({live:!0,channel:"",audio:G.url,hls:M}),c==null||c(s,!1),O&&P(G.url,M,s),()=>{R=!1}}return F(`/api/fm-station?url=${encodeURIComponent(G.url)}`).then(M=>M.ok?M.json():null).then(M=>{R&&(M!=null&&M.channel||M!=null&&M.video?(h({live:!0,channel:M.channel??"",video:M.video??void 0}),c==null||c(s,!1)):(p(!0),c==null||c(s,!0)))}).catch(()=>{R&&(p(!0),c==null||c(s,!0))}),()=>{R=!1}}if(qi(s))return p(!0),c==null||c(s,!0),()=>{R=!1};const Y=s,V=b7[Y];if(V)F(V).then(M=>M.ok?M.json():null).then(M=>{R&&(M!=null&&M.video&&h({live:!0,channel:"",video:M.video}),M!=null&&M.video||(p(!0),w(!1),k(!1)),c==null||c(s,!(M!=null&&M.video)))}).catch(()=>{R&&(p(!0),w(!1),k(!1),c==null||c(s,!0))});else if(Y!=="claude-fm"){const M=Y.replace("lofi-","");F(`/api/lofi-girl?station=${encodeURIComponent(M)}`).then(z=>z.ok?z.json():null).then(z=>{R&&(z!=null&&z.video&&h({live:!0,channel:"",video:z.video}),z!=null&&z.video||(p(!0),w(!1),k(!1)),c==null||c(s,!(z!=null&&z.video)))}).catch(()=>{R&&(p(!0),w(!1),k(!1),c==null||c(s,!0))})}else F("/api/claude-fm").then(M=>M.ok?M.json():null).then(M=>{if(!R)return;const z=!!(M!=null&&M.live&&(M!=null&&M.channel));z&&h({live:!0,channel:M.channel}),z||(p(!0),w(!1),k(!1)),c==null||c(s,!z)}).catch(()=>{R&&(p(!0),w(!1),k(!1),c==null||c(s,!0))});return()=>{R=!1}},[i==null?void 0:i.id,i==null?void 0:i.url,(B=i==null?void 0:i.radio)==null?void 0:B.hls,t,e,c,o,s,P,A]),y.useEffect(()=>()=>A(),[A]),y.useEffect(()=>{if(!g)return;const R=F=>{var G;if(F.origin!==Gb||F.source!==((G=I.current)==null?void 0:G.contentWindow))return;const O=v7(F.data);if(O){if(O.kind==="ready"){D(ci("setVolume",[L.current])),D(ci(r?"mute":"unMute")),D(ci("playVideo"));return}if(O.kind==="playing"){k(O.playing);return}w7.includes(O.code)&&(w(!1),k(!1),p(!0),c==null||c(s,!0))}};return window.addEventListener("message",R),()=>window.removeEventListener("message",R)},[g,r,c,D,s]);const $=y.useCallback(()=>{if(!d)return;if(d.audio){if(g){A(),w(!1),k(!1),b(!1);return}P(d.audio,d.hls===!0,s);return}if(!g){w(!0),k(!0);return}const R=!N;k(R),D(ci(R?"playVideo":"pauseVideo")),R||w(!1)},[d,g,N,s,D,P,A]);return y.useMemo(()=>({probe:d,dead:f,armed:g,playing:N,buffering:x,frame:I,say:D,press:$}),[d,f,g,N,x,D,$])}const l_="agent-dag.radio-favorites",c_="agent-dag.radio-recent",u_="agent-dag.radio-catalogue";function N7(e){if(!Array.isArray(e))return[];const t=new Set;return e.slice(0,300).flatMap(n=>{if(!n||typeof n!="object")return[];const r=n,s=typeof r.id=="string"?r.id:"",o=typeof r.name=="string"?r.name.trim().slice(0,80):"",i=typeof r.url=="string"?Zh(r.url):null,c=VO(r.radio??r);return!/^radio-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(s)||!o||!c||!i||i.kind!=="direct-audio"||t.has(s)?[]:(t.add(s),[{id:s,name:o,url:i.url,radio:c}])})}function d_(e){try{const t=JSON.parse(e??"[]");return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&/^[A-Za-z0-9_-]{1,80}$/.test(n)))].slice(0,100):[]}catch{return[]}}function j7(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function Npe(e,t,n=Math.random){const r=e.filter(s=>s.id!==t);return r.length?r[Math.min(r.length-1,Math.floor(Math.max(0,n())*r.length))]:null}function jpe(e,t,n){if(!e.length)return null;const r=e.findIndex(o=>o.id===t),s=e[r<0?n===1?0:e.length-1:(r+n+e.length)%e.length];return s.id===t?null:s}function GO(e,t,n){const r=e.findIndex(s=>s.id===t);for(let s=1;s<=e.length;s++){const o=e[(r+s)%e.length];if(o.id!==t&&!n.has(o.id))return o}return null}function Spe(e,t){if(!e.length)return null;const n=[...e].sort((s,o)=>s.id.localeCompare(o.id));let r=0;for(const s of t)r=Math.imul(r,31)+s.charCodeAt(0)>>>0;return n[r%n.length]}function _pe(e,t,n,r,s){return(!t||`${e.name} ${e.radio.country} ${e.radio.region} ${e.radio.tags}`.toLowerCase().includes(t.toLowerCase()))&&(!n||e.radio.countryCode===n)&&(!r||e.radio.tags.toLowerCase().includes(r.toLowerCase()))&&(!s||e.radio.language.toLowerCase().includes(s.toLowerCase()))}function S7(){const[e,t]=y.useState(()=>d_(Ke(l_))),[n,r]=y.useState(()=>d_(Ke(c_))),[s,o]=y.useState(()=>{try{return N7(JSON.parse(Ke(u_)??"[]"))}catch{return[]}});y.useEffect(()=>{Ge(l_,JSON.stringify(e))},[e]),y.useEffect(()=>{Ge(c_,JSON.stringify(n))},[n]);const i=y.useCallback(h=>r(f=>j7(f,h)),[]),c=y.useCallback(h=>t(f=>f.includes(h)?f.filter(p=>p!==h):[...f,h].slice(-100)),[]),d=y.useCallback(h=>{o(h),Ge(u_,JSON.stringify(h))},[]);return{favorites:e,recent:n,catalogue:s,remember:i,toggleFavorite:c,updateCatalogue:d}}function _7(e,t,n,r){const s=GO(e,t,n);if(!s)return()=>{};const o=setTimeout(()=>{n.add(t),r(s)},1e3);return()=>clearTimeout(o)}const Jh=148,h_=6e3,E7=16e3,KO=46,ya=34;function C7(e,t,n=Jh){let r=-Math.round(t()*n);if(Math.abs(r-e)<ya){const s=e-ya>=-n?-ya:ya;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return{to:r,ms:Math.round(Math.abs(r-e)*KO)}}function T7(e){return Math.round(h_+e()*(E7-h_))}const f_=[{kind:"stroll",weight:44},{kind:"tidy",weight:17},{kind:"kick",weight:17},{kind:"sit",weight:12},{kind:"watch",weight:16},{kind:"leave",weight:7},{kind:"fish",weight:12},{kind:"skip",weight:10}];function R7(e){const t=f_.reduce((r,s)=>r+s.weight,0);let n=e()*t;for(const r of f_)if(n-=r.weight,n<0)return r.kind;return"stroll"}const A7=720,M7=260,$7=620,I7=220,p_=520,YO=1600,m_=7e3,O7=15e3,g_=6e3,L7=14e3;function ui(e,t,n=Jh){let r=-Math.round(t()*n);if(Math.abs(r-e)<ya){const s=e-ya>=-n?-ya:ya;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return r}const Ht=(e,t)=>Math.round(Math.abs(t-e)*KO),P7=120,vd=0;function D7(e,t){const n=r=>({kind:"litter",at:t,...r});return[{x:t,prop:n({}),act:"walk",ms:Ht(e,t)},{x:t,prop:n({}),act:"stoop",ms:A7},{x:vd,prop:n({held:!0}),act:"carry",ms:Ht(t,vd)},{x:vd,prop:n({held:!0}),act:"windup",ms:M7},{x:vd,prop:n({held:!0,leaving:!0}),act:"toss",ms:$7}]}function F7(e,t){const n=t>e?1:-1,r=t-n*Math.min(15,Math.abs(t-e)),s=(o={})=>({kind:"ball",at:t,...o});return[{x:r,prop:s(),act:"walk",ms:Ht(e,r)},{x:r,prop:s(),act:"windup",ms:I7,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"kick",ms:p_,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"stand",ms:YO-p_}]}const XO=640;function B7(e,t,n){const r=Math.max(-70,Math.min(-20,t)),s={x:r,prop:null,facing:"left"};return[{x:r,prop:null,act:"walk",ms:Ht(e,r)},{...s,act:"sit",ms:600},{...s,act:"cast",ms:900},{...s,act:"fish",ms:6e3+Math.round(n()*4e3)},{...s,act:"reel",ms:1200},{...s,act:"stow",ms:500},{...s,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:Ht(r,0)}]}function q7(e,t,n){const r=Math.max(-110,Math.min(-30,t)),s={x:r,prop:null};return[{...s,act:"walk",ms:Ht(e,r)},{...s,act:"skip-ready",ms:500},{...s,act:"skip",ms:XO*(6+Math.floor(n()*5))},{...s,act:"skip-rest",ms:600},{...s,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Ht(r,0)}]}function U7(e,t,n){return[{x:t,prop:null,act:"walk",ms:Ht(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(g_+n()*(L7-g_))},{x:t,prop:null,act:"stand",ms:400}]}function H7(e,t,n){t=Math.max(-110,Math.min(0,t));const r=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:Ht(e,t)},{x:t,prop:r(),act:"watch",ms:Math.round(m_+n()*(O7-m_))},{x:t,prop:r(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Lm(e,t,n){return e.facing?e.facing:e.act==="watch"||e.act==="scope-pack"?"left":e.x===t?n:e.x>t?"right":"left"}const W7=1500,z7=e=>Math.round(1e3*Math.sqrt(2*e/W7)),V7=115,G7=e=>Math.round(e/V7*1e3),K7=620,Y7=200,X7=760,Z7=600,J7=240;function Q7(e,t,n){const s=-(t.ledgeSpan??Jh),o=z7(t.ledgeH),i=G7(t.ledgeH),c=n(),d=n(),h=-Math.round(c*t.floorSpan),f=-Math.round(d*t.floorSpan);return[{x:s,act:"walk",prop:null,ms:Ht(e,s)},{x:s,act:"peer",prop:null,ms:K7},{x:s,act:"fall",prop:null,ms:o,place:"floor"},{x:s,act:"land",prop:null,ms:Y7,place:"floor"},{x:h,act:"walk",prop:null,ms:Ht(s,h),place:"floor",floorFrac:c},{x:f,act:"walk",prop:null,ms:Ht(h,f),place:"floor",floorFrac:d},{x:s,act:"walk",prop:null,ms:Ht(f,s),place:"floor"},{x:s,act:"lasso",prop:null,ms:X7,place:"floor"},{x:s,act:"rope-throw",prop:null,ms:Z7,place:"floor"},{x:s,act:"rope-catch",prop:null,ms:J7,place:"floor"},{x:s,act:"climb",prop:null,ms:i},{x:s,act:"pull-up",prop:null,ms:480}]}function e9(e,t,n){const r=(n==null?void 0:n.ledgeSpan)??Jh;switch(R7(t)){case"tidy":return D7(e,ui(e,t,r));case"kick":return F7(e,ui(e,t,r));case"sit":return U7(e,ui(e,t,r),t);case"watch":return H7(e,ui(e,t,r),t);case"fish":return B7(e,ui(e,t,r),t);case"skip":return q7(e,ui(e,t,r),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return Q7(e,n,t)}}const o=C7(e,t,r);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const t9=420;function n9(e,t,n){const r=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(t9,Math.max(0,r))}const r9=260,s9=200;function a9(e,t,n){const r=(f,p=Ht(e,f))=>({x:f,prop:null,act:"walk",ms:p,place:"floor"});if(!n||n.height<=0)return[r(t)];const s=Math.min(e,t);if(Math.max(e,t)<=n.left||s>=n.right)return[r(t)];const i=t>e,c=i?n.left:n.right,d=i?n.right:n.left,h={place:"floor",riser:n.height,prop:null};return[r(c,Ht(e,c)),{...h,x:c,act:"mount",ms:r9},{...h,x:d,act:"walk",ms:Ht(c,d)},{x:d,prop:null,act:"dismount",ms:s9,place:"floor"},{x:t,prop:null,act:"walk",ms:Ht(d,t),place:"floor"}]}const ZO=["bob","sway","groove"],y_=9e3,o9=16e3,JO=1e3,i9=.08;function l9(e,t){const n=ZO.filter(o=>o!==e),r=n[Math.min(n.length-1,Math.floor(t()*n.length))],s=(t()*2-1)*i9;return{dance:r,beatMs:Math.round(JO*(1+s))}}function c9(e){return Math.round(y_+e()*(o9-y_))}const yk=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],w_=18,u9=yk.length,QO="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",eL="M12 9H14V6H13V3H11V2H9V4H12Z",wk=new Set(["a","c","p"]);function _a(e=yk){const t=[];return e.forEach((n,r)=>{let s=0;for(;s<n.length;){const o=n[s];if(o==="."){s+=1;continue}let i=1;for(;s+i<n.length&&n[s+i]===o;)i+=1;t.push({x:s,y:r,w:i,cell:o}),s+=i}}),t}const d9=[".xx.","xxxx",".xx."],h9=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],f9=["...xx...............","..xaax..............",".xaallx.............","xaallllx............",".xllllllx...........","..xllllllx..........","...xllllllx.........","....xllllllxx.......",".....xllllxsxx..xx..","......xllxsssx.xllxx",".......xxssssxxxllxx","........xssssssxx...",".........xssssx.....","..........xxxx......","..........xax.......",".........xxxxx......","........xx.x.xx.....","........xl.x.lx.....",".......xl..x..lx....",".......xl..x..lx....","......xl...x...lx...","......xl...x...lx...",".....xl....x....lx..","....xxx...xxx...xxx."],Pm={litter:d9,ball:h9,scope:f9},p9=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],m9=3,g9=-1,Kb=11,v_=9;function x_(e){let t=null,n=null,r=0,s=0,o=!1;const i=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(s=performance.now(),t=setTimeout(()=>{t=null;const h=n;n=null,h==null||h()},r))},d=()=>{e.hidden&&t!==null?(r=Math.max(0,r-(performance.now()-s)),i()):e.hidden||c()};return e.addEventListener("visibilitychange",d),{schedule(h,f){o||(i(),n=h,r=Math.max(0,f),c())},dispose(){o=!0,i(),n=null,e.removeEventListener("visibilitychange",d)}}}function y9(e,t,n){const[r,s]=y.useState(0),[o,i]=y.useState(0),[c,d]=y.useState(null),[h,f]=y.useState(null),[p,g]=y.useState({x:0,drop:0}),[w,N]=y.useState("ledge"),[k,x]=y.useState("left"),[b,j]=y.useState(0),S=y.useRef(null),[E,T]=y.useState(()=>document.hidden);y.useEffect(()=>{const $=new Set,B=()=>{var R;if(document.hidden){for(const F of((R=S.current)==null?void 0:R.getAnimations({subtree:!0}))??[])if(F.playState==="running"||F.pending){const O=F.currentTime;F.pause(),O!==null&&(F.currentTime=O),$.add(F)}}else{for(const F of $)F.playState==="paused"&&F.play();$.clear()}T(document.hidden)};return B(),document.addEventListener("visibilitychange",B),()=>document.removeEventListener("visibilitychange",B)},[e,t]);const[I,A]=y.useState(null),[D,L]=y.useState(JO),[U,P]=y.useState(()=>{var $;return(($=window.matchMedia)==null?void 0:$.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return y.useEffect(()=>{var R;const $=(R=window.matchMedia)==null?void 0:R.call(window,"(prefers-reduced-motion: reduce)");if(!$)return;const B=()=>P($.matches);return B(),$.addEventListener("change",B),()=>$.removeEventListener("change",B)},[]),y.useEffect(()=>{var Q;if(!e||t||U)return;const $=x_(document);let B=0;s(ee=>B=ee);let R=null,F=0,O=0;const G=ee=>{var se,me;const[re,...ie]=ee;if(!re){R=null,d(null),f(null),H();return}d(re.act),f(re.prop),N(re.place??"ledge"),j(re.riser??0);const de=B,pe=z(re);if(re.act==="kick"){const he=(me=(se=S.current)==null?void 0:se.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:me.getBoundingClientRect();he&&g({x:n9(he.x,Lm(re,de,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-he.y+24)})}O=re.act==="walk"?Math.max(Ht(de,pe),P7):re.ms,re.act==="carry"&&(O=Ht(de,pe)),i(O),x(he=>Lm({...re,x:pe},de,he)),s(pe),B=pe,R=re,F=Date.now(),$.schedule(()=>G(ie),O)},Y=()=>{const ee=S.current,re=ee==null?void 0:ee.querySelector(".fm-sprite"),ie=ee==null?void 0:ee.parentElement;if(!ee||!re||!ie)return null;const de=ee.getBoundingClientRect(),pe=ie.getBoundingClientRect(),se=pe.right-de.right,me=pe.width-se*2-re.offsetWidth;return me>0?me:null},V=()=>{const ee=S.current,re=ee==null?void 0:ee.querySelector(".fm-sprite");return!ee||!re?0:Math.max(0,ee.getBoundingClientRect().width-re.offsetWidth)},q=()=>{const ee=S.current,re=ee==null?void 0:ee.querySelector(".fm-walker"),ie=Y();if(!ee||!re||ie==null)return;const de=ee.getBoundingClientRect().bottom-re.getBoundingClientRect().bottom;if(de>0)return{ledgeH:de,floorSpan:ie,ledgeSpan:V()}},M=()=>{const ee=S.current,re=document.querySelector(".canvas-notices");if(!ee||!re)return null;const ie=ee.getBoundingClientRect(),de=re.getBoundingClientRect();return de.width<=0||de.height<=0?null:{left:de.left-ie.right,right:de.right-ie.right,height:de.height}},z=ee=>{const re=(ee.place??"ledge")==="floor",ie=re?Y()??V():V(),de=re&&ee.floorFrac!=null?-Math.round(ee.floorFrac*ie):ee.x;return Math.max(-ie,Math.min(0,de))},Z=()=>{if(!R)return;const ee=z(R);ee!==B&&(i(Math.max(0,F+O-Date.now())),x(re=>Lm({...R,x:ee},B,re)),s(ee),B=ee)},H=()=>{$.schedule(()=>{const ee=e9(B,Math.random,q()),re=ee.some(pe=>pe.place==="floor")?M():null;let ie=B;const de=ee.flatMap(pe=>{const se=ie;if(ie=pe.x,!(pe.place==="floor"&&pe.act==="walk"))return[pe];const me=a9(se,pe.x,re),he=me.length-1;return pe.floorFrac==null?me:me.map((le,ue)=>ue===he?{...le,floorFrac:pe.floorFrac}:le)});G(de)},T7(Math.random))},X=(Q=S.current)==null?void 0:Q.parentElement,K=typeof ResizeObserver>"u"?null:new ResizeObserver(Z);return X&&K&&K.observe(X),H(),()=>{$.dispose(),K==null||K.disconnect(),N("ledge"),s(ee=>Math.max(-V(),Math.min(0,ee))),i(0),d(null),f(null),j(0)}},[e,t,U]),y.useEffect(()=>{if(!n||U){A(null);return}const $=x_(document),B=R=>{const F=l9(R,Math.random);A(F.dance),L(F.beatMs),$.schedule(()=>B(F.dance),c9(Math.random))};return B(null),()=>$.dispose()},[n,U]),{scene:S,suspended:E,x:r,walkMs:o,act:c,prop:h,ballFlight:p,place:w,facing:k,riser:b,dance:I,beatMs:D}}const Dm={e:"fm-eye",s:"fm-shade",p:"fm-pad"},lh=_a().filter(e=>!wk.has(e.cell)),w9=_a().filter(e=>wk.has(e.cell)),b_=lh.filter(e=>e.cell==="e"),v9=_a(p9),x9=lh.filter(e=>e.y<Kb&&e.cell!=="e").map(e=>{if(e.y!==8&&e.y!==9)return e;const t=Math.max(6,e.x);return{...e,x:t,w:Math.max(0,Math.min(12,e.x+e.w)-t)}}).filter(e=>e.w>0),b9={left:lh.filter(e=>e.y>=Kb&&e.x<v_),right:lh.filter(e=>e.y>=Kb&&e.x>=v_)},k9=y.memo(function({act:t,facing:n}){return a.jsxs("svg",{viewBox:`0 0 ${w_} ${u9}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:w9.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Dm[r.cell]},`g${r.y}-${r.x}`))})}),a.jsxs("g",{className:"fm-body",children:[b_.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:"var(--accent)"},`eye-bed-${r.x}`)),x9.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Dm[r.cell]},`b${r.y}-${r.x}`)),a.jsxs("g",{className:"fm-arms",children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2}),a.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),b_.map(r=>a.jsx("rect",{x:r.x-(r.x>=w_/2?1:0)+(n==="right"?1:0),y:r.y,width:r.w,height:1,className:"fm-eye"},`eye-${r.x}`))]}),a.jsx("g",{className:"fm-hat",children:v9.map(r=>a.jsx("rect",{x:m9+r.x,y:g9+r.y,width:r.w,height:1,className:r.cell==="k"?"fm-hatband":void 0},`h${r.y}-${r.x}`))}),(t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up")&&a.jsxs("g",{className:"fm-grip",children:[a.jsx("path",{className:"fm-grip-left",d:QO}),a.jsx("path",{className:"fm-grip-right",d:eL})]}),(t==="land"||t==="dismount")&&a.jsxs("g",{className:"fm-crouch-legs",children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&a.jsxs("g",{className:"fm-seated-legs",children:[a.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(r=>a.jsx("g",{className:"fm-leg","data-side":r,children:b9[r].map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Dm[s.cell]},`${r}${s.y}-${s.x}`))},r))]})}),N9=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],j9=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],Vr={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},S9={p:"fm-pad"},Nc=_a(N9),_9=_a(j9);function Yb(e,t,n){return e.map(r=>({...r,x:Math.max(t,r.x),w:Math.max(0,Math.min(n,r.x+r.w)-Math.max(t,r.x))})).filter(r=>r.w>0)}const E9=Yb(Nc.filter(e=>e.y>=8),12,18),C9=Nc.filter(e=>e.y<11&&e.cell!=="e").map(e=>e.y===8||e.y===9?{...e,x:Math.max(6,e.x),w:Math.max(0,Math.min(12,e.x+e.w)-Math.max(6,e.x))}:e.y===10?{...e,w:Math.max(0,Math.min(12,e.x+e.w)-e.x)}:e).filter(e=>e.w>0),k_=Nc.filter(e=>e.cell==="e"),T9={left:Yb(Nc.filter(e=>e.y>=11),0,9),right:Yb(Nc.filter(e=>e.y>=11),9,12)},R9=y.memo(function({act:t,facing:n}){const r=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",s=t==="land"||t==="dismount",o=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return a.jsxs("svg",{"data-character":"fox",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[a.jsx("g",{className:"fm-body","data-part":"tail",children:E9.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Vr[i.cell]},`t${i.y}-${i.x}`))}),a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:_9.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:S9[i.cell]},`g${i.y}-${i.x}`))})}),a.jsxs("g",{className:"fm-body",children:[C9.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Vr[i.cell]},`b${i.y}-${i.x}`)),k_.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Vr.f},`bed${i.x}`)),a.jsxs("g",{className:"fm-arms",fill:Vr.f,children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2})]}),k_.map(i=>a.jsx("rect",{x:i.x+(n==="right"?1:0)-(i.x>=9?1:0),y:i.y,width:i.w,height:1,className:"fm-eye",style:{fill:Vr.n}},`e${i.x}`))]}),r&&a.jsxs("g",{className:"fm-grip",style:{fill:Vr.f},children:[a.jsx("path",{className:"fm-grip-left",d:QO}),a.jsx("path",{className:"fm-grip-right",d:eL})]}),s&&a.jsxs("g",{className:"fm-crouch-legs",style:{fill:Vr.f},children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&a.jsxs("g",{className:"fm-seated-legs",style:{fill:Vr.f},children:[a.jsx("path",{className:"fm-seated-far",style:{fill:Vr.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(i=>a.jsx("g",{className:"fm-leg","data-side":i,children:T9[i].map(c=>a.jsx("rect",{x:c.x,y:c.y,width:c.w,height:1,fill:Vr[c.cell]},`${c.y}-${c.x}`))},i))]})}),A9=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],ks={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},M9={p:"fm-pad"},ch=_a(A9),$9=_a(yk).filter(e=>wk.has(e.cell)),N_=ch.filter(e=>e.cell==="e"),I9=ch.filter(e=>e.y<12&&e.cell!=="e"),O9={left:ch.filter(e=>e.y>=12&&e.x<9),right:ch.filter(e=>e.y>=12&&e.x>=9)},L9=y.memo(function({act:t}){const n=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",r=t==="land"||t==="dismount",s=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return a.jsxs("svg",{"data-character":"penguin",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:$9.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:M9[o.cell]},`g${o.y}-${o.x}`))})}),a.jsxs("g",{className:"fm-body",children:[I9.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:ks[o.cell]},`b${o.y}-${o.x}`)),N_.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:ks.w},`bed${o.x}`)),a.jsxs("g",{className:"fm-arms",fill:ks.d,children:[a.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),a.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),N_.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:ks.e}},`e${o.x}`))]}),n&&a.jsxs("g",{className:"fm-grip",style:{fill:ks.h},children:[a.jsx("path",{className:"fm-grip-left",d:"M5 10H4V4H5V2H6V1H7V0H9V2H7V3H6V10Z"}),a.jsx("path",{className:"fm-grip-right",d:"M12 10H14V6H13V3H11V2H9V4H12Z"})]}),r&&a.jsxs("g",{className:"fm-crouch-legs",style:{fill:ks.b},children:[a.jsx("path",{d:"M5 12H8V13H5Z"}),a.jsx("path",{d:"M10 12H13V13H10Z"})]}),s&&a.jsxs("g",{className:"fm-seated-legs",style:{fill:ks.b},children:[a.jsx("path",{className:"fm-seated-far",style:{fill:ks.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),a.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>a.jsx("g",{className:"fm-leg","data-side":o,children:O9[o].map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ks.b},`${i.y}-${i.x}`))},o))]})});function tL({character:e,act:t,facing:n}){return e==="penguin"?a.jsx(L9,{act:t,facing:n}):e==="fox"?a.jsx(R9,{act:t,facing:n}):a.jsx(k9,{act:t,facing:n})}const P9={"claude-fm":"Claude FM","lofi-relax":"Lofi Girl relax/study","lofi-game":"Lofi Girl chill/game","lofi-vibe":"Lofi Girl vibe/chill","lofi-sleep":"Lofi Girl sleep/chill","radio-mix":"Radio Mix Live","best-of-nostalgia":"Best of Nostalgia Live","good-life-radio":"The Good Life Radio Live","cafe-music-bgm":"Cafe Music BGM Live"};function nL(e,t){return t&&ka(t.id)===e?t.name:qi(e)?"Custom FM":P9[e]}function Fm(e,t){var r;const n=((r=e[0])==null?void 0:r.length)??0;return a.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:_a(e).map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:s.cell==="s"?"var(--fm-prop-shadow, var(--bg))":s.cell==="l"?"var(--fm-prop-light, var(--text))":s.cell==="a"?"var(--accent)":void 0},`${t}${s.y}-${s.x}`))})}const j_={litter:Fm(Pm.litter,"litter"),ball:Fm(Pm.ball,"ball"),scope:Fm(Pm.scope,"scope")};function D9(e){try{return new URL(e).host}catch{return"the station's server"}}const F9=y.memo(function({player:t,source:n,customStation:r,character:s="deck"}){const{probe:o,dead:i,playing:c,press:d}=t,{scene:h,suspended:f,x:p,walkMs:g,act:w,prop:N,ballFlight:k,place:x,facing:b,riser:j,dance:S,beatMs:E}=y9(o,i,c);if(!o||i)return null;const T=nL(n,r),I=o.audio?D9(o.audio):"YouTube";return a.jsxs("div",{ref:h,className:"fm","data-suspended":f?"":void 0,"data-place":x,style:{"--fm-beat":`${E}ms`},children:[N&&!N.held&&a.jsx("div",{className:"fm-prop","data-prop":N.kind,"data-leaving":N.leaving?"":void 0,style:{"--fm-prop-x":`${N.at}px`,"--fm-roll-to":`${k.x}px`,"--fm-ball-drop":`${k.drop}px`,"--fm-ball-flight-ms":`${YO}ms`,"--fm-ball-turn":b==="right"?"1080deg":"-1080deg"},children:j_[N.kind]}),(w==="lasso"||w==="rope-throw"||w==="rope-catch"||w==="climb"||w==="pull-up")&&a.jsxs("div",{className:"fm-rope","data-act":w,style:{"--fm-rope-x":`${p}px`,"--fm-rope-ms":`${g}ms`},children:[a.jsx("div",{className:"fm-rope-line"}),a.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),a.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),a.jsxs("div",{className:"fm-walker","data-act":w??void 0,"data-place":x,"data-facing":b,style:{"--fm-x":`${p}px`,"--fm-walk-ms":`${g}ms`,"--fm-riser":`${j}px`,"--fm-skip-beat":`${XO}ms`},children:[(N==null?void 0:N.held)&&a.jsx("div",{className:"fm-held","data-prop":N.kind,"data-toss":N.leaving?"":void 0,children:j_[N.kind]}),["cast","fish","reel","stow"].includes(w)&&a.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsxs("g",{children:[a.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),a.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),a.jsxs("g",{className:"fm-fishing-line",children:[a.jsx("path",{d:"M8 2V26"}),a.jsxs("g",{className:"fm-float",children:[a.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),a.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),a.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(w)&&a.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),a.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),a.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),a.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),a.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),a.jsx("button",{type:"button",className:"fm-sprite","data-playing":c?"":void 0,"data-dance":c?S??ZO[0]:void 0,onClick:d,title:c?`Stop ${T}`:`Play ${T} — streams from ${I}`,"aria-label":c?`Stop ${T}`:`Play ${T}`,children:a.jsx(tL,{character:s,act:w,facing:b})})]})]})});function B9({player:e,label:t}){const{probe:n,armed:r,frame:s,say:o}=e;return n?a.jsx(a.Fragment,{children:r&&!n.audio&&(n.channel||n.video)&&a.jsx("iframe",{ref:s,className:"fm-frame",title:t,src:p7(n.channel,window.location.origin,n.video),onLoad:()=>o(m7()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const q9={radio:"M4 8h16v12H4z M7 8l10-5 M7 12h5 M15 12h2 M7 16h2 M13 16h4",play:"M8 5l11 7-11 7z",pause:"M8 5v14 M16 5v14",shuffle:"M3 6h3c5 0 7 12 12 12h3 M17 14l4 4-4 4 M3 18h3c2 0 4-3 6-6s4-6 6-6h3 M17 2l4 4-4 4",heart:"M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1.1-1.1a5.5 5.5 0 0 0-7.8 7.8L12 21l8.8-8.6a5.5 5.5 0 0 0 0-7.8z",close:"M6 6l12 12 M6 18L18 6",search:"M10.5 3a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15 M16 16l5 5",globe:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20 M2 12h20 M12 2c-6 6-6 14 0 20 M12 2c6 6 6 14 0 20",back:"M16 5l-7 7 7 7",previous:"M5 5v14 M19 5l-10 7 10 7z",next:"M19 5v14 M5 5l10 7-10 7z",volume:"M11 4L6 8H3v8h3l5 4z M15 8a6 6 0 0 1 0 8 M18 5a10 10 0 0 1 0 14",muted:"M11 4L6 8H3v8h3l5 4z M16 9l6 6 M16 15l6-6"};function U9({name:e}){return a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:q9[e]})})}function H9({opening:e=!1}){const[t,n]=y.useState(()=>document.hidden);return y.useEffect(()=>{const r=()=>n(document.hidden);return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)},[]),a.jsxs("div",{className:"radio-tuning",role:"status","data-paused":t||void 0,children:[a.jsxs("svg",{className:"radio-tuning-art",viewBox:"0 0 240 112",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsxs("g",{className:"radio-tuning-tower",children:[a.jsx("circle",{cx:"40",cy:"24",r:"4"}),a.jsx("path",{d:"M40 28v60 M40 36L24 88h32L40 36 M31 66h18 M28 77h24 M20 92h40"}),a.jsx("path",{d:"M29 17a15 15 0 0 0 0 14 M51 17a15 15 0 0 1 0 14"})]}),a.jsxs("g",{className:"radio-tuning-send",children:[a.jsx("path",{d:"M75 26q7 8 0 16"}),a.jsx("path",{d:"M102 26q7 8 0 16"}),a.jsx("path",{d:"M129 26q7 8 0 16"})]}),a.jsxs("g",{className:"radio-tuning-receiver",children:[a.jsx("path",{d:"M165 49l30-22"}),a.jsx("rect",{x:"154",y:"49",width:"66",height:"43",rx:"7"}),a.jsx("path",{d:"M161 92v3 M213 92v3 M163 60h17 M163 66h17 M163 72h17 M163 78h17"}),a.jsx("circle",{cx:"202",cy:"65",r:"7"}),a.jsx("path",{d:"M202 62v3l3 2 M197 81h10"})]})]}),a.jsx("strong",{children:e?"Opening Radio":"Tuning into the world"}),a.jsx("span",{children:e?"Getting your explorer ready…":"Finding stations…"})]})}function W9({onClose:e}){const[t]=y.useState(()=>{var r;return((r=document.activeElement)==null?void 0:r.matches(":focus-visible"))??!1}),n=pt(e);return a.jsxs("div",{ref:n,className:"radio-loading nodrag nopan",role:"dialog","aria-modal":"true","aria-label":"Opening Radio","data-keyboard-interaction":t||void 0,onKeyDown:NW,children:[a.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close radio",onClick:e,children:a.jsx(U9,{name:"close"})}),a.jsx(H9,{opening:!0})]})}const z9=y.lazy(()=>Uc(()=>import("./RadioPanel-BTPZdlIr.js"),[]));function V9({fm:e,characterEnabled:t,character:n,open:r,onClose:s}){const[o,i]=y.useState(!1),[c,d]=y.useState("Connecting to the deck…"),h=S7(),[f,p]=y.useState(null),g=y.useRef(new Set);y.useEffect(()=>{const I=new AbortController;return fetch("/api/music-config",{signal:I.signal}).then(A=>A.ok?A.json():null).then(A=>{I.signal.aborted||(i((A==null?void 0:A.enabled)===!0),d(A?"Music is turned off on this deck.":"Cannot reach the deck. Reopen Radio when it reconnects."))}).catch(()=>{I.signal.aborted||d("Cannot reach the deck. Reopen Radio when it reconnects.")}),()=>I.abort()},[r]);const w=e.customFmStations.find(I=>ka(I.id)===e.fmSource),N=w!=null&&w.radio?w:void 0,k=k7({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),x=nL(e.fmSource,w),b=o&&N&&k.dead&&e.fmPlayRequest>0?GO(f??h.catalogue,N.id,g.current):null,{remember:j}=h;y.useEffect(()=>{N&&k.playing&&j(N.id)},[N==null?void 0:N.id,k.playing,j]);const S=s,E=wt(s),T=y.useCallback((I,A=!1)=>{var P;if(!o)return;A||g.current.clear();const D=ka(I.id),L=D===e.fmSource;if(L&&k.armed&&!k.dead){k.press();return}const U=L&&!!w&&(w.url!==I.url||((P=w.radio)==null?void 0:P.hls)!==I.radio.hls);e.addFmStation(I,!0),L&&!k.dead&&!U?k.press():e.pickFmSource(D,U),fetch(`/api/radio-click?id=${encodeURIComponent(I.id)}`).catch(()=>{})},[o,w,e.addFmStation,e.fmSource,e.pickFmSource,k.armed,k.dead,k.press]);return y.useEffect(()=>{k.playing&&!k.dead&&g.current.clear()},[k.playing,k.dead]),y.useEffect(()=>{if(!(!o||!N||!k.dead||e.fmPlayRequest===0))return _7(f??h.catalogue,N.id,g.current,I=>T(I,!0))},[o,N==null?void 0:N.id,k.dead,e.fmPlayRequest,f,h.catalogue,T]),a.jsxs(a.Fragment,{children:[t&&a.jsx(F9,{character:n,player:k,source:e.fmSource,customStation:w}),a.jsx(B9,{player:k,label:x}),r&&Mt.createPortal(a.jsx("div",{className:"modal-backdrop radio-backdrop",...E,children:a.jsx(y.Suspense,{fallback:a.jsx(W9,{onClose:S}),children:a.jsx(z9,{fm:e,player:k,library:h,selected:N,label:x,enabled:o,disabledReason:c,autoNext:b==null?void 0:b.name,onPick:T,onQueueChange:p,onClose:S})})}),document.body)]})}function rL(e){const t=Math.max(0,e);return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function Xb(e){return rL(Math.floor(e/1e3))}function Qh(e,t){const n=e-t;if(n<=0)return null;const r=Math.floor(n/86400),s=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);return r>0?`${r}d ${s}h`:s>0?`${s}h ${o}m`:`${o}m`}function G9(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function uh(e,t,n){const r=new Date(e),s=Xb(t-e);return{label:G9(r,new Date(t))?s:`${s} · ${r.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:r.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function K9({data:e}){const t=jo(3e4),n=e.note,r=n.kind==="recap",s=uh(n.at,t),o=r?"recap-note":`recap-note is-status status-${n.kind}`,i=r?void 0:Yh(n);return a.jsxs("div",{className:o,role:"note","aria-label":r?"Claude Code's recap":`Session note: ${xa(n.kind)}`,"aria-description":i,style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"recap-note-head",title:i,children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(oh,{recap:r}),xa(n.kind)]}),a.jsx("span",{className:"recap-note-age",title:s.title,children:s.label}),a.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":r?"Hide the recap":"Hide this note",title:"Hide — the mark on the card brings it back",onClick:c=>{c.stopPropagation(),VW(e.noteKey)},children:"×"})]}),a.jsx("p",{className:"recap-note-text",title:rz(n.text,i),children:n.text}),n.reply&&a.jsxs("p",{className:"recap-note-reply",title:`suggested reply “${n.reply}”`,children:["suggested reply “",n.reply,"”"]}),a.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(oh,{recap:r}),xa(n.kind)]}),a.jsx("span",{className:"recap-face-age",children:s.label})]}),a.jsx("p",{className:"recap-face-text",children:n.text})]}),a.jsx(yo,{type:"source",position:Oe.Right,style:{background:"transparent",border:"none"}})]})}function ef(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function tf(e){return/mac|iphone|ipad/i.test(e)}const dh=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function Y9(e,t,n){return{positions:dh(e.positions),pinned:dh(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function X9(e,t){t.positions.clear();for(const[n,r]of dh(e.positions))t.positions.set(n,r);t.pinned.clear();for(const[n,r]of dh(e.pinned))t.pinned.set(n,r);t.provisional.clear();for(const n of e.provisional)t.provisional.add(n);t.layoutSig.current=e.layoutSig}const S_=7e3,Z9=2e3,J9=140,Q9="Layout re-arranged",eV="Layout re-arranged. Undo available.",__="Layout restored.",tV={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function nV(e,t=tV){let n=null,r=null,s=0,o=S_;const i=new Set,c=()=>{r!==null&&t.clear(r),r=null},d=()=>{c(),!(n===null||i.size>0)&&(s=t.now()+o,r=t.set(()=>{r=null,h()},o))};function h(){c(),i.clear(),n!==null&&(n=null,e(!1))}return{open(f){const p=n===null;n=f,o=S_,d(),p&&e(!0)},take(){const f=n;return h(),f},close:h,hold(f){n!==null&&(i.size===0&&r!==null&&(o=Math.max(0,s-t.now()),c()),i.add(f))},release(f){!i.delete(f)||i.size>0||n===null||(o=Math.max(o,Z9),d())},get isOpen(){return n!==null},get snapshot(){return n}}}function rV(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function sV(e){return tf(e)?"⌘Z":"Ctrl+Z"}function aV({undo:e}){const{open:t,said:n,undo:r,dismiss:s,hold:o,release:i}=e,c=Ni(t,J9),d=y.useRef(null);return y.useEffect(()=>t?On.push(s,0,"popover"):void 0,[t,s]),y.useEffect(()=>{var f;if(t)return;const h=d.current;h&&h.contains(document.activeElement)&&((f=h.closest("main"))==null||f.focus({preventScroll:!0}))},[t]),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:n}),ga(c)&&a.jsxs("div",{ref:d,className:c==="leaving"?"rearrange-undo leaving":"rearrange-undo",onPointerEnter:()=>o("hover"),onPointerLeave:()=>i("hover"),onFocus:()=>o("focus"),onBlur:h=>{h.currentTarget.contains(h.relatedTarget)||i("focus")},children:[a.jsx("span",{id:"rearrange-undo-state",className:"rearrange-undo-state",children:Q9}),a.jsxs("button",{type:"button",className:"rearrange-undo-act",onClick:r,"aria-describedby":"rearrange-undo-state","aria-keyshortcuts":"Meta+Z Control+Z",children:["Undo",a.jsx("span",{className:"rearrange-undo-key","aria-hidden":"true",children:sV(ef())})]})]})]})}function oV({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s,targetPosition:o,style:i}){const[c]=Z0({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:.35});return a.jsxs("g",{className:"recap-tie",style:i,children:[a.jsx("path",{className:"recap-tie-thread",d:c,vectorEffect:"non-scaling-stroke"}),a.jsx("path",{className:"recap-tie-beads",d:c,vectorEffect:"non-scaling-stroke"}),a.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),a.jsx("circle",{className:"recap-tie-end",cx:n,cy:r,r:3.5})]})}function Zb(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function hh(e,t){const n=Zb(e);return n?n.slice(-t):e.slice(-t)}function sL(e,t,n=4){const r=Zb(e);if(!r)return hh(e,n);let s=n;for(const o of t){if(o===e)continue;const i=Zb(o);let c=0;for(;c<r.length&&c<i.length&&r[r.length-1-c]===i[i.length-1-c];)c++;s=Math.max(s,c+1)}return r.slice(-s)}const oc=" · ",iV=32,lV=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function E_(e){return lV.test(e)?2:1}function C_(e,t=iV){const n=[...e];let r=0;for(const i of n)r+=E_(i);if(r<=t)return e;const s=[];let o=0;for(const i of n){const c=E_(i);if(o+c>t-1)break;s.push(i),o+=c}for(;s.length&&/[\s\-_.:/]/.test(s[s.length-1]);)s.pop();return`${s.join("")}…`}function cV(e,t,n,r,s=[],{branch:o,alarm:i=!1}={}){const c=(t==null?void 0:t.trim())??"",d=r?sL(n,s):void 0,h=[e,c||void 0,d].filter(Boolean),f=[e,o,c||void 0,d].filter(Boolean).join(oc);return{label:C_(e),name:c?C_(c):void 0,shortId:d,fullLabel:h.join(oc),title:`${i?"waiting on you: ":""}${f}
82
+ Blocked for ${Fi(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?a.jsx("span",{className:"ap-pulse","aria-hidden":!0}):a.jsx("span",{className:"waiting-dot","aria-hidden":!0}),a.jsx("span",{className:"waiting-said",children:ah(e)}),a.jsx("b",{children:Fi(e.since,void 0,t)})]})}function Uz({tools:e,outputs:t}){const n=jo(1e3),{counts:r,title:s}=$z(e,t,n),o=Om/Ri;return a.jsxs("div",{className:"tool-spark-row",title:s,children:[a.jsx("svg",{className:"tool-spark",width:Om,height:qd,viewBox:`0 0 ${Om} ${qd}`,"aria-hidden":!0,children:r.map((i,c)=>{const d=Oz(i),h=c===Ri-1&&i>0,p=`tool-spark-bar${i>0?" active":""}${h?" latest":""}`;return a.jsx("rect",{x:c*o+.4,y:qd-d,width:Math.max(.5,o-1),height:d,rx:.8,className:p},h?`landed:${i}`:c)})}),a.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function Hz({enableAutoFitAndRefit:e}){return a.jsxs("div",{className:"autofit-chip",children:[a.jsx("span",{className:"autofit-state",title:"New sessions are not brought into view while you are moving it yourself",children:"Auto-fit off"}),a.jsx("button",{type:"button",className:"autofit-resume",onClick:e,title:"Bring new sessions into view again","aria-label":"Resume auto-fit",children:"Resume"})]})}const mk="agent-dag.single-key-shortcuts";function BO(e){return e!=="0"}function qO(e){return e.length===1}function UO(e,t){return!t&&qO(e)}function un(e,t,n){return n?`${e} (${t})`:e}let ho=null;const Xl=new Set;function HO(){for(const e of Xl)e()}function zb(){return ho===null&&(ho=BO(Ke(mk))),ho}function Wz(e){ho!==e&&(ho=e,Ge(mk,e?"1":"0"),HO())}function QS(e){if(e.key!==mk)return;const t=BO(e.newValue);t!==ho&&(ho=t,HO())}function zz(e){var t;return Xl.add(e),Xl.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",QS)),()=>{var n;Xl.delete(e),Xl.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",QS))}}function ih(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const e_=99;function Vz(e){const t=Math.max(0,Math.floor(e));return t>e_?`${e_}+`:String(t)}const Gz="Pause the canvas";function Kz(e){const t=e.singleKeys??!0;if(!e.paused)return un("Pause live updates — events keep arriving and are applied when you resume","Space",t);const n=Math.max(0,Math.floor(e.dropped??0));return n>0?un(`The pause is full — ${ih(e.held)} held and ${n} older ${n===1?"one":"ones"} already dropped. Resume to follow the canvas again`,"Space",t):e.held<=0?un("Nothing has arrived since you paused. Resume to follow the canvas again","Space",t):un(`${ih(e.held)} arrived while paused and will be applied in order when you resume`,"Space",t)}function Yz(e){return e.connected||!e.paused?null:"The canvas is paused as well — Space resumes it, but nothing new arrives until the stream is back."}const WO="paused · full",Xz=(e,t)=>t>0?WO:e>0?`paused · ${Vz(e)}`:"paused";function Zz(e){const t=Math.max(0,Math.floor(e.dropped??0)),n=e.singleKeys??!0;return e.connected?e.paused?{tone:"paused",resting:!1,label:Xz(e.held,t),widest:WO,title:un(t>0?`Connected — the pause is full at ${ih(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up`:e.held>0?`Connected — ${ih(e.held)} held until you resume`:"Connected — updates held until you resume","Space",n)}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function Sn(){return y.useSyncExternalStore(zz,zb,zb)}const Jz=e=>e.transform[2]>=e.maxZoom,Qz=e=>e.transform[2]<=e.minZoom;function e7({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:r,togglePause:s,handleRelayout:o,requestClear:i,setKeyHelpOpen:c}){const d=zi(),h=Je(Jz),f=Je(Qz),p=Sn();return a.jsxs(NU,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[a.jsx(er,{onClick:()=>{h||d.zoomIn()},title:"Zoom in","aria-label":"Zoom in","aria-disabled":h||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(er,{onClick:()=>{f||d.zoomOut()},title:"Zoom out","aria-label":"Zoom out","aria-disabled":f||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(er,{onClick:t,title:e?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view","data-nudge":e?"":void 0,children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(er,{"data-group-start":"",onClick:s,title:Kz({paused:n,held:r.size,dropped:r.dropped,singleKeys:p}),"aria-label":Gz,"aria-pressed":n,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(er,{onClick:o,title:un("Auto-arrange — clear pins","R",p),"aria-label":"Re-arrange the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),a.jsx(er,{"data-group-start":"","data-danger":"",onClick:()=>i("button"),title:un("Clear the canvas and the server's event log — asks first","C",p),"aria-label":"Clear the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),a.jsx("path",{d:"M9 6.2V4.4a1.6 1.6 0 0 1 1.6-1.6h2.8a1.6 1.6 0 0 1 1.6 1.6v1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M17.4 6.4 16.7 20a2 2 0 0 1-2 1.9H9.3a2 2 0 0 1-2-1.9L6.6 6.4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(er,{"data-group-start":"",onClick:()=>c(g=>!g),title:p?un("Keyboard shortcuts","?",!0):"Keyboard shortcuts — the single-key ones are off","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M8.6 8.4a3.5 3.5 0 1 1 4.6 3.35c-.85.3-1.2 1-1.2 1.85v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const t7="modulepreload",n7=function(e){return"/"+e},t_={},Uc=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let i=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));s=i(n.map(h=>{if(h=n7(h),h in t_)return;t_[h]=!0;const f=h.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const g=document.createElement("link");if(g.rel=f?"stylesheet":t7,f||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),f)return new Promise((w,N)=>{g.addEventListener("load",w),g.addEventListener("error",()=>N(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return s.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})},n_="agent-dag.fm-custom-stations",r_="agent-dag.fm-muted",Vb="custom:",r7=/^UC[A-Za-z0-9_-]{22}$/,s7=/^[A-Za-z0-9_-]{11}$/,gk=/^[A-Za-z0-9_-]{1,80}$/,a7=/\.(mp3|aac|ogg)$/i,o7=/\.m3u8$/i,zO=2048,kc=80;function ka(e){return`${Vb}${e}`}function qi(e){if(!e.startsWith(Vb))return null;const t=e.slice(Vb.length);return gk.test(t)?t:null}function s_(e){return qi(e)??e}function i7(e){return e?"This station could not be played. Check its link, pick another, or pick it again to retry.":"This station is not live right now. Pick another, or pick it again later to retry."}function Zh(e){var i,c;const t=e.trim();if(t.length>zO)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password)return null;const r=n.toString(),s=n.hostname.toLowerCase();if(s==="youtube.com"||s==="www.youtube.com"||s==="m.youtube.com"){if(n.port)return null;const d=(i=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:i[1];if(d&&r7.test(d))return{kind:"youtube-channel",url:r,channel:d};const h=(c=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:c[1];if(h&&/^[A-Za-z0-9._-]{1,64}$/.test(h))return{kind:"youtube-handle",url:r,handle:h};if(n.pathname==="/watch"){const f=n.searchParams.get("v")??"";if(s7.test(f))return{kind:"youtube-video",url:r,video:f}}return null}return o7.test(n.pathname)?{kind:"direct-audio",url:r,format:"hls"}:a7.test(n.pathname)?{kind:"direct-audio",url:r,format:"audio"}:/\.(html?|pls|m3u)$/i.test(n.pathname)?null:{kind:"direct-audio",url:r,format:"audio"}}function l7(e){return e==="1"}function c7(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=new Set,r=[];for(const s of t){if(!s||typeof s!="object")continue;const o=typeof s.id=="string"?s.id:"",i=typeof s.name=="string"?s.name.trim():"",c=typeof s.url=="string"?s.url.trim():"",d=Zh(c);if(!gk.test(o)||n.has(o)||!i||i.length>kc||!d)continue;n.add(o);const h=VO(s.radio);r.push({id:o,name:i,url:d.url,...h?{radio:h}:{}})}return r}function u7(e,t,n){const r=qi(e??"");return r&&t.some(s=>s.id===r)?ka(r):n(e)}function d7(e,t){return e===ka(t)?"claude-fm":e}function h7(){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 f7(e,t,n=h7()){const r=e.trim(),s=Zh(t);return!r||r.length>kc||!gk.test(n)||!s?null:{id:n,name:r,url:s.url}}function VO(e){if(!e||typeof e!="object")return null;const t=e,n=(s,o)=>typeof t[s]=="string"?t[s].slice(0,o):"",r=(s,o)=>typeof t[s]=="number"&&Number.isFinite(t[s])&&Math.abs(t[s])<=o?t[s]:null;return{...t.hls===!0?{hls:!0}:{},country:n("country",80),countryCode:n("countryCode",2),region:n("region",80),tags:n("tags",180),language:n("language",80),codec:n("codec",12),bitrate:typeof t.bitrate=="number"&&Number.isFinite(t.bitrate)?Math.max(0,Math.min(1e3,t.bitrate)):0,lat:r("lat",90),lon:r("lon",180)}}const Gb="https://www.youtube-nocookie.com";function p7(e,t,n){const r=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${Gb}/embed/${n?encodeURIComponent(n):"live_stream"}?${r.toString()}`}function ci(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function m7(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const g7=[1,3],y7=[0,2],w7=[2,5,100,101,150];function v7(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const{event:n,info:r}=t;if(n==="onReady")return{kind:"ready"};if(n==="onError"){const s=typeof r=="number"?r:Number(r==null?void 0:r.errorCode);return Number.isFinite(s)?{kind:"error",code:s}:null}if(n==="onStateChange"||n==="infoDelivery"){const s=typeof r=="number"?r:r==null?void 0:r.playerState;return typeof s!="number"||!Number.isFinite(s)?null:g7.includes(s)?{kind:"playing",playing:!0}:y7.includes(s)?{kind:"playing",playing:!1}:null}return null}const Ul=new Set;let a_="";function o_(e){const t=new Date().toISOString().slice(0,10);if(t!==a_&&(Ul.clear(),a_=t),!Ul.has(e)){Ul.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&Ul.delete(e)}catch{Ul.delete(e)}}}const i_=864e5,x7=6e4;function Qt(e,t=!0){y.useEffect(()=>{if(!t)return;o_(e);let n;const r=()=>{n=setTimeout(()=>{o_(e),r()},i_-Date.now()%i_+x7)};return r(),()=>clearTimeout(n)},[e,t])}const b7={"claude-fm":null,"lofi-relax":null,"lofi-game":null,"lofi-vibe":null,"lofi-sleep":null,"radio-mix":"/api/live-radio-mix","best-of-nostalgia":"/api/best-of-nostalgia","good-life-radio":"/api/good-life-radio","cafe-music-bgm":"/api/cafe-music-bgm"};function k7({fetchImpl:e,enabled:t=!0,volume:n,muted:r,source:s,playRequest:o,customStation:i,onAvailabilityChange:c}){var B;const[d,h]=y.useState(null),[f,p]=y.useState(!1),[g,w]=y.useState(!1),[N,k]=y.useState(!1),[x,b]=y.useState(!1);Qt("claude-fm",N);const j=y.useRef(o),S=y.useRef(null),E=y.useRef(null),T=y.useRef(void 0),I=y.useRef(null),A=y.useCallback(()=>{var F;clearTimeout(T.current),(F=E.current)==null||F.destroy(),E.current=null;const R=S.current;R&&(R.pause(),R.removeAttribute("src"),R.load(),S.current=null)},[]),D=y.useCallback(R=>{var F,O;(O=(F=I.current)==null?void 0:F.contentWindow)==null||O.postMessage(R,Gb)},[]),L=y.useRef(n);L.current=n;const U=y.useRef(r);U.current=r;const P=y.useCallback((R,F,O)=>{A();const G=new Audio;G.preload="none",G.volume=L.current/100,G.muted=U.current,S.current=G,w(!0),k(!1),b(!1);let Y=!1;const V=()=>S.current===G,q=()=>{clearTimeout(T.current),A(),w(!1),k(!1),b(!1)},M=()=>{V()&&(q(),p(!0),c==null||c(O,!0))},z=H=>{if(V()){if(H instanceof DOMException&&H.name==="NotAllowedError"){q();return}M()}};T.current=setTimeout(()=>{V()&&!Y&&M()},15e3),G.addEventListener("playing",()=>{V()&&(clearTimeout(T.current),Y=!0,k(!0),b(!1),c==null||c(O,!1))});const Z=()=>{V()&&(k(!1),b(Y),clearTimeout(T.current),T.current=setTimeout(()=>{V()&&M()},15e3))};G.addEventListener("waiting",Z),G.addEventListener("stalled",Z),G.addEventListener("ended",()=>{V()&&q()}),G.addEventListener("error",M,{once:!0}),F&&!G.canPlayType("application/vnd.apple.mpegurl")?Uc(async()=>{const{default:H}=await import("./hls-BFpXDghs.js");return{default:H}},[]).then(({default:H})=>{if(!V())return;if(!H.isSupported()){M();return}const X=new H;E.current=X,X.on(H.Events.ERROR,(K,Q)=>{Q.fatal&&M()}),X.on(H.Events.MEDIA_ATTACHED,()=>X.loadSource(R)),X.on(H.Events.MANIFEST_PARSED,()=>{G.play().catch(z)}),X.attachMedia(G)},M):(G.src=R,G.play().catch(z))},[c,A]);y.useEffect(()=>{g&&(D(ci("setVolume",[n])),D(ci(r?"mute":"unMute")),S.current&&(S.current.volume=n/100,S.current.muted=r))},[n,r,g,D]),y.useEffect(()=>{var q;let R=!0;const F=e??fetch,O=j.current!==o;if(j.current=o,h(null),p(!1),b(!1),w(O),k(O),A(),!t){w(!1),k(!1);return}const G=i&&ka(i.id)===s?Zh(i.url):null;if(G){if(G.kind==="direct-audio"){const M=G.format==="hls"||((q=i==null?void 0:i.radio)==null?void 0:q.hls)===!0;return h({live:!0,channel:"",audio:G.url,hls:M}),c==null||c(s,!1),O&&P(G.url,M,s),()=>{R=!1}}return F(`/api/fm-station?url=${encodeURIComponent(G.url)}`).then(M=>M.ok?M.json():null).then(M=>{R&&(M!=null&&M.channel||M!=null&&M.video?(h({live:!0,channel:M.channel??"",video:M.video??void 0}),c==null||c(s,!1)):(p(!0),c==null||c(s,!0)))}).catch(()=>{R&&(p(!0),c==null||c(s,!0))}),()=>{R=!1}}if(qi(s))return p(!0),c==null||c(s,!0),()=>{R=!1};const Y=s,V=b7[Y];if(V)F(V).then(M=>M.ok?M.json():null).then(M=>{R&&(M!=null&&M.video&&h({live:!0,channel:"",video:M.video}),M!=null&&M.video||(p(!0),w(!1),k(!1)),c==null||c(s,!(M!=null&&M.video)))}).catch(()=>{R&&(p(!0),w(!1),k(!1),c==null||c(s,!0))});else if(Y!=="claude-fm"){const M=Y.replace("lofi-","");F(`/api/lofi-girl?station=${encodeURIComponent(M)}`).then(z=>z.ok?z.json():null).then(z=>{R&&(z!=null&&z.video&&h({live:!0,channel:"",video:z.video}),z!=null&&z.video||(p(!0),w(!1),k(!1)),c==null||c(s,!(z!=null&&z.video)))}).catch(()=>{R&&(p(!0),w(!1),k(!1),c==null||c(s,!0))})}else F("/api/claude-fm").then(M=>M.ok?M.json():null).then(M=>{if(!R)return;const z=!!(M!=null&&M.live&&(M!=null&&M.channel));z&&h({live:!0,channel:M.channel}),z||(p(!0),w(!1),k(!1)),c==null||c(s,!z)}).catch(()=>{R&&(p(!0),w(!1),k(!1),c==null||c(s,!0))});return()=>{R=!1}},[i==null?void 0:i.id,i==null?void 0:i.url,(B=i==null?void 0:i.radio)==null?void 0:B.hls,t,e,c,o,s,P,A]),y.useEffect(()=>()=>A(),[A]),y.useEffect(()=>{if(!g)return;const R=F=>{var G;if(F.origin!==Gb||F.source!==((G=I.current)==null?void 0:G.contentWindow))return;const O=v7(F.data);if(O){if(O.kind==="ready"){D(ci("setVolume",[L.current])),D(ci(r?"mute":"unMute")),D(ci("playVideo"));return}if(O.kind==="playing"){k(O.playing);return}w7.includes(O.code)&&(w(!1),k(!1),p(!0),c==null||c(s,!0))}};return window.addEventListener("message",R),()=>window.removeEventListener("message",R)},[g,r,c,D,s]);const $=y.useCallback(()=>{if(!d)return;if(d.audio){if(g){A(),w(!1),k(!1),b(!1);return}P(d.audio,d.hls===!0,s);return}if(!g){w(!0),k(!0);return}const R=!N;k(R),D(ci(R?"playVideo":"pauseVideo")),R||w(!1)},[d,g,N,s,D,P,A]);return y.useMemo(()=>({probe:d,dead:f,armed:g,playing:N,buffering:x,frame:I,say:D,press:$}),[d,f,g,N,x,D,$])}const l_="agent-dag.radio-favorites",c_="agent-dag.radio-recent",u_="agent-dag.radio-catalogue";function N7(e){if(!Array.isArray(e))return[];const t=new Set;return e.slice(0,300).flatMap(n=>{if(!n||typeof n!="object")return[];const r=n,s=typeof r.id=="string"?r.id:"",o=typeof r.name=="string"?r.name.trim().slice(0,80):"",i=typeof r.url=="string"?Zh(r.url):null,c=VO(r.radio??r);return!/^radio-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(s)||!o||!c||!i||i.kind!=="direct-audio"||t.has(s)?[]:(t.add(s),[{id:s,name:o,url:i.url,radio:c}])})}function d_(e){try{const t=JSON.parse(e??"[]");return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&/^[A-Za-z0-9_-]{1,80}$/.test(n)))].slice(0,100):[]}catch{return[]}}function j7(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function Npe(e,t,n=Math.random){const r=e.filter(s=>s.id!==t);return r.length?r[Math.min(r.length-1,Math.floor(Math.max(0,n())*r.length))]:null}function jpe(e,t,n){if(!e.length)return null;const r=e.findIndex(o=>o.id===t),s=e[r<0?n===1?0:e.length-1:(r+n+e.length)%e.length];return s.id===t?null:s}function GO(e,t,n){const r=e.findIndex(s=>s.id===t);for(let s=1;s<=e.length;s++){const o=e[(r+s)%e.length];if(o.id!==t&&!n.has(o.id))return o}return null}function Spe(e,t){if(!e.length)return null;const n=[...e].sort((s,o)=>s.id.localeCompare(o.id));let r=0;for(const s of t)r=Math.imul(r,31)+s.charCodeAt(0)>>>0;return n[r%n.length]}function _pe(e,t,n,r,s){return(!t||`${e.name} ${e.radio.country} ${e.radio.region} ${e.radio.tags}`.toLowerCase().includes(t.toLowerCase()))&&(!n||e.radio.countryCode===n)&&(!r||e.radio.tags.toLowerCase().includes(r.toLowerCase()))&&(!s||e.radio.language.toLowerCase().includes(s.toLowerCase()))}function S7(){const[e,t]=y.useState(()=>d_(Ke(l_))),[n,r]=y.useState(()=>d_(Ke(c_))),[s,o]=y.useState(()=>{try{return N7(JSON.parse(Ke(u_)??"[]"))}catch{return[]}});y.useEffect(()=>{Ge(l_,JSON.stringify(e))},[e]),y.useEffect(()=>{Ge(c_,JSON.stringify(n))},[n]);const i=y.useCallback(h=>r(f=>j7(f,h)),[]),c=y.useCallback(h=>t(f=>f.includes(h)?f.filter(p=>p!==h):[...f,h].slice(-100)),[]),d=y.useCallback(h=>{o(h),Ge(u_,JSON.stringify(h))},[]);return{favorites:e,recent:n,catalogue:s,remember:i,toggleFavorite:c,updateCatalogue:d}}function _7(e,t,n,r){const s=GO(e,t,n);if(!s)return()=>{};const o=setTimeout(()=>{n.add(t),r(s)},1e3);return()=>clearTimeout(o)}const Jh=148,h_=6e3,E7=16e3,KO=46,ya=34;function C7(e,t,n=Jh){let r=-Math.round(t()*n);if(Math.abs(r-e)<ya){const s=e-ya>=-n?-ya:ya;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return{to:r,ms:Math.round(Math.abs(r-e)*KO)}}function T7(e){return Math.round(h_+e()*(E7-h_))}const f_=[{kind:"stroll",weight:44},{kind:"tidy",weight:17},{kind:"kick",weight:17},{kind:"sit",weight:12},{kind:"watch",weight:16},{kind:"leave",weight:7},{kind:"fish",weight:12},{kind:"skip",weight:10}];function R7(e){const t=f_.reduce((r,s)=>r+s.weight,0);let n=e()*t;for(const r of f_)if(n-=r.weight,n<0)return r.kind;return"stroll"}const A7=720,M7=260,$7=620,I7=220,p_=520,YO=1600,m_=7e3,O7=15e3,g_=6e3,L7=14e3;function ui(e,t,n=Jh){let r=-Math.round(t()*n);if(Math.abs(r-e)<ya){const s=e-ya>=-n?-ya:ya;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return r}const Ht=(e,t)=>Math.round(Math.abs(t-e)*KO),P7=120,vd=0;function D7(e,t){const n=r=>({kind:"litter",at:t,...r});return[{x:t,prop:n({}),act:"walk",ms:Ht(e,t)},{x:t,prop:n({}),act:"stoop",ms:A7},{x:vd,prop:n({held:!0}),act:"carry",ms:Ht(t,vd)},{x:vd,prop:n({held:!0}),act:"windup",ms:M7},{x:vd,prop:n({held:!0,leaving:!0}),act:"toss",ms:$7}]}function F7(e,t){const n=t>e?1:-1,r=t-n*Math.min(15,Math.abs(t-e)),s=(o={})=>({kind:"ball",at:t,...o});return[{x:r,prop:s(),act:"walk",ms:Ht(e,r)},{x:r,prop:s(),act:"windup",ms:I7,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"kick",ms:p_,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"stand",ms:YO-p_}]}const XO=640;function B7(e,t,n){const r=Math.max(-70,Math.min(-20,t)),s={x:r,prop:null,facing:"left"};return[{x:r,prop:null,act:"walk",ms:Ht(e,r)},{...s,act:"sit",ms:600},{...s,act:"cast",ms:900},{...s,act:"fish",ms:6e3+Math.round(n()*4e3)},{...s,act:"reel",ms:1200},{...s,act:"stow",ms:500},{...s,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:Ht(r,0)}]}function q7(e,t,n){const r=Math.max(-110,Math.min(-30,t)),s={x:r,prop:null};return[{...s,act:"walk",ms:Ht(e,r)},{...s,act:"skip-ready",ms:500},{...s,act:"skip",ms:XO*(6+Math.floor(n()*5))},{...s,act:"skip-rest",ms:600},{...s,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Ht(r,0)}]}function U7(e,t,n){return[{x:t,prop:null,act:"walk",ms:Ht(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(g_+n()*(L7-g_))},{x:t,prop:null,act:"stand",ms:400}]}function H7(e,t,n){t=Math.max(-110,Math.min(0,t));const r=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:Ht(e,t)},{x:t,prop:r(),act:"watch",ms:Math.round(m_+n()*(O7-m_))},{x:t,prop:r(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Lm(e,t,n){return e.facing?e.facing:e.act==="watch"||e.act==="scope-pack"?"left":e.x===t?n:e.x>t?"right":"left"}const W7=1500,z7=e=>Math.round(1e3*Math.sqrt(2*e/W7)),V7=115,G7=e=>Math.round(e/V7*1e3),K7=620,Y7=200,X7=760,Z7=600,J7=240;function Q7(e,t,n){const s=-(t.ledgeSpan??Jh),o=z7(t.ledgeH),i=G7(t.ledgeH),c=n(),d=n(),h=-Math.round(c*t.floorSpan),f=-Math.round(d*t.floorSpan);return[{x:s,act:"walk",prop:null,ms:Ht(e,s)},{x:s,act:"peer",prop:null,ms:K7},{x:s,act:"fall",prop:null,ms:o,place:"floor"},{x:s,act:"land",prop:null,ms:Y7,place:"floor"},{x:h,act:"walk",prop:null,ms:Ht(s,h),place:"floor",floorFrac:c},{x:f,act:"walk",prop:null,ms:Ht(h,f),place:"floor",floorFrac:d},{x:s,act:"walk",prop:null,ms:Ht(f,s),place:"floor"},{x:s,act:"lasso",prop:null,ms:X7,place:"floor"},{x:s,act:"rope-throw",prop:null,ms:Z7,place:"floor"},{x:s,act:"rope-catch",prop:null,ms:J7,place:"floor"},{x:s,act:"climb",prop:null,ms:i},{x:s,act:"pull-up",prop:null,ms:480}]}function e9(e,t,n){const r=(n==null?void 0:n.ledgeSpan)??Jh;switch(R7(t)){case"tidy":return D7(e,ui(e,t,r));case"kick":return F7(e,ui(e,t,r));case"sit":return U7(e,ui(e,t,r),t);case"watch":return H7(e,ui(e,t,r),t);case"fish":return B7(e,ui(e,t,r),t);case"skip":return q7(e,ui(e,t,r),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return Q7(e,n,t)}}const o=C7(e,t,r);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const t9=420;function n9(e,t,n){const r=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(t9,Math.max(0,r))}const r9=260,s9=200;function a9(e,t,n){const r=(f,p=Ht(e,f))=>({x:f,prop:null,act:"walk",ms:p,place:"floor"});if(!n||n.height<=0)return[r(t)];const s=Math.min(e,t);if(Math.max(e,t)<=n.left||s>=n.right)return[r(t)];const i=t>e,c=i?n.left:n.right,d=i?n.right:n.left,h={place:"floor",riser:n.height,prop:null};return[r(c,Ht(e,c)),{...h,x:c,act:"mount",ms:r9},{...h,x:d,act:"walk",ms:Ht(c,d)},{x:d,prop:null,act:"dismount",ms:s9,place:"floor"},{x:t,prop:null,act:"walk",ms:Ht(d,t),place:"floor"}]}const ZO=["bob","sway","groove"],y_=9e3,o9=16e3,JO=1e3,i9=.08;function l9(e,t){const n=ZO.filter(o=>o!==e),r=n[Math.min(n.length-1,Math.floor(t()*n.length))],s=(t()*2-1)*i9;return{dance:r,beatMs:Math.round(JO*(1+s))}}function c9(e){return Math.round(y_+e()*(o9-y_))}const yk=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],w_=18,u9=yk.length,QO="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",eL="M12 9H14V6H13V3H11V2H9V4H12Z",wk=new Set(["a","c","p"]);function _a(e=yk){const t=[];return e.forEach((n,r)=>{let s=0;for(;s<n.length;){const o=n[s];if(o==="."){s+=1;continue}let i=1;for(;s+i<n.length&&n[s+i]===o;)i+=1;t.push({x:s,y:r,w:i,cell:o}),s+=i}}),t}const d9=[".xx.","xxxx",".xx."],h9=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],f9=["...xx...............","..xaax..............",".xaallx.............","xaallllx............",".xllllllx...........","..xllllllx..........","...xllllllx.........","....xllllllxx.......",".....xllllxsxx..xx..","......xllxsssx.xllxx",".......xxssssxxxllxx","........xssssssxx...",".........xssssx.....","..........xxxx......","..........xax.......",".........xxxxx......","........xx.x.xx.....","........xl.x.lx.....",".......xl..x..lx....",".......xl..x..lx....","......xl...x...lx...","......xl...x...lx...",".....xl....x....lx..","....xxx...xxx...xxx."],Pm={litter:d9,ball:h9,scope:f9},p9=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],m9=3,g9=-1,Kb=11,v_=9;function x_(e){let t=null,n=null,r=0,s=0,o=!1;const i=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(s=performance.now(),t=setTimeout(()=>{t=null;const h=n;n=null,h==null||h()},r))},d=()=>{e.hidden&&t!==null?(r=Math.max(0,r-(performance.now()-s)),i()):e.hidden||c()};return e.addEventListener("visibilitychange",d),{schedule(h,f){o||(i(),n=h,r=Math.max(0,f),c())},dispose(){o=!0,i(),n=null,e.removeEventListener("visibilitychange",d)}}}function y9(e,t,n){const[r,s]=y.useState(0),[o,i]=y.useState(0),[c,d]=y.useState(null),[h,f]=y.useState(null),[p,g]=y.useState({x:0,drop:0}),[w,N]=y.useState("ledge"),[k,x]=y.useState("left"),[b,j]=y.useState(0),S=y.useRef(null),[E,T]=y.useState(()=>document.hidden);y.useEffect(()=>{const $=new Set,B=()=>{var R;if(document.hidden){for(const F of((R=S.current)==null?void 0:R.getAnimations({subtree:!0}))??[])if(F.playState==="running"||F.pending){const O=F.currentTime;F.pause(),O!==null&&(F.currentTime=O),$.add(F)}}else{for(const F of $)F.playState==="paused"&&F.play();$.clear()}T(document.hidden)};return B(),document.addEventListener("visibilitychange",B),()=>document.removeEventListener("visibilitychange",B)},[e,t]);const[I,A]=y.useState(null),[D,L]=y.useState(JO),[U,P]=y.useState(()=>{var $;return(($=window.matchMedia)==null?void 0:$.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return y.useEffect(()=>{var R;const $=(R=window.matchMedia)==null?void 0:R.call(window,"(prefers-reduced-motion: reduce)");if(!$)return;const B=()=>P($.matches);return B(),$.addEventListener("change",B),()=>$.removeEventListener("change",B)},[]),y.useEffect(()=>{var Q;if(!e||t||U)return;const $=x_(document);let B=0;s(ee=>B=ee);let R=null,F=0,O=0;const G=ee=>{var se,me;const[re,...ie]=ee;if(!re){R=null,d(null),f(null),H();return}d(re.act),f(re.prop),N(re.place??"ledge"),j(re.riser??0);const de=B,pe=z(re);if(re.act==="kick"){const he=(me=(se=S.current)==null?void 0:se.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:me.getBoundingClientRect();he&&g({x:n9(he.x,Lm(re,de,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-he.y+24)})}O=re.act==="walk"?Math.max(Ht(de,pe),P7):re.ms,re.act==="carry"&&(O=Ht(de,pe)),i(O),x(he=>Lm({...re,x:pe},de,he)),s(pe),B=pe,R=re,F=Date.now(),$.schedule(()=>G(ie),O)},Y=()=>{const ee=S.current,re=ee==null?void 0:ee.querySelector(".fm-sprite"),ie=ee==null?void 0:ee.parentElement;if(!ee||!re||!ie)return null;const de=ee.getBoundingClientRect(),pe=ie.getBoundingClientRect(),se=pe.right-de.right,me=pe.width-se*2-re.offsetWidth;return me>0?me:null},V=()=>{const ee=S.current,re=ee==null?void 0:ee.querySelector(".fm-sprite");return!ee||!re?0:Math.max(0,ee.getBoundingClientRect().width-re.offsetWidth)},q=()=>{const ee=S.current,re=ee==null?void 0:ee.querySelector(".fm-walker"),ie=Y();if(!ee||!re||ie==null)return;const de=ee.getBoundingClientRect().bottom-re.getBoundingClientRect().bottom;if(de>0)return{ledgeH:de,floorSpan:ie,ledgeSpan:V()}},M=()=>{const ee=S.current,re=document.querySelector(".canvas-notices");if(!ee||!re)return null;const ie=ee.getBoundingClientRect(),de=re.getBoundingClientRect();return de.width<=0||de.height<=0?null:{left:de.left-ie.right,right:de.right-ie.right,height:de.height}},z=ee=>{const re=(ee.place??"ledge")==="floor",ie=re?Y()??V():V(),de=re&&ee.floorFrac!=null?-Math.round(ee.floorFrac*ie):ee.x;return Math.max(-ie,Math.min(0,de))},Z=()=>{if(!R)return;const ee=z(R);ee!==B&&(i(Math.max(0,F+O-Date.now())),x(re=>Lm({...R,x:ee},B,re)),s(ee),B=ee)},H=()=>{$.schedule(()=>{const ee=e9(B,Math.random,q()),re=ee.some(pe=>pe.place==="floor")?M():null;let ie=B;const de=ee.flatMap(pe=>{const se=ie;if(ie=pe.x,!(pe.place==="floor"&&pe.act==="walk"))return[pe];const me=a9(se,pe.x,re),he=me.length-1;return pe.floorFrac==null?me:me.map((le,ue)=>ue===he?{...le,floorFrac:pe.floorFrac}:le)});G(de)},T7(Math.random))},X=(Q=S.current)==null?void 0:Q.parentElement,K=typeof ResizeObserver>"u"?null:new ResizeObserver(Z);return X&&K&&K.observe(X),H(),()=>{$.dispose(),K==null||K.disconnect(),N("ledge"),s(ee=>Math.max(-V(),Math.min(0,ee))),i(0),d(null),f(null),j(0)}},[e,t,U]),y.useEffect(()=>{if(!n||U){A(null);return}const $=x_(document),B=R=>{const F=l9(R,Math.random);A(F.dance),L(F.beatMs),$.schedule(()=>B(F.dance),c9(Math.random))};return B(null),()=>$.dispose()},[n,U]),{scene:S,suspended:E,x:r,walkMs:o,act:c,prop:h,ballFlight:p,place:w,facing:k,riser:b,dance:I,beatMs:D}}const Dm={e:"fm-eye",s:"fm-shade",p:"fm-pad"},lh=_a().filter(e=>!wk.has(e.cell)),w9=_a().filter(e=>wk.has(e.cell)),b_=lh.filter(e=>e.cell==="e"),v9=_a(p9),x9=lh.filter(e=>e.y<Kb&&e.cell!=="e").map(e=>{if(e.y!==8&&e.y!==9)return e;const t=Math.max(6,e.x);return{...e,x:t,w:Math.max(0,Math.min(12,e.x+e.w)-t)}}).filter(e=>e.w>0),b9={left:lh.filter(e=>e.y>=Kb&&e.x<v_),right:lh.filter(e=>e.y>=Kb&&e.x>=v_)},k9=y.memo(function({act:t,facing:n}){return a.jsxs("svg",{viewBox:`0 0 ${w_} ${u9}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:w9.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Dm[r.cell]},`g${r.y}-${r.x}`))})}),a.jsxs("g",{className:"fm-body",children:[b_.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:"var(--accent)"},`eye-bed-${r.x}`)),x9.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Dm[r.cell]},`b${r.y}-${r.x}`)),a.jsxs("g",{className:"fm-arms",children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2}),a.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),b_.map(r=>a.jsx("rect",{x:r.x-(r.x>=w_/2?1:0)+(n==="right"?1:0),y:r.y,width:r.w,height:1,className:"fm-eye"},`eye-${r.x}`))]}),a.jsx("g",{className:"fm-hat",children:v9.map(r=>a.jsx("rect",{x:m9+r.x,y:g9+r.y,width:r.w,height:1,className:r.cell==="k"?"fm-hatband":void 0},`h${r.y}-${r.x}`))}),(t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up")&&a.jsxs("g",{className:"fm-grip",children:[a.jsx("path",{className:"fm-grip-left",d:QO}),a.jsx("path",{className:"fm-grip-right",d:eL})]}),(t==="land"||t==="dismount")&&a.jsxs("g",{className:"fm-crouch-legs",children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&a.jsxs("g",{className:"fm-seated-legs",children:[a.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(r=>a.jsx("g",{className:"fm-leg","data-side":r,children:b9[r].map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Dm[s.cell]},`${r}${s.y}-${s.x}`))},r))]})}),N9=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],j9=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],Vr={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},S9={p:"fm-pad"},Nc=_a(N9),_9=_a(j9);function Yb(e,t,n){return e.map(r=>({...r,x:Math.max(t,r.x),w:Math.max(0,Math.min(n,r.x+r.w)-Math.max(t,r.x))})).filter(r=>r.w>0)}const E9=Yb(Nc.filter(e=>e.y>=8),12,18),C9=Nc.filter(e=>e.y<11&&e.cell!=="e").map(e=>e.y===8||e.y===9?{...e,x:Math.max(6,e.x),w:Math.max(0,Math.min(12,e.x+e.w)-Math.max(6,e.x))}:e.y===10?{...e,w:Math.max(0,Math.min(12,e.x+e.w)-e.x)}:e).filter(e=>e.w>0),k_=Nc.filter(e=>e.cell==="e"),T9={left:Yb(Nc.filter(e=>e.y>=11),0,9),right:Yb(Nc.filter(e=>e.y>=11),9,12)},R9=y.memo(function({act:t,facing:n}){const r=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",s=t==="land"||t==="dismount",o=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return a.jsxs("svg",{"data-character":"fox",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[a.jsx("g",{className:"fm-body","data-part":"tail",children:E9.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Vr[i.cell]},`t${i.y}-${i.x}`))}),a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:_9.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:S9[i.cell]},`g${i.y}-${i.x}`))})}),a.jsxs("g",{className:"fm-body",children:[C9.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Vr[i.cell]},`b${i.y}-${i.x}`)),k_.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Vr.f},`bed${i.x}`)),a.jsxs("g",{className:"fm-arms",fill:Vr.f,children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2})]}),k_.map(i=>a.jsx("rect",{x:i.x+(n==="right"?1:0)-(i.x>=9?1:0),y:i.y,width:i.w,height:1,className:"fm-eye",style:{fill:Vr.n}},`e${i.x}`))]}),r&&a.jsxs("g",{className:"fm-grip",style:{fill:Vr.f},children:[a.jsx("path",{className:"fm-grip-left",d:QO}),a.jsx("path",{className:"fm-grip-right",d:eL})]}),s&&a.jsxs("g",{className:"fm-crouch-legs",style:{fill:Vr.f},children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&a.jsxs("g",{className:"fm-seated-legs",style:{fill:Vr.f},children:[a.jsx("path",{className:"fm-seated-far",style:{fill:Vr.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(i=>a.jsx("g",{className:"fm-leg","data-side":i,children:T9[i].map(c=>a.jsx("rect",{x:c.x,y:c.y,width:c.w,height:1,fill:Vr[c.cell]},`${c.y}-${c.x}`))},i))]})}),A9=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],ks={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},M9={p:"fm-pad"},ch=_a(A9),$9=_a(yk).filter(e=>wk.has(e.cell)),N_=ch.filter(e=>e.cell==="e"),I9=ch.filter(e=>e.y<12&&e.cell!=="e"),O9={left:ch.filter(e=>e.y>=12&&e.x<9),right:ch.filter(e=>e.y>=12&&e.x>=9)},L9=y.memo(function({act:t}){const n=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",r=t==="land"||t==="dismount",s=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return a.jsxs("svg",{"data-character":"penguin",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:$9.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:M9[o.cell]},`g${o.y}-${o.x}`))})}),a.jsxs("g",{className:"fm-body",children:[I9.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:ks[o.cell]},`b${o.y}-${o.x}`)),N_.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:ks.w},`bed${o.x}`)),a.jsxs("g",{className:"fm-arms",fill:ks.d,children:[a.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),a.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),N_.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:ks.e}},`e${o.x}`))]}),n&&a.jsxs("g",{className:"fm-grip",style:{fill:ks.h},children:[a.jsx("path",{className:"fm-grip-left",d:"M5 10H4V4H5V2H6V1H7V0H9V2H7V3H6V10Z"}),a.jsx("path",{className:"fm-grip-right",d:"M12 10H14V6H13V3H11V2H9V4H12Z"})]}),r&&a.jsxs("g",{className:"fm-crouch-legs",style:{fill:ks.b},children:[a.jsx("path",{d:"M5 12H8V13H5Z"}),a.jsx("path",{d:"M10 12H13V13H10Z"})]}),s&&a.jsxs("g",{className:"fm-seated-legs",style:{fill:ks.b},children:[a.jsx("path",{className:"fm-seated-far",style:{fill:ks.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),a.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>a.jsx("g",{className:"fm-leg","data-side":o,children:O9[o].map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ks.b},`${i.y}-${i.x}`))},o))]})});function tL({character:e,act:t,facing:n}){return e==="penguin"?a.jsx(L9,{act:t,facing:n}):e==="fox"?a.jsx(R9,{act:t,facing:n}):a.jsx(k9,{act:t,facing:n})}const P9={"claude-fm":"Claude FM","lofi-relax":"Lofi Girl relax/study","lofi-game":"Lofi Girl chill/game","lofi-vibe":"Lofi Girl vibe/chill","lofi-sleep":"Lofi Girl sleep/chill","radio-mix":"Radio Mix Live","best-of-nostalgia":"Best of Nostalgia Live","good-life-radio":"The Good Life Radio Live","cafe-music-bgm":"Cafe Music BGM Live"};function nL(e,t){return t&&ka(t.id)===e?t.name:qi(e)?"Custom FM":P9[e]}function Fm(e,t){var r;const n=((r=e[0])==null?void 0:r.length)??0;return a.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:_a(e).map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:s.cell==="s"?"var(--fm-prop-shadow, var(--bg))":s.cell==="l"?"var(--fm-prop-light, var(--text))":s.cell==="a"?"var(--accent)":void 0},`${t}${s.y}-${s.x}`))})}const j_={litter:Fm(Pm.litter,"litter"),ball:Fm(Pm.ball,"ball"),scope:Fm(Pm.scope,"scope")};function D9(e){try{return new URL(e).host}catch{return"the station's server"}}const F9=y.memo(function({player:t,source:n,customStation:r,character:s="deck"}){const{probe:o,dead:i,playing:c,press:d}=t,{scene:h,suspended:f,x:p,walkMs:g,act:w,prop:N,ballFlight:k,place:x,facing:b,riser:j,dance:S,beatMs:E}=y9(o,i,c);if(!o||i)return null;const T=nL(n,r),I=o.audio?D9(o.audio):"YouTube";return a.jsxs("div",{ref:h,className:"fm","data-suspended":f?"":void 0,"data-place":x,style:{"--fm-beat":`${E}ms`},children:[N&&!N.held&&a.jsx("div",{className:"fm-prop","data-prop":N.kind,"data-leaving":N.leaving?"":void 0,style:{"--fm-prop-x":`${N.at}px`,"--fm-roll-to":`${k.x}px`,"--fm-ball-drop":`${k.drop}px`,"--fm-ball-flight-ms":`${YO}ms`,"--fm-ball-turn":b==="right"?"1080deg":"-1080deg"},children:j_[N.kind]}),(w==="lasso"||w==="rope-throw"||w==="rope-catch"||w==="climb"||w==="pull-up")&&a.jsxs("div",{className:"fm-rope","data-act":w,style:{"--fm-rope-x":`${p}px`,"--fm-rope-ms":`${g}ms`},children:[a.jsx("div",{className:"fm-rope-line"}),a.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),a.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),a.jsxs("div",{className:"fm-walker","data-act":w??void 0,"data-place":x,"data-facing":b,style:{"--fm-x":`${p}px`,"--fm-walk-ms":`${g}ms`,"--fm-riser":`${j}px`,"--fm-skip-beat":`${XO}ms`},children:[(N==null?void 0:N.held)&&a.jsx("div",{className:"fm-held","data-prop":N.kind,"data-toss":N.leaving?"":void 0,children:j_[N.kind]}),["cast","fish","reel","stow"].includes(w)&&a.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsxs("g",{children:[a.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),a.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),a.jsxs("g",{className:"fm-fishing-line",children:[a.jsx("path",{d:"M8 2V26"}),a.jsxs("g",{className:"fm-float",children:[a.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),a.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),a.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(w)&&a.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),a.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),a.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),a.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),a.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),a.jsx("button",{type:"button",className:"fm-sprite","data-playing":c?"":void 0,"data-dance":c?S??ZO[0]:void 0,onClick:d,title:c?`Stop ${T}`:`Play ${T} — streams from ${I}`,"aria-label":c?`Stop ${T}`:`Play ${T}`,children:a.jsx(tL,{character:s,act:w,facing:b})})]})]})});function B9({player:e,label:t}){const{probe:n,armed:r,frame:s,say:o}=e;return n?a.jsx(a.Fragment,{children:r&&!n.audio&&(n.channel||n.video)&&a.jsx("iframe",{ref:s,className:"fm-frame",title:t,src:p7(n.channel,window.location.origin,n.video),onLoad:()=>o(m7()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const q9={radio:"M4 8h16v12H4z M7 8l10-5 M7 12h5 M15 12h2 M7 16h2 M13 16h4",play:"M8 5l11 7-11 7z",pause:"M8 5v14 M16 5v14",shuffle:"M3 6h3c5 0 7 12 12 12h3 M17 14l4 4-4 4 M3 18h3c2 0 4-3 6-6s4-6 6-6h3 M17 2l4 4-4 4",heart:"M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1.1-1.1a5.5 5.5 0 0 0-7.8 7.8L12 21l8.8-8.6a5.5 5.5 0 0 0 0-7.8z",close:"M6 6l12 12 M6 18L18 6",search:"M10.5 3a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15 M16 16l5 5",globe:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20 M2 12h20 M12 2c-6 6-6 14 0 20 M12 2c6 6 6 14 0 20",back:"M16 5l-7 7 7 7",previous:"M5 5v14 M19 5l-10 7 10 7z",next:"M19 5v14 M5 5l10 7-10 7z",volume:"M11 4L6 8H3v8h3l5 4z M15 8a6 6 0 0 1 0 8 M18 5a10 10 0 0 1 0 14",muted:"M11 4L6 8H3v8h3l5 4z M16 9l6 6 M16 15l6-6"};function U9({name:e}){return a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:q9[e]})})}function H9({opening:e=!1}){const[t,n]=y.useState(()=>document.hidden);return y.useEffect(()=>{const r=()=>n(document.hidden);return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)},[]),a.jsxs("div",{className:"radio-tuning",role:"status","data-paused":t||void 0,children:[a.jsxs("svg",{className:"radio-tuning-art",viewBox:"0 0 240 112",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsxs("g",{className:"radio-tuning-tower",children:[a.jsx("circle",{cx:"40",cy:"24",r:"4"}),a.jsx("path",{d:"M40 28v60 M40 36L24 88h32L40 36 M31 66h18 M28 77h24 M20 92h40"}),a.jsx("path",{d:"M29 17a15 15 0 0 0 0 14 M51 17a15 15 0 0 1 0 14"})]}),a.jsxs("g",{className:"radio-tuning-send",children:[a.jsx("path",{d:"M75 26q7 8 0 16"}),a.jsx("path",{d:"M102 26q7 8 0 16"}),a.jsx("path",{d:"M129 26q7 8 0 16"})]}),a.jsxs("g",{className:"radio-tuning-receiver",children:[a.jsx("path",{d:"M165 49l30-22"}),a.jsx("rect",{x:"154",y:"49",width:"66",height:"43",rx:"7"}),a.jsx("path",{d:"M161 92v3 M213 92v3 M163 60h17 M163 66h17 M163 72h17 M163 78h17"}),a.jsx("circle",{cx:"202",cy:"65",r:"7"}),a.jsx("path",{d:"M202 62v3l3 2 M197 81h10"})]})]}),a.jsx("strong",{children:e?"Opening Radio":"Tuning into the world"}),a.jsx("span",{children:e?"Getting your explorer ready…":"Finding stations…"})]})}function W9({onClose:e}){const[t]=y.useState(()=>{var r;return((r=document.activeElement)==null?void 0:r.matches(":focus-visible"))??!1}),n=pt(e);return a.jsxs("div",{ref:n,className:"radio-loading nodrag nopan",role:"dialog","aria-modal":"true","aria-label":"Opening Radio","data-keyboard-interaction":t||void 0,onKeyDown:NW,children:[a.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close radio",onClick:e,children:a.jsx(U9,{name:"close"})}),a.jsx(H9,{opening:!0})]})}const z9=y.lazy(()=>Uc(()=>import("./RadioPanel-N-duyYFJ.js"),[]));function V9({fm:e,characterEnabled:t,character:n,open:r,onClose:s}){const[o,i]=y.useState(!1),[c,d]=y.useState("Connecting to the deck…"),h=S7(),[f,p]=y.useState(null),g=y.useRef(new Set);y.useEffect(()=>{const I=new AbortController;return fetch("/api/music-config",{signal:I.signal}).then(A=>A.ok?A.json():null).then(A=>{I.signal.aborted||(i((A==null?void 0:A.enabled)===!0),d(A?"Music is turned off on this deck.":"Cannot reach the deck. Reopen Radio when it reconnects."))}).catch(()=>{I.signal.aborted||d("Cannot reach the deck. Reopen Radio when it reconnects.")}),()=>I.abort()},[r]);const w=e.customFmStations.find(I=>ka(I.id)===e.fmSource),N=w!=null&&w.radio?w:void 0,k=k7({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),x=nL(e.fmSource,w),b=o&&N&&k.dead&&e.fmPlayRequest>0?GO(f??h.catalogue,N.id,g.current):null,{remember:j}=h;y.useEffect(()=>{N&&k.playing&&j(N.id)},[N==null?void 0:N.id,k.playing,j]);const S=s,E=wt(s),T=y.useCallback((I,A=!1)=>{var P;if(!o)return;A||g.current.clear();const D=ka(I.id),L=D===e.fmSource;if(L&&k.armed&&!k.dead){k.press();return}const U=L&&!!w&&(w.url!==I.url||((P=w.radio)==null?void 0:P.hls)!==I.radio.hls);e.addFmStation(I,!0),L&&!k.dead&&!U?k.press():e.pickFmSource(D,U),fetch(`/api/radio-click?id=${encodeURIComponent(I.id)}`).catch(()=>{})},[o,w,e.addFmStation,e.fmSource,e.pickFmSource,k.armed,k.dead,k.press]);return y.useEffect(()=>{k.playing&&!k.dead&&g.current.clear()},[k.playing,k.dead]),y.useEffect(()=>{if(!(!o||!N||!k.dead||e.fmPlayRequest===0))return _7(f??h.catalogue,N.id,g.current,I=>T(I,!0))},[o,N==null?void 0:N.id,k.dead,e.fmPlayRequest,f,h.catalogue,T]),a.jsxs(a.Fragment,{children:[t&&a.jsx(F9,{character:n,player:k,source:e.fmSource,customStation:w}),a.jsx(B9,{player:k,label:x}),r&&Mt.createPortal(a.jsx("div",{className:"modal-backdrop radio-backdrop",...E,children:a.jsx(y.Suspense,{fallback:a.jsx(W9,{onClose:S}),children:a.jsx(z9,{fm:e,player:k,library:h,selected:N,label:x,enabled:o,disabledReason:c,autoNext:b==null?void 0:b.name,onPick:T,onQueueChange:p,onClose:S})})}),document.body)]})}function rL(e){const t=Math.max(0,e);return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function Xb(e){return rL(Math.floor(e/1e3))}function Qh(e,t){const n=e-t;if(n<=0)return null;const r=Math.floor(n/86400),s=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);return r>0?`${r}d ${s}h`:s>0?`${s}h ${o}m`:`${o}m`}function G9(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function uh(e,t,n){const r=new Date(e),s=Xb(t-e);return{label:G9(r,new Date(t))?s:`${s} · ${r.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:r.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function K9({data:e}){const t=jo(3e4),n=e.note,r=n.kind==="recap",s=uh(n.at,t),o=r?"recap-note":`recap-note is-status status-${n.kind}`,i=r?void 0:Yh(n);return a.jsxs("div",{className:o,role:"note","aria-label":r?"Claude Code's recap":`Session note: ${xa(n.kind)}`,"aria-description":i,style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"recap-note-head",title:i,children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(oh,{recap:r}),xa(n.kind)]}),a.jsx("span",{className:"recap-note-age",title:s.title,children:s.label}),a.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":r?"Hide the recap":"Hide this note",title:"Hide — the mark on the card brings it back",onClick:c=>{c.stopPropagation(),VW(e.noteKey)},children:"×"})]}),a.jsx("p",{className:"recap-note-text",title:rz(n.text,i),children:n.text}),n.reply&&a.jsxs("p",{className:"recap-note-reply",title:`suggested reply “${n.reply}”`,children:["suggested reply “",n.reply,"”"]}),a.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(oh,{recap:r}),xa(n.kind)]}),a.jsx("span",{className:"recap-face-age",children:s.label})]}),a.jsx("p",{className:"recap-face-text",children:n.text})]}),a.jsx(yo,{type:"source",position:Oe.Right,style:{background:"transparent",border:"none"}})]})}function ef(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function tf(e){return/mac|iphone|ipad/i.test(e)}const dh=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function Y9(e,t,n){return{positions:dh(e.positions),pinned:dh(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function X9(e,t){t.positions.clear();for(const[n,r]of dh(e.positions))t.positions.set(n,r);t.pinned.clear();for(const[n,r]of dh(e.pinned))t.pinned.set(n,r);t.provisional.clear();for(const n of e.provisional)t.provisional.add(n);t.layoutSig.current=e.layoutSig}const S_=7e3,Z9=2e3,J9=140,Q9="Layout re-arranged",eV="Layout re-arranged. Undo available.",__="Layout restored.",tV={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function nV(e,t=tV){let n=null,r=null,s=0,o=S_;const i=new Set,c=()=>{r!==null&&t.clear(r),r=null},d=()=>{c(),!(n===null||i.size>0)&&(s=t.now()+o,r=t.set(()=>{r=null,h()},o))};function h(){c(),i.clear(),n!==null&&(n=null,e(!1))}return{open(f){const p=n===null;n=f,o=S_,d(),p&&e(!0)},take(){const f=n;return h(),f},close:h,hold(f){n!==null&&(i.size===0&&r!==null&&(o=Math.max(0,s-t.now()),c()),i.add(f))},release(f){!i.delete(f)||i.size>0||n===null||(o=Math.max(o,Z9),d())},get isOpen(){return n!==null},get snapshot(){return n}}}function rV(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function sV(e){return tf(e)?"⌘Z":"Ctrl+Z"}function aV({undo:e}){const{open:t,said:n,undo:r,dismiss:s,hold:o,release:i}=e,c=Ni(t,J9),d=y.useRef(null);return y.useEffect(()=>t?On.push(s,0,"popover"):void 0,[t,s]),y.useEffect(()=>{var f;if(t)return;const h=d.current;h&&h.contains(document.activeElement)&&((f=h.closest("main"))==null||f.focus({preventScroll:!0}))},[t]),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:n}),ga(c)&&a.jsxs("div",{ref:d,className:c==="leaving"?"rearrange-undo leaving":"rearrange-undo",onPointerEnter:()=>o("hover"),onPointerLeave:()=>i("hover"),onFocus:()=>o("focus"),onBlur:h=>{h.currentTarget.contains(h.relatedTarget)||i("focus")},children:[a.jsx("span",{id:"rearrange-undo-state",className:"rearrange-undo-state",children:Q9}),a.jsxs("button",{type:"button",className:"rearrange-undo-act",onClick:r,"aria-describedby":"rearrange-undo-state","aria-keyshortcuts":"Meta+Z Control+Z",children:["Undo",a.jsx("span",{className:"rearrange-undo-key","aria-hidden":"true",children:sV(ef())})]})]})]})}function oV({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s,targetPosition:o,style:i}){const[c]=Z0({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:.35});return a.jsxs("g",{className:"recap-tie",style:i,children:[a.jsx("path",{className:"recap-tie-thread",d:c,vectorEffect:"non-scaling-stroke"}),a.jsx("path",{className:"recap-tie-beads",d:c,vectorEffect:"non-scaling-stroke"}),a.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),a.jsx("circle",{className:"recap-tie-end",cx:n,cy:r,r:3.5})]})}function Zb(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function hh(e,t){const n=Zb(e);return n?n.slice(-t):e.slice(-t)}function sL(e,t,n=4){const r=Zb(e);if(!r)return hh(e,n);let s=n;for(const o of t){if(o===e)continue;const i=Zb(o);let c=0;for(;c<r.length&&c<i.length&&r[r.length-1-c]===i[i.length-1-c];)c++;s=Math.max(s,c+1)}return r.slice(-s)}const oc=" · ",iV=32,lV=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function E_(e){return lV.test(e)?2:1}function C_(e,t=iV){const n=[...e];let r=0;for(const i of n)r+=E_(i);if(r<=t)return e;const s=[];let o=0;for(const i of n){const c=E_(i);if(o+c>t-1)break;s.push(i),o+=c}for(;s.length&&/[\s\-_.:/]/.test(s[s.length-1]);)s.pop();return`${s.join("")}…`}function cV(e,t,n,r,s=[],{branch:o,alarm:i=!1}={}){const c=(t==null?void 0:t.trim())??"",d=r?sL(n,s):void 0,h=[e,c||void 0,d].filter(Boolean),f=[e,o,c||void 0,d].filter(Boolean).join(oc);return{label:C_(e),name:c?C_(c):void 0,shortId:d,fullLabel:h.join(oc),title:`${i?"waiting on you: ":""}${f}
83
83
  Zoom to this session
84
84
  drag the wrapper to move the whole session`}}const oo=18,Jb=26,vk=12,uV=240,aL=16;function oL(e,t){return(e+uV)*(t||1)}function dV(e,t){return{position:"absolute",left:0,top:0,transform:`translate(${e.x}px, ${e.y}px)`,width:e.w,height:e.h,"--session-hue":t}}function hV(e,t,n,r){return{position:"absolute",left:e.x+aL,top:e.y-vk/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:r??oL(e.w,t),"--session-hue":n}}function fV(e){const t=new Map;for(const s of e){if(s.type!=="agent"&&s.type!=="recapNote")continue;const o=s.data;if(!(o!=null&&o.sessionId)||o.exitAt!=null||s.width==null||s.height==null)continue;const i=s.position.x,c=s.position.y,d=i+s.width,h=c+s.height,f=t.get(o.sessionId),p=pV(o);f?(f.minX=Math.min(f.minX,i),f.minY=Math.min(f.minY,c),f.maxX=Math.max(f.maxX,d),f.maxY=Math.max(f.maxY,h),p&&(f.label=p.label??f.label,f.name=p.name,f.alarm=p.alarm,f.branch=p.branch)):t.set(o.sessionId,{minX:i,minY:c,maxX:d,maxY:h,label:(p==null?void 0:p.label)??o.sessionId,name:p==null?void 0:p.name,alarm:(p==null?void 0:p.alarm)??!1,branch:p==null?void 0:p.branch})}const n=new Map;for(const[s,o]of t){const i=n.get(o.label);i?i.push(s):n.set(o.label,[s])}const r=[];for(const[s,o]of t){const i=n.get(o.label)??[],c=i.length>1;r.push({sessionId:s,...cV(o.label,o.name,s,c,i,{branch:o.branch,alarm:o.alarm}),x:o.minX-oo,y:o.minY-oo-Jb,w:o.maxX-o.minX+oo*2,h:o.maxY-o.minY+oo*2+Jb,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null})}return r}function pV(e){if(e.kind!=="root")return null;const t=e.branch;return{label:e.label,name:ck(e.sessionName,e.sessionTitle).face,alarm:Pn(e.waiting),branch:t&&t.total>0?MO(t):void 0}}function mV(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const r=e[n],s=t[n];if(r.sessionId!==s.sessionId||r.label!==s.label||r.name!==s.name||r.shortId!==s.shortId||r.alarm!==s.alarm||r.branch!==s.branch||r.fullLabel!==s.fullLabel||r.title!==s.title||r.x!==s.x||r.y!==s.y||r.w!==s.w||r.h!==s.h)return!1}return!0}const gV=20,Ns=4,yV=64,wV=".cat-filter-bar, .react-flow__panel, .autofit-chip, .rearrange-undo, .usage-panel, .sysdetail, .detail";function vV(e,t,n,r){const s=t.zoom||1,o=oL(e.w,s);if(n.width<=0||n.height<=0)return{maxWidth:o,hidden:!1};const i=(e.x+aL)*s+t.x,c=e.y*s+t.y-vk,d=c+gV;let h=Math.min(o,n.width-Ns-i),f=i<Ns||c<Ns||d>n.height-Ns;for(const p of r)if(!(p.top-Ns>=d||p.bottom+Ns<=c)&&!(p.right+Ns<=i)){if(p.left-Ns<=i){f=!0;break}h=Math.min(h,p.left-Ns-i)}return h<yV&&(f=!0),{maxWidth:Math.max(0,h),hidden:f}}function xV(e){const t=e.getBoundingClientRect(),n=[];for(const r of e.ownerDocument.querySelectorAll(wV)){const s=r.getBoundingClientRect(),o=Math.max(s.left,t.left)-t.left,i=Math.max(s.top,t.top)-t.top,c=Math.min(s.right,t.right)-t.left,d=Math.min(s.bottom,t.bottom)-t.top;c-o<1||d-i<1||n.push({left:Math.round(o),top:Math.round(i),right:Math.round(c),bottom:Math.round(d)})}return n}function bV(e,t){return e.length===t.length&&e.every((n,r)=>{const s=t[r];return n.left===s.left&&n.top===s.top&&n.right===s.right&&n.bottom===s.bottom})}const kV=500;function iL({focus:e,setTimeout:t,clearTimeout:n,ms:r=kV}){let s=null;const o=()=>{s!==null&&(n(s),s=null)};return{hold(i){o(),s=t(()=>{s=null;try{e(i)}catch{}},r)},cancel:o}}function NV(e){return fV(e.nodeInternals.values())}const jV=e=>e.width,SV=e=>e.height,_V=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function EV({onFocusSession:e}){const{x:t,y:n,zoom:r}=AI(),s=Je(NV,mV),o=Je(jV),i=Je(SV),c={width:o,height:i},d=y.useRef(null),h=Je(_V),[f,p]=y.useState([]);y.useLayoutEffect(()=>{var I;const S=(I=d.current)==null?void 0:I.parentElement;if(!S)return;const E=xV(S),T=requestAnimationFrame(()=>{p(A=>bV(A,E)?A:E)});return()=>cancelAnimationFrame(T)});const g=y.useRef(e);g.current=e;const[w]=y.useState(()=>iL({focus:S=>{var E;return(E=g.current)==null?void 0:E.call(g,S)},setTimeout:(S,E)=>window.setTimeout(S,E),clearTimeout:S=>window.clearTimeout(S)}));if(y.useEffect(()=>()=>w.cancel(),[w]),s.length<=1)return null;const N=S=>{try{e==null||e(S)}catch{}},k=(S,E)=>{S.detail>0&&Fc()?w.hold(E):N(E)},x={transform:`translate(${t}px, ${n}px) scale(${r})`},b=a.jsx("div",{className:"session-clusters",style:x,ref:d,children:s.map(S=>{const E=vc(S.sessionId),T=dV(S,E);return a.jsx("div",{className:"cluster-card",style:T,"aria-hidden":!0},S.sessionId)})}),j=h&&Mt.createPortal(a.jsx("div",{className:"cluster-labels nopan",children:s.map(S=>{const E=vc(S.sessionId),T=vV(S,{x:t,y:n,zoom:r},c,f),I=hV(S,r,E,T.maxWidth);return a.jsxs("button",{type:"button",className:"cluster-label","data-alarm":S.alarm?"":void 0,"data-offpane":T.hidden?"":void 0,style:I,title:S.title,onClick:A=>k(A,S.sessionId),children:[S.alarm?a.jsxs(a.Fragment,{children:[a.jsx(pk,{}),a.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,S.label,S.branch?a.jsx("span",{className:"cluster-label-branch",children:oc+S.branch}):null,S.name?a.jsx("span",{className:"cluster-label-name",children:oc+S.name}):null,S.shortId?a.jsx("span",{className:"cluster-label-id",children:oc+S.shortId}):null]},S.sessionId)})}),h);return a.jsxs(a.Fragment,{children:[b,j]})}function CV({data:e}){return a.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const lL=600,TV=4,RV=36,fh=14,AV=60,MV=6,T_=220,$V=96,IV=28;function OV(e,t){return Math.max($V,61+[...t].length*6.8)}function LV(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function PV(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/lL)}function DV(e,t){const n=[],r=new Set;for(let s=e.length-1;s>=0&&n.length<t;s--){const o=e[s];r.has(o.id)||(r.add(o.id),n.push(o))}return n.reverse()}function FV(e,t,n,r,s,o){const i=[];for(const c of e.values()){if(!t.has(c.id)||c.exitAt!=null&&o-c.exitAt>lL)continue;const d=r.get(c.id)??n.get(c.id);if(!d)continue;const h=DV(c.tools,TV);if(h.length===0)continue;const f=c.exitAt??null,p=s.get(c.id),g=Math.max((p==null?void 0:p.width)??T_,T_),w=(p==null?void 0:p.height)??130,N=d.x,k=d.y,x=N+g,b=k+w/2;h.forEach((j,S)=>{const E=S*RV,T=N+g+AV,I=k+MV+E,A=PV(o,f),D=j.inputPreview??"",L=LV(j),U=A<.999,P=fk(j.name);i.push({id:`${c.id}::${j.id}`,toolId:j.id,agentId:c.id,toolName:j.name,name:P.label,emoji:P.emoji,status:L,category:$O(j.name),mcpHue:P.hue,inputPreview:D,fade:A,fading:U,worldX:T,worldY:I,anchorX:x,anchorY:b,spawnDx:x-T,spawnDy:b-(I+fh)});const $=PO(j.name,j.input);if($){const B=OV(j.name,P.label),R=T+B+IV,F=I,O=T+B,G=I+fh;i.push({id:`sub:${c.id}::${j.id}`,toolId:j.id,agentId:c.id,toolName:j.name,name:Az($.label,$.category),fullName:$.label,emoji:$.emoji,isSub:!0,status:L,category:$.category,inputPreview:$.detail??D,fade:A,fading:U,worldX:R,worldY:F,anchorX:O,anchorY:G,spawnDx:O-R,spawnDy:0})}})}return i}function BV({agents:e,visibleAgentIds:t,positions:n,pinned:r,measured:s,spotlight:o,hiddenCategories:i,now:c,onOpenTool:d}){const h=FV(e,t,n,r,s,c),f=i&&i.size>0?h.filter(p=>!i.has(p.category)):h;return a.jsx(qV,{bursts:f,spotlight:o,onOpenTool:d})}function qV({bursts:e,spotlight:t,onOpenTool:n}){const r=e.map(o=>{const i=o.anchorX,c=o.anchorY,d=o.worldX+6,h=o.worldY+fh,f=Math.max(1,d-i),p=Math.min(1,Math.abs(h-c)/f),g=i+f*(.55-.22*p),w=c+(h-c)*.12,N=d-f*.25,k=t!=null&&!t.has(o.agentId),x=o.fade*(k?.14:1);return a.jsx("path",{d:`M ${i} ${c} C ${g} ${w}, ${N} ${h}, ${d} ${h}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:x,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),s=e.map(o=>a.jsx(WV,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return a.jsx(UV,{connectors:r,bubbles:s})}function UV({connectors:e,bubbles:t}){const{x:n,y:r,zoom:s}=AI();return a.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,style:{"--tool-burst-height":`${2*fh}px`},children:[a.jsx("svg",{className:"tool-bursts-svg",children:a.jsx("g",{transform:`translate(${n} ${r}) scale(${s})`,children:e})}),a.jsx("div",{className:"tool-bursts-world",style:{transform:`translate(${n}px, ${r}px) scale(${s})`},children:t})]})}function HV(e,t){const n=e.b,r=t.b;return e.dim===t.dim&&e.onOpenTool===t.onOpenTool&&n.id===r.id&&n.toolId===r.toolId&&n.worldX===r.worldX&&n.worldY===r.worldY&&n.spawnDx===r.spawnDx&&n.spawnDy===r.spawnDy&&n.status===r.status&&n.fading===r.fading&&n.category===r.category&&n.mcpHue===r.mcpHue&&n.isSub===r.isSub&&n.emoji===r.emoji&&n.name===r.name&&n.fullName===r.fullName&&n.toolName===r.toolName&&n.inputPreview===r.inputPreview}const WV=y.memo(function({b:t,dim:n,onOpenTool:r}){const s={left:`${t.worldX}px`,top:`${t.worldY}px`,"--spawn-dx":`${t.spawnDx}px`,"--spawn-dy":`${t.spawnDy}px`},o=t.isSub?`${t.toolName} · ${t.fullName??t.name}`:t.toolName,i=t.inputPreview?`${o} · ${t.inputPreview}`:o,c=r!=null,d=t.mcpHue!=null?{"--mcp-hue":t.mcpHue}:{},h=n?" dim":"";return a.jsx("div",{className:"tool-burst-wrap",style:s,children:a.jsxs("div",{className:`tool-burst cat-${t.category}${t.mcpHue!=null?" mcp-hue":""} status-${t.status}${t.fading?" fading":""}${c?" clickable":""}${t.isSub?" sub":""}${h}`,style:d,title:i,onClick:c?()=>r(t.agentId,t.toolId):void 0,children:[a.jsx("span",{className:"tb-emoji",children:t.emoji}),a.jsx("span",{className:"tb-name",children:t.name}),t.status==="inflight"&&a.jsx("span",{className:"tb-spin"}),t.status==="done"&&a.jsx("span",{className:"tb-mark done",children:"✓"}),t.status==="err"&&a.jsx("span",{className:"tb-mark err",children:"×"})]})})},HV),zV={width:140,height:105},VV={agent:Pz,sessionGroup:CV,recapNote:K9},GV={recapTie:oV},R_=400;function KV({graph:e,layout:t,viewport:n,clicks:r,drag:s,appearance:o,fm:i,radioOpen:c,onRadioClose:d,autoFit:h,pause:f,stateRef:p,measuredRef:g,hiddenCats:w,now:N,openTool:k,focusAgent:x,requestClear:b,setKeyHelpOpen:j}){const{allNodes:S,edges:E,visibleAgentIds:T,spotlightSet:I}=e,{positionsRef:A,pinnedRef:D,handleRelayout:L,rearrangeUndo:U}=t,{restoredViewport:P,onMoveStart:$,onMove:B}=n,{onNodeClick:R,onPaneClick:F,onNodeDoubleClick:O,onNodeMouseEnter:G,onNodeMouseLeave:Y}=r,{onNodeDragStart:V,onNodeDrag:q,onNodeDragStop:M}=s,{palette:z,minimapNodeFill:Z,characterEnabled:H}=o,{autoFitDisabled:X,enableAutoFitAndRefit:K}=h,{paused:Q,pauseGate:ee,togglePause:re}=f;return a.jsxs(RI,{nodes:S,edges:E,nodeTypes:VV,edgesFocusable:!1,edgeTypes:GV,fitView:!P,fitViewOptions:{padding:.25,duration:Fb({durationMs:R_,documentHidden:document.hidden})?R_:0},minZoom:LI,maxZoom:PI,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:R,onPaneClick:F,onNodeDoubleClick:O,onNodeMouseEnter:G,onNodeMouseLeave:Y,onMoveStart:$,onMove:B,onNodeDragStart:(ie,de,pe)=>{U.dismiss(),V(ie,de,pe)},onNodeDrag:q,onNodeDragStop:M,children:[a.jsx(TU,{gap:28,size:1,color:z["--grid-line"]}),a.jsx(EV,{onFocusSession:x}),a.jsx(BV,{agents:p.current.agents,visibleAgentIds:T,positions:A.current,pinned:D.current,measured:g.current,spotlight:I,hiddenCategories:w,now:N,onOpenTool:k}),a.jsxs("div",{className:"canvas-notices",children:[X&&a.jsx(Hz,{enableAutoFitAndRefit:K}),a.jsx(aV,{undo:U})]}),a.jsx(e7,{autoFitDisabled:X,enableAutoFitAndRefit:K,paused:Q,pauseGate:ee,togglePause:re,handleRelayout:L,requestClear:b,setKeyHelpOpen:j}),a.jsx(gU,{style:zV,zoomable:!0,pannable:!0,nodeColor:Z,nodeStrokeWidth:2,maskColor:z["--minimap-mask"],maskStrokeColor:z["--line"]}),a.jsx(V9,{fm:i,character:o.character,characterEnabled:H,open:c,onClose:d})]})}function YV(){const e=window.ccdeckWindow;return y.useEffect(()=>{if(!e)return;const t=()=>{const r=document.querySelector(".topbar");if(!r)return;const s=getComputedStyle(r),o=i=>{var d;const c=(d=i.match(/\d+/g))==null?void 0:d.slice(0,3);return(c==null?void 0:c.length)===3?`#${c.map(h=>Number(h).toString(16).padStart(2,"0")).join("")}`:"#191a1c"};e.colors({color:o(s.backgroundColor),symbolColor:o(s.color)}).catch(()=>{})};t();const n=new MutationObserver(t);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-color-scheme"]}),()=>n.disconnect()},[e]),!e||e.platform==="darwin"?null:a.jsx("button",{type:"button",className:"desktop-menu btn","aria-label":"Application menu",title:"Application menu","aria-haspopup":"menu",onClick:()=>{e.menu().catch(()=>{})},children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:a.jsx("path",{d:"M3 4h10M3 8h10M3 12h10",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})})})}function XV(e){const t={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};let n=0,r=0,s=0,o=0;for(const i of e){const c=jn(i);t.input+=c.input,t.output+=c.output,t.cacheRead+=c.cacheRead,t.cacheWrite+=c.cacheWrite,t.total+=c.total,n+=i.usage.inputTokens,r+=i.usage.outputTokens,s+=i.usage.cacheReadTokens,o+=i.usage.cacheCreateTokens}return{cost:t,inputTokens:n,outputTokens:r,cacheReadTokens:s,cacheCreateTokens:o,sum:n+r}}const ZV="spend on this board",JV="on this board",cL=`Everything on the board right now, and only that.
85
85
  Finished sessions are evicted from the canvas a couple of minutes after they end, and their tokens and dollars leave with them — so this figure falls on its own.
@@ -105,7 +105,7 @@ ${n}`:t}const nle=new Set(["idle","checking","current","downloading","ready","er
105
105
  ${Ve(i.total)} spent${d?` · ${d}`:""}`:""}`,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:[Ve(i.total),d?a.jsxs("span",{className:"selected-rate",children:[" · ",d]}):null]}),h>0&&a.jsxs("span",{className:"selected-extra",children:["+",h]}),a.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:f=>{f.stopPropagation(),s()},children:"×"})]})}function jle({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(o=>{const i=r.has(o);return a.jsxs("button",{type:"button",className:`cat-filter${i?" off":""}`,onClick:()=>s(o),"aria-pressed":!i,title:`${i?"Show":"Hide"} ${Th[o]} tools`,children:[a.jsx(die,{cat:o}),a.jsx("span",{className:"cat-name",children:Th[o]})]},o)})})}const Sle=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function _le(e){var n,r;const t=e.target;!(t!=null&&t.closest)||t.closest(Sle)!==e.currentTarget||(e.preventDefault(),(r=(n=document.activeElement)==null?void 0:n.blur)==null||r.call(n))}function Ele({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:r}){const s=Sn();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"?`${un("The session list","L",s)} brings it back`:"The session keeps running"})]})]})}function Cle({canvasRef:e,bubbling:t,dragging:n,trash:r,zoom:s,viewport:o,stateRef:i,peek:c,children:d}){const{trashDragging:h,trashState:f,trashPhase:p,trashZoneRef:g,trashLabel:w}=r,{lod:N,lodRef:k}=s,{markCanvasInput:x}=o,{peekAgent:b,peekLabel:j,peekRecap:S,peekBounds:E}=c;return a.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${h&&f==="over"?" trash-hover":""}`,"data-lod":N,ref:e,onMouseDownCapture:_le,onPointerDownCapture:x,onPointerUpCapture:x,onWheelCapture:x,onFocusCapture:T=>{const I=T.target;if(!l1(I)||k.current==null||k.current==="detail")return;const A=I.getAttribute("data-id");A&&i.current.agents.has(A)&&I.matches(":focus-visible")&&K3(A,I,"focus")},onBlurCapture:T=>{var A,D;const I=(D=(A=T.target).getAttribute)==null?void 0:D.call(A,"data-id");I&&ja(I)},children:[d,ga(p)&&a.jsx(Ele,{trashZoneRef:g,trashState:f,trashPhase:p,trashLabel:w}),a.jsx(Pae,{agentFor:b,recapFor:S,labelFor:j,bounds:E})]})}function Tle({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 ${Lt}…`:(()=>{const s=Yz({connected:n,paused:r});return a.jsxs(a.Fragment,{children:[`Lost connection to the ${Lt} server. Reconnecting…`,s&&a.jsx("span",{className:"conn-sub",children:s})]})})()]})}function Rle({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 ",Lt," 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 w4="Thanks — that helps.",Ale=Array.from({length:11},(e,t)=>t);function Mle(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const $le=6;function Ile(e){const t=y.useRef(null);return y.useLayoutEffect(()=>{const n=t.current,r=n==null?void 0:n.closest(".app");if(!n||!r)return;const s=()=>r.style.setProperty("--rating-h",`${Math.ceil(n.getBoundingClientRect().height)}px`);s();const o=typeof ResizeObserver>"u"?null:new ResizeObserver(s);return o==null||o.observe(n),()=>{o==null||o.disconnect(),r.style.removeProperty("--rating-h")}},[e]),t}function Ole(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function Lle({phase:e,score:t,onAnswer:n,onLater:r,onClose:s,onFeedback:o,onHold:i}){const c=Ile(e),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1);y.useEffect(()=>{var g,w;e!=="thanks"||!f.current||(f.current=!1,Bn(((g=document.activeElement)==null?void 0:g.tagName)??null)&&((w=d.current??h.current)==null||w.focus()))},[e]);const p=g=>{var w;(w=c.current)!=null&&w.contains(document.activeElement)&&Ole(),g()};return e==="thanks"?a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",onFocus:()=>i(!0),onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||i(!1)},children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{children:w4}),t!==null&&t<=$le?a.jsx("button",{ref:d,type:"button",className:"ver-act",onClick:o,children:"Tell us what would make it better"}):null,a.jsx("button",{ref:h,type:"button","aria-label":"Dismiss",className:"ver-close",onClick:()=>p(s),children:"×"})]}):a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",role:"group","aria-labelledby":"rating-question",children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{id:"rating-question",children:"How useful is ccdeck to you?"}),a.jsx("span",{className:"rating-scale",children:Ale.map(g=>a.jsx("button",{type:"button",className:"rating-pick","aria-label":Mle(g),onClick:w=>{f.current=w.detail===0||w.currentTarget.matches(":focus-visible"),n(g)},children:g},g))}),a.jsx("span",{className:"ver-sub rating-ends","aria-hidden":"true",children:"0 not at all · 10 extremely"}),a.jsx("button",{type:"button",className:"ver-act",onClick:()=>p(r),children:"Not now"})]})}const Ple=3e4;function Dle({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function Fle({bundle:e,running:t,pending:n,lastTried:r}){return t?Dle({bundle:e,running:t,lastTried:r})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function Ble(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function qle({asked:e,reported:t}){return t?t!==e:!1}function v4(e){const t=e.thresholdMs??Ple;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 Ule(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 Hle(e,t){return e?t==null?"auto when idle":`auto in ${Ule(t)}`:"auto-restart off"}function T2(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function Wle(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 zle(e){const t=v4(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 M0={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",one_off:"this deck runs from a one-off pnpm dlx, bunx or yarn dlx copy that cannot be upgraded in place — to keep one, 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 Vle({notice:e,version:t,dismissNotice:n,upgradeState:r,startUpgrade:s,copyCommand:o,cmdCopied:i,autoRestart:c,toggleAutoRestart:d,askRestart:h,restartCopy:f,restartFuseMs:p,restarting:g}){var w,N,k;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:()=>h(),...Rs(g),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
106
106
 
107
107
  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…":f.label}),!g&&a.jsx("span",{className:"ver-sub",children:f.clause}),a.jsxs("label",{className:"ver-auto",children:[a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":c,onClick:d,"aria-label":"Auto-restart when idle",title:c?"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:Hle(c,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:[Lt," 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,...Rs(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:()=>h({upgrade:!0}),...Rs(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:((N=t==null?void 0:t.upgrade)==null?void 0:N.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((k=t==null?void 0:t.upgrade)==null?void 0:k.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:":M0.npx}):t!=null&&t.upgradeBlocked?a.jsx("span",{className:"ver-sub",children:Ut(M0,t.upgradeBlocked)??"cannot install from here"}):null,a.jsxs("button",{type:"button",className:"ver-cmd",onClick:o,title:"Copy to clipboard",children:[a.jsx("code",{children:t==null?void 0:t.command}),a.jsx("span",{className:"ver-cmd-hint",children:i?"copied":"copy"})]})]}),a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}function Gle({restart:e,versionCheck:t,upgrade:n,oldNameNotice:r,rating:s,onFeedback:o,everConnected:i,live:c,paused:d}){const{autoRestart:h,toggleAutoRestart:f,restarting:p,restartMode:g,restartedTo:w,askRestart:N,restartCopy:k,restartFuseMs:x}=e,{version:b,notice:j,noticeOpen:S,dismissNotice:E}=t,{upgradeState:T,startUpgrade:I,copyCommand:A,cmdCopied:D}=n,{oldName:L,oldNameOpen:U,dismissOldName:P}=r,{ratingPhase:$,ratingScore:B,answerRating:R,rateLater:F,closeRating:O,holdThanks:G}=s,Y=w?a.jsxs("div",{className:"ver-banner done",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:["Restarted — now running v",w,"."]}),a.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):i&&!c?a.jsx(Tle,{restarting:p,restartMode:g,live:c,paused:d}):S&&j?a.jsx(Vle,{notice:j,version:b,dismissNotice:E,upgradeState:T,startUpgrade:I,copyCommand:A,cmdCopied:D,autoRestart:h,toggleAutoRestart:f,askRestart:N,restartCopy:k,restartFuseMs:x,restarting:p}):U&&L?a.jsx(Rle,{oldName:L,version:b,dismissOldName:P}):$!=="hidden"?a.jsx(Lle,{phase:$,score:B,onAnswer:R,onLater:F,onClose:O,onFeedback:o,onHold:G}):null;return a.jsxs(a.Fragment,{children:[Y,a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:$==="thanks"?w4:""})]})}function Kle(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function Yle(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 Xle(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Zle(e,t){const n=Xle(e),r=(...i)=>[n?`${n} on the canvas`:null,...i,"layout, pins and selection"].filter(c=>c!==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 i=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,c=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:r(),stays:[`the event log — ${i}${c}`,"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 o=t.decks-1;return{goes:r(`the event log ${o===1?"1 other running deck shares":`${o} other running decks share`} with this one — every session recorded in it, not just the ones drawn here`),stays:[o===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 Jle({agentCount:e,onConfirm:t,onCancel:n}){const r=y.useRef(null),s=pt(n,{focusRef:r,layer:gW}),o=wt(n),[i,c]=y.useState(null);y.useEffect(()=>{let g=!1;return fetch("/api/clear").then(w=>w.ok?w.json():null).then(w=>{g||c(Yle(w))}).catch(()=>{}),()=>{g=!0}},[]);const{goes:d,stays:h,final:f,confirm:p}=Zle(e,i);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal clear-confirm",onClick:g=>g.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:d.map(g=>a.jsx("span",{children:g},g))}),a.jsx("dt",{children:"Stays"}),a.jsx("dd",{children:h.length>0?h.map(g=>a.jsx("span",{children:g},g)):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:p})]})]})]})})}const Ah=[{value:"bug",label:"Bug",question:"What happened?",placeholder:`I was trying to…
108
- What did you expect to happen?`},{value:"idea",label:"Idea",question:"What would make ccdeck better?",placeholder:"It would be useful if…"},{value:"other",label:"Other",question:"What would you like to tell us?",placeholder:"Write anything…"}];function x4(e){return Ah.find(t=>t.value===e)??Ah[0]}const $0=3,mb=120,b4=1e4,k4=200,Qle="Write something first.";function R2(e){return e.trim()!==""}function ece(e){var o;const t=e.trim();if(t==="")return"";const n=A2(t.split(/\r?\n/,1)[0]),r=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,s=gb(r).length>=$0?gb(r):gb(n);return nce(s.length>=$0?s:A2(t))}function tce(e,t){const n=ece(t);return n.length>=$0?n:`${x4(e).label}: ${n}`}function A2(e){return e.replace(/\s+/g," ").trim()}function gb(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function nce(e){if(e.length<=mb)return e;const t=e.slice(0,mb-1),n=t.lastIndexOf(" ");return`${(n>=mb/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function rce({kind:e,body:t,contact:n}){const r={kind:e,title:tce(e,t),body:t.trim()};return n.trim()!==""&&(r.contact=n.trim()),r}function sce(e){const t=e;return(t==null?void 0:t.ok)!==!0||typeof t.appVersion!="string"||typeof t.platform!="string"||t.appVersion===""||t.platform===""?null:{appVersion:t.appVersion,platform:t.platform}}const ace={darwin:"macOS",win32:"Windows",linux:"Linux"};function oce(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),r=t===-1?"":e.slice(t+1),s=ace[n]??n;return r?`${s} · ${r}`:s}function ice(e){return e?`ccdeck ${e.appVersion} · ${oce(e.platform)}`:null}const lce="sent with it",cce="Your ccdeck version and system are sent with it.",uce="Add details",dce="How to reach you",hce="Email or GitHub @name",fce="Only if you would like an answer.",pce=["It all goes to the people who make ccdeck, with the version and system below.","Nothing becomes public by being sent. They may open a public GitHub issue from it, choosing its title and text; your contact and screenshots are never put on one."];function mce(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function N4(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function gce(e){return tf(e)?["⌘","Enter"]:["Ctrl","Enter"]}function yce(e){return[...e].length===1}const j4="Thanks — feedback sent.";function M2(e,t,n){if(t==="vetoed")return"This deck was started with AGENTS_DECK_NO_INSTALL=1, which keeps it off the network, so nothing was sent.";if(e===429||t==="too_many")return"Too much feedback from this network in the last hour. Try again later; your text is still here.";if(e===413||t==="too_large")return"The images are too large to send together. Remove one and send again; your text is still here.";const r=n==null?void 0:n.images;return e===400&&Array.isArray(r)&&typeof r[0]=="string"?`The server did not accept an image. ${r[0]} Remove it and send again; your text is still here.`:e===400?"The server did not accept the message. It is still here; check it and send again.":"ccdeck's server could not be reached. Nothing was sent; your text is still here."}function wce(e){return e==="sending"?"Sending…":e==="sent"?j4:""}const $2=1400,vce=160;function xce({kind:e,onChange:t}){return a.jsxs("fieldset",{className:"fb-kinds",children:[a.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),Ah.map(n=>a.jsxs("label",{className:"fb-kind",children:[a.jsx("input",{type:"radio",name:"feedback-kind",value:n.value,checked:e===n.value,onChange:()=>t(n.value),onKeyDown:r=>{N4(r.nativeEvent)&&r.preventDefault()}}),n.label]},n.value))]})}const S4="fb-details";function bce({open:e,onToggle:t}){return a.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":S4,onClick:t,children:[uce,a.jsx("svg",{className:"fb-chev",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function kce({open:e,contact:t,onContact:n}){const r=y.useId();return a.jsx("div",{id:S4,className:"fb-details","data-open":e||void 0,children:a.jsx("div",{className:"fb-details-clip",children:a.jsxs("div",{className:"fb-details-body",children:[a.jsxs("div",{className:"fb-field",children:[a.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[dce,a.jsx("span",{className:"fb-optional",children:"optional"})]}),a.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:k4,autoComplete:"email",placeholder:hce,"aria-describedby":r,onChange:s=>n(s.target.value),onKeyDown:s=>{N4(s.nativeEvent)&&s.preventDefault()}}),a.jsx("p",{id:r,className:"fb-hint",children:fce})]}),a.jsx("div",{className:"fb-where",children:pce.map(s=>a.jsx("p",{children:s},s))})]})})})}const io=3,Nce=5*1024*1024,jce=12*1024*1024,I0=8192,Sce=64*1024,_ce=256*1024,Ece=.92,Cce=640,_4=.9,Tce=.85,Rce=6,Ace=512*1024,Mh={png:"image/png",jpeg:"image/jpeg"},Mce={png:"png",jpeg:"jpg"},$ce=[137,80,78,71,13,10,26,10],Ice=[255,216,255];function E4(e){const t=n=>e.length>=n.length&&n.every((r,s)=>e[s]===r);return t($ce)?"png":t(Ice)?"jpeg":null}function Oce(e){const t=E4(e);return t==="png"?Lce(e):t==="jpeg"?Dce(e):null}function Lce(e){const t=[73,72,68,82];if(e.length<24||!t.every((r,s)=>e[12+s]===r))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function Pce(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function Dce(e){let t=2;for(;t<e.length;){if(e[t]!==255)return null;for(;t<e.length&&e[t]===255;)t++;const n=e[t++];if(n===void 0||n===217||n===218)return null;if(n===1||n>=208&&n<=215)continue;if(t+2>e.length)return null;const r=e[t]<<8|e[t+1];if(r<2)return null;if(Pce(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=r}return null}function I2(e,t){return e.bytes>t||e.width>I0||e.height>I0}function Fce(e){return Math.min(Nce,jce-Sce-e)}function C4(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function Bce(e,t){const n=I0/Math.max(e.width,e.height),r=e.bytes>t?Math.sqrt(t/e.bytes)*_4:1;return C4(e,Math.min(1,n,r))}async function qce(e,t,n){let r=Bce(e,t),s=e.format;for(let o=0;o<Rce;o++){const i=await n(r,s,s==="jpeg"?Ece:void 0);if(!i)return null;if(i.size<=t)return{...r,blob:i,format:s};if(s==="png"){s="jpeg";continue}if(r=C4(r,Math.min(Tce,Math.sqrt(t/i.size)*_4)),Math.max(r.width,r.height)<Cce)return null}return null}async function Uce(e,t,n){const r=new Uint8Array(await e.slice(0,Ace).arrayBuffer()),s=E4(r);if(!s)return{ok:!1,problem:"type"};if(t<_ce)return{ok:!1,problem:"no_room"};const o=e.type===Mh[s]?e:new Blob([e],{type:Mh[s]}),i=Oce(r);if(i&&!I2({...i,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const c=await n(e).catch(()=>null);if(!c)return{ok:!1,problem:"unreadable"};try{const d={width:c.width,height:c.height,bytes:e.size,format:s};if(!I2(d,t))return{ok:!0,blob:o,resized:null};const h=await qce(d,t,c.encoder);return h?{ok:!0,blob:h.blob,resized:{width:h.width,height:h.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function Hce(e){return({width:t,height:n},r,s)=>new Promise(o=>{const i=document.createElement("canvas");i.width=t,i.height=n;const c=i.getContext("2d");if(!c)return o(null);r==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),i.toBlob(d=>{i.width=0,i.height=0,o(d)},Mh[r],s)})}const Wce=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:Hce(t),release:()=>t.close()}};function zce(e){return e.includes("Files")}function Vce({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Gce(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Kce(e,t){if(t.length===0)return{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)};const n=new FormData;return n.append("kind",e.kind),n.append("title",e.title),n.append("body",e.body),e.contact!==void 0&&n.append("contact",e.contact),t.forEach((r,s)=>{const o=r.type===Mh.jpeg?"jpeg":"png";n.append("images",r,`image-${s+1}.${Mce[o]}`)}),{method:"POST",body:n}}const Yce="Add screenshot",O2="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",Xce="A screenshot can show emails, costs and paths. Crop out what should not be seen.",L2="Three images at most. Remove one to add another.",Zce="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function Jce(e,t,n){const r=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${r}`}function Qce(e,t){const n=`${e} of ${io}`;return t>0?`${n} · ${t} resized to fit`:n}function eue(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function tue(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function nue(e,t){const n=tue(t);return e==="type"?`${n} is not a PNG or a JPEG, so it was not added. GIF, WebP and HEIC are not converted; save it as a PNG or a JPEG first.`:e==="no_room"?`There is no room left for ${n}: images go at up to 12 MB in all. Remove one to add it.`:e==="unreadable"?`${n} could not be read as an image.`:`${n} could not be made small enough to send: images go at up to 5 MB each.`}const T4="image/png,image/jpeg";function R4({className:e="fb-glyph"}){return a.jsxs("svg",{className:e,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),a.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),a.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function rue({images:e,buttonRef:t}){const n=y.useRef(null),r=e.shots.length>=io;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:O2,"aria-describedby":"fb-attach-hint",onClick:()=>{var s;return r?e.sayFull():(s=n.current)==null?void 0:s.click()},children:[a.jsx(R4,{}),Yce]}),a.jsx("span",{id:"fb-attach-hint",hidden:!0,children:O2}),a.jsx("input",{ref:n,type:"file",accept:T4,multiple:!0,hidden:!0,onChange:s=>{e.add(Array.from(s.target.files??[])),s.target.value=""}})]})}function sue({images:e,addRef:t}){const n=y.useRef(new Map),r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),[i,c]=y.useState(null),{shots:d}=e,h=Qce(d.length,d.filter(g=>g.resized).length);y.useLayoutEffect(()=>{var g;i!==null&&((g=i==="add"?t.current:n.current.get(i))==null||g.focus(),c(null))},[i,t]),y.useEffect(()=>{var g;e.problem&&((g=r.current)==null||g.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function f(g){c(Gce(d.map(w=>w.id),g)??"add"),e.remove(g)}function p(g){var w;o.current=g,(w=s.current)==null||w.click()}return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),a.jsx("input",{ref:s,type:"file",accept:T4,hidden:!0,onChange:g=>{const w=o.current;w!==null&&e.replace(w,Array.from(g.target.files??[])),o.current=null,g.target.value=""}}),d.length>0&&a.jsxs("div",{className:"fb-shots",children:[a.jsxs("div",{className:"fb-shots-row",children:[a.jsx("ul",{className:"fb-shots-list",children:d.map((g,w)=>a.jsxs("li",{className:"fb-shot","data-fitting":g.blob?void 0:!0,children:[a.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":Jce(w,g.name,g.resized),onClick:()=>p(g.id),children:[a.jsx("img",{className:"fb-shot-img",src:g.url,alt:""}),g.blob?a.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:"Replace"}):a.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:"Resizing…"})]}),a.jsx("button",{ref:N=>{N?n.current.set(g.id,N):n.current.delete(g.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":`Remove image ${w+1}`,title:`Remove image ${w+1}`,onClick:()=>f(g.id),children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},g.id))}),a.jsx("span",{className:"fb-shots-count",children:h})]}),a.jsx("p",{className:"fb-hint",children:Xce})]}),e.problem&&a.jsx("p",{ref:r,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function aue(e,t){return e.map((n,r)=>({id:t+r,name:n.name,url:URL.createObjectURL(n.blob),blob:n.blob,resized:n.resized}))}function oue(e,t,n){return n?e.map(r=>r.id===t.id?t:r):[...e,t]}function iue(e,t,n){return n?e.map(r=>r.id===t?n:r):e.filter(r=>r.id!==t)}function lue(e){const[t,n]=y.useState(()=>aue((e==null?void 0:e.ready)??[],1)),[r,s]=y.useState({problem:"",id:0}),o=y.useRef(0),i=y.useCallback($=>{$&&o.current++,s(B=>$?{problem:$,id:B.id+1}:B.problem?{problem:"",id:B.id}:B)},[]),[c,d]=y.useState(""),h=y.useRef(t),f=y.useRef(null),p=y.useRef(t.length),g=y.useRef(!0),w=y.useRef(new Map),N=y.useRef([]),k=y.useRef(0),x=y.useCallback($=>{h.current=$(h.current),n(h.current)},[]);y.useEffect(()=>(g.current=!0,()=>{g.current=!1;for(const $ of h.current)URL.revokeObjectURL($.url)}),[]);const b=y.useCallback(async($,B)=>{const R=h.current.reduce((Z,H)=>{var X;return Z+(H.id===(B==null?void 0:B.id)?0:((X=H.blob)==null?void 0:X.size)??0)},0),F=(B==null?void 0:B.id)??++p.current,O=URL.createObjectURL($),G={id:F,name:$.name||"image",url:O,blob:null,resized:null},Y=k.current;w.current.set(F,$);let V=!1;const q=()=>{V||(V=!0,x(Z=>oue(Z,G,B!==void 0)))},M=await Uce($,Fce(R),async Z=>(q(),Wce(Z))).catch(()=>({ok:!1,problem:"unreadable"})),z=h.current.some(Z=>Z.id===F);return!g.current||k.current!==Y||!z&&(V||B)?(URL.revokeObjectURL(O),B&&URL.revokeObjectURL(B.url),g.current&&w.current.delete(F),""):(w.current.delete(F),M.ok?(q(),B&&URL.revokeObjectURL(B.url),x(Z=>Z.map(H=>H.id===F?{...H,blob:M.blob,resized:M.resized}:H)),""):(URL.revokeObjectURL(O),V&&x(Z=>iue(Z,F,B)),nue(M.problem,$.name||"image")))},[x]),j=y.useCallback(async $=>{i("");const B=k.current,R=[];let F=0,O=0;for(const Y of $){if(!g.current||k.current!==B)return;const V=N.current.indexOf(Y);if(V!==-1&&N.current.splice(V,1),h.current.length>=io){F++;continue}const q=h.current.length,M=await b(Y);M&&R.push(M),h.current.length>q&&O++}if(!g.current||k.current!==B)return;F>0&&R.push(O===0&&R.length===0?L2:eue(F)),i(R.join(" "));const G=h.current.length;O>0&&d(`${O===1?"Image":`${O} images`} added, ${G} of ${io}.`)},[b,i]),S=y.useCallback(async($,B)=>{i("");const R=h.current.find(G=>G.id===$);if(!R)return j([B]);const F=await b(B,R);if(!g.current)return;i(F);const O=h.current.findIndex(G=>G.id===$);!F&&O!==-1&&d(`Image ${O+1} replaced, ${h.current.length} of ${io}.`)},[j,b,i]),E=y.useCallback($=>{const B=k.current;f.current=(f.current??Promise.resolve()).then(()=>k.current===B?$():void 0).catch(()=>{})},[]),T=y.useCallback($=>{$.length!==0&&(N.current.push(...$),E(()=>j($)))},[j,E]);y.useEffect(()=>{e&&e.waiting.length>0&&T(e.waiting)},[]);const I=y.useCallback(($,B)=>{const R=B[0];R&&E(()=>S($,R))},[E,S]),A=y.useCallback($=>{const B=h.current.find(R=>R.id===$);B&&(URL.revokeObjectURL(B.url),w.current.delete($),x(R=>R.filter(F=>F.id!==$)),i(""),d(`Image removed, ${h.current.length} of ${io}.`))},[x,i]),D=y.useCallback(()=>i(L2),[i]),L=y.useCallback(async()=>{const $=o.current;return await f.current,o.current!==$?null:h.current.flatMap(B=>B.blob?[B.blob]:[])},[]),U=y.useCallback(()=>({ready:h.current.flatMap($=>$.blob&&!w.current.has($.id)?[{name:$.name,blob:$.blob,resized:$.resized}]:[]),waiting:[...w.current.values(),...N.current]}),[]),P=y.useCallback(()=>{k.current++;for(const $ of h.current)URL.revokeObjectURL($.url);w.current.clear(),N.current=[],x(()=>[]),i("")},[x,i]);return{shots:t,problem:r.problem,problemId:r.id,announcement:c,add:T,replace:I,remove:A,sayFull:D,ready:L,kept:U,clear:P}}function cue(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(r=>r.ok?r.json():null).then(r=>{n&&t(sce(r))}).catch(()=>{}),()=>{n=!1}},[]),e}function uue(e){const[t,n]=y.useState({state:"idle"}),r=y.useRef(!1),s=y.useRef(null);y.useEffect(()=>()=>{var c;return(c=s.current)==null?void 0:c.abort()},[]);async function o(c){if(!sr(r.current))return;r.current=!0;const{signal:d}=s.current=new AbortController;n({state:"sending"});try{const h=await e.ready();if(d.aborted)return;if(!h){n({state:"failed",message:Zce});return}const f=await fetch("/api/feedback",{...Kce(rce(c),h),signal:d}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:M2(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{d.aborted||n({state:"failed",message:M2(0,null)})}finally{r.current=!1}}const i=()=>n(c=>c.state==="failed"?{state:"idle"}:c);return{outcome:t,sending:t.state==="sending",send:o,clearFailure:i}}function due(e,t){const[n,r]=y.useState(!1),s=y.useRef(t);return s.current=t,y.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>r(!0),$2),i=window.setTimeout(()=>s.current(),$2+vce);return()=>{window.clearTimeout(o),window.clearTimeout(i)}},[e]),n}const yb="agent-dag.feedbackDrafts",P2=4;function hue({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function fue(e){return JSON.stringify([e.kind,e.body])}function pue(e){return e.ready.length+e.waiting.length}function A4(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function mue(e){return e===1?"The screenshot was not kept through the page reload. Add it again to send it.":`The ${e} screenshots were not kept through the page reload. Add them again to send them.`}const gue="Discard",yue="Confirm discard",wue="Clear the message, the screenshots and the contact",D2="Press again to clear this draft. It cannot be brought back.",vue={ready:[],waiting:[]};function xue(e){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string")return null;const t=e[1];if(!t||typeof t!="object")return null;const{kind:n,body:r,contact:s,images:o}=t;return!Ah.some(i=>i.value===n)||typeof r!="string"||r.length>b4||typeof s!="string"||s.length>k4||typeof o!="number"||!Number.isInteger(o)||o<0||o>io?null:[e[0],{kind:n,body:r,contact:s,images:o}]}function bue(e){let t=null;function n(){var o;if(t)return t;t=new Map;try{const i=(o=e())==null?void 0:o.getItem(yb),c=i?JSON.parse(i):[];if(Array.isArray(c))for(const d of c.slice(-P2)){const h=xue(d);h&&t.set(h[0],{...h[1],images:null,imageCount:h[1].images})}}catch{}return t}function r(){try{const o=e();if(!o)return;const i=[...n()].map(([c,d])=>[c,{kind:d.kind,body:d.body,contact:d.contact,images:d.imageCount}]);i.length===0?o.removeItem(yb):o.setItem(yb,JSON.stringify(i))}catch{}}function s(o){n().delete(o)&&r()}return{read(o){const i=n().get(o);return i?{kind:i.kind,body:i.body,contact:i.contact,images:i.images??vue,imagesLost:i.images?0:i.imageCount}:null},keep(o,i,c){const d=pue(i.images);if(!A4({body:i.body,contact:i.contact,images:d},c)){s(o);return}const h=n();h.delete(o),h.set(o,{kind:i.kind,body:i.body,contact:i.contact,images:i.images,imageCount:d});for(const f of h.keys()){if(h.size<=P2)break;h.delete(f)}r()},forget:s}}function kue(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const O0=bue(kue),Nue=4e3;function jue(e,t,n,r,s){const o=y.useRef(null);o.current={key:e,seed:t,words:n,images:r,sent:s};const i=y.useCallback(()=>{const c=o.current;!c||c.sent||O0.keep(c.key,{...c.words,images:c.images.kept()},c.seed)},[]);y.useEffect(i,[i,n.kind,n.body,n.contact,r.shots]),y.useEffect(()=>i,[i]),y.useEffect(()=>{s&&O0.forget(e)},[s,e])}const F2="draft";function Sue(e){const[t,n]=y.useState(!1),r=y.useRef(0);y.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),Nue);return()=>window.clearTimeout(o)},[t]);function s(){const o=Date.now(),i=xo({armedFor:t?F2:null,target:F2,armedAt:r.current,now:o,gapMs:vo});if(i==="arm"){n(!0),r.current=o;return}i!=="ignore"&&(n(!1),e())}return{armed:t,press:s}}function M4({onClose:e,initialKind:t,initialBody:n}){const r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),i=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(null),p=y.useRef(0),g=pt(e,{focusRef:r}),w=wt(e),N=hue({initialKind:t,initialBody:n}),k=fue(N),[x]=y.useState(()=>O0.read(k)),[b,j]=y.useState((x==null?void 0:x.kind)??N.kind),[S,E]=y.useState((x==null?void 0:x.body)??N.body),[T,I]=y.useState((x==null?void 0:x.contact)??""),[A,D]=y.useState((x==null?void 0:x.imagesLost)??0),[L,U]=y.useState(!1),[P,$]=y.useState(!1),[B,R]=y.useState(!1),F=lue(x==null?void 0:x.images),O=ice(cue()),{outcome:G,sending:Y,send:V,clearFailure:q}=uue(F),M=G.state==="sent",z=due(M,e);jue(k,N,{kind:b,body:S,contact:T},F,M);const Z=A4({body:S,contact:T,images:F.shots.length},N),H=Sue(()=>{var xe;j(N.kind),E(N.body),I(""),D(0),$(!1),F.clear(),q(),(xe=r.current)==null||xe.focus()}),X=x4(b),K=P&&!R2(S),Q=A>0&&F.shots.length===0,ee=[K&&"fb-body-error",Q&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[re,ie]=gce(ef());y.useEffect(()=>{var Ee,Le;const xe=i.current;if(!xe)return;const Ne=xe.contains(document.activeElement)||Bn(((Ee=document.activeElement)==null?void 0:Ee.tagName)??null);xe.inert=M,M&&Ne&&((Le=s.current)==null||Le.focus())},[M]),y.useEffect(()=>{var $e,rt;const xe=c.current;if(!xe)return;const Ne=h.current;if(Y){const Be=document.activeElement,Qe=Be!=null&&(xe.contains(Be)||Be===Ne);f.current=Qe?Be:null,xe.inert=!0,Ne&&(Ne.inert=!0),f.current&&(($e=d.current)==null||$e.focus());return}xe.inert=!1,Ne&&(Ne.inert=!1);const Ee=f.current;f.current=null;const Le=document.activeElement===d.current||Bn(((rt=document.activeElement)==null?void 0:rt.tagName)??null);!M&&Ee&&Le&&Ee.focus()},[Y,M]);function de(xe){var Ne;if(xe.preventDefault(),!R2(S)){$(!0),(Ne=r.current)==null||Ne.focus();return}V({kind:b,body:S,contact:T})}const pe=!M&&!Y,se=xe=>zce(Array.from(xe.dataTransfer.types));function me(xe){!se(xe)||!pe||(xe.preventDefault(),p.current++,R(!0))}function he(xe){se(xe)&&(xe.preventDefault(),xe.dataTransfer.dropEffect=pe?"copy":"none")}function le(xe){se(xe)&&(p.current=Math.max(0,p.current-1),p.current===0&&R(!1))}function ue(xe){se(xe)&&(xe.preventDefault(),p.current=0,R(!1),pe&&F.add(Array.from(xe.dataTransfer.files)))}function ye(xe){xe.target!==xe.currentTarget||!se(xe)||(xe.preventDefault(),xe.dataTransfer.dropEffect="none")}function ke(xe){se(xe)&&xe.preventDefault()}function Te(xe){if(!pe)return;const Ne=Array.from(xe.clipboardData.files),Ee=xe.target,Le=Ee instanceof HTMLTextAreaElement||Ee instanceof HTMLInputElement,$e=Array.from(xe.clipboardData.types).includes("text/plain");Vce({files:Ne.length,hasText:$e,intoTextField:Le})&&(xe.preventDefault(),F.add(Ne))}return a.jsx("div",{className:"modal-backdrop",...w,role:"presentation",onDragOver:ye,onDrop:ke,"data-leaving":z||void 0,children:a.jsxs("div",{ref:g,className:"modal feedback-dialog",onClick:xe=>xe.stopPropagation(),onDragEnter:me,onDragOver:he,onDragLeave:le,onDrop:ue,onPaste:Te,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:"Send feedback"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:s,type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("p",{className:"vis-hidden",role:"status",children:H.armed?D2:wce(G.state)}),a.jsxs("div",{className:"fb-stage",children:[a.jsxs("form",{ref:i,className:"fb-form",onSubmit:de,onKeyDown:xe=>{mce(xe.nativeEvent)&&(xe.preventDefault(),xe.currentTarget.requestSubmit())},noValidate:!0,children:[a.jsxs("section",{ref:c,className:"modal-body fb-body",children:[a.jsx(xce,{kind:b,onChange:j}),a.jsxs("div",{className:"fb-compose",children:[a.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:X.question}),a.jsx("textarea",{ref:r,id:"fb-body",className:"ap-manage-input fb-message",value:S,maxLength:b4,rows:5,placeholder:X.placeholder,onChange:xe=>E(xe.target.value),"aria-invalid":K||void 0,"aria-describedby":ee,required:!0}),K&&a.jsx("p",{id:"fb-body-error",className:"fb-error",children:Qle}),a.jsx(sue,{images:F,addRef:o}),Q&&a.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:mue(A)}),a.jsxs("div",{className:"fb-tools",children:[a.jsx(rue,{images:F,buttonRef:o}),a.jsx(bce,{open:L,onToggle:()=>U(xe=>!xe)})]}),a.jsx(kce,{open:L,contact:T,onContact:I})]}),a.jsx("p",{className:"fb-facts",children:O?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"fb-facts-value",children:O})," — ",lce]}):cce}),G.state==="failed"&&a.jsx("p",{className:"fb-error",role:"alert",children:G.message})]}),a.jsxs("div",{className:"fb-foot",children:[Z&&a.jsx("button",{ref:h,type:"button",className:`btn danger fb-discard${H.armed?" armed":""}`,onKeyDown:xe=>{xe.repeat&&xe.preventDefault()},onClick:H.press,title:H.armed?D2:wue,children:H.armed?yue:gue}),a.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[a.jsx("kbd",{"data-symbol":yce(re)||void 0,children:re}),a.jsx("kbd",{children:ie})," to send"]}),a.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),a.jsx("button",{ref:d,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...Rs(Y),children:a.jsxs("span",{className:"fb-send-label",children:[a.jsx("span",{className:"fb-send-idle",children:"Send feedback"}),a.jsx("span",{className:"fb-send-busy",children:"Sending…"})]})})]})]}),M&&a.jsxs("div",{className:"fb-done",children:[a.jsx(yh,{}),a.jsx("p",{className:"fb-done-line",children:j4})]})]}),a.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":B||void 0,children:a.jsxs("div",{className:"fb-drop-frame",children:[a.jsx(R4,{className:"fb-drop-glyph"}),a.jsx("p",{className:"fb-drop-title",children:"Drop to attach"}),a.jsx("p",{className:"fb-drop-note",children:"PNG or JPEG, up to three"})]})})]})})}const _ue="Press Esc first if a key does nothing.",B2=[{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 — the session list (L) brings it back",binds:["Delete"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"Ctrl + Z",macCap:"⌘ Z",action:"undo a re-arrange, while the canvas offers it",binds:["z","Z"],chord:!0},{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:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"Ctrl + ,",macCap:"⌘ ,",action:"all settings",binds:[","],chord:!0},{cap:"V",action:"sound settings — the switch, and each tone's volume and sound",binds:["v","V"]},{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:[]}]}],Eue=/ \([A-Z?]\)/g;function Cue(e){return e?B2:B2.map(t=>({...t,rows:t.rows.filter(n=>n.chord||!n.binds.some(qO)).map(n=>({...n,action:n.action.replace(Eue,"")}))})).filter(t=>t.rows.length>0)}const Tue="Single-key shortcuts are off.",$4="Settings › General",Rue=`Single-key shortcuts can be turned off in ${$4}.`;function Aue({onClose:e,onTour:t,onSettings:n}){const r=pt(e),s=wt(e),o=tf(ef()),i=Sn(),c=Cue(i);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal key-help",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title","aria-describedby":i?void 0:"key-help-off",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:[!i&&a.jsxs("div",{className:"kh-off",children:[a.jsxs("p",{className:"kh-off-text",id:"key-help-off",children:[a.jsx("strong",{children:Tue})," Turn them back on in"," ",a.jsx("span",{className:"kh-place",children:$4}),". Everything below still works."]}),n&&a.jsx("button",{type:"button",className:"btn",onClick:n,children:"Open Settings"})]}),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:c.map(d=>a.jsxs(y.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:d.title}),d.rows.map(h=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:o&&h.macCap?h.macCap:h.cap}),a.jsx("span",{children:h.action})]},`${d.title}:${h.cap}:${h.action}`))]},d.title))}),i&&a.jsxs("p",{className:"kh-foot",children:[_ue," ",Rue]})]})]})})}function h1(e,t){return y.lazy(()=>e().catch(n=>(console.warn(`ccdeck could not load ${t}`,n),{default:({onClose:r})=>a.jsx(Mue,{name:t,onClose:r})})))}function Mue({name:e,onClose:t}){const n=y.useRef(null),r=pt(t,{focusRef:n}),s=wt(t);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal dialog-missing",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{className:"dm-note",children:[e," did not load. The deck has most likely been updated since this tab opened, and a reload picks up the new version."]}),a.jsxs("div",{className:"dm-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"}),a.jsx("button",{type:"button",ref:n,className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"})]})]})]})})}function $ue(e,t){return`${e}#${t}`}function Iue(e,{lan:t,now:n,closed:r}){if(t===void 0)return[];const s=[];for(const o of e??[]){const i=o.reauth;if(!i||i.dismissed||o.origin!=="ccdeck_signin")continue;const c=$ue(i.key,i.since);if(r.has(c)||HZ(i.key,o.email,t,n))continue;const d=o.email??"";s.push({id:c,key:i.key,since:i.since,num:o.num,email:d,name:d||o.alias||`Account ${o.num}`,alias:d&&o.alias?o.alias:null})}return s}function Oue(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(r=>r.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(r.num)===String(t.num))).map(r=>r.id):[]}function I4({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function Lue(e){return e===1?"Account needs your attention":"Accounts need your attention"}function Pue(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const Due="Login expired",Fue="Until then the deck cannot read its usage or switch to it. Signing in again brings it back — it keeps its slot, its alias and its history.",Bue="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function que(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,o)=>(s.at??0)-(o.at??0));return{request:r[0],waiting:r.length-1}}function Uue({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:o,onLater:i}){const c=y.useRef(null),d=pt(i,{focusRef:c}),h=wt(i),f=Na(n,"accept"),p=Na(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:g=>g.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:i,"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 ",Ok(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:c,className:"btn",disabled:p.disabled,"aria-busy":p.busy,onClick:o,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 Hue(e){const t=y.useRef(!1),n=Wue(e),r=I4({rows:n?1:0,ours:t.current,dialogs:On.dialogDepth()});return t.current=r,r?n:null}function Wue({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:r,deferLanPair:s}){const{request:o,waiting:i}=que(e,t.current);return o?a.jsx(Uue,{request:o,waiting:i,busy:n,now:Date.now(),onAccept:()=>void r("accept",o.fp),onDecline:()=>void r("dismiss",o.fp),onLater:()=>s(o.fp)},o.fp):null}function zue({rows:e,onSignIn:t,onLater:n,firstRef:r}){const s=e.length===1?e[0]:null;return a.jsxs("section",{className:"modal-body",children:[s?a.jsxs(a.Fragment,{children:[a.jsxs("p",{id:"reauth-lead",className:"reauth-lead",children:["The Claude login for ",a.jsx("strong",{className:"reauth-name",children:s.name}),s.alias?a.jsxs("span",{className:"reauth-alias",children:[" (",s.alias,")"]}):null," ","has expired and needs a new sign","‑","in."]}),a.jsx("p",{className:"reauth-note",children:Fue})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:Pue(e.length)}),a.jsx("ul",{className:"reauth-list",children:e.map((o,i)=>a.jsxs("li",{className:"reauth-row",children:[a.jsxs("span",{className:"reauth-who",title:o.alias?`${o.alias} — ${o.name}`:o.name,children:[o.name,o.alias?a.jsxs("span",{className:"reauth-alias",children:[" ",o.alias]}):null]}),a.jsx("span",{className:"reauth-what",children:Due}),a.jsx("button",{type:"button",className:"btn",ref:i===0?r:void 0,"aria-label":`Sign in again as ${o.name}`,onClick:()=>t(o),children:"Sign in again"})]},o.id))}),a.jsx("p",{className:"reauth-note",children:"Each keeps its slot, its alias and its history."})]}),a.jsxs("div",{className:"reauth-acts",children:[a.jsx("button",{type:"button",className:"btn",title:Bue,onClick:n,children:"Not now"}),s&&a.jsx("button",{type:"button",className:"btn primary",ref:r,onClick:()=>t(s),children:"Sign in again"})]})]})}function Vue({rows:e,onSignIn:t,onLater:n}){const r=y.useRef(null),s=pt(n,{focusRef:r}),o=wt(n);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal reauth-ask",onClick:i=>i.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:Lue(e.length)})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Not now (Esc)",title:"Not now (Esc)",children:"×"})})]}),a.jsx(zue,{rows:e,onSignIn:t,onLater:n,firstRef:r})]})})}function Gue({rows:e,signingIn:t,signIn:n,signedIn:r,refresh:s,closeSignIn:o,later:i,pairing:c=!1}){const d=y.useRef(!1),h=On.dialogDepth()+(c?1:0),f=t!=null||I4({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?a.jsx(eP,{email:t.email||null,onClose:o,onChanged:s,onSignedIn:r}):f?a.jsx(Vue,{rows:e,onSignIn:n,onLater:i},e.length===1?"one":"many"):null}const Kue={"//":["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.35.0","3.35.1","3.36.0","3.36.1","3.36.4","3.36.5","3.36.6","3.36.7","3.36.8","3.36.9","3.37.0","3.38.0","3.38.1","3.38.2","3.38.6","3.39.4"],"3.40.0":[{title:"📻 Explore radio around the world",body:"Open Radio from the right sidebar to discover stations on a world map, filter by country, sound or language, and save your favorites. Recent listening, a daily pick and Surprise me make it easier to find something to play. Music keeps playing when you close the explorer. Volume now adjusts in 1% steps, and an unavailable stream automatically advances to the next station after one second."},{title:"🦊 Choose your canvas companion",body:"Choose Deck companion, Fox or Penguin in Settings › Appearance. Your companion shares the existing canvas movements and music controls, and your choice stays saved."},{title:"📊 See what each session used",body:"Open a session’s usage details to inspect tokens, models and estimated cost. For Codex, compare Automatic, Standard, Fast and Flex pricing estimates without changing your Codex settings or billing."},{title:"A clearer canvas",body:"Session cards, tool traces and connections are easier to scan. The canvas reframes more reliably when resizing to portrait or rearranging sessions, and model cost estimates use updated pricing."}],"3.39.3":[{title:"A cleaner desktop window",body:"The desktop app now has one compact toolbar that follows your theme, with native window controls and an application menu. Wider side rails give icons more room; the Local network footer and unread badges are more compact."},{title:"Clearer account usage and Telemetry Radar",body:"Account usage shows reset times together with capacity. Telemetry Radar has a clearer monitoring workspace and keeps history for up to 24 hours. Radar remains Beta."}],"3.39.1":[{title:"🎨 More themes, with clearer contrast",body:"Choose Omarchy, Matrix, Black Contrast, White Contrast or Catppuccin Mocha in Settings › Appearance. Fresh installations start with Rider Black; your saved theme choice is preserved."},{title:"A little more room on the canvas",body:"The minimap is smaller, leaving more room for the character and your sessions. Undo and Resume now sit beside each other at the bottom of the canvas. Telemetry Radar is marked Beta while it is being tested and improved."}],"3.39.0":[{title:"🔎 Inspect Claude Code telemetry on macOS",body:"Telemetry Radar shows Claude Code's configured telemetry and can inspect traffic at destinations you choose. When settings are absent, it can show observed connections separately; a connection alone does not prove telemetry or reveal message contents. Capture starts only after you run its generated command in Terminal, which uses macOS tcpdump with administrator permission. Captured telemetry can contain prompt or response content, and other apps sending to the same destination may appear too. Messages stay in ccdeck's memory for up to five minutes; no capture file is written."},{title:"🧭 Open panels from the edges",body:"Open the session list, Claude accounts, Usage, This machine, Usage history and Browser Watch from the window edges. You can keep several panels open beside the canvas; on a phone, the same controls sit in a bottom dock."},{title:"More control while you work",body:"Turn off single-key shortcuts if typed letters should not control the deck, see each stage while adding a Claude account, and undo a recent rearrangement. The topbar also names the Claude Code session waiting on you."},{title:"🎨 Two new dark themes",body:"Choose Rider Black or VS Code Black in Settings › Appearance. Both add a darker canvas with flatter panels and distinct focus accents; your existing Light or Dark choice stays as it was."}],"3.38.5":[{title:"🔧 Settings are in one place now",body:"The theme, the sounds, notifications, Claude FM and the minimap character are all in Settings, behind the gear at the right of the topbar, or Cmd+, (Ctrl+, on Windows and Linux). The speaker beside it keeps the quick things one click away: sounds on or off, and how loud each tone is. Nothing you had set has changed, it has only moved, and T still switches the theme. The auto-switch threshold also takes a custom value now: pick Custom… and type a whole percent from 50 to 99."},{title:"Windows: no more temperature stuck at 28 °C",body:"On many Windows laptops the only temperature Windows offers is a thermal zone wired to nothing, which reads a fixed 28 °C however hot the CPU is, and the machine panel showed it as a reading. A thermal zone is now drawn only once its value has changed. Until then the panel shows LibreHardwareMonitor's readings if its web server is running, and otherwise no Thermal section at all: the deck never invents a reading."}],"3.38.4":[{title:"🔔 A notification when Auto-switch changes your account",body:'When Auto-switch moves Claude Code to another account, ccdeck now tells you once, with where it went and why, for example "Switched to work · personal@example.com reached 90%". You can turn it off in the sound settings, where two more wait, off until you turn them on: one when a quota window of the Claude or Codex account you are on reaches 90% and again at 100%, and one when a window that had reached 90% is available again. Each is said once per window and a restart does not repeat it. With either quota notification on, the deck reads quota about every two minutes even while no page is open.'}],"3.38.3":[{title:"🧾 Subagent costs count their whole reply",body:"A subagent's request was counted from the first moment of its reply, before most of it had been written, so much of its output was left out of the deck's token and cost counts, and a subagent turn in fast mode was priced at the standard rate. Each request is now counted from its finished reply. Days with subagents will read higher than before: that is the part that was missing, not a new charge. Projects counts its history again once after the update, so past days come out right too. Codex sessions on GPT-6 Sol, GPT-6.1 Sol and GPT-6 Luna now show a cost instead of not priced."}],"3.37.1":[{title:"🔁 Expired logins repair from your other machines",body:"When a login stops working on this machine and a machine you paired with still has it working and ticked, Local network now copies it back on the next round, whether or not the account is ticked here. Before, it stayed marked expired until the account was ticked here as well, or deleted so that it arrived again. A machine that paired on its own, through Say yes to every deck that asks, still repairs only the accounts ticked here."}],"3.36.3":[{title:"🔑 An expired login asks to be signed in again",body:"When an account you added with + → Sign in stops working, the deck now tells you in one dialog, with every affected account together and Sign in again beside each. That opens the usual sign-in with the address already filled in, and the account keeps its slot, its alias and its history. Not now leaves it marked in the Accounts panel and does not ask again until it has worked and stopped again. A paired deck holding a working copy gets to repair it first, and accounts that came from a share or Local network are never asked about."}],"3.34.1":[{title:"🗂️ The tray menu stays open while you read it",body:"On Linux the menu behind the tray icon could close by itself while agents were working, often before the row you pressed took the click, so it had to be opened and pressed again. It now changes only when something it says has changed, and stays open while you choose."}],"3.34.0":[{title:"🗺️ The network map shows who you are connected to",body:"Paired decks that are on stand closest to this one, and a light runs along their wires. Paired decks that are away come next, in a colour of their own, with how long they have been gone, and machines that are not paired stand outside in grey. Decks reached over Tailscale sit together in their own shaded slice instead of on dashed wires. Pointing at a deck opens its details beside the map: whether it is there, what to do next if anything, its address and what it runs, and every login the two share, the ones that need a look first."},{title:"🔑 A login that expired everywhere says so",body:`When a shared login expired on this deck and every paired deck that is on held an expired copy too, the row said "Login expired" and waited for a repair that could never come. It now says "Login expired on all online decks". Claude retires a login's other copies each time one machine refreshes it, so shared copies expire together: sign in again on any one machine and the others repair from it on their next round.`},{title:"💬 Send feedback from inside the deck",body:'Appearance settings has a "Send feedback…" button: pick what kind it is, write a title and a few lines, and add a way to reach you if you want an answer. It goes to the people who make ccdeck, who may open a public issue from it, never with your contact in it. If it cannot be sent, the form stays filled in and says why.'}],"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.
108
+ What did you expect to happen?`},{value:"idea",label:"Idea",question:"What would make ccdeck better?",placeholder:"It would be useful if…"},{value:"other",label:"Other",question:"What would you like to tell us?",placeholder:"Write anything…"}];function x4(e){return Ah.find(t=>t.value===e)??Ah[0]}const $0=3,mb=120,b4=1e4,k4=200,Qle="Write something first.";function R2(e){return e.trim()!==""}function ece(e){var o;const t=e.trim();if(t==="")return"";const n=A2(t.split(/\r?\n/,1)[0]),r=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,s=gb(r).length>=$0?gb(r):gb(n);return nce(s.length>=$0?s:A2(t))}function tce(e,t){const n=ece(t);return n.length>=$0?n:`${x4(e).label}: ${n}`}function A2(e){return e.replace(/\s+/g," ").trim()}function gb(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function nce(e){if(e.length<=mb)return e;const t=e.slice(0,mb-1),n=t.lastIndexOf(" ");return`${(n>=mb/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function rce({kind:e,body:t,contact:n}){const r={kind:e,title:tce(e,t),body:t.trim()};return n.trim()!==""&&(r.contact=n.trim()),r}function sce(e){const t=e;return(t==null?void 0:t.ok)!==!0||typeof t.appVersion!="string"||typeof t.platform!="string"||t.appVersion===""||t.platform===""?null:{appVersion:t.appVersion,platform:t.platform}}const ace={darwin:"macOS",win32:"Windows",linux:"Linux"};function oce(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),r=t===-1?"":e.slice(t+1),s=ace[n]??n;return r?`${s} · ${r}`:s}function ice(e){return e?`ccdeck ${e.appVersion} · ${oce(e.platform)}`:null}const lce="sent with it",cce="Your ccdeck version and system are sent with it.",uce="Add details",dce="How to reach you",hce="Email or GitHub @name",fce="Only if you would like an answer.",pce=["It all goes to the people who make ccdeck, with the version and system below.","Nothing becomes public by being sent. They may open a public GitHub issue from it, choosing its title and text; your contact and screenshots are never put on one."];function mce(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function N4(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function gce(e){return tf(e)?["⌘","Enter"]:["Ctrl","Enter"]}function yce(e){return[...e].length===1}const j4="Thanks — feedback sent.";function M2(e,t,n){if(t==="vetoed")return"This deck was started with AGENTS_DECK_NO_INSTALL=1, which keeps it off the network, so nothing was sent.";if(e===429||t==="too_many")return"Too much feedback from this network in the last hour. Try again later; your text is still here.";if(e===413||t==="too_large")return"The images are too large to send together. Remove one and send again; your text is still here.";const r=n==null?void 0:n.images;return e===400&&Array.isArray(r)&&typeof r[0]=="string"?`The server did not accept an image. ${r[0]} Remove it and send again; your text is still here.`:e===400?"The server did not accept the message. It is still here; check it and send again.":"ccdeck's server could not be reached. Nothing was sent; your text is still here."}function wce(e){return e==="sending"?"Sending…":e==="sent"?j4:""}const $2=1400,vce=160;function xce({kind:e,onChange:t}){return a.jsxs("fieldset",{className:"fb-kinds",children:[a.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),Ah.map(n=>a.jsxs("label",{className:"fb-kind",children:[a.jsx("input",{type:"radio",name:"feedback-kind",value:n.value,checked:e===n.value,onChange:()=>t(n.value),onKeyDown:r=>{N4(r.nativeEvent)&&r.preventDefault()}}),n.label]},n.value))]})}const S4="fb-details";function bce({open:e,onToggle:t}){return a.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":S4,onClick:t,children:[uce,a.jsx("svg",{className:"fb-chev",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function kce({open:e,contact:t,onContact:n}){const r=y.useId();return a.jsx("div",{id:S4,className:"fb-details","data-open":e||void 0,children:a.jsx("div",{className:"fb-details-clip",children:a.jsxs("div",{className:"fb-details-body",children:[a.jsxs("div",{className:"fb-field",children:[a.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[dce,a.jsx("span",{className:"fb-optional",children:"optional"})]}),a.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:k4,autoComplete:"email",placeholder:hce,"aria-describedby":r,onChange:s=>n(s.target.value),onKeyDown:s=>{N4(s.nativeEvent)&&s.preventDefault()}}),a.jsx("p",{id:r,className:"fb-hint",children:fce})]}),a.jsx("div",{className:"fb-where",children:pce.map(s=>a.jsx("p",{children:s},s))})]})})})}const io=3,Nce=5*1024*1024,jce=12*1024*1024,I0=8192,Sce=64*1024,_ce=256*1024,Ece=.92,Cce=640,_4=.9,Tce=.85,Rce=6,Ace=512*1024,Mh={png:"image/png",jpeg:"image/jpeg"},Mce={png:"png",jpeg:"jpg"},$ce=[137,80,78,71,13,10,26,10],Ice=[255,216,255];function E4(e){const t=n=>e.length>=n.length&&n.every((r,s)=>e[s]===r);return t($ce)?"png":t(Ice)?"jpeg":null}function Oce(e){const t=E4(e);return t==="png"?Lce(e):t==="jpeg"?Dce(e):null}function Lce(e){const t=[73,72,68,82];if(e.length<24||!t.every((r,s)=>e[12+s]===r))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function Pce(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function Dce(e){let t=2;for(;t<e.length;){if(e[t]!==255)return null;for(;t<e.length&&e[t]===255;)t++;const n=e[t++];if(n===void 0||n===217||n===218)return null;if(n===1||n>=208&&n<=215)continue;if(t+2>e.length)return null;const r=e[t]<<8|e[t+1];if(r<2)return null;if(Pce(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=r}return null}function I2(e,t){return e.bytes>t||e.width>I0||e.height>I0}function Fce(e){return Math.min(Nce,jce-Sce-e)}function C4(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function Bce(e,t){const n=I0/Math.max(e.width,e.height),r=e.bytes>t?Math.sqrt(t/e.bytes)*_4:1;return C4(e,Math.min(1,n,r))}async function qce(e,t,n){let r=Bce(e,t),s=e.format;for(let o=0;o<Rce;o++){const i=await n(r,s,s==="jpeg"?Ece:void 0);if(!i)return null;if(i.size<=t)return{...r,blob:i,format:s};if(s==="png"){s="jpeg";continue}if(r=C4(r,Math.min(Tce,Math.sqrt(t/i.size)*_4)),Math.max(r.width,r.height)<Cce)return null}return null}async function Uce(e,t,n){const r=new Uint8Array(await e.slice(0,Ace).arrayBuffer()),s=E4(r);if(!s)return{ok:!1,problem:"type"};if(t<_ce)return{ok:!1,problem:"no_room"};const o=e.type===Mh[s]?e:new Blob([e],{type:Mh[s]}),i=Oce(r);if(i&&!I2({...i,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const c=await n(e).catch(()=>null);if(!c)return{ok:!1,problem:"unreadable"};try{const d={width:c.width,height:c.height,bytes:e.size,format:s};if(!I2(d,t))return{ok:!0,blob:o,resized:null};const h=await qce(d,t,c.encoder);return h?{ok:!0,blob:h.blob,resized:{width:h.width,height:h.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function Hce(e){return({width:t,height:n},r,s)=>new Promise(o=>{const i=document.createElement("canvas");i.width=t,i.height=n;const c=i.getContext("2d");if(!c)return o(null);r==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),i.toBlob(d=>{i.width=0,i.height=0,o(d)},Mh[r],s)})}const Wce=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:Hce(t),release:()=>t.close()}};function zce(e){return e.includes("Files")}function Vce({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Gce(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Kce(e,t){if(t.length===0)return{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)};const n=new FormData;return n.append("kind",e.kind),n.append("title",e.title),n.append("body",e.body),e.contact!==void 0&&n.append("contact",e.contact),t.forEach((r,s)=>{const o=r.type===Mh.jpeg?"jpeg":"png";n.append("images",r,`image-${s+1}.${Mce[o]}`)}),{method:"POST",body:n}}const Yce="Add screenshot",O2="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",Xce="A screenshot can show emails, costs and paths. Crop out what should not be seen.",L2="Three images at most. Remove one to add another.",Zce="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function Jce(e,t,n){const r=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${r}`}function Qce(e,t){const n=`${e} of ${io}`;return t>0?`${n} · ${t} resized to fit`:n}function eue(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function tue(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function nue(e,t){const n=tue(t);return e==="type"?`${n} is not a PNG or a JPEG, so it was not added. GIF, WebP and HEIC are not converted; save it as a PNG or a JPEG first.`:e==="no_room"?`There is no room left for ${n}: images go at up to 12 MB in all. Remove one to add it.`:e==="unreadable"?`${n} could not be read as an image.`:`${n} could not be made small enough to send: images go at up to 5 MB each.`}const T4="image/png,image/jpeg";function R4({className:e="fb-glyph"}){return a.jsxs("svg",{className:e,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),a.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),a.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function rue({images:e,buttonRef:t}){const n=y.useRef(null),r=e.shots.length>=io;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:O2,"aria-describedby":"fb-attach-hint",onClick:()=>{var s;return r?e.sayFull():(s=n.current)==null?void 0:s.click()},children:[a.jsx(R4,{}),Yce]}),a.jsx("span",{id:"fb-attach-hint",hidden:!0,children:O2}),a.jsx("input",{ref:n,type:"file",accept:T4,multiple:!0,hidden:!0,onChange:s=>{e.add(Array.from(s.target.files??[])),s.target.value=""}})]})}function sue({images:e,addRef:t}){const n=y.useRef(new Map),r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),[i,c]=y.useState(null),{shots:d}=e,h=Qce(d.length,d.filter(g=>g.resized).length);y.useLayoutEffect(()=>{var g;i!==null&&((g=i==="add"?t.current:n.current.get(i))==null||g.focus(),c(null))},[i,t]),y.useEffect(()=>{var g;e.problem&&((g=r.current)==null||g.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function f(g){c(Gce(d.map(w=>w.id),g)??"add"),e.remove(g)}function p(g){var w;o.current=g,(w=s.current)==null||w.click()}return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),a.jsx("input",{ref:s,type:"file",accept:T4,hidden:!0,onChange:g=>{const w=o.current;w!==null&&e.replace(w,Array.from(g.target.files??[])),o.current=null,g.target.value=""}}),d.length>0&&a.jsxs("div",{className:"fb-shots",children:[a.jsxs("div",{className:"fb-shots-row",children:[a.jsx("ul",{className:"fb-shots-list",children:d.map((g,w)=>a.jsxs("li",{className:"fb-shot","data-fitting":g.blob?void 0:!0,children:[a.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":Jce(w,g.name,g.resized),onClick:()=>p(g.id),children:[a.jsx("img",{className:"fb-shot-img",src:g.url,alt:""}),g.blob?a.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:"Replace"}):a.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:"Resizing…"})]}),a.jsx("button",{ref:N=>{N?n.current.set(g.id,N):n.current.delete(g.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":`Remove image ${w+1}`,title:`Remove image ${w+1}`,onClick:()=>f(g.id),children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},g.id))}),a.jsx("span",{className:"fb-shots-count",children:h})]}),a.jsx("p",{className:"fb-hint",children:Xce})]}),e.problem&&a.jsx("p",{ref:r,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function aue(e,t){return e.map((n,r)=>({id:t+r,name:n.name,url:URL.createObjectURL(n.blob),blob:n.blob,resized:n.resized}))}function oue(e,t,n){return n?e.map(r=>r.id===t.id?t:r):[...e,t]}function iue(e,t,n){return n?e.map(r=>r.id===t?n:r):e.filter(r=>r.id!==t)}function lue(e){const[t,n]=y.useState(()=>aue((e==null?void 0:e.ready)??[],1)),[r,s]=y.useState({problem:"",id:0}),o=y.useRef(0),i=y.useCallback($=>{$&&o.current++,s(B=>$?{problem:$,id:B.id+1}:B.problem?{problem:"",id:B.id}:B)},[]),[c,d]=y.useState(""),h=y.useRef(t),f=y.useRef(null),p=y.useRef(t.length),g=y.useRef(!0),w=y.useRef(new Map),N=y.useRef([]),k=y.useRef(0),x=y.useCallback($=>{h.current=$(h.current),n(h.current)},[]);y.useEffect(()=>(g.current=!0,()=>{g.current=!1;for(const $ of h.current)URL.revokeObjectURL($.url)}),[]);const b=y.useCallback(async($,B)=>{const R=h.current.reduce((Z,H)=>{var X;return Z+(H.id===(B==null?void 0:B.id)?0:((X=H.blob)==null?void 0:X.size)??0)},0),F=(B==null?void 0:B.id)??++p.current,O=URL.createObjectURL($),G={id:F,name:$.name||"image",url:O,blob:null,resized:null},Y=k.current;w.current.set(F,$);let V=!1;const q=()=>{V||(V=!0,x(Z=>oue(Z,G,B!==void 0)))},M=await Uce($,Fce(R),async Z=>(q(),Wce(Z))).catch(()=>({ok:!1,problem:"unreadable"})),z=h.current.some(Z=>Z.id===F);return!g.current||k.current!==Y||!z&&(V||B)?(URL.revokeObjectURL(O),B&&URL.revokeObjectURL(B.url),g.current&&w.current.delete(F),""):(w.current.delete(F),M.ok?(q(),B&&URL.revokeObjectURL(B.url),x(Z=>Z.map(H=>H.id===F?{...H,blob:M.blob,resized:M.resized}:H)),""):(URL.revokeObjectURL(O),V&&x(Z=>iue(Z,F,B)),nue(M.problem,$.name||"image")))},[x]),j=y.useCallback(async $=>{i("");const B=k.current,R=[];let F=0,O=0;for(const Y of $){if(!g.current||k.current!==B)return;const V=N.current.indexOf(Y);if(V!==-1&&N.current.splice(V,1),h.current.length>=io){F++;continue}const q=h.current.length,M=await b(Y);M&&R.push(M),h.current.length>q&&O++}if(!g.current||k.current!==B)return;F>0&&R.push(O===0&&R.length===0?L2:eue(F)),i(R.join(" "));const G=h.current.length;O>0&&d(`${O===1?"Image":`${O} images`} added, ${G} of ${io}.`)},[b,i]),S=y.useCallback(async($,B)=>{i("");const R=h.current.find(G=>G.id===$);if(!R)return j([B]);const F=await b(B,R);if(!g.current)return;i(F);const O=h.current.findIndex(G=>G.id===$);!F&&O!==-1&&d(`Image ${O+1} replaced, ${h.current.length} of ${io}.`)},[j,b,i]),E=y.useCallback($=>{const B=k.current;f.current=(f.current??Promise.resolve()).then(()=>k.current===B?$():void 0).catch(()=>{})},[]),T=y.useCallback($=>{$.length!==0&&(N.current.push(...$),E(()=>j($)))},[j,E]);y.useEffect(()=>{e&&e.waiting.length>0&&T(e.waiting)},[]);const I=y.useCallback(($,B)=>{const R=B[0];R&&E(()=>S($,R))},[E,S]),A=y.useCallback($=>{const B=h.current.find(R=>R.id===$);B&&(URL.revokeObjectURL(B.url),w.current.delete($),x(R=>R.filter(F=>F.id!==$)),i(""),d(`Image removed, ${h.current.length} of ${io}.`))},[x,i]),D=y.useCallback(()=>i(L2),[i]),L=y.useCallback(async()=>{const $=o.current;return await f.current,o.current!==$?null:h.current.flatMap(B=>B.blob?[B.blob]:[])},[]),U=y.useCallback(()=>({ready:h.current.flatMap($=>$.blob&&!w.current.has($.id)?[{name:$.name,blob:$.blob,resized:$.resized}]:[]),waiting:[...w.current.values(),...N.current]}),[]),P=y.useCallback(()=>{k.current++;for(const $ of h.current)URL.revokeObjectURL($.url);w.current.clear(),N.current=[],x(()=>[]),i("")},[x,i]);return{shots:t,problem:r.problem,problemId:r.id,announcement:c,add:T,replace:I,remove:A,sayFull:D,ready:L,kept:U,clear:P}}function cue(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(r=>r.ok?r.json():null).then(r=>{n&&t(sce(r))}).catch(()=>{}),()=>{n=!1}},[]),e}function uue(e){const[t,n]=y.useState({state:"idle"}),r=y.useRef(!1),s=y.useRef(null);y.useEffect(()=>()=>{var c;return(c=s.current)==null?void 0:c.abort()},[]);async function o(c){if(!sr(r.current))return;r.current=!0;const{signal:d}=s.current=new AbortController;n({state:"sending"});try{const h=await e.ready();if(d.aborted)return;if(!h){n({state:"failed",message:Zce});return}const f=await fetch("/api/feedback",{...Kce(rce(c),h),signal:d}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:M2(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{d.aborted||n({state:"failed",message:M2(0,null)})}finally{r.current=!1}}const i=()=>n(c=>c.state==="failed"?{state:"idle"}:c);return{outcome:t,sending:t.state==="sending",send:o,clearFailure:i}}function due(e,t){const[n,r]=y.useState(!1),s=y.useRef(t);return s.current=t,y.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>r(!0),$2),i=window.setTimeout(()=>s.current(),$2+vce);return()=>{window.clearTimeout(o),window.clearTimeout(i)}},[e]),n}const yb="agent-dag.feedbackDrafts",P2=4;function hue({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function fue(e){return JSON.stringify([e.kind,e.body])}function pue(e){return e.ready.length+e.waiting.length}function A4(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function mue(e){return e===1?"The screenshot was not kept through the page reload. Add it again to send it.":`The ${e} screenshots were not kept through the page reload. Add them again to send them.`}const gue="Discard",yue="Confirm discard",wue="Clear the message, the screenshots and the contact",D2="Press again to clear this draft. It cannot be brought back.",vue={ready:[],waiting:[]};function xue(e){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string")return null;const t=e[1];if(!t||typeof t!="object")return null;const{kind:n,body:r,contact:s,images:o}=t;return!Ah.some(i=>i.value===n)||typeof r!="string"||r.length>b4||typeof s!="string"||s.length>k4||typeof o!="number"||!Number.isInteger(o)||o<0||o>io?null:[e[0],{kind:n,body:r,contact:s,images:o}]}function bue(e){let t=null;function n(){var o;if(t)return t;t=new Map;try{const i=(o=e())==null?void 0:o.getItem(yb),c=i?JSON.parse(i):[];if(Array.isArray(c))for(const d of c.slice(-P2)){const h=xue(d);h&&t.set(h[0],{...h[1],images:null,imageCount:h[1].images})}}catch{}return t}function r(){try{const o=e();if(!o)return;const i=[...n()].map(([c,d])=>[c,{kind:d.kind,body:d.body,contact:d.contact,images:d.imageCount}]);i.length===0?o.removeItem(yb):o.setItem(yb,JSON.stringify(i))}catch{}}function s(o){n().delete(o)&&r()}return{read(o){const i=n().get(o);return i?{kind:i.kind,body:i.body,contact:i.contact,images:i.images??vue,imagesLost:i.images?0:i.imageCount}:null},keep(o,i,c){const d=pue(i.images);if(!A4({body:i.body,contact:i.contact,images:d},c)){s(o);return}const h=n();h.delete(o),h.set(o,{kind:i.kind,body:i.body,contact:i.contact,images:i.images,imageCount:d});for(const f of h.keys()){if(h.size<=P2)break;h.delete(f)}r()},forget:s}}function kue(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const O0=bue(kue),Nue=4e3;function jue(e,t,n,r,s){const o=y.useRef(null);o.current={key:e,seed:t,words:n,images:r,sent:s};const i=y.useCallback(()=>{const c=o.current;!c||c.sent||O0.keep(c.key,{...c.words,images:c.images.kept()},c.seed)},[]);y.useEffect(i,[i,n.kind,n.body,n.contact,r.shots]),y.useEffect(()=>i,[i]),y.useEffect(()=>{s&&O0.forget(e)},[s,e])}const F2="draft";function Sue(e){const[t,n]=y.useState(!1),r=y.useRef(0);y.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),Nue);return()=>window.clearTimeout(o)},[t]);function s(){const o=Date.now(),i=xo({armedFor:t?F2:null,target:F2,armedAt:r.current,now:o,gapMs:vo});if(i==="arm"){n(!0),r.current=o;return}i!=="ignore"&&(n(!1),e())}return{armed:t,press:s}}function M4({onClose:e,initialKind:t,initialBody:n}){const r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),i=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(null),p=y.useRef(0),g=pt(e,{focusRef:r}),w=wt(e),N=hue({initialKind:t,initialBody:n}),k=fue(N),[x]=y.useState(()=>O0.read(k)),[b,j]=y.useState((x==null?void 0:x.kind)??N.kind),[S,E]=y.useState((x==null?void 0:x.body)??N.body),[T,I]=y.useState((x==null?void 0:x.contact)??""),[A,D]=y.useState((x==null?void 0:x.imagesLost)??0),[L,U]=y.useState(!1),[P,$]=y.useState(!1),[B,R]=y.useState(!1),F=lue(x==null?void 0:x.images),O=ice(cue()),{outcome:G,sending:Y,send:V,clearFailure:q}=uue(F),M=G.state==="sent",z=due(M,e);jue(k,N,{kind:b,body:S,contact:T},F,M);const Z=A4({body:S,contact:T,images:F.shots.length},N),H=Sue(()=>{var xe;j(N.kind),E(N.body),I(""),D(0),$(!1),F.clear(),q(),(xe=r.current)==null||xe.focus()}),X=x4(b),K=P&&!R2(S),Q=A>0&&F.shots.length===0,ee=[K&&"fb-body-error",Q&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[re,ie]=gce(ef());y.useEffect(()=>{var Ee,Le;const xe=i.current;if(!xe)return;const Ne=xe.contains(document.activeElement)||Bn(((Ee=document.activeElement)==null?void 0:Ee.tagName)??null);xe.inert=M,M&&Ne&&((Le=s.current)==null||Le.focus())},[M]),y.useEffect(()=>{var $e,rt;const xe=c.current;if(!xe)return;const Ne=h.current;if(Y){const Be=document.activeElement,Qe=Be!=null&&(xe.contains(Be)||Be===Ne);f.current=Qe?Be:null,xe.inert=!0,Ne&&(Ne.inert=!0),f.current&&(($e=d.current)==null||$e.focus());return}xe.inert=!1,Ne&&(Ne.inert=!1);const Ee=f.current;f.current=null;const Le=document.activeElement===d.current||Bn(((rt=document.activeElement)==null?void 0:rt.tagName)??null);!M&&Ee&&Le&&Ee.focus()},[Y,M]);function de(xe){var Ne;if(xe.preventDefault(),!R2(S)){$(!0),(Ne=r.current)==null||Ne.focus();return}V({kind:b,body:S,contact:T})}const pe=!M&&!Y,se=xe=>zce(Array.from(xe.dataTransfer.types));function me(xe){!se(xe)||!pe||(xe.preventDefault(),p.current++,R(!0))}function he(xe){se(xe)&&(xe.preventDefault(),xe.dataTransfer.dropEffect=pe?"copy":"none")}function le(xe){se(xe)&&(p.current=Math.max(0,p.current-1),p.current===0&&R(!1))}function ue(xe){se(xe)&&(xe.preventDefault(),p.current=0,R(!1),pe&&F.add(Array.from(xe.dataTransfer.files)))}function ye(xe){xe.target!==xe.currentTarget||!se(xe)||(xe.preventDefault(),xe.dataTransfer.dropEffect="none")}function ke(xe){se(xe)&&xe.preventDefault()}function Te(xe){if(!pe)return;const Ne=Array.from(xe.clipboardData.files),Ee=xe.target,Le=Ee instanceof HTMLTextAreaElement||Ee instanceof HTMLInputElement,$e=Array.from(xe.clipboardData.types).includes("text/plain");Vce({files:Ne.length,hasText:$e,intoTextField:Le})&&(xe.preventDefault(),F.add(Ne))}return a.jsx("div",{className:"modal-backdrop",...w,role:"presentation",onDragOver:ye,onDrop:ke,"data-leaving":z||void 0,children:a.jsxs("div",{ref:g,className:"modal feedback-dialog",onClick:xe=>xe.stopPropagation(),onDragEnter:me,onDragOver:he,onDragLeave:le,onDrop:ue,onPaste:Te,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:"Send feedback"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:s,type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("p",{className:"vis-hidden",role:"status",children:H.armed?D2:wce(G.state)}),a.jsxs("div",{className:"fb-stage",children:[a.jsxs("form",{ref:i,className:"fb-form",onSubmit:de,onKeyDown:xe=>{mce(xe.nativeEvent)&&(xe.preventDefault(),xe.currentTarget.requestSubmit())},noValidate:!0,children:[a.jsxs("section",{ref:c,className:"modal-body fb-body",children:[a.jsx(xce,{kind:b,onChange:j}),a.jsxs("div",{className:"fb-compose",children:[a.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:X.question}),a.jsx("textarea",{ref:r,id:"fb-body",className:"ap-manage-input fb-message",value:S,maxLength:b4,rows:5,placeholder:X.placeholder,onChange:xe=>E(xe.target.value),"aria-invalid":K||void 0,"aria-describedby":ee,required:!0}),K&&a.jsx("p",{id:"fb-body-error",className:"fb-error",children:Qle}),a.jsx(sue,{images:F,addRef:o}),Q&&a.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:mue(A)}),a.jsxs("div",{className:"fb-tools",children:[a.jsx(rue,{images:F,buttonRef:o}),a.jsx(bce,{open:L,onToggle:()=>U(xe=>!xe)})]}),a.jsx(kce,{open:L,contact:T,onContact:I})]}),a.jsx("p",{className:"fb-facts",children:O?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"fb-facts-value",children:O})," — ",lce]}):cce}),G.state==="failed"&&a.jsx("p",{className:"fb-error",role:"alert",children:G.message})]}),a.jsxs("div",{className:"fb-foot",children:[Z&&a.jsx("button",{ref:h,type:"button",className:`btn danger fb-discard${H.armed?" armed":""}`,onKeyDown:xe=>{xe.repeat&&xe.preventDefault()},onClick:H.press,title:H.armed?D2:wue,children:H.armed?yue:gue}),a.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[a.jsx("kbd",{"data-symbol":yce(re)||void 0,children:re}),a.jsx("kbd",{children:ie})," to send"]}),a.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),a.jsx("button",{ref:d,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...Rs(Y),children:a.jsxs("span",{className:"fb-send-label",children:[a.jsx("span",{className:"fb-send-idle",children:"Send feedback"}),a.jsx("span",{className:"fb-send-busy",children:"Sending…"})]})})]})]}),M&&a.jsxs("div",{className:"fb-done",children:[a.jsx(yh,{}),a.jsx("p",{className:"fb-done-line",children:j4})]})]}),a.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":B||void 0,children:a.jsxs("div",{className:"fb-drop-frame",children:[a.jsx(R4,{className:"fb-drop-glyph"}),a.jsx("p",{className:"fb-drop-title",children:"Drop to attach"}),a.jsx("p",{className:"fb-drop-note",children:"PNG or JPEG, up to three"})]})})]})})}const _ue="Press Esc first if a key does nothing.",B2=[{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 — the session list (L) brings it back",binds:["Delete"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"Ctrl + Z",macCap:"⌘ Z",action:"undo a re-arrange, while the canvas offers it",binds:["z","Z"],chord:!0},{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:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"Ctrl + ,",macCap:"⌘ ,",action:"all settings",binds:[","],chord:!0},{cap:"V",action:"sound settings — the switch, and each tone's volume and sound",binds:["v","V"]},{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:[]}]}],Eue=/ \([A-Z?]\)/g;function Cue(e){return e?B2:B2.map(t=>({...t,rows:t.rows.filter(n=>n.chord||!n.binds.some(qO)).map(n=>({...n,action:n.action.replace(Eue,"")}))})).filter(t=>t.rows.length>0)}const Tue="Single-key shortcuts are off.",$4="Settings › General",Rue=`Single-key shortcuts can be turned off in ${$4}.`;function Aue({onClose:e,onTour:t,onSettings:n}){const r=pt(e),s=wt(e),o=tf(ef()),i=Sn(),c=Cue(i);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal key-help",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title","aria-describedby":i?void 0:"key-help-off",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:[!i&&a.jsxs("div",{className:"kh-off",children:[a.jsxs("p",{className:"kh-off-text",id:"key-help-off",children:[a.jsx("strong",{children:Tue})," Turn them back on in"," ",a.jsx("span",{className:"kh-place",children:$4}),". Everything below still works."]}),n&&a.jsx("button",{type:"button",className:"btn",onClick:n,children:"Open Settings"})]}),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:c.map(d=>a.jsxs(y.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:d.title}),d.rows.map(h=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:o&&h.macCap?h.macCap:h.cap}),a.jsx("span",{children:h.action})]},`${d.title}:${h.cap}:${h.action}`))]},d.title))}),i&&a.jsxs("p",{className:"kh-foot",children:[_ue," ",Rue]})]})]})})}function h1(e,t){return y.lazy(()=>e().catch(n=>(console.warn(`ccdeck could not load ${t}`,n),{default:({onClose:r})=>a.jsx(Mue,{name:t,onClose:r})})))}function Mue({name:e,onClose:t}){const n=y.useRef(null),r=pt(t,{focusRef:n}),s=wt(t);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal dialog-missing",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{className:"dm-note",children:[e," did not load. The deck has most likely been updated since this tab opened, and a reload picks up the new version."]}),a.jsxs("div",{className:"dm-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"}),a.jsx("button",{type:"button",ref:n,className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"})]})]})]})})}function $ue(e,t){return`${e}#${t}`}function Iue(e,{lan:t,now:n,closed:r}){if(t===void 0)return[];const s=[];for(const o of e??[]){const i=o.reauth;if(!i||i.dismissed||o.origin!=="ccdeck_signin")continue;const c=$ue(i.key,i.since);if(r.has(c)||HZ(i.key,o.email,t,n))continue;const d=o.email??"";s.push({id:c,key:i.key,since:i.since,num:o.num,email:d,name:d||o.alias||`Account ${o.num}`,alias:d&&o.alias?o.alias:null})}return s}function Oue(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(r=>r.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(r.num)===String(t.num))).map(r=>r.id):[]}function I4({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function Lue(e){return e===1?"Account needs your attention":"Accounts need your attention"}function Pue(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const Due="Login expired",Fue="Until then the deck cannot read its usage or switch to it. Signing in again brings it back — it keeps its slot, its alias and its history.",Bue="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function que(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,o)=>(s.at??0)-(o.at??0));return{request:r[0],waiting:r.length-1}}function Uue({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:o,onLater:i}){const c=y.useRef(null),d=pt(i,{focusRef:c}),h=wt(i),f=Na(n,"accept"),p=Na(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:g=>g.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:i,"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 ",Ok(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:c,className:"btn",disabled:p.disabled,"aria-busy":p.busy,onClick:o,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 Hue(e){const t=y.useRef(!1),n=Wue(e),r=I4({rows:n?1:0,ours:t.current,dialogs:On.dialogDepth()});return t.current=r,r?n:null}function Wue({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:r,deferLanPair:s}){const{request:o,waiting:i}=que(e,t.current);return o?a.jsx(Uue,{request:o,waiting:i,busy:n,now:Date.now(),onAccept:()=>void r("accept",o.fp),onDecline:()=>void r("dismiss",o.fp),onLater:()=>s(o.fp)},o.fp):null}function zue({rows:e,onSignIn:t,onLater:n,firstRef:r}){const s=e.length===1?e[0]:null;return a.jsxs("section",{className:"modal-body",children:[s?a.jsxs(a.Fragment,{children:[a.jsxs("p",{id:"reauth-lead",className:"reauth-lead",children:["The Claude login for ",a.jsx("strong",{className:"reauth-name",children:s.name}),s.alias?a.jsxs("span",{className:"reauth-alias",children:[" (",s.alias,")"]}):null," ","has expired and needs a new sign","‑","in."]}),a.jsx("p",{className:"reauth-note",children:Fue})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:Pue(e.length)}),a.jsx("ul",{className:"reauth-list",children:e.map((o,i)=>a.jsxs("li",{className:"reauth-row",children:[a.jsxs("span",{className:"reauth-who",title:o.alias?`${o.alias} — ${o.name}`:o.name,children:[o.name,o.alias?a.jsxs("span",{className:"reauth-alias",children:[" ",o.alias]}):null]}),a.jsx("span",{className:"reauth-what",children:Due}),a.jsx("button",{type:"button",className:"btn",ref:i===0?r:void 0,"aria-label":`Sign in again as ${o.name}`,onClick:()=>t(o),children:"Sign in again"})]},o.id))}),a.jsx("p",{className:"reauth-note",children:"Each keeps its slot, its alias and its history."})]}),a.jsxs("div",{className:"reauth-acts",children:[a.jsx("button",{type:"button",className:"btn",title:Bue,onClick:n,children:"Not now"}),s&&a.jsx("button",{type:"button",className:"btn primary",ref:r,onClick:()=>t(s),children:"Sign in again"})]})]})}function Vue({rows:e,onSignIn:t,onLater:n}){const r=y.useRef(null),s=pt(n,{focusRef:r}),o=wt(n);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal reauth-ask",onClick:i=>i.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:Lue(e.length)})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Not now (Esc)",title:"Not now (Esc)",children:"×"})})]}),a.jsx(zue,{rows:e,onSignIn:t,onLater:n,firstRef:r})]})})}function Gue({rows:e,signingIn:t,signIn:n,signedIn:r,refresh:s,closeSignIn:o,later:i,pairing:c=!1}){const d=y.useRef(!1),h=On.dialogDepth()+(c?1:0),f=t!=null||I4({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?a.jsx(eP,{email:t.email||null,onClose:o,onChanged:s,onSignedIn:r}):f?a.jsx(Vue,{rows:e,onSignIn:n,onLater:i},e.length===1?"one":"many"):null}const Kue={"//":["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.35.0","3.35.1","3.36.0","3.36.1","3.36.4","3.36.5","3.36.6","3.36.7","3.36.8","3.36.9","3.37.0","3.38.0","3.38.1","3.38.2","3.38.6","3.39.4","3.40.1"],"3.40.0":[{title:"📻 Explore radio around the world",body:"Open Radio from the right sidebar to discover stations on a world map, filter by country, sound or language, and save your favorites. Recent listening, a daily pick and Surprise me make it easier to find something to play. Music keeps playing when you close the explorer. Volume now adjusts in 1% steps, and an unavailable stream automatically advances to the next station after one second."},{title:"🦊 Choose your canvas companion",body:"Choose Deck companion, Fox or Penguin in Settings › Appearance. Your companion shares the existing canvas movements and music controls, and your choice stays saved."},{title:"📊 See what each session used",body:"Open a session’s usage details to inspect tokens, models and estimated cost. For Codex, compare Automatic, Standard, Fast and Flex pricing estimates without changing your Codex settings or billing."},{title:"A clearer canvas",body:"Session cards, tool traces and connections are easier to scan. The canvas reframes more reliably when resizing to portrait or rearranging sessions, and model cost estimates use updated pricing."}],"3.39.3":[{title:"A cleaner desktop window",body:"The desktop app now has one compact toolbar that follows your theme, with native window controls and an application menu. Wider side rails give icons more room; the Local network footer and unread badges are more compact."},{title:"Clearer account usage and Telemetry Radar",body:"Account usage shows reset times together with capacity. Telemetry Radar has a clearer monitoring workspace and keeps history for up to 24 hours. Radar remains Beta."}],"3.39.1":[{title:"🎨 More themes, with clearer contrast",body:"Choose Omarchy, Matrix, Black Contrast, White Contrast or Catppuccin Mocha in Settings › Appearance. Fresh installations start with Rider Black; your saved theme choice is preserved."},{title:"A little more room on the canvas",body:"The minimap is smaller, leaving more room for the character and your sessions. Undo and Resume now sit beside each other at the bottom of the canvas. Telemetry Radar is marked Beta while it is being tested and improved."}],"3.39.0":[{title:"🔎 Inspect Claude Code telemetry on macOS",body:"Telemetry Radar shows Claude Code's configured telemetry and can inspect traffic at destinations you choose. When settings are absent, it can show observed connections separately; a connection alone does not prove telemetry or reveal message contents. Capture starts only after you run its generated command in Terminal, which uses macOS tcpdump with administrator permission. Captured telemetry can contain prompt or response content, and other apps sending to the same destination may appear too. Messages stay in ccdeck's memory for up to five minutes; no capture file is written."},{title:"🧭 Open panels from the edges",body:"Open the session list, Claude accounts, Usage, This machine, Usage history and Browser Watch from the window edges. You can keep several panels open beside the canvas; on a phone, the same controls sit in a bottom dock."},{title:"More control while you work",body:"Turn off single-key shortcuts if typed letters should not control the deck, see each stage while adding a Claude account, and undo a recent rearrangement. The topbar also names the Claude Code session waiting on you."},{title:"🎨 Two new dark themes",body:"Choose Rider Black or VS Code Black in Settings › Appearance. Both add a darker canvas with flatter panels and distinct focus accents; your existing Light or Dark choice stays as it was."}],"3.38.5":[{title:"🔧 Settings are in one place now",body:"The theme, the sounds, notifications, Claude FM and the minimap character are all in Settings, behind the gear at the right of the topbar, or Cmd+, (Ctrl+, on Windows and Linux). The speaker beside it keeps the quick things one click away: sounds on or off, and how loud each tone is. Nothing you had set has changed, it has only moved, and T still switches the theme. The auto-switch threshold also takes a custom value now: pick Custom… and type a whole percent from 50 to 99."},{title:"Windows: no more temperature stuck at 28 °C",body:"On many Windows laptops the only temperature Windows offers is a thermal zone wired to nothing, which reads a fixed 28 °C however hot the CPU is, and the machine panel showed it as a reading. A thermal zone is now drawn only once its value has changed. Until then the panel shows LibreHardwareMonitor's readings if its web server is running, and otherwise no Thermal section at all: the deck never invents a reading."}],"3.38.4":[{title:"🔔 A notification when Auto-switch changes your account",body:'When Auto-switch moves Claude Code to another account, ccdeck now tells you once, with where it went and why, for example "Switched to work · personal@example.com reached 90%". You can turn it off in the sound settings, where two more wait, off until you turn them on: one when a quota window of the Claude or Codex account you are on reaches 90% and again at 100%, and one when a window that had reached 90% is available again. Each is said once per window and a restart does not repeat it. With either quota notification on, the deck reads quota about every two minutes even while no page is open.'}],"3.38.3":[{title:"🧾 Subagent costs count their whole reply",body:"A subagent's request was counted from the first moment of its reply, before most of it had been written, so much of its output was left out of the deck's token and cost counts, and a subagent turn in fast mode was priced at the standard rate. Each request is now counted from its finished reply. Days with subagents will read higher than before: that is the part that was missing, not a new charge. Projects counts its history again once after the update, so past days come out right too. Codex sessions on GPT-6 Sol, GPT-6.1 Sol and GPT-6 Luna now show a cost instead of not priced."}],"3.37.1":[{title:"🔁 Expired logins repair from your other machines",body:"When a login stops working on this machine and a machine you paired with still has it working and ticked, Local network now copies it back on the next round, whether or not the account is ticked here. Before, it stayed marked expired until the account was ticked here as well, or deleted so that it arrived again. A machine that paired on its own, through Say yes to every deck that asks, still repairs only the accounts ticked here."}],"3.36.3":[{title:"🔑 An expired login asks to be signed in again",body:"When an account you added with + → Sign in stops working, the deck now tells you in one dialog, with every affected account together and Sign in again beside each. That opens the usual sign-in with the address already filled in, and the account keeps its slot, its alias and its history. Not now leaves it marked in the Accounts panel and does not ask again until it has worked and stopped again. A paired deck holding a working copy gets to repair it first, and accounts that came from a share or Local network are never asked about."}],"3.34.1":[{title:"🗂️ The tray menu stays open while you read it",body:"On Linux the menu behind the tray icon could close by itself while agents were working, often before the row you pressed took the click, so it had to be opened and pressed again. It now changes only when something it says has changed, and stays open while you choose."}],"3.34.0":[{title:"🗺️ The network map shows who you are connected to",body:"Paired decks that are on stand closest to this one, and a light runs along their wires. Paired decks that are away come next, in a colour of their own, with how long they have been gone, and machines that are not paired stand outside in grey. Decks reached over Tailscale sit together in their own shaded slice instead of on dashed wires. Pointing at a deck opens its details beside the map: whether it is there, what to do next if anything, its address and what it runs, and every login the two share, the ones that need a look first."},{title:"🔑 A login that expired everywhere says so",body:`When a shared login expired on this deck and every paired deck that is on held an expired copy too, the row said "Login expired" and waited for a repair that could never come. It now says "Login expired on all online decks". Claude retires a login's other copies each time one machine refreshes it, so shared copies expire together: sign in again on any one machine and the others repair from it on their next round.`},{title:"💬 Send feedback from inside the deck",body:'Appearance settings has a "Send feedback…" button: pick what kind it is, write a title and a few lines, and add a way to reach you if you want an answer. It goes to the people who make ccdeck, who may open a public issue from it, never with your contact in it. If it cannot be sent, the form stays filled in and says why.'}],"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.
109
109
 
110
110
  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.
111
111
 
@@ -299,8 +299,8 @@ It marks that work now. A chart with bars in it means the agent is doing somethi
299
299
 
300
300
  Nothing was added to the card and nothing new is polled. The deck already reads each session's transcript for its token counts; this reads the same file for what the model has finished writing, and a session that is quiet costs one file check per second and a half.`}]},f1="agent-dag.releaseNotesSeen";function q2(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function Hi(e,t){const n=q2(e),r=q2(t);for(let s=0;s<Math.max(n.length,r.length);s++){const o=(n[s]??0)-(r[s]??0);if(o!==0)return o<0?-1:1}return 0}function Wi(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function Yue(e){if(!e||typeof e!="object")return!1;const{title:t,body:n}=e;return typeof t=="string"&&t.trim()!==""&&typeof n=="string"&&n.trim()!==""}function Xue(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(!Wi(n)||!Array.isArray(r))continue;const s=r.filter(Yue);s.length&&t.push({version:n,notes:s})}return t.sort((n,r)=>Hi(r.version,n.version))}const U2=Xue(Kue);function O4(e,t,n){return e.filter(r=>Hi(r.version,n)<=0&&(t===null||Hi(r.version,t)>0))}function Zue(e,t){return e.filter(n=>Hi(n.version,t)===0)}function Jue(e){if(!e.length)return"";const t=e[0].version,n=e[e.length-1].version;return t===n?`v${t}`:`v${n} – v${t}`}function Que({since:e,running:t,entries:n,firstRun:r}){if(!n.length)return"Nothing in this build has anything to report yet. Most releases do not, which is the point.";if(e!==null){const i=n.length===1?"one release":`${n.length} releases`;return`You were last caught up at v${e}. Since then ${i} changed something you would notice. Clicking the version in the topbar brings this back.`}if(r&&Wi(t))return`The deck has not run in this browser before, so this is what v${t} — the release you have — changed. Earlier releases are not repeated here; clicking the version in the topbar brings all of them back.`;const s=n[0].version;if(!Wi(t))return"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.";const o=Hi(s,t);return o<0?`v${t} · 🐛 Bug fixes and performance improvements. Earlier release notes are shown below.`:o>0?"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.":`You are running v${t}, and this is what it changed — and everything before it, newest first. Most releases have nothing here, which is why the deck stays quiet about them.`}const ede=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function tde(e){const t=ede.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function nde(e){if(!e)return null;let t=null;try{t=e.getItem(f1)}catch{return null}return Wi(t)?t:null}function rde(e){if(!e)return!1;try{return e.getItem(f1),!0}catch{return!1}}function sde(e,t){if(!e)return!1;try{return e.setItem(f1,t),!0}catch{return!1}}const L4="agent-dag.tourSeen";function ade(e){if(!e)return!1;try{return e.getItem(L4)==="1"}catch{return!1}}function ode(e){if(!e)return!1;try{return e.setItem(L4,"1"),!0}catch{return!1}}function ide({tourSeen:e,decision:t}){if(t.reason==="no-version"||t.reason==="cannot-remember")return{tour:!1,notes:"none"};if(t.reason==="welcome"||t.reason==="first-run")return{tour:!e,notes:"none"};const n=t.show.length>0;return e?{tour:!1,notes:n?"now":"none"}:{tour:!0,notes:n?"after":"none"}}function lde({stored:e,running:t,notes:n,remembers:r=!0}){if(!Wi(t))return{show:[],record:null,reason:"no-version"};if(!Wi(e)){if(!r)return{show:[],record:t,reason:"cannot-remember"};const i=Zue(n,t);return i.length?{show:i,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const s=Hi(e,t);if(s===0)return{show:[],record:null,reason:"seen"};if(s>0)return{show:[],record:null,reason:"ahead"};const o=O4(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function cde(e,t){if(/\s|^$/.test(e[t+2]??""))return-1;let n=t+2;for(;n<e.length;){if(e[n]==="`"){const r=e.indexOf("`",n+1);if(r<0)break;n=r+1;continue}if(e.startsWith("**",n)&&!/\s/.test(e[n-1]??" "))return n;n++}return-1}function P4(e,t=!0){const n=[];let r="";const s=()=>{r&&(n.push({kind:"text",text:r}),r="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const i=e.indexOf("`",o+1);if(i>o+1){s(),n.push({kind:"code",text:e.slice(o+1,i)}),o=i+1;continue}}else if(t&&e.startsWith("**",o)){const i=cde(e,o);if(i>0){s(),n.push({kind:"bold",kids:P4(e.slice(o+2,i),!1)}),o=i+2;continue}}r+=e[o],o+=1}return s(),n}function No(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function Tpe(e,t,n){if(e===null)return null;const r=e+t-n;return r>0?r:null}function Rpe(e){const t=Math.ceil(e/1e3),n=Math.floor(t/60),r=t%60;return n>0?`${n}m ${r}s`:`${r}s`}function ude(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function Ape(e){return!Number.isFinite(e)||e<=0?"empty":_s(e)}function Mpe(e,t){return e.map(n=>({key:n.key,name:n.name,running:n.running,visits:t.filter(r=>r.browser===n.key).reduce((r,s)=>r+s.programVisits,0)}))}function dde(e,t){if(e===null)return null;const n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"just now";if(n<60)return`${n} sec ago`;const r=Math.round(n/60);return r<60?`${r} min ago`:`${Math.round(r/60)} hr ago`}function $pe(e){const t=e.profiles.filter(r=>r.degraded);if(t.length>0){const r=t[0],s=t.length-1;return{kind:"unreadable",text:`${r.name}/${r.profile} could not be read — ${r.reason??"no reason given"}`+(s>0?`, and ${s} more`:"")+". The watch continues on the profiles it can read."}}const n=ude(e.browsers);return n.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."}:n.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."}}const hde="Check for updates",D4="Ask npm now whether a newer ccdeck is out.",H2="Checking…",fde="Couldn't reach npm. Try again.",pde="Couldn't reach the deck. Try again.",mde="Update checks are off on this deck (AGENTS_DECK_NO_UPDATE_CHECK or AGENTS_DECK_NO_INSTALL).",gde="The deck looks again in five minutes.";function yde(e,t,n,r){const s=r?t.npx:n?Ut(t,n):void 0;return s?`${e} is out, but ${s}`:`${e} is out. Run:`}const bn=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),to=e=>bn(e,{tone:"note"});function W2(e,t){return dde(e,t)??"just now"}function wde(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?to(`${n.version} is ready. Restart to update.`):(n==null?void 0:n.status)==="checking"?to("The app is checking for updates…"):(n==null?void 0:n.status)==="downloading"?to(n.version?`${n.version} is out. The app is downloading it.`:"The app is downloading an update."):(n==null?void 0:n.status)==="current"?to(`You're on the latest, ${e.version??t}. You can check again here.`):(n==null?void 0:n.status)==="error"?to("The app's last update check failed. Try Check for updates again."):to("The app keeps itself up to date. Check for updates here.")}function vde(e,t,n){var i;const r=e.version;if((r==null?void 0:r.upgradeMode)==="install"&&e.upgradeState!=="failed"){if(e.upgradeState==="done")return bn(`${t} is installed.`);const c=e.upgradeState==="running",d=`Runs ${((i=r.upgrade)==null?void 0:i.command)??r.command} here, then restarts once nothing is running.`;return bn(c?`Installing ${t}…`:`${t} is out.`,{action:{kind:"install",label:"Update now",busy:c,why:d}})}if((r==null?void 0:r.upgradeMode)==="npx"&&r.canRestart){const c=e.upgradeState==="failed";return bn(c?`The last update to ${t} came back on ${e.running}.`:`${t} is out.`,{action:{kind:"npx",label:c?"Retry update":"Update & restart",busy:e.restarting,why:`Runs ${r.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`}})}const s=e.upgradeState==="failed"?`Installing ${t} failed. Run it yourself:`:yde(t,n,r==null?void 0:r.upgradeBlocked,(r==null?void 0:r.upgradeMode)==="npx"),o=(r==null?void 0:r.command)??null;return bn(s,{command:o,action:o?{kind:"copy",label:e.copied?"Copied":"Copy",busy:!1}:null})}function xde(e){const t=e.version;if(e.unreachable)return bn(pde,{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return bn(fde,{tone:"warn",age:e.answered?null:`Last tried ${W2(n,e.now)}.`});const r=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(r)return bn(`${r} is tagged on npm but can't be installed yet. ${gde}`);const s=t!=null&&t.checkedAt?W2(t.checkedAt,e.now):null;if(e.answered&&(t!=null&&t.latest)){const o=t.latest===e.running?`You're on the latest, ${e.running}.`:`You're on ${e.running}, ahead of npm's ${t.latest}.`;return bn(o,{age:s?`Checked ${s}.`:null})}return bn("",{age:s?`Last checked ${s}.`:null})}function bde(e,t){var s,o;const n=e.version;if((s=e.app)!=null&&s.inApp&&(n!=null&&n.checkDisabled)){const i=wde(e.app,e.running);return i&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?bn("The desktop updater did not accept the check. Try the ccdeck menu or update the desktop app.",{tone:"warn"}):e.checking?bn(H2):i}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:to(mde)};const r=(n==null?void 0:n.notice)??null;if((r==null?void 0:r.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:vde(e,r.to,t)};if((r==null?void 0:r.kind)==="restart"){const i=n!=null&&n.canRestart?`${r.to} is installed. Restart the deck to start running it.`:`${r.to} is installed. Restart ccdeck to start running it.`;return{canCheck:!0,checking:e.checking,line:bn(i)}}return e.checking?{canCheck:!0,checking:!0,line:bn(H2)}:{canCheck:!0,checking:!1,line:xde(e)}}const F4=450;async function kde(e,t=n=>new Promise(r=>setTimeout(r,n))){const[n]=await Promise.all([e(!0),t(F4)]);return n?"answered":"unreachable"}async function Nde(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,F4))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const z2="Eight pictures of what the deck shows.",V2="Restart the deck. Sessions, settings and pairings come back as they were.";function jde(e){var I;const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=jo(3e4),[r,s]=y.useState(!1),o=y.useRef(!1),[i,c]=y.useState(!1),[d,h]=y.useState(!1),f=y.useRef(t);if(y.useEffect(()=>{f.current&&!t&&h(!0),f.current=t},[t]),!e)return null;const{versionCheck:p,upgrade:g,restart:w,desktopUpdate:N,running:k,onHandOff:x}=e,b=bde({version:p.version,running:k,checking:r||t,answered:d,unreachable:i,now:n,upgradeState:g.upgradeState,copied:g.cmdCopied,restarting:w.restarting,app:{inApp:No(),update:N.appUpdate,version:f4(),menu:m4()}},M0);if(!b)return null;const j=No()&&((I=p.version)==null?void 0:I.checkDisabled);return{state:b,check:async()=>{var D;if(!sr(o.current||t)||j&&((D=N.appUpdate)==null?void 0:D.status)==="checking")return;o.current=!0,s(!0);const A=j?await Nde():await kde(p.loadVersion);o.current=!1,s(!1),c(A==="unreachable"),h(!0)},act:A=>{if(A.kind==="copy")return void g.copyCommand();x(),p.showNotice(),A.kind==="install"?g.startUpgrade():w.askRestart({upgrade:!0})},checkWhy:j?"Ask the desktop app whether a newer ccdeck is out.":D4}}function Sde({onTour:e,onRestart:t,updateCheck:n}){var h,f;const r=el("above","dialog"),s=jde(n),o=y.useId(),i=(s==null?void 0:s.state.canCheck)??!1,d=((h=s==null?void 0:s.state.line.action)==null?void 0:h.kind)==="install"||((f=s==null?void 0:s.state.line.action)==null?void 0:f.kind)==="npx"?void 0:t;return!e&&!i&&!d&&!s?null:a.jsxs("div",{className:"rn-actions",children:[(e||i||d)&&a.jsxs("div",{className:"rn-acts",children:[e&&a.jsxs("button",{type:"button",className:"btn rn-act",onClick:e,"aria-describedby":`${o}-tour`,...r.bind({label:z2}),children:[a.jsx(Hie,{}),"Take the tour"]}),s&&i&&a.jsxs("button",{type:"button",className:"btn rn-act",onClick:()=>void s.check(),"aria-busy":s.state.checking||void 0,"aria-describedby":`${o}-check`,...r.bind({label:s.checkWhy}),children:[a.jsx(Wie,{}),hde]}),d&&a.jsxs("button",{type:"button",className:"btn rn-act rn-act-restart",onClick:d,"aria-describedby":`${o}-restart`,...r.bind({label:V2}),children:[a.jsx(zie,{}),"Restart"]})]}),s&&a.jsx(_de,{line:s.state.line,onAct:s.act,bindHint:r.bind,whyId:`${o}-act`}),a.jsx("span",{hidden:!0,id:`${o}-tour`,children:z2}),a.jsx("span",{hidden:!0,id:`${o}-check`,children:(s==null?void 0:s.checkWhy)??D4}),a.jsx("span",{hidden:!0,id:`${o}-restart`,children:V2}),r.node]})}function _de({line:e,onAct:t,bindHint:n,whyId:r}){const{action:s}=e,o=s&&a.jsx(Ede,{action:s,onAct:t,bindHint:n,whyId:r});return a.jsxs("p",{className:"rn-update-line","data-tone":e.tone,children:[a.jsx("span",{className:"rn-update-what",role:"status",children:e.said}),e.age&&a.jsx("span",{className:"rn-update-age",children:e.age}),e.command?a.jsxs("span",{className:"rn-update-cmd",children:[a.jsx("code",{className:"rn-code",children:e.command}),o]}):o]})}function Ede({action:e,onAct:t,bindHint:n,whyId:r}){const s=e.kind==="copy"?null:e.why;return a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:s?"btn primary rn-line-act":"btn rn-line-act",onClick:()=>t(e),"aria-busy":e.busy||void 0,"aria-describedby":s&&r?r:void 0,...s&&n?n({label:s}):{},children:e.label}),s&&r&&a.jsx("span",{hidden:!0,id:r,children:s})]})}function Cde({entries:e,since:t,running:n,firstRun:r,onClose:s,onTour:o,updateVersion:i,updateBusy:c,onUpdateRestart:d,updateFailure:h,onRestart:f,updateCheck:p}){const g=pt(s),w=wt(s),N=Jue(e);return a.jsx("div",{className:"modal-backdrop",...w,role:"presentation",children:a.jsxs("div",{ref:g,className:"modal release-notes",onClick:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),N&&a.jsx("span",{className:"modal-tool-id",children:N})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[(i||h)&&a.jsxs("div",{className:"rn-update",children:[i&&d&&a.jsxs("div",{className:"guide-door",children:[a.jsxs("span",{children:["ccdeck v",i," is downloaded and verified."]}),a.jsx("button",{type:"button",className:"btn",onClick:d,"aria-busy":c||void 0,children:c?"Restarting…":Rh})]}),a.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),a.jsx("p",{className:"modal-note",children:Que({since:t,running:n,firstRun:r,entries:e})}),a.jsx(Sde,{onTour:i?void 0:o,onRestart:f,updateCheck:p}),e.map(k=>a.jsxs("section",{className:"modal-section",children:[a.jsxs("h3",{className:"rn-version",children:["v",k.version]}),a.jsx("ul",{className:"rn-notes",children:k.notes.map((x,b)=>{const{icon:j,rest:S}=tde(x.title);return a.jsxs("li",{className:"rn-note",children:[a.jsxs("p",{className:"rn-note-title",children:[j&&a.jsx("span",{className:"rn-note-icon",children:j}),S]}),a.jsx("p",{className:"rn-note-body",children:B4(P4(x.body))})]},b)})})]},k.version))]})]})})}function B4(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?a.jsx("code",{className:"rn-code",children:t.text},n):a.jsx("strong",{className:"rn-strong",children:B4(t.kids)},n))}function Tde({state:e,sessionId:t,onClose:n}){const r=y.useMemo(()=>Rde(e,t),[e,e.revision,t]),s=y.useRef(null),o=pt(n,{focusRef:s}),i=wt(n);return r?a.jsx("div",{className:"modal-backdrop",...i,role:"presentation",children:a.jsxs("div",{ref:o,className:"modal session-summary",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),a.jsx("span",{id:"ss-title",className:"modal-tool-name",title:r.cwd??r.sessionId,children:r.label}),a.jsxs("span",{className:"modal-tool-id",children:["· ",r.sessionId.slice(0,8)]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",title:"Total wall time",children:r.durationLabel}),a.jsx("button",{type:"button",ref:s,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("div",{className:"modal-body",children:[a.jsxs("section",{className:"ss-hero",children:[a.jsxs("div",{className:"ss-hero-left",children:[a.jsx("div",{className:"ss-cost-label",children:uL}),a.jsx("div",{className:"ss-cost",children:Ve(r.cost.total)}),r.modelChips.length>0&&a.jsx("div",{className:"ss-models",children:r.modelChips.map(c=>a.jsx("span",{className:"model-chip","data-family":zh(c),title:c,children:es(c)},c))})]}),a.jsx("div",{className:"ss-hero-right",children:r.cost.total>0&&a.jsxs(a.Fragment,{children:[a.jsx(bk,{cost:r.cost,size:"lg"}),a.jsxs("div",{className:"ss-cost-legend",children:[a.jsxs("span",{className:"ssl ssl-in",children:["input ",a.jsx("b",{children:Ve(r.cost.input)})]}),a.jsxs("span",{className:"ssl ssl-out",children:["output ",a.jsx("b",{children:Ve(r.cost.output)})]}),a.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",a.jsx("b",{children:Ve(r.cost.cacheRead)})]}),a.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",a.jsx("b",{children:Ve(r.cost.cacheWrite)})]})]})]})})]}),a.jsxs("section",{className:"ss-stats",children:[a.jsx(gi,{label:"agents",value:r.agentCount}),a.jsx(gi,{label:"subagents",value:r.subagentCount}),a.jsx(gi,{label:"tool calls",value:r.toolCount}),a.jsx(gi,{label:"prompts",value:r.promptCount}),a.jsx(gi,{label:"tokens",value:r.tokensSum.toLocaleString()}),r.errCount>0&&a.jsx(gi,{label:"errors",value:r.errCount,tone:"err"})]}),r.topTools.length>0&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Most-used tools"}),a.jsx("div",{className:"ss-top-tools",children:r.topTools.map(([c,d])=>a.jsxs("div",{className:"ss-tt",children:[a.jsx("span",{className:"ss-tt-name",children:c}),a.jsx("span",{className:"ss-tt-bar",children:a.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${d/r.topTools[0][1]*100}%`}})}),a.jsx("span",{className:"ss-tt-count",children:d})]},c))})]}),r.firstPrompt&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Opening prompt"}),a.jsx("div",{className:"ss-prompt",children:r.firstPrompt})]})]})]})}):null}function gi({label:e,value:t,tone:n}){return a.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[a.jsx("div",{className:"ss-stat-value",children:t}),a.jsx("div",{className:"ss-stat-label",children:e})]})}function Rde(e,t){const n=e.agents.get(t);if(!n)return null;const r=[];for(const S of e.agents.values())S.sessionId===t&&r.push(S);if(r.length===0)return null;const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,i=new Map;let c=0,d=0,h=0,f=0,p=0,g,w=1/0,N=0;for(const S of r){const E=jn(S);s.input+=E.input,s.output+=E.output,s.cacheRead+=E.cacheRead,s.cacheWrite+=E.cacheWrite,s.total+=E.total;for(const I of yO(S))o.add(I);S.model&&o.add(S.model),S.kind==="subagent"&&p++;const T=nO(S.prompts);d+=T.length,!g&&T.length>0&&(g=T[0].text),h+=S.usage.inputTokens+S.usage.outputTokens,c+=S.toolCount,f+=S.toolErrorCount??0;for(const[I,A]of S.toolCountByName??[])i.set(I,(i.get(I)??0)+A);w=Math.min(w,S.startedAt),N=Math.max(N,S.endedAt??Date.now())}const k=Math.max(0,N-w),x=Math.floor(k/1e3),b=x<60?`${x}s`:x<3600?`${Math.floor(x/60)}m ${String(x%60).padStart(2,"0")}s`:`${Math.floor(x/3600)}h ${Math.floor(x%3600/60)}m`,j=Array.from(i.entries()).sort((S,E)=>E[1]-S[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:b,cost:s,modelChips:Array.from(o),agentCount:r.length,subagentCount:p,toolCount:c,promptCount:d,tokensSum:h,errCount:f,topTools:j,firstPrompt:g}}const Ade="Single-key shortcuts",Mde="Keys like L, U, M, ? and Space open panels and toggle things. Turn this off if you use voice control or press them by accident.";function $de({singleKeys:e,onToggleSingleKeys:t}){return a.jsxs("section",{className:"settings-group","aria-labelledby":"settings-keyboard-caption",children:[a.jsx("div",{className:"settings-caption",children:a.jsx("h3",{id:"settings-keyboard-caption",children:"Keyboard"})}),a.jsx("div",{className:"appearance-controls",children:a.jsxs("label",{className:"appearance-row",children:[a.jsx("span",{className:"appearance-row-label",id:"settings-single-keys-label",children:Ade}),a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"settings-single-keys-label","aria-describedby":"settings-single-keys-note",onClick:t,children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{id:"settings-single-keys-note",className:"appearance-row-note",children:Mde})]})})]})}function q4({id:e,label:t="Volume",value:n,step:r=qk,onLevel:s,"aria-describedby":o}){return a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:e,children:t}),a.jsx("input",{id:e,type:"range",min:zd,max:kh,step:r,value:n,"aria-describedby":o,onChange:i=>s(Number(i.target.value)),style:{"--sm-level":`${(n-zd)/(kh-zd)*100}%`}}),a.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const U4="agent-dag.character-enabled",H4="agent-dag.fm-volume",W4=1,G2="agent-dag.fm-source",Ide=[{value:"claude-fm",label:"🎧 Claude FM"},{group:"📻 Lofi Girl",value:"lofi-relax",label:"📚 Relax / study"},{group:"📻 Lofi Girl",value:"lofi-game",label:"🎮 Chill / game"},{group:"📻 Lofi Girl",value:"lofi-vibe",label:"🌅 Vibe / chill"},{group:"📻 Lofi Girl",value:"lofi-sleep",label:"💤 Sleep / chill"},{group:"📻 Radio Mix",value:"radio-mix",label:"📡 Live radio mix"},{group:"📻 Best of Nostalgia",value:"best-of-nostalgia",label:"📼 Best of nostalgia live"},{group:"📻 The Good Life Radio",value:"good-life-radio",label:"🌴 The Good Life Radio"},{group:"☕ Cafe Music BGM",value:"cafe-music-bgm",label:"☕ Cafe music BGM"}];function Ode(e){return e==="lofi-relax"||e==="lofi-game"||e==="lofi-vibe"||e==="lofi-sleep"||e==="radio-mix"||e==="best-of-nostalgia"||e==="good-life-radio"||e==="cafe-music-bgm"?e:"claude-fm"}function Lde(e){return e!=="0"}function Pde(){return Lde(Ke(U4))}function Dde(e){return DP(e,W4)}function Fde(){return Dde(Ke(H4))}const K2=Ide,yi="Give the station a name.",Bde="Use an https YouTube live or channel link, or a direct https audio stream.";function qde({fmVolume:e,onFmVolume:t,fmMuted:n,onFmMuted:r,fmSource:s,onFmSource:o,customFmStations:i,unavailableFmStations:c,onAddFmStation:d,onRenameFmStation:h,onRemoveFmStation:f}){var he;const p=[...K2.map(le=>({...le,label:c.has(le.value)?`${le.label} · not live`:le.label,unavailable:c.has(le.value)})),...i.map(le=>({group:"🎵 Your stations",value:ka(le.id),label:c.has(le.id)?`${le.name} · unavailable`:le.name,unavailable:c.has(le.id)}))],g=p.some(le=>le.value===s&&le.unavailable),w=[];p.forEach((le,ue)=>{const ye=w[w.length-1];ye&&ye.group===le.group?ye.indexes.push(ue):w.push({group:le.group,indexes:[ue]})});const[N,k]=y.useState(!1),[x,b]=y.useState(()=>Math.max(0,p.findIndex(le=>le.value===s))),[j,S]=y.useState(!1),[E,T]=y.useState(""),[I,A]=y.useState(""),[D,L]=y.useState(""),[U,P]=y.useState(!1),[$,B]=y.useState(""),[R,F]=y.useState(""),[O,G]=y.useState(null),Y=y.useRef(0),V=y.useRef(null),q=y.useRef(null),M=y.useRef(null),z=y.useRef(null),Z=y.useRef(null),H=qi(s),X=H?i.find(le=>le.id===H):void 0;y.useEffect(()=>{const le=p.findIndex(ue=>ue.value===s);b(le<0?0:le)},[s,i,c]),y.useEffect(()=>{P(!1),B((X==null?void 0:X.name)??"")},[X==null?void 0:X.id,X==null?void 0:X.name]),y.useEffect(()=>{var le;N&&((le=document.getElementById(`appearance-fm-option-${x}`))==null||le.scrollIntoView({block:"nearest"}))},[x,N]),y.useEffect(()=>{if(!N)return;const le=ue=>{var ke,Te;const ye=ue.target;!((ke=V.current)!=null&&ke.contains(ye))&&!((Te=Z.current)!=null&&Te.contains(ye))&&k(!1)};return document.addEventListener("pointerdown",le),()=>document.removeEventListener("pointerdown",le)},[N]);const K=le=>{const ue=le.relatedTarget;ue&&!le.currentTarget.contains(ue)&&k(!1)},Q=le=>{var ye;const ue=p[le];ue&&(b(le),o(ue.value),k(!1),(ye=V.current)==null||ye.focus())},ee=le=>{if(jO(le.key)){if(!N)return;le.preventDefault(),le.stopPropagation(),k(!1);return}if(le.key==="Tab"){k(!1);return}if(le.key==="Enter"||le.key===" "){le.preventDefault(),N?Q(x):k(!0);return}le.key!=="ArrowDown"&&le.key!=="ArrowUp"&&le.key!=="Home"&&le.key!=="End"||(le.preventDefault(),k(!0),b(ue=>le.key==="Home"?0:le.key==="End"?p.length-1:Math.min(p.length-1,Math.max(0,ue+(le.key==="ArrowDown"?1:-1)))))},re=()=>{var le;return(le=V.current)==null?void 0:le.focus()};y.useEffect(()=>{if(!O)return;const le=window.setTimeout(()=>G(null),4e3);return()=>window.clearTimeout(le)},[O]);const ie=()=>{if(!X)return;const le=Date.now(),ue=xo({armedFor:O,target:X.id,armedAt:Y.current,now:le,gapMs:vo});if(ue==="arm"){G(X.id),Y.current=le;return}ue!=="ignore"&&(G(null),f(X.id),re())},de=X!==void 0&&O===X.id,pe=le=>{var ye,ke;if(le.preventDefault(),!E.trim()){L(yi),(ye=q.current)==null||ye.focus();return}const ue=f7(E,I);if(!ue){L(Bde),(ke=M.current)==null||ke.focus();return}d(ue),o(ka(ue.id)),T(""),A(""),L(""),S(!1),re()},se=le=>{var ue;if(le.preventDefault(),!!H){if(!$.trim()){F(yi),(ue=z.current)==null||ue.focus();return}h(H,$),P(!1),re()}},me=le=>{const ue=p[le],ye="unavailable"in ue&&ue.unavailable;return a.jsxs("div",{className:"appearance-source-option",role:"option",id:`appearance-fm-option-${le}`,"aria-selected":s===ue.value,"data-highlighted":x===le||void 0,"data-unavailable":ye||void 0,onMouseEnter:()=>b(le),onClick:()=>Q(le),children:[a.jsx("span",{children:ue.label}),s===ue.value&&a.jsx("span",{"aria-hidden":!0,children:"✓"})]},ue.value)};return a.jsx(a.Fragment,{children:a.jsxs("section",{className:"settings-group","aria-labelledby":"appearance-fm-caption",children:[a.jsx("div",{className:"settings-caption",children:a.jsxs("div",{children:[a.jsx("h3",{id:"appearance-fm-caption",children:"Claude FM"}),a.jsx("p",{className:"settings-caption-note",children:"Music for the character to play while you work."})]})}),a.jsxs("div",{className:"appearance-controls",children:[a.jsxs("div",{className:"appearance-source-row",children:[a.jsx("label",{htmlFor:"appearance-fm-source",children:"Station"}),a.jsxs("div",{className:`appearance-source-picker${N?" is-open":""}`,onBlur:K,children:[a.jsxs("button",{ref:V,type:"button",id:"appearance-fm-source",className:"appearance-source-trigger",role:"combobox","aria-haspopup":"listbox","aria-expanded":N,"aria-controls":N?"appearance-fm-source-list":void 0,"aria-activedescendant":N?`appearance-fm-option-${x}`:void 0,"aria-describedby":"appearance-fm-source-note",onClick:()=>k(le=>!le),onKeyDown:ee,children:[a.jsx("span",{children:((he=p.find(le=>le.value===s))==null?void 0:he.label)??K2[0].label}),a.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"m2.5 4.5 3.5 3 3.5-3"})})]}),N&&a.jsx("div",{ref:Z,id:"appearance-fm-source-list",className:"appearance-source-list",role:"listbox","aria-label":"Music stations",children:w.map((le,ue)=>le.group?a.jsxs("div",{role:"group","aria-labelledby":`appearance-fm-group-${ue}`,children:[a.jsx("div",{id:`appearance-fm-group-${ue}`,className:"appearance-source-group",role:"presentation",children:le.group}),le.indexes.map(me)]},`group-${ue}`):le.indexes.map(me))})]})]}),a.jsx("span",{id:"appearance-fm-source-note",className:"vis-hidden",children:"Changing station starts live playback automatically."}),a.jsx("p",{className:"appearance-fm-status",role:"status",children:g?i7(qi(s)!==null):""}),a.jsxs("div",{className:"appearance-station-manage",children:[a.jsx("button",{type:"button",className:"btn appearance-station-action","aria-expanded":j,onClick:()=>{S(le=>!le),L("")},children:j?"Cancel":"+ Add station"}),X&&!U&&a.jsxs("span",{className:"appearance-station-edit",children:[a.jsx("button",{type:"button",className:"btn appearance-station-action",onClick:()=>{B(X.name),F(""),P(!0)},children:"Rename"}),a.jsx("button",{type:"button",className:`btn danger appearance-station-action${de?" armed":""}`,onClick:ie,"aria-label":de?`Confirm removing ${X.name}`:`Remove ${X.name}`,title:de?"Press again to remove this station. It cannot be brought back.":"Remove this station",children:de?"Confirm":"Remove"})]})]}),j&&a.jsxs("form",{className:"appearance-station-form",onSubmit:pe,noValidate:!0,children:[a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Station name"}),a.jsx("input",{ref:q,className:"ap-manage-input",value:E,onChange:le=>T(le.target.value),"aria-invalid":D===yi||void 0,"aria-describedby":D===yi?"appearance-station-error":void 0,maxLength:kc,autoFocus:!0})]}),a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Link"}),a.jsx("input",{ref:M,className:"ap-manage-input",value:I,onChange:le=>A(le.target.value),placeholder:"https://…","aria-invalid":D!==""&&D!==yi||void 0,"aria-describedby":D&&D!==yi?"appearance-station-error":void 0,inputMode:"url",autoComplete:"off",spellCheck:!1,maxLength:zO})]}),a.jsx("button",{type:"submit",className:"btn primary",children:"Add"}),D&&a.jsx("p",{id:"appearance-station-error",className:"appearance-station-error",role:"alert",children:D})]}),X&&U&&a.jsxs("form",{className:"appearance-station-form is-rename",onSubmit:se,noValidate:!0,children:[a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Station name"}),a.jsx("input",{ref:z,className:"ap-manage-input",value:$,onChange:le=>B(le.target.value),"aria-invalid":R!==""||void 0,"aria-describedby":R?"appearance-rename-error":void 0,maxLength:kc,autoFocus:!0})]}),a.jsx("button",{type:"submit",className:"btn primary",children:"Save"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{P(!1),re()},children:"Cancel"}),R&&a.jsx("p",{id:"appearance-rename-error",className:"appearance-station-error",role:"alert",children:R})]}),a.jsx(q4,{id:"appearance-fm-volume",value:e,step:W4,"aria-describedby":"appearance-fm-volume-note",onLevel:t}),a.jsxs("label",{className:"appearance-row",children:[a.jsx("span",{className:"appearance-row-label",id:"appearance-fm-mute-label",children:"Mute music"}),a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":n,"aria-labelledby":"appearance-fm-mute-label",onClick:r,children:a.jsx("span",{className:"switch-knob"})})]})]}),a.jsx("span",{id:"appearance-fm-volume-note",className:"vis-hidden",children:"Controls live music volume."})]})})}const Ude="With no deck tab open, get a notification wherever a sound would have played.",Hde="With the ccdeck window closed, get a notification wherever a sound would have played.";function Wde(e){return e?Hde:Ude}const zde="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",Vde=[{kind:"notifySwap",label:"Account auto-switched",title:"When auto-switch moves Claude Code to another account"},{kind:"notifyQuota",label:"Quota at 90% and 100%",title:"When a quota window of the account you're on reaches 90%, and again at 100%"},{kind:"notifyReset",label:"Quota reset",title:"When a quota window that reached 90% is available again"}],Gde="For the Claude and Codex accounts you're on, whether or not the deck is open.",Kde="Held off for this run too.",Y2="Get notified when you're away from this tab.";function Yde(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:Y2};case"default":return{status:null,ask:!0,ok:!1,note:Y2};case"denied":return{status:"Blocked",ask:!1,ok:!1,note:"Your browser is blocking them; only its own site settings can undo that. You'll still be told once this tab is closed."};default:return{status:"Unavailable",ask:!1,ok:!1,note:"This browser cannot show them. You'll still be told once this tab is closed."}}}function Xde({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:r,onAskNotify:s,accountNotify:o,onToggleAccountNotify:i}){const c=Yde(r),d=No(),h=e&&!n&&!d,f=y.useRef(null),p=Es(!c.ask,f);return a.jsxs("div",{className:"sm-switches",children:[a.jsxs("div",{className:"sm-setting",children:[a.jsxs("label",{className:"sm-switch",children:[a.jsx("span",{className:"sm-switch-label",id:"sm-notify-label",children:"Notifications while closed"}),a.jsx("button",{ref:f,type:"button",role:"switch","aria-checked":e,"aria-labelledby":"sm-notify-label",className:"switch",onClick:t,title:"With no deck tab open, a notification wherever a sound would play",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsx("p",{className:"sm-note",children:n?zde:Wde(d)})]}),h&&a.jsxs("section",{className:"sm-channel","aria-labelledby":"sm-channel-name",children:[a.jsxs("div",{className:"sm-channel-head",children:[a.jsx("h3",{className:"sm-channel-name",id:"sm-channel-name",children:"Browser notifications"}),c.ask?a.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{p(),s()},children:"Enable"}):a.jsxs("span",{className:"sm-channel-state","data-ok":c.ok||void 0,children:[c.ok&&a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),c.status]})]}),a.jsx("p",{className:"sm-note",children:c.note})]}),a.jsxs("div",{className:"sm-account-switches",children:[a.jsx("p",{className:"sm-note",children:n?Kde:Gde}),Vde.map(({kind:g,label:w,title:N})=>a.jsxs("label",{className:"sm-switch",children:[a.jsx("span",{className:"sm-switch-label",id:`sm-${g}-label`,children:w}),a.jsx("button",{type:"button",role:"switch","aria-checked":o[g],"aria-labelledby":`sm-${g}-label`,className:"switch",onClick:()=>i(g),title:N,children:a.jsx("span",{className:"switch-knob"})})]},g))]})]})}function Zde({section:e}){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e==="sounds"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),a.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),a.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}),e==="general"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M1.5 3h4.3M9.2 3h3.3M1.5 7h1.3M6.2 7h6.3M1.5 11h6.3M11.2 11h1.3"}),a.jsx("circle",{cx:"7.5",cy:"3",r:"1.7"}),a.jsx("circle",{cx:"4.5",cy:"7",r:"1.7"}),a.jsx("circle",{cx:"9.5",cy:"11",r:"1.7"})]}),e==="notifications"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3.4 9.1c.6-.8.6-1.8.6-3V4.7a3 3 0 0 1 6 0v1.4c0 1.2 0 2.2.6 3"}),a.jsx("path",{d:"M2.2 9.1h9.6"}),a.jsx("path",{d:"M5.7 11.2a1.3 1.3 0 0 0 2.6 0"})]}),e==="music"&&a.jsx("path",{d:"M2 8.4h2a1 1 0 0 1 1 1v1.4a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V7.2a5 5 0 0 1 10 0v3.6a1 1 0 0 1-1 1h-1a1 1 0 0 1-1-1V9.4a1 1 0 0 1 1-1h2"})]})}const Jde=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function Qde(e){return Jde.find(t=>e(t))}const ehe=4400;function the(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function nhe({full:e,setCustomError:t,runCustom:n,onImportCustom:r}){const[s,o]=y.useState(!1),i=y.useRef(null),c=y.useRef(null),d=y.useRef(!1),h=()=>{var p;c.current!==null&&clearTimeout(c.current),c.current=null,((p=i.current)==null?void 0:p.state)==="recording"&&i.current.stop()},f=async()=>{var g;if(e)return;if(t(""),!((g=navigator.mediaDevices)!=null&&g.getUserMedia)||typeof MediaRecorder>"u"){t("Microphone recording is unavailable in this browser.");return}let p;try{p=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{d.current||t("Microphone access was denied or unavailable.");return}if(d.current||i.current){p.getTracks().forEach(w=>w.stop());return}try{const w=Qde(x=>MediaRecorder.isTypeSupported(x)),N=new MediaRecorder(p,w?{mimeType:w}:void 0),k=[];i.current=N,N.ondataavailable=x=>{x.data.size&&k.push(x.data)},N.onerror=()=>t("Recording failed. Please try again."),N.onstop=()=>{p.getTracks().forEach(S=>S.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const x=i.current===N;if(x&&(i.current=null),o(!1),!x||!k.length)return;const b=the(N.mimeType),j=new File(k,b.name,{type:b.type});n(()=>r(j))},N.start(200),o(!0),c.current=setTimeout(h,ehe)}catch{i.current=null,p.getTracks().forEach(w=>w.stop()),t("This browser cannot record a supported audio format.")}};return y.useEffect(()=>(d.current=!1,()=>{d.current=!0,c.current!==null&&clearTimeout(c.current);const p=i.current;i.current=null,(p==null?void 0:p.state)==="recording"&&p.stop()}),[]),{recording:s,startRecording:f,stopRecording:h}}function rhe({full:e,fullProps:t,runCustom:n,onCreateVoice:r}){const[s,o]=y.useState("Custom voice"),[i,c]=y.useState("Your turn"),[d,h]=y.useState(""),[f,p]=y.useState("1"),[g,w]=y.useState("1"),[N,k]=y.useState([]);return y.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const x=()=>{k(window.speechSynthesis.getVoices())};return x(),window.speechSynthesis.addEventListener("voiceschanged",x),()=>window.speechSynthesis.removeEventListener("voiceschanged",x)},[]),a.jsxs("details",{className:"sm-voice",children:[a.jsxs("summary",{...t,onClick:x=>{const b=x.currentTarget.parentElement;e&&b&&!b.open&&x.preventDefault()},children:[a.jsx("span",{children:"Spoken voice"}),a.jsx("span",{children:"Create from text"})]}),a.jsxs("div",{className:"sm-voice-fields",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Name"}),a.jsx("input",{className:"ap-manage-input",value:s,maxLength:80,onChange:x=>o(x.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Text"}),a.jsx("input",{className:"ap-manage-input",value:i,maxLength:180,onChange:x=>c(x.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Voice"}),a.jsxs("select",{className:"sm-select",value:d,onChange:x=>h(x.target.value),children:[a.jsx("option",{value:"",children:"System default"}),N.map(x=>a.jsx("option",{value:x.voiceURI,children:x.name},x.voiceURI))]})]}),a.jsxs("div",{className:"sm-voice-pair",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Rate"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:f,onChange:x=>p(x.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Pitch"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:g,onChange:x=>w(x.target.value)})]})]}),a.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await r({name:s,text:i,voiceURI:d,rate:parseFloat(f),pitch:parseFloat(g)}),c("Your turn")})},children:"Add spoken voice"})]})]})}function she({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:r,onPreviewCustom:s,onDeleteCustom:o}){const[i,c]=y.useState(""),d=e.length,h=k0(d),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[g,w]=y.useState(null),N=y.useRef(0),k=y.useRef(new Map),x=y.useRef(null),b=y.useRef(null);y.useEffect(()=>{if(!g)return;const A=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(A)},[g]);const j=async A=>{c("");try{await A()}catch(D){c(D instanceof Error?D.message:"Custom audio could not be saved.")}},S=(A,D)=>{const L=Date.now(),U=xo({armedFor:g,target:A,armedAt:N.current,now:L,gapMs:vo});if(U==="arm"){w(A),N.current=L;return}if(U==="ignore")return;w(null);const P=ste(e.map($=>$.id),A);j(async()=>{var B;await o(A);const $=document.activeElement;$!==D&&!Bn(($==null?void 0:$.tagName)??null)||(B=P?k.current.get(P):x.current)==null||B.focus()})},{recording:E,startRecording:T,stopRecording:I}=nhe({full:f,setCustomError:c,runCustom:j,onImportCustom:t});return a.jsxs("section",{className:"sm-custom","aria-labelledby":"sm-custom-title",children:[a.jsxs("div",{className:"sm-custom-head",children:[a.jsx("h3",{className:"sm-tone-name",id:"sm-custom-title",children:"Custom sounds"}),a.jsxs("span",{children:[d," of ",b0,", kept on this machine"]})]}),f&&a.jsx("p",{className:"sm-note",id:"sm-custom-full",children:h}),a.jsxs("div",{className:"sm-custom-actions",children:[a.jsxs("div",{className:"sm-custom-card",children:[a.jsxs("span",{className:"sm-custom-card-copy",children:[a.jsx("strong",{children:"Import audio"}),a.jsx("span",{children:"WAV, MP3 or OGG"})]}),a.jsx("button",{ref:x,type:"button",className:"btn sm-custom-action",...p,onClick:()=>{var A;f||(A=b.current)==null||A.click()},children:"Choose file"}),a.jsx("input",{ref:b,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:A=>{var L;const D=(L=A.target.files)==null?void 0:L[0];A.currentTarget.value="",D&&!f&&j(()=>t(D))}})]}),a.jsxs("div",{className:"sm-custom-card",children:[a.jsxs("span",{className:"sm-custom-card-copy",children:[a.jsx("strong",{children:"Record a clip"}),a.jsx("span",{children:E?"Recording…":"Up to 5 seconds"})]}),E?a.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:I,children:"Stop & save"}):a.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void T(),children:"Record"})]})]}),a.jsx(rhe,{full:f,fullProps:p,runCustom:j,onCreateVoice:n}),e.length>0&&a.jsx("div",{className:"sm-custom-list",children:e.map(A=>a.jsxs("div",{className:"sm-custom-item",children:[a.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${A.name}`,defaultValue:A.name,maxLength:80,onBlur:D=>{if(!D.target.value.trim()){D.target.value=A.name;return}j(()=>r(A.id,D.target.value))},onKeyDown:D=>{D.key==="Enter"&&D.currentTarget.blur()}}),a.jsx("span",{children:A.kind==="audio"?`${A.duration.toFixed(1)}s`:"Voice"}),a.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${A.name}`,onClick:()=>s(A.id),children:"Play"}),a.jsx("button",{type:"button",ref:D=>{D?k.current.set(A.id,D):k.current.delete(A.id)},className:`btn sm-custom-icon${g===A.id?" armed":""}`,onKeyDown:D=>{D.repeat&&D.preventDefault()},onClick:D=>S(A.id,D.currentTarget),"aria-label":g===A.id?`Confirm deleting ${A.name}`:`Delete ${A.name}`,title:g===A.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:g===A.id?"Confirm":"Delete"})]},A.id))}),i&&a.jsx("p",{className:"sm-custom-error",role:"alert",children:i})]})}function ahe({soundOn:e,onToggleSound:t}){const n=y.useId(),r=Sn();return a.jsxs("div",{className:"sm-setting",children:[a.jsxs("label",{className:"sm-switch",children:[a.jsx("span",{className:"sm-switch-label",id:n,children:"Play sounds"}),a.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-labelledby":n,className:"switch",onClick:t,title:"A tone when a turn finishes, and when Claude asks for something",children:a.jsx("span",{className:"switch-knob"})})]}),r&&a.jsxs("p",{className:"sm-note sm-key-note",children:[a.jsx("kbd",{children:"M"}),"Mute or unmute sounds anywhere."]})]})}const L0="custom:";function X2(e){return`${L0}${e}`}function ohe(e){return e.startsWith(L0)?e.slice(L0.length):null}const Z2={done:"Turn finished","needs-input":"Claude is asking"},ihe={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function lhe({chime:e,tone:t,soundOn:n,customAssets:r,customSelections:s,onLevel:o,onFigure:i,onPreview:c,onBuiltInSelected:d,onCustomSelected:h}){const f=`sm-level-${e}`,p=`sm-figure-${e}`,g=s[e];return a.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${e}`,children:[a.jsxs("div",{className:"sm-tone-head",children:[a.jsx("h3",{className:"sm-tone-name",id:`sm-name-${e}`,children:Z2[e]}),a.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":`Hear the ${Z2[e].toLowerCase()} tone`,title:n?"Play this tone now, at what it is set to":"Plays even when sounds are off","aria-describedby":n?void 0:"sm-preview-note",children:[a.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:a.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),a.jsx(q4,{id:f,value:t.level,onLevel:w=>o(e,w)}),a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:p,children:"Tone"}),a.jsxs("select",{id:p,className:"sm-select",value:g?X2(g):t.figure,onChange:w=>{const N=w.target.value,k=ohe(N);k!==null?h(e,k):(d(e),i(e,N))},children:[Bk[e].map(w=>a.jsx("option",{value:w.id,children:w.label},w.id)),r.length>0&&a.jsx("optgroup",{label:"Custom",children:r.map(w=>a.jsx("option",{value:X2(w.id),children:w.name},w.id))})]})]}),a.jsx("p",{className:"sm-note",children:ihe[e]})]})}const che="Claude Code isn't on this machine, so only Turn finished plays here — for Codex turns.";function uhe({soundOn:e,onToggleSound:t,prefs:n,claudeHere:r,onLevel:s,onFigure:o,onPreview:i,customAssets:c,customSelections:d,onBuiltInSelected:h,onCustomSelected:f,onImportCustom:p,onCreateVoice:g,onRenameCustom:w,onPreviewCustom:N,onDeleteCustom:k}){var S;const x=nte(d),b=((S=c.find(E=>E.id===x))==null?void 0:S.name)??"the same custom sound",j=x?`Both tones use “${b}”. They may be harder to tell apart.`:"";return a.jsxs("div",{className:"sm-sounds",children:[a.jsx(ahe,{soundOn:e,onToggleSound:t}),!r&&a.jsx("p",{className:"sm-note",children:che}),!e&&a.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:"Plays even when sounds are off, so you can set a tone before turning sounds back on."}),a.jsx("div",{className:"sm-tones",children:Wd.map(E=>a.jsx(lhe,{chime:E,tone:n[E],soundOn:e,customAssets:c,customSelections:d,onLevel:s,onFigure:o,onPreview:i,onBuiltInSelected:h,onCustomSelected:f},E))}),j&&a.jsx("p",{className:"sm-note","aria-hidden":!0,children:j}),a.jsx("p",{className:"vis-hidden",role:"status",children:j}),a.jsx(she,{customAssets:c,onImportCustom:p,onCreateVoice:g,onRenameCustom:w,onPreviewCustom:N,onDeleteCustom:k})]})}function dhe({theme:e}){return a.jsx("span",{className:"appearance-preview","data-swatch":e,children:a.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),a.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),a.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),a.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),a.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),a.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),a.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),a.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),a.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),a.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function hhe({theme:e,onTheme:t,singleKeys:n}){const r=s=>{var c;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(s.key))return;s.preventDefault();const i=(ma.indexOf(e)+(s.key==="ArrowLeft"||s.key==="ArrowUp"?-1:1)+ma.length)%ma.length;t(ma[i]),(c=s.currentTarget.querySelectorAll('[role="radio"]')[i])==null||c.focus()};return a.jsxs("section",{className:"settings-group","aria-labelledby":"appearance-theme-caption",children:[a.jsxs("div",{className:"settings-caption",children:[a.jsxs("div",{children:[a.jsx("h3",{id:"appearance-theme-caption",children:"Color theme"}),a.jsx("p",{className:"settings-caption-note",children:"Choose how the dashboard looks."})]}),n&&a.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"})]}),a.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":n?"T":void 0,onKeyDown:r,children:ma.map(s=>a.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","data-theme-choice":s,"aria-checked":e===s,tabIndex:e===s?0:-1,onClick:()=>t(s),children:[a.jsx(dhe,{theme:s}),a.jsxs("span",{className:"appearance-theme-name",children:[If[s].name,a.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},s))})]})}const z4="agent-dag.character",wb=[{id:"deck",name:"Deck companion"},{id:"fox",name:"Fox"},{id:"penguin",name:"Penguin"}];function fhe(e){return e==="fox"||e==="penguin"?e:"deck"}function phe(){return fhe(Ke(z4))}function mhe({character:e,onCharacter:t}){const n=y.useRef([]);function r(s,o){var c;const i=$k(s,o,wb.length,"vertical");i.kind==="select"&&(s.preventDefault(),t(wb[i.index].id),(c=n.current[i.index])==null||c.focus())}return a.jsx("div",{className:"character-picker",role:"radiogroup","aria-label":"Choose character",children:wb.map((s,o)=>a.jsxs("button",{type:"button",className:"character-choice",role:"radio","aria-checked":e===s.id,tabIndex:e===s.id?0:-1,ref:i=>{n.current[o]=i},onClick:()=>t(s.id),onKeyDown:i=>r(i,o),children:[a.jsx("span",{className:"character-preview",children:a.jsx(tL,{character:s.id,act:null,facing:"right"})}),a.jsx("span",{children:s.name}),a.jsx("svg",{className:"character-check",viewBox:"0 0 16 16","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"m3 8 3 3 7-7",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})]},s.id))})}function ghe({characterEnabled:e,onToggleCharacter:t,character:n="deck",onCharacter:r}){return a.jsxs("section",{className:"settings-group","aria-labelledby":"appearance-character-caption",children:[a.jsxs("div",{className:"settings-caption",children:[a.jsx("h3",{id:"appearance-character-caption",children:"Character"}),a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"appearance-character-caption",onClick:t,children:a.jsx("span",{className:"switch-knob"})})]}),a.jsx(mhe,{character:n,onCharacter:r})]})}function yhe({section:e,onSection:t,onClose:n,providers:r,sound:s,tones:o,customTones:i,notify:c,appearance:d,fm:h}){const f=y.useRef(null),p=pt(n,{focusRef:f}),g=wt(n),w=y.useRef([]),N=Woe(e);y.useEffect(()=>{var Ne,Ee;zoe((Ne=document.activeElement)==null?void 0:Ne.id,e)&&((Ee=f.current)==null||Ee.focus())},[e]);const{theme:k,setTheme:x,characterEnabled:b,setCharacterEnabled:j,character:S,setCharacter:E}=d,T=Sn(),I=Ne=>{var Le;const Ee=$k(Ne,N,tc.length,"vertical");Ee.kind!=="pass"&&(Ne.preventDefault(),t(tc[Ee.index].id),(Le=w.current[Ee.index])==null||Le.focus())},A=Ne=>{var $e;if(Ne.key===" "){Ne.stopPropagation();return}if(UO(Ne.key,T))return;const Ee=Ne.target;if(uo(Ee)||Ee.tagName==="SELECT"||Ne.key!=="t"&&Ne.key!=="T"||Ne.ctrlKey||Ne.metaKey||Ne.altKey)return;Ne.preventDefault(),Ne.stopPropagation();const Le=s4(k);x(Le),Ee.getAttribute("role")==="radio"&&(($e=Ne.currentTarget.querySelector(`[role="radio"][data-theme-choice="${Le}"]`))==null||$e.focus())},{soundOn:D,toggleSound:L}=s,{tonePrefs:U,previewTone:P,changeTone:$}=o,{customSelections:B,customAssets:R,clearCustomOnly:F,selectCustomTone:O,importNotificationAudio:G,createNotificationVoice:Y,renameCustomAsset:V,deleteCustomAsset:q,previewCustomAsset:M}=i,{notifyPermission:z,notifyOn:Z,notifyVetoed:H,toggleNotify:X,notifySupported:K,askForNotifications:Q,accountNotify:ee,toggleAccountNotify:re}=c,{fmVolume:ie,setFmVolume:de,fmMuted:pe,setFmMuted:se,fmSource:me,customFmStations:he,unavailableFmStations:le,addFmStation:ue,renameFmStation:ye,removeFmStation:ke,pickFmSource:Te}=h,xe=(()=>{switch(e){case"notifications":return a.jsx(Xde,{notifyOn:Z,onToggleNotify:X,notifyVetoed:H,notifyPermission:K?z:"unsupported",onAskNotify:Q,accountNotify:ee,onToggleAccountNotify:re});case"sounds":return a.jsx(uhe,{soundOn:D===!0,onToggleSound:L,prefs:U,claudeHere:r.claude,onLevel:(Ne,Ee)=>$(Ne,{level:Ee}),onFigure:(Ne,Ee)=>$(Ne,{figure:Ee}),onPreview:Ne=>P(Ne),customAssets:R,customSelections:B,onBuiltInSelected:F,onCustomSelected:O,onImportCustom:G,onCreateVoice:Y,onRenameCustom:V,onPreviewCustom:M,onDeleteCustom:q});case"music":return a.jsx(qde,{fmVolume:ie,onFmVolume:de,fmMuted:pe,onFmMuted:()=>se(Ne=>!Ne),fmSource:me,onFmSource:Te,customFmStations:he,unavailableFmStations:le,onAddFmStation:ue,onRenameFmStation:ye,onRemoveFmStation:ke});default:return a.jsxs(a.Fragment,{children:[a.jsx(hhe,{theme:k,onTheme:x,singleKeys:T}),a.jsx(ghe,{characterEnabled:b,character:S,onCharacter:E,onToggleCharacter:()=>j(Ne=>!Ne)}),a.jsx($de,{singleKeys:T,onToggleSingleKeys:()=>Wz(!T)})]})}})();return a.jsx("div",{className:"modal-backdrop",...g,role:"presentation",children:a.jsxs("div",{ref:p,id:"settings",className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",onClick:Ne=>Ne.stopPropagation(),onKeyDown:A,children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"settings-title",className:"modal-tool-name",children:"Settings"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close settings",title:"Close (Esc)",children:"×"})})]}),a.jsxs("div",{className:"settings-body",children:[a.jsx("div",{className:"settings-nav",role:"tablist","aria-label":"Settings sections","aria-orientation":"vertical",onKeyDown:I,children:tc.map((Ne,Ee)=>a.jsxs("button",{ref:Le=>{w.current[Ee]=Le,Ne.id===e&&(f.current=Le)},type:"button",role:"tab",id:`settings-tab-${Ne.id}`,className:"settings-tab","aria-selected":Ne.id===e,"aria-controls":"settings-pane",tabIndex:Ne.id===e?0:-1,onClick:()=>t(Ne.id),children:[a.jsx(Zde,{section:Ne.id}),a.jsx("span",{className:"settings-tab-label",children:Ne.label})]},Ne.id))}),a.jsxs("div",{className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,children:[a.jsx("h2",{className:"settings-pane-title",children:tc[N].label}),xe]},e)]})]})})}function whe({tool:e,onClose:t}){const n=pt(t),r=wt(t),s=e.endedAt==null?"inflight":e.ok===!1?"err":"done",o=y.useRef({of:null});o.current.of!==e&&(o.current={of:e}),e.input!==void 0&&(o.current.input=e.input),e.response!==void 0&&(o.current.response=e.response);const i=o.current.input??e.inputPreview,c=o.current.response??e.errorPreview,d=e.trimmed===!0&&o.current.input===void 0&&o.current.response===void 0,h=y.useMemo(()=>{const f=gH(e.name,i,c);return{input:f.input.map((p,g)=>a.jsx(J2,{block:p},g)),response:f.response.map((p,g)=>a.jsx(J2,{block:p},g)),copyInput:$S(e.name,"input",i),copyResponse:$S(e.name,"response",c)}},[e.name,i,c]);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal",onClick:f=>f.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 ${s}`,"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:kO(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:[d&&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(Q2,{text:h.copyInput,what:"input"})]}),h.input]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsxs("h4",{children:["Response ",s==="err"&&a.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&a.jsx(Q2,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?a.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const vhe={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function J2({block:e}){const[t,n]=y.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=y.useMemo(()=>cH(e),[e]),{shown:s}=rO(r,t),o=uH(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((i,c)=>a.jsxs("span",{className:i.tone?vhe[i.tone]:void 0,children:[i.text,c<s.length-1?`
301
301
  `:""]},c)):s.map(i=>i.text).join(`
302
- `)}),o&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(i=>!i),children:o.label})]})}function Q2({text:e,what:t}){const[n,r]=y.useState(!1),s=y.useRef(!0);return y.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 So(e).then(o=>{!o||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const xhe=h1(()=>Uc(()=>import("./UsageHistoryModal-C7ay7k-d.js"),[]),"Usage history"),bhe=h1(()=>Uc(()=>import("./BrowserWatchModal-BB9KSESQ.js"),[]),"Browser Watch"),khe=h1(()=>Uc(()=>import("./TrafficRadar-DlMqUfpo.js"),[]),"Telemetry Radar");function Nhe({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:r,restart:s,upgrade:o,lanPairs:i,attention:c,clearFlow:d,watchBadge:h,announcements:f,appearance:p,providers:g,stateRef:w,agentCount:N,menus:k,sound:x,tones:b,customTones:j,notify:S,fm:E}){const{openedTool:T,setOpenedToolKey:I,usageHistoryOpen:A,setUsageHistoryOpen:D,browserWatchOpen:L,setBrowserWatchOpen:U,contextAgent:P,setContextFor:$,summaryFor:B,setSummaryFor:R,keyHelpOpen:F,setKeyHelpOpen:O,feedbackOpen:G,setFeedbackOpen:Y,feedbackPrefill:V,setFeedbackPrefill:q}=e,{trafficRadarOpen:M,setTrafficRadarOpen:z}=e,{tourOpen:Z,openTour:H,closeTour:X,releaseNotes:K,closeReleaseNotes:Q,chipVersion:ee}=t,{desktopUpdateRestarting:re,desktopUpdateFailure:ie,readyAppUpdate:de,askDesktopUpdateRestart:pe}=n,{version:se}=r,{askRestart:me}=s,{clearConfirmOpen:he,setClearConfirmOpen:le,requestClear:ue}=d,{setWatchOn:ye,markWatchSeen:ke}=h,{setWatchSaid:Te}=f,{palette:xe}=p,{settingsOpen:Ne,settingsSection:Ee,showSection:Le,closeSettings:$e,openSettings:rt}=k;return a.jsxs(a.Fragment,{children:[T&&a.jsx(whe,{tool:T,onClose:()=>I(null)}),A&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(xhe,{providers:g,onClose:()=>D(!1)})}),L&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(bhe,{onClose:()=>U(!1),onSeen:Be=>{Te(""),ke(Be)},onWatching:ye,palette:xe})}),P&&a.jsx(OW,{agent:P,onClose:()=>$(null)}),M&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(khe,{sessions:[...w.current.agents.values()].filter(Be=>Be.kind==="root"&&Be.provider!=="codex").map(Be=>({id:Be.sessionId,label:Be.cwdBasename??Be.label})),onClose:()=>z(!1)})}),G&&a.jsx(M4,{initialKind:V==null?void 0:V.initialKind,initialBody:V==null?void 0:V.initialBody,onClose:()=>{Y(!1),q(null)}}),B&&a.jsx(Tde,{state:w.current,sessionId:B,onClose:()=>R(null)}),Ne&&a.jsx(yhe,{section:Ee,onSection:Le,onClose:$e,providers:g,sound:x,tones:b,customTones:j,notify:S,appearance:p,fm:E}),K&&a.jsx(Cde,{entries:K.entries,since:K.since,firstRun:K.firstRun,running:ee,onClose:Q,onTour:()=>{Q(),H()},updateVersion:de==null?void 0:de.version,updateBusy:re,updateFailure:ie&&(!de||de.version===ie.version)?ole(ie.failure,ie.version):void 0,onUpdateRestart:de?()=>{pe(de.version)}:void 0,onRestart:!de&&(se!=null&&se.canRestart)?()=>{Q(),me()}:void 0,updateCheck:{versionCheck:r,upgrade:o,restart:s,desktopUpdate:n,running:ee,onHandOff:Q}}),a.jsx(jhe,{lanPairs:i,attention:c}),F&&a.jsx(Aue,{onClose:()=>O(!1),onTour:()=>{O(!1),H()},onSettings:()=>{O(!1),rt("general")}}),Z&&a.jsx(iP,{title:"What the deck shows you",steps:cJ,onClose:X}),he&&a.jsx(Jle,{agentCount:N,onConfirm:()=>ue("confirmation"),onCancel:()=>le(!1)})]})}function jhe({lanPairs:e,attention:t}){const n=Hue(e);return a.jsxs(a.Fragment,{children:[n,a.jsx(Gue,{...t,pairing:n!=null})]})}const She=10,V4=500,G4=4e3,_he=[/ResizeObserver loop/i,/^Script error\.?$/i],$h=String.raw`[^\s\\/:'"\`<>|?*;,]`,Ehe=String.raw`${$h}(?:[^\\/\r\n:'"\`<>|?*;,]*${$h})?[\\/]`,Che=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,Gl=String.raw`(?:${Ehe})*(?:${Che})?`,The=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${Gl}|[A-Za-z]:[\\/]${Gl}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${Gl}|/(?=${$h})${Gl}|(?<!:)//(?=${$h})${Gl})`,Rhe=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,Ahe=new Set([".claude",".codex"]);function Mhe(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...r]=e.slice(2).split(/[\\/]/);return n?Ahe.has(n)?r.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const $he=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function Ihe(e,t,n){return n?"<deck>":`${t}://<host>`}const e$=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,K4=String.raw`${e$}(?:\.${e$}){3}`,vb=String.raw`[0-9A-Fa-f]{1,4}`,t$=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${vb}:){7})(?:(?:${vb})?:)+(?:${K4}|${vb})?`,n$=String.raw`%[\w-]+(?:\.[\w-]+)*`,r$=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,Ohe=String.raw`(?<![\w:.%-])(?:\[(?!${r$}\])${t$}(?:${n$})?\]|(?!${r$}(?::\d{1,5})?(?![\w:%]|\.\d))${t$}(?:${n$})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${K4}(?![\w-]|\.\d)`,xb=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,Lhe=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${xb}|${xb}(?=:\d{1,5}(?![\w:-]|\.\w))|${xb}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function s$(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(The,"g"),Mhe).replace(new RegExp(Rhe,"g"),"<project>").replace(new RegExp($he,"g"),Ihe).replace(new RegExp(Ohe,"g"),"<host>").replace(new RegExp(Lhe,"g"),"<host>").replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,"<email>").replace(/\b(?:sk-ant-[A-Za-z0-9_-]{8,}|sk-[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{20,}|xox[abpr]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}|[A-Fa-f0-9]{40,}|[A-Za-z0-9+_=-]{48,})/g,"<secret>")}const Y4=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function Phe(e,t,n=Y4){const r=String(e??"").slice(0,V4).trim();r&&n({message:r,stack:typeof t=="string"?t.slice(0,G4):void 0})}function Dhe(e,t=window,n=Y4){let r=0;const s=new Set,o=(d,h)=>{const f=String(d??"").slice(0,V4).trim();!e()||!f||r>=She||s.has(f)||_he.some(p=>p.test(f))||(s.add(f),r++,n({message:f,stack:typeof h=="string"?h.slice(0,G4):void 0}))},i=d=>{var h,f;return o(((h=d.error)==null?void 0:h.message)??d.message,(f=d.error)==null?void 0:f.stack)},c=d=>typeof d.reason=="object"&&d.reason!==null?o(d.reason.message,d.reason.stack):o(d.reason,void 0);return t.addEventListener("error",i),t.addEventListener("unhandledrejection",c),()=>{t.removeEventListener("error",i),t.removeEventListener("unhandledrejection",c)}}const Fhe=12;function Bhe(e,t){const n=[s$(e).trim()||"The deck threw an error with no message."],r=t==null?void 0:t.trim();if(r){const s=r.split(`
302
+ `)}),o&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(i=>!i),children:o.label})]})}function Q2({text:e,what:t}){const[n,r]=y.useState(!1),s=y.useRef(!0);return y.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 So(e).then(o=>{!o||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const xhe=h1(()=>Uc(()=>import("./UsageHistoryModal-DNMj-rt1.js"),[]),"Usage history"),bhe=h1(()=>Uc(()=>import("./BrowserWatchModal-C07nz8O3.js"),[]),"Browser Watch"),khe=h1(()=>Uc(()=>import("./TrafficRadar-rynjtyN0.js"),[]),"Telemetry Radar");function Nhe({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:r,restart:s,upgrade:o,lanPairs:i,attention:c,clearFlow:d,watchBadge:h,announcements:f,appearance:p,providers:g,stateRef:w,agentCount:N,menus:k,sound:x,tones:b,customTones:j,notify:S,fm:E}){const{openedTool:T,setOpenedToolKey:I,usageHistoryOpen:A,setUsageHistoryOpen:D,browserWatchOpen:L,setBrowserWatchOpen:U,contextAgent:P,setContextFor:$,summaryFor:B,setSummaryFor:R,keyHelpOpen:F,setKeyHelpOpen:O,feedbackOpen:G,setFeedbackOpen:Y,feedbackPrefill:V,setFeedbackPrefill:q}=e,{trafficRadarOpen:M,setTrafficRadarOpen:z}=e,{tourOpen:Z,openTour:H,closeTour:X,releaseNotes:K,closeReleaseNotes:Q,chipVersion:ee}=t,{desktopUpdateRestarting:re,desktopUpdateFailure:ie,readyAppUpdate:de,askDesktopUpdateRestart:pe}=n,{version:se}=r,{askRestart:me}=s,{clearConfirmOpen:he,setClearConfirmOpen:le,requestClear:ue}=d,{setWatchOn:ye,markWatchSeen:ke}=h,{setWatchSaid:Te}=f,{palette:xe}=p,{settingsOpen:Ne,settingsSection:Ee,showSection:Le,closeSettings:$e,openSettings:rt}=k;return a.jsxs(a.Fragment,{children:[T&&a.jsx(whe,{tool:T,onClose:()=>I(null)}),A&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(xhe,{providers:g,onClose:()=>D(!1)})}),L&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(bhe,{onClose:()=>U(!1),onSeen:Be=>{Te(""),ke(Be)},onWatching:ye,palette:xe})}),P&&a.jsx(OW,{agent:P,onClose:()=>$(null)}),M&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(khe,{sessions:[...w.current.agents.values()].filter(Be=>Be.kind==="root"&&Be.provider!=="codex").map(Be=>({id:Be.sessionId,label:Be.cwdBasename??Be.label})),onClose:()=>z(!1)})}),G&&a.jsx(M4,{initialKind:V==null?void 0:V.initialKind,initialBody:V==null?void 0:V.initialBody,onClose:()=>{Y(!1),q(null)}}),B&&a.jsx(Tde,{state:w.current,sessionId:B,onClose:()=>R(null)}),Ne&&a.jsx(yhe,{section:Ee,onSection:Le,onClose:$e,providers:g,sound:x,tones:b,customTones:j,notify:S,appearance:p,fm:E}),K&&a.jsx(Cde,{entries:K.entries,since:K.since,firstRun:K.firstRun,running:ee,onClose:Q,onTour:()=>{Q(),H()},updateVersion:de==null?void 0:de.version,updateBusy:re,updateFailure:ie&&(!de||de.version===ie.version)?ole(ie.failure,ie.version):void 0,onUpdateRestart:de?()=>{pe(de.version)}:void 0,onRestart:!de&&(se!=null&&se.canRestart)?()=>{Q(),me()}:void 0,updateCheck:{versionCheck:r,upgrade:o,restart:s,desktopUpdate:n,running:ee,onHandOff:Q}}),a.jsx(jhe,{lanPairs:i,attention:c}),F&&a.jsx(Aue,{onClose:()=>O(!1),onTour:()=>{O(!1),H()},onSettings:()=>{O(!1),rt("general")}}),Z&&a.jsx(iP,{title:"What the deck shows you",steps:cJ,onClose:X}),he&&a.jsx(Jle,{agentCount:N,onConfirm:()=>ue("confirmation"),onCancel:()=>le(!1)})]})}function jhe({lanPairs:e,attention:t}){const n=Hue(e);return a.jsxs(a.Fragment,{children:[n,a.jsx(Gue,{...t,pairing:n!=null})]})}const She=10,V4=500,G4=4e3,_he=[/ResizeObserver loop/i,/^Script error\.?$/i],$h=String.raw`[^\s\\/:'"\`<>|?*;,]`,Ehe=String.raw`${$h}(?:[^\\/\r\n:'"\`<>|?*;,]*${$h})?[\\/]`,Che=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,Gl=String.raw`(?:${Ehe})*(?:${Che})?`,The=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${Gl}|[A-Za-z]:[\\/]${Gl}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${Gl}|/(?=${$h})${Gl}|(?<!:)//(?=${$h})${Gl})`,Rhe=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,Ahe=new Set([".claude",".codex"]);function Mhe(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...r]=e.slice(2).split(/[\\/]/);return n?Ahe.has(n)?r.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const $he=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function Ihe(e,t,n){return n?"<deck>":`${t}://<host>`}const e$=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,K4=String.raw`${e$}(?:\.${e$}){3}`,vb=String.raw`[0-9A-Fa-f]{1,4}`,t$=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${vb}:){7})(?:(?:${vb})?:)+(?:${K4}|${vb})?`,n$=String.raw`%[\w-]+(?:\.[\w-]+)*`,r$=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,Ohe=String.raw`(?<![\w:.%-])(?:\[(?!${r$}\])${t$}(?:${n$})?\]|(?!${r$}(?::\d{1,5})?(?![\w:%]|\.\d))${t$}(?:${n$})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${K4}(?![\w-]|\.\d)`,xb=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,Lhe=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${xb}|${xb}(?=:\d{1,5}(?![\w:-]|\.\w))|${xb}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function s$(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(The,"g"),Mhe).replace(new RegExp(Rhe,"g"),"<project>").replace(new RegExp($he,"g"),Ihe).replace(new RegExp(Ohe,"g"),"<host>").replace(new RegExp(Lhe,"g"),"<host>").replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,"<email>").replace(/\b(?:sk-ant-[A-Za-z0-9_-]{8,}|sk-[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{20,}|xox[abpr]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}|[A-Fa-f0-9]{40,}|[A-Za-z0-9+_=-]{48,})/g,"<secret>")}const Y4=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function Phe(e,t,n=Y4){const r=String(e??"").slice(0,V4).trim();r&&n({message:r,stack:typeof t=="string"?t.slice(0,G4):void 0})}function Dhe(e,t=window,n=Y4){let r=0;const s=new Set,o=(d,h)=>{const f=String(d??"").slice(0,V4).trim();!e()||!f||r>=She||s.has(f)||_he.some(p=>p.test(f))||(s.add(f),r++,n({message:f,stack:typeof h=="string"?h.slice(0,G4):void 0}))},i=d=>{var h,f;return o(((h=d.error)==null?void 0:h.message)??d.message,(f=d.error)==null?void 0:f.stack)},c=d=>typeof d.reason=="object"&&d.reason!==null?o(d.reason.message,d.reason.stack):o(d.reason,void 0);return t.addEventListener("error",i),t.addEventListener("unhandledrejection",c),()=>{t.removeEventListener("error",i),t.removeEventListener("unhandledrejection",c)}}const Fhe=12;function Bhe(e,t){const n=[s$(e).trim()||"The deck threw an error with no message."],r=t==null?void 0:t.trim();if(r){const s=r.split(`
303
303
  `).slice(0,Fhe).join(`
304
304
  `);n.push("",s$(s).trim())}return n.join(`
305
305
  `)}class qhe extends y.Component{constructor(){super(...arguments);hm(this,"state",{error:null,componentStack:null,reportOpen:!1});hm(this,"onKey",n=>{jO(n.key)&&On.dismissTop()})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error("ccdeck hit a render error it could not draw past",n,r.componentStack),this.setState({componentStack:r.componentStack??null}),Phe(n.message,n.stack),r4("offline")}componentDidUpdate(n,r){this.state.reportOpen!==r.reportOpen&&(this.state.reportOpen?window.addEventListener("keydown",this.onKey):window.removeEventListener("keydown",this.onKey))}componentWillUnmount(){window.removeEventListener("keydown",this.onKey)}render(){const{error:n,componentStack:r,reportOpen:s}=this.state;return n?a.jsxs("div",{className:"error-fallback",children:[a.jsxs("div",{className:"error-fallback-card",role:"alert",children:[a.jsx("p",{className:"error-fallback-title",children:"Something went wrong"}),a.jsx("p",{className:"error-fallback-note",children:"The deck hit an error it could not draw past. Reloading usually clears it — and if it keeps happening, a report tells the people who make ccdeck what broke."}),a.jsxs("div",{className:"error-fallback-actions",children:[a.jsx("button",{type:"button",className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>this.setState({reportOpen:!0}),"aria-haspopup":"dialog",children:"Send report"})]})]}),s&&a.jsx(M4,{initialKind:"bug",initialBody:Bhe(n.message,r),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const Uhe=1e3;function Hhe(e={}){const t=Math.max(1,Math.floor(e.limit??Uhe)),n=e.protect;let r=!1,s=[],o=new Set,i=0,c=0,d=null;return{get paused(){return r},get size(){return s.length},get dropped(){return i},get overflowed(){return i>0},get through(){return c},accept(h){const f=typeof(h==null?void 0:h.seq)=="number"?h.seq:null,p=(h==null?void 0:h.epoch)??null,g=p!==null&&p!==d;g&&(d=p,c=0);const w=f!==null&&!g&&f<=c;if(f!==null&&f>c&&(c=f),!r)return!0;if(w)return!1;if(s.push(h),n!=null&&n(h)&&o.add(h),s.length>t){let N=0;if(o.size<s.length)for(;o.has(s[N]);)N++;const[k]=s.splice(N,1);o.delete(k),i++}return!1},setPaused(h){if(r=h,h)return[];const f=s;return s=[],o=new Set,i=0,f}}}function Whe(e){const t=y.useState(()=>Hhe({protect:o=>bH(e.current,o)}))[0],[n,r]=y.useState(!1),s=y.useCallback(()=>{const o=t.paused&&t.dropped>0,i=t.setPaused(!t.paused);o&&HH(e.current);for(const c of i)e.current=hO(e.current,c);r(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:s}}const P0={kind:"assumed",claude:!0,codex:!0};function zhe(e){if(!e||typeof e!="object")return P0;const t=e.providers;if(!t||typeof t!="object")return P0;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function Vhe(e){const[t,n]=y.useState(null),[r,s]=y.useState(P0);y.useEffect(()=>{let i=!1;return fetch("/api/health").then(c=>c.ok?c.json():null).then(c=>{i||(s(zhe(c)),!(!c||typeof c.workspace!="string")&&n(c.workspace))}).catch(()=>{}),()=>{i=!0}},[e]);const o=Dn(r);return{workspace:t,providers:r,providersRef:o}}const X4=3*6e4,Ghe=2e4;function Khe({fetchReport:e,visible:t,now:n,onReport:r}){let s=0,o=!0;const i=async()=>{if(!t())return;const c=await e();!o||!c||(s=n(),r(c))};return{tick:i,wake:async()=>{t()&&n()-s>=X4&&await i()},stop:()=>{o=!1}}}async function Yhe(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(Ghe)});return e.ok?await e.json():null}catch{return null}}function Xhe(e){const[t,n]=y.useState(null);return y.useEffect(()=>{if(!e){n(null);return}const r=Khe({fetchReport:Yhe,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});r.tick();const s=window.setInterval(r.tick,X4),o=()=>{r.wake()};return document.addEventListener("visibilitychange",o),()=>{r.stop(),window.clearInterval(s),document.removeEventListener("visibilitychange",o)}},[e]),t}const Zhe={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Jhe={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Qhe={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},efe={claude:"Claude",codex:"Codex"},tfe=new Set(["status.claude.com","status.openai.com"]),nfe=30*6e4,rfe=10*6e4;function sfe(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&tfe.has(t.hostname)?t:null}catch{return null}}function a$(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function afe(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function ofe(e,t){if(!e||typeof e!="object")return null;const n=Ut(Zhe,e.state),r=Ut(efe,e.provider);if(!n||!r||typeof e.checkedAt!="number"||t-e.checkedAt>nfe)return null;const s=sfe(e.statusPageUrl);if(!s)return null;const o=Array.isArray(e.components)?e.components:[],i=e.stale===!0||t-e.checkedAt>rfe,c=[`${r}: ${n}${e.summary?` — ${e.summary}`:""}`,o.length>0?`Affected: ${o.join(", ")}`:null,e.scope==="page"?`The page's overall status: it names none of ${r}'s components`:null,i?`Last read from ${s.hostname} at ${a$(e.checkedAt)}; this is the last thing it said`:`Reported by ${s.hostname}, checked ${afe(t-e.checkedAt)}`,"Opens the status page"],d=i?a$(e.checkedAt):null;return{provider:e.provider,state:e.state,name:r,label:`${r} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:Ut(Jhe,e.state)??n,shortWords:Ut(Qhe,e.state)??n,asOf:d,what:e.summary||(o.length>0?o.join(", "):null),href:s.href,host:s.hostname,stale:i,detail:c.filter(Boolean).join(`
306
- `)}}function ife(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>ofe(n,t)).filter(n=>n!==null)}function lfe(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const cfe="The providers' status pages report no incident.";function ufe({version:e,loadVersion:t}){var h;const[n,r]=y.useState(!1),s=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=Ble(e==null?void 0:e.upgrade),i=y.useRef(!1),c=y.useCallback(async()=>{if(sr(i.current||s==="running")){i.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),i.current=!1}},[s,t]);y.useEffect(()=>{if(s!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[s,t]);const d=y.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await So(f)||(r(!0),window.setTimeout(()=>r(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:s,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const o$="agent-dag.browserWatch.seenMs";function dfe(e,t){return e.filter(n=>n.startMs>t)}function hfe(){const[e,t]=y.useState(()=>Number(Ke(o$))||0),[n,r]=y.useState([]),[s,o]=y.useState(!1);y.useEffect(()=>{let d=!0;const h=()=>{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??[]),o(((g=p.settings)==null?void 0:g.enabled)===!0))}).catch(()=>{})};h();const f=setInterval(h,5*6e4);return()=>{d=!1,clearInterval(f)}},[]);const i=y.useMemo(()=>dfe(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),Ge(o$,String(d))},[]);return{watchOn:s,setWatchOn:o,watchUnseen:i,markWatchSeen:c}}const Z4=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function i$(e){const t={};for(const n of Z4)t[n]=e(n);return t}function ffe(e){return t=>e[t]??""}function pfe(e,t){return Z4.every(n=>e[n]===t[n])}function l$(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function mfe(){const[e,t]=y.useState(Zoe),[n,r]=y.useState(Pde),[s,o]=y.useState(phe),[i,c]=y.useState(()=>i$(l$)),d=y.useMemo(()=>ffe(i),[i]),h=y.useCallback(f=>voe(f,d),[d]);return y.useEffect(()=>{document.documentElement.dataset.theme=e,document.documentElement.dataset.colorScheme=If[e].colorScheme,Ge(a4,e),c(f=>{const p=i$(l$);return pfe(f,p)?f:p})},[e]),y.useEffect(()=>{Ge(U4,n?"1":"0")},[n]),y.useEffect(()=>{Ge(z4,s)},[s]),y.useEffect(()=>{const f=document.querySelector('meta[name="theme-color"]'),p=i["--panel"];f&&p&&f.setAttribute("content",p)},[i]),{theme:e,setTheme:t,characterEnabled:n,setCharacterEnabled:r,character:s,setCharacter:o,palette:i,minimapNodeFill:h}}function gfe(e){const t=y.useRef(null),[n,r]=y.useState(!1),[s,o]=y.useState(()=>new Set),i=y.useMemo(()=>{const d=new Set;for(const h of e.current.agents.values())for(const f of h.tools)d.add(l4(f.name));return Object.keys(i4).filter(h=>d.has(h))},[e.current,e.current.revision]);y.useEffect(()=>{if(i.length<=1){r(!1);return}let d=0;const h=()=>{const f=t.current;if(f&&!document.hidden){const p=f.getBoundingClientRect(),g=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(N=>N.getBoundingClientRect()),w=oG(p,g,8);r(N=>N===w?N:w)}d=window.setTimeout(h,300)};return h(),()=>window.clearTimeout(d)},[i.length]);const c=y.useCallback(d=>{o(h=>{const f=new Set(h);return f.has(d)?f.delete(d):f.add(d),f})},[]);return{presentCats:i,hiddenCats:s,toggleCat:c,catBarRef:t,catBarOccluded:n}}function yfe(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const r=new Set,s=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var g;return(g=e.onState)==null?void 0:g.call(e,s())};function i(){var g,w;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(g=n.addEventListener)==null||g.call(n,"statechange",o)),(w=n.resume)==null||w.call(n).then(o,()=>{}),o()}catch{}}function c(g,w,N=w.figure){if(!n||n.state!=="running")return!1;const k=N0(g,N),x=yte(w.level,k),b=n.currentTime;for(const j of k.notes){const S=n.createOscillator(),E=n.createGain();S.type=k.type??"sine",S.frequency.value=j.hz;const T=b+j.at,I=T+j.ms/1e3;E.gain.setValueAtTime(WE,T),E.gain.exponentialRampToValueAtTime(x,T+wte),E.gain.exponentialRampToValueAtTime(WE,I),S.connect(E).connect(n.destination),S.start(T),S.stop(I+.02)}return!0}async function d(g,w){var x;if(!e.loadCustom)return"unavailable";let N;try{N=await e.loadCustom(g)}catch{return"unavailable"}if(!N)return"missing";if(N.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const b=new SpeechSynthesisUtterance(N.text),j=window.speechSynthesis.getVoices();b.voice=j.find(S=>S.voiceURI===N.voiceURI)??null,b.rate=N.rate,b.pitch=N.pitch,b.volume=vte(w.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(b),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let k;try{k=await n.decodeAudioData(N.bytes.slice(0))}catch{return"broken"}try{const b=n.createBufferSource(),j=n.createGain();return b.buffer=k,j.gain.setValueAtTime(xte(N.normalizationGain,w.level),n.currentTime),b.connect(j).connect(n.destination),r.add(b),(x=b.addEventListener)==null||x.call(b,"ended",()=>r.delete(b)),b.start(n.currentTime),"played"}catch{return"unavailable"}}function h(g,w=!1){var x,b;if(!w&&!e.enabled())return!1;const N=Ete((x=e.prefs)==null?void 0:x.call(e),g),k=((b=e.customSelection)==null?void 0:b.call(e)[g])??null;return k&&e.loadCustom?(d(k,N).then(j=>{var S;j==="played"||j==="locked"||((j==="missing"||j==="broken")&&((S=e.onCustomFailure)==null||S.call(e,g,k)),c(g,{...N,figure:Ln},Ln))}),!0):!n||n.state!=="running"?!1:c(g,N)}function f(g,w=ko){return d(g,{level:pf(w),figure:Ln}),!0}function p(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const g of r)try{g.stop()}catch{}r.clear()}return{unlock:i,play:h,previewCustom:f,silence:p,state:s,get context(){return n}}}function wfe({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:r,fallbackCustomRef:s}){y.useEffect(()=>{const o=yfe({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>r.current,loadCustom:hte,onCustomFailure:(h,f)=>s.current(h,f)});e.current=o;const i=["pointerdown","pointerup","keydown"],c=()=>{for(const h of i)window.removeEventListener(h,d,{capture:!0})},d=()=>{var h;o.unlock(),((h=o.context)==null?void 0:h.state)==="running"&&c()};for(const h of i)window.addEventListener(h,d,{capture:!0});return c},[])}function vfe(){const[e,t]=y.useState(Fde),[n,r]=y.useState(()=>c7(Ke(n_))),[s,o]=y.useState(()=>l7(Ke(r_))),[i,c]=y.useState(()=>u7(Ke(G2),n,Ode)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{Ge(H4,String(e))},[e]),y.useEffect(()=>{Ge(r_,s?"1":"0")},[s]),y.useEffect(()=>{Ge(n_,JSON.stringify(n))},[n]),y.useEffect(()=>{Ge(G2,i)},[i]);const g=y.useCallback((b,j=!1)=>{r(S=>{const E=S.find(T=>T.id===b.id);return E?!j||!b.radio||!E.radio||E.url===b.url&&JSON.stringify(E.radio)===JSON.stringify(b.radio)?S:S.map(T=>T.id===b.id?{...T,url:b.url,radio:b.radio}:T):[...S,b]}),h(S=>{if(!S.has(b.id))return S;const E=new Set(S);return E.delete(b.id),E})},[]),w=y.useCallback((b,j)=>{const S=j.trim();!S||S.length>kc||r(E=>E.map(T=>T.id===b?{...T,name:S}:T))},[]),N=y.useCallback(b=>{r(j=>j.filter(S=>S.id!==b)),c(j=>d7(j,b)),h(j=>{if(!j.has(b))return j;const S=new Set(j);return S.delete(b),S})},[]),k=y.useCallback((b,j=!1)=>{const S=s_(b),E=d.has(S);b===i&&!E&&!j||(E&&h(T=>{const I=new Set(T);return I.delete(S),I}),c(b),p(T=>T+1))},[i,d]),x=y.useCallback((b,j)=>{const S=s_(b);h(E=>{if(E.has(S)===j)return E;const I=new Set(E);return j?I.add(S):I.delete(S),I})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:o,fmSource:i,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:g,renameFmStation:w,removeFmStation:N,pickFmSource:k,markFmStationAvailability:x}}function xfe(e){const[t,n]=y.useState(null),[r,s]=y.useState(!1),[o,i]=y.useState(null),c=y.useRef(0);y.useEffect(()=>{if(!e||!No())return;let N=!1;const k=c.current;return fetch("/api/desktop-update").then(x=>x.ok?x.json():null).then(x=>{if(N||c.current!==k)return;const b=E2(x);b&&n(b)}).catch(()=>{}),()=>{N=!0}},[e]);const d=rle(t),h=y.useRef(!1),f=y.useRef(0),p=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(f.current),[]);const g=y.useCallback(async N=>{if(!sr(h.current))return;const k=++p.current;window.clearTimeout(f.current),h.current=!0,s(!0),i(null);const x=b=>{k===p.current&&(window.clearTimeout(f.current),h.current=!1,s(!1),i({failure:b,version:N}))};try{const b=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:N})});if(!b.ok)return x(ale(await b.json().catch(()=>null)))}catch{return x("unreachable")}k===p.current&&(f.current=window.setTimeout(()=>x("timeout"),p4))},[]),w=y.useCallback(N=>{if(No())try{const k=E2(JSON.parse(N));k&&(c.current++,n(k),k.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,s(!1)))}catch{}},[]);return{desktopUpdateRestarting:r,desktopUpdateFailure:o,readyAppUpdate:d,appUpdate:t,askDesktopUpdateRestart:g,onDesktopUpdateEvent:w}}const Id="agent-dag.autoRestart",c$="agent-dag.bundleReloadedFor";function bfe({now:e,stateRef:t,version:n,notice:r,noticeOpen:s,upgradeFailure:o,paused:i}){const[c,d]=y.useState(()=>Ke(Id)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const U=!c;h.current=!0,Jr(Id),d(U),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:U})}).then(P=>P.ok?P.json():null).then(P=>{var $;P!=null&&P.ok&&d((($=P.prefs)==null?void 0:$.autoUpdate)!==!1)}).catch(()=>{})},[c]),[p,g]=y.useState(!1),[w,N]=y.useState("restart"),[k,x]=y.useState(null),b=y.useRef(!1),j=y.useRef(null),S=y.useRef(0),E=y.useRef(null),T=y.useCallback(async U=>{if(!sr(b.current))return;const P=(U==null?void 0:U.upgrade)===!0,$=(U==null?void 0:U.whenIdle)===!0;b.current=!0,j.current=o;const B=++S.current,R=()=>{N(P?"npx":"restart"),g(!0)};$||R();try{window.sessionStorage.setItem("agent-dag.restartPending",(r==null?void 0:r.to)??"")}catch{}let F=!1;try{const O=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($?{upgrade:P,whenIdle:$}:{upgrade:P})});F=$&&O.status===409}catch{}if(F){b.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}$&&R(),window.setTimeout(()=>{if(S.current===B&&b.current){b.current=!1,g(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},P?18e4:3e4)},[r==null?void 0:r.to,o]);y.useEffect(()=>{const U=T2(t.current.agents.values())>0,P=zle({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:U,idleSince:E.current,now:e});E.current=P.idleSince,P.restart&&T({whenIdle:!0})},[c,r==null?void 0:r.kind,n==null?void 0:n.canRestart,s,e,T]);const I=T2(t.current.agents.values()),A=Wle(I,i),D=v4({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:I>0,idleSince:E.current,now:e});y.useEffect(()=>{const U=n==null?void 0:n.running;let P=null,$=null;try{P=window.sessionStorage.getItem("agent-dag.restartPending"),$=window.sessionStorage.getItem(c$)}catch{return}const B=Fle({bundle:"3.40.0",running:U,pending:P,lastTried:$});if(B==="reload"){try{window.sessionStorage.setItem(c$,U??"")}catch{return}window.location.reload();return}if(B!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}b.current=!1,g(!1),x(U??null);const R=window.setTimeout(()=>x(null),6e3);return()=>window.clearTimeout(R)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&qle({asked:j.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}b.current=!1,g(!1)}},[p,o]);const L=y.useCallback(U=>{var P,$;if(!h.current){const B=Ke(Id)==="0";Jr(Id),B&&((P=U.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((($=U.prefs)==null?void 0:$.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:f,restarting:p,restartMode:w,restartedTo:k,askRestart:T,restartCopy:A,restartFuseMs:D,loadAutoRestartPrefs:L}}function kfe(){const[e,t]=y.useState([]),n=y.useRef(new Set),[r,s]=y.useState(null),[o,i]=y.useState(void 0);y.useEffect(()=>{let h=!0,f=0;const p=()=>{fetch("/api/lan").then(g=>g.ok?g.json():null).then(g=>h?(g!=null&&g.ok&&t(pE(Array.isArray(g.pending)?g.pending:[],g.aliases)),g):null).catch(()=>null).then(g=>{h&&(i(w=>g!=null&&g.ok?g:w===void 0?null:w),f=window.setTimeout(p,(g==null?void 0:g.enabled)===!0?m0:oP))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const c=y.useCallback(async(h,f)=>{if(!r){s(h);try{const g=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:h,fp:f})})).json().catch(()=>null);g&&Array.isArray(g.pending)?t(pE(g.pending,g.aliases)):t(w=>w.filter(N=>N.fp!==f))}catch{}finally{s(null)}}},[r]),d=y.useCallback(h=>{r||(n.current.add(h),t(f=>[...f]))},[r]);return{lanPending:e,lanDeferred:n,lanBusy:r,answerLanPair:c,deferLanPair:d,lanStatus:o}}const Nfe=6e4;function jfe({enabled:e,lanStatus:t,now:n}){const[r,s]=y.useState(null),[o,i]=y.useState(()=>new Set),[c,d]=y.useState(null),h=y.useCallback(b=>{b!=null&&b.ok&&Array.isArray(b.accounts)&&s(b.accounts)},[]),f=y.useCallback(async b=>{try{const j=await fetch(`/api/claude-accounts${b?"?refresh=1":""}`);j.ok&&h(await j.json())}catch{}},[h]);y.useEffect(()=>{e&&f(!1)},[e,f]),y.useEffect(()=>{if(!e)return;let b=Date.now();const j=()=>{document.visibilityState!=="visible"||Date.now()-b<Nfe||(b=Date.now(),f(!1))};return document.addEventListener("visibilitychange",j),window.addEventListener("focus",j),()=>{document.removeEventListener("visibilitychange",j),window.removeEventListener("focus",j)}},[e,f]);const p=y.useMemo(()=>e?Iue(r,{lan:t,now:n,closed:o}):[],[e,r,t,n,o]),g=y.useRef(p);g.current=p;const w=y.useCallback(b=>{b.length&&i(j=>new Set([...j,...b]))},[]),N=y.useCallback(()=>{const b=g.current;b.length&&(w(b.map(j=>j.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:b.map(j=>({key:j.key,since:j.since}))})}).catch(()=>{}))},[w]),k=y.useRef(c);k.current=c;const x=y.useCallback(b=>{const j=k.current;w(Oue(j?[j,...g.current]:g.current,b))},[w]);return{rows:p,signingIn:c,observe:h,signIn:d,signedIn:x,refresh:y.useCallback(()=>{f(!0)},[f]),closeSignIn:y.useCallback(()=>d(null),[]),later:N}}const J4=288,Sfe=J4;function _fe(e,t,n){return e?"session-list":t||n?"accounts":null}function Efe(e){return e==="session-list"?Sfe:e==="accounts"?J4:0}const Cfe=240,Tfe=20;function Rfe(e){const t=y.useRef(0),n=y.useRef(e);return y.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=Fc()?0:performance.now()+Cfe+Tfe)},[e]),t}const Q4="agent-dag.sessionListOpen",eD="agent-dag.accountsPanelOpen";function Afe(){return Ke(Q4)==="1"}function Mfe(e){Ge(Q4,e?"1":"0")}function $fe(){const e=Ke(eD);return e===null?!0:e==="1"}function Ife(){const[e,t]=y.useState(Afe);y.useEffect(()=>{Mfe(e)},[e]);const n=y.useRef(!1),[r,s]=y.useState(()=>{const f=$fe();return f&&e?(n.current=!0,!1):f});y.useEffect(()=>{!r&&n.current||Ge(eD,r?"1":"0")},[r]),y.useEffect(()=>{!e&&n.current&&(n.current=!1,s(!0))},[e]);const o=y.useCallback(()=>{t(f=>(f||s(p=>(p&&(n.current=!0),!1)),!f))},[]),i=y.useCallback(()=>{n.current=!1,s(f=>(f||t(!1),!f))},[]),c=y.useCallback(()=>t(!1),[]),d=y.useCallback(()=>s(!1),[]),h=_fe(e,r,n.current);return{sessionListOpen:e,accountsPanelOpen:r,panel:h,toggleSessionList:o,toggleAccountsPanel:i,closeSessionList:c,closeAccountsPanel:d}}const tD="agent-dag.detailOpen",nD="agent-dag.usagePanelOpen",rD="agent-dag.systemPanelOpen";function Ofe(){return Ke(tD)==="1"}function Lfe(e){Ge(tD,e?"1":"0")}function Pfe(){const e=Ke(nD);return e===null?!0:e==="1"}function Dfe(e){Ge(nD,e?"1":"0")}function Ffe(){const e=Ke(rD);return e===null?!0:e==="1"}function Bfe(e){Ge(rD,e?"1":"0")}function qfe(){const[e,t]=y.useState(Ofe);y.useEffect(()=>{Lfe(e)},[e]);const[n,r]=y.useState(Pfe);y.useEffect(()=>{Dfe(n)},[n]);const[s,o]=y.useState(Ffe);return y.useEffect(()=>{Bfe(s)},[s]),Qt("usage-panel",n),Qt("machine-panel",s),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:r,machinePanelOpen:s,setMachinePanelOpen:o}}const Ufe={permission:"your permission",asked:"your answer"},Hfe="No sessions are waiting for you.";function Wfe(e){if(e.length===0)return"";const[t,...n]=e,r=t.waiting.kind,s=n.every(i=>i.waiting.kind===r)?Ufe[r]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${s}.`;const o=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${o} are waiting for ${s}.`}function bb(e,t,n=Hfe){return t!==""?t:e===""?"":n}function zfe({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[r,s]=y.useState(""),o=Wfe(e);y.useEffect(()=>{s(g=>bb(g,o))},[o]);const[i,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(g=>bb(g,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=lfe(n);return y.useEffect(()=>{f(g=>bb(g,p,cfe))},[p]),{blockedSaid:r,watchSaid:i,setWatchSaid:c,incidentSaid:h}}const Vfe="/icon-192.png",sD=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1});function u$(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:sD[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset")}}function Gfe({waitingSessions:e,liveSince:t,focusSession:n}){const[r,s]=y.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,i]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,g]=y.useState(sD),w=y.useCallback(D=>{const L=!p[D];g(U=>({...U,[D]:L})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[D]:L})}).then(U=>U.ok?U.json():null).then(U=>{U!=null&&U.ok&&g(u$(U.prefs))}).catch(()=>{})},[p]),N=y.useRef(()=>{}),k=y.useRef(new Set),x=Dn(e),b=y.useCallback(()=>{const D=!c;d(D),D&&(k.current=yd(x.current)),D&&typeof Notification<"u"&&Notification.permission==="default"&&N.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:D})}).then(L=>L.ok?L.json():null).then(L=>{var U;L!=null&&L.ok&&(d(((U=L.prefs)==null?void 0:U.notifications)===!0),f(L.notificationsVetoed===!0))}).catch(()=>{})},[c]),j=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const L=setTimeout(()=>i(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(L)},[o]);const S=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(D=>{const L=D;s(L),L==="granted"?i("on"):L==="denied"&&i("blocked")})},[]);N.current=S;const E=y.useRef(null),T=e.map(D=>Vh(D.id,D.waiting)).join("|");y.useEffect(()=>{oW(E.current,r)&&(E.current=r,k.current=yd(e))},[r]);const I=y.useRef(!1);y.useEffect(()=>{iW(I.current,t)&&(I.current=!0,k.current=yd(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!lW(E.current,t))return;const D=typeof document>"u"||!document.hidden,L=sW(e,k.current,D,c);for(const U of L)try{const P=new Notification(U.title,{body:U.body,tag:U.key,icon:Vfe});P.onclick=()=>{window.focus(),n(U.sessionId),P.close()}}catch{}k.current=D?yd(e):aW(e,L,k.current)},[T,t]);const A=y.useCallback(D=>{var L;d(((L=D.prefs)==null?void 0:L.notifications)===!0),f(D.notificationsVetoed===!0),g(u$(D.prefs))},[]);return{notifyPermission:r,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:b,notifySupported:j,askForNotifications:S,loadNotifyPrefs:A,accountNotify:p,toggleAccountNotify:w}}function Kfe({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:r,summaryFor:s,browserWatchOpen:o,keyHelpOpen:i,releaseNotes:c,feedbackOpen:d,trafficRadarOpen:h=!1}){const f=Dn(i),p=y.useRef(!1);return p.current=e!=null||t||n!=null||r||s!=null||o||i||c!=null||d||h,{keyHelpOpenRef:f,modalOpenRef:p}}function Yfe({stateRef:e,tourOpen:t,releaseNotes:n}){const[r,s]=y.useState(null),o=y.useCallback(($,B)=>s({agentId:$,toolId:B}),[]),[i,c]=y.useState(null),[d,h]=y.useState(null),f=y.useCallback($=>h($),[]),[p,g]=y.useState(!1),[w,N]=y.useState(!1),[k,x]=y.useState(!1),[b,j]=y.useState(!1),[S,E]=y.useState(!1),[T,I]=y.useState(null),A=y.useCallback($=>{I($??null),E(!0)},[]);Qt("tool-detail",r!==null),Qt("session-summary",i!==null),Qt("context-window",d!==null),Qt("keyboard-help",p),Qt("usage-history",w),Qt("browser-watch",k),Qt("feedback",S);const D=r?yH(e.current.agents,r.agentId,r.toolId):null,L=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:U,modalOpenRef:P}=Kfe({openedTool:D,usageHistoryOpen:w,contextFor:d,tourOpen:t,summaryFor:i,browserWatchOpen:k,keyHelpOpen:p,releaseNotes:n,feedbackOpen:S,trafficRadarOpen:b});return{setOpenedToolKey:s,openTool:o,openedTool:D,summaryFor:i,setSummaryFor:c,contextFor:d,setContextFor:h,openContext:f,contextAgent:L,keyHelpOpen:p,setKeyHelpOpen:g,usageHistoryOpen:w,setUsageHistoryOpen:N,browserWatchOpen:k,setBrowserWatchOpen:x,trafficRadarOpen:b,setTrafficRadarOpen:j,feedbackOpen:S,setFeedbackOpen:E,feedbackPrefill:T,setFeedbackPrefill:I,openFeedback:A,keyHelpOpenRef:U,modalOpenRef:P}}function Xfe({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:r,lastLayoutSigRef:s,forgetRemovals:o,clearSelection:i,rerender:c,modalOpenRef:d}){const[h,f]=y.useState(!1),p=y.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=rk(),t.current.clear(),n.current.clear(),r.current.clear(),s.current="",Q3(),o(),i(),c()},[c,i,o]),g=Dn(h),w=y.useCallback(N=>{const k=Kle(N,{confirmOpen:g.current,modalOpen:d.current});k==="confirm"?f(!0):k==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:w}}const d$="agent-dag.oldNameNoticeDismissed";function Zfe(e){const[t,n]=y.useState(()=>Ke(d$)??""),r=e!=null&&e.invokedAs&&e.invokedAs!==Lt?e.invokedAs:null,s=r!=null&&t!==r,o=y.useCallback(()=>{r&&(n(r),Ge(d$,r))},[r]);return{oldName:r,oldNameOpen:s,dismissOldName:o}}const Jfe=300*1e3,Qfe=1800*1e3,epe=8e3,tpe=3e4;function h$(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function npe({modalOpenRef:e}){const t=y.useCallback(()=>Bd({appModal:e.current,dialogDepth:On.dialogDepth()}),[e]),[n,r]=y.useState("hidden"),[s,o]=y.useState(null),[i,c]=y.useState(!1),d=y.useRef(n);d.current=n,y.useEffect(()=>{let w=!1;const N=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const b=await fetch("/api/rating").then(j=>j.ok?j.json():null).catch(()=>null);w||!b||r(j=>j==="thanks"?j:b.ask===!0?"asking":"hidden")},k=window.setTimeout(N,Jfe),x=window.setInterval(N,Qfe);return()=>{w=!0,window.clearTimeout(k),window.clearInterval(x)}},[t]),y.useEffect(()=>{if(n!=="thanks"||i)return;const w=s!==null&&s<=6?tpe:epe;let N=0;const k=()=>{t()?N=window.setTimeout(k,w):r("hidden")};return N=window.setTimeout(k,w),()=>window.clearTimeout(N)},[n,s,i,t]);const h=y.useCallback(w=>{o(w),c(!1),r("thanks"),h$({score:w})},[]),f=y.useCallback(w=>c(w),[]),p=y.useCallback(()=>{r("hidden"),h$({later:!0})},[]),g=y.useCallback(()=>r("hidden"),[]);return{ratingPhase:n,ratingScore:s,answerRating:h,rateLater:p,closeRating:g,holdThanks:f}}function rpe({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:r}){const[s,o]=y.useState(()=>ete(Ke)),i=Dn(s),[c,d]=y.useState([]),h=y.useCallback(j=>{o(S=>{const E={...S,[j]:null};return i.current=E,E}),Jr(lc[j])},[]),f=y.useCallback((j,S)=>{const E=i.current[j];S&&E!==S||(h(j),t(T=>{const I={...T,[j]:{...T[j],figure:Ln}};return n.current=I,I}),Ge(Nh[j],Ln))},[h]),p=Dn(f);y.useEffect(()=>{let j=!0;return dte().then(S=>{if(!j)return;d(S);const E=new Set(S.map(T=>T.id));for(const T of Wd){const I=i.current[T];I&&!E.has(I)&&p.current(T,I)}},()=>{}),()=>{j=!1}},[]);const g=y.useCallback((j,S)=>{if(!c.some(T=>T.id===S))return;const E={...i.current,[j]:S};i.current=E,o(E),Ge(lc[j],S),r(j,!0)},[c,r]),w=y.useCallback(async j=>{var I;const S=k0(c.length);if(S)throw new Error(S);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 ote(j,L=>T.decodeAudioData(L));await UE(A);const D=Ac(A);d(L=>[...L.filter(U=>U.id!==D.id),D])}finally{(I=T.close)==null||I.call(T)}},[c.length]),N=y.useCallback(async j=>{const S=k0(c.length);if(S)throw new Error(S);const E=ite(j);await UE(E);const T=Ac(E);d(I=>[...I.filter(A=>A.id!==T.id),T])},[c.length]),k=y.useCallback(async(j,S)=>{const E=c.find(I=>I.id===j),T=S.trim().slice(0,80);!E||!T||T===E.name||(await fte(j,T),d(I=>I.map(A=>A.id===j?{...A,name:T}:A)))},[c]),x=y.useCallback(async j=>{await pte(j),d(I=>I.filter(A=>A.id!==j));const S=i.current,E=tte(S,j);i.current=E,o(E);const T=Wd.filter(I=>S[I]===j);for(const I of T)Jr(lc[I]),Ge(Nh[I],Ln);T.length>0&&t(I=>{const A={...I};for(const D of T)A[D]={...A[D],figure:Ln};return n.current=A,A})},[]),b=y.useCallback(j=>{var T,I;const S=Wd.find(A=>i.current[A]===j),E=S?n.current[S].level:ko;(T=e.current)==null||T.unlock(),(I=e.current)==null||I.previewCustom(j,E)},[]);return{customSelections:s,customSelectionsRef:i,customAssets:c,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:g,importNotificationAudio:w,createNotificationVoice:N,renameCustomAsset:k,deleteCustomAsset:x,previewCustomAsset:b}}function spe(e){const[t,n]=y.useState(()=>_te(Ke)),r=Dn(t),s=y.useRef(null),o=y.useCallback((c,d=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),s.current!==null&&clearTimeout(s.current),s.current=null,!d){(f=e.current)==null||f.play(c,!0);return}s.current=setTimeout(()=>{var p;s.current=null,(p=e.current)==null||p.play(c,!0)},bte)},[]),i=y.useCallback((c,d)=>{n(h=>{const f={level:pf(d.level??h[c].level),figure:LP(c,d.figure??h[c].figure)};return Ge(FP[c],String(f.level)),Ge(Nh[c],f.figure),{...h,[c]:f}}),o(c,!0)},[o]);return y.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:r,previewTone:o,changeTone:i}}const ape=15e3;function ope(e){return e.visibilityState==="visible"&&e.hasFocus()}function ipe(e,t){return t||e===!0}function lpe(){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 cpe(){y.useEffect(()=>{const e=lpe();let t=null;const n=i=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:i}),keepalive:!0}).catch(()=>{})},r=()=>{const i=ope(document);ipe(t,i)&&n(i),t=i},s=()=>{t&&n(!1),t=!1};r();const o=window.setInterval(r,ape);return window.addEventListener("focus",r),window.addEventListener("blur",r),document.addEventListener("visibilitychange",r),window.addEventListener("pagehide",s),()=>{window.clearInterval(o),window.removeEventListener("focus",r),window.removeEventListener("blur",r),document.removeEventListener("visibilitychange",r),window.removeEventListener("pagehide",s),s()}},[])}function upe({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){y.useEffect(()=>{let r=!0;return fetch("/api/prefs").then(s=>s.ok?s.json():null).then(s=>{!r||!(s!=null&&s.ok)||(e(s),t(s),n(s))}).catch(()=>{}),()=>{r=!1}},[])}const kb="agent-dag.versionNoticeDismissed",dpe=15*6e4;function hpe(e){const[t,n]=y.useState(null),[r,s]=y.useState(()=>Ke(kb)??""),o=y.useRef(0),[i,c]=y.useState(!1),d=y.useCallback((k=!1)=>(k&&(o.current=Date.now(),c(!0)),fetch(k?"/api/version?refresh=1":"/api/version").then(x=>x.ok?x.json():null).then(x=>(x&&n(x),x??null)).catch(()=>null).finally(()=>{k&&c(!1)})),[]),h=y.useCallback(()=>{d(Date.now()-o.current>=dpe)},[d]);y.useEffect(()=>{d();const k=window.setInterval(h,5*6e4),x=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",x),()=>{window.clearInterval(k),document.removeEventListener("visibilitychange",x)}},[d,h]),y.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=g4(f),g=dle(f,r),w=y.useCallback(()=>{s(""),Ge(kb,"")},[]),N=y.useCallback(()=>{f&&(s(p),Ge(kb,p))},[f,p]);return{version:t,notice:f,noticeOpen:g,showNotice:w,dismissNotice:N,versionChecking:i,loadVersion:d}}function fpe({version:e,readyAppUpdate:t}){const[n,r]=y.useState(!1),s=y.useRef(null),[o,i]=y.useState(null),c=o&&t?t.version:null,d=y.useRef(null);y.useEffect(()=>{!c||d.current===c||(d.current=c,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:c})}).catch(()=>{}))},[c]);const h=y.useRef(!1);y.useEffect(()=>{if(h.current)return;const x=ac(),b=nde(x),j=lde({stored:b,running:(e==null?void 0:e.running)??null,notes:U2,remembers:rde(x)});if(j.reason==="no-version")return;h.current=!0,j.record&&sde(x,j.record);let S=!0;return(async()=>{var D;let T=ade(x);if(No())try{const L=await fetch("/api/prefs");if(!L.ok)throw new Error("desktop tour preferences unavailable");const U=await L.json();if(!(U!=null&&U.ok))throw new Error("desktop tour preferences unavailable");const P=((D=U.prefs)==null?void 0:D.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(!S)return;const I=ide({tourSeen:T,decision:j}),A=j.show.length?{entries:j.show,since:b,firstRun:!1}:null;I.tour&&r(!0),I.notes==="now"?i(A):I.notes==="after"&&(s.current=A)})(),()=>{S=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.40.0",p=y.useMemo(()=>O4(U2,null,f),[f]),g=y.useCallback(()=>{i({entries:p,since:null,firstRun:!1})},[p]),w=y.useCallback(()=>r(!0),[]),N=y.useCallback(()=>i(null),[]),k=y.useCallback(()=>{r(!1),ode(ac()),No()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const x=s.current;s.current=null,x&&i(x)},[]);return{tourOpen:n,openTour:w,closeTour:k,releaseNotes:o,closeReleaseNotes:N,chipVersion:f,openReleaseNotes:g}}function ppe(){const[e,t]=y.useState(void 0),[n,r]=y.useState(!1),s=y.useRef(!1);return s.current=e===!0&&!n,y.useEffect(()=>Dhe(()=>s.current),[]),{loadReportsPrefs:y.useCallback(i=>{var c;t(((c=i.prefs)==null?void 0:c.reports)!==!1),r(i.reportsVetoed===!0)},[])}}function mpe(e){const[t,n]=y.useState(null);y.useEffect(()=>{const c=Ke("agent-dag.sound");n(c===null?!0:c==="on")},[]);const r=y.useCallback(()=>{n(c=>{var h,f;const d=c!==!0;return Ge("agent-dag.sound",d?"on":"off"),d?(h=e.current)==null||h.unlock():(f=e.current)==null||f.silence(),d})},[]),s=y.useCallback(c=>{r()},[r]),o=Dn(s),i=Dn(t);return{soundOn:t,toggleSound:r,activateSoundRef:o,soundOnRef:i}}function gpe(){const[e,t]=y.useState(Voe),n=y.useCallback(o=>{t(i=>Goe(i,o))},[]),r=y.useCallback(()=>t(o=>({...o,open:!1})),[]),s=y.useCallback(o=>t(i=>({...i,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,openSettings:n,closeSettings:r,showSection:s}}const ype="agent-dag.autoFitDisabled";function wpe(e){const t=y.useRef(!1),[n,r]=y.useState(!1);y.useEffect(()=>{Jr(ype)},[]);const s=y.useCallback(()=>{t.current||(t.current=!0,r(!0))},[]),o=y.useCallback(()=>{t.current=!1,r(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:o}}function vpe(){return a.jsx(nk,{children:a.jsx(qhe,{children:a.jsx(xpe,{})})})}function xpe(){const e=zi(),t=y.useState(rk)[0],n=y.useRef(t),[,r]=y.useState(0),s=y.useCallback(()=>r(qr=>qr+1),[]),{detailOpen:o,setDetailOpen:i,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=qfe(),{selectedIds:p,primarySelectedId:g,selectAgent:w,clearSelection:N,pruneSelectionToBoard:k}=Wte(n,i),{sessionListOpen:x,accountsPanelOpen:b,panel:j,toggleSessionList:S,toggleAccountsPanel:E,closeSessionList:T,closeAccountsPanel:I}=Ife(),A=Ni(b,200),D=Ni(x,200),L=SS(x,D),U=Ni(c,130),P=Ni(h,130),$=y.useRef(null),B=mpe($),{activateSoundRef:R,soundOnRef:F}=B,O=spe($),{setTonePrefs:G,tonePrefsRef:Y,previewTone:V}=O,q=rpe({chimesRef:$,setTonePrefs:G,tonePrefsRef:Y,previewTone:V}),{customSelectionsRef:M,fallbackCustomRef:z}=q,Z=gpe(),{openSettings:H}=Z;wfe({chimesRef:$,soundOnRef:F,tonePrefsRef:Y,customSelectionsRef:M,fallbackCustomRef:z});const X=Whe(n),{pauseGate:K,paused:Q,togglePause:ee}=X,re=y.useRef(()=>{}),{live:ie,tabCapped:de,everConnected:pe,liveSince:se}=Ite({stateRef:n,rerender:s,pauseGate:K,chimesRef:$,desktopUpdateRef:re}),me=hpe(ie),{version:he,notice:le,noticeOpen:ue,loadVersion:ye}=me,ke=xfe(ie),{readyAppUpdate:Te,onDesktopUpdateEvent:xe}=ke;re.current=xe,cpe();const Ne=fpe({version:he,readyAppUpdate:Te}),{tourOpen:Ee,openTour:Le,releaseNotes:$e}=Ne,{workspace:rt,providers:Be,providersRef:Qe}=Vhe(ie),ot=Efe(j==="accounts"&&!Be.claude?null:j),It=Rfe(ot),Ye=SS(b,A)&&Be.claude,xt=Zfe(he),it=ufe({version:he,loadVersion:ye}),{upgradeFailure:Ue}=it,bt=Yfe({stateRef:n,tourOpen:Ee,releaseNotes:$e}),ct=npe({modalOpenRef:bt.modalOpenRef}),{openTool:Et,setSummaryFor:et,setContextFor:mt,openContext:jt,setKeyHelpOpen:ut,setUsageHistoryOpen:tt,setBrowserWatchOpen:Ct,keyHelpOpenRef:Un,modalOpenRef:Tt}=bt,dn=ppe(),an=hfe(),{watchOn:_n,watchUnseen:hn}=an,Yt=kfe(),[Hn,Se]=y.useState(0),{presentCats:Ie,hiddenCats:Fe,toggleCat:gt,catBarRef:zt,catBarOccluded:ss}=gfe(n),Ps=y.useRef(null),[Ds,Fs]=y.useState(0),dt=zte({stateRef:n,rerender:s,pruneSelectionToBoard:k,setContextFor:mt,setSummaryFor:et}),Bs=Xhe(Be.claude||Be.codex),$r=ife(Bs,dt),as=jfe({enabled:Be.claude,lanStatus:Yt.lanStatus,now:dt}),ur=bfe({now:dt,stateRef:n,version:he,notice:le,noticeOpen:ue,upgradeFailure:Ue,paused:X.paused}),{askRestart:qs,loadAutoRestartPrefs:os}=ur,dr=mfe(),{setTheme:is,palette:Ca}=dr,ge=vfe(),ze=Gae(),{applyViewport:Xe,moveCamera:En,fitLeft:Cn,cameraEpochRef:Ir,lastFitTimeRef:ls}=ze,fn=ioe(ze),{pinnedRef:Rt,positionsRef:Or,lastLayoutSigRef:Tn,handleRelayout:Of,rearrangeUndo:Lf}=fn,Qc=y.useRef(null),Ta=y.useRef(()=>{}),Ro=se!==null,Us=y.useRef(0),Ra=y.useCallback(()=>{Us.current=Date.now()},[]),{canvasRef:Lr,canvasSize:Pf,paneSizeRef:tl}=Boe(It),nl=wpe(Cn),{autoFitDisabledRef:Ao,disableAutoFit:cs}=nl,rl=y.useRef(!1),{measuredRef:hr,measuredVersionRef:st,sizeVersion:eu,domSizeVersion:tu}=qoe(rl),{removedNodes:Mo,removedAgentIds:us,removeNode:nu,removeSelectedNode:sl,removalNotice:$o,bringBack:Hs,bringBackAll:Pr,forgetRemovals:Dr}=Coe({stateRef:n,pinnedRef:Rt,positionsRef:Or,canvasRef:Lr,clearSelection:N,primarySelectedId:g}),Wn=Noe({stateRef:n,now:dt,removedAgentIds:us,sizeVersion:eu,domSizeVersion:tu});loe(Wn,fn),Eoe({layoutSig:Wn,rf:e,stateRef:n,measuredRef:hr,pinnedRef:Rt,positionsRef:Or,paneSizeRef:tl,lastInteractRef:Us,autoFitDisabledRef:Ao,lastFitTimeRef:ls,fitLeft:Cn});const Ws=Uoe(),{bubbling:Aa,endBubble:Fr,onBubble:Df}=Dee(),[Io,Ma]=y.useState(!1),ru=Lee(),{beginTrashDrag:su,trackTrashDrag:Oo,endTrashDrag:au}=ru,ou=Gee({stateRef:n,measuredRef:hr,measuredVersionRef:st,canvasRef:Lr}),{lodRef:$a,applyZoom:Ia}=ou,ds=Poe({applyViewport:Xe,lastFitTimeRef:ls,cameraEpochRef:Ir,disableAutoFit:cs,markInteract:Ra,canvasRef:Lr,applyZoom:Ia}),Br=g?n.current.agents.get(g):null,al=o&&Br!=null,zs=eie({sessionListShown:L,usageShown:ga(U),machineShown:ga(P),accountsShown:Ye,detailShown:al,primarySelectedId:g,canvasRef:Lr}),{railInsetRef:Vs,availableWidth:Oa,availableHeight:Lo}=Uae({canvasRef:Lr,canvasSize:Pf,machinePhase:P,usagePhase:U,usagePanelOpen:c,detailShown:al}),ol=joe({stateRef:n,now:dt,availableWidth:Oa,availableHeight:Lo,layout:fn,measuredRef:hr,onBubble:Df,settled:Ws,dragging:Io,layoutSig:Wn,selectedIds:p,openContext:jt,historyReplayed:Ro,removedNodes:Mo,removedAgentIds:us,dragTick:Hn,dragPatchRef:Ps,dragMoveTick:Ds}),{nodes:zn,edges:il}=ol,Gs=Dn(g);coe({nodes:zn,edges:il,settled:Ws,dragging:Io,availableWidth:Oa,availableHeight:Lo,layout:fn,camera:ze,rf:e,measuredRef:hr,stateRef:n,lastFocusRef:Qc,primarySelectedIdRef:Gs,focusAgentRef:Ta,autoFitDisabledRef:Ao});const ll=Xfe({stateRef:n,pinnedRef:Rt,measuredRef:hr,positionsRef:Or,lastLayoutSigRef:Tn,forgetRemovals:Dr,clearSelection:N,rerender:s,modalOpenRef:Tt}),{requestClear:La}=ll,Po=tie({nodes:zn,stateRef:n,pinnedRef:Rt,positionsRef:Or,draggingRef:rl,dragPatchRef:Ps,setDragging:Ma,setDragMoveTick:Fs,setDragTick:Se,endBubble:Fr,markInteract:Ra,disableAutoFit:cs,beginTrashDrag:su,trackTrashDrag:Oo,endTrashDrag:au,removeNode:nu}),iu=y.useCallback(()=>Cn(500),[Cn]),Xt=Dn(zn),{focusAgent:fr,stepAgent:cl,focusSession:Vn}=Yae({canvasRef:Lr,stateRef:n,measuredRef:hr,nodesRef:Xt,railInsetRef:Vs,moveCamera:En,disableAutoFit:cs,lastFocusRef:Qc,focusAgentRef:Ta,selectAgent:w,primarySelectedIdRef:Gs}),Ff=Doe({clearSelection:N,selectAgent:w,detailOpen:o,setDetailOpen:i,detailShown:al,focusAgent:fr,draggingRef:rl,lodRef:$a}),ul=Xae({nodesRef:Xt,stateRef:n,canvasRef:Lr,railInsetRef:Vs}),dl=Dn(sl),hs=y.useRef(null),Do=y.useCallback(qr=>{us.has(qr)&&Hs([qr]),Vn(qr)},[us,Hs,Vn]),lu=Hoe();Joe({pointerFocusRef:lu,nodesRef:Xt,stateRef:n,primarySelectedIdRef:Gs,providersRef:Qe,soundOnRef:F,keyHelpOpenRef:Un,modalOpenRef:Tt,waitingCursorRef:hs,removeSelectedRef:dl,activateSoundRef:R,clearSelection:N,selectAgent:w,focusAgent:fr,stepAgent:cl,focusSession:Vn,requestClear:La,handleRelayout:Of,undoRearrange:Lf.undo,handleFit:iu,togglePause:ee,toggleSessionList:S,toggleAccountsPanel:E,setDetailOpen:i,setUsageHistoryOpen:tt,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:Ct,setKeyHelpOpen:ut,setTheme:is,openSettings:H});const cu=n.current.agents.size,Ks=y.useMemo(()=>qb(n.current.agents.values()),[n.current,n.current.revision]);Toe({stateRef:n,waitingSessions:Ks,removedAgentIds:us,removedNodes:Mo,bringBack:Hs}),Ioe({stateRef:n,waitingSessions:Ks,live:ie});const uu=zfe({waitingSessions:Ks,watchUnseen:hn,incidents:$r}),Pa=Gfe({waitingSessions:Ks,liveSince:se,focusSession:Vn}),{loadNotifyPrefs:Bf}=Pa;upe({loadAutoRestartPrefs:os,loadNotifyPrefs:Bf,loadReportsPrefs:dn.loadReportsPrefs});const Da=Yie($ie),[du,hu]=y.useState(!1),qf=y.useCallback(()=>hu(!1),[]),pr=Kie({providers:Be,sessionListOpen:x,toggleSessionList:S,accountsPanelOpen:b,toggleAccountsPanel:E,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f,setUsageHistoryOpen:tt,watchOn:_n,watchUnseen:hn,setBrowserWatchOpen:Ct,setTrafficRadarOpen:bt.setTrafficRadarOpen,openSettings:H,onFeedback:bt.openFeedback,radioOpen:du,setRadioOpen:hu,toggles:zs.toggles}),[Uf,Hf]=y.useState(0),Wf=y.useCallback(()=>{x||S(),requestAnimationFrame(()=>{var qr;return(qr=document.querySelector("#session-list .sl-row"))==null?void 0:qr.focus()})},[x,S]);return 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(YV,{}),a.jsx(kle,{versionCheck:me,welcome:Ne,desktopUpdate:ke,pause:X,announcements:uu,notify:Pa,waitingSessions:Ks,waitingCursorRef:hs,focusSession:Vn,live:ie,now:dt,incidents:$r,queueNamed:Da?0:Uf}),!Da&&a.jsx(vle,{waitingSessions:Ks,waitingCursorRef:hs,focusSession:Vn,now:dt,onFit:Hf,onMore:Wf}),Br&&a.jsx(Nle,{selected:Br,now:dt,selectedIds:p,focusAgent:fr,clearSelection:N}),!Da&&a.jsx("div",{className:"actions",children:a.jsx(Aie,{items:pr.utilities})})]}),Da?a.jsx(Rie,{items:[...pr.left,...pr.right[0],pr.utilities[0]],more:[...pr.right.slice(1).flat(),pr.utilities[1]]}):a.jsx(S2,{side:"left",label:"Left column",groups:[pr.left]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:$o?`${$o.label} removed from the board.`:""}),a.jsx(Gle,{restart:ur,versionCheck:me,upgrade:it,oldNameNotice:xt,rating:ct,onFeedback:bt.openFeedback,everConnected:pe,live:ie,paused:Q}),(L||Ye)&&a.jsxs(Tee,{width:ot,children:[Ye&&a.jsx(Cee,{leaving:_S(b,A),onReport:bt.openFeedback,onRoster:as.observe,onClose:()=>{zs.accounts(),I()}}),L&&a.jsx(cG,{leaving:_S(x,D),state:n.current,now:dt,selectedIds:p,onSelect:Do,onClose:()=>{zs.sessionList(),T()},removedIds:us,onBringBackAll:Pr})]}),a.jsxs(Cle,{canvasRef:Lr,bubbling:Aa,dragging:Io,trash:ru,zoom:ou,viewport:ds,stateRef:n,peek:ul,children:[cu===0&&(!ie&&de?a.jsx(rie,{reservedRight:Vs.current}):a.jsx(sie,{live:ie,everConnected:pe,providers:Be,workspace:rt,onTour:Le,reservedRight:Vs.current})),(Ie.length>1||Fe.size>0)&&a.jsx(jle,{catBarRef:zt,catBarOccluded:ss,presentCats:Ie,hiddenCats:Fe,toggleCat:gt}),a.jsx(KV,{graph:ol,layout:fn,viewport:ds,clicks:Ff,drag:Po,appearance:dr,fm:ge,radioOpen:du,onRadioClose:qf,autoFit:nl,pause:X,stateRef:n,measuredRef:hr,hiddenCats:Fe,now:dt,openTool:Et,focusAgent:fr,requestClear:La,setKeyHelpOpen:ut})]}),!Da&&a.jsx(S2,{side:"right",label:"Right panels",groups:pr.right}),ga(U)&&a.jsx(hK,{state:n.current,now:dt,providers:Be,incidents:$r,liveSince:se,leaving:U==="leaving",onClose:()=>{zs.usage(),d(!1)}}),ga(P)&&a.jsx(XK,{usageOpen:c,leaving:P==="leaving",onClose:()=>{zs.machine(),f(!1)}}),o&&Br?a.jsx(yie,{selected:Br,now:dt,openTool:Et,setSummaryFor:et,stateRef:n,removeSelectedNode:sl,onClose:()=>{zs.detail(),i(!1)}}):null,a.jsx(Nhe,{dialogs:bt,welcome:Ne,desktopUpdate:ke,versionCheck:me,restart:ur,upgrade:it,lanPairs:Yt,attention:as,clearFlow:ll,watchBadge:an,announcements:uu,appearance:dr,providers:Be,stateRef:n,agentCount:cu,menus:Z,sound:B,tones:O,customTones:q,notify:Pa,fm:ge})]})}try{UW(window.localStorage)}catch{}const bpe=C5.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);bpe.render(a.jsx(vpe,{}));export{xo as A,Na as B,$k as C,N7 as D,_pe as E,jpe as F,Spe as G,NW as H,W4 as I,Npe as J,H9 as K,Ide as L,ka as M,U9 as R,q4 as V,wL as a,at as b,es as c,wt as d,Es as e,Ve as f,Epe as g,Rs as h,Cpe as i,a as j,Tc as k,Bn as l,ste as m,Tpe as n,dde as o,n0 as p,Rpe as q,y as r,sr as s,Ape as t,pt as u,Mpe as v,So as w,ude as x,$pe as y,sf as z};
306
+ `)}}function ife(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>ofe(n,t)).filter(n=>n!==null)}function lfe(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const cfe="The providers' status pages report no incident.";function ufe({version:e,loadVersion:t}){var h;const[n,r]=y.useState(!1),s=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=Ble(e==null?void 0:e.upgrade),i=y.useRef(!1),c=y.useCallback(async()=>{if(sr(i.current||s==="running")){i.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),i.current=!1}},[s,t]);y.useEffect(()=>{if(s!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[s,t]);const d=y.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await So(f)||(r(!0),window.setTimeout(()=>r(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:s,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const o$="agent-dag.browserWatch.seenMs";function dfe(e,t){return e.filter(n=>n.startMs>t)}function hfe(){const[e,t]=y.useState(()=>Number(Ke(o$))||0),[n,r]=y.useState([]),[s,o]=y.useState(!1);y.useEffect(()=>{let d=!0;const h=()=>{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??[]),o(((g=p.settings)==null?void 0:g.enabled)===!0))}).catch(()=>{})};h();const f=setInterval(h,5*6e4);return()=>{d=!1,clearInterval(f)}},[]);const i=y.useMemo(()=>dfe(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),Ge(o$,String(d))},[]);return{watchOn:s,setWatchOn:o,watchUnseen:i,markWatchSeen:c}}const Z4=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function i$(e){const t={};for(const n of Z4)t[n]=e(n);return t}function ffe(e){return t=>e[t]??""}function pfe(e,t){return Z4.every(n=>e[n]===t[n])}function l$(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function mfe(){const[e,t]=y.useState(Zoe),[n,r]=y.useState(Pde),[s,o]=y.useState(phe),[i,c]=y.useState(()=>i$(l$)),d=y.useMemo(()=>ffe(i),[i]),h=y.useCallback(f=>voe(f,d),[d]);return y.useEffect(()=>{document.documentElement.dataset.theme=e,document.documentElement.dataset.colorScheme=If[e].colorScheme,Ge(a4,e),c(f=>{const p=i$(l$);return pfe(f,p)?f:p})},[e]),y.useEffect(()=>{Ge(U4,n?"1":"0")},[n]),y.useEffect(()=>{Ge(z4,s)},[s]),y.useEffect(()=>{const f=document.querySelector('meta[name="theme-color"]'),p=i["--panel"];f&&p&&f.setAttribute("content",p)},[i]),{theme:e,setTheme:t,characterEnabled:n,setCharacterEnabled:r,character:s,setCharacter:o,palette:i,minimapNodeFill:h}}function gfe(e){const t=y.useRef(null),[n,r]=y.useState(!1),[s,o]=y.useState(()=>new Set),i=y.useMemo(()=>{const d=new Set;for(const h of e.current.agents.values())for(const f of h.tools)d.add(l4(f.name));return Object.keys(i4).filter(h=>d.has(h))},[e.current,e.current.revision]);y.useEffect(()=>{if(i.length<=1){r(!1);return}let d=0;const h=()=>{const f=t.current;if(f&&!document.hidden){const p=f.getBoundingClientRect(),g=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(N=>N.getBoundingClientRect()),w=oG(p,g,8);r(N=>N===w?N:w)}d=window.setTimeout(h,300)};return h(),()=>window.clearTimeout(d)},[i.length]);const c=y.useCallback(d=>{o(h=>{const f=new Set(h);return f.has(d)?f.delete(d):f.add(d),f})},[]);return{presentCats:i,hiddenCats:s,toggleCat:c,catBarRef:t,catBarOccluded:n}}function yfe(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const r=new Set,s=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var g;return(g=e.onState)==null?void 0:g.call(e,s())};function i(){var g,w;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(g=n.addEventListener)==null||g.call(n,"statechange",o)),(w=n.resume)==null||w.call(n).then(o,()=>{}),o()}catch{}}function c(g,w,N=w.figure){if(!n||n.state!=="running")return!1;const k=N0(g,N),x=yte(w.level,k),b=n.currentTime;for(const j of k.notes){const S=n.createOscillator(),E=n.createGain();S.type=k.type??"sine",S.frequency.value=j.hz;const T=b+j.at,I=T+j.ms/1e3;E.gain.setValueAtTime(WE,T),E.gain.exponentialRampToValueAtTime(x,T+wte),E.gain.exponentialRampToValueAtTime(WE,I),S.connect(E).connect(n.destination),S.start(T),S.stop(I+.02)}return!0}async function d(g,w){var x;if(!e.loadCustom)return"unavailable";let N;try{N=await e.loadCustom(g)}catch{return"unavailable"}if(!N)return"missing";if(N.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const b=new SpeechSynthesisUtterance(N.text),j=window.speechSynthesis.getVoices();b.voice=j.find(S=>S.voiceURI===N.voiceURI)??null,b.rate=N.rate,b.pitch=N.pitch,b.volume=vte(w.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(b),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let k;try{k=await n.decodeAudioData(N.bytes.slice(0))}catch{return"broken"}try{const b=n.createBufferSource(),j=n.createGain();return b.buffer=k,j.gain.setValueAtTime(xte(N.normalizationGain,w.level),n.currentTime),b.connect(j).connect(n.destination),r.add(b),(x=b.addEventListener)==null||x.call(b,"ended",()=>r.delete(b)),b.start(n.currentTime),"played"}catch{return"unavailable"}}function h(g,w=!1){var x,b;if(!w&&!e.enabled())return!1;const N=Ete((x=e.prefs)==null?void 0:x.call(e),g),k=((b=e.customSelection)==null?void 0:b.call(e)[g])??null;return k&&e.loadCustom?(d(k,N).then(j=>{var S;j==="played"||j==="locked"||((j==="missing"||j==="broken")&&((S=e.onCustomFailure)==null||S.call(e,g,k)),c(g,{...N,figure:Ln},Ln))}),!0):!n||n.state!=="running"?!1:c(g,N)}function f(g,w=ko){return d(g,{level:pf(w),figure:Ln}),!0}function p(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const g of r)try{g.stop()}catch{}r.clear()}return{unlock:i,play:h,previewCustom:f,silence:p,state:s,get context(){return n}}}function wfe({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:r,fallbackCustomRef:s}){y.useEffect(()=>{const o=yfe({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>r.current,loadCustom:hte,onCustomFailure:(h,f)=>s.current(h,f)});e.current=o;const i=["pointerdown","pointerup","keydown"],c=()=>{for(const h of i)window.removeEventListener(h,d,{capture:!0})},d=()=>{var h;o.unlock(),((h=o.context)==null?void 0:h.state)==="running"&&c()};for(const h of i)window.addEventListener(h,d,{capture:!0});return c},[])}function vfe(){const[e,t]=y.useState(Fde),[n,r]=y.useState(()=>c7(Ke(n_))),[s,o]=y.useState(()=>l7(Ke(r_))),[i,c]=y.useState(()=>u7(Ke(G2),n,Ode)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{Ge(H4,String(e))},[e]),y.useEffect(()=>{Ge(r_,s?"1":"0")},[s]),y.useEffect(()=>{Ge(n_,JSON.stringify(n))},[n]),y.useEffect(()=>{Ge(G2,i)},[i]);const g=y.useCallback((b,j=!1)=>{r(S=>{const E=S.find(T=>T.id===b.id);return E?!j||!b.radio||!E.radio||E.url===b.url&&JSON.stringify(E.radio)===JSON.stringify(b.radio)?S:S.map(T=>T.id===b.id?{...T,url:b.url,radio:b.radio}:T):[...S,b]}),h(S=>{if(!S.has(b.id))return S;const E=new Set(S);return E.delete(b.id),E})},[]),w=y.useCallback((b,j)=>{const S=j.trim();!S||S.length>kc||r(E=>E.map(T=>T.id===b?{...T,name:S}:T))},[]),N=y.useCallback(b=>{r(j=>j.filter(S=>S.id!==b)),c(j=>d7(j,b)),h(j=>{if(!j.has(b))return j;const S=new Set(j);return S.delete(b),S})},[]),k=y.useCallback((b,j=!1)=>{const S=s_(b),E=d.has(S);b===i&&!E&&!j||(E&&h(T=>{const I=new Set(T);return I.delete(S),I}),c(b),p(T=>T+1))},[i,d]),x=y.useCallback((b,j)=>{const S=s_(b);h(E=>{if(E.has(S)===j)return E;const I=new Set(E);return j?I.add(S):I.delete(S),I})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:o,fmSource:i,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:g,renameFmStation:w,removeFmStation:N,pickFmSource:k,markFmStationAvailability:x}}function xfe(e){const[t,n]=y.useState(null),[r,s]=y.useState(!1),[o,i]=y.useState(null),c=y.useRef(0);y.useEffect(()=>{if(!e||!No())return;let N=!1;const k=c.current;return fetch("/api/desktop-update").then(x=>x.ok?x.json():null).then(x=>{if(N||c.current!==k)return;const b=E2(x);b&&n(b)}).catch(()=>{}),()=>{N=!0}},[e]);const d=rle(t),h=y.useRef(!1),f=y.useRef(0),p=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(f.current),[]);const g=y.useCallback(async N=>{if(!sr(h.current))return;const k=++p.current;window.clearTimeout(f.current),h.current=!0,s(!0),i(null);const x=b=>{k===p.current&&(window.clearTimeout(f.current),h.current=!1,s(!1),i({failure:b,version:N}))};try{const b=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:N})});if(!b.ok)return x(ale(await b.json().catch(()=>null)))}catch{return x("unreachable")}k===p.current&&(f.current=window.setTimeout(()=>x("timeout"),p4))},[]),w=y.useCallback(N=>{if(No())try{const k=E2(JSON.parse(N));k&&(c.current++,n(k),k.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,s(!1)))}catch{}},[]);return{desktopUpdateRestarting:r,desktopUpdateFailure:o,readyAppUpdate:d,appUpdate:t,askDesktopUpdateRestart:g,onDesktopUpdateEvent:w}}const Id="agent-dag.autoRestart",c$="agent-dag.bundleReloadedFor";function bfe({now:e,stateRef:t,version:n,notice:r,noticeOpen:s,upgradeFailure:o,paused:i}){const[c,d]=y.useState(()=>Ke(Id)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const U=!c;h.current=!0,Jr(Id),d(U),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:U})}).then(P=>P.ok?P.json():null).then(P=>{var $;P!=null&&P.ok&&d((($=P.prefs)==null?void 0:$.autoUpdate)!==!1)}).catch(()=>{})},[c]),[p,g]=y.useState(!1),[w,N]=y.useState("restart"),[k,x]=y.useState(null),b=y.useRef(!1),j=y.useRef(null),S=y.useRef(0),E=y.useRef(null),T=y.useCallback(async U=>{if(!sr(b.current))return;const P=(U==null?void 0:U.upgrade)===!0,$=(U==null?void 0:U.whenIdle)===!0;b.current=!0,j.current=o;const B=++S.current,R=()=>{N(P?"npx":"restart"),g(!0)};$||R();try{window.sessionStorage.setItem("agent-dag.restartPending",(r==null?void 0:r.to)??"")}catch{}let F=!1;try{const O=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($?{upgrade:P,whenIdle:$}:{upgrade:P})});F=$&&O.status===409}catch{}if(F){b.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}$&&R(),window.setTimeout(()=>{if(S.current===B&&b.current){b.current=!1,g(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},P?18e4:3e4)},[r==null?void 0:r.to,o]);y.useEffect(()=>{const U=T2(t.current.agents.values())>0,P=zle({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:U,idleSince:E.current,now:e});E.current=P.idleSince,P.restart&&T({whenIdle:!0})},[c,r==null?void 0:r.kind,n==null?void 0:n.canRestart,s,e,T]);const I=T2(t.current.agents.values()),A=Wle(I,i),D=v4({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:I>0,idleSince:E.current,now:e});y.useEffect(()=>{const U=n==null?void 0:n.running;let P=null,$=null;try{P=window.sessionStorage.getItem("agent-dag.restartPending"),$=window.sessionStorage.getItem(c$)}catch{return}const B=Fle({bundle:"3.40.1",running:U,pending:P,lastTried:$});if(B==="reload"){try{window.sessionStorage.setItem(c$,U??"")}catch{return}window.location.reload();return}if(B!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}b.current=!1,g(!1),x(U??null);const R=window.setTimeout(()=>x(null),6e3);return()=>window.clearTimeout(R)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&qle({asked:j.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}b.current=!1,g(!1)}},[p,o]);const L=y.useCallback(U=>{var P,$;if(!h.current){const B=Ke(Id)==="0";Jr(Id),B&&((P=U.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((($=U.prefs)==null?void 0:$.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:f,restarting:p,restartMode:w,restartedTo:k,askRestart:T,restartCopy:A,restartFuseMs:D,loadAutoRestartPrefs:L}}function kfe(){const[e,t]=y.useState([]),n=y.useRef(new Set),[r,s]=y.useState(null),[o,i]=y.useState(void 0);y.useEffect(()=>{let h=!0,f=0;const p=()=>{fetch("/api/lan").then(g=>g.ok?g.json():null).then(g=>h?(g!=null&&g.ok&&t(pE(Array.isArray(g.pending)?g.pending:[],g.aliases)),g):null).catch(()=>null).then(g=>{h&&(i(w=>g!=null&&g.ok?g:w===void 0?null:w),f=window.setTimeout(p,(g==null?void 0:g.enabled)===!0?m0:oP))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const c=y.useCallback(async(h,f)=>{if(!r){s(h);try{const g=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:h,fp:f})})).json().catch(()=>null);g&&Array.isArray(g.pending)?t(pE(g.pending,g.aliases)):t(w=>w.filter(N=>N.fp!==f))}catch{}finally{s(null)}}},[r]),d=y.useCallback(h=>{r||(n.current.add(h),t(f=>[...f]))},[r]);return{lanPending:e,lanDeferred:n,lanBusy:r,answerLanPair:c,deferLanPair:d,lanStatus:o}}const Nfe=6e4;function jfe({enabled:e,lanStatus:t,now:n}){const[r,s]=y.useState(null),[o,i]=y.useState(()=>new Set),[c,d]=y.useState(null),h=y.useCallback(b=>{b!=null&&b.ok&&Array.isArray(b.accounts)&&s(b.accounts)},[]),f=y.useCallback(async b=>{try{const j=await fetch(`/api/claude-accounts${b?"?refresh=1":""}`);j.ok&&h(await j.json())}catch{}},[h]);y.useEffect(()=>{e&&f(!1)},[e,f]),y.useEffect(()=>{if(!e)return;let b=Date.now();const j=()=>{document.visibilityState!=="visible"||Date.now()-b<Nfe||(b=Date.now(),f(!1))};return document.addEventListener("visibilitychange",j),window.addEventListener("focus",j),()=>{document.removeEventListener("visibilitychange",j),window.removeEventListener("focus",j)}},[e,f]);const p=y.useMemo(()=>e?Iue(r,{lan:t,now:n,closed:o}):[],[e,r,t,n,o]),g=y.useRef(p);g.current=p;const w=y.useCallback(b=>{b.length&&i(j=>new Set([...j,...b]))},[]),N=y.useCallback(()=>{const b=g.current;b.length&&(w(b.map(j=>j.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:b.map(j=>({key:j.key,since:j.since}))})}).catch(()=>{}))},[w]),k=y.useRef(c);k.current=c;const x=y.useCallback(b=>{const j=k.current;w(Oue(j?[j,...g.current]:g.current,b))},[w]);return{rows:p,signingIn:c,observe:h,signIn:d,signedIn:x,refresh:y.useCallback(()=>{f(!0)},[f]),closeSignIn:y.useCallback(()=>d(null),[]),later:N}}const J4=288,Sfe=J4;function _fe(e,t,n){return e?"session-list":t||n?"accounts":null}function Efe(e){return e==="session-list"?Sfe:e==="accounts"?J4:0}const Cfe=240,Tfe=20;function Rfe(e){const t=y.useRef(0),n=y.useRef(e);return y.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=Fc()?0:performance.now()+Cfe+Tfe)},[e]),t}const Q4="agent-dag.sessionListOpen",eD="agent-dag.accountsPanelOpen";function Afe(){return Ke(Q4)==="1"}function Mfe(e){Ge(Q4,e?"1":"0")}function $fe(){const e=Ke(eD);return e===null?!0:e==="1"}function Ife(){const[e,t]=y.useState(Afe);y.useEffect(()=>{Mfe(e)},[e]);const n=y.useRef(!1),[r,s]=y.useState(()=>{const f=$fe();return f&&e?(n.current=!0,!1):f});y.useEffect(()=>{!r&&n.current||Ge(eD,r?"1":"0")},[r]),y.useEffect(()=>{!e&&n.current&&(n.current=!1,s(!0))},[e]);const o=y.useCallback(()=>{t(f=>(f||s(p=>(p&&(n.current=!0),!1)),!f))},[]),i=y.useCallback(()=>{n.current=!1,s(f=>(f||t(!1),!f))},[]),c=y.useCallback(()=>t(!1),[]),d=y.useCallback(()=>s(!1),[]),h=_fe(e,r,n.current);return{sessionListOpen:e,accountsPanelOpen:r,panel:h,toggleSessionList:o,toggleAccountsPanel:i,closeSessionList:c,closeAccountsPanel:d}}const tD="agent-dag.detailOpen",nD="agent-dag.usagePanelOpen",rD="agent-dag.systemPanelOpen";function Ofe(){return Ke(tD)==="1"}function Lfe(e){Ge(tD,e?"1":"0")}function Pfe(){const e=Ke(nD);return e===null?!0:e==="1"}function Dfe(e){Ge(nD,e?"1":"0")}function Ffe(){const e=Ke(rD);return e===null?!0:e==="1"}function Bfe(e){Ge(rD,e?"1":"0")}function qfe(){const[e,t]=y.useState(Ofe);y.useEffect(()=>{Lfe(e)},[e]);const[n,r]=y.useState(Pfe);y.useEffect(()=>{Dfe(n)},[n]);const[s,o]=y.useState(Ffe);return y.useEffect(()=>{Bfe(s)},[s]),Qt("usage-panel",n),Qt("machine-panel",s),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:r,machinePanelOpen:s,setMachinePanelOpen:o}}const Ufe={permission:"your permission",asked:"your answer"},Hfe="No sessions are waiting for you.";function Wfe(e){if(e.length===0)return"";const[t,...n]=e,r=t.waiting.kind,s=n.every(i=>i.waiting.kind===r)?Ufe[r]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${s}.`;const o=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${o} are waiting for ${s}.`}function bb(e,t,n=Hfe){return t!==""?t:e===""?"":n}function zfe({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[r,s]=y.useState(""),o=Wfe(e);y.useEffect(()=>{s(g=>bb(g,o))},[o]);const[i,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(g=>bb(g,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=lfe(n);return y.useEffect(()=>{f(g=>bb(g,p,cfe))},[p]),{blockedSaid:r,watchSaid:i,setWatchSaid:c,incidentSaid:h}}const Vfe="/icon-192.png",sD=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1});function u$(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:sD[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset")}}function Gfe({waitingSessions:e,liveSince:t,focusSession:n}){const[r,s]=y.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,i]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,g]=y.useState(sD),w=y.useCallback(D=>{const L=!p[D];g(U=>({...U,[D]:L})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[D]:L})}).then(U=>U.ok?U.json():null).then(U=>{U!=null&&U.ok&&g(u$(U.prefs))}).catch(()=>{})},[p]),N=y.useRef(()=>{}),k=y.useRef(new Set),x=Dn(e),b=y.useCallback(()=>{const D=!c;d(D),D&&(k.current=yd(x.current)),D&&typeof Notification<"u"&&Notification.permission==="default"&&N.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:D})}).then(L=>L.ok?L.json():null).then(L=>{var U;L!=null&&L.ok&&(d(((U=L.prefs)==null?void 0:U.notifications)===!0),f(L.notificationsVetoed===!0))}).catch(()=>{})},[c]),j=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const L=setTimeout(()=>i(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(L)},[o]);const S=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(D=>{const L=D;s(L),L==="granted"?i("on"):L==="denied"&&i("blocked")})},[]);N.current=S;const E=y.useRef(null),T=e.map(D=>Vh(D.id,D.waiting)).join("|");y.useEffect(()=>{oW(E.current,r)&&(E.current=r,k.current=yd(e))},[r]);const I=y.useRef(!1);y.useEffect(()=>{iW(I.current,t)&&(I.current=!0,k.current=yd(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!lW(E.current,t))return;const D=typeof document>"u"||!document.hidden,L=sW(e,k.current,D,c);for(const U of L)try{const P=new Notification(U.title,{body:U.body,tag:U.key,icon:Vfe});P.onclick=()=>{window.focus(),n(U.sessionId),P.close()}}catch{}k.current=D?yd(e):aW(e,L,k.current)},[T,t]);const A=y.useCallback(D=>{var L;d(((L=D.prefs)==null?void 0:L.notifications)===!0),f(D.notificationsVetoed===!0),g(u$(D.prefs))},[]);return{notifyPermission:r,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:b,notifySupported:j,askForNotifications:S,loadNotifyPrefs:A,accountNotify:p,toggleAccountNotify:w}}function Kfe({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:r,summaryFor:s,browserWatchOpen:o,keyHelpOpen:i,releaseNotes:c,feedbackOpen:d,trafficRadarOpen:h=!1}){const f=Dn(i),p=y.useRef(!1);return p.current=e!=null||t||n!=null||r||s!=null||o||i||c!=null||d||h,{keyHelpOpenRef:f,modalOpenRef:p}}function Yfe({stateRef:e,tourOpen:t,releaseNotes:n}){const[r,s]=y.useState(null),o=y.useCallback(($,B)=>s({agentId:$,toolId:B}),[]),[i,c]=y.useState(null),[d,h]=y.useState(null),f=y.useCallback($=>h($),[]),[p,g]=y.useState(!1),[w,N]=y.useState(!1),[k,x]=y.useState(!1),[b,j]=y.useState(!1),[S,E]=y.useState(!1),[T,I]=y.useState(null),A=y.useCallback($=>{I($??null),E(!0)},[]);Qt("tool-detail",r!==null),Qt("session-summary",i!==null),Qt("context-window",d!==null),Qt("keyboard-help",p),Qt("usage-history",w),Qt("browser-watch",k),Qt("feedback",S);const D=r?yH(e.current.agents,r.agentId,r.toolId):null,L=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:U,modalOpenRef:P}=Kfe({openedTool:D,usageHistoryOpen:w,contextFor:d,tourOpen:t,summaryFor:i,browserWatchOpen:k,keyHelpOpen:p,releaseNotes:n,feedbackOpen:S,trafficRadarOpen:b});return{setOpenedToolKey:s,openTool:o,openedTool:D,summaryFor:i,setSummaryFor:c,contextFor:d,setContextFor:h,openContext:f,contextAgent:L,keyHelpOpen:p,setKeyHelpOpen:g,usageHistoryOpen:w,setUsageHistoryOpen:N,browserWatchOpen:k,setBrowserWatchOpen:x,trafficRadarOpen:b,setTrafficRadarOpen:j,feedbackOpen:S,setFeedbackOpen:E,feedbackPrefill:T,setFeedbackPrefill:I,openFeedback:A,keyHelpOpenRef:U,modalOpenRef:P}}function Xfe({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:r,lastLayoutSigRef:s,forgetRemovals:o,clearSelection:i,rerender:c,modalOpenRef:d}){const[h,f]=y.useState(!1),p=y.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=rk(),t.current.clear(),n.current.clear(),r.current.clear(),s.current="",Q3(),o(),i(),c()},[c,i,o]),g=Dn(h),w=y.useCallback(N=>{const k=Kle(N,{confirmOpen:g.current,modalOpen:d.current});k==="confirm"?f(!0):k==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:w}}const d$="agent-dag.oldNameNoticeDismissed";function Zfe(e){const[t,n]=y.useState(()=>Ke(d$)??""),r=e!=null&&e.invokedAs&&e.invokedAs!==Lt?e.invokedAs:null,s=r!=null&&t!==r,o=y.useCallback(()=>{r&&(n(r),Ge(d$,r))},[r]);return{oldName:r,oldNameOpen:s,dismissOldName:o}}const Jfe=300*1e3,Qfe=1800*1e3,epe=8e3,tpe=3e4;function h$(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function npe({modalOpenRef:e}){const t=y.useCallback(()=>Bd({appModal:e.current,dialogDepth:On.dialogDepth()}),[e]),[n,r]=y.useState("hidden"),[s,o]=y.useState(null),[i,c]=y.useState(!1),d=y.useRef(n);d.current=n,y.useEffect(()=>{let w=!1;const N=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const b=await fetch("/api/rating").then(j=>j.ok?j.json():null).catch(()=>null);w||!b||r(j=>j==="thanks"?j:b.ask===!0?"asking":"hidden")},k=window.setTimeout(N,Jfe),x=window.setInterval(N,Qfe);return()=>{w=!0,window.clearTimeout(k),window.clearInterval(x)}},[t]),y.useEffect(()=>{if(n!=="thanks"||i)return;const w=s!==null&&s<=6?tpe:epe;let N=0;const k=()=>{t()?N=window.setTimeout(k,w):r("hidden")};return N=window.setTimeout(k,w),()=>window.clearTimeout(N)},[n,s,i,t]);const h=y.useCallback(w=>{o(w),c(!1),r("thanks"),h$({score:w})},[]),f=y.useCallback(w=>c(w),[]),p=y.useCallback(()=>{r("hidden"),h$({later:!0})},[]),g=y.useCallback(()=>r("hidden"),[]);return{ratingPhase:n,ratingScore:s,answerRating:h,rateLater:p,closeRating:g,holdThanks:f}}function rpe({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:r}){const[s,o]=y.useState(()=>ete(Ke)),i=Dn(s),[c,d]=y.useState([]),h=y.useCallback(j=>{o(S=>{const E={...S,[j]:null};return i.current=E,E}),Jr(lc[j])},[]),f=y.useCallback((j,S)=>{const E=i.current[j];S&&E!==S||(h(j),t(T=>{const I={...T,[j]:{...T[j],figure:Ln}};return n.current=I,I}),Ge(Nh[j],Ln))},[h]),p=Dn(f);y.useEffect(()=>{let j=!0;return dte().then(S=>{if(!j)return;d(S);const E=new Set(S.map(T=>T.id));for(const T of Wd){const I=i.current[T];I&&!E.has(I)&&p.current(T,I)}},()=>{}),()=>{j=!1}},[]);const g=y.useCallback((j,S)=>{if(!c.some(T=>T.id===S))return;const E={...i.current,[j]:S};i.current=E,o(E),Ge(lc[j],S),r(j,!0)},[c,r]),w=y.useCallback(async j=>{var I;const S=k0(c.length);if(S)throw new Error(S);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 ote(j,L=>T.decodeAudioData(L));await UE(A);const D=Ac(A);d(L=>[...L.filter(U=>U.id!==D.id),D])}finally{(I=T.close)==null||I.call(T)}},[c.length]),N=y.useCallback(async j=>{const S=k0(c.length);if(S)throw new Error(S);const E=ite(j);await UE(E);const T=Ac(E);d(I=>[...I.filter(A=>A.id!==T.id),T])},[c.length]),k=y.useCallback(async(j,S)=>{const E=c.find(I=>I.id===j),T=S.trim().slice(0,80);!E||!T||T===E.name||(await fte(j,T),d(I=>I.map(A=>A.id===j?{...A,name:T}:A)))},[c]),x=y.useCallback(async j=>{await pte(j),d(I=>I.filter(A=>A.id!==j));const S=i.current,E=tte(S,j);i.current=E,o(E);const T=Wd.filter(I=>S[I]===j);for(const I of T)Jr(lc[I]),Ge(Nh[I],Ln);T.length>0&&t(I=>{const A={...I};for(const D of T)A[D]={...A[D],figure:Ln};return n.current=A,A})},[]),b=y.useCallback(j=>{var T,I;const S=Wd.find(A=>i.current[A]===j),E=S?n.current[S].level:ko;(T=e.current)==null||T.unlock(),(I=e.current)==null||I.previewCustom(j,E)},[]);return{customSelections:s,customSelectionsRef:i,customAssets:c,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:g,importNotificationAudio:w,createNotificationVoice:N,renameCustomAsset:k,deleteCustomAsset:x,previewCustomAsset:b}}function spe(e){const[t,n]=y.useState(()=>_te(Ke)),r=Dn(t),s=y.useRef(null),o=y.useCallback((c,d=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),s.current!==null&&clearTimeout(s.current),s.current=null,!d){(f=e.current)==null||f.play(c,!0);return}s.current=setTimeout(()=>{var p;s.current=null,(p=e.current)==null||p.play(c,!0)},bte)},[]),i=y.useCallback((c,d)=>{n(h=>{const f={level:pf(d.level??h[c].level),figure:LP(c,d.figure??h[c].figure)};return Ge(FP[c],String(f.level)),Ge(Nh[c],f.figure),{...h,[c]:f}}),o(c,!0)},[o]);return y.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:r,previewTone:o,changeTone:i}}const ape=15e3;function ope(e){return e.visibilityState==="visible"&&e.hasFocus()}function ipe(e,t){return t||e===!0}function lpe(){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 cpe(){y.useEffect(()=>{const e=lpe();let t=null;const n=i=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:i}),keepalive:!0}).catch(()=>{})},r=()=>{const i=ope(document);ipe(t,i)&&n(i),t=i},s=()=>{t&&n(!1),t=!1};r();const o=window.setInterval(r,ape);return window.addEventListener("focus",r),window.addEventListener("blur",r),document.addEventListener("visibilitychange",r),window.addEventListener("pagehide",s),()=>{window.clearInterval(o),window.removeEventListener("focus",r),window.removeEventListener("blur",r),document.removeEventListener("visibilitychange",r),window.removeEventListener("pagehide",s),s()}},[])}function upe({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){y.useEffect(()=>{let r=!0;return fetch("/api/prefs").then(s=>s.ok?s.json():null).then(s=>{!r||!(s!=null&&s.ok)||(e(s),t(s),n(s))}).catch(()=>{}),()=>{r=!1}},[])}const kb="agent-dag.versionNoticeDismissed",dpe=15*6e4;function hpe(e){const[t,n]=y.useState(null),[r,s]=y.useState(()=>Ke(kb)??""),o=y.useRef(0),[i,c]=y.useState(!1),d=y.useCallback((k=!1)=>(k&&(o.current=Date.now(),c(!0)),fetch(k?"/api/version?refresh=1":"/api/version").then(x=>x.ok?x.json():null).then(x=>(x&&n(x),x??null)).catch(()=>null).finally(()=>{k&&c(!1)})),[]),h=y.useCallback(()=>{d(Date.now()-o.current>=dpe)},[d]);y.useEffect(()=>{d();const k=window.setInterval(h,5*6e4),x=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",x),()=>{window.clearInterval(k),document.removeEventListener("visibilitychange",x)}},[d,h]),y.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=g4(f),g=dle(f,r),w=y.useCallback(()=>{s(""),Ge(kb,"")},[]),N=y.useCallback(()=>{f&&(s(p),Ge(kb,p))},[f,p]);return{version:t,notice:f,noticeOpen:g,showNotice:w,dismissNotice:N,versionChecking:i,loadVersion:d}}function fpe({version:e,readyAppUpdate:t}){const[n,r]=y.useState(!1),s=y.useRef(null),[o,i]=y.useState(null),c=o&&t?t.version:null,d=y.useRef(null);y.useEffect(()=>{!c||d.current===c||(d.current=c,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:c})}).catch(()=>{}))},[c]);const h=y.useRef(!1);y.useEffect(()=>{if(h.current)return;const x=ac(),b=nde(x),j=lde({stored:b,running:(e==null?void 0:e.running)??null,notes:U2,remembers:rde(x)});if(j.reason==="no-version")return;h.current=!0,j.record&&sde(x,j.record);let S=!0;return(async()=>{var D;let T=ade(x);if(No())try{const L=await fetch("/api/prefs");if(!L.ok)throw new Error("desktop tour preferences unavailable");const U=await L.json();if(!(U!=null&&U.ok))throw new Error("desktop tour preferences unavailable");const P=((D=U.prefs)==null?void 0:D.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(!S)return;const I=ide({tourSeen:T,decision:j}),A=j.show.length?{entries:j.show,since:b,firstRun:!1}:null;I.tour&&r(!0),I.notes==="now"?i(A):I.notes==="after"&&(s.current=A)})(),()=>{S=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.40.1",p=y.useMemo(()=>O4(U2,null,f),[f]),g=y.useCallback(()=>{i({entries:p,since:null,firstRun:!1})},[p]),w=y.useCallback(()=>r(!0),[]),N=y.useCallback(()=>i(null),[]),k=y.useCallback(()=>{r(!1),ode(ac()),No()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const x=s.current;s.current=null,x&&i(x)},[]);return{tourOpen:n,openTour:w,closeTour:k,releaseNotes:o,closeReleaseNotes:N,chipVersion:f,openReleaseNotes:g}}function ppe(){const[e,t]=y.useState(void 0),[n,r]=y.useState(!1),s=y.useRef(!1);return s.current=e===!0&&!n,y.useEffect(()=>Dhe(()=>s.current),[]),{loadReportsPrefs:y.useCallback(i=>{var c;t(((c=i.prefs)==null?void 0:c.reports)!==!1),r(i.reportsVetoed===!0)},[])}}function mpe(e){const[t,n]=y.useState(null);y.useEffect(()=>{const c=Ke("agent-dag.sound");n(c===null?!0:c==="on")},[]);const r=y.useCallback(()=>{n(c=>{var h,f;const d=c!==!0;return Ge("agent-dag.sound",d?"on":"off"),d?(h=e.current)==null||h.unlock():(f=e.current)==null||f.silence(),d})},[]),s=y.useCallback(c=>{r()},[r]),o=Dn(s),i=Dn(t);return{soundOn:t,toggleSound:r,activateSoundRef:o,soundOnRef:i}}function gpe(){const[e,t]=y.useState(Voe),n=y.useCallback(o=>{t(i=>Goe(i,o))},[]),r=y.useCallback(()=>t(o=>({...o,open:!1})),[]),s=y.useCallback(o=>t(i=>({...i,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,openSettings:n,closeSettings:r,showSection:s}}const ype="agent-dag.autoFitDisabled";function wpe(e){const t=y.useRef(!1),[n,r]=y.useState(!1);y.useEffect(()=>{Jr(ype)},[]);const s=y.useCallback(()=>{t.current||(t.current=!0,r(!0))},[]),o=y.useCallback(()=>{t.current=!1,r(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:o}}function vpe(){return a.jsx(nk,{children:a.jsx(qhe,{children:a.jsx(xpe,{})})})}function xpe(){const e=zi(),t=y.useState(rk)[0],n=y.useRef(t),[,r]=y.useState(0),s=y.useCallback(()=>r(qr=>qr+1),[]),{detailOpen:o,setDetailOpen:i,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=qfe(),{selectedIds:p,primarySelectedId:g,selectAgent:w,clearSelection:N,pruneSelectionToBoard:k}=Wte(n,i),{sessionListOpen:x,accountsPanelOpen:b,panel:j,toggleSessionList:S,toggleAccountsPanel:E,closeSessionList:T,closeAccountsPanel:I}=Ife(),A=Ni(b,200),D=Ni(x,200),L=SS(x,D),U=Ni(c,130),P=Ni(h,130),$=y.useRef(null),B=mpe($),{activateSoundRef:R,soundOnRef:F}=B,O=spe($),{setTonePrefs:G,tonePrefsRef:Y,previewTone:V}=O,q=rpe({chimesRef:$,setTonePrefs:G,tonePrefsRef:Y,previewTone:V}),{customSelectionsRef:M,fallbackCustomRef:z}=q,Z=gpe(),{openSettings:H}=Z;wfe({chimesRef:$,soundOnRef:F,tonePrefsRef:Y,customSelectionsRef:M,fallbackCustomRef:z});const X=Whe(n),{pauseGate:K,paused:Q,togglePause:ee}=X,re=y.useRef(()=>{}),{live:ie,tabCapped:de,everConnected:pe,liveSince:se}=Ite({stateRef:n,rerender:s,pauseGate:K,chimesRef:$,desktopUpdateRef:re}),me=hpe(ie),{version:he,notice:le,noticeOpen:ue,loadVersion:ye}=me,ke=xfe(ie),{readyAppUpdate:Te,onDesktopUpdateEvent:xe}=ke;re.current=xe,cpe();const Ne=fpe({version:he,readyAppUpdate:Te}),{tourOpen:Ee,openTour:Le,releaseNotes:$e}=Ne,{workspace:rt,providers:Be,providersRef:Qe}=Vhe(ie),ot=Efe(j==="accounts"&&!Be.claude?null:j),It=Rfe(ot),Ye=SS(b,A)&&Be.claude,xt=Zfe(he),it=ufe({version:he,loadVersion:ye}),{upgradeFailure:Ue}=it,bt=Yfe({stateRef:n,tourOpen:Ee,releaseNotes:$e}),ct=npe({modalOpenRef:bt.modalOpenRef}),{openTool:Et,setSummaryFor:et,setContextFor:mt,openContext:jt,setKeyHelpOpen:ut,setUsageHistoryOpen:tt,setBrowserWatchOpen:Ct,keyHelpOpenRef:Un,modalOpenRef:Tt}=bt,dn=ppe(),an=hfe(),{watchOn:_n,watchUnseen:hn}=an,Yt=kfe(),[Hn,Se]=y.useState(0),{presentCats:Ie,hiddenCats:Fe,toggleCat:gt,catBarRef:zt,catBarOccluded:ss}=gfe(n),Ps=y.useRef(null),[Ds,Fs]=y.useState(0),dt=zte({stateRef:n,rerender:s,pruneSelectionToBoard:k,setContextFor:mt,setSummaryFor:et}),Bs=Xhe(Be.claude||Be.codex),$r=ife(Bs,dt),as=jfe({enabled:Be.claude,lanStatus:Yt.lanStatus,now:dt}),ur=bfe({now:dt,stateRef:n,version:he,notice:le,noticeOpen:ue,upgradeFailure:Ue,paused:X.paused}),{askRestart:qs,loadAutoRestartPrefs:os}=ur,dr=mfe(),{setTheme:is,palette:Ca}=dr,ge=vfe(),ze=Gae(),{applyViewport:Xe,moveCamera:En,fitLeft:Cn,cameraEpochRef:Ir,lastFitTimeRef:ls}=ze,fn=ioe(ze),{pinnedRef:Rt,positionsRef:Or,lastLayoutSigRef:Tn,handleRelayout:Of,rearrangeUndo:Lf}=fn,Qc=y.useRef(null),Ta=y.useRef(()=>{}),Ro=se!==null,Us=y.useRef(0),Ra=y.useCallback(()=>{Us.current=Date.now()},[]),{canvasRef:Lr,canvasSize:Pf,paneSizeRef:tl}=Boe(It),nl=wpe(Cn),{autoFitDisabledRef:Ao,disableAutoFit:cs}=nl,rl=y.useRef(!1),{measuredRef:hr,measuredVersionRef:st,sizeVersion:eu,domSizeVersion:tu}=qoe(rl),{removedNodes:Mo,removedAgentIds:us,removeNode:nu,removeSelectedNode:sl,removalNotice:$o,bringBack:Hs,bringBackAll:Pr,forgetRemovals:Dr}=Coe({stateRef:n,pinnedRef:Rt,positionsRef:Or,canvasRef:Lr,clearSelection:N,primarySelectedId:g}),Wn=Noe({stateRef:n,now:dt,removedAgentIds:us,sizeVersion:eu,domSizeVersion:tu});loe(Wn,fn),Eoe({layoutSig:Wn,rf:e,stateRef:n,measuredRef:hr,pinnedRef:Rt,positionsRef:Or,paneSizeRef:tl,lastInteractRef:Us,autoFitDisabledRef:Ao,lastFitTimeRef:ls,fitLeft:Cn});const Ws=Uoe(),{bubbling:Aa,endBubble:Fr,onBubble:Df}=Dee(),[Io,Ma]=y.useState(!1),ru=Lee(),{beginTrashDrag:su,trackTrashDrag:Oo,endTrashDrag:au}=ru,ou=Gee({stateRef:n,measuredRef:hr,measuredVersionRef:st,canvasRef:Lr}),{lodRef:$a,applyZoom:Ia}=ou,ds=Poe({applyViewport:Xe,lastFitTimeRef:ls,cameraEpochRef:Ir,disableAutoFit:cs,markInteract:Ra,canvasRef:Lr,applyZoom:Ia}),Br=g?n.current.agents.get(g):null,al=o&&Br!=null,zs=eie({sessionListShown:L,usageShown:ga(U),machineShown:ga(P),accountsShown:Ye,detailShown:al,primarySelectedId:g,canvasRef:Lr}),{railInsetRef:Vs,availableWidth:Oa,availableHeight:Lo}=Uae({canvasRef:Lr,canvasSize:Pf,machinePhase:P,usagePhase:U,usagePanelOpen:c,detailShown:al}),ol=joe({stateRef:n,now:dt,availableWidth:Oa,availableHeight:Lo,layout:fn,measuredRef:hr,onBubble:Df,settled:Ws,dragging:Io,layoutSig:Wn,selectedIds:p,openContext:jt,historyReplayed:Ro,removedNodes:Mo,removedAgentIds:us,dragTick:Hn,dragPatchRef:Ps,dragMoveTick:Ds}),{nodes:zn,edges:il}=ol,Gs=Dn(g);coe({nodes:zn,edges:il,settled:Ws,dragging:Io,availableWidth:Oa,availableHeight:Lo,layout:fn,camera:ze,rf:e,measuredRef:hr,stateRef:n,lastFocusRef:Qc,primarySelectedIdRef:Gs,focusAgentRef:Ta,autoFitDisabledRef:Ao});const ll=Xfe({stateRef:n,pinnedRef:Rt,measuredRef:hr,positionsRef:Or,lastLayoutSigRef:Tn,forgetRemovals:Dr,clearSelection:N,rerender:s,modalOpenRef:Tt}),{requestClear:La}=ll,Po=tie({nodes:zn,stateRef:n,pinnedRef:Rt,positionsRef:Or,draggingRef:rl,dragPatchRef:Ps,setDragging:Ma,setDragMoveTick:Fs,setDragTick:Se,endBubble:Fr,markInteract:Ra,disableAutoFit:cs,beginTrashDrag:su,trackTrashDrag:Oo,endTrashDrag:au,removeNode:nu}),iu=y.useCallback(()=>Cn(500),[Cn]),Xt=Dn(zn),{focusAgent:fr,stepAgent:cl,focusSession:Vn}=Yae({canvasRef:Lr,stateRef:n,measuredRef:hr,nodesRef:Xt,railInsetRef:Vs,moveCamera:En,disableAutoFit:cs,lastFocusRef:Qc,focusAgentRef:Ta,selectAgent:w,primarySelectedIdRef:Gs}),Ff=Doe({clearSelection:N,selectAgent:w,detailOpen:o,setDetailOpen:i,detailShown:al,focusAgent:fr,draggingRef:rl,lodRef:$a}),ul=Xae({nodesRef:Xt,stateRef:n,canvasRef:Lr,railInsetRef:Vs}),dl=Dn(sl),hs=y.useRef(null),Do=y.useCallback(qr=>{us.has(qr)&&Hs([qr]),Vn(qr)},[us,Hs,Vn]),lu=Hoe();Joe({pointerFocusRef:lu,nodesRef:Xt,stateRef:n,primarySelectedIdRef:Gs,providersRef:Qe,soundOnRef:F,keyHelpOpenRef:Un,modalOpenRef:Tt,waitingCursorRef:hs,removeSelectedRef:dl,activateSoundRef:R,clearSelection:N,selectAgent:w,focusAgent:fr,stepAgent:cl,focusSession:Vn,requestClear:La,handleRelayout:Of,undoRearrange:Lf.undo,handleFit:iu,togglePause:ee,toggleSessionList:S,toggleAccountsPanel:E,setDetailOpen:i,setUsageHistoryOpen:tt,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:Ct,setKeyHelpOpen:ut,setTheme:is,openSettings:H});const cu=n.current.agents.size,Ks=y.useMemo(()=>qb(n.current.agents.values()),[n.current,n.current.revision]);Toe({stateRef:n,waitingSessions:Ks,removedAgentIds:us,removedNodes:Mo,bringBack:Hs}),Ioe({stateRef:n,waitingSessions:Ks,live:ie});const uu=zfe({waitingSessions:Ks,watchUnseen:hn,incidents:$r}),Pa=Gfe({waitingSessions:Ks,liveSince:se,focusSession:Vn}),{loadNotifyPrefs:Bf}=Pa;upe({loadAutoRestartPrefs:os,loadNotifyPrefs:Bf,loadReportsPrefs:dn.loadReportsPrefs});const Da=Yie($ie),[du,hu]=y.useState(!1),qf=y.useCallback(()=>hu(!1),[]),pr=Kie({providers:Be,sessionListOpen:x,toggleSessionList:S,accountsPanelOpen:b,toggleAccountsPanel:E,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f,setUsageHistoryOpen:tt,watchOn:_n,watchUnseen:hn,setBrowserWatchOpen:Ct,setTrafficRadarOpen:bt.setTrafficRadarOpen,openSettings:H,onFeedback:bt.openFeedback,radioOpen:du,setRadioOpen:hu,toggles:zs.toggles}),[Uf,Hf]=y.useState(0),Wf=y.useCallback(()=>{x||S(),requestAnimationFrame(()=>{var qr;return(qr=document.querySelector("#session-list .sl-row"))==null?void 0:qr.focus()})},[x,S]);return 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(YV,{}),a.jsx(kle,{versionCheck:me,welcome:Ne,desktopUpdate:ke,pause:X,announcements:uu,notify:Pa,waitingSessions:Ks,waitingCursorRef:hs,focusSession:Vn,live:ie,now:dt,incidents:$r,queueNamed:Da?0:Uf}),!Da&&a.jsx(vle,{waitingSessions:Ks,waitingCursorRef:hs,focusSession:Vn,now:dt,onFit:Hf,onMore:Wf}),Br&&a.jsx(Nle,{selected:Br,now:dt,selectedIds:p,focusAgent:fr,clearSelection:N}),!Da&&a.jsx("div",{className:"actions",children:a.jsx(Aie,{items:pr.utilities})})]}),Da?a.jsx(Rie,{items:[...pr.left,...pr.right[0],pr.utilities[0]],more:[...pr.right.slice(1).flat(),pr.utilities[1]]}):a.jsx(S2,{side:"left",label:"Left column",groups:[pr.left]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:$o?`${$o.label} removed from the board.`:""}),a.jsx(Gle,{restart:ur,versionCheck:me,upgrade:it,oldNameNotice:xt,rating:ct,onFeedback:bt.openFeedback,everConnected:pe,live:ie,paused:Q}),(L||Ye)&&a.jsxs(Tee,{width:ot,children:[Ye&&a.jsx(Cee,{leaving:_S(b,A),onReport:bt.openFeedback,onRoster:as.observe,onClose:()=>{zs.accounts(),I()}}),L&&a.jsx(cG,{leaving:_S(x,D),state:n.current,now:dt,selectedIds:p,onSelect:Do,onClose:()=>{zs.sessionList(),T()},removedIds:us,onBringBackAll:Pr})]}),a.jsxs(Cle,{canvasRef:Lr,bubbling:Aa,dragging:Io,trash:ru,zoom:ou,viewport:ds,stateRef:n,peek:ul,children:[cu===0&&(!ie&&de?a.jsx(rie,{reservedRight:Vs.current}):a.jsx(sie,{live:ie,everConnected:pe,providers:Be,workspace:rt,onTour:Le,reservedRight:Vs.current})),(Ie.length>1||Fe.size>0)&&a.jsx(jle,{catBarRef:zt,catBarOccluded:ss,presentCats:Ie,hiddenCats:Fe,toggleCat:gt}),a.jsx(KV,{graph:ol,layout:fn,viewport:ds,clicks:Ff,drag:Po,appearance:dr,fm:ge,radioOpen:du,onRadioClose:qf,autoFit:nl,pause:X,stateRef:n,measuredRef:hr,hiddenCats:Fe,now:dt,openTool:Et,focusAgent:fr,requestClear:La,setKeyHelpOpen:ut})]}),!Da&&a.jsx(S2,{side:"right",label:"Right panels",groups:pr.right}),ga(U)&&a.jsx(hK,{state:n.current,now:dt,providers:Be,incidents:$r,liveSince:se,leaving:U==="leaving",onClose:()=>{zs.usage(),d(!1)}}),ga(P)&&a.jsx(XK,{usageOpen:c,leaving:P==="leaving",onClose:()=>{zs.machine(),f(!1)}}),o&&Br?a.jsx(yie,{selected:Br,now:dt,openTool:Et,setSummaryFor:et,stateRef:n,removeSelectedNode:sl,onClose:()=>{zs.detail(),i(!1)}}):null,a.jsx(Nhe,{dialogs:bt,welcome:Ne,desktopUpdate:ke,versionCheck:me,restart:ur,upgrade:it,lanPairs:Yt,attention:as,clearFlow:ll,watchBadge:an,announcements:uu,appearance:dr,providers:Be,stateRef:n,agentCount:cu,menus:Z,sound:B,tones:O,customTones:q,notify:Pa,fm:ge})]})}try{UW(window.localStorage)}catch{}const bpe=C5.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);bpe.render(a.jsx(vpe,{}));export{xo as A,Na as B,$k as C,N7 as D,_pe as E,jpe as F,Spe as G,NW as H,W4 as I,Npe as J,H9 as K,Ide as L,ka as M,U9 as R,q4 as V,wL as a,at as b,es as c,wt as d,Es as e,Ve as f,Epe as g,Rs as h,Cpe as i,a as j,Tc as k,Bn as l,ste as m,Tpe as n,dde as o,n0 as p,Rpe as q,y as r,sr as s,Ape as t,pt as u,Mpe as v,So as w,ude as x,$pe as y,sf as z};