blade-code 0.10.8 → 0.10.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/blade.js +3 -3
  2. package/dist/{chunk-nymm525r.js → chunk-095x2ykj.js} +1 -1
  3. package/dist/{chunk-wmnszjmv.js → chunk-2mzcxq6c.js} +2 -2
  4. package/dist/{chunk-66hb7kxm.js → chunk-363pgv1e.js} +2 -2
  5. package/dist/chunk-3aqdjrtm.js +2 -0
  6. package/dist/chunk-3n4m3pcy.js +1 -0
  7. package/dist/{chunk-d0g4t8fw.js → chunk-3v0ay0sf.js} +1 -1
  8. package/dist/{chunk-8gnfj89a.js → chunk-4dq9y7zn.js} +2 -2
  9. package/dist/chunk-4zs5r4n4.js +1 -0
  10. package/dist/{chunk-kagpk2x5.js → chunk-576pdgtm.js} +2 -2
  11. package/dist/{chunk-y4c3wwpa.js → chunk-5s123nbs.js} +1 -1
  12. package/dist/chunk-632rgzcf.js +2 -0
  13. package/dist/{chunk-a8h3fymk.js → chunk-6kwv8ph0.js} +2 -2
  14. package/dist/{chunk-m2xrx1je.js → chunk-732n8xj6.js} +2 -2
  15. package/dist/{chunk-8gcvpmwk.js → chunk-74shfpve.js} +1 -1
  16. package/dist/chunk-7hjjjkj0.js +1 -0
  17. package/dist/chunk-7mhkm3x7.js +6 -0
  18. package/dist/{chunk-cbpqcdga.js → chunk-7wjy6kgt.js} +1 -1
  19. package/dist/{chunk-eq2qj9ja.js → chunk-8j01ssaf.js} +1 -1
  20. package/dist/chunk-9cnm1hgp.js +1 -0
  21. package/dist/chunk-9e5z64ap.js +1 -0
  22. package/dist/chunk-9tnaads5.js +2 -0
  23. package/dist/{chunk-33ave20b.js → chunk-afkhzdfc.js} +1 -1
  24. package/dist/{chunk-b5szbtmp.js → chunk-ah97bmns.js} +2 -2
  25. package/dist/chunk-b6gknm33.js +1 -0
  26. package/dist/chunk-bxp1w7sh.js +200 -0
  27. package/dist/chunk-c7201g75.js +3 -0
  28. package/dist/{chunk-7zsyejr1.js → chunk-cfwnbrrd.js} +12 -12
  29. package/dist/{chunk-yfs9tq3y.js → chunk-d600wn06.js} +2 -2
  30. package/dist/{chunk-4h9ff923.js → chunk-dpt56hah.js} +1 -1
  31. package/dist/{chunk-fj8v7pep.js → chunk-dsj62dcg.js} +1 -1
  32. package/dist/{chunk-h421wzbm.js → chunk-egmwj6xg.js} +2 -2
  33. package/dist/{chunk-s9aj3p11.js → chunk-epek6vr2.js} +1 -1
  34. package/dist/chunk-f4z3gkbs.js +2 -0
  35. package/dist/chunk-fvrmjhz5.js +1 -0
  36. package/dist/chunk-fvy56ajf.js +1 -0
  37. package/dist/{chunk-954vmnrn.js → chunk-g11hq0e5.js} +1 -1
  38. package/dist/{chunk-8h0yxh6y.js → chunk-g1qpzyt3.js} +1 -1
  39. package/dist/{chunk-w0nscjd2.js → chunk-gav4hxcv.js} +2 -2
  40. package/dist/{chunk-van4ysq6.js → chunk-ggq4y248.js} +300 -279
  41. package/dist/{chunk-vgp8m9fg.js → chunk-gvc0qqk4.js} +2 -2
  42. package/dist/{chunk-vsg8f0e6.js → chunk-heqs3xan.js} +1 -1
  43. package/dist/chunk-hetayg68.js +10 -0
  44. package/dist/{chunk-cf8e7e92.js → chunk-hfv5gcqj.js} +54 -20
  45. package/dist/chunk-hveqdgt6.js +1 -0
  46. package/dist/chunk-hxp5qs1x.js +1 -0
  47. package/dist/{chunk-2thg3fq1.js → chunk-j42jswx0.js} +1 -1
  48. package/dist/chunk-jw8gb53m.js +1 -0
  49. package/dist/{chunk-xmcsn7y0.js → chunk-ktf3bpmw.js} +2 -2
  50. package/dist/chunk-kvx3sb3z.js +2 -0
  51. package/dist/{chunk-rxqft6td.js → chunk-mhne9y2k.js} +2 -2
  52. package/dist/{chunk-fxpq9nh6.js → chunk-mtk2tf9n.js} +1 -1
  53. package/dist/chunk-nmmj1x0c.js +1 -0
  54. package/dist/chunk-p4zt7ts9.js +2 -0
  55. package/dist/chunk-r76wc1cn.js +2 -0
  56. package/dist/chunk-rhw2zkq8.js +6 -0
  57. package/dist/{chunk-v8pq6qmv.js → chunk-s5666ta0.js} +2 -2
  58. package/dist/{chunk-zvk3g177.js → chunk-t9aggrv8.js} +1 -1
  59. package/dist/chunk-tkqrhxqr.js +1 -0
  60. package/dist/chunk-ttncpgr6.js +1 -0
  61. package/dist/{chunk-nhc49pan.js → chunk-vdj00rsv.js} +2 -2
  62. package/dist/{chunk-7hbw6q6d.js → chunk-vmq248m7.js} +1 -1
  63. package/dist/chunk-wnqybbry.js +2 -0
  64. package/dist/{chunk-r7tsa2zv.js → chunk-xx1d9kfd.js} +1 -1
  65. package/dist/{chunk-8gcg2z3y.js → chunk-y56s2qww.js} +2 -2
  66. package/dist/{chunk-h28ptrrt.js → chunk-ybvdac8k.js} +1 -1
  67. package/dist/chunk-z5zcwwfm.js +1 -0
  68. package/dist/{chunk-pv9sw79c.js → chunk-z8c5rhdh.js} +2 -2
  69. package/dist/{chunk-j4tttsaz.js → chunk-zepqp80m.js} +2 -2
  70. package/dist/{chunk-g00wj2we.js → chunk-zf183j2y.js} +1 -1
  71. package/dist/{chunk-xa05phpw.js → chunk-zyf1r2j3.js} +3 -3
  72. package/dist/web/assets/ChatView-DdX4BvAo.js +7 -0
  73. package/dist/web/assets/{CodeBlockHighlighter-EgdsVoMQ.js → CodeBlockHighlighter-DBw81YZa.js} +1 -1
  74. package/dist/web/assets/{FilePreview-xicd9-Sl.js → FilePreview-Di-mSDMs.js} +2 -2
  75. package/dist/web/assets/{MarkdownRenderer-DBSjC_z3.js → MarkdownRenderer-CxSfwebU.js} +3 -3
  76. package/dist/web/assets/SettingsModal-CoBMb8of.js +5 -0
  77. package/dist/web/assets/{TaskSwitcher-DXcj0iJ_.js → TaskSwitcher-BmS-DA4i.js} +1 -1
  78. package/dist/web/assets/{TerminalPanel-DWVY-Elm.js → TerminalPanel-BPruynbV.js} +1 -1
  79. package/dist/web/assets/index-BC7ygRH_.css +1 -0
  80. package/dist/web/assets/index-Bx7HzeXs.js +32 -0
  81. package/dist/web/assets/{vendor-icons-Cv18Q6rW.js → vendor-icons-ICv1v-tf.js} +71 -66
  82. package/dist/web/index.html +3 -3
  83. package/package.json +1 -1
  84. package/dist/chunk-1w6azndv.js +0 -1
  85. package/dist/chunk-2gwaqpge.js +0 -1
  86. package/dist/chunk-2pjd4cys.js +0 -1
  87. package/dist/chunk-2zn5en0w.js +0 -1
  88. package/dist/chunk-3w1z6fwm.js +0 -1
  89. package/dist/chunk-43x4qbvt.js +0 -1
  90. package/dist/chunk-52csdk21.js +0 -3
  91. package/dist/chunk-6j8wgp2s.js +0 -2
  92. package/dist/chunk-6vsszvgg.js +0 -2
  93. package/dist/chunk-7evtr0yr.js +0 -10
  94. package/dist/chunk-8sfycn3y.js +0 -194
  95. package/dist/chunk-bxm2hq0m.js +0 -1
  96. package/dist/chunk-c8da4b3d.js +0 -1
  97. package/dist/chunk-kvnwhwx3.js +0 -1
  98. package/dist/chunk-nz57y1ad.js +0 -6
  99. package/dist/chunk-p2m56new.js +0 -2
  100. package/dist/chunk-qgp08qmz.js +0 -6
  101. package/dist/chunk-rkvfsx8e.js +0 -2
  102. package/dist/chunk-senkwdh6.js +0 -2
  103. package/dist/chunk-v1c58sm6.js +0 -1
  104. package/dist/chunk-w26jhcj9.js +0 -1
  105. package/dist/chunk-x6wgh726.js +0 -1
  106. package/dist/chunk-ymzcxryf.js +0 -1
  107. package/dist/chunk-zknv3d6y.js +0 -2
  108. package/dist/chunk-zp4x2mwj.js +0 -1
  109. package/dist/web/assets/ChatView-Fqy97qw9.js +0 -7
  110. package/dist/web/assets/SettingsModal-Bkh5rMAJ.js +0 -5
  111. package/dist/web/assets/index-Bi5ijAQP.css +0 -1
  112. package/dist/web/assets/index-CxEh32hc.js +0 -32
@@ -0,0 +1,7 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-CxSfwebU.js","assets/index-Bx7HzeXs.js","assets/vendor-react-DG5dkZ_t.js","assets/vendor-radix-DXRuAJHH.js","assets/vendor-icons-ICv1v-tf.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 D,a as y,b as ie,s as ye,c as Pe,d as W,D as we,e as Ne,f as _e,g as Se,h as Ce,i as Ee,j as A,k as O,l as Ve,B as ne,m as Le,n as Oe,o as Ue,_ as He,S as Ke,p as qe,q as ze,t as Ge,r as We,C as Je,v as Qe}from"./index-Bx7HzeXs.js";import{Q as he,O as Ye,G as Xe,Y as Ze,L as F,z as et,T as Y,C as Z,Z as tt,v as st,_ as rt,B as at,$ as Te,y as ee,m as oe,R as le,s as nt,H as it,a0 as Ae,U as ot,a1 as lt,a2 as ct,a3 as dt,P as Fe,a4 as ut,X as mt,a5 as xt,a6 as ht,f as De,a7 as pt,W as ft,a as bt}from"./vendor-icons-ICv1v-tf.js";import{j as gt,k as vt,l as kt,m as Re}from"./vendor-radix-DXRuAJHH.js";function pe(t){return t.split("/").filter(Boolean).at(-1)||t}function jt(){const t=D(),s=y(w=>w.sessions),r=y(w=>w.currentSessionRef),a=y(w=>w.taskDeliveryActions),c=y(w=>w.deliverTask),n=ie(w=>w.openFilePreview),[u,b]=f.useState(!1),l=s.find(w=>ye({sessionId:w.sessionId,projectPath:w.projectPath},r));if(!(l!=null&&l.taskIsolation))return null;const o=l.taskDiffStat,v=l.taskIsolation==="worktree",i=Pe(l),p=a[W(i)],h=l.taskDelivery,k=(h==null?void 0:h.status)==="conflicted",N=!!(o&&(o.changedFiles>0||o.commits>0)),x=!["queued","running"].includes(l.taskStatus),C=(h==null?void 0:h.status)==="applied"||(h==null?void 0:h.status)==="discarded",d=v&&N&&x&&!C,m=o?o.additions+o.deletions:0,j=m>0&&o?o.additions/m*100:0,S=w=>{c(i,w).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(he,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:pe(l.taskSourceProjectPath||l.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(Ye,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(he,{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")})]}),l.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:l.taskWorktreeBranch,children:[e.jsx(Xe,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:l.taskWorktreeBranch})]})]})]}),o&&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(Ze,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:o.changedFiles})]}),m>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:`${j}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-j}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",o.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",o.deletions]}),o.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:o.commits})}),N&&(h==null?void 0:h.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:()=>n({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")}),d&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!p,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:[p==="apply"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(et,{className:"h-3 w-3"}),t(p==="apply"?"artifact.applying":k?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!p,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:p==="discard"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(Y,{className:"h-3 w-3"})})]}),(h==null?void 0:h.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")]}),(h==null?void 0:h.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")]})]}),(h==null?void 0:h.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(tt,{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:h.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(we,{open:u,onOpenChange:b,children:e.jsxs(Ne,{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(_e,{children:[e.jsx(Se,{children:t("artifact.discardDialog.title")}),e.jsx(Ce,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:pe(l.taskSourceProjectPath||l.projectPath),count:(o==null?void 0:o.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(Ee,{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 yt=new Set(["completed","stale","failed","aborted","interrupted"]),wt={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"},Nt={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 St(t){const s=X(t),r=X(s==null?void 0:s.codeLocation),a=s==null?void 0:s.priority,c=s==null?void 0:s.confidenceScore,n=r==null?void 0:r.lineStart,u=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 c!="number"||!Number.isFinite(c)||typeof(r==null?void 0:r.path)!="string"||!Number.isInteger(n)||!Number.isInteger(u)))return{title:s.title,body:s.body,priority:a,confidenceScore:c,codeLocation:{path:r.path,lineStart:n,lineEnd:u}}}function Ct(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"||!yt.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(St);if(!a.some(c=>c===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 Et(t){const{path:s,lineStart:r,lineEnd:a}=t.codeLocation;return r===a?`${s}:L${r}`:`${s}:L${r}-${a}`}function Tt({report:t}){const s=D(),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",Nt[t.status]),children:[s("chat.review.status"),": ",s(wt[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,c)=>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:Et(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}:${c}`))})]}),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 At({elicitation:t,messageId:s}){const r=D(),a=y(d=>d.currentSessionRef),c=y(d=>d.setElicitation),[n,u]=f.useState(()=>Dt(t.details.fields??[])),[b,l]=f.useState(()=>Rt(t.details.fields??[])),[o,v]=f.useState(!1),[i,p]=f.useState(),h=t.details.fields??[],k=f.useMemo(()=>h.every(d=>{var j;if(!d.required)return!0;if(te(d))return!!((j=b[d.name])!=null&&j.trim()||d.defaultValue!==void 0);const m=n[d.name]??d.defaultValue;return Array.isArray(m)?m.length>0:m!==void 0}),[h,b,n]);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(d,m)=>{if(!(!a||o)){v(!0),p(void 0);try{await O.respondToElicitation(a,t.toolCallId,{action:d,...m?{content:m}:{}}),c(s,{...t,status:"responded"})}catch(j){p(j instanceof Error?j.message:r("interaction.elicitation.failed"))}finally{v(!1)}}},x=async()=>{try{await N("accept",Mt(h,n,b))}catch(d){p(d instanceof Error?d.message:String(d))}},C=()=>{const d=t.details.url;if(!d){p("MCP URL is unavailable");return}if(!window.open(d,"_blank","noopener,noreferrer")){p("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(st,{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(H,{onClick:C,disabled:o,primary:!0,label:r("interaction.elicitation.open"),icon:e.jsx(rt,{className:"h-3.5 w-3.5"})}),e.jsx(H,{onClick:()=>void N("decline"),disabled:o,label:r("interaction.elicitation.decline")}),e.jsx(H,{onClick:()=>void N("cancel"),disabled:o,label:r("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[h.map(d=>e.jsx(Ft,{field:d,value:n[d.name],rawValue:b[d.name]??"",onValueChange:m=>u(j=>({...j,[d.name]:m})),onRawChange:m=>l(j=>({...j,[d.name]:m}))},d.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(H,{onClick:()=>void x(),disabled:o||!k,primary:!0,label:r("interaction.elicitation.submit"),icon:o?e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(H,{onClick:()=>void N("decline"),disabled:o,label:r("interaction.elicitation.decline")}),e.jsx(H,{onClick:()=>void N("cancel"),disabled:o,label:r("interaction.elicitation.cancel")})]})]}),i&&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:i})]})}function Ft({field:t,value:s,rawValue:r,onValueChange:a,onRawChange:c}){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:It(t).map(n=>{const u=Array.isArray(s)?s.includes(n.value):s===n.typedValue;return e.jsx("button",{type:"button","aria-pressed":u,onClick:()=>{if(t.type==="multi-select"){const b=Array.isArray(s)?s:[];a(b.includes(n.value)?b.filter(l=>l!==n.value):[...b,n.value])}else a(n.typedValue)},className:A("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",u?"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:n.label},n.value)})}):e.jsx("input",{id:`mcp-elicitation-${t.name}`,type:Bt(t),value:r,onChange:n=>c(n.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 H({onClick:t,disabled:s,primary:r=!1,label:a,icon:c}){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:[c,a]})}function Dt(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 Rt(t){return Object.fromEntries(t.filter(s=>te(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function Mt(t,s,r){var c;const a={};for(const n of t){if(te(n)){const b=((c=r[n.name])==null?void 0:c.trim())??"";if(!b){if(n.defaultValue!==void 0)a[n.name]=n.defaultValue;else if(n.required)throw new Error(`${n.title} is required`);continue}if(n.type==="number"||n.type==="integer"){const l=Number(b);if(!Number.isFinite(l))throw new Error(`${n.title} must be a finite number`);if(n.type==="integer"&&!Number.isSafeInteger(l))throw new Error(`${n.title} must be a safe integer`);a[n.name]=l}else a[n.name]=b;continue}const u=s[n.name]??n.defaultValue;if(u===void 0){if(n.required)throw new Error(`${n.title} is required`);continue}if(Array.isArray(u)){if(n.minItems!==void 0&&u.length<n.minItems)throw new Error(`${n.title} requires at least ${n.minItems} choices`);if(n.maxItems!==void 0&&u.length>n.maxItems)throw new Error(`${n.title} allows at most ${n.maxItems} choices`)}a[n.name]=u}return a}function It(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 Bt(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 $t(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 Pt({report:t}){const s=D(),[r,a]=f.useState(!1),c=JSON.stringify(t.output,null,2),n=async()=>{try{await navigator.clipboard.writeText(c),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(at,{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:n,"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(Te,{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:c})]})}const _t=f.lazy(()=>He(()=>import("./MarkdownRenderer-CxSfwebU.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.MarkdownRenderer})));function fe({text:t,label:s}){const[r,a]=f.useState(!1);if(!t.trim())return null;const c=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:c,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(Te,{className:"h-3.5 w-3.5"})})}function Vt(){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 Lt(){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 be(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 Ot(t){if(typeof t=="string")return{text:be(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:be(s),images:r}}function ce(t){return typeof t=="string"?t:t.filter(s=>s.type==="text").map(s=>s.text).join(`
4
+ `)}function Ut(t){const s=t.agentContent;return s?Ve(s):ce(t.content)}function ge({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(_t,{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 Ht(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 Kt({tool:t}){const[s,r]=f.useState(!1),a=Ht(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(c=>!c),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 Me({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(Kt,{tool:s},s.toolCallId))})}function qt({toolCalls:t,toolCallIds:s}){const r=D(),[a,c]=f.useState(!1),n=f.useMemo(()=>new Map(t.map(i=>[i.toolCallId,i])),[t]),u=s.flatMap(i=>{const p=n.get(i);return p?[p]:[]});if(u.length===0)return null;const b=u.filter(i=>i.status==="running").length,l=u.filter(i=>i.status==="error").length,o=[...u].reverse().find(i=>i.status==="running"&&!!i.progressMessage),v=b>0?r(u.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:u.length}):l>0?r(u.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:u.length,errors:l}):r(u.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:u.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>c(i=>!i),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}),(o==null?void 0:o.progressMessage)&&e.jsxs("span",{className:"min-w-0 truncate text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[o.progressMessage,o.progress!==void 0&&o.progressTotal!==void 0&&` · ${Math.max(0,Math.min(100,Math.round(o.progress/o.progressTotal*100)))}%`]})]}),(o==null?void 0:o.progress)!==void 0&&o.progressTotal!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${o.toolName} progress`,"aria-valuemin":0,"aria-valuemax":o.progressTotal,"aria-valuenow":Math.min(o.progress,o.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,o.progress/o.progressTotal*100))}%`}})}),a&&e.jsx("div",{"data-agent-tool-group-details":!0,className:"mt-2 space-y-2 pl-1",children:e.jsx(Me,{toolCalls:u})})]})}function zt({content:t}){const s=D(),[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(c=>!c),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 Gt({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 Wt({toolCalls:t}){const s=ie(a=>a.openFilePreview),r=f.useMemo(()=>{const a=new Map,c=["Write","SearchReplace","Edit","ApplyPatch"];for(const n of t){if(n.status!=="success")continue;const u=n.metadata;if(n.toolName==="ApplyPatch"&&Array.isArray(u==null?void 0:u.changes)){for(const l of u.changes)l&&typeof l=="object"&&"path"in l&&typeof l.path=="string"&&a.set(l.path,{path:l.path,toolName:n.toolName});continue}const b=u==null?void 0:u.file_path;b&&c.includes(n.toolName)&&a.set(b,{path:b,toolName:n.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 c=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(nt,{className:"w-3 h-3"}),c]},a)})})]})}function Jt({subagent:t}){var $,q;const s=D(),[r,a]=f.useState(null),[c,n]=f.useState(!1),[u,b]=f.useState(null),[l,o]=f.useState(!1),[v,i]=f.useState(""),[p,h]=f.useState(!1),[k,N]=f.useState(null),[x,C]=f.useState(null),d=y(T=>T.currentSessionRef),m=y(T=>T.isStreaming),j=y(T=>T.isTemporarySession);if(!t)return null;const S=t.status==="running",w=r!==null?r:S,R=t.toolCalls||u||[],K=t.output||t.thinking||R.length>0||t.sessionId,M=x&&x.status!=="running"?x.id:t.sessionId,U=!S&&!m&&!j&&(x==null?void 0:x.status)!=="running"&&!!(M&&d);f.useEffect(()=>{if(!w||S||!t.sessionId||!(d!=null&&d.projectPath)||u!==null||t.toolCalls&&t.toolCalls.length>0)return;let T=!0;return n(!0),O.getMessages({sessionId:t.sessionId,projectPath:d.projectPath}).then(V=>{var B,I;if(!T)return;const P=Ue(V),_=new Map;for(const L of P)if((I=(B=L.agentContent)==null?void 0:B.toolCalls)!=null&&I.length)for(const z of L.agentContent.toolCalls)_.has(z.toolCallId)||_.set(z.toolCallId,z);b(Array.from(_.values()))}).finally(()=>{T&&n(!1)}),()=>{T=!1}},[w,S,t.sessionId,t.toolCalls,u,d==null?void 0:d.projectPath]),f.useEffect(()=>{if(!t.sessionId||!d)return;let T=!0;const V=t.rootAgentId??t.sessionId,P=t.resumeDepth??0;return O.listSubagents(d).then(_=>{if(!T)return;const B=_.filter(I=>I.id!==t.sessionId&&I.rootAgentId===V&&I.resumeDepth>P).sort((I,L)=>L.resumeDepth-I.resumeDepth||L.lastActiveAt-I.lastActiveAt)[0];B&&C(B)}).catch(()=>{}),()=>{T=!1}},[d==null?void 0:d.sessionId,d==null?void 0:d.projectPath,t.sessionId,t.rootAgentId,t.resumeDepth]),f.useEffect(()=>{if(!x||x.status!=="running"||!d)return;let T=!0;const V=async()=>{try{const B=(await O.listSubagents(d)).find(I=>I.id===x.id);T&&B&&C(B)}catch{}},P=window.setInterval(()=>{V()},1e3);return()=>{T=!1,window.clearInterval(P)}},[d,x==null?void 0:x.id,x==null?void 0:x.status]);const E=async()=>{if(!(!d||!M||!v.trim()||p)){h(!0),N(null);try{const T=await O.resumeSubagent(d,M,v.trim());C(T.session),i(""),o(!1),a(!0)}catch(T){N(T instanceof Error?T.message:s("chat.subagent.resumeFailed"))}finally{h(!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(!w),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})})]}),K&&e.jsx(ee,{className:A("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",w&&"rotate-180")})]}),w&&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})]}),c&&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")]}),!c&&R.length>0&&e.jsx(Me,{toolCalls:R}),x&&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:x.id,status:x.status,depth:x.resumeDepth??1})}),((($=x.result)==null?void 0:$.message)||((q=x.result)==null?void 0:q.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:x.result.message||x.result.error})]}),U&&e.jsxs("div",{className:"space-y-2",children:[l?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=>i(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:()=>{o(!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()||p,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[p&&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:()=>o(!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")]}),k&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:k})]})]})]})}function Qt({confirmation:t,messageId:s}){const r=D(),[a,c]=f.useState(!1),[n,u]=f.useState(null),b=y(v=>v.currentSessionRef),l=y(v=>v.setConfirmation);if(!t)return null;const o=async(v,i)=>{if(!(!b||a)){c(!0),u(null);try{await O.respondPermission(b,t.toolCallId,{approved:v,scope:i}),l(s,{...t,status:v?"approved":"denied"})}catch(p){u(p instanceof Error?p.message:r("interaction.permission.failed"))}finally{c(!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}),n&&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:n}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void o(!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 o(!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 o(!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 o(!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 Yt({question:t,messageId:s}){const r=D(),[a,c]=f.useState({}),[n,u]=f.useState({}),[b,l]=f.useState(!1),[o,v]=f.useState(null),i=y(x=>x.currentSessionRef),p=y(x=>x.setQuestion),h=f.useMemo(()=>t?t.questions.reduce((x,C)=>{var S;const d=(S=n[C.header])==null?void 0:S.trim(),m=a[C.header];if(C.multiSelect){const w=Array.isArray(m)?[...m]:[];return d&&w.push(d),w.length>0&&(x[C.header]=w),x}const j=d||(typeof m=="string"?m:"");return j&&(x[C.header]=j),x},{}):{},[a,n,t]),k=(t==null?void 0:t.questions.every(x=>x.header in h))??!1;if(!t)return null;const N=async()=>{if(!(!i||b||!k)){l(!0),v(null);try{await O.respondToQuestion(i,t.toolCallId,h),p(s,{...t,status:"answered",answers:h})}catch(x){v(x instanceof Error?x.message:r("interaction.question.failed"))}finally{l(!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((x,C)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:x.question}),e.jsxs("div",{className:"space-y-1",children:[x.options.map((d,m)=>e.jsxs("button",{type:"button",onClick:()=>{if(x.multiSelect){const j=a[x.header]||[],S=j.includes(d.label)?j.filter(w=>w!==d.label):[...j,d.label];c({...a,[x.header]:S})}else c({...a,[x.header]:d.label}),u({...n,[x.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))]",(x.multiSelect?(a[x.header]||[]).includes(d.label):a[x.header]===d.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:d.label}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-faint))] mt-1",children:d.description})]},m)),e.jsx("input",{"aria-label":`${x.header} other response`,value:n[x.header]??"",onChange:d=>u({...n,[x.header]:d.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)),o&&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:o}),e.jsxs("button",{type:"button",onClick:()=>void N(),disabled:b||!k,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 Xt({message:t}){const s=t.agentContent,r=y(k=>k.isStreaming&&k.currentAssistantMessageId===t.id);if(!s){const k=ce(t.content);return k?e.jsx(ge,{content:k}):null}const{toolCalls:a,tasks:c,confirmation:n,question:u,elicitation:b}=s,l=Le(s),o=Oe(s);if(!(o.length>0||c.length>0||l.length>0||n||u||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 p=a.length>0&&a.every(k=>k.status==="success"||k.status==="error")&&!r,h=!r;return e.jsxs("div",{className:"space-y-3",children:[o.map(k=>k.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(zt,{content:k.content})},k.id):k.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(ge,{content:k.content,syntaxHighlight:h})},k.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(qt,{toolCalls:a,toolCallIds:k.toolCallIds})},k.id)),c.length>0&&e.jsx(Gt,{tasks:c}),l.map(k=>e.jsx(Jt,{subagent:k},k.id)),n&&e.jsx(Qt,{confirmation:n,messageId:t.id}),u&&e.jsx(Yt,{question:u,messageId:t.id}),b&&e.jsx(At,{elicitation:b,messageId:t.id}),p&&e.jsx(Wt,{toolCalls:a})]})}function Zt({message:t,showAvatar:s=!0}){var b,l,o,v;const r=t.role==="user";if(t.role==="system"){const i=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:i})})}if(r){const i=(b=t.metadata)!=null&&b.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(l=t.metadata)!=null&&l.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(i){const k=typeof i.command=="string"?i.command:"",N=i.status==="running"?"running":i.status==="completed"?"success":"error",x=typeof i.output=="string"?i.output:[typeof i.stdout=="string"?i.stdout:"",typeof i.stderr=="string"&&i.stderr?`stderr:
5
+ ${i.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:"$"}),k]}),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:x||"(no output)"}),typeof i.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 ",i.exitCode,typeof i.durationMs=="number"?` · ${(i.durationMs/1e3).toFixed(3)}s`:"",i.truncated===!0?" · truncated":""]})]})})}const{text:p,images:h}=Ot(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(fe,{text:p,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[p&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:p}),h.length>0&&e.jsx("div",{className:A("grid gap-2",h.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:h.map((k,N)=>e.jsx("img",{src:k,alt:`attachment-${N+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${k}-${N}`))})]}),e.jsx(Lt,{})]})}const c=Ut(t),n=Ct((o=t.metadata)==null?void 0:o.codeReview),u=$t((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(Vt,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[n?e.jsx(Tt,{report:n}):u?e.jsx(Pt,{report:u}):e.jsx(Xt,{message:t}),!u&&c.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(fe,{text:c,label:"Copy response"})})]})]})}const es=f.memo(Zt);function ts(t,s,r){return Math.max(0,t+(r-s))}function ss(t,s,r){return Math.min(s,Math.max(0,t)+Math.max(0,r))}function ve(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function rs({turns:t,viewportRef:s,containerRef:r,onRevealTurn:a}){const c=D(),[n,u]=f.useState(null),[b,l]=f.useState(!1),o=f.useRef(null),v=f.useCallback(()=>{var x;const p=s.current,h=r.current;if(!p||!h||t.length===0)return;const k=p.getBoundingClientRect().top;let N=((x=t[0])==null?void 0:x.id)??null;for(const C of t){const d=ve(h,C.id);if(d)if(d.getBoundingClientRect().top-k<=24)N=C.id;else break}u(N)},[t,s,r]);f.useEffect(()=>{const p=s.current;if(!p)return;const h=()=>{o.current===null&&(o.current=window.requestAnimationFrame(()=>{o.current=null,v()}))};return v(),p.addEventListener("scroll",h,{passive:!0}),()=>{p.removeEventListener("scroll",h),o.current!==null&&(window.cancelAnimationFrame(o.current),o.current=null)}},[v,s]);const i=f.useCallback(p=>{const h=()=>{const N=ve(r.current,p.id);N&&(N.scrollIntoView({behavior:"smooth",block:"start"}),u(p.id))};a(p.index)?h():window.requestAnimationFrame(()=>window.requestAnimationFrame(h))},[r,a]);return t.length<2?null:e.jsx("nav",{"aria-label":c("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onFocusCapture:()=>l(!0),onBlurCapture:p=>{p.currentTarget.contains(p.relatedTarget)||l(!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(p=>e.jsx("li",{children:e.jsx("span",{className:A("block rounded-full transition-all",p.id===n?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},p.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((p,h)=>e.jsxs("button",{type:"button",onClick:()=>i(p),className:A("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",p.id===n?"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",p.id===n?"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:c("chat.turns.label",{n:h+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:p.preview})]})]},p.id))})]})})}const ke=80;function as(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function ns(t){const s=as(t).replace(/\s+/g," ").trim();return s?s.length>ke?`${s.slice(0,ke-1)}…`:s:""}function is(t){const s=[];for(let r=0;r<t.length;r+=1){const a=t[r];if(a.role!=="user"||!a.id)continue;const c=ns(a.content);c&&s.push({id:a.id,index:r,preview:c})}return s}const re=120,ae=80,os=96;function G(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function ls({messages:t,isLoading:s}){const r=D(),a=f.useRef(null),c=f.useRef(null),n=f.useRef(!0),u=f.useRef(t.length),b=f.useRef(null),[l,o]=f.useState(re),[v,i]=f.useState(!1);f.useEffect(()=>{const m=G(a.current);if(!m||!n.current)return;const j=window.requestAnimationFrame(()=>{m.scrollTop=m.scrollHeight});return()=>window.cancelAnimationFrame(j)},[t]),f.useEffect(()=>{const m=G(a.current);if(!m)return;c.current=m;const j=()=>{const w=m.scrollHeight-m.scrollTop-m.clientHeight<=os;n.current=w,i(!w)};return j(),m.addEventListener("scroll",j,{passive:!0}),()=>m.removeEventListener("scroll",j)},[]),f.useEffect(()=>{const m=u.current;u.current=t.length,o(j=>j>=m&&t.length>m?t.length:Math.min(Math.max(j,re),t.length||re))},[t.length]);const p=Math.max(t.length-l,0),h=p,k=f.useMemo(()=>t.slice(h),[t,h]),N=f.useMemo(()=>is(t),[t]);if(f.useLayoutEffect(()=>{var S;const m=b.current;if(!m)return;const j=G(a.current);if(b.current=null,!!j){if((S=m.element)!=null&&S.isConnected){const w=m.element.getBoundingClientRect().top-m.viewportTop;j.scrollTop+=w;return}j.scrollTop=ts(m.scrollTop,m.scrollHeight,j.scrollHeight)}},[l]),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(it,{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((m,j)=>e.jsxs("div",{className:A("flex gap-3",j%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:`${m}%`,animationDelay:`${j*120}ms`}})]},m))})]})});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 x=()=>{const m=G(a.current);m&&(n.current=!0,i(!1),m.scrollTo({top:m.scrollHeight,behavior:"smooth"}))},C=()=>{var j;const m=G(a.current);if(m){const S=((j=a.current)==null?void 0:j.querySelector("[data-chat-message-id]"))??null;b.current={element:S,viewportTop:(S==null?void 0:S.getBoundingClientRect().top)??0,scrollHeight:m.scrollHeight,scrollTop:m.scrollTop}}o(S=>ss(S,t.length,ae))},d=m=>m>=h?!0:(o(t.length),!1);return e.jsxs("div",{ref:a,className:"relative flex-1 min-h-0",children:[e.jsx(Ke,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[p>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(p,ae),remaining:p}),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(p,ae)})})}),k.map((m,j)=>{const S=h+j,w=S>0?t[S-1]:null,R=!w||w.role!==m.role||w.role==="user";return e.jsx(es,{message:m,showAvatar:R},m.id||`msg-${S}`)})]})}),e.jsx(rs,{turns:N,viewportRef:c,containerRef:a,onRevealTurn:d}),v&&e.jsxs("button",{type:"button",onClick:x,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(Ae,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),r("chat.list.jumpLatest")]})]})}const cs=f.memo(ls),Ie=gt,Be=vt,$e=kt,ue=f.forwardRef(({className:t,sideOffset:s=4,...r},a)=>e.jsx(Re,{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=Re.displayName;const ds={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 us(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 ms(){var U;const t=D(),{locale:s}=qe(),r=y(E=>E.goal),a=y(E=>E.pauseGoal),c=y(E=>E.resumeGoal),n=y(E=>E.editGoal),u=y(E=>E.clearGoal),[b,l]=f.useState(!1),[o,v]=f.useState(!1),[i,p]=f.useState(""),[h,k]=f.useState(null),[N,x]=f.useState(!1);if(f.useEffect(()=>{l(!1),v(!1),p((r==null?void 0:r.objective)??""),x(!1)},[r==null?void 0:r.goalId]),!r)return null;const C=ds[r.status],d=["active","verifying","paused","blocked"].includes(r.status),m=r.status==="active"||r.status==="verifying",j=r.status==="paused"||r.status==="blocked",S=h!==null,w=async(E,$)=>{k(E);try{await $()}finally{k(null)}},R=()=>{p(r.objective),v(!0),l(!0)},K=async E=>{E.preventDefault();const $=i.trim();if(!$||$===r.objective){v(!1);return}await w("edit",()=>n($)),v(!1)},M=async()=>{await w("delete",u),x(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(Ie,{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(ot,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(lt,{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:()=>l(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:[m&&e.jsx(Q,{label:t("goal.action.pause"),disabled:S,onClick:()=>void w("pause",a),children:h==="pause"?e.jsx(F,{className:"animate-spin"}):e.jsx(ct,{})}),j&&e.jsx(Q,{label:t("goal.action.resume"),disabled:S,onClick:()=>void w("resume",c),children:h==="resume"?e.jsx(F,{className:"animate-spin"}):e.jsx(dt,{})}),e.jsx(Q,{label:t(d?"goal.action.edit":"goal.action.expand"),disabled:!d&&!b,onClick:d?R:()=>l(E=>!E),children:d?e.jsx(Fe,{}):e.jsx(ut,{})}),e.jsx(Q,{label:t("goal.action.delete"),disabled:S,destructive:!0,onClick:()=>x(!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:o?e.jsxs("form",{onSubmit:K,children:[e.jsx("textarea",{id:"goal-objective",value:i,onChange:E=>p(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(mt,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!i.trim()||h==="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:[h==="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(xt,{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(ht,{className:"h-3 w-3"}),us(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()," ·"," ",((U=r.completionVerification.verifierSessionId)==null?void 0:U.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(we,{open:N,onOpenChange:x,children:e.jsxs(Ne,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(Se,{children:t("goal.dialog.title")}),e.jsx(Ce,{children:t("goal.dialog.description")}),e.jsxs(Ee,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>x(!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:h==="delete",onClick:()=>void M(),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:[h==="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:c}){return e.jsxs(Be,{children:[e.jsx($e,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:r,onClick:c,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 xs(){const t=D(),s=y(l=>l.currentSessionRef),r=y(l=>l.sessions),a=y(l=>l.messages),c=f.useMemo(()=>{var o,v,i,p,h;const l=s?(o=ze(r,s))==null?void 0:o.pendingInteraction:void 0;if(l)return l.type;for(let k=a.length-1;k>=0;k-=1){const N=(v=a[k])==null?void 0:v.agentContent;if(((i=N==null?void 0:N.confirmation)==null?void 0:i.status)==="pending")return"permission";if(((p=N==null?void 0:N.question)==null?void 0:p.status)==="pending")return"question";if(((h=N==null?void 0:N.elicitation)==null?void 0:h.status)==="pending")return"elicitation"}return null},[s,a,r]);if(!c)return null;const n=()=>{const l=document.querySelector(`[data-pending-interaction="${c}"]`);l==null||l.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>l==null?void 0:l.focus(),250)},u=c==="question",b=c==="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(De,{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(u?"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(u?"interaction.bar.questionHint":b?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:n,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(Ae,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}const hs={running:"status.phase.running",compacting:"status.phase.compacting",switching_model:"status.phase.switchingModel",waiting_permission:"status.phase.waitingPermission",error:"status.phase.error",idle:""},je=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString();function ps(){const t=D(),s=y(o=>o.tokenUsage),r=y(o=>o.isStreaming),a=y(o=>o.agentPhase),c=hs[a]??"",n=c?t(c):"",u=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,b=Math.min(u,100),l=u>95?"danger":u>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",l==="safe"&&"text-[hsl(var(--deck-ink))]",l==="warn"&&"text-amber-600 dark:text-amber-400",l==="danger"&&"text-red-600 dark:text-red-400"),children:je(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",je(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(Ie,{children:e.jsxs(Be,{children:[e.jsx($e,{asChild:!0,children:e.jsx(pt,{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",l==="safe"&&"bg-[hsl(var(--deck-accent))]",l==="warn"&&"bg-amber-500",l==="danger"&&"bg-red-500"),style:{width:`${b}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(o=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${o}%`}},o))})]}),e.jsxs("span",{className:A("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",l==="warn"&&"text-amber-600 dark:text-amber-400",l==="danger"&&"text-red-600 dark:text-red-400"),children:[u,"%"]})]}),e.jsx("div",{className:"flex-1"}),r&&n&&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:n})]})]})}function fs(t){const s=[...t].reverse().find(c=>c.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const r=s.content.filter(c=>c.type==="text").map(c=>c.text).join(`
7
+ `),a=s.content.filter(c=>c.type==="image_url").map((c,n)=>{var b;const u=((b=c.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:b[1])??"application/octet-stream";return{id:`recovery-${s.id}-${n}`,name:`attachment-${n+1}`,mimeType:u,dataUrl:c.image_url.url}});return{content:r,attachments:a}}function js(){var xe;const t=D(),s=y(g=>g.messages),r=y(g=>g.currentSessionRef),a=y(g=>g.isStreaming),c=y(g=>g.isStopping),n=y(g=>g.sessionEventConnectionState),u=y(g=>g.pendingSteeringCount),b=y(g=>g.pendingInputDelivery),l=y(g=>g.recoveredSteeringCount),o=y(g=>g.isLoading),v=y(g=>g.error),i=y(g=>g.errorContext),p=y(g=>g.sessions),h=y(g=>g.sendMessage),k=y(g=>g.abortSession),N=y(g=>g.retryTask),x=y(g=>g.retryingTaskKeys),C=ie(g=>g.openSettings),d=y(g=>g.reconnectSessionEvents),m=y(g=>g.clearError),j=y(g=>g.unsubscribeFromEvents),[S,w]=f.useState(null),R=r?p.find(g=>g.sessionId===r.sessionId&&g.projectPath===r.projectPath):void 0,K=!!v&&((i==null?void 0:i.kind)==="navigation"||!(i!=null&&i.sessionRef)||ye(i.sessionRef,r)),M=(i==null?void 0:i.failureCode)??((xe=R==null?void 0:R.taskFailure)==null?void 0:xe.code),U=(i==null?void 0:i.kind)==="execution"&&M?t(Ge(M)):v==="queue_full"?t("chat.error.queueFull"):v==="turn_unavailable"||v==="turn_active"?t("chat.error.turnChanged"):v,E=n==="connecting"||n==="reconnecting",$=a&&n!=="connected",q=r?`session:${W(r)}`:"session:temporary",T=f.useMemo(()=>fs(s),[s]),V=r?W(r):"temporary-session",P=!!(r&&(R!=null&&R.taskRetryAvailable)&&(!M||We(M)))&&((i==null?void 0:i.kind)==="execution"||(i==null?void 0:i.kind)==="task_action"),_=(i==null?void 0:i.kind)==="execution"&&(M==="authentication"||M==="permission"||M==="model_unavailable"),B=r?x.includes(W(r)):!1;f.useEffect(()=>()=>{j()},[j]),f.useEffect(()=>{w(null)},[V]);const I=async g=>h({content:g.content,modelId:g.modelId,reasoningEffort:g.reasoningEffort,serviceTier:g.serviceTier,responseVerbosity:g.responseVerbosity,communicationStyle:g.communicationStyle,...g.outputSchema?{outputSchema:g.outputSchema}:{},attachments:g.attachments.map(se=>({type:"image",content:se.dataUrl,mimeType:se.mimeType,name:se.name}))}),L=()=>k(),z=async()=>{if(_){m(),C("models");return}if(P&&r){m(),await N(r).catch(()=>{});return}if((i==null?void 0:i.kind)==="execution"&&T){w({...T,revision:Date.now()}),m();return}m(),requestAnimationFrame(()=>Qe())},me=P?t(B?"chat.error.action.retryingTask":"chat.error.action.retryTask"):_?t("chat.error.action.checkModels"):(i==null?void 0:i.kind)==="execution"&&T?t("chat.error.action.editResend"):(i==null?void 0:i.kind)==="submission"?t("chat.error.action.returnDraft"):null;return e.jsxs("div",{className:"flex h-full flex-col bg-[hsl(var(--deck-canvas))]",children:[K&&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(De,{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((i==null?void 0:i.kind)==="submission"?"chat.error.title.submission":(i==null?void 0:i.kind)==="execution"?"chat.error.title.execution":(i==null?void 0:i.kind)==="navigation"?"chat.error.title.navigation":"chat.error.title.generic")})," ",U]}),me&&e.jsxs("button",{type:"button",onClick:()=>void z(),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:[P?B?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(le,{className:"h-3 w-3"}):e.jsx(Fe,{className:"h-3 w-3"}),me]}),e.jsx("button",{type:"button",onClick:m,"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:"✕"})]}),(E||n==="offline")&&e.jsxs("div",{role:n==="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:[E?e.jsx(F,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(ft,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:t(E?"chat.connection.reconnecting":"chat.connection.offline")}),n==="offline"&&e.jsxs("button",{type:"button",onClick:()=>void d().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(bt,{className:"h-3 w-3"}),t("chat.connection.retry")]})]}),e.jsx(jt,{}),e.jsx(cs,{messages:s,isLoading:o},r?W(r):"temporary-session"),e.jsx(xs,{}),e.jsx(ms,{}),e.jsx(Je,{draftKey:q,draft:S==null?void 0:S.content,draftAttachments:S==null?void 0:S.attachments,draftRevision:S==null?void 0:S.revision,onSend:I,onAbort:L,disabled:o||$,isStreaming:a,isStopping:c,pendingSteeringCount:u,pendingInputDelivery:b,recoveredSteeringCount:l,workspacePath:r==null?void 0:r.projectPath},q),e.jsx(ps,{})]})}export{js as ChatView};
@@ -1,4 +1,4 @@
1
- import{c as I,j as Ke}from"./vendor-react-DG5dkZ_t.js";import{f as Ve,p as Se,a as xe,n as Ae,h as Je,s as Qe,d as Ne}from"./MarkdownRenderer-DBSjC_z3.js";import"./index-CxEh32hc.js";import"./vendor-radix-DXRuAJHH.js";import"./vendor-icons-Cv18Q6rW.js";function Pe(e,t){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function et(e,t){if(e==null)return{};var n,a,o=Pe(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function se(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function tt(e){if(Array.isArray(e))return se(e)}function nt(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function at(e,t){if(e){if(typeof e=="string")return se(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?se(e,t):void 0}}function ot(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{c as I,j as Ke}from"./vendor-react-DG5dkZ_t.js";import{f as Ve,p as Se,a as xe,n as Ae,h as Je,s as Qe,d as Ne}from"./MarkdownRenderer-CxSfwebU.js";import"./index-Bx7HzeXs.js";import"./vendor-radix-DXRuAJHH.js";import"./vendor-icons-ICv1v-tf.js";function Pe(e,t){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function et(e,t){if(e==null)return{};var n,a,o=Pe(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function se(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function tt(e){if(Array.isArray(e))return se(e)}function nt(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function at(e,t){if(e){if(typeof e=="string")return se(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?se(e,t):void 0}}function ot(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function le(e){return tt(e)||nt(e)||at(e)||ot()}function Z(e){"@babel/helpers - typeof";return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(e)}function rt(e,t){if(Z(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,t);if(Z(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function it(e){var t=rt(e,"string");return Z(t)=="symbol"?t:t+""}function Te(e,t,n){return(t=it(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ce(){return ce=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},ce.apply(null,arguments)}function Ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function H(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ee(Object(n),!0).forEach(function(a){Te(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ee(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function st(e){var t=e.length;if(t===0||t===1)return e;if(t===2)return[e[0],e[1],"".concat(e[0],".").concat(e[1]),"".concat(e[1],".").concat(e[0])];if(t===3)return[e[0],e[1],e[2],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0])];if(t>=4)return[e[0],e[1],e[2],e[3],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[2],".").concat(e[3]),"".concat(e[3],".").concat(e[0]),"".concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[0]),"".concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[3],".").concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[2],".").concat(e[1],".").concat(e[0])]}var ie={};function lt(e){if(e.length===0||e.length===1)return e;var t=e.join(".");return ie[t]||(ie[t]=st(e)),ie[t]}function ct(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,a=e.filter(function(r){return r!=="token"}),o=lt(a);return o.reduce(function(r,s){return H(H({},r),n[s])},t)}function Fe(e){return e.join(" ")}function ut(e,t){var n=0;return function(a){return n+=1,a.map(function(o,r){return Ie({node:o,stylesheet:e,useInlineStyles:t,key:"code-segment-".concat(n,"-").concat(r)})})}}function Ie(e){var t=e.node,n=e.stylesheet,a=e.style,o=a===void 0?{}:a,r=e.useInlineStyles,s=e.key,i=t.properties,c=t.type,l=t.tagName,u=t.value;if(c==="text")return u;if(l){var g=ut(n,r),d;if(!r)d=H(H({},i),{},{className:Fe(i.className)});else{var p=Object.keys(n).reduce(function(b,w){return w.split(".").forEach(function(N){b.includes(N)||b.push(N)}),b},[]),f=i.className&&i.className.includes("token")?["token"]:[],v=i.className&&f.concat(i.className.filter(function(b){return!p.includes(b)}));d=H(H({},i),{},{className:Fe(v)||void 0,style:ct(i.className,Object.assign({},i.style,o),n)})}var y=g(t.children);return I.createElement(l,ce({key:s},d),y)}}const dt=function(e,t){var n=e.listLanguages();return n.indexOf(t)!==-1};var gt=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function $e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function R(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?$e(Object(n),!0).forEach(function(a){Te(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$e(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}var pt=/\n/g;function ft(e){return e.match(pt)}function ht(e){var t=e.lines,n=e.startingLineNumber,a=e.style;return t.map(function(o,r){var s=r+n;return I.createElement("span",{key:"line-".concat(r),className:"react-syntax-highlighter-line-number",style:typeof a=="function"?a(s):a},"".concat(s,`
3
3
  `))})}function bt(e){var t=e.codeString,n=e.codeStyle,a=e.containerStyle,o=a===void 0?{float:"left",paddingRight:"10px"}:a,r=e.numberStyle,s=r===void 0?{}:r,i=e.startingLineNumber;return I.createElement("code",{style:Object.assign({},n,o)},ht({lines:t.replace(/\n$/,"").split(`
4
4
  `),style:s,startingLineNumber:i}))}function mt(e){return"".concat(e.toString().length,".25em")}function Re(e,t){return{type:"element",tagName:"span",properties:{key:"line-number--".concat(e),className:["comment","linenumber","react-syntax-highlighter-line-number"],style:t},children:[{type:"text",value:e}]}}function De(e,t,n){var a={display:"inline-block",minWidth:mt(n),paddingRight:"1em",textAlign:"right",userSelect:"none"},o=typeof e=="function"?e(t):e,r=R(R({},a),o);return r}function J(e){var t=e.children,n=e.lineNumber,a=e.lineNumberStyle,o=e.largestLineNumber,r=e.showInlineLineNumbers,s=e.lineProps,i=s===void 0?{}:s,c=e.className,l=c===void 0?[]:c,u=e.showLineNumbers,g=e.wrapLongLines,d=e.wrapLines,p=d===void 0?!1:d,f=p?R({},typeof i=="function"?i(n):i):{};if(f.className=f.className?[].concat(le(f.className.trim().split(/\s+/)),le(l)):l,n&&r){var v=De(a,n,o);t.unshift(Re(n,v))}return g&u&&(f.style=R({display:"flex"},f.style)),{type:"element",tagName:"span",properties:f,children:t}}function ze(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];e.length===void 0&&(e=[e]);for(var a=0;a<e.length;a++){var o=e[a];if(o.type==="text")n.push(J({children:[o],className:le(new Set(t))}));else if(o.children){var r,s=t.concat(((r=o.properties)===null||r===void 0?void 0:r.className)||[]);ze(o.children,s).forEach(function(i){return n.push(i)})}}return n}function yt(e,t,n,a,o,r,s,i,c){var l,u=ze(e.value),g=[],d=-1,p=0;function f(S,k){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return J({children:S,lineNumber:k,lineNumberStyle:i,largestLineNumber:s,showInlineLineNumbers:o,lineProps:n,className:x,showLineNumbers:a,wrapLongLines:c,wrapLines:t})}function v(S,k){if(a&&k&&o){var x=De(i,k,s);S.unshift(Re(k,x))}return S}function y(S,k){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return t||x.length>0?f(S,k,x):v(S,k)}for(var b=function(){var k=u[p],x=k.children[0].value,E=ft(x);if(E){var j=x.split(`
@@ -1,8 +1,8 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DI8ZWdWH.js","assets/vendor-react-DG5dkZ_t.js"])))=>i.map(i=>d[i]);
2
- import{j as T,u as P,b as et,a as B,s as V,O as Te,k as Xt,Q as Yt,E as Zt,_ as er}from"./index-CxEh32hc.js";import{r as o,j as t}from"./vendor-react-DG5dkZ_t.js";import{k as Pe,a4 as tr,al as rr,y as bt,m as vt,s as kt,L as gt,d as nr,aj as sr,R as ar,X as or}from"./vendor-icons-Cv18Q6rW.js";import"./vendor-radix-DXRuAJHH.js";const yt=o.createContext(null);function wt(e){const r=o.useContext(yt);if(!r)throw new Error(`${e} must be used within <Tabs>`);return r}function ir({value:e,onValueChange:r,className:s,children:a}){const c=o.useMemo(()=>({value:e,setValue:r}),[e,r]);return t.jsx(yt.Provider,{value:c,children:t.jsx("div",{className:s,children:a})})}function cr({className:e,children:r}){return t.jsx("div",{role:"tablist",className:T("inline-flex items-center",e),children:r})}function Fe({value:e,className:r,children:s}){const{value:a,setValue:c}=wt("TabsTrigger"),i=a===e;return t.jsx("button",{type:"button",role:"tab","aria-selected":i,"data-state":i?"active":"inactive",onClick:()=>c(e),className:T("inline-flex items-center justify-center whitespace-nowrap rounded-sm transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--deck-accent))]",r),children:s})}function Le({value:e,className:r,children:s}){const{value:a}=wt("TabsContent");return a!==e?null:t.jsx("div",{role:"tabpanel",className:r,children:s})}const lr={"ayu-dark":{background:{primary:"#0f1419",secondary:"#14191f"},text:{primary:"#e6e1cf",secondary:"#bae67e",muted:"#5c6773"},border:{light:"#2d323b"},syntax:{comment:"#5c6773",string:"#bae67e",number:"#ffcc66",keyword:"#ff8f40",function:"#73d0ff",variable:"#e6e1cf",operator:"#f29e74",type:"#73d0ff",tag:"#ff8f40",attr:"#ffd580",default:"#e6e1cf"}},dracula:{background:{primary:"#282a36",secondary:"#44475a"},text:{primary:"#f8f8f2",secondary:"#f1fa8c",muted:"#6272a4"},border:{light:"#44475a"},syntax:{comment:"#6272a4",string:"#f1fa8c",number:"#bd93f9",keyword:"#ff79c6",function:"#50fa7b",variable:"#f8f8f2",operator:"#ff79c6",type:"#8be9fd",tag:"#ff79c6",attr:"#50fa7b",default:"#f8f8f2"}},monokai:{background:{primary:"#272822",secondary:"#3e3d32"},text:{primary:"#f8f8f2",secondary:"#e6db74",muted:"#75715e"},border:{light:"#3e3d32"},syntax:{comment:"#75715e",string:"#e6db74",number:"#ae81ff",keyword:"#f92672",function:"#a6e22e",variable:"#f8f8f2",operator:"#f92672",type:"#66d9ef",tag:"#f92672",attr:"#a6e22e",default:"#f8f8f2"}},nord:{background:{primary:"#2e3440",secondary:"#3b4252"},text:{primary:"#eceff4",secondary:"#d8dee9",muted:"#4c566a"},border:{light:"#434c5e"},syntax:{comment:"#616e88",string:"#a3be8c",number:"#b48ead",keyword:"#81a1c1",function:"#88c0d0",variable:"#d8dee9",operator:"#81a1c1",type:"#8fbcbb",tag:"#81a1c1",attr:"#8fbcbb",default:"#eceff4"}},"solarized-light":{background:{primary:"#fdf6e3",secondary:"#eee8d5"},text:{primary:"#586e75",secondary:"#657b83",muted:"#93a1a1"},border:{light:"#eee8d5"},syntax:{comment:"#93a1a1",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#657b83",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#657b83"}},"solarized-dark":{background:{primary:"#002b36",secondary:"#073642"},text:{primary:"#839496",secondary:"#93a1a1",muted:"#586e75"},border:{light:"#073642"},syntax:{comment:"#586e75",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#839496",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#839496"}},"tokyo-night":{background:{primary:"#1a1b26",secondary:"#292e42"},text:{primary:"#a9b1d6",secondary:"#c0caf5",muted:"#565f89"},border:{light:"#292e42"},syntax:{comment:"#565f89",string:"#9ece6a",number:"#ff9e64",keyword:"#bb9af7",function:"#7aa2f7",variable:"#c0caf5",operator:"#89ddff",type:"#7dcfff",tag:"#f7768e",attr:"#7aa2f7",default:"#a9b1d6"}},github:{background:{primary:"#ffffff",secondary:"#f6f8fa"},text:{primary:"#24292f",secondary:"#57606a",muted:"#6e7781"},border:{light:"#d0d7de"},syntax:{comment:"#6e7781",string:"#0a3069",number:"#0550ae",keyword:"#cf222e",function:"#8250df",variable:"#24292f",operator:"#cf222e",type:"#0550ae",tag:"#116329",attr:"#0550ae",default:"#24292f"}},gruvbox:{background:{primary:"#282828",secondary:"#3c3836"},text:{primary:"#ebdbb2",secondary:"#d5c4a1",muted:"#928374"},border:{light:"#3c3836"},syntax:{comment:"#928374",string:"#b8bb26",number:"#d3869b",keyword:"#fb4934",function:"#b8bb26",variable:"#ebdbb2",operator:"#fe8019",type:"#fabd2f",tag:"#fb4934",attr:"#fabd2f",default:"#ebdbb2"}},"one-dark":{background:{primary:"#282c34",secondary:"#21252b"},text:{primary:"#abb2bf",secondary:"#e5c07b",muted:"#5c6370"},border:{light:"#3e4451"},syntax:{comment:"#5c6370",string:"#98c379",number:"#d19a66",keyword:"#c678dd",function:"#61afef",variable:"#e06c75",operator:"#56b6c2",type:"#e5c07b",tag:"#e06c75",attr:"#d19a66",default:"#abb2bf"}},catppuccin:{background:{primary:"#1e1e2e",secondary:"#313244"},text:{primary:"#cdd6f4",secondary:"#f5e0dc",muted:"#6c7086"},border:{light:"#313244"},syntax:{comment:"#6c7086",string:"#a6e3a1",number:"#fab387",keyword:"#cba6f7",function:"#89b4fa",variable:"#f5e0dc",operator:"#89dceb",type:"#f9e2af",tag:"#f38ba8",attr:"#f9e2af",default:"#cdd6f4"}},"rose-pine":{background:{primary:"#191724",secondary:"#1f1d2e"},text:{primary:"#e0def4",secondary:"#908caa",muted:"#6e6a86"},border:{light:"#26233a"},syntax:{comment:"#6e6a86",string:"#f6c177",number:"#ebbcba",keyword:"#c4a7e7",function:"#9ccfd8",variable:"#e0def4",operator:"#31748f",type:"#eb6f92",tag:"#eb6f92",attr:"#c4a7e7",default:"#e0def4"}},kanagawa:{background:{primary:"#1f1f28",secondary:"#2a2a37"},text:{primary:"#dcd7ba",secondary:"#c8c093",muted:"#727169"},border:{light:"#2a2a37"},syntax:{comment:"#727169",string:"#98bb6c",number:"#d27e99",keyword:"#957fb8",function:"#7e9cd8",variable:"#dcd7ba",operator:"#c0a36e",type:"#7aa89f",tag:"#e46876",attr:"#ffa066",default:"#dcd7ba"}}};function dr(e){const r=e.replace("#",""),s=parseInt(r.substring(0,2),16),a=parseInt(r.substring(2,4),16),c=parseInt(r.substring(4,6),16);return(.299*s+.587*a+.114*c)/255<.5}function ur(e){return{base:dr(e.background.primary)?"vs-dark":"vs",inherit:!0,rules:[{token:"",foreground:e.text.primary.replace("#",""),background:e.background.primary.replace("#","")},{token:"comment",foreground:e.syntax.comment.replace("#",""),fontStyle:"italic"},{token:"string",foreground:e.syntax.string.replace("#","")},{token:"number",foreground:e.syntax.number.replace("#","")},{token:"keyword",foreground:e.syntax.keyword.replace("#","")},{token:"type",foreground:e.syntax.type.replace("#","")},{token:"identifier",foreground:e.syntax.variable.replace("#","")},{token:"function",foreground:e.syntax.function.replace("#","")},{token:"variable",foreground:e.syntax.variable.replace("#","")},{token:"operator",foreground:e.syntax.operator.replace("#","")},{token:"delimiter",foreground:e.syntax.operator.replace("#","")},{token:"tag",foreground:e.syntax.tag.replace("#","")},{token:"attribute.name",foreground:e.syntax.attr.replace("#","")},{token:"attribute.value",foreground:e.syntax.string.replace("#","")}],colors:{"editor.background":e.background.primary,"editor.foreground":e.text.primary,"editor.lineHighlightBackground":e.background.secondary,"editor.selectionBackground":`${e.syntax.function}40`,"editorLineNumber.foreground":e.text.muted,"editorLineNumber.activeForeground":e.text.secondary,"editorCursor.foreground":e.text.primary,"editorIndentGuide.background":e.border.light,"editorWidget.background":e.background.secondary,"editorWidget.border":e.border.light,"scrollbarSlider.background":`${e.text.muted}40`,"scrollbarSlider.hoverBackground":`${e.text.muted}60`}}}const tt=new Set;function rt(e,r){const s=r.toLowerCase().replace(/\s+/g,"-"),a=lr[s];if(!a)return"vs-dark";if(!tt.has(s)){const c=ur(a);e.editor.defineTheme(s,c),tt.add(s)}return s}function oe(e){return e.normalize("NFKC").toLocaleLowerCase().trim()}function fr(e,r,s){const a=oe(r).split(/\s+/).filter(Boolean);return e.filter(c=>{if(s!=="all"&&c.status!==s)return!1;if(a.length===0)return!0;const i=oe([c.title,c.subtitle,c.content].filter(Boolean).join(" "));return a.every(g=>i.includes(g))})}function jt(e){return e.replace(/\/+$/,"").split("/").filter(Boolean).at(-1)||e}function hr(e,r){const s=oe(r).split(/\s+/).filter(Boolean);return s.length===0?e:e.filter(a=>{const c=oe([a.filePath,a.summary].filter(Boolean).join(" "));return s.every(i=>c.includes(i))})}function pr(e,r,s){return r===0?0:(e+s+r)%r}const nt=20,st=20,at=160,ot=240;function it(e,r){const s=i=>i.replace(/\\/g,"/").replace(/^\.?\//,"").replace(/\/+/g,"/"),a=s(e),c=s(r);return a===c||a.endsWith(`/${c}`)||c.endsWith(`/${a}`)}function mr({diffs:e,expanded:r,targetPath:s,onToggle:a,onSetAllExpanded:c}){var d,N;const i=P(),[g,u]=o.useState(""),b=`${g}\0${e.length}\0${((d=e[0])==null?void 0:d.filePath)??""}\0${((N=e.at(-1))==null?void 0:N.filePath)??""}`,[f,h]=o.useState({key:b,count:nt}),x=f.key===b?f.count:nt,m=o.useMemo(()=>hr(e,g),[e,g]),k=o.useMemo(()=>{const p=m.slice(0,x);if(!s)return p;const j=m.find(S=>S.filePath&&it(S.filePath,s));return j&&!p.includes(j)?[...p,j]:p},[m,s,x]);return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"sticky top-0 z-10 space-y-2 bg-[hsl(var(--deck-canvas))] pb-1",children:[t.jsxs("div",{className:"flex h-8 items-center gap-2 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 focus-within:border-[hsl(var(--deck-accent)/0.6)]",children:[t.jsx(Pe,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),t.jsx("input",{type:"search","aria-label":i("preview.diff.searchAria"),placeholder:i("preview.diff.searchPlaceholder"),value:g,onChange:p=>u(p.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))]"}),t.jsxs("span",{className:"font-mono text-[9px] tabular-nums text-[hsl(var(--deck-ink-faint))]",children:[m.length,"/",e.length]})]}),t.jsxs("div",{className:"flex items-center justify-between font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:[t.jsx("span",{children:i("preview.diff.changedFiles",{count:e.length})}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsxs("button",{type:"button",onClick:()=>c(!0),className:"inline-flex items-center gap-1 rounded px-1.5 py-1 transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink-muted))]",children:[t.jsx(tr,{className:"h-3 w-3"}),i("preview.diff.expandAll")]}),t.jsxs("button",{type:"button",onClick:()=>c(!1),className:"inline-flex items-center gap-1 rounded px-1.5 py-1 transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink-muted))]",children:[t.jsx(rr,{className:"h-3 w-3"}),i("preview.diff.collapseAll")]})]})]})]}),m.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-[hsl(var(--deck-border))] p-6 text-center font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:i("preview.diff.noMatches")}):k.map(p=>{const j=p.filePath||"unknown",S=e.indexOf(p),E=r[j]??S===0,A=!!(s&&it(j,s));return t.jsxs("div",{"data-preview-diff-path":p.filePath,className:T("overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] transition-colors",A&&"border-[hsl(var(--deck-accent)/0.7)] bg-[hsl(var(--deck-accent-soft))] ring-1 ring-[hsl(var(--deck-accent)/0.2)]"),children:[t.jsxs("button",{type:"button","aria-expanded":E,onClick:()=>a(j),className:"flex w-full items-center gap-2 bg-[hsl(var(--deck-surface-2))] px-3 py-2 transition-colors hover:bg-[hsl(var(--deck-surface))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent)/0.65)]",children:[E?t.jsx(bt,{className:"h-4 w-4 text-[hsl(var(--deck-ink-muted))]"}):t.jsx(vt,{className:"h-4 w-4 text-[hsl(var(--deck-ink-muted))]"}),t.jsx(kt,{className:"h-4 w-4 text-[hsl(var(--deck-ink-muted))]"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-left font-mono text-[13px] text-[hsl(var(--deck-ink))]",children:jt(j)}),p.summary&&t.jsx("span",{className:"shrink-0 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:p.summary})]}),E&&t.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))]",children:[t.jsx("div",{className:"truncate px-3 py-1 font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:p.filePath}),t.jsx(xr,{diff:p.diff})]})]},j)}),x<m.length&&t.jsx("div",{className:"flex justify-center pt-1",children:t.jsx("button",{type:"button",onClick:()=>h({key:b,count:Math.min(m.length,x+st)}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:i("preview.diff.showMoreFiles",{count:Math.min(st,m.length-x)})})})]})}function xr({diff:e}){const r=P(),s=o.useMemo(()=>e.patch.split(`
2
+ import{j as T,u as P,b as et,a as B,s as V,Q as Te,k as Xt,R as Yt,F as Zt,_ as er}from"./index-Bx7HzeXs.js";import{r as o,j as t}from"./vendor-react-DG5dkZ_t.js";import{k as Pe,a4 as tr,am as rr,y as bt,m as vt,s as kt,L as gt,d as nr,ak as sr,R as ar,X as or}from"./vendor-icons-ICv1v-tf.js";import"./vendor-radix-DXRuAJHH.js";const yt=o.createContext(null);function wt(e){const r=o.useContext(yt);if(!r)throw new Error(`${e} must be used within <Tabs>`);return r}function ir({value:e,onValueChange:r,className:s,children:a}){const c=o.useMemo(()=>({value:e,setValue:r}),[e,r]);return t.jsx(yt.Provider,{value:c,children:t.jsx("div",{className:s,children:a})})}function cr({className:e,children:r}){return t.jsx("div",{role:"tablist",className:T("inline-flex items-center",e),children:r})}function Fe({value:e,className:r,children:s}){const{value:a,setValue:c}=wt("TabsTrigger"),i=a===e;return t.jsx("button",{type:"button",role:"tab","aria-selected":i,"data-state":i?"active":"inactive",onClick:()=>c(e),className:T("inline-flex items-center justify-center whitespace-nowrap rounded-sm transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--deck-accent))]",r),children:s})}function Le({value:e,className:r,children:s}){const{value:a}=wt("TabsContent");return a!==e?null:t.jsx("div",{role:"tabpanel",className:r,children:s})}const lr={"ayu-dark":{background:{primary:"#0f1419",secondary:"#14191f"},text:{primary:"#e6e1cf",secondary:"#bae67e",muted:"#5c6773"},border:{light:"#2d323b"},syntax:{comment:"#5c6773",string:"#bae67e",number:"#ffcc66",keyword:"#ff8f40",function:"#73d0ff",variable:"#e6e1cf",operator:"#f29e74",type:"#73d0ff",tag:"#ff8f40",attr:"#ffd580",default:"#e6e1cf"}},dracula:{background:{primary:"#282a36",secondary:"#44475a"},text:{primary:"#f8f8f2",secondary:"#f1fa8c",muted:"#6272a4"},border:{light:"#44475a"},syntax:{comment:"#6272a4",string:"#f1fa8c",number:"#bd93f9",keyword:"#ff79c6",function:"#50fa7b",variable:"#f8f8f2",operator:"#ff79c6",type:"#8be9fd",tag:"#ff79c6",attr:"#50fa7b",default:"#f8f8f2"}},monokai:{background:{primary:"#272822",secondary:"#3e3d32"},text:{primary:"#f8f8f2",secondary:"#e6db74",muted:"#75715e"},border:{light:"#3e3d32"},syntax:{comment:"#75715e",string:"#e6db74",number:"#ae81ff",keyword:"#f92672",function:"#a6e22e",variable:"#f8f8f2",operator:"#f92672",type:"#66d9ef",tag:"#f92672",attr:"#a6e22e",default:"#f8f8f2"}},nord:{background:{primary:"#2e3440",secondary:"#3b4252"},text:{primary:"#eceff4",secondary:"#d8dee9",muted:"#4c566a"},border:{light:"#434c5e"},syntax:{comment:"#616e88",string:"#a3be8c",number:"#b48ead",keyword:"#81a1c1",function:"#88c0d0",variable:"#d8dee9",operator:"#81a1c1",type:"#8fbcbb",tag:"#81a1c1",attr:"#8fbcbb",default:"#eceff4"}},"solarized-light":{background:{primary:"#fdf6e3",secondary:"#eee8d5"},text:{primary:"#586e75",secondary:"#657b83",muted:"#93a1a1"},border:{light:"#eee8d5"},syntax:{comment:"#93a1a1",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#657b83",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#657b83"}},"solarized-dark":{background:{primary:"#002b36",secondary:"#073642"},text:{primary:"#839496",secondary:"#93a1a1",muted:"#586e75"},border:{light:"#073642"},syntax:{comment:"#586e75",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#839496",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#839496"}},"tokyo-night":{background:{primary:"#1a1b26",secondary:"#292e42"},text:{primary:"#a9b1d6",secondary:"#c0caf5",muted:"#565f89"},border:{light:"#292e42"},syntax:{comment:"#565f89",string:"#9ece6a",number:"#ff9e64",keyword:"#bb9af7",function:"#7aa2f7",variable:"#c0caf5",operator:"#89ddff",type:"#7dcfff",tag:"#f7768e",attr:"#7aa2f7",default:"#a9b1d6"}},github:{background:{primary:"#ffffff",secondary:"#f6f8fa"},text:{primary:"#24292f",secondary:"#57606a",muted:"#6e7781"},border:{light:"#d0d7de"},syntax:{comment:"#6e7781",string:"#0a3069",number:"#0550ae",keyword:"#cf222e",function:"#8250df",variable:"#24292f",operator:"#cf222e",type:"#0550ae",tag:"#116329",attr:"#0550ae",default:"#24292f"}},gruvbox:{background:{primary:"#282828",secondary:"#3c3836"},text:{primary:"#ebdbb2",secondary:"#d5c4a1",muted:"#928374"},border:{light:"#3c3836"},syntax:{comment:"#928374",string:"#b8bb26",number:"#d3869b",keyword:"#fb4934",function:"#b8bb26",variable:"#ebdbb2",operator:"#fe8019",type:"#fabd2f",tag:"#fb4934",attr:"#fabd2f",default:"#ebdbb2"}},"one-dark":{background:{primary:"#282c34",secondary:"#21252b"},text:{primary:"#abb2bf",secondary:"#e5c07b",muted:"#5c6370"},border:{light:"#3e4451"},syntax:{comment:"#5c6370",string:"#98c379",number:"#d19a66",keyword:"#c678dd",function:"#61afef",variable:"#e06c75",operator:"#56b6c2",type:"#e5c07b",tag:"#e06c75",attr:"#d19a66",default:"#abb2bf"}},catppuccin:{background:{primary:"#1e1e2e",secondary:"#313244"},text:{primary:"#cdd6f4",secondary:"#f5e0dc",muted:"#6c7086"},border:{light:"#313244"},syntax:{comment:"#6c7086",string:"#a6e3a1",number:"#fab387",keyword:"#cba6f7",function:"#89b4fa",variable:"#f5e0dc",operator:"#89dceb",type:"#f9e2af",tag:"#f38ba8",attr:"#f9e2af",default:"#cdd6f4"}},"rose-pine":{background:{primary:"#191724",secondary:"#1f1d2e"},text:{primary:"#e0def4",secondary:"#908caa",muted:"#6e6a86"},border:{light:"#26233a"},syntax:{comment:"#6e6a86",string:"#f6c177",number:"#ebbcba",keyword:"#c4a7e7",function:"#9ccfd8",variable:"#e0def4",operator:"#31748f",type:"#eb6f92",tag:"#eb6f92",attr:"#c4a7e7",default:"#e0def4"}},kanagawa:{background:{primary:"#1f1f28",secondary:"#2a2a37"},text:{primary:"#dcd7ba",secondary:"#c8c093",muted:"#727169"},border:{light:"#2a2a37"},syntax:{comment:"#727169",string:"#98bb6c",number:"#d27e99",keyword:"#957fb8",function:"#7e9cd8",variable:"#dcd7ba",operator:"#c0a36e",type:"#7aa89f",tag:"#e46876",attr:"#ffa066",default:"#dcd7ba"}}};function dr(e){const r=e.replace("#",""),s=parseInt(r.substring(0,2),16),a=parseInt(r.substring(2,4),16),c=parseInt(r.substring(4,6),16);return(.299*s+.587*a+.114*c)/255<.5}function ur(e){return{base:dr(e.background.primary)?"vs-dark":"vs",inherit:!0,rules:[{token:"",foreground:e.text.primary.replace("#",""),background:e.background.primary.replace("#","")},{token:"comment",foreground:e.syntax.comment.replace("#",""),fontStyle:"italic"},{token:"string",foreground:e.syntax.string.replace("#","")},{token:"number",foreground:e.syntax.number.replace("#","")},{token:"keyword",foreground:e.syntax.keyword.replace("#","")},{token:"type",foreground:e.syntax.type.replace("#","")},{token:"identifier",foreground:e.syntax.variable.replace("#","")},{token:"function",foreground:e.syntax.function.replace("#","")},{token:"variable",foreground:e.syntax.variable.replace("#","")},{token:"operator",foreground:e.syntax.operator.replace("#","")},{token:"delimiter",foreground:e.syntax.operator.replace("#","")},{token:"tag",foreground:e.syntax.tag.replace("#","")},{token:"attribute.name",foreground:e.syntax.attr.replace("#","")},{token:"attribute.value",foreground:e.syntax.string.replace("#","")}],colors:{"editor.background":e.background.primary,"editor.foreground":e.text.primary,"editor.lineHighlightBackground":e.background.secondary,"editor.selectionBackground":`${e.syntax.function}40`,"editorLineNumber.foreground":e.text.muted,"editorLineNumber.activeForeground":e.text.secondary,"editorCursor.foreground":e.text.primary,"editorIndentGuide.background":e.border.light,"editorWidget.background":e.background.secondary,"editorWidget.border":e.border.light,"scrollbarSlider.background":`${e.text.muted}40`,"scrollbarSlider.hoverBackground":`${e.text.muted}60`}}}const tt=new Set;function rt(e,r){const s=r.toLowerCase().replace(/\s+/g,"-"),a=lr[s];if(!a)return"vs-dark";if(!tt.has(s)){const c=ur(a);e.editor.defineTheme(s,c),tt.add(s)}return s}function oe(e){return e.normalize("NFKC").toLocaleLowerCase().trim()}function fr(e,r,s){const a=oe(r).split(/\s+/).filter(Boolean);return e.filter(c=>{if(s!=="all"&&c.status!==s)return!1;if(a.length===0)return!0;const i=oe([c.title,c.subtitle,c.content].filter(Boolean).join(" "));return a.every(g=>i.includes(g))})}function jt(e){return e.replace(/\/+$/,"").split("/").filter(Boolean).at(-1)||e}function hr(e,r){const s=oe(r).split(/\s+/).filter(Boolean);return s.length===0?e:e.filter(a=>{const c=oe([a.filePath,a.summary].filter(Boolean).join(" "));return s.every(i=>c.includes(i))})}function pr(e,r,s){return r===0?0:(e+s+r)%r}const nt=20,st=20,at=160,ot=240;function it(e,r){const s=i=>i.replace(/\\/g,"/").replace(/^\.?\//,"").replace(/\/+/g,"/"),a=s(e),c=s(r);return a===c||a.endsWith(`/${c}`)||c.endsWith(`/${a}`)}function mr({diffs:e,expanded:r,targetPath:s,onToggle:a,onSetAllExpanded:c}){var d,N;const i=P(),[g,u]=o.useState(""),b=`${g}\0${e.length}\0${((d=e[0])==null?void 0:d.filePath)??""}\0${((N=e.at(-1))==null?void 0:N.filePath)??""}`,[f,h]=o.useState({key:b,count:nt}),x=f.key===b?f.count:nt,m=o.useMemo(()=>hr(e,g),[e,g]),k=o.useMemo(()=>{const p=m.slice(0,x);if(!s)return p;const j=m.find(S=>S.filePath&&it(S.filePath,s));return j&&!p.includes(j)?[...p,j]:p},[m,s,x]);return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"sticky top-0 z-10 space-y-2 bg-[hsl(var(--deck-canvas))] pb-1",children:[t.jsxs("div",{className:"flex h-8 items-center gap-2 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 focus-within:border-[hsl(var(--deck-accent)/0.6)]",children:[t.jsx(Pe,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),t.jsx("input",{type:"search","aria-label":i("preview.diff.searchAria"),placeholder:i("preview.diff.searchPlaceholder"),value:g,onChange:p=>u(p.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))]"}),t.jsxs("span",{className:"font-mono text-[9px] tabular-nums text-[hsl(var(--deck-ink-faint))]",children:[m.length,"/",e.length]})]}),t.jsxs("div",{className:"flex items-center justify-between font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:[t.jsx("span",{children:i("preview.diff.changedFiles",{count:e.length})}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsxs("button",{type:"button",onClick:()=>c(!0),className:"inline-flex items-center gap-1 rounded px-1.5 py-1 transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink-muted))]",children:[t.jsx(tr,{className:"h-3 w-3"}),i("preview.diff.expandAll")]}),t.jsxs("button",{type:"button",onClick:()=>c(!1),className:"inline-flex items-center gap-1 rounded px-1.5 py-1 transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink-muted))]",children:[t.jsx(rr,{className:"h-3 w-3"}),i("preview.diff.collapseAll")]})]})]})]}),m.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-[hsl(var(--deck-border))] p-6 text-center font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:i("preview.diff.noMatches")}):k.map(p=>{const j=p.filePath||"unknown",S=e.indexOf(p),E=r[j]??S===0,A=!!(s&&it(j,s));return t.jsxs("div",{"data-preview-diff-path":p.filePath,className:T("overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] transition-colors",A&&"border-[hsl(var(--deck-accent)/0.7)] bg-[hsl(var(--deck-accent-soft))] ring-1 ring-[hsl(var(--deck-accent)/0.2)]"),children:[t.jsxs("button",{type:"button","aria-expanded":E,onClick:()=>a(j),className:"flex w-full items-center gap-2 bg-[hsl(var(--deck-surface-2))] px-3 py-2 transition-colors hover:bg-[hsl(var(--deck-surface))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent)/0.65)]",children:[E?t.jsx(bt,{className:"h-4 w-4 text-[hsl(var(--deck-ink-muted))]"}):t.jsx(vt,{className:"h-4 w-4 text-[hsl(var(--deck-ink-muted))]"}),t.jsx(kt,{className:"h-4 w-4 text-[hsl(var(--deck-ink-muted))]"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-left font-mono text-[13px] text-[hsl(var(--deck-ink))]",children:jt(j)}),p.summary&&t.jsx("span",{className:"shrink-0 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:p.summary})]}),E&&t.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))]",children:[t.jsx("div",{className:"truncate px-3 py-1 font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:p.filePath}),t.jsx(xr,{diff:p.diff})]})]},j)}),x<m.length&&t.jsx("div",{className:"flex justify-center pt-1",children:t.jsx("button",{type:"button",onClick:()=>h({key:b,count:Math.min(m.length,x+st)}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:i("preview.diff.showMoreFiles",{count:Math.min(st,m.length-x)})})})]})}function xr({diff:e}){const r=P(),s=o.useMemo(()=>e.patch.split(`
3
3
  `),[e.patch]),[a,c]=o.useState({patch:e.patch,count:at}),i=a.patch===e.patch?a.count:at,g=s.slice(0,i);let u=0,b=0;return t.jsxs("div",{className:"overflow-hidden rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[t.jsxs("div",{className:"flex items-center justify-between border-b 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:[t.jsx("span",{children:r("preview.diff.patch")}),e.matchLine&&t.jsx("span",{children:r("preview.diff.line",{line:e.matchLine})})]}),t.jsx("div",{className:"overflow-x-auto font-mono text-[12px]",children:g.map((f,h)=>{if(f.startsWith("@@")){const x=/@@ -(?<old>\d+),?(?<oldCount>\d*) \+(?<new>\d+),?(?<newCount>\d*) @@/.exec(f);return x!=null&&x.groups&&(u=Number.parseInt(x.groups.old,10),b=Number.parseInt(x.groups.new,10)),t.jsx(z,{line:f},`${f}-${h}`)}if(f.startsWith("---")||f.startsWith("+++")||f.startsWith("Index:")||f.startsWith("==="))return t.jsx(z,{line:f},`${f}-${h}`);if(f.startsWith("+")){const x=b++;return t.jsx(z,{line:f,oldLine:null,newLine:x},`${f}-${h}`)}if(f.startsWith("-")){const x=u++;return t.jsx(z,{line:f,oldLine:x,newLine:null},`${f}-${h}`)}return f.startsWith(" ")?t.jsx(z,{line:f,oldLine:u++,newLine:b++},`${f}-${h}`):t.jsx(z,{line:f},`${f}-${h}`)})}),i<s.length&&t.jsx("div",{className:"flex justify-center border-t border-[hsl(var(--deck-border))] p-2",children:t.jsx("button",{type:"button",onClick:()=>c({patch:e.patch,count:Math.min(s.length,i+ot)}),className:"rounded-md border border-[hsl(var(--deck-border))] px-3 py-1 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface-2))] hover:text-[hsl(var(--deck-ink))]",children:r("preview.diff.showMoreLines",{count:Math.min(ot,s.length-i)})})})]})}function z({line:e,oldLine:r,newLine:s}){const a=e.startsWith("---")||e.startsWith("+++")||e.startsWith("Index:")||e.startsWith("==="),c=e.startsWith("@@"),i=e[0],g=a||c?e:e.slice(1),u=a?"text-[hsl(var(--deck-ink-muted))]":i==="+"?"bg-[#22C55E]/10 text-[#166534] dark:bg-[#22C55E]/10 dark:text-[#86efac]":i==="-"?"bg-[#EF4444]/10 text-[#b91c1c] dark:bg-[#EF4444]/10 dark:text-[#fca5a5]":c?"bg-[#DBEAFE] text-[#1d4ed8] dark:bg-[#1e3a8a]/30 dark:text-[#93c5fd]":"text-[hsl(var(--deck-ink))]";return t.jsxs("div",{"data-preview-diff-line":!0,className:T("grid min-w-max grid-cols-[40px_40px_1fr] gap-2 px-3 py-0.5",u),children:[t.jsx("span",{className:"text-right text-[hsl(var(--deck-ink-faint))]",children:r?String(r).padStart(2," "):""}),t.jsx("span",{className:"text-right text-[hsl(var(--deck-ink-faint))]",children:s?String(s).padStart(2," "):""}),t.jsx("span",{className:"whitespace-pre",children:g})]})}function br({nodes:e,expandedDirs:r,childrenCache:s,directoryStates:a,selectedPath:c,onToggleDir:i,onRetryDir:g,onSelectFile:u}){return t.jsx(t.Fragment,{children:e.map(b=>t.jsx(Nt,{node:b,depth:0,expandedDirs:r,childrenCache:s,directoryStates:a,selectedPath:c,onToggleDir:i,onRetryDir:g,onSelectFile:u},b.path))})}function Nt({node:e,depth:r,expandedDirs:s,childrenCache:a,directoryStates:c,selectedPath:i,onToggleDir:g,onRetryDir:u,onSelectFile:b}){const f=P(),h=e.type==="dir",x=!!s[e.path],m=!h&&i===e.path,k=a[e.path]??[],d=c[e.path],N=r*14+24;return t.jsxs("div",{children:[t.jsxs("button",{type:"button","aria-expanded":h?x:void 0,"aria-busy":h&&(d==null?void 0:d.status)==="loading",onClick:()=>h?g(e.path):b(e.path),className:T("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left font-mono text-[12px] transition-colors",m?"border border-[#16A34A]/30 bg-[#16A34A]/10 text-[#111827] dark:border-[#22C55E]/30 dark:bg-[#22C55E]/10 dark:text-[#E5E5E5]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-surface))]",h&&"cursor-pointer"),style:{paddingLeft:r*14+8},children:[h?(d==null?void 0:d.status)==="loading"?t.jsx(gt,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}):x?t.jsx(nr,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink))]"}):t.jsx(sr,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-muted))]"}):t.jsx(kt,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),t.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:e.name})]}),h&&x&&t.jsxs("div",{children:[(d==null?void 0:d.status)==="loading"&&t.jsx("div",{role:"status",style:{paddingLeft:N},className:"py-1 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:f("preview.files.directoryLoading")}),(d==null?void 0:d.status)==="error"&&t.jsxs("div",{role:"alert",style:{marginLeft:N},className:"my-1 mr-1 rounded-md border border-red-200 bg-red-50/70 px-2 py-1.5 font-mono text-[10px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[t.jsx("div",{className:"truncate",title:d.message,children:d.message}),t.jsxs("button",{type:"button",onClick:()=>u(e.path),className:"mt-1 inline-flex items-center gap-1 font-medium underline-offset-2 hover:underline",children:[t.jsx(ar,{className:"h-2.5 w-2.5"}),f("preview.action.retry")]})]}),(d==null?void 0:d.status)==="loaded"&&k.length===0&&t.jsx("div",{style:{paddingLeft:N},className:"py-1 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:f("preview.files.directoryEmpty")}),k.map(p=>t.jsx(Nt,{node:p,depth:r+1,expandedDirs:s,childrenCache:a,directoryStates:c,selectedPath:i,onToggleDir:g,onRetryDir:u,onSelectFile:b},p.path))]})]})}const ct=80,lt=80;function vr({logs:e}){var d,N;const r=P(),[s,a]=o.useState(""),[c,i]=o.useState("all"),[g,u]=o.useState({}),b=`${c}\0${s}\0${e.length}\0${((d=e[0])==null?void 0:d.id)??""}\0${((N=e.at(-1))==null?void 0:N.id)??""}`,[f,h]=o.useState({key:b,count:ct}),x=o.useMemo(()=>fr(e,s,c),[c,e,s]),m=f.key===b?f.count:ct,k=x.slice(0,m);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"space-y-2 border-b border-[hsl(var(--deck-border))] px-4 py-3",children:[t.jsxs("div",{className:"flex h-8 items-center gap-2 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 focus-within:border-[hsl(var(--deck-accent)/0.6)]",children:[t.jsx(Pe,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),t.jsx("input",{type:"search","aria-label":r("preview.logs.searchAria"),placeholder:r("preview.logs.searchPlaceholder"),value:s,onChange:p=>a(p.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))]"}),t.jsxs("span",{className:"font-mono text-[9px] tabular-nums text-[hsl(var(--deck-ink-faint))]",children:[x.length,"/",e.length]})]}),t.jsx("div",{className:"flex items-center gap-1","aria-label":r("preview.logs.filterAria"),children:["all","running","error","success"].map(p=>t.jsx("button",{type:"button","aria-pressed":c===p,onClick:()=>i(p),className:T("rounded-md border px-2 py-1 font-mono text-[9.5px] transition-colors",c===p?"border-[hsl(var(--deck-accent)/0.45)] bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-accent))]":"border-[hsl(var(--deck-border))] text-[hsl(var(--deck-ink-faint))] hover:text-[hsl(var(--deck-ink-muted))]"),children:r(`preview.logs.filter.${p}`)},p))})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-4",children:[e.length===0?t.jsx(dt,{title:r("preview.logs.emptyTitle"),subtitle:r("preview.logs.emptyHint")}):x.length===0?t.jsx(dt,{title:r("preview.logs.noMatches"),subtitle:r("preview.logs.noMatchesHint")}):k.map(p=>{var W;const j=g[p.id],S=(p.content||"").split(`
4
4
  `),E=S.length>10||(((W=p.content)==null?void 0:W.length)||0)>800,A=j||!E?S:S.slice(0,8);return t.jsxs("div",{"data-preview-log-id":p.id,className:"overflow-hidden rounded-lg border border-[hsl(var(--deck-border))]",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2",children:[t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("div",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:p.title}),p.subtitle&&t.jsx("div",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:p.subtitle})]}),t.jsx(kr,{status:p.status})]}),p.content&&t.jsxs("div",{className:"space-y-2 px-3 py-3",children:[t.jsxs("pre",{className:"overflow-x-auto whitespace-pre-wrap rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] p-3 font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:[A.join(`
5
5
  `),!j&&E&&`
6
- …`]}),E&&t.jsxs("button",{type:"button",onClick:()=>u(O=>({...O,[p.id]:!O[p.id]})),className:"flex items-center gap-1 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:text-[hsl(var(--deck-ink))]",children:[j?t.jsx(bt,{className:"h-3 w-3"}):t.jsx(vt,{className:"h-3 w-3"}),r(j?"preview.logs.collapse":"preview.logs.expand")]})]})]},p.id)}),m<x.length&&t.jsx("div",{className:"flex justify-center",children:t.jsx("button",{type:"button",onClick:()=>h({key:b,count:Math.min(x.length,m+lt)}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:r("preview.logs.showMore",{count:Math.min(lt,x.length-m)})})})]})]})}function dt({title:e,subtitle:r}){return t.jsxs("div",{className:"rounded-lg border border-dashed border-[hsl(var(--deck-border))] p-6 text-center",children:[t.jsx("div",{className:"font-mono text-[13px] text-[hsl(var(--deck-ink))]",children:e}),t.jsx("div",{className:"mt-1 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r})]})}function kr({status:e}){const r=P(),s=r(e==="success"?"preview.logs.status.success":e==="error"?"preview.logs.status.error":"preview.logs.status.running"),a=e==="success"?"bg-[#22C55E] text-white":e==="error"?"bg-[#FEE2E2] text-[#b91c1c] dark:bg-[#EF4444]/20 dark:text-[#fca5a5]":"bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink-muted))]";return t.jsx("span",{className:T("rounded-full px-2 py-0.5 font-mono text-[11px]",a),children:s})}const gr=640,Ct=360,Re=960;function ut(e){const r=typeof window>"u"?Re:Math.max(280,Math.floor(window.innerWidth*.72));return Math.min(Re,r,Math.max(Ct,Math.round(e)))}function St(e,r,s){var a;if(e){const c=(a=s==null?void 0:s.taskDelivery)==null?void 0:a.status;return(s==null?void 0:s.taskIsolation)==="worktree"&&s.taskSourceProjectPath&&(c==="applied"||c==="discarded")?{sessionId:e.sessionId,projectPath:s.taskSourceProjectPath}:e}return r?{sessionId:`project:${r}`,projectPath:r}:null}function Ie(){const e=B.getState(),r=e.sessions.find(s=>V({sessionId:s.sessionId,projectPath:s.projectPath},e.currentSessionRef));return St(e.currentSessionRef,e.selectedProjectPath,r)}function ft(e,r){const s=i=>i.replace(/\\/g,"/").replace(/^\.?\//,"").replace(/\/+/g,"/"),a=s(e),c=s(r);return a===c||a.endsWith(`/${c}`)||c.endsWith(`/${a}`)}const yr=o.lazy(async()=>({default:(await er(()=>import("./index-DI8ZWdWH.js"),__vite__mapDeps([0,1]))).Editor}));function ae(e,r){return e instanceof Error?e.message:r}function Fr({returnFocusElement:e}={}){var Ye,Ze;const r=P(),{toggleFilePreview:s,previewWidth:a,setPreviewWidth:c,previewTab:i,setPreviewTab:g,previewTargetPath:u,previewRequestId:b}=et(),f=B(n=>n.messages),h=B(n=>n.currentSessionRef),x=B(n=>n.sessions),m=B(n=>n.selectedProjectPath),k=o.useMemo(()=>x.find(n=>V({sessionId:n.sessionId,projectPath:n.projectPath},h)),[h,x]),d=o.useMemo(()=>St(h,m,k),[k,h,m]),[N,p]=o.useState(i),[j,S]=o.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 1023px)").matches),[E,A]=o.useState(null),[W,O]=o.useState(!1),[ie,ce]=o.useState([]),[Et,Ae]=o.useState({}),[Dt,We]=o.useState({}),[Tt,Ft]=o.useState(0),[K,le]=o.useState(!1),[U,de]=o.useState(null),[$,ue]=o.useState(""),[Q,J]=o.useState([]),[$e,X]=o.useState(!1),[Lt,Y]=o.useState(!1),[It,Rt]=o.useState(0),[fe,Z]=o.useState(0),[Pt,he]=o.useState({}),[At,ee]=o.useState({}),[F,_e]=o.useState(null),[Wt,pe]=o.useState(""),[me,xe]=o.useState(!1),[be,ve]=o.useState(null),[qe,ke]=o.useState(!1),Me=o.useRef(d),_=o.useRef(0),te=o.useRef(0),q=o.useRef({}),ge=o.useRef(0),re=o.useRef(0),M=o.useRef(0),L=o.useRef({}),ne=o.useRef({}),ye=o.useRef({}),we=o.useRef(null),je=o.useRef(null),ze=o.useRef(null),Be=o.useRef(null),Ne=o.useRef(a),Ge=o.useRef(h);o.useLayoutEffect(()=>{V(Me.current,d)||(_.current+=1),Me.current=d},[d]),o.useEffect(()=>{if(typeof window.matchMedia!="function")return;const n=window.matchMedia("(max-width: 1023px)"),l=()=>S(n.matches);return l(),n.addEventListener("change",l),()=>n.removeEventListener("change",l)},[]),o.useEffect(()=>(Be.current=e??(document.activeElement instanceof HTMLElement?document.activeElement:null),()=>{const n=Be.current;requestAnimationFrame(()=>{n!=null&&n.isConnected&&n.focus({preventScroll:!0})})}),[e]),o.useEffect(()=>{var n;j&&((n=ze.current)==null||n.focus({preventScroll:!0}))},[j]);const $t=n=>{var C;if(!j)return;if(n.key==="Escape"){n.preventDefault(),s();return}if(n.key!=="Tab")return;const l=Array.from(((C=je.current)==null?void 0:C.querySelectorAll('button:not([disabled]), input:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))??[]).filter(w=>!w.hasAttribute("hidden"));if(l.length===0)return;const y=l[0],v=l[l.length-1];n.shiftKey&&document.activeElement===y?(n.preventDefault(),v==null||v.focus()):!n.shiftKey&&document.activeElement===v&&(n.preventDefault(),y==null||y.focus())},H=(n,l)=>l===_.current&&V(Ie(),n),Oe=async(n,l="")=>{const y=l?`/suggestions/files/tree?path=${encodeURIComponent(l)}`:"/suggestions/files/tree",v=await fetch(y,{headers:Te(n)});if(!v.ok)throw new Error(r("preview.files.treeFailed"));return(await v.json()).map(w=>({...w,children:w.type==="dir"?[]:void 0}))};o.useEffect(()=>{const n=++te.current;return(async()=>{if(!d){ce([]),le(!1),de(null);return}const y={...d},v=_.current,C=()=>n===te.current&&H(y,v);if(C()){ce([]),le(!0),de(null);try{const w=await Oe(y);C()&&ce(w)}catch(w){C()&&de(ae(w,r("preview.files.treeFailed")))}finally{C()&&le(!1)}}})(),()=>{te.current===n&&(te.current+=1)}},[Tt,d==null?void 0:d.projectPath,d==null?void 0:d.sessionId]),o.useEffect(()=>{we.current=null,L.current={},ne.current={},ye.current={},q.current={},ge.current+=1,_e(null),pe(""),xe(!1),ve(null),ke(!1),he({}),Ae({}),We({}),ue(""),J([]),X(!1),Y(!1),Z(0),ee({})},[d==null?void 0:d.projectPath,d==null?void 0:d.sessionId]);const _t=o.useMemo(()=>jr(f),[f]),[qt,He]=o.useState(null),[Mt,Ce]=o.useState(!1),[Ve,Ke]=o.useState(null),[zt,Bt]=o.useState(0),Se=(k==null?void 0:k.taskIsolation)==="worktree"&&((Ye=k.taskDelivery)==null?void 0:Ye.status)==="discarded",Ue=(k==null?void 0:k.taskIsolation)==="worktree"&&!!k.taskDiffStat&&!Se,Qe=Ue&&!!(k!=null&&k.taskDiffStat&&k.taskDiffStat.changedFiles>0),I=Se?[]:Ue?qt??[]:_t,Gt=o.useMemo(()=>wr(f),[f]);o.useEffect(()=>{const n=$.trim(),l=++re.current;if(Z(0),Y(!1),!n||N!=="files"||!d){J([]),X(!1);return}const y={...d},v=_.current;X(!0);const C=window.setTimeout(()=>{fetch(`/suggestions/files?q=${encodeURIComponent(n)}&limit=100&type=file`,{headers:Te(y)}).then(async w=>{if(!w.ok)throw new Error(r("preview.files.searchFailed"));return await w.json()}).then(w=>{l===re.current&&H(y,v)&&(J(w.filter(D=>!D.endsWith("/"))),Y(!1))}).catch(()=>{l===re.current&&H(y,v)&&(J([]),Y(!0))}).finally(()=>{l===re.current&&X(!1)})},160);return()=>window.clearTimeout(C)},[N,$,It,d==null?void 0:d.projectPath,d==null?void 0:d.sessionId]),o.useEffect(()=>{p(et.getState().previewTab)},[b]),o.useEffect(()=>{const n=Ge.current;Ge.current=h,!h&&m&&(n||N!=="files")&&(p("files"),g("files"))},[N,h==null?void 0:h.projectPath,h==null?void 0:h.sessionId,m,g]),o.useEffect(()=>{var y;if(!u||N!=="diff")return;const n=(y=I.find(v=>v.filePath&&ft(v.filePath,u)))==null?void 0:y.filePath;if(!n)return;ee(v=>({...v,[n]:!0}));const l=requestAnimationFrame(()=>{var C,w;const v=Array.from(((C=je.current)==null?void 0:C.querySelectorAll("[data-preview-diff-path]"))??[]).find(D=>ft(D.dataset.previewDiffPath??"",u));typeof(v==null?void 0:v.scrollIntoView)=="function"&&v.scrollIntoView({block:"nearest",behavior:"smooth"}),(w=v==null?void 0:v.querySelector("button"))==null||w.focus({preventScroll:!0})});return()=>cancelAnimationFrame(l)},[N,I,b,u]),o.useEffect(()=>{const n=++M.current;if(He(null),Ke(null),Ce(!1),!h||!Qe)return;const l={...h};return Ce(!0),Xt.getTaskDiff(l).then(y=>{n!==M.current||!V(B.getState().currentSessionRef,l)||He(y.files.map(v=>({filePath:v.path,diff:{patch:v.patch},summary:v.binary?"binary":`+${v.additions} -${v.deletions}${v.truncated?" (truncated)":""}`})))}).catch(y=>{n===M.current&&Ke(ae(y,r("preview.diff.failedTitle")))}).finally(()=>{n===M.current&&Ce(!1)}),()=>{M.current===n&&(M.current+=1)}},[k==null?void 0:k.taskCompletedAt,(Ze=k==null?void 0:k.taskDelivery)==null?void 0:Ze.status,k==null?void 0:k.taskDiffStat,k==null?void 0:k.taskIsolation,h,Qe,zt]);const Ot=n=>{ee(l=>({...l,[n]:!l[n]}))},Ht=n=>{ee(Object.fromEntries(I.map(l=>[l.filePath||"unknown",n])))},se=async n=>{const l=Ie();if(!l)return;const y=_.current,v=++ge.current,C=()=>v===ge.current&&we.current===n&&H(l,y);we.current=n,_e(n),pe(""),xe(!0),ve(null),ke(!1);try{const w=await fetch(`/suggestions/files/content?path=${encodeURIComponent(n)}`,{headers:Te(l)});if(!w.ok)throw new Error(r("preview.files.contentFailed"));const D=await w.json();C()&&(pe(D.content||""),ke(!!D.truncated))}catch(w){C()&&ve(ae(w,r("preview.files.contentFailed")))}finally{C()&&xe(!1)}},Vt=n=>{if(n.key==="ArrowDown"||n.key==="ArrowUp"){n.preventDefault(),Z(l=>pr(l,Q.length,n.key==="ArrowDown"?1:-1));return}if(n.key==="Enter"){const l=Q[fe];if(!l)return;n.preventDefault(),se(l);return}n.key==="Escape"&&(n.preventDefault(),ue(""))},Ee=(n,l)=>{const y={...ye.current,[n]:l};ye.current=y,We(y)},Je=async n=>{const l=(q.current[n]??0)+1;q.current[n]=l,Ee(n,{status:"loading"});const y=Ie();if(!y)return;const v=_.current,C=()=>q.current[n]===l&&L.current[n]===!0&&H(y,v);try{const w=await Oe(y,n);if(C()){const D={...ne.current,[n]:w};ne.current=D,Ae(D),Ee(n,{status:"loaded"})}}catch(w){C()&&Ee(n,{status:"error",message:ae(w,r("preview.files.treeFailed"))})}},Kt=n=>{const l=!L.current[n],y={...L.current,[n]:l};if(L.current=y,he(y),!l){q.current[n]=(q.current[n]??0)+1;return}ne.current[n]||Je(n)},Ut=n=>{if(!L.current[n]){const l={...L.current,[n]:!0};L.current=l,he(l)}Je(n)},Qt=n=>{n.preventDefault(),n.currentTarget.setPointerCapture(n.pointerId),Ne.current=a,O(!0),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},Jt=n=>{if(!W)return;const l=ut(window.innerWidth-n.clientX);Ne.current=l,A(l)},Xe=n=>{W&&(n.currentTarget.hasPointerCapture(n.pointerId)&&n.currentTarget.releasePointerCapture(n.pointerId),O(!1),A(null),c(Ne.current),document.body.style.cursor="",document.body.style.userSelect="")};o.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect=""},[]);const De=ut(E??a);return t.jsxs("div",{ref:je,"data-testid":"file-preview",role:j?"dialog":"complementary","aria-modal":j||void 0,"aria-label":r("preview.title"),onKeyDown:$t,style:{width:De,maxWidth:"72vw"},className:"relative flex h-full min-w-[360px] shrink-0 flex-col border-l border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] shadow-xl max-lg:fixed max-lg:inset-0 max-lg:z-[60] max-lg:!h-dvh max-lg:!w-full max-lg:!max-w-full max-lg:min-w-0 max-lg:border-l-0",children:[t.jsx("div",{role:"separator","aria-label":r("preview.action.resize"),"aria-orientation":"vertical","aria-valuemin":Ct,"aria-valuemax":Re,"aria-valuenow":De,"aria-hidden":j||void 0,tabIndex:j?-1:0,onPointerDown:Qt,onPointerMove:Jt,onPointerUp:Xe,onPointerCancel:Xe,onDoubleClick:()=>c(gr),onKeyDown:n=>{n.key!=="ArrowLeft"&&n.key!=="ArrowRight"||(n.preventDefault(),c(De+(n.key==="ArrowLeft"?24:-24)))},className:T("absolute inset-y-0 -left-1 z-20 w-2 cursor-col-resize touch-none outline-none max-lg:hidden","after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-transparent after:transition-colors","hover:after:bg-[hsl(var(--deck-accent)/0.6)] focus-visible:after:bg-[hsl(var(--deck-accent))]",W&&"after:bg-[hsl(var(--deck-accent))]")}),t.jsxs("div",{className:"flex items-center justify-between px-4 h-12 border-b border-[hsl(var(--deck-border))] shrink-0",children:[t.jsx("span",{className:"font-normal text-[13px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r("preview.title")}),t.jsx(Yt,{ref:ze,variant:"ghost",size:"icon",onClick:s,"aria-label":r("preview.action.close"),title:r("preview.action.close"),className:"h-8 w-8 text-[hsl(var(--deck-ink-faint))] hover:text-[hsl(var(--deck-ink))] hover:bg-[hsl(var(--deck-surface))]",children:t.jsx(or,{className:"w-4 h-4"})})]}),t.jsxs(ir,{value:N,onValueChange:n=>{const l=n;p(l),g(l)},className:"flex flex-col flex-1 min-h-0",children:[t.jsx("div",{className:"px-4 py-3 border-b border-[hsl(var(--deck-border))]",children:t.jsxs(cr,{className:"bg-[hsl(var(--deck-surface))] border border-[hsl(var(--deck-border))] h-9 p-1 rounded-md w-full justify-start",children:[t.jsx(Fe,{value:"diff",className:"text-[12px] font-mono px-3 text-[hsl(var(--deck-ink-muted))] data-[state=active]:bg-[hsl(var(--deck-canvas-veil))] data-[state=active]:text-[hsl(var(--deck-ink))]",children:r("preview.tab.diff")}),t.jsx(Fe,{value:"files",className:"text-[12px] font-mono px-3 text-[hsl(var(--deck-ink-muted))] data-[state=active]:bg-[hsl(var(--deck-canvas-veil))] data-[state=active]:text-[hsl(var(--deck-ink))]",children:r("preview.tab.files")}),t.jsx(Fe,{value:"logs",className:"text-[12px] font-mono px-3 text-[hsl(var(--deck-ink-muted))] data-[state=active]:bg-[hsl(var(--deck-canvas-veil))] data-[state=active]:text-[hsl(var(--deck-ink))]",children:r("preview.tab.logs")})]})}),t.jsx(Le,{value:"diff",className:"overflow-hidden flex-1 mt-0",children:t.jsx("div",{className:"overflow-y-auto px-4 py-4 space-y-3 h-full",children:Se?t.jsx(R,{title:r("preview.diff.discardedTitle"),subtitle:r("preview.diff.discardedHint"),role:"status"}):Mt&&I.length===0?t.jsx(R,{title:r("preview.diff.loadingTitle"),subtitle:r("preview.diff.loadingHint")}):Ve&&I.length===0?t.jsx(R,{title:r("preview.diff.failedTitle"),subtitle:Ve,actionLabel:r("preview.action.retry"),onAction:()=>Bt(n=>n+1),role:"alert"}):I.length===0?t.jsx(R,{title:r("preview.diff.emptyTitle"),subtitle:r("preview.diff.emptyHint")}):t.jsx(mr,{diffs:I,expanded:At,targetPath:u,onToggle:Ot,onSetAllExpanded:Ht})})}),t.jsx(Le,{value:"files",className:"overflow-hidden flex-1 mt-0",children:t.jsxs("div",{className:"px-4 py-4 h-full",children:[K&&t.jsx(R,{title:r("preview.files.loadingTitle"),subtitle:r("preview.files.loadingHint")}),!K&&U&&t.jsx(R,{title:r("preview.files.failedTitle"),subtitle:U,actionLabel:r("preview.action.retry"),onAction:()=>Ft(n=>n+1),role:"alert"}),!K&&!U&&ie.length===0&&t.jsx(R,{title:r("preview.files.emptyTitle"),subtitle:r("preview.files.emptyHint")}),!K&&!U&&ie.length>0&&t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-[minmax(170px,220px)_minmax(0,1fr)] gap-3 max-sm:grid-cols-1 max-sm:grid-rows-[180px_minmax(0,1fr)]",children:[t.jsxs("div",{className:"flex min-h-0 flex-col overflow-hidden rounded-lg border border-[hsl(var(--deck-border))]",children:[t.jsx("div",{className:"border-b border-[hsl(var(--deck-border))] p-2",children:t.jsxs("div",{className:"flex h-8 items-center gap-2 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 focus-within:border-[hsl(var(--deck-accent)/0.6)]",children:[t.jsx(Pe,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),t.jsx("input",{type:"search","aria-label":r("preview.files.searchAria"),placeholder:r("preview.files.searchPlaceholder"),value:$,onChange:n=>ue(n.target.value),onKeyDown:Vt,className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))]"}),$e&&t.jsx(gt,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"})]})}),t.jsx("div",{role:$?"listbox":void 0,"aria-label":$?r("preview.files.searchResultsAria"):void 0,className:"min-h-0 flex-1 overflow-y-auto p-2",children:$?Lt?t.jsxs("div",{role:"alert",className:"px-2 py-5 text-center font-mono text-[10.5px] text-red-700 dark:text-red-300",children:[t.jsx("div",{children:r("preview.files.searchFailed")}),t.jsx("button",{type:"button",onClick:()=>Rt(n=>n+1),className:"mt-1 underline underline-offset-2",children:r("preview.action.retry")})]}):Q.length>0?Q.map((n,l)=>t.jsxs("button",{type:"button",role:"option","aria-selected":l===fe,"data-preview-file-result":l,onMouseEnter:()=>Z(l),onClick:()=>void se(n),className:T("mb-0.5 flex w-full min-w-0 flex-col rounded-md px-2 py-1.5 text-left font-mono transition-colors",l===fe?"bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-surface))]"),children:[t.jsx("span",{className:"truncate text-[11.5px]",children:jt(n)}),t.jsx("span",{className:"truncate text-[9px] text-[hsl(var(--deck-ink-faint))]",children:n})]},n)):!$e&&t.jsx("div",{className:"px-2 py-5 text-center font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:r("preview.files.noMatches")}):t.jsx(br,{nodes:ie,expandedDirs:Pt,childrenCache:Et,directoryStates:Dt,selectedPath:F,onToggleDir:Kt,onRetryDir:Ut,onSelectFile:se})})]}),t.jsxs("div",{className:"border border-[hsl(var(--deck-border))] rounded-lg overflow-hidden flex flex-col min-h-0",children:[t.jsxs("div",{className:"px-3 py-2 bg-[hsl(var(--deck-surface-2))] border-b border-[hsl(var(--deck-border))] text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono flex items-center justify-between",children:[t.jsx("span",{className:"min-w-0 truncate",children:F||r("preview.files.selectTitle")}),F&&t.jsx("span",{className:"ml-2 shrink-0 text-[11px] text-[hsl(var(--deck-ink-faint))] font-mono",children:r(me?"preview.files.status.loading":qe?"preview.files.status.truncated":"preview.files.status.ready")})]}),qe&&!me&&t.jsx("div",{className:"px-3 py-2 bg-[#FEF3C7] dark:bg-[#111113] border-b border-[hsl(var(--deck-border))] text-[11px] text-[#b45309] dark:text-[#facc15] font-mono",children:r("preview.files.truncatedNotice")}),t.jsxs("div",{className:"flex-1 min-h-0",children:[!F&&t.jsx("div",{className:"h-full flex items-center justify-center text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r("preview.files.pickHint")}),F&&be&&t.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2 px-4 text-center font-mono text-[12px] text-[#DC2626] dark:text-[#fca5a5]",children:[t.jsx("span",{children:be}),t.jsx("button",{type:"button",onClick:()=>void se(F),className:"underline underline-offset-2",children:r("preview.action.retry")})]}),F&&!be&&t.jsx("div",{className:"h-full",children:me?t.jsx(xt,{}):t.jsx(o.Suspense,{fallback:t.jsx(xt,{}),children:t.jsx(Nr,{content:Wt,filename:F})})})]})]})]})]})}),t.jsx(Le,{value:"logs",className:"overflow-hidden flex-1 mt-0",children:t.jsx(vr,{logs:Gt})})]})]})}function R({title:e,subtitle:r,actionLabel:s,onAction:a,role:c}){return t.jsxs("div",{role:c,className:"border border-dashed border-[hsl(var(--deck-border))] rounded-lg p-6 text-center",children:[t.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:e}),t.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono mt-1",children:r}),s&&a&&t.jsx("button",{type:"button",onClick:a,className:"mt-3 rounded-md border border-[hsl(var(--deck-border))] px-2.5 py-1 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]",children:s})]})}function wr(e){return e.flatMap(r=>{var c,i,g;const s=[];if((c=r.agentContent)!=null&&c.toolCalls)for(const u of r.agentContent.toolCalls){const b=mt(u.arguments),f=u.output,h=f?(i=G(f))!=null&&i.diff?pt(f):f:void 0;s.push({id:`${r.id}-${u.toolCallId}`,title:u.toolName||"Tool",subtitle:u.summary,status:u.status==="success"?"success":u.status==="error"?"error":"running",content:h||(b?`Arguments:
6
+ …`]}),E&&t.jsxs("button",{type:"button",onClick:()=>u(H=>({...H,[p.id]:!H[p.id]})),className:"flex items-center gap-1 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:text-[hsl(var(--deck-ink))]",children:[j?t.jsx(bt,{className:"h-3 w-3"}):t.jsx(vt,{className:"h-3 w-3"}),r(j?"preview.logs.collapse":"preview.logs.expand")]})]})]},p.id)}),m<x.length&&t.jsx("div",{className:"flex justify-center",children:t.jsx("button",{type:"button",onClick:()=>h({key:b,count:Math.min(x.length,m+lt)}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:r("preview.logs.showMore",{count:Math.min(lt,x.length-m)})})})]})]})}function dt({title:e,subtitle:r}){return t.jsxs("div",{className:"rounded-lg border border-dashed border-[hsl(var(--deck-border))] p-6 text-center",children:[t.jsx("div",{className:"font-mono text-[13px] text-[hsl(var(--deck-ink))]",children:e}),t.jsx("div",{className:"mt-1 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r})]})}function kr({status:e}){const r=P(),s=r(e==="success"?"preview.logs.status.success":e==="error"?"preview.logs.status.error":"preview.logs.status.running"),a=e==="success"?"bg-[#22C55E] text-white":e==="error"?"bg-[#FEE2E2] text-[#b91c1c] dark:bg-[#EF4444]/20 dark:text-[#fca5a5]":"bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink-muted))]";return t.jsx("span",{className:T("rounded-full px-2 py-0.5 font-mono text-[11px]",a),children:s})}const gr=640,Ct=360,Re=960;function ut(e){const r=typeof window>"u"?Re:Math.max(280,Math.floor(window.innerWidth*.72));return Math.min(Re,r,Math.max(Ct,Math.round(e)))}function St(e,r,s){var a;if(e){const c=(a=s==null?void 0:s.taskDelivery)==null?void 0:a.status;return(s==null?void 0:s.taskIsolation)==="worktree"&&s.taskSourceProjectPath&&(c==="applied"||c==="discarded")?{sessionId:e.sessionId,projectPath:s.taskSourceProjectPath}:e}return r?{sessionId:`project:${r}`,projectPath:r}:null}function Ie(){const e=B.getState(),r=e.sessions.find(s=>V({sessionId:s.sessionId,projectPath:s.projectPath},e.currentSessionRef));return St(e.currentSessionRef,e.selectedProjectPath,r)}function ft(e,r){const s=i=>i.replace(/\\/g,"/").replace(/^\.?\//,"").replace(/\/+/g,"/"),a=s(e),c=s(r);return a===c||a.endsWith(`/${c}`)||c.endsWith(`/${a}`)}const yr=o.lazy(async()=>({default:(await er(()=>import("./index-DI8ZWdWH.js"),__vite__mapDeps([0,1]))).Editor}));function ae(e,r){return e instanceof Error?e.message:r}function Fr({returnFocusElement:e}={}){var Ye,Ze;const r=P(),{toggleFilePreview:s,previewWidth:a,setPreviewWidth:c,previewTab:i,setPreviewTab:g,previewTargetPath:u,previewRequestId:b}=et(),f=B(n=>n.messages),h=B(n=>n.currentSessionRef),x=B(n=>n.sessions),m=B(n=>n.selectedProjectPath),k=o.useMemo(()=>x.find(n=>V({sessionId:n.sessionId,projectPath:n.projectPath},h)),[h,x]),d=o.useMemo(()=>St(h,m,k),[k,h,m]),[N,p]=o.useState(i),[j,S]=o.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 1023px)").matches),[E,A]=o.useState(null),[W,H]=o.useState(!1),[ie,ce]=o.useState([]),[Et,Ae]=o.useState({}),[Dt,We]=o.useState({}),[Tt,Ft]=o.useState(0),[K,le]=o.useState(!1),[U,de]=o.useState(null),[$,ue]=o.useState(""),[Q,J]=o.useState([]),[$e,X]=o.useState(!1),[Lt,Y]=o.useState(!1),[It,Rt]=o.useState(0),[fe,Z]=o.useState(0),[Pt,he]=o.useState({}),[At,ee]=o.useState({}),[F,_e]=o.useState(null),[Wt,pe]=o.useState(""),[me,xe]=o.useState(!1),[be,ve]=o.useState(null),[qe,ke]=o.useState(!1),Me=o.useRef(d),_=o.useRef(0),te=o.useRef(0),q=o.useRef({}),ge=o.useRef(0),re=o.useRef(0),M=o.useRef(0),L=o.useRef({}),ne=o.useRef({}),ye=o.useRef({}),we=o.useRef(null),je=o.useRef(null),ze=o.useRef(null),Be=o.useRef(null),Ne=o.useRef(a),Ge=o.useRef(h);o.useLayoutEffect(()=>{V(Me.current,d)||(_.current+=1),Me.current=d},[d]),o.useEffect(()=>{if(typeof window.matchMedia!="function")return;const n=window.matchMedia("(max-width: 1023px)"),l=()=>S(n.matches);return l(),n.addEventListener("change",l),()=>n.removeEventListener("change",l)},[]),o.useEffect(()=>(Be.current=e??(document.activeElement instanceof HTMLElement?document.activeElement:null),()=>{const n=Be.current;requestAnimationFrame(()=>{n!=null&&n.isConnected&&n.focus({preventScroll:!0})})}),[e]),o.useEffect(()=>{var n;j&&((n=ze.current)==null||n.focus({preventScroll:!0}))},[j]);const $t=n=>{var C;if(!j)return;if(n.key==="Escape"){n.preventDefault(),s();return}if(n.key!=="Tab")return;const l=Array.from(((C=je.current)==null?void 0:C.querySelectorAll('button:not([disabled]), input:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))??[]).filter(w=>!w.hasAttribute("hidden"));if(l.length===0)return;const y=l[0],v=l[l.length-1];n.shiftKey&&document.activeElement===y?(n.preventDefault(),v==null||v.focus()):!n.shiftKey&&document.activeElement===v&&(n.preventDefault(),y==null||y.focus())},O=(n,l)=>l===_.current&&V(Ie(),n),He=async(n,l="")=>{const y=l?`/suggestions/files/tree?path=${encodeURIComponent(l)}`:"/suggestions/files/tree",v=await fetch(y,{headers:Te(n)});if(!v.ok)throw new Error(r("preview.files.treeFailed"));return(await v.json()).map(w=>({...w,children:w.type==="dir"?[]:void 0}))};o.useEffect(()=>{const n=++te.current;return(async()=>{if(!d){ce([]),le(!1),de(null);return}const y={...d},v=_.current,C=()=>n===te.current&&O(y,v);if(C()){ce([]),le(!0),de(null);try{const w=await He(y);C()&&ce(w)}catch(w){C()&&de(ae(w,r("preview.files.treeFailed")))}finally{C()&&le(!1)}}})(),()=>{te.current===n&&(te.current+=1)}},[Tt,d==null?void 0:d.projectPath,d==null?void 0:d.sessionId]),o.useEffect(()=>{we.current=null,L.current={},ne.current={},ye.current={},q.current={},ge.current+=1,_e(null),pe(""),xe(!1),ve(null),ke(!1),he({}),Ae({}),We({}),ue(""),J([]),X(!1),Y(!1),Z(0),ee({})},[d==null?void 0:d.projectPath,d==null?void 0:d.sessionId]);const _t=o.useMemo(()=>jr(f),[f]),[qt,Oe]=o.useState(null),[Mt,Ce]=o.useState(!1),[Ve,Ke]=o.useState(null),[zt,Bt]=o.useState(0),Se=(k==null?void 0:k.taskIsolation)==="worktree"&&((Ye=k.taskDelivery)==null?void 0:Ye.status)==="discarded",Ue=(k==null?void 0:k.taskIsolation)==="worktree"&&!!k.taskDiffStat&&!Se,Qe=Ue&&!!(k!=null&&k.taskDiffStat&&k.taskDiffStat.changedFiles>0),I=Se?[]:Ue?qt??[]:_t,Gt=o.useMemo(()=>wr(f),[f]);o.useEffect(()=>{const n=$.trim(),l=++re.current;if(Z(0),Y(!1),!n||N!=="files"||!d){J([]),X(!1);return}const y={...d},v=_.current;X(!0);const C=window.setTimeout(()=>{fetch(`/suggestions/files?q=${encodeURIComponent(n)}&limit=100&type=file`,{headers:Te(y)}).then(async w=>{if(!w.ok)throw new Error(r("preview.files.searchFailed"));return await w.json()}).then(w=>{l===re.current&&O(y,v)&&(J(w.filter(D=>!D.endsWith("/"))),Y(!1))}).catch(()=>{l===re.current&&O(y,v)&&(J([]),Y(!0))}).finally(()=>{l===re.current&&X(!1)})},160);return()=>window.clearTimeout(C)},[N,$,It,d==null?void 0:d.projectPath,d==null?void 0:d.sessionId]),o.useEffect(()=>{p(et.getState().previewTab)},[b]),o.useEffect(()=>{const n=Ge.current;Ge.current=h,!h&&m&&(n||N!=="files")&&(p("files"),g("files"))},[N,h==null?void 0:h.projectPath,h==null?void 0:h.sessionId,m,g]),o.useEffect(()=>{var y;if(!u||N!=="diff")return;const n=(y=I.find(v=>v.filePath&&ft(v.filePath,u)))==null?void 0:y.filePath;if(!n)return;ee(v=>({...v,[n]:!0}));const l=requestAnimationFrame(()=>{var C,w;const v=Array.from(((C=je.current)==null?void 0:C.querySelectorAll("[data-preview-diff-path]"))??[]).find(D=>ft(D.dataset.previewDiffPath??"",u));typeof(v==null?void 0:v.scrollIntoView)=="function"&&v.scrollIntoView({block:"nearest",behavior:"smooth"}),(w=v==null?void 0:v.querySelector("button"))==null||w.focus({preventScroll:!0})});return()=>cancelAnimationFrame(l)},[N,I,b,u]),o.useEffect(()=>{const n=++M.current;if(Oe(null),Ke(null),Ce(!1),!h||!Qe)return;const l={...h};return Ce(!0),Xt.getTaskDiff(l).then(y=>{n!==M.current||!V(B.getState().currentSessionRef,l)||Oe(y.files.map(v=>({filePath:v.path,diff:{patch:v.patch},summary:v.binary?"binary":`+${v.additions} -${v.deletions}${v.truncated?" (truncated)":""}`})))}).catch(y=>{n===M.current&&Ke(ae(y,r("preview.diff.failedTitle")))}).finally(()=>{n===M.current&&Ce(!1)}),()=>{M.current===n&&(M.current+=1)}},[k==null?void 0:k.taskCompletedAt,(Ze=k==null?void 0:k.taskDelivery)==null?void 0:Ze.status,k==null?void 0:k.taskDiffStat,k==null?void 0:k.taskIsolation,h,Qe,zt]);const Ht=n=>{ee(l=>({...l,[n]:!l[n]}))},Ot=n=>{ee(Object.fromEntries(I.map(l=>[l.filePath||"unknown",n])))},se=async n=>{const l=Ie();if(!l)return;const y=_.current,v=++ge.current,C=()=>v===ge.current&&we.current===n&&O(l,y);we.current=n,_e(n),pe(""),xe(!0),ve(null),ke(!1);try{const w=await fetch(`/suggestions/files/content?path=${encodeURIComponent(n)}`,{headers:Te(l)});if(!w.ok)throw new Error(r("preview.files.contentFailed"));const D=await w.json();C()&&(pe(D.content||""),ke(!!D.truncated))}catch(w){C()&&ve(ae(w,r("preview.files.contentFailed")))}finally{C()&&xe(!1)}},Vt=n=>{if(n.key==="ArrowDown"||n.key==="ArrowUp"){n.preventDefault(),Z(l=>pr(l,Q.length,n.key==="ArrowDown"?1:-1));return}if(n.key==="Enter"){const l=Q[fe];if(!l)return;n.preventDefault(),se(l);return}n.key==="Escape"&&(n.preventDefault(),ue(""))},Ee=(n,l)=>{const y={...ye.current,[n]:l};ye.current=y,We(y)},Je=async n=>{const l=(q.current[n]??0)+1;q.current[n]=l,Ee(n,{status:"loading"});const y=Ie();if(!y)return;const v=_.current,C=()=>q.current[n]===l&&L.current[n]===!0&&O(y,v);try{const w=await He(y,n);if(C()){const D={...ne.current,[n]:w};ne.current=D,Ae(D),Ee(n,{status:"loaded"})}}catch(w){C()&&Ee(n,{status:"error",message:ae(w,r("preview.files.treeFailed"))})}},Kt=n=>{const l=!L.current[n],y={...L.current,[n]:l};if(L.current=y,he(y),!l){q.current[n]=(q.current[n]??0)+1;return}ne.current[n]||Je(n)},Ut=n=>{if(!L.current[n]){const l={...L.current,[n]:!0};L.current=l,he(l)}Je(n)},Qt=n=>{n.preventDefault(),n.currentTarget.setPointerCapture(n.pointerId),Ne.current=a,H(!0),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},Jt=n=>{if(!W)return;const l=ut(window.innerWidth-n.clientX);Ne.current=l,A(l)},Xe=n=>{W&&(n.currentTarget.hasPointerCapture(n.pointerId)&&n.currentTarget.releasePointerCapture(n.pointerId),H(!1),A(null),c(Ne.current),document.body.style.cursor="",document.body.style.userSelect="")};o.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect=""},[]);const De=ut(E??a);return t.jsxs("div",{ref:je,"data-testid":"file-preview",role:j?"dialog":"complementary","aria-modal":j||void 0,"aria-label":r("preview.title"),onKeyDown:$t,style:{width:De,maxWidth:"72vw"},className:"relative flex h-full min-w-[360px] shrink-0 flex-col border-l border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] shadow-xl max-lg:fixed max-lg:inset-0 max-lg:z-[60] max-lg:!h-dvh max-lg:!w-full max-lg:!max-w-full max-lg:min-w-0 max-lg:border-l-0",children:[t.jsx("div",{role:"separator","aria-label":r("preview.action.resize"),"aria-orientation":"vertical","aria-valuemin":Ct,"aria-valuemax":Re,"aria-valuenow":De,"aria-hidden":j||void 0,tabIndex:j?-1:0,onPointerDown:Qt,onPointerMove:Jt,onPointerUp:Xe,onPointerCancel:Xe,onDoubleClick:()=>c(gr),onKeyDown:n=>{n.key!=="ArrowLeft"&&n.key!=="ArrowRight"||(n.preventDefault(),c(De+(n.key==="ArrowLeft"?24:-24)))},className:T("absolute inset-y-0 -left-1 z-20 w-2 cursor-col-resize touch-none outline-none max-lg:hidden","after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-transparent after:transition-colors","hover:after:bg-[hsl(var(--deck-accent)/0.6)] focus-visible:after:bg-[hsl(var(--deck-accent))]",W&&"after:bg-[hsl(var(--deck-accent))]")}),t.jsxs("div",{className:"flex items-center justify-between px-4 h-12 border-b border-[hsl(var(--deck-border))] shrink-0",children:[t.jsx("span",{className:"font-normal text-[13px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r("preview.title")}),t.jsx(Yt,{ref:ze,variant:"ghost",size:"icon",onClick:s,"aria-label":r("preview.action.close"),title:r("preview.action.close"),className:"h-8 w-8 text-[hsl(var(--deck-ink-faint))] hover:text-[hsl(var(--deck-ink))] hover:bg-[hsl(var(--deck-surface))]",children:t.jsx(or,{className:"w-4 h-4"})})]}),t.jsxs(ir,{value:N,onValueChange:n=>{const l=n;p(l),g(l)},className:"flex flex-col flex-1 min-h-0",children:[t.jsx("div",{className:"px-4 py-3 border-b border-[hsl(var(--deck-border))]",children:t.jsxs(cr,{className:"bg-[hsl(var(--deck-surface))] border border-[hsl(var(--deck-border))] h-9 p-1 rounded-md w-full justify-start",children:[t.jsx(Fe,{value:"diff",className:"text-[12px] font-mono px-3 text-[hsl(var(--deck-ink-muted))] data-[state=active]:bg-[hsl(var(--deck-canvas-veil))] data-[state=active]:text-[hsl(var(--deck-ink))]",children:r("preview.tab.diff")}),t.jsx(Fe,{value:"files",className:"text-[12px] font-mono px-3 text-[hsl(var(--deck-ink-muted))] data-[state=active]:bg-[hsl(var(--deck-canvas-veil))] data-[state=active]:text-[hsl(var(--deck-ink))]",children:r("preview.tab.files")}),t.jsx(Fe,{value:"logs",className:"text-[12px] font-mono px-3 text-[hsl(var(--deck-ink-muted))] data-[state=active]:bg-[hsl(var(--deck-canvas-veil))] data-[state=active]:text-[hsl(var(--deck-ink))]",children:r("preview.tab.logs")})]})}),t.jsx(Le,{value:"diff",className:"overflow-hidden flex-1 mt-0",children:t.jsx("div",{className:"overflow-y-auto px-4 py-4 space-y-3 h-full",children:Se?t.jsx(R,{title:r("preview.diff.discardedTitle"),subtitle:r("preview.diff.discardedHint"),role:"status"}):Mt&&I.length===0?t.jsx(R,{title:r("preview.diff.loadingTitle"),subtitle:r("preview.diff.loadingHint")}):Ve&&I.length===0?t.jsx(R,{title:r("preview.diff.failedTitle"),subtitle:Ve,actionLabel:r("preview.action.retry"),onAction:()=>Bt(n=>n+1),role:"alert"}):I.length===0?t.jsx(R,{title:r("preview.diff.emptyTitle"),subtitle:r("preview.diff.emptyHint")}):t.jsx(mr,{diffs:I,expanded:At,targetPath:u,onToggle:Ht,onSetAllExpanded:Ot})})}),t.jsx(Le,{value:"files",className:"overflow-hidden flex-1 mt-0",children:t.jsxs("div",{className:"px-4 py-4 h-full",children:[K&&t.jsx(R,{title:r("preview.files.loadingTitle"),subtitle:r("preview.files.loadingHint")}),!K&&U&&t.jsx(R,{title:r("preview.files.failedTitle"),subtitle:U,actionLabel:r("preview.action.retry"),onAction:()=>Ft(n=>n+1),role:"alert"}),!K&&!U&&ie.length===0&&t.jsx(R,{title:r("preview.files.emptyTitle"),subtitle:r("preview.files.emptyHint")}),!K&&!U&&ie.length>0&&t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-[minmax(170px,220px)_minmax(0,1fr)] gap-3 max-sm:grid-cols-1 max-sm:grid-rows-[180px_minmax(0,1fr)]",children:[t.jsxs("div",{className:"flex min-h-0 flex-col overflow-hidden rounded-lg border border-[hsl(var(--deck-border))]",children:[t.jsx("div",{className:"border-b border-[hsl(var(--deck-border))] p-2",children:t.jsxs("div",{className:"flex h-8 items-center gap-2 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 focus-within:border-[hsl(var(--deck-accent)/0.6)]",children:[t.jsx(Pe,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),t.jsx("input",{type:"search","aria-label":r("preview.files.searchAria"),placeholder:r("preview.files.searchPlaceholder"),value:$,onChange:n=>ue(n.target.value),onKeyDown:Vt,className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))]"}),$e&&t.jsx(gt,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"})]})}),t.jsx("div",{role:$?"listbox":void 0,"aria-label":$?r("preview.files.searchResultsAria"):void 0,className:"min-h-0 flex-1 overflow-y-auto p-2",children:$?Lt?t.jsxs("div",{role:"alert",className:"px-2 py-5 text-center font-mono text-[10.5px] text-red-700 dark:text-red-300",children:[t.jsx("div",{children:r("preview.files.searchFailed")}),t.jsx("button",{type:"button",onClick:()=>Rt(n=>n+1),className:"mt-1 underline underline-offset-2",children:r("preview.action.retry")})]}):Q.length>0?Q.map((n,l)=>t.jsxs("button",{type:"button",role:"option","aria-selected":l===fe,"data-preview-file-result":l,onMouseEnter:()=>Z(l),onClick:()=>void se(n),className:T("mb-0.5 flex w-full min-w-0 flex-col rounded-md px-2 py-1.5 text-left font-mono transition-colors",l===fe?"bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-surface))]"),children:[t.jsx("span",{className:"truncate text-[11.5px]",children:jt(n)}),t.jsx("span",{className:"truncate text-[9px] text-[hsl(var(--deck-ink-faint))]",children:n})]},n)):!$e&&t.jsx("div",{className:"px-2 py-5 text-center font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:r("preview.files.noMatches")}):t.jsx(br,{nodes:ie,expandedDirs:Pt,childrenCache:Et,directoryStates:Dt,selectedPath:F,onToggleDir:Kt,onRetryDir:Ut,onSelectFile:se})})]}),t.jsxs("div",{className:"border border-[hsl(var(--deck-border))] rounded-lg overflow-hidden flex flex-col min-h-0",children:[t.jsxs("div",{className:"px-3 py-2 bg-[hsl(var(--deck-surface-2))] border-b border-[hsl(var(--deck-border))] text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono flex items-center justify-between",children:[t.jsx("span",{className:"min-w-0 truncate",children:F||r("preview.files.selectTitle")}),F&&t.jsx("span",{className:"ml-2 shrink-0 text-[11px] text-[hsl(var(--deck-ink-faint))] font-mono",children:r(me?"preview.files.status.loading":qe?"preview.files.status.truncated":"preview.files.status.ready")})]}),qe&&!me&&t.jsx("div",{className:"px-3 py-2 bg-[#FEF3C7] dark:bg-[#111113] border-b border-[hsl(var(--deck-border))] text-[11px] text-[#b45309] dark:text-[#facc15] font-mono",children:r("preview.files.truncatedNotice")}),t.jsxs("div",{className:"flex-1 min-h-0",children:[!F&&t.jsx("div",{className:"h-full flex items-center justify-center text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r("preview.files.pickHint")}),F&&be&&t.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2 px-4 text-center font-mono text-[12px] text-[#DC2626] dark:text-[#fca5a5]",children:[t.jsx("span",{children:be}),t.jsx("button",{type:"button",onClick:()=>void se(F),className:"underline underline-offset-2",children:r("preview.action.retry")})]}),F&&!be&&t.jsx("div",{className:"h-full",children:me?t.jsx(xt,{}):t.jsx(o.Suspense,{fallback:t.jsx(xt,{}),children:t.jsx(Nr,{content:Wt,filename:F})})})]})]})]})]})}),t.jsx(Le,{value:"logs",className:"overflow-hidden flex-1 mt-0",children:t.jsx(vr,{logs:Gt})})]})]})}function R({title:e,subtitle:r,actionLabel:s,onAction:a,role:c}){return t.jsxs("div",{role:c,className:"border border-dashed border-[hsl(var(--deck-border))] rounded-lg p-6 text-center",children:[t.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:e}),t.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono mt-1",children:r}),s&&a&&t.jsx("button",{type:"button",onClick:a,className:"mt-3 rounded-md border border-[hsl(var(--deck-border))] px-2.5 py-1 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]",children:s})]})}function wr(e){return e.flatMap(r=>{var c,i,g;const s=[];if((c=r.agentContent)!=null&&c.toolCalls)for(const u of r.agentContent.toolCalls){const b=mt(u.arguments),f=u.output,h=f?(i=G(f))!=null&&i.diff?pt(f):f:void 0;s.push({id:`${r.id}-${u.toolCallId}`,title:u.toolName||"Tool",subtitle:u.summary,status:u.status==="success"?"success":u.status==="error"?"error":"running",content:h||(b?`Arguments:
7
7
  ${b}`:void 0),timestamp:r.timestamp})}const a=r.metadata;if(a){if(a.kind==="tool_call"){const u=a.toolName||"Tool",b=mt(a.arguments);s.push({id:r.id,title:`Tool Call · ${u}`,subtitle:a.toolKind?String(a.toolKind):void 0,status:a.status==="success"?"success":a.status==="error"?"error":"running",content:b?`Arguments:
8
8
  ${b}`:void 0,timestamp:r.timestamp})}if(a.kind==="tool_result"){const u=a.toolName||"Tool",b=a.success,f=a.summary,h=a.output,x=h?(g=G(h))!=null&&g.diff?pt(h):h:void 0;s.push({id:r.id,title:`Tool Result · ${u}`,subtitle:f,status:b===void 0?"running":b?"success":"error",content:x,timestamp:r.timestamp})}}return s})}function jr(e){var a;const r=[],s=new Set;for(let c=e.length-1;c>=0;c-=1){const i=e[c];if((a=i.agentContent)!=null&&a.toolCalls)for(let h=i.agentContent.toolCalls.length-1;h>=0;h-=1){const x=i.agentContent.toolCalls[h],m=x.metadata;if((m==null?void 0:m.kind)==="patch"&&Array.isArray(m.changes)){ht(r,s,m.changes,x.summary);continue}const k=x.output||"",d=G(k)||G((m==null?void 0:m.diff_snippet)||"");if(d!=null&&d.diff){const N=(m==null?void 0:m.file_path)||x.toolName||"unknown";if(!s.has(N)){s.add(N);const p=typeof(m==null?void 0:m.oldContent)=="string"?m.oldContent:void 0,j=typeof(m==null?void 0:m.newContent)=="string"?m.newContent:void 0;r.push({diff:d.diff,filePath:N,summary:x.summary,oldContent:p,newContent:j})}}}const g=i.metadata;if(!g||g.kind!=="tool_result")continue;const u=g.metadata;if((u==null?void 0:u.kind)==="patch"&&Array.isArray(u.changes)){ht(r,s,u.changes,g.summary);continue}const b=g.output||(typeof i.content=="string"?i.content:"")||"",f=G(b)||G((u==null?void 0:u.diff_snippet)||"");if(f!=null&&f.diff){const h=(u==null?void 0:u.file_path)||g.toolName||"unknown";if(!s.has(h)){s.add(h);const x=typeof(u==null?void 0:u.oldContent)=="string"?u.oldContent:void 0,m=typeof(u==null?void 0:u.newContent)=="string"?u.newContent:void 0;r.push({diff:f.diff,filePath:h,summary:g.summary,oldContent:x,newContent:m})}}}return r.reverse()}function ht(e,r,s,a){for(let c=s.length-1;c>=0;c--){const i=s[c];!i||typeof i!="object"||!("path"in i)||typeof i.path!="string"||!("diff"in i)||typeof i.diff!="string"||r.has(i.path)||(r.add(i.path),e.push({diff:{patch:i.diff,startLine:1,matchLine:1},filePath:i.path,summary:a,oldContent:"oldContent"in i&&typeof i.oldContent=="string"?i.oldContent:void 0,newContent:"newContent"in i&&typeof i.newContent=="string"?i.newContent:void 0}))}}function G(e){if(!e)return null;const r=/<<<DIFF>>>\s*([\s\S]*?)\s*<<<\/DIFF>>>/m,s=e.match(r);if(!s)return null;try{return{diff:JSON.parse(s[1])}}catch{return null}}function pt(e){return e?e.replace(/<<<DIFF>>>[\s\S]*?<<<\/DIFF>>>/m,"").trim():""}function mt(e){if(!e)return"";if(typeof e=="string")try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}return JSON.stringify(e,null,2)}function xt(){const e=P();return t.jsx("div",{className:"h-full flex items-center justify-center text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:e("preview.files.editorLoading")})}function Nr({content:e,filename:r}){const{theme:s}=Zt(),a=o.useRef(null),[c,i]=o.useState("vs-dark"),g=Cr(r),u=b=>{a.current=b;const f=rt(b,s);i(f)};return o.useEffect(()=>{if(a.current){const b=rt(a.current,s);i(b)}},[s]),t.jsx(yr,{value:e,language:g,theme:c,height:"100%",beforeMount:u,options:{readOnly:!0,minimap:{enabled:!1},fontSize:12,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0}},r)}function Cr(e){var a;const r=((a=e.split(".").pop())==null?void 0:a.toLowerCase())||"";return{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",json:"json",md:"markdown",css:"css",scss:"scss",html:"html",yml:"yaml",yaml:"yaml",go:"go",rs:"rust",py:"python",java:"java",c:"c",cpp:"cpp",h:"cpp",hpp:"cpp",sh:"shell",zsh:"shell",toml:"toml",xml:"xml"}[r]||"plaintext"}export{Fr as FilePreview};