@jetcrab/pi-desk 1.1.18-dev → 1.1.21
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/docs/plugins.md +82 -2
- package/next.config.ts +1 -0
- package/package.json +4 -3
- package/src/app/page.tsx +6 -1
- package/src/app/project-preview/page.tsx +10 -0
- package/src/client/l1_entry/pages/l1-home-page.tsx +30 -0
- package/src/client/l1_entry/pages/l1-project-preview-page.tsx +33 -0
- package/src/client/l1_entry/providers/l1-app-providers.tsx +18 -15
- package/src/client/l1_entry/providers/l1-app-runtime-provider.tsx +2 -2
- package/src/client/l2_biz/auth/l2-login-biz.ts +3 -0
- package/src/client/l2_biz/auth/l2-login.tsx +2 -3
- package/src/client/l2_biz/plugin-host/l2-plugin-capability-details.tsx +6 -1
- package/src/client/l2_biz/plugin-host/l2-plugin-contribution-host.tsx +71 -10
- package/src/client/l2_biz/plugin-host/l2-plugin-management-controls.tsx +9 -0
- package/src/client/l2_biz/plugin-host/l2-plugin-session-header-layout.ts +18 -0
- package/src/client/l2_biz/plugin-host/l2-plugin-session-header.tsx +247 -0
- package/src/client/l2_biz/plugin-host/l2-plugin-widgets.tsx +50 -0
- package/src/client/l2_biz/plugin-host/views/l2-plugin-session-header-action.tsx +112 -0
- package/src/client/l2_biz/project-preview/hooks/l2-use-project-picker.ts +76 -0
- package/src/client/l2_biz/project-preview/hooks/l2-use-project-preview.ts +214 -0
- package/src/client/l2_biz/project-preview/l2-project-preview-biz.ts +49 -4
- package/src/client/l2_biz/project-preview/l2-project-preview-dialog.tsx +42 -450
- package/src/client/l2_biz/project-preview/l2-project-preview-page.tsx +61 -0
- package/src/client/l2_biz/project-preview/l2-project-preview.tsx +342 -0
- package/src/client/l2_biz/project-preview/runtime/l2-project-history-runtime.ts +9 -3
- package/src/client/l2_biz/project-preview/views/l2-project-picker.tsx +168 -0
- package/src/client/l2_biz/settings/hooks/l2-use-model-settings.ts +34 -31
- package/src/client/l2_biz/settings/views/l2-model-replacement-preview.tsx +7 -1
- package/src/client/l2_biz/workbench/file-workspace/l2-file-workspace-runtime.ts +1 -1
- package/src/client/l2_biz/workbench/file-workspace/l2-project-preview-biz.ts +4 -3
- package/src/client/l2_biz/workbench/hooks/l2-workbench-chat-reload.ts +42 -0
- package/src/client/l2_biz/workbench/hooks/l2-workbench-chat-viewport.ts +28 -21
- package/src/client/l2_biz/workbench/l2-work-session-columns.module.css +32 -0
- package/src/client/l2_biz/workbench/l2-work-session-columns.tsx +55 -16
- package/src/client/l2_biz/workbench/l2-work-session-sidebar.tsx +38 -9
- package/src/client/l2_biz/workbench/l2-workbench-chat-composer.tsx +12 -1
- package/src/client/l2_biz/workbench/l2-workbench-chat.ts +45 -0
- package/src/client/l2_biz/workbench/l2-workbench-initialization-notice.tsx +8 -3
- package/src/client/l2_biz/workbench/l2-workbench-plugin-slots.ts +13 -0
- package/src/client/l2_biz/workbench/l2-workbench.tsx +19 -2
- package/src/client/l3_modules/conversation/l3-conversation-markdown.tsx +10 -1
- package/src/client/l3_modules/conversation/l3-conversation-viewport.tsx +12 -6
- package/src/client/l3_modules/project-files/l3-markdown-preview.module.css +1 -1
- package/src/client/l3_modules/project-files/l3-markdown-preview.tsx +10 -1
- package/src/client/l3_modules/project-files/l3-project-document-git.ts +4 -3
- package/src/client/l3_modules/project-files/l3-project-document-view.tsx +6 -1
- package/src/client/l3_modules/project-files/l3-project-file-browser.tsx +171 -229
- package/src/client/l3_modules/project-files/l3-project-file-runtime.ts +133 -70
- package/src/client/l3_modules/project-files/l3-project-reader.ts +26 -37
- package/src/client/l3_modules/project-files/views/l3-project-search-controls.tsx +201 -0
- package/src/client/l3_modules/project-files/views/l3-project-search-results.tsx +333 -0
- package/src/client/l4_foundation/lib/l4-client-id.tsx +11 -0
- package/src/client/l4_foundation/plugin-host/l4-plugin-host-runtime.ts +316 -35
- package/src/client/l4_foundation/ui/code/l4-code-preview.tsx +47 -3
- package/src/client/l4_foundation/ui/markdown/l4-markdown-remark.ts +89 -0
- package/src/client/l4_foundation/ui/markdown/l4-markdown.module.css +58 -0
- package/src/client/l4_foundation/ui/markdown/l4-markdown.tsx +108 -0
- package/src/common/l2_biz/auth/l2-auth-return-to.ts +41 -0
- package/src/common/l2_biz/model-settings/l2-model-settings-contract.ts +5 -1
- package/src/common/l2_biz/plugin/l2-plugin-management-messages.ts +4 -0
- package/src/common/l2_biz/project-preview/l2-project-history-messages.ts +28 -0
- package/src/common/l2_biz/project-preview/l2-project-preview-navigation.ts +5 -0
- package/src/common/l2_biz/settings/l2-settings-messages.ts +4 -3
- package/src/common/l2_biz/work-session/l2-work-session-file-contract.ts +4 -3
- package/src/common/l2_biz/workbench/l2-workbench-locale-messages.ts +8 -0
- package/src/common/l3_modules/project-files/l3-project-files-contract.ts +2 -3
- package/src/common/l3_modules/project-files/l3-project-files-locale-messages.ts +56 -10
- package/src/common/l4_foundation/file/l4-project-file-contract.ts +51 -1
- package/src/common/l4_foundation/locale/l4-host-error-messages.ts +11 -0
- package/src/common/l4_foundation/locale/l4-locale-messages.ts +16 -0
- package/src/instrumentation.ts +0 -2
- package/src/server/l1_entry/api/l1-project-read-routes.ts +6 -4
- package/src/server/l1_entry/api/l1-project-route.ts +9 -8
- package/src/server/l1_entry/api/l1-work-session-file-error.ts +23 -0
- package/src/server/l1_entry/node/l1-server.ts +8 -4
- package/src/server/l2_biz/plugin-management/l2-plugin-management.ts +0 -3
- package/src/server/l2_biz/work-session/l2-work-session-chat-runtime.ts +30 -58
- package/src/server/l2_biz/work-session/l2-work-session-manage.ts +0 -4
- package/src/server/l4_foundation/file/l4-project-file-index.ts +276 -0
- package/src/server/l4_foundation/file/l4-project-search.ts +399 -0
- package/src/server/l4_foundation/file/l4-ripgrep-search.ts +192 -0
- package/src/server/l4_foundation/file/l4-work-session-project-file.ts +8 -332
- package/src/server/l4_foundation/model-settings/l4-model-settings-store.ts +29 -20
- package/src/server/l4_foundation/model-settings/l4-model-settings-types.ts +1 -1
- package/src/server/l4_foundation/pi/l4-pi-chat-worker.ts +22 -5
- package/src/server/l4_foundation/pi/l4-pi-package-maintenance.ts +0 -6
- package/src/server/l4_foundation/pi/l4-pi-plugin-capability-probe.ts +1 -3
- package/src/server/l4_foundation/pi/l4-pi-plugin-owner-runtime.ts +133 -13
- package/src/server/l4_foundation/pi/l4-pi-plugin-probe.ts +1 -3
- package/src/server/l4_foundation/pi/l4-pi-runner-process.ts +2 -2
- package/src/server/l4_foundation/pi/l4-pi-session-initialization.ts +9 -0
- package/src/server/l4_foundation/process/l4-process-tree.js +23 -4
- package/temp/build/pi-desk/release/.next/BUILD_ID +1 -1
- package/temp/build/pi-desk/release/.next/app-path-routes-manifest.json +3 -2
- package/temp/build/pi-desk/release/.next/build-manifest.json +3 -3
- package/temp/build/pi-desk/release/.next/prerender-manifest.json +3 -3
- package/temp/build/pi-desk/release/.next/react-loadable-manifest.json +1 -2
- package/temp/build/pi-desk/release/.next/required-server-files.js +4 -3
- package/temp/build/pi-desk/release/.next/required-server-files.json +4 -3
- package/temp/build/pi-desk/release/.next/routes-manifest.json +6 -0
- package/temp/build/pi-desk/release/.next/server/app/_global-error/page.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/_global-error.html +1 -1
- package/temp/build/pi-desk/release/.next/server/app/_global-error.rsc +3 -3
- package/temp/build/pi-desk/release/.next/server/app/_global-error.segments/_full.segment.rsc +3 -3
- package/temp/build/pi-desk/release/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +3 -3
- package/temp/build/pi-desk/release/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/temp/build/pi-desk/release/.next/server/app/_not-found/page.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/auth/login/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/auth/logout/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/auth-settings/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/auth-settings/replace/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/capability-modes/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/capability-modes/replace/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/chat/context/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/chat/images/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/chat/messages/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/health/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/mcp-check/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/mcp-settings/del/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/mcp-settings/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/mcp-settings/replace/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/model-catalog/list/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/model-settings/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/model-settings/preview/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/model-settings/replace/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/pi/directories/list/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/pi/directory-entries/list/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/pi/directory-ignores/list/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/pi/directory-ignores/replace/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/pi/models/list/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/pi/session-user-messages/list/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/pi/sessions/list/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugin-catalog/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugin-catalog/search/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugin-catalog/settings-get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugin-catalog/settings-replace/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugins/add/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugins/apply/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugins/batch/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugins/browser-resources/[resourceGroup]/[...resourcePath]/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugins/del/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugins/enabled-set/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugins/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugins/host-runtime/[runtimeVersion]/[...resourcePath]/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugins/list/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugins/reload/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/plugins/update/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/project-files/get/route.js +2 -1
- package/temp/build/pi-desk/release/.next/server/app/api/project-files/list/route.js +2 -1
- package/temp/build/pi-desk/release/.next/server/app/api/project-files/reveal/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/project-files/search/route.js +2 -1
- package/temp/build/pi-desk/release/.next/server/app/api/project-git/get/route.js +2 -1
- package/temp/build/pi-desk/release/.next/server/app/api/project-git-branches/list/route.js +2 -1
- package/temp/build/pi-desk/release/.next/server/app/api/project-git-changes/list/route.js +2 -1
- package/temp/build/pi-desk/release/.next/server/app/api/project-git-diff/get/route.js +2 -1
- package/temp/build/pi-desk/release/.next/server/app/api/project-git-heads/get/route.js +2 -1
- package/temp/build/pi-desk/release/.next/server/app/api/project-git-log/list/route.js +2 -1
- package/temp/build/pi-desk/release/.next/server/app/api/project-model-default/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/project-model-default/replace/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/skill-files/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/skill-files/list/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/skill-files/replace/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/skills/list/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/task-center/images/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/task-center/messages/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/work-session-git-branch/add/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/work-session-git-branch/replace/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/work-session-tree/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/work-session-tree-entry/get/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/add/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/branch/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/del/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/rename/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/replace/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/api/work-sessions/sort/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/favicon.ico/route.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/login/page.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/page.js +72 -72
- package/temp/build/pi-desk/release/.next/server/app/page_client-reference-manifest.js +1 -1
- package/temp/build/pi-desk/release/.next/server/app/project-preview/page.js +1 -0
- package/temp/build/pi-desk/release/.next/server/app/project-preview/page_client-reference-manifest.js +1 -0
- package/temp/build/pi-desk/release/.next/server/app-paths-manifest.json +3 -2
- package/temp/build/pi-desk/release/.next/server/chunks/10912.js +2 -2
- package/temp/build/pi-desk/release/.next/server/chunks/20460.js +15 -0
- package/temp/build/pi-desk/release/.next/server/chunks/23054.js +1 -1
- package/temp/build/pi-desk/release/.next/server/chunks/25406.js +10 -10
- package/temp/build/pi-desk/release/.next/server/chunks/35985.js +3 -17
- package/temp/build/pi-desk/release/.next/server/chunks/36361.js +1 -1
- package/temp/build/pi-desk/release/.next/server/chunks/48180.js +1 -1
- package/temp/build/pi-desk/release/.next/server/chunks/50520.js +2 -4
- package/temp/build/pi-desk/release/.next/server/chunks/56830.js +235 -0
- package/temp/build/pi-desk/release/.next/server/chunks/6917.js +1 -1
- package/temp/build/pi-desk/release/.next/server/chunks/70780.js +1 -0
- package/temp/build/pi-desk/release/.next/server/chunks/74528.js +1 -1
- package/temp/build/pi-desk/release/.next/server/chunks/78262.js +1 -1
- package/temp/build/pi-desk/release/.next/server/chunks/79686.js +62 -0
- package/temp/build/pi-desk/release/.next/server/chunks/80780.js +1 -0
- package/temp/build/pi-desk/release/.next/server/chunks/81363.js +1 -1
- package/temp/build/pi-desk/release/.next/server/chunks/82499.js +4 -4
- package/temp/build/pi-desk/release/.next/server/chunks/92386.js +8 -8
- package/temp/build/pi-desk/release/.next/server/instrumentation.js +1 -1
- package/temp/build/pi-desk/release/.next/server/middleware-build-manifest.js +1 -1
- package/temp/build/pi-desk/release/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/temp/build/pi-desk/release/.next/server/pages/500.html +1 -1
- package/temp/build/pi-desk/release/.next/server/server-reference-manifest.json +1 -1
- package/temp/build/pi-desk/release/.next/static/8Yd33M0zPi4tbRn4xCaRY/_buildManifest.js +1 -0
- package/temp/build/pi-desk/release/.next/static/chunks/11937-1d0a9822f2c7995b.js +1 -0
- package/temp/build/pi-desk/release/.next/static/chunks/14825-5579aed34a631ad7.js +62 -0
- package/temp/build/pi-desk/release/.next/static/chunks/15302-9c807afc6c60de0c.js +1 -0
- package/temp/build/pi-desk/release/.next/static/chunks/19991.8aa2e4b6df15fad6.js +1 -0
- package/temp/build/pi-desk/release/.next/static/chunks/22092-6d1bfbefa825ec03.js +1 -0
- package/temp/build/pi-desk/release/.next/static/chunks/37313-d5970e2d0c270d22.js +238 -0
- package/temp/build/pi-desk/release/.next/static/chunks/{49516-cc4dcd84d64ab4fe.js → 51474-8dc714cb76b2e60a.js} +2 -2
- package/temp/build/pi-desk/release/.next/static/chunks/57235-03ba1044f22b6c84.js +1 -0
- package/temp/build/pi-desk/release/.next/static/chunks/79267-7d21d7cdbd7cfca1.js +1 -0
- package/temp/build/pi-desk/release/.next/static/chunks/82371-f7ba4a07a5dbcf34.js +1 -0
- package/temp/build/pi-desk/release/.next/static/chunks/9038-03144ed96d613f75.js +15 -0
- package/temp/build/pi-desk/release/.next/static/chunks/app/{error-0296a3b20cd1bf00.js → error-216b14b5da089ed3.js} +1 -1
- package/temp/build/pi-desk/release/.next/static/chunks/app/layout-20718f1503910291.js +1 -0
- package/temp/build/pi-desk/release/.next/static/chunks/app/login/page-0d3d4827802108e5.js +1 -0
- package/temp/build/pi-desk/release/.next/static/chunks/app/{not-found-2aab8b33ebbf3257.js → not-found-720cdf6a606b821a.js} +1 -1
- package/temp/build/pi-desk/release/.next/static/chunks/app/page-6ebc1c877f6025dd.js +158 -0
- package/temp/build/pi-desk/release/.next/static/chunks/app/project-preview/page-d70ee4e9409b970a.js +1 -0
- package/temp/build/pi-desk/release/.next/static/chunks/webpack-b60891a214e0925d.js +1 -0
- package/temp/build/pi-desk/release/.next/static/css/1e780a4936aa6ba3.css +1 -0
- package/temp/build/pi-desk/release/.next/static/css/6dbae2922f88ca31.css +1 -0
- package/temp/build/pi-desk/release/.next/static/css/f646ca6c07245c4c.css +1 -0
- package/temp/build/pi-desk/release/.next/trace-build +1 -1
- package/temp/build/pi-desk/release/.next/server/chunks/33658.js +0 -296
- package/temp/build/pi-desk/release/.next/server/chunks/8584.js +0 -2
- package/temp/build/pi-desk/release/.next/static/chunks/31087-ba426d09d6f68bfd.js +0 -1
- package/temp/build/pi-desk/release/.next/static/chunks/3814-35cfab0ce3aa7c41.js +0 -1
- package/temp/build/pi-desk/release/.next/static/chunks/39654-b5fedd762ea0312e.js +0 -238
- package/temp/build/pi-desk/release/.next/static/chunks/70669.07f3670bfb7d6dd2.js +0 -1
- package/temp/build/pi-desk/release/.next/static/chunks/74220-795a2e7185bd66cb.js +0 -1
- package/temp/build/pi-desk/release/.next/static/chunks/75130-d2ca74894aff8085.js +0 -13
- package/temp/build/pi-desk/release/.next/static/chunks/78923-17a9c337b29dcecd.js +0 -1
- package/temp/build/pi-desk/release/.next/static/chunks/81881-f11dbe7dc0d04ed9.js +0 -1
- package/temp/build/pi-desk/release/.next/static/chunks/96995-8f8313ea2ac3abd7.js +0 -62
- package/temp/build/pi-desk/release/.next/static/chunks/app/layout-c0e1c5cef8620cf8.js +0 -3
- package/temp/build/pi-desk/release/.next/static/chunks/app/login/page-84892b06243891f0.js +0 -1
- package/temp/build/pi-desk/release/.next/static/chunks/app/page-a984139e99586041.js +0 -158
- package/temp/build/pi-desk/release/.next/static/chunks/webpack-40a782fc8a3535b9.js +0 -1
- package/temp/build/pi-desk/release/.next/static/css/6427d02b6edf406f.css +0 -1
- package/temp/build/pi-desk/release/.next/static/css/79e06f05df9edff0.css +0 -1
- package/temp/build/pi-desk/release/.next/static/n2LrXQgq8UkbH_AzhR3fw/_buildManifest.js +0 -1
- /package/temp/build/pi-desk/release/.next/static/{n2LrXQgq8UkbH_AzhR3fw → 8Yd33M0zPi4tbRn4xCaRY}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
exports.id=20460,exports.ids=[20460],exports.modules={1222:(a,b,c)=>{"use strict";c.d(b,{Ms:()=>t,N1:()=>s,Sb:()=>v,tQ:()=>u});var d=c(87883),e=c(51949),f=c(98722);let g="pi-super:project-preview:global",h="pi-super:project-preview:projects",i=d.ai().min(5).max(95),j=d.Ik({maximized:d.zM(),directoryOpen:d.zM(),gitOpen:d.zM(),gitMaximized:d.zM(),treeLayout:d.k5(["directory","repository"]),directorySize:i,gitSize:i,logSize:i,changeSize:i}),k={maximized:!1,directoryOpen:!0,gitOpen:!1,gitMaximized:!1,treeLayout:"directory",directorySize:22,gitSize:45,logSize:62,changeSize:70},l=d.Ik({repositoryRoot:d.Yj().nullable(),mode:d.k5(["history","compare"]),tip:d.Yj(),base:d.Yj(),target:d.Yj(),strategy:d.k5(["merge-base","direct"]),query:d.Yj().max(200),author:d.Yj().max(200),selectedCommit:f.aD.nullable(),selectedChangePath:e._g.nullable(),logScroll:d.ai().nonnegative(),changesScroll:d.ai().nonnegative()}),m=d.Ie(a=>"object"==typeof a&&null!==a&&Array.isArray(a.cursorState)&&"object"==typeof a.viewState),n=d.Ik({page:d.k5(["files","code","git"]),historyPane:d.k5(["log","files"]),tabs:d.YO(e._g).max(20),activePath:e._g.nullable(),editorStates:d.g1(e._g,m),fileViewModes:d.g1(e._g,d.k5(["source","preview"])),expandedPaths:d.YO(d.Yj()).max(500),treeScrollTop:d.ai().nonnegative(),searchQuery:d.Yj().max(200),changesOnly:d.zM(),expandedRepositories:d.YO(d.Yj()).max(100),history:l,activeDiff:d.Ik({repositoryRoot:d.Yj(),path:e._g,comparison:f.xv.optional()}).nullable()}),o=d.Ik({cwd:d.Yj(),lastOpenedAt:d.ai(),state:n});function p(a){let b=a.replaceAll("\\","/").replace(/\/+$/,"");return/^[a-z]:\//i.test(b)||b.startsWith("//")?b.toLowerCase():b}function q(){try{let a=JSON.parse(window.localStorage.getItem(h)??"[]");if(!Array.isArray(a))return[];let b=Date.now();return a.flatMap(a=>{let c=o.safeParse(a);return c.success&&b-c.data.lastOpenedAt<2592e6?[c.data]:[]})}catch{return[]}}function r(a){try{window.localStorage.setItem(h,JSON.stringify(a.sort((a,b)=>b.lastOpenedAt-a.lastOpenedAt).slice(0,50)))}catch(a){console.warn("[Pi Desk][ProjectPreview] 保存项目浏览状态失败",a)}}function s(){try{let a=JSON.parse(window.localStorage.getItem(g)??"null");return{...k,...j.partial().parse(a)}}catch{return{...k}}}function t(a){try{window.localStorage.setItem(g,JSON.stringify(a))}catch(a){console.warn("[Pi Desk][ProjectPreview] 保存全局布局失败",a)}}function u(a){let b=p(a),c=q(),d=c.find(a=>a.cwd===b);return d&&(d.lastOpenedAt=Date.now()),r(c),d?.state??null}function v(a,b){let c=n.safeParse(b);if(!c.success)return;let d=p(a),e=q(),f=e.find(a=>a.cwd===d);f?f.state=c.data:e.push({cwd:d,lastOpenedAt:Date.now(),state:c.data}),r(e)}},4935:a=>{a.exports={markdown:"l4-markdown_markdown__oIf6d",status:"l4-markdown_status__EVcKw",alert:"l4-markdown_alert__Aooao",alertTitle:"l4-markdown_alertTitle__GIoFs",alertBody:"l4-markdown_alertBody__BtDVT"}},5701:(a,b,c)=>{"use strict";c.d(b,{V:()=>l});var d=c(52834);c(49147);var e=c(58029),f=c(82260),g=c(13943),h=c(15620),i=c(39395),j=c(54239);function k({className:a,orientation:b="vertical",...c}){return(0,d.jsx)(i.V,{"data-slot":"scroll-area-scrollbar","data-orientation":b,orientation:b,className:(0,h.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",a),...c,children:(0,d.jsx)(j.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function l({className:a,viewportClassName:b,viewportRef:c,onViewportScroll:i,children:j,...m}){return(0,d.jsxs)(e.V,{"data-slot":"l4-scroll-area",className:(0,h.cn)("relative min-h-0 overflow-hidden",a),...m,children:[(0,d.jsx)(f.B,{ref:c,"data-slot":"l4-scroll-area-viewport",className:(0,h.cn)("size-full rounded-[inherit] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",b),onScroll:i,children:j}),(0,d.jsx)(k,{className:"data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent"}),(0,d.jsx)(g.I,{})]})}},6995:a=>{a.exports={document:"l3-markdown-preview_document__tuJfC"}},9860:(a,b,c)=>{"use strict";c.d(b,{G7:()=>k,L$:()=>n,h_:()=>o,oI:()=>l,uB:()=>j,xL:()=>m});var d=c(52834);c(49147);var e=c(86536),f=c(15620);c(16664);var g=c(89101),h=c(41568),i=c(97832);function j({className:a,...b}){return(0,d.jsx)(e.uB,{"data-slot":"command",className:(0,f.cn)("flex size-full flex-col overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground",a),...b})}function k({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"command-input-wrapper",className:"p-1 pb-0",children:(0,d.jsxs)(g.MG,{className:"has-[[data-slot=command-input]:focus-visible]:outline-2 has-[[data-slot=command-input]:focus-visible]:outline-solid has-[[data-slot=command-input]:focus-visible]:-outline-offset-2 has-[[data-slot=command-input]:focus-visible]:outline-ring",children:[(0,d.jsx)(e.uB.Input,{"data-slot":"command-input",className:(0,f.cn)("min-h-8 w-full bg-transparent px-2.5 text-sm leading-5 outline-none disabled:cursor-not-allowed disabled:opacity-50",a),...b}),(0,d.jsx)(g.Sq,{children:(0,d.jsx)(h.A,{className:"size-4 shrink-0 opacity-50"})})]})})}function l({className:a,...b}){return(0,d.jsx)(e.uB.List,{"data-slot":"command-list",className:(0,f.cn)("pi-desk-chat-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",a),...b})}function m({className:a,...b}){return(0,d.jsx)(e.uB.Empty,{"data-slot":"command-empty",className:(0,f.cn)("py-6 text-center text-sm",a),...b})}function n({className:a,...b}){return(0,d.jsx)(e.uB.Group,{"data-slot":"command-group",className:(0,f.cn)("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",a),...b})}function o({className:a,children:b,...c}){return(0,d.jsxs)(e.uB.Item,{"data-slot":"command-item",className:(0,f.cn)("group/command-item relative flex min-h-8 cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-sm leading-5 outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[selected=true]:*:[svg]:text-foreground",a),...c,children:[b,(0,d.jsx)(i.A,{className:"ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100"})]})}},11071:(a,b,c)=>{"use strict";c.d(b,{p:()=>g});var d=c(52834);c(49147);var e=c(17372),f=c(15620);function g({className:a,type:b,...c}){return(0,d.jsx)(e.p,{type:b,"data-slot":"input",className:(0,f.cn)("min-h-8 w-full min-w-0 rounded-lg border border-input bg-card px-2.5 py-1 text-sm leading-5 transition-colors duration-150 outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-50 aria-invalid:border-destructive aria-invalid:outline-destructive",a),...c})}},13221:(a,b,c)=>{"use strict";c.d(b,{T:()=>f});var d=c(52834);c(49147);var e=c(15620);function f({className:a,...b}){return(0,d.jsx)("textarea",{"data-slot":"textarea",className:(0,e.cn)("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-card px-2.5 py-2 text-sm leading-5 transition-colors duration-150 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-50 aria-invalid:border-destructive aria-invalid:outline-destructive",a),...b})}},13749:(a,b,c)=>{"use strict";c.d(b,{$:()=>g,P:()=>f});var d=c(17983),e=c(95186);async function f(a,b,c,f){await (0,e.QL)(a,d.Ot,{...b,path:c,targetType:f})}function g(a,b){let c=/^[a-zA-Z]:[\\/]/.test(a)||a.startsWith("\\\\"),d=c?"\\":"/",e=(c?a.replaceAll("/","\\"):a).replace(/[\\/]+$/,"");return b?`${e}${d}${b.replaceAll("/",d)}`:/^[a-z]:$/i.test(e)?`${e}${d}`:e||d}},16664:(a,b,c)=>{"use strict";c.d(b,{Hl:()=>x,YM:()=>A,YV:()=>t,_Y:()=>y,hA:()=>w,uX:()=>B,vu:()=>z});var d=c(52834);c(49147);var e=c(52878),f=c(40282),g=c(40898),h=c(24505),i=c(56500),j=c(61576),k=c(82488),l=c(58029),m=c(82260),n=c(39395),o=c(54239),p=c(13943),q=c(32772),r=c(57850),s=c(15620);function t({onOpenChange:a,...b}){return(0,d.jsx)(e.D,{"data-slot":"app-dialog",...b,onOpenChange:(c,d)=>{c||!1===b.modal||"outside-press"!==d.reason||d.event.target instanceof Element&&"app-dialog-backdrop"===d.event.target.getAttribute("data-slot")?a?.(c,d):d.cancel()}})}function u({...a}){return(0,d.jsx)(f.Z,{"data-slot":"app-dialog-portal",...a})}function v({className:a,...b}){return(0,d.jsx)(g.X,{"data-slot":"app-dialog-backdrop",className:(0,s.cn)("fixed inset-0 z-[100] bg-black/35 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",a),...b})}function w({className:a,children:b,showCloseButton:c=!0,finalFocus:e=!1,backdropClassName:f,...g}){let{t:j}=(0,r.Bd)("common");return(0,d.jsxs)(u,{children:[(0,d.jsx)(v,{className:f,forceRender:!!f}),(0,d.jsxs)(h.h,{"data-slot":"app-dialog-content",finalFocus:e,className:(0,s.cn)("fixed top-1/2 left-1/2 z-[110] flex max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-[27.5rem] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border bg-popover text-sm text-popover-foreground shadow-lg outline-none duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",a),...g,children:[b,c?(0,d.jsxs)(i.H,{"data-slot":"app-dialog-close-button","aria-label":j("closeDialog"),title:j("closeDialog"),className:"absolute top-2 right-2 flex size-8 cursor-pointer items-center justify-center rounded-lg text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground active:bg-foreground/14 focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",children:[(0,d.jsx)(q.A,{className:"size-4"}),(0,d.jsx)("span",{className:"sr-only",children:j("closeDialog")})]}):null]})]})}function x({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"app-dialog-header",className:(0,s.cn)("flex shrink-0 flex-col gap-1.5",a),...b})}function y({className:a,children:b,...c}){return(0,d.jsxs)(l.V,{"data-slot":"app-dialog-body",className:(0,s.cn)("relative min-h-0 flex-1 overflow-hidden",a),...c,children:[(0,d.jsx)(m.B,{"data-slot":"app-dialog-body-viewport",className:"h-full max-h-[inherit] w-full overscroll-contain rounded-[inherit] outline-none focus-visible:ring-2 focus-visible:ring-ring",children:b}),(0,d.jsx)(n.V,{"data-slot":"app-dialog-body-scrollbar",orientation:"vertical",className:"flex h-full w-2.5 touch-none border-l border-l-transparent p-px select-none",children:(0,d.jsx)(o.l,{"data-slot":"app-dialog-body-thumb",className:"relative flex-1 rounded-full bg-muted-foreground/45 hover:bg-muted-foreground/70"})}),(0,d.jsx)(p.I,{})]})}function z({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"app-dialog-footer",className:(0,s.cn)("flex shrink-0 flex-wrap justify-end gap-2 border-t bg-popover px-4 py-3",a),...b})}function A({className:a,...b}){return(0,d.jsx)(j.L,{"data-slot":"app-dialog-title",className:(0,s.cn)("text-lg leading-[1.4] font-semibold",a),...b})}function B({className:a,...b}){return(0,d.jsx)(k.r,{"data-slot":"app-dialog-description",className:(0,s.cn)("text-sm leading-5 text-muted-foreground",a),...b})}},17983:(a,b,c)=>{"use strict";c.d(b,{OC:()=>u,Ot:()=>l,Xe:()=>m,ZI:()=>o,_X:()=>q,fg:()=>n,p0:()=>p,p3:()=>s,ry:()=>r,ys:()=>t});var d=c(87883),e=c(51949),f=c(18997),g=c(98722);let h=d.Ik({cwd:d.Yj().trim().min(1).max(4096),workId:d.Yj().trim().min(1).optional()}).strict(),i=h.extend({repositoryRoot:e.rh}),j=h.extend({path:e.eC,imagePreviewMode:e.p$}).superRefine((a,b)=>{a.workId||e._g.safeParse(a.path).success||b.addIssue({code:"custom",path:["path"],message:"独立项目预览只接受根内相对路径"})}),k=d.k5(["file","directory"]),l={path:"/api/project-files/reveal",request:h.extend({path:d.KC([e.rh,e.eC]),targetType:k.optional()}).refine(a=>""!==a.path||"directory"===a.targetType,"文件路径不能为空").refine(a=>a.workId&&"directory"!==a.targetType||e.rh.safeParse(a.path).success,"独立项目和目录定位只接受根内相对路径"),response:d.Ik({}).strict()},m={path:"/api/project-files/list",request:h.extend({path:e.rh}).strict(),response:e.JH},n={path:"/api/project-files/search",request:h.extend(e.Nu.shape).strict(),response:e.jI},o={path:"/api/project-files/get",request:j,response:e.ih},p={path:"/api/project-git/get",request:h.extend({refresh:d.zM().optional()}).strict(),response:d.Ik({repositories:d.YO(f.u2).max(100)}).strict()},q={path:"/api/project-git-heads/get",request:h,response:d.Ik({repositories:d.YO(f.yl).max(f.y2)}).strict()},r={path:"/api/project-git-branches/list",request:i.strict(),response:g.WW},s={path:"/api/project-git-log/list",request:i.extend(g.co.shape).strict(),response:g.yw},t={path:"/api/project-git-changes/list",request:i.extend(g.ph.shape).strict(),response:g.T8},u={path:"/api/project-git-diff/get",request:i.extend({path:e._g,comparison:g.xv.optional()}).strict(),response:g.lw}},18997:(a,b,c)=>{"use strict";c.d(b,{FJ:()=>t,Ww:()=>h,cP:()=>i,gf:()=>r,u2:()=>p,y2:()=>g,yl:()=>o,zp:()=>m,zt:()=>q});var d=c(87883),e=c(53403),f=c(51949);let g=100,h=f.rh,i=d.Yj().trim().min(1).max(1024),j=d.gM("type",[d.Ik({type:d.eu("branch"),name:i}).strict(),d.Ik({type:d.eu("detached"),commit:d.Yj().regex(/^[0-9a-f]{40,64}$/)}).strict()]),k=d.k5(["added","modified","deleted","renamed","unmerged","untracked"]),l=d.Ik({path:f._g,oldPath:f._g.nullable(),indexStatus:k.nullable(),worktreeStatus:k.nullable()}).strict(),m=d.Ik({root:h,state:d.eu("ready"),head:j,changes:d.YO(l).max(5e4)}).strict(),n=d.Ik({root:h,state:d.eu("unavailable"),message:e.qf.refine(a=>("string"==typeof a?[a]:[a.default,...Object.values(a.translations)]).every(a=>a.length>0&&a.length<=2e3))}).strict(),o=d.gM("state",[m.omit({changes:!0}),n]),p=d.gM("state",[m,n]),q=d.gM("type",[d.Ik({type:d.eu("local"),name:i}).strict(),d.Ik({type:d.eu("remote"),name:i}).strict()]),r=d.Ik({head:j,recent:d.YO(i).max(5),local:d.YO(i).max(1e4),remote:d.YO(i).max(1e4)}).strict(),s=d.Ik({path:f._g,content:d.Yj()}).strict(),t=d.gM("kind",[d.Ik({kind:d.eu("text"),original:s,modified:s}).strict(),d.Ik({kind:d.eu("binary")}).strict(),d.Ik({kind:d.eu("too_large")}).strict()])},23423:(a,b,c)=>{"use strict";c.d(b,{$E:()=>f,Rv:()=>g,m4:()=>e});var d=c(87883);let e=d.Yj().trim().min(1),f=d.Yj().trim().min(1),g=d.Yj().trim().min(1)},28661:(a,b,c)=>{"use strict";function d(a){let b=atob(a.data),c=new Uint8Array(b.length);for(let a=0;a<b.length;a+=1)c[a]=b.charCodeAt(a);return new Blob([c],{type:a.mimeType})}c.d(b,{E:()=>d})},37096:(a,b,c)=>{"use strict";c.d(b,{HK:()=>g,WM:()=>i,wV:()=>h});var d=c(52834),e=c(39169),f=c(15620);function g({className:a,...b}){return(0,d.jsx)(e.YJ,{"data-slot":"resizable-panel-group",className:(0,f.cn)("flex h-full w-full aria-[orientation=vertical]:flex-col",a),...b})}function h({...a}){return(0,d.jsx)(e.Zk,{"data-slot":"resizable-panel",...a})}function i({withHandle:a,className:b,...c}){return(0,d.jsx)(e.wv,{"data-slot":"resizable-handle",className:(0,f.cn)("relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",b),...c})}},41994:(a,b,c)=>{"use strict";c.d(b,{k:()=>d});let d=c(87883).ai().int().nonnegative().max(Number.MAX_SAFE_INTEGER)},42704:(a,b,c)=>{"use strict";c.d(b,{AM:()=>l,Wv:()=>m,eO:()=>o,hl:()=>n});var d=c(52834);c(49147);var e=c(20104),f=c(10834),g=c(43088),h=c(47900),i=c(93915),j=c(62688),k=c(15620);function l({...a}){return(0,d.jsx)(e.y,{"data-slot":"popover",...a})}function m({...a}){return(0,d.jsx)(f.W,{"data-slot":"popover-trigger",...a})}function n({className:a,positionerClassName:b,align:c="center",alignOffset:e=0,side:f="bottom",sideOffset:j=4,finalFocus:l=!1,...m}){return(0,d.jsx)(g.i,{children:(0,d.jsx)(h.U,{align:c,alignOffset:e,side:f,sideOffset:j,className:(0,k.cn)("isolate z-50",b),children:(0,d.jsx)(i.i,{"data-slot":"popover-content",finalFocus:l,className:(0,k.cn)("z-50 flex w-80 max-w-[calc(100vw-2rem)] origin-(--transform-origin) flex-col gap-3 rounded-lg border border-border bg-popover p-3 text-sm text-popover-foreground shadow-md outline-hidden duration-100 motion-reduce:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",a),...m})})})}function o({className:a,...b}){return(0,d.jsx)(j.e,{"data-slot":"popover-title",className:(0,k.cn)("font-medium",a),...b})}},45427:(a,b,c)=>{"use strict";c.d(b,{n:()=>m});var d=c(52834),e=c(19480),f=c(36331),g=c(49147),h=c(38684),i=c(53437),j=c(6995),k=c.n(j);let l={cjk:e.h,code:f.a},m=(0,g.memo)(function({content:a,label:b,savedScrollTop:c,onScroll:e}){let f=(0,g.useRef)(null),j=(0,g.useRef)(c);return(0,g.useLayoutEffect)(()=>{f.current&&(f.current.scrollTop=j.current)},[]),(0,d.jsx)("div",{ref:f,"data-testid":"markdown-preview",role:"region","aria-label":b,tabIndex:0,className:"h-full min-h-0 overflow-auto overscroll-contain bg-background outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onScroll:a=>e(a.currentTarget.scrollTop),children:(0,d.jsx)(h.jH,{className:`${k().document} ${i.om}`,allowedTags:i.IV,components:i.e6,remarkPlugins:i.XC,mode:"static",parseIncompleteMarkdown:!1,isAnimating:!1,controls:!1,lineNumbers:!1,plugins:l,children:a})})})},45694:(a,b,c)=>{"use strict";c.d(b,{z:()=>e});let d=`<script>
|
|
2
|
+
window.addEventListener('keydown', function (event) {
|
|
3
|
+
if (event.defaultPrevented || event.isComposing || event.repeat) return;
|
|
4
|
+
if (event.key === 'Escape' && !event.ctrlKey && !event.altKey && !event.metaKey && !event.shiftKey) {
|
|
5
|
+
event.preventDefault();
|
|
6
|
+
window.parent.postMessage('pi-desk:file-escape', '*');
|
|
7
|
+
} else if (event.key === 'Tab' && event.ctrlKey && !event.altKey && !event.metaKey) {
|
|
8
|
+
event.preventDefault();
|
|
9
|
+
window.parent.postMessage('pi-desk:file-switch-pane', '*');
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
</script>`;function e(a){return`${a}
|
|
13
|
+
${d}`}},45741:(a,b,c)=>{"use strict";c.d(b,{F:()=>X});var d=c(52834),e=c(3935),f=c(22232),g=c(83401),h=c(97586),i=c(85278),j=c(90814),k=c(37496),l=c(26890),m=c(75152),n=c(35385),o=c(63155),p=c(41568),q=c(49147),r=c(57850),s=c(53403),t=c(4998),u=c(15620),v=c(82563),w=c(9365);let x=(0,q.createContext)({expandedPaths:new Set,togglePath:()=>{}}),y=({expanded:a,defaultExpanded:b=new Set,selectedPath:c,onSelect:e,onExpandedChange:f,className:g,children:h,...i})=>{let[j,k]=(0,q.useState)(b),l=a??j,m=(0,q.useCallback)(a=>{let b=new Set(l);b.has(a)?b.delete(a):b.add(a),k(b),f?.(b)},[l,f]),n=(0,q.useMemo)(()=>({expandedPaths:l,onSelect:e,selectedPath:c,togglePath:m}),[l,e,c,m]);return(0,d.jsx)(x.Provider,{value:n,children:(0,d.jsx)("div",{className:(0,u.cn)("rounded-lg border bg-background font-sans text-sm",g),role:"tree",...i,children:(0,d.jsx)("div",{className:"p-2",children:h})})})},z=({className:a,children:b,...c})=>(0,d.jsx)("span",{className:(0,u.cn)("shrink-0",a),...c,children:b}),A=({className:a,children:b,...c})=>(0,d.jsx)("span",{className:(0,u.cn)("truncate",a),...c,children:b}),B=(0,q.createContext)({isExpanded:!1,name:"",path:""}),C=({path:a,name:b,className:c,children:e,...f})=>{let{expandedPaths:g,togglePath:h,selectedPath:i,onSelect:j}=(0,q.useContext)(x),l=g.has(a),n=i===a,o=(0,q.useCallback)(()=>{h(a)},[h,a]),p=(0,q.useCallback)(()=>{j?.(a)},[j,a]),r=(0,q.useMemo)(()=>({isExpanded:l,name:b,path:a}),[l,b,a]);return(0,d.jsx)(B.Provider,{value:r,children:(0,d.jsx)(v.Nt,{onOpenChange:o,open:l,children:(0,d.jsxs)("div",{className:(0,u.cn)("",c),role:"treeitem","aria-expanded":l,"aria-selected":n,tabIndex:0,...f,children:[(0,d.jsxs)("div",{className:(0,u.cn)("flex min-h-9 w-full items-center gap-2 rounded-md px-2 py-1 text-left transition-colors hover:bg-foreground/8",n&&"bg-accent"),children:[(0,d.jsx)(v.R6,{render:(0,d.jsx)("button",{className:"flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md border-none bg-transparent p-0 outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":`${l?"收起":"展开"} ${b}`,type:"button"}),children:(0,d.jsx)(k.A,{className:(0,u.cn)("size-4 shrink-0 text-muted-foreground transition-transform",l&&"rotate-90")})}),(0,d.jsxs)("button",{className:"flex min-h-7 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md border-none bg-transparent p-0 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:p,type:"button",children:[(0,d.jsx)(z,{children:l?(0,d.jsx)(w.A,{className:"size-4 text-muted-foreground"}):(0,d.jsx)(m.A,{className:"size-4 text-muted-foreground"})}),(0,d.jsx)(A,{children:b})]})]}),(0,d.jsx)(v.Ke,{children:(0,d.jsx)("div",{className:"ml-4 border-l pl-2",children:e})})]})})})},D=(0,q.createContext)({name:"",path:""}),E=({path:a,name:b,icon:c,className:e,children:f,...g})=>{let{selectedPath:h,onSelect:j}=(0,q.useContext)(x),k=h===a,l=(0,q.useCallback)(()=>{j?.(a)},[j,a]),m=(0,q.useCallback)(b=>{("Enter"===b.key||" "===b.key)&&j?.(a)},[j,a]),n=(0,q.useMemo)(()=>({name:b,path:a}),[b,a]);return(0,d.jsx)(D.Provider,{value:n,children:(0,d.jsx)("div",{className:(0,u.cn)("flex min-h-9 cursor-pointer items-center gap-2 rounded-md px-2 py-1 outline-none transition-colors hover:bg-foreground/8 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",k&&"bg-accent",e),onClick:l,onKeyDown:m,role:"treeitem","aria-selected":k,tabIndex:0,...g,children:f??(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"size-6 shrink-0"}),(0,d.jsx)(z,{children:c??(0,d.jsx)(i.A,{className:"size-4 text-muted-foreground"})}),(0,d.jsx)(A,{children:b})]})})})};var F=c(5701),G=c(5319),H=c(32772),I=c(89101),J=c(59582);let K=["all","files","content"],L=[{key:"caseSensitive",label:"searchCaseSensitive",text:"Aa"},{key:"wholeWord",label:"searchWholeWord",text:"Ab"},{key:"regex",label:"searchRegex",text:".*"}];function M({input:a,inputRef:b,invalid:c,onQueryChange:e,onOptionsChange:f,onComposingChange:g,onClose:h,onOpenFirst:i,onFocusResults:j}){let{t:k}=(0,r.Bd)("projectFiles"),[l,m]=(0,q.useState)(null),n=(0,q.useRef)(!1),o=k("files"===a.scope?"searchFiles":"content"===a.scope?"searchContent":"searchAll");return(0,d.jsx)("div",{className:"shrink-0 border-b px-2.5 py-2",children:(0,d.jsxs)("div",{className:"rounded-lg border border-input bg-card p-1 focus-within:border-ring focus-within:outline-2 focus-within:-outline-offset-2 focus-within:outline-ring",children:[(0,d.jsxs)("div",{className:"flex min-h-7 items-center justify-between gap-1",children:[(0,d.jsx)("div",{className:"flex min-w-0 items-center gap-1",role:"radiogroup","aria-label":k("searchScope"),children:K.map((b,c)=>(0,d.jsx)(G.$,{type:"button",role:"radio","aria-checked":a.scope===b,tabIndex:a.scope===b?0:-1,disabled:null!==l,variant:"ghost",size:"sm","data-testid":`project-search-scope-${b}`,className:(0,u.cn)("min-h-7 px-2 text-xs",a.scope===b&&"bg-accent text-accent-foreground"),onClick:()=>f({scope:b}),onKeyDown:a=>{let b="ArrowRight"===a.key||"ArrowDown"===a.key,d="ArrowLeft"===a.key||"ArrowUp"===a.key;if(!b&&!d&&"Home"!==a.key&&"End"!==a.key)return;a.preventDefault();let e="Home"===a.key?0:"End"===a.key?2:(c+(b?1:2))%3;f({scope:K[e]}),a.currentTarget.parentElement?.querySelectorAll('[role="radio"]')[e]?.focus()},children:k("all"===b?"searchScopeAll":"files"===b?"searchScopeFiles":"searchScopeContent")},b))}),(0,d.jsxs)(J.m_,{children:[(0,d.jsx)(J.k$,{render:(0,d.jsx)(G.$,{type:"button",variant:"ghost",size:"icon-sm",className:"size-7 shrink-0","aria-label":k("closeSearch"),onClick:h}),children:(0,d.jsx)(H.A,{className:"size-4"})}),(0,d.jsx)(J.ZI,{children:k("closeSearch")})]})]}),(0,d.jsxs)(I.MG,{className:"min-h-8 rounded-none border-0 bg-transparent has-[[data-slot=input-group-control]:focus-visible]:outline-none",children:[(0,d.jsx)(I.Sq,{className:"pl-1.5 py-0",children:(0,d.jsx)(p.A,{className:"size-3.5"})}),(0,d.jsx)(I.iV,{ref:b,"data-testid":"project-file-search",className:"min-w-0 px-1.5 text-sm placeholder:text-xs",value:l??a.query,placeholder:o,"aria-label":o,"aria-invalid":c||void 0,autoComplete:"off",spellCheck:!1,onChange:a=>{n.current?m(a.target.value):e(a.target.value)},onCompositionStart:a=>{n.current=!0,m(a.currentTarget.value),g(!0)},onCompositionEnd:a=>{n.current=!1,m(null),e(a.currentTarget.value),g(!1)},onKeyDown:a=>{a.nativeEvent.isComposing||n.current||("Enter"===a.key?(a.preventDefault(),i()):"ArrowDown"===a.key&&(a.preventDefault(),j()))}}),(0,d.jsx)(I.Sq,{align:"inline-end",className:"gap-0 pr-1 py-0",children:L.map(({key:b,label:c,text:e})=>(0,d.jsxs)(J.m_,{children:[(0,d.jsx)(J.k$,{render:(0,d.jsx)(I.Ik,{size:"icon-xs",disabled:null!==l,"aria-label":k(c),"aria-pressed":a[b],"data-testid":`project-search-option-${b}`,className:(0,u.cn)("border border-transparent font-mono text-xs text-muted-foreground","wholeWord"===b&&"underline underline-offset-4",a[b]&&"border-input bg-accent text-accent-foreground"),onClick:()=>f({[b]:!a[b]})}),children:e}),(0,d.jsx)(J.ZI,{children:k(c)})]},b))})]})]})})}function N(a,b,c=0){let e=[],f=0;for(let g of b){let b=Math.max(f,g.start-c,0),h=Math.min(g.end-c,a.length);h<=b||(e.push(a.slice(f,b)),e.push((0,d.jsx)("mark",{className:"rounded-sm bg-foreground/15 text-inherit",children:a.slice(b,h)},`${b}:${h}`)),f=h)}return e.push(a.slice(f)),e}function O({search:a,resultsRef:b,activePath:c,onOpen:e,wrapFile:f,renderFileIcon:g,fileDecoration:h}){let{t:l}=(0,r.Bd)("projectFiles"),m=(0,q.useId)(),[n,o]=(0,q.useState)(!1),[s,t]=(0,q.useState)(new Set),[v,w]=(0,q.useState)(null),x=new Map;for(let b of a.contentMatches){let a=x.get(b.path);a?a.push(b):x.set(b.path,[b])}let y=!!a.query.trim(),z=y&&"ready"===a.status,A=a.fileMatches.length,B=a.contentMatches.length,C="all"===a.scope&&A>3&&B>0&&!n,D=C?a.fileMatches.slice(0,3):a.fileMatches,E=l("searchCounts",{files:new Set([...a.fileMatches.map(a=>a.path),...x.keys()]).size,lines:B}),H=a=>{t(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})};return(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,d.jsxs)("div",{className:"flex min-h-8 flex-wrap items-center justify-between gap-x-2 px-3 text-xs text-muted-foreground",role:"status","aria-live":"polite",children:[(0,d.jsx)("span",{children:l("searchResults")}),z?(0,d.jsx)("span",{className:"tabular-nums",children:a.truncated?l("searchShownCounts",{counts:E}):E}):null]}),(0,d.jsx)(F.V,{className:"min-h-0 flex-1",viewportClassName:"pb-2",children:(0,d.jsx)("div",{ref:b,role:"region","aria-label":l("searchResults"),"aria-busy":y&&"loading"===a.status,onKeyDown:a=>{if("ArrowDown"!==a.key&&"ArrowUp"!==a.key&&"Home"!==a.key&&"End"!==a.key)return;let b=[...a.currentTarget.querySelectorAll("button")].filter(a=>!a.disabled&&!a.closest("[hidden]")),c=b.indexOf(document.activeElement);if(c<0)return;a.preventDefault();let d="Home"===a.key?0:"End"===a.key?b.length-1:Math.max(0,Math.min(b.length-1,c+("ArrowDown"===a.key?1:-1)));b[d]?.focus()},children:y?"loading"===a.status?(0,d.jsxs)("div",{className:"flex min-h-10 items-center gap-2 px-3 text-xs text-muted-foreground",children:[(0,d.jsx)(j.A,{className:"size-3.5 animate-spin"}),l("searching")]}):"error"===a.status?(0,d.jsx)("p",{role:"alert",className:"mx-3 my-2 break-words rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:a.error||l("searchFailed")}):z&&0===A&&0===B?(0,d.jsxs)("div",{className:"px-5 py-9 text-center text-sm text-muted-foreground",children:[(0,d.jsx)(p.A,{className:"mx-auto mb-3 size-6"}),(0,d.jsx)("p",{children:l(a.truncated?"resultLimit":"noMatches")}),(0,d.jsx)("p",{className:"mt-2 text-xs",children:l("searchTryOptions")})]}):z?(0,d.jsxs)(d.Fragment,{children:[A>0?(0,d.jsxs)("section",{className:"pt-1",children:[(0,d.jsxs)("h3",{className:"flex min-h-8 items-center gap-2 px-3 text-xs text-muted-foreground",children:[l("searchFileHeading"),(0,d.jsx)("span",{className:"tabular-nums",children:A})]}),D.map(({path:a,ranges:b})=>{let i=a.lastIndexOf("/"),j=h(a);return f(a,void 0,(0,d.jsxs)(G.$,{type:"button",variant:"ghost","data-testid":`project-search-result-${a}`,"data-search-result":"true",className:(0,u.cn)("mx-1.5 flex min-h-14 w-[calc(100%-0.75rem)] justify-start gap-2 px-2 py-2 text-left font-normal",c===a&&"bg-accent"),title:a,onClick:()=>e(a),children:[(0,d.jsx)("span",{className:"shrink-0",children:g(a)}),(0,d.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,d.jsx)("span",{className:(0,u.cn)("block truncate text-sm",j.className),children:N(a.slice(i+1),b,i+1)}),(0,d.jsx)("span",{className:"mt-0.5 block truncate font-mono text-xs text-muted-foreground",children:i<0?l("searchProjectRoot"):N(a.slice(0,i),b)})]}),j.badge?(0,d.jsx)("span",{className:(0,u.cn)("text-xs",j.className),"aria-label":l("gitStatus",{status:j.badge}),children:j.badge}):null]},a))}),C?(0,d.jsx)(G.$,{type:"button",variant:"ghost",size:"sm",className:"ml-8 text-xs text-muted-foreground",onClick:()=>o(!0),children:l("searchExpandFiles",{count:A-3})}):null]}):null,B>0?(0,d.jsxs)("section",{className:(0,u.cn)("pt-1",A>0&&"mt-2 border-t"),children:[(0,d.jsxs)("h3",{className:"flex min-h-8 flex-wrap items-center gap-x-2 px-3 text-xs text-muted-foreground",children:[l("searchContentHeading"),(0,d.jsx)("span",{children:l("searchContentCounts",{lines:B,files:x.size})})]}),[...x].map(([a,b],c)=>{let g=a.lastIndexOf("/"),h=!s.has(a),j=`${m}-${c}`;return(0,d.jsxs)("section",{className:"mb-1",children:[(0,d.jsxs)(G.$,{type:"button",variant:"ghost",className:"min-h-8 w-full justify-start gap-1.5 rounded-none px-3 text-left font-normal",title:a,"aria-expanded":h,"aria-controls":j,onClick:()=>H(a),onKeyDown:b=>{("ArrowLeft"===b.key&&h||"ArrowRight"===b.key&&!h)&&(b.preventDefault(),H(a))},children:[(0,d.jsx)(k.A,{className:(0,u.cn)("size-3 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none",h&&"rotate-90")}),(0,d.jsx)(i.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,d.jsxs)("span",{className:"min-w-0 truncate text-sm",children:[a.slice(g+1),(0,d.jsx)("span",{className:"ml-1.5 text-xs text-muted-foreground",children:a.slice(0,Math.max(0,g))})]}),(0,d.jsx)("span",{className:"ml-auto shrink-0 rounded bg-muted px-1 text-xs text-muted-foreground tabular-nums",children:b.length})]}),(0,d.jsx)("div",{id:j,hidden:!h,children:b.map(({line:b,text:c,ranges:g})=>f(a,b,(0,d.jsxs)(G.$,{type:"button",variant:"ghost","data-testid":`project-search-line-${a}-${b}`,"data-search-result":"true",className:(0,u.cn)("min-h-8 w-full justify-start gap-2 rounded-none border-l-2 border-transparent py-1 pr-3 pl-7 text-left font-mono font-normal",v?.path===a&&v.line===b&&"border-l-foreground/50 bg-accent"),title:c,"aria-label":l("searchOpenLine",{path:a,line:b}),onClick:()=>{w({path:a,line:b}),e(a,b)},children:[(0,d.jsx)("span",{className:"min-w-5 shrink-0 text-right text-xs text-muted-foreground tabular-nums",children:b}),(0,d.jsx)("span",{className:"min-w-0 truncate whitespace-pre text-sm",children:N(c,g)})]},`${a}:${b}`)))})]},a)})]}):null,a.truncated?(0,d.jsx)("p",{className:"px-3 py-2 text-xs leading-5 text-muted-foreground",children:l("resultLimit")}):null]}):null:(0,d.jsxs)("div",{className:"px-5 py-9 text-center text-sm text-muted-foreground",children:[(0,d.jsx)(p.A,{className:"mx-auto mb-3 size-6"}),(0,d.jsx)("p",{children:l("searchStart")}),(0,d.jsx)("p",{className:"mt-2 text-xs",children:l("files"===a.scope?"searchFiles":"content"===a.scope?"searchContent":"searchAll")})]})})}),"files"!==a.scope?(0,d.jsx)("p",{className:"shrink-0 border-t px-3 py-1.5 text-xs leading-5 text-muted-foreground",children:l("searchTextLimit")}):null]})}var P=c(49057),Q=c(51108),R=c(83731);let S=[],T=new WeakMap;function U(a){let b=a.split("/").at(-1)?.toLocaleLowerCase()??"",c=b.includes(".")?b.split(".").at(-1)??"":"";return["png","jpg","jpeg","webp","gif"].includes(c)?(0,d.jsx)(e.A,{className:"size-4 text-muted-foreground"}):"json"===c||"jsonl"===c?(0,d.jsx)(f.A,{className:"size-4 text-muted-foreground"}):["md","mdx","txt"].includes(c)?(0,d.jsx)(g.A,{className:"size-4 text-muted-foreground"}):["ts","tsx","js","jsx","mjs","cjs","py","go","rs","java","c","cpp","h","hpp","css","scss","html","xml","yaml","yml","toml","sql","sh"].includes(c)?(0,d.jsx)(h.A,{className:"size-4 text-muted-foreground"}):(0,d.jsx)(i.A,{className:"size-4 text-muted-foreground"})}function V(a){if(a)return(0,P.iH)(a.change)}function W({state:a,onRetry:b}){let{t:c}=(0,r.Bd)("projectFiles");return a&&"idle"!==a.status&&"loading"!==a.status?"error"!==a.status?null:(0,d.jsx)("button",{type:"button",onClick:b,className:"min-h-8 w-full rounded px-2 text-left text-xs text-destructive hover:bg-destructive/10",children:c("retryReading",{error:a.error})}):(0,d.jsxs)("div",{className:"flex min-h-8 items-center gap-2 px-2 text-xs text-muted-foreground",children:[(0,d.jsx)(j.A,{className:"size-3.5 animate-spin"})," ",c("reading")]})}function X({cwd:a,projectName:b,runtime:c,gitRuntime:e,onOpenGitBranches:f,onFileOpened:g,rootTitle:h,gitReadOnly:i=!1}){let j,v,w,{t:x}=(0,r.Bd)("projectFiles"),{locale:B}=(0,t.i)();(0,q.useSyncExternalStore)(c.subscribe,c.getRevision,c.getRevision),(0,q.useSyncExternalStore)(e.subscribe,e.getRevision,e.getRevision);let D=c.state,H=e.getWorkspace(a),I=(0,q.useRef)(null),J=(0,q.useRef)(null),K=(0,q.useRef)(null),L=(0,q.useRef)(null),[N,Y]=(0,q.useState)(!1),Z=(0,q.useRef)({}),$=(0,q.useCallback)(a=>{a?T.set(c,Z.current):T.get(c)===Z.current&&T.delete(c),Y(a)},[c]),_=D.searchOpen,aa=()=>{Y(!1),c.setSearchOpen(!1),requestAnimationFrame(()=>L.current?.focus())},[ab,ac]=(0,q.useState)({}),ad=(a,b)=>{let c=ab[a]??300;return c<b?(0,d.jsx)("button",{type:"button",className:"min-h-8 px-3 text-sm text-muted-foreground hover:bg-accent",onClick:b=>{b.stopPropagation(),ac(b=>({...b,[a]:c+300}))},children:x("showMore",{visible:c,total:b})}):null};D?.search.query;let ae=H?.snapshot.repositories??S,af=(0,P.eP)(ae),ag=new Map(af.map(a=>[a.projectPath,a])),ah=ae.map(a=>a.root).filter(Boolean);[...H?.expandedRepositories??[]].join("\0");let ai=new Set(ah),aj=new Map,ak=new Set([...D.expandedPaths].map(a=>(0,R.Im)("directory",a))),al=(a,b)=>{let d=new Set(D.expandedPaths);for(let c of a.paths)b?d.add(c):d.delete(c);c.setExpandedPaths(d,!1),b&&!H?.changesOnly&&c.expandDirectoryChain(a.path,ai)},am=a=>{for(let[b,c]of[...aj].filter(([b])=>a.has((0,R.Im)("directory",b))!==D.expandedPaths.has(b)))al(c,a.has((0,R.Im)("directory",b)))},an=(a,b)=>{c.openFile(a,b),g?.()},ao=a=>{c.openDiff(a.repositoryRoot,a.path),g?.()},ap=(b,e)=>(0,d.jsx)(Q.J,{cwd:a,path:b.targetPath,type:"directory",trigger:e,expanded:D.expandedPaths.has(b.path),onToggle:()=>al(b,!D.expandedPaths.has(b.path)),onReveal:c.canReveal?(a,b)=>c.revealFile(a,b):void 0},(0,R.Im)("directory",b.path)),aq=(b,e,f=null,g=!1,h)=>(0,d.jsx)(Q.J,{cwd:a,path:b,type:"file",trigger:e,openLabel:x(g?"viewDiff":"openPreview"),onOpen:()=>g&&f?ao(f):an(b,h),oldPath:f?.change.oldPath?(0,R._J)(f.repositoryRoot,f.change.oldPath):void 0,onReveal:c.canReveal?(a,b)=>c.revealFile(a,b):void 0},void 0===h?(0,R.Im)("file",b):`${b}:${h}`),ar=(a,b,c,e)=>aq(a,(0,d.jsxs)(E,{path:(0,R.Im)("file",a),name:b,title:a,"data-testid":`project-file-${a}`,onClick:()=>{e&&c?ao(c):an(a)},children:[(0,d.jsx)("span",{className:"size-6 shrink-0"}),(0,d.jsx)(z,{children:U(a)}),(0,d.jsx)(A,{"data-testid":`project-file-name-${a}`,className:(0,u.cn)("min-w-0 flex-1",V(c)),children:b}),c?(0,d.jsx)("span",{className:(0,u.cn)("text-xs tabular-nums",V(c)),"aria-label":x("gitStatus",{status:(0,P.XB)(c.change)}),children:(0,P.XB)(c.change)}):null]}),c,e),as=(a,b,e)=>{let f=D?.directories.get(a);if(f?.status!=="ready")return(0,d.jsx)(W,{state:f,onRetry:()=>void c.ensureDirectory(a)});let g=e?f.entries.filter(c=>{let d;return d=(0,R._J)(a,c.name),!ah.some(a=>a!==b&&d===a)}):f.entries;return(0,d.jsxs)(d.Fragment,{children:[g.slice(0,ab[`directory:${a}`]??300).map(f=>{let g=(0,R._J)(a,f.name);if("file"===f.type)return ar(g,f.name,ag.get(g)??null,!1);let h=c.compactDirectory(g,ai);return aj.set(g,h),ap(h,(0,d.jsx)(C,{path:(0,R.Im)("directory",g),name:h.label,title:h.targetPath,"data-testid":`project-folder-${g}`,children:as(h.targetPath,b,e)}))}),ad(`directory:${a}`,g.length),f.truncated?(0,d.jsx)("p",{className:"px-2 py-2 text-xs leading-5 text-amber-600 dark:text-amber-400",children:x("directoryLimit")}):null,0===g.length?(0,d.jsx)("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:x("emptyDirectory")}):null]})},at=(a,b)=>{let c=a.get(b);if(!c)return null;let e=[...c.directories.keys()].sort(R.Kn),f=[...c.files].sort(R.Kn),g=ab[`changes:${b}`]??300;return(0,d.jsxs)(d.Fragment,{children:[e.slice(0,g).map(b=>{let c=(0,R.xV)(b,a,ai);return aj.set(b,c),ap(c,(0,d.jsx)(C,{path:(0,R.Im)("directory",b),name:c.label,title:c.targetPath,"data-testid":`project-folder-${b}`,children:at(a,c.targetPath)}))}),f.slice(0,Math.max(0,g-e.length)).map(a=>ar(a,a.slice(a.lastIndexOf("/")+1),ag.get(a)??null,!0)),ad(`changes:${b}`,e.length+f.length)]})},au=a=>{if(a.startsWith("directory:")){let b=aj.get(a.slice(10));b&&al(b,!D.expandedPaths.has(b.path));return}let b=a.slice(5),c=ag.get(b);H?.changesOnly&&c?ao(c):an(b)},av=(g,h,j)=>{if(H?.changesOnly&&!g)return null;let o=H?.expandedRepositories.has(h)??!1,p=g?.state==="ready"?af.filter(a=>a.repositoryRoot===h):[],q=p.length;if(H?.changesOnly&&g?.state==="ready"&&0===q)return null;let r=(0,R.OA)(p.map(a=>a.projectPath),h);return(0,d.jsxs)("section",{"data-testid":`project-git-repository-${h||"root"}`,className:"border-b last:border-b-0",children:[(0,d.jsxs)("div",{className:"flex min-h-8 items-center gap-1 px-1 py-0.5",children:[(0,d.jsxs)("button",{"data-testid":`project-git-repository-toggle-${h||"root"}`,type:"button",className:"flex min-w-0 flex-1 items-center gap-1 rounded-md px-1 py-0.5 text-left hover:bg-muted/60","aria-expanded":o,onClick:()=>{o&&c.cancelDirectoryExpansion(h),e.toggleRepository(a,h),o||c.ensureDirectory(h)},children:[(0,d.jsx)(k.A,{className:(0,u.cn)("size-3 shrink-0 text-muted-foreground transition-transform",o&&"rotate-90")}),g?(0,d.jsx)(l.A,{className:"size-4 shrink-0 text-muted-foreground"}):(0,d.jsx)(m.A,{className:"size-4 shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:g&&h||b,children:j})]}),g?(0,d.jsxs)("button",{"data-testid":`project-git-branch-${h||"root"}`,type:"button",disabled:i||"ready"!==g.state,className:(0,u.cn)((0,G.r)({variant:"outline",size:"sm"}),"max-w-28 shrink gap-1 font-mono text-xs text-muted-foreground"),title:"ready"===g.state?x(i?"gitBranchReadOnly":"gitBranches"):(0,s.fD)(g.message,B),onClick:()=>f(h),children:[(0,d.jsx)(n.A,{className:"size-3 shrink-0"}),(0,d.jsx)("span",{className:"min-w-0 truncate",children:"ready"===g.state?(0,P.ws)(g.head):x("unavailable")}),q>0?(0,d.jsx)("span",{className:"rounded-md bg-muted px-1 text-xs text-status-warning",children:q}):null]}):null]}),o?H?.changesOnly?(0,d.jsx)(y,{className:"rounded-none border-0 bg-transparent px-1 pb-1",expanded:ak,selectedPath:D?.activeDiff?(0,R.Im)("file",(0,P.oW)(D.activeDiff.repositoryRoot,D.activeDiff.path)):void 0,onExpandedChange:am,onSelect:au,children:q>0?at(r,h):(0,d.jsx)("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:x("noChanges")})}):(0,d.jsx)(y,{className:"rounded-none border-0 bg-transparent px-1 pb-1",expanded:ak,selectedPath:D.activePath?(0,R.Im)("file",D.activePath):void 0,onExpandedChange:am,onSelect:au,children:as(h,g?.root??null,!0)}):null]},g?`git:${h}`:"workspace")},aw=1===ae.length&&ae[0]?.root===""?ae[0]:null,ax=ae.length>0&&!aw,ay=ax?H?.layout??"directory":"directory";return(0,d.jsxs)("section",{className:"flex h-full min-h-0 flex-col bg-sidebar","aria-label":x("projectFiles",{name:b}),onKeyDown:a=>{!_||"Escape"!==a.key||(a.stopPropagation(),a.nativeEvent.isComposing||N||(a.preventDefault(),aa()))},children:[_?(0,d.jsx)(M,{input:D.search,inputRef:J,invalid:"error"===D.search.status,onQueryChange:a=>c.setSearchQuery(a),onOptionsChange:a=>c.setSearchOptions(a),onComposingChange:$,onClose:aa,onOpenFirst:()=>{let a=c.state.search;if("ready"!==a.status)return;let b=a.fileMatches[0],d=a.contentMatches[0];b?an(b.path):d&&an(d.path,d.line)},onFocusResults:()=>K.current?.querySelector("button")?.focus()}):(0,d.jsxs)("div",{className:"space-y-1.5 border-b px-2.5 py-2",children:[(0,d.jsxs)("div",{className:"flex min-h-7 min-w-0 items-center gap-2",children:[(0,d.jsx)(Q.J,{cwd:a,path:"",type:"directory",onReveal:c.canReveal?(a,b)=>c.revealFile(a,b):void 0,trigger:h?(0,d.jsx)("div",{className:"flex min-w-0 flex-1",children:h}):(0,d.jsxs)("div",{tabIndex:0,className:"flex min-w-0 flex-1 items-baseline gap-1",children:[(0,d.jsx)("p",{className:"shrink-0 truncate text-xs font-semibold",title:b,children:b}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"\xb7"}),(0,d.jsx)("p",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",title:a,children:(j=a.replaceAll("\\","/").split("/").filter(Boolean)).length<=2?a:`…/${j.slice(-2).join("/")}`})]})}),aw?(0,d.jsxs)("button",{type:"button",disabled:i||"ready"!==aw.state,className:(0,u.cn)((0,G.r)({variant:"outline",size:"sm"}),"max-w-32 shrink gap-1 font-mono text-xs text-muted-foreground"),title:"ready"===aw.state?x(i?"gitBranchReadOnly":"gitBranches"):(0,s.fD)(aw.message,B),onClick:()=>f(""),children:[(0,d.jsx)(n.A,{className:"size-3 shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:"ready"===aw.state?(0,P.ws)(aw.head):x("unavailable")})]}):null]}),(0,d.jsxs)("div",{className:"flex min-h-8 min-w-0 items-center gap-1.5",children:[ax?(0,d.jsx)("div",{className:"flex shrink-0 rounded-md border bg-background/55 p-0.5",role:"group","aria-label":x("layout"),children:["directory","repository"].map(b=>(0,d.jsx)("button",{"data-testid":`project-file-layout-${b}`,type:"button","aria-pressed":ay===b,className:(0,u.cn)((0,G.r)({variant:"ghost",size:"sm"}),ay===b&&"bg-accent text-accent-foreground"),onClick:()=>{c.cancelDirectoryExpansion(),e.setLayout(a,b)},children:x("directory"===b?"directory":"repository")},b))}):null,ae.length>0?(0,d.jsxs)("button",{"data-testid":"project-git-changes-toggle",type:"button","aria-pressed":H?.changesOnly??!1,className:(0,u.cn)((0,G.r)({variant:"outline",size:"sm"}),"min-w-0 gap-1",H?.changesOnly&&"bg-accent text-accent-foreground"),onClick:()=>{c.cancelDirectoryExpansion(),e.setChangesOnly(a,!H?.changesOnly)},children:[(0,d.jsx)(o.A,{className:"size-3 shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:x("changesOnly")}),(0,d.jsx)("span",{className:"rounded-md bg-muted px-1 font-mono text-xs",children:af.length})]}):null,(0,d.jsx)("button",{ref:L,type:"button",className:(0,u.cn)((0,G.r)({variant:"outline",size:"icon-sm"}),"ml-auto"),"aria-label":x("searchProject"),title:x("searchProject"),onClick:()=>{c.setSearchOpen(!0),requestAnimationFrame(()=>J.current?.focus())},children:(0,d.jsx)(p.A,{className:"size-3.5"})})]})]}),_?(0,d.jsx)(O,{search:D.search,resultsRef:K,activePath:D.activeDiff?null:D.activePath,onOpen:an,wrapFile:(a,b,c)=>aq(a,c,ag.get(a)??null,!1,b),renderFileIcon:U,fileDecoration:a=>{let b=ag.get(a)??null;return{className:V(b),badge:b?(0,P.XB)(b.change):void 0}}},JSON.stringify([D.search.query,D.search.scope,D.search.caseSensitive,D.search.wholeWord,D.search.regex])):(0,d.jsxs)(F.V,{className:"min-h-0 flex-1",viewportClassName:"py-1.5",viewportRef:I,onViewportScroll:a=>c.setTreeScrollTop(a.currentTarget.scrollTop),children:[ae.filter(a=>"unavailable"===a.state).map(a=>"unavailable"===a.state?(0,d.jsxs)("p",{role:"alert",className:"mx-2 mb-1 break-words rounded-md bg-muted px-2 py-2 text-sm text-destructive",children:[a.root||b,":",(0,s.fD)(a.message,B)]},a.root):null),H?.snapshot.status==="error"?(0,d.jsx)("p",{className:"mx-2 mb-1 rounded-md bg-muted px-2 py-2 text-sm text-destructive",children:H.snapshot.error}):null,"repository"===ay?(v=ae.some(a=>""===a.root),w=H?.changesOnly?ae.filter(a=>"unavailable"===a.state||a.changes.length>0):ae,(0,d.jsxs)("div",{className:"px-1",children:[v?null:av(null,"",b),w.map(a=>av(a,a.root,(0,P.Hj)(b,a.root))),H?.changesOnly&&0===w.length?(0,d.jsx)("p",{className:"px-2 py-5 text-center text-xs text-muted-foreground",children:x("noChangedFiles")}):null]})):(()=>{if(H?.changesOnly){let a=(0,R.OA)(af.map(a=>a.projectPath));return(0,d.jsx)(y,{className:"rounded-none border-0 bg-transparent",expanded:ak,selectedPath:D?.activeDiff?(0,R.Im)("file",(0,P.oW)(D.activeDiff.repositoryRoot,D.activeDiff.path)):D.activePath?(0,R.Im)("file",D.activePath):void 0,onExpandedChange:am,onSelect:au,children:af.length>0?at(a,""):(0,d.jsx)("p",{className:"px-2 py-5 text-center text-xs text-muted-foreground",children:ae.some(a=>"unavailable"===a.state)?x("incompleteRepository"):x("noChangedFiles")})})}return(0,d.jsx)(y,{className:"rounded-none border-0 bg-transparent",expanded:ak,selectedPath:D.activePath?(0,R.Im)("file",D.activePath):void 0,onExpandedChange:am,onSelect:au,children:as("",null,!1)})})()]})]})}},49057:(a,b,c)=>{"use strict";c.d(b,{A_:()=>k,Hj:()=>i,XB:()=>l,eP:()=>o,iH:()=>m,lN:()=>n,oW:()=>h,oY:()=>g,ws:()=>j});var d=c(53403),e=c(89172),f=c(83731);function g(a){let b=new Map;for(let c of a){let a=c.split("/").filter(Boolean),d=b,e="";for(let[b,f]of a.entries()){e=e?`${e}/${f}`:f;let g=d.get(f);g||(g={name:f,path:e,branchName:null,children:new Map},d.set(f,g)),b===a.length-1&&(g.branchName=c),d=g.children}}return function a(b){return[...b].sort((a,b)=>a.name.localeCompare(b.name,void 0,{numeric:!0,sensitivity:"base"})).map(b=>({name:b.name,path:b.path,branchName:b.branchName,children:a(b.children.values())}))}(b.values())}function h(a,b){return(0,f._J)(a,b)}function i(a,b){return b.split("/").at(-1)||a}function j(a){return"branch"===a.type?a.name:`@ ${a.commit.slice(0,7)}`}function k(a,b,c="en"){if(0===b.length)return null;let f=e.C[c];if(1===b.length){let e=b[0],g=i(a,e.root);if("unavailable"===e.state){let a=f.gitUnavailable;return{full:e.root?`${g} \xb7 ${a}`:a,compact:"Git !",title:`${g}${"en"===c?": ":":"}${(0,d.fD)(e.message,c)}`,diverged:!0}}let h=j(e.head);return{full:e.root?`${g} \xb7 ${h}`:h,compact:h,title:`${f.gitBranches}: ${g} \xb7 ${h}`,diverged:"detached"===e.head.type}}let g=`${b.length} ${f.repositoriesUnit}`;return{full:g,compact:`Git ${b.length}`,title:`${f.gitBranches}: ${g}`,diverged:!1}}function l(a){let b=[a.indexStatus,a.worktreeStatus];return b.includes("unmerged")?"!":b.includes("deleted")?"D":b.includes("renamed")?"R":b.includes("added")?"A":b.includes("modified")?"M":"?"}function m(a){let b=l(a);return"D"===b?"text-muted-foreground":"?"===b?"text-red-600 dark:text-red-400":"A"===b?"text-emerald-600 dark:text-emerald-400":"!"===b?"text-violet-600 dark:text-violet-400":"text-blue-600 dark:text-blue-400"}function n(a,b,c){if(/^(?:[a-z]:|\/|\\\\)/i.test(b))return null;let d=/^[a-z]:[\\/]/i.test(a)||a.startsWith("\\\\"),e=a=>d?a.toLowerCase():a,f=[...c].sort((a,b)=>b.root.length-a.root.length).find(a=>!a.root||e(b).startsWith(`${e(a.root)}/`));if(!f)return null;let g=f.root?b.slice(f.root.length+1):b;return{repository:f,path:g,change:"ready"===f.state?f.changes.find(a=>e(a.path)===e(g)):void 0}}function o(a){return a.flatMap(a=>"ready"===a.state?a.changes.map(b=>({repositoryRoot:a.root,repository:a,path:b.path,projectPath:h(a.root,b.path),change:b})):[])}},51108:(a,b,c)=>{"use strict";c.d(b,{J:()=>q});var d=c(52834),e=c(97586),f=c(87366),g=c(37496),h=c(9365),i=c(50599),j=c(49147),k=c(57850),l=c(93306),m=c(2719),n=c(91816),o=c(60819),p=c(13749);function q({cwd:a,path:b,type:c,trigger:r,openLabel:s,onOpen:t,expanded:u,onToggle:v,historical:w,oldPath:x,onReveal:y}){let{t:z}=(0,k.Bd)("projectFiles"),A=(0,m.G)(),[B,C]=(0,j.useState)(null),D=B??{cwd:a,path:b,type:c,oldPath:x},E=(0,j.useRef)(!1),F=(0,j.useRef)(""),G="file"===c?"file":"folder",H=a=>{(0,l.x)(a).then(a=>{a?A.success(z("copied")):A.error(z("copyFailed"))})},I=(D.path||D.cwd.replaceAll("\\","/")).split("/").filter(Boolean).at(-1)??D.cwd;return(0,d.jsxs)(n.tz,{onOpenChange:(d,e)=>{C(d?{cwd:a,path:b,type:c,oldPath:x}:null);let f=e.event;d&&("touch"===F.current||"pointerType"in f&&"touch"===f.pointerType||f.type.startsWith("touch"))&&(E.current=!0)},children:[(0,d.jsx)(n.Rc,{render:r,"data-project-path-menu-trigger":"",onPointerDown:a=>{F.current=a.pointerType,E.current=!1},onTouchEndCapture:a=>{let b=a.target;!B||!E.current||"touch"!==F.current||b instanceof Element&&b.closest("[data-project-path-menu-trigger]")===a.currentTarget&&a.cancelable&&a.preventDefault()},onClickCapture:a=>{E.current&&(a.preventDefault(),a.stopPropagation(),E.current=!1)},onKeyDownCapture:a=>{if(a.defaultPrevented||a.nativeEvent.isComposing)return;let b=a.target;if(!(b instanceof Element)||b.closest("[data-project-path-menu-trigger]")!==a.currentTarget||(F.current="keyboard",E.current=!1,"ContextMenu"!==a.key&&!("F10"===a.key&&a.shiftKey)))return;a.preventDefault(),a.stopPropagation();let c=b.getBoundingClientRect();a.currentTarget.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,button:2,clientX:c.left+Math.min(c.width,120)/2,clientY:c.top+Math.min(c.height,36)/2}))}}),(0,d.jsxs)(o.D,{children:[t?(0,d.jsxs)(n.kt,{onClick:t,children:[(0,d.jsx)(e.A,{}),s??z("openPreview")]}):null,v?(0,d.jsxs)(n.kt,{onClick:v,children:[u?(0,d.jsx)(f.A,{}):(0,d.jsx)(g.A,{}),z(u?"collapse":"expand")]}):null,t||v?(0,d.jsx)(n.K5,{}):null,y?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(n.kt,{"data-testid":`project-${G}-reveal-${b}`,onClick:()=>{y&&y(D.path,D.type).then(()=>A.success(z("revealRequested"))).catch(a=>{A.error(a instanceof Error?a.message:z("revealFailed"))})},children:[(0,d.jsx)(h.A,{}),w?"directory"===c?z("openCurrentWorkspace"):z("locateCurrentWorkspace"):"directory"===c?z("openFolder"):z("openContainingFolder")]}),(0,d.jsx)(n.K5,{})]}):null,(0,d.jsxs)(n.kt,{"data-testid":`project-${G}-copy-address-${b}`,onClick:()=>H((0,p.$)(D.cwd,D.path)),children:[(0,d.jsx)(i.A,{}),z("copyAbsolutePath")]}),(0,d.jsxs)(n.kt,{onClick:()=>H(D.path||"."),children:[(0,d.jsx)(i.A,{}),z("copyRelativePath")]}),(0,d.jsxs)(n.kt,{onClick:()=>H(I),children:[(0,d.jsx)(i.A,{}),z("directory"===c?"copyFolderName":"copyFileName")]}),D.oldPath?(0,d.jsxs)(n.kt,{onClick:()=>H(D.oldPath),children:[(0,d.jsx)(i.A,{}),z("copyOldRelativePath")]}):null]})]})}},51949:(a,b,c)=>{"use strict";c.d(b,{CT:()=>n,JH:()=>p,NL:()=>g,Nu:()=>q,_g:()=>k,eC:()=>l,gB:()=>h,ih:()=>v,jI:()=>u,p$:()=>m,rh:()=>j,uV:()=>e,xm:()=>f});var d=c(87883);let e=4096,f=5e3,g=5242880,h=1048576;function i(a,b){return""===a?b:!(a.length>e||a.startsWith("/")||a.includes("\\")||a.includes("\0")||/^[a-zA-Z]:/.test(a))&&a.split("/").every(a=>a.length>0&&"."!==a&&".."!==a)}let j=d.Yj().max(e).refine(a=>i(a,!0),"目录路径必须是规范相对路径"),k=d.Yj().min(1).max(e).refine(a=>i(a,!1),"文件路径必须是规范相对路径"),l=d.Yj().min(1).max(e).refine(a=>i(a,!1)||a.length>0&&a.length<=e&&!a.includes("\0")&&(a.startsWith("/")||a.startsWith("\\\\")||/^[a-zA-Z]:[\\/]/.test(a)),"预览路径必须是规范相对路径或绝对路径"),m=d.k5(["compressed","original"]),n=d.k5(["image/jpeg","image/png","image/webp","image/gif"]),o=d.Ik({name:d.Yj().min(1),type:d.k5(["directory","file"])}).strict(),p=d.Ik({entries:d.YO(o).max(f),truncated:d.zM()}).strict(),q=d.Ik({query:d.Yj().min(1).max(200).refine(a=>a.trim().length>0&&!/[\0\r\n]/.test(a),"搜索词必须是非空单行文本"),scope:d.k5(["all","files","content"]).default("all"),caseSensitive:d.zM().default(!1),wholeWord:d.zM().default(!1),regex:d.zM().default(!1)}).strict(),r=d.Ik({start:d.ai().int().nonnegative(),end:d.ai().int().nonnegative()}).strict().refine(a=>a.start<=a.end,"搜索命中区间无效"),s=d.Ik({path:k,ranges:d.YO(r)}).strict().refine(a=>a.ranges.every(b=>b.end<=a.path.length),"文件名命中区间越界"),t=d.Ik({path:k,line:d.ai().int().positive(),text:d.Yj().max(1e3),ranges:d.YO(r)}).strict().refine(a=>a.ranges.every(b=>b.end<=a.text.length),"正文命中区间越界"),u=d.Ik({fileMatches:d.YO(s).max(100),contentMatches:d.YO(t).max(200),truncated:d.zM()}).strict(),v=d.gM("kind",[d.Ik({kind:d.eu("text"),content:d.Yj(),size:d.ai().int().nonnegative().max(g)}).strict(),d.Ik({kind:d.eu("image"),mimeType:n,data:d.Yj().min(1),size:d.ai().int().positive().max(0xa00000)}).strict()])},51972:(a,b,c)=>{"use strict";function d(a,b,c){a.addCommand(b,c,"editorTextFocus && !findWidgetVisible && !suggestWidgetVisible && !renameInputVisible && !parameterHintsVisible && !referenceSearchVisible && !editorHoverVisible && !editorHoverFocused")}c.d(b,{e:()=>d})},52660:(a,b,c)=>{"use strict";c.d(b,{Wq:()=>g,ku:()=>i,lU:()=>h}),c(51949);let d=new Set,e="compressed";function f(){}function g(){return f(),e}function h(a){if(f(),e!==a){e=a;try{window.localStorage.setItem("pi-super:image-preview-mode",a)}catch{}for(let a of[...d])a()}}function i(a){return d.add(a),()=>d.delete(a)}},53403:(a,b,c)=>{"use strict";c.d(b,{fD:()=>f,qf:()=>e});var d=c(87883);let e=d.KC([d.Yj(),d.Ik({default:d.Yj(),translations:d.g1(d.Yj().min(1).max(35),d.Yj()).refine(a=>Object.keys(a).length<=16,"too many translations")}).strict()]);function f(a,b){return"string"==typeof a?a:a.translations[b]??a.translations[b.split("-")[0]]??a.default}},53437:(a,b,c)=>{"use strict";c.d(b,{IV:()=>o,om:()=>t,e6:()=>v,XC:()=>s});var d=c(52834),e=c(60816),f=c(63345),g=c(98004),h=c(40181),i=c(49028),j=c(21556),k=c(97832),l=c(57850),m=c(38684),n=c(15620);let o={input:["dataPiMarkdownProgress"],blockquote:["dataPiMarkdownAlert"]};function p(a){return{type:"paragraph",children:[],data:{hName:"input",hProperties:{type:"checkbox",disabled:!0,checked:"[x]"===a.toLowerCase(),..."[-]"===a?{dataPiMarkdownProgress:"true"}:{}}}}}var q=c(4935),r=c.n(q);let s=[...Object.values(m.U2),function(){return(a,b)=>{let c=String(b.value),d=(a,b)=>{let d=a.position?.start.offset;return void 0!==d&&c.slice(d,d+b.length)===b},e=a=>{let b=a.children?.[0];if("tableCell"===a.type&&a.children?.length===1&&b?.type==="text"){let c=b.value??"";/^\[[ xX-]\]$/.test(c)&&d(b,c)&&(a.children=[p(c)])}else if("listItem"===a.type&&b?.type==="paragraph"){let c=b.children?.[0];c?.type==="text"&&/^\[-\](?:\s|$)/.test(c.value??"")&&d(c,"[-]")&&(c.value=c.value.slice(3),b.children.unshift(p("[-]")),a.data={...a.data,hProperties:{className:["task-list-item"]}})}else if("blockquote"===a.type&&b?.type==="paragraph"){let c=b.children?.[0],e=c?.value?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\][ \t]*(?:\r?\n|$)/);c?.type==="text"&&e&&d(c,`[!${e[1]}]`)&&(e[0].endsWith("\n")||1===b.children.length||b.children[1]?.type==="break")&&(c.value=c.value.slice(e[0].length),c.value||(b.children.shift(),b.children[0]?.type==="break"&&b.children.shift()),0===b.children.length&&a.children.shift(),a.data={...a.data,hProperties:{dataPiMarkdownAlert:e[1].toLowerCase()}})}for(let b of a.children??[])e(b)};e(a)}}],t=r().markdown,u={note:{icon:e.A,label:"markdownNote"},tip:{icon:f.A,label:"markdownTip"},important:{icon:g.A,label:"markdownImportant"},warning:{icon:h.A,label:"markdownWarning"},caution:{icon:i.A,label:"markdownCaution"}},v={input:function({"data-pi-markdown-progress":a,...b}){let{t:c}=(0,l.Bd)("common");if(delete b.node,"checkbox"!==b.type)return(0,d.jsx)("input",{...b});let e=a?"progress":b.checked?"completed":"pending",f=a?"[-]":b.checked?"[x]":"[ ]",g=c(a?"markdownProgress":b.checked?"markdownCompleted":"markdownPending");return(0,d.jsxs)("span",{className:r().status,"data-state":e,role:"img","aria-label":g,title:g,children:[a?(0,d.jsx)(j.A,{"aria-hidden":"true"}):b.checked?(0,d.jsx)(k.A,{"aria-hidden":"true"}):null,(0,d.jsx)("span",{className:"sr-only","aria-hidden":"true",children:f})]})},blockquote:function({"data-pi-markdown-alert":a,className:b,children:c,...e}){let{t:f}=(0,l.Bd)("common");delete e.node;let g=Object.entries(u).find(([b])=>b===a)?.[1];if(!g)return(0,d.jsx)("blockquote",{...e,"data-streamdown":"blockquote",className:(0,n.cn)("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",b),children:c});let h=g.icon;return(0,d.jsxs)("aside",{className:r().alert,role:"note","aria-label":f(g.label),children:[(0,d.jsxs)("div",{className:r().alertTitle,children:[(0,d.jsx)(h,{"aria-hidden":"true"}),f(g.label)]}),(0,d.jsx)("div",{className:r().alertBody,children:c})]})}}},55091:(a,b,c)=>{"use strict";function d(a){return/\.(md|markdown)$/i.test(a)?"markdown":/\.html?$/i.test(a)?"html":null}c.d(b,{g:()=>d})},55579:(a,b,c)=>{"use strict";c.d(b,{F:()=>e});let d="/project-preview";function e(a){return a?`${d}?cwd=${encodeURIComponent(a)}`:d}},59411:(a,b,c)=>{"use strict";c.d(b,{FH:()=>h,N$:()=>i,rB:()=>k,rn:()=>l});var d=c(87883),e=c(23423),f=c(41994);let g=d.Ik({cwd:e.m4,sessionCount:d.ai().int().nonnegative(),updatedAt:f.k}).strict(),h=d.Ik({forceRefresh:d.zM().default(!1)}).strict(),i=d.Ik({directories:d.YO(g)}).strict();d.Ik({cwd:e.m4,ignored:d.zM()}).strict(),d.Ik({}).strict();let j=d.Ik({cwd:e.m4,name:d.Yj().trim().min(1)}).strict(),k=d.Ik({cwd:e.m4.nullable()}).strict(),l=d.Ik({cwd:e.m4.nullable(),parentCwd:e.m4.nullable(),directories:d.YO(j)}).strict(),m=d.k5(["title","user","assistant","sessionId"]),n=d.Ik({scope:m,count:d.ai().int().positive(),entryId:e.Rv.nullable(),timestampMs:f.k.nullable(),preview:d.Yj().min(1).max(160)}).strict(),o=d.Ik({sessionId:e.$E,cwd:e.m4,name:d.Yj().nullable(),createdAt:f.k,updatedAt:f.k,messageCount:d.ai().int().nonnegative(),userMessageCount:d.ai().int().nonnegative(),firstMessage:d.Yj().max(160),matches:d.YO(n).min(1).max(4).nullable()}).strict();d.Ik({cwd:e.m4,query:d.Yj().trim().max(120).default(""),forceRefresh:d.zM().default(!1),searchIn:d.YO(m).min(1).max(4).default(["title","user"])}).strict(),d.Ik({cwd:e.m4,sessions:d.YO(o)}).strict(),d.Ik({cwd:e.m4,sessionId:e.$E,query:d.Yj().trim().max(120).default(""),page:d.Ik({index:d.ai().int().positive(),size:d.ai().int().positive().max(50)}).strict()}).strict();let p=d.Ik({entryId:e.Rv,timestampMs:f.k,text:d.Yj()}).strict();d.Ik({page:d.Ik({index:d.ai().int().positive(),size:d.ai().int().positive(),total:d.ai().int().nonnegative()}).strict(),messages:d.YO(p)}).strict()},60819:(a,b,c)=>{"use strict";c.d(b,{D:()=>k});var d=c(52834),e=c(65614),f=c(9698),g=c(5701),h=c(91816),i=c(15620),j=c(91464);function k({children:a}){return(0,d.jsx)(h.JW,{children:(0,d.jsx)(e.y,{className:"isolate z-[130] outline-none",side:"right",align:"start",alignOffset:4,children:(0,d.jsx)(f._,{"data-slot":"context-menu-content",finalFocus:!1,className:(0,i.cn)(j.hD,"flex flex-col overflow-hidden p-0"),children:(0,d.jsx)(g.V,{className:"min-h-0",viewportClassName:"p-1",children:a})})})})}},68341:(a,b,c)=>{"use strict";c.d(b,{Cp:()=>q,ph:()=>r,Tk:()=>p});var d=c(13749),e=c(95186),f=c(59411),g=c(92494);class h{constructor(a,b){this.cwd=a,this.reader=b,this.state={snapshot:{status:"idle",repositories:[],error:null},layout:"directory",changesOnly:!1,expandedRepositories:new Set},this.listeners=new Set,this.revision=0,this.request=null,this.disposed=!1,this.subscribe=a=>(this.listeners.add(a),()=>this.listeners.delete(a)),this.getRevision=()=>this.revision}getWorkspace(a){return a===this.cwd?this.state:null}ensureSnapshot(a){return a!==this.cwd||"ready"===this.state.snapshot.status||this.request?Promise.resolve():this.load(!1)}refreshSnapshot(a){return a===this.cwd?this.load(!0):Promise.resolve()}setLayout(a,b){this.state.layout=b,this.publish()}setChangesOnly(a,b){this.state.changesOnly=b,this.publish()}toggleRepository(a,b){let c=new Set(this.state.expandedRepositories);c.has(b)?c.delete(b):c.add(b),this.state.expandedRepositories=c,this.publish()}dispose(){this.disposed=!0,this.request?.abort(),this.request=null,this.listeners.clear()}async load(a){if(this.disposed)return;this.request?.abort();let b=new AbortController;this.request=b,this.state.snapshot={...this.state.snapshot,status:"loading",error:null},this.publish();try{let c=await this.reader.snapshot(b.signal,a);if(this.request!==b)return;this.state.snapshot={status:"ready",repositories:c.repositories,error:null}}catch(a){if(this.request!==b)return;this.state.snapshot={...this.state.snapshot,status:"error",error:a instanceof Error?a.message:"读取 Git 状态失败"}}this.request===b&&(this.request=null,this.publish())}publish(){if(!this.disposed)for(let a of(this.revision+=1,this.listeners))a()}}var i=c(52660),j=c(51601),k=c(21850),l=c(83731);function m(a,b){return(0,k.B)({msg:j.p["zh-CN"][a],i18n:{key:`projectHistory:${a}`,...b?{params:b}:{}}})}function n(){return{status:"idle",data:null,error:null}}class o{constructor(a,b){this.reader=a,this.files=b,this.state={repositoryRoot:null,mode:"history",tip:"HEAD",base:"",target:"HEAD",strategy:"merge-base",query:"",author:"",authorSuggestions:[],selectedCommit:null,selectedChangePath:null,branches:n(),log:n(),changes:n()},this.scroll={log:0,changes:0},this.listeners=new Set,this.requests=new Map,this.revision=0,this.disposed=!1,this.logPage=1,this.changesPage=1,this.range=null,this.selection=null,this.restoredCommit=null,this.restoredChangePath=null,this.restoredChangesScroll=null,this.queryTimer=null,this.collapsedDirectories=new Set,this.changeTree=(0,l.OA)([]),this.changeRows=[],this.subscribe=a=>(this.listeners.add(a),()=>this.listeners.delete(a)),this.getRevision=()=>this.revision}getChangeRows(){return this.changeRows}restoreBrowsing(a,b=!0){Object.assign(this.state,{repositoryRoot:a.repositoryRoot,mode:a.mode,tip:a.tip,base:a.base,target:a.target,strategy:a.strategy,query:a.query,author:a.author}),this.scroll.log=a.logScroll,this.restoredChangesScroll=a.changesScroll,this.restoredCommit=a.selectedCommit,this.restoredChangePath=a.selectedChangePath,b&&null!==a.repositoryRoot&&(this.loadBranches(),this.reload())}selectChange(a){this.state.changes.data?.items.some(b=>b.path===a)&&(this.state.selectedChangePath=a,this.publish())}toggleChangeDirectory(a){let b=this.changeRows.find(b=>b.directory?.path===a);if(b?.directory){if(b.expanded)this.collapsedDirectories.add(a);else for(let a of b.directory.paths)this.collapsedDirectories.delete(a);this.rebuildChangeRows(),this.publish()}}setScroll(a,b){this.scroll[a]=b}setRepository(a){if(a===this.state.repositoryRoot){"idle"===this.state.branches.status&&(this.loadBranches(),this.reload());return}this.cancel("branches"),this.state.repositoryRoot=a,this.state.tip=this.state.target="HEAD",this.state.base="",this.state.author="",this.state.authorSuggestions=[],this.state.branches=n(),this.resetSelection(),this.loadBranches(),this.reload()}setMode(a){this.state.mode!==a&&(this.state.mode=a,this.resetSelection(),this.reload())}setRevision(a,b){this.state[a]!==b&&(this.state[a]=b,this.resetSelection(),this.reload())}setStrategy(a){this.state.strategy!==a&&(this.state.strategy=a,this.resetSelection(),this.reload())}setQuery(a){this.setLogFilter("query",a)}setAuthor(a){this.setLogFilter("author",a)}setLogFilter(a,b){this.state[a]=b,this.resetSelection(),this.queryTimer=setTimeout(()=>{this.queryTimer=null,this.reload()},220)}refresh(){this.resetSelection(),this.loadBranches(),this.reload()}async reload(){if(!this.disposed&&null!==this.state.repositoryRoot){if("compare"===this.state.mode)return this.state.base?void await this.loadChanges({base:this.state.base,target:this.state.target,strategy:this.state.strategy},1,!0):void this.publish();await this.loadLog(1)}}selectCommit(a,b){let c="string"==typeof a?a:a.oid;this.state.selectedCommit=c,this.scroll.changes=0,this.clearHistoricalDiff(),this.loadChanges({commit:c,...b?{parent:b}:{}},1)}showAggregate(){this.range&&(this.state.selectedCommit=null,this.clearHistoricalDiff(),this.loadChanges(this.range,1))}loadMoreLog(){"ready"===this.state.log.status&&this.state.log.data?.hasMore&&!(this.state.log.data.items.length>=2e3)&&this.loadLog(this.logPage+1)}loadMoreChanges(){this.selection&&"ready"===this.state.changes.status&&this.state.changes.data?.hasMore&&this.loadChanges(this.selection,this.changesPage+1)}openChange(a){if(null===this.state.repositoryRoot)return;let b=this.state.changes.data,c=b?.items.find(b=>b.path===a);if(!b||!c)return;this.state.selectedChangePath=a,this.publish();let{original:d,target:e}=b.comparison,f=d?d.slice(0,8):m("emptyRevision"),g=m(this.state.selectedCommit||"merge-base"!==this.state.strategy?"historyDiffDirect":"historyDiffAncestor",{left:f,target:e.slice(0,8)});this.files.openDiff(this.state.repositoryRoot,a,{baseCommit:d,targetCommit:e,...c.oldPath?{oldPath:c.oldPath}:{}},g)}dispose(){for(let a of(this.disposed=!0,this.queryTimer&&clearTimeout(this.queryTimer),this.requests.values()))a.abort();this.requests.clear(),this.resetChangeTree(),this.listeners.clear()}async loadBranches(){let a=this.state.repositoryRoot;if(null===a||this.disposed)return;let b=this.begin("branches");this.state.branches={status:"loading",data:this.state.branches.data,error:null},this.publish();try{let c=await this.reader.branches(a,b.signal);if(!this.current("branches",b))return;this.state.branches={status:"ready",data:c,error:null}}catch(a){if(!this.current("branches",b))return;this.state.branches={status:"error",data:null,error:this.error(a)}}this.requests.delete("branches"),this.publish()}async loadLog(a){let b=this.state.repositoryRoot;if(this.disposed||null===b)return;let c=a>1?this.state.log.data:null,d=c?.tip??("compare"===this.state.mode?this.range?.target:this.state.tip),e=c?.exclude??("compare"===this.state.mode?this.range?.base:void 0);if(!d)return;let f=this.begin("log");this.state.log={status:"loading",data:c,error:null},this.publish();try{let g=await this.reader.log(b,{tip:d,...e?{exclude:e}:{},query:this.state.query,...this.state.author.trim()?{author:this.state.author.trim()}:{},page:{index:a,size:50}},f.signal);if(!this.current("log",f))return;for(let{author:b}of(this.logPage=a,g.items))b&&this.state.authorSuggestions.length<200&&!this.state.authorSuggestions.includes(b)&&this.state.authorSuggestions.push(b);if(this.state.log={status:"ready",data:{...g,items:[...c?.items??[],...g.items].slice(0,2e3)},error:null},1===a&&g.items[0]){let a=g.items.find(a=>a.oid===this.restoredCommit);this.restoredCommit=null,a?(this.state.selectedCommit=a.oid,this.loadChanges({commit:a.oid},1)):"history"===this.state.mode&&this.selectCommit(g.items[0])}}catch(a){if(!this.current("log",f))return;this.state.log={status:"error",data:c,error:this.error(a)}}this.requests.delete("log"),this.publish()}async loadChanges(a,b,c=!1){let d=this.state.repositoryRoot;if(this.disposed||null===d)return;let e=this.begin("changes"),f=b>1?this.state.changes.data:null;1===b&&this.resetChangeTree(),this.selection=a,this.state.changes={status:"loading",data:f,error:null},this.publish();try{let g=await this.reader.changes(d,{selection:a,page:{index:b,size:200}},e.signal);if(!this.current("changes",e))return;this.changesPage=b;let h=[...f?.items??[],...g.items];this.state.changes={status:"ready",data:{...g,items:h},error:null},this.changeTree=(0,l.OA)(h.map(a=>a.path)),null!==this.restoredChangesScroll&&(this.scroll.changes=this.restoredChangesScroll,this.restoredChangesScroll=null),this.rebuildChangeRows(),this.restoredChangePath&&h.some(a=>a.path===this.restoredChangePath)&&(this.state.selectedChangePath=this.restoredChangePath,this.restoredChangePath=null),this.selection="commit"in a?{commit:g.comparison.target,...g.commit?.selectedParent?{parent:g.commit.selectedParent}:{}}:{base:g.comparison.base,target:g.comparison.target,strategy:a.strategy},c&&"base"in this.selection&&(this.range=this.selection,this.loadLog(1))}catch(a){if(!this.current("changes",e))return;this.state.changes={status:"error",data:f,error:this.error(a)}}this.requests.delete("changes"),this.publish()}resetSelection(){this.restoredCommit=null,this.restoredChangePath=null,this.restoredChangesScroll=null,this.queryTimer&&clearTimeout(this.queryTimer),this.queryTimer=null,this.scroll.log=this.scroll.changes=0,this.cancel("log"),this.cancel("changes"),this.range=null,this.selection=null,this.state.selectedCommit=null,this.state.log=n(),this.state.changes=n(),this.resetChangeTree(),this.clearHistoricalDiff(),this.publish()}resetChangeTree(){this.collapsedDirectories.clear(),this.changeTree=(0,l.OA)([]),this.changeRows=[],this.state.selectedChangePath=null,this.scroll.changes=0}rebuildChangeRows(){let a=Math.floor(this.scroll.changes/36),b=this.changeRows[a],c=this.scroll.changes%36;this.changeRows=(0,l.qV)(this.changeTree,this.collapsedDirectories);let d=b?this.changeRows.findIndex(a=>a.key===b.key):-1;this.scroll.changes=d>=0?36*d+c:Math.min(this.scroll.changes,Math.max(0,(this.changeRows.length-1)*36))}clearHistoricalDiff(){this.files.state.activeDiff?.comparison&&this.files.closeDiff()}begin(a){this.cancel(a);let b=new AbortController;return this.requests.set(a,b),b}cancel(a){this.requests.get(a)?.abort(),this.requests.delete(a)}current(a,b){return!this.disposed&&this.requests.get(a)===b}error(a){return a instanceof Error?a.message:m("historyReadFailed")}publish(){if(!this.disposed)for(let a of(this.revision+=1,this.listeners))a()}}function p(a,b){return(0,e.QL)(a,{path:"/api/pi/directories/list",request:f.FH,response:f.N$},{forceRefresh:!1},b)}function q(a,b,c){return(0,e.QL)(a,{path:"/api/pi/directory-entries/list",request:f.rB,response:f.rn},{cwd:b},c)}function r(a,b,c,f,j,k={}){let l=(0,e.Y4)(a,{cwd:b},k.onUnauthorized),m=new g.h(b,l,{imagePreviewMode:i.Wq,onNotice:c,reveal:(c,e="file")=>(0,d.P)(a,{cwd:b},c,e),maxTabs:20}),n=new h(b,l),p=new o(l,m),q=!1;return{files:m,git:n,history:p,restore(){if(!q&&(q=!0,n.setLayout(b,j.treeLayout),f)){for(let a of(n.setChangesOnly(b,f.changesOnly),f.expandedRepositories))n.toggleRepository(b,a);m.restoreBrowsing(f),p.restoreBrowsing(f.history,!k.lazyHistory)}},dispose(){p.dispose(),n.dispose(),m.dispose()}}}},70448:a=>{a.exports={host:"l4-code-line-markers_host__BBo2H",added:"l4-code-line-markers_added__oTNsK",modified:"l4-code-line-markers_modified__PZnY_",deletedBefore:"l4-code-line-markers_deletedBefore___1b0w",deletedAfter:"l4-code-line-markers_deletedAfter__SEoHy"}},82386:(a,b,c)=>{"use strict";c.d(b,{B3:()=>m,BK:()=>g,R:()=>f,Tr:()=>l,cu:()=>j,dC:()=>k,ix:()=>n});var d=c(51949),e=c(37222);function f(){let a=Number.parseFloat(getComputedStyle(document.documentElement).fontSize)/16;return{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:14*a,lineHeight:Math.round(22*a)}}function g(a){let b=new MutationObserver(()=>a(f()));return b.observe(document.documentElement,{attributes:!0,attributeFilter:["data-pi-desk-display-size"]}),()=>b.disconnect()}let h=null,i=0;function j(){return h||(h=(async()=>{(0,e.fx)()?.locale==="zh-CN"&&await c.e(80880).then(c.t.bind(c,80880,23));let{monaco:a}=await Promise.all([c.e(73691),c.e(20842),c.e(82499)]).then(c.bind(c,82499));return globalThis.MonacoEnvironment={getWorker:(a,b)=>new Worker(new URL(c.p+c.u(354),c.b),{type:void 0,name:b})},a})())}function k(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}function l(a){let b=new MutationObserver(()=>a(k()));return b.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>b.disconnect()}function m(a,b,c){i+=1;let d=b.split("/").map(a=>encodeURIComponent(a)).join("/");return a.Uri.parse(`inmemory://pi-desk/${i}/${c}/${d}`)}function n(a,b){if(b>d.gB)return"plaintext";let c=a.replaceAll("\\","/").split("/").at(-1)?.toLocaleLowerCase()??"";return"dockerfile"===c?"dockerfile":"makefile"===c?"plaintext":({bat:"bat",c:"c",cc:"cpp",cjs:"javascript",cpp:"cpp",cs:"csharp",css:"css",dockerfile:"dockerfile",go:"go",h:"cpp",hpp:"cpp",htm:"html",html:"html",ini:"ini",java:"java",js:"javascript",json:"javascript",jsonl:"javascript",jsx:"javascript",kt:"kotlin",less:"less",lua:"lua",md:"markdown",mdx:"markdown",mjs:"javascript",php:"php",ps1:"powershell",py:"python",rb:"ruby",rs:"rust",scss:"scss",sh:"shell",sql:"sql",swift:"swift",toml:"ini",ts:"typescript",tsx:"typescript",txt:"plaintext",xml:"xml",yaml:"yaml",yml:"yaml"})[c.includes(".")?c.split(".").at(-1)??"":""]??"plaintext"}},82563:(a,b,c)=>{"use strict";c.d(b,{Ke:()=>j,Nt:()=>h,R6:()=>i});var d=c(52834),e=c(33023),f=c(42500),g=c(91047);function h({...a}){return(0,d.jsx)(e.N,{"data-slot":"collapsible",...a})}function i({...a}){return(0,d.jsx)(f.R,{"data-slot":"collapsible-trigger",...a})}function j({...a}){return(0,d.jsx)(g.j,{"data-slot":"collapsible-content",...a})}},82589:(a,b,c)=>{"use strict";c.d(b,{b:()=>l});var d=c(52834),e=c(99451),f=c(49147),g=c(57850),h=c(5319),i=c(9860),j=c(42704),k=c(15620);function l({value:a,options:b,onChange:c,ariaLabel:m,placeholder:n,searchPlaceholder:o,emptyText:p,disabled:q=!1,className:r}){let{t:s}=(0,g.Bd)("common"),[t,u]=(0,f.useState)(!1),v=b.find(b=>b.value===a);return(0,d.jsxs)(j.AM,{open:t,onOpenChange:u,children:[(0,d.jsx)(j.Wv,{render:(0,d.jsxs)(h.$,{type:"button",variant:"outline",role:"combobox","aria-label":m,"aria-expanded":t,disabled:q,className:(0,k.cn)("w-full min-w-0 justify-between border-input px-2.5 font-normal focus-visible:-outline-offset-2",r),children:[(0,d.jsx)("span",{className:(0,k.cn)("min-w-0 truncate",!v&&"text-muted-foreground"),children:v?.label??n??s("selectPlaceholder")}),(0,d.jsx)(e.A,{className:"text-muted-foreground"})]})}),(0,d.jsx)(j.hl,{align:"start",sideOffset:4,positionerClassName:"z-[120]",className:"w-(--anchor-width) max-w-[calc(100vw-2rem)] gap-0 p-0",children:(0,d.jsxs)(i.uB,{children:[(0,d.jsx)(i.G7,{placeholder:o??s("searchPlaceholder"),autoFocus:!0}),(0,d.jsxs)(i.oI,{className:"max-h-[min(20rem,var(--available-height))]",children:[(0,d.jsx)(i.xL,{children:p??s("noMatches")}),(0,d.jsx)(i.L$,{children:b.map(b=>(0,d.jsx)(i.h_,{value:`${b.label} ${b.description??""} ${b.value}`,"data-checked":b.value===a?"true":void 0,onSelect:()=>{c(b.value),u(!1)},children:(0,d.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,d.jsx)("span",{className:"block truncate",children:b.label}),b.description?(0,d.jsx)("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:b.description}):null]})},b.value))})]})]})})]})}},83731:(a,b,c)=>{"use strict";function d(a,b){return`${a}:${b}`}function e(a,b){return a?`${a}/${b}`:b}function f(a,b){return a.localeCompare(b,void 0,{numeric:!0,sensitivity:"base"})}function g(a,b,c=new Set){let d=[a],e=a;for(;!c.has(e);){let a=b(e);if(!a||c.has(a)||!a.startsWith(`${e}/`))break;d.push(a),e=a}return{path:a,targetPath:e,paths:d,label:e.slice(a.lastIndexOf("/")+1)}}function h(a,b=""){let c={path:b,directories:new Map,files:[]},d=new Map([[b,c]]);for(let f of a){let a=(b?f.slice(b.length+1):f).split("/"),g=c;for(let b of a.slice(0,-1)){let a=e(g.path,b),c=d.get(a);c||(c={path:a,directories:new Map,files:[]},d.set(a,c),g.directories.set(a,c)),g=c}g.files.push(f)}return d}function i(a,b,c){return g(a,a=>{let c=b.get(a);return c&&0===c.files.length&&1===c.directories.size?c.directories.keys().next().value??null:null},c)}function j(a,b,c=""){let e=[],g=(c,h)=>{let j=a.get(c);if(j){for(let c of[...j.directories.keys()].sort(f)){let f=i(c,a),j=!f.paths.some(a=>b.has(a));e.push({key:d("directory",c),type:"directory",path:f.targetPath,label:f.label,depth:h,directory:f,expanded:j}),j&&g(f.targetPath,h+1)}for(let a of[...j.files].sort(f))e.push({key:d("file",a),type:"file",path:a,label:a.slice(a.lastIndexOf("/")+1),depth:h})}};return g(c,0),e}c.d(b,{Im:()=>d,Kn:()=>f,OA:()=>h,_J:()=>e,qV:()=>j,rk:()=>g,xV:()=>i})},85544:(a,b,c)=>{"use strict";c.d(b,{k:()=>h});var d=c(52834);c(84593);var e=c(49147),f=c(15620),g=c(4998);function h(a){let{locale:b}=(0,g.i)(),{slides:c,index:h=0,onIndexChange:i,className:j,thumbnails:k=!0,ariaLabel:l="en"===b?"Image preview":"图片预览"}=a,m="inline"===a.mode,n="inline"===a.mode||a.open,o="modal"===a.mode?a.onClose:void 0;c.length;let p=Math.min(Math.max(h,0),Math.max(c.length-1,0)),q=`pi-desk-image-viewer-${(0,e.useId)().replaceAll(":","")}`,r=(0,e.useRef)(null),s=(0,e.useRef)(null),t=(0,e.useRef)(null);if((0,e.useRef)(""),(0,e.useRef)(""),(0,e.useRef)(p),(0,e.useRef)(p),(0,e.useRef)(i),(0,e.useRef)(o),(0,e.useMemo)(()=>JSON.stringify(c.map(a=>[a.src,a.alt])),[c]),(0,f.cn)("pi-desk-image-viewer",m?"pi-desk-image-viewer-inline":"pi-desk-image-viewer-modal",q,j),0===c.length||!n)return null;let u=(0,d.jsx)("span",{ref:r,className:"pi-desk-image-viewer-source","aria-hidden":"true",children:c.map((a,b)=>(0,d.jsx)("img",{src:a.src,alt:a.alt,width:a.width,height:a.height,decoding:"async",draggable:!1},b))});return m?(0,d.jsx)("div",{ref:s,className:"pi-desk-image-viewer-host",role:"region","aria-label":l,tabIndex:0,onKeyDown:a=>{let b=t.current;!b||b.fulled||a.altKey||a.ctrlKey||a.metaKey||a.nativeEvent.isComposing||("ArrowLeft"===a.key||"ArrowRight"===a.key)&&(a.preventDefault(),a.stopPropagation(),"ArrowLeft"===a.key?b.prev(!1):b.next(!1))},children:u}):u}},87348:(a,b,c)=>{"use strict";c.d(b,{e:()=>k});var d=c(52834),e=c(90814),f=c(49147),g=c(57850);c(82386),c(51972);var h=c(96478),i=c(70448),j=c.n(i);let k=(0,f.forwardRef)(function({path:a,content:b,size:c,savedState:i,onSaveState:k,onEscape:l,originalContent:m,onChanges:n,onOpenDiff:o,navigation:p,onNavigation:q},r){let{t:s}=(0,g.Bd)("common"),{t:t}=(0,g.Bd)("projectFiles"),{wrapLines:u}=(0,h.TX)(),v=(0,f.useRef)(null),w=(0,f.useRef)(null);(0,f.useRef)(k),(0,f.useRef)(u),(0,f.useRef)(i),(0,f.useRef)(l);let x=(0,f.useRef)(null);(0,f.useRef)(n),(0,f.useRef)(o),(0,f.useRef)(q);let y=(0,f.useRef)(null),z=(0,f.useRef)(null);(0,f.useCallback)(a=>{let b=z.current;y.current?.clear(),null===b||b>(a.getModel()?.getLineCount()??0)||(y.current??=a.createDecorationsCollection(),y.current.set([{range:{startLineNumber:b,startColumn:1,endLineNumber:b,endColumn:1},options:{isWholeLine:!0,className:"bg-accent"}}]))},[]);let[A,B]=(0,f.useState)("loading");return(0,f.useImperativeHandle)(r,()=>({openSearch(){w.current?.getAction("actions.find")?.run()},gotoLine(){w.current?.getAction("editor.action.gotoLine")?.run()},getSelectionText(){let a=w.current,b=a?.getModel(),c=a?.getSelection();return b&&c&&!c.isEmpty()?b.getValueInRange(c):""},getViewState:()=>w.current?.saveViewState()??null,focus(){w.current?.focus()},previousChange(){x.current?.previousChange()},nextChange(){x.current?.nextChange()}}),[]),(0,d.jsxs)("div",{"data-testid":"code-preview",className:"relative h-full min-h-0 w-full overflow-hidden bg-background",children:[(0,d.jsx)("div",{ref:v,className:`size-full ${j().host}`}),"loading"===A?(0,d.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 bg-background text-sm text-muted-foreground",children:[(0,d.jsx)(e.A,{className:"size-4 animate-spin"})," ",s("codeLoading")]}):null,"error"===A?(0,d.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center text-sm text-destructive",children:s("codeFailed")}):null]})})},89101:(a,b,c)=>{"use strict";c.d(b,{Ik:()=>n,MG:()=>j,Sq:()=>l,iV:()=>o,oR:()=>p});var d=c(52834);c(49147);var e=c(80546),f=c(15620),g=c(5319),h=c(11071),i=c(13221);function j({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"input-group",role:"group",className:(0,f.cn)("group/input-group relative flex min-h-8 w-full min-w-0 items-center rounded-lg border border-input bg-card transition-colors duration-150 outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-muted has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:outline-2 has-[[data-slot=input-group-control]:focus-visible]:outline-solid has-[[data-slot=input-group-control]:focus-visible]:-outline-offset-2 has-[[data-slot=input-group-control]:focus-visible]:outline-ring has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",a),...b})}let k=(0,e.F)("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function l({className:a,align:b="inline-start",...c}){return(0,d.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":b,className:(0,f.cn)(k({align:b}),a),onClick:a=>{a.target.closest("button")||a.currentTarget.parentElement?.querySelector("input")?.focus()},...c})}let m=(0,e.F)("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"min-h-7 gap-2 rounded-md px-2",sm:"","icon-xs":"size-7 rounded-md p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function n({className:a,type:b="button",variant:c="ghost",size:e="xs",...h}){return(0,d.jsx)(g.$,{type:b,"data-size":e,variant:c,className:(0,f.cn)(m({size:e}),a),...h})}function o({className:a,...b}){return(0,d.jsx)(h.p,{"data-slot":"input-group-control",className:(0,f.cn)("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:outline-none focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0",a),...b})}function p({className:a,...b}){return(0,d.jsx)(i.T,{"data-slot":"input-group-control",className:(0,f.cn)("flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:outline-none focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0",a),...b})}},91464:(a,b,c)=>{"use strict";c.d(b,{S6:()=>d,dQ:()=>e,hD:()=>f});let d="relative flex min-h-7 cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-sm leading-5 outline-none select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e="data-[variant=destructive]:text-destructive data-[variant=destructive]:data-highlighted:bg-destructive/10 data-[variant=destructive]:data-highlighted:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive",f="z-50 max-h-(--available-height) min-w-60 max-w-[calc(100vw-2rem)] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-md outline-none transition-[opacity,transform] duration-100 ease-out data-starting-style:scale-[0.98] data-starting-style:opacity-0 data-ending-style:scale-[0.98] data-ending-style:opacity-0 motion-reduce:transition-none"},91816:(a,b,c)=>{"use strict";c.d(b,{Ip:()=>q,JW:()=>o,K5:()=>s,Rc:()=>p,kt:()=>r,tz:()=>n});var d=c(52834);c(49147);var e=c(49067),f=c(10962),g=c(48329),h=c(65614),i=c(9698),j=c(16484),k=c(36089),l=c(15620),m=c(91464);function n({...a}){return(0,d.jsx)(e.D,{"data-slot":"context-menu",...a})}function o({...a}){return(0,d.jsx)(f.g,{"data-slot":"context-menu-portal",...a})}function p({className:a,...b}){return(0,d.jsx)(g.R,{"data-slot":"context-menu-trigger",className:(0,l.cn)("select-none",a),...b})}function q({className:a,align:b="start",alignOffset:c=4,side:e="right",sideOffset:g=0,finalFocus:j=!1,...k}){return(0,d.jsx)(f.g,{children:(0,d.jsx)(h.y,{className:"isolate z-50 outline-none",align:b,alignOffset:c,side:e,sideOffset:g,children:(0,d.jsx)(i._,{"data-slot":"context-menu-content",finalFocus:j,className:(0,l.cn)(m.hD,a),...k})})})}function r({className:a,inset:b,variant:c="default",...e}){return(0,d.jsx)(j.D,{"data-slot":"context-menu-item","data-inset":b,"data-variant":c,className:(0,l.cn)(m.S6,m.dQ,"group/context-menu-item",a),...e})}function s({className:a,...b}){return(0,d.jsx)(k.w,{"data-slot":"context-menu-separator",className:(0,l.cn)("-mx-1 my-1 h-px bg-border",a),...b})}},92494:(a,b,c)=>{"use strict";c.d(b,{h:()=>o});var d=c(89172),e=c(21850),f=c(28661),g=c(96478),h=c(95186),i=c(55091),j=c(83731);let k={scope:"all",caseSensitive:!1,wholeWord:!1,regex:!1};function l(a){return{...a,status:a.query.trim()?"loading":"idle",fileMatches:[],contentMatches:[],truncated:!1,error:null}}function m(a,b){return(0,e.B)({msg:d.C["zh-CN"][a],i18n:{key:`projectFiles:${a}`,...b?{params:b}:{}}})}function n(a){return a instanceof Error?a.message:m("projectReadFailed")}class o{constructor(a,b,c){this.cwd=a,this.reader=b,this.options=c,this.state={tabs:[],activePath:null,directories:new Map,expandedPaths:new Set,treeScrollTop:0,search:l({query:"",...k}),searchOpen:!1,documents:new Map,activeDiff:null},this.listeners=new Set,this.directoryRequests=new Map,this.compactRequests=new Map,this.documentRequests=new Map,this.closeMissing=new Set,this.restoredTabs=new Set,this.restoredEditorStates=new Map,this.restoredFileViewModes=new Map,this.restoredPreviewScrollTops=new Map,this.searchRequest=null,this.navigation=null,this.diffRequest=null,this.revision=0,this.disposed=!1,this.subscribe=a=>(this.listeners.add(a),()=>this.listeners.delete(a)),this.getRevision=()=>this.revision}setSearchOpen(a){this.disposed||this.state.searchOpen===a||(this.cancelSearch(),this.state.searchOpen=a,this.state.search=l({...this.searchInput(),scope:a?"all":this.state.search.scope}),this.publish())}get pendingNavigation(){let a=this.state.activePath;return a&&!this.documentRequests.has(a)?this.navigation:null}consumeNavigation(a,b){this.navigation===a&&(this.navigation=null,b||this.options.onNotice?.(m("searchLineUnavailable")),this.publish())}get canReveal(){return!!this.options.reveal}getBrowsingDocumentSettings(){let a={},b={};for(let c of this.state.tabs){let d=this.state.documents.get(c),e=d?.status==="text"?d.editorState:this.restoredEditorStates.get(c);e&&JSON.stringify(e).length<32768&&(a[c]=e);let f=d?.status==="text"?d.viewMode:this.restoredFileViewModes.get(c);f&&(b[c]=f)}return{editorStates:a,fileViewModes:b}}restoreBrowsing(a){for(let b of(this.state.tabs=[...a.tabs],a.tabs)){this.restoredTabs.add(b);let c=a.editorStates[b];c&&this.restoredEditorStates.set(b,c);let d=a.fileViewModes[b];d&&this.restoredFileViewModes.set(b,d)}for(let b of(this.state.activePath=a.activePath&&a.tabs.includes(a.activePath)?a.activePath:null,this.state.expandedPaths=new Set(a.expandedPaths),this.state.treeScrollTop=a.treeScrollTop,this.state.search=l({query:a.searchQuery,...k}),a.tabs))this.state.documents.set(b,{status:"unloaded"});for(let b of a.expandedPaths)this.ensureDirectory(b);a.activeDiff?this.openDiff(a.activeDiff.repositoryRoot,a.activeDiff.path,a.activeDiff.comparison):this.state.activePath&&this.ensureDocument(this.state.activePath)}async revealFile(a,b="file"){if(!this.options.reveal)throw Error(m("revealUnavailable"));await this.options.reveal(a,b)}ensureRoot(){return this.ensureDirectory("")}ensureDirectory(a){if(this.disposed||this.state.directories.get(a)?.status==="ready")return Promise.resolve();let b=this.directoryRequests.get(a);if(b)return b.promise;let c=new AbortController,d=Promise.resolve().then(async()=>{try{if(c.signal.aborted)return;let b=await this.reader.list(a,c.signal);if(this.directoryRequests.get(a)?.controller!==c)return;this.state.directories.set(a,{status:"ready",...b})}catch(b){if(this.directoryRequests.get(a)?.controller!==c)return;this.state.directories.set(a,{status:"error",error:n(b)})}this.directoryRequests.get(a)?.controller===c&&(this.directoryRequests.delete(a),this.publish())});return this.directoryRequests.set(a,{controller:c,promise:d}),this.state.directories.set(a,{status:"loading"}),this.publish(),d}setExpandedPaths(a,b=!0){let c=[...this.state.expandedPaths].filter(b=>!a.has(b));for(let b of(this.state.expandedPaths=new Set(a),this.compactRequests.keys()))c.some(a=>b===a||b.startsWith(`${a}/`))&&this.compactRequests.delete(b);if(this.publish(),b)for(let b of a)this.ensureDirectory(b)}cancelDirectoryExpansion(a=""){for(let b of this.compactRequests.keys())(!a||b===a||b.startsWith(`${a}/`))&&this.compactRequests.delete(b)}compactDirectory(a,b){return(0,j.rk)(a,a=>{let b=this.onlyDirectory(a);return b&&this.state.directories.has(b)?b:null},b)}async expandDirectoryChain(a,b){let c={};this.compactRequests.set(a,c);let d=a,e=16;for(;!this.disposed&&this.compactRequests.get(a)===c&&this.state.expandedPaths.has(a);){if(this.state.directories.get(d)?.status!=="ready"){if(e--<=0)break;await this.ensureDirectory(d)}if(this.compactRequests.get(a)!==c||this.disposed)return;let f=this.onlyDirectory(d);if(!f||b.has(d)||b.has(f)||e<=0&&this.state.directories.get(f)?.status!=="ready")break;this.state.expandedPaths.add(f),d=f,this.publish()}this.compactRequests.get(a)===c&&this.compactRequests.delete(a)}onlyDirectory(a){let b=this.state.directories.get(a);if(b?.status!=="ready"||b.truncated||1!==b.entries.length)return null;let c=b.entries[0];return"directory"===c.type?(0,j._J)(a,c.name):null}setTreeScrollTop(a){this.state.treeScrollTop=a}refreshTree(){for(let a of(this.compactRequests.clear(),this.directoryRequests.values()))a.controller.abort();this.directoryRequests.clear(),this.state.directories.clear(),this.cancelSearch(),this.state.search=l(this.searchInput()),this.publish(),this.ensureRoot().then(()=>{if(!this.disposed){for(let a of this.state.expandedPaths)this.ensureDirectory(a);this.state.searchOpen&&this.state.search.query.trim()&&(this.cancelSearch(),this.state.search={...this.state.search,status:"loading"},this.search(this.state.search.query))}})}setSearchQuery(a){this.disposed||this.state.search.query===a||(this.cancelSearch(),this.state.search=l({...this.searchInput(),query:a}),this.publish())}setSearchOptions(a){if(this.disposed)return;let b=this.searchInput(),c={...b,...a};(c.scope!==b.scope||c.caseSensitive!==b.caseSensitive||c.wholeWord!==b.wholeWord||c.regex!==b.regex)&&(this.cancelSearch(),this.state.search=l(c),this.publish(),this.state.searchOpen&&this.search(c.query))}searchInput(){let{query:a,scope:b,caseSensitive:c,wholeWord:d,regex:e}=this.state.search;return{query:a,scope:b,caseSensitive:c,wholeWord:d,regex:e}}async search(a){if(this.disposed||!a.trim()||this.state.search.query!==a||"ready"===this.state.search.status||this.searchRequest)return;let b=new AbortController;this.searchRequest=b;let c=this.searchInput();this.state.search=l(c),this.publish();try{let a=await this.reader.search(c,b.signal);if(this.searchRequest!==b)return;this.state.search={...c,status:"ready",...a,error:null}}catch(a){if(this.searchRequest!==b)return;this.state.search={...l(c),status:"error",error:n(a)}}this.searchRequest===b&&(this.searchRequest=null,this.publish())}openFile(a,b){var c;let d,e;if(this.disposed)return;let f=(c=this.cwd,d=a.replaceAll("\\","/"),e=`${c.replaceAll("\\","/").replace(/\/+$/,"")}/`,(/^[a-z]:\//i.test(e)||e.startsWith("//")?d.toLowerCase().startsWith(e.toLowerCase()):d.startsWith(e))?d.slice(e.length):d),g=/^[a-z]:[\\/]/i.test(this.cwd)||this.cwd.startsWith("\\\\")?this.state.tabs.find(a=>a.toLowerCase()===f.toLowerCase())??f:f;if(!this.state.tabs.includes(g)){if(this.options.maxTabs&&this.state.tabs.length>=this.options.maxTabs)return void this.options.onNotice?.(m("maxOpenFiles",{count:this.options.maxTabs}));this.state.tabs.push(g)}this.clearDiff(),this.state.documents.has(g)||this.state.documents.set(g,{status:"unloaded"}),this.state.activePath=g,this.navigation=void 0===b?null:{line:b};let h=this.state.documents.get(g);void 0!==b&&h?.status==="text"&&(h.viewMode="source"),this.ensureDocument(g,void 0!==b),this.publish()}closeTabs(a,b){let c=this.state,d=[...c.tabs,...c.activeDiff?[null]:[]],e=d.indexOf(a);if(e<0&&"all"!==b)return;let f=new Set(d.filter((c,d)=>"all"===b||("current"===b?c===a:"others"===b?c!==a:"left"===b?d<e:d>e)));if(!f.size)return;let g=c.activeDiff?null:c.activePath;for(let a of f){if(null===a){this.clearDiff();continue}this.documentRequests.get(a)?.abort(),this.documentRequests.delete(a),this.releaseDocument(c.documents.get(a)),c.documents.delete(a),this.restoredEditorStates.delete(a),this.restoredFileViewModes.delete(a),this.restoredPreviewScrollTops.delete(a),this.closeMissing.delete(a),this.restoredTabs.delete(a)}if(c.tabs=c.tabs.filter(a=>!f.has(a)),c.activePath&&f.has(c.activePath)){this.navigation=null;let a=d.indexOf(c.activePath);c.activePath=d.slice(a+1).find(a=>null!==a&&!f.has(a))??d.slice(0,a).reverse().find(a=>null!==a&&!f.has(a))??null}this.publish(),!c.activeDiff&&c.activePath&&g!==c.activePath&&this.ensureDocument(c.activePath)}reloadFile(a){if(this.state.tabs.includes(a)){if(this.state.activePath===a&&this.navigation)return void this.ensureDocument(a,!0);this.invalidateDocument(a),this.publish(),this.ensureDocument(a)}}async ensureDocument(a,b=!1){if(this.disposed||!this.state.tabs.includes(a)||this.documentRequests.has(a))return;let c=this.state.documents.get(a);if(!b&&c&&["loading","text","image"].includes(c.status))return;let d=new AbortController;this.documentRequests.set(a,d),c?.status!=="text"&&this.state.documents.set(a,{status:"loading"}),this.publish();try{let b=await this.reader.get(a,this.options.imagePreviewMode(),d.signal);if(this.documentRequests.get(a)!==d)return;this.documentRequests.delete(a),this.closeMissing.delete(a),this.restoredTabs.delete(a),(c?.status!=="text"||"text"!==b.kind||c.content!==b.content||c.size!==b.size)&&this.state.documents.set(a,"text"===b.kind?{status:"text",content:b.content,size:b.size,editorState:c?.status==="text"?c.editorState:this.restoredEditorStates.get(a)??null,viewMode:this.state.activePath===a&&this.navigation?"source":c?.status==="text"?c.viewMode:this.restoredFileViewModes.get(a)??("markdown"===(0,i.g)(a)||this.options.htmlPreview&&"html"===(0,i.g)(a)?"preview":"source"),previewScrollTop:c?.status==="text"?c.previewScrollTop:this.restoredPreviewScrollTops.get(a)??0}:{status:"image",mimeType:b.mimeType,size:b.size,objectUrl:URL.createObjectURL((0,f.E)(b))}),this.state.activePath===a&&"text"!==b.kind&&(this.navigation=null),this.releaseDocument(c)}catch(f){if(this.documentRequests.get(a)!==d)return;this.documentRequests.delete(a);let b=this.restoredTabs.delete(a),e=this.closeMissing.delete(a);if((b||e)&&f instanceof h.aw&&404===f.status&&"errors:fileMissing"===f.errorKey){this.closeTabs(a,"current"),e&&this.options.onNotice?.(m("branchFileClosed",{path:a}));return}console.warn("[Pi Desk][ProjectFile] 读取文件失败",{cwd:this.cwd,path:a,error:n(f)}),this.state.documents.set(a,{status:"error",error:n(f)}),this.releaseDocument(c),this.state.activePath===a&&(this.navigation=null)}this.publish()}async compareFile(a,b,c){let d=this.state.documents.get(a);if(this.disposed||c.aborted||d?.status!=="text")return;if(!b){d.comparison&&(delete d.comparison,this.publish());return}let e={status:"loading"};d.comparison=e,this.publish();let f=()=>!this.disposed&&!c.aborted&&this.state.documents.get(a)===d&&d.comparison===e;try{let a=await this.reader.diff(b.repositoryRoot,b.path,c);if(!f())return;"text"===a.kind?(d.content=a.modified.content,d.size=new TextEncoder().encode(a.modified.content).length,d.comparison={status:"ready",repositoryRoot:b.repositoryRoot,path:b.path,original:a.original}):d.comparison={status:"unavailable"}}catch(b){if(!f())return;console.warn("[Pi Desk][ProjectFile] 读取行变更失败",{cwd:this.cwd,path:a,error:n(b)}),d.comparison={status:"error",error:n(b)}}this.publish()}openFileDiff(a,b){let c=this.state.documents.get(a);if(this.disposed||c?.status!=="text"||c.comparison?.status!=="ready")return;let d=c.comparison;this.clearDiff(),this.state.activeDiff={status:"text",repositoryRoot:d.repositoryRoot,path:d.path,original:d.original,modified:{path:d.path,content:c.content},initialLine:b},this.publish()}openDiff(a,b,c,d){this.disposed||(this.clearDiff(),this.state.activeDiff={status:"loading",repositoryRoot:a,path:b,comparison:c,label:d},this.publish(),this.ensureDiff())}closeDiff(){this.closeTabs(null,"current")}reloadDiff(){let a=this.state.activeDiff;a&&(this.clearDiff(),this.state.activeDiff={...a,status:"loading"},this.publish(),this.ensureDiff())}saveDiffState(a,b){this.state.activeDiff===a&&(a.editorState=b)}setDiffViewMode(a){this.state.activeDiff&&(0,g.ZQ)({diffViewMode:a})}setDiffWrapLines(a){this.state.activeDiff&&(0,g.ZQ)({wrapLines:a})}setDiffCollapseUnchanged(a){this.state.activeDiff&&(0,g.ZQ)({collapseUnchanged:a})}handleGitBranchChanged(a){for(let b of(this.refreshTree(),this.state.tabs))(!a||b===a||b.startsWith(`${a}/`))&&(this.invalidateDocument(b),this.closeMissing.add(b));this.state.activeDiff?.repositoryRoot===a?this.reloadDiff():this.publish(),!this.state.activeDiff&&this.state.activePath&&this.ensureDocument(this.state.activePath)}saveEditorState(a,b){let c=this.state.documents.get(a);c?.status==="text"&&(c.editorState=b)}savePreviewScrollTop(a,b){let c=this.state.documents.get(a);c?.status==="text"&&(c.previewScrollTop=b)}setWrapLines(a,b){this.state.documents.get(a)?.status==="text"&&(0,g.ZQ)({wrapLines:b})}setTextViewMode(a,b){let c=this.state.documents.get(a);c?.status==="text"&&c.viewMode!==b&&(c.viewMode=b,this.publish())}dispose(){for(let a of(this.disposed=!0,this.compactRequests.clear(),this.directoryRequests.values()))a.controller.abort();for(let a of(this.directoryRequests.clear(),this.documentRequests.values()))a.abort();for(let a of(this.documentRequests.clear(),this.cancelSearch(),this.clearDiff(),this.state.documents.values()))this.releaseDocument(a);this.state.documents.clear(),this.restoredPreviewScrollTops.clear(),this.listeners.clear()}async ensureDiff(){let a=this.state.activeDiff;if(this.disposed||a?.status!=="loading"||this.diffRequest)return;let b=new AbortController;this.diffRequest=b;try{let c=await this.reader.diff(a.repositoryRoot,a.path,b.signal,a.comparison);if(this.diffRequest!==b)return;this.state.activeDiff="text"===c.kind?{...a,status:"text",original:c.original,modified:c.modified}:"metadata"===c.kind?{...a,status:"metadata",originalMetadata:c.original,modifiedMetadata:c.modified}:{...a,status:c.kind,error:null}}catch(c){if(this.diffRequest!==b)return;this.state.activeDiff={...a,status:"error",error:n(c)}}this.diffRequest===b&&(this.diffRequest=null,this.publish())}clearDiff(){this.navigation=null,this.diffRequest?.abort(),this.diffRequest=null,this.state.activeDiff=null}cancelSearch(){this.searchRequest?.abort(),this.searchRequest=null}invalidateDocument(a){this.state.activePath===a&&(this.navigation=null),this.documentRequests.get(a)?.abort(),this.documentRequests.delete(a);let b=this.state.documents.get(a);b?.status==="text"&&(b.editorState&&this.restoredEditorStates.set(a,b.editorState),this.restoredFileViewModes.set(a,b.viewMode),this.restoredPreviewScrollTops.set(a,b.previewScrollTop)),this.releaseDocument(b),this.state.documents.set(a,{status:"unloaded"})}releaseDocument(a){a?.status==="image"&&URL.revokeObjectURL(a.objectUrl)}publish(){if(!this.disposed)for(let a of(this.revision+=1,this.listeners))a()}}},93306:(a,b,c)=>{"use strict";c.d(b,{x:()=>e});var d=c(97563);function e(a){return(0,d.h3)(a)}},95186:(a,b,c)=>{"use strict";c.d(b,{QL:()=>g,Y4:()=>h,aw:()=>f});var d=c(21850),e=c(17983);class f extends Error{constructor(a,b,c,d=null){super(c),this.status=a,this.code=b,this.errorKey=d,this.name="L3ProjectRequestError"}}async function g(a,b,c,e){let g=await fetch(b.path,{method:"POST",headers:{"Content-Type":"application/json","X-Pi-Desk-Client-Id":a},body:JSON.stringify(b.request.parse(c)),signal:e}),h=await g.json();if(!g.ok||0!==h.code||null===h.data)throw new f(g.status,h.code,h.msg?(0,d.B)(h):"项目读取失败",h.i18n?.key??null);return b.response.parse(h.data)}function h(a,b,c){async function d(b,d,e){try{return await g(a,b,d,e)}catch(a){throw!e?.aborted&&a instanceof f&&401===a.status&&c?.(),a}}return{list:(a,c)=>d(e.Xe,{...b,path:a},c),search:(a,c)=>d(e.fg,{...b,...a},c),get:(a,c,f)=>d(e.ZI,{...b,path:a,imagePreviewMode:c},f),snapshot:(a,c)=>d(e.p0,{...b,refresh:c},a),branches:(a,c)=>d(e.ry,{...b,repositoryRoot:a},c),log:(a,c,f)=>d(e.p3,{...b,repositoryRoot:a,...c},f),changes:(a,c,f)=>d(e.ys,{...b,repositoryRoot:a,...c},f),diff:(a,c,f,g)=>d(e.OC,{...b,repositoryRoot:a,path:c,comparison:g},f)}}},95198:(a,b,c)=>{"use strict";c.d(b,{q:()=>ap});var d=c(52834),e=c(57850),f=c(35385),g=c(46505),h=c(34911),i=c(38721),j=c(22207),k=c(79918),l=c(39620),m=c(9665),n=c(97586),o=c(84912),p=c(37096),q=c(5319),r=c(45741),s=c(32772),t=c(9913),u=c(87366),v=c(49147),w=c(15620),x=c(91816),y=c(60819),z=c(49057);let A=[{scope:"current",label:"closeTab"},{scope:"others",label:"closeOtherTabs"},{scope:"right",label:"closeRightTabs"},{scope:"left",label:"closeLeftTabs"},{scope:"all",label:"closeAllTabs"}];function B(a,b){let c=a.replaceAll("\\","/").split("/"),d=c.at(-1)??a;return b.some(b=>b!==a&&b.split("/").at(-1)===d)&&c.length>1?c.slice(-2).join("/"):d}function C({cwd:a,gitRuntime:b,paths:c,activePath:f,diffPath:g,mobile:h,onActivate:i,onClose:j}){let{t:k}=(0,e.Bd)("projectFiles");(0,v.useSyncExternalStore)(b.subscribe,b.getRevision,b.getRevision);let l=b.getWorkspace(a)?.snapshot,m=(0,v.useRef)(null),o=(0,v.useRef)(!1),[p,r]=(0,v.useState)(!1),[D,E]=(0,v.useState)(!1),[F,G]=(0,v.useState)([]),H=c.map(a=>({path:a,label:B(a,c),title:a}));g&&H.push({path:null,label:`${B(g,c)} \xb7 Diff`,title:g});let I=g?null:f;return 0===H.length?null:(0,d.jsxs)("div",{className:"shrink-0 border-b bg-muted","data-testid":"file-tabs",children:[(0,d.jsx)("div",{className:"overflow-hidden",style:{maxHeight:p?void 0:(h?2:3)*36},children:(0,d.jsx)("div",{ref:m,role:"tablist","aria-label":k("openFiles"),className:"relative flex flex-wrap content-start items-start",children:H.map((b,c)=>{let e=!p&&F.includes(c),f=b.path===I,g=b.path&&l?.status==="ready"?(0,z.lN)(a,b.path,l.repositories)?.change:void 0,t=null===b.path?k("closeDiff",{name:b.title.split("/").at(-1)}):k("closeFile",{name:b.title.split("/").at(-1)});return(0,d.jsxs)(x.tz,{onOpenChange:(a,b)=>{a&&"pointerType"in b.event&&"touch"===b.event.pointerType&&(o.current=!0)},children:[(0,d.jsxs)(x.Rc,{render:(0,d.jsx)("div",{"data-file-tab":!0,"data-testid":null===b.path?`file-diff-tab-${b.title}`:`file-tab-${b.path}`,"aria-hidden":e||void 0,inert:e||void 0,title:b.title,className:(0,w.cn)("flex h-9 max-w-full items-center border-r border-b text-sm",h?"w-[min(50%,12rem)]":"max-w-60",e&&"invisible",f?"bg-background text-foreground shadow-[inset_0_-2px_0_var(--primary)]":"text-muted-foreground"),onPointerDown:a=>{"touch"===a.pointerType&&(o.current=!1)}}),children:[(0,d.jsxs)("button",{type:"button",role:"tab","aria-selected":f,className:"flex h-9 min-w-0 flex-1 cursor-pointer items-center gap-2 pl-3 pr-1 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:()=>{if(o.current){o.current=!1;return}null!==b.path&&i(b.path)},onKeyDown:a=>{if("F10"===a.key&&a.shiftKey){a.preventDefault(),a.stopPropagation();let b=a.currentTarget.closest('[data-slot="context-menu-trigger"]');if(b){let a=b.getBoundingClientRect();b.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:a.left+a.width/2,clientY:a.top+a.height/2}))}return}let b="ArrowRight"===a.key||"ArrowDown"===a.key?1:"ArrowLeft"===a.key||"ArrowUp"===a.key?-1:0;if(!b)return;a.preventDefault();let d=(c+b+H.length)%H.length;r(!0);let e=m.current?.querySelectorAll('[role="tab"]');e?.[d]?.focus({preventScroll:!0})},children:[(0,d.jsx)(n.A,{className:"size-3.5 shrink-0"}),(0,d.jsx)("span",{className:(0,w.cn)("truncate",g&&(0,z.iH)(g)),children:b.label}),g?(0,d.jsx)("span",{className:(0,w.cn)("shrink-0 text-xs",(0,z.iH)(g)),"aria-label":k("gitStatus",{status:(0,z.XB)(g)}),children:(0,z.XB)(g)}):null]}),(0,d.jsx)(q.$,{variant:"ghost",size:"icon","data-testid":null===b.path?`file-diff-tab-close-${b.title}`:`file-tab-close-${b.path}`,"aria-label":t,onClick:a=>{if(a.stopPropagation(),o.current){o.current=!1;return}j(b.path,"current")},children:(0,d.jsx)(s.A,{className:"size-3.5"})})]}),(0,d.jsx)(y.D,{children:A.map(({scope:a,label:e})=>(0,d.jsxs)("span",{children:["all"===a?(0,d.jsx)(x.K5,{}):null,(0,d.jsx)(x.kt,{disabled:"others"===a?H.length<=1:"left"===a?0===c:"right"===a&&c===H.length-1,onClick:()=>{o.current=!1,j(b.path,a)},children:k(e)})]},a))})]},b.path??"diff")})})}),D?(0,d.jsxs)(q.$,{variant:"ghost",className:"w-full rounded-none text-muted-foreground","aria-expanded":p,onClick:()=>r(a=>!a),children:[p?(0,d.jsx)(t.A,{className:"size-3.5"}):(0,d.jsx)(u.A,{className:"size-3.5"}),p?k("collapseTabs"):k("expandTabs",{count:H.length})]}):null]})}var D=c(17747),E=c(31748),F=c(51314),G=c(30340),H=c(29837),I=c(41568),J=c(79904),K=c(50599),L=c(90814),M=c(93306),N=c(87348);c(82386),c(51972);var O=c(96478);let P=(0,v.forwardRef)(function({original:a,modified:b,viewMode:c,onEscape:f,savedState:g,onSaveState:h,initialLine:i},j){let{t:k}=(0,e.Bd)("common"),{wrapLines:l,collapseUnchanged:m}=(0,O.TX)(),n=(0,v.useRef)(null),o=(0,v.useRef)(null);(0,v.useRef)({viewMode:c,wrapLines:l,collapseUnchanged:m}),(0,v.useRef)(f),(0,v.useRef)(g),(0,v.useRef)(h),(0,v.useRef)(i);let[p,q]=(0,v.useState)("loading"),[r,s]=(0,v.useState)(null);return(0,v.useImperativeHandle)(j,()=>({previousChange(){o.current?.goToDiff("previous")},nextChange(){o.current?.goToDiff("next")},focus(){o.current?.getModifiedEditor().focus()}}),[]),(0,d.jsxs)("div",{"data-testid":"code-diff",className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden bg-background",children:[(0,d.jsx)("div",{ref:n,className:"min-h-0 flex-1"}),(0,d.jsx)("div",{role:"status","aria-label":k("diffStatus"),className:"flex min-h-6 shrink-0 items-center justify-end border-t px-3 text-xs text-muted-foreground",children:null===r?k("diffCalculating"):k("diffCount",{count:r})}),"loading"===p?(0,d.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 bg-background text-sm text-muted-foreground",children:[(0,d.jsx)(L.A,{className:"size-4 animate-spin"})," ",k("diffLoading")]}):null,"error"===p?(0,d.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center text-sm text-destructive",children:k("diffFailed")}):null]})});var Q=c(85544),R=c(2719),S=c(59582);function T({label:a,onClick:b,active:c=!1,children:e}){return(0,d.jsxs)(S.m_,{children:[(0,d.jsx)(S.k$,{render:(0,d.jsx)(q.$,{type:"button",size:"icon-sm",variant:"ghost","aria-label":a,"aria-pressed":c||void 0,onPointerDown:a=>a.preventDefault(),onClick:b}),children:e}),(0,d.jsx)(S.ZI,{children:a})]})}var U=c(45694),V=c(45427),W=c(55091);function X({ref:a,runtime:b,gitRuntime:c,compact:f,visible:g=!0,refreshOnFocus:h=!0,onEscape:i,onSwitchPane:j}){let{t:k}=(0,e.Bd)("projectFiles"),{wrapLines:m,diffViewMode:p,collapseUnchanged:r}=(0,O.TX)();(0,v.useSyncExternalStore)(b.subscribe,b.getRevision,b.getRevision);let{activeDiff:s,activePath:t}=b.state,u=!s&&t?b.state.documents.get(t):null,w=t?(0,W.g)(t):null,x=u?.status==="text"&&(!w||"source"===u.viewMode),y=(0,v.useRef)(null),A=(0,v.useRef)(null),B=(0,v.useRef)(null),C=(0,v.useRef)(null),L=(0,R.G)();(0,v.useImperativeHandle)(a,()=>({focus(){x?A.current?.focus():s?B.current?.focus():y.current?.querySelector('[data-testid="markdown-preview"]')?.focus()}}),[s,x]);let S=()=>{t&&A.current&&b.saveEditorState(t,A.current.getViewState())},{refresh:Z,unavailable:$}=function(a,b,c,d=!0){(0,v.useSyncExternalStore)(b.subscribe,b.getRevision,b.getRevision);let e=b.getWorkspace(a.cwd)?.snapshot,f=a.state.activePath,g=!!a.state.activeDiff;f&&a.state.documents.get(f);let h=(0,v.useRef)(c),i=(0,v.useCallback)(()=>{f&&!g&&(h.current(),a.reloadFile(f),b.refreshSnapshot(a.cwd))},[g,b,f,a]),j=f&&e?.status==="ready"?(0,z.lN)(a.cwd,f,e.repositories):null;return{refresh:i,unavailable:e?.status==="error"||j?.repository.state==="unavailable"}}(b,c,S,h),_=u?.status==="text"?u.comparison:void 0,[aa,ab]=(0,v.useState)(null),ac=_?.status==="ready"&&u?.status==="text"&&aa?.original===_.original.content&&aa.modified===u.content?aa.count:void 0,ad=a=>{t&&(S(),b.openFileDiff(t,a))},ae=$||_?.status==="error"?k("gitMarkersFailed"):_?.status==="unavailable"||_?.status==="ready"&&null===ac?k("gitMarkersUnavailable"):_?.status==="loading"||_?.status==="ready"&&void 0===ac?k("gitMarkersLoading"):_?.status==="ready"?k("gitChangesCount",{count:ac}):null;return(0,d.jsxs)("div",{ref:y,className:"flex size-full min-h-0 min-w-0 flex-col outline-none",tabIndex:-1,onFocus:a=>{a.target===a.currentTarget&&(x?A.current?.focus():s?B.current?.focus():y.current?.querySelector('[data-testid="markdown-preview"]')?.focus())},children:[s||t?(0,d.jsx)("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center justify-end gap-2 border-b px-3 py-1","aria-label":k("fileActions"),children:s?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"mr-auto shrink-0 px-1 text-xs text-muted-foreground",children:[s.label??k("headToWorking"),"text"===s.status&&s.original.content===s.modified.content?k("noDiffChanges"):""]}),(0,d.jsx)(T,{label:k("previousChange"),onClick:()=>B.current?.previousChange(),children:(0,d.jsx)(D.A,{className:"size-4"})}),(0,d.jsx)(T,{label:k("nextChange"),onClick:()=>B.current?.nextChange(),children:(0,d.jsx)(E.A,{className:"size-4"})}),f?null:(0,d.jsx)(T,{label:"side-by-side"===p?k("inlineDiff"):k("sideBySideDiff"),active:"inline"===p,onClick:()=>b.setDiffViewMode("side-by-side"===p?"inline":"side-by-side"),children:(0,d.jsx)(o.A,{className:"size-4"})}),(0,d.jsx)(T,{label:k(m?"wrapOff":"wrapOn"),active:m,onClick:()=>b.setDiffWrapLines(!m),children:(0,d.jsx)(F.A,{className:"size-4"})}),(0,d.jsx)(T,{label:k(r?"expandUnchanged":"collapseUnchanged"),active:r,onClick:()=>b.setDiffCollapseUnchanged(!r),children:(0,d.jsx)(G.A,{className:"size-4"})}),(0,d.jsx)(T,{label:k("reloadDiff"),onClick:()=>b.reloadDiff(),children:(0,d.jsx)(l.A,{className:"size-4"})})]}):(0,d.jsxs)(d.Fragment,{children:[w&&u?.status==="text"&&t?(0,d.jsx)("div",{className:"mr-auto flex shrink-0",role:"group","aria-label":k("markdown"===w?"markdownMode":"htmlMode"),children:["preview","source"].map(a=>(0,d.jsx)(q.$,{variant:u.viewMode===a?"secondary":"ghost",size:"sm","aria-pressed":u.viewMode===a,onClick:()=>{S(),b.setTextViewMode(t,a)},children:k("preview"===a?"previewMode":"sourceMode")},a))}):null,x&&ae?(0,d.jsx)("span",{"data-testid":"file-git-status",role:"status",className:"mr-auto min-w-0 truncate text-xs text-muted-foreground",title:_?.status==="error"?_.error:ae,children:f&&_?.status==="ready"&&"number"==typeof ac?k("gitChangesCompact",{count:ac}):ae}):null,x&&_?.status==="ready"?(0,d.jsxs)(d.Fragment,{children:["number"==typeof ac&&ac>0?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(T,{label:k("previousChange"),onClick:()=>A.current?.previousChange(),children:(0,d.jsx)(D.A,{className:"size-4"})}),(0,d.jsx)(T,{label:k("nextChange"),onClick:()=>A.current?.nextChange(),children:(0,d.jsx)(E.A,{className:"size-4"})})]}):null,(0,d.jsx)(T,{label:k("viewDiff"),onClick:()=>ad(),children:(0,d.jsx)(H.A,{className:"size-4"})})]}):null,x&&t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(T,{label:k("findInFile"),onClick:()=>A.current?.openSearch(),children:(0,d.jsx)(I.A,{className:"size-4"})}),f?null:(0,d.jsx)(T,{label:k("goToLine"),onClick:()=>A.current?.gotoLine(),children:(0,d.jsx)(J.A,{className:"size-4"})}),(0,d.jsx)(T,{label:k(m?"wrapOff":"wrapOn"),active:m,onClick:()=>b.setWrapLines(t,!m),children:(0,d.jsx)(F.A,{className:"size-4"})}),(0,d.jsx)(T,{label:k("copySelectionOrAll"),onClick:()=>{if(u?.status!=="text")return;let a=A.current?.getSelectionText()??"";(0,M.x)(a||u.content).then(b=>{b?L.success(k(a?"selectedCodeCopied":"allCodeCopied")):L.error(k("copyContentFailed"))})},children:(0,d.jsx)(K.A,{className:"size-4"})})]}):null,t?(0,d.jsx)(T,{label:k("reloadCurrentFile"),onClick:Z,children:(0,d.jsx)(l.A,{className:"size-4"})}):null]})}):null,(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden pb-[env(safe-area-inset-bottom)]",children:s?"text"===s.status?(0,d.jsx)(P,{ref:B,original:s.original,modified:s.modified,viewMode:f?"inline":p,savedState:s.editorState,initialLine:s.initialLine,onSaveState:a=>b.saveDiffState(s,a),onEscape:i},`${s.repositoryRoot}:${s.path}`):"metadata"===s.status?(0,d.jsxs)("div",{className:"grid h-full grid-cols-1 gap-4 overflow-auto p-4 md:grid-cols-2",children:[(0,d.jsx)("pre",{className:"whitespace-pre-wrap break-all text-sm",children:s.originalMetadata}),(0,d.jsx)("pre",{className:"whitespace-pre-wrap break-all text-sm",children:s.modifiedMetadata})]}):"loading"===s.status?(0,d.jsx)(Y,{}):(0,d.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-center text-sm",children:[(0,d.jsx)("p",{className:"text-muted-foreground",children:"binary"===s.status?k("binaryDiffUnavailable"):"too_large"===s.status?k("largeDiffUnavailable"):s.error}),"error"===s.status?(0,d.jsx)(q.$,{variant:"outline",onClick:()=>b.reloadDiff(),children:k("readAgain")}):null]}):t&&u?"loading"===u.status||"unloaded"===u.status?(0,d.jsx)(Y,{}):"error"===u.status?(0,d.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-center",children:[(0,d.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:u.error}),(0,d.jsx)(q.$,{variant:"outline",onClick:()=>b.reloadFile(t),children:k("readAgain")})]}):"image"===u.status?(0,d.jsx)(Q.k,{mode:"inline",slides:[{src:u.objectUrl,alt:t}],ariaLabel:k("imageViewer",{name:t.replaceAll("\\","/").split("/").at(-1)??t})},u.objectUrl):"markdown"===w&&"preview"===u.viewMode?(0,d.jsx)(V.n,{content:u.content,label:k("markdownPreview",{name:t}),savedScrollTop:u.previewScrollTop,onScroll:a=>b.savePreviewScrollTop(t,a)},t):"html"===w&&"preview"===u.viewMode?(0,d.jsx)("iframe",{ref:C,className:"block size-full border-0 bg-white",sandbox:"allow-scripts",srcDoc:(0,U.z)(u.content),title:k("htmlPreview",{name:t})}):(0,d.jsx)(N.e,{ref:A,path:t,content:u.content,size:u.size,originalContent:_?.status==="ready"?_.original.content:void 0,onChanges:a=>{_?.status==="ready"&&ab({original:_.original.content,modified:u.content,count:a})},onOpenDiff:ad,savedState:u.editorState,navigation:b.pendingNavigation,onNavigation:(a,c)=>b.consumeNavigation(a,c),onSaveState:(a,c)=>b.saveEditorState(a,c),onEscape:i},t):(0,d.jsxs)("div",{"data-testid":"file-workspace-empty",className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-sm text-muted-foreground",children:[(0,d.jsx)(n.A,{className:"size-6"}),k("noOpenFile")]})})]})}function Y(){let{t:a}=(0,e.Bd)("projectFiles");return(0,d.jsxs)("div",{className:"flex size-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,d.jsx)(L.A,{className:"size-4 animate-spin"}),a("loadingFile")]})}var Z=c(68341),$=c(1222),_=c(79739),aa=c(53403),ab=c(4998),ac=c(5701),ad=c(11071),ae=c(82589);function af({items:a,label:b,scrollTop:c,onScroll:e,render:f,role:g="listbox",onKeyDown:h}){let i=(0,v.useRef)(null),[j,k]=(0,v.useState)({top:c,height:300}),l=Math.max(0,Math.floor(j.top/36)-8),m=Math.min(a.length,Math.ceil((j.top+j.height)/36)+8);return(0,d.jsx)("div",{ref:i,role:g,tabIndex:"tree"===g?0:void 0,onKeyDown:h,"aria-label":b,className:"min-h-0 flex-1 overflow-auto overscroll-contain",onScroll:a=>{let b=a.currentTarget.scrollTop;k(a=>({...a,top:b})),e(b)},children:(0,d.jsx)("div",{style:{height:36*a.length,position:"relative"},children:(0,d.jsx)("div",{style:{position:"absolute",top:36*l,left:0,right:0},children:a.slice(l,m).map((a,b)=>f(a,l+b))})})})}var ag=c(37496),ah=c(9365),ai=c(75152),aj=c(51108),ak=c(83731);let al={added:"A",modified:"M",deleted:"D",renamed:"R","type-changed":"T"};function am({cwd:a,repositoryRoot:b,rows:c,changes:f,selectedPath:g,scrollTop:h,onScroll:i,onSelect:j,onToggle:k,onOpen:l,onReveal:m}){let{t:n}=(0,e.Bd)("projectHistory"),p=new Map(f.map(a=>[a.path,a]));return(0,d.jsx)(af,{role:"tree",label:n("changeFiles"),items:c,scrollTop:h,onScroll:i,onKeyDown:a=>{if(a.defaultPrevented||!a.currentTarget.contains(a.target))return;let b=a.target instanceof Element?a.target.closest("[data-tree-key]"):null;if(a.target instanceof Element&&a.target.closest("button"))return;let d=b?c.findIndex(a=>a.key===b.dataset.treeKey):-1,e=c[d],f=d;if("ArrowDown"===a.key)f=Math.min(c.length-1,d+1);else if("ArrowUp"===a.key)f=Math.max(0,d-1);else if("Home"===a.key)f=0;else if("End"===a.key)f=c.length-1;else if("ArrowRight"===a.key&&e?.directory)e.expanded?f=Math.min(c.length-1,d+1):k(e.directory.path);else if("ArrowLeft"===a.key&&e){if(e.expanded&&e.directory)k(e.directory.path);else for(let a=d-1;a>=0;a-=1)if(c[a].depth<e.depth){f=a;break}}else{if("Enter"!==a.key&&" "!==a.key||!e)return;e.directory?k(e.directory.path):"Enter"===a.key?l(e.path):j(e.path)}a.preventDefault();let g=c[f];if(!g)return;let h=a.currentTarget;36*f<h.scrollTop?h.scrollTop=36*f:(f+1)*36>h.scrollTop+h.clientHeight&&(h.scrollTop=(f+1)*36-h.clientHeight),requestAnimationFrame(()=>{[...h.querySelectorAll("[data-tree-key]")].find(a=>a.dataset.treeKey===g.key)?.focus()})},render:c=>{let e=p.get(c.path),f=(0,ak._J)(b,c.path),h=c.directory;return(0,d.jsx)(aj.J,{cwd:a,path:f,type:c.type,historical:!0,expanded:c.expanded,onToggle:h?()=>k(h.path):void 0,onOpen:"file"===c.type?()=>l(c.path):void 0,openLabel:n("viewDiff"),oldPath:"file"===c.type&&e?.oldPath?(0,ak._J)(b,e.oldPath):void 0,onReveal:m,trigger:(0,d.jsxs)("div",{role:"treeitem",tabIndex:0,"aria-level":c.depth+1,"aria-expanded":c.expanded,"aria-selected":"file"===c.type&&g===c.path,"data-tree-key":c.key,className:(0,w.cn)("flex h-9 min-w-0 cursor-pointer items-center gap-2 pr-2 text-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","file"===c.type&&g===c.path&&"bg-accent"),style:{paddingLeft:8+16*c.depth},title:e?.oldPath&&"file"===c.type?`${(0,ak._J)(b,e.oldPath)} → ${f}`:f,onClick:a=>{h?a.detail<2&&k(h.path):j(c.path)},onDoubleClick:()=>{"file"===c.type&&l(c.path)},children:[h?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ag.A,{className:(0,w.cn)("size-4 shrink-0 text-muted-foreground",c.expanded&&"rotate-90")}),c.expanded?(0,d.jsx)(ah.A,{className:"size-4 shrink-0 text-muted-foreground"}):(0,d.jsx)(ai.A,{className:"size-4 shrink-0 text-muted-foreground"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"w-4 shrink-0"}),(0,d.jsx)("span",{className:(0,w.cn)("w-4 shrink-0 font-mono text-xs",e?.status==="added"?"text-emerald-600 dark:text-emerald-400":e?.status==="deleted"?"text-red-600 dark:text-red-400":"text-blue-600 dark:text-blue-400"),"aria-label":n("gitStatus",{status:e?al[e.status]:""}),children:e?al[e.status]:""})]}),(0,d.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[c.label,"directory"===c.type&&p.has(c.path)?"/":""]}),"file"===c.type?(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":n("viewDiffPath",{path:c.path}),onDoubleClick:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation(),l(c.path)},children:(0,d.jsx)(o.A,{className:"size-4"})}):null]})},c.key)}})}function an(a){let{state:b,repositories:c,projectName:f,narrow:g,scroll:h}=a,{t:i}=(0,e.Bd)("projectHistory"),{locale:j,timeZone:k}=(0,ab.i)(),m=(0,v.useMemo)(()=>new Intl.DateTimeFormat("en"===j?"en-US":"zh-CN",{timeZone:k,month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),[j,k]),n=(0,v.useMemo)(()=>new Intl.DateTimeFormat("en"===j?"en-US":"zh-CN",{timeZone:k,timeZoneName:"shortOffset",year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),[j,k]),o=(0,v.useId)(),{mobilePane:r,onMobilePane:s}=a,t=b.changes.data,u=`${b.repositoryRoot}:${t?.comparison.original}:${t?.comparison.target}`,x=b.selectedChangePath,y=[{value:"HEAD",label:i("currentHead")},...(b.branches.data?.local??[]).map(a=>({value:`refs/heads/${a}`,label:a,description:i("localBranch")})),...(b.branches.data?.remote??[]).map(a=>({value:`refs/remotes/${a}`,label:a,description:i("remoteBranch")}))],z=b.branches.data?.upstream,A=t?.commit,B=c=>c?(0,d.jsxs)("div",{role:"alert",className:"flex flex-wrap items-center gap-2 p-3 text-sm text-destructive",children:[(0,d.jsx)("span",{className:"min-w-0 flex-1 break-words",children:c}),(0,d.jsx)(q.$,{size:"sm",variant:"outline",onClick:a.onRefresh,children:i("retry")}),"compare"===b.mode&&"merge-base"===b.strategy?(0,d.jsx)(q.$,{size:"sm",variant:"outline",onClick:()=>a.onStrategy("direct"),children:i("compareDirect")}):null]}):null,C=(0,d.jsxs)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:[B(b.log.error),"loading"===b.log.status?(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,d.jsx)(L.A,{className:"size-4 animate-spin"}),i("loadingCommits")]}):null,(0,d.jsx)(af,{items:b.log.data?.items??[],label:i("commitList"),scrollTop:h.log,onScroll:b=>a.onScroll("log",b),render:c=>(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":b.selectedCommit===c.oid,className:(0,w.cn)("flex h-9 w-full items-center gap-3 border-b border-border/40 px-3 text-left text-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",b.selectedCommit===c.oid&&"bg-accent"),onClick:()=>{var b;return b=c.oid,void(a.onCommit(b),g&&s("files"))},title:`${c.subject}
|
|
14
|
+
${c.oid}
|
|
15
|
+
${c.author} \xb7 ${n.format(c.timestampMs)}`,children:[(0,d.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[c.subject||i("noCommitMessage"),c.refs.length?(0,d.jsx)("span",{className:"ml-2 text-xs text-muted-foreground",children:c.refs.join(" \xb7 ")}):null]}),(0,d.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:c.oid.slice(0,7)}),g?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"w-20 truncate text-xs text-muted-foreground",children:c.author}),(0,d.jsx)("time",{className:"w-28 shrink-0 text-right text-xs text-muted-foreground",children:m.format(c.timestampMs)})]})]},c.oid)},`${b.repositoryRoot}:${b.mode}:${b.tip}:${b.base}:${b.target}:${b.query}:${b.author}`),"ready"!==b.log.status||b.log.data?.items.length?null:(0,d.jsx)("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:b.query||b.author?i("noMatchingCommits"):i("noCommits")}),b.log.data?.truncated?(0,d.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("scanLimit")}):null,(b.log.data?.items.length??0)>=2e3?(0,d.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("loadedLimit")}):b.log.data?.hasMore?(0,d.jsx)(q.$,{variant:"ghost",size:"sm",disabled:"loading"===b.log.status,onClick:a.onMoreLog,children:i("loadMoreCommits")}):null]}),D=(0,d.jsxs)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:[(0,d.jsxs)("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center gap-2 border-b px-3 py-1",children:[g?(0,d.jsx)(q.$,{variant:"ghost",size:"icon-sm","aria-label":i("backCommits"),onClick:()=>s("log"),children:(0,d.jsx)(_.A,{className:"size-4"})}):null,(0,d.jsx)("span",{className:"text-sm font-medium",children:b.selectedCommit?i("commitChanges"):i("cumulativeChanges")}),t?(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:i("loadedFiles",{count:t.items.length})}):null,"compare"===b.mode&&b.selectedCommit?(0,d.jsx)(q.$,{variant:"ghost",size:"sm",onClick:a.onAggregate,children:i("backCumulative")}):null]}),B(b.changes.error),"loading"===b.changes.status?(0,d.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,d.jsx)(L.A,{className:"size-4 animate-spin"}),i("loadingChanges")]}):null,(0,d.jsxs)(p.HK,{orientation:"vertical",defaultLayout:{"project-changes":a.panelSizes.changes,"project-detail":100-a.panelSizes.changes},onLayoutChanged:(b,c)=>{c.isUserInteraction&&void 0!==b["project-changes"]&&a.onPanelSize("changes",b["project-changes"])},children:[(0,d.jsx)(p.wV,{id:"project-changes",defaultSize:`${a.panelSizes.changes}%`,minSize:"80px",children:(0,d.jsxs)("div",{className:"flex size-full min-h-0 flex-col",children:[(0,d.jsx)(am,{cwd:a.cwd,repositoryRoot:b.repositoryRoot??"",rows:a.changeRows,changes:t?.items??[],selectedPath:x,scrollTop:h.changes,onScroll:b=>a.onScroll("changes",b),onSelect:a.onSelectChange,onToggle:a.onToggleDirectory,onOpen:a.onOpenFile,onReveal:a.onReveal},u),"ready"!==b.changes.status||t?.items.length?null:(0,d.jsx)("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:i("noDiff")}),t?.hasMore?(0,d.jsx)(q.$,{size:"sm",variant:"ghost",disabled:"loading"===b.changes.status,onClick:a.onMoreChanges,children:i("loadMoreFiles")}):null,t?.truncated?(0,d.jsx)("p",{className:"p-3 text-xs text-muted-foreground",children:i("changesLimit")}):null]})}),(0,d.jsx)(p.WM,{}),(0,d.jsx)(p.wV,{id:"project-detail",defaultSize:`${100-a.panelSizes.changes}%`,minSize:"60px",children:(0,d.jsxs)(ac.V,{className:"h-full",viewportClassName:"p-3 text-sm",role:"region","aria-label":i("commitDetails"),children:[A?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("pre",{className:"mb-3 whitespace-pre-wrap break-words font-sans leading-relaxed",children:A.message}),(0,d.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,d.jsx)("span",{className:"min-w-0 flex-1 break-all font-mono text-xs",children:A.oid}),(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":i("copySha"),onClick:()=>a.onCopy(A.oid),children:(0,d.jsx)(K.A,{className:"size-4"})})]}),(0,d.jsxs)("p",{className:"mb-3 text-xs text-muted-foreground",children:[A.author," \xb7 ",n.format(A.timestampMs)]}),A.parents.length>1?(0,d.jsx)(ae.b,{className:"mb-3",ariaLabel:i("compareParent"),value:A.selectedParent??"",options:A.parents.map((a,b)=>({value:a,label:i("parentCommit",{count:b+1,oid:a.slice(0,10)})})),onChange:b=>a.onCommit(A.oid,b)}):null]}):t?(0,d.jsxs)("div",{className:"space-y-2 text-xs text-muted-foreground",children:[(0,d.jsx)("p",{children:"merge-base"===b.strategy?i("mergeBaseToTarget"):i("baseToTarget")}),(0,d.jsx)("p",{className:"break-all font-mono",children:t.comparison.original??i("emptyRevision")}),(0,d.jsx)("p",{className:"break-all font-mono",children:t.comparison.target})]}):(0,d.jsx)("p",{className:"text-muted-foreground",children:i("selectCommit")}),x?(0,d.jsx)("p",{className:"mt-3 break-all font-mono text-xs text-muted-foreground",children:x}):null]})})]})]});return(0,d.jsxs)("section",{className:"flex size-full min-h-0 min-w-0 flex-col","aria-label":i("historyAndCompare"),children:[(0,d.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b px-3 py-2",children:[(0,d.jsxs)("div",{className:"flex gap-1",role:"group","aria-label":i("viewMode"),children:[(0,d.jsx)(q.$,{size:"sm",variant:"history"===b.mode?"secondary":"ghost","aria-pressed":"history"===b.mode,onClick:()=>{a.onMode("history"),s("log")},children:i("historyMode")}),(0,d.jsx)(q.$,{size:"sm",variant:"compare"===b.mode?"secondary":"ghost","aria-pressed":"compare"===b.mode,onClick:()=>{a.onMode("compare"),s("log")},children:i("compareMode")})]}),(0,d.jsx)(ae.b,{className:"w-44",ariaLabel:i("selectRepository"),value:b.repositoryRoot??"",options:c.map(a=>({value:a.root,label:a.root||f,description:"unavailable"===a.state?(0,aa.fD)(a.message,j):void 0})),onChange:a.onRepository}),"history"===b.mode?(0,d.jsx)(ae.b,{className:"w-48",ariaLabel:i("viewBranch"),value:b.tip,options:y,onChange:b=>a.onRevision("tip",b)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ae.b,{className:"w-44",ariaLabel:i("baseBranch"),placeholder:i("chooseBase"),value:b.base,options:y,onChange:b=>a.onRevision("base",b)}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"→"}),(0,d.jsx)(ae.b,{className:"w-44",ariaLabel:i("targetBranch"),value:b.target,options:y,onChange:b=>a.onRevision("target",b)}),(0,d.jsx)(ae.b,{className:"w-48",ariaLabel:i("comparison"),value:b.strategy,options:[{value:"merge-base",label:i("introducedChanges")},{value:"direct",label:i("directComparison")}],onChange:b=>a.onStrategy("direct"===b?"direct":"merge-base")}),g?(0,d.jsx)(q.$,{size:"sm",variant:"outline",onClick:()=>s("files"),children:i("cumulativeChanges")}):null]}),(0,d.jsx)(ad.p,{className:"w-40 shrink-0","aria-label":i("filterAuthor"),placeholder:i("author"),list:o,value:b.author,onChange:b=>a.onAuthor(b.target.value)}),(0,d.jsx)("datalist",{id:o,children:b.authorSuggestions.map(a=>(0,d.jsx)("option",{value:a},a))}),(0,d.jsx)(ad.p,{className:"min-w-32 flex-1 basis-40","aria-label":i("searchCommits"),placeholder:i("searchCommits"),value:b.query,onChange:b=>a.onQuery(b.target.value)}),(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":i("refreshGit"),onClick:a.onRefresh,children:(0,d.jsx)(l.A,{className:"size-4"})})]}),b.branches.error?B(b.branches.error):null,z?(0,d.jsxs)("p",{className:"shrink-0 truncate border-b px-3 py-1 text-xs text-muted-foreground",title:z.ref,children:[z.ref.replace("refs/remotes/","")," \xb7 ",i("localRecord")," \xb7"," ",null===z.ahead||null===z.behind?i("refUnavailable"):i("aheadBehind",{ahead:z.ahead,behind:z.behind})]}):null,"compare"!==b.mode||b.base?g?"log"===r?C:D:(0,d.jsxs)(p.HK,{orientation:"horizontal",defaultLayout:{"project-log":a.panelSizes.log,"project-files":100-a.panelSizes.log},onLayoutChanged:(b,c)=>{c.isUserInteraction&&void 0!==b["project-log"]&&a.onPanelSize("log",b["project-log"])},children:[(0,d.jsx)(p.wV,{id:"project-log",defaultSize:`${a.panelSizes.log}%`,minSize:"30%",children:C}),(0,d.jsx)(p.WM,{}),(0,d.jsx)(p.wV,{id:"project-files",defaultSize:`${100-a.panelSizes.log}%`,minSize:"25%",children:D})]}):(0,d.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:i("chooseBaseBranch")})]})}let ao=()=>{};function ap({clientId:a,cwd:b,refreshOnFocus:c,title:s,actions:t,onEscape:u=ao,onUnauthorized:w}){let{t:x}=(0,e.Bd)("projectHistory"),y=(0,R.G)(),{files:z,git:A,history:B,global:D,updateGlobal:E,page:F,setPage:G,historyPane:H,setHistoryPane:I,setContainer:J,narrow:K,stacked:L,width:N,openGit:O,refresh:P}=function(a,b,c,d){let e=(0,R.G)(),[f]=(0,v.useState)($.N1),[g,h]=(0,v.useState)(f),i=(0,v.useCallback)(a=>{h(b=>({...b,...a})),(0,$.Ms)({...(0,$.N1)(),...a})},[]),[j]=(0,v.useState)(()=>(0,$.tQ)(b)),[k]=(0,v.useState)(()=>(0,Z.ph)(a,b,a=>e.show({level:"info",title:a}),j,f,{lazyHistory:!c,onUnauthorized:d})),{files:l,git:m,history:n}=k;(0,v.useSyncExternalStore)(l.subscribe,l.getRevision,l.getRevision),(0,v.useSyncExternalStore)(m.subscribe,m.getRevision,m.getRevision),(0,v.useSyncExternalStore)(n.subscribe,n.getRevision,n.getRevision);let[o,p]=(0,v.useState)(j?.page??"files"),[q,r]=(0,v.useState)(j?.historyPane??"log"),[s,t]=(0,v.useState)({width:1200,height:800}),[u,w]=(0,v.useState)(null);(0,v.useRef)(!1),(0,v.useRef)(()=>void 0);let x=s.width<900,y=x||s.height<680;m.getWorkspace(b).snapshot.repositories;let z=l.state,A=g.gitOpen&&(!y||"git"===o);return{files:l,git:m,history:n,global:g,updateGlobal:i,page:o,setPage:p,historyPane:q,setHistoryPane:r,setContainer:w,narrow:x,stacked:y,width:s.width,openGit(a){i({gitOpen:!0}),p("git"),void 0!==a&&n.setRepository(a)},refresh(){l.refreshTree(),m.refreshSnapshot(b),z.activeDiff?l.reloadDiff():z.activePath&&l.reloadFile(z.activePath),A&&n.refresh()}}}(a,b,c,w),{directoryOpen:Q,gitOpen:S,gitMaximized:T}=D,U=b.replaceAll("\\","/").split("/").filter(Boolean).at(-1)??b,V=A.getWorkspace(b),W=V.snapshot.repositories,Y=z.state,_=Y.activeDiff?[Y.activeDiff.repositoryRoot,Y.activeDiff.path].filter(Boolean).join("/"):null,aa=(0,d.jsx)(r.F,{cwd:b,projectName:U,runtime:z,gitRuntime:A,onOpenGitBranches:O,onFileOpened:()=>G("code")}),ab=(0,d.jsxs)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:[(0,d.jsx)(C,{cwd:b,gitRuntime:A,paths:Y.tabs,activePath:Y.activePath,diffPath:_,mobile:K,onActivate:a=>z.openFile(a),onClose:(a,b)=>z.closeTabs(a,b)}),(0,d.jsx)(X,{runtime:z,gitRuntime:A,compact:N<1100,refreshOnFocus:c,onEscape:u})]}),ac=(0,d.jsxs)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:[(0,d.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-2 border-b bg-muted px-3",children:[(0,d.jsx)(f.A,{className:"size-4"}),(0,d.jsx)("span",{className:"flex-1 text-sm font-medium",children:"Git"}),L?null:(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":x(T?"restoreGit":"maximizeGit"),onClick:()=>E({gitMaximized:!T}),children:T?(0,d.jsx)(g.A,{className:"size-4"}):(0,d.jsx)(h.A,{className:"size-4"})}),(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":x("collapseGit"),onClick:()=>{E({gitOpen:!1,gitMaximized:!1}),G("code")},children:(0,d.jsx)(i.A,{className:"size-4"})})]}),W.length?(0,d.jsx)(an,{state:B.state,cwd:b,changeRows:B.getChangeRows(),onSelectChange:a=>B.selectChange(a),onToggleDirectory:a=>B.toggleChangeDirectory(a),onReveal:(a,b)=>z.revealFile(a,b),repositories:W,projectName:U,narrow:K,mobilePane:H,onMobilePane:I,scroll:B.scroll,onScroll:(a,b)=>B.setScroll(a,b),panelSizes:{log:D.logSize,changes:D.changeSize},onPanelSize:(a,b)=>E("log"===a?{logSize:b}:{changeSize:b}),onRepository:a=>{B.setRepository(a),I("log")},onMode:a=>B.setMode(a),onRevision:(a,b)=>B.setRevision(a,b),onStrategy:a=>B.setStrategy(a),onQuery:a=>B.setQuery(a),onAuthor:a=>B.setAuthor(a),onCommit:(a,b)=>B.selectCommit(a,b),onAggregate:()=>B.showAggregate(),onMoreLog:()=>B.loadMoreLog(),onMoreChanges:()=>B.loadMoreChanges(),onOpenFile:a=>{B.openChange(a),G("code"),E({gitMaximized:!1})},onRefresh:()=>B.refresh(),onCopy:a=>{(0,M.x)(a).then(a=>{a||y.error(x("copyFailed"))})}}):(0,d.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:"loading"===V.snapshot.status||"idle"===V.snapshot.status?x("findingGit"):V.snapshot.error??x("noGit")})]}),ad=(0,d.jsxs)(p.HK,{orientation:"horizontal",defaultLayout:Q?{"project-tree":D.directorySize,"project-code":100-D.directorySize}:void 0,onLayoutChanged:(a,b)=>{b.isUserInteraction&&void 0!==a["project-tree"]&&E({directorySize:a["project-tree"]})},children:[Q?(0,d.jsx)(p.wV,{id:"project-tree",defaultSize:`${D.directorySize}%`,minSize:"180px",maxSize:"40%",children:aa}):null,Q?(0,d.jsx)(p.WM,{}):null,(0,d.jsx)(p.wV,{id:"project-code",minSize:"40%",children:ab})]},Q?"tree-visible":"tree-hidden");return(0,d.jsxs)("div",{ref:J,className:"flex size-full min-h-0 min-w-0 flex-col overflow-hidden","data-testid":"project-preview",children:[(0,d.jsxs)("header",{className:"flex min-h-14 shrink-0 flex-wrap items-center gap-2 border-b bg-muted px-3 py-2 pt-[max(8px,env(safe-area-inset-top))]",children:[L?null:(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":x(Q?"collapseDirectory":"expandDirectory"),onClick:()=>E({directoryOpen:!Q}),children:Q?(0,d.jsx)(j.A,{className:"size-4"}):(0,d.jsx)(k.A,{className:"size-4"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[s??(0,d.jsx)("h1",{className:"truncate text-lg font-semibold",title:b,children:U}),(0,d.jsx)("p",{className:"truncate text-xs text-muted-foreground",title:b,children:b})]}),(0,d.jsxs)(q.$,{size:"sm",variant:S?"secondary":"ghost","aria-pressed":S,onClick:()=>O(),children:[(0,d.jsx)(f.A,{className:"size-4"}),(0,d.jsx)("span",{className:"max-sm:hidden",children:x("gitRecords")})]}),(0,d.jsx)(q.$,{size:"icon-sm",variant:"ghost","aria-label":x("refreshPreview"),onClick:P,children:(0,d.jsx)(l.A,{className:"size-4"})}),t]}),V.snapshot.error?(0,d.jsx)("p",{role:"alert",className:"shrink-0 border-b px-3 py-2 text-sm text-destructive",children:V.snapshot.error}):null,L?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex shrink-0 gap-1 border-b px-2 py-1",role:"group","aria-label":x("previewArea"),children:[(0,d.jsxs)(q.$,{size:"sm",variant:"files"===F?"secondary":"ghost",onClick:()=>G("files"),children:[(0,d.jsx)(m.A,{className:"size-4"}),x("files")]}),(0,d.jsxs)(q.$,{size:"sm",variant:"code"===F?"secondary":"ghost",onClick:()=>G("code"),children:[(0,d.jsx)(n.A,{className:"size-4"}),x("code")]}),(0,d.jsxs)(q.$,{size:"sm",variant:"git"===F?"secondary":"ghost",onClick:()=>O(),children:[(0,d.jsx)(o.A,{className:"size-4"}),"Git"]})]}),(0,d.jsx)("div",{className:"min-h-0 flex-1",children:"files"===F?aa:"git"===F?ac:ab})]}):T&&S?ac:(0,d.jsxs)(p.HK,{orientation:"vertical",defaultLayout:S?{"project-main":100-D.gitSize,"project-git":D.gitSize}:void 0,onLayoutChanged:(a,b)=>{b.isUserInteraction&&void 0!==a["project-git"]&&E({gitSize:a["project-git"]})},children:[(0,d.jsx)(p.wV,{id:"project-main",defaultSize:S?`${100-D.gitSize}%`:"100%",minSize:"35%",children:ad}),S?(0,d.jsx)(p.WM,{}):null,S?(0,d.jsx)(p.wV,{id:"project-git",defaultSize:`${D.gitSize}%`,minSize:"300px",children:ac}):null]},S?"git-visible":"git-hidden")]})}},97563:(a,b,c)=>{"use strict";async function d(a){let b="u"<typeof navigator?void 0:navigator.clipboard;if(b?.writeText)try{return await b.writeText(a),!0}catch{}if("u"<typeof document||!document.body)return!1;let c=document.activeElement instanceof HTMLElement?document.activeElement:null,d=document.createElement("textarea");d.value=a,d.setAttribute("readonly",""),d.setAttribute("aria-hidden","true"),d.style.position="fixed",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.opacity="0";try{return document.body.append(d),d.select(),d.setSelectionRange(0,d.value.length),document.execCommand("copy")}catch{return!1}finally{d.remove();try{c?.focus()}catch{}}}c.d(b,{h3:()=>d,qj:()=>e});class e extends Error{constructor(a){super(a.message,{cause:a.cause}),this.name="PiDeskBrowserPluginError",this.pluginName=a.pluginName,this.contributionName=a.contributionName??null,this.phase=a.phase}}},98722:(a,b,c)=>{"use strict";c.d(b,{T8:()=>q,WW:()=>r,aD:()=>g,co:()=>m,lw:()=>s,ph:()=>p,xv:()=>k,yw:()=>n});var d=c(87883),e=c(51949),f=c(18997);let g=d.Yj().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),h=d.KC([g,d.eu("HEAD"),d.Yj().max(1024).regex(/^refs\/(?:heads|remotes)\/[^\0\r\n]+$/)]).refine(a=>!a.includes("..")&&!a.endsWith("/"),"Git 版本无效"),i=d.KC([d.Ik({commit:h,parent:g.optional()}).strict(),d.Ik({base:h,target:h,strategy:d.k5(["merge-base","direct"])}).strict()]),j=d.Ik({base:g.nullable(),target:g,original:g.nullable()}).strict(),k=d.Ik({baseCommit:g.nullable(),targetCommit:g,oldPath:e._g.optional()}).strict(),l=d.Ik({oid:g,parents:d.YO(g),subject:d.Yj(),author:d.Yj(),timestampMs:d.ai().int(),refs:d.YO(d.Yj())}).strict(),m=d.Ik({tip:h,exclude:h.optional(),query:d.Yj().trim().max(200).default(""),author:d.Yj().trim().max(200).optional(),page:d.Ik({index:d.ai().int().min(1).max(2e3),size:d.ai().int().min(1).max(100)}).strict()}).strict(),n=d.Ik({tip:g.nullable(),exclude:g.nullable(),items:d.YO(l),hasMore:d.zM(),truncated:d.zM()}).strict(),o=d.Ik({path:e._g,oldPath:e._g.nullable(),status:d.k5(["added","modified","deleted","renamed","type-changed"])}).strict(),p=d.Ik({selection:i,page:d.Ik({index:d.ai().int().min(1).max(5e4),size:d.ai().int().min(1).max(500)}).strict()}).strict(),q=d.Ik({comparison:j,commit:l.extend({message:d.Yj(),selectedParent:g.nullable()}).nullable(),items:d.YO(o),hasMore:d.zM(),truncated:d.zM()}).strict(),r=f.gf.extend({upstream:d.Ik({ref:d.Yj(),ahead:d.ai().int().nonnegative().nullable(),behind:d.ai().int().nonnegative().nullable()}).strict().nullable()}).strict(),s=d.KC([f.FJ,d.Ik({kind:d.eu("metadata"),original:d.Yj(),modified:d.Yj()}).strict()])}};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";exports.id=23054,exports.ids=[23054],exports.modules={18477:(a,b,c)=>{c.d(b,{KE:()=>l,ds:()=>n,kM:()=>o});var d=c(59473),e=c(54733),f=c(58311),g=c(2364),h=c(2002);let i=d.Ik({}).strict(),j=d.Ik({workId:e.eW}).strict(),k=d.Ik({workId:e.eW}).strict(),l=d.Ik({cwd:e.ik.optional(),sessionId:e.Kx.optional(),branchId:d.Yj().min(1).optional(),projectName:d.Yj().trim().min(1).optional(),sessionTitle:d.Yj().trim().min(1).nullable().optional(),status:e.jw.optional(),messageCounts:e.AA.optional(),lastMessageUpdatedAt:g.k.nullable().optional()}).strict().refine(a=>Object.keys(a).length>0,{message:"work session changes cannot be empty"}),m=d.Ik({workSessions:d.YO(e.MY),pinnedCount:e.MT,appRuntime:f.GR}).strict().refine(a=>a.pinnedCount<=a.workSessions.length,{message:"pinnedCount cannot exceed work session count",path:["pinnedCount"]}),n=d.gM("type",[d.Ik({type:d.eu("snapshot"),workSessions:d.YO(e.MY),pinnedCount:e.MT}).strict().refine(a=>a.pinnedCount<=a.workSessions.length,{message:"pinnedCount cannot exceed work session count",path:["pinnedCount"]}),d.Ik({type:d.eu("update"),workId:e.eW,changes:l}).strict(),d.Ik({type:d.eu("delete"),workId:e.eW}).strict()]),o=Object.freeze({list:(0,h.Vc)({path:"work-sessions/list",inputSchema:i,outputSchema:m}),acknowledgeCompleted:(0,h.Vc)({path:"work-sessions/ack-completed",inputSchema:j,outputSchema:k}),update:(0,h._G)({path:"work-sessions/update",bodySchema:n})})},23024:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{E:()=>g});var e=c(72498),f=a([e]);e=(f.then?(await f)():f)[0];class g{constructor(a,b){this.workId=a,this.runtime=b}static async create(a,b,c){let d=c?await e.vC.open(b,c):e.vC.create(b);return new g(a,d)}get cwd(){return this.runtime.cwd}get sessionId(){return this.runtime.sessionId}get branchId(){return this.runtime.branchId}async branch(a){let b=await this.runtime.branch(a);return{changed:b.changed,editorText:b.editorText}}async createBranchedSession(a,b){let c=this.runtime.createBranchedSession(b);return{workSession:new g(a,c.runtime),editorText:c.editorText}}async send(a){return this.runtime.send(a)}async interrupt(){await this.runtime.interrupt()}async restoreQueuedMessages(){return this.runtime.restoreQueuedMessages()}async setTitle(a){await this.runtime.setTitle(a)}async setModel(a){await this.runtime.setModel(a)}}d()}catch(a){d(a)}})},23054:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{HK:()=>F,JJ:()=>y,Jl:()=>I,Jv:()=>G,Ki:()=>C,VH:()=>D,XM:()=>B,if:()=>H,k1:()=>A,qm:()=>x});var e=c(71473),f=c(77598),g=c(73024),h=c(76760),i=c(59473),j=c(25084),k=c(40529),l=c(77394),m=c(54733),n=c(18477),o=c(33270),p=c(23024),q=c(52913),r=c(65129),s=c(65209),t=c(72498),u=c(46524),v=c(47574),w=a([e,p,r,s,t,v]);[e,p,r,s,t,v]=w.then?(await w)():w;let z=i.Ik({workSessions:m.TO,pinnedCount:m.MT}).strict().refine(a=>a.pinnedCount<=a.workSessions.length,{message:"pinnedCount cannot exceed persisted work session count",path:["pinnedCount"]});class A extends Error{constructor(){super("WorkSession order does not match the current collection"),this.name="WorkSessionOrderConflictError"}}class B extends Error{constructor(a){super(`WorkSession not found: ${a}`),this.name="WorkSessionNotFoundError"}}class C extends Error{constructor(a,b){super(`Pi session ${a} is already bound to work session ${b}`),this.name="WorkSessionSessionConflictError"}}class D extends Error{constructor(a,b){super(`Pi session ${b} was not found in ${a}`),this.name="WorkSessionHistoryNotFoundError"}}class E extends Error{constructor(a,b,c){super(`WorkSession project changed: ${a} (${b} -> ${c})`),this.name="WorkSessionProjectChangedError"}}class F extends Error{constructor(a,b,c){super(`WorkSession binding changed: ${a} (${b} -> ${c})`),this.name="WorkSessionBindingChangedError"}}class G extends Error{constructor(a){super(`WorkSession branch entry was not found: ${a}`),this.name="WorkSessionBranchEntryNotFoundError"}}class H extends Error{constructor(a){super(a),this.name="WorkSessionBranchBlockedError"}}class I extends Error{constructor(a,b){super(b),this.kind=a,this.name="WorkSessionBranchInvalidError"}}class J extends Error{constructor(a){super(`WorkSession project directory is invalid: ${a}`),this.name="WorkSessionDirectoryInvalidError"}}function x(a){return a instanceof Error&&"WorkSessionDirectoryInvalidError"===a.name}class K{constructor(a=(0,h.join)((0,e.M)(),"work-sessions.json")){this.storePath=a,this.workSessionsById=new Map,this.updateListeners=new Set,this.chat=new v.yO,this.hydrated=!1,this.operationTail=Promise.resolve();const b=this.readPersistedState();this.restoredRecords=b.workSessions,this.pinnedCount=b.pinnedCount,this.rewriteLegacyStore=b.rewriteLegacyStore,this.chat.subscribeRecordChanges((a,b,c)=>this.publishChatRecordChange(a,b,c))}initialize(){return this.runExclusive(()=>this.ensureHydrated())}listWorkSessions(){return this.runExclusive(async()=>(await this.ensureHydrated(),this.createSnapshot()))}refreshPluginMessages(){this.chat.refreshPluginMessages()}runPluginRestart(a){return this.runExclusive(async()=>{await this.ensureHydrated();let b=await this.chat.pauseForProcessRestart();try{let b=await a();return console.info("[Pi Desk][WorkSessionManage] 全部工作会话已冻结,等待插件重载"),b}catch(a){throw b(),a}})}subscribeUpdates(a){return this.updateListeners.add(a),()=>this.updateListeners.delete(a)}subscribeMessageEvents(a){return this.chat.subscribe(a)}subscribePluginPushEvents(a){return this.chat.subscribePluginPush(a)}async prepareChatSourceSyncs(a){await this.initialize();let b=a.find(a=>!this.chat.isCurrentSource(a.source));if(b)throw new v.dM(b.source);return await Promise.all(a.map(a=>this.chat.prepareSource(a.source).catch(b=>{if(this.chat.isCurrentSource(a.source))throw b}))),a.filter(a=>this.chat.isCurrentSource(a.source)).map(a=>{let b=this.chat.createSync(a.source,a.cursor);return{source:a.source,event:b.event,watermark:b.watermark}})}async getChatMessageDetail(a){return await this.initialize(),this.chat.getMessageDetail(a)}async getChatModelContext(a){return await this.initialize(),this.chat.getModelContext(a)}async getChatImage(a){return await this.initialize(),this.chat.getImage(a)}async sendChat(a){return await this.initialize(),this.chat.send(a)}async interruptChat(a){await this.initialize(),await this.chat.interrupt(a)}async compactChat(a){await this.initialize(),await this.chat.compact(a)}async reloadChat(a,b){await this.initialize(),await this.chat.reload(a,b)}async setChatPresentation(a,b){await this.initialize(),await this.chat.setPresentation(a,b)}async restoreChatQueue(a){return await this.initialize(),this.chat.restoreQueuedMessages(a)}async setChatModel(a){await this.initialize(),await this.chat.setModel(a)}async setChatCapabilityMode(a){await this.initialize(),await this.chat.setCapabilityMode(a)}getNativeUi(a){if(!this.chat.isCurrentSource(a))throw new v.dM(a);return(0,t.ls)(a.sessionId).nativeUi}async invokeSessionPluginMethod(a){return await this.initialize(),this.chat.invokePluginMethod(a)}async listNativeCommands(a){return await this.initialize(),j.WF.parse({commands:await this.chat.listNativeCommands(a.source)})}async executeNativeCommand(a){await this.initialize(),await this.chat.executeNativeCommand(a.source,a.command,a.args??"")}async listNativeTools(a){return await this.initialize(),j.RH.parse({tools:await this.chat.listNativeTools(a.source)})}async executeDirectBash(a){return await this.initialize(),j.uU.parse(await this.chat.executeDirectBash(a.source,{command:a.command,excludeFromContext:a.excludeFromContext}))}async abortDirectBash(a){await this.initialize(),await this.chat.abortDirectBash(a.source)}async listModels(a){let b=m.eW.parse(a);await this.initialize();let c=this.workSessionsById.get(b);if(!c)throw new B(b);return k.IM.parse(await (0,t.ls)(c.sessionId).listModels())}async acknowledgeCompleted(a){let b=m.eW.parse(a);if(await this.initialize(),!this.workSessionsById.has(b))throw new B(b);return this.chat.acknowledgeCompleted(b)}setWorkSessionArrangement(a,b){let c=a.map(a=>m.eW.parse(a)),d=m.MT.parse(b);return this.runExclusive(async()=>{await this.ensureHydrated();let a=Array.from(this.workSessionsById.keys());if(c.length!==a.length||d>c.length||new Set(c).size!==c.length||c.some(a=>!this.workSessionsById.has(a)))throw new A;if(c.every((b,c)=>b===a[c])&&d===this.pinnedCount)return this.createSnapshot();let b=c.map(a=>this.workSessionsById.get(a));for(let a of(this.workSessionsById.clear(),b))this.workSessionsById.set(a.workId,a);this.pinnedCount=d,this.persist();let e=this.createSnapshot();return this.publishUpdate({type:"snapshot",...e}),console.info("[Pi Desk][WorkSessionManage] 已更新工作会话排列",{workIds:c,pinnedCount:d}),e})}getWorkSession(a){let b=m.eW.parse(a);return this.runExclusive(async()=>(await this.ensureHydrated(),this.workSessionsById.get(b)??null))}getProjectPreviewContext(a,b){return this.workSessionsById.get(a.workId)!==a?null:this.chat.getProjectPreviewContext(a,b)}async replaceProjectGitBranch(a){let b=l.Yh.parse(a),c=await this.authorizeProjectFiles(b.workId,b.cwd),d=await (0,q.Ak)(c,b.repositoryRoot,b.target);return console.info("[Pi Desk][WorkSessionManage] 已切换 Git 分支",{workId:b.workId,cwd:c,repositoryRoot:b.repositoryRoot,targetType:b.target.type,targetName:b.target.name}),l.hr.parse({repository:d})}async addProjectGitBranch(a){let b=l.XV.parse(a),c=await this.authorizeProjectFiles(b.workId,b.cwd),d=await (0,q.bV)(c,b.repositoryRoot,b.name,b.startPoint);return console.info("[Pi Desk][WorkSessionManage] 已新建并切换 Git 分支",{workId:b.workId,cwd:c,repositoryRoot:b.repositoryRoot,branchName:b.name,startPointType:b.startPoint?.type??null,startPointName:b.startPoint?.name??null}),l.hr.parse({repository:d})}createWorkSession(a,b){let c,d=m.ik.parse(a),e=void 0===b?void 0:m.Kx.parse(b);try{c=(0,r.G2)(d)}catch{throw new J(d)}return this.runExclusive(async()=>{if(await this.ensureHydrated(),e){let a=this.findBoundWorkId(e);if(a)throw new C(e,a);if(!await (0,s.vg)(c,e))throw new D(c,e)}let a=await p.E.create((0,f.randomUUID)(),c,e);this.chat.addWorkSession(a),this.insertUnpinnedWorkSession(a),this.persist();let b=this.toListItem(a),d=this.createSnapshot();return this.publishUpdate({type:"snapshot",...d}),console.info("[Pi Desk][WorkSessionManage] 已创建工作会话",{workId:a.workId,cwd:a.cwd,sessionId:a.sessionId,creationType:e?"history":"empty"}),b})}renameWorkSession(a){let b=m.qL.parse(a);return this.runExclusive(async()=>{await this.ensureHydrated();let a=this.workSessionsById.get(b.workId);if(!a)throw new B(b.workId);this.assertSessionBinding(a,b.sessionId),await this.chat.setTitle(a,b.title)})}replaceWorkSession(a,b){let c=m.eW.parse(a),d=b?{cwd:m.ik.parse(b.cwd),sessionId:m.Kx.parse(b.sessionId)}:null;return this.runExclusive(async()=>{let a;await this.ensureHydrated();let b=this.workSessionsById.get(c);if(!b)throw new B(c);if(d&&b.cwd===d.cwd&&b.sessionId===d.sessionId)return this.createSnapshot();if(d){let a=this.findBoundWorkId(d.sessionId);if(a&&a!==c)throw new C(d.sessionId,a)}let e=this.toListItem(b);await this.chat.pauseWorkSession(c);try{a=await p.E.create(c,d?.cwd??b.cwd,d?.sessionId),await this.chat.replaceWorkSession(b,a)}catch(a){throw this.chat.resumeWorkSession(c),a}this.workSessionsById.set(c,a),this.persist();let f=this.toListItem(a),g=this.createSnapshot(),h=this.toChanges(e,f);return h&&this.publishUpdate({type:"update",workId:c,changes:h}),console.info("[Pi Desk][WorkSessionManage] 已替换 Pi 会话",{workId:c,replacementType:d?"history":"empty",previousCwd:b.cwd,previousSessionId:b.sessionId,cwd:a.cwd,sessionId:a.sessionId,branchId:a.branchId}),g})}getWorkSessionTree(a){let b=o.i0.parse(a);return this.runExclusive(async()=>{await this.ensureHydrated();let a=this.workSessionsById.get(b.workId);if(!a)throw new B(b.workId);return this.assertSessionBinding(a,b.sessionId),o.u1.parse(await (0,t.ls)(a.sessionId).readSessionTree())})}getWorkSessionTreeEntry(a){let b=o.iW.parse(a);return this.runExclusive(async()=>{await this.ensureHydrated();let a=this.workSessionsById.get(b.workId);if(!a)throw new B(b.workId);this.assertSessionBinding(a,b.sessionId);try{return o.Cn.parse(await (0,t.ls)(a.sessionId).readSessionTreeEntryDetail(b.entryId))}catch(a){if(a instanceof u.Ns)throw new G(b.entryId);throw a}})}branchWorkSession(a){let b=o.g$.parse(a);return this.runExclusive(async()=>{let a;await this.ensureHydrated();let c=this.workSessionsById.get(b.workId);if(!c)throw new B(b.workId);if(this.assertSessionBinding(c,b.sessionId),"tree"===b.action){let a,d=this.toListItem(c);await this.chat.pauseWorkSession(c.workId);try{(a=await c.branch(b.entryId)).changed?await this.chat.refreshWorkSession(c):this.chat.resumeWorkSession(c.workId)}catch(a){if(c.branchId!==d.branchId){await this.chat.refreshWorkSession(c);let a=this.toChanges(d,this.toListItem(c));a&&this.publishUpdate({type:"update",workId:c.workId,changes:a})}else this.chat.resumeWorkSession(c.workId);this.throwBranchError(a,b.entryId)}let e=this.toListItem(c),f=this.toChanges(d,e);f&&this.publishUpdate({type:"update",workId:c.workId,changes:f});let g=this.createSnapshot();return console.info("[Pi Desk][WorkSessionManage] 已切换当前 JSONL 分支",{workId:c.workId,cwd:c.cwd,sessionId:c.sessionId,entryId:b.entryId,branchId:c.branchId,changed:a.changed}),o.WJ.parse({...g,targetWorkId:c.workId,editorText:a.editorText})}"clone"===b.action&&await this.chat.pauseWorkSession(c.workId);try{a=await c.createBranchedSession((0,f.randomUUID)(),"fork"===b.action?{position:"before",entryId:b.entryId}:{position:"at"}),this.chat.addWorkSession(a.workSession)}catch(a){this.throwBranchError(a,"entryId"in b?b.entryId:null)}finally{"clone"===b.action&&this.chat.resumeWorkSession(c.workId)}let d=a.workSession;this.insertUnpinnedWorkSession(d),this.persist();let e=this.createSnapshot();return this.publishUpdate({type:"snapshot",...e}),console.info("[Pi Desk][WorkSessionManage] 已创建分支 WorkSession",{action:b.action,sourceWorkId:c.workId,sourceSessionId:c.sessionId,workId:d.workId,cwd:d.cwd,entryId:"entryId"in b?b.entryId:null,sessionId:d.sessionId,branchId:d.branchId}),o.WJ.parse({...e,targetWorkId:d.workId,editorText:a.editorText})})}removeWorkSession(a){let b=m.eW.parse(a);return this.runExclusive(async()=>{await this.ensureHydrated();let a=this.workSessionsById.get(b);if(!a)return!1;let c=Array.from(this.workSessionsById.keys()).indexOf(b);return await this.chat.pauseWorkSession(b),await this.chat.removeWorkSession(a),this.workSessionsById.delete(b),c<this.pinnedCount&&(this.pinnedCount-=1),this.persist(),this.publishUpdate({type:"delete",workId:b}),console.info("[Pi Desk][WorkSessionManage] 已删除工作会话",{workId:b,pinnedCount:this.pinnedCount}),!0})}async ensureHydrated(){if(this.hydrated)return;let a=performance.now();console.info("[Pi Desk][WorkSessionManage] 开始恢复工作会话",{workSessionCount:this.restoredRecords.length});let b=await Promise.all(this.restoredRecords.map(a=>p.E.create(a.workId,a.cwd,a.sessionId))),c=performance.now();await this.chat.initialize(b);let d=performance.now();for(let e of(console.info("[Pi Desk][WorkSessionManage] 工作会话恢复完成",{workSessionCount:b.length,durationMs:Math.round(d-a),sessionOpenMs:Math.round(c-a),messageProjectionMs:Math.round(d-c)}),b))this.workSessionsById.set(e.workId,e);this.hydrated=!0,this.rewriteLegacyStore&&(this.persist(),this.rewriteLegacyStore=!1,console.info("[Pi Desk][WorkSessionManage] 已升级工作会话持久化格式",{workSessionCount:b.length,pinnedCount:this.pinnedCount}))}async authorizeProjectFiles(a,b){await this.initialize();let c=this.workSessionsById.get(a);if(!c)throw new B(a);if(c.cwd!==b)throw new E(a,b,c.cwd);return c.cwd}findBoundWorkId(a){for(let b of this.workSessionsById.values())if(b.sessionId===a)return b.workId}insertUnpinnedWorkSession(a){let b=this.orderedWorkSessions();for(let c of(b.splice(this.pinnedCount,0,a),this.workSessionsById.clear(),b))this.workSessionsById.set(c.workId,c)}assertSessionBinding(a,b){if(a.sessionId!==b)throw new F(a.workId,b,a.sessionId)}throwBranchError(a,b){if(a instanceof u.Ns)throw new G(b??"");if(a instanceof u.dX)throw new I("fork-target","只有用户消息可以 Fork");if(a instanceof t.er)throw new I("clone-empty","当前会话还没有可克隆的消息");if(a instanceof t.Wo)throw new H(a.message);throw a}orderedWorkSessions(){return Array.from(this.workSessionsById.values())}createSnapshot(){return m.kg.parse({workSessions:this.orderedWorkSessions().map(a=>this.toListItem(a)),pinnedCount:this.pinnedCount})}toRecord(a){return m.ER.parse({workId:a.workId,cwd:a.cwd,sessionId:a.sessionId})}toListItem(a){let b=this.chat.metadataFor(a);return m.MY.parse({...this.toRecord(a),branchId:a.branchId,projectName:(0,h.basename)(a.cwd)||a.cwd,sessionTitle:b.sessionTitle,status:this.chat.statusFor(a),messageCounts:b.messageCounts,lastMessageUpdatedAt:b.lastMessageUpdatedAt})}toChanges(a,b){let c={};return a.cwd!==b.cwd&&(c.cwd=b.cwd),a.sessionId!==b.sessionId&&(c.sessionId=b.sessionId),a.branchId!==b.branchId&&(c.branchId=b.branchId),a.projectName!==b.projectName&&(c.projectName=b.projectName),a.sessionTitle!==b.sessionTitle&&(c.sessionTitle=b.sessionTitle),a.status!==b.status&&(c.status=b.status),(a.messageCounts.user!==b.messageCounts.user||a.messageCounts.total!==b.messageCounts.total)&&(c.messageCounts=b.messageCounts),a.lastMessageUpdatedAt!==b.lastMessageUpdatedAt&&(c.lastMessageUpdatedAt=b.lastMessageUpdatedAt),0===Object.keys(c).length?null:n.KE.parse(c)}publishChatRecordChange(a,b,c){if(!this.hydrated)return;let d=this.workSessionsById.get(a);if(!d)return;let e=this.toListItem(d),f=this.toChanges({...e,...b,status:c},e);f&&this.publishUpdate({type:"update",workId:a,changes:f})}publishUpdate(a){let b=n.ds.parse(a);for(let a of[...this.updateListeners])try{a(b)}catch(a){console.error("[Pi Desk][WorkSessionManage] 推送工作会话变化失败",{updateType:b.type,errorName:a instanceof Error?a.name:"UnknownError"})}}readPersistedState(){if(!(0,g.existsSync)(this.storePath))return{workSessions:[],pinnedCount:0,rewriteLegacyStore:!1};let a=JSON.parse((0,g.readFileSync)(this.storePath,"utf8")),b=Array.isArray(a),c=b?z.parse({workSessions:m.TO.parse(a),pinnedCount:0}):z.parse(a),d=new Set,e=new Set;for(let a of c.workSessions){if(d.has(a.workId))throw Error(`Duplicate persisted workId: ${a.workId}`);if(e.has(a.sessionId))throw Error(`Duplicate persisted sessionId binding: ${a.sessionId}`);d.add(a.workId),e.add(a.sessionId)}return{...c,rewriteLegacyStore:b}}persist(){let a=z.parse({workSessions:this.orderedWorkSessions().map(a=>this.toRecord(a)),pinnedCount:this.pinnedCount});(0,g.mkdirSync)((0,h.dirname)(this.storePath),{recursive:!0});let b=`${this.storePath}.${process.pid}.${(0,f.randomUUID)()}.tmp`;try{(0,g.writeFileSync)(b,`${JSON.stringify(a,null,2)}
|
|
1
|
+
"use strict";exports.id=23054,exports.ids=[23054],exports.modules={18477:(a,b,c)=>{c.d(b,{KE:()=>l,ds:()=>n,kM:()=>o});var d=c(59473),e=c(54733),f=c(58311),g=c(2364),h=c(2002);let i=d.Ik({}).strict(),j=d.Ik({workId:e.eW}).strict(),k=d.Ik({workId:e.eW}).strict(),l=d.Ik({cwd:e.ik.optional(),sessionId:e.Kx.optional(),branchId:d.Yj().min(1).optional(),projectName:d.Yj().trim().min(1).optional(),sessionTitle:d.Yj().trim().min(1).nullable().optional(),status:e.jw.optional(),messageCounts:e.AA.optional(),lastMessageUpdatedAt:g.k.nullable().optional()}).strict().refine(a=>Object.keys(a).length>0,{message:"work session changes cannot be empty"}),m=d.Ik({workSessions:d.YO(e.MY),pinnedCount:e.MT,appRuntime:f.GR}).strict().refine(a=>a.pinnedCount<=a.workSessions.length,{message:"pinnedCount cannot exceed work session count",path:["pinnedCount"]}),n=d.gM("type",[d.Ik({type:d.eu("snapshot"),workSessions:d.YO(e.MY),pinnedCount:e.MT}).strict().refine(a=>a.pinnedCount<=a.workSessions.length,{message:"pinnedCount cannot exceed work session count",path:["pinnedCount"]}),d.Ik({type:d.eu("update"),workId:e.eW,changes:l}).strict(),d.Ik({type:d.eu("delete"),workId:e.eW}).strict()]),o=Object.freeze({list:(0,h.Vc)({path:"work-sessions/list",inputSchema:i,outputSchema:m}),acknowledgeCompleted:(0,h.Vc)({path:"work-sessions/ack-completed",inputSchema:j,outputSchema:k}),update:(0,h._G)({path:"work-sessions/update",bodySchema:n})})},23024:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{E:()=>g});var e=c(72498),f=a([e]);e=(f.then?(await f)():f)[0];class g{constructor(a,b){this.workId=a,this.runtime=b}static async create(a,b,c){let d=c?await e.vC.open(b,c):e.vC.create(b);return new g(a,d)}get cwd(){return this.runtime.cwd}get sessionId(){return this.runtime.sessionId}get branchId(){return this.runtime.branchId}async branch(a){let b=await this.runtime.branch(a);return{changed:b.changed,editorText:b.editorText}}async createBranchedSession(a,b){let c=this.runtime.createBranchedSession(b);return{workSession:new g(a,c.runtime),editorText:c.editorText}}async send(a){return this.runtime.send(a)}async interrupt(){await this.runtime.interrupt()}async restoreQueuedMessages(){return this.runtime.restoreQueuedMessages()}async setTitle(a){await this.runtime.setTitle(a)}async setModel(a){await this.runtime.setModel(a)}}d()}catch(a){d(a)}})},23054:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{HK:()=>F,JJ:()=>y,Jl:()=>I,Jv:()=>G,Ki:()=>C,VH:()=>D,XM:()=>B,if:()=>H,k1:()=>A,qm:()=>x});var e=c(71473),f=c(77598),g=c(73024),h=c(76760),i=c(59473),j=c(25084),k=c(40529),l=c(77394),m=c(54733),n=c(18477),o=c(33270),p=c(23024),q=c(52913),r=c(65129),s=c(65209),t=c(72498),u=c(46524),v=c(47574),w=a([e,p,r,s,t,v]);[e,p,r,s,t,v]=w.then?(await w)():w;let z=i.Ik({workSessions:m.TO,pinnedCount:m.MT}).strict().refine(a=>a.pinnedCount<=a.workSessions.length,{message:"pinnedCount cannot exceed persisted work session count",path:["pinnedCount"]});class A extends Error{constructor(){super("WorkSession order does not match the current collection"),this.name="WorkSessionOrderConflictError"}}class B extends Error{constructor(a){super(`WorkSession not found: ${a}`),this.name="WorkSessionNotFoundError"}}class C extends Error{constructor(a,b){super(`Pi session ${a} is already bound to work session ${b}`),this.name="WorkSessionSessionConflictError"}}class D extends Error{constructor(a,b){super(`Pi session ${b} was not found in ${a}`),this.name="WorkSessionHistoryNotFoundError"}}class E extends Error{constructor(a,b,c){super(`WorkSession project changed: ${a} (${b} -> ${c})`),this.name="WorkSessionProjectChangedError"}}class F extends Error{constructor(a,b,c){super(`WorkSession binding changed: ${a} (${b} -> ${c})`),this.name="WorkSessionBindingChangedError"}}class G extends Error{constructor(a){super(`WorkSession branch entry was not found: ${a}`),this.name="WorkSessionBranchEntryNotFoundError"}}class H extends Error{constructor(a){super(a),this.name="WorkSessionBranchBlockedError"}}class I extends Error{constructor(a,b){super(b),this.kind=a,this.name="WorkSessionBranchInvalidError"}}class J extends Error{constructor(a){super(`WorkSession project directory is invalid: ${a}`),this.name="WorkSessionDirectoryInvalidError"}}function x(a){return a instanceof Error&&"WorkSessionDirectoryInvalidError"===a.name}class K{constructor(a=(0,h.join)((0,e.M)(),"work-sessions.json")){this.storePath=a,this.workSessionsById=new Map,this.updateListeners=new Set,this.chat=new v.yO,this.hydrated=!1,this.operationTail=Promise.resolve();const b=this.readPersistedState();this.restoredRecords=b.workSessions,this.pinnedCount=b.pinnedCount,this.rewriteLegacyStore=b.rewriteLegacyStore,this.chat.subscribeRecordChanges((a,b,c)=>this.publishChatRecordChange(a,b,c))}initialize(){return this.runExclusive(()=>this.ensureHydrated())}listWorkSessions(){return this.runExclusive(async()=>(await this.ensureHydrated(),this.createSnapshot()))}runPluginRestart(a){return this.runExclusive(async()=>{await this.ensureHydrated();let b=await this.chat.pauseForProcessRestart();try{let b=await a();return console.info("[Pi Desk][WorkSessionManage] 全部工作会话已冻结,等待插件重载"),b}catch(a){throw b(),a}})}subscribeUpdates(a){return this.updateListeners.add(a),()=>this.updateListeners.delete(a)}subscribeMessageEvents(a){return this.chat.subscribe(a)}subscribePluginPushEvents(a){return this.chat.subscribePluginPush(a)}async prepareChatSourceSyncs(a){await this.initialize();let b=a.find(a=>!this.chat.isCurrentSource(a.source));if(b)throw new v.dM(b.source);return await Promise.all(a.map(a=>this.chat.prepareSource(a.source).catch(b=>{if(this.chat.isCurrentSource(a.source))throw b}))),a.filter(a=>this.chat.isCurrentSource(a.source)).map(a=>{let b=this.chat.createSync(a.source,a.cursor);return{source:a.source,event:b.event,watermark:b.watermark}})}async getChatMessageDetail(a){return await this.initialize(),this.chat.getMessageDetail(a)}async getChatModelContext(a){return await this.initialize(),this.chat.getModelContext(a)}async getChatImage(a){return await this.initialize(),this.chat.getImage(a)}async sendChat(a){return await this.initialize(),this.chat.send(a)}async interruptChat(a){await this.initialize(),await this.chat.interrupt(a)}async compactChat(a){await this.initialize(),await this.chat.compact(a)}async reloadChat(a,b){await this.initialize(),await this.chat.reload(a,b)}async setChatPresentation(a,b){await this.initialize(),await this.chat.setPresentation(a,b)}async restoreChatQueue(a){return await this.initialize(),this.chat.restoreQueuedMessages(a)}async setChatModel(a){await this.initialize(),await this.chat.setModel(a)}async setChatCapabilityMode(a){await this.initialize(),await this.chat.setCapabilityMode(a)}getNativeUi(a){if(!this.chat.isCurrentSource(a))throw new v.dM(a);return(0,t.ls)(a.sessionId).nativeUi}async invokeSessionPluginMethod(a){return await this.initialize(),this.chat.invokePluginMethod(a)}async listNativeCommands(a){return await this.initialize(),j.WF.parse({commands:await this.chat.listNativeCommands(a.source)})}async executeNativeCommand(a){await this.initialize(),await this.chat.executeNativeCommand(a.source,a.command,a.args??"")}async listNativeTools(a){return await this.initialize(),j.RH.parse({tools:await this.chat.listNativeTools(a.source)})}async executeDirectBash(a){return await this.initialize(),j.uU.parse(await this.chat.executeDirectBash(a.source,{command:a.command,excludeFromContext:a.excludeFromContext}))}async abortDirectBash(a){await this.initialize(),await this.chat.abortDirectBash(a.source)}async listModels(a){let b=m.eW.parse(a);await this.initialize();let c=this.workSessionsById.get(b);if(!c)throw new B(b);return k.IM.parse(await (0,t.ls)(c.sessionId).listModels())}async acknowledgeCompleted(a){let b=m.eW.parse(a);if(await this.initialize(),!this.workSessionsById.has(b))throw new B(b);return this.chat.acknowledgeCompleted(b)}setWorkSessionArrangement(a,b){let c=a.map(a=>m.eW.parse(a)),d=m.MT.parse(b);return this.runExclusive(async()=>{await this.ensureHydrated();let a=Array.from(this.workSessionsById.keys());if(c.length!==a.length||d>c.length||new Set(c).size!==c.length||c.some(a=>!this.workSessionsById.has(a)))throw new A;if(c.every((b,c)=>b===a[c])&&d===this.pinnedCount)return this.createSnapshot();let b=c.map(a=>this.workSessionsById.get(a));for(let a of(this.workSessionsById.clear(),b))this.workSessionsById.set(a.workId,a);this.pinnedCount=d,this.persist();let e=this.createSnapshot();return this.publishUpdate({type:"snapshot",...e}),console.info("[Pi Desk][WorkSessionManage] 已更新工作会话排列",{workIds:c,pinnedCount:d}),e})}getWorkSession(a){let b=m.eW.parse(a);return this.runExclusive(async()=>(await this.ensureHydrated(),this.workSessionsById.get(b)??null))}getProjectPreviewContext(a,b){return this.workSessionsById.get(a.workId)!==a?null:this.chat.getProjectPreviewContext(a,b)}async replaceProjectGitBranch(a){let b=l.Yh.parse(a),c=await this.authorizeProjectFiles(b.workId,b.cwd),d=await (0,q.Ak)(c,b.repositoryRoot,b.target);return console.info("[Pi Desk][WorkSessionManage] 已切换 Git 分支",{workId:b.workId,cwd:c,repositoryRoot:b.repositoryRoot,targetType:b.target.type,targetName:b.target.name}),l.hr.parse({repository:d})}async addProjectGitBranch(a){let b=l.XV.parse(a),c=await this.authorizeProjectFiles(b.workId,b.cwd),d=await (0,q.bV)(c,b.repositoryRoot,b.name,b.startPoint);return console.info("[Pi Desk][WorkSessionManage] 已新建并切换 Git 分支",{workId:b.workId,cwd:c,repositoryRoot:b.repositoryRoot,branchName:b.name,startPointType:b.startPoint?.type??null,startPointName:b.startPoint?.name??null}),l.hr.parse({repository:d})}createWorkSession(a,b){let c,d=m.ik.parse(a),e=void 0===b?void 0:m.Kx.parse(b);try{c=(0,r.G2)(d)}catch{throw new J(d)}return this.runExclusive(async()=>{if(await this.ensureHydrated(),e){let a=this.findBoundWorkId(e);if(a)throw new C(e,a);if(!await (0,s.vg)(c,e))throw new D(c,e)}let a=await p.E.create((0,f.randomUUID)(),c,e);this.chat.addWorkSession(a),this.insertUnpinnedWorkSession(a),this.persist();let b=this.toListItem(a),d=this.createSnapshot();return this.publishUpdate({type:"snapshot",...d}),console.info("[Pi Desk][WorkSessionManage] 已创建工作会话",{workId:a.workId,cwd:a.cwd,sessionId:a.sessionId,creationType:e?"history":"empty"}),b})}renameWorkSession(a){let b=m.qL.parse(a);return this.runExclusive(async()=>{await this.ensureHydrated();let a=this.workSessionsById.get(b.workId);if(!a)throw new B(b.workId);this.assertSessionBinding(a,b.sessionId),await this.chat.setTitle(a,b.title)})}replaceWorkSession(a,b){let c=m.eW.parse(a),d=b?{cwd:m.ik.parse(b.cwd),sessionId:m.Kx.parse(b.sessionId)}:null;return this.runExclusive(async()=>{let a;await this.ensureHydrated();let b=this.workSessionsById.get(c);if(!b)throw new B(c);if(d&&b.cwd===d.cwd&&b.sessionId===d.sessionId)return this.createSnapshot();if(d){let a=this.findBoundWorkId(d.sessionId);if(a&&a!==c)throw new C(d.sessionId,a)}let e=this.toListItem(b);await this.chat.pauseWorkSession(c);try{a=await p.E.create(c,d?.cwd??b.cwd,d?.sessionId),await this.chat.replaceWorkSession(b,a)}catch(a){throw this.chat.resumeWorkSession(c),a}this.workSessionsById.set(c,a),this.persist();let f=this.toListItem(a),g=this.createSnapshot(),h=this.toChanges(e,f);return h&&this.publishUpdate({type:"update",workId:c,changes:h}),console.info("[Pi Desk][WorkSessionManage] 已替换 Pi 会话",{workId:c,replacementType:d?"history":"empty",previousCwd:b.cwd,previousSessionId:b.sessionId,cwd:a.cwd,sessionId:a.sessionId,branchId:a.branchId}),g})}getWorkSessionTree(a){let b=o.i0.parse(a);return this.runExclusive(async()=>{await this.ensureHydrated();let a=this.workSessionsById.get(b.workId);if(!a)throw new B(b.workId);return this.assertSessionBinding(a,b.sessionId),o.u1.parse(await (0,t.ls)(a.sessionId).readSessionTree())})}getWorkSessionTreeEntry(a){let b=o.iW.parse(a);return this.runExclusive(async()=>{await this.ensureHydrated();let a=this.workSessionsById.get(b.workId);if(!a)throw new B(b.workId);this.assertSessionBinding(a,b.sessionId);try{return o.Cn.parse(await (0,t.ls)(a.sessionId).readSessionTreeEntryDetail(b.entryId))}catch(a){if(a instanceof u.Ns)throw new G(b.entryId);throw a}})}branchWorkSession(a){let b=o.g$.parse(a);return this.runExclusive(async()=>{let a;await this.ensureHydrated();let c=this.workSessionsById.get(b.workId);if(!c)throw new B(b.workId);if(this.assertSessionBinding(c,b.sessionId),"tree"===b.action){let a,d=this.toListItem(c);await this.chat.pauseWorkSession(c.workId);try{(a=await c.branch(b.entryId)).changed?await this.chat.refreshWorkSession(c):this.chat.resumeWorkSession(c.workId)}catch(a){if(c.branchId!==d.branchId){await this.chat.refreshWorkSession(c);let a=this.toChanges(d,this.toListItem(c));a&&this.publishUpdate({type:"update",workId:c.workId,changes:a})}else this.chat.resumeWorkSession(c.workId);this.throwBranchError(a,b.entryId)}let e=this.toListItem(c),f=this.toChanges(d,e);f&&this.publishUpdate({type:"update",workId:c.workId,changes:f});let g=this.createSnapshot();return console.info("[Pi Desk][WorkSessionManage] 已切换当前 JSONL 分支",{workId:c.workId,cwd:c.cwd,sessionId:c.sessionId,entryId:b.entryId,branchId:c.branchId,changed:a.changed}),o.WJ.parse({...g,targetWorkId:c.workId,editorText:a.editorText})}"clone"===b.action&&await this.chat.pauseWorkSession(c.workId);try{a=await c.createBranchedSession((0,f.randomUUID)(),"fork"===b.action?{position:"before",entryId:b.entryId}:{position:"at"}),this.chat.addWorkSession(a.workSession)}catch(a){this.throwBranchError(a,"entryId"in b?b.entryId:null)}finally{"clone"===b.action&&this.chat.resumeWorkSession(c.workId)}let d=a.workSession;this.insertUnpinnedWorkSession(d),this.persist();let e=this.createSnapshot();return this.publishUpdate({type:"snapshot",...e}),console.info("[Pi Desk][WorkSessionManage] 已创建分支 WorkSession",{action:b.action,sourceWorkId:c.workId,sourceSessionId:c.sessionId,workId:d.workId,cwd:d.cwd,entryId:"entryId"in b?b.entryId:null,sessionId:d.sessionId,branchId:d.branchId}),o.WJ.parse({...e,targetWorkId:d.workId,editorText:a.editorText})})}removeWorkSession(a){let b=m.eW.parse(a);return this.runExclusive(async()=>{await this.ensureHydrated();let a=this.workSessionsById.get(b);if(!a)return!1;let c=Array.from(this.workSessionsById.keys()).indexOf(b);return await this.chat.pauseWorkSession(b),await this.chat.removeWorkSession(a),this.workSessionsById.delete(b),c<this.pinnedCount&&(this.pinnedCount-=1),this.persist(),this.publishUpdate({type:"delete",workId:b}),console.info("[Pi Desk][WorkSessionManage] 已删除工作会话",{workId:b,pinnedCount:this.pinnedCount}),!0})}async ensureHydrated(){if(this.hydrated)return;let a=performance.now();console.info("[Pi Desk][WorkSessionManage] 开始恢复工作会话",{workSessionCount:this.restoredRecords.length});let b=await Promise.all(this.restoredRecords.map(a=>p.E.create(a.workId,a.cwd,a.sessionId))),c=performance.now();await this.chat.initialize(b);let d=performance.now();for(let e of(console.info("[Pi Desk][WorkSessionManage] 工作会话恢复完成",{workSessionCount:b.length,durationMs:Math.round(d-a),sessionOpenMs:Math.round(c-a),messageProjectionMs:Math.round(d-c)}),b))this.workSessionsById.set(e.workId,e);this.hydrated=!0,this.rewriteLegacyStore&&(this.persist(),this.rewriteLegacyStore=!1,console.info("[Pi Desk][WorkSessionManage] 已升级工作会话持久化格式",{workSessionCount:b.length,pinnedCount:this.pinnedCount}))}async authorizeProjectFiles(a,b){await this.initialize();let c=this.workSessionsById.get(a);if(!c)throw new B(a);if(c.cwd!==b)throw new E(a,b,c.cwd);return c.cwd}findBoundWorkId(a){for(let b of this.workSessionsById.values())if(b.sessionId===a)return b.workId}insertUnpinnedWorkSession(a){let b=this.orderedWorkSessions();for(let c of(b.splice(this.pinnedCount,0,a),this.workSessionsById.clear(),b))this.workSessionsById.set(c.workId,c)}assertSessionBinding(a,b){if(a.sessionId!==b)throw new F(a.workId,b,a.sessionId)}throwBranchError(a,b){if(a instanceof u.Ns)throw new G(b??"");if(a instanceof u.dX)throw new I("fork-target","只有用户消息可以 Fork");if(a instanceof t.er)throw new I("clone-empty","当前会话还没有可克隆的消息");if(a instanceof t.Wo)throw new H(a.message);throw a}orderedWorkSessions(){return Array.from(this.workSessionsById.values())}createSnapshot(){return m.kg.parse({workSessions:this.orderedWorkSessions().map(a=>this.toListItem(a)),pinnedCount:this.pinnedCount})}toRecord(a){return m.ER.parse({workId:a.workId,cwd:a.cwd,sessionId:a.sessionId})}toListItem(a){let b=this.chat.metadataFor(a);return m.MY.parse({...this.toRecord(a),branchId:a.branchId,projectName:(0,h.basename)(a.cwd)||a.cwd,sessionTitle:b.sessionTitle,status:this.chat.statusFor(a),messageCounts:b.messageCounts,lastMessageUpdatedAt:b.lastMessageUpdatedAt})}toChanges(a,b){let c={};return a.cwd!==b.cwd&&(c.cwd=b.cwd),a.sessionId!==b.sessionId&&(c.sessionId=b.sessionId),a.branchId!==b.branchId&&(c.branchId=b.branchId),a.projectName!==b.projectName&&(c.projectName=b.projectName),a.sessionTitle!==b.sessionTitle&&(c.sessionTitle=b.sessionTitle),a.status!==b.status&&(c.status=b.status),(a.messageCounts.user!==b.messageCounts.user||a.messageCounts.total!==b.messageCounts.total)&&(c.messageCounts=b.messageCounts),a.lastMessageUpdatedAt!==b.lastMessageUpdatedAt&&(c.lastMessageUpdatedAt=b.lastMessageUpdatedAt),0===Object.keys(c).length?null:n.KE.parse(c)}publishChatRecordChange(a,b,c){if(!this.hydrated)return;let d=this.workSessionsById.get(a);if(!d)return;let e=this.toListItem(d),f=this.toChanges({...e,...b,status:c},e);f&&this.publishUpdate({type:"update",workId:a,changes:f})}publishUpdate(a){let b=n.ds.parse(a);for(let a of[...this.updateListeners])try{a(b)}catch(a){console.error("[Pi Desk][WorkSessionManage] 推送工作会话变化失败",{updateType:b.type,errorName:a instanceof Error?a.name:"UnknownError"})}}readPersistedState(){if(!(0,g.existsSync)(this.storePath))return{workSessions:[],pinnedCount:0,rewriteLegacyStore:!1};let a=JSON.parse((0,g.readFileSync)(this.storePath,"utf8")),b=Array.isArray(a),c=b?z.parse({workSessions:m.TO.parse(a),pinnedCount:0}):z.parse(a),d=new Set,e=new Set;for(let a of c.workSessions){if(d.has(a.workId))throw Error(`Duplicate persisted workId: ${a.workId}`);if(e.has(a.sessionId))throw Error(`Duplicate persisted sessionId binding: ${a.sessionId}`);d.add(a.workId),e.add(a.sessionId)}return{...c,rewriteLegacyStore:b}}persist(){let a=z.parse({workSessions:this.orderedWorkSessions().map(a=>this.toRecord(a)),pinnedCount:this.pinnedCount});(0,g.mkdirSync)((0,h.dirname)(this.storePath),{recursive:!0});let b=`${this.storePath}.${process.pid}.${(0,f.randomUUID)()}.tmp`;try{(0,g.writeFileSync)(b,`${JSON.stringify(a,null,2)}
|
|
2
2
|
`,"utf8"),(0,g.renameSync)(b,this.storePath)}finally{(0,g.existsSync)(b)&&(0,g.unlinkSync)(b)}}runExclusive(a){let b=this.operationTail.then(a,a);return this.operationTail=b.then(()=>void 0,()=>void 0),b}}function y(){return globalThis.__piDeskWorkSessionManage||(globalThis.__piDeskWorkSessionManage=new K),globalThis.__piDeskWorkSessionManage}d()}catch(a){d(a)}})},25084:(a,b,c)=>{c.d(b,{QV:()=>u,RH:()=>p,WF:()=>k,uU:()=>r});var d=c(59473),e=c(96089),f=c(2002),g=c(24187);let h=d.k5(["extension","prompt","skill"]),i=d.Ik({name:d.Yj().trim().min(1).max(128),description:d.Yj().max(500).nullable(),source:h}).strict(),j=d.Ik({source:e.R}).strict(),k=d.Ik({commands:d.YO(i)}).strict(),l=d.Ik({source:e.R,command:d.Yj().trim().min(1).max(128),args:d.Yj().max(32768).optional()}).strict(),m=d.Ik({}).strict(),n=d.Ik({name:d.Yj().trim().min(1).max(128),description:d.Yj(),parameters:g.Dz,active:d.zM(),exposure:d.k5(["direct","model-only","codemode","deferred","hidden"]),source:d.Yj().nullable(),blockedByMode:d.zM()}).strict(),o=d.Ik({source:e.R}).strict(),p=d.Ik({tools:d.YO(n)}).strict(),q=d.Ik({source:e.R,command:d.Yj().min(1).max(32768),excludeFromContext:d.zM()}).strict(),r=d.Ik({output:d.Yj(),exitCode:d.ai().int().nullable(),cancelled:d.zM(),truncated:d.zM(),fullOutputPath:d.Yj().nullable()}).strict(),s=d.Ik({source:e.R}).strict(),t=d.Ik({}).strict(),u=Object.freeze({commandsList:(0,f.Vc)({path:"pi/commands/list",inputSchema:j,outputSchema:k}),commandExecute:(0,f.Vc)({path:"pi/commands/execute",inputSchema:l,outputSchema:m,timeoutMs:3e5}),toolsList:(0,f.Vc)({path:"pi/tools/list",inputSchema:o,outputSchema:p}),bashExecute:(0,f.Vc)({path:"pi/bash/execute",inputSchema:q,outputSchema:r,timeoutMs:12e4}),bashAbort:(0,f.Vc)({path:"pi/bash/abort",inputSchema:s,outputSchema:t})})},33270:(a,b,c)=>{c.d(b,{Cn:()=>l,WJ:()=>n,g$:()=>m,i0:()=>i,iW:()=>k,u1:()=>j});var d=c(59473),e=c(2364),f=c(54733);let g=d.k5(["user","assistant","tool","bash","custom_message","compaction","branch_summary","custom","model_change","thinking_level_change","session_info","label"]),h=d.Ik({entryId:f.C3,parentEntryId:f.C3.nullable(),timestampMs:e.k,kind:g,preview:d.Yj(),label:d.Yj().trim().min(1).nullable()}).strict(),i=d.Ik({workId:f.eW,sessionId:f.Kx}).strict(),j=d.Ik({sessionId:f.Kx,leafEntryId:f.C3.nullable(),nodes:d.YO(h)}).strict().superRefine((a,b)=>{let c=new Set;for(let[d,e]of a.nodes.entries())c.has(e.entryId)&&b.addIssue({code:"custom",message:"work session tree entryId values must be unique",path:["nodes",d,"entryId"]}),c.add(e.entryId);null===a.leafEntryId||c.has(a.leafEntryId)||b.addIssue({code:"custom",message:"work session tree leafEntryId must reference a node",path:["leafEntryId"]})}),k=d.Ik({workId:f.eW,sessionId:f.Kx,entryId:f.C3}).strict(),l=d.Ik({entryId:f.C3,kind:g,content:d.Yj(),truncated:d.zM()}).strict();d.k5(["tree","fork","clone"]);let m=d.gM("action",[d.Ik({action:d.eu("tree"),workId:f.eW,sessionId:f.Kx,entryId:f.C3}).strict(),d.Ik({action:d.eu("fork"),workId:f.eW,sessionId:f.Kx,entryId:f.C3}).strict(),d.Ik({action:d.eu("clone"),workId:f.eW,sessionId:f.Kx}).strict()]),n=d.Ik({workSessions:d.YO(f.MY),pinnedCount:f.MT,targetWorkId:f.eW,editorText:d.Yj().nullable()}).strict().superRefine((a,b)=>{a.pinnedCount>a.workSessions.length&&b.addIssue({code:"custom",message:"pinnedCount cannot exceed work session count",path:["pinnedCount"]}),a.workSessions.some(b=>b.workId===a.targetWorkId)||b.addIssue({code:"custom",message:"targetWorkId must reference a returned work session",path:["targetWorkId"]})})},40529:(a,b,c)=>{c.d(b,{IM:()=>l,kJ:()=>k});var d=c(59473),e=c(54733),f=c(62977);let g=d.Yj().trim().min(1),h=d.Yj().trim().min(1),i=d.Ik({provider:g,modelId:h,name:d.Yj().trim().min(1),input:d.YO(d.k5(["text","image"])).min(1),kind:d.k5(["physical","virtual"]),contextWindow:d.ai().int().positive().max(Number.MAX_SAFE_INTEGER).nullable(),thinkingLevels:d.YO(f.$).min(1)}).strict(),j=d.Ik({provider:g,modelId:h,thinkingLevel:f.$,color:d.Yj().trim().min(1).nullable()}).strict(),k=d.Ik({workId:e.eW}).strict(),l=d.Ik({models:d.YO(i),presets:d.YO(j)}).strict()},58311:(a,b,c)=>{c.d(b,{$C:()=>A,A8:()=>E,GR:()=>q,MQ:()=>D,Pq:()=>B,UH:()=>j,Wh:()=>r,Xo:()=>o,YT:()=>z});var d=c(59473),e=c(41904),f=c(20369),g=c(24187),h=c(2364);let i=d.Yj().uuid(),j=d.Yj().trim().min(1).max(256),k=d.k5(["info","success","warning","error"]),l=d.Yj().trim().min(1).max(120),m=d.Yj().trim().max(320).nullable(),n=d.Ik({type:d.eu("plugin"),pluginName:g.tv,name:g.f7,data:g.Dz}).strict(),o=d.Ik({notificationId:i,level:k,title:l,description:m,createdAt:h.k,event:n.nullable()}).strict(),p=d.g1(g.tv,g.Dz),q=d.Ik({mode:d.k5(["normal","basic"]).default("normal"),notifications:d.YO(o),plugins:p,capabilityModes:f.Wu,settings:e.J.default({region:{locale:"en",timeZone:"UTC"}})}).strict(),r=d.Ik({level:k.optional(),title:l.optional(),description:m.optional(),event:n.nullable().optional()}).strict().refine(a=>Object.keys(a).length>0,{message:"notification changes cannot be empty"}),s=d.Ik({type:d.eu("add"),notification:o}).strict(),t=d.Ik({type:d.eu("update"),notificationId:i,changes:r}).strict(),u=d.Ik({type:d.eu("delete"),notificationId:i}).strict(),v=d.gM("type",[s,t,u]),w=d.Ik({pluginName:g.tv,state:g.Dz.nullable()}).strict(),x=d.Ik({key:d.eu("capabilityModes"),update:f.Wu}).strict(),y=d.Ik({key:d.eu("settings"),update:e.J}).strict();d.gM("key",[y,x,d.Ik({key:d.eu("notifications"),update:v}).strict(),d.Ik({key:d.eu("plugins"),update:w}).strict()]);let z=d.KC([y.extend({type:d.eu("update")}),x.extend({type:d.eu("update")}),d.Ik({type:d.eu("replace"),runtime:q}).strict(),d.Ik({type:d.eu("update"),key:d.eu("notifications"),update:v}).strict(),d.Ik({type:d.eu("update"),key:d.eu("plugins"),update:w}).strict()]),A=d.gM("key",[d.Ik({key:d.eu("notifications"),update:u}).strict(),d.Ik({key:d.eu("settings"),update:d.Ik({region:e.a.unwrap().partial().strict().refine(a=>Object.keys(a).length>0,"地区更新不能为空")}).strict()}).strict()]),B=d.Ik({}).strict(),C=d.Ik({name:g.f7,data:g.Dz}).strict(),D=d.Ik({key:j.optional(),level:k,title:l,description:d.Yj().trim().max(320).optional(),event:C.optional()}).strict(),E=d.Ik({level:k.optional(),title:l.optional(),description:m.optional()}).strict().refine(a=>Object.keys(a).length>0,{message:"plugin notification changes cannot be empty"})},65129:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{G2:()=>l,W1:()=>j,XO:()=>o,pm:()=>k});var e=c(51455),f=c(73024),g=c(76760),h=c(7499),i=a([h]);h=(i.then?(await i)():i)[0];class p extends Error{constructor(a){super(`Pi project directory is invalid: ${a}`),this.name="L4PiDirectoryInvalidError"}}class q extends Error{constructor(a){super(`Pi project directory cannot be read: ${a}`),this.name="L4PiDirectoryReadError"}}function j(a){return a instanceof Error&&"L4PiDirectoryInvalidError"===a.name}function k(a){return a instanceof Error&&"L4PiDirectoryReadError"===a.name}function l(a){let b=(0,g.resolve)(a);try{if(!(0,f.statSync)(b).isDirectory())throw new p(b)}catch(a){if(a instanceof p)throw a;throw new p(b)}return b}function m(){return new Set((0,h.Us)().map(h.sC))}async function n(a,b,c,d){if(c)return!0;if(!d)return!1;try{return(await (0,e.stat)((0,g.join)(a,b))).isDirectory()}catch{return!1}}async function o(a){let b;if(null===a){let a,b,c;return a=(0,g.parse)(process.cwd()).root,b="win32"===process.platform?function(){let a=[];for(let b=65;b<=90;b+=1){let c=`${String.fromCharCode(b)}:\\`;try{(0,f.statSync)(c).isDirectory()&&a.push({cwd:c,name:c})}catch{}}return a}():[{cwd:a,name:a}],c=m(),{cwd:null,parentCwd:null,directories:b.filter(a=>!c.has((0,h.sC)(a.cwd)))}}let c=l(a);try{b=await (0,e.readdir)(c,{withFileTypes:!0})}catch{throw new q(c)}let d=m(),i=(await Promise.all(b.map(async a=>{if(!await n(c,a.name,a.isDirectory(),a.isSymbolicLink()))return null;let b=(0,g.resolve)(c,a.name);return d.has((0,h.sC)(b))?null:{cwd:b,name:a.name}}))).filter(a=>null!==a).sort((a,b)=>a.name.localeCompare(b.name,void 0,{numeric:!0,sensitivity:"base"})),j=(0,g.parse)(c).root;return{cwd:c,parentCwd:(0,h.sC)(c)===(0,h.sC)(j)?null:(0,g.dirname)(c),directories:i}}d()}catch(a){d(a)}})},77394:(a,b,c)=>{c.d(b,{XV:()=>p,Yh:()=>o,hr:()=>q});var d=c(59473),e=c(66951),f=c(63719),g=c(54733);let h=e.y2,i=d.Ik({workId:g.eW,cwd:g.ik}).strict(),j=e.Ww,k=e.cP,l=e.zp,m=e.u2;d.Ik({repositories:d.YO(m).max(h)}).strict(),i.extend({repositoryRoot:j}).strict();let n=e.zt,o=i.extend({repositoryRoot:j,target:n}).strict(),p=i.extend({repositoryRoot:j,name:k,startPoint:n.nullable()}).strict(),q=d.Ik({repository:l}).strict();i.extend({repositoryRoot:j,path:f._g}).strict()}};
|