@pi-chamber/web 1.0.7 → 1.0.8-rc.2
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/dist/assets/AgentsSurface-CcWBqAWV.js +1 -0
- package/dist/assets/ChoicesArtifact-Kk-qvrSB.js +1 -0
- package/dist/assets/DiagramView-DZUBo1uP.js +1 -0
- package/dist/assets/{DiffView-BxW6BuOC.js → DiffView-CiZy4jFA.js} +6 -6
- package/dist/assets/FileSaveConflictDialog-DZ9NDwOO.js +3 -0
- package/dist/assets/FilesView-DqiZ9kw9.js +6 -0
- package/dist/assets/GitHubDetailScaffold-DM2DH7o8.js +11 -0
- package/dist/assets/GitHubLinkPicker-ChB8NZ1h.js +1 -0
- package/dist/assets/GitHubListPrimitives-CibDiJGq.js +1 -0
- package/dist/assets/{GitView-DD33ngnM.js → GitView--EaZQrBr.js} +5 -5
- package/dist/assets/{IssuesSurface-BAY_eyX5.js → IssuesSurface-CySTpaD1.js} +3 -3
- package/dist/assets/{JsonTreeView-DpXbUrAl.js → JsonTreeView-_yMHKKQZ.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-Cn63lAmn.js → MarkdownRendererImpl-D_-2fQw0.js} +3 -3
- package/dist/assets/PatchDiff-bHObDlhD.js +1 -0
- package/dist/assets/PierreDiffViewer-UY7Cse-s.js +147 -0
- package/dist/assets/PullRequestsSurface-iXy6chwc.js +2 -0
- package/dist/assets/{SessionSwitcherContent-CscYekC1.js → SessionSwitcherContent-DJGCa_wN.js} +1 -1
- package/dist/assets/SessionSwitcherDropdown-CDOX-5Y2.js +2 -0
- package/dist/assets/SessionUnreadDot-Dwc3MdvA.js +1 -0
- package/dist/assets/SettingsView-DA-U9lsj.js +11 -0
- package/dist/assets/{SettingsWindow-gxjULdm1.js → SettingsWindow-CUg49Mfh.js} +1 -1
- package/dist/assets/{StickyHorizontalScrollbar-DNsbTLS7.js → StickyHorizontalScrollbar-CMbTn5WQ.js} +1 -1
- package/dist/assets/SubagentsArtifact-DUZX9tDe.js +1 -0
- package/dist/assets/ToolOutputDialog-BuZZaRw4.js +8 -0
- package/dist/assets/ToolPartDiffPreview-CKncG6i2.js +1 -0
- package/dist/assets/{VirtualizedFileDiff-BrbPymTL.js → VirtualizedFileDiff-BGZiLPe_.js} +4 -4
- package/dist/assets/{Virtualizer-okhy9Aq3.js → Virtualizer-PxblpQn6.js} +1 -1
- package/dist/assets/VisualFrame-DBZkHFnG.js +22 -0
- package/dist/assets/VisualsArtifact-Bq0vMO-i.js +1 -0
- package/dist/assets/{collapsible-D6qdoq7-.js → collapsible-Bro9KrfM.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-G4csGiKs.js → computeVirtualFileMetrics-DJQqK49u.js} +2 -2
- package/dist/assets/contextFileOpenGuard-ByWK3Sru.js +1 -0
- package/dist/assets/{fileTreeStatus-Bskhj4qT.js → fileTreeStatus-CyJ3TOYD.js} +2 -2
- package/dist/assets/gitStatusPredicates-BsXrwngT.js +1 -0
- package/dist/assets/githubLink-g2bmC0qi.js +10 -0
- package/dist/assets/index-B_L9GVYw.css +1 -0
- package/dist/assets/{index-ComwtfT4.js → index-C9rUUQ_Y.js} +1 -1
- package/dist/assets/index-CKKWVoND.js +11 -0
- package/dist/assets/{main-DoiadX0a.js → main-DT-4_fhe.js} +2 -2
- package/dist/assets/main-DsLMU9CT.js +137 -0
- package/dist/assets/{markdownCore-DczkEluO.js → markdownCore-QmM_aOnZ.js} +2 -2
- package/dist/assets/{miniChat-Ck6MEZ9Q.js → miniChat-BqGslD2z.js} +2 -2
- package/dist/assets/{mobile-BucKVm1P.js → mobile-C5JOcDIC.js} +2 -2
- package/dist/assets/{nativeFileSave-Cp9i5QGd.js → nativeFileSave-DSMsJqXM.js} +1 -1
- package/dist/assets/pi-session-focus-preference-Cc_S4zi1.js +9 -0
- package/dist/assets/{renderDiffWithHighlighter-PL82AR81.js → renderDiffWithHighlighter-BXhnIAHg.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-CiSkecEE.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-CYgfbA4F.js → renderFileWithHighlighter-CK29YZtC.js} +1 -1
- package/dist/assets/renderMobileApp-C4JuoxsZ.js +11 -0
- package/dist/assets/runtimeEndpointReset-Dwj-jCDS.js +66 -0
- package/dist/assets/runtimeSurface-0K7vuUpd.js +1 -0
- package/dist/assets/selection-CnYkEsu_.js +1 -0
- package/dist/assets/useAppFontEffects-CV5UyTRw.js +226 -0
- package/dist/assets/useGitHubRemoteSearch-CgP-zEBj.js +1 -0
- package/dist/assets/useSwitcherItems-C8G5F0hs.js +1 -0
- package/dist/assets/{vendor-aparajita-capacitor-secure-storage-DVZvgYu4.js → vendor-aparajita-capacitor-secure-storage-DUoR8t1G.js} +1 -1
- package/dist/assets/{vendor-base-ui-BCqPBzDj.js → vendor-base-ui-DE6jnTiC.js} +1 -1
- package/dist/assets/{vendor-boot-3SaHYVb1.js → vendor-boot-D-KEJjsM.js} +29 -29
- package/dist/assets/{vendor-capacitor-app-NbQ-WiPS.js → vendor-capacitor-app-CO5jS31X.js} +1 -1
- package/dist/assets/{vendor-capacitor-keyboard-CgrHt8iN.js → vendor-capacitor-keyboard-335osRpd.js} +1 -1
- package/dist/assets/{vendor-capacitor-status-bar-CWt0OF5t.js → vendor-capacitor-status-bar-lB9y4H9d.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-WThuuUAz.js → vendor-codemirror-autocomplete-BKvJ8PfM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-BbLGCxF6.js → vendor-codemirror-lang-angular-wjCUD0bM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-Cceks-9O.js → vendor-codemirror-lang-cpp-LJzlG8sJ.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-D1wpUg3Z.js → vendor-codemirror-lang-css-DoEEdEpW.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-Cv0zXHHM.js → vendor-codemirror-lang-go-DexsLPb8.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-DbL8oT9H.js → vendor-codemirror-lang-html-h25V-Hp5.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CNugenuC.js → vendor-codemirror-lang-java-D8xoT8cv.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-Bx_FIyZF.js → vendor-codemirror-lang-javascript-DF3GDYje.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-DDGjB3Zq.js → vendor-codemirror-lang-jinja-BboTHFdn.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-DIvqf9Pb.js → vendor-codemirror-lang-json-DCqvG1nE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-D8r9dGG1.js → vendor-codemirror-lang-less-B8ZrSKJM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-B24mguYi.js → vendor-codemirror-lang-liquid-DF9S5m5F.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-v3yG2sbf.js → vendor-codemirror-lang-markdown-6BNbCEPe.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-BcZGalqy.js → vendor-codemirror-lang-php-CQwAz1Hd.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-b-JqEwQy.js → vendor-codemirror-lang-python-DQym-8Tx.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-B1uZxDW-.js → vendor-codemirror-lang-rust-DknzOTkO.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-DqPrngKp.js → vendor-codemirror-lang-sass-dB0Rm5HI.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-UyCnpt-k.js → vendor-codemirror-lang-sql-CCQUnnD-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-xDwYkovV.js → vendor-codemirror-lang-vue-h1M5bF00.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-CF3169p_.js → vendor-codemirror-lang-wast-DWgtlGfu.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-FCtVhuOb.js → vendor-codemirror-lang-xml-DncwoCUY.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-g0sPmAnv.js → vendor-codemirror-lang-yaml-C7QkS5ER.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-B03xgzP2.js → vendor-codemirror-language-data-BUZIlm3G.js} +2 -2
- package/dist/assets/{vendor-codemirror-search-Dw3Wpu15.js → vendor-codemirror-search-BlDCaCMK.js} +1 -1
- package/dist/assets/{vendor-lezer-cpp-Cu3E-KUI.js → vendor-lezer-cpp-B4JK1BC1.js} +1 -1
- package/dist/assets/{vendor-lezer-css-Cb8vp67u.js → vendor-lezer-css-DRxDmhcy.js} +1 -1
- package/dist/assets/{vendor-lezer-go-BTsIaOm7.js → vendor-lezer-go-DsUgfmxi.js} +1 -1
- package/dist/assets/{vendor-lezer-html-UQMsUwj-.js → vendor-lezer-html-qr9pUPmM.js} +1 -1
- package/dist/assets/{vendor-lezer-java-BIWrFrAx.js → vendor-lezer-java-6UyNiQiB.js} +1 -1
- package/dist/assets/{vendor-lezer-javascript-BH2Etgoy.js → vendor-lezer-javascript-CUdJ0VGA.js} +1 -1
- package/dist/assets/{vendor-lezer-json-CE-QUCwM.js → vendor-lezer-json-BKYAA8Hu.js} +1 -1
- package/dist/assets/{vendor-lezer-lr-HY6Yc0Vr.js → vendor-lezer-lr-DluApmOX.js} +1 -1
- package/dist/assets/{vendor-lezer-markdown-xFL3Evwf.js → vendor-lezer-markdown-B-uzYzYT.js} +1 -1
- package/dist/assets/{vendor-lezer-php-Cr_mQGrG.js → vendor-lezer-php-DI6PNjlz.js} +1 -1
- package/dist/assets/{vendor-lezer-python-BNRFWCb0.js → vendor-lezer-python-Bj232yb5.js} +1 -1
- package/dist/assets/{vendor-lezer-rust-BvfOK5cU.js → vendor-lezer-rust-DlPG_Yau.js} +1 -1
- package/dist/assets/{vendor-lezer-sass-qoxiLisk.js → vendor-lezer-sass-CBsyWB2A.js} +1 -1
- package/dist/assets/{vendor-lezer-xml--x8SSpqU.js → vendor-lezer-xml-C1FmgtmE.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-BDo1JaEr.js → vendor-lezer-yaml-DpHmjriG.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-D1Fe7FiY.js → vendor-replit-codemirror-vim-Cvk64got.js} +1 -1
- package/dist/assets/{web-components-CGDpzixf.js → web-components-BpncHjnV.js} +4 -4
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -1
- package/plugins/featured.json +12 -0
- package/plugins/registry.json +7 -0
- package/plugins/subagents/LICENSE +25 -0
- package/plugins/subagents/agents/planner.md +36 -0
- package/plugins/subagents/agents/reviewer.md +34 -0
- package/plugins/subagents/agents/scout.md +49 -0
- package/plugins/subagents/agents/worker.md +23 -0
- package/plugins/subagents/extension.js +631 -0
- package/plugins/subagents/extension.test.js +295 -0
- package/plugins/subagents/package.json +41 -0
- package/plugins/visuals/choices.js +168 -0
- package/plugins/visuals/extension.js +90 -0
- package/plugins/visuals/files.js +74 -0
- package/plugins/visuals/package.json +32 -0
- package/server/index.js +103 -24
- package/server/lib/git/DOCUMENTATION.md +4 -0
- package/server/lib/git/service.js +70 -5
- package/server/lib/git/service.test.js +179 -0
- package/server/lib/github/DOCUMENTATION.md +6 -2
- package/server/lib/github/gh-cli.js +35 -9
- package/server/lib/github/gh-cli.test.js +122 -0
- package/server/lib/marketplace/DOCUMENTATION.md +95 -0
- package/server/lib/marketplace/featured.js +176 -0
- package/server/lib/marketplace/featured.test.js +207 -0
- package/server/lib/marketplace/npm-registry.js +255 -0
- package/server/lib/marketplace/npm-registry.test.js +227 -0
- package/server/lib/marketplace/routes.js +64 -0
- package/server/lib/marketplace/routes.test.js +119 -0
- package/server/lib/marketplace/service.js +225 -0
- package/server/lib/marketplace/service.test.js +174 -0
- package/server/lib/notifications/DOCUMENTATION.md +10 -4
- package/server/lib/notifications/pi-notification-watcher.js +95 -33
- package/server/lib/notifications/pi-notification-watcher.test.js +89 -0
- package/server/lib/open-url/DOCUMENTATION.md +2 -1
- package/server/lib/pi/extension-protocol.js +54 -0
- package/server/lib/pi/fixtures/pichamber-gui-demo.ts +12 -13
- package/server/lib/pi/merged-event-stream.js +316 -0
- package/server/lib/pi/merged-event-stream.test.js +95 -0
- package/server/lib/pi/routes-daemon-pool.test.js +348 -0
- package/server/lib/pi/routes-extension-events.test.js +115 -0
- package/server/lib/pi/routes-merged-events.test.js +327 -0
- package/server/lib/pi/routes-sandbox.test.js +1684 -0
- package/server/lib/pi/routes.js +790 -87
- package/server/lib/pi/routes.test.js +381 -1
- package/server/lib/pi/sandbox/DOCUMENTATION.md +68 -0
- package/server/lib/pi/sandbox/launcher.js +122 -0
- package/server/lib/pi/sandbox/launcher.test.js +91 -0
- package/server/lib/pi/sandbox/nono-launcher.js +455 -0
- package/server/lib/pi/sandbox/nono-launcher.test.js +371 -0
- package/server/lib/pi/sandbox/nono-profile-macos.json +20 -0
- package/server/lib/pi/sandbox/nono-profile-wsl2.json +21 -0
- package/server/lib/pi/sandbox/nono-profile.json +22 -0
- package/server/lib/pi/sandbox/project-sandbox-manager.js +1461 -0
- package/server/lib/pi/sandbox/project-sandbox-setting.js +166 -0
- package/server/lib/pi/sandbox/project-sandbox.js +207 -0
- package/server/lib/pi/sandbox/sandbox-routes.js +110 -0
- package/server/lib/pi/sandbox/sandboxed-folders.js +100 -0
- package/server/lib/pi/sandbox/sandboxed-folders.test.js +65 -0
- package/server/lib/pi/sandbox/trust-ask.js +135 -0
- package/server/lib/pi/sandbox/trust-ask.test.js +54 -0
- package/server/lib/pi/sandbox/worktree-ids.js +96 -0
- package/server/lib/pi/sandbox/worktree-ids.test.js +73 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +47 -10
- package/server/lib/pi/session-daemon/daemon-pool.js +157 -0
- package/server/lib/pi/session-daemon/daemon-process.js +10 -1
- package/server/lib/pi/session-daemon/extension-bridge.js +89 -29
- package/server/lib/pi/session-daemon/extension-config.js +902 -0
- package/server/lib/pi/session-daemon/extension-config.test.js +798 -0
- package/server/lib/pi/session-daemon/extension-controls.js +177 -0
- package/server/lib/pi/session-daemon/extension-controls.test.js +181 -0
- package/server/lib/pi/session-daemon/extension-name.js +6 -0
- package/server/lib/pi/session-daemon/extension-name.test.js +5 -0
- package/server/lib/pi/session-daemon/extension-palette.js +146 -0
- package/server/lib/pi/session-daemon/extension-palette.test.js +107 -0
- package/server/lib/pi/session-daemon/extension-replacements.js +138 -0
- package/server/lib/pi/session-daemon/extension-replacements.test.js +116 -0
- package/server/lib/pi/session-daemon/extension-ui-mode.js +30 -0
- package/server/lib/pi/session-daemon/extension-ui-mode.test.js +34 -0
- package/server/lib/pi/session-daemon/pichamber-ui.js +44 -0
- package/server/lib/pi/session-daemon/plugin-host.js +245 -0
- package/server/lib/pi/session-daemon/plugin-host.test.js +192 -0
- package/server/lib/pi/session-daemon/session-daemon-controls.e2e.test.js +205 -0
- package/server/lib/pi/session-daemon/session-daemon-drafts.e2e.test.js +409 -0
- package/server/lib/pi/session-daemon/session-daemon-extension-config.e2e.test.js +196 -0
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +137 -6
- package/server/lib/pi/session-daemon/session-daemon-plugins.e2e.test.js +272 -0
- package/server/lib/pi/session-daemon/session-daemon-providers.e2e.test.js +153 -0
- package/server/lib/pi/session-daemon/session-daemon-read-persisted.test.js +167 -0
- package/server/lib/pi/session-daemon/session-daemon.js +927 -108
- package/server/lib/pi/session-daemon/session-daemon.test.js +391 -4
- package/server/lib/pi/session-daemon/session-engine-router.js +7 -0
- package/server/lib/pi/session-daemon/session-engine-router.test.js +20 -0
- package/server/lib/pi/session-daemon/session-idle-residency.test.js +98 -1
- package/server/lib/pi/session-daemon/session-jsonl.js +49 -10
- package/server/lib/pi/session-daemon/session-jsonl.test.js +11 -0
- package/server/lib/pi/session-daemon/session-lease.js +93 -15
- package/server/lib/pi/session-daemon/session-lease.test.js +107 -1
- package/server/lib/pi/session-daemon/supervisor-launcher-stop.test.js +295 -0
- package/server/lib/pi/session-daemon/supervisor-sandbox-nono.e2e.test.js +301 -0
- package/server/lib/pi/session-daemon/supervisor-sandbox.test.js +444 -0
- package/server/lib/pi/session-daemon/supervisor.js +408 -38
- package/server/lib/pi/session-daemon/supervisor.test.js +28 -0
- package/server/lib/pi/settings-store.js +14 -0
- package/server/lib/pi/settings-store.test.js +11 -0
- package/server/lib/pi/ui-settings-store.js +88 -2
- package/server/lib/pi/ui-settings-store.test.js +118 -0
- package/server/lib/plugins/DOCUMENTATION.md +198 -0
- package/server/lib/plugins/daemon-sync.js +88 -0
- package/server/lib/plugins/daemon-sync.supervisor.test.js +83 -0
- package/server/lib/plugins/daemon-sync.test.js +108 -0
- package/server/lib/plugins/impact.js +139 -0
- package/server/lib/plugins/impact.test.js +83 -0
- package/server/lib/plugins/manifest.js +220 -0
- package/server/lib/plugins/manifest.test.js +127 -0
- package/server/lib/plugins/registry.js +59 -0
- package/server/lib/plugins/routes.js +92 -0
- package/server/lib/plugins/routes.test.js +247 -0
- package/server/lib/plugins/service.js +183 -0
- package/server/lib/plugins/store.js +261 -0
- package/server/lib/plugins/store.test.js +188 -0
- package/server/lib/plugins/visuals-extension.test.js +237 -0
- package/server/lib/server/cross-process-lock.js +28 -3
- package/server/lib/server-browser/DOCUMENTATION.md +32 -7
- package/server/lib/server-browser/browser-tab.js +4 -1
- package/server/lib/server-browser/downloads.js +261 -34
- package/server/lib/server-browser/downloads.test.js +171 -0
- package/server/lib/server-browser/runtime.integration.test.js +47 -0
- package/server/lib/server-browser/runtime.js +16 -0
- package/server/lib/server-browser/server-browser.js +25 -6
- package/server/lib/tunnels/executable-search.js +5 -1
- package/server/lib/tunnels/executable-search.test.js +26 -0
- package/dist/assets/DiagramView-BB-aZobi.js +0 -1
- package/dist/assets/FileSaveConflictDialog-Bzz8FNMq.js +0 -3
- package/dist/assets/FilesView-DECxN8Z0.js +0 -6
- package/dist/assets/GitHubDetailScaffold-CWsWycRd.js +0 -11
- package/dist/assets/GitHubLinkPicker-BVYdg_e8.js +0 -1
- package/dist/assets/GitHubListPrimitives-Dlv3tC4d.js +0 -1
- package/dist/assets/PatchDiff-BklyOEHs.js +0 -1
- package/dist/assets/PierreDiffViewer-wc6cB6qw.js +0 -147
- package/dist/assets/PullRequestsSurface-BZvJkT1I.js +0 -2
- package/dist/assets/SessionSwitcherDropdown-DShvvGwC.js +0 -2
- package/dist/assets/SessionUnreadDot-CbqRq6h_.js +0 -1
- package/dist/assets/SettingsView-DcF-At5E.js +0 -6
- package/dist/assets/ToolOutputDialog-DdMIfrnK.js +0 -8
- package/dist/assets/ToolPartDiffPreview-C6Sm4eVf.js +0 -1
- package/dist/assets/contextFileOpenGuard-UU86YHgI.js +0 -1
- package/dist/assets/gitStatusPredicates-DQEO4Psc.js +0 -1
- package/dist/assets/githubLink-ByPAyFjh.js +0 -10
- package/dist/assets/index-BaLCg7tL.css +0 -1
- package/dist/assets/index-I2QYqABE.js +0 -11
- package/dist/assets/main-DyFfbllq.js +0 -137
- package/dist/assets/pi-session-focus-preference-Dx0UXPoO.js +0 -9
- package/dist/assets/renderElectronMiniChatApp-Cb7s7dWl.js +0 -2
- package/dist/assets/renderMobileApp-Bp74b_Lo.js +0 -11
- package/dist/assets/runtimeEndpointReset-7nWYnKd4.js +0 -62
- package/dist/assets/runtimeSurface-CFwnvks_.js +0 -1
- package/dist/assets/useAppFontEffects-ZTyNwFk6.js +0 -213
- package/dist/assets/useGitHubRemoteSearch-BF3ohpsh.js +0 -1
- package/dist/assets/useSwitcherItems-BJzwyDGX.js +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{j as _}from"./vendor-boot-3SaHYVb1.js";import{R as y}from"./vendor-react-Bz1tRBxM.js";import{m as je}from"./vendor-morphdom-B7dS_VPB.js";import{r as Ze}from"./vendor-beautiful-mermaid-b48gT2g0.js";import{a as Ue,aa as Xe,h as Ae,z as Ge,Q as ee,bQ as Ye,f as U,A as te}from"./index-I2QYqABE.js";import{dq as ve,dr as Qe,ds as Je,ah as W,br as et,bs as tt,dt as rt,du as nt,dv as ot,dw as re,dx as at,dy as it,dz as st,z as ke,y as Ee,dA as Ce,dB as lt,ar as ct}from"./useAppFontEffects-ZTyNwFk6.js";import{r as dt,s as ut,i as mt,a as ft,b as pt}from"./markdownCore-DczkEluO.js";import{r as ht}from"./registerCustomTheme-C-h6lsYW.js";import{saveOrShareFile as gt}from"./nativeFileSave-Cp9i5QGd.js";import{i as bt}from"./runtimeSurface-CFwnvks_.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-elkjs-D1S1RCAO.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./vendor-marked-Be78pDn1.js";import"./vendor-dompurify-BGCr_sdL.js";import"./vendor-remend-DcBOpbSu.js";import"./themeResolver-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.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 Se="pichamber-md",wt={name:Se,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 ne=!1;const yt=()=>{ne||(ne=!0,ht(Se,()=>Promise.resolve(wt)))},k=e=>Number.isFinite(e)&&e>0,oe=e=>{if(typeof e=="number")return k(e)?e:null;if(typeof e!="string")return null;const t=e.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!t)return null;const n=Number(t[1]);return k(n)?n:null},B=(e,t,n)=>Math.min(n,Math.max(t,e)),At=6,ae=1.25,vt=1.0015,kt=.5,Et=12,ie=3,Ct=400,I='[data-markdown="mermaid-block"]',M=e=>e.querySelector(I)!==null,St=e=>[e.x,e.y,e.width,e.height].map(t=>{const n=Number(t.toFixed(At));return Object.is(n,-0)?"0":String(n)}).join(" "),Mt=e=>{const t=e.viewBox?.trim().split(/[\s,]+/).map(s=>Number.parseFloat(s));if(t?.length===4){const[s,o,a,i]=t;if(Number.isFinite(s)&&Number.isFinite(o)&&k(a)&&k(i))return{x:s,y:o,width:a,height:i}}const n=oe(e.width),r=oe(e.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},Lt=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},Nt=e=>{const t=e.renderMode||"unknown",n=e.svgMarkup??"";if(!n){const r=[e.viewBox??"",e.width??"",e.height??""];return r.some(s=>s!=="")?`${t}:bounds:${r.join(":")}`:`${t}:no-svg`}return[t,Lt(n)].join(":")},Me=(e,t)=>{if(!k(t.width)||!k(t.height))return e;const n=e.width/e.height,r=t.width/t.height;if(n>r){const o=e.width/r;return{x:e.x,y:e.y-(o-e.height)/2,width:e.width,height:o}}const s=e.height*r;return{x:e.x-(s-e.width)/2,y:e.y,width:s,height:e.height}},xt=({currentBox:e,viewport:t,delta:n})=>!k(t.width)||!k(t.height)||!k(e.width)||!k(e.height)?e:{x:e.x-n.x/t.width*e.width,y:e.y-n.y/t.height*e.height,width:e.width,height:e.height},Tt=(e,t)=>{const n=t.x-e.x,r=t.y-e.y;return n*n+r*r>ie*ie},Pt=({currentBox:e,contentBox:t,viewport:n,pointer:r,zoomFactor:s,minScale:o,maxScale:a})=>{if(!k(n.width)||!k(n.height)||!k(s)||!k(e.width)||!k(e.height)||!k(t.width)||!k(t.height)||!k(o)||!k(a))return e;const i=Math.min(o,a),l=Math.max(o,a),d=Me(t,n),c=d.width/e.width,m=B(c*s,i,l),f=d.width/m,p=f/(e.width/e.height),h=B(r.x/n.width,0,1),A=B(r.y/n.height,0,1),v=e.x+h*e.width,w=e.y+A*e.height;return{x:v-h*f,y:w-A*p,width:f,height:p}},X=new WeakMap,Rt=e=>e instanceof HTMLElement?X.get(e)??null:null,_t=e=>e.querySelector('[data-markdown="mermaid-viewport"]')??e.querySelector('[data-markdown="mermaid"]'),se=e=>{const t=e.querySelector('[data-markdown="mermaid"] svg'),n=e.querySelector('[data-markdown="mermaid"]');return Nt({renderMode:e.getAttribute("data-mermaid-render"),svgMarkup:n?.getAttribute("data-md-original-svg")??t?.outerHTML??null,viewBox:t?.getAttribute("viewBox"),width:t?.getAttribute("width"),height:t?.getAttribute("height")})},R=e=>{const t=e.getBoundingClientRect();return{width:t.width,height:t.height}},It=(e,t)=>{const n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},Ft=e=>e instanceof Element&&!!e.closest('button, a, [role="button"]'),Ot=e=>{const t=_t(e),n=e.querySelector('[data-markdown="mermaid"] svg');if(!t||!n)return null;const r=Mt({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let s=r,o=null,a=null,i=null,l=null;const d=u=>{s=u,n.setAttribute("viewBox",St(u)),n.removeAttribute("width"),n.removeAttribute("height")},c=()=>{d(Me(r,R(t)))},m=(u,E)=>{d(Pt({currentBox:s,contentBox:r,viewport:R(t),pointer:u,zoomFactor:E,minScale:kt,maxScale:Et}))},f=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},ae)},p=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},1/ae)},h=u=>{!u.ctrlKey&&!u.metaKey||(u.preventDefault(),u.stopPropagation(),m(It(u,t),Math.pow(vt,-u.deltaY)))},A=u=>{u.button!==0||Ft(u.target)||(o=u.pointerId,a={x:u.clientX,y:u.clientY},i=a,l!==null&&(window.clearTimeout(l),l=null),e.removeAttribute("data-mermaid-suppress-click"),t.setPointerCapture?.(u.pointerId),e.setAttribute("data-mermaid-panning","true"),u.preventDefault())},v=u=>{if(o!==u.pointerId||!i)return;const E={x:u.clientX,y:u.clientY};d(xt({currentBox:s,viewport:R(t),delta:{x:E.x-i.x,y:E.y-i.y}})),i=E,a&&Tt(a,E)&&e.setAttribute("data-mermaid-suppress-click","true"),u.preventDefault()},w=u=>{o===u.pointerId&&(t.releasePointerCapture?.(u.pointerId),o=null,a=null,i=null,e.removeAttribute("data-mermaid-panning"),e.hasAttribute("data-mermaid-suppress-click")&&(l=window.setTimeout(()=>{e.removeAttribute("data-mermaid-suppress-click"),l=null},Ct)))},g=()=>{c()};t.addEventListener("wheel",h,{passive:!1}),t.addEventListener("pointerdown",A),t.addEventListener("pointermove",v),t.addEventListener("pointerup",w),t.addEventListener("pointercancel",w),window.addEventListener("resize",g);const b=typeof ResizeObserver>"u"?null:new ResizeObserver(g);return b?.observe(t),c(),{zoomIn:f,zoomOut:p,fit:c,cleanup:()=>{t.removeEventListener("wheel",h),t.removeEventListener("pointerdown",A),t.removeEventListener("pointermove",v),t.removeEventListener("pointerup",w),t.removeEventListener("pointercancel",w),window.removeEventListener("resize",g),b?.disconnect(),l!==null&&window.clearTimeout(l),e.removeAttribute("data-mermaid-panning"),e.removeAttribute("data-mermaid-suppress-click"),X.delete(e)}}},Dt=e=>{const t=new Map,n=new Map,r=()=>{for(const[o,a]of Array.from(t.entries())){const i=se(o);(!e.contains(o)||i!==n.get(o))&&(a.cleanup(),t.delete(o),n.delete(o))}for(const o of Array.from(e.querySelectorAll(I))){if(t.has(o)||o.querySelector('[data-markdown="mermaid"] svg')===null)continue;const a=Ot(o);a&&(t.set(o,a),n.set(o,se(o)),X.set(o,a))}},s=()=>{for(const o of t.values())o.cleanup();t.clear(),n.clear()};return r(),{refresh:r,cleanup:s}},x=e=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${e}"></use></svg>`,q={copy:x("file-copy"),check:x("check"),download:x("download"),zoomIn:x("add"),zoomOut:x("subtract"),fit:x("refresh")},Le="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)]",z=(e,t)=>{e.innerHTML=t},S=(e,t,n)=>{const r=document.createElement("button");return r.type="button",r.className=Le,r.setAttribute("data-md-action",n),r.setAttribute("title",t),r.setAttribute("aria-label",t),z(r,q[e]),r},Ne=e=>{const t=e.querySelector("[data-md-code-body]"),n=e.querySelector("pre"),r=e.querySelector("pre code"),s=e.querySelectorAll("[data-md-code-line-content]");e.setAttribute("data-code-wrap","true"),t?.classList.remove("overflow-x-auto"),t?.classList.add("overflow-x-hidden"),n?.classList.add("whitespace-pre-wrap","break-words"),r?.classList.add("whitespace-pre-wrap","break-words"),n&&(n.style.whiteSpace="pre-wrap",n.style.overflowWrap="anywhere"),r&&(r.style.whiteSpace="pre-wrap",r.style.overflowWrap="anywhere");for(const o of Array.from(s))o.style.whiteSpace="pre-wrap",o.style.overflowWrap="anywhere"},xe=e=>{const t=e.querySelector(":scope > code");if(!t||t.hasAttribute("data-md-code-lines"))return;const n=t.textContent??"",r=n.endsWith(`
|
|
1
|
+
import{j as _}from"./vendor-boot-D-KEJjsM.js";import{R as y}from"./vendor-react-Bz1tRBxM.js";import{m as Ke}from"./vendor-morphdom-B7dS_VPB.js";import{r as Ze}from"./vendor-beautiful-mermaid-b48gT2g0.js";import{f as Ue,B as Xe,u as ve,r as Ge,C as ee,D as Ye,c as U,a as te}from"./index-CKKWVoND.js";import{a_ as Ae,a$ as Je,b0 as Qe,a2 as W,b1 as et,b2 as tt,b3 as rt,b4 as nt,a1 as ot,b5 as re,b6 as at,b7 as it,b8 as st,j as ke,aZ as Ee,b9 as Ce,ba as lt,v as ct}from"./useAppFontEffects-CV5UyTRw.js";import{r as dt,s as ut,i as mt,a as ft,b as pt}from"./markdownCore-QmM_aOnZ.js";import{r as ht}from"./registerCustomTheme-C-h6lsYW.js";import{saveOrShareFile as bt}from"./nativeFileSave-DSMsJqXM.js";import{i as gt}from"./runtimeSurface-0K7vuUpd.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-elkjs-D1S1RCAO.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./vendor-marked-Be78pDn1.js";import"./vendor-dompurify-BGCr_sdL.js";import"./vendor-remend-DcBOpbSu.js";import"./themeResolver-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.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 Se="pichamber-md",wt={name:Se,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 ne=!1;const yt=()=>{ne||(ne=!0,ht(Se,()=>Promise.resolve(wt)))},k=e=>Number.isFinite(e)&&e>0,oe=e=>{if(typeof e=="number")return k(e)?e:null;if(typeof e!="string")return null;const t=e.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!t)return null;const n=Number(t[1]);return k(n)?n:null},B=(e,t,n)=>Math.min(n,Math.max(t,e)),vt=6,ae=1.25,At=1.0015,kt=.5,Et=12,ie=3,Ct=400,I='[data-markdown="mermaid-block"]',M=e=>e.querySelector(I)!==null,St=e=>[e.x,e.y,e.width,e.height].map(t=>{const n=Number(t.toFixed(vt));return Object.is(n,-0)?"0":String(n)}).join(" "),Mt=e=>{const t=e.viewBox?.trim().split(/[\s,]+/).map(s=>Number.parseFloat(s));if(t?.length===4){const[s,o,a,i]=t;if(Number.isFinite(s)&&Number.isFinite(o)&&k(a)&&k(i))return{x:s,y:o,width:a,height:i}}const n=oe(e.width),r=oe(e.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},Lt=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},Nt=e=>{const t=e.renderMode||"unknown",n=e.svgMarkup??"";if(!n){const r=[e.viewBox??"",e.width??"",e.height??""];return r.some(s=>s!=="")?`${t}:bounds:${r.join(":")}`:`${t}:no-svg`}return[t,Lt(n)].join(":")},Me=(e,t)=>{if(!k(t.width)||!k(t.height))return e;const n=e.width/e.height,r=t.width/t.height;if(n>r){const o=e.width/r;return{x:e.x,y:e.y-(o-e.height)/2,width:e.width,height:o}}const s=e.height*r;return{x:e.x-(s-e.width)/2,y:e.y,width:s,height:e.height}},xt=({currentBox:e,viewport:t,delta:n})=>!k(t.width)||!k(t.height)||!k(e.width)||!k(e.height)?e:{x:e.x-n.x/t.width*e.width,y:e.y-n.y/t.height*e.height,width:e.width,height:e.height},Tt=(e,t)=>{const n=t.x-e.x,r=t.y-e.y;return n*n+r*r>ie*ie},Pt=({currentBox:e,contentBox:t,viewport:n,pointer:r,zoomFactor:s,minScale:o,maxScale:a})=>{if(!k(n.width)||!k(n.height)||!k(s)||!k(e.width)||!k(e.height)||!k(t.width)||!k(t.height)||!k(o)||!k(a))return e;const i=Math.min(o,a),l=Math.max(o,a),d=Me(t,n),c=d.width/e.width,m=B(c*s,i,l),f=d.width/m,p=f/(e.width/e.height),h=B(r.x/n.width,0,1),v=B(r.y/n.height,0,1),A=e.x+h*e.width,w=e.y+v*e.height;return{x:A-h*f,y:w-v*p,width:f,height:p}},X=new WeakMap,Rt=e=>e instanceof HTMLElement?X.get(e)??null:null,_t=e=>e.querySelector('[data-markdown="mermaid-viewport"]')??e.querySelector('[data-markdown="mermaid"]'),se=e=>{const t=e.querySelector('[data-markdown="mermaid"] svg'),n=e.querySelector('[data-markdown="mermaid"]');return Nt({renderMode:e.getAttribute("data-mermaid-render"),svgMarkup:n?.getAttribute("data-md-original-svg")??t?.outerHTML??null,viewBox:t?.getAttribute("viewBox"),width:t?.getAttribute("width"),height:t?.getAttribute("height")})},R=e=>{const t=e.getBoundingClientRect();return{width:t.width,height:t.height}},It=(e,t)=>{const n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},Ft=e=>e instanceof Element&&!!e.closest('button, a, [role="button"]'),Ot=e=>{const t=_t(e),n=e.querySelector('[data-markdown="mermaid"] svg');if(!t||!n)return null;const r=Mt({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let s=r,o=null,a=null,i=null,l=null;const d=u=>{s=u,n.setAttribute("viewBox",St(u)),n.removeAttribute("width"),n.removeAttribute("height")},c=()=>{d(Me(r,R(t)))},m=(u,E)=>{d(Pt({currentBox:s,contentBox:r,viewport:R(t),pointer:u,zoomFactor:E,minScale:kt,maxScale:Et}))},f=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},ae)},p=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},1/ae)},h=u=>{!u.ctrlKey&&!u.metaKey||(u.preventDefault(),u.stopPropagation(),m(It(u,t),Math.pow(At,-u.deltaY)))},v=u=>{u.button!==0||Ft(u.target)||(o=u.pointerId,a={x:u.clientX,y:u.clientY},i=a,l!==null&&(window.clearTimeout(l),l=null),e.removeAttribute("data-mermaid-suppress-click"),t.setPointerCapture?.(u.pointerId),e.setAttribute("data-mermaid-panning","true"),u.preventDefault())},A=u=>{if(o!==u.pointerId||!i)return;const E={x:u.clientX,y:u.clientY};d(xt({currentBox:s,viewport:R(t),delta:{x:E.x-i.x,y:E.y-i.y}})),i=E,a&&Tt(a,E)&&e.setAttribute("data-mermaid-suppress-click","true"),u.preventDefault()},w=u=>{o===u.pointerId&&(t.releasePointerCapture?.(u.pointerId),o=null,a=null,i=null,e.removeAttribute("data-mermaid-panning"),e.hasAttribute("data-mermaid-suppress-click")&&(l=window.setTimeout(()=>{e.removeAttribute("data-mermaid-suppress-click"),l=null},Ct)))},b=()=>{c()};t.addEventListener("wheel",h,{passive:!1}),t.addEventListener("pointerdown",v),t.addEventListener("pointermove",A),t.addEventListener("pointerup",w),t.addEventListener("pointercancel",w),window.addEventListener("resize",b);const g=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return g?.observe(t),c(),{zoomIn:f,zoomOut:p,fit:c,cleanup:()=>{t.removeEventListener("wheel",h),t.removeEventListener("pointerdown",v),t.removeEventListener("pointermove",A),t.removeEventListener("pointerup",w),t.removeEventListener("pointercancel",w),window.removeEventListener("resize",b),g?.disconnect(),l!==null&&window.clearTimeout(l),e.removeAttribute("data-mermaid-panning"),e.removeAttribute("data-mermaid-suppress-click"),X.delete(e)}}},Dt=e=>{const t=new Map,n=new Map,r=()=>{for(const[o,a]of Array.from(t.entries())){const i=se(o);(!e.contains(o)||i!==n.get(o))&&(a.cleanup(),t.delete(o),n.delete(o))}for(const o of Array.from(e.querySelectorAll(I))){if(t.has(o)||o.querySelector('[data-markdown="mermaid"] svg')===null)continue;const a=Ot(o);a&&(t.set(o,a),n.set(o,se(o)),X.set(o,a))}},s=()=>{for(const o of t.values())o.cleanup();t.clear(),n.clear()};return r(),{refresh:r,cleanup:s}},x=e=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${e}"></use></svg>`,q={copy:x("file-copy"),check:x("check"),download:x("download"),zoomIn:x("add"),zoomOut:x("subtract"),fit:x("refresh")},Le="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)]",$=(e,t)=>{e.innerHTML=t},S=(e,t,n)=>{const r=document.createElement("button");return r.type="button",r.className=Le,r.setAttribute("data-md-action",n),r.setAttribute("title",t),r.setAttribute("aria-label",t),$(r,q[e]),r},Ne=e=>{const t=e.querySelector("[data-md-code-body]"),n=e.querySelector("pre"),r=e.querySelector("pre code"),s=e.querySelectorAll("[data-md-code-line-content]");e.setAttribute("data-code-wrap","true"),t?.classList.remove("overflow-x-auto"),t?.classList.add("overflow-x-hidden"),n?.classList.add("whitespace-pre-wrap","break-words"),r?.classList.add("whitespace-pre-wrap","break-words"),n&&(n.style.whiteSpace="pre-wrap",n.style.overflowWrap="anywhere"),r&&(r.style.whiteSpace="pre-wrap",r.style.overflowWrap="anywhere");for(const o of Array.from(s))o.style.whiteSpace="pre-wrap",o.style.overflowWrap="anywhere"},xe=e=>{const t=e.querySelector(":scope > code");if(!t||t.hasAttribute("data-md-code-lines"))return;const n=t.textContent??"",r=n.endsWith(`
|
|
2
2
|
`),s=r?n.slice(0,-1).split(`
|
|
3
3
|
`):n.split(`
|
|
4
4
|
`),o=s.length>0?s:[""],a=Array.from(t.children).filter(d=>d.classList.contains("line"));r&&a.length===o.length+1&&a.at(-1)?.textContent===""&&a.pop();const i=a.length===o.length,l=document.createDocumentFragment();o.forEach((d,c)=>{const m=document.createElement("span");m.setAttribute("data-md-code-line","");const f=document.createElement("span");f.setAttribute("data-md-code-line-number",""),f.setAttribute("aria-hidden","true"),f.textContent=String(c+1);const p=document.createElement("span");if(p.setAttribute("data-md-code-line-content",""),i){const h=a[c];h&&p.append(...Array.from(h.childNodes))}else p.textContent=d;if(m.append(f,p),l.appendChild(m),c<o.length-1||r){const h=document.createElement("span");h.setAttribute("data-md-code-line-break",""),h.textContent=`
|
|
5
5
|
`,l.appendChild(h)}}),t.replaceChildren(l),t.setAttribute("data-md-code-lines",""),t.toggleAttribute("data-md-code-trailing-newline",r)},Te=e=>{const t=Array.from(e.querySelectorAll("[data-md-code-line-content]"));if(t.length===0)return e.textContent??"";const n=t.map(r=>r.textContent??"").join(`
|
|
6
6
|
`);return e.hasAttribute("data-md-code-trailing-newline")?`${n}
|
|
7
|
-
`:n},qt=e=>{const t=e.querySelectorAll('[data-component="markdown-code"]');for(const n of Array.from(t)){const r=n.querySelector("pre");r&&xe(r),Ne(n)}},le=(e,t,n,r)=>{
|
|
7
|
+
`:n},qt=e=>{const t=e.querySelectorAll('[data-component="markdown-code"]');for(const n of Array.from(t)){const r=n.querySelector("pre");r&&xe(r),Ne(n)}},le=(e,t,n,r)=>{$(e,q.check),e.setAttribute("title",t),e.setAttribute("aria-label",t),window.setTimeout(()=>{$(e,q[n]),e.setAttribute("title",r),e.setAttribute("aria-label",r)},2e3)},$t=e=>{const t=e.querySelectorAll(":not(pre) > code");for(const n of Array.from(t))n.getAttribute("data-markdown")!=="inline-code"&&n.setAttribute("data-markdown","inline-code")},zt=(e,t)=>{const n=e.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const s=r.parentElement;if(!s||s.closest('[data-component="markdown-code"]'))continue;const o=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],a=r.getAttribute("data-md-lang")??o??"text",i=document.createElement("div");i.setAttribute("data-component","markdown-code"),i.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 d=document.createElement("span");d.className="font-mono text-[13px] text-muted-foreground",d.textContent=a;const c=S("copy",t.labels.copy,"copy-code");l.appendChild(d);const m=document.createElement("div");m.className="flex items-center gap-1",m.setAttribute("data-md-code-actions",""),m.appendChild(c),l.appendChild(m);const f=document.createElement("div");f.setAttribute("data-md-code-body",""),f.className="px-3 py-2.5 overflow-x-auto",s.replaceChild(i,r),r.style.margin="0",r.style.background="transparent",r.classList.add("min-w-0","w-full","flex-1"),t.deferCodeLineNumberSync||xe(r),f.appendChild(r),i.appendChild(l),i.appendChild(f),Ne(i)}},ce=e=>{const t=[],n=[],r=e.querySelectorAll("thead th");for(const o of Array.from(r))t.push((o.textContent??"").trim());const s=e.querySelectorAll("tbody tr");for(const o of Array.from(s)){const a=Array.from(o.querySelectorAll("td")).map(i=>(i.textContent??"").trim());a.length>0&&n.push(a)}return{headers:t,rows:n}},Ht=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,de=({headers:e,rows:t})=>[e,...t].map(n=>n.map(Ht).join(",")).join(`
|
|
8
8
|
`),Wt=({headers:e,rows:t})=>[e,...t].map(n=>n.join(" ")).join(`
|
|
9
9
|
`),ue=({headers:e,rows:t})=>{const n=`| ${e.join(" | ")} |`,r=`| ${e.map(()=>"---").join(" | ")} |`,s=t.map(o=>`| ${o.join(" | ")} |`).join(`
|
|
10
10
|
`);return`${n}
|
|
11
11
|
${r}
|
|
12
|
-
${s}`},me=(e,t)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${et}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",e);for(const r of t){const s=document.createElement("button");s.type="button",s.className=`w-full text-left ${tt}`,s.setAttribute("data-md-action",`${e}-${r.key}`),s.textContent=r.label,n.appendChild(s)}return n},Bt=(e,t)=>{const n=e.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 flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const a=document.createElement("div");a.className="flex items-center justify-end gap-1";const i=document.createElement("div");i.className="relative",i.appendChild(S("copy",t.copyTable,"table-copy-toggle")),i.appendChild(me("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const l=document.createElement("div");l.className="relative",l.appendChild(S("download",t.downloadTable,"table-download-toggle")),l.appendChild(me("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),a.appendChild(i),a.appendChild(l);const d=document.createElement("div");d.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const c=r.parentElement;if(!c)continue;c.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const f of Array.from(r.querySelectorAll("tr")))f.classList.add("border-b","border-border/60");const m=r.querySelector("tbody tr:last-child");m?.classList.remove("border-b"),m?.classList.add("border-0");for(const f of Array.from(r.querySelectorAll("th")))f.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const f of Array.from(r.querySelectorAll("td")))f.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground","last:border-r-0");d.appendChild(r),o.appendChild(a),o.appendChild(d)}},Vt=(e,t)=>{const n=e.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const s=r.parentElement;if(!s)continue;const o=(r.textContent??"").replace(/\s+$/,""),a=t.renderMermaid(o),i=document.createElement("div");i.setAttribute("data-markdown","mermaid-block"),i.setAttribute("data-md-source",o),i.className="group relative";const l=document.createElement("div");l.setAttribute("data-markdown","mermaid-scroll");const d=document.createElement("div");if(d.setAttribute("data-markdown","mermaid-toolbar"),d.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",a.svg){i.setAttribute("data-mermaid-render","svg");const m=document.createElement("div");m.setAttribute("data-markdown","mermaid-viewport");const f=document.createElement("div");if(f.setAttribute("data-markdown","mermaid"),f.setAttribute("data-md-original-svg",a.svg),f.innerHTML=a.svg,m.appendChild(f),l.appendChild(m),t.mermaidControls.showPanZoomControls&&(d.appendChild(S("zoomIn",t.labels.zoomInDiagram,"mermaid-zoom-in")),d.appendChild(S("zoomOut",t.labels.zoomOutDiagram,"mermaid-zoom-out")),d.appendChild(S("fit",t.labels.resetDiagramView,"mermaid-fit"))),t.mermaidControls.copy){const p=S("copy",t.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",o),d.appendChild(p)}if(t.mermaidControls.download){const p=S("download",t.labels.downloadDiagram,"mermaid-download");p.setAttribute("data-md-svg","1"),d.appendChild(p)}}else{i.setAttribute("data-mermaid-render","svg");const m=document.createElement("pre");if(m.setAttribute("data-markdown","mermaid-ascii"),m.textContent=o,l.appendChild(m),t.mermaidControls.copy){const f=S("copy",t.labels.copyDiagram,"mermaid-copy");f.setAttribute("data-md-source",o),d.appendChild(f)}}i.appendChild(l),i.appendChild(d);const c=s.parentElement;c&&c.replaceChild(i,s)}},Kt=(e,t)=>{const n=e.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-pichamber-file-link")==="true")continue;const s=r.getAttribute("href")??"";if(!ve(s))continue;r.setAttribute("data-md-link-decorated","true");const o=Qe(s);if(o){const a=document.createElement("span");a.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const i=document.createElement("img");i.src=o,i.alt="",i.setAttribute("aria-hidden","true"),i.loading="lazy",i.decoding="async",i.className="size-3.5 rounded-sm",i.addEventListener("error",()=>a.remove(),{once:!0}),a.appendChild(i),r.parentNode?.insertBefore(a,r)}if(t.onPreviewLoopback&&Je(s)){const a=document.createElement("button");a.type="button",a.className=`ml-1 align-middle ${Le}`,a.setAttribute("data-md-action","preview-loopback"),a.setAttribute("data-md-url",s),a.setAttribute("title",t.labels.previewTitle),a.setAttribute("aria-label",t.labels.previewLabel),z(a,q.download),r.parentNode?.insertBefore(a,r.nextSibling)}}},fe=(e,t)=>{zt(e),Vt(e,t),$t(e,t),Bt(e,t.labels),Kt(e,t)},pe=(e,t,n)=>{gt({filename:e,mimeType:n,data:t}).catch(r=>console.warn("[markdown] Download failed",r))},F=e=>{for(const t of Array.from(e.querySelectorAll("[data-md-menu]")))t.classList.add("hidden")},jt=(e,t)=>{const n=r=>{const s=r.target;if(!(s instanceof Element))return;const o=s.closest("[data-md-action]");if(!o){F(e);return}const a=o.getAttribute("data-md-action")??"";if(a==="copy-code"){const i=o.closest('[data-component="markdown-code"]')?.querySelector("code"),l=i?Te(i):"";l&&W(l).then(()=>le(o,t.labels.copied,"copy",t.labels.copy));return}if(a==="table-copy-toggle"||a==="table-download-toggle"){r.preventDefault();const i=o.parentElement?.querySelector("[data-md-menu]")??null,l=i?.classList.contains("hidden")??!1;F(e),i&&l&&i.classList.remove("hidden");return}if(a.startsWith("table-copy-")){const i=a.replace("table-copy-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const d=ce(l),c=i==="csv"?de(d):i==="tsv"?Wt(d):ue(d);W(c)}F(e);return}if(a.startsWith("table-download-")){const i=a.replace("table-download-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const d=ce(l),c=i==="csv"?de(d):ue(d);pe(i==="csv"?"table.csv":"table.md",c,i==="csv"?"text/csv":"text/markdown")}F(e);return}if(a==="mermaid-copy"){const i=o.getAttribute("data-md-source")??"";i&&W(i).then(()=>le(o,t.labels.copied,"copy",t.labels.copyDiagram));return}if(a==="mermaid-zoom-in"||a==="mermaid-zoom-out"||a==="mermaid-fit"){r.preventDefault();const i=o.closest('[data-markdown="mermaid-block"]'),l=Rt(i);a==="mermaid-zoom-in"?l?.zoomIn():a==="mermaid-zoom-out"?l?.zoomOut():l?.fit();return}if(a==="mermaid-download"){const i=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),l=i?.getAttribute("data-md-original-svg")??i?.innerHTML??"";l&&pe("diagram.svg",l,"image/svg+xml;charset=utf-8");return}if(a==="preview-loopback"){r.preventDefault();const i=o.getAttribute("data-md-url")??"";i&&t.onPreviewLoopback?.(i);return}};return e.addEventListener("click",n),()=>e.removeEventListener("click",n)},he=(e,t,n)=>{let r=0;for(const o of e){const a=r+o.data.length;if(t<a||t===a&&n==="left")return{node:o,offset:Math.max(0,t-r)};r=a}const s=e.at(-1);return s?{node:s,offset:s.data.length}:null},Zt=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),ge=Array.from(Zt).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Ut=e=>nt(e),Xt=e=>rt(e),$=e=>{let t=(e||"").trim();return t?((t.startsWith("`")&&t.endsWith("`")||t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1).trim()),t=t.replace(/[.,;!?]+$/g,""),t.endsWith(")")&&!t.includes("(")&&(t=t.slice(0,-1)),t.endsWith("]")&&!t.includes("[")&&(t=t.slice(0,-1)),t):""},O=e=>{let t=$(e);if(!t)return"";const n=t.indexOf(";");n>=0&&(t=t.slice(0,n)),t=t.replace(/#.*$/,"");const r=t.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(t=r[1]??t);const s=ge.length>0?t.match(new RegExp(`^(.*(?:/|^)(${ge})):.*$`,"i")):null;return s&&(t=s[1]??t),$(t)},Pe=e=>{const t=$(e);if(!t)return null;const n=t.indexOf(";"),r=n>=0?$(t.slice(0,n)):t;if(!r)return null;const s=r.match(/^(.*?):(\d+)-(\d+)$/);if(s){const l=O(s[1]??""),d=Number.parseInt(s[2]??"",10),c=Number.parseInt(s[3]??"",10);return!l||!Number.isFinite(d)||!Number.isFinite(c)||c<d?null:{path:l,line:d,endLine:c}}const o=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const l=O(o[1]??""),d=Number.parseInt(o[2]??"",10),c=o[3]?Number.parseInt(o[3],10):void 0;return!l||!Number.isFinite(d)?null:{path:l,line:d,column:Number.isFinite(c??Number.NaN)?c:void 0}}const a=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(a){const l=O(a[1]??""),d=Number.parseInt(a[2]??"",10),c=a[3]?Number.parseInt(a[3],10):void 0;return!l||!Number.isFinite(d)?null:{path:l,line:d,column:Number.isFinite(c??Number.NaN)?c:void 0}}const i=O(r);return i?{path:i}:null},V=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,Re=({containerRef:e,enabled:t})=>{y.useEffect(()=>{if(t===!1)return;const n=e.current;if(!n)return;const r=s=>{if(s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.altKey||s.shiftKey)return;const o=s.target;if(!(o instanceof Element))return;const a=o.closest("a[href]");if(!(a instanceof HTMLAnchorElement)||a.getAttribute("data-pichamber-file-link")==="true")return;const i=a.getAttribute("href")??"";ve(i)&&(s.preventDefault(),s.stopPropagation(),ot(i))};return n.addEventListener("click",r),()=>{n.removeEventListener("click",r)}},[e,t])},be='[data-pichamber-file-link="true"]',_e="data-pichamber-block-path-token",Ie=`[${_e}]`,T="data-pichamber-block-paths-scanned",Gt=2e5,Yt=4,Qt=1e3,Jt=80,we=160,L=new Map;let D=0;const ye=[],er=()=>Qt,tr=()=>Jt,rr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),G=e=>Ut(e),nr=e=>Xt(e),or=(e,t)=>st(e,t),ar=e=>{const t=e.split("/").filter(Boolean).pop()??"";return!t||t.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(t)},Fe=e=>{if(!e||e.startsWith("--")||e.includes("://")||/[<>]/.test(e)||/\s{2,}/.test(e))return!1;const t=G(e),n=t.split("/").filter(Boolean).pop()??t;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return rr.has(r)||r.startsWith(".")&&r.length>1?!0:ar(t)},Oe=e=>{const t=Pe(e);return t?Fe(t.path):!1},ir=e=>{const t=e.querySelectorAll(Ie);for(const r of Array.from(t))r.replaceWith(e.ownerDocument.createTextNode(r.textContent??""));const n=e.querySelectorAll(`code[${T}]`);for(const r of Array.from(n))r.removeAttribute(T),r.normalize()},K=e=>{if(e.tagName.toLowerCase()==="a"){const t=e.getAttribute("href")?.trim();if(t&&Oe(t))return t}return(e.textContent||"").trim()},sr=e=>{const t=e.querySelectorAll("pre code");if(t.length===0)return;const n=e.ownerDocument;if(n)for(const r of Array.from(t)){if(r.getAttribute(T)==="true")continue;if((r.textContent??"").length>Gt){r.setAttribute(T,"true");continue}const s=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let a=s.nextNode();for(;a;){const c=a;c.parentElement?.closest("[data-md-code-line-number]")||o.push(c),a=s.nextNode()}const i=Te(r);if(!i.includes(".")){r.setAttribute(T,"true");continue}V.lastIndex=0;const l=[];let d=V.exec(i);for(;d;){const c=d[0];c&&Oe(c)&&l.push({start:d.index,end:d.index+c.length,raw:c}),d=V.exec(i)}for(const{start:c,end:m,raw:f}of l.reverse()){const p=he(o,c,"right"),h=he(o,m,"left");if(!p||!h)continue;const A=n.createRange();A.setStart(p.node,p.offset),A.setEnd(h.node,h.offset);const v=n.createElement("span");v.setAttribute(_e,"true"),v.textContent=f,A.deleteContents(),A.insertNode(v)}r.setAttribute(T,"true")}},j=(e,t)=>{const n=Pe(e);if(!n||!Fe(n.path))return null;const r=nr(n.path)?G(n.path):or(t,n.path);return r?{...n,resolvedPath:r}:null},lr=e=>{const t=G(e);if(!t)return Promise.resolve(!1);const n=L.get(t);if(n)return L.delete(t),L.set(t,n),n;const r=new Promise(o=>{const a=()=>{D+=1,Ge(`/api/fs/stat?path=${encodeURIComponent(t)}&optional=true`,{method:"GET",cache:"no-store"}).then(async i=>{if(!i.ok){o(!1);return}const l=await i.json().catch(()=>null);o(l?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{D=Math.max(0,D-1),ye.shift()?.()})};if(D<Yt){a();return}ye.push(a)}),s=er();for(;L.size>=s;){const o=L.keys().next().value;if(typeof o!="string")break;L.delete(o)}return L.set(t,r),r},cr=(e,t)=>e||it(e,t),De=({containerRef:e,effectiveDirectory:t,editor:n,preferRuntimeEditor:r,enabled:s})=>{const o=y.useRef(null);y.useEffect(()=>{const a=e.current;if(!a)return;let i=!1;const l=tr(),d=s&&!bt(),c=g=>{g.removeAttribute("data-pichamber-file-link"),g.removeAttribute("data-pichamber-file-ref"),g.removeAttribute("data-pichamber-file-path"),g.getAttribute("title")==="Open file"&&g.removeAttribute("title"),g.tagName.toLowerCase()!=="a"&&(g.removeAttribute("role"),g.removeAttribute("tabindex"))},m=()=>{const g=a.querySelectorAll(be);for(const b of Array.from(g))c(b);ir(a)};if(!d){m();return}const f=(g=0)=>{if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){p();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{i||p()})},g)},p=()=>{d&&sr(a);const g=a.querySelectorAll(`[data-markdown="inline-code"], a, ${Ie}`);let b=0;for(const u of Array.from(g)){const E=K(u),C=j(E,t);if(c(u),!C||b>=l)continue;b+=1,(Ue()&&Xe()&&!re(C.resolvedPath,t)?Promise.resolve(!0):lr(C.resolvedPath)).then(Ke=>{if(i||!Ke||!a.contains(u))return;const J=K(u),H=j(J,t);!H||H.resolvedPath!==C.resolvedPath||(u.setAttribute("data-pichamber-file-link","true"),u.setAttribute("data-pichamber-file-ref",J),u.setAttribute("data-pichamber-file-path",H.resolvedPath),u.setAttribute("title","Open file"),u.tagName.toLowerCase()!=="a"&&(u.setAttribute("role","button"),u.setAttribute("tabindex","0")))})}},h=async g=>{const b=g.getAttribute("data-pichamber-file-ref")||K(g),u=j(b,t);if(!u)return;const E=cr(t,u.resolvedPath);re(u.resolvedPath,t)||await at(u.resolvedPath,t);const C=Ae.getState();Number.isFinite(u.line??Number.NaN)?C.openContextFileAtLine(E,u.resolvedPath,Math.max(1,Math.trunc(u.line)),Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):1):C.openContextFile(E,u.resolvedPath)},A=g=>{const b=g.target;if(!(b instanceof Element))return;const u=b.closest(be);u instanceof HTMLElement&&(g.preventDefault(),g.stopPropagation(),h(u))},v=g=>{if(g.key!=="Enter"&&g.key!==" ")return;const b=g.target;!(b instanceof HTMLElement)||b.getAttribute("data-pichamber-file-link")!=="true"||(g.preventDefault(),g.stopPropagation(),h(b))};f(we);const w=new MutationObserver(()=>{f(we)});return w.observe(a,{childList:!0,subtree:!0}),a.addEventListener("click",A),a.addEventListener("keydown",v),()=>{i=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,w.disconnect(),a.removeEventListener("click",A),a.removeEventListener("keydown",v)}},[e,n,t,r,s])},P={download:!0,copy:!0,showPanZoomControls:!0},qe=!0,ze=({containerRef:e,onShowPopup:t,enableFullscreen:n,enablePanZoom:r,allowMermaidWheelEvents:s})=>{y.useEffect(()=>{const o=e.current;if(!o)return;const a=l=>{if(!t)return;const d=l.target;if(!(d instanceof Element)||d.closest('button, a, [role="button"]'))return;const c=d.closest(I);if(!c)return;if(c instanceof HTMLElement&&c.hasAttribute("data-mermaid-suppress-click")){c.removeAttribute("data-mermaid-suppress-click");return}const f=Array.from(o.querySelectorAll(I)).indexOf(c);if(f<0)return;const p=c instanceof HTMLElement?c.getAttribute("data-md-source"):null;if(!p||p.trim().length===0)return;const h=`Diagram ${f+1}`;t({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}})},i=l=>{if(s||(l.ctrlKey||l.metaKey)&&r)return;const d=l.target;!(d instanceof Element)||!d.closest(I)||l.stopPropagation()};return o.addEventListener("click",a),o.addEventListener("wheel",i,{capture:!0,passive:!0}),()=>{o.removeEventListener("click",a),o.removeEventListener("wheel",i,!0)}},[s,e,n,r,t])},N=new Map,dr=100,ur=(e,t)=>{const n=N.get(e);if(n)return N.delete(e),N.set(e,n),n;const r=t();if(N.set(e,r),N.size>dr){const s=N.keys().next().value;s&&N.delete(s)}return r},mr=e=>({bg:e.colors.surface.elevated,fg:e.colors.surface.foreground,line:e.colors.interactive.border,accent:e.colors.primary.base,muted:e.colors.surface.mutedForeground,surface:e.colors.surface.muted,border:e.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),$e=()=>{const e=ct(),t=te(!1),n=te(!0);return e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?n:t)},fr=e=>{const t=e.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return t?e.slice(t[0].length):e},He=(e,t,n,r=P)=>{const s=y.useMemo(()=>({copy:"Copy code",copied:"Copied",copyTable:"Copy table",downloadTable:"Download table",copyDiagram:"Copy source",downloadDiagram:"Download SVG",zoomInDiagram:"Zoom in",zoomOutDiagram:"Zoom out",resetDiagramView:"Reset view",previewLabel:"Preview",previewTitle:"Open preview pane"}),[]);return y.useMemo(()=>{const o=mr(e),a=e.metadata?.id??"theme";return{labels:s,mermaidControls:r,deferCodeLineNumberSync:t,renderMermaid:l=>ur(`${a}:svg:${l}`,()=>{try{return{svg:Ze(l,o)}}catch{return{}}}),onPreviewLoopback:n}},[e,s,r,t,n])},We=e=>{e.style.display="contents",e.style.width="",e.style.minWidth="",e.style.maxWidth=""},Z=(e,t)=>{We(e);const n=pt(t);let r=e.querySelector(":scope > [data-md-live]");const s=r?.hasAttribute("data-md-live-pre")===!0;(!r||s!==n)&&(e.replaceChildren(),r=document.createElement(n?"div":"p"),r.setAttribute("data-md-live",""),n&&r.setAttribute("data-md-live-pre",""),r.className=n?"w-full min-w-0 whitespace-pre-wrap break-words":"w-full min-w-0 break-words",r.appendChild(document.createTextNode("")),e.appendChild(r));const o=r.firstChild;if(!(o instanceof globalThis.Text)){r.replaceChildren(document.createTextNode(t));return}if(t.startsWith(o.data)){const a=t.slice(o.data.length);a.length>0&&o.appendData(a);return}o.data=t},Be=({containerRef:e,text:t,streaming:n,cacheKey:r,syntaxVars:s,ctx:o})=>{y.useEffect(()=>{yt()},[]);const a=y.useRef(null),i=y.useRef(null),l=y.useRef(r);l.current!==r&&(l.current=r,i.current=null);const d=y.useCallback(()=>{const c=e.current;if(c){if(!a.current){if(!M(c))return;a.current=Dt(c);return}a.current.refresh()}},[e]);y.useLayoutEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;if(m&&t&&m.childNodes.length===0){const f=document.createElement("div");if(f.setAttribute("data-md-block",""),f.style.display="contents",n){Z(f,t),m.appendChild(f);return}f.innerHTML=dt(t),fe(f,o),m.appendChild(f),M(f)&&d()}},[e,t,n,o,d]),y.useEffect(()=>()=>{a.current?.cleanup(),a.current=null},[]),y.useEffect(()=>{const c=e.current;if(!c)return;const m=c.querySelector("[data-markdown-content]")??c;let f=!0;if(n&&i.current){const p=ut(r).update(t);if(mt(i.current,p)){const h=p[p.length-1],A=m.querySelectorAll(":scope > [data-md-block]")[p.length-1];if(h&&A){Z(A,h.raw),A.setAttribute("data-md-id",`live:${p.length-1}`),i.current=i.current.map((v,w)=>w===p.length-1?{...v,raw:h.raw,id:`live:${w}`,mode:"live"}:v);return}}}return ft(t,n,r).then(p=>{if(!f)return;const h=Array.from(m.querySelectorAll(":scope > [data-md-block]"));p.forEach((w,g)=>{let b=h[g];if(b||(b=document.createElement("div"),b.setAttribute("data-md-block",""),b.style.display="contents",m.appendChild(b)),w.mode==="live"){Z(b,w.raw),b.setAttribute("data-md-id",w.id);return}if(We(b),b.getAttribute("data-md-id")===w.id)return;const u=document.createElement("div");u.innerHTML=w.html,fe(u,o);const E=M(b),C=M(u);je(b,u,{childrenOnly:!0,onBeforeElUpdated:(Y,Q)=>!Y.isEqualNode(Q)}),b.setAttribute("data-md-id",w.id),(E||C||M(b))&&d()});const A=M(m);let v=!1;for(let w=h.length-1;w>=p.length;w-=1){const g=h[w];g&&M(g)&&(v=!0),g?.remove()}(v||h.length>p.length&&A)&&d(),i.current=p}),()=>{f=!1}},[e,t,n,r,o,d]),y.useEffect(()=>{const c=e.current;if(c)return jt(c,o)},[e,o]),y.useEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;if(m)for(const[f,p]of Object.entries(s))m.style.setProperty(f,p)},[e,s]),y.useEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;m&&(o.deferCodeLineNumberSync||qt(m))},[e,o.deferCodeLineNumberSync])},Ve=(e,t)=>U("w-full min-w-0",e==="tool"?"markdown-content markdown-tool":e==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",t&&"markdown-streaming"),pr=({content:e,part:t,messageId:n,isAnimated:r=!0,skipFadeIn:s=!1,className:o,isStreaming:a=!1,disableStreamAnimation:i=!1,variant:l="assistant",onShowPopup:d,enableFileReferences:c=!0})=>{ee("ui.markdown_renderer.render"),a&&ee("ui.markdown_renderer.render.streaming"),Ye("ui.markdown_renderer.content_len",e.length);const m=$e(),{editor:f}=ke(),p=y.useRef(null),h=Ee()??"",A=Ae(C=>C.openContextPreview),v=y.useCallback(C=>{h&&A(h,C)},[h,A]),w=a&&!i;ze({containerRef:p,onShowPopup:d,enableFullscreen:qe,enablePanZoom:P.showPanZoomControls}),De({containerRef:p,effectiveDirectory:h,editor:f,preferRuntimeEditor:!1,enabled:c&&!a}),Re({containerRef:p});const g=y.useMemo(()=>Ce(m),[m]),b=He(m,w,h?v:void 0,P),u=`markdown-${t?.id?`part-${t.id}`:`message-${n}`}`;Be({containerRef:p,text:e,streaming:w,cacheKey:u,syntaxVars:g,ctx:b});const E=_.jsx("div",{className:U("break-words w-full min-w-0",o),ref:p,children:_.jsx("div",{className:Ve(l,w),"data-markdown-content":!0})});return r?_.jsx(lt,{skipAnimation:s,children:E},u):E},Qr=y.memo(pr,(e,t)=>e.content===t.content&&e.isStreaming===t.isStreaming&&e.disableStreamAnimation===t.disableStreamAnimation&&e.variant===t.variant&&e.isAnimated===t.isAnimated&&e.skipFadeIn===t.skipFadeIn&&e.className===t.className&&e.messageId===t.messageId&&e.onShowPopup===t.onShowPopup&&e.enableFileReferences===t.enableFileReferences&&e.part?.id===t.part?.id),hr=({content:e,className:t,variant:n="assistant",disableLinkSafety:r,stripFrontmatter:s=!1,onShowPopup:o,mermaidControls:a=P,allowMermaidWheelEvents:i=!1,enableFileReferences:l=!0})=>{const{editor:d}=ke(),c=$e(),m=y.useRef(null),f=Ee()??"",p=y.useMemo(()=>s?fr(e):e,[e,s]);ze({containerRef:m,onShowPopup:o,enableFullscreen:qe,enablePanZoom:a.showPanZoomControls,allowMermaidWheelEvents:i}),De({containerRef:m,effectiveDirectory:f,editor:d,preferRuntimeEditor:!1,enabled:l}),Re({containerRef:m,enabled:!r});const h=y.useMemo(()=>Ce(c),[c]),A=He(c,!1,void 0,a);return Be({containerRef:m,text:p,streaming:!1,cacheKey:`simple:${n}`,syntaxVars:h,ctx:A}),_.jsx("div",{className:U("break-words w-full min-w-0",t),ref:m,children:_.jsx("div",{className:Ve(n),"data-markdown-content":!0})})},Jr=y.memo(hr,(e,t)=>{const n=e.mermaidControls??P,r=t.mermaidControls??P;return e.content===t.content&&e.variant===t.variant&&e.className===t.className&&e.disableLinkSafety===t.disableLinkSafety&&e.stripFrontmatter===t.stripFrontmatter&&e.onShowPopup===t.onShowPopup&&n.download===r.download&&n.copy===r.copy&&n.showPanZoomControls===r.showPanZoomControls&&e.allowMermaidWheelEvents===t.allowMermaidWheelEvents&&e.enableFileReferences===t.enableFileReferences});export{Qr as MarkdownRenderer,Jr as SimpleMarkdownRenderer};
|
|
12
|
+
${s}`},me=(e,t)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${et}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",e);for(const r of t){const s=document.createElement("button");s.type="button",s.className=`w-full text-left ${tt}`,s.setAttribute("data-md-action",`${e}-${r.key}`),s.textContent=r.label,n.appendChild(s)}return n},Bt=(e,t)=>{const n=e.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 flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const a=document.createElement("div");a.className="flex items-center justify-end gap-1";const i=document.createElement("div");i.className="relative",i.appendChild(S("copy",t.copyTable,"table-copy-toggle")),i.appendChild(me("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const l=document.createElement("div");l.className="relative",l.appendChild(S("download",t.downloadTable,"table-download-toggle")),l.appendChild(me("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),a.appendChild(i),a.appendChild(l);const d=document.createElement("div");d.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const c=r.parentElement;if(!c)continue;c.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const f of Array.from(r.querySelectorAll("tr")))f.classList.add("border-b","border-border/60");const m=r.querySelector("tbody tr:last-child");m?.classList.remove("border-b"),m?.classList.add("border-0");for(const f of Array.from(r.querySelectorAll("th")))f.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const f of Array.from(r.querySelectorAll("td")))f.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground","last:border-r-0");d.appendChild(r),o.appendChild(a),o.appendChild(d)}},Vt=(e,t)=>{const n=e.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const s=r.parentElement;if(!s)continue;const o=(r.textContent??"").replace(/\s+$/,""),a=t.renderMermaid(o),i=document.createElement("div");i.setAttribute("data-markdown","mermaid-block"),i.setAttribute("data-md-source",o),i.className="group relative";const l=document.createElement("div");l.setAttribute("data-markdown","mermaid-scroll");const d=document.createElement("div");if(d.setAttribute("data-markdown","mermaid-toolbar"),d.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",a.svg){i.setAttribute("data-mermaid-render","svg");const m=document.createElement("div");m.setAttribute("data-markdown","mermaid-viewport");const f=document.createElement("div");if(f.setAttribute("data-markdown","mermaid"),f.setAttribute("data-md-original-svg",a.svg),f.innerHTML=a.svg,m.appendChild(f),l.appendChild(m),t.mermaidControls.showPanZoomControls&&(d.appendChild(S("zoomIn",t.labels.zoomInDiagram,"mermaid-zoom-in")),d.appendChild(S("zoomOut",t.labels.zoomOutDiagram,"mermaid-zoom-out")),d.appendChild(S("fit",t.labels.resetDiagramView,"mermaid-fit"))),t.mermaidControls.copy){const p=S("copy",t.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",o),d.appendChild(p)}if(t.mermaidControls.download){const p=S("download",t.labels.downloadDiagram,"mermaid-download");p.setAttribute("data-md-svg","1"),d.appendChild(p)}}else{i.setAttribute("data-mermaid-render","svg");const m=document.createElement("pre");if(m.setAttribute("data-markdown","mermaid-ascii"),m.textContent=o,l.appendChild(m),t.mermaidControls.copy){const f=S("copy",t.labels.copyDiagram,"mermaid-copy");f.setAttribute("data-md-source",o),d.appendChild(f)}}i.appendChild(l),i.appendChild(d);const c=s.parentElement;c&&c.replaceChild(i,s)}},jt=(e,t)=>{const n=e.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-pichamber-file-link")==="true")continue;const s=r.getAttribute("href")??"";if(!Ae(s))continue;r.setAttribute("data-md-link-decorated","true");const o=Je(s);if(o){const a=document.createElement("span");a.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const i=document.createElement("img");i.src=o,i.alt="",i.setAttribute("aria-hidden","true"),i.loading="lazy",i.decoding="async",i.className="size-3.5 rounded-sm",i.addEventListener("error",()=>a.remove(),{once:!0}),a.appendChild(i),r.parentNode?.insertBefore(a,r)}if(t.onPreviewLoopback&&Qe(s)){const a=document.createElement("button");a.type="button",a.className=`ml-1 align-middle ${Le}`,a.setAttribute("data-md-action","preview-loopback"),a.setAttribute("data-md-url",s),a.setAttribute("title",t.labels.previewTitle),a.setAttribute("aria-label",t.labels.previewLabel),$(a,q.download),r.parentNode?.insertBefore(a,r.nextSibling)}}},fe=(e,t)=>{$t(e),Vt(e,t),zt(e,t),Bt(e,t.labels),jt(e,t)},pe=(e,t,n)=>{bt({filename:e,mimeType:n,data:t}).catch(r=>console.warn("[markdown] Download failed",r))},F=e=>{for(const t of Array.from(e.querySelectorAll("[data-md-menu]")))t.classList.add("hidden")},Kt=(e,t)=>{const n=r=>{const s=r.target;if(!(s instanceof Element))return;const o=s.closest("[data-md-action]");if(!o){F(e);return}const a=o.getAttribute("data-md-action")??"";if(a==="copy-code"){const i=o.closest('[data-component="markdown-code"]')?.querySelector("code"),l=i?Te(i):"";l&&W(l).then(()=>le(o,t.labels.copied,"copy",t.labels.copy));return}if(a==="table-copy-toggle"||a==="table-download-toggle"){r.preventDefault();const i=o.parentElement?.querySelector("[data-md-menu]")??null,l=i?.classList.contains("hidden")??!1;F(e),i&&l&&i.classList.remove("hidden");return}if(a.startsWith("table-copy-")){const i=a.replace("table-copy-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const d=ce(l),c=i==="csv"?de(d):i==="tsv"?Wt(d):ue(d);W(c)}F(e);return}if(a.startsWith("table-download-")){const i=a.replace("table-download-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const d=ce(l),c=i==="csv"?de(d):ue(d);pe(i==="csv"?"table.csv":"table.md",c,i==="csv"?"text/csv":"text/markdown")}F(e);return}if(a==="mermaid-copy"){const i=o.getAttribute("data-md-source")??"";i&&W(i).then(()=>le(o,t.labels.copied,"copy",t.labels.copyDiagram));return}if(a==="mermaid-zoom-in"||a==="mermaid-zoom-out"||a==="mermaid-fit"){r.preventDefault();const i=o.closest('[data-markdown="mermaid-block"]'),l=Rt(i);a==="mermaid-zoom-in"?l?.zoomIn():a==="mermaid-zoom-out"?l?.zoomOut():l?.fit();return}if(a==="mermaid-download"){const i=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),l=i?.getAttribute("data-md-original-svg")??i?.innerHTML??"";l&&pe("diagram.svg",l,"image/svg+xml;charset=utf-8");return}if(a==="preview-loopback"){r.preventDefault();const i=o.getAttribute("data-md-url")??"";i&&t.onPreviewLoopback?.(i);return}};return e.addEventListener("click",n),()=>e.removeEventListener("click",n)},he=(e,t,n)=>{let r=0;for(const o of e){const a=r+o.data.length;if(t<a||t===a&&n==="left")return{node:o,offset:Math.max(0,t-r)};r=a}const s=e.at(-1);return s?{node:s,offset:s.data.length}:null},Zt=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),be=Array.from(Zt).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Ut=e=>nt(e),Xt=e=>rt(e),z=e=>{let t=(e||"").trim();return t?((t.startsWith("`")&&t.endsWith("`")||t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1).trim()),t=t.replace(/[.,;!?]+$/g,""),t.endsWith(")")&&!t.includes("(")&&(t=t.slice(0,-1)),t.endsWith("]")&&!t.includes("[")&&(t=t.slice(0,-1)),t):""},O=e=>{let t=z(e);if(!t)return"";const n=t.indexOf(";");n>=0&&(t=t.slice(0,n)),t=t.replace(/#.*$/,"");const r=t.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(t=r[1]??t);const s=be.length>0?t.match(new RegExp(`^(.*(?:/|^)(${be})):.*$`,"i")):null;return s&&(t=s[1]??t),z(t)},Pe=e=>{const t=z(e);if(!t)return null;const n=t.indexOf(";"),r=n>=0?z(t.slice(0,n)):t;if(!r)return null;const s=r.match(/^(.*?):(\d+)-(\d+)$/);if(s){const l=O(s[1]??""),d=Number.parseInt(s[2]??"",10),c=Number.parseInt(s[3]??"",10);return!l||!Number.isFinite(d)||!Number.isFinite(c)||c<d?null:{path:l,line:d,endLine:c}}const o=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const l=O(o[1]??""),d=Number.parseInt(o[2]??"",10),c=o[3]?Number.parseInt(o[3],10):void 0;return!l||!Number.isFinite(d)?null:{path:l,line:d,column:Number.isFinite(c??Number.NaN)?c:void 0}}const a=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(a){const l=O(a[1]??""),d=Number.parseInt(a[2]??"",10),c=a[3]?Number.parseInt(a[3],10):void 0;return!l||!Number.isFinite(d)?null:{path:l,line:d,column:Number.isFinite(c??Number.NaN)?c:void 0}}const i=O(r);return i?{path:i}:null},V=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,Re=({containerRef:e,enabled:t})=>{y.useEffect(()=>{if(t===!1)return;const n=e.current;if(!n)return;const r=s=>{if(s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.altKey||s.shiftKey)return;const o=s.target;if(!(o instanceof Element))return;const a=o.closest("a[href]");if(!(a instanceof HTMLAnchorElement)||a.getAttribute("data-pichamber-file-link")==="true")return;const i=a.getAttribute("href")??"";Ae(i)&&(s.preventDefault(),s.stopPropagation(),ot(i))};return n.addEventListener("click",r),()=>{n.removeEventListener("click",r)}},[e,t])},ge='[data-pichamber-file-link="true"]',_e="data-pichamber-block-path-token",Ie=`[${_e}]`,T="data-pichamber-block-paths-scanned",Gt=2e5,Yt=4,Jt=1e3,Qt=80,we=160,L=new Map;let D=0;const ye=[],er=()=>Jt,tr=()=>Qt,rr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),G=e=>Ut(e),nr=e=>Xt(e),or=(e,t)=>st(e,t),ar=e=>{const t=e.split("/").filter(Boolean).pop()??"";return!t||t.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(t)},Fe=e=>{if(!e||e.startsWith("--")||e.includes("://")||/[<>]/.test(e)||/\s{2,}/.test(e))return!1;const t=G(e),n=t.split("/").filter(Boolean).pop()??t;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return rr.has(r)||r.startsWith(".")&&r.length>1?!0:ar(t)},Oe=e=>{const t=Pe(e);return t?Fe(t.path):!1},ir=e=>{const t=e.querySelectorAll(Ie);for(const r of Array.from(t))r.replaceWith(e.ownerDocument.createTextNode(r.textContent??""));const n=e.querySelectorAll(`code[${T}]`);for(const r of Array.from(n))r.removeAttribute(T),r.normalize()},j=e=>{if(e.tagName.toLowerCase()==="a"){const t=e.getAttribute("href")?.trim();if(t&&Oe(t))return t}return(e.textContent||"").trim()},sr=e=>{const t=e.querySelectorAll("pre code");if(t.length===0)return;const n=e.ownerDocument;if(n)for(const r of Array.from(t)){if(r.getAttribute(T)==="true")continue;if((r.textContent??"").length>Gt){r.setAttribute(T,"true");continue}const s=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let a=s.nextNode();for(;a;){const c=a;c.parentElement?.closest("[data-md-code-line-number]")||o.push(c),a=s.nextNode()}const i=Te(r);if(!i.includes(".")){r.setAttribute(T,"true");continue}V.lastIndex=0;const l=[];let d=V.exec(i);for(;d;){const c=d[0];c&&Oe(c)&&l.push({start:d.index,end:d.index+c.length,raw:c}),d=V.exec(i)}for(const{start:c,end:m,raw:f}of l.reverse()){const p=he(o,c,"right"),h=he(o,m,"left");if(!p||!h)continue;const v=n.createRange();v.setStart(p.node,p.offset),v.setEnd(h.node,h.offset);const A=n.createElement("span");A.setAttribute(_e,"true"),A.textContent=f,v.deleteContents(),v.insertNode(A)}r.setAttribute(T,"true")}},K=(e,t)=>{const n=Pe(e);if(!n||!Fe(n.path))return null;const r=nr(n.path)?G(n.path):or(t,n.path);return r?{...n,resolvedPath:r}:null},lr=e=>{const t=G(e);if(!t)return Promise.resolve(!1);const n=L.get(t);if(n)return L.delete(t),L.set(t,n),n;const r=new Promise(o=>{const a=()=>{D+=1,Ge(`/api/fs/stat?path=${encodeURIComponent(t)}&optional=true`,{method:"GET",cache:"no-store"}).then(async i=>{if(!i.ok){o(!1);return}const l=await i.json().catch(()=>null);o(l?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{D=Math.max(0,D-1),ye.shift()?.()})};if(D<Yt){a();return}ye.push(a)}),s=er();for(;L.size>=s;){const o=L.keys().next().value;if(typeof o!="string")break;L.delete(o)}return L.set(t,r),r},cr=(e,t)=>e||it(e,t),De=({containerRef:e,effectiveDirectory:t,editor:n,preferRuntimeEditor:r,enabled:s})=>{const o=y.useRef(null);y.useEffect(()=>{const a=e.current;if(!a)return;let i=!1;const l=tr(),d=s&&!gt(),c=b=>{b.removeAttribute("data-pichamber-file-link"),b.removeAttribute("data-pichamber-file-ref"),b.removeAttribute("data-pichamber-file-path"),b.getAttribute("title")==="Open file"&&b.removeAttribute("title"),b.tagName.toLowerCase()!=="a"&&(b.removeAttribute("role"),b.removeAttribute("tabindex"))},m=()=>{const b=a.querySelectorAll(ge);for(const g of Array.from(b))c(g);ir(a)};if(!d){m();return}const f=(b=0)=>{if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){p();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{i||p()})},b)},p=()=>{d&&sr(a);const b=a.querySelectorAll(`[data-markdown="inline-code"], a, ${Ie}`);let g=0;for(const u of Array.from(b)){const E=j(u),C=K(E,t);if(c(u),!C||g>=l)continue;g+=1,(Ue()&&Xe()&&!re(C.resolvedPath,t)?Promise.resolve(!0):lr(C.resolvedPath)).then(je=>{if(i||!je||!a.contains(u))return;const Q=j(u),H=K(Q,t);!H||H.resolvedPath!==C.resolvedPath||(u.setAttribute("data-pichamber-file-link","true"),u.setAttribute("data-pichamber-file-ref",Q),u.setAttribute("data-pichamber-file-path",H.resolvedPath),u.setAttribute("title","Open file"),u.tagName.toLowerCase()!=="a"&&(u.setAttribute("role","button"),u.setAttribute("tabindex","0")))})}},h=async b=>{const g=b.getAttribute("data-pichamber-file-ref")||j(b),u=K(g,t);if(!u)return;const E=cr(t,u.resolvedPath);re(u.resolvedPath,t)||await at(u.resolvedPath,t);const C=ve.getState();Number.isFinite(u.line??Number.NaN)?C.openContextFileAtLine(E,u.resolvedPath,Math.max(1,Math.trunc(u.line)),Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):1):C.openContextFile(E,u.resolvedPath)},v=b=>{const g=b.target;if(!(g instanceof Element))return;const u=g.closest(ge);u instanceof HTMLElement&&(b.preventDefault(),b.stopPropagation(),h(u))},A=b=>{if(b.key!=="Enter"&&b.key!==" ")return;const g=b.target;!(g instanceof HTMLElement)||g.getAttribute("data-pichamber-file-link")!=="true"||(b.preventDefault(),b.stopPropagation(),h(g))};f(we);const w=new MutationObserver(()=>{f(we)});return w.observe(a,{childList:!0,subtree:!0}),a.addEventListener("click",v),a.addEventListener("keydown",A),()=>{i=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,w.disconnect(),a.removeEventListener("click",v),a.removeEventListener("keydown",A)}},[e,n,t,r,s])},P={download:!0,copy:!0,showPanZoomControls:!0},qe=!0,$e=({containerRef:e,onShowPopup:t,enableFullscreen:n,enablePanZoom:r,allowMermaidWheelEvents:s})=>{y.useEffect(()=>{const o=e.current;if(!o)return;const a=l=>{if(!t)return;const d=l.target;if(!(d instanceof Element)||d.closest('button, a, [role="button"]'))return;const c=d.closest(I);if(!c)return;if(c instanceof HTMLElement&&c.hasAttribute("data-mermaid-suppress-click")){c.removeAttribute("data-mermaid-suppress-click");return}const f=Array.from(o.querySelectorAll(I)).indexOf(c);if(f<0)return;const p=c instanceof HTMLElement?c.getAttribute("data-md-source"):null;if(!p||p.trim().length===0)return;const h=`Diagram ${f+1}`;t({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}})},i=l=>{if(s||(l.ctrlKey||l.metaKey)&&r)return;const d=l.target;!(d instanceof Element)||!d.closest(I)||l.stopPropagation()};return o.addEventListener("click",a),o.addEventListener("wheel",i,{capture:!0,passive:!0}),()=>{o.removeEventListener("click",a),o.removeEventListener("wheel",i,!0)}},[s,e,n,r,t])},N=new Map,dr=100,ur=(e,t)=>{const n=N.get(e);if(n)return N.delete(e),N.set(e,n),n;const r=t();if(N.set(e,r),N.size>dr){const s=N.keys().next().value;s&&N.delete(s)}return r},mr=e=>({bg:e.colors.surface.elevated,fg:e.colors.surface.foreground,line:e.colors.interactive.border,accent:e.colors.primary.base,muted:e.colors.surface.mutedForeground,surface:e.colors.surface.muted,border:e.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),ze=()=>{const e=ct(),t=te(!1),n=te(!0);return e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?n:t)},fr=e=>{const t=e.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return t?e.slice(t[0].length):e},He=(e,t,n,r=P)=>{const s=y.useMemo(()=>({copy:"Copy code",copied:"Copied",copyTable:"Copy table",downloadTable:"Download table",copyDiagram:"Copy source",downloadDiagram:"Download SVG",zoomInDiagram:"Zoom in",zoomOutDiagram:"Zoom out",resetDiagramView:"Reset view",previewLabel:"Preview",previewTitle:"Open preview pane"}),[]);return y.useMemo(()=>{const o=mr(e),a=e.metadata?.id??"theme";return{labels:s,mermaidControls:r,deferCodeLineNumberSync:t,renderMermaid:l=>ur(`${a}:svg:${l}`,()=>{try{return{svg:Ze(l,o)}}catch{return{}}}),onPreviewLoopback:n}},[e,s,r,t,n])},We=e=>{e.style.display="contents",e.style.width="",e.style.minWidth="",e.style.maxWidth=""},Z=(e,t)=>{We(e);const n=pt(t);let r=e.querySelector(":scope > [data-md-live]");const s=r?.hasAttribute("data-md-live-pre")===!0;(!r||s!==n)&&(e.replaceChildren(),r=document.createElement(n?"div":"p"),r.setAttribute("data-md-live",""),n&&r.setAttribute("data-md-live-pre",""),r.className=n?"w-full min-w-0 whitespace-pre-wrap break-words":"w-full min-w-0 break-words",r.appendChild(document.createTextNode("")),e.appendChild(r));const o=r.firstChild;if(!(o instanceof globalThis.Text)){r.replaceChildren(document.createTextNode(t));return}if(t.startsWith(o.data)){const a=t.slice(o.data.length);a.length>0&&o.appendData(a);return}o.data=t},Be=({containerRef:e,text:t,streaming:n,cacheKey:r,syntaxVars:s,ctx:o})=>{y.useEffect(()=>{yt()},[]);const a=y.useRef(null),i=y.useRef(null),l=y.useRef(r);l.current!==r&&(l.current=r,i.current=null);const d=y.useCallback(()=>{const c=e.current;if(c){if(!a.current){if(!M(c))return;a.current=Dt(c);return}a.current.refresh()}},[e]);y.useLayoutEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;if(m&&t&&m.childNodes.length===0){const f=document.createElement("div");if(f.setAttribute("data-md-block",""),f.style.display="contents",n){Z(f,t),m.appendChild(f);return}f.innerHTML=dt(t),fe(f,o),m.appendChild(f),M(f)&&d()}},[e,t,n,o,d]),y.useEffect(()=>()=>{a.current?.cleanup(),a.current=null},[]),y.useEffect(()=>{const c=e.current;if(!c)return;const m=c.querySelector("[data-markdown-content]")??c;let f=!0;if(n&&i.current){const p=ut(r).update(t);if(mt(i.current,p)){const h=p[p.length-1],v=m.querySelectorAll(":scope > [data-md-block]")[p.length-1];if(h&&v){Z(v,h.raw),v.setAttribute("data-md-id",`live:${p.length-1}`),i.current=i.current.map((A,w)=>w===p.length-1?{...A,raw:h.raw,id:`live:${w}`,mode:"live"}:A);return}}}return ft(t,n,r).then(p=>{if(!f)return;const h=Array.from(m.querySelectorAll(":scope > [data-md-block]"));p.forEach((w,b)=>{let g=h[b];if(g||(g=document.createElement("div"),g.setAttribute("data-md-block",""),g.style.display="contents",m.appendChild(g)),w.mode==="live"){Z(g,w.raw),g.setAttribute("data-md-id",w.id);return}if(We(g),g.getAttribute("data-md-id")===w.id)return;const u=document.createElement("div");u.innerHTML=w.html,fe(u,o);const E=M(g),C=M(u);Ke(g,u,{childrenOnly:!0,onBeforeElUpdated:(Y,J)=>!Y.isEqualNode(J)}),g.setAttribute("data-md-id",w.id),(E||C||M(g))&&d()});const v=M(m);let A=!1;for(let w=h.length-1;w>=p.length;w-=1){const b=h[w];b&&M(b)&&(A=!0),b?.remove()}(A||h.length>p.length&&v)&&d(),i.current=p}),()=>{f=!1}},[e,t,n,r,o,d]),y.useEffect(()=>{const c=e.current;if(c)return Kt(c,o)},[e,o]),y.useEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;if(m)for(const[f,p]of Object.entries(s))m.style.setProperty(f,p)},[e,s]),y.useEffect(()=>{const c=e.current,m=c?.querySelector("[data-markdown-content]")??c;m&&(o.deferCodeLineNumberSync||qt(m))},[e,o.deferCodeLineNumberSync])},Ve=(e,t)=>U("w-full min-w-0",e==="tool"?"markdown-content markdown-tool":e==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",t&&"markdown-streaming"),pr=({content:e,part:t,messageId:n,isAnimated:r=!0,skipFadeIn:s=!1,className:o,isStreaming:a=!1,disableStreamAnimation:i=!1,variant:l="assistant",onShowPopup:d,enableFileReferences:c=!0})=>{ee("ui.markdown_renderer.render"),a&&ee("ui.markdown_renderer.render.streaming"),Ye("ui.markdown_renderer.content_len",e.length);const m=ze(),{editor:f}=ke(),p=y.useRef(null),h=Ee()??"",v=ve(C=>C.openContextPreview),A=y.useCallback(C=>{h&&v(h,C)},[h,v]),w=a&&!i;$e({containerRef:p,onShowPopup:d,enableFullscreen:qe,enablePanZoom:P.showPanZoomControls}),De({containerRef:p,effectiveDirectory:h,editor:f,preferRuntimeEditor:!1,enabled:c&&!a}),Re({containerRef:p});const b=y.useMemo(()=>Ce(m),[m]),g=He(m,w,h?A:void 0,P),u=`markdown-${t?.id?`part-${t.id}`:`message-${n}`}`;Be({containerRef:p,text:e,streaming:w,cacheKey:u,syntaxVars:b,ctx:g});const E=_.jsx("div",{className:U("break-words w-full min-w-0",o),ref:p,children:_.jsx("div",{className:Ve(l,w),"data-markdown-content":!0})});return r?_.jsx(lt,{skipAnimation:s,children:E},u):E},Jr=y.memo(pr,(e,t)=>e.content===t.content&&e.isStreaming===t.isStreaming&&e.disableStreamAnimation===t.disableStreamAnimation&&e.variant===t.variant&&e.isAnimated===t.isAnimated&&e.skipFadeIn===t.skipFadeIn&&e.className===t.className&&e.messageId===t.messageId&&e.onShowPopup===t.onShowPopup&&e.enableFileReferences===t.enableFileReferences&&e.part?.id===t.part?.id),hr=({content:e,className:t,variant:n="assistant",disableLinkSafety:r,stripFrontmatter:s=!1,onShowPopup:o,mermaidControls:a=P,allowMermaidWheelEvents:i=!1,enableFileReferences:l=!0})=>{const{editor:d}=ke(),c=ze(),m=y.useRef(null),f=Ee()??"",p=y.useMemo(()=>s?fr(e):e,[e,s]);$e({containerRef:m,onShowPopup:o,enableFullscreen:qe,enablePanZoom:a.showPanZoomControls,allowMermaidWheelEvents:i}),De({containerRef:m,effectiveDirectory:f,editor:d,preferRuntimeEditor:!1,enabled:l}),Re({containerRef:m,enabled:!r});const h=y.useMemo(()=>Ce(c),[c]),v=He(c,!1,void 0,a);return Be({containerRef:m,text:p,streaming:!1,cacheKey:`simple:${n}`,syntaxVars:h,ctx:v}),_.jsx("div",{className:U("break-words w-full min-w-0",t),ref:m,children:_.jsx("div",{className:Ve(n),"data-markdown-content":!0})})},Qr=y.memo(hr,(e,t)=>{const n=e.mermaidControls??P,r=t.mermaidControls??P;return e.content===t.content&&e.variant===t.variant&&e.className===t.className&&e.disableLinkSafety===t.disableLinkSafety&&e.stripFrontmatter===t.stripFrontmatter&&e.onShowPopup===t.onShowPopup&&n.download===r.download&&n.copy===r.copy&&n.showPanZoomControls===r.showPanZoomControls&&e.allowMermaidWheelEvents===t.allowMermaidWheelEvents&&e.enableFileReferences===t.enableFileReferences});export{Jr as MarkdownRenderer,Qr as SimpleMarkdownRenderer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aS as j,aT as y,aU as D}from"./useAppFontEffects-CV5UyTRw.js";import{g as k,a as C}from"./web-components-BpncHjnV.js";import{M as P,G as O,u as L,W as A,a as M,b as R,n as F,t as H}from"./Virtualizer-PxblpQn6.js";import{j as a}from"./vendor-boot-D-KEJjsM.js";import{V as T,F as _}from"./VirtualizedFileDiff-BGZiLPe_.js";import{a as w}from"./vendor-react-Bz1tRBxM.js";function N({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function U(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:V(n,e.startContentIndex)}}function V(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const s=e.hunkContent[l];n+=s.type==="context"?s.lines:s.deletions+s.additions}return n}function z(e){const t=j(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:s,renderHeaderMetadata:x,renderAnnotation:d,renderGutterUtility:u,renderMergeConflictUtility:o,lineAnnotations:f,getHoveredLine:p,getInstance:m}){const g=n?.(e),c=l?.(e),i=s?.(e),v=x?.(e);return a.jsxs(a.Fragment,{children:[g!=null?a.jsx("div",{slot:y,children:g}):a.jsxs(a.Fragment,{children:[c!=null&&a.jsx("div",{slot:"header-prefix",children:c}),i!=null&&a.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&a.jsx("div",{slot:"header-metadata",children:v})]}),d!=null&&f?.map((r,h)=>a.jsx("div",{slot:k(r),children:d(r)},h)),t!=null&&o!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return a.jsx("div",{slot:h,style:P,children:o(r,m)},h)}),u!=null&&a.jsx("div",{slot:"gutter-utility-slot",style:O,children:u(p)})]})}function b(e,t){const n=U(e,t);return n!=null?N({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const S=typeof window>"u"?w.useEffect:w.useLayoutEffect;function G({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:s,metrics:x,hasGutterRenderUtility:d,hasCustomHeader:u,disableWorkerPool:o,contentEditable:f}){const p=L(),m=l!==void 0,g=w.useContext(A),c=M(),i=w.useRef(null),v=R(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");p!=null?i.current=new T(E({controlledSelection:m,contentEditable:f,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:d,options:t}),p,x,o?void 0:g,!0):i.current=new _(E({controlledSelection:m,contentEditable:f,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:d,options:t}),o?void 0:g,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:s})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return S(()=>{const{current:r}=i;if(r==null)return;const h=E({controlledSelection:m,contentEditable:f,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:d,options:t}),I=!C(r.options,h);r.setOptions(h),r.render({forceRender:I,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),S(()=>{if(f&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[f,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function E({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:s,hasGutterRenderUtility:x}){const d=n&&s,u=t||x||l;if(!u&&!d)return e;let o={...e};return u&&(o={...o,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),d&&(o={...o,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),o}function Y({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:s,className:x,style:d,prerenderedHTML:u,renderAnnotation:o,renderCustomHeader:f,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=q(e),{ref:h,getHoveredLine:I}=G({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:s,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:f!=null,disableWorkerPool:i,contentEditable:v});return a.jsx(D,{ref:h,className:x,style:d,children:H($({fileDiff:r,renderCustomHeader:f,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderAnnotation:o,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>z(e),[e])}export{Y as P};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import{aX as Se,j as z}from"./vendor-boot-D-KEJjsM.js";import{a as f,R as ae}from"./vendor-react-Bz1tRBxM.js";import{a as Ee}from"./web-components-BpncHjnV.js";import{e as ce}from"./computeVirtualFileMetrics-DJQqK49u.js";import{V as ke,F as xe}from"./VirtualizedFileDiff-BGZiLPe_.js";import{v as Te,aj as Oe}from"./useAppFontEffects-CV5UyTRw.js";import{P as ze,S as De}from"./StickyHorizontalScrollbar-CMbTn5WQ.js";import{u as Ce}from"./runtimeEndpointReset-Dwj-jCDS.js";import{ensurePierreThemeRegistered as ue,getResolvedShikiTheme as he}from"./appThemeRegistry-Ca8eGRB9.js";import{a as de,c as fe}from"./index-CKKWVoND.js";const J=new Set;let ne=null;function E(n){J.add(n),ne??=requestAnimationFrame(be)}function be(n){const e=new Set(J);J.clear();for(const t of e)try{t(n)}catch(r){console.error(r)}J.size>0?ne=requestAnimationFrame(be):ne=null}function pe({scrollTop:n,scrollHeight:e,height:t,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:s}){const h=t+s*2,d=r?t+i*2:h;if(e=Math.max(e,d),h>=e||r){const p=Math.max(n-i,0),y=Math.min(n+d,e);return{top:p,bottom:Math.max(y,p)}}let c=n+t/2-h/2,m=c+h;return c<0&&(c=0),m>e&&(m=e),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(m,e),c))}}function Ie(n,e){return n==null||e==null?n===e:n.top===e.top&&n.bottom===e.bottom}const ye=1e3,Me=ye*4,He=[0,1e-6,.99999,1],Pe={overscrollSize:ye,intersectionObserverMargin:Me,resizeDebugging:!1};let X=0,Le=-1;var _e=class x{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++Le}`;config;type="simple";intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...Pe,...e}}setup(e,t){if(this.root==null){this.root=e,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:He,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),e instanceof Document?this.setupWindow():this.setupElement(t),window.__INSTANCE=this,window.__TOGGLE=()=>{x.__STOP?(x.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:x.__lastScrollPosition}),E(this.computeRenderRangeAndEmit)):(x.__lastScrollPosition=this.getScrollTop(),x.__STOP=!0)};for(const[r,i]of this.connectQueue.entries())this.connect(r,i);this.connectQueue.clear(),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}}instanceChanged(e,t){this.instancesChanged.add(e),t&&this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=pe({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){const r=this.getScrollTop(),i=this.getHeight(),s=this.config.intersectionObserverMargin,h=r-s,d=r+i+s;return!(e<h-t||e>d)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(const r of e){const i=r.borderBoxSize[0].blockSize;this.root instanceof Document?i!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:i-X,newSize:i}),X=i)):r.target===this.root?i!==this.height&&(this.heightDirty=!0,t=!0):r.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:i-X,newSize:i}),X=i))}t&&E(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw new Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw new Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+U(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw new Error("Virtualizer.connect: instance is already connected...");return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){const t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),E(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{x.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,E(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{x.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{x.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(x.__STOP)return;const e=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;let t=this.instancesChanged.size>0;if(this.instancesChanged.size===0){const s=pe({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&Ie(this.windowSpecs,s)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty)return;this.windowSpecs=s}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const r=this.getScrollAnchor(this.height),i=new Set;for(const s of e?this.observers.values():this.visibleInstances.values())s.onRender(e)&&i.add(s);for(const s of this.instancesChanged)i.has(s)||s.onRender(e)&&i.add(s);this.scrollFix(r);for(const s of i)s.reconcileHeights();t||=this.instancesChanged.size>0,t&&this.markDOMDirty(),(t||e)&&E(this.computeRenderRangeAndEmit),i.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;const t=this.getScrollContainerElement(),{lineIndex:r,lineOffset:i,fileElement:s,fileOffset:h,fileTypeOffset:d}=e;if(r!=null&&i!=null){const m=s.shadowRoot?.querySelector(`[data-line][data-line-index="${r}"]`);if(m instanceof HTMLElement){const p=U(m,t);if(p!==i){const y=p-i;this.applyScrollFix(y)}return}}const c=U(s,t);if(d==="top")c!==h&&this.applyScrollFix(c-h);else{const m=c+s.getBoundingClientRect().height;m!==h&&this.applyScrollFix(m-h)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(e){const t=this.getScrollContainerElement();let r;for(const[i]of this.visibleInstances.entries()){const s=U(i,t),h=s+i.offsetHeight;let d,c;h<=0?(d=h,c="bottom"):(d=s,c="top");let m,p;if(h>0&&s<e)for(const w of i.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(w instanceof HTMLElement))continue;const W=w.dataset.lineIndex;if(W==null)continue;const D=U(w,t);if(!(D<0)){m=W,p=D;break}}if(r?.lineOffset!=null&&p==null)continue;let y=!1;(r==null||p!=null&&(r.lineOffset==null||p<r.lineOffset)||p==null&&r.lineOffset==null&&(d>=0&&(r.fileOffset<0||d<r.fileOffset)||d<0&&r.fileOffset<0&&d>r.fileOffset))&&(y=!0),y&&(r={fileElement:i,fileTypeOffset:c,fileOffset:d,lineIndex:m,lineOffset:p})}return r}handleIntersectionChange=e=>{this.scrollDirty=!0;for(const{target:t,isIntersecting:r}of e){if(!(t instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const i=this.observers.get(t);i!=null&&(r&&!this.visibleInstances.has(t)?(i.setVisibility(!0),this.visibleInstances.set(t,i),this.visibleInstancesDirty=!0):!r&&this.visibleInstances.has(t)&&(i.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&E(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function U(n,e){const t=n.getBoundingClientRect(),r=e?.getBoundingClientRect().top??0;return t.top-r}const ge=5e5,Fe=`
|
|
2
|
+
:host {
|
|
3
|
+
font-family: var(--font-mono);
|
|
4
|
+
font-size: var(--text-code);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
pre, [data-code] {
|
|
8
|
+
font-family: var(--font-mono);
|
|
9
|
+
font-size: var(--text-code);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* Mobile touch selection support */
|
|
13
|
+
[data-line-number] {
|
|
14
|
+
touch-action: manipulation;
|
|
15
|
+
-webkit-tap-highlight-color: transparent;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* Ensure interactive line numbers work on touch */
|
|
20
|
+
pre[data-interactive-line-numbers] [data-line-number] {
|
|
21
|
+
touch-action: manipulation;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* With wrapping on, a line's later rows hang 4ch in from its first row, so a
|
|
25
|
+
continuation never starts at the code edge where the next line does. The
|
|
26
|
+
+/- marker is absolutely placed, so it stays put, but it is an inline-block
|
|
27
|
+
that would inherit the negative indent and push its glyph out of view. */
|
|
28
|
+
[data-overflow="wrap"] [data-line] {
|
|
29
|
+
padding-inline-start: calc(2ch + 4ch);
|
|
30
|
+
text-indent: -4ch;
|
|
31
|
+
}
|
|
32
|
+
[data-overflow="wrap"] [data-line]:before {
|
|
33
|
+
text-indent: 0;
|
|
34
|
+
}
|
|
35
|
+
`,me=`
|
|
36
|
+
${Fe}
|
|
37
|
+
|
|
38
|
+
:host {
|
|
39
|
+
--diffs-bg-separator-override: var(--surface-elevated);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[data-diff-header],
|
|
43
|
+
[data-diff] {
|
|
44
|
+
[data-separator] {
|
|
45
|
+
height: 24px !important;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[data-separator="line-info-basic"] {
|
|
50
|
+
height: 24px !important;
|
|
51
|
+
background: var(--diffs-bg) !important;
|
|
52
|
+
position: relative;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
[data-diff-type="single"] [data-gutter],
|
|
56
|
+
[data-diff-type="split"] [data-deletions] [data-gutter] {
|
|
57
|
+
[data-separator-wrapper] {
|
|
58
|
+
position: absolute;
|
|
59
|
+
left: 100%;
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
gap: unset;
|
|
63
|
+
width: max-content;
|
|
64
|
+
background: transparent;
|
|
65
|
+
color: var(--diffs-fg-number);
|
|
66
|
+
font-family: var(--diffs-header-font-family, var(--font-sans));
|
|
67
|
+
font-size: 0.75rem;
|
|
68
|
+
line-height: 1;
|
|
69
|
+
margin-left: calc(-2ch - 2px);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
[data-separator-wrapper][data-separator-multi-button] {
|
|
73
|
+
margin-left: calc(-3ch - 2px);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
[data-expand-button],
|
|
77
|
+
[data-separator-content] {
|
|
78
|
+
display: block;
|
|
79
|
+
align-self: unset;
|
|
80
|
+
min-width: unset;
|
|
81
|
+
min-height: unset;
|
|
82
|
+
padding: 0;
|
|
83
|
+
flex-shrink: 0;
|
|
84
|
+
grid-column: unset;
|
|
85
|
+
border: none;
|
|
86
|
+
width: auto;
|
|
87
|
+
height: auto;
|
|
88
|
+
background-color: transparent;
|
|
89
|
+
color: inherit;
|
|
90
|
+
font: inherit;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[data-expand-button]:not([data-expand-all-button]) {
|
|
94
|
+
&[data-expand-down]::before {
|
|
95
|
+
content: '\\2191';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&[data-expand-up]::before {
|
|
99
|
+
content: '\\2193';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
&[data-expand-both]::before {
|
|
103
|
+
content: '\\2195';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
svg {
|
|
107
|
+
display: none;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
[data-separator-content] {
|
|
112
|
+
background: transparent;
|
|
113
|
+
margin-left: calc(2px + 1ch);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
[data-expand-all-button] {
|
|
117
|
+
position: relative;
|
|
118
|
+
margin-left: 14px;
|
|
119
|
+
text-transform: lowercase;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
[data-expand-all-button]::before {
|
|
123
|
+
content: '';
|
|
124
|
+
display: block;
|
|
125
|
+
position: absolute;
|
|
126
|
+
top: 50%;
|
|
127
|
+
left: -8px;
|
|
128
|
+
margin-top: -1px;
|
|
129
|
+
width: 3px;
|
|
130
|
+
height: 3px;
|
|
131
|
+
border-radius: 2px;
|
|
132
|
+
background-color: var(--diffs-fg-number);
|
|
133
|
+
pointer-events: none;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
[data-separator-content]:hover,
|
|
137
|
+
[data-expand-button]:hover,
|
|
138
|
+
[data-expand-all-button]:hover {
|
|
139
|
+
color: var(--diffs-fg);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
[data-expand-all-button]:hover {
|
|
143
|
+
text-decoration: underline;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
`;function Ae(n){let e=2166136261;for(let t=0;t<n.length;t+=1)e^=n.charCodeAt(t),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)}function ve(n){const e=n.length>400?`${n.slice(0,200)}${n.slice(-200)}`:n;return`${n.length}:${Ae(e)}`}const Ve=n=>n==="auto"||n==="scroll"||n==="overlay",$e=n=>{let e=n?.parentElement??null;for(;e;){const t=window.getComputedStyle(e);if(Ve(t.overflowY))return e;e=e.parentElement}return null},qe=(n,e)=>{if(!n||!e||typeof window>"u")return()=>{};const t=$e(n);if(!t)return()=>{};const r=e.getBoundingClientRect().height;if(!r)return()=>{};const i=n.getBoundingClientRect().top-t.getBoundingClientRect().top,s=e.style.minHeight;e.style.minHeight=`${Math.ceil(r)}px`;let h=!1;return()=>{if(h)return;h=!0,e.style.minHeight=s;const c=n.getBoundingClientRect().top-t.getBoundingClientRect().top-i;c&&(t.scrollTop+=c)}},We=(n,e)=>{if(typeof window>"u")return()=>{};let t=null,r=null,i=!1;const s=()=>{i||(r?.disconnect(),r=null,t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>{i||e()})}))},h=()=>n.querySelector("diffs-container")?.shadowRoot??void 0,d=(c=h())=>!!c?.querySelector("[data-line]");return d()?s():typeof MutationObserver<"u"?(r=new MutationObserver(()=>{const c=h();if(c){if(d(c)){s();return}r?.disconnect(),r=new MutationObserver(()=>{d(c)&&s()}),r.observe(c,{childList:!0,subtree:!0})}}),r.observe(n,{childList:!0,subtree:!0})):t=window.requestAnimationFrame(s),()=>{i=!0,r?.disconnect(),t!==null&&window.cancelAnimationFrame(t)}},Z=new WeakMap,Be={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function Ne(n){const e=n.closest("[data-diff-virtual-root]");if(e instanceof HTMLElement){const t=e.querySelector("[data-diff-virtual-content]");return{key:e,root:e,content:t instanceof HTMLElement?t:void 0}}return{key:document,root:document,content:void 0}}function je(n){if(typeof document>"u")return null;const e=Ne(n);let t=Z.get(e.key);if(!t){const i=new _e;i.setup(e.root,e.content),t={virtualizer:i,refs:0},Z.set(e.key,t)}t.refs+=1;let r=!1;return{virtualizer:t.virtualizer,root:e.root,release:()=>{if(r)return;r=!0;const i=Z.get(e.key);i&&(i.refs-=1,!(i.refs>0)&&(i.virtualizer.cleanUp(),Z.delete(e.key)))}}}const Ue=(n,e,t)=>{if(typeof window>"u")return()=>{};const r=[],i=()=>{try{n.rerender()}catch{}const s=e?.root;s instanceof HTMLElement?s.dispatchEvent(new Event("scroll",{bubbles:!1})):document.dispatchEvent(new Event("scroll",{bubbles:!1})),window.dispatchEvent(new Event("resize")),t()};return r.push(window.requestAnimationFrame(i)),r.push(window.requestAnimationFrame(()=>{r.push(window.requestAnimationFrame(i))})),()=>{for(const s of r)window.cancelAnimationFrame(s)}},nt=({original:n,modified:e,fileDiff:t,language:r,fileName:i,renderSideBySide:s,wrapLines:h,layout:d="fill",enableGutterUtility:c=!1,enableLineSelection:m=!1,onGutterUtilityClick:p,onLineSelectionEnd:y,lineAnnotations:w,renderAnnotation:W})=>{const D=Te(),C=D?.currentTheme.metadata.variant==="dark",_=D?.availableThemes.find(o=>o.metadata.id===D.lightThemeId)??de(!1),F=D?.availableThemes.find(o=>o.metadata.id===D.darkThemeId)??de(!0);ue(_),ue(F);const B=`${_.metadata.id}:${F.metadata.id}:${C?"dark":"light"}`,N=f.useMemo(()=>{if(t){const o=t.deletionLines.reduce((a,u)=>a+u.length,0),l=t.additionLines.reduce((a,u)=>a+u.length,0);return Math.max(o,l)>ge}return Math.max(n.length,e.length)>ge},[t,e.length,n.length]),K=f.useRef(null),A=f.useRef(null),V=f.useRef(null),j=f.useRef(null),ee=f.useRef(null),te=f.useRef(null),re=f.useRef(void 0),Q=f.useRef(void 0),Y=f.useRef(void 0),G=f.useRef(void 0),[,se]=ae.useReducer(o=>o+1,0),$=Ce(N?"unified":s?"split":"unified"),I=f.useRef(new Map),ie=f.useRef(W);ie.current=W;const oe=o=>`${o.side}:${o.lineNumber}`,le=f.useCallback(o=>{if(typeof document>"u")return;const l=`${o.side}:${o.lineNumber}`;let a=I.current.get(l);if(!a){const u=document.createElement("div");u.setAttribute("data-pichamber-line-annotation",l),a={root:Se.createRoot(u),element:u},I.current.set(l,a)}return a.root.render(ie.current?.(o)??null),a.element},[]);f.useEffect(()=>{if(!w){for(const[,a]of I.current)a.root.unmount();I.current.clear();return}const o=new Set(w.map(oe));for(const[a,u]of I.current)o.has(a)||(u.root.unmount(),I.current.delete(a));const l=ie.current;if(l)for(const a of w){const u=I.current.get(oe(a));u&&u.root.render(l(a))}},[w]),f.useEffect(()=>{const o=I.current;return()=>{for(const l of o.values())l.root.unmount();o.clear()}},[]);const T=f.useMemo(()=>he(_),[_]),O=f.useMemo(()=>he(F),[F]);ae.useLayoutEffect(()=>{const o=K.current;if(!o)return;const l=o.querySelector("diffs-container");if(!l)return;const a=C?O:T,u=(we,Re)=>we.colors?.[Re],R=u(T,"terminal.ansiGreen"),v=u(T,"terminal.ansiRed"),b=u(T,"terminal.ansiBlue"),P=u(O,"terminal.ansiGreen"),k=u(O,"terminal.ansiRed"),M=u(O,"terminal.ansiBlue");l.style.setProperty("--shiki-light",T.fg),l.style.setProperty("--shiki-light-bg",T.bg),R&&l.style.setProperty("--shiki-light-addition-color",R),v&&l.style.setProperty("--shiki-light-deletion-color",v),b&&l.style.setProperty("--shiki-light-modified-color",b),l.style.setProperty("--shiki-dark",O.fg),l.style.setProperty("--shiki-dark-bg",O.bg),P&&l.style.setProperty("--shiki-dark-addition-color",P),k&&l.style.setProperty("--shiki-dark-deletion-color",k),M&&l.style.setProperty("--shiki-dark-modified-color",M),l.style.setProperty("--diffs-bg",a.bg),l.style.setProperty("--diffs-fg",a.fg);const S=C?P:R,L=C?k:v,q=C?M:b;S&&l.style.setProperty("--diffs-addition-color-override",S),L&&l.style.setProperty("--diffs-deletion-color-override",L),q&&l.style.setProperty("--diffs-modified-color-override",q);const g=l.shadowRoot?.querySelector("pre");g&&(g.style.setProperty("--shiki-light",T.fg),g.style.setProperty("--shiki-light-bg",T.bg),R&&g.style.setProperty("--shiki-light-addition-color",R),v&&g.style.setProperty("--shiki-light-deletion-color",v),b&&g.style.setProperty("--shiki-light-modified-color",b),g.style.setProperty("--shiki-dark",O.fg),g.style.setProperty("--shiki-dark-bg",O.bg),P&&g.style.setProperty("--shiki-dark-addition-color",P),k&&g.style.setProperty("--shiki-dark-deletion-color",k),M&&g.style.setProperty("--shiki-dark-modified-color",M),g.style.setProperty("--diffs-bg",a.bg),g.style.setProperty("--diffs-fg",a.fg),S&&g.style.setProperty("--diffs-addition-color-override",S),L&&g.style.setProperty("--diffs-deletion-color-override",L),q&&g.style.setProperty("--diffs-modified-color-override",q))},[O,B,C,T]);const H=f.useMemo(()=>({theme:{dark:F.metadata.id,light:_.metadata.id},themeType:C?"dark":"light",diffStyle:s?"split":"unified",diffIndicators:"classic",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:N?0:1e3,maxLineLengthForHighlighting:N?1:1e3,tokenizeMaxLineLength:N?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:h?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:m,enableGutterUtility:c,enableHoverUtility:!1,...p?{onGutterUtilityClick:p}:{},...y?{onLineSelectionEnd:y}:{},renderAnnotation:le,unsafeCSS:d==="inline"?`${me}
|
|
147
|
+
${ze}`:me}),[le,F.metadata.id,c,m,C,N,d,_.metadata.id,p,y,s,h]);return f.useEffect(()=>{const o=A.current;return()=>{V.current?.cleanUp(),V.current=null,j.current?.release(),j.current=null,ee.current=null,te.current=null,re.current=void 0,Q.current=void 0,Y.current=void 0,G.current=void 0,o&&(o.innerHTML="")}},[]),f.useEffect(()=>{if(typeof window>"u")return;const o=A.current,l=K.current;if(!o||!$)return;const a=qe(l,o);let u=j.current;u||(u=je(o),j.current=u),j.current=u;const R=u?.virtualizer??null,v=t?void 0:{name:i||"",contents:n,lang:r,cacheKey:`old:${B}:${i}:${ve(n)}`},b=t?void 0:{name:i||"",contents:e,lang:r,cacheKey:`new:${B}:${i}:${ve(e)}`},P=t?Q.current!==t:Q.current!==void 0||!v||!b||!Y.current||!G.current||!ce(Y.current,v)||!ce(G.current,b),k=V.current,M=!!(k&&(ee.current!==R||te.current!==$||R&&(re.current!==H.hunkSeparators||P)));M&&(k?.cleanUp(),V.current=null,o.innerHTML="");let S=V.current;const L=!M&&k?!Ee(k.options,H):!1;if(S?S.setOptions(H):(S=u?new ke(H,u.virtualizer,Be,$):new xe(H,$),V.current=S),ee.current=R,te.current=$,re.current=R?H.hunkSeparators:void 0,Q.current=t,Y.current=v,G.current=b,t)S.render({fileDiff:t,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}});else{if(!v||!b)return;S.render({oldFile:v,newFile:b,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}})}const q=We(o,()=>{a(),Ue(S,u,se)});return()=>{q(),a()}},[B,t,i,r,w,e,H,n,$]),f.useEffect(()=>{const o=A.current;if(!o)return;let l=null,a=null;const R=setTimeout(()=>{const v=o.querySelector("diffs-container");if(!(v instanceof HTMLElement))return;const b=v.shadowRoot;l=new MutationObserver(()=>{a&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{se(),a=null})}),l.observe(v,{childList:!0,subtree:!0}),b&&l.observe(b,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(R),a&&cancelAnimationFrame(a),l?.disconnect()}},[B,i]),typeof window>"u"?null:d==="fill"?z.jsx("div",{className:fe("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:z.jsx("div",{className:"flex-1 relative min-h-0",children:z.jsx(Oe,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:z.jsx("div",{ref:K,className:"size-full relative",children:z.jsx("div",{ref:A,className:"size-full"})})})})}):z.jsx("div",{className:fe("relative","w-full"),children:z.jsxs("div",{ref:K,className:"pierre-diff-wrapper w-full relative","data-no-drawer-swipe":"true",children:[z.jsx("div",{ref:A,className:"w-full"}),z.jsx(De,{hostRef:A,enabled:!h})]})})};export{nt as P};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects-CV5UyTRw.js","assets/index-CKKWVoND.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js","assets/index-B_L9GVYw.css","assets/vendor-boot-D-KEJjsM.js","assets/runtimeSurface-0K7vuUpd.js","assets/nativeFileSave-DSMsJqXM.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as Ne}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as e,aY as We,aZ as Ye,a_ as Ze,a$ as Qe,b0 as Xe}from"./vendor-boot-D-KEJjsM.js";import{R as o}from"./vendor-react-Bz1tRBxM.js";import{h as le,k as Le,u as mt,e as ht,f as ft,l as xt,m as pt,n as gt,r as bt,o as et,t as vt,g as ce,G as yt,a as jt,p as wt,c as kt,d as Ct,i as Nt,j as St}from"./useGitHubRemoteSearch-CgP-zEBj.js";import{j as Ee,t as G,N as Rt,B as P,I as M,bi as Lt,f as tt,D as Me,h as ze,i as Ae,V as Et,W as Ft,af as Se,a0 as we,aY as Pt,aZ as Tt}from"./useAppFontEffects-CV5UyTRw.js";import{i as I,T as Mt,r as zt,j as At,k as Dt,g as $t,l as Gt,m as Ht,f as qt,n as De,p as It,q as Ot,t as Bt,v as _t,w as Ut,x as Vt,y as Kt,z as Jt}from"./runtimeEndpointReset-Dwj-jCDS.js";import{z as Wt,A as Yt,B as Zt,C as Qt,D as st,E as Xt,F as es,H as ge,I as ts,q as ss,J as te,K as ns,L as as,M as ls,N as os,O as fe,u as is,i as rs,P as cs,b as ds,c as $e,j as ke,e as Ce,k as us,f as Ge,h as He,l as qe,m as nt,n as ms,p as Ie,Q as hs,v as fs,w as xs,x as ps,y as gs,R as be,S as he,T as bs,G as vs,U as ys,V as js,W as ws}from"./GitHubDetailScaffold-DM2DH7o8.js";import{c as xe,E as ks,s as Cs,u as Ns,A as Ss}from"./index-CKKWVoND.js";import{S as ve,d as Rs}from"./GitHubListPrimitives-CibDiJGq.js";import{P as Ls}from"./PierreDiffViewer-UY7Cse-s.js";import{c as Es,p as Fs}from"./vendor-zustand-CXhN0IMY.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-0K7vuUpd.js";import"./nativeFileSave-DSMsJqXM.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./SessionUnreadDot-Dwc3MdvA.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./vendor-dompurify-BGCr_sdL.js";import"./web-components-BpncHjnV.js";import"./computeVirtualFileMetrics-DJQqK49u.js";import"./vendor-shiki-BEwTOAFg.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.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-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-engine-javascript-DL394yyj.js";import"./vendor-oniguruma-to-es-DgwFOwdE.js";import"./vendor-oniguruma-parser-BrbMHgHx.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-BGZiLPe_.js";import"./renderDiffWithHighlighter-BXhnIAHg.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-CMbTn5WQ.js";import"./appThemeRegistry-Ca8eGRB9.js";import"./registerCustomTheme-C-h6lsYW.js";const Fe=()=>{const t=Ee(),[s,n]=o.useState(null);return{send:o.useCallback(async l=>{const d=t.github;if(!d)return G.error("GitHub is not available in this runtime"),!1;n(l.key);try{const c=await d.agentContext(l.directory,l.repo,l.contextType,l.number,l.contextOptions),r=Wt({kind:l.kind,repo:l.repo,number:l.number,detail:l.detail}),f=Yt({kind:l.kind,repo:l.repo,number:l.number,contextText:c.text}),x=Rt.getState();x.setPendingInputText(r,"append");const k=x.pendingSyntheticParts??[];return x.setPendingSyntheticParts([...k,{text:f,synthetic:!0}]),G.success("Added to composer"),!0}catch(c){return G.error(c instanceof Error?c.message:"Failed to fetch GitHub context"),!1}finally{n(null)}},[t.github]),sendingKey:s}},Ps=800,Ts=3,Pe={added:{icon:"add-circle",letter:"A",tint:"text-[var(--status-success)]"},removed:{icon:"subtract",letter:"D",tint:"text-[var(--status-error)]"},modified:{icon:"pencil",letter:"M",tint:"text-[var(--status-warning)]"},renamed:{icon:"expand-up-down",letter:"R",tint:"text-[var(--status-info)]"},other:{icon:"file",letter:"•",tint:"text-muted-foreground"}},at=t=>{switch((t??"").toLowerCase()){case"added":return"added";case"removed":return"removed";case"modified":return"modified";case"renamed":return"renamed";default:return"other"}},lt=t=>Pe[t].icon,Ms=t=>Pe[t].letter,Re=t=>Pe[t].tint,ot=t=>{const s=t.lastIndexOf("/");return s<0?{dir:"",base:t}:{dir:t.slice(0,s),base:t.slice(s+1)}},it=t=>{const s=typeof t.additions=="number"?t.additions:0,n=typeof t.deletions=="number"?t.deletions:0;return s!==0||n!==0?s+n:typeof t.changes=="number"?t.changes:0},rt=t=>it(t)>Ps,zs=t=>{const s=new Map;for(const a of t){const l=a.filename.lastIndexOf("/"),d=l<0?"":a.filename.slice(0,l),c=s.get(d);c?c.push(a):s.set(d,[a])}const n=[...s.entries()].map(([a,l])=>({folder:a,files:[...l].sort((d,c)=>d.filename.localeCompare(c.filename,void 0,{sensitivity:"base"}))}));return n.sort((a,l)=>a.folder===""?1:l.folder===""?-1:a.folder.localeCompare(l.folder,void 0,{sensitivity:"base"})),n},As=t=>{let s=0,n=0;for(const a of t)s+=typeof a.additions=="number"?a.additions:0,n+=typeof a.deletions=="number"?a.deletions:0;return{additions:s,deletions:n}},Ds=t=>{const s={};return t.forEach((n,a)=>{s[n.filename]=a>=Ts||rt(n)}),s},$s=(t,s,n)=>{if(!s)return null;const a=t.split("/");if(a.length!==3||a.some(r=>r.length===0))return null;const[l,d,c]=a;return`https://${l}/${d}/${c}/blob/${s}/${n}`},Gs=({comment:t,onRemove:s})=>e.jsxs("div",{className:"rounded-md border border-dashed border-border p-2.5 typography-ui text-foreground",contentEditable:!1,onPointerDown:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(M,{name:"chat-1",className:"size-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{children:"Pending — sent when you submit the review"}),e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard this comment",title:"Discard this comment",onClick:s,className:"ml-auto size-6",children:e.jsx(M,{name:"delete-bin",className:"size-3.5"})})]}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap break-words",children:t.body})]}),Oe=({thread:t,replyAllowed:s,replyDisabledReason:n,resolveAllowed:a,resolveDisabledReason:l,busy:d,onReply:c,onToggleResolved:r})=>{const[f,x]=o.useState(!t.resolved),[k,m]=o.useState(!1),[g,p]=o.useState(""),[z,F]=o.useState(!1),L=t.comments.length,j=async()=>{const b=g.trim();if(!(b.length===0||z||d)){F(!0);try{await c(b)&&(p(""),m(!1))}finally{F(!1)}}};return e.jsxs("div",{className:"rounded-md border border-border/60 bg-[var(--surface-elevated)] p-2.5 typography-ui text-foreground",contentEditable:!1,onPointerDown:b=>b.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(M,{name:t.resolved?"check":"chat-1",className:xe("size-3.5 shrink-0",t.resolved?"text-[var(--status-success)]":""),"aria-hidden":"true"}),e.jsxs("button",{type:"button",className:"hover:text-foreground","aria-expanded":f,onClick:()=>x(b=>!b),children:[t.resolved?"Resolved":"Open"," · ",L," ",L===1?"comment":"comments"]}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"ml-auto",disabled:!a||d,title:l??(t.resolved?"Reopen this conversation":"Resolve this conversation"),"aria-label":t.resolved?"Reopen conversation":"Resolve conversation",onClick:r,children:t.resolved?"Unresolve":"Resolve"})]}),f?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 flex flex-col gap-2",children:t.comments.map((b,i)=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"typography-micro text-muted-foreground",children:b.author?.login??"ghost"}),e.jsx(ss,{markdown:b.body,html:b.bodyHtml??null,fallbackUrl:b.url})]},b.id??`${t.id}-${i}`))}),s?k?e.jsxs("div",{className:"mt-2",children:[e.jsx("textarea",{autoFocus:!0,value:g,rows:2,placeholder:"Reply","aria-label":"Reply to this conversation",disabled:z||d,onChange:b=>p(b.target.value),onKeyDown:b=>{b.nativeEvent.isComposing||(b.key==="Escape"&&(b.preventDefault(),m(!1)),b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&!b.shiftKey&&!b.altKey&&!b.repeat&&(b.preventDefault(),b.stopPropagation(),j()))},className:"min-h-12 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"mt-1.5 flex justify-end gap-1.5",children:[e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>m(!1),children:"Cancel"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:z||d||g.trim().length===0,onClick:()=>{j()},children:z?"Replying…":"Reply"})]})]}):e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"mt-2",onClick:()=>m(!0),children:"Reply"}):n?e.jsxs("p",{className:"mt-2 typography-micro text-muted-foreground",title:n,children:["Reply unavailable — ",n.charAt(0).toLowerCase()+n.slice(1)]}):null]}):null]})},Hs=({path:t,line:s,sendingToAgent:n,onCancel:a,onAddToReview:l,onSendToAgent:d})=>{const[c,r]=o.useState(""),f=o.useRef(null),x=c.trim();o.useLayoutEffect(()=>{const m=window.requestAnimationFrame(()=>{f.current?.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(m)},[]);const k=()=>{x&&l(x)};return e.jsxs("div",{className:"rounded-md border border-border/60 bg-[var(--surface-elevated)] p-2.5",contentEditable:!1,onPointerDown:m=>m.stopPropagation(),children:[e.jsxs("p",{className:"truncate font-mono typography-micro text-muted-foreground",title:`${t}:${s}`,children:[t,":",s]}),e.jsx("textarea",{ref:f,value:c,rows:3,placeholder:"Add a comment…","aria-label":`Comment on ${t} line ${s}`,onChange:m=>r(m.target.value),onFocus:m=>{const g=m.currentTarget.value.length;m.currentTarget.setSelectionRange(g,g)},onKeyDown:m=>{m.nativeEvent.isComposing||(m.key==="Escape"&&(m.preventDefault(),a()),m.key==="Enter"&&(m.metaKey||m.ctrlKey)&&!m.shiftKey&&!m.altKey&&!m.repeat&&(m.preventDefault(),m.stopPropagation(),k()))},className:"mt-1.5 min-h-16 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"mr-auto typography-micro text-muted-foreground",children:"Ctrl/Cmd+Enter to add"}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:a,children:"Cancel"}),e.jsx(P,{type:"button",variant:"outline",size:"xs",disabled:!x||n,title:"Send this line to the agent",onClick:()=>d(x),children:n?"Sending…":"Send to agent"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:!x,onClick:k,children:"Add to review"})]})]})},qs=({file:t,collapsed:s,onToggleCollapse:n,viewed:a,onToggleViewed:l,blobUrl:d,threads:c,directory:r,repo:f,number:x,github:k,access:m,onThreadsChanged:g})=>{const p=I(w=>w.threadAction),z=le(w=>w.removeComment),F=le(w=>w.addComment),L=Le(f,x),[j,b]=o.useState(null),[i,C]=o.useState(!1),{send:h,sendingKey:O}=Fe(),{original:N,modified:E}=o.useMemo(()=>Zt(t.patch),[t.patch]),T=o.useMemo(()=>Qt(t.patch),[t.patch]),B=`pr-${x}-file-${t.filename}`,V=st(m),S=Xt(m),D=es(m),K=o.useCallback(w=>{if(!w||!V.allowed)return;const H=(w.endSide??w.side??"additions")==="deletions"?"deletions":"additions",ie=H==="deletions"?T.syntheticToOld.get(w.end):T.syntheticToNew.get(w.end);if(ie==null){G.error("That line is outside the rendered hunks");return}b({synthLine:w.end,side:H,realLine:ie,realSide:H==="deletions"?"LEFT":"RIGHT"})},[V.allowed,T]),_=at(t.status),{dir:Q,base:R}=ot(t.filename),q=rt(t),[y,de]=o.useState(!1),Z=q&&!y&&!a&&t.patch!=null,ee=c.filter(w=>!w.resolved).length,X=o.useMemo(()=>L.filter(w=>w.path===t.filename),[L,t.filename]),{annotations:se,orphans:ne}=o.useMemo(()=>{const w=new Map,$=[],H=(A,U)=>{const W=`${A}:${U}`;let J=w.get(W);return J||(J={side:A,synthLine:U,threads:[],pendings:[]},w.set(W,J)),J};for(const A of c){const U=A.line??A.originalLine??null;if(U==null){$.push(A);continue}let W,J;if(A.diffSide==="LEFT"?(J="deletions",W=T.oldToSynthetic.get(U)):A.diffSide==="RIGHT"?(J="additions",W=T.newToSynthetic.get(U)):(W=T.newToSynthetic.get(U),J="additions",W==null&&(W=T.oldToSynthetic.get(U),J="deletions")),W==null){$.push(A);continue}H(J,W).threads.push(A)}for(const A of X){if(A.line==null)continue;const U=A.side==="LEFT"?"deletions":"additions",W=U==="deletions"?T.oldToSynthetic.get(A.line):T.newToSynthetic.get(A.line);W!=null&&H(U,W).pendings.push(A)}return j&&H(j.side,j.synthLine),{annotations:[...w.values()].sort((A,U)=>A.synthLine-U.synthLine).map(A=>({side:A.side,lineNumber:A.synthLine,metadata:{threads:A.threads,pendings:A.pendings,draft:j&&j.side===A.side&&j.synthLine===A.synthLine?{realLine:j.realLine,realSide:j.realSide}:null}})),orphans:$}},[c,X,j,T]),oe=o.useCallback(async(w,$)=>{const H=w.comments[w.comments.length-1]?.id??null;if(typeof H!="number")return G.error("Cannot reply to this thread yet"),!1;if(i)return!1;C(!0);try{return(await p(r,f,x,w.id,{action:"reply",body:$,commentId:H},k)).ok?(G.success("Reply posted"),g(),!0):(G.error("Failed to post reply"),!1)}finally{C(!1)}},[r,f,x,k,p,i,g]),ae=o.useCallback(w=>{i||(C(!0),p(r,f,x,w.id,w.resolved?{action:"unresolve"}:{action:"resolve"},k).then($=>{$.ok?(G.success(w.resolved?"Thread reopened":"Thread resolved"),g()):G.error("Failed to update thread")}).finally(()=>C(!1)))},[r,f,x,k,p,i,g]),ue=o.useCallback(w=>e.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2",contentEditable:!1,onPointerDown:$=>$.stopPropagation(),children:[w.metadata.threads.map($=>e.jsx(Oe,{thread:$,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:D.allowed,resolveDisabledReason:D.reason,busy:i,onReply:H=>oe($,H),onToggleResolved:()=>ae($)},$.id)),w.metadata.pendings.map($=>e.jsx(Gs,{comment:$,onRemove:()=>z(f,x,$.id)},$.id)),w.metadata.draft?e.jsx(Hs,{path:t.filename,line:w.metadata.draft.realLine,sendingToAgent:O===`${B}-draft-agent`,onCancel:()=>b(null),onAddToReview:$=>{const H=w.metadata.draft;H&&(F(f,x,{path:t.filename,body:$,line:H.realLine,side:H.realSide}),b(null),G.success("Added to review"))},onSendToAgent:$=>{const H=w.metadata.draft;H&&h({key:`${B}-draft-agent`,kind:"lines",directory:r,repo:f,number:x,contextType:"pr",contextOptions:{includeDiff:!0},detail:`${t.filename} line ${H.realLine} ("${$.trim()}")`})}}):null]}),[S.allowed,S.reason,D.allowed,D.reason,i,oe,ae,z,F,f,x,t.filename,B,O,r,h]);return e.jsxs("article",{className:"overflow-hidden rounded-md border border-border/60",children:[e.jsxs("div",{className:"sticky top-8 z-[5] flex items-center gap-1.5 bg-[var(--surface-muted)] px-2 py-1.5",children:[e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:()=>n(t.filename),"aria-label":s?`Expand ${t.filename}`:`Collapse ${t.filename}`,title:s?"Expand":"Collapse",className:"size-6",children:e.jsx(M,{name:s?"arrow-right-s":"arrow-down-s",className:"size-4"})}),e.jsx(M,{name:lt(_),className:xe("size-3.5 shrink-0",Re(_)),"aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono typography-micro",title:t.filename,children:[Q?e.jsxs("span",{className:"text-muted-foreground",children:[Q,"/"]}):null,e.jsx("span",{className:"text-foreground",children:R})]}),_!=="other"?e.jsx("span",{className:xe("shrink-0 rounded px-1 font-mono typography-micro",Re(_)),title:t.status??void 0,children:Ms(_)}):null,e.jsx(ge,{additions:t.additions,deletions:t.deletions,className:"typography-micro"}),c.length>0||X.length>0?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-muted-foreground",title:`${c.length} ${c.length===1?"conversation":"conversations"}${X.length>0?`, ${X.length} pending`:""}`,children:[e.jsx(M,{name:"chat-1",className:"size-3.5","aria-hidden":"true"}),c.length>0?e.jsx("span",{className:"tabular-nums",children:ee>0?ee:c.length}):null,X.length>0?e.jsxs("span",{className:"tabular-nums",children:["+",X.length]}):null]}):null,e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",onClick:w=>w.stopPropagation(),children:[e.jsx(Lt,{checked:a,onChange:w=>l(t.filename,w),ariaLabel:a?`Mark ${t.filename} as not viewed`:`Mark ${t.filename} as viewed`}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Viewed"})]}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{h({key:`${B}-agent`,kind:"file",directory:r,repo:f,number:x,contextType:"pr",contextOptions:{includeDiff:!0},detail:t.filename})},disabled:O===`${B}-agent`,"aria-label":`Send ${t.filename} to agent`,children:"Send to agent"})]}),s?null:e.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[ne.length>0?e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md bg-[var(--surface-muted)] px-2 py-2",children:[e.jsxs("p",{className:"typography-micro text-muted-foreground",children:["Other conversations (",ne.length,") — ",ne.length===1?"this line is":"these lines are"," no longer in the diff"]}),ne.map(w=>e.jsx(Oe,{thread:w,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:D.allowed,resolveDisabledReason:D.reason,busy:i,onReply:$=>oe(w,$),onToggleResolved:()=>ae(w)},w.id))]}):null,Z?e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-[var(--surface-muted)] px-3 py-3 typography-ui",children:[e.jsx(M,{name:"file",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsxs("p",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["Large diff — ",it(t)," changed lines"]}),e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>de(!0),children:"Load diff"})]}):t.patch?e.jsx("div",{className:"min-h-24 overflow-hidden",children:e.jsx(Ls,{original:N,modified:E,language:ts(t.filename),fileName:t.filename,renderSideBySide:!1,layout:"inline",enableGutterUtility:V.allowed&&j===null,enableLineSelection:V.allowed&&j===null,onGutterUtilityClick:K,onLineSelectionEnd:K,lineAnnotations:se,renderAnnotation:w=>ue(w)})}):e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-[var(--surface-muted)] px-3 py-3 typography-ui",children:[e.jsx(M,{name:"file",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("p",{className:"min-w-0 flex-1 text-muted-foreground",children:"Diff not available for this file."}),d?e.jsx(P,{type:"button",variant:"link",size:"sm",asChild:!0,children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",children:"Open on GitHub"})}):null]})]})]})},Is=o.memo(qs),Os=({directory:t,repo:s,number:n,github:a,pr:l,access:d,onCommented:c})=>{const r=I(i=>i.addComment),f=I(i=>i.performAction),x=le(i=>i.clearCommentDraft),{draft:k,onDraftChange:m,flushDraft:g}=mt(s,n),{busy:p,error:z,submit:F}=ht({postComment:i=>r(t,s,n,i,a),runFollowUp:i=>f(t,s,n,i,a),verbs:{close:"close",reopen:"reopen"},doneLabels:{close:"Closed with comment",reopen:"Reopened with comment"},afterPost:()=>{m(""),x(s,n),c()}}),L=st(d),j=l.state==="open"?"close":l.state==="closed"?"reopen":null,b=j?te(j,l,d):null;return L.allowed?e.jsx(ft,{draft:k,onDraftChange:m,onDraftBlur:g,ariaLabel:"Leave a comment on this pull request",busy:p,error:z,disabledReason:L.reason,followUp:j?{id:j,label:j==="close"?"Close with comment":"Reopen with comment",busyLabel:j==="close"?"Closing…":"Reopening…",onRun:()=>{F(j,k)},allowed:b?.allowed===!0,reason:b?.reason}:null,onSubmitComment:()=>{F("comment",k)}}):null},Bs={comment:"Comment",approve:"Approve","request-changes":"Request changes"},_s=({repo:t,number:s,verdicts:n,summary:a,verdict:l,pendingCount:d,busy:c,textareaRef:r,onSubmit:f})=>{const x=le(p=>p.setSummary),k=le(p=>p.setVerdict),m=n.includes(l)?l:n[0]??"comment",g=as({verdict:m,summary:a,pendingCount:d});return e.jsxs("div",{children:[e.jsx(Mt,{ref:r,rows:3,value:a,placeholder:"Summarize your review (optional)","aria-label":"Review summary",disabled:c,onChange:p=>x(t,s,p.target.value),onKeyDown:p=>{p.nativeEvent.isComposing||p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&!p.shiftKey&&!p.altKey&&!p.repeat&&(p.preventDefault(),p.stopPropagation(),g&&!c&&f())}}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsxs("label",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"sr-only",children:"Review verdict"}),e.jsx("select",{value:m,disabled:c,onChange:p=>k(t,s,p.target.value),"aria-label":"Review verdict",className:"h-7 max-w-40 truncate rounded-md border border-border bg-[var(--surface-elevated)] px-1.5 typography-micro text-foreground",children:n.map(p=>e.jsx("option",{value:p,children:Bs[p]},p))})]}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:c||!g,title:g?`Submit review${d>0?` with ${d} ${d===1?"line comment":"line comments"}`:""}`:"Add a summary or a line comment first",onClick:f,children:c?"Submitting…":"Submit review"})]})]})},ct=({directory:t,repo:s,number:n,github:a,access:l,size:d="sm",onReviewSubmitted:c})=>{const r=I(T=>T.submitReview),f=le(T=>T.removeComments),x=le(T=>T.clearSummary),k=le(T=>T.clearComments),m=Le(s,n),g=xt(s,n),p=pt(s,n),[z,F]=o.useState(!1),[L,j]=o.useState(!1),b=o.useRef(null),i=o.useMemo(()=>ns(l),[l]),C=i.includes(p)?p:i[0]??"comment",h=m.length,O=h>0||g.trim().length>0;if(o.useEffect(()=>{if(!z)return;const T=window.requestAnimationFrame(()=>b.current?.focus({preventScroll:!0}));return()=>window.cancelAnimationFrame(T)},[z]),i.length===0)return null;const N=async()=>{if(L)return;const T=g,B=[...m];j(!0);try{const V=B.map(D=>({path:D.path,body:D.body,...D.line!=null?{line:D.line}:{},...D.side?{side:D.side}:{}})),S=await r(t,s,n,{event:C,body:T.trim()?T:void 0,comments:V},a);if(!S.ok){G.error(S.error?.kind==="failed"?S.error.message:"Failed to submit review");return}f(s,n,B.map(D=>D.id)),x(s,n,T),G.success(C==="approve"?"Pull request approved":C==="request-changes"?"Changes requested":"Review submitted"),F(!1),c?.()}finally{j(!1)}},E=h>0?`Review · ${h}`:"Review";return e.jsxs(We,{open:z,onOpenChange:F,children:[e.jsxs(Ye,{render:e.jsx(P,{type:"button",variant:h>0?"default":"outline",size:d,className:"shrink-0","aria-label":h>0?`Review pull request, ${h} ${h===1?"line comment":"line comments"} pending`:"Review pull request",title:O?"Finish your review":"Approve, request changes, or comment with a review"}),children:[e.jsx(M,{name:"file-check",className:"size-3.5","aria-hidden":"true"}),E]}),e.jsx(Ze,{children:e.jsx(Qe,{className:"z-50",side:"top",align:"end",sideOffset:8,collisionPadding:8,children:e.jsxs(Xe,{"aria-label":"Review pull request",className:"w-[min(24rem,calc(100vw-2rem))] rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3 shadow-lg",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 truncate typography-ui-label text-foreground",children:h>0?`Review · ${h} ${h===1?"line comment":"line comments"}`:"Review pull request"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[h>0?e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard pending line comments",title:"Discard pending line comments",disabled:L,onClick:()=>k(s,n),className:"size-6",children:e.jsx(M,{name:"delete-bin",className:"size-3.5"})}):null,e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Close review",onClick:()=>F(!1),className:"size-6",children:e.jsx(M,{name:"close",className:"size-3.5"})})]})]}),e.jsx(_s,{repo:s,number:n,verdicts:i,summary:g,verdict:C,pendingCount:h,busy:L,textareaRef:b,onSubmit:()=>{N()}})]})})})]})},ye=(t,s)=>`${t}#${s}`,Be=50,Us=Object.freeze([]),_e=(t,s)=>{const n=Object.keys(t);if(n.length<=Be)return t;const a={};for(const l of n.slice(n.length-Be))a[l]=t[l];if(!(s in a)&&s in t){const l=Object.keys(a)[0];delete a[l],a[s]=t[s]}return a},pe=Es()(Fs((t,s)=>({entries:{},setViewed:(n,a,l,d)=>{const c=ye(n,a);(s().entries[c]?.viewed.includes(l)??!1)!==d&&t(x=>{const k=x.entries[c]??{viewed:[],headSha:null},m=d?[...k.viewed,l]:k.viewed.filter(g=>g!==l);return{entries:_e({...x.entries,[c]:{...k,viewed:m}},c)}})},syncHeadSha:(n,a,l)=>{const d=ye(n,a),c=s().entries[d];c&&c.headSha===(l??null)||t(r=>({entries:_e({...r.entries,[d]:{viewed:[],headSha:l??null}},d)}))},resetForRuntimeSwitch:()=>t({entries:{}})}),{name:"pichamber:github-viewed-files",version:1,storage:ks(),partialize:t=>({entries:t.entries})}));typeof window<"u"&&Cs(()=>{pe.getState().resetForRuntimeSwitch()});const Vs=(t,s)=>pe(n=>n.entries[ye(t,s)]?.viewed??Us),Ks=(t,s)=>pe(n=>n.entries[ye(t,s)]?.viewed.length??0),Ue=20,Js=[],Ws=[],Ve=t=>`pr-file-${encodeURIComponent(t)}`,dt=o.memo(({file:t,viewed:s,threadCount:n,pendingCount:a,showDir:l,onSelectFile:d})=>{const c=at(t.status),{dir:r,base:f}=ot(t.filename);return e.jsxs("button",{type:"button",onClick:()=>d(t.filename),title:t.filename,"aria-label":`Go to ${t.filename}`,className:"flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left hover:bg-interactive-hover",children:[e.jsx(M,{name:lt(c),className:xe("size-3.5 shrink-0",Re(c)),"aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono typography-micro",children:[l&&r?e.jsxs("span",{className:"text-muted-foreground",children:[r,"/"]}):null,e.jsx("span",{className:"text-foreground",children:f})]}),e.jsx(ge,{additions:t.additions,deletions:t.deletions,className:"typography-micro"}),n>0?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 typography-micro text-muted-foreground",title:`${n} ${n===1?"conversation":"conversations"}`,children:[e.jsx(M,{name:"chat-1",className:"size-3","aria-hidden":"true"}),e.jsx("span",{className:"tabular-nums",children:n})]}):null,a>0?e.jsxs("span",{className:"shrink-0 tabular-nums typography-micro text-muted-foreground",title:`${a} pending`,children:["+",a]}):null,s?e.jsx(M,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]","aria-label":"Viewed"}):null]})});dt.displayName="FileJumpRow";const ut=({files:t,viewedPaths:s,threadCounts:n,pendingCounts:a,onSelectFile:l})=>{const[d,c]=o.useState(""),r=o.useMemo(()=>zs(t),[t]),f=o.useMemo(()=>new Set(s),[s]),x=d.trim().toLowerCase(),k=o.useMemo(()=>x?r.map(m=>({...m,files:m.files.filter(g=>g.filename.toLowerCase().includes(x))})).filter(m=>m.files.length>0):r,[r,x]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-1",children:[e.jsx(tt,{value:d,onChange:m=>c(m.target.value),placeholder:"Filter files","aria-label":"Filter files",className:"h-7 shrink-0 typography-micro"}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",role:"list","aria-label":"Changed files",children:k.length===0?e.jsx("p",{className:"px-1.5 py-2 typography-micro text-muted-foreground",children:t.length===0?"No changed files":"No files match"}):k.map(m=>e.jsxs("div",{role:"group","aria-label":m.folder||"Repository root",children:[r.length>1?e.jsx("p",{className:"truncate px-1.5 pt-1.5 pb-0.5 typography-micro text-muted-foreground",title:m.folder||"/",children:m.folder||"/"}):null,m.files.map(g=>e.jsx(dt,{file:g,viewed:f.has(g.filename),threadCount:n.get(g.filename)??0,pendingCount:a.get(g.filename)??0,showDir:r.length<=1,onSelectFile:l},g.filename))]},m.folder))})]})},Ys=t=>{const[s,n]=o.useState(!1),{onSelectFile:a}=t,l=o.useCallback(d=>{n(!1),a(d)},[a]);return e.jsxs(We,{open:s,onOpenChange:n,children:[e.jsxs(Ye,{render:e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0","aria-label":`Jump to file, ${t.files.length} ${t.files.length===1?"file":"files"}`,title:"Jump to file"}),children:[e.jsx(M,{name:"file",className:"size-3.5","aria-hidden":"true"}),"Files"]}),e.jsx(Ze,{children:e.jsx(Qe,{className:"z-50",side:"bottom",align:"start",sideOffset:4,collisionPadding:8,children:e.jsx(Xe,{"aria-label":"Jump to file",className:"flex max-h-[min(28rem,calc(100dvh-4rem))] w-[min(22rem,calc(100vw-2rem))] flex-col rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-1.5 shadow-lg",children:e.jsx(ut,{...t,onSelectFile:l})})})})]})},Zs=48,Qs=(t,s)=>{const[n,a]=o.useState(null);return o.useLayoutEffect(()=>{if(!s)return;const l=t.current?.closest("[data-diff-virtual-root]");if(!(l instanceof HTMLElement))return;const d=()=>{const r=Math.max(160,Math.floor(l.clientHeight-Zs));a(f=>f===r?f:r)};if(d(),typeof ResizeObserver>"u")return;const c=new ResizeObserver(d);return c.observe(l),()=>c.disconnect()},[t,s]),n},Xs=t=>{const{directory:s,repo:n,number:a,github:l,access:d,headSha:c=null}=t,r=t.files?.files??Js,f=Vs(n,a),x=Ks(n,a),k=Le(n,a);o.useEffect(()=>{pe.getState().syncHeadSha(n,a,c)},[n,a,c]);const m=o.useMemo(()=>Ds(r),[r]),g=o.useRef(m);g.current=m;const p=o.useRef(r);p.current=r;const[z,F]=o.useState({}),[L,j]=o.useState(Ue),b=o.useMemo(()=>As(r),[r]),i=o.useMemo(()=>{const R=new Map;for(const q of t.threads){if(!q.path)continue;const y=R.get(q.path)??[];y.push(q),R.set(q.path,y)}return R},[t.threads]),C=o.useMemo(()=>{const R=new Map;for(const[q,y]of i)R.set(q,y.length);return R},[i]),h=o.useMemo(()=>{const R=new Map;for(const q of k)R.set(q.path,(R.get(q.path)??0)+1);return R},[k]),O=o.useCallback(R=>{F(q=>({...q,[R]:!(q[R]??g.current[R]??!1)}))},[]),N=o.useCallback(()=>{F(Object.fromEntries(p.current.map(R=>[R.filename,!1])))},[]),E=o.useCallback(()=>{F(Object.fromEntries(p.current.map(R=>[R.filename,!0])))},[]),T=o.useCallback((R,q)=>{pe.getState().setViewed(n,a,R,q),F(y=>({...y,[R]:q}))},[n,a]),B=o.useCallback(R=>{F(y=>y[R]??g.current[R]??!1?{...y,[R]:!1}:y);const q=p.current.findIndex(y=>y.filename===R);q>=0&&j(y=>q<y?y:q+1),requestAnimationFrame(()=>{document.getElementById(Ve(R))?.scrollIntoView({block:"start"})})},[]),V=o.useMemo(()=>r.slice(0,L),[r,L]),S=o.useRef(null),D=Qs(S,V.length>0),K=o.useMemo(()=>new Set(f),[f]),_=r.length===1?"1 file":`${r.length} files`,Q=r.length===0?"Nothing viewed yet":`${x}/${r.length} viewed`;return e.jsxs("section",{"aria-label":"Changed files",className:"@container flex flex-col gap-2","data-diff-virtual-content":!0,children:[e.jsx(ve,{error:t.filesError,onRetry:t.onRetryFiles,label:"Changed files"}),e.jsx(ve,{error:t.threadsError,onRetry:t.onRetryDetail,label:"Review threads"}),e.jsxs("div",{className:"sticky top-0 z-10 flex h-8 shrink-0 items-center gap-2 border-b border-border/60 bg-[var(--surface-background)] px-1 text-[12px]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:_}),e.jsx(ge,{additions:b.additions,deletions:b.deletions}),e.jsxs("span",{className:"shrink-0 tabular-nums text-muted-foreground","aria-label":Q,children:[x,"/",r.length," viewed"]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[e.jsx(ct,{directory:s,repo:n,number:a,github:l,access:d,size:"xs",onReviewSubmitted:t.onReviewSubmitted}),e.jsx("span",{className:"@4xl:hidden",children:e.jsx(Ys,{files:r,viewedPaths:f,threadCounts:C,pendingCounts:h,onSelectFile:B})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:N,"aria-label":"Expand all files",title:"Expand all files",className:"size-7",children:e.jsx(M,{name:"expand-up-down",className:"size-3.5"})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:E,"aria-label":"Collapse all files",title:"Collapse all files",className:"size-7",children:e.jsx(M,{name:"collapse-vertical",className:"size-3.5"})})]})]}),t.filesLoading&&V.length===0?e.jsx(Rs,{rows:5,label:"Loading changed files"}):null,!t.filesLoading&&V.length===0?e.jsx("p",{className:"px-1 py-4 typography-micro text-muted-foreground",children:"No changed files"}):null,V.length>0?e.jsxs("div",{className:"flex min-h-0 items-start gap-3",children:[e.jsx("aside",{ref:S,"aria-label":"Changed files",style:D!=null?{height:D}:void 0,className:"sticky top-10 hidden max-h-[calc(100dvh-10rem)] w-60 shrink-0 flex-col @4xl:flex",children:e.jsx(ut,{files:r,viewedPaths:f,threadCounts:C,pendingCounts:h,onSelectFile:B})}),e.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:V.map(R=>e.jsx("div",{id:Ve(R.filename),className:"scroll-mt-12",children:e.jsx(Is,{file:R,collapsed:z[R.filename]??m[R.filename]??!1,onToggleCollapse:O,viewed:K.has(R.filename),onToggleViewed:T,blobUrl:$s(n,c,R.filename),threads:i.get(R.filename)??Ws,directory:s,repo:n,number:a,github:l,access:d,onThreadsChanged:t.onRetryDetail})},R.filename))})]}):null,r.length>L?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>j(L+Ue),children:"Show more files"})}):null,t.filesHasMore?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:t.onLoadMoreFiles,children:"Load more files"})}):null]})},en=({directory:t,repo:s,number:n,github:a,checks:l,checksError:d,checksLoading:c,onRetryChecks:r,onOpenFilesAtLine:f})=>{const[x,k]=o.useState({}),[m,g]=o.useState({}),{send:p,sendingKey:z}=Fe(),F=ls(l);return e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-1 py-1",children:[e.jsx("p",{className:"min-w-0 flex-1 typography-micro text-muted-foreground","aria-live":"polite",children:F?F.text:c?"Loading checks…":"No checks reported for this pull request."}),F&&F.failed>0?e.jsxs(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{p({key:`pr-${n}-failed-checks`,kind:"checks",directory:t,repo:s,number:n,contextType:"checks"})},disabled:z===`pr-${n}-failed-checks`,"aria-label":"Send failed checks to agent",title:"Send failed checks to agent",children:[e.jsx(M,{name:"send-plane-2",className:"size-3.5"}),"Send failures to agent"]}):null,e.jsxs(P,{type:"button",variant:"ghost",size:"xs",onClick:r,"aria-label":"Refresh checks",title:"Refresh checks",children:[e.jsx(M,{name:"refresh",className:xe("size-3.5",c&&"animate-spin")}),"Refresh"]})]}),e.jsx(ve,{error:d,onRetry:r,label:"Checks"}),l?e.jsx(tn,{checks:l,directory:t,repo:s,number:n,github:a,expandedJobs:x,onToggleJob:L=>k(j=>({...j,[L]:!j[L]})),jobSteps:m,setJobSteps:g,sendingKey:z,send:p,onOpenFilesAtLine:f}):null]})},tn=({checks:t,directory:s,repo:n,number:a,github:l,expandedJobs:d,onToggleJob:c,jobSteps:r,setJobSteps:f,sendingKey:x,send:k,onOpenFilesAtLine:m})=>{const g=I(i=>i.rerunFailedChecks),[p,z]=o.useState({}),F=async i=>{const C=`run-${i.id??i.name}`;if(c(C),!(d[C]||r[C]||i.id==null)){f(h=>({...h,[C]:{steps:[],loading:!0}}));try{const O=(await l.checkJobs(s,n,i.runId??null,i.id)).jobs[0];f(E=>({...E,[C]:{steps:O?.steps??[],loading:!1}}));const N=await l.checkAnnotations(s,n,i.id).catch(()=>null);N&&z(E=>({...E,[i.id]:{loading:!1,items:N.annotations}}))}catch{f(h=>({...h,[C]:{steps:[],loading:!1}}))}}},L=async i=>{(await g(s,n,i,l)).ok?G.success("Re-run requested"):G.error("Re-run failed")},j=i=>{const C=`run-${i.id??i.name}`,h=d[C]??!1,O=r[C],N=os(i);return e.jsxs("div",{className:"rounded-md px-2 py-2 hover:bg-interactive-hover",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(fe,{state:i.conclusion??i.status}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui text-foreground",title:i.name,children:i.name}),i.conclusion?e.jsx("span",{className:"typography-micro text-muted-foreground",children:i.conclusion}):null,e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{F(i)},"aria-expanded":h,"aria-label":`${h?"Collapse":"Expand"} ${i.name}`,children:"Details"}),N&&i.runId!=null?e.jsx(P,{type:"button",variant:"outline",size:"xs",onClick:()=>{L(i.runId)},children:"Re-run"}):null,N?e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{k({key:`${C}-agent`,kind:"check",directory:s,repo:n,number:a,contextType:"checks",detail:i.name})},disabled:x===`${C}-agent`,"aria-label":`Send ${i.name} to agent`,children:"Send to agent"}):null]}),h?e.jsxs("div",{className:"mt-1.5 flex flex-col gap-1 border-t border-border/60 pt-1.5",children:[O?.loading?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Loading steps…"}):null,(O?.steps??[]).map((E,T)=>e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(fe,{state:E.conclusion??E.status}),e.jsx("span",{className:"truncate",children:E.name}),E.conclusion?e.jsxs("span",{children:["· ",E.conclusion]}):null]},`${E.name}-${T}`)),i.id!=null&&p[i.id]?.items?.length?e.jsx("div",{className:"flex flex-col gap-1",children:p[i.id]?.items.map((E,T)=>e.jsxs("div",{className:"typography-micro text-muted-foreground",children:[E.path&&E.startLine&&m?e.jsxs("button",{type:"button",className:"font-mono underline",onClick:()=>m(E.path,E.startLine),children:[E.path,":",E.startLine]}):e.jsxs("span",{className:"font-mono",children:[E.path,E.startLine?`:${E.startLine}`:""]})," ",E.title?e.jsxs("span",{className:"text-foreground",children:[E.title," — "]}):null,E.message]},T))}):null]}):null]},C)},b=(i,C)=>e.jsxs("div",{className:"flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-interactive-hover",children:[e.jsx(fe,{state:i.state}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui text-foreground",title:i.context,children:i.context}),i.description?e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:i.description}):null]},`${i.context}-${C}`);return e.jsxs("div",{className:"flex flex-col gap-1",children:[t.sectionErrors?.runs||t.sectionErrors?.statuses?e.jsx("div",{className:"rounded-md border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-2 py-1 typography-micro text-foreground",role:"alert",children:"Some check sources failed to load; counts below are partial, not empty."}):null,t.runs.length>0?e.jsx("div",{className:"flex flex-col","aria-label":"Check runs",children:t.runs.map(j)}):null,t.statuses.length>0?e.jsx("div",{className:"flex flex-col","aria-label":"Commit statuses",children:t.statuses.map(b)}):null,t.runs.length===0&&t.statuses.length===0?e.jsx("p",{className:"typography-ui text-muted-foreground",children:"No checks reported for this pull request."}):null]})},Ke=({pr:t})=>e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nt,{login:t.author?.login,avatarUrl:t.author?.avatarUrl,size:"xs"}),t.author?.login??"ghost"]}),t.updatedAt?` · updated ${gs(t.updatedAt)}`:"",t.draft?" · Draft":""]}),Je=({pr:t,filesCount:s})=>e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"shrink-0 truncate",title:t.base,children:t.base}),e.jsx("span",{className:"shrink-0","aria-label":"receives changes from",children:"←"}),e.jsx("code",{className:"min-w-0 flex-1 truncate",title:t.head,children:t.head}),typeof s=="number"?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 tabular-nums",children:[e.jsx(M,{name:"file-code",className:"size-3 shrink-0","aria-hidden":"true"}),s," ",s===1?"file":"files"]}):null,e.jsx(ge,{additions:t.additions,deletions:t.deletions})]}),sn=({repo:t,pr:s,access:n,acting:a,mergeMethod:l,onMergeMethodChange:d,onRun:c,checkingOut:r,onCheckout:f,onCopyLink:x,askSending:k,onAskAgent:m})=>{const g=I(N=>N.setMergeMethod),p=s.state==="open",z=be.filter(N=>te(N.id,s,n).allowed),F=z.some(N=>N.id===l)?l:z[0]?.id??l,L=te(F,s,n),j=te("ready",s,n),b=te("draft",s,n),i=te("close",s,n),C=te("reopen",s,n),h=be.find(N=>N.id===F)??be[0],O=z.length===0||a;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pt-1 pb-2","aria-label":"Pull request actions",children:[p&&!s.draft?e.jsxs("span",{role:"group","aria-label":"Merge pull request",className:"inline-flex shrink-0 items-center gap-1",children:[e.jsx(ce,{copy:he(F,s.base,s.head),busy:a,disabled:!L.allowed,disabledReason:L.reason??`Merge via ${h.label}`,label:F==="merge"?"Merge pull request":h.label,icon:e.jsx(M,{name:"git-merge",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c(F)}),e.jsxs(Me,{modal:!1,children:[e.jsx(ze,{asChild:!0,children:e.jsx(P,{type:"button",variant:"default",size:"xs",className:"shrink-0 px-1.5",title:"Merge options","aria-label":"Merge options",disabled:O,children:e.jsx(M,{name:"arrow-down-s",className:"size-3.5"})})}),e.jsx(Ae,{align:"start",className:"w-72",children:e.jsx(Et,{value:F,onValueChange:N=>{const E=N;d(E),g(t,E)},children:be.map(N=>{const E=te(N.id,s,n);return e.jsx(Ft,{value:N.id,disabled:!E.allowed,title:E.reason??N.description,children:e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"truncate",children:N.label}),e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:N.description})]})},N.id)})})})]})]}):null,p&&s.draft?e.jsx(ce,{copy:he("ready",s.base,s.head),busy:a,disabled:!j.allowed,disabledReason:j.reason??"Ready for review",label:"Ready for review",icon:e.jsx(M,{name:"git-pull-request",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("ready")}):null,p&&!s.draft?e.jsx(ce,{copy:he("draft",s.base,s.head),busy:a,variant:"outline",disabled:!b.allowed,disabledReason:b.reason??"Convert to draft",label:"Convert to draft",icon:e.jsx(M,{name:"pencil",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("draft")}):null,p?e.jsx(ce,{copy:he("close",s.base,s.head),busy:a,destructive:!0,variant:"outline",disabled:!i.allowed,disabledReason:i.reason??"Close pull request",label:"Close",icon:e.jsx(M,{name:"close",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("close")}):e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>c("reopen"),disabled:!C.allowed||a,title:C.reason??"Reopen pull request","aria-label":"Reopen pull request",children:[e.jsx(M,{name:"history",className:"size-3.5","aria-hidden":"true"}),"Reopen"]}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>f("worktree"),disabled:r,title:"Check out in a new worktree","aria-label":"Check out in a new worktree",children:[e.jsx(M,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),r?"Checking out…":"Check out"]}),e.jsx(ce,{copy:{title:"Check out this branch here?",detail:"This switches your current checkout to the PR branch. Uncommitted work may be disrupted.",confirm:"Check out here",progress:"Checking out…"},busy:r,variant:"outline",label:"Check out here",icon:e.jsx(M,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>f("current")}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:m,disabled:k,title:"Send pull request context to the agent composer","aria-label":"Ask agent about this pull request",children:[e.jsx(M,{name:"send-plane-2",className:"size-3.5","aria-hidden":"true"}),k?"Asking…":"Ask agent"]}),e.jsxs(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{Se(s.url)},title:"Review on GitHub","aria-label":"Review on GitHub",children:[e.jsx(M,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Review on GitHub"]}),e.jsxs(Me,{modal:!1,children:[e.jsx(ze,{asChild:!0,children:e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 px-1.5","aria-label":"More pull request actions",title:"More pull request actions",children:e.jsx(M,{name:"more-2",className:"size-4"})})}),e.jsxs(Ae,{align:"end",className:"w-60",children:[e.jsxs(we,{onClick:()=>{Se(s.url)},children:[e.jsx(M,{name:"external-link",className:"size-3.5"}),"Open on GitHub"]}),e.jsxs(we,{onClick:x,children:[e.jsx(M,{name:"file-copy",className:"size-3.5"}),"Copy link"]}),e.jsx(Pt,{}),e.jsxs(we,{onClick:()=>f("worktree"),disabled:r,children:[e.jsx(M,{name:"git-branch",className:"size-3.5"}),"Check out in new worktree"]})]})]})]})},nn=({pr:t,access:s,acting:n,onRun:a})=>{const l=bs(t);if(!l)return null;const d=te("update-branch",t,s),c=l.tone==="error"?"border-[var(--status-error-border)] bg-[var(--status-error-background)] text-foreground":"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-foreground",r=l.tone==="error"?"text-[var(--status-error)]":"text-[var(--status-warning)]";return e.jsxs("div",{className:`mx-3 mb-2 flex flex-wrap items-center gap-x-2 gap-y-1.5 rounded-md border px-2.5 py-2 ${c}`,role:"status",children:[e.jsx(M,{name:l.icon,className:`size-4 shrink-0 ${r}`,"aria-hidden":"true"}),e.jsxs("p",{className:"min-w-0 flex-1 basis-48",children:[e.jsxs("span",{className:"typography-ui-label font-medium",children:[l.title," ",e.jsx("code",{className:"font-mono",children:t.base})]}),e.jsx("span",{className:"block typography-micro text-muted-foreground",children:l.detail})]}),l.canUpdate?e.jsx(ce,{copy:he("update-branch",t.base,t.head),busy:n,variant:"outline",disabled:!d.allowed,disabledReason:d.reason??"Update branch",label:"Update branch",icon:e.jsx(M,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>a("update-branch")}):e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{Se(t.url)},title:"Resolve conflicts on GitHub","aria-label":"Resolve conflicts on GitHub",children:[e.jsx(M,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Resolve on GitHub"]})]})},an=t=>{const{directory:s,repo:n,number:a,github:l,detail:d}=t,c=I(u=>u.performAction),r=I(u=>u.updateTitleBody),f=I(u=>u.checkout),[x,k]=o.useState("summary"),[m,g]=o.useState(!1),[p,z]=o.useState(()=>zt(n)??"merge"),[F,L]=o.useState(!1),[j,b]=o.useState(""),[i,C]=o.useState(!1),[h,O]=o.useState(""),[N,E]=o.useState("newest"),[T,B]=o.useState(1),[V,S]=o.useState(!1),[D,K]=o.useState(null),_=gt(n,a),{send:Q,sendingKey:R}=Fe(),q=is(s,n),y=d?.pr??null,de=d?.sectionErrors??null,Z=o.useMemo(()=>({capabilities:d?.capabilities??null,isAuthor:rs(y?.author?.login,d?.viewerLogin),permissionFallback:d?.viewerPermission?.fallback===!0}),[d?.capabilities,d?.viewerLogin,d?.viewerPermission?.fallback,y?.author?.login]),ee=cs(y,Z);o.useEffect(()=>{k("summary"),L(!1),C(!1),B(1),K(null)},[n,a]);const X=o.useCallback(async u=>{g(!0);try{const Y=await c(s,n,a,u,l);if(!Y.ok){G.error(Y.error?.kind==="failed"?Y.error.message:"Action failed");return}u==="close"?G.success("Pull request closed"):u==="reopen"?G.success("Pull request reopened"):u==="update-branch"?G.success("Branch update requested"):u==="ready"?G.success("Marked as ready for review"):u==="draft"?G.success("Converted to draft"):G.success("Pull request merged")}finally{g(!1)}},[s,n,a,l,c]),se=o.useCallback(()=>{Q({key:`pr-${a}-ask`,kind:"pr",directory:s,repo:n,number:a,contextType:"pr"})},[Q,s,n,a]),ne=o.useCallback(async()=>{if(!j.trim()){G.error("Enter a title");return}const u=await r(s,n,a,{title:j.trim()},l);u.ok?(G.success("Title updated"),L(!1)):G.error(u.error?.kind==="failed"?u.error.message:"Failed to update title")},[j,s,n,a,l,r]),oe=o.useCallback(async()=>{const u=await r(s,n,a,{body:h},l);u.ok?(G.success("Description updated"),C(!1)):G.error(u.error?.kind==="failed"?u.error.message:"Failed to update description")},[h,s,n,a,l,r]),ae=Ee().git,ue=o.useCallback(async u=>{if(u==="current"){const Y=await Ne(()=>import("./useAppFontEffects-CV5UyTRw.js").then(re=>re.f0),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(re=>re.useGitStore.getState().directories.get(s)?.status??null).catch(()=>null);if(Y&&!Y.isClean){G.error("Working tree has uncommitted changes. Commit or stash first, or use New worktree.");return}}S(!0);try{const Y=await f(s,n,a,u,l);Y.ok?(await bt(s,ae),K({path:Y.path??null,branch:Y.branch??""}),G.success(u==="worktree"?"Worktree created":"Branch checked out")):G.error(Y.error?.kind==="failed"?Y.error.message:"Checkout failed")}finally{S(!1)}},[s,n,a,l,ae,f]),w=o.useCallback(()=>{D?.path&&Ne(async()=>{const{useSessionUIStore:u}=await import("./useAppFontEffects-CV5UyTRw.js").then(Y=>Y.eZ);return{useSessionUIStore:u}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({useSessionUIStore:u})=>{u.getState().openNewSessionDraft({directoryOverride:D.path}),Ns.getState().setActiveMainTab("chat")})},[D]),$=ds(y?.url),H=o.useMemo(()=>{const u=[...t.comments];return u.sort((Y,je)=>{const re=Y.createdAt?Date.parse(Y.createdAt):0,Te=je.createdAt?Date.parse(je.createdAt):0;return N==="newest"?Te-re:re-Te}),u},[t.comments,N]),A=H.slice(0,T*20),U=A.filter(u=>!$e(u.author?.login)),W=A.filter(u=>$e(u.author?.login));if(t.detailError&&!d)return e.jsx(ke,{header:e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:q,number:a,openLabel:`Open pull request #${a} on GitHub`,title:`Pull request #${a}`}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(et,{info:vt(t.detailError),onRetry:t.onRetryDetail})});if(!y){const u=t.seed&&t.seed.number===a?t.seed:null;return e.jsx(ke,{header:e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:q,number:a,url:u?.url??null,numberTintClass:u?He("pr",u.state,u.draft):void 0,statePill:u?e.jsx(Ge,{kind:"pr",state:u.state,draft:u.draft}):void 0,openLabel:`Open pull request #${a} on GitHub`,title:u?.title??null,meta:u?e.jsx(Ke,{pr:u}):void 0,branches:u?e.jsx(Je,{pr:u,filesCount:u.changedFiles??null}):void 0}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(us,{label:"Loading pull request"})})}const J=t.checks?.summary??null,me=t.files?.files.length??y.changedFiles??0,v=_>0&&!t.hideFilesTab?`${me} · ${_} pending`:String(me);return e.jsx(ke,{header:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:q,number:y.number,url:y.url,numberTintClass:He("pr",y.state,y.draft),statePill:e.jsx(Ge,{kind:"pr",state:y.state,draft:y.draft}),openLabel:`Open pull request #${y.number} on GitHub`,title:y.title,onEditTitle:()=>{b(y.title),L(!0)},editTitleLabel:"Edit pull request title",editTitleDisabledReason:ee.allowed?null:ee.reason,meta:e.jsx(Ke,{pr:y}),branches:e.jsx(Je,{pr:y,filesCount:me})}),e.jsx(sn,{directory:s,repo:n,number:a,github:l,pr:y,access:Z,acting:m,mergeMethod:p,onMergeMethodChange:z,onRun:u=>{X(u)},checkingOut:V,onCheckout:u=>{ue(u)},onCopyLink:$,askSending:R===`pr-${a}-ask`,onAskAgent:se}),e.jsx(nn,{pr:y,access:Z,acting:m,onRun:u=>{X(u)}})]}),tabs:[{id:"summary",label:"Summary"},...t.hideFilesTab?[]:[{id:"files",label:"Code",hint:v}],{id:"checks",label:"Checks",hint:J?`${J.success}/${J.total}`:void 0,glyph:J?e.jsx(fe,{state:J.state}):void 0}],activeTab:x,onTabChange:u=>k(u),children:e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[t.detailStale?e.jsxs("p",{className:"typography-micro text-muted-foreground",role:"note",children:["Showing saved details — last refresh failed."," ",e.jsx("button",{type:"button",className:"underline",onClick:t.onRetryDetail,children:"Retry"})]}):null,Z.permissionFallback?e.jsx("p",{className:"typography-micro text-muted-foreground",role:"note",children:"Permissions could not be loaded — actions stay enabled and any failure will be shown after you act."}):null,F?e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 py-1",children:[e.jsx(tt,{value:j,onChange:u=>b(u.target.value),"aria-label":"Pull request title",className:"h-7"}),e.jsx(P,{type:"button",variant:"default",size:"xs",onClick:()=>{ne()},children:"Save"}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>L(!1),children:"Cancel"})]}):null,D?e.jsxs("p",{className:"flex flex-wrap items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(M,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]"}),e.jsxs("span",{children:["Ready on ",D.branch,D.path?` at ${D.path}`:"","."]}),D.path?e.jsx(P,{type:"button",variant:"default",size:"xs",onClick:w,children:"Open session here"}):null,e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>K(null),"aria-label":"Dismiss checkout result",children:"Dismiss"})]}):null,x==="summary"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-1.5 py-1",children:[e.jsx(qe,{icon:"user",label:"Reviewers",children:e.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[y.requestedReviewers.length===0?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):y.requestedReviewers.map(u=>e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",children:[e.jsx(nt,{login:u.login,avatarUrl:u.avatarUrl,size:"xs"}),e.jsx("span",{className:"truncate",children:u.login})]},u.login)),e.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[y.reviewSummary.approvals," approvals · ",y.reviewSummary.changesRequested," changes requested ·"," ",y.reviewSummary.commented," commented"]})]})}),e.jsx(qe,{icon:"list-unordered",label:"Labels",children:e.jsx("span",{className:"flex min-w-0 flex-wrap items-center gap-1",children:y.labels.length===0?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):y.labels.map(u=>e.jsx(ms,{name:u.name,color:u.color},u.name))})})]}),e.jsx(Ie,{id:`pr-${a}-description`,title:"Description",action:i?void 0:e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{O(y.body??""),C(!0)},"aria-label":"Edit description",title:ee.reason??"Edit description",disabled:!ee.allowed,children:"Edit"}),children:i?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("textarea",{value:h,onChange:u=>O(u.target.value),rows:6,"aria-label":"Pull request description",className:"min-h-24 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(P,{type:"button",variant:"default",size:"sm",onClick:()=>{oe()},children:"Save"}),e.jsx(P,{type:"button",variant:"ghost",size:"sm",onClick:()=>C(!1),children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(hs,{markdown:y.body??"",html:y.bodyHtml??null,fallbackUrl:y.url,label:"pull request description"}),y.body?.trim()?null:e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No description provided."})]})}),e.jsx(Ie,{id:`pr-${a}-comments`,title:`Comments${H.length?` (${H.length})`:""}`,action:e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",children:[t.hideFilesTab?e.jsx(ct,{directory:s,repo:n,number:a,github:l,access:Z,size:"xs",onReviewSubmitted:t.onRetryDetail}):null,e.jsx(ps,{order:N,onToggle:()=>E(N==="newest"?"oldest":"newest")})]}),children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ve,{error:t.commentsError,onRetry:t.onRetryComments,label:"Comments"}),U.map(u=>e.jsx(fs,{comment:u},u.id)),e.jsx(xs,{comments:W}),t.commentsLoading&&H.length===0&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading comments…"}):null,H.length===0&&!t.commentsLoading&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No comments yet."}):null,H.length>A.length?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>B(T+1),children:"Show older comments"})}):t.commentsHasMore?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:t.onLoadMoreComments,disabled:t.commentsLoading,children:t.commentsLoading?"Loading…":"Load older comments"})}):null,e.jsx(Os,{directory:s,repo:n,number:a,github:l,pr:y,access:Z,onCommented:()=>{t.onRetryComments(),t.onRetryDetail()}})]})})]}):null,x==="files"&&!t.hideFilesTab?e.jsx(Xs,{files:t.files,filesLoading:t.filesLoading,filesError:t.filesError,filesHasMore:t.filesHasMore,onLoadMoreFiles:t.onLoadMoreFiles,onRetryFiles:t.onRetryFiles,threads:t.threads,threadsError:de?.threads??null,onRetryDetail:t.onRetryDetail,directory:s,repo:n,number:a,github:l,access:Z,headSha:y.headSha??null,onReviewSubmitted:t.onRetryDetail},`${n}#${a}`):null,x==="checks"?e.jsx(en,{directory:s,repo:n,number:a,github:l,checks:t.checks,checksError:t.checksError,checksLoading:t.checksLoading,onRetryChecks:t.onRetryChecks,onOpenFilesAtLine:t.onOpenFilesAtLine}):null]})})},ln=({items:t,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,filters:r,checksByUrl:f,incompleteNotice:x=null,remote:k=null,numberJump:m=null,onFiltersChange:g,onClearFilters:p,onLoadMore:z,onRetry:F,onOpen:L,headerActionsSlot:j=null,headerActionsPresentation:b="drawer"})=>{const i=r.state==="open"&&r.involvement==="all"&&!r.search.trim(),C=o.useCallback(h=>e.jsx("li",{role:"listitem",children:e.jsx(yt,{glyph:e.jsx(vs,{kind:"pr",state:h.state,draft:h.draft}),glyphBelow:e.jsx(fe,{state:(h.url?f[h.url]:void 0)??null}),number:`#${h.number}`,title:h.title,status:e.jsx(ge,{additions:h.additions,deletions:h.deletions,className:"typography-micro"}),meta:e.jsxs(e.Fragment,{children:[e.jsx(jt,{login:h.author?.login,avatarUrl:h.author?.avatarUrl}),e.jsx(wt,{head:h.head,base:h.base}),h.draft?e.jsx("span",{className:"shrink-0 rounded bg-[var(--surface-muted)] px-1 typography-micro text-muted-foreground",children:"Draft"}):null]}),updatedAt:h.updatedAt,onOpen:()=>L(h.number),ariaLabel:`Open pull request #${h.number} ${h.title}`})},h.number),[f,L]);return e.jsx(kt,{items:t,renderRow:C,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,searchValue:r.search,onSearchChange:h=>g({search:h}),searchPlaceholder:"Search pull requests, or label:bug",searchAriaLabel:"Search pull requests",toolbarControls:e.jsx(Ct,{stateValue:r.state,stateOptions:ws.map(h=>({id:h.id,label:h.label})),onStateChange:h=>g({state:h}),involvementValue:r.involvement,involvementOptions:js.map(h=>({id:h.id,label:h.label})),onInvolvementChange:h=>g({involvement:h}),sortValue:r.sort,sortOptions:ys.map(h=>({id:h.id,label:h.label})),onSortChange:h=>g({sort:h}),sortAriaLabel:"Sort pull requests"}),headerActionsSlot:j,headerActionsPresentation:b,isDefaultFilters:i,noItemsTitle:r.state==="open"?"No open pull requests":"No pull requests yet",noItemsBody:"Pull requests for this repository appear here.",noItemsIcon:"git-pull-request",listAriaLabel:"Pull requests",skeletonLabel:"Loading pull requests",incompleteNotice:x,remote:k,numberJump:m,numberJumpKind:"pull request",onClearFilters:p,onLoadMore:z,onRetry:F,onOpen:L})},on=t=>{const s=At(n=>n.results);return o.useMemo(()=>{const n=Dt(s),a={};for(const l of t){if(!l.url)continue;const d=n.get(l.url);d!==void 0&&(a[l.url]=d)}return a},[t,s])},da=({hideFilesTab:t=!1,headerActionsSlot:s=null,headerActionsPresentation:n="drawer"})=>{const a=Tt()??"";return a?e.jsx(rn,{directory:a,hideFilesTab:t,headerActionsSlot:s,headerActionsPresentation:n}):e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center",children:e.jsx("p",{className:"typography-ui text-muted-foreground",children:"Open a project to browse pull requests."})})},rn=({directory:t,hideFilesTab:s,headerActionsSlot:n=null,headerActionsPresentation:a="drawer"})=>{const d=Ee().github??null,[c,r]=o.useState(!1),[f,x]=o.useState(!1),k=o.useRef(null);return o.useEffect(()=>$t(),[]),e.jsx(Nt,{directory:t,isRefreshing:c,onRefresh:()=>k.current?.(),children:({repo:m,directory:g})=>e.jsx(cn,{directory:g,repo:m,github:d,refreshing:c,setRefreshing:r,loadingMore:f,setLoadingMore:x,refreshRef:k,hideFilesTab:s,headerActionsSlot:n,headerActionsPresentation:a},m)})},cn=({directory:t,repo:s,github:n,refreshing:a,setRefreshing:l,loadingMore:d,setLoadingMore:c,refreshRef:r,hideFilesTab:f,headerActionsSlot:x=null,headerActionsPresentation:k="drawer"})=>{const m=I(v=>v.ensureCollectionsFresh),g=I(v=>v.searchRemote),p=I(v=>v.loadMoreRemote),z=I(v=>v.loadMoreCollection),F=I(v=>v.refreshAllForScope),L=I(v=>v.selectPullRequest),j=I(v=>v.setFilters),b=I(v=>v.resetFilters),i=Gt(t,s),C=Ht(t),h=qt(),O=C.repo===s?C.number:null,N=i.state==="open"?"open":i.state==="all"?"both":"closed";o.useEffect(()=>{if(!n)return;let v=!1;return l(!0),m(t,s,N,n).then(()=>{v||l(!1)}).catch(()=>{v||l(!1)}),()=>{v=!0}},[t,s,n,N]),o.useEffect(()=>{if(!n)return;const v=()=>{typeof document<"u"&&document.hidden||m(t,s,N,n).catch(()=>{})};return window.addEventListener("focus",v),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("focus",v),document.removeEventListener("visibilitychange",v)}},[t,s,n,N]);const E=De(s,"open"),T=De(s,"closed"),B=o.useMemo(()=>It(s),[s,E?.data,T?.data]),V=o.useMemo(()=>new Set(B.map(v=>v.number)),[B]),S=o.useMemo(()=>Ot(B,{state:i.state,involvement:i.involvement,search:i.search,sort:i.sort,viewerLogin:h}),[B,i.state,i.involvement,i.search,i.sort,h]),D=on(S),K=N==="both"?[E,T]:[N==="open"?E:T],_=K.some(v=>v?.data!=null),Q=_&&K.every(v=>v?.data?.nextCursor==null),R=K.reduce((v,u)=>v+(u?.data?.items.length??0),0),q=K.find(v=>v?.error)?.error??null,y=K.some(v=>v?.isLoading),de=K.some(v=>v?.stale),Z=i.search.trim(),ee=i.involvement!=="all"&&!h,X=Z.length>0||i.involvement!=="all",se=o.useMemo(()=>({state:i.state,involvement:i.involvement,q:Z}),[i.state,i.involvement,Z]),ne=`${se.state}|${se.involvement}|${se.q}`,oe=!Q&&_&&S.length===0&&(Z.length>0||ee),ae=o.useCallback(v=>n?g(t,s,v,n):Promise.resolve(null),[t,s,n,g]),ue=o.useCallback(v=>n?p(t,s,v,n):Promise.resolve(null),[t,s,n,p]),{remoteView:w,numberJump:$,remotePending:H,handleSearchAll:ie}=St({repo:s,query:se,queryKey:ne,autoRemote:oe,indexNumbers:V,visibleItems:S,searchText:Z,useRemoteEntry:Jt,runSearch:ae,runLoadMore:ue}),A=o.useMemo(()=>{if(Q||!_||!X)return null;const v=S.length===1?"1 match":`${S.length} matches`,u=R===1?"1 most recent loaded pull request":`${R} most recent loaded pull requests`;return`Showing ${v} from the ${u}`},[Q,_,X,S.length,R]),U=o.useCallback(()=>{n&&(l(!0),F(t,s,n).then(()=>{l(!1)}).catch(()=>l(!1)))},[t,s,n,F,l]);o.useEffect(()=>(r.current=U,()=>{r.current===U&&(r.current=null)}),[r,U]);const W=o.useCallback(()=>{if(!n)return;c(!0);const v=N==="both"?["open","closed"]:[N];Promise.all(v.map(u=>z(t,s,u,n))).then(()=>c(!1)).catch(()=>c(!1))},[t,s,N,n,z,c]),J=o.useCallback(v=>{L(t,s,v)},[t,s,L]),me=o.useCallback(()=>{L(t,null,null)},[t,L]);return n?O!=null?e.jsx(dn,{directory:t,repo:s,number:O,github:n,onBack:me,hideFilesTab:f,seed:Bt(s,O)}):e.jsx(ln,{items:S,headerActionsSlot:x,headerActionsPresentation:k,hasMore:K.some(v=>v?.data?.nextCursor!=null),isLoadingMore:d,isLoading:y,isRefreshing:a&&_,stale:de,error:q,filters:i,checksByUrl:D,incompleteNotice:A?{summary:A,searching:H,onSearchAll:ie}:null,remote:w,numberJump:$,onFiltersChange:v=>j(t,s,v),onClearFilters:()=>b(t,s),onLoadMore:W,onRetry:U,onOpen:J}):e.jsx(et,{info:{reason:"failed",message:"GitHub is not available in this runtime."}})},dn=({directory:t,repo:s,number:n,github:a,onBack:l,hideFilesTab:d,seed:c})=>{const r=I(S=>S.ensureDetail),f=I(S=>S.ensureComments),x=I(S=>S.ensureFiles),k=I(S=>S.ensureChecks),m=I(S=>S.loadMoreFiles),g=I(S=>S.loadMoreComments),p=I(S=>S.refreshComments),z=I(S=>S.refreshDetail),F=I(S=>S.refreshChecks);o.useEffect(()=>{r(t,s,n,a).catch(()=>{}),f(t,s,n,a).catch(()=>{}),d||x(t,s,n,a).catch(()=>{}),k(t,s,n,a).catch(()=>{})},[t,s,n,d]);const L=_t(s,n),j=Ut(s,n),b=Vt(s,n),i=Kt(s,n),C=L?.data?.detail??null,h=o.useCallback((S,D)=>{const K=Ss(t);Ne(async()=>{const{useUIStore:_}=await import("./index-CKKWVoND.js").then(Q=>Q.cN);return{useUIStore:_}},__vite__mapDeps([1,2,3,4,5,6,7,8])).then(({useUIStore:_})=>{_.getState().openContextFileAtLine(K,S,D)}).catch(()=>{})},[t]),O=o.useCallback(()=>{m(t,s,n,a).catch(()=>{})},[t,s,n,a,m]),N=o.useCallback(()=>{g(t,s,n,a).catch(()=>{})},[t,s,n,a,g]),E=o.useCallback(()=>{p(t,s,n,a).catch(()=>{})},[t,s,n,a,p]),T=o.useCallback(()=>{z(t,s,n,a).catch(()=>{})},[t,s,n,a,z]),B=o.useCallback(()=>{x(t,s,n,a).catch(()=>{})},[t,s,n,a,x]),V=o.useCallback(()=>{F(t,s,n,a).catch(()=>{})},[t,s,n,a,F]);return e.jsx(an,{hideFilesTab:d,seed:c,directory:t,repo:s,number:n,github:a,detail:C,detailError:L?.error??null,detailStale:L?.stale??!1,files:b?.data??null,filesError:b?.error??null,filesLoading:b?.isLoading??!1,filesHasMore:b?.data?.nextCursor!=null,onLoadMoreFiles:O,checks:i?.data??null,checksError:i?.error??null,checksLoading:i?.isLoading??!1,reviews:C?.reviews??[],threads:C?.threads??[],comments:j?.data?.comments??[],commentsError:j?.error??null,commentsLoading:j?.isLoading??!1,commentsHasMore:j?.data?.nextCursor!=null,onLoadMoreComments:N,onRetryComments:E,onBack:l,onRetryDetail:T,onRetryFiles:B,onRetryChecks:V,onOpenFilesAtLine:h})};export{da as PullRequestsSurface};
|