@hienlh/ppm 0.9.93 → 0.9.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/.env.example +98 -0
- package/.opencode/skills/ads-management/scripts/.env.example +13 -0
- package/.opencode/skills/ai-multimodal/.env.example +230 -0
- package/.opencode/skills/cip-design/.env.example +6 -0
- package/.opencode/skills/devops/.env.example +76 -0
- package/.opencode/skills/docs-seeker/.env.example +15 -0
- package/.opencode/skills/elevenlabs/.env.example +3 -0
- package/.opencode/skills/marketing-dashboard/.env.example +15 -0
- package/.opencode/skills/marketing-dashboard/app/.env.example +2 -0
- package/.opencode/skills/marketing-dashboard/server/.env.example +2 -0
- package/.opencode/skills/mcp-management/scripts/dist/analyze-tools.js +70 -0
- package/.opencode/skills/mcp-management/scripts/dist/cli.js +160 -0
- package/.opencode/skills/mcp-management/scripts/dist/mcp-client.js +183 -0
- package/.opencode/skills/payment-integration/scripts/.env.example +20 -0
- package/.opencode/skills/sequential-thinking/.env.example +8 -0
- package/CHANGELOG.md +15 -0
- package/bun.lock +6 -0
- package/dist/web/assets/ai-settings-section-LMO_cfIW.js +1 -0
- package/dist/web/assets/api-client-o_6TmLGC.js +1 -0
- package/dist/web/assets/api-settings-CoKe_BdR.js +1 -0
- package/dist/web/assets/architecture-PBZL5I3N-CUZIB1Vq.js +1 -0
- package/dist/web/assets/arrow-up-Dtrfv490.js +1 -0
- package/dist/web/assets/chat-tab-BRM81W0L.js +10 -0
- package/dist/web/assets/chevron-right-BzAdxJRG.js +1 -0
- package/dist/web/assets/code-CuravVys.js +1 -0
- package/dist/web/assets/code-editor-lxeFhLDX.js +8 -0
- package/dist/web/assets/columns-2-4fQcE4PF.js +1 -0
- package/dist/web/assets/conflict-editor-CO6NyEYJ.js +19 -0
- package/dist/web/assets/createLucideIcon-BjHrJDVb.js +1 -0
- package/dist/web/assets/{csv-preview-BZRICDP0.js → csv-preview-BizIVMyb.js} +2 -2
- package/dist/web/assets/database-D4DIhgi-.js +1 -0
- package/dist/web/assets/database-viewer-CU2X8VC-.js +2 -0
- package/dist/web/assets/diff-viewer-EybMrfw9.js +4 -0
- package/dist/web/assets/dist-C5IgeqrV.js +1 -0
- package/dist/web/assets/dist-im4ynINo.js +11 -0
- package/dist/web/assets/esm-K1XIK4vc.js +2 -0
- package/dist/web/assets/extension-store-3yZYn07W.js +1 -0
- package/dist/web/assets/extension-webview-DkacDy3f.js +3 -0
- package/dist/web/assets/gitGraph-HDMCJU4V-CtOMUphQ.js +1 -0
- package/dist/web/assets/index-BZ4G-2BK.css +2 -0
- package/dist/web/assets/index-D7PJ14mf.js +26 -0
- package/dist/web/assets/info-3K5VOQVL-BCrPCWGY.js +1 -0
- package/dist/web/assets/input-CHRMley8.js +1 -0
- package/dist/web/assets/keybindings-store-BAuymsWd.js +1 -0
- package/dist/web/assets/keybindings-store-BKyNIeFB.js +1 -0
- package/dist/web/assets/{lib-DSLzfeW0.js → lib-D_kRA9p6.js} +1 -1
- package/dist/web/assets/markdown-renderer-ocvtw_4F.js +3 -0
- package/dist/web/assets/packet-RMMSAZCW-D_OqB-zi.js +1 -0
- package/dist/web/assets/pie-UPGHQEXC-WUHpLNJz.js +1 -0
- package/dist/web/assets/plus-51UQ45rf.js +1 -0
- package/dist/web/assets/port-forwarding-tab-Chz3t_rM.js +1 -0
- package/dist/web/assets/postgres-viewer-cf8Xbssy.js +3 -0
- package/dist/web/assets/project-store-Ciq-cK1O.js +1 -0
- package/dist/web/assets/radar-KQ55EAFF-HQIIecVM.js +1 -0
- package/dist/web/assets/react-GqWghJ-L.js +1 -0
- package/dist/web/assets/refresh-cw-CSFrDtiu.js +1 -0
- package/dist/web/assets/scroll-area-DwWF9FpN.js +1 -0
- package/dist/web/assets/settings-store-B470PCWf.js +2 -0
- package/dist/web/assets/settings-tab-1jARRAlz.js +1 -0
- package/dist/web/assets/{sql-query-editor-DaePHpQI.js → sql-query-editor-DZ9xskL8.js} +1 -1
- package/dist/web/assets/sqlite-viewer-CveDk6KG.js +1 -0
- package/dist/web/assets/square-nsMa3iMk.js +1 -0
- package/dist/web/assets/tab-store-DZbiYk7y.js +1 -0
- package/dist/web/assets/table-Dq575bPF.js +1 -0
- package/dist/web/assets/terminal-tab-RvacNDWY.js +1 -0
- package/dist/web/assets/text-wrap-Cn6BNQfq.js +1 -0
- package/dist/web/assets/trash-2-CJYoLw7Q.js +1 -0
- package/dist/web/assets/treemap-KZPCXAKY-0wLgUUTz.js +1 -0
- package/dist/web/assets/{use-monaco-theme-CM4IMROI.js → use-monaco-theme-OY18iXNi.js} +1 -1
- package/dist/web/assets/vendor-markdown-0Mxgxy0L.js +295 -0
- package/dist/web/assets/vendor-mermaid-B2SLgECS.js +2657 -0
- package/dist/web/assets/vendor-ui-B-T_damt.js +45 -0
- package/dist/web/assets/vendor-xterm-ejLe7-tK.js +36 -0
- package/dist/web/assets/x-DlFGzN8d.js +1 -0
- package/dist/web/index.html +26 -21
- package/dist/web/sw.js +1 -1
- package/docs/code-standards.md +56 -4
- package/docs/journals/260415-frontend-memory-optimization.md +73 -0
- package/docs/project-changelog.md +11 -1
- package/docs/system-architecture.md +36 -0
- package/package.json +1 -1
- package/src/cli/commands/stop.ts +31 -0
- package/src/server/index.ts +68 -17
- package/src/services/autostart-generator.ts +1 -1
- package/src/services/autostart-register.ts +34 -29
- package/src/web/components/chat/message-list.tsx +59 -22
- package/src/web/components/chat/tool-cards.tsx +11 -4
- package/src/web/components/database/data-grid.tsx +2 -1
- package/src/web/components/editor/code-editor.tsx +14 -8
- package/src/web/components/editor/conflict-editor.tsx +2 -1
- package/src/web/components/editor/diff-viewer.tsx +2 -1
- package/src/web/components/editor/editor-breadcrumb.tsx +2 -1
- package/src/web/components/explorer/file-tree.tsx +6 -5
- package/src/web/components/explorer/search-panel.tsx +2 -1
- package/src/web/components/extensions/extension-webview.tsx +16 -30
- package/src/web/components/git/git-status-panel.tsx +2 -1
- package/src/web/components/layout/add-project-form.tsx +2 -1
- package/src/web/components/layout/mobile-drawer.tsx +2 -1
- package/src/web/components/layout/mobile-nav.tsx +2 -1
- package/src/web/components/layout/panel-layout.tsx +3 -3
- package/src/web/components/layout/project-bar.tsx +7 -6
- package/src/web/components/layout/project-bottom-sheet.tsx +2 -1
- package/src/web/components/layout/sidebar.tsx +5 -4
- package/src/web/components/layout/status-bar.tsx +5 -4
- package/src/web/components/layout/tab-bar.tsx +3 -3
- package/src/web/components/layout/tab-content.tsx +2 -1
- package/src/web/components/postgres/postgres-viewer.tsx +7 -5
- package/src/web/components/settings/settings-tab.tsx +2 -1
- package/src/web/components/shared/markdown-code-block.tsx +10 -8
- package/src/web/components/terminal/terminal-tab.tsx +3 -3
- package/src/web/hooks/use-chat.ts +4 -1
- package/vite.config.ts +17 -0
- package/dist/web/assets/_basePickBy-Bj0dI1ei.js +0 -1
- package/dist/web/assets/_baseUniq-CyzdZeQH.js +0 -1
- package/dist/web/assets/ai-settings-section-Bo9lCaTd.js +0 -1
- package/dist/web/assets/api-client-BvxmRZUi.js +0 -1
- package/dist/web/assets/api-settings-CUxg9RE5.js +0 -1
- package/dist/web/assets/arc-CxgHJ7Z4.js +0 -1
- package/dist/web/assets/architecture-PBZL5I3N-DDFO_NKq.js +0 -1
- package/dist/web/assets/architectureDiagram-2XIMDMQ5-D16OotsC.js +0 -36
- package/dist/web/assets/array-BFDiaBgf.js +0 -1
- package/dist/web/assets/arrow-up-I9-21gkR.js +0 -1
- package/dist/web/assets/blockDiagram-WCTKOSBZ-Ct57Wtfk.js +0 -132
- package/dist/web/assets/c4Diagram-IC4MRINW-BIymcNsg.js +0 -10
- package/dist/web/assets/channel-wumTB1if.js +0 -1
- package/dist/web/assets/chat-tab-CC721_mQ.js +0 -10
- package/dist/web/assets/chevron-right-DY_wImxB.js +0 -1
- package/dist/web/assets/chunk-4BX2VUAB-CENmY7Kw.js +0 -1
- package/dist/web/assets/chunk-55IACEB6-DhZGI1l3.js +0 -1
- package/dist/web/assets/chunk-7E7YKBS2-DZcnC7Ow.js +0 -1
- package/dist/web/assets/chunk-7R4GIKGN-y8bfHEy-.js +0 -80
- package/dist/web/assets/chunk-C72U2L5F-BHPkfQj2.js +0 -1
- package/dist/web/assets/chunk-EGIJ26TM-nant2LXl.js +0 -1
- package/dist/web/assets/chunk-FMBD7UC4-Bog4cpN-.js +0 -15
- package/dist/web/assets/chunk-GEFDOKGD-86LFbsAC.js +0 -2
- package/dist/web/assets/chunk-GLR3WWYH-Re-5eSlQ.js +0 -2
- package/dist/web/assets/chunk-HHEYEP7N-C45i5G_3.js +0 -1
- package/dist/web/assets/chunk-JSJVCQXG-23eG9mgt.js +0 -1
- package/dist/web/assets/chunk-KX2RTZJC-CHj8TnTB.js +0 -1
- package/dist/web/assets/chunk-KYZI473N-gqRLpJ4w.js +0 -53
- package/dist/web/assets/chunk-L3YUKLVL-DnSMmNFC.js +0 -1
- package/dist/web/assets/chunk-MX3YWQON-B6g1ZH9X.js +0 -1
- package/dist/web/assets/chunk-NQ4KR5QH-DX32345Y.js +0 -220
- package/dist/web/assets/chunk-O4XLMI2P-Vp_V4P-b.js +0 -7
- package/dist/web/assets/chunk-OZEHJAEY-lKq2SWjA.js +0 -1
- package/dist/web/assets/chunk-PQ6SQG4A-Bik13fTV.js +0 -1
- package/dist/web/assets/chunk-PU5JKC2W-DD95Rx35.js +0 -70
- package/dist/web/assets/chunk-QZHKN3VN-N3VXx1VH.js +0 -1
- package/dist/web/assets/chunk-R5LLSJPH-dRhXRnrb.js +0 -1
- package/dist/web/assets/chunk-WL4C6EOR-B1iIvLOG.js +0 -189
- package/dist/web/assets/chunk-XIRO2GV7-DZBoNl1_.js +0 -1
- package/dist/web/assets/chunk-XPW4576I-CgLyyW03.js +0 -32
- package/dist/web/assets/chunk-XZSTWKYB-DjV8xl5A.js +0 -94
- package/dist/web/assets/chunk-YBOYWFTD-D_ILLe6_.js +0 -1
- package/dist/web/assets/classDiagram-VBA2DB6C-mr-Cb1me.js +0 -1
- package/dist/web/assets/classDiagram-v2-RAHNMMFH-BKe8_uda.js +0 -1
- package/dist/web/assets/clone--z5KLAuR.js +0 -1
- package/dist/web/assets/code-editor-BZ0xwZ4Z.js +0 -8
- package/dist/web/assets/columns-2-IeETSfON.js +0 -1
- package/dist/web/assets/conflict-editor-Bwls2-yk.js +0 -19
- package/dist/web/assets/cose-bilkent-S5V4N54A-BGNPFv3x.js +0 -1
- package/dist/web/assets/cytoscape.esm-C8i2jUzT.js +0 -321
- package/dist/web/assets/dagre-CkhlMHnx.js +0 -1
- package/dist/web/assets/dagre-KLK3FWXG-Cnp996VG.js +0 -4
- package/dist/web/assets/database-CgTomMxt.js +0 -1
- package/dist/web/assets/database-viewer-DiXWqOJH.js +0 -2
- package/dist/web/assets/defaultLocale-ZeknFqNe.js +0 -1
- package/dist/web/assets/diagram-E7M64L7V-BZF0tSOr.js +0 -24
- package/dist/web/assets/diagram-IFDJBPK2-nUcO8sN8.js +0 -43
- package/dist/web/assets/diagram-P4PSJMXO-CW0eCkwC.js +0 -24
- package/dist/web/assets/diff-viewer-CC-RmeV5.js +0 -4
- package/dist/web/assets/dist-CM0oD8tQ.js +0 -1
- package/dist/web/assets/dist-DZmJeHOA.js +0 -1
- package/dist/web/assets/erDiagram-INFDFZHY-DSkriYZ9.js +0 -70
- package/dist/web/assets/extension-webview-C1d6fezE.js +0 -3
- package/dist/web/assets/flowDiagram-PKNHOUZH-CFYAfZBx.js +0 -162
- package/dist/web/assets/ganttDiagram-A5KZAMGK-KSn4XAU4.js +0 -292
- package/dist/web/assets/gitGraph-HDMCJU4V-OkvBPi6H.js +0 -1
- package/dist/web/assets/gitGraphDiagram-K3NZZRJ6-BMgjjVys.js +0 -65
- package/dist/web/assets/graphlib-BWe1iK_s.js +0 -1
- package/dist/web/assets/index-BcIyrJiY.js +0 -26
- package/dist/web/assets/index-Chf0otez.css +0 -2
- package/dist/web/assets/info-3K5VOQVL-BDU2_bYD.js +0 -1
- package/dist/web/assets/infoDiagram-LFFYTUFH-Diq4Cyc3.js +0 -2
- package/dist/web/assets/init-0VJVrkRJ.js +0 -1
- package/dist/web/assets/input-BHj0veau.js +0 -45
- package/dist/web/assets/isArrayLikeObject-ClzWCpcm.js +0 -1
- package/dist/web/assets/isEmpty-BfLnxq-B.js +0 -1
- package/dist/web/assets/ishikawaDiagram-PHBUUO56-CiVEvp8o.js +0 -70
- package/dist/web/assets/journeyDiagram-4ABVD52K-CG_v5Aho.js +0 -139
- package/dist/web/assets/jsx-runtime-BRW_vwa9.js +0 -1
- package/dist/web/assets/kanban-definition-K7BYSVSG-miB0-_Zq.js +0 -89
- package/dist/web/assets/keybindings-store-BIufrOzJ.js +0 -1
- package/dist/web/assets/line-CSuSrJ9J.js +0 -1
- package/dist/web/assets/linear-DFN_MPsw.js +0 -1
- package/dist/web/assets/markdown-renderer-C5UPA1-7.js +0 -306
- package/dist/web/assets/math-CRc16Nj6.js +0 -1
- package/dist/web/assets/mermaid-parser.core-CFdP1Z5_.js +0 -4
- package/dist/web/assets/mindmap-definition-YRQLILUH-pYPWwASE.js +0 -68
- package/dist/web/assets/ordinal-DpFn432U.js +0 -1
- package/dist/web/assets/packet-RMMSAZCW-BwpIpYB3.js +0 -1
- package/dist/web/assets/path-INs8XTPH.js +0 -1
- package/dist/web/assets/pie-UPGHQEXC-BPgAfmes.js +0 -1
- package/dist/web/assets/pieDiagram-SKSYHLDU-Dovdlvhu.js +0 -30
- package/dist/web/assets/plus-DQGIb4mQ.js +0 -1
- package/dist/web/assets/port-forwarding-tab-DmifthYH.js +0 -1
- package/dist/web/assets/postgres-viewer-Bo7jEQfQ.js +0 -13
- package/dist/web/assets/preload-helper-mr3rCizq.js +0 -1
- package/dist/web/assets/quadrantDiagram-337W2JSQ-TXe6cU_F.js +0 -7
- package/dist/web/assets/radar-KQ55EAFF-TqxBkWx-.js +0 -1
- package/dist/web/assets/react-0tkk-ztn.js +0 -1
- package/dist/web/assets/react-dom-Bpkvzu3U.js +0 -1
- package/dist/web/assets/react-nm2Ru1Pt.js +0 -1
- package/dist/web/assets/refresh-cw-Clk8fdUD.js +0 -1
- package/dist/web/assets/requirementDiagram-Z7DCOOCP-CuiiuGS9.js +0 -73
- package/dist/web/assets/rough.esm-eLccZ4OJ.js +0 -1
- package/dist/web/assets/sankeyDiagram-WA2Y5GQK-BbRmhv0t.js +0 -10
- package/dist/web/assets/scroll-area-BpXCNme3.js +0 -1
- package/dist/web/assets/sequenceDiagram-2WXFIKYE-B2D8IQDb.js +0 -145
- package/dist/web/assets/settings-tab-D9GicyA9.js +0 -1
- package/dist/web/assets/sqlite-viewer-pacZlViY.js +0 -1
- package/dist/web/assets/square-vBdqj0bF.js +0 -1
- package/dist/web/assets/src-CqyWLlNZ.js +0 -1
- package/dist/web/assets/stateDiagram-RAJIS63D-ylr4HxPu.js +0 -1
- package/dist/web/assets/stateDiagram-v2-FVOUBMTO-D6zvxf3M.js +0 -1
- package/dist/web/assets/table-Bi27fEaN.js +0 -1
- package/dist/web/assets/terminal-tab-DpzE3yoD.js +0 -36
- package/dist/web/assets/text-wrap-D_OmSzhp.js +0 -1
- package/dist/web/assets/timeline-definition-YZTLITO2-pMv1grvM.js +0 -61
- package/dist/web/assets/trash-2-CNuB-htI.js +0 -1
- package/dist/web/assets/treemap-KZPCXAKY-Kck06FKU.js +0 -1
- package/dist/web/assets/vennDiagram-LZ73GAT5-C-rkIUbo.js +0 -34
- package/dist/web/assets/x-Dw3TjeY_.js +0 -1
- package/dist/web/assets/xychartDiagram-JWTSCODW-CtpjAakO.js +0 -7
- /package/dist/web/assets/{csv-parser-i7fjqP2H.js → csv-parser--2WJNgS7.js} +0 -0
- /package/dist/web/assets/{katex-DR0kdMDv.js → katex-CKoArbIw.js} +0 -0
- /package/dist/web/assets/{chunk-CFjPhJqf.js → rolldown-runtime-FhOqtrmT.js} +0 -0
- /package/dist/web/assets/{sql-completion-provider-B8uUWWej.js → sql-completion-provider-C3cq9j99.js} +0 -0
- /package/dist/web/assets/{utils-DX8jb5qv.js → utils-ChWX7pZv.js} +0 -0
- /package/dist/web/assets/{terminal-tab-BrP-ENHg.css → vendor-xterm-BrP-ENHg.css} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-ocvtw_4F.js","assets/rolldown-runtime-FhOqtrmT.js","assets/index-D7PJ14mf.js","assets/vendor-mermaid-B2SLgECS.js","assets/vendor-ui-B-T_damt.js","assets/vendor-markdown-0Mxgxy0L.js","assets/input-CHRMley8.js","assets/utils-ChWX7pZv.js","assets/createLucideIcon-BjHrJDVb.js","assets/x-DlFGzN8d.js","assets/scroll-area-DwWF9FpN.js","assets/ai-settings-section-LMO_cfIW.js","assets/dist-C5IgeqrV.js","assets/plus-51UQ45rf.js","assets/refresh-cw-CSFrDtiu.js","assets/trash-2-CJYoLw7Q.js","assets/api-client-o_6TmLGC.js","assets/api-settings-CoKe_BdR.js","assets/chevron-right-BzAdxJRG.js","assets/database-D4DIhgi-.js","assets/react-GqWghJ-L.js","assets/extension-store-3yZYn07W.js","assets/keybindings-store-BAuymsWd.js","assets/tab-store-DZbiYk7y.js","assets/project-store-Ciq-cK1O.js","assets/settings-store-B470PCWf.js","assets/index-BZ4G-2BK.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import"./vendor-ui-B-T_damt.js";import{t as r}from"./createLucideIcon-BjHrJDVb.js";import{t as i}from"./arrow-up-Dtrfv490.js";import{a,c as o,d as s,f as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y}from"./ai-settings-section-LMO_cfIW.js";import{i as b,n as x,r as S}from"./dist-C5IgeqrV.js";import{n as C,r as w,t as T}from"./plus-51UQ45rf.js";import{t as E}from"./chevron-right-BzAdxJRG.js";import{a as D,i as O,l as k,n as A,o as j,r as M,s as N,t as P,u as F}from"./input-CHRMley8.js";import{t as I}from"./code-CuravVys.js";import{t as L}from"./columns-2-4fQcE4PF.js";import{n as R,r as ee,t as te}from"./x-DlFGzN8d.js";import{t as z}from"./refresh-cw-CSFrDtiu.js";import{t as B}from"./square-nsMa3iMk.js";import{t as ne}from"./trash-2-CJYoLw7Q.js";import{G as V}from"./vendor-mermaid-B2SLgECS.js";import{n as re}from"./settings-store-B470PCWf.js";import{n as H,r as ie,t as U}from"./utils-ChWX7pZv.js";import{n as W,t as G}from"./tab-store-DZbiYk7y.js";import{i as K,r as ae,t as q}from"./api-client-o_6TmLGC.js";import{n as oe}from"./project-store-Ciq-cK1O.js";import{a as se,c as ce,f as J,g as Y,i as le,l as ue,m as de,o as X,p as fe,r as pe,s as me,t as he,u as ge}from"./api-settings-CoKe_BdR.js";import{A as Z,C as _e,E as ve,F as ye,H as be,M as xe,N as Se,O as Ce,R as we,S as Te,T as Ee,V as De,W as Oe,_ as ke,b as Ae,h as je,i as Me,k as Ne,r as Pe,t as Fe,x as Ie,z as Le}from"./index-D7PJ14mf.js";var Re=r(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),ze=r(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),Be=r(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),Ve=r(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),He=r(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),Ue=r(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),We=r(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Ge=r(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),Ke=r(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),qe=r(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),Je=r(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),Ye=r(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),Xe=r(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),Ze=r(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Qe=r(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),$e=r(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),et=r(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),tt=r(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),nt=r(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),rt=r(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),Q=e(n(),1);function it({url:e,onMessage:t,autoConnect:n=!0}){let r=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{let i=new Fe(e);return r.current=i,t&&i.onMessage(t),n&&i.connect(),()=>{i.disconnect(),r.current=null}},[e,n]),{send:(0,Q.useCallback)(e=>{r.current?.send(e)},[]),connect:(0,Q.useCallback)(()=>{r.current?.connect()},[]),disconnect:(0,Q.useCallback)(()=>{r.current?.disconnect()},[])}}var at=null;function ot(){return at||=new AudioContext,at}function st(e,t,n,r,i=`sine`){let a=ot(),o=a.createOscillator(),s=a.createGain();o.type=i,o.frequency.value=e,s.gain.setValueAtTime(r,n),s.gain.exponentialRampToValueAtTime(.001,n+t),o.connect(s),s.connect(a.destination),o.start(n),o.stop(n+t)}function ct(){let e=ot().currentTime;st(523,.15,e,.15),st(659,.2,e+.12,.15)}function lt(){let e=ot().currentTime;st(880,.12,e,.18,`square`),st(698,.12,e+.15,.18,`square`),st(880,.15,e+.3,.15,`square`)}function ut(){let e=ot().currentTime;st(440,.12,e,.12),st(523,.12,e+.1,.12),st(659,.18,e+.2,.12)}var dt={done:ct,approval_request:lt,question:ut};function ft(e){try{dt[e]?.()}catch{}}var pt={hasTeams:!1,teamNames:[],messageCount:0,unreadCount:0};function mt(e){if(document.hidden)return!1;let{panels:t,focusedPanelId:n}=W.getState(),r=t[n];if(!r)return!1;let i=r.tabs.find(e=>e.id===r.activeTabId);return i?.type===`chat`&&i.metadata?.sessionId===e}function ht(e,t=`claude`,n=``){let[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(`idle`),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(0),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!1),E=(0,Q.useRef)(``),D=(0,Q.useRef)([]),O=(0,Q.useRef)(null),k=(0,Q.useRef)(`idle`),A=(0,Q.useRef)(null),j=(0,Q.useRef)(()=>{}),M=(0,Q.useRef)(null),N=(0,Q.useRef)(e);N.current=e;let P=(0,Q.useRef)(n);P.current=n;let F=(0,Q.useRef)(null),I=(0,Q.useRef)({teamNames:new Set,messages:[]}),L=(0,Q.useRef)(0),[R,ee]=(0,Q.useState)(pt),[te,z]=(0,Q.useState)([]),B=(0,Q.useCallback)(()=>{let e=I.current;ee({hasTeams:e.teamNames.size>0,teamNames:Array.from(e.teamNames),messageCount:e.messages.length,unreadCount:L.current}),z([...e.messages])},[]),ne=(0,Q.useCallback)(()=>{L.current=0,B()},[B]),V=s!==`idle`,re=(0,Q.useCallback)((e,t)=>{let n=D.current.findIndex(e=>e.type===`tool_use`&&(e.tool===`Agent`||e.tool===`Task`)&&e.toolUseId===t);if(n===-1)return!1;let r=D.current[n];if(r.type!==`tool_use`)return!1;let i=[...r.children??[],e];return D.current[n]={...r,children:i},!0},[]),H=(0,Q.useCallback)(()=>{let e=E.current,t=[...D.current],n=O.current;i(r=>{let i=r[r.length-1];return i?.role===`assistant`&&!i.id.startsWith(`final-`)?[...r.slice(0,-1),{...i,content:e,events:t,...n}]:[...r,{id:`streaming-${Date.now()}`,role:`assistant`,content:e,events:t,timestamp:new Date().toISOString(),...n}]})},[]),ie=(0,Q.useCallback)(e=>{let t=e,n=t?.type;if(n)switch(n){case`account_info`:O.current={accountId:t.accountId,accountLabel:t.accountLabel},b(null);break;case`account_retry`:t.accountId&&t.accountLabel&&(O.current={accountId:t.accountId,accountLabel:t.accountLabel}),D.current.push(t),H();break;case`status_update`:{let e=t.accountLabel?` (${t.accountLabel})`:``;b(`${t.message}${e}`);break}case`text`:{let e=t.parentToolUseId;if(e&&re(t,e)){H();break}E.current+=t.content,D.current.push(t),H();break}case`thinking`:{let e=t.parentToolUseId;if(e&&re(t,e)){H();break}D.current.push(t),H();break}case`tool_use`:{let e=t.parentToolUseId;if(e&&re(t,e)){H();break}D.current.push(t),H();break}case`tool_result`:{let e=t.parentToolUseId;if(e&&re(t,e)){H();break}D.current.push(t),H();break}case`approval_request`:if(D.current.push(t),m({requestId:t.requestId,tool:t.tool,input:t.input}),N.current&&!mt(N.current)){let e=t.tool===`AskUserQuestion`?`question`:`approval_request`;ke.getState().addNotification(N.current,e,P.current),ft(e);let n=N.current,r=t.tool===`AskUserQuestion`;F.current=x[r?`info`:`warning`](r?`AI has a question`:`${t.tool} needs permission`,{description:P.current||`Session ${n.slice(0,8)}`,duration:1/0,action:{label:`Go to session`,onClick:()=>{let{panels:e}=W.getState();for(let[t,r]of Object.entries(e)){let e=r.tabs.find(e=>e.metadata?.sessionId===n);if(e){W.getState().setActiveTab(e.id,t);break}}}}})}break;case`error`:{D.current.push(t);let e=[...D.current];i(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,events:e}]:[...n,{id:`error-${Date.now()}`,role:`system`,content:t.message,events:[t],timestamp:new Date().toISOString()}]});break}case`team_detected`:{let e=t.teamName;e&&(I.current.teamNames.add(e),q.get(`/api/teams/${encodeURIComponent(e)}`).then(e=>{if(e?.messages){let t=I.current.messages,n=e.messages.filter(e=>!t.some(t=>t.timestamp===e.timestamp&&t.from===e.from));t.push(...n),t.sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),t.length>500&&t.splice(0,t.length-500)}B()}).catch(()=>{}),B());break}case`team_inbox`:{let e=t.messages;if(Array.isArray(e)){let t=I.current.messages;t.push(...e),t.length>500&&t.splice(0,t.length-500),L.current+=e.length,B()}break}case`team_updated`:B();break;case`done`:{if(k.current===`idle`)break;t.contextWindowPct!=null&&g(t.contextWindowPct),N.current&&!mt(N.current)&&(ke.getState().addNotification(N.current,`done`,P.current),ft(`done`));let e=E.current,n=[...D.current],r=t.lastMessageUuid;i(t=>{let i=t[t.length-1];return i?.role===`assistant`?[...t.slice(0,-1),{...i,id:`final-${Date.now()}`,content:e||i.content,events:n.length>0?n:i.events,...r&&{sdkUuid:r}}]:t}),E.current=``,D.current=[],O.current=null,b(null);break}}},[re,H]),U=(0,Q.useCallback)(e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(t.type!==`ping`){if(t.type===`title_updated`){C(t.title??null);return}if(t.type===`compact_status`){let e=t.status;e===`compacting`?v(`compacting`):e===`done`&&(v(null),M.current?.());return}if(t.type===`phase_changed`){let e=t.phase;c(e),k.current=e,f(e===`connecting`?t.elapsed??0:0);return}if(t.type===`session_state`){T(!0);let e=t,n=e.phase;c(n),k.current=n,e.sessionTitle&&C(e.sessionTitle),e.pendingApproval&&m({requestId:e.pendingApproval.requestId,tool:e.pendingApproval.tool,input:e.pendingApproval.input}),n===`idle`&&(M.current?.(),u(!1));return}if(t.type===`turn_events`){let e=t.events;if(!e?.length){u(!1);return}i(e=>{let t=e.findLastIndex(e=>e.role===`user`);return t>=0?e.slice(0,t+1):e}),E.current=``,D.current=[],O.current=null;let n=0,r=()=>{let t=Math.min(n+100,e.length);for(let r=n;r<t;r++)ie(e[r]);n=t,n<e.length?requestAnimationFrame(r):u(!1)};requestAnimationFrame(r);return}ie(t)}},[ie]),{send:G,connect:oe}=it({url:e&&n?`/ws/project/${encodeURIComponent(n)}/chat/${e}`:``,onMessage:U,autoConnect:!!e&&!!n});j.current=G,(0,Q.useEffect)(()=>{let r=!1;return c(`idle`),k.current=`idle`,m(null),F.current!=null&&(x.dismiss(F.current),F.current=null),v(null),E.current=``,D.current=[],T(!1),I.current={teamNames:new Set,messages:[]},L.current=0,ee(pt),z([]),e&&n?(o(!0),fetch(`${K(n)}/chat/sessions/${e}/messages?providerId=${t}`,{headers:{Authorization:`Bearer ${ae()}`}}).then(e=>e.json()).then(e=>{r||k.current!==`idle`||(e.ok&&Array.isArray(e.data)&&e.data.length>0?i(e.data):i([]))}).catch(()=>{!r&&k.current===`idle`&&i([])}).finally(()=>{r||o(!1)})):i([]),()=>{r=!0}},[e,t,n]);let se=(0,Q.useCallback)((e,t)=>{if(!e.trim())return;let n=k.current!==`idle`;if(n){let e=E.current,t=[...D.current];i(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n})}i(t=>[...t,{id:`user-${Date.now()}`,role:`user`,content:e,timestamp:new Date().toISOString()}]),E.current=``,D.current=[],A.current=null,n?(c(`thinking`),k.current=`thinking`):(c(`initializing`),k.current=`initializing`),m(null),F.current!=null&&(x.dismiss(F.current),F.current=null),G(JSON.stringify({type:`message`,content:e,permissionMode:t?.permissionMode,priority:t?.priority,images:t?.images}))},[G]),ce=(0,Q.useCallback)((e,t,n)=>{if(G(JSON.stringify({type:`approval_response`,requestId:e,approved:t,data:n})),t&&n){let t=D.current.find(t=>t.type===`approval_request`&&t.requestId===e&&t.tool===`AskUserQuestion`);if(t){let e=t.input;e&&typeof e==`object`&&(e.answers=n)}i(e=>[...e])}m(null),F.current!=null&&(x.dismiss(F.current),F.current=null)},[G]),J=(0,Q.useCallback)(()=>{if(k.current===`idle`)return;G(JSON.stringify({type:`cancel`}));let e=E.current,t=[...D.current];i(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n}),E.current=``,D.current=[],A.current=null,c(`idle`),k.current=`idle`,m(null),F.current!=null&&(x.dismiss(F.current),F.current=null)},[G]),Y=(0,Q.useCallback)(()=>{T(!1),u(!0),oe()},[oe]),le=(0,Q.useCallback)(()=>{!e||!n||(o(!0),fetch(`${K(n)}/chat/sessions/${e}/messages?providerId=${t}`,{headers:{Authorization:`Bearer ${ae()}`}}).then(e=>e.json()).then(e=>{e.ok&&Array.isArray(e.data)&&e.data.length>0&&(i(e.data),E.current=``,D.current=[])}).catch(()=>{}).finally(()=>o(!1)))},[e,t,n]);return M.current=le,{messages:r,messagesLoading:a,isStreaming:V,phase:s,isReconnecting:l,connectingElapsed:d,pendingApproval:p,contextWindowPct:h,compactStatus:_,statusMessage:y,sessionTitle:S,teamActivity:R,teamMessages:te,markTeamRead:ne,sendMessage:se,respondToApproval:ce,cancelStreaming:J,reconnect:Y,refetchMessages:le,isConnected:w}}var gt=12e4;function _t(e,t=`claude`){let[n,r]=(0,Q.useState)({}),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(null),l=(0,Q.useCallback)((n=!1)=>{if(!e)return;a(!0);let i=n?`&refresh=1`:``;fetch(`${K(e)}/chat/usage?providerId=${t}${i}`,{headers:{Authorization:`Bearer ${ae()}`}}).then(e=>e.json()).then(e=>{e.ok&&e.data&&(r(t=>({...t,...e.data})),e.data.lastFetchedAt&&s(e.data.lastFetchedAt))}).catch(()=>{}).finally(()=>a(!1))},[e,t]);return(0,Q.useEffect)(()=>(l(),c.current=setInterval(()=>l(),gt),()=>{c.current&&clearInterval(c.current)}),[l]),{usageInfo:n,usageLoading:i,lastFetchedAt:o,refreshUsage:(0,Q.useCallback)(()=>l(!0),[l])}}var vt={damping:.7,stiffness:.05,mass:1.25},yt=70,bt=1e3/60,xt=350,St=!1;globalThis.document?.addEventListener(`mousedown`,()=>{St=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{St=!1}),globalThis.document?.addEventListener(`click`,()=>{St=!1});var Ct=(e={})=>{let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(e.initial!==!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);s.current=e;let c=(0,Q.useCallback)(()=>{if(!St)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),l=(0,Q.useCallback)(e=>{d.isAtBottom=e,i(e)},[]),u=(0,Q.useCallback)(e=>{d.escapedFromLock=e,n(e)},[]),d=(0,Q.useMemo)(()=>{let n;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(e){g.current&&(g.current.scrollTop=e,d.ignoreScrollToTop=g.current.scrollTop)},get targetScrollTop(){return!g.current||!_.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!_.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(n?.targetScrollTop===t)return n.calculatedScrollTop;let r=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:_.current}),t),0);return n={targetScrollTop:t,calculatedScrollTop:r},requestAnimationFrame(()=>{n=void 0}),r},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=yt}}},[]),f=(0,Q.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=Et(s.current,e.animation),{ignoreEscapes:r=!1}=e,i,a=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{i=Date.now()}):i=t+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:l}=d,u=performance.now(),p=(u-(d.lastTick??u))/bt;if(d.animation||={behavior:n,promise:e,ignoreEscapes:r},d.animation.behavior===n&&(d.lastTick=u),c()||t>Date.now())return o();if(l<Math.min(a,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if(n===`instant`)return d.scrollTop=d.calculatedTargetScrollTop,o();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*p,d.scrollTop+=d.accumulated,d.scrollTop!==l&&(d.accumulated=0)}return o()}return i>Date.now()?(a=d.calculatedTargetScrollTop,o()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:Et(s.current,s.current.resize),ignoreEscapes:r,duration:Math.max(0,i-Date.now())||void 0}):d.isAtBottom)});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return e.wait!==!0&&(d.animation=void 0),d.animation?.behavior===n?d.animation.promise:o()},[l,c,d]),p=(0,Q.useCallback)(()=>{u(!0),l(!1)},[u,l]),m=(0,Q.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:n}=d,{lastScrollTop:r=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,n&&n>t&&(r=n),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===n)return;if(c()){u(!0),l(!1);return}let e=t>r,i=t<r;if(d.animation?.ignoreEscapes){d.scrollTop=r;return}i&&(u(!0),l(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&l(!0)},1)},[u,l,c,d]),h=(0,Q.useCallback)(({target:e,deltaY:t})=>{let n=e;for(;![`scroll`,`auto`].includes(getComputedStyle(n).overflow);){if(!n.parentElement)return;n=n.parentElement}n===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,d]),g=wt(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=wt(e=>{if(d.resizeObserver?.disconnect(),!e)return;let t;d.resizeObserver=new ResizeObserver(([e])=>{let{height:n}=e.contentRect,r=n-(t??n);if(d.resizeDifference=r,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),r>=0){let e=Et(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:xt})}else d.isNearBottom&&(u(!1),l(!0));t=n,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===r&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e)},[]);return{contentRef:_,scrollRef:g,scrollToBottom:f,stopScroll:p,isAtBottom:r||a,isNearBottom:a,escapedFromLock:t,state:d}};function wt(e,t){let n=(0,Q.useCallback)(t=>(n.current=t,e(t)),t);return n}var Tt=new Map;function Et(...e){let t={...vt},n=!1;for(let r of e){if(r===`instant`){n=!0;continue}typeof r==`object`&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let r=JSON.stringify(t);return Tt.has(r)||Tt.set(r,Object.freeze(t)),n?`instant`:Tt.get(r)}var Dt=(0,Q.createContext)(null),Ot=typeof window<`u`?Q.useLayoutEffect:Q.useEffect;function kt({instance:e,children:t,resize:n,initial:r,mass:i,damping:a,stiffness:o,targetScrollTop:s,contextRef:c,...l}){let u=(0,Q.useRef)(null),d=Ct({mass:i,damping:a,stiffness:o,resize:n,initial:r,targetScrollTop:Q.useCallback((e,t)=>(y?.targetScrollTop??s)?.(e,t)??e,[s])}),{scrollRef:f,contentRef:p,scrollToBottom:m,stopScroll:h,isAtBottom:g,escapedFromLock:_,state:v}=e??d,y=(0,Q.useMemo)(()=>({scrollToBottom:m,stopScroll:h,scrollRef:f,isAtBottom:g,escapedFromLock:_,contentRef:p,state:v,get targetScrollTop(){return u.current},set targetScrollTop(e){u.current=e}}),[m,g,p,f,h,_,v]);return(0,Q.useImperativeHandle)(c,()=>y,[y]),Ot(()=>{f.current&&getComputedStyle(f.current).overflow===`visible`&&(f.current.style.overflow=`auto`)},[]),Q.createElement(Dt.Provider,{value:y},Q.createElement(`div`,{...l},typeof t==`function`?t(y):t))}(function(e){function t({children:e,scrollClassName:t,...n}){let r=At();return Q.createElement(`div`,{ref:r.scrollRef,style:{height:`100%`,width:`100%`,scrollbarGutter:`stable both-edges`},className:t},Q.createElement(`div`,{...n,ref:r.contentRef},typeof e==`function`?e(r):e))}e.Content=t})(kt||={});function At(){let e=(0,Q.useContext)(Dt);if(!e)throw Error(`use-stick-to-bottom component context must be used within a StickToBottom component`);return e}var $=t(),jt=(0,Q.lazy)(()=>V(()=>import(`./markdown-renderer-ocvtw_4F.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])));function Mt(e){let t=e.type===`approval_request`;return{toolName:e.type===`tool_use`?e.tool:t?e.tool??`Tool`:`Tool`,input:e.type===`tool_use`?e.input:t?e.input??{}:{}}}function Nt({tool:e,result:t,completed:n,projectName:r}){let[i,a]=(0,Q.useState)(!1);if(e.type===`error`)return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded bg-red-500/10 border border-red-500/20 px-2 py-1.5 text-xs text-red-400`,children:[(0,$.jsx)(be,{className:`size-3`}),(0,$.jsx)(`span`,{children:e.message})]});let{toolName:o,input:s}=Mt(e),c=t?.type===`tool_result`,l=c&&!!t.isError,u=o===`AskUserQuestion`&&!!s?.answers,d=(o===`Agent`||o===`Task`)&&e.type===`tool_use`,f=d?e.children:void 0,p=f&&f.length>0;return(0,$.jsxs)(`div`,{className:`rounded border text-xs ${d?`border-accent/30 bg-accent/5`:`border-border bg-background`}`,children:[(0,$.jsxs)(`button`,{onClick:()=>a(!i),className:`flex items-center gap-2 px-2 py-1.5 w-full text-left hover:bg-surface transition-colors min-w-0`,children:[i?(0,$.jsx)(w,{className:`size-3 shrink-0`}):(0,$.jsx)(E,{className:`size-3 shrink-0`}),l?(0,$.jsx)(ze,{className:`size-3 text-red-400 shrink-0`}):c||u||n?(0,$.jsx)(De,{className:`size-3 text-green-400 shrink-0`}):(0,$.jsx)(Z,{className:`size-3 text-yellow-400 shrink-0 animate-spin`}),(0,$.jsx)(`span`,{className:`truncate text-text-primary`,children:(0,$.jsx)(Pt,{name:o,input:s})}),p&&(0,$.jsxs)(`span`,{className:`ml-auto text-[10px] text-text-subtle shrink-0`,children:[f.length,` steps`]})]}),i&&(0,$.jsxs)(`div`,{className:`px-2 pb-2 space-y-1.5`,children:[(e.type===`tool_use`||e.type===`approval_request`)&&(0,$.jsx)(Ft,{name:o,input:s,projectName:r}),p&&(0,$.jsx)(zt,{events:f,projectName:r}),c&&(0,$.jsx)(Lt,{toolName:o,output:t.output})]})]})}function Pt({name:e,input:t}){let n=e=>String(e??``);switch(e){case`Read`:case`Write`:case`Edit`:case`MultiEdit`:case`NotebookEdit`:return(0,$.jsxs)($.Fragment,{children:[e,` `,(0,$.jsx)(`span`,{className:`text-text-subtle`,children:U(n(t.file_path))})]});case`Bash`:return(0,$.jsxs)($.Fragment,{children:[e,` `,(0,$.jsx)(`span`,{className:`font-mono text-text-subtle`,children:Vt(n(t.command),60)})]});case`Glob`:return(0,$.jsxs)($.Fragment,{children:[e,` `,(0,$.jsx)(`span`,{className:`font-mono text-text-subtle`,children:n(t.pattern)})]});case`Grep`:return(0,$.jsxs)($.Fragment,{children:[e,` `,(0,$.jsx)(`span`,{className:`font-mono text-text-subtle`,children:Vt(n(t.pattern),40)})]});case`WebSearch`:return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_e,{className:`size-3 inline`}),` `,e,` `,(0,$.jsx)(`span`,{className:`text-text-subtle`,children:Vt(n(t.query),50)})]});case`WebFetch`:return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(S,{className:`size-3 inline`}),` `,e,` `,(0,$.jsx)(`span`,{className:`text-text-subtle`,children:Vt(n(t.url),50)})]});case`ToolSearch`:return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_e,{className:`size-3 inline`}),` `,e,` `,(0,$.jsx)(`span`,{className:`text-text-subtle`,children:Vt(n(t.query),50)})]});case`Agent`:case`Task`:return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(f,{className:`size-3 inline`}),` `,e,` `,(0,$.jsx)(`span`,{className:`text-text-subtle`,children:Vt(n(t.description||t.prompt),60)})]});case`TodoWrite`:{let n=Array.isArray(t.todos)?t.todos:[],r=n.filter(e=>e.status===`completed`).length;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ke,{className:`size-3 inline`}),` `,e,` `,(0,$.jsxs)(`span`,{className:`text-text-subtle`,children:[r,`/`,n.length,` done`]})]})}case`AskUserQuestion`:{let n=Array.isArray(t.questions)?t.questions:[],r=!!t.answers;return(0,$.jsxs)($.Fragment,{children:[e,` `,(0,$.jsxs)(`span`,{className:`text-text-subtle`,children:[n.length,` question`,n.length===1?``:`s`,r?` ✓`:``]})]})}default:return(0,$.jsx)($.Fragment,{children:e})}}function Ft({name:e,input:t,projectName:n}){let r=e=>String(e??``),{openTab:i}=G(je(e=>({openTab:e.openTab}))),a=e=>{n&&i({type:`editor`,title:U(e),metadata:{filePath:e,projectName:n},projectId:n,closable:!0})},o=(e,t,r)=>{i({type:`git-diff`,title:`Diff ${U(e)}`,metadata:{filePath:e,projectName:n,original:t,modified:r},projectId:n??null,closable:!0})};switch(e){case`Bash`:return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[!!t.description&&(0,$.jsx)(`p`,{className:`text-text-subtle italic`,children:r(t.description)}),(0,$.jsx)(`pre`,{className:`font-mono text-text-secondary overflow-x-auto whitespace-pre-wrap break-all`,children:r(t.command)})]});case`Read`:case`Write`:case`Edit`:case`MultiEdit`:case`NotebookEdit`:{let n=r(t.file_path);return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`font-mono text-text-secondary break-all hover:text-primary hover:underline text-left flex items-center gap-1`,onClick:()=>a(n),title:`Open file in editor`,children:[(0,$.jsx)(we,{className:`size-3 shrink-0`}),n]}),e===`Edit`&&(!!t.old_string||!!t.new_string)&&(0,$.jsxs)(`button`,{type:`button`,className:`text-text-subtle hover:text-primary hover:underline text-left flex items-center gap-1`,onClick:()=>o(n,r(t.old_string),r(t.new_string)),title:`View diff in new tab`,children:[(0,$.jsx)(L,{className:`size-3 shrink-0`}),`View Diff`]}),e===`Write`&&!!t.content&&(0,$.jsx)(`pre`,{className:`font-mono text-text-subtle overflow-x-auto max-h-32 whitespace-pre-wrap`,children:Vt(r(t.content),300)})]})}case`Glob`:return(0,$.jsxs)(`p`,{className:`font-mono text-text-secondary`,children:[r(t.pattern),t.path?` in ${r(t.path)}`:``]});case`Grep`:return(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsxs)(`p`,{className:`font-mono text-text-secondary`,children:[`/`,r(t.pattern),`/`]}),!!t.path&&(0,$.jsxs)(`p`,{className:`text-text-subtle`,children:[`in `,r(t.path)]})]});case`TodoWrite`:return(0,$.jsx)(It,{todos:t.todos??[]});case`Agent`:case`Task`:return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[!!t.description&&(0,$.jsx)(`p`,{className:`text-text-secondary font-medium`,children:r(t.description)}),!!t.subagent_type&&(0,$.jsxs)(`p`,{className:`text-text-subtle`,children:[`Type: `,r(t.subagent_type)]}),!!t.prompt&&(0,$.jsx)(Bt,{content:r(t.prompt),maxHeight:`max-h-48`})]});case`ToolSearch`:return(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`font-mono text-text-secondary`,children:r(t.query)}),!!t.max_results&&(0,$.jsxs)(`p`,{className:`text-text-subtle`,children:[`Max results: `,r(t.max_results)]})]});case`WebFetch`:return(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsxs)(`a`,{href:r(t.url),target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-primary hover:underline break-all flex items-center gap-1`,children:[(0,$.jsx)(S,{className:`size-3 shrink-0`}),r(t.url)]}),!!t.prompt&&(0,$.jsx)(`p`,{className:`text-text-subtle`,children:Vt(r(t.prompt),100)})]});case`AskUserQuestion`:{let e=t.questions??[],n=t.answers??{};return(0,$.jsx)(`div`,{className:`space-y-2`,children:e.map((e,t)=>(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsxs)(`p`,{className:`text-text-primary font-medium`,children:[e.header?`${e.header}: `:``,e.question]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.options.map((t,r)=>(0,$.jsx)(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-xs border ${(n[e.question]??``).split(`, `).includes(t.label)?`border-accent bg-accent/20 text-text-primary`:`border-border text-text-subtle`}`,children:t.label},r))}),n[e.question]&&(0,$.jsxs)(`p`,{className:`text-foreground text-xs`,children:[`Answer: `,n[e.question]]})]},t))})}default:return(0,$.jsx)(`pre`,{className:`overflow-x-auto text-text-secondary font-mono whitespace-pre-wrap break-all`,children:JSON.stringify(t,null,2)})}}function It({todos:e}){return(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,$.jsx)(`span`,{className:`shrink-0 mt-0.5 ${e.status===`completed`?`text-green-400`:e.status===`in_progress`?`text-yellow-400`:`text-text-subtle`}`,children:e.status===`completed`?`✓`:e.status===`in_progress`?`▶`:`○`}),(0,$.jsx)(`span`,{className:e.status===`completed`?`line-through text-text-subtle`:`text-text-secondary`,children:e.content})]},t))})}function Lt({toolName:e,output:t}){let[n,r]=(0,Q.useState)(!1),i=(0,Q.useMemo)(()=>{if(e!==`Agent`&&e!==`Task`)return null;try{let e=JSON.parse(t);if(Array.isArray(e)){let t=e.filter(e=>e.type===`text`&&e.text).map(e=>e.text).join(`
|
|
3
|
+
|
|
4
|
+
`);if(t)return t}if(typeof e==`string`)return e}catch{if(t&&!t.startsWith(`[{`))return t}return null},[e,t]);return i?(0,$.jsxs)(`div`,{className:`border-t border-border pt-1.5 space-y-1`,children:[(0,$.jsx)(Bt,{content:i,maxHeight:`max-h-60`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),className:`flex items-center gap-1 text-[10px] text-text-subtle hover:text-text-secondary transition-colors`,children:[(0,$.jsx)(I,{className:`size-3`}),n?`Hide`:`Show`,` raw`]}),n&&(0,$.jsx)(`pre`,{className:`overflow-x-auto text-text-subtle font-mono max-h-40 whitespace-pre-wrap break-all text-[10px]`,children:t})]}):(0,$.jsx)(Rt,{output:t})}function Rt({output:e}){let t=e.split(`
|
|
5
|
+
`).length,n=t>3||e.length>200,[r,i]=(0,Q.useState)(n);return(0,$.jsxs)(`div`,{className:`border-t border-border pt-1.5`,children:[n&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),className:`flex items-center gap-1 text-[10px] text-text-subtle hover:text-text-secondary transition-colors mb-1`,children:[r?(0,$.jsx)(E,{className:`size-3`}):(0,$.jsx)(w,{className:`size-3`}),`Output (`,t,` lines)`]}),(0,$.jsx)(`pre`,{className:`overflow-x-auto text-text-subtle font-mono whitespace-pre-wrap break-all ${r?`max-h-16 overflow-hidden`:`max-h-60`}`,children:e})]})}function zt({events:e,projectName:t}){let n=[],r=``;for(let t of e)if(t.type===`text`)r+=t.content;else if(t.type===`tool_use`)r&&=(n.push({kind:`text`,content:r}),``),n.push({kind:`tool`,tool:t});else if(t.type===`tool_result`){let e=t.toolUseId,r=e?n.find(t=>t.kind===`tool`&&t.tool.type===`tool_use`&&t.tool.toolUseId===e&&!t.result):n.findLast(e=>e.kind===`tool`&&!e.result);r&&(r.result=t)}return r&&n.push({kind:`text`,content:r}),(0,$.jsx)(`div`,{className:`border-l-2 border-accent/20 pl-2 space-y-1 mt-1`,children:n.map((e,n)=>e.kind===`text`?(0,$.jsx)(`div`,{className:`text-text-secondary text-[11px]`,children:(0,$.jsx)(Bt,{content:e.content,maxHeight:`max-h-24`})},`st-${n}`):(0,$.jsx)(Nt,{tool:e.tool,result:e.result,completed:!!e.result,projectName:t},`sc-${n}`))})}function Bt({content:e,maxHeight:t=`max-h-48`}){return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded`}),children:(0,$.jsx)(jt,{content:e,className:`text-text-secondary overflow-auto ${t}`})})}function Vt(e,t=50){return e?e.length>t?e.slice(0,t)+`…`:e:``}var Ht=5,Ut=20;function Wt(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}catch{return``}}function Gt({projectName:e,onSelectSession:t}){let[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),c=(0,Q.useCallback)(async()=>{if(e){a(!0);try{r((await q.get(`${K(e)}/chat/sessions?limit=${Ut}`)).sessions.slice(0,Ut))}catch{}finally{a(!1)}}},[e]);(0,Q.useEffect)(()=>{c()},[c]);let l=(0,Q.useCallback)(async(t,n)=>{if(t.stopPropagation(),!e)return;let i=`${K(e)}/chat/sessions/${n.id}/pin`;try{n.pinned?await q.del(i):await q.put(i),r(e=>e.map(e=>e.id===n.id?{...e,pinned:!e.pinned}:e).sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()))}catch{}},[e]),u=n.filter(e=>e.pinned),d=n.filter(e=>!e.pinned),p=o?d:d.slice(0,Ht),m=d.length>Ht;function h(e){return(0,$.jsxs)(`button`,{onClick:()=>t(e),className:`group flex items-center gap-2.5 w-full px-3 py-2.5 text-left hover:bg-surface-elevated active:bg-surface-elevated transition-colors border-b border-border/50 last:border-0`,children:[(0,$.jsx)(Ne,{className:`size-3.5 shrink-0 text-text-subtle`}),(0,$.jsx)(`span`,{className:`flex-1 min-w-0 text-xs font-medium truncate text-text-primary`,children:e.title||`Untitled`}),e.updatedAt&&(0,$.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:Wt(e.updatedAt)}),(0,$.jsx)(`span`,{role:`button`,tabIndex:0,onClick:t=>l(t,e),className:`p-1 rounded transition-colors shrink-0 ${e.pinned?`text-primary hover:text-primary/70`:`text-text-subtle can-hover:opacity-0 can-hover:group-hover:opacity-100 hover:text-text-primary`}`,"aria-label":e.pinned?`Unpin session`:`Pin session`,children:e.pinned?(0,$.jsx)(ve,{className:`size-3`}):(0,$.jsx)(Ee,{className:`size-3`})})]},e.id)}return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-6 text-text-secondary overflow-y-auto`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,$.jsx)(f,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Send a message to start a new conversation`})]}),!i&&u.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 w-full max-w-sm px-4`,children:[(0,$.jsx)(`p`,{className:`text-xs text-text-subtle text-center`,children:`Pinned`}),(0,$.jsx)(`div`,{className:`w-full rounded-md border border-border bg-surface overflow-hidden`,children:u.map(h)})]}),!i&&p.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 w-full max-w-sm px-4`,children:[(0,$.jsx)(`p`,{className:`text-xs text-text-subtle text-center`,children:`Recent chats`}),(0,$.jsx)(`div`,{className:`w-full rounded-md border border-border bg-surface overflow-hidden`,children:p.map(h)}),m&&(0,$.jsxs)(`button`,{onClick:()=>s(!o),className:`flex items-center justify-center gap-1 text-[11px] text-text-subtle hover:text-text-primary transition-colors py-1`,children:[o?(0,$.jsx)(C,{className:`size-3`}):(0,$.jsx)(w,{className:`size-3`}),o?`Show less`:`Show more (${d.length-Ht})`]})]})]})}function Kt(e){let[t,n]=(0,Q.useState)({}),[r,i]=(0,Q.useState)({}),[a,o]=(0,Q.useState)(0),s=(0,Q.useCallback)((e,t)=>{n(n=>({...n,[e]:[t]})),i(t=>({...t,[e]:``}))},[]),c=(0,Q.useCallback)((e,t)=>{n(n=>{let r=n[e]||[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},[]),l=(0,Q.useCallback)((e,t)=>{i(n=>({...n,[e]:t})),t&&n(t=>({...t,[e]:[]}))},[]),u=(0,Q.useCallback)(e=>(t[e]?.length??0)>0||(r[e]?.trim().length??0)>0,[t,r]);return{answers:t,customInputs:r,activeTab:a,setActiveTab:o,handleSingleSelect:s,handleMultiSelect:c,handleCustomInput:l,hasAnswer:u,allAnswered:(0,Q.useMemo)(()=>e.every((e,t)=>u(t)),[e,u]),getFinalAnswer:(0,Q.useCallback)(e=>r[e]?.trim()||(t[e]??[]).join(`, `),[t,r]),goToNextTab:(0,Q.useCallback)(()=>o(t=>Math.min(t+1,e.length-1)),[e.length]),goToPrevTab:(0,Q.useCallback)(()=>o(e=>Math.max(e-1,0)),[])}}function qt(e){let[t,n]=(0,Q.useState)(0),r=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>n(0),[e.activeTab]),(0,Q.useEffect)(()=>{if(!e.enabled)return;let i=r=>{let i=document.activeElement===e.customInputRef.current;if(!i&&r.key>=`1`&&r.key<=`9`){r.preventDefault();let t=parseInt(r.key)-1;t<e.totalOptions-1&&(n(t),e.onSelectOption(t));return}if(!i&&(r.key===`o`||r.key===`O`||r.key===`0`)){r.preventDefault(),e.customInputRef.current?.focus(),n(e.totalOptions-1);return}if(r.key===`Tab`&&e.questions.length>1){r.preventDefault(),r.shiftKey?e.goToPrevTab():e.goToNextTab();return}if(!i){if(r.key===`ArrowLeft`){r.preventDefault(),e.goToPrevTab();return}if(r.key===`ArrowRight`){r.preventDefault(),e.goToNextTab();return}if(r.key===`ArrowUp`){r.preventDefault(),n(e=>Math.max(0,e-1));return}if(r.key===`ArrowDown`){r.preventDefault(),n(t=>Math.min(e.totalOptions-1,t+1));return}if(r.key===` `){r.preventDefault(),e.onSelectOption(t);return}}if(r.key===`Enter`){r.preventDefault(),e.allAnswered?e.onSubmit():e.hasAnswer(e.activeTab)&&e.goToNextTab();return}r.key===`Escape`&&i&&e.customInputRef.current?.blur()},a=r.current;return a&&(a.addEventListener(`keydown`,i),a.setAttribute(`tabindex`,`0`),a.contains(document.activeElement)||a.focus()),()=>{a?.removeEventListener(`keydown`,i)}},[e,t]),{focusedOption:t,setFocusedOption:n,containerRef:r}}function Jt({questions:e,onSubmit:t,onSkip:n}){let r=(0,Q.useRef)(null),i=Kt(e),a=e[i.activeTab],o=a?a.options.length+1:0,s=e.length>1,c=(0,Q.useCallback)(()=>{if(!i.allAnswered)return;let n={};e.forEach((e,t)=>{n[e.question]=i.getFinalAnswer(t)}),t(n)},[i.allAnswered,i.getFinalAnswer,e,t]),l=(0,Q.useCallback)(e=>{if(!(!a||e<0))if(e<a.options.length){let t=a.options[e]?.label;if(!t)return;a.multiSelect?i.handleMultiSelect(i.activeTab,t):i.handleSingleSelect(i.activeTab,t)}else e===a.options.length&&r.current?.focus()},[a,i]),u=qt({questions:e,activeTab:i.activeTab,totalOptions:o,allAnswered:i.allAnswered,hasAnswer:i.hasAnswer,onSelectOption:l,goToNextTab:i.goToNextTab,goToPrevTab:i.goToPrevTab,onSubmit:c,customInputRef:r,enabled:!0}),d=(0,Q.useCallback)(e=>{l(e),u.setFocusedOption(e)},[l,u.setFocusedOption]);return(0,$.jsxs)(`div`,{ref:u.containerRef,className:`rounded-lg border-2 border-primary/30 bg-primary/5 p-3 space-y-3 outline-none animate-in slide-in-from-bottom-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-sm font-medium text-text-primary`,children:[(0,$.jsxs)(`span`,{children:[`AI has `,s?`${e.length} questions`:`a question`]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-text-secondary font-normal`,children:[s?`←→ tabs · `:``,`↑↓ options · 1-`,Math.min(o-1,9),` select · Enter submit`]})]}),s&&(0,$.jsx)(`div`,{className:`flex gap-1 p-1 bg-background rounded-md overflow-x-auto border border-border`,children:e.map((e,t)=>(0,$.jsxs)(`button`,{className:`flex items-center gap-1.5 px-3 py-1.5 rounded text-xs whitespace-nowrap transition-all ${i.activeTab===t?`bg-primary text-primary-foreground`:i.hasAnswer(t)?`text-primary bg-transparent`:`text-text-secondary hover:bg-surface-elevated`}`,onClick:()=>{i.setActiveTab(t),u.setFocusedOption(0)},tabIndex:-1,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4 h-4 rounded-full text-[10px] font-semibold ${i.activeTab===t?`bg-white/20`:i.hasAnswer(t)?`bg-primary/20 text-primary`:`bg-surface-elevated text-text-secondary`}`,children:i.hasAnswer(t)?`✓`:t+1}),(0,$.jsx)(`span`,{className:`max-w-[100px] overflow-hidden text-ellipsis`,children:e.header||`Q${t+1}`})]},t))}),a&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[!s&&a.header&&(0,$.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-text-secondary`,children:a.header}),(0,$.jsx)(`div`,{className:`text-sm text-text-primary`,children:a.question}),a.multiSelect&&(0,$.jsx)(`div`,{className:`text-[11px] text-text-secondary`,children:`Select multiple`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a.options.map((e,t)=>{let n=(i.answers[i.activeTab]||[]).includes(e.label),r=u.focusedOption===t;return(0,$.jsxs)(`button`,{onClick:()=>d(t),className:`text-left flex items-start gap-2.5 rounded px-2.5 py-2 text-xs border transition-all ${n?`border-primary bg-primary/10 text-text-primary`:`border-border bg-background text-text-secondary hover:border-primary/40 hover:bg-primary/5`} ${r?`ring-2 ring-primary/40 ring-offset-1 ring-offset-background`:``}`,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4.5 h-4.5 rounded text-[10px] font-semibold shrink-0 mt-px ${n?`bg-primary/20 text-primary`:`bg-surface-elevated text-text-secondary`}`,children:t+1}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5 flex-1`,children:[(0,$.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.label}),e.description&&(0,$.jsx)(`span`,{className:`text-[11px] text-text-secondary`,children:e.description})]})]},t)}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded px-2.5 py-2 text-xs border border-dashed transition-all border-border bg-transparent ${u.focusedOption===o-1?`ring-2 ring-primary/40 ring-offset-1 ring-offset-background`:``}`,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4.5 h-4.5 rounded bg-surface-elevated text-text-secondary text-[10px] font-semibold shrink-0 mt-px`,children:`O`}),(0,$.jsx)(`input`,{ref:r,type:`text`,className:`flex-1 px-2 py-1 text-xs bg-surface border border-border rounded text-text-primary outline-none placeholder:text-text-subtle focus:border-primary`,placeholder:`Other (press O to type)...`,value:i.customInputs[i.activeTab]||``,onChange:e=>i.handleCustomInput(i.activeTab,e.target.value),onFocus:()=>u.setFocusedOption(o-1)})]})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 justify-end pt-1`,children:[s&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{className:`px-3 py-1.5 text-xs rounded border border-border bg-background text-text-primary hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,onClick:i.goToPrevTab,disabled:i.activeTab===0,tabIndex:-1,children:`← Prev`}),(0,$.jsx)(`button`,{className:`px-3 py-1.5 text-xs rounded border border-border bg-background text-text-primary hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,onClick:i.goToNextTab,disabled:i.activeTab===e.length-1,tabIndex:-1,children:`Next →`})]}),(0,$.jsx)(`button`,{onClick:n,className:`px-4 py-1.5 rounded border border-border bg-background text-text-secondary text-xs hover:bg-surface-elevated transition-colors`,tabIndex:-1,children:`Skip`}),(0,$.jsxs)(`button`,{onClick:c,disabled:!i.allAnswered,className:`px-4 py-1.5 rounded bg-primary text-primary-foreground text-xs font-medium hover:bg-primary/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,tabIndex:-1,children:[`Submit `,i.allAnswered?`✓`:`(${e.filter((e,t)=>i.hasAnswer(t)).length}/${e.length})`]})]})]})}var Yt=(0,Q.lazy)(()=>V(()=>import(`./markdown-renderer-ocvtw_4F.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])));function Xt({messages:e,messagesLoading:t,pendingApproval:n,onApprovalResponse:r,isStreaming:i,phase:a,onSelectSession:o,connectingElapsed:s,statusMessage:c,compactStatus:l,projectName:u,onFork:d}){let[p,m]=(0,Q.useState)(50),h=e[0]?.id;(0,Q.useEffect)(()=>{m(50)},[h]);let g=(0,Q.useMemo)(()=>e.filter(e=>{let t=e.content&&e.content.trim().length>0,n=e.events&&e.events.length>0;return e.role===`user`?t:t||n}),[e]),_=(0,Q.useMemo)(()=>{let e=Math.max(0,g.length-p);return g.slice(e)},[g,p]),v=p<g.length,y=(0,Q.useCallback)((e,t)=>{d?.(e,t)},[d]);return t?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,$.jsx)(f,{className:`size-10 text-text-subtle animate-pulse`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Loading messages...`})]}):e.length===0&&!i?(0,$.jsx)(Gt,{projectName:u||``,onSelectSession:o||(()=>{})}):(0,$.jsx)(`div`,{className:`relative flex-1 overflow-hidden flex flex-col min-h-0`,children:(0,$.jsxs)(kt,{className:`flex-1 overflow-y-auto overflow-x-hidden`,resize:`smooth`,initial:`instant`,children:[(0,$.jsxs)(kt.Content,{className:`p-4 space-y-4`,children:[v&&(0,$.jsxs)(`button`,{onClick:()=>m(e=>e+50),className:`w-full py-2 text-xs text-text-secondary hover:text-text-primary bg-surface-elevated/50 hover:bg-surface-elevated rounded-md border border-border/50 transition-colors`,children:[`Load `,Math.min(50,g.length-p),` more messages...`]}),_.map((e,t)=>{let n=g.length-_.length+t,r=n>0?g[n-1]:void 0;return(0,$.jsx)(Qt,{message:e,isStreaming:i&&e.id.startsWith(`streaming-`),projectName:u,onFork:e.role===`user`&&d?y:void 0,prevMsgId:r?.sdkUuid??r?.id},e.id)}),n&&(n.tool===`AskUserQuestion`?(0,$.jsx)(wn,{approval:n,onRespond:r}):(0,$.jsx)(Cn,{approval:n,onRespond:r})),i&&(0,$.jsx)(yn,{lastMessage:e[e.length-1],phase:a,elapsed:s,statusMessage:c}),!i&&l===`compacting`&&(0,$.jsx)(yn,{lastMessage:void 0,phase:`thinking`,elapsed:void 0,statusMessage:`Compacting messages...`})]}),(0,$.jsx)(Zt,{})]})})}function Zt(){let{isAtBottom:e,scrollToBottom:t}=At();return e?null:(0,$.jsxs)(`button`,{onClick:()=>t(),className:`absolute bottom-4 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-3 py-1 rounded-full bg-surface-elevated border border-border text-xs text-text-secondary hover:text-foreground shadow-lg transition-all`,children:[(0,$.jsx)(w,{className:`size-3`}),`Scroll to bottom`]})}var Qt=(0,Q.memo)(function({message:e,isStreaming:t,projectName:n,onFork:r,prevMsgId:i}){if(e.role===`user`){let t=r?()=>r(e.content,i):void 0;return(0,$.jsx)(sn,{content:e.content,projectName:n,onFork:t})}return e.role===`system`?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:[(0,$.jsx)(be,{className:`size-4 shrink-0`}),(0,$.jsx)(`p`,{children:e.content})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.events&&e.events.length>0?(0,$.jsx)(gn,{events:e.events,isStreaming:t,projectName:n}):e.content&&(0,$.jsx)(`div`,{className:`text-sm text-text-primary`,children:(0,$.jsx)(Sn,{content:e.content,projectName:n})}),e.accountLabel&&(0,$.jsxs)(`p`,{className:`text-[10px] select-none`,style:{color:`var(--color-text-subtle)`},children:[`via `,e.accountLabel]})]})}),$t=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`]),en={"system-reminder":`Context`,claudeMd:`CLAUDE.md`,gitStatus:`Git Status`,currentDate:`Date`,fast_mode_info:`Fast Mode`,"available-deferred-tools":`Tools`,"task-notification":`Task Result`,environment_details:`Environment`};function tn(e){let t=[],n=/<(system-reminder|available-deferred-tools|antml:[\w-]+|fast_mode_info|claudeMd|gitStatus|currentDate|task-notification|environment_details)[^>]*>([\s\S]*?)<\/\1>/g,r;for(;(r=n.exec(e))!==null;){let e=r[1];t.push({name:e,label:en[e]??e.replace(/^antml:/,``).replace(/-/g,` `),content:r[2].trim()})}return{cleanText:e.replace(n,``).trim(),tags:t}}function nn(e){let t=e.match(/^\[Attached file: (.+?)\]\n\n?/);if(t)return{files:[t[1]],text:e.slice(t[0].length)};let n=e.match(/^\[Attached files:\n([\s\S]+?)\]\n\n?/);return n?{files:n[1].split(`
|
|
6
|
+
`).map(e=>e.trim()).filter(Boolean),text:e.slice(n[0].length)}:{files:[],text:e}}function rn(e,t){let n=U(e);return`/api/project/${encodeURIComponent(t??`_`)}/chat/uploads/${encodeURIComponent(n)}`}function an(e){let t=e.lastIndexOf(`.`);return t===-1?!1:$t.has(e.slice(t).toLowerCase())}var on=new Set([`task-notification`,`environment_details`]);function sn({content:e,projectName:t,onFork:n}){let{files:r,text:i,tags:a}=(0,Q.useMemo)(()=>{let t=nn(e),{cleanText:n,tags:r}=tn(t.text);return{files:t.files,text:n,tags:r}},[e]),o=a.some(e=>on.has(e.name)),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{let e=f.current;if(!e)return;let t=()=>d(e.scrollHeight>e.clientHeight+2);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[i]),(0,$.jsxs)(`div`,{className:H(`group/user relative rounded-lg px-3 py-2 text-sm border shadow-sm`,o?`bg-surface/40 border-border/40 text-text-secondary`:`bg-primary/10 border-primary/15 text-text-primary`),children:[a.length>0&&(0,$.jsx)(cn,{tags:a}),r.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map((e,n)=>an(e)?(0,$.jsx)(hn,{filePath:e,projectName:t},n):(0,$.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/60 bg-background/40 px-1.5 py-0.5 text-[11px] text-text-secondary`,children:[(0,$.jsx)(ye,{className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-32`,children:U(e)})]},n))}),i&&(0,$.jsx)(`div`,{ref:f,className:H(`whitespace-pre-wrap break-words transition-all duration-200`,!c&&`line-clamp-2`,c&&`max-h-[50vh] overflow-y-auto`),children:o?(0,$.jsx)(pn,{text:i,projectName:t}):i}),(u||c)&&(0,$.jsx)(`button`,{onClick:()=>l(!c),className:H(`flex items-center gap-1 text-xs mt-1 transition-colors`,o?`text-text-subtle hover:text-text-secondary`:`text-primary/70 hover:text-primary`),children:c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(C,{className:`size-3`}),`Show less`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(w,{className:`size-3`}),`Show more`]})}),!o&&n&&(0,$.jsx)(`button`,{onClick:n,title:`Retry from this message (fork session)`,className:`absolute top-1.5 right-1.5 can-hover:opacity-0 can-hover:group-hover/user:opacity-100 transition-opacity size-5 flex items-center justify-center rounded text-text-subtle hover:text-text-primary`,children:(0,$.jsx)(s,{className:`size-3`})})]})}function cn({tags:e}){return(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map((e,t)=>(0,$.jsx)(ln,{tag:e},t))})}function ln({tag:e}){let[t,n]=(0,Q.useState)(!1);return e.name===`task-notification`?(0,$.jsx)(dn,{content:e.content}):(0,$.jsxs)(`div`,{className:`text-xs`,children:[(0,$.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-1 rounded-full border border-border/60 bg-surface/50 px-2 py-0.5 text-text-subtle hover:text-text-secondary hover:bg-surface transition-colors`,children:[(0,$.jsx)(tt,{className:`size-2.5`}),(0,$.jsx)(`span`,{children:e.label}),(0,$.jsx)(E,{className:H(`size-2.5 transition-transform`,t&&`rotate-90`)})]}),t&&(0,$.jsx)(`div`,{className:`mt-1 rounded border border-border/40 bg-surface/30 px-2 py-1.5 text-[11px] text-text-subtle/80 whitespace-pre-wrap max-h-40 overflow-y-auto leading-relaxed`,children:e.content})]})}function un(e,t){return e.match(RegExp(`<${t}>([\\s\\S]*?)</${t}>`))?.[1]?.trim()||void 0}function dn({content:e}){let[t,n]=(0,Q.useState)(!1),r=un(e,`status`),i=un(e,`summary`),a=un(e,`output-file`),o=un(e,`result`);return(0,$.jsxs)(`div`,{className:`text-xs`,children:[(0,$.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-1.5 rounded-full border border-border/60 bg-surface/50 px-2 py-0.5 text-text-subtle hover:text-text-secondary hover:bg-surface transition-colors`,children:[r===`completed`?(0,$.jsx)(De,{className:`size-2.5 text-green-500`}):(0,$.jsx)(ze,{className:`size-2.5 text-yellow-500`}),(0,$.jsx)(`span`,{className:`truncate max-w-80`,children:i??`Task notification`}),(0,$.jsx)(E,{className:H(`size-2.5 transition-transform shrink-0`,t&&`rotate-90`)})]}),t&&(0,$.jsxs)(`div`,{className:`mt-1 rounded border border-border/40 bg-surface/30 px-2 py-1.5 space-y-1.5`,children:[i&&(0,$.jsx)(`p`,{className:`text-[11px] text-text-secondary`,children:i}),a&&(0,$.jsx)(fn,{path:a}),o&&(0,$.jsx)(`div`,{className:`text-[11px] text-text-subtle/80 max-h-60 overflow-y-auto leading-relaxed`,children:(0,$.jsx)(Sn,{content:o})})]})]})}function fn({path:e,projectName:t}){return(0,$.jsxs)(`button`,{type:`button`,onClick:(0,Q.useCallback)(()=>{let n=G.getState().openTab,r=t??oe.getState().activeProject?.name,i=U(e),a={filePath:e};r&&(a.projectName=r),q.get(`/api/fs/read?path=${encodeURIComponent(e)}`).then(()=>{n({type:`editor`,title:i,metadata:a,projectId:null,closable:!0})}).catch(()=>{n({type:`editor`,title:i,metadata:a,projectId:null,closable:!0})})},[e,t]),className:`inline-flex items-center gap-1 rounded border border-border/50 bg-surface/50 px-1.5 py-0.5 font-mono text-[10px] text-text-secondary hover:text-text-primary hover:bg-surface transition-colors cursor-pointer`,children:[(0,$.jsx)(ye,{className:`size-2.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-60`,children:U(e)}),(0,$.jsx)(we,{className:`size-2 shrink-0 opacity-50`})]})}function pn({text:e,projectName:t}){return(0,$.jsx)($.Fragment,{children:(0,Q.useMemo)(()=>{let t=/(\/(?:[\w.\-]+\/)+[\w.\-]+)/g,n=[],r=0,i;for(;(i=t.exec(e))!==null;)i.index>r&&n.push({kind:`text`,value:e.slice(r,i.index)}),n.push({kind:`path`,value:i[1]}),r=i.index+i[0].length;return r<e.length&&n.push({kind:`text`,value:e.slice(r)}),n},[e]).map((e,n)=>e.kind===`path`?(0,$.jsx)(fn,{path:e.value,projectName:t},n):(0,$.jsx)(`span`,{children:e.value},n))})}function mn(e){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let t=!1,r,a=ae();return fetch(e,{headers:a?{Authorization:`Bearer ${a}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(e=>{t||(r=URL.createObjectURL(e),n(r))}).catch(()=>{t||i(!0)}),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),{blobUrl:t,error:r}}function hn({filePath:e,projectName:t}){let{blobUrl:n,error:r}=mn(rn(e,t)),i=Pe(e=>e.open),a=U(e);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n&&i(n,a),className:`flex items-center gap-1 rounded-md border border-border/60 bg-background/40 px-1.5 py-0.5 text-[11px] text-text-secondary hover:bg-surface transition-colors cursor-pointer`,children:[n?(0,$.jsx)(`img`,{src:n,alt:a,className:`size-4 rounded-sm object-cover shrink-0`}):r?(0,$.jsx)(We,{className:`size-3 shrink-0`}):(0,$.jsx)(`div`,{className:`size-4 rounded-sm bg-surface animate-pulse shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-32`,children:a})]})}function gn({events:e,isStreaming:t,projectName:n}){let r=[],i=``,a=``;for(let t=0;t<e.length;t++){let n=e[t];if(n.type===`thinking`){i&&=(r.push({kind:`text`,content:i}),``),a+=n.content;continue}if(a&&=(r.push({kind:`thinking`,content:a}),``),n.type===`account_retry`){i&&=(r.push({kind:`text`,content:i}),``);let e=n.accountLabel??`another account`,t=n.reason??`Auth failed`;r.push({kind:`text`,content:`\n\n> ↻ ${t} — retrying with **${e}**...\n\n`});continue}n.type===`text`?i+=n.content:n.type===`tool_use`?(i&&=(r.push({kind:`text`,content:i}),``),r.push({kind:`tool`,tool:n})):n.type===`tool_result`||(i&&=(r.push({kind:`text`,content:i}),``),r.push({kind:`tool`,tool:n}))}a&&r.push({kind:`thinking`,content:a}),i&&r.push({kind:`text`,content:i});let o=e.filter(e=>e.type===`tool_result`);for(let e of o){let t=e.toolUseId;if(t){let n=r.find(e=>e.kind===`tool`&&e.tool.type===`tool_use`&&e.tool.toolUseId===t);if(n){n.result=e;continue}}let n=r.find(e=>e.kind===`tool`&&!e.result);n&&(n.result=e)}for(let e of r)if(e.kind===`tool`&&!e.result&&e.tool.type===`tool_use`){let t=e.tool.result;t&&(e.result={type:`tool_result`,output:t.output,isError:t.isError})}for(let e=0;e<r.length;e++){let n=r[e];if(n.kind===`tool`&&!n.result){let i=!1;if(n.tool.type===`tool_use`&&n.tool.tool===`Read`){let t=n.tool.input?.file_path;t&&(i=r.slice(e+1).some(e=>e.kind===`tool`&&e.result&&e.tool.type===`tool_use`&&e.tool.tool===`Edit`&&e.tool.input?.file_path===t))}n.completed=i||!t}}return(0,$.jsx)($.Fragment,{children:r.map((e,i)=>{if(e.kind===`thinking`)return(0,$.jsx)(_n,{content:e.content,isStreaming:t&&i===r.length-1},`think-${i}`);if(e.kind===`text`){let a=t&&i===r.length-1;return(0,$.jsx)(`div`,{className:`text-sm text-text-primary`,children:(0,$.jsx)(vn,{content:e.content,animate:a,projectName:n})},`text-${i}`)}return(0,$.jsx)(Nt,{tool:e.tool,result:e.result,completed:e.completed,projectName:n},`tool-${i}`)})})}function _n({content:e,isStreaming:t}){let[n,r]=(0,Q.useState)(t),i=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{!t&&e.length>0&&r(!1)},[t,e.length]),(0,Q.useEffect)(()=>{t&&n&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e,t,n]),(0,$.jsxs)(`div`,{className:`rounded border border-border/50 bg-surface/30 text-xs`,children:[(0,$.jsxs)(`button`,{onClick:()=>r(!n),className:`flex items-center gap-2 px-2 py-1.5 w-full text-left hover:bg-surface transition-colors text-text-subtle`,children:[t?(0,$.jsx)(Z,{className:`size-3 animate-spin`}):(0,$.jsx)(E,{className:`size-3 transition-transform ${n?`rotate-90`:``}`}),(0,$.jsxs)(`span`,{children:[`Thinking`,t?`...`:``]}),!t&&(0,$.jsx)(`span`,{className:`text-text-subtle/50 ml-auto`,children:e.length>100?`${Math.round(e.length/4)} tokens`:``})]}),n&&(0,$.jsx)(`div`,{ref:i,className:`max-h-60 overflow-y-auto`,children:(0,$.jsx)(`div`,{className:`px-2 pb-2 text-text-subtle/80 whitespace-pre-wrap text-[11px] leading-relaxed`,children:e})})]})}function vn({content:e,animate:t,projectName:n}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Sn,{content:e,projectName:n,isStreaming:t}),t&&(0,$.jsx)(`span`,{className:`text-text-subtle text-sm animate-pulse`,children:`Thinking...`})]})}function yn({lastMessage:e,phase:t,elapsed:n,statusMessage:r}){let i=!e||e.role!==`assistant`,a=e?.events?.length?e.events[e.events.length-1].type===`tool_result`:!1;return!r&&!i&&!a?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-text-subtle`,children:[(0,$.jsx)(Z,{className:`size-3 animate-spin`}),(0,$.jsxs)(`span`,{children:[r||(t===`initializing`?`Initializing`:t===`connecting`?`Connecting`:t===`thinking`?`Thinking`:`Processing`),i&&(n??0)>0&&(0,$.jsxs)(`span`,{className:`text-text-subtle/60`,children:[`... (`,n,`s)`]})]})]}),t===`connecting`&&(n??0)>=30&&(0,$.jsx)(`p`,{className:`text-xs text-yellow-500/80 ml-5`,children:`Taking longer than usual — may be rate-limited or API slow. Try sending a new message to retry.`})]})}var bn=/<teammate-message[^>]*>[\s\S]*?<\/teammate-message>/g;function xn(e){return e.replace(bn,``).replace(/\n{3,}/g,`
|
|
7
|
+
|
|
8
|
+
`).trim()}function Sn({content:e,projectName:t,isStreaming:n}){let r=xn(e);return r?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded`}),children:(0,$.jsx)(Yt,{content:r,projectName:t,codeActions:!0,isStreaming:n})}):null}function Cn({approval:e,onRespond:t}){return(0,$.jsxs)(`div`,{className:`rounded-lg border-2 border-yellow-500/40 bg-yellow-500/10 p-3 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-yellow-400 text-sm font-medium`,children:[(0,$.jsx)(Qe,{className:`size-4`}),(0,$.jsx)(`span`,{children:`Tool Approval Required`})]}),(0,$.jsx)(`div`,{className:`text-xs text-text-primary`,children:(0,$.jsx)(`span`,{className:`font-medium`,children:e.tool})}),(0,$.jsx)(`pre`,{className:`text-xs font-mono text-text-secondary overflow-x-auto bg-background rounded p-2 border border-border`,children:JSON.stringify(e.input,null,2)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`button`,{onClick:()=>t(e.requestId,!0),className:`px-4 py-1.5 rounded bg-green-600 text-white text-xs font-medium hover:bg-green-500 transition-colors`,children:`Allow`}),(0,$.jsx)(`button`,{onClick:()=>t(e.requestId,!1),className:`px-4 py-1.5 rounded bg-red-600 text-white text-xs font-medium hover:bg-red-500 transition-colors`,children:`Deny`})]})]})}function wn({approval:e,onRespond:t}){return(0,$.jsx)(Jt,{questions:e.input.questions??[],onSubmit:n=>t(e.requestId,!0,n),onSkip:()=>t(e.requestId,!1)})}function Tn(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function En(e){let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),a=(0,Q.useRef)(null),o=(0,Q.useRef)(``),s=typeof window<`u`&&Tn()!==null;return{isListening:t,interimText:r,start:(0,Q.useCallback)(t=>{let r=Tn();if(!r)return;a.current?.abort();let s=new r;s.lang=e?.lang??`vi-VN`,s.continuous=!0,s.interimResults=!0,o.current=``,s.onresult=e=>{let n=``,r=``;for(let t=0;t<e.results.length;t++){let i=e.results[t];i.isFinal?r+=i[0].transcript:n+=i[0].transcript}r&&(o.current=r);let a=(o.current+` `+n).trim();i(n),t(a,n.length===0&&o.current.length>0)},s.onend=()=>{n(!1),i(``),o.current&&t(o.current.trim(),!0)},s.onerror=e=>{e.error!==`no-speech`&&e.error!==`aborted`&&console.warn(`[voice-input] error:`,e.error),n(!1),i(``)},a.current=s,s.start(),n(!0)},[e?.lang]),stop:(0,Q.useCallback)(()=>{a.current?.stop(),a.current=null,n(!1),i(``)},[]),supported:s}}var Dn=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]),On=new Set([`application/pdf`]),kn=[`text/`,`application/json`,`application/xml`,`application/javascript`,`application/typescript`,`application/x-yaml`,`application/toml`,`application/x-sh`],An=new Set(`.ts,.tsx,.js,.jsx,.mjs,.cjs,.py,.rb,.go,.rs,.java,.kt,.swift,.c,.cpp,.h,.hpp,.cs,.json,.yaml,.yml,.toml,.xml,.md,.mdx,.txt,.csv,.tsv,.html,.css,.scss,.less,.sass,.sh,.bash,.zsh,.fish,.sql,.graphql,.gql,.env,.ini,.cfg,.conf,.dockerfile,.makefile,.vue,.svelte,.astro,.ipynb`.split(`,`));function jn(e){return Dn.has(e.type)}function Mn(e){if(Dn.has(e.type)||On.has(e.type)||kn.some(t=>e.type.startsWith(t)))return!0;let t=Nn(e.name);return!!(t&&An.has(t))}function Nn(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t).toLowerCase()}function Pn({attachments:e,onRemove:t}){return e.length===0?null:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-2 md:px-4 pt-2`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-surface px-2 py-1 text-xs text-text-secondary max-w-48`,children:[e.previewUrl?(0,$.jsx)(`img`,{src:e.previewUrl,alt:e.name,className:`size-5 rounded object-cover shrink-0`}):e.isImage?(0,$.jsx)(We,{className:`size-3.5 shrink-0 text-text-subtle`}):(0,$.jsx)(ye,{className:`size-3.5 shrink-0 text-text-subtle`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name}),e.status===`uploading`?(0,$.jsx)(Z,{className:`size-3 shrink-0 animate-spin text-text-subtle`}):e.status===`error`?(0,$.jsx)(`span`,{className:`text-red-500 shrink-0`,title:`Upload failed`,children:`!`}):null,(0,$.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),className:`shrink-0 rounded-sm p-0.5 hover:bg-border/50 transition-colors`,"aria-label":`Remove ${e.name}`,children:(0,$.jsx)(te,{className:`size-3`})})]},e.id))})}var Fn=[{id:`default`,label:`Ask before edits`,icon:He,description:`Claude will ask for approval before making each edit`},{id:`acceptEdits`,label:`Edit automatically`,icon:I,description:`Claude will edit files without asking first`},{id:`plan`,label:`Plan mode`,icon:Ve,description:`Claude will present a plan before editing`},{id:`bypassPermissions`,label:`Bypass permissions`,icon:$e,description:`Claude will not ask before running commands`}];function In(e){return Fn.find(t=>t.id===e)?.label??`Unknown`}function Ln(e){return Fn.find(t=>t.id===e)?.icon??He}function Rn({value:e,onChange:t,open:n,onOpenChange:r}){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&!i.current.contains(e.target)&&r(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n,r]),(0,Q.useEffect)(()=>{n&&(a.current=Fn.findIndex(t=>t.id===e),a.current<0&&(a.current=0))},[n,e]);let o=(0,Q.useCallback)(e=>{if(e.key===`Escape`){r(!1);return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;a.current=(a.current+t+Fn.length)%Fn.length,(i.current?.querySelector(`[data-idx="${a.current}"]`))?.focus()}if(e.key===`Enter`){e.preventDefault();let n=Fn[a.current];n&&(t(n.id),r(!1))}},[t,r]);return n?(0,$.jsxs)(`div`,{ref:i,role:`listbox`,"aria-label":`Permission modes`,onKeyDown:o,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`absolute bottom-full left-0 mb-1 z-50 w-72 md:w-80 rounded-lg border border-border bg-surface shadow-lg`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-text-secondary`,children:`Modes`}),(0,$.jsx)(`kbd`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-surface-elevated text-text-subtle border border-border`,children:`Shift + Tab`})]}),(0,$.jsx)(`div`,{className:`py-1`,children:Fn.map((n,i)=>{let a=n.icon,o=n.id===e;return(0,$.jsxs)(`button`,{"data-idx":i,role:`option`,"aria-selected":o,tabIndex:0,onClick:()=>{t(n.id),r(!1)},className:`w-full flex items-start gap-3 px-3 py-2.5 text-left transition-colors hover:bg-surface-elevated focus:bg-surface-elevated focus:outline-none ${o?`bg-surface-elevated`:``}`,children:[(0,$.jsx)(a,{className:`size-4 mt-0.5 shrink-0 text-text-secondary`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-text-primary`,children:n.label}),(0,$.jsx)(`div`,{className:`text-xs text-text-subtle leading-snug`,children:n.description})]}),o&&(0,$.jsx)(b,{className:`size-4 mt-0.5 shrink-0 text-primary`})]},n.id)})})]}):null}function zn(e){let t=[];function n(e){for(let r of e)t.push(r),r.children&&n(r.children)}return n(e),t}function Bn({items:e,filter:t,onSelect:n,onClose:r,visible:i}){let[a,o]=(0,Q.useState)(0),s=(0,Q.useRef)(null),c=(()=>{if(!t)return e.slice(0,50);let n=t.toLowerCase();return e.filter(e=>e.path.toLowerCase().includes(n)||e.name.toLowerCase().includes(n)).slice(0,50)})();(0,Q.useEffect)(()=>{o(0)},[t]),(0,Q.useEffect)(()=>{let e=s.current;e&&e.children[a]?.scrollIntoView({block:`nearest`})},[a]);let l=(0,Q.useCallback)(e=>{if(!i||c.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),o(e=>e>0?e-1:c.length-1),!0;case`ArrowDown`:return e.preventDefault(),o(e=>e<c.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),c[a]&&n(c[a]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[i,c,a,n,r]);return(0,Q.useEffect)(()=>{if(!i)return;let e=e=>{l(e)&&e.stopPropagation()};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i,l]),!i||c.length===0?null:(0,$.jsx)(`div`,{className:`max-h-52 overflow-y-auto border-b border-border bg-surface`,children:(0,$.jsx)(`div`,{ref:s,className:`py-1`,children:c.map((e,t)=>(0,$.jsxs)(`button`,{className:`flex items-center gap-2 w-full px-3 py-1.5 text-left transition-colors ${t===a?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>o(t),onClick:()=>n(e),children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:e.type===`directory`?(0,$.jsx)(xe,{className:`size-4 text-amber-500`}):(0,$.jsx)(Se,{className:`size-4 text-blue-400`})}),(0,$.jsx)(`span`,{className:`text-sm truncate`,children:e.path})]},e.path))})})}var Vn=(0,Q.memo)(function({onSend:e,isStreaming:t,onCancel:n,disabled:r,projectName:a,onSlashStateChange:o,onSlashItemsLoaded:s,slashSelected:c,onFileStateChange:l,onFileItemsLoaded:u,fileSelected:d,externalFiles:f,initialValue:p,autoFocus:m,permissionMode:h,onModeChange:_,providerId:v,onProviderChange:y}){let[b,x]=(0,Q.useState)(p??``),[S,C]=(0,Q.useState)([]),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(`next`),A=(0,Q.useRef)(null),j=(0,Q.useRef)(null),M=(0,Q.useRef)(null),N=(0,Q.useRef)([]),P=(0,Q.useRef)(!1),F=(0,Q.useRef)(void 0),I=(0,Q.useRef)(0),L=(0,Q.useRef)([]),R=En(),ee=(0,Q.useRef)(``),te=(0,Q.useCallback)(e=>{let t=ee.current;x(t?t+` `+e:e),requestAnimationFrame(()=>{let e=window.matchMedia(`(min-width: 768px)`).matches?A.current:j.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,160)+`px`)})},[]),z=(0,Q.useCallback)(()=>{R.isListening?R.stop():(ee.current=b.trim(),R.start(te))},[R.isListening,R.start,R.stop,b,te]);(0,Q.useEffect)(()=>{let e=()=>{R.supported&&z()};return window.addEventListener(`toggle-voice-input`,e),()=>window.removeEventListener(`toggle-voice-input`,e)},[R.supported,z]),(0,Q.useEffect)(()=>{p&&(x(p),setTimeout(()=>{let e=A.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)},50))},[p]),(0,Q.useEffect)(()=>{m&&setTimeout(()=>{(window.matchMedia(`(min-width: 768px)`).matches?A.current:j.current)?.focus()},100)},[]),(0,Q.useEffect)(()=>{if(!a){N.current=[],s?.([],!1);return}q.get(`${K(a)}/chat/slash-items`).then(e=>{N.current=e,P.current=!1,s?.(e,!1)}).catch(()=>{N.current=[],s?.([],!1)})},[a]),(0,Q.useEffect)(()=>()=>{F.current&&clearTimeout(F.current)},[]),(0,Q.useEffect)(()=>{if(!a){L.current=[],u?.([]);return}q.get(`${K(a)}/files/tree?depth=5`).then(e=>{let t=zn(e);L.current=t,u?.(t)}).catch(()=>{L.current=[],u?.([])})},[a]),(0,Q.useEffect)(()=>{if(!c)return;let e=A.current,t=e?.selectionStart??b.length,n=b.slice(0,t),r=b.slice(t),i=n.replace(/(?:^|\s)\/\S*$/,e=>`${e.startsWith(`/`)?``:e[0]}/${c.name} `);x(i+r),o?.(!1,``),l?.(!1,``),e&&(e.focus(),setTimeout(()=>{e.selectionStart=e.selectionEnd=i.length},0))},[c]),(0,Q.useEffect)(()=>{if(!d)return;let e=A.current;if(!e)return;let t=e.selectionStart,n=b.slice(0,t),r=b.slice(t),i=n.match(/@(\S*)$/);if(i){let t=n.length-i[0].length;x(n.slice(0,t)+`@${d.path} `+r);let a=t+d.path.length+2;setTimeout(()=>{e.selectionStart=e.selectionEnd=a,e.focus()},0)}else{let t=b+`@${d.path} `;x(t),setTimeout(()=>{e.selectionStart=e.selectionEnd=t.length,e.focus()},0)}l?.(!1,``)},[d]),(0,Q.useEffect)(()=>{!f||f.length===0||V(f)},[f]);let ne=(0,Q.useCallback)(async e=>{if(!a)return null;try{let t=new FormData;t.append(`files`,e);let n={},r=ae();r&&(n.Authorization=`Bearer ${r}`);let i=await(await fetch(`${K(a)}/chat/upload`,{method:`POST`,headers:n,body:t})).json();return i.ok&&Array.isArray(i.data)&&i.data.length>0?i.data[0].path:null}catch{return null}},[a]),V=(0,Q.useCallback)(e=>{for(let t of e){if(!Mn(t)){x(e=>e+(e.length>0&&!e.endsWith(` `)?` `:``)+t.name);continue}let e=ie(),n=jn(t),r=n?URL.createObjectURL(t):void 0,i={id:e,name:t.name,file:t,isImage:n,previewUrl:r,status:`uploading`};C(e=>[...e,i]),ne(t).then(t=>{C(n=>n.map(n=>n.id===e?{...n,serverPath:t??void 0,status:t?`ready`:`error`}:n))})}(j.current??A.current)?.focus()},[ne]),re=(0,Q.useCallback)(e=>{C(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),H=(0,Q.useCallback)(()=>{let n=b.trim(),r=S.filter(e=>e.status===`ready`);if(!n&&r.length===0){D(!1);return}o?.(!1,``),l?.(!1,``),R.isListening&&R.stop(),e(n,r,t?O:void 0),x(``);for(let e of S)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);C([]),D(!1),k(`next`),A.current&&(A.current.style.height=`auto`),j.current&&(j.current.style.height=`auto`)},[b,S,e,o,l,t,O]),U=(0,Q.useCallback)(()=>{if(!r){if(S.some(e=>e.status===`uploading`)){(b.trim()||S.some(e=>e.status!==`error`))&&D(!0);return}H()}},[b,S,r,H]);(0,Q.useEffect)(()=>{E&&(S.some(e=>e.status===`uploading`)||H())},[E,S,H]);let W=(0,Q.useCallback)(e=>{if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),U();return}if(e.shiftKey&&e.key===`Tab`){e.preventDefault();let t=[`default`,`acceptEdits`,`plan`,`bypassPermissions`],n=t[(t.indexOf(h??`bypassPermissions`)+1)%t.length];_?.(n)}},[U,h,_]),G=(0,Q.useCallback)(e=>{if(F.current&&clearTimeout(F.current),!a||!e)return;let t=++I.current;F.current=setTimeout(()=>{q.get(`${K(a)}/chat/slash-items?q=${encodeURIComponent(e)}`).then(e=>{t===I.current&&(N.current=e,P.current=!0,s?.(e,!0))}).catch(()=>{t===I.current&&(P.current=!1)})},150)},[a,s]),oe=(0,Q.useCallback)((e,t)=>{let n=e.slice(0,t),r=n.match(/(?:^|\s)\/(\S*)$/);if(r&&N.current.length>0){let e=r[1]??``;o?.(!0,e),l?.(!1,``),e&&G(e);return}F.current&&clearTimeout(F.current),P.current&&=!1;let i=n.match(/@(\S*)$/);if(i&&L.current.length>0){l?.(!0,i[1]??``),o?.(!1,``);return}o?.(!1,``),l?.(!1,``)},[o,l,G]),se=(0,Q.useCallback)((e,t)=>{x(e),oe(e,t)},[oe]),ce=(0,Q.useCallback)(e=>{let t=e?.target??A.current;t&&(t.style.height=`auto`,t.style.height=Math.min(t.scrollHeight,160)+`px`)},[]),J=(0,Q.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),V(n))},[V]),Y=(0,Q.useCallback)(e=>{e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length>0&&V(t)},[V]),le=(0,Q.useCallback)(e=>{e.preventDefault()},[]),ue=(0,Q.useCallback)(()=>{M.current?.click()},[]),de=(0,Q.useCallback)(e=>{let t=Array.from(e.target.files??[]);t.length>0&&V(t),e.target.value=``},[V]),X=b.trim().length>0||S.some(e=>e.status!==`error`),fe=t&&!X;return(0,$.jsxs)(`div`,{className:`p-2 md:p-3 bg-background`,children:[(0,$.jsxs)(`div`,{className:`border border-border rounded-xl md:rounded-2xl bg-surface shadow-sm cursor-text`,onClick:e=>{r||e.target instanceof HTMLTextAreaElement||(window.matchMedia(`(min-width: 768px)`).matches?A.current:j.current)?.focus()},children:[(0,$.jsx)(Pn,{attachments:S,onRemove:re}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pt-2 md:hidden relative`,children:[(0,$.jsx)(Hn,{mode:h??`bypassPermissions`,onClick:()=>T(e=>!e)}),(0,$.jsx)(Rn,{value:h??`bypassPermissions`,onChange:e=>_?.(e),open:w,onOpenChange:T}),y&&a&&(0,$.jsx)(g,{value:v??`claude`,onChange:y,projectName:a}),t&&(0,$.jsx)(Wn,{value:O,onChange:k})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-1 md:hidden px-2 py-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ue()},disabled:r,className:`flex items-center justify-center size-7 shrink-0 rounded-full text-text-subtle hover:text-text-primary transition-colors disabled:opacity-50`,"aria-label":`Attach file`,children:(0,$.jsx)(Xe,{className:`size-4`})}),(0,$.jsx)(`textarea`,{ref:j,value:b,onChange:e=>{se(e.target.value,e.target.selectionStart),ce(e)},onKeyDown:W,onPaste:J,onDrop:Y,onDragOver:le,placeholder:t?`Follow-up...`:`Ask anything...`,disabled:r,rows:1,className:`flex-1 resize-none bg-transparent py-1.5 text-sm text-foreground placeholder:text-text-subtle focus:outline-none disabled:opacity-50 max-h-20`}),R.supported&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),z()},disabled:r,className:`flex items-center justify-center size-7 shrink-0 rounded-full transition-colors disabled:opacity-50 ${R.isListening?`bg-red-600 text-white animate-pulse`:`text-text-subtle hover:text-text-primary`}`,"aria-label":R.isListening?`Stop voice input`:`Start voice input`,children:R.isListening?(0,$.jsx)(Je,{className:`size-4`}):(0,$.jsx)(Ce,{className:`size-4`})}),fe?(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n?.()},className:`flex items-center justify-center size-7 shrink-0 rounded-full bg-red-600 text-white hover:bg-red-500 transition-colors`,"aria-label":`Stop`,children:(0,$.jsx)(B,{className:`size-3`})}):(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),E?D(!1):U()},disabled:r||!X,className:`flex items-center justify-center size-7 shrink-0 rounded-full bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-30 transition-colors`,"aria-label":E?`Cancel queued send`:`Send`,children:E?(0,$.jsx)(Z,{className:`size-3.5 animate-spin`}):(0,$.jsx)(i,{className:`size-3.5`})})]}),(0,$.jsxs)(`div`,{className:`hidden md:block`,children:[(0,$.jsx)(`textarea`,{ref:A,value:b,onChange:e=>{se(e.target.value,e.target.selectionStart),ce(e)},onKeyDown:W,onPaste:J,onDrop:Y,onDragOver:le,placeholder:t?`Follow-up or Stop...`:`Ask anything...`,disabled:r,rows:1,className:`w-full resize-none bg-transparent px-4 pt-3 pb-1 text-sm text-foreground placeholder:text-text-subtle focus:outline-none disabled:opacity-50 max-h-40`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ue()},disabled:r,className:`flex items-center justify-center size-8 rounded-full text-text-subtle hover:text-text-primary hover:bg-surface-elevated transition-colors disabled:opacity-50`,"aria-label":`Attach file`,children:(0,$.jsx)(Xe,{className:`size-4`})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Hn,{mode:h??`bypassPermissions`,onClick:()=>T(e=>!e)}),(0,$.jsx)(Rn,{value:h??`bypassPermissions`,onChange:e=>_?.(e),open:w,onOpenChange:T})]}),y&&a&&(0,$.jsx)(g,{value:v??`claude`,onChange:y,projectName:a}),t&&(0,$.jsx)(Wn,{value:O,onChange:k})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[R.supported&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),z()},disabled:r,className:`flex items-center justify-center size-8 rounded-full transition-colors disabled:opacity-50 ${R.isListening?`bg-red-600 text-white animate-pulse`:`text-text-subtle hover:text-text-primary hover:bg-surface-elevated`}`,"aria-label":R.isListening?`Stop voice input`:`Start voice input`,children:R.isListening?(0,$.jsx)(Je,{className:`size-4`}):(0,$.jsx)(Ce,{className:`size-4`})}),fe?(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n?.()},className:`flex items-center justify-center size-8 rounded-full bg-red-600 text-white hover:bg-red-500 transition-colors`,"aria-label":`Stop response`,children:(0,$.jsx)(B,{className:`size-3.5`})}):(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),E?D(!1):U()},disabled:r||!X,className:`flex items-center justify-center size-8 rounded-full bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,"aria-label":E?`Cancel queued send`:`Send message`,children:E?(0,$.jsx)(Z,{className:`size-4 animate-spin`}):(0,$.jsx)(i,{className:`size-4`})})]})]})]})]}),(0,$.jsx)(`input`,{ref:M,type:`file`,multiple:!0,className:`hidden`,onChange:de})]})});function Hn({mode:e,onClick:t}){let n=Ln(e),r=In(e);return(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t()},className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-[11px] text-text-subtle hover:text-text-primary hover:bg-surface-elevated transition-colors border border-transparent hover:border-border`,"aria-label":`Permission mode: ${r}`,children:[(0,$.jsx)(n,{className:`size-3`}),(0,$.jsx)(`span`,{className:`max-w-[100px] truncate`,children:r})]})}var Un=[{value:`now`,label:`Interrupt`,Icon:rt},{value:`next`,label:`Queue`,Icon:Ge},{value:`later`,label:`Later`,Icon:F}];function Wn({value:e,onChange:t}){let n=(0,Q.useCallback)(()=>{let n=[`next`,`later`,`now`];t(n[(n.indexOf(e)+1)%n.length])},[e,t]),r=Un.find(t=>t.value===e)??Un[1],i=r.Icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),n()},className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-[11px] text-text-subtle hover:text-text-primary hover:bg-surface-elevated transition-colors border border-transparent hover:border-border`,"aria-label":`Message priority: ${r.label}`,title:`Priority: ${r.label} (click to cycle)`,children:[(0,$.jsx)(i,{className:`size-3`}),(0,$.jsx)(`span`,{children:r.label})]})}function Gn({items:e,filter:t,onSelect:n,onClose:r,visible:i,ranked:a}){let[o,s]=(0,Q.useState)(0),c=(0,Q.useRef)(null),l=a?e:e.filter(e=>{let n=t.toLowerCase();return e.name.toLowerCase().includes(n)||e.description.toLowerCase().includes(n)});(0,Q.useEffect)(()=>{s(0)},[t]),(0,Q.useEffect)(()=>{let e=c.current;e&&e.children[o]?.scrollIntoView({block:`nearest`})},[o]);let u=(0,Q.useCallback)(e=>{if(!i||l.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),s(e=>e>0?e-1:l.length-1),!0;case`ArrowDown`:return e.preventDefault(),s(e=>e<l.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),l[o]&&n(l[o]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[i,l,o,n,r]);return(0,Q.useEffect)(()=>{if(!i)return;let e=e=>{u(e)&&e.stopPropagation()};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i,u]),!i||l.length===0?null:(0,$.jsx)(`div`,{className:`max-h-52 overflow-y-auto border-b border-border bg-surface`,children:(0,$.jsx)(`div`,{ref:c,className:`py-1`,children:l.map((e,t)=>(0,$.jsxs)(`button`,{className:`flex items-start gap-3 w-full px-3 py-2 text-left transition-colors ${t===o?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>s(t),onClick:()=>n(e),children:[(0,$.jsx)(`span`,{className:`shrink-0 mt-0.5`,children:e.type===`builtin`?(0,$.jsx)(rt,{className:`size-4 text-emerald-500`}):e.type===`skill`?(0,$.jsx)(et,{className:`size-4 text-amber-500`}):(0,$.jsx)(Ie,{className:`size-4 text-blue-500`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-sm`,children:[`/`,e.name]}),e.argumentHint&&(0,$.jsx)(`span`,{className:`text-xs text-text-subtle`,children:e.argumentHint}),(0,$.jsx)(`span`,{className:`text-xs text-text-subtle capitalize ml-auto`,children:e.scope===`bundled`?`PPM`:e.scope===`user`?`global`:e.type})]}),e.description&&(0,$.jsx)(`p`,{className:`text-xs text-text-subtle mt-0.5 line-clamp-2`,children:e.description})]})]},`${e.type}-${e.name}`))})})}var Kn=`ppm-hienlh`;function qn({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(`idle`);function b(){f(null),m(``),v(`idle`),u(null)}function x(){t(!1),b(),i(``),o(``),u(null)}async function S(){g(!0),u(null);try{let{url:e,state:t}=await ge();f(t),v(`waiting`),window.open(e,`_blank`)}catch(e){u(e.message)}g(!1)}async function C(){if(!(!p.trim()||!d)){g(!0),u(null);try{let e=p.trim();e.includes(`#`)&&(e=e.split(`#`)[0]??e),await le(e,d),x(),n(`Account connected via OAuth!`)}catch(e){u(e.message)}g(!1)}}async function w(){if(r.trim()){c(!0),u(null);try{await he({apiKey:r.trim(),label:a.trim()||void 0}),x(),n(`Account added!`)}catch(e){u(e.message)}c(!1)}}let T=r.trim()?r.trim().startsWith(`sk-ant-oat`)?`OAuth token (Claude Max/Pro)`:r.trim().startsWith(`sk-ant-api`)?`API key`:`Unknown format`:``;return(0,$.jsx)(A,{open:e,onOpenChange:e=>{e||x()},children:(0,$.jsxs)(M,{className:`sm:max-w-md`,children:[(0,$.jsxs)(j,{children:[(0,$.jsx)(N,{className:`text-sm`,children:`Add Claude Account`}),(0,$.jsx)(O,{className:`text-xs leading-relaxed`,children:`Connect via OAuth (recommended) or paste a token manually.`})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Recommended: Login with Claude`}),_===`idle`?(0,$.jsx)(k,{size:`sm`,className:`w-full h-8 text-xs`,onClick:S,disabled:h,children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{className:`size-3 animate-spin mr-1`}),` Opening...`]}):`Login with Claude`}):(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Authorize in the opened tab, then paste the code:`}),(0,$.jsx)(P,{placeholder:`Paste code here...`,value:p,onChange:e=>m(e.target.value),className:`text-xs h-8 font-mono`,autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(k,{size:`sm`,className:`flex-1 h-7 text-xs`,onClick:C,disabled:!p.trim()||h,children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{className:`size-3 animate-spin mr-1`}),` Connecting...`]}):`Connect`}),(0,$.jsx)(k,{size:`sm`,variant:`ghost`,className:`h-7 text-xs`,onClick:b,children:`Cancel`})]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex-1 border-t`}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`or paste token`}),(0,$.jsx)(`div`,{className:`flex-1 border-t`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(y,{htmlFor:`add-token`,className:`text-xs`,children:`Token`}),(0,$.jsx)(P,{id:`add-token`,type:`password`,placeholder:`sk-ant-...`,value:r,onChange:e=>i(e.target.value),className:`text-xs h-8 font-mono`}),T&&(0,$.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Detected: `,T]})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(y,{htmlFor:`add-label`,className:`text-xs`,children:`Label (optional)`}),(0,$.jsx)(P,{id:`add-label`,placeholder:`e.g. Personal, Work`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`})]})]}),l&&(0,$.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-red-500/10 text-red-600`,children:l}),(0,$.jsxs)(D,{children:[(0,$.jsx)(k,{size:`sm`,variant:`outline`,className:`text-xs h-7`,onClick:x,children:`Cancel`}),(0,$.jsx)(k,{size:`sm`,className:`text-xs h-7`,onClick:w,disabled:!r.trim()||s,children:s?`Adding...`:`Add Token`})]})]})})}function Jn({open:e,onOpenChange:t,accounts:n,preselectId:r,onMessage:i}){let a=n.filter(e=>e.hasRefreshToken),[o,s]=(0,Q.useState)(new Set),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1);e&&!_&&(s(r?new Set([r]):new Set(a.map(e=>e.id))),v(!0)),!e&&_&&v(!1);function b(){t(!1),l(``),d(!1),p(!1)}async function x(e){if(o.size===0)return;g(!0);let t=c.trim()||Kn;try{let n={"Content-Type":`application/json`},r=ae();r&&(n.Authorization=`Bearer ${r}`);let a=await fetch(`/api/accounts/export`,{method:`POST`,headers:n,body:JSON.stringify({password:t,accountIds:[...o],includeRefreshToken:u,refreshBeforeExport:f})});if(!a.ok){let e=await a.json();throw Error(e.error??`Export failed: ${a.status}`)}let s=await a.text();if(e)try{await navigator.clipboard.writeText(s),i?.(`Backup copied to clipboard!`)}catch{Xn(s),i?.(`Backup downloaded.`)}else Xn(s),i?.(`Backup downloaded.`);b()}catch{}g(!1)}let S=o.size>0&&!m;return(0,$.jsx)(A,{open:e,onOpenChange:e=>{e||b()},children:(0,$.jsxs)(M,{className:`sm:max-w-md`,children:[(0,$.jsxs)(j,{children:[(0,$.jsxs)(N,{className:`text-sm flex items-center gap-1.5`,children:[(0,$.jsx)(h,{className:`size-3.5`}),` Export Accounts`]}),(0,$.jsx)(O,{className:`text-xs`,children:`Select accounts and set a password to protect the backup.`})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Accounts to export`}),(0,$.jsx)(`button`,{className:`text-[10px] text-primary hover:underline cursor-pointer`,onClick:()=>s(o.size===a.length?new Set:new Set(a.map(e=>e.id))),children:o.size===a.length?`Deselect all`:`Select all`})]}),a.length===0?(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground p-2 border rounded`,children:`No exportable accounts.`}):(0,$.jsx)(`div`,{className:`max-h-36 overflow-y-auto space-y-1 border rounded p-2`,children:a.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`exp-${e.id}`,checked:o.has(e.id),onChange:t=>{let n=new Set(o);t.target.checked?n.add(e.id):n.delete(e.id),s(n)},className:`size-3.5 accent-primary cursor-pointer`}),(0,$.jsx)(`label`,{htmlFor:`exp-${e.id}`,className:`text-xs cursor-pointer truncate`,children:e.label??e.email??e.id.slice(0,8)})]},e.id))})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(y,{className:`text-xs`,children:[`Password `,(0,$.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,$.jsx)(P,{type:`password`,placeholder:`Leave empty for default`,value:c,onChange:e=>l(e.target.value),className:`text-xs h-8`,autoComplete:`new-password`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`exp-full`,checked:u,onChange:e=>d(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,$.jsx)(`label`,{htmlFor:`exp-full`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens (full transfer)`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`exp-refresh`,checked:f,onChange:e=>p(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,$.jsx)(`label`,{htmlFor:`exp-refresh`,className:`text-[11px] cursor-pointer`,children:`Refresh tokens before export`})]}),u?(0,$.jsxs)(`div`,{className:`rounded-md border border-red-500/30 bg-red-500/5 p-2.5`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-red-600`,children:`Full transfer — source accounts will expire`}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Refresh tokens included. Source machine expires in ~1h after target refreshes.`})]}):f?(0,$.jsx)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-2.5`,children:(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-amber-600`,children:`Refresh before export — invalidates previous shares`})}):(0,$.jsx)(`div`,{className:`rounded-md border border-green-500/30 bg-green-500/5 p-2.5`,children:(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-green-600`,children:`Share current token (safe)`})}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Encrypted with AES-256-GCM + scrypt.`})]}),(0,$.jsxs)(D,{className:`gap-1.5 flex-col sm:flex-row`,children:[(0,$.jsx)(k,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:b,children:`Cancel`}),(0,$.jsxs)(k,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,disabled:!S,onClick:()=>x(!0),children:[(0,$.jsx)(Le,{className:`size-3 mr-1`}),` Copy`]}),(0,$.jsx)(k,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!S,onClick:()=>x(!1),children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ee,{className:`size-3 mr-1`}),` Download`]})})]})]})})}function Yn({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null);function d(){t(!1),i(``),o(``),u(null)}async function f(){if(r.trim()){c(!0),u(null);try{let e=await fe({data:r.trim(),password:a.trim()||Kn});d(),n(`Imported ${e.imported} account(s)`)}catch(e){u(e.message||`Import failed`)}c(!1)}}return(0,$.jsx)(A,{open:e,onOpenChange:e=>{e||d()},children:(0,$.jsxs)(M,{className:`sm:max-w-md`,children:[(0,$.jsxs)(j,{children:[(0,$.jsxs)(N,{className:`text-sm flex items-center gap-1.5`,children:[(0,$.jsx)(h,{className:`size-3.5`}),` Import Accounts`]}),(0,$.jsx)(O,{className:`text-xs`,children:`Paste backup data and enter the export password. Imported accounts are temporary (~1h).`})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(y,{className:`text-xs`,children:`Backup data`}),(0,$.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),placeholder:`Paste backup JSON here...`,rows:4,className:`w-full text-xs p-2 rounded border border-border bg-background font-mono resize-none focus:outline-none focus:ring-1 focus:ring-primary`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(y,{className:`text-xs`,children:[`Password `,(0,$.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,$.jsx)(P,{type:`password`,placeholder:`Leave empty for default`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`,autoComplete:`current-password`})]})]}),l&&(0,$.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-red-500/10 text-red-600`,children:l}),(0,$.jsxs)(D,{children:[(0,$.jsx)(k,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:d,children:`Cancel`}),(0,$.jsx)(k,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!r.trim()||s,onClick:f,children:s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{className:`size-3 animate-spin mr-1`}),` Importing...`]}):`Import`})]})]})})}function Xn(e){let t=new Blob([e],{type:`application/json`}),n=document.createElement(`a`);n.href=URL.createObjectURL(t),n.download=`ppm-accounts-backup.json`,n.click(),URL.revokeObjectURL(n.href)}var Zn=typeof window<`u`?window.matchMedia(`(min-width: 768px)`):null;function Qn(e){return Zn?.addEventListener(`change`,e),()=>Zn?.removeEventListener(`change`,e)}function $n(){return Zn?.matches??!0}function er(){let[e,t]=(0,Q.useState)(null),[n,r]=(0,Q.useState)(!0);return(0,Q.useEffect)(()=>{r(!0),X().then(t).finally(()=>r(!1))},[]),n?(0,$.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Loading...`}):e?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Rotation Strategy`}),(0,$.jsxs)(a,{value:e.strategy,onValueChange:async e=>{t(await Y({strategy:e}))},children:[(0,$.jsx)(o,{className:`w-full h-9 text-xs`,children:(0,$.jsx)(d,{})}),(0,$.jsxs)(m,{children:[(0,$.jsx)(_,{value:`round-robin`,children:`Round-robin`}),(0,$.jsx)(_,{value:`fill-first`,children:`Fill-first`}),(0,$.jsx)(_,{value:`lowest-usage`,children:`Lowest usage`})]})]}),(0,$.jsxs)(`p`,{className:`text-[10px] text-text-subtle`,children:[e.strategy===`round-robin`&&`Cycles through accounts evenly`,e.strategy===`fill-first`&&`Uses one account until its limit, then moves on`,e.strategy===`lowest-usage`&&`Picks the account with the lowest current usage`]})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Max Retry`}),(0,$.jsx)(`input`,{type:`number`,min:0,value:e.maxRetry,className:`w-full h-9 text-xs border rounded-md px-3 bg-background`,onChange:async e=>{let n=parseInt(e.target.value,10);!isNaN(n)&&n>=0&&t(await Y({maxRetry:n}))}}),(0,$.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`How many accounts to try on failure. 0 = try all available accounts.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs border-t border-border pt-3`,children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Active accounts`}),(0,$.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.activeCount})]})]}):(0,$.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Failed to load settings`})}function tr({open:e,onOpenChange:t}){let n=(0,Q.useSyncExternalStore)(Qn,$n);return e?n?(0,$.jsx)(A,{open:e,onOpenChange:t,children:(0,$.jsxs)(M,{className:`sm:max-w-sm`,children:[(0,$.jsx)(j,{children:(0,$.jsxs)(N,{className:`text-sm flex items-center gap-2`,children:[(0,$.jsx)(Te,{className:`size-4`}),` Rotation & Retry`]})}),(0,$.jsx)(er,{})]})}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-50 transition-opacity duration-200 opacity-100`,onClick:()=>t(!1),style:{backgroundColor:`rgba(0,0,0,0.5)`}}),(0,$.jsxs)(`div`,{className:H(`fixed bottom-0 left-0 right-0 z-50 bg-background rounded-t-2xl border-t border-border shadow-2xl`,`transition-transform duration-300 ease-out max-h-[85vh] overflow-y-auto`,`translate-y-0`),children:[(0,$.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,$.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,$.jsx)(Te,{className:`size-4`}),` Rotation & Retry`]}),(0,$.jsx)(`button`,{onClick:()=>t(!1),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,$.jsx)(te,{className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`px-4 py-4 pb-8`,children:(0,$.jsx)(er,{})})]})]}):null}var nr=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],rr=Array.from({length:24},(e,t)=>t);function ir(e,t){let n=Array.from({length:7},()=>Array.from({length:24},()=>({sum:0,count:0,avg:0})));for(let r of e){let e=t===`5h`?r.five_hour_util:r.weekly_util;if(e==null)continue;let i=new Date(r.recorded_at+(r.recorded_at.endsWith(`Z`)?``:`Z`)),a=(i.getDay()+6)%7,o=i.getHours();n[a][o].sum+=e,n[a][o].count+=1}for(let e of n)for(let t of e)t.avg=t.count>0?t.sum/t.count:0;return n}function ar(e){return e.map(e=>{let t=e.reduce((e,t)=>e+t.sum,0),n=e.reduce((e,t)=>e+t.count,0);return n>0?t/n:0})}function or(e){return rr.map(t=>{let n=0,r=0;for(let i of e)n+=i[t].sum,r+=i[t].count;return r>0?n/r:0})}function sr(e){return e===0?`bg-surface-elevated`:e<.3?`bg-green-500/30`:e<.5?`bg-green-500/60`:e<.7?`bg-amber-500/50`:e<.9?`bg-amber-500/80`:`bg-red-500/80`}function cr(e){return e<.3?`bg-green-500`:e<.7?`bg-amber-500`:`bg-red-500`}function lr({accountId:e}){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!0),[a,o]=(0,Q.useState)(`5h`);(0,Q.useEffect)(()=>{i(!0),J(e).then(n).catch(()=>n([])).finally(()=>i(!1))},[e]);let s=(0,Q.useMemo)(()=>t?ir(t,a):null,[t,a]),c=(0,Q.useMemo)(()=>s?ar(s):[],[s]),l=(0,Q.useMemo)(()=>s?or(s):[],[s]),u=Math.max(...c,.01);if(Math.max(...l,.01),r)return(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,$.jsx)(Z,{className:`size-3 animate-spin text-text-subtle`})});if(!t||t.length===0)return(0,$.jsx)(`div`,{className:`text-[10px] text-text-subtle py-2 text-center`,children:`No usage history yet`});let d=t.length,f=new Set(t.map(e=>new Date(e.recorded_at+(e.recorded_at.endsWith(`Z`)?``:`Z`)).toDateString())).size;return(0,$.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Usage Pattern (7d)`}),(0,$.jsxs)(`div`,{className:`flex gap-0.5 text-[9px]`,children:[(0,$.jsx)(`button`,{onClick:()=>o(`5h`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`5h`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`5-hour rolling window limit — resets every 5 hours`,children:`5h`}),(0,$.jsx)(`button`,{onClick:()=>o(`weekly`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`weekly`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`Weekly limit — resets every 7 days`,children:`Wk`})]})]}),(0,$.jsxs)(`p`,{className:`text-[9px] text-text-subtle leading-tight`,children:[`Avg `,a===`5h`?`5-hour`:`weekly`,` limit usage over `,f,`d (`,d,` samples). Higher % = closer to rate limit. Hover cells for details.`]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by day of week`}),(0,$.jsx)(`div`,{className:`flex flex-col gap-[2px] mt-0.5`,children:nr.map((e,t)=>{let n=c[t]??0;return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`text-[8px] text-text-subtle w-5 shrink-0 text-right tabular-nums`,children:e}),(0,$.jsx)(`div`,{className:`flex-1 h-2.5 bg-surface-elevated rounded-sm overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-sm transition-all ${cr(n)}`,style:{width:`${Math.round(n/u*100)}%`}})}),(0,$.jsxs)(`span`,{className:`text-[8px] text-text-subtle w-6 shrink-0 text-right tabular-nums`,children:[Math.round(n*100),`%`]})]},e)})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by hour (0h-23h)`}),(0,$.jsx)(`div`,{className:`flex gap-[1px] mt-0.5`,children:rr.map(e=>{let t=l[e]??0;return(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-[1px]`,children:[(0,$.jsx)(`div`,{className:`w-full aspect-square rounded-[2px] ${sr(t)}`,title:`${e}:00 — avg ${Math.round(t*100)}% usage`}),e%6==0&&(0,$.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})]},e)})})]}),s&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Day x Hour heatmap`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-[1px] mt-0.5`,children:[nr.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,$.jsx)(`span`,{className:`text-[7px] text-text-subtle w-4 shrink-0 text-right`,children:e.charAt(0)}),rr.map(n=>{let r=s[t][n];return(0,$.jsx)(`div`,{className:`flex-1 aspect-square rounded-[1px] ${sr(r.avg)}`,title:`${e} ${n}:00 — ${r.count>0?`avg ${Math.round(r.avg*100)}% (${r.count} samples)`:`no data`}`},n)})]},e)),(0,$.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,$.jsx)(`span`,{className:`w-4 shrink-0`}),rr.map(e=>(0,$.jsx)(`div`,{className:`flex-1 text-center`,children:e%6==0&&(0,$.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})},e))]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[8px] text-text-subtle`,children:[(0,$.jsx)(`span`,{children:`Low`}),(0,$.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-green-500/30`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-green-500/60`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-amber-500/50`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-amber-500/80`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-red-500/80`})]}),(0,$.jsx)(`span`,{children:`High`}),(0,$.jsx)(`span`,{className:`ml-1`,children:`|`}),(0,$.jsx)(`div`,{className:`size-2 rounded-[1px] bg-surface-elevated border border-border/30`}),(0,$.jsx)(`span`,{children:`No data`})]})]})}function ur(e){return e>=90?`text-red-500`:e>=70?`text-amber-500`:`text-green-500`}function dr(e){return e>=90?`bg-red-500`:e>=70?`bg-amber-500`:`bg-green-500`}function fr(e){if(!e)return null;let t=null;if(e.resetsInMinutes!=null)t=e.resetsInMinutes;else if(e.resetsInHours!=null)t=Math.round(e.resetsInHours*60);else if(e.resetsAt){let n=new Date(e.resetsAt).getTime()-Date.now();t=n>0?Math.ceil(n/6e4):0}if(t==null)return null;if(t<=0)return`now`;let n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?i>0?`${n}d ${r}h ${i}m`:r>0?`${n}d ${r}h`:`${n}d`:r>0?i>0?`${r}h ${i}m`:`${r}h`:`${i}m`}function pr({label:e,bucket:t}){if(!t)return null;let n=Math.round(t.utilization*100),r=fr(t);return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-text-primary`,children:e}),r&&(0,$.jsxs)(`span`,{className:`text-[10px] text-text-subtle`,title:`Resets in`,children:[`↻ `,r]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex-1 h-2 rounded-full bg-border overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all ${dr(n)}`,style:{width:`${Math.min(n,100)}%`}})}),(0,$.jsxs)(`span`,{className:`text-xs font-medium tabular-nums w-10 text-right ${ur(n)}`,children:[n,`%`]})]})]})}function mr(e){let t=e-Date.now();if(t<=0)return`expired`;let n=Math.ceil(t/6e4),r=Math.floor(n/60),i=Math.floor(r/24);return i>0?`${i}d ${r%24}h`:r>0?`${r}h ${n%60}m`:`${n}m`}function hr(e){if(!e)return{label:`unknown`,tip:`No account info available`,color:`text-text-subtle`};if(!e.expiresAt)return{label:`key`,tip:`API key (no expiry)`,color:`text-text-subtle`};let t=e.expiresAt*1e3<Date.now();return t&&e.hasRefreshToken?{label:`expired`,tip:`Token expired but has refresh token — will auto-renew`,color:`text-amber-500`}:t?{label:`expired`,tip:`Token expired, no refresh token`,color:`text-red-500`}:e.hasRefreshToken?{label:`long-lived`,tip:`OAuth token with refresh — long-lived`,color:`text-green-500`}:{label:`temp`,tip:`Temporary token without refresh — will expire`,color:`text-amber-500`}}function gr(e){if(!e)return null;let t=Math.round((Date.now()-e)/1e3);if(t<5)return`just now`;if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60),i=n%60;return r<24?i>0?`${r}h ${i}m ago`:`${r}h ago`:`${Math.floor(r/24)}d ago`}function _r({entry:e,isActive:t,accountInfo:n,onToggle:r,onDelete:i,onExport:a,onViewProfile:o,flash:s,fullscreen:c}){let{usage:l}=e,d=l.session||l.weekly||l.weeklyOpus||l.weeklySonnet,f=n?.status??e.accountStatus,p=!!(n&&!n.hasRefreshToken&&n.expiresAt&&n.expiresAt<Math.floor(Date.now()/1e3));return(0,$.jsxs)(`div`,{className:`rounded-md border p-2 transition-colors duration-500 ${c?`flex flex-col gap-1.5 overflow-hidden`:`space-y-1.5 min-w-[200px] shrink-0 snap-start`} ${p?`opacity-50`:``} ${s?`bg-primary/10 border-primary/40`:``} ${t?`border-primary/30 bg-primary/5`:`border-border/50`}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium truncate flex-1 min-w-0`,children:e.accountLabel??e.accountId.slice(0,8)}),p&&(0,$.jsx)(`span`,{className:`text-[9px] text-red-500 shrink-0 font-medium`,children:`Expired`}),!e.isOAuth&&!p&&(0,$.jsx)(`span`,{className:`text-[9px] text-text-subtle shrink-0`,children:`API key`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[!p&&o&&n?.profileData&&(0,$.jsx)(`button`,{className:`p-1 rounded cursor-pointer text-text-subtle hover:text-foreground hover:bg-surface-elevated transition-colors`,onClick:()=>o(n.profileData,e.accountId),title:`View profile`,children:(0,$.jsx)(R,{className:`size-3`})}),!p&&a&&e.isOAuth&&(0,$.jsx)(`button`,{className:`p-1 rounded cursor-pointer text-text-subtle hover:text-blue-500 hover:bg-surface-elevated transition-colors`,onClick:()=>a(e.accountId),title:`Export this account`,children:(0,$.jsx)(ee,{className:`size-3`})}),!p&&r&&(0,$.jsx)(u,{checked:f!==`disabled`,onCheckedChange:()=>r(e.accountId,f),disabled:f===`cooldown`,className:`scale-[0.6] cursor-pointer`}),i&&(0,$.jsx)(`button`,{className:`p-1 rounded cursor-pointer text-text-subtle hover:text-red-500 hover:bg-surface-elevated transition-colors`,onClick:()=>i(e.accountId,e.accountLabel??e.accountId.slice(0,8)),title:`Remove account`,children:(0,$.jsx)(ne,{className:`size-3`})})]})]}),d?(0,$.jsxs)(`div`,{className:c?`flex-1 flex flex-col justify-evenly min-h-0`:`space-y-1.5`,children:[(0,$.jsx)(pr,{label:`5-Hour Session`,bucket:l.session}),(0,$.jsx)(pr,{label:`Weekly`,bucket:l.weekly}),(0,$.jsx)(pr,{label:`Weekly (Opus)`,bucket:l.weeklyOpus}),(0,$.jsx)(pr,{label:`Weekly (Sonnet)`,bucket:l.weeklySonnet})]}):(0,$.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:e.isOAuth?`No usage data yet`:`Usage tracking not available for API keys`}),(()=>{let e=hr(n);return(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] text-text-subtle flex-wrap`,children:[l.lastFetchedAt&&(0,$.jsxs)(`span`,{title:`Last usage data update`,children:[`↻ `,gr(new Date(l.lastFetchedAt).getTime())]}),n?.expiresAt&&n.expiresAt*1e3>Date.now()&&(0,$.jsxs)(`span`,{title:`Token expires in`,children:[`⏱ `,mr(n.expiresAt*1e3)]}),(0,$.jsxs)(`span`,{className:e.color,title:e.tip,children:[`© `,e.label]})]})})()]})}function vr({usage:e,visible:t,onClose:n,onReload:r,loading:i,lastFetchedAt:a}){let[o,s]=(0,Q.useState)([]),[c,l]=(0,Q.useState)([]),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(new Set),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(null),L=(0,Q.useRef)(void 0),R=(0,Q.useRef)([]);function B(e){L.current&&clearTimeout(L.current),I(e),L.current=setTimeout(()=>I(null),4e3)}function ne(e){V(),e&&B(e)}async function V(){let e=o.length>0;e?h(!0):p(!0);let[t,n,r]=await Promise.allSettled([ue(),me(),ce()]);if(t.status===`fulfilled`){let n=t.value;if(e&&R.current.length>0){let e=new Set,t=new Map(R.current.map(e=>[e.accountId,e]));for(let r of n){let n=t.get(r.accountId);if(!n){e.add(r.accountId);continue}let i=n.usage,a=r.usage;(i.session?.utilization!==a.session?.utilization||i.weekly?.utilization!==a.weekly?.utilization||i.weeklyOpus?.utilization!==a.weeklyOpus?.utilization||i.weeklySonnet?.utilization!==a.weeklySonnet?.utilization)&&e.add(r.accountId)}e.size>0&&(_(e),setTimeout(()=>_(new Set),1500))}R.current=n,s(n)}n.status===`fulfilled`&&l(n.value),r.status===`fulfilled`&&d(r.value?.id??null),p(!1),h(!1)}if((0,Q.useEffect)(()=>{t&&V()},[t]),(0,Q.useEffect)(()=>{!t||!a||V()},[a]),!t)return null;let re=new Map(c.map(e=>[e.id,e])),H=e.queryCostUsd!=null||e.totalCostUsd!=null,ie=o.length>0,U=o.length||1,W=Math.ceil(Math.sqrt(U)),G=Math.ceil(U/W);async function K(e,t){await de(e,{status:t===`disabled`?`active`:`disabled`}),V(),r?.()}async function ae(){if(k){try{await pe(k.id),B(`Account "${k.display}" removed.`),V(),r?.()}catch(e){B(`Failed to remove: ${e.message}`)}A(null)}}function q(){M(null),C(!0)}return(0,$.jsxs)(`div`,{className:`relative border-b border-border bg-surface px-3 py-2.5 ${N?`fixed inset-0 z-50 flex flex-col gap-2.5 overflow-hidden`:`space-y-2.5 max-h-[350px] overflow-y-auto`}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-semibold text-text-primary`,children:`Usage & Accounts`}),a&&(0,$.jsx)(`span`,{className:`text-[10px] text-text-subtle`,children:gr(new Date(a).getTime())})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{onClick:()=>O(!0),className:`text-xs text-text-subtle hover:text-text-primary px-1 cursor-pointer`,title:`Rotation & retry settings`,children:(0,$.jsx)(Te,{className:`size-3`})}),ie&&(0,$.jsx)(`button`,{onClick:()=>P(e=>!e),className:`text-xs text-text-subtle hover:text-text-primary px-1 cursor-pointer`,title:N?`Exit fullscreen`:`Fullscreen view`,children:N?(0,$.jsx)(Ye,{className:`size-3`}):(0,$.jsx)(qe,{className:`size-3`})}),r&&(0,$.jsx)(`button`,{onClick:()=>{r(),V()},disabled:i||m,className:`text-xs text-text-subtle hover:text-text-primary px-1 disabled:opacity-50 cursor-pointer`,title:`Refresh`,children:(0,$.jsx)(z,{className:`size-3 ${i||m?`animate-spin`:``}`})}),(0,$.jsx)(`button`,{onClick:()=>{P(!1),n()},className:`text-xs text-text-subtle hover:text-text-primary px-1 cursor-pointer`,children:(0,$.jsx)(te,{className:`size-3`})})]})]}),F&&(0,$.jsx)(`div`,{className:`text-[11px] p-1.5 rounded bg-green-500/10 text-green-600 text-center animate-in fade-in duration-200`,children:F}),ie||f?(0,$.jsx)(`div`,{className:N?`flex-1 min-h-0 grid gap-2 overflow-hidden`:`flex gap-1.5 overflow-x-auto pb-1 -mx-3 px-3 snap-x snap-mandatory scrollbar-thin`,style:N?{gridTemplateColumns:`repeat(${W}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${G}, minmax(0, 1fr))`}:void 0,children:f?(0,$.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Loading...`}):o.map(t=>(0,$.jsx)(_r,{entry:t,isActive:t.accountId===(u??e.activeAccountId),accountInfo:re.get(t.accountId),onToggle:K,onDelete:(e,t)=>A({id:e,display:t}),onExport:e=>{M(e),C(!0)},onViewProfile:(e,t)=>y({profile:e,accountId:t}),flash:g.has(t.accountId),fullscreen:N},t.accountId))}):(0,$.jsx)($.Fragment,{children:e.session||e.weekly||e.weeklyOpus||e.weeklySonnet?(0,$.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,$.jsx)(pr,{label:`5-Hour Session`,bucket:e.session}),(0,$.jsx)(pr,{label:`Weekly`,bucket:e.weekly}),(0,$.jsx)(pr,{label:`Weekly (Opus)`,bucket:e.weeklyOpus}),(0,$.jsx)(pr,{label:`Weekly (Sonnet)`,bucket:e.weeklySonnet})]}):(0,$.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`No usage data available`})}),H&&(0,$.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[e.queryCostUsd!=null&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Last query`}),(0,$.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.queryCostUsd.toFixed(4)]})]}),e.totalCostUsd!=null&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Session total`}),(0,$.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.totalCostUsd.toFixed(4)]})]})]}),v&&(0,$.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Profile`}),(0,$.jsx)(`button`,{className:`text-text-subtle hover:text-foreground cursor-pointer`,onClick:()=>y(null),children:(0,$.jsx)(te,{className:`size-3`})})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[70px_1fr] gap-x-2 gap-y-0.5 text-[10px]`,children:[v.profile.account?.display_name&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Name`}),(0,$.jsx)(`span`,{children:v.profile.account.display_name})]}),v.profile.account?.email&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Email`}),(0,$.jsx)(`span`,{children:v.profile.account.email})]}),v.profile.organization?.name&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Org`}),(0,$.jsx)(`span`,{children:v.profile.organization.name})]}),v.profile.organization?.organization_type&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Type`}),(0,$.jsx)(`span`,{children:v.profile.organization.organization_type})]}),v.profile.organization?.rate_limit_tier&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Tier`}),(0,$.jsx)(`span`,{children:v.profile.organization.rate_limit_tier})]}),v.profile.organization?.subscription_status&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Status`}),(0,$.jsx)(`span`,{children:v.profile.organization.subscription_status})]})]}),(0,$.jsx)(lr,{accountId:v.accountId})]}),(0,$.jsxs)(`div`,{className:`border-t border-border pt-2 flex gap-1.5 shrink-0`,children:[(0,$.jsxs)(`button`,{onClick:()=>x(!0),className:`flex-1 flex items-center justify-center gap-1 rounded-md border border-border px-2 py-1 text-[11px] text-text-secondary hover:bg-surface-hover transition-colors cursor-pointer`,children:[(0,$.jsx)(T,{className:`size-3`}),` Add`]}),(0,$.jsxs)(`button`,{onClick:q,className:`flex-1 flex items-center justify-center gap-1 rounded-md border border-border px-2 py-1 text-[11px] text-text-secondary hover:bg-surface-hover transition-colors cursor-pointer`,children:[(0,$.jsx)(ee,{className:`size-3`}),` Export`]}),(0,$.jsxs)(`button`,{onClick:()=>E(!0),className:`flex-1 flex items-center justify-center gap-1 rounded-md border border-border px-2 py-1 text-[11px] text-text-secondary hover:bg-surface-hover transition-colors cursor-pointer`,children:[(0,$.jsx)(Ae,{className:`size-3`}),` Import`]})]}),k&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/80 backdrop-blur-sm rounded-md`,children:(0,$.jsxs)(`div`,{className:`bg-surface border border-border rounded-lg shadow-lg p-4 mx-4 max-w-[280px] w-full space-y-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-text-primary text-center`,children:[`Remove `,(0,$.jsx)(`strong`,{className:`text-foreground`,children:k.display}),`?`]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`button`,{onClick:()=>A(null),className:`flex-1 px-3 py-1.5 rounded-md text-xs border border-border text-text-secondary hover:bg-surface-hover cursor-pointer transition-colors`,children:`Cancel`}),(0,$.jsx)(`button`,{onClick:ae,className:`flex-1 px-3 py-1.5 rounded-md text-xs bg-red-500 text-white hover:bg-red-600 cursor-pointer transition-colors`,children:`Remove`})]})]})}),(0,$.jsx)(qn,{open:b,onOpenChange:x,onSuccess:ne}),(0,$.jsx)(Jn,{open:S,onOpenChange:e=>{C(e),e||M(null)},accounts:c,preselectId:j,onMessage:B}),(0,$.jsx)(Yn,{open:w,onOpenChange:E,onSuccess:ne}),(0,$.jsx)(tr,{open:D,onOpenChange:O})]})}var yr={active:`bg-green-500`,idle:`bg-yellow-500`,shutdown:`bg-zinc-400`},br={task_assignment:{label:`task`,className:`bg-blue-500/20 text-blue-400`},idle_notification:{label:`idle`,className:`bg-yellow-500/20 text-yellow-400`},completion:{label:`done`,className:`bg-green-500/20 text-green-400`},shutdown_request:{label:`shutdown`,className:`bg-red-500/20 text-red-400`},shutdown_approved:{label:`shutdown ✓`,className:`bg-zinc-500/20 text-zinc-400`}};function xr({teamNames:e,messages:t}){let[n,r]=(0,Q.useState)(e[0]??``),[i,a]=(0,Q.useState)([]),[o,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e.length>0&&!e.includes(n)&&r(e[0])},[e,n]);let l=(0,Q.useCallback)(async e=>{s(!0);try{a((await q.get(`/api/teams/${encodeURIComponent(e)}`))?.members??[])}catch{a([])}s(!1)},[]);(0,Q.useEffect)(()=>{n&&l(n)},[n,l]),(0,Q.useEffect)(()=>{c.current?.scrollIntoView({behavior:`smooth`})},[t.length]);let u=t.slice(-200);return(0,$.jsxs)(`div`,{className:`space-y-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mb-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1 overflow-x-auto min-w-0 flex-1`,children:e.map(e=>(0,$.jsx)(`button`,{onClick:()=>r(e),className:H(`px-2 py-0.5 text-[11px] rounded-md whitespace-nowrap transition-colors`,n===e?`bg-primary/10 text-primary font-medium`:`text-text-subtle hover:text-text-primary`),children:e},e))}),(0,$.jsx)(`button`,{onClick:()=>n&&l(n),className:`text-text-subtle hover:text-foreground p-1 shrink-0`,"aria-label":`Refresh`,children:(0,$.jsx)(z,{className:H(`size-3`,o&&`animate-spin`)})})]}),i.length>0&&(0,$.jsxs)(`div`,{className:`pb-2 mb-2 border-b border-border/30`,children:[(0,$.jsx)(`div`,{className:`text-[10px] text-text-subtle uppercase tracking-wider mb-1`,children:`Members`}),(0,$.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:H(`size-1.5 rounded-full shrink-0`,yr[e.status]??`bg-zinc-400`)}),(0,$.jsx)(`span`,{className:`font-medium truncate`,children:e.name}),e.model&&e.model!==`unknown`&&(0,$.jsxs)(`span`,{className:`text-text-subtle text-[10px]`,children:[`(`,e.model,`)`]}),(0,$.jsx)(`span`,{className:`ml-auto text-text-subtle text-[10px]`,children:e.status})]},e.name))})]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto`,children:u.length===0?(0,$.jsx)(`p`,{className:`text-xs text-text-subtle text-center py-2`,children:`No messages yet`}):(0,$.jsxs)(`div`,{className:`space-y-2`,children:[u.map((e,t)=>{let n=e.parsedType?br[e.parsedType]:null,r=Sr(e.timestamp);return(0,$.jsxs)(`div`,{className:`text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-text-subtle`,children:[(0,$.jsx)(`span`,{className:`font-medium`,style:Cr(e.color),children:e.from}),(0,$.jsx)(`span`,{children:`→`}),(0,$.jsx)(`span`,{children:e.to}),(0,$.jsx)(`span`,{className:`ml-auto text-[10px]`,children:r})]}),(0,$.jsxs)(`div`,{className:`mt-0.5 text-foreground/90 break-words`,children:[n&&(0,$.jsx)(`span`,{className:H(`inline-block px-1 py-0 rounded text-[9px] mr-1`,n.className),children:n.label}),e.summary??wr(e.text)]})]},`${e.timestamp}-${t}`)}),(0,$.jsx)(`div`,{ref:c})]})})]})}function Sr(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function Cr(e){if(e&&(/^#[0-9a-fA-F]{3,8}$/.test(e)||/^[a-zA-Z]{3,20}$/.test(e)))return{color:e}}function wr(e,t=120){if(!e)return``;try{let n=JSON.parse(e);return n.summary??n.text??e.slice(0,t)}catch{}return e.length>t?e.slice(0,t)+`...`:e}function Tr(e){try{return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}catch{return``}}function Er(e){return e>=90?`text-red-500`:e>=70?`text-amber-500`:`text-green-500`}function Dr({sessionId:e,projectName:t}){let[n,r]=(0,Q.useState)(!1);return(0,$.jsx)(`button`,{onClick:()=>{try{let n=q.get(`${K(t)}/chat/sessions/${e}/debug?project=${encodeURIComponent(t)}`).then(e=>{let t=[`PPM Session: ${e.ppmSessionId}`,`SDK Session: ${e.sdkSessionId}`,e.jsonlPath?`JSONL: ${e.jsonlPath}`:`JSONL: not found`,e.projectPath?`Project: ${e.projectPath}`:null].filter(Boolean).join(`
|
|
9
|
+
`);return new Blob([t],{type:`text/plain`})});navigator.clipboard.write([new ClipboardItem({"text/plain":n})]).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})}catch{}},className:`p-1 rounded transition-colors ${n?`text-green-500 bg-green-500/10`:`text-text-subtle hover:text-text-secondary hover:bg-surface-elevated`}`,title:n?`Copied!`:`Copy session debug info`,children:n?(0,$.jsx)(Be,{className:`size-3`}):(0,$.jsx)(Oe,{className:`size-3`})})}function Or({projectName:e,usageInfo:t,usageLoading:n,refreshUsage:r,lastFetchedAt:i,sessionId:a,providerId:o,onSelectSession:s,onBugReport:u,isConnected:d,onReconnect:m,teamActivity:h,teamMessages:g,onTeamOpen:_}){let[y,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)([]),[w,T]=(0,Q.useState)(!1),E=ke(e=>a?e.notifications.has(a):!1),D=ke(e=>e.clearForSession),[O,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(``),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!1),R=(0,Q.useRef)(null),ee=G(e=>e.openTab),B=e=>{x(t=>t===e?null:e)},V=(0,Q.useCallback)(async()=>{if(e){T(!0);try{let t=await q.get(`${K(e)}/chat/sessions?limit=50&offset=0`);C(t.sessions),F(t.hasMore)}catch{}finally{T(!1)}}},[e]),re=(0,Q.useCallback)(async()=>{if(!(!e||I||!P)){L(!0);try{let t=S.filter(e=>!e.pinned).length,n=await q.get(`${K(e)}/chat/sessions?limit=50&offset=${t}`);C(e=>{let t=new Set(e.map(e=>e.id)),r=n.sessions.filter(e=>!t.has(e.id));return[...e,...r]}),F(n.hasMore)}catch{}finally{L(!1)}}},[e,I,P,S]);(0,Q.useEffect)(()=>{y===`history`&&S.length===0&&V()},[y]);function H(t){s?(s(t),x(null)):ee({type:`chat`,title:t.title||`Chat`,projectId:e??null,metadata:{projectName:e,sessionId:t.id,providerId:t.providerId},closable:!0})}let ie=(0,Q.useCallback)((e,t)=>{t.stopPropagation(),j(e.id),N(e.title||``),setTimeout(()=>R.current?.select(),0)},[]),U=(0,Q.useCallback)(async()=>{if(!A||!M.trim()||!e){j(null);return}try{await q.patch(`${K(e)}/chat/sessions/${A}`,{title:M.trim()}),C(e=>e.map(e=>e.id===A?{...e,title:M.trim()}:e))}catch{}j(null)},[A,M,e]),W=(0,Q.useCallback)(()=>j(null),[]),ae=(0,Q.useCallback)(async(t,n)=>{if(t.stopPropagation(),!e)return;let r=`${K(e)}/chat/sessions/${n.id}/pin`;try{n.pinned?await q.del(r):await q.put(r),C(e=>e.map(e=>e.id===n.id?{...e,pinned:!e.pinned}:e).sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()))}catch{}},[e]),oe=(0,Q.useCallback)(async(t,n)=>{if(t.stopPropagation(),e&&window.confirm(`Delete this session? This cannot be undone.`))try{await q.del(`${K(e)}/chat/sessions/${n.id}?providerId=${n.providerId}`),C(e=>e.filter(e=>e.id!==n.id))}catch{}},[e]),se=O.trim()?S.filter(e=>(e.title||``).toLowerCase().includes(O.toLowerCase())):S,ce=!o||o===`claude`,J=t.fiveHour==null?null:Math.round(t.fiveHour*100),Y=t.sevenDay==null?null:Math.round(t.sevenDay*100),le=J!=null||Y!=null?Er(Math.max(J??0,Y??0)):`text-text-subtle`;return(0,$.jsxs)(`div`,{className:`border-b border-border/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,$.jsxs)(`button`,{onClick:()=>B(`history`),className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-colors ${y===`history`?`text-primary bg-primary/10`:`text-text-secondary hover:text-foreground hover:bg-surface-elevated`}`,children:[(0,$.jsx)(Ue,{className:`size-3`}),(0,$.jsx)(`span`,{children:`History`})]}),a&&o&&o!==`mock`?(0,$.jsxs)(`button`,{onClick:()=>B(`config`),className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-colors ${y===`config`?`text-primary bg-primary/10`:`text-text-secondary hover:text-foreground hover:bg-surface-elevated`}`,title:`AI Settings`,children:[(0,$.jsx)(p,{providerId:o}),(0,$.jsx)(`span`,{className:`capitalize`,children:o})]}):(0,$.jsx)(`button`,{onClick:()=>B(`config`),className:`p-1 rounded transition-colors ${y===`config`?`text-primary bg-primary/10`:`text-text-subtle hover:text-text-secondary hover:bg-surface-elevated`}`,title:`AI Settings`,children:(0,$.jsx)(Ze,{className:`size-3`})}),ce?(0,$.jsxs)(`button`,{onClick:()=>B(`usage`),className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-medium tabular-nums transition-colors hover:bg-surface-elevated ${y===`usage`?`bg-primary/10`:``} ${le}`,title:`Usage limits`,children:[(0,$.jsx)(Re,{className:`size-3`}),t.activeAccountLabel&&(0,$.jsxs)(`span`,{className:`text-text-secondary font-normal truncate max-w-[60px]`,children:[`[`,t.activeAccountLabel,`]`]}),(0,$.jsxs)(`span`,{children:[`5h:`,J==null?`--%`:`${J}%`]}),(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`·`}),(0,$.jsxs)(`span`,{children:[`Wk:`,Y==null?`--%`:`${Y}%`]})]}):null,h?.hasTeams&&(0,$.jsxs)(`button`,{onClick:()=>{B(`team`),_?.()},className:`relative flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-colors ${y===`team`?`text-primary bg-primary/10`:`text-text-secondary hover:text-foreground hover:bg-surface-elevated`}`,title:`Team activity`,children:[(0,$.jsx)(nt,{className:`size-3`}),(0,$.jsx)(`span`,{children:`Team`}),(h.unreadCount??0)>0&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-2 bg-primary rounded-full animate-pulse`})]}),(0,$.jsx)(`div`,{className:`flex-1`}),E&&a&&(0,$.jsx)(`button`,{onClick:()=>D(a),className:`p-1 rounded text-amber-500 hover:text-amber-400 hover:bg-surface-elevated transition-colors`,title:`Mark as read`,children:(0,$.jsx)(l,{className:`size-3`})}),a&&(0,$.jsx)(Dr,{sessionId:a,projectName:e}),m&&(0,$.jsx)(`button`,{onClick:m,className:`size-4 flex items-center justify-center`,title:d?`Connected`:`Disconnected — click to reconnect`,children:(0,$.jsx)(`span`,{className:`size-2 rounded-full ${d?`bg-green-500`:`bg-red-500 animate-pulse`}`})})]}),y===`history`&&(0,$.jsxs)(`div`,{className:`border-t border-border/30 bg-surface`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 border-b border-border/30`,children:[(0,$.jsx)(_e,{className:`size-3 text-text-subtle shrink-0`}),(0,$.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`Search sessions...`,className:`flex-1 bg-transparent text-[11px] text-text-primary outline-none placeholder:text-text-subtle`}),(0,$.jsx)(`button`,{onClick:V,disabled:w,className:`p-0.5 rounded text-text-subtle hover:text-text-secondary transition-colors disabled:opacity-50`,title:`Refresh`,children:(0,$.jsx)(z,{className:`size-3 ${w?`animate-spin`:``}`})})]}),(0,$.jsx)(`div`,{className:`max-h-[200px] overflow-y-auto`,children:w&&S.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,$.jsx)(Z,{className:`size-3.5 animate-spin text-text-subtle`})}):se.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3 text-[11px] text-text-subtle`,children:O?`No matching sessions`:`No sessions yet`}):(0,$.jsxs)($.Fragment,{children:[se.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 w-full px-3 py-1.5 text-left hover:bg-surface-elevated transition-colors group`,children:[(0,$.jsx)(p,{providerId:e.providerId}),A===e.id?(0,$.jsxs)(`form`,{className:`flex items-center gap-1 flex-1 min-w-0`,onSubmit:e=>{e.preventDefault(),U()},children:[(0,$.jsx)(`input`,{ref:R,value:M,onChange:e=>N(e.target.value),onBlur:U,onKeyDown:e=>{e.key===`Escape`&&W()},className:`flex-1 min-w-0 bg-surface-elevated text-[11px] text-text-primary px-1 py-0.5 rounded border border-border outline-none focus:border-primary`,autoFocus:!0}),(0,$.jsx)(`button`,{type:`submit`,className:`p-0.5 text-green-500 hover:text-green-400`,onClick:e=>e.stopPropagation(),children:(0,$.jsx)(b,{className:`size-3`})}),(0,$.jsx)(`button`,{type:`button`,className:`p-0.5 text-text-subtle hover:text-text-secondary`,onClick:e=>{e.stopPropagation(),W()},children:(0,$.jsx)(te,{className:`size-3`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{onClick:()=>H(e),className:`text-[11px] truncate flex-1 text-left flex items-center gap-1`,children:[e.title?.startsWith(`[PPM]`)&&(0,$.jsx)(f,{className:`size-3 text-muted-foreground shrink-0`}),e.title?.startsWith(`[PPM]`)?e.title.slice(7):e.title||`Untitled`]}),(0,$.jsx)(`button`,{onClick:t=>ae(t,e),className:`p-0.5 rounded transition-all ${e.pinned?`text-primary hover:text-primary/70`:`text-text-subtle hover:text-text-secondary can-hover:opacity-0 can-hover:group-hover:opacity-100`}`,title:e.pinned?`Unpin session`:`Pin session`,children:e.pinned?(0,$.jsx)(ve,{className:`size-3`}):(0,$.jsx)(Ee,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:t=>ie(e,t),className:`p-0.5 rounded text-text-subtle hover:text-text-secondary can-hover:opacity-0 can-hover:group-hover:opacity-100 transition-opacity`,title:`Rename session`,children:(0,$.jsx)(c,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:t=>oe(t,e),className:`p-0.5 rounded text-text-subtle hover:text-red-400 hover:bg-red-500/20 can-hover:opacity-0 can-hover:group-hover:opacity-100 transition-opacity`,title:`Delete session`,children:(0,$.jsx)(ne,{className:`size-3`})})]}),A!==e.id&&e.updatedAt&&(0,$.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0 w-10 text-right`,children:Tr(e.updatedAt)})]},e.id)),P&&!O&&(0,$.jsxs)(`button`,{onClick:re,disabled:I,className:`flex items-center justify-center gap-1 w-full py-1.5 text-[11px] text-text-subtle hover:text-text-secondary hover:bg-surface-elevated transition-colors`,children:[I?(0,$.jsx)(Z,{className:`size-3 animate-spin`}):null,I?`Loading...`:`Load more`]})]})})]}),y===`config`&&(0,$.jsx)(`div`,{className:`border-t border-border/30 bg-surface px-3 py-2 max-h-[280px] overflow-y-auto`,children:(0,$.jsx)(v,{compact:!0})}),y===`team`&&h?.hasTeams&&(0,$.jsx)(`div`,{className:`border-t border-border/30 bg-surface px-3 py-2 max-h-[280px] overflow-y-auto`,children:(0,$.jsx)(xr,{teamNames:h.teamNames,messages:g??[]})}),y===`usage`&&ce&&(0,$.jsx)(vr,{usage:t,visible:!0,onClose:()=>x(null),onReload:r,loading:n,lastFetchedAt:i})]})}function kr({metadata:e,tabId:t}){let[n,r]=(0,Q.useState)(e?.sessionId??null),[i,a]=(0,Q.useState)(e?.providerId??`claude`),[o,s]=(0,Q.useState)([]),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)([]),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(e?.permissionMode??void 0),E=(0,Q.useRef)(null),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(null),j=(0,Q.useRef)(0),M=e?.projectName??``,N=G(e=>e.updateTab),P=re(e=>e.version),{usageInfo:F,usageLoading:I,lastFetchedAt:L,refreshUsage:R}=_t(M,i);(0,Q.useEffect)(()=>{w||se().then(e=>{let t=e.providers[e.default_provider??`claude`];T(t?.permission_mode??`bypassPermissions`)}).catch(()=>{})},[]),(0,Q.useEffect)(()=>{!t||!n||N(t,{metadata:{...e,sessionId:n,providerId:i,permissionMode:w}})},[n,i,w]);let{messages:ee,messagesLoading:te,isStreaming:z,phase:B,isReconnecting:ne,connectingElapsed:H,pendingApproval:ie,contextWindowPct:U,compactStatus:ae,statusMessage:oe,sessionTitle:ce,sendMessage:J,respondToApproval:Y,cancelStreaming:le,reconnect:ue,refetchMessages:de,isConnected:X,teamActivity:fe,teamMessages:pe,markTeamRead:me}=ht(n,i,M);(0,Q.useEffect)(()=>{if(X&&E.current){let{content:e,permissionMode:t}=E.current;E.current=null,J(e,{permissionMode:t})}},[X,J]),(0,Q.useEffect)(()=>{if(!n||!t)return;let e=()=>{if(document.hidden)return;let{panels:e,focusedPanelId:r}=W.getState();e[r]?.activeTabId===t&&ke.getState().clearForSession(n)};e(),document.addEventListener(`visibilitychange`,e);let r=W.subscribe(e);return()=>{document.removeEventListener(`visibilitychange`,e),r()}},[n,t]),(0,Q.useEffect)(()=>{t&&ce&&N(t,{title:ce})},[ce]);let[he,ge]=(0,Q.useState)(e?.pendingMessage);(0,Q.useEffect)(()=>{he&&X&&n&&t&&N(t,{metadata:{...e,pendingMessage:void 0}})},[X,n]),(0,Q.useCallback)(()=>{G.getState().openTab({type:`chat`,title:`AI Chat`,metadata:{projectName:M,providerId:i},projectId:M||null,closable:!0})},[M,i]);let _e=(0,Q.useCallback)(e=>{r(e.id),a(e.providerId),t&&N(t,{title:e.title||`Chat`})},[t,N]),ve=(0,Q.useCallback)(async(e,t)=>{if(!(!n||!M))try{let{api:r,projectUrl:a}=await V(async()=>{let{api:e,projectUrl:t}=await import(`./api-client-o_6TmLGC.js`).then(e=>e.n);return{api:e,projectUrl:t}},__vite__mapDeps([16,1])),o=await r.post(`${a(M)}/chat/sessions/${n}/fork?providerId=${i}`,{messageId:t});G.getState().openTab({type:`chat`,title:`Fork: ${e.slice(0,30)}`,metadata:{projectName:M,sessionId:o.id,providerId:i,pendingMessage:e},projectId:M||null,closable:!0})}catch(e){console.error(`Fork failed:`,e)}},[n,M,i]),ye=(0,Q.useCallback)((e,t)=>{if(t.length===0)return e;let n=t.filter(e=>e.serverPath).map(e=>e.serverPath).join(`
|
|
10
|
+
`);return n?(t.length===1?`[Attached file: ${n}]\n\n`:`[Attached files:\n${n}\n]\n\n`)+e:e},[]),be=(0,Q.useCallback)(async(e,t=[],o)=>{let s=ye(e,t);if(s.trim()){if(!n)try{let t=M,n=await q.post(`${K(t)}/chat/sessions`,{providerId:i,title:e.slice(0,50)});r(n.id),a(n.providerId),E.current={content:s,permissionMode:w};return}catch(e){console.error(`Failed to create session:`,e);return}J(s,{permissionMode:w,priority:o})}},[n,i,M,J,ye,w]),xe=(0,Q.useCallback)((e,t)=>{l(e),d(t),(!e||!t)&&p(!1)},[]),Se=(0,Q.useCallback)(e=>{h(e),l(!1),d(``),setTimeout(()=>h(null),50)},[]),Ce=(0,Q.useCallback)(()=>{l(!1),d(``)},[]),we=(0,Q.useCallback)((e,t)=>{y(e),x(t)},[]),Te=(0,Q.useCallback)(e=>{C(e),y(!1),x(``),setTimeout(()=>C(null),50)},[]),Ee=(0,Q.useCallback)(()=>{y(!1),x(``)},[]);return(0,$.jsxs)(`div`,{className:`flex flex-col h-full relative`,onDragEnter:(0,Q.useCallback)(e=>{e.preventDefault(),j.current++,e.dataTransfer.types.includes(`Files`)&&O(!0)},[]),onDragLeave:(0,Q.useCallback)(e=>{e.preventDefault(),j.current--,j.current===0&&O(!1)},[]),onDragOver:(0,Q.useCallback)(e=>{e.preventDefault()},[]),onDrop:(0,Q.useCallback)(e=>{e.preventDefault(),j.current=0,O(!1);let t=Array.from(e.dataTransfer.files);t.length>0&&(A(t),setTimeout(()=>A(null),100))},[]),children:[D&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm border-2 border-dashed border-primary rounded-lg pointer-events-none`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-primary`,children:[(0,$.jsx)(Ae,{className:`size-8`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:`Drop files to attach`})]})}),ne&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/60 backdrop-blur-sm`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Z,{className:`size-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Reconnecting...`})]})}),(0,$.jsx)(Xt,{messages:ee,messagesLoading:te,pendingApproval:ie,onApprovalResponse:Y,isStreaming:z,phase:B,connectingElapsed:H,statusMessage:oe,compactStatus:ae,projectName:M,onFork:z?void 0:ve,onSelectSession:_e}),(0,$.jsxs)(`div`,{className:`border-t border-border bg-background shrink-0`,children:[(0,$.jsx)(Or,{projectName:M,usageInfo:F,usageLoading:I,refreshUsage:R,lastFetchedAt:L,sessionId:n,providerId:i,onSelectSession:_e,onBugReport:n?()=>Me(P,{sessionId:n,projectName:M}):void 0,isConnected:X,onReconnect:()=>{X||ue(),de()},teamActivity:fe,teamMessages:pe,onTeamOpen:me}),(0,$.jsx)(Gn,{items:o,filter:u,onSelect:Se,onClose:Ce,visible:c,ranked:f}),(0,$.jsx)(Bn,{items:g,filter:b,onSelect:Te,onClose:Ee,visible:v}),(0,$.jsx)(Vn,{onSend:(e,t,n)=>{he&&ge(void 0),be(e,t,n)},isStreaming:z,onCancel:le,autoFocus:!e?.sessionId||!!he,initialValue:he,projectName:M,onSlashStateChange:xe,onSlashItemsLoaded:(e,t)=>{s(e),t!==void 0&&p(t)},slashSelected:m,onFileStateChange:we,onFileItemsLoaded:_,fileSelected:S,externalFiles:k,permissionMode:w,onModeChange:T,providerId:i,onProviderChange:n?void 0:a})]})]})}export{kr as ChatTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./createLucideIcon-BjHrJDVb.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./createLucideIcon-BjHrJDVb.js";var t=e(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]);export{t};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-ocvtw_4F.js","assets/rolldown-runtime-FhOqtrmT.js","assets/index-D7PJ14mf.js","assets/vendor-mermaid-B2SLgECS.js","assets/vendor-ui-B-T_damt.js","assets/vendor-markdown-0Mxgxy0L.js","assets/input-CHRMley8.js","assets/utils-ChWX7pZv.js","assets/createLucideIcon-BjHrJDVb.js","assets/x-DlFGzN8d.js","assets/scroll-area-DwWF9FpN.js","assets/ai-settings-section-LMO_cfIW.js","assets/dist-C5IgeqrV.js","assets/plus-51UQ45rf.js","assets/refresh-cw-CSFrDtiu.js","assets/trash-2-CJYoLw7Q.js","assets/api-client-o_6TmLGC.js","assets/api-settings-CoKe_BdR.js","assets/chevron-right-BzAdxJRG.js","assets/database-D4DIhgi-.js","assets/react-GqWghJ-L.js","assets/extension-store-3yZYn07W.js","assets/keybindings-store-BAuymsWd.js","assets/tab-store-DZbiYk7y.js","assets/project-store-Ciq-cK1O.js","assets/settings-store-B470PCWf.js","assets/index-BZ4G-2BK.css","assets/csv-preview-BizIVMyb.js","assets/lib-D_kRA9p6.js","assets/arrow-up-Dtrfv490.js","assets/csv-parser--2WJNgS7.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import"./vendor-ui-B-T_damt.js";import{t as r}from"./createLucideIcon-BjHrJDVb.js";import"./scroll-area-DwWF9FpN.js";import{t as i}from"./chevron-right-BzAdxJRG.js";import{a,l as o,n as s,o as c,r as l,s as ee,t as u}from"./input-CHRMley8.js";import{t as d}from"./code-CuravVys.js";import{t as te}from"./database-D4DIhgi-.js";import{n as f,r as p}from"./x-DlFGzN8d.js";import{t as m}from"./table-Dq575bPF.js";import{t as h}from"./text-wrap-Cn6BNQfq.js";import{G as g}from"./vendor-mermaid-B2SLgECS.js";import{n as _}from"./settings-store-B470PCWf.js";import{t as v}from"./utils-ChWX7pZv.js";import{n as ne,t as y}from"./tab-store-DZbiYk7y.js";import{i as b,r as x,t as S}from"./api-client-o_6TmLGC.js";import{n as re}from"./project-store-Ciq-cK1O.js";import{A as C,F as w,I as T,L as ie,M as ae,N as E,P as D,R as O,a as oe,c as k,d as A,f as j,g as M,h as N,l as P,m as F,o as se,p as ce,u as I,w as le,y as ue}from"./index-D7PJ14mf.js";import{n as de,t as fe}from"./use-monaco-theme-OY18iXNi.js";import{n as pe,t as me}from"./sql-completion-provider-C3cq9j99.js";var he=r(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),L=e(n(),1),R=t(),ge={ts:T,tsx:T,js:T,jsx:T,py:T,rs:T,go:T,html:T,css:T,scss:T,json:ie,md:w,txt:w,yaml:D,yml:D};function z(e,t){return t?ae:ge[e.split(`.`).pop()?.toLowerCase()??``]??E}function _e(e,t){let n=[],r=e;for(let e=0;e<t.length;e++){let i=t[e],a=t.slice(0,e+1).join(`/`),o=r.find(e=>e.name===i);if(n.push({name:i,fullPath:a,node:o??null,siblings:r}),o?.children)r=o.children;else{for(let r=e+1;r<t.length;r++)n.push({name:t[r],fullPath:t.slice(0,r+1).join(`/`),node:null,siblings:[]});break}}return n}function B(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}function ve({filePath:e,projectName:t,tabId:n,className:r}){let a=ue(e=>e.tree),{updateTab:o,openTab:s}=y(N(e=>({updateTab:e.updateTab,openTab:e.openTab}))),c=(0,L.useRef)(null),l=(0,L.useMemo)(()=>_e(a,e.split(`/`).filter(Boolean)),[a,e]);(0,L.useEffect)(()=>{c.current&&(c.current.scrollLeft=c.current.scrollWidth)},[l]);function ee(e,r){let i=v(e);r.metaKey||r.ctrlKey?s({type:`editor`,title:i,metadata:{filePath:e,projectName:t},projectId:t,closable:!0}):o(n,{title:i,metadata:{filePath:e,projectName:t}})}return(0,R.jsx)(`div`,{ref:c,className:r,children:l.map((e,n)=>(0,R.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[n>0&&(0,R.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),e.siblings.length>0?(0,R.jsx)(V,{segment:e,isLast:n===l.length-1,projectName:t,onFileClick:ee}):(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground px-1 py-0.5`,children:e.name})]},e.fullPath))})}function V({segment:e,isLast:t,projectName:n,onFileClick:r}){let i=(0,L.useMemo)(()=>B(e.siblings),[e.siblings]);return(0,R.jsxs)(k,{children:[(0,R.jsx)(F,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,className:`text-xs px-1 py-0.5 rounded hover:bg-muted transition-colors truncate max-w-[120px] ${t?`text-foreground font-medium`:`text-muted-foreground`}`,children:e.name})}),(0,R.jsx)(P,{align:`start`,className:`max-h-[300px] p-1`,children:i.map(t=>(0,R.jsx)(H,{node:t,projectName:n,activePath:e.fullPath,onFileClick:r},t.path))})]})}function H({node:e,projectName:t,activePath:n,onFileClick:r}){let i=z(e.name,e.type===`directory`),a=e.path===n;return e.type===`directory`&&e.children&&e.children.length>0?(0,R.jsxs)(A,{children:[(0,R.jsxs)(ce,{className:`text-xs gap-1.5 ${a?`bg-muted`:``}`,children:[(0,R.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,R.jsx)(j,{className:`max-h-[300px] overflow-y-auto p-1`,children:B(e.children).map(e=>(0,R.jsx)(H,{node:e,projectName:t,activePath:n,onFileClick:r},e.path))})]}):(0,R.jsxs)(I,{className:`text-xs gap-1.5 cursor-pointer ${a?`bg-muted`:``}`,onSelect:e=>{},onClick:t=>{e.type!==`directory`&&r(e.path,t)},children:[(0,R.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]})}function U({active:e,onClick:t,icon:n,label:r}){return(0,R.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,R.jsx)(n,{className:`size-3`}),(0,R.jsx)(`span`,{className:`hidden sm:inline`,children:r})]})}function ye({ext:e,mdMode:t,onMdModeChange:n,csvMode:r,onCsvModeChange:i,wordWrap:a,onToggleWordWrap:o,filePath:s,projectName:c,className:l}){return(0,R.jsxs)(`div`,{className:l,children:[(e===`md`||e===`mdx`)&&n&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(U,{active:t===`edit`,onClick:()=>n(`edit`),icon:d,label:`Edit`}),(0,R.jsx)(U,{active:t===`preview`,onClick:()=>n(`preview`),icon:f,label:`Preview`})]}),e===`csv`&&i&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(U,{active:r===`table`,onClick:()=>i(`table`),icon:m,label:`Table`}),(0,R.jsx)(U,{active:r===`raw`,onClick:()=>i(`raw`),icon:d,label:`Raw`})]}),(0,R.jsx)(U,{active:a,onClick:o,icon:h,label:`Wrap`}),s&&c&&(0,R.jsx)(U,{active:!1,onClick:()=>M(c,s),icon:p,label:`Download`})]})}function be({open:e,defaultName:t,content:n,onSave:r,onCancel:i}){let[d,te]=(0,L.useState)(t),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(``),g=re(e=>e.activeProject),_=(0,L.useCallback)(()=>{let e=d.trim();if(!e){h(`Filename cannot be empty`);return}if(/[/\\]/.test(e)){h(`Filename cannot contain / or \\`);return}h(``),p(!0)},[d]),v=(0,L.useCallback)(e=>{let t=e.includes(`\\`)?`\\`:`/`;r(e.endsWith(t)?`${e}${d.trim()}`:`${e}${t}${d.trim()}`,n)},[d,n,r]);return f?(0,R.jsx)(se,{open:!0,mode:`folder`,root:g?.path,title:`Save "${d.trim()}" to...`,onSelect:v,onCancel:()=>p(!1)}):(0,R.jsx)(s,{open:e,onOpenChange:e=>{e||i()},children:(0,R.jsxs)(l,{className:`sm:max-w-md`,children:[(0,R.jsx)(c,{children:(0,R.jsx)(ee,{children:`Save As`})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,R.jsx)(`label`,{className:`text-sm text-muted-foreground`,children:`Filename`}),(0,R.jsx)(u,{value:d,onChange:e=>{te(e.target.value),h(``)},onKeyDown:e=>{e.key===`Enter`&&_()},placeholder:`e.g. my-file.ts`,autoFocus:!0}),m&&(0,R.jsx)(`p`,{className:`text-xs text-destructive`,children:m})]}),(0,R.jsxs)(a,{children:[(0,R.jsx)(o,{variant:`outline`,onClick:i,children:`Cancel`}),(0,R.jsx)(o,{onClick:_,children:`Choose Folder...`})]})]})})}var xe=(0,L.lazy)(()=>g(()=>import(`./markdown-renderer-ocvtw_4F.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]))),Se=(0,L.lazy)(()=>g(()=>import(`./csv-preview-BizIVMyb.js`).then(e=>({default:e.CsvPreview})),__vite__mapDeps([27,1,4,5,28,8,29,30]))),Ce=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),we=new Set([`db`,`sqlite`,`sqlite3`]);function Te(e){return e.split(`.`).pop()?.toLowerCase()??``}function Ee(e){return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,html:`html`,css:`css`,scss:`scss`,json:`json`,md:`markdown`,mdx:`markdown`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`,sql:`sql`}[Te(e)]??`plaintext`}var W=(0,L.memo)(function({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,i=e?.inlineContent,a=e?.inlineLanguage,[o,s]=(0,L.useState)(i??null),[c,l]=(0,L.useState)(`utf-8`),[ee,u]=(0,L.useState)(!0),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(!1),h=(0,L.useRef)(null),g=(0,L.useRef)(``),x=(0,L.useRef)(null),{tabs:re,updateTab:w}=y(N(e=>({tabs:e.tabs,updateTab:e.updateTab}))),{wordWrap:T,toggleWordWrap:ie}=_(N(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),ae=fe(),E=e?.isUntitled===!0,D=e?.unsavedContent,[O,k]=(0,L.useState)(!1),A=re.find(e=>e.id===t),j=n?Te(n):``,M=Ce.has(j),P=j===`pdf`,F=we.has(j),se=j===`md`||j===`mdx`,ce=j===`csv`,I=j===`sql`,[ue,ge]=(0,L.useState)(`preview`),[z,_e]=(0,L.useState)(`table`),{connections:B,cachedTables:V,refreshTables:H}=oe(),[U,xe]=(0,L.useState)(()=>{if(!I||!n)return null;let e=localStorage.getItem(`ppm:sql-conn:${n}`);return e?Number(e):null}),W=(0,L.useRef)(null),G=(0,L.useRef)(null),K=(0,L.useMemo)(()=>B.find(e=>e.id===U)??null,[B,U]),Ae=i!=null&&(a===`json`||a===`xml`),[q,J]=(0,L.useState)(!1),je=(0,L.useCallback)(()=>{if(i)if(q)s(i),J(!1);else{let e=i.trimStart();if(a===`json`)try{s(JSON.stringify(JSON.parse(e),null,2)),J(!0)}catch{}else if(a===`xml`){let t=0;s(e.replace(/(>)(<)(\/*)/g,`$1
|
|
3
|
+
$2$3`).split(`
|
|
4
|
+
`).map(e=>{let n=e.trim();n.startsWith(`</`)&&(t=Math.max(0,t-1));let r=` `.repeat(t)+n;return n.startsWith(`<`)&&!n.startsWith(`</`)&&!n.endsWith(`/>`)&&!n.includes(`</`)&&t++,r}).join(`
|
|
5
|
+
`)),J(!0)}}},[i,a,q]),Me=(0,L.useCallback)(e=>{xe(e),n&&localStorage.setItem(`ppm:sql-conn:${n}`,String(e)),H(e).catch(()=>{})},[n,H]),Y=(0,L.useMemo)(()=>{if(!I||!U)return;let e=(V.get(U)??[]).map(e=>({name:e.tableName,schema:e.schemaName}));if(e.length!==0)return{tables:e,getColumns:async(e,t)=>S.get(`/api/db/connections/${U}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[I,U,V]);(0,L.useEffect)(()=>{if(!(!W.current||!Y))return G.current?.dispose(),me(),G.current=W.current.languages.registerCompletionItemProvider(`sql`,pe(W.current,Y)),()=>{G.current?.dispose()}},[Y]);let Ne=y(e=>e.openTab),X=(0,L.useCallback)(e=>{K&&Ne({type:`database`,title:`${K.name} · Query`,projectId:null,closable:!0,metadata:{connectionId:K.id,connectionName:K.name,dbType:K.type,initialSql:e}})},[K,Ne]),Pe=(0,L.useCallback)(()=>{if(!x.current||!K)return;let e=x.current,t=e.getSelection();X(t&&!t.isEmpty()?e.getModel()?.getValueInRange(t)??e.getValue():e.getValue())},[K,X]),Z=(0,L.useRef)([]),Fe=(0,L.useRef)(X);Fe.current=X,(0,L.useEffect)(()=>()=>{Z.current.forEach(e=>e.dispose()),Z.current=[]},[]),(0,L.useEffect)(()=>{F&&t&&w(t,{type:`sqlite`})},[F,t,w]);let Q=n?/^(\/|[A-Za-z]:[/\\])/.test(n):!1;(0,L.useEffect)(()=>{if(i!=null){u(!1);return}if(E){s(D??``),g.current=D??``,u(!1),D&&m(!0);return}if(!n||!Q&&!r)return;if(M||P){u(!1);return}u(!0),f(null);let e=Q?`/api/fs/read?path=${encodeURIComponent(n)}`:`${b(r)}/files/read?path=${encodeURIComponent(n)}`;return S.get(e).then(e=>{s(e.content),e.encoding&&l(e.encoding),g.current=e.content,u(!1)}).catch(e=>{f(e instanceof Error?e.message:`Failed to load file`),u(!1)}),()=>{h.current&&clearTimeout(h.current)}},[n,r,M,P,Q,E]),(0,L.useEffect)(()=>{if(!A)return;let t=E?`Untitled-${e?.untitledNumber??1}`:n?v(n):`Untitled`,r=p?`${t} \u25CF`:t;A.title!==r&&w(A.id,{title:r})},[p]);let Ie=(0,L.useCallback)(async e=>{if(n&&!(!Q&&!r))try{Q?await S.put(`/api/fs/write`,{path:n,content:e}):await S.put(`${b(r)}/files/write`,{path:n,content:e}),m(!1)}catch{}},[n,r,Q]);function Le(n){let r=n??``;s(r),g.current=r,m(!0),h.current&&clearTimeout(h.current),E?h.current=setTimeout(()=>{t&&w(t,{metadata:{...e,unsavedContent:g.current}})},2e3):h.current=setTimeout(()=>Ie(g.current),1e3)}let Re=(0,L.useCallback)(async(e,n)=>{try{if(h.current&&clearTimeout(h.current),await S.put(`/api/fs/write`,{path:e,content:n}),t){let{closeTab:n,openTab:r}=ne.getState();n(t),r({type:`editor`,title:v(e),projectId:null,metadata:{filePath:e},closable:!0})}m(!1),k(!1)}catch{}},[t]),$=e?.lineNumber,ze=(0,L.useCallback)((e,t)=>{if(x.current=e,W.current=t,$&&$>0&&setTimeout(()=>{e.revealLineInCenter($),e.setPosition({lineNumber:$,column:1}),e.focus()},100),E&&e.addCommand(t.KeyMod.CtrlCmd|t.KeyCode.KeyS,()=>k(!0)),e.addCommand(t.KeyMod.Alt|t.KeyCode.KeyZ,()=>_.getState().toggleWordWrap()),t.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),t.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),Y&&(G.current?.dispose(),G.current=t.languages.registerCompletionItemProvider(`sql`,pe(t,Y))),I){Z.current.forEach(e=>e.dispose()),Z.current=[];let n=e.getModel(),r=e.addCommand(0,(e,t)=>{t&&Fe.current(t)});if(r&&n){let e=t.languages.registerCodeLensProvider(`sql`,{provideCodeLenses:e=>{if(e!==n)return{lenses:[],dispose:()=>{}};let t=[],i=e.getValue().split(`
|
|
6
|
+
`),a=-1,o=[],s=!1,c=(e,n)=>{let i=n.trim();!i||i.startsWith(`--`)||t.push({range:{startLineNumber:e,startColumn:1,endLineNumber:e,endColumn:1},command:{id:r,title:`▷ Run`,arguments:[i]}})};for(let e=0;e<i.length;e++){let t=i[e].trim();if(a===-1){if(!t||t.startsWith(`--`))continue;a=e+1,o=[]}o.push(i[e]),(t.match(/\$\$/g)||[]).length%2==1&&(s=!s),!s&&t.endsWith(`;`)&&(c(a,o.join(`
|
|
7
|
+
`)),a=-1,o=[])}return a>0&&o.join(``).trim()&&c(a,o.join(`
|
|
8
|
+
`)),{lenses:t,dispose:()=>{}}}});Z.current.push(e)}}},[Y]);if(!i&&!E&&(!n||!Q&&!r))return(0,R.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`No file selected.`});if(ee)return(0,R.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,R.jsx)(C,{className:`size-5 animate-spin`}),(0,R.jsx)(`span`,{className:`text-sm`,children:`Loading file...`})]});if(d)return(0,R.jsx)(`div`,{className:`flex items-center justify-center h-full text-error text-sm`,children:d});if(M)return(0,R.jsx)(Oe,{filePath:n,projectName:r});if(P)return(0,R.jsx)(ke,{filePath:n,projectName:r});if(c===`base64`)return(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,R.jsx)(he,{className:`size-10 text-text-subtle`}),(0,R.jsx)(`p`,{className:`text-sm`,children:`This file is a binary format and cannot be displayed.`}),(0,R.jsx)(`p`,{className:`text-xs text-text-subtle`,children:n})]});let Be=I?(0,R.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1 px-2 border-l border-border`,children:[(0,R.jsx)(te,{className:`size-3 text-muted-foreground`}),(0,R.jsxs)(`select`,{value:U??``,onChange:e=>{let t=Number(e.target.value);t&&Me(t)},className:`h-5 text-[10px] bg-transparent border border-border rounded px-1 text-foreground outline-none max-w-[140px]`,title:`Select connection for autocomplete`,children:[(0,R.jsx)(`option`,{value:``,children:`Connection…`}),B.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,R.jsx)(`button`,{type:`button`,onClick:Pe,disabled:!K,className:`p-0.5 rounded text-muted-foreground hover:text-primary disabled:opacity-30 transition-colors`,title:`Run all in DB Viewer`,children:(0,R.jsx)(le,{className:`size-3.5`})})]}):null;return(0,R.jsxs)(`div`,{className:`flex flex-col h-full w-full overflow-hidden`,children:[i!=null&&Ae&&(0,R.jsx)(`div`,{className:`flex items-center h-7 border-b border-border bg-background shrink-0 px-2 gap-2`,children:(0,R.jsx)(`button`,{type:`button`,onClick:je,className:`text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted transition-colors text-foreground`,children:q?`Raw`:`Beautify`})}),n&&r&&t&&(0,R.jsxs)(`div`,{className:`hidden md:flex items-center h-7 border-b border-border bg-background shrink-0`,children:[(0,R.jsx)(ve,{filePath:n,projectName:r,tabId:t,className:`flex items-center flex-1 min-w-0 overflow-x-auto scrollbar-none px-2 gap-0.5`}),Be,(0,R.jsx)(ye,{ext:j,mdMode:ue,onMdModeChange:ge,csvMode:z,onCsvModeChange:_e,wordWrap:T,onToggleWordWrap:ie,filePath:n,projectName:r,className:`shrink-0 flex items-center gap-1 px-2`})]}),I&&(!r||!t)&&(0,R.jsxs)(`div`,{className:`hidden md:flex items-center h-7 border-b border-border bg-background shrink-0 px-2`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1`,children:n?v(n):`SQL`}),Be]}),ce&&z===`table`?(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,R.jsx)(C,{className:`size-5 animate-spin text-text-subtle`})}),children:(0,R.jsx)(Se,{content:o??``,onContentChange:Le,wordWrap:T})}):se&&ue===`preview`?(0,R.jsx)(De,{content:o??``}):(0,R.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,R.jsx)(de,{height:`100%`,language:a??Ee(n??``),value:o??``,onChange:i==null?Le:void 0,onMount:ze,theme:ae,options:{fontSize:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,wordWrap:T?`on`:`off`,minimap:{enabled:!1},scrollBeyondLastLine:!1,automaticLayout:!0,lineNumbers:`on`,folding:!0,bracketPairColorization:{enabled:!0},readOnly:i!=null},loading:(0,R.jsx)(C,{className:`size-5 animate-spin text-text-subtle`})})}),O&&(0,R.jsx)(be,{open:O,defaultName:`Untitled-${e?.untitledNumber??1}`,content:g.current,onSave:Re,onCancel:()=>k(!1)})]})});function De({content:e}){return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded m-4`}),children:(0,R.jsx)(xe,{content:e,className:`flex-1 overflow-auto p-4`})})}function Oe({filePath:e,projectName:t}){let[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{let n,i=`${b(t)}/files/raw?path=${encodeURIComponent(e)}`,o=x();return fetch(i,{headers:o?{Authorization:`Bearer ${o}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(e=>{let t=URL.createObjectURL(e);n=t,r(t)}).catch(()=>a(!0)),()=>{n&&URL.revokeObjectURL(n)}},[e,t]),i?(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,R.jsx)(he,{className:`size-10 text-text-subtle`}),(0,R.jsx)(`p`,{className:`text-sm`,children:`Failed to load image.`})]}):n?(0,R.jsx)(`div`,{className:`flex items-center justify-center h-full p-4 bg-surface overflow-auto`,children:(0,R.jsx)(`img`,{src:n,alt:e,className:`max-w-full max-h-full object-contain`})}):(0,R.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,R.jsx)(C,{className:`size-5 animate-spin text-text-subtle`})})}function ke({filePath:e,projectName:t}){let[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(!1);(0,L.useEffect)(()=>{let n,i=`${b(t)}/files/raw?path=${encodeURIComponent(e)}`,o=x();return fetch(i,{headers:o?{Authorization:`Bearer ${o}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(e=>{let t=URL.createObjectURL(new Blob([e],{type:`application/pdf`}));n=t,r(t)}).catch(()=>a(!0)),()=>{n&&URL.revokeObjectURL(n)}},[e,t]);let o=(0,L.useCallback)(()=>{n&&window.open(n,`_blank`)},[n]);return i?(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,R.jsx)(he,{className:`size-10 text-text-subtle`}),(0,R.jsx)(`p`,{className:`text-sm`,children:`Failed to load PDF.`})]}):n?(0,R.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,R.jsx)(`span`,{className:`text-xs text-text-secondary truncate`,children:e}),(0,R.jsxs)(`button`,{onClick:o,className:`flex items-center gap-1 text-xs text-text-secondary hover:text-text-primary transition-colors`,children:[(0,R.jsx)(O,{className:`size-3`}),` Open in new tab`]})]}),(0,R.jsx)(`iframe`,{src:n,title:e,className:`flex-1 w-full border-none`})]}):(0,R.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,R.jsx)(C,{className:`size-5 animate-spin text-text-subtle`})})}export{W as CodeEditor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./createLucideIcon-BjHrJDVb.js";var t=e(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]);export{t};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import"./vendor-mermaid-B2SLgECS.js";import{n as r}from"./settings-store-B470PCWf.js";import{i,t as a}from"./api-client-o_6TmLGC.js";import{A as o,h as s}from"./index-D7PJ14mf.js";import{n as c,t as l}from"./use-monaco-theme-OY18iXNi.js";var u=e(n(),1),d=t();function f(e){return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,html:`html`,css:`css`,scss:`scss`,json:`json`,md:`markdown`,mdx:`markdown`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`,go:`go`,rs:`rust`,java:`java`,rb:`ruby`,php:`php`,swift:`swift`,sql:`sql`,xml:`xml`,toml:`toml`}[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function p(e){let t=e.split(`
|
|
2
|
+
`),n=[],r=0,i=0;for(;r<t.length;){let e=t[r];if(e.startsWith(`<<<<<<<`)){let a=r,o=e.substring(7).trim(),s=[];for(r++;r<t.length&&!t[r].startsWith(`=======`);)s.push(t[r]),r++;if(r>=t.length)break;let c=r,l=[];for(r++;r<t.length&&!t[r].startsWith(`>>>>>>>`);)l.push(t[r]),r++;if(r>=t.length)break;let u=t[r].substring(7).trim();n.push({id:i++,startLine:a+1,separatorLine:c+1,endLine:r+1,currentContent:s.join(`
|
|
3
|
+
`),incomingContent:l.join(`
|
|
4
|
+
`),currentLabel:o,incomingLabel:u})}r++}return n}function m({metadata:e}){let t=e?.filePath,n=e?.projectName,[m,g]=(0,u.useState)(null),[_,v]=(0,u.useState)(!0),[y,b]=(0,u.useState)(null),[x,S]=(0,u.useState)(0),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=(0,u.useRef)([]),E=(0,u.useRef)(null),{wordWrap:D}=r(s(e=>({wordWrap:e.wordWrap}))),O=l(),k=(0,u.useRef)(null),[A,j]=(0,u.useState)();(0,u.useEffect)(()=>{let e=k.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&j(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[]),(0,u.useEffect)(()=>{!t||!n||(v(!0),a.get(`${i(n)}/files/read?path=${encodeURIComponent(t)}`).then(e=>{g(e.content),v(!1)}).catch(e=>{b(e.message||`Failed to load file`),v(!1)}))},[t,n]);let M=(0,u.useCallback)(()=>{let e=C.current,t=w.current;if(!e||!t)return;let n=p(e.getModel()?.getValue()||``);S(n.length);for(let t of T.current)e.removeContentWidget(t);if(T.current=[],E.current&&E.current.clear(),n.length===0)return;let r=[];for(let e of n)r.push({range:new t.Range(e.startLine,1,e.startLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-current`}}),r.push({range:new t.Range(e.separatorLine,1,e.separatorLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`}}),r.push({range:new t.Range(e.endLine,1,e.endLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-incoming`}}),e.separatorLine-e.startLine>1&&r.push({range:new t.Range(e.startLine+1,1,e.separatorLine-1,1),options:{isWholeLine:!0,className:`conflict-current-content`}}),e.endLine-e.separatorLine>1&&r.push({range:new t.Range(e.separatorLine+1,1,e.endLine-1,1),options:{isWholeLine:!0,className:`conflict-incoming-content`}});E.current=e.createDecorationsCollection(r);for(let r of n){let n=`conflict-widget-${r.id}`,i=document.createElement(`div`);i.className=`conflict-actions`,i.innerHTML=`<span class="conflict-label">Current Change (${h(r.currentLabel||`HEAD`)})</span><button class="conflict-btn conflict-btn-current" data-action="current">Accept Current</button><button class="conflict-btn conflict-btn-incoming" data-action="incoming">Accept Incoming</button><button class="conflict-btn conflict-btn-both" data-action="both">Accept Both</button>`,i.addEventListener(`click`,e=>{let t=e.target.closest(`[data-action]`);if(!t)return;let n=t.getAttribute(`data-action`);N(r.id,n)});let a={getId:()=>n,getDomNode:()=>i,getPosition:()=>({position:{lineNumber:r.startLine,column:1},preference:[t.editor.ContentWidgetPositionPreference.ABOVE]})};e.addContentWidget(a),T.current.push(a)}},[]),N=(0,u.useCallback)((e,t)=>{let n=C.current,r=w.current;if(!n||!r)return;let i=n.getModel();if(!i)return;let a=p(i.getValue()).find(t=>t.id===e);if(!a)return;let o;switch(t){case`current`:o=a.currentContent;break;case`incoming`:o=a.incomingContent;break;case`both`:o=a.currentContent+`
|
|
5
|
+
`+a.incomingContent;break}let s=new r.Range(a.startLine,1,a.endLine+1,1);i.pushEditOperations([],[{range:s,text:o+`
|
|
6
|
+
`}],()=>null),P(i.getValue()),setTimeout(()=>M(),50)},[M]),P=(0,u.useCallback)(async e=>{if(!(!t||!n))try{await a.put(`${i(n)}/files/write`,{path:t,content:e})}catch(e){console.error(`[conflict-editor] save failed:`,e)}},[t,n]),F=(e,t)=>{C.current=e,w.current=t;let n=e.getDomNode()?.ownerDocument??document;if(!n.getElementById(`conflict-editor-styles`)){let e=n.createElement(`style`);e.id=`conflict-editor-styles`,e.textContent=`
|
|
7
|
+
.conflict-current-content { background: rgba(34, 197, 94, 0.1) !important; }
|
|
8
|
+
.conflict-incoming-content { background: rgba(59, 130, 246, 0.1) !important; }
|
|
9
|
+
.conflict-marker-line { background: rgba(100, 100, 100, 0.15) !important; font-style: italic; }
|
|
10
|
+
.conflict-glyph-current { background: #22c55e !important; }
|
|
11
|
+
.conflict-glyph-incoming { background: #3b82f6 !important; }
|
|
12
|
+
.conflict-actions { display: flex; gap: 8px; align-items: center; padding: 2px 0; font-size: 12px; font-family: system-ui; }
|
|
13
|
+
.conflict-label { color: #22c55e; font-weight: 600; margin-right: 8px; }
|
|
14
|
+
.conflict-btn { padding: 1px 8px; border-radius: 3px; border: none; cursor: pointer; font-size: 11px; opacity: 0.9; }
|
|
15
|
+
.conflict-btn:hover { opacity: 1; }
|
|
16
|
+
.conflict-btn-current { color: #22c55e; background: rgba(34, 197, 94, 0.15); }
|
|
17
|
+
.conflict-btn-incoming { color: #3b82f6; background: rgba(59, 130, 246, 0.15); }
|
|
18
|
+
.conflict-btn-both { color: #a855f7; background: rgba(168, 85, 247, 0.15); }
|
|
19
|
+
`,n.head?.appendChild(e)}M()},I=t?.split(/[\\/]/).pop()??`unknown`,L=f(I);return _?(0,d.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,d.jsx)(o,{className:`size-6 animate-spin text-primary`})}):y?(0,d.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive`,children:y}):(0,d.jsxs)(`div`,{className:`h-full w-full flex flex-col`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 text-xs border-b border-border bg-muted/50 flex-shrink-0`,children:[(0,d.jsx)(`span`,{className:`font-medium`,children:I}),(0,d.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}),x>0?(0,d.jsxs)(`span`,{className:`text-destructive font-medium`,children:[x,` conflict`,x===1?``:`s`,` remaining`]}):(0,d.jsx)(`span`,{className:`text-green-500 font-medium`,children:`All conflicts resolved`})]}),(0,d.jsx)(`div`,{ref:k,className:`flex-1 min-h-0`,children:m!==null&&A&&(0,d.jsx)(c,{height:A,language:L,value:m,onMount:F,theme:O,options:{fontSize:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,wordWrap:D?`on`:`off`,glyphMargin:!0,readOnly:!1,automaticLayout:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1}}})})]})}function h(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}export{m as ConflictEditor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{x as t}from"./vendor-markdown-0Mxgxy0L.js";var n=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),r=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),i=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),a=e=>{let t=i(e);return t.charAt(0).toUpperCase()+t.slice(1)},o={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},s=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},c=e(t()),l=(0,c.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:r=2,absoluteStrokeWidth:i,className:a=``,children:l,iconNode:u,...d},f)=>(0,c.createElement)(`svg`,{ref:f,...o,width:t,height:t,stroke:e,strokeWidth:i?Number(r)*24/Number(t):r,className:n(`lucide`,a),...!l&&!s(d)&&{"aria-hidden":`true`},...d},[...u.map(([e,t])=>(0,c.createElement)(e,t)),...Array.isArray(l)?l:[l]])),u=(e,t)=>{let i=(0,c.forwardRef)(({className:i,...o},s)=>(0,c.createElement)(l,{ref:s,iconNode:t,className:n(`lucide-${r(a(e))}`,`lucide-${e}`,i),...o}));return i.displayName=a(e),i};export{u as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{o as e}from"./
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{Z as r}from"./vendor-ui-B-T_damt.js";import{t as i}from"./createLucideIcon-BjHrJDVb.js";import{t as a}from"./arrow-up-Dtrfv490.js";import{n as o,t as s}from"./csv-parser--2WJNgS7.js";import{i as c,n as l,r as u,t as d}from"./lib-D_kRA9p6.js";var f=i(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),p=e(r(),1),m=e(n(),1);function h(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
2
2
|
font-size: .6rem;
|
|
3
3
|
font-weight: bold;
|
|
4
|
-
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function g(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var _=(e,t)=>Math.abs(e-t)<1.01,v=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},y=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},b=e=>e,x=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},S=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(y(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(y(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},C={passive:!0},w=typeof window>`u`?!0:`onscrollend`in window,T=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&w?()=>void 0:v(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,C);let l=e.options.useScrollendEvent&&w;return l&&n.addEventListener(`scrollend`,c,C),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},E=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},D=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},O=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:b,rangeExtractor:x,onChange:()=>{},measureElement:E,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=h(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=h(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=h(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=h(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?A({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=h(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=h(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return g(t[k(0,t.length-1,e=>g(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&_(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},k=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function A({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=k(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var j=typeof document<`u`?m.useLayoutEffect:m.useEffect;function M({useFlushSync:e=!0,...t}){let n=m.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,p.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=m.useState(()=>new O(r));return i.setOptions(r),j(()=>i._didMount(),[]),j(()=>i._willUpdate()),i}function N(e){return M({observeElementRect:S,observeElementOffset:T,scrollToFn:D,...e})}var P=i();function F({content:e,onContentChange:t,wordWrap:n}){let r=(0,m.useMemo)(()=>s(e),[e]),[i,p]=(0,m.useState)(()=>r.rows),[h,g]=(0,m.useState)([]),_=(0,m.useRef)(null),v=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(v.current){v.current=!1;return}p(r.rows)},[r.rows]);let y=r.headers,b=(0,m.useCallback)((e,n,r)=>{p(i=>{let a=i.map((t,n)=>n===e?[...t]:t);return a[e][n]=r,v.current=!0,t(o(y,a)),a})},[y,t]),x=l({data:i,columns:(0,m.useMemo)(()=>y.map((e,t)=>({id:`col-${t}`,header:e||`Column ${t+1}`,accessorFn:e=>e[t]??``,cell:({row:e,getValue:r})=>(0,P.jsx)(I,{value:r(),onSave:n=>b(e.index,t,n),wordWrap:n}),size:150,minSize:80})),[y,b,n]),state:{sorting:h},onSortingChange:g,getCoreRowModel:u(),getSortedRowModel:c(),enableColumnResizing:!0,columnResizeMode:`onChange`}),{rows:S}=x.getRowModel(),C=N({count:S.length,getScrollElement:()=>_.current,estimateSize:()=>32,overscan:20});return y.length===0?(0,P.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`Empty CSV file`}):(0,P.jsx)(`div`,{ref:_,className:`flex-1 overflow-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-xs font-mono border-collapse`,children:[(0,P.jsx)(`thead`,{className:`sticky top-0 bg-background z-10 border-b border-border block`,children:x.getHeaderGroups().map(e=>(0,P.jsx)(`tr`,{className:`flex w-full`,children:e.headers.map(e=>(0,P.jsxs)(`th`,{className:`relative text-left px-2 py-1.5 font-medium text-muted-foreground select-none cursor-pointer hover:bg-muted/50 border-r border-border last:border-r-0`,style:{width:e.getSize(),minWidth:e.getSize()},onClick:e.column.getToggleSortingHandler(),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`truncate`,children:d(e.column.columnDef.header,e.getContext())}),e.column.getIsSorted()===`asc`&&(0,P.jsx)(a,{className:`size-3 shrink-0`}),e.column.getIsSorted()===`desc`&&(0,P.jsx)(f,{className:`size-3 shrink-0`})]}),(0,P.jsx)(`div`,{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),onClick:e=>e.stopPropagation(),className:`absolute right-0 top-0 h-full w-1 cursor-col-resize hover:bg-primary/50 active:bg-primary`})]},e.id))},e.id))}),(0,P.jsx)(`tbody`,{style:{height:C.getTotalSize(),position:`relative`,display:`block`},children:C.getVirtualItems().map(e=>{let t=S[e.index];return(0,P.jsx)(`tr`,{"data-index":e.index,ref:e=>C.measureElement(e),style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`,display:`flex`},children:t.getVisibleCells().map(e=>(0,P.jsx)(`td`,{className:`px-2 py-1 border-b border-border/50 border-r border-r-border/30 last:border-r-0 ${n?`whitespace-pre-wrap break-words`:`truncate`}`,style:{width:e.column.getSize(),minWidth:e.column.getSize()},children:d(e.column.columnDef.cell,e.getContext())},e.id))},t.id)})})]})})}function I({value:e,onSave:t,wordWrap:n}){let[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(e),s=(0,m.useRef)(null),c=(0,m.useCallback)(e=>{e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[]);return(0,m.useEffect)(()=>{r&&s.current&&(s.current.focus(),c(s.current))},[r,c]),r?(0,P.jsx)(`textarea`,{ref:s,className:`w-full bg-transparent outline-none border border-primary/50 rounded text-xs font-mono resize-none p-0.5`,style:{minHeight:a.includes(`
|
|
4
|
+
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function g(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var _=(e,t)=>Math.abs(e-t)<1.01,v=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},y=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},b=e=>e,x=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},S=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(y(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(y(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},C={passive:!0},w=typeof window>`u`?!0:`onscrollend`in window,T=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&w?()=>void 0:v(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,C);let l=e.options.useScrollendEvent&&w;return l&&n.addEventListener(`scrollend`,c,C),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},E=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},D=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},O=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:b,rangeExtractor:x,onChange:()=>{},measureElement:E,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=h(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=h(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=h(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=h(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?A({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=h(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=h(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return g(t[k(0,t.length-1,e=>g(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&_(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},k=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function A({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=k(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var j=typeof document<`u`?m.useLayoutEffect:m.useEffect;function M({useFlushSync:e=!0,...t}){let n=m.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,p.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=m.useState(()=>new O(r));return i.setOptions(r),j(()=>i._didMount(),[]),j(()=>i._willUpdate()),i}function N(e){return M({observeElementRect:S,observeElementOffset:T,scrollToFn:D,...e})}var P=t();function F({content:e,onContentChange:t,wordWrap:n}){let r=(0,m.useMemo)(()=>s(e),[e]),[i,p]=(0,m.useState)(()=>r.rows),[h,g]=(0,m.useState)([]),_=(0,m.useRef)(null),v=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(v.current){v.current=!1;return}p(r.rows)},[r.rows]);let y=r.headers,b=(0,m.useCallback)((e,n,r)=>{p(i=>{let a=i.map((t,n)=>n===e?[...t]:t);return a[e][n]=r,v.current=!0,t(o(y,a)),a})},[y,t]),x=l({data:i,columns:(0,m.useMemo)(()=>y.map((e,t)=>({id:`col-${t}`,header:e||`Column ${t+1}`,accessorFn:e=>e[t]??``,cell:({row:e,getValue:r})=>(0,P.jsx)(I,{value:r(),onSave:n=>b(e.index,t,n),wordWrap:n}),size:150,minSize:80})),[y,b,n]),state:{sorting:h},onSortingChange:g,getCoreRowModel:u(),getSortedRowModel:c(),enableColumnResizing:!0,columnResizeMode:`onChange`}),{rows:S}=x.getRowModel(),C=N({count:S.length,getScrollElement:()=>_.current,estimateSize:()=>32,overscan:20});return y.length===0?(0,P.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`Empty CSV file`}):(0,P.jsx)(`div`,{ref:_,className:`flex-1 overflow-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-xs font-mono border-collapse`,children:[(0,P.jsx)(`thead`,{className:`sticky top-0 bg-background z-10 border-b border-border block`,children:x.getHeaderGroups().map(e=>(0,P.jsx)(`tr`,{className:`flex w-full`,children:e.headers.map(e=>(0,P.jsxs)(`th`,{className:`relative text-left px-2 py-1.5 font-medium text-muted-foreground select-none cursor-pointer hover:bg-muted/50 border-r border-border last:border-r-0`,style:{width:e.getSize(),minWidth:e.getSize()},onClick:e.column.getToggleSortingHandler(),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`truncate`,children:d(e.column.columnDef.header,e.getContext())}),e.column.getIsSorted()===`asc`&&(0,P.jsx)(a,{className:`size-3 shrink-0`}),e.column.getIsSorted()===`desc`&&(0,P.jsx)(f,{className:`size-3 shrink-0`})]}),(0,P.jsx)(`div`,{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),onClick:e=>e.stopPropagation(),className:`absolute right-0 top-0 h-full w-1 cursor-col-resize hover:bg-primary/50 active:bg-primary`})]},e.id))},e.id))}),(0,P.jsx)(`tbody`,{style:{height:C.getTotalSize(),position:`relative`,display:`block`},children:C.getVirtualItems().map(e=>{let t=S[e.index];return(0,P.jsx)(`tr`,{"data-index":e.index,ref:e=>C.measureElement(e),style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`,display:`flex`},children:t.getVisibleCells().map(e=>(0,P.jsx)(`td`,{className:`px-2 py-1 border-b border-border/50 border-r border-r-border/30 last:border-r-0 ${n?`whitespace-pre-wrap break-words`:`truncate`}`,style:{width:e.column.getSize(),minWidth:e.column.getSize()},children:d(e.column.columnDef.cell,e.getContext())},e.id))},t.id)})})]})})}function I({value:e,onSave:t,wordWrap:n}){let[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(e),s=(0,m.useRef)(null),c=(0,m.useCallback)(e=>{e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[]);return(0,m.useEffect)(()=>{r&&s.current&&(s.current.focus(),c(s.current))},[r,c]),r?(0,P.jsx)(`textarea`,{ref:s,className:`w-full bg-transparent outline-none border border-primary/50 rounded text-xs font-mono resize-none p-0.5`,style:{minHeight:a.includes(`
|
|
5
5
|
`)?48:20},rows:1,value:a,onChange:e=>{o(e.target.value),c(e.target)},onBlur:()=>{i(!1),a!==e&&t(a)},onKeyDown:n=>{n.key===`Enter`&&!n.shiftKey?(n.preventDefault(),i(!1),a!==e&&t(a)):n.key===`Escape`&&(i(!1),o(e))}}):(0,P.jsx)(`span`,{className:`block cursor-text ${n?`whitespace-pre-wrap break-words`:`truncate`}`,onClick:()=>{o(e),i(!0)},children:e||`\xA0`})}export{F as CsvPreview};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./createLucideIcon-BjHrJDVb.js";var t=e(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]);export{t};
|