@wjarka/cezarion 0.18.0-dev.7085 → 0.18.0-dev.7094
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/web/dist/assets/activity-motion-YVMdTv1H.js +2 -0
- package/web/dist/assets/{activity-route-KsJ3FdWd.js → activity-route-Bd9LuD0o.js} +1 -1
- package/web/dist/assets/agent-accounts-DetCQbKD.js +1 -0
- package/web/dist/assets/attention-Bs96zuwc.js +1 -0
- package/web/dist/assets/{cez-idle-D49bY6KR.js → cez-idle-CnPEf2T2.js} +1 -1
- package/web/dist/assets/{chunk-BO2N2NFS-DE6qKn3r.js → chunk-BO2N2NFS-CM5F_Wdn.js} +17 -17
- package/web/dist/assets/{commit-diff-panel-DGjLiAVs.js → commit-diff-panel-BY9ItExV.js} +1 -1
- package/web/dist/assets/{core-BCsw8oQw.js → core-DzoyrHjB.js} +2 -2
- package/web/dist/assets/{design-icons-DmYTv2r1.js → design-icons-B6-0w7Aw.js} +1 -1
- package/web/dist/assets/dialog-tMSuX5a7.js +1 -0
- package/web/dist/assets/{diff-controls-CeYlCm_y.js → diff-controls-fOOHkbPK.js} +1 -1
- package/web/dist/assets/diff-nSqnAkNf.js +3 -0
- package/web/dist/assets/{diff-view-lTo0JT2v.js → diff-view-Bp_dyecW.js} +5 -5
- package/web/dist/assets/dist-CwBtGUlU.js +1 -0
- package/web/dist/assets/dropdown-menu-CzUYjvx4.js +1 -0
- package/web/dist/assets/file-preview-Dkl6S-Ej.js +2 -0
- package/web/dist/assets/{git-toolbar-ChgRC3vR.js → git-toolbar-xd4qbEj6.js} +1 -1
- package/web/dist/assets/github-DRMN6FYi.js +1 -0
- package/web/dist/assets/{global-activity-route-lHJSxyik.js → global-activity-route-BMBowNcw.js} +1 -1
- package/web/dist/assets/{highlighted-body-OFNGDK62-BL-MfFgl.js → highlighted-body-OFNGDK62-D2OLwPBs.js} +1 -1
- package/web/dist/assets/index-BhQ7JeB6.css +1 -0
- package/web/dist/assets/index-QM9AFNSj.js +14 -0
- package/web/dist/assets/lib-DrPFkMXk.js +1 -0
- package/web/dist/assets/{live-protocol-DHEBTIRD.js → live-protocol-C_Z-JQOy.js} +1 -1
- package/web/dist/assets/markdown-CZVLEjwk.js +4 -0
- package/web/dist/assets/mermaid-GHXKKRXX-DCw6rSYC.js +1 -0
- package/web/dist/assets/picker-pill-DKbLlGPr.js +18 -0
- package/web/dist/assets/{preview-pane-connected-Cpc-OIBO.js → preview-pane-connected-DCz8ZSjW.js} +3 -3
- package/web/dist/assets/{project-router-RpJixuMl.js → project-router-D5aSJsZ7.js} +1 -1
- package/web/dist/assets/project-scope-context-BUXmC8my.js +4 -0
- package/web/dist/assets/prompt-template-menu-De-8v5io.js +1 -0
- package/web/dist/assets/queries-DkipLnOL.js +1 -0
- package/web/dist/assets/{reference-chip-CZ88WX7M.js → reference-chip-BVB5YsfP.js} +1 -1
- package/web/dist/assets/repo-git-BdRmck7y.js +1 -0
- package/web/dist/assets/report-reader-C8_2WEz6.js +1 -0
- package/web/dist/assets/reports-DxAL6BCk.js +1 -0
- package/web/dist/assets/run-header-Dhh86q4A.js +2 -0
- package/web/dist/assets/skills-C49LGb-4.js +1 -0
- package/web/dist/assets/skills-pM_PouEs.js +1 -0
- package/web/dist/assets/{tab-link-BT6RV1JN.js → tab-link-BTFjRC1e.js} +1 -1
- package/web/dist/assets/task-changes-B0oxkbcW.js +1 -0
- package/web/dist/assets/{task-commits-yRo6PLOs.js → task-commits-DDZcksfZ.js} +1 -1
- package/web/dist/assets/task-files-BTj0Ehlx.js +1 -0
- package/web/dist/assets/{task-github-item-aysyirC9.js → task-github-item-y1rABsg2.js} +1 -1
- package/web/dist/assets/task-thread-CaRlk42s.js +9 -0
- package/web/dist/assets/{thread-state-CbZJSZ8d.js → thread-state-BE9onTdO.js} +1 -1
- package/web/dist/assets/{use-desktop-DXVYKnpA.js → use-desktop-DWhNBxlY.js} +1 -1
- package/web/dist/assets/use-hand-to-agent-state-D_Yp8YT9.js +1 -0
- package/web/dist/assets/{useInfiniteQuery-hcJtqg7r.js → useInfiniteQuery-0WCd35C5.js} +1 -1
- package/web/dist/assets/useQuery-BifRjEjr.js +1 -0
- package/web/dist/assets/workflows-BN66M7yw.js +7 -0
- package/web/dist/assets/workflows-C21NystW.css +1 -0
- package/web/dist/assets/{ws-DUd04kII.js → ws-DJraxHk2.js} +1 -1
- package/web/dist/index.html +21 -23
- package/web/dist/live-worker.js +1 -1
- package/web/dist/assets/activity-motion-xKVlnR0q.js +0 -2
- package/web/dist/assets/agent-accounts-CEmxoU4C.js +0 -18
- package/web/dist/assets/alert-dialog-CH4SXGfX.js +0 -1
- package/web/dist/assets/attention-D0gSE5Rr.js +0 -1
- package/web/dist/assets/dialog-B7p5oc5r.js +0 -1
- package/web/dist/assets/diff-CsyHTaL2.js +0 -3
- package/web/dist/assets/dist-ClnpAEgV.js +0 -1
- package/web/dist/assets/dropdown-menu-DPrTX-zi.js +0 -1
- package/web/dist/assets/file-preview-Dq54dro7.js +0 -2
- package/web/dist/assets/github-BnwdgVET.js +0 -1
- package/web/dist/assets/index-Ci54Zqis.css +0 -1
- package/web/dist/assets/index-ZXr4fght.js +0 -17
- package/web/dist/assets/lib-BxQXEXDF.js +0 -1
- package/web/dist/assets/mermaid-GHXKKRXX-C4jxqUUb.js +0 -1
- package/web/dist/assets/project-scope-context-Cs9K5L24.js +0 -4
- package/web/dist/assets/prompt-template-menu-35CQbC0C.js +0 -1
- package/web/dist/assets/queries-CU1rdCnf.js +0 -1
- package/web/dist/assets/repo-git-BQRXiSQc.js +0 -1
- package/web/dist/assets/report-reader-B90i10fL.js +0 -1
- package/web/dist/assets/reports-DHccd243.js +0 -1
- package/web/dist/assets/run-header-B1Mhp48O.js +0 -2
- package/web/dist/assets/skill-empty-hint-YDmkqgo-.js +0 -1
- package/web/dist/assets/skills-9eRk7nNW.js +0 -1
- package/web/dist/assets/skills-DFBiAuJG.js +0 -1
- package/web/dist/assets/task-changes-D0x55i9H.js +0 -1
- package/web/dist/assets/task-files-DxDEn0jU.js +0 -1
- package/web/dist/assets/task-thread-CFw63WOG.js +0 -9
- package/web/dist/assets/use-hand-to-agent-state-CPCd0vCN.js +0 -1
- package/web/dist/assets/useQuery-DeFHpzJJ.js +0 -1
- package/web/dist/assets/workflows-DMUcQeqG.js +0 -7
package/web/dist/assets/{preview-pane-connected-Cpc-OIBO.js → preview-pane-connected-DCz8ZSjW.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{L as t,t as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{
|
|
2
|
-
`);return(0,Y.jsxs)(`div`,{"data-slot":`preview-log-tail`,className:r(`min-w-0 rounded-lg bg-muted px-3.5 py-3 font-mono text-xs`,i),children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,Y.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${a.length} ${a.length===1?`line`:`lines`} · ${t}`]}),(0,Y.jsxs)(`button`,{type:`button`,className:`-m-2 inline-flex min-h-11 items-center gap-1.5 rounded-sm p-2 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:min-h-0 md:p-0`,onClick:()=>n(e),children:[(0,Y.jsx)(M,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,Y.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Fe=/^([a-z][a-z0-9+.-]*):/i;function Ie(e,t){let n=e.trim();if(n===``)return{kind:`error`,message:`Type a URL or a port.`};if(/^\d{1,5}$/.test(n)){let e=Number(n);return e<1||e>65535?{kind:`error`,message:`A port is a number from 1 to 65535.`}:t.some(t=>t.port===e)?{kind:`server`,port:e}:{kind:`url`,url:`http://localhost:${e}`}}let r=Fe.exec(n)?.[1]?.toLowerCase();return r&&!/^[a-z0-9.-]+:\d/i.test(n)?r!==`http`&&r!==`https`?{kind:`error`,message:`Only http and https addresses open here.`}:Le(n):Le(`http://${n}`)}function Le(e){let t={kind:`error`,message:`That is not a valid address.`};if(/\s/.test(e))return t;try{new URL(e)}catch{return t}return{kind:`url`,url:e}}function Re(e){return e.replace(/^https?:\/\//i,``)}var ze=`https://github.com/hearsay-tools/squawk#environment-variables`;function Be({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,Y.jsx)(We,{state:e,actions:t});case`downloading`:return(0,Y.jsx)(Ke,{state:e,actions:t});case`download-failed`:return(0,Y.jsx)(qe,{state:e,actions:t});case`sandbox-failed`:return(0,Y.jsx)(Je,{state:e,actions:t});case`browser-exited`:return(0,Y.jsx)(Ye,{state:e,actions:t});case`needs-approval`:return(0,Y.jsx)(Qe,{state:e,actions:t});case`port-held`:return(0,Y.jsx)($e,{state:e,actions:t});case`server-starting`:return(0,Y.jsx)(et,{state:e,actions:t});case`server-stalled`:return(0,Y.jsx)(tt,{state:e,actions:t});case`server-exited`:return(0,Y.jsx)(nt,{state:e,actions:t});case`server-stopped`:return(0,Y.jsx)(rt,{state:e,actions:t});case`loading`:return(0,Y.jsx)(at,{step:e.step,url:n});case`worktree-removed`:return(0,Y.jsx)(ot,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,Y.jsx)(st,{actions:t});case`taken-over`:return(0,Y.jsx)(lt,{state:e,actions:t})}}function X({icon:e,title:t,children:n,state:r}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":r,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:e}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Z=({children:e})=>(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),Q=({children:e})=>(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function Ve({server:e}){return(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(ce,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Runs ${N(e.command)} in this task's worktree, on the host.`})]})}function He({copy:e,command:t,label:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-3 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:[(0,Y.jsx)(`span`,{children:n}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,className:`-m-2 inline-flex size-11 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:size-6`,onClick:()=>e(t),children:(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":`true`})})]}),(0,Y.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function Ue({server:e,status:t}){return(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,Y.jsx)(F,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,Y.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,Y.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,Y.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,Y.jsx)(`span`,{children:`cwd`}),(0,Y.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,Y.jsx)(`div`,{className:`mt-2.5`,children:(0,Y.jsx)(Ve,{server:e})})]})}function We({state:e,actions:r}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(z,{}),title:`This host has no browser yet`,children:[(0,Y.jsx)(Z,{children:e.canDownload?`Preview runs Chromium on the machine ${t(`cezar`)} runs on. ${t(`cezar`)} can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine ${t(`cezar`)} runs on. ${t(`cezar`)} has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:r.download,children:[(0,Y.jsx)(z,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,Y.jsx)(He,{command:e.installCommand,copy:r.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function Ge(e){return Math.round(e/1e6)}function Ke({state:e,actions:t}){let r=(0,J.useRef)(null);r.current??={at:Date.now(),received:e.received};let i=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,a=(Date.now()-r.current.at)/1e3,o=a>=1?(e.received-r.current.received)/a:0,s=o>0?Math.ceil((e.total-e.received)/o):void 0;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(z,{}),title:`Downloading Chromium`,children:[(0,Y.jsx)(Z,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${i}%`}})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:`${Ge(e.received)} of ${Ge(e.total)} MB · ${i}%`}),s===void 0?null:(0,Y.jsx)(`span`,{children:`about ${s} s left`})]})]}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function qe({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(Ee,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,Y.jsx)(Z,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,Y.jsx)(He,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Retry download`]}),(0,Y.jsxs)(n,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function Je({state:e,actions:r}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(we,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,Y.jsxs)(Z,{children:[`The host blocks the sandbox Chromium needs. This usually means `,t(`cezar`),` runs as root, or inside a container without user namespaces.`]}),(0,Y.jsx)(Pe,{text:e.stderrTail,source:`chromium`,onCopy:r.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:r.retryBrowser,children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(n,{variant:`outline`,onClick:()=>r.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,Y.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:ze,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function Ye({state:e,actions:t}){let r=e.reason===`timeout`,i=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,a=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,o=r?`Chromium did not start in time`:`Chromium exited${i}`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(p,{className:`text-danger`}),title:r?`The browser did not start`:`The browser stopped`,children:[(0,Y.jsx)(Z,{children:r?`Chromium did not open its DevTools port in time. ${a}`:`Chromium exited unexpectedly${i}. ${a}`}),(0,Y.jsx)(Pe,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(n,{variant:`outline`,onClick:()=>t.copy(`${o}\n${e.stderrTail}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Xe=2;function Ze(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Qe({state:e,actions:r}){let{server:i,wasRunning:a}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:a?(0,Y.jsx)(De,{className:`text-pending-strong`}):(0,Y.jsx)(v,{}),title:a?`Nothing answers on :${i.port} anymore`:`${i.label} isn't running yet`,children:[(0,Y.jsx)(Z,{children:a?`${i.label} was running when the agent registered it, likely inside the agent's own session, which has ended. ${t(`cezar`)} can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,Y.jsx)(Ue,{server:i,status:a?`was running when registered · silent now`:`registered · not started`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:()=>r.run(i.port),children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Run and open`]})})]})}function $e({state:e,actions:t}){let{server:r,ownerTitle:i}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(Ee,{className:`text-pending-strong`}),title:`${r.label} :${r.port} is in use by another task`,children:[(0,Y.jsx)(Z,{children:`Task "${i}" is running its own server on :${r.port}. Register a different port for this task, or stop that task's server.`}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function et({state:e,actions:r}){let{server:i}=e,a=Ze(1e3),o=Math.max(0,Math.floor((a-Date.parse(e.startedAt))/1e3)),[s,c]=(0,J.useState)(()=>Date.now());(0,J.useEffect)(()=>c(Date.now()),[e.attempt]);let l=Math.max(0,Math.ceil(Xe-(a-s)/1e3));return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(v,{}),title:`Starting ${i.label}`,children:[(0,Y.jsx)(Z,{children:`${t(`cezar`)} ran ${N(i.command)} in the worktree. The page opens as soon as :${i.port} answers.`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,Y.jsx)(_,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),l>0?`Attempt ${e.attempt} · next try in ${l} s`:`Attempt ${e.attempt}`]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${o} s ago`})]}),e.logTail.length>0?(0,Y.jsx)(Pe,{text:e.logTail.join(`
|
|
3
|
-
`),source:N(i.command),onCopy:r.copy}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`outline`,onClick:()=>r.stop(i.port),children:`Stop server`})})]})}function tt({state:e,actions:t}){let{server:r}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(h,{className:`text-pending-strong`}),title:`${r.label} is running, but :${r.port} is silent`,children:[(0,Y.jsx)(Z,{children:`The process has run for 2 min without opening the port. It may be waiting on another service, or listening somewhere else.`}),(0,Y.jsx)(Pe,{text:e.logTail,source:N(r.command),onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(n,{variant:`contrast`,onClick:()=>t.keepWaiting(r.port),children:`Keep waiting`}),(0,Y.jsx)(n,{variant:`outline`,onClick:()=>t.stop(r.port),children:`Stop server`})]})]})}function nt({state:e,actions:t}){let{server:r}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(p,{className:`text-danger`}),title:e.exitCode===null?`${r.label} was stopped by a signal`:`${r.label} exited with code ${e.exitCode}`,children:[(0,Y.jsx)(Z,{children:`${N(r.command)} stopped.`}),(0,Y.jsx)(Pe,{text:e.logTail,source:N(r.command),onCopy:t.copy}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:()=>t.run(r.port),children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Ve,{server:r})]})}function rt({state:e,actions:r}){let{server:i}=e,a=e.reason===`idle`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(de,{}),title:a?`Stopped after 15 min idle`:`${i.label} stopped`,children:[(0,Y.jsx)(Z,{children:a?`Nobody had this pane open for 15 min, so ${t(`cezar`)} stopped ${i.label} :${i.port} and the browser to free memory. Start again reopens ${Re(e.lastUrl)}.`:`You stopped ${i.label} :${i.port}. Start again reopens ${Re(e.lastUrl)}.`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:()=>r.run(i.port),children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Ve,{server:i})]})}var it=[`browser`,`page`,`frame`];function at({step:e,url:t}){let n=it.indexOf(e),i=t?Re(t):`the page`;return(0,Y.jsx)(`div`,{"data-slot":`preview-state`,"data-state":`loading`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center px-6 py-8`,children:(0,Y.jsx)(`ol`,{"aria-label":`Opening the page`,className:`mx-auto flex flex-col gap-4 text-sm`,children:[{done:`Browser started`,active:`Starting the browser`},{done:`Opened ${i}`,active:`Opening ${i}`},{done:`First frame`,active:`First frame`}].map((e,t)=>{let i=t<n,a=t===n;return(0,Y.jsxs)(`li`,{"aria-current":a?`step`:void 0,className:r(`flex items-center gap-3`,a?`font-semibold text-foreground`:i?`text-foreground`:`text-soft-foreground`),children:[i?(0,Y.jsx)(m,{className:`size-5 text-success`,"aria-hidden":`true`}):a?(0,Y.jsx)(_,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,Y.jsx)(R,{className:`size-5 text-border`,"aria-hidden":`true`}),i?e.done:a?e.active:e.done]},t)})})})}function ot({state:e,actions:t,worktree:r}){let i=r?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(r)?.[0]:void 0,a=e.server?.label;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(V,{}),title:`This task's worktree is gone`,children:[(0,Y.jsx)(Z,{children:`${a??`The server`} ran in ${i??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,Y.jsx)(ee,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function st({actions:e}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":`proxy-blocked`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Ne,{})}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,Y.jsx)(G,{})}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,Y.jsxs)(Z,{children:[`The proxy in front of `,t(`cezar`),` didn't let the preview's WebSocket through. This is a known gap behind Basic Auth. Everything else in `,t(`cezar`),` keeps working.`]}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(n,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,Y.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:ze,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function ct(e){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Windows/.test(e)?`Windows`:/Mac OS X|Macintosh/.test(e)?`Mac`:/Linux|X11/.test(e)?`Linux`:``,n=/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n&&t?`${n} on ${t}`:n||t}function lt({state:e,actions:t}){let r=ct(e.by);return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(W,{}),title:`Preview is open somewhere else`,children:[(0,Y.jsx)(Z,{children:`Another tab took this browser${r?` (${r})`:``}. Only one tab can view and drive it at a time.`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:t.useHere,children:[(0,Y.jsx)(z,{"aria-hidden":`true`}),`Use it here`]}),(0,Y.jsx)(n,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function ut({attempt:e,exhausted:t,onReconnect:r}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-connection-banner`,role:`status`,className:`absolute inset-x-3 top-3 z-10 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-3.5 py-2.5 text-sm shadow-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(Oe,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,Y.jsx)(n,{variant:`outline`,onClick:r,children:t?`Reconnect`:`Reconnect now`})]})}function dt({servers:e,states:t,onOpen:r,agentLive:i=!1,agentIdle:a=!1,onOpenAgent:o}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":a?`agent-idle`:`empty`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,Y.jsx)(Z,{children:`The browser runs on the host, next to the worktree. Type a URL, a bare port such as 3000, or open a server the agent registered.`}),a?(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,Y.jsx)(De,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,i&&o!==void 0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-agent`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Driven by the agent`}),(0,Y.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(F,{tone:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,Y.jsx)(n,{variant:`outline`,size:`sm`,className:`max-md:h-11`,"aria-label":`Open the agent's page`,onClick:o,children:`Open`})]})]}):null,e.length>0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-registered`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Registered in this task`}),(0,Y.jsx)(`ul`,{children:e.map(e=>{let i=he(e,t),a=ue(i);return(0,Y.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border px-3.5 py-2 text-sm last:border-b-0`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(F,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:a.text})]}),(0,Y.jsx)(n,{variant:`outline`,size:`sm`,className:`max-md:h-11`,onClick:()=>r(e.port),children:fe(i)?`Open`:`Review`})]},e.port)})})]}):null,(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(g,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Review opens a server's approval in this pane: its command, cwd and Run and open. Nothing runs from this list. Paste works; copying text out, file pickers and downloads don't yet.`})]})]})}function ft({dialog:e,onResult:t}){let[r,i]=(0,J.useState)(e.defaultPrompt??``),a=e.type===`beforeunload`,o=(0,J.useRef)(null),s=(0,J.useRef)(null);(0,J.useEffect)(()=>{(e.type===`prompt`?s.current:o.current)?.focus()},[e.type]);let c=(0,J.useRef)(t);c.current=t,(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target instanceof Element?e.target:null;t&&t!==document.body&&!t.closest(`[data-slot="preview-pane-body"], [data-slot="preview-page-dialog"]`)||(e.stopPropagation(),c.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let l=()=>t(e.type===`prompt`?{accept:!0,text:r}:{accept:!0});return(0,Y.jsx)(`div`,{"data-slot":`preview-page-dialog`,className:`absolute inset-0 z-20 flex items-center justify-center bg-foreground/30 p-4`,children:(0,Y.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`${e.origin} says`,className:`w-full max-w-[380px] rounded-xl border border-border bg-card p-4 shadow-lg`,children:[(0,Y.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,Y.jsx)(`p`,{className:`mb-4 text-sm break-words whitespace-pre-wrap text-foreground`,children:e.message||(a?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,Y.jsx)(`input`,{ref:s,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l()},className:`mb-4 h-11 w-full rounded-md border border-border bg-background px-3 text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,Y.jsx)(n,{variant:`outline`,onClick:()=>t({accept:!1}),children:a?`Stay`:`Cancel`}),(0,Y.jsx)(n,{ref:o,variant:`contrast`,onClick:l,children:a?`Leave`:`OK`})]})]})})}var pt=10,mt=500,ht=500,gt=4,_t=16,vt=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function yt(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function bt(e,t){return{rect:e,scale:t,touches:new Map,multiTouch:!1,click:{at:-1/0,x:0,y:0,button:-1,count:1}}}var xt=[`left`,`middle`,`right`];function $(e,t,n,r){let i=yt(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:xt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:vt(n),...r}}var St=e=>e===0?0:-e;function Ct(e,t,n,r,i){let a=yt(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:St(r/e.scale),deltaY:St(i/e.scale),modifiers:0}}function wt(e,t){let{touches:n}=t,r=n.get(e.pointerId),i=()=>{n.delete(e.pointerId),n.size===0&&(t.multiTouch=!1)};switch(e.type){case`pointerdown`:return n.set(e.pointerId,{startX:e.clientX,startY:e.clientY,startAt:e.timeStamp,lastX:e.clientX,lastY:e.clientY,scrolling:!1}),n.size>1&&(t.multiTouch=!0),[];case`pointermove`:{if(!r)return[];if(t.multiTouch)return r.lastX=e.clientX,r.lastY=e.clientY,[];if(!r.scrolling){if(Math.hypot(e.clientX-r.startX,e.clientY-r.startY)<=pt)return[];r.scrolling=!0}let n=e.clientX-r.lastX,i=e.clientY-r.lastY;return r.lastX=e.clientX,r.lastY=e.clientY,n===0&&i===0?[]:[Ct(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=mt;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[$(`mouseMoved`,t,a,{button:`none`,buttons:0}),$(`mousePressed`,t,a,{button:`left`,buttons:1}),$(`mouseReleased`,t,a,{button:`left`,buttons:0})]}case`pointercancel`:return i(),[]}}function Tt(e,t){if(e.pointerType===`touch`)return wt(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=ht&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=gt;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[$(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[$(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[$(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Et(e,t,n){let r=yt(e.clientX,e.clientY,t,n),i=e.deltaMode===1?_t:1;return{t:`mouse`,type:`mouseWheel`,x:r.x,y:r.y,button:`none`,buttons:e.buttons??0,deltaX:e.deltaX*i/n,deltaY:e.deltaY*i/n,modifiers:vt(e)}}var Dt={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Ot(e){let t=e.key.toLowerCase(),n=(e.ctrlKey||e.metaKey)&&!e.getModifierState?.(`AltGraph`);if(n&&(t===`v`||t===`k`))return;let r={t:`key`,key:e.key,code:e.code,modifiers:vt(e),vk:e.keyCode};if(e.type===`keyup`)return{...r,type:`keyUp`};let i=n?``:e.key.length===1?e.key:e.key===`Enter`?`\r`:e.key===`Tab`?` `:``,a=n?t===`z`&&e.shiftKey?`redo`:Dt[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:vt(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function kt(e){return e?{t:`insertText`,text:e}:void 0}var At=e=>e,jt=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function Mt({scale:e,send:t,onLeave:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(bt({left:0,top:0},e)),a=(0,J.useRef)(e);a.current=e;let o=(0,J.useRef)(t);o.current=t;let s=(0,J.useRef)(void 0),c=()=>{let e=r.current;e&&(i.current.rect=e.getBoundingClientRect()),i.current.scale=a.current},l=e=>{c();for(let t of Tt(At(e),i.current))o.current(t)},u=()=>{let e=s.current;e&&(s.current=void 0,cancelAnimationFrame(e.frame),l(e.event))};(0,J.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,J.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,J.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{e.preventDefault(),c(),o.current(Et(e,i.current.rect,i.current.scale))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,J.useEffect)(()=>{let e=e=>{if(document.activeElement!==r.current)return;let t=kt(e.clipboardData?.getData(`text`)??``);t&&(e.preventDefault(),o.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[]);let d=e=>{u(),r.current?.focus({preventScroll:!0});try{r.current?.setPointerCapture(e.pointerId)}catch{}l(e.nativeEvent)},f=e=>{let t=e.nativeEvent;if(t.pointerType===`touch`)return l(t);let n=s.current;if(n){n.event=t;return}s.current={event:t,frame:requestAnimationFrame(()=>{let e=s.current;s.current=void 0,e&&l(e.event)})}},p=e=>{u(),l(e.nativeEvent)},m=e=>{if(jt(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Ot(e.nativeEvent);i&&(e.preventDefault(),e.stopPropagation(),t(i))};return(0,Y.jsx)(`div`,{ref:r,"data-slot":`preview-input`,role:`application`,"aria-label":`Page preview, interactive`,"aria-description":`Keys go to the page, Tab included. Press Shift+Escape to return to the cockpit.`,tabIndex:0,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onContextMenu:e=>e.preventDefault(),onKeyDown:m,onKeyUp:m,className:`absolute inset-0 touch-none select-none outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset`})}async function Nt(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,release:()=>t.close()}}let t=URL.createObjectURL(e),n=new Image;return n.src=t,await n.decode(),{source:n,width:n.naturalWidth,height:n.naturalHeight,release:()=>URL.revokeObjectURL(t)}}function Pt({ref:e,viewport:t,dimmed:n=!1,cursor:i,onSize:a,renderInput:o,children:s}){let c=(0,J.useRef)(0),u=(0,J.useRef)(null),d=(0,J.useRef)(null),[f,p]=(0,J.useState)(null),m=(0,J.useRef)(a);m.current=a,(0,J.useImperativeHandle)(e,()=>({async draw(e){let t=++c.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!l()))try{let i=await Nt(e);try{if(t!==c.current||!l()||d.current!==n)return;n.width!==i.width&&(n.width=i.width),n.height!==i.height&&(n.height=i.height),r.drawImage(i.source,0,0)}finally{i.release()}}catch{}}}),[]),(0,J.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{let t=Math.round(e.clientWidth),n=Math.round(e.clientHeight);t===0||n===0||(p(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n}),m.current?.({w:t,h:n}))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let h=t===`fit`?f:t,g=t===`fit`||!f?1:Math.min(1,(f.w-24)/t.w,(f.h-24)/t.h),_=h?{width:Math.floor(h.w*g),height:Math.floor(h.h*g)}:void 0;return(0,Y.jsxs)(`div`,{ref:u,"data-slot":`preview-stage`,"data-viewport":t===`fit`?`fit`:`${t.w}x${t.h}`,className:r(`relative min-h-0 flex-1 overflow-hidden bg-muted`,t!==`fit`&&`flex items-start justify-center overflow-auto p-3`),children:[h?(0,Y.jsxs)(`div`,{"data-slot":`preview-surface`,"data-scale":g,style:{..._,cursor:i},className:r(`relative shrink-0 bg-card`,t!==`fit`&&`shadow-md`,n&&`opacity-60 saturate-50`),children:[(0,Y.jsx)(`canvas`,{ref:d,"aria-label":`Page preview`,role:`img`,style:_,className:`block touch-none select-none`}),o?.({canvas:d.current,scale:g,viewport:h})]}):null,s]})}var Ft=`cez-preview-quality`,It=[{value:`normal`,label:`Normal`,detail:`The default. Lighter on CPU and network.`},{value:`high`,label:`High`,detail:`Sharper text and fine detail. Uses more CPU and network.`},{value:`ultra`,label:`Ultra`,detail:`High at your screen's pixel density, up to 2×. Uses the most CPU and network.`}];function Lt(e){return It.find(t=>t.value===e)?.value??`normal`}var Rt=e=>It.find(t=>t.value===e)?.label??`Normal`;function zt(){try{return Lt(localStorage.getItem(Ft))}catch{return`normal`}}function Bt(e){try{localStorage.setItem(Ft,e)}catch{}}var Vt=[{w:390,h:844,icon:ve},{w:820,h:1180,icon:Te},{w:1440,h:900,icon:ae}],Ht=`size-8 shrink-0 max-md:size-11`,Ut=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Wt(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Gt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Kt({stats:e,shrunk:t}){let n=Wt(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,Y.jsx)(F,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,Y.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Gt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(F,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Gt(e)})]})}function qt({current:e,agentShown:t,...r}){let i=e?e.label:t?`Agent's page`:`Server`;return(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`max-w-[11rem] min-w-0 gap-1.5 max-md:h-11`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${i}`:`Server`,...r,children:[e||t?(0,Y.jsx)(F,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,Y.jsx)(x,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:i}),e?(0,Y.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,Y.jsx)(ge,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function Jt({shown:e,live:t,onSelect:n}){return(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,Y.jsx)(F,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,Y.jsx)(P,{className:`size-4`,"aria-hidden":`true`}):null]})}function Yt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Xt(e){let t=e.onPickAgent!==void 0,n=e.agentLive===!0&&t,r=e.agentShown===!0;return{agentLive:n,agentShown:r,agentListed:n||r&&t}}function Zt(e){let{compact:t=!1,navEnabled:r,loading:i=!1}=e,a=(0,J.useRef)(null),o=e.urlInputRef??a,s=(0,J.useRef)(!1),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1),p=(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Back`,disabled:!r,onClick:e.onBack,children:(0,Y.jsx)(xe,{"aria-hidden":`true`})}),m=(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Forward`,disabled:!r,onClick:e.onForward,children:(0,Y.jsx)(f,{"aria-hidden":`true`})}),h=(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Reload`,"aria-busy":i||void 0,disabled:!r||i,onClick:()=>e.onReload(!1),children:(0,Y.jsx)(q,{"aria-hidden":`true`})}),g=e.onSession?(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1 max-md:h-11`,onClick:e.onSession,children:[(0,Y.jsx)(pe,{"aria-hidden":`true`}),`Session`]}):null,_=i?(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Loading the page`,className:`absolute inset-x-0 bottom-0 h-0.5 overflow-hidden bg-transparent`,children:(0,Y.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,v=(0,Y.jsx)($t,{props:e,input:o,draft:c,setDraft:l,focused:u,setFocused:d}),{agentListed:y}=Xt(e),ee=e.servers.length+ +!!y>=2,b=ee||e.adopted,x={back:p,forward:m,reload:h,address:v,more:(0,Y.jsx)(an,{props:e,compact:t,crowded:b}),session:g,progress:_};return t?(0,Y.jsx)(on,{props:e,elements:x}):(0,Y.jsx)(sn,{props:e,elements:x,switcher:ee,crowded:b,input:o,focusUrlAfterMenu:s})}function Qt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Xt(e);return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsx)(qt,{current:i,agentShown:o})}),(0,Y.jsxs)(D,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,Y.jsx)(Jt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=ue(he(t,e.serverStates));return(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":i?.port===t.port||void 0,onSelect:()=>e.onPickServer(t.port),children:[(0,Y.jsx)(F,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,Y.jsx)(P,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,Y.jsx)(T,{}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,Y.jsx)(_e,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function $t({props:e,input:n,draft:i,setDraft:a,focused:o,setFocused:s}){let{url:c,adopted:l}=e;return(0,Y.jsxs)(`div`,{className:`relative flex min-w-[9rem] flex-1 items-center`,children:[(0,Y.jsx)(_e,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{ref:n,type:`text`,"aria-label":`Page address`,placeholder:`Type a URL or a port`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:i??(o?c:Re(c)),title:c||void 0,className:r(`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-muted pl-8 font-mono text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:bg-background focus-visible:ring-[3px] focus-visible:ring-ring/30 max-md:h-11`,l?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;s(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{s(!1),a(null)},onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(i??c),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),l&&!o?(0,Y.jsxs)(`span`,{className:`pointer-events-none absolute right-2 inline-flex h-6 items-center gap-1 rounded-full border border-border bg-card px-2 text-xs font-semibold text-muted-foreground`,children:[(0,Y.jsx)(Ce,{className:`size-3`,"aria-hidden":`true`}),`Not started by `,t(`cezar`)]}):null]})}function en({props:e}){let{viewport:t}=e;return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ut(t)}`,children:[t===`fit`?(0,Y.jsx)(U,{"aria-hidden":`true`}):(0,Y.jsx)(ae,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:r(`hidden @min-[500px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ut(t)}),(0,Y.jsx)(ge,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(D,{align:`start`,className:`min-w-56`,children:[(0,Y.jsxs)(w,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,Y.jsx)(U,{"aria-hidden":`true`}),`Fit`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,Y.jsx)(P,{className:`size-4`,"aria-hidden":`true`}):null]}),Vt.map(({w:n,h:r,icon:i})=>(0,Y.jsxs)(w,{className:`gap-2.5 font-mono`,"aria-current":t!==`fit`&&t.w===n&&t.h===r||void 0,onSelect:()=>e.onViewport({w:n,h:r}),children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,Y.jsx)(P,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function tn({quality:e,onQuality:t,compact:n}){return(0,Y.jsx)(O,{value:e,onValueChange:e=>t(Lt(e)),children:It.map(e=>(0,Y.jsx)(C,{value:e.value,"data-quality":e.value,className:r(`items-start`,n&&`min-h-11`),children:(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function nn({props:e}){let{quality:t}=e;return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Rt(t)}`,children:[(0,Y.jsx)(Se,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[560px]:inline`,children:Rt(t)}),(0,Y.jsx)(ge,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(D,{align:`start`,className:`w-64`,children:[(0,Y.jsx)(S,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(tn,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function rn({stats:e,status:t,crowded:n}){return e?(0,Y.jsx)(Kt,{stats:e,shrunk:n}):t?(0,Y.jsxs)(`span`,{"data-slot":`preview-status`,className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(F,{tone:t.tone,"aria-hidden":`true`}),t.label]}):null}function an({props:e,compact:r,crowded:i}){let{stats:a,navEnabled:o,url:s,current:c,adopted:l}=e;return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`More`,children:(0,Y.jsx)(I,{"aria-hidden":`true`})})}),(0,Y.jsxs)(D,{align:`end`,className:`min-w-64`,children:[i&&a&&!r?(0,Y.jsx)(S,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Gt(a)}):null,(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!o,onSelect:()=>e.onReload(!0),children:[(0,Y.jsx)(K,{"aria-hidden":`true`}),`Reload without cache`]}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:s===``,onSelect:e.onCopyUrl,children:[(0,Y.jsx)(me,{"aria-hidden":`true`}),`Copy page URL`]}),c?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{}),l?(0,Y.jsxs)(w,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,Y.jsx)(H,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${c.label} :${c.port}`}),(0,Y.jsxs)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:[t(`cezar`),` didn't start this server, so it won't stop it. Stop it where it was started.`]})]})]}):(0,Y.jsxs)(w,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(c.port),children:[(0,Y.jsx)(L,{"aria-hidden":`true`}),`Stop server · ${c.label} :${c.port}`]})]}):null,r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{}),(0,Y.jsx)(S,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(tn,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,Y.jsx)(T,{}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,Y.jsx)(A,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function on({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Xt(e),{back:o,forward:s,reload:c,address:l,more:u,session:d,progress:f}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,Y.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,Y.jsx)(F,{tone:`success`,"aria-hidden":`true`}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:Yt(r,a)})]}),i?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[o,s,c,l]}),f]})}function sn({props:e,elements:t,switcher:r,crowded:i,input:a,focusUrlAfterMenu:o}){let{badge:s=!0,stats:c,status:l}=e,{back:u,forward:d,reload:f,address:p,more:m,session:h,progress:g}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1.5 border-b border-border bg-background px-2.5 py-2`,children:[h,u,d,f,r?(0,Y.jsx)(Qt,{props:e,input:a,focusUrlAfterMenu:o}):null,p,(0,Y.jsx)(en,{props:e}),(0,Y.jsx)(nn,{props:e}),(0,Y.jsx)(rn,{stats:c,status:l,crowded:i}),s?(0,Y.jsx)(Ne,{iconOnly:i,responsive:!i}):null,(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),m,(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Close preview`,onClick:e.onClose,children:(0,Y.jsx)(A,{"aria-hidden":`true`})}),g]})}function cn({transport:e,takenOver:t,empty:n,stage:r,hasFrame:i,lost:a,url:o,worktree:s}){let c=a||e!==`blocked`&&t!==void 0;return e===`blocked`?{content:{kind:`state`,state:{stage:`proxy-blocked`}},dim:c}:t===void 0?n||r?.stage===`agent-idle`?{content:{kind:`empty`,agentIdle:!n&&r?.stage===`agent-idle`},dim:c}:r?.stage===`streaming`||r?.stage===`loading`&&i?{content:{kind:`none`},dim:c}:r?{content:{kind:`state`,state:r,url:o,worktree:s},dim:c}:a?{content:{kind:`none`},dim:c}:{content:{kind:`state`,state:{t:`state`,stage:`loading`,step:`browser`},url:o},dim:c}:{content:{kind:`state`,state:{stage:`taken-over`,by:t}},dim:c}}function ln(e,{servers:t,serverStates:n,agentLive:r,openServer:i,openAgent:a,actions:o}){switch(e.kind){case`none`:return null;case`state`:{let{kind:t,...n}=e;return(0,Y.jsx)(Be,{...n,actions:o})}case`empty`:return(0,Y.jsx)(dt,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function un(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function dn(){let[e,t]=(0,J.useState)(un);return(0,J.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(un());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var fn=2e3,pn=500,mn=1e3;function hn(e,t){switch(e.stage){case`needs-approval`:case`port-held`:case`server-starting`:case`server-stalled`:case`server-exited`:case`server-stopped`:return e.server.port===t;case`loading`:case`streaming`:return!0;default:return!1}}function gn(e){navigator.clipboard?.writeText(e).then(()=>u(`Copied`),()=>u(`Couldn't copy to the clipboard`,{tone:`danger`}))}var _n=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function vn(e,t){return e?.port===void 0?e?.agent===!0||e?.url!==void 0:e.restored!==!0||t.some(t=>t.port===e.port)}function yn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function bn({run:e,servers:t,request:n,onTarget:r,onLive:i,onClose:a}){let o=dn(),s=(0,J.useRef)(o);s.current=o;let u=c(),d=(0,J.useRef)(crypto.randomUUID()),f=(0,J.useRef)(!1),p=te(),m=oe(be,!1),[h,g]=(0,J.useState)(0),[_,v]=(0,J.useState)({state:`connecting`,attempt:0}),[y,ee]=(0,J.useState)(!1),[b,x]=(0,J.useState)(void 0),[S,C]=(0,J.useState)(void 0),[w,T]=(0,J.useState)(``),[E,D]=(0,J.useState)(void 0),[O,k]=(0,J.useState)(!1),[A,j]=(0,J.useState)(void 0),[ne,re]=(0,J.useState)(!1),[ie,ae]=(0,J.useState)(!1),[se,M]=(0,J.useState)(void 0),[ce,le]=(0,J.useState)(void 0),[ue,N]=(0,J.useState)(void 0),[P,de]=(0,J.useState)(`fit`),[fe,pe]=(0,J.useState)(zt),[me,he]=(0,J.useState)(null),[ge,F]=(0,J.useState)(void 0),[_e,ve]=(0,J.useState)(0),I=(0,J.useRef)(void 0),ye=(0,J.useRef)(null),xe=(0,J.useRef)(null),L=(0,J.useRef)(void 0),R=(0,J.useRef)(void 0),z=(0,J.useRef)(fe);z.current=fe;let B=(0,J.useRef)({port:E,stage:S,agent:O});B.current={port:E,stage:S,agent:O};let V=(0,J.useRef)([]),Se=(0,J.useRef)(void 0),Ce=(0,J.useRef)(!1),H=(0,J.useRef)(!1),U=(0,J.useCallback)(e=>{H.current&&I.current?.send(e)},[]);(0,J.useEffect)(()=>{let t;return t=Me({projectId:p??`default`,runId:e.id},{onFrame(e){if(!l())return;let n=Date.now();V.current.push({at:n,bytes:e.size}),Ce.current||(Ce.current=!0,ae(!0)),(ye.current?.draw(e)??Promise.resolve()).finally(()=>t?.send({t:`ack`}))},onMessage(e){switch(e.t){case`state`:if(C(e),(e.stage===`streaming`||e.stage===`loading`)&&ve(e=>e+1),R.current!==void 0&&hn(e,R.current)){let n=R.current;R.current=void 0,(e.stage===`needs-approval`||e.stage===`server-exited`||e.stage===`server-stopped`)&&t?.send({t:`run`,port:n})}return;case`url`:return T(e.url);case`cursor`:return M(e.cursor);case`dialog`:return le(e);case`pong`:Se.current=Math.max(0,Date.now()-e.ts);return;case`downloadProgress`:C(t=>t?.stage===`downloading`?{...t,received:e.received,total:e.total}:t);return;case`replaced`:x(e.by),H.current=!1,t?.close();return}},onTransport(e,n){H.current=e===`open`,v({state:e,attempt:n??0}),e===`open`&&(ee(!0),L.current&&(t?.send({t:`open`,target:L.current,viewerId:d.current,resume:f.current,quality:z.current,dpr:s.current}),f.current=!0))}}),I.current=t,()=>{H.current=!1,t?.close(),I.current===t&&(I.current=void 0)}},[p,e.id,h]);let W=u&&_.state===`open`&&b===void 0,G=m||P===`fit`?me:P;(0,J.useEffect)(()=>{G&&W&&(S?.stage===`streaming`||S?.stage===`loading`)&&U({t:`resize`,w:G.w,h:G.h,...o===1?{}:{dpr:o}})},[G?.w,G?.h,o,W,S?.stage,_e,U]),(0,J.useEffect)(()=>{if(!W)return;let e=setInterval(()=>U({t:`ping`,ts:Date.now()}),fn);return()=>clearInterval(e)},[W,U]);let K=W&&S?.stage===`streaming`;(0,J.useEffect)(()=>{if(!K){N(void 0);return}let e=setInterval(()=>{let e=Date.now();V.current=V.current.filter(t=>e-t.at<=mn);let t={fps:V.current.length,kbps:Math.round(V.current.reduce((e,t)=>e+t.bytes,0)/1024),...Se.current===void 0?{}:{rttMs:Se.current},...V.current.length>0?{lastFrameAt:V.current.at(-1).at}:{}};N(e=>{let n=t.lastFrameAt??e?.lastFrameAt,r={...t,...n===void 0?{}:{lastFrameAt:n}};return e&&e.fps===r.fps&&e.kbps===r.kbps&&e.rttMs===r.rttMs&&e.lastFrameAt===r.lastFrameAt?e:r})},pn);return()=>clearInterval(e)},[K]),(0,J.useEffect)(()=>(i?.(K),()=>i?.(!1)),[K,i]),(0,J.useEffect)(()=>{A&&r?.(A)},[A,r]);let q=(0,J.useCallback)((e,t,n=!1)=>{L.current=e,R.current=n&&`port`in e?e.port:void 0,re(!0),C(void 0),x(void 0),F(void 0),T(t),D(`port`in e?e.port:void 0),k(`agent`in e),j(yn(e)),U({t:`open`,target:e,viewerId:d.current,quality:z.current,dpr:s.current}),f.current=H.current},[U]),we=(0,J.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);q({port:e},r?_n(r):`http://localhost:${e}`,n)},[t,q]),Te=(0,J.useCallback)(()=>q({agent:!0},``),[q]);(0,J.useEffect)(()=>{if(n?.agent){if(B.current.agent&&B.current.stage?.stage===`streaming`)return;Te();return}if(n?.url!==void 0){let e=Ie(n.url,t);e.kind===`server`?we(e.port):e.kind===`url`&&q({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||B.current.port===n.port&&B.current.stage?.stage===`streaming`&&n.run!==!0||we(n.port,n.run===!0))},[n]);let Ee=!ne&&!b&&_.state!==`blocked`,De=vn(n,t);(0,J.useEffect)(()=>{Ee&&!De&&xe.current?.focus()},[Ee,De]);let Oe=e=>{let n=Ie(e,t);if(n.kind===`error`)return F(n.message);if(n.kind===`server`)return we(n.port);if(B.current.stage?.stage===`streaming`&&!B.current.agent)return L.current={url:n.url},R.current=void 0,D(void 0),j({url:n.url}),F(void 0),T(n.url),U({t:`nav`,url:n.url});q({url:n.url},n.url)},ke=(0,J.useCallback)(e=>{z.current=e,pe(e),Bt(e),U({t:`quality`,quality:e})},[U]),Ae=()=>{f.current=!1,x(void 0),v({state:`connecting`,attempt:0}),Ce.current=!1,g(e=>e+1)};return{compact:m,transport:_,everOpened:y,takenOver:b,stage:S,url:w,port:E,agent:O,hasFrame:ie,cursor:se,dialog:ce,setDialog:le,stats:ue,viewport:P,setViewport:de,quality:fe,chooseQuality:ke,setStageSize:he,addressError:ge,stageHandle:ye,urlInput:xe,send:U,connected:W,streaming:K,openServer:we,openAgent:Te,empty:Ee,navigate:Oe,reconnect:Ae,actions:(0,J.useMemo)(()=>({download:()=>U({t:`download`}),cancelDownload:()=>U({t:`cancelDownload`}),retryBrowser:()=>U({t:`retryBrowser`}),run:e=>U({t:`run`,port:e}),stop:e=>U({t:`stop`,port:e}),keepWaiting:e=>U({t:`keepWaiting`,port:e}),close:a,useHere:Ae,copy:gn}),[U,a])}}function xn(e){return(0,Y.jsx)(ye,{onClose:e.onClose,children:(0,Y.jsx)(wn,{...e})})}function Sn(e,t,n,r){return e.state===`blocked`?{tone:`neutral`,label:`not supported`}:n?{tone:`neutral`,label:`paused`}:t&&(e.state===`reconnecting`||e.state===`closed`)?{tone:`danger`,label:`offline`}:e.state===`open`?r?Cn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Cn(e){switch(e.stage){case`downloading`:return{tone:`pending`,label:`downloading`};case`download-failed`:return{tone:`danger`,label:`download failed`};case`sandbox-failed`:return{tone:`danger`,label:`browser failed`};case`browser-exited`:return{tone:`danger`,label:e.reason===`timeout`?`browser timed out`:`browser exited`};case`needs-approval`:return{tone:`neutral`,label:`not started`};case`port-held`:return{tone:`danger`,label:`port in use`};case`server-starting`:return{tone:`pending`,label:`waiting for :${e.server.port}`};case`server-stalled`:return{tone:`pending`,label:`waiting · 2 min`};case`server-exited`:return{tone:`danger`,label:`server exited`};case`server-stopped`:return{tone:`neutral`,label:`stopped`};case`agent-idle`:return{tone:`neutral`,label:`agent idle`};case`loading`:return{tone:`neutral`,label:`connecting…`};default:return}}function wn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=bn(e),{compact:c,transport:l,everOpened:u,takenOver:d,stage:f,url:p,port:m,agent:h,hasFrame:g,stats:_,viewport:v,setViewport:y,quality:ee,chooseQuality:b,addressError:x,urlInput:S,send:C,streaming:w,openServer:T,openAgent:E,empty:D,navigate:O,actions:k}=s,te=n.find(e=>e.port===m),A=f?.stage===`streaming`&&f.adopted,j=u&&(l.state===`reconnecting`||l.state===`closed`),{content:ne,dim:re}=cn({transport:l.state,takenOver:d,empty:D,stage:f,hasFrame:g,lost:j,url:p,worktree:t.worktreePath}),ie=ln(ne,{servers:n,serverStates:r,agentLive:i,openServer:T,openAgent:E,actions:k});return(0,Y.jsxs)(`section`,{"data-slot":`preview-pane-body`,"aria-label":`Live preview`,className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,Y.jsx)(Zt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:te,agentLive:i===!0,agentShown:h,adopted:A,viewport:c?`fit`:v,quality:ee,compact:c,navEnabled:w,loading:f?.stage===`loading`,stats:w?_??{fps:0,kbps:0}:void 0,status:w?void 0:Sn(l,u,d!==void 0,f),urlInputRef:S,onSession:a,onNavigate:O,onBack:()=>C({t:`back`}),onForward:()=>C({t:`forward`}),onReload:e=>C({t:`reload`,...e?{ignoreCache:!0}:{}}),onPickServer:e=>T(e),onPickAgent:E,onViewport:y,onQuality:b,onCopyUrl:()=>gn(p),onStop:e=>C({t:`stop`,port:e}),onClose:o}),x?(0,Y.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:x}):null,(0,Y.jsx)(Tn,{transportState:s,overlay:ie,dim:re,lost:j})]})}function Tn({transportState:e,overlay:t,dim:n,lost:r}){let{connected:i,dialog:a,hasFrame:o,stage:s,stageHandle:c,compact:l,viewport:u,cursor:d,setStageSize:f,send:p,urlInput:m,transport:h,reconnect:g,setDialog:_}=e,v=s?.stage,y=i&&t===null&&!a;return(0,Y.jsxs)(Pt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,Y.jsx)(Mt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,Y.jsx)(ut,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,Y.jsx)(`div`,{"data-slot":`preview-overlay`,className:n&&o?`absolute inset-0 overflow-auto bg-background/85`:`absolute inset-0 overflow-auto bg-background`,children:t}):null,a?(0,Y.jsx)(ft,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function En(e){let{visibleEvents:t}=le(e);return(0,J.useMemo)(()=>{let e=new Map;for(let n of b(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function Dn(e){let t=En(e.run.id),n=se(e.run.id);return(0,Y.jsx)(xn,{...e,serverStates:t,agentLive:n})}export{Dn as ConnectedPreviewPane};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{L as t,t as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Dr as o,Er as s,Tr as c,sr as l}from"./project-scope-context-BUXmC8my.js";import{n as u}from"./toaster-CoMJoQvk.js";import{t as d}from"./createLucideIcon-BHp8sXmF.js";import{t as f}from"./arrow-right-Dh_Lx3um.js";import{n as p,r as m,t as h}from"./hourglass-B0lPAJvT.js";import{t as g}from"./info-DA1x_4bz.js";import{a as _}from"./format-BNCkW110.js";import{t as v}from"./play-CmVAj_fu.js";import{d as y,l as ee,n as b,u as x}from"./thread-state-BE9onTdO.js";import{a as S,c as C,i as w,l as T,p as E,r as D,s as O,t as k}from"./dropdown-menu-CzUYjvx4.js";import{s as te}from"./project-router-D5aSJsZ7.js";import{Ft as A,Gt as j,It as ne,Nt as re,Pt as ie,Qt as ae,Xt as oe,Zt as se,b as ce,cn as M,d as le,dn as ue,f as de,fn as N,g as fe,h as P,in as pe,m as me,nn as he,p as ge,rn as _e,sn as ve,tn as ye,un as F,x as be,y as xe}from"./index-QM9AFNSj.js";var Se=d(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),I=d(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),L=d(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),R=d(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),z=d(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),B=d(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),Ce=d(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),we=d(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),V=d(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),H=d(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),U=d(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),W=d(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),G=d(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),K=d(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),q=d(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Te=d(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),Ee=d(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),De=d(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),Oe=d(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),J=e(i(),1),ke=1e3,Ae=[500,1e3,2e3,4e3,8e3],je=1;function Me(e,t){let n=`/api/v1/p/${encodeURIComponent(e.projectId)}/runs/${encodeURIComponent(e.runId)}/preview/ws`,r=()=>`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${n}`,i=null,a,o=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||c(),m=()=>{if(o||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,i=n,n.addEventListener(`open`,()=>{n===i&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==i)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=l.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(f=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==i||o)return;if(i=null,!u){if(d+=1,d>=2){o=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),a=setTimeout(m,ke);return}if(f>=5){o=!0,t.onTransport(`closed`);return}let e=Ae[Math.min(f,Ae.length-1)];f+=1,t.onTransport(`reconnecting`,f),a=setTimeout(m,e)})},h=s(e=>{if(!o)if(e)i||m();else{clearTimeout(a),a=void 0;let e=i;i=null,e?.close()}});return t.onTransport(`connecting`),m(),{send(e){i?.readyState===je&&i.send(JSON.stringify(e))},close(){o=!0,h(),clearTimeout(a),a=void 0;let e=i;i=null,e?.close()}}}var Y=a();function Ne({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(A,{children:(0,Y.jsxs)(re,{children:[(0,Y.jsx)(ne,{asChild:!0,children:(0,Y.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-0 rounded-full bg-muted px-0 text-xs font-semibold text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none @min-[640px]:gap-1.5 @min-[640px]:px-2.5`,n),children:[(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(ie,{children:`Experimental`})]})}):e?(0,Y.jsx)(A,{children:(0,Y.jsxs)(re,{children:[(0,Y.jsx)(ne,{asChild:!0,children:(0,Y.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(ie,{children:`Experimental`})]})}):(0,Y.jsxs)(`span`,{"data-slot":`preview-experimental`,className:r(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-muted px-2.5 text-xs font-semibold text-muted-foreground`,n),children:[(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function Pe({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
|
|
2
|
+
`);return(0,Y.jsxs)(`div`,{"data-slot":`preview-log-tail`,className:r(`min-w-0 rounded-lg bg-muted px-3.5 py-3 font-mono text-xs`,i),children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,Y.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${a.length} ${a.length===1?`line`:`lines`} · ${t}`]}),(0,Y.jsxs)(`button`,{type:`button`,className:`-m-2 inline-flex min-h-11 items-center gap-1.5 rounded-sm p-2 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:min-h-0 md:p-0`,onClick:()=>n(e),children:[(0,Y.jsx)(M,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,Y.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Fe=/^([a-z][a-z0-9+.-]*):/i;function Ie(e,t){let n=e.trim();if(n===``)return{kind:`error`,message:`Type a URL or a port.`};if(/^\d{1,5}$/.test(n)){let e=Number(n);return e<1||e>65535?{kind:`error`,message:`A port is a number from 1 to 65535.`}:t.some(t=>t.port===e)?{kind:`server`,port:e}:{kind:`url`,url:`http://localhost:${e}`}}let r=Fe.exec(n)?.[1]?.toLowerCase();return r&&!/^[a-z0-9.-]+:\d/i.test(n)?r!==`http`&&r!==`https`?{kind:`error`,message:`Only http and https addresses open here.`}:Le(n):Le(`http://${n}`)}function Le(e){let t={kind:`error`,message:`That is not a valid address.`};if(/\s/.test(e))return t;try{new URL(e)}catch{return t}return{kind:`url`,url:e}}function Re(e){return e.replace(/^https?:\/\//i,``)}var ze=`https://github.com/hearsay-tools/squawk#environment-variables`;function Be({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,Y.jsx)(We,{state:e,actions:t});case`downloading`:return(0,Y.jsx)(Ke,{state:e,actions:t});case`download-failed`:return(0,Y.jsx)(qe,{state:e,actions:t});case`sandbox-failed`:return(0,Y.jsx)(Je,{state:e,actions:t});case`browser-exited`:return(0,Y.jsx)(Ye,{state:e,actions:t});case`needs-approval`:return(0,Y.jsx)(Qe,{state:e,actions:t});case`port-held`:return(0,Y.jsx)($e,{state:e,actions:t});case`server-starting`:return(0,Y.jsx)(et,{state:e,actions:t});case`server-stalled`:return(0,Y.jsx)(tt,{state:e,actions:t});case`server-exited`:return(0,Y.jsx)(nt,{state:e,actions:t});case`server-stopped`:return(0,Y.jsx)(rt,{state:e,actions:t});case`loading`:return(0,Y.jsx)(at,{step:e.step,url:n});case`worktree-removed`:return(0,Y.jsx)(ot,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,Y.jsx)(st,{actions:t});case`taken-over`:return(0,Y.jsx)(lt,{state:e,actions:t})}}function X({icon:e,title:t,children:n,state:r}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":r,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:e}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Z=({children:e})=>(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),Q=({children:e})=>(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function Ve({server:e}){return(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(se,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Runs ${P(e.command)} in this task's worktree, on the host.`})]})}function He({copy:e,command:t,label:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-3 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:[(0,Y.jsx)(`span`,{children:n}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,className:`-m-2 inline-flex size-11 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:size-6`,onClick:()=>e(t),children:(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":`true`})})]}),(0,Y.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function Ue({server:e,status:t}){return(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,Y.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,Y.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,Y.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,Y.jsx)(`span`,{children:`cwd`}),(0,Y.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,Y.jsx)(`div`,{className:`mt-2.5`,children:(0,Y.jsx)(Ve,{server:e})})]})}function We({state:e,actions:r}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(R,{}),title:`This host has no browser yet`,children:[(0,Y.jsx)(Z,{children:e.canDownload?`Preview runs Chromium on the machine ${t(`cezar`)} runs on. ${t(`cezar`)} can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine ${t(`cezar`)} runs on. ${t(`cezar`)} has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:r.download,children:[(0,Y.jsx)(R,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,Y.jsx)(He,{command:e.installCommand,copy:r.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function Ge(e){return Math.round(e/1e6)}function Ke({state:e,actions:t}){let r=(0,J.useRef)(null);r.current??={at:Date.now(),received:e.received};let i=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,a=(Date.now()-r.current.at)/1e3,o=a>=1?(e.received-r.current.received)/a:0,s=o>0?Math.ceil((e.total-e.received)/o):void 0;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(R,{}),title:`Downloading Chromium`,children:[(0,Y.jsx)(Z,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${i}%`}})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:`${Ge(e.received)} of ${Ge(e.total)} MB · ${i}%`}),s===void 0?null:(0,Y.jsx)(`span`,{children:`about ${s} s left`})]})]}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function qe({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(Ee,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,Y.jsx)(Z,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,Y.jsx)(He,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Retry download`]}),(0,Y.jsxs)(n,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function Je({state:e,actions:r}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(q,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,Y.jsxs)(Z,{children:[`The host blocks the sandbox Chromium needs. This usually means `,t(`cezar`),` runs as root, or inside a container without user namespaces.`]}),(0,Y.jsx)(Pe,{text:e.stderrTail,source:`chromium`,onCopy:r.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:r.retryBrowser,children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(n,{variant:`outline`,onClick:()=>r.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,Y.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:ze,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function Ye({state:e,actions:t}){let r=e.reason===`timeout`,i=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,a=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,o=r?`Chromium did not start in time`:`Chromium exited${i}`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(p,{className:`text-danger`}),title:r?`The browser did not start`:`The browser stopped`,children:[(0,Y.jsx)(Z,{children:r?`Chromium did not open its DevTools port in time. ${a}`:`Chromium exited unexpectedly${i}. ${a}`}),(0,Y.jsx)(Pe,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(n,{variant:`outline`,onClick:()=>t.copy(`${o}\n${e.stderrTail}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Xe=2;function Ze(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Qe({state:e,actions:r}){let{server:i,wasRunning:a}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:a?(0,Y.jsx)(De,{className:`text-pending-strong`}):(0,Y.jsx)(v,{}),title:a?`Nothing answers on :${i.port} anymore`:`${i.label} isn't running yet`,children:[(0,Y.jsx)(Z,{children:a?`${i.label} was running when the agent registered it, likely inside the agent's own session, which has ended. ${t(`cezar`)} can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,Y.jsx)(Ue,{server:i,status:a?`was running when registered · silent now`:`registered · not started`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:()=>r.run(i.port),children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Run and open`]})})]})}function $e({state:e,actions:t}){let{server:r,ownerTitle:i}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(Ee,{className:`text-pending-strong`}),title:`${r.label} :${r.port} is in use by another task`,children:[(0,Y.jsx)(Z,{children:`Task "${i}" is running its own server on :${r.port}. Register a different port for this task, or stop that task's server.`}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function et({state:e,actions:r}){let{server:i}=e,a=Ze(1e3),o=Math.max(0,Math.floor((a-Date.parse(e.startedAt))/1e3)),[s,c]=(0,J.useState)(()=>Date.now());(0,J.useEffect)(()=>c(Date.now()),[e.attempt]);let l=Math.max(0,Math.ceil(Xe-(a-s)/1e3));return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(v,{}),title:`Starting ${i.label}`,children:[(0,Y.jsx)(Z,{children:`${t(`cezar`)} ran ${P(i.command)} in the worktree. The page opens as soon as :${i.port} answers.`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,Y.jsx)(_,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),l>0?`Attempt ${e.attempt} · next try in ${l} s`:`Attempt ${e.attempt}`]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${o} s ago`})]}),e.logTail.length>0?(0,Y.jsx)(Pe,{text:e.logTail.join(`
|
|
3
|
+
`),source:P(i.command),onCopy:r.copy}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`outline`,onClick:()=>r.stop(i.port),children:`Stop server`})})]})}function tt({state:e,actions:t}){let{server:r}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(h,{className:`text-pending-strong`}),title:`${r.label} is running, but :${r.port} is silent`,children:[(0,Y.jsx)(Z,{children:`The process has run for 2 min without opening the port. It may be waiting on another service, or listening somewhere else.`}),(0,Y.jsx)(Pe,{text:e.logTail,source:P(r.command),onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(n,{variant:`contrast`,onClick:()=>t.keepWaiting(r.port),children:`Keep waiting`}),(0,Y.jsx)(n,{variant:`outline`,onClick:()=>t.stop(r.port),children:`Stop server`})]})]})}function nt({state:e,actions:t}){let{server:r}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(p,{className:`text-danger`}),title:e.exitCode===null?`${r.label} was stopped by a signal`:`${r.label} exited with code ${e.exitCode}`,children:[(0,Y.jsx)(Z,{children:`${P(r.command)} stopped.`}),(0,Y.jsx)(Pe,{text:e.logTail,source:P(r.command),onCopy:t.copy}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:()=>t.run(r.port),children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Ve,{server:r})]})}function rt({state:e,actions:r}){let{server:i}=e,a=e.reason===`idle`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(ye,{}),title:a?`Stopped after 15 min idle`:`${i.label} stopped`,children:[(0,Y.jsx)(Z,{children:a?`Nobody had this pane open for 15 min, so ${t(`cezar`)} stopped ${i.label} :${i.port} and the browser to free memory. Start again reopens ${Re(e.lastUrl)}.`:`You stopped ${i.label} :${i.port}. Start again reopens ${Re(e.lastUrl)}.`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:()=>r.run(i.port),children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Ve,{server:i})]})}var it=[`browser`,`page`,`frame`];function at({step:e,url:t}){let n=it.indexOf(e),i=t?Re(t):`the page`;return(0,Y.jsx)(`div`,{"data-slot":`preview-state`,"data-state":`loading`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center px-6 py-8`,children:(0,Y.jsx)(`ol`,{"aria-label":`Opening the page`,className:`mx-auto flex flex-col gap-4 text-sm`,children:[{done:`Browser started`,active:`Starting the browser`},{done:`Opened ${i}`,active:`Opening ${i}`},{done:`First frame`,active:`First frame`}].map((e,t)=>{let i=t<n,a=t===n;return(0,Y.jsxs)(`li`,{"aria-current":a?`step`:void 0,className:r(`flex items-center gap-3`,a?`font-semibold text-foreground`:i?`text-foreground`:`text-soft-foreground`),children:[i?(0,Y.jsx)(m,{className:`size-5 text-success`,"aria-hidden":`true`}):a?(0,Y.jsx)(_,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,Y.jsx)(L,{className:`size-5 text-border`,"aria-hidden":`true`}),i?e.done:a?e.active:e.done]},t)})})})}function ot({state:e,actions:t,worktree:r}){let i=r?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(r)?.[0]:void 0,a=e.server?.label;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(B,{}),title:`This task's worktree is gone`,children:[(0,Y.jsx)(Z,{children:`${a??`The server`} ran in ${i??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,Y.jsx)(ee,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function st({actions:e}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":`proxy-blocked`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Ne,{})}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,Y.jsx)(W,{})}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,Y.jsxs)(Z,{children:[`The proxy in front of `,t(`cezar`),` didn't let the preview's WebSocket through. This is a known gap behind Basic Auth. Everything else in `,t(`cezar`),` keeps working.`]}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(n,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,Y.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:ze,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function ct(e){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Windows/.test(e)?`Windows`:/Mac OS X|Macintosh/.test(e)?`Mac`:/Linux|X11/.test(e)?`Linux`:``,n=/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n&&t?`${n} on ${t}`:n||t}function lt({state:e,actions:t}){let r=ct(e.by);return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(U,{}),title:`Preview is open somewhere else`,children:[(0,Y.jsx)(Z,{children:`Another tab took this browser${r?` (${r})`:``}. Only one tab can view and drive it at a time.`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:t.useHere,children:[(0,Y.jsx)(R,{"aria-hidden":`true`}),`Use it here`]}),(0,Y.jsx)(n,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function ut({attempt:e,exhausted:t,onReconnect:r}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-connection-banner`,role:`status`,className:`absolute inset-x-3 top-3 z-10 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-3.5 py-2.5 text-sm shadow-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(Oe,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,Y.jsx)(n,{variant:`outline`,onClick:r,children:t?`Reconnect`:`Reconnect now`})]})}function dt({servers:e,states:t,onOpen:r,agentLive:i=!1,agentIdle:a=!1,onOpenAgent:o}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":a?`agent-idle`:`empty`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,Y.jsx)(Z,{children:`The browser runs on the host, next to the worktree. Type a URL, a bare port such as 3000, or open a server the agent registered.`}),a?(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,Y.jsx)(De,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,i&&o!==void 0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-agent`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Driven by the agent`}),(0,Y.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,Y.jsx)(n,{variant:`outline`,size:`sm`,className:`max-md:h-11`,"aria-label":`Open the agent's page`,onClick:o,children:`Open`})]})]}):null,e.length>0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-registered`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Registered in this task`}),(0,Y.jsx)(`ul`,{children:e.map(e=>{let i=ge(e,t),a=fe(i);return(0,Y.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border px-3.5 py-2 text-sm last:border-b-0`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:a.text})]}),(0,Y.jsx)(n,{variant:`outline`,size:`sm`,className:`max-md:h-11`,onClick:()=>r(e.port),children:me(i)?`Open`:`Review`})]},e.port)})})]}):null,(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(g,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Review opens a server's approval in this pane: its command, cwd and Run and open. Nothing runs from this list. Paste works; copying text out, file pickers and downloads don't yet.`})]})]})}function ft({dialog:e,onResult:t}){let[r,i]=(0,J.useState)(e.defaultPrompt??``),a=e.type===`beforeunload`,o=(0,J.useRef)(null),s=(0,J.useRef)(null);(0,J.useEffect)(()=>{(e.type===`prompt`?s.current:o.current)?.focus()},[e.type]);let c=(0,J.useRef)(t);c.current=t,(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target instanceof Element?e.target:null;t&&t!==document.body&&!t.closest(`[data-slot="preview-pane-body"], [data-slot="preview-page-dialog"]`)||(e.stopPropagation(),c.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let l=()=>t(e.type===`prompt`?{accept:!0,text:r}:{accept:!0});return(0,Y.jsx)(`div`,{"data-slot":`preview-page-dialog`,className:`absolute inset-0 z-20 flex items-center justify-center bg-foreground/30 p-4`,children:(0,Y.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`${e.origin} says`,className:`w-full max-w-[380px] rounded-xl border border-border bg-card p-4 shadow-lg`,children:[(0,Y.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,Y.jsx)(`p`,{className:`mb-4 text-sm break-words whitespace-pre-wrap text-foreground`,children:e.message||(a?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,Y.jsx)(`input`,{ref:s,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l()},className:`mb-4 h-11 w-full rounded-md border border-border bg-background px-3 text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,Y.jsx)(n,{variant:`outline`,onClick:()=>t({accept:!1}),children:a?`Stay`:`Cancel`}),(0,Y.jsx)(n,{ref:o,variant:`contrast`,onClick:l,children:a?`Leave`:`OK`})]})]})})}var pt=10,mt=500,ht=500,gt=4,_t=16,vt=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function yt(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function bt(e,t){return{rect:e,scale:t,touches:new Map,multiTouch:!1,click:{at:-1/0,x:0,y:0,button:-1,count:1}}}var xt=[`left`,`middle`,`right`];function $(e,t,n,r){let i=yt(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:xt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:vt(n),...r}}var St=e=>e===0?0:-e;function Ct(e,t,n,r,i){let a=yt(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:St(r/e.scale),deltaY:St(i/e.scale),modifiers:0}}function wt(e,t){let{touches:n}=t,r=n.get(e.pointerId),i=()=>{n.delete(e.pointerId),n.size===0&&(t.multiTouch=!1)};switch(e.type){case`pointerdown`:return n.set(e.pointerId,{startX:e.clientX,startY:e.clientY,startAt:e.timeStamp,lastX:e.clientX,lastY:e.clientY,scrolling:!1}),n.size>1&&(t.multiTouch=!0),[];case`pointermove`:{if(!r)return[];if(t.multiTouch)return r.lastX=e.clientX,r.lastY=e.clientY,[];if(!r.scrolling){if(Math.hypot(e.clientX-r.startX,e.clientY-r.startY)<=pt)return[];r.scrolling=!0}let n=e.clientX-r.lastX,i=e.clientY-r.lastY;return r.lastX=e.clientX,r.lastY=e.clientY,n===0&&i===0?[]:[Ct(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=mt;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[$(`mouseMoved`,t,a,{button:`none`,buttons:0}),$(`mousePressed`,t,a,{button:`left`,buttons:1}),$(`mouseReleased`,t,a,{button:`left`,buttons:0})]}case`pointercancel`:return i(),[]}}function Tt(e,t){if(e.pointerType===`touch`)return wt(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=ht&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=gt;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[$(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[$(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[$(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Et(e,t,n){let r=yt(e.clientX,e.clientY,t,n),i=e.deltaMode===1?_t:1;return{t:`mouse`,type:`mouseWheel`,x:r.x,y:r.y,button:`none`,buttons:e.buttons??0,deltaX:e.deltaX*i/n,deltaY:e.deltaY*i/n,modifiers:vt(e)}}var Dt={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Ot(e){let t=e.key.toLowerCase(),n=(e.ctrlKey||e.metaKey)&&!e.getModifierState?.(`AltGraph`);if(n&&(t===`v`||t===`k`))return;let r={t:`key`,key:e.key,code:e.code,modifiers:vt(e),vk:e.keyCode};if(e.type===`keyup`)return{...r,type:`keyUp`};let i=n?``:e.key.length===1?e.key:e.key===`Enter`?`\r`:e.key===`Tab`?` `:``,a=n?t===`z`&&e.shiftKey?`redo`:Dt[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:vt(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function kt(e){return e?{t:`insertText`,text:e}:void 0}var At=e=>e,jt=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function Mt({scale:e,send:t,onLeave:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(bt({left:0,top:0},e)),a=(0,J.useRef)(e);a.current=e;let o=(0,J.useRef)(t);o.current=t;let s=(0,J.useRef)(void 0),c=()=>{let e=r.current;e&&(i.current.rect=e.getBoundingClientRect()),i.current.scale=a.current},l=e=>{c();for(let t of Tt(At(e),i.current))o.current(t)},u=()=>{let e=s.current;e&&(s.current=void 0,cancelAnimationFrame(e.frame),l(e.event))};(0,J.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,J.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,J.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{e.preventDefault(),c(),o.current(Et(e,i.current.rect,i.current.scale))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,J.useEffect)(()=>{let e=e=>{if(document.activeElement!==r.current)return;let t=kt(e.clipboardData?.getData(`text`)??``);t&&(e.preventDefault(),o.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[]);let d=e=>{u(),r.current?.focus({preventScroll:!0});try{r.current?.setPointerCapture(e.pointerId)}catch{}l(e.nativeEvent)},f=e=>{let t=e.nativeEvent;if(t.pointerType===`touch`)return l(t);let n=s.current;if(n){n.event=t;return}s.current={event:t,frame:requestAnimationFrame(()=>{let e=s.current;s.current=void 0,e&&l(e.event)})}},p=e=>{u(),l(e.nativeEvent)},m=e=>{if(jt(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Ot(e.nativeEvent);i&&(e.preventDefault(),e.stopPropagation(),t(i))};return(0,Y.jsx)(`div`,{ref:r,"data-slot":`preview-input`,role:`application`,"aria-label":`Page preview, interactive`,"aria-description":`Keys go to the page, Tab included. Press Shift+Escape to return to the cockpit.`,tabIndex:0,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onContextMenu:e=>e.preventDefault(),onKeyDown:m,onKeyUp:m,className:`absolute inset-0 touch-none select-none outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset`})}async function Nt(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,release:()=>t.close()}}let t=URL.createObjectURL(e),n=new Image;return n.src=t,await n.decode(),{source:n,width:n.naturalWidth,height:n.naturalHeight,release:()=>URL.revokeObjectURL(t)}}function Pt({ref:e,viewport:t,dimmed:n=!1,cursor:i,onSize:a,renderInput:o,children:s}){let l=(0,J.useRef)(0),u=(0,J.useRef)(null),d=(0,J.useRef)(null),[f,p]=(0,J.useState)(null),m=(0,J.useRef)(a);m.current=a,(0,J.useImperativeHandle)(e,()=>({async draw(e){let t=++l.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!c()))try{let i=await Nt(e);try{if(t!==l.current||!c()||d.current!==n)return;n.width!==i.width&&(n.width=i.width),n.height!==i.height&&(n.height=i.height),r.drawImage(i.source,0,0)}finally{i.release()}}catch{}}}),[]),(0,J.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{let t=Math.round(e.clientWidth),n=Math.round(e.clientHeight);t===0||n===0||(p(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n}),m.current?.({w:t,h:n}))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let h=t===`fit`?f:t,g=t===`fit`||!f?1:Math.min(1,(f.w-24)/t.w,(f.h-24)/t.h),_=h?{width:Math.floor(h.w*g),height:Math.floor(h.h*g)}:void 0;return(0,Y.jsxs)(`div`,{ref:u,"data-slot":`preview-stage`,"data-viewport":t===`fit`?`fit`:`${t.w}x${t.h}`,className:r(`relative min-h-0 flex-1 overflow-hidden bg-muted`,t!==`fit`&&`flex items-start justify-center overflow-auto p-3`),children:[h?(0,Y.jsxs)(`div`,{"data-slot":`preview-surface`,"data-scale":g,style:{..._,cursor:i},className:r(`relative shrink-0 bg-card`,t!==`fit`&&`shadow-md`,n&&`opacity-60 saturate-50`),children:[(0,Y.jsx)(`canvas`,{ref:d,"aria-label":`Page preview`,role:`img`,style:_,className:`block touch-none select-none`}),o?.({canvas:d.current,scale:g,viewport:h})]}):null,s]})}var Ft=`cez-preview-quality`,It=[{value:`normal`,label:`Normal`,detail:`The default. Lighter on CPU and network.`},{value:`high`,label:`High`,detail:`Sharper text and fine detail. Uses more CPU and network.`},{value:`ultra`,label:`Ultra`,detail:`High at your screen's pixel density, up to 2×. Uses the most CPU and network.`}];function Lt(e){return It.find(t=>t.value===e)?.value??`normal`}var Rt=e=>It.find(t=>t.value===e)?.label??`Normal`;function zt(){try{return Lt(localStorage.getItem(Ft))}catch{return`normal`}}function Bt(e){try{localStorage.setItem(Ft,e)}catch{}}var Vt=[{w:390,h:844,icon:ae},{w:820,h:1180,icon:Te},{w:1440,h:900,icon:he}],Ht=`size-8 shrink-0 max-md:size-11`,Ut=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Wt(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Gt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Kt({stats:e,shrunk:t}){let n=Wt(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,Y.jsx)(j,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,Y.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Gt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Gt(e)})]})}function qt({current:e,agentShown:t,...r}){let i=e?e.label:t?`Agent's page`:`Server`;return(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`max-w-[11rem] min-w-0 gap-1.5 max-md:h-11`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${i}`:`Server`,...r,children:[e||t?(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,Y.jsx)(x,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:i}),e?(0,Y.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,Y.jsx)(F,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function Jt({shown:e,live:t,onSelect:n}){return(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,Y.jsx)(j,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,Y.jsx)(N,{className:`size-4`,"aria-hidden":`true`}):null]})}function Yt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Xt(e){let t=e.onPickAgent!==void 0,n=e.agentLive===!0&&t,r=e.agentShown===!0;return{agentLive:n,agentShown:r,agentListed:n||r&&t}}function Zt(e){let{compact:t=!1,navEnabled:r,loading:i=!1}=e,a=(0,J.useRef)(null),o=e.urlInputRef??a,s=(0,J.useRef)(!1),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1),p=(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Back`,disabled:!r,onClick:e.onBack,children:(0,Y.jsx)(Se,{"aria-hidden":`true`})}),m=(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Forward`,disabled:!r,onClick:e.onForward,children:(0,Y.jsx)(f,{"aria-hidden":`true`})}),h=(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Reload`,"aria-busy":i||void 0,disabled:!r||i,onClick:()=>e.onReload(!1),children:(0,Y.jsx)(K,{"aria-hidden":`true`})}),g=e.onSession?(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1 max-md:h-11`,onClick:e.onSession,children:[(0,Y.jsx)(ue,{"aria-hidden":`true`}),`Session`]}):null,_=i?(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Loading the page`,className:`absolute inset-x-0 bottom-0 h-0.5 overflow-hidden bg-transparent`,children:(0,Y.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,v=(0,Y.jsx)($t,{props:e,input:o,draft:c,setDraft:l,focused:u,setFocused:d}),{agentListed:y}=Xt(e),ee=e.servers.length+ +!!y>=2,b=ee||e.adopted,x={back:p,forward:m,reload:h,address:v,more:(0,Y.jsx)(an,{props:e,compact:t,crowded:b}),session:g,progress:_};return t?(0,Y.jsx)(on,{props:e,elements:x}):(0,Y.jsx)(sn,{props:e,elements:x,switcher:ee,crowded:b,input:o,focusUrlAfterMenu:s})}function Qt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Xt(e);return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsx)(qt,{current:i,agentShown:o})}),(0,Y.jsxs)(D,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,Y.jsx)(Jt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=fe(ge(t,e.serverStates));return(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":i?.port===t.port||void 0,onSelect:()=>e.onPickServer(t.port),children:[(0,Y.jsx)(j,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,Y.jsx)(N,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,Y.jsx)(T,{}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,Y.jsx)(pe,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function $t({props:e,input:n,draft:i,setDraft:a,focused:o,setFocused:s}){let{url:c,adopted:l}=e;return(0,Y.jsxs)(`div`,{className:`relative flex min-w-[9rem] flex-1 items-center`,children:[(0,Y.jsx)(pe,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{ref:n,type:`text`,"aria-label":`Page address`,placeholder:`Type a URL or a port`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:i??(o?c:Re(c)),title:c||void 0,className:r(`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-muted pl-8 font-mono text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:bg-background focus-visible:ring-[3px] focus-visible:ring-ring/30 max-md:h-11`,l?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;s(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{s(!1),a(null)},onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(i??c),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),l&&!o?(0,Y.jsxs)(`span`,{className:`pointer-events-none absolute right-2 inline-flex h-6 items-center gap-1 rounded-full border border-border bg-card px-2 text-xs font-semibold text-muted-foreground`,children:[(0,Y.jsx)(we,{className:`size-3`,"aria-hidden":`true`}),`Not started by `,t(`cezar`)]}):null]})}function en({props:e}){let{viewport:t}=e;return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ut(t)}`,children:[t===`fit`?(0,Y.jsx)(H,{"aria-hidden":`true`}):(0,Y.jsx)(he,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:r(`hidden @min-[500px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ut(t)}),(0,Y.jsx)(F,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(D,{align:`start`,className:`min-w-56`,children:[(0,Y.jsxs)(w,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,Y.jsx)(H,{"aria-hidden":`true`}),`Fit`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,Y.jsx)(N,{className:`size-4`,"aria-hidden":`true`}):null]}),Vt.map(({w:n,h:r,icon:i})=>(0,Y.jsxs)(w,{className:`gap-2.5 font-mono`,"aria-current":t!==`fit`&&t.w===n&&t.h===r||void 0,onSelect:()=>e.onViewport({w:n,h:r}),children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,Y.jsx)(N,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function tn({quality:e,onQuality:t,compact:n}){return(0,Y.jsx)(O,{value:e,onValueChange:e=>t(Lt(e)),children:It.map(e=>(0,Y.jsx)(C,{value:e.value,"data-quality":e.value,className:r(`items-start`,n&&`min-h-11`),children:(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function nn({props:e}){let{quality:t}=e;return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Rt(t)}`,children:[(0,Y.jsx)(Ce,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[560px]:inline`,children:Rt(t)}),(0,Y.jsx)(F,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(D,{align:`start`,className:`w-64`,children:[(0,Y.jsx)(S,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(tn,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function rn({stats:e,status:t,crowded:n}){return e?(0,Y.jsx)(Kt,{stats:e,shrunk:n}):t?(0,Y.jsxs)(`span`,{"data-slot":`preview-status`,className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:t.tone,"aria-hidden":`true`}),t.label]}):null}function an({props:e,compact:r,crowded:i}){let{stats:a,navEnabled:o,url:s,current:c,adopted:l}=e;return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`More`,children:(0,Y.jsx)(ve,{"aria-hidden":`true`})})}),(0,Y.jsxs)(D,{align:`end`,className:`min-w-64`,children:[i&&a&&!r?(0,Y.jsx)(S,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Gt(a)}):null,(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!o,onSelect:()=>e.onReload(!0),children:[(0,Y.jsx)(G,{"aria-hidden":`true`}),`Reload without cache`]}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:s===``,onSelect:e.onCopyUrl,children:[(0,Y.jsx)(_e,{"aria-hidden":`true`}),`Copy page URL`]}),c?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{}),l?(0,Y.jsxs)(w,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,Y.jsx)(V,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${c.label} :${c.port}`}),(0,Y.jsxs)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:[t(`cezar`),` didn't start this server, so it won't stop it. Stop it where it was started.`]})]})]}):(0,Y.jsxs)(w,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(c.port),children:[(0,Y.jsx)(I,{"aria-hidden":`true`}),`Stop server · ${c.label} :${c.port}`]})]}):null,r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{}),(0,Y.jsx)(S,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(tn,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,Y.jsx)(T,{}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,Y.jsx)(oe,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function on({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Xt(e),{back:o,forward:s,reload:c,address:l,more:u,session:d,progress:f}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,Y.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:Yt(r,a)})]}),i?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[o,s,c,l]}),f]})}function sn({props:e,elements:t,switcher:r,crowded:i,input:a,focusUrlAfterMenu:o}){let{badge:s=!0,stats:c,status:l}=e,{back:u,forward:d,reload:f,address:p,more:m,session:h,progress:g}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1.5 border-b border-border bg-background px-2.5 py-2`,children:[h,u,d,f,r?(0,Y.jsx)(Qt,{props:e,input:a,focusUrlAfterMenu:o}):null,p,(0,Y.jsx)(en,{props:e}),(0,Y.jsx)(nn,{props:e}),(0,Y.jsx)(rn,{stats:c,status:l,crowded:i}),s?(0,Y.jsx)(Ne,{iconOnly:i,responsive:!i}):null,(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),m,(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Close preview`,onClick:e.onClose,children:(0,Y.jsx)(oe,{"aria-hidden":`true`})}),g]})}function cn({transport:e,takenOver:t,empty:n,stage:r,hasFrame:i,lost:a,url:o,worktree:s}){let c=a||e!==`blocked`&&t!==void 0;return e===`blocked`?{content:{kind:`state`,state:{stage:`proxy-blocked`}},dim:c}:t===void 0?n||r?.stage===`agent-idle`?{content:{kind:`empty`,agentIdle:!n&&r?.stage===`agent-idle`},dim:c}:r?.stage===`streaming`||r?.stage===`loading`&&i?{content:{kind:`none`},dim:c}:r?{content:{kind:`state`,state:r,url:o,worktree:s},dim:c}:a?{content:{kind:`none`},dim:c}:{content:{kind:`state`,state:{t:`state`,stage:`loading`,step:`browser`},url:o},dim:c}:{content:{kind:`state`,state:{stage:`taken-over`,by:t}},dim:c}}function ln(e,{servers:t,serverStates:n,agentLive:r,openServer:i,openAgent:a,actions:o}){switch(e.kind){case`none`:return null;case`state`:{let{kind:t,...n}=e;return(0,Y.jsx)(Be,{...n,actions:o})}case`empty`:return(0,Y.jsx)(dt,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function un(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function dn(){let[e,t]=(0,J.useState)(un);return(0,J.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(un());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var fn=2e3,pn=500,mn=1e3;function hn(e,t){switch(e.stage){case`needs-approval`:case`port-held`:case`server-starting`:case`server-stalled`:case`server-exited`:case`server-stopped`:return e.server.port===t;case`loading`:case`streaming`:return!0;default:return!1}}function gn(e){navigator.clipboard?.writeText(e).then(()=>u(`Copied`),()=>u(`Couldn't copy to the clipboard`,{tone:`danger`}))}var _n=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function vn(e,t){return e?.port===void 0?e?.agent===!0||e?.url!==void 0:e.restored!==!0||t.some(t=>t.port===e.port)}function yn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function bn({run:e,servers:t,request:n,onTarget:r,onLive:i,onClose:a}){let s=dn(),l=(0,J.useRef)(s);l.current=s;let u=o(),d=(0,J.useRef)(crypto.randomUUID()),f=(0,J.useRef)(!1),p=te(),m=ce(xe,!1),[h,g]=(0,J.useState)(0),[_,v]=(0,J.useState)({state:`connecting`,attempt:0}),[y,ee]=(0,J.useState)(!1),[b,x]=(0,J.useState)(void 0),[S,C]=(0,J.useState)(void 0),[w,T]=(0,J.useState)(``),[E,D]=(0,J.useState)(void 0),[O,k]=(0,J.useState)(!1),[A,j]=(0,J.useState)(void 0),[ne,re]=(0,J.useState)(!1),[ie,ae]=(0,J.useState)(!1),[oe,se]=(0,J.useState)(void 0),[M,le]=(0,J.useState)(void 0),[ue,de]=(0,J.useState)(void 0),[N,fe]=(0,J.useState)(`fit`),[P,pe]=(0,J.useState)(zt),[me,he]=(0,J.useState)(null),[ge,_e]=(0,J.useState)(void 0),[ve,ye]=(0,J.useState)(0),F=(0,J.useRef)(void 0),be=(0,J.useRef)(null),Se=(0,J.useRef)(null),I=(0,J.useRef)(void 0),L=(0,J.useRef)(void 0),R=(0,J.useRef)(P);R.current=P;let z=(0,J.useRef)({port:E,stage:S,agent:O});z.current={port:E,stage:S,agent:O};let B=(0,J.useRef)([]),Ce=(0,J.useRef)(void 0),we=(0,J.useRef)(!1),V=(0,J.useRef)(!1),H=(0,J.useCallback)(e=>{V.current&&F.current?.send(e)},[]);(0,J.useEffect)(()=>{let t;return t=Me({projectId:p??`default`,runId:e.id},{onFrame(e){if(!c())return;let n=Date.now();B.current.push({at:n,bytes:e.size}),we.current||(we.current=!0,ae(!0)),(be.current?.draw(e)??Promise.resolve()).finally(()=>t?.send({t:`ack`}))},onMessage(e){switch(e.t){case`state`:if(C(e),(e.stage===`streaming`||e.stage===`loading`)&&ye(e=>e+1),L.current!==void 0&&hn(e,L.current)){let n=L.current;L.current=void 0,(e.stage===`needs-approval`||e.stage===`server-exited`||e.stage===`server-stopped`)&&t?.send({t:`run`,port:n})}return;case`url`:return T(e.url);case`cursor`:return se(e.cursor);case`dialog`:return le(e);case`pong`:Ce.current=Math.max(0,Date.now()-e.ts);return;case`downloadProgress`:C(t=>t?.stage===`downloading`?{...t,received:e.received,total:e.total}:t);return;case`replaced`:x(e.by),V.current=!1,t?.close();return}},onTransport(e,n){V.current=e===`open`,v({state:e,attempt:n??0}),e===`open`&&(ee(!0),I.current&&(t?.send({t:`open`,target:I.current,viewerId:d.current,resume:f.current,quality:R.current,dpr:l.current}),f.current=!0))}}),F.current=t,()=>{V.current=!1,t?.close(),F.current===t&&(F.current=void 0)}},[p,e.id,h]);let U=u&&_.state===`open`&&b===void 0,W=m||N===`fit`?me:N;(0,J.useEffect)(()=>{W&&U&&(S?.stage===`streaming`||S?.stage===`loading`)&&H({t:`resize`,w:W.w,h:W.h,...s===1?{}:{dpr:s}})},[W?.w,W?.h,s,U,S?.stage,ve,H]),(0,J.useEffect)(()=>{if(!U)return;let e=setInterval(()=>H({t:`ping`,ts:Date.now()}),fn);return()=>clearInterval(e)},[U,H]);let G=U&&S?.stage===`streaming`;(0,J.useEffect)(()=>{if(!G){de(void 0);return}let e=setInterval(()=>{let e=Date.now();B.current=B.current.filter(t=>e-t.at<=mn);let t={fps:B.current.length,kbps:Math.round(B.current.reduce((e,t)=>e+t.bytes,0)/1024),...Ce.current===void 0?{}:{rttMs:Ce.current},...B.current.length>0?{lastFrameAt:B.current.at(-1).at}:{}};de(e=>{let n=t.lastFrameAt??e?.lastFrameAt,r={...t,...n===void 0?{}:{lastFrameAt:n}};return e&&e.fps===r.fps&&e.kbps===r.kbps&&e.rttMs===r.rttMs&&e.lastFrameAt===r.lastFrameAt?e:r})},pn);return()=>clearInterval(e)},[G]),(0,J.useEffect)(()=>(i?.(G),()=>i?.(!1)),[G,i]),(0,J.useEffect)(()=>{A&&r?.(A)},[A,r]);let K=(0,J.useCallback)((e,t,n=!1)=>{I.current=e,L.current=n&&`port`in e?e.port:void 0,re(!0),C(void 0),x(void 0),_e(void 0),T(t),D(`port`in e?e.port:void 0),k(`agent`in e),j(yn(e)),H({t:`open`,target:e,viewerId:d.current,quality:R.current,dpr:l.current}),f.current=V.current},[H]),q=(0,J.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);K({port:e},r?_n(r):`http://localhost:${e}`,n)},[t,K]),Te=(0,J.useCallback)(()=>K({agent:!0},``),[K]);(0,J.useEffect)(()=>{if(n?.agent){if(z.current.agent&&z.current.stage?.stage===`streaming`)return;Te();return}if(n?.url!==void 0){let e=Ie(n.url,t);e.kind===`server`?q(e.port):e.kind===`url`&&K({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||z.current.port===n.port&&z.current.stage?.stage===`streaming`&&n.run!==!0||q(n.port,n.run===!0))},[n]);let Ee=!ne&&!b&&_.state!==`blocked`,De=vn(n,t);(0,J.useEffect)(()=>{Ee&&!De&&Se.current?.focus()},[Ee,De]);let Oe=e=>{let n=Ie(e,t);if(n.kind===`error`)return _e(n.message);if(n.kind===`server`)return q(n.port);if(z.current.stage?.stage===`streaming`&&!z.current.agent)return I.current={url:n.url},L.current=void 0,D(void 0),j({url:n.url}),_e(void 0),T(n.url),H({t:`nav`,url:n.url});K({url:n.url},n.url)},ke=(0,J.useCallback)(e=>{R.current=e,pe(e),Bt(e),H({t:`quality`,quality:e})},[H]),Ae=()=>{f.current=!1,x(void 0),v({state:`connecting`,attempt:0}),we.current=!1,g(e=>e+1)};return{compact:m,transport:_,everOpened:y,takenOver:b,stage:S,url:w,port:E,agent:O,hasFrame:ie,cursor:oe,dialog:M,setDialog:le,stats:ue,viewport:N,setViewport:fe,quality:P,chooseQuality:ke,setStageSize:he,addressError:ge,stageHandle:be,urlInput:Se,send:H,connected:U,streaming:G,openServer:q,openAgent:Te,empty:Ee,navigate:Oe,reconnect:Ae,actions:(0,J.useMemo)(()=>({download:()=>H({t:`download`}),cancelDownload:()=>H({t:`cancelDownload`}),retryBrowser:()=>H({t:`retryBrowser`}),run:e=>H({t:`run`,port:e}),stop:e=>H({t:`stop`,port:e}),keepWaiting:e=>H({t:`keepWaiting`,port:e}),close:a,useHere:Ae,copy:gn}),[H,a])}}function xn(e){return(0,Y.jsx)(be,{onClose:e.onClose,children:(0,Y.jsx)(wn,{...e})})}function Sn(e,t,n,r){return e.state===`blocked`?{tone:`neutral`,label:`not supported`}:n?{tone:`neutral`,label:`paused`}:t&&(e.state===`reconnecting`||e.state===`closed`)?{tone:`danger`,label:`offline`}:e.state===`open`?r?Cn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Cn(e){switch(e.stage){case`downloading`:return{tone:`pending`,label:`downloading`};case`download-failed`:return{tone:`danger`,label:`download failed`};case`sandbox-failed`:return{tone:`danger`,label:`browser failed`};case`browser-exited`:return{tone:`danger`,label:e.reason===`timeout`?`browser timed out`:`browser exited`};case`needs-approval`:return{tone:`neutral`,label:`not started`};case`port-held`:return{tone:`danger`,label:`port in use`};case`server-starting`:return{tone:`pending`,label:`waiting for :${e.server.port}`};case`server-stalled`:return{tone:`pending`,label:`waiting · 2 min`};case`server-exited`:return{tone:`danger`,label:`server exited`};case`server-stopped`:return{tone:`neutral`,label:`stopped`};case`agent-idle`:return{tone:`neutral`,label:`agent idle`};case`loading`:return{tone:`neutral`,label:`connecting…`};default:return}}function wn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=bn(e),{compact:c,transport:l,everOpened:u,takenOver:d,stage:f,url:p,port:m,agent:h,hasFrame:g,stats:_,viewport:v,setViewport:y,quality:ee,chooseQuality:b,addressError:x,urlInput:S,send:C,streaming:w,openServer:T,openAgent:E,empty:D,navigate:O,actions:k}=s,te=n.find(e=>e.port===m),A=f?.stage===`streaming`&&f.adopted,j=u&&(l.state===`reconnecting`||l.state===`closed`),{content:ne,dim:re}=cn({transport:l.state,takenOver:d,empty:D,stage:f,hasFrame:g,lost:j,url:p,worktree:t.worktreePath}),ie=ln(ne,{servers:n,serverStates:r,agentLive:i,openServer:T,openAgent:E,actions:k});return(0,Y.jsxs)(`section`,{"data-slot":`preview-pane-body`,"aria-label":`Live preview`,className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,Y.jsx)(Zt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:te,agentLive:i===!0,agentShown:h,adopted:A,viewport:c?`fit`:v,quality:ee,compact:c,navEnabled:w,loading:f?.stage===`loading`,stats:w?_??{fps:0,kbps:0}:void 0,status:w?void 0:Sn(l,u,d!==void 0,f),urlInputRef:S,onSession:a,onNavigate:O,onBack:()=>C({t:`back`}),onForward:()=>C({t:`forward`}),onReload:e=>C({t:`reload`,...e?{ignoreCache:!0}:{}}),onPickServer:e=>T(e),onPickAgent:E,onViewport:y,onQuality:b,onCopyUrl:()=>gn(p),onStop:e=>C({t:`stop`,port:e}),onClose:o}),x?(0,Y.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:x}):null,(0,Y.jsx)(Tn,{transportState:s,overlay:ie,dim:re,lost:j})]})}function Tn({transportState:e,overlay:t,dim:n,lost:r}){let{connected:i,dialog:a,hasFrame:o,stage:s,stageHandle:c,compact:l,viewport:u,cursor:d,setStageSize:f,send:p,urlInput:m,transport:h,reconnect:g,setDialog:_}=e,v=s?.stage,y=i&&t===null&&!a;return(0,Y.jsxs)(Pt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,Y.jsx)(Mt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,Y.jsx)(ut,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,Y.jsx)(`div`,{"data-slot":`preview-overlay`,className:n&&o?`absolute inset-0 overflow-auto bg-background/85`:`absolute inset-0 overflow-auto bg-background`,children:t}):null,a?(0,Y.jsx)(ft,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function En(e){let{visibleEvents:t}=de(e);return(0,J.useMemo)(()=>{let e=new Map;for(let n of b(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function Dn(e){let t=En(e.run.id),n=le(e.run.id);return(0,Y.jsx)(xn,{...e,serverStates:t,agentLive:n})}export{Dn as ConnectedPreviewPane};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,b as n,h as r,m as i,p as a,w as o}from"./button-DGwhwRuD.js";import{i as s,t as c}from"./react-runtime-CCIEwYL0.js";import{r as l}from"./project-scope-context-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,b as n,h as r,m as i,p as a,w as o}from"./button-DGwhwRuD.js";import{i as s,t as c}from"./react-runtime-CCIEwYL0.js";import{r as l}from"./project-scope-context-BUXmC8my.js";var u=e(s(),1),d=c(),f=/^\/p\/([^/]+)(?=\/|$)/;function p(e){let t=f.exec(e)?.[1];return t===void 0?null:decodeURIComponent(t)}function m(e){let t=f.exec(e);if(!t)return e;let n=e.slice(t[0].length);return n===``?`/`:n}function h(e,t){return!t.startsWith(`/`)||t===`/p`||t.startsWith(`/p/`)?t:`/p/${encodeURIComponent(e)}${t}`}function g(e,t){return e===null?t:typeof t==`string`?h(e,t):t.pathname===void 0?t:{...t,pathname:h(e,t.pathname)}}function _(){let{projectId:e}=l(),{pathname:n}=t();return e??p(n)}function v(){let e=_();return(0,u.useCallback)(t=>g(e,t),[e])}function y(e){let{pathname:r}=t();return(0,u.useMemo)(()=>n(e,m(r)),[e,r])}function b({to:e,...t}){let n=v();return(0,d.jsx)(a,{...t,to:n(e)})}function x({to:e,...t}){let n=v();return(0,d.jsx)(i,{...t,to:n(e)})}function S({to:e,...t}){let n=v();return(0,d.jsx)(r,{...t,to:n(e)})}function C(){let e=o(),t=v();return(0,u.useMemo)(()=>((n,r)=>typeof n==`number`?e(n):e(t(n),r)),[e,t])}export{g as a,C as c,p as i,y as l,x as n,m as o,S as r,_ as s,b as t};
|