@vantran-se/openchamber-web 1.23.1 → 1.24.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.test.js +29 -6
- package/bin/lib/cli-http.js +5 -1
- package/bin/lib/commands-status.js +5 -0
- package/dist/assets/{CodeMirrorCommentWidgets-BOpqXpFU.js → CodeMirrorCommentWidgets-BjJHrzmU.js} +1 -1
- package/dist/assets/DiffView-COVQhWGd.js +4 -0
- package/dist/assets/FilesView-B1V5JxFX.js +13 -0
- package/dist/assets/GitView-CDOJy5Ay.js +6 -0
- package/dist/assets/GuestAttachDialog-D3S0Rjic.js +1 -0
- package/dist/assets/{JsonTreeView-nd_E8eVM.js → JsonTreeView-D0C9nU7K.js} +1 -1
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/LinearIssuesView-D7FKg1XJ.js +1 -0
- package/dist/assets/{MarkdownImageGallery-CVYds3sQ.js → MarkdownImageGallery-BrFjAVEf.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-DWepTafh.js +12 -0
- package/dist/assets/{OnboardingScreen-Dd2IbPTn.js → OnboardingScreen-Dyxxiqdt.js} +1 -1
- package/dist/assets/{PatchDiff-nUu5i4bG.js → PatchDiff-DnEhjXcC.js} +1 -1
- package/dist/assets/PierreDiffViewer-DyxZVVVR.js +210 -0
- package/dist/assets/PlanView-LW2z_EAP.js +5 -0
- package/dist/assets/PluginPane-B4tKno2h.js +3 -0
- package/dist/assets/SettingsView-DEaMulN9.js +29 -0
- package/dist/assets/{SettingsWindow-BccxY81J.js → SettingsWindow-FLDJXOgQ.js} +1 -1
- package/dist/assets/SubmoduleDiffSummary-CvVwD-Vi.js +1 -0
- package/dist/assets/ToolOutputDialog-BiP0x2Rw.js +15 -0
- package/dist/assets/{ToolPartDiffPreview-BFVgk0UK.js → ToolPartDiffPreview-CkR4msKP.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-z3_H74UR.js → VirtualizedFileDiff-0pyr_mHY.js} +3 -3
- package/dist/assets/{WalkthroughView-BqM9GFbJ.js → WalkthroughView-yNj4nOP5.js} +2 -2
- package/dist/assets/appThemeRegistry-BuUKhbYQ.js +1 -0
- package/dist/assets/commitAndPush-DvJKa3Ks.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-Bdazp9Qo.js → computeVirtualFileMetrics-DxTBMuu-.js} +1 -1
- package/dist/assets/de-DgxgFyGG.js +10 -0
- package/dist/assets/es-BFsZj5F_.js +16 -0
- package/dist/assets/fr-jdZ5KKQi.js +14 -0
- package/dist/assets/{index-eo1-D_7z.js → index-CKHjPKbq.js} +1 -1
- package/dist/assets/index-Cbci4i1W.js +40 -0
- package/dist/assets/index-DqaMWNrC.css +1 -0
- package/dist/assets/{isDiffPlainText-BvKH712-.js → isDiffPlainText-D7FkBMP6.js} +1 -1
- package/dist/assets/{isFilePlainText-BdVVPukf.js → isFilePlainText-CL2vsrIZ.js} +1 -1
- package/dist/assets/ja-C5kKrhO4.js +16 -0
- package/dist/assets/ko-DXDTT_0O.js +16 -0
- package/dist/assets/main-CZALtVek.js +896 -0
- package/dist/assets/main-CgXMBNvG.js +2 -0
- package/dist/assets/{markdown-shiki.worker-D5fBU-lw.js → markdown-shiki.worker-CahLvHIq.js} +5 -5
- package/dist/assets/markdownCore-Dh7WEsdM.js +5 -0
- package/dist/assets/miniChat-CwTmDixi.js +2 -0
- package/dist/assets/mobile-CLf2vCtO.js +2 -0
- package/dist/assets/{patchFileDiff-B7LjppSS.js → patchFileDiff-Bsba8KFp.js} +3 -3
- package/dist/assets/pl-D-7x4Y8Q.js +16 -0
- package/dist/assets/pt-BR-CSBZrHa8.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-C5gAFBk0.js +2 -0
- package/dist/assets/renderMobileApp-V4hYd32H.js +25 -0
- package/dist/assets/runtimeEndpointReset-DhlHCn-2.js +25 -0
- package/dist/assets/{scheduledTasksApi-hceovDei.js → scheduledTasksApi-DzjbLd8P.js} +1 -1
- package/dist/assets/shikiHighlight-8_3csmr6.js +1 -0
- package/dist/assets/textMateThemeFromAppTheme-CHo2fCgW.js +1 -0
- package/dist/assets/tr-Dr-oJ22L.js +7 -0
- package/dist/assets/uk-9Nx83UcI.js +16 -0
- package/dist/assets/useAppFontEffects-khZXpFL_.js +7333 -0
- package/dist/assets/useInlineCommentController-DkQ_gqpn.js +2 -0
- package/dist/assets/useRootScrollLock-DdvHf9Pt.js +2 -0
- package/dist/assets/{vendor-base-ui-BY_5qla_.js → vendor-base-ui-CsXYnR5c.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-DWA1bm1F.js → vendor-codemirror-language-data-CdzUmUyZ.js} +2 -2
- package/dist/assets/vendor-framer-motion-Bq3iTZ6r.js +1 -0
- package/dist/assets/vendor-katex-Cp579UoJ.css +1 -0
- package/dist/assets/{vendor-motion-dom-D_o3BTI3.js → vendor-motion-dom-DcCgeG69.js} +1 -1
- package/dist/assets/{vendor-remixicon-react-Dil0zKKT.js → vendor-remixicon-react-BDmGmFCA.js} +1 -1
- package/dist/assets/vendor-strip-json-comments-5dJlOkP1.js +4 -0
- package/dist/assets/{vendor-tanstack-react-virtual-g05Cx3z9.js → vendor-tanstack-react-virtual-ClYN8CzB.js} +1 -1
- package/dist/assets/{vendor-tanstack-virtual-core-Dubg10g5.js → vendor-tanstack-virtual-core-BewVQryB.js} +1 -1
- package/dist/assets/{vendor-zod-B6551dwG.js → vendor-zod-CgAdXWZO.js} +4 -4
- package/dist/assets/{web-components-B_Z64So5.js → web-components-B8IcVQAA.js} +2 -2
- package/dist/assets/zh-CN-Bxy_Hj3r.js +16 -0
- package/dist/assets/zh-TW-0BB4gpHM.js +16 -0
- package/dist/index.html +6 -4
- package/dist/mini-chat.html +6 -4
- package/dist/mobile.html +6 -4
- package/package.json +12 -9
- package/server/built-in-extensions/registry.json +4 -0
- package/server/index.d.ts +2 -0
- package/server/index.js +44 -10
- package/server/lib/agent-tool/DOCUMENTATION.md +17 -4
- package/server/lib/agent-tool/runtime.js +62 -15
- package/server/lib/agent-tool/runtime.test.js +88 -2
- package/server/lib/changelog/update-notes.js +2 -1
- package/server/lib/changelog/update-notes.test.js +19 -0
- package/server/lib/event-stream/DOCUMENTATION.md +23 -0
- package/server/lib/event-stream/delta-coalescer.js +0 -0
- package/server/lib/event-stream/delta-coalescer.test.js +292 -0
- package/server/lib/event-stream/global-hub.js +53 -23
- package/server/lib/event-stream/global-hub.test.js +160 -0
- package/server/lib/event-stream/global-ws-bridge.js +1 -0
- package/server/lib/event-stream/index.js +4 -0
- package/server/lib/fs/DOCUMENTATION.md +10 -1
- package/server/lib/fs/git-process.test.js +77 -0
- package/server/lib/fs/routes.js +58 -5
- package/server/lib/fs/routes.test.js +116 -0
- package/server/lib/fs/search.js +2 -1
- package/server/lib/git/DOCUMENTATION.md +20 -5
- package/server/lib/git/routes.js +16 -3
- package/server/lib/git/serial-refresh.js +93 -0
- package/server/lib/git/serial-refresh.test.js +112 -0
- package/server/lib/git/service.js +429 -70
- package/server/lib/git/service.test.js +418 -0
- package/server/lib/github/pr-status.js +5 -5
- package/server/lib/github/pr-status.test.js +1 -1
- package/server/lib/github/routes.js +4 -4
- package/server/lib/guests/DOCUMENTATION.md +68 -0
- package/server/lib/guests/auth-store.js +184 -0
- package/server/lib/guests/auth-store.test.js +112 -0
- package/server/lib/guests/background.test.js +83 -0
- package/server/lib/guests/builtins.js +34 -0
- package/server/lib/guests/builtins.test.js +174 -0
- package/server/lib/guests/catalog.js +477 -0
- package/server/lib/guests/catalog.test.js +390 -0
- package/server/lib/guests/clone.js +297 -0
- package/server/lib/guests/extract-zip.js +136 -0
- package/server/lib/guests/extract-zip.test.js +109 -0
- package/server/lib/guests/files.js +308 -0
- package/server/lib/guests/files.test.js +262 -0
- package/server/lib/guests/grant-scope.js +81 -0
- package/server/lib/guests/grant-scope.test.js +75 -0
- package/server/lib/guests/host-session.js +73 -0
- package/server/lib/guests/host-session.test.js +30 -0
- package/server/lib/guests/html-styles.js +6 -0
- package/server/lib/guests/html-styles.test.js +45 -0
- package/server/lib/guests/html-tokens.js +73 -0
- package/server/lib/guests/html-tokens.test.js +53 -0
- package/server/lib/guests/install.js +406 -0
- package/server/lib/guests/install.test.js +338 -0
- package/server/lib/guests/oauth.js +501 -0
- package/server/lib/guests/oauth.test.js +481 -0
- package/server/lib/guests/persist.js +336 -0
- package/server/lib/guests/persist.test.js +288 -0
- package/server/lib/guests/request.js +112 -0
- package/server/lib/guests/request.test.js +206 -0
- package/server/lib/guests/routes.js +838 -0
- package/server/lib/guests/service.js +538 -0
- package/server/lib/guests/service.test.js +277 -0
- package/server/lib/guests/sockets.js +129 -0
- package/server/lib/guests/sockets.test.js +110 -0
- package/server/lib/guests/ssh-install.test.js +188 -0
- package/server/lib/guests/storage.js +68 -0
- package/server/lib/guests/storage.test.js +59 -0
- package/server/lib/guests/updates.js +294 -0
- package/server/lib/guests/updates.test.js +334 -0
- package/server/lib/guests/upload.js +50 -0
- package/server/lib/guests/upload.test.js +131 -0
- package/server/lib/linear/DOCUMENTATION.md +1 -1
- package/server/lib/message-queue/DOCUMENTATION.md +10 -1
- package/server/lib/message-queue/runtime.js +21 -1
- package/server/lib/message-queue/runtime.test.js +52 -5
- package/server/lib/notifications/routes.js +5 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +6 -0
- package/server/lib/openchamber-sessions/routes.js +62 -29
- package/server/lib/openchamber-sessions/routes.test.js +96 -0
- package/server/lib/opencode/DOCUMENTATION.md +55 -1
- package/server/lib/opencode/bootstrap-runtime.js +1 -0
- package/server/lib/opencode/core-routes.js +39 -1
- package/server/lib/opencode/feature-routes-runtime.js +15 -0
- package/server/lib/opencode/lifecycle-process.test.js +84 -0
- package/server/lib/opencode/lifecycle.js +54 -67
- package/server/lib/opencode/openchamber-routes.js +72 -14
- package/server/lib/opencode/openchamber-routes.test.js +71 -3
- package/server/lib/opencode/session-runtime.js +68 -0
- package/server/lib/opencode/session-runtime.test.js +43 -0
- package/server/lib/opencode/settings-helpers.js +8 -0
- package/server/lib/opencode/settings-helpers.test.js +13 -1
- package/server/lib/opencode/settings-normalization-runtime.js +2 -0
- package/server/lib/opencode/settings-normalization-runtime.test.js +13 -0
- package/server/lib/opencode/settings-registry.json +15 -0
- package/server/lib/opencode/shutdown-runtime.js +3 -0
- package/server/lib/opencode/shutdown-runtime.test.js +24 -0
- package/server/lib/opencode/theme-archive.js +53 -0
- package/server/lib/opencode/theme-catalog.js +171 -0
- package/server/lib/opencode/theme-catalog.test.js +125 -0
- package/server/lib/opencode/theme-import.test.js +144 -0
- package/server/lib/opencode/theme-runtime.js +100 -28
- package/server/lib/opencode/theme-runtime.test.js +15 -0
- package/server/lib/permission-auto-accept/DOCUMENTATION.md +8 -0
- package/server/lib/permission-auto-accept/runtime.js +13 -0
- package/server/lib/permission-auto-accept/runtime.test.js +37 -1
- package/server/lib/projects/project-config.js +2 -2
- package/server/lib/quota/DOCUMENTATION.md +0 -1
- package/server/lib/quota/providers/index.js +0 -7
- package/server/lib/realtime-proxy-terminal.test.js +150 -0
- package/server/lib/realtime-proxy.js +2 -0
- package/server/lib/routing/DOCUMENTATION.md +83 -0
- package/server/lib/routing/defaults.js +98 -0
- package/server/lib/routing/feature-flag.js +11 -0
- package/server/lib/routing/history.js +34 -0
- package/server/lib/routing/jev.js +98 -0
- package/server/lib/routing/routes.http.test.js +100 -0
- package/server/lib/routing/routes.js +81 -0
- package/server/lib/routing/runtime.js +217 -0
- package/server/lib/routing/runtime.test.js +188 -0
- package/server/lib/routing/store.js +249 -0
- package/server/lib/routing/store.test.js +96 -0
- package/server/lib/scheduled-tasks/runtime.js +2 -2
- package/server/lib/scheduled-tasks/runtime.test.js +14 -0
- package/server/lib/security/request-security.js +9 -5
- package/server/lib/security/request-security.test.js +37 -0
- package/server/lib/small-model/DOCUMENTATION.md +14 -2
- package/server/lib/small-model/call.js +37 -6
- package/server/lib/small-model/call.test.js +182 -0
- package/server/lib/terminal/DOCUMENTATION.md +23 -2
- package/server/lib/terminal/runtime.js +27 -5
- package/server/lib/terminal/runtime.test.js +67 -0
- package/server/lib/terminal/shutdown.js +106 -0
- package/server/lib/terminal/shutdown.test.js +84 -0
- package/server/lib/tts/service.test.js +78 -0
- package/server/lib/ui-auth/DOCUMENTATION.md +8 -0
- package/server/lib/ui-auth/session-cookie.js +51 -0
- package/server/lib/ui-auth/session-cookie.test.js +46 -0
- package/server/lib/ui-auth/ui-auth.js +56 -17
- package/server/lib/ui-auth/ui-auth.test.js +96 -0
- package/dist/assets/DiffView-CyLmb-wF.js +0 -4
- package/dist/assets/DirtyBranchSwitchDialog-pu5kcoir.js +0 -1
- package/dist/assets/FilesView-WtJB0y_l.js +0 -13
- package/dist/assets/GitView-DkNrV0BK.js +0 -6
- package/dist/assets/LinearIssuesView-B0H0Otii.js +0 -1
- package/dist/assets/MarkdownRendererImpl-DSqVN2d8.js +0 -12
- package/dist/assets/PierreDiffViewer-Bsq9z-sw.js +0 -161
- package/dist/assets/PlanView-CAFziKH5.js +0 -5
- package/dist/assets/SettingsView-BRittavZ.js +0 -28
- package/dist/assets/ToolOutputDialog-B0uYaJio.js +0 -15
- package/dist/assets/appThemeRegistry-BK0dHKa6.js +0 -1
- package/dist/assets/de-c7CYLCAW.js +0 -10
- package/dist/assets/es-BKAVPQmQ.js +0 -16
- package/dist/assets/fr-Bj1glqfV.js +0 -14
- package/dist/assets/index-BYFyOu_D.css +0 -1
- package/dist/assets/index-BfwRClDe.js +0 -40
- package/dist/assets/ja-5jwSIbK0.js +0 -16
- package/dist/assets/ko-BaDbg-Eb.js +0 -16
- package/dist/assets/main-CGG2_uHq.js +0 -2
- package/dist/assets/main-CcrSaL4J.js +0 -930
- package/dist/assets/markdownCore-DsmQr3bt.js +0 -5
- package/dist/assets/miniChat-DEaAhP4b.js +0 -2
- package/dist/assets/mobile-BC3rsvv0.js +0 -2
- package/dist/assets/pl-BFKVBDFu.js +0 -16
- package/dist/assets/pt-BR-qKfHvkDL.js +0 -16
- package/dist/assets/registerCustomTheme-BBXUCRnG.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-CR9d1Mr0.js +0 -2
- package/dist/assets/renderMobileApp-Da5dwobZ.js +0 -25
- package/dist/assets/runtimeEndpointReset-CLYVRw2H.js +0 -41
- package/dist/assets/shikiHighlight-D1Z9G58W.js +0 -1
- package/dist/assets/tr-DYXPoEDG.js +0 -7
- package/dist/assets/uk-CwAoloR8.js +0 -16
- package/dist/assets/useAppFontEffects-DeStGcUT.js +0 -7282
- package/dist/assets/useGitComparison-CpxioduU.js +0 -1
- package/dist/assets/useInlineCommentController-gmUnJtrb.js +0 -2
- package/dist/assets/useRootScrollLock--a3cPz8s.js +0 -1
- package/dist/assets/vendor-framer-motion-livSKyyV.js +0 -1
- package/dist/assets/zh-CN-D9MG0lqF.js +0 -16
- package/dist/assets/zh-TW-1HNK7shh.js +0 -16
- package/server/lib/quota/providers/crof.js +0 -96
- package/server/lib/quota/providers/crof.test.js +0 -98
- /package/dist/assets/{vendor-katex-k3Ppq1Ha.js → vendor-katex-CHD9BdDO.js} +0 -0
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{R as l,r as ve,j as t,f as Ct}from"./vendor-react-BUCujlKS.js";import{f as nt,y as rt,a3 as Dt,ie as _n,d3 as Yt,cq as Qt,t as b,I as T,ao as Ts,ap as Ls,aq as Fr,ar as Os,cJ as As,cK as zs,cL as Gs,cM as _s,cE as Xt,cF as Zt,B as W,ig as Hn,ih as $n,bN as mt,bO as ht,bP as gt,bQ as ft,bR as bt,V as gr,a9 as es,aa as ts,ab as ss,ii as Wn,h as Se,ij as Un,ik as Jn,il as qn,im as Kn,bb as Yn,au as Qn,bZ as Xn,io as Zn,ip as ea,iq as ta,ir as sa,is as ra,it as na,iu as aa,bT as Rr,c2 as ia,c3 as oa,c4 as la,c5 as ca,c6 as da,ca as ua,c0 as ma,b$ as ha,iv as ga,c9 as fa,bS as Es,f4 as pa,Y as xa,ae as wa,af as ya,H as ba,ag as va,bD as ja,iw as Ca,ah as Na,ix as Sa,iy as ka,ai as Va,iz as Pa,J as Ia,bX as Fa,hq as Ra,iA as Ba,l as Da,cb as Ma,g as Ea,cO as Ta,an as fr,a4 as La,iB as Oa,iC as Bs}from"./useAppFontEffects-DeStGcUT.js";import{a as Aa,b as za}from"./main-CcrSaL4J.js";import{a6 as Ga,J as _a,e as Ha,ab as $a}from"./runtimeEndpointReset-CLYVRw2H.js";import{u as pr}from"./vendor-zustand-BAGL70zf.js";import{h as Wa,u as Rt}from"./index-BfwRClDe.js";import{C as Ua,a as Ja,D as qa}from"./DirtyBranchSwitchDialog-pu5kcoir.js";import{P as Ka}from"./PierreDiffViewer-Bsq9z-sw.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-base-ui-BY_5qla_.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DWA1bm1F.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-zod-B6551dwG.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./useRootScrollLock--a3cPz8s.js";import"./scheduledTasksApi-hceovDei.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./web-components-B_Z64So5.js";import"./computeVirtualFileMetrics-Bdazp9Qo.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-z3_H74UR.js";import"./isDiffPlainText-BvKH712-.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-gmUnJtrb.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";const Br="gitmojiCache",Ya=1e3*60*60*24*7,Dr="1",Qa="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",Mr=o=>{if(!o||typeof o!="object")return!1;const e=o;return typeof e.emoji=="string"&&typeof e.code=="string"&&typeof e.description=="string"},Ds=()=>{if(typeof window>"u")return null;try{const o=window.localStorage.getItem(Br);if(!o)return null;const e=JSON.parse(o);return!e||e.version!==Dr||typeof e.fetchedAt!="number"||!Array.isArray(e.gitmojis)?null:{gitmojis:e.gitmojis.filter(Mr),fetchedAt:e.fetchedAt,version:e.version}}catch{return null}},Xa=o=>{if(!(typeof window>"u"))try{const e={gitmojis:o,fetchedAt:Date.now(),version:Dr};window.localStorage.setItem(Br,JSON.stringify(e))}catch{return}},xr=o=>Date.now()-o.fetchedAt<Ya;let qt=null;const Bt=new Set,wr=async()=>{if(qt)return qt;const o=(async()=>{try{const e=await fetch(Qa);if(!e.ok)throw new Error(`Failed to load gitmojis: ${e.statusText}`);const a=await e.json(),m=Array.isArray(a.gitmojis)?a.gitmojis.filter(Mr):[];return Xa(m),Bt.forEach(N=>N(m)),m}catch(e){console.warn("Failed to load gitmoji list:",e);const a=[];return Bt.forEach(m=>m(a)),a}finally{qt=null}})();return qt=o,o},Za=o=>{const[e,a]=l.useState(()=>o?Ds()?.gitmojis??[]:[]),[m,N]=l.useState(!1),f=l.useRef(o);f.current=o,l.useEffect(()=>{if(!o){Bt.delete(a),a([]),N(!1);return}const x=Ds();if(x&&(a(x.gitmojis),xr(x)))return;Bt.add(a),N(!0);let g=!1;return wr().finally(()=>{!g&&f.current&&N(!1)}),()=>{g=!0,Bt.delete(a)}},[o]);const p=l.useCallback(async()=>{if(!f.current)return[];if(e.length>0)return e;const x=Ds();return x&&xr(x)?x.gitmojis:wr()},[e]);return{gitmojis:e,isLoading:m,ensureLoaded:p}},Nt=async(o,e)=>{const a=await Wa(`/api/git/integrate/${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!a.ok){const m=await a.json().catch(()=>null);throw new Error(m?.error||`Git integrate request failed: ${a.statusText}`)}return a.json()};async function Ft(o){return Nt("plan",o)}async function ei(o){return Nt("conflict-details",{tempWorktreePath:o})}async function ti(o){return(await Nt("cherry-pick-status",{tempWorktreePath:o})).inProgress}async function si(o){return Nt("run",{plan:o})}async function ri(o){await Nt("abort",{state:o})}async function ni(o){return Nt("continue",{state:o})}const ai=({repoRoot:o,sourceBranch:e,worktreeMetadata:a,localBranches:m,defaultTargetBranch:N,refreshKey:f,onRefresh:p,showHeader:x=!0})=>{const{t:g}=nt(),w=rt(h=>h.currentSessionId),[M,v]=ve.useState(!1),[V,L]=ve.useState(""),S=ve.useRef(null),z=ve.useMemo(()=>Dt(m,V,h=>[h]),[m,V]),[C,y]=ve.useState(N);ve.useEffect(()=>{y(N)},[N]),ve.useEffect(()=>{if(M){const h=setTimeout(()=>{S.current?.focus()},0);return()=>clearTimeout(h)}},[M]);const D=!!(o&&e&&C&&C!=="HEAD"&&e!==C),[k,R]=ve.useState({kind:"idle"}),[I,F]=ve.useState(!1),[r,Y]=ve.useState([]),B=ve.useMemo(()=>w?`openchamber.integrate.conflict:${w}`:null,[w]);ve.useEffect(()=>{if(!B||typeof window>"u")return;const h=window.localStorage.getItem(B);if(!h)return;let d=!1;try{const P=JSON.parse(h);if(!P?.tempWorktreePath||P.repoRoot!==o){window.localStorage.removeItem(B);return}(async()=>{const O=await ti(P.tempWorktreePath).catch(()=>!1);if(d)return;if(!O){window.localStorage.removeItem(B);return}const K=await ei(P.tempWorktreePath).catch(()=>null);d||K&&R({kind:"conflict",state:P,details:K})})()}catch{window.localStorage.removeItem(B)}return()=>{d=!0}},[B,o]),ve.useEffect(()=>{if(!D){R({kind:"idle"});return}let h=!1;return R({kind:"loading"}),(async()=>{try{const d=await Ft({repoRoot:o,sourceBranch:e,targetBranch:C});if(h)return;if(R({kind:"ready",plan:d}),d.commits.length>0){const O=d.commits.slice(-50).reverse(),K=await _n(o,O);h||(Y(K),F(!1))}else h||(Y([]),F(!1))}catch{h||R({kind:"idle"})}})(),()=>{h=!0}},[D,o,e,C,f]);const u=ve.useCallback(h=>{w&&rt.getState().setWorktreeMetadata(w,{...a,createdFromBranch:h})},[w,a]),E=rt(h=>h.openNewSessionDraft),se=ve.useCallback(async h=>{const d=await Yt("git.integrate.cherrypick.resolve.visible",{current_commit:h.state.currentCommit,target_branch:h.state.targetBranch}),P=await Yt("git.integrate.cherrypick.resolve.instructions",{repo_root:h.state.repoRoot,temp_worktree_path:h.state.tempWorktreePath,source_branch:h.state.sourceBranch,target_branch:h.state.targetBranch,current_commit:h.state.currentCommit}),O=`Cherry-pick conflict context (JSON)
|
|
2
|
-
${JSON.stringify({repoRoot:h.state.repoRoot,tempWorktreePath:h.state.tempWorktreePath,sourceBranch:h.state.sourceBranch,targetBranch:h.state.targetBranch,currentCommit:h.state.currentCommit,remainingCommits:h.state.remainingCommits,statusPorcelain:h.details.statusPorcelain,unmergedFiles:h.details.unmergedFiles,currentPatchMeta:h.details.currentPatchMeta,currentPatch:h.details.currentPatch,diff:h.details.diff},null,2)}`;return{visibleText:d,instructionsText:P,payloadText:O}},[]),U=Qt(h=>h.setPendingInputText),G=Qt(h=>h.setPendingSyntheticParts),H=ve.useCallback(async(h,d)=>{const P=await se(h);if(d){E({directoryOverride:h.state.tempWorktreePath,initialPrompt:P.visibleText,syntheticParts:[{text:P.instructionsText,synthetic:!0},{text:P.payloadText,synthetic:!0}]});return}if(!w){b.error(g("gitView.integrate.noActiveSession"),{description:g("gitView.integrate.noActiveSessionDescription")});return}U(P.visibleText,"replace"),G([{text:P.instructionsText,synthetic:!0},{text:P.payloadText,synthetic:!0}])},[w,se,E,U,G,g]),X=ve.useCallback(async()=>{if(k.kind==="ready"){if(k.plan.commits.length===0){b.message(g("gitView.integrate.noCommitsToMoveToast"));return}R({kind:"running",plan:k.plan});try{const h=await si(k.plan);if(h.kind==="success"){b.success(g("gitView.integrate.commitsMovedToast"),{description:h.moved===1?g("gitView.integrate.commitsMovedDescriptionSingle",{count:h.moved,branch:k.plan.targetBranch}):g("gitView.integrate.commitsMovedDescriptionPlural",{count:h.moved,branch:k.plan.targetBranch})});const d=await Ft(k.plan);R({kind:"ready",plan:d}),p?.();return}h.kind==="conflict"&&(b.error(g("gitView.integrate.cherryPickConflictToast"),{description:g("gitView.integrate.cherryPickConflictDescription")}),R({kind:"conflict",state:h.state,details:h.details}),B&&typeof window<"u"&&window.localStorage.setItem(B,JSON.stringify(h.state)))}catch(h){const d=h instanceof Error?h.message:String(h);b.error(g("gitView.integrate.failedToMoveToast"),{description:d});const P=await Ft({repoRoot:o,sourceBranch:e,targetBranch:C}).catch(()=>null);R(P?{kind:"ready",plan:P}:{kind:"idle"})}}},[k,p,o,e,C,B,g]),$=ve.useCallback(async()=>{if(k.kind==="conflict")try{await ri(k.state),b.message(g("gitView.integrate.cherryPickAbortedToast")),B&&typeof window<"u"&&window.localStorage.removeItem(B)}finally{const h=await Ft({repoRoot:o,sourceBranch:e,targetBranch:C}).catch(()=>null);R(h?{kind:"ready",plan:h}:{kind:"idle"})}},[k,o,e,C,B,g]),le=ve.useCallback(async()=>{if(k.kind==="conflict")try{const h=await ni(k.state);if(h.kind==="success"){b.success(g("gitView.integrate.cherryPickFinishedToast"));const d=await Ft({repoRoot:o,sourceBranch:e,targetBranch:C}).catch(()=>null);R(d?{kind:"ready",plan:d}:{kind:"idle"}),B&&typeof window<"u"&&window.localStorage.removeItem(B),p?.();return}h.kind==="conflict"&&(R({kind:"conflict",state:h.state,details:h.details}),B&&typeof window<"u"&&window.localStorage.setItem(B,JSON.stringify(h.state)))}catch(h){const d=h instanceof Error?h.message:String(h);b.error(g("gitView.integrate.cherryPickContinueFailedToast"),{description:d})}},[k,o,e,C,p,B,g]);return!o||!e?null:t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[x?t.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(T,{name:"split-cells-horizontal",className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:g("gitView.integrate.title")}),k.kind==="ready"&&k.plan.commits.length>0?t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:g("gitView.integrate.toMoveCount",{count:k.plan.commits.length})}):null]}),t.jsx("div",{className:"flex items-center gap-2",children:k.kind==="loading"||k.kind==="running"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):null})]}):null,t.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:g("gitView.integrate.moveCommits")}),t.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," → ",C]})]}),t.jsx("div",{className:"flex-1"}),t.jsxs(Ts,{open:M,onOpenChange:v,children:[t.jsx(Ls,{asChild:!0,children:t.jsxs("button",{type:"button",className:Fr({size:"default"}),children:[g("gitView.integrate.target"),t.jsx("span",{className:"max-w-[160px] truncate font-mono text-xs text-muted-foreground",children:C}),t.jsx(T,{name:"arrow-down-s",className:"size-4 opacity-60"})]})}),t.jsx(Os,{align:"end",className:"w-72 p-0 max-h-[var(--available-height)] flex flex-col overflow-hidden",children:t.jsxs(As,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(zs,{ref:S,placeholder:g("gitView.branch.searchPlaceholder"),value:V,onValueChange:L,onKeyDown:h=>h.stopPropagation()}),t.jsxs(Gs,{className:"h-full min-h-0",scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(_s,{children:g("gitView.branch.empty")}),t.jsx(Xt,{heading:g("gitView.branch.localBranches"),children:z.map(h=>t.jsx(Zt,{value:h,onSelect:()=>{y(h),u(h),v(!1),L("")},children:h},h))})]})]})})]}),k.kind==="ready"?t.jsx(W,{size:"sm",onClick:()=>{X()},disabled:!D||k.plan.commits.length===0,children:g("gitView.integrate.move")}):k.kind==="loading"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:g("gitView.integrate.checking")}):k.kind==="running"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:g("gitView.integrate.moving")}):null]}),k.kind==="ready"&&k.plan.commits.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:g("gitView.integrate.noCommitsToMove")}),k.kind==="ready"&&k.plan.commits.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"typography-meta text-foreground",children:[g("gitView.integrate.commitsToMove"),t.jsxs("span",{className:"text-muted-foreground",children:[" (",k.plan.commits.length,")"]})]}),r.length>0&&k.plan.commits.length>5&&t.jsx("button",{type:"button",onClick:()=>F(h=>!h),className:"typography-micro text-muted-foreground hover:text-foreground",children:g(I?"gitView.integrate.showLess":"gitView.integrate.showAll")})]}),t.jsxs("div",{className:"space-y-1",children:[(I?r:r.slice(0,5)).map(h=>t.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[t.jsx("span",{className:"font-mono text-xs text-muted-foreground flex-shrink-0",children:h.short}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:h.subject||h.sha})]},h.sha)),r.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:g("gitView.integrate.previewUnavailable")}),k.plan.commits.length>r.length&&t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:g("gitView.integrate.showingFirstCommits",{count:r.length})})]})]}),k.kind==="conflict"&&t.jsxs("div",{className:"rounded-md border border-border/60 bg-background/60 p-3 space-y-2",children:[t.jsx("div",{className:"typography-meta text-foreground",children:g("gitView.integrate.conflictsInFiles",{count:k.details.unmergedFiles.length})}),t.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[g("gitView.integrate.currentCommit"),": ",t.jsx("span",{className:"font-mono",children:k.state.currentCommit.slice(0,7)})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[k.details.unmergedFiles.slice(0,6).map(h=>t.jsx("span",{className:"font-mono text-xs px-2 py-0.5 rounded bg-muted/40 text-muted-foreground",children:h},h)),k.details.unmergedFiles.length>6&&t.jsx("span",{className:"text-xs text-muted-foreground",children:g("gitView.integrate.moreFiles",{count:k.details.unmergedFiles.length-6})})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{size:"sm",variant:"ghost",className:"typography-meta",onClick:()=>{$()},children:g("gitView.operation.abort")}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",disabled:!w,onClick:()=>{H({state:k.state,details:k.details},!1)},children:[t.jsx(T,{name:"sparkling",className:"size-3.5"}),g("gitView.integrate.currentSession")]}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",onClick:()=>{H({state:k.state,details:k.details},!0)},children:[t.jsx(T,{name:"sparkling",className:"size-3.5"}),g("gitView.integrate.newSession")]}),t.jsx(W,{size:"sm",className:"typography-meta",onClick:()=>{le()},children:g("gitView.operation.continue")})]})]})]})]})},ii=({open:o,onOpenChange:e,directory:a,hasUncommittedChanges:m,hasStagedChanges:N=!1,uncommittedFileCount:f,onChanged:p})=>{const{t:x}=nt(),[g,w]=l.useState([]),[M,v]=l.useState(!1),[V,L]=l.useState(""),[S,z]=l.useState(""),[C,y]=l.useState(null),[D,k]=l.useState({}),R=l.useCallback(async()=>{if(a){v(!0);try{const u=await Hn(a);w(u.stashes),k({})}catch(u){b.error(u instanceof Error?u.message:x("gitView.stashes.toast.loadFailed"))}finally{v(!1)}}},[a,x]);l.useEffect(()=>{o&&R()},[R,o]),l.useEffect(()=>{if(!o||!a||g.length===0)return;let u=!1;const E=g.map(se=>se.ref);return $n(a,E).then(se=>{u||k(se.counts)}).catch(()=>{}),()=>{u=!0}},[a,o,g]);const I=l.useMemo(()=>Dt(g,V,u=>[u.message,u.ref,u.relativeTime]),[V,g]),F=l.useCallback(async u=>{await R(),await p?.(u)},[R,p]),r=async()=>{if(!(!a||C)){y("create");try{const u=await Wn(a,{message:S.trim()||void 0});u.created?(b.success(x("gitView.stashes.toast.created")),z("")):b.info(x("gitView.stashes.toast.noChanges")),await F({affectsIndex:!!(u.created&&N)})}catch(u){b.error(u instanceof Error?u.message:x("gitView.stashes.toast.createFailed"))}finally{y(null)}}},Y=async(u,E)=>{if(!(!a||C)&&!(E==="drop"&&!window.confirm(x("gitView.stashes.confirm.drop",{ref:u.ref})))){y(`${E}:${u.ref}`);try{E==="apply"&&await Un(a,{ref:u.ref}),E==="pop"&&await Jn(a,{ref:u.ref}),E==="drop"&&await qn(a,{ref:u.ref});const se=E==="apply"?"gitView.stashes.toast.applySuccess":E==="pop"?"gitView.stashes.toast.popSuccess":"gitView.stashes.toast.dropSuccess";b.success(x(se)),await F({affectsIndex:E!=="drop"})}catch(se){const U=E==="apply"?"gitView.stashes.toast.applyFailed":E==="pop"?"gitView.stashes.toast.popFailed":"gitView.stashes.toast.dropFailed";b.error(se instanceof Error?se.message:x(U)),await F({affectsIndex:E!=="drop"})}finally{y(null)}}},B=C!==null;return t.jsx(mt,{open:o,onOpenChange:e,children:t.jsxs(ht,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsxs(gt,{children:[t.jsxs(ft,{className:"flex items-center gap-2",children:[t.jsx(T,{name:"archive-stack",className:"h-5 w-5"}),x("gitView.stashes.title")]}),t.jsx(bt,{children:x("gitView.stashes.description")})]}),t.jsxs("div",{className:"mt-2 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(gr,{value:S,onChange:u=>z(u.target.value),placeholder:x("gitView.stashes.messagePlaceholder"),disabled:B||!m,className:"flex-1"}),t.jsxs(W,{onClick:r,disabled:!m||B||!a,children:[C==="create"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"inbox-archive",className:"size-4"}),x("gitView.stashes.actions.stashCurrentWithCount",{count:f})]})]}),t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:x("gitView.stashes.includeUntrackedHint")})]}),t.jsxs("div",{className:"relative mt-2",children:[t.jsx(T,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(gr,{value:V,onChange:u=>L(u.target.value),placeholder:x("gitView.stashes.searchPlaceholder"),className:"pl-9"})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:M?t.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:t.jsx(T,{name:"loader-4",className:"size-5 animate-spin"})}):I.length===0?t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:x(V?"gitView.stashes.empty.search":"gitView.stashes.empty.list")}):I.map((u,E)=>t.jsxs("div",{className:"group flex items-center gap-2 rounded py-1.5 transition-colors hover:bg-interactive-hover/30",children:[t.jsxs("div",{className:"min-w-0 flex-1 pl-2",children:[t.jsx("p",{className:"typography-small truncate text-foreground",children:u.message||x("gitView.stashes.untitled")}),t.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[t.jsxs(es,{children:[t.jsx(ts,{asChild:!0,children:t.jsx("span",{children:E===0&&!V.trim()?x("gitView.stashes.latestLabel"):x("gitView.stashes.itemNumber",{number:E+1})})}),t.jsx(ss,{sideOffset:6,children:u.ref})]})," · ",u.relativeTime," · ",typeof D[u.ref]=="number"?x("gitView.stashes.fileCount",{count:D[u.ref]}):x("gitView.stashes.fileCountLoading")]})]}),t.jsxs("div",{className:"mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[t.jsx(Ms,{label:x("gitView.stashes.actions.apply"),loading:C===`apply:${u.ref}`,onClick:()=>Y(u,"apply"),disabled:B,children:t.jsx(T,{name:"inbox-unarchive",className:"size-4"})}),t.jsx(Ms,{label:x("gitView.stashes.actions.pop"),loading:C===`pop:${u.ref}`,onClick:()=>Y(u,"pop"),disabled:B,children:t.jsx(T,{name:"inbox-unarchive-fill",className:"size-4"})}),t.jsx(Ms,{label:x("gitView.stashes.actions.drop"),loading:C===`drop:${u.ref}`,onClick:()=>Y(u,"drop"),disabled:B,destructive:!0,children:t.jsx(T,{name:"delete-bin",className:"size-4"})})]})]},u.ref))})]})})},Ms=o=>{const e=Ct.c(17),{label:a,loading:m,disabled:N,destructive:f,onClick:p,children:x}=o,g=m||void 0,w=f?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground";let M;e[0]!==w?(M=Se("flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50",w),e[0]=w,e[1]=M):M=e[1];let v;e[2]!==x||e[3]!==m?(v=m?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):x,e[2]=x,e[3]=m,e[4]=v):v=e[4];let V;e[5]!==N||e[6]!==a||e[7]!==p||e[8]!==g||e[9]!==M||e[10]!==v?(V=t.jsx(ts,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":a,"aria-busy":g,className:M,onClick:p,disabled:N,children:v})}),e[5]=N,e[6]=a,e[7]=p,e[8]=g,e[9]=M,e[10]=v,e[11]=V):V=e[11];let L;e[12]!==a?(L=t.jsx(ss,{sideOffset:6,children:a}),e[12]=a,e[13]=L):L=e[13];let S;return e[14]!==V||e[15]!==L?(S=t.jsxs(es,{children:[V,L]}),e[14]=V,e[15]=L,e[16]=S):S=e[16],S},oi=o=>{const e=Ct.c(16),{onOpenStashes:a}=o,{t:m}=nt();let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(T,{name:"git-commit",className:"size-10 text-muted-foreground/70 mb-4"}),e[0]=N):N=e[0];let f;e[1]!==m?(f=m("gitView.empty.cleanTitle"),e[1]=m,e[2]=f):f=e[2];let p;e[3]!==f?(p=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:f}),e[3]=f,e[4]=p):p=e[4];let x;e[5]!==m?(x=m("gitView.empty.cleanDescription"),e[5]=m,e[6]=x):x=e[6];let g;e[7]!==x?(g=t.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:x}),e[7]=x,e[8]=g):g=e[8];let w;e[9]!==a||e[10]!==m?(w=a?t.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[t.jsx(T,{name:"archive-stack",className:"size-4"}),m("gitView.stashes.title")]}):null,e[9]=a,e[10]=m,e[11]=w):w=e[11];let M;return e[12]!==p||e[13]!==g||e[14]!==w?(M=t.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[N,p,g,w]}),e[12]=p,e[13]=g,e[14]=w,e[15]=M):M=e[15],M},ut=8,li=o=>{const e=Ct.c(18),{laned:a,totalLanes:m,isExpanded:N}=o,{lane:f,color:p,connectors:x}=a,w=Math.max(m,f+1)*ut+ut/2,M=l.useRef(null),v=l.useRef(null);let V;e[0]!==p||e[1]!==x||e[2]!==f||e[3]!==w?(V=()=>{const y=M.current,D=v.current;if(!y||!D)return;const k=y.offsetHeight;if(k===0)return;const R=window.devicePixelRatio||1;D.width=w*R,D.height=k*R;const I=D.getContext("2d");if(!I)return;I.scale(R,R),I.clearRect(0,0,w,k);const F=k/2,r=f*ut+ut/2,Y=getComputedStyle(D),B=Y.getPropertyValue("--surface-muted-foreground").trim()||Y.color,u=U=>{if(!U.startsWith("var("))return U;const G=U.slice(4,-1).trim();return Y.getPropertyValue(G).trim()||B},E=[...x].sort(di);for(const U of E){const G=U.fromLane*ut+ut/2,H=U.toLane*ut+ut/2,X=U.type==="passing"?.72:U.type==="branch-out"||U.type==="merge-in"?.95:1;I.beginPath(),I.strokeStyle=u(U.color),I.globalAlpha=X,I.lineWidth=1.25,I.lineCap="round";e:switch(U.type){case"passing":case"commit-lane":{I.moveTo(G,0),I.lineTo(G,k);break e}case"top-stub":{I.moveTo(G,0),I.lineTo(G,F);break e}case"bottom-stub":{I.moveTo(G,F),I.lineTo(G,k);break e}case"branch-out":{const $=(F+k)/2;I.moveTo(r,F),I.bezierCurveTo(r,$,H,$,H,k);break e}case"merge-in":{const $=F/2;I.moveTo(G,0),I.bezierCurveTo(G,$,r,$,r,F);break e}default:continue}I.stroke(),I.globalAlpha=1}const se=Y.getPropertyValue("--background").trim()||Y.getPropertyValue("--surface-background").trim();I.beginPath(),I.arc(r,F,4,0,Math.PI*2),I.fillStyle=u(p),I.fill(),I.beginPath(),I.arc(r,F,5,0,Math.PI*2),I.strokeStyle=se||B,I.lineWidth=2,I.stroke()},e[0]=p,e[1]=x,e[2]=f,e[3]=w,e[4]=V):V=e[4];let L;e[5]!==p||e[6]!==x||e[7]!==N||e[8]!==f||e[9]!==a||e[10]!==m||e[11]!==w?(L=[a,f,p,x,m,N,w],e[5]=p,e[6]=x,e[7]=N,e[8]=f,e[9]=a,e[10]=m,e[11]=w,e[12]=L):L=e[12],l.useLayoutEffect(V,L);let S;e[13]!==w?(S={width:w,height:"100%",position:"relative",flexShrink:0,overflow:"hidden"},e[13]=w,e[14]=S):S=e[14];let z;e[15]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("canvas",{ref:v,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),e[15]=z):z=e[15];let C;return e[16]!==S?(C=t.jsx("div",{ref:M,style:S,children:z}),e[16]=S,e[17]=C):C=e[17],C};function ci(o){return o==="branch-out"||o==="merge-in"}function di(o,e){const a=ci;return(a(o.type)?1:0)-(a(e.type)?1:0)}const yr=15e3,br=500,vr=12,jr=8*1024*1024,Cr=o=>typeof o=="string"?0:(o.original?.length??0)+(o.modified?.length??0),Nr=o=>{if(o.size<=vr){let N=0;for(const f of o.values())N+=Cr(f);if(N<=jr)return o}const e=Array.from(o.entries()).reverse(),a=new Map;let m=0;for(const[N,f]of e){if(a.size>=vr)continue;const p=Cr(f);m+p>jr&&a.size>0||(a.set(N,f),m+=p)}return new Map(Array.from(a.entries()).reverse())};function Sr(o,e){const a=new Date(o);return Number.isNaN(a.getTime())?o:Xn(a,e,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ui(o){switch(o){case"A":return"text-[var(--status-success)]";case"D":return"text-[var(--status-error)]";case"M":return"text-[var(--status-warning)]";case"R":return"text-[var(--status-info)]";default:return"text-muted-foreground"}}function mi(o){return o?o.split(",").map(e=>e.trim()).filter(Boolean).map(e=>{const a=e.startsWith("HEAD ->");return{label:a?e.replace("HEAD -> ",""):e.replace("tag: ",""),isHead:a,isTag:e.startsWith("tag: ")}}):[]}const hi=l.memo(({entry:o,mode:e="history",laned:a,totalLanes:m,isExpanded:N,onToggle:f,files:p,isLoadingFiles:x,onCopyHash:g,directory:w,onConflict:M,onActionSuccess:v})=>{const{t:V}=nt(),L=Rt(d=>d.timeFormatPreference),S=e==="graph",[z,C]=l.useState(null),[y,D]=l.useState(!1),[k,R]=l.useState(""),[I,F]=l.useState(null),[r,Y]=l.useState(new Set),[B,u]=l.useState(new Map),[E,se]=l.useState(new Set),U=async()=>{if(w){C("checkout");try{await aa(w,o.hash),b.success(V("gitView.history.actions.detachedHead")),v?.()}catch(d){b.error(String(d.message))}finally{C(null)}}},G=async()=>{if(!(!w||!k.trim())){C("createBranch");try{await Zn(w,k.trim(),o.hash),D(!1),R(""),v?.()}catch(d){b.error(String(d.message))}finally{C(null)}}},H=async()=>{if(w){C("cherryPick");try{const d=await na(w,o.hash);d.conflict?M?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"cherry-pick"}):v?.()}catch(d){b.error(String(d.message))}finally{C(null)}}},X=async()=>{if(w){C("revert");try{const d=await ra(w,o.hash);d.conflict?M?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"revert"}):v?.()}catch(d){b.error(String(d.message))}finally{C(null)}}},$=async(d,P=!1)=>{if(!(!w||z!==null)){C("reset");try{await ea(w,o.hash,d,P),v?.()}catch(O){b.error(String(O.message))}finally{C(null)}}},le=async()=>{if(!I)return;const d=I;switch(F(null),d){case"checkout":return U();case"cherryPick":return H();case"revert":return X();case"merge":return ae();case"rebase":return ce();case"resetSoft":return $("soft");case"resetMixed":return $("mixed");case"resetHard":return $("hard",!0)}},ae=async()=>{if(w){C("merge");try{const d=await sa(w,{branch:o.hash});d.conflict?M?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"merge"}):v?.()}catch(d){b.error(String(d.message))}finally{C(null)}}},ce=async()=>{if(w){C("rebase");try{const d=await ta(w,{onto:o.hash});d.conflict?M?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"rebase"}):v?.()}catch(d){b.error(String(d.message))}finally{C(null)}}},ie=l.useCallback(async d=>{const P=d.path;if(!w){u(O=>new Map(O).set(P,"error"));return}u(O=>Nr(new Map(O).set(P,"loading")));try{const O=Kn(w,o.hash,d.path,!1),K=new Promise((re,q)=>{setTimeout(()=>q(new Error(`Timed out after ${yr}ms`)),yr)}),ne=await Promise.race([O,K]);u(re=>Nr(new Map(re).set(P,ne)))}catch{u(O=>new Map(O).set(P,"error"))}},[w,o.hash]),h=l.useCallback(async d=>{const P=d.path;if(d.changeType==="R"||d.isBinary){Y(re=>{const q=new Set(re);return q.has(P)?q.delete(P):q.add(P),q});return}const O=B.get(P);if(r.has(P)&&O&&O!=="error"){Y(re=>{const q=new Set(re);return q.delete(P),q});return}Y(re=>{const q=new Set(re);return q.add(P),q}),!(O&&O!=="error"||d.insertions+d.deletions>br&&!E.has(P))&&await ie(d)},[B,E,ie,r]);return t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:f,className:Se("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",S?"hover:bg-[var(--interactive-hover)]/40":N?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[S&&a&&m!==void 0?t.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:t.jsx(li,{laned:a,totalLanes:m,isExpanded:N})}):t.jsx("div",{className:"h-2 w-2 translate-y-2 rounded-full shrink-0",style:{backgroundColor:"var(--status-success)"},"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[S?(()=>{const d=mi(o.refs);return d.length>0?t.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:d.map(P=>t.jsx("span",{className:Se("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",P.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":P.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:P.label},P.label))}):null})():null,t.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:o.message}),t.jsxs("div",{className:"flex items-center gap-1 typography-meta text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[t.jsx("span",{className:"truncate min-w-[3ch]",title:o.author_name,children:o.author_name}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("span",{className:"truncate min-w-0",title:Sr(o.date,L),children:Sr(o.date,L)})]}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("code",{className:"shrink-0 font-mono",children:o.hash.slice(0,8)}),t.jsxs(es,{children:[t.jsx(ts,{asChild:!0,children:t.jsx(W,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:d=>{d.stopPropagation(),g(o.hash)},children:t.jsx(T,{name:"file-copy",className:"size-3"})})}),t.jsx(ss,{sideOffset:8,children:V("gitView.history.copySha")})]})]})]})]}),N&&t.jsxs("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:[S&&I?t.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-border/30 mb-2",children:[t.jsx("span",{className:"typography-micro text-muted-foreground flex-1 min-w-0",children:V(`gitView.history.actions.${I}Confirm`)}),t.jsxs(W,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:z!==null,onClick:d=>{d.stopPropagation(),le()},children:[z!==null?t.jsx(T,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.confirmButton")]}),t.jsx(W,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:z!==null,onClick:d=>{d.stopPropagation(),F(null)},children:V("gitView.history.actions.cancelButton")})]}):S?t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2",children:[t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("checkout")},children:V("gitView.history.actions.checkout")}),y?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{autoFocus:!0,value:k,onChange:d=>R(d.target.value),onKeyDown:d=>{d.key==="Enter"&&G(),d.key==="Escape"&&(D(!1),R(""))},placeholder:V("gitView.history.actions.createBranchPlaceholder"),className:"h-6 text-xs px-2 rounded border border-border/60 bg-background min-w-0 w-32"}),t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:!k.trim()||z!==null,onClick:d=>{d.stopPropagation(),G()},children:[z==="createBranch"?t.jsx(T,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.createBranchConfirm")]})]}):t.jsx(W,{variant:"outline",size:"xs",className:"h-6",onClick:d=>{d.stopPropagation(),D(!0)},children:V("gitView.history.actions.createBranch")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("cherryPick")},children:V("gitView.history.actions.cherryPick")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("revert")},children:V("gitView.history.actions.revert")}),t.jsxs(Ts,{children:[t.jsx(Ls,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>d.stopPropagation(),children:[z==="reset"?t.jsx(T,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.reset")]})}),t.jsx(Os,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(d=>t.jsx(Yn,{disabled:z!==null,onSelect:P=>{P.stopPropagation(),F(`reset${d.charAt(0).toUpperCase()+d.slice(1)}`)},children:V(`gitView.history.actions.reset${d.charAt(0).toUpperCase()+d.slice(1)}`)},d))})]}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("merge")},children:V("gitView.history.actions.merge")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:z!==null,onClick:d=>{d.stopPropagation(),F("rebase")},children:V("gitView.history.actions.rebase")})]}):null,x?t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:V("gitView.history.loadingFiles")})]}):p.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:V("gitView.history.noFiles")}):t.jsx("ul",{className:"space-y-0.5 py-2",children:p.map(d=>t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:()=>h(d),className:Se("w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1",r.has(d.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[t.jsx("span",{className:Se("font-semibold w-3 text-center shrink-0",ui(d.changeType)),children:d.changeType}),t.jsx("span",{className:"truncate text-foreground min-w-0",title:d.path,children:d.path}),!d.isBinary&&t.jsxs("span",{className:"shrink-0",children:[t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",d.insertions]}),t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",d.deletions]})]}),d.isBinary&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:V("gitView.history.binary")}),t.jsx(T,{name:r.has(d.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),r.has(d.path)&&t.jsx("div",{className:"max-h-[400px] overflow-y-auto rounded border border-border/40 mx-2 mb-1","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:d.changeType==="R"?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.renamedNoDiff")}):d.isBinary?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.binaryNoDiff")}):(()=>{const P=d.insertions+d.deletions;if(!E.has(d.path)&&P>br)return t.jsxs("div",{className:"flex flex-col items-start gap-1 px-3 py-2 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:V("gitView.history.largeDiffTitle",{count:P})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:V("gitView.history.largeDiffDescription")}),t.jsx(W,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{se(K=>new Set(K).add(d.path)),ie(d)},children:V("gitView.history.renderDiffAnyway")})]});const O=B.get(d.path);return O==="loading"||O===void 0?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.loadingDiff")}):O==="error"?t.jsx("button",{type:"button",onClick:()=>h(d),className:"w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:V("gitView.history.diffError")}):t.jsx(Ka,{original:O.original,modified:O.modified,language:Qn(d.path)||"",fileName:d.path,renderSideBySide:!1,layout:"inline",enableComments:!1})})()})]},d.path))})]})]})}),kr=["var(--chart-1)","var(--chart-2)","var(--chart-3)","var(--chart-4)","var(--chart-5)","var(--syntax-keyword)","var(--syntax-string)","var(--status-info)"];function Kt(o){return kr[o%kr.length]}function gi(o){if(o.length===0)return[];const e=[],a=[];for(let m=0;m<o.length;m++){const N=o[m],f=[];for(let S=0;S<e.length;S++)e[S]===N.hash&&f.push(S);let p=f.length>0?f[0]:-1;if(p===-1){const S=e.indexOf(null);S!==-1?p=S:(p=e.length,e.push(null))}const x=f.slice(1),g=Kt(p),w=e[p]===N.hash,M=N.parents.length>0;M?e[p]=N.parents[0]:e[p]=null;const v=[],V=new Set;for(let S=1;S<N.parents.length;S++){const z=N.parents[S],C=e.indexOf(z);if(C!==-1)v.push(C);else{const y=e.indexOf(null);if(y!==-1)e[y]=z,v.push(y),V.add(y);else{const D=e.length;e.push(z),v.push(D),V.add(D)}}}const L=[];w&&M?L.push({fromLane:p,toLane:p,color:g,type:"commit-lane"}):w&&!M?L.push({fromLane:p,toLane:p,color:g,type:"top-stub"}):!w&&M&&L.push({fromLane:p,toLane:p,color:g,type:"bottom-stub"});for(const S of x)L.push({fromLane:S,toLane:p,color:Kt(S),type:"merge-in"}),e[S]=null;for(const S of v)L.push({fromLane:p,toLane:S,color:Kt(S),type:"branch-out"});for(let S=0;S<e.length;S++)e[S]!==null&&S!==p&&(V.has(S)||L.push({fromLane:S,toLane:S,color:Kt(S),type:"passing"}));a.push({commit:N,lane:p,color:g,connectors:L})}return a}const fi=[{labelKey:"gitView.history.logSize25",value:25},{labelKey:"gitView.history.logSize50",value:50},{labelKey:"gitView.history.logSize100",value:100}],pi=o=>{const e=Ct.c(84),{mode:a,log:m,isLogLoading:N,logMaxCount:f,onLogMaxCountChange:p,expandedCommitHashes:x,onToggleCommit:g,commitFilesMap:w,loadingCommitHashes:M,onCopyHash:v,directory:V,showHeader:L,contentMaxHeightClassName:S,branchDivider:z,onConflict:C,onActionSuccess:y}=o,D=a===void 0?"history":a,k=L===void 0?!0:L,R=S===void 0?"max-h-[50vh]":S,I=z===void 0?null:z,{t:F}=nt(),[r,Y]=l.useState(!0),B=D==="graph";let u;e[0]!==B||e[1]!==m?(u=B&&m?gi(m.all):[],e[0]=B,e[1]=m,e[2]=u):u=e[2];const E=u;let se;e[3]!==E?(se=Math.max(1,...E.map(xi)),e[3]=E,e[4]=se):se=e[4];const U=se;let G;e[5]!==E?(G=new Map(E.map(wi)),e[5]=E,e[6]=G):G=e[6];const H=G;if(!m)return null;const X=I!==null&&I.insertBeforeIndex>0&&I.insertBeforeIndex<m.all.length,$=I!==null&&I.insertBeforeIndex===m.all.length,le=X||$;let ae;e[7]!==I||e[8]!==X||e[9]!==$||e[10]!==m.all?(ae=X?m.all.slice(0,I.insertBeforeIndex):$?m.all:[],e[7]=I,e[8]=X,e[9]=$,e[10]=m.all,e[11]=ae):ae=e[11];const ce=ae;let ie;if(e[12]!==I||e[13]!==w||e[14]!==R||e[15]!==V||e[16]!==x||e[17]!==X||e[18]!==le||e[19]!==B||e[20]!==N||e[21]!==H||e[22]!==M||e[23]!==m.all||e[24]!==f||e[25]!==U||e[26]!==D||e[27]!==y||e[28]!==C||e[29]!==v||e[30]!==p||e[31]!==g||e[32]!==F||e[33]!==ce){const J=X?m.all.slice(I.insertBeforeIndex):[];let de;e[35]!==I?.direction?(de=I?.direction==="down"?t.jsx(T,{name:"arrow-down-s",className:"size-3.5"}):t.jsx(T,{name:"arrow-up",className:"size-3.5"}),e[35]=I?.direction,e[36]=de):de=e[36];const ke=de;let ye;e[37]!==w||e[38]!==V||e[39]!==x||e[40]!==B||e[41]!==H||e[42]!==M||e[43]!==U||e[44]!==D||e[45]!==y||e[46]!==C||e[47]!==v||e[48]!==g?(ye=Re=>t.jsx("ul",{className:"divide-y divide-border/60",children:Re.map(ue=>t.jsx(hi,{entry:ue,mode:D,laned:B?H.get(ue.hash):void 0,totalLanes:B?U:void 0,isExpanded:x.has(ue.hash),onToggle:()=>g(ue.hash),files:w.get(ue.hash)??[],isLoadingFiles:M.has(ue.hash),onCopyHash:v,directory:V,onConflict:C,onActionSuccess:y},ue.hash))}),e[37]=w,e[38]=V,e[39]=x,e[40]=B,e[41]=H,e[42]=M,e[43]=U,e[44]=D,e[45]=y,e[46]=C,e[47]=v,e[48]=g,e[49]=ye):ye=e[49];const me=ye;let xe;e[50]!==N||e[51]!==m.all.length||e[52]!==f||e[53]!==p||e[54]!==F?(xe=m.all.length>=f?t.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:t.jsx(W,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(f+25),disabled:N,className:"px-3 text-muted-foreground hover:text-foreground",children:N?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(T,{name:"loader-4",className:"size-3 animate-spin"}),F("gitView.history.loadingMore")]}):F("gitView.history.loadMore")})}):null,e[50]=N,e[51]=m.all.length,e[52]=f,e[53]=p,e[54]=F,e[55]=xe):xe=e[55];const Ve=xe;ie=t.jsx(Rr,{outerClassName:`min-h-0 ${R}`,className:"h-full w-full",children:m.all.length===0?t.jsx("div",{className:"flex h-full items-center justify-center p-4",children:t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:F("gitView.history.noCommits")})}):le&&I?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-0",children:[ce.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:me(ce)}):null,t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5","aria-hidden":!0,children:[t.jsx("span",{className:"h-px flex-1 bg-border/60"}),t.jsxs("span",{className:"inline-flex max-w-[80%] items-center gap-1 typography-micro text-muted-foreground",children:[t.jsx("span",{className:"truncate",title:I.branchName,children:I.branchName}),ke]}),t.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),J.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:me(J)}):null]}),Ve]}):t.jsxs(t.Fragment,{children:[me(m.all),Ve]})}),e[12]=I,e[13]=w,e[14]=R,e[15]=V,e[16]=x,e[17]=X,e[18]=le,e[19]=B,e[20]=N,e[21]=H,e[22]=M,e[23]=m.all,e[24]=f,e[25]=U,e[26]=D,e[27]=y,e[28]=C,e[29]=v,e[30]=p,e[31]=g,e[32]=F,e[33]=ce,e[34]=ie}else ie=e[34];const h=ie;if(!k){if(le){let de;return e[56]!==h?(de=t.jsx("section",{className:"h-full min-h-0",children:h}),e[56]=h,e[57]=de):de=e[57],de}let J;return e[58]!==h?(J=t.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:h}),e[58]=h,e[59]=J):J=e[59],J}let d;e[60]!==F?(d=F("gitView.history.title"),e[60]=F,e[61]=d):d=e[61];let P;e[62]!==d?(P=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:d}),e[62]=d,e[63]=P):P=e[63];let O;e[64]!==N||e[65]!==r||e[66]!==f||e[67]!==p||e[68]!==F?(O=r&&t.jsx("div",{onClick:yi,onPointerDown:bi,children:t.jsxs(ia,{value:String(f),onValueChange:J=>p(Number(J)),disabled:N,children:[t.jsx(oa,{size:"sm",className:"w-auto",disabled:N,children:t.jsx(la,{placeholder:F("gitView.history.commitsPlaceholder")})}),t.jsx(ca,{children:fi.map(J=>t.jsx(da,{value:String(J.value),children:F(J.labelKey)},J.value))})]})}),e[64]=N,e[65]=r,e[66]=f,e[67]=p,e[68]=F,e[69]=O):O=e[69];let K;e[70]!==r?(K=r?t.jsx(T,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):t.jsx(T,{name:"arrow-down-s",className:"size-4 text-muted-foreground"}),e[70]=r,e[71]=K):K=e[71];let ne;e[72]!==O||e[73]!==K?(ne=t.jsxs("div",{className:"flex items-center gap-2",children:[O,K]}),e[72]=O,e[73]=K,e[74]=ne):ne=e[74];let re;e[75]!==P||e[76]!==ne?(re=t.jsxs(ua,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[P,ne]}),e[75]=P,e[76]=ne,e[77]=re):re=e[77];let q;e[78]!==h?(q=t.jsx(ma,{children:h}),e[78]=h,e[79]=q):q=e[79];let we;return e[80]!==r||e[81]!==re||e[82]!==q?(we=t.jsxs(ha,{open:r,onOpenChange:Y,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[re,q]}),e[80]=r,e[81]=re,e[82]=q,e[83]=we):we=e[83],we};function xi(o){return o.lane+1}function wi(o){return[o.commit.hash,o]}function yi(o){return o.stopPropagation()}function bi(o){return o.stopPropagation()}const vi=o=>{const e=Ct.c(148),{open:a,onOpenChange:m,conflictFiles:N,directory:f,operation:p,onAbort:x,onClearState:g}=o;let w;e[0]!==N?(w=N===void 0?[]:N,e[0]=N,e[1]=w):w=e[1];const M=w,{t:v}=nt(),V=rt(ji),L=rt(Ci),S=Qt(Ni),z=Qt(Si),[C,y]=l.useState(!1),[D,k]=l.useState(null),[R,I]=l.useState(null);let F,r;e[2]!==f||e[3]!==a||e[4]!==v?(F=()=>{!a||!f||(y(!0),I(null),k(null),ga(f).then(ee=>{k(ee)}).catch(ee=>{const he=ee instanceof Error?ee.message:v("gitView.conflict.loadFailed");I(he)}).finally(()=>{y(!1)}))},r=[a,f,v],e[2]=f,e[3]=a,e[4]=v,e[5]=F,e[6]=r):(F=e[5],r=e[6]),l.useEffect(F,r);let Y;e[7]!==D||e[8]!==f||e[9]!==p?(Y=async()=>{if(!D)return null;const ee=p==="merge"?"merge":"rebase",he=D.headInfo||(p==="merge"?"MERGE_HEAD":"REBASE_HEAD"),Be=p==="merge"?"git commit --no-edit":"git rebase --continue",ge=await Yt("git.conflict.resolve.visible",{operation_label:ee,head_ref:he}),Ne=await Yt("git.conflict.resolve.instructions",{operation_label:ee,directory:f,operation:p,head_info:D.headInfo||"N/A",continue_cmd:Be}),Pe=`${ee} conflict context (JSON)
|
|
3
|
-
${JSON.stringify({directory:f,operation:D.operation,headInfo:D.headInfo,statusPorcelain:D.statusPorcelain,unmergedFiles:D.unmergedFiles,diff:D.diff},null,2)}`;return{visibleText:ge,instructionsText:Ne,payloadText:Pe}},e[7]=D,e[8]=f,e[9]=p,e[10]=Y):Y=e[10];const B=Y;let u;e[11]!==x||e[12]!==m?(u=()=>{x(),m(!1)},e[11]=x,e[12]=m,e[13]=u):u=e[13];const E=u;let se;e[14]!==g||e[15]!==m?(se=()=>{g?.(),m(!1)},e[14]=g,e[15]=m,e[16]=se):se=e[16];const U=se;let G;e[17]!==B||e[18]!==L||e[19]!==g||e[20]!==m||e[21]!==S||e[22]!==z||e[23]!==v?(G=async()=>{const ee=await B();if(!ee){b.error(v("gitView.conflict.noDetailsAvailable"));return}if(!L){b.error(v("gitView.conflict.noActiveSession"),{description:v("gitView.conflict.noActiveSessionDescription")});return}S(ee.visibleText,"replace"),z([{text:ee.instructionsText,synthetic:!0},{text:ee.payloadText,synthetic:!0}]),g?.(),m(!1)},e[17]=B,e[18]=L,e[19]=g,e[20]=m,e[21]=S,e[22]=z,e[23]=v,e[24]=G):G=e[24];const H=G;let X;e[25]!==B||e[26]!==f||e[27]!==g||e[28]!==m||e[29]!==V||e[30]!==v?(X=async()=>{const ee=await B();if(!ee){b.error(v("gitView.conflict.noDetailsAvailable"));return}V({directoryOverride:f,initialPrompt:ee.visibleText,syntheticParts:[{text:ee.instructionsText,synthetic:!0},{text:ee.payloadText,synthetic:!0}]}),g?.(),m(!1)},e[25]=B,e[26]=f,e[27]=g,e[28]=m,e[29]=V,e[30]=v,e[31]=X):X=e[31];const $=X;let le,ae,ce,ie,h,d,P,O,K,ne,re,q,we,J,de,ke,ye,me,xe,Ve,Re,ue;if(e[32]!==D||e[33]!==M||e[34]!==L||e[35]!==E||e[36]!==U||e[37]!==H||e[38]!==$||e[39]!==C||e[40]!==R||e[41]!==m||e[42]!==a||e[43]!==p||e[44]!==v){const ee=v(p==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),he=D?.unmergedFiles||M;ce=mt,Re=a,ue=m,ae=ht,Ve="max-w-md w-[calc(100vw-2rem)]",J="flex flex-col gap-4 overflow-hidden";let Be;e[67]===Symbol.for("react.memo_cache_sentinel")?(Be=t.jsx(T,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e[67]=Be):Be=e[67];const ge=t.jsxs("div",{className:"flex items-center gap-2",children:[Be,t.jsx(ft,{children:v("gitView.conflict.detectedTitle",{operation:ee})})]});let Ne;e[68]!==p||e[69]!==v?(Ne=v("gitView.conflict.detectedDescription",{operation:p}),e[68]=p,e[69]=v,e[70]=Ne):Ne=e[70];let Pe;e[71]!==Ne?(Pe=t.jsx(bt,{children:Ne}),e[71]=Ne,e[72]=Pe):Pe=e[72],e[73]!==ge||e[74]!==Pe?(de=t.jsxs(gt,{children:[ge,Pe]}),e[73]=ge,e[74]=Pe,e[75]=de):de=e[75],e[76]!==C||e[77]!==v?(ke=C&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-meta",children:v("gitView.conflict.loading")})]}),e[76]=C,e[77]=v,e[78]=ke):ke=e[78],e[79]!==R||e[80]!==v?(ye=R&&t.jsx("div",{className:"rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words",children:v("gitView.conflict.errorLoadingDetails",{message:R})}),e[79]=R,e[80]=v,e[81]=ye):ye=e[81],e[82]!==he||e[83]!==v?(me=he.length>0&&t.jsxs("div",{className:"space-y-2 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:v("gitView.conflict.conflictedFiles")}),t.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground",children:he.length})]}),t.jsx("div",{className:"bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden",children:t.jsx("ul",{className:"space-y-1",children:he.map(ki)})})]}),e[82]=he,e[83]=v,e[84]=me):me=e[84],e[85]!==D||e[86]!==v?(xe=D?.headInfo&&t.jsxs("div",{className:"space-y-1 overflow-hidden",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:v("gitView.conflict.headInfo")}),t.jsx("div",{className:"typography-micro text-foreground font-mono bg-[var(--surface-elevated)] rounded-lg p-3 max-h-24 overflow-y-auto break-words whitespace-pre-wrap",children:D.headInfo})]}),e[85]=D,e[86]=v,e[87]=xe):xe=e[87],re="flex flex-col gap-2 pt-2";let Te;e[88]!==$?(Te=()=>{$()},e[88]=$,e[89]=Te):Te=e[89];const oe=C||!D;let Ie;e[90]!==C?(Ie=C?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"add",className:"size-4"}),e[90]=C,e[91]=Ie):Ie=e[91];let Fe;e[92]!==v?(Fe=v("gitView.conflict.resolveNewSession"),e[92]=v,e[93]=Fe):Fe=e[93],e[94]!==Te||e[95]!==oe||e[96]!==Ie||e[97]!==Fe?(q=t.jsxs(W,{variant:"default",onClick:Te,disabled:oe,className:"w-full gap-2",children:[Ie,Fe]}),e[94]=Te,e[95]=oe,e[96]=Ie,e[97]=Fe,e[98]=q):q=e[98];let De;e[99]!==H?(De=()=>{H()},e[99]=H,e[100]=De):De=e[100];const Ue=C||!D||!L;let Le;e[101]!==C?(Le=C?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"chat-1",className:"size-4"}),e[101]=C,e[102]=Le):Le=e[102];let Q;e[103]!==v?(Q=v("gitView.conflict.resolveCurrentSession"),e[103]=v,e[104]=Q):Q=e[104],e[105]!==De||e[106]!==Ue||e[107]!==Le||e[108]!==Q?(we=t.jsxs(W,{variant:"outline",onClick:De,disabled:Ue,className:"w-full gap-2",children:[Le,Q]}),e[105]=De,e[106]=Ue,e[107]=Le,e[108]=Q,e[109]=we):we=e[109],K="flex gap-2 pt-1";let fe;e[110]!==v?(fe=v("gitView.conflict.continueLater"),e[110]=v,e[111]=fe):fe=e[111],e[112]!==U||e[113]!==fe?(ne=t.jsx(W,{variant:"ghost",size:"sm",onClick:U,className:"flex-1",children:fe}),e[112]=U,e[113]=fe,e[114]=ne):ne=e[114],le=W,ie="destructive",h="sm",d=E,P="flex-1",O=v("gitView.conflict.abortOperation",{operation:ee}),e[32]=D,e[33]=M,e[34]=L,e[35]=E,e[36]=U,e[37]=H,e[38]=$,e[39]=C,e[40]=R,e[41]=m,e[42]=a,e[43]=p,e[44]=v,e[45]=le,e[46]=ae,e[47]=ce,e[48]=ie,e[49]=h,e[50]=d,e[51]=P,e[52]=O,e[53]=K,e[54]=ne,e[55]=re,e[56]=q,e[57]=we,e[58]=J,e[59]=de,e[60]=ke,e[61]=ye,e[62]=me,e[63]=xe,e[64]=Ve,e[65]=Re,e[66]=ue}else le=e[45],ae=e[46],ce=e[47],ie=e[48],h=e[49],d=e[50],P=e[51],O=e[52],K=e[53],ne=e[54],re=e[55],q=e[56],we=e[57],J=e[58],de=e[59],ke=e[60],ye=e[61],me=e[62],xe=e[63],Ve=e[64],Re=e[65],ue=e[66];let He;e[115]!==le||e[116]!==ie||e[117]!==h||e[118]!==d||e[119]!==P||e[120]!==O?(He=t.jsx(le,{variant:ie,size:h,onClick:d,className:P,children:O}),e[115]=le,e[116]=ie,e[117]=h,e[118]=d,e[119]=P,e[120]=O,e[121]=He):He=e[121];let Ae;e[122]!==K||e[123]!==ne||e[124]!==He?(Ae=t.jsxs("div",{className:K,children:[ne,He]}),e[122]=K,e[123]=ne,e[124]=He,e[125]=Ae):Ae=e[125];let je;e[126]!==re||e[127]!==q||e[128]!==we||e[129]!==Ae?(je=t.jsxs("div",{className:re,children:[q,we,Ae]}),e[126]=re,e[127]=q,e[128]=we,e[129]=Ae,e[130]=je):je=e[130];let be;e[131]!==J||e[132]!==de||e[133]!==ke||e[134]!==ye||e[135]!==me||e[136]!==xe||e[137]!==je?(be=t.jsxs("div",{className:J,children:[de,ke,ye,me,xe,je]}),e[131]=J,e[132]=de,e[133]=ke,e[134]=ye,e[135]=me,e[136]=xe,e[137]=je,e[138]=be):be=e[138];let Ce;e[139]!==ae||e[140]!==Ve||e[141]!==be?(Ce=t.jsx(ae,{className:Ve,children:be}),e[139]=ae,e[140]=Ve,e[141]=be,e[142]=Ce):Ce=e[142];let Ee;return e[143]!==ce||e[144]!==Re||e[145]!==ue||e[146]!==Ce?(Ee=t.jsx(ce,{open:Re,onOpenChange:ue,children:Ce}),e[143]=ce,e[144]=Re,e[145]=ue,e[146]=Ce,e[147]=Ee):Ee=e[147],Ee};function ji(o){return o.openNewSessionDraft}function Ci(o){return o.currentSessionId}function Ni(o){return o.setPendingInputText}function Si(o){return o.setPendingSyntheticParts}function ki(o){return t.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:o,children:o},o)}const Vi=({open:o,onOpenChange:e,operation:a,targetBranch:m,onConfirm:N})=>{const{t:f}=nt(),[p,x]=l.useState(!0),[g,w]=l.useState(!1),M=f(a==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),v=async()=>{w(!0);try{await N(p),e(!1)}catch(L){const S=L instanceof Error?L.message:`Failed to ${a}`;b.error(S)}finally{w(!1)}},V=()=>{g||e(!1)};return t.jsx(mt,{open:o,onOpenChange:g?void 0:e,children:t.jsxs(ht,{className:"max-w-md",children:[t.jsxs(gt,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(T,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),t.jsx(ft,{children:f("gitView.stash.title")})]}),t.jsx(bt,{children:f("gitView.stash.description",{operation:a})})]}),t.jsxs("div",{className:"py-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:f("gitView.stash.thisWill")}),t.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[t.jsx("li",{children:f("gitView.stash.stepStash")}),t.jsxs("li",{children:[f(a==="merge"?"gitView.operation.merge":"gitView.operation.rebase")," ",f(a==="merge"?"gitView.stash.mergeWith":"gitView.stash.rebaseOnto")," ",t.jsx("span",{className:"font-mono text-primary",children:m})]}),p&&t.jsx("li",{children:f("gitView.stash.stepRestore")})]})]}),t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(fa,{checked:p,onChange:x,disabled:g,ariaLabel:f("gitView.stash.restoreAria")}),t.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!g&&x(!p),children:f("gitView.stash.restoreAfterOperation",{operation:a})})]}),t.jsxs(Es,{className:"gap-2",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:V,disabled:g,children:f("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:v,disabled:g,className:"gap-1.5",children:g?t.jsxs(t.Fragment,{children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),f("gitView.common.processing")]}):f("gitView.stash.confirmButton",{operation:M})})]})]})})},Pi=({mergeInProgress:o,rebaseInProgress:e,onContinue:a,onAbort:m,onResolveWithAI:N,conflictCount:f=0,isLoading:p=!1})=>{const{t:x}=nt(),[g,w]=l.useState(null),M=o&&o.head,v=e&&(e.headName||e.onto),V=M?"merge":v?"rebase":null;if(!V)return null;const L=async()=>{w("continue");try{await a()}finally{w(null)}},S=async()=>{w("abort");try{await m()}finally{w(null)}},z=g!==null,C=f>0,y=x(V==="merge"?"gitView.operation.merge":"gitView.operation.rebase");let D="";o?D=o.message?x("gitView.operation.mergingMessage",{message:o.message}):x("gitView.operation.mergeInProgressWithHead",{head:o.head}):e&&(D=e.headName?x("gitView.operation.rebasingOnto",{headName:e.headName,onto:e.onto||""}):x("gitView.operation.rebaseInProgress"));const k=C?f===1?x("gitView.operation.inProgressTitleOneConflict",{operation:y,count:f}):x("gitView.operation.inProgressTitleManyConflicts",{operation:y,count:f}):x("gitView.operation.inProgressTitle",{operation:y}),R=x(C?"gitView.operation.resolveConflictsHint":"gitView.operation.readyToContinueHint");return t.jsx("div",{className:"mx-4 mt-3 overflow-hidden rounded-lg border border-[var(--status-warning-border)]",children:t.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"typography-label text-[var(--status-warning)]",children:k}),D&&t.jsx("p",{className:"typography-micro break-words text-muted-foreground",children:D})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"typography-micro min-w-0 flex-1 text-muted-foreground",children:R}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs(W,{variant:"ghost",size:"sm",onClick:S,disabled:z||p,className:"gap-1.5",children:[g==="abort"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"close",className:"size-4"}),x("gitView.operation.abort")]}),C?N&&t.jsx(W,{variant:"default",size:"sm",onClick:N,disabled:z||p,children:x("gitView.operation.resolveWithAi")}):t.jsxs(W,{variant:"default",size:"sm",onClick:L,disabled:z||p,className:"gap-1.5",children:[g==="continue"?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"check",className:"size-4"}),x("gitView.operation.continue")]})]})]})]})})},Ii=o=>{const e=Ct.c(104),{currentBranch:a,localBranches:m,remoteBranches:N,onMerge:f,onRebase:p,disabled:x,isOperating:g,operationLogs:w,onOperationComplete:M,mode:v,defaultTargetBranch:V}=o,L=x===void 0?!1:x,S=g===void 0?!1:g,z=w===void 0?[]:w,C=v===void 0?"dialog":v,{t:y}=nt(),[D,k]=l.useState(!1),[R,I]=l.useState("merge"),[F,r]=l.useState(null),[Y,B]=l.useState(!1),[u,E]=l.useState(""),se=l.useRef(null),U=l.useRef(null),G=L||S,H=a||y("gitView.branch.currentBranchFallback"),X=z.length>0&&z.every(Fi),$=z.some(Ri);let le;e[0]===Symbol.for("react.memo_cache_sentinel")?(le=()=>{U.current&&(U.current.scrollTop=U.current.scrollHeight)},e[0]=le):le=e[0],l.useEffect(le,[z]);let ae;e[1]!==N?(ae=new Set(N.map(Bi).filter(Boolean)),e[1]=N,e[2]=ae):ae=e[2];const ce=ae;let ie;if(e[3]!==u||e[4]!==a||e[5]!==m||e[6]!==ce){let Q;e[8]!==a||e[9]!==ce?(Q=Oe=>Oe!==a&&!ce.has(Oe),e[8]=a,e[9]=ce,e[10]=Q):Q=e[10];const fe=m.filter(Q);ie=Dt(fe,u,Di),e[3]=u,e[4]=a,e[5]=m,e[6]=ce,e[7]=ie}else ie=e[7];const h=ie;let d;e[11]!==u||e[12]!==N?(d=Dt(N,u,Mi),e[11]=u,e[12]=N,e[13]=d):d=e[13];const P=d;let O;e[14]!==V||e[15]!==m||e[16]!==N?(O=()=>V&&(N.includes(V)||m.includes(V))?V:null,e[14]=V,e[15]=m,e[16]=N,e[17]=O):O=e[17];const K=O;let ne;e[18]!==K||e[19]!==k?(ne=()=>{k(!0),r(K()),I("merge"),E("")},e[18]=K,e[19]=k,e[20]=ne):ne=e[20];const re=ne;let q;e[21]===Symbol.for("react.memo_cache_sentinel")?(q=Q=>{r(Q),B(!1),E("")},e[21]=q):q=e[21];const we=q;let J;e[22]!==f||e[23]!==p||e[24]!==R||e[25]!==F?(J=()=>{F&&(R==="merge"?f(F):p(F))},e[22]=f,e[23]=p,e[24]=R,e[25]=F,e[26]=J):J=e[26];const de=J;let ke;e[27]!==S||e[28]!==k?(ke=()=>{S||(r(null),I("merge"),E(""),k(!1))},e[27]=S,e[28]=k,e[29]=ke):ke=e[29];const ye=ke,me=()=>{S&&!X||(X&&M?.(),r(null),I("merge"),E(""),k(!1))};let xe,Ve;e[30]!==Y?(xe=()=>{Y||E("")},Ve=[Y],e[30]=Y,e[31]=xe,e[32]=Ve):(xe=e[31],Ve=e[32]),l.useEffect(xe,Ve);let Re,ue;e[33]!==C||e[34]!==K||e[35]!==F?(Re=()=>{C==="dialog"||F||r(K())},ue=[C,K,F],e[33]=C,e[34]=K,e[35]=F,e[36]=Re,e[37]=ue):(Re=e[36],ue=e[37]),l.useEffect(Re,ue);const je=S?t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{ref:U,className:"rounded-lg border border-border bg-muted/30 p-3 max-h-48 overflow-y-auto",children:t.jsx("div",{className:"space-y-2",children:z.map(Ei)})}),X?C==="dialog"?t.jsx(Es,{children:t.jsx(W,{variant:"default",size:"sm",onClick:me,children:y($?"gitView.common.close":"gitView.common.done")})}):t.jsx("div",{className:"flex justify-end",children:t.jsx(W,{variant:"default",size:"sm",onClick:me,children:y($?"gitView.common.close":"gitView.common.done")})}):null]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:y("gitView.branch.operation")}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>I("merge"),className:Se("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",R==="merge"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(T,{name:"git-merge",className:Se("size-4",R==="merge"?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Se("typography-ui-label",R==="merge"?"text-foreground":"text-muted-foreground"),children:y("gitView.operation.merge")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:y("gitView.branch.mergeDescription")})]}),t.jsxs("button",{type:"button",onClick:()=>I("rebase"),className:Se("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",R==="rebase"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(T,{name:"git-branch",className:Se("size-4",R==="rebase"?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Se("typography-ui-label",R==="rebase"?"text-foreground":"text-muted-foreground"),children:y("gitView.operation.rebase")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:y("gitView.branch.rebaseDescription")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:R==="merge"?y("gitView.branch.branchToMergeInto",{branch:H}):y("gitView.branch.branchToRebaseOnto")}),t.jsxs(Ts,{open:Y,onOpenChange:B,modal:!1,children:[t.jsx(Ls,{asChild:!0,children:t.jsxs("button",{type:"button",className:Se(Fr({size:"default"}),"w-full"),children:[t.jsx("span",{className:Se("truncate",!F&&"text-muted-foreground"),children:F||y("gitView.branch.selectBranch")}),t.jsx(T,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),t.jsx(Os,{align:"start",sideOffset:6,className:"w-[var(--anchor-width)] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",children:t.jsxs(As,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(zs,{ref:se,placeholder:y("gitView.branch.searchPlaceholder"),value:u,onValueChange:E,onKeyDown:Ti}),t.jsxs(Gs,{className:"h-full min-h-0",disableHorizontal:!0,children:[t.jsx(_s,{children:y("gitView.branch.empty")}),h.length>0&&t.jsx(Xt,{heading:y("gitView.branch.localBranches"),children:h.map(Q=>t.jsx(Zt,{onSelect:()=>we(Q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Q})},`local-${Q}`))}),h.length>0&&P.length>0?t.jsx(pa,{}):null,P.length>0&&t.jsx(Xt,{heading:y("gitView.branch.remoteBranches"),children:P.map(Q=>t.jsx(Zt,{onSelect:()=>we(Q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Q})},`remote-${Q}`))})]})]})})]})]}),F?t.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:R==="merge"?t.jsxs(t.Fragment,{children:[y("gitView.branch.summaryMergePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:F})," ",y("gitView.branch.summaryMergeInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:H})]}):t.jsxs(t.Fragment,{children:[y("gitView.branch.summaryRebasePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:H})," ",y("gitView.branch.summaryRebaseInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:F})]})})}):null,C==="dialog"?t.jsxs(Es,{className:"gap-2 pt-1",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:ye,children:y("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:de,disabled:!F,className:"gap-1.5",children:R==="merge"?t.jsxs(t.Fragment,{children:[t.jsx(T,{name:"git-merge",className:"size-4"}),y("gitView.operation.merge")]}):t.jsxs(t.Fragment,{children:[t.jsx(T,{name:"git-branch",className:"size-4"}),y("gitView.operation.rebase")]})})]}):t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{variant:"destructive",size:"sm",onClick:ye,disabled:G,children:y("gitView.common.reset")}),t.jsx("div",{className:"flex-1"}),t.jsx(W,{variant:"default",size:"sm",onClick:de,disabled:G||!F,children:y(R==="merge"?"gitView.operation.merge":"gitView.operation.rebase")})]})]});if(C==="bare")return je;if(C==="inline"){let Q;e[38]!==y?(Q=y("gitView.branch.updateTitle"),e[38]=y,e[39]=Q):Q=e[39];let fe;e[40]!==Q?(fe=t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:Q}),e[40]=Q,e[41]=fe):fe=e[41];let Oe;e[42]!==y?(Oe=y("gitView.branch.updateDescriptionPrefix"),e[42]=y,e[43]=Oe):Oe=e[43];let et;e[44]!==H?(et=t.jsx("span",{className:"font-mono text-foreground",children:H}),e[44]=H,e[45]=et):et=e[45];let $e;e[46]!==Oe||e[47]!==et?($e=t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[Oe," ",et,"."]}),e[46]=Oe,e[47]=et,e[48]=$e):$e=e[48];let Je;e[49]!==fe||e[50]!==$e?(Je=t.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:t.jsxs("div",{className:"space-y-1",children:[fe,$e]})}),e[49]=fe,e[50]=$e,e[51]=Je):Je=e[51];let We;e[52]!==je?(We=t.jsx("div",{className:"pt-3",children:je}),e[52]=je,e[53]=We):We=e[53];let pt;return e[54]!==Je||e[55]!==We?(pt=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[Je,We]}),e[54]=Je,e[55]=We,e[56]=pt):pt=e[56],pt}let be;e[57]!==S?(be=S?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"git-merge",className:"size-4"}),e[57]=S,e[58]=be):be=e[58];let Ce;e[59]!==y?(Ce=y("gitView.branch.mergeRebase"),e[59]=y,e[60]=Ce):Ce=e[60];let Ee;e[61]!==Ce?(Ee=t.jsx("span",{children:Ce}),e[61]=Ce,e[62]=Ee):Ee=e[62];let ee;e[63]!==re||e[64]!==G||e[65]!==be||e[66]!==Ee?(ee=t.jsx(ts,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5",onClick:re,disabled:G,children:[be,Ee]})}),e[63]=re,e[64]=G,e[65]=be,e[66]=Ee,e[67]=ee):ee=e[67];let he;e[68]!==y?(he=y("gitView.branch.mergeRebaseTooltip"),e[68]=y,e[69]=he):he=e[69];let Be;e[70]!==he?(Be=t.jsx(ss,{sideOffset:8,children:he}),e[70]=he,e[71]=Be):Be=e[71];let ge;e[72]!==ee||e[73]!==Be?(ge=t.jsxs(es,{children:[ee,Be]}),e[72]=ee,e[73]=Be,e[74]=ge):ge=e[74];let Ne;e[75]!==me||e[76]!==k?(Ne=Q=>{Q?k(!0):me()},e[75]=me,e[76]=k,e[77]=Ne):Ne=e[77];let Pe;e[78]!==y?(Pe=y("gitView.branch.updateTitle"),e[78]=y,e[79]=Pe):Pe=e[79];let Te;e[80]!==Pe?(Te=t.jsx(ft,{children:Pe}),e[80]=Pe,e[81]=Te):Te=e[81];let oe;e[82]!==$||e[83]!==S||e[84]!==R||e[85]!==X||e[86]!==y||e[87]!==H?(oe=S?y(X?$?"gitView.branch.operationFailed":"gitView.branch.operationCompleted":R==="merge"?"gitView.branch.mergingInProgress":"gitView.branch.rebasingInProgress"):t.jsxs(t.Fragment,{children:[y("gitView.branch.dialogDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:H}),"."]}),e[82]=$,e[83]=S,e[84]=R,e[85]=X,e[86]=y,e[87]=H,e[88]=oe):oe=e[88];let Ie;e[89]!==oe?(Ie=t.jsx(bt,{children:oe}),e[89]=oe,e[90]=Ie):Ie=e[90];let Fe;e[91]!==Te||e[92]!==Ie?(Fe=t.jsxs(gt,{children:[Te,Ie]}),e[91]=Te,e[92]=Ie,e[93]=Fe):Fe=e[93];let De;e[94]!==je||e[95]!==Fe?(De=t.jsxs(ht,{className:"max-w-md",children:[Fe,je]}),e[94]=je,e[95]=Fe,e[96]=De):De=e[96];let Ue;e[97]!==D||e[98]!==Ne||e[99]!==De?(Ue=t.jsx(mt,{open:D,onOpenChange:Ne,children:De}),e[97]=D,e[98]=Ne,e[99]=De,e[100]=Ue):Ue=e[100];let Le;return e[101]!==ge||e[102]!==Ue?(Le=t.jsxs(t.Fragment,{children:[ge,Ue]}),e[101]=ge,e[102]=Ue,e[103]=Le):Le=e[103],Le};function Fi(o){return o.status==="done"||o.status==="error"}function Ri(o){return o.status==="error"}function Bi(o){return o.slice(o.indexOf("/")+1)}function Di(o){return[o]}function Mi(o){return[o]}function Ei(o,e){return t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("div",{className:"mt-0.5 shrink-0",children:[o.status==="running"&&t.jsx(T,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),o.status==="done"&&t.jsx(T,{name:"check",className:"size-3.5 text-success"}),o.status==="error"&&t.jsx(T,{name:"close",className:"size-3.5 text-destructive"}),o.status==="pending"&&t.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),t.jsx("span",{className:Se("typography-micro",o.status==="error"&&"text-destructive",o.status==="done"&&"text-muted-foreground",o.status==="running"&&"text-foreground",o.status==="pending"&&"text-muted-foreground/60"),children:o.message})]},e)}function Ti(o){return o.stopPropagation()}const Li=({runMutation:o,onMutationComplete:e,onMutationError:a,onPathsComplete:m,scheduleFlush:N})=>{const f=[];let p=!1;return{enqueue:g=>{const w=f[f.length-1];if(w?.directory===g.directory&&w.direction===g.direction){g.paths.forEach(M=>w.paths.add(M));return}f.push(g)},flush:()=>{if(p)return;const g=f.shift();if(!g)return;p=!0;const w={directory:g.directory,direction:g.direction,paths:Array.from(g.paths),rollback:g.rollback};(async()=>{try{await o(w),e(w)}catch(M){a(w,M)}finally{m(w.paths),p=!1,f.length>0&&N()}})()},clear:()=>{f.length=0},size:()=>f.length,isRunning:()=>p}},Oi=15e3,Ai=40,zi=20,Vr={feat:":sparkles:",feature:":sparkles:",fix:":bug:",bug:":bug:",hotfix:":ambulance:",docs:":memo:",documentation:":memo:",style:":lipstick:",refactor:":recycle:",perf:":zap:",performance:":zap:",test:":white_check_mark:",tests:":white_check_mark:",build:":construction_worker:",ci:":green_heart:",chore:":wrench:",revert:":rewind:",wip:":construction:",security:":lock:",release:":bookmark:",merge:":twisted_rightwards_arrows:",mv:":truck:",move:":truck:",rename:":truck:",remove:":fire:",delete:":fire:",add:":sparkles:",create:":sparkles:",implement:":sparkles:",update:":recycle:",improve:":zap:",optimize:":zap:",upgrade:":arrow_up:",downgrade:":arrow_down:",deploy:":rocket:",init:":tada:",initial:":tada:"},Pr=(o,e)=>{const a=o.toLowerCase(),m=/^([a-z]+)(?:\(.*\))?!?:/,N=a.match(m);if(N){const x=N[1],g=Vr[x];if(g)return e.find(w=>w.code===g)||null}const f=a.split(" ")[0],p=Vr[f];return p&&e.find(x=>x.code===p)||null},Gi=20,yt=new Map,_i=(o,e)=>{if(yt.delete(o),yt.set(o,e),yt.size>Gi){const a=yt.keys().next().value;a!==void 0&&yt.delete(a)}},Ze=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),Ir=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},Hi=o=>{const e=o.working_dir?.trim(),a=o.index?.trim();return!!(e||a==="?")},ic=({isActive:o})=>{const{t:e}=nt(),{git:a}=xa(),m=wa(),[N,f]=l.useState(null),[p,x]=l.useState(null),g=rt(s=>s.currentSessionId),w=rt(s=>s.newSessionDraft),M=rt(s=>s.setDraftBootstrapPendingDirectory),v=rt(s=>s.worktreeMetadata),V=rt(s=>s.availableWorktrees),L=Ze(m),S=l.useMemo(()=>{if(!L)return;const s=V.find(n=>Ze(n.path)===L);if(s)return s;for(const n of v.values())if(Ze(n.path)===L)return n},[V,L,v]),z=l.useMemo(()=>{if(g)return v.get(g)??S;if(w?.open)return S},[g,S,w?.open,v]),{profiles:C,globalIdentity:y,defaultGitIdentityId:D,loadProfiles:k,loadGlobalIdentity:R,loadDefaultGitIdentityId:I}=Ga(pr(s=>({profiles:s.profiles,globalIdentity:s.globalIdentity,defaultGitIdentityId:s.defaultGitIdentityId,loadProfiles:s.loadProfiles,loadGlobalIdentity:s.loadGlobalIdentity,loadDefaultGitIdentityId:s.loadDefaultGitIdentityId}))),{rootIsGitRepo:F,gitDirectory:r,nestedRepos:Y}=ya(m??null,{enabled:o}),B=ba(r??null),u=va(r??null),E=ja(s=>g?s.getAttachment(g):void 0),se=E?Ca(E):[],U=E&&!E.degraded&&!E.legacy?E.worktreeRoot??void 0:void 0,G=Aa(m,z,u?.current??void 0),H=Na(r??null),X=Sa(r??null),$=ka(r??null),le=Va(r??null),ae=Pa(r??null),{setActiveDirectory:ce,ensureAll:ie,fetchStatus:h,fetchBranches:d,fetchLog:P,setLogMaxCount:O,fetchIdentity:K,prefetchDiffs:ne,clearDiffCache:re,moveStatusPathsOptimistically:q,restoreStatus:we,bumpIndexRevision:J,ensureNestedRepos:de,selectNestedRepo:ke}=Ia(pr(s=>({setActiveDirectory:s.setActiveDirectory,ensureAll:s.ensureAll,fetchStatus:s.fetchStatus,fetchBranches:s.fetchBranches,fetchLog:s.fetchLog,setLogMaxCount:s.setLogMaxCount,fetchIdentity:s.fetchIdentity,prefetchDiffs:s.prefetchDiffs,clearDiffCache:s.clearDiffCache,moveStatusPathsOptimistically:s.moveStatusPathsOptimistically,restoreStatus:s.restoreStatus,bumpIndexRevision:s.bumpIndexRevision,ensureNestedRepos:s.ensureNestedRepos,selectNestedRepo:s.selectNestedRepo}))),ye=Rt(s=>s.isMobile),me=Rt(s=>s.openContextDiff),xe=Rt(s=>s.openContextSurface),Ve=u?.current??null,Re=Fa(s=>!r||!Ve?null:Ra(s.entries,r,Ve)),ue=Rt(s=>s.navigateToDiff),He=l.useRef(null),Ae=l.useRef(null),je=l.useRef(null),be=l.useRef(!0);l.useEffect(()=>()=>{be.current=!1},[]);const Ce=l.useCallback(()=>{He.current!==null&&(window.clearTimeout(He.current),He.current=null)},[]),Ee=l.useCallback(s=>{Ce(),He.current=window.setTimeout(()=>{He.current=null,Ze(s)===Ze(r)&&h(s,a,{silent:!0})},Oi)},[Ce,r,h,a]);l.useEffect(()=>Ce,[Ce]);const ee=l.useCallback(()=>{Ae.current!==null&&(window.clearTimeout(Ae.current),Ae.current=null)},[]),he=l.useCallback(()=>{Ae.current===null&&(Ae.current=window.setTimeout(()=>{Ae.current=null,je.current?.()},0))},[]),Be=l.useCallback(async(s,n,i)=>{if(n==="stage"){if(a.stageGitFiles){await a.stageGitFiles(s,i);return}await Promise.all(i.map(c=>a.stageGitFile(s,c)));return}if(a.unstageGitFiles){await a.unstageGitFiles(s,i);return}await Promise.all(i.map(c=>a.unstageGitFile(s,c)))},[a]),ge=l.useMemo(()=>Li({runMutation:({directory:s,direction:n,paths:i})=>Be(s,n,i),onMutationComplete:({directory:s})=>{J(s),Ee(s)},onMutationError:({directory:s,direction:n,rollback:i},c)=>{i?.(),J(s),Ee(s);const j=e(n==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed");b.error(c instanceof Error?c.message:j)},onPathsComplete:s=>{Ks(n=>{const i=new Set(n);return s.forEach(c=>i.delete(c)),i})},scheduleFlush:he}),[J,Be,he,Ee,e]);l.useEffect(()=>(je.current=ge.flush,()=>{je.current=null}),[ge]),l.useEffect(()=>()=>ge.clear(),[ge]),l.useEffect(()=>ee,[ee]),l.useEffect(()=>{if(!o)return;if(!m){f(null);return}const s=Ze(m)??m;f({directory:s,status:null});let n=!1,i=null;const c=async()=>{try{const j=await Oa(m);if(n)return;f({directory:s,status:j.status}),j.status==="pending"&&(i=window.setTimeout(()=>{c()},500))}catch{n||f({directory:s,status:null})}};return c(),()=>{n=!0,i!==null&&window.clearTimeout(i)}},[o,m]);const Ne=Ze(w?.bootstrapPendingDirectory??null),Pe=!!(m&&Ne&&Ne===Ze(m)),Te=Ba(m??null),oe=Ze(m),Ie=N?.directory===oe?N.status:null,Fe=!!(m&&(Te||Ie==="pending"||Pe&&w?.pendingWorktreeRequestId)),De=!!(oe&&p?.directory===oe);l.useEffect(()=>{if(!oe)return;if(Ie==="failed"){M(null),x(n=>n?.directory===oe?null:n);return}if(Fe){x(n=>n?.directory===oe&&n.status==="refreshing"?n:{directory:oe,status:"refreshing"});return}if(p?.directory!==oe||p.status!=="refreshing"||!r||!a)return;let s=!1;return h(r,a,{force:!0,silent:!0,throwOnError:!0}).then(()=>{s||x(n=>n?.directory===oe?null:n)}).catch(()=>{s||x(n=>n?.directory===oe?{...n,status:"failed"}:n)}),()=>{s=!0}},[h,a,r,Fe,oe,Ie,p,M]);const Ue=Fe||De,Le=De&&p?.status==="failed",Q=l.useMemo(()=>r?yt.get(r)??null:null,[r]),fe=Da(s=>s.settingsGitmojiEnabled),[Oe,et]=l.useState(null),{gitmojis:$e}=Za(fe);l.useEffect(()=>{const s=U||G?.projectDirectory;if(!s){et(null);return}let n=!1;return Ma(s).then(i=>{if(n)return;const c=i.trim();et(c&&c!=="HEAD"?c:null)}).catch(()=>{n||et(null)}),()=>{n=!0}},[U,G?.projectDirectory]);const[Je,We]=l.useState(Q?.commitMessage??""),[pt,Er]=l.useState([]),[Tr,rs]=l.useState(!1),Hs=l.useRef(null),[$s,Mt]=l.useState(null),[Lr,ns]=l.useState(!1),[Ws,Us]=l.useState(null),[Ye,Or]=l.useState(25),[Ar,Js]=l.useState(!1),{triggerFireworks:zr}=za(),qs=l.useRef(new Map),Et=l.useRef(0),as=l.useCallback(()=>{Et.current+=1,be.current&&Js(!0)},[]),is=l.useCallback(()=>{Et.current=Math.max(0,Et.current-1),be.current&&Et.current===0&&Js(!1)},[]),[os,Tt]=l.useState(new Set),[Gr,Ks]=l.useState(new Set),[ls,Ys]=l.useState(!1),[_r,Hr]=l.useState(0),[$r,Qs]=l.useState(!1),[cs,ds]=l.useState(Q?.generatedHighlights??[]),Wr=Gr.size>0||ge.size()>0||ge.isRunning(),Xs=l.useCallback(()=>{const s=Hs.current;s&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.scrollTo({top:s.scrollHeight,behavior:"smooth"})})})},[]),us=U||G?.projectDirectory||null,ms=u?.current||null,Ur=l.useMemo(()=>{const s=u?.tracking;return s?s.startsWith("origin/"):!0},[u?.tracking]),Zs=l.useMemo(()=>{const s=G?.createdFromBranch,n=typeof s=="string"?s.trim():"",i=typeof u?.current=="string"?u.current.trim():"",c=typeof Oe=="string"?Oe.trim():"";return n?n===i&&n.startsWith("opencode/")&&c.length>0&&c!==n?c:n:c||i||"HEAD"},[G?.createdFromBranch,u,Oe]),Lt=l.useCallback(()=>{ds([])},[]),[hs,Jr]=l.useState(new Set),[Ot,qr]=l.useState(new Map),[At,gs]=l.useState(new Set),fs=l.useRef(Ot),St=l.useRef(At),[Kr,vt]=l.useState(null),[xt,ps]=l.useState(null),[er,tr]=l.useState(""),[Me,zt]=l.useState(null),[Yr,sr]=l.useState(!1),[Qr,rr]=l.useState(!1),[xs,ws]=l.useState([]),[Xr,nr]=l.useState(null),[ar,ys]=l.useState(null),[Zr,Gt]=l.useState([]),[en,Qe]=l.useState(!1),[tn,tt]=l.useState([]),[_t,st]=l.useState("merge"),[sn,bs]=l.useState(null),[vs,ir]=l.useState(!1),[js,rn]=l.useState(100),[nn,an]=l.useState(0),Xe=l.useMemo(()=>g?`openchamber.conflict:${g}`:null,[g]),at=l.useCallback((s,n,i)=>{if(!Xe||typeof window>"u")return;const c={directory:s,conflictFiles:n,operation:i};window.localStorage.setItem(Xe,JSON.stringify(c))},[Xe]),qe=l.useCallback(()=>{!Xe||typeof window>"u"||window.localStorage.removeItem(Xe)},[Xe]);l.useEffect(()=>{if(!Xe||typeof window>"u"||!r)return;const s=window.localStorage.getItem(Xe);if(s)try{const n=JSON.parse(s);if(n.directory!==r){window.localStorage.removeItem(Xe);return}tt(n.conflictFiles??[]),st(n.operation??"merge"),Qe(!0)}catch{window.localStorage.removeItem(Xe)}},[Xe,r]);const[on,Cs]=l.useState(!1),[Ht,kt]=l.useState(null),[Ns,or]=l.useState("merge"),[Ss,lr]=l.useState(""),ln=l.useCallback(s=>{Ea(s).then(n=>{if(n.ok){b.success(e("gitView.toast.commitHashCopied"));return}b.error(e("gitView.toast.copyFailed"))})},[e]),cn=l.useCallback(s=>{Jr(n=>{const i=new Set(n);return i.has(s)?i.delete(s):i.add(s),i})},[]);l.useEffect(()=>{fs.current=Ot},[Ot]),l.useEffect(()=>{St.current=At},[At]),l.useEffect(()=>{if(!r||!a)return;const s=Array.from(hs).filter(i=>!fs.current.has(i)&&!St.current.has(i));if(s.length===0)return;let n=!1;return gs(i=>{const c=new Set(i);for(const j of s)c.add(j);return St.current=c,c}),Promise.all(s.map(i=>a.getCommitFiles(r,i).then(c=>({hash:i,files:c.files})).catch(c=>(console.error("Failed to fetch commit files:",c),{hash:i,files:[]})))).then(i=>{n||(qr(c=>{const j=new Map(c);for(const{hash:A,files:Z}of i)j.set(A,Z);return fs.current=j,j}),gs(c=>{const j=new Set(c);for(const{hash:A}of i)j.delete(A);return St.current=j,j}))}),()=>{n=!0,gs(i=>{let c=!1;const j=new Set(i);for(const A of s)j.delete(A)&&(c=!0);return c?(St.current=j,j):i})}},[hs,r,a]),l.useEffect(()=>{if(!r)return;const s=yt.get(r)??null;We(s?.commitMessage??""),ds(s?.generatedHighlights??[])},[r]),l.useEffect(()=>{r&&_i(r,{directory:r,commitMessage:Je,generatedHighlights:cs})},[Je,r,cs]),l.useEffect(()=>{o&&(k(),R(),I())},[o,k,R,I]),l.useEffect(()=>{if(!o)return;if(!r||!a?.getRemoteUrl||B!==!0){ps(null);return}let s=!1;return a.getRemoteUrl(r).then(n=>{s||ps(n)}).catch(()=>{s||ps(null)}),()=>{s=!0}},[o,r,a,B]);const $t=l.useCallback(async()=>{if(!r||!a?.getRemotes||B!==!0){ws([]);return}try{const s=await a.getRemotes(r);be.current&&ws(s)}catch{be.current&&ws([])}},[r,a,B]);l.useEffect(()=>{o&&$t()},[o,$t]),l.useEffect(()=>{o&&m&&r&&(ce(m),ie(r,a))},[o,m,r,ce,ie,a]),l.useEffect(()=>{if(o&&r)return Ta.onGitRefreshHint(s=>{Ze(s.directory)===Ze(r)&&(s.paths?.length&&re(r,s.paths),h(r,a,{silent:!0}))})},[o,re,r,h,a]);const te=l.useCallback(async(s=!0)=>{if(r)try{await Promise.all([h(r,a),d(r,a)])}catch(n){if(s){const i=n instanceof Error?n.message:e("gitView.toast.refreshRepositoryFailed");b.error(i)}}},[r,a,h,d,e]),pe=l.useCallback(async()=>{r&&await P(r,a,Ye)},[r,a,P,Ye]),ks=l.useCallback(async()=>{r&&await K(r,a)},[r,a,K]);l.useEffect(()=>{if(!o||!r||!a?.hasLocalIdentity||B!==!0)return;const s=typeof D=="string"?D.trim():"";if(!s||s==="global"||qs.current.get(r)===s)return;let i=!1;return(async()=>{try{const j=await a.hasLocalIdentity?.(r);if(i||j===!0)return;as(),await a.setGitIdentity(r,s),qs.current.set(r,s),await ks()}catch(j){console.warn("Failed to auto-apply default git identity:",j)}finally{i||is()}})(),()=>{i=!0}},[o,as,r,D,is,a,B,ks]);const it=l.useMemo(()=>u?[...u.files??[]].sort((n,i)=>n.path.localeCompare(i.path)):[],[u]),Ke=l.useMemo(()=>it.filter(Ir),[it]),Vs=l.useMemo(()=>it.filter(Hi),[it]);l.useEffect(()=>{if(!o||!r||it.length===0)return;const s=[],n=new Set,i=j=>{!j||n.has(j)||(n.add(j),s.push(j))};if(Ke.forEach(j=>i(j.path)),pt.forEach(i),it.slice(0,zi).forEach(j=>i(j.path)),s.length===0)return;const c=window.setTimeout(()=>{ne(r,a,s,{maxFiles:Ai})},120);return()=>{window.clearTimeout(c)}},[o,it,r,a,ne,Ke,pt]);const cr=s=>s?.pushed[0]?.remote||u?.tracking?.split("/")[0]||ze.find(n=>n.name==="origin")?.name||ze[0]?.name||"origin",dr=async(s,n)=>{if(r){Mt(s);try{const i=c=>{const j=`${c.name}/`,A=u?.tracking?.startsWith(j)?u.tracking.slice(j.length):void 0;return{remote:c.name,branch:A,rebase:!0}};if(s==="fetch"){if(!n)throw new Error("No remote available for fetch");await a.gitFetch(r,{remote:n.name}),b.success(e("gitView.toast.fetchedFromRemote",{name:n.name}))}else if(s==="pull"){if(!n)throw new Error("No remote available for pull");const c=await a.gitPull(r,i(n));b.success(c.files.length===1?e("gitView.toast.pulledFilesSingle",{count:c.files.length,name:n.name}):e("gitView.toast.pulledFilesPlural",{count:c.files.length,name:n.name}))}else if(s==="push"){const c=await a.gitPush(r);b.success(e("gitView.toast.pushedToUpstream",{name:cr(c)}))}else if(s==="sync"){if(!n)throw new Error("No remote available for sync");let c=0,j=!1;await a.gitFetch(r,{remote:n.name});const A=await a.getGitStatus(r);if((A.behind??0)>0){if((A.files?.length??0)>0){b.error(e("gitView.toast.commitOrStashBeforeSync"));return}c=(await a.gitPull(r,i(n))).files.length}((await a.getGitStatus(r)).ahead??0)>0&&(await a.gitPush(r),j=!0),c>0&&j?b.success(c===1?e("gitView.toast.syncedPulledSingleAndPushed",{count:c,name:n.name}):e("gitView.toast.syncedPulledPluralAndPushed",{count:c,name:n.name})):c>0?b.success(c===1?e("gitView.toast.pulledFilesSingle",{count:c,name:n.name}):e("gitView.toast.pulledFilesPlural",{count:c,name:n.name})):j?b.success(e("gitView.toast.pushedToUpstream",{name:n.name})):b.success(e("gitView.toast.alreadyUpToDate"))}await te(!1),await pe()}catch(i){const c=i instanceof Error?i.message:e("gitView.toast.syncActionFailed",{action:s==="sync"?e("gitView.sync.syncChanges"):s==="pull"?e("gitView.sync.pull"):s});b.error(c)}finally{Mt(null)}}},dn=l.useCallback(async s=>{if(!r)return;const n=s.name.trim();if(!n){b.error(e("gitView.toast.remoteNameRequired"));return}if(n==="origin"){b.error(e("gitView.toast.cannotRemoveOriginRemote"));return}nr(n);try{await a.removeRemote(r,{remote:n}),b.success(e("gitView.toast.removedRemote",{name:n})),await Promise.all([te(!1),$t()])}catch(i){const c=i instanceof Error?i.message:`Failed to remove ${n}`;b.error(c)}finally{nr(null)}},[r,a,$t,te,e]),ur=async(s={})=>{if(!r)return;if(!Je.trim()){b.error(e("gitView.toast.enterCommitMessage"));return}const n=Ke.map(c=>c.path).sort();if(n.length===0){b.error(e("gitView.toast.stageFileToCommit"));return}const i=s.pushAfter?"commitAndPush":"commit";Us(i);try{if(await a.createGitCommit(r,Je.trim(),{files:n,stageFiles:[]}),J(r),b.success(e("gitView.toast.commitCreated")),We(""),Lt(),await te(),s.pushAfter){const c=u?.tracking?.split("/")[0],j=ze.find(Gn=>Gn.name===c)??ze[0];if(!j)throw new Error(e("mobile.changes.noRemote"));Mt("sync");const A=`${j.name}/`,Z=u?.tracking?.startsWith(A)?u.tracking.slice(A.length):void 0;await a.gitFetch(r,{remote:j.name});const _=await a.getGitStatus(r);if((_.behind??0)>0){if((_.files?.length??0)>0){b.error(e("gitView.toast.commitOrStashBeforeSync")),await te(!1);return}await a.gitPull(r,{remote:j.name,branch:Z,rebase:!0})}const _e=await a.getGitStatus(r);let jt;(_e.ahead??0)>0&&(jt=await a.gitPush(r)),b.success(e("gitView.toast.pushedToUpstream",{name:cr(jt)})),zr(),await te(!1)}else await te(!1);await pe(),Hr(c=>c+1)}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.createCommitFailed");b.error(j)}finally{Us(null),s.pushAfter&&Mt(null)}},un=l.useCallback(async()=>{if(!r)return;const s=Ke.map(n=>n.path).sort();if(s.length===0){b.error(e("gitView.toast.stageFileToDescribe"));return}console.error("[git-generation][browser] generate button clicked",{directory:r,selectedFiles:s.length}),Qs(!0);try{const{message:n}=await fr(r,s),i=n.subject?.trim()??"",c=Array.isArray(n.highlights)?n.highlights:[];if(i){let j=i;if(fe&&$e.length>0){const A=Pr(i,$e);if(A){const{code:Z,emoji:_}=A;!i.startsWith(Z)&&!i.startsWith(_)&&(j=`${Z} ${i}`)}}We(j)}ds(c),Xs()}catch(n){console.error("[git-generation][browser] GitView generate handler failed",{message:n instanceof Error?n.message:String(n),error:n});const i=n instanceof Error?n.message:e("gitView.toast.generateCommitMessageFailed");b.error(i)}finally{Qs(!1)}},[r,Ke,fe,$e,Xs,e]),Ps=s=>s.reason==="attention"?`${s.attentionReason} in progress`:s.reason==="missing"?"worktree is missing":"worktree is invalid",mn=async(s,n)=>{if(!r||!u)return;const i=Bs(E);if(i.length>0){b.error(e("gitView.toast.cannotCreateBranch",{reason:Ps(i[0])}));return}const c=u.current??null,j=n?.name??"origin";try{await a.createBranch(r,s,c??"HEAD"),b.success(e("gitView.toast.createdBranch",{name:s})),await a.checkoutBranch(r,s);let A=!1;try{await a.gitPush(r,{remote:j,branch:s,options:["--set-upstream"]}),A=!0}catch(Z){const _=Z instanceof Error?Z.message:`Unable to push new branch to ${j}.`;b.warning(e("gitView.toast.branchCreatedLocally"),{description:t.jsxs("span",{className:"text-foreground/80 dark:text-foreground/70",children:["Upstream setup failed: ",_]})})}await te(),await pe(),A&&b.success(e("gitView.toast.upstreamSet",{branch:s,remote:j}))}catch(A){const Z=A instanceof Error?A.message:e("gitView.toast.createBranchFailed");throw b.error(Z),A}},hn=async(s,n)=>{if(!r)return;const i=Bs(E);if(i.length>0){b.error(e("gitView.toast.cannotRenameBranch",{reason:Ps(i[0])}));return}try{await a.renameBranch(r,s,n),b.success(e("gitView.toast.renamedBranch",{oldName:s,newName:n})),await te(),await pe()}catch(c){const j=c instanceof Error?c.message:e("gitView.toast.renameBranchFailed",{oldName:s,newName:n});b.error(j)}},gn=async s=>{if(!r)return;const n=Bs(E);if(n.length>0){b.error(e("gitView.toast.cannotCheckout",{reason:Ps(n[0])}));return}const i=s.replace(/^remotes\//,"");if(u?.current!==i){if((u?.files?.length??0)>0){kt(i);return}await Is(i)}},Is=async s=>{if(!r)return;const n=s;try{const i=await a.checkoutBranch(r,n);b.success(e("gitView.toast.checkedOut",{name:i?.branch||n})),await te(),await pe()}catch(i){const c=i instanceof Error?i.message:e("gitView.toast.checkoutFailed",{name:n});b.error(c)}},fn=async s=>{if(r){as();try{await a.setGitIdentity(r,s.id),b.success(e("gitView.toast.appliedIdentity",{name:s.name})),await ks()}catch(n){const i=n instanceof Error?n.message:e("gitView.toast.applyIdentityFailed");b.error(i)}finally{is()}}},Vt=l.useMemo(()=>H?.all?H.all.filter(s=>!s.startsWith("remotes/")).sort():[],[H]),ot=l.useMemo(()=>H?.all?H.all.filter(s=>s.startsWith("remotes/")).map(s=>s.replace(/^remotes\//,"")).sort():[],[H]),ze=l.useMemo(()=>{if(xs.length>0)return xs;const s=new Set,n=u?.tracking?.trim();n&&n.includes("/")&&s.add(n.split("/")[0]);for(const i of ot){const c=i.indexOf("/");c>0&&s.add(i.slice(0,c))}return s.size===0&&xt&&s.add("origin"),Array.from(s).map(i=>({name:i,fetchUrl:xt??"",pushUrl:xt??""}))},[xs,ot,xt,u?.tracking]),lt=u?.current??null,mr=l.useMemo(()=>{const s=u?.tracking?.trim().split("/")[0];return(s&&H?.defaultBranches?.[s])??H?.defaultBranches?.origin},[H,u?.tracking]),wt=l.useMemo(()=>_a({remoteNames:new Set(ze.map(s=>s.name)),localBranches:Vt,worktreeCreatedFromBranch:G?.createdFromBranch,rootBranchHint:Oe,defaultBranch:mr,headBranch:lt}),[lt,mr,ze,Vt,Oe,G?.createdFromBranch]),pn=l.useMemo(()=>ze.map(i=>i.name).map(i=>`${i}/${wt}`).find(i=>ot.includes(i))??wt,[wt,ze,ot]),xn=l.useMemo(()=>{const s=new Map;y&&s.set(y.id,y);let n=null;if(xt)try{let i=xt.trim();i.startsWith("git@")&&(i=`https://${i.slice(4).replace(":","/")}`),i.endsWith(".git")&&(i=i.slice(0,-4));const c=new URL(i);n=c.hostname+c.pathname}catch{}for(const i of C){if(i.authType!=="token"){s.set(i.id,i);continue}const c=i.host;if(!c){s.set(i.id,i);continue}if(!c.includes("/")){s.set(i.id,i);continue}n&&n===c&&s.set(i.id,i)}return Array.from(s.values())},[C,y,xt]),wn=l.useMemo(()=>{if($?.userName&&$?.userEmail){const s=C.find(n=>n.userName===$.userName&&n.userEmail===$.userEmail);return s||(y&&y.userName===$.userName&&y.userEmail===$.userEmail?y:{id:"local-config",name:$.userName,userName:$.userName,userEmail:$.userEmail,sshKey:$.sshCommand?.replace("ssh -i ","")??null,color:"info",icon:"user"})}return y??null},[$,C,y]),yn=Ke.length,bn=le||$s!==null||Ws!==null,vn=!!(G&&us&&ms&&Ur),hr=!!lt,ct=vn&&us&&ms&&G?{repoRoot:us,sourceBranch:ms,worktreeMetadata:G}:null;l.useEffect(()=>{if(!r||!a||!X?.all?.length||!lt||!wt||lt===wt){vt(null);return}let s=!1;return(async()=>{try{const i=await a.getGitLog(r,{from:wt,to:"HEAD",maxCount:Ye});if(s)return;const c=new Set((i?.all??[]).map(A=>A.hash).filter(A=>typeof A=="string"&&A.length>0));if(c.size===0){vt(null);return}const j=X.all.findIndex(A=>!c.has(A.hash));if(j===0){vt(null);return}if(j===-1){vt({insertBeforeIndex:X.all.length,branchName:lt,direction:"up"});return}vt({insertBeforeIndex:j,branchName:lt,direction:"up"})}catch{s||vt(null)}})(),()=>{s=!0}},[wt,lt,r,a,X,Ye]),l.useEffect(()=>{bs(null)},[r]),l.useEffect(()=>{if(Me!=="graph"||!r){Me!=="graph"&&bs(null);return}let s=!1;return ir(!0),a.getGitLog(r,{maxCount:js,all:!0}).then(n=>{s||bs(n)}).catch(n=>{console.error("Failed to fetch graph log:",n)}).finally(()=>{s||ir(!1)}),()=>{s=!0}},[Me,r,js,nn,a]);const Pt=l.useCallback((s,n)=>{if(!r||s.length===0)return;const i=Array.from(new Set(s));Ks(j=>{const A=new Set(j);return i.forEach(Z=>A.add(Z)),A});const c=q(r,i,n);ge.enqueue({directory:r,direction:n,paths:new Set(i),rollback:()=>we(r,c)}),he()},[r,ge,q,we,he]),Fs=l.useCallback(async s=>{if(r){Tt(n=>{const i=new Set(n);return i.add(s),i});try{await a.revertGitFile(r,s,{scope:"working"}),b.success(e("gitView.toast.revertedFile",{path:s})),await te(!1)}catch(n){const i=n instanceof Error?n.message:e("gitView.toast.revertFailed");b.error(i)}finally{Tt(n=>{const i=new Set(n);return i.delete(s),i})}}},[r,te,a,e]),It=l.useCallback(async(s,n,i="all")=>{if(!r||s.length===0)return;const c=Array.from(new Set(s));if(ls||c.some(_=>os.has(_)))return;const j=new Set(Ke.map(_=>_.path)),A=i==="all"&&c.some(_=>j.has(_));n&&Ys(!0),Tt(_=>{const _e=new Set(_);return c.forEach(jt=>_e.add(jt)),_e});const Z=[];try{if(await Promise.all(c.map(async _=>{try{await a.revertGitFile(r,_,{scope:i})}catch(_e){Z.push({path:_,message:_e instanceof Error?_e.message:e("gitView.toast.revertFailed")})}})),A&&Z.length<c.length&&J(r),await te(!1),Z.length===0)b.success(c.length===1?e("gitView.toast.revertedFilesSingle",{count:c.length}):e("gitView.toast.revertedFilesPlural",{count:c.length}));else if(Z.length===c.length)b.error(Z[0]?.message||e("gitView.toast.revertFailed"));else{const _=c.length-Z.length;b.warning(_===1?e("gitView.toast.revertedSomeSingle",{success:_,failed:Z.length}):e("gitView.toast.revertedSomePlural",{success:_,failed:Z.length}))}}finally{Tt(_=>{const _e=new Set(_);return c.forEach(jt=>_e.delete(jt)),_e}),n&&Ys(!1)}},[J,r,a,ls,te,os,Ke,e]),jn=l.useCallback(async s=>{await It(s,!0)},[It]),Cn=l.useCallback(async s=>{await It(s,!1,"working")},[It]),Rs=l.useCallback((s,n)=>{if(m&&!ye){me(m,s,n);return}ue(s,n)},[m,ye,ue,me]),Nn=l.useCallback(()=>ns(!0),[]),Sn=l.useMemo(()=>{const s=[];return Ke.length>0&&s.push({id:"staged",title:e("gitView.changes.stagedTitle"),entries:Ke,actionSymbol:"-",actionAllLabel:e("gitView.changes.unstageAllAria"),getActionLabel:n=>e("gitView.changes.unstageFileAria",{path:n}),onActionFile:n=>{Pt([n],"unstage")},onActionAll:n=>{Pt(n,"unstage")},onViewDiff:n=>Rs(n,!0),onRevertFile:Fs,showRevertActions:!1,accent:!0}),Vs.length>0&&s.push({id:"unstaged",title:e("gitView.changes.title"),entries:Vs,actionSymbol:"+",actionAllLabel:e("gitView.changes.stageAllAria"),getActionLabel:n=>e("gitView.changes.stageFileAria",{path:n}),onActionFile:n=>{Pt([n],"stage")},onActionAll:n=>{Pt(n,"stage")},onViewDiff:n=>Rs(n,!1),onRevertFile:Fs}),s},[Fs,Rs,Pt,Ke,e,Vs]),kn=l.useCallback(s=>{if(s.length===0)return;const n=s.map(i=>i.trim()).filter(Boolean);if(n.length===0){Lt();return}We(i=>{const c=i.trim(),j=c.length>0?`
|
|
4
|
-
|
|
5
|
-
`:"";return`${c}${j}${n.join(`
|
|
6
|
-
`)}`.trim()}),Lt()},[Lt]),Vn=l.useCallback((s,n)=>{const i=n||s;We(c=>{const j=c.trimStart();return j.startsWith(s)||n&&j.startsWith(n)?c:`${i.endsWith(" ")?i:`${i} `}${c}`.trimStart()}),tr(""),rs(!1)},[]),Wt=l.useCallback(s=>{const n=s instanceof Error?s.message.toLowerCase():"";return n.includes("uncommitted changes")||n.includes("local changes")||n.includes("your local changes would be overwritten")||n.includes("please commit your changes or stash them")||n.includes("cannot rebase: you have unstaged changes")||n.includes("error: cannot pull with rebase")},[]),dt=l.useCallback((s,n)=>{Gt(i=>[...i,{message:s,status:n,timestamp:Date.now()}])},[]),Ge=l.useCallback((s,n)=>{Gt(i=>{if(i.length===0)return i;const c=[...i];return c[c.length-1]={...c[c.length-1],status:s,...n?{message:n}:{}},c})},[]),Ut=l.useCallback(()=>{Gt([])},[]),Pn=l.useCallback(()=>{Gt([]),ys(null)},[]),Jt=l.useCallback(s=>{const n=s.trim(),i=new Set(ze.map(j=>j.name)),c=n.indexOf("/");if(c>0){const j=n.slice(0,c),A=n.slice(c+1);if(i.has(j)&&A)return{branch:n,remote:j,remoteBranch:A}}for(const j of ze){const A=`${j.name}/${n}`;if(ot.includes(A))return{branch:A,remote:j.name,remoteBranch:n}}return{branch:n,remote:null,remoteBranch:null}},[ze,ot]),In=l.useCallback(async s=>{if(!r)return;ys("merge"),Ut();const n=u?.current,i=Jt(s);try{i.remote&&i.remoteBranch&&(dt(`Fetching ${i.remote}/${i.remoteBranch}...`,"running"),await a.gitFetch(r,{remote:i.remote,branch:i.remoteBranch}),Ge("done",`Fetched ${i.remote}/${i.remoteBranch}`)),dt(`Merging ${i.branch} into ${n}...`,"running");const c=await a.merge(r,{branch:i.branch});c.conflict?(Ge("error","Merge conflicts detected"),tt(c.conflictFiles??[]),st("merge"),Qe(!0),at(r,c.conflictFiles??[],"merge")):(Ge("done",`Merged ${i.branch} into ${n}`),qe(),dt("Refreshing repository status...","running"),await te(),await pe(),Ge("done","Repository status updated"))}catch(c){if(Wt(c))Ge("error","Uncommitted changes detected"),or("merge"),lr(i.branch),Cs(!0);else{const j=c instanceof Error?c.message:`Failed to merge ${i.branch}`;Ge("error",j)}}},[r,a,u,Jt,te,pe,Wt,at,qe,dt,Ge,Ut]),Fn=l.useCallback(async s=>{if(!r)return;ys("rebase"),Ut();const n=u?.current,i=Jt(s);try{i.remote&&i.remoteBranch&&(dt(`Fetching ${i.remote}/${i.remoteBranch}...`,"running"),await a.gitFetch(r,{remote:i.remote,branch:i.remoteBranch}),Ge("done",`Fetched ${i.remote}/${i.remoteBranch}`)),dt(`Rebasing ${n} onto ${i.branch}...`,"running");const c=await a.rebase(r,{onto:i.branch});c.conflict?(Ge("error","Rebase conflicts detected"),tt(c.conflictFiles??[]),st("rebase"),Qe(!0),at(r,c.conflictFiles??[],"rebase")):(Ge("done",`Rebased ${n} onto ${i.branch}`),qe(),dt("Refreshing repository status...","running"),await te(),await pe(),Ge("done","Repository status updated"))}catch(c){if(Wt(c))Ge("error","Uncommitted changes detected"),or("rebase"),lr(i.branch),Cs(!0);else{const j=c instanceof Error?c.message:`Failed to rebase onto ${i.branch}`;Ge("error",j)}}},[r,a,u,Jt,te,pe,Wt,at,qe,dt,Ge,Ut]),Rn=l.useCallback(async()=>{if(r)try{_t==="merge"?(await a.abortMerge(r),b.success(e("gitView.toast.mergeAborted"))):(await a.abortRebase(r),b.success(e("gitView.toast.rebaseAborted"))),qe(),await te(),await pe()}catch(s){const n=s instanceof Error?s.message:`Failed to abort ${_t}`;b.error(n)}},[r,a,_t,te,pe,qe,e]),Bn=l.useMemo(()=>u?.files?u.files.filter(s=>s.index==="U"||s.working_dir==="U"||s.index==="A"&&s.working_dir==="A"||s.index==="D"&&s.working_dir==="D").length:0,[u?.files]),Dn=l.useCallback(async()=>{if(r)try{const s=!!u?.mergeInProgress?.head,n=!!(u?.rebaseInProgress?.headName||u?.rebaseInProgress?.onto);if(s){const i=await a.continueMerge(r);i.conflict?(tt(i.conflictFiles??[]),st("merge"),Qe(!0),at(r,i.conflictFiles??[],"merge"),b.error(e("gitView.toast.mergeConflictsDetected"))):(qe(),b.success(e("gitView.toast.mergeCompleted")),await te(),await pe())}else if(n){const i=await a.continueRebase(r);i.conflict?(tt(i.conflictFiles??[]),st("rebase"),Qe(!0),at(r,i.conflictFiles??[],"rebase"),b.error(e("gitView.toast.rebaseConflictsDetected"))):(qe(),b.success(e("gitView.toast.rebaseStepCompleted")),await te(),await pe())}}catch(s){const n=s instanceof Error?s.message:e("gitView.toast.continueOperationFailed");b.error(n)}},[r,a,u,te,pe,at,qe,e]),Mn=l.useCallback(async()=>{if(r)try{!!u?.mergeInProgress?.head?(await a.abortMerge(r),b.success(e("gitView.toast.mergeAborted"))):(await a.abortRebase(r),b.success(e("gitView.toast.rebaseAborted"))),qe(),await te(),await pe()}catch(s){const n=s instanceof Error?s.message:e("gitView.toast.abortOperationFailed");b.error(n)}},[r,a,u,te,pe,qe,e]),En=l.useCallback(()=>{if(!r)return;const n=!!u?.mergeInProgress?.head?"merge":"rebase",i=u?.files?.filter(c=>c.index==="U"||c.working_dir==="U").map(c=>c.path)??[];i.length>0&&tt(i),st(n),Qe(!0)},[r,u]),Tn=l.useCallback(async s=>{if(!r)return;const n=u?.current,i=Ns,c=Ss,j=(u?.files??[]).some(Ir);try{await a.stash(r,{message:`Auto-stash before ${i} with ${c}`,includeUntracked:!0}),j&&J(r)}catch(_){const _e=_ instanceof Error?_.message:"Failed to stash changes";b.error(_e);return}let A=!1,Z=!1;try{if(i==="merge"){const _=await a.merge(r,{branch:c});_.conflict?(Z=!0,tt(_.conflictFiles??[]),st("merge"),Qe(!0)):(A=!0,b.success(e("gitView.toast.mergedIntoBranch",{branch:c,currentBranch:n||""})))}else{const _=await a.rebase(r,{onto:c});_.conflict?(Z=!0,tt(_.conflictFiles??[]),st("rebase"),Qe(!0)):(A=!0,b.success(e("gitView.toast.rebasedOntoBranch",{currentBranch:n||"",branch:c})))}if(s&&A)try{await a.stashPop(r),J(r),b.success(e("gitView.toast.stashedRestored"))}catch(_){const _e=_ instanceof Error?_.message:e("gitView.toast.restoreStashFailed");b.error(_e)}else s&&Z&&b.info(e("gitView.toast.restoreStashManually"));await te(),await pe()}catch(_){if(s)try{await a.stashPop(r),J(r)}catch{}throw _}},[J,r,a,u,Ns,Ss,te,pe,e]),Ln=l.useCallback(s=>{Or(s),r&&(O(r,s),P(r,a,s))},[r,P,a,O]),On=l.useCallback(s=>{rn(s)},[]),An=l.useCallback(()=>{zt(null),r&&(h(r,a),d(r,a),P(r,a,Ye))},[r,h,d,P,Ye,a]),zn=l.useCallback(s=>{if(s.conflict){if(s.operation==="cherry-pick"||s.operation==="revert"){b.error(e("gitView.history.actions.conflictToastTitle"),{description:e("gitView.history.actions.conflictToastDescription",{files:s.conflictFiles?.join(", ")??"unknown files"})}),r&&(h(r,a),d(r,a),P(r,a,Ye));return}tt(s.conflictFiles??[]),st(s.operation),Qe(!0),r&&at(r,s.conflictFiles??[],s.operation)}},[e,tt,st,Qe,at,r,h,d,P,Ye,a]);return m?Ue?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[Le?null:t.jsx(T,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e(Le?"gitView.toast.refreshRepositoryFailed":"gitView.empty.worktreeSetupInProgress")}),Le?t.jsx(W,{type:"button",variant:"outline",size:"sm",className:"mt-3",onClick:()=>{oe&&x({directory:oe,status:"refreshing"})},children:e("gitView.empty.retryDiscovery")}):t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.worktreeSetupDescription")})]}):B===null||B===!0&&!u?t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-ui-label",children:e("gitView.loading.checkingRepository")})]})}):B===!1?t.jsx(Ha,{rootIsGitRepo:F,resolvedIsGitRepo:B,nestedRepos:Y,onRetryDiscovery:()=>{m&&de(m,{force:!0})},emptyStateFooter:se.includes("open-without-worktree-features")?t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:e("gitView.empty.worktreeFeaturesUnavailable")}):void 0}):t.jsxs("div",{className:Se("flex h-full flex-col overflow-hidden"),children:[t.jsx($a,{directory:r??"",status:u,localBranches:Vt,remoteBranches:ot,branchInfo:H?.branches,syncAction:$s,remotes:ze,onFetch:s=>dr("fetch",s),onSync:s=>dr("sync",s),onRemoveRemote:dn,removingRemoteName:Xr,onCheckoutBranch:gn,onCreateBranch:mn,onRenameBranch:hn,activeIdentityProfile:wn,availableIdentities:xn,onSelectIdentity:fn,isApplyingIdentity:Ar,isWorktreeMode:!!G,onOpenHistory:()=>zt("history"),onOpenGraph:()=>zt("graph"),onOpenStashes:Nn,onOpenUpdateBranch:hr?()=>sr(!0):void 0,onOpenReintegrateCommits:ct?()=>rr(!0):void 0,pullRequest:Re?.pr??null,prChecks:Re?.checks??null,onOpenPullRequest:r?()=>xe(r,"pr"):void 0,repositoryOptions:r!==m&&Array.isArray(Y)?Y:void 0,selectedRepository:r!==m?r:null,onSelectRepository:r!==m&&m?s=>ke(m,s):void 0,repositoryRoot:r!==m?m:void 0}),m&&(u?.mergeInProgress?.head||u?.rebaseInProgress?.headName||u?.rebaseInProgress?.onto)&&t.jsx(Pi,{mergeInProgress:u?.mergeInProgress,rebaseInProgress:u?.rebaseInProgress,onContinue:Dn,onAbort:Mn,onResolveWithAI:En,conflictCount:Bn,isLoading:le}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx("div",{className:"h-full min-h-0 flex flex-col",children:t.jsx("div",{className:Se("min-w-0 min-h-0 h-full flex flex-col"),children:t.jsx(Rr,{as:La,ref:Hs,outerClassName:"flex-1 min-h-0",className:Se("px-4","pt-1 pb-4"),disableHorizontal:!0,preventOverscroll:!0,children:t.jsx("div",{className:"flex h-full min-h-0 flex-col gap-3",children:(it?.length??0)>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Ua,{groups:Sn,diffStats:u?.diffStats,revertingPaths:os,isRevertingAll:ls,onVisiblePathsChange:Er,onRevertAll:jn,onRevertDirectory:Cn,headerBackgroundClassName:"bg-background"})}),t.jsx(Ja,{stagedCount:yn,commitMessage:Je,onCommitMessageChange:We,generatedHighlights:cs,onInsertHighlights:kn,onGenerateMessage:un,isGeneratingMessage:$r,onCommit:()=>ur({pushAfter:!1}),onCommitAndPush:()=>ur({pushAfter:!0}),commitAction:Ws,hasPendingIndexMutation:Wr,gitmojiEnabled:fe,onOpenGitmojiPicker:()=>rs(!0)})]}):t.jsx(oi,{onOpenStashes:()=>ns(!0)})})})})})}),t.jsx(mt,{open:Yr,onOpenChange:s=>{!s&&ar!==null||sr(s)},children:t.jsxs(ht,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(gt,{children:[t.jsx(ft,{children:e("gitView.branch.updateTitle")}),t.jsxs(bt,{children:[e("gitView.branch.updateDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:u?.current??""}),"."]})]}),hr?t.jsx(Ii,{mode:"bare",currentBranch:u?.current,localBranches:Vt,remoteBranches:ot,defaultTargetBranch:pn,onMerge:In,onRebase:Fn,disabled:bn,isOperating:ar!==null,operationLogs:Zr,onOperationComplete:Pn}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("gitView.branch.actionsUnavailable")})]})}),t.jsx(mt,{open:Qr,onOpenChange:rr,children:t.jsxs(ht,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(gt,{children:[t.jsx(ft,{children:e("gitView.integrate.title")}),t.jsx(bt,{children:ct?t.jsxs("span",{className:"font-mono text-foreground",children:[ct.sourceBranch," → ",Zs]}):null})]}),ct?t.jsx(ai,{repoRoot:ct.repoRoot,sourceBranch:ct.sourceBranch,worktreeMetadata:ct.worktreeMetadata,localBranches:Vt,defaultTargetBranch:Zs,refreshKey:_r,showHeader:!1,onRefresh:()=>{r&&(h(r,a),d(r,a),P(r,a,Ye))}},ct.worktreeMetadata.path):null]})}),t.jsx(mt,{open:Me!==null,onOpenChange:s=>{s||zt(null)},children:t.jsxs(ht,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs(gt,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(ft,{children:e(Me==="graph"?"gitView.graph.title":"gitView.history.title")}),t.jsxs(W,{type:"button",variant:"ghost",size:"sm",className:"mr-6 h-7 shrink-0 gap-1.5 px-2",onClick:()=>{if(Me==="graph"){an(s=>s+1);return}r&&P(r,a,Ye)},disabled:Me==="graph"?vs:ae,title:e("gitView.history.refresh"),"aria-label":e("gitView.history.refresh"),children:[t.jsx(T,{name:"refresh",className:Se("size-4",(Me==="graph"?vs:ae)&&"animate-spin")}),e("gitView.history.refresh")]})]}),t.jsx(bt,{children:e("gitView.history.dialogDescription")})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(pi,{mode:Me==="graph"?"graph":"history",log:Me==="graph"?sn??X:X,isLogLoading:Me==="graph"&&vs||ae,logMaxCount:Me==="graph"?js:Ye,onLogMaxCountChange:Me==="graph"?On:Ln,expandedCommitHashes:hs,onToggleCommit:cn,commitFilesMap:Ot,loadingCommitHashes:At,onCopyHash:ln,directory:r??void 0,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:Me==="graph"?null:Kr,onConflict:Me==="graph"?zn:void 0,onActionSuccess:Me==="graph"?An:void 0})})]})}),t.jsx(ii,{open:Lr,onOpenChange:ns,directory:r,hasUncommittedChanges:(u?.files?.length??0)>0,hasStagedChanges:Ke.length>0,uncommittedFileCount:u?.files?.length??0,onChanged:async s=>{r&&s?.affectsIndex&&J(r),await te(!1),await pe()}}),t.jsx(mt,{open:Tr,onOpenChange:rs,children:t.jsxs(ht,{className:"max-w-md p-0 overflow-hidden",children:[t.jsx(gt,{className:"px-4 pt-4",children:t.jsx(ft,{children:e("gitView.gitmoji.title")})}),t.jsxs(As,{className:"h-[420px]",shouldFilter:!1,children:[t.jsx(zs,{placeholder:e("gitView.gitmoji.searchPlaceholder"),value:er,onValueChange:tr}),t.jsxs(Gs,{children:[t.jsx(_s,{children:e("gitView.gitmoji.empty")}),t.jsx(Xt,{children:Dt($e,er,s=>[s.code,s.description,s.emoji]).map(s=>t.jsxs(Zt,{onSelect:()=>Vn(s.emoji,s.code),children:[t.jsx("span",{className:"text-lg",children:s.emoji}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s.code}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s.description})]},s.code))})]})]})]})}),r&&t.jsx(vi,{open:en,onOpenChange:Qe,conflictFiles:tn,directory:r,operation:_t,onAbort:Rn,onClearState:qe}),t.jsx(qa,{open:Ht!==null,onOpenChange:s=>{s||kt(null)},targetBranch:Ht??"",changedFileCount:u?.files?.length??0,onCommitAndSwitch:async(s,n)=>{const i=Ht;if(!i||!r)return;const c=u?.current??null;await a.createGitCommit(r,s,{addAll:!0}),J(r);let j=null;if(n){const A=u?.tracking?.split("/")[0],Z=ze.find(_=>_.name===A)??ze[0];try{if(!Z)throw new Error(e("mobile.changes.noRemote"));await a.gitPush(r,u?.tracking?{remote:Z.name}:{remote:Z.name,branch:c??void 0,options:["--set-upstream"]}),j=Z.name}catch(_){console.error("Push after commit failed:",_),b.error(e("gitView.dirtySwitch.pushFailed")),await te(),await pe(),kt(null);return}}b.success(j?e("gitView.toast.pushedToUpstream",{name:j}):c?e("gitView.dirtySwitch.committedNotPushed",{branch:c}):e("gitView.toast.commitCreated")),await te(),await pe(),kt(null),await Is(i)},onGenerateMessage:async()=>{if(!r)return"";const s=(u?.files??[]).map(c=>c.path).sort(),{message:n}=await fr(r,s),i=n.subject?.trim()??"";if(i&&fe&&$e.length>0){const c=Pr(i,$e);if(c&&!i.startsWith(c.code)&&!i.startsWith(c.emoji))return`${c.code} ${i}`}return i},onRevertAndSwitch:async()=>{const s=Ht;if(!s||!r)return;const n=(u?.files??[]).map(c=>c.path);await It(n,!0,"all");const i=await a.getGitStatus(r);if(!i.isClean&&(i.files?.length??0)>0){b.error(e("gitView.dirtySwitch.revertIncomplete"));return}kt(null),await Is(s)}}),t.jsx(Vi,{open:on,onOpenChange:Cs,operation:Ns,targetBranch:Ss,onConfirm:Tn})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center",children:t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:e("gitView.empty.selectSessionOrDirectory")})})};export{ic as GitView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as r,j as s,f as tt}from"./vendor-react-BUCujlKS.js";import{f as yt,Y as vt,aC as xe,ch as jt,bZ as It,t as y,iD as Nt,I as u,B as he,o as Ze,bT as He,a4 as Qe,c2 as Pt,c3 as wt,c4 as St,c5 as kt,c6 as Lt,c8 as $e,h as K,V as Ct,at as Rt,ap as At,ar as Ft,as as Et,ao as Tt}from"./useAppFontEffects-DeStGcUT.js";import{u as f,dF as M}from"./index-BfwRClDe.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-BY_5qla_.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DWA1bm1F.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-zod-B6551dwG.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-sdk-BJ73u-bH.js";const Je="[&_img]:max-w-full [&_img]:h-auto",st="flex h-8 min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",Ae="flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",Mt=520,Xe=t=>t.name?.trim()||t.urlKey?.trim()||t.id,Kt={0:"contextPanel.linear.priority.none",1:"contextPanel.linear.priority.urgent",2:"contextPanel.linear.priority.high",3:"contextPanel.linear.priority.medium",4:"contextPanel.linear.priority.low"},Dt={triage:0,backlog:1,unstarted:2,started:3,completed:4,canceled:5},et=t=>t==="triage"||t==="backlog"||t==="unstarted"||t==="started"||t==="completed"||t==="canceled"?Dt[t]:99,Ot=(t,n)=>{const o=et(t.type)-et(n.type);return o!==0?o:t.position!==n.position?t.position-n.position:t.name.localeCompare(n.name)},zt=t=>t!==0&&t!==1&&t!==2&&t!==3&&t!==4?null:Kt[t],ge=[{value:"all",labelKey:"contextPanel.linear.filter.status.all"},{value:"backlog",labelKey:"contextPanel.linear.filter.status.backlog"},{value:"todo",labelKey:"contextPanel.linear.filter.status.todo"},{value:"started",labelKey:"contextPanel.linear.filter.status.started"},{value:"inReview",labelKey:"contextPanel.linear.filter.status.inReview"},{value:"completed",labelKey:"contextPanel.linear.filter.status.completed"},{value:"canceled",labelKey:"contextPanel.linear.filter.status.canceled"},{value:"duplicate",labelKey:"contextPanel.linear.filter.status.duplicate"}],Ut=t=>ge.some(n=>n.value===t),be=[{value:"all",labelKey:"contextPanel.linear.filter.priority.all"},{value:"urgent",labelKey:"contextPanel.linear.priority.urgent"},{value:"high",labelKey:"contextPanel.linear.priority.high"},{value:"medium",labelKey:"contextPanel.linear.priority.medium"},{value:"low",labelKey:"contextPanel.linear.priority.low"},{value:"none",labelKey:"contextPanel.linear.priority.none"}],_t=t=>be.some(n=>n.value===t),Wt=t=>t?{color:t,backgroundColor:`color-mix(in srgb, ${t} 18%, transparent)`}:{backgroundColor:"color-mix(in srgb, var(--surface-mutedForeground) 12%, transparent)"},Vt=t=>{const n=tt.c(4),{labels:o}=t;if(o.length===0)return null;let c;n[0]!==o?(c=o.map(Yt),n[0]=o,n[1]=c):c=n[1];let b;return n[2]!==c?(b=s.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:c}),n[2]=c,n[3]=b):b=n[3],b},te=t=>{const n=tt.c(31),{icon:o,label:c,ariaLabel:b,value:W,items:V,disabled:v,compact:x,active:w,onValueChange:d}=t,[S,G]=r.useState(!1),B=v?!1:S;let F;n[0]!==v?(F=D=>{v||G(D)},n[0]=v,n[1]=F):F=n[1];const Z=w===!0,k=x?Ae:st,H=x?c:void 0,Q=w?"text-primary":"text-muted-foreground";let L;n[2]!==Q?(L=K("size-3.5 shrink-0",Q),n[2]=Q,n[3]=L):L=n[3];let C;n[4]!==o||n[5]!==L?(C=s.jsx(u,{name:o,className:L}),n[4]=o,n[5]=L,n[6]=C):C=n[6];let h;n[7]!==x||n[8]!==c?(h=x?null:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate",children:c}),s.jsx(u,{name:"arrow-down-s",className:"size-4 shrink-0 opacity-60"})]}),n[7]=x,n[8]=c,n[9]=h):h=n[9];let R;n[10]!==b||n[11]!==v||n[12]!==Z||n[13]!==k||n[14]!==H||n[15]!==C||n[16]!==h?(R=s.jsx(At,{asChild:!0,children:s.jsxs("button",{type:"button",disabled:v,"aria-pressed":Z,className:k,"aria-label":b,title:H,children:[C,h]})}),n[10]=b,n[11]=v,n[12]=Z,n[13]=k,n[14]=H,n[15]=C,n[16]=h,n[17]=R):R=n[17];let j;n[18]!==d?(j=D=>{d(D),G(!1)},n[18]=d,n[19]=j):j=n[19];let A;n[20]!==V?(A=V.map(Zt),n[20]=V,n[21]=A):A=n[21];let I;n[22]!==j||n[23]!==A||n[24]!==W?(I=s.jsx(Ft,{align:"start",className:"min-w-40",children:s.jsx(Et,{value:W,onValueChange:j,children:A})}),n[22]=j,n[23]=A,n[24]=W,n[25]=I):I=n[25];let N;return n[26]!==B||n[27]!==R||n[28]!==I||n[29]!==F?(N=s.jsxs(Tt,{open:B,onOpenChange:F,children:[R,I]}),n[26]=B,n[27]=R,n[28]=I,n[29]=F,n[30]=N):N=n[30],N},Gt=t=>{const n=t.trim();if(!n)return null;const o=n.match(/linear\.app\/(?:[^/]+\/)?issue\/([A-Za-z][A-Za-z0-9]*-\d+)/i);return o?o[1].toUpperCase():/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(n)?n.toUpperCase():null},Bt=t=>({id:t.id,identifier:t.identifier,title:t.title,url:t.url,state:t.state,assignee:t.assignee,team:t.team,priority:t.priority,labels:t.labels}),qt=(t,n)=>{const o=Bt(n);return t.map(c=>c.id===n.id?o:c)},Nn=()=>{const{t}=yt(),{linear:n}=vt(),o=xe(e=>e.status),c=xe(e=>e.hasChecked),b=xe(e=>e.refreshStatus),W=xe(e=>e.setStatus),V=f(e=>e.setSettingsDialogOpen),v=f(e=>e.setSettingsPage),x=f(e=>e.linearIssueListStatus),w=f(e=>e.linearIssueListAssignee),d=f(e=>e.linearIssueListTeamId),S=f(e=>e.linearIssueListPriority),G=f(e=>e.linearIssueFocus),B=f(e=>e.timeFormatPreference),F=f(e=>e.setLinearIssueListStatus),Z=f(e=>e.setLinearIssueListAssignee),k=f(e=>e.setLinearIssueListTeamId),H=f(e=>e.setLinearIssueListPriority),Q=f(e=>e.resetLinearIssueListFilters),L=f(e=>e.setLinearIssueFocus),C=f(e=>e.applyLinearIssueListFiltersForRuntime);r.useEffect(()=>{C()},[C]);const[h,R]=r.useState(""),[j,A]=r.useState(!1),[I,N]=r.useState([]),[D,se]=r.useState(null),[ye,ne]=r.useState(!1),[O,z]=r.useState(!0),[ae,Fe]=r.useState(!1),[$,Ee]=r.useState(!1),[Te,re]=r.useState(null),[J,E]=r.useState(null),[l,X]=r.useState(null),[U,le]=r.useState([]),[nt,Me]=r.useState(!1),[q,Ke]=r.useState(!1),[ie,De]=r.useState(!1),[oe,ve]=r.useState(!1),[Y,ce]=r.useState([]),[ue,Oe]=r.useState(!1),P=r.useRef(0),je=r.useRef(null),ze=r.useRef(null),[Ue,at]=r.useState(0),de=r.useMemo(()=>Gt(h),[h]),Ie=jt(h,350),rt=r.useCallback(e=>{if(!e)return"";const a=Date.parse(e);return Number.isFinite(a)?It(a,B,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):""},[B]),lt=r.useCallback(()=>{v("integrations"),V(!0)},[V,v]),me=r.useMemo(()=>({query:Ie.trim()||void 0,status:x,assignee:w,teamId:d===M?void 0:d,priority:S==="all"?void 0:S}),[Ie,w,S,x,d]),pe=o?.workspaces??[],_=pe.find(e=>e.current)?.id||o?.organization?.id||"",_e=r.useCallback(async()=>{if(c&&o?.connected===!1){z(!1),N([]),ne(!1),se(null),re(null);return}if(!n?.issuesList){z(!0),re(t("session.linearIssuePicker.error.runtimeUnavailable"));return}const e=P.current+1;P.current=e,Fe(!0),re(null);try{const a=await n.issuesList(me);if(e!==P.current)return;if(z(a.connected!==!1),a.connected===!1){N([]),ne(!1),se(null);return}N(a.issues??[]),se(a.cursor??null),ne(!!a.hasMore)}catch(a){if(e!==P.current)return;re(a instanceof Error?a.message:String(a))}finally{e===P.current&&Fe(!1)}},[n,c,o,me,t]);r.useEffect(()=>{n&&!c&&b(n)},[n,c,b]),r.useEffect(()=>{_e()},[_e]),r.useEffect(()=>{if(!n?.mappingGet||!O){ce([]);return}let e=!1;return n.mappingGet().then(a=>{if(!e){if(a.connected===!1){ce([]);return}ce(a.teams??[])}}).catch(()=>{e||ce([])}),()=>{e=!0}},[O,_,n]),r.useEffect(()=>{d===M||Y.length===0||Y.some(e=>e.id===d)||k(M)},[d,k,Y]);const it=r.useCallback(async()=>{if(!n?.issuesList||$||ae||!ye||!D)return;const e=P.current+1;P.current=e,Ee(!0);try{const a=await n.issuesList({...me,cursor:D});if(e!==P.current||(z(a.connected!==!1),a.connected===!1))return;N(i=>[...i,...a.issues??[]]),se(a.cursor??null),ne(!!a.hasMore)}catch(a){if(e!==P.current)return;const i=a instanceof Error?a.message:String(a);y.error(t("session.linearIssuePicker.toast.loadMoreFailed"),{description:i})}finally{e===P.current&&Ee(!1)}},[D,ye,ae,$,n,me,t]);r.useEffect(()=>{if(!J||!n?.issueGet)return;let e=!1;return Me(!0),X(null),le([]),(async()=>{try{const a=await n.issueGet(J);if(e)return;if(a.connected===!1){z(!1),E(null);return}const i=a.issue;if(!i){y.error(t("session.linearIssuePicker.error.issueNotFound")),E(null);return}X(i);const T=i.team?.id;if(!T||!n.issueStates)return;try{const g=await n.issueStates(T);if(e)return;if(g.connected===!1){z(!1);return}le(g.states??[])}catch(g){if(e)return;const fe=g instanceof Error?g.message:String(g);y.error(t("session.linearIssuePicker.toast.loadIssueDetailsFailed"),{description:fe})}}catch(a){if(e)return;const i=a instanceof Error?a.message:String(a);y.error(t("session.linearIssuePicker.toast.loadIssueDetailsFailed"),{description:i}),E(null)}finally{e||Me(!1)}})(),()=>{e=!0}},[n,J,t]),r.useEffect(()=>{G&&(E(G),L(null))},[G,L]);const We=r.useCallback(e=>{X(e),N(a=>qt(a,e))},[]),Ne=r.useCallback(async(e,a)=>{if(!(!n?.issueUpdate||!l||q)&&l.state?.id!==e){Ke(!0);try{const i=await n.issueUpdate({id:l.id,stateId:e});if(i.connected===!1){z(!1),y.error(t(a));return}if(!i.issue){y.error(t(a));return}We(i.issue),y.success(t("contextPanel.linear.toast.statusUpdated"))}catch(i){const T=i instanceof Error?i.message:String(i);y.error(t(a),{description:T})}finally{Ke(!1)}}},[We,q,n,l,t]),ot=r.useCallback(()=>{const e=U.find(a=>a.type==="completed");if(!e){y.error(t("contextPanel.linear.error.noCompletedState"));return}Ne(e.id,"contextPanel.linear.toast.closeFailed")},[t,Ne,U]),ct=r.useCallback(async()=>{if(!(!l||ie)){De(!0);try{await Nt({linear:n,issueKey:l.id,createInWorktree:oe,t})}finally{De(!1)}}},[oe,ie,n,l,t]),ut=r.useCallback(async e=>{if(!(!n?.authActivate||!e||e===_||ue)){Oe(!0);try{const a=await n.authActivate(e);W(a),E(null),X(null),le([]),k(M),y.success(t("contextPanel.linear.toast.workspaceSwitched"))}catch(a){const i=a instanceof Error?a.message:String(a);y.error(t("contextPanel.linear.toast.workspaceSwitchFailed"),{description:i})}finally{Oe(!1)}}},[_,ue,n,W,k,t]),Pe=r.useMemo(()=>{const e=new Map(U.map(g=>[g.id,g])),a=l?.state?.id,i=l?.state?.name;return[...a&&i&&!e.has(a)?[{id:a,name:i,type:l.state?.type??null,position:0},...U]:U].sort(Ot)},[l,U]),dt=U.find(e=>e.type==="completed"),mt=l?.state?.type==="completed",Ve=c&&O===!1,pt=!n,Ge=!!J,Be=x==="all"&&w==="any"&&d===M&&S==="all",we=!!n&&O&&!Ve,ee=!we||ue,m=Ue>0&&Ue<Mt,Se=h.trim().length>0,ft=!Be||Se,ke=!m||j||Se,Le=r.useCallback(()=>{R(""),A(!1)},[]);r.useEffect(()=>{const e=je.current;if(!e||!globalThis.ResizeObserver)return;const a=new ResizeObserver(i=>{at(i[0]?.contentRect.width??0)});return a.observe(e),()=>a.disconnect()},[Ge]),r.useEffect(()=>{m&&j&&ze.current?.focus()},[m,j]);const xt=s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":oe,onClick:()=>ve(e=>!e),onKeyDown:e=>{(e.key===" "||e.key==="Enter")&&(e.preventDefault(),ve(a=>!a))},children:[s.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),ve(a=>!a)},"aria-label":t("session.linearIssuePicker.actions.toggleWorktreeAria"),className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:oe?s.jsx(u,{name:"checkbox",className:"h-4 w-4 text-primary"}):s.jsx(u,{name:"checkbox-blank",className:"h-4 w-4"})}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("session.linearIssuePicker.actions.createInWorktree")})]}),ht=e=>s.jsxs("div",{className:K("group flex items-center gap-2 py-1.5 px-1 rounded cursor-pointer hover:bg-interactive-hover/30 transition-colors",J===e.id&&"bg-interactive-selection/30"),onClick:()=>E(e.id),children:[s.jsx("span",{className:"typography-meta text-muted-foreground w-16 text-right flex-shrink-0",children:e.identifier}),s.jsx("p",{className:"flex-1 min-w-0 typography-small text-foreground truncate ml-0.5",children:e.title}),s.jsx("div",{className:"flex-shrink-0 h-5 flex items-center mr-1",children:s.jsx("button",{type:"button",className:"hidden group-hover:flex h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground transition-colors",onClick:a=>{a.stopPropagation(),Ze(e.url)},"aria-label":t("session.linearIssuePicker.actions.openInLinearAria"),children:s.jsx(u,{name:"external-link",className:"h-4 w-4"})})})]},e.id);if(Ge){const e=l?.assignee?.displayName||l?.assignee?.name,a=l?.comments??[],i=l?.description?.trim()||"",T=l?.state?.id||"",g=zt(l?.priority),fe=l?.labels??[];return s.jsxs("div",{ref:je,className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[s.jsxs(he,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:()=>{E(null),X(null),le([])},"aria-label":t("contextPanel.linear.actions.backToList"),children:[s.jsx(u,{name:"arrow-left-s",className:"h-4 w-4"}),t("contextPanel.linear.actions.backToList")]}),l?s.jsx("button",{type:"button",className:"ml-auto flex h-7 w-7 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{Ze(l.url)},"aria-label":t("session.linearIssuePicker.actions.openInLinearAria"),children:s.jsx(u,{name:"external-link",className:"h-4 w-4"})}):null]}),s.jsxs(He,{as:Qe,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:[nt&&!l?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("contextPanel.linear.loading.issue")]}):null,l?s.jsx(r.Suspense,{fallback:s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("contextPanel.linear.loading.issue")]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:l.identifier}),s.jsx("h2",{className:"typography-ui-header text-foreground mt-0.5",children:l.title})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Pe.length>0&&T?s.jsxs(Pt,{value:T,onValueChange:p=>{Ne(p,"contextPanel.linear.toast.statusUpdateFailed")},disabled:q,children:[s.jsx(wt,{size:"sm",className:"h-7 w-auto min-w-0","aria-label":t("contextPanel.linear.label.statusAria"),children:s.jsx(St,{placeholder:t("contextPanel.linear.label.status"),children:p=>Pe.find(Ce=>Ce.id===p)?.name??p})}),s.jsx(kt,{children:Pe.map(p=>s.jsx(Lt,{value:p.id,children:p.name},p.id))})]}):l.state?.name?s.jsx("span",{className:"typography-meta text-muted-foreground",children:l.state.name}):null,dt&&!mt?s.jsxs(he,{type:"button",variant:"outline",size:"sm",className:"h-7",onClick:ot,disabled:q,children:[q?s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}):null,t("contextPanel.linear.actions.closeIssue")]}):null]}),s.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 typography-meta",children:[l.team?.name?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.team")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:l.team.name})]}):null,s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.assignee")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:e||t("contextPanel.linear.label.unassigned")}),g?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.priority")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:t(g)})]}):null,fe.length>0?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.labels")}),s.jsx("dd",{className:"min-w-0",children:s.jsx(Vt,{labels:fe})})]}):null]}),s.jsx("div",{children:i?s.jsx($e,{content:i,className:Je,enableFileReferences:!1}):s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("contextPanel.linear.empty.noDescription")})}),s.jsxs("div",{children:[s.jsx("h3",{className:"typography-ui-label text-foreground mb-2",children:t("contextPanel.linear.label.comments")}),a.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("contextPanel.linear.empty.noComments")}):s.jsx("div",{className:"relative pl-3",children:a.map((p,Ce)=>{const Re=p.user?.displayName||p.user?.name||t("contextPanel.linear.label.unassigned"),qe=p.user?.avatarUrl||null,gt=Re.charAt(0).toUpperCase(),bt=Ce===a.length-1,Ye=rt(p.createdAt);return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[bt?null:s.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),s.jsx("div",{className:"absolute left-0 top-0 z-10 flex size-8 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-surface-elevated text-xs text-muted-foreground",children:qe?s.jsx("img",{src:qe,alt:Re,className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("span",{children:gt})}),s.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{className:"text-foreground whitespace-nowrap",children:Re}),Ye?s.jsx("span",{className:"whitespace-nowrap",children:Ye}):null]}),p.body.trim()?s.jsx($e,{content:p.body,className:K("typography-markdown-body text-foreground break-words",Je),enableFileReferences:!1}):null]})]},p.id)})})]})]})}):null]}),l?s.jsxs("div",{className:"shrink-0 border-t border-border px-4 py-3 flex flex-col gap-3",children:[xt,s.jsxs(he,{type:"button",onClick:()=>{ct()},disabled:ie||q,className:"w-full",children:[ie?s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}):null,t("contextPanel.linear.actions.startSession")]})]}):null]})}return s.jsxs("div",{ref:je,className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"px-3 pt-3 space-y-2",children:[ke?s.jsxs("div",{className:"relative",children:[s.jsx(u,{name:"search",className:K("absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4",Se?"text-primary":"text-muted-foreground")}),s.jsx(Ct,{ref:ze,placeholder:t("session.linearIssuePicker.searchPlaceholder"),value:h,onChange:e=>R(e.target.value),onKeyDown:e=>{e.key==="Escape"&&m&&(e.preventDefault(),Le())},className:K("pl-9 w-full",m&&"pr-9")}),m?s.jsx("button",{type:"button",className:"absolute right-1.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-interactive-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring","aria-label":t("contextPanel.linear.actions.closeSearch"),title:t("contextPanel.linear.actions.closeSearch"),onClick:Le,children:s.jsx(u,{name:"close",className:"size-3.5"})}):null]}):null,we||m&&!ke?s.jsxs("div",{className:K("flex min-w-0 items-center",m&&"gap-0.5"),children:[we?s.jsxs(s.Fragment,{children:[s.jsx(te,{icon:"task",label:t((ge.find(e=>e.value===x)??ge[0]).labelKey),ariaLabel:t("contextPanel.linear.filter.statusAria"),value:x,active:x!=="all",disabled:ee,items:ge.map(e=>({value:e.value,label:t(e.labelKey)})),onValueChange:e=>{Ut(e)&&F(e)}}),s.jsx(te,{icon:"error-warning",compact:m,label:t((be.find(e=>e.value===S)??be[0]).labelKey),ariaLabel:t("contextPanel.linear.filter.priorityAria"),value:S,active:S!=="all",disabled:ee,items:be.map(e=>({value:e.value,label:t(e.labelKey)})),onValueChange:e=>{_t(e)&&H(e)}}),s.jsx(te,{icon:"user-3",compact:m,label:t(w==="me"?"contextPanel.linear.filter.assignee.me":"contextPanel.linear.filter.assignee.any"),ariaLabel:t("contextPanel.linear.filter.assigneeAria"),value:w,active:w!=="any",disabled:ee,items:[{value:"any",label:t("contextPanel.linear.filter.assignee.any")},{value:"me",label:t("contextPanel.linear.filter.assignee.me")}],onValueChange:e=>{(e==="any"||e==="me")&&Z(e)}}),Y.length>0?s.jsx(te,{icon:"team",compact:m,label:d===M?t("contextPanel.linear.filter.team.all"):Y.find(e=>e.id===d)?.name??d,ariaLabel:t("contextPanel.linear.filter.teamAria"),value:d,active:d!==M,disabled:ee,items:[{value:M,label:t("contextPanel.linear.filter.team.all")},...Y.map(e=>({value:e.id,label:e.name}))],onValueChange:k}):null,pe.length>1&&_?s.jsx(te,{icon:"briefcase",compact:m,label:Xe(pe.find(e=>e.id===_)??{id:_,name:null,urlKey:null}),ariaLabel:t("contextPanel.linear.label.workspaceAria"),value:_,disabled:ue,items:pe.map(e=>({value:e.id,label:Xe(e)})),onValueChange:e=>{ut(e)}}):null,ft?s.jsxs("button",{type:"button",className:K(m?Ae:st,!m&&"flex-none"),"aria-label":t("contextPanel.linear.filter.clearAria"),title:t("contextPanel.linear.filter.clearAria"),disabled:ee,onClick:()=>{Q(),Le()},children:[s.jsx(u,{name:"close",className:"size-3.5 shrink-0 text-muted-foreground"}),m?null:s.jsx("span",{className:"min-w-0 truncate",children:t("contextPanel.linear.filter.clear")})]}):null]}):null,m&&!ke?s.jsx("button",{type:"button",className:Ae,"aria-label":t("contextPanel.linear.filter.searchAria"),title:t("contextPanel.linear.filter.searchAria"),onClick:()=>A(!0),children:s.jsx(u,{name:"search",className:"size-3.5 shrink-0 text-muted-foreground"})}):null]}):null]}),s.jsxs(He,{as:Qe,outerClassName:"h-full min-h-0 flex-1",className:"px-3 py-2",disableHorizontal:!0,preventOverscroll:!0,children:[pt?s.jsx("div",{className:"text-center text-muted-foreground py-8",children:t("session.linearIssuePicker.empty.runtimeUnavailable")}):null,ae&&I.length===0?s.jsxs("div",{className:"text-center text-muted-foreground py-8 flex items-center justify-center gap-2",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("session.linearIssuePicker.loading.issues")]}):null,Ve?s.jsxs("div",{className:"text-center text-muted-foreground py-8 space-y-3",children:[s.jsx("div",{children:t("session.linearIssuePicker.empty.notConnected")}),s.jsx("div",{className:"flex justify-center",children:s.jsx(he,{variant:"outline",size:"sm",onClick:lt,children:t("session.linearIssuePicker.actions.openSettings")})})]}):null,Te?s.jsx("div",{className:"text-center text-muted-foreground py-8 break-words",children:Te}):null,de&&n&&O?s.jsxs("div",{className:"group flex items-center gap-2 py-1.5 px-1 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer",onClick:()=>E(de),children:[s.jsx("span",{className:"typography-meta text-muted-foreground w-16 text-right flex-shrink-0",children:de}),s.jsx("p",{className:"flex-1 min-w-0 typography-small text-foreground truncate ml-0.5",children:t("session.linearIssuePicker.actions.useIssue",{identifier:de})})]}):null,I.length===0&&!ae&&O&&n?s.jsx("div",{className:"text-center text-muted-foreground py-8",children:Ie.trim()?t("session.linearIssuePicker.empty.noIssuesFound"):t(Be?"session.linearIssuePicker.empty.noOpenIssuesFound":"contextPanel.linear.empty.noMatchingIssues")}):null,I.map(ht),ye&&O&&n?s.jsx("div",{className:"py-2 flex justify-center",children:s.jsx("button",{type:"button",onClick:()=>{it()},disabled:$,className:K("typography-meta text-muted-foreground hover:text-foreground transition-colors underline underline-offset-4",$&&"opacity-50 cursor-not-allowed hover:text-muted-foreground"),children:$?s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("session.linearIssuePicker.loading.more")]}):t("session.linearIssuePicker.actions.loadMore")})}):null]})]})};function Yt(t){return s.jsx("span",{className:"inline-flex h-5 max-w-[8rem] items-center truncate rounded-md px-1.5 typography-meta text-muted-foreground",style:Wt(t.color),children:t.name},t.id)}function Zt(t){return s.jsx(Rt,{value:t.value,children:t.label},t.value)}export{Nn as LinearIssuesView};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{R as C,f as ae,j as re}from"./vendor-react-BUCujlKS.js";import{m as zt}from"./vendor-morphdom-B7dS_VPB.js";import{r as Ht,a as Vt}from"./vendor-beautiful-mermaid-DztCUpLZ.js";import{fP as at,fQ as Kt,fR as jt,fS as Ut,g as we,bj as Zt,bm as Xt,fT as Gt,fU as Yt,Y as lt,ae as ct,fV as dt,f as ut,h as mt,em as Qt,en as We,fW as Jt,fX as qe,fY as en,fZ as tn,f_ as nn,f$ as rn,g0 as on,o as sn}from"./useAppFontEffects-DeStGcUT.js";import{h as an,K as pt,O as oe,cG as ln,u as Y,a as cn,aX as dn,D as un,E as mn}from"./index-BfwRClDe.js";import{getCachedMarkdownBlocks as Be,renderMarkdownSync as pn,renderMarkdownBlocks as fn}from"./markdownCore-DsmQr3bt.js";import{r as hn}from"./registerCustomTheme-BBXUCRnG.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-elkjs-BRwcR927.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-BY_5qla_.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DWA1bm1F.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-zod-B6551dwG.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-marked-CX41MkDF.js";import"./vendor-marked-linkify-it-CXI_LHIE.js";import"./vendor-linkify-it-DZCzzDkK.js";import"./vendor-uc.micro-BAd0H0z4.js";import"./vendor-remend-BWYYytN3.js";import"./vendor-katex-k3Ppq1Ha.js";import"./vendor-dompurify-r8glNMJW.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";const ft=t=>{const e=t.target;if(!(e instanceof Element))return null;const n=e.closest("a[href]");return!(n instanceof HTMLAnchorElement)||n.getAttribute("data-openchamber-file-link")==="true"?null:n},Me=(t,e)=>{if(t.defaultPrevented)return!1;const r=ft(t)?.getAttribute("href")??"";return Kt(r)?(t.preventDefault(),t.stopPropagation(),e?.(r),!0):!1},gn=t=>t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey,bn=(t,e)=>{const n=o=>{if(Me(o,e.openAppLink)||!e.allowExternalHttp||o.defaultPrevented||!gn(o))return;const s=ft(o)?.getAttribute("href")??"";at(s)&&(o.preventDefault(),o.stopPropagation(),e.openExternalHttp(s))},r=o=>{o.button===1&&Me(o,e.openAppLink)},i=o=>{Me(o)};return t.addEventListener("click",n),t.addEventListener("auxclick",r),t.addEventListener("dragstart",i),()=>{t.removeEventListener("click",n),t.removeEventListener("auxclick",r),t.removeEventListener("dragstart",i)}},ht="openchamber-md",wn={name:ht,colors:{"editor.background":"transparent","editor.foreground":"var(--md-syntax-foreground)"},tokenColors:[{scope:["comment","punctuation.definition.comment","string.comment"],settings:{foreground:"var(--md-syntax-comment)",fontStyle:"italic"}},{scope:["string","punctuation.definition.string","string.template"],settings:{foreground:"var(--md-syntax-string)"}},{scope:["constant.numeric","constant.language","constant.character","constant"],settings:{foreground:"var(--md-syntax-number)"}},{scope:["keyword","storage","storage.type","storage.modifier","keyword.control"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["keyword.operator","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--md-syntax-operator)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--md-syntax-function)"}},{scope:["entity.name.type","entity.name.class","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--md-syntax-type)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--md-syntax-variable)"}},{scope:["variable.other.property","meta.property-name","support.type.property-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["entity.name.tag","punctuation.definition.tag"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["entity.other.attribute-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["markup.bold","punctuation.definition.bold"],settings:{fontStyle:"bold"}},{scope:["markup.italic","punctuation.definition.italic"],settings:{fontStyle:"italic"}},{scope:["markup.heading","markup.heading entity.name"],settings:{foreground:"var(--md-syntax-keyword)",fontStyle:"bold"}},{scope:["markup.inserted","punctuation.definition.inserted"],settings:{foreground:"var(--md-syntax-inserted)"}},{scope:["markup.deleted","punctuation.definition.deleted"],settings:{foreground:"var(--md-syntax-deleted)"}},{scope:["invalid","invalid.illegal"],settings:{foreground:"var(--md-syntax-deleted)"}}]};let $e=!1;const yn=()=>{$e||($e=!0,hn(ht,()=>Promise.resolve(wn)))},T=t=>Number.isFinite(t)&&t>0,ze=t=>{if(t==null)return null;const e=String(t).trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!e)return null;const n=Number(e[1]);return T(n)?n:null},Ne=(t,e,n)=>Math.min(n,Math.max(e,t)),An=6,He=1.25,vn=1.0015,kn=.5,Cn=12,Ve=3,En=400,ie='[data-markdown="mermaid-block"]',F=t=>t.querySelector(ie)!==null,Sn=t=>[t.x,t.y,t.width,t.height].map(e=>{const n=Number(e.toFixed(An));return Object.is(n,-0)?"0":String(n)}).join(" "),Ln=t=>{const e=t.viewBox?.trim().split(/[\s,]+/).map(i=>Number.parseFloat(i));if(e?.length===4){const[i,o,s,a]=e;if(Number.isFinite(i)&&Number.isFinite(o)&&T(s)&&T(a))return{x:i,y:o,width:s,height:a}}const n=ze(t.width),r=ze(t.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},Mn=t=>{let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(36)},Nn=t=>{const e=t.renderMode||"unknown",n=t.svgMarkup??"";if(!n){const r=[t.viewBox??"",t.width??"",t.height??""];return r.some(i=>i!=="")?`${e}:bounds:${r.join(":")}`:`${e}:no-svg`}return[e,Mn(n)].join(":")},gt=(t,e)=>{if(!T(e.width)||!T(e.height))return t;const n=t.width/t.height,r=e.width/e.height;if(n>r){const o=t.width/r;return{x:t.x,y:t.y-(o-t.height)/2,width:t.width,height:o}}const i=t.height*r;return{x:t.x-(i-t.width)/2,y:t.y,width:i,height:t.height}},Rn=({currentBox:t,viewport:e,delta:n})=>!T(e.width)||!T(e.height)||!T(t.width)||!T(t.height)?t:{x:t.x-n.x/e.width*t.width,y:t.y-n.y/e.height*t.height,width:t.width,height:t.height},Tn=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return n*n+r*r>Ve*Ve},xn=({currentBox:t,contentBox:e,viewport:n,pointer:r,zoomFactor:i,minScale:o,maxScale:s})=>{if(!T(n.width)||!T(n.height)||!T(i)||!T(t.width)||!T(t.height)||!T(e.width)||!T(e.height)||!T(o)||!T(s))return t;const a=Math.min(o,s),l=Math.max(o,s),c=gt(e,n),u=c.width/t.width,f=Ne(u*i,a,l),m=c.width/f,g=m/(t.width/t.height),y=Ne(r.x/n.width,0,1),v=Ne(r.y/n.height,0,1),S=t.x+y*t.width,p=t.y+v*t.height;return{x:S-y*m,y:p-v*g,width:m,height:g}},ye=new WeakMap,Ie=new WeakMap,j=new Set,se=new Set;let K=null,ne=null,J=null;const _n=t=>t.querySelector('[data-markdown="mermaid-viewport"]')??t.querySelector('[data-markdown="mermaid"]'),bt=t=>{const e=t.querySelector('[data-markdown="mermaid"] svg'),n=t.querySelector('[data-markdown="mermaid"]');return Nn({renderMode:t.getAttribute("data-mermaid-render"),svgMarkup:n?.getAttribute("data-md-original-svg")??e?.outerHTML??null,viewBox:e?.getAttribute("viewBox"),width:e?.getAttribute("width"),height:e?.getAttribute("height")})},G=t=>{const e=t.getBoundingClientRect();return{width:e.width,height:e.height}},Pn=(t,e)=>{const n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},In=t=>t instanceof Element&&!!t.closest('button, a, [role="button"]'),wt=t=>{const e=t.map(n=>G(n.viewport));t.forEach((n,r)=>{const i=e[r];i&&n.fitToViewport(i)})},yt=()=>{J!==null||j.size===0||(J=window.requestAnimationFrame(()=>{J=null,wt(Array.from(j))}))},Fn=()=>{if(K)return K;const t=globalThis.ResizeObserver;return t?(K=new t(e=>{for(const n of e)n.target instanceof HTMLElement&&Ie.get(n.target)?.fitToViewport({width:n.contentRect.width,height:n.contentRect.height})}),K):null},Dn=t=>{if(j.has(t))return;const e=j.size===0;j.add(t),Ie.set(t.viewport,t),Fn()?.observe(t.viewport),e&&window.addEventListener("resize",yt)},On=t=>{j.delete(t)&&(K?.unobserve(t.viewport),Ie.delete(t.viewport),!(j.size>0)&&(K?.disconnect(),K=null,window.removeEventListener("resize",yt),J!==null&&(window.cancelAnimationFrame(J),J=null)))},Wn=t=>{const e=_n(t),n=t.querySelector('[data-markdown="mermaid"] svg');if(!e||!n)return null;const r=Ln({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let i=r,o=null,s=null,a=null,l=null;const c=d=>{i=d,n.setAttribute("viewBox",Sn(d)),n.removeAttribute("width"),n.removeAttribute("height")},u=d=>{c(gt(r,d))},f=()=>{u(G(e))},m=(d,b)=>{c(xn({currentBox:i,contentBox:r,viewport:G(e),pointer:d,zoomFactor:b,minScale:kn,maxScale:Cn}))},g=()=>{const d=G(e);m({x:d.width/2,y:d.height/2},He)},y=()=>{const d=G(e);m({x:d.width/2,y:d.height/2},1/He)},v=d=>{!d.ctrlKey&&!d.metaKey||(d.preventDefault(),d.stopPropagation(),m(Pn(d,e),Math.pow(vn,-d.deltaY)))},S=d=>{d.button!==0||In(d.target)||(o=d.pointerId,s={x:d.clientX,y:d.clientY},a=s,l!==null&&(window.clearTimeout(l),l=null),t.removeAttribute("data-mermaid-suppress-click"),e.setPointerCapture?.(d.pointerId),t.setAttribute("data-mermaid-panning","true"),d.preventDefault())},p=d=>{if(o!==d.pointerId||!a)return;const b={x:d.clientX,y:d.clientY};c(Rn({currentBox:i,viewport:G(e),delta:{x:b.x-a.x,y:b.y-a.y}})),a=b,s&&Tn(s,b)&&t.setAttribute("data-mermaid-suppress-click","true"),d.preventDefault()},h=d=>{o===d.pointerId&&(e.releasePointerCapture?.(d.pointerId),o=null,s=null,a=null,t.removeAttribute("data-mermaid-panning"),t.hasAttribute("data-mermaid-suppress-click")&&(l=window.setTimeout(()=>{t.removeAttribute("data-mermaid-suppress-click"),l=null},En)))};e.addEventListener("wheel",v,{passive:!1}),e.addEventListener("pointerdown",S),e.addEventListener("pointermove",p),e.addEventListener("pointerup",h),e.addEventListener("pointercancel",h);const k={viewport:e,zoomIn:g,zoomOut:y,fit:f,fitToViewport:u,cleanup:()=>{On(k),e.removeEventListener("wheel",v),e.removeEventListener("pointerdown",S),e.removeEventListener("pointermove",p),e.removeEventListener("pointerup",h),e.removeEventListener("pointercancel",h),l!==null&&window.clearTimeout(l),t.removeAttribute("data-mermaid-panning"),t.removeAttribute("data-mermaid-suppress-click"),ye.delete(t)}};return k},At=t=>{for(const[e,n]of t.controllers){const r=bt(e);(!t.container.contains(e)||r!==t.signatures.get(e))&&(n.cleanup(),t.controllers.delete(e),t.signatures.delete(e))}},qn=t=>{if(t.disposed)return[];const e=[];for(const n of Array.from(t.container.querySelectorAll(ie))){if(t.controllers.has(n)||n.querySelector('[data-markdown="mermaid"] svg')===null)continue;const r=Wn(n);r&&(t.controllers.set(n,r),t.signatures.set(n,bt(n)),ye.set(n,r),e.push(r))}return e},vt=()=>{const t=Array.from(se);se.clear();const e=[];for(const n of t)n.disposed||(At(n),e.push(...qn(n)));wt(e);for(const n of e)Dn(n)},Bn=()=>{ne===null&&(ne=window.requestAnimationFrame(()=>{ne=null,ne=window.requestAnimationFrame(()=>{ne=null,vt()})}))},$n=t=>{t.disposed||(At(t),se.add(t),Bn())},zn=t=>{if(!(t instanceof HTMLElement))return null;const e=ye.get(t);if(e)return e;for(const n of se)if(n.container.contains(t))return vt(),ye.get(t)??null;return null},Hn=t=>{const e={container:t,controllers:new Map,signatures:new Map,disposed:!1},n=()=>$n(e),r=()=>{e.disposed=!0,se.delete(e);for(const i of e.controllers.values())i.cleanup();e.controllers.clear(),e.signatures.clear()};return n(),{refresh:n,cleanup:r}},Vn={copy:"file-copy",check:"check",download:"download",zoomIn:"add",zoomOut:"subtract",fit:"refresh",textWrap:"text-wrap",image:"file-image",disclosure:"arrow-right-s"},kt="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]",ee=(t,e)=>{const n=Vn[e],r=t.ownerDocument.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","remixicon size-3.5"),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("aria-hidden","true");const i=t.ownerDocument.createElementNS("http://www.w3.org/2000/svg","use");i.setAttribute("href",`#oc-${n}`),r.appendChild(i),t.replaceChildren(r)},Kn=t=>{for(const e of Array.from(t.querySelectorAll('[data-openchamber-markdown-image-label="true"]'))){if(e.querySelector("[data-openchamber-markdown-image-label-icon]"))continue;const n=document.createElement("span");n.className="inline-flex shrink-0",n.setAttribute("aria-hidden","true"),n.setAttribute("data-openchamber-markdown-image-label-icon","true"),ee(n,"image"),e.prepend(n)}},jn=t=>{for(const e of t.querySelectorAll("details[data-md-details] > summary")){if(e.querySelector("[data-md-disclosure-icon]"))continue;const n=document.createElement("span");n.append(...Array.from(e.childNodes));const r=document.createElement("span");r.setAttribute("data-md-disclosure-icon",""),r.setAttribute("aria-hidden","true"),ee(r,"disclosure"),e.append(r,n)}},B=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className=kt,r.setAttribute("data-md-action",n),r.setAttribute("title",e),r.setAttribute("aria-label",e),ee(r,t),r},Ct=(t,e,n)=>{const r=t.querySelector("[data-md-code-body]"),i=t.querySelector("pre"),o=t.querySelector("pre code"),s=t.querySelectorAll("[data-md-code-line-content]"),a=t.querySelector('[data-md-action="toggle-code-wrap"]');t.setAttribute("data-code-wrap",e?"true":"false"),r?.classList.toggle("overflow-x-auto",!e),r?.classList.toggle("overflow-x-hidden",e),i?.classList.toggle("whitespace-pre-wrap",e),i?.classList.toggle("break-words",e),o?.classList.toggle("whitespace-pre-wrap",e),o?.classList.toggle("break-words",e),i&&(i.style.whiteSpace=e?"pre-wrap":"pre",i.style.overflowWrap=e?"anywhere":"normal"),o&&(o.style.whiteSpace=e?"pre-wrap":"pre",o.style.overflowWrap=e?"anywhere":"normal");for(const l of Array.from(s))l.style.whiteSpace=e?"pre-wrap":"pre",l.style.overflowWrap=e?"anywhere":"normal";if(a){const l=e?n.disableCodeWrap:n.enableCodeWrap;a.setAttribute("title",l),a.setAttribute("aria-label",l),a.classList.toggle("text-foreground",e),a.classList.toggle("opacity-100",e),a.classList.toggle("text-muted-foreground",!e),a.classList.toggle("opacity-65",!e),a.setAttribute("aria-pressed",e?"true":"false")}},Et=t=>{const e=t.querySelector(":scope > code");if(!e||e.hasAttribute("data-md-code-lines"))return;t.removeAttribute("data-md-gutter-reserved");const n=e.textContent??"",r=n.endsWith(`
|
|
2
|
-
`),i=r?n.slice(0,-1).split(`
|
|
3
|
-
`):n.split(`
|
|
4
|
-
`),o=i.length>0?i:[""],s=Array.from(e.children).filter(c=>c.classList.contains("line"));r&&s.length===o.length+1&&s.at(-1)?.textContent===""&&s.pop();const a=s.length===o.length,l=document.createDocumentFragment();o.forEach((c,u)=>{const f=document.createElement("span");f.setAttribute("data-md-code-line","");const m=document.createElement("span");m.setAttribute("data-md-code-line-number",String(u+1)),m.setAttribute("aria-hidden","true");const g=document.createElement("span");if(g.setAttribute("data-md-code-line-content",""),a){const y=s[u];y&&g.append(...Array.from(y.childNodes))}else g.textContent=c;if(f.append(m,g),l.appendChild(f),u<o.length-1||r){const y=document.createElement("span");y.setAttribute("data-md-code-line-break",""),y.textContent=`
|
|
5
|
-
`,l.appendChild(y)}}),e.replaceChildren(l),e.setAttribute("data-md-code-lines",""),e.toggleAttribute("data-md-code-trailing-newline",r)},St=t=>{const e=Array.from(t.querySelectorAll("[data-md-code-line-content]"));if(e.length===0)return t.textContent??"";const n=e.map(r=>r.textContent??"").join(`
|
|
6
|
-
`);return t.hasAttribute("data-md-code-trailing-newline")?`${n}
|
|
7
|
-
`:n},Ke=(t,e,n)=>{const r=t.querySelectorAll('[data-component="markdown-code"]');for(const i of Array.from(r)){const o=i.querySelector("pre");o&&Et(o),Ct(i,e,n)}},je=(t,e,n,r)=>{ee(t,"check"),t.setAttribute("title",e),t.setAttribute("aria-label",e),window.setTimeout(()=>{ee(t,n),t.setAttribute("title",r),t.setAttribute("aria-label",r)},2e3)},Un=t=>{const e=t.querySelectorAll(":not(pre) > code");for(const n of Array.from(e))n.getAttribute("data-markdown")!=="inline-code"&&n.setAttribute("data-markdown","inline-code")},Zn=(t,e)=>{const n=t.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const i=r.parentElement;if(!i||i.closest('[data-component="markdown-code"]'))continue;const o=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],s=r.getAttribute("data-md-lang")??o??"text",a=document.createElement("div");a.setAttribute("data-component","markdown-code"),a.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const l=document.createElement("div");l.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const c=document.createElement("span");c.className="font-mono text-[13px] text-muted-foreground",c.textContent=s;const u=B("copy",e.labels.copy,"copy-code"),f=B("textWrap",e.codeBlockLineWrap?e.labels.disableCodeWrap:e.labels.enableCodeWrap,"toggle-code-wrap");l.appendChild(c);const m=document.createElement("div");m.className="flex items-center gap-1",m.setAttribute("data-md-code-actions",""),m.appendChild(f),m.appendChild(u),l.appendChild(m);const g=document.createElement("div");g.setAttribute("data-md-code-body",""),g.className="px-3 py-2.5 overflow-x-auto",i.replaceChild(a,r),r.style.margin="0",r.style.background="transparent",r.classList.add("min-w-0","w-full","flex-1"),e.deferCodeLineNumberSync?r.setAttribute("data-md-gutter-reserved",""):Et(r),g.appendChild(r),a.appendChild(l),a.appendChild(g),Ct(a,e.codeBlockLineWrap,e.labels)}},Ue=t=>{const e=[],n=[],r=t.querySelectorAll("thead th");for(const o of Array.from(r))e.push((o.textContent??"").trim());const i=t.querySelectorAll("tbody tr");for(const o of Array.from(i)){const s=Array.from(o.querySelectorAll("td")).map(a=>(a.textContent??"").trim());s.length>0&&n.push(s)}return{headers:e,rows:n}},Xn=t=>/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t,Ze=({headers:t,rows:e})=>[t,...e].map(n=>n.map(Xn).join(",")).join(`
|
|
8
|
-
`),Gn=({headers:t,rows:e})=>[t,...e].map(n=>n.join(" ")).join(`
|
|
9
|
-
`),Xe=({headers:t,rows:e})=>{const n=`| ${t.join(" | ")} |`,r=`| ${t.map(()=>"---").join(" | ")} |`,i=e.map(o=>`| ${o.join(" | ")} |`).join(`
|
|
10
|
-
`);return`${n}
|
|
11
|
-
${r}
|
|
12
|
-
${i}`},Ge=(t,e)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${Zt}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",t);for(const r of e){const i=document.createElement("button");i.type="button",i.className=`w-full text-left ${Xt}`,i.setAttribute("data-md-action",`${t}-${r.key}`),i.textContent=r.label,n.appendChild(i)}return n},Yn=120,Qn=320,Pe="data-md-table-layout",Jn=(t,e)=>{const n=t.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex w-fit max-w-full flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const s=document.createElement("div");s.className="flex items-center justify-end gap-1";const a=document.createElement("div");a.className="relative",a.appendChild(B("copy",e.copyTable,"table-copy-toggle")),a.appendChild(Ge("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const l=document.createElement("div");l.className="relative",l.appendChild(B("download",e.downloadTable,"table-download-toggle")),l.appendChild(Ge("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),s.appendChild(a),s.appendChild(l);const c=document.createElement("div");c.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const u=r.parentElement;if(!u)continue;u.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.setAttribute(Pe,"pending"),r.classList.add("w-max","border-collapse","text-sm");for(const m of Array.from(r.querySelectorAll("tr")))m.classList.add("border-b","border-border/60");const f=r.querySelector("tbody tr:last-child");f?.classList.remove("border-b"),f?.classList.add("border-0");for(const m of Array.from(r.querySelectorAll("th")))m.classList.add("min-w-[120px]","max-w-[320px]","whitespace-normal","[overflow-wrap:anywhere]","border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const m of Array.from(r.querySelectorAll("td")))m.classList.add("min-w-[120px]","max-w-[320px]","whitespace-normal","[overflow-wrap:anywhere]","border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");c.appendChild(r),o.appendChild(s),o.appendChild(c)}},er=t=>{const e=Array.from(t.querySelectorAll(`table[data-markdown="table"]:not([${Pe}="fixed"])`));if(e.length===0||!t.isConnected)return;const n=t.ownerDocument.createElement("div");n.setAttribute("aria-hidden","true"),n.setAttribute("data-md-table-measure",""),n.style.position="fixed",n.style.left="-100000px",n.style.top="0",n.style.visibility="hidden",n.style.pointerEvents="none",n.style.width="max-content";const r=e.map(o=>{const s=f=>Array.from(f.children).filter(m=>m.tagName==="TH"||m.tagName==="TD"),a=Array.from(o.querySelectorAll("tbody tr")),l=a.some(f=>s(f).length>0)?a:Array.from(o.querySelectorAll("thead tr")),c=Math.max(0,...Array.from(o.querySelectorAll("tr")).map(f=>s(f).length)),u=[];for(let f=0;f<c;f+=1){const m=t.ownerDocument.createElement("table");m.className=o.className,m.style.tableLayout="auto",m.style.width="max-content";const g=t.ownerDocument.createElement("tbody");for(const y of l){const v=s(y)[f];if(!v)continue;const S=t.ownerDocument.createElement("tr"),p=v.cloneNode(!0);p instanceof HTMLElement&&(p.style.width="auto",p.style.minWidth="0",p.style.maxWidth="none",p.style.whiteSpace="nowrap",p.style.overflowWrap="normal",S.appendChild(p),g.appendChild(S))}m.appendChild(g),n.appendChild(m),u.push(m)}return{table:o,columnProbes:u}});t.appendChild(n);const i=r.map(({table:o,columnProbes:s})=>({table:o,widths:s.map(a=>Math.min(Qn,Math.max(Yn,Math.ceil(a.getBoundingClientRect().width))))}));n.remove();for(const{table:o,widths:s}of i){Array.from(o.children).find(u=>u.matches("colgroup[data-md-table-columns]"))?.remove();const l=t.ownerDocument.createElement("colgroup");l.setAttribute("data-md-table-columns","");for(const u of s){const f=t.ownerDocument.createElement("col");f.style.width=`${u}px`,l.appendChild(f)}const c=Array.from(o.children).find(u=>u.tagName==="THEAD"||u.tagName==="TBODY"||u.tagName==="TFOOT")??null;o.insertBefore(l,c),o.style.tableLayout="fixed",o.style.width=`${s.reduce((u,f)=>u+f,0)}px`,o.setAttribute(Pe,"fixed")}},tr=(t,e)=>{const n=t.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const i=r.parentElement;if(!i)continue;const o=(r.textContent??"").replace(/\s+$/,""),s=e.renderMermaid(o),a=document.createElement("div");a.setAttribute("data-markdown","mermaid-block"),a.setAttribute("data-md-source",o),a.className="group relative";const l=document.createElement("div");l.setAttribute("data-markdown","mermaid-scroll");const c=document.createElement("div");if(c.setAttribute("data-markdown","mermaid-toolbar"),c.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",s.svg){a.setAttribute("data-mermaid-render","svg");const f=document.createElement("div");f.setAttribute("data-markdown","mermaid-viewport");const m=document.createElement("div");if(m.setAttribute("data-markdown","mermaid"),m.setAttribute("data-md-original-svg",s.svg),m.innerHTML=s.svg,f.appendChild(m),l.appendChild(f),e.mermaidControls.showPanZoomControls&&(c.appendChild(B("zoomIn",e.labels.zoomInDiagram,"mermaid-zoom-in")),c.appendChild(B("zoomOut",e.labels.zoomOutDiagram,"mermaid-zoom-out")),c.appendChild(B("fit",e.labels.resetDiagramView,"mermaid-fit"))),e.mermaidControls.copy){const g=B("copy",e.labels.copyDiagram,"mermaid-copy");g.setAttribute("data-md-source",o),c.appendChild(g)}if(e.mermaidControls.download){const g=B("download",e.labels.downloadDiagram,"mermaid-download");g.setAttribute("data-md-svg","1"),c.appendChild(g)}}else{a.setAttribute("data-mermaid-render","ascii");const f=document.createElement("pre");if(f.setAttribute("data-markdown","mermaid-ascii"),f.textContent=s.ascii||o,l.appendChild(f),e.mermaidControls.copy){const m=B("copy",e.labels.copyDiagram,"mermaid-copy");m.setAttribute("data-md-source",s.ascii||o),c.appendChild(m)}}a.appendChild(l),a.appendChild(c);const u=i.parentElement;u&&u.replaceChild(a,i)}},nr=(t,e)=>{const n=t.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-openchamber-file-link")==="true")continue;const i=r.getAttribute("href")??"";if(!at(i))continue;r.setAttribute("data-md-link-decorated","true");const o=jt(i);if(o){const s=document.createElement("span");s.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const a=document.createElement("img");a.src=o,a.alt="",a.setAttribute("aria-hidden","true"),a.loading="lazy",a.decoding="async",a.className="size-3.5 rounded-sm",a.addEventListener("error",()=>s.remove(),{once:!0}),s.appendChild(a),r.parentNode?.insertBefore(s,r)}if(e.onPreviewLoopback&&Ut(i)){const s=document.createElement("button");s.type="button",s.className=`ml-1 align-middle ${kt}`,s.setAttribute("data-md-action","preview-loopback"),s.setAttribute("data-md-url",i),s.setAttribute("title",e.labels.previewTitle),s.setAttribute("aria-label",e.labels.previewLabel),ee(s,"download"),r.parentNode?.insertBefore(s,r.nextSibling)}}},pe=(t,e)=>{jn(t),Kn(t),Un(t),tr(t,e),Zn(t,e),Jn(t,e.labels),nr(t,e)},Ye=(t,e,n)=>{const r=new Blob([e],{type:n}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)},fe=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},Qe=t=>(t.nodeType===1?t:t.parentElement)?.closest("pre code[data-md-code-lines]")??null,rr=t=>{const e=Qe(t.startContainer);return!e||e!==Qe(t.endContainer)?null:t.toString()},he=new WeakMap,or=t=>{let e=he.get(t);if(!e){const n=()=>{const o=t.getSelection();return!o||o.rangeCount!==1||o.isCollapsed?null:rr(o.getRangeAt(0))},r=o=>{if(!o.clipboardData)return;const s=n();s!==null&&(o.preventDefault(),o.stopPropagation(),o.clipboardData.setData("text/plain",s))},i=o=>{const s=n();s!==null&&(o.preventDefault(),we(s))};e={registrations:0,handler:r,menuHandler:i},he.set(t,e),t.addEventListener("copy",r,!0),t.defaultView?.addEventListener("openchamber:copy",i)}return e.registrations+=1,()=>{const n=he.get(t);n&&(n.registrations-=1,!(n.registrations>0)&&(t.removeEventListener("copy",n.handler,!0),t.defaultView?.removeEventListener("openchamber:copy",n.menuHandler),he.delete(t)))}},ir=(t,e)=>{const n=or(t.ownerDocument),r=i=>{const o=i.target;if(!(o instanceof Element))return;const s=o.closest("[data-md-action]");if(!s){fe(t);return}const a=s.getAttribute("data-md-action")??"";if(a==="copy-code"){const l=s.closest('[data-component="markdown-code"]')?.querySelector("code"),c=l?St(l):"";c&&(s.setAttribute("data-md-copy-pending",""),we(c).then(()=>je(s,e.labels.copied,"copy",e.labels.copy)).finally(()=>s.removeAttribute("data-md-copy-pending")));return}if(a==="toggle-code-wrap"){i.preventDefault(),e.onToggleCodeBlockLineWrap?.();return}if(a==="table-copy-toggle"||a==="table-download-toggle"){i.preventDefault();const l=s.parentElement?.querySelector("[data-md-menu]")??null,c=l?.classList.contains("hidden")??!1;fe(t),l&&c&&l.classList.remove("hidden");return}if(a.startsWith("table-copy-")){const l=a.replace("table-copy-",""),c=s.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const u=Ue(c),f=l==="csv"?Ze(u):l==="tsv"?Gn(u):Xe(u);we(f)}fe(t);return}if(a.startsWith("table-download-")){const l=a.replace("table-download-",""),c=s.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const u=Ue(c),f=l==="csv"?Ze(u):Xe(u);Ye(l==="csv"?"table.csv":"table.md",f,l==="csv"?"text/csv":"text/markdown")}fe(t);return}if(a==="mermaid-copy"){const l=s.getAttribute("data-md-source")??"";l&&we(l).then(()=>je(s,e.labels.copied,"copy",e.labels.copyDiagram));return}if(a==="mermaid-zoom-in"||a==="mermaid-zoom-out"||a==="mermaid-fit"){i.preventDefault();const l=s.closest('[data-markdown="mermaid-block"]'),c=zn(l);a==="mermaid-zoom-in"?c?.zoomIn():a==="mermaid-zoom-out"?c?.zoomOut():c?.fit();return}if(a==="mermaid-download"){const l=s.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),c=l?.getAttribute("data-md-original-svg")??l?.innerHTML??"";c&&Ye("diagram.svg",c,"image/svg+xml;charset=utf-8");return}if(a==="preview-loopback"){i.preventDefault();const l=s.getAttribute("data-md-url")??"";l&&e.onPreviewLoopback?.(l);return}};return t.addEventListener("click",r),()=>{n(),t.removeEventListener("click",r)}},Je=(t,e,n)=>{let r=0;for(const o of t){const s=r+o.data.length;if(e<s||e===s&&n==="left")return{node:o,offset:Math.max(0,e-r)};r=s}const i=t.at(-1);return i?{node:i,offset:i.data.length}:null},sr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),et=Array.from(sr).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Lt=t=>Gt(t),ar=t=>Yt(t),lr=t=>{let e;try{e=new URL(t.trim())}catch{return null}if(e.protocol!=="file:"||e.hostname&&e.hostname!=="localhost")return null;try{const n=decodeURIComponent(e.pathname);return/^\/[A-Za-z]:\//.test(n)?n.slice(1):n.startsWith("/")?n:null}catch{return null}},Ae=t=>{let e=(t||"").trim();return e?((e.startsWith("`")&&e.endsWith("`")||e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e=e.replace(/[.,;!?]+$/g,""),e.endsWith(")")&&!e.includes("(")&&(e=e.slice(0,-1)),e.endsWith("]")&&!e.includes("[")&&(e=e.slice(0,-1)),e):""},ge=t=>{let e=Ae(t);if(!e)return"";const n=e.indexOf(";");n>=0&&(e=e.slice(0,n)),e=e.replace(/#.*$/,"");const r=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(e=r[1]??e);const i=et.length>0?e.match(new RegExp(`^(.*(?:/|^)(${et})):.*$`,"i")):null;return i&&(e=i[1]??e),Ae(e)},Mt=t=>{const e=Ae(t);if(!e)return null;const n=e.indexOf(";"),r=n>=0?Ae(e.slice(0,n)):e;if(!r)return null;const i=r.match(/^(.*?):(\d+)-(\d+)$/);if(i){const l=ge(i[1]??""),c=Number.parseInt(i[2]??"",10),u=Number.parseInt(i[3]??"",10);return!l||!Number.isFinite(c)||!Number.isFinite(u)||u<c?null:{path:l,line:c,endLine:u}}const o=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const l=ge(o[1]??""),c=Number.parseInt(o[2]??"",10),u=o[3]?Number.parseInt(o[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(u??Number.NaN)?u:void 0}}const s=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(s){const l=ge(s[1]??""),c=Number.parseInt(s[2]??"",10),u=s[3]?Number.parseInt(s[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(u??Number.NaN)?u:void 0}}const a=ge(r);return a?{path:a}:null},Re=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,cr=4,dr=1e3,ur=200,z=new Map;let be=0;const tt=[],mr=()=>pt()?ur:dr,pr=(t,e)=>`${t}\0${e}`,fr=(t,e)=>{const n=Lt(t);if(!n)return Promise.resolve(!1);const r=pr(e,n),i=z.get(r);if(i)return z.delete(r),z.set(r,i),i;const o=new Promise(a=>{const l=()=>{be+=1,an(`/api/fs/stat?path=${encodeURIComponent(n)}&optional=true`,{method:"GET",cache:"no-store",headers:e?{"x-opencode-directory":e}:void 0}).then(async c=>{if(!c.ok){a(!1);return}const u=await c.json().catch(()=>null);a(u?.exists!==!1)}).catch(()=>a(!1)).finally(()=>{be=Math.max(0,be-1),tt.shift()?.()})};if(be<cr){l();return}tt.push(l)}),s=mr();for(;z.size>=s;){const a=z.keys().next().value;if(typeof a!="string")break;z.delete(a)}return z.set(r,o),o},hr={maxSessions:8,maxEntriesPerSession:4};class gr{maxSessions;maxEntriesPerSession;sessions=new Map;constructor(e=hr){this.maxSessions=Math.max(1,e.maxSessions),this.maxEntriesPerSession=Math.max(1,e.maxEntriesPerSession)}store(e){const n=e.scope,r=e.id;let i=this.sessions.get(n);for(i===void 0?(i=new Map,this.sessions.set(n,i)):this.refreshSession(n,i),i.delete(r),i.set(r,e);i.size>this.maxEntriesPerSession;)this.removeOldestEntry(i);for(;this.sessions.size>this.maxSessions;)this.removeOldestSession()}take(e){const n=e.scope,r=this.sessions.get(n);if(!r)return null;const i=e.id;this.refreshSession(n,r);const o=r.get(i);return o===void 0||o.locale!==e.locale||o.directory!==e.directory?null:(r.delete(i),r.size===0&&this.sessions.delete(n),o.fragment)}clear(){this.sessions.clear()}stats(){let e=0;for(const n of this.sessions.values())e+=n.size;return{sessions:this.sessions.size,entries:e}}refreshSession(e,n){this.sessions.delete(e),this.sessions.set(e,n)}removeOldestEntry(e){const n=e.keys().next().value;n!==void 0&&e.delete(n)}removeOldestSession(){const e=this.sessions.keys().next().value;e!==void 0&&this.sessions.delete(e)}}const nt=new gr,Nt=()=>{const t=ae.c(4),e=Qt();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=We(!1),t[0]=n):n=t[0];const r=n;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=We(!0),t[1]=i):i=t[1];const o=i;let s;return t[2]!==e?.currentTheme?(s=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:r),t[2]=e?.currentTheme,t[3]=s):s=t[3],s},Rt=t=>{const e=ae.c(4),{containerRef:n,enabled:r}=t;let i,o;e[0]!==n||e[1]!==r?(i=()=>{const s=n.current;if(s)return bn(s,{allowExternalHttp:r!==!1,openAppLink:Dr,openExternalHttp:Or})},o=[n,r],e[0]=n,e[1]=r,e[2]=i,e[3]=o):(i=e[2],o=e[3]),C.useEffect(i,o)},te={download:!0,copy:!0,showPanZoomControls:!0},Tt=!0,br=t=>{const e=t.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return e?t.slice(e[0].length):t},rt='[data-openchamber-file-link="true"]',xt="data-openchamber-block-path-token",_t=`[${xt}]`,Q="data-openchamber-block-paths-scanned",wr=2e5,yr=80,Ar=40,ot=160,vr=()=>pt()?Ar:yr,kr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Pt=t=>Lt(t),Cr=t=>ar(t),Er=(t,e)=>nn(t,e),Sr=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},It=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=Pt(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return kr.has(r)||r.startsWith(".")&&r.length>1?!0:Sr(e)},Ft=t=>{const e=Mt(t);return e?It(e.path):!1},Lr=t=>{const e=t.querySelectorAll(_t);for(const r of Array.from(e))r.replaceWith(t.ownerDocument.createTextNode(r.textContent??""));const n=t.querySelectorAll(`code[${Q}]`);for(const r of Array.from(n))r.removeAttribute(Q),r.normalize()},Te=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim(),n=e?lr(e):null;if(n)return n;if(e&&Ft(e))return e}return(t.textContent||"").trim()},Mr=t=>{const e=t.querySelectorAll("pre code");if(e.length===0)return;const n=t.ownerDocument;if(n)for(const r of Array.from(e)){if(r.getAttribute(Q)==="true")continue;if((r.textContent??"").length>wr){r.setAttribute(Q,"true");continue}const i=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let s=i.nextNode();for(;s;){const u=s;u.parentElement?.closest("[data-md-code-line-number]")||o.push(u),s=i.nextNode()}const a=St(r);if(!a.includes(".")){r.setAttribute(Q,"true");continue}Re.lastIndex=0;const l=[];let c=Re.exec(a);for(;c;){const u=c[0];u&&Ft(u)&&l.push({start:c.index,end:c.index+u.length,raw:u}),c=Re.exec(a)}for(const{start:u,end:f,raw:m}of l.reverse()){const g=Je(o,u,"right"),y=Je(o,f,"left");if(!g||!y)continue;const v=n.createRange();v.setStart(g.node,g.offset),v.setEnd(y.node,y.offset);const S=n.createElement("span");S.setAttribute(xt,"true"),S.textContent=m,v.deleteContents(),v.insertNode(S)}r.setAttribute(Q,"true")}},xe=(t,e)=>{const n=Mt(t);if(!n||!It(n.path))return null;const r=Cr(n.path)?Pt(n.path):Er(e,n.path);return r?{...n,resolvedPath:r}:null},Nr=(t,e)=>t||tn(t,e),Dt=({containerRef:t,effectiveDirectory:e,editor:n,preferRuntimeEditor:r,enabled:i})=>{const o=C.useRef(null);C.useEffect(()=>{const s=t.current;if(!s||i&&!e)return;let a=!1;const l=vr(),c=i&&!dn(),u=d=>{d.removeAttribute("data-openchamber-file-link"),d.removeAttribute("data-openchamber-file-ref"),d.removeAttribute("data-openchamber-file-path"),d.getAttribute("title")==="Open file"&&d.removeAttribute("title"),d.tagName.toLowerCase()!=="a"&&(d.removeAttribute("role"),d.removeAttribute("tabindex"))},f=()=>{const d=s.querySelectorAll(rt);for(const b of Array.from(d))u(b);Lr(s)};if(!c){f();return}const m=(d=0)=>{if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){g();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{a||g()})},d)},g=()=>{h+=1;try{y()}finally{queueMicrotask(()=>{h-=1})}},y=()=>{c&&Mr(s);const d=s.querySelectorAll(`[data-markdown="inline-code"], a, ${_t}`);let b=0;for(const w of Array.from(d)){const A=Te(w),M=xe(A,e);if(u(w),!M||b>=l)continue;b+=1,(un()&&mn()&&!qe(M.resolvedPath,e)?Promise.resolve(!0):fr(M.resolvedPath,e)).then(_=>{if(a||!_||!s.contains(w))return;const L=Te(w),R=xe(L,e);!R||R.resolvedPath!==M.resolvedPath||(w.setAttribute("data-openchamber-file-link","true"),w.setAttribute("data-openchamber-file-ref",L),w.setAttribute("data-openchamber-file-path",R.resolvedPath),w.setAttribute("title","Open file"),w.tagName.toLowerCase()!=="a"&&(w.setAttribute("role","button"),w.setAttribute("tabindex","0")))})}},v=async d=>{const b=d.getAttribute("data-openchamber-file-ref")||Te(d),w=xe(b,e);if(!w)return;const A=Nr(e,w.resolvedPath);if(r&&n){n.openFile(w.resolvedPath,Number.isFinite(w.line??Number.NaN)?Math.max(1,Math.trunc(w.line)):void 0,Number.isFinite(w.column??Number.NaN)?Math.max(1,Math.trunc(w.column)):void 0);return}qe(w.resolvedPath,e)||await en(w.resolvedPath,e);const M=Y.getState();Number.isFinite(w.line??Number.NaN)?M.openContextFileAtLine(A,w.resolvedPath,Math.max(1,Math.trunc(w.line)),Number.isFinite(w.column??Number.NaN)?Math.max(1,Math.trunc(w.column)):1):M.openContextFile(A,w.resolvedPath)},S=d=>{const b=d.target;if(!(b instanceof Element))return;const w=b.closest(rt);w instanceof HTMLElement&&(d.preventDefault(),d.stopPropagation(),v(w))},p=d=>{if(d.key!=="Enter"&&d.key!==" ")return;const b=d.target;!(b instanceof HTMLElement)||b.getAttribute("data-openchamber-file-link")!=="true"||(d.preventDefault(),d.stopPropagation(),v(b))};m(ot);let h=0;const k=new MutationObserver(()=>{h>0||m(ot)});return k.observe(s,{childList:!0,subtree:!0}),s.addEventListener("click",S),s.addEventListener("keydown",p),()=>{a=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,k.disconnect(),s.removeEventListener("click",S),s.removeEventListener("keydown",p)}},[t,n,e,r,i])},Ot=t=>{const e=ae.c(7),{containerRef:n,onShowPopup:r,enableFullscreen:i,enablePanZoom:o,allowMermaidWheelEvents:s}=t;let a,l;e[0]!==s||e[1]!==n||e[2]!==i||e[3]!==o||e[4]!==r?(a=()=>{const c=n.current;if(!c)return;const u=m=>{if(!i||!r)return;const g=m.target;if(!(g instanceof Element)||g.closest('button, a, [role="button"]'))return;const y=g.closest(ie);if(!y)return;if(y instanceof HTMLElement&&y.hasAttribute("data-mermaid-suppress-click")){y.removeAttribute("data-mermaid-suppress-click");return}const S=Array.from(c.querySelectorAll(ie)).indexOf(y);if(S<0)return;const p=y instanceof HTMLElement?y.getAttribute("data-md-source"):null;if(!p||p.trim().length===0)return;const h=`Diagram ${S+1}`;r({open:!0,title:h,content:"",metadata:{tool:"mermaid-preview",filename:h},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(p)}`,source:p,filename:h}})},f=m=>{if(s||(m.ctrlKey||m.metaKey)&&o)return;const g=m.target;!(g instanceof Element)||!g.closest(ie)||m.stopPropagation()};return c.addEventListener("click",u),c.addEventListener("wheel",f,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",u),c.removeEventListener("wheel",f,!0)}},l=[s,n,i,o,r],e[0]=s,e[1]=n,e[2]=i,e[3]=o,e[4]=r,e[5]=a,e[6]=l):(a=e[5],l=e[6]),C.useEffect(a,l)},H=new Map,Rr=100,V="data-md-decoration-id",Tr=(t,e,n)=>{const r=t.children;if(r.length!==e.length)return!1;for(let i=0;i<e.length;i+=1){const o=r[i];if(!o||o.getAttribute("data-md-id")!==e[i]?.id||o.getAttribute(V)!==n)return!1}return!0},it=new WeakMap;let st=0;const xr=2e5,_e=t=>{const e=it.get(t);if(e)return e;const n=`decoration-${st}`;return st+=1,it.set(t,n),n},_r=(t,e)=>{const n=H.get(t);if(n)return H.delete(t),H.set(t,n),n;const r=e();if(H.set(t,r),H.size>Rr){const i=H.keys().next().value;i&&H.delete(i)}return r},Pr=t=>({bg:t.colors.surface.elevated,fg:t.colors.surface.foreground,line:t.colors.interactive.border,accent:t.colors.primary.base,muted:t.colors.surface.mutedForeground,surface:t.colors.surface.muted,border:t.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),Wt=(t,e,n,r=te)=>{const{t:i}=ut(),o=C.useMemo(()=>({copy:i("markdownRenderer.code.actions.copyTitle"),copied:i("markdownRenderer.code.actions.copiedTitle"),enableCodeWrap:i("markdownRenderer.code.actions.enableWrapTitle"),disableCodeWrap:i("markdownRenderer.code.actions.disableWrapTitle"),copyTable:i("markdownRenderer.table.actions.copyTitle"),downloadTable:i("markdownRenderer.table.actions.downloadTitle"),copyDiagram:i("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:i("markdownRenderer.mermaid.actions.downloadSvgTitle"),zoomInDiagram:i("markdownRenderer.mermaid.actions.zoomInTitle"),zoomOutDiagram:i("markdownRenderer.mermaid.actions.zoomOutTitle"),resetDiagramView:i("markdownRenderer.mermaid.actions.resetViewTitle"),previewLabel:i("terminalView.preview.open"),previewTitle:i("terminalView.preview.openTitle")}),[i]),s=Y(c=>c.codeBlockLineWrap),a=Y(c=>c.setCodeBlockLineWrap),l=C.useCallback(()=>{a(!Y.getState().codeBlockLineWrap)},[a]);return C.useMemo(()=>{const c=Pr(t),u=Y.getState().mermaidRenderingMode,f=t.metadata?.id??"theme";return{labels:o,mermaidControls:r,codeBlockLineWrap:s,deferCodeLineNumberSync:e,onToggleCodeBlockLineWrap:l,renderMermaid:g=>_r(`${f}:${u}:${g}`,()=>{try{return u==="ascii"?{ascii:Ht(g)}:{svg:Vt(g,c)}}catch{return{}}}),onPreviewLoopback:n}},[t,o,r,s,e,l,n])},qt=({containerRef:t,text:e,streaming:n,imageMode:r="inline",syntaxVars:i,ctx:o,domCacheKey:s,tableLayoutSettled:a})=>{C.useEffect(()=>{yn()},[]);const l=C.useRef(null),c=C.useRef(0),u=C.useRef(null),f=C.useContext(Jt),m=C.useRef(null),g=C.useCallback(()=>{m.current?.(),m.current=null},[]);C.useEffect(()=>g,[g]);const y=C.useRef(null),v=C.useCallback(()=>{const p=t.current;if(p){if(!l.current){if(!F(p))return;l.current=Hn(p);return}l.current.refresh()}},[t]),S=C.useCallback(()=>{if(!a)return;const p=u.current;p!==null&&window.cancelAnimationFrame(p);const h=c.current,k=window.requestAnimationFrame(()=>{if(u.current!==k||(u.current=null,c.current!==h))return;const d=t.current,b=d?.querySelector("[data-markdown-content]")??d;b&&er(b)});u.current=k},[t,a]);C.useEffect(()=>()=>{const p=u.current;p!==null&&(window.cancelAnimationFrame(p),u.current=null)},[]),C.useLayoutEffect(()=>{c.current+=1,y.current=null},[o,r,n,e]),C.useLayoutEffect(()=>{if(!s)return;const p=t.current,h=p?.querySelector("[data-markdown-content]")??p;if(!h||h.childNodes.length>0)return;const k=nt.take(s);if(k){h.appendChild(k);const d=_e(o);for(const b of Array.from(h.children))b.setAttribute(V,d);for(const[b,w]of Object.entries(i))h.style.setProperty(b,w);Ke(h,o.codeBlockLineWrap,o.labels),y.current={key:s,copiedLabel:o.labels.copied},oe("ui.markdown_renderer.dom_cache.hit")}},[t,o,s,i,e.length]),C.useLayoutEffect(()=>{const p=t.current,h=p?.querySelector("[data-markdown-content]")??p;if(h)return()=>{const k=y.current;if(!k||h.childNodes.length===0||F(h)||Array.from(h.children).some(M=>!M.hasAttribute("data-md-id"))||h.querySelector("[data-md-copy-pending]"))return;const d=window.getSelection();if(d?.rangeCount&&!d.isCollapsed&&d.getRangeAt(0).intersectsNode(h))return;const b=h.querySelector("[data-md-menu]:not(.hidden)"),w=Array.from(h.querySelectorAll("[data-md-action]")).some(M=>M.getAttribute("title")===k.copiedLabel);if(b||w)return;const A=document.createDocumentFragment();A.append(...Array.from(h.childNodes)),nt.store({...k.key,fragment:A}),oe("ui.markdown_renderer.dom_cache.capture")}},[t]),C.useLayoutEffect(()=>{const p=t.current,h=p?.querySelector("[data-markdown-content]")??p;if(!h)return;const k=_e(o);if(e&&h.childNodes.length===0){const d=n?null:Be(e,r);if(d){let b=!1;for(const w of d){const A=document.createElement("div");A.setAttribute("data-md-block",""),A.style.display="contents",A.innerHTML=w.html,pe(A,o),A.setAttribute("data-md-id",w.id),A.setAttribute(V,k),b||=F(A),h.appendChild(A)}b&&v()}else{!n&&!m.current&&(m.current=f?.hold()??null);const b=document.createElement("div");b.setAttribute("data-md-block",""),b.style.display="contents",b.innerHTML=pn(e,r),pe(b,o),b.setAttribute(V,k),h.appendChild(b),F(b)&&v()}}else!l.current&&F(h)&&v()},[t,e,n,r,o,v,f]),C.useEffect(()=>()=>{l.current?.cleanup(),l.current=null},[]),C.useEffect(()=>{const p=t.current;if(!p)return;const h=p.querySelector("[data-markdown-content]")??p;let k=!0;const d=c.current,b=_e(o);if(!n){const w=Be(e,r);if(w&&Tr(h,w,b)){y.current=s?{key:s,copiedLabel:o.labels.copied}:null,oe("ui.markdown_renderer.settled_paint.reused"),S(),g();return}}return fn(e,n,r).then(w=>{if(!k||c.current!==d)return;const A=Array.from(h.children),M=Array.from(h.querySelectorAll("details[data-md-details]")).map(L=>({summary:L.querySelector("summary")?.textContent,open:L.open}));let D=0;w.forEach((L,R)=>{let E=A[R],P=!1;if(E||(E=document.createElement("div"),E.setAttribute("data-md-block",""),E.style.display="contents",h.appendChild(E),P=!0),E.getAttribute("data-md-id")===L.id){if(E.getAttribute(V)!==b){const I=F(E);I&&(l.current?.cleanup(),l.current=null);const N=document.createElement("div");N.setAttribute("data-md-block",""),N.style.display="contents",N.innerHTML=L.html,pe(N,o),N.setAttribute("data-md-id",L.id),N.setAttribute(V,b),E.replaceWith(N),(I||F(N))&&v()}!l.current&&F(E)&&v();return}const x=document.createElement("div");if(x.innerHTML=L.html,pe(x,o),P&&n&&R>0){const I=Math.min(D,4)*55;D+=1;for(const N of Array.from(x.children))N.classList.add("oc-md-block-enter"),I>0&&N instanceof HTMLElement&&N.style.setProperty("--oc-md-enter-delay",`${I}ms`)}const O=F(E),W=F(x);zt(E,x,{childrenOnly:!0,onBeforeElUpdated:(I,N)=>(I.matches("details[data-md-details]")&&N.matches("details[data-md-details]")&&I.querySelector("summary")?.textContent===N.querySelector("summary")?.textContent&&N.toggleAttribute("open",I.hasAttribute("open")),!I.isEqualNode(N))}),E.setAttribute("data-md-id",L.id),E.setAttribute(V,b),(O||W||F(E))&&v()});const $=F(h);let _=!1;for(let L=A.length-1;L>=w.length;L-=1){const R=A[L];R&&F(R)&&(_=!0),R?.remove()}(_||A.length>w.length&&$)&&v(),M.length>0&&h.querySelectorAll("details[data-md-details]").forEach((L,R)=>{const E=M[R];E&&E.summary===L.querySelector("summary")?.textContent&&(L.open=E.open)}),y.current=s?{key:s,copiedLabel:o.labels.copied}:null,S(),g()}),()=>{k=!1}},[t,o,s,r,v,g,S,n,e]),C.useEffect(()=>{const p=t.current;if(p)return ir(p,o)},[t,o]),C.useEffect(()=>{const p=t.current,h=p?.querySelector("[data-markdown-content]")??p;if(h)for(const[k,d]of Object.entries(i))h.style.setProperty(k,d)},[t,i]),C.useEffect(()=>{const p=t.current,h=p?.querySelector("[data-markdown-content]")??p;h&&(o.deferCodeLineNumberSync||Ke(h,o.codeBlockLineWrap,o.labels))},[t,o.codeBlockLineWrap,o.deferCodeLineNumberSync,o.labels])},Bt=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",Ir=t=>{const e=ae.c(40),{content:n,part:r,messageId:i,isAnimated:o,skipFadeIn:s,className:a,isStreaming:l,disableStreamAnimation:c,variant:u,onShowPopup:f,enableFileReferences:m}=t,g=o===void 0?!0:o,y=s===void 0?!1:s,v=l===void 0?!1:l,S=c===void 0?!1:c,p=u===void 0?"assistant":u,h=m===void 0?!0:m;oe("ui.markdown_renderer.render"),v&&oe("ui.markdown_renderer.render.streaming"),ln("ui.markdown_renderer.content_len",n.length);const k=Nt(),{editor:d,runtime:b}=lt(),w=C.useRef(null),A=ct()??"",M=Y(Wr);let D;e[0]!==A||e[1]!==M?(D=q=>{A&&M(A,q)},e[0]=A,e[1]=M,e[2]=D):D=e[2];const $=D,_=v&&!S;let L;e[3]!==f?(L={containerRef:w,onShowPopup:f,enableFullscreen:Tt,enablePanZoom:te.showPanZoomControls},e[3]=f,e[4]=L):L=e[4],Ot(L);const R=h&&!v;let E;e[5]!==d||e[6]!==A||e[7]!==b.isVSCode||e[8]!==R?(E={containerRef:w,effectiveDirectory:A,editor:d,preferRuntimeEditor:b.isVSCode,enabled:R},e[5]=d,e[6]=A,e[7]=b.isVSCode,e[8]=R,e[9]=E):E=e[9],Dt(E);let P;e[10]===Symbol.for("react.memo_cache_sentinel")?(P={containerRef:w},e[10]=P):P=e[10],Rt(P);let x;e[11]!==k?(x=dt(k),e[11]=k,e[12]=x):x=e[12];const O=x,W=Wt(k,_,A?$:void 0,te),{locale:I}=ut(),N=p==="assistant"?"label":"inline",ve=r&&(r.type==="text"||r.type==="reasoning")&&r.time?.end!==void 0?r:null;let le;e[13]===Symbol.for("react.memo_cache_sentinel")?(le=cn(),e[13]=le):le=e[13];const $t=le,Fe=ve?.sessionID,De=ve?.messageID,Oe=ve?.id;let ke;e:{if(v||!Fe||!De||!Oe||n.length===0||n.length>xr){ke=null;break e}const q=`${$t}\0${Fe}`,Le=`${De}\0${Oe}\0${N}\0${n.length}`;let me;e[14]!==A||e[15]!==I||e[16]!==q||e[17]!==Le?(me={scope:q,id:Le,locale:I,directory:A},e[14]=A,e[15]=I,e[16]=q,e[17]=Le,e[18]=me):me=e[18],ke=me}const Ce=ke,Ee=`markdown-${r?.id?`part-${r.id}`:`message-${i}`}`,Se=!v;let ce;e[19]!==n||e[20]!==W||e[21]!==Ce||e[22]!==N||e[23]!==_||e[24]!==O||e[25]!==Se?(ce={containerRef:w,text:n,streaming:_,imageMode:N,syntaxVars:O,ctx:W,domCacheKey:Ce,tableLayoutSettled:Se},e[19]=n,e[20]=W,e[21]=Ce,e[22]=N,e[23]=_,e[24]=O,e[25]=Se,e[26]=ce):ce=e[26],qt(ce);let U;e[27]!==a?(U=mt("break-words w-full min-w-0",a),e[27]=a,e[28]=U):U=e[28];let Z;e[29]!==p?(Z=Bt(p),e[29]=p,e[30]=Z):Z=e[30];let X;e[31]!==Z?(X=re.jsx("div",{className:Z,"data-markdown-content":!0}),e[31]=Z,e[32]=X):X=e[32];let de;e[33]!==U||e[34]!==X?(de=re.jsx("div",{className:U,ref:w,children:X}),e[33]=U,e[34]=X,e[35]=de):de=e[35];const ue=de;if(g){let q;return e[36]!==Ee||e[37]!==ue||e[38]!==y?(q=re.jsx(rn,{skipAnimation:y,children:ue},Ee),e[36]=Ee,e[37]=ue,e[38]=y,e[39]=q):q=e[39],q}return ue},zi=C.memo(Ir,(t,e)=>t.content===e.content&&t.isStreaming===e.isStreaming&&t.disableStreamAnimation===e.disableStreamAnimation&&t.variant===e.variant&&t.isAnimated===e.isAnimated&&t.skipFadeIn===e.skipFadeIn&&t.className===e.className&&t.messageId===e.messageId&&t.onShowPopup===e.onShowPopup&&t.enableFileReferences===e.enableFileReferences&&t.part?.id===e.part?.id),Fr=t=>{const e=ae.c(29),{content:n,className:r,variant:i,disableLinkSafety:o,stripFrontmatter:s,onShowPopup:a,mermaidControls:l,allowMermaidWheelEvents:c,enableFileReferences:u}=t,f=i===void 0?"assistant":i,m=s===void 0?!1:s,g=l===void 0?te:l,y=c===void 0?!1:c,v=u===void 0?!0:u,{editor:S,runtime:p}=lt(),h=Nt(),k=C.useRef(null),d=ct()??"";let b;e[0]!==n||e[1]!==m?(b=m?br(n):n,e[0]=n,e[1]=m,e[2]=b):b=e[2];const w=b;let A;e[3]!==y||e[4]!==g.showPanZoomControls||e[5]!==a?(A={containerRef:k,onShowPopup:a,enableFullscreen:Tt,enablePanZoom:g.showPanZoomControls,allowMermaidWheelEvents:y},e[3]=y,e[4]=g.showPanZoomControls,e[5]=a,e[6]=A):A=e[6],Ot(A);let M;e[7]!==S||e[8]!==d||e[9]!==v||e[10]!==p.isVSCode?(M={containerRef:k,effectiveDirectory:d,editor:S,preferRuntimeEditor:p.isVSCode,enabled:v},e[7]=S,e[8]=d,e[9]=v,e[10]=p.isVSCode,e[11]=M):M=e[11],Dt(M);const D=!o;let $;e[12]!==D?($={containerRef:k,enabled:D},e[12]=D,e[13]=$):$=e[13],Rt($);let _;e[14]!==h?(_=dt(h),e[14]=h,e[15]=_):_=e[15];const L=_,R=Wt(h,!1,void 0,g);let E;e[16]!==R||e[17]!==w||e[18]!==L?(E={containerRef:k,text:w,streaming:!1,syntaxVars:L,ctx:R,tableLayoutSettled:!0},e[16]=R,e[17]=w,e[18]=L,e[19]=E):E=e[19],qt(E);let P;e[20]!==r?(P=mt("break-words w-full min-w-0",r),e[20]=r,e[21]=P):P=e[21];let x;e[22]!==f?(x=Bt(f),e[22]=f,e[23]=x):x=e[23];let O;e[24]!==x?(O=re.jsx("div",{className:x,"data-markdown-content":!0}),e[24]=x,e[25]=O):O=e[25];let W;return e[26]!==P||e[27]!==O?(W=re.jsx("div",{className:P,ref:k,children:O}),e[26]=P,e[27]=O,e[28]=W):W=e[28],W},Hi=C.memo(Fr,(t,e)=>{const n=t.mermaidControls??te,r=e.mermaidControls??te;return t.content===e.content&&t.variant===e.variant&&t.className===e.className&&t.disableLinkSafety===e.disableLinkSafety&&t.stripFrontmatter===e.stripFrontmatter&&t.onShowPopup===e.onShowPopup&&n.download===r.download&&n.copy===r.copy&&n.showPanZoomControls===r.showPanZoomControls&&t.allowMermaidWheelEvents===e.allowMermaidWheelEvents&&t.enableFileReferences===e.enableFileReferences});function Dr(t){on(t)}function Or(t){sn(t)}function Wr(t){return t.openContextPreview}export{zi as MarkdownRenderer,Hi as SimpleMarkdownRenderer};
|