@aiworker/web 1.22.0 → 1.23.0
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 +4 -4
- package/bin/cli.js +14 -4
- package/bin/cli.test.js +165 -73
- package/bin/lib/cli-api-target.js +2 -2
- package/bin/lib/cli-args.js +119 -119
- package/bin/lib/cli-lifecycle.js +9 -9
- package/bin/lib/cli-network.js +3 -3
- package/bin/lib/cli-paths.js +3 -3
- package/bin/lib/cli-ports.js +2 -2
- package/bin/lib/cli-process.js +4 -4
- package/bin/lib/cli-startup.js +64 -15
- package/bin/lib/cli-tunnel-profiles.js +1 -1
- package/bin/lib/cli-tunnel-utils.js +2 -2
- package/bin/lib/commands-connect-url.js +19 -19
- package/bin/lib/commands-lifecycle.js +27 -27
- package/bin/lib/commands-logs.js +5 -5
- package/bin/lib/commands-models.js +1 -1
- package/bin/lib/commands-projects.js +1 -1
- package/bin/lib/commands-schedule.js +1 -1
- package/bin/lib/commands-serve.js +29 -29
- package/bin/lib/commands-session.js +1 -1
- package/bin/lib/commands-startup.js +45 -10
- package/bin/lib/commands-status.js +1 -1
- package/bin/lib/commands-tunnel.js +40 -40
- package/bin/lib/commands-update.js +1 -1
- package/bin/lib/commands-update.test.js +6 -6
- package/dist/assets/{CodeMirrorCommentWidgets-B3u7UIcE.js → CodeMirrorCommentWidgets-B1Gizi3a.js} +1 -1
- package/dist/assets/DiffView-DXjVsEOw.js +4 -0
- package/dist/assets/DirtyBranchSwitchDialog-aig6zJjg.js +1 -0
- package/dist/assets/FilesView-CJdG0-wk.js +17 -0
- package/dist/assets/GitView-BXsS3jG6.js +6 -0
- package/dist/assets/{JsonTreeView-B0BdZEHG.js → JsonTreeView-D_hpXBnF.js} +1 -1
- package/dist/assets/LinearIssuesView-BoUiLQG1.js +1 -0
- package/dist/assets/MarkdownImageGallery-B_B_a9KS.js +1 -0
- package/dist/assets/MarkdownRendererImpl-xgyyLiBM.js +12 -0
- package/dist/assets/OnboardingScreen-DIp84OWt.js +1 -0
- package/dist/assets/{PatchDiff-DvfqDql7.js → PatchDiff-8p6nLJaU.js} +1 -1
- package/dist/assets/PierreDiffViewer-DjC8nTk9.js +161 -0
- package/dist/assets/PlanView-CJTmOF6I.js +5 -0
- package/dist/assets/SettingsView-DD-JqIJx.js +28 -0
- package/dist/assets/{SettingsWindow-i45U1Cy1.js → SettingsWindow-Cpb4hM6q.js} +1 -1
- package/dist/assets/SymbolsNerdFontMono-Regular-aK5vsLov.woff2 +0 -0
- package/dist/assets/{ToolOutputDialog-BTwyh5OF.js → ToolOutputDialog-DfaKZXNU.js} +6 -6
- package/dist/assets/ToolPartDiffPreview-DtZLzrSK.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-DD8lDVej.js → VirtualizedFileDiff-C8i9HpTB.js} +1 -1
- package/dist/assets/WalkthroughView-DeKMvZlL.js +4 -0
- package/dist/assets/{computeVirtualFileMetrics-BMIRgMHv.js → computeVirtualFileMetrics-BBI7ZwrC.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-BdA6bdky.js +1 -0
- package/dist/assets/de-DCrsQ5zS.js +10 -0
- package/dist/assets/es-Dwv4YfH6.js +16 -0
- package/dist/assets/fr-BCWg4Cnx.js +14 -0
- package/dist/assets/ghostty-vt-DdA0Zryv.wasm +0 -0
- package/dist/assets/index-B68h5S5B.css +1 -0
- package/dist/assets/index-DVwMarHI.js +39 -0
- package/dist/assets/{index-CODwDsU_.js → index-jXSK5RrB.js} +1 -1
- package/dist/assets/{isDiffPlainText-BqayB8d3.js → isDiffPlainText-B_x_rVon.js} +1 -1
- package/dist/assets/{isFilePlainText-QfoiKJNY.js → isFilePlainText-DW_xMer1.js} +1 -1
- package/dist/assets/ja-Bruw3RYC.js +16 -0
- package/dist/assets/ko-idhXGF8j.js +16 -0
- package/dist/assets/main-BkyaQhJX.js +930 -0
- package/dist/assets/{main-C5DVOxc6.js → main-CzdPuL0s.js} +2 -2
- package/dist/assets/markdownCore-Cn4Tyejo.js +5 -0
- package/dist/assets/{miniChat-DUJ4irZc.js → miniChat-CCkqKOLp.js} +2 -2
- package/dist/assets/{mobile-CcaxB0n4.js → mobile-mvxTo055.js} +2 -2
- package/dist/assets/patchFileDiff-Csk4iNUi.js +13 -0
- package/dist/assets/pl-CGZWUqZJ.js +16 -0
- package/dist/assets/pt-BR-B8V7u7tA.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-BxoyujA5.js +2 -0
- package/dist/assets/renderMobileApp-B48CsP4r.js +25 -0
- package/dist/assets/runtimeEndpointReset-Bg5gx18H.js +17 -0
- package/dist/assets/scheduledTasksApi-BW0Etzwz.js +1 -0
- package/dist/assets/{shikiHighlight-DYOWuY65.js → shikiHighlight-CRl0SUC9.js} +1 -1
- package/dist/assets/surface-oMvhsog3.js +1 -0
- package/dist/assets/tr-BK_KiO2V.js +7 -0
- package/dist/assets/uk-CG74xV8N.js +16 -0
- package/dist/assets/useAppFontEffects-CPKeOpUo.js +7284 -0
- package/dist/assets/useGitComparison-DH220WmO.js +1 -0
- package/dist/assets/useInlineCommentController-BiWz4AVb.js +2 -0
- package/dist/assets/useRootScrollLock-BS4-kr7P.js +1 -0
- package/dist/assets/{vendor-base-ui-BeMD8X_w.js → vendor-base-ui-DdV8vhHn.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-DFZik9R2.js → vendor-codemirror-language-data-Bg4AEeCr.js} +2 -2
- package/dist/assets/vendor-zod-BPAANqvH.js +39 -0
- package/dist/assets/{web-components-Bhg83tjf.js → web-components-z7hfnS8n.js} +1 -1
- package/dist/assets/zh-CN-T4AXofZI.js +16 -0
- package/dist/assets/zh-TW-Dte40sxp.js +16 -0
- package/dist/index.html +21 -59
- package/dist/mini-chat.html +7 -7
- package/dist/mobile.html +5 -5
- package/package.json +3 -4
- package/server/index.d.ts +15 -0
- package/server/index.js +158 -89
- package/server/lib/agent-memory/actions.js +2 -2
- package/server/lib/agent-memory/feature-flag.js +1 -1
- package/server/lib/agent-memory/feature-flag.test.js +8 -8
- package/server/lib/agent-memory/routes.js +2 -2
- package/server/lib/agent-tool/runtime.js +37 -54
- package/server/lib/agent-tool/runtime.test.js +59 -59
- package/server/lib/browser-control/broker.js +3 -3
- package/server/lib/browser-control/broker.test.js +1 -1
- package/server/lib/changelog/update-notes.js +82 -0
- package/server/lib/changelog/update-notes.test.js +59 -0
- package/server/lib/client-auth/remote-clients.test.js +5 -5
- package/server/lib/context-obligatory/runtime.js +7 -7
- package/server/lib/context-obligatory/runtime.test.js +5 -5
- package/server/lib/data-dir-migration.js +40 -0
- package/server/lib/data-dir-migration.test.js +59 -0
- package/server/lib/dev-servers/parse.js +2 -2
- package/server/lib/dev-servers/parse.test.js +2 -2
- package/server/lib/dev-servers/routes.js +1 -1
- package/server/lib/dev-tunnel/DOCUMENTATION.md +13 -4
- package/server/lib/dev-tunnel/client.js +1 -1
- package/server/lib/dev-tunnel/runtime.js +5 -5
- package/server/lib/dev-tunnel/tunnel.test.js +21 -1
- package/server/lib/dictation/local/model-catalog.js +1 -1
- package/server/lib/dictation/local/worker-process.js +2 -2
- package/server/lib/event-stream/directory-ws-bridge.js +1 -1
- package/server/lib/event-stream/global-ws-bridge.js +1 -1
- package/server/lib/event-stream/protocol.test.js +4 -4
- package/server/lib/event-stream/runtime.test.js +18 -18
- package/server/lib/fs/DOCUMENTATION.md +5 -0
- package/server/lib/fs/routes.js +68 -26
- package/server/lib/fs/routes.test.js +208 -22
- package/server/lib/git/DOCUMENTATION.md +32 -6
- package/server/lib/git/identity-storage.js +1 -1
- package/server/lib/git/issue-2746-longpaths.test.js +4 -4
- package/server/lib/git/routes.js +41 -5
- package/server/lib/git/service.js +300 -224
- package/server/lib/git/service.test.js +596 -28
- package/server/lib/github/auth.js +8 -8
- package/server/lib/github/pr-status.js +1 -1
- package/server/lib/github/routes.js +2 -2
- package/server/lib/inherited-env.js +17 -10
- package/server/lib/inherited-env.test.js +10 -11
- package/server/lib/linear/auth.js +8 -8
- package/server/lib/linear/auth.test.js +24 -24
- package/server/lib/linear/issues.test.js +6 -6
- package/server/lib/linear/mapping.test.js +4 -4
- package/server/lib/linear/oauth.js +2 -2
- package/server/lib/linear/oauth.test.js +14 -14
- package/server/lib/linear/routes.js +5 -5
- package/server/lib/linear/routes.test.js +16 -16
- package/server/lib/linear/status-runtime.test.js +9 -9
- package/server/lib/linear/status.js +1 -1
- package/server/lib/linear/status.test.js +15 -15
- package/server/lib/linear/teams.test.js +4 -4
- package/server/lib/magic-prompts/routes.js +2 -2
- package/server/lib/mcp-reconnect/DOCUMENTATION.md +55 -0
- package/server/lib/mcp-reconnect/runtime.js +122 -0
- package/server/lib/mcp-reconnect/runtime.test.js +140 -0
- package/server/lib/message-queue/DOCUMENTATION.md +161 -0
- package/server/lib/message-queue/runtime.js +870 -0
- package/server/lib/message-queue/runtime.test.js +482 -0
- package/server/lib/network-defaults.js +23 -0
- package/server/lib/network-defaults.test.js +52 -0
- package/server/lib/notifications/apns-runtime.js +17 -17
- package/server/lib/notifications/apns-runtime.test.js +11 -11
- package/server/lib/notifications/emitter-runtime.js +1 -1
- package/server/lib/notifications/emitter-runtime.test.js +1 -1
- package/server/lib/notifications/push-runtime.js +7 -7
- package/server/lib/notifications/routes.js +1 -1
- package/server/lib/notifications/runtime.js +1 -1
- package/server/lib/openchamber-control/action-resolution.test.js +10 -10
- package/server/lib/openchamber-control/actions.js +24 -24
- package/server/lib/openchamber-control/error.js +4 -4
- package/server/lib/openchamber-control/routes.js +2 -2
- package/server/lib/openchamber-control/routes.test.js +5 -5
- package/server/lib/openchamber-control/screenshots.js +1 -1
- package/server/lib/openchamber-control/screenshots.test.js +1 -1
- package/server/lib/openchamber-control/service.js +50 -50
- package/server/lib/openchamber-control/service.test.js +5 -5
- package/server/lib/openchamber-sessions/routes.js +124 -22
- package/server/lib/openchamber-sessions/routes.test.js +99 -11
- package/server/lib/opencode/DOCUMENTATION.md +30 -6
- package/server/lib/opencode/auth.js +1 -1
- package/server/lib/opencode/bootstrap-runtime.js +8 -6
- package/server/lib/opencode/cli-options.js +8 -8
- package/server/lib/opencode/config-paths.test.js +116 -0
- package/server/lib/opencode/core-routes.js +8 -7
- package/server/lib/opencode/core-routes.test.js +11 -11
- package/server/lib/opencode/env-config.js +5 -5
- package/server/lib/opencode/env-config.test.js +7 -7
- package/server/lib/opencode/env-runtime.js +10 -10
- package/server/lib/opencode/env-runtime.test.js +18 -18
- package/server/lib/opencode/feature-routes-runtime.js +19 -12
- package/server/lib/opencode/hmr-state-runtime.js +2 -2
- package/server/lib/opencode/hmr-state-runtime.test.js +1 -1
- package/server/lib/opencode/input-history-scope.js +14 -0
- package/server/lib/opencode/lifecycle.js +8 -8
- package/server/lib/opencode/lifecycle.test.js +4 -4
- package/server/lib/opencode/managed-plugin-config.js +35 -0
- package/server/lib/opencode/managed-process-registry.js +3 -3
- package/server/lib/opencode/mcp-oauth-callback.test.js +2 -2
- package/server/lib/opencode/openchamber-routes.js +79 -19
- package/server/lib/opencode/openchamber-routes.test.js +139 -12
- package/server/lib/opencode/plugins.js +2 -2
- package/server/lib/opencode/plugins.test.js +1 -1
- package/server/lib/opencode/project-icon-routes.js +2 -2
- package/server/lib/opencode/project-icon-routes.test.js +1 -1
- package/server/lib/opencode/providers.js +44 -2
- package/server/lib/opencode/providers.test.js +131 -4
- package/server/lib/opencode/proxy.js +2 -2
- package/server/lib/opencode/pwa-manifest-routes.js +1 -1
- package/server/lib/opencode/restart-session-recovery.test.js +1 -1
- package/server/lib/opencode/routes-upgrade.test.js +4 -4
- package/server/lib/opencode/routes.js +19 -17
- package/server/lib/opencode/server-startup-runtime.js +6 -6
- package/server/lib/opencode/session-runtime.js +3 -3
- package/server/lib/opencode/session-runtime.test.js +6 -6
- package/server/lib/opencode/settings-files.js +214 -0
- package/server/lib/opencode/settings-helpers.js +116 -44
- package/server/lib/opencode/settings-helpers.test.js +354 -12
- package/server/lib/opencode/settings-registry.json +747 -0
- package/server/lib/opencode/settings-runtime.js +141 -20
- package/server/lib/opencode/settings-runtime.test.js +191 -4
- package/server/lib/opencode/shared.js +5 -2
- package/server/lib/opencode/shared.test.js +7 -7
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/opencode/skill-routes.js +2 -1
- package/server/lib/opencode/snippets.js +1 -2
- package/server/lib/opencode/startup-performance.js +1 -1
- package/server/lib/opencode/startup-performance.test.js +6 -6
- package/server/lib/opencode/static-routes-runtime.js +8 -8
- package/server/lib/opencode/static-routes-runtime.test.js +7 -7
- package/server/lib/opencode/upgrade-capability.js +2 -2
- package/server/lib/opencode/upgrade-capability.test.js +3 -3
- package/server/lib/package-manager.js +17 -42
- package/server/lib/package-manager.test.js +19 -19
- package/server/lib/permission-auto-accept/runtime.js +1 -1
- package/server/lib/project-context/DOCUMENTATION.md +25 -1
- package/server/lib/project-context/routes.http.test.js +18 -0
- package/server/lib/project-context/routes.js +16 -1
- package/server/lib/project-context/runtime.js +248 -23
- package/server/lib/project-context/runtime.test.js +106 -3
- package/server/lib/projects/DOCUMENTATION.md +76 -0
- package/server/lib/projects/project-config.js +144 -11
- package/server/lib/projects/project-id.js +17 -0
- package/server/lib/projects/project-setup.js +409 -0
- package/server/lib/projects/project-setup.test.js +557 -0
- package/server/lib/projects/routes.js +59 -0
- package/server/lib/quota/DOCUMENTATION.md +40 -2
- package/server/lib/quota/credentials/providers.js +4 -0
- package/server/lib/quota/credentials/store.js +4 -4
- package/server/lib/quota/credentials/store.test.js +8 -8
- package/server/lib/quota/index.js +1 -0
- package/server/lib/quota/providers/cline-pass.js +125 -0
- package/server/lib/quota/providers/cline-pass.test.js +103 -0
- package/server/lib/quota/providers/exe-dev.js +75 -0
- package/server/lib/quota/providers/exe-dev.test.js +47 -0
- package/server/lib/quota/providers/hyper.js +118 -0
- package/server/lib/quota/providers/hyper.test.js +126 -0
- package/server/lib/quota/providers/index.js +22 -0
- package/server/lib/quota/providers/neuralwatt.js +3 -6
- package/server/lib/quota/providers/neuralwatt.test.js +7 -7
- package/server/lib/quota/providers/ollama-cloud.js +32 -1
- package/server/lib/quota/providers/ollama-cloud.test.js +33 -1
- package/server/lib/quota/providers/opencode-go.js +3 -2
- package/server/lib/quota/providers/opencode-go.test.js +35 -6
- package/server/lib/quota/providers/openrouter.js +119 -24
- package/server/lib/quota/providers/openrouter.test.js +330 -0
- package/server/lib/quota/providers/xai.js +1 -1
- package/server/lib/quota/routes.js +2 -0
- package/server/lib/quota/utils/auth.js +1 -1
- package/server/lib/relay/DOCUMENTATION.md +56 -1
- package/server/lib/relay/cross-compat.test.js +26 -0
- package/server/lib/relay/downstream-scheduler.js +154 -0
- package/server/lib/relay/downstream-scheduler.test.js +162 -0
- package/server/lib/relay/e2ee.js +10 -8
- package/server/lib/relay/flow-control.test.js +177 -0
- package/server/lib/relay/host-client.js +38 -9
- package/server/lib/relay/host-client.test.js +9 -1
- package/server/lib/relay/host-lock.js +1 -1
- package/server/lib/relay/service.js +5 -5
- package/server/lib/relay/tunnel-codec.js +9 -0
- package/server/lib/relay/tunnel-host.js +69 -18
- package/server/lib/relay/tunnel-host.test.js +9 -1
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +2 -2
- package/server/lib/scheduled-tasks/routes.js +5 -5
- package/server/lib/scheduled-tasks/service.js +25 -25
- package/server/lib/scheduled-tasks/service.test.js +1 -1
- package/server/lib/security/bind-host.js +4 -4
- package/server/lib/security/bind-host.test.js +1 -1
- package/server/lib/security/request-security.js +11 -5
- package/server/lib/security/request-security.test.js +14 -14
- package/server/lib/session-assist/runtime.js +15 -18
- package/server/lib/session-folders/routes.js +2 -2
- package/server/lib/session-folders/routes.test.js +8 -8
- package/server/lib/session-goal/DOCUMENTATION.md +20 -7
- package/server/lib/session-goal/create.js +4 -2
- package/server/lib/session-goal/create.test.js +1 -1
- package/server/lib/session-goal/objectives.js +4 -4
- package/server/lib/session-goal/routes.js +1 -1
- package/server/lib/session-goal/runtime.js +91 -30
- package/server/lib/session-goal/runtime.test.js +428 -2
- package/server/lib/session-knowledge/runtime.js +11 -11
- package/server/lib/session-knowledge/runtime.test.js +5 -5
- package/server/lib/skills-catalog/DOCUMENTATION.md +1 -1
- package/server/lib/skills-catalog/cache.test.js +2 -2
- package/server/lib/skills-catalog/disk-cache.js +5 -5
- package/server/lib/skills-catalog/github-meta.test.js +2 -2
- package/server/lib/skills-catalog/install.js +3 -2
- package/server/lib/small-model/DOCUMENTATION.md +7 -2
- package/server/lib/small-model/call.js +18 -7
- package/server/lib/small-model/call.test.js +58 -6
- package/server/lib/small-model/index.js +12 -16
- package/server/lib/small-model/index.test.js +1 -1
- package/server/lib/small-model/resolve.js +1 -1
- package/server/lib/small-model/resolve.test.js +1 -1
- package/server/lib/small-model/routes.js +2 -1
- package/server/lib/small-model/runtime-providers.js +15 -7
- package/server/lib/small-model/runtime-providers.test.js +7 -1
- package/server/lib/system-prompt/runtime.js +3 -22
- package/server/lib/system-prompt/runtime.test.js +3 -3
- package/server/lib/terminal/DOCUMENTATION.md +14 -10
- package/server/lib/terminal/runtime.js +190 -31
- package/server/lib/terminal/runtime.test.js +572 -38
- package/server/lib/terminal/shells.js +20 -3
- package/server/lib/terminal/shells.test.js +33 -2
- package/server/lib/tts/base-url.js +3 -3
- package/server/lib/tts/routes.test.js +20 -20
- package/server/lib/ui-auth/ui-auth.js +12 -9
- package/server/lib/ui-auth/ui-auth.test.js +19 -3
- package/server/lib/ui-auth/ui-passkeys.js +7 -7
- package/server/lib/walkthrough/DOCUMENTATION.md +33 -14
- package/server/lib/walkthrough/index.js +1 -0
- package/server/lib/walkthrough/jobs.test.js +1 -1
- package/server/lib/walkthrough/language.test.js +1 -1
- package/server/lib/walkthrough/model-settings.js +11 -15
- package/server/lib/walkthrough/model-settings.test.js +1 -1
- package/server/lib/walkthrough/prompt.js +3 -1
- package/server/lib/walkthrough/pull-request.test.js +5 -5
- package/server/lib/walkthrough/reproduce-2607.test.js +2 -2
- package/server/lib/walkthrough/routes.test.js +26 -5
- package/server/lib/walkthrough/sources.js +23 -2
- package/server/lib/walkthrough/store.js +3 -3
- package/server/lib/walkthrough/store.test.js +1 -1
- package/server/opencode-proxy.test.js +2 -2
- package/server/proxy-headers.js +1 -1
- package/server/sse-routes.test.js +4 -4
- package/README.md.bak +0 -250
- package/bin/lib/DOCUMENTATION.md.bak +0 -163
- package/dist/assets/CommitSection-SGBCAW0w.js +0 -1
- package/dist/assets/DiffView-DluiRSla.js +0 -4
- package/dist/assets/FilesView-Bdq8ppva.js +0 -17
- package/dist/assets/GitView-Znn7VJcP.js +0 -6
- package/dist/assets/LinearIssuesView-jP-hXyac.js +0 -1
- package/dist/assets/MarkdownImageGallery-ClOvuZxC.js +0 -1
- package/dist/assets/MarkdownRendererImpl-Dt9mjTRN.js +0 -12
- package/dist/assets/OnboardingScreen-D2DG7K6b.js +0 -1
- package/dist/assets/PierreDiffViewer-B7m3f0d7.js +0 -157
- package/dist/assets/PlanView-B0F3BtPZ.js +0 -5
- package/dist/assets/SettingsView-BBW-S-gh.js +0 -28
- package/dist/assets/ToolPartDiffPreview-CUNe28U1.js +0 -8
- package/dist/assets/WalkthroughView-egQgxel3.js +0 -4
- package/dist/assets/contextPanelEmbeddedChat-C3fjDbdg.js +0 -1
- package/dist/assets/de-C1P6X5Rs.js +0 -9
- package/dist/assets/es-CDgaF1_t.js +0 -15
- package/dist/assets/fr-Bgxqvvz_.js +0 -13
- package/dist/assets/index-C57jT0Sa.css +0 -1
- package/dist/assets/index-DW_E3rnL.js +0 -7
- package/dist/assets/ja-BDRrEcNP.js +0 -15
- package/dist/assets/ko-Ba8sQV79.js +0 -15
- package/dist/assets/main-Bv5Pkngh.js +0 -928
- package/dist/assets/markdownCore-CZwzz5gw.js +0 -3
- package/dist/assets/patchFileDiff-yNfWXN4E.js +0 -10
- package/dist/assets/pl-Dioz29BI.js +0 -15
- package/dist/assets/pt-BR-DIs6ElwV.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-BcKLHXKe.js +0 -2
- package/dist/assets/renderMobileApp-D9yQJy0L.js +0 -25
- package/dist/assets/runtimeEndpointReset-CjhvxLH0.js +0 -16
- package/dist/assets/scheduledTasksApi-DLW0mkQK.js +0 -1
- package/dist/assets/tr-DFnMlPxY.js +0 -6
- package/dist/assets/uk-ZrCNjM7Y.js +0 -15
- package/dist/assets/useAppFontEffects-CjrntdL0.js +0 -7310
- package/dist/assets/useInlineCommentController-CDEuSlPH.js +0 -2
- package/dist/assets/useRootScrollLock-BHYPkrLv.js +0 -1
- package/dist/assets/vendor-ghostty-web-CrxinGGH.js +0 -13
- package/dist/assets/vendor-zod-BLfBSgBh.js +0 -39
- package/dist/assets/zh-CN-iv_AV4EC.js +0 -15
- package/dist/assets/zh-TW-CzEUk38j.js +0 -15
- package/server/index.d.ts.bak +0 -39
- package/server/lib/agent-tool/DOCUMENTATION.md.bak +0 -119
- package/server/lib/browser-control/DOCUMENTATION.md.bak +0 -50
- package/server/lib/context-obligatory/DOCUMENTATION.md.bak +0 -19
- package/server/lib/dev-tunnel/DOCUMENTATION.md.bak +0 -57
- package/server/lib/dictation/DOCUMENTATION.md.bak +0 -100
- package/server/lib/event-stream/DOCUMENTATION.md.bak +0 -62
- package/server/lib/fs/DOCUMENTATION.md.bak +0 -47
- package/server/lib/git/DOCUMENTATION.md.bak +0 -193
- package/server/lib/github/DOCUMENTATION.md.bak +0 -183
- package/server/lib/linear/DOCUMENTATION.md.bak +0 -97
- package/server/lib/linear/OAUTH-BROKER-HANDOFF.md.bak +0 -91
- package/server/lib/markdown-image-grants/DOCUMENTATION.md.bak +0 -40
- package/server/lib/notifications/APNS.md.bak +0 -135
- package/server/lib/notifications/DOCUMENTATION.md.bak +0 -138
- package/server/lib/openchamber-control/DOCUMENTATION.md.bak +0 -64
- package/server/lib/opencode/DOCUMENTATION.md.bak +0 -431
- package/server/lib/opencode/managed-process-registry.d.ts.bak +0 -13
- package/server/lib/opencode/provider-env-aliases.d.ts.bak +0 -3
- package/server/lib/permission-auto-accept/DOCUMENTATION.md.bak +0 -34
- package/server/lib/project-context/DOCUMENTATION.md.bak +0 -160
- package/server/lib/quota/DOCUMENTATION.md.bak +0 -123
- package/server/lib/relay/DOCUMENTATION.md.bak +0 -100
- package/server/lib/scheduled-tasks/DOCUMENTATION.md.bak +0 -182
- package/server/lib/session-assist/DOCUMENTATION.md.bak +0 -66
- package/server/lib/session-goal/DOCUMENTATION.md.bak +0 -213
- package/server/lib/session-knowledge/DOCUMENTATION.md.bak +0 -89
- package/server/lib/skills-catalog/DOCUMENTATION.md.bak +0 -151
- package/server/lib/small-model/DOCUMENTATION.md.bak +0 -212
- package/server/lib/system-prompt/DOCUMENTATION.md.bak +0 -36
- package/server/lib/terminal/DOCUMENTATION.md.bak +0 -50
- package/server/lib/text/DOCUMENTATION.md.bak +0 -35
- package/server/lib/tts/DOCUMENTATION.md.bak +0 -147
- package/server/lib/tunnels/DOCUMENTATION.md.bak +0 -21
- package/server/lib/ui-auth/DOCUMENTATION.md.bak +0 -44
- package/server/lib/walkthrough/DOCUMENTATION.md.bak +0 -411
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as S,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as Ae}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as Q,ap as ze,a6 as fe,a7 as me,I as R,a8 as ue,h as Z,B as J,a1 as Ee,h4 as Ie,bG as pe,bH as ge,bI as xe,bJ as be,bK as ye,bL as ve,b5 as Te}from"./useAppFontEffects-CjrntdL0.js";import{u as Ce}from"./index-DW_E3rnL.js";const ke={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Me=ke.M;function He(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function Re(p){const e=He(p);return ke[e]??Me}const $e=S.memo(function(e){const t=oe.c(58),{file:o,actionLabel:x,actionSymbol:b,onAction:m,onViewDiff:f,onRevert:l,isReverting:d,stats:z,rowPaddingClassName:g,indentPx:y,actionAtStart:A,showRevert:$}=e,j=y===void 0?0:y,r=A===void 0?!1:A,w=$===void 0?!0:$;let N;t[0]!==o?(N=Re(o),t[0]=o,t[1]=N):N=t[1];const h=N,{t:E}=Q(),F=h.description,M=z?.insertions??0,C=z?.deletions??0;let D;t[2]!==m||t[3]!==f?(D=U=>{U.key===" "?(U.preventDefault(),m()):U.key==="Enter"&&(U.preventDefault(),f())},t[2]=m,t[3]=f,t[4]=D):D=t[4];const V=D;let I;t[5]!==m?(I=U=>{U.preventDefault(),U.stopPropagation(),m()},t[5]=m,t[6]=I):I=t[6];const u=I;let P;t[7]!==l?(P=U=>{U.preventDefault(),U.stopPropagation(),l()},t[7]=l,t[8]=P):P=t[8];const W=P;let L;t[9]!==x||t[10]!==b||t[11]!==u?(L=s.jsx("button",{type:"button",onClick:u,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":x,title:x,children:b}),t[9]=x,t[10]=b,t[11]=u,t[12]=L):L=t[12];const H=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${g??"px-3"}`;let T;t[13]!==j?(T=j>0?{paddingLeft:`${j}px`}:void 0,t[13]=j,t[14]=T):T=t[14];const Y=r?H:null;let K;t[15]!==h.color?(K={color:h.color},t[15]=h.color,t[16]=K):K=t[16];let G;t[17]!==h.code||t[18]!==F||t[19]!==K?(G=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:F,"aria-label":F,children:h.code}),t[17]=h.code,t[18]=F,t[19]=K,t[20]=G):G=t[20];let O;t[21]!==o.path?(O=s.jsx(ze,{filePath:o.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=o.path,t[22]=O):O=t[22];let B;if(t[23]!==o.path){e:{const U=o.path.lastIndexOf("/");if(U===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],B=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:o.path,children:o.path});break e}const De=o.path.slice(0,U),Ve=o.path.slice(U);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const re=s.jsx("span",{className:"text-foreground",children:Ve.slice(1)});let ie;t[28]!==re?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,re]}),t[28]=re,t[29]=ie):ie=t[29],B=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:o.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:De}),ie]})}t[23]=o.path,t[24]=B}else B=t[24];let q;t[30]===Symbol.for("react.memo_cache_sentinel")?(q={color:"var(--status-success)"},t[30]=q):q=t[30];let i;t[31]!==M?(i=s.jsxs("span",{style:q,children:["+",M]}),t[31]=M,t[32]=i):i=t[32];let n,a;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),a={color:"var(--status-error)"},t[33]=n,t[34]=a):(n=t[33],a=t[34]);let c;t[35]!==C?(c=s.jsxs("span",{style:a,children:["-",C]}),t[35]=C,t[36]=c):c=t[36];let k;t[37]!==i||t[38]!==c?(k=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,c]}),t[37]=i,t[38]=c,t[39]=k):k=t[39];let v;t[40]!==o.path||t[41]!==W||t[42]!==d||t[43]!==w||t[44]!==E?(v=w?s.jsxs(fe,{children:[s.jsx(me,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W,disabled:d,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":E("gitView.changes.revertFileAria",{path:o.path}),children:d?s.jsx(R,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(R,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(ue,{sideOffset:8,children:E("gitView.changes.revertFileTooltip")})]}):null,t[40]=o.path,t[41]=W,t[42]=d,t[43]=w,t[44]=E,t[45]=v):v=t[45];const _=r?null:H;let ee;return t[46]!==V||t[47]!==f||t[48]!==T||t[49]!==Y||t[50]!==G||t[51]!==O||t[52]!==B||t[53]!==k||t[54]!==v||t[55]!==_||t[56]!==X?(ee=s.jsxs("div",{className:X,role:"button",tabIndex:0,onClick:f,onKeyDown:V,style:T,children:[Y,G,O,B,k,v,_]}),t[46]=V,t[47]=f,t[48]=T,t[49]=Y,t[50]=G,t[51]=O,t[52]=B,t[53]=k,t[54]=v,t[55]=_,t[56]=X,t[57]=ee):ee=t[57],ee}),je=14,Se=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),we=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Fe=p=>{const e=we("","");for(const t of p){const o=Se(t.path);if(!o)continue;const b=o.split("/").filter(Boolean).slice(0,-1);let m=e;if(m.files.push(t),b.length>0){let f="";for(const l of b){f=f?`${f}/${l}`:l;const d=m.children.get(l);if(d){d.files.push(t),m=d;continue}const z=we(f,l);z.files.push(t),m.children.set(l,z),m=z}}m.directFiles.push(t)}return e},Pe=(p,e)=>{const t=[],o=(x,b)=>{const m=Array.from(x.children.values()).sort((l,d)=>l.path.localeCompare(d.path));for(const l of m)t.push({key:l.id,kind:"directory",depth:b,directory:l}),e.has(l.path)&&o(l,b+1);const f=[...x.directFiles].sort((l,d)=>l.path.localeCompare(d.path));for(const l of f)t.push({key:`file:${Se(l.path)}`,kind:"file",depth:b,file:l})};return o(p,0),t},Le=1e3,Ne=34,ce=30,le="pl-0 pr-2",de=(p,e)=>`${p} ${e}`,Ye=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:o=!1,headerBackgroundClassName:x="bg-sidebar",onVisiblePathsChange:b,onRevertAll:m,onRevertDirectory:f})=>{const{t:l}=Q(),d=S.useRef(null),g=Ce(i=>i.gitChangesViewMode)==="tree",y=S.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[A,$]=S.useState(new Set),[j,r]=S.useState(new Set),[w,N]=S.useState(!1),[h,E]=S.useState(null),F=S.useMemo(()=>y.map(i=>Fe(i.entries)),[y]),M=S.useMemo(()=>{const i=[];return y.forEach((n,a)=>{Array.from(F[a]?.children.values()??[]).forEach(c=>{i.push(de(n.id,c.path))})}),i},[F,y]);S.useEffect(()=>{g&&r(i=>{const n=new Set,a=new Set(M);return i.forEach(c=>{(c.slice(c.indexOf(" ")+1).includes("/")||a.has(c))&&n.add(c)}),M.forEach(c=>n.add(c)),n})},[g,M]);const C=S.useMemo(()=>{const i=[];return y.forEach((n,a)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:a}),!A.has(n.id)){if(g){const c=new Set;j.forEach(v=>{v.startsWith(`${n.id} `)&&c.add(v.slice(n.id.length+1))}),Pe(F[a],c).forEach(v=>{v.kind==="file"?i.push({type:"file",key:`${n.id}:${v.key}`,groupIndex:a,file:v.file,depth:v.depth}):i.push({type:"directory",key:`${n.id}:${v.key}`,groupIndex:a,directory:v.directory,depth:v.depth})});return}n.entries.forEach(c=>{i.push({type:"file",key:`${n.id}:file:${c.path}`,groupIndex:a,file:c,depth:0})})}}),m&&y.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[A,j,g,m,F,y]),D=C.length,V=D>=Le,I=Ae({count:D,enabled:V,getScrollElement:()=>d.current,estimateSize:()=>Ne,overscan:12,getItemKey:i=>C[i]?.key??i}),u=I.getVirtualItems(),P=S.useMemo(()=>{if(!V)return 0;const i=d.current?.scrollTop??0;return u.find(a=>a.end>i)?.index??0},[V,u,d]);S.useEffect(()=>{if(!b)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(D===0){b([]);return}if(!V){const n=[];for(const a of C)if(a.type==="file"&&(n.push(a.file.path),n.length>=ce))break;b(n);return}b(C.slice(P,P+Math.ceil((d.current?.clientHeight??0)/Ne)+ce).map(n=>i(n)).filter(n=>!!n).slice(0,ce))},[b,D,C,V,P]);const W=S.useCallback(i=>{$(n=>{const a=new Set(n);return a.has(i)?a.delete(i):a.add(i),a})},[]),L=S.useCallback((i,n)=>{r(a=>{const c=new Set(a),k=de(i,n);return c.has(k)?c.delete(k):c.add(k),c})},[]),H=S.useMemo(()=>{const i=new Set;return y.forEach(n=>n.entries.forEach(a=>i.add(a.path))),Array.from(i)},[y]),X=H.length,T=h?o||h.paths.some(i=>t.has(i)):!1,Y=S.useCallback(async()=>{!m||o||H.length===0||(await m(H),N(!1))},[H,o,m]),K=S.useCallback(async()=>{!f||!h||T||(await f(h.paths),E(null))},[T,f,h]),G=S.useCallback((i,n)=>{const a=A.has(i.id),c=i.entries.length;return s.jsxs("div",{className:Z("sticky top-0 z-10 flex items-center gap-2 py-2",x,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(k=>k.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>W(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!a,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),s.jsx(R,{name:"arrow-down-s",className:Z("size-3.5 shrink-0 text-muted-foreground transition-transform",a&&"-rotate-90")})]})]})},[A,x,W]),O=S.useCallback((i,n,a)=>{const c=j.has(de(i.id,n.path)),k=n.files.map(_=>_.path),v=o||k.some(_=>t.has(_));return s.jsxs("div",{className:Z("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${a*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>L(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":c?l("gitView.changes.collapseDirectoryAria",{path:n.path}):l("gitView.changes.expandDirectoryAria",{path:n.path}),children:[c?s.jsx(R,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(R,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&f?s.jsx("button",{type:"button",onClick:()=>E({path:n.path,paths:k,count:k.length}),disabled:v,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":l("gitView.changes.revertDirectoryAria",{path:n.path}),title:l("gitView.changes.revertDirectoryTooltip"),children:v?s.jsx(R,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(R,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(_=>_.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[j,o,f,t,l,L]),B=S.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:Z("flex justify-end py-2",le),children:s.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>N(!0),disabled:o,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(R,{name:"arrow-go-back",className:"size-3.5"}),l("gitView.changes.revertAll")]})});const a=y[i.groupIndex];if(!a)return null;if(i.type==="header")return G(a,n);if(i.type==="directory")return O(a,i.directory,i.depth);const c=i.file;return s.jsx($e,{file:c,actionLabel:a.getActionLabel(c.path),actionSymbol:a.actionSymbol,onAction:()=>a.onActionFile(c.path),stats:e?.[c.path],onViewDiff:()=>a.onViewDiff(c.path),onRevert:()=>a.onRevertFile(c.path),isReverting:t.has(c.path)||o,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!g,showRevert:a.showRevertActions!==!1})},[e,o,g,O,G,t,l,y]),q=S.useCallback(i=>{const n=C[i],a=C[i-1];return!n||!a||n.type!=="file"&&n.type!=="directory"||a.type!=="file"&&a.type!=="directory"?!1:a.groupIndex===n.groupIndex},[C]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Ee,{ref:d,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:V?s.jsx("div",{style:{height:I.getTotalSize(),position:"relative"},children:u.map(i=>{const n=C[i.index];return n?s.jsx("div",{"data-index":i.index,ref:I.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:Z(q(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:B(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":l("gitView.changes.changedFilesAria"),children:C.map((i,n)=>s.jsx("div",{className:Z("relative",q(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:B(i,n===0)},i.key))})}),s.jsx(Ie,{containerRef:d,disableHorizontal:!0})]}),s.jsx(pe,{open:w,onOpenChange:i=>{!o&&!i&&N(!1)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertAllDialogTitle")}),s.jsx(ye,{children:X===1?l("gitView.changes.revertAllDescriptionSingle",{count:X}):l("gitView.changes.revertAllDescriptionPlural",{count:X})})]}),s.jsxs(ve,{children:[s.jsx(J,{variant:"outline",size:"sm",onClick:()=>N(!1),disabled:o,children:l("gitView.common.cancel")}),s.jsx(J,{variant:"destructive",size:"sm",onClick:()=>{Y()},disabled:o,children:l(o?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(pe,{open:!!h,onOpenChange:i=>{!T&&!i&&E(null)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(ye,{children:h?h.count===1?l("gitView.changes.revertDirectoryDescriptionSingle",{count:h.count,path:h.path}):l("gitView.changes.revertDirectoryDescriptionPlural",{count:h.count,path:h.path}):null})]}),s.jsxs(ve,{children:[s.jsx(J,{variant:"outline",size:"sm",onClick:()=>E(null),disabled:T,children:l("gitView.common.cancel")}),s.jsx(J,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:T||!h,children:l(T?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,ae=200,Ge=p=>{const e=oe.c(23),{value:t,onChange:o,onSubmit:x,placeholder:b,disabled:m,hasTouchInput:f,isMobile:l}=p,d=m===void 0?!1:m,z=f===void 0?!1:f,g=l===void 0?!1:l,{t:y}=Q(),A=S.useRef(null),$=Ce(Oe);let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{const u=A.current;if(!u)return;const P=document.activeElement===u,W=()=>{u.style.height=`${he}px`;const H=u.scrollHeight,X=Math.min(Math.max(H,he),ae);u.style.height=`${X}px`,u.style.overflowY=H>ae?"auto":"hidden",H>ae&&!P&&(u.scrollTop=u.scrollHeight)};W();const L=window.requestAnimationFrame(W);return()=>{window.cancelAnimationFrame(L)}},e[0]=j):j=e[0];let r;e[1]!==t?(r=[t],e[1]=t,e[2]=r):r=e[2],S.useLayoutEffect(j,r);let w;e[3]!==o?(w=u=>o(u.target.value),e[3]=o,e[4]=w):w=e[4];let N;e[5]!==x?(N=u=>{u.key==="Enter"&&(u.metaKey||u.ctrlKey)&&!u.shiftKey&&!u.altKey&&(u.preventDefault(),x?.())},e[5]=x,e[6]=N):N=e[6];let h;e[7]!==b||e[8]!==y?(h=b??y("gitView.commit.messagePlaceholder"),e[7]=b,e[8]=y,e[9]=h):h=e[9];const E=z?"on":"off",F=z?"sentences":"off",M=g||$,C=d&&"opacity-50";let D;e[10]!==C?(D=Z("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",C),e[10]=C,e[11]=D):D=e[11];let V;e[12]===Symbol.for("react.memo_cache_sentinel")?(V={minHeight:he,maxHeight:ae},e[12]=V):V=e[12];let I;return e[13]!==d||e[14]!==F||e[15]!==M||e[16]!==D||e[17]!==w||e[18]!==N||e[19]!==h||e[20]!==E||e[21]!==t?(I=s.jsx("textarea",{ref:A,value:t,onChange:w,onKeyDown:N,placeholder:h,rows:1,disabled:d,autoCorrect:E,autoCapitalize:F,spellCheck:M,className:D,style:V}),e[13]=d,e[14]=F,e[15]=M,e[16]=D,e[17]=w,e[18]=N,e[19]=h,e[20]=E,e[21]=t,e[22]=I):I=e[22],I};function Oe(p){return p.inputSpellcheckEnabled}const Ke=p=>{const e=oe.c(30),{highlights:t,onInsert:o}=p,{t:x}=Q();if(t.length===0)return null;let b;e[0]!==t||e[1]!==o?(b=()=>{o(t)},e[0]=t,e[1]=o,e[2]=b):b=e[2];const m=b;let f;e[3]!==x?(f=x("gitView.commit.aiHighlights.title"),e[3]=x,e[4]=f):f=e[4];let l;e[5]!==f?(l=s.jsx("p",{className:"typography-micro text-muted-foreground",children:f}),e[5]=f,e[6]=l):l=e[6];let d;e[7]!==x?(d=x("gitView.commit.aiHighlights.insertAria"),e[7]=x,e[8]=d):d=e[8];let z;e[9]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(R,{name:"arrow-down",className:"size-4"}),e[9]=z):z=e[9];let g;e[10]!==m||e[11]!==d?(g=s.jsx(me,{asChild:!0,children:s.jsx(J,{variant:"ghost",size:"icon",className:"size-6",onClick:m,"aria-label":d,children:z})}),e[10]=m,e[11]=d,e[12]=g):g=e[12];let y;e[13]!==x?(y=x("gitView.commit.aiHighlights.insertTooltip"),e[13]=x,e[14]=y):y=e[14];let A;e[15]!==y?(A=s.jsx(ue,{sideOffset:8,children:y}),e[15]=y,e[16]=A):A=e[16];let $;e[17]!==g||e[18]!==A?($=s.jsxs(fe,{children:[g,A]}),e[17]=g,e[18]=A,e[19]=$):$=e[19];let j;e[20]!==l||e[21]!==$?(j=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l,$]}),e[20]=l,e[21]=$,e[22]=j):j=e[22];let r;e[23]!==t?(r=t.map(Be),e[23]=t,e[24]=r):r=e[24];let w;e[25]!==r?(w=s.jsx("ul",{className:"space-y-1",children:r}),e[25]=r,e[26]=w):w=e[26];let N;return e[27]!==j||e[28]!==w?(N=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[j,w]}),e[27]=j,e[28]=w,e[29]=N):N=e[29],N};function Be(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const qe=p=>{const e=oe.c(80),{stagedCount:t,commitMessage:o,onCommitMessageChange:x,generatedHighlights:b,onInsertHighlights:m,onGenerateMessage:f,isGeneratingMessage:l,onCommit:d,onCommitAndPush:z,commitAction:g,hasPendingIndexMutation:y,gitmojiEnabled:A,onOpenGitmojiPicker:$}=p,j=y===void 0?!1:y,{t:r}=Q(),w=t>0;let N;e[0]!==g||e[1]!==o||e[2]!==j||e[3]!==w?(N=o.trim()&&w&&g===null&&!j,e[0]=g,e[1]=o,e[2]=j,e[3]=w,e[4]=N):N=e[4];const h=N,{isMobile:E,hasTouchInput:F}=Te();let M;e[5]!==r?(M=r("gitView.commit.title"),e[5]=r,e[6]=M):M=e[6];let C;e[7]!==M?(C=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:M}),e[7]=M,e[8]=C):C=e[8];let D;e[9]!==w||e[10]!==r?(D=w?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:r("gitView.commit.stageFilesHint")}),e[9]=w,e[10]=r,e[11]=D):D=e[11];let V;e[12]!==C||e[13]!==D?(V=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[C,D]}),e[12]=C,e[13]=D,e[14]=V):V=e[14];let I;e[15]!==b||e[16]!==m?(I=s.jsx(Ke,{highlights:b,onInsert:m}),e[15]=b,e[16]=m,e[17]=I):I=e[17];let u;e[18]!==h||e[19]!==l||e[20]!==d?(u=()=>{h&&!l&&d()},e[18]=h,e[19]=l,e[20]=d,e[21]=u):u=e[21];let P;e[22]!==r?(P=r("gitView.commit.messagePlaceholder"),e[22]=r,e[23]=P):P=e[23];const W=g!==null;let L;e[24]!==o||e[25]!==F||e[26]!==E||e[27]!==x||e[28]!==W||e[29]!==u||e[30]!==P?(L=s.jsx(Ge,{value:o,onChange:x,onSubmit:u,placeholder:P,disabled:W,hasTouchInput:F,isMobile:E}),e[24]=o,e[25]=F,e[26]=E,e[27]=x,e[28]=W,e[29]=u,e[30]=P,e[31]=L):L=e[31];let H;e[32]!==A||e[33]!==$||e[34]!==r?(H=A&&s.jsxs(J,{variant:"outline",size:"sm",onClick:$,className:"w-fit",type:"button",children:[s.jsx(R,{name:"emotion-happy",className:"size-4"}),r("gitView.commit.addGitmoji")]}),e[32]=A,e[33]=$,e[34]=r,e[35]=H):H=e[35];const X=l||g!==null||j||t===0;let T;e[36]!==r?(T=r("gitView.commit.generateAria"),e[36]=r,e[37]=T):T=e[37];let Y;e[38]!==l?(Y=l?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"ai-generate-2",className:"size-4 text-primary"}),e[38]=l,e[39]=Y):Y=e[39];let K;e[40]!==r?(K=r("gitView.commit.generate"),e[40]=r,e[41]=K):K=e[41];let G;e[42]!==K?(G=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=G):G=e[43];let O;e[44]!==f||e[45]!==X||e[46]!==T||e[47]!==Y||e[48]!==G?(O=s.jsxs(J,{variant:"outline",size:"sm",onClick:f,disabled:X,type:"button","aria-label":T,className:"commit-actions__btn",children:[Y,G]}),e[44]=f,e[45]=X,e[46]=T,e[47]=Y,e[48]=G,e[49]=O):O=e[49];let B;e[50]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx("div",{className:"flex-1"}),e[50]=B):B=e[50];const q=!h||l;let i;e[51]!==r?(i=r("gitView.commit.commitAria"),e[51]=r,e[52]=i):i=e[52];let n;e[53]!==g||e[54]!==r?(n=g==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:r("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(R,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:r("gitView.commit.commit")})]}),e[53]=g,e[54]=r,e[55]=n):n=e[55];let a;e[56]!==d||e[57]!==q||e[58]!==i||e[59]!==n?(a=s.jsx(J,{size:"sm",variant:"outline",onClick:d,disabled:q,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=d,e[57]=q,e[58]=i,e[59]=n,e[60]=a):a=e[60];let c;e[61]!==h||e[62]!==g||e[63]!==l||e[64]!==E||e[65]!==z||e[66]!==r?(c=E?s.jsxs(fe,{children:[s.jsx(me,{asChild:!0,children:s.jsx(J,{variant:"default",size:"sm",onClick:()=>z(),disabled:!h||l,className:"h-7 w-7 p-0","aria-label":r("gitView.commit.pushAria"),children:g==="commitAndPush"?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(ue,{side:"top",children:s.jsx("p",{children:r("gitView.commit.push")})})]}):s.jsx(J,{size:"sm",variant:"default",onClick:()=>z(),disabled:!h||l,className:"commit-actions__btn","aria-label":r("gitView.commit.pushAria"),children:g==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:r("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(R,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:r("gitView.commit.push")})]})}),e[61]=h,e[62]=g,e[63]=l,e[64]=E,e[65]=z,e[66]=r,e[67]=c):c=e[67];let k;e[68]!==O||e[69]!==a||e[70]!==c?(k=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[O,B,a,c]}),e[68]=O,e[69]=a,e[70]=c,e[71]=k):k=e[71];let v;e[72]!==L||e[73]!==H||e[74]!==k||e[75]!==I?(v=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[I,L,H,k]}),e[72]=L,e[73]=H,e[74]=k,e[75]=I,e[76]=v):v=e[76];let _;return e[77]!==v||e[78]!==V?(_=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[V,v]}),e[77]=v,e[78]=V,e[79]=_):_=e[79],_};export{Ye as C,qe as a};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{R as o,j as n,f as he}from"./vendor-react-BUCujlKS.js";import{X as wn,a as ct,u as Y,F as Pe}from"./index-DW_E3rnL.js";import{f as ge,V as Tt,ab as yn,ac as vn,b5 as jn,ae as Sn,ad as Nn,af as Fn,ag as Z,y as Ft,k as kn,hQ as Cn,hR as Rn,hS as Dn,cC as An,t as Ke,hT as En,an as Ve,B as pe,I as A,h as ue,a6 as Bn,a7 as Vn,a8 as Ln,hD as Mt,hU as Tn,fD as Mn,fI as Ge,a0 as In,c2 as at,ap as It,am as _n,b1 as On,b3 as zn,fJ as Pn,b4 as Gn}from"./useAppFontEffects-CjrntdL0.js";import{b as Kn}from"./runtimeEndpointReset-CjhvxLH0.js";import{c as $n,p as Hn}from"./vendor-zustand-BAGL70zf.js";import{P as Wn}from"./PierreDiffViewer-B7m3f0d7.js";import{u as Un,v as qn,g as Xn,W as Jn}from"./main-Bv5Pkngh.js";import{f as Qn}from"./patchFileDiff-yNfWXN4E.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zod-BLfBSgBh.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BeMD8X_w.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-C3fjDbdg.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DFZik9R2.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./web-components-Bhg83tjf.js";import"./computeVirtualFileMetrics-BMIRgMHv.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-DD8lDVej.js";import"./isDiffPlainText-BqayB8d3.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-CDEuSlPH.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./useRootScrollLock-BHYPkrLv.js";import"./scheduledTasksApi-DLW0mkQK.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const Yn="aiworker.git-base-branch",Zn=100,$e=(s,e)=>JSON.stringify([ct(),s,e]),kt=$n()(Hn((s,e)=>({overrides:{},getOverride:(i,a)=>!i||!a?null:e().overrides[$e(i,a)]??null,setOverride:(i,a,d)=>{!i||!a||!d||s(f=>{const h=$e(i,a),x=Object.entries({...f.overrides,[h]:d});for(;x.length>Zn;)x.shift();return{overrides:Object.fromEntries(x)}})},clearOverride:(i,a)=>{!i||!a||s(d=>{const f=$e(i,a);if(!(f in d.overrides))return d;const h={...d.overrides};return delete h[f],{overrides:h}})}}),{name:Yn,storage:wn(),partialize:s=>({overrides:s.overrides})})),es=(s,e)=>!!s&&e!==null&&s!==e,ts=(s,e,i,a)=>i?s===null||a&&e===null?!0:e!==null&&s===e:!1,ns=(s,e)=>s==="branch"&&!e?"working":s,ss=(s,e,i)=>JSON.stringify([s,e,i]),rs=(s,e,i,a,d,f)=>{const h=o.useRef({directory:"",attempts:0}),[x,u]=o.useState(()=>({directory:"",exhausted:!1})),p=o.useRef(d);p.current=d;const b=!!s&&x.directory===s&&x.exhausted;return o.useEffect(()=>{if(!s||!e||a||i)return;const w=h.current.directory===s?h.current.attempts:0;if(w>=f){x.directory===s&&x.exhausted||u({directory:s,exhausted:!0});return}h.current={directory:s,attempts:w+1},p.current()},[s,x,a,e,i,f]),b},is=(s,e,i,a)=>{const[d,f]=o.useState(()=>new Map),h=o.useRef(d);h.current=d;const x=o.useRef(i);x.current=i;const u=o.useCallback((p,b)=>{const w=new Map(h.current);if(b===null){if(!w.delete(p))return}else w.set(p,b);h.current=w,f(w)},[]);return o.useEffect(()=>{s&&(h.current=new Map,f(h.current))},[s]),o.useEffect(()=>{const p=x.current;if(!s||!p||!e)return;let b=!1;const w=new Set;for(const y of e.split("\0"))h.current.has(y)||(w.add(y),u(y,a),p(y).then(j=>{b||(w.delete(y),u(y,j))}).catch(()=>{b||(w.delete(y),u(y,null))}));return()=>{b=!0;for(const y of w)u(y,null)}},[e,a,s,u]),d},Ct=(s,e)=>{if(e.length===0)return null;let i=null,a=null;for(const f of e)f.top<=s?(!i||f.top>i.top)&&(i=f):(!a||f.top<a.top)&&(a=f);const d=i??a;return d?{path:d.path,topOffset:d.top-s}:null},os=(s,e,i,a)=>Math.min(Math.max(0,a),Math.max(0,s+i-e)),Rt=s=>{if(!s)return null;const e=s.split(`
|
|
2
|
-
`);let i=null;for(const a of e){const d=a.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(d){const f=Number.parseInt(d[1]??"",10);i=Number.isFinite(f)&&f>=1?f:null;continue}if(i!==null){if(a.startsWith(" ")){i+=1;continue}if(a.startsWith("+"))return i;if(a.startsWith("-"))return Math.max(1,i)}}return null},as=1100,ls=15e3,Dt=500,At=300,cs=1e6,us=3,fs=s=>s<=6?s:s<=12?6:s<=25?4:2,ds={original:"",modified:"",isBinary:!1,contextMode:"patch"},ps=3,ms=o.memo(()=>{const s=he.c(4),{t:e}=ge();let i;s[0]!==e?(i=e("diffView.binary.unavailable"),s[0]=e,s[1]=i):i=s[1];let a;return s[2]!==i?(a=n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:i})}),s[2]=i,s[3]=a):a=s[3],a}),_t={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},hs=_t.M,gs=s=>{const e=s.index?.trim(),i=s.working_dir?.trim();return e&&e!=="?"?e.charAt(0):i?i.charAt(0):e?.charAt(0)||i?.charAt(0)||"M"},Ot=s=>{const e=gs(s);return _t[e]??hs},xs=s=>{const{index:e,working_dir:i}=s;return e==="A"||i==="A"||e==="?"||i==="?"},Et=s=>{const e=s.index?.trim();return!!(e&&e!=="?")},Bt=s=>!!s.working_dir?.trim()||s.index==="?",bs=(s,e)=>Mn(s,e),Vt=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/,""),Lt=(s,e)=>{const i=s.split(`
|
|
3
|
-
`),a=e.split(`
|
|
4
|
-
`),d=Math.min(i.length,a.length);for(let f=0;f<d;f+=1)if(i[f]!==a[f])return f+1;return a.length>i.length?i.length+1:i.length>a.length?Math.max(1,a.length):1},ws=s=>/^Binary files .+ differ$/m.test(s)||/^GIT binary patch$/m.test(s),ys=s=>Array.isArray(s)?s.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],vs=s=>s==="added"?"A":s==="deleted"?"D":"M",lt=(s,e,i)=>ws(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:i}:{original:"",modified:"",patch:e,fileDiff:Qn(s,e),contextMode:i},zt=(s,e,i)=>{const a=s??0,d=e??0;return!a&&!d?null:n.jsxs("span",{className:ue("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",i?.className),children:[a?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",a]}):null,d?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",d]}):null]})},js=o.memo(s=>{const e=he.c(58),{scope:i,workingCount:a,stagedCount:d,turnCount:f,branchCount:h,showBranchOption:x,onScopeChange:u}=s,{t:p}=ge(),[b,w]=o.useState(!1),y=i==="staged"?d:i==="turn"?f:i==="branch"?h??0:a;let j;e[0]!==i||e[1]!==p?(j=p(i==="staged"?"diffView.scope.staged":i==="turn"?"diffView.scope.lastTurn":i==="branch"?"diffView.scope.branch":"diffView.scope.changed"),e[0]=i,e[1]=p,e[2]=j):j=e[2];const P=j;let m;e[3]!==p?(m=p("diffView.scope.selectorAria"),e[3]=p,e[4]=m):m=e[4];let le;e[5]!==y?(le=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",y]}),e[5]=y,e[6]=le):le=e[6];let k;e[7]!==P||e[8]!==le?(k=n.jsxs("span",{className:"whitespace-nowrap",children:[P,le]}),e[7]=P,e[8]=le,e[9]=k):k=e[9];let E;e[10]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(A,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=E):E=e[10];let L;e[11]!==m||e[12]!==k?(L=n.jsx(On,{asChild:!0,children:n.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":m,children:[k,E]})}),e[11]=m,e[12]=k,e[13]=L):L=e[13];let W;e[14]!==u?(W=B=>{(B==="working"||B==="staged"||B==="turn"||B==="branch")&&(u?.(B),w(!1))},e[14]=u,e[15]=W):W=e[15];let N;e[16]!==p?(N=p("diffView.scope.changed"),e[16]=p,e[17]=N):N=e[17];let ee;e[18]!==N?(ee=n.jsx("span",{children:N}),e[18]=N,e[19]=ee):ee=e[19];let U;e[20]!==a?(U=n.jsx("span",{className:"typography-meta text-muted-foreground",children:a}),e[20]=a,e[21]=U):U=e[21];let q;e[22]!==U||e[23]!==ee?(q=n.jsx(Ge,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[ee,U]})}),e[22]=U,e[23]=ee,e[24]=q):q=e[24];let G;e[25]!==p?(G=p("diffView.scope.staged"),e[25]=p,e[26]=G):G=e[26];let K;e[27]!==G?(K=n.jsx("span",{children:G}),e[27]=G,e[28]=K):K=e[28];let te;e[29]!==d?(te=n.jsx("span",{className:"typography-meta text-muted-foreground",children:d}),e[29]=d,e[30]=te):te=e[30];let I;e[31]!==K||e[32]!==te?(I=n.jsx(Ge,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[K,te]})}),e[31]=K,e[32]=te,e[33]=I):I=e[33];let _;e[34]!==p?(_=p("diffView.scope.lastTurn"),e[34]=p,e[35]=_):_=e[35];let V;e[36]!==_?(V=n.jsx("span",{children:_}),e[36]=_,e[37]=V):V=e[37];let O;e[38]!==f?(O=n.jsx("span",{className:"typography-meta text-muted-foreground",children:f}),e[38]=f,e[39]=O):O=e[39];let ne;e[40]!==V||e[41]!==O?(ne=n.jsx(Ge,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[V,O]})}),e[40]=V,e[41]=O,e[42]=ne):ne=e[42];let T;e[43]!==h||e[44]!==x||e[45]!==p?(T=x?n.jsx(Ge,{value:"branch",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:p("diffView.scope.branch")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:h??"…"})]})}):null,e[43]=h,e[44]=x,e[45]=p,e[46]=T):T=e[46];let se;e[47]!==i||e[48]!==q||e[49]!==I||e[50]!==ne||e[51]!==T||e[52]!==W?(se=n.jsx(zn,{align:"start",className:"w-40",children:n.jsxs(Pn,{value:i,onValueChange:W,children:[q,I,ne,T]})}),e[47]=i,e[48]=q,e[49]=I,e[50]=ne,e[51]=T,e[52]=W,e[53]=se):se=e[53];let re;return e[54]!==b||e[55]!==se||e[56]!==L?(re=n.jsxs(Gn,{open:b,onOpenChange:w,children:[L,se]}),e[54]=b,e[55]=se,e[56]=L,e[57]=re):re=e[57],re}),Ss=o.memo(s=>{const e=he.c(11),{changedFiles:i,selectedFile:a,onSelectFile:d}=s,{t:f}=ge();if(i.length===0)return null;let h;if(e[0]!==i||e[1]!==d||e[2]!==a||e[3]!==f){let u;e[5]!==d||e[6]!==a||e[7]!==f?(u=p=>{const b=Ot(p),w=a===p.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>d(p.path),className:ue("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",w?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(It,{filePath:p.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:b.color},title:f(b.descriptionKey),"aria-label":f(b.descriptionKey),children:b.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:p.path,children:p.path}),zt(p.insertions,p.deletions)]})},p.path)},e[5]=d,e[6]=a,e[7]=f,e[8]=u):u=e[8],h=i.map(u),e[0]=i,e[1]=d,e[2]=a,e[3]=f,e[4]=h}else h=e[4];let x;return e[9]!==h?(x=n.jsx(at,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:h})}),e[9]=h,e[10]=x):x=e[10],x}),Ns=o.memo(s=>{const e=he.c(20),{filePath:i,diff:a,renderSideBySide:d}=s,{t:f}=ge(),h=a.original.length>0,x=a.modified.length>0,u=d?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",p=d?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={contain:"layout"},e[0]=b):b=e[0];let w;e[1]!==a.original||e[2]!==i||e[3]!==h||e[4]!==p||e[5]!==d||e[6]!==f?(w=h&&n.jsxs("div",{className:p,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f("diffView.image.original")}),n.jsx("img",{src:a.original,alt:f("diffView.image.originalAlt",{path:i}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=a.original,e[2]=i,e[3]=h,e[4]=p,e[5]=d,e[6]=f,e[7]=w):w=e[7];let y;e[8]!==a.modified||e[9]!==i||e[10]!==x||e[11]!==h||e[12]!==p||e[13]!==d||e[14]!==f?(y=x&&n.jsxs("div",{className:p,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f(h?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:a.modified,alt:f("diffView.image.modifiedAlt",{path:i}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=a.modified,e[9]=i,e[10]=x,e[11]=h,e[12]=p,e[13]=d,e[14]=f,e[15]=y):y=e[15];let j;return e[16]!==u||e[17]!==w||e[18]!==y?(j=n.jsx("div",{className:"w-full overflow-auto p-4",style:b,children:n.jsxs("div",{className:u,children:[w,y]})}),e[16]=u,e[17]=w,e[18]=y,e[19]=j):j=e[19],j}),Fs=o.memo(s=>{const e=he.c(16),{filePath:i,diff:a,renderSideBySide:d,wrapLines:f}=s;let h;e[0]!==i?(h=_n(i)||"text",e[0]=i,e[1]=h):h=e[1];const x=h;if(a.isBinary){let b;return e[2]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(ms,{}),e[2]=b):b=e[2],b}if(Ve(i)){let b;return e[3]!==a||e[4]!==i||e[5]!==d?(b=n.jsx(Ns,{filePath:i,diff:a,renderSideBySide:d}),e[3]=a,e[4]=i,e[5]=d,e[6]=b):b=e[6],b}let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u={contain:"layout"},e[7]=u):u=e[7];let p;return e[8]!==a.fileDiff||e[9]!==a.modified||e[10]!==a.original||e[11]!==i||e[12]!==x||e[13]!==d||e[14]!==f?(p=n.jsx("div",{className:"w-full",style:u,children:n.jsx(Wn,{original:a.original,modified:a.modified,fileDiff:a.fileDiff,language:x,fileName:i,renderSideBySide:d,wrapLines:f,layout:"inline"})}),e[8]=a.fileDiff,e[9]=a.modified,e[10]=a.original,e[11]=i,e[12]=x,e[13]=d,e[14]=f,e[15]=p):p=e[15],p}),ks=o.memo(s=>{const e=he.c(7),{filePath:i,staged:a,busyAction:d,disabled:f,onAction:h}=s,{t:x}=ge();let u;return e[0]!==d||e[1]!==f||e[2]!==i||e[3]!==h||e[4]!==a||e[5]!==x?(u=n.jsx("div",{className:"flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:a?n.jsx(ot,{label:x("gitView.changes.unstageFileAria",{path:i}),icon:"arrow-go-back",loading:d==="unstage",disabled:f,onClick:()=>h("unstage")}):n.jsxs(n.Fragment,{children:[n.jsx(ot,{label:x("gitView.changes.revertFileAria",{path:i}),icon:"arrow-go-back",loading:d==="discard",disabled:f,tone:"failure",onClick:()=>h("discard")}),n.jsx(ot,{label:x("gitView.changes.stageFileAria",{path:i}),icon:"add",loading:d==="stage",disabled:f,tone:"success",onClick:()=>h("stage")})]})}),e[0]=d,e[1]=f,e[2]=i,e[3]=h,e[4]=a,e[5]=x,e[6]=u):u=e[6],u}),ot=s=>{const e=he.c(14),{label:i,icon:a,loading:d,disabled:f,tone:h,onClick:x}=s,u=h==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",p=h==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]";let b;e[0]!==u||e[1]!==p?(b=ue("h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100",u,p),e[0]=u,e[1]=p,e[2]=b):b=e[2];let w;e[3]!==x?(w=P=>{P.stopPropagation(),x()},e[3]=x,e[4]=w):w=e[4];let y;e[5]!==a||e[6]!==d?(y=d?n.jsx(A,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(A,{name:a,className:a==="add"?"size-4":"size-3.5"}),e[5]=a,e[6]=d,e[7]=y):y=e[7];let j;return e[8]!==f||e[9]!==i||e[10]!==b||e[11]!==w||e[12]!==y?(j=n.jsx(pe,{variant:"ghost",size:"sm",className:b,disabled:f,title:i,"aria-label":i,onClick:w,children:y}),e[8]=f,e[9]=i,e[10]=b,e[11]=w,e[12]=y,e[13]=j):j=e[13],j},Cs=o.memo(({directory:s,file:e,layout:i,wrapLines:a,isSelected:d,isExpanded:f,isMounted:h,onSelect:x,onExpandedChange:u,registerSectionRef:p,showOpenInEditorAction:b=!1,isOpeningInEditor:w=!1,onOpenInEditor:y,staged:j=!1,loadFullFiles:P=!1,initialDiffData:m=null,readOnlyActions:le=!1})=>{const{t:k}=ge(),{git:E}=Tt(),L=Z(o.useCallback(c=>c.directories.get(s)?.diffCache.get(e.path)??null,[s,e.path])),W=Z(c=>c.setDiff),N=Z(c=>c.fetchStatus),ee=Y(c=>c.setDiffFileLayout),[U,q]=o.useState(0),[G,K]=o.useState(null),[te,I]=o.useState(!1),[_,V]=o.useState(null),[O,ne]=o.useState(!1),[T,se]=o.useState(null),[re,B]=o.useState(null),ie=o.useRef(null),He=o.useRef(null),ce=o.useMemo(()=>Ot(e),[e]),fe=i==="side-by-side",xe=P?"full":"patch",Ce=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,X=o.useMemo(()=>m||(j?re:T||(L?{original:L.original,modified:L.modified,isBinary:L.isBinary,contextMode:"full"}:null)),[L,m,T,j,re]),Re=X?.contextMode===xe,We=o.useCallback(c=>{He.current=c,p(e.path,c)},[e.path,p]),Le=o.useCallback(c=>{u(e.path,c)},[e.path,u]),be=o.useCallback(()=>{x(e.path)},[e.path,x]);o.useEffect(()=>{j?B(null):se(null),K(null),ie.current=null},[Ce,j]),o.useEffect(()=>{if(!f||!h)return;if(!s||m||X&&Re){ie.current=null,I(!1);return}const c=`${s}::${e.path}::${j?"staged":"unstaged"}::${Ce}::${xe}::${U}`;if(ie.current===c)return;ie.current=c,K(null),I(!0);let C=!1;const oe=ct(),Me=P?cs:us,de=Ve(e.path)?E.getGitFileDiff(s,{path:e.path,staged:j}):E.getGitDiff(s,{path:e.path,staged:j,contextLines:Me}),De=ls,Ae=new Promise(($,J)=>{setTimeout(()=>J(new Error(`Timed out after ${De}ms`)),De)});return Promise.race([de,Ae]).then($=>{if(!C){if("diff"in $){const J=lt(e.path,$.diff,xe);j?B(J):se(J)}else{const J={original:$.original??"",modified:$.modified??"",isBinary:$.isBinary,contextMode:"full"};j?B(J):W(s,e.path,J,oe)}I(!1)}}).catch($=>{if(C)return;const J=$ instanceof Error?$.message:String($);K(J),I(!1)}),()=>{C=!0,ie.current===c&&(ie.current=null)}},[xe,X,Re,U,s,e.path,Ce,E,m,f,h,P,W,j]);const we=o.useCallback(()=>{Le(!f),be()},[Le,be,f]),Te=o.useCallback(async c=>{if(!(!s||_!==null)){V(c);try{c==="stage"?await E.stageGitFile(s,e.path):c==="unstage"?await E.unstageGitFile(s,e.path):await E.revertGitFile(s,e.path,{scope:"working"}),q(C=>C+1),await N(s,E)}catch(C){const oe=c==="unstage"?"gitView.toast.unstageFileFailed":c==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.revertFailed";Ke.error(C instanceof Error?C.message:k(oe))}finally{V(C=>C===c?null:C)}}},[s,N,e.path,_,E,k]);return n.jsxs("div",{ref:We,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[n.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:n.jsxs("div",{role:"button",tabIndex:0,onClick:we,onKeyDown:c=>{c.target===c.currentTarget&&(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),we())},className:ue("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",d?"bg-[var(--interactive-selection)]/35":null),children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:f?n.jsx(A,{name:"arrow-down-s",className:"size-4"}):n.jsx(A,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:ce.color},title:k(ce.descriptionKey),"aria-label":k(ce.descriptionKey),children:ce.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(It,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const c=e.path.lastIndexOf("/");if(c===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:e.path});const C=e.path.slice(0,c),oe=e.path.slice(c+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:C}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:oe})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[zt(e.insertions,e.deletions),b&&y?n.jsx(pe,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:k("diffView.actions.openFileInEditorAtChange"),onClick:c=>{c.stopPropagation(),y(e.path,X)},disabled:w,children:w?n.jsx(A,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(A,{name:"edit",className:"size-3.5"})}):null,n.jsx(Mt,{mode:fe?"side-by-side":"unified",onModeChange:c=>{const C=c==="side-by-side"?"side-by-side":"inline";ee(e.path,C)},className:"opacity-70"})]})]})}),f&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!h&&!G?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,G?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:G}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>q(c=>c+1),children:k("diffView.actions.retry")})]}):null,h&&te&&!X&&!G?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),k("diffView.state.loadingDiff")]}):null,h&&X&&!O&&e.insertions+e.deletions>Dt?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.largeDiff",{count:e.insertions+e.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:k("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>ne(!0),children:k("diffView.actions.renderAnyway")})]}):null,h&&X&&(O||e.insertions+e.deletions<=Dt)?n.jsxs(n.Fragment,{children:[n.jsx(Fs,{filePath:e.path,diff:X,renderSideBySide:fe,wrapLines:a}),n.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20",children:n.jsx("div",{className:"pointer-events-auto",children:le?null:n.jsx(ks,{filePath:e.path,staged:j,busyAction:_,disabled:_!==null,onAction:Te})})})]}):null]})]})}),Ki=({hideStackedFileSidebar:s=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:i=!1,showOpenInEditorAction:a=!1,diffScope:d="all",onDiffScopeChange:f,targetFilePath:h=null,flushContent:x=!1})=>{const{t:u}=ge(),{git:p,files:b}=Tt(),w=yn(),{rootIsGitRepo:y,gitDirectory:j,nestedRepos:P}=vn(w??null),m=j??w,le=Y(t=>t.openContextSurface),k=Un(t=>t.requestSource),{screenWidth:E,isMobile:L}=jn(),W=Sn(m??null),N=Nn(m??null),ee=Fn(m??null),U=Z(t=>t.setActiveDirectory),q=Z(t=>t.ensureStatus),G=Z(t=>t.selectNestedRepo),K=Z(t=>t.fetchStatus),te=Z(t=>t.fetchBranches),I=Z(t=>t.clearDiffCache),_=Z(t=>t.setDiff),[V,O]=o.useState(null),[ne,T]=o.useState(!1),[se,re]=o.useState(null),[B,ie]=o.useState(()=>new Set),[He,ce]=o.useState(()=>new Set),[fe,xe]=o.useState(!1),[Ce,X]=o.useState(0),[Re,We]=o.useState(()=>new Map),[Le,be]=o.useState(!1),[we,Te]=o.useState(!1),[c,C]=o.useState(d);o.useEffect(()=>{C(d)},[d]);const oe=Y(t=>t.pendingDiffFile),Me=Y(t=>t.pendingDiffStaged),de=Y(t=>t.pendingDiffScope),De=Y(t=>t.setPendingDiffFile),Ae=Y(t=>t.diffLayoutPreference),$=Y(t=>t.diffFileLayout),J=Y(t=>t.setDiffFileLayout),ut=Y(t=>t.diffWrapLines),Pt=Y(t=>t.setDiffWrapLines),ft=Y(t=>t.openContextFileAtLine),ye=Ft(t=>t.currentSessionId),Ue=kn(ye??"",w??void 0),qe=ut,Xe=c==="staged"?!0:c==="working"?!1:null,Ie=Xe??ne,Je=L||E<=768,Gt=!!ye&&c!=="turn"&&!Je&&!Pe(),Kt=c!=="turn"&&!Je&&!Pe(),$t=!s&&!Je&&E>=1024,ve=o.useRef(null),Ee=o.useRef(new Map),me=o.useRef(null),z=o.useRef(null),je=o.useRef(!1),Se=o.useRef(null),dt=o.useRef(null),Qe=o.useRef(null),Ye=o.useRef(null),pt=o.useCallback(()=>{const t=ve.current;if(!t)return null;const r=t.getBoundingClientRect().top,l=[];for(const[g,v]of Ee.current)v&&l.push({path:g,top:v.getBoundingClientRect().top});return Ct(r,l)},[]),Ne=o.useCallback(()=>{me.current=null,je.current=!1,re(null),z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null)},[]),Fe=o.useCallback(t=>{ie(r=>{if(r.has(t))return r;const l=new Set(r);return l.add(t),l})},[]),Be=o.useMemo(()=>{for(let t=Ue.length-1;t>=0;t-=1){const r=Ue[t];if(r.role==="user")return ys(r.summary?.diffs)}return[]},[Ue]),Ht=o.useMemo(()=>{const t=new Map;for(const r of Be)if(r.file){if(typeof r.patch=="string"){t.set(r.file,lt(r.file,r.patch,"patch"));continue}t.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return t},[Be]),Wt=o.useMemo(()=>N?.files?N.files.filter(Bt).length:0,[N]),Ut=o.useMemo(()=>N?.files?N.files.filter(Et).length:0,[N]),qt=Be.length,R=N?.current??null,ke=Z(t=>m?t.directories.get(m)?.branches??null:null),Xt=Z(t=>m?t.directories.get(m)?.isLoadingBranches??!1:!1),Jt=o.useCallback(()=>{m&&te(m,p)},[m,te,p]),Qt=rs(m??null,W!==!1,Xt,!!ke,Jt,ps),mt=o.useMemo(()=>{const t=N?.tracking?.trim().split("/")[0];return(t&&ke?.defaultBranches?.[t])??ke?.defaultBranches?.origin??null},[ke,N?.tracking]),Ze=!Pe()&&es(R,mt),Yt=N!==null,ht=Pe()||Qt||ts(R,mt,Yt,ke!==null),Zt=kt(t=>t.setOverride),en=kt(o.useCallback(t=>m&&R?t.overrides[$e(m,R)]??null:null,[R,m])),[tn,et]=o.useState(null),[nn,tt]=o.useState(!1),[gt,sn]=o.useState("");o.useEffect(()=>{const t=ns(c,!ht);t!==c&&(C(t),t==="working"&&f?.("working"))},[c,ht,f]),o.useEffect(()=>{if(!Ze||!m||!R){et(null),tt(!1);return}let t=!1;return tt(!1),Cn(m,R).then(r=>{t||et(r.base)}).catch(()=>{t||et(null)}).finally(()=>{t||tt(!0)}),()=>{t=!0}},[R,m,Ze]);const ae=en??tn,[_e,xt]=o.useState(null),[bt,wt]=o.useState(null),Oe=o.useRef(0),nt=o.useCallback(()=>{if(!m||!R||!ae)return;const t=Oe.current+1;Oe.current=t,xt(null),wt(null),Rn(m,{base:ae,head:R}).then(r=>{Oe.current===t&&xt(r)}).catch(r=>{Oe.current===t&&wt(r instanceof Error?r.message:u("diffView.branch.loadError"))})},[ae,R,m,u]);o.useEffect(()=>{c==="branch"&&nt()},[c,nt]);const yt=c==="branch"&&m&&R&&ae?ss(m,ae,R):null,rn=o.useMemo(()=>c==="branch"?Array.from(B).sort().join("\0"):"",[c,B]),on=o.useCallback(t=>!m||!ae||!R?Promise.reject(new Error("branch range is unavailable")):Dn(m,{base:ae,head:R,path:t}).then(r=>lt(t,r.diff,"patch")),[ae,R,m]),an=is(yt,rn,yt?on:null,ds),ln=_e?.length??null,S=o.useMemo(()=>{if(c==="branch")return(_e??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:0,deletions:0,isNew:l.status==="A"})).sort((l,g)=>l.path.localeCompare(g.path));if(c==="turn")return Be.map(l=>({path:l.file??"",index:"",working_dir:vs(l.status),insertions:l.additions??0,deletions:l.deletions??0,isNew:l.status==="added"})).filter(l=>l.path).sort((l,g)=>l.path.localeCompare(g.path));if(!N?.files)return[];const t=N.diffStats??{},r=c==="staged"?Et:c==="working"?Bt:()=>!0;return N.files.filter(r).map(l=>({...l,insertions:t[l.path]?.insertions??0,deletions:t[l.path]?.deletions??0,isNew:xs(l)})).sort((l,g)=>l.path.localeCompare(g.path))},[c,_e,Be,N]),st=o.useMemo(()=>S.map(t=>t.path).join("\0"),[S]);o.useEffect(()=>{const t=st?st.split("\0"):[],r=new Set(t),l=`${m??""}:${c}:${e?"collapsed":"default"}`,g=dt.current!==l;dt.current=l,ie(v=>{if(g){const D=e?0:fs(t.length);return new Set(t.slice(0,D))}let M=!1;const F=new Set;for(const D of v){if(!r.has(D)){M=!0;continue}F.add(D)}return M?F:v}),ce(v=>{if(g)return new Set;let M=!1;const F=new Set;for(const D of v){if(!r.has(D)){M=!0;continue}F.add(D)}return M?F:v})},[c,st,m,e]);const vt=o.useCallback(()=>{Se.current=null;const t=ve.current;if(!t)return;const r=t.getBoundingClientRect(),l=r.top-At,g=r.bottom+At,v={},M=[];for(const[F,D]of Ee.current){if(!D)continue;const H=D.getBoundingClientRect();M.push({path:F,top:H.top}),B.has(F)&&(H.bottom<l||H.top>g||(v[F]=!0))}Qe.current=Ct(r.top,M),ce(F=>{let D=!1;const H=new Set(F);for(const Nt of Object.keys(v))H.has(Nt)||(H.add(Nt),D=!0);return D?H:F})},[B]),Q=o.useCallback(()=>{typeof window>"u"||Se.current===null&&(Se.current=window.requestAnimationFrame(vt))},[vt]);o.useEffect(()=>{const t=ve.current;if(t)return Q(),t.addEventListener("scroll",Q,{passive:!0}),window.addEventListener("resize",Q),()=>{t.removeEventListener("scroll",Q),window.removeEventListener("resize",Q),Se.current!==null&&(window.cancelAnimationFrame(Se.current),Se.current=null)}},[S,B,Q]);const rt=o.useCallback(t=>{const r=$[t.path];if(r)return r;if(Ae==="inline")return"inline";if(Ae==="side-by-side")return"side-by-side";const l=E<as;return t.isNew||l?"inline":"side-by-side"},[$,Ae,E]),jt=o.useMemo(()=>S.length===0?null:S.every(t=>rt(t)==="side-by-side")?"side-by-side":"inline",[S,rt]);o.useEffect(()=>{m&&(U(m),q(m,p))},[m,U,q,p]),o.useEffect(()=>{if(m)return An.onGitRefreshHint(t=>{Vt(t.directory)===Vt(m)&&(t.paths?.length&&(Ye.current=pt()??Qe.current,I(m,t.paths),We(r=>{const l=new Map(r);for(const g of t.paths??[])l.set(g,(l.get(g)??0)+1);return l})),K(m,p,{silent:!0}))})},[pt,I,m,K,p]),o.useLayoutEffect(()=>{const t=Ye.current;if(!t)return;Ye.current=null;const r=ve.current,l=Ee.current.get(t.path);if(!r||!l)return;const g=r.getBoundingClientRect().top,v=l.getBoundingClientRect().top-g;r.scrollTop=os(r.scrollTop,t.topOffset,v,r.scrollHeight-r.clientHeight),Qe.current=t},[Re]),o.useEffect(()=>{c!=="all"&&!de||oe&&(de&&C(de),O(oe),T(de==="staged"||!de&&Me),De(null),je.current=!0,me.current=oe,Fe(oe),X(t=>t+1))},[c,Fe,oe,de,Me,De]),o.useEffect(()=>{if(c==="all")return;const t=h?.trim();t&&(O(t),T(c==="staged"),je.current=!0,me.current=t,Fe(t),X(r=>r+1))},[c,Fe,h]),o.useEffect(()=>{if(!V)return;S.some(r=>r.path===V)||(O(null),T(!1))},[S,V]);const cn=o.useCallback((t,r)=>{const l=Ee.current;r?l.set(t,r):l.delete(t),Q()},[Q]),un=o.useCallback((t,r)=>{Ne(),ie(l=>{const g=l.has(t);if(r===g)return l;const v=new Set(l);return r?v.add(t):v.delete(t),v}),r||ce(l=>{if(!l.has(t))return l;const g=new Set(l);return g.delete(t),g}),Q()},[Ne,Q]),fn=o.useCallback(()=>{Ne(),ie(t=>t.size>0?new Set:new Set(S.map(r=>r.path))),ce(new Set),Q()},[Ne,S,Q]),dn=o.useCallback(async t=>{if(!ye)return;const r=Ft.getState().getDirectoryForSession(ye)||w||"";if(!r){Ke.error(u("diffView.reviewDialog.toast.noSessionDirectory"));return}Te(!0);try{await En({originalSessionID:ye,directory:r,providerID:t.providerID,modelID:t.modelID,agent:t.agent||void 0,variant:t.variant||void 0,generateHandoff:t.generateHandoff,returnAfterHandoffRequest:t.generateHandoff,autoReview:t.autoReview}),be(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Ke.error(l instanceof Error?l.message:u("diffView.reviewDialog.toast.startFailed"))}finally{Te(!1)}},[ye,w,u]),ze=o.useCallback(t=>{const r=Ee.current.get(t),l=ve.current;if(!r||!l)return!1;const g=r.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+g,behavior:"auto"}),!0},[]);o.useEffect(()=>{if(!me.current)return;let r=0;const l=20;let g=!1;const v=(F=!0)=>{g||(g=!0,me.current=null,je.current=!1,F&&re(null),z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null))},M=()=>{if(g){z.current=null;return}const F=me.current;if(!F){v(),z.current=null;return}if(!ze(F)){r+=1,r<l?z.current=window.requestAnimationFrame(M):(v(),z.current=null);return}if(i&&je.current){re(F),v(!1);return}v()};return z.current=window.requestAnimationFrame(M),()=>{g=!0,z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null)}},[i,Ce,ze]);const pn=o.useCallback(t=>{},[]),it=o.useCallback(t=>{Ne(),O(t),T(!1),je.current=!0,me.current=t,Fe(t),X(r=>r+1),ze(t)},[Ne,Fe,ze]);o.useEffect(()=>{const t=r=>{if(!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const l=r.target;if(l instanceof HTMLElement&&(l.isContentEditable||l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.closest('[role="dialog"]'))||S.length===0)return;const g=r.key==="ArrowDown"?1:-1,v=V?S.findIndex(D=>D.path===V):-1,M=v===-1?g>0?0:S.length-1:v+g,F=S[M];F&&(r.preventDefault(),it(F.path))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[S,V,it]);const mn=o.useCallback(t=>{const r=t==="side-by-side"?"side-by-side":"inline";S.forEach(l=>{J(l.path,r)})},[S,J]),[hn,St]=o.useState(null),gn=o.useCallback(async(t,r)=>{if(!m||!t)return;St(t);const l=ct();try{let g=null;if(r?.patch&&!r.isBinary&&!Ve(t)?g=Rt(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!Ve(t)&&(g=Lt(r.original,r.modified)),g===null)try{const H=await p.getGitDiff(m,{path:t,staged:Ie,contextLines:3});g=Rt(H.diff)}catch{g=null}let v=r;if(g===null||!v){const H=await p.getGitFileDiff(m,{path:t,staged:Ie});v={original:H.original??"",modified:H.modified??"",isBinary:H.isBinary},Ie||_(m,t,v,l)}const M=g??(v.isBinary||Ve(t)?1:Lt(v.original,v.modified)),F=bs(m,t),D=await qn(b,F,{directory:m});if(!D.ok){Ke.error(Xn(D.reason));return}ft(m,F,M,1)}finally{St(g=>g===t?null:g)}},[Ie,m,b,p,ft,_]),xn=()=>{if(!m)return null;const t=r=>Xe!==null?Xe:ne&&r===V;return n.jsxs("div",{className:ue("flex min-w-0 flex-1 min-h-0 h-full",x?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[$t&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:u("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:S.length})]}),n.jsx(Ss,{changedFiles:S,selectedFile:null,onSelectFile:it})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(at,{ref:ve,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:S.map(r=>n.jsx(Cs,{directory:m,file:r,layout:rt(r),wrapLines:qe,isSelected:!1,isExpanded:B.has(r.path),isMounted:He.has(r.path)||r.path===se,onSelect:pn,onExpandedChange:un,registerSectionRef:cn,showOpenInEditorAction:a&&c!=="turn",isOpeningInEditor:hn===r.path,onOpenInEditor:(l,g)=>{gn(l,g)},staged:t(r.path),loadFullFiles:fe,readOnlyActions:c==="branch",initialDiffData:c==="turn"?Ht.get(r.path)??null:c==="branch"?an.get(r.path)??null:null},`${r.path}:${Re.get(r.path)??0}`))})})})]})},bn=()=>{if(!m)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:u("diffView.state.selectSessionDirectory")});if(c!=="turn"&&ee&&!N)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.state.loadingRepositoryStatus")]});if(c!=="turn"&&W===!1)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:u("diffView.state.notGitRepository")});if(c==="branch"){if(!nn)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.branch.resolvingBase")]});if(!ae){const t=(ke?.all??[]).map(l=>l.replace(/^remotes\//,"")).filter(l=>l!==R&&!l.endsWith(`/${R}`)).sort(),r=In(t,gt,l=>[l]);return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx(A,{name:"git-branch",className:"size-6 text-muted-foreground"}),n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:u("diffView.branch.noBaseTitle")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:u("diffView.branch.noBaseDescription")}),n.jsx("input",{type:"text",value:gt,onChange:l=>sn(l.target.value),placeholder:u("gitView.branch.searchPlaceholder"),"aria-label":u("gitView.branch.searchPlaceholder"),className:"w-full max-w-sm rounded-md border border-border/60 bg-[var(--surface-elevated)] px-2.5 py-1.5 typography-meta text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]"}),n.jsx(at,{outerClassName:"max-h-48 w-full max-w-sm min-h-0",className:"px-1 py-1",children:r.length===0?n.jsx("div",{className:"px-2 py-3 typography-meta text-muted-foreground",children:u("gitView.branch.empty")}):n.jsx("div",{className:"flex flex-col gap-0.5",children:r.map(l=>n.jsxs("button",{type:"button",onClick:()=>m&&R&&Zt(m,R,l),className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",children:[n.jsx(A,{name:"git-branch",className:"size-3.5 text-primary"}),n.jsx("span",{className:"truncate typography-ui-label text-foreground",title:l,children:l})]},l))})})]})}if(bt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:u("diffView.branch.loadError")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:bt}),n.jsx(pe,{variant:"outline",size:"sm",onClick:()=>nt(),children:u("diffView.actions.retry")})]});if(_e===null)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.branch.loadingFiles")]})}return S.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c==="turn"?u("diffView.state.noLastTurnChanges"):c==="branch"&&ae?u("diffView.branch.empty",{base:ae}):u("diffView.state.cleanWorkingTree")}):xn()};return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[y===!1&&Array.isArray(P)&&P.length>0?n.jsx(Kn,{repositories:P,selectedRepository:j??null,onSelectRepository:t=>{w&&G(w,t)},repositoryRoot:w??void 0}):null,!L&&(c==="working"||c==="staged"||c==="turn"||c==="branch"?n.jsx(js,{scope:c,workingCount:Wt,stagedCount:Ut,turnCount:qt,branchCount:ln,showBranchOption:Ze,onScopeChange:t=>{C(t),f?.(t)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:ee&&!N?u("diffView.state.loadingChanges"):S.length===1?u("diffView.summary.changedFilesSingle",{count:S.length}):u("diffView.summary.changedFilesPlural",{count:S.length})})})),S.length>0&&n.jsxs(pe,{variant:"ghost",size:"sm",onClick:fn,className:ue("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:B.size>0?u("diffView.actions.collapseAll"):u("diffView.actions.expandAll"),children:[n.jsx(A,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:B.size>0?u("diffView.actions.collapseAll"):u("diffView.actions.expandAll")})]}),S.length>0&&Gt&&n.jsxs(pe,{variant:"default",size:"sm",onClick:()=>be(!0),disabled:we,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":u("diffView.actions.reviewAria"),children:[we?n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(A,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:u("diffView.actions.review")})]}),S.length>0&&Kt&&n.jsxs(pe,{variant:"outline",size:"sm",onClick:()=>{const t=m??"";k(t,{kind:"working-tree",scope:c==="staged"||c==="working"?c:"all"}),le(t,"walkthrough")},className:ue("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",Jn),"aria-label":u("walkthrough.action.open"),children:[n.jsx(A,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:u("walkthrough.action.open")})]}),S.length>0&&n.jsxs(Bn,{children:[n.jsx(Vn,{asChild:!0,children:n.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>xe(t=>!t),"aria-pressed":fe,"aria-label":u(fe?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:ue("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",fe&&"bg-interactive-selection text-interactive-selection-foreground"),children:n.jsx(A,{name:"file-download",className:"size-4"})})}),n.jsx(Ln,{children:n.jsx("p",{children:u(fe?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),S.length>0&&n.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>Pt(!ut),className:ue("h-5 w-5 p-0 transition-opacity",qe?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:u(qe?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(A,{name:"text-wrap",className:"size-4"})}),jt&&n.jsx(Mt,{mode:jt==="side-by-side"?"side-by-side":"unified",onModeChange:mn})]}),n.jsx(Tn,{open:Le,onOpenChange:be,projectDirectory:m??null,submitting:we,onConfirm:dn}),bn()]})};export{Ki as DiffView};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{f as gt,R as n,c as Sn,j as s,r as ir}from"./vendor-react-BUCujlKS.js";import{R as la,S as ca,T as ua,U as da,al as kn,n as He,u as ht,d5 as fa,C as Rn,w as ma,r as Tn,W as Vn,e as pa,d3 as ha,aO as ga,d4 as xa,a as va}from"./index-DW_E3rnL.js";import{f as Bt,y as En,ab as Yn,bS as wa,h as q,ht as ba,fj as ya,S as ss,B as z,I as b,V as ja,L as Fa,b5 as Na,ad as Ca,c8 as Sa,hu as Dn,hv as ka,g_ as Ra,fk as Ta,t as Q,l as Pn,am as ar,c3 as Cs,cC as Va,b as Ea,hw as or,bF as Da,an as Mn,hx as zn,c4 as An,c5 as Pa,gd as Ma,hy as za,hz as Aa,hA as La,bG as Zn,bH as ei,bI as ti,bJ as si,bK as ri,bL as ni,b4 as mr,b1 as pr,ap as ks,b3 as hr,b0 as Rs,c2 as lr,ao as cr,b_ as Ln,a6 as zt,a7 as At,a8 as Lt,bD as Ia,bE as Oa,g as Vs,b2 as Ba,bc as $a}from"./useAppFontEffects-CjrntdL0.js";import{$ as Wa,y as _a,z as Ua,A as Ka,B as Ha,E as Ga}from"./runtimeEndpointReset-CjhvxLH0.js";import{c as In,s as qa,C as On,P as ur}from"./shikiHighlight-DYOWuY65.js";import{a as Xa}from"./vendor-codemirror-state-C9awkmn-.js";import{E as jt}from"./vendor-codemirror-view-CiLROUVV.js";import{J as Ja,F as Qa}from"./JsonTreeView-B0BdZEHG.js";import{ensurePierreThemeRegistered as Bn,getResolvedShikiTheme as Ya}from"./appThemeRegistry-BK0dHKa6.js";import{V as Za,W as eo}from"./Virtualizer-CZlLSacm.js";import{V as to}from"./Virtualizer-D_a8gKmg.js";import{u as Ss,c as so,e as ro}from"./scheduledTasksApi-DLW0mkQK.js";import{D as no}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as io,u as ao,n as oo}from"./useInlineCommentController-CDEuSlPH.js";import{b as lo}from"./CodeMirrorCommentWidgets-B3u7UIcE.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-zod-BLfBSgBh.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BeMD8X_w.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-C3fjDbdg.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DFZik9R2.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-Bhg83tjf.js";import"./computeVirtualFileMetrics-BMIRgMHv.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isFilePlainText-QfoiKJNY.js";import"./registerCustomTheme-BBXUCRnG.js";function $n(a){const e=gt.c(41),{containerRef:r,filePath:d,fileContent:v}=a,{t:g}=Bt(),x=En(xo),w=En(go),f=Yn(),C=wa(ho),[h,F]=n.useState(null),[N,k]=n.useState(""),[j,T]=n.useState(!1),o=n.useRef(!1),L=n.useRef(null),I=n.useRef(null),[W,A]=n.useState(null);let E;e[0]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{F(null),k(""),T(!1),o.current=!1,I.current=null,A(null)},e[0]=E):E=e[0];const V=E;let S,M;e[1]!==r?(S=()=>{const B=r.current;if(!B)return;const G=()=>{if(o.current)return;const re=window.getSelection(),Se=re?.toString().trim()??"";if(!re||!Se||re.rangeCount===0){V();return}const ie=re.getRangeAt(0);if(!B.contains(ie.commonAncestorContainer)){V();return}const ae=ie.getBoundingClientRect();I.current=ie.cloneRange(),k(Se),F({x:ae.left+ae.width/2,y:ae.top-10})},se=re=>{L.current?.contains(re.target)||o.current&&V()};return document.addEventListener("selectionchange",G),document.addEventListener("pointerdown",se),()=>{document.removeEventListener("selectionchange",G),document.removeEventListener("pointerdown",se)}},M=[r,V],e[1]=r,e[2]=S,e[3]=M):(S=e[2],M=e[3]),n.useEffect(S,M);let $;e[4]!==v?($=B=>{const G=de=>v.slice(0,de).split(`
|
|
2
|
-
`).length,se=mo,re=(de,Ve)=>{for(const Ee of se(de)){const ke=v.indexOf(Ee,Ve);if(ke>=0)return ke}return-1},Se=B.length>=8?v.indexOf(B):-1;if(Se>=0){const de=G(Se);return{start:de,end:de+B.split(`
|
|
3
|
-
`).length-1}}const ie=B.split(`
|
|
4
|
-
`).map(fo).filter(Boolean);if(ie.length===0)return null;const ae=re(ie[0],0);if(ae<0)return null;const ye=G(ae);if(ie.length===1)return{start:ye,end:ye};const Te=re(ie[ie.length-1],ae);return Te<0?null:{start:ye,end:Math.max(ye,G(Te))}},e[4]=v,e[5]=$):$=e[5];const P=$;let J;e[6]===Symbol.for("react.memo_cache_sentinel")?(J=()=>{const B=I.current;if(!B){A(null);return}A(ba(B))},e[6]=J):J=e[6];const Ne=J;let _,Y;e[7]!==j?(_=()=>{if(!j)return;let B=null;const G=()=>{B===null&&(B=window.requestAnimationFrame(()=>{B=null,Ne()}))};return document.addEventListener("scroll",G,{capture:!0,passive:!0}),window.addEventListener("resize",G),()=>{B!==null&&window.cancelAnimationFrame(B),document.removeEventListener("scroll",G,{capture:!0}),window.removeEventListener("resize",G)}},Y=[j,Ne],e[7]=j,e[8]=_,e[9]=Y):(_=e[8],Y=e[9]),n.useEffect(_,Y);let ee;e[10]!==N?(ee=()=>{N&&(T(!0),o.current=!0,Ne(),window.getSelection()?.removeAllRanges())},e[10]=N,e[11]=ee):ee=e[11];const le=ee;let te;e[12]!==C||e[13]!==x||e[14]!==f||e[15]!==d||e[16]!==w||e[17]!==P||e[18]!==N?(te=B=>{const G=x??(w?"draft":null);if(!N||!G||!f){V();return}const se=P(N);C({directory:f,sessionKey:G},{source:"file-quote",fileLabel:d,startLine:se?.start??0,endLine:se?.end??0,code:N,language:"",text:B.trim()}),V(),queueMicrotask(uo)},e[12]=C,e[13]=x,e[14]=f,e[15]=d,e[16]=w,e[17]=P,e[18]=N,e[19]=te):te=e[19];const Ce=te;if(!h)return null;let O;e[20]!==j||e[21]!==P||e[22]!==N?(O=j?P(N):null,e[20]=j,e[21]=P,e[22]=N,e[23]=O):O=e[23];const ve=O;let we;e[24]!==h.x||e[25]!==h.y?(we={left:h.x,top:h.y,transform:"translate(-50%, -100%)"},e[24]=h.x,e[25]=h.y,e[26]=we):we=e[26];let ce;e[27]!==j||e[28]!==W?(ce=j&&W&&W.length>0?Sn.createPortal(s.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:W.map(co)}),document.body):null,e[27]=j,e[28]=W,e[29]=ce):ce=e[29];let ue;e[30]!==j||e[31]!==d||e[32]!==ve||e[33]!==le||e[34]!==Ce||e[35]!==g?(ue=j?s.jsx("div",{className:"w-[min(420px,80vw)]",children:s.jsx(io,{fileLabel:d,lineRange:ve?{start:ve.start,end:ve.end}:void 0,onSave:Ce,onCancel:V})}):s.jsx("div",{className:q("flex items-center whitespace-nowrap","oc-glass-popover rounded-full border border-[var(--interactive-border)]","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","p-1"),children:s.jsx("button",{type:"button",onClick:le,className:q("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-[var(--surface-foreground)]","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:g("chat.textSelection.title.commentOnSelection"),children:g("chat.textSelection.actions.comment")})}),e[30]=j,e[31]=d,e[32]=ve,e[33]=le,e[34]=Ce,e[35]=g,e[36]=ue):ue=e[36];let be;return e[37]!==we||e[38]!==ce||e[39]!==ue?(be=Sn.createPortal(s.jsxs("div",{ref:L,className:"fixed z-50",style:we,children:[ce,ue]}),document.body),e[37]=we,e[38]=ce,e[39]=ue,e[40]=be):be=e[40],be}function co(a,e){return s.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:a.left,top:a.top,width:a.width,height:a.height}},e)}function uo(){ya()}function fo(a){return a.trim()}function mo(a){const e=a.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(po)}function po(a){return a.length>=8}function ho(a){return a.addDraft}function go(a){return a.newSessionDraft?.open}function xo(a){return a.currentSessionId}const vo=(a,e)=>{if(!e)return null;const r=Number.parseInt(a.trim(),10);return!Number.isFinite(r)||r<1?null:Math.min(r,e.state.doc.lines)},Wn=(a,e)=>{const r=a.state.doc.lineAt(e.main.head);return{lineNumber:r.number,character:e.main.head-r.from+1,selection:e}},_n=(a,e,r)=>{const d=a.state.doc.line(e),v=Math.max(1,Math.min(r,d.length+1)),g=d.from+v-1;a.dispatch({selection:Xa.cursor(g),effects:jt.scrollIntoView(g,{y:"center"})})};function wo({open:a,onOpenChange:e,view:r,variant:d="overlay"}){const{t:v}=Bt(),[g,x]=n.useState(""),w=n.useRef(null),f=n.useRef(!1),C=n.useRef(null),h=n.useRef(null),F=n.useMemo(()=>vo(g,r),[g,r]);n.useEffect(()=>{!a||!r||(f.current=!1,w.current=Wn(r,r.state.selection),x(""))},[a,r]),n.useEffect(()=>{a&&window.requestAnimationFrame(()=>{h.current?.focus(),h.current?.select()})},[a]),n.useEffect(()=>{if(!(!a||!r||!w.current)){if(F===null){const{selection:o}=w.current;r.dispatch({selection:o,effects:jt.scrollIntoView(o.main.from,{y:"center"})});return}_n(r,F,w.current.character)}},[F,a,r]);const N=n.useCallback(()=>{if(!r||f.current||!w.current)return;const{selection:o}=w.current;r.dispatch({selection:o,effects:jt.scrollIntoView(o.main.from,{y:"center"})})},[r]),k=n.useCallback(o=>{o||N(),e(o)},[e,N]),j=n.useCallback(()=>{!r||F===null||!w.current||(f.current=!0,_n(r,F,w.current.character),e(!1),r.focus())},[F,e,r]);n.useEffect(()=>{if(!a)return;const o=I=>{const W=C.current,A=I.target;!W||!(A instanceof Node)||W.contains(A)||k(!1)},L=I=>{I.key==="Escape"&&(I.preventDefault(),k(!1))};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",L,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",L,!0)}},[k,a,d]);const T=n.useMemo(()=>{if(!r)return v("goToLineDialog.helper.editorUnavailable");if(F===null){const o=w.current??Wn(r,r.state.selection);return v("goToLineDialog.helper.currentLineRange",{current:o.lineNumber,max:r.state.doc.lines})}return v("goToLineDialog.helper.goToLine",{line:F})},[F,v,r]);return d==="inline"?a?s.jsxs("div",{ref:C,className:"ml-1 flex h-6 items-center gap-1",children:[s.jsx(ss,{ref:h,type:"number",min:1,step:1,inputMode:"numeric",value:g,onChange:o=>x(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),j())},placeholder:v("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),s.jsx(z,{variant:"outline",size:"xs",onClick:j,disabled:!r||F===null,className:"h-6 px-2",children:v("goToLineDialog.actions.go")})]}):null:s.jsx("div",{ref:C,className:q("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",a?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:s.jsxs("div",{className:"min-w-0",children:[s.jsx(ss,{ref:h,type:"number",min:1,step:1,inputMode:"numeric",value:g,onChange:o=>x(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),j())},placeholder:v("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),s.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:T})]})})}const bo=(a,e)=>{const r=e.trim().toLowerCase(),d=[];if(!r)return d;const v=a.toLowerCase();let g=0;for(;;){const x=v.indexOf(r,g);if(x===-1)break;d.push({start:x,end:x+r.length}),g=x+r.length}return d},Ds="data-md-find",dr="data-md-find-current",ii="rounded-[2px] bg-status-warning/30 text-foreground",yo="rounded-[2px] bg-status-warning/60 text-foreground",jo=120,Fo=a=>a instanceof Element&&a.hasAttribute(Ds),No=a=>a.target instanceof Element&&a.target.hasAttribute(Ds)?!0:[...a.addedNodes].some(e=>Fo(e)),ai=a=>{const e=new Set;a.querySelectorAll(`mark[${Ds}]`).forEach(r=>{const d=r.parentNode;d&&(d.replaceChild(document.createTextNode(r.textContent??""),r),e.add(d))}),e.forEach(r=>r.normalize())},Co=(a,e)=>{ai(a);const r=e.trim().toLowerCase();if(!r)return[];const d=[],v=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,{acceptNode(x){const w=x.parentElement;return!w||w.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),g=[];for(;v.nextNode();){const x=v.currentNode;x instanceof Text&&g.push(x)}for(const x of g){const w=x.nodeValue??"";if(!w)continue;const f=bo(w,r);if(f.length===0)continue;const C=x.parentNode;if(!C)continue;const h=document.createDocumentFragment();let F=0;for(const N of f){N.start>F&&h.appendChild(document.createTextNode(w.slice(F,N.start)));const k=document.createElement("mark");k.setAttribute(Ds,""),k.className=ii,k.textContent=w.slice(N.start,N.end),h.appendChild(k),d.push(k),F=N.end}F<w.length&&h.appendChild(document.createTextNode(w.slice(F))),C.replaceChild(h,x)}return d},Un=({containerRef:a,open:e,onOpenChange:r,focusNonce:d,className:v})=>{const{t:g}=Bt(),[x,w]=n.useState(""),[f,C]=n.useState(0),[h,F]=n.useState(0),N=n.useRef(null),k=n.useRef([]),j=n.useRef(x);j.current=x;const T=n.useRef(null),o=n.useRef(null),L=n.useCallback((S,M=!1)=>{const $=a.current;if(!$){k.current=[],C(0),F(0);return}k.current=Co($,S);const P=k.current.length;C(P),F(J=>!M||P===0?0:Math.min(J,P-1))},[a]),I=n.useCallback((S,M=!1)=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{T.current=null,L(S,M)},jo)},[L]);n.useEffect(()=>()=>{T.current&&clearTimeout(T.current)},[]);const W=n.useCallback(()=>{r(!1);const S=o.current;o.current=null,S?.isConnected&&S.focus()},[r]);n.useEffect(()=>{const S=a.current;if(!e||!S)return;const M=new MutationObserver($=>{!j.current.trim()||!$.some(J=>!No(J))||I(j.current,!0)});return M.observe(S,{childList:!0,subtree:!0,characterData:!0}),()=>{M.disconnect(),ai(S)}},[a,e,I]),n.useEffect(()=>{if(!e)return;const S=document.activeElement;S instanceof HTMLElement&&!o.current&&(o.current=S),N.current?.focus()},[e]),n.useEffect(()=>{e&&d>0&&(N.current?.focus(),N.current?.select())},[e,d]),n.useEffect(()=>{const S=a.current;if(!S||(S.querySelectorAll(`mark[${dr}]`).forEach($=>{$.removeAttribute(dr),$.className=ii}),f===0))return;const M=k.current[Math.min(Math.max(h,0),f-1)];M&&(M.setAttribute(dr,""),M.className=yo,M.scrollIntoView({block:"nearest"}))},[a,h,f]);const A=n.useCallback(()=>{F(S=>f===0?0:(S+1)%f)},[f]),E=n.useCallback(()=>{F(S=>f===0?0:(S-1+f)%f)},[f]),V=n.useCallback(S=>{S.key==="Enter"?(S.preventDefault(),S.shiftKey?E():A()):S.key==="Escape"&&(S.preventDefault(),W())},[W,A,E]);return e?s.jsxs("div",{className:q("absolute right-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",v),children:[s.jsx(b,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),s.jsx(ss,{ref:N,value:x,onChange:S=>{w(S.target.value),I(S.target.value)},onKeyDown:V,placeholder:g("filesView.preview.find.placeholder"),"aria-label":g("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),s.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":f>0?g("filesView.preview.find.countAria",{current:h+1,total:f}):g("filesView.preview.find.noMatches"),children:x.trim()&&f===0?g("filesView.preview.find.noMatches"):f>0?`${h+1}/${f}`:""}),s.jsx(z,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:E,title:g("filesView.preview.find.previousAria"),"aria-label":g("filesView.preview.find.previousAria"),disabled:f===0,children:s.jsx(b,{name:"arrow-up",className:"size-3.5"})}),s.jsx(z,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:A,title:g("filesView.preview.find.nextAria"),"aria-label":g("filesView.preview.find.nextAria"),disabled:f===0,children:s.jsx(b,{name:"arrow-down",className:"size-3.5"})}),s.jsx(z,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:W,title:g("filesView.preview.find.closeAria"),"aria-label":g("filesView.preview.find.closeAria"),children:s.jsx(b,{name:"close",className:"size-3.5"})})]}):null};function Kn(){const a=gt.c(8),[e]=ir.useState(So),r=ir.useRef(!1);let d;a[0]!==e?(d=f=>{if(f==null){e.cleanUp(),r.current=!1;return}r.current||(r.current=!0,e.setup(f,f.firstElementChild??void 0))},a[0]=e,a[1]=d):d=a[1];const v=d;let g,x;a[2]!==e?(g=()=>()=>{r.current=!1,e.cleanUp()},x=[e],a[2]=e,a[3]=g,a[4]=x):(g=a[3],x=a[4]),ir.useLayoutEffect(g,x);let w;return a[5]!==v||a[6]!==e?(w={virtualizer:e,setScroller:v},a[5]=v,a[6]=e,a[7]=w):w=a[7],w}function So(){return new to}function ko(a){return!(!a.autoSaveEnabled||!a.isDirty||!a.canWrite||a.isSaving||a.fileLoading||a.isNonEditableBinary||!a.selectedFilePath||a.loadedFilePath!==a.selectedFilePath)}function Ro(a){return a.selectedFilePath?a.isDirty?!(a.fileLoading||a.loadedFilePath!==a.selectedFilePath||a.isNonEditableBinary||a.draftContent===""&&a.fileContent!==""&&a.loadedFilePath!==a.selectedFilePath):!0:!1}const To='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function Hn(){if(typeof document>"u")return!1;const a=document.documentElement.getAttribute("data-theme");return a==="dark"||!a&&window.matchMedia("(prefers-color-scheme: dark)").matches}const Vo=n.forwardRef(function({xml:e,readOnly:r,className:d,onChange:v},g){const x=n.useRef(e),w=n.useRef(null),f=n.useRef(!1),[C,h]=n.useState(Hn),F=n.useRef(e),N=n.useRef(e);N.current!==e&&(N.current=e,F.current=e,x.current=e);const k=n.useRef(C);k.current!==C&&(k.current=C,F.current=x.current);const j=n.useRef(null);n.useEffect(()=>{const L=()=>h(Hn());L();const I=new MutationObserver(L);return I.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>I.disconnect()},[]),n.useEffect(()=>{const L=setTimeout(()=>{j.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(L)},[]),n.useImperativeHandle(g,()=>({getXml:()=>x.current}));const T=n.useCallback(()=>{!e&&!f.current&&(f.current=!0,setTimeout(()=>{w.current?.template({})},500))},[e]),o=n.useCallback(L=>{x.current=L.xml,v?.(L.xml)},[v]);return s.jsx("div",{ref:j,className:q("h-full w-full",d),children:s.jsx(no,{ref:w,xml:F.current||To,autosave:!0,urlParameters:{ui:r?"simple":C?"dark":"kennedy",spin:!0,libraries:!r,chrome:r,nav:r,layers:r,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:T,onAutoSave:o},C?"dark":"light")})}),Eo=a=>{const e=H(a);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const r=e.lastIndexOf("/");if(r<0)return e;if(r===0)return"/";const d=e.slice(0,r);return/^[A-Za-z]:$/.test(d)?`${d}/`:d},Do=a=>{const e=gt.c(8),{label:r,iconDataUrl:d}=a,[v,g]=n.useState(!1);let x;e[0]!==r?(x=r.trim().slice(0,1).toUpperCase()||"?",e[0]=r,e[1]=x):x=e[1];const w=x;if(d&&!v){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=()=>g(!0),e[2]=h):h=e[2];let F;return e[3]!==d?(F=s.jsx("img",{src:d,alt:"",className:"size-4 rounded-sm",onError:h}),e[3]=d,e[4]=F):F=e[4],F}let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=q("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=f):f=e[5];let C;return e[6]!==w?(C=s.jsx("span",{className:f,children:w}),e[6]=w,e[7]=C):C=e[7],C},Po=a=>a.slice().sort((e,r)=>e.type!==r.type?e.type==="directory"?-1:1:e.name.localeCompare(r.name)),H=a=>{if(!a)return"";const e=a.replace(/\\/g,"/"),r=e.startsWith("//");let d=e.replace(/\/+/g,"/");r&&!d.startsWith("//")&&(d=`/${d}`);const v=d==="/",g=/^[A-Za-z]:\/$/.test(d);return!v&&!g&&(d=d.replace(/\/+$/,"")),d},Mo=a=>a.startsWith("/")||a.startsWith("//")||/^[A-Za-z]:\//.test(a),Ot=a=>/^[A-Za-z]:\//.test(a)?a.toLowerCase():a,Es=(a,e)=>{const r=H(e),d=H(a);if(!r||!d)return!1;const v=Ot(r),g=Ot(d);return g===v||g.startsWith(`${v}/`)},Gn=(a,e)=>{const r=H(e),d=H(a);if(!Es(d,r))return[];const g=d.slice(r.length).replace(/^\//,"").split("/"),x=[];let w=r;for(let f=0;f<g.length-1;f++)w=w?`${w}/${g[f]}`:g[f],x.push(w);return x},Ts=(a,e)=>{if(!e)return"";const r=H(e);if(!a||!Es(r,a))return r;const d=r.slice(a.length);return d.startsWith("/")?d.slice(1):d},zo=new Set(["node_modules"]),Ao=a=>{const e=gt.c(3),{status:r}=a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=d):d=e[0];const v=d[r];let g;return e[1]!==v?(g=s.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:v}}),e[1]=v,e[2]=g):g=e[2],g},qn=a=>{const e=gt.c(11),{name:r}=a,d=n.useRef(null),v=n.useRef(null),[g,x]=n.useState(!1);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{const N=d.current,k=v.current;if(!N||!k)return;const j=()=>{x(k.scrollWidth>N.clientWidth+1)};j();const T=new ResizeObserver(j);return T.observe(N),T.observe(k),()=>{T.disconnect()}},e[0]=w):w=e[0];let f;e[1]!==r?(f=[r],e[1]=r,e[2]=f):f=e[2],n.useLayoutEffect(w,f);let C;e[3]!==r?(C=s.jsx("span",{ref:v,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:r}),e[3]=r,e[4]=C):C=e[4];let h;e[5]!==r||e[6]!==g?(h=g?s.jsxs("span",{className:"open-file-name-marquee-track",children:[s.jsx("span",{className:"open-file-name-marquee-item",children:r}),s.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:r})]}):s.jsx("span",{className:"block min-w-0 truncate",children:r}),e[5]=r,e[6]=g,e[7]=h):h=e[7];let F;return e[8]!==C||e[9]!==h?(F=s.jsxs("span",{ref:d,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[C,h]}),e[8]=C,e[9]=h,e[10]=F):F=e[10],F},Lo=a=>zo.has(a),Io=a=>{const e=H(a);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Oo=a=>{const r=(a instanceof Error?a.message:String(a??"")).toLowerCase();return r.includes("is a directory")||r.includes("eisdir")},Xn=a=>{const r=(a instanceof Error?a.message:String(a??"")).toLowerCase();return r.includes("file not found")||r.includes("enoent")||r.includes("no such file")||r.includes("does not exist")},It=2e5;function Bo(a){const e=a.length>400?`${a.slice(0,200)}${a.slice(-200)}`:a;let r=2166136261;for(let d=0;d<e.length;d+=1)r^=e.charCodeAt(d),r=r+((r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24))>>>0;return`${a.length}:${r.toString(16)}`}const $o=a=>{let e=0,r=0;for(let d=0;d<a.length;d+=1)a.charCodeAt(d)===10&&(d>0&&a.charCodeAt(d-1)===13?e+=1:r+=1);return e>r?`\r
|
|
5
|
-
`:`
|
|
6
|
-
`},oi=a=>a.replace(/\r\n/g,`
|
|
7
|
-
`).replace(/\r/g,`
|
|
8
|
-
`),Wo=(a,e)=>{const r=oi(a);return e===`\r
|
|
9
|
-
`?r.replace(/\n/g,`\r
|
|
10
|
-
`):r},li=(a,e)=>s.jsx(ks,{filePath:a,extension:e}),Jn=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},_o=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},fr=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Uo=a=>{const e=gt.c(76),{node:r,root:d,isExpanded:v,isActive:g,isMobile:x,isBrowserClient:w,alwaysShowActions:f,status:C,badge:h,permissions:F,downloadFile:N,contextMenuPath:k,setContextMenuPath:j,rightClickMenuPath:T,setRightClickMenuPath:o,onSelect:L,onToggle:I,onRevealPath:W,onOpenDialog:A}=a,{t:E}=Bt(),V=r.type==="directory",{canRename:S,canCreateFile:M,canCreateFolder:$,canDelete:P,canReveal:J}=F,Ne=!V&&!!N,_=J&&!w,Y=S||M||$||P||Ne||_;let ee;e[0]!==Y||e[1]!==r.path||e[2]!==o?(ee=fe=>{Y&&(fe?.preventDefault(),o(r.path))},e[0]=Y,e[1]=r.path,e[2]=o,e[3]=ee):ee=e[3];const le=ee;let te;e[4]!==V||e[5]!==r||e[6]!==L||e[7]!==I?(te=()=>{V?I(r.path):L(r)},e[4]=V,e[5]=r,e[6]=L,e[7]=I,e[8]=te):te=e[8];const Ce=te;let O;e[9]!==r.path||e[10]!==j||e[11]!==o?(O=fe=>{fe.stopPropagation(),o(null),j(r.path)},e[9]=r.path,e[10]=j,e[11]=o,e[12]=O):O=e[12];const ve=O;let we;e[13]!==M||e[14]!==$||e[15]!==P||e[16]!==S||e[17]!==_||e[18]!==N||e[19]!==w||e[20]!==V||e[21]!==r||e[22]!==A||e[23]!==W||e[24]!==d||e[25]!==E?(we=fe=>{const{Item:he,Separator:et}=fe;return s.jsxs(s.Fragment,{children:[S&&s.jsxs(he,{onClick:X=>{X.stopPropagation(),A("rename",r)},children:[s.jsx(b,{name:"edit",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.rename")]}),s.jsxs(he,{onClick:X=>{X.stopPropagation(),Vs(r.path).then(at=>{if(at.ok){Q.success(E("sidebarFilesTree.toast.pathCopied"));return}Q.error(E("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(b,{name:"file-copy",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.copyPath")]}),s.jsxs(he,{onClick:X=>{X.stopPropagation();const at=Ts(d,r.path)||r.path;Vs(at).then(me=>{if(me.ok){Q.success(E("filesView.toast.relativePathCopied"));return}Q.error(E("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(b,{name:"file-copy-2",className:"mr-2 size-4"})," ",E("filesView.tree.menu.copyRelativePath")]}),!V&&N&&s.jsxs(he,{onClick:X=>{X.stopPropagation(),N(r.path).catch(at=>{console.error("Download failed:",at),Q.error(E("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(b,{name:"download",className:"mr-2 size-4"})," ",E(w?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),_&&s.jsxs(he,{onClick:X=>{X.stopPropagation(),W(r.path)},children:[s.jsx(b,{name:"folder-received",className:"mr-2 size-4"})," ",E($a())]}),V&&(M||$)&&s.jsxs(s.Fragment,{children:[s.jsx(et,{}),M&&s.jsxs(he,{onClick:X=>{X.stopPropagation(),A("createFile",r)},children:[s.jsx(b,{name:"file-add",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.newFile")]}),$&&s.jsxs(he,{onClick:X=>{X.stopPropagation(),A("createFolder",r)},children:[s.jsx(b,{name:"folder-add",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.newFolder")]})]}),P&&s.jsxs(s.Fragment,{children:[s.jsx(et,{}),s.jsxs(he,{onClick:X=>{X.stopPropagation(),A("delete",r)},className:"text-destructive focus:text-destructive",children:[s.jsx(b,{name:"delete-bin",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.delete")]})]})]})},e[13]=M,e[14]=$,e[15]=P,e[16]=S,e[17]=_,e[18]=N,e[19]=w,e[20]=V,e[21]=r,e[22]=A,e[23]=W,e[24]=d,e[25]=E,e[26]=we):we=e[26];const ce=we,ue=T===r.path;let be;e[27]!==r.path||e[28]!==o?(be=fe=>o(fe?r.path:null),e[27]=r.path,e[28]=o,e[29]=be):be=e[29];const B=x?void 0:le;let G;e[30]!==B?(G=s.jsx("div",{className:"group relative flex items-center",onContextMenu:B}),e[30]=B,e[31]=G):G=e[31];const se=x?void 0:le,re=g?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let Se;e[32]!==re?(Se=q("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",re),e[32]=re,e[33]=Se):Se=e[33];let ie;e[34]!==V||e[35]!==v||e[36]!==r.extension||e[37]!==r.path?(ie=V?v?s.jsx(b,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):s.jsx(b,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):li(r.path,r.extension),e[34]=V,e[35]=v,e[36]=r.extension,e[37]=r.path,e[38]=ie):ie=e[38];let ae;e[39]!==r.name||e[40]!==r.path?(ae=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:r.path,children:r.name}),e[39]=r.name,e[40]=r.path,e[41]=ae):ae=e[41];let ye;e[42]!==V||e[43]!==C?(ye=!V&&C&&s.jsx(Ao,{status:C}),e[42]=V,e[43]=C,e[44]=ye):ye=e[44];let Te;e[45]!==h||e[46]!==V?(Te=V&&h&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[h.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",h.modified]}),h.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",h.added]})]}),e[45]=h,e[46]=V,e[47]=Te):Te=e[47];let de;e[48]!==Ce||e[49]!==Se||e[50]!==ie||e[51]!==ae||e[52]!==ye||e[53]!==Te||e[54]!==se?(de=s.jsxs("button",{type:"button",onClick:Ce,onContextMenu:se,className:Se,children:[ie,ae,ye,Te]}),e[48]=Ce,e[49]=Se,e[50]=ie,e[51]=ae,e[52]=ye,e[53]=Te,e[54]=se,e[55]=de):de=e[55];let Ve;e[56]!==f||e[57]!==k||e[58]!==ve||e[59]!==Y||e[60]!==x||e[61]!==r.path||e[62]!==ce||e[63]!==j?(Ve=Y&&s.jsx("div",{className:q("absolute right-1 top-1/2 -translate-y-1/2",f?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:s.jsxs(mr,{open:k===r.path,onOpenChange:fe=>j(fe?r.path:null),children:[s.jsx(pr,{asChild:!0,children:s.jsx(z,{variant:"ghost",size:"icon",className:"size-6",onClick:ve,children:s.jsx(b,{name:"more-2-fill",className:"size-4"})})}),s.jsx(hr,{align:"end",side:"bottom",onCloseAutoFocus:()=>j(null),children:ce({Item:Rs,Separator:Ba})})]})}),e[56]=f,e[57]=k,e[58]=ve,e[59]=Y,e[60]=x,e[61]=r.path,e[62]=ce,e[63]=j,e[64]=Ve):Ve=e[64];let Ee;e[65]!==de||e[66]!==Ve||e[67]!==G?(Ee=s.jsxs(Ha,{render:G,children:[de,Ve]}),e[65]=de,e[66]=Ve,e[67]=G,e[68]=Ee):Ee=e[68];let ke;e[69]!==ce?(ke=s.jsx(_a,{className:"min-w-[180px]",children:ce({Item:Ka,Separator:Ua})}),e[69]=ce,e[70]=ke):ke=e[70];let Z;return e[71]!==Ee||e[72]!==ke||e[73]!==ue||e[74]!==be?(Z=s.jsxs(Ga,{open:ue,onOpenChange:be,children:[Ee,ke]}),e[71]=Ee,e[72]=ke,e[73]=ue,e[74]=be,e[75]=Z):Z=e[75],Z},Ko=a=>{const e=gt.c(83),{activeDialog:r,dialogData:d,dialogInputValue:v,onDialogInputChange:g,isDialogSubmitting:x,onDialogSubmit:w,onClose:f,inputRef:C}=a,{t:h}=Bt(),F=!!r;let N;e[0]!==f?(N=O=>!O&&f(),e[0]=f,e[1]=N):N=e[1];let k;e[2]!==r||e[3]!==h?(k=r==="createFile"&&h("filesView.dialog.createFile.title"),e[2]=r,e[3]=h,e[4]=k):k=e[4];let j;e[5]!==r||e[6]!==h?(j=r==="createFolder"&&h("filesView.dialog.createFolder.title"),e[5]=r,e[6]=h,e[7]=j):j=e[7];let T;e[8]!==r||e[9]!==h?(T=r==="rename"&&h("filesView.dialog.rename.title"),e[8]=r,e[9]=h,e[10]=T):T=e[10];let o;e[11]!==r||e[12]!==h?(o=r==="delete"&&h("filesView.dialog.delete.title"),e[11]=r,e[12]=h,e[13]=o):o=e[13];let L;e[14]!==k||e[15]!==j||e[16]!==T||e[17]!==o?(L=s.jsxs(si,{children:[k,j,T,o]}),e[14]=k,e[15]=j,e[16]=T,e[17]=o,e[18]=L):L=e[18];let I;e[19]!==r||e[20]!==d?.path||e[21]!==h?(I=r==="createFile"&&h("filesView.dialog.createFile.description",{path:d?.path??h("filesView.dialog.rootFallback")}),e[19]=r,e[20]=d?.path,e[21]=h,e[22]=I):I=e[22];let W;e[23]!==r||e[24]!==d?.path||e[25]!==h?(W=r==="createFolder"&&h("filesView.dialog.createFolder.description",{path:d?.path??h("filesView.dialog.rootFallback")}),e[23]=r,e[24]=d?.path,e[25]=h,e[26]=W):W=e[26];let A;e[27]!==r||e[28]!==d?.name||e[29]!==h?(A=r==="rename"&&h("filesView.dialog.rename.description",{name:d?.name??""}),e[27]=r,e[28]=d?.name,e[29]=h,e[30]=A):A=e[30];let E;e[31]!==r||e[32]!==d?.name||e[33]!==h?(E=r==="delete"&&h("filesView.dialog.delete.description",{name:d?.name??""}),e[31]=r,e[32]=d?.name,e[33]=h,e[34]=E):E=e[34];let V;e[35]!==A||e[36]!==E||e[37]!==I||e[38]!==W?(V=s.jsxs(ri,{children:[I,W,A,E]}),e[35]=A,e[36]=E,e[37]=I,e[38]=W,e[39]=V):V=e[39];let S;e[40]!==V||e[41]!==L?(S=s.jsxs(ti,{children:[L,V]}),e[40]=V,e[41]=L,e[42]=S):S=e[42];let M;e[43]!==r||e[44]!==v||e[45]!==C||e[46]!==g||e[47]!==w||e[48]!==h?(M=r!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(ss,{value:v,onChange:O=>g(O.target.value),placeholder:h(r==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:O=>{O.key==="Enter"&&w()},ref:C})}),e[43]=r,e[44]=v,e[45]=C,e[46]=g,e[47]=w,e[48]=h,e[49]=M):M=e[49];let $;e[50]!==h?($=h("filesView.dialog.cancel"),e[50]=h,e[51]=$):$=e[51];let P;e[52]!==x||e[53]!==f||e[54]!==$?(P=s.jsx(z,{variant:"outline",onClick:f,disabled:x,children:$}),e[52]=x,e[53]=f,e[54]=$,e[55]=P):P=e[55];const J=r==="delete"?"destructive":"default";let Ne;e[56]!==w?(Ne=()=>{w()},e[56]=w,e[57]=Ne):Ne=e[57];let _;e[58]!==r||e[59]!==v||e[60]!==x?(_=x||r!=="delete"&&!v.trim(),e[58]=r,e[59]=v,e[60]=x,e[61]=_):_=e[61];let Y;e[62]!==r||e[63]!==x||e[64]!==h?(Y=x?s.jsx(b,{name:"loader-4",className:"size-4 animate-spin"}):h(r==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=r,e[63]=x,e[64]=h,e[65]=Y):Y=e[65];let ee;e[66]!==J||e[67]!==Ne||e[68]!==_||e[69]!==Y?(ee=s.jsx(z,{variant:J,onClick:Ne,disabled:_,children:Y}),e[66]=J,e[67]=Ne,e[68]=_,e[69]=Y,e[70]=ee):ee=e[70];let le;e[71]!==P||e[72]!==ee?(le=s.jsxs(ni,{children:[P,ee]}),e[71]=P,e[72]=ee,e[73]=le):le=e[73];let te;e[74]!==C||e[75]!==S||e[76]!==M||e[77]!==le?(te=s.jsxs(ei,{initialFocus:C,children:[S,M,le]}),e[74]=C,e[75]=S,e[76]=M,e[77]=le,e[78]=te):te=e[78];let Ce;return e[79]!==F||e[80]!==N||e[81]!==te?(Ce=s.jsx(Zn,{open:F,onOpenChange:N,children:te}),e[79]=F,e[80]=N,e[81]=te,e[82]=Ce):Ce=e[82],Ce},Qn=(a,e,r)=>{const d=gt.c(8),[v,g]=n.useState(""),[x,w]=n.useState(0);let f,C;d[0]!==a||d[1]!==r||d[2]!==e?(f=()=>{if(!a){g("");return}let F=!1;g("");const N=pa(),k=ha(N);ga(N).then(T=>{F||!T||(g(a),e(null))}).catch(T=>{F||(e(T instanceof Error?T.message:r),g(a))});const j=xa(()=>{F||(g(a),w(Ho),e(null))});return()=>{F=!0,k(),j()}},C=[a,e,r],d[0]=a,d[1]=r,d[2]=e,d[3]=f,d[4]=C):(f=d[3],C=d[4]),n.useEffect(f,C);let h;return d[5]!==x||d[6]!==v?(h={readyKey:v,nonce:x},d[5]=x,d[6]=v,d[7]=h):h=d[7],h},mu=({mode:a="full"})=>{const{t:e}=Bt(),{files:r,runtime:d}=ja(),{currentTheme:v,availableThemes:g,lightThemeId:x,darkThemeId:w}=Fa(),{isMobile:f,isTablet:C,screenWidth:h}=Na(),F=la(d.platform),N=f||C,k=ca(),j=ua(),T=Yn()??"",o=H(T.trim()),L=a!=="editor-only",I=a==="editor-only"&&!f,W=da(t=>t.searchFiles),A=Ca(T),[E,V]=n.useState(""),S=Sa(E,200),M=n.useRef(null),[$,P]=n.useState(!1),[J,Ne]=n.useState(!0),[_,Y]=n.useState(!1),[ee,le]=n.useState(!1),te=n.useRef(0),Ce=n.useCallback(t=>{te.current=Math.max(0,te.current+(t?1:-1))},[]),[O,ve]=n.useState("edit"),[we,ce]=n.useState("edit"),[ue,be]=n.useState("tree"),[B,G]=n.useState("edit"),[se,re]=n.useState("preview"),[Se,ie]=n.useState(0),ae=n.useRef({}),ye=n.useRef({}),Te=n.useRef({}),de=n.useRef({}),Ve=n.useMemo(()=>g.find(t=>t.metadata.id===x)??kn(!1),[g,x]),Ee=n.useMemo(()=>g.find(t=>t.metadata.id===w)??kn(!0),[g,w]);n.useEffect(()=>{Bn(Ve),Bn(Ee)},[Ve,Ee]);const ke=n.useMemo(()=>[],[]),Z=He(t=>o?t.byRoot[o]?.openPaths??ke:ke),fe=He(t=>o?t.byRoot[o]?.selectedPath??null:null),he=He(t=>o?t.byRoot[o]?.expandedPaths??ke:ke),et=He(t=>t.removeOpenPath),X=He(t=>t.removeOpenPathsByPrefix),at=He(t=>t.removeExpandedPathsByPrefix),me=He(t=>t.setSelectedPath),gr=He(t=>t.toggleExpandedPath),rs=He(t=>t.expandPaths),Ft=n.useCallback(t=>{const i=H(t),l=i.split("/"),u=l[l.length-1]||i,p=u.includes(".")?u.split(".").pop()?.toLowerCase():void 0;return{name:u,path:i,type:"file",extension:p}},[]),Nt=n.useMemo(()=>Z.map(Ft),[Z,Ft]),Ps=n.useMemo(()=>{if(fe){const t=Ot(fe);if(Z.some(i=>Ot(i)===t))return fe}return Z[0]??null},[Z,fe]),c=n.useMemo(()=>Ps?Ft(Ps):null,[Ps,Ft]),Ge=c?.path??"",[,ci]=n.useState(0);n.useEffect(()=>{if(!o||!fe)return;const t=Ot(fe);Z.some(l=>Ot(l)===t)||me(o,Z[0]??null)},[Z,o,fe,me]);const ns=!!(o&&Ge&&!Es(Ge,o)),xr=ns?Dn(Ge):void 0,xt=n.useMemo(()=>({allowOutsideWorkspace:a==="editor-only"&&ns,outsideFileGrant:xr,directory:o||void 0}),[a,ns,xr,o]),qe=n.useCallback(async t=>{const i=Dn(t),l=await ka(t,o,a==="editor-only");return l.outsideFileGrant&&l.outsideFileGrant!==i&&ci(u=>u+1),l},[a,o]),Ms=n.useRef(null),[vr,ui]=n.useState({left:!1,right:!1}),wr=n.useCallback(()=>{const t=Ms.current;t&&ui({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),br=n.useRef(wr);br.current=wr,n.useEffect(()=>{const t=Ms.current;if(!t)return;const i=()=>br.current();i(),t.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(t),()=>{t.removeEventListener("scroll",i),l.disconnect()}},[Nt.length]);const[yr,zs]=n.useState({}),[is,$t]=n.useState({}),ze=n.useRef(new Set),Ae=n.useRef(new Set),tt=n.useRef(new Map),jr=n.useRef(0),[Fr,as]=n.useState([]),[di,os]=n.useState(!1),[D,pe]=n.useState(""),{isPlaying:ls,play:fi,stop:mi}=Ra(),[Le,ot]=n.useState(!1),[st,ge]=n.useState(null),[pi,Ie]=n.useState(""),[De,oe]=n.useState(null),[ne,xe]=n.useState(""),[Wt,As]=n.useState(!1),[Nr,hi]=n.useState(`
|
|
11
|
-
`),gi=n.useRef(null),Xe=n.useRef(null),Pe=n.useRef(null),lt=n.useRef(""),_t=n.useRef(""),rt=n.useRef(null),Cr=n.useRef(null),Je=n.useRef(null),Ut=n.useRef(0),Ct=n.useRef(null),[cs,xi]=n.useState(0),[vi,St]=n.useState("idle"),[wi,us]=n.useState(!1),[Kt,Sr]=n.useState(!1),je=ht(t=>t.autoSaveEnabled),bi=ht(t=>t.setAutoSaveEnabled),[Ls,Ht]=n.useState(!1),kt=n.useRef(null),Gt=n.useRef(null),qt=n.useRef(!1),Xt=n.useRef(null),Jt=n.useRef(null),We=n.useRef(null),ds=n.useRef(null),[yi,Is]=n.useState(0),Rt=n.useRef(null),vt=n.useRef({key:"",attempts:0});n.useEffect(()=>()=>{Rt.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(Rt.current),Rt.current=null)},[]);const[wt,Os]=n.useState(null),[bt,ji]=n.useState(null),[ct,kr]=n.useState(""),[Fi,Bs]=n.useState(!1),[Ni,Ci]=n.useState(null),[Si,ki]=n.useState(null),[Ri,Rr]=n.useState(!1),[Ti,Tr]=n.useState(!1),[Vi,$s]=n.useState(!1),[Vr,fs]=n.useState(!1),[Er,Dr]=n.useState(0),ms=n.useRef(null),ps=n.useCallback(t=>{const i=t?.currentTarget??ms.current;if(!i)return;const l=document.activeElement;l&&l!==document.body&&l!==i&&(Ta(l)||i.contains(l))||i.focus({preventScroll:!0})},[]),Ws=n.useRef(null),Pr=!!r.writeFile,Mr=!!r.createDirectory,zr=!!r.rename,Ar=!!r.delete,Lr=!!r.revealPath,Ei=Ss(t=>t.availableApps),Di=Ss(t=>t.isCacheStale),Ir=Ss(t=>t.initialize),Pi=Ss(t=>t.loadInstalledApps);n.useEffect(()=>{Ir()},[Ir]);const Mi=n.useCallback(t=>{r.revealPath&&r.revealPath(t).catch(()=>{Q.error(e("sidebarFilesTree.toast.revealFailed"))})},[r,e]),zi=n.useCallback(async t=>{if(!c?.path||await fa(c.path,t.id,t.appName)||await Rn(c.path,t.appName))return;const u=Eo(c.path)||o;u&&await Rn(u,t.appName)||Q.error(e("filesView.toast.openInAppFailed",{app:t.appName}))},[o,c?.path,e]),_s=n.useCallback((t,i)=>{Os(t),ji(i),kr(t==="rename"&&i.name||""),Bs(!1)},[]),[U,_e]=n.useState(null),Tt=n.useRef(!1),ut=n.useRef(null),[Or,Vt]=n.useState(!1),Qe=ht(t=>t.pendingFileNavigation),hs=ht(t=>t.setPendingFileNavigation),Us=ht(t=>t.pendingFileFocusPath),Ks=ht(t=>t.setPendingFileFocusPath),Br=ht(t=>t.fileEditorKeymap),Qt=Pn(t=>t.settingsDefaultFileViewerPreview),Ai=Pn(t=>t.showMessageTTSButtons);n.useEffect(()=>{const t=()=>{Tt.current=!1,ut.current=null,Vt(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),n.useEffect(()=>()=>{Xt.current!==null&&window.clearTimeout(Xt.current),Jt.current!==null&&window.clearTimeout(Jt.current)},[]);const Li=n.useCallback((t,i)=>{const l=t.split(`
|
|
12
|
-
`),u=Math.max(1,i.start),p=Math.min(l.length,i.end);return u>p?"":l.slice(u-1,p).join(`
|
|
13
|
-
`)},[]),gs=n.useRef(null),Ii=ao({source:"file",fileLabel:c?.path??null,language:c?.path&&ar(c.path)||"text",getCodeForRange:t=>Li(D,oo(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:$r,commentText:xs,setCommentText:Wr,editingDraftId:vs,setSelection:_r,saveComment:Ur,cancel:Yt,reset:Kr,startEdit:Hr,deleteDraft:Gr}=Ii;n.useEffect(()=>{_e(null),Kr(),xe(""),As(!1)},[c?.path,Kr]),n.useEffect(()=>{_r(U)},[U,_r]),n.useEffect(()=>{if(!U&&!vs)return;const t=l=>{const u=l.target;u.closest('[data-comment-input="true"]')||u.closest('[data-comment-card="true"]')||u.closest(".cm-gutterElement")||u.closest("[data-sonner-toast]")||u.closest("[data-sonner-toaster]")||xs.trim()||(_e(null),Yt())},i=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(i),document.removeEventListener("click",t)}},[Yt,xs,vs,U]);const qr=n.useCallback((t,i)=>{const l=i??U??void 0;i&&_e(i),Ur(t,l),_e(null)},[U,Ur]),Xr=n.useCallback((t,i)=>{const l=[];for(const u of i){if(!(u&&typeof u.name=="string"&&u.name.length>0)||!k&&u.name.startsWith(".")||!j&&Lo(u.name))continue;const p=u.name,m=H(u.path||""),y=m?Mo(m)?m:H(`${t}/${m}`):H(`${t}/${p}`),R=u.isDirectory?"directory":"file",K=R==="file"&&p.includes(".")?p.split(".").pop()?.toLowerCase():void 0;l.push({name:p,path:y,type:R,extension:K})}return Po(l)},[j,k]),Oe=n.useCallback(async t=>{const i=H(t.trim());if(!i||ze.current.has(i)||Ae.current.has(i))return;Ae.current=new Set(Ae.current),Ae.current.add(i);const l=jr.current+1;jr.current=l,tt.current=new Map(tt.current),tt.current.set(i,l);const u=()=>tt.current.get(i)===l;await(r.listDirectory?r.listDirectory(i).then(m=>m.entries.map(y=>({name:y.name,path:y.path,isDirectory:y.isDirectory}))):ma.listLocalDirectory(i).then(m=>m.map(y=>({name:y.name,path:y.path,isDirectory:y.isDirectory})))).then(m=>{if(!u())return;const y=Xr(i,m);ze.current=new Set(ze.current),ze.current.add(i),$t(R=>{if(!R[i])return R;const K={...R};return delete K[i],K}),zs(R=>({...R,[i]:y}))}).catch(m=>{if(!u())return;const y=m instanceof Error?m.message:String(m??"");if(y==="Directory not found"&&o&&i!==o){at(o,i),$t(R=>{if(!R[i])return R;const K={...R};return delete K[i],K});return}console.error("Failed to load files directory:",m),$t(R=>({...R,[i]:y}))}).finally(()=>{u()&&(tt.current=new Map(tt.current),tt.current.delete(i),Ae.current=new Set(Ae.current),Ae.current.delete(i))})},[r,Xr,at,o]),ws=n.useCallback(async()=>{o&&(ze.current=new Set,Ae.current=new Set,tt.current=new Map,$t({}),zs(t=>Object.keys(t).length===0?t:{}),await Oe(o))},[Oe,o]),Ye=n.useCallback(async t=>{if(!t){await ws();return}const i=H(t);ze.current=new Set(ze.current),ze.current.delete(i),Ae.current=new Set(Ae.current),Ae.current.delete(i),await Oe(i)},[Oe,ws]),Jr=n.useRef(""),Qr=n.useRef("");n.useEffect(()=>{if(!o)return;const t=`${o}|h${k?"1":"0"}|g${j?"1":"0"}`,i=Jr.current!==o,l=Qr.current!==t;!i&&!l||(i&&(Jr.current=o,pe(""),ge(null),Ie(""),oe(null),P(!1)),l&&(Qr.current=t,ze.current=new Set,Ae.current=new Set,tt.current=new Map,$t({}),zs(u=>Object.keys(u).length===0?u:{}),Oe(o)))},[Oe,o,j,k]),n.useEffect(()=>{if(!r.listDirectory)return;const t=()=>{if(!document.hidden&&he.length>0)for(const i of he)Ye(i)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[he,r.listDirectory,Ye]),n.useEffect(()=>{if(!r.listDirectory||he.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const i of he)Ye(i)},8e3);return()=>clearInterval(t)},[he,r.listDirectory,Ye]);const Oi=n.useCallback(async t=>{if(t?.preventDefault(),!bt||!wt)return;Bs(!0);const i=()=>{Os(null)},l=p=>{Q.error(p)},u=()=>{Bs(!1)};if(wt==="createFile"){if(!ct.trim()){l(e("sidebarFilesTree.toast.filenameRequired")),u();return}if(!r.writeFile){l(e("sidebarFilesTree.toast.writeNotSupported")),u();return}const p=bt.path,m=p?`${p}/`:"",y=H(`${m}${ct.trim()}`);await r.writeFile(y,"").then(async R=>{R.success&&(Q.success(e("sidebarFilesTree.toast.fileCreated")),await Ye(p)),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(wt==="createFolder"){if(!ct.trim()){l(e("sidebarFilesTree.toast.folderNameRequired")),u();return}const p=bt.path,m=p?`${p}/`:"",y=H(`${m}${ct.trim()}`);await r.createDirectory(y).then(async R=>{R.success&&(Q.success(e("sidebarFilesTree.toast.folderCreated")),await Ye(p)),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(wt==="rename"){if(!ct.trim()){l(e("sidebarFilesTree.toast.nameRequired")),u();return}if(!r.rename){l(e("sidebarFilesTree.toast.renameNotSupported")),u();return}const p=bt.path,m=p.split("/").slice(0,-1).join("/"),y=m?`${m}/`:"",R=H(`${y}${ct.trim()}`);await r.rename(p,R).then(async K=>{K.success&&(Q.success(e("sidebarFilesTree.toast.renamedSuccessfully")),await Ye(m),o&&X(o,p),(c?.path===p||c?.path.startsWith(`${p}/`))&&(o&&me(o,null),pe(""),ge(null),Ie(""),oe(null),f&&P(!1))),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(wt==="delete"){if(!r.delete){l(e("sidebarFilesTree.toast.deleteNotSupported")),u();return}const p=bt.path,m=p.split("/").slice(0,-1).join("/");await r.delete(p).then(async y=>{y.success&&(Q.success(e("sidebarFilesTree.toast.deletedSuccessfully")),await Ye(m),o&&X(o,p),(c?.path===p||c?.path.startsWith(`${p}/`))&&(o&&me(o,null),pe(""),ge(null),Ie(""),oe(null),f&&P(!1))),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}u()},[wt,bt,ct,r,Ye,f,X,o,c?.path,me,e]);n.useEffect(()=>{if(!T){as([]),os(!1);return}const t=S.trim();if(!t){as([]),os(!1);return}let i=!1;return os(!0),W(T,t,150,{includeHidden:k,respectGitignore:!j,type:"file"}).then(l=>{if(i)return;const p=l.filter(m=>j||!Io(m.path)).map(m=>({name:m.name,path:H(m.path),type:"file",extension:m.extension,relativePath:m.relativePath}));as(p)}).catch(()=>{i||as([])}).finally(()=>{i||os(!1)}),()=>{i=!0}},[T,S,W,k,j]);const Yr=n.useCallback(async t=>{const i=await qe(t);if(r.readFile)return(await r.readFile(t,{...i,directory:o||void 0})).content??"";const l=new URLSearchParams({path:t});i.allowOutsideWorkspace&&l.set("allowOutsideWorkspace","true"),i.outsideFileGrant&&l.set("outsideFileGrant",i.outsideFileGrant),o&&l.set("directory",o);const u=await Tn(`/api/fs/read?${l.toString()}`);if(!u.ok){const p=await u.json().catch(()=>({error:u.statusText}));throw new Error(p.error||e("filesView.error.readFileFailed"))}return u.text()},[r,qe,o,e]),dt=n.useCallback(async t=>{if(r.statFile){const i=await qe(t),l=await r.statFile(t,{...i,directory:o||void 0});return{path:l.path,size:l.size,mtimeMs:l.mtimeMs}}return null},[r,qe,o]);n.useEffect(()=>{if(!o||!r.statFile||Z.length===0)return;let t=!1;const i=[...Z];return Promise.all(i.map(async l=>{try{const u=await qe(l),p=await r.statFile?.(l,{...u,directory:o||void 0});!t&&p&&!p.isFile&&X(o,l)}catch(u){!t&&Xn(u)&&X(o,l)}})),()=>{t=!0}},[r,Z,X,qe,o]);const Hs=n.useMemo(()=>D.length>It?`${D.slice(0,It)}
|
|
14
|
-
|
|
15
|
-
… truncated …`:D,[D]),Me=ne!==Hs,Et=n.useCallback(async()=>{if(!c||!r.writeFile)return Q.error(e("filesView.toast.savingNotSupported")),!1;const t=Cs(c.path)||Kt;if(!Ro({selectedFilePath:c.path,loadedFilePath:De,fileLoading:Le,isDirty:Me,draftContent:ne,fileContent:D,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${c.path}".`):ne===""&&D!==""&&De!==c.path&&console.warn(`[saveDraft] refusing to save empty draft for "${c.path}" (${D.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!Me)return!0;As(!0);try{const i=Wo(ne,Nr);if(!(await r.writeFile(c.path,i))?.success)return Q.error(e("filesView.toast.writeFileFailed")),!1;if(pe(ne),o&&Es(c.path,o)){const u=Ts(o,c.path);u&&Va.requestGitRefresh({directory:o,paths:[u]})}if(o&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(H(c.path))){const u=Ea.getState().projects.find(p=>H(p.path)===H(o));if(u)try{await so(u.id)}catch{Q.error(e("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return c?.path&&or(c.path)&&(lt.current=ne,_t.current=ne),dt(c.path).then(u=>{u&&(Je.current=u)}).catch(()=>{}),!0}catch(i){return Q.error(i instanceof Error?i.message:e("filesView.toast.saveFailed")),!1}finally{As(!1)}},[Kt,ne,D,Le,r,Me,Nr,De,dt,o,c,e]);n.useEffect(()=>{je||(St("idle"),Xe.current&&(clearTimeout(Xe.current),Xe.current=null))},[je]);const Zr=1500;n.useEffect(()=>{const t=!!(c&&r.writeFile),i=!!(c?.path&&(Cs(c.path)||Kt));if(ko({autoSaveEnabled:je,isDirty:Me,canWrite:t,isSaving:Wt,fileLoading:Le,selectedFilePath:c?.path,loadedFilePath:De,isNonEditableBinary:i}))return Xe.current=setTimeout(()=>{Et().then(l=>{l&&(St("saved"),setTimeout(()=>St("idle"),2e3))})},Zr),()=>{Xe.current&&(clearTimeout(Xe.current),Xe.current=null)}},[je,Kt,ne,Le,Me,De,c,r.writeFile,Wt,Et]),n.useEffect(()=>{St("idle")},[c?.path]),Da({save_file:t=>{if(!(t.target instanceof Node)||!ds.current?.contains(t.target))return!1;Xe.current&&(clearTimeout(Xe.current),Xe.current=null),Wt||Et().then(i=>{i&&(St("saved"),setTimeout(()=>St("idle"),2e3))})},find_in_file:t=>{if(!(t.target instanceof Node))return!1;if(Ze&&$e()==="preview"){if(f||!(_?Ws.current:ms.current)?.contains(t.target))return!1;fs(!0),Dr(l=>l+1);return}if(!ds.current?.contains(t.target))return!1;le(!0)}});const en=n.useCallback(async t=>{const i=Ut.current+1;Ut.current=i;const l=()=>{if(!o)return!1;const R=He.getState().byRoot[o],K=R?.selectedPath??R?.openPaths[0]??null;return Ut.current===i&&K===t.path};if(ge(null),Ie(""),oe(null),Sr(!1),ot(!0),await qe(t.path),!l())return;const u=Mn(t.path),p=zn(t.path),m=An(t.path),y=Cs(t.path);if(f&&P(!0),d.isDesktop&&u&&!p){pe(""),xe("");return}if(!d.isDesktop&&u&&!p){pe(""),xe(""),oe(t.path),ot(!1);return}if(m){pe(""),xe(""),oe(t.path),ot(!1);return}if(y){pe(""),xe(""),oe(t.path),ot(!1);return}await Yr(t.path).then(R=>{if(!l())return;if(Pa(R)){Sr(!0),pe(""),xe(""),oe(t.path);return}const K=oi(R);hi($o(R)),pe(K),lt.current=K,_t.current=K,xe(K.length>It?`${K.slice(0,It)}
|
|
16
|
-
|
|
17
|
-
… truncated …`:K),oe(t.path),dt(t.path).then(mt=>{mt&&l()&&(Je.current=mt)}).catch(()=>{})}).catch(R=>{if(l()){if(Oo(R)){if(ot(!1),o&&me(o,null),ge(null),pe(""),xe(""),oe(null),Je.current=null,E.trim().length>0&&V(""),f&&P(!1),o){const mt=[...Gn(t.path,o),t.path];mt.length>0&&rs(o,mt);for(const pt of mt)ze.current.has(pt)||Oe(pt)}return}if(Xn(R)){o&&X(o,t.path),pe(""),xe(""),ge(null),Je.current=null,f&&P(!1);return}pe(""),xe(""),ge(R instanceof Error?R.message:e("filesView.error.readFileFailed")),Je.current=null}}).finally(()=>{l()&&ot(!1)})},[rs,f,Oe,Yr,dt,X,qe,o,d.isDesktop,E,me,e]),bs=n.useCallback(async(t,i)=>{if(!o)return;const l=Gn(t,o),u=i?[...l,t]:l;u.length>0&&rs(o,u);const p=u.map(m=>{if(!ze.current.has(m))return Oe(m)}).filter(Boolean);await Promise.all(p)},[rs,Oe,o]),tn=n.useCallback((t,i)=>{const l=i.findIndex(u=>u.path===t);return l===-1||i.length<=1?null:i[l+1]??i[l-1]??null},[]),Re=n.useCallback(async t=>{if(qt.current)qt.current=!1;else if(Me){Ht(!0),kt.current=t;return}o&&(me(o,t.path),bs(t.path,!1)),ge(null),Ie(""),pe(""),lt.current="",_t.current="",xe(""),oe(null),f&&P(!0)},[bs,Me,f,o,me]);n.useEffect(()=>{c?.path&&bs(c.path,!1)},[bs,c?.path]),n.useEffect(()=>{if(!c){Ut.current+=1,Ct.current=null,ot(!1);return}if(De===c.path||Ct.current===c.path)return;const t=c.path;Ct.current=t,en(c).finally(()=>{Ct.current===t&&(Ct.current=null)})},[cs,en,De,c]);const Gs=n.useRef(Me);Gs.current=Me,n.useEffect(()=>ro(({runtimeKey:t,paths:i})=>{const l=c?.path;t!==va()||!l||Gs.current||!i.includes(H(l))||(Ut.current+=1,Ct.current=null,Je.current=null,Ie(""),ge(null),oe(null),xi(u=>u+1))}),[c?.path]),n.useEffect(()=>{if(!c?.path||De!==c.path)return;let t=!1;const i=window.setInterval(()=>{document.hidden||dt(c.path).then(l=>{if(t||!l)return;const u=Je.current;if(!u||u.path!==c.path){Je.current=l;return}const p=l.mtimeMs!==void 0&&u.mtimeMs!==void 0&&l.mtimeMs!==u.mtimeMs,m=l.size!==u.size;!p&&!m||Gs.current||(Je.current=l,oe(null))}).catch(()=>{})},2e3);return()=>{t=!0,window.clearInterval(i)}},[De,dt,c?.path]);const Bi=n.useCallback(()=>{const t=kt.current,i=Gt.current;if(kt.current=null,Gt.current=null,qt.current=!0,Ht(!1),xe(Hs),i){o&&et(o,i),c?.path===i&&(t?Re(t):(o&&me(o,null),pe(""),ge(null),Ie(""),oe(null),f&&P(!1)));return}if(t){Re(t);return}},[Hs,Re,f,et,o,c?.path,me]),$i=n.useCallback(async()=>{const t=kt.current,i=Gt.current;if(!await Et()){qt.current=!1;return}if(kt.current=null,Gt.current=null,qt.current=!0,Ht(!1),i){o&&et(o,i),c?.path===i&&(t?await Re(t):(o&&me(o,null),pe(""),ge(null),Ie(""),oe(null),f&&P(!1)));return}if(t){await Re(t);return}},[Re,f,et,o,Et,c?.path,me]),sn=n.useCallback(t=>{const i=c?.path===t,l=tn(t,Nt);if(i&&Me){Ht(!0),kt.current=l,Gt.current=t;return}if(o&&et(o,t),!!i){if(l){Re(l);return}o&&me(o,null),pe(""),ge(null),Ie(""),oe(null),f&&P(!1)}},[tn,Re,Me,f,Nt,et,o,c?.path,me]),Wi=n.useCallback(t=>{if(Z.includes(t))return"open";if(A?.files){const i=t.startsWith(o+"/")?t.slice(o.length+1):t,l=A.files.find(u=>u.path===i);if(l){if(l.index==="A"||l.working_dir==="?")return"git-added";if(l.index==="D")return"git-deleted";if(l.index==="M"||l.working_dir==="M")return"git-modified"}}return null},[Z,A,o]),_i=n.useCallback(t=>{if(!A?.files)return null;const i=t.startsWith(o+"/")?t.slice(o.length+1):t,l=i?`${i}/`:"";let u=0,p=0;for(const m of A.files)m.path.startsWith(l)&&((m.index==="M"||m.working_dir==="M")&&u++,(m.index==="A"||m.working_dir==="?")&&p++);return u+p>0?{modified:u,added:p}:null},[A,o]),Ui=n.useCallback(async t=>{const i=H(t);o&&(gr(o,i),ze.current.has(i)||await Oe(i))},[Oe,o,gr]),Ki=n.useMemo(()=>({canRename:zr,canCreateFile:Pr,canCreateFolder:Mr,canDelete:Ar,canReveal:Lr}),[zr,Pr,Mr,Ar,Lr]);function rn(t,i){const l=yr[t]??[];return l.map((u,p)=>{const m=u.type==="directory",y=m&&he.includes(u.path),R=c?.path===u.path,K=p===l.length-1;return s.jsxs("li",{className:"relative",children:[i>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),K&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),s.jsx(Uo,{node:u,root:o,isExpanded:y,isActive:R,isMobile:f,isBrowserClient:F,alwaysShowActions:N,status:m?void 0:Wi(u.path),badge:m?_i(u.path):void 0,permissions:Ki,downloadFile:r.downloadFile,contextMenuPath:Ni,setContextMenuPath:Ci,rightClickMenuPath:Si,setRightClickMenuPath:ki,onSelect:Re,onToggle:Ui,onRevealPath:Mi,onOpenDialog:_s}),m&&y&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[is[u.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:is[u.path],children:is[u.path]}),s.jsxs(z,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ye(u.path)},children:[s.jsx(b,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):null,rn(u.path,i+1)]})]},u.path)})}const Fe=!!(c?.path&&Mn(c.path)),ys=!!(c?.path&&zn(c.path)),Be=!!(c?.path&&An(c.path)),qs=!!(c?.path&&(Cs(c.path)||Kt)),nt=qs&&!Fe&&!Be,nn=n.useMemo(()=>H(Qe?.path??""),[Qe?.path]),Dt=!!(Qe&&nn&&Ge&&Ge===nn&&!Le&&!st&&!Fe&&!Be&&!nt),ft=n.useMemo(()=>Ts(o,Ge),[Ge,o]),Hi=!!(c&&(!Fe||ys)&&!Be&&!nt&&D.length>0),Gi=!!(c&&ft.length>0),Ue=!!(c&&!ns&&!qs&&!Fe&&r.writeFile&&D.length<=It),Ze=!!(c?.path&&Jn(c.path)),Zt=!!(c?.path&&_o(c.path)),Pt=!!(c?.path&&fr(c.path)),es=!!(c?.path&&or(c.path)),Xs=!!(c&&!qs&&!Fe)&&!Ze&&!es&&!(Pt&&B==="preview"),qi=Ze&&we==="edit"||Pt&&B==="edit"||Zt&&ue==="text"||!Ze&&!Pt&&!Zt&&O==="edit",js=n.useMemo(()=>Ge?Ma(Ge):null,[Ge]),[an,Js]=n.useState(null);n.useEffect(()=>{let t=!1;const i=c?.path;if(!i||js){Js(null);return}return Js(null),za(i).then(l=>{t||Js(l)}),()=>{t=!0}},[c?.path,js]),n.useEffect(()=>{!Ue&&O==="edit"&&ve("view")},[Ue,O]);const Qs="aiworker:files:md-viewer-mode",Ys="aiworker:files:html-viewer-mode",Zs="aiworker:files:json-viewer-mode";n.useEffect(()=>{const t=c?.path;if(!t)return;ve(ae.current[t]??"edit");let i=Qt?"preview":"edit";try{const p=localStorage.getItem(Qs);(p==="preview"||p==="edit")&&(i=p)}catch{}ce(ye.current[t]??i);let l=Qt?"preview":"edit";try{const p=localStorage.getItem(Ys);(p==="preview"||p==="edit")&&(l=p)}catch{}G(Te.current[t]??l),re(de.current[t]??(Qt?"preview":"edit"));let u=Qt?"tree":"text";try{const p=localStorage.getItem(Zs);(p==="tree"||p==="text")&&(u=p)}catch{}be(u)},[c?.path,Qt]);const Xi=n.useCallback(t=>{const i=c?.path;i&&(ae.current[i]=t),ve(t)},[c?.path]),Ji=n.useCallback(t=>{const i=c?.path;i&&(ye.current[i]=t),ce(t);try{localStorage.setItem(Qs,t)}catch{}},[c?.path]),$e=n.useCallback(()=>we,[we]),on=c&&Ze&&$e()==="preview"&&!Le?c.path:null;n.useEffect(()=>{!on||f||ps()},[ps,_,f,on]);const Qi=n.useCallback(t=>{be(t);try{localStorage.setItem(Zs,t)}catch{}},[]),Yi=n.useCallback(t=>{const i=c?.path;i&&(Te.current[i]=t),G(t);try{localStorage.setItem(Ys,t)}catch{}},[c?.path]),Zi=n.useCallback(t=>{const i=c?.path;if(i&&(de.current[i]=t),Pe.current&&(clearTimeout(Pe.current),Pe.current=null),rt.current!==null&&(cancelAnimationFrame(rt.current),rt.current=null),t==="edit")xe(lt.current||D),re(t);else{lt.current=ne;const l=i;re("edit"),rt.current=requestAnimationFrame(()=>{rt.current=requestAnimationFrame(()=>{rt.current=null,!(o&&l&&He.getState().byRoot[o]?.selectedPath!==l)&&(ie(u=>u+1),re("preview"))})});return}},[ne,D,o,c?.path]),er=n.useCallback(async(t,i)=>{if(!r.writeFile||i===_t.current)return!1;if(!(await r.writeFile(t,i))?.success)return Q.error(e("filesView.toast.writeFileFailed")),!1;lt.current=i,_t.current=i,xe(i);const u=await dt(t).catch(()=>null);return u&&(Je.current=u),!0},[r,dt,e]);n.useEffect(()=>()=>{Pe.current&&(clearTimeout(Pe.current),Pe.current=null),rt.current!==null&&(cancelAnimationFrame(rt.current),rt.current=null)},[se,c?.path]);const ea=n.useCallback(t=>{if(lt.current=t,!je||!c?.path||se!=="preview"||!r.writeFile)return;Pe.current&&clearTimeout(Pe.current);const i=c.path;Pe.current=setTimeout(()=>{Pe.current=null,er(i,t).then(l=>{l&&(us(!0),setTimeout(()=>us(!1),1500))}).catch(l=>{Q.error(l instanceof Error?l.message:e("filesView.toast.saveFailed"))})},Zr)},[je,se,r.writeFile,er,c?.path,e]),ta=n.useMemo(()=>es&&(lt.current||ne)||D,[ne,D,es]),ln=n.useCallback(()=>B,[B]);n.useEffect(()=>{const t=l=>{const u=l?"preview":"edit",p=l?"tree":"text";for(const m of Z)ae.current[m]="edit",Jn(m)&&(ye.current[m]=u),fr(m)&&(Te.current[m]=u),or(m)&&(de.current[m]=u);ve("edit"),ce(u),G(u),re(u),be(p);try{localStorage.setItem(Qs,u),localStorage.setItem(Ys,u),localStorage.setItem(Zs,p)}catch{}},i=l=>{const u=!!l.detail?.enabled;t(u)};return window.addEventListener("aiworker:file-viewer-preview-mode-changed",i),()=>{window.removeEventListener("aiworker:file-viewer-preview-mode-changed",i)}},[Z]),n.useEffect(()=>{if(!Qe||!o)return;const t=()=>{typeof window>"u"||Rt.current===null&&(Rt.current=window.requestAnimationFrame(()=>{Rt.current=null,Is(it=>it+1)}))},i=(it,yt)=>{if(it.state.doc.length!==yt.length)return!1;if(yt.length===0)return!0;const nr=Math.min(128,yt.length);if(it.state.sliceDoc(0,nr)!==yt.slice(0,nr))return!1;const Cn=Math.max(0,yt.length-nr);return it.state.sliceDoc(Cn,yt.length)===yt.slice(Cn)},l=H(Qe.path);if(!l){hs(null),vt.current={key:"",attempts:0};return}const u=`${l}:${Qe.line}:${Qe.column??1}`;if(vt.current.key!==u&&(vt.current={key:u,attempts:0}),c?.path!==l){if(Ls)return;Re(Ft(l));return}if(Le||De!==l)return;if(st||Fe||Be||nt){hs(null),vt.current={key:"",attempts:0};return}if(!Ue)return;if(O!=="edit"){ve("edit");return}const p=We.current;if(!p){t();return}if(!i(p,ne)){t();return}const m=Math.max(1,Math.min(Qe.line,p.state.doc.lines)),y=p.state.doc.line(m),R=Math.max(1,Qe.column||1),K=Math.max(0,y.to-y.from),mt=Math.min(K,R-1),pt=y.from+mt;if(!(p.state.selection.main.head===pt)||vt.current.attempts===0){vt.current.attempts+=1,p.dispatch({selection:{anchor:pt},effects:jt.scrollIntoView(pt,{y:"center"})}),p.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const it=We.current;it&&(it.dispatch({selection:{anchor:pt},effects:jt.scrollIntoView(pt,{y:"center"})}),it.focus())}),hs(null),vt.current={key:"",attempts:0}},[Ue,Ls,ne,yi,st,Le,Fe,Be,nt,De,Re,Qe,o,c?.path,hs,O,Ft]),n.useEffect(()=>{if(!Us||!o)return;const t=H(Us);if(!t){Ks(null);return}c?.path===t&&(Le||De!==t||(!st&&!Fe&&!Be&&!nt&&Ue&&O==="edit"&&We.current?.focus(),Ks(null)))},[Ue,st,Le,Fe,Be,nt,De,Us,o,c?.path,Ks,O]);const Mt=n.useCallback(t=>{if(!f||!t||!t.hasFocus||typeof window>"u")return;const i=window.visualViewport;if(!i)return;const l=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,l-(i.offsetTop+i.height))<=0)return;const p=t.state.selection.main.head,m=t.coordsAtPos(p);if(!m)return;const y=Math.round(i.offsetTop+i.height),K=m.bottom+20-y;K<=0||(t.scrollDOM.scrollTop+=K)},[f]);n.useEffect(()=>{if(!f||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{Mt(We.current)})},i=window.visualViewport;return i?.addEventListener("resize",t),i?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{i?.removeEventListener("resize",t),i?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[f,Mt]),Aa("open_go_to_line",t=>{if(!Ue||O!=="edit"||f)return!1;const i=t.target;if(i?.closest('[role="dialog"]')||!(i instanceof Node)||!ds.current?.contains(i))return!1;const l=!!i?.closest(".cm-editor");if(!!i?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!l)return!1;$s(!0)});const Fs=ht(t=>t.editorFontSize),cn=n.useMemo(()=>{if(!c?.path)return[In(v,{fontSize:Fs})];const t=ar(c.path),i=[In(v,t?{syntaxColors:!1,fontSize:Fs}:{fontSize:Fs})],l=js??an;return l&&i.push(l),t&&i.push(qa({language:t,themeName:v.metadata.id,theme:Ya(v)})),J&&i.push(jt.lineWrapping),f&&i.push(jt.updateListener.of(u=>{u.view.hasFocus&&(u.selectionSet||u.focusChanged||u.viewportChanged||u.geometryChanged)&&window.requestAnimationFrame(()=>{Mt(u.view)})})),i},[v,c?.path,js,an,J,f,Mt,Fs]),un=n.useMemo(()=>({light:Ve.metadata.id,dark:Ee.metadata.id}),[Ve.metadata.id,Ee.metadata.id]),ts=c?.path&&Be&&(!xt.allowOutsideWorkspace||xt.outsideFileGrant)?`${c.path}|${xt.allowOutsideWorkspace?"outside":"workspace"}|${xt.outsideFileGrant??""}|${cs}`:"",Ns=c?.path&&Pt&&B==="preview"&&!d.isVSCode?`${c.path}|${cs}`:"",dn=e("filesView.error.readFileFailed"),{readyKey:fn,nonce:sa}=Qn(Ns,ge,dn),{readyKey:mn,nonce:pn}=Qn(ts,ge,dn),ra=!!(Ns&&fn!==Ns),hn=!!(ts&&mn!==ts),gn=c?.path&&Fe?ys?`data:${La(c.path)};utf8,${encodeURIComponent(D)}`:pi:"",xn=c?.path&&Be&&ts&&mn===ts?Vn().authenticatedAsset("/api/fs/raw",{path:c.path,allowOutsideWorkspace:xt.allowOutsideWorkspace?"true":void 0,outsideFileGrant:xt.outsideFileGrant,directory:o||void 0}):"",vn=n.useCallback(t=>s.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:s.jsx("iframe",{src:xn,className:"h-full w-full border-0",title:t.name},pn)}),[xn,pn]);n.useEffect(()=>{let t=!1,i="";return(async()=>{if(!c?.path||!Fe||ys){Ie("");return}ge(null);const u=await qe(c.path);if(t)return;await(r.readFileBinary?r.readFileBinary(c.path,u).then(m=>m.dataUrl):(async()=>{const m=await Tn("/api/fs/raw",{query:{path:c.path,allowOutsideWorkspace:u.allowOutsideWorkspace?"true":void 0,outsideFileGrant:u.outsideFileGrant,directory:o||void 0}});if(!m.ok)throw new Error(e("filesView.error.readFileFailed"));const y=await m.blob();return i=URL.createObjectURL(y),t?(URL.revokeObjectURL(i),i="",""):i})()).then(m=>{t||(Ie(m),oe(c.path))}).catch(m=>{t||(Ie(""),ge(m instanceof Error?m.message:e("filesView.error.readFileFailed")),oe(null))}).finally(()=>{t||ot(!1)})})(),()=>{t=!0,i&&URL.revokeObjectURL(i)}},[cs,r,Fe,ys,qe,o,c?.path,xt,e]);const na=n.useCallback(()=>Os(null),[]),ia=n.useMemo(()=>lo({drafts:$r,editingDraftId:vs,commentText:xs,onTextChange:Wr,selection:U,isDragging:Or,fileLabel:c?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:qr,onCancel:()=>{_e(null),Yt()},onEdit:t=>{Hr(t),_e({start:t.startLine,end:t.endLine})},onDelete:Gr}),[Yt,xs,Gr,vs,$r,qr,Or,U,c?.path,Wr,Hr]),wn=Kn(),bn=Kn(),tr=Wa("unified"),Ke=D.length>It,sr=n.useMemo(()=>Ke?Bo(D):void 0,[D,Ke]),yn=n.useCallback((t,i,l)=>{const u={name:t.name,contents:i,lang:ar(t.path)||void 0},p=m=>s.jsx(Qa,{file:Ke&&sr?{...u,cacheKey:`${t.path}:${sr}`}:u,options:{disableFileHeader:!0,overflow:J?"wrap":"scroll",theme:un,themeType:v.metadata.variant==="dark"?"dark":"light"},className:Ke?"block w-full":"block h-full w-full",style:Ke?void 0:{height:"100%"}},m);return Ke?s.jsx("div",{className:"h-full",children:s.jsx(Za.Provider,{value:l.virtualizer,children:s.jsx(eo.Provider,{value:tr,children:p(`${t.path}:${tr?"pool":"pending"}`)})})}):s.jsx("div",{className:"h-full",children:p(t.path)})},[v.metadata.variant,Ke,sr,un,tr,J]),jn=({exitFullscreenOnly:t=!1,layout:i="floating"}={})=>{if(!c)return null;const l=i==="docked",u=Ia(Oa("save_file")),p=l?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",m=(y,R)=>s.jsxs(zt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:R})}),s.jsx(Lt,{side:"bottom",sideOffset:6,children:y})]});return s.jsxs("div",{className:p,children:[Ue&&qi&&s.jsxs(s.Fragment,{children:[Wt?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[s.jsx(b,{name:"loader-4",className:"size-3.5 animate-spin"}),e("filesView.editor.saving")]}):je&&vi==="saved"&&!Me?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[s.jsx(b,{name:"check",className:"size-3.5"}),e("filesView.editor.saved")]}):Me?m(e(je?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:u}),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{Et()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(je?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:u}),"aria-label":e("filesView.editor.saveAria",{shortcut:u}),children:s.jsx(b,{name:"save-3",className:"size-4"})})):null,m(e(je?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>bi(!je),className:q("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",je?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(je?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":e(je?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:je?s.jsx(b,{name:"file-check-fill",className:"size-4"}):s.jsx(b,{name:"file-check",className:"size-4"})}))]}),s.jsxs(mr,{onOpenChange:Ce,children:[s.jsxs(zt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(pr,{asChild:!0,children:s.jsx(z,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.openInDesktopApp"),"aria-label":e("filesView.editor.openInDesktopApp"),children:s.jsx(b,{name:"file-transfer",className:"size-4"})})})})}),s.jsx(Lt,{side:"bottom",sideOffset:6,children:e("filesView.editor.openInDesktopApp")})]}),s.jsxs(hr,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[Ei.map(y=>s.jsxs(Rs,{className:"flex items-center gap-2",onClick:()=>{zi(y)},children:[s.jsx(Do,{label:y.label,iconDataUrl:y.iconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:y.label})]},y.id)),Di?s.jsxs(Rs,{className:"flex items-center gap-2",onClick:()=>{Pi(!0)},children:[s.jsx(b,{name:"refresh",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:e("filesView.editor.refreshApps")})]}):null]})]}),!Fe&&!Be&&!nt&&s.jsxs(s.Fragment,{children:[m(e(J?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Ne(!J),className:q("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",J?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(J?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:s.jsx(b,{name:"text-wrap",className:"size-4"})})),O==="edit"&&s.jsxs(s.Fragment,{children:[m(e("filesView.editor.findInFile"),s.jsx(z,{variant:"ghost",size:"sm",onClick:y=>{le(!ee),y.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:s.jsx(b,{name:"search",className:"size-4"})})),m(e("filesView.editor.goToLine"),s.jsx(z,{variant:"ghost",size:"sm",onClick:y=>{$s(R=>!R),y.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.goToLine"),children:s.jsx(b,{name:"menu-fold-2",className:"size-4"})})),s.jsx(wo,{open:Vi,onOpenChange:$s,view:We.current,variant:"inline"})]})]}),Xs&&Ue&&!Zt&&!Pt&&s.jsx(ur,{currentMode:O==="view"?"preview":"edit",onToggle:()=>{Xi(O==="view"?"edit":"view")}}),Ze&&m(e($e()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Ji($e()==="preview"?"edit":"preview"),className:q("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",$e()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:e($e()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":e($e()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(b,{name:$e()==="preview"?"eye":"eye-off",className:"size-4"})})),fr(c?.path??"")&&s.jsx(ur,{currentMode:ln(),onToggle:()=>{Yi(ln()==="preview"?"edit":"preview")}}),Ze&&$e()==="preview"&&m(e("filesView.editor.findInFile"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{fs(!0),Dr(y=>y+1)},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:s.jsx(b,{name:"search",className:"size-4"})})),Ze&&$e()==="preview"&&Ai&&s.jsxs(zt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(z,{variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent","aria-label":e(ls?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{ls?mi():D.trim()&&fi(D)},children:ls?s.jsx(b,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(b,{name:"volume-up",className:"size-4"})})}),s.jsx(Lt,{sideOffset:8,children:e(ls?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),es&&s.jsxs(s.Fragment,{children:[s.jsx(ur,{currentMode:se,onToggle:()=>Zi(se==="preview"?"edit":"preview")}),se==="preview"&&s.jsx(z,{variant:"ghost",size:"sm",onClick:async()=>{const y=Cr.current?.getXml();if(Pe.current&&(clearTimeout(Pe.current),Pe.current=null),c?.path&&y){if(!await er(c.path,y))return;us(!0),setTimeout(()=>us(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.diagram.saveDiagram"),children:wi?s.jsx(b,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(b,{name:"save-3",className:"size-4"})})]}),Zt&&m(e(ue==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Qi(ue==="tree"?"text":"tree"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(ue==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:ue==="tree"?s.jsx(b,{name:"code-sslash",className:"size-4"}):s.jsx(b,{name:"node-tree",className:"size-4"})})),Hi&&m(e("filesView.editor.copyFileContents"),s.jsx(z,{variant:"ghost",size:"sm",onClick:async()=>{(await Vs(D)).ok?(Rr(!0),Xt.current!==null&&window.clearTimeout(Xt.current),Xt.current=window.setTimeout(()=>{Rr(!1)},1200)):Q.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFileContents"),"aria-label":e("filesView.editor.copyFileContents"),children:Ri?s.jsx(b,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(b,{name:"clipboard",className:"size-4"})})),Gi&&m(e("filesView.editor.copyFilePathTitle",{path:ft}),s.jsx(z,{variant:"ghost",size:"sm",onClick:async()=>{(await Vs(ft)).ok?(Tr(!0),Jt.current!==null&&window.clearTimeout(Jt.current),Jt.current=window.setTimeout(()=>{Tr(!1)},1200)):Q.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFilePathTitle",{path:ft}),"aria-label":e("filesView.editor.copyFilePathTitle",{path:ft}),children:Ti?s.jsx(b,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(b,{name:"file-copy-2",className:"size-4"})})),r.downloadFile&&m(e("filesView.editor.saveFile"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{const y=r.downloadFile;y&&y(c.path).catch(R=>{console.error("Download failed:",R),Q.error(e("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.saveFile"),"aria-label":e("filesView.editor.saveFile"),children:s.jsx(b,{name:"download",className:"size-4"})})),t?m(e("filesView.editor.exitFullscreen"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Y(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.exitFullscreen"),"aria-label":e("filesView.editor.exitFullscreen"),children:s.jsx(b,{name:"fullscreen-exit",className:"size-4"})})):!f&&a==="full"&&m(e(_?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Y(!_),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e(_?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":e(_?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:_?s.jsx(b,{name:"fullscreen-exit",className:"size-4"}):s.jsx(b,{name:"fullscreen",className:"size-4"})}))]})},rr=s.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[s.jsx(Zn,{open:Ls,onOpenChange:t=>{t||Ht(!0)},children:s.jsxs(ei,{showCloseButton:!1,className:"max-w-md",children:[s.jsxs(ti,{children:[s.jsx(si,{children:e("filesView.unsaved.title")}),s.jsx(ri,{children:e("filesView.unsaved.description")})]}),s.jsxs(ni,{children:[s.jsx(z,{variant:"outline",onClick:()=>{$i()},disabled:Wt,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:e("filesView.unsaved.saveChanges")}),s.jsx(z,{variant:"destructive",onClick:Bi,children:e("filesView.unsaved.discard")})]})]})}),s.jsxs("div",{className:q("flex flex-col flex-shrink-0",L&&"border-b border-border/40"),children:[L?s.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[f&&$&&s.jsx("button",{type:"button",onClick:()=>P(!1),"aria-label":e("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:s.jsx(b,{name:"arrow-left-s",className:"size-5"})}),f?c?s.jsxs(mr,{children:[s.jsx(pr,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":e("filesView.editor.openFilesAria"),children:[s.jsx(ks,{filePath:c.path,extension:c.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(qn,{name:c.name}),s.jsx(b,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(hr,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:Nt.map(t=>{const i=c?.path===t.path;return s.jsxs(Rs,{onSelect:l=>{if(l.target.closest("[data-close-open-file]")){l.preventDefault();return}i||Re(t)},className:q("flex min-w-0 items-center justify-between gap-2 overflow-hidden",i&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[s.jsx(ks,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(qn,{name:t.name})]}),s.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:l=>{l.preventDefault(),l.stopPropagation()},onClick:l=>{l.preventDefault(),l.stopPropagation(),sn(t.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(b,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")}):Nt.length>0?s.jsxs("div",{className:"relative min-w-0 flex-1",children:[vr.left&&s.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),vr.right&&s.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),s.jsx("div",{ref:Ms,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:Nt.map(t=>{const i=c?.path===t.path;return s.jsxs("div",{title:Ts(o,t.path),className:q("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",i?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[s.jsx(ks,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx("button",{type:"button",onClick:()=>{i||Re(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),s.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),sn(t.path)},className:q("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!i&&!N&&"opacity-0 group-hover:opacity-100"),"aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(b,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")})]}):null,c?s.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[ft&&!f?s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:ft,children:ft}):null,s.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:jn({layout:"docked"})})]}):null]}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:s.jsx(lr,{ref:wn.setScroller,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",Ke&&"[overflow-anchor:none]"),children:c?Le||hn?I?s.jsx("div",{className:"p-3"}):s.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(b,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.loading")]}):st?s.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:st}):Fe?s.jsx("div",{className:"flex h-full items-center justify-center p-3",children:s.jsx("img",{src:gn,alt:c?.name??e("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):Be?vn(c):nt?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),r.downloadFile?s.jsxs(z,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=r.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),Q.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(b,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):c&&es&&se==="preview"?s.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(Vo,{ref:Cr,xml:ta,onChange:ea},`${c.path}:${Se}`)}):c&&Zt&&ue==="tree"?s.jsx(cr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.jsonViewerUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToTextMode")})]}),children:s.jsx("div",{className:"h-full overflow-auto",children:s.jsx(Ja,{jsonString:D,maxHeight:"100%",initiallyExpandedDepth:2})})}):c&&Ze&&$e()==="preview"?s.jsxs("div",{className:"relative h-full min-h-0",children:[s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:ps,ref:t=>{gs.current=t,ms.current=t},children:[s.jsx($n,{containerRef:gs,filePath:c.path,fileContent:D}),D.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(D.length/1024)})}),s.jsx(cr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(Ln,{content:D,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),!_&&s.jsx(Un,{containerRef:ms,open:Vr,onOpenChange:fs,focusNonce:Er})]}):c&&Pt&&B==="preview"?ra?s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:e("common.loading")}):s.jsx("div",{className:"h-full overflow-hidden",children:s.jsx("iframe",{src:!d.isVSCode&&fn===Ns?(()=>{const t=c.path.split("/").map(i=>encodeURIComponent(i)).join("/");return Vn().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:d.isVSCode?(()=>{const t=c.path.substring(0,c.path.lastIndexOf("/")+1);return t?D.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):D})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:e("filesView.editor.htmlPreviewTitle")},sa)}):c&&Xs&&O==="view"?yn(c,Ke?D:ne,wn):s.jsxs("div",{className:q("relative h-full",Dt&&"overflow-hidden"),ref:ds,children:[s.jsx("div",{className:q("h-full",Dt&&"invisible"),children:s.jsx(On,{value:ne,onChange:xe,readOnly:!Ue,vimMode:Br==="vim",extensions:cn,className:"h-full",blockWidgets:ia,onViewReady:t=>{We.current=t,Is(i=>i+1),window.requestAnimationFrame(()=>{Mt(t)})},onViewDestroy:()=>{We.current&&(We.current=null),Is(t=>t+1)},enableSearch:!0,searchOpen:ee,onSearchOpenChange:le,highlightLines:U?{start:Math.min(U.start,U.end),end:Math.max(U.start,U.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,i,l)=>{if(!(l instanceof MouseEvent)||l.button!==0)return!1;l.preventDefault();const u=t.state.doc.lineAt(i.from).number;if(U&&!l.shiftKey&&Math.min(U.start,U.end)===u&&Math.max(U.start,U.end)===u)return _e(null),Yt(),Tt.current=!1,ut.current=null,Vt(!1),!0;if(f&&U&&!l.shiftKey){const p=Math.min(U.start,U.end,u),m=Math.max(U.start,U.end,u);return _e({start:p,end:m}),Tt.current=!1,ut.current=null,Vt(!1),!0}if(Tt.current=!0,ut.current=u,Vt(!0),U&&l.shiftKey){const p=Math.min(U.start,u),m=Math.max(U.end,u);_e({start:p,end:m})}else _e({start:u,end:u});return!0},mouseover:(t,i,l)=>{if(!(l instanceof MouseEvent)||l.buttons!==1||!Tt.current||ut.current===null)return!1;const u=t.state.doc.lineAt(i.from).number,p=Math.min(ut.current,u),m=Math.max(ut.current,u);return _e({start:p,end:m}),Vt(!0),!1},mouseup:()=>(Tt.current=!1,ut.current=null,Vt(!1),!1)}}})}),Dt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(b,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]}):s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:e("filesView.editor.pickFileFromTree")})})})]}),aa=!!(o&&yr[o]),Fn=o?is[o]:null,Nn=s.jsxs("section",{className:q("flex min-h-0 flex-col overflow-hidden",f?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[s.jsx("div",{className:q("flex flex-col gap-2 py-2",f?"px-3":"px-2"),children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx(b,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),s.jsx(ss,{ref:M,value:E,onChange:t=>V(t.target.value),placeholder:e("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),E.trim().length>0&&s.jsx("button",{type:"button","aria-label":e("filesView.tree.search.clearAria"),className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{V(""),M.current?.focus()},children:s.jsx(b,{name:"close",className:"size-4"})})]}),s.jsxs(zt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>_s("createFile",{path:T,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFileTitle"),"aria-label":e("filesView.tree.actions.newFileTitle"),children:s.jsx(b,{name:"file-add",className:"size-4"})})})}),s.jsx(Lt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFileTitle")})]}),s.jsxs(zt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>_s("createFolder",{path:T,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFolderTitle"),"aria-label":e("filesView.tree.actions.newFolderTitle"),children:s.jsx(b,{name:"folder-add",className:"size-4"})})})}),s.jsx(Lt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFolderTitle")})]}),s.jsxs(zt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{ws()},className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.refreshTitle"),"aria-label":e("filesView.tree.actions.refreshTitle"),children:s.jsx(b,{name:"refresh",className:"size-4"})})})}),s.jsx(Lt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.refreshTitle")})]})]})}),s.jsx(lr,{outerClassName:"flex-1 min-h-0",className:q("py-2",f?"px-3":"px-2"),children:s.jsx("ul",{className:"flex flex-col",children:di?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(b,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.tree.search.searching")]}):Fr.length>0?Fr.map(t=>{const i=c?.path===t.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>{Re(t)},className:q("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[li(t.path,t.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):Fn?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"text-[var(--status-error)]",children:Fn}),s.jsxs(z,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ws()},children:[s.jsx(b,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):aa?rn(o,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:e("filesView.state.loading")})})})]}),oa=a==="full"&&_&&c&&s.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[s.jsx("div",{className:"absolute right-4 top-4 z-30",children:jn({exitFullscreenOnly:!0})}),s.jsx(lr,{ref:bn.setScroller,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",Ke&&"[overflow-anchor:none]"),children:Le||hn?I?s.jsx("div",{className:"p-4"}):s.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(b,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):st?s.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:st}):Fe?s.jsx("div",{className:"flex h-full items-center justify-center p-4",children:s.jsx("img",{src:gn,alt:c.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):Be?vn(c):nt?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),r.downloadFile?s.jsxs(z,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=r.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),Q.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(b,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):Ze&&$e()==="preview"?s.jsxs("div",{className:"relative h-full min-h-0",children:[s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:ps,ref:t=>{gs.current=t,Ws.current=t},children:[c?s.jsx($n,{containerRef:gs,filePath:c.path,fileContent:D}):null,D.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(D.length/1024)})}),s.jsx(cr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(Ln,{content:D,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),s.jsx(Un,{containerRef:Ws,open:Vr,onOpenChange:fs,focusNonce:Er,className:"right-4 top-16"})]}):Xs&&O==="view"?yn(c,Ke?D:ne,bn):s.jsxs("div",{className:q("relative h-full",Dt&&"overflow-hidden"),children:[s.jsx("div",{className:q("h-full",Dt&&"invisible"),children:s.jsx(On,{value:ne,onChange:xe,readOnly:!Ue,vimMode:Br==="vim",extensions:cn,className:"h-full",onViewReady:t=>{We.current=t,window.requestAnimationFrame(()=>{Mt(t)})},onViewDestroy:()=>{We.current&&(We.current=null)}})}),Dt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(b,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]})})]})});return s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[s.jsx(Ko,{activeDialog:wt,dialogData:bt,dialogInputValue:ct,onDialogInputChange:kr,isDialogSubmitting:Fi,onDialogSubmit:Oi,onClose:na,inputRef:gi}),oa,f?$?rr:Nn:a==="editor-only"?s.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:rr})}):s.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[h>=700&&s.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:Nn}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:rr})]})]})};function Ho(a){return a+1}export{mu as FilesView};
|