@wjarka/cezarion 0.18.0-dev.7724 → 0.18.0-dev.7731
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/web/dist/app-icon.png +0 -0
- package/web/dist/assets/{activity-motion-4jefGnf3.js → activity-motion-CHWLFQui.js} +1 -1
- package/web/dist/assets/{activity-route-CrgEEOkP.js → activity-route-CDZ8vEvw.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-BhqIhVpi.js → commit-diff-panel-BiFrj_Kg.js} +1 -1
- package/web/dist/assets/{diff-Dtz4yPu-.js → diff-Bp_ZwIlK.js} +2 -2
- package/web/dist/assets/{diff-view-01iQrxA3.js → diff-view-BLWY32aP.js} +1 -1
- package/web/dist/assets/{file-preview-Bqu0JXBY.js → file-preview-BMb-p58M.js} +1 -1
- package/web/dist/assets/{git-toolbar-zEjeF-_V.js → git-toolbar-BLOs2P23.js} +1 -1
- package/web/dist/assets/{github-D3a22EyV.js → github-DLd49gwL.js} +1 -1
- package/web/dist/assets/{global-activity-route-DXD818_k.js → global-activity-route-C6qUGiQ-.js} +1 -1
- package/web/dist/assets/{index-DPA7Ibhf.js → index-D9Yu2XLO.js} +11 -11
- package/web/dist/assets/{markdown-Dzq31k8-.js → markdown-HUI2AGRH.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-TaIGMKvt.js → preview-pane-connected-Br0FHHb0.js} +1 -1
- package/web/dist/assets/{repo-git-BvN7c_-7.js → repo-git-CXxRkRrr.js} +1 -1
- package/web/dist/assets/{report-reader-BEGToSIA.js → report-reader-DK9rxnu_.js} +1 -1
- package/web/dist/assets/{reports-D61rDO35.js → reports-DyqYeCfW.js} +1 -1
- package/web/dist/assets/{run-header-gwQQqs03.js → run-header-DI2Zp-1g.js} +1 -1
- package/web/dist/assets/{skills-DB3DAhWt.js → skills-BsojRHiF.js} +1 -1
- package/web/dist/assets/{task-changes-C4Hp9Bog.js → task-changes-D0fhNQ8e.js} +1 -1
- package/web/dist/assets/{task-commits-IGZ1CJcy.js → task-commits-DfPvhSgU.js} +1 -1
- package/web/dist/assets/{task-files-CBrQO4v2.js → task-files-Do9eS-uO.js} +1 -1
- package/web/dist/assets/{task-github-item-BJwFCJMl.js → task-github-item-IDiDedZh.js} +1 -1
- package/web/dist/assets/{task-thread-Dkn8HN1R.js → task-thread-BK0lz7hd.js} +1 -1
- package/web/dist/assets/{thread-state-DVfKElYJ.js → thread-state-D2FZC_j9.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-ChF_oDo3.js → use-hand-to-agent-state-CntaNwZk.js} +1 -1
- package/web/dist/assets/{workflows-BTzKBfs-.js → workflows-BnU1T_ay.js} +1 -1
- package/web/dist/index.html +13 -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{C as r,S as i,d as a,w as o}from"./button-C1fD-ZFr.js";import{i as s}from"./bundle-mjs-BT31bpU6.js";import{G as c,J as l,K as u,W as d,dt as f,ft as ee,gt as p,ht as m,lt as h,mt as g,pt as te,ut as ne}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{C as r,S as i,d as a,w as o}from"./button-C1fD-ZFr.js";import{i as s}from"./bundle-mjs-BT31bpU6.js";import{G as c,J as l,K as u,W as d,dt as f,ft as ee,gt as p,ht as m,lt as h,mt as g,pt as te,ut as ne}from"./index-D9Yu2XLO.js";import{i as re,n as _}from"./chunk-BO2N2NFS-CM5F_Wdn.js";var v=e(t(),1),y=n();function b({isOpen:e,onClose:t,onConfirm:n,url:r}){return(0,y.jsx)(h,{open:e,onOpenChange:e=>{e||t()},children:(0,y.jsxs)(ee,{"data-slot":`link-safety-dialog`,children:[(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:`Open this link?`}),(0,y.jsxs)(te,{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)(g,{children:[(0,y.jsx)(f,{children:`Cancel`}),(0,y.jsx)(ne,{onClick:n,children:`Open link`})]})]})})}var x=String.raw`https?:\/\/(?:cdn\.jsdelivr\.net\/npm|unpkg\.com)\/`,ie=[{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 ie.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 s(()=>import(`./index.global-D3Ga_D3Y.js`),[])).default,"tailwind-v3":()=>Promise.resolve(se),mermaid:async()=>(await s(()=>import(`./mermaid.min-3O9YjB2l.js`),[])).default};async function E(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 ae(){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 oe=`(${ae.toString()})()`,se=[`@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
|
`),D=`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'`,ce=`${D}; frame-src 'none'`,O=`allow-scripts allow-popups allow-popups-to-escape-sandbox`,k=`clipboard-write`,A=`data:text/javascript,export%20default%20globalThis.mermaid`;function j(e){return/\.html?$/i.test(e)}var M=/^(?:https?:|mailto:)/i,N=/^data:/i,P=`http://www.w3.org/1999/xlink`,F=/^(?:[a-z][a-z\d+.-]*:|\/\/)/i,I=/url\(\s*(['"]?)([^'")]*)\1\s*\)|@import\s+(['"])([^'"]+)\3/gi,L=[`src`,`href`,`xlink:href`,`poster`,`background`],R=/(?:^|,)\s*(data:\S+|[^,\s]+)/gi,z=/\b(?:preconnect|dns-prefetch|prefetch|preload|modulepreload|prerender)\b/i;function B(e,t){let n=e.trim();!n||n.startsWith(`#`)||N.test(n)||(F.test(n)?t.remote++:t.relative++)}function V(e,t){for(let n of e.matchAll(I))B(n[2]??n[4]??``,t)}function H(e,t){let n=e.createElement(`script`);return n.textContent=t.replace(/<\/script/gi,`<\\/script`),n}function U(e,t){let n=e.createElement(`style`);return n.setAttribute(`type`,`text/tailwindcss`),n.textContent=t,n}var W=`http://www.w3.org/2000/svg`;function G(e){return e.namespaceURI===W?e.getAttribute(`href`)??e.getAttributeNS(P,`href`):e.getAttribute(`src`)}function le(e,t,n,r){let i=r===void 0?[]:[U(e,r),H(e,oe)],a=H(e,n),o=t.hasAttribute(`defer`)||t.hasAttribute(`async`)||t.getAttribute(`type`)===`module`;o&&e.body.append(a),t.replaceWith(...i,...o?[]:[a])}function K(e,t,n){let r=new Set,i=new Set;for(let a of[...e.querySelectorAll(`script`)]){let o=G(a);if(o!==null&&N.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),le(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,A]))}),e.head.prepend(a,...r.has(`mermaid`)?[]:[H(e,n.mermaid)])}function ue(e,t,n){let r=t=>{let n=[...e.querySelectorAll(t)];return n.forEach(e=>e.remove()),n.length};K(e,t,n),t.embeds=r(`iframe, frame, frameset, object, embed, portal`),r(`base, meta[http-equiv]`);for(let t of e.querySelectorAll(`link`))z.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 de(e,t){for(let n of e.querySelectorAll(`a, area`)){let e=n.getAttribute(`href`)??n.getAttributeNS(P,`href`);if(e===null)continue;let r=e.trim();if(r.startsWith(`#`)){n.setAttribute(`href`,`about:srcdoc${r}`),n.removeAttributeNS(P,`href`),n.removeAttribute(`target`);continue}if(M.test(r)){n.setAttribute(`target`,`_blank`),n.setAttribute(`rel`,`noopener noreferrer`);continue}F.test(r)||t.relative++,n.removeAttribute(`href`),n.removeAttributeNS(P,`href`),n.removeAttribute(`target`)}}function fe(e,t){for(let n of e.querySelectorAll(`[style]`))V(n.getAttribute(`style`),t);for(let n of e.querySelectorAll(`style`))/^(?:text\/css)?$/i.test(n.getAttribute(`type`)?.trim()??``)&&V(n.textContent??``,t);for(let n of e.querySelectorAll(`link[href]`))B(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 L){let r=n.getAttribute(e);r!==null&&B(r,t)}for(let e of(n.getAttribute(`srcset`)??``).matchAll(R))B(e[1],t)}}function pe(e,t={}){let n=new DOMParser().parseFromString(e,`text/html`),r={scripts:0,remote:0,relative:0,forms:0,embeds:0};ue(n,r,t),de(n,r),fe(n,r);let i=n.createElement(`meta`);i.setAttribute(`http-equiv`,`Content-Security-Policy`),i.setAttribute(`content`,D);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 q=e=>e.replace(/&/g,`&`).replace(/"/g,`"`);function me(e,t){return`<!DOCTYPE html><html><head><meta http-equiv="Content-Security-Policy" content="${ce}"><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="${q(t)}" sandbox="${O}" allow="${k}" referrerpolicy="no-referrer" srcdoc="${q(e)}"></iframe></body></html>`}var J=(0,v.createContext)(null),he=/^[0-9a-f-]{36}$/i,ge=/^(\/p\/[^/?#]+\/tasks\/[^/?#]+)\/files\?(artifact=[^&#]*)$/;function Y(e){let t=new URLSearchParams(e);return[...t.keys()].length===1&&he.test(t.get(`artifact`)??``)}function _e(e,t,n){if(e.startsWith(`${t}?artifact=`))return Y(e.slice(t.length+1))?n+e.slice(t.length):null;let r=ge.exec(e);return r&&Y(r[2])?`${r[1]}/report?${r[2]}`:void 0}var ve=/^\/(?:api|p|tasks|new|settings|skills|workflows|git|github|inbox|automations)(?:\/|[?#]|$)/;function ye(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 X(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=_e(r,o,a+s);if(c!==void 0)return c===null?null:c+i;if(ve.test(r))return null;let l=ye(r,t.basePath);return l===null?null:`${a}${j(l)?s:o}?path=${encodeURIComponent(l)}${i}`}var Z=`text-accent-text underline underline-offset-2`;function be({href:e,children:t,internal:n,...r}){let[a,o]=(0,v.useState)(!1),s=i();return e?n?s?(0,y.jsx)(xe,{...r,href:e,children:t}):(0,y.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:Z,children:t}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:`cursor-pointer ${Z}`,onClick:e=>{e.preventDefault(),o(!0)},children:t}),(0,y.jsx)(b,{isOpen:a,url:e,onClose:()=>o(!1),onConfirm:()=>{window.open(e,`_blank`,`noreferrer`),o(!1)}})]}):(0,y.jsx)(`span`,{children:t})}function xe({href:e,children:t,...n}){let i=o(),a=r();return(0,y.jsx)(`a`,{...n,href:e,"data-streamdown":`link`,className:Z,onClick:t=>Q(t,i,e,a),children:t})}function Q(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 Se={name:`shiki`,type:`code-highlighter`,getThemes:()=>[d,d],getSupportedLanguages:()=>l(),supportsLanguage:e=>l().includes(String(e).toLowerCase()),highlight:({code:e,language:t},n)=>u(e,String(t))||(c(e,String(t)).then(e=>n?.(e)),null)};function Ce(){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 $=[...Object.values(_),Ce],we=[`p`,`strong`,`em`,`del`,`code`,`a`],Te={p:`span`,a:`span`},Ee={enabled:!0,renderModal:e=>(0,y.jsx)(b,{...e})},De=`https://refused.invalid/`,Oe=0,ke=(0,v.memo)(function({children:e,breaks:t=!1,inline:n=!1,document:r=!1,imageSrc:i}){let o=(0,v.useContext)(J),s=(0,v.useMemo)(()=>{let e={instance:++Oe},n=new Set;function a(){let e=t=>{if((t.type===`link`||t.type===`definition`)&&t.url&&o){let e=X(t.url,o);e&&(t.url=e,n.add(e))}t.children?.forEach(e)};return e}let s=new Set;function c(){let e=t=>{if(t.type===`image`&&t.url&&i){let e=i(t.url);t.url=e?new URL(e,window.location.href).href:De,e&&s.add(t.url)}t.children?.forEach(e)};return e}let l=o?[[a,e]]:[],u=r&&i?[[c,e]]:[];return{remark:[...t?$:Object.values(_),...l,...u],components:{...o||r?{a:({href:e,children:t})=>r&&!o&&!/^(?:https?:|mailto:|#)/i.test(e??``)?(0,y.jsx)(`span`,{children:t}):(0,y.jsx)(be,{href:e,internal:n.has(e??``),children:t})}:{},...r?{img:({src:e,alt:t})=>typeof e==`string`&&s.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,r,i]);return(0,y.jsx)(re,{className:n?`thread-markdown thread-markdown-inline`:`thread-markdown`,plugins:{code:Se},shikiTheme:[d,d],...a({remarkPlugins:o||r&&i?s.remark:t?$:void 0,allowedElements:n?we:void 0,unwrapDisallowed:n||void 0,components:n?Te:o||r?s.components:void 0}),linkSafety:Ee,controls:{code:{copy:!0,download:!1},table:!1,mermaid:!1},lineNumbers:!1,children:e})});export{k as a,pe as c,E as d,X as i,me as l,Q as n,O as o,J as r,j as s,ke as t,w as u};
|
package/web/dist/assets/{preview-pane-connected-TaIGMKvt.js → preview-pane-connected-Br0FHHb0.js}
RENAMED
|
@@ -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{l as r,t as i}from"./button-C1fD-ZFr.js";import{Ir as a,Lr as o,Rr as s,dr as c}from"./project-scope-context-CR3cozni.js";import{n as l}from"./toaster-Cxgzn9ip.js";import{t as u}from"./createLucideIcon-BHp8sXmF.js";import{t as d}from"./arrow-right-Dh_Lx3um.js";import{n as f,r as p,t as m}from"./hourglass-B0lPAJvT.js";import{t as h}from"./info-DA1x_4bz.js";import{a as g}from"./format-BNCkW110.js";import{t as _}from"./play-CmVAj_fu.js";import{d as v,l as y,n as b,u as x}from"./thread-state-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{l as r,t as i}from"./button-C1fD-ZFr.js";import{Ir as a,Lr as o,Rr as s,dr as c}from"./project-scope-context-CR3cozni.js";import{n as l}from"./toaster-Cxgzn9ip.js";import{t as u}from"./createLucideIcon-BHp8sXmF.js";import{t as d}from"./arrow-right-Dh_Lx3um.js";import{n as f,r as p,t as m}from"./hourglass-B0lPAJvT.js";import{t as h}from"./info-DA1x_4bz.js";import{a as g}from"./format-BNCkW110.js";import{t as _}from"./play-CmVAj_fu.js";import{d as v,l as y,n as b,u as x}from"./thread-state-D2FZC_j9.js";import{a as S,c as C,i as w,l as T,p as E,r as D,s as ee,t as O}from"./dropdown-menu-DRFDwG2X.js";import{s as te}from"./project-router-BLLH9tz9.js";import{Bt as ne,Ht as k,Vt as A,Zt as j,_n as re,b as ie,cn as ae,d as oe,f as se,g as ce,gn as le,h as M,in as ue,ln as de,m as fe,mn as N,nn as pe,p as me,pn as he,rn as ge,sn as _e,un as P,vn as F,x as ve,y as ye,zt as I}from"./index-D9Yu2XLO.js";var be=u(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),xe=u(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),L=u(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),R=u(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),z=u(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),B=u(`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`}]]),V=u(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Se=u(`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`}]]),Ce=u(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),H=u(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),U=u(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),W=u(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),G=u(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),K=u(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),q=u(`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`}]]),we=u(`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`}]]),Te=u(`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`}]]),Ee=u(`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=u(`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}`,i=null,s,l=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||a(),m=()=>{if(l||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,i=n,n.addEventListener(`open`,()=>{n===i&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==i)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=c.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(f=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==i||l)return;if(i=null,!u){if(d+=1,d>=2){l=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),s=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),s=setTimeout(m,e)})},h=o(e=>{if(!l)if(e)i||m();else{clearTimeout(s),s=void 0;let e=i;i=null,e?.close()}});return t.onTransport(`connecting`),m(),{send(e){i?.readyState===Ae&&i.send(JSON.stringify(e))},close(){l=!0,h(),clearTimeout(s),s=void 0;let e=i;i=null,e?.close()}}}var Y=n();function Me({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(A,{children:(0,Y.jsxs)(I,{children:[(0,Y.jsx)(k,{asChild:!0,children:(0,Y.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-0 rounded-full bg-muted px-0 text-xs font-semibold text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none @min-[640px]:gap-1.5 @min-[640px]:px-2.5`,n),children:[(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(ne,{children:`Experimental`})]})}):e?(0,Y.jsx)(A,{children:(0,Y.jsxs)(I,{children:[(0,Y.jsx)(k,{asChild:!0,children:(0,Y.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(ne,{children:`Experimental`})]})}):(0,Y.jsxs)(`span`,{"data-slot":`preview-experimental`,className:r(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-muted px-2.5 text-xs font-semibold text-muted-foreground`,n),children:[(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function 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)(N,{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)(ge,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Runs ${M(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)(N,{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)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,Y.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,Y.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,Y.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,Y.jsx)(`span`,{children:`cwd`}),(0,Y.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,Y.jsx)(`div`,{className:`mt-2.5`,children:(0,Y.jsx)(Be,{server:e})})]})}function Ue({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(R,{}),title:`This host has no browser yet`,children:[(0,Y.jsx)(Z,{children:e.canDownload?`Preview runs Chromium on the machine 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)(i,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(R,{"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,a=(Date.now()-n.current.at)/1e3,o=a>=1?(e.received-n.current.received)/a:0,s=o>0?Math.ceil((e.total-e.received)/o):void 0;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(R,{}),title:`Downloading Chromium`,children:[(0,Y.jsx)(Z,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":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}%`}),s===void 0?null:(0,Y.jsx)(`span`,{children:`about ${s} s left`})]})]}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(i,{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)(Te,{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)(i,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Retry download`]}),(0,Y.jsxs)(i,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function qe({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(q,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,Y.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)(i,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(i,{variant:`outline`,onClick:()=>t.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,Y.jsx)(N,{"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})`,a=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,o=n?`Chromium did not start in time`:`Chromium exited${r}`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(f,{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. ${a}`:`Chromium exited unexpectedly${r}. ${a}`}),(0,Y.jsx)(Ne,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(i,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(i,{variant:`outline`,onClick:()=>t.copy(`${o}\n${e.stderrTail}`),children:[(0,Y.jsx)(N,{"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)(Ee,{className:`text-pending-strong`}):(0,Y.jsx)(_,{}),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)(i,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(_,{"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)(Te,{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)(i,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function $e({state:e,actions:t}){let{server:n}=e,r=Xe(1e3),a=Math.max(0,Math.floor((r-Date.parse(e.startedAt))/1e3)),[o,s]=(0,J.useState)(()=>Date.now());(0,J.useEffect)(()=>s(Date.now()),[e.attempt]);let c=Math.max(0,Math.ceil(Ye-(r-o)/1e3));return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(_,{}),title:`Starting ${n.label}`,children:[(0,Y.jsx)(Z,{children:`Squawk ran ${M(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)(g,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),c>0?`Attempt ${e.attempt} · next try in ${c} s`:`Attempt ${e.attempt}`]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${a} s ago`})]}),e.logTail.length>0?(0,Y.jsx)(Ne,{text:e.logTail.join(`
|
|
3
3
|
`),source:M(n.command),onCopy:t.copy}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(i,{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)(m,{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:M(n.command),onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(i,{variant:`contrast`,onClick:()=>t.keepWaiting(n.port),children:`Keep waiting`}),(0,Y.jsx)(i,{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)(f,{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:`${M(n.command)} stopped.`}),(0,Y.jsx)(Ne,{text:e.logTail,source:M(n.command),onCopy:t.copy}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(i,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(v,{"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)(_e,{}),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)(i,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(v,{"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)(p,{className:`size-5 text-success`,"aria-hidden":`true`}):a?(0,Y.jsx)(g,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,Y.jsx)(L,{className:`size-5 text-border`,"aria-hidden":`true`}),i?e.done:a?e.active:e.done]},t)})})})}function at({state:e,actions:t,worktree:n}){let r=n?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(n)?.[0]:void 0,a=e.server?.label;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(B,{}),title:`This task's worktree is gone`,children:[(0,Y.jsx)(Z,{children:`${a??`The server`} ran in ${r??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,Y.jsx)(y,{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)(i,{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)(W,{})}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,Y.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)(i,{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)(U,{}),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)(i,{variant:`contrast`,onClick:t.useHere,children:[(0,Y.jsx)(R,{"aria-hidden":`true`}),`Use it here`]}),(0,Y.jsx)(i,{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)(i,{variant:`outline`,onClick:n,children:t?`Reconnect`:`Reconnect now`})]})}function ut({servers:e,states:t,onOpen:n,agentLive:r=!1,agentIdle:a=!1,onOpenAgent:o}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":a?`agent-idle`:`empty`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,Y.jsx)(Z,{children:`The browser runs on the host, next to the worktree. Type a URL, a bare port such as 3000, or open a server the agent registered.`}),a?(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,Y.jsx)(Ee,{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&&o!==void 0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-agent`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Driven by the agent`}),(0,Y.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,Y.jsx)(i,{variant:`outline`,size:`sm`,className:`max-md:h-11`,"aria-label":`Open the agent's page`,onClick:o,children:`Open`})]})]}):null,e.length>0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-registered`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Registered in this task`}),(0,Y.jsx)(`ul`,{children:e.map(e=>{let r=me(e,t),a=ce(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)(j,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:a.text})]}),(0,Y.jsx)(i,{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)(h,{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??``),a=e.type===`beforeunload`,o=(0,J.useRef)(null),s=(0,J.useRef)(null);(0,J.useEffect)(()=>{(e.type===`prompt`?s.current:o.current)?.focus()},[e.type]);let c=(0,J.useRef)(t);c.current=t,(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target instanceof Element?e.target:null;t&&t!==document.body&&!t.closest(`[data-slot="preview-pane-body"], [data-slot="preview-page-dialog"]`)||(e.stopPropagation(),c.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let l=()=>t(e.type===`prompt`?{accept:!0,text: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||(a?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,Y.jsx)(`input`,{ref:s,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l()},className:`mb-4 h-11 w-full rounded-md border border-border bg-background px-3 text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,Y.jsx)(i,{variant:`outline`,onClick:()=>t({accept:!1}),children:a?`Stay`:`Cancel`}),(0,Y.jsx)(i,{ref:o,variant:`contrast`,onClick:l,children:a?`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:o,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)(o);m.current=o,(0,J.useImperativeHandle)(e,()=>({async draw(e){let t=++l.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!a()))try{let i=await Mt(e);try{if(t!==l.current||!a()||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:ue},{w:820,h:1180,icon:we},{w:1440,h:900,icon:ae}],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)(j,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,Y.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Wt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Wt(e)})]})}function Kt({current:e,agentShown:t,...n}){let r=e?e.label:t?`Agent's page`:`Server`;return(0,Y.jsxs)(i,{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)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,Y.jsx)(x,{"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)(le,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function qt({shown:e,live:t,onSelect:n}){return(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,Y.jsx)(j,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,Y.jsx)(F,{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,a=(0,J.useRef)(null),o=e.urlInputRef??a,s=(0,J.useRef)(!1),[c,l]=(0,J.useState)(null),[u,f]=(0,J.useState)(!1),p=(0,Y.jsx)(i,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Back`,disabled:!n,onClick:e.onBack,children:(0,Y.jsx)(be,{"aria-hidden":`true`})}),m=(0,Y.jsx)(i,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Forward`,disabled:!n,onClick:e.onForward,children:(0,Y.jsx)(d,{"aria-hidden":`true`})}),h=(0,Y.jsx)(i,{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)(K,{"aria-hidden":`true`})}),g=e.onSession?(0,Y.jsxs)(i,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1 max-md:h-11`,onClick:e.onSession,children:[(0,Y.jsx)(re,{"aria-hidden":`true`}),`Session`]}):null,_=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,v=(0,Y.jsx)(Qt,{props:e,input:o,draft:c,setDraft:l,focused:u,setFocused:f}),{agentListed:y}=Yt(e),b=e.servers.length+ +!!y>=2,x=b||e.adopted,S={back:p,forward:m,reload:h,address:v,more:(0,Y.jsx)(rn,{props:e,compact:t,crowded:x}),session:g,progress:_};return t?(0,Y.jsx)(an,{props:e,elements:S}):(0,Y.jsx)(on,{props:e,elements:S,switcher:b,crowded:x,input:o,focusUrlAfterMenu:s})}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)(O,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsx)(Kt,{current:i,agentShown:o})}),(0,Y.jsxs)(D,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,Y.jsx)(qt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=ce(me(t,e.serverStates));return(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":i?.port===t.port||void 0,onSelect:()=>e.onPickServer(t.port),children:[(0,Y.jsx)(j,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,Y.jsx)(F,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,Y.jsx)(T,{}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,Y.jsx)(P,{"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)(P,{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)(Se,{className:`size-3`,"aria-hidden":`true`}),`Not started by Squawk`]}):null]})}function $t({props:e}){let{viewport:t}=e;return(0,Y.jsxs)(O,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsxs)(i,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ht(t)}`,children:[t===`fit`?(0,Y.jsx)(H,{"aria-hidden":`true`}):(0,Y.jsx)(ae,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:r(`hidden @min-[500px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ht(t)}),(0,Y.jsx)(le,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(D,{align:`start`,className:`min-w-56`,children:[(0,Y.jsxs)(w,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,Y.jsx)(H,{"aria-hidden":`true`}),`Fit`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,Y.jsx)(F,{className:`size-4`,"aria-hidden":`true`}):null]}),Bt.map(({w:n,h:r,icon:i})=>(0,Y.jsxs)(w,{className:`gap-2.5 font-mono`,"aria-current":t!==`fit`&&t.w===n&&t.h===r||void 0,onSelect:()=>e.onViewport({w:n,h:r}),children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,Y.jsx)(F,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function en({quality:e,onQuality:t,compact:n}){return(0,Y.jsx)(ee,{value:e,onValueChange:e=>t(It(e)),children:Ft.map(e=>(0,Y.jsx)(C,{value:e.value,"data-quality":e.value,className:r(`items-start`,n&&`min-h-11`),children:(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function tn({props:e}){let{quality:t}=e;return(0,Y.jsxs)(O,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsxs)(i,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Lt(t)}`,children:[(0,Y.jsx)(V,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[560px]:inline`,children:Lt(t)}),(0,Y.jsx)(le,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(D,{align:`start`,className:`w-64`,children:[(0,Y.jsx)(S,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(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)(j,{tone:t.tone,"aria-hidden":`true`}),t.label]}):null}function rn({props:e,compact:t,crowded:n}){let{stats:r,navEnabled:a,url:o,current:s,adopted:c}=e;return(0,Y.jsxs)(O,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsx)(i,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`More`,children:(0,Y.jsx)(he,{"aria-hidden":`true`})})}),(0,Y.jsxs)(D,{align:`end`,className:`min-w-64`,children:[n&&r&&!t?(0,Y.jsx)(S,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Wt(r)}):null,(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!a,onSelect:()=>e.onReload(!0),children:[(0,Y.jsx)(G,{"aria-hidden":`true`}),`Reload without cache`]}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:o===``,onSelect:e.onCopyUrl,children:[(0,Y.jsx)(de,{"aria-hidden":`true`}),`Copy page URL`]}),s?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{}),c?(0,Y.jsxs)(w,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,Y.jsx)(Ce,{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 · ${s.label} :${s.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)(w,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(s.port),children:[(0,Y.jsx)(xe,{"aria-hidden":`true`}),`Stop server · ${s.label} :${s.port}`]})]}):null,t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{}),(0,Y.jsx)(S,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,Y.jsx)(T,{}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,Y.jsx)(pe,{"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)(j,{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:a,focusUrlAfterMenu:o}){let{badge:s=!0,stats:c,status:l}=e,{back:u,forward:d,reload:f,address:p,more:m,session:h,progress:g}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1.5 border-b border-border bg-background px-2.5 py-2`,children:[h,u,d,f,n?(0,Y.jsx)(Zt,{props:e,input:a,focusUrlAfterMenu:o}):null,p,(0,Y.jsx)($t,{props:e}),(0,Y.jsx)(tn,{props:e}),(0,Y.jsx)(nn,{stats:c,status:l,crowded:r}),s?(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`}),m,(0,Y.jsx)(i,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Close preview`,onClick:e.onClose,children:(0,Y.jsx)(pe,{"aria-hidden":`true`})}),g]})}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(()=>l(`Copied`),()=>l(`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:o}){let c=un(),l=(0,J.useRef)(c);l.current=c;let u=s(),d=(0,J.useRef)(crypto.randomUUID()),f=(0,J.useRef)(!1),p=te(),m=ie(ye,!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),[T,E]=(0,J.useState)(``),[D,ee]=(0,J.useState)(void 0),[O,ne]=(0,J.useState)(!1),[k,A]=(0,J.useState)(void 0),[j,re]=(0,J.useState)(!1),[ae,oe]=(0,J.useState)(!1),[se,ce]=(0,J.useState)(void 0),[le,M]=(0,J.useState)(void 0),[ue,de]=(0,J.useState)(void 0),[fe,N]=(0,J.useState)(`fit`),[pe,me]=(0,J.useState)(Rt),[he,ge]=(0,J.useState)(null),[_e,P]=(0,J.useState)(void 0),[F,ve]=(0,J.useState)(0),I=(0,J.useRef)(void 0),be=(0,J.useRef)(null),xe=(0,J.useRef)(null),L=(0,J.useRef)(void 0),R=(0,J.useRef)(void 0),z=(0,J.useRef)(pe);z.current=pe;let B=(0,J.useRef)({port:D,stage:C,agent:O});B.current={port:D,stage:C,agent:O};let V=(0,J.useRef)([]),Se=(0,J.useRef)(void 0),Ce=(0,J.useRef)(!1),H=(0,J.useRef)(!1),U=(0,J.useCallback)(e=>{H.current&&I.current?.send(e)},[]);(0,J.useEffect)(()=>{let t;return t=je({projectId:p??`default`,runId:e.id},{onFrame(e){if(!a())return;let n=Date.now();V.current.push({at:n,bytes:e.size}),Ce.current||(Ce.current=!0,oe(!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),R.current!==void 0&&mn(e,R.current)){let n=R.current;R.current=void 0,(e.stage===`needs-approval`||e.stage===`server-exited`||e.stage===`server-stopped`)&&t?.send({t:`run`,port:n})}return;case`url`:return E(e.url);case`cursor`:return ce(e.cursor);case`dialog`:return M(e);case`pong`:Se.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),H.current=!1,t?.close();return}},onTransport(e,n){H.current=e===`open`,v({state:e,attempt:n??0}),e===`open`&&(b(!0),L.current&&(t?.send({t:`open`,target:L.current,viewerId:d.current,resume:f.current,quality:z.current,dpr:l.current}),f.current=!0))}}),I.current=t,()=>{H.current=!1,t?.close(),I.current===t&&(I.current=void 0)}},[p,e.id,h]);let W=u&&_.state===`open`&&x===void 0,G=m||fe===`fit`?he:fe;(0,J.useEffect)(()=>{G&&W&&(C?.stage===`streaming`||C?.stage===`loading`)&&U({t:`resize`,w:G.w,h:G.h,...c===1?{}:{dpr:c}})},[G?.w,G?.h,c,W,C?.stage,F,U]),(0,J.useEffect)(()=>{if(!W)return;let e=setInterval(()=>U({t:`ping`,ts:Date.now()}),dn);return()=>clearInterval(e)},[W,U]);let K=W&&C?.stage===`streaming`;(0,J.useEffect)(()=>{if(!K){de(void 0);return}let e=setInterval(()=>{let e=Date.now();V.current=V.current.filter(t=>e-t.at<=pn);let t={fps:V.current.length,kbps:Math.round(V.current.reduce((e,t)=>e+t.bytes,0)/1024),...Se.current===void 0?{}:{rttMs:Se.current},...V.current.length>0?{lastFrameAt:V.current.at(-1).at}:{}};de(e=>{let n=t.lastFrameAt??e?.lastFrameAt,r={...t,...n===void 0?{}:{lastFrameAt:n}};return e&&e.fps===r.fps&&e.kbps===r.kbps&&e.rttMs===r.rttMs&&e.lastFrameAt===r.lastFrameAt?e:r})},fn);return()=>clearInterval(e)},[K]),(0,J.useEffect)(()=>(i?.(K),()=>i?.(!1)),[K,i]),(0,J.useEffect)(()=>{k&&r?.(k)},[k,r]);let q=(0,J.useCallback)((e,t,n=!1)=>{L.current=e,R.current=n&&`port`in e?e.port:void 0,re(!0),w(void 0),S(void 0),P(void 0),E(t),ee(`port`in e?e.port:void 0),ne(`agent`in e),A(vn(e)),U({t:`open`,target:e,viewerId:d.current,quality:z.current,dpr:l.current}),f.current=H.current},[U]),we=(0,J.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);q({port:e},r?gn(r):`http://localhost:${e}`,n)},[t,q]),Te=(0,J.useCallback)(()=>q({agent:!0},``),[q]);(0,J.useEffect)(()=>{if(n?.agent){if(B.current.agent&&B.current.stage?.stage===`streaming`)return;Te();return}if(n?.url!==void 0){let e=Fe(n.url,t);e.kind===`server`?we(e.port):e.kind===`url`&&q({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||B.current.port===n.port&&B.current.stage?.stage===`streaming`&&n.run!==!0||we(n.port,n.run===!0))},[n]);let Ee=!j&&!x&&_.state!==`blocked`,De=_n(n,t);(0,J.useEffect)(()=>{Ee&&!De&&xe.current?.focus()},[Ee,De]);let Oe=e=>{let n=Fe(e,t);if(n.kind===`error`)return P(n.message);if(n.kind===`server`)return we(n.port);if(B.current.stage?.stage===`streaming`&&!B.current.agent)return L.current={url:n.url},R.current=void 0,ee(void 0),A({url:n.url}),P(void 0),E(n.url),U({t:`nav`,url:n.url});q({url:n.url},n.url)},ke=(0,J.useCallback)(e=>{z.current=e,me(e),zt(e),U({t:`quality`,quality:e})},[U]),Ae=()=>{f.current=!1,S(void 0),v({state:`connecting`,attempt:0}),Ce.current=!1,g(e=>e+1)};return{compact:m,transport:_,everOpened:y,takenOver:x,stage:C,url:T,port:D,agent:O,hasFrame:ae,cursor:se,dialog:le,setDialog:M,stats:ue,viewport:fe,setViewport:N,quality:pe,chooseQuality:ke,setStageSize:ge,addressError:_e,stageHandle:be,urlInput:xe,send:U,connected:W,streaming:K,openServer:we,openAgent:Te,empty:Ee,navigate:Oe,reconnect:Ae,actions:(0,J.useMemo)(()=>({download:()=>U({t:`download`}),cancelDownload:()=>U({t:`cancelDownload`}),retryBrowser:()=>U({t:`retryBrowser`}),run:e=>U({t:`run`,port:e}),stop:e=>U({t:`stop`,port:e}),keepWaiting:e=>U({t:`keepWaiting`,port:e}),close:o,useHere:Ae,copy:hn}),[U,o])}}function bn(e){return(0,Y.jsx)(ve,{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:T,openServer:E,openAgent:D,empty:ee,navigate:O,actions:te}=s,ne=n.find(e=>e.port===m),k=f?.stage===`streaming`&&f.adopted,A=u&&(l.state===`reconnecting`||l.state===`closed`),{content:j,dim:re}=sn({transport:l.state,takenOver:d,empty:ee,stage:f,hasFrame:g,lost:A,url:p,worktree:t.worktreePath}),ie=cn(j,{servers:n,serverStates:r,agentLive:i,openServer:E,openAgent:D,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:ne,agentLive:i===!0,agentShown:h,adopted:k,viewport:c?`fit`:v,quality:b,compact:c,navEnabled:T,loading:f?.stage===`loading`,stats:T?_??{fps:0,kbps:0}:void 0,status:T?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=>E(e),onPickAgent:D,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:ie,dim:re,lost:A})]})}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}=se(e);return(0,J.useMemo)(()=>{let e=new Map;for(let n of b(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function En(e){let t=Tn(e.run.id),n=oe(e.run.id);return(0,Y.jsx)(bn,{...e,serverStates:t,agentLive:n})}export{En as ConnectedPreviewPane};
|
|
@@ -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{D as r,E as i,M as a,l as o,t as s,u as c}from"./button-C1fD-ZFr.js";import{C as l,Qt as u,Rt as d,T as f,Zt as p,a as m,ei as h,k as g}from"./project-scope-context-CR3cozni.js";import{J as _}from"./live-protocol-60uiPDg6.js";import{C as v,L as ee,M as y,Nt as te,U as b,Vt as x,Yt as S,ct as ne,lt as re,ot as C,st as w,t as T,yt as ie}from"./queries-BCXjp1_j.js";import{n as E,u as D}from"./use-desktop-CEB_iBfH.js";import{n as O}from"./toaster-Cxgzn9ip.js";import{A as k,C as A,E as ae,F as oe,J as se,M as ce,X as le,Y as ue,at as de,j as fe,n as pe,ot as j,s as me,u as he,v as ge,x as _e}from"./design-icons-B6-0w7Aw.js";import{t as M}from"./createLucideIcon-BHp8sXmF.js";import{l as ve,n as ye,y as be}from"./nav-row-styles-CFjnD-9J.js";import{n as xe,r as Se}from"./diff-controls-C8aqhty4.js";import{i as Ce,r as we,t as Te}from"./git-toolbar-zEjeF-_V.js";import{t as N}from"./info-DA1x_4bz.js";import{a as Ee,i as P}from"./format-BNCkW110.js";import{c as De,i as Oe,l as ke,t as Ae}from"./reference-chip-1O0efJ0d.js";import{i as F,l as je,p as Me,r as Ne,t as Pe}from"./dropdown-menu-DRFDwG2X.js";import{t as I}from"./project-router-BLLH9tz9.js";import{t as L}from"./centered-state-CiiA8Vgw.js";import{$ as Fe,A as R,Q as Ie,Z as Le,Zt as Re,at as ze,ct as Be,dn as Ve,dt as z,et as He,ft as B,gt as V,ht as H,it as Ue,k as We,lt as U,mt as W,nt as Ge,ot as Ke,pt as G,rt as qe,st as Je,tn as K,tt as Ye,ut as q,yn as J}from"./index-DPA7Ibhf.js";import{t as Xe}from"./markdown-BBDDg-4t.js";import{t as Ze}from"./diff-Dtz4yPu-.js";import{t as Qe}from"./commit-diff-panel-BhqIhVpi.js";var Y=e(t(),1);function $e(e,t){let n=h(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(_.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var et=M(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),tt=M(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function nt(){let e=a(),t=C(),n=h(),r=$e({queryKey:T.repo})>0,i=t.data?.info?t.data:null,s=Le(e,i,`screen`);return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-slot":`git-screen`,className:ye,children:[(0,X.jsxs)(`div`,{className:`mb-[16px] flex items-center gap-[8px]`,children:[(0,X.jsx)(`h1`,{className:o(ve,`min-w-0 flex-1`),children:`Git`}),(0,X.jsx)(`button`,{type:`button`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:r,onClick:()=>{n.invalidateQueries({queryKey:T.repo}),n.invalidateQueries({queryKey:T.worktrees})},className:`-my-2 -mr-[10px] flex size-11 shrink-0 items-center justify-center rounded-md text-soft-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,children:(0,X.jsx)(ue,{size:17,"aria-hidden":`true`,className:o(`size-[17px]`,r&&`motion-safe:animate-spin`)})})]}),i?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(He,{scope:e,repo:i,info:i.info,variant:`screen`},e)}):t.isPending?(0,X.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,X.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,X.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,X.jsx)(Ie,{branch:i?.info?.branch??null,counts:s,variant:`screen`})]})}function Z({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-[11px] text-soft-foreground`,children:e.keptReason}):null}function rt({repo:e,info:t}){let n=y(),r=w(),i=new Map((r.data?.branches??[]).map(e=>[e.name,e])),a=h(),c=S({mutationFn:e=>l({name:e}),onSuccess:async e=>{O(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([a.invalidateQueries({queryKey:T.repo}),a.invalidateQueries({queryKey:T.health})]),a.setQueryData(T.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),a.setQueryData(T.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:e=>O(e.message,{tone:`danger`})}),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(``),m=f.trim().toLowerCase(),g=Q(e,r.data?.branches),_=m?g.filter(e=>e.toLowerCase().includes(m)):g;return(0,X.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(le,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,X.jsx)(K,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:f,onChange:e=>p(e.target.value),className:`h-11 pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[_.map(e=>{let n=e===t.branch,r=i.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,X.jsx)(I,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] text-[13px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:o(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),r?(0,X.jsx)(ct,{entry:r}):null]}),r?(0,X.jsx)(Z,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[12px] font-medium text-accent-text`,children:`Current`}):(0,X.jsxs)(s,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:c.isPending,onClick:()=>c.mutate(e),children:[(0,X.jsx)(k,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),_.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,f.trim(),`”.`]}):null]})]}),(0,X.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,X.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=u.trim();t&&c.mutate(t,{onSuccess:()=>d(``)})},children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,X.jsx)(K,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:u,onChange:e=>d(e.target.value)}),(0,X.jsxs)(s,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!u.trim()||c.isPending,children:[(0,X.jsx)(se,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,X.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,X.jsx)(it,{}):null]})}function it(){let e=v({limit:20});return(0,X.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,X.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,X.jsx)(at,{pr:e},e.number))}):(0,X.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function at({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,X.jsx)(ot,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,X.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:c(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:o(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function ot({checks:e}){return(0,X.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:o(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}var st={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function ct({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:o(`shrink-0 rounded-[4px] border px-[5px] py-[1px] text-[10.5px] leading-[14px]`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:st[e.class]})}function Q(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function lt(){let e=ne(),t=E(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof m&&e.error.status===409,f=e.data?.files??[],p=(0,Y.useMemo)(()=>we(f),[f]),h=(0,Y.useMemo)(()=>f.some(Xe),[f]),g=t?n:`unified`,_=!t||i;return(0,X.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,X.jsx)(Te,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`hidden items-center gap-1 md:flex`,children:(0,X.jsx)(xe,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})}),h?(0,X.jsx)(Se,{preview:o,onPreviewChange:s}):null]})]}),e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,X.jsx)(L,{icon:d?(0,X.jsx)(A,{size:16}):(0,X.jsx)(j,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(L,{icon:(0,X.jsx)(A,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,X.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,X.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(Ce,{root:p,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),(0,X.jsx)(Ze,{files:f,viewRef:u,mode:g,wrap:_,preview:o,className:`min-w-0 flex-1`})]})]})}function ut({repo:e,info:t}){let{sha:n}=i(),r=e.log,a=(0,Y.useMemo)(()=>Je(r),[r]);if(n)return(0,X.jsx)(pt,{sha:n});let o=ze(e,t),s=o&&o.behind>0?(0,X.jsx)(ft,{info:t,tracking:o}):null;return r.length===0?(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{className:`px-[8px] pt-[12px] md:px-[20px]`,children:s}):null,(0,X.jsx)(L,{icon:(0,X.jsx)(fe,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[20px] md:px-[20px]`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col`,children:[(0,X.jsx)(`h2`,{className:`px-[10px] pt-[14px] pb-[4px] text-[11px] font-medium text-soft-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.commits.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-[14px] rounded-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsxs)(I,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-[3px] rounded-[6px] px-[10px] py-[6px] focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono`,children:e.hash}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,e.author,` · `,Be(e.when)]})]})]}),(0,X.jsx)(dt,{source:e.source})]},e.hash))})]},e.label))]})}function dt({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-[10px] text-[11.5px] text-soft-foreground md:flex`;return e?(0,X.jsxs)(I,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:o(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ce,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(me,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:t,children:`no task found`})}function ft({info:e,tracking:t}){let n=Ge(a(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`mb-[4px] flex min-h-[40px] items-center gap-[8px] rounded-[8px] border border-border px-[10px] py-[6px]`,children:[(0,X.jsx)(et,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[26px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Ee,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(pe,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(Ye,{checkout:n,returnFocus:r})]})}function pt({sha:e}){return(0,X.jsx)(Qe,{commit:re(e),sha:e,backTo:E()?`/git`:qe,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`})}var $=`Squash-merged branches may show as not landed without GitHub`;function mt(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function ht(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}var gt={done:`success`,failed:`danger`,cancelled:`neutral`};function _t(){let e=w(),t=ie(),n=a(),r=b(),[i,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`px-[28px] py-[20px] text-[13px] text-soft-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(L,{icon:(0,X.jsx)(j,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=mt(e.data.branches),c=ht(e.data.branches),l=c>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(N,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),(0,X.jsxs)(`span`,{children:[c,` finished task`,c===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,c===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(I,{to:Ue.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,u=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(Oe,{projectId:n,repoBase:r,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[e.data.prStateKnown?null:(0,X.jsx)(vt,{}),l,s.length===0?(0,X.jsx)(L,{icon:(0,X.jsx)(Ve,{size:16}),tone:`neutral`,heading:`h2`,title:c>0?`Nothing else waiting to land`:`Everything landed`,subtitle:c>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`}):(0,X.jsxs)(X.Fragment,{children:[s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-[6px] px-[10px] pt-[14px] pb-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,X.jsx)(`span`,{children:e.rows.length}),e.note?(0,X.jsxs)(`span`,{children:[`· `,e.note]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.rows.map(e=>(0,X.jsx)(yt,{entry:e,finishedAt:e.runId?u.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key)),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-[6px] px-[10px] pt-[14px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(N,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),`Delete branch is in each row's … menu. It confirms and names the commits it drops. Nothing on this list can be bulk-deleted.`]})]})]}),(0,X.jsx)(wt,{entry:i,onClose:()=>o(null)})]})}function vt({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:o(`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,e),children:[(0,X.jsx)(N,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),$,`.`]})}function yt({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[56px] items-center gap-[12px] rounded-[6px] px-[10px] py-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(St,{entry:e,finishedAt:t}),(0,X.jsx)(bt,{entry:e}),(0,X.jsx)(xt,{entry:e,onDelete:n})]})}function bt({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-[4px] text-[11.5px] text-muted-foreground md:flex`,children:[(0,X.jsx)(Ae,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(Ct,{entry:e})]}):null})}function xt({entry:e,onDelete:t}){let n=h(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,a=!r&&e.runId!==null&&!i,s=S({mutationFn:()=>f(e.runId),onSuccess:e=>{O(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:T.repoBranches}),n.invalidateQueries({queryKey:T.runs.all})},onError:e=>O(e instanceof m&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>O(`Copied ${e.name}`),()=>O(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-[28px] shrink-0 items-center gap-[5px] rounded-[6px] px-[10px] text-[12px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(I,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:o(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:`Open task`}):null,a?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:o(l,`hidden bg-muted hover:brightness-110 md:inline-flex`),children:[(0,X.jsx)(tt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Create draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:o(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(ge,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(Pe,{children:[(0,X.jsx)(Me,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(_e,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Ne,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(F,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(I,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,a?(0,X.jsx)(F,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Create draft PR`}):null,(0,X.jsx)(F,{className:o(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(je,{className:`md:hidden`}),(0,X.jsx)(F,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function St({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=P(t??e.lastCommit.at),a=n||!e.runStatus?i?`${i} ago`:``:`${e.runStatus}${i?` ${i} ago`:``}`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(be,{"aria-label":`Task deleted`,className:`size-[12px] text-soft-foreground`}):(0,X.jsx)(Re,{tone:e.runStatus&>[e.runStatus]||`neutral`,"aria-label":e.runStatus??void 0})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[e.runId?(0,X.jsx)(I,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] text-muted-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(`span`,{className:`flex shrink-0 gap-[4px] tabular-nums`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[`+`,e.diffStat.additions]}),(0,X.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.diffStat.deletions]})]}):null,a?(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,a]}):null]}),e.parentRunId?(0,X.jsx)(I,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-[11px] text-soft-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Z,{entry:e})]})]})}function Ct({entry:e}){let t=x(De(`PR`,e.pr?.number).status),n=e.pr?.state;return(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr-state`,children:[`· `,n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`]})}function wt({entry:e,onClose:t}){let n=h(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=S({mutationFn:e=>g({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;O(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:T.repo}),s()},onError:e=>O(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(U,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(B,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(H,{children:[(0,X.jsxs)(V,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,` `,`(`,(0,X.jsx)(`span`,{className:`font-mono`,children:e?.lastCommit.sha.slice(0,7)}),`).`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(K,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(z,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(q,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Tt({base:e}){let t=w(),n=h(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),s=(t.data?.branches??[]).filter(e=>e.class===`merged`),c=(t.data?.branches??[]).filter(e=>e.class===`empty`),l=[...s,...c],u=S({mutationFn:e=>g({names:e}),onSuccess:e=>{let t=e.refused.length;O(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:T.repo})},onError:e=>{n.invalidateQueries({queryKey:T.repo}),O(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let d=l.length,f=`branch${d===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,d]}),(0,X.jsxs)(`p`,{className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:d===0||u.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(de,{"aria-hidden":`true`,className:`size-[12px]`}),u.isPending?`Deleting…`:`Delete ${d} ${f}`]})]}),(0,X.jsx)(Et,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Et,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:c,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(U,{open:a,onOpenChange:o,children:(0,X.jsxs)(B,{children:[(0,X.jsxs)(H,{children:[(0,X.jsxs)(V,{children:[`Delete `,d,` `,f,`?`]}),(0,X.jsxs)(G,{children:[s.length,` merged into `,e,` and `,c.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(z,{children:`Keep them`}),(0,X.jsxs)(q,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{u.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,d,` `,f]})]})]})})]})}function Et({kind:e,title:t,hint:n,rows:r,open:i,onToggle:a}){let s=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":s,disabled:r.length===0,onClick:a,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(he,{"aria-hidden":`true`,className:o(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-[11.5px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),e.runId?(0,X.jsx)(I,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums text-soft-foreground`,children:P(e.lastCommit.at)})]},e.name))}):null]})}function Dt(){let e=te(),t=ee().data?.targets.find(e=>e.id===`finder`),n=S({mutationFn:e=>d(e,t.id),onError:e=>O(e.message,{tone:`danger`})}),r=h(),[i,a]=(0,Y.useState)(!1),o=()=>Promise.all([r.invalidateQueries({queryKey:T.worktrees}),r.invalidateQueries({queryKey:T.repoBranches})]),s=S({mutationFn:e=>u(),onSuccess:(e,t)=>{o();let n=e.reclaimed.length,r=Math.max(0,t-n);O(n===0?r>0?`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Nothing to reclaim — no finished worktrees exceed the keep limit`:`Reclaimed ${n} worktree${n===1?``:`s`} (branch kept)${r>0?` · ${r} kept: uncommitted work or in use`:``}`)},onError:e=>O(e.message,{tone:`danger`})}),c=S({mutationFn:e=>p(e.runId),onSuccess:(e,t)=>{o(),O(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{o(),O(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:l,totalBytes:f,keep:m}=e.data,g=s.isPending||c.isPending,_=l.filter(e=>e.pastKeep),v=_.length>0,y=_.some(e=>e.sizeBytes===null)?null:_.reduce((e,t)=>e+(t.sizeBytes??0),0),b=v?y?`Reclaim ${D(y)} now`:`Reclaim ${_.length} now`:`Reclaim now`,x=f?D(f):null;return(0,X.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,x?` · ${x}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[m===0?`Retention is unlimited (`:`Retention keeps the newest ${m} finished checkout${m===1?``:`s`} (`,(0,X.jsx)(I,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:ke(`worktrees`,` › `)}),m===0?`), so nothing is reclaimed on its own.`:`) and reclaims the rest.`,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:g||!v,title:v?void 0:`Nothing past the keep limit to reclaim`,onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[12px]`}),b]})]}),l.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:l.map(e=>(0,X.jsx)(At,{worktree:e,keep:m,disabled:g,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>c.mutate(e)},e.runId))}),(0,X.jsx)(U,{open:i,onOpenChange:a,children:(0,X.jsxs)(B,{children:[(0,X.jsxs)(H,{children:[(0,X.jsx)(V,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(G,{children:[_.length,` finished worktree`,_.length===1?``:`s`,` beyond the keep limit`,y?` (${D(y)})`:``,` `,_.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(z,{children:`Keep them`}),(0,X.jsx)(q,{"data-action":`worktrees-confirm`,onClick:()=>{s.mutate(_.length),a(!1)},children:b})]})]})})]})}var Ot=new Set([`queued`,`running`,`waiting`,`review`]);function kt(e,t){return Ot.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`}:e.pastKeep?{label:`reclaimable`,tone:`plain`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`}}function At({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:a}){let s=kt(e,t),c=P(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${c} ago`:e.status,u=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:o(`text-[11.5px]`,s.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:s.label}),d=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-[10.5px] text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:D(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:u}),r?(0,X.jsx)(`button`,{type:`button`,className:d,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ae,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":`Reclaim the worktree of ${e.title} (branch kept)`,title:`Reclaim the directory (branch kept)`,disabled:n,onClick:a,className:d,children:(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function jt({section:e,index:t=!1}){let n=C(),i=E(),[a]=r();if(t&&!i&&a.get(`view`)!==`repo`)return(0,X.jsx)(nt,{});if(n.isPending)return(0,X.jsx)(We,{});if(n.isError)return(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(R,{}),(0,X.jsx)(L,{icon:(0,X.jsx)(j,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})]});let o=n.data.info;return o?(0,X.jsx)(Mt,{repo:n.data,info:o,section:e}):(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(R,{}),(0,X.jsx)(L,{icon:(0,X.jsx)(k,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})]})}function Mt({repo:e,info:t,section:n}){return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-git-section":n,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(R,{}),(0,X.jsxs)(`header`,{"data-slot":`repo-header`,className:`flex flex-col gap-1 px-[18px] pt-[18px] md:min-h-[61px] md:flex-row md:items-center md:gap-[10px] md:border-b md:border-border md:px-7 md:py-4`,children:[(0,X.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-2xl font-semibold tracking-tight md:text-[15px] md:tracking-normal`,children:Fe(n,t.branch)}),(0,X.jsx)(`p`,{"data-slot":`repo-meta`,className:`min-w-0 truncate text-[12px] text-soft-foreground md:text-[11.5px]`,children:(0,X.jsx)(Nt,{repo:e,info:t,section:n})})]}),n===`main`?(0,X.jsx)(ut,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(_t,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-[16px] px-[18px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[(0,X.jsx)(Dt,{}),(0,X.jsx)(Tt,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(rt,{repo:e,info:t}):(0,X.jsx)(lt,{})]})}function Nt({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`no commits yet`:`latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${Ke(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Pt,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`nothing here can delete work that is not on `,r]})}}function Pt({repo:e,info:t}){let n=Q(e,w().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{jt as RepoGitRoute};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{D as r,E as i,M as a,l as o,t as s,u as c}from"./button-C1fD-ZFr.js";import{C as l,Qt as u,Rt as d,T as f,Zt as p,a as m,ei as h,k as g}from"./project-scope-context-CR3cozni.js";import{J as _}from"./live-protocol-60uiPDg6.js";import{C as v,L as ee,M as y,Nt as te,U as b,Vt as x,Yt as S,ct as ne,lt as re,ot as C,st as w,t as T,yt as ie}from"./queries-BCXjp1_j.js";import{n as E,u as D}from"./use-desktop-CEB_iBfH.js";import{n as O}from"./toaster-Cxgzn9ip.js";import{A as k,C as A,E as ae,F as oe,J as se,M as ce,X as le,Y as ue,at as de,j as fe,n as pe,ot as j,s as me,u as he,v as ge,x as _e}from"./design-icons-B6-0w7Aw.js";import{t as M}from"./createLucideIcon-BHp8sXmF.js";import{l as ve,n as ye,y as be}from"./nav-row-styles-CFjnD-9J.js";import{n as xe,r as Se}from"./diff-controls-C8aqhty4.js";import{i as Ce,r as we,t as Te}from"./git-toolbar-BLOs2P23.js";import{t as N}from"./info-DA1x_4bz.js";import{a as Ee,i as P}from"./format-BNCkW110.js";import{c as De,i as Oe,l as ke,t as Ae}from"./reference-chip-1O0efJ0d.js";import{i as F,l as je,p as Me,r as Ne,t as Pe}from"./dropdown-menu-DRFDwG2X.js";import{t as I}from"./project-router-BLLH9tz9.js";import{t as L}from"./centered-state-CiiA8Vgw.js";import{$ as Fe,A as R,Q as Ie,Z as Le,Zt as Re,at as ze,ct as Be,dn as Ve,dt as z,et as He,ft as B,gt as V,ht as H,it as Ue,k as We,lt as U,mt as W,nt as Ge,ot as Ke,pt as G,rt as qe,st as Je,tn as K,tt as Ye,ut as q,yn as J}from"./index-D9Yu2XLO.js";import{t as Xe}from"./markdown-BBDDg-4t.js";import{t as Ze}from"./diff-Bp_ZwIlK.js";import{t as Qe}from"./commit-diff-panel-BiFrj_Kg.js";var Y=e(t(),1);function $e(e,t){let n=h(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(_.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var et=M(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),tt=M(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function nt(){let e=a(),t=C(),n=h(),r=$e({queryKey:T.repo})>0,i=t.data?.info?t.data:null,s=Le(e,i,`screen`);return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-slot":`git-screen`,className:ye,children:[(0,X.jsxs)(`div`,{className:`mb-[16px] flex items-center gap-[8px]`,children:[(0,X.jsx)(`h1`,{className:o(ve,`min-w-0 flex-1`),children:`Git`}),(0,X.jsx)(`button`,{type:`button`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:r,onClick:()=>{n.invalidateQueries({queryKey:T.repo}),n.invalidateQueries({queryKey:T.worktrees})},className:`-my-2 -mr-[10px] flex size-11 shrink-0 items-center justify-center rounded-md text-soft-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,children:(0,X.jsx)(ue,{size:17,"aria-hidden":`true`,className:o(`size-[17px]`,r&&`motion-safe:animate-spin`)})})]}),i?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(He,{scope:e,repo:i,info:i.info,variant:`screen`},e)}):t.isPending?(0,X.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,X.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,X.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,X.jsx)(Ie,{branch:i?.info?.branch??null,counts:s,variant:`screen`})]})}function Z({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-[11px] text-soft-foreground`,children:e.keptReason}):null}function rt({repo:e,info:t}){let n=y(),r=w(),i=new Map((r.data?.branches??[]).map(e=>[e.name,e])),a=h(),c=S({mutationFn:e=>l({name:e}),onSuccess:async e=>{O(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([a.invalidateQueries({queryKey:T.repo}),a.invalidateQueries({queryKey:T.health})]),a.setQueryData(T.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),a.setQueryData(T.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:e=>O(e.message,{tone:`danger`})}),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(``),m=f.trim().toLowerCase(),g=Q(e,r.data?.branches),_=m?g.filter(e=>e.toLowerCase().includes(m)):g;return(0,X.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(le,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,X.jsx)(K,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:f,onChange:e=>p(e.target.value),className:`h-11 pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[_.map(e=>{let n=e===t.branch,r=i.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,X.jsx)(I,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] text-[13px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:o(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),r?(0,X.jsx)(ct,{entry:r}):null]}),r?(0,X.jsx)(Z,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[12px] font-medium text-accent-text`,children:`Current`}):(0,X.jsxs)(s,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:c.isPending,onClick:()=>c.mutate(e),children:[(0,X.jsx)(k,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),_.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,f.trim(),`”.`]}):null]})]}),(0,X.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,X.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=u.trim();t&&c.mutate(t,{onSuccess:()=>d(``)})},children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,X.jsx)(K,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:u,onChange:e=>d(e.target.value)}),(0,X.jsxs)(s,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!u.trim()||c.isPending,children:[(0,X.jsx)(se,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,X.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,X.jsx)(it,{}):null]})}function it(){let e=v({limit:20});return(0,X.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,X.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,X.jsx)(at,{pr:e},e.number))}):(0,X.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function at({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,X.jsx)(ot,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,X.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:c(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:o(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function ot({checks:e}){return(0,X.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:o(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}var st={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function ct({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:o(`shrink-0 rounded-[4px] border px-[5px] py-[1px] text-[10.5px] leading-[14px]`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:st[e.class]})}function Q(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function lt(){let e=ne(),t=E(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof m&&e.error.status===409,f=e.data?.files??[],p=(0,Y.useMemo)(()=>we(f),[f]),h=(0,Y.useMemo)(()=>f.some(Xe),[f]),g=t?n:`unified`,_=!t||i;return(0,X.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,X.jsx)(Te,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`hidden items-center gap-1 md:flex`,children:(0,X.jsx)(xe,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})}),h?(0,X.jsx)(Se,{preview:o,onPreviewChange:s}):null]})]}),e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,X.jsx)(L,{icon:d?(0,X.jsx)(A,{size:16}):(0,X.jsx)(j,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(L,{icon:(0,X.jsx)(A,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,X.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,X.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(Ce,{root:p,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),(0,X.jsx)(Ze,{files:f,viewRef:u,mode:g,wrap:_,preview:o,className:`min-w-0 flex-1`})]})]})}function ut({repo:e,info:t}){let{sha:n}=i(),r=e.log,a=(0,Y.useMemo)(()=>Je(r),[r]);if(n)return(0,X.jsx)(pt,{sha:n});let o=ze(e,t),s=o&&o.behind>0?(0,X.jsx)(ft,{info:t,tracking:o}):null;return r.length===0?(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{className:`px-[8px] pt-[12px] md:px-[20px]`,children:s}):null,(0,X.jsx)(L,{icon:(0,X.jsx)(fe,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[20px] md:px-[20px]`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col`,children:[(0,X.jsx)(`h2`,{className:`px-[10px] pt-[14px] pb-[4px] text-[11px] font-medium text-soft-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.commits.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-[14px] rounded-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsxs)(I,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-[3px] rounded-[6px] px-[10px] py-[6px] focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono`,children:e.hash}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,e.author,` · `,Be(e.when)]})]})]}),(0,X.jsx)(dt,{source:e.source})]},e.hash))})]},e.label))]})}function dt({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-[10px] text-[11.5px] text-soft-foreground md:flex`;return e?(0,X.jsxs)(I,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:o(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ce,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(me,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:t,children:`no task found`})}function ft({info:e,tracking:t}){let n=Ge(a(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`mb-[4px] flex min-h-[40px] items-center gap-[8px] rounded-[8px] border border-border px-[10px] py-[6px]`,children:[(0,X.jsx)(et,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[26px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Ee,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(pe,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(Ye,{checkout:n,returnFocus:r})]})}function pt({sha:e}){return(0,X.jsx)(Qe,{commit:re(e),sha:e,backTo:E()?`/git`:qe,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`})}var $=`Squash-merged branches may show as not landed without GitHub`;function mt(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function ht(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}var gt={done:`success`,failed:`danger`,cancelled:`neutral`};function _t(){let e=w(),t=ie(),n=a(),r=b(),[i,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`px-[28px] py-[20px] text-[13px] text-soft-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(L,{icon:(0,X.jsx)(j,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=mt(e.data.branches),c=ht(e.data.branches),l=c>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(N,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),(0,X.jsxs)(`span`,{children:[c,` finished task`,c===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,c===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(I,{to:Ue.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,u=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(Oe,{projectId:n,repoBase:r,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[e.data.prStateKnown?null:(0,X.jsx)(vt,{}),l,s.length===0?(0,X.jsx)(L,{icon:(0,X.jsx)(Ve,{size:16}),tone:`neutral`,heading:`h2`,title:c>0?`Nothing else waiting to land`:`Everything landed`,subtitle:c>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`}):(0,X.jsxs)(X.Fragment,{children:[s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-[6px] px-[10px] pt-[14px] pb-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,X.jsx)(`span`,{children:e.rows.length}),e.note?(0,X.jsxs)(`span`,{children:[`· `,e.note]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.rows.map(e=>(0,X.jsx)(yt,{entry:e,finishedAt:e.runId?u.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key)),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-[6px] px-[10px] pt-[14px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(N,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),`Delete branch is in each row's … menu. It confirms and names the commits it drops. Nothing on this list can be bulk-deleted.`]})]})]}),(0,X.jsx)(wt,{entry:i,onClose:()=>o(null)})]})}function vt({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:o(`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,e),children:[(0,X.jsx)(N,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),$,`.`]})}function yt({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[56px] items-center gap-[12px] rounded-[6px] px-[10px] py-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(St,{entry:e,finishedAt:t}),(0,X.jsx)(bt,{entry:e}),(0,X.jsx)(xt,{entry:e,onDelete:n})]})}function bt({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-[4px] text-[11.5px] text-muted-foreground md:flex`,children:[(0,X.jsx)(Ae,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(Ct,{entry:e})]}):null})}function xt({entry:e,onDelete:t}){let n=h(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,a=!r&&e.runId!==null&&!i,s=S({mutationFn:()=>f(e.runId),onSuccess:e=>{O(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:T.repoBranches}),n.invalidateQueries({queryKey:T.runs.all})},onError:e=>O(e instanceof m&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>O(`Copied ${e.name}`),()=>O(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-[28px] shrink-0 items-center gap-[5px] rounded-[6px] px-[10px] text-[12px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(I,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:o(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:`Open task`}):null,a?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:o(l,`hidden bg-muted hover:brightness-110 md:inline-flex`),children:[(0,X.jsx)(tt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Create draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:o(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(ge,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(Pe,{children:[(0,X.jsx)(Me,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(_e,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Ne,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(F,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(I,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,a?(0,X.jsx)(F,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Create draft PR`}):null,(0,X.jsx)(F,{className:o(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(je,{className:`md:hidden`}),(0,X.jsx)(F,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function St({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=P(t??e.lastCommit.at),a=n||!e.runStatus?i?`${i} ago`:``:`${e.runStatus}${i?` ${i} ago`:``}`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(be,{"aria-label":`Task deleted`,className:`size-[12px] text-soft-foreground`}):(0,X.jsx)(Re,{tone:e.runStatus&>[e.runStatus]||`neutral`,"aria-label":e.runStatus??void 0})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[e.runId?(0,X.jsx)(I,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] text-muted-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(`span`,{className:`flex shrink-0 gap-[4px] tabular-nums`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[`+`,e.diffStat.additions]}),(0,X.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.diffStat.deletions]})]}):null,a?(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,a]}):null]}),e.parentRunId?(0,X.jsx)(I,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-[11px] text-soft-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Z,{entry:e})]})]})}function Ct({entry:e}){let t=x(De(`PR`,e.pr?.number).status),n=e.pr?.state;return(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr-state`,children:[`· `,n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`]})}function wt({entry:e,onClose:t}){let n=h(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=S({mutationFn:e=>g({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;O(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:T.repo}),s()},onError:e=>O(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(U,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(B,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(H,{children:[(0,X.jsxs)(V,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,` `,`(`,(0,X.jsx)(`span`,{className:`font-mono`,children:e?.lastCommit.sha.slice(0,7)}),`).`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(K,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(z,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(q,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Tt({base:e}){let t=w(),n=h(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),s=(t.data?.branches??[]).filter(e=>e.class===`merged`),c=(t.data?.branches??[]).filter(e=>e.class===`empty`),l=[...s,...c],u=S({mutationFn:e=>g({names:e}),onSuccess:e=>{let t=e.refused.length;O(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:T.repo})},onError:e=>{n.invalidateQueries({queryKey:T.repo}),O(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let d=l.length,f=`branch${d===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,d]}),(0,X.jsxs)(`p`,{className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:d===0||u.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(de,{"aria-hidden":`true`,className:`size-[12px]`}),u.isPending?`Deleting…`:`Delete ${d} ${f}`]})]}),(0,X.jsx)(Et,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Et,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:c,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(U,{open:a,onOpenChange:o,children:(0,X.jsxs)(B,{children:[(0,X.jsxs)(H,{children:[(0,X.jsxs)(V,{children:[`Delete `,d,` `,f,`?`]}),(0,X.jsxs)(G,{children:[s.length,` merged into `,e,` and `,c.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(z,{children:`Keep them`}),(0,X.jsxs)(q,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{u.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,d,` `,f]})]})]})})]})}function Et({kind:e,title:t,hint:n,rows:r,open:i,onToggle:a}){let s=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":s,disabled:r.length===0,onClick:a,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(he,{"aria-hidden":`true`,className:o(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-[11.5px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),e.runId?(0,X.jsx)(I,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums text-soft-foreground`,children:P(e.lastCommit.at)})]},e.name))}):null]})}function Dt(){let e=te(),t=ee().data?.targets.find(e=>e.id===`finder`),n=S({mutationFn:e=>d(e,t.id),onError:e=>O(e.message,{tone:`danger`})}),r=h(),[i,a]=(0,Y.useState)(!1),o=()=>Promise.all([r.invalidateQueries({queryKey:T.worktrees}),r.invalidateQueries({queryKey:T.repoBranches})]),s=S({mutationFn:e=>u(),onSuccess:(e,t)=>{o();let n=e.reclaimed.length,r=Math.max(0,t-n);O(n===0?r>0?`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Nothing to reclaim — no finished worktrees exceed the keep limit`:`Reclaimed ${n} worktree${n===1?``:`s`} (branch kept)${r>0?` · ${r} kept: uncommitted work or in use`:``}`)},onError:e=>O(e.message,{tone:`danger`})}),c=S({mutationFn:e=>p(e.runId),onSuccess:(e,t)=>{o(),O(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{o(),O(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:l,totalBytes:f,keep:m}=e.data,g=s.isPending||c.isPending,_=l.filter(e=>e.pastKeep),v=_.length>0,y=_.some(e=>e.sizeBytes===null)?null:_.reduce((e,t)=>e+(t.sizeBytes??0),0),b=v?y?`Reclaim ${D(y)} now`:`Reclaim ${_.length} now`:`Reclaim now`,x=f?D(f):null;return(0,X.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,x?` · ${x}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[m===0?`Retention is unlimited (`:`Retention keeps the newest ${m} finished checkout${m===1?``:`s`} (`,(0,X.jsx)(I,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:ke(`worktrees`,` › `)}),m===0?`), so nothing is reclaimed on its own.`:`) and reclaims the rest.`,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:g||!v,title:v?void 0:`Nothing past the keep limit to reclaim`,onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[12px]`}),b]})]}),l.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:l.map(e=>(0,X.jsx)(At,{worktree:e,keep:m,disabled:g,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>c.mutate(e)},e.runId))}),(0,X.jsx)(U,{open:i,onOpenChange:a,children:(0,X.jsxs)(B,{children:[(0,X.jsxs)(H,{children:[(0,X.jsx)(V,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(G,{children:[_.length,` finished worktree`,_.length===1?``:`s`,` beyond the keep limit`,y?` (${D(y)})`:``,` `,_.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(z,{children:`Keep them`}),(0,X.jsx)(q,{"data-action":`worktrees-confirm`,onClick:()=>{s.mutate(_.length),a(!1)},children:b})]})]})})]})}var Ot=new Set([`queued`,`running`,`waiting`,`review`]);function kt(e,t){return Ot.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`}:e.pastKeep?{label:`reclaimable`,tone:`plain`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`}}function At({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:a}){let s=kt(e,t),c=P(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${c} ago`:e.status,u=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:o(`text-[11.5px]`,s.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:s.label}),d=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-[10.5px] text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:D(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:u}),r?(0,X.jsx)(`button`,{type:`button`,className:d,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ae,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":`Reclaim the worktree of ${e.title} (branch kept)`,title:`Reclaim the directory (branch kept)`,disabled:n,onClick:a,className:d,children:(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function jt({section:e,index:t=!1}){let n=C(),i=E(),[a]=r();if(t&&!i&&a.get(`view`)!==`repo`)return(0,X.jsx)(nt,{});if(n.isPending)return(0,X.jsx)(We,{});if(n.isError)return(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(R,{}),(0,X.jsx)(L,{icon:(0,X.jsx)(j,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})]});let o=n.data.info;return o?(0,X.jsx)(Mt,{repo:n.data,info:o,section:e}):(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(R,{}),(0,X.jsx)(L,{icon:(0,X.jsx)(k,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})]})}function Mt({repo:e,info:t,section:n}){return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-git-section":n,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(R,{}),(0,X.jsxs)(`header`,{"data-slot":`repo-header`,className:`flex flex-col gap-1 px-[18px] pt-[18px] md:min-h-[61px] md:flex-row md:items-center md:gap-[10px] md:border-b md:border-border md:px-7 md:py-4`,children:[(0,X.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-2xl font-semibold tracking-tight md:text-[15px] md:tracking-normal`,children:Fe(n,t.branch)}),(0,X.jsx)(`p`,{"data-slot":`repo-meta`,className:`min-w-0 truncate text-[12px] text-soft-foreground md:text-[11.5px]`,children:(0,X.jsx)(Nt,{repo:e,info:t,section:n})})]}),n===`main`?(0,X.jsx)(ut,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(_t,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-[16px] px-[18px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[(0,X.jsx)(Dt,{}),(0,X.jsx)(Tt,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(rt,{repo:e,info:t}):(0,X.jsx)(lt,{})]})}function Nt({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`no commits yet`:`latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${Ke(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Pt,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`nothing here can delete work that is not on `,r]})}}function Pt({repo:e,info:t}){let n=Q(e,w().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{jt as RepoGitRoute};
|
|
@@ -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{C as r,D as i,E as a,h as o,p as s,t as c,w as l}from"./button-C1fD-ZFr.js";import{a as u,c as d}from"./project-scope-context-CR3cozni.js";import{c as f,x as p}from"./queries-BCXjp1_j.js";import{ot as m,r as h}from"./design-icons-B6-0w7Aw.js";import{c as g,i as _,l as v,o as y,s as b,t as x}from"./file-preview-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{C as r,D as i,E as a,h as o,p as s,t as c,w as l}from"./button-C1fD-ZFr.js";import{a as u,c as d}from"./project-scope-context-CR3cozni.js";import{c as f,x as p}from"./queries-BCXjp1_j.js";import{ot as m,r as h}from"./design-icons-B6-0w7Aw.js";import{c as g,i as _,l as v,o as y,s as b,t as x}from"./file-preview-BMb-p58M.js";import{t as S}from"./centered-state-CiiA8Vgw.js";import{b as C,v as w,y as T}from"./index-D9Yu2XLO.js";import{s as E}from"./markdown-HUI2AGRH.js";var D=e(t(),1),O=n();function k(){let e=r(),t=l();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=A(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function A(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function j(e){return e?.type===`file`?e:null}function M(){let[e]=i(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function N(){let{id:e=``}=a(),t=M(),n=r(),i=k();return(0,O.jsx)(P,{runId:e,selection:t,fragment:n.hash,onBack:i,variant:`route`})}function P({runId:e,selection:t,fragment:n,onBack:i,variant:a,sourceLookup:s}){let{path:c,conflict:l,selected:u,result:d}=I(e,t,s),f=C(w,!0),p=C(T,!1),m=r(),[h,g]=(0,D.useState)(!1),_=j(d.data);if(a===`route`&&L(_))return(0,O.jsx)(o,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=z(_,c),y=a===`pane`&&!p&&!f?`Conversation`:`Back`,b=a===`pane`&&!h&&R(_),x=F(m.pathname,e,t);return(0,O.jsxs)(`div`,{"data-route":`task-report`,"data-variant":a,onKeyDown:e=>{a!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),i())},className:a===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,O.jsx)(B,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:i,backLabel:y,hideDownload:a===`pane`&&p,focusBack:a===`pane`}),(0,O.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,O.jsx)(V,{conflict:l,selected:u,result:d,source:h,name:v,fragment:n,pane:a===`pane`,filesHref:x})})]})}function F(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function I(e,t,n){let{path:r=null,artifactId:i=null,conflict:a=!1}=t,o=n?.isPending||n?.isError,s=p(e,i||a||o?null:r),c=f(e,a||o?null:i),l=o&&n?{...n,data:void 0}:i?c:s;return{path:r,conflict:a,selected:r!==null||i!==null,result:l}}function L(e){return e!==null&&(!E(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function R(e){return e!==null&&!e.tooLarge&&!e.binary}function z(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function B({runId:e,file:t,name:n,source:r,onSource:i,onBack:a,backLabel:o,hideDownload:s,focusBack:l}){let u=(0,D.useRef)(null);(0,D.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let f=t?.artifact;return(0,O.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,O.jsxs)(c,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":o,children:[(0,O.jsx)(h,{size:18,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`max-sm:sr-only`,children:o})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,O.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[f?`Published snapshot · ${new Date(f.createdAt).toLocaleString()}`:`Live file`,` · `,_(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,O.jsx)(c,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,f&&!s?(0,O.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:d(e,f.id,`download`),children:`Download`}):null]})}function V({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:c}){if(e)return(0,O.jsx)(U,{icon:(0,O.jsx)(b,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,O.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,O.jsx)(H,{result:n});let l=n.data;return l.type===`file`?o&&!E(l.path)?(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,O.jsx)(s,{to:c,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):l.tooLarge?(0,O.jsx)(U,{icon:(0,O.jsx)(v,{}),title:`Too large to preview`,subtitle:`${_(l.size)} is past the 500 kB preview limit. Download it to read it.`}):l.binary?(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,O.jsx)(`div`,{className:`bg-card`,children:(0,O.jsx)(x,{path:l.path,text:l.content??``})}):(0,O.jsx)(y,{html:l.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,O.jsx)(U,{icon:(0,O.jsx)(b,{}),title:l.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:l.reason})}function H({result:e}){let t=e.error instanceof u&&e.error.status===404;return(0,O.jsx)(U,{icon:t?(0,O.jsx)(b,{}):(0,O.jsx)(m,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,O.jsx)(c,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function U({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,O.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,O.jsx)(S,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{P as ReportReader,N as TaskReportRoute};
|
|
@@ -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{C as r,M as i,T as a,t as o}from"./button-C1fD-ZFr.js";import{Mt as s,br as c,ei as l,gn as u,jr as d,kr as f,p}from"./project-scope-context-CR3cozni.js";import{H as m,K as h,L as g,N as _,P as v,R as y,j as b,q as x}from"./live-protocol-60uiPDg6.js";import{t as S}from"./useInfiniteQuery-Bh_R8jAH.js";import{n as C,t as w}from"./ws-DCvFYEh3.js";import{t as T}from"./project-router-BLLH9tz9.js";import{C as E,Nt as D,tn as O}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{C as r,M as i,T as a,t as o}from"./button-C1fD-ZFr.js";import{Mt as s,br as c,ei as l,gn as u,jr as d,kr as f,p}from"./project-scope-context-CR3cozni.js";import{H as m,K as h,L as g,N as _,P as v,R as y,j as b,q as x}from"./live-protocol-60uiPDg6.js";import{t as S}from"./useInfiniteQuery-Bh_R8jAH.js";import{n as C,t as w}from"./ws-DCvFYEh3.js";import{t as T}from"./project-router-BLLH9tz9.js";import{C as E,Nt as D,tn as O}from"./index-D9Yu2XLO.js";import{t as k}from"./report-title-D4Mbu2Er.js";var A=e(t(),1),j=1e3,M=m().min(1).max(1024);y({q:m().max(j).optional(),before:M.optional(),limit:m().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var N=y({reports:b(y({id:h(),runId:h(),name:m(),title:m(),createdAt:x(),size:g().int().nonnegative(),taskTitle:m(),taskStatus:c}).strict()),nextCursor:M.nullable(),total:g().int().nonnegative()}).strict(),P=y({epoch:h(),generation:g().int().nonnegative(),metadataGeneration:g().int().nonnegative()}).strict(),F=y({runId:h(),taskTitle:m(),taskStatus:c}).strict(),I=_(`type`,[P.extend({type:v(`snapshot`)}),P.extend({type:v(`content`)}),P.extend({type:v(`metadata`),runs:b(F)})]),L=new WeakMap;function R(e,t){if(!e)return{content:t.type===`content`,metadata:t.type===`metadata`,reset:!1};if(e.epoch!==t.epoch)return{content:!0,metadata:!0,reset:!0};if(!(t.generation<e.generation||t.metadataGeneration<e.metadataGeneration)&&!(e.generation===t.generation&&e.metadataGeneration===t.metadataGeneration))return{content:t.generation!==e.generation,metadata:t.metadataGeneration!==e.metadataGeneration,reset:!1}}var z=class{client;project;state;content=0;metadata=0;patches=new Map;trailing=new Set;flights=new Map;constructor(e,t){this.client=e,this.project=t,e.getQueryCache().subscribe(n=>{if(n.type===`removed`){this.trailing.delete(n.query),this.flights.delete(n.query);return}if(!(n.query.queryKey[0]!==t||n.query.queryKey[1]!==`reports`)){if(n.type===`updated`&&n.action.type===`fetch`&&this.flights.set(n.query,this.metadata),n.query.state.fetchStatus===`idle`&&this.flights.has(n.query)){let e=this.flights.get(n.query);this.flights.delete(n.query),e!==this.metadata&&String(n.query.queryKey[2]??``).trim()===``&&this.client.setQueryData(n.query.queryKey,t=>t&&{...t,pages:t.pages.map(t=>this.patch(t,e))})}!this.trailing.has(n.query)||n.query.state.fetchStatus!==`idle`||(this.trailing.delete(n.query),queueMicrotask(()=>{e.invalidateQueries({queryKey:n.query.queryKey,exact:!0,refetchType:`active`},{cancelRefetch:!1})}))}})}patch(e,t=-1){return{...e,reports:e.reports.map(e=>{let n=this.patches.get(e.runId);return n&&n.version>t?{...e,taskTitle:n.value.taskTitle,taskStatus:n.value.taskStatus}:e})}}async read(e,t){for(;;){let n=this.content,r=this.metadata,i=await t();if(!(n!==this.content||e.trim()!==``&&r!==this.metadata))return e.trim()===``?this.patch(i,r):i}}receive(e,t=!1){let n=this.state;if(!n&&e.type===`snapshot`){this.state=e,this.content++,this.client.getQueryCache().findAll({queryKey:[this.project,`reports`]}).some(e=>e.state.data!==void 0)&&this.invalidate(!0);return}let r=R(n,e);if(!r){t&&e.type===`snapshot`&&(this.content++,this.invalidate(!0));return}let{metadata:i,reset:a}=r,o=r.content||t&&e.type===`snapshot`;this.state=e,a&&this.patches.clear(),i&&this.metadata++,o&&this.content++,e.type===`metadata`&&!a&&this.patchCaches(e);let s=o||i&&e.type!==`metadata`;(s||i)&&this.invalidate(s)}patchCaches(e){for(let t of e.runs)this.patches.set(t.runId,{value:t,version:this.metadata});this.client.setQueriesData({queryKey:[this.project,`reports`],predicate:e=>String(e.queryKey[2]??``).trim()===``},e=>e&&{...e,pages:e.pages.map(e=>this.patch(e,this.metadata-1))})}invalidate(e){let t={queryKey:[this.project,`reports`],refetchType:`active`,...e?{}:{predicate:e=>String(e.queryKey[2]??``).trim()!==``}};for(let e of this.client.getQueryCache().findAll(t))e.state.fetchStatus===`fetching`&&this.trailing.add(e);this.client.invalidateQueries(t,{cancelRefetch:!1})}};function B(e,t){let n=L.get(e);n||(n=new Map,L.set(e,n));let r=n.get(t);return r||(r=new z(e,t),n.set(t,r)),r}async function V(e,t){let n=await p.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},s({signal:t}));return P.parse(await u(n,`/reports/state`))}function H(e){let t=B(l(),e);return(0,A.useEffect)(()=>{let n=w(`reports:project:${e}`,e=>{let n=I.safeParse(e);n.success&&t.receive(n.data,n.data.type===`snapshot`)}),r,i,a=()=>{if(f()===`finite`&&!r){i=new AbortController;let n=i.signal;V(e,n).then(e=>{n.aborted||t.receive({type:`snapshot`,...e})}).catch(()=>void 0),r=C({path:`/api/v1/p/${encodeURIComponent(e)}/reports/state`,intervalMs:5e3},(e,n)=>{let r=P.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else f()!==`finite`&&(i?.abort(),r?.(),r=void 0)};a();let o=d(a);return()=>{o(),i?.abort(),r?.(),n()}},[t,e]),t}async function U(e,t,n,r){let i=await p.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,j),...n?{before:n}:{}}},s(r?{signal:r}:void 0));return N.parse(await u(i,`/reports`))}function W(e){let t=i(),n=H(t);return S({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>U(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var G=n(),K=new Map;function q(){let e=r(),t=a(),[n,i]=E(),s=(n.get(`q`)??``).slice(0,j),c=W(s),l=(0,A.useRef)(null),u=(0,A.useRef)(``),d=e.pathname+e.search,f=c.data?.pages.flatMap(e=>e.reports)??[];(0,A.useLayoutEffect)(()=>{if(!c.data||u.current===d)return;let n=K.get(d),r=e.state?.filesRestoreKey===d;if(!n||!l.current||t!==`POP`&&!r){u.current=d;return}let i=l.current.querySelector(`[data-report-id="${n.row}"]`);if(c.isFetchNextPageError){u.current=d,l.current.scrollTop=0;return}if((!i||c.data.pages.length<n.pages)&&c.hasNextPage){c.isFetchingNextPage||c.fetchNextPage();return}u.current=d,l.current.scrollTop=i?n.scroll:0,i?.focus({preventScroll:!0})},[d,c.data,c.hasNextPage,c.isFetchingNextPage,c.isFetchNextPageError,c.fetchNextPage,e.state,t]);let p=t=>i(n=>(t?n.set(`q`,t.slice(0,j)):n.delete(`q`),K.delete(e.pathname+`?`+n.toString()),n));return(0,G.jsxs)(`section`,{"data-route":`reports`,className:`flex h-full min-h-0 flex-col`,children:[(0,G.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b border-border p-4`,children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Reports`}),(0,G.jsx)(O,{maxLength:j,"aria-label":`Search reports`,placeholder:`Search reports or source tasks`,value:s,onChange:e=>p(e.target.value),className:`min-h-11`})]}),(0,G.jsxs)(`div`,{ref:l,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 [scrollbar-gutter:stable]`,children:[c.isPending?(0,G.jsx)(`p`,{role:`status`,children:`Loading reports…`}):c.isError?(0,G.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3`,children:[(0,G.jsx)(`p`,{children:`Could not load reports`}),(0,G.jsx)(`p`,{className:`text-sm text-soft-foreground`,children:c.error.message}),(0,G.jsx)(o,{className:`min-h-11`,onClick:()=>void c.refetch(),children:`Retry`})]}):f.length===0?(0,G.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,G.jsx)(`h2`,{className:`font-medium`,children:s?`No matching reports`:`No published reports yet`}),s?(0,G.jsx)(o,{"data-slot":`reports-clear-search`,variant:`outline`,className:`min-h-11`,onClick:()=>p(``),children:`Clear search`}):(0,G.jsxs)(`p`,{className:`text-sm text-soft-foreground`,children:[`Publish an HTML snapshot with `,(0,G.jsxs)(`code`,{children:[D(),` artifact publish`]}),` to list it here.`]})]}):(0,G.jsx)(`ul`,{className:`flex flex-col gap-3`,children:f.map(e=>(0,G.jsxs)(`li`,{"data-slot":`report-row`,className:`reports-row rounded-lg border border-border bg-card p-3`,children:[(0,G.jsx)(`h2`,{className:`min-w-0 font-medium [overflow-wrap:anywhere]`,children:(0,G.jsx)(T,{"data-report-id":e.id,className:`reports-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:d,filesRestoreKey:d},onClick:()=>K.set(d,{scroll:l.current?.scrollTop??0,row:e.id,pages:c.data?.pages.length??1}),children:k(e)})}),(0,G.jsx)(T,{className:`reports-task text-sm text-accent-text underline [overflow-wrap:anywhere]`,to:`/tasks/${e.runId}`,children:e.taskTitle}),(0,G.jsx)(`time`,{className:`block text-xs text-soft-foreground`,dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleString()})]},e.id))}),c.hasNextPage?(0,G.jsx)(o,{variant:`outline`,className:`min-h-11`,disabled:c.isFetchingNextPage,onClick:()=>void c.fetchNextPage(),children:`Load more reports`}):null]})]})}export{q as ReportsRoute};
|