@wjarka/cezarion 0.18.0-dev.8161 → 0.18.0-dev.8167

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/package.json +2 -2
  2. package/web/dist/assets/{accounts-section-xFYT_zfY.js → accounts-section-CRiql0cT.js} +1 -1
  3. package/web/dist/assets/{activity-motion-OAYNqxZ2.js → activity-motion-Dic711r4.js} +1 -1
  4. package/web/dist/assets/{activity-route-cdDIR26F.js → activity-route-DkqFQfEX.js} +1 -1
  5. package/web/dist/assets/{agent-config-section-B8yx4Ftt.js → agent-config-section-pDXHYHXz.js} +1 -1
  6. package/web/dist/assets/{agent-defaults-section-BUJi0JBr.js → agent-defaults-section-D_d24TE0.js} +1 -1
  7. package/web/dist/assets/{appearance-L-Mcz7xt.js → appearance-BcCBqgn-.js} +1 -1
  8. package/web/dist/assets/{automations-route-DndFRPQ2.js → automations-route-fR3nMyuy.js} +1 -1
  9. package/web/dist/assets/{commit-diff-panel-uXKNbpAQ.js → commit-diff-panel-Ox2k_MeC.js} +1 -1
  10. package/web/dist/assets/{diff-DcmpXzlx.js → diff-B-6M-t3K.js} +2 -2
  11. package/web/dist/assets/{diff-view-Bu3mxoNK.js → diff-view-nrQTDxks.js} +1 -1
  12. package/web/dist/assets/{file-preview-DmLdg1Ak.js → file-preview-B3KVy73J.js} +1 -1
  13. package/web/dist/assets/{git-toolbar-CBMk5v-t.js → git-toolbar-TX4S_cYI.js} +1 -1
  14. package/web/dist/assets/github-DMMGSGqg.js +1 -0
  15. package/web/dist/assets/{global-activity-route-Rx7cgzpu.js → global-activity-route-c5c5Q00Y.js} +1 -1
  16. package/web/dist/assets/{index-CilVqe_c.js → index-DfmmHZB9.js} +4 -4
  17. package/web/dist/assets/{markdown-CoC8_Mxa.js → markdown-CH0W4B61.js} +1 -1
  18. package/web/dist/assets/{notifications-section-CRVfC723.js → notifications-section-bytadcE1.js} +1 -1
  19. package/web/dist/assets/{preview-pane-connected-BcePJL41.js → preview-pane-connected-Be0ZQ1QZ.js} +1 -1
  20. package/web/dist/assets/{projects-section-BzJOvGbU.js → projects-section-D2OikZvZ.js} +1 -1
  21. package/web/dist/assets/{prompt-templates-section-DCXEFZeZ.js → prompt-templates-section-BZQcqxyC.js} +1 -1
  22. package/web/dist/assets/{remote-settings-notice-B6gmSQmK.js → remote-settings-notice-B7vBsgJe.js} +1 -1
  23. package/web/dist/assets/{repo-git-f5cKDC-i.js → repo-git-4HLZT14I.js} +1 -1
  24. package/web/dist/assets/{report-reader-D_SwO-8H.js → report-reader-CmGgO12j.js} +1 -1
  25. package/web/dist/assets/{reports-CyP79G2S.js → reports-B-AxM1y5.js} +1 -1
  26. package/web/dist/assets/{run-header-CmEgf2OE.js → run-header-KmcjpBMq.js} +1 -1
  27. package/web/dist/assets/{settings-agent-picker-CIUuXcrv.js → settings-agent-picker-X-g0UKgD.js} +1 -1
  28. package/web/dist/assets/{settings-shell-DuQAKYA0.js → settings-shell-DEbkOTuH.js} +1 -1
  29. package/web/dist/assets/{skills-CBHa5_n1.js → skills-DkL4o5z5.js} +1 -1
  30. package/web/dist/assets/{task-changes-B-daTy0n.js → task-changes-DggkNS5B.js} +1 -1
  31. package/web/dist/assets/{task-commits-B8JcUxwa.js → task-commits-xhACNoGj.js} +1 -1
  32. package/web/dist/assets/{task-files-QGAAGN7K.js → task-files-CL76uaPp.js} +1 -1
  33. package/web/dist/assets/{task-github-item-BUQ-EaXP.js → task-github-item-CqID35v9.js} +1 -1
  34. package/web/dist/assets/{task-thread-BDXHF8cV.js → task-thread-BuX8KtlY.js} +1 -1
  35. package/web/dist/assets/{thread-state-CiVcAJSc.js → thread-state-dtADhBQ_.js} +1 -1
  36. package/web/dist/assets/{use-hand-to-agent-state-qYz6wj5e.js → use-hand-to-agent-state-BD10hMfn.js} +1 -1
  37. package/web/dist/assets/{workflows-CmaJn4ba.js → workflows-C2H-HfDa.js} +1 -1
  38. package/web/dist/assets/{workspace-tools-CJ8gOVwz.js → workspace-tools-Cyfz8V_L.js} +1 -1
  39. package/web/dist/assets/{worktrees-section-DmsaW6FZ.js → worktrees-section-Doo2MjMH.js} +1 -1
  40. package/web/dist/index.html +1 -1
  41. package/web/dist/assets/github-ktVA2Gmk.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{r}from"./utils-DSMR_WLb.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{d as a,f as o,p as s}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{Bt as c,Gt as l,Ht as ee,Kt as te,Ut as u,Vt as ne,Wt as d,qt as f}from"./index-CilVqe_c.js";import{i as p,n as m,s as h}from"./chunk-BO2N2NFS-DQrpGzb-.js";import{i as re,o as g,r as ie,t as _}from"./highlighter-DvLzHjjY.js";var v=e(t(),1),y=n();function b({isOpen:e,onClose:t,onConfirm:n,url:r}){return(0,y.jsx)(c,{open:e,onOpenChange:e=>{e||t()},children:(0,y.jsxs)(u,{"data-slot":`link-safety-dialog`,children:[(0,y.jsxs)(te,{children:[(0,y.jsx)(f,{children:`Open this link?`}),(0,y.jsxs)(d,{children:[`It leaves Squawk in a new tab. The words of a link in a transcript are the agent's — the address below is where it actually goes.`,(0,y.jsx)(`span`,{"data-slot":`link-safety-url`,className:`mt-3 block wrap-anywhere rounded-md border border-border bg-muted px-3 py-2 font-mono text-xs text-foreground`,children:r})]})]}),(0,y.jsxs)(l,{children:[(0,y.jsx)(ee,{children:`Cancel`}),(0,y.jsx)(ne,{onClick:n,children:`Open link`})]})]})})}var x=String.raw`https?:\/\/(?:cdn\.jsdelivr\.net\/npm|unpkg\.com)\/`,ae=[{id:`tailwind-v3`,script:/^https?:\/\/cdn\.tailwindcss\.com(?:\/[\d.]+)?\/?(?:[?#]|$)/i},{id:`tailwind`,script:new RegExp(String.raw`^${x}@tailwindcss\/browser@4(?:\.[.\d]*)?(?:\/dist\/index\.global(?:\.min)?\.js)?\/?(?:[?#]|$)`,`i`)},{id:`mermaid`,script:new RegExp(String.raw`^${x}mermaid@11(?:\.[.\d]*)?\/dist\/mermaid(?:\.esm)?(?:\.min)?\.m?js(?:[?#]|$)`,`i`)}],S=new RegExp(String.raw`(['"])(${x}mermaid@11(?:\.[.\d]*)?(?:\/dist\/mermaid(?:\.esm)?(?:\.min)?\.mjs|\/\+esm)?)\1`,`gi`);function C(e){let t=e.trim();return ae.find(e=>e.script.test(t))?.id??null}function w(e){let t=new DOMParser().parseFromString(e,`text/html`),n=new Set;for(let e of t.querySelectorAll(`script`)){let t=e.getAttribute(`src`),r=t===null?null:C(t);r&&n.add(r===`tailwind-v3`?`tailwind`:r).add(r),t===null&&e.getAttribute(`type`)===`module`&&(e.textContent??``).search(S)>=0&&n.add(`mermaid`),S.lastIndex=0}return[...n].sort()}var T={tailwind:async()=>(await i(()=>import(`./index.global-D3Ga_D3Y.js`),[])).default,"tailwind-v3":()=>Promise.resolve(le),mermaid:async()=>(await i(()=>import(`./mermaid.min-3O9YjB2l.js`),[])).default};async function oe(e){let t=await Promise.all(e.map(e=>T[e]().then(t=>[e,t],()=>null)));return Object.fromEntries(t.filter(e=>e!==null))}function se(){let e={colors:`color`,fontFamily:`font`,fontSize:`text`,fontWeight:`font-weight`,spacing:`spacing`,borderRadius:`radius`,boxShadow:`shadow`,dropShadow:`drop-shadow`,blur:`blur`,screens:`breakpoint`,letterSpacing:`tracking`,lineHeight:`leading`,maxWidth:`container`,animation:`animate`,aspectRatio:`aspect`},t=e=>typeof e==`object`&&!!e&&!Array.isArray(e),n=t=>Object.hasOwn(e,t)?e[t]:void 0,r=(e,n,i,a)=>{if(t(a)){for(let[t,o]of Object.entries(a))r(e,n,t===`DEFAULT`?i:i?`${i}-${t}`:t,o);return}let o=i?`--${n}-${i}`:`--${n}`;if(n===`text`&&Array.isArray(a)){e.push(`${o}: ${String(a[0])};`);let n=t(a[1])?a[1].lineHeight:a[1];typeof n==`string`&&e.push(`${o}--line-height: ${n};`);return}typeof a==`string`||typeof a==`number`?e.push(`${o}: ${a};`):Array.isArray(a)&&e.push(`${o}: ${a.join(`, `)};`)},i=e=>{let[t,n]=Array.isArray(e)?e:[e];if(t!==`class`&&t!==`selector`)return``;let r=typeof n==`string`?n:`.dark`;return`@custom-variant dark (&:where(${r}, ${r} *));\n`},a=e=>{let a=t(e)?e:{},o=t(a.theme)?a.theme:{},s=[];for(let[e,t]of Object.entries(o)){let i=n(e);i&&(s.push(`--${i}-*: initial;`),r(s,i,``,t))}for(let[e,i]of Object.entries(t(o.extend)?o.extend:{})){let t=n(e);t&&r(s,t,``,i)}return`${i(a.darkMode)}@theme {\n${s.join(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{r}from"./utils-DSMR_WLb.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{d as a,f as o,p as s}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{Bt as c,Gt as l,Ht as ee,Kt as te,Ut as u,Vt as ne,Wt as d,qt as f}from"./index-DfmmHZB9.js";import{i as p,n as m,s as h}from"./chunk-BO2N2NFS-DQrpGzb-.js";import{i as re,o as g,r as ie,t as _}from"./highlighter-DvLzHjjY.js";var v=e(t(),1),y=n();function b({isOpen:e,onClose:t,onConfirm:n,url:r}){return(0,y.jsx)(c,{open:e,onOpenChange:e=>{e||t()},children:(0,y.jsxs)(u,{"data-slot":`link-safety-dialog`,children:[(0,y.jsxs)(te,{children:[(0,y.jsx)(f,{children:`Open this link?`}),(0,y.jsxs)(d,{children:[`It leaves Squawk in a new tab. The words of a link in a transcript are the agent's — the address below is where it actually goes.`,(0,y.jsx)(`span`,{"data-slot":`link-safety-url`,className:`mt-3 block wrap-anywhere rounded-md border border-border bg-muted px-3 py-2 font-mono text-xs text-foreground`,children:r})]})]}),(0,y.jsxs)(l,{children:[(0,y.jsx)(ee,{children:`Cancel`}),(0,y.jsx)(ne,{onClick:n,children:`Open link`})]})]})})}var x=String.raw`https?:\/\/(?:cdn\.jsdelivr\.net\/npm|unpkg\.com)\/`,ae=[{id:`tailwind-v3`,script:/^https?:\/\/cdn\.tailwindcss\.com(?:\/[\d.]+)?\/?(?:[?#]|$)/i},{id:`tailwind`,script:new RegExp(String.raw`^${x}@tailwindcss\/browser@4(?:\.[.\d]*)?(?:\/dist\/index\.global(?:\.min)?\.js)?\/?(?:[?#]|$)`,`i`)},{id:`mermaid`,script:new RegExp(String.raw`^${x}mermaid@11(?:\.[.\d]*)?\/dist\/mermaid(?:\.esm)?(?:\.min)?\.m?js(?:[?#]|$)`,`i`)}],S=new RegExp(String.raw`(['"])(${x}mermaid@11(?:\.[.\d]*)?(?:\/dist\/mermaid(?:\.esm)?(?:\.min)?\.mjs|\/\+esm)?)\1`,`gi`);function C(e){let t=e.trim();return ae.find(e=>e.script.test(t))?.id??null}function w(e){let t=new DOMParser().parseFromString(e,`text/html`),n=new Set;for(let e of t.querySelectorAll(`script`)){let t=e.getAttribute(`src`),r=t===null?null:C(t);r&&n.add(r===`tailwind-v3`?`tailwind`:r).add(r),t===null&&e.getAttribute(`type`)===`module`&&(e.textContent??``).search(S)>=0&&n.add(`mermaid`),S.lastIndex=0}return[...n].sort()}var T={tailwind:async()=>(await i(()=>import(`./index.global-D3Ga_D3Y.js`),[])).default,"tailwind-v3":()=>Promise.resolve(le),mermaid:async()=>(await i(()=>import(`./mermaid.min-3O9YjB2l.js`),[])).default};async function oe(e){let t=await Promise.all(e.map(e=>T[e]().then(t=>[e,t],()=>null)));return Object.fromEntries(t.filter(e=>e!==null))}function se(){let e={colors:`color`,fontFamily:`font`,fontSize:`text`,fontWeight:`font-weight`,spacing:`spacing`,borderRadius:`radius`,boxShadow:`shadow`,dropShadow:`drop-shadow`,blur:`blur`,screens:`breakpoint`,letterSpacing:`tracking`,lineHeight:`leading`,maxWidth:`container`,animation:`animate`,aspectRatio:`aspect`},t=e=>typeof e==`object`&&!!e&&!Array.isArray(e),n=t=>Object.hasOwn(e,t)?e[t]:void 0,r=(e,n,i,a)=>{if(t(a)){for(let[t,o]of Object.entries(a))r(e,n,t===`DEFAULT`?i:i?`${i}-${t}`:t,o);return}let o=i?`--${n}-${i}`:`--${n}`;if(n===`text`&&Array.isArray(a)){e.push(`${o}: ${String(a[0])};`);let n=t(a[1])?a[1].lineHeight:a[1];typeof n==`string`&&e.push(`${o}--line-height: ${n};`);return}typeof a==`string`||typeof a==`number`?e.push(`${o}: ${a};`):Array.isArray(a)&&e.push(`${o}: ${a.join(`, `)};`)},i=e=>{let[t,n]=Array.isArray(e)?e:[e];if(t!==`class`&&t!==`selector`)return``;let r=typeof n==`string`?n:`.dark`;return`@custom-variant dark (&:where(${r}, ${r} *));\n`},a=e=>{let a=t(e)?e:{},o=t(a.theme)?a.theme:{},s=[];for(let[e,t]of Object.entries(o)){let i=n(e);i&&(s.push(`--${i}-*: initial;`),r(s,i,``,t))}for(let[e,i]of Object.entries(t(o.extend)?o.extend:{})){let t=n(e);t&&r(s,t,``,i)}return`${i(a.darkMode)}@theme {\n${s.join(`
2
2
  `)}\n}`},o=document.createElement(`style`);o.setAttribute(`type`,`text/tailwindcss`),document.currentScript?.before(o);let s={};Object.defineProperty(globalThis,"tailwind",{configurable:!0,value:{get config(){return s},set config(e){s=e,o.textContent=a(e)}}})}var ce=`(${se.toString()})()`,le=[`@import "tailwindcss/theme.css";@import "tailwindcss/preflight.css";@import "tailwindcss/utilities.css";`,`@theme{`,`--color-slate-50:#f8fafc;--color-slate-100:#f1f5f9;--color-slate-200:#e2e8f0;--color-slate-300:#cbd5e1;--color-slate-400:#94a3b8;--color-slate-500:#64748b;--color-slate-600:#475569;--color-slate-700:#334155;--color-slate-800:#1e293b;--color-slate-900:#0f172a;--color-slate-950:#020617;`,`--color-gray-50:#f9fafb;--color-gray-100:#f3f4f6;--color-gray-200:#e5e7eb;--color-gray-300:#d1d5db;--color-gray-400:#9ca3af;--color-gray-500:#6b7280;--color-gray-600:#4b5563;--color-gray-700:#374151;--color-gray-800:#1f2937;--color-gray-900:#111827;--color-gray-950:#030712;`,`--color-zinc-50:#fafafa;--color-zinc-100:#f4f4f5;--color-zinc-200:#e4e4e7;--color-zinc-300:#d4d4d8;--color-zinc-400:#a1a1aa;--color-zinc-500:#71717a;--color-zinc-600:#52525b;--color-zinc-700:#3f3f46;--color-zinc-800:#27272a;--color-zinc-900:#18181b;--color-zinc-950:#09090b;`,`--color-neutral-50:#fafafa;--color-neutral-100:#f5f5f5;--color-neutral-200:#e5e5e5;--color-neutral-300:#d4d4d4;--color-neutral-400:#a3a3a3;--color-neutral-500:#737373;--color-neutral-600:#525252;--color-neutral-700:#404040;--color-neutral-800:#262626;--color-neutral-900:#171717;--color-neutral-950:#0a0a0a;`,`--color-stone-50:#fafaf9;--color-stone-100:#f5f5f4;--color-stone-200:#e7e5e4;--color-stone-300:#d6d3d1;--color-stone-400:#a8a29e;--color-stone-500:#78716c;--color-stone-600:#57534e;--color-stone-700:#44403c;--color-stone-800:#292524;--color-stone-900:#1c1917;--color-stone-950:#0c0a09;`,`--color-red-50:#fef2f2;--color-red-100:#fee2e2;--color-red-200:#fecaca;--color-red-300:#fca5a5;--color-red-400:#f87171;--color-red-500:#ef4444;--color-red-600:#dc2626;--color-red-700:#b91c1c;--color-red-800:#991b1b;--color-red-900:#7f1d1d;--color-red-950:#450a0a;`,`--color-orange-50:#fff7ed;--color-orange-100:#ffedd5;--color-orange-200:#fed7aa;--color-orange-300:#fdba74;--color-orange-400:#fb923c;--color-orange-500:#f97316;--color-orange-600:#ea580c;--color-orange-700:#c2410c;--color-orange-800:#9a3412;--color-orange-900:#7c2d12;--color-orange-950:#431407;`,`--color-amber-50:#fffbeb;--color-amber-100:#fef3c7;--color-amber-200:#fde68a;--color-amber-300:#fcd34d;--color-amber-400:#fbbf24;--color-amber-500:#f59e0b;--color-amber-600:#d97706;--color-amber-700:#b45309;--color-amber-800:#92400e;--color-amber-900:#78350f;--color-amber-950:#451a03;`,`--color-yellow-50:#fefce8;--color-yellow-100:#fef9c3;--color-yellow-200:#fef08a;--color-yellow-300:#fde047;--color-yellow-400:#facc15;--color-yellow-500:#eab308;--color-yellow-600:#ca8a04;--color-yellow-700:#a16207;--color-yellow-800:#854d0e;--color-yellow-900:#713f12;--color-yellow-950:#422006;`,`--color-lime-50:#f7fee7;--color-lime-100:#ecfccb;--color-lime-200:#d9f99d;--color-lime-300:#bef264;--color-lime-400:#a3e635;--color-lime-500:#84cc16;--color-lime-600:#65a30d;--color-lime-700:#4d7c0f;--color-lime-800:#3f6212;--color-lime-900:#365314;--color-lime-950:#1a2e05;`,`--color-green-50:#f0fdf4;--color-green-100:#dcfce7;--color-green-200:#bbf7d0;--color-green-300:#86efac;--color-green-400:#4ade80;--color-green-500:#22c55e;--color-green-600:#16a34a;--color-green-700:#15803d;--color-green-800:#166534;--color-green-900:#14532d;--color-green-950:#052e16;`,`--color-emerald-50:#ecfdf5;--color-emerald-100:#d1fae5;--color-emerald-200:#a7f3d0;--color-emerald-300:#6ee7b7;--color-emerald-400:#34d399;--color-emerald-500:#10b981;--color-emerald-600:#059669;--color-emerald-700:#047857;--color-emerald-800:#065f46;--color-emerald-900:#064e3b;--color-emerald-950:#022c22;`,`--color-teal-50:#f0fdfa;--color-teal-100:#ccfbf1;--color-teal-200:#99f6e4;--color-teal-300:#5eead4;--color-teal-400:#2dd4bf;--color-teal-500:#14b8a6;--color-teal-600:#0d9488;--color-teal-700:#0f766e;--color-teal-800:#115e59;--color-teal-900:#134e4a;--color-teal-950:#042f2e;`,`--color-cyan-50:#ecfeff;--color-cyan-100:#cffafe;--color-cyan-200:#a5f3fc;--color-cyan-300:#67e8f9;--color-cyan-400:#22d3ee;--color-cyan-500:#06b6d4;--color-cyan-600:#0891b2;--color-cyan-700:#0e7490;--color-cyan-800:#155e75;--color-cyan-900:#164e63;--color-cyan-950:#083344;`,`--color-sky-50:#f0f9ff;--color-sky-100:#e0f2fe;--color-sky-200:#bae6fd;--color-sky-300:#7dd3fc;--color-sky-400:#38bdf8;--color-sky-500:#0ea5e9;--color-sky-600:#0284c7;--color-sky-700:#0369a1;--color-sky-800:#075985;--color-sky-900:#0c4a6e;--color-sky-950:#082f49;`,`--color-blue-50:#eff6ff;--color-blue-100:#dbeafe;--color-blue-200:#bfdbfe;--color-blue-300:#93c5fd;--color-blue-400:#60a5fa;--color-blue-500:#3b82f6;--color-blue-600:#2563eb;--color-blue-700:#1d4ed8;--color-blue-800:#1e40af;--color-blue-900:#1e3a8a;--color-blue-950:#172554;`,`--color-indigo-50:#eef2ff;--color-indigo-100:#e0e7ff;--color-indigo-200:#c7d2fe;--color-indigo-300:#a5b4fc;--color-indigo-400:#818cf8;--color-indigo-500:#6366f1;--color-indigo-600:#4f46e5;--color-indigo-700:#4338ca;--color-indigo-800:#3730a3;--color-indigo-900:#312e81;--color-indigo-950:#1e1b4b;`,`--color-violet-50:#f5f3ff;--color-violet-100:#ede9fe;--color-violet-200:#ddd6fe;--color-violet-300:#c4b5fd;--color-violet-400:#a78bfa;--color-violet-500:#8b5cf6;--color-violet-600:#7c3aed;--color-violet-700:#6d28d9;--color-violet-800:#5b21b6;--color-violet-900:#4c1d95;--color-violet-950:#2e1065;`,`--color-purple-50:#faf5ff;--color-purple-100:#f3e8ff;--color-purple-200:#e9d5ff;--color-purple-300:#d8b4fe;--color-purple-400:#c084fc;--color-purple-500:#a855f7;--color-purple-600:#9333ea;--color-purple-700:#7e22ce;--color-purple-800:#6b21a8;--color-purple-900:#581c87;--color-purple-950:#3b0764;`,`--color-fuchsia-50:#fdf4ff;--color-fuchsia-100:#fae8ff;--color-fuchsia-200:#f5d0fe;--color-fuchsia-300:#f0abfc;--color-fuchsia-400:#e879f9;--color-fuchsia-500:#d946ef;--color-fuchsia-600:#c026d3;--color-fuchsia-700:#a21caf;--color-fuchsia-800:#86198f;--color-fuchsia-900:#701a75;--color-fuchsia-950:#4a044e;`,`--color-pink-50:#fdf2f8;--color-pink-100:#fce7f3;--color-pink-200:#fbcfe8;--color-pink-300:#f9a8d4;--color-pink-400:#f472b6;--color-pink-500:#ec4899;--color-pink-600:#db2777;--color-pink-700:#be185d;--color-pink-800:#9d174d;--color-pink-900:#831843;--color-pink-950:#500724;`,`--color-rose-50:#fff1f2;--color-rose-100:#ffe4e6;--color-rose-200:#fecdd3;--color-rose-300:#fda4af;--color-rose-400:#fb7185;--color-rose-500:#f43f5e;--color-rose-600:#e11d48;--color-rose-700:#be123c;--color-rose-800:#9f1239;--color-rose-900:#881337;--color-rose-950:#4c0519;`,`--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";`,`--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;`,`--text-xs--line-height:1rem;--text-sm--line-height:1.25rem;--text-base--line-height:1.5rem;--text-lg--line-height:1.75rem;`,`--text-xl--line-height:1.75rem;--text-2xl--line-height:2rem;--text-3xl--line-height:2.25rem;--text-4xl--line-height:2.5rem;`,`--shadow-sm:0 1px 2px 0 rgb(0 0 0 / 0.05);--radius-sm:0.125rem;--blur-sm:4px;`,`}`,`body{line-height:inherit}`,`*,::after,::before,::backdrop,::file-selector-button{border-color:var(--color-gray-200,currentColor)}`,`input::placeholder,textarea::placeholder{color:var(--color-gray-400)}`,`button:not(:disabled),[role="button"]:not(:disabled){cursor:pointer}`].join(`
3
3
  `),E=`default-src 'none'; script-src 'unsafe-inline' data:; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:; form-action 'none'; base-uri 'none'`,ue=`${E}; frame-src 'none'`,D=`allow-scripts allow-popups allow-popups-to-escape-sandbox`,O=`clipboard-write`,k=`data:text/javascript,export%20default%20globalThis.mermaid`;function A(e){return/\.html?$/i.test(e)}var j=/^(?:https?:|mailto:)/i,M=/^data:/i,N=`http://www.w3.org/1999/xlink`,P=/^(?:[a-z][a-z\d+.-]*:|\/\/)/i,F=/url\(\s*(['"]?)([^'")]*)\1\s*\)|@import\s+(['"])([^'"]+)\3/gi,I=[`src`,`href`,`xlink:href`,`poster`,`background`],L=/(?:^|,)\s*(data:\S+|[^,\s]+)/gi,R=/\b(?:preconnect|dns-prefetch|prefetch|preload|modulepreload|prerender)\b/i;function z(e,t){let n=e.trim();!n||n.startsWith(`#`)||M.test(n)||(P.test(n)?t.remote++:t.relative++)}function B(e,t){for(let n of e.matchAll(F))z(n[2]??n[4]??``,t)}function V(e,t){let n=e.createElement(`script`);return n.textContent=t.replace(/<\/script/gi,`<\\/script`),n}function H(e,t){let n=e.createElement(`style`);return n.setAttribute(`type`,`text/tailwindcss`),n.textContent=t,n}var U=`http://www.w3.org/2000/svg`;function de(e){return e.namespaceURI===U?e.getAttribute(`href`)??e.getAttributeNS(N,`href`):e.getAttribute(`src`)}function fe(e,t,n,r){let i=r===void 0?[]:[H(e,r),V(e,ce)],a=V(e,n),o=t.hasAttribute(`defer`)||t.hasAttribute(`async`)||t.getAttribute(`type`)===`module`;o&&e.body.append(a),t.replaceWith(...i,...o?[]:[a])}function W(e,t,n){let r=new Set,i=new Set;for(let a of[...e.querySelectorAll(`script`)]){let o=de(a);if(o!==null&&M.test(o.trim()))continue;if(o===null){if(a.getAttribute(`type`)===`module`)for(let e of(a.textContent??``).matchAll(S))i.add(e[2]);continue}let s=C(o),c=s===`tailwind-v3`?`tailwind`:s,l=c?n[c]:void 0;if(!c||l===void 0||s===`tailwind-v3`&&n[`tailwind-v3`]===void 0){t.scripts++,a.remove();continue}if(r.has(c)){a.remove();continue}r.add(c),fe(e,a,l,s===`tailwind-v3`?n[`tailwind-v3`]:void 0)}if(!i.size)return;if(n.mermaid===void 0){t.scripts+=i.size;return}let a=e.createElement(`script`);a.setAttribute(`type`,`importmap`),a.textContent=JSON.stringify({imports:Object.fromEntries([...i].map(e=>[e,k]))}),e.head.prepend(a,...r.has(`mermaid`)?[]:[V(e,n.mermaid)])}function pe(e,t,n){let r=t=>{let n=[...e.querySelectorAll(t)];return n.forEach(e=>e.remove()),n.length};W(e,t,n),t.embeds=r(`iframe, frame, frameset, object, embed, portal`),r(`base, meta[http-equiv]`);for(let t of e.querySelectorAll(`link`))R.test(t.getAttribute(`rel`)??``)&&t.remove();for(let t of e.querySelectorAll(`[ping]`))t.removeAttribute(`ping`);for(let n of e.querySelectorAll(`form`))t.forms++,n.removeAttribute(`action`);for(let t of e.querySelectorAll(`[formaction]`))t.removeAttribute(`formaction`)}function me(e,t){for(let n of e.querySelectorAll(`a, area`)){let e=n.getAttribute(`href`)??n.getAttributeNS(N,`href`);if(e===null)continue;let r=e.trim();if(r.startsWith(`#`)){n.setAttribute(`href`,`about:srcdoc${r}`),n.removeAttributeNS(N,`href`),n.removeAttribute(`target`);continue}if(j.test(r)){n.setAttribute(`target`,`_blank`),n.setAttribute(`rel`,`noopener noreferrer`);continue}P.test(r)||t.relative++,n.removeAttribute(`href`),n.removeAttributeNS(N,`href`),n.removeAttribute(`target`)}}function he(e,t){for(let n of e.querySelectorAll(`[style]`))B(n.getAttribute(`style`),t);for(let n of e.querySelectorAll(`style`))/^(?:text\/css)?$/i.test(n.getAttribute(`type`)?.trim()??``)&&B(n.textContent??``,t);for(let n of e.querySelectorAll(`link[href]`))z(n.getAttribute(`href`),t);for(let n of e.querySelectorAll(`img, source, video, audio, track, input, image, use, body, table, td`)){for(let e of I){let r=n.getAttribute(e);r!==null&&z(r,t)}for(let e of(n.getAttribute(`srcset`)??``).matchAll(L))z(e[1],t)}}function ge(e,t={}){let n=new DOMParser().parseFromString(e,`text/html`),r={scripts:0,remote:0,relative:0,forms:0,embeds:0};pe(n,r,t),me(n,r),he(n,r);let i=n.createElement(`meta`);i.setAttribute(`http-equiv`,`Content-Security-Policy`),i.setAttribute(`content`,E);let a=n.createElement(`meta`);return a.setAttribute(`name`,`referrer`),a.setAttribute(`content`,`no-referrer`),n.head.prepend(i,a),{srcdoc:`<!DOCTYPE html>${n.documentElement.outerHTML}`,blocked:r}}var G=e=>e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`);function _e(e,t){return`<!DOCTYPE html><html><head><meta http-equiv="Content-Security-Policy" content="${ue}"><meta name="referrer" content="no-referrer"><style>html,body{margin:0;height:100%;overflow:hidden}iframe{display:block;border:0;width:100%;height:100%}</style></head><body><iframe title="${G(t)}" sandbox="${D}" allow="${O}" referrerpolicy="no-referrer" srcdoc="${G(e)}"></iframe></body></html>`}var K=(0,v.createContext)(null),ve=/^[0-9a-f-]{36}$/i,ye=/^(\/p\/[^/?#]+\/tasks\/[^/?#]+)\/files\?(artifact=[^&#]*)$/;function q(e){let t=new URLSearchParams(e);return[...t.keys()].length===1&&ve.test(t.get(`artifact`)??``)}function be(e,t,n){if(e.startsWith(`${t}?artifact=`))return q(e.slice(t.length+1))?n+e.slice(t.length):null;let r=ye.exec(e);return r&&q(r[2])?`${r[1]}/report?${r[2]}`:void 0}var xe=/^\/(?:api|p|tasks|new|settings|skills|workflows|git|github|inbox|automations)(?:\/|[?#]|$)/;function Se(e,t){let n=/^[a-z]:[\\/]/i.test(e),r=/^file:/i.test(e);if(!n&&/^[a-z][a-z\d+.-]*:/i.test(e)&&!r)return null;let i=r?e:decodeURIComponent(e);if(/[\u0000-\u001f]/.test(i))return null;if(!t||i.startsWith(`/`)||n||r)return i;let a=t.replaceAll(`\\`,`/`);return a.slice(0,a.lastIndexOf(`/`)+1)+i}function J(e,t){if(!e||/[\u0000-\u001f]/.test(e)||e.startsWith(`#`)||e.startsWith(`//`))return null;let n=e.indexOf(`#`),r=n<0?e:e.slice(0,n),i=n<0?``:e.slice(n),a=t.projectId?`/p/${encodeURIComponent(t.projectId)}`:``,o=`/tasks/${encodeURIComponent(t.runId)}/files`,s=`/tasks/${encodeURIComponent(t.runId)}/report`,c=be(r,o,a+s);if(c!==void 0)return c===null?null:c+i;if(xe.test(r))return null;let l=Se(r,t.basePath);return l===null?null:`${a}${A(l)?s:o}?path=${encodeURIComponent(l)}${i}`}var Y=`text-accent-text underline underline-offset-2`;function Ce({href:e,children:t,internal:n,...r}){let[i,o]=(0,v.useState)(!1),s=a();return e?n?s?(0,y.jsx)(we,{...r,href:e,children:t}):(0,y.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:Y,children:t}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:`cursor-pointer ${Y}`,onClick:e=>{e.preventDefault(),o(!0)},children:t}),(0,y.jsx)(b,{isOpen:i,url:e,onClose:()=>o(!1),onConfirm:()=>{window.open(e,`_blank`,`noreferrer`),o(!1)}})]}):(0,y.jsx)(`span`,{children:t})}function we({href:e,children:t,...n}){let r=s(),i=o();return(0,y.jsx)(`a`,{...n,href:e,"data-streamdown":`link`,className:Y,onClick:t=>X(t,r,e,i),children:t})}function X(e,t,n,r){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t(n,{state:{readerFrom:r.pathname+r.search,filesRestoreKey:r.key}}))}var Te={name:`shiki`,type:`code-highlighter`,getThemes:()=>[_,_],getSupportedLanguages:()=>g(),supportsLanguage:e=>g().includes(String(e).toLowerCase()),highlight:({code:e,language:t},n)=>re(e,String(t))||(ie(e,String(t)).then(e=>n?.(e)),null)};function Ee(){let e=t=>{if(!t.children)return;let n=[];for(let r of t.children)if(r.type===`text`&&r.value?.includes(`
4
4
  `)){let e=r.value.split(/\r?\n/);e.forEach((t,r)=>{r>0&&!(t===``&&r===e.length-1)&&n.push({type:`break`}),t&&n.push({type:`text`,value:t})})}else e(r),n.push(r);t.children=n};return e}var Z=[...Object.values(m),Ee],De=[`p`,`strong`,`em`,`del`,`code`,`a`],Oe={p:`span`,a:`span`},ke={enabled:!0,renderModal:e=>(0,y.jsx)(b,{...e})},Ae=`https://refused.invalid/`,Q=new WeakSet;function $(e){let t=e.position?.start.offset,n=e.position?.end.offset;return t===void 0||n===void 0?null:`${t}:${n}`}function je(e){return(t,n)=>{let r=new Set,i=new Map,a=t=>{if((t.type===`link`||t.type===`definition`)&&t.url){let n=J(t.url,e);if(t.type===`definition`&&t.identifier&&!i.has(t.identifier)&&i.set(t.identifier,n!==null),n){t.url=n;let e=$(t);t.type===`link`&&e!==null&&r.add(e)}}t.children?.forEach(a)};a(t);let o=e=>{let t=$(e);e.type===`linkReference`&&e.identifier&&i.get(e.identifier)&&t!==null&&r.add(t),e.children?.forEach(o)};o(t),n.data.taskLinks=r}}function Me(){return(e,t)=>{let n=e=>{let r=$(e);e.tagName===`a`&&r!==null&&t.data.taskLinks instanceof Set&&t.data.taskLinks.has(r)&&Q.add(e),e.children?.forEach(n)};n(e)}}var Ne=0,Pe=(0,v.memo)(function({children:e,breaks:t=!1,inline:n=!1,document:i=!1,imageSrc:a}){let o=(0,v.useContext)(K),s=(0,v.useMemo)(()=>{let e={instance:++Ne},n=new Set;function r(){let e=t=>{if(t.type===`image`&&t.url&&a){let e=a(t.url);t.url=e?new URL(e,window.location.href).href:Ae,e&&n.add(t.url)}t.children?.forEach(e)};return e}let s=o?[[je,o]]:[],c=i&&a?[[r,e]]:[];return{remark:[...t?Z:Object.values(m),...s,...c],components:{...o||i?{a:({href:e,children:t,node:n})=>i&&!o&&!/^(?:https?:|mailto:|#)/i.test(e??``)?(0,y.jsx)(`span`,{children:t}):(0,y.jsx)(Ce,{href:e,internal:n!==void 0&&Q.has(n),children:t})}:{},...i?{img:({src:e,alt:t})=>typeof e==`string`&&n.has(e)?(0,y.jsx)(`img`,{src:e,alt:t??``,loading:`lazy`}):(0,y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`[Image: `,t||`embedded image`,`]`]})}:{}}}},[o,t,i,a]);return(0,y.jsx)(p,{className:n?`thread-markdown thread-markdown-inline`:`thread-markdown`,plugins:{code:Te},shikiTheme:[_,_],...r({rehypePlugins:o?[...Object.values(h),Me]:void 0,remarkPlugins:o||i&&a?s.remark:t?Z:void 0,allowedElements:n?De:void 0,unwrapDisallowed:n||void 0,components:n?Oe:o||i?s.components:void 0}),linkSafety:ke,controls:{code:{copy:!0,download:!1},table:!1,mermaid:!1},lineNumbers:!1,children:e})});export{O as a,ge as c,oe as d,J as i,_e as l,X as n,D as o,K as r,A as s,Pe as t,w as u};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Yt as r,ci as i}from"./project-scope-context-DqBHMdSb.js";import{Nt as a,jt as o}from"./queries-DeeY9cGJ.js";import{n as s}from"./toaster-Bo5vCbz-.js";import{t as c}from"./switch-Bv2Zf1uU.js";import{ct as l,lt as u}from"./index-CilVqe_c.js";var d=e(t(),1),f=n();function p(){let e=i(),t=o(),[n,p]=d.useState(!1),[m,h]=d.useState(u),g=t.data;d.useEffect(()=>{g!==void 0&&p(l(g.notifications).enabled)},[g]);let _=d.useCallback(t=>{p(t),r({notifications:{enabled:t}}).then(t=>e.setQueryData(a.uiState,t)).catch(t=>{s(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:a.uiState})})},[e]),v=d.useCallback(e=>{if(!e){_(!1);return}if(u()!=="default"){_(!0);return}_(!0),Notification.requestPermission().then(e=>h(e)).catch(()=>h(u()))},[_]),y=m===`unsupported`;return(0,f.jsx)(`div`,{"data-slot":`notifications-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,f.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,f.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:(0,f.jsx)(`label`,{htmlFor:`notifications-enabled`,children:`Notify when an agent needs you`})}),(0,f.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`A browser notification when a task starts waiting, asks for review, or fails — only while this tab is in the background. Off by default.`})]}),(0,f.jsx)(c,{id:`notifications-enabled`,"data-slot":`notifications-toggle`,checked:n,disabled:y,onCheckedChange:v})]}),y?null:(0,f.jsxs)(`p`,{"data-slot":`notifications-permission`,"data-permission":m,className:`mt-4 text-[13px] text-muted-foreground`,children:[`Browser permission · `,m===`granted`?`Allowed`:m===`denied`?`Blocked`:`Not requested`]}),(0,f.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Permission is requested only when you enable notifications.`}),y?(0,f.jsx)(`p`,{"data-slot":`notifications-unsupported`,className:`text-[13px] text-muted-foreground`,children:`This browser does not support notifications, so the toggle is unavailable here.`}):null,!y&&n&&m===`denied`?(0,f.jsxs)(`div`,{"data-slot":`notifications-denied`,className:`mt-5 flex flex-col gap-2`,children:[(0,f.jsx)(`h3`,{className:`text-sm`,children:`Allow notifications in your browser`}),(0,f.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`This browser is blocking notifications. Your preference is saved. Allow notifications in the browser’s site settings to receive them.`}),(0,f.jsx)(`p`,{className:`settings-readout`,children:`Notifications are blocked for this site.`})]}):null]})})}export{p as NotificationsSection};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Yt as r,ci as i}from"./project-scope-context-DqBHMdSb.js";import{Nt as a,jt as o}from"./queries-DeeY9cGJ.js";import{n as s}from"./toaster-Bo5vCbz-.js";import{t as c}from"./switch-Bv2Zf1uU.js";import{ct as l,lt as u}from"./index-DfmmHZB9.js";var d=e(t(),1),f=n();function p(){let e=i(),t=o(),[n,p]=d.useState(!1),[m,h]=d.useState(u),g=t.data;d.useEffect(()=>{g!==void 0&&p(l(g.notifications).enabled)},[g]);let _=d.useCallback(t=>{p(t),r({notifications:{enabled:t}}).then(t=>e.setQueryData(a.uiState,t)).catch(t=>{s(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:a.uiState})})},[e]),v=d.useCallback(e=>{if(!e){_(!1);return}if(u()!=="default"){_(!0);return}_(!0),Notification.requestPermission().then(e=>h(e)).catch(()=>h(u()))},[_]),y=m===`unsupported`;return(0,f.jsx)(`div`,{"data-slot":`notifications-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,f.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,f.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:(0,f.jsx)(`label`,{htmlFor:`notifications-enabled`,children:`Notify when an agent needs you`})}),(0,f.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`A browser notification when a task starts waiting, asks for review, or fails — only while this tab is in the background. Off by default.`})]}),(0,f.jsx)(c,{id:`notifications-enabled`,"data-slot":`notifications-toggle`,checked:n,disabled:y,onCheckedChange:v})]}),y?null:(0,f.jsxs)(`p`,{"data-slot":`notifications-permission`,"data-permission":m,className:`mt-4 text-[13px] text-muted-foreground`,children:[`Browser permission · `,m===`granted`?`Allowed`:m===`denied`?`Blocked`:`Not requested`]}),(0,f.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Permission is requested only when you enable notifications.`}),y?(0,f.jsx)(`p`,{"data-slot":`notifications-unsupported`,className:`text-[13px] text-muted-foreground`,children:`This browser does not support notifications, so the toggle is unavailable here.`}):null,!y&&n&&m===`denied`?(0,f.jsxs)(`div`,{"data-slot":`notifications-denied`,className:`mt-5 flex flex-col gap-2`,children:[(0,f.jsx)(`h3`,{className:`text-sm`,children:`Allow notifications in your browser`}),(0,f.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`This browser is blocking notifications. Your preference is saved. Allow notifications in the browser’s site settings to receive them.`}),(0,f.jsx)(`p`,{className:`settings-readout`,children:`Notifications are blocked for this site.`})]}):null]})})}export{p as NotificationsSection};
@@ -1,3 +1,3 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{Gr as i,Kr as a,Wr as o,lr as s}from"./project-scope-context-DqBHMdSb.js";import{n as c}from"./toaster-Bo5vCbz-.js";import{t as l}from"./createLucideIcon-BHp8sXmF.js";import{t as u}from"./arrow-right-Dh_Lx3um.js";import{r as d}from"./dist-C28wFbz0.js";import{t as f}from"./chevron-down-CHGyCDBH.js";import{n as p,r as m,t as h}from"./hourglass-B0lPAJvT.js";import{n as g,t as _}from"./smartphone-Lr8Ug2z_.js";import{t as v}from"./info-DA1x_4bz.js";import{a as y}from"./format-BNCkW110.js";import{n as b,t as x}from"./moon-CRE9nU5R.js";import{t as S}from"./play-CmVAj_fu.js";import{d as C,l as w,n as ee,u as T}from"./thread-state-CiVcAJSc.js";import{t as E}from"./square-terminal-B6RYYieR.js";import{t as D}from"./button-BQ2y4XRB.js";import{a as O,c as te,i as k,l as A,p as j,r as M,s as ne,t as N}from"./dropdown-menu-4e2iKSMT.js";import{s as re}from"./project-router-CYJwJlJL.js";import{t as P}from"./status-dot-DtAOFiIi.js";import{$n as F,Dn as ie,En as ae,On as oe,Qn as se,Tn as ce,Wn as le,_ as ue,c as de,d as fe,er as pe,f as I,g as me,l as he,p as ge,qn as _e,u as ve,v as ye}from"./index-CilVqe_c.js";var be=l(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),xe=l(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Se=l(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),L=l(`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`}]]),R=l(`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`}]]),z=l(`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`}]]),B=l(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Ce=l(`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`}]]),we=l(`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`}]]),V=l(`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`}]]),H=l(`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`}]]),U=l(`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`}]]),W=l(`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`}]]),G=l(`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`}]]),K=l(`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=l(`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=l(`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`}]]),q=l(`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`}]]),De=l(`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(t(),1),Oe=1e3,ke=[500,1e3,2e3,4e3,8e3],Ae=1;function je(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}`,a=null,c,l=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||o(),m=()=>{if(l||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,a=n,n.addEventListener(`open`,()=>{n===a&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==a)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=s.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!==a||l)return;if(a=null,!u){if(d+=1,d>=2){l=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),c=setTimeout(m,Oe);return}if(f>=5){l=!0,t.onTransport(`closed`);return}let e=ke[Math.min(f,ke.length-1)];f+=1,t.onTransport(`reconnecting`,f),c=setTimeout(m,e)})},h=i(e=>{if(!l)if(e)a||m();else{clearTimeout(c),c=void 0;let e=a;a=null,e?.close()}});return t.onTransport(`connecting`),m(),{send(e){a?.readyState===Ae&&a.send(JSON.stringify(e))},close(){l=!0,h(),clearTimeout(c),c=void 0;let e=a;a=null,e?.close()}}}var Y=n();function Me({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(ie,{children:(0,Y.jsxs)(ce,{children:[(0,Y.jsx)(oe,{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)(R,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(ae,{children:`Experimental`})]})}):e?(0,Y.jsx)(ie,{children:(0,Y.jsxs)(ce,{children:[(0,Y.jsx)(oe,{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)(R,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(ae,{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)(R,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function Ne({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{Gr as i,Kr as a,Wr as o,lr as s}from"./project-scope-context-DqBHMdSb.js";import{n as c}from"./toaster-Bo5vCbz-.js";import{t as l}from"./createLucideIcon-BHp8sXmF.js";import{t as u}from"./arrow-right-Dh_Lx3um.js";import{r as d}from"./dist-C28wFbz0.js";import{t as f}from"./chevron-down-CHGyCDBH.js";import{n as p,r as m,t as h}from"./hourglass-B0lPAJvT.js";import{n as g,t as _}from"./smartphone-Lr8Ug2z_.js";import{t as v}from"./info-DA1x_4bz.js";import{a as y}from"./format-BNCkW110.js";import{n as b,t as x}from"./moon-CRE9nU5R.js";import{t as S}from"./play-CmVAj_fu.js";import{d as C,l as w,n as ee,u as T}from"./thread-state-dtADhBQ_.js";import{t as E}from"./square-terminal-B6RYYieR.js";import{t as D}from"./button-BQ2y4XRB.js";import{a as O,c as te,i as k,l as A,p as j,r as M,s as ne,t as N}from"./dropdown-menu-4e2iKSMT.js";import{s as re}from"./project-router-CYJwJlJL.js";import{t as P}from"./status-dot-DtAOFiIi.js";import{$n as F,Dn as ie,En as ae,On as oe,Qn as se,Tn as ce,Wn as le,_ as ue,c as de,d as fe,er as pe,f as I,g as me,l as he,p as ge,qn as _e,u as ve,v as ye}from"./index-DfmmHZB9.js";var be=l(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),xe=l(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Se=l(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),L=l(`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`}]]),R=l(`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`}]]),z=l(`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`}]]),B=l(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Ce=l(`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`}]]),we=l(`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`}]]),V=l(`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`}]]),H=l(`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`}]]),U=l(`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`}]]),W=l(`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`}]]),G=l(`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`}]]),K=l(`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=l(`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=l(`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`}]]),q=l(`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`}]]),De=l(`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(t(),1),Oe=1e3,ke=[500,1e3,2e3,4e3,8e3],Ae=1;function je(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}`,a=null,c,l=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||o(),m=()=>{if(l||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,a=n,n.addEventListener(`open`,()=>{n===a&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==a)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=s.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!==a||l)return;if(a=null,!u){if(d+=1,d>=2){l=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),c=setTimeout(m,Oe);return}if(f>=5){l=!0,t.onTransport(`closed`);return}let e=ke[Math.min(f,ke.length-1)];f+=1,t.onTransport(`reconnecting`,f),c=setTimeout(m,e)})},h=i(e=>{if(!l)if(e)a||m();else{clearTimeout(c),c=void 0;let e=a;a=null,e?.close()}});return t.onTransport(`connecting`),m(),{send(e){a?.readyState===Ae&&a.send(JSON.stringify(e))},close(){l=!0,h(),clearTimeout(c),c=void 0;let e=a;a=null,e?.close()}}}var Y=n();function Me({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(ie,{children:(0,Y.jsxs)(ce,{children:[(0,Y.jsx)(oe,{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)(R,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(ae,{children:`Experimental`})]})}):e?(0,Y.jsx)(ie,{children:(0,Y.jsxs)(ce,{children:[(0,Y.jsx)(oe,{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)(R,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(ae,{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)(R,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function Ne({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
2
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)(F,{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 Pe=/^([a-z][a-z0-9+.-]*):/i;function Fe(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=Pe.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.`}:Ie(n):Ie(`http://${n}`)}function Ie(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 Le(e){return e.replace(/^https?:\/\//i,``)}var Re=`https://github.com/hearsay-tools/squawk#environment-variables`;function ze({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,Y.jsx)(Ue,{state:e,actions:t});case`downloading`:return(0,Y.jsx)(Ge,{state:e,actions:t});case`download-failed`:return(0,Y.jsx)(Ke,{state:e,actions:t});case`sandbox-failed`:return(0,Y.jsx)(qe,{state:e,actions:t});case`browser-exited`:return(0,Y.jsx)(Je,{state:e,actions:t});case`needs-approval`:return(0,Y.jsx)(Ze,{state:e,actions:t});case`port-held`:return(0,Y.jsx)(Qe,{state:e,actions:t});case`server-starting`:return(0,Y.jsx)($e,{state:e,actions:t});case`server-stalled`:return(0,Y.jsx)(et,{state:e,actions:t});case`server-exited`:return(0,Y.jsx)(tt,{state:e,actions:t});case`server-stopped`:return(0,Y.jsx)(nt,{state:e,actions:t});case`loading`:return(0,Y.jsx)(it,{step:e.step,url:n});case`worktree-removed`:return(0,Y.jsx)(at,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,Y.jsx)(ot,{actions:t});case`taken-over`:return(0,Y.jsx)(ct,{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 Be({server:e}){return(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(E,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Runs ${I(e.command)} in this task's worktree, on the host.`})]})}function Ve({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)(F,{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 He({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)(P,{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)(Be,{server:e})})]})}function Ue({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(L,{}),title:`This host has no browser yet`,children:[(0,Y.jsx)(Z,{children:e.canDownload?`Preview runs Chromium on the machine Squawk runs on. Squawk can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine Squawk runs on. Squawk has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,Y.jsx)(Q,{children:(0,Y.jsxs)(D,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(L,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,Y.jsx)(Ve,{command:e.installCommand,copy:t.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function We(e){return Math.round(e/1e6)}function Ge({state:e,actions:t}){let n=(0,J.useRef)(null);n.current??={at:Date.now(),received:e.received};let r=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,i=(Date.now()-n.current.at)/1e3,a=i>=1?(e.received-n.current.received)/i:0,o=a>0?Math.ceil((e.total-e.received)/a):void 0;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(L,{}),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":r,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${r}%`}})}),(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:`${We(e.received)} of ${We(e.total)} MB · ${r}%`}),o===void 0?null:(0,Y.jsx)(`span`,{children:`about ${o} s left`})]})]}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(D,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function Ke({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)(Ve,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(D,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Retry download`]}),(0,Y.jsxs)(D,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function qe({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(K,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,Y.jsx)(Z,{children:`The host blocks the sandbox Chromium needs. This usually means Squawk runs as root, or inside a container without user namespaces.`}),(0,Y.jsx)(Ne,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(D,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(D,{variant:`outline`,onClick:()=>t.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,Y.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Re,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function Je({state:e,actions:t}){let n=e.reason===`timeout`,r=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,i=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,a=n?`Chromium did not start in time`:`Chromium exited${r}`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(p,{className:`text-danger`}),title:n?`The browser did not start`:`The browser stopped`,children:[(0,Y.jsx)(Z,{children:n?`Chromium did not open its DevTools port in time. ${i}`:`Chromium exited unexpectedly${r}. ${i}`}),(0,Y.jsx)(Ne,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(D,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(D,{variant:`outline`,onClick:()=>t.copy(`${a}\n${e.stderrTail}`),children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Ye=2;function Xe(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 Ze({state:e,actions:t}){let{server:n,wasRunning:r}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:r?(0,Y.jsx)(q,{className:`text-pending-strong`}):(0,Y.jsx)(S,{}),title:r?`Nothing answers on :${n.port} anymore`:`${n.label} isn't running yet`,children:[(0,Y.jsx)(Z,{children:r?`${n.label} was running when the agent registered it, likely inside the agent's own session, which has ended. Squawk can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,Y.jsx)(He,{server:n,status:r?`was running when registered · silent now`:`registered · not started`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(D,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(S,{"aria-hidden":`true`}),`Run and open`]})})]})}function Qe({state:e,actions:t}){let{server:n,ownerTitle:r}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(Ee,{className:`text-pending-strong`}),title:`${n.label} :${n.port} is in use by another task`,children:[(0,Y.jsx)(Z,{children:`Task "${r}" is running its own server on :${n.port}. Register a different port for this task, or stop that task's server.`}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(D,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function $e({state:e,actions:t}){let{server:n}=e,r=Xe(1e3),i=Math.max(0,Math.floor((r-Date.parse(e.startedAt))/1e3)),[a,o]=(0,J.useState)(()=>Date.now());(0,J.useEffect)(()=>o(Date.now()),[e.attempt]);let s=Math.max(0,Math.ceil(Ye-(r-a)/1e3));return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(S,{}),title:`Starting ${n.label}`,children:[(0,Y.jsx)(Z,{children:`Squawk ran ${I(n.command)} in the worktree. The page opens as soon as :${n.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)(y,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),s>0?`Attempt ${e.attempt} · next try in ${s} s`:`Attempt ${e.attempt}`]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${i} s ago`})]}),e.logTail.length>0?(0,Y.jsx)(Ne,{text:e.logTail.join(`
3
3
  `),source:I(n.command),onCopy:t.copy}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(D,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})})]})}function et({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(h,{className:`text-pending-strong`}),title:`${n.label} is running, but :${n.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)(Ne,{text:e.logTail,source:I(n.command),onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(D,{variant:`contrast`,onClick:()=>t.keepWaiting(n.port),children:`Keep waiting`}),(0,Y.jsx)(D,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})]})]})}function tt({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(p,{className:`text-danger`}),title:e.exitCode===null?`${n.label} was stopped by a signal`:`${n.label} exited with code ${e.exitCode}`,children:[(0,Y.jsx)(Z,{children:`${I(n.command)} stopped.`}),(0,Y.jsx)(Ne,{text:e.logTail,source:I(n.command),onCopy:t.copy}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(D,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Be,{server:n})]})}function nt({state:e,actions:t}){let{server:n}=e,r=e.reason===`idle`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(x,{}),title:r?`Stopped after 15 min idle`:`${n.label} stopped`,children:[(0,Y.jsx)(Z,{children:r?`Nobody had this pane open for 15 min, so Squawk stopped ${n.label} :${n.port} and the browser to free memory. Start again reopens ${Le(e.lastUrl)}.`:`You stopped ${n.label} :${n.port}. Start again reopens ${Le(e.lastUrl)}.`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(D,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Be,{server:n})]})}var rt=[`browser`,`page`,`frame`];function it({step:e,url:t}){let n=rt.indexOf(e),i=t?Le(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)(y,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,Y.jsx)(Se,{className:`size-5 text-border`,"aria-hidden":`true`}),i?e.done:a?e.active:e.done]},t)})})})}function at({state:e,actions:t,worktree:n}){let r=n?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(n)?.[0]:void 0,i=e.server?.label;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(z,{}),title:`This task's worktree is gone`,children:[(0,Y.jsx)(Z,{children:`${i??`The server`} ran in ${r??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,Y.jsx)(w,{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)(D,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function ot({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)(Me,{})}),(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)(U,{})}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,Y.jsx)(Z,{children:`The proxy in front of Squawk didn't let the preview's WebSocket through. This is a known gap behind Basic Auth. Everything else in Squawk keeps working.`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(D,{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:Re,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function st(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 ct({state:e,actions:t}){let n=st(e.by);return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(H,{}),title:`Preview is open somewhere else`,children:[(0,Y.jsx)(Z,{children:`Another tab took this browser${n?` (${n})`:``}. Only one tab can view and drive it at a time.`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(D,{variant:`contrast`,onClick:t.useHere,children:[(0,Y.jsx)(L,{"aria-hidden":`true`}),`Use it here`]}),(0,Y.jsx)(D,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function lt({attempt:e,exhausted:t,onReconnect:n}){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)(De,{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)(D,{variant:`outline`,onClick:n,children:t?`Reconnect`:`Reconnect now`})]})}function ut({servers:e,states:t,onOpen:n,agentLive:r=!1,agentIdle:i=!1,onOpenAgent:a}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":i?`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.`}),i?(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,Y.jsx)(q,{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,r&&a!==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)(P,{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)(D,{variant:`outline`,size:`sm`,className:`max-md:h-11`,"aria-label":`Open the agent's page`,onClick:a,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 r=ve(e,t),i=ge(r);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)(P,{tone:i.tone,shape:i.ring?`ring`:`filled`,pulse:i.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:i.text})]}),(0,Y.jsx)(D,{variant:`outline`,size:`sm`,className:`max-md:h-11`,onClick:()=>n(e.port),children:fe(r)?`Open`:`Review`})]},e.port)})})]}):null,(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(v,{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 dt({dialog:e,onResult:t}){let[n,r]=(0,J.useState)(e.defaultPrompt??``),i=e.type===`beforeunload`,a=(0,J.useRef)(null),o=(0,J.useRef)(null);(0,J.useEffect)(()=>{(e.type===`prompt`?o.current:a.current)?.focus()},[e.type]);let s=(0,J.useRef)(t);s.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(),s.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let c=()=>t(e.type===`prompt`?{accept:!0,text:n}:{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||(i?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,Y.jsx)(`input`,{ref:o,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()},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)(D,{variant:`outline`,onClick:()=>t({accept:!1}),children:i?`Stay`:`Cancel`}),(0,Y.jsx)(D,{ref:a,variant:`contrast`,onClick:c,children:i?`Leave`:`OK`})]})]})})}var ft=10,pt=500,mt=500,ht=4,gt=16,_t=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function vt(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function yt(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 bt=[`left`,`middle`,`right`];function $(e,t,n,r){let i=vt(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:bt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:_t(n),...r}}var xt=e=>e===0?0:-e;function St(e,t,n,r,i){let a=vt(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:xt(r/e.scale),deltaY:xt(i/e.scale),modifiers:0}}function Ct(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)<=ft)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?[]:[St(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=pt;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 wt(e,t){if(e.pointerType===`touch`)return Ct(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=mt&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=ht;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 Tt(e,t,n){let r=vt(e.clientX,e.clientY,t,n),i=e.deltaMode===1?gt: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:_t(e)}}var Et={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Dt(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:_t(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`:Et[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:_t(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function Ot(e){return e?{t:`insertText`,text:e}:void 0}var kt=e=>e,At=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function jt({scale:e,send:t,onLeave:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(yt({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 wt(kt(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(Tt(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=Ot(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(At(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Dt(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 Mt(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 Nt({ref:e,viewport:t,dimmed:n=!1,cursor:i,onSize:a,renderInput:s,children:c}){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||!o()))try{let i=await Mt(e);try{if(t!==l.current||!o()||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`}),s?.({canvas:d.current,scale:g,viewport:h})]}):null,c]})}var Pt=`cez-preview-quality`,Ft=[{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 It(e){return Ft.find(t=>t.value===e)?.value??`normal`}var Lt=e=>Ft.find(t=>t.value===e)?.label??`Normal`;function Rt(){try{return It(localStorage.getItem(Pt))}catch{return`normal`}}function zt(e){try{localStorage.setItem(Pt,e)}catch{}}var Bt=[{w:390,h:844,icon:_},{w:820,h:1180,icon:Te},{w:1440,h:900,icon:b}],Vt=`size-8 shrink-0 max-md:size-11`,Ht=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Ut(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 Wt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Gt({stats:e,shrunk:t}){let n=Ut(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,Y.jsx)(P,{"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`:Wt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(P,{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`:Wt(e)})]})}function Kt({current:e,agentShown:t,...n}){let r=e?e.label:t?`Agent's page`:`Server`;return(0,Y.jsxs)(D,{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: ${r}`:`Server`,...n,children:[e||t?(0,Y.jsx)(P,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,Y.jsx)(T,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:r}),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 qt({shown:e,live:t,onSelect:n}){return(0,Y.jsxs)(k,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,Y.jsx)(P,{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)(d,{className:`size-4`,"aria-hidden":`true`}):null]})}function Jt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Yt(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 Xt(e){let{compact:t=!1,navEnabled:n,loading:r=!1}=e,i=(0,J.useRef)(null),a=e.urlInputRef??i,o=(0,J.useRef)(!1),[s,c]=(0,J.useState)(null),[l,d]=(0,J.useState)(!1),f=(0,Y.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Back`,disabled:!n,onClick:e.onBack,children:(0,Y.jsx)(be,{"aria-hidden":`true`})}),p=(0,Y.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Forward`,disabled:!n,onClick:e.onForward,children:(0,Y.jsx)(u,{"aria-hidden":`true`})}),m=(0,Y.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Reload`,"aria-busy":r||void 0,disabled:!n||r,onClick:()=>e.onReload(!1),children:(0,Y.jsx)(G,{"aria-hidden":`true`})}),h=e.onSession?(0,Y.jsxs)(D,{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,g=r?(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,_=(0,Y.jsx)(Qt,{props:e,input:a,draft:s,setDraft:c,focused:l,setFocused:d}),{agentListed:v}=Yt(e),y=e.servers.length+ +!!v>=2,b=y||e.adopted,x={back:f,forward:p,reload:m,address:_,more:(0,Y.jsx)(rn,{props:e,compact:t,crowded:b}),session:h,progress:g};return t?(0,Y.jsx)(an,{props:e,elements:x}):(0,Y.jsx)(on,{props:e,elements:x,switcher:y,crowded:b,input:a,focusUrlAfterMenu:o})}function Zt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Yt(e);return(0,Y.jsxs)(N,{children:[(0,Y.jsx)(j,{asChild:!0,children:(0,Y.jsx)(Kt,{current:i,agentShown:o})}),(0,Y.jsxs)(M,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,Y.jsx)(qt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=ge(ve(t,e.serverStates));return(0,Y.jsxs)(k,{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)(P,{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)(d,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,Y.jsx)(A,{}),(0,Y.jsxs)(k,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,Y.jsx)(g,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function Qt({props:e,input:t,draft:n,setDraft:i,focused:a,setFocused:o}){let{url:s,adopted:c}=e;return(0,Y.jsxs)(`div`,{className:`relative flex min-w-[9rem] flex-1 items-center`,children:[(0,Y.jsx)(g,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{ref:t,type:`text`,"aria-label":`Page address`,placeholder:`Type a URL or a port`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:n??(a?s:Le(s)),title:s||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`,c?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;o(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{o(!1),i(null)},onChange:e=>i(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(n??s),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),c&&!a?(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 Squawk`]}):null]})}function $t({props:e}){let{viewport:t}=e;return(0,Y.jsxs)(N,{children:[(0,Y.jsx)(j,{asChild:!0,children:(0,Y.jsxs)(D,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ht(t)}`,children:[t===`fit`?(0,Y.jsx)(V,{"aria-hidden":`true`}):(0,Y.jsx)(b,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:r(`hidden @min-[500px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ht(t)}),(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(M,{align:`start`,className:`min-w-56`,children:[(0,Y.jsxs)(k,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,Y.jsx)(V,{"aria-hidden":`true`}),`Fit`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]}),Bt.map(({w:n,h:r,icon:i})=>(0,Y.jsxs)(k,{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)(d,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function en({quality:e,onQuality:t,compact:n}){return(0,Y.jsx)(ne,{value:e,onValueChange:e=>t(It(e)),children:Ft.map(e=>(0,Y.jsx)(te,{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 tn({props:e}){let{quality:t}=e;return(0,Y.jsxs)(N,{children:[(0,Y.jsx)(j,{asChild:!0,children:(0,Y.jsxs)(D,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Lt(t)}`,children:[(0,Y.jsx)(B,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[560px]:inline`,children:Lt(t)}),(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(M,{align:`start`,className:`w-64`,children:[(0,Y.jsx)(O,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function nn({stats:e,status:t,crowded:n}){return e?(0,Y.jsx)(Gt,{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)(P,{tone:t.tone,"aria-hidden":`true`}),t.label]}):null}function rn({props:e,compact:t,crowded:n}){let{stats:r,navEnabled:i,url:a,current:o,adopted:s}=e;return(0,Y.jsxs)(N,{children:[(0,Y.jsx)(j,{asChild:!0,children:(0,Y.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`More`,children:(0,Y.jsx)(se,{"aria-hidden":`true`})})}),(0,Y.jsxs)(M,{align:`end`,className:`min-w-64`,children:[n&&r&&!t?(0,Y.jsx)(O,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Wt(r)}):null,(0,Y.jsxs)(k,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!i,onSelect:()=>e.onReload(!0),children:[(0,Y.jsx)(W,{"aria-hidden":`true`}),`Reload without cache`]}),(0,Y.jsxs)(k,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:a===``,onSelect:e.onCopyUrl,children:[(0,Y.jsx)(_e,{"aria-hidden":`true`}),`Copy page URL`]}),o?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(A,{}),s?(0,Y.jsxs)(k,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,Y.jsx)(we,{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 · ${o.label} :${o.port}`}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:`Squawk didn't start this server, so it won't stop it. Stop it where it was started.`})]})]}):(0,Y.jsxs)(k,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(o.port),children:[(0,Y.jsx)(xe,{"aria-hidden":`true`}),`Stop server · ${o.label} :${o.port}`]})]}):null,t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(A,{}),(0,Y.jsx)(O,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,Y.jsx)(A,{}),(0,Y.jsxs)(k,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,Y.jsx)(le,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function an({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Yt(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)(P,{tone:`success`,"aria-hidden":`true`}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:Jt(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 on({props:e,elements:t,switcher:n,crowded:r,input:i,focusUrlAfterMenu:a}){let{badge:o=!0,stats:s,status:c}=e,{back:l,forward:u,reload:d,address:f,more:p,session:m,progress:h}=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:[m,l,u,d,n?(0,Y.jsx)(Zt,{props:e,input:i,focusUrlAfterMenu:a}):null,f,(0,Y.jsx)($t,{props:e}),(0,Y.jsx)(tn,{props:e}),(0,Y.jsx)(nn,{stats:s,status:c,crowded:r}),o?(0,Y.jsx)(Me,{iconOnly:r,responsive:!r}):null,(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),p,(0,Y.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Close preview`,onClick:e.onClose,children:(0,Y.jsx)(le,{"aria-hidden":`true`})}),h]})}function sn({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 cn(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)(ze,{...n,actions:o})}case`empty`:return(0,Y.jsx)(ut,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function ln(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function un(){let[e,t]=(0,J.useState)(ln);return(0,J.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(ln());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var dn=2e3,fn=500,pn=1e3;function mn(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 hn(e){navigator.clipboard?.writeText(e).then(()=>c(`Copied`),()=>c(`Couldn't copy to the clipboard`,{tone:`danger`}))}var gn=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function _n(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 vn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function yn({run:e,servers:t,request:n,onTarget:r,onLive:i,onClose:s}){let c=un(),l=(0,J.useRef)(c);l.current=c;let u=a(),d=(0,J.useRef)(crypto.randomUUID()),f=(0,J.useRef)(!1),p=re(),m=ue(me,!1),[h,g]=(0,J.useState)(0),[_,v]=(0,J.useState)({state:`connecting`,attempt:0}),[y,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)(void 0),[C,w]=(0,J.useState)(void 0),[ee,T]=(0,J.useState)(``),[E,D]=(0,J.useState)(void 0),[O,te]=(0,J.useState)(!1),[k,A]=(0,J.useState)(void 0),[j,M]=(0,J.useState)(!1),[ne,N]=(0,J.useState)(!1),[P,F]=(0,J.useState)(void 0),[ie,ae]=(0,J.useState)(void 0),[oe,se]=(0,J.useState)(void 0),[ce,le]=(0,J.useState)(`fit`),[de,fe]=(0,J.useState)(Rt),[pe,I]=(0,J.useState)(null),[he,ge]=(0,J.useState)(void 0),[_e,ve]=(0,J.useState)(0),ye=(0,J.useRef)(void 0),be=(0,J.useRef)(null),xe=(0,J.useRef)(null),Se=(0,J.useRef)(void 0),L=(0,J.useRef)(void 0),R=(0,J.useRef)(de);R.current=de;let z=(0,J.useRef)({port:E,stage:C,agent:O});z.current={port:E,stage:C,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&&ye.current?.send(e)},[]);(0,J.useEffect)(()=>{let t;return t=je({projectId:p??`default`,runId:e.id},{onFrame(e){if(!o())return;let n=Date.now();B.current.push({at:n,bytes:e.size}),we.current||(we.current=!0,N(!0)),(be.current?.draw(e)??Promise.resolve()).finally(()=>t?.send({t:`ack`}))},onMessage(e){switch(e.t){case`state`:if(w(e),(e.stage===`streaming`||e.stage===`loading`)&&ve(e=>e+1),L.current!==void 0&&mn(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 F(e.cursor);case`dialog`:return ae(e);case`pong`:Ce.current=Math.max(0,Date.now()-e.ts);return;case`downloadProgress`:w(t=>t?.stage===`downloading`?{...t,received:e.received,total:e.total}:t);return;case`replaced`:S(e.by),V.current=!1,t?.close();return}},onTransport(e,n){V.current=e===`open`,v({state:e,attempt:n??0}),e===`open`&&(b(!0),Se.current&&(t?.send({t:`open`,target:Se.current,viewerId:d.current,resume:f.current,quality:R.current,dpr:l.current}),f.current=!0))}}),ye.current=t,()=>{V.current=!1,t?.close(),ye.current===t&&(ye.current=void 0)}},[p,e.id,h]);let U=u&&_.state===`open`&&x===void 0,W=m||ce===`fit`?pe:ce;(0,J.useEffect)(()=>{W&&U&&(C?.stage===`streaming`||C?.stage===`loading`)&&H({t:`resize`,w:W.w,h:W.h,...c===1?{}:{dpr:c}})},[W?.w,W?.h,c,U,C?.stage,_e,H]),(0,J.useEffect)(()=>{if(!U)return;let e=setInterval(()=>H({t:`ping`,ts:Date.now()}),dn);return()=>clearInterval(e)},[U,H]);let G=U&&C?.stage===`streaming`;(0,J.useEffect)(()=>{if(!G){se(void 0);return}let e=setInterval(()=>{let e=Date.now();B.current=B.current.filter(t=>e-t.at<=pn);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}:{}};se(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})},fn);return()=>clearInterval(e)},[G]),(0,J.useEffect)(()=>(i?.(G),()=>i?.(!1)),[G,i]),(0,J.useEffect)(()=>{k&&r?.(k)},[k,r]);let K=(0,J.useCallback)((e,t,n=!1)=>{Se.current=e,L.current=n&&`port`in e?e.port:void 0,M(!0),w(void 0),S(void 0),ge(void 0),T(t),D(`port`in e?e.port:void 0),te(`agent`in e),A(vn(e)),H({t:`open`,target:e,viewerId:d.current,quality:R.current,dpr:l.current}),f.current=V.current},[H]),Te=(0,J.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);K({port:e},r?gn(r):`http://localhost:${e}`,n)},[t,K]),Ee=(0,J.useCallback)(()=>K({agent:!0},``),[K]);(0,J.useEffect)(()=>{if(n?.agent){if(z.current.agent&&z.current.stage?.stage===`streaming`)return;Ee();return}if(n?.url!==void 0){let e=Fe(n.url,t);e.kind===`server`?Te(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||Te(n.port,n.run===!0))},[n]);let q=!j&&!x&&_.state!==`blocked`,De=_n(n,t);(0,J.useEffect)(()=>{q&&!De&&xe.current?.focus()},[q,De]);let Oe=e=>{let n=Fe(e,t);if(n.kind===`error`)return ge(n.message);if(n.kind===`server`)return Te(n.port);if(z.current.stage?.stage===`streaming`&&!z.current.agent)return Se.current={url:n.url},L.current=void 0,D(void 0),A({url:n.url}),ge(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,fe(e),zt(e),H({t:`quality`,quality:e})},[H]),Ae=()=>{f.current=!1,S(void 0),v({state:`connecting`,attempt:0}),we.current=!1,g(e=>e+1)};return{compact:m,transport:_,everOpened:y,takenOver:x,stage:C,url:ee,port:E,agent:O,hasFrame:ne,cursor:P,dialog:ie,setDialog:ae,stats:oe,viewport:ce,setViewport:le,quality:de,chooseQuality:ke,setStageSize:I,addressError:he,stageHandle:be,urlInput:xe,send:H,connected:U,streaming:G,openServer:Te,openAgent:Ee,empty:q,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:s,useHere:Ae,copy:hn}),[H,s])}}function bn(e){return(0,Y.jsx)(ye,{onClose:e.onClose,children:(0,Y.jsx)(Cn,{...e})})}function xn(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?Sn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Sn(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 Cn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=yn(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:b,chooseQuality:x,addressError:S,urlInput:C,send:w,streaming:ee,openServer:T,openAgent:E,empty:D,navigate:O,actions:te}=s,k=n.find(e=>e.port===m),A=f?.stage===`streaming`&&f.adopted,j=u&&(l.state===`reconnecting`||l.state===`closed`),{content:M,dim:ne}=sn({transport:l.state,takenOver:d,empty:D,stage:f,hasFrame:g,lost:j,url:p,worktree:t.worktreePath}),N=cn(M,{servers:n,serverStates:r,agentLive:i,openServer:T,openAgent:E,actions:te});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)(Xt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:k,agentLive:i===!0,agentShown:h,adopted:A,viewport:c?`fit`:v,quality:b,compact:c,navEnabled:ee,loading:f?.stage===`loading`,stats:ee?_??{fps:0,kbps:0}:void 0,status:ee?void 0:xn(l,u,d!==void 0,f),urlInputRef:C,onSession:a,onNavigate:O,onBack:()=>w({t:`back`}),onForward:()=>w({t:`forward`}),onReload:e=>w({t:`reload`,...e?{ignoreCache:!0}:{}}),onPickServer:e=>T(e),onPickAgent:E,onViewport:y,onQuality:x,onCopyUrl:()=>hn(p),onStop:e=>w({t:`stop`,port:e}),onClose:o}),S?(0,Y.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:S}):null,(0,Y.jsx)(wn,{transportState:s,overlay:N,dim:ne,lost:j})]})}function wn({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)(Nt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,Y.jsx)(jt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,Y.jsx)(lt,{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)(dt,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function Tn(e){let{visibleEvents:t}=he(e);return(0,J.useMemo)(()=>{let e=new Map;for(let n of ee(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function En(e){let t=Tn(e.run.id),n=de(e.run.id);return(0,Y.jsx)(bn,{...e,serverStates:t,agentLive:n})}export{En as ConnectedPreviewPane};
@@ -1 +1 @@
1
- import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{t as i}from"./utils-DSMR_WLb.js";import{Jt as a,ci as o}from"./project-scope-context-DqBHMdSb.js";import{At as s,Dt as c,Gt as l,Kt as u,Nt as d,in as f,nt as p,q as m}from"./queries-DeeY9cGJ.js";import{n as h}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as g}from"./toaster-Bo5vCbz-.js";import{O as _,ft as v}from"./design-icons-CzEoMH9c.js";import{t as y}from"./button-BQ2y4XRB.js";import{n as b,r as x,t as S}from"./popover-BPgUYFyu.js";import{t as C}from"./centered-state-V15AR_qo.js";import{Bt as w,Gt as T,Ht as E,Kt as D,Un as O,Ut as k,Vt as A,Wt as j,qt as M}from"./index-CilVqe_c.js";import{t as N}from"./settings-field-Bl6WuvGX.js";var P=t(n(),1),F=r();function I(){let e=p();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{g(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>g(e.message,{tone:`danger`})})}}function L({project:e,onOpenChange:t,onConfirm:n}){return(0,F.jsx)(w,{open:e!==null,onOpenChange:t,children:(0,F.jsxs)(k,{children:[(0,F.jsxs)(D,{children:[(0,F.jsxs)(M,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,F.jsxs)(j,{children:[`This only unregisters the project — `,(0,F.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,(0,F.jsx)(`span`,{className:`mt-1 block truncate font-mono text-[11px] text-foreground`,title:e?.root,children:e?.root})]})]}),(0,F.jsxs)(T,{children:[(0,F.jsx)(E,{children:`Keep it`}),(0,F.jsx)(A,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var R=e({MaxParallelSelect:()=>J,ProjectTagsEditor:()=>q,ProjectsSection:()=>H,STATUS_LABEL:()=>B}),z=1,B={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function V(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function H(){let e=s(),t=m();return e.isPending||t.isPending?(0,F.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,F.jsx)(C,{icon:(0,F.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,F.jsx)(U,{config:e.data,registry:t.data})}function U({config:e,registry:t}){let[n,r]=(0,P.useState)(!1);return(0,F.jsxs)(`div`,{"data-slot":`projects-section`,className:`mx-auto flex w-full max-w-4xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,F.jsx)(W,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,savedLabel:`Browse folder`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,F.jsx)(W,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/cezar/projects`,slot:`checkout`,savedLabel:`Checkout folder`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,F.jsx)(G,{registry:t,workspaceMax:e.resources.maxParallel}),(0,F.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,F.jsx)(O,{open:!0,onOpenChange:r}):null]})}function W({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:s,savedLabel:c,footer:l,refreshProjects:u=!1}){let p=o(),m=f({mutationFn:t=>a(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{p.setQueryData(d.config,t),e===`browseRoot`?p.invalidateQueries({queryKey:d.fsBrowseRoot}):u&&p.invalidateQueries({queryKey:d.projects})}}),[h,_]=(0,P.useState)(t),v=h.trim(),b=v===t,x=m.isError?m.error.message:null;return(0,F.jsxs)(N,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":x!==null,"data-slot":`projects-${s}-root`,value:h,disabled:m.isPending,placeholder:i,onChange:e=>{_(e.target.value),m.isError&&m.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`}),(0,F.jsx)(y,{type:`button`,variant:`outline`,size:`sm`,"data-action":`projects-save-${s}-root`,disabled:b||v===``||m.isPending,onClick:()=>m.mutate(v,{onSuccess:()=>g(`${c} set to ${v}`)}),children:`Save`})]}),x===null?(0,F.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:l}):(0,F.jsxs)(`p`,{"data-slot":`projects-${s}-root-error`,role:`alert`,className:`text-[11px] text-danger`,children:[x,` — setting unchanged`]})]})}function G({registry:e,workspaceMax:t}){let[n,r]=(0,P.useState)(null),i=I(),a=(0,P.useMemo)(()=>l(e.projects),[e.projects]);return(0,F.jsxs)(N,{title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[e.projects.length===0?(0,F.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}):(0,F.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:(0,F.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,F.jsx)(`caption`,{className:`sr-only`,children:`Projects registered in this workspace`}),(0,F.jsxs)(`colgroup`,{children:[(0,F.jsx)(`col`,{}),(0,F.jsx)(`col`,{style:{width:`104px`}}),(0,F.jsx)(`col`,{style:{width:`260px`}}),(0,F.jsx)(`col`,{style:{width:`150px`}}),(0,F.jsx)(`col`,{style:{width:`72px`}}),(0,F.jsx)(`col`,{style:{width:`92px`}})]}),(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-border text-left text-[12px] text-soft-foreground`,children:[(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Project`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Status`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Tags`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Max parallel`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Added`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,F.jsx)(`tbody`,{children:e.projects.map(n=>(0,F.jsx)(K,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:a,disabled:i.isPending,onRemove:()=>r(n)},n.id))})]})}),(0,F.jsx)(L,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),i.confirm(e)}})]})}function K({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){return(0,F.jsxs)(`tr`,{"data-slot":`project-row`,"data-project":e.id,className:`border-b border-border last:border-0`,children:[(0,F.jsxs)(`th`,{scope:`row`,className:`max-w-0 px-3 py-2 text-left font-normal`,children:[(0,F.jsx)(`span`,{className:`block truncate text-foreground`,children:e.name}),(0,F.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-soft-foreground`,title:e.root,children:e.root})]}),(0,F.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,F.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-[12px] text-danger`:`text-[12px] text-soft-foreground`,children:B[e.status]}),e.status===`missing`?null:(0,F.jsxs)(`span`,{className:`ml-1 text-[11px] text-soft-foreground`,children:[`· `,e.source]})]}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(q,{project:e,vocabulary:r})}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(J,{project:e,workspaceMax:n})}),(0,F.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:V(e.addedAt)}),(0,F.jsxs)(`td`,{className:`px-3 py-2 text-right`,children:[e.status===`missing`?null:(0,F.jsx)(y,{asChild:!0,variant:`outline`,className:`mr-2`,children:(0,F.jsx)(h,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,F.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function q({project:e,vocabulary:t}){let n=c(),[r,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1),[l,d]=(0,P.useState)(-1),f=(0,P.useRef)(null),p=e.tags??[],m=u(t,p,r),h=o&&m.length>0,_=(t,r)=>{n.mutate({id:e.id,tags:t},{onSuccess:()=>g(r),onError:e=>g(e.message,{tone:`danger`})})},y=t=>{let n=t.trim().slice(0,32);if(d(-1),n){if(p.some(e=>e.toLowerCase()===n.toLowerCase())){a(``);return}if(p.length>=20){g(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}a(``),_([...p,n],`${e.name} tagged \u201c${n}\u201d`)}},C=t=>{_(p.filter(e=>e!==t),`\u201c${t}\u201d removed from ${e.name}`)},w=`project-tag-suggestions-${e.id}`;return(0,F.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[p.map(t=>(0,F.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-[11px] font-medium whitespace-nowrap text-accent-text`,children:[t,(0,F.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:n.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,F.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,F.jsxs)(S,{open:h,onOpenChange:s,children:[(0,F.jsx)(b,{asChild:!0,children:(0,F.jsx)(`input`,{ref:f,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":h,"aria-controls":h?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":h&&l>=0?`${w}-${l}`:void 0,placeholder:p.length===0?`Add tag…`:`+`,value:r,maxLength:32,disabled:n.isPending,onFocus:()=>s(!0),onBlur:()=>s(!1),onChange:e=>{if(s(!0),d(-1),e.target.value.includes(`,`)){a(e.target.value.replace(/,/g,``));return}a(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(m.length===0)return;e.preventDefault(),s(!0);let t=e.key===`ArrowDown`?1:-1,n=l+t;d(n>=m.length?-1:n<-1?m.length-1:n);return}if(e.key===`Escape`&&h){e.preventDefault(),s(!1),d(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),y(l>=0?m[l]??r:r);return}if(e.key===`Tab`){s(!1);return}if(e.key===`Backspace`&&r===``&&p.length>0){e.preventDefault();let t=p[p.length-1];t!==void 0&&C(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,F.jsxs)(x,{align:`start`,sideOffset:4,id:w,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,F.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-[11px] text-soft-foreground`,children:`Tags used in this workspace`}),m.map((e,t)=>(0,F.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===l,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{y(e),f.current?.focus()},onMouseEnter:()=>d(t),className:i(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===l&&`bg-muted`),children:e},e))]})]})]})}function J({project:e,workspaceMax:t}){let n=c(),r=e.maxParallel===void 0?``:String(e.maxParallel);return(0,F.jsxs)(`select`,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:r,disabled:n.isPending,onChange:r=>{let i=r.target.value,a=i===``?null:Number(i);n.mutate({id:e.id,maxParallel:a},{onSuccess:()=>g(a===null?`${e.name} inherits the workspace limit (${t})`:`${e.name} runs at most ${a} task${a===1?``:`s`} at a time`),onError:e=>g(e.message,{tone:`danger`})})},className:`block w-44 rounded-md border border-input bg-card px-2 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,F.jsxs)(`option`,{value:``,children:[`Inherit workspace (`,t,`)`]}),Array.from({length:16},(e,t)=>t+z).map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})}export{I as a,L as i,B as n,R as r,J as t};
1
+ import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{t as i}from"./utils-DSMR_WLb.js";import{Jt as a,ci as o}from"./project-scope-context-DqBHMdSb.js";import{At as s,Dt as c,Gt as l,Kt as u,Nt as d,in as f,nt as p,q as m}from"./queries-DeeY9cGJ.js";import{n as h}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as g}from"./toaster-Bo5vCbz-.js";import{O as _,ft as v}from"./design-icons-CzEoMH9c.js";import{t as y}from"./button-BQ2y4XRB.js";import{n as b,r as x,t as S}from"./popover-BPgUYFyu.js";import{t as C}from"./centered-state-V15AR_qo.js";import{Bt as w,Gt as T,Ht as E,Kt as D,Un as O,Ut as k,Vt as A,Wt as j,qt as M}from"./index-DfmmHZB9.js";import{t as N}from"./settings-field-Bl6WuvGX.js";var P=t(n(),1),F=r();function I(){let e=p();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{g(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>g(e.message,{tone:`danger`})})}}function L({project:e,onOpenChange:t,onConfirm:n}){return(0,F.jsx)(w,{open:e!==null,onOpenChange:t,children:(0,F.jsxs)(k,{children:[(0,F.jsxs)(D,{children:[(0,F.jsxs)(M,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,F.jsxs)(j,{children:[`This only unregisters the project — `,(0,F.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,(0,F.jsx)(`span`,{className:`mt-1 block truncate font-mono text-[11px] text-foreground`,title:e?.root,children:e?.root})]})]}),(0,F.jsxs)(T,{children:[(0,F.jsx)(E,{children:`Keep it`}),(0,F.jsx)(A,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var R=e({MaxParallelSelect:()=>J,ProjectTagsEditor:()=>q,ProjectsSection:()=>H,STATUS_LABEL:()=>B}),z=1,B={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function V(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function H(){let e=s(),t=m();return e.isPending||t.isPending?(0,F.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,F.jsx)(C,{icon:(0,F.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,F.jsx)(U,{config:e.data,registry:t.data})}function U({config:e,registry:t}){let[n,r]=(0,P.useState)(!1);return(0,F.jsxs)(`div`,{"data-slot":`projects-section`,className:`mx-auto flex w-full max-w-4xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,F.jsx)(W,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,savedLabel:`Browse folder`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,F.jsx)(W,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/cezar/projects`,slot:`checkout`,savedLabel:`Checkout folder`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,F.jsx)(G,{registry:t,workspaceMax:e.resources.maxParallel}),(0,F.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,F.jsx)(O,{open:!0,onOpenChange:r}):null]})}function W({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:s,savedLabel:c,footer:l,refreshProjects:u=!1}){let p=o(),m=f({mutationFn:t=>a(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{p.setQueryData(d.config,t),e===`browseRoot`?p.invalidateQueries({queryKey:d.fsBrowseRoot}):u&&p.invalidateQueries({queryKey:d.projects})}}),[h,_]=(0,P.useState)(t),v=h.trim(),b=v===t,x=m.isError?m.error.message:null;return(0,F.jsxs)(N,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":x!==null,"data-slot":`projects-${s}-root`,value:h,disabled:m.isPending,placeholder:i,onChange:e=>{_(e.target.value),m.isError&&m.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`}),(0,F.jsx)(y,{type:`button`,variant:`outline`,size:`sm`,"data-action":`projects-save-${s}-root`,disabled:b||v===``||m.isPending,onClick:()=>m.mutate(v,{onSuccess:()=>g(`${c} set to ${v}`)}),children:`Save`})]}),x===null?(0,F.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:l}):(0,F.jsxs)(`p`,{"data-slot":`projects-${s}-root-error`,role:`alert`,className:`text-[11px] text-danger`,children:[x,` — setting unchanged`]})]})}function G({registry:e,workspaceMax:t}){let[n,r]=(0,P.useState)(null),i=I(),a=(0,P.useMemo)(()=>l(e.projects),[e.projects]);return(0,F.jsxs)(N,{title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[e.projects.length===0?(0,F.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}):(0,F.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:(0,F.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,F.jsx)(`caption`,{className:`sr-only`,children:`Projects registered in this workspace`}),(0,F.jsxs)(`colgroup`,{children:[(0,F.jsx)(`col`,{}),(0,F.jsx)(`col`,{style:{width:`104px`}}),(0,F.jsx)(`col`,{style:{width:`260px`}}),(0,F.jsx)(`col`,{style:{width:`150px`}}),(0,F.jsx)(`col`,{style:{width:`72px`}}),(0,F.jsx)(`col`,{style:{width:`92px`}})]}),(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-border text-left text-[12px] text-soft-foreground`,children:[(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Project`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Status`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Tags`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Max parallel`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Added`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,F.jsx)(`tbody`,{children:e.projects.map(n=>(0,F.jsx)(K,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:a,disabled:i.isPending,onRemove:()=>r(n)},n.id))})]})}),(0,F.jsx)(L,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),i.confirm(e)}})]})}function K({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){return(0,F.jsxs)(`tr`,{"data-slot":`project-row`,"data-project":e.id,className:`border-b border-border last:border-0`,children:[(0,F.jsxs)(`th`,{scope:`row`,className:`max-w-0 px-3 py-2 text-left font-normal`,children:[(0,F.jsx)(`span`,{className:`block truncate text-foreground`,children:e.name}),(0,F.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-soft-foreground`,title:e.root,children:e.root})]}),(0,F.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,F.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-[12px] text-danger`:`text-[12px] text-soft-foreground`,children:B[e.status]}),e.status===`missing`?null:(0,F.jsxs)(`span`,{className:`ml-1 text-[11px] text-soft-foreground`,children:[`· `,e.source]})]}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(q,{project:e,vocabulary:r})}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(J,{project:e,workspaceMax:n})}),(0,F.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:V(e.addedAt)}),(0,F.jsxs)(`td`,{className:`px-3 py-2 text-right`,children:[e.status===`missing`?null:(0,F.jsx)(y,{asChild:!0,variant:`outline`,className:`mr-2`,children:(0,F.jsx)(h,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,F.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function q({project:e,vocabulary:t}){let n=c(),[r,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1),[l,d]=(0,P.useState)(-1),f=(0,P.useRef)(null),p=e.tags??[],m=u(t,p,r),h=o&&m.length>0,_=(t,r)=>{n.mutate({id:e.id,tags:t},{onSuccess:()=>g(r),onError:e=>g(e.message,{tone:`danger`})})},y=t=>{let n=t.trim().slice(0,32);if(d(-1),n){if(p.some(e=>e.toLowerCase()===n.toLowerCase())){a(``);return}if(p.length>=20){g(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}a(``),_([...p,n],`${e.name} tagged \u201c${n}\u201d`)}},C=t=>{_(p.filter(e=>e!==t),`\u201c${t}\u201d removed from ${e.name}`)},w=`project-tag-suggestions-${e.id}`;return(0,F.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[p.map(t=>(0,F.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-[11px] font-medium whitespace-nowrap text-accent-text`,children:[t,(0,F.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:n.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,F.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,F.jsxs)(S,{open:h,onOpenChange:s,children:[(0,F.jsx)(b,{asChild:!0,children:(0,F.jsx)(`input`,{ref:f,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":h,"aria-controls":h?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":h&&l>=0?`${w}-${l}`:void 0,placeholder:p.length===0?`Add tag…`:`+`,value:r,maxLength:32,disabled:n.isPending,onFocus:()=>s(!0),onBlur:()=>s(!1),onChange:e=>{if(s(!0),d(-1),e.target.value.includes(`,`)){a(e.target.value.replace(/,/g,``));return}a(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(m.length===0)return;e.preventDefault(),s(!0);let t=e.key===`ArrowDown`?1:-1,n=l+t;d(n>=m.length?-1:n<-1?m.length-1:n);return}if(e.key===`Escape`&&h){e.preventDefault(),s(!1),d(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),y(l>=0?m[l]??r:r);return}if(e.key===`Tab`){s(!1);return}if(e.key===`Backspace`&&r===``&&p.length>0){e.preventDefault();let t=p[p.length-1];t!==void 0&&C(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,F.jsxs)(x,{align:`start`,sideOffset:4,id:w,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,F.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-[11px] text-soft-foreground`,children:`Tags used in this workspace`}),m.map((e,t)=>(0,F.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===l,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{y(e),f.current?.focus()},onMouseEnter:()=>d(t),className:i(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===l&&`bg-muted`),children:e},e))]})]})]})}function J({project:e,workspaceMax:t}){let n=c(),r=e.maxParallel===void 0?``:String(e.maxParallel);return(0,F.jsxs)(`select`,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:r,disabled:n.isPending,onChange:r=>{let i=r.target.value,a=i===``?null:Number(i);n.mutate({id:e.id,maxParallel:a},{onSuccess:()=>g(a===null?`${e.name} inherits the workspace limit (${t})`:`${e.name} runs at most ${a} task${a===1?``:`s`} at a time`),onError:e=>g(e.message,{tone:`danger`})})},className:`block w-44 rounded-md border border-input bg-card px-2 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,F.jsxs)(`option`,{value:``,children:[`Inherit workspace (`,t,`)`]}),Array.from({length:16},(e,t)=>t+z).map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})}export{I as a,L as i,B as n,R as r,J as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{ci as i,qt as a}from"./project-scope-context-DqBHMdSb.js";import{Pt as o,Tt as s,in as c,t as l}from"./queries-DeeY9cGJ.js";import{n as u}from"./toaster-Bo5vCbz-.js";import{J as d,W as f,c as p,ft as m,l as h,tt as g}from"./design-icons-CzEoMH9c.js";import{t as _}from"./button-BQ2y4XRB.js";import{i as v,r as y,t as b}from"./popover-BPgUYFyu.js";import{a as x,i as S,o as C,r as w,s as T,t as E}from"./command-CDt1BsZy.js";import{f as D,i as O,p as k,u as A}from"./skills-pM_PouEs.js";import{t as j}from"./centered-state-V15AR_qo.js";import{Hn as M,Q as N,at as P,nt as F,tt as I}from"./index-CilVqe_c.js";import{t as L}from"./textarea-vJt9undk.js";var R=e(t(),1),z=n();function B(){let e=s();return e.isPending?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading prompt templates…`}):e.isError?(0,z.jsx)(j,{icon:(0,z.jsx)(f,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:e.error.message,heading:`h2`}):(0,z.jsx)(V,{initial:F(e.data.promptTemplates)})}function V({initial:e}){let t=i(),n=o(),r=s(),[f,p]=(0,R.useState)(e),[h,g]=(0,R.useState)(``),[v,y]=(0,R.useState)(``),b=c({mutationFn:e=>a({promptTemplates:e}),onSuccess:e=>{t.setQueryData(l.uiState,e),u(`Prompt templates saved`)},onError:e=>u(e.message,{tone:`danger`})}),x=JSON.stringify(f)!==JSON.stringify(e),S=f.some(e=>e.label.trim()===``||e.text.trim()===``),C=(e,t)=>p(n=>n.map(n=>n.id===e?{...n,...t}:n)),w=(e,t)=>p(n=>n.map(n=>{if(n.id!==e)return n;let r=n.skills??[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],{skills:a,...o}=n;return i.length>0?{...o,skills:i}:o})),T=e=>p(t=>t.filter(t=>t.id!==e));return(0,z.jsx)(`div`,{"data-slot":`prompt-templates-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,z.jsxs)(U,{title:`Reusable instructions`,hint:`Insert templates from task composers, or apply them automatically with selected skills when the prompt is empty.`,children:[(0,z.jsx)(`div`,{"data-slot":`prompt-template-list`,className:`flex flex-col gap-3`,children:f.length===0?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-[13px] text-soft-foreground`,children:`No templates. Add one below, or reset to the built-ins.`}):f.map(e=>(0,z.jsxs)(`div`,{"data-slot":`prompt-template-row`,"data-template":e.id,className:`flex flex-col gap-1.5 rounded-md border border-border bg-card p-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`label`,{htmlFor:`template-label-${e.id}`,className:`text-sm`,children:`Template label`}),(0,z.jsx)(M,{id:`template-label-${e.id}`,"aria-label":`Label for ${e.label||`this template`}`,"data-slot":`prompt-template-label-input`,value:e.label,maxLength:80,onChange:t=>C(e.id,{label:t.target.value}),className:`flex-1`})]}),(0,z.jsx)(`label`,{htmlFor:`template-text-${e.id}`,className:`text-sm`,children:`Instructions`}),(0,z.jsx)(L,{id:`template-text-${e.id}`,"aria-label":`Text for ${e.label||`this template`}`,"data-slot":`prompt-template-text-input`,value:e.text,maxLength:2e3,onChange:t=>C(e.id,{text:t.target.value}),className:`min-h-14 text-[13px]`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm`,children:`Apply automatically with skills`}),(0,z.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,z.jsx)(H,{label:e.label,skills:n.data??[],skillUsage:r.data?.skillUsage,selected:e.skills??[],onToggle:t=>w(e.id,t)}),(e.skills??[]).map(t=>(0,z.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skill-chip`,"data-skill":t,title:`Stop applying “${e.label}” automatically with ${t}`,onClick:()=>w(e.id,t),className:`inline-flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-px font-mono text-[11px] font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[t,(0,z.jsx)(m,{"aria-hidden":`true`,className:`size-3`})]},t))]}),(0,z.jsx)(_,{type:`button`,className:`self-start`,variant:`outline`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>T(e.id),children:`Delete template`})]},e.id))}),(0,z.jsxs)(`div`,{"data-slot":`prompt-template-new`,className:`flex flex-col gap-1.5 rounded-md border border-dashed border-border p-3`,children:[(0,z.jsx)(`h3`,{className:`text-lg`,children:`New template`}),(0,z.jsx)(`label`,{htmlFor:`new-template-label`,className:`text-sm`,children:`Label`}),(0,z.jsx)(M,{id:`new-template-label`,"aria-label":`New template label`,"data-slot":`prompt-template-new-label`,placeholder:`e.g. Review security`,value:h,maxLength:80,onChange:e=>g(e.target.value)}),(0,z.jsx)(`label`,{htmlFor:`new-template-text`,className:`text-sm`,children:`Instructions to insert`}),(0,z.jsx)(L,{id:`new-template-text`,"aria-label":`New template text`,"data-slot":`prompt-template-new-text`,placeholder:`Enter reusable instructions…`,value:v,maxLength:2e3,onChange:e=>y(e.target.value),className:`min-h-14 text-[13px]`}),(0,z.jsxs)(_,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,disabled:!h.trim()||!v.trim(),onClick:()=>{let e=h.trim(),t=v.trim();!e||!t||(p(n=>[...n,{id:I(),label:e,text:t}]),g(``),y(``))},className:`self-start`,children:[(0,z.jsx)(d,{"aria-hidden":`true`,className:`size-3.5`}),`Add template`]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(_,{type:`button`,variant:`primary`,size:`sm`,"data-action":`prompt-templates-save`,disabled:!x||S||b.isPending,onClick:()=>b.mutate(f),children:`Save`}),(0,z.jsx)(_,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:b.isPending,onClick:()=>p(N.map(e=>({...e}))),children:`Reset to defaults`}),S?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-[11px] text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function H({label:e,skills:t,skillUsage:n,selected:i,onToggle:a}){let[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(``),u=(0,R.useRef)(null),{mostUsed:d,project:f,global:m,ranked:_}=A(t,c,n),j=(e,t)=>{let n=i.includes(e.id);return(0,z.jsxs)(C,{value:D(e),keywords:k(e.name,e.description),"data-slot":`prompt-template-skill-option`,"data-skill":e.id,"data-selected":n?`true`:void 0,onSelect:()=>a(e.id),children:[(0,z.jsx)(P,{skill:e,emphasized:t}),n?(0,z.jsx)(p,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},D(e))};return(0,z.jsxs)(b,{open:o,onOpenChange:e=>{s(e),e||l(``)},children:[(0,z.jsx)(v,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skills-trigger`,"aria-label":`Apply ${e||`this template`} automatically with a skill`,title:`Pick the skills this template applies itself to`,className:r(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,i.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,z.jsx)(g,{"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`apply with…`,(0,z.jsx)(h,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,z.jsx)(y,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,z.jsxs)(E,{shouldFilter:!1,children:[(0,z.jsx)(x,{placeholder:`search skills…`,value:c,onValueChange:l,onInput:()=>u.current?.scrollTo(0,0)}),(0,z.jsxs)(T,{ref:u,"data-slot":`prompt-template-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.trim()&&!t.some(e=>e.id===c.trim())?(0,z.jsx)(S,{children:(0,z.jsxs)(C,{value:`typed-skill`,onSelect:()=>a(c.trim()),children:[`Use skill id “`,c.trim(),`” (unchecked)`]})}):null,(_?_.length===0:d.length===0&&f.length===0&&m.length===0)?(0,z.jsx)(w,{children:`Nothing matches.`}):null,_?_.length>0?(0,z.jsx)(S,{children:_.map(e=>j(e,O(e)))}):null:(0,z.jsxs)(z.Fragment,{children:[d.length>0?(0,z.jsx)(S,{heading:`Most used`,children:d.map(e=>j(e,O(e)))}):null,f.length>0?(0,z.jsx)(S,{heading:`Project skills`,children:f.map(e=>j(e,!0))}):null,m.length>0?(0,z.jsx)(S,{heading:`Global`,children:m.map(e=>j(e,!1))}):null]})]})]})})]})}function U({title:e,hint:t,children:n}){return(0,z.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,z.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}export{B as PromptTemplatesSection};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{ci as i,qt as a}from"./project-scope-context-DqBHMdSb.js";import{Pt as o,Tt as s,in as c,t as l}from"./queries-DeeY9cGJ.js";import{n as u}from"./toaster-Bo5vCbz-.js";import{J as d,W as f,c as p,ft as m,l as h,tt as g}from"./design-icons-CzEoMH9c.js";import{t as _}from"./button-BQ2y4XRB.js";import{i as v,r as y,t as b}from"./popover-BPgUYFyu.js";import{a as x,i as S,o as C,r as w,s as T,t as E}from"./command-CDt1BsZy.js";import{f as D,i as O,p as k,u as A}from"./skills-pM_PouEs.js";import{t as j}from"./centered-state-V15AR_qo.js";import{Hn as M,Q as N,at as P,nt as F,tt as I}from"./index-DfmmHZB9.js";import{t as L}from"./textarea-vJt9undk.js";var R=e(t(),1),z=n();function B(){let e=s();return e.isPending?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading prompt templates…`}):e.isError?(0,z.jsx)(j,{icon:(0,z.jsx)(f,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:e.error.message,heading:`h2`}):(0,z.jsx)(V,{initial:F(e.data.promptTemplates)})}function V({initial:e}){let t=i(),n=o(),r=s(),[f,p]=(0,R.useState)(e),[h,g]=(0,R.useState)(``),[v,y]=(0,R.useState)(``),b=c({mutationFn:e=>a({promptTemplates:e}),onSuccess:e=>{t.setQueryData(l.uiState,e),u(`Prompt templates saved`)},onError:e=>u(e.message,{tone:`danger`})}),x=JSON.stringify(f)!==JSON.stringify(e),S=f.some(e=>e.label.trim()===``||e.text.trim()===``),C=(e,t)=>p(n=>n.map(n=>n.id===e?{...n,...t}:n)),w=(e,t)=>p(n=>n.map(n=>{if(n.id!==e)return n;let r=n.skills??[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],{skills:a,...o}=n;return i.length>0?{...o,skills:i}:o})),T=e=>p(t=>t.filter(t=>t.id!==e));return(0,z.jsx)(`div`,{"data-slot":`prompt-templates-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,z.jsxs)(U,{title:`Reusable instructions`,hint:`Insert templates from task composers, or apply them automatically with selected skills when the prompt is empty.`,children:[(0,z.jsx)(`div`,{"data-slot":`prompt-template-list`,className:`flex flex-col gap-3`,children:f.length===0?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-[13px] text-soft-foreground`,children:`No templates. Add one below, or reset to the built-ins.`}):f.map(e=>(0,z.jsxs)(`div`,{"data-slot":`prompt-template-row`,"data-template":e.id,className:`flex flex-col gap-1.5 rounded-md border border-border bg-card p-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`label`,{htmlFor:`template-label-${e.id}`,className:`text-sm`,children:`Template label`}),(0,z.jsx)(M,{id:`template-label-${e.id}`,"aria-label":`Label for ${e.label||`this template`}`,"data-slot":`prompt-template-label-input`,value:e.label,maxLength:80,onChange:t=>C(e.id,{label:t.target.value}),className:`flex-1`})]}),(0,z.jsx)(`label`,{htmlFor:`template-text-${e.id}`,className:`text-sm`,children:`Instructions`}),(0,z.jsx)(L,{id:`template-text-${e.id}`,"aria-label":`Text for ${e.label||`this template`}`,"data-slot":`prompt-template-text-input`,value:e.text,maxLength:2e3,onChange:t=>C(e.id,{text:t.target.value}),className:`min-h-14 text-[13px]`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm`,children:`Apply automatically with skills`}),(0,z.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,z.jsx)(H,{label:e.label,skills:n.data??[],skillUsage:r.data?.skillUsage,selected:e.skills??[],onToggle:t=>w(e.id,t)}),(e.skills??[]).map(t=>(0,z.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skill-chip`,"data-skill":t,title:`Stop applying “${e.label}” automatically with ${t}`,onClick:()=>w(e.id,t),className:`inline-flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-px font-mono text-[11px] font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[t,(0,z.jsx)(m,{"aria-hidden":`true`,className:`size-3`})]},t))]}),(0,z.jsx)(_,{type:`button`,className:`self-start`,variant:`outline`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>T(e.id),children:`Delete template`})]},e.id))}),(0,z.jsxs)(`div`,{"data-slot":`prompt-template-new`,className:`flex flex-col gap-1.5 rounded-md border border-dashed border-border p-3`,children:[(0,z.jsx)(`h3`,{className:`text-lg`,children:`New template`}),(0,z.jsx)(`label`,{htmlFor:`new-template-label`,className:`text-sm`,children:`Label`}),(0,z.jsx)(M,{id:`new-template-label`,"aria-label":`New template label`,"data-slot":`prompt-template-new-label`,placeholder:`e.g. Review security`,value:h,maxLength:80,onChange:e=>g(e.target.value)}),(0,z.jsx)(`label`,{htmlFor:`new-template-text`,className:`text-sm`,children:`Instructions to insert`}),(0,z.jsx)(L,{id:`new-template-text`,"aria-label":`New template text`,"data-slot":`prompt-template-new-text`,placeholder:`Enter reusable instructions…`,value:v,maxLength:2e3,onChange:e=>y(e.target.value),className:`min-h-14 text-[13px]`}),(0,z.jsxs)(_,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,disabled:!h.trim()||!v.trim(),onClick:()=>{let e=h.trim(),t=v.trim();!e||!t||(p(n=>[...n,{id:I(),label:e,text:t}]),g(``),y(``))},className:`self-start`,children:[(0,z.jsx)(d,{"aria-hidden":`true`,className:`size-3.5`}),`Add template`]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(_,{type:`button`,variant:`primary`,size:`sm`,"data-action":`prompt-templates-save`,disabled:!x||S||b.isPending,onClick:()=>b.mutate(f),children:`Save`}),(0,z.jsx)(_,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:b.isPending,onClick:()=>p(N.map(e=>({...e}))),children:`Reset to defaults`}),S?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-[11px] text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function H({label:e,skills:t,skillUsage:n,selected:i,onToggle:a}){let[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(``),u=(0,R.useRef)(null),{mostUsed:d,project:f,global:m,ranked:_}=A(t,c,n),j=(e,t)=>{let n=i.includes(e.id);return(0,z.jsxs)(C,{value:D(e),keywords:k(e.name,e.description),"data-slot":`prompt-template-skill-option`,"data-skill":e.id,"data-selected":n?`true`:void 0,onSelect:()=>a(e.id),children:[(0,z.jsx)(P,{skill:e,emphasized:t}),n?(0,z.jsx)(p,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},D(e))};return(0,z.jsxs)(b,{open:o,onOpenChange:e=>{s(e),e||l(``)},children:[(0,z.jsx)(v,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skills-trigger`,"aria-label":`Apply ${e||`this template`} automatically with a skill`,title:`Pick the skills this template applies itself to`,className:r(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,i.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,z.jsx)(g,{"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`apply with…`,(0,z.jsx)(h,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,z.jsx)(y,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,z.jsxs)(E,{shouldFilter:!1,children:[(0,z.jsx)(x,{placeholder:`search skills…`,value:c,onValueChange:l,onInput:()=>u.current?.scrollTo(0,0)}),(0,z.jsxs)(T,{ref:u,"data-slot":`prompt-template-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.trim()&&!t.some(e=>e.id===c.trim())?(0,z.jsx)(S,{children:(0,z.jsxs)(C,{value:`typed-skill`,onSelect:()=>a(c.trim()),children:[`Use skill id “`,c.trim(),`” (unchecked)`]})}):null,(_?_.length===0:d.length===0&&f.length===0&&m.length===0)?(0,z.jsx)(w,{children:`Nothing matches.`}):null,_?_.length>0?(0,z.jsx)(S,{children:_.map(e=>j(e,O(e)))}):null:(0,z.jsxs)(z.Fragment,{children:[d.length>0?(0,z.jsx)(S,{heading:`Most used`,children:d.map(e=>j(e,O(e)))}):null,f.length>0?(0,z.jsx)(S,{heading:`Project skills`,children:f.map(e=>j(e,!0))}):null,m.length>0?(0,z.jsx)(S,{heading:`Global`,children:m.map(e=>j(e,!1))}):null]})]})]})})]})}function U({title:e,hint:t,children:n}){return(0,z.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,z.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}export{B as PromptTemplatesSection};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{ci as r}from"./project-scope-context-DqBHMdSb.js";import{M as i,t as a}from"./queries-DeeY9cGJ.js";import{gn as o}from"./index-CilVqe_c.js";var s=e(t(),1),c=n();function l(){let e=r(),t=(0,s.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:a.health}),e.invalidateQueries({queryKey:a.agentConfig,exact:!0})])},[e]);return(0,s.useEffect)(()=>{t()},[t]),t}var u=`${o()} remote-settings enable`;function d({risk:e}){return i().data?.capabilities?.remoteSettingsAdmin===!0?(0,c.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,c.jsxs)(`code`,{children:[o(),` remote-settings disable`]}),`.`]}):null}export{d as n,l as r,u as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{ci as r}from"./project-scope-context-DqBHMdSb.js";import{M as i,t as a}from"./queries-DeeY9cGJ.js";import{gn as o}from"./index-DfmmHZB9.js";var s=e(t(),1),c=n();function l(){let e=r(),t=(0,s.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:a.health}),e.invalidateQueries({queryKey:a.agentConfig,exact:!0})])},[e]);return(0,s.useEffect)(()=>{t()},[t]),t}var u=`${o()} remote-settings enable`;function d({risk:e}){return i().data?.capabilities?.remoteSettingsAdmin===!0?(0,c.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,c.jsxs)(`code`,{children:[o(),` remote-settings disable`]}),`.`]}):null}export{d as n,l as r,u as t};