blade-code 0.10.20 → 0.10.22
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/dist/blade.js +2 -2
- package/dist/{chunk-z2fn2yg8.js → chunk-04gq93dx.js} +1 -1
- package/dist/{chunk-nqd6t5t7.js → chunk-06pbdpcg.js} +1 -1
- package/dist/{chunk-wmttq8eq.js → chunk-18f9g8ja.js} +1 -1
- package/dist/{chunk-2c3zavy2.js → chunk-18n15nn8.js} +1 -1
- package/dist/chunk-1ejj4jvg.js +1 -0
- package/dist/{chunk-eakfkjk4.js → chunk-244cdt25.js} +1 -1
- package/dist/{chunk-fa6313dv.js → chunk-2kpynwxa.js} +1 -1
- package/dist/{chunk-htarfekt.js → chunk-2rbct4ks.js} +3 -3
- package/dist/{chunk-t3b689pm.js → chunk-33wheqb0.js} +1 -1
- package/dist/chunk-34cqp0rx.js +1 -0
- package/dist/chunk-3bk8jveq.js +1 -0
- package/dist/{chunk-095x2ykj.js → chunk-4dnvydyv.js} +1 -1
- package/dist/{chunk-kf56q9zs.js → chunk-5bgyskdm.js} +1 -1
- package/dist/{chunk-6sb7cg95.js → chunk-5sw8j9ae.js} +1 -1
- package/dist/{chunk-r1jxbx1h.js → chunk-5xph8r1k.js} +1 -1
- package/dist/{chunk-zzkdr84r.js → chunk-5ztdsaex.js} +2 -2
- package/dist/{chunk-1n60pgsq.js → chunk-698qsvyb.js} +2 -2
- package/dist/chunk-7nygnmnm.js +1 -0
- package/dist/{chunk-jpwfq49n.js → chunk-8472vz3s.js} +2 -2
- package/dist/{chunk-96h588rd.js → chunk-9ka0bdry.js} +1 -1
- package/dist/{chunk-k3nkcaap.js → chunk-9m80tr4t.js} +2 -2
- package/dist/chunk-9nc6sfj4.js +1 -0
- package/dist/chunk-9wdg2mqh.js +1 -0
- package/dist/{chunk-zqf8043h.js → chunk-a3yg9fd5.js} +358 -337
- package/dist/{chunk-zdkc4kj1.js → chunk-abtq0kjb.js} +1 -1
- package/dist/{chunk-fvj1mzgs.js → chunk-afv2grka.js} +1 -1
- package/dist/chunk-avtsweaa.js +1 -0
- package/dist/{chunk-0y0wbjyf.js → chunk-bh42pn4d.js} +2 -2
- package/dist/{chunk-6g5k5de1.js → chunk-c7zk9zj2.js} +1 -1
- package/dist/{chunk-yvf4nmds.js → chunk-czjbz0fp.js} +2 -2
- package/dist/{chunk-j9vqys2g.js → chunk-d3kqhv5k.js} +3 -3
- package/dist/{chunk-6207mbmr.js → chunk-djh79rde.js} +2 -2
- package/dist/{chunk-bffw1t7e.js → chunk-ef8rr9eh.js} +2 -2
- package/dist/{chunk-yqfqj7mh.js → chunk-f9tahtz6.js} +1 -1
- package/dist/{chunk-7pkscxbb.js → chunk-g1zrs8tj.js} +1 -1
- package/dist/{chunk-y2g5a5bp.js → chunk-gcsygn5a.js} +1 -1
- package/dist/{chunk-fbnetqrz.js → chunk-gwvds95j.js} +2 -2
- package/dist/{chunk-qkrssft1.js → chunk-h0q03x9f.js} +1 -1
- package/dist/{chunk-h41b8965.js → chunk-haqfbgv4.js} +1 -1
- package/dist/chunk-hfveg7c1.js +1 -0
- package/dist/{chunk-wt7gy9bm.js → chunk-hjvdsrzb.js} +2 -2
- package/dist/chunk-kky5ydtw.js +2 -0
- package/dist/{chunk-xfr5z6pz.js → chunk-kntre6sz.js} +2 -2
- package/dist/{chunk-kbpc97n3.js → chunk-ksm02qjh.js} +2 -2
- package/dist/{chunk-prgh321y.js → chunk-kvd5nexw.js} +1 -1
- package/dist/{chunk-5chec8rs.js → chunk-m27w377p.js} +1 -1
- package/dist/{chunk-619rxqh6.js → chunk-m96f2aq9.js} +2 -2
- package/dist/chunk-mrx6qkax.js +1 -0
- package/dist/chunk-n63thdsq.js +100 -0
- package/dist/{chunk-xpt6cdn8.js → chunk-nwy1rpwf.js} +2 -2
- package/dist/chunk-p29w4zfc.js +1 -0
- package/dist/{chunk-ehgfwwqk.js → chunk-pefrn6n0.js} +1 -1
- package/dist/{chunk-e37k44j1.js → chunk-qw900zg9.js} +2 -2
- package/dist/{chunk-f6a1grte.js → chunk-r40fthzd.js} +2 -2
- package/dist/{chunk-xet98pc1.js → chunk-rxfmqnf7.js} +2 -2
- package/dist/chunk-s1310gqw.js +1 -0
- package/dist/{chunk-83jkb44s.js → chunk-s7g6jt82.js} +2 -2
- package/dist/{chunk-bv7e8221.js → chunk-se1ef1r7.js} +2 -2
- package/dist/chunk-sr2stcda.js +2 -0
- package/dist/chunk-tnt2hhcg.js +1 -0
- package/dist/chunk-txqccp76.js +1 -0
- package/dist/{chunk-entmz5b1.js → chunk-vannpbp0.js} +1 -1
- package/dist/chunk-vc2c8wkx.js +2 -0
- package/dist/chunk-vxhf2q0r.js +1 -0
- package/dist/{chunk-8rzwyknk.js → chunk-vypake1a.js} +2 -2
- package/dist/{chunk-6pa6c2n0.js → chunk-wax3nm7t.js} +1 -1
- package/dist/{chunk-yz2bsntj.js → chunk-xjqcc0nt.js} +1 -1
- package/dist/chunk-y5xyh4br.js +10 -0
- package/dist/{chunk-zt5wq0qj.js → chunk-yqk501wp.js} +1 -1
- package/dist/{chunk-d9k98jy2.js → chunk-zj651nrm.js} +1 -1
- package/dist/web/assets/ChatView-CCxjYDmJ.js +7 -0
- package/dist/web/assets/{CodeBlockHighlighter-DYuOTwXS.js → CodeBlockHighlighter-D9MqsrZP.js} +1 -1
- package/dist/web/assets/{FilePreview-CWOBOnzz.js → FilePreview-Cn5HOlPw.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-YiYvkN2w.js → MarkdownRenderer-ALTOCdfi.js} +3 -3
- package/dist/web/assets/{SettingsModal-BT-oFKGN.js → SettingsModal-Dk69F1bS.js} +1 -1
- package/dist/web/assets/{TaskSwitcher-D5Gd6FN9.js → TaskSwitcher-DRZZocE1.js} +1 -1
- package/dist/web/assets/{TerminalPanel-C1hLHq_K.js → TerminalPanel-ByAqKZ47.js} +1 -1
- package/dist/web/assets/{index-DuYx6fkN.js → index-CRCirUK7.js} +5 -5
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-3qhqbj09.js +0 -2
- package/dist/chunk-4544fy5s.js +0 -1
- package/dist/chunk-4svjvyyd.js +0 -1
- package/dist/chunk-7wx9vt15.js +0 -1
- package/dist/chunk-87vsgqvy.js +0 -1
- package/dist/chunk-88639hse.js +0 -1
- package/dist/chunk-8mp5qg8q.js +0 -1
- package/dist/chunk-a5ncqsat.js +0 -1
- package/dist/chunk-axe8621t.js +0 -1
- package/dist/chunk-bcxbrbvd.js +0 -1
- package/dist/chunk-eq5kb8m9.js +0 -1
- package/dist/chunk-h1b6wehr.js +0 -1
- package/dist/chunk-n00q74bt.js +0 -1
- package/dist/chunk-q3c07kb4.js +0 -2
- package/dist/chunk-q6ev6t06.js +0 -100
- package/dist/chunk-qt114yth.js +0 -2
- package/dist/chunk-w6azkwgq.js +0 -10
- package/dist/chunk-y72p0x68.js +0 -1
- package/dist/chunk-zvdervx9.js +0 -1
- package/dist/web/assets/ChatView-YFotW0KS.js +0 -7
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-YiYvkN2w.js","assets/index-DuYx6fkN.js","assets/vendor-react-DG5dkZ_t.js","assets/vendor-radix-DXRuAJHH.js","assets/vendor-icons-ICv1v-tf.js","assets/session-events-K_9Lexp8.js","assets/index-BC7ygRH_.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as f,j as e}from"./vendor-react-DG5dkZ_t.js";import{u as M,a as w,b as ie,s as je,c as $e,d as W,D as ye,e as we,f as Pe,g as Ne,h as Se,i as Ce,j as A,k as H,B as ne,_ as _e,S as Ve,l as Le,m as Oe,C as Ue,n as He}from"./index-DuYx6fkN.js";import{Q as xe,O as Ke,G as ze,Y as qe,L as F,z as Ge,T as Y,C as Z,Z as We,v as Je,_ as Qe,B as Ye,$ as Ee,y as ee,m as oe,R as le,s as Xe,H as Ze,a0 as Te,U as et,a1 as tt,a2 as st,a3 as rt,P as Ae,a4 as at,X as nt,a5 as it,a6 as ot,f as Fe,a7 as lt,W as ct,a as dt}from"./vendor-icons-ICv1v-tf.js";import{k as ut,g as mt,l as xt,e as ht,t as pt,j as ft}from"./session-events-K_9Lexp8.js";import{j as bt,k as gt,l as vt,m as Me}from"./vendor-radix-DXRuAJHH.js";function he(t){return t.split("/").filter(Boolean).at(-1)||t}function kt(){const t=M(),s=w(y=>y.sessions),r=w(y=>y.currentSessionRef),a=w(y=>y.taskDeliveryActions),o=w(y=>y.deliverTask),i=ie(y=>y.openFilePreview),[m,b]=f.useState(!1),c=s.find(y=>je({sessionId:y.sessionId,projectPath:y.projectPath},r));if(!(c!=null&&c.taskIsolation))return null;const l=c.taskDiffStat,v=c.taskIsolation==="worktree",n=$e(c),d=a[W(n)],p=c.taskDelivery,j=(p==null?void 0:p.status)==="conflicted",N=!!(l&&(l.changedFiles>0||l.commits>0)),h=!["queued","running"].includes(c.taskStatus),C=(p==null?void 0:p.status)==="applied"||(p==null?void 0:p.status)==="discarded",u=v&&N&&h&&!C,x=l?l.additions+l.deletions:0,g=x>0&&l?l.additions/x*100:0,S=y=>{o(n,y).catch(()=>{})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-h-10 flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/60 px-3 py-1.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:px-5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx(xe,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:he(c.taskSourceProjectPath||c.projectPath)})]}),e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[v?e.jsx(Ke,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(xe,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:v?"text-[hsl(var(--deck-accent))]":void 0,children:t(v?"artifact.env.isolated":"artifact.env.local")})]}),c.taskWorktreeBranch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 truncate",title:c.taskWorktreeBranch,children:[e.jsx(ze,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:c.taskWorktreeBranch})]})]})]}),l&&e.jsxs("div",{className:"ml-auto flex max-w-full items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(qe,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:l.changedFiles})]}),x>0&&e.jsxs("span",{className:"relative hidden h-1.5 w-14 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] sm:inline-flex","aria-hidden":"true",children:[e.jsx("span",{className:"h-full bg-[hsl(var(--deck-accent))]",style:{width:`${g}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-g}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",l.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",l.deletions]}),l.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:l.commits})}),N&&(p==null?void 0:p.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:()=>i({tab:"diff"}),className:"inline-flex items-center gap-1 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 py-1 text-[hsl(var(--deck-ink))] transition hover:border-[hsl(var(--deck-accent)/0.55)] hover:text-[hsl(var(--deck-accent))]",children:t("artifact.review")}),u&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!d,onClick:()=>S("apply"),className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2 py-1 font-semibold text-white transition hover:brightness-95 disabled:cursor-wait disabled:opacity-65",children:[d==="apply"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(Ge,{className:"h-3 w-3"}),t(d==="apply"?"artifact.applying":j?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!d,onClick:()=>b(!0),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[hsl(var(--deck-ink-faint))] transition hover:bg-red-500/10 hover:text-red-600 disabled:cursor-wait disabled:opacity-50 dark:hover:text-red-400","aria-label":t("artifact.discard"),title:t("artifact.discard"),children:d==="discard"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(Y,{className:"h-3 w-3"})})]}),(p==null?void 0:p.status)==="applied"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-500/10 px-2 py-1 font-semibold text-emerald-700 dark:text-emerald-300",children:[e.jsx(Z,{className:"h-3 w-3"}),t("artifact.applied")]}),(p==null?void 0:p.status)==="discarded"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-surface-2))] px-2 py-1 text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(Y,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(p==null?void 0:p.status)==="conflicted"&&e.jsxs("div",{className:"flex w-full items-start gap-1.5 border-t border-amber-500/20 pt-1.5 text-amber-700 dark:text-amber-300",role:"alert",children:[e.jsx(We,{className:"mt-0.5 h-3 w-3 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 space-y-0.5",children:[e.jsx("span",{className:"block",children:p.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(ye,{open:m,onOpenChange:b,children:e.jsxs(we,{className:"w-[calc(100%_-_2rem)] max-w-md border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink))]",children:[e.jsxs(Pe,{children:[e.jsx(Ne,{children:t("artifact.discardDialog.title")}),e.jsx(Se,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:he(c.taskSourceProjectPath||c.projectPath),count:(l==null?void 0:l.changedFiles)??0})})]}),e.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-xs leading-relaxed text-red-700 dark:text-red-300",children:t("artifact.discardDialog.warning")}),e.jsxs(Ce,{className:"gap-2 sm:space-x-0",children:[e.jsx("button",{type:"button",onClick:()=>b(!1),className:"rounded-md border border-[hsl(var(--deck-border))] px-3 py-2 text-sm hover:bg-[hsl(var(--deck-surface-2))]",children:t("artifact.discardDialog.cancel")}),e.jsxs("button",{type:"button",onClick:()=>{b(!1),S("discard")},className:"inline-flex items-center justify-center gap-1.5 rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white hover:bg-red-700",children:[e.jsx(Y,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const jt=new Set(["completed","stale","failed","aborted","interrupted"]),yt={completed:"chat.review.status.completed",stale:"chat.review.status.stale",failed:"chat.review.status.failed",aborted:"chat.review.status.aborted",interrupted:"chat.review.status.interrupted"},wt={completed:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 border-emerald-500/20",stale:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/20",failed:"bg-red-500/10 text-red-700 dark:text-red-300 border-red-500/20",aborted:"bg-zinc-500/10 text-zinc-700 dark:text-zinc-300 border-zinc-500/20",interrupted:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/20"};function X(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Nt(t){const s=X(t),r=X(s==null?void 0:s.codeLocation),a=s==null?void 0:s.priority,o=s==null?void 0:s.confidenceScore,i=r==null?void 0:r.lineStart,m=r==null?void 0:r.lineEnd;if(!(typeof(s==null?void 0:s.title)!="string"||typeof s.body!="string"||a!==0&&a!==1&&a!==2&&a!==3||typeof o!="number"||!Number.isFinite(o)||typeof(r==null?void 0:r.path)!="string"||!Number.isInteger(i)||!Number.isInteger(m)))return{title:s.title,body:s.body,priority:a,confidenceScore:o,codeLocation:{path:r.path,lineStart:i,lineEnd:m}}}function St(t){const s=X(t),r=X(s==null?void 0:s.target);if((s==null?void 0:s.phase)!=="completed"||typeof s.status!="string"||!jt.has(s.status)||typeof(r==null?void 0:r.label)!="string"||r.kind!=="uncommitted"&&r.kind!=="base"&&r.kind!=="commit"||typeof s.overallExplanation!="string"||!Array.isArray(s.findings))return;const a=s.findings.map(Nt);if(!a.some(o=>o===void 0))return{status:s.status,target:{kind:r.kind,label:r.label,...typeof r.reference=="string"?{reference:r.reference}:{}},overallExplanation:s.overallExplanation,findings:a,...typeof s.error=="string"?{error:s.error}:{}}}function Ct(t){const{path:s,lineStart:r,lineEnd:a}=t.codeLocation;return r===a?`${s}:L${r}`:`${s}:L${r}-${a}`}function Et({report:t}){const s=M(),r=t.target.kind==="uncommitted"?s("chat.review.target.uncommitted"):t.target.kind==="base"?s("chat.review.target.base",{ref:t.target.reference??t.target.label}):s("chat.review.target.commit",{ref:t.target.reference??t.target.label});return e.jsxs("section",{"data-code-review-report":!0,className:"overflow-hidden rounded-xl border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface-2))]/60 px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-[hsl(var(--deck-ink))]",children:s("chat.review.title")}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:[s("chat.review.target"),": ",r]})]}),e.jsxs("span",{className:A("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",wt[t.status]),children:[s("chat.review.status"),": ",s(yt[t.status])]})]}),e.jsxs("div",{className:"space-y-4 px-4 py-3.5",children:[e.jsx("p",{className:"whitespace-pre-wrap text-[13px] leading-6 text-[hsl(var(--deck-ink-muted))]",children:t.overallExplanation}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("h4",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:s("chat.review.findings")}),e.jsx("span",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:t.findings.length})]}),t.findings.length===0?e.jsx("div",{className:"rounded-lg bg-[hsl(var(--deck-surface-2))] px-3 py-2.5 text-[12px] text-[hsl(var(--deck-ink-muted))]",children:s("chat.review.noFindings")}):e.jsx("ol",{className:"space-y-2",children:t.findings.map((a,o)=>e.jsxs("li",{className:"rounded-lg border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-3 py-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx("h5",{className:"text-[12.5px] font-medium leading-5 text-[hsl(var(--deck-ink))]",children:a.title}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:s("chat.review.confidence",{value:a.confidenceScore.toFixed(2)})})]}),e.jsx("code",{className:"mt-1 block text-[10.5px] text-[hsl(var(--deck-accent))]",children:Ct(a)}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:a.body})]},`${a.codeLocation.path}:${a.codeLocation.lineStart}:${o}`))})]}),t.error&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-[11px] text-red-700 dark:text-red-300",children:[e.jsxs("span",{className:"font-medium",children:[s("chat.review.error"),":"]})," ",t.error]})]})]})}function Tt({elicitation:t,messageId:s}){const r=M(),a=w(u=>u.currentSessionRef),o=w(u=>u.setElicitation),[i,m]=f.useState(()=>Ft(t.details.fields??[])),[b,c]=f.useState(()=>Mt(t.details.fields??[])),[l,v]=f.useState(!1),[n,d]=f.useState(),p=t.details.fields??[],j=f.useMemo(()=>p.every(u=>{var g;if(!u.required)return!0;if(te(u))return!!((g=b[u.name])!=null&&g.trim()||u.defaultValue!==void 0);const x=i[u.name]??u.defaultValue;return Array.isArray(x)?x.length>0:x!==void 0}),[p,b,i]);if(t.status!=="pending")return e.jsx("div",{className:"rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r(t.status==="cancelled"?"interaction.elicitation.cancelled":"interaction.elicitation.responded")});const N=async(u,x)=>{if(!(!a||l)){v(!0),d(void 0);try{await H.respondToElicitation(a,t.toolCallId,{action:u,...x?{content:x}:{}}),o(s,{...t,status:"responded"})}catch(g){d(g instanceof Error?g.message:r("interaction.elicitation.failed"))}finally{v(!1)}}},h=async()=>{try{await N("accept",Dt(p,i,b))}catch(u){d(u instanceof Error?u.message:String(u))}},C=()=>{const u=t.details.url;if(!u){d("MCP URL is unavailable");return}if(!window.open(u,"_blank","noopener,noreferrer")){d("The browser blocked the external window");return}N("accept")};return e.jsxs("div",{"data-pending-interaction":"elicitation",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Je,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"font-mono text-[12px] font-semibold text-[hsl(var(--deck-ink))]",children:[r("interaction.elicitation.title")," · ",t.details.serverName]}),e.jsx("div",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t.details.message}),e.jsx("div",{className:"font-mono text-[11px] text-amber-700 dark:text-amber-300",children:r("interaction.elicitation.warning")})]})]}),t.details.mode==="url"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] p-3 font-mono text-[11px]",children:[e.jsx("div",{className:"text-[hsl(var(--deck-ink-muted))]",children:t.details.domain}),e.jsx("div",{className:"mt-1 break-all text-[hsl(var(--deck-ink))]",children:t.details.url})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(q,{onClick:C,disabled:l,primary:!0,label:r("interaction.elicitation.open"),icon:e.jsx(Qe,{className:"h-3.5 w-3.5"})}),e.jsx(q,{onClick:()=>void N("decline"),disabled:l,label:r("interaction.elicitation.decline")}),e.jsx(q,{onClick:()=>void N("cancel"),disabled:l,label:r("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[p.map(u=>e.jsx(At,{field:u,value:i[u.name],rawValue:b[u.name]??"",onValueChange:x=>m(g=>({...g,[u.name]:x})),onRawChange:x=>c(g=>({...g,[u.name]:x}))},u.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(q,{onClick:()=>void h(),disabled:l||!j,primary:!0,label:r("interaction.elicitation.submit"),icon:l?e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(q,{onClick:()=>void N("decline"),disabled:l,label:r("interaction.elicitation.decline")}),e.jsx(q,{onClick:()=>void N("cancel"),disabled:l,label:r("interaction.elicitation.cancel")})]})]}),n&&e.jsx("div",{className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:n})]})}function At({field:t,value:s,rawValue:r,onValueChange:a,onRawChange:o}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:`mcp-elicitation-${t.name}`,className:"block font-mono text-[12px] font-medium text-[hsl(var(--deck-ink))]",children:[t.title,t.required?" *":""]}),t.description&&e.jsx("div",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:t.description}),t.type==="select"||t.type==="multi-select"||t.type==="boolean"?e.jsx("div",{id:`mcp-elicitation-${t.name}`,className:"flex flex-wrap gap-2",children:Rt(t).map(i=>{const m=Array.isArray(s)?s.includes(i.value):s===i.typedValue;return e.jsx("button",{type:"button","aria-pressed":m,onClick:()=>{if(t.type==="multi-select"){const b=Array.isArray(s)?s:[];a(b.includes(i.value)?b.filter(c=>c!==i.value):[...b,i.value])}else a(i.typedValue)},className:A("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",m?"border-emerald-500 bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-200":"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:i.label},i.value)})}):e.jsx("input",{id:`mcp-elicitation-${t.name}`,type:It(t),value:r,onChange:i=>o(i.target.value),min:t.minimum,max:t.maximum,minLength:t.minLength,maxLength:t.maxLength,required:t.required,placeholder:t.defaultValue===void 0?t.required?"Required":"Optional":String(t.defaultValue),className:"w-full rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink))] outline-none transition-colors focus:border-amber-500 focus:ring-1 focus:ring-amber-500"})]})}function q({onClick:t,disabled:s,primary:r=!1,label:a,icon:o}){return e.jsxs("button",{type:"button",onClick:t,disabled:s,className:A("inline-flex min-h-8 items-center gap-1.5 rounded-md px-3 py-1.5 font-mono text-[12px] transition-colors disabled:cursor-wait disabled:opacity-50",r?"bg-amber-600 text-white hover:bg-amber-700":"border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:[o,a]})}function Ft(t){return Object.fromEntries(t.filter(s=>!te(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function Mt(t){return Object.fromEntries(t.filter(s=>te(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function Dt(t,s,r){var o;const a={};for(const i of t){if(te(i)){const b=((o=r[i.name])==null?void 0:o.trim())??"";if(!b){if(i.defaultValue!==void 0)a[i.name]=i.defaultValue;else if(i.required)throw new Error(`${i.title} is required`);continue}if(i.type==="number"||i.type==="integer"){const c=Number(b);if(!Number.isFinite(c))throw new Error(`${i.title} must be a finite number`);if(i.type==="integer"&&!Number.isSafeInteger(c))throw new Error(`${i.title} must be a safe integer`);a[i.name]=c}else a[i.name]=b;continue}const m=s[i.name]??i.defaultValue;if(m===void 0){if(i.required)throw new Error(`${i.title} is required`);continue}if(Array.isArray(m)){if(i.minItems!==void 0&&m.length<i.minItems)throw new Error(`${i.title} requires at least ${i.minItems} choices`);if(i.maxItems!==void 0&&m.length>i.maxItems)throw new Error(`${i.title} allows at most ${i.maxItems} choices`)}a[i.name]=m}return a}function Rt(t){return t.type==="boolean"?[{value:"true",label:"Yes",typedValue:!0},{value:"false",label:"No",typedValue:!1}]:(t.options??[]).map(s=>({...s,typedValue:s.value}))}function te(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function It(t){return t.type==="number"||t.type==="integer"?"number":t.format==="email"?"email":t.format==="uri"?"url":t.format==="date"?"date":t.format==="date-time"?"datetime-local":"text"}function Bt(t){if(!t||typeof t!="object"||Array.isArray(t))return;const s=t;if(!(!s.output||typeof s.output!="object"||Array.isArray(s.output)))return{output:s.output,...typeof s.schemaDigest=="string"?{schemaDigest:s.schemaDigest}:{}}}function $t({report:t}){const s=M(),[r,a]=f.useState(!1),o=JSON.stringify(t.output,null,2),i=async()=>{try{await navigator.clipboard.writeText(o),a(!0),window.setTimeout(()=>a(!1),1400)}catch{}};return e.jsxs("section",{"data-structured-output":!0,className:"overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex min-h-9 items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(Ye,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-accent))]"}),e.jsx("span",{className:"font-mono text-[11px] font-semibold text-[hsl(var(--deck-ink))]",children:s("chat.structuredOutput.title")}),t.schemaDigest&&e.jsxs("span",{title:t.schemaDigest,className:"truncate font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["sha256:",t.schemaDigest.slice(0,10)]})]}),e.jsx("button",{type:"button",onClick:i,"aria-label":s("chat.structuredOutput.copy"),title:s("chat.structuredOutput.copy"),className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:r?e.jsx(Z,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Ee,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"max-h-[440px] overflow-auto whitespace-pre p-3 font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink))]",children:o})]})}const Pt=f.lazy(()=>_e(()=>import("./MarkdownRenderer-YiYvkN2w.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function pe({text:t,label:s}){const[r,a]=f.useState(!1);if(!t.trim())return null;const o=async()=>{try{await navigator.clipboard.writeText(t),a(!0),window.setTimeout(()=>a(!1),1400)}catch{}};return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:o,className:"flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:r?e.jsx(Z,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Ee,{className:"h-3.5 w-3.5"})})}function _t(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] shadow-[0_1px_0_hsl(var(--deck-hairline))]",children:e.jsx(ne,{size:20,pulse:!1})})}function Vt(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-full border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas-veil))]",children:e.jsx("span",{className:"font-mono text-[11px] font-medium text-[hsl(var(--deck-ink))]",children:"U"})})}function fe(t){let s=t;return s=s.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g,""),s=s.replace(/<file path="[^"]*">[\s\S]*?<\/file>/g,""),s=s.replace(/<attached_files>[\s\S]*?<\/attached_files>/g,""),s=s.trim(),s}function Lt(t){if(typeof t=="string")return{text:fe(t),images:[]};const s=t.filter(a=>a.type==="text").map(a=>a.text).join(`
|
|
3
|
-
`),r=t.filter(a=>a.type==="image_url").map(a=>a.image_url.url);return{text:fe(s),images:r}}function ce(t){return typeof t=="string"?t:t.filter(s=>s.type==="text").map(s=>s.text).join(`
|
|
4
|
-
`)}function Ot(t){const s=t.agentContent;return s?ut(s):ce(t.content)}function be({content:t,syntaxHighlight:s=!0}){return e.jsx(f.Suspense,{fallback:e.jsx("pre",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono whitespace-pre-wrap",children:t}),children:e.jsx(Pt,{content:t,syntaxHighlight:s})})}function de({status:t}){if(!t)return null;const s={running:"bg-[#FEF3C7] text-[#92400E] dark:bg-[#F59E0B]/20 dark:text-[#FBBF24]",success:"bg-[#DCFCE7] text-[#15803D] dark:bg-[#22C55E]/20 dark:text-[#22C55E]",error:"bg-[#FEE2E2] text-[#b91c1c] dark:bg-[#EF4444]/20 dark:text-[#fca5a5]",pending:"bg-[#E5E7EB] text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",info:"bg-[#DBEAFE] text-[#1D4ED8] dark:bg-[#3B82F6]/20 dark:text-[#60A5FA]"},r={running:"Running",success:"Success",error:"Error",pending:"Pending",info:"Info"};return e.jsx("span",{className:A("text-[11px] px-2 py-0.5 rounded-full font-mono",s[t]),children:r[t]})}function Ut(t){if(!t)return"";if(typeof t=="string")try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}return JSON.stringify(t,null,2)}function Ht({tool:t}){const[s,r]=f.useState(!1),a=Ut(t.arguments);return e.jsxs("div",{className:"bg-white dark:bg-[#18181b] border border-[hsl(var(--deck-border))] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button","aria-expanded":s,"data-tool-call-id":t.toolCallId,onClick:()=>r(o=>!o),className:"w-full flex items-center justify-between px-3 py-2 bg-[hsl(var(--deck-surface-2))] hover:bg-[hsl(var(--deck-surface))] transition-colors",children:[e.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[s?e.jsx(ee,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}):e.jsx(oe,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}),e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink))] font-mono shrink-0",children:t.toolName}),t.summary&&e.jsx("span",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono truncate",children:t.summary})]}),e.jsx(de,{status:t.status})]}),t.status==="running"&&t.progressMessage&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx("span",{className:"truncate",children:t.progressMessage}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsxs("span",{className:"shrink-0",children:[Math.max(0,Math.min(100,Math.round(t.progress/t.progressTotal*100))),"%"]})]}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${t.toolName} progress`,"aria-valuemin":0,"aria-valuemax":t.progressTotal,"aria-valuenow":Math.min(t.progress,t.progressTotal),className:"h-1 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,t.progress/t.progressTotal*100))}%`}})})]}),s&&e.jsxs("div",{className:"px-3 py-2 space-y-2 border-t border-[hsl(var(--deck-border))]",children:[a&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Arguments"}),e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:a})]}),t.output&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Output"}),e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:t.output.length>500?t.output.slice(0,500)+"...":t.output})]})]})]})}function De({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(Ht,{tool:s},s.toolCallId))})}function Kt({toolCalls:t,toolCallIds:s}){const r=M(),[a,o]=f.useState(!1),i=f.useMemo(()=>new Map(t.map(n=>[n.toolCallId,n])),[t]),m=s.flatMap(n=>{const d=i.get(n);return d?[d]:[]});if(m.length===0)return null;const b=m.filter(n=>n.status==="running").length,c=m.filter(n=>n.status==="error").length,l=[...m].reverse().find(n=>n.status==="running"&&!!n.progressMessage),v=b>0?r(m.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:m.length}):c>0?r(m.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:m.length,errors:c}):r(m.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:m.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>o(n=>!n),className:"group flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[a?e.jsx(ee,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(oe,{className:"h-3.5 w-3.5 shrink-0"}),b>0&&e.jsx(F,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:v}),(l==null?void 0:l.progressMessage)&&e.jsxs("span",{className:"min-w-0 truncate text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[l.progressMessage,l.progress!==void 0&&l.progressTotal!==void 0&&` · ${Math.max(0,Math.min(100,Math.round(l.progress/l.progressTotal*100)))}%`]})]}),(l==null?void 0:l.progress)!==void 0&&l.progressTotal!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${l.toolName} progress`,"aria-valuemin":0,"aria-valuemax":l.progressTotal,"aria-valuenow":Math.min(l.progress,l.progressTotal),className:"mx-1.5 h-0.5 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,l.progress/l.progressTotal*100))}%`}})}),a&&e.jsx("div",{"data-agent-tool-group-details":!0,className:"mt-2 space-y-2 pl-1",children:e.jsx(De,{toolCalls:m})})]})}function zt({content:t}){const s=M(),[r,a]=f.useState(!1);return t?e.jsxs("div",{"data-agent-thinking":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>a(o=>!o),className:"flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[r?e.jsx(ee,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(oe,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{children:s("chat.timeline.thinking")})]}),r&&e.jsx("div",{className:"ml-1 mt-1 border-l border-[hsl(var(--deck-border))] py-1 pl-3",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:t})})]}):null}function qt({tasks:t}){if(t.length===0)return null;const s=t.filter(a=>a.status==="completed").length,r=s===t.length;return e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"flex gap-2 items-center",children:e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r?"✓ All tasks done":`Tasks: ${s}/${t.length}`})})})}function Gt({toolCalls:t}){const s=ie(a=>a.openFilePreview),r=f.useMemo(()=>{const a=new Map,o=["Write","SearchReplace","Edit","ApplyPatch"];for(const i of t){if(i.status!=="success")continue;const m=i.metadata;if(i.toolName==="ApplyPatch"&&Array.isArray(m==null?void 0:m.changes)){for(const c of m.changes)c&&typeof c=="object"&&"path"in c&&typeof c.path=="string"&&a.set(c.path,{path:c.path,toolName:i.toolName});continue}const b=m==null?void 0:m.file_path;b&&o.includes(i.toolName)&&a.set(b,{path:b,toolName:i.toolName})}return Array.from(a.values())},[t]);return r.length===0?null:e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono mb-1.5",children:["Changed files (",r.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(({path:a})=>{const o=a.split("/").pop()||a;return e.jsxs("button",{onClick:()=>s({tab:"diff",targetPath:a}),className:"flex items-center gap-1 px-2 py-1 text-[11px] font-mono bg-[#E5E7EB] dark:bg-[#27272a] text-[hsl(var(--deck-ink))] rounded hover:bg-[#D1D5DB] dark:hover:bg-[#3f3f46] transition-colors",title:a,children:[e.jsx(Xe,{className:"w-3 h-3"}),o]},a)})})]})}function Wt({subagent:t}){var I,K;const s=M(),[r,a]=f.useState(null),[o,i]=f.useState(!1),[m,b]=f.useState(null),[c,l]=f.useState(!1),[v,n]=f.useState(""),[d,p]=f.useState(!1),[j,N]=f.useState(null),[h,C]=f.useState(null),u=w(T=>T.currentSessionRef),x=w(T=>T.isStreaming),g=w(T=>T.isTemporarySession);if(!t)return null;const S=t.status==="running",y=r!==null?r:S,P=t.toolCalls||m||[],R=t.output||t.thinking||P.length>0||t.sessionId,O=h&&h.status!=="running"?h.id:t.sessionId,V=!S&&!x&&!g&&(h==null?void 0:h.status)!=="running"&&!!(O&&u);f.useEffect(()=>{if(!y||S||!t.sessionId||!(u!=null&&u.projectPath)||m!==null||t.toolCalls&&t.toolCalls.length>0)return;let T=!0;return i(!0),H.getMessages({sessionId:t.sessionId,projectPath:u.projectPath}).then(_=>{var $,D;if(!T)return;const L=ht(_),B=new Map;for(const U of L)if((D=($=U.agentContent)==null?void 0:$.toolCalls)!=null&&D.length)for(const z of U.agentContent.toolCalls)B.has(z.toolCallId)||B.set(z.toolCallId,z);b(Array.from(B.values()))}).finally(()=>{T&&i(!1)}),()=>{T=!1}},[y,S,t.sessionId,t.toolCalls,m,u==null?void 0:u.projectPath]),f.useEffect(()=>{if(!t.sessionId||!u)return;let T=!0;const _=t.rootAgentId??t.sessionId,L=t.resumeDepth??0;return H.listSubagents(u).then(B=>{if(!T)return;const $=B.filter(D=>D.id!==t.sessionId&&D.rootAgentId===_&&D.resumeDepth>L).sort((D,U)=>U.resumeDepth-D.resumeDepth||U.lastActiveAt-D.lastActiveAt)[0];$&&C($)}).catch(()=>{}),()=>{T=!1}},[u==null?void 0:u.sessionId,u==null?void 0:u.projectPath,t.sessionId,t.rootAgentId,t.resumeDepth]),f.useEffect(()=>{if(!h||h.status!=="running"||!u)return;let T=!0;const _=async()=>{try{const $=(await H.listSubagents(u)).find(D=>D.id===h.id);T&&$&&C($)}catch{}},L=window.setInterval(()=>{_()},1e3);return()=>{T=!1,window.clearInterval(L)}},[u,h==null?void 0:h.id,h==null?void 0:h.status]);const E=async()=>{if(!(!u||!O||!v.trim()||d)){p(!0),N(null);try{const T=await H.resumeSubagent(u,O,v.trim());C(T.session),n(""),l(!1),a(!0)}catch(T){N(T instanceof Error?T.message:s("chat.subagent.resumeFailed"))}finally{p(!1)}}};return e.jsxs("div",{"data-subagent-id":t.id,className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("button",{type:"button",onClick:()=>a(!y),className:"flex gap-2 justify-between items-center w-full transition-opacity cursor-pointer hover:opacity-80",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[S&&e.jsx(F,{className:"h-3 w-3 animate-spin text-[hsl(var(--deck-ink-muted))]"}),e.jsxs("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[t.type,": ",t.description]}),e.jsx(de,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:A("rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",t.verificationVerdict==="pass"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":t.verificationVerdict==="fail"?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-amber-500/10 text-amber-600 dark:text-amber-400"),children:t.verificationVerdict}),t.resumedFrom&&e.jsx("span",{className:"rounded bg-[#EDE9FE] px-1.5 py-0.5 text-[10px] font-mono text-[#6D28D9] dark:bg-[#2E1065] dark:text-[#C4B5FD]",title:s("chat.subagent.resumedFromTitle",{id:t.resumedFrom}),children:s("chat.subagent.resumedDepth",{depth:t.resumeDepth??1})})]}),R&&e.jsx(ee,{className:A("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",y&&"rotate-180")})]}),y&&e.jsxs("div",{className:"mt-2 space-y-2",children:[(t.output||t.thinking)&&e.jsxs(e.Fragment,{children:[t.output&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[160px] overflow-y-auto",children:t.output}),t.thinking&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:t.thinking})]}),o&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[e.jsx(F,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.loadingLogs")]}),!o&&P.length>0&&e.jsx(De,{toolCalls:P}),h&&e.jsxs("div",{className:"rounded-md border border-[#DDD6FE] bg-[#F5F3FF] p-2 text-[11px] font-mono text-[#5B21B6] dark:border-[#4C1D95] dark:bg-[#1E1B4B] dark:text-[#C4B5FD]",children:[e.jsx("div",{children:s("chat.subagent.resumedAs",{id:h.id,status:h.status,depth:h.resumeDepth??1})}),(((I=h.result)==null?void 0:I.message)||((K=h.result)==null?void 0:K.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:h.result.message||h.result.error})]}),V&&e.jsxs("div",{className:"space-y-2",children:[c?e.jsxs("div",{className:"space-y-2 rounded-md border border-[#E5E7EB] bg-white p-2 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsx("textarea",{"aria-label":s("chat.subagent.followUpAria"),value:v,onChange:T=>n(T.target.value),placeholder:s("chat.subagent.followUpPlaceholder"),rows:3,className:"w-full resize-y rounded border border-[#D1D5DB] bg-white p-2 text-[11px] text-[#111827] outline-none focus:border-[#8B5CF6] dark:border-[#3f3f46] dark:bg-[#18181b] dark:text-[#f4f4f5]"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:()=>{l(!1),N(null)},className:"rounded px-2 py-1 text-[11px] text-[#6B7280] hover:bg-[#F3F4F6] dark:hover:bg-[#27272a]",children:s("chat.subagent.cancel")}),e.jsxs("button",{type:"button",onClick:()=>void E(),disabled:!v.trim()||d,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[d&&e.jsx(F,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.resumeAgent")]})]})]}):e.jsxs("button",{type:"button","aria-label":s("chat.subagent.resumeAria"),onClick:()=>l(!0),className:"flex items-center gap-1.5 rounded-md border border-[#D1D5DB] px-2 py-1 text-[11px] font-medium text-[#374151] transition-colors hover:bg-[#F3F4F6] dark:border-[#3f3f46] dark:text-[#d4d4d8] dark:hover:bg-[#27272a]",children:[e.jsx(le,{className:"w-3 h-3"}),s("chat.subagent.resume")]}),j&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:j})]})]})]})}function Jt({confirmation:t,messageId:s}){const r=M(),[a,o]=f.useState(!1),[i,m]=f.useState(null),b=w(v=>v.currentSessionRef),c=w(v=>v.setConfirmation);if(!t)return null;const l=async(v,n)=>{if(!(!b||a)){o(!0),m(null);try{await H.respondPermission(b,t.toolCallId,{approved:v,scope:n}),c(s,{...t,status:v?"approved":"denied"})}catch(d){m(d instanceof Error?d.message:r("interaction.permission.failed"))}finally{o(!1)}}};return t.status!=="pending"?null:e.jsxs("div",{"data-pending-interaction":"permission",tabIndex:-1,role:"alert",className:"space-y-3 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:r("interaction.permission.title",{tool:t.toolName})}),e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:t.description}),t.diff&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[200px] overflow-y-auto",children:t.diff}),i&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:i}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void l(!0,"once"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:a?e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}):r("interaction.permission.once")}),t.allowRemember!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>void l(!0,"session"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#3B82F6] text-white rounded-md hover:bg-[#2563EB] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.session")}),e.jsx("button",{type:"button",onClick:()=>void l(!0,"project"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#6366F1] text-white rounded-md hover:bg-[#4F46E5] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.project")})]}),e.jsx("button",{type:"button",onClick:()=>void l(!1),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#EF4444] text-white rounded-md hover:bg-[#DC2626] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.deny")})]})]})}function Qt({question:t,messageId:s}){const r=M(),[a,o]=f.useState({}),[i,m]=f.useState({}),[b,c]=f.useState(!1),[l,v]=f.useState(null),n=w(h=>h.currentSessionRef),d=w(h=>h.setQuestion),p=f.useMemo(()=>t?t.questions.reduce((h,C)=>{var S;const u=(S=i[C.header])==null?void 0:S.trim(),x=a[C.header];if(C.multiSelect){const y=Array.isArray(x)?[...x]:[];return u&&y.push(u),y.length>0&&(h[C.header]=y),h}const g=u||(typeof x=="string"?x:"");return g&&(h[C.header]=g),h},{}):{},[a,i,t]),j=(t==null?void 0:t.questions.every(h=>h.header in p))??!1;if(!t)return null;const N=async()=>{if(!(!n||b||!j)){c(!0),v(null);try{await H.respondToQuestion(n,t.toolCallId,p),d(s,{...t,status:"answered",answers:p})}catch(h){v(h instanceof Error?h.message:r("interaction.question.failed"))}finally{c(!1)}}};return t.status!=="pending"?e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r("interaction.question.answered")})}):e.jsxs("div",{"data-pending-interaction":"question",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[t.questions.map((h,C)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:h.question}),e.jsxs("div",{className:"space-y-1",children:[h.options.map((u,x)=>e.jsxs("button",{type:"button",onClick:()=>{if(h.multiSelect){const g=a[h.header]||[],S=g.includes(u.label)?g.filter(y=>y!==u.label):[...g,u.label];o({...a,[h.header]:S})}else o({...a,[h.header]:u.label}),m({...i,[h.header]:""})},className:A("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(h.multiSelect?(a[h.header]||[]).includes(u.label):a[h.header]===u.label)?"bg-[#DCFCE7] text-[#166534] dark:bg-[#22C55E]/20 dark:text-[#E5E5E5]":"bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))]"),children:[e.jsx("div",{children:u.label}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-faint))] mt-1",children:u.description})]},x)),e.jsx("input",{"aria-label":`${h.header} other response`,value:i[h.header]??"",onChange:u=>m({...i,[h.header]:u.target.value}),placeholder:r("interaction.question.other"),className:"w-full rounded-md border border-[#E5E7EB] bg-white px-3 py-2 text-[12px] text-[#111827] outline-none focus:border-[#22C55E] dark:border-[#27272a] dark:bg-[#111113] dark:text-[#E5E5E5]"})]})]},C)),l&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:l}),e.jsxs("button",{type:"button",onClick:()=>void N(),disabled:b||!j,className:"inline-flex min-h-8 items-center gap-1.5 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:[b&&e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}),r("interaction.question.submit")]})]})}function Yt({message:t}){const s=t.agentContent,r=w(j=>j.isStreaming&&j.currentAssistantMessageId===t.id);if(!s){const j=ce(t.content);return j?e.jsx(be,{content:j}):null}const{toolCalls:a,tasks:o,confirmation:i,question:m,elicitation:b}=s,c=mt(s),l=xt(s);if(!(l.length>0||o.length>0||c.length>0||i||m||b)&&r)return e.jsxs("div",{className:"flex items-center gap-2 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(F,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-[12px] font-mono",children:"Thinking..."})]});const d=a.length>0&&a.every(j=>j.status==="success"||j.status==="error")&&!r,p=!r;return e.jsxs("div",{className:"space-y-3",children:[l.map(j=>j.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(zt,{content:j.content})},j.id):j.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(be,{content:j.content,syntaxHighlight:p})},j.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(Kt,{toolCalls:a,toolCallIds:j.toolCallIds})},j.id)),o.length>0&&e.jsx(qt,{tasks:o}),c.map(j=>e.jsx(Wt,{subagent:j},j.id)),i&&e.jsx(Jt,{confirmation:i,messageId:t.id}),m&&e.jsx(Qt,{question:m,messageId:t.id}),b&&e.jsx(Tt,{elicitation:b,messageId:t.id}),d&&e.jsx(Gt,{toolCalls:a})]})}function Xt({message:t,showAvatar:s=!0}){var b,c,l,v;const r=t.role==="user";if(t.role==="system"){const n=ce(t.content);return e.jsx("div",{"data-chat-message-id":t.id,className:"flex justify-center p-2 w-full",children:e.jsx("div",{className:"text-xs text-[hsl(var(--deck-ink-muted))] bg-[#F3F4F6] dark:bg-[#18181b] px-3 py-1 rounded-full font-mono",children:n})})}if(r){const n=(b=t.metadata)!=null&&b.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(c=t.metadata)!=null&&c.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(n){const j=typeof n.command=="string"?n.command:"",N=n.status==="running"?"running":n.status==="completed"?"success":"error",h=typeof n.output=="string"?n.output:[typeof n.stdout=="string"?n.stdout:"",typeof n.stderr=="string"&&n.stderr?`stderr:
|
|
5
|
-
${n.stderr}`:""].filter(Boolean).join(`
|
|
6
|
-
`);return e.jsx("div",{"data-chat-message-id":t.id,"data-user-shell-command":!0,className:"flex w-full justify-end p-4",children:e.jsxs("div",{className:"w-full max-w-[85%] overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 truncate font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:[e.jsx("span",{className:"mr-2 text-amber-600 dark:text-amber-400",children:"$"}),j]}),e.jsx(de,{status:N})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:h||"(no output)"}),typeof n.exitCode=="number"&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-1.5 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:["exit ",n.exitCode,typeof n.durationMs=="number"?` · ${(n.durationMs/1e3).toFixed(3)}s`:"",n.truncated===!0?" · truncated":""]})]})})}const{text:d,images:p}=Lt(t.content);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"user",className:"group flex gap-2 justify-end p-4 w-full items-start",children:[e.jsx("div",{className:"mt-1 flex shrink-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(pe,{text:d,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[d&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:d}),p.length>0&&e.jsx("div",{className:A("grid gap-2",p.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:p.map((j,N)=>e.jsx("img",{src:j,alt:`attachment-${N+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${j}-${N}`))})]}),e.jsx(Vt,{})]})}const o=Ot(t),i=St((l=t.metadata)==null?void 0:l.codeReview),m=Bt((v=t.metadata)==null?void 0:v.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,className:A("group flex gap-4 justify-start w-full",s?"p-4":"px-4 pt-0 pb-3"),children:[s?e.jsx(_t,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[i?e.jsx(Et,{report:i}):m?e.jsx($t,{report:m}):e.jsx(Yt,{message:t}),!m&&o.trim()&&e.jsx("div",{className:"mt-1.5 flex opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(pe,{text:o,label:"Copy response"})})]})]})}const Zt=f.memo(Xt);function es(t,s,r){return Math.max(0,t+(r-s))}function ts(t,s,r){return Math.min(s,Math.max(0,t)+Math.max(0,r))}function ge(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function ss({turns:t,viewportRef:s,containerRef:r,onRevealTurn:a}){const o=M(),[i,m]=f.useState(null),[b,c]=f.useState(!1),l=f.useRef(null),v=f.useCallback(()=>{var h;const d=s.current,p=r.current;if(!d||!p||t.length===0)return;const j=d.getBoundingClientRect().top;let N=((h=t[0])==null?void 0:h.id)??null;for(const C of t){const u=ge(p,C.id);if(u)if(u.getBoundingClientRect().top-j<=24)N=C.id;else break}m(N)},[t,s,r]);f.useEffect(()=>{const d=s.current;if(!d)return;const p=()=>{l.current===null&&(l.current=window.requestAnimationFrame(()=>{l.current=null,v()}))};return v(),d.addEventListener("scroll",p,{passive:!0}),()=>{d.removeEventListener("scroll",p),l.current!==null&&(window.cancelAnimationFrame(l.current),l.current=null)}},[v,s]);const n=f.useCallback(d=>{const p=()=>{const N=ge(r.current,d.id);N&&(N.scrollIntoView({behavior:"smooth",block:"start"}),m(d.id))};a(d.index)?p():window.requestAnimationFrame(()=>window.requestAnimationFrame(p))},[r,a]);return t.length<2?null:e.jsx("nav",{"aria-label":o("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocusCapture:()=>c(!0),onBlurCapture:d=>{d.currentTarget.contains(d.relatedTarget)||c(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:A("flex flex-col items-center gap-2 py-2 transition-opacity",b?"opacity-0":"opacity-100"),"aria-hidden":b,children:t.map(d=>e.jsx("li",{children:e.jsx("span",{className:A("block rounded-full transition-all",d.id===i?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},d.id))}),e.jsx("div",{className:A("absolute right-0 max-h-[min(70vh,520px)] w-[280px] overflow-y-auto rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/95 p-1 shadow-xl backdrop-blur transition-all",b?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((d,p)=>e.jsxs("button",{type:"button",onClick:()=>n(d),className:A("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",d.id===i?"bg-[hsl(var(--deck-hairline))]/70 text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-hairline))]/50 hover:text-[hsl(var(--deck-ink))]"),children:[e.jsx("span",{className:A("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",d.id===i?"bg-[hsl(var(--deck-accent))]":"bg-[hsl(var(--deck-ink-faint))]/40")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-mono text-[9.5px] uppercase tracking-[0.12em] text-[hsl(var(--deck-ink-faint))]",children:o("chat.turns.label",{n:p+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:d.preview})]})]},d.id))})]})})}const ve=80;function rs(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function as(t){const s=rs(t).replace(/\s+/g," ").trim();return s?s.length>ve?`${s.slice(0,ve-1)}…`:s:""}function ns(t){const s=[];for(let r=0;r<t.length;r+=1){const a=t[r];if(a.role!=="user"||!a.id)continue;const o=as(a.content);o&&s.push({id:a.id,index:r,preview:o})}return s}const re=120,ae=80,is=96;function G(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function os({messages:t,isLoading:s}){const r=M(),a=f.useRef(null),o=f.useRef(null),i=f.useRef(!0),m=f.useRef(t.length),b=f.useRef(null),[c,l]=f.useState(re),[v,n]=f.useState(!1);f.useEffect(()=>{const x=G(a.current);if(!x||!i.current)return;const g=window.requestAnimationFrame(()=>{x.scrollTop=x.scrollHeight});return()=>window.cancelAnimationFrame(g)},[t]),f.useEffect(()=>{const x=G(a.current);if(!x)return;o.current=x;const g=()=>{const y=x.scrollHeight-x.scrollTop-x.clientHeight<=is;i.current=y,n(!y)};return g(),x.addEventListener("scroll",g,{passive:!0}),()=>x.removeEventListener("scroll",g)},[]),f.useEffect(()=>{const x=m.current;m.current=t.length,l(g=>g>=x&&t.length>x?t.length:Math.min(Math.max(g,re),t.length||re))},[t.length]);const d=Math.max(t.length-c,0),p=d,j=f.useMemo(()=>t.slice(p),[t,p]),N=f.useMemo(()=>ns(t),[t]);if(f.useLayoutEffect(()=>{var S;const x=b.current;if(!x)return;const g=G(a.current);if(b.current=null,!!g){if((S=x.element)!=null&&S.isConnected){const y=x.element.getBoundingClientRect().top-x.viewportTop;g.scrollTop+=y;return}g.scrollTop=es(x.scrollTop,x.scrollHeight,g.scrollHeight)}},[c]),s)return e.jsx("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex overflow-hidden flex-1 justify-center items-center px-5 py-8 min-h-0",children:e.jsxs("div",{className:"w-full max-w-[560px]",children:[e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 animate-pulse rounded-full bg-[hsl(var(--deck-accent-soft))] blur-xl"}),e.jsx(ne,{size:42,className:"relative"})]}),e.jsxs("div",{className:"mt-4 inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.16em] text-[hsl(var(--deck-accent))]",children:[e.jsx(Ze,{className:"w-3 h-3"}),r("chat.list.loading.eyebrow")]}),e.jsx("h2",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:r("chat.list.loading.title")}),e.jsx("p",{className:"mt-1 max-w-sm text-[11.5px] leading-5 text-[hsl(var(--deck-ink-faint))]",children:r("chat.list.loading.hint")})]}),e.jsx("div",{"aria-hidden":"true",className:"mt-7 space-y-4 rounded-xl border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))]/45 px-4 py-5",children:[72,88,64].map((x,g)=>e.jsxs("div",{className:A("flex gap-3",g%2===1&&"flex-row-reverse"),children:[e.jsx("span",{className:"h-7 w-7 shrink-0 animate-pulse rounded-md bg-[hsl(var(--deck-surface-2))]"}),e.jsx("span",{className:"h-10 animate-pulse rounded-lg bg-[hsl(var(--deck-surface-2))]",style:{width:`${x}%`,animationDelay:`${g*120}ms`}})]},x))})]})});if(t.length===0&&!s)return e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsxs("div",{className:"flex flex-col gap-4 items-center text-center",children:[e.jsx(ne,{size:44}),e.jsxs("div",{children:[e.jsx("div",{className:"deck-eyebrow text-[hsl(var(--deck-accent))]",children:r("chat.list.empty.eyebrow")}),e.jsx("div",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:r("chat.list.empty.title")}),e.jsx("div",{className:"mt-1 max-w-xs text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r("chat.list.empty.hint")})]})]})});const h=()=>{const x=G(a.current);x&&(i.current=!0,n(!1),x.scrollTo({top:x.scrollHeight,behavior:"smooth"}))},C=()=>{var g;const x=G(a.current);if(x){const S=((g=a.current)==null?void 0:g.querySelector("[data-chat-message-id]"))??null;b.current={element:S,viewportTop:(S==null?void 0:S.getBoundingClientRect().top)??0,scrollHeight:x.scrollHeight,scrollTop:x.scrollTop}}l(S=>ts(S,t.length,ae))},u=x=>x>=p?!0:(l(t.length),!1);return e.jsxs("div",{ref:a,className:"relative flex-1 min-h-0",children:[e.jsx(Ve,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[d>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:C,"aria-label":r("chat.list.showEarlierWithRemaining",{count:Math.min(d,ae),remaining:d}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:r("chat.list.showEarlier",{count:Math.min(d,ae)})})}),j.map((x,g)=>{const S=p+g,y=S>0?t[S-1]:null,P=!y||y.role!==x.role||y.role==="user";return e.jsx(Zt,{message:x,showAvatar:P},x.id||`msg-${S}`)})]})}),e.jsx(ss,{turns:N,viewportRef:o,containerRef:a,onRevealTurn:u}),v&&e.jsxs("button",{type:"button",onClick:h,className:"absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-[hsl(var(--deck-border-strong))] bg-[hsl(var(--deck-surface))]/95 px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] shadow-lg backdrop-blur transition-colors hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[e.jsx(Te,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),r("chat.list.jumpLatest")]})]})}const ls=f.memo(os),Re=bt,Ie=gt,Be=vt,ue=f.forwardRef(({className:t,sideOffset:s=4,...r},a)=>e.jsx(Me,{ref:a,sideOffset:s,className:A("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...r}));ue.displayName=Me.displayName;const cs={active:{labelKey:"goal.status.active",dot:"bg-[hsl(var(--deck-accent))] shadow-[0_0_6px_hsl(var(--deck-accent-glow)/0.5)]",accent:"text-[hsl(var(--deck-accent))]"},verifying:{labelKey:"goal.status.active",dot:"animate-pulse bg-sky-400",accent:"text-sky-600 dark:text-sky-300"},paused:{labelKey:"goal.status.paused",dot:"bg-amber-400",accent:"text-amber-600 dark:text-amber-300"},blocked:{labelKey:"goal.status.blocked",dot:"bg-rose-500",accent:"text-rose-600 dark:text-rose-300"},usage_limited:{labelKey:"goal.status.usageLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},budget_limited:{labelKey:"goal.status.budgetLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},complete:{labelKey:"goal.status.complete",dot:"bg-emerald-500",accent:"text-emerald-600 dark:text-emerald-300"}};function J(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function ds(t){if(t<60)return`${t}s`;const s=Math.floor(t/60),r=t%60;return r===0?`${s}m`:`${s}m ${r}s`}function us(){var V;const t=M(),{locale:s}=Le(),r=w(E=>E.goal),a=w(E=>E.pauseGoal),o=w(E=>E.resumeGoal),i=w(E=>E.editGoal),m=w(E=>E.clearGoal),[b,c]=f.useState(!1),[l,v]=f.useState(!1),[n,d]=f.useState(""),[p,j]=f.useState(null),[N,h]=f.useState(!1);if(f.useEffect(()=>{c(!1),v(!1),d((r==null?void 0:r.objective)??""),h(!1)},[r==null?void 0:r.goalId]),!r)return null;const C=cs[r.status],u=["active","verifying","paused","blocked"].includes(r.status),x=r.status==="active"||r.status==="verifying",g=r.status==="paused"||r.status==="blocked",S=p!==null,y=async(E,I)=>{j(E);try{await I()}finally{j(null)}},P=()=>{d(r.objective),v(!0),c(!0)},R=async E=>{E.preventDefault();const I=n.trim();if(!I||I===r.objective){v(!1);return}await y("edit",()=>i(I)),v(!1)},O=async()=>{await y("delete",m),h(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(Re,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0",children:[e.jsxs("div",{className:A("flex h-9 items-center gap-2 rounded-lg border px-3 transition-colors","border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 backdrop-blur-sm",b&&"rounded-b-none border-b-0"),children:[r.status==="complete"?e.jsx(et,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(tt,{className:A("h-3.5 w-3.5 shrink-0",C.accent)}),e.jsx("span",{className:A("h-1.5 w-1.5 shrink-0 rounded-full",C.dot)}),e.jsx("span",{className:A("shrink-0 text-[10px] font-medium leading-none",C.accent),children:r.status==="verifying"?s==="zh"?"验证中":"Verifying":t(C.labelKey)}),e.jsx("span",{className:"h-3 w-px shrink-0 bg-[hsl(var(--deck-hairline))]"}),e.jsx("button",{type:"button","aria-label":t(b?"goal.action.collapse":"goal.action.expand"),className:"min-w-0 flex-1 truncate text-left text-[12px] leading-5 text-[hsl(var(--deck-ink))]/85 outline-none transition-colors hover:text-[hsl(var(--deck-ink))]",onClick:()=>c(E=>!E),"aria-expanded":b,title:r.objective,children:r.objective}),r.tokensUsed>0&&e.jsxs("span",{className:"hidden shrink-0 text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))] sm:inline",children:[J(r.tokensUsed),r.tokenBudget!==void 0&&`/${J(r.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[x&&e.jsx(Q,{label:t("goal.action.pause"),disabled:S,onClick:()=>void y("pause",a),children:p==="pause"?e.jsx(F,{className:"animate-spin"}):e.jsx(st,{})}),g&&e.jsx(Q,{label:t("goal.action.resume"),disabled:S,onClick:()=>void y("resume",o),children:p==="resume"?e.jsx(F,{className:"animate-spin"}):e.jsx(rt,{})}),e.jsx(Q,{label:t(u?"goal.action.edit":"goal.action.expand"),disabled:!u&&!b,onClick:u?P:()=>c(E=>!E),children:u?e.jsx(Ae,{}):e.jsx(at,{})}),e.jsx(Q,{label:t("goal.action.delete"),disabled:S,destructive:!0,onClick:()=>h(!0),children:e.jsx(Y,{})})]})]}),b&&e.jsx("div",{className:"rounded-b-lg border border-t-0 border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 px-4 py-3 backdrop-blur-sm",children:l?e.jsxs("form",{onSubmit:R,children:[e.jsx("textarea",{id:"goal-objective",value:n,onChange:E=>d(E.target.value),onKeyDown:E=>{E.key==="Escape"&&v(!1)},rows:3,autoFocus:!0,className:"w-full resize-none rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-3 py-2 text-[12px] leading-5 text-[hsl(var(--deck-ink))] outline-none transition-shadow focus:border-[hsl(var(--deck-accent))] focus:ring-1 focus:ring-[hsl(var(--deck-accent-glow))]"}),e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>v(!1),className:"inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-hairline))]/60",children:[e.jsx(nt,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!n.trim()||p==="edit",className:"inline-flex h-7 items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2.5 text-[11px] font-medium text-white transition-colors hover:bg-[hsl(var(--deck-accent))]/90 disabled:cursor-not-allowed disabled:opacity-50",children:[p==="edit"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(Z,{className:"h-3 w-3"}),t("goal.action.save")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink))]/90",children:r.objective}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(it,{className:"h-3 w-3"}),J(r.tokensUsed),r.tokenBudget!==void 0&&` / ${J(r.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ot,{className:"h-3 w-3"}),ds(r.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(le,{className:"h-3 w-3"}),r.continuationCount===1?t("goal.metrics.continuationOne",{n:r.continuationCount}):t("goal.metrics.continuationMany",{n:r.continuationCount})]})]}),r.completionVerification&&e.jsxs("div",{"data-goal-verification":r.completionVerification.status,className:"mt-2 rounded-md border border-sky-200/50 bg-sky-50/60 px-2.5 py-2 text-[11px] text-sky-900 dark:border-sky-400/15 dark:bg-sky-400/[0.05] dark:text-sky-100",children:[e.jsxs("p",{className:"font-mono font-medium",children:["#",r.completionVerification.attempt," ·"," ",r.completionVerification.status.toUpperCase()," ·"," ",((V=r.completionVerification.verifierSessionId)==null?void 0:V.slice(0,12))??"-"]}),r.completionVerification.summary&&e.jsx("p",{className:"mt-1 line-clamp-3 whitespace-pre-wrap opacity-80",children:r.completionVerification.summary}),r.completionVerification.evidenceSha256&&e.jsxs("p",{className:"mt-1 font-mono text-[10px] opacity-60",children:["sha256:",r.completionVerification.evidenceSha256.slice(0,12)]})]}),r.statusReason&&e.jsx("div",{className:"mt-2 rounded-md border border-amber-200/50 bg-amber-50/60 px-2.5 py-1.5 text-[11px] text-amber-800 dark:border-amber-400/15 dark:bg-amber-400/[0.05] dark:text-amber-200",children:r.statusReason})]})})]})}),e.jsx(ye,{open:N,onOpenChange:h,children:e.jsxs(we,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(Ne,{children:t("goal.dialog.title")}),e.jsx(Se,{children:t("goal.dialog.description")}),e.jsxs(Ce,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>h(!1),className:"inline-flex h-8 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] px-3 text-[12px] text-[hsl(var(--deck-ink))] hover:bg-[hsl(var(--deck-hairline))]/60",children:t("goal.action.cancel")}),e.jsxs("button",{type:"button",disabled:p==="delete",onClick:()=>void O(),className:"inline-flex gap-1.5 justify-center items-center px-3 h-8 text-[12px] font-medium text-white bg-rose-600 rounded-md hover:bg-rose-500 disabled:opacity-50",children:[p==="delete"&&e.jsx(F,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function Q({label:t,children:s,disabled:r,destructive:a,onClick:o}){return e.jsxs(Ie,{children:[e.jsx(Be,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:r,onClick:o,className:A("flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-muted))] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent-glow))]/50 disabled:cursor-not-allowed disabled:opacity-35 [&_svg]:h-3.5 [&_svg]:w-3.5",a?"hover:bg-rose-500/10 hover:text-rose-500":"hover:bg-[hsl(var(--deck-hairline))]/60 hover:text-[hsl(var(--deck-ink))]"),children:s})}),e.jsx(ue,{side:"top",className:"text-[10px]",children:t})]})}function ms(){const t=M(),s=w(c=>c.currentSessionRef),r=w(c=>c.sessions),a=w(c=>c.messages),o=f.useMemo(()=>{var l,v,n,d,p;const c=s?(l=Oe(r,s))==null?void 0:l.pendingInteraction:void 0;if(c)return c.type;for(let j=a.length-1;j>=0;j-=1){const N=(v=a[j])==null?void 0:v.agentContent;if(((n=N==null?void 0:N.confirmation)==null?void 0:n.status)==="pending")return"permission";if(((d=N==null?void 0:N.question)==null?void 0:d.status)==="pending")return"question";if(((p=N==null?void 0:N.elicitation)==null?void 0:p.status)==="pending")return"elicitation"}return null},[s,a,r]);if(!o)return null;const i=()=>{const c=document.querySelector(`[data-pending-interaction="${o}"]`);c==null||c.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>c==null?void 0:c.focus(),250)},m=o==="question",b=o==="elicitation";return e.jsxs("div",{role:"alert",className:"mx-3 mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-amber-300/80 bg-amber-50/95 px-3 py-2 font-mono text-amber-950 shadow-sm backdrop-blur dark:border-amber-800/80 dark:bg-amber-950/90 dark:text-amber-100 sm:mx-5",children:[e.jsx(Fe,{className:"h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-[180px] flex-1",children:[e.jsx("div",{className:"text-[11.5px] font-semibold",children:t(m?"interaction.bar.questionTitle":b?"interaction.bar.elicitationTitle":"interaction.bar.permissionTitle")}),e.jsx("div",{className:"mt-0.5 text-[10px] leading-4 text-amber-800 dark:text-amber-300",children:t(m?"interaction.bar.questionHint":b?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:i,className:"inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-400/80 bg-white/80 px-2.5 text-[10.5px] font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/70 dark:hover:bg-amber-900",children:[e.jsx(Te,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}const xs={running:"status.phase.running",compacting:"status.phase.compacting",recovering_context:"status.phase.recoveringContext",switching_model:"status.phase.switchingModel",waiting_permission:"status.phase.waitingPermission",error:"status.phase.error",idle:""},ke=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString();function hs(){const t=M(),s=w(d=>d.tokenUsage),r=w(d=>d.isStreaming),a=w(d=>d.agentPhase),o=w(d=>d.providerRetry),i=w(d=>d.providerStall),m=xs[a]??"",b=(o==null?void 0:o.delayMs)!==void 0?` · ${Math.max(0,Math.ceil(o.delayMs/1e3))}s`:"",c=i?`${t("status.phase.providerStall")} · ${Math.ceil(i.durationMs/1e3)}s / ${Math.ceil(i.timeoutMs/1e3)}s`:o?`Provider · ${t("chat.error.action.retryingTask")} · ${o.attempt}/${o.maxRetries}${b}`:m?t(m):"",l=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,v=Math.min(l,100),n=l>95?"danger":l>80?"warn":"safe";return e.jsxs("div",{className:"flex items-center gap-4 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/70 px-5 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm",children:[e.jsxs("div",{className:"flex gap-3 items-center",children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.context")}),e.jsxs("span",{className:"flex gap-1 items-baseline tabular-nums",children:[e.jsx("span",{className:A("text-[12px] font-medium",n==="safe"&&"text-[hsl(var(--deck-ink))]",n==="warn"&&"text-amber-600 dark:text-amber-400",n==="danger"&&"text-red-600 dark:text-red-400"),children:ke(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",ke(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(Re,{children:e.jsxs(Ie,{children:[e.jsx(Be,{asChild:!0,children:e.jsx(lt,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(ue,{side:"top",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:t("status.tokenLimitTooltip")})})]})}),e.jsxs("div",{className:"relative h-2 w-32 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]","aria-hidden":"true",children:[e.jsx("div",{className:A("absolute inset-y-0 left-0 transition-[width] duration-300",n==="safe"&&"bg-[hsl(var(--deck-accent))]",n==="warn"&&"bg-amber-500",n==="danger"&&"bg-red-500"),style:{width:`${v}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(d=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${d}%`}},d))})]}),e.jsxs("span",{className:A("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",n==="warn"&&"text-amber-600 dark:text-amber-400",n==="danger"&&"text-red-600 dark:text-red-400"),children:[l,"%"]})]}),e.jsx("div",{className:"flex-1"}),r&&c&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"text-[hsl(var(--deck-accent))]",children:c})]})]})}function ps(t){const s=[...t].reverse().find(o=>o.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const r=s.content.filter(o=>o.type==="text").map(o=>o.text).join(`
|
|
7
|
-
`),a=s.content.filter(o=>o.type==="image_url").map((o,i)=>{var b;const m=((b=o.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:b[1])??"application/octet-stream";return{id:`recovery-${s.id}-${i}`,name:`attachment-${i+1}`,mimeType:m,dataUrl:o.image_url.url}});return{content:r,attachments:a}}function js(){var me;const t=M(),s=w(k=>k.messages),r=w(k=>k.currentSessionRef),a=w(k=>k.isStreaming),o=w(k=>k.isStopping),i=w(k=>k.sessionEventConnectionState),m=w(k=>k.pendingSteeringCount),b=w(k=>k.pendingInputDelivery),c=w(k=>k.recoveredSteeringCount),l=w(k=>k.isLoading),v=w(k=>k.error),n=w(k=>k.errorContext),d=w(k=>k.sessions),p=w(k=>k.sendMessage),j=w(k=>k.abortSession),N=w(k=>k.retryTask),h=w(k=>k.retryingTaskKeys),C=ie(k=>k.openSettings),u=w(k=>k.reconnectSessionEvents),x=w(k=>k.clearError),[g,S]=f.useState(null),y=r?d.find(k=>k.sessionId===r.sessionId&&k.projectPath===r.projectPath):void 0,P=!!v&&((n==null?void 0:n.kind)==="navigation"||!(n!=null&&n.sessionRef)||je(n.sessionRef,r)),R=(n==null?void 0:n.failureCode)??((me=y==null?void 0:y.taskFailure)==null?void 0:me.code),O=(n==null?void 0:n.kind)==="execution"&&R?t(pt(R)):v==="queue_full"?t("chat.error.queueFull"):v==="turn_unavailable"||v==="turn_active"?t("chat.error.turnChanged"):v,V=i==="connecting"||i==="reconnecting",E=a&&i!=="connected",I=r?`session:${W(r)}`:"session:temporary",K=f.useMemo(()=>ps(s),[s]),T=r?W(r):"temporary-session",_=!!(r&&(y!=null&&y.taskRetryAvailable)&&(!R||ft(R)))&&((n==null?void 0:n.kind)==="execution"||(n==null?void 0:n.kind)==="task_action"),L=(n==null?void 0:n.kind)==="execution"&&(R==="authentication"||R==="permission"||R==="model_unavailable"),B=r?h.includes(W(r)):!1;f.useEffect(()=>{S(null)},[T]);const $=async k=>p({content:k.content,modelId:k.modelId,reasoningEffort:k.reasoningEffort,serviceTier:k.serviceTier,responseVerbosity:k.responseVerbosity,communicationStyle:k.communicationStyle,...k.outputSchema?{outputSchema:k.outputSchema}:{},attachments:k.attachments.map(se=>({type:"image",content:se.dataUrl,mimeType:se.mimeType,name:se.name}))}),D=()=>j(),U=async()=>{if(L){x(),C("models");return}if(_&&r){x(),await N(r).catch(()=>{});return}if((n==null?void 0:n.kind)==="execution"&&K){S({...K,revision:Date.now()}),x();return}x(),requestAnimationFrame(()=>He())},z=_?t(B?"chat.error.action.retryingTask":"chat.error.action.retryTask"):L?t("chat.error.action.checkModels"):(n==null?void 0:n.kind)==="execution"&&K?t("chat.error.action.editResend"):(n==null?void 0:n.kind)==="submission"?t("chat.error.action.returnDraft"):null;return e.jsxs("div",{className:"flex h-full flex-col bg-[hsl(var(--deck-canvas))]",children:[P&&e.jsxs("div",{role:"alert",className:"flex min-h-11 flex-wrap items-center gap-2 border-b border-red-200/60 bg-red-50/80 px-4 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300 sm:px-5",children:[e.jsx(Fe,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 break-words",children:[e.jsx("span",{className:"font-semibold",children:t((n==null?void 0:n.kind)==="submission"?"chat.error.title.submission":(n==null?void 0:n.kind)==="execution"?"chat.error.title.execution":(n==null?void 0:n.kind)==="navigation"?"chat.error.title.navigation":"chat.error.title.generic")})," ",O]}),z&&e.jsxs("button",{type:"button",onClick:()=>void U(),disabled:B,className:"inline-flex min-h-7 shrink-0 items-center gap-1.5 rounded-md border border-red-300/70 bg-white/65 px-2.5 font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60 dark:border-red-800 dark:bg-red-950/45 dark:hover:bg-red-900/60",children:[_?B?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(le,{className:"h-3 w-3"}):e.jsx(Ae,{className:"h-3 w-3"}),z]}),e.jsx("button",{type:"button",onClick:x,"aria-label":t("chat.error.dismiss"),className:"p-1 text-red-500 rounded transition-colors hover:bg-red-100/60 hover:text-red-700 dark:hover:bg-red-950/60 dark:hover:text-red-100",children:"✕"})]}),(V||i==="offline")&&e.jsxs("div",{role:i==="offline"?"alert":"status","aria-live":"polite",className:"flex min-h-10 flex-wrap items-center gap-2 border-b border-amber-300/60 bg-amber-50/80 px-4 py-2 font-mono text-[11px] text-amber-900 dark:border-amber-800/60 dark:bg-amber-950/35 dark:text-amber-200 sm:px-5",children:[V?e.jsx(F,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(ct,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:t(V?"chat.connection.reconnecting":"chat.connection.offline")}),i==="offline"&&e.jsxs("button",{type:"button",onClick:()=>void u().catch(()=>{}),className:"inline-flex min-h-7 items-center gap-1.5 rounded-md border border-amber-400/70 bg-white/60 px-2.5 font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/50 dark:hover:bg-amber-900/50",children:[e.jsx(dt,{className:"h-3 w-3"}),t("chat.connection.retry")]})]}),e.jsx(kt,{}),e.jsx(ls,{messages:s,isLoading:l},r?W(r):"temporary-session"),e.jsx(ms,{}),e.jsx(us,{}),e.jsx(Ue,{draftKey:I,draft:g==null?void 0:g.content,draftAttachments:g==null?void 0:g.attachments,draftRevision:g==null?void 0:g.revision,onSend:$,onAbort:D,disabled:l||E,isStreaming:a,isStopping:o,pendingSteeringCount:m,pendingInputDelivery:b,recoveredSteeringCount:c,workspacePath:r==null?void 0:r.projectPath},I),e.jsx(hs,{})]})}export{js as ChatView};
|