@jingyi0605/codingns 0.8.1 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/codingns.mjs +180 -0
- package/dist/public/assets/{AdaptiveButlerPage-b7s6F_sd.js → AdaptiveButlerPage-CJw8Ae62.js} +3 -3
- package/dist/public/assets/App-BOHBGFOd.js +30 -0
- package/dist/public/assets/{BootstrapPage-jFfl7KNK.js → BootstrapPage-BxHQT4nA.js} +1 -1
- package/dist/public/assets/{ConversationPage-sj_rn4q0.js → ConversationPage-DWFsF6BB.js} +6 -6
- package/dist/public/assets/{DesktopDetachPreviewPage-C5c88SOX.js → DesktopDetachPreviewPage-DOgEjYEf.js} +1 -1
- package/dist/public/assets/DesktopModal-D_A8sgQU.js +1 -0
- package/dist/public/assets/DesktopWindowPage-DK7L7osV.js +2 -0
- package/dist/public/assets/FileContextPanel-BdCoubcJ.js +1 -0
- package/dist/public/assets/GitSidebar-BeZ0hj7A.js +6 -0
- package/dist/public/assets/MobileCreateSessionSheet-DfLMVu8q.js +1 -0
- package/dist/public/assets/MobileSheet-5kZ-w-gU.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-_I0t7cC_.js → MobileTopHeaderFrame-lcp2GscV.js} +1 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-C6JMiOq_.js +1 -0
- package/dist/public/assets/PluginAccessOverview-DGcKAMQl.js +1 -0
- package/dist/public/assets/PluginContainerPage-BlY-xJDh.js +1 -0
- package/dist/public/assets/PluginDetailPage-CAJ7LFpD.js +1 -0
- package/dist/public/assets/PluginsListPage-BxZG1NyT.js +1 -0
- package/dist/public/assets/{RelayConnectEntryPage-CMtDWyGS.js → RelayConnectEntryPage-CfNO_TIl.js} +1 -1
- package/dist/public/assets/ServerSettingsModal-by36Z_5k.js +1 -0
- package/dist/public/assets/SessionIndexPage-DkBp9Mqz.js +1 -0
- package/dist/public/assets/SettingsPage-C-ASmJAG.js +2 -0
- package/dist/public/assets/TerminalManagerPanel-NVZRxxmH.js +1 -0
- package/dist/public/assets/{TerminalPage-CBIKHI33.js → TerminalPage-C4LNoPBp.js} +3 -3
- package/dist/public/assets/TerminalRuntimeFallbackModal-Bzum5nZ0.js +1 -0
- package/dist/public/assets/ToolFilesPage-47zbdgTW.js +1 -0
- package/dist/public/assets/ToolGitPage-Fuk_b_jg.js +1 -0
- package/dist/public/assets/ToolProcessesPage-sWSMWD-9.js +1 -0
- package/dist/public/assets/ToolsHomePage-R1mZlbZi.js +1 -0
- package/dist/public/assets/WorkbenchLandingPage-CqmiFH2u.js +1 -0
- package/dist/public/assets/WorkbenchLayout-OFi6CWgH.js +244 -0
- package/dist/public/assets/WorkbenchModal-C7qoQElW.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-BAQe_E0O.js +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-DhKa6e9y.js +1 -0
- package/dist/public/assets/WorkspaceDetailPage-BPsrFffw.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-KAtqZOAb.js +1 -0
- package/dist/public/assets/{client-runtime-manager-CdJP7nUp.js → client-runtime-manager-wmCJZKYd.js} +1 -1
- package/dist/public/assets/file-tree-icon-Mg1DiBRX.js +590 -0
- package/dist/public/assets/{index-VVxfF0s5.css → index-C4t-vvqk.css} +1 -1
- package/dist/public/assets/index-CL97fwWB.js +42 -0
- package/dist/public/assets/{login-direct-candidate-resolver-C-mo698r.js → login-direct-candidate-resolver-BOAgTuUf.js} +1 -1
- package/dist/public/assets/plugin-permission-copy-Cq99cnzV.js +1 -0
- package/dist/public/assets/plugins-api-BQTV5DOp.js +1 -0
- package/dist/public/assets/{preferences-service-CnaTvZq2.js → preferences-service-DJxbEEeg.js} +1 -1
- package/dist/public/assets/realtime-client-CLafKzzJ.js +1 -0
- package/dist/public/assets/{relay-entry-D7OgZZN-.js → relay-entry-D-LfvdiX.js} +1 -1
- package/dist/public/assets/{terminal-runtime-meta-BCtAYB0E.js → terminal-runtime-meta-BJmy8dyK.js} +1 -1
- package/dist/public/assets/useRegisteredDebugTemplates-DQAWVdCo.js +1 -0
- package/dist/public/assets/workbench-navigation-MEzCSmsK.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +1 -0
- package/dist/server/config/env.js +4 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js +1 -1
- package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js.map +1 -1
- package/dist/server/modules/channels/wechat-claw-client.d.ts +51 -0
- package/dist/server/modules/channels/wechat-claw-client.js +245 -0
- package/dist/server/modules/channels/wechat-claw-client.js.map +1 -0
- package/dist/server/modules/file/file-access-guard.d.ts +2 -0
- package/dist/server/modules/file/file-access-guard.js +24 -2
- package/dist/server/modules/file/file-access-guard.js.map +1 -1
- package/dist/server/modules/file/file-controller.d.ts +153 -1
- package/dist/server/modules/file/file-controller.js +215 -1
- package/dist/server/modules/file/file-controller.js.map +1 -1
- package/dist/server/modules/file/file-preview-link-service.d.ts +2 -0
- package/dist/server/modules/file/file-preview-link-service.js +5 -1
- package/dist/server/modules/file/file-preview-link-service.js.map +1 -1
- package/dist/server/modules/file/runtime/codingns-workspace-bridge.js +911 -0
- package/dist/server/modules/file/workspace-file-bridge-service.d.ts +126 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js +471 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js.map +1 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.d.ts +42 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js +304 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js.map +1 -0
- package/dist/server/modules/model-switch/cc-switch-adapter.js +1 -1
- package/dist/server/modules/model-switch/cc-switch-adapter.js.map +1 -1
- package/dist/server/modules/plugins/plugin-controller.d.ts +131 -0
- package/dist/server/modules/plugins/plugin-controller.js +277 -0
- package/dist/server/modules/plugins/plugin-controller.js.map +1 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.d.ts +38 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js +178 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-manifest.d.ts +8 -0
- package/dist/server/modules/plugins/plugin-manifest.js +420 -0
- package/dist/server/modules/plugins/plugin-manifest.js.map +1 -0
- package/dist/server/modules/plugins/plugin-permission-service.d.ts +49 -0
- package/dist/server/modules/plugins/plugin-permission-service.js +267 -0
- package/dist/server/modules/plugins/plugin-permission-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-process-runner.d.ts +21 -0
- package/dist/server/modules/plugins/plugin-process-runner.js +127 -0
- package/dist/server/modules/plugins/plugin-process-runner.js.map +1 -0
- package/dist/server/modules/plugins/plugin-registry-service.d.ts +41 -0
- package/dist/server/modules/plugins/plugin-registry-service.js +238 -0
- package/dist/server/modules/plugins/plugin-registry-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-runtime-service.d.ts +55 -0
- package/dist/server/modules/plugins/plugin-runtime-service.js +252 -0
- package/dist/server/modules/plugins/plugin-runtime-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.d.ts +21 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.js +83 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.d.ts +31 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.js +232 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-static-service.d.ts +11 -0
- package/dist/server/modules/plugins/plugin-static-service.js +145 -0
- package/dist/server/modules/plugins/plugin-static-service.js.map +1 -0
- package/dist/server/modules/presentation/presentation-controller.d.ts +3 -0
- package/dist/server/modules/presentation/presentation-controller.js +11 -0
- package/dist/server/modules/presentation/presentation-controller.js.map +1 -1
- package/dist/server/modules/presentation/presentation-export-task-service.d.ts +6 -0
- package/dist/server/modules/presentation/presentation-export-task-service.js +52 -8
- package/dist/server/modules/presentation/presentation-export-task-service.js.map +1 -1
- package/dist/server/modules/presentation/presentation-pptx-export-service.js +200 -14
- package/dist/server/modules/presentation/presentation-pptx-export-service.js.map +1 -1
- package/dist/server/modules/presentation/presentation-renderer.d.ts +50 -0
- package/dist/server/modules/presentation/presentation-renderer.js +450 -37
- package/dist/server/modules/presentation/presentation-renderer.js.map +1 -1
- package/dist/server/modules/tasks/task-types.d.ts +2 -0
- package/dist/server/modules/tasks/task-types.js +2 -0
- package/dist/server/modules/tasks/task-types.js.map +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js.map +1 -1
- package/dist/server/routes/files.js +40 -0
- package/dist/server/routes/files.js.map +1 -1
- package/dist/server/routes/plugins-public.d.ts +3 -0
- package/dist/server/routes/plugins-public.js +5 -0
- package/dist/server/routes/plugins-public.js.map +1 -0
- package/dist/server/routes/plugins.d.ts +3 -0
- package/dist/server/routes/plugins.js +19 -0
- package/dist/server/routes/plugins.js.map +1 -0
- package/dist/server/routes/presentation.js +1 -0
- package/dist/server/routes/presentation.js.map +1 -1
- package/dist/server/server/create-server.d.ts +20 -0
- package/dist/server/server/create-server.js +47 -1
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/shared/http/error-handler.js +10 -6
- package/dist/server/shared/http/error-handler.js.map +1 -1
- package/dist/server/shared/runtime/better-sqlite3.d.ts +5 -0
- package/dist/server/shared/runtime/better-sqlite3.js +6 -0
- package/dist/server/shared/runtime/better-sqlite3.js.map +1 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.d.ts +8 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.js +49 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-definition-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-definition-repository.js +84 -0
- package/dist/server/storage/repositories/plugin-definition-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.d.ts +9 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.js +74 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.d.ts +12 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.js +142 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-run-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-run-repository.js +111 -0
- package/dist/server/storage/repositories/plugin-run-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.js +86 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.js.map +1 -0
- package/dist/server/storage/sqlite/client.d.ts +2 -2
- package/dist/server/storage/sqlite/client.js +250 -1
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +140 -0
- package/dist/server/types/domain.d.ts +122 -0
- package/package.json +10 -3
- package/scripts/postinstall.mjs +248 -11
- package/vendor/better-sqlite3-win32-x64-node22/LICENSE +21 -0
- package/vendor/better-sqlite3-win32-x64-node22/README.md +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/README.upstream.md +99 -0
- package/vendor/better-sqlite3-win32-x64-node22/binding.gyp +38 -0
- package/vendor/better-sqlite3-win32-x64-node22/build/Release/better_sqlite3.node +0 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/common.gypi +68 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/copy.js +31 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/defines.gypi +41 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/download.sh +122 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/patches/1208.patch +15 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3.c +265994 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3.h +13968 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3ext.h +730 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3.gyp +80 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/test_extension.c +21 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/database.js +90 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/index.js +3 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/aggregate.js +43 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/backup.js +67 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/function.js +31 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/inspect.js +7 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/pragma.js +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/serialize.js +16 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/table.js +189 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/transaction.js +78 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/wrappers.js +54 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/sqlite-error.js +20 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/util.js +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/package.json +38 -0
- package/vendor/better-sqlite3-win32-x64-node22/scripts/verify-runtime.cjs +42 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/addon.cpp +47 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/better_sqlite3.cpp +74 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/backup.cpp +120 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/backup.hpp +36 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/database.cpp +417 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/database.hpp +103 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement-iterator.cpp +113 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement-iterator.hpp +50 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement.cpp +383 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement.hpp +58 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/bind-map.cpp +73 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/binder.cpp +193 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/constants.cpp +172 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-aggregate.cpp +121 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-function.cpp +59 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-table.cpp +409 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/data-converter.cpp +17 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/data.cpp +194 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/helpers.cpp +109 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/macros.cpp +83 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/query-macros.cpp +71 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/row-builder.cpp +49 -0
- package/vendor/node-pty-fork/README.md +1 -0
- package/vendor/node-pty-fork/scripts/runtime-install-context.cjs +24 -0
- package/vendor/node-pty-fork/scripts/verify-runtime.cjs +8 -0
- package/vendor/node-pty-fork/scripts/verify-runtime.test.cjs +30 -0
- package/vendor-src/better-sqlite3-win32-x64-node22/README.md +12 -0
- package/dist/public/assets/App-B0q8uDA-.js +0 -30
- package/dist/public/assets/DesktopWindowPage-BdKUZrKG.js +0 -2
- package/dist/public/assets/FileContextPanel-lM5mBcfn.js +0 -1
- package/dist/public/assets/GitSidebar-CmXAhyjo.js +0 -6
- package/dist/public/assets/MobileCreateSessionSheet-CceV0-AH.js +0 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-DhaM9fgx.js +0 -1
- package/dist/public/assets/ServerSettingsModal-Rkgn3jft.js +0 -1
- package/dist/public/assets/SessionIndexPage-BOumP3ij.js +0 -1
- package/dist/public/assets/SettingsPage-vx_c-00-.js +0 -2
- package/dist/public/assets/TerminalManagerPanel-D9JHCS6d.js +0 -1
- package/dist/public/assets/TerminalRuntimeFallbackModal-W5NjqFEz.js +0 -1
- package/dist/public/assets/ToolFilesPage-DWtpaN_7.js +0 -1
- package/dist/public/assets/ToolGitPage-MpGXsw4_.js +0 -1
- package/dist/public/assets/ToolProcessesPage-B1jHQKhZ.js +0 -1
- package/dist/public/assets/ToolsHomePage-CJrn8ZFl.js +0 -1
- package/dist/public/assets/WorkbenchLandingPage-CJQ1V5U-.js +0 -1
- package/dist/public/assets/WorkbenchLayout-D48i71PU.js +0 -244
- package/dist/public/assets/WorkbenchModal-BYNuMIoV.js +0 -1
- package/dist/public/assets/WorkbenchShellRoute-CGKjy4J-.js +0 -1
- package/dist/public/assets/WorkspaceDebugDetailPage-DCAYgays.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-D5v-nUIi.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-I5G1p5SR.js +0 -1
- package/dist/public/assets/file-tree-icon-BFwaPxKs.js +0 -590
- package/dist/public/assets/index-CjewzOUG.js +0 -42
- package/dist/public/assets/model-switch-api-Br0ivfe5.js +0 -1
- package/dist/public/assets/realtime-client-BlQRqVmm.js +0 -1
- package/dist/public/assets/useRegisteredDebugTemplates-CXmxu69X.js +0 -1
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{b as l,t as n,j as e,A as qn}from"./index-CjewzOUG.js";import{u as ki,e as Gi,f as $i,g as Hn}from"./App-B0q8uDA-.js";import{u as Ui,a7 as ut,b as Rn,bv as wn,w as Bi,bw as Vi,bx as Wi,bl as zi,by as Pn,bz as Ki,bA as Ii,bo as Xi,bB as qi,bn as Yi,bC as Zi,bm as Yn,bD as Ji,bu as Qi,bE as An,Z as es,c as ts,bF as ns,bG as is,bH as ss}from"./WorkbenchLayout-D48i71PU.js";import{S as as,y as rs,z as os,e as ls}from"./model-switch-api-Br0ivfe5.js";import{F as cs,r as Wt,a as zt}from"./file-tree-icon-BFwaPxKs.js";import{W as Oe}from"./WorkbenchModal-BYNuMIoV.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-D7OgZZN-.js";const Ot=56,Dn=28,kt=72,dt=8,Ln=960,_n=60*1e3,Fn=20,On=9,kn=9,Gt=68,O=12,mt=8,Kt=260,us=120,$t=6e4,ht={authMode:"none",username:"",password:"",token:"",rememberOnHost:!1};function Fs({className:a,workspaceId:i,panelActive:u=!0,externalWindowMode:h=!1,workbenchShellOverrides:g}){const j=ki(),f=Gi(),x=Ui(),{subscribeGitSnapshot:b,requestGitRefresh:v,addGitSnapshotListener:H,requestNavigationRefresh:S,selectWorkspace:T,upsertNavigationSession:p}={...x,...g},[o,m]=l.useState(null),[y,R]=l.useState(null),[C,M]=l.useState([]),[F,P]=l.useState(0),[X,se]=l.useState(null),[be,pt]=l.useState(!1),[U,xe]=l.useState(null),[ae,q]=l.useState(null),[ye,je]=l.useState(""),[$e,B]=l.useState(!1),[N,A]=l.useState(!1),[ai,Zt]=l.useState([]),[te,Jt]=l.useState(!0),[ne,z]=l.useState(!1),[k,ri]=l.useState(()=>typeof window<"u"?window.innerWidth<=Ln:!1),[bt,V]=l.useState([]),[Ce,K]=l.useState(null),[Ne,re]=l.useState("unstaged"),[ve,Y]=l.useState(null),[oe,Z]=l.useState(null),[oi,xt]=l.useState(!1),[li,yt]=l.useState(null),[ci,Ue]=l.useState(!1),[Qt,Be]=l.useState(null),[_,Se]=l.useState(null),[en,Te]=l.useState(null),[ui,Me]=l.useState(!1),[Ee,le]=l.useState(null),[ie,jt]=l.useState(!1),[di,ce]=l.useState(!1),[Ve,Ct]=l.useState("push"),[We,ze]=l.useState([]),[mi,Ke]=l.useState(!1),[Ie,Xe]=l.useState(new Set),[hi,ue]=l.useState(new Map),[qe,tn]=l.useState({}),[gi,de]=l.useState(!1),[Ye,nn]=l.useState(null),[D,J]=l.useState(ht),[sn,an]=l.useState("generic"),[rn,Ze]=l.useState(null),[G,Nt]=l.useState(null),[$,vt]=l.useState(null),[on,ln]=l.useState(Ot),[St,Tt]=l.useState(!1),[cn,He]=l.useState(null),[fi,Re]=l.useState(null),un=l.useRef(null),dn=l.useRef(null),mn=l.useRef(null),hn=l.useRef(null),gn=l.useRef(null),fn=l.useRef(null),Mt=l.useRef(null),we=l.useRef(new Map),Je=l.useRef(new Map),Pe=l.useRef(0),pn=l.useRef(u),bn=l.useRef(u),Qe=l.useRef(null),{showToast:E}=$i(),xn=f.isDesktop&&!k;l.useEffect(()=>{ut("git_sidebar.props",{workspaceId:i,externalWindowMode:h})},[h,i]),l.useEffect(()=>{bn.current=u},[u]),l.useEffect(()=>{Zt([]),Jt(!0),P(0),se(null),pt(!1),q(null),je(""),z(!1),V([]),K(null),re("unstaged"),Y(null),Z(null),xt(!1),yt(null),Ue(!1),Be(null),Se(null),Te(null),Me(!1),le(null),jt(!1),ce(!1),Ct("push"),ze([]),Xe(new Set),ue(new Map),tn({}),de(!1),nn(null),J(ht),an("generic"),Ze(null),Nt(null),vt(null),Tt(!1),ln(Ot),He(null),Re(null),Je.current.clear(),we.current.clear()},[i]),l.useEffect(()=>{function t(){ri(window.innerWidth<=Ln)}return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),l.useEffect(()=>{if(!St)return;const t=document.body.style.cursor,s=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";function r(d){vn(d.clientY)}function c(){Tt(!1)}return window.addEventListener("pointermove",r),window.addEventListener("pointerup",c),()=>{document.body.style.cursor=t,document.body.style.userSelect=s,window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",c)}},[St]),l.useEffect(()=>{var c,d;if(!(i!=null&&i.trim())){Qe.current=null,m(null),R(null),M([]),P(0),se(null),xe(null),B(!1);return}const t=i.trim(),s=Rn(ke(t),_n),r=Bt(s);if(ut("git_sidebar.snapshot",{workspaceId:t,cached:r,cachedHistoryCount:((c=s==null?void 0:s.history)==null?void 0:c.length)??0,cachedChangedCount:((d=s==null?void 0:s.status)==null?void 0:d.changes.length)??0}),r&&s){Et(s,t),B(!1);return}Qe.current=null,wn(ke(t)),m(null),R(null),M([]),P(0),se(null),xe(null),B(!0)},[i]),l.useEffect(()=>{if(i!=null&&i.trim())return H(t=>{var s,r,c;t.workspaceId===i.trim()&&(ut("git_sidebar.snapshot_received",{workspaceId:t.workspaceId,changedCount:((s=t.status)==null?void 0:s.changes.length)??0,historyCount:t.history.length,branchCount:(((r=t.branches)==null?void 0:r.local.length)??0)+(((c=t.branches)==null?void 0:c.remote.length)??0)}),Et(t,t.workspaceId),B(!1))})},[H,i]),l.useEffect(()=>{if(!(i!=null&&i.trim()))return;const t=i.trim(),s=Rn(ke(t),_n),r=Bt(s)?(s==null?void 0:s.revision)??null:null;b(t,{knownRevision:r}),bn.current&&I()},[v,b,i]),l.useEffect(()=>{const t=pn.current;pn.current=u,i!=null&&i.trim()&&!t&&u&&v(i.trim(),{knownRevision:y})},[u,v,y,i]),l.useEffect(()=>{const t=i==null?void 0:i.trim();if(!t||Qe.current!==t)return;const s={revision:y,status:o,history:C,historyTotalCount:F,historyNextCursor:X,branches:U};if(!Bt(s)){wn(ke(t));return}Bi(ke(t),s)},[U,C,X,F,y,o,i]),l.useEffect(()=>{if(!o||!ae)return;o.changes.find(s=>s.path===ae)||q(null)},[ae,o]),l.useEffect(()=>{bs(hn.current)},[ye]),l.useEffect(()=>{k||(V([]),K(null),Y(null),Ze(null))},[k]),l.useEffect(()=>{if(!o){V([]);return}const t=new Set(o.changes.map(s=>s.path));V(s=>s.filter(r=>t.has(r)))},[o]);function pi(){const t=mn.current;if(!t)return;t.querySelectorAll(".git-tree-shell").forEach(r=>{r.scrollTop=0})}function Et(t,s){Qe.current=(s==null?void 0:s.trim())??(i==null?void 0:i.trim())??null,R(typeof t.revision=="string"?t.revision:null),m(t.status),M(Array.isArray(t.history)?t.history:[]),P(typeof t.historyTotalCount=="number"?t.historyTotalCount:0),se(typeof t.historyNextCursor=="string"?t.historyNextCursor:null),xe(t.branches??null)}function I(t){i!=null&&i.trim()&&(B(!0),ut("git_sidebar.refresh_requested",{workspaceId:i.trim(),resetTreeScroll:!1}),v(i.trim(),{knownRevision:y}))}async function Ht(t){if(!(i!=null&&i.trim()))return;const s=i.trim();B(!0);try{const[r,c,d]=await Promise.all([zi(s),Pn(s,Fn,null),Ki(s)]);Et({status:r,history:c.items,historyTotalCount:c.totalCount,historyNextCursor:c.nextCursor,branches:d}),v(s),t!=null&&t.resetTreeScroll&&requestAnimationFrame(()=>{pi()})}catch(r){E({title:L(r,n("git.panelLoadFailed")),tone:"error"})}finally{B(!1)}}async function et(){if(!(!i||!X||be)){pt(!0);try{const t=await Pn(i,Fn,X);M(s=>{const r=new Set(s.map(d=>d.commitHash)),c=t.items.filter(d=>!r.has(d.commitHash));return[...s,...c]}),P(t.totalCount),se(t.nextCursor)}catch(t){E({title:L(t,n("git.panelLoadFailed")),tone:"error"})}finally{pt(!1)}}}function bi(t){if(!te||be||!X)return;const s=t.currentTarget;s.scrollHeight-s.scrollTop-s.clientHeight<=40&&et()}async function xi(){if(i){A(!0);try{const t=await Wi(i,"ai");je(t.validation.normalizedDraft.subject||t.draft.subject)}catch(t){E({title:L(t,n("git.draftFailed")),tone:"error"})}finally{A(!1)}}}async function tt(t,s){if(i&&t.length){A(!0);try{const r=s?await qi(i,t):await Yi(i,t);m(r),q(t[t.length-1]??null),V(c=>c.filter(d=>!t.includes(d))),K(null),I()}catch(r){B(!1),E({title:L(r,n("git.stageFailed")),tone:"error"})}finally{A(!1)}}}async function Rt(t){if(i&&t.length){A(!0);try{const s=await Ji(i,t);m(s),t.includes(ae??"")&&q(null),V(r=>r.filter(c=>!t.includes(c))),K(null),I()}catch(s){B(!1),E({title:L(s,n("git.discardFailed")),tone:"error"})}finally{A(!1)}}}async function yi(){if(!(!i||!ye.trim())){A(!0);try{await Ii(i,gs(ye)),E({title:n("git.commitSuccess"),tone:"success"}),je(""),q(null),I()}catch(t){E({title:L(t,n("git.commitFailed")),tone:"error"})}finally{A(!1)}}}async function ji(){if(i!=null&&i.trim()){A(!0),B(!0);try{const t=await Vi(i.trim());m(t),M([]),P(0),se(null),xe(null),E({title:n("git.initSuccess"),tone:"success"}),I()}catch(t){E({title:L(t,n("git.initFailed")),tone:"error"})}finally{A(!1),B(!1)}}}async function wt(){const t=i==null?void 0:i.trim();if(!t)return[];const s=await ns(t);return(i==null?void 0:i.trim())!==t?[]:(ze(s),s)}async function nt(t){const s=await wt(),r=gt(s,t);if(!r){E({title:n("git.noRemotes"),tone:"error"});return}const c=qe[r.name]??null;nn(r.name),an(vs(s,r.name)),J(Cs((c==null?void 0:c.auth)??null,(c==null?void 0:c.rememberOnHost)??!1)),de(!0)}async function Ci(){if(i!=null&&i.trim()){Ke(!0);try{const t=await wt();if(t.length===0){E({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){await nt(t[0].name);return}Ct("auth"),Xe(new Set),ue(new Map),ce(!0)}catch(t){E({title:L(t,n("git.remoteFailed")),tone:"error"})}finally{Ke(!1)}}}function Ni(){const t=Ye==null?void 0:Ye.trim();if(!t){de(!1);return}const s=Ns(D),r=sn==="github"?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder");if(D.authMode==="basic"){if(!D.username.trim()){E({title:n("shell.cloneUsernamePlaceholder"),tone:"error"});return}if(!D.password){E({title:r,tone:"error"});return}}if(D.authMode==="token"&&!D.token){E({title:n("shell.cloneTokenPlaceholder"),tone:"error"});return}tn(c=>{if(!s){const{[t]:d,...w}=c;return w}return{...c,[t]:{auth:s,rememberOnHost:D.rememberOnHost}}}),de(!1),E({title:s?n("git.remoteAuthSaved"):n("git.remoteAuthCleared"),description:s&&D.rememberOnHost?n("git.remoteAuthRememberHint"):void 0,tone:"success"})}async function yn(){if(i){Ke(!0);try{const t=await wt();if(t.length===0){E({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){jn([t[0].name]);return}Ct("push"),Xe(new Set),ue(new Map),ce(!0)}catch(t){E({title:L(t,n("git.remoteFailed")),tone:"error"})}finally{Ke(!1)}}}async function jn(t){if(!i||t.length===0)return;A(!0),ue(new Map);const s=new Map;let r=!1;try{for(const c of t){const d=qe[c]??null;try{const w=await An(i,"push",c,d==null?void 0:d.auth,(d==null?void 0:d.rememberOnHost)??!1);s.set(c,{ok:!0,summary:w.summary}),d!=null&&d.rememberOnHost&&d.auth&&ze(Oi=>Oi.map(Ft=>Ft.name===c?{...Ft,credentialConfigured:!0}:Ft))}catch(w){if(r=!0,s.set(c,{ok:!1,summary:L(w,n("git.remoteFailed"))}),ue(new Map(s)),Kn(w)){nt(c);return}}}ue(s),I(),r||(E({title:n("git.pushAllSuccess",{count:String(t.length)}),tone:"success"}),ce(!1))}finally{A(!1)}}async function Pt(t){if(i){if(t==="push"){z(!1),yn();return}A(!0);try{const s=In(We),r=s?qe[s]??null:null,c=await An(i,t,void 0,r==null?void 0:r.auth,(r==null?void 0:r.rememberOnHost)??!1);E({title:c.summary,tone:"success"}),s&&(r!=null&&r.rememberOnHost)&&r.auth&&ze(d=>d.map(w=>w.name===s?{...w,credentialConfigured:!0}:w)),z(!1),I()}catch(s){if(Kn(s)){nt(In(We));return}E({title:L(s,n("git.remoteFailed")),tone:"error"})}finally{A(!1)}}}async function me(){if(i){A(!0);try{const t=await Zi(i);je(t.commitSubject??""),E({title:t.summary||n("git.undoLastCommitSuccess"),tone:"success"}),z(!1),I()}catch(t){E({title:L(t,n("git.undoLastCommitFailed")),tone:"error"})}finally{A(!1)}}}async function vi(t){if(i){A(!0);try{const s=await is(i,t,!1);xe(s),z(!1),I()}catch(s){E({title:L(s,n("git.branchFailed")),tone:"error"})}finally{A(!1)}}}async function At(t){const s=i==null?void 0:i.trim();if(!s)throw new Error(n("git.panelLoadFailed"));const r=Je.current.get(t);if(r)return r;const c=await ss(s,t);return Je.current.set(t,c),c}async function Ae(t){Z(null),Y(null),yt(t),Be(null);const s=Je.current.get(t)??null;if(Se(s),Ue(!s),s)return;const r=Pe.current+1;Pe.current=r;try{const c=await At(t);if(Pe.current!==r)return;Se(c)}catch(c){if(Pe.current!==r)return;Be(L(c,n("git.commitDetailLoadFailed"))),Se(null)}finally{Pe.current===r&&Ue(!1)}}function Si(){yt(null),Ue(!1),Be(null),Se(null)}async function De(t){try{const s=await At(t);await W(s.versionLabel,n("git.copyCommitVersionSuccess"))}catch(s){E({title:L(s,n("git.commitDetailLoadFailed")),tone:"error"})}}function Le(t){Z(null),Y(null),Te(t),le(null),Me(!0)}function Ti(t){var r;const s=((r=C[0])==null?void 0:r.commitHash)===t.commitHash&&t.commitKind==="local";return[{id:`view-changes:${t.commitHash}`,label:n("git.viewCommitChanges"),onSelect:()=>void Ae(t.commitHash)},{id:`copy-hash:${t.commitHash}`,label:n("git.copyCommitHash"),onSelect:()=>void W(t.commitHash,n("git.copyCommitHashSuccess"))},{id:`copy-message:${t.commitHash}`,label:n("git.copyCommitMessage"),onSelect:()=>void W(pe(t),n("git.copyCommitMessageSuccess"))},{id:`copy-version:${t.commitHash}`,label:n("git.copyCommitVersion"),onSelect:()=>void De(t.commitHash)},{id:`explain:${t.commitHash}`,label:n("git.explainCommitAction"),onSelect:()=>Le(t.commitHash)},...s?[{id:`undo:${t.commitHash}`,label:n("git.undoLastCommit"),disabled:N,onSelect:()=>void me()}]:[]]}async function Cn(t){Z(null),Y(null),await Qi(Ti(t))}async function Mi(){var t,s;if(!(!i||!en||!Ee||ie)){jt(!0);try{const r=await At(en),c=await rs({workspaceId:i,provider:Ee,content:ps(r),clientRequestId:((s=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:s.call(t))??`git-explain-${Date.now()}-${Math.random().toString(16).slice(2)}`,permissionMode:es()}),d=c.session??await os(c.sessionId);p(d),S(),T(d.workspaceId),j(ts(d.workspaceId,d.sessionId)),Me(!1),Te(null),le(null),E({title:n("git.explainCommitStarted"),tone:"success"})}catch(r){E({title:L(r,n("git.explainCommitFailed")),tone:"error"})}finally{jt(!1)}}}function it(t){Zt(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t])}const Ei=450;function Nn(t){const s=Date.now(),r=un.current;return un.current={filePath:t,timestamp:s},(r==null?void 0:r.filePath)===t&&s-r.timestamp<=Ei}async function st(t,s){if(s.binary){E({title:n("git.binaryDiff"),tone:"info"});return}if(s.status==="A"||s.status==="?")Re(null),He(t);else if(i)try{const r=await Xi(i,t,s.staged);Re(r.content),He(t)}catch{Re(null),He(t)}}function at(t){q(t),K(null),V(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t])}function vn(t){const s=dn.current;if(!s||!Number.isFinite(t))return;const r=s.getBoundingClientRect(),c=r.height-dt;if(!Number.isFinite(r.top)||!Number.isFinite(r.height)||c<=0)return;const d=(t-r.top-dt/2)/c*100;if(!Number.isFinite(d))return;const w=Math.max(Dn,Math.min(kt,Math.round(d)));ln(w)}function Hi(t){t.preventDefault(),vn(t.clientY),Tt(!0)}const _e=(o==null?void 0:o.changes)??[],Q=_e.filter(t=>It(t,"staged")),he=_e.filter(t=>It(t,"unstaged")),Sn=Wn(Q,"staged"),Tn=Wn(he,"unstaged"),rt=new Set(ai),ot=new Set(bt),ge=zn(bt,_e,"staged"),fe=zn(bt,_e,"unstaged"),Dt=_e.length===0&&((o==null?void 0:o.snapshot.ahead)??0)>0,Ri=Q.length>0&&ye.trim().length>0,lt=(U==null?void 0:U.currentBranch)??(o==null?void 0:o.snapshot.branch)??n("common.unknown"),ct=gt(We,Ye),Fe=sn==="github",wi=Fe?n("git.remoteAuthDescriptionGithub"):n("git.remoteAuthDescription"),Pi=Fe?n("git.remoteAuthGithubPatLabel"):n("shell.clonePasswordLabel"),Ai=Fe?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder"),Di=Fe?n("git.remoteAuthGithubUsernamePlaceholder"):n("shell.cloneUsernamePlaceholder"),Lt=Number.isFinite(on)?on:Ot,Li=te?`minmax(120px, ${Lt}fr) ${dt}px minmax(140px, ${100-Lt}fr)`:`minmax(120px, 1fr) ${dt}px auto`,_i=ys(o);l.useEffect(()=>{Ce==="staged"&&ge.length===0&&K(null),Ce==="unstaged"&&fe.length===0&&K(null)},[Ce,ge.length,fe.length]),l.useEffect(()=>{if(!k)return;const t=he.length>0?"unstaged":Q.length>0?"staged":"history";re(s=>s==="unstaged"&&he.length>0||s==="staged"&&Q.length>0?s:t)},[k,Q.length,he.length]),l.useEffect(()=>{ve&&(C.some(t=>t.commitHash===ve)||Y(null))},[C,ve]),l.useEffect(()=>{oe&&(C.some(t=>t.commitHash===oe)||Z(null))},[oe,C]),l.useEffect(()=>{k&&Ne!=="history"&&ne&&z(!1)},[k,ne,Ne]),l.useLayoutEffect(()=>{if(k||!ne){Nt(null);return}function t(){const r=gn.current,c=fn.current;!r||!c||typeof window>"u"||Nt(Xn(r.getBoundingClientRect(),{width:c.getBoundingClientRect().width||Kt,height:c.getBoundingClientRect().height||c.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}t();const s=window.requestAnimationFrame(t);return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[N,U==null?void 0:U.local.length,lt,k,ne]);const ee=ve??oe;l.useLayoutEffect(()=>{if(!ee){vt(null);return}const t=ee;function s(){const c=we.current.get(t)??null,d=Mt.current;!c||!d||typeof window>"u"||vt(Xn(c.getBoundingClientRect(),{width:d.getBoundingClientRect().width||Kt,height:d.getBoundingClientRect().height||d.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}s();const r=window.requestAnimationFrame(s);return window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{window.cancelAnimationFrame(r),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[ee,C.length]),l.useEffect(()=>{if(!ee||typeof document>"u")return;const t=ee;function s(r){const c=r.target;if(!(c instanceof Node))return;const d=we.current.get(t)??null,w=Mt.current;d!=null&&d.contains(c)||w!=null&&w.contains(c)||(Y(null),Z(null))}return document.addEventListener("pointerdown",s),()=>{document.removeEventListener("pointerdown",s)}},[ee]);async function W(t,s){var r;try{if(f.isDesktop&&(await f.bridge.writeClipboardText(t)).ok){E({title:s,tone:"success"});return}if(typeof navigator<"u"&&((r=navigator.clipboard)!=null&&r.writeText)){await navigator.clipboard.writeText(t),E({title:s,tone:"success"});return}if(fs(t)){E({title:s,tone:"success"});return}}catch{E({title:n("common.copyContentFailed"),tone:"error"})}}async function Mn(t,s){typeof window<"u"&&!window.confirm(n("git.discardConfirm",{path:s}))||await Rt(t)}function En(t){const s=(t==null?void 0:t.desktopFloating)===!0&&!k,r=s?{top:(G==null?void 0:G.top)??O,left:(G==null?void 0:G.left)??O,maxHeight:G==null?void 0:G.maxHeight,transformOrigin:(G==null?void 0:G.transformOrigin)??"top right"}:void 0,c=e.jsxs("div",{ref:s?fn:void 0,className:"git-operations-menu","data-floating":s?"true":"false",style:r,children:[e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.currentBranch")}),e.jsx("strong",{className:"git-menu-branch",children:lt})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.remoteAuthStatusLabel")}),e.jsxs("div",{className:"git-menu-branch-list",children:[e.jsx("strong",{className:"git-menu-branch",children:n("git.remoteAuthManageHint")}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N||mi,onClick:()=>void Ci(),children:e.jsx("span",{children:n("git.remoteAuthAction")})})]})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.branchTitle")}),e.jsx("div",{className:"git-menu-branch-list",children:U==null?void 0:U.local.map(d=>e.jsx("button",{className:"git-menu-item",type:"button",disabled:N||d.current,onClick:()=>void vi(d.name),children:e.jsx("span",{children:d.current?`${n("git.switchBranch")} ${d.name}`:`${n("git.switchBranchTo")} ${d.name}`})},d.name))})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>{z(!1),xt(!0)},children:e.jsx("span",{children:n("git.viewAllVersions")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void Pt("fetch"),children:e.jsx("span",{children:n("git.fetch")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void Pt("pull"),children:e.jsx("span",{children:n("git.pull")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void Pt("push"),children:e.jsx("span",{children:n("git.push")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N,onClick:()=>void me(),children:e.jsx("span",{children:n("git.undoLastCommit")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:N||$e,onClick:()=>void Ht({resetTreeScroll:!0}),children:e.jsx("span",{children:n("git.refresh")})})]})]});return s?typeof document>"u"?null:Hn.createPortal(c,document.body):c}function _t(t,s){if(s){we.current.set(t,s);return}we.current.delete(t)}function Fi(){var r;if(!ee||typeof document>"u")return null;const t=C.find(c=>c.commitHash===ee);if(!t)return null;const s=((r=C[0])==null?void 0:r.commitHash)===t.commitHash&&t.commitKind==="local";return Hn.createPortal(e.jsx("div",{ref:Mt,className:"git-history-entry-menu","data-floating":"true",style:{top:($==null?void 0:$.top)??O,left:($==null?void 0:$.left)??O,maxHeight:$==null?void 0:$.maxHeight,transformOrigin:($==null?void 0:$.transformOrigin)??"top right"},children:e.jsx(ms,{item:t,canUndo:s,actioning:N,onViewCommitChanges:c=>void Ae(c),onCopyCommitHash:c=>void W(c,n("git.copyCommitHashSuccess")),onCopyCommitMessage:c=>void W(pe(c),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:c=>void De(c),onExplainCommitChange:c=>void Le(c),onUndoLastCommit:()=>void me()})}),document.body)}return o&&!_i?e.jsx("section",{className:["conversation-panel","surface-card","git-sidebar",a].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:e.jsxs("section",{className:"git-card git-scaffold-section git-disabled-state",children:[e.jsxs("div",{className:"git-disabled-copy",children:[e.jsx("h3",{children:n("git.uninitializedTitle")}),e.jsx("p",{children:n("git.uninitializedDescription")})]}),e.jsx("div",{className:"git-primary-actions",children:e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>void ji(),disabled:N||$e||!i,children:N?n("git.initInProgress"):n("git.initRepository")})})]})}):e.jsxs("section",{className:["conversation-panel","surface-card","git-sidebar",a].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:[e.jsxs("section",{className:"git-card git-scaffold-section",children:[e.jsxs("div",{className:"git-editor-row",children:[e.jsx("textarea",{ref:hn,rows:1,value:ye,onChange:t=>je(ti(t.target.value)),onKeyDown:t=>{t.key==="Enter"&&t.preventDefault()},placeholder:n("git.commitSubjectPlaceholder")}),e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.generateDraft"),title:n("git.generateDraft"),onClick:()=>void xi(),disabled:N||$e,children:e.jsx(Ms,{})})]}),e.jsxs("div",{className:"git-primary-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Ht({resetTreeScroll:!0}),disabled:N||$e||!i,children:n("git.refreshNow")}),e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>{if(Dt){yn();return}yi()},disabled:N||!Dt&&!Ri,children:Dt?n("git.pushNow"):n("git.commitNow")})]})]}),k?e.jsxs("div",{className:"git-mobile-sections",children:[e.jsx(Ut,{title:n("git.stagedChangesTitle"),count:Q.length,expanded:Ne==="staged",onToggle:()=>re("staged"),children:e.jsx($n,{title:n("git.stagedChangesTitle"),nodes:Sn,collapsedTreePathSet:rt,onToggleTreePath:it,onToggleMobileSelection:at,selectedMobilePathSet:ot,selectedTargets:ge,actioning:N,variant:"staged",swipeRowState:rn,onSwipeRowChange:Ze,onStageToggle:tt,onDiscardWithConfirm:Mn,onClearSelectedTargets:()=>V(t=>t.filter(s=>!ge.includes(s))),onPreviewFile:st})}),e.jsx(Ut,{title:n("git.changesTitle"),count:he.length,expanded:Ne==="unstaged",onToggle:()=>re("unstaged"),children:e.jsx($n,{title:n("git.changesTitle"),nodes:Tn,collapsedTreePathSet:rt,onToggleTreePath:it,onToggleMobileSelection:at,selectedMobilePathSet:ot,selectedTargets:fe,actioning:N,variant:"unstaged",swipeRowState:rn,onSwipeRowChange:Ze,onStageToggle:tt,onDiscardWithConfirm:Mn,onClearSelectedTargets:()=>V(t=>t.filter(s=>!fe.includes(s))),onPreviewFile:st})}),e.jsxs(Ut,{title:n("git.recentVersionsTitle"),count:F,expanded:Ne==="history",onToggle:()=>re("history"),trailingContent:e.jsx("span",{className:"badge",children:lt}),headerAction:e.jsx("button",{className:"git-icon-button git-mobile-section-action",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),"aria-expanded":ne,onClick:()=>{re("history"),z(t=>!t)},disabled:N,children:e.jsx(Ge,{})}),children:[ne?e.jsx("div",{className:"git-mobile-operations-shell",children:En()}):null,e.jsx(ds,{history:C,historyLoadingMore:be,hasMore:!!X,actioning:N,openCommitHash:ve,onMenuTriggerRef:_t,onToggleMenu:t=>Y(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void W(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void W(pe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void De(t),onExplainCommitChange:t=>void Le(t),onUndoLastCommit:()=>void me(),onLoadMore:()=>void et()})]})]}):e.jsxs("div",{ref:dn,className:"git-content-split",style:{gridTemplateRows:Li},children:[e.jsx("section",{className:"git-card git-tree-panel",children:e.jsxs("div",{ref:mn,className:"git-tree-panel-body",children:[Q.length>0?e.jsx(Gn,{title:n("git.stagedChangesTitle"),count:Q.length,nodes:Sn,selectedPath:ae,collapsedTreePathSet:rt,onToggleTreePath:it,onSelectFile:q,onPreviewFile:(t,s)=>{Nn(t)&&st(t,s)},onToggleMobileSelection:at,onStageToggle:tt,onDiscard:Rt,actioning:N,variant:"staged",isMobileViewport:k,selectedMobilePathSet:ot,selectedTargets:ge,mobileActionMenuOpen:Ce==="staged",onToggleMobileActionMenu:()=>K(t=>t==="staged"?null:"staged"),onClearSelectedTargets:()=>V(t=>t.filter(s=>!ge.includes(s)))}):null,e.jsx(Gn,{title:n("git.changesTitle"),count:he.length,nodes:Tn,selectedPath:ae,collapsedTreePathSet:rt,onToggleTreePath:it,onSelectFile:q,onPreviewFile:(t,s)=>{Nn(t)&&st(t,s)},onToggleMobileSelection:at,onStageToggle:tt,onDiscard:Rt,actioning:N,variant:"unstaged",isMobileViewport:k,selectedMobilePathSet:ot,selectedTargets:fe,mobileActionMenuOpen:Ce==="unstaged",onToggleMobileActionMenu:()=>K(t=>t==="unstaged"?null:"unstaged"),onClearSelectedTargets:()=>V(t=>t.filter(s=>!fe.includes(s)))})]})}),e.jsx("button",{className:"git-panel-divider",type:"button",role:"separator","aria-label":n("git.resizePanels"),"aria-orientation":"horizontal","aria-valuemin":Dn,"aria-valuemax":kt,"aria-valuenow":te?Lt:kt,"data-dragging":St,onPointerDown:Hi,children:e.jsx("span",{className:"git-panel-divider-handle","aria-hidden":"true"})}),e.jsxs("section",{className:"git-card git-history-section",children:[e.jsxs("div",{className:"git-history-topbar",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":te,"aria-label":te?n("git.collapseRecentVersions"):n("git.expandRecentVersions"),onClick:()=>Jt(t=>!t),children:[e.jsxs("span",{className:"git-section-toggle-main",children:[e.jsx(ft,{expanded:te}),e.jsx("span",{children:n("git.recentVersionsTitle")})]}),e.jsx("span",{className:"workbench-section-counter",children:F})]}),e.jsxs("div",{className:"git-history-actions",children:[e.jsx("span",{className:"badge",children:lt}),e.jsx("button",{className:"git-icon-button",type:"button",ref:gn,"aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:()=>z(t=>!t),disabled:N,children:e.jsx(Ge,{})}),ne?En({desktopFloating:!0}):null]})]}),te?e.jsx(Bn,{history:C,historyLoadingMore:be,hasMore:!!X,actioning:N,openCommitHash:oe,useNativeContextMenu:xn,onMenuTriggerRef:_t,onScroll:bi,onToggleMenu:t=>{if(xn){const s=C.find(r=>r.commitHash===t);s&&Cn(s);return}Z(s=>s===t?null:t)},onOpenContextMenu:t=>void Cn(t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void W(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void W(pe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void De(t),onExplainCommitChange:t=>void Le(t),onUndoLastCommit:()=>void me(),onLoadMore:()=>void et()}):null]})]}),e.jsxs(Oe,{open:di,title:Ve==="push"?n("git.selectRemoteTitle"):n("git.remoteAuthManageTitle"),description:Ve==="push"?n("git.selectRemoteDesc"):n("git.remoteAuthManageDescription"),onClose:()=>{N||ce(!1)},children:[e.jsx("div",{className:"git-remote-select-list",children:We.map(t=>{const s=Ie.has(t.name),r=hi.get(t.name),c=Ss(t,qe[t.name]??null);return e.jsxs("div",{className:"git-remote-item",children:[Ve==="push"?e.jsxs("label",{className:"git-remote-item-selector",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:N,onChange:()=>{Xe(d=>{const w=new Set(d);return w.has(t.name)?w.delete(t.name):w.add(t.name),w})}}),e.jsxs("span",{className:"git-remote-item-body",children:[e.jsx("span",{className:"git-remote-name",children:t.name}),e.jsx("span",{className:"git-remote-url",children:t.pushUrl}),r&&e.jsx("span",{className:`git-remote-result ${r.ok?"ok":"err"}`,children:r.summary})]})]}):e.jsx("div",{className:"git-remote-item-selector git-remote-item-selector-static",children:e.jsxs("span",{className:"git-remote-item-body",children:[e.jsx("span",{className:"git-remote-name",children:t.name}),e.jsx("span",{className:"git-remote-url",children:t.pushUrl}),r&&e.jsx("span",{className:`git-remote-result ${r.ok?"ok":"err"}`,children:r.summary})]})}),e.jsxs("div",{className:"git-remote-item-meta",children:[e.jsx("span",{className:`git-remote-credential-badge ${c.kind}`,children:c.label}),e.jsx("button",{className:"secondary-button git-remote-inline-action",type:"button",disabled:N,onClick:()=>void nt(t.name),children:n("git.remoteAuthAction")})]})]},t.name)})}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:N,onClick:()=>ce(!1),children:n("common.close")}),Ve==="push"?e.jsx("button",{className:"primary-button",type:"button",disabled:N||Ie.size===0,onClick:()=>void jn(Array.from(Ie)),children:N?n("git.pushing"):n("git.pushSelected",{count:String(Ie.size)})}):null]})]}),e.jsxs(Oe,{open:gi,title:n("git.remoteAuthTitle"),description:wi,onClose:()=>{N||de(!1)},children:[ct?e.jsxs("div",{className:"git-remote-auth-target",children:[e.jsx("strong",{children:ct.name}),e.jsx("span",{children:ct.pushUrl||ct.fetchUrl})]}):null,e.jsxs("div",{className:"workbench-clone-form",children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneAuthModeLabel")}),e.jsxs("select",{value:D.authMode,disabled:N,onChange:t=>J(s=>({...s,authMode:t.target.value})),children:[e.jsx("option",{value:"none",children:n("shell.cloneAuthModeNone")}),e.jsx("option",{value:"basic",children:n("shell.cloneAuthModeBasic")}),e.jsx("option",{value:"token",children:n("shell.cloneAuthModeToken")})]})]}),D.authMode==="basic"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneUsernameLabel")}),e.jsx("input",{type:"text",value:D.username,placeholder:Di,autoComplete:"username",onChange:t=>J(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:Pi}),e.jsx("input",{type:"password",value:D.password,placeholder:Ai,autoComplete:"current-password",onChange:t=>J(s=>({...s,password:t.target.value}))})]})]}):null,D.authMode==="token"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneUsernameLabel")}),e.jsx("input",{type:"text",value:D.username,placeholder:n("shell.cloneTokenUsernamePlaceholder"),autoComplete:"username",onChange:t=>J(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneTokenLabel")}),e.jsx("input",{type:"password",value:D.token,placeholder:n("shell.cloneTokenPlaceholder"),autoComplete:"current-password",onChange:t=>J(s=>({...s,token:t.target.value}))})]})]}):null,Fe?e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthGithubPatHint")}):null,D.authMode!=="none"?e.jsxs("label",{className:"settings-checkbox git-remote-auth-remember-toggle",children:[e.jsx("input",{type:"checkbox",checked:D.rememberOnHost,onChange:t=>J(s=>({...s,rememberOnHost:t.target.checked}))}),e.jsx("span",{children:n("git.remoteAuthRemember")})]}):null,e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthSessionHint")})]}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:N,onClick:()=>de(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:N,onClick:Ni,children:n("git.remoteAuthSave")})]})]}),e.jsx(Oe,{open:oi,title:n("git.viewAllVersions"),description:n("git.viewAllVersionsDescription",{count:String(F)}),onClose:()=>xt(!1),children:e.jsx(Bn,{history:C,historyLoadingMore:be,hasMore:!!X,actioning:N,openCommitHash:oe,className:"git-history-modal-list",onMenuTriggerRef:_t,onToggleMenu:t=>Z(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void W(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void W(pe(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void De(t),onExplainCommitChange:t=>void Le(t),onUndoLastCommit:()=>void me(),onLoadMore:()=>void et()})}),e.jsx(Oe,{open:li!==null,className:"git-commit-detail-modal",title:(_==null?void 0:_.subject)||n("git.commitDetailTitle"),description:_?n("git.commitDetailDescription",{hash:_.shortHash}):n("git.commitDetailLoading"),onClose:Si,children:ci?e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailLoading")})}):Qt?e.jsx("div",{className:"git-commit-detail-state is-error",children:e.jsx("p",{children:Qt})}):_?e.jsxs("div",{className:"git-commit-detail-shell",children:[e.jsxs("div",{className:"git-commit-detail-meta-grid",children:[e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitVersionLabel")}),e.jsx("strong",{children:_.versionLabel})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitHashLabel")}),e.jsx("strong",{children:_.commitHash})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitAuthorLabel")}),e.jsx("strong",{children:_.authorName})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitTimeLabel")}),e.jsx("strong",{children:xs(_.authoredAt)})]})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsx("div",{className:"git-commit-detail-section-header",children:e.jsx("h3",{children:n("git.commitMessageLabel")})}),e.jsx("pre",{className:"git-commit-detail-message",children:pe(_)})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsxs("div",{className:"git-commit-detail-section-header",children:[e.jsx("h3",{children:n("git.changedFilesTitle")}),e.jsx("span",{className:"workbench-section-counter",children:_.changedFiles.length})]}),e.jsx("div",{className:"git-commit-detail-file-list",children:_.changedFiles.map(t=>e.jsxs("div",{className:"git-commit-detail-file-item",children:[e.jsx("span",{className:"git-commit-detail-file-status","data-status":t.status,children:t.status}),e.jsxs("div",{className:"git-commit-detail-file-copy",children:[e.jsx("strong",{children:t.path}),t.oldPath?e.jsx("span",{children:n("git.renamedFromLabel",{path:t.oldPath})}):null]})]},`${t.status}:${t.oldPath??""}:${t.path}`))})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsxs("div",{className:"git-commit-detail-section-header",children:[e.jsx("h3",{children:n("git.commitDiffLabel")}),_.diffTruncated?e.jsx("span",{className:"git-commit-detail-truncated",children:n("git.diffTruncated")}):null]}),e.jsx("pre",{className:"git-commit-detail-diff",children:_.diffContent||n("git.emptyDiff")})]})]}):e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailEmpty")})})}),e.jsx(Oe,{open:ui,className:"git-explain-provider-modal",title:n("git.explainCommitTitle"),description:n("git.explainCommitDescription"),onClose:()=>{ie||(Me(!1),Te(null),le(null))},children:e.jsxs("div",{className:"git-explain-provider-shell",children:[e.jsx(as,{workspaceId:i,selectedProvider:Ee,pendingProvider:ie?Ee:null,disabled:ie,onSelect:t=>le(t)}),e.jsxs("div",{className:"git-explain-provider-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:ie,onClick:()=>{Me(!1),Te(null),le(null)},children:n("common.cancel")}),e.jsx("button",{type:"button",className:"primary-button",disabled:!Ee||ie,onClick:()=>void Mi(),children:ie?n("conversation.sendingState"):n("git.startExplainCommit")})]})]})}),e.jsx(cs,{workspaceId:i,filePath:cn,open:cn!==null,onClose:()=>{He(null),Re(null)},onSaved:async()=>{await Ht({resetTreeScroll:!0})},diffContent:fi}),Fi()]})}function Gn({title:a,count:i,nodes:u,selectedPath:h,collapsedTreePathSet:g,onToggleTreePath:j,onSelectFile:f,onPreviewFile:x,onToggleMobileSelection:b,onStageToggle:v,onDiscard:H,actioning:S,variant:T,isMobileViewport:p,selectedMobilePathSet:o,selectedTargets:m,mobileActionMenuOpen:y,onToggleMobileActionMenu:R,onClearSelectedTargets:C}){const M=Yn(),F=Yt(u),P=T==="staged"?n("git.unstageAll"):n("git.stageAll");return e.jsxs("section",{className:"git-tree-group","data-variant":T,children:[e.jsxs("div",{className:"git-section-header git-tree-group-header",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"git-tree-group-actions",children:[e.jsx("span",{className:"workbench-section-counter",children:i}),!p&&F.length>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":P,title:P,onClick:()=>void v(F,T==="staged"),disabled:S,children:e.jsx(Xt,{staged:T==="staged"})}),T==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":n("git.discardAll"),title:n("git.discardAll"),onClick:()=>void H(F),disabled:S,children:e.jsx(qt,{})}):null]}):null,p&&m.length>0?e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:R,disabled:S,children:e.jsx(Ge,{})}):null]}),p&&y?e.jsxs("div",{className:"git-selection-menu",children:[e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.selectedFiles")}),e.jsx("strong",{className:"git-menu-branch",children:m.length})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void v(m,T==="staged"),children:e.jsx("span",{children:T==="staged"?n("git.unstage"):n("git.stage")})}),T==="unstaged"?e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void H(m),children:e.jsx("span",{children:n("git.discard")})}):null,e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:C,children:e.jsx("span",{children:n("git.clearSelection")})})]})]}):null]}),e.jsx("div",{ref:M,className:"git-tree-shell",role:"tree","aria-label":a,"data-scrollbar-autohide":"true",children:u.length?Jn({nodes:u,depth:0,collapsedTreePathSet:g,selectedPath:h,onToggleTreePath:j,onSelectFile:f,onPreviewFile:x,onToggleMobileSelection:b,onStageToggle:v,onDiscard:H,actioning:S,variant:T,isMobileViewport:p,selectedMobilePathSet:o}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Ut({title:a,count:i,expanded:u,onToggle:h,trailingContent:g,headerAction:j,children:f}){return e.jsxs("section",{className:"git-mobile-section","data-expanded":u,children:[e.jsxs("div",{className:"git-mobile-section-header",children:[e.jsxs("button",{className:"git-mobile-section-toggle",type:"button","aria-expanded":u,onClick:h,children:[e.jsxs("span",{className:"git-mobile-section-toggle-main",children:[e.jsx(ft,{expanded:u}),e.jsx("h3",{children:a})]}),e.jsxs("span",{className:"git-mobile-section-toggle-meta",children:[g,e.jsx("span",{className:"workbench-section-counter",children:i})]})]}),j?e.jsx("div",{className:"git-mobile-section-header-action",children:j}):null]}),u?e.jsx("div",{className:"git-mobile-section-body",children:f}):null]})}function $n({title:a,nodes:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,selectedTargets:f,actioning:x,variant:b,swipeRowState:v,onSwipeRowChange:H,onStageToggle:S,onDiscardWithConfirm:T,onClearSelectedTargets:p,onPreviewFile:o}){return e.jsxs("div",{className:"git-mobile-record-shell",children:[f.length>0?e.jsxs("div",{className:"git-mobile-selection-toolbar",children:[e.jsxs("span",{className:"git-mobile-selection-count",children:[n("git.selectedFiles")," ",f.length]}),e.jsxs("div",{className:"git-mobile-selection-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:x,onClick:()=>void S(f,b==="staged"),children:b==="staged"?n("git.unstage"):n("git.stage")}),b==="unstaged"?e.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:x,onClick:()=>void T(f,`${f.length}`),children:n("git.discard")}):null,e.jsx("button",{type:"button",className:"secondary-button",disabled:x,onClick:p,children:n("git.clearSelection")})]})]}):null,e.jsx("div",{className:"git-mobile-record-list",role:"tree","aria-label":a,children:i.length?Zn({nodes:i,depth:0,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:x,variant:b,swipeRowState:v,onSwipeRowChange:H,onStageToggle:S,onDiscardWithConfirm:T,onPreviewFile:o}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Zn({nodes:a,depth:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:f,variant:x,swipeRowState:b,onSwipeRowChange:v,onStageToggle:H,onDiscardWithConfirm:S,onPreviewFile:T}){return a.map(p=>{if(p.kind==="directory"){const y=!u.has(p.path),R=Yt(p.children),C=`directory:${p.path}`;return e.jsxs("div",{className:"git-mobile-record-branch",children:[e.jsx(Un,{rowKey:C,openState:(b==null?void 0:b.path)===C?b.direction:null,onOpenStateChange:M=>v(M?{path:C,direction:M}:null),trailingActions:R.length>0?[{label:x==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void H(R,x==="staged")},...x==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S(R,p.path)}]:[]]:null,children:e.jsxs("button",{className:"git-mobile-record git-mobile-record-directory",type:"button",style:{paddingInlineStart:`${On+i*kn}px`},onClick:()=>h(p.path),children:[e.jsxs("span",{className:"git-mobile-record-leading",children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":y,children:e.jsx(ft,{expanded:y})}),e.jsx("span",{className:"git-mobile-record-title",children:p.name})]}),e.jsx("span",{className:"git-mobile-record-meta",children:R.length})]})}),y?e.jsx("div",{className:"git-mobile-record-children",role:"group",children:Zn({nodes:p.children,depth:i+1,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:g,selectedMobilePathSet:j,actioning:f,variant:x,swipeRowState:b,onSwipeRowChange:v,onStageToggle:H,onDiscardWithConfirm:S,onPreviewFile:T})}):null]},C)}const o=`file:${p.path}`,m=j.has(p.path);return e.jsx(Un,{rowKey:o,openState:(b==null?void 0:b.path)===o?b.direction:null,onOpenStateChange:y=>v(y?{path:o,direction:y}:null),trailingActions:[{label:n("git.preview"),tone:"neutral",onPress:()=>T(p.change.path,p.change)},{label:x==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void H([p.change.path],x==="staged")},...x==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S([p.change.path],p.path)}]:[]],children:e.jsxs("div",{className:"git-mobile-record git-mobile-record-file","data-active":m,style:{paddingInlineStart:`${On+i*kn}px`},children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:m,"aria-label":`${n("git.selectFile")} ${p.name}`,onChange:()=>g(p.change.path)}),e.jsxs("button",{className:"git-mobile-record-file-main",type:"button",onClick:()=>g(p.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":zt(p.name),"aria-hidden":"true",children:Wt(p.name)}),e.jsxs("span",{className:"git-mobile-record-copy",children:[e.jsx("span",{className:"git-mobile-record-title",children:p.name}),e.jsx("span",{className:"git-mobile-record-path",children:p.path})]}),e.jsx("span",{className:"git-status-badge","data-status":p.status,children:p.status})]})]})},o)})}function Un({rowKey:a,openState:i,onOpenStateChange:u,trailingActions:h,children:g}){const j=ls(),f=l.useRef(null),[x,b]=l.useState(0),v=((h==null?void 0:h.length)??0)*Gt;l.useEffect(()=>{i||b(0)},[i,a]);const H=x!==0?x:i==="trailing"?-v:0;function S(m){var y,R;m.button===0&&(f.current={pointerId:m.pointerId,startX:m.clientX},(R=(y=m.currentTarget).setPointerCapture)==null||R.call(y,m.pointerId))}function T(m){const y=f.current;if(!y||y.pointerId!==m.pointerId)return;const R=v>0?v+10:0,C=Math.max(-R,Math.min(0,m.clientX-y.startX));b(C)}function p(m){var R,C;const y=f.current;if(!(!y||y.pointerId!==m.pointerId)){if((C=(R=m.currentTarget).releasePointerCapture)==null||C.call(R,m.pointerId),f.current=null,x<=-44&&(h!=null&&h.length)){j.trigger("gesture"),u("trailing"),b(0);return}u(null),b(0)}}function o(m){var R,C;const y=f.current;!y||y.pointerId!==m.pointerId||((C=(R=m.currentTarget).releasePointerCapture)==null||C.call(R,m.pointerId),f.current=null,b(0))}return e.jsxs("div",{className:"git-mobile-swipe-row","data-open-state":i??"closed","data-dragging":x!==0,children:[h==null?void 0:h.map((m,y)=>e.jsx("button",{type:"button",className:"git-mobile-swipe-action trailing","data-tone":m.tone,style:{right:y*Gt,width:Gt},onClick:()=>{j.trigger(m.tone==="danger"?"warning":"action"),u(null),m.onPress()},children:m.label},`trailing-${y}`)),e.jsx("div",{className:"git-mobile-swipe-content",style:{transform:`translateX(${H}px)`},onPointerDown:S,onPointerMove:T,onPointerUp:p,onPointerCancel:o,children:g})]})}function ds({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:g,onMenuTriggerRef:j,onToggleMenu:f,onViewCommitChanges:x,onCopyCommitHash:b,onCopyCommitMessage:v,onCopyCommitVersion:H,onExplainCommitChange:S,onUndoLastCommit:T,onLoadMore:p}){return a.length?e.jsxs("div",{className:"git-mobile-history-list",children:[a.map(o=>e.jsx("article",{className:"git-mobile-history-entry","data-kind":o.commitKind,children:e.jsxs("div",{className:"git-mobile-history-entry-main",children:[e.jsx("span",{className:"git-history-marker","data-kind":o.commitKind,"aria-hidden":"true"}),e.jsxs("div",{className:"git-mobile-history-copy",children:[e.jsxs("div",{className:"git-history-title-row",children:[e.jsx("strong",{title:o.subject,children:o.subject}),e.jsx("span",{className:"git-history-kind-badge","data-kind":o.commitKind,children:ni(o.commitKind)})]}),o.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:o.refs.map(m=>e.jsx("span",{className:"git-history-ref-pill","data-kind":m.kind,"data-remote-index":String(ii(m.remoteName)),children:m.name},`${o.commitHash}:${m.kind}:${m.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:o.commitHash.slice(0,8)}),e.jsx("span",{children:o.authorName}),e.jsx("time",{dateTime:o.authoredAt,children:si(o.authoredAt)})]})]}),e.jsx("button",{type:"button",className:"git-icon-button",ref:m=>j(o.commitHash,m),"aria-label":n("git.historyItemMenu"),onClick:()=>f(o.commitHash),children:e.jsx(Ge,{})})]})},o.commitHash)),u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:p,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"git-tree-status",children:n("git.noHistory")})}function Bn({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:g,className:j,useNativeContextMenu:f=!1,onMenuTriggerRef:x,onScroll:b,onToggleMenu:v,onOpenContextMenu:H,onViewCommitChanges:S,onCopyCommitHash:T,onCopyCommitMessage:p,onCopyCommitVersion:o,onExplainCommitChange:m,onUndoLastCommit:y,onLoadMore:R}){const C=Yn();return a.length?e.jsxs("div",{ref:C,className:["git-history-list",j].filter(Boolean).join(" "),onScroll:b,"data-scrollbar-autohide":"true",children:[a.map(M=>{const F=g===M.commitHash;return e.jsxs("article",{className:"git-history-entry","data-kind":M.commitKind,"data-menu-open":F?"true":"false",onContextMenu:P=>{!f||!H||(P.preventDefault(),P.stopPropagation(),H(M))},children:[e.jsx("span",{className:"git-history-marker","data-kind":M.commitKind,"aria-hidden":"true"}),e.jsxs("div",{className:"git-history-body",children:[e.jsxs("div",{className:"git-history-title-row",children:[e.jsx("strong",{title:M.subject,children:M.subject}),e.jsxs("div",{className:"git-history-title-actions",children:[e.jsx("span",{className:"git-history-kind-badge","data-kind":M.commitKind,children:ni(M.commitKind)}),f?null:e.jsx("button",{type:"button",className:"git-icon-button git-history-more",ref:P=>x(M.commitHash,P),"aria-label":n("git.historyItemMenu"),onClick:()=>{v(M.commitHash)},children:e.jsx(Ge,{})})]})]}),M.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:M.refs.map(P=>e.jsx("span",{className:"git-history-ref-pill","data-kind":P.kind,"data-remote-index":String(ii(P.remoteName)),children:P.name},`${M.commitHash}:${P.kind}:${P.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:M.commitHash.slice(0,8)}),e.jsx("span",{children:M.authorName}),e.jsx("time",{dateTime:M.authoredAt,children:si(M.authoredAt)})]})]})]},M.commitHash)}),i?e.jsxs("p",{className:"git-history-loading",children:[n("git.refreshNow"),"..."]}):null,u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:R,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"status-text",children:n("git.noHistory")})}function ms({item:a,canUndo:i,actioning:u,onViewCommitChanges:h,onCopyCommitHash:g,onCopyCommitMessage:j,onCopyCommitVersion:f,onExplainCommitChange:x,onUndoLastCommit:b}){return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>h(a.commitHash),children:e.jsx("span",{children:n("git.viewCommitChanges")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>g(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitHash")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>j(a),children:e.jsx("span",{children:n("git.copyCommitMessage")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>f(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitVersion")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>x(a.commitHash),children:e.jsx("span",{children:n("git.explainCommitAction")})}),i?e.jsx("button",{type:"button",className:"git-menu-item",disabled:u,onClick:b,children:e.jsx("span",{children:n("git.undoLastCommit")})}):null]})}function Jn({nodes:a,depth:i,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:g,onSelectFile:j,onPreviewFile:f,onToggleMobileSelection:x,onStageToggle:b,onDiscard:v,actioning:H,variant:S,isMobileViewport:T,selectedMobilePathSet:p}){return a.map(o=>{if(o.kind==="directory"){const R=!u.has(o.path),C=Yt(o.children),M=`${S==="staged"?n("git.unstage"):n("git.stage")} ${o.path}`,F=`${n("git.discard")} ${o.path}`;return e.jsxs("div",{className:"git-tree-node",children:[e.jsxs("div",{className:"git-tree-row",role:"treeitem","aria-expanded":R,children:[e.jsxs("button",{className:"git-tree-trigger",type:"button",style:{paddingInlineStart:`${6+i*8}px`},onClick:()=>g(o.path),children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":R,children:e.jsx(ft,{expanded:R})}),e.jsx("span",{className:"git-tree-label git-tree-label-directory",children:o.name})]}),!T&&C.length>0?e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":M,title:M,onClick:()=>void b(C,S==="staged"),disabled:H,children:e.jsx(Xt,{staged:S==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":F,title:F,onClick:()=>void v(C),disabled:H,children:e.jsx(qt,{})}):null]}):null]}),R?e.jsx("div",{className:"git-tree-children",role:"group",children:Jn({nodes:o.children,depth:i+1,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:g,onSelectFile:j,onPreviewFile:f,onToggleMobileSelection:x,onStageToggle:b,onDiscard:v,actioning:H,variant:S,isMobileViewport:T,selectedMobilePathSet:p})}):null]},`directory:${o.path}`)}const m=p.has(o.path),y=T?m:h===o.path;return T?e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":y,"data-mobile":"true",children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:m,"aria-label":`${n("git.selectFile")} ${o.name}`,onChange:()=>x(o.change.path)}),e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":y,"data-mobile":"true",style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>x(o.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":zt(o.name),"aria-hidden":"true",children:Wt(o.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:o.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":o.status,children:o.status})})]})]},`file:${o.path}`):e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":y,children:[e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":y,style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>{j(o.change.path),f&&f(o.change.path,o.change)},children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":zt(o.name),"aria-hidden":"true",children:Wt(o.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:o.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":o.status,children:o.status})})]}),e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":o.variant==="staged"?n("git.unstage"):n("git.stage"),title:o.variant==="staged"?n("git.unstage"):n("git.stage"),onClick:()=>void b([o.change.path],o.variant==="staged"),disabled:H,children:e.jsx(Xt,{staged:o.variant==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":n("git.discard"),title:n("git.discard"),onClick:()=>void v([o.change.path]),disabled:H,children:e.jsx(qt,{})}):null]})]},`file:${o.path}`)})}function Vn(a,i){return{kind:"directory",name:a,path:i,children:new Map}}function Wn(a,i){const u=Vn("","");for(const h of a){const g=h.path.replace(/\\/g,"/"),j=g.split("/").filter(Boolean);let f=u;j.forEach((x,b)=>{const v=j.slice(0,b+1).join("/");if(b===j.length-1){f.children.set(`file:${v}`,{kind:"file",name:x,path:g,change:h,status:hs(h,i),variant:i});return}const H=`directory:${v}`,S=f.children.get(H);if(S&&S.kind==="directory"){f=S;return}const T=Vn(x,v);f.children.set(H,T),f=T})}return ei(Qn([...u.children.values()]))}function Qn(a){return[...a].sort((i,u)=>i.kind!==u.kind?i.kind==="directory"?-1:1:i.name.localeCompare(u.name,"zh-CN")).map(i=>i.kind==="directory"?{kind:"directory",name:i.name,path:i.path,children:Qn([...i.children.values()])}:i)}function ei(a){return a.map(i=>{var f;if(i.kind!=="directory")return i;const u=ei(i.children);let h=i.name,g=i.path,j=u;for(;j.length===1&&((f=j[0])==null?void 0:f.kind)==="directory";){const x=j[0];h=`${h}/${x.name}`,g=x.path,j=x.children}return{kind:"directory",name:h,path:g,children:j}})}function zn(a,i,u){const h=new Set(a);return i.filter(g=>It(g,u)&&h.has(g.path)).map(g=>g.path)}function Yt(a){const i=[],u=new Set;function h(g){if(g.kind==="file"){u.has(g.path)||(u.add(g.path),i.push(g.path));return}g.children.forEach(h)}return a.forEach(h),i}function It(a,i){return i==="staged"?!!a.stagedStatus:!!a.worktreeStatus}function hs(a,i){return i==="staged"?a.stagedStatus??a.status:a.worktreeStatus??a.status}function gs(a){return{subject:ti(a).trim(),body:null,footer:null,source:"manual"}}function ti(a){return a.replace(/[\r\n]+/g," ")}function fs(a){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const i=document.createElement("textarea");i.value=a,i.setAttribute("readonly","true"),i.style.position="fixed",i.style.top="-9999px",i.style.left="-9999px",i.style.opacity="0",document.body.appendChild(i),i.focus(),i.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(i)}}function pe(a){const i=a.subject.trim(),u=a.body.trim();return u?`${i}
|
|
2
|
-
|
|
3
|
-
${u}`:i}function ps(a){const i=a.changedFiles.map(g=>`- [${g.status}] ${g.path}${g.oldPath?` (from ${g.oldPath})`:""}`).join(`
|
|
4
|
-
`),u=a.diffContent.length>$t?a.diffContent.slice(0,$t):a.diffContent,h=a.diffContent.length>$t||a.diffTruncated?`
|
|
5
|
-
注意:diff 内容过长,下面已经截断,只分析可见部分,同时明确指出可能遗漏的区域。`:"";return["请你分析下面这个 Git 提交。","输出要求:","1. 先用 3 到 5 句话说明这次改动的核心目的。","2. 按文件说明关键改动点,不要泛泛而谈。","3. 指出潜在风险、边界情况和可能的回归点。","4. 如果提交信息写得差,给出一条更合适的中文提交说明。","",`版本号:${a.versionLabel}`,`Commit Hash:${a.commitHash}`,`提交标题:${a.subject}`,`提交作者:${a.authorName} <${a.authorEmail}>`,`提交时间:${a.authoredAt}`,"","变更文件:",i||"- 无",h,"","Diff:",u||"(empty diff)"].join(`
|
|
6
|
-
`)}function bs(a){if(!a)return;a.style.height="0px";const i=Math.min(Math.max(a.scrollHeight,34),120);a.style.height=`${i}px`,a.style.overflowY=a.scrollHeight>120?"auto":"hidden"}function ni(a){switch(a){case"local":return n("git.historyKindLocal");case"remote":return n("git.historyKindRemote");default:return n("git.historyKindShared")}}function ii(a){if(!a)return 0;let i=0;for(const u of a)i=i*33+u.charCodeAt(0)>>>0;return i%6}function xs(a){const i=Date.parse(a);return Number.isNaN(i)?a:new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(i)}function L(a,i){return a instanceof qn?js(a)??a.message:typeof a=="object"&&a&&"message"in a?a.message:i}function ke(a){return`git-sidebar.snapshot.${a}`}function Bt(a){return a?!!(a.status||a.branches||a.history.length>0||a.historyTotalCount>0||a.historyNextCursor||a.revision):!1}function ys(a){return a?a.snapshot.enabled!==!1:!0}function js(a){switch(a.errorCode){case"UNAUTHORIZED":return n("git.errors.unauthorized");case"WORKSPACE_NOT_FOUND":return n("git.errors.workspaceNotFound");case"INVALID_WORKSPACE":return n("git.errors.invalidWorkspace");case"NOT_GIT_REPOSITORY":return n("git.errors.notGitRepository");case"GIT_REPO_NOT_FOUND":return n("git.errors.repoNotFound");case"PATH_OUT_OF_WORKSPACE":return n("git.errors.pathOutOfWorkspace");case"INVALID_TARGET":return n("git.errors.invalidTarget");case"NOT_STAGED":return n("git.errors.notStaged");case"EMPTY_STAGED_CHANGES":return n("git.errors.emptyStagedChanges");case"BRANCH_CONFLICT":return n("git.errors.branchConflict");case"BRANCH_NOT_FOUND":return n("git.errors.branchNotFound");case"REMOTE_NOT_FOUND":return n("git.errors.remoteNotFound");case"GIT_REMOTE_AUTH_FAILED":return n("git.errors.remoteAuthFailed");case"GIT_PUSH_FAILED":return n("git.errors.pushFailed");case"GIT_PULL_FAILED":return n("git.errors.pullFailed");case"GIT_REMOTE_FAILED":return n("git.errors.remoteFailed");case"GIT_COMMAND_TIMEOUT":return n("git.errors.commandTimeout");case"GIT_INIT_FAILED":return n("git.errors.initFailed");case"GIT_DISCARD_FAILED":return n("git.discardFailed");case"GIT_UNDO_FAILED":return n("git.undoLastCommitFailed");default:return null}}function Kn(a){return a instanceof qn&&a.errorCode==="GIT_REMOTE_AUTH_FAILED"}function Cs(a,i=!1){return!a||!a.mode||a.mode==="none"?ht:a.mode==="basic"?{authMode:"basic",username:a.username??"",password:a.password??"",token:"",rememberOnHost:i}:a.mode==="token"?{authMode:"token",username:a.username??"",password:"",token:a.token??"",rememberOnHost:i}:ht}function Ns(a){return a.authMode==="none"?null:a.authMode==="basic"?{mode:"basic",username:a.username.trim(),password:a.password}:{mode:"token",username:a.username.trim()||void 0,token:a.token}}function vs(a,i){const u=gt(a,i);if(!u)return"generic";const h=u.pushUrl||u.fetchUrl;return Ts(h)?"github":"generic"}function gt(a,i){return a.find(u=>u.name===i)??a.find(u=>u.name==="origin")??a[0]??null}function In(a){var i;return(i=gt(a))==null?void 0:i.name}function Ss(a,i){return i!=null&&i.auth?{kind:"session",label:n("git.remoteAuthConfiguredInSession")}:a.credentialConfigured?{kind:"host",label:n("git.remoteAuthConfiguredOnHost")}:{kind:"missing",label:n("git.remoteAuthNotConfigured")}}function Ts(a){const i=(a==null?void 0:a.trim().toLowerCase())??"";return i.startsWith("https://github.com/")||i.startsWith("http://github.com/")||i.startsWith("ssh://git@github.com/")||i.startsWith("git@github.com:")}function Xn(a,i,u){const h=Math.max(0,u.width),g=Math.max(0,u.height),j=Math.max(0,g-O*2),f=Math.max(0,h-O*2),x=Math.min(Math.max(i.width||Kt,0),f),b=Math.max(0,g-a.bottom-mt-O),v=Math.max(0,a.top-mt-O),H=b<i.height&&v>b,T=Vt(Math.max(H?v:b,us),0,j),p=Math.min(Math.max(i.height,0),T),o=H?a.top-mt-p:a.bottom+mt,m=Math.max(O,g-O-p),y=Math.max(O,h-O-x);return{top:Vt(o,O,m),left:Vt(a.right-x,O,y),maxHeight:Math.max(0,T),transformOrigin:`${H?"bottom":"top"} right`}}function Vt(a,i,u){return!Number.isFinite(a)||u<i?i:Math.min(Math.max(a,i),u)}function ft({expanded:a}){return e.jsx("svg",{className:"git-chevron-icon",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:a?"rotate(0deg)":"rotate(-90deg)"},"aria-hidden":"true",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Xt({staged:a}){return a?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M5 12h14"})}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"M5 12h14"})]})}function qt(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M10 7L6 11l4 4",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7 11h7c3.87 0 7 3.13 7 7 0 1.9-.76 3.63-2 4.89",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ms(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z"})})}function Ge(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"5",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"19",cy:"12",r:"1.8"})]})}function si(a){try{return new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(a))}catch{return a}}export{Fs as GitSidebar,Xn as resolveGitOperationsMenuPosition};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as c,j as e,t as n}from"./index-CjewzOUG.js";import{e as j,M as f,f as p,h as g,i as M,j as S,k as v,S as L}from"./model-switch-api-Br0ivfe5.js";function E({open:o,workspaces:l,workspaceOptions:t,initialWorkspaceId:d,onClose:b,onSelect:x}){const[a,m]=c.useState(""),[h,u]=c.useState(!1),k=j(),i=c.useMemo(()=>t??l.map(s=>({workspace:s,label:s.name,subtitle:s.path,depth:0,kind:"workspace",meta:null})),[t,l]),w=c.useMemo(()=>i.map(s=>s.workspace.id).join("|"),[i]);if(c.useEffect(()=>{o&&(m(N(i,d)),u(!1))},[d,o,w]),!o)return null;const r=i.find(s=>s.workspace.id===a)??i[0]??null;return e.jsxs(f,{open:o,title:n("shell.createSessionModalTitle"),description:n("shell.createSessionModalDescription"),kind:"form",height:"three-quarter",className:"mobile-create-session-sheet",cardClassName:"mobile-create-session-sheet-card",bodyClassName:"mobile-feature-form mobile-workspace-home-form mobile-create-session-form",showHandle:!0,onClose:b,children:[e.jsx(p,{className:"mobile-create-session-section",tone:"accent",children:e.jsxs(g,{label:n("shell.createSessionWorkspaceLabel"),children:[e.jsxs("button",{type:"button",className:"mobile-create-session-workspace-trigger","aria-label":`${n("shell.createSessionWorkspaceLabel")} ${(r==null?void 0:r.label)??""}`.trim(),"aria-expanded":h?"true":"false",disabled:i.length===0,onClick:()=>{k.trigger("selection"),u(s=>!s)},children:[e.jsxs("span",{className:"mobile-create-session-workspace-copy",children:[e.jsx("strong",{children:(r==null?void 0:r.label)??n("common.unknown")}),e.jsx("span",{children:(r==null?void 0:r.subtitle)??n("common.unknown")})]}),e.jsx(C,{expanded:h})]}),h?e.jsx(M,{className:"mobile-workspace-home-group mobile-create-session-workspace-list",role:"list",children:i.map(s=>e.jsx(S,{as:"button",className:"mobile-workspace-home-row mobile-create-session-workspace-row","data-worktree-kind":s.kind,"data-worktree-depth":s.depth,selected:s.workspace.id===a,trailing:e.jsx("span",{className:"mobile-workspace-home-row-trailing",children:s.workspace.id===a?e.jsx(I,{}):e.jsx(y,{})}),style:{"--mobile-workspace-tree-depth":String(s.depth)},onClick:()=>{s.workspace.id!==a&&k.trigger("selection"),m(s.workspace.id),u(!1)},children:e.jsxs("span",{className:"mobile-create-session-workspace-option-copy",children:[e.jsxs("strong",{children:[s.kind==="worktree"?e.jsx(v,{className:"mobile-workspace-home-worktree-badge",children:n("shell.mobileWorktreeBadge")}):null,s.label]}),e.jsx("span",{children:s.subtitle})]})},s.workspace.id))}):null]})}),e.jsx(p,{className:"mobile-create-session-provider-block",heading:n("shell.createSessionProviderLabel"),children:e.jsx(L,{disabled:!a,workspaceId:a||null,onSelect:s=>{a&&x(a,s)}})})]})}function N(o,l){var t;return l&&o.some(d=>d.workspace.id===l)?l:((t=o[0])==null?void 0:t.workspace.id)??""}function C({expanded:o}){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",className:"mobile-create-session-workspace-chevron","data-expanded":o?"true":"false",children:e.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function y(){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function I(){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}export{E as M};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as j,f as B,h as $,j as t,t as l}from"./index-CjewzOUG.js";import{e as K,i as F,j as P,k as S,M as G}from"./model-switch-api-Br0ivfe5.js";import{bi as q,m as z,bj as D,aK as X,bk as J}from"./WorkbenchLayout-D48i71PU.js";import{u as Q,f as V}from"./App-B0q8uDA-.js";import{M as Y}from"./MobileTopHeaderFrame-_I0t7cC_.js";function Z(s){return s.flatMap(o=>[{workspace:o.workspace,label:o.workspace.name,subtitle:o.workspace.path,depth:0,kind:"workspace",meta:null},...v(o.childWorktrees??[])])}function we(s,o){const a=o==null?void 0:o.trim();if(!a)return null;for(const i of s){if(i.workspace.id===a)return{workspace:i.workspace,sessions:i.sessions,childWorktrees:i.childWorktrees??[],meta:null};const n=H(i.childWorktrees??[],a);if(n)return n}return null}function v(s){return s.flatMap(o=>[{workspace:o.workspace,label:o.meta.displayName||o.workspace.name,subtitle:o.workspace.path,depth:o.meta.depth,kind:"worktree",meta:o.meta},...v(o.children)])}function H(s,o){for(const a of s){if(a.workspace.id===o)return{workspace:a.workspace,sessions:a.sessions,childWorktrees:a.children,meta:a.meta};const i=H(a.children,o);if(i)return i}return null}const W=10080*60*1e3;function ee(s,o){return se(s.hosts,s.activeHostId).flatMap(a=>{const i=a.id===s.activeHostId?o:oe(a.id);return[{kind:"host",host:a,workspaceCount:i.length},...i.map(n=>({kind:"workspace",host:a,workspace:n.workspace,option:n}))]})}function se(s,o){return[...s].sort((a,i)=>{if(a.id===o)return-1;if(i.id===o)return 1;const n=a.lastConnectedAt??a.updatedAt??a.createdAt;return(i.lastConnectedAt??i.updatedAt??i.createdAt).localeCompare(n)})}function oe(s){const o=q(W,s);return o?Z(z(o)):[]}function ke({currentWorkspace:s,workspaces:o,workspaceOptions:a,onSelectWorkspace:i,className:n,containerRef:w,heading:N,content:C,sheetContent:k,triggerLabel:M,triggerAriaLabel:L,onTriggerClick:c,trailing:A,gestureHandlers:y}){const[u,d]=j.useState(!1),[m,b]=j.useState(null),f=K(),I=Q(),{showToast:T}=V(),r=B(e=>e),h=$(r),E=a??o.map(e=>({workspace:{...e,repoRoot:e.path},label:e.name,subtitle:e.path,depth:0,kind:"workspace",meta:null})),O=ee(r,E),p=(s==null?void 0:s.name)??(h==null?void 0:h.name)??null,x=(s==null?void 0:s.path)??(h==null?void 0:h.baseUrl)??null;if(!p)return null;async function R(e){const U=e.kind==="host"?`host:${e.host.id}`:`workspace:${e.host.id}:${e.workspace.id}`;if(!m){b(U);try{e.host.id!==r.activeHostId&&(f.trigger("selection"),await D.switchHost(e.host.id)),e.kind==="host"?I(X()):(e.workspace.id!==(s==null?void 0:s.id)||e.host.id!==r.activeHostId)&&await(i==null?void 0:i(e.workspace.id)),d(!1)}catch(_){T({title:te(_,e.host.name),tone:"error"})}finally{b(null)}}}return t.jsxs(t.Fragment,{children:[t.jsx(Y,{className:n,frameRef:w,...y,children:t.jsxs("section",{className:"mobile-workspace-home-header",children:[t.jsx("h1",{className:"mobile-workspace-switcher-heading",children:N??p}),t.jsxs("div",{className:"mobile-workspace-home-toolbar-top",children:[t.jsxs("button",{type:"button",className:"mobile-workspace-home-switcher","aria-label":L??l("shell.workspaceHomeSwitcherLabel"),onClick:()=>{if(c){c();return}f.trigger("selection"),d(!0)},children:[t.jsx("span",{className:"mobile-workspace-home-switcher-label",children:M??p}),t.jsx(ne,{})]}),t.jsx("div",{className:"mobile-workspace-home-toolbar-actions",children:A})]}),x?t.jsx("p",{className:"mobile-workspace-home-path",children:x}):null,C]})}),u&&!c?t.jsxs(ie,{open:u,title:l("shell.hostWorkspaceSwitcherTitle"),onClose:()=>d(!1),children:[t.jsx(F,{className:"mobile-workspace-home-group mobile-workspace-home-sheet-group",children:O.map(e=>t.jsx(P,{as:"button",className:"mobile-workspace-home-row mobile-workspace-home-sheet-row","data-host-entry-kind":e.kind,"data-host-active":e.host.id===r.activeHostId,"data-worktree-kind":e.kind==="workspace"?e.option.kind:void 0,"data-worktree-depth":e.kind==="workspace"?e.option.depth+1:0,disabled:m!==null,selected:e.kind==="host"&&e.host.id===r.activeHostId||e.kind==="workspace"&&e.workspace.id===(s==null?void 0:s.id)&&e.host.id===r.activeHostId,trailing:t.jsx("span",{className:"mobile-workspace-home-row-trailing",children:e.kind==="host"&&e.host.id===r.activeHostId?t.jsx(g,{}):e.kind==="workspace"&&e.workspace.id===(s==null?void 0:s.id)&&e.host.id===r.activeHostId?t.jsx(g,{}):t.jsx(re,{})}),style:{"--mobile-workspace-tree-depth":String(e.kind==="host"?0:e.option.depth+1)},onClick:()=>{R(e)},label:t.jsxs("span",{className:e.kind==="host"?"mobile-workspace-home-sheet-label mobile-host-workspace-switcher-host-label":"mobile-workspace-home-sheet-label",children:[e.kind==="host"?t.jsx(S,{className:"mobile-host-workspace-switcher-host-badge",children:l("shell.hostSwitcherNodeBadge")}):null,e.kind==="workspace"&&e.option.kind==="worktree"?t.jsx(S,{className:"mobile-workspace-home-worktree-badge",children:l("shell.mobileWorktreeBadge")}):null,t.jsx("span",{className:"mobile-workspace-home-sheet-label-text",children:e.kind==="host"?e.host.name:e.option.label})]}),description:t.jsx("span",{className:"mobile-workspace-home-sheet-description",children:e.kind==="host"?ae(e.host,e.workspaceCount):e.option.subtitle})},e.kind==="host"?`host-${e.host.id}`:`workspace-${e.host.id}-${e.workspace.id}`))}),k?k(()=>d(!1)):null]}):null]})}function te(s,o){return s instanceof J?s.code==="HOST_UNREACHABLE"?l("shell.hostSwitchUnreachable",{name:o}):l("shell.hostSwitchMissing"):l("shell.hostSwitchFailed")}function ae(s,o){return s?s.lastUsername?l("shell.hostSwitcherWorkspaceCountWithUser",{username:s.lastUsername,count:o}):o>0?l("shell.hostSwitcherWorkspaceCount",{count:o}):s.baseUrl:""}function ie({open:s,title:o,onClose:a,children:i}){return t.jsx(G,{open:s,title:o,kind:"picker",height:"three-quarter",className:"mobile-host-workspace-switcher-sheet",bodyClassName:"mobile-workspace-home-form",showHandle:!0,onClose:a,children:i})}function ne(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function re(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function g(){return t.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:t.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}export{ke as M,we as a,Z as f};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as n,n as U,j as r,t as s,e as N}from"./index-CjewzOUG.js";import{r as E,b as k}from"./relay-entry-D7OgZZN-.js";import{a as h,s as O,t as P,v as w}from"./App-B0q8uDA-.js";import{W as T}from"./WorkbenchModal-BYNuMIoV.js";function z({isOpen:t,onClose:u,onSave:c,theme:$="dark"}){const d=h(e=>e.baseUrl),B=h(e=>e.options),p=h(e=>e.presetOptions),f=P(),[i,o]=n.useState(d),[g,l]=n.useState(null),[v,m]=n.useState(!1),a=n.useMemo(()=>{try{return U(i)}catch{return null}},[i]),x=O(a??i,B),S=p.find(e=>e.value===x)??null,b="server-settings-preset",j="server-settings-address";if(n.useEffect(()=>{t&&(o(d),l(null),m(!1))},[t,d]),!t)return null;async function I(){if(!a){l(s("auth.serverInvalid"));return}m(!0);try{const e=await E(a);e?await N.update(k(N.getState(),e)):w.setBaseUrl(a),c==null||c(a),u()}catch(e){l(e instanceof Error&&e.message.trim()?e.message:s("auth.serverInvalid"))}finally{m(!1)}}function C(){a&&o(a)}return r.jsx(T,{open:t,title:s("auth.serverSettingsTitle"),description:s("auth.serverHint"),className:"server-settings-modal-card",onClose:u,children:r.jsxs("form",{className:"server-settings-modal-form",onSubmit:e=>{e.preventDefault(),I()},children:[r.jsxs("label",{className:"workbench-modal-field",htmlFor:b,children:[r.jsx("span",{children:s("auth.serverPreset")}),r.jsxs("select",{id:b,"aria-label":s("auth.serverPreset"),value:x,onChange:e=>{const y=e.target.value;y!==f&&(o(y),l(null))},children:[p.map(e=>r.jsx("option",{value:e.value,children:V(e)},`${e.source}:${e.value}`)),r.jsx("option",{value:f,children:s("auth.serverCustomOption")})]})]}),S?r.jsx("div",{className:"server-settings-modal-tags","aria-live":"polite",children:S.source==="discovered"?r.jsx("span",{className:"server-settings-modal-tag","data-tone":"discovered",children:s("auth.serverDiscoveredTag")}):null}):null,r.jsxs("label",{className:"workbench-modal-field",htmlFor:j,children:[r.jsx("span",{children:s("auth.serverAddress")}),r.jsx("input",{id:j,"aria-label":s("auth.serverAddress"),value:i,placeholder:s("auth.serverPlaceholder"),disabled:v,onBlur:C,onChange:e=>{o(e.target.value),l(null)}})]}),g?r.jsx("p",{className:"server-settings-modal-status","data-tone":"error",children:g}):r.jsx("p",{className:"server-settings-modal-hint",children:s("auth.serverHint")}),r.jsxs("div",{className:"workbench-modal-actions",children:[r.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:s("common.cancel")}),r.jsx("button",{type:"submit",className:"primary-button",disabled:v,children:v?s("common.loading"):s("auth.saveServerSettings")})]})]})})}function V(t){return t.source==="discovered"?`${t.value} · ${s("auth.serverDiscoveredTag")}`:t.value}export{z as ServerSettingsModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as d,j as e,t as a}from"./index-CjewzOUG.js";import{g as pe,u as je}from"./App-B0q8uDA-.js";import{e as ye,a as fe}from"./model-switch-api-Br0ivfe5.js";import{D as ce,E as Se,F as Ne,G as ke,H as Me,I as Ae,J as Ee,u as Ce,K as Pe,L as Ie,M as de,g as Le,N as se,O as ne,P as De,n as Te,c as Re}from"./WorkbenchLayout-D48i71PU.js";import{f as Ge,a as ue,M as Oe}from"./MobileWorkspaceSwitcherHeader-DhaM9fgx.js";import{M as We}from"./MobileCreateSessionSheet-CceV0-AH.js";import{w as he}from"./styles-JKFlsYFv.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./WorkbenchModal-BYNuMIoV.js";import"./relay-entry-D7OgZZN-.js";import"./MobileTopHeaderFrame-_I0t7cC_.js";const Be=420,Fe=156;function He({entry:t,isFavorite:i,isActive:u=!1,depth:h=0,variant:c="default",workspaceTone:M="root",hasSubsessions:m=!1,subsessionsExpanded:A=!1,showActions:z=!0,onActivate:J,onToggleSubsessions:W,onToggleFavorite:te,onArchive:B,onUnarchive:ie,onRename:r}){var v;const[w,D]=d.useState(!1),[T,R]=d.useState(null),[j,F]=d.useState(null),E=d.useRef(null),G=d.useRef(!1),O=d.useRef(null),H=ye(),{session:l,workspace:oe}=t,V=l.title??l.sessionId,Z=fe(l.provider),$=[Z,Ve(l.lastMessageAt??l.updatedAt??null),ce(l)].filter(Boolean).join(" · "),_=c==="mobile"?null:ce(l),K=_?Se("session-list-activity-badge",l):null,S=c!=="mobile",U=S?Ne(l.parallelGroup):null,q=S?ke(l.parallelGroup):null,ae=S?Me(l.parallelGroup):void 0;d.useEffect(()=>()=>{Y()},[]),d.useLayoutEffect(()=>{if(!w||!j||typeof window>"u"){R(null);return}const n=()=>{var I,y;const g=Ae(j,{width:((I=O.current)==null?void 0:I.offsetWidth)??0,height:((y=O.current)==null?void 0:y.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:Fe});R({position:"fixed",left:`${Math.round(g.left)}px`,top:`${Math.round(g.top)}px`,width:`${Math.round(g.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(g.maxHeight)}px`,transformOrigin:g.transformOrigin})},x=g=>{var y;const I=g.target;I&&!((y=O.current)!=null&&y.contains(I))&&N()},P=g=>{g.key==="Escape"&&N()};return n(),window.addEventListener("pointerdown",x),window.addEventListener("keydown",P),window.addEventListener("resize",n),window.addEventListener("scroll",n,!0),()=>{window.removeEventListener("pointerdown",x),window.removeEventListener("keydown",P),window.removeEventListener("resize",n),window.removeEventListener("scroll",n,!0)}},[j,w]);function X(n){F(n),D(!0)}function N(){D(!1),F(null)}function Y(){E.current!==null&&(window.clearTimeout(E.current),E.current=null)}function le(n){if(!z||n.pointerType==="mouse")return;const x={x:n.clientX,y:n.clientY};Y(),E.current=window.setTimeout(()=>{G.current=!0,H.trigger("gesture"),X(x)},Be)}function C(){Y()}function Q(){if(G.current){G.current=!1;return}H.trigger("selection"),J(l.sessionId)}const s=async()=>{const n=window.prompt(a("shell.renameModalDescription"),V);n&&(await r(l.sessionId,n.trim()),N())},o=async()=>{if(l.isArchived){await ie(l.sessionId),N();return}await B(l.sessionId),N()},p=()=>{te(l.sessionId),N()},f=n=>{if(n.key!=="ContextMenu"&&!(n.shiftKey&&n.key==="F10"))return;n.preventDefault(),n.stopPropagation();const x=n.currentTarget.getBoundingClientRect();X({x:x.right,y:x.bottom})},k=w&&typeof document<"u"?pe.createPortal(e.jsxs("div",{ref:O,className:"session-action-menu surface-card",role:"menu","aria-label":a("shell.sessionMoreAction"),style:T??{position:"fixed",top:0,left:0,visibility:"hidden"},onClick:n=>n.stopPropagation(),children:[e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:p,children:i?a("shell.unfavoriteAction"):a("shell.favoriteAction")}),e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void o(),children:l.isArchived?a("shell.unarchiveAction"):a("shell.archiveAction")}),e.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void s(),children:a("shell.renameAction")})]}),document.body):null;return e.jsxs("article",{className:"session-list-item","data-depth":h,"data-active":u,"data-workspace-tone":M,"data-has-subsessions":m,"data-variant":c,"data-parallel-group":S&&l.parallelGroup?"true":void 0,"data-parallel-role":S?((v=l.parallelGroup)==null?void 0:v.role)??void 0:void 0,style:ae,onContextMenu:n=>{z&&(n.preventDefault(),n.stopPropagation(),X({x:n.clientX,y:n.clientY}))},children:[m?e.jsx("button",{type:"button",className:"session-list-subsession-toggle","aria-label":A?a("shell.subagentCollapse"):a("shell.subagentExpand"),title:A?a("shell.subagentCollapse"):a("shell.subagentExpand"),"aria-expanded":A,onClick:n=>{n.stopPropagation(),H.trigger("selection"),W==null||W()},children:e.jsx("span",{className:me(l,{isActive:u,hasSubsessions:m}),"aria-hidden":"true"})}):e.jsx("span",{className:me(l,{isActive:u,hasSubsessions:m}),"aria-hidden":"true"}),e.jsx("button",{type:"button",className:"session-list-link",onClick:Q,onPointerDown:le,onPointerUp:C,onPointerCancel:C,onPointerLeave:C,onKeyDown:f,children:e.jsxs("div",{className:"session-list-copy",children:[e.jsxs("div",{className:"session-list-title-row",children:[e.jsx("div",{className:"session-list-title",children:V||a("shell.searchEntry")}),U?e.jsx("span",{className:"session-list-parallel-badge",children:U}):null,q?e.jsx("span",{className:"session-list-parallel-role-badge",children:q}):null]}),e.jsx("div",{className:"session-list-meta",children:c==="mobile"?e.jsx(e.Fragment,{children:e.jsx("span",{children:$})}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:oe.name}),_&&K?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{className:K,children:_})]}):null,e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:Z})]})})]})}),k]})}function me(t,i){return Ee("session-list-indicator",t,{isActive:i.isActive,hasSubagents:i.hasSubsessions})}function Ve(t){return t?new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):a("common.unknown")}const ee=5;function ls(){var Q;const t=je(),{navigationGroups:i,favoriteSessionIds:u,currentWorkspaceId:h,currentSessionId:c,navigationLoading:M,selectWorkspace:m,toggleFavoriteSession:A,archiveSession:z,unarchiveSession:J,renameSession:W,startDraftSession:te}=Ce(),B=Ge(i),ie=d.useMemo(()=>Pe(i),[i]),r=ue(i,h)??ue(i,((Q=i[0])==null?void 0:Q.workspace.id)??null),w=B.find(s=>s.workspace.id===(r==null?void 0:r.workspace.id))??(r?{workspace:r.workspace,label:r.workspace.name,subtitle:r.workspace.path}:null),D=d.useMemo(()=>new Set(u),[u]),T=d.useMemo(()=>r?r.sessions.filter(s=>{if(s.isArchived)return!1;const o=Ie(s,{mode:"mobile"});if(!o)return!0;const p=r.sessions.find(f=>f.sessionId===o);return!p||!p.isArchived}).map(s=>({session:s,workspace:r.workspace})):[],[r]),R=d.useMemo(()=>T.filter(s=>D.has(s.session.sessionId)),[T,D]),j=d.useMemo(()=>de(T,{mode:"mobile"}),[T]),F=d.useMemo(()=>de(R,{mode:"mobile"}),[R]),E=d.useMemo(()=>r?r.sessions.filter(s=>s.isArchived===!0&&!Le(s)):[],[r]),G=(r==null?void 0:r.workspace.id)??"",O=!!G,[H,l]=d.useState([]),[oe,V]=d.useState({}),[Z,$]=d.useState(!1),[_,K]=d.useState(!1),[S,U]=d.useState(null);d.useEffect(()=>{V(s=>{const o={};for(const p of j){const f=se(ne(p));if(f.length===0)continue;const k=f.findIndex(v=>v.item.session.sessionId===c);o[p.item.session.sessionId]=Xe(f.length,ee,s[p.item.session.sessionId],k)}return Ye(s,o)?s:o})},[c,j]),d.useEffect(()=>{if(!c)return;const s=De(j,c,o=>o.session.sessionId);s.length!==0&&l(o=>{const p=new Set(o);let f=!1;for(const k of s)p.has(k)||(p.add(k),f=!0);return f?Array.from(p):o})},[c,j]);function q(s){l(o=>o.includes(s)?o.filter(p=>p!==s):[...o,s])}function ae(s){return oe[s]??ee}function X(s){V(o=>({...o,[s]:(o[s]??ee)+ee}))}function N(s,o){he("immersive"),t(Re(s,o))}function Y(s,o){$(!1),he("immersive"),te(s,o)}async function le(s){U(s);try{await J(s)}finally{U(o=>o===s?null:o)}}function C(s,o=!1,p=[],f=!1,k=!1){var re;const v=s.item.session.sessionId,n=s.children,x=s.depth===0&&n.length>0,P=o||x&&H.includes(v),g=P&&x,I=g?Ue(s,ae(v)):s,y=P?I.children:[],be=se(n).length,xe=se(y).length,ge=g&&xe<be,we=s.depth>0?[...p,f]:[...p];return e.jsxs("div",{className:"session-list-tree-node",children:[e.jsxs("div",{className:"session-list-tree-row",style:{"--session-tree-depth":s.depth},children:[s.depth>0?e.jsxs("div",{className:"session-tree-guides","aria-hidden":"true",style:{"--session-tree-depth":s.depth},children:[p.map((b,L)=>b?e.jsx("span",{className:"session-tree-guide-column",style:{"--session-tree-level":L+1}},`${v}:ancestor:${L}`):null),e.jsx("span",{className:"session-tree-guide-branch","data-continue":f,"data-first":k,style:{"--session-tree-level":s.depth},children:e.jsx("span",{className:"session-tree-guide-branch-horizontal"})})]}):null,e.jsx(He,{entry:s.item,isFavorite:D.has(v),isActive:c===v,depth:s.depth,variant:"mobile",workspaceTone:((re=ie[s.item.workspace.id])==null?void 0:re.tone)??"root",hasSubsessions:x,subsessionsExpanded:P,onActivate:b=>N(s.item.workspace.id,b),onToggleSubsessions:x?()=>q(v):void 0,onToggleFavorite:b=>{A(b)},onArchive:b=>z(b),onUnarchive:b=>J(b),onRename:(b,L)=>W(b,L)})]}),P&&y.length>0?e.jsx("div",{className:"session-list-children",children:y.map((b,L)=>C(b,!0,we,L<y.length-1,L===0))}):null,ge?e.jsx("div",{className:"session-list-children",children:e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>X(v),children:a("shell.subagentExpandMore")})}):null]},`${s.item.workspace.id}:${v}`)}return e.jsxs("main",{className:"session-index-page mobile-feature-page mobile-page-scroll-root mobile-page-with-top-header",children:[e.jsx(Oe,{currentWorkspace:w?{id:w.workspace.id,name:w.label,path:w.subtitle}:null,workspaces:i.map(s=>s.workspace),workspaceOptions:B,onSelectWorkspace:s=>{m(s),t(Te(s))},content:e.jsx("button",{type:"button",className:"primary-button mobile-session-index-create-button",disabled:M||!O,onClick:()=>$(!0),children:a("shell.createSession")})}),e.jsxs("div",{className:"mobile-page-top-body",children:[e.jsx("div",{className:"session-index-archive-actions",children:e.jsxs("button",{type:"button",className:"primary-button mobile-session-index-create-button session-index-archive-button",disabled:M||!r,onClick:()=>K(!0),children:[e.jsx("span",{children:a("shell.archiveViewAction")}),e.jsx("span",{className:"session-index-archive-count",children:E.length})]})}),F.length>0?e.jsxs("section",{className:"session-section session-section-sheet",children:[e.jsxs("header",{className:"session-section-heading",children:[e.jsx("div",{children:e.jsx("h2",{children:a("shell.favoriteSectionTitle")})}),e.jsx("span",{className:"session-section-count",children:R.length})]}),e.jsx("div",{className:"session-current-workspace-list",children:F.map(s=>C(s))})]}):null,e.jsxs("section",{className:"session-section session-section-sheet",children:[e.jsxs("header",{className:"session-section-heading",children:[e.jsx("div",{children:e.jsx("h2",{children:a("shell.mobileConversationCurrentWorkspaceSection")})}),e.jsx("span",{className:"session-section-count",children:j.length})]}),j.length===0?e.jsx("p",{className:"session-section-empty",children:M?a("shell.searchSessionHint"):a("shell.emptyWorkspaceSessions")}):e.jsx("div",{className:"session-current-workspace-list",children:j.map(s=>C(s))})]})]}),e.jsx(We,{open:Z,workspaces:i.map(s=>s.workspace),workspaceOptions:B,initialWorkspaceId:h??G,onClose:()=>$(!1),onSelect:Y}),e.jsx($e,{open:_,workspaceName:(w==null?void 0:w.label)??(r==null?void 0:r.workspace.name)??null,sessions:E,restoringSessionId:S,onClose:()=>{S||K(!1)},onRestore:s=>void le(s)})]})}function $e({open:t,workspaceName:i,sessions:u,restoringSessionId:h,onClose:c,onRestore:M}){return d.useEffect(()=>{if(!t)return;function m(A){A.key==="Escape"&&!h&&c()}return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m)}},[c,t,h]),!t||typeof document>"u"?null:pe.createPortal(e.jsxs("div",{className:"workbench-modal-layer",children:[e.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":a("common.close"),disabled:!!h,onClick:c}),e.jsxs("section",{className:"workbench-modal-card surface-card",role:"dialog","aria-modal":"true","aria-label":a("shell.archiveModalTitle"),children:[e.jsx("div",{className:"workbench-modal-header",children:e.jsxs("div",{className:"workbench-modal-title-wrap",children:[e.jsx("h2",{children:a("shell.archiveModalTitle")}),e.jsx("p",{children:i?`${i} · ${a("shell.archiveModalDescription")}`:a("shell.archiveModalDescription")})]})}),e.jsx("div",{className:"workbench-modal-body",children:u.length>0?e.jsx("div",{className:"workbench-archive-list",children:u.map(m=>e.jsxs("article",{className:"workbench-archive-item",children:[e.jsxs("div",{className:"workbench-archive-item-main",children:[e.jsx("strong",{title:m.title??m.sessionId,children:m.title??m.sessionId}),e.jsx("p",{children:_e(m)})]}),e.jsx("button",{type:"button",className:"secondary-button",disabled:h===m.sessionId,onClick:()=>{M(m.sessionId)},children:a("shell.unarchiveAction")})]},m.sessionId))}):e.jsx("p",{className:"workbench-section-empty",children:a("shell.archiveEmpty")})})]})]}),document.body)}function _e(t){const i=fe(t.provider),u=Ke(t.lastMessageAt??t.updatedAt??null);return[i,u].filter(Boolean).join(" · ")}function Ke(t){if(!t)return null;const i=Date.parse(t);return Number.isNaN(i)?null:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(i)}function Ue(t,i){const u=new Set(se(ne(t)).sort((h,c)=>(c.item.session.lastMessageAt??c.item.session.updatedAt).localeCompare(h.item.session.lastMessageAt??h.item.session.updatedAt)).slice(0,i).map(h=>h.item.session.sessionId));return{...t,children:ve(ne(t),u)}}function ve(t,i){return t.flatMap(u=>{const h=ve(ne(u),i);return!i.has(u.item.session.sessionId)&&h.length===0?[]:[{...u,children:h}]})}function Xe(t,i,u,h=-1){if(t<=0)return 0;const c=h>=0?Math.max(i,h+1):i;return Math.min(t,Math.max(u??0,c))}function Ye(t,i){const u=Object.keys(t),h=Object.keys(i);return u.length!==h.length?!1:u.every(c=>t[c]===i[c])}export{ls as SessionIndexPage};
|