@pi-chamber/web 1.0.4 → 1.0.5-rc.1
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/README.md +1 -1
- package/bin/cli.js +21 -2
- package/bin/cli.test.js +164 -4
- package/bin/lib/DOCUMENTATION.md +3 -3
- package/bin/lib/cli-args.js +96 -13
- package/bin/lib/commands-connect-url-tailscale.test.js +136 -0
- package/bin/lib/commands-connect-url.js +146 -39
- package/bin/lib/commands-connect-url.test.js +126 -0
- package/bin/lib/commands-serve.js +45 -2
- package/bin/lib/commands-status.js +28 -5
- package/bin/lib/commands-status.test.js +107 -0
- package/bin/lib/commands-tunnel.js +36 -10
- package/dist/assets/{DiagramView-BpG1c3Hi.js → DiagramView-D-OSWTbO.js} +1 -1
- package/dist/assets/DiffView-BKT-MIH4.js +18 -0
- package/dist/assets/{FileSaveConflictDialog-DP7k9a-i.js → FileSaveConflictDialog-DBkVFssC.js} +2 -2
- package/dist/assets/FilesView-B7GIuRlh.js +6 -0
- package/dist/assets/{GitHubDetailScaffold-UxLAMAOl.js → GitHubDetailScaffold-C9rCZMUT.js} +2 -2
- package/dist/assets/{GitHubLinkPicker-Bh9RO1yK.js → GitHubLinkPicker-Bm09hvhJ.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-DQyhT5wG.js → GitHubListPrimitives-DlhAlxI6.js} +1 -1
- package/dist/assets/{GitView-XBBheKRM.js → GitView-BgqdMb0m.js} +4 -4
- package/dist/assets/{IssuesSurface-BA1kpvAJ.js → IssuesSurface-BZXAvt49.js} +3 -3
- package/dist/assets/{JsonTreeView-BAaEPL4O.js → JsonTreeView-BKgCQjh_.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DzgDmUsL.js → MarkdownRendererImpl-BdcyMPw-.js} +1 -1
- package/dist/assets/{PatchDiff-BMEUsgXH.js → PatchDiff-2MmWXcGe.js} +1 -1
- package/dist/assets/PierreDiffViewer-D1F2WvD0.js +135 -0
- package/dist/assets/PullRequestsSurface-CN2z3DFv.js +2 -0
- package/dist/assets/SessionSwitcherContent-CCljxAZb.js +1 -0
- package/dist/assets/SessionSwitcherDropdown-DtNt3qw4.js +2 -0
- package/dist/assets/SessionUnreadDot-B9bHMy5q.js +1 -0
- package/dist/assets/SettingsView-DaZVCInW.js +6 -0
- package/dist/assets/{SettingsWindow-j0e99YI0.js → SettingsWindow-C-ydfopH.js} +1 -1
- package/dist/assets/StickyHorizontalScrollbar-BMITjK4e.js +8 -0
- package/dist/assets/{ToolOutputDialog-VlS12Xyq.js → ToolOutputDialog-DJUAx_Oj.js} +4 -4
- package/dist/assets/{ToolPartDiffPreview-DdSneZws.js → ToolPartDiffPreview-DFyuJM4c.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-BqiXjvP6.js → VirtualizedFileDiff-BS-af6rn.js} +4 -4
- package/dist/assets/{Virtualizer-Cp_cJWbI.js → Virtualizer-DP6HbEeC.js} +1 -1
- package/dist/assets/{collapsible-C7oyikVm.js → collapsible-BOcd0lzY.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-BJjC-tXV.js → computeVirtualFileMetrics-BI6wORhM.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-BBzqKGei.js → contextFileOpenGuard-DUMSGR4M.js} +1 -1
- package/dist/assets/{gitStatusPredicates-Dq-E5DaH.js → gitStatusPredicates-FdKYDZe3.js} +1 -1
- package/dist/assets/{githubLink-Cryd7GkG.js → githubLink-B3-BaGpb.js} +5 -5
- package/dist/assets/index-DWSrsQWl.js +11 -0
- package/dist/assets/{index-BbhXFTId.js → index-Df-vmvzu.js} +1 -1
- package/dist/assets/index-DsQIBAWK.css +1 -0
- package/dist/assets/main-61_cd7S7.js +2 -0
- package/dist/assets/main-q43jqZ2I.js +136 -0
- package/dist/assets/{markdownCore-B9AuEyYi.js → markdownCore-CqHYlXi_.js} +2 -2
- package/dist/assets/{miniChat-CgOaJfD8.js → miniChat-vOuWN5pV.js} +2 -2
- package/dist/assets/mobile-mrXWV5ky.js +2 -0
- package/dist/assets/{nativeFileSave-BzhtrDoD.js → nativeFileSave-CFuugNKV.js} +1 -1
- package/dist/assets/pi-session-focus-preference-BEufpwC6.js +9 -0
- package/dist/assets/{renderDiffWithHighlighter-CVLsdtQ5.js → renderDiffWithHighlighter-BD9CAhZU.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-QQFXkY5Y.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-DJ9mk2bZ.js → renderFileWithHighlighter-KiEWMtzI.js} +1 -1
- package/dist/assets/renderMobileApp-DIZYvrhi.js +11 -0
- package/dist/assets/runtimeEndpointReset-BA2uP2rj.js +62 -0
- package/dist/assets/{runtimeSurface-DBiUWYK2.js → runtimeSurface-Der4qUnI.js} +1 -1
- package/dist/assets/useAppFontEffects-Bfw_d5eB.js +212 -0
- package/dist/assets/{useFilesViewSearch-D2Au5Xgt.js → useFilesViewSearch-Budwejnx.js} +3 -3
- package/dist/assets/useGitHubRemoteSearch-gUdylYy3.js +1 -0
- package/dist/assets/{useSwitcherItems-Dej8BzXI.js → useSwitcherItems-yHSMduoo.js} +1 -1
- package/dist/assets/{vendor-aparajita-capacitor-secure-storage-BYohCVY0.js → vendor-aparajita-capacitor-secure-storage-BDrMx_CE.js} +1 -1
- package/dist/assets/{vendor-base-ui-BscvGUFt.js → vendor-base-ui-CKRUCG-f.js} +1 -1
- package/dist/assets/{vendor-boot-Dgb9NVFe.js → vendor-boot-EC6IyLt1.js} +13 -13
- package/dist/assets/{vendor-capacitor-app-BjdQVib9.js → vendor-capacitor-app-BaupizkW.js} +1 -1
- package/dist/assets/{vendor-capacitor-keyboard-eTtI5go3.js → vendor-capacitor-keyboard-9BVxykO7.js} +1 -1
- package/dist/assets/{vendor-capacitor-status-bar-9rNIGxlO.js → vendor-capacitor-status-bar-BsrUwiaA.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-DxS3jwvE.js → vendor-codemirror-autocomplete-CGpAsPWp.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-DdjXl9e2.js → vendor-codemirror-lang-angular-CDJoHJSY.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp--aMr7NVt.js → vendor-codemirror-lang-cpp-BmHofQls.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-CZ_qxZY9.js → vendor-codemirror-lang-css-RM2HqXZ0.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-Ca-y2Alu.js → vendor-codemirror-lang-go-Crwca_X7.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-COZ0L5wT.js → vendor-codemirror-lang-html-CHSHUpwq.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-D3Rf3QNJ.js → vendor-codemirror-lang-java-lhQXgWu0.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-DwJ-IvCs.js → vendor-codemirror-lang-javascript-Dw4kFO4e.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-D_5lod6k.js → vendor-codemirror-lang-jinja-_pAC3UTN.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-BG8C7OpC.js → vendor-codemirror-lang-json-B-b1vAv-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-CVEkoaTw.js → vendor-codemirror-lang-less-xIgOi1ze.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-U9vj0m8w.js → vendor-codemirror-lang-liquid-CP49m5dB.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-DqlYH9gY.js → vendor-codemirror-lang-markdown-BTht2ATe.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-BFEiEVA1.js → vendor-codemirror-lang-php-BguZDhaO.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-Cz1dQXQd.js → vendor-codemirror-lang-python-CH6_em9L.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-C_CoD9mj.js → vendor-codemirror-lang-rust-EG_DtGyi.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-BuR0aKh5.js → vendor-codemirror-lang-sass-BknY5Qpo.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-DggNUjdM.js → vendor-codemirror-lang-sql-B0f-qCZo.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-DFZHi2J3.js → vendor-codemirror-lang-vue-CyGn9snv.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-zuTN3SHT.js → vendor-codemirror-lang-wast-CsFfSyyB.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-CrcvhI-k.js → vendor-codemirror-lang-xml-Cdan_Jp1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-DcVWsakb.js → vendor-codemirror-lang-yaml-COI5hck8.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-CCLITgCF.js → vendor-codemirror-language-data-CqU7kHmg.js} +2 -2
- package/dist/assets/{vendor-codemirror-search-H7NOEdbX.js → vendor-codemirror-search-DUfSCF9S.js} +1 -1
- package/dist/assets/{vendor-lezer-cpp-C8aD2KAr.js → vendor-lezer-cpp-DMZOJzBa.js} +1 -1
- package/dist/assets/{vendor-lezer-css-2lbTJF-Y.js → vendor-lezer-css-DUkkbMp7.js} +1 -1
- package/dist/assets/{vendor-lezer-go-Bw6LFTrZ.js → vendor-lezer-go-CHIhCNY6.js} +1 -1
- package/dist/assets/{vendor-lezer-html-D7ym2z7S.js → vendor-lezer-html-B3h0MOrG.js} +1 -1
- package/dist/assets/{vendor-lezer-java-CZhK7w21.js → vendor-lezer-java-tMazV_6X.js} +1 -1
- package/dist/assets/{vendor-lezer-javascript-rpKeTHZp.js → vendor-lezer-javascript-ctwLWf4v.js} +1 -1
- package/dist/assets/{vendor-lezer-json-C7jwsd2G.js → vendor-lezer-json-BP_UAzLL.js} +1 -1
- package/dist/assets/{vendor-lezer-lr-DR-ylqNN.js → vendor-lezer-lr-B8TQctNw.js} +1 -1
- package/dist/assets/{vendor-lezer-markdown-Bir0m5nB.js → vendor-lezer-markdown-aGLZf_3h.js} +1 -1
- package/dist/assets/{vendor-lezer-php-y0hIEfo1.js → vendor-lezer-php-D5zCNzlt.js} +1 -1
- package/dist/assets/{vendor-lezer-python-D64A9lNV.js → vendor-lezer-python-EJ4Im4y2.js} +1 -1
- package/dist/assets/{vendor-lezer-rust-E3ZA9T2L.js → vendor-lezer-rust-DO5c7OtA.js} +1 -1
- package/dist/assets/{vendor-lezer-sass-C5UFI9SP.js → vendor-lezer-sass-CMi6zfXI.js} +1 -1
- package/dist/assets/{vendor-lezer-xml-DOy7FzCR.js → vendor-lezer-xml-0MHMeZDp.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-kEjaSCvZ.js → vendor-lezer-yaml-BE2EFjpA.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-BLfh0LPy.js → vendor-replit-codemirror-vim-AnOuN8yJ.js} +1 -1
- package/dist/assets/{web-components-C7CmoFxi.js → web-components-CeHLxvED.js} +3 -3
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/dist/sw.js +1 -1
- package/package.json +1 -2
- package/server/index.js +69 -30
- package/server/lib/client-auth/DOCUMENTATION.md +15 -1
- package/server/lib/client-auth/pairing.js +2 -12
- package/server/lib/client-auth/remote-clients.js +2 -12
- package/server/lib/cloudflare-tunnel.js +0 -132
- package/server/lib/fs/DOCUMENTATION.md +8 -0
- package/server/lib/fs/atomic-write.js +111 -0
- package/server/lib/fs/atomic-write.test.js +133 -0
- package/server/lib/notifications/DOCUMENTATION.md +43 -32
- package/server/lib/notifications/pi-notification-watcher.js +8 -7
- package/server/lib/notifications/pi-notification-watcher.test.js +88 -2
- package/server/lib/pi/routes-extension-events.test.js +231 -0
- package/server/lib/pi/routes.js +137 -4
- package/server/lib/pi/routes.test.js +248 -2
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +17 -4
- package/server/lib/pi/session-daemon/daemon-process.js +2 -0
- package/server/lib/pi/session-daemon/engines/index.js +6 -0
- package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +1 -1
- package/server/lib/pi/session-daemon/extension-bridge.js +24 -0
- package/server/lib/pi/session-daemon/extension-message-render.js +74 -0
- package/server/lib/pi/session-daemon/extension-message-render.test.js +164 -0
- package/server/lib/pi/session-daemon/extension-tool-render.js +13 -6
- package/server/lib/pi/session-daemon/pending-input.js +188 -0
- package/server/lib/pi/session-daemon/pending-input.test.js +202 -0
- package/server/lib/pi/session-daemon/session-daemon-engines.test.js +828 -0
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +296 -6
- package/server/lib/pi/session-daemon/session-daemon-turn.e2e.test.js +9 -0
- package/server/lib/pi/session-daemon/session-daemon.js +219 -19
- package/server/lib/pi/session-daemon/session-daemon.test.js +30 -2
- package/server/lib/pi/session-daemon/session-engine-router.js +390 -0
- package/server/lib/pi/session-daemon/session-engine-router.test.js +515 -0
- package/server/lib/pi/session-daemon/session-engines.js +467 -0
- package/server/lib/pi/session-daemon/session-engines.test.js +383 -0
- package/server/lib/pi/snippets-store.js +8 -17
- package/server/lib/pi/ui-settings-store.js +6 -10
- package/server/lib/pi/ui-settings-store.test.js +37 -1
- package/server/lib/relay/DOCUMENTATION.md +6 -4
- package/server/lib/relay/identity-store.js +116 -0
- package/server/lib/relay/identity-store.test.js +169 -0
- package/server/lib/relay/identity.js +6 -4
- package/server/lib/relay/server-id.js +63 -0
- package/server/lib/relay/server-id.test.js +132 -0
- package/server/lib/relay/signing-key.js +14 -11
- package/server/lib/security/bind-host.js +6 -2
- package/server/lib/security/bind-host.test.js +17 -0
- package/server/lib/server/core-routes.js +27 -1
- package/server/lib/server/lan-addresses.js +18 -6
- package/server/lib/server/lan-addresses.test.js +28 -0
- package/server/lib/server/tunnel-auth.js +47 -7
- package/server/lib/server/tunnel-auth.rate-limit.test.js +164 -0
- package/server/lib/server/tunnel-service.DOCUMENTATION.md +3 -4
- package/server/lib/server/tunnel-service.js +23 -20
- package/server/lib/server/tunnel-service.test.js +19 -2
- package/server/lib/stt/config-store.js +5 -15
- package/server/lib/tailscale/DOCUMENTATION.md +264 -0
- package/server/lib/tailscale/routes.js +45 -0
- package/server/lib/tailscale/service.js +959 -0
- package/server/lib/tailscale/tailscale.js +302 -0
- package/server/lib/tailscale/tailscale.test.js +1861 -0
- package/server/lib/tunnels/DOCUMENTATION.md +3 -4
- package/server/lib/tunnels/providers/cloudflare.js +1 -22
- package/server/lib/tunnels/types.js +0 -2
- package/server/lib/ui-auth/DOCUMENTATION.md +31 -0
- package/server/lib/ui-auth/ui-auth.js +80 -6
- package/server/lib/ui-auth/ui-auth.test.js +136 -0
- package/server/lib/ui-auth/ui-passkeys.js +2 -13
- package/server/lib/update-job-store.js +4 -6
- package/dist/assets/DiffView-BxwoRCYx.js +0 -18
- package/dist/assets/FilesView-D_2QcdUt.js +0 -6
- package/dist/assets/PierreDiffViewer-BW8MO-O6.js +0 -134
- package/dist/assets/PullRequestsSurface-B3ictm4I.js +0 -2
- package/dist/assets/SessionSwitcherContent-rLoyVqgs.js +0 -1
- package/dist/assets/SessionSwitcherDropdown-CfySKnUu.js +0 -2
- package/dist/assets/SessionUnreadDot-CmEF9sxM.js +0 -1
- package/dist/assets/SettingsView-BiwlwnTK.js +0 -6
- package/dist/assets/index-BnZVqcki.js +0 -11
- package/dist/assets/index-BnieExes.css +0 -1
- package/dist/assets/main-9O5IAtT_.js +0 -136
- package/dist/assets/main-DWGwALIw.js +0 -2
- package/dist/assets/mobile-BbJcYVym.js +0 -2
- package/dist/assets/pi-session-focus-preference-Bmk1iOvn.js +0 -10
- package/dist/assets/renderElectronMiniChatApp-R5o9NwFC.js +0 -2
- package/dist/assets/renderMobileApp-CQ9tWYIj.js +0 -11
- package/dist/assets/runtimeEndpointReset-CtK4C_5h.js +0 -62
- package/dist/assets/useAppFontEffects-DviRbaCJ.js +0 -212
- package/dist/assets/useGitHubRemoteSearch-D-K7aolk.js +0 -1
- package/dist/assets/vendor-capacitor-push-notifications-CBKq2Arn.js +0 -1
- package/server/lib/notifications/delivery-runtime.js +0 -314
- package/server/lib/notifications/delivery-runtime.test.js +0 -85
- package/server/lib/notifications/routes.js +0 -74
- package/server/lib/relay/service.js +0 -9
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiffView-BxwoRCYx.js","assets/vendor-boot-Dgb9NVFe.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js","assets/index-BnZVqcki.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BnieExes.css","assets/useAppFontEffects-DviRbaCJ.js","assets/runtimeSurface-DBiUWYK2.js","assets/nativeFileSave-BzhtrDoD.js","assets/gitStatusPredicates-Dq-E5DaH.js","assets/VirtualizedFileDiff-BqiXjvP6.js","assets/web-components-C7CmoFxi.js","assets/computeVirtualFileMetrics-BJjC-tXV.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/renderDiffWithHighlighter-CVLsdtQ5.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-BW8MO-O6.js","assets/runtimeEndpointReset-CtK4C_5h.js","assets/SessionUnreadDot-CmEF9sxM.js","assets/permissionStore-B9Hkrqny.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/vendor-xterm-xterm-css-DDGTF8rc.css","assets/appThemeRegistry-gegrE2dq.js","assets/registerCustomTheme-DmolaWWZ.js","assets/contextFileOpenGuard-BBzqKGei.js","assets/FilesView-D_2QcdUt.js","assets/vendor-codemirror-lang-javascript-DwJ-IvCs.js","assets/vendor-lezer-javascript-rpKeTHZp.js","assets/vendor-lezer-lr-DR-ylqNN.js","assets/vendor-codemirror-autocomplete-DxS3jwvE.js","assets/vendor-codemirror-lang-json-BG8C7OpC.js","assets/vendor-lezer-json-C7jwsd2G.js","assets/vendor-codemirror-lang-css-CZ_qxZY9.js","assets/vendor-lezer-css-2lbTJF-Y.js","assets/vendor-codemirror-lang-html-COZ0L5wT.js","assets/vendor-lezer-html-D7ym2z7S.js","assets/vendor-codemirror-lang-markdown-DqlYH9gY.js","assets/vendor-lezer-markdown-Bir0m5nB.js","assets/vendor-codemirror-language-data-CCLITgCF.js","assets/vendor-codemirror-lang-python-Cz1dQXQd.js","assets/vendor-lezer-python-D64A9lNV.js","assets/shell-CjFT_Tl9.js","assets/FileSaveConflictDialog-DP7k9a-i.js","assets/vendor-react-drawio-Duu5LgQA.js","assets/useFilesViewSearch-D2Au5Xgt.js","assets/JsonTreeView-BAaEPL4O.js","assets/Virtualizer-Cp_cJWbI.js","assets/renderFileWithHighlighter-DJ9mk2bZ.js","assets/vendor-codemirror-search-H7NOEdbX.js","assets/vendor-replit-codemirror-vim-BLfh0LPy.js","assets/GitView-XBBheKRM.js","assets/GitHubDetailScaffold-UxLAMAOl.js","assets/vendor-dompurify-r8glNMJW.js","assets/collapsible-C7oyikVm.js","assets/vendor-base-ui-BscvGUFt.js","assets/PullRequestsSurface-B3ictm4I.js","assets/useGitHubRemoteSearch-D-K7aolk.js","assets/GitHubListPrimitives-DQyhT5wG.js","assets/IssuesSurface-BA1kpvAJ.js","assets/githubLink-Cryd7GkG.js","assets/DiagramView-BpG1c3Hi.js","assets/SettingsView-BiwlwnTK.js","assets/vendor-qrcode-Dv4uniC1.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/SettingsWindow-j0e99YI0.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{aO as on,aP as mt,aQ as Vn,k as e,aR as an,aS as ln,aT as cn,aU as Kn,aV as Xn,aW as dn,aX as un,aY as qn,aZ as Gn,a_ as Yn,a$ as Jn,b0 as Mt,b1 as Qe,aM as It,aN as Qn}from"./vendor-boot-Dgb9NVFe.js";import{R as r,a as Ne}from"./vendor-react-DASdDPIk.js";/* empty css */import{t as ne,o as le,m as rt,E as hn,F as Zn,h as fn,G as pn,a as er,H as tr,I as nr,v as Te,J as rr,K as Ae,L as sr,M as or,N as ar,O as Lt,P as Xe,u as ir,Q as lr,R as cr,S as dr,T as ur,U as mn,V as gn,W as hr,X as fr,Y as pr,A as mr,Z as gr,B as xr,w as xn,z as wr}from"./index-BnZVqcki.js";import{_ as Ee}from"./vendor-vite-runtime-DD1OZmLC.js";import{l as yr,y as br,z as vr,B as Sr,E as jr,G as Cr,I as wn,J as yn,K as gt,T as bn,L as Nr,N as kr,O as Pr,m as Rr,w as Er,t as Tr,v as _r,H as Ot,C as $t,A as Wt,S as Ft,n as Ar,p as Dr,x as Mr,q as Ir,F as Lr,W as Or}from"./runtimeEndpointReset-CtK4C_5h.js";import{a4 as at,I as V,E as Pe,a5 as it,h as Ce,t as je,a6 as $r,B as me,o as st,P as vn,a7 as yt,a8 as Wr,a9 as We,aa as Fe,ab as Fr,ac as Be,ad as Br,ae as bt,af as zr,ag as Ur,q as vt,p as Je,ah as Sn,ai as Bt,aj as Hr,ak as St,al as jt,am as Ct,an as Nt,ao as kt,ap as Vr,aq as Kr,ar as Xr,as as qr,at as jn,H as $e,au as qe,av as Gr,aw as Yr,ax as _e,ay as Cn,az as Jr,aA as Qr,aB as Pt,aC as Zr,aD as Nn,s as zt,aE as es,aF as ts,aG as ns,aH as rs,aI as Ut,aJ as ss,b as os,c as as,aK as is,a as Ht,aL as ls,r as lt,aM as cs,aN as ds,aO as us,aP as hs,aQ as fs,aR as ps,aS as ms,aT as Ve,aU as Ke,aV as gs,a2 as xs,a3 as ws,U as ys,T as bs,V as vs,R as Ss,X as js,W as Cs,Y as Ns,Z as ks,a0 as Ps,a1 as Rs}from"./useAppFontEffects-DviRbaCJ.js";import{v as kn,g as Pn}from"./contextFileOpenGuard-BBzqKGei.js";import{g as Rn,u as Es,s as Ts,i as _s,a as As,b as Ds}from"./useFilesViewSearch-D2Au5Xgt.js";import{g as En}from"./SessionUnreadDot-CmEF9sxM.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";/* empty css */import"./nativeFileSave-BzhtrDoD.js";import"./permissionStore-B9Hkrqny.js";import"./runtimeSurface-DBiUWYK2.js";const Ms=280,Vt=4,Is=({transform:t})=>({...t,y:0}),Ls=({id:t,children:n,className:o})=>{const{attributes:i,listeners:a,setNodeRef:m,transform:x,transition:c,isDragging:h}=dn({id:t});return e.jsx("div",{ref:m,"data-sortable-tab-id":t,style:{transform:un.Transform.toString(x),transition:c},className:le("h-full rounded-md",o,h&&"opacity-50"),...i,...a,children:n})},Os=({id:t,children:n,className:o})=>e.jsx("div",{className:le("h-full",o),"data-sortable-tab-id":t,children:n}),$s=({items:t,activeId:n,onSelect:o,onClose:i,onReorder:a,layoutMode:m="scrollable",variant:x="default",activePillInsetClassName:c,activePillButtonClassName:h,inactiveTabsIconOnly:g=!1,animateActivePill:v,activePillLowercase:u=!0,nonCompositedIndicator:l=!1,className:N})=>{const f=ne(P=>P.isMobile),{isTablet:T}=at(),p=f||T,S=r.useRef(null),[k,O]=r.useState({left:!1,right:!1}),oe=r.useMemo(()=>t.map(P=>P.id),[t]),z=m==="scrollable",G=x==="default",Q=x==="active-pill",b=Q||x==="animated",X=G,q=b||X,K=Q&&z,Y=b,ee=v??b,E=typeof a=="function",Z=E?Ls:Os,j=r.useRef(new Map),[W,re]=r.useState(null),[$,F]=r.useState(!1),[ie,ce]=r.useState(null),he=r.useRef(!1),ge=r.useRef(0),pe=r.useRef(n),de=r.useRef(null),ue=r.useMemo(()=>{if(!q||!ie||!n||ie===n)return 0;const P=t.findIndex(fe=>fe.id===ie),se=t.findIndex(fe=>fe.id===n);return P<0||se<0?0:P>se?Vt:-Vt},[n,t,ie,q]),M=on(mt(Vn,{activationConstraint:{distance:8}})),B=r.useCallback((P,se)=>!P||!se?P===se:Math.abs(P.left-se.left)<.5&&Math.abs(P.top-se.top)<.5&&Math.abs(P.width-se.width)<.5&&Math.abs(P.height-se.height)<.5,[]),U=r.useCallback((P,se)=>{if(se){j.current.set(P,se);return}j.current.delete(P)},[]),J=r.useCallback(()=>{if(!q||!n){re(L=>L===null?L:null);return}const P=S.current,se=j.current.get(n);if(!P||!se){re(L=>L===null?L:null);return}let fe=0,R=0,w=se;for(;w&&w!==P;)fe+=w.offsetLeft,R+=w.offsetTop,w=w.offsetParent;const _={left:fe,top:R,width:se.offsetWidth,height:se.offsetHeight};re(L=>B(L,_)?L:_)},[n,B,q]),ae=r.useCallback(()=>{if(!z){O({left:!1,right:!1});return}const P=S.current;if(!P){O({left:!1,right:!1});return}O({left:P.scrollLeft>2,right:P.scrollLeft+P.clientWidth<P.scrollWidth-2})},[z]);r.useEffect(()=>{if(!z){O({left:!1,right:!1});return}const P=S.current;if(!P)return;ae(),P.addEventListener("scroll",ae,{passive:!0});const se=new ResizeObserver(ae);return se.observe(P),()=>{P.removeEventListener("scroll",ae),se.disconnect()}},[z,t.length,ae]),r.useEffect(()=>{if(!q){re(null);return}J();const P=S.current;if(!P)return;const se=new ResizeObserver(()=>{performance.now()-ge.current>Ms&&F(!1),J()});if(se.observe(P),n){const fe=j.current.get(n);fe&&se.observe(fe)}return()=>{se.disconnect()}},[n,t.length,J,q]),r.useLayoutEffect(()=>{J()});const xe=oe.join("\0");r.useLayoutEffect(()=>{if(!q){he.current=!1,F(!1);return}const P=de.current!==xe;if(de.current=xe,!he.current){he.current=!0,pe.current=n;return}const se=pe.current!==n;if(pe.current=n,!se||P){F(!1);return}ge.current=performance.now(),F(!0)},[n,xe,q]),r.useEffect(()=>{if(!z||!n)return;const P=S.current;if(!P)return;const se=window.requestAnimationFrame(()=>{const fe=typeof window.CSS?.escape=="function"?window.CSS.escape(n):n.replace(/"/g,'\\"'),R=P.querySelector(`[data-sortable-tab-id="${fe}"]`);R&&(R.scrollIntoView({block:"nearest",inline:"nearest"}),ae())});return()=>{window.cancelAnimationFrame(se)}},[n,z,t.length,ae]);const ve=r.useCallback(P=>{if(!a)return;const{active:se,over:fe}=P;!fe||se.id===fe.id||a(String(se.id),String(fe.id))},[a]),ye=e.jsxs("div",{className:le("relative flex h-full min-w-0 flex-1",N),children:[z&&k.left?e.jsx("div",{className:le("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",b?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,z&&k.right?e.jsx("div",{className:le("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",b?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e.jsxs("div",{ref:S,className:le("relative flex h-full min-w-0 flex-1",b?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",b&&"@container/pill-tabs",b&&"pill-tabs__track",b&&(c??"gap-0.5 py-0.5"),X&&"items-center overflow-y-hidden",Y&&"rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_4%,transparent)] p-0.5 gap-0.5",z?"overflow-x-auto scrollbar-none":"overflow-x-hidden"),style:z?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,role:"tablist","aria-label":"Tabs",children:[b&&W?e.jsx("div",{className:le("pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[var(--surface-elevated)]","border border-[color-mix(in_srgb,var(--foreground)_7%,transparent)]","shadow-[0_1px_2px_color-mix(in_srgb,var(--foreground)_10%,transparent),0_2px_6px_color-mix(in_srgb,var(--foreground)_6%,transparent)]",ee&&$&&(l?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:l?{left:`${W.left+ue}px`,top:`${W.top}px`,width:`${W.width}px`,height:`${W.height}px`}:{transform:`translate3d(${W.left+ue}px, ${W.top}px, 0)`,width:`${W.width}px`,height:`${W.height}px`}}):null,X&&W?e.jsx("div",{className:le("pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",$&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${W.left+ue}px, 0, 0)`,width:`${W.width}px`},"aria-hidden":!0}):null,t.map(P=>{const se=P.id===n,fe=g&&b&&!se&&!!P.icon,R=!fe,w=!!P.icon,_=g&&b&&se&&!z&&!K,L=P.closable!==!1&&!!i,A=L&&!!P.icon,s=z||K?void 0:b?_?"flex-none basis-auto":f?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",d=L?H=>{H.button===1&&(H.preventDefault(),H.stopPropagation(),i?.(P.id))}:void 0,D=L?H=>{H.button===1&&H.preventDefault()}:void 0,I=H=>w?e.jsxs("span",{className:H,children:[e.jsx("span",{className:le("flex items-center justify-center transition-opacity",A&&(p?"opacity-0":"group-hover:opacity-0")),children:P.icon}),A?e.jsx("span",{role:"button",tabIndex:-1,className:le("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",p?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:te=>te.stopPropagation(),onClick:te=>{te.stopPropagation(),i?.(P.id)},"aria-label":P.closeLabel??`Close ${P.label} tab`,title:P.closeLabel??`Close ${P.label} tab`,children:e.jsx(V,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null;return e.jsx(Z,{id:P.id,className:s,children:e.jsxs("div",{ref:H=>U(P.id,H),onAuxClick:d,onMouseDown:D,className:le("group flex h-full min-w-0 flex-nowrap items-center",z||K?"shrink-0":b?"w-full":"w-full min-w-0",b?"relative z-10 bg-transparent":se?"relative z-10 bg-transparent text-foreground":"relative z-10 bg-transparent text-muted-foreground hover:text-foreground"),children:[e.jsx("button",{type:"button",role:"tab","aria-selected":se,"aria-label":fe?P.title??P.label:void 0,onClick:()=>o(P.id),onPointerDown:q?()=>{F(!0),ce(P.id)}:void 0,onPointerUp:q?()=>ce(null):void 0,onPointerLeave:q?()=>ce(null):void 0,onPointerCancel:q?()=>ce(null):void 0,className:le(b?"animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0":"flex h-full min-w-0 flex-nowrap items-center typography-micro",b&&u?"lowercase":null,b&&(fe?"gap-0":"gap-1.5"),b?K?"shrink-0 whitespace-nowrap px-3 text-center":z?"max-w-56 shrink-0 px-3 text-center":fe?"px-2 !min-w-0 text-center":_?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":z?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",b?h??(Q?f?"h-[38px]":"h-[31px]":"h-7"):null,b?se?"text-foreground":"text-muted-foreground hover:text-foreground":null,b?"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background":null),title:P.title??P.label,children:b?e.jsxs(e.Fragment,{children:[I("relative flex h-4 w-4 shrink-0 items-center justify-center"),R?e.jsx("span",{className:"animated-tabs__label truncate",children:P.label}):null]}):e.jsxs("span",{className:le("flex min-w-0 flex-nowrap items-center gap-1.5",!z&&"justify-center"),children:[I(le("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",se?"text-[var(--primary-base)]":"text-muted-foreground")),e.jsx("span",{className:"truncate leading-[1.2]",children:P.label})]})}),L&&!A?e.jsx("button",{type:"button",onPointerDown:H=>{H.stopPropagation()},onClick:H=>{H.stopPropagation(),i?.(P.id)},className:le("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",b?"-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md":"aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1",b?se?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":se?"text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100"),"aria-label":P.closeLabel??`Close ${P.label} tab`,title:P.closeLabel??`Close ${P.label} tab`,children:e.jsx(V,{name:"close",className:"h-3 w-3"})}):null]})},P.id)})]})]});return E?e.jsxs(an,{sensors:M,collisionDetection:ln,onDragEnd:ve,modifiers:[Is],children:[e.jsx(cn,{items:oe,strategy:Kn,children:ye}),e.jsx(Xn,{dropAnimation:null})]}):ye},Kt=280,Xt=280,qt=500,Ws=({isOpen:t,isMobile:n,children:o,className:i,topBar:a})=>{const m=ne(y=>y.sidebarWidth),x=ne(y=>y.setSidebarWidth),[c,h]=r.useState(!1),g=r.useRef(0),v=r.useRef(m||Kt),u=r.useRef(null),l=r.useRef(null),N=r.useRef(null),f=r.useCallback(y=>Math.min(qt,Math.max(Xt,y)),[]),T=r.useCallback(y=>{const b=N.current;b&&(b.style.width=`${y}px`,b.style.minWidth=`${y}px`,b.style.maxWidth=`${y}px`,b.style.setProperty("--oc-left-sidebar-width",`${y}px`))},[]);r.useEffect(()=>{n&&c&&h(!1)},[n,c]),r.useEffect(()=>{c||(u.current=null,l.current=null)},[c]);const p=yr(t);if(n)return null;const S=Math.min(qt,Math.max(Xt,m||Kt)),k=p.layoutVisible?S:0,O=y=>{if(t){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}l.current=y.pointerId,h(!0),g.current=y.clientX,v.current=k,u.current=k,T(k),y.preventDefault()}},oe=y=>{if(n||!c||l.current!==y.pointerId)return;const b=y.clientX-g.current,X=f(v.current+b);u.current!==X&&(u.current=X,T(X))},z=y=>{if(l.current!==y.pointerId||n)return;try{y.currentTarget.releasePointerCapture(y.pointerId)}catch{}const b=f(u.current??k);l.current=null,u.current=null,h(!1),x(b)},G=c?u.current??k:k,Q=c?G:k;return e.jsxs("aside",{ref:N,className:le("relative flex h-full overflow-hidden motion-reduce:transition-none","bg-sidebar",i),style:{width:`${Q}px`,minWidth:`${Q}px`,maxWidth:`${Q}px`,"--oc-left-sidebar-width":`${c?G:S}px`,overflowX:"clip",transform:c||p.slidIn?"translateX(0)":"translateX(-100%)",transition:c?"none":p.transition},"aria-hidden":!t||Q===0,children:[t&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&e.jsx("div",{className:le("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",c&&"bg-[var(--interactive-border)]"),onPointerDown:O,onPointerMove:oe,onPointerUp:z,onPointerCancel:z,role:"separator","aria-orientation":"vertical","aria-label":"Resize left panel"}),e.jsxs("div",{className:le("relative z-10 flex h-full shrink-0 flex-col",c&&"pointer-events-none",!t&&"pointer-events-none select-none"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[a,e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(Pe,{children:o})})]})]})},Fs=t=>{if(!t||typeof t!="object")return!1;const n=t;return typeof n.x=="number"&&typeof n.y=="number"},Gt=t=>!t||typeof t!="object"?!1:Object.values(t).every(n=>typeof n=="string"),Ue=t=>{if(!t||typeof t!="object")return!1;const n=t,o=n.bounds;return typeof n.tag=="string"&&typeof n.text=="string"&&typeof n.selector=="string"&&typeof n.path=="string"&&!!o&&typeof o?.x=="number"&&typeof o?.y=="number"&&typeof o?.width=="number"&&typeof o?.height=="number"&&Fs(n.center)&&Gt(n.attributes)&&Gt(n.computedStyle)&&Array.isArray(n.ancestry)},Rt=({pageUrl:t,viewport:n,devicePixelRatio:o,target:i,screenshotAttached:a,intro:m})=>{const x=i.text.trim(),c=Object.entries(i.attributes).map(([N,f])=>`${N}="${f}"`).join(" "),h=i.computedStyle,g=i.bounds,v=i.center,u=m.replace(/[.:]+$/g,""),l=i.ancestry.map(N=>N.selectorPart).join(" > ");return[`${u}:`,`Page: ${t||"preview"}`,`Viewport: ${n.width}x${n.height}, DPR ${o}`,`Screenshot: ${a?"attached":"not attached"}`,`Element: ${i.tag}`,x?`Text: ${x}`:null,`- Selector: ${i.selector}`,`- Path: ${i.path}`,l?`- Ancestry: ${l}`:null,c?`- Attributes: ${c}`:null,`- Bounds: x=${Math.round(g.x)}, y=${Math.round(g.y)}, width=${Math.round(g.width)}, height=${Math.round(g.height)}`,`- Center: x=${Math.round(v.x)}, y=${Math.round(v.y)}`,`Styles: display=${h.display}; position=${h.position}; font=${h.fontWeight} ${h.fontSize} / ${h.lineHeight} ${h.fontFamily}; color=${h.color}; background=${h.backgroundColor}; z-index=${h.zIndex}`].filter(N=>typeof N=="string").join(`
|
|
3
|
-
`)},Re=new Map,Bs=3e4,Et=t=>{const n=Re.get(t);return n?n.expiresAt-Date.now()<=Bs?(Re.delete(t),null):n:null},zs=t=>{try{return new URL(t).origin}catch{return t}},He="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=",ct=new Map;function Tn(t){const n="#ffffff",o=t.defaultView??window;try{const i=t.body?o.getComputedStyle(t.body).backgroundColor:"";if(i&&i!=="rgba(0, 0, 0, 0)"&&i!=="transparent")return i;const a=o.getComputedStyle(t.documentElement).backgroundColor;if(a&&a!=="rgba(0, 0, 0, 0)"&&a!=="transparent")return a}catch{}return n}const _n=t=>new Promise((n,o)=>{const i=new FileReader;i.onloadend=()=>n(typeof i.result=="string"?i.result:He),i.onerror=()=>o(i.error??new Error("Failed to read image blob")),i.readAsDataURL(t)}),Us=async(t,n=.82)=>{const o=await new Promise(i=>t.toBlob(i,"image/jpeg",n));return o&&(await _n(o)).split(",",2)[1]||""},dt=async(t,n)=>{try{const o=await fetch(t,{credentials:n});return o.ok?await _n(await o.blob()):null}catch{return null}},Hs=async t=>{if(t.protocol!=="http:"&&t.protocol!=="https:")return"";const n=t.origin,o=Et(n);if(o)return`${o.proxyBasePath}${t.pathname}${t.search}${t.hash}`;const i=ct.get(n),a=i??(async()=>{try{const x=await rt("/api/preview/targets",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:t.toString(),allowExternal:!0})});if(!x.ok)return Re.delete(n),null;const c=await x.json(),h=typeof c.proxyBasePath=="string"?c.proxyBasePath:"",g=typeof c.expiresAt=="number"?c.expiresAt:0;if(!h)return Re.delete(n),null;const v={proxyBasePath:h,expiresAt:g};return Re.set(n,v),v}catch{return Re.delete(n),null}finally{ct.delete(n)}})();i||ct.set(n,a);const m=await a;return m?`${m.proxyBasePath}${t.pathname}${t.search}${t.hash}`:""},An=async(t,n)=>{if(!t||t.startsWith("data:"))return t;try{const o=new URL(t,n.baseURI);if(o.origin===window.location.origin||o.protocol!=="http:"&&o.protocol!=="https:")return await dt(o.toString(),"include")??He;const i=await Hs(o),a=i?await dt(i,"include"):null;return a||(await dt(o.toString(),"omit")??He)}catch{return He}},Vs=async(t,n)=>{if(!t||t==="none"||!t.includes("url("))return t;const o=Array.from(t.matchAll(/url\((['"]?)(.*?)\1\)/g));let i=t;for(const a of o){const m=a[2]||"";if(!m||m.startsWith("data:"))continue;const x=await An(m,n);i=i.replace(a[0],`url("${x}")`)}return i},Yt=t=>t.complete?Promise.resolve():new Promise(n=>{t.addEventListener("load",()=>n(),{once:!0}),t.addEventListener("error",()=>n(),{once:!0})}),Dn=t=>{const n=t.style.cssText;return()=>{t.style.cssText=n}},Ks=t=>{const n=Number.parseFloat(t.lineHeight);if(Number.isFinite(n)&&n>0)return n;const o=Number.parseFloat(t.fontSize);return Number.isFinite(o)&&o>0?o*1.2:16},Xs=(t,n,o)=>{const i=[],a=t.defaultView??window,x=Array.from(t.querySelectorAll('button, a, summary, label, [role="button"], [role="link"], [role="menuitem"], [role="tab"], nav *, header *'));for(const c of x){const h=c.textContent?.replace(/\s+/g," ").trim()??"";if(!h||!h.includes(" "))continue;const g=c.getBoundingClientRect();if(g.width<=0||g.height<=0||g.right<0||g.bottom<0||g.left>n||g.top>o)continue;const v=a.getComputedStyle(c);if(v.display==="none"||v.visibility==="hidden"||Number(v.opacity)===0)continue;const u=v.getPropertyValue("text-wrap"),l=v.getPropertyValue("text-wrap-mode"),N=v.whiteSpace.includes("nowrap")||u==="nowrap"||l==="nowrap",f=g.height<=Ks(v)*1.7;!N&&(!f||g.width>n*.72)||(i.push(Dn(c)),c.style.whiteSpace="nowrap",c.style.overflowWrap="normal",c.style.wordBreak="normal",c.style.setProperty("text-wrap","nowrap"),c.style.setProperty("text-wrap-mode","nowrap"))}return()=>{for(let c=i.length-1;c>=0;c-=1)i[c]?.()}},qs=(t,n,o,i)=>{const a=[],m=t.defaultView??window,x=m.scrollX||t.documentElement.scrollLeft||t.body?.scrollLeft||0,c=m.scrollY||t.documentElement.scrollTop||t.body?.scrollTop||0,h=Array.from(t.querySelectorAll("*")).filter(g=>{const v=m.getComputedStyle(g);if(v.position!=="fixed"||v.display==="none"||v.visibility==="hidden"||Number(v.opacity)===0)return!1;const u=g.getBoundingClientRect();return u.width>0&&u.height>0&&u.right>=0&&u.bottom>=0&&u.left<=n&&u.top<=o}).filter((g,v,u)=>!u.some((l,N)=>N<v&&l.contains(g)));for(const g of h){const v=g.getBoundingClientRect(),u=m.getComputedStyle(g),l=Math.ceil(v.width)+8,N=Math.ceil(v.height)+2;i?.add(g),a.push(Dn(g)),g.style.position="absolute",g.style.top=`${v.top+c}px`,g.style.left=`${v.left+x}px`,g.style.right="auto",g.style.bottom="auto",g.style.width=`${l}px`,g.style.minWidth=`${l}px`,g.style.height=`${N}px`,g.style.minHeight=`${N}px`,g.style.margin="0",g.style.boxSizing="border-box",g.style.transform="none",u.zIndex!=="auto"&&(g.style.zIndex=u.zIndex)}return()=>{for(let g=a.length-1;g>=0;g-=1)a[g]?.()}},Mn=async(t,n,o,i={})=>{const a=[],m=t.defaultView??window,x=u=>{if(u===t.documentElement||u===t.body)return!0;try{const l=u.getBoundingClientRect();return l.width>0&&l.height>0&&l.right>=0&&l.bottom>=0&&l.left<=n&&l.top<=o}catch{return!1}};if(i.applyLayoutWorkarounds){const u=new WeakSet;a.push(qs(t,n,o,u)),a.push(Xs(t,n,o))}const c=new Map;for(const u of Array.from(t.images))c.set(u,u.currentSrc||u.src||u.getAttribute("src")||"");const h=Array.from(t.querySelectorAll("picture"));for(const u of h){const l=Array.from(u.querySelectorAll("source"));if(l.length===0)continue;const N=l.map(f=>({source:f,srcset:f.getAttribute("srcset"),sizes:f.getAttribute("sizes")}));a.push(()=>{for(const f of N)f.srcset===null?f.source.removeAttribute("srcset"):f.source.setAttribute("srcset",f.srcset),f.sizes===null?f.source.removeAttribute("sizes"):f.source.setAttribute("sizes",f.sizes)});for(const f of l)f.removeAttribute("srcset"),f.removeAttribute("sizes")}const g=Array.from(t.images).filter(u=>x(u));await Promise.all(g.map(async u=>{const l=c.get(u)||u.currentSrc||u.src||u.getAttribute("src")||"";if(!l)return;await Yt(u);const N=await An(l,t),f={src:u.getAttribute("src"),srcset:u.getAttribute("srcset"),sizes:u.getAttribute("sizes")};a.push(()=>{f.src===null?u.removeAttribute("src"):u.setAttribute("src",f.src),f.srcset===null?u.removeAttribute("srcset"):u.setAttribute("srcset",f.srcset),f.sizes===null?u.removeAttribute("sizes"):u.setAttribute("sizes",f.sizes)}),u.removeAttribute("srcset"),u.removeAttribute("sizes"),u.setAttribute("src",N||He),await Yt(u)}));const v=Array.from(t.querySelectorAll("*")).filter(x);return await Promise.all(v.map(async u=>{const l=m.getComputedStyle(u).backgroundImage;if(!l||l==="none"||!l.includes("url("))return;const N=await Vs(l,t);if(N===l)return;const f=u.style.backgroundImage;a.push(()=>{u.style.backgroundImage=f}),u.style.backgroundImage=N})),()=>{for(let u=a.length-1;u>=0;u-=1)try{a[u]?.()}catch{}}},Gs=()=>{try{return!!window.__previewCaptureDebug}catch{return!1}},et=(...t)=>{Gs()&&console.info("[preview-capture]",...t)},In=(t,n=8)=>{const o=[];try{const i=t.querySelectorAll("*");for(const a of i){const m=a.scrollTop||0,x=a.scrollLeft||0;if(m<=0&&x<=0)continue;const c=a.tagName.toLowerCase(),h=a.id?`#${a.id}`:"",g=typeof a.className=="string"&&a.className?`.${a.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";if(o.push({selector:`${c}${h}${g}`,scrollTop:m,scrollLeft:x,clientWidth:a.clientWidth,clientHeight:a.clientHeight,scrollWidth:a.scrollWidth,scrollHeight:a.scrollHeight}),o.length>=n)break}}catch{}return o},Ge="data-oc-fixed-pin",Ys=(t,n,o)=>{if(n<=0&&o<=0)return()=>{};const i=t.defaultView;if(!i)return()=>{};const a=[],m=[];try{for(const x of t.querySelectorAll("*")){if(i.getComputedStyle(x).position!=="fixed")continue;const c=x.getBoundingClientRect();if(!(c.width>0&&c.height>0))continue;x.setAttribute(Ge,JSON.stringify({top:c.top+o,left:c.left+n,width:c.width,height:c.height})),a.push(x);const h=x.tagName.toLowerCase(),g=typeof x.className=="string"&&x.className?`.${x.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";m.push({selector:`${h}${g}`,top:Math.round(c.top),left:Math.round(c.left),width:Math.round(c.width),height:Math.round(c.height)})}}catch{}return et("tagged fixed elements",m),()=>{for(const x of a)try{x.removeAttribute(Ge)}catch{}}},Js={name:"oc-fixed-pin",afterClone(t){const n=t?.clone;if(!(!n||typeof n.querySelectorAll!="function"))for(const o of n.querySelectorAll(`[${Ge}]`)){let i;try{i=JSON.parse(o.getAttribute(Ge)||"")}catch{continue}o.style.setProperty("position","absolute","important"),o.style.setProperty("top",`${i.top}px`,"important"),o.style.setProperty("left",`${i.left}px`,"important"),o.style.setProperty("right","auto","important"),o.style.setProperty("bottom","auto","important"),o.style.setProperty("width",`${i.width}px`,"important"),o.style.setProperty("height",`${i.height}px`,"important"),o.removeAttribute(Ge)}}},ze="data-oc-scroll-pin",Qs=t=>{const n=[],o=In(t,64);try{const m=t.documentElement,x=t.body;for(const c of t.querySelectorAll("*")){const h=c.scrollTop||0,g=c.scrollLeft||0;if(h<=0&&g<=0)continue;const v=c!==m&&c!==x;v&&c.setAttribute(ze,JSON.stringify({top:h,left:g})),n.push({el:c,top:h,left:g,tagged:v})}}catch{}return{reapply:()=>{for(const m of n)try{m.el.scrollHeight,m.el.scrollTop!==m.top&&(m.el.scrollTop=m.top),m.el.scrollLeft!==m.left&&(m.el.scrollLeft=m.left)}catch{}},cleanup:()=>{for(const m of n)if(m.tagged)try{m.el.removeAttribute(ze)}catch{}},snapshot:o}},Zs={name:"oc-nested-scroll",afterClone(t){const n=t?.clone;if(!n||typeof n.querySelectorAll!="function")return;const o=n.ownerDocument;if(o)for(const i of n.querySelectorAll(`[${ze}]`)){let a;try{a=JSON.parse(i.getAttribute(ze)||"")}catch{i.removeAttribute(ze);continue}const m=`translate(${-a.left}px, ${-a.top}px)`,x=i.children.length===1&&i.firstElementChild instanceof HTMLElement&&i.firstElementChild.style.willChange==="transform"?i.firstElementChild:null;if(x)x.style.transform=m;else{i.style.overflow="hidden";const c=o.createElement("div");for(c.style.transform=m,c.style.willChange="transform",c.style.display="inline-block",c.style.width="100%";i.firstChild;)c.appendChild(i.firstChild);i.appendChild(c)}i.removeAttribute(ze)}}},Ln=async(t,n)=>{if(typeof window<"u")try{const o=t.getBoundingClientRect(),i=await hn("desktop_capture_page_rect",{x:o.left,y:o.top,width:o.width,height:o.height});if(!i)throw new Error("Desktop screenshot capture is not available");const a=new Image;await new Promise((f,T)=>{a.onload=()=>f(),a.onerror=()=>T(new Error("Failed to load desktop preview screenshot")),a.src=`data:${i.mime};base64,${i.base64}`});const m=Math.max(1,a.naturalWidth||i.width||Math.floor(o.width)),x=Math.max(1,a.naturalHeight||i.height||Math.floor(o.height)),h=Math.min(1,1200/m),g=document.createElement("canvas");g.width=Math.floor(m*h),g.height=Math.floor(x*h);const v=g.getContext("2d");if(!v)return null;v.scale(h,h),v.drawImage(a,0,0,m,x);const u=m/Math.max(1,o.width),l=x/Math.max(1,o.height);v.fillStyle="rgba(37, 99, 235, 0.28)",v.strokeStyle="rgb(37, 99, 235)",v.lineWidth=Math.max(2,2*u),v.fillRect(n.bounds.x*u,n.bounds.y*l,n.bounds.width*u,n.bounds.height*l),v.strokeRect(n.bounds.x*u,n.bounds.y*l,n.bounds.width*u,n.bounds.height*l);const N=await new Promise(f=>g.toBlob(f,"image/jpeg",.82));return N?new File([N],`preview-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch(o){return console.warn("[preview] failed to capture annotation screenshot:",o),null}return await to(t,n)},Tt=async(t,n,o,i,a,m)=>{if(!t)return null;try{const x=new Image;await new Promise((p,S)=>{x.onload=()=>p(),x.onerror=()=>S(new Error("Failed to load desktop browser screenshot")),x.src=`data:image/jpeg;base64,${t}`});const c=Math.max(1,x.naturalWidth||n),h=Math.max(1,x.naturalHeight||o),v=Math.min(1,1200/c),u=document.createElement("canvas");u.width=Math.floor(c*v),u.height=Math.floor(h*v);const l=u.getContext("2d");if(!l)return null;l.scale(v,v),l.drawImage(x,0,0,c,h);const N=c/Math.max(1,i||c),f=h/Math.max(1,a||h);l.fillStyle="rgba(37, 99, 235, 0.14)",l.strokeStyle="rgb(37, 99, 235)",l.lineWidth=Math.max(2,2*N),l.fillRect(m.bounds.x*N,m.bounds.y*f,m.bounds.width*N,m.bounds.height*f),l.strokeRect(m.bounds.x*N,m.bounds.y*f,m.bounds.width*N,m.bounds.height*f);const T=await new Promise(p=>u.toBlob(p,"image/jpeg",.82));return T?new File([T],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}};async function eo(t,n){try{const o=t.contentWindow,i=t.contentDocument??o?.document,a=i?.documentElement;if(!o||!i||!a)return null;const m=t.getBoundingClientRect(),x=Math.max(1,Math.ceil(o.innerWidth||t.clientWidth||m.width)),c=Math.max(1,Math.ceil(o.innerHeight||t.clientHeight||m.height)),h=i.body,g=i.scrollingElement instanceof HTMLElement?i.scrollingElement:null,v=o.scrollX||0,u=o.scrollY||0,l=o.pageXOffset||0,N=o.pageYOffset||0,f=o.visualViewport?.pageLeft||o.visualViewport?.offsetLeft||0,T=o.visualViewport?.pageTop||o.visualViewport?.offsetTop||0,p=a.scrollLeft||0,S=a.scrollTop||0,k=h?.scrollLeft||0,O=h?.scrollTop||0,oe=g?.scrollLeft||0,z=g?.scrollTop||0,G=Math.max(v,l,f,p,k,oe),Q=Math.max(u,N,T,S,O,z);et("scroll sources",{windowScrollX:v,windowScrollY:u,pageScrollX:l,pageScrollY:N,visualViewportScrollX:f,visualViewportScrollY:T,rootScrollX:p,rootScrollY:S,bodyScrollX:k,bodyScrollY:O,scrollingElementScrollX:oe,scrollingElementScrollY:z,scrollingElementTag:g?.tagName?.toLowerCase()??null,resolvedScrollX:G,resolvedScrollY:Q,nestedScrolledElements:In(i)});const y=Math.max(x,a.scrollWidth||0,h?.scrollWidth||0,Math.ceil(a.getBoundingClientRect().width||0)),b=Math.max(c,a.scrollHeight||0,h?.scrollHeight||0,Math.ceil(a.getBoundingClientRect().height||0)),X=Math.min(2,Math.max(1,window.devicePixelRatio||1)),q=a.style.scrollBehavior,K=h?.style.scrollBehavior??"";a.style.scrollBehavior="auto",h&&(h.style.scrollBehavior="auto");const Y=Qs(i);et("nested scroll snapshot",Y.snapshot);let ee=()=>{},E=()=>{};try{await i.fonts?.ready.catch(()=>{}),ee=await Mn(i,x,c,{applyLayoutWorkarounds:!1}),o.scrollTo(G,Q),E=Ys(i,G,Q),Y.reapply();const{snapdom:Z}=await Ee(async()=>{const{snapdom:U}=await import("./vendor-zumer-snapdom-Btyu_Xi2.js");return{snapdom:U}},[]),j={backgroundColor:Tn(i),cache:"disabled",dpr:X,embedFonts:!0,fast:!1,height:b,outerShadows:!0,outerTransforms:!0,placeholders:!0,plugins:[Js,Zs],quality:.82,width:y},re=await(await Z(a,j)).toCanvas();if(!re.width||!re.height)return null;const $=re.width/Math.max(1,y),F=re.height/Math.max(1,b),ie=Math.min(re.width,Math.max(1,Math.round(x*$))),ce=Math.min(re.height,Math.max(1,Math.round(c*F))),he=Math.max(0,re.width-ie),ge=Math.max(0,re.height-ce),pe=Math.min(he,Math.max(0,Math.round(G*$))),de=Math.min(ge,Math.max(0,Math.round(Q*F)));et("capture geometry",{viewportWidth:x,viewportHeight:c,captureWidth:y,captureHeight:b,canvasWidth:re.width,canvasHeight:re.height,xScale:$,yScale:F,sourceX:pe,sourceY:de,sourceWidth:ie,sourceHeight:ce});const ue=i.createElement("canvas");ue.width=ie,ue.height=ce;const M=ue.getContext("2d");if(!M)return null;M.drawImage(re,pe,de,ie,ce,0,0,ie,ce);const B=await Us(ue,.82);return B?await Tt(B,x,c,x,c,n):null}finally{E(),Y.cleanup(),ee(),o.scrollTo(G,Q),Y.reapply(),a.style.scrollBehavior=q,h&&(h.style.scrollBehavior=K)}}catch(o){return console.warn("[preview] failed to capture iframe DOM screenshot with snapDOM:",o),null}}async function to(t,n){const o=await eo(t,n);if(o)return o;try{const i=t.contentWindow,a=t.contentDocument??i?.document,m=a?.documentElement;if(!i||!a||!m)return null;const x=t.getBoundingClientRect(),c=Math.max(1,Math.ceil(i.innerWidth||t.clientWidth||x.width)),h=Math.max(1,Math.ceil(i.innerHeight||t.clientHeight||x.height)),g=i.scrollX||a.documentElement.scrollLeft||a.body?.scrollLeft||0,v=i.scrollY||a.documentElement.scrollTop||a.body?.scrollTop||0,u=a.body,l=Math.max(h,m.scrollHeight||0,u?.scrollHeight||0),N=Math.min(2,Math.max(1,window.devicePixelRatio||1)),f=m.style.scrollBehavior,T=u?.style.scrollBehavior??"";m.style.scrollBehavior="auto",u&&(u.style.scrollBehavior="auto");let p="",S=()=>{};try{await a.fonts?.ready.catch(()=>{}),S=await Mn(a,c,h,{applyLayoutWorkarounds:!0}),i.scrollTo(g,v);const{getFontEmbedCSS:O,toJpeg:oe}=await Ee(async()=>{const{getFontEmbedCSS:G,toJpeg:Q}=await import("./vendor-html-to-image-BeoRn2gJ.js");return{getFontEmbedCSS:G,toJpeg:Q}},[]),z=await O(m).catch(()=>"");p=await oe(m,{quality:.82,pixelRatio:N,width:c,height:h,backgroundColor:Tn(a),imagePlaceholder:He,fontEmbedCSS:z||void 0,style:{transform:`translate(${-g}px, ${-v}px)`,transformOrigin:"top left",minWidth:`${c}px`,minHeight:`${l}px`},cacheBust:!0})}finally{S(),i.scrollTo(g,v),m.style.scrollBehavior=f,u&&(u.style.scrollBehavior=T)}const k=p.split(",",2)[1]||"";return k?await Tt(k,c,h,c,h,n):null}catch(i){return console.warn("[preview] failed to capture iframe DOM screenshot:",i),null}}const Jt=200,no=(t,n)=>n==="all"?!0:n==="errors"?t.level==="error"||t.level==="runtime"||t.level==="resource":n==="warnings"?t.level==="warn":t.level==="log"||t.level==="info"||t.level==="debug",ot=t=>{const n=it.getState();n.setPendingSyntheticParts([...n.pendingSyntheticParts??[],{text:t,synthetic:!0}])},On=async t=>{const n=await t.json().catch(()=>({}));if(!t.ok)return{ok:!1,message:typeof n.error=="string"?n.error:`HTTP ${t.status}`};const o=typeof n.proxyBasePath=="string"?n.proxyBasePath:"",i=typeof n.previewToken=="string"?n.previewToken:"";return!o||!i?{ok:!1,message:"Could not start preview proxy."}:{ok:!0,target:{proxyBasePath:o,previewToken:i,expiresAt:typeof n.expiresAt=="number"?n.expiresAt:0}}},$n=t=>{if(typeof window>"u")return"";try{return new URL(t||window.location.href,window.location.href).origin}catch{return window.location.origin}},Qt=(t,n,o)=>{t.postMessage(o,$n(n))},ro=t=>{if(!t)return t;try{const n=new URL(t);return n.searchParams.delete("oc_preview_token"),n.searchParams.delete("oc_client_token"),n.searchParams.delete("oc_url_token"),n.toString()}catch{return t}},Zt=t=>{if(!t)return t;try{const n=new URL(t);return n.searchParams.delete("ocPreview"),n.searchParams.delete("oc_preview_token"),n.searchParams.delete("oc_client_token"),n.searchParams.delete("oc_url_token"),n.toString()}catch{return t}};function Wn(t){const[n,o]=r.useState("");return r.useEffect(()=>{if(!t){o("");return}let i=!1;return o(""),Zn(fn()).then(a=>{!i&&a&&o(t)}).catch(()=>{}),()=>{i=!0}},[t]),n}const Fn=`new Promise((resolve) => {
|
|
4
|
-
const existing = document.getElementById('__pichamber_desktop_browser_overlay');
|
|
5
|
-
if (existing) existing.remove();
|
|
6
|
-
if (typeof window.__pichamberDesktopBrowserCancelInspect === 'function') {
|
|
7
|
-
try { window.__pichamberDesktopBrowserCancelInspect(); } catch { /* webview not ready */ }
|
|
8
|
-
}
|
|
9
|
-
const overlay = document.createElement('div');
|
|
10
|
-
overlay.id = '__pichamber_desktop_browser_overlay';
|
|
11
|
-
overlay.style.cssText = 'position:fixed;z-index:2147483647;pointer-events:none;border:2px solid #60a5fa;background:rgba(96,165,250,.24);border-radius:3px;display:none;box-sizing:border-box;';
|
|
12
|
-
document.documentElement.appendChild(overlay);
|
|
13
|
-
const cssEscape = (value) => {
|
|
14
|
-
try { return CSS.escape(value); } catch { return String(value).replace(/[^a-zA-Z0-9_-]/g, '\\\\$&'); }
|
|
15
|
-
};
|
|
16
|
-
const selectorPart = (element) => {
|
|
17
|
-
const tag = element.tagName.toLowerCase();
|
|
18
|
-
if (element.id) return tag + '#' + cssEscape(element.id);
|
|
19
|
-
const className = String(element.className || '').trim().split(/\\s+/).filter(Boolean).slice(0, 3).map((part) => '.' + cssEscape(part)).join('');
|
|
20
|
-
return tag + className;
|
|
21
|
-
};
|
|
22
|
-
const metadata = (element) => {
|
|
23
|
-
const rect = element.getBoundingClientRect();
|
|
24
|
-
const style = getComputedStyle(element);
|
|
25
|
-
const ancestry = [];
|
|
26
|
-
let current = element;
|
|
27
|
-
while (current && current.nodeType === Node.ELEMENT_NODE && ancestry.length < 8) {
|
|
28
|
-
ancestry.unshift({ tag: current.tagName.toLowerCase(), id: current.id || undefined, className: typeof current.className === 'string' ? current.className : undefined, selectorPart: selectorPart(current) });
|
|
29
|
-
current = current.parentElement;
|
|
30
|
-
}
|
|
31
|
-
const attrs = {};
|
|
32
|
-
for (const attr of Array.from(element.attributes || []).slice(0, 16)) attrs[attr.name] = attr.value.slice(0, 300);
|
|
33
|
-
const path = ancestry.map((entry) => entry.selectorPart).join(' > ');
|
|
34
|
-
return {
|
|
35
|
-
frame: 'top',
|
|
36
|
-
tag: element.tagName.toLowerCase(),
|
|
37
|
-
text: String(element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim().slice(0, 500),
|
|
38
|
-
selector: element.id ? '#' + cssEscape(element.id) : path,
|
|
39
|
-
path,
|
|
40
|
-
bounds: { x: rect.x, y: rect.y, width: rect.width, height: rect.height },
|
|
41
|
-
center: { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 },
|
|
42
|
-
attributes: attrs,
|
|
43
|
-
computedStyle: { display: style.display, position: style.position, fontWeight: style.fontWeight, fontSize: style.fontSize, lineHeight: style.lineHeight, fontFamily: style.fontFamily, color: style.color, backgroundColor: style.backgroundColor, zIndex: style.zIndex },
|
|
44
|
-
ancestry,
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
const move = (event) => {
|
|
48
|
-
const element = document.elementFromPoint(event.clientX, event.clientY);
|
|
49
|
-
if (!element || element === overlay || element === document.documentElement || element === document.body) return;
|
|
50
|
-
const rect = element.getBoundingClientRect();
|
|
51
|
-
overlay.style.display = 'block';
|
|
52
|
-
overlay.style.left = rect.left + 'px';
|
|
53
|
-
overlay.style.top = rect.top + 'px';
|
|
54
|
-
overlay.style.width = rect.width + 'px';
|
|
55
|
-
overlay.style.height = rect.height + 'px';
|
|
56
|
-
};
|
|
57
|
-
const cleanup = () => {
|
|
58
|
-
window.removeEventListener('mousemove', move, true);
|
|
59
|
-
window.removeEventListener('click', click, true);
|
|
60
|
-
window.removeEventListener('keydown', keydown, true);
|
|
61
|
-
if (window.__pichamberDesktopBrowserCancelInspect === cancel) {
|
|
62
|
-
delete window.__pichamberDesktopBrowserCancelInspect;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const cancel = () => {
|
|
66
|
-
cleanup();
|
|
67
|
-
overlay.remove();
|
|
68
|
-
resolve(null);
|
|
69
|
-
};
|
|
70
|
-
const click = (event) => {
|
|
71
|
-
event.preventDefault();
|
|
72
|
-
event.stopPropagation();
|
|
73
|
-
const element = document.elementFromPoint(event.clientX, event.clientY);
|
|
74
|
-
const result = element ? metadata(element) : null;
|
|
75
|
-
cleanup();
|
|
76
|
-
overlay.remove();
|
|
77
|
-
resolve(result);
|
|
78
|
-
};
|
|
79
|
-
const keydown = (event) => {
|
|
80
|
-
if (event.key !== 'Escape') return;
|
|
81
|
-
cancel();
|
|
82
|
-
};
|
|
83
|
-
window.__pichamberDesktopBrowserCancelInspect = cancel;
|
|
84
|
-
window.addEventListener('mousemove', move, true);
|
|
85
|
-
window.addEventListener('click', click, true);
|
|
86
|
-
window.addEventListener('keydown', keydown, true);
|
|
87
|
-
});`,tt=`(() => {
|
|
88
|
-
if (typeof window.__pichamberDesktopBrowserCancelInspect === 'function') {
|
|
89
|
-
window.__pichamberDesktopBrowserCancelInspect();
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const overlay = document.getElementById('__pichamber_desktop_browser_overlay');
|
|
93
|
-
if (overlay) overlay.remove();
|
|
94
|
-
})()`,so=`(() => {
|
|
95
|
-
if (window.__pichamberSameWebviewNavigationInstalled) return;
|
|
96
|
-
window.__pichamberSameWebviewNavigationInstalled = true;
|
|
97
|
-
|
|
98
|
-
const navigate = (rawUrl) => {
|
|
99
|
-
if (typeof rawUrl !== 'string' || rawUrl.length === 0) return false;
|
|
100
|
-
try {
|
|
101
|
-
const url = new URL(rawUrl, window.location.href);
|
|
102
|
-
if (url.protocol !== 'http:' && url.protocol !== 'https:') return false;
|
|
103
|
-
window.location.assign(url.href);
|
|
104
|
-
return true;
|
|
105
|
-
} catch (_error) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const originalOpen = window.open.bind(window);
|
|
111
|
-
window.open = (url, target, features) => {
|
|
112
|
-
if (navigate(url)) return null;
|
|
113
|
-
return originalOpen(url, target, features);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
document.addEventListener('click', (event) => {
|
|
117
|
-
if (event.defaultPrevented) return;
|
|
118
|
-
const target = event.target;
|
|
119
|
-
if (!(target instanceof Element)) return;
|
|
120
|
-
const anchor = target.closest('a[target="_blank"][href]');
|
|
121
|
-
if (!(anchor instanceof HTMLAnchorElement)) return;
|
|
122
|
-
if (!navigate(anchor.href)) return;
|
|
123
|
-
event.preventDefault();
|
|
124
|
-
event.stopPropagation();
|
|
125
|
-
}, true);
|
|
126
|
-
})()`,Ye=t=>{const n=t.trim();if(!n)return"about:blank";try{const o=new URL(n.includes("://")?n:`https://${n}`);return o.protocol!=="http:"&&o.protocol!=="https:"?"about:blank":o.toString()}catch{return"about:blank"}},en=async(t,n)=>{const o=t.contentWindow;if(!o)throw new Error("Iframe window is not available");const a=o.eval.call(o,n);return await Promise.resolve(a)},oo=()=>typeof window<"u"&&!!window.__PICHAMBER_ELECTRON__,ao=({initialUrl:t,directory:n,tabID:o})=>{const i=r.useRef(null),a=ne(M=>M.setContextPanelTabTargetPath),m=Ye(t),x=m!=="about:blank"?m:"",[c,h]=r.useState(x),[g,v]=r.useState(x),[u,l]=r.useState(x),[N,f]=r.useState(()=>x?[x]:[]),[T,p]=r.useState(()=>x?0:-1),[S,k]=r.useReducer(M=>M+1,0),[O,oe]=r.useState(!!x),[z,G]=r.useState(!1),[Q,y]=r.useState(null),[b,X]=r.useState({status:"idle"}),q=Ce(M=>M.currentSessionId),K=Ce(M=>M.newSessionDraft?.open),Y=it(M=>M.addAttachedFile),ee=r.useCallback(M=>{!M||M==="about:blank"||!n||!o||a(n,o,M)},[n,o,a]),E=r.useCallback((M,B)=>{const U=Ye(M),J=U!=="about:blank"?U:"";v(J),h(J),B?.inFrame?oe(!1):(l(J),oe(!!J)),ee(J),f(ae=>{if(!J)return p(-1),[];if(B?.replaceHistory)return ae;const xe=T>=0?ae.slice(0,T+1):[];if(xe[xe.length-1]===J)return p(xe.length-1),xe;const ye=[...xe,J];return p(ye.length-1),ye})},[T,ee]),Z=r.useCallback(M=>{const B=N[M];B&&(p(M),v(B),l(B),h(B),oe(!0),ee(B))},[N,ee]),j=r.useCallback(()=>{if(g){oe(!0);try{i.current?.contentWindow?.location.reload()}catch{k()}}},[g]);r.useEffect(()=>{if(!u){X({status:"idle"});return}const M=zs(u),B=Et(M);if(B?.previewToken){X({status:"ready",proxyBasePath:B.proxyBasePath,previewToken:B.previewToken,expiresAt:B.expiresAt});return}B&&Re.delete(M);let U=!1;return X({status:"loading"}),oe(!0),(async()=>{try{const J=await rt("/api/preview/targets",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:u,allowExternal:!0})}),ae=await On(J);if(!ae.ok){U||X({status:"error",message:ae.message});return}Re.set(M,ae.target),U||X({status:"ready",...ae.target})}catch(J){if(!U){const ae=J instanceof Error?J.message:String(J);X({status:"error",message:ae})}}})(),()=>{U=!0}},[u]);const W=u&&b.status==="ready"?`${b.proxyBasePath}|${b.previewToken||""}|${S}`:"",re=Wn(W),$=r.useMemo(()=>{if(re!==W||!u||b.status!=="ready")return"";try{const M=new URL(u),B=M.pathname||"/",U=new URLSearchParams(M.search);U.delete("oc_url_token"),U.delete("oc_client_token"),U.set("ocPreview",String(S)),U.set("oc_preview_token",b.previewToken||"");const J=U.toString();return pn().authenticatedAsset(`${b.proxyBasePath}${B}${J?`?${J}`:""}${M.hash}`)}catch{return""}},[u,b,W,S,re]),F=$||(b.status==="error"?u:""),ie=r.useCallback(M=>{if(!M||!u||b.status!=="ready")return"";try{const B=new URL(M,window.location.origin),U=b.proxyBasePath.endsWith("/")?b.proxyBasePath.slice(0,-1):b.proxyBasePath;if(B.origin!==window.location.origin||!B.pathname.startsWith(U))return"";const J=B.pathname.slice(U.length)||"/",ae=new URL(u).origin;return Zt(new URL(`${J}${B.search}${B.hash}`,ae).toString())}catch{return""}},[u,b]),ce=r.useCallback(M=>{if(!M||!u||b.status!=="ready")return"";try{const B=new URL(M,window.location.origin),U=new URL(u).origin;if(B.origin!==window.location.origin||U===window.location.origin)return"";const J=b.proxyBasePath.endsWith("/")?b.proxyBasePath.slice(0,-1):b.proxyBasePath;return B.pathname.startsWith(J)?"":Zt(new URL(`${B.pathname}${B.search}${B.hash}`,U).toString())}catch{return""}},[u,b]),he=r.useCallback(M=>{const B=i.current?.contentWindow;B&&B.postMessage({source:"pichamber-preview-parent",version:1,type:"set-inspect-mode",enabled:M},window.location.origin)},[]),ge=r.useCallback(async M=>{if(!(q??(K?"draft":null))){je.error("Open a chat session before attaching preview annotations");return}const U=i.current,J=U?.contentWindow,ae=U?.getBoundingClientRect(),xe={width:Number.isFinite(J?.innerWidth)?J?.innerWidth??ae?.width??0:ae?.width??0,height:Number.isFinite(J?.innerHeight)?J?.innerHeight??ae?.height??0:ae?.height??0},ve=U?await Ln(U,M):null,ye=!!ve;ve&&await Y(ve),ot(Rt({pageUrl:g,viewport:xe,devicePixelRatio:window.devicePixelRatio||1,target:M,screenshotAttached:ye,intro:ye?"This is a selected DOM element from the in-app preview. A screenshot of the visible preview area with the selected element highlighted is attached.":"This is a selected DOM element from the in-app preview."})),je.success("Preview annotation attached to chat")},[Y,q,g,K]),pe=r.useCallback(()=>{const M=i.current;y(null),he(!1),M&&en(M,tt).catch(()=>{})},[he]);r.useEffect(()=>{if(!z)return;const M=B=>{B.key==="Escape"&&(B.preventDefault(),B.stopImmediatePropagation(),G(!1),pe())};return window.addEventListener("keydown",M,!0),()=>window.removeEventListener("keydown",M,!0)},[pe,z]),r.useEffect(()=>()=>pe(),[pe]),r.useEffect(()=>{const M=B=>{if(B.source!==i.current?.contentWindow)return;const U=B.data;if(!(!U||U.source!=="pichamber-preview-bridge"||U.version!==1)){if(U.type==="ready"){const J=typeof U.url=="string"?U.url:"",ae=ie(J);ae&&ae!==g&&E(ae,{inFrame:!0});return}if(U.type==="hover"){y(Ue(U.target)?U.target:null);return}if(U.type==="select"&&Ue(U.target)){y(null),G(!1),he(!1),ge(U.target);return}if(U.type==="navigate-preview"){const J=typeof U.url=="string"?U.url:"",ae=ce(J);if(ae){E(ae);return}J&&E(J)}}};return window.addEventListener("message",M),()=>window.removeEventListener("message",M)},[E,ge,g,ie,ce,he]);const de=r.useCallback(()=>{const M=i.current;if(!(!M||!g)){if(z){G(!1),pe();return}if($){y(null),G(!0),he(!0);return}G(!0),(async()=>{try{const B=await en(M,Fn);if(G(!1),!B||!Ue(B))return;await ge(B)}catch{G(!1),je.error("This page cannot be inspected from the browser panel.")}})()}},[ge,pe,g,z,he,$]),ue=r.useCallback(()=>{try{const M=i.current?.contentWindow?.location.href||"",B=ce(M);if(B){E(B,{inFrame:!0});return}}catch{}oe(!1),z&&$&&he(!0)},[E,ce,z,he,$]);return e.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[e.jsx(me,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:T<=0,onClick:()=>Z(T-1),children:e.jsx(V,{name:"arrow-left",className:"h-3.5 w-3.5"})}),e.jsx(me,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:T<0||T>=N.length-1,onClick:()=>Z(T+1),children:e.jsx(V,{name:"arrow-right",className:"h-3.5 w-3.5"})}),e.jsx(me,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:!g,onClick:j,children:e.jsx(V,{name:"refresh",className:"h-3.5 w-3.5"})}),e.jsx("form",{className:"min-w-0 flex-1",onSubmit:M=>{M.preventDefault(),E(c)},children:e.jsx("input",{value:c,onChange:M=>h(M.target.value),className:"h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]","aria-label":"Browser address"})}),e.jsx(me,{type:"button",variant:z?"secondary":"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:!g,onClick:de,title:"Inspect preview element","aria-label":"Inspect preview element",children:e.jsx(V,{name:"cursor",className:"h-3.5 w-3.5"})}),e.jsx(me,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:!g,onClick:()=>{st(g)},children:e.jsx(V,{name:"external-link",className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[F?e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("iframe",{ref:i,src:F,title:"Web browser",className:"absolute inset-0 h-full w-full border-0 bg-background",allow:"clipboard-read; clipboard-write; fullscreen",allowFullScreen:!0,onLoad:ue},`${o}:${S}`),z&&Q?e.jsx("div",{className:"pointer-events-none absolute rounded-sm border-2 border-[var(--interactive-focus-ring)] bg-[var(--interactive-focus-ring)]/35",style:{left:Q.bounds.x,top:Q.bounds.y,width:Q.bounds.width,height:Q.bounds.height},children:e.jsxs("div",{className:"absolute -top-6 left-0 max-w-64 truncate rounded bg-[var(--surface-elevated)] px-2 py-0.5 typography-micro text-foreground shadow",children:[Q.tag,Q.text?` · ${Q.text}`:""]})}):null]}):e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center",children:[e.jsx(vn,{width:140,height:140,className:"opacity-20"}),e.jsx("span",{className:"typography-ui-header text-muted-foreground",children:"Web browser"}),e.jsx("span",{className:"max-w-sm typography-micro text-muted-foreground",children:"Enter an address above to start browsing the web"}),e.jsx("span",{className:"max-w-md typography-micro leading-relaxed text-status-warning/70",children:"Pages opened here run with full access to PiChamber — needed for inspect and screenshots. Only open sites you trust: a malicious page could read your data or act on your behalf."})]}),O?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground",children:"Loading..."}):null]})]})},io=({initialUrl:t,directory:n,tabID:o})=>{const i=r.useRef(null),a=ne(y=>y.setContextPanelTabTargetPath),m=Ye(t),x=m!=="about:blank"?m:"",c=r.useRef(Ye(t)),[h,g]=r.useState(x),[v,u]=r.useState(x),[l,N]=r.useState(!1),[f,T]=r.useState(!0),p=r.useRef(null),S=f,k=r.useCallback(y=>{!y||y==="about:blank"||!n||!o||a(n,o,y)},[n,o,a]),O=Ce(y=>y.currentSessionId),oe=Ce(y=>y.newSessionDraft?.open),z=it(y=>y.addAttachedFile);r.useEffect(()=>{const y=i.current;if(!y)return;const b=()=>{try{const E=y.getURL();E&&E!=="about:blank"&&(u(E),g(E),k(E))}catch{}},X=E=>{const Z=E.detail;typeof Z?.url=="string"&&Z.url&&(u(Z.url),g(Z.url),k(Z.url))},q=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>T(!0),200)},K=()=>{p.current&&clearTimeout(p.current),T(!1),b()},Y=E=>{const Z=E.detail;if(Z?.disposition==="new-window"||Z?.disposition==="foreground-tab"||Z?.disposition==="background-tab"){E.preventDefault();const j=i.current;typeof j?.loadURL=="function"&&Z.url&&j.loadURL(Z.url)}},ee=()=>{try{y.executeJavaScript?.(so,!0).catch(()=>{})}catch{}};y.addEventListener("did-navigate",X),y.addEventListener("did-navigate-in-page",X),y.addEventListener("did-start-loading",q),y.addEventListener("did-stop-loading",K),y.addEventListener("new-window",Y),y.addEventListener("dom-ready",ee);try{y.isLoading()||(T(!1),b())}catch{}return ee(),()=>{p.current&&clearTimeout(p.current),y.removeEventListener("did-navigate",X),y.removeEventListener("did-navigate-in-page",X),y.removeEventListener("did-start-loading",q),y.removeEventListener("did-stop-loading",K),y.removeEventListener("new-window",Y),y.removeEventListener("dom-ready",ee)}},[k]),r.useEffect(()=>{const y=setTimeout(()=>T(!1),3e4);return()=>clearTimeout(y)},[]),r.useEffect(()=>{if(!l)return;const y=b=>{if(b.key!=="Escape")return;b.preventDefault(),b.stopImmediatePropagation(),N(!1);const X=i.current;try{X?.executeJavaScript?.(tt).catch(()=>{})}catch{}};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[l]),r.useEffect(()=>{const y=i.current;return()=>{try{const b=y?.getURL?.();b&&b!=="about:blank"&&a(n,o,b)}catch{}try{y?.executeJavaScript?.(tt).catch(()=>{})}catch{}}},[n,o,a]);const G=r.useCallback(y=>{const b=i.current;if(typeof b?.loadURL!="function")return;const X=Ye(y);try{b.loadURL(X)}catch{}},[]),Q=r.useCallback(()=>{const y=i.current;if(y){if(l){N(!1);try{y.executeJavaScript?.(tt).catch(()=>{})}catch{}return}N(!0),y.executeJavaScript?.(Fn,!0).then(async b=>{if(N(!1),!b||!Ue(b))return;if(!(O??(oe?"draft":null))){je.error("Open a chat session before attaching preview annotations");return}const q=typeof y.getWebContentsId=="function"?y.getWebContentsId():null;if(q==null)return;const K=await $r("desktop_browser_capture_page",{webContentsId:q}),Y=await y.executeJavaScript?.("({ width: window.innerWidth, height: window.innerHeight })",!0).catch(()=>null),ee=Number.isFinite(Y?.width)?Y.width:K.width,E=Number.isFinite(Y?.height)?Y.height:K.height,Z=await Tt(K.base64,K.width,K.height,ee,E,b),j=!!Z;Z&&await z(Z),ot(Rt({pageUrl:v,viewport:{width:ee,height:E},devicePixelRatio:window.devicePixelRatio||1,target:b,screenshotAttached:j,intro:"This is a selected DOM element from the in-app preview. A screenshot of the visible preview area with the selected element highlighted is attached."})),je.success("Preview annotation attached to chat")}).catch(()=>N(!1))}},[z,O,v,l,oe]);return e.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[e.jsx(me,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{try{i.current?.goBack?.()}catch{}},children:e.jsx(V,{name:"arrow-left",className:"h-3.5 w-3.5"})}),e.jsx(me,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{try{i.current?.goForward?.()}catch{}},children:e.jsx(V,{name:"arrow-right",className:"h-3.5 w-3.5"})}),e.jsx(me,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{try{i.current?.reload?.()}catch{}},children:e.jsx(V,{name:"refresh",className:"h-3.5 w-3.5"})}),e.jsx("form",{className:"min-w-0 flex-1",onSubmit:y=>{y.preventDefault(),G(h)},children:e.jsx("input",{value:h,onChange:y=>g(y.target.value),className:"h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]","aria-label":"Browser address"})}),e.jsx(me,{type:"button",variant:l?"secondary":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:Q,title:"Inspect preview element","aria-label":"Inspect preview element",children:e.jsx(V,{name:"cursor",className:"h-3.5 w-3.5"})}),e.jsx(me,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{st(v)},children:e.jsx(V,{name:"external-link",className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[e.jsx("webview",{ref:i,src:c.current,partition:"persist:pichamber-browser",allowpopups:!0,style:{width:"100%",height:"100%",border:"none"}}),(!v||v==="about:blank")&&!f?e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center",children:[e.jsx(vn,{width:140,height:140,className:"opacity-20"}),e.jsx("span",{className:"typography-ui-header text-muted-foreground",children:"Web browser"})]}):null,S?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground",children:"Loading..."}):null]})]})},lo=t=>{const n=oo()?io:ao;return e.jsx(n,{...t})},co=8,De=new Map,_t=t=>JSON.stringify([er(),t]),tn=t=>{const n=_t(t),o=De.get(n);return o?(o.touchedAt=Date.now(),De.delete(n),De.set(n,o),o):null},ut=t=>{const n=_t(t),o=De.get(n);if(o)return o.touchedAt=Date.now(),o;if(De.size>=co){const a=De.keys().next().value;a!==void 0&&De.delete(a)}const i={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return De.set(n,i),i},uo=t=>{De.delete(_t(t))},Bn=(t,n)=>e.jsx(yt,{filePath:t,extension:n}),ho=({status:t})=>{const n={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"}[t];return e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:n}})},fo=({node:t,root:n,isExpanded:o,isActive:i,isBrowserClient:a,status:m,badge:x,permissions:c,downloadFile:h,onSelect:g,onToggle:v,onRevealPath:u,onOpenDialog:l})=>{const N=t.type==="directory",{canRename:f,canCreateFile:T,canCreateFolder:p,canDelete:S,canReveal:k}=c,O=!N&&!!h,oe=k&&!a,z=f||T||p||S||O||oe,[G,Q]=r.useState(!1),[y,b]=r.useState(!1),X=r.useCallback(E=>{z&&(E?.preventDefault(),b(!0))},[z]),q=r.useCallback(()=>{N?v(t.path):g(t)},[N,t,g,v]),K=r.useCallback(E=>{E.stopPropagation(),b(!1),Q(!0)},[]),Y=({Item:E,Separator:Z})=>e.jsxs(e.Fragment,{children:[f&&e.jsxs(E,{onClick:j=>{j.stopPropagation(),l("rename",t)},children:[e.jsx(V,{name:"edit",className:"mr-2 h-4 w-4"})," ","Rename"]}),e.jsxs(E,{onClick:j=>{j.stopPropagation(),bt(t.path).then(W=>{if(W.ok){je.success("Path copied");return}je.error("Copy failed")})},children:[e.jsx(V,{name:"file-copy",className:"mr-2 h-4 w-4"})," ","Copy Path"]}),!N&&h&&e.jsxs(E,{onClick:j=>{j.stopPropagation(),h(t.path).catch(W=>{console.error("Download failed:",W),je.error("Operation failed")})},children:[e.jsx(V,{name:"download",className:"mr-2 h-4 w-4"})," ",a?"Download":"Save"]}),oe&&e.jsxs(E,{onClick:j=>{j.stopPropagation(),u(t.path)},children:[e.jsx(V,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",tr()]}),N&&(T||p)&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{}),T&&e.jsxs(E,{onClick:j=>{j.stopPropagation(),l("createFile",t)},children:[e.jsx(V,{name:"file-add",className:"mr-2 h-4 w-4"})," ","New File"]}),p&&e.jsxs(E,{onClick:j=>{j.stopPropagation(),l("createFolder",t)},children:[e.jsx(V,{name:"folder-add",className:"mr-2 h-4 w-4"})," ","New Folder"]})]}),S&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{}),e.jsxs(E,{onClick:j=>{j.stopPropagation(),l("delete",t)},className:"text-destructive focus:text-destructive",children:[e.jsx(V,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ","Delete"]})]})]}),ee=r.useCallback(E=>{const Z=Rn(n,t.path);Z&&(E.dataTransfer.setData("application/x-pichamber-file-path",Z),E.dataTransfer.effectAllowed="copy")},[t.path,n]);return e.jsxs(br,{open:y,onOpenChange:b,children:[e.jsxs(vr,{render:e.jsx("div",{className:"group relative flex items-center",onContextMenu:X}),children:[e.jsxs("button",{type:"button",onClick:q,onContextMenu:X,draggable:!0,onDragStart:ee,className:le("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40","cursor-grab active:cursor-grabbing"),children:[N?o?e.jsx(V,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):e.jsx(V,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):Bn(t.path,t.extension),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:t.path,children:t.name}),!N&&m&&e.jsx(ho,{status:m}),N&&x&&e.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[x.modified>0&&e.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",x.modified]}),x.added>0&&e.jsxs("span",{className:"text-[var(--status-success)]",children:["+",x.added]})]})]}),z&&e.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:e.jsxs(Wr,{open:G,onOpenChange:Q,children:[e.jsxs(We,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:e.jsx(Fr,{asChild:!0,children:e.jsx(me,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:K,title:"File menu","aria-label":"File menu",children:e.jsx(V,{name:"more-2-fill",className:"h-4 w-4"})})})})}),e.jsx(Be,{side:"bottom",sideOffset:6,children:"File menu"})]}),e.jsx(Br,{align:"end",side:"bottom",onCloseAutoFocus:()=>Q(!1),children:Y({Item:zr,Separator:Ur})})]})})]}),e.jsx(Sr,{className:"min-w-[180px]",children:Y({Item:jr,Separator:Cr})})]})},po=(t,n)=>t.node===n.node&&t.root===n.root&&t.isExpanded===n.isExpanded&&t.isActive===n.isActive&&t.isBrowserClient===n.isBrowserClient&&t.status===n.status&&t.badge===n.badge&&t.permissions===n.permissions&&t.downloadFile===n.downloadFile&&t.onSelect===n.onSelect&&t.onToggle===n.onToggle&&t.onRevealPath===n.onRevealPath&&t.onOpenDialog===n.onOpenDialog,mo=r.memo(fo,po),go=()=>{const{files:t,runtime:n}=vt(),o=nr(n.platform),i=Je()??"",a=Te(i.trim()),m=rr(),x=ne(s=>s.openContextFile),c=Sn(i),[h,g]=r.useState(""),v=r.useRef(null),{results:u,searching:l}=Es({directory:i,query:h,chrome:"desktop",showGitignored:m}),[N,f]=r.useState({}),[T,p]=r.useState({}),S=r.useRef(new Set),k=r.useRef(new Set),O=r.useRef(null);r.useEffect(()=>{if(!a){f({}),p({}),S.current=new Set;return}const s=tn(a);s?(f({...s.childrenByDir}),p({...s.loadErrorsByDir}),S.current=new Set(s.loadedDirs)):(f({}),p({}),S.current=new Set)},[a]),r.useEffect(()=>{if(!a)return;const s=ut(a);s.childrenByDir=N},[a,N]),r.useEffect(()=>{if(!a)return;const s=ut(a);s.loadErrorsByDir=T},[a,T]),r.useEffect(()=>{if(!a)return;const s=ut(a);s.loadedDirs=new Set(S.current)},[a,N,T]),r.useEffect(()=>()=>{if(!a)return;const s=tn(a);s&&s.loadedDirs.size===0&&Object.keys(s.childrenByDir).length===0&&uo(a)},[a]);const oe=r.useMemo(()=>[],[]),z=r.useMemo(()=>[],[]),G=Ae(s=>a?s.byRoot[a]?.expandedPaths??oe:oe),Q=Ae(s=>a?s.byRoot[a]?.selectedPath??null:null),y=Ae(s=>s.setSelectedPath),b=Ae(s=>s.addOpenPath),X=Ae(s=>s.removeOpenPathsByPrefix),q=Ae(s=>s.toggleExpandedPath),K=Ae(s=>s.collapseAllExpandedPaths),Y=ne(s=>a?s.contextPanelByDirectory[a]?.tabs??z:z),ee=r.useMemo(()=>new Set(Y.map(s=>s.mode==="file"?s.targetPath:null).filter(s=>typeof s=="string"&&s.length>0).map(s=>Te(s))),[Y]),E=r.useCallback(s=>{t.revealPath&&t.revealPath(s).catch(()=>{je.error("Failed to reveal path")})},[t]),Z=r.useCallback((s,d)=>{const D=d.filter(I=>I&&typeof I.name=="string"&&I.name.length>0).filter(I=>m||!Ts(I.name)).map(I=>{const H=I.name,te=Te(I.path||""),we=te?_s(te)?te:Te(`${s}/${te}`):Te(`${s}/${H}`),be=I.isDirectory?"directory":"file",C=be==="file"&&H.includes(".")?H.split(".").pop()?.toLowerCase():void 0;return{name:H,path:we,type:be,extension:C}});return As(D)},[m]),j=r.useCallback(async(s,d)=>{const D=Te(s.trim());if(!D||S.current.has(D)||k.current.has(D))return;k.current=new Set(k.current),k.current.add(D);const I=t.listDirectory?t.listDirectory(D).then(H=>H.entries.map(te=>({name:te.name,path:te.path,isDirectory:te.isDirectory}))):sr(D).then(H=>H.map(te=>({name:te.name,path:te.path,isDirectory:te.isDirectory})));try{const H=await I;if(d?.())return;const te=Z(D,H);S.current=new Set(S.current),S.current.add(D),p(we=>{if(!we[D])return we;const be={...we};return delete be[D],be}),f(we=>({...we,[D]:te}))}catch(H){if(d?.())return;const te=H instanceof Error?H.message:String(H??"");console.error("Failed to load sidebar directory:",H),p(we=>({...we,[D]:te}))}finally{k.current=new Set(k.current),k.current.delete(D)}},[t,Z]),W=r.useCallback(async()=>{if(!a)return;O.current?.abort();const s=new AbortController;O.current=s;try{const D=(Ae.getState().byRoot[a]?.expandedPaths??[]).map(te=>Te(te)).filter(te=>!!te&&te!==a&&te.startsWith(`${a}/`)),I=[a,...D];S.current=new Set(S.current);for(const te of I)S.current.delete(te);p(te=>{if(Object.keys(te).length===0)return te;const we={...te};let be=!1;for(const C of I)C in we&&(delete we[C],be=!0);return be?we:te});const H=()=>s.signal.aborted;await j(a,H);for(let te=0;te<D.length&&!s.signal.aborted;te+=3){const we=D.slice(te,te+3);await Promise.all(we.map(be=>j(be,H)))}}catch(d){if(s.signal.aborted)return;console.error("Failed to refresh sidebar tree:",d)}finally{O.current===s&&(O.current=null)}},[j,a]),re=r.useCallback(async s=>{if(!s){await W();return}const d=Te(s);S.current=new Set(S.current),S.current.delete(d),k.current=new Set(k.current),k.current.delete(d),await j(d)},[j,W]),$=r.useCallback(()=>{a&&y(a,null)},[a,y]),{operation:F,target:ie,inputValue:ce,setInputValue:he,submitting:ge,inputRef:pe,open:de,close:ue,submit:M,capabilities:{canCreateFile:B,canCreateFolder:U,canRename:J,canDelete:ae}}=Ds({files:t,root:a,selectedPath:Q??"",refreshDirectory:re,removeOpenPathsByPrefix:X,clearSelectedPath:$}),xe=!!t.revealPath,ve=r.useMemo(()=>({canRename:J,canCreateFile:B,canCreateFolder:U,canDelete:ae,canReveal:xe}),[J,B,U,ae,xe]);r.useEffect(()=>{a&&(O.current?.abort(),S.current=new Set,k.current=new Set,p({}),f(s=>Object.keys(s).length===0?s:{}),j(a))},[j,a,m]),r.useEffect(()=>{if(!a||G.length===0)return;const s=G.map(I=>Te(I)).filter(I=>!!I&&I!==a&&I.startsWith(`${a}/`)&&!S.current.has(I)&&!k.current.has(I)).sort((I,H)=>I.split("/").length-H.split("/").length);if(s.length===0)return;let d=!1;const D=()=>d;return(async()=>{for(let I=0;I<s.length&&!d;I+=3){const H=s.slice(I,I+3);await Promise.all(H.map(te=>j(te,D)))}})(),()=>{d=!0}},[G,j,a]);const ye=r.useMemo(()=>{const s=new Map;if(!c?.files)return s;for(const d of c.files)d.index==="A"||d.working_dir==="?"?s.set(d.path,"git-added"):d.index==="D"?s.set(d.path,"git-deleted"):(d.index==="M"||d.working_dir==="M")&&s.set(d.path,"git-modified");return s},[c]),P=r.useMemo(()=>{const s=new Map;if(!c?.files||!a)return s;for(const d of c.files){const D=d.index==="M"||d.working_dir==="M",I=d.index==="A"||d.working_dir==="?";if(!D&&!I)continue;const H=d.path.split("/");if(H.length<=1)continue;let te=a;for(let we=0;we<H.length-1;we++){te=`${te}/${H[we]}`;let be=s.get(te);be||(be={modified:0,added:0},s.set(te,be)),D&&be.modified++,I&&be.added++}}return s},[c,a]),se=r.useCallback(s=>{if(ee.has(s))return"open";if(ye.size===0)return null;const d=s.startsWith(a+"/")?s.slice(a.length+1):s;return ye.get(d)??null},[ee,ye,a]),fe=r.useCallback(s=>{if(P.size===0)return null;const d=P.get(s);return d&&d.modified+d.added>0?d:null},[P]),R=r.useCallback(async s=>{if(!a)return;const d=await kn(t,s.path,{directory:a});if(!d.ok){je.error(Pn(d.reason));return}y(a,s.path),b(a,s.path),x(a,s.path)},[b,t,x,a,y]),w=r.useCallback(async s=>{const d=Te(s);a&&(q(a,d),S.current.has(d)||await j(d))},[j,a,q]);function _(s,d){const D=N[s]??[];return D.map((I,H)=>{const te=I.type==="directory",we=te&&G.includes(I.path),be=Q===I.path,C=H===D.length-1;return e.jsxs("li",{className:"relative",children:[d>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),C&&e.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),e.jsx(mo,{node:I,root:a,isExpanded:we,isActive:be,isBrowserClient:o,status:te?void 0:se(I.path),badge:te?fe(I.path):void 0,permissions:ve,downloadFile:t.downloadFile,onSelect:R,onToggle:w,onRevealPath:E,onOpenDialog:de}),te&&we&&e.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[T[I.path]?e.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:T[I.path],children:T[I.path]}),e.jsxs(me,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{re(I.path)},children:[e.jsx(V,{name:"refresh",className:"h-3.5 w-3.5"}),"Refresh"]})]}):null,_(I.path,d+1)]})]},I.path)})}const L=!!(a&&N[a]),A=a?T[a]:null;return e.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-border/40 px-3 py-2",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(V,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),e.jsx(Bt,{ref:v,value:h,onChange:s=>g(s.target.value),placeholder:"Search files...",className:"h-8 pl-8 pr-8 typography-meta"}),h.trim().length>0?e.jsx("button",{type:"button","aria-label":"Clear search",className:"absolute right-2 top-2 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{g(""),v.current?.focus()},children:e.jsx(V,{name:"close",className:"h-4 w-4"})}):null]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[B&&e.jsxs(We,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>de("createFile",{path:i,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:"New File","aria-label":"New File",children:e.jsx(V,{name:"file-add",className:"h-4 w-4"})})})}),e.jsx(Be,{side:"bottom",sideOffset:6,children:"New File"})]}),U&&e.jsxs(We,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>de("createFolder",{path:i,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:"New Folder","aria-label":"New Folder",children:e.jsx(V,{name:"folder-add",className:"h-4 w-4"})})})}),e.jsx(Be,{side:"bottom",sideOffset:6,children:"New Folder"})]}),e.jsxs(We,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>{W()},className:"h-8 w-8 p-0 flex-shrink-0",title:"Refresh","aria-label":"Refresh",children:e.jsx(V,{name:"refresh",className:"h-4 w-4"})})})}),e.jsx(Be,{side:"bottom",sideOffset:6,children:"Refresh"})]}),e.jsxs(We,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>{a&&K(a)},className:"h-8 w-8 p-0 flex-shrink-0",title:"Collapse all folders","aria-label":"Collapse all folders",children:e.jsx(V,{name:"collapse-vertical",className:"h-4 w-4"})})})}),e.jsx(Be,{side:"bottom",sideOffset:6,children:"Collapse all folders"})]})]})]}),e.jsx(Hr,{outerClassName:"flex-1 min-h-0",className:"px-1 py-2",children:e.jsx("ul",{className:"flex flex-col",children:l?e.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx(V,{name:"loader-4",className:"h-4 w-4 animate-spin"}),"Searching..."]}):u.length>0?u.map(s=>{const d=Q===s.path;return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>R(s),draggable:!0,onDragStart:D=>{const I=s.relativePath||Rn(a??"",s.path);!I||I==="."||(D.dataTransfer.setData("application/x-pichamber-file-path",I),D.dataTransfer.effectAllowed="copy")},className:le("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors cursor-grab active:cursor-grabbing",d?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:s.path,children:[Bn(s.path,s.extension),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:s.relativePath??s.path})]})},s.path)}):A?e.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx("span",{children:A}),e.jsxs(me,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{W()},children:[e.jsx(V,{name:"refresh",className:"h-3.5 w-3.5"}),"Refresh"]})]}):L&&a?_(a,0):e.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:"Loading..."})})}),e.jsx(St,{open:!!F,onOpenChange:s=>!s&&ue(),children:e.jsxs(jt,{children:[e.jsxs(Ct,{children:[e.jsxs(Nt,{children:[F==="createFile"&&"Create File",F==="createFolder"&&"Create Folder",F==="rename"&&"Rename",F==="delete"&&"Delete"]}),e.jsxs(kt,{children:[F==="createFile"&&`Create a new file in ${ie?.path??"root"}`,F==="createFolder"&&`Create a new folder in ${ie?.path??"root"}`,F==="rename"&&`Rename ${ie?.name??""}`,F==="delete"&&`Are you sure you want to delete ${ie?.name??""}? This action cannot be undone.`]})]}),F!=="delete"&&e.jsx("div",{className:"py-4",children:e.jsx(Bt,{ref:pe,value:ce,onChange:s=>he(s.target.value),placeholder:F==="rename"?"New name":"Name",onKeyDown:s=>{s.key==="Enter"&&M()},autoFocus:!0})}),e.jsxs(Vr,{children:[e.jsx(me,{variant:"outline",onClick:ue,disabled:ge,children:"Cancel"}),e.jsx(me,{variant:F==="delete"?"destructive":"default",onClick:()=>{M()},disabled:ge||F!=="delete"&&!ce.trim(),children:ge?e.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}):F==="delete"?"Delete":"Confirm"})]})]})})]})},xo=200,wo=480,yo=({visible:t})=>{const n=ne(p=>p.contextEditorTreeWidth),o=ne(p=>p.setContextEditorTreeWidth),[i,a]=r.useState(!1),m=r.useRef(0),x=r.useRef(n),c=r.useRef(null),h=r.useRef(null),g=r.useRef(null),v=r.useCallback(p=>Math.min(wo,Math.max(xo,Math.round(p))),[]),u=r.useCallback(p=>{const S=g.current;S&&(S.style.width=`${p}px`,S.style.setProperty("--oc-editor-tree-width",`${p}px`))},[]),l=p=>{if(t){try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}h.current=p.pointerId,a(!0),m.current=p.clientX,x.current=n,c.current=n,p.preventDefault()}},N=p=>{if(!i||h.current!==p.pointerId)return;const S=m.current-p.clientX,k=v(x.current+S);c.current!==k&&(c.current=k,u(k))},f=p=>{if(h.current!==p.pointerId)return;try{p.currentTarget.releasePointerCapture(p.pointerId)}catch{}const S=v(c.current??n);h.current=null,c.current=null,a(!1),o(S)},T=t?n:0;return e.jsxs("div",{ref:g,className:le("relative h-full flex-shrink-0 overflow-hidden border-l border-border bg-background will-change-[width] motion-reduce:transition-none",!t&&"border-l-0"),style:{width:`${i?c.current??T:T}px`,"--oc-editor-tree-width":`${i?c.current??n:n}px`,overflowX:"clip",transitionProperty:i?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&e.jsx("div",{className:le("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",i&&"bg-[var(--interactive-border)]"),onPointerDown:l,onPointerMove:N,onPointerUp:f,onPointerCancel:f,role:"separator","aria-orientation":"vertical","aria-label":"Resize context panel"}),e.jsx("div",{className:le("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",i&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)"},"aria-hidden":!t,children:e.jsx(go,{})})]})},bo="x-pichamber-preview-target-error",vo=t=>{const n=t.get(bo);return n==="missing"||n==="expired"||n==="invalid-token"?n:null},So=(t,n)=>vo(t)?n?"stop-retrying":"retry-registration":"none",jo=({rawUrl:t,onNavigate:n})=>{const{currentTheme:o}=Kr(),[i,a]=r.useReducer(R=>R+1,0),[m,x]=r.useReducer(R=>R+1,0),[c,h]=r.useState({status:"idle"}),g=r.useRef(null),v=r.useRef(1),[u,l]=r.useState(!1),[N,f]=r.useState(!1),[T,p]=r.useState("all"),[S,k]=r.useState([]),[O,oe]=r.useState(!1),[z,G]=r.useState(null),Q=Ce(R=>R.currentSessionId),y=Ce(R=>R.newSessionDraft?.open),b=Je(),X=it(R=>R.addAttachedFile);let q=null;try{q=t?new URL(t):null}catch{q=null}const K=q?q.hostname==="localhost"||q.hostname==="127.0.0.1"||q.hostname==="::1"||q.hostname==="[::1]"||q.hostname==="0.0.0.0":!1,Y=q?q.hostname==="0.0.0.0"?new URL(q.toString().replace("0.0.0.0","127.0.0.1")):q:null,ee=Y?Y.toString():"",E=ee?`${fn()||"same-origin"}|${ee}`:"",Z=o.metadata.variant;r.useEffect(()=>{if(!ee||!K){h({status:"idle"});return}const R=Et(E);if(R?.previewToken){h({status:"ready",proxyBasePath:R.proxyBasePath,previewToken:R.previewToken,expiresAt:R.expiresAt});return}R&&Re.delete(E);let w=!1;return h({status:"loading"}),(async()=>{try{const _=await rt("/api/preview/targets",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:ee})}),L=await On(_);if(!L.ok){Re.delete(E),w||h({status:"error",message:L.message});return}Re.set(E,L.target),w||h({status:"ready",...L.target})}catch(_){if(Re.delete(E),!w){const L=_ instanceof Error?_.message:String(_);h({status:"error",message:L})}}})(),()=>{w=!0}},[K,E,m,ee]);const j=Y&&(Y.protocol==="http:"||Y.protocol==="https:")?Y.toString():"",W=K&&c.status==="ready"?`${c.proxyBasePath}|${c.previewToken||""}|${i}`:"",re=Wn(W),$=K&&c.status==="ready"&&Y&&re===W?(()=>{const R=Y.pathname||"/",w=new URLSearchParams(Y.search);w.delete("oc_url_token"),w.delete("oc_client_token"),w.set("ocPreview",String(i)),w.set("oc_preview_token",c.previewToken||"");const _=w.toString(),L=Y.hash||"";return pn().authenticatedAsset(`${c.proxyBasePath}${R}${_?`?${_}`:""}${L}`)})():"",F=K?$:j,ie=K?ro($):j,ce=K&&(c.status==="loading"||c.status==="idle"||re!==W),he=K&&c.status==="error",ge=r.useCallback(R=>{if(!(Q??(y?"draft":null))||!b){je.error("Open a chat session before attaching preview annotations");return}const _=t||F||"",L=typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0},A=typeof window<"u"?window.devicePixelRatio:1;(async()=>{let s=!1;try{const d=g.current,D=d?await Ln(d,R):null;D&&(await X(D),s=!0)}catch{s=!1}ot(Rt({pageUrl:_,viewport:L,devicePixelRatio:A,target:R,screenshotAttached:s,intro:"This is a selected DOM element from the in-app preview."})),je.success("Preview annotation attached to chat")})()},[X,Q,b,F,y,t]);r.useEffect(()=>{l(!1),k([]),f(!1),p("all"),oe(!1),G(null),v.current=1},[F]),r.useEffect(()=>{const R=g.current?.contentWindow;!u||!R||Qt(R,$,{source:"pichamber-preview-parent",version:1,type:"set-inspect-mode",enabled:O})},[u,O,$]),r.useEffect(()=>{const R=g.current?.contentWindow;!u||!R||Qt(R,$,{source:"pichamber-preview-parent",version:1,type:"set-color-scheme",scheme:Z})},[u,Z,$]),r.useEffect(()=>{if(!O||typeof window>"u")return;const R=w=>{w.key==="Escape"&&(w.preventDefault(),w.stopImmediatePropagation(),oe(!1))};return window.addEventListener("keydown",R,!0),()=>window.removeEventListener("keydown",R,!0)},[O]),r.useEffect(()=>{if(!K||typeof window>"u")return;const R=L=>{if(typeof L=="string")return L;if(L==null)return"";try{return JSON.stringify(L)}catch{return String(L)}},w=L=>{const A=v.current;v.current+=1,k(s=>{const d=[...s,{...L,id:A}];return d.length>Jt?d.slice(d.length-Jt):d})},_=L=>{if(L.source!==g.current?.contentWindow)return;const A=L.data;if(!(!A||A.source!=="pichamber-preview-bridge"||A.version!==1)){if(A.type==="ready"){l(!0);return}if(A.type==="console"){const s=A.level==="error"||A.level==="warn"||A.level==="info"||A.level==="debug"?A.level:"log",d=Array.isArray(A.args)?A.args.map(R).filter(Boolean):[];w({level:s,message:d.join(" "),ts:typeof A.ts=="number"?A.ts:Date.now()});return}if(A.type==="runtime-error"){const s=R(A.filename),d=typeof A.line=="number"?A.line:null,D=typeof A.column=="number"?A.column:null,I=s?`${s}${d!==null?`:${d}${D!==null?`:${D}`:""}`:""}`:"",H=R(A.stack);w({level:"runtime",message:R(A.message)||"Runtime error",details:[I,H].filter(Boolean).join(`
|
|
127
|
-
`),ts:typeof A.ts=="number"?A.ts:Date.now()});return}if(A.type==="resource-error"){const s=R(A.tag)||"resource",d=R(A.url);w({level:"resource",message:d?`${s}: ${d}`:s,details:R(A.outerHTML),ts:typeof A.ts=="number"?A.ts:Date.now()});return}if(A.type==="hover"){G(Ue(A.target)?A.target:null);return}if(A.type==="select"&&Ue(A.target)){G(A.target),oe(!1),ge(A.target);return}if(A.type==="navigate-preview"){const s=typeof A.url=="string"?A.url:"",d=A.navigation==="external"?"external":"proxy";if(s&&d==="external"){st(s);return}s&&n(s)}}};return window.addEventListener("message",_),()=>{window.removeEventListener("message",_)}},[ge,K,n]);const pe=S.filter(R=>R.level==="error"||R.level==="runtime"||R.level==="resource").length,de=S.filter(R=>no(R,T)),ue=r.useCallback(()=>{const R=[`Preview URL: ${t||F||""}`,`Events: ${S.length}`,""].join(`
|
|
128
|
-
`),w=S.map(_=>{const L=new Date(_.ts).toISOString(),A=_.details?`
|
|
129
|
-
${_.details}`:"";return`[${L}] [${_.level}] ${_.message}${A}`}).join(`
|
|
130
|
-
`);bt(`${R}${w}`).then(_=>{_.ok?je.success("Preview console copied"):je.error("Failed to copy preview console")})},[S,F,t]),M=r.useCallback(()=>{if(!(Q??(y?"draft":null))||!b){je.error("Open a chat session before attaching preview logs");return}const w=[`Preview URL: ${t||F||""}`,`Events: ${S.length}`,""].join(`
|
|
131
|
-
`),_=S.map(L=>{const A=new Date(L.ts).toISOString(),s=L.details?`
|
|
132
|
-
${L.details}`:"";return`[${A}] [${L.level}] ${L.message}${s}`}).join(`
|
|
133
|
-
`);ot(`These are browser console logs from the dev server running for this project.
|
|
134
|
-
|
|
135
|
-
${w}${_}`),je.success("Preview console attached to chat")},[S,Q,b,F,y,t]),[B,U]=r.useState("unknown"),J=r.useRef(0),ae=r.useRef(0),xe=r.useRef(""),ve=r.useRef(""),ye=15e3;r.useEffect(()=>{if(!$){U("unknown"),xe.current="",J.current=0,ae.current=0;return}let R=!1,w=null;xe.current!==E&&(xe.current=E,J.current=Date.now(),ae.current=0);const _=L=>{w=setTimeout(()=>{R||a()},L)};return U("unknown"),(async()=>{const A=await(async()=>{try{return await rt($,{method:"GET",credentials:"include",cache:"no-store",redirect:"manual"})}catch{return null}})();if(R)return;if(!A){U("unreachable"),_(5e3);return}const s=So(A.headers,ve.current===E);if(s!=="none"){if(Re.delete(E),s==="retry-registration")ve.current=E,h({status:"loading"}),x();else{const I=await A.json().catch(()=>({}));if(R)return;const H=typeof I?.error=="string"?I.error:`HTTP ${A.status}`;h({status:"error",message:H})}return}if(A.status!==502){ve.current="",U("reachable");return}const d=J.current||Date.now();if(Date.now()-d<ye){U("starting"),ae.current+=1;const I=ae.current,H=Math.min(2e3,250*Math.pow(2,Math.min(4,I)));_(H);return}U("unreachable"),_(5e3)})(),()=>{R=!0,w&&clearTimeout(w)}},[E,$,i]);const P=K&&c.status==="ready"&&(B==="unknown"||B==="starting"),se=K&&c.status==="ready"&&B==="unreachable",fe=r.useCallback(R=>{if(!K||c.status!=="ready"||typeof window>"u")return;const w=R.currentTarget.contentWindow;if(w)try{const _=w.location,L=$n($);if(_.origin!==L||_.pathname.startsWith(c.proxyBasePath))return;const A=`${c.proxyBasePath}${_.pathname}${_.search}${_.hash}`;w.location.replace(A)}catch{}},[K,$,c]);return e.jsxs("div",{className:"absolute inset-0 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[e.jsx("div",{className:"min-w-0 flex-1 truncate typography-micro text-muted-foreground",title:ie||t,children:ie||t||"No preview URL"}),e.jsx(me,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>a(),title:"Reload preview","aria-label":"Reload preview",disabled:!F,children:e.jsx(V,{name:"refresh",className:"h-3.5 w-3.5"})}),e.jsx(me,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{j&&st(j)},title:"Open in browser","aria-label":"Open in browser",disabled:!j,children:e.jsx(V,{name:"external-link",className:"h-3.5 w-3.5"})}),K?e.jsx(me,{type:"button",size:"sm",variant:O?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>oe(R=>!R),title:"Inspect preview element","aria-label":"Inspect preview element",disabled:!u,children:e.jsx(V,{name:"cursor",className:"h-3.5 w-3.5"})}):null,K?e.jsxs(me,{type:"button",size:"sm",variant:N?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>f(R=>!R),title:u?"Open preview console":"Waiting for preview console","aria-label":u?"Open preview console":"Waiting for preview console",disabled:!u&&S.length===0,children:[e.jsx(V,{name:"terminal-box",className:"h-3.5 w-3.5"}),pe>0?e.jsx("span",{className:"typography-micro text-status-error",children:pe}):null]}):null]}),e.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[P?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[e.jsx("div",{children:"Starting dev server..."}),e.jsx("div",{className:"text-xs opacity-70",children:"Waiting for the server to accept connections."})]}):se?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[e.jsx("div",{children:"Dev server is not responding."}),e.jsx("div",{className:"text-xs opacity-70",children:"Make sure your dev server is still running, then retry."}),e.jsx(me,{type:"button",size:"sm",variant:"outline",onClick:()=>a(),children:"Retry"})]}):F&&(!K||B==="reachable")?e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("iframe",{ref:g,src:F,title:"Preview",className:"h-full w-full border-0",style:{colorScheme:Z},onLoad:fe,sandbox:K?"allow-scripts allow-same-origin allow-forms allow-popups allow-downloads":"allow-scripts allow-forms"},`${F}:${i}`),O&&z?e.jsx("div",{className:"pointer-events-none absolute rounded-sm border-2 border-[var(--interactive-focus-ring)] bg-[var(--interactive-focus-ring)]/35",style:{left:z.bounds.x,top:z.bounds.y,width:z.bounds.width,height:z.bounds.height},children:e.jsxs("div",{className:"absolute -top-6 left-0 max-w-64 truncate rounded bg-[var(--surface-elevated)] px-2 py-0.5 typography-micro text-foreground shadow",children:[z.tag,z.text?` · ${z.text}`:""]})}):null]}):ce?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-muted-foreground",children:"Connecting preview proxy..."}):he?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-sm text-muted-foreground",children:[e.jsx("div",{children:"Could not start preview proxy."}),c.status==="error"?e.jsx("div",{className:"text-center text-xs opacity-70",children:c.message}):null]}):e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-muted-foreground",children:"Preview needs a valid http(s) URL."}),N?e.jsxs("div",{className:"absolute inset-x-3 bottom-3 z-10 max-h-[45%] overflow-hidden rounded-xl border border-border/70 bg-[var(--surface-elevated)] shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/50 px-3 py-2",children:[e.jsx("div",{className:"typography-ui-label text-foreground",children:"Preview console"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(me,{type:"button",size:"xs",variant:"ghost",onClick:M,disabled:S.length===0,children:"Attach"}),e.jsx(me,{type:"button",size:"xs",variant:"ghost",onClick:ue,disabled:S.length===0,children:"Copy"}),e.jsx(me,{type:"button",size:"xs",variant:"ghost",onClick:()=>k([]),disabled:S.length===0,children:"Clear"})]})]}),e.jsx("div",{className:"flex items-center gap-1 border-b border-border/30 px-3 py-1.5",children:["all","errors","warnings","logs"].map(R=>e.jsx(me,{type:"button",size:"xs",variant:T===R?"secondary":"ghost",onClick:()=>p(R),children:R==="all"?"All":R==="errors"?"Errors":R==="warnings"?"Warnings":"Logs"},R))}),e.jsx("div",{className:"max-h-64 overflow-auto p-2 typography-code text-xs",children:S.length===0?e.jsx("div",{className:"px-2 py-3 text-muted-foreground",children:"No preview console events yet."}):de.length===0?e.jsx("div",{className:"px-2 py-3 text-muted-foreground",children:"No events match this filter."}):de.map(R=>e.jsx("div",{className:"border-b border-border/30 px-2 py-1 last:border-b-0",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:le("shrink-0 uppercase",R.level==="error"||R.level==="runtime"||R.level==="resource"?"text-status-error":R.level==="warn"?"text-status-warning":"text-muted-foreground"),children:R.level}),e.jsx("span",{className:"min-w-0 break-words text-foreground",children:R.message})]})},R.id))})]}):null]})]})},At=t=>t,xt=t=>{const n=At(t).type;return typeof n=="string"?n:""},Co=t=>{const n=At(t).tool;return typeof n=="string"?n:""},No=t=>{const n=At(t).text;return typeof n=="string"?n:""},ko=t=>{const n=xt(t);return n==="tool"?Co(t).trim().toLowerCase()||"tool":n||"unknown"},Po=t=>{if(t.length===0)return"";const n=[];for(const o of t){const i=ko(o);n.includes(i)||n.push(i)}return n.join(" + ")},Ro=t=>t.replace(/\s+/g," ").trim(),Eo=t=>{for(const o of t)if(xt(o)==="text"){const i=Ro(No(o));if(i.length===0)continue;return i}const n=t.filter(o=>xt(o)!=="text").length;return n===0?"":`${n} attachment${n===1?"":"s"}`},To=(t,n,o)=>`${o(t)} / ${o(n)}`,_o=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Ao=(t,n)=>{if(!t||!Number.isFinite(t))return"-";const o=_o(n);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:o===!1?"2-digit":"numeric",minute:"2-digit",...o===void 0?{}:{hour12:o}})},Do={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},nt={user:0,assistant:0,tool:0,other:0},Mo=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,ht=t=>gt(t),Io=(...t)=>{for(const n of t)if(typeof n=="string"&&n.trim().length>0)return n;return""},ke=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((n,o)=>n+ke(o),0):t&&typeof t=="object"?Object.values(t).reduce((n,o)=>n+ke(o),0):0,Lo=(t,n)=>{const o=t,i=typeof o.type=="string"?o.type:"";if(i==="reasoning")return{...nt,assistant:ke(o.text)+ke(o.content)};const a=Io(o.text,o.content,o.value,o.source?.value,o.source?.text?.value);return i==="tool"||n==="tool"?{user:0,assistant:0,tool:ke(o.input)+ke(o.output)+ke(o.error)+ke(o.call?.input)+ke(o.call?.output)+ke(o.call?.error)+ke(o.raw)+Math.round(ke(o.metadata)*.25)+Math.round(ke(o.state)*.1),other:0}:n==="user"?{user:a.length,assistant:0,tool:0,other:0}:n==="assistant"?{user:0,assistant:a.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:a.length}},nn=(t,n)=>({user:t.user+n.user,assistant:t.assistant+n.assistant,tool:t.tool+n.tool,other:t.other+n.other}),Oo=t=>{const n=qe(t.info);return n.isUser?"user":n.role==="assistant"?"assistant":n.role==="tool"?"tool":"other"},$o=(t,n)=>{if(t.length===0)return{...nt};const o=t.reduce((i,a)=>{const m=Oo(a);let x={...nt};for(const c of a.parts)x=nn(x,Lo(c,m));return nn(i,x)},{...nt});return o.user+=n.length,{user:Math.ceil(o.user/4),assistant:Math.ceil(o.assistant/4),tool:Math.ceil(o.tool/4),other:Math.ceil(o.other/4)}},Le=t=>t.toLocaleString("en-US"),Wo=t=>!Number.isFinite(t)||t<=0?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(0):new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:t<.01?4:2,maximumFractionDigits:t<.01?4:2}).format(t),Fo=(t,n)=>!t||!Number.isFinite(t)?"-":Yr(t,n,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Bo=(t,n,o)=>{const i=t.find(m=>m.id===n),a=i?.models?.find(m=>m.id===o);return{providerName:i?.name||n||"-",modelName:a?.name||o||"-",contextLimit:typeof a?.limit?.context=="number"?a.limit.context:null}},zo=()=>{const t=ne(f=>f.timeFormatPreference),[n,o]=r.useState({}),{value:i,show:a,clear:m}=Xr(null,2e3),x=Ce(f=>f.currentSessionId),c=Ce(f=>f.currentSessionDirectory),h=qr(),g=jn(x??""),v=$e(f=>f.providers);r.useEffect(()=>{o(f=>Object.keys(f).length>0?{}:f),m()},[m,c,x]);const u=r.useCallback(async(f,T)=>{(await bt(T)).ok?a(f):m()},[m,a]),l=r.useMemo(()=>{const f=x?h.find($=>$.id===x)??null:null,T=g.filter($=>qe($.info).role==="assistant"),p=g.filter($=>qe($.info).isUser);let S=null;for(let $=T.length-1;$>=0;$-=1){const F=T[$];if(ht(F).total>0){S=F;break}}const k=S?ht(S):Do,O=S?.info?.usage,oe=wn({input:k.input,cache:{read:k.cacheRead,write:k.cacheWrite}}),z=T.reduce(($,F)=>{const ie=Mo(F.info.cost);return $+ie},0),G=S?.info?.model??null,Q=Bo(v,G?.providerID||"",G?.modelID||""),y=Q.contextLimit,b=O?yn(O):k.total,X=y&&y>0?Math.min(999,b/y*100):0,q=[...g].reverse().find($=>qe($.info).isUser&&typeof $.info.system=="string")?.info?.system||"",K=$o(g,q),Y=K.user,ee=K.assistant,E=K.tool,Z=O?0:Math.max(0,k.input-Y-ee-E),j=Y+ee+E+Z,W=g[0]?.info?.time?.created,re=g.length>0?g[g.length-1]?.info?.time?.created:null;return{sessionTitle:En(f),messagesCount:g.length,userMessagesCount:p.length,assistantMessagesCount:T.length,createdAt:f?.time?.created??W??null,lastActivityAt:re??f?.time?.created??null,providerModel:Q,tokenBreakdown:k,usagePercent:X,cacheHitRate:oe,totalAssistantCost:z,contextLimit:y,contextWindowTokens:b,hasUsage:O!==void 0,breakdown:{user:Y,assistant:ee,tool:E,other:Z},breakdownTotal:j}},[x,v,g,h]);if(!x)return e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:"Open a session to inspect context."});const N=[{key:"user",label:"User",value:l.breakdown.user,color:"var(--status-success)"},{key:"assistant",label:"Assistant",value:l.breakdown.assistant,color:"var(--primary-base)"},{key:"tool",label:"Tool Calls",value:l.breakdown.tool,color:"var(--status-warning)"},...l.hasUsage?[]:[{key:"other",label:"Other",value:l.breakdown.other,color:"var(--surface-muted-foreground)"}]];return e.jsx("div",{className:"h-full overflow-y-auto bg-background",children:e.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:l.sessionTitle}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[e.jsxs("span",{children:[l.providerModel.providerName," / ",l.providerModel.modelName]}),l.createdAt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:Fo(l.createdAt,t)})]})]})]}),e.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Context"}),e.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[Le(l.contextWindowTokens),l.contextLimit?` / ${Le(l.contextLimit)}`:""]})]}),e.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:l.usagePercent>0&&e.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,l.usagePercent)}%`,backgroundColor:l.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}})}),e.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:`${l.usagePercent.toFixed(1)}% used`})]}),e.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:[{label:"Messages",value:Le(l.messagesCount)},{label:"User",value:Le(l.userMessagesCount)},{label:"Assistant",value:Le(l.assistantMessagesCount)},{label:"Cost",value:Wo(l.totalAssistantCost)}].map(f=>e.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[e.jsx("div",{className:"typography-micro text-muted-foreground/70",children:f.label}),e.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:f.value})]},f.label))}),e.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[e.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:"Last Assistant Message"}),e.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:"Input",value:l.tokenBreakdown.input,format:"count"},{label:"Output",value:l.tokenBreakdown.output,format:"count"},{label:"Reasoning",value:l.tokenBreakdown.reasoning,format:"count"},{label:"Cache Read",value:l.tokenBreakdown.cacheRead,format:"count"},{label:"Cache Write",value:l.tokenBreakdown.cacheWrite,format:"count"},{label:"Cache Hit",value:l.cacheHitRate.hasInput?l.cacheHitRate.percent:null,format:"percent"}].map(f=>e.jsxs("div",{children:[e.jsx("div",{className:"typography-micro text-muted-foreground/70",children:f.label}),e.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:f.value!==null&&f.value!==void 0?f.format==="percent"?`${f.value.toFixed(1)}%`:Le(f.value):"—"})]},f.label))})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:N.map(f=>f.value<=0||l.breakdownTotal<=0?null:e.jsx("div",{style:{width:`${f.value/l.breakdownTotal*100}%`,backgroundColor:f.color}},f.key))}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:N.map(f=>{const T=l.breakdownTotal>0?f.value/l.breakdownTotal*100:0;return e.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:f.color}}),e.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[f.label," ",e.jsxs("span",{className:"tabular-nums",children:[T.toFixed(0),"%"]})]})]},f.key)})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"typography-micro text-muted-foreground",children:"Raw Messages"}),e.jsx("div",{className:"mt-2.5 space-y-1",children:[...g].reverse().map(f=>{const p=qe(f.info).role,S=p==="assistant",k=p==="user",O=n[f.info.id]===!0,oe=i===f.info.id,z=f.info.time?.created??null,G=Po(f.parts),Q=S?ht({info:f.info,parts:f.parts}):null,y=k?Eo(f.parts):"",b=Ao(z,t),X=G||"—",q=Q?To(Q.input,Q.output,Le):"",K=p||"unknown",Y=G?`${K}: ${G}`:K,ee=O?JSON.stringify({info:f.info,parts:f.parts},null,2):"";return e.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[e.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":O,onClick:()=>{o(E=>({...E,[f.info.id]:E[f.info.id]!==!0}))},children:e.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:S?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[k?e.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",y]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:S?X:Y}),S&&e.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:q})]}),e.jsx("span",{className:"text-right text-muted-foreground",children:b})]})}),O&&e.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:e.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[e.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:E=>{E.stopPropagation(),u(f.info.id,ee)},"aria-label":oe?"Copied":"Copy JSON",title:oe?"Copied":"Copy",children:oe?e.jsx(V,{name:"check",className:"size-3.5"}):e.jsx(V,{name:"file-copy",className:"size-3.5"})})}),e.jsx(Gr,{language:"json",code:ee,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},f.info.id)})})]})]})})},Uo=_e(()=>Ee(()=>import("./DiffView-BxwoRCYx.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52])).then(t=>({default:t.DiffView}))),Ho=_e(()=>Ee(()=>import("./FilesView-D_2QcdUt.js"),__vite__mapDeps([53,1,2,3,4,5,6,7,8,9,10,11,12,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,50,51,33,34,18,19,20,21,22,23,24,25,26,27,28,29,30,31,70,71,45,46,47,48,49,72,73,15,16,17,32,35,36,37,38,39,40,41,74,75,76,77])).then(t=>({default:t.FilesView}))),Vo=_e(()=>Ee(()=>import("./GitView-XBBheKRM.js"),__vite__mapDeps([78,6,1,2,3,10,4,5,7,8,9,11,12,45,46,47,48,49,13,79,80,81,82,44,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,14,42,43,50,51])).then(t=>({default:t.GitView}))),Ko=_e(()=>Ee(()=>import("./PullRequestsSurface-B3ictm4I.js"),__vite__mapDeps([83,6,1,2,3,84,4,5,7,8,9,10,11,12,45,46,47,48,49,85,79,80,44,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,14,42,43,50,51])).then(t=>({default:t.PullRequestsSurface}))),Xo=_e(()=>Ee(()=>import("./IssuesSurface-BA1kpvAJ.js"),__vite__mapDeps([86,1,2,3,84,4,5,6,7,8,9,10,11,12,45,46,47,48,49,85,79,80,87])).then(t=>({default:t.IssuesSurface}))),qo=380,Go=1400,zn=600,Yo=100,Jo=24,rn=t=>Number.isFinite(t)?Math.min(Go,Math.max(qo,Math.round(t))):zn,Qo=t=>{const n=t?.parentElement?.clientWidth;return!n||n<=0?null:n},Zo=(t,n)=>{if(!t)return"";const o=t.replace(/\\/g,"/"),i=n.replace(/\\/g,"/").replace(/\/+$/,"");return i&&o.startsWith(i+"/")?o.slice(i.length+1):o},wt=(t,n=null)=>t==="file"?"Files":t==="diff"?"Changes":t==="preview"?"Preview":t==="browser"?"Browser":t==="git"?Pt(n).label:t==="terminal"?"Terminal":t==="pull-requests"?"Pull requests":t==="issues"?"Issues":t==="extensions"?"Extensions":"Context",ea=t=>{if(!t)return null;const n=t.replace(/\\/g,"/").trim();if(!n)return null;const o=n.split("/").filter(Boolean);return o.length===0?n:o[o.length-1]||null},ta=(t,n=null)=>{if(t.label)return t.label;if(t.mode==="file")return ea(t.targetPath)||"Files";if(t.mode==="preview"){const o=t.targetPath;if(o)try{const i=new URL(o);return i.host||i.hostname||"Preview"}catch{}return"Preview"}return t.mode==="diff"?"Changes":wt(t.mode,n)},ft=(t,n=null)=>{if(t.mode==="file")return t.targetPath?e.jsx(yt,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return e.jsx(Nr,{className:"h-3.5 w-3.5"});if(t.mode==="git")return e.jsx(V,{name:Pt(n).icon,className:"h-3.5 w-3.5"});if(t.mode==="terminal")return e.jsx(V,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return e.jsx(V,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="preview")return e.jsx(V,{name:"global",className:"h-3.5 w-3.5 text-[var(--status-info)]"});if(t.mode==="browser")return e.jsx(V,{name:"global",className:"h-3.5 w-3.5"});if(t.mode==="pull-requests")return e.jsx(V,{name:"git-pull-request",className:"h-3.5 w-3.5"});if(t.mode==="issues")return e.jsx(V,{name:"task",className:"h-3.5 w-3.5"});if(t.mode==="extensions")return e.jsx(V,{name:"plug-2",className:"h-3.5 w-3.5"})},na=(t,n)=>t.length<=n?t:`${t.slice(0,n-3)}...`,ra=()=>{const t=Je()??"",n=r.useMemo(()=>Te(t),[t]),o=ne(C=>n?C.contextPanelByDirectory[n]:void 0),i=ne(C=>C.closeContextPanel),a=ne(C=>C.closeContextPanelTab),m=ne(C=>C.openContextPanelTab),x=ne(C=>C.toggleContextPanelExpanded),c=ne(C=>C.setContextPanelWidth),h=ne(C=>C.setActiveContextPanelTab),g=ne(C=>C.reorderContextPanelTabs),v=Ae(C=>C.setSelectedPath),u=ne(C=>C.openContextPreview),l=ne(C=>C.contextEditorTreeVisible),N=ne(C=>C.toggleContextEditorTree),f=Ce(C=>C.currentSessionId),T=r.useMemo(()=>o?.tabs??[],[o?.tabs]),p=T.find(C=>C.id===o?.activeTabId)??T[T.length-1]??null,S=!!(o?.isOpen&&p),k=!!(S&&o?.expanded),[O,oe]=r.useState(null),z=o?.width,G=Zr,Q=O??(typeof window<"u"?window.innerWidth:zn*2),y=rn(z??Math.round(G*Q)),b=Cn(n||null),[X,q]=r.useState(!1),[K,Y]=r.useState(null),[ee,E]=r.useState(null),[Z,j]=r.useState(null),[W,re]=r.useState(null),$=r.useRef(0),F=r.useRef(y),ie=r.useRef(null),ce=r.useRef(null),he=r.useRef(null),ge=r.useRef(!1);r.useLayoutEffect(()=>{const C=he.current?.parentElement;if(!C||typeof ResizeObserver>"u")return;const Se=new ResizeObserver(()=>{oe(C.clientWidth||null)});return Se.observe(C),oe(C.clientWidth||null),()=>Se.disconnect()},[]),r.useEffect(()=>{if(!S||ge.current){ge.current=S;return}const C=window.requestAnimationFrame(()=>{he.current?.focus({preventScroll:!0})});return ge.current=!0,()=>window.cancelAnimationFrame(C)},[S]);const pe=r.useRef(null),de=r.useRef(null),ue=r.useCallback(()=>{de.current=null;const C=he.current,Se=ie.current;!C||Se===null||C.style.setProperty("--oc-context-panel-width",`${Se}px`)},[]);r.useEffect(()=>()=>{de.current!==null&&clearTimeout(de.current)},[]);const M=r.useCallback(C=>{const Se=rn(C),Me=pe.current;return Me===null?Se:Math.min(Se,Math.max(1,Me))},[]),B=r.useCallback(C=>{!S||k||!n||(ce.current=C.pointerId,q(!0),$.current=C.clientX,F.current=y,ie.current=y,pe.current=Qo(he.current),document.documentElement.style.cursor="col-resize",C.preventDefault())},[n,k,S,y]),U=r.useCallback(()=>{const C=M(ie.current??y);ie.current=null,pe.current=null,de.current!==null&&(clearTimeout(de.current),de.current=null),document.documentElement.style.cursor="",n&&c(n,C),q(!1),ce.current=null},[M,n,c,y]);r.useEffect(()=>{if(!X)return;const C=Ie=>{if(ce.current!==Ie.pointerId)return;const Hn=$.current-Ie.clientX,Dt=M(F.current+Hn);ie.current!==Dt&&(ie.current=Dt,de.current===null&&(de.current=setTimeout(ue,Yo)))},Se=Ie=>{ce.current===Ie.pointerId&&U()},Me=()=>{U()};return window.addEventListener("pointermove",C),window.addEventListener("pointerup",Se),window.addEventListener("pointercancel",Se),window.addEventListener("blur",Me),()=>{window.removeEventListener("pointermove",C),window.removeEventListener("pointerup",Se),window.removeEventListener("pointercancel",Se),window.removeEventListener("blur",Me)}},[ue,M,U,X]),r.useEffect(()=>{X||(ie.current=null,document.documentElement.style.cursor="")},[X]);const J=r.useCallback(()=>{n&&i(n)},[i,n]),ae=r.useCallback(()=>{n&&x(n)},[n,x]),xe=r.useCallback(C=>{C.key==="Escape"&&(Jr(C.target)||(C.preventDefault(),C.stopPropagation(),J()))},[J]);r.useEffect(()=>{if(!(!n||!p)&&p.mode==="file"&&p.targetPath){v(n,p.targetPath,{allowOutsideRoot:!0});return}},[p,n,v]);const ve=r.useCallback(C=>{!n||p?.mode!=="diff"||m(n,{mode:"diff",targetPath:p.targetPath,stagedDiff:C==="staged",diffScope:C})},[p,n,m]),ye=p?.mode==="file"||p?.mode==="preview",P=r.useMemo(()=>p?T.filter(C=>C.mode===p.mode):[],[p,T]),se=r.useMemo(()=>P.map(C=>{const Se=ta(C,b),Me=na(Se,Jo),Ie=Zo(C.targetPath,t);return{id:C.id,label:Me,icon:ft(C,b),title:Ie?`${Se}: ${Ie}`:Se,closeLabel:`Close ${Me} tab`}}),[P,t,b]),fe=p?.mode==="pull-requests",R=p?.mode==="issues",w=p?.mode==="context"?e.jsx(zo,{}):p?.mode==="extensions"?e.jsx(Qr,{sessionId:f}):p?.mode==="git"?e.jsx(r.Suspense,{fallback:null,children:e.jsx(Vo,{isActive:S,gitHeaderSlot:p?.mode==="git"?ee:null})}):p?.mode==="pull-requests"?e.jsx(r.Suspense,{fallback:null,children:e.jsx(Ko,{headerActionsSlot:fe?W:null,headerActionsPresentation:"desktop"},`pull-requests:${n}`)}):p?.mode==="issues"?e.jsx(r.Suspense,{fallback:null,children:e.jsx(Xo,{headerActionsSlot:R?W:null,headerActionsPresentation:"desktop"},`issues:${n}`)}):p?.mode==="preview"?e.jsx(jo,{rawUrl:p.targetPath??"",onNavigate:C=>u(t,C)}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx(V,{name:"global",className:"h-12 w-12 text-muted-foreground/50"}),e.jsx("div",{className:"typography-ui-header text-foreground",children:"Preview"}),e.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:"Use Project Actions or a terminal Preview button to open a preview."})]}),_=r.useMemo(()=>T.filter(C=>C.mode==="browser"),[T]),L=r.useMemo(()=>T.filter(C=>C.mode==="diff"),[T]),A=r.useMemo(()=>T.some(C=>C.mode==="terminal"),[T]),s=r.useMemo(()=>T.some(C=>C.mode==="file"),[T]),d=r.useMemo(()=>T.some(C=>C.mode==="file"&&C.targetPath),[T]),D=p?.mode==="file",I=p?.mode==="terminal",H=p?.mode==="git",te=p?.mode==="diff",we=e.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[ye?e.jsx($s,{items:se,activeId:p?.id??null,onSelect:C=>{n&&h(n,C)},onClose:C=>{n&&a(n,C)},onReorder:(C,Se)=>{n&&g(n,C,Se)},layoutMode:"scrollable",variant:"default"}):I?e.jsx("div",{ref:C=>{Y(C)},className:"flex min-w-0 flex-1 items-center px-1"}):H?e.jsx("div",{ref:C=>{E(C)},className:"flex min-w-0 flex-1 items-center overflow-hidden px-1"}):te?e.jsx("div",{ref:C=>{j(C)},className:"flex min-w-0 flex-1 items-center overflow-hidden px-1"}):fe||R?e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[p?ft(p,b):null,e.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:p?wt(p.mode,b):null}),e.jsx("span",{className:"min-w-0 flex-1"}),e.jsx("div",{ref:C=>{re(C)},className:"flex shrink-0 items-center gap-1"})]}):e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[p?ft(p,b):null,e.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:p?wt(p.mode,b):null})]}),e.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[D?e.jsx(me,{type:"button",variant:"ghost",size:"sm",onClick:N,className:"h-8 w-8 p-0",title:"Toggle file tree","aria-label":"Toggle file tree","aria-pressed":l,children:e.jsx(V,{name:"layout-right",className:"size-4"})}):null,e.jsx(me,{type:"button",variant:"ghost",size:"sm",onClick:ae,className:"h-8 w-8 p-0",title:k?"Collapse panel":"Expand panel","aria-label":k?"Collapse panel":"Expand panel",children:k?e.jsx(V,{name:"fullscreen-exit",className:"size-4"}):e.jsx(V,{name:"fullscreen",className:"size-4"})}),e.jsx(me,{type:"button",variant:"ghost",size:"sm",onClick:J,className:"h-8 w-8 p-0",title:"Close panel","aria-label":"Close panel",children:e.jsx(V,{name:"close",className:"size-4"})})]})]}),be=S?k?{"--oc-context-panel-width":O!==null?`${O}px`:"100%",width:O!==null?`${O}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${y}px`}:{"--oc-context-panel-width":`${y}px`,width:0,maxWidth:"100%",overflowX:"clip"};return e.jsxs("aside",{ref:he,"data-context-panel":"true",tabIndex:-1,inert:!S||void 0,className:le("flex min-h-0 flex-col overflow-hidden bg-background",k?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!S&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:xe,style:be,children:[S&&!k&&e.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),S&&e.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!k&&e.jsx("div",{className:le("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",X&&"bg-[var(--interactive-border)]"),onPointerDown:B,role:"separator","aria-orientation":"vertical","aria-label":"Resize context panel"}),e.jsxs("div",{className:le("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!S&&"pointer-events-none select-none opacity-0"),style:{width:k?O!==null?`${O}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!S,children:[we,e.jsxs("div",{className:le("relative min-h-0 flex-1 overflow-hidden",X&&"pointer-events-none"),children:[s?e.jsxs("div",{className:le("absolute inset-0 flex",D?"flex":"hidden"),children:[e.jsx("div",{className:"h-full min-w-0 flex-1",children:d?e.jsx(r.Suspense,{fallback:null,children:e.jsx(Ho,{mode:"editor-only",isVisible:S&&D})}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx(V,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),e.jsx("div",{className:"typography-ui-header text-foreground",children:"No file open"}),e.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:"Pick a file from the tree to start editing."})]})}),e.jsx(yo,{visible:l})]}):null,_.map(C=>e.jsx("div",{className:le("absolute inset-0",p?.id!==C.id&&"hidden"),children:e.jsx(lo,{initialUrl:C.targetPath??"",directory:n,tabID:C.id})},C.id)),S?L.filter(C=>p?.id===C.id).map(C=>e.jsx("div",{className:"absolute inset-0",children:e.jsx(r.Suspense,{fallback:null,children:e.jsx(Uo,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:C.diffScope??(C.stagedDiff?"staged":"working"),onDiffScopeChange:ve,targetFilePath:C.targetPath,flushContent:!0,toolbarSlot:te?Z:null})})},C.id)):null,A?e.jsx("div",{className:le("absolute inset-0",p?.mode==="terminal"?"block":"hidden"),children:e.jsx(bn,{visible:S&&p?.mode==="terminal",terminalHeaderSlot:I?K:null})}):null,S&&!D&&p?.mode!=="browser"&&p?.mode!=="diff"&&p?.mode!=="terminal"?w:null]})]})]})},sa=150,oa=500,aa=[],Oe=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),Ze=(t,n)=>{if(!t||typeof t!="object")return;const o=t[n];return typeof o=="number"&&Number.isFinite(o)?o:void 0},ia=t=>t>99?"99+":String(t),la=t=>t>=90?"text-[var(--status-error)]":t>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",ca=({surface:t,isActive:n,showActivityDot:o,label:i,description:a,badgeCount:m,badgeAriaLabel:x,badgeDescription:c,orderNumber:h,showOrderNumber:g,onSelect:v,chartPercentage:u,chartDetails:l})=>{const{attributes:N,listeners:f,setNodeRef:T,transform:p,transition:S,isDragging:k}=dn({id:t.id}),O=m!=null&&m>0?ia(m):null;return e.jsx("div",{ref:T,style:{transform:un.Translate.toString(p),transition:S},className:le("relative",k&&"z-10 opacity-70"),children:e.jsxs(We,{delayDuration:sa,children:[e.jsx(Fe,{asChild:!0,children:e.jsxs("button",{type:"button",...N,...f,onClick:()=>v(t),"aria-label":x??i,"aria-pressed":n,className:le("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",n?"text-primary":"text-muted-foreground hover:text-foreground"),children:[t.id==="context"&&typeof u=="number"?e.jsx(Ut,{percentage:u,className:"size-[18px] -rotate-90"}):e.jsx(V,{name:t.icon,className:"h-[18px] w-[18px]"}),g&&h!=null?e.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):O?e.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:O}):o?e.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null]})}),e.jsx(Be,{side:"left",sideOffset:8,className:t.id==="context"&&l?"p-0 border-0 bg-transparent shadow-none":void 0,children:t.id==="context"&&l?e.jsx("div",{className:"w-[300px] overflow-hidden rounded-lg border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_8px_24px_rgb(0_0_0_/_0.18)]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[e.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:e.jsx(Ut,{percentage:l.percentage,className:"size-[18px] -rotate-90"})}),e.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:l.hasData?e.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[e.jsxs("span",{className:le("font-semibold",la(l.percentage)),children:[l.percentage.toFixed(1),"%"]}),e.jsx("span",{className:"text-muted-foreground",children:`${Oe(l.totalTokens)}/${Oe(l.contextLimit)}`})]}):e.jsx("span",{className:"typography-micro text-muted-foreground",children:"No data yet"})})]}),l.hasData?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Used tokens"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.totalTokens)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Context limit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.contextLimit)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Output limit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.outputLimit)})]}),typeof l.cacheRead=="number"&&typeof l.cacheWrite=="number"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache read"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.cacheRead)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache write"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Oe(l.cacheWrite)})]})]}):null,typeof l.cacheHitPercent=="number"?e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache hit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:`${l.cacheHitPercent.toFixed(1)}%`})]}):null]}):e.jsx("div",{className:"px-2.5 py-2 typography-micro text-muted-foreground",children:a})]})}):e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{children:i}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),c?e.jsx("span",{className:"typography-micro text-muted-foreground",children:c}):null]})})]})})},da=()=>{const t=Je(),n=t?or(t):"",o=ne(w=>n?w.contextPanelByDirectory[n]:void 0),i=ne(w=>w.contextRailOrder),a=ne(w=>w.setContextRailOrder),m=ne(w=>w.openContextSurface),x=ne(w=>w.shortcutOverrides),{screenWidth:c}=at(),{git:h,github:g}=vt(),v=Sn(n||null),u=Cn(n||null),l=Nn(w=>w.ensureStatus),N=zt(w=>w.ensureScope);r.useEffect(()=>{n&&l(n,h)},[n,l,h]),r.useEffect(()=>{!n||!g||N(n,g)},[n,N,g]);const f=r.useMemo(()=>ar("switch_context_surface",x),[x]),[T,p]=r.useState(!1);r.useEffect(()=>{const w=new Set;let _=null,L=!1;const A=H=>H.length===1&&H>="0"&&H<="9",s=()=>{Lt(f,w)?!L&&_===null&&(_=setTimeout(()=>p(!0),oa)):(L=!1,_!==null&&(clearTimeout(_),_=null),p(!1))},d=H=>{if(w.add(H.key.toLowerCase()),A(H.key)&&Lt(f,w)){L=!0,_!==null&&(clearTimeout(_),_=null),p(!1);return}s()},D=H=>{w.delete(H.key.toLowerCase()),s()},I=()=>{w.clear(),L=!1,_!==null&&(clearTimeout(_),_=null),p(!1)};return window.addEventListener("keydown",d,!0),window.addEventListener("keyup",D,!0),window.addEventListener("blur",I),()=>{window.removeEventListener("keydown",d,!0),window.removeEventListener("keyup",D,!0),window.removeEventListener("blur",I),_!==null&&clearTimeout(_)}},[f]);const S=on(mt(Gn,{activationConstraint:{distance:8}}),mt(qn,{activationConstraint:{delay:200,tolerance:6}})),k=o?.tabs??aa,O=k.find(w=>w.id===o?.activeTabId)??null,oe=o?.isOpen?O?.mode??null:null,z=v?.files.length??0,G=Ce(w=>w.currentSessionId),Q=Ce(w=>!!w.newSessionDraft?.open),y=$e(w=>w.providers),b=$e(w=>w.currentProviderId),X=$e(w=>w.currentModelId),q=$e(w=>w.getCurrentModel()),K=$e(w=>w.getModelMetadata);$e(w=>w.modelsMetadata.size);const Y=es(r.useCallback(w=>G?w.sessionModelSelections.get(G)??null:null,[G])),ee=jn(G??""),E=r.useMemo(()=>{for(let w=ee.length-1;w>=0;w-=1){const _=ee[w];if(_?.info.role==="assistant")try{if(gt(_).total>0)return _}catch{continue}}return null},[ee]),j=r.useMemo(()=>{for(let w=ee.length-1;w>=0;w-=1){const _=ee[w]?.info;if(_.role!=="user")continue;const L=_.model,A=L?.providerID??L?.providerId,s=L?.modelID??L?.modelId;if(typeof A=="string"&&A.trim()&&typeof s=="string"&&s.trim())return{providerID:A,modelID:s}}return null},[ee])??(()=>{const w=E?.info.model,_=w?.providerID??w?.providerId,L=w?.modelID??w?.modelId;return _&&L?{providerID:_,modelID:L}:null})()??(Y?{providerID:Y.providerId,modelID:Y.modelId}:null)??(b&&X?{providerID:b,modelID:X}:null),re=(j?y.find(w=>w.id===j.providerID):void 0)?.models.find(w=>w.id===j?.modelID),$=j?K(j.providerID,j.modelID):void 0,F=Ze(re?.limit,"context")??$?.limit?.context??Ze(q?.limit,"context")??0,ie=Ze(re?.limit,"output")??$?.limit?.output??Ze(q?.limit,"output")??0,ce=E?(()=>{try{return gt(E)}catch{return null}})():null,he=E?.info?.usage,ge=he?yn(he):ce?.total??0,pe=!Q&&ge>0&&F>0?Math.min(ge/F*100,999):0,de=pe,ue=ce?wn({input:ce.input,cache:{read:ce.cacheRead,write:ce.cacheWrite}}):null,M=ue?.hasInput?ue.percent:null,B=r.useMemo(()=>{const w=!!E&&ge>0&&F>0;return{percentage:pe,totalTokens:ge,contextLimit:F,outputLimit:ie,cacheRead:ce?.cacheRead??null,cacheWrite:ce?.cacheWrite??null,cacheHitPercent:M,hasData:w}},[ce,M,F,E,ie,pe,ge]),U=ts(w=>G?w.reducer.bySession.get(G)?.extensionWidgets:void 0,(w,_)=>w===_,G?`session:${G}`:"chrome"),J=r.useMemo(()=>U?.size?[...U.entries()].map(([w,_])=>`${w}:${_.lines.join(`
|
|
136
|
-
`)}`).join(";"):"",[U]),ae=J!=="",xe=r.useRef({});r.useEffect(()=>{oe==="extensions"&&G&&J&&(xe.current[G]=J)},[oe,G,J]);const ve=G?xe.current[G]??"":"",ye=oe!=="extensions"&&J!==""&&ve!==J,P=zt(w=>n?w.entriesByDirectory[n]??null:null),se=r.useMemo(()=>{if(!P)return{isLoading:!0,hasResult:!1,hasGitHubRepo:!1,hasError:!1};const w=P.scope?.repositories??[];return{isLoading:P.isLoading,hasResult:!!(P.scope||P.error),hasGitHubRepo:w.some(_=>!!(_.host&&_.owner&&_.repo&&!_.disabledReason)),hasError:!!(P.error&&!P.scope)}},[P]),fe=r.useMemo(()=>ns({railOrder:i,tabs:k,githubScope:se,hasExtensionContent:ae}),[i,c,k,se,ae]),R=r.useCallback(w=>{const{active:_,over:L}=w;if(!L||_.id===L.id)return;const A=rs(ne.getState().contextRailOrder).map(D=>D.id),s=A.indexOf(_.id),d=A.indexOf(L.id);s===-1||d===-1||a(Yn(A,s,d))},[a]);return n?e.jsx("nav",{"aria-label":"Panel surfaces",className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:e.jsx(an,{sensors:S,collisionDetection:ln,onDragEnd:R,children:e.jsx(cn,{items:fe.map(w=>w.id),strategy:Jn,children:fe.map((w,_)=>{const L=w.id==="git"?Pt(u):null,A=L?{...w,...L}:w,s=A.label,d=w.id==="git"&&u===!0?z:0,D=d>0?d:null,I=w.id==="context",H=w.id==="extensions"?ye:!1;return e.jsx(ca,{surface:A,isActive:oe===w.mode,showActivityDot:H,label:s,description:A.description,badgeCount:D,badgeAriaLabel:D!==null?D===1?`${s}, ${D} changed file`:`${s}, ${D} changed files`:null,badgeDescription:D!==null?D===1?`${D} changed file`:`${D} changed files`:null,chartPercentage:I?de:void 0,chartDetails:I?B:void 0,orderNumber:_+1,showOrderNumber:T,onSelect:te=>m(n,te.mode)},w.id)})})})}):null},ua=(t,n)=>!t||n.length===0?"":JSON.stringify([t,n]),ha=(t,n,o,i)=>!o||i!==o||t.length===0?[]:Xe(t,n,a=>a.name,{limit:10,threshold:.4}),fa=new Set,pt=t=>{if(!t)return"";const n=t.replace(/\\/g,"/"),o=n.startsWith("//");let i=n.replace(/\/+/g,"/");o&&!i.startsWith("//")&&(i=`/${i}`);const a=i==="/",m=/^[A-Za-z]:\/$/.test(i);return!a&&!m&&(i=i.replace(/\/+$/,"")),i},pa=()=>{const t=ne(s=>s.isCommandPaletteOpen),n=ne(s=>s.setCommandPaletteOpen),o=ne(s=>s.setActiveMainTab),i=ne(s=>s.setSettingsDialogOpen),a=ne(s=>s.setSettingsPage),m=ne(s=>s.setSessionSwitcherOpen),x=ne(s=>s.toggleSidebar),c=ne(s=>s.openContextOverview),h=ne(s=>s.openContextSurface),g=ne(s=>s.openContextFile),v=ne(s=>s.shortcutOverrides),u=Ce(s=>s.openNewSessionDraft),l=Ce(s=>s.setCurrentSession),N=ss({archived:!1}),f=os(r.useCallback(s=>t?s.ids:fa,[t])),T=as(r.useCallback(s=>t?s.rankById:is,[t])),p=ir(s=>s.currentDirectory),S=Ht(s=>s.getActiveProject()),k=Ht(s=>s.projects),O=Je(),oe=lr(s=>s.searchFiles),{files:z,git:G}=vt(),Q=Nn(s=>s.ensureStatus),{isMobile:y}=at(),b=r.useMemo(()=>O?pt(O):null,[O]),[X,q]=r.useState(""),Y=ls(X,200).trim(),ee=X.trim();r.useEffect(()=>{t&&q("")},[t]),r.useEffect(()=>{if(!t||!G)return;const s=setTimeout(()=>{const d=new Set;for(const D of N){const I=lt(D);!I||d.has(I)||(d.add(I),Q(I,G))}},0);return()=>clearTimeout(s)},[t,N,G,Q]);const E=r.useCallback(()=>n(!1),[n]),Z=r.useCallback(s=>()=>{E(),s()},[E]),j=r.useMemo(()=>{const s=[{id:"new-session",title:"New Session",icon:e.jsx(V,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:"New Session",onSelect:Z(()=>{o("chat"),m(!1),u()})},{id:"add-project",title:"Add Project",icon:e.jsx(V,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:"Add Project",onSelect:Z(()=>{cs.requestDirectoryDialog()})},{id:"toggle-sidebar",title:y?"Show Session Switcher":"Toggle Sidebar",icon:e.jsx(V,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:y?"Show Session Switcher":"Toggle Sidebar",onSelect:Z(()=>{if(y){const{isSessionSwitcherOpen:d}=ne.getState();m(!d)}else x()})},{id:"toggle-terminal",title:"Toggle Terminal",icon:e.jsx(V,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:"Toggle Terminal",onSelect:Z(()=>{p&&h(p,"terminal")})},{id:"context-usage",title:"Show Context Usage",icon:e.jsx(V,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:"Show Context Usage",onSelect:Z(()=>{p&&c(p)})},{id:"open-settings",title:"Open Settings...",icon:e.jsx(V,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:"Open Settings...",onSelect:Z(()=>i(!0))}];return cr()&&s.splice(1,0,{id:"new-mini-chat",title:"New Mini Chat Window",icon:e.jsx(V,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:"New Mini Chat Window",onSelect:Z(()=>{hn("desktop_open_draft_mini_chat_window",{directory:pt(p||S?.path||""),projectId:S?.id??null}).catch(d=>{console.warn("[command-palette] failed to open draft mini chat window",d)})})}),s},[Z,y,o,m,u,x,h,p,c,i,S?.id,S?.path]),W=r.useMemo(()=>{const s=dr();return{isWeb:!s&&ur(),isDesktop:s,isMobile:y}},[y]),re=r.useMemo(()=>kr.filter(s=>s.slug!=="home").filter(s=>s.isAvailable?s.isAvailable(W):!0).map(s=>{const d=Pr(s.slug)??"settings-3",D=(s.keywords??[]).join(" ");return{id:`settings:${s.slug}`,title:s.title,icon:e.jsx(V,{name:d,className:"mr-2 h-4 w-4"}),searchText:`${s.title} ${s.group} ${D}`,onSelect:Z(()=>{a(s.slug),i(!0)})}}),[W,Z,a,i]),$=r.useMemo(()=>ds(N,f,T),[N,f,T]),F=us(),ie=r.useCallback((s,d)=>d&&F.get(d)?.trim()||null,[F]),[ce,he]=r.useState([]),[ge,pe]=r.useState(""),de=ua(b,Y);r.useEffect(()=>{if(!t){he([]),pe("");return}if(!de){he([]),pe("");return}if(!b){he([]),pe("");return}let s=!1;return oe(b,Y,10,{type:"file"}).then(d=>{s||(he(d.map(D=>({path:pt(D.path),name:D.name,relativePath:D.relativePath}))),pe(de))}).catch(()=>{s||(he([]),pe(de))}),()=>{s=!0}},[t,b,Y,de,oe]);const ue=ee.length>0,M=r.useMemo(()=>ue?Xe(j,ee,s=>s.searchText,{limit:7,noFuzzy:!0}):j.map(s=>({item:s,score:0})),[j,ee,ue]),B=r.useMemo(()=>ue?Xe(re,ee,s=>s.searchText,{limit:7,noFuzzy:!0}):[],[re,ee,ue]),U=r.useMemo(()=>ue?Xe($,ee,s=>s.title||"",{limit:7,threshold:.2}):$.slice(0,5).map(s=>({item:s,score:0})),[$,ee,ue]),J=r.useMemo(()=>t?ha(ce,Y,de,ge):[],[t,ce,ge,de,Y]),ae=t&&de.length>0&&ge!==de,xe=r.useMemo(()=>{if(!ue)return[];const s=k.map(d=>({...d,displayName:d.label||d.path.split("/").pop()||d.path,searchText:`${d.label||""} ${d.path}`}));return Xe(s,ee,d=>d.searchText,{limit:7,threshold:.4})},[k,ee,ue]),ve=M.map(s=>s.item),ye=B.map(s=>s.item),P=U.map(s=>s.item),se=ue?J.map(s=>s.item):[],fe=ue?xe.map(s=>s.item):[],R=r.useMemo(()=>{if(!ue)return["commands","sessions"];const s=D=>D.length?D[0].score:1/0,d=[{key:"commands",score:s(M)},{key:"settings",score:s(B)},{key:"sessions",score:s(U)},{key:"files",score:s(J)},{key:"projects",score:s(xe)}];return d.sort((D,I)=>D.score-I.score),d.map(D=>D.key)},[ue,M,B,U,J,xe]),w=r.useCallback(s=>{E(),l(s.id,lt(s))},[E,l]),_=r.useCallback(async s=>{if(!b)return;const d=await kn(z,s,{directory:b});if(!d.ok){je.error(Pn(d.reason));return}g(b,s),E()},[b,z,g,E]),L=r.useCallback((s,d)=>{E(),u({selectedProjectId:s,directoryOverride:d})},[E,u]),A=r.useCallback(s=>mn(gn(s,v)),[v]);return e.jsxs(St,{open:t,onOpenChange:n,children:[e.jsxs(Ct,{className:"sr-only",children:[e.jsx(Nt,{children:"Command Palette"}),e.jsx(kt,{children:"Search files, sessions, and commands."})]}),e.jsx(jt,{className:"overflow-hidden p-0",showCloseButton:!0,children:e.jsxs(hs,{shouldFilter:!1,className:"[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta",children:[e.jsx(fs,{value:X,onValueChange:q,placeholder:"Search files, sessions, commands..."}),e.jsxs(ps,{children:[e.jsx(ms,{children:"No results found."}),R.map(s=>s==="commands"&&ve.length>0?e.jsx(Ve,{children:ve.map(d=>e.jsxs(Ke,{value:d.id,onSelect:d.onSelect,children:[d.icon,e.jsx("span",{children:d.title}),d.shortcutId?e.jsx(gs,{children:A(d.shortcutId)}):null]},d.id))},"commands"):s==="settings"&&ye.length>0?e.jsx(Ve,{children:ye.map(d=>e.jsxs(Ke,{value:d.id,onSelect:d.onSelect,children:[d.icon,e.jsx("span",{children:d.title})]},d.id))},"settings"):s==="sessions"&&P.length>0?e.jsx(Ve,{children:P.map(d=>{const D=En(d),I=lt(d),H=ie(d.id,I);return e.jsxs(Ke,{value:`session:${d.id}`,onSelect:()=>w(d),children:[e.jsx(V,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"truncate",children:D}),H?e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[e.jsx(V,{name:"git-branch",className:"h-3 w-3"}),e.jsx("span",{className:"truncate max-w-[160px]",children:H})]}):null]},d.id)})},"sessions"):s==="files"&&se.length>0?e.jsx(Ve,{children:se.map(d=>{const D=hr(d.relativePath||d.name,{maxLength:80});return e.jsxs(Ke,{value:`file:${d.path}`,onSelect:()=>{_(d.path)},children:[e.jsx(yt,{filePath:d.path,className:"mr-2 size-4 shrink-0"}),e.jsx("span",{className:"truncate","aria-label":d.relativePath,children:D})]},`file:${d.path}`)})},"files"):s==="projects"&&fe.length>0?e.jsx(Ve,{children:fe.map(d=>{const D=d.displayName;return e.jsxs(Ke,{value:`project:${d.id}`,onSelect:()=>L(d.id,d.path),children:[e.jsx(V,{name:"folder",className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"truncate",children:D}),e.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:d.path})]},`project:${d.id}`)})},"projects"):null),ae?e.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:"Searching files..."}):null]})]})})]})},ma=(t,n,o)=>pr(t)?mn(gn(t,o)):n,ga=()=>{const t=ne(m=>m.isHelpDialogOpen),n=ne(m=>m.setHelpDialogOpen),o=ne(m=>m.shortcutOverrides),i=fr(),a=[{categoryKey:"Navigation & Commands",items:[{id:"open_command_palette",descriptionKey:"Open Command Palette",icon:"command",keys:""},{id:"open_help",descriptionKey:"Show Keyboard Shortcuts (this dialog)",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"Toggle Session Sidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"Add Selection to Chat",icon:"add",keys:""},{id:"open_model_selector",descriptionKey:"Open Model Selector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"Navigate Models (in picker)",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"Adjust Thinking Mode (in picker, when supported)",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"Cycle thinking (global shortcut)",icon:"brain-ai-3",keys:""},{keys:[`Shift + Alt + ${i} + N`],descriptionKey:"New Window (desktop only)",icon:"window"}]},{categoryKey:"Session Management",items:[{id:"new_chat",descriptionKey:"Create New Session",icon:"add",keys:""},{id:"focus_input",descriptionKey:"Focus Chat Input",icon:"text",keys:""},{id:"cycle_session_folder",descriptionKey:"Cycle session folder",icon:"folder-open",keys:""},{id:"cycle_draft_folder",descriptionKey:"Cycle draft folder",icon:"folder-3",keys:""},{id:"open_timeline_dialog",descriptionKey:"Open conversation timeline",icon:"history",keys:""},{id:"abort_run",descriptionKey:"Abort active run (double press)",icon:"close-circle",keys:""}]},{categoryKey:"Panels",items:[{id:"open_right_sidebar",descriptionKey:"Open right sidebar",icon:"layout-right",keys:""},{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{keys:[`${i} + 1...0`],descriptionKey:"Switch Context Panel Surface (number key)",icon:"layout-right"}]},{categoryKey:"Interface",items:[{id:"cycle_theme",descriptionKey:"Cycle Theme (Light → Dark → System)",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"Open Settings",icon:"settings-3",keys:""}]}];return e.jsx(St,{open:t,onOpenChange:n,children:e.jsxs(jt,{className:"w-[92vw] max-w-[1120px] h-[84vh] max-h-[900px] flex flex-col overflow-hidden",children:[e.jsxs(Ct,{children:[e.jsxs(Nt,{className:"flex items-center gap-2",children:[e.jsx(V,{name:"command",className:"h-5 w-5"}),"Keyboard Shortcuts"]}),e.jsx(kt,{children:"Use these keyboard shortcuts to navigate PiChamber efficiently"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto mt-3 pr-1",children:e.jsx("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-x-10",children:a.map(m=>e.jsxs("div",{className:"min-w-0 break-inside-avoid",children:[e.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:m.categoryKey}),e.jsx("div",{className:"space-y-1",children:m.items.map(x=>{const c=x.id?ma(x.id,Array.isArray(x.keys)?x.keys[0]:x.keys,o):Array.isArray(x.keys)?x.keys:x.keys.split(" / ");return e.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[x.icon&&e.jsx(V,{name:x.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"typography-meta",children:x.descriptionKey})]}),e.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(c)?c:[c]).map((h,g)=>e.jsxs(r.Fragment,{children:[g>0&&e.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:"or"}),e.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:h})]},`${h}-${g}`))})]},x.id||x.descriptionKey)})})]},m.categoryKey))})})]})})},xa=r.createContext(null),wa=({children:t,value:n})=>e.jsx(xa.Provider,{value:n,children:t}),sn=_e(()=>Ee(()=>import("./GitView-XBBheKRM.js"),__vite__mapDeps([78,6,1,2,3,10,4,5,7,8,9,11,12,45,46,47,48,49,13,79,80,81,82,44,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,14,42,43,50,51])).then(t=>({default:t.GitView}))),ya=_e(()=>Ee(()=>import("./DiffView-BxwoRCYx.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52])).then(t=>({default:t.DiffView}))),ba=_e(()=>Ee(()=>import("./FilesView-D_2QcdUt.js"),__vite__mapDeps([53,1,2,3,4,5,6,7,8,9,10,11,12,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,50,51,33,34,18,19,20,21,22,23,24,25,26,27,28,29,30,31,70,71,45,46,47,48,49,72,73,15,16,17,32,35,36,37,38,39,40,41,74,75,76,77])).then(t=>({default:t.FilesView}))),va=_e(()=>Ee(()=>import("./DiagramView-BpG1c3Hi.js"),__vite__mapDeps([88,1,2,3,10,4,5,6,7,8,9,11,12,70,71])).then(t=>({default:t.DiagramView}))),Sa=_e(()=>Ee(()=>import("./SettingsView-BiwlwnTK.js").then(t=>t.a),__vite__mapDeps([89,1,2,3,4,5,6,7,8,9,10,11,12,45,46,47,48,49,90,91,81,82])).then(t=>({default:t.SettingsView}))),ja=_e(()=>Ee(()=>import("./SettingsWindow-j0e99YI0.js"),__vite__mapDeps([92,1,2,3,4,5,6,7,8,9,10,11,12,89,45,46,47,48,49,90,91,81,82])).then(t=>({default:t.SettingsWindow}))),Ca=()=>{const t=ne(j=>j.isSidebarOpen),n=ne(j=>j.activeMainTab),o=ne(j=>j.setIsMobile),i=ne(j=>j.isSessionSwitcherOpen),a=ne(j=>j.isSettingsDialogOpen),m=ne(j=>j.setSettingsDialogOpen),[x,c]=r.useState(!1);r.useEffect(()=>{a&&c(!0)},[a]),r.useEffect(()=>{const j=()=>ne.getState().closeMainSurfaces(),W=Ce.subscribe(($,F)=>{const ie=!!$.currentSessionId&&$.currentSessionId!==F.currentSessionId,ce=!!$.newSessionDraft?.open&&$.newSessionDraft!==F.newSessionDraft;(ie||ce)&&j()}),re=ne.subscribe(($,F)=>{$.activeMainTab!==F.activeMainTab&&j()});return()=>{W(),re()}},[]);const{isMobile:h}=at(),g=r.useRef(!1),[v,u]=r.useState(!1),[l,N]=r.useState(!1),[f,T]=r.useState(!1),[p,S]=r.useState(!1),k=r.useCallback(j=>{u(j),ne.getState().setSessionSwitcherOpen(j)},[]),O=r.useRef(typeof window>"u"?0:window.innerWidth),oe=r.useRef(null),z=r.useRef(!1),G=r.useRef(!1),Q=r.useRef(!1),y=r.useRef(null),b=r.useRef(null),X=Mt(-O.current),q=Ne.useRef(0),K=Mt(O.current),Y=Ne.useRef(0);Ne.useEffect(()=>{h&&(q.current=window.innerWidth,Y.current=window.innerWidth)},[h]),Ne.useEffect(()=>{if(!h)return;const j=()=>{const W=window.innerWidth;q.current=W,Y.current=W,v||X.get()<-10&&X.set(-W),l||K.get()>10&&K.set(W)};return window.addEventListener("resize",j),window.addEventListener("orientationchange",j),()=>{window.removeEventListener("resize",j),window.removeEventListener("orientationchange",j)}},[h,X,K,v,l]),Ne.useEffect(()=>{if(!h){T(!1);return}v&&T(!0);const j=q.current||O.current||(typeof window<"u"?window.innerWidth:0),W=Qe(X,v?0:-j,{type:"spring",stiffness:400,damping:35,mass:.8});return y.current=W,()=>W.stop()},[v,h,X]),Ne.useEffect(()=>{if(!h){S(!1);return}l&&S(!0);const j=Y.current||O.current||(typeof window<"u"?window.innerWidth:0),W=Qe(K,l?0:j,{type:"spring",stiffness:400,damping:35,mass:.8});return b.current=W,()=>W.stop()},[h,l,K]),Ne.useEffect(()=>{if(h)return X.on("change",j=>{const W=q.current||O.current,re=v||j>-W+.5;T($=>$===re?$:re)})},[h,X,v]),Ne.useEffect(()=>{if(h)return K.on("change",j=>{const W=Y.current||O.current,re=l||j<W-.5;S($=>$===re?$:re)})},[h,l,K]),Ne.useEffect(()=>{h&&!i&&v&&k(!1)},[i,h,v,k]),Ne.useEffect(()=>{if(!h){g.current=!1;return}g.current||(g.current=!0,k(!1),N(!1))},[h,k]),Ne.useEffect(()=>{if(!h||n!=="chat"||v||l||a)return;let j=!1,W;return($=>{W=window.setTimeout(()=>{if(j)return;const F=Ce.getState(),ie=ne.getState();ie.activeMainTab!=="chat"||ie.isSettingsDialogOpen||F.currentSessionId||F.newSessionDraft?.open||F.openNewSessionDraft({automatic:!0})},$)})(500),()=>{j=!0,W!==void 0&&window.clearTimeout(W)}},[n,h,a,v,l]),Ne.useEffect(()=>{!h||!a||(k(!1),N(!1))},[h,a,k]),r.useEffect(()=>{ne.getState().isMobile!==h&&o(h)},[h,o]);const ee=r.useCallback(()=>{v&&k(!1),N(!l)},[v,l,k]);Rr(oe,{enabled:h,leftOpen:v,rightOpen:l,leftWidth:()=>q.current||O.current||(typeof window<"u"?window.innerWidth:0),rightWidth:()=>Y.current||O.current||(typeof window<"u"?window.innerWidth:0),onLeftProgress:j=>{const W=q.current||O.current||(typeof window<"u"?window.innerWidth:0);X.set(W*(j-1))},onRightProgress:j=>{const W=Y.current||O.current||(typeof window<"u"?window.innerWidth:0);K.set(W*(1-j))},onLeftOpen:()=>{l&&N(!1),k(!0)},onLeftClose:()=>k(!1),onRightOpen:()=>{v&&k(!1),N(!0)},onRightClose:()=>N(!1),onDragStart:j=>{z.current=!0,j==="left"?(G.current=v,y.current?.stop(),f||T(!0)):(Q.current=l,b.current?.stop(),p||S(!0))},onDragEnd:(j,W)=>{if(z.current=!1,j==="left"&&typeof W=="boolean"){const re=G.current;if(W===re){const $=q.current||O.current||(typeof window<"u"?window.innerWidth:0),F=Qe(X,re?0:-$,{type:"spring",stiffness:400,damping:35,mass:.8});y.current=F}}if(j==="right"&&typeof W=="boolean"){const re=Q.current;if(W===re){const $=Y.current||O.current||(typeof window<"u"?window.innerWidth:0),F=Qe(K,re?0:$,{type:"spring",stiffness:400,damping:35,mass:.8});b.current=F}}}});const E=r.useMemo(()=>{if(!h&&n!=="terminal"&&n!=="diagram"||h&&n==="git"&&(l||p))return null;switch(n){case"git":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(sn,{isActive:!0})});case"diff":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(ya,{})});case"terminal":return e.jsx(bn,{onCloseView:()=>ne.getState().setActiveMainTab("chat")});case"files":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(ba,{})});case"diagram":return e.jsx(r.Suspense,{fallback:null,children:e.jsx(va,{})});default:return null}},[n,h,p,l]),Z=n==="chat";return e.jsxs(Er,{children:[e.jsx(Tr,{}),e.jsxs("div",{"data-page-scroll-lock":"true",className:le("main-content-safe-area",h?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[e.jsx(pa,{}),e.jsx(ga,{}),e.jsx(_r,{}),h?e.jsxs(wa,{value:{leftDrawerOpen:v,rightDrawerOpen:l,toggleLeftDrawer:()=>{const j=!v;l&&N(!1),k(j)},toggleRightDrawer:ee,leftDrawerX:X,rightDrawerX:K,leftDrawerWidth:q,rightDrawerWidth:Y,setMobileLeftDrawerOpen:k,setRightSidebarOpen:N},children:[!a&&e.jsx(Ot,{onToggleLeftDrawer:()=>{const j=!v;l&&N(!1),k(j)},onToggleRightDrawer:()=>{ee()},leftDrawerOpen:v,rightDrawerOpen:l}),e.jsx("div",{"data-page-scroll-lock":"true",className:le("flex flex-1 overflow-hidden relative",a&&"hidden"),children:e.jsxs("main",{ref:oe,className:"w-full h-full overflow-hidden bg-background relative","data-page-scroll-lock":"true",style:{touchAction:"pan-x pan-y"},children:[e.jsx("div",{className:le("absolute inset-0",!Z&&"invisible"),children:e.jsx(Pe,{children:e.jsx($t,{active:Z&&!a})})}),E&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(Pe,{children:E})}),e.jsx(Pe,{children:e.jsx(Wt,{})}),e.jsx(It.div,{className:le("absolute inset-0 z-20 bg-sidebar",!f&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:X},"aria-hidden":!v,children:e.jsx(Pe,{children:e.jsx(Ft,{mobileVariant:!0,isVisible:f})})}),e.jsx(It.div,{className:le("absolute inset-0 z-20 bg-sidebar",!p&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:K},"aria-hidden":!l,children:e.jsx(Pe,{children:l||p?e.jsx(r.Suspense,{fallback:null,children:e.jsx(sn,{isActive:l})}):null})})]})}),a&&e.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:e.jsx(Pe,{children:e.jsx(r.Suspense,{fallback:null,children:e.jsx(Sa,{onClose:()=>m(!1)})})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ar,{}),e.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[e.jsx(Ws,{isOpen:t,isMobile:h,children:e.jsx(Ft,{isVisible:t})}),e.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[e.jsx(Ot,{}),e.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[e.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:e.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:e.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[e.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[e.jsx("div",{className:le("absolute inset-0",!Z&&"invisible"),children:e.jsx(Pe,{children:e.jsx($t,{active:Z&&!a})})}),E&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(Pe,{children:E})}),e.jsx(Pe,{children:e.jsx(Wt,{})})]}),e.jsx(ra,{})]})})}),e.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:e.jsx(Pe,{children:e.jsx(da,{})})})]})]})]}),x?e.jsx(r.Suspense,{fallback:null,children:e.jsx(ja,{open:a,onOpenChange:m})}):null]})]})]})},Na=()=>(Ss(),Ir(),e.jsxs(Lr,{children:[e.jsx(js,{embeddedBackgroundWorkEnabled:!0}),e.jsx(Cs,{}),e.jsx(Ca,{}),e.jsx(Or,{}),e.jsx(Ns,{}),e.jsx(ks,{})]}));function ka({apis:t}){const n=t??xn(),[o,i]=r.useState(0);return r.useEffect(()=>mr(a=>{if(a.runtimeKey===a.previousRuntimeKey){gr();return}Dr(a),i(m=>m+1)}),[]),r.useEffect(()=>{let a=!0,m=null,x=null,c=null;return xr().then(()=>{a&&(m=xs(),x=ws(),c=Mr())}),()=>{a=!1,m?.(),x?.(),c?.()}},[o]),r.useEffect(()=>{n&&wr(n)},[n]),n?e.jsx(Pe,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground",children:e.jsx(ys,{apis:n,children:e.jsx(bs,{children:e.jsx(vs,{children:e.jsx(Na,{})})},o)})})}):e.jsx(Pe,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground"})})}const Un=document.getElementById("root");if(!Un)throw new Error("Root element not found");Qn.createRoot(Un).render(e.jsx(Ne.StrictMode,{children:e.jsx(Ps,{children:e.jsx(Rs,{children:e.jsx(ka,{apis:xn()??void 0})})})}));
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-CQ9tWYIj.js","assets/vendor-boot-Dgb9NVFe.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js","assets/index-BnZVqcki.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BnieExes.css","assets/pi-session-focus-preference-Bmk1iOvn.js","assets/useAppFontEffects-DviRbaCJ.js","assets/runtimeSurface-DBiUWYK2.js","assets/nativeFileSave-BzhtrDoD.js","assets/runtimeEndpointReset-CtK4C_5h.js","assets/SessionUnreadDot-CmEF9sxM.js","assets/permissionStore-B9Hkrqny.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/vendor-xterm-xterm-css-DDGTF8rc.css","assets/vendor-aparajita-capacitor-secure-storage-BYohCVY0.js","assets/SettingsView-BiwlwnTK.js","assets/vendor-qrcode-Dv4uniC1.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/collapsible-C7oyikVm.js","assets/vendor-base-ui-BscvGUFt.js","assets/useSwitcherItems-Dej8BzXI.js","assets/vendor-katex-css-Cp579UoJ.css","assets/main-9O5IAtT_.js","assets/contextFileOpenGuard-BBzqKGei.js","assets/useFilesViewSearch-D2Au5Xgt.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as a}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as m,g as f}from"./index-BnZVqcki.js";import{r as w}from"./runtimeSurface-DBiUWYK2.js";/* empty css */import"./vendor-zustand-CUi8eEds.js";import"./vendor-react-DASdDPIk.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";function _(t={}){const{immediate:r=!1,onNeedRefresh:i,onOfflineReady:n,onRegistered:s,onRegisteredSW:c,onRegisterError:d}=t;let o,u;const l=async(e=!0)=>{await u};async function p(){if("serviceWorker"in navigator){if(o=await a(async()=>{const{Workbox:e}=await import("./vendor-workbox-window-BIl4cyR9.js");return{Workbox:e}},[]).then(({Workbox:e})=>new e("/sw.js",{scope:"/",type:"classic"})).catch(e=>{d?.(e)}),!o)return;o.addEventListener("activated",e=>{(e.isUpdate||e.isExternal)&&window.location.reload()}),o.addEventListener("installed",e=>{e.isUpdate||n?.()}),o.register({immediate:r}).then(e=>{c?c("/sw.js",e):s?.(e)}).catch(e=>{d?.(e)})}}return u=p(),l}const v=w(),g=()=>!(!("serviceWorker"in navigator)||!window.isSecureContext||window.location.protocol!=="http:"&&window.location.protocol!=="https:"||document.prerendering||String(document.visibilityState)==="prerender"),S=t=>{let r=!1;const i=()=>{r||g()&&(r=!0,t())},n=()=>{setTimeout(i,0)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0}),(document.prerendering||String(document.visibilityState)==="prerender")&&document.addEventListener("visibilitychange",i,{once:!0})},E=()=>{S(()=>{try{_({onRegisterError(t){console.warn("[PWA] service worker registration skipped:",t)}})}catch(t){console.warn("[PWA] service worker registration skipped:",t)}})},R=async()=>{if(window.__PICHAMBER_RUNTIME_APIS__=m(),v==="mobile"){const{renderMobileApp:t}=await a(async()=>{const{renderMobileApp:r}=await import("./renderMobileApp-CQ9tWYIj.js").then(i=>i.r);return{renderMobileApp:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]));t();return}await f(),await a(()=>import("./main-9O5IAtT_.js"),__vite__mapDeps([27,1,2,3,4,5,6,7,8,9,14,11,12,13,15,16,17,18,28,29,26]))};R();E();
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-CQ9tWYIj.js","assets/vendor-boot-Dgb9NVFe.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js","assets/index-BnZVqcki.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BnieExes.css","assets/pi-session-focus-preference-Bmk1iOvn.js","assets/useAppFontEffects-DviRbaCJ.js","assets/runtimeSurface-DBiUWYK2.js","assets/nativeFileSave-BzhtrDoD.js","assets/runtimeEndpointReset-CtK4C_5h.js","assets/SessionUnreadDot-CmEF9sxM.js","assets/permissionStore-B9Hkrqny.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/vendor-xterm-xterm-css-DDGTF8rc.css","assets/vendor-aparajita-capacitor-secure-storage-BYohCVY0.js","assets/SettingsView-BiwlwnTK.js","assets/vendor-qrcode-Dv4uniC1.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/collapsible-C7oyikVm.js","assets/vendor-base-ui-BscvGUFt.js","assets/useSwitcherItems-Dej8BzXI.js","assets/vendor-katex-css-Cp579UoJ.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as t}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as i}from"./index-BnZVqcki.js";/* empty css */import"./vendor-zustand-CUi8eEds.js";import"./vendor-react-DASdDPIk.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";window.__PICHAMBER_RUNTIME_APIS__=i();t(async()=>{const{renderMobileApp:r}=await import("./renderMobileApp-CQ9tWYIj.js").then(o=>o.r);return{renderMobileApp:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])).then(({renderMobileApp:r})=>{r()});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-BjdQVib9.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-boot-Dgb9NVFe.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{h as R,bY as b,bZ as k,g as _,ae as W,b_ as z,bH as J,b$ as K,c0 as Z,a as q,c1 as Q,c2 as E,c3 as X,c4 as ee}from"./useAppFontEffects-DviRbaCJ.js";import{aG as te,u as A,aH as se,a as oe,w as P,aI as ne,m as re,aJ as ie,T as Y,i as L,b as ae,C as F}from"./index-BnZVqcki.js";import{_ as le}from"./vendor-vite-runtime-DD1OZmLC.js";import{R as ce}from"./vendor-react-DASdDPIk.js";const de=[];function G(){return[...de].reverse()}const ge={getLastAssistantMessage(){if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const t=E();if(!t||t.length===0)return console.log("[ERROR] No messages in current session"),null;for(let s=t.length-1;s>=0;s--){const n=t[s];if(n.role==="assistant"){const l=(b(n.id)||[]).map(i=>{const g={id:i.id,type:i.type};return i.type==="text"?(g.text=i.text,g.textLength=i.text?.length||0):i.type==="tool"?(g.tool=i.tool,g.state=i.state?.status):(i.type==="step-start"||i.type==="step-finish")&&(g.isStepMarker=!0),g}),u=l.some(i=>i.type==="text"&&i.text&&i.text.trim().length>0),a=l.some(i=>i.type==="tool"),d=l.some(i=>i.type==="step-start"||i.type==="step-finish"),p=l.length===0,y=!u&&!a&&(!p||d),r={messageId:n.id,role:n.role,timestamp:n.time?.created||0,partsCount:l.length,parts:l,isEmpty:p,isEmptyResponse:y,raw:n};return console.log("[INSPECT] Last Assistant Message:",r),console.log("[SUMMARY] Summary:",{messageId:r.messageId,partsCount:r.partsCount,isEmpty:r.isEmpty,isEmptyResponse:r.isEmptyResponse,hasText:u,hasTools:a,hasStepMarkers:d,onlyStepMarkers:d&&!u&&!a}),r.isEmpty&&console.warn("[WARNING] Message has NO parts!"),r.isEmptyResponse&&(console.warn("[WARNING] Message has parts but NO meaningful content (empty text, no tools)!"),d&&!u&&!a&&(console.warn("[CRITICAL] CLAUDE EMPTY RESPONSE BUG: Only step-start/step-finish markers, no actual content!"),console.log("This is a known issue with Claude models (anthropic provider)"),console.log("Recommendation: Send a follow-up message or try a different model"))),r}}return console.log("[ERROR] No assistant messages found in current session"),null},truncateString(e,o=80){return!e||typeof e!="string"||e.length<=o?e:e.substring(0,o)+"…"},truncateMessages(e){return e.map(o=>({...o,parts:(b(o.id)||[]).map(t=>{const s={...t};return"text"in t&&(s.text=this.truncateString(t.text)),"textPreview"in t&&(s.textPreview=this.truncateString(t.textPreview)),t.state&&(s.state={...t.state},"output"in t.state&&(s.state.output=this.truncateString(t.state.output)),"error"in t.state&&(s.state.error=this.truncateString(t.state.error)),t.state.metadata&&"preview"in t.state.metadata&&(s.state.metadata={...t.state.metadata,preview:this.truncateString(t.state.metadata.preview)})),s})}))},getAllMessages(e=!1){if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const s=E();return console.log(`[MESSAGES] Total messages in session: ${s.length}`),s.forEach((n,m)=>{const l=b(n.id)||[];console.log(`[${m}] ${n.role} - ${n.id} - ${l.length} parts`)}),e?this.truncateMessages(s):s},async getAppStatus(){const e=A.getState(),o=R.getState(),t=q.getState(),s=e.currentDirectory||null,n=_().getState(),m=n.directory??null,l=Q(),u=new Set,a={};l.forEach(c=>{const f=c.directory;typeof f=="string"&&f.trim().length>0?(u.add(f),a[f]=(a[f]??0)+1):a["(none)"]=(a["(none)"]??0)+1});const d=(()=>{if(typeof window>"u")return{available:!1};try{return{available:!0,lastDirectory:window.localStorage.getItem("lastDirectory"),homeDirectory:window.localStorage.getItem("homeDirectory")}}catch(c){return{available:!1,error:c instanceof Error?c.message:String(c)}}})(),p=P(),y=typeof window<"u"&&!!window.__PICHAMBER_ELECTRON__,r=async c=>{try{return await c.json()}catch{return null}},g=await(async c=>{try{const f=await re(c);return f.ok?await r(f):{status:f.status}}catch(f){return{error:f instanceof Error?f.message:String(f)}}})("/api/pi/ui-settings");let I=null;try{I=await se.health({runtimeKey:oe()})}catch(c){I={error:c instanceof Error?c.message:String(c)}}let w={isGitRepo:null};if(s)try{const c=P()?.git.checkIsGitRepository??ne;w.isGitRepo=await c(s)}catch(c){w={isGitRepo:null,error:c instanceof Error?c.message:String(c)}}const D=t.projects.map(c=>({id:c.id,path:c.path,label:c.label})),S={runtime:{platform:p?.runtime?.platform??null,isDesktop:y,hasRuntimeApis:!!p,desktopServerOrigin:null},location:typeof window<"u"?{href:window.location?.href??null,origin:window.location?.origin??null}:null,directories:{currentDirectory:s,piDirectory:m,homeDirectory:e.homeDirectory||null,isHomeReady:e.isHomeReady,hasPersistedDirectory:e.hasPersistedDirectory,isSwitchingDirectory:e.isSwitchingDirectory},projects:{total:t.projects.length,activeProjectId:t.activeProjectId,samples:D},sessions:{total:l.length,currentSessionId:o.currentSessionId,uniqueDirectories:u.size,directorySamples:Array.from(u).slice(0,5),directoryCounts:a},git:w,localStorage:d,pi:{health:I,connection:n.connection},pichamber:{settingsInfo:g},recentSendFailures:G(),currentSessionDirectoryResolution:o.currentSessionId?this.diagnoseSessionDirectory(o.currentSessionId):null};return console.log("[DEBUG] App status snapshot:",S),S},getRecentSendFailures(){const e=G();return e.length===0?console.log("[OK] No prompt sends were rejected in this session."):(console.warn(`[ALERT] ${e.length} rejected prompt send(s):`),console.table(e)),e},diagnoseSessionDirectory(e){const o=R.getState(),t=e??o.currentSessionId;if(!t)return console.log("[ERROR] No session selected and no session id passed"),null;const s=z(t),n=J().find(g=>g.id===t),m=n?.directory??null,l=t===o.currentSessionId?o.currentSessionDirectory:null,a=K({session:n??null,currentDirectory:l}),d=o.getDirectoryForSession(t),p=Z(t),y=[["owning child store",s],["session record",m],["current selection",l],["runtime memory",p.runtime],["persisted memory",p.persisted]],r=d?y.find(([,g])=>g&&g!==d):void 0,i={sessionId:t,isCurrentSession:t===o.currentSessionId,routedDirectory:d,resolvedFrom:a.source,conflict:r?{source:r[0],directory:r[1]}:null,sources:X(),details:{owningChildStore:s,sessionRecordDirectory:m,sessionIndexed:!!n,currentSessionDirectory:o.currentSessionDirectory,rememberedForRuntime:p.runtime,persistedAcrossRestarts:p.persisted,activeDirectory:A.getState().currentDirectory??null,piSessionDirectory:_().getState().directory??null}};return console.log("[DEBUG] Session directory resolution:",i),r?console.warn(`[ALERT] Directory sources disagree: routing to "${d}" while "${r[1]}" came from ${r[0]}.`):d?console.log("[OK] All known sources agree on the session directory."):console.warn("[ALERT] No directory resolved for this session — sends fall back to the active directory."),i},async buildDiagnosticsReport(){const e=await this.getAppStatus();return JSON.stringify(e,null,2)},async copyTextToClipboard(e){return W(e)},async copyDiagnosticsReport(){const e=await this.buildDiagnosticsReport();return{...await this.copyTextToClipboard(e),report:e}},checkLastMessage(){const e=this.getLastAssistantMessage();if(!e)return!1;const o=e.isEmpty||e.isEmptyResponse;return o?(console.error("[ALERT] PROBLEMATIC MESSAGE DETECTED!"),console.log("Details:",{messageId:e.messageId,isEmpty:e.isEmpty,isEmptyResponse:e.isEmptyResponse,partsCount:e.partsCount}),e.parts.length>0&&console.log("Parts:",e.parts)):console.log("[OK] Last message looks good!"),o},getStreamingState(){const e=R.getState(),o=_().getState().reducer.bySession,t=new Map;for(const[n,m]of o)t.set(n,k(m));const s=e.currentSessionId?t.get(e.currentSessionId)??null:null;return console.log("[STREAM] Streaming State:",{streamingMessageId:s,streamingMessageIds:Array.from(t.entries())}),{streamingMessageId:s,streamingMessageIds:t}},findEmptyMessages(){if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const s=E().filter(n=>n.role==="assistant").filter(n=>{const m=b(n.id)||[],l=m.some(a=>a.type==="text"&&a.text&&a.text.trim().length>0),u=m.some(a=>a.type==="tool");return m.length===0||!l&&!u});return console.log(`[INSPECT] Found ${s.length} empty assistant messages`),s.forEach((n,m)=>{const l=b(n.id)||[];console.log(`[${m}] Empty message:`,{messageId:n.id,partsCount:l.length,provider:n.providerID,model:n.modelID,timestamp:n.time?.created})}),s},showRetryHelp(){console.log(`[DEBUG] How to handle empty Claude responses:
|
|
3
|
-
`),console.log("1. Check the last message:"),console.log(` __piDebug.getLastAssistantMessage()
|
|
4
|
-
`),console.log("2. Find all empty messages in session:"),console.log(` __piDebug.findEmptyMessages()
|
|
5
|
-
`),console.log("3. To retry, you can:"),console.log(" - Edit your last user message and resend"),console.log(' - Send a follow-up message like "Please provide the response"'),console.log(` - Try a different model (OpenAI models tend to be more reliable)
|
|
6
|
-
`),console.log("[TIP] Empty responses are usually due to:"),console.log(" - Model rate limits"),console.log(" - Context length issues"),console.log(" - Model refusing to respond to certain prompts"),console.log(" - API errors from provider")},analyzeMessageCompletionConsistency(e={}){const{includeNonAssistant:o=!1,verbose:t=!0,maxTableRows:s=25}=e;if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),{summary:null,rows:[]};const l=E(),u=o?l:l.filter(r=>r.role==="assistant"),a={totalMessages:l.length,analyzedMessages:u.length,completedMissing:0,completedBeforeTool:0,completedBeforeReasoning:0,runningToolsWhenCompleted:0,reasoningOpenWhenCompleted:0,withTools:0,withReasoning:0},d=r=>typeof r=="number"&&Number.isFinite(r)?r:null,p=r=>{const i=r.filter(g=>typeof g=="number");return i.length>0?Math.max(...i):null},y=u.map((r,i)=>{const g=r,I=b(r.id)||[],w=g.time??{},D=d(w.completed),S=D!==null,c=I.filter(h=>h.type==="tool"),f=I.filter(h=>h.type==="reasoning"),C=p(c.map(h=>d(h.state?.time?.end??h.state?.time?.start))),M=p(f.map(h=>d(h.time?.end??h.time?.start))),V=p([C,M].filter(h=>h!==null)),x=c.some(h=>["pending","running","started"].includes(h.state?.status)),O=f.some(h=>typeof h.time?.end!="number");c.length>0&&(a.withTools+=1),f.length>0&&(a.withReasoning+=1),S||(a.completedMissing+=1);const N=!!(S&&typeof C=="number"&&D<C);N&&(a.completedBeforeTool+=1);const B=!!(S&&typeof M=="number"&&D<M);return B&&(a.completedBeforeReasoning+=1),S&&x&&(a.runningToolsWhenCompleted+=1),S&&O&&(a.reasoningOpenWhenCompleted+=1),{index:i,messageId:g.id,role:g.role,completedAt:D,latestToolTimestamp:C,latestReasoningTimestamp:M,latestPartTimestamp:V,completed_missing:!S,completed_before_tool:N,completed_before_reasoning:B,running_tools_when_completed:!!(S&&x),reasoning_open_when_completed:!!(S&&O),has_tools:c.length>0,has_reasoning:f.length>0}});return t&&(console.table(y.slice(0,s)),y.length>s&&console.log(`Displayed first ${s} rows out of ${y.length}.`),console.log("[SUMMARY] Message completion timing:",a)),{summary:a,rows:y}},checkCompletionStatus(){if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const s=E().filter(w=>w.role==="assistant");if(s.length===0)return console.log("[ERROR] No assistant messages"),null;const n=s[s.length-1],l=(b(n.id)||[]).filter(w=>w.type==="step-finish"),u=n.finish==="stop",d=n.time?.completed,p=n.status,y=typeof d=="number"&&d>0||p==="completed",r=!!(y&&u),i=n.sessionID,g=i?k(_().getState().reducer.bySession.get(i)??null):null,I=n.id===g;return console.log("[SUMMARY] Completion Status:"),console.log("Message ID:",n.id),console.log("time.completed:",d,"(type:",typeof d,")"),console.log("status:",p),console.log("hasCompletedFlag:",y),console.log("hasStopReason:",u),console.log("messageIsComplete:",r),console.log("isStreamingCandidate:",I),console.log("streamingMessageId:",g),console.log("Step-finish parts:",l),{messageId:n.id,completed:d,status:p,hasCompletedFlag:y,hasStopReason:u,messageIsComplete:r,stepFinishParts:l,raw:n}}};typeof window<"u"&&(window.__piDebug=ge,te()&&(console.log("[DEBUG] Pi debug utilities loaded. Use window.__piDebug in the console."),console.log("Available commands:"),console.log(" __piDebug.getLastAssistantMessage() - Get last assistant message details"),console.log(" __piDebug.getAllMessages(truncate?) - List all messages (truncate=true for short preview)"),console.log(" __piDebug.truncateMessages(messages) - Truncate long fields in messages array"),console.log(" __piDebug.getAppStatus() - Show app status snapshot"),console.log(" __piDebug.diagnoseSessionDirectory(sessionId?) - Show how the session directory is resolved"),console.log(" __piDebug.getRecentSendFailures() - List prompt sends that were rejected and rolled back"),console.log(" __piDebug.checkLastMessage() - Check if last message is problematic"),console.log(" __piDebug.findEmptyMessages() - Find all empty assistant messages"),console.log(" __piDebug.showRetryHelp() - Show instructions for handling empty responses"),console.log(" __piDebug.getStreamingState() - Get streaming state info"),console.log(" __piDebug.analyzeMessageCompletionConsistency(opts?) - Compare time.completed vs part timings"),console.log(" __piDebug.checkCompletionStatus() - Check completion status of last message")),window.addEventListener("error",e=>{try{const o=e.message||"",t=e.filename||"";typeof o=="string"&&o.includes("this._renderer.value.dimensions")&&/xterm/i.test(String(t))&&e.preventDefault()}catch{}}));const he=async()=>{if(typeof window>"u")return;let e=null;try{e=window.localStorage.getItem("lastDirectory")}catch(o){console.warn("Failed to read saved directory preferences:",o)}e&&A.getState().setDirectory(e,{showOverlay:!1})};let $=!1;const H="pichamber-typography-base",ue=()=>{if(typeof document>"u")return;const o=`:root {
|
|
7
|
-
${Object.entries(ie).map(([n,m])=>` --text-${n.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${m};`).join(`
|
|
8
|
-
`)}
|
|
9
|
-
}
|
|
10
|
-
`,t=document.getElementById(H);if(t){t.textContent=o;return}const s=document.createElement("style");s.id=H,s.textContent=o,document.head.appendChild(s)},Se=()=>{$||typeof window>"u"||($=!0,ue())},j=2e4,U=()=>typeof document>"u"||document.visibilityState==="visible"&&document.hasFocus()?"visible":"hidden",v=e=>{if(!Y()&&!L())return;const o=P();o?.push?.setVisibility&&o.push.setVisibility({visible:e,platform:ae()})},we=e=>{const o=e?.enabled??!0;ce.useEffect(()=>{if(!o||!Y()&&!L()||typeof window>"u")return;if(L()){let l=!0,u=!1,a=null;const d=()=>v(l);le(()=>import("./vendor-capacitor-app-BjdQVib9.js"),__vite__mapDeps([0,1,2,3,4])).then(async({App:y})=>{if(u)return;const r=await y.getState().catch(()=>null);r&&(l=r.isActive===!0),d();const i=await y.addListener("appStateChange",({isActive:g})=>{l=g===!0,d()});if(u){i.remove();return}a=()=>{i.remove()}}).catch(()=>{});const p=window.setInterval(()=>{l&&v(!0)},j);return()=>{u=!0,window.clearInterval(p),a?.()}}if(typeof document>"u")return;const t=()=>{v(U()==="visible")},s=()=>{U()==="visible"&&v(!0)},n=()=>{v(!1)};t();const m=window.setInterval(s,j);return document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",n),window.addEventListener("pageshow",t),window.addEventListener("focus",t),window.addEventListener("blur",t),()=>{window.clearInterval(m),document.removeEventListener("visibilitychange",t),window.removeEventListener("pagehide",n),window.removeEventListener("pageshow",t),window.removeEventListener("focus",t),window.removeEventListener("blur",t)}},[o])},T=(e,o)=>!!(e&&o)&&F(e??null)===F(o??null);function Re(e,o){if(!e)return null;const t=_();if(T(t.getState().directory,e))return null;const s=R.getState();return ee(s.newSessionDraft,s.currentSessionId)?null:s.currentSessionId&&T(s.currentSessionDirectory,e)?s.currentSessionId:o?.sessionId&&T(o.directory,e)?o.sessionId:t.lastSelectedSessionForDirectory(e)}export{he as a,Re as f,Se as s,we as u};
|