@cuongtran001/kanna 1.43.2 → 1.43.3

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 (75) hide show
  1. package/dist/client/assets/{BoardsPage-aVUB66Sg.js → BoardsPage-CTjhzYPs.js} +1 -1
  2. package/dist/client/assets/{BoardsRoutePage-DxTxOJTt.js → BoardsRoutePage-BEHGMQ9e.js} +1 -1
  3. package/dist/client/assets/{ChatPreferenceControls-C8_AU8Ea.js → ChatPreferenceControls-CjzVhGJs.js} +1 -1
  4. package/dist/client/assets/{CronJobsPage-qiEM-t5J.js → CronJobsPage-C9ZdPf4v.js} +1 -1
  5. package/dist/client/assets/{CronRunMessage-BtTOaNBJ.js → CronRunMessage-CWnhZpxr.js} +1 -1
  6. package/dist/client/assets/{LocalProjectsPage-DpFtS1Q8.js → LocalProjectsPage-Ci4tuN5x.js} +1 -1
  7. package/dist/client/assets/{SettingsPage-BfMDi-P1.js → SettingsPage-CjAo4rHt.js} +1 -1
  8. package/dist/client/assets/{StackBoardsRoutePage-DZWNiSdW.js → StackBoardsRoutePage-CDl6stwA.js} +1 -1
  9. package/dist/client/assets/{WorkflowsPage-Dd0O7VbU.js → WorkflowsPage-BQAt3koH.js} +1 -1
  10. package/dist/client/assets/{WorkflowsSection-B5T59wER.js → WorkflowsSection-Bykl8tZu.js} +4 -4
  11. package/dist/client/assets/{arc-B_Axb_3F.js → arc-Cks0xuPw.js} +1 -1
  12. package/dist/client/assets/{architectureDiagram-3BPJPVTR-DsWq1Gaf.js → architectureDiagram-3BPJPVTR-DVvD18R7.js} +1 -1
  13. package/dist/client/assets/{blockDiagram-GPEHLZMM-CFqnK4ww.js → blockDiagram-GPEHLZMM-BiaIHdCs.js} +1 -1
  14. package/dist/client/assets/{c4Diagram-AAUBKEIU-D4CuZu0F.js → c4Diagram-AAUBKEIU-Ihf4dMVP.js} +1 -1
  15. package/dist/client/assets/channel-Bn9tz3K-.js +1 -0
  16. package/dist/client/assets/{chunk-2J33WTMH-DVMGL0NK.js → chunk-2J33WTMH-CHZjT_yB.js} +1 -1
  17. package/dist/client/assets/{chunk-4BX2VUAB-Dyva4Sg4.js → chunk-4BX2VUAB-Qa0Fk_Yp.js} +1 -1
  18. package/dist/client/assets/{chunk-55IACEB6-_Mw4Wo08.js → chunk-55IACEB6-CZV3cQBc.js} +1 -1
  19. package/dist/client/assets/{chunk-727SXJPM-D7c3ffQ8.js → chunk-727SXJPM-Cm7T4Wpi.js} +1 -1
  20. package/dist/client/assets/{chunk-AQP2D5EJ-CiOZcKeX.js → chunk-AQP2D5EJ-CN-_H3Id.js} +1 -1
  21. package/dist/client/assets/{chunk-FMBD7UC4-CGks8dyD.js → chunk-FMBD7UC4-DLcgUnHX.js} +1 -1
  22. package/dist/client/assets/{chunk-ND2GUHAM-SPDexoPS.js → chunk-ND2GUHAM-C6VOzqXe.js} +1 -1
  23. package/dist/client/assets/{chunk-QZHKN3VN-QBOxAgms.js → chunk-QZHKN3VN-Dook8xxJ.js} +1 -1
  24. package/dist/client/assets/classDiagram-4FO5ZUOK-Cio5u5Gz.js +1 -0
  25. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-Cio5u5Gz.js +1 -0
  26. package/dist/client/assets/{columnStyle-DYH9vt9P.js → columnStyle-BUhiREXS.js} +1 -1
  27. package/dist/client/assets/{cose-bilkent-S5V4N54A-DkDvUpPF.js → cose-bilkent-S5V4N54A-Dmac8EZg.js} +1 -1
  28. package/dist/client/assets/{dagre-BM42HDAG-D5DK9tqj.js → dagre-BM42HDAG-DFnlVyIO.js} +1 -1
  29. package/dist/client/assets/{diagram-2AECGRRQ-D844tV51.js → diagram-2AECGRRQ-sBB70rEG.js} +1 -1
  30. package/dist/client/assets/{diagram-5GNKFQAL-pYFak_RO.js → diagram-5GNKFQAL-SCQloco_.js} +1 -1
  31. package/dist/client/assets/{diagram-KO2AKTUF-DP1mPLyY.js → diagram-KO2AKTUF-CYSxoyD5.js} +1 -1
  32. package/dist/client/assets/{diagram-LMA3HP47-B8C1Slwx.js → diagram-LMA3HP47-DllYmwTm.js} +1 -1
  33. package/dist/client/assets/{diagram-OG6HWLK6-HHe_1Ms2.js → diagram-OG6HWLK6-Cz1uqatB.js} +1 -1
  34. package/dist/client/assets/{erDiagram-TEJ5UH35-Cq4J7X-i.js → erDiagram-TEJ5UH35-B91DwiKm.js} +1 -1
  35. package/dist/client/assets/{external-link-Dn7b4TFh.js → external-link-DwktYVMa.js} +1 -1
  36. package/dist/client/assets/{flowDiagram-I6XJVG4X-DJ0fnAdZ.js → flowDiagram-I6XJVG4X-BBQzSw-a.js} +1 -1
  37. package/dist/client/assets/{folder-DO6XYlD4.js → folder-MCCIA_mr.js} +1 -1
  38. package/dist/client/assets/{ganttDiagram-6RSMTGT7-w0WxHzta.js → ganttDiagram-6RSMTGT7-D_GiW11e.js} +1 -1
  39. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-BMQrbKe1.js → gitGraphDiagram-PVQCEYII-9NTperEg.js} +1 -1
  40. package/dist/client/assets/{index-Cdanl_10.js → index-BMlaarqi.js} +1 -1
  41. package/dist/client/assets/{index-CZhHYh3L.js → index-C8zkilqi.js} +1 -1
  42. package/dist/client/assets/{index-CYGgzYjD.js → index-CQHs_fLN.js} +3 -3
  43. package/dist/client/assets/{index-DXSQvXUy.js → index-CZwuLrNi.js} +1 -1
  44. package/dist/client/assets/{index-Da6Q--VC.js → index-u7uCA_nx.js} +4 -4
  45. package/dist/client/assets/{infoDiagram-5YYISTIA-CB_w_Bsg.js → infoDiagram-5YYISTIA-CPzZQBig.js} +1 -1
  46. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-BXCJ99MW.js → ishikawaDiagram-YF4QCWOH-CDdal8tc.js} +1 -1
  47. package/dist/client/assets/{journeyDiagram-JHISSGLW-BVuEvHCs.js → journeyDiagram-JHISSGLW-DqUKbrL1.js} +1 -1
  48. package/dist/client/assets/{kanban-definition-UN3LZRKU-Br3A6HTG.js → kanban-definition-UN3LZRKU-l_XArCPB.js} +1 -1
  49. package/dist/client/assets/{linear-CyJH8eE7.js → linear-Cbs85svO.js} +1 -1
  50. package/dist/client/assets/{mermaid.core-DHuSoCjt.js → mermaid.core-ChAu8gwz.js} +4 -4
  51. package/dist/client/assets/{mindmap-definition-RKZ34NQL-B9XRL1Xv.js → mindmap-definition-RKZ34NQL-SpK2aVai.js} +1 -1
  52. package/dist/client/assets/{monitor-CcAlRKyi.js → monitor-CrU4rsYb.js} +1 -1
  53. package/dist/client/assets/{pieDiagram-4H26LBE5-BpFavsSD.js → pieDiagram-4H26LBE5-C8SNfzyF.js} +1 -1
  54. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-NRsHCkjO.js → quadrantDiagram-W4KKPZXB-BybYOeog.js} +1 -1
  55. package/dist/client/assets/{requirementDiagram-4Y6WPE33-DPPrmx1V.js → requirementDiagram-4Y6WPE33-morKn36w.js} +1 -1
  56. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-Cn-c8V-F.js → sankeyDiagram-5OEKKPKP-CeQOXcPf.js} +1 -1
  57. package/dist/client/assets/{search-B5O9tejp.js → search-DAIo8ajC.js} +1 -1
  58. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-D_9yVnRk.js → sequenceDiagram-3UESZ5HK-DXmblv-R.js} +1 -1
  59. package/dist/client/assets/{settings-header-button-D1JRdGKR.js → settings-header-button-_r-gvFLd.js} +1 -1
  60. package/dist/client/assets/{stateDiagram-AJRCARHV-DGlBkEHo.js → stateDiagram-AJRCARHV-v__FCcjL.js} +1 -1
  61. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-Dn5emxWZ.js +1 -0
  62. package/dist/client/assets/{terminal-CAxY-QfP.js → terminal-DfBnyME3.js} +1 -1
  63. package/dist/client/assets/{timeline-definition-PNZ67QCA-BTbMnaDC.js → timeline-definition-PNZ67QCA-HziTYscp.js} +1 -1
  64. package/dist/client/assets/{vennDiagram-CIIHVFJN-B6iluyGy.js → vennDiagram-CIIHVFJN-M4b5nVTw.js} +1 -1
  65. package/dist/client/assets/{wardley-L42UT6IY-DrAC3n4z.js → wardley-L42UT6IY-CnqehCmv.js} +1 -1
  66. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-DaurgMfa.js → wardleyDiagram-YWT4CUSO-C35yNal5.js} +1 -1
  67. package/dist/client/assets/{xychartDiagram-2RQKCTM6-6YjJvZmr.js → xychartDiagram-2RQKCTM6-BCtf0wO6.js} +1 -1
  68. package/dist/client/index.html +1 -1
  69. package/package.json +1 -1
  70. package/src/server/codex-session-scanner.adapter.ts +40 -0
  71. package/src/server/codex-session-scanner.test.ts +149 -0
  72. package/dist/client/assets/channel-Brn7sbLm.js +0 -1
  73. package/dist/client/assets/classDiagram-4FO5ZUOK-CnYHttg0.js +0 -1
  74. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-CnYHttg0.js +0 -1
  75. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-CwxaiIgB.js +0 -1
@@ -1 +1 @@
1
- import{l as I,r as o,j as t,B as T,P as R,I as A,d as E,m as z,n as O,E as _,o as $}from"./index-Da6Q--VC.js";import{u as C,s as D,o as w,C as L}from"./columnStyle-DYH9vt9P.js";const F=[],u=I()(e=>({templates:F,openMenuId:null,picking:!1,renamingId:null,error:null,setTemplates:s=>e({templates:Array.isArray(s)?s:[]}),openMenu:s=>e({openMenuId:s}),closeMenu:()=>e({openMenuId:null}),openPicker:()=>e({picking:!0,error:null}),closePicker:()=>e({picking:!1}),startRename:s=>e({renamingId:s,picking:!1,openMenuId:null}),stopRename:()=>e({renamingId:null}),setError:s=>e({error:s})}));function U(e){return e.templates}function K({ownerKind:e,ownerId:s,ownerName:a,socket:c,onOpenBoard:l}){const r=w(e,s),i=C(D(r)),x=u(U),p=u(n=>n.picking),h=u(n=>n.renamingId),d=u(n=>n.error),{openPicker:f,closePicker:j,startRename:B,stopRename:k,setError:y,setTemplates:N}=u.getState();o.useEffect(()=>c.subscribe({type:"boards",ownerKind:e,ownerId:s},n=>{C.getState().setBoards(w(n.ownerKind,n.ownerId),n.boards)}),[e,s,c]),o.useEffect(()=>{let n=!1;return c.command({type:"board.templates.list"}).then(m=>{n||N(m)}).catch(()=>{}),()=>{n=!0}},[c,N]);const g=o.useCallback(async n=>{try{await c.command(n),y(null)}catch(m){y(m instanceof Error?m.message:"That did not work.")}},[c,y]),P=o.useCallback(n=>{j(),g({type:"board.create",ownerKind:e,ownerId:s,title:n?n.name:"Untitled board",templateId:(n==null?void 0:n.id)??null})},[j,e,s,g]),M=o.useCallback((n,m)=>{k();const v=m.trim();v!==""&&g({type:"board.update",boardId:n,title:v})},[g,k]),S=p||i.length===0;return t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-background",children:[t.jsxs("header",{className:"flex items-end justify-between gap-4 border-b border-border px-6 py-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-lg font-medium leading-tight tracking-[-0.01em] text-foreground",children:"Boards"}),t.jsxs("p",{className:"truncate text-13 text-muted-foreground",children:[a,i.length>0?t.jsxs("span",{className:"tabular-nums",children:[" · ",i.length," boards"]}):null]})]}),i.length>0?t.jsxs(T,{size:"sm",onClick:f,children:[t.jsx(R,{className:"size-3.5"}),"New board"]}):null]}),d?t.jsx("p",{className:"border-b border-border px-6 py-2 text-13 text-destructive-text",children:d}):null,t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[S?t.jsx(q,{templates:x,firstRun:i.length===0,onPick:P,onCancel:j}):null,i.length>0?t.jsx("ul",{className:"px-4 py-1",children:i.map(n=>t.jsx(V,{board:n,renaming:h===n.id,onOpen:l,onStartRename:B,onRename:M,onCancelRename:k,onCommand:g},n.id))}):null]})]})}function V({board:e,renaming:s,onOpen:a,onStartRename:c,onRename:l,onCancelRename:r,onCommand:i}){const x=o.useCallback(()=>a(e.id),[e.id,a]),p=o.useCallback(d=>{d.key==="Enter"&&l(e.id,d.currentTarget.value),d.key==="Escape"&&r()},[e.id,r,l]),h=o.useCallback(d=>l(e.id,d.currentTarget.value),[e.id,l]);return t.jsxs("li",{className:"group grid grid-cols-[1fr_auto_auto] items-center gap-5 border-b border-border px-3 py-3 last:border-b-0 hover:bg-secondary",children:[t.jsx("div",{className:"min-w-0",children:s?t.jsx(A,{autoFocus:!0,defaultValue:e.title,onKeyDown:p,onBlur:h,className:"h-7 max-w-sm","aria-label":"Board name"}):t.jsxs("button",{type:"button",onClick:x,className:"block w-full text-left",children:[t.jsx("span",{className:"block truncate text-15 font-semibold tracking-[-0.005em] text-foreground",children:e.title}),e.description?t.jsx("span",{className:"mt-0.5 block truncate text-13 text-muted-foreground",children:e.description}):null]})}),t.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[t.jsxs("span",{children:[t.jsx("b",{className:"font-medium tabular-nums text-foreground",children:e.columnCount})," columns"]}),t.jsxs("span",{children:[t.jsx("b",{className:"font-medium tabular-nums text-foreground",children:e.cardCount})," cards"]})]}),t.jsx(Y,{board:e,onStartRename:c,onCommand:i})]})}function Y({board:e,onStartRename:s,onCommand:a}){const c=u(f=>f.openMenuId===e.id),{openMenu:l,closeMenu:r}=u.getState(),i=o.useCallback(f=>{f?l(e.id):r()},[e.id,r,l]),x=o.useCallback(()=>{r(),s(e.id)},[e.id,r,s]),p=o.useCallback(()=>{r(),a({type:"board.duplicate",boardId:e.id,title:`${e.title} copy`})},[e.id,e.title,r,a]),h=o.useCallback(()=>{r(),a({type:"board.saveAsTemplate",boardId:e.id,name:e.title})},[e.id,e.title,r,a]),d=o.useCallback(()=>{r(),a({type:"board.archive",boardId:e.id})},[e.id,r,a]);return t.jsxs(z,{open:c,onOpenChange:i,children:[t.jsx(O,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":`Actions for ${e.title}`,className:"rounded-md px-1.5 py-1 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100",children:t.jsx(_,{className:"size-4"})})}),t.jsxs($,{align:"end",className:"w-56 p-1",children:[t.jsx(b,{onClick:x,children:"Rename"}),t.jsx(b,{onClick:p,children:"Duplicate structure"}),t.jsx(b,{onClick:h,children:"Save as template"}),t.jsx("div",{className:"my-1 h-px bg-border"}),t.jsx(b,{onClick:d,tone:"destructive",children:"Archive"})]})]})}function b({onClick:e,children:s,tone:a}){return t.jsx("button",{type:"button",onClick:e,className:E("flex w-full items-center rounded-sm px-2 py-1.5 text-left text-xs font-medium hover:bg-secondary",a==="destructive"&&"text-destructive-text"),children:s})}function q({templates:e,firstRun:s,onPick:a,onCancel:c}){const l=o.useCallback(()=>a(null),[a]);return t.jsxs("div",{className:"px-6 py-8",children:[s?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-15 font-semibold text-foreground",children:"No boards yet."}),t.jsx("p",{className:"mt-1 max-w-[58ch] text-sm text-muted-foreground",children:"A board turns issues into work your agents can pick up. Start from a shape, or import an existing tracker."})]}):t.jsx("h2",{className:"text-15 font-semibold text-foreground",children:"Start from a shape"}),t.jsxs("div",{className:"mt-4 max-w-xl rounded-lg border border-border",children:[e.map(r=>t.jsx(G,{template:r,onPick:a},r.id)),t.jsx("button",{type:"button",onClick:l,className:"flex w-full items-center border-t border-border px-3.5 py-2.5 text-left hover:bg-secondary",children:t.jsxs("span",{children:[t.jsx("span",{className:"block text-sm font-medium text-foreground",children:"Empty board"}),t.jsx("span",{className:"block text-xs text-muted-foreground",children:"Name your own columns"})]})})]}),s?null:t.jsx(T,{variant:"ghost",size:"sm",className:"mt-3",onClick:c,children:"Cancel"})]})}function G({template:e,onPick:s}){const a=o.useCallback(()=>s(e),[s,e]),c=e.definition.columns;return t.jsxs("button",{type:"button",onClick:a,className:"flex w-full items-center gap-3 border-b border-border px-3.5 py-2.5 text-left last:border-b-0 hover:bg-secondary",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium text-foreground",children:e.name}),t.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:c.map(l=>l.title).join(" · ")})]}),t.jsx("span",{"aria-hidden":!0,className:"ml-auto flex shrink-0 gap-1",children:c.map((l,r)=>t.jsx("span",{className:E("size-1.5 rounded-full",l.colorToken?L[l.colorToken]:"bg-muted-icon")},`${e.id}-${String(r)}`))})]})}export{K as B};
1
+ import{l as I,r as o,j as t,B as T,P as R,I as A,d as E,m as z,n as O,E as _,o as $}from"./index-u7uCA_nx.js";import{u as C,s as D,o as w,C as L}from"./columnStyle-BUhiREXS.js";const F=[],u=I()(e=>({templates:F,openMenuId:null,picking:!1,renamingId:null,error:null,setTemplates:s=>e({templates:Array.isArray(s)?s:[]}),openMenu:s=>e({openMenuId:s}),closeMenu:()=>e({openMenuId:null}),openPicker:()=>e({picking:!0,error:null}),closePicker:()=>e({picking:!1}),startRename:s=>e({renamingId:s,picking:!1,openMenuId:null}),stopRename:()=>e({renamingId:null}),setError:s=>e({error:s})}));function U(e){return e.templates}function K({ownerKind:e,ownerId:s,ownerName:a,socket:c,onOpenBoard:l}){const r=w(e,s),i=C(D(r)),x=u(U),p=u(n=>n.picking),h=u(n=>n.renamingId),d=u(n=>n.error),{openPicker:f,closePicker:j,startRename:B,stopRename:k,setError:y,setTemplates:N}=u.getState();o.useEffect(()=>c.subscribe({type:"boards",ownerKind:e,ownerId:s},n=>{C.getState().setBoards(w(n.ownerKind,n.ownerId),n.boards)}),[e,s,c]),o.useEffect(()=>{let n=!1;return c.command({type:"board.templates.list"}).then(m=>{n||N(m)}).catch(()=>{}),()=>{n=!0}},[c,N]);const g=o.useCallback(async n=>{try{await c.command(n),y(null)}catch(m){y(m instanceof Error?m.message:"That did not work.")}},[c,y]),P=o.useCallback(n=>{j(),g({type:"board.create",ownerKind:e,ownerId:s,title:n?n.name:"Untitled board",templateId:(n==null?void 0:n.id)??null})},[j,e,s,g]),M=o.useCallback((n,m)=>{k();const v=m.trim();v!==""&&g({type:"board.update",boardId:n,title:v})},[g,k]),S=p||i.length===0;return t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-background",children:[t.jsxs("header",{className:"flex items-end justify-between gap-4 border-b border-border px-6 py-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-lg font-medium leading-tight tracking-[-0.01em] text-foreground",children:"Boards"}),t.jsxs("p",{className:"truncate text-13 text-muted-foreground",children:[a,i.length>0?t.jsxs("span",{className:"tabular-nums",children:[" · ",i.length," boards"]}):null]})]}),i.length>0?t.jsxs(T,{size:"sm",onClick:f,children:[t.jsx(R,{className:"size-3.5"}),"New board"]}):null]}),d?t.jsx("p",{className:"border-b border-border px-6 py-2 text-13 text-destructive-text",children:d}):null,t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[S?t.jsx(q,{templates:x,firstRun:i.length===0,onPick:P,onCancel:j}):null,i.length>0?t.jsx("ul",{className:"px-4 py-1",children:i.map(n=>t.jsx(V,{board:n,renaming:h===n.id,onOpen:l,onStartRename:B,onRename:M,onCancelRename:k,onCommand:g},n.id))}):null]})]})}function V({board:e,renaming:s,onOpen:a,onStartRename:c,onRename:l,onCancelRename:r,onCommand:i}){const x=o.useCallback(()=>a(e.id),[e.id,a]),p=o.useCallback(d=>{d.key==="Enter"&&l(e.id,d.currentTarget.value),d.key==="Escape"&&r()},[e.id,r,l]),h=o.useCallback(d=>l(e.id,d.currentTarget.value),[e.id,l]);return t.jsxs("li",{className:"group grid grid-cols-[1fr_auto_auto] items-center gap-5 border-b border-border px-3 py-3 last:border-b-0 hover:bg-secondary",children:[t.jsx("div",{className:"min-w-0",children:s?t.jsx(A,{autoFocus:!0,defaultValue:e.title,onKeyDown:p,onBlur:h,className:"h-7 max-w-sm","aria-label":"Board name"}):t.jsxs("button",{type:"button",onClick:x,className:"block w-full text-left",children:[t.jsx("span",{className:"block truncate text-15 font-semibold tracking-[-0.005em] text-foreground",children:e.title}),e.description?t.jsx("span",{className:"mt-0.5 block truncate text-13 text-muted-foreground",children:e.description}):null]})}),t.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[t.jsxs("span",{children:[t.jsx("b",{className:"font-medium tabular-nums text-foreground",children:e.columnCount})," columns"]}),t.jsxs("span",{children:[t.jsx("b",{className:"font-medium tabular-nums text-foreground",children:e.cardCount})," cards"]})]}),t.jsx(Y,{board:e,onStartRename:c,onCommand:i})]})}function Y({board:e,onStartRename:s,onCommand:a}){const c=u(f=>f.openMenuId===e.id),{openMenu:l,closeMenu:r}=u.getState(),i=o.useCallback(f=>{f?l(e.id):r()},[e.id,r,l]),x=o.useCallback(()=>{r(),s(e.id)},[e.id,r,s]),p=o.useCallback(()=>{r(),a({type:"board.duplicate",boardId:e.id,title:`${e.title} copy`})},[e.id,e.title,r,a]),h=o.useCallback(()=>{r(),a({type:"board.saveAsTemplate",boardId:e.id,name:e.title})},[e.id,e.title,r,a]),d=o.useCallback(()=>{r(),a({type:"board.archive",boardId:e.id})},[e.id,r,a]);return t.jsxs(z,{open:c,onOpenChange:i,children:[t.jsx(O,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":`Actions for ${e.title}`,className:"rounded-md px-1.5 py-1 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100",children:t.jsx(_,{className:"size-4"})})}),t.jsxs($,{align:"end",className:"w-56 p-1",children:[t.jsx(b,{onClick:x,children:"Rename"}),t.jsx(b,{onClick:p,children:"Duplicate structure"}),t.jsx(b,{onClick:h,children:"Save as template"}),t.jsx("div",{className:"my-1 h-px bg-border"}),t.jsx(b,{onClick:d,tone:"destructive",children:"Archive"})]})]})}function b({onClick:e,children:s,tone:a}){return t.jsx("button",{type:"button",onClick:e,className:E("flex w-full items-center rounded-sm px-2 py-1.5 text-left text-xs font-medium hover:bg-secondary",a==="destructive"&&"text-destructive-text"),children:s})}function q({templates:e,firstRun:s,onPick:a,onCancel:c}){const l=o.useCallback(()=>a(null),[a]);return t.jsxs("div",{className:"px-6 py-8",children:[s?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-15 font-semibold text-foreground",children:"No boards yet."}),t.jsx("p",{className:"mt-1 max-w-[58ch] text-sm text-muted-foreground",children:"A board turns issues into work your agents can pick up. Start from a shape, or import an existing tracker."})]}):t.jsx("h2",{className:"text-15 font-semibold text-foreground",children:"Start from a shape"}),t.jsxs("div",{className:"mt-4 max-w-xl rounded-lg border border-border",children:[e.map(r=>t.jsx(G,{template:r,onPick:a},r.id)),t.jsx("button",{type:"button",onClick:l,className:"flex w-full items-center border-t border-border px-3.5 py-2.5 text-left hover:bg-secondary",children:t.jsxs("span",{children:[t.jsx("span",{className:"block text-sm font-medium text-foreground",children:"Empty board"}),t.jsx("span",{className:"block text-xs text-muted-foreground",children:"Name your own columns"})]})})]}),s?null:t.jsx(T,{variant:"ghost",size:"sm",className:"mt-3",onClick:c,children:"Cancel"})]})}function G({template:e,onPick:s}){const a=o.useCallback(()=>s(e),[s,e]),c=e.definition.columns;return t.jsxs("button",{type:"button",onClick:a,className:"flex w-full items-center gap-3 border-b border-border px-3.5 py-2.5 text-left last:border-b-0 hover:bg-secondary",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium text-foreground",children:e.name}),t.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:c.map(l=>l.title).join(" · ")})]}),t.jsx("span",{"aria-hidden":!0,className:"ml-auto flex shrink-0 gap-1",children:c.map((l,r)=>t.jsx("span",{className:E("size-1.5 rounded-full",l.colorToken?L[l.colorToken]:"bg-muted-icon")},`${e.id}-${String(r)}`))})]})}export{K as B};
@@ -1 +1 @@
1
- import{u as p,a as i,b as d,g as u,r as l,j as r}from"./index-Da6Q--VC.js";import{B as m}from"./BoardsPage-aVUB66Sg.js";import"./columnStyle-DYH9vt9P.js";function P(){const o=p(),t=i(),{projectId:e=""}=d(),s=[...o.sidebarData.starredProjectGroups,...o.sidebarData.projectGroups].find(a=>a.groupKey===e),n=s?u(s.localPath):"Project",c=l.useCallback(a=>{t(`/boards/${e}/${a}`)},[t,e]);return r.jsx("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:r.jsx(m,{ownerKind:"project",ownerId:e,ownerName:n,socket:o.socket,onOpenBoard:c})})}export{P as BoardsRoutePage};
1
+ import{u as p,a as i,b as d,g as u,r as l,j as r}from"./index-u7uCA_nx.js";import{B as m}from"./BoardsPage-CTjhzYPs.js";import"./columnStyle-BUhiREXS.js";function P(){const o=p(),t=i(),{projectId:e=""}=d(),s=[...o.sidebarData.starredProjectGroups,...o.sidebarData.projectGroups].find(a=>a.groupKey===e),n=s?u(s.localPath):"Project",c=l.useCallback(a=>{t(`/boards/${e}/${a}`)},[t,e]);return r.jsx("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:r.jsx(m,{ownerKind:"project",ownerId:e,ownerName:n,socket:o.socket,onOpenBoard:c})})}export{P as BoardsRoutePage};
@@ -1,4 +1,4 @@
1
- import{c as U,r,a2 as Lt,a3 as Le,j as e,a4 as Dt,a5 as Me,a6 as z,a7 as Q,a8 as D,a9 as Ue,aa as Ot,ab as Bt,ac as Vt,ad as k,ae as Ht,af as $e,ag as Ft,ah as Wt,ai as Ut,aj as $t,ak as Kt,al as qt,am as zt,an as Gt,ao as Zt,ap as Xt,d as M,_ as Yt,aq as Qt,p as Ke,ar as Jt,as as eo,at as to,H as oo,au as no,av as Ce,aw as De,ax as ro,m as qe,n as ze,o as Ge}from"./index-Da6Q--VC.js";import{L as Oe,S as so}from"./search-B5O9tejp.js";/**
1
+ import{c as U,r,a2 as Lt,a3 as Le,j as e,a4 as Dt,a5 as Me,a6 as z,a7 as Q,a8 as D,a9 as Ue,aa as Ot,ab as Bt,ac as Vt,ad as k,ae as Ht,af as $e,ag as Ft,ah as Wt,ai as Ut,aj as $t,ak as Kt,al as qt,am as zt,an as Gt,ao as Zt,ap as Xt,d as M,_ as Yt,aq as Qt,p as Ke,ar as Jt,as as eo,at as to,H as oo,au as no,av as Ce,aw as De,ax as ro,m as qe,n as ze,o as Ge}from"./index-u7uCA_nx.js";import{L as Oe,S as so}from"./search-DAIo8ajC.js";/**
2
2
  * @license lucide-react v0.562.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{f as b,h as f,r as m,j as e,S as g,C as N,g as v,H as w,i as C,k as i,L as P,X as I,d as k}from"./index-Da6Q--VC.js";import{u as y,C as L,a as x,h as R,P as S,b as A}from"./CronRunMessage-BtTOaNBJ.js";import{E}from"./external-link-Dn7b4TFh.js";function D(){const n=b(t=>t.rows),d=f(),o=y(1e3),l=m.useCallback((t,a)=>{d.command({type:t,chatId:a.chatId,jobId:a.job.jobId}).catch(()=>{})},[d]),h=m.useMemo(()=>{const t=new Map;for(const a of n){const r=t.get(a.projectId)??{projectPath:a.projectPath,rows:[]};r.rows.push(a),t.set(a.projectId,r)}return[...t.values()]},[n]);return e.jsx("div",{className:g,children:e.jsxs("div",{className:"mx-auto w-full max-w-[900px] px-4 py-8",children:[e.jsxs("h1",{className:"flex items-center gap-2.5 text-lg font-semibold text-foreground",children:[e.jsx(N,{className:"h-5 w-5 text-muted-foreground","aria-hidden":"true"}),"Cron jobs",e.jsxs("span",{className:"text-sm font-normal text-muted-foreground tabular-nums",children:[n.length," armed"]})]}),n.length===0?e.jsxs("p",{className:"mt-6 text-sm text-muted-foreground",children:["No cron jobs armed anywhere. Arm one from any chat with"," ",e.jsx("code",{className:"font-mono text-xs",children:"/cron <instruction> inline|spawn <schedule>"}),"."]}):e.jsx("div",{className:"mt-6 space-y-6",children:h.map(t=>e.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[e.jsxs("h2",{className:"border-b border-border bg-card p-3 px-4 text-sm font-medium text-foreground",children:[v(t.projectPath),e.jsx("span",{className:"ml-2 font-mono text-xs font-normal text-muted-foreground",children:t.projectPath})]}),e.jsx("div",{children:t.rows.map((a,r)=>{var u;const s=a.job,j=r===t.rows.length-1,p=o-s.armedAt,c=((u=s.lastRun)==null?void 0:u.status)==="running"?s.lastRun:null;return e.jsxs("div",{className:k("flex items-center gap-3 bg-background px-4 py-2.5",!j&&"border-b border-border"),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm text-foreground",children:s.instruction}),s.paused?e.jsx(L,{}):null,!s.paused&&s.lastRun?e.jsx(x,{status:s.lastRun.status}):null]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-mono",children:s.jobId}),e.jsx("span",{children:R(s.schedule,s.scheduleText)}),e.jsxs("span",{children:["· ",s.mode]}),s.model?e.jsx("span",{className:"font-mono",children:s.model}):null,e.jsx(w,{label:new Date(s.armedAt).toLocaleString(),side:"top",children:e.jsxs("span",{className:"tabular-nums",children:["created ",C(p)," ago"]})}),c?e.jsxs("span",{className:"tabular-nums",children:["running for ",i(o-c.firedAt)]}):null,s.paused&&s.lastRun?e.jsxs("span",{className:"tabular-nums",children:["Last run: ",e.jsx(x,{status:s.lastRun.status})]}):null,!s.paused&&s.nextFireAt!==null?e.jsxs("span",{className:"tabular-nums",children:["next in ",i(Math.max(0,s.nextFireAt-o))]}):null,e.jsxs(P,{to:`/chat/${a.chatId}`,className:"inline-flex items-center gap-1 text-primary hover:underline",children:[e.jsx(E,{className:"h-3 w-3","aria-hidden":"true"}),a.chatTitle||"Open chat"]})]})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[s.paused?e.jsx("button",{type:"button","aria-label":`Resume cron job ${s.jobId}`,className:"rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-foreground",onClick:()=>l("cron.resume",a),children:e.jsx(S,{className:"h-3.5 w-3.5","aria-hidden":"true"})}):e.jsx("button",{type:"button","aria-label":`Pause cron job ${s.jobId}`,className:"rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-foreground",onClick:()=>l("cron.pause",a),children:e.jsx(A,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx("button",{type:"button","aria-label":`Remove cron job ${s.jobId}`,className:"rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-destructive",onClick:()=>l("cron.remove",a),children:e.jsx(I,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]},`${a.chatId} ${s.jobId}`)})})]},t.projectPath))})]})})}export{D as CronJobsPage};
1
+ import{f as b,h as f,r as m,j as e,S as g,C as N,g as v,H as w,i as C,k as i,L as P,X as I,d as k}from"./index-u7uCA_nx.js";import{u as y,C as L,a as x,h as R,P as S,b as A}from"./CronRunMessage-CWnhZpxr.js";import{E}from"./external-link-DwktYVMa.js";function D(){const n=b(t=>t.rows),d=f(),o=y(1e3),l=m.useCallback((t,a)=>{d.command({type:t,chatId:a.chatId,jobId:a.job.jobId}).catch(()=>{})},[d]),h=m.useMemo(()=>{const t=new Map;for(const a of n){const r=t.get(a.projectId)??{projectPath:a.projectPath,rows:[]};r.rows.push(a),t.set(a.projectId,r)}return[...t.values()]},[n]);return e.jsx("div",{className:g,children:e.jsxs("div",{className:"mx-auto w-full max-w-[900px] px-4 py-8",children:[e.jsxs("h1",{className:"flex items-center gap-2.5 text-lg font-semibold text-foreground",children:[e.jsx(N,{className:"h-5 w-5 text-muted-foreground","aria-hidden":"true"}),"Cron jobs",e.jsxs("span",{className:"text-sm font-normal text-muted-foreground tabular-nums",children:[n.length," armed"]})]}),n.length===0?e.jsxs("p",{className:"mt-6 text-sm text-muted-foreground",children:["No cron jobs armed anywhere. Arm one from any chat with"," ",e.jsx("code",{className:"font-mono text-xs",children:"/cron <instruction> inline|spawn <schedule>"}),"."]}):e.jsx("div",{className:"mt-6 space-y-6",children:h.map(t=>e.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[e.jsxs("h2",{className:"border-b border-border bg-card p-3 px-4 text-sm font-medium text-foreground",children:[v(t.projectPath),e.jsx("span",{className:"ml-2 font-mono text-xs font-normal text-muted-foreground",children:t.projectPath})]}),e.jsx("div",{children:t.rows.map((a,r)=>{var u;const s=a.job,j=r===t.rows.length-1,p=o-s.armedAt,c=((u=s.lastRun)==null?void 0:u.status)==="running"?s.lastRun:null;return e.jsxs("div",{className:k("flex items-center gap-3 bg-background px-4 py-2.5",!j&&"border-b border-border"),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm text-foreground",children:s.instruction}),s.paused?e.jsx(L,{}):null,!s.paused&&s.lastRun?e.jsx(x,{status:s.lastRun.status}):null]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-mono",children:s.jobId}),e.jsx("span",{children:R(s.schedule,s.scheduleText)}),e.jsxs("span",{children:["· ",s.mode]}),s.model?e.jsx("span",{className:"font-mono",children:s.model}):null,e.jsx(w,{label:new Date(s.armedAt).toLocaleString(),side:"top",children:e.jsxs("span",{className:"tabular-nums",children:["created ",C(p)," ago"]})}),c?e.jsxs("span",{className:"tabular-nums",children:["running for ",i(o-c.firedAt)]}):null,s.paused&&s.lastRun?e.jsxs("span",{className:"tabular-nums",children:["Last run: ",e.jsx(x,{status:s.lastRun.status})]}):null,!s.paused&&s.nextFireAt!==null?e.jsxs("span",{className:"tabular-nums",children:["next in ",i(Math.max(0,s.nextFireAt-o))]}):null,e.jsxs(P,{to:`/chat/${a.chatId}`,className:"inline-flex items-center gap-1 text-primary hover:underline",children:[e.jsx(E,{className:"h-3 w-3","aria-hidden":"true"}),a.chatTitle||"Open chat"]})]})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[s.paused?e.jsx("button",{type:"button","aria-label":`Resume cron job ${s.jobId}`,className:"rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-foreground",onClick:()=>l("cron.resume",a),children:e.jsx(S,{className:"h-3.5 w-3.5","aria-hidden":"true"})}):e.jsx("button",{type:"button","aria-label":`Pause cron job ${s.jobId}`,className:"rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-foreground",onClick:()=>l("cron.pause",a),children:e.jsx(A,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx("button",{type:"button","aria-label":`Remove cron job ${s.jobId}`,className:"rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-destructive",onClick:()=>l("cron.remove",a),children:e.jsx(I,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]},`${a.chatId} ${s.jobId}`)})})]},t.projectPath))})]})})}export{D as CronJobsPage};
@@ -1,4 +1,4 @@
1
- import{c as v,r as m,y as b,j as r,d as g,C as S,a0 as j,L as w}from"./index-Da6Q--VC.js";import{E as N}from"./external-link-Dn7b4TFh.js";/**
1
+ import{c as v,r as m,y as b,j as r,d as g,C as S,a0 as j,L as w}from"./index-u7uCA_nx.js";import{E as N}from"./external-link-DwktYVMa.js";/**
2
2
  * @license lucide-react v0.562.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{p as z,j as e,d as b,l as H,y as D,r as h,D as K,z as U,A as W,F as J,G as V,J as Y,I as L,K as q,B as v,M as n,s as M,N as g,P as G,O as Q,Q as X,T as Z,U as ee,g as te,V as se,Y as re,Z as oe,_ as ne,$ as ae,u as ie}from"./index-Da6Q--VC.js";import{M as _}from"./monitor-CcAlRKyi.js";import{C as F,T as ce}from"./terminal-CAxY-QfP.js";import{F as le}from"./folder-DO6XYlD4.js";const T=z("CopyButton",()=>t=>({copied:!1,setCopied:s=>t({copied:s})}));function O({narrow:t=!1,title:s,subtitle:o,icon:a=_}){return e.jsxs("div",{className:b("w-full",t?"max-w-2xl px-6 pt-16 mx-auto":"px-6 pt-16 mb-10"),children:[e.jsxs("div",{className:b("flex items-center gap-1 mb-2",t&&"justify-center"),children:[e.jsx("div",{className:"p-2 pl-0 rounded-lg",children:e.jsx(a,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:s})]}),o&&e.jsx("p",{className:b("text-muted-foreground",t&&"mb-10 text-center"),children:o})]})}const u=H()(t=>({tab:"new",name:"",existingPath:"",setTab:s=>t({tab:s}),setName:s=>t({name:s}),setExistingPath:s=>t({existingPath:s}),resetForOpen:()=>t({tab:"new",name:"",existingPath:""})})),de=()=>u(t=>t.tab),xe=()=>u(t=>t.name),me=()=>u(t=>t.existingPath);function ue(t){return t.toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}function he({open:t,onOpenChange:s,onConfirm:o,ports:a={}}){const l=a.timer??D,i=de(),d=xe(),x=me(),w=u(r=>r.setTab),j=u(r=>r.setName),m=u(r=>r.setExistingPath),f=u(r=>r.resetForOpen),c=h.useRef(null),E=h.useRef(null);h.useEffect(()=>{t&&(f(),l.setTimeout(()=>{var r;return(r=c.current)==null?void 0:r.focus()},0))},[t,f,l]),h.useEffect(()=>{t&&l.setTimeout(()=>{var r,I;i==="new"?(r=c.current)==null||r.focus():(I=E.current)==null||I.focus()},0)},[i,t,l]);const y=ue(d),P=y?`${Y}/${y}`:"",p=x.trim(),$=i==="new"?!!y:!!p,C=()=>{if($){if(i==="new")o({mode:"new",localPath:P,title:d.trim()});else{const r=p.split("/").pop()||p;o({mode:"existing",localPath:p,title:r})}s(!1)}};return e.jsx(K,{open:t,onOpenChange:s,children:e.jsxs(U,{size:"sm",children:[e.jsxs(W,{className:"space-y-4",children:[e.jsx(J,{children:"Add Project"}),e.jsx(V,{value:i,onValueChange:w,options:[{value:"new",label:"New Folder"},{value:"existing",label:"Existing Path"}],className:"w-full mb-2",optionClassName:"flex-1 justify-center"}),i==="new"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{ref:c,type:"text",value:d,onChange:r=>j(r.target.value),onKeyDown:r=>{r.key==="Enter"&&C(),r.key==="Escape"&&s(!1)},placeholder:"Project name"}),P&&e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:P})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{ref:E,type:"text",value:x,onChange:r=>m(r.target.value),onKeyDown:r=>{r.key==="Enter"&&C(),r.key==="Escape"&&s(!1)},placeholder:"~/Projects/my-app"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The folder will be created if it doesn't exist."})]})]}),e.jsxs(q,{children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Cancel"}),e.jsx(v,{variant:"secondary",size:"sm",onClick:C,disabled:!$,children:"Create"})]})]})})}function je({text:t,ports:s={}}){const o=T.useScopedStore(x=>x.copied),a=T.useScopedStore(x=>x.setCopied),l=s.clipboard??oe,i=s.timer??D;async function d(){await l.writeText(t),a(!0),i.setTimeout(()=>a(!1),2e3)}return e.jsx(v,{variant:"ghost",size:"icon-mobile","aria-label":o?"Copied":"Copy to clipboard",className:"text-muted-foreground hover:text-foreground",onClick:()=>void d(),children:o?e.jsx(ne,{className:"h-4 w-4 text-success"}):e.jsx(ae,{className:"h-4 w-4"})})}function fe({text:t}){return e.jsx(T.Provider,{init:{},children:e.jsx(je,{text:t})})}function R({children:t}){return e.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center group bg-background border border-border text-foreground rounded-xl p-1.5 pl-3 font-mono text-sm",children:[e.jsxs("pre",{className:"inline-flex items-center gap-2 overflow-x-auto",children:[e.jsx(X,{className:"inline h-4 w-4 opacity-40"}),e.jsx("code",{children:t})]}),e.jsx(fe,{text:t})]})}function N({children:t}){return e.jsx("div",{className:"bg-card border border-border rounded-2xl p-4",children:t})}function k({children:t}){return e.jsx("h2",{className:"text-13 font-medium text-muted-foreground tracking-wider mb-3",children:t})}function S({icon:t,title:s,subtitle:o,iconClassName:a}){return e.jsxs("div",{className:"flex flex-col items-start gap-1.5 min-w-0",children:[e.jsx(t,{className:a||"h-5 w-5 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:s}),e.jsx("span",{className:"text-xs text-muted-foreground leading-tight",children:o})]})}function A(){return e.jsx("div",{"aria-hidden":!0,className:"mt-5 h-px w-6 shrink-0 bg-border"})}function B({number:t,title:s,children:o}){return e.jsx("div",{className:"flex gap-4",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-baseline gap-3",children:[e.jsxs("div",{className:"flex-shrink-0 flex items-center justify-center font-medium text-logo",children:[t,"."]}),e.jsx("h3",{className:"font-medium text-foreground mb-2",children:s})]}),e.jsx("div",{className:"text-muted-foreground text-sm space-y-3",children:o})]})})}function pe({localPath:t,loading:s,onClick:o}){return e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsxs("button",{className:b("border border-border hover:border-primary/30 group rounded-lg bg-card px-4 py-3 flex items-center gap-3 w-full text-left hover:bg-muted/50 transition-colors",s&&"opacity-50 cursor-not-allowed"),disabled:s,onClick:o,children:[e.jsx(le,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"font-medium text-foreground truncate flex-1",children:te(t)}),s?e.jsx(M,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary animate-spin flex-shrink-0"}):e.jsx(se,{className:"h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]})}),e.jsx(re,{children:e.jsx("p",{children:t})})]})}function ge({connectionStatus:t,ready:s,snapshot:o,startingLocalPath:a,commandError:l,newProjectOpen:i,onNewProjectOpenChange:d,onOpenProject:x,onCreateProject:w}){const j=h.useMemo(()=>(o==null?void 0:o.projects)??[],[o==null?void 0:o.projects]),m=t==="connecting"||!s,f=t==="connected"&&s;return e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-y-auto",children:[f?e.jsxs(e.Fragment,{children:[e.jsx(O,{title:(o==null?void 0:o.machine.displayName)??"Local Projects",subtitle:`${n} is connected, choose a project below to get started.`}),e.jsxs("div",{className:"w-full px-6 mb-10",children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsx("h2",{className:"text-13 font-medium text-muted-foreground tracking-wider",children:"Projects"}),e.jsxs(v,{variant:"default",size:"sm",onClick:()=>d(!0),children:[e.jsx(G,{className:"h-4 w-4 mr-1.5"}),"Add Project"]})]}),j.length>0?e.jsx("div",{className:"grid gap-2 [grid-template-columns:repeat(auto-fill,minmax(min(260px,100%),1fr))]",children:j.map(c=>e.jsx(pe,{localPath:c.localPath,loading:a===c.localPath,onClick:()=>{x(c.localPath)}},c.localPath))}):e.jsx(N,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No local projects discovered yet. Open one with Claude or Codex, or create a new project here."})}),l?e.jsx("div",{className:"text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3 mt-4",children:l}):null]})]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{narrow:!0,icon:F,title:m?`Connecting ${n}`:`Connect ${n}`,subtitle:m?`${n} is starting up and loading your local projects.`:`Run ${n} directly on your machine with full access to your local files and agent project history.`}),e.jsxs("div",{className:"max-w-2xl w-full mx-auto pb-12 px-6",children:[e.jsx(k,{children:"Status"}),e.jsx("div",{className:"mb-8",children:e.jsx(N,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(M,{className:"h-4 w-4 text-muted-foreground animate-spin"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:m?`Connecting to your local ${n} server...`:e.jsxs(e.Fragment,{children:["Not connected. Run ",e.jsx("code",{className:"bg-background border border-border rounded-md mx-0.5 p-1 font-mono text-xs text-foreground",children:g()})," from any terminal on this machine."]})})]})})}),m?null:e.jsxs("div",{className:"mb-10",children:[e.jsx(k,{children:"How it works"}),e.jsx(N,{children:e.jsxs("div",{className:"flex items-start gap-4 py-2 px-2",children:[e.jsx(S,{icon:ce,title:`${n} CLI`,subtitle:"On Your Machine"}),e.jsx(A,{}),e.jsx(S,{icon:_,title:`${n} Server`,subtitle:"Local WebSocket"}),e.jsx(A,{}),e.jsx(S,{icon:F,title:`${n} UI`,subtitle:"Project Chat"})]})})]}),m?null:e.jsxs("div",{className:"mb-10",children:[e.jsx(k,{children:"Setup"}),e.jsx(N,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(B,{number:1,title:`Start ${n}`,children:[e.jsx("p",{children:"Run this command in your terminal:"}),e.jsx(R,{children:g()})]}),e.jsxs(B,{number:2,title:"Open the local UI",children:[e.jsxs("p",{children:[n," serves the app locally and opens the Local Projects page in an app-style browser window."]}),e.jsx(R,{children:"http://localhost:3210/local"})]}),e.jsxs("div",{className:"mt-8",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground tracking-wider mb-4",children:"Notes"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex gap-4",children:[e.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:g("").trim()}),e.jsx("span",{className:"text-muted-foreground",children:"Start in the current directory"})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:g("--no-open")}),e.jsx("span",{className:"text-muted-foreground",children:"Start the server without opening the browser"})]})]})]})]})})]})]})]}),e.jsx(he,{open:i,onOpenChange:d,onConfirm:c=>{w(c)}}),e.jsx("div",{className:"py-4 text-center",children:e.jsxs("span",{className:"text-xs text-muted-foreground/50",children:["v",Q.split("/")[1]]})})]})}function ye(){const t=ie();return e.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 relative",children:e.jsx(ge,{connectionStatus:t.connectionStatus,ready:t.localProjectsReady,snapshot:t.localProjects,startingLocalPath:t.startingLocalPath,commandError:t.commandError,newProjectOpen:t.addProjectModalOpen,onNewProjectOpenChange:s=>{if(s){t.openAddProjectModal();return}t.closeAddProjectModal()},onOpenProject:t.handleOpenLocalProject,onCreateProject:t.handleCreateProject})})}export{ye as LocalProjectsPage};
1
+ import{p as z,j as e,d as b,l as H,y as D,r as h,D as K,z as U,A as W,F as J,G as V,J as Y,I as L,K as q,B as v,M as n,s as M,N as g,P as G,O as Q,Q as X,T as Z,U as ee,g as te,V as se,Y as re,Z as oe,_ as ne,$ as ae,u as ie}from"./index-u7uCA_nx.js";import{M as _}from"./monitor-CrU4rsYb.js";import{C as F,T as ce}from"./terminal-DfBnyME3.js";import{F as le}from"./folder-MCCIA_mr.js";const T=z("CopyButton",()=>t=>({copied:!1,setCopied:s=>t({copied:s})}));function O({narrow:t=!1,title:s,subtitle:o,icon:a=_}){return e.jsxs("div",{className:b("w-full",t?"max-w-2xl px-6 pt-16 mx-auto":"px-6 pt-16 mb-10"),children:[e.jsxs("div",{className:b("flex items-center gap-1 mb-2",t&&"justify-center"),children:[e.jsx("div",{className:"p-2 pl-0 rounded-lg",children:e.jsx(a,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:s})]}),o&&e.jsx("p",{className:b("text-muted-foreground",t&&"mb-10 text-center"),children:o})]})}const u=H()(t=>({tab:"new",name:"",existingPath:"",setTab:s=>t({tab:s}),setName:s=>t({name:s}),setExistingPath:s=>t({existingPath:s}),resetForOpen:()=>t({tab:"new",name:"",existingPath:""})})),de=()=>u(t=>t.tab),xe=()=>u(t=>t.name),me=()=>u(t=>t.existingPath);function ue(t){return t.toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}function he({open:t,onOpenChange:s,onConfirm:o,ports:a={}}){const l=a.timer??D,i=de(),d=xe(),x=me(),w=u(r=>r.setTab),j=u(r=>r.setName),m=u(r=>r.setExistingPath),f=u(r=>r.resetForOpen),c=h.useRef(null),E=h.useRef(null);h.useEffect(()=>{t&&(f(),l.setTimeout(()=>{var r;return(r=c.current)==null?void 0:r.focus()},0))},[t,f,l]),h.useEffect(()=>{t&&l.setTimeout(()=>{var r,I;i==="new"?(r=c.current)==null||r.focus():(I=E.current)==null||I.focus()},0)},[i,t,l]);const y=ue(d),P=y?`${Y}/${y}`:"",p=x.trim(),$=i==="new"?!!y:!!p,C=()=>{if($){if(i==="new")o({mode:"new",localPath:P,title:d.trim()});else{const r=p.split("/").pop()||p;o({mode:"existing",localPath:p,title:r})}s(!1)}};return e.jsx(K,{open:t,onOpenChange:s,children:e.jsxs(U,{size:"sm",children:[e.jsxs(W,{className:"space-y-4",children:[e.jsx(J,{children:"Add Project"}),e.jsx(V,{value:i,onValueChange:w,options:[{value:"new",label:"New Folder"},{value:"existing",label:"Existing Path"}],className:"w-full mb-2",optionClassName:"flex-1 justify-center"}),i==="new"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{ref:c,type:"text",value:d,onChange:r=>j(r.target.value),onKeyDown:r=>{r.key==="Enter"&&C(),r.key==="Escape"&&s(!1)},placeholder:"Project name"}),P&&e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:P})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{ref:E,type:"text",value:x,onChange:r=>m(r.target.value),onKeyDown:r=>{r.key==="Enter"&&C(),r.key==="Escape"&&s(!1)},placeholder:"~/Projects/my-app"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The folder will be created if it doesn't exist."})]})]}),e.jsxs(q,{children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Cancel"}),e.jsx(v,{variant:"secondary",size:"sm",onClick:C,disabled:!$,children:"Create"})]})]})})}function je({text:t,ports:s={}}){const o=T.useScopedStore(x=>x.copied),a=T.useScopedStore(x=>x.setCopied),l=s.clipboard??oe,i=s.timer??D;async function d(){await l.writeText(t),a(!0),i.setTimeout(()=>a(!1),2e3)}return e.jsx(v,{variant:"ghost",size:"icon-mobile","aria-label":o?"Copied":"Copy to clipboard",className:"text-muted-foreground hover:text-foreground",onClick:()=>void d(),children:o?e.jsx(ne,{className:"h-4 w-4 text-success"}):e.jsx(ae,{className:"h-4 w-4"})})}function fe({text:t}){return e.jsx(T.Provider,{init:{},children:e.jsx(je,{text:t})})}function R({children:t}){return e.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center group bg-background border border-border text-foreground rounded-xl p-1.5 pl-3 font-mono text-sm",children:[e.jsxs("pre",{className:"inline-flex items-center gap-2 overflow-x-auto",children:[e.jsx(X,{className:"inline h-4 w-4 opacity-40"}),e.jsx("code",{children:t})]}),e.jsx(fe,{text:t})]})}function N({children:t}){return e.jsx("div",{className:"bg-card border border-border rounded-2xl p-4",children:t})}function k({children:t}){return e.jsx("h2",{className:"text-13 font-medium text-muted-foreground tracking-wider mb-3",children:t})}function S({icon:t,title:s,subtitle:o,iconClassName:a}){return e.jsxs("div",{className:"flex flex-col items-start gap-1.5 min-w-0",children:[e.jsx(t,{className:a||"h-5 w-5 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:s}),e.jsx("span",{className:"text-xs text-muted-foreground leading-tight",children:o})]})}function A(){return e.jsx("div",{"aria-hidden":!0,className:"mt-5 h-px w-6 shrink-0 bg-border"})}function B({number:t,title:s,children:o}){return e.jsx("div",{className:"flex gap-4",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-baseline gap-3",children:[e.jsxs("div",{className:"flex-shrink-0 flex items-center justify-center font-medium text-logo",children:[t,"."]}),e.jsx("h3",{className:"font-medium text-foreground mb-2",children:s})]}),e.jsx("div",{className:"text-muted-foreground text-sm space-y-3",children:o})]})})}function pe({localPath:t,loading:s,onClick:o}){return e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsxs("button",{className:b("border border-border hover:border-primary/30 group rounded-lg bg-card px-4 py-3 flex items-center gap-3 w-full text-left hover:bg-muted/50 transition-colors",s&&"opacity-50 cursor-not-allowed"),disabled:s,onClick:o,children:[e.jsx(le,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"font-medium text-foreground truncate flex-1",children:te(t)}),s?e.jsx(M,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary animate-spin flex-shrink-0"}):e.jsx(se,{className:"h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]})}),e.jsx(re,{children:e.jsx("p",{children:t})})]})}function ge({connectionStatus:t,ready:s,snapshot:o,startingLocalPath:a,commandError:l,newProjectOpen:i,onNewProjectOpenChange:d,onOpenProject:x,onCreateProject:w}){const j=h.useMemo(()=>(o==null?void 0:o.projects)??[],[o==null?void 0:o.projects]),m=t==="connecting"||!s,f=t==="connected"&&s;return e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-y-auto",children:[f?e.jsxs(e.Fragment,{children:[e.jsx(O,{title:(o==null?void 0:o.machine.displayName)??"Local Projects",subtitle:`${n} is connected, choose a project below to get started.`}),e.jsxs("div",{className:"w-full px-6 mb-10",children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsx("h2",{className:"text-13 font-medium text-muted-foreground tracking-wider",children:"Projects"}),e.jsxs(v,{variant:"default",size:"sm",onClick:()=>d(!0),children:[e.jsx(G,{className:"h-4 w-4 mr-1.5"}),"Add Project"]})]}),j.length>0?e.jsx("div",{className:"grid gap-2 [grid-template-columns:repeat(auto-fill,minmax(min(260px,100%),1fr))]",children:j.map(c=>e.jsx(pe,{localPath:c.localPath,loading:a===c.localPath,onClick:()=>{x(c.localPath)}},c.localPath))}):e.jsx(N,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No local projects discovered yet. Open one with Claude or Codex, or create a new project here."})}),l?e.jsx("div",{className:"text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3 mt-4",children:l}):null]})]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{narrow:!0,icon:F,title:m?`Connecting ${n}`:`Connect ${n}`,subtitle:m?`${n} is starting up and loading your local projects.`:`Run ${n} directly on your machine with full access to your local files and agent project history.`}),e.jsxs("div",{className:"max-w-2xl w-full mx-auto pb-12 px-6",children:[e.jsx(k,{children:"Status"}),e.jsx("div",{className:"mb-8",children:e.jsx(N,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(M,{className:"h-4 w-4 text-muted-foreground animate-spin"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:m?`Connecting to your local ${n} server...`:e.jsxs(e.Fragment,{children:["Not connected. Run ",e.jsx("code",{className:"bg-background border border-border rounded-md mx-0.5 p-1 font-mono text-xs text-foreground",children:g()})," from any terminal on this machine."]})})]})})}),m?null:e.jsxs("div",{className:"mb-10",children:[e.jsx(k,{children:"How it works"}),e.jsx(N,{children:e.jsxs("div",{className:"flex items-start gap-4 py-2 px-2",children:[e.jsx(S,{icon:ce,title:`${n} CLI`,subtitle:"On Your Machine"}),e.jsx(A,{}),e.jsx(S,{icon:_,title:`${n} Server`,subtitle:"Local WebSocket"}),e.jsx(A,{}),e.jsx(S,{icon:F,title:`${n} UI`,subtitle:"Project Chat"})]})})]}),m?null:e.jsxs("div",{className:"mb-10",children:[e.jsx(k,{children:"Setup"}),e.jsx(N,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(B,{number:1,title:`Start ${n}`,children:[e.jsx("p",{children:"Run this command in your terminal:"}),e.jsx(R,{children:g()})]}),e.jsxs(B,{number:2,title:"Open the local UI",children:[e.jsxs("p",{children:[n," serves the app locally and opens the Local Projects page in an app-style browser window."]}),e.jsx(R,{children:"http://localhost:3210/local"})]}),e.jsxs("div",{className:"mt-8",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground tracking-wider mb-4",children:"Notes"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex gap-4",children:[e.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:g("").trim()}),e.jsx("span",{className:"text-muted-foreground",children:"Start in the current directory"})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:g("--no-open")}),e.jsx("span",{className:"text-muted-foreground",children:"Start the server without opening the browser"})]})]})]})]})})]})]})]}),e.jsx(he,{open:i,onOpenChange:d,onConfirm:c=>{w(c)}}),e.jsx("div",{className:"py-4 text-center",children:e.jsxs("span",{className:"text-xs text-muted-foreground/50",children:["v",Q.split("/")[1]]})})]})}function ye(){const t=ie();return e.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 relative",children:e.jsx(ge,{connectionStatus:t.connectionStatus,ready:t.localProjectsReady,snapshot:t.localProjects,startingLocalPath:t.startingLocalPath,commandError:t.commandError,newProjectOpen:t.addProjectModalOpen,onNewProjectOpenChange:s=>{if(s){t.openAddProjectModal();return}t.closeAddProjectModal()},onOpenProject:t.handleOpenLocalProject,onCreateProject:t.handleCreateProject})})}export{ye as LocalProjectsPage};
@@ -1,4 +1,4 @@
1
- import{c as Y,l as Ee,ay as me,az as be,ar as ie,aA as fn,aB as ze,as as Ut,r as N,aC as gn,aD as _t,j as e,I as P,d as re,B as O,P as Se,G as Q,ax as pn,aE as ba,at as va,aF as ja,aw as Na,aG as ya,aH as Ce,aI as As,aJ as ka,aK as Ft,aL as Ca,H as De,$ as wa,Z as Sa,aM as ct,aN as Ea,aO as Ot,aP as bn,y as vn,aQ as jn,T as Nn,U as yn,Y as kn,aR as Da,aS as Ma,aT as Cn,s as oe,e as Ta,aU as Pa,aV as Is,a as Aa,b as Ia,u as _a,aW as Oa,O as La,aX as ue,aY as at,aZ as lt,a_ as ye,a$ as Ra,b0 as Ua,b1 as Fa,b2 as Va,b3 as za,b4 as _s,b5 as wt,b6 as Lt,b7 as St,b8 as Ka,b9 as Wa,ba as $a,bb as Ba,bc as Ha,bd as Ga,be as Ya,bf as qa,bg as Os,bh as Ls,bi as Xa,bj as Rs,bk as Us,bl as Qa,bm as Za,bn as Et,bo as Dt,bp as rt,bq as ot,br as Ja,bs as Rt,bt as el,D as Fs,z as Vs,A as zs,F as Ks,K as Ws,X as tl,bu as sl,bv as nl,bw as $s,bx as al,by as ll}from"./index-Da6Q--VC.js";import{S as J,a as ee,b as te,c as se,d as W,B as Vt,K as rl,D as Bs,e as ol,f as fe,E as il,g as dl,M as Hs,h as Gs,C as Ys,i as cl}from"./ChatPreferenceControls-C8_AU8Ea.js";import{E as zt}from"./external-link-Dn7b4TFh.js";import{R as ul,S as ml}from"./search-B5O9tejp.js";import{S as Ke}from"./settings-header-button-D1JRdGKR.js";import{M as xl}from"./monitor-CcAlRKyi.js";/**
1
+ import{c as Y,l as Ee,ay as me,az as be,ar as ie,aA as fn,aB as ze,as as Ut,r as N,aC as gn,aD as _t,j as e,I as P,d as re,B as O,P as Se,G as Q,ax as pn,aE as ba,at as va,aF as ja,aw as Na,aG as ya,aH as Ce,aI as As,aJ as ka,aK as Ft,aL as Ca,H as De,$ as wa,Z as Sa,aM as ct,aN as Ea,aO as Ot,aP as bn,y as vn,aQ as jn,T as Nn,U as yn,Y as kn,aR as Da,aS as Ma,aT as Cn,s as oe,e as Ta,aU as Pa,aV as Is,a as Aa,b as Ia,u as _a,aW as Oa,O as La,aX as ue,aY as at,aZ as lt,a_ as ye,a$ as Ra,b0 as Ua,b1 as Fa,b2 as Va,b3 as za,b4 as _s,b5 as wt,b6 as Lt,b7 as St,b8 as Ka,b9 as Wa,ba as $a,bb as Ba,bc as Ha,bd as Ga,be as Ya,bf as qa,bg as Os,bh as Ls,bi as Xa,bj as Rs,bk as Us,bl as Qa,bm as Za,bn as Et,bo as Dt,bp as rt,bq as ot,br as Ja,bs as Rt,bt as el,D as Fs,z as Vs,A as zs,F as Ks,K as Ws,X as tl,bu as sl,bv as nl,bw as $s,bx as al,by as ll}from"./index-u7uCA_nx.js";import{S as J,a as ee,b as te,c as se,d as W,B as Vt,K as rl,D as Bs,e as ol,f as fe,E as il,g as dl,M as Hs,h as Gs,C as Ys,i as cl}from"./ChatPreferenceControls-CjzVhGJs.js";import{E as zt}from"./external-link-DwktYVMa.js";import{R as ul,S as ml}from"./search-DAIo8ajC.js";import{S as Ke}from"./settings-header-button-_r-gvFLd.js";import{M as xl}from"./monitor-CrU4rsYb.js";/**
2
2
  * @license lucide-react v0.562.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{u as i,a as d,b as l,r as m,j as n}from"./index-Da6Q--VC.js";import{B as k}from"./BoardsPage-aVUB66Sg.js";import"./columnStyle-DYH9vt9P.js";function f(){const s=i(),e=d(),{stackId:a=""}=l(),o=s.sidebarData.stacks.find(t=>t.id===a),r=o?o.title:"Stack",c=m.useCallback(t=>{e(`/boards/stack/${a}/${t}`)},[e,a]);return n.jsx("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:n.jsx(k,{ownerKind:"stack",ownerId:a,ownerName:r,socket:s.socket,onOpenBoard:c})})}export{f as StackBoardsRoutePage};
1
+ import{u as i,a as d,b as l,r as m,j as n}from"./index-u7uCA_nx.js";import{B as k}from"./BoardsPage-CTjhzYPs.js";import"./columnStyle-BUhiREXS.js";function f(){const s=i(),e=d(),{stackId:a=""}=l(),o=s.sidebarData.stacks.find(t=>t.id===a),r=o?o.title:"Stack",c=m.useCallback(t=>{e(`/boards/stack/${a}/${t}`)},[e,a]);return n.jsx("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:n.jsx(k,{ownerKind:"stack",ownerId:a,ownerName:r,socket:s.socket,onOpenBoard:c})})}export{f as StackBoardsRoutePage};
@@ -1,4 +1,4 @@
1
- import{c as T,p as W,j as e,r as u,q as L,s as P,u as B,a as V,b as q,t as M,v as O,x as _,W as z,d as A}from"./index-Da6Q--VC.js";import{S as F,a as H,W as G,b as Y}from"./WorkflowsSection-B5T59wER.js";import{R as $}from"./search-B5O9tejp.js";import{S as D}from"./settings-header-button-D1JRdGKR.js";import"./terminal-CAxY-QfP.js";/**
1
+ import{c as T,p as W,j as e,r as u,q as L,s as P,u as B,a as V,b as q,t as M,v as O,x as _,W as z,d as A}from"./index-u7uCA_nx.js";import{S as F,a as H,W as G,b as Y}from"./WorkflowsSection-Bykl8tZu.js";import{R as $}from"./search-DAIo8ajC.js";import{S as D}from"./settings-header-button-_r-gvFLd.js";import"./terminal-DfBnyME3.js";/**
2
2
  * @license lucide-react v0.562.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-DHuSoCjt.js","assets/index-Da6Q--VC.js","assets/index-C7q7I53R.css","assets/index-DXSQvXUy.js"])))=>i.map(i=>d[i]);
2
- var tn=Object.defineProperty;var nn=(e,t,r)=>t in e?tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var k=(e,t,r)=>nn(e,typeof t!="symbol"?t+"":t,r);import{c as j,bz as Me,aM as I,y as me,j as n,d as b,X as pe,p as R,r as g,aJ as rn,Q as ct,Z as xe,B as E,_ as Ee,$ as Ie,bA as H,bB as q,bC as sn,af as on,P as an,bD as dt,aW as ln,bE as ut,bF as $e,bG as cn,bH as dn,bI as un,bJ as mn,bK as pn,bL as xn,bM as hn,bN as fn,bO as gn,bP as yn,bQ as bn,bR as jn,bS as vn,bT as Nn,bU as wn,bV as kn,bW as _n,bX as Sn,bY as Tn,bZ as Cn,b_ as Ae,b$ as ze,c0 as Pe,c1 as Mn,c2 as En,c3 as In,c4 as $n,c5 as Rn,c6 as Ln,c7 as Oe,c8 as Fe,c9 as An,ca as zn,cb as Pn,cc as On,cd as Fn,ce as ve,D as mt,z as pt,F as xt,cf as Dn,cg as Bn,ch as Kn,ci as ht,cj as ft,ck as Re,q as Un,i as he,s as gt,t as Wn,v as Vn,x as Hn,cl as qn,cm as De,aI as se,L as Gn,cn as Jn,A as Xn}from"./index-Da6Q--VC.js";import{S as ye,L as Be,R as Yn}from"./search-B5O9tejp.js";import{T as Zn,C as Qn}from"./terminal-CAxY-QfP.js";/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-ChAu8gwz.js","assets/index-u7uCA_nx.js","assets/index-C7q7I53R.css","assets/index-CZwuLrNi.js"])))=>i.map(i=>d[i]);
2
+ var tn=Object.defineProperty;var nn=(e,t,r)=>t in e?tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var k=(e,t,r)=>nn(e,typeof t!="symbol"?t+"":t,r);import{c as j,bz as Me,aM as I,y as me,j as n,d as b,X as pe,p as R,r as g,aJ as rn,Q as ct,Z as xe,B as E,_ as Ee,$ as Ie,bA as H,bB as q,bC as sn,af as on,P as an,bD as dt,aW as ln,bE as ut,bF as $e,bG as cn,bH as dn,bI as un,bJ as mn,bK as pn,bL as xn,bM as hn,bN as fn,bO as gn,bP as yn,bQ as bn,bR as jn,bS as vn,bT as Nn,bU as wn,bV as kn,bW as _n,bX as Sn,bY as Tn,bZ as Cn,b_ as Ae,b$ as ze,c0 as Pe,c1 as Mn,c2 as En,c3 as In,c4 as $n,c5 as Rn,c6 as Ln,c7 as Oe,c8 as Fe,c9 as An,ca as zn,cb as Pn,cc as On,cd as Fn,ce as ve,D as mt,z as pt,F as xt,cf as Dn,cg as Bn,ch as Kn,ci as ht,cj as ft,ck as Re,q as Un,i as he,s as gt,t as Wn,v as Vn,x as Hn,cl as qn,cm as De,aI as se,L as Gn,cn as Jn,A as Xn}from"./index-u7uCA_nx.js";import{S as ye,L as Be,R as Yn}from"./search-DAIo8ajC.js";import{T as Zn,C as Qn}from"./terminal-DfBnyME3.js";/**
3
3
  * @license lucide-react v0.562.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
@@ -163,11 +163,11 @@ var tn=Object.defineProperty;var nn=(e,t,r)=>t in e?tn(e,t,{enumerable:!0,config
163
163
  `):e}function zs(e){if(!e.includes("#")||!e.includes("http"))return e;const t=[],r=new RegExp($s.source,"g");let s;for(;(s=r.exec(e))!==null;){let c=s[0];const m=c.match(Ls);m&&(c=c.slice(0,-m[0].length)),t.push({start:s.index,end:s.index+c.length,url:c})}if(t.length===0)return e;const o=[],a=new RegExp(Rs.source,"gi");for(;(s=a.exec(e))!==null;){const c=e.slice(0,s.index);c.lastIndexOf("[")>c.lastIndexOf("]")||o.push({start:s.index,end:s.index+s[0].length,full:s[0],num:s[2]??""})}if(o.length===0)return e;const i=new Map;for(const c of o){const m=t.find(p=>{try{const{pathname:y,search:x}=new URL(p.url),v=y+x;return new RegExp(`(?:/|\\.|-|=)${c.num}(?:[/?&#]|$)`).test(v)}catch{return!1}});if(m){i.set(c.start,m.url);continue}const u=t.find(p=>p.start>c.end);if(u){const p=e.slice(c.end,u.start);!/[.!?]\s/.test(p)&&p.length<200&&i.set(c.start,u.url)}}if(i.size===0)return e;const l=o.filter(c=>i.has(c.start)).sort((c,m)=>m.start-c.start);let d=e;for(const c of l){const m=i.get(c.start);d=`${d.slice(0,c.start)}[${c.full}](${m})${d.slice(c.end)}`}return d}class J extends H{constructor(r,s,o,a,i=I){super(a);k(this,"__mentionKind");k(this,"__value");k(this,"__label");k(this,"__dom");this.__mentionKind=r,this.__value=s,this.__label=o,this.__dom=i}static getType(){return"kanna-mention"}static clone(r){return new J(r.__mentionKind,r.__value,r.__label,r.__key,r.__dom)}static importJSON(r){return Ps({mentionKind:r.mentionKind,value:r.value,label:r.label})}exportJSON(){return{type:J.getType(),version:1,mentionKind:this.__mentionKind,value:this.__value,label:this.__label}}createDOM(r,s){const o=this.__dom.createElement("span");return o.dataset.lexicalDecorator="true",o}updateDOM(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}getTextContent(){return this.__mentionKind==="agent"?`@agent/${this.__value}`:`@${this.__value}`}decorate(r,s){const o=this.__label;return this.__mentionKind==="agent"?n.jsx("span",{className:b("inline-flex items-center rounded px-1 text-sm","bg-primary/10 text-primary border border-primary/20"),children:o}):n.jsx("span",{className:b("inline-flex items-center rounded px-1 text-sm","bg-muted text-muted-foreground border border-border"),children:o})}}function Ps(e){return q(new J(e.mentionKind,e.value,e.label))}class X extends H{constructor(r,s,o,a=I){super(o);k(this,"__commandName");k(this,"__hasArgument");k(this,"__dom");this.__commandName=r,this.__hasArgument=s,this.__dom=a}static getType(){return"kanna-slash-command"}static clone(r){return new X(r.__commandName,r.__hasArgument,r.__key,r.__dom)}static importJSON(r){return Os({commandName:r.commandName,hasArgument:r.hasArgument})}exportJSON(){return{type:X.getType(),version:1,commandName:this.__commandName,hasArgument:this.__hasArgument}}createDOM(r,s){const o=this.__dom.createElement("span");return o.dataset.lexicalDecorator="true",o}updateDOM(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}getTextContent(){return this.__hasArgument?`/${this.__commandName} `:`/${this.__commandName}`}decorate(r,s){return n.jsx("span",{className:b("inline-flex items-center rounded px-1 text-sm font-mono","bg-muted text-muted-foreground border border-border"),children:`/${this.__commandName}`})}}function Os(e){return q(new X(e.commandName,e.hasArgument))}class V extends H{constructor(r,s,o=I){super(s);k(this,"__attachment");k(this,"__dom");this.__attachment=r,this.__dom=o}static getType(){return"kanna-attachment"}static clone(r){return new V(r.__attachment,r.__key,r.__dom)}static importJSON(r){return Fs(r.attachment)}getAttachment(){return this.getLatest().__attachment}isInline(){return!0}isKeyboardSelectable(){return!0}getTextContent(){return""}createDOM(r,s){return this.__dom.createElement("span")}updateDOM(){return!1}exportJSON(){return{type:V.getType(),version:1,attachment:this.__attachment}}decorate(r,s){const o=this.getLatest().__attachment;return o.kind==="image"&&o.contentUrl?n.jsx(ks,{attachment:o,size:"composer"}):n.jsx(oe,{attachment:o})}}function Fs(e){return q(new V(e))}function oi(){return sn(V)}const Ds=.25,Bs=8,Xe=.25;function Ye(e){return Math.min(Bs,Math.max(Ds,e))}function Ks(){return e=>({scale:1,offset:{x:0,y:0},drag:null,zoomIn:()=>e(t=>{const r=Ye(t.scale+Xe);return r===t.scale?t:{scale:r}}),zoomOut:()=>e(t=>{const r=Ye(t.scale-Xe);return r===t.scale?t:{scale:r}}),resetView:()=>e({scale:1,offset:{x:0,y:0}}),beginDrag:(t,r)=>e(s=>({drag:{x:t-s.offset.x,y:r-s.offset.y}})),dragTo:(t,r)=>e(s=>s.drag?{offset:{x:t-s.drag.x,y:r-s.drag.y}}:s),endDrag:()=>e({drag:null})})}const L=R("MermaidZoomModal",Ks);function Us({svg:e,onClose:t,ports:r}){const s=(r==null?void 0:r.dom)??I,o=L.useScopedStore(x=>x.scale),a=L.useScopedStore(x=>x.offset),i=L.useScopedStore(x=>x.zoomIn),l=L.useScopedStore(x=>x.zoomOut),d=L.useScopedStore(x=>x.resetView),c=L.useScopedStore(x=>x.beginDrag),m=L.useScopedStore(x=>x.dragTo),u=L.useScopedStore(x=>x.endDrag);g.useEffect(()=>{const x=v=>{v.key==="Escape"&&t()};return s.addWindowListener("keydown",x)},[t,s]);const p=x=>c(x.clientX,x.clientY),y=x=>m(x.clientX,x.clientY);return on.createPortal(n.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col bg-background/95",role:"dialog","aria-modal":"true","aria-label":"Diagram zoom view",children:[n.jsxs("div",{className:"flex justify-end gap-1 p-2",children:[n.jsx(E,{variant:"ghost",size:"icon","aria-label":"Zoom out",className:"h-9 w-9",onClick:l,children:n.jsx(zr,{className:"h-4 w-4"})}),n.jsx(E,{variant:"ghost",size:"icon","aria-label":"Zoom in",className:"h-9 w-9",onClick:i,children:n.jsx(an,{className:"h-4 w-4"})}),n.jsx(E,{variant:"ghost",size:"icon","aria-label":"Reset view",className:"h-9 w-9",onClick:d,children:n.jsx(Dr,{className:"h-4 w-4"})}),n.jsx(E,{variant:"ghost",size:"icon","aria-label":"Close",className:"h-9 w-9",onClick:t,children:n.jsx(pe,{className:"h-4 w-4"})})]}),n.jsx("div",{className:"flex-1 overflow-hidden touch-none cursor-grab active:cursor-grabbing",onPointerDown:p,onPointerMove:y,onPointerUp:u,onPointerLeave:u,children:n.jsx("div",{"data-mermaid-stage":!0,className:"w-full h-full flex items-center justify-center",style:{transform:`translate(${a.x}px, ${a.y}px) scale(${o})`},dangerouslySetInnerHTML:{__html:e}})})]}),s.getBodyElement())}function Ws({svg:e,onClose:t,ports:r}){return n.jsx(L.Provider,{init:void 0,children:n.jsx(Us,{svg:e,onClose:t,ports:r})})}const A=R("MermaidDiagram",()=>e=>({renderState:{status:"loading"},showSource:!1,zoomOpen:!1,copied:!1,setRenderState:t=>e({renderState:t}),setShowSource:t=>e({showSource:t}),setZoomOpen:t=>e({zoomOpen:t}),setCopied:t=>e({copied:t})})),Ze=/error on line (\d+)\s*[.:]?\s*(.*)$/i,Vs=/^[\s-]*\^\s*$/;function Qe(e){return e.map(t=>t.trim()).filter(t=>t.length>0).join(" ")}function Hs(e){const t=e.trim();if(t.length===0)return{line:null,summary:"Unknown error",excerpt:null};const r=t.split(`
164
164
  `),s=r.findIndex(u=>Ze.test(u)),o=s===-1?null:Ze.exec(r[s]??"");if(o===null)return{line:null,summary:Qe(r),excerpt:null};const a=Number(o[1]),i=r.slice(s+1),l=i.findIndex(u=>Vs.test(u)),d=l===-1?null:i.slice(0,l+1).join(`
165
165
  `),c=l===-1?i:i.slice(l+1),m=Qe([o[2]??"",...c]);return{line:Number.isInteger(a)?a:null,summary:m.length>0?m:`Parse error on line ${String(a)}`,excerpt:d}}const qs=[{from:"-.x",to:"-.-x"},{from:"-.o",to:"-.-o"}],ee={"[":"]","(":")","{":"}"};function Gs(e){const t=[];let r="",s=1,o=0,a=!1,i=!1,l=!1;const d=[];for(;o<e.length;){const c=e[o]??"";if(c===`
166
- `){i=!1,l=!1,a=!1,d.length=0,s+=1,r+=c,o+=1;continue}if(i){r+=c,o+=1;continue}if(a){c==='"'&&(a=!1),r+=c,o+=1;continue}if(c==='"'){a=!0,r+=c,o+=1;continue}if(e.startsWith("%%",o)){i=!0,r+="%%",o+=2;continue}if(d.length>0){c===d[d.length-1]?d.pop():ee[c]&&d.push(ee[c]),r+=c,o+=1;continue}if(ee[c]){d.push(ee[c]),r+=c,o+=1;continue}if(c==="|"){l=!l,r+=c,o+=1;continue}if(l){r+=c,o+=1;continue}const m=qs.find(u=>e.startsWith(u.from,o));if(m){r+=m.to,t.push({line:s,from:m.from,to:m.to}),o+=m.from.length;continue}r+=c,o+=1}return{source:r,repairs:t}}const Js=["failed to fetch dynamically imported module","error loading dynamically imported module","importing a module script failed"];function Xs(e){const t=e.message.toLowerCase();return Js.some(r=>t.includes(r))}function Ys(e){let t=null;return()=>(t||(t=e().catch(r=>{throw t=null,dt(r)})),t)}const Zs=Ys(()=>ut(()=>import("./mermaid.core-DHuSoCjt.js").then(e=>e.bm),__vite__mapDeps([0,1,2])).then(e=>e.default));async function Qs(e,t,r){try{const{svg:s}=await e.render(t,r);return{svg:s,repairs:[]}}catch(s){const o=Gs(r);if(o.repairs.length===0)throw s;try{const{svg:a}=await e.render(`${t}-repaired`,o.source);return{svg:a,repairs:o.repairs}}catch{throw s}}}function eo(e){const t=[];for(const r of e){const s=`${r.from} → ${r.to}`;t.includes(s)||t.push(s)}return t.join(", ")}function to({source:e,ports:t}){const{resolvedTheme:r}=ln(),s=r==="dark"?"dark":"default",o=A.useScopedStore(f=>f.renderState),a=o.status==="error"?o.message:void 0,i=o.status==="error"&&o.kind==="stale-chunk",l=A.useScopedStore(f=>f.showSource),d=A.useScopedStore(f=>f.zoomOpen),c=A.useScopedStore(f=>f.copied),m=A.useScopedStore(f=>f.setRenderState),u=A.useScopedStore(f=>f.setShowSource),p=A.useScopedStore(f=>f.setZoomOpen),y=A.useScopedStore(f=>f.setCopied),v=`mermaid-${g.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,C=g.useCallback(()=>p(!1),[p]),_=async()=>{await((t==null?void 0:t.clipboard)??xe).writeText(e),y(!0),((t==null?void 0:t.timer)??me).setTimeout(()=>y(!1),2e3)},w=(t==null?void 0:t.loadMermaid)??Zs;if(g.useEffect(()=>{let f=!1;return w().then(async S=>{S.initialize({startOnLoad:!1,securityLevel:"strict",theme:s});const{svg:M,repairs:h}=await Qs(S,v,e);f||m({status:"ready",svg:M,repairs:h})}).catch(S=>{if(f)return;const M=dt(S);if(Xs(M)){m({status:"error",kind:"stale-chunk"});return}m({status:"error",message:M.message})}),()=>{f=!0}},[e,s,v,m,w]),i)return n.jsxs("div",{className:"my-3",children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-1",children:[n.jsx(Ue,{className:"size-3.5 shrink-0"}),n.jsx("span",{children:"This diagram needs the latest version of the app."}),n.jsxs(E,{variant:"ghost",size:"sm","aria-label":"Reload the app",className:"h-6 px-2 text-xs",onClick:()=>((t==null?void 0:t.dom)??I).reload(),children:[n.jsx(Yn,{className:"size-3 mr-1"}),"Reload"]})]}),n.jsx(Q,{source:e})]});if(o.status==="error"){const f=Hs(a??"");return n.jsxs("div",{className:"my-3",children:[n.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-destructive mb-1",children:[n.jsx(Ue,{className:"size-3.5 shrink-0 mt-px"}),n.jsxs("div",{className:"min-w-0",children:[n.jsxs("span",{children:["Couldn't render this Mermaid diagram",f.line!==null?n.jsxs("span",{className:"text-muted-foreground",children:[" — line ",n.jsx("span",{className:"tabular-nums",children:f.line})]}):null]}),n.jsx("div",{className:"text-muted-foreground",children:f.summary}),f.excerpt?n.jsx("pre",{className:"mt-1 overflow-x-auto rounded-md border border-border bg-muted px-2 py-1 font-mono text-xs leading-snug whitespace-pre text-muted-foreground",children:f.excerpt}):null]})]}),n.jsx(Q,{source:e,highlightLine:f.line??void 0})]})}return o.status==="loading"?n.jsx("div",{className:"relative group/mermaid",children:n.jsx(Q,{source:e})}):l?n.jsxs("div",{className:"relative group/mermaid",children:[n.jsx(Q,{source:e}),n.jsx(et,{showSource:l,onToggleSource:()=>u(!l),onCopy:_,copied:c,onZoom:void 0})]}):n.jsxs("div",{className:"relative group/mermaid my-3",children:[o.repairs.length>0&&n.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-muted-foreground mb-1",children:[n.jsx(es,{className:"size-3.5 shrink-0 mt-px"}),n.jsxs("span",{children:["Corrected ",n.jsx("span",{className:"tabular-nums",children:o.repairs.length}),o.repairs.length===1?" invalid link":" invalid links"," to render this (",n.jsx("span",{className:"font-mono",children:eo(o.repairs)}),"). The source is unchanged."]})]}),n.jsx("div",{className:"flex justify-center overflow-x-auto",dangerouslySetInnerHTML:{__html:o.svg}}),n.jsx(et,{showSource:l,onToggleSource:()=>u(!l),onCopy:_,copied:c,onZoom:()=>p(!0)}),d&&n.jsx(Ws,{svg:o.svg,onClose:C})]})}function Ft({source:e,ports:t}){return n.jsx(A.Provider,{init:void 0,children:n.jsx(to,{source:e,ports:t})})}function et({showSource:e,onToggleSource:t,onCopy:r,copied:s,onZoom:o}){return n.jsxs("div",{className:"absolute top-1.5 right-1.5 flex gap-1 opacity-100 md:opacity-0 md:group-hover/mermaid:opacity-100 transition-opacity [@media(hover:none)]:!opacity-100",children:[o&&!e&&n.jsx(E,{variant:"ghost",size:"icon","aria-label":"Zoom diagram",className:"h-8 w-8 rounded-md text-muted-foreground hover:text-foreground",onClick:o,children:n.jsx($r,{className:"h-4 w-4"})}),n.jsx(E,{variant:"ghost",size:"icon","aria-label":e?"View rendered diagram":"View diagram source",className:"h-8 w-8 rounded-md text-muted-foreground hover:text-foreground",onClick:t,children:n.jsx(Qn,{className:"h-4 w-4"})}),n.jsx(E,{variant:"ghost",size:"icon","aria-label":s?"Copied":"Copy diagram source",className:b("h-8 w-8 rounded-md text-muted-foreground",!s&&"hover:text-foreground",s&&"hover:!bg-transparent"),onClick:r,children:s?n.jsx(Ee,{className:"h-4 w-4 text-success"}):n.jsx(Ie,{className:"h-4 w-4"})})]})}class O extends H{constructor(r,s,o=I){super(s);k(this,"__source");k(this,"__dom");this.__source=r,this.__dom=o}static getType(){return"kanna-mermaid"}static clone(r){return new O(r.__source,r.__key,r.__dom)}static importJSON(r){return Dt(r.source)}exportJSON(){return{type:O.getType(),version:1,source:this.__source}}createDOM(r,s){return this.__dom.createElement("div")}updateDOM(){return!1}isInline(){return!1}getTextContent(){return this.__source}decorate(r,s){return n.jsx(Ft,{source:this.__source})}}function Dt(e){return q(new O(e))}function no(e){return e instanceof O}function ro(e,t=28){if(e.length<=t)return e;const r="…",s=e.lastIndexOf("."),o=s>0&&e.length-s<=6,a=o?e.slice(s):"",i=o?e.slice(0,s):e,l=t-r.length-a.length;if(l<=2){const m=t-r.length,u=Math.ceil(m/2),p=Math.floor(m/2);return`${e.slice(0,u)}${r}${e.slice(e.length-p)}`}const d=Math.ceil(l/2),c=l-d;return`${i.slice(0,d)}${r}${i.slice(i.length-c)}${a}`}const so=new Set([".c",".cc",".cfg",".conf",".cpp",".cs",".css",".diff",".env",".go",".graphql",".h",".hpp",".html",".ini",".java",".js",".json",".jsonc",".jsx",".kt",".log",".lua",".md",".mjs",".patch",".php",".pl",".properties",".py",".rb",".rs",".scss",".sh",".sql",".swift",".toml",".ts",".tsx",".txt",".vue",".xml",".yaml",".yml",".zsh"]),oo=new Set([".gitignore",".npmrc",".prettierrc",".python-version",".ruby-version",".tool-versions","Dockerfile","Gemfile","Makefile","Procfile"]);function te(e){if(!e)return;const t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function tt(e){var s,o;const t=/^(?<path>\/.+?)#L(?<line>\d+)(?:C(?<column>\d+))?$/.exec(e);if((s=t==null?void 0:t.groups)!=null&&s.path)return{path:t.groups.path,line:te(t.groups.line),column:te(t.groups.column)};const r=/^(?<path>\/.+?):(?<line>\d+)(?::(?<column>\d+))?$/.exec(e);return(o=r==null?void 0:r.groups)!=null&&o.path?{path:r.groups.path,line:te(r.groups.line),column:te(r.groups.column)}:e.startsWith("/")?{path:e}:null}function ao(e,t=I){if(!e)return null;const r=e.trim();if(!r||/^(mailto:|ftp:|file:)/i.test(r))return null;if(/^https?:/i.test(r))try{const s=new URL(r);return s.origin!==t.getOrigin()||!s.pathname.startsWith("/")?null:tt(`${s.pathname}${s.hash}`)}catch{return null}return tt(r)}function ai(e){const t=e.split(/[\\/]/);for(;t.length>0&&t[t.length-1]==="";)t.pop();const r=t.length>0?t[t.length-1]:e;if(oo.has(r))return!0;const s=r.lastIndexOf(".");if(s<0)return!0;const o=r.slice(s).toLowerCase();return so.has(o)}const io=["/Users/","/home/","/private/","/tmp/","/var/","/opt/","/root/"];function lo(e){return e?e.startsWith("file://")?!0:io.some(t=>e.startsWith(t)):!1}function Bt(e){let t=e;if(t.startsWith("file://"))try{t=decodeURIComponent(new URL(t).pathname)}catch{t=t.slice(7)}return`/api/local-file?path=${encodeURIComponent(t)}`}function ne(e,t){if(!e)return"";if(t){const r=t.endsWith("/")?t:`${t}/`;if(e.startsWith(r))return e.slice(r.length);if(e===t)return""}return e.replace(/^\/home\/user\/workspace\//,"")}function co(e,t){return{id:e.id,contentUrl:e.contentUrl,displayName:e.displayName,fileName:e.displayName,relativePath:e.relativePath,mimeType:e.mimeType,size:e.size,origin:t}}const G=R("LocalFileLinkCard",()=>e=>({probe:{kind:"loading"},previewOpen:!1,setProbe:t=>e({probe:t}),setPreviewOpen:t=>e({previewOpen:t})}));function uo(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function mo({path:e,linkText:t}){const r=g.useMemo(()=>Bt(e),[e]),s=G.useScopedStore(h=>h.probe),o=G.useScopedStore(h=>h.previewOpen),a=G.useScopedStore(h=>h.setProbe),i=G.useScopedStore(h=>h.setPreviewOpen);g.useEffect(()=>{const h=new AbortController;return ts(r,{signal:h.signal}).then(T=>{h.signal.aborted||a(T)}),()=>h.abort()},[r,a]);const l=uo(e),d=t||l,c=ro(d,28),m=s.kind==="ready"?s.mimeType:"application/octet-stream",u=s.kind==="ready"?s.size:0,p={id:`local-file-${r}`,kind:"file",displayName:c,absolutePath:e,relativePath:e,contentUrl:r,mimeType:m,size:u};if(s.kind==="missing")return n.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:n.jsx(oe,{attachment:p,disabledReason:"File no longer available"})});const y=fe(p),x=Ct(y,m),v=u>0?ge(u):null,C=s.kind==="loading",_=s.kind==="error";let w;C?w=n.jsx("span",{className:"text-muted-foreground",children:"Fetching…"}):_?w=n.jsx("span",{className:"text-muted-foreground",children:"Unable to load"}):w=n.jsxs(n.Fragment,{children:[x,v?n.jsxs(n.Fragment,{children:[" · ",n.jsx("span",{className:"tabular-nums",children:v})]}):null]});const f=s.kind==="ready"?Tt(p):null,S=f!==null&&!f.openInNewTab,M=[S?"Preview":"Download",d,x,v].filter(h=>!!h);return S?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:n.jsx(oe,{attachment:p,onClick:()=>i(!0),meta:w,ariaLabel:M.join(", ")})}),n.jsx(Go,{source:o?co(p,"local_file_link"):null,open:o,onOpenChange:i})]}):n.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:n.jsx(oe,{attachment:p,href:r,download:l,meta:w,ariaLabel:M.join(", ")})})}function po({path:e,linkText:t}){return n.jsx(G.Provider,{init:void 0,children:n.jsx(mo,{path:e,linkText:t})})}class F extends H{constructor(r,s,o,a,i=I){super(a);k(this,"__path");k(this,"__line");k(this,"__column");k(this,"__dom");this.__path=r,this.__line=s,this.__column=o,this.__dom=i}static getType(){return"kanna-local-file-link"}static clone(r){return new F(r.__path,r.__line,r.__column,r.__key,r.__dom)}static importJSON(r){return Kt({path:r.path,line:r.line,column:r.column})}exportJSON(){const r={type:F.getType(),version:1,path:this.__path};return this.__line!==void 0&&(r.line=this.__line),this.__column!==void 0&&(r.column=this.__column),r}createDOM(r,s){return this.__dom.createElement("span")}updateDOM(){return!1}isInline(){return!0}getTextContent(){return this.__path}decorate(r,s){const o=this.__line!==void 0?`${this.__path}:${this.__line}${this.__column!==void 0?`:${this.__column}`:""}`:void 0;return n.jsx(po,{path:this.__path,linkText:o})}}function Kt(e){return q(new F(e.path,e.line,e.column))}function xo(e){return e instanceof F}class Y extends H{constructor(r,s,o=I){super(s);k(this,"__content");k(this,"__dom");this.__content=r,this.__dom=o}static getType(){return"kanna-thinking"}static clone(r){return new Y(r.__content,r.__key,r.__dom)}static importJSON(r){return ho(r.content)}exportJSON(){return{type:Y.getType(),version:1,content:this.__content}}createDOM(r,s){return this.__dom.createElement("div")}updateDOM(){return!1}isInline(){return!1}getTextContent(){return this.__content}decorate(r,s){return n.jsx($e,{content:this.__content})}}function ho(e){return q(new Y(e))}const ii=[J,X,V],fo=[O,F,Y],go=/^[ \t]*(`{3,})[ \t]*mermaid[ \t]*$/i,yo=/^[ \t]*`{3,}[ \t]*$/;function bo(e){return new RegExp(`^[ \\t]*\`{${String(e)},}[ \\t]*$`)}function jo(e,t,r){const s=bo(r.length),o=[];let a=t;for(let i=t+1;i<e.length;i++){const l=e[i];if(l===void 0||(a=i,s.test(l)))break;o.push(l)}return{source:o.join(`
166
+ `){i=!1,l=!1,a=!1,d.length=0,s+=1,r+=c,o+=1;continue}if(i){r+=c,o+=1;continue}if(a){c==='"'&&(a=!1),r+=c,o+=1;continue}if(c==='"'){a=!0,r+=c,o+=1;continue}if(e.startsWith("%%",o)){i=!0,r+="%%",o+=2;continue}if(d.length>0){c===d[d.length-1]?d.pop():ee[c]&&d.push(ee[c]),r+=c,o+=1;continue}if(ee[c]){d.push(ee[c]),r+=c,o+=1;continue}if(c==="|"){l=!l,r+=c,o+=1;continue}if(l){r+=c,o+=1;continue}const m=qs.find(u=>e.startsWith(u.from,o));if(m){r+=m.to,t.push({line:s,from:m.from,to:m.to}),o+=m.from.length;continue}r+=c,o+=1}return{source:r,repairs:t}}const Js=["failed to fetch dynamically imported module","error loading dynamically imported module","importing a module script failed"];function Xs(e){const t=e.message.toLowerCase();return Js.some(r=>t.includes(r))}function Ys(e){let t=null;return()=>(t||(t=e().catch(r=>{throw t=null,dt(r)})),t)}const Zs=Ys(()=>ut(()=>import("./mermaid.core-ChAu8gwz.js").then(e=>e.bm),__vite__mapDeps([0,1,2])).then(e=>e.default));async function Qs(e,t,r){try{const{svg:s}=await e.render(t,r);return{svg:s,repairs:[]}}catch(s){const o=Gs(r);if(o.repairs.length===0)throw s;try{const{svg:a}=await e.render(`${t}-repaired`,o.source);return{svg:a,repairs:o.repairs}}catch{throw s}}}function eo(e){const t=[];for(const r of e){const s=`${r.from} → ${r.to}`;t.includes(s)||t.push(s)}return t.join(", ")}function to({source:e,ports:t}){const{resolvedTheme:r}=ln(),s=r==="dark"?"dark":"default",o=A.useScopedStore(f=>f.renderState),a=o.status==="error"?o.message:void 0,i=o.status==="error"&&o.kind==="stale-chunk",l=A.useScopedStore(f=>f.showSource),d=A.useScopedStore(f=>f.zoomOpen),c=A.useScopedStore(f=>f.copied),m=A.useScopedStore(f=>f.setRenderState),u=A.useScopedStore(f=>f.setShowSource),p=A.useScopedStore(f=>f.setZoomOpen),y=A.useScopedStore(f=>f.setCopied),v=`mermaid-${g.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,C=g.useCallback(()=>p(!1),[p]),_=async()=>{await((t==null?void 0:t.clipboard)??xe).writeText(e),y(!0),((t==null?void 0:t.timer)??me).setTimeout(()=>y(!1),2e3)},w=(t==null?void 0:t.loadMermaid)??Zs;if(g.useEffect(()=>{let f=!1;return w().then(async S=>{S.initialize({startOnLoad:!1,securityLevel:"strict",theme:s});const{svg:M,repairs:h}=await Qs(S,v,e);f||m({status:"ready",svg:M,repairs:h})}).catch(S=>{if(f)return;const M=dt(S);if(Xs(M)){m({status:"error",kind:"stale-chunk"});return}m({status:"error",message:M.message})}),()=>{f=!0}},[e,s,v,m,w]),i)return n.jsxs("div",{className:"my-3",children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-1",children:[n.jsx(Ue,{className:"size-3.5 shrink-0"}),n.jsx("span",{children:"This diagram needs the latest version of the app."}),n.jsxs(E,{variant:"ghost",size:"sm","aria-label":"Reload the app",className:"h-6 px-2 text-xs",onClick:()=>((t==null?void 0:t.dom)??I).reload(),children:[n.jsx(Yn,{className:"size-3 mr-1"}),"Reload"]})]}),n.jsx(Q,{source:e})]});if(o.status==="error"){const f=Hs(a??"");return n.jsxs("div",{className:"my-3",children:[n.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-destructive mb-1",children:[n.jsx(Ue,{className:"size-3.5 shrink-0 mt-px"}),n.jsxs("div",{className:"min-w-0",children:[n.jsxs("span",{children:["Couldn't render this Mermaid diagram",f.line!==null?n.jsxs("span",{className:"text-muted-foreground",children:[" — line ",n.jsx("span",{className:"tabular-nums",children:f.line})]}):null]}),n.jsx("div",{className:"text-muted-foreground",children:f.summary}),f.excerpt?n.jsx("pre",{className:"mt-1 overflow-x-auto rounded-md border border-border bg-muted px-2 py-1 font-mono text-xs leading-snug whitespace-pre text-muted-foreground",children:f.excerpt}):null]})]}),n.jsx(Q,{source:e,highlightLine:f.line??void 0})]})}return o.status==="loading"?n.jsx("div",{className:"relative group/mermaid",children:n.jsx(Q,{source:e})}):l?n.jsxs("div",{className:"relative group/mermaid",children:[n.jsx(Q,{source:e}),n.jsx(et,{showSource:l,onToggleSource:()=>u(!l),onCopy:_,copied:c,onZoom:void 0})]}):n.jsxs("div",{className:"relative group/mermaid my-3",children:[o.repairs.length>0&&n.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-muted-foreground mb-1",children:[n.jsx(es,{className:"size-3.5 shrink-0 mt-px"}),n.jsxs("span",{children:["Corrected ",n.jsx("span",{className:"tabular-nums",children:o.repairs.length}),o.repairs.length===1?" invalid link":" invalid links"," to render this (",n.jsx("span",{className:"font-mono",children:eo(o.repairs)}),"). The source is unchanged."]})]}),n.jsx("div",{className:"flex justify-center overflow-x-auto",dangerouslySetInnerHTML:{__html:o.svg}}),n.jsx(et,{showSource:l,onToggleSource:()=>u(!l),onCopy:_,copied:c,onZoom:()=>p(!0)}),d&&n.jsx(Ws,{svg:o.svg,onClose:C})]})}function Ft({source:e,ports:t}){return n.jsx(A.Provider,{init:void 0,children:n.jsx(to,{source:e,ports:t})})}function et({showSource:e,onToggleSource:t,onCopy:r,copied:s,onZoom:o}){return n.jsxs("div",{className:"absolute top-1.5 right-1.5 flex gap-1 opacity-100 md:opacity-0 md:group-hover/mermaid:opacity-100 transition-opacity [@media(hover:none)]:!opacity-100",children:[o&&!e&&n.jsx(E,{variant:"ghost",size:"icon","aria-label":"Zoom diagram",className:"h-8 w-8 rounded-md text-muted-foreground hover:text-foreground",onClick:o,children:n.jsx($r,{className:"h-4 w-4"})}),n.jsx(E,{variant:"ghost",size:"icon","aria-label":e?"View rendered diagram":"View diagram source",className:"h-8 w-8 rounded-md text-muted-foreground hover:text-foreground",onClick:t,children:n.jsx(Qn,{className:"h-4 w-4"})}),n.jsx(E,{variant:"ghost",size:"icon","aria-label":s?"Copied":"Copy diagram source",className:b("h-8 w-8 rounded-md text-muted-foreground",!s&&"hover:text-foreground",s&&"hover:!bg-transparent"),onClick:r,children:s?n.jsx(Ee,{className:"h-4 w-4 text-success"}):n.jsx(Ie,{className:"h-4 w-4"})})]})}class O extends H{constructor(r,s,o=I){super(s);k(this,"__source");k(this,"__dom");this.__source=r,this.__dom=o}static getType(){return"kanna-mermaid"}static clone(r){return new O(r.__source,r.__key,r.__dom)}static importJSON(r){return Dt(r.source)}exportJSON(){return{type:O.getType(),version:1,source:this.__source}}createDOM(r,s){return this.__dom.createElement("div")}updateDOM(){return!1}isInline(){return!1}getTextContent(){return this.__source}decorate(r,s){return n.jsx(Ft,{source:this.__source})}}function Dt(e){return q(new O(e))}function no(e){return e instanceof O}function ro(e,t=28){if(e.length<=t)return e;const r="…",s=e.lastIndexOf("."),o=s>0&&e.length-s<=6,a=o?e.slice(s):"",i=o?e.slice(0,s):e,l=t-r.length-a.length;if(l<=2){const m=t-r.length,u=Math.ceil(m/2),p=Math.floor(m/2);return`${e.slice(0,u)}${r}${e.slice(e.length-p)}`}const d=Math.ceil(l/2),c=l-d;return`${i.slice(0,d)}${r}${i.slice(i.length-c)}${a}`}const so=new Set([".c",".cc",".cfg",".conf",".cpp",".cs",".css",".diff",".env",".go",".graphql",".h",".hpp",".html",".ini",".java",".js",".json",".jsonc",".jsx",".kt",".log",".lua",".md",".mjs",".patch",".php",".pl",".properties",".py",".rb",".rs",".scss",".sh",".sql",".swift",".toml",".ts",".tsx",".txt",".vue",".xml",".yaml",".yml",".zsh"]),oo=new Set([".gitignore",".npmrc",".prettierrc",".python-version",".ruby-version",".tool-versions","Dockerfile","Gemfile","Makefile","Procfile"]);function te(e){if(!e)return;const t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function tt(e){var s,o;const t=/^(?<path>\/.+?)#L(?<line>\d+)(?:C(?<column>\d+))?$/.exec(e);if((s=t==null?void 0:t.groups)!=null&&s.path)return{path:t.groups.path,line:te(t.groups.line),column:te(t.groups.column)};const r=/^(?<path>\/.+?):(?<line>\d+)(?::(?<column>\d+))?$/.exec(e);return(o=r==null?void 0:r.groups)!=null&&o.path?{path:r.groups.path,line:te(r.groups.line),column:te(r.groups.column)}:e.startsWith("/")?{path:e}:null}function ao(e,t=I){if(!e)return null;const r=e.trim();if(!r||/^(mailto:|ftp:|file:)/i.test(r))return null;if(/^https?:/i.test(r))try{const s=new URL(r);return s.origin!==t.getOrigin()||!s.pathname.startsWith("/")?null:tt(`${s.pathname}${s.hash}`)}catch{return null}return tt(r)}function ai(e){const t=e.split(/[\\/]/);for(;t.length>0&&t[t.length-1]==="";)t.pop();const r=t.length>0?t[t.length-1]:e;if(oo.has(r))return!0;const s=r.lastIndexOf(".");if(s<0)return!0;const o=r.slice(s).toLowerCase();return so.has(o)}const io=["/Users/","/home/","/private/","/tmp/","/var/","/opt/","/root/"];function lo(e){return e?e.startsWith("file://")?!0:io.some(t=>e.startsWith(t)):!1}function Bt(e){let t=e;if(t.startsWith("file://"))try{t=decodeURIComponent(new URL(t).pathname)}catch{t=t.slice(7)}return`/api/local-file?path=${encodeURIComponent(t)}`}function ne(e,t){if(!e)return"";if(t){const r=t.endsWith("/")?t:`${t}/`;if(e.startsWith(r))return e.slice(r.length);if(e===t)return""}return e.replace(/^\/home\/user\/workspace\//,"")}function co(e,t){return{id:e.id,contentUrl:e.contentUrl,displayName:e.displayName,fileName:e.displayName,relativePath:e.relativePath,mimeType:e.mimeType,size:e.size,origin:t}}const G=R("LocalFileLinkCard",()=>e=>({probe:{kind:"loading"},previewOpen:!1,setProbe:t=>e({probe:t}),setPreviewOpen:t=>e({previewOpen:t})}));function uo(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function mo({path:e,linkText:t}){const r=g.useMemo(()=>Bt(e),[e]),s=G.useScopedStore(h=>h.probe),o=G.useScopedStore(h=>h.previewOpen),a=G.useScopedStore(h=>h.setProbe),i=G.useScopedStore(h=>h.setPreviewOpen);g.useEffect(()=>{const h=new AbortController;return ts(r,{signal:h.signal}).then(T=>{h.signal.aborted||a(T)}),()=>h.abort()},[r,a]);const l=uo(e),d=t||l,c=ro(d,28),m=s.kind==="ready"?s.mimeType:"application/octet-stream",u=s.kind==="ready"?s.size:0,p={id:`local-file-${r}`,kind:"file",displayName:c,absolutePath:e,relativePath:e,contentUrl:r,mimeType:m,size:u};if(s.kind==="missing")return n.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:n.jsx(oe,{attachment:p,disabledReason:"File no longer available"})});const y=fe(p),x=Ct(y,m),v=u>0?ge(u):null,C=s.kind==="loading",_=s.kind==="error";let w;C?w=n.jsx("span",{className:"text-muted-foreground",children:"Fetching…"}):_?w=n.jsx("span",{className:"text-muted-foreground",children:"Unable to load"}):w=n.jsxs(n.Fragment,{children:[x,v?n.jsxs(n.Fragment,{children:[" · ",n.jsx("span",{className:"tabular-nums",children:v})]}):null]});const f=s.kind==="ready"?Tt(p):null,S=f!==null&&!f.openInNewTab,M=[S?"Preview":"Download",d,x,v].filter(h=>!!h);return S?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:n.jsx(oe,{attachment:p,onClick:()=>i(!0),meta:w,ariaLabel:M.join(", ")})}),n.jsx(Go,{source:o?co(p,"local_file_link"):null,open:o,onOpenChange:i})]}):n.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:n.jsx(oe,{attachment:p,href:r,download:l,meta:w,ariaLabel:M.join(", ")})})}function po({path:e,linkText:t}){return n.jsx(G.Provider,{init:void 0,children:n.jsx(mo,{path:e,linkText:t})})}class F extends H{constructor(r,s,o,a,i=I){super(a);k(this,"__path");k(this,"__line");k(this,"__column");k(this,"__dom");this.__path=r,this.__line=s,this.__column=o,this.__dom=i}static getType(){return"kanna-local-file-link"}static clone(r){return new F(r.__path,r.__line,r.__column,r.__key,r.__dom)}static importJSON(r){return Kt({path:r.path,line:r.line,column:r.column})}exportJSON(){const r={type:F.getType(),version:1,path:this.__path};return this.__line!==void 0&&(r.line=this.__line),this.__column!==void 0&&(r.column=this.__column),r}createDOM(r,s){return this.__dom.createElement("span")}updateDOM(){return!1}isInline(){return!0}getTextContent(){return this.__path}decorate(r,s){const o=this.__line!==void 0?`${this.__path}:${this.__line}${this.__column!==void 0?`:${this.__column}`:""}`:void 0;return n.jsx(po,{path:this.__path,linkText:o})}}function Kt(e){return q(new F(e.path,e.line,e.column))}function xo(e){return e instanceof F}class Y extends H{constructor(r,s,o=I){super(s);k(this,"__content");k(this,"__dom");this.__content=r,this.__dom=o}static getType(){return"kanna-thinking"}static clone(r){return new Y(r.__content,r.__key,r.__dom)}static importJSON(r){return ho(r.content)}exportJSON(){return{type:Y.getType(),version:1,content:this.__content}}createDOM(r,s){return this.__dom.createElement("div")}updateDOM(){return!1}isInline(){return!1}getTextContent(){return this.__content}decorate(r,s){return n.jsx($e,{content:this.__content})}}function ho(e){return q(new Y(e))}const ii=[J,X,V],fo=[O,F,Y],go=/^[ \t]*(`{3,})[ \t]*mermaid[ \t]*$/i,yo=/^[ \t]*`{3,}[ \t]*$/;function bo(e){return new RegExp(`^[ \\t]*\`{${String(e)},}[ \\t]*$`)}function jo(e,t,r){const s=bo(r.length),o=[];let a=t;for(let i=t+1;i<e.length;i++){const l=e[i];if(l===void 0||(a=i,s.test(l)))break;o.push(l)}return{source:o.join(`
167
167
  `),lastLineIndex:a}}const vo={type:"multiline-element",dependencies:[O],regExpStart:go,regExpEnd:{optional:!0,regExp:yo},handleImportAfterStartMatch({lines:e,rootNode:t,startLineIndex:r,startMatch:s}){const{source:o,lastLineIndex:a}=jo(e,r,s[1]??"```");return t.append(Dt(o)),[!0,a]},replace(e,t,r,s,o,a){return!1},export(e){return e instanceof O?`\`\`\`mermaid
168
168
  ${e.getTextContent()}
169
169
  \`\`\``:null}},Ut="(?:file://|/(?:Users|home|private|tmp|var|opt|root)/)",No=new RegExp(`\\[(.+?)\\]\\((${Ut}[^)\\s]*)\\)`),wo=new RegExp(`\\[([^[\\]]+)\\]\\((${Ut}[^)\\s]*)\\)$`),ko={type:"text-match",dependencies:[F],importRegExp:No,regExp:wo,trigger:")",replace(e,t){const r=t[2];if(!r)return;const s=ao(r);if(!s||!lo(s.path)&&!r.startsWith("/"))return;const o=Kt({path:s.path,line:s.line,column:s.column});e.replace(o)},export(e){if(!(e instanceof F))return null;const t=e.getTextContent();return`[${t}](${t})`}},_o=[vo,ko,...cn],So=[un,mn,pn,xn,hn,fn,gn,yn,bn,jn,vn,...fo];let Wt=0;function N(){return String(Wt++)}let K=null,U=null;const nt={h1:"text-20 font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h2:"text-18 font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h3:"text-16 font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h4:"text-16 font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h5:"text-16 font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h6:"text-16 font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0"};function Vt(e){if(no(e)&&K&&U)return n.jsx("span",{children:e.decorate(K,U)},N());if(xo(e)&&K&&U)return n.jsx("span",{children:e.decorate(K,U)},N());if(_n(e)){const r=e.getTag(),s=z(e),o=nt[r]??nt.h1,a=N();switch(r){case"h1":return n.jsx("h1",{className:o,children:s},a);case"h2":return n.jsx("h2",{className:o,children:s},a);case"h3":return n.jsx("h3",{className:o,children:s},a);case"h4":return n.jsx("h4",{className:o,children:s},a);case"h5":return n.jsx("h5",{className:o,children:s},a);default:return n.jsx("h6",{className:o,children:s},a)}}if(Sn(e))return n.jsx("blockquote",{className:"my-2 mt-5 mb-3 first:mt-0 last:mb-0 border-l-2 border-border/80 pl-2 text-muted-foreground",children:z(e)},N());if(Tn(e))return n.jsx("p",{className:"break-words mt-5 mb-3 first:mt-0 last:mb-0",children:z(e)},N());if(Cn(e)){const r=e.getLanguage()??"",s=e.getChildren().map(o=>Ae(o)||ze(o)?o.getTextContent():Pe(o)?`
170
- `:"").join("");return n.jsx(Mn,{source:s,lang:r},N())}if(En(e)){const r=e.getListType(),s=z(e),o=N();return r==="number"?n.jsx("ol",{className:"list-decimal ml-5 my-2",children:s},o):n.jsx("ul",{className:"list-disc ml-5 my-2",children:s},o)}if(In(e)){const r=e.getChecked(),s=z(e),o=N();return r!==void 0?n.jsxs("li",{className:"my-0.5 list-none flex items-start gap-1.5",children:[n.jsx("input",{type:"checkbox",readOnly:!0,checked:r,className:"mt-[3px] shrink-0"}),n.jsx("span",{children:s})]},o):n.jsx("li",{className:"my-0.5",children:s},o)}if($n(e)||Rn(e)){const r=e.getURL();return n.jsx("a",{href:r,className:"transition-colors underline decoration-2 text-logo decoration-logo/50 hover:text-logo/70 dark:text-logo dark:decoration-logo/70 dark:hover:text-logo/60 dark:hover:decoration-logo/40",target:"_blank",rel:"noopener noreferrer",children:z(e)},N())}if(Ln(e)){const r=e.getChildren(),s=r[0],o=s!==void 0&&Oe(s)&&s.getChildren().every(l=>Fe(l)&&(l.getHeaderStyles()&An.ROW)!==0),a=o?s:void 0,i=o?r.slice(1):r;return n.jsx("div",{className:"border border-border rounded-xl overflow-x-auto",children:n.jsxs("table",{className:"table-auto min-w-full divide-y divide-border bg-background",children:[a!==void 0&&n.jsx("thead",{children:n.jsx("tr",{children:a.getChildren().map(l=>n.jsx("th",{className:"text-left text-xs text-muted-foreground tracking-wider p-2 pl-0 first:pl-3 bg-muted dark:bg-card [&_*]:font-semibold",children:z(l)},N()))})}),n.jsx("tbody",{className:"divide-y divide-border",children:i.map(l=>Oe(l)?n.jsx("tr",{children:l.getChildren().map(d=>Fe(d)?n.jsx("td",{className:"text-left p-2 pl-0 first:pl-3 [&_*]:font-normal",children:z(d)},N()):null)},N()):null)})]})},N())}if(Pe(e))return n.jsx("br",{},N());if(Ae(e))return To(e);if(ze(e))return n.jsx("code",{className:"break-all px-1 bg-border/60 py-0.5 rounded text-sm",children:e.getTextContent()},N());const t=e.getTextContent();return t?n.jsx("span",{children:t},N()):null}function To(e){const t=e.getFormat(),r=e.getTextContent(),s=(t&Fn)!==0,o=(t&On)!==0,a=(t&Pn)!==0;if((t&zn)!==0)return n.jsx("code",{className:"break-all px-1 bg-border/60 py-0.5 rounded text-sm",children:r},N());let l=r;return a&&(l=n.jsx("del",{className:"line-through",children:l},N())),o&&(l=n.jsx("em",{className:"italic",children:l},N())),s&&(l=n.jsx("strong",{className:"font-semibold",children:l},N())),!s&&!o&&!a?r:l}function z(e){return e.getChildren().map(Vt)}function Ht(e){const t=As(e),r=dn({namespace:"kanna-message-renderer",nodes:So,editable:!1}),s=Nn(r);return s.update(()=>{wn(t,_o,void 0,!0)},{discrete:!0}),s.getEditorState().read(()=>{Wt=0,K=s,U=r;const a=kn().getChildren(),i=n.jsx(n.Fragment,{children:a.map(Vt)});return K=null,U=null,i})}function Co(e){return Ht(e)}function Mo(e){const r=Ms(e).map((s,o)=>{if(s.kind==="thinking")return n.jsx($e,{content:s.content},`think-${o}`);const a=Ht(s.content);return n.jsx("span",{children:a},`text-${o}`)});return n.jsx(n.Fragment,{children:r})}const ae=new Map;function Eo(e){return`${e.id}|${e.contentUrl}|${e.size??0}`}function Io(e,t){return t.type==="setLoadState"?{...e,loadState:t.payload}:{lastKey:t.newKey,loadState:ae.get(t.newKey)??{status:"loading"}}}function Z(e){const t=Eo(e),r=ae.get(t),[{loadState:s,lastKey:o},a]=g.useReducer(Io,{loadState:r??{status:"loading"},lastKey:t}),i=g.useRef(t);return i.current=t,o!==t&&a({type:"resetForKey",newKey:t}),g.useEffect(()=>{if(r&&r.status!=="loading")return;let l=!1;const d=t;return Mt(e.contentUrl,wt).then(c=>{if(l||i.current!==d)return;const m={status:"ready",content:c.content,truncated:c.truncated};ae.set(d,m),a({payload:m,type:"setLoadState"})}).catch(c=>{if(l||i.current!==d)return;const u={status:"error",message:c instanceof Error?c.message:"Unable to load preview."};ae.set(d,u),a({payload:u,type:"setLoadState"})}),()=>{l=!0}},[r,t,e.contentUrl]),s}function $o({source:e}){const t=Z(e);return t.status==="loading"?n.jsxs("div",{className:"p-4 text-sm text-muted-foreground",children:[n.jsx("div",{className:"prose hidden"})," Loading…"]}):t.status==="error"?n.jsx("div",{className:"p-4 text-sm text-destructive",children:t.message}):n.jsxs("div",{className:"space-y-2 p-3",children:[t.truncated?n.jsx("div",{className:"rounded-xl border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:"Preview truncated to 1024 KB."}):null,n.jsx("div",{className:"prose prose-sm prose-invert max-w-none rounded-xl border border-border bg-background p-4",children:Co(t.content)})]})}const _e=R("TableBody",e=>t=>({state:e.initialState,setState:r=>t({state:r})})),ie=new Map;function qt(e){return`${e.id}|${e.contentUrl}|${e.size??0}|${e.mimeType}`}function Ro({source:e}){const t=qt(e),r=ie.get(t),s=_e.useScopedStore(m=>m.state),o=_e.useScopedStore(m=>m.setState),a=g.useRef(t);if(a.current=t,g.useEffect(()=>{if(r&&r.status!=="loading")return;const m=e.mimeType==="text/tab-separated-values"?" ":",";let u=!1;const p=t;return Mt(e.contentUrl,wt).then(y=>{if(u||a.current!==p)return;const x={status:"ready",table:is(y.content,m),truncated:y.truncated};ie.set(p,x),o(x)}).catch(y=>{if(u||a.current!==p)return;const x={status:"error",message:y instanceof Error?y.message:"Unable to load preview."};ie.set(p,x),o(x)}),()=>{u=!0}},[r,t,e.contentUrl,e.mimeType,o]),s.status==="loading")return n.jsxs("div",{className:"p-4 text-sm text-muted-foreground",children:[n.jsx("table",{className:"sr-only"})," Loading…"]});if(s.status==="error")return n.jsxs("div",{className:"p-4 text-sm text-destructive",children:[n.jsx("table",{className:"sr-only"})," ",s.message]});const{table:i}=s,[l,...d]=i.rows,c=[s.truncated?"Preview truncated to 1024 KB.":null,i.truncatedRows?`Showing first ${i.rows.length} of ${i.rowCount} rows.`:null,i.truncatedColumns?`Showing first ${Ne} of ${i.columnCount} columns.`:null].filter(Boolean);return n.jsxs("div",{className:"space-y-2 p-3",children:[c.length?n.jsx("div",{className:"rounded-xl border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:c.join(" ")}):null,n.jsx("div",{className:"overflow-x-auto rounded-xl border border-border bg-background",children:n.jsxs("table",{className:"min-w-full border-collapse text-xs",children:[l?n.jsx("thead",{className:"sticky top-0 bg-muted",children:n.jsx("tr",{children:l.map((m,u)=>n.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium",children:m||" "},u))})}):null,n.jsx("tbody",{children:d.map((m,u)=>n.jsx("tr",{className:"odd:bg-background even:bg-muted/20",children:m.map((p,y)=>n.jsx("td",{className:"max-w-[320px] border-b border-border px-3 py-2 align-top",children:n.jsx("div",{className:"whitespace-pre-wrap break-words",children:p||" "})},y))},u))})]})})]})}function Lo({source:e}){const t=qt(e),r=ie.get(t);return n.jsx(_e.Provider,{init:{initialState:r??{status:"loading"}},children:n.jsx(Ro,{source:e})})}function Ao({source:e}){const t=Z(e);return t.status==="loading"?n.jsxs("div",{className:"p-4 text-sm text-muted-foreground",children:[n.jsx("pre",{className:"sr-only"})," Loading…"]}):t.status==="error"?n.jsxs("div",{className:"p-4 text-sm text-destructive",children:[n.jsx("pre",{className:"sr-only"})," ",t.message]}):n.jsxs("div",{className:"space-y-2 p-3",children:[t.truncated?n.jsx(zo,{children:"Preview truncated to 1024 KB."}):null,n.jsx("pre",{className:"whitespace-pre-wrap break-words rounded-xl border border-border bg-background p-3 text-xs",children:t.content})]})}function zo({children:e}){return n.jsx("div",{className:"rounded-xl border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:e})}function Po({source:e}){const t=Z(e),r=g.useMemo(()=>t.status==="ready"?as(t.content):"",[t]);return t.status==="loading"?n.jsxs("div",{className:"p-4 text-sm text-muted-foreground",children:[n.jsx("pre",{className:"sr-only"})," Loading…"]}):t.status==="error"?n.jsxs("div",{className:"p-4 text-sm text-destructive",children:[n.jsx("pre",{className:"sr-only"})," ",t.message]}):n.jsxs("div",{className:"space-y-2 p-3",children:[t.truncated?n.jsx("div",{className:"rounded-xl border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:"Preview truncated to 1024 KB."}):null,n.jsx("pre",{className:"whitespace-pre-wrap break-words rounded-xl border border-border bg-background p-3 text-xs",children:r})]})}function Oo({source:e}){return n.jsxs("div",{className:"flex h-full flex-col items-stretch justify-center gap-3 p-4",children:[n.jsx("div",{className:"text-sm font-medium text-foreground",children:e.displayName}),n.jsx("audio",{src:e.contentUrl,controls:!0,preload:"metadata",className:"w-full"})]})}function Fo({source:e}){return n.jsx("div",{className:"flex h-full items-center justify-center bg-black/40 p-2",children:n.jsx("video",{src:e.contentUrl,controls:!0,playsInline:!0,preload:"metadata",className:"max-h-[60dvh] w-full rounded-xl"})})}const Se=R("CodeBody",()=>e=>({highlighted:null,setHighlighted:t=>e({highlighted:t})})),Do=200*1024;function Bo(e){const t=e.lastIndexOf(".");if(t<0)return"text";const r=e.slice(t+1).toLowerCase();return{ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",go:"go",rs:"rust",java:"java",rb:"ruby",sh:"bash",zsh:"bash",yml:"yaml",yaml:"yaml",css:"css",scss:"scss",html:"html",json:"json",md:"markdown",sql:"sql",cpp:"cpp",c:"c",h:"c",swift:"swift",kt:"kotlin",php:"php",toml:"toml"}[r]??"text"}function Ko({source:e}){const t=Z(e),r=t.status==="ready"&&t.content.length<=Do,s=r?`${e.id}|${e.contentUrl}|${e.size??0}|${t.content.length}`:null,o=Se.useScopedStore(i=>i.highlighted),a=Se.useScopedStore(i=>i.setHighlighted);return g.useEffect(()=>{if(!r||t.status!=="ready"||s===null)return;let i=!1;const l=s;return ut(()=>import("./index-DXSQvXUy.js").then(d=>d.i),__vite__mapDeps([3,1,2])).then(async d=>{if(i)return;const c=await d.codeToHtml(t.content,{lang:Bo(e.fileName),theme:"github-dark"});i||a({key:l,html:c})}).catch(()=>{ve.warn("[file-preview] Shiki unavailable; falling back to plain text")}),()=>{i=!0}},[r,s,t,e.fileName,a]),t.status==="loading"?n.jsxs("div",{className:"p-4 text-sm text-muted-foreground",children:[n.jsx("pre",{className:"sr-only"})," Loading…"]}):t.status==="error"?n.jsxs("div",{className:"p-4 text-sm text-destructive",children:[n.jsx("pre",{className:"sr-only"})," ",t.message]}):o&&o.key===s?n.jsx("div",{className:"overflow-x-auto p-3 text-xs",dangerouslySetInnerHTML:{__html:o.html}}):n.jsxs("div",{className:"space-y-2 p-3",children:[t.truncated?n.jsx("div",{className:"rounded-xl border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:"Preview truncated to 1024 KB."}):null,n.jsx("pre",{className:"whitespace-pre-wrap break-words rounded-xl border border-border bg-background p-3 text-xs",children:t.content})]})}function Uo({source:e}){return n.jsx(Se.Provider,{init:void 0,children:n.jsx(Ko,{source:e})})}function Wo({source:e}){const t=Z(e);return t.status==="loading"?n.jsxs("div",{className:"p-4 text-sm text-muted-foreground",children:[n.jsx("div",{className:"hidden"})," Loading…"]}):t.status==="error"?n.jsx("div",{className:"p-4 text-sm text-destructive",children:t.message}):n.jsx("div",{className:"p-4",children:n.jsx(Ft,{source:t.content})})}async function Vo(e,t={}){const r=t.dom??I,s=t.clipboard??xe,o=qo(e.contentUrl,r);if(r.isWebShareSupported())try{return await r.webShare({title:e.displayName,url:o}),"shared"}catch(a){if(a instanceof DOMException&&a.name==="AbortError")return"shared"}try{return await s.writeText(o),"copied"}catch{return"failed"}}function Ho(e,t={}){(t.dom??I).triggerDownload(e.contentUrl,e.fileName)}function qo(e,t){return new URL(e,t.getBaseURI()||t.getHref()).toString()}const Te=R("SheetBody",()=>e=>({dy:0,setDy:t=>e({dy:t})}));function Go({source:e,open:t,onOpenChange:r}){const s=g.useCallback(()=>r(!1),[r]);return n.jsx(mt,{open:t&&e!==null,onOpenChange:r,children:n.jsx(pt,{size:"lg",className:"inset-0 h-[100dvh] max-h-none w-full max-w-none translate-x-0 translate-y-0 rounded-none p-0 md:inset-auto md:left-1/2 md:top-1/2 md:h-auto md:max-h-[90dvh] md:w-auto md:max-w-3xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-2xl",children:e?n.jsx(Qo,{source:e,onClose:s}):null})})}const Jo=120,Xo=.5;function Yo({startY:e,lastY:t,lastT:r,endY:s,now:o}){const a=s-e,i=Math.max(1,o-r),l=(s-t)/i;return a>Jo||l>Xo}function Zo({source:e,onClose:t}){const r=ta(e),s=Te.useScopedStore(u=>u.dy),o=Te.useScopedStore(u=>u.setDy),a=g.useRef(null),i=g.useCallback(u=>{a.current={y:u.clientY,lastY:u.clientY,lastT:Date.now()};try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}},[]),l=g.useCallback(u=>{if(!a.current)return;const p=u.clientY-a.current.y;p<0||(a.current.lastY=u.clientY,a.current.lastT=Date.now(),o(p))},[o]),d=g.useCallback(u=>{const p=a.current;a.current=null;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}p&&(Yo({startY:p.y,lastY:p.lastY,lastT:p.lastT,endY:u.clientY,now:Date.now()})?t():o(0))},[t,o]),c=g.useCallback(()=>{Vo(e)},[e]),m=g.useCallback(()=>Ho(e),[e]);return n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",style:s>0?{transform:`translateY(${s}px)`,transition:"none"}:void 0,children:[n.jsxs("div",{onPointerDown:i,onPointerMove:l,onPointerUp:d,onPointerCancel:d,className:"border-b border-border px-4 py-3 touch-none",children:[n.jsx("div",{className:"mx-auto mb-2 h-1 w-12 rounded-full bg-muted md:hidden",role:"button","aria-label":"Drag down to close"}),n.jsx(xt,{className:"truncate text-base",children:e.displayName}),n.jsx(Dn,{className:"truncate text-xs",children:r})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain touch-pan-y [-webkit-overflow-scrolling:touch]",role:"region","aria-label":"File preview",children:g.createElement(ea(e),{source:e})},e.id),n.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-border px-4 py-3",children:[n.jsxs(E,{type:"button",variant:"outline",onClick:c,children:[n.jsx(Wr,{className:"mr-2 h-4 w-4"}),"Share"]}),e.origin==="offer_download"?n.jsxs(E,{type:"button",onClick:m,children:[n.jsx(Bn,{className:"mr-2 h-4 w-4"}),"Download"]}):null]})]})}function Qo({source:e,onClose:t}){return n.jsx(Te.Provider,{init:void 0,children:n.jsx(Zo,{source:e,onClose:t})})}function ea(e){const t={id:e.id,displayName:e.displayName,mimeType:e.mimeType,size:e.size??0,contentUrl:e.contentUrl,relativePath:e.relativePath??""},r=fe(t);return r==="image"?Cs:r==="pdf"?Ge:r==="audio"?Oo:r==="video"?Fo:r==="table"?Lo:r==="markdown"?$o:r==="json"?Po:r==="mermaid"?Wo:r==="code"?Uo:Tt(t).kind==="external"?Ge:Ao}function ta(e){const t={id:e.id,displayName:e.displayName,mimeType:e.mimeType,size:e.size??0,contentUrl:e.contentUrl,relativePath:e.relativePath??""},r=fe(t),s=Ct(r,e.mimeType),o=e.size?` · ${ge(e.size)}`:"";return`${s}${o}`}function Gt(e,t,r){const s=typeof e.maxTokens=="number"&&Number.isFinite(e.maxTokens)?e.maxTokens:null,o=s&&s>0?Math.min(100,e.usedTokens/s*100):null,a=s!==null?Math.max(0,Math.round(s-e.usedTokens)):null,i=o!==null?Math.max(0,100-o):null;return{...e,compactsAutomatically:e.compactsAutomatically||r,maxTokens:s??void 0,remainingTokens:a,usedPercentage:o,remainingPercentage:i,updatedAt:t}}function li(e){const t=e.some(r=>r.kind==="compact_boundary"||r.kind==="compact_summary"||r.kind==="context_cleared");for(let r=e.length-1;r>=0;r-=1){const s=e[r];if(s&&!(s.kind!=="context_window_updated"||s.usage.usedTokens<=0))return Gt(s.usage,new Date(s.createdAt).toISOString(),t)}return null}function ci(e,t){return!e||t===null||!Number.isFinite(t)||t<=0?e:Gt({...e,maxTokens:t},e.updatedAt,e.compactsAutomatically)}function P(e){return e===void 0||!Number.isFinite(e)||e<0?0:e}function di(e,t){let r=0,s=0,o=0,a=0;for(const l of e){if(l.kind!=="result")continue;const d=l.usage;d&&(r+=P(d.inputTokens),s+=P(d.outputTokens),o+=P(d.cachedInputTokens)),a+=P(l.costUsd??(d==null?void 0:d.costUsd))}for(const l of t){const d=l.usage;d&&(r+=P(d.inputTokens),s+=P(d.outputTokens),o+=P(d.cachedInputTokens),a+=P(d.costUsd))}if(r===0&&s===0&&o===0&&a===0)return null;const i=r>0?o/r*100:null;return{inputTokens:r,outputTokens:s,cachedTokens:o,costUsd:a,cacheHitPercentage:i}}function ui(e){return!Number.isFinite(e)||e<=0?"$0.00":e<.01?"<$0.01":`$${e.toFixed(2)}`}function na(e){return e==null||!Number.isFinite(e)?"0":e<1e3?`${Math.round(e)}`:e<1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,"")}m`}const ra=g.memo(({message:e})=>n.jsx("div",{className:"text-pretty prose prose-sm dark:prose-invert px-0.5 w-full max-w-[70ch] space-y-4",children:Mo(e.text)})),sa=g.memo(({message:e})=>n.jsx("div",{className:"px-0.5 w-full max-w-[70ch]",children:n.jsx($e,{content:e.text})})),oa=({children:e,className:t,animate:r=!0,shimmerWidth:s,...o})=>n.jsx("span",{className:b("mx-auto max-w-md text-foreground/60",r&&"animate-shiny-pulse",t),...o,children:e});function aa(e){const t=e.split(`
170
+ `:"").join("");return n.jsx(Mn,{source:s,lang:r},N())}if(En(e)){const r=e.getListType(),s=z(e),o=N();return r==="number"?n.jsx("ol",{className:"list-decimal ml-5 my-2",children:s},o):n.jsx("ul",{className:"list-disc ml-5 my-2",children:s},o)}if(In(e)){const r=e.getChecked(),s=z(e),o=N();return r!==void 0?n.jsxs("li",{className:"my-0.5 list-none flex items-start gap-1.5",children:[n.jsx("input",{type:"checkbox",readOnly:!0,checked:r,className:"mt-[3px] shrink-0"}),n.jsx("span",{children:s})]},o):n.jsx("li",{className:"my-0.5",children:s},o)}if($n(e)||Rn(e)){const r=e.getURL();return n.jsx("a",{href:r,className:"transition-colors underline decoration-2 text-logo decoration-logo/50 hover:text-logo/70 dark:text-logo dark:decoration-logo/70 dark:hover:text-logo/60 dark:hover:decoration-logo/40",target:"_blank",rel:"noopener noreferrer",children:z(e)},N())}if(Ln(e)){const r=e.getChildren(),s=r[0],o=s!==void 0&&Oe(s)&&s.getChildren().every(l=>Fe(l)&&(l.getHeaderStyles()&An.ROW)!==0),a=o?s:void 0,i=o?r.slice(1):r;return n.jsx("div",{className:"border border-border rounded-xl overflow-x-auto",children:n.jsxs("table",{className:"table-auto min-w-full divide-y divide-border bg-background",children:[a!==void 0&&n.jsx("thead",{children:n.jsx("tr",{children:a.getChildren().map(l=>n.jsx("th",{className:"text-left text-xs text-muted-foreground tracking-wider p-2 pl-0 first:pl-3 bg-muted dark:bg-card [&_*]:font-semibold",children:z(l)},N()))})}),n.jsx("tbody",{className:"divide-y divide-border",children:i.map(l=>Oe(l)?n.jsx("tr",{children:l.getChildren().map(d=>Fe(d)?n.jsx("td",{className:"text-left p-2 pl-0 first:pl-3 [&_*]:font-normal",children:z(d)},N()):null)},N()):null)})]})},N())}if(Pe(e))return n.jsx("br",{},N());if(Ae(e))return To(e);if(ze(e))return n.jsx("code",{className:"break-all px-1 bg-border/60 py-0.5 rounded text-sm",children:e.getTextContent()},N());const t=e.getTextContent();return t?n.jsx("span",{children:t},N()):null}function To(e){const t=e.getFormat(),r=e.getTextContent(),s=(t&Fn)!==0,o=(t&On)!==0,a=(t&Pn)!==0;if((t&zn)!==0)return n.jsx("code",{className:"break-all px-1 bg-border/60 py-0.5 rounded text-sm",children:r},N());let l=r;return a&&(l=n.jsx("del",{className:"line-through",children:l},N())),o&&(l=n.jsx("em",{className:"italic",children:l},N())),s&&(l=n.jsx("strong",{className:"font-semibold",children:l},N())),!s&&!o&&!a?r:l}function z(e){return e.getChildren().map(Vt)}function Ht(e){const t=As(e),r=dn({namespace:"kanna-message-renderer",nodes:So,editable:!1}),s=Nn(r);return s.update(()=>{wn(t,_o,void 0,!0)},{discrete:!0}),s.getEditorState().read(()=>{Wt=0,K=s,U=r;const a=kn().getChildren(),i=n.jsx(n.Fragment,{children:a.map(Vt)});return K=null,U=null,i})}function Co(e){return Ht(e)}function Mo(e){const r=Ms(e).map((s,o)=>{if(s.kind==="thinking")return n.jsx($e,{content:s.content},`think-${o}`);const a=Ht(s.content);return n.jsx("span",{children:a},`text-${o}`)});return n.jsx(n.Fragment,{children:r})}const ae=new Map;function Eo(e){return`${e.id}|${e.contentUrl}|${e.size??0}`}function Io(e,t){return t.type==="setLoadState"?{...e,loadState:t.payload}:{lastKey:t.newKey,loadState:ae.get(t.newKey)??{status:"loading"}}}function Z(e){const t=Eo(e),r=ae.get(t),[{loadState:s,lastKey:o},a]=g.useReducer(Io,{loadState:r??{status:"loading"},lastKey:t}),i=g.useRef(t);return i.current=t,o!==t&&a({type:"resetForKey",newKey:t}),g.useEffect(()=>{if(r&&r.status!=="loading")return;let l=!1;const d=t;return Mt(e.contentUrl,wt).then(c=>{if(l||i.current!==d)return;const m={status:"ready",content:c.content,truncated:c.truncated};ae.set(d,m),a({payload:m,type:"setLoadState"})}).catch(c=>{if(l||i.current!==d)return;const u={status:"error",message:c instanceof Error?c.message:"Unable to load preview."};ae.set(d,u),a({payload:u,type:"setLoadState"})}),()=>{l=!0}},[r,t,e.contentUrl]),s}function $o({source:e}){const t=Z(e);return t.status==="loading"?n.jsxs("div",{className:"p-4 text-sm text-muted-foreground",children:[n.jsx("div",{className:"prose hidden"})," Loading…"]}):t.status==="error"?n.jsx("div",{className:"p-4 text-sm text-destructive",children:t.message}):n.jsxs("div",{className:"space-y-2 p-3",children:[t.truncated?n.jsx("div",{className:"rounded-xl border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:"Preview truncated to 1024 KB."}):null,n.jsx("div",{className:"prose prose-sm prose-invert max-w-none rounded-xl border border-border bg-background p-4",children:Co(t.content)})]})}const _e=R("TableBody",e=>t=>({state:e.initialState,setState:r=>t({state:r})})),ie=new Map;function qt(e){return`${e.id}|${e.contentUrl}|${e.size??0}|${e.mimeType}`}function Ro({source:e}){const t=qt(e),r=ie.get(t),s=_e.useScopedStore(m=>m.state),o=_e.useScopedStore(m=>m.setState),a=g.useRef(t);if(a.current=t,g.useEffect(()=>{if(r&&r.status!=="loading")return;const m=e.mimeType==="text/tab-separated-values"?" ":",";let u=!1;const p=t;return Mt(e.contentUrl,wt).then(y=>{if(u||a.current!==p)return;const x={status:"ready",table:is(y.content,m),truncated:y.truncated};ie.set(p,x),o(x)}).catch(y=>{if(u||a.current!==p)return;const x={status:"error",message:y instanceof Error?y.message:"Unable to load preview."};ie.set(p,x),o(x)}),()=>{u=!0}},[r,t,e.contentUrl,e.mimeType,o]),s.status==="loading")return n.jsxs("div",{className:"p-4 text-sm text-muted-foreground",children:[n.jsx("table",{className:"sr-only"})," Loading…"]});if(s.status==="error")return n.jsxs("div",{className:"p-4 text-sm text-destructive",children:[n.jsx("table",{className:"sr-only"})," ",s.message]});const{table:i}=s,[l,...d]=i.rows,c=[s.truncated?"Preview truncated to 1024 KB.":null,i.truncatedRows?`Showing first ${i.rows.length} of ${i.rowCount} rows.`:null,i.truncatedColumns?`Showing first ${Ne} of ${i.columnCount} columns.`:null].filter(Boolean);return n.jsxs("div",{className:"space-y-2 p-3",children:[c.length?n.jsx("div",{className:"rounded-xl border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:c.join(" ")}):null,n.jsx("div",{className:"overflow-x-auto rounded-xl border border-border bg-background",children:n.jsxs("table",{className:"min-w-full border-collapse text-xs",children:[l?n.jsx("thead",{className:"sticky top-0 bg-muted",children:n.jsx("tr",{children:l.map((m,u)=>n.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium",children:m||" "},u))})}):null,n.jsx("tbody",{children:d.map((m,u)=>n.jsx("tr",{className:"odd:bg-background even:bg-muted/20",children:m.map((p,y)=>n.jsx("td",{className:"max-w-[320px] border-b border-border px-3 py-2 align-top",children:n.jsx("div",{className:"whitespace-pre-wrap break-words",children:p||" "})},y))},u))})]})})]})}function Lo({source:e}){const t=qt(e),r=ie.get(t);return n.jsx(_e.Provider,{init:{initialState:r??{status:"loading"}},children:n.jsx(Ro,{source:e})})}function Ao({source:e}){const t=Z(e);return t.status==="loading"?n.jsxs("div",{className:"p-4 text-sm text-muted-foreground",children:[n.jsx("pre",{className:"sr-only"})," Loading…"]}):t.status==="error"?n.jsxs("div",{className:"p-4 text-sm text-destructive",children:[n.jsx("pre",{className:"sr-only"})," ",t.message]}):n.jsxs("div",{className:"space-y-2 p-3",children:[t.truncated?n.jsx(zo,{children:"Preview truncated to 1024 KB."}):null,n.jsx("pre",{className:"whitespace-pre-wrap break-words rounded-xl border border-border bg-background p-3 text-xs",children:t.content})]})}function zo({children:e}){return n.jsx("div",{className:"rounded-xl border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:e})}function Po({source:e}){const t=Z(e),r=g.useMemo(()=>t.status==="ready"?as(t.content):"",[t]);return t.status==="loading"?n.jsxs("div",{className:"p-4 text-sm text-muted-foreground",children:[n.jsx("pre",{className:"sr-only"})," Loading…"]}):t.status==="error"?n.jsxs("div",{className:"p-4 text-sm text-destructive",children:[n.jsx("pre",{className:"sr-only"})," ",t.message]}):n.jsxs("div",{className:"space-y-2 p-3",children:[t.truncated?n.jsx("div",{className:"rounded-xl border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:"Preview truncated to 1024 KB."}):null,n.jsx("pre",{className:"whitespace-pre-wrap break-words rounded-xl border border-border bg-background p-3 text-xs",children:r})]})}function Oo({source:e}){return n.jsxs("div",{className:"flex h-full flex-col items-stretch justify-center gap-3 p-4",children:[n.jsx("div",{className:"text-sm font-medium text-foreground",children:e.displayName}),n.jsx("audio",{src:e.contentUrl,controls:!0,preload:"metadata",className:"w-full"})]})}function Fo({source:e}){return n.jsx("div",{className:"flex h-full items-center justify-center bg-black/40 p-2",children:n.jsx("video",{src:e.contentUrl,controls:!0,playsInline:!0,preload:"metadata",className:"max-h-[60dvh] w-full rounded-xl"})})}const Se=R("CodeBody",()=>e=>({highlighted:null,setHighlighted:t=>e({highlighted:t})})),Do=200*1024;function Bo(e){const t=e.lastIndexOf(".");if(t<0)return"text";const r=e.slice(t+1).toLowerCase();return{ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",go:"go",rs:"rust",java:"java",rb:"ruby",sh:"bash",zsh:"bash",yml:"yaml",yaml:"yaml",css:"css",scss:"scss",html:"html",json:"json",md:"markdown",sql:"sql",cpp:"cpp",c:"c",h:"c",swift:"swift",kt:"kotlin",php:"php",toml:"toml"}[r]??"text"}function Ko({source:e}){const t=Z(e),r=t.status==="ready"&&t.content.length<=Do,s=r?`${e.id}|${e.contentUrl}|${e.size??0}|${t.content.length}`:null,o=Se.useScopedStore(i=>i.highlighted),a=Se.useScopedStore(i=>i.setHighlighted);return g.useEffect(()=>{if(!r||t.status!=="ready"||s===null)return;let i=!1;const l=s;return ut(()=>import("./index-CZwuLrNi.js").then(d=>d.i),__vite__mapDeps([3,1,2])).then(async d=>{if(i)return;const c=await d.codeToHtml(t.content,{lang:Bo(e.fileName),theme:"github-dark"});i||a({key:l,html:c})}).catch(()=>{ve.warn("[file-preview] Shiki unavailable; falling back to plain text")}),()=>{i=!0}},[r,s,t,e.fileName,a]),t.status==="loading"?n.jsxs("div",{className:"p-4 text-sm text-muted-foreground",children:[n.jsx("pre",{className:"sr-only"})," Loading…"]}):t.status==="error"?n.jsxs("div",{className:"p-4 text-sm text-destructive",children:[n.jsx("pre",{className:"sr-only"})," ",t.message]}):o&&o.key===s?n.jsx("div",{className:"overflow-x-auto p-3 text-xs",dangerouslySetInnerHTML:{__html:o.html}}):n.jsxs("div",{className:"space-y-2 p-3",children:[t.truncated?n.jsx("div",{className:"rounded-xl border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:"Preview truncated to 1024 KB."}):null,n.jsx("pre",{className:"whitespace-pre-wrap break-words rounded-xl border border-border bg-background p-3 text-xs",children:t.content})]})}function Uo({source:e}){return n.jsx(Se.Provider,{init:void 0,children:n.jsx(Ko,{source:e})})}function Wo({source:e}){const t=Z(e);return t.status==="loading"?n.jsxs("div",{className:"p-4 text-sm text-muted-foreground",children:[n.jsx("div",{className:"hidden"})," Loading…"]}):t.status==="error"?n.jsx("div",{className:"p-4 text-sm text-destructive",children:t.message}):n.jsx("div",{className:"p-4",children:n.jsx(Ft,{source:t.content})})}async function Vo(e,t={}){const r=t.dom??I,s=t.clipboard??xe,o=qo(e.contentUrl,r);if(r.isWebShareSupported())try{return await r.webShare({title:e.displayName,url:o}),"shared"}catch(a){if(a instanceof DOMException&&a.name==="AbortError")return"shared"}try{return await s.writeText(o),"copied"}catch{return"failed"}}function Ho(e,t={}){(t.dom??I).triggerDownload(e.contentUrl,e.fileName)}function qo(e,t){return new URL(e,t.getBaseURI()||t.getHref()).toString()}const Te=R("SheetBody",()=>e=>({dy:0,setDy:t=>e({dy:t})}));function Go({source:e,open:t,onOpenChange:r}){const s=g.useCallback(()=>r(!1),[r]);return n.jsx(mt,{open:t&&e!==null,onOpenChange:r,children:n.jsx(pt,{size:"lg",className:"inset-0 h-[100dvh] max-h-none w-full max-w-none translate-x-0 translate-y-0 rounded-none p-0 md:inset-auto md:left-1/2 md:top-1/2 md:h-auto md:max-h-[90dvh] md:w-auto md:max-w-3xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-2xl",children:e?n.jsx(Qo,{source:e,onClose:s}):null})})}const Jo=120,Xo=.5;function Yo({startY:e,lastY:t,lastT:r,endY:s,now:o}){const a=s-e,i=Math.max(1,o-r),l=(s-t)/i;return a>Jo||l>Xo}function Zo({source:e,onClose:t}){const r=ta(e),s=Te.useScopedStore(u=>u.dy),o=Te.useScopedStore(u=>u.setDy),a=g.useRef(null),i=g.useCallback(u=>{a.current={y:u.clientY,lastY:u.clientY,lastT:Date.now()};try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}},[]),l=g.useCallback(u=>{if(!a.current)return;const p=u.clientY-a.current.y;p<0||(a.current.lastY=u.clientY,a.current.lastT=Date.now(),o(p))},[o]),d=g.useCallback(u=>{const p=a.current;a.current=null;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}p&&(Yo({startY:p.y,lastY:p.lastY,lastT:p.lastT,endY:u.clientY,now:Date.now()})?t():o(0))},[t,o]),c=g.useCallback(()=>{Vo(e)},[e]),m=g.useCallback(()=>Ho(e),[e]);return n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",style:s>0?{transform:`translateY(${s}px)`,transition:"none"}:void 0,children:[n.jsxs("div",{onPointerDown:i,onPointerMove:l,onPointerUp:d,onPointerCancel:d,className:"border-b border-border px-4 py-3 touch-none",children:[n.jsx("div",{className:"mx-auto mb-2 h-1 w-12 rounded-full bg-muted md:hidden",role:"button","aria-label":"Drag down to close"}),n.jsx(xt,{className:"truncate text-base",children:e.displayName}),n.jsx(Dn,{className:"truncate text-xs",children:r})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain touch-pan-y [-webkit-overflow-scrolling:touch]",role:"region","aria-label":"File preview",children:g.createElement(ea(e),{source:e})},e.id),n.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-border px-4 py-3",children:[n.jsxs(E,{type:"button",variant:"outline",onClick:c,children:[n.jsx(Wr,{className:"mr-2 h-4 w-4"}),"Share"]}),e.origin==="offer_download"?n.jsxs(E,{type:"button",onClick:m,children:[n.jsx(Bn,{className:"mr-2 h-4 w-4"}),"Download"]}):null]})]})}function Qo({source:e,onClose:t}){return n.jsx(Te.Provider,{init:void 0,children:n.jsx(Zo,{source:e,onClose:t})})}function ea(e){const t={id:e.id,displayName:e.displayName,mimeType:e.mimeType,size:e.size??0,contentUrl:e.contentUrl,relativePath:e.relativePath??""},r=fe(t);return r==="image"?Cs:r==="pdf"?Ge:r==="audio"?Oo:r==="video"?Fo:r==="table"?Lo:r==="markdown"?$o:r==="json"?Po:r==="mermaid"?Wo:r==="code"?Uo:Tt(t).kind==="external"?Ge:Ao}function ta(e){const t={id:e.id,displayName:e.displayName,mimeType:e.mimeType,size:e.size??0,contentUrl:e.contentUrl,relativePath:e.relativePath??""},r=fe(t),s=Ct(r,e.mimeType),o=e.size?` · ${ge(e.size)}`:"";return`${s}${o}`}function Gt(e,t,r){const s=typeof e.maxTokens=="number"&&Number.isFinite(e.maxTokens)?e.maxTokens:null,o=s&&s>0?Math.min(100,e.usedTokens/s*100):null,a=s!==null?Math.max(0,Math.round(s-e.usedTokens)):null,i=o!==null?Math.max(0,100-o):null;return{...e,compactsAutomatically:e.compactsAutomatically||r,maxTokens:s??void 0,remainingTokens:a,usedPercentage:o,remainingPercentage:i,updatedAt:t}}function li(e){const t=e.some(r=>r.kind==="compact_boundary"||r.kind==="compact_summary"||r.kind==="context_cleared");for(let r=e.length-1;r>=0;r-=1){const s=e[r];if(s&&!(s.kind!=="context_window_updated"||s.usage.usedTokens<=0))return Gt(s.usage,new Date(s.createdAt).toISOString(),t)}return null}function ci(e,t){return!e||t===null||!Number.isFinite(t)||t<=0?e:Gt({...e,maxTokens:t},e.updatedAt,e.compactsAutomatically)}function P(e){return e===void 0||!Number.isFinite(e)||e<0?0:e}function di(e,t){let r=0,s=0,o=0,a=0;for(const l of e){if(l.kind!=="result")continue;const d=l.usage;d&&(r+=P(d.inputTokens),s+=P(d.outputTokens),o+=P(d.cachedInputTokens)),a+=P(l.costUsd??(d==null?void 0:d.costUsd))}for(const l of t){const d=l.usage;d&&(r+=P(d.inputTokens),s+=P(d.outputTokens),o+=P(d.cachedInputTokens),a+=P(d.costUsd))}if(r===0&&s===0&&o===0&&a===0)return null;const i=r>0?o/r*100:null;return{inputTokens:r,outputTokens:s,cachedTokens:o,costUsd:a,cacheHitPercentage:i}}function ui(e){return!Number.isFinite(e)||e<=0?"$0.00":e<.01?"<$0.01":`$${e.toFixed(2)}`}function na(e){return e==null||!Number.isFinite(e)?"0":e<1e3?`${Math.round(e)}`:e<1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,"")}m`}const ra=g.memo(({message:e})=>n.jsx("div",{className:"text-pretty prose prose-sm dark:prose-invert px-0.5 w-full max-w-[70ch] space-y-4",children:Mo(e.text)})),sa=g.memo(({message:e})=>n.jsx("div",{className:"px-0.5 w-full max-w-[70ch]",children:n.jsx($e,{content:e.text})})),oa=({children:e,className:t,animate:r=!0,shimmerWidth:s,...o})=>n.jsx("span",{className:b("mx-auto max-w-md text-foreground/60",r&&"animate-shiny-pulse",t),...o,children:e});function aa(e){const t=e.split(`
171
171
  `),r=/^\s*(\d+)→(.*)$/;return t.map(s=>{const o=s.match(r);return o?{lineNumber:parseInt(o[1],10),content:o[2]}:{lineNumber:null,content:s}})}function ia(e){return e.replace(/<[^>]+>/g,"")}function la(e,t){const r=e.split(`
172
172
  `),s=t.split(`
173
173
  `),o=ca(r,s),a=da(r,s,o);return ua(a)}function ca(e,t){const r=e.length,s=t.length,o=Array.from({length:r+1},()=>Array(s+1).fill(0));for(let a=1;a<=r;a++)for(let i=1;i<=s;i++)o[a][i]=e[a-1]===t[i-1]?o[a-1][i-1]+1:Math.max(o[a-1][i],o[a][i-1]);return o}function da(e,t,r){const s=[];let o=e.length,a=t.length;for(;o>0||a>0;)o>0&&a>0&&e[o-1]===t[a-1]?(s.push({type:"context",text:e[o-1],oldIdx:o,newIdx:a}),o--,a--):a>0&&(o===0||r[o][a-1]>=r[o-1][a])?(s.push({type:"added",text:t[a-1],oldIdx:o,newIdx:a}),a--):(s.push({type:"removed",text:e[o-1],oldIdx:o,newIdx:a}),o--);return s.reverse()}function ua(e){return e.map(t=>{let r;return t.type==="removed"?r="-":t.type==="added"?r="+":r=" ",{type:t.type,content:`${r}${t.text}`}})}function re({content:e,isDiff:t=!1,oldString:r,newString:s}){const o=g.useMemo(()=>t&&r!==void 0&&s!==void 0?la(r,s):[],[t,r,s]),a=g.useMemo(()=>t?[]:aa(e),[e,t]),i=g.useMemo(()=>a.some(l=>l.lineNumber!==null),[a]);return t&&o.length>0?n.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:n.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:n.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:n.jsx("tbody",{children:o.map((l,d)=>{let c;l.type==="removed"?c="bg-destructive/10 dark:bg-destructive/15":l.type==="added"?c="bg-success/10 dark:bg-success/15":c="";let m;l.type==="removed"?m="text-destructive":l.type==="added"?m="text-success":m="text-foreground";let u;l.type==="removed"?u="text-destructive/50":l.type==="added"?u="text-success/50":u="text-muted-foreground/50";let p;return l.type==="removed"?p="-":l.type==="added"?p="+":p=" ",n.jsxs("tr",{className:c,children:[n.jsx("td",{className:`px-2 py-0 select-none w-0 whitespace-nowrap ${u}`,children:p}),n.jsx("td",{className:`px-2 py-0 whitespace-pre select-all ${m}`,children:l.content.slice(1)})]},d)})})})})}):n.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:n.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:n.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:n.jsx("tbody",{children:a.map((l,d)=>n.jsxs("tr",{children:[i&&n.jsx("td",{className:"px-2 py-0 select-none w-0 whitespace-nowrap text-muted-foreground/50 text-right",children:l.lineNumber!==null?l.lineNumber:""}),n.jsx("td",{className:"px-2 py-0 whitespace-pre select-all text-foreground",children:ia(l.content)})]},d))})})})})}function Jt({tone:e,label:t}){return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-border bg-card px-2 py-1 text-xs font-medium",children:[n.jsx("span",{"aria-hidden":!0,className:b("inline-block size-1.5 rounded-full",ft(e))}),n.jsx("span",{className:Re(e),children:t})]})}function Le({status:e,pulse:t=!1}){return n.jsx(Jt,{tone:ht(e),label:Kn(e),pulse:t&&e==="running"})}function ma(){return n.jsx("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium tracking-wide text-muted-foreground",children:"started…"})}function pa({name:e,description:t,run:r}){const s=e??"Workflow";return n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx(vt,{className:"size-4 text-muted-icon shrink-0"}),n.jsxs("div",{className:"flex flex-1 items-center gap-2 min-w-0 overflow-hidden",children:[n.jsx("span",{className:"font-medium text-foreground/80 text-sm truncate",children:s}),t&&n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t}),r?n.jsxs(n.Fragment,{children:[n.jsx(Le,{status:r.status}),r.agentCount!=null&&r.agentCount>0&&n.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[r.agentCount," agents"]})]}):n.jsx(ma,{})]})]})}const Xt=g.createContext(null);function mi({children:e,value:t}){return n.jsx(Xt.Provider,{value:t,children:e})}function xa(){return g.useContext(Xt)}const ha=[],$=R("SubagentTaskMessage",()=>e=>({expanded:!1,loading:!1,loaded:!1,children:ha,error:null,setExpanded:t=>e({expanded:t}),setLoading:t=>e({loading:t}),setLoaded:t=>e({loaded:t}),setChildren:t=>e({children:t}),setError:t=>e({error:t})}));function fa(e,t){return t||e==="failed"||e==="error"?"destructive":e==="in_progress"||e==="running"?"active":"muted"}function ga(e){if(!e)return"";const t=[],r=(s,o,a)=>{s&&s>0&&t.push(`${s} ${s===1?o:a}`)};return r(e.readCount,"read","reads"),r(e.editFileCount,"edit","edits"),r(e.bashCount,"cmd","cmds"),r(e.searchCount,"search","searches"),r(e.otherToolCount,"tool","tools"),t.join(" · ")}function ya({subagentType:e,result:t,isError:r,localPath:s}){const o=e||"Agent",a=fa(t==null?void 0:t.status,r),i=ga(t==null?void 0:t.toolStats),l=xa(),d=t==null?void 0:t.agentId,c=!!(l&&d),m=$.useScopedStore(h=>h.expanded),u=$.useScopedStore(h=>h.loading),p=$.useScopedStore(h=>h.loaded),y=$.useScopedStore(h=>h.children),x=$.useScopedStore(h=>h.error),v=$.useScopedStore(h=>h.setExpanded),C=$.useScopedStore(h=>h.setLoading),_=$.useScopedStore(h=>h.setLoaded),w=$.useScopedStore(h=>h.setChildren),f=$.useScopedStore(h=>h.setError),S=g.useCallback(()=>{if(!l||!d)return;const h=!m;v(h),h&&!p&&!u&&(C(!0),f(null),l(d).then(T=>{w(Un(T)),_(!0)}).catch(T=>f(T instanceof Error?T.message:"Failed to load subagent transcript")).finally(()=>C(!1)))},[l,d,m,p,u,v,C,f,w,_]),M=n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c?n.jsx(ct,{className:b("size-4 text-muted-icon shrink-0 transition-transform",m&&"rotate-90"),"aria-hidden":!0}):n.jsx(Nt,{className:"size-4 text-muted-icon shrink-0"}),n.jsxs("div",{className:"flex flex-1 items-center gap-2 min-w-0 overflow-hidden",children:[n.jsx("span",{className:"font-medium text-foreground/80 text-sm truncate",children:o}),(t==null?void 0:t.status)&&n.jsx(Jt,{tone:a,label:t.status}),(t==null?void 0:t.totalTokens)!=null&&t.totalTokens>0&&n.jsxs("span",{className:"inline-flex items-center gap-0.5 text-xs text-muted-foreground tabular-nums",children:[n.jsx(or,{className:"size-3","aria-hidden":!0}),na(t.totalTokens)," tokens"]}),(t==null?void 0:t.totalDurationMs)!=null&&t.totalDurationMs>0&&n.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:he(t.totalDurationMs)}),i&&n.jsx("span",{className:"text-xs text-muted-foreground tabular-nums truncate",children:i}),u&&n.jsx(gt,{className:"size-3 animate-spin text-muted-foreground","aria-label":"Loading"})]})]});return c?n.jsxs("div",{className:"min-w-0",children:[n.jsx("button",{type:"button",onClick:S,"aria-expanded":m,className:"w-full text-left cursor-pointer",children:M}),m&&n.jsxs("div",{className:"mt-2 ml-2 border-l-2 border-muted-foreground/20 pl-3 space-y-2",children:[x&&n.jsx("div",{className:"text-xs text-destructive",children:x}),!x&&p&&y.length===0&&n.jsx("div",{className:"text-xs text-muted-foreground",children:"No subagent activity recorded."}),y.map(h=>n.jsx(Fa,{message:h,localPath:s??""},h.id))]})]}):M}function ba({subagentType:e,result:t,isError:r,localPath:s}){return n.jsx($.Provider,{init:void 0,children:n.jsx(ya,{subagentType:e,result:t,isError:r,localPath:s})})}function rt(e){let t;return se(e)&&Array.isArray(e.content)?t=e.content:Array.isArray(e)?t=e:t=[],t.flatMap(r=>!r||typeof r!="object"||!("type"in r)||r.type!=="image"?[]:"data"in r&&typeof r.data=="string"?[{type:"image",data:r.data,mimeType:"mimeType"in r&&typeof r.mimeType=="string"?r.mimeType:void 0}]:"source"in r&&r.source&&typeof r.source=="object"&&"type"in r.source&&r.source.type==="base64"&&"data"in r.source&&typeof r.source.data=="string"?[{type:"image",data:r.source.data,mimeType:"media_type"in r.source&&typeof r.source.media_type=="string"?r.source.media_type:void 0}]:[])}function ja({images:e}){return n.jsx("div",{className:"flex flex-col gap-3",children:e.map((t,r)=>{const s=t.mimeType||"image/png";return n.jsx("div",{className:"overflow-hidden rounded-lg border border-border bg-muted/20",children:n.jsx("img",{src:`data:${s};base64,${t.data}`,alt:`Read result ${r+1}`,className:"max-h-[50vh] w-full object-contain bg-background"})},`${s}:${r}`)})})}function va({message:e,isLoading:t=!1,localPath:r,chatId:s=""}){var M;const o=e.result!==void 0,a=!o&&t,i=Wn(Vn(Hn(s))),l=g.useMemo(()=>{if(e.toolKind==="skill")return e.input.skill;if(e.toolKind==="glob")return`Search files ${e.input.pattern==="**/*"?"in all directories":`matching ${e.input.pattern}`}`;if(e.toolKind==="grep"){const h=e.input.pattern,T=e.input.outputMode;return T==="count"?`Count \`${h}\` occurrences`:T==="content"?`Find \`${h}\` in text`:`Find \`${h}\` in files`}return e.toolKind==="bash"?e.input.description||(e.input.command?qn(e.input.command):"Bash"):e.toolKind==="web_search"?e.input.query||"Web Search":e.toolKind==="read_file"?`Read ${ne(e.input.filePath,r)}`:e.toolKind==="write_file"?`Write ${ne(e.input.filePath,r)}`:e.toolKind==="edit_file"?`Edit ${ne(e.input.filePath,r)}`:e.toolKind==="delete_file"?`Delete ${ne(e.input.filePath,r)}`:e.toolKind==="mcp_generic"?`${De(e.input.tool)} from ${De(e.input.server)}`:e.toolKind==="subagent_task"?e.input.subagentType||e.toolName:e.toolKind==="workflow"?e.input.name??"Workflow":e.toolName},[e.input,e.toolKind,e.toolName,r]),d=g.useMemo(()=>e.toolKind==="subagent_task",[e.toolKind]),c=g.useMemo(()=>{if(e.toolKind==="skill")return e.input.skill},[e.input,e.toolKind]),m=e.toolKind==="bash",u=e.toolKind==="write_file",p=e.toolKind==="edit_file",y=e.toolKind==="delete_file",x=e.toolKind==="read_file",v=g.useMemo(()=>{if(typeof e.result=="string")return e.result;if(!e.result)return"";if(se(e.result)){const h=e.result.content;if(typeof h=="string")return h}return JSON.stringify(e.result,null,2)},[e.result]),C=g.useMemo(()=>{if(!x)return[];if(se(e.result)){const h=e.result.blocks;if(Array.isArray(h)){const T=rt(h);if(T.length>0)return T}}return rt(e.rawResult)},[x,e.rawResult,e.result]),_=g.useMemo(()=>{switch(e.toolKind){case"bash":return e.input.command;case"write_file":case"delete_file":return e.input.content;default:return JSON.stringify(e.input,null,2)}},[e]);let w;m?w=n.jsxs("span",{className:"flex items-center gap-2 w-full",children:[n.jsx("span",{children:"Command"}),!!e.input.timeoutMs&&n.jsxs("span",{className:"text-muted-foreground",children:["timeout: ",String(e.input.timeoutMs),"ms"]}),!!e.input.runInBackground&&n.jsx("span",{className:"text-muted-foreground",children:"background"})]}):u?w="Contents":w="Input";let f;p?f=n.jsx(re,{content:"",isDiff:!0,oldString:e.input.oldString,newString:e.input.newString}):y?f=n.jsx(re,{content:e.input.content}):!x&&!u?f=n.jsx(He,{label:w,copyText:_,children:_}):f=null;let S;if(e.toolKind==="workflow"&&!e.isError){const h=se(e.result)&&typeof e.result.text=="string"?{taskId:typeof e.result.taskId=="string"?e.result.taskId:void 0,text:e.result.text}:void 0,T=h==null?void 0:h.taskId,Qt=T?i.find(en=>en.taskId===T):void 0;S=n.jsx(pa,{name:e.input.name,description:e.input.description,run:Qt})}else e.toolKind==="subagent_task"&&e.result?S=n.jsx(ba,{subagentType:e.input.subagentType,result:e.result,isError:e.isError,localPath:r}):S=n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:e.isError?n.jsx(pe,{className:"size-4 text-destructive"}):d?n.jsx(Nt,{className:"size-4 text-muted-icon"}):e.toolKind==="workflow"?n.jsx(vt,{className:"size-4 text-muted-icon"}):n.jsx(At,{icon:fs(e.toolName),className:"size-4 text-muted-icon"})}),n.jsx(Pt,{className:"text-left transition-opacity duration-200 truncate",children:n.jsx(oa,{animate:a,shimmerWidth:Math.max(20,(((M=c||l)==null?void 0:M.length)??33)*3),children:c||l})})]});return n.jsx(zt,{className:"w-full",children:n.jsx(bs,{expandedContent:n.jsx(vs,{className:"my-4 text-sm",children:n.jsxs("div",{className:"flex flex-col gap-2",children:[f,o&&x&&!e.isError&&(C.length>0?n.jsxs("div",{children:[n.jsx("span",{className:"font-medium text-muted-foreground",children:"Image"}),n.jsx("div",{className:"mt-1",children:n.jsx(ja,{images:C})})]}):n.jsx(re,{content:v})),u&&!e.isError&&n.jsx(re,{content:e.input.content}),o&&!x&&!(u&&!e.isError)&&!(p&&!e.isError)&&!(y&&!e.isError)&&n.jsx(He,{label:e.isError?"Error":"Result",copyText:v,children:v})]})}),children:S})})}const Yt={serverOverloaded:"transient",internalServerError:"transient",httpConnectionFailed:"transient",responseStreamConnectionFailed:"transient",responseStreamDisconnected:"transient",responseTooManyFailedAttempts:"transient",usageLimitExceeded:"quota",sessionBudgetExceeded:"quota",unauthorized:"auth",contextWindowExceeded:"fatal",badRequest:"fatal",cyberPolicy:"fatal",sandboxError:"fatal",threadRollbackFailed:"fatal",activeTurnNotSteerable:"fatal",other:"unknown"},st=new Set(["httpConnectionFailed","responseStreamConnectionFailed","responseStreamDisconnected","responseTooManyFailedAttempts","activeTurnNotSteerable"]);function Ce(e){return e in Yt}function Na(e){if(e==null)return null;if(typeof e=="string")return Ce(e)&&!st.has(e)?e:null;if(typeof e!="object")return null;const t=Object.keys(e);if(t.length!==1)return null;const[r]=t;return st.has(r)&&Ce(r)?r:null}function Zt(e){return typeof e=="string"?Ce(e)?e:null:Na(e)}function wa(e){const t=Zt(e);return t===null?"unknown":Yt[t]}function ka(e){return wa(e)==="transient"}const _a={serverOverloaded:e=>`${e} is temporarily at capacity. Retry, or switch to another model.`,internalServerError:e=>`${e} hit a server-side error. Retrying usually clears it.`,httpConnectionFailed:()=>"Could not reach the model provider. Check your connection, then retry.",responseStreamConnectionFailed:()=>"The response stream failed to connect. Retry to start a new stream.",responseStreamDisconnected:()=>"The response stream disconnected mid-turn. Retry to pick up from where it stopped.",responseTooManyFailedAttempts:e=>`${e} failed repeatedly while streaming. Retry, or switch to another model.`,usageLimitExceeded:()=>"You have reached your Codex usage limit. Access returns when the limit window resets.",sessionBudgetExceeded:()=>"This session reached its configured token budget.",unauthorized:()=>"Codex rejected the credentials for this request. Re-authenticate with `codex login`.",contextWindowExceeded:e=>`The conversation no longer fits in ${e}'s context window. Start a new chat or compact this one.`,badRequest:()=>"Codex rejected the request as malformed.",cyberPolicy:()=>"Codex declined this request under its usage policy.",sandboxError:()=>"The Codex sandbox failed to run the requested command.",threadRollbackFailed:()=>"Codex could not roll the conversation back to the requested point.",activeTurnNotSteerable:()=>"The running turn cannot accept new input. Wait for it to finish, or stop it."},Sa="The selected model";function Ta(e,t){const r=Zt(e);if(r===null)return null;const s=_a[r];return s===void 0?null:s(Sa)}const le=R("TranscriptActionCard",()=>e=>({busyId:null,actionError:null,setBusyId:t=>e({busyId:t}),setActionError:t=>e({actionError:t})})),Ca={neutral:"border-border bg-card",muted:"border-border/50 bg-card/50 opacity-75",success:"border-emerald-500/30 bg-emerald-500/5",error:"border-destructive/40 bg-destructive/5"},Ma={primary:"default",secondary:"secondary",ghost:"ghost",destructive:"destructive"};function Ea(e){return n.jsx(le.Provider,{init:void 0,children:n.jsx(Ia,{...e})})}function Ia({title:e,description:t,body:r,errorMessage:s,tone:o="neutral",actions:a=[]}){const i=le.useScopedStore(u=>u.busyId),l=le.useScopedStore(u=>u.actionError),d=le.useScopedStoreApi(),c=g.useCallback(async u=>{const p=d.getState();if(p.busyId)return;p.setActionError(null);let y;try{y=u.onClick()}catch(x){ve.error("[transcript-action-card] sync click threw",String(x)),d.getState().setActionError(x instanceof Error?x.message:String(x));return}if(y instanceof Promise){p.setBusyId(u.id);try{await y}catch(x){ve.error("[transcript-action-card] async click rejected",String(x)),d.getState().setActionError(x instanceof Error?x.message:String(x))}finally{d.getState().setBusyId(null)}}},[d]),m=i!==null;return n.jsxs("div",{"data-focus-fallback-ignore":!0,className:b("rounded-lg border px-4 py-3 text-sm space-y-2 transition-colors",Ca[o]),children:[n.jsx("div",{className:"flex items-start justify-between gap-3",children:n.jsxs("div",{className:"space-y-1 min-w-0 flex-1",children:[n.jsx("div",{className:"font-medium leading-tight",children:e}),t?n.jsx("div",{className:"text-muted-foreground text-xs leading-snug",children:t}):null]})}),r?n.jsx("div",{className:"text-xs leading-snug",children:r}):null,s?n.jsx("div",{className:"text-destructive text-xs leading-snug",children:s}):null,l?n.jsx("div",{className:"text-destructive text-xs leading-snug",role:"alert",children:l}):null,a.length>0?n.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:a.map(u=>{const p=i===u.id;return n.jsxs(E,{type:"button",size:"sm",variant:Ma[u.variant??"ghost"],disabled:u.disabled||m&&!p,onClick:()=>{c(u)},className:"gap-1.5",children:[p?n.jsx(gt,{className:"size-3.5 animate-spin"}):null,u.label]},u.id)})}):null]})}function $a(e){if(e<1e3)return`${e}ms`;const t=Math.floor(e/1e3),r=Math.floor(t/3600),s=Math.floor(t%3600/60),o=t%60;return r>0?`${r}h${s>0?` ${s}m`:""}`:s>0?`${s}m${o>0?` ${o}s`:""}`:`${o}s`}function ot({durationMs:e,prefix:t="Worked for"}){return e<=0?null:n.jsxs(gs,{children:[t," ",$a(e)]})}const je=/\[([^\]]+)\]\(\/chat\/([0-9a-fA-F][0-9a-fA-F-]{7,})\)/g;function Ra(e,t){const r=[];let s=0,o=0;je.lastIndex=0;for(let a=je.exec(e);a!==null;a=je.exec(e))a.index>s&&r.push(e.slice(s,a.index)),r.push(n.jsx(Gn,{to:`/chat/${a[2]}`,className:"underline decoration-destructive/40 hover:decoration-destructive",children:a[1]},`chat-link-${o++}`)),s=a.index+a[0].length;return s<e.length&&r.push(e.slice(s)),r.length===0?e:r}function La({resultMessageId:e,body:t,onRetry:r}){const o=[{id:"retry",label:"Retry",variant:"primary",onClick:g.useCallback(()=>r(e),[r,e])}];return n.jsx("div",{className:"mx-2 my-1",children:n.jsx(Ea,{title:"Turn failed",tone:"error",body:t,actions:o})})}function Aa({message:e,onRetry:t}){if(!e.success){const r=e.codexErrorInfo,s=(r?Ta(r):null)??e.result??"",o=s.trim().length>0,a=r!==void 0&&ka(r);let i=null;return a&&t?i=n.jsx(La,{resultMessageId:e.id,body:s,onRetry:t}):o&&(i=n.jsx("div",{className:"px-4 py-3 mx-2 my-1 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive text-sm whitespace-pre-wrap",children:Ra(s)})),n.jsxs(n.Fragment,{children:[i,e.durationMs>0?n.jsx(ot,{durationMs:e.durationMs,prefix:"Failed after"}):null]})}return n.jsx(ot,{durationMs:e.durationMs})}function za(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function Pa(e){return typeof e=="string"?e:JSON.stringify(e,null,2)}function Oa(e){return e.replace(/<persisted-output>\n?/g,"").replace(/\n?<\/persisted-output>/g,"")}function Fa({message:e,localPath:t,isRunning:r=!1}){if(e.kind==="tool"&&e.persisted){const o=Oa(Pa(e.rawResult??""));return n.jsxs("div",{className:"animate-in fade-in-0 duration-200 rounded-md border border-border bg-muted/30 p-2 space-y-1 text-xs",children:[n.jsxs("div",{className:"font-medium",children:[e.toolName,": output too large (",za(e.persisted.originalSize),") — saved to disk"]}),n.jsx("pre",{className:"text-xs whitespace-pre-wrap overflow-hidden max-h-48",children:o}),n.jsxs("a",{href:Bt(e.persisted.filePath),className:"text-blue-500 hover:underline break-all",target:"_blank",rel:"noreferrer",children:["View full output (",e.persisted.filePath,")"]})]})}let s;switch(e.kind){case"assistant_text":s=n.jsx(ra,{message:e});break;case"assistant_thinking":s=n.jsx(sa,{message:e});break;case"tool":s=n.jsx(va,{message:e,isLoading:r,localPath:t});break;case"result":s=n.jsx(Aa,{message:e});break;default:return null}return n.jsx("div",{className:"animate-in fade-in-0 duration-200",children:s})}const B=R("WorkflowsSectionDetail",()=>e=>({selectedRun:null,selectedRunId:null,setSelectedRun:t=>e({selectedRun:t}),setSelectedRunId:t=>e({selectedRunId:t}),clearSelection:()=>e({selectedRun:null,selectedRunId:null})})),at="Agents";function it(e){return typeof e.phaseIndex=="number"&&e.phaseIndex>=1}function Da(e,t){var a;if(!t.some(it))return t.length===0?[]:[{key:"ungrouped",phaseIndex:null,title:at,agents:t}];const r=new Map,s=[];for(const i of t)if(it(i)){const l=r.get(i.phaseIndex)??[];l.push(i),r.set(i.phaseIndex,l)}else s.push(i);const o=[];e.forEach((i,l)=>{const d=l+1;o.push({key:`phase-${d}`,phaseIndex:d,title:i.title,detail:i.detail,agents:r.get(d)??[]}),r.delete(d)});for(const i of[...r.keys()].sort((l,d)=>l-d)){const l=r.get(i);o.push({key:`phase-${i}`,phaseIndex:i,title:((a=l[0])==null?void 0:a.phaseTitle)??`Phase ${i}`,agents:l})}return s.length>0&&o.push({key:"ungrouped",phaseIndex:null,title:at,agents:s}),o}function Ba({runs:e,onSelectRun:t,selectedRunId:r}){return e.length===0?n.jsx(Ka,{}):n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("div",{className:"flex items-center justify-between gap-2",children:n.jsxs("span",{className:"text-xs font-medium tracking-wide text-muted-foreground",style:{fontVariantNumeric:"tabular-nums"},children:[e.length," ",e.length===1?"run":"runs"]})}),n.jsx("ul",{className:"flex flex-col gap-0.5",children:e.map(s=>n.jsx(Ua,{run:s,selected:s.runId===r,onSelect:t},s.runId))})]})}function Ka(){return n.jsxs("div",{className:"flex w-full flex-col items-center gap-4 rounded-lg border border-dashed border-border px-6 py-14 text-center","data-testid":"workflow-empty",children:[n.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground",children:n.jsx(tr,{className:"size-5","aria-hidden":!0})}),n.jsx("p",{className:"text-sm font-medium text-foreground",children:"No workflow runs"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Workflow runs will appear here when triggered."})]})}function Ua(e){const{run:t,selected:r}=e,s=t.workflowName??t.runId,o=t.status==="running",a=g.useCallback(()=>{e.onSelect(t.runId)},[e,t.runId]);return n.jsx("li",{children:n.jsxs("button",{type:"button","data-testid":`workflow-row:${t.runId}`,onClick:a,className:b("flex w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted",r&&"bg-muted"),children:[n.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[n.jsx("span",{className:b("truncate text-sm text-foreground",(o||r)&&"font-medium"),children:s}),n.jsx(Le,{status:t.status,pulse:!0})]}),n.jsxs("span",{className:"flex w-full items-center gap-3 text-xs text-muted-foreground",children:[t.agentCount!=null?n.jsxs("span",{className:"tabular-nums",style:{fontVariantNumeric:"tabular-nums"},children:[t.agentCount," ",t.agentCount===1?"agent":"agents"]}):null,t.totalTokens!=null?n.jsxs("span",{className:"tabular-nums",style:{fontVariantNumeric:"tabular-nums"},children:[t.totalTokens.toLocaleString()," tokens"]}):null,t.durationMs!=null?n.jsx("span",{className:"tabular-nums",style:{fontVariantNumeric:"tabular-nums"},children:he(t.durationMs)}):null]})]})})}function Wa(e){return e==="running"||e==="progress"?"active":e==="failed"||e==="error"?"destructive":e==="killed"?"attention":"muted"}function Va(e){const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}}function Ha({run:e,open:t,onClose:r}){return n.jsx(mt,{open:t,onOpenChange:s=>{s||r()},children:n.jsxs(pt,{size:"lg","aria-describedby":void 0,children:[n.jsx(Jn,{children:n.jsx(xt,{children:e?e.workflowName??e.runId:"Workflow run"})}),n.jsx(Xn,{children:e?n.jsx(Ga,{run:e}):n.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"})})]})})}function lt({label:e,text:t}){return n.jsxs("div",{className:"rounded border border-border/50 bg-muted/40 px-2 py-1",children:[n.jsx("span",{className:"text-xs font-medium tracking-wide text-muted-foreground",children:e}),n.jsx("p",{className:"whitespace-pre-wrap break-words text-xs text-muted-foreground/90",children:t})]})}function qa({agent:e,onSelectAgent:t}){const r=Wa(e.state),s=r==="active",o=!!(t&&e.agentId);return n.jsxs("li",{"data-testid":`workflow-agent:${e.agentId??e.index}`,className:"group flex items-start gap-2 rounded-md px-2 py-1.5 transition-colors hover:bg-muted/50",children:[n.jsx("span",{"aria-hidden":!0,className:b("mt-1.5 inline-block size-1.5 shrink-0 rounded-full",ft(r),s&&"animate-pulse")}),n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:b("truncate text-sm text-foreground",s&&"font-medium"),children:e.label}),e.model?n.jsx("span",{className:"shrink-0 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium text-muted-foreground",children:e.model}):null,o?n.jsxs("button",{type:"button","data-testid":`workflow-agent-transcript:${e.agentId}`,onClick:()=>t==null?void 0:t(e.agentId),className:"ml-auto inline-flex shrink-0 items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[n.jsx(bt,{className:"size-3","aria-hidden":!0}),"Transcript"]}):null]}),n.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-muted-foreground",children:[n.jsx("span",{className:b("capitalize",Re(r)),children:e.state}),e.lastToolName?n.jsxs("span",{className:"truncate",children:["last: ",e.lastToolName]}):null,e.durationMs!=null?n.jsx("span",{className:"tabular-nums",children:he(e.durationMs)}):null,e.tokens!=null?n.jsxs("span",{className:"tabular-nums",children:[e.tokens.toLocaleString()," tok"]}):null,e.toolCalls!=null?n.jsxs("span",{className:"tabular-nums",children:[e.toolCalls," calls"]}):null]}),e.lastToolSummary?n.jsx("span",{className:"truncate text-xs text-muted-foreground/80",children:e.lastToolSummary}):null,e.promptPreview?n.jsx(lt,{label:"Prompt",text:e.promptPreview}):null,e.resultPreview?n.jsx(lt,{label:"Result",text:e.resultPreview}):null]})]})}function Ga({run:e,onSelectAgent:t,title:r}){const s=ht(e.status),o=Da(e.phases,e.agents);return n.jsxs("div",{className:"flex flex-col gap-5",children:[n.jsxs("div",{className:"flex flex-col gap-1.5",children:[r?n.jsx("h3",{className:"truncate text-base font-semibold text-foreground",children:r}):null,n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n.jsx(Le,{status:e.status,pulse:!0}),e.durationMs!=null?n.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:he(e.durationMs)}):null,e.agentCount!=null?n.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[e.agentCount," ",e.agentCount===1?"agent":"agents"]}):null,e.totalTokens!=null?n.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[e.totalTokens.toLocaleString()," tokens"]}):null,e.totalToolCalls!=null?n.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[e.totalToolCalls," tool calls"]}):null]})]}),e.summary?n.jsxs("section",{className:"flex flex-col gap-1",children:[n.jsx("h4",{className:"text-xs font-medium tracking-wide text-muted-foreground",children:"Summary"}),n.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:e.summary})]}):null,o.length>0?n.jsx("section",{className:"flex flex-col gap-4","data-testid":"workflow-progress-tree",children:o.map(a=>n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[a.phaseIndex!=null?n.jsx("span",{"aria-hidden":!0,className:"flex size-4 shrink-0 items-center justify-center rounded bg-muted text-xs font-medium text-muted-foreground tabular-nums",children:a.phaseIndex}):null,n.jsx("h4",{className:"text-xs font-semibold tracking-wide text-foreground",children:a.title}),n.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[a.agents.length," ",a.agents.length===1?"agent":"agents"]})]}),a.detail?n.jsx("p",{className:"text-xs text-muted-foreground",children:a.detail}):null,a.agents.length>0?n.jsx("ul",{className:"ml-1.5 flex flex-col gap-0.5 border-l border-border pl-2.5",children:a.agents.map(i=>n.jsx(qa,{agent:i,onSelectAgent:t},i.agentId??i.index))}):n.jsx("p",{className:"ml-1.5 border-l border-border pl-2.5 text-xs italic text-muted-foreground/70",children:"No agents yet"})]},a.key))}):null,e.result?n.jsxs("section",{className:"flex flex-col gap-1",children:[n.jsx("h4",{className:"text-xs font-medium tracking-wide text-muted-foreground",children:"Result"}),n.jsx("pre",{className:"max-h-80 overflow-auto rounded-md border border-border/60 bg-muted/40 px-3 py-2 text-xs text-foreground whitespace-pre-wrap break-words",children:Va(e.result)})]}):null,e.script?n.jsxs("details",{className:"flex flex-col gap-1",children:[n.jsx("summary",{className:"cursor-pointer text-xs font-medium tracking-wide text-muted-foreground hover:text-foreground",children:"Script"}),n.jsx("pre",{className:"mt-1.5 max-h-96 overflow-auto rounded-md border border-border/60 bg-muted/40 px-3 py-2 text-xs text-foreground whitespace-pre-wrap break-words",children:e.script})]}):null,e.error&&e.status!=="completed"?n.jsxs("section",{className:"flex flex-col gap-1",children:[n.jsx("h4",{className:b("text-xs font-medium tracking-wide",Re(s)),children:"Error"}),n.jsx("p",{className:"rounded-md border border-destructive/20 bg-destructive/5 px-3 py-2 text-sm text-destructive whitespace-pre-wrap",children:e.error})]}):null]})}function Ja({runs:e,getRunDetail:t}){const r=B.useScopedStore(u=>u.selectedRun),s=B.useScopedStore(u=>u.selectedRunId),o=B.useScopedStore(u=>u.setSelectedRun),a=B.useScopedStore(u=>u.setSelectedRunId),i=B.useScopedStore(u=>u.clearSelection),l=r!==null,d=g.useRef(null),c=g.useCallback(async u=>{d.current=e,a(u),o("loading");const p=await t(u);o(p)},[t,e,o,a]),m=g.useCallback(()=>{i(),d.current=null},[i]);return g.useEffect(()=>{if(s===null||e===d.current)return;const u=e.find(y=>y.runId===s);if(!u||u.status!=="running")return;let p=!1;return t(s).then(y=>{p||y===null||o(y)}),()=>{p=!0}},[e,s,t,o]),n.jsxs(n.Fragment,{children:[n.jsx(Ba,{runs:e,onSelectRun:u=>{c(u)}}),n.jsx(Ha,{run:r==="loading"?null:r,open:l,onClose:m})]})}function pi(e){return n.jsx(B.Provider,{init:void 0,children:n.jsx(Ja,{...e})})}export{Ps as $,ks as A,sa as B,W as C,ra as D,bs as E,Go as F,vt as G,na as H,ui as I,Os as J,Fs as K,oi as L,zr as M,ci as N,ti as O,ii as P,ei as Q,Aa as R,mi as S,Ue as T,Nt as U,vs as V,Ga as W,ni as X,tr as Y,ai as Z,pi as _,Fa as a,Ra as a0,li as a1,di as a2,Ba as b,oe as c,or as d,bt as e,Tt as f,Lr as g,zt as h,Pt as i,ri as j,Ve as k,hs as l,si as m,fs as n,He as o,ts as p,fe as q,Co as r,ne as s,co as t,Ct as u,ge as v,Mt as w,oa as x,va as y,Ea as z};
@@ -1 +1 @@
1
- import{M as ln,N as an,O as Y,P as O,Q,R as un,S as y,T as tn,V as j,W as _,X as rn,Y as o,Z as on,$ as sn,a0 as fn}from"./mermaid.core-DHuSoCjt.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,D,S,v,R,V,a){var E=D-l,i=S-h,n=V-v,d=a-R,u=d*E-n*i;if(!(u*u<y))return u=(n*(h-R)-d*(l-v))/u,[l+u*E,h+u*i]}function H(l,h,D,S,v,R,V){var a=l-D,E=h-S,i=(V?R:-R)/j(a*a+E*E),n=i*E,d=-i*a,u=l+n,s=h+d,f=D+n,c=S+d,W=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,A=m*m+g*g,T=v-R,P=u*c-f*s,I=(g<0?-1:1)*j(on(0,T*T*A-P*P)),M=(P*g-m*I)/A,N=(-P*m-g*I)/A,w=(P*g+m*I)/A,p=(-P*m+g*I)/A,x=M-W,e=N-t,r=w-W,X=p-t;return x*x+e*e>r*r+X*X&&(M=w,N=p),{cx:M,cy:N,x01:-n,y01:-d,x11:M*(v/T-1),y11:N*(v/T-1)}}function hn(){var l=cn,h=yn,D=Q(0),S=null,v=gn,R=dn,V=mn,a=null,E=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=R.apply(this,arguments)-un,W=rn(c-f),t=c>f;if(a||(a=n=E()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(W>tn-y)a.moveTo(s*Y(f),s*O(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*Y(c),u*O(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,A=f,T=c,P=W,I=W,M=V.apply(this,arguments)/2,N=M>y&&(S?+S.apply(this,arguments):j(u*u+s*s)),w=_(rn(s-u)/2,+D.apply(this,arguments)),p=w,x=w,e,r;if(N>y){var X=sn(N/u*O(M)),z=sn(N/s*O(M));(P-=X*2)>y?(X*=t?1:-1,A+=X,T-=X):(P=0,A=T=(f+c)/2),(I-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(I=0,m=g=(f+c)/2)}var Z=s*Y(m),$=s*O(m),B=u*Y(T),C=u*O(T);if(w>y){var F=s*Y(g),G=s*O(g),J=u*Y(A),K=u*O(A),q;if(W<an)if(q=pn(Z,$,J,K,F,G,B,C)){var L=Z-q[0],U=$-q[1],k=F-q[0],b=G-q[1],nn=1/O(fn((L*k+U*b)/(j(L*L+U*U)*j(k*k+b*b)))/2),en=j(q[0]*q[0]+q[1]*q[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}I>y?x>y?(e=H(J,K,Z,$,s,x,t),r=H(F,G,B,C,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(Z,$),a.arc(0,0,s,m,g,!t)):a.moveTo(Z,$),!(u>y)||!(P>y)?a.lineTo(B,C):p>y?(e=H(B,C,F,G,u,-p,t),r=H(Z,$,J,K,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,A,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-an/2;return[Y(d)*n,O(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:Q(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:Q(+n),i):h},i.cornerRadius=function(n){return arguments.length?(D=typeof n=="function"?n:Q(+n),i):D},i.padRadius=function(n){return arguments.length?(S=n==null?null:typeof n=="function"?n:Q(+n),i):S},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:Q(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:Q(+n),i):R},i.padAngle=function(n){return arguments.length?(V=typeof n=="function"?n:Q(+n),i):V},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
1
+ import{M as ln,N as an,O as Y,P as O,Q,R as un,S as y,T as tn,V as j,W as _,X as rn,Y as o,Z as on,$ as sn,a0 as fn}from"./mermaid.core-ChAu8gwz.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,D,S,v,R,V,a){var E=D-l,i=S-h,n=V-v,d=a-R,u=d*E-n*i;if(!(u*u<y))return u=(n*(h-R)-d*(l-v))/u,[l+u*E,h+u*i]}function H(l,h,D,S,v,R,V){var a=l-D,E=h-S,i=(V?R:-R)/j(a*a+E*E),n=i*E,d=-i*a,u=l+n,s=h+d,f=D+n,c=S+d,W=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,A=m*m+g*g,T=v-R,P=u*c-f*s,I=(g<0?-1:1)*j(on(0,T*T*A-P*P)),M=(P*g-m*I)/A,N=(-P*m-g*I)/A,w=(P*g+m*I)/A,p=(-P*m+g*I)/A,x=M-W,e=N-t,r=w-W,X=p-t;return x*x+e*e>r*r+X*X&&(M=w,N=p),{cx:M,cy:N,x01:-n,y01:-d,x11:M*(v/T-1),y11:N*(v/T-1)}}function hn(){var l=cn,h=yn,D=Q(0),S=null,v=gn,R=dn,V=mn,a=null,E=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=R.apply(this,arguments)-un,W=rn(c-f),t=c>f;if(a||(a=n=E()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(W>tn-y)a.moveTo(s*Y(f),s*O(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*Y(c),u*O(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,A=f,T=c,P=W,I=W,M=V.apply(this,arguments)/2,N=M>y&&(S?+S.apply(this,arguments):j(u*u+s*s)),w=_(rn(s-u)/2,+D.apply(this,arguments)),p=w,x=w,e,r;if(N>y){var X=sn(N/u*O(M)),z=sn(N/s*O(M));(P-=X*2)>y?(X*=t?1:-1,A+=X,T-=X):(P=0,A=T=(f+c)/2),(I-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(I=0,m=g=(f+c)/2)}var Z=s*Y(m),$=s*O(m),B=u*Y(T),C=u*O(T);if(w>y){var F=s*Y(g),G=s*O(g),J=u*Y(A),K=u*O(A),q;if(W<an)if(q=pn(Z,$,J,K,F,G,B,C)){var L=Z-q[0],U=$-q[1],k=F-q[0],b=G-q[1],nn=1/O(fn((L*k+U*b)/(j(L*L+U*U)*j(k*k+b*b)))/2),en=j(q[0]*q[0]+q[1]*q[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}I>y?x>y?(e=H(J,K,Z,$,s,x,t),r=H(F,G,B,C,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(Z,$),a.arc(0,0,s,m,g,!t)):a.moveTo(Z,$),!(u>y)||!(P>y)?a.lineTo(B,C):p>y?(e=H(B,C,F,G,u,-p,t),r=H(Z,$,J,K,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,A,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-an/2;return[Y(d)*n,O(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:Q(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:Q(+n),i):h},i.cornerRadius=function(n){return arguments.length?(D=typeof n=="function"?n:Q(+n),i):D},i.padRadius=function(n){return arguments.length?(S=n==null?null:typeof n=="function"?n:Q(+n),i):S},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:Q(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:Q(+n),i):R},i.padAngle=function(n){return arguments.length?(V=typeof n=="function"?n:Q(+n),i):V},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};