blade-code 0.10.65 → 0.10.66

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 (107) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-czb954vz.js → chunk-0j22w4wh.js} +1 -1
  3. package/dist/{chunk-tb4jmrkp.js → chunk-0qtrv97b.js} +1 -1
  4. package/dist/chunk-0scxrkcf.js +1 -0
  5. package/dist/{chunk-eg5mh9m9.js → chunk-0wxkymqv.js} +1 -1
  6. package/dist/{chunk-s16x4qkb.js → chunk-1c69c4rd.js} +1 -1
  7. package/dist/{chunk-ca5mm1gk.js → chunk-1z9wct9w.js} +1 -1
  8. package/dist/chunk-2eq5dyga.js +1 -0
  9. package/dist/{chunk-h127mgg2.js → chunk-2kkpn41a.js} +2 -2
  10. package/dist/{chunk-j6w1vf2q.js → chunk-2xk6m4fc.js} +12 -3
  11. package/dist/{chunk-ka2kn5bs.js → chunk-30kmydfj.js} +2 -2
  12. package/dist/{chunk-yrtmkb4a.js → chunk-4sztphe9.js} +1 -1
  13. package/dist/{chunk-5qaacj3x.js → chunk-50jthhfq.js} +1 -1
  14. package/dist/{chunk-ky32s7az.js → chunk-5147jh26.js} +1 -1
  15. package/dist/{chunk-aphcj8rz.js → chunk-5d2cdvdy.js} +1 -1
  16. package/dist/chunk-69j98a7j.js +166 -0
  17. package/dist/{chunk-ngmajm4h.js → chunk-6pyktfa4.js} +1 -1
  18. package/dist/chunk-89090tyx.js +1 -0
  19. package/dist/chunk-8c677xtx.js +1 -0
  20. package/dist/{chunk-zxwdtn6q.js → chunk-8nmwft1y.js} +9 -9
  21. package/dist/{chunk-1vt7e9e7.js → chunk-98n2rxmq.js} +2 -2
  22. package/dist/{chunk-57gp2px5.js → chunk-a2594p5r.js} +1 -1
  23. package/dist/{chunk-wzkr0p09.js → chunk-a3xnd8cg.js} +2 -2
  24. package/dist/{chunk-svczh6hn.js → chunk-abef6dq1.js} +2 -2
  25. package/dist/chunk-ax9ftraa.js +1 -0
  26. package/dist/{chunk-sbpb7pcc.js → chunk-b66veqye.js} +2 -2
  27. package/dist/{chunk-a1m7wr7r.js → chunk-bbcb9jzb.js} +1 -1
  28. package/dist/{chunk-5gjqdbxb.js → chunk-bjqjdw34.js} +2 -2
  29. package/dist/chunk-c8zcyvss.js +1 -0
  30. package/dist/{chunk-hbbpe5f0.js → chunk-cdy9efgm.js} +1 -1
  31. package/dist/chunk-dc64v4sa.js +1 -0
  32. package/dist/{chunk-s1xp6g8m.js → chunk-dktrankr.js} +1 -1
  33. package/dist/chunk-e7pssnr9.js +1 -0
  34. package/dist/chunk-eq99gcj8.js +1 -0
  35. package/dist/{chunk-y51v2jvh.js → chunk-f99n8812.js} +2 -2
  36. package/dist/{chunk-015t2dey.js → chunk-gezg1mpa.js} +1 -1
  37. package/dist/{chunk-1jm8njkw.js → chunk-h0ft81a3.js} +1 -1
  38. package/dist/{chunk-5ntrhs8k.js → chunk-ha50z8dp.js} +1 -1
  39. package/dist/{chunk-k4t45b64.js → chunk-hat9v5c5.js} +1 -1
  40. package/dist/{chunk-arzhhj0e.js → chunk-hcv17986.js} +1 -1
  41. package/dist/{chunk-zpwasxzh.js → chunk-j38jh128.js} +2 -2
  42. package/dist/chunk-jmjn6zcc.js +1 -0
  43. package/dist/{chunk-d39xaa7w.js → chunk-k0pa8874.js} +1 -1
  44. package/dist/{chunk-pfmmvpfh.js → chunk-k99r5c4v.js} +3 -3
  45. package/dist/chunk-kmarzy98.js +1 -0
  46. package/dist/{chunk-m6a1c1tg.js → chunk-kv0bkxhd.js} +1 -1
  47. package/dist/{chunk-2yxdneb9.js → chunk-m57w4p91.js} +1 -1
  48. package/dist/{chunk-4t89y8nj.js → chunk-nt55nz8d.js} +40 -40
  49. package/dist/chunk-p0b4mv7e.js +10 -0
  50. package/dist/{chunk-6tacv9rs.js → chunk-ppsvzgs5.js} +2 -2
  51. package/dist/{chunk-e11kmyt3.js → chunk-pzb5sqwd.js} +1 -1
  52. package/dist/{chunk-9yvw5xy3.js → chunk-q3mfescm.js} +2 -2
  53. package/dist/{chunk-98qmtexa.js → chunk-qdah5kkc.js} +243 -243
  54. package/dist/{chunk-rd7jwwse.js → chunk-rf01e14b.js} +1 -1
  55. package/dist/chunk-rhs1dv6w.js +1 -0
  56. package/dist/{chunk-53tb8vvv.js → chunk-s7jsadnc.js} +2 -2
  57. package/dist/{chunk-793067rd.js → chunk-t2gq918a.js} +2 -2
  58. package/dist/chunk-t89q7d03.js +22 -0
  59. package/dist/{chunk-gafk33py.js → chunk-t8xmh4w2.js} +1 -1
  60. package/dist/{chunk-9ebwtazz.js → chunk-te21eb71.js} +1 -1
  61. package/dist/{chunk-edd8n5r0.js → chunk-th4jjfgm.js} +1 -1
  62. package/dist/{chunk-7mdbwjxj.js → chunk-v0rsz1rt.js} +1 -1
  63. package/dist/{chunk-z228cmc5.js → chunk-w6p2hcfw.js} +1 -1
  64. package/dist/{chunk-ejsggxs4.js → chunk-xny9q252.js} +2 -2
  65. package/dist/chunk-xz6y0w4n.js +2 -0
  66. package/dist/{chunk-rabt8yyf.js → chunk-ybv6stfh.js} +2 -2
  67. package/dist/{chunk-5ha0vf37.js → chunk-yn51162x.js} +1 -1
  68. package/dist/{chunk-eharmsjt.js → chunk-ypqp368c.js} +2 -2
  69. package/dist/{chunk-r94jtbd2.js → chunk-yvg961q3.js} +1 -1
  70. package/dist/chunk-yy6h97k0.js +1 -0
  71. package/dist/{chunk-a49dy92d.js → chunk-zdxxqchm.js} +2 -2
  72. package/dist/chunk-zk42hrdh.js +1 -0
  73. package/dist/{chunk-bnp9asmd.js → chunk-zvz2cnt4.js} +1 -1
  74. package/dist/web/assets/{ChatView-Jfq-sqKG.js → ChatView-BVrhnE2j.js} +6 -6
  75. package/dist/web/assets/{CodeBlockHighlighter-C9DvlG-V.js → CodeBlockHighlighter-Dy7QpAmC.js} +1 -1
  76. package/dist/web/assets/{FilePreview-YPtQcXr3.js → FilePreview-BI3nkxz1.js} +2 -2
  77. package/dist/web/assets/KanbanBoard-D5dYOyPH.js +1 -0
  78. package/dist/web/assets/{MarkdownRenderer-CpUKw2Gk.js → MarkdownRenderer-Da1vB81L.js} +12 -12
  79. package/dist/web/assets/{SettingsModal-BfDHa4xn.js → SettingsModal-jcCFqLqS.js} +2 -2
  80. package/dist/web/assets/TaskSwitcher-CQ--jOLB.js +1 -0
  81. package/dist/web/assets/{TerminalPanel-CDq3_gCr.js → TerminalPanel-CWzjEXOb.js} +1 -1
  82. package/dist/web/assets/index-BOgOL4hG.js +11 -0
  83. package/dist/web/assets/index-DbWgTuT3.css +1 -0
  84. package/dist/web/assets/{vendor-icons-ICv1v-tf.js → vendor-icons-B63aW_OM.js} +82 -62
  85. package/dist/web/index.html +3 -3
  86. package/package.json +2 -2
  87. package/dist/chunk-0h74p1h8.js +0 -1
  88. package/dist/chunk-18nkg8hr.js +0 -1
  89. package/dist/chunk-197qz36b.js +0 -1
  90. package/dist/chunk-2vdq0fav.js +0 -1
  91. package/dist/chunk-4a75gwa1.js +0 -1
  92. package/dist/chunk-76ks3ygm.js +0 -10
  93. package/dist/chunk-8wvk5rgg.js +0 -1
  94. package/dist/chunk-98vestg4.js +0 -22
  95. package/dist/chunk-b7p7ywe6.js +0 -1
  96. package/dist/chunk-cxc2q3yy.js +0 -1
  97. package/dist/chunk-fv3aggr5.js +0 -1
  98. package/dist/chunk-fz60jh3y.js +0 -2
  99. package/dist/chunk-m19xed90.js +0 -1
  100. package/dist/chunk-mr5c4yzr.js +0 -1
  101. package/dist/chunk-pr8a6xfm.js +0 -1
  102. package/dist/chunk-pwehsv52.js +0 -159
  103. package/dist/chunk-w4eskwzj.js +0 -1
  104. package/dist/chunk-y8zk4r3y.js +0 -1
  105. package/dist/web/assets/TaskSwitcher-DacXxQcV.js +0 -1
  106. package/dist/web/assets/index-Dxdnbd79.css +0 -1
  107. package/dist/web/assets/index-t4mGaG1Z.js +0 -11
@@ -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,I as Te,k as Xt,J as Yt,w as Zt,_ as er}from"./index-t4mGaG1Z.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";import"./session-events-BvtUOaNG.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,O as Te,k as Xt,r as Yt,F as Zt,_ as er}from"./index-BOgOL4hG.js";import{r as o,j as t}from"./vendor-react-DG5dkZ_t.js";import{l as Pe,a5 as tr,aq as rr,z as bt,n as vt,t as kt,L as gt,d as nr,ap as sr,R as ar,X as or}from"./vendor-icons-B63aW_OM.js";import"./vendor-radix-DXRuAJHH.js";import"./session-events-BvtUOaNG.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(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 Lr({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(""),[J,Q]=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(""),Q([]),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,Je=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){Q([]),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)&&(Q(w.filter(D=>!D.endsWith("/"))),Y(!1))}).catch(()=>{l===re.current&&O(y,v)&&(Q([]),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||!Je)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,Je,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,J.length,n.key==="ArrowDown"?1:-1));return}if(n.key==="Enter"){const l=J[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)},Qe=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]||Qe(n)},Ut=n=>{if(!L.current[n]){const l={...L.current,[n]:!0};L.current=l,he(l)}Qe(n)},Jt=n=>{n.preventDefault(),n.currentTarget.setPointerCapture(n.pointerId),Ne.current=a,H(!0),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},Qt=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:Jt,onPointerMove:Qt,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")})]}):J.length>0?J.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(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 Lr({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(""),[J,Q]=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(""),Q([]),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,Je=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){Q([]),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)&&(Q(w.filter(D=>!D.endsWith("/"))),Y(!1))}).catch(()=>{l===re.current&&H(y,v)&&(Q([]),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||!Je)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,Je,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,J.length,n.key==="ArrowDown"?1:-1));return}if(n.key==="Enter"){const l=J[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)},Qe=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]||Qe(n)},Ut=n=>{if(!L.current[n]){const l={...L.current,[n]:!0};L.current=l,he(l)}Qe(n)},Jt=n=>{n.preventDefault(),n.currentTarget.setPointerCapture(n.pointerId),Ne.current=a,O(!0),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},Qt=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:Jt,onPointerMove:Qt,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")})]}):J.length>0?J.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{codeTheme: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{Lr as FilePreview};
@@ -0,0 +1 @@
1
+ import{j as e,r as p}from"./vendor-react-DG5dkZ_t.js";import{u as V,c as g,d as M,o as ne,p as pe,j as P,q as be,D as fe,e as ve,f as ge,g as je,h as Ne,i as ye,r as ee,a as o,t as we,b as U,v as Se,P as Pe}from"./index-BOgOL4hG.js";import{a9 as re,aa as Te,ab as Ce,L as E,R as De,S as Ie,P as Ae,A as _e,J as Ke,V as Ee,f as Fe,ac as Re,e as se,ad as Oe,a4 as qe,a3 as Le,i as Me,l as Be,c as ze,W as Qe,a as Ue}from"./vendor-icons-B63aW_OM.js";import"./vendor-radix-DXRuAJHH.js";import"./session-events-BvtUOaNG.js";const G=["waiting","active","blocked","review"],ae={high:0,medium:1,low:2};function Ve(t){return t.taskIsolation!==void 0||t.taskPromptSummary!==void 0||t.taskRetryAvailable===!0}function te(t){return t.taskSourceProjectPath||t.projectPath}function Ye(t){return t.pendingInteraction?"blocked":t.taskStatus==="queued"?"waiting":t.taskStatus==="running"?"active":t.taskStatus==="completed"?"review":"blocked"}function He(t,r){if(t.pendingInteraction!==r.pendingInteraction)return t.pendingInteraction?-1:1;const i=ae[t.taskPriority??"medium"]-ae[r.taskPriority??"medium"];if(i!==0)return i;const u=t.taskDueAt?Date.parse(t.taskDueAt):Number.POSITIVE_INFINITY,n=r.taskDueAt?Date.parse(r.taskDueAt):Number.POSITIVE_INFINITY;if(u!==n)return u-n;if(t.taskStatus==="queued"&&r.taskStatus==="queued"){const m=(t.taskQueuePosition??Number.POSITIVE_INFINITY)-(r.taskQueuePosition??Number.POSITIVE_INFINITY);if(m!==0)return m}return r.lastMessageTime.localeCompare(t.lastMessageTime)}function We(t){const r={waiting:[],active:[],blocked:[],review:[]};for(const i of t)Ve(i)&&r[Ye(i)].push(i);for(const i of G)r[i].sort(He);return r}function $e(t){return`TASK-${t.replace(/^task-?/,"").slice(0,6).toUpperCase()}`}const Ge={high:{label:"kanban.priority.high",className:"border-red-200 bg-red-50 text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300"},medium:{label:"kanban.priority.medium",className:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/70 dark:bg-amber-950/35 dark:text-amber-300"},low:{label:"kanban.priority.low",className:"border-zinc-200 bg-zinc-50 text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400"}},Je={feature:"kanban.kind.feature",bug:"kanban.kind.bug",maintenance:"kanban.kind.maintenance",research:"kanban.kind.research"};function Xe(t){const r=new Date(t);return Number.isNaN(r.getTime())?"":new Intl.DateTimeFormat(be()==="zh"?"zh-CN":"en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}function K({label:t,onClick:r,disabled:i,tone:u="neutral",children:n}){return e.jsx("button",{type:"button","aria-label":t,title:t,disabled:i,onClick:r,className:P("flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:cursor-wait disabled:opacity-45",u==="danger"?"text-red-500 hover:bg-red-500/10 focus-visible:ring-red-500":u==="accent"?"text-[hsl(var(--deck-accent))] hover:bg-[hsl(var(--deck-accent-soft))] focus-visible:ring-[hsl(var(--deck-accent))]":"text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface-2))] hover:text-[hsl(var(--deck-ink))] focus-visible:ring-[hsl(var(--deck-accent))]"),children:n})}function Ze({session:t,unread:r,cancelling:i,retrying:u,updating:n,onOpen:m,onInspect:T,onEdit:C,onCancel:y,onRetry:c,onArchive:k}){const l=V(),w=g(t),f=M(w),b=ne(t,l),v=Ge[t.taskPriority??"medium"],x=t.taskKind??"feature",h=pe(t,l),D=t.taskSourceProjectPath||t.projectPath,I=D.split("/").filter(Boolean).at(-1)||D,F=t.taskStatus==="queued"||t.taskStatus==="running",N=!!t.taskRetryAvailable&&["failed","interrupted","cancelled"].includes(t.taskStatus),A=!!t.pendingInteraction,S=t.taskStatus==="completed";return e.jsxs("article",{"data-kanban-task":f,className:P("group rounded-md border bg-[hsl(var(--deck-surface))] px-3 py-3 shadow-[0_1px_2px_hsl(var(--deck-ink)/0.04)] transition-[border-color,box-shadow,transform]","border-[hsl(var(--deck-border))] hover:-translate-y-px hover:border-[hsl(var(--deck-border-strong))] hover:shadow-[0_8px_24px_-16px_hsl(var(--deck-ink)/0.35)]",r&&"border-[hsl(var(--deck-accent)/0.55)]"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-mono text-[9.5px] uppercase text-[hsl(var(--deck-ink-faint))]",children:$e(t.sessionId)}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[r&&e.jsx("span",{"aria-label":l("kanban.card.unread"),title:l("kanban.card.unread"),className:"h-1.5 w-1.5 rounded-full bg-[hsl(var(--deck-accent))] shadow-[0_0_6px_hsl(var(--deck-accent-glow)/0.8)]"}),e.jsx("span",{className:"truncate font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:I})]})]}),e.jsx("button",{type:"button",onClick:m,className:"mt-2 block w-full text-left text-[13px] font-medium leading-[1.45] text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:b}),h&&e.jsx("p",{title:h,className:P("mt-1.5 line-clamp-2 text-[10.5px] leading-[1.45]",A||t.taskStatus==="failed"?"text-red-600 dark:text-red-400":"text-[hsl(var(--deck-ink-faint))]"),children:h}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1",children:[e.jsx("span",{className:P("rounded-sm border px-1.5 py-0.5 font-mono text-[9px] font-medium",v.className),children:l(v.label)}),e.jsx("span",{className:"rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-1.5 py-0.5 font-mono text-[9px] text-[hsl(var(--deck-ink-muted))]",children:l(Je[x])}),t.taskDueAt&&e.jsxs("span",{className:P("inline-flex items-center gap-1 rounded-sm border px-1.5 py-0.5 font-mono text-[9px]",Date.parse(t.taskDueAt)<Date.now()&&!S?"border-red-200 bg-red-50 text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300":"border-[hsl(var(--deck-border))] text-[hsl(var(--deck-ink-faint))]"),children:[e.jsx(re,{className:"h-2.5 w-2.5"}),Xe(t.taskDueAt)]})]}),t.taskStatus==="queued"&&t.taskQueuePosition&&e.jsx("div",{className:"mt-2 font-mono text-[9.5px] text-amber-700 dark:text-amber-400",children:l("kanban.card.queuePosition",{position:t.taskQueuePosition,depth:t.taskQueueDepth??t.taskQueuePosition})}),t.taskDiffStat&&e.jsx("div",{className:"mt-2 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:l("kanban.card.diff",{files:t.taskDiffStat.changedFiles,additions:t.taskDiffStat.additions,deletions:t.taskDiffStat.deletions})}),e.jsxs("div",{className:"mt-3 flex items-center justify-end gap-0.5 border-t border-[hsl(var(--deck-hairline))] pt-2",children:[A&&e.jsx(K,{label:l("kanban.action.respond"),onClick:m,tone:"danger",children:e.jsx(Te,{className:"h-3.5 w-3.5"})}),S&&e.jsx(K,{label:l("kanban.action.inspect"),onClick:T,tone:"accent",children:e.jsx(Ce,{className:"h-3.5 w-3.5"})}),N&&e.jsx(K,{label:l("kanban.action.retry"),onClick:c,disabled:u,tone:"accent",children:u?e.jsx(E,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(De,{className:"h-3.5 w-3.5"})}),F&&e.jsx(K,{label:l("kanban.action.cancel"),onClick:y,disabled:i,tone:"danger",children:i?e.jsx(E,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ie,{className:"h-3.5 w-3.5"})}),e.jsx(K,{label:l("kanban.action.edit"),onClick:C,disabled:n,children:n?e.jsx(E,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ae,{className:"h-3.5 w-3.5"})}),S&&e.jsx(K,{label:l("kanban.action.archive"),onClick:k,children:e.jsx(_e,{className:"h-3.5 w-3.5"})}),e.jsx(K,{label:l("kanban.action.open"),onClick:m,children:e.jsx(Ke,{className:"h-3.5 w-3.5"})})]})]})}const ea={waiting:{title:"kanban.column.waiting",description:"kanban.column.waitingDescription",icon:Re,accent:"bg-amber-400",iconStyle:"text-amber-700 dark:text-amber-400"},active:{title:"kanban.column.active",description:"kanban.column.activeDescription",icon:E,accent:"bg-blue-500",iconStyle:"text-blue-700 dark:text-blue-400"},blocked:{title:"kanban.column.blocked",description:"kanban.column.blockedDescription",icon:Fe,accent:"bg-red-500",iconStyle:"text-red-700 dark:text-red-400"},review:{title:"kanban.column.review",description:"kanban.column.reviewDescription",icon:Ee,accent:"bg-[hsl(var(--deck-accent))]",iconStyle:"text-[hsl(var(--deck-accent))]"}};function aa({id:t,sessions:r,unreadTaskKeys:i,cancellingTaskKeys:u,retryingTaskKeys:n,updatingTaskKeys:m,taskKey:T,onOpen:C,onInspect:y,onEdit:c,onCancel:k,onRetry:l,onArchive:w}){const f=V(),b=ea[t],v=b.icon;return e.jsxs("section",{"data-kanban-column":t,"aria-labelledby":`kanban-column-${t}`,className:"flex min-h-[180px] min-w-0 flex-col border-t-2 border-[hsl(var(--deck-hairline))] pt-3 md:min-h-[360px]",children:[e.jsxs("header",{className:"mb-3 flex min-h-12 items-start gap-2 px-0.5",children:[e.jsx(v,{className:P("mt-0.5 h-3.5 w-3.5 shrink-0",b.iconStyle,t==="active"&&"animate-spin")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{id:`kanban-column-${t}`,className:"font-mono text-[11px] font-semibold uppercase text-[hsl(var(--deck-ink))]",children:f(b.title)}),e.jsx("span",{className:"min-w-5 rounded-sm bg-[hsl(var(--deck-surface-2))] px-1.5 py-0.5 text-center font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:r.length})]}),e.jsx("p",{className:"mt-0.5 text-[10px] leading-4 text-[hsl(var(--deck-ink-faint))]",children:f(b.description)})]}),e.jsx("span",{className:P("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",b.accent)})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2.5",children:[r.map(x=>{const h=T(x);return e.jsx(Ze,{session:x,unread:i.includes(h),cancelling:u.includes(h),retrying:n.includes(h),updating:m.includes(h),onOpen:()=>C(x),onInspect:()=>y(x),onEdit:()=>c(x),onCancel:()=>k(x),onRetry:()=>l(x),onArchive:()=>w(x)},h)}),r.length===0&&e.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-md border border-dashed border-[hsl(var(--deck-border))] px-4 text-center font-mono text-[10px] leading-4 text-[hsl(var(--deck-ink-faint))]",children:f("kanban.column.empty")})]})]})}function ta(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?"":new Date(r.getTime()-r.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function na({open:t,onOpenChange:r,projects:i,defaultProjectPath:u,session:n,submitting:m,canCreate:T,onCreate:C,onUpdate:y}){const c=V(),k=!!n,[l,w]=p.useState(""),[f,b]=p.useState(""),[v,x]=p.useState(u??""),[h,D]=p.useState("medium"),[I,F]=p.useState("feature"),[N,A]=p.useState(""),[S,R]=p.useState(null);p.useEffect(()=>{var s;t&&(w((n==null?void 0:n.title)??""),b((n==null?void 0:n.taskPromptSummary)??""),x((n==null?void 0:n.taskSourceProjectPath)??(n==null?void 0:n.projectPath)??u??((s=i.find(j=>j.available))==null?void 0:s.path)??""),D((n==null?void 0:n.taskPriority)??"medium"),F((n==null?void 0:n.taskKind)??"feature"),A(ta(n==null?void 0:n.taskDueAt)),R(null))},[u,t,i,n]);const B=async s=>{s.preventDefault();const j=l.trim(),z=f.trim();if(!(!k&&(!z||!v))){R(null);try{k?await y({...j?{title:j}:{},taskPriority:h,taskKind:I,taskDueAt:N?new Date(N).toISOString():null}):await C({...j?{title:j}:{},prompt:z,projectPath:v,taskPriority:h,taskKind:I,...N?{taskDueAt:new Date(N).toISOString()}:{}}),r(!1)}catch(O){R(O instanceof Error?O.message:c("kanban.dialog.submitFailed"))}}};return e.jsx(fe,{open:t,onOpenChange:r,children:e.jsxs(ve,{className:"max-w-[560px] gap-0 overflow-hidden border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-0",children:[e.jsxs(ge,{className:"border-b border-[hsl(var(--deck-hairline))] px-5 py-4",children:[e.jsx(je,{className:"font-mono text-[15px] text-[hsl(var(--deck-ink))]",children:c(k?"kanban.dialog.editTitle":"kanban.dialog.createTitle")}),e.jsx(Ne,{className:"text-[11.5px] text-[hsl(var(--deck-ink-faint))]",children:c(k?"kanban.dialog.editDescription":"kanban.dialog.createDescription")})]}),e.jsxs("form",{onSubmit:B,children:[e.jsxs("div",{className:"grid gap-4 px-5 py-5",children:[e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase text-[hsl(var(--deck-ink-muted))]",children:c("kanban.field.title")}),e.jsx("input",{value:l,onChange:s=>w(s.target.value),maxLength:200,className:"field",placeholder:c("kanban.field.titlePlaceholder")})]}),!k&&e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase text-[hsl(var(--deck-ink-muted))]",children:c("kanban.field.prompt")}),e.jsx("textarea",{required:!0,value:f,onChange:s=>b(s.target.value),maxLength:32e3,rows:6,className:"min-h-32 w-full resize-y rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-3 py-2.5 text-[13px] leading-5 text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))] focus:border-[hsl(var(--deck-accent)/0.6)] focus:ring-1 focus:ring-[hsl(var(--deck-accent)/0.35)]",placeholder:c("kanban.field.promptPlaceholder")})]}),!k&&e.jsxs("label",{className:"grid gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[10px] uppercase text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(se,{className:"h-3 w-3"}),c("kanban.field.project")]}),e.jsx("select",{required:!0,value:v,onChange:s=>x(s.target.value),className:"field",children:i.filter(s=>s.available).map(s=>e.jsx("option",{value:s.path,children:s.name},s.path))})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("label",{className:"grid gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[10px] uppercase text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(Oe,{className:"h-3 w-3"}),c("kanban.field.kind")]}),e.jsxs("select",{value:I,onChange:s=>F(s.target.value),className:"field",children:[e.jsx("option",{value:"feature",children:c("kanban.kind.feature")}),e.jsx("option",{value:"bug",children:c("kanban.kind.bug")}),e.jsx("option",{value:"maintenance",children:c("kanban.kind.maintenance")}),e.jsx("option",{value:"research",children:c("kanban.kind.research")})]})]}),e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase text-[hsl(var(--deck-ink-muted))]",children:c("kanban.field.priority")}),e.jsxs("select",{value:h,onChange:s=>D(s.target.value),className:"field",children:[e.jsx("option",{value:"high",children:c("kanban.priority.high")}),e.jsx("option",{value:"medium",children:c("kanban.priority.medium")}),e.jsx("option",{value:"low",children:c("kanban.priority.low")})]})]}),e.jsxs("label",{className:"grid gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[10px] uppercase text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(re,{className:"h-3 w-3"}),c("kanban.field.dueAt")]}),e.jsx("input",{type:"datetime-local",value:N,onChange:s=>A(s.target.value),className:"field min-w-0"})]})]}),!k&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[hsl(var(--deck-accent))]"}),c("kanban.dialog.localExecution")]}),S&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:S})]}),e.jsxs(ye,{className:"border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface-2))]/60 px-5 py-3",children:[e.jsx(ee,{type:"button",variant:"ghost",onClick:()=>r(!1),disabled:m,children:c("kanban.dialog.cancel")}),e.jsxs(ee,{type:"submit",disabled:m||!k&&(!T||!f.trim()||!v),className:"gap-2",children:[m&&e.jsx(E,{className:"h-3.5 w-3.5 animate-spin"}),c(k?"kanban.dialog.save":"kanban.dialog.dispatch")]})]})]})]})})}function oa(){var Z;const t=V(),r=o(a=>a.sessions),i=o(a=>a.boundProjects),u=o(a=>a.selectedProjectPath),n=o(a=>a.taskWorkspaceInfo),m=o(a=>a.catalogLoadState),T=o(a=>a.taskEventConnectionState),C=o(a=>a.isDispatchingTask),y=o(a=>a.isUpdatingTaskAdmission),c=o(a=>a.cancellingTaskKeys),k=o(a=>a.retryingTaskKeys),l=o(a=>a.updatingTaskKeys),w=o(a=>a.unreadTaskKeys),f=o(a=>a.error),b=o(a=>a.selectProject),v=o(a=>a.selectSession),x=o(a=>a.dispatchTask),h=o(a=>a.updateTask),D=o(a=>a.cancelTask),I=o(a=>a.retryTask),F=o(a=>a.archiveSession),N=o(a=>a.setTaskAdmissionPaused),A=o(a=>a.reconnectTaskEvents),S=o(a=>a.clearError),R=we(a=>a.currentMode),B=U(a=>a.setMainView),s=U(a=>a.boardProjectPath),j=U(a=>a.setBoardProjectPath),z=U(a=>a.openFilePreview),[O,ce]=p.useState(""),[ie,Y]=p.useState(!1),[le,H]=p.useState(null),[oe,W]=p.useState(!1);p.useEffect(()=>{s&&!i.some(a=>a.path===s&&a.available)&&j(null)},[s,i,j]);const q=r.find(a=>M(g(a))===le)??null,$=O.trim().toLowerCase(),J=p.useMemo(()=>r.filter(a=>s&&te(a)!==s?!1:$?[a.sessionId,ne(a,t),a.taskPromptSummary,te(a),a.taskPriority,a.taskKind].filter(Boolean).join(" ").toLowerCase().includes($):!0),[s,$,r,t]),X=p.useMemo(()=>We(J),[J]),de=G.reduce((a,d)=>a+X[d].length,0),_=n==null?void 0:n.taskAdmission,L=_?!_.paused:!0,Q=i.filter(a=>a.available),ue=s??u??((Z=Q[0])==null?void 0:Z.path)??null,me=q?l.includes(M(g(q))):C,ke=async a=>{B("workspace"),await v(g(a))},xe=async a=>{B("workspace"),await v(g(a)),z({tab:"diff"})},he=async a=>{b(a.projectPath),await x({...a,isolation:"local",permissionMode:R},{selectSession:!1})};return e.jsxs("main",{"data-kanban-board":!0,className:"flex h-full min-w-0 flex-col overflow-hidden bg-[hsl(var(--deck-canvas))] text-[hsl(var(--deck-ink))]",children:[e.jsxs("div",{className:"border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas))] px-4 py-3 sm:px-6",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"font-mono text-[15px] font-semibold",children:t("kanban.title")}),e.jsx("span",{className:"rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-1.5 py-0.5 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:t("kanban.taskCount",{count:de})})]}),e.jsx("p",{className:"mt-0.5 text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:t("kanban.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[_&&e.jsx("div",{className:"hidden rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2.5 py-1.5 lg:block",children:e.jsx(Se,{inFlight:_.inFlight,queued:_.queued,maxConcurrent:_.maxConcurrent,compact:!0})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":L,disabled:!_||y,onClick:()=>{N(L).catch(()=>{})},className:P("inline-flex h-8 items-center gap-2 rounded-md border px-2.5 font-mono text-[10.5px] transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:opacity-45",L?"border-[hsl(var(--deck-accent)/0.45)] bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-accent))]":"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink-muted))]"),children:[y?e.jsx(E,{className:"h-3 w-3 animate-spin"}):L?e.jsx(qe,{className:"h-3 w-3 fill-current"}):e.jsx(Le,{className:"h-3 w-3"}),t(L?"kanban.autoClaim.running":"kanban.autoClaim.paused")]}),e.jsxs("button",{type:"button",onClick:()=>{if(Q.length===0){W(!0);return}H(null),Y(!0)},className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[hsl(var(--deck-ink))] px-3 font-mono text-[10.5px] font-medium text-[hsl(var(--deck-canvas))] transition-opacity hover:opacity-85 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--deck-accent))]",children:[e.jsx(Me,{className:"h-3.5 w-3.5"}),t("kanban.action.newTask")]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsxs("label",{className:"relative min-w-[180px] flex-1 sm:max-w-[320px]",children:[e.jsx(Be,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("input",{type:"search",value:O,onChange:a=>ce(a.target.value),"aria-label":t("kanban.searchAria"),placeholder:t("kanban.searchPlaceholder"),className:"h-8 w-full rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] pl-8 pr-3 font-mono text-[10.5px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))] focus:border-[hsl(var(--deck-accent)/0.55)] focus:ring-1 focus:ring-[hsl(var(--deck-accent)/0.25)]"})]}),e.jsxs("label",{className:"relative",children:[e.jsx(se,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[hsl(var(--deck-accent))]"}),e.jsxs("select",{value:s??"__all__",onChange:a=>{const d=a.target.value;j(d==="__all__"?null:d),d!=="__all__"&&b(d)},"aria-label":t("kanban.projectFilterAria"),className:"h-8 min-w-[160px] appearance-none rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] pl-8 pr-7 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] outline-none focus:border-[hsl(var(--deck-accent)/0.55)]",children:[e.jsx("option",{value:"__all__",children:t("kanban.projectAll")}),Q.map(a=>e.jsx("option",{value:a.path,children:a.name},a.path))]})]}),e.jsx("button",{type:"button",onClick:()=>W(!0),"aria-label":t("projects.bind.action"),title:t("projects.bind.action"),className:"flex h-8 w-8 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink-faint))] hover:text-[hsl(var(--deck-accent))]",children:e.jsx(ze,{className:"h-3.5 w-3.5"})}),m==="loading"||m==="hydrating"?e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(E,{className:"h-3 w-3 animate-spin"}),t("sidebar.catalog.syncing")]}):null]})]}),T==="offline"&&e.jsxs("div",{role:"alert",className:"flex items-center gap-2 border-b border-amber-300/60 bg-amber-50/80 px-4 py-2 text-[10.5px] text-amber-800 dark:border-amber-900/70 dark:bg-amber-950/30 dark:text-amber-300 sm:px-6",children:[e.jsx(Qe,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"flex-1",children:t("kanban.feed.offline")}),e.jsxs("button",{type:"button",onClick:()=>void A().catch(()=>{}),className:"inline-flex h-7 items-center gap-1 rounded-md px-2 font-mono hover:bg-amber-100 dark:hover:bg-amber-900/40",children:[e.jsx(Ue,{className:"h-3 w-3"}),t("taskHome.feed.retry")]})]}),f&&e.jsxs("div",{role:"alert",className:"flex items-center gap-3 border-b border-red-200 bg-red-50 px-4 py-2 text-[10.5px] text-red-700 dark:border-red-900/70 dark:bg-red-950/30 dark:text-red-300 sm:px-6",children:[e.jsx("span",{className:"flex-1",children:f}),e.jsx("button",{type:"button",onClick:S,className:"font-mono underline",children:t("taskHome.error.dismiss")})]}),e.jsx("div",{className:"flex-1 overflow-auto px-4 py-4 sm:px-6",children:e.jsx("div",{className:"grid min-w-0 grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-4",children:G.map(a=>e.jsx(aa,{id:a,sessions:X[a],unreadTaskKeys:w,cancellingTaskKeys:c,retryingTaskKeys:k,updatingTaskKeys:l,taskKey:d=>M(g(d)),onOpen:d=>{ke(d).catch(()=>{})},onInspect:d=>{xe(d).catch(()=>{})},onEdit:d=>{H(M(g(d))),Y(!0)},onCancel:d=>{D(g(d)).catch(()=>{})},onRetry:d=>{I(g(d)).catch(()=>{})},onArchive:d=>{F(g(d))}},a))})}),e.jsx(na,{open:ie,onOpenChange:a=>{Y(a),a||H(null)},projects:i,defaultProjectPath:ue,session:q,submitting:me,canCreate:Q.length>0,onCreate:he,onUpdate:async a=>{q&&await h(g(q),a)}}),e.jsx(Pe,{open:oe,onOpenChange:W})]})}export{oa as KanbanBoard};