@jingyi0605/codingns 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/public/assets/AdaptiveButlerPage-SffCV4Vb.js +3 -0
- package/dist/public/assets/App-WOLwMld_.js +30 -0
- package/dist/public/assets/{BootstrapPage-Vu5oEJ8z.js → BootstrapPage--zExdgfM.js} +1 -1
- package/dist/public/assets/{ConversationPage-Cjpg6g0J.js → ConversationPage-D9pzRmOg.js} +2 -2
- package/dist/public/assets/{DesktopDetachPreviewPage-BgeEqbc5.js → DesktopDetachPreviewPage-DvI9CIKi.js} +1 -1
- package/dist/public/assets/{DesktopWindowPage-1WelvxdH.js → DesktopWindowPage-D8FpOSLE.js} +1 -1
- package/dist/public/assets/FileContextPanel-C8T7oqRN.js +1 -0
- package/dist/public/assets/GitSidebar-Bze7DNnc.js +6 -0
- package/dist/public/assets/{MobileCreateSessionSheet-DLq5qPkx.js → MobileCreateSessionSheet-CXSKMnYn.js} +1 -1
- package/dist/public/assets/MobileSheet-Gzc14EpR.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-DArgZI7L.js → MobileTopHeaderFrame-BWorAJ1C.js} +1 -1
- package/dist/public/assets/{MobileWorkspaceSwitcherHeader-0ywJKfBQ.js → MobileWorkspaceSwitcherHeader-DOr4pTUq.js} +1 -1
- package/dist/public/assets/{ServerSettingsModal-izoYMx9U.js → ServerSettingsModal-BYB0GvTl.js} +1 -1
- package/dist/public/assets/{SessionIndexPage-C5aG8FIv.js → SessionIndexPage-CR3IARXX.js} +1 -1
- package/dist/public/assets/SettingsPage-B_BQtnwE.js +1 -0
- package/dist/public/assets/TerminalManagerPanel-PQ-EM64j.js +1 -0
- package/dist/public/assets/{TerminalPage-CtKXIU0h.js → TerminalPage-CvnHXBhw.js} +12 -12
- package/dist/public/assets/{TerminalRuntimeFallbackModal-CRhOQOsT.js → TerminalRuntimeFallbackModal-D7Aq186N.js} +1 -1
- package/dist/public/assets/{ToolFilesPage-DcYPsS-e.js → ToolFilesPage-Qzkc6K2I.js} +1 -1
- package/dist/public/assets/{ToolGitPage-CsPl89ty.js → ToolGitPage-BdNDN-cV.js} +1 -1
- package/dist/public/assets/{ToolProcessesPage-D0dvR8xK.js → ToolProcessesPage-EXJ9DHWI.js} +1 -1
- package/dist/public/assets/{ToolsHomePage-4fP-KRiv.js → ToolsHomePage-CjF3CWzR.js} +1 -1
- package/dist/public/assets/{WorkbenchLandingPage-kvlfyxRo.js → WorkbenchLandingPage-DZPk4SmX.js} +1 -1
- package/dist/public/assets/WorkbenchLayout-rwQib5In.js +3 -0
- package/dist/public/assets/{WorkbenchModal-Ctob14VR.js → WorkbenchModal-B09hC9b5.js} +1 -1
- package/dist/public/assets/WorkbenchShellRoute-Cerk5uK7.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-DsW4mBTX.css +1 -0
- package/dist/public/assets/{WorkspaceDebugDetailPage-Com5kEXJ.js → WorkspaceDebugDetailPage-Bcq8s-Ma.js} +1 -1
- package/dist/public/assets/WorkspaceDetailPage-DNAa8pKr.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-BoiLuACV.js +1 -0
- package/dist/public/assets/client-runtime-manager-CRQ-F5d2.js +1 -0
- package/dist/public/assets/{default-session-permission-mode-CcGwR4Kk.js → default-session-permission-mode-D0wZ9Jek.js} +1 -1
- package/dist/public/assets/{file-tree-icon-UFVoVzhM.js → file-tree-icon-Dp_xhVfD.js} +14 -14
- package/dist/public/assets/index-C2G8Gmf1.js +42 -0
- package/dist/public/assets/{index-_52jxu4a.css → index-CpPTUeA3.css} +1 -1
- package/dist/public/assets/{preferences-service-KIYeE2gk.js → preferences-service-gOt2ZjKZ.js} +1 -1
- package/dist/public/assets/{session-runtime-machine-0KNSSPp5.js → session-runtime-machine-Dq3pW-UF.js} +8 -8
- package/dist/public/assets/{terminal-runtime-meta-AWXJpN4r.js → terminal-runtime-meta-BMT-rSEe.js} +1 -1
- package/dist/public/assets/{useRegisteredDebugTemplates-DBDRdptr.js → useRegisteredDebugTemplates-zMcEOGca.js} +1 -1
- package/dist/public/index.html +2 -2
- package/dist/server/modules/client/client-controller.js +1 -1
- package/dist/server/modules/client/client-controller.js.map +1 -1
- package/dist/server/modules/client/client-service.d.ts +16 -2
- package/dist/server/modules/client/client-service.js +21 -3
- package/dist/server/modules/client/client-service.js.map +1 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.d.ts +2 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js +203 -8
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js.map +1 -1
- package/dist/server/modules/workbench/snapshot-revision.d.ts +4 -0
- package/dist/server/modules/workbench/snapshot-revision.js +13 -0
- package/dist/server/modules/workbench/snapshot-revision.js.map +1 -0
- package/dist/server/modules/workbench/workbench-service.d.ts +1 -0
- package/dist/server/modules/workbench/workbench-service.js +3 -2
- package/dist/server/modules/workbench/workbench-service.js.map +1 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.d.ts +6 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js +10 -8
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js.map +1 -1
- package/dist/server/server/create-server.js +1 -1
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/types/domain.d.ts +9 -0
- package/dist/server/ws/workbench-ws-hub.js +135 -33
- package/dist/server/ws/workbench-ws-hub.js.map +1 -1
- package/package.json +1 -1
- package/dist/public/assets/AdaptiveButlerPage-R-XZw7pd.js +0 -3
- package/dist/public/assets/App-DkvE5EyM.js +0 -30
- package/dist/public/assets/FileContextPanel-D_ghXJuW.js +0 -1
- package/dist/public/assets/GitSidebar-D9f9Jxwr.js +0 -6
- package/dist/public/assets/MobileSheet-DLg-gX1t.js +0 -1
- package/dist/public/assets/SettingsPage-HJIC-P-4.js +0 -1
- package/dist/public/assets/TerminalManagerPanel-DpyUTo9k.js +0 -1
- package/dist/public/assets/WorkbenchLayout-ByFw4eeu.js +0 -3
- package/dist/public/assets/WorkbenchShellRoute-BUITtdAg.css +0 -1
- package/dist/public/assets/WorkbenchShellRoute-Kw7JEZI3.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-D0Lrx4Uz.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-wR8d3aP9.js +0 -1
- package/dist/public/assets/index-Byp9hJ0c.js +0 -42
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as d,j as e}from"./index-
|
|
1
|
+
import{b as d,j as e}from"./index-C2G8Gmf1.js";function c(){return d.useEffect(()=>{const t=document.documentElement.style.background,s=document.body.style.background;return document.documentElement.style.background="transparent",document.body.style.background="transparent",()=>{document.documentElement.style.background=t,document.body.style.background=s}},[]),e.jsx("main",{className:"desktop-detach-preview-page","aria-hidden":"true",children:e.jsxs("section",{className:"desktop-detach-preview-card",children:[e.jsx("header",{className:"desktop-detach-preview-bar",children:e.jsx("strong",{className:"desktop-detach-preview-title",children:"小窗口"})}),e.jsx("div",{className:"desktop-detach-preview-body",children:e.jsx("span",{className:"desktop-detach-preview-badge"})})]})})}export{c as DesktopDetachPreviewPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/window-BWqRixxq.js","assets/event-DvH9tcej.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{b as a,
|
|
2
|
+
import{b as a,l as R,_ as D,j as s,t as l}from"./index-C2G8Gmf1.js";import{u as L,g as N}from"./MobileSheet-Gzc14EpR.js";import{FileContextPanel as E}from"./FileContextPanel-C8T7oqRN.js";import{GitSidebar as j}from"./GitSidebar-Bze7DNnc.js";import{TerminalManagerPanel as q}from"./TerminalManagerPanel-PQ-EM64j.js";import{TerminalPage as y}from"./TerminalPage-CvnHXBhw.js";import{W as O,m as v}from"./WorkbenchLayout-rwQib5In.js";import{c as F,u as C,d as P,N as _}from"./App-WOLwMld_.js";import"./WorkbenchModal-B09hC9b5.js";import"./file-tree-icon-Dp_xhVfD.js";import"./default-session-permission-mode-D0wZ9Jek.js";import"./terminal-runtime-meta-BMT-rSEe.js";import"./TerminalRuntimeFallbackModal-D7Aq186N.js";import"./MobileWorkspaceSwitcherHeader-DOr4pTUq.js";import"./MobileTopHeaderFrame-BWorAJ1C.js";import"./window-BWqRixxq.js";import"./event-DvH9tcej.js";function $(n){return{navigationGroups:n,subscribeFileTree:()=>{},requestFileTreeRefresh:()=>{},addFileTreeSnapshotListener:()=>()=>{},subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function U(){return{subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function z(){return{subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function A(n,p){return{navigationGroups:p,currentWorkspaceId:n,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function T(n){return n.kind==="files"?l("shell.filesEntry"):n.kind==="git"?l("shell.gitEntry"):n.kind==="processes"?l("shell.terminalManagerEntry"):n.kind==="terminals"?l("shell.terminalsEntry"):n.kind}function K(n,p){var e;const i=n.workspaceId?((e=p.find(h=>h.workspace.id===n.workspaceId))==null?void 0:e.workspace.name)??null:null,u=T(n);return i?`CodingNS - ${u}(${i})`:`CodingNS - ${u}`}function le(){const{windowId:n}=F(),p=C(),i=P(),u=L(t=>t.sessionDisplaySortMode),[e,h]=a.useState(null),[W,f]=a.useState(!0),[S,k]=a.useState(null),[o,w]=a.useState([]),[r,g]=a.useState(null);a.useEffect(()=>{let t=!1;async function d(){if(!n){h(null),f(!1),k(l("desktopWindow.invalidWindowId"));return}f(!0),k(null);const c=await i.bridge.getWindowDescriptor(n),b=c.ok?c.value??null:i.windows.getDescriptor(n);if(!t){if(!b){h(null),f(!1),k(c.detail??l("desktopWindow.loadDescriptorFailed"));return}i.windows.registerDescriptor(b),i.windows.markWindowOpen(b.windowId),h(b),f(!1)}}return d(),()=>{t=!0}},[i,n]),a.useEffect(()=>{if(!(e!=null&&e.workspaceId)){w([]);return}let t=!1;async function d(){try{const c=await N();if(t)return;w(v(c,u))}catch{if(t)return;w([])}}return d(),()=>{t=!0}},[e==null?void 0:e.workspaceId,u]),a.useEffect(()=>{if(!e){g(null);return}const t=new O({onConnectionChange:()=>{},onSnapshot:d=>{w(v(d,u))},onUnauthorized:()=>{R.clear(),p(`/login?returnTo=${encodeURIComponent(`/desktop-window/${e.windowId}`)}`,{replace:!0})}});return g(t),t.start(),()=>{t.close(),g(null)}},[e,p,u]),a.useEffect(()=>{if(!i.isDesktop||!i.bridge.supported||!e||e.mode!=="external")return;const t=K(e,o);document.title=t,D(async()=>{const{getCurrentWindow:d}=await import("./window-BWqRixxq.js").then(c=>c.w);return{getCurrentWindow:d}},__vite__mapDeps([0,1])).then(({getCurrentWindow:d})=>d().setTitle(t)).catch(()=>{})},[e,o,i.bridge.supported,i.isDesktop]);const M=a.useMemo(()=>r?{navigationGroups:o,subscribeFileTree:r.subscribeFileTree.bind(r),requestFileTreeRefresh:r.requestFileTreeRefresh.bind(r),addFileTreeSnapshotListener:r.addFileTreeSnapshotListener.bind(r),subscribeGitSnapshot:r.subscribeGit.bind(r),requestGitRefresh:r.requestGitRefresh.bind(r),addGitSnapshotListener:r.addGitSnapshotListener.bind(r)}:$(o),[o,r]),x=a.useMemo(()=>r?{subscribeGitSnapshot:r.subscribeGit.bind(r),requestGitRefresh:r.requestGitRefresh.bind(r),addGitSnapshotListener:r.addGitSnapshotListener.bind(r)}:U(),[r]),I=a.useMemo(()=>r?{subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:z(),[r]),G=a.useMemo(()=>r?{navigationGroups:o,currentWorkspaceId:(e==null?void 0:e.workspaceId)??null,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:A((e==null?void 0:e.workspaceId)??null,o),[e==null?void 0:e.workspaceId,o,r]);if(!i.isDesktop)return s.jsx(_,{to:"/",replace:!0});if(W)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:l("common.loading")})});if(S)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:S})});if(!e)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:l("desktopWindow.loadDescriptorFailed")})});let m=null;return e.kind==="files"?m=s.jsx(E,{sessionId:e.sessionId,workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:M}):e.kind==="git"?m=s.jsx(j,{workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:x}):e.kind==="processes"?m=s.jsx(q,{currentWorkspaceId:e.workspaceId,navigationGroups:o,externalWindowMode:!0,workbenchShellOverrides:I}):e.kind==="terminals"&&(m=s.jsx(y,{externalWindowMode:!0,externalWindowWorkspaceId:e.workspaceId,workbenchShellOverrides:G})),m?s.jsx("main",{className:"desktop-window-page",children:s.jsx("div",{className:"desktop-window-body","data-window-kind":e.kind,"aria-label":T(e),children:m})}):s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:l("desktopWindow.unsupportedKind",{kind:e.kind})})})}export{le as DesktopWindowPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as u,j as i,t as r,A as Ln}from"./index-C2G8Gmf1.js";import{e as Wn,d as fi,f as di}from"./App-WOLwMld_.js";import{ae as hi,u as pi}from"./MobileSheet-Gzc14EpR.js";import{av as mi,r as Kt,w as yt,aw as bi,u as vi,X as Ne,ax as yi,ay as $t,az as dt,aA as xi,aB as gi,aC as Ci}from"./WorkbenchLayout-rwQib5In.js";import{W as Pi}from"./WorkbenchModal-B09hC9b5.js";import{a as wt,b as St,F as ji}from"./file-tree-icon-Dp_xhVfD.js";import"./window-BWqRixxq.js";import"./event-DvH9tcej.js";const wi=new Set([".ds_store","thumbs.db","ehthumbs.db","desktop.ini",".spotlight-v100",".trashes",".fseventsd","__macosx","$recycle.bin","system volume information",".apdisk",".appledouble",".temporaryitems"]),Si=["._"];function Ot(t){return t.split(/[/\\]/).filter(Boolean).pop()??t}function Ni(t){const n=t.trim().toLowerCase();return n?wi.has(n)||Si.some(a=>n.startsWith(a)):!1}function Xt(t,n,a){return a?[...t]:t.filter(o=>!Ni(n(o)))}function xt(t,n){return Xt(t,a=>a.name,n)}function Di(t,n){return n?t:Object.entries(t).reduce((a,[o,h])=>(a[o]=xt(h,!1),a),{})}async function Ht(t,n){const[a,o]=await Promise.all([mi(n),hi(t)]);return Ei(a.changes,o.items)}function Ei(t,n){const a=new Set(n.map(o=>Ct(o.path)));return t.filter(o=>a.has(Ct(o.path))||o.oldPath!==null&&a.has(Ct(o.oldPath)))}function ki(t){const n=Sn("","");for(const a of t){const o=Ct(a.path),h=o.split("/").filter(Boolean);let d=n;h.forEach((m,x)=>{const C=h.slice(0,x+1).join("/");if(x===h.length-1){d.children.set(`file:${C}`,{kind:"file",name:m,path:o,change:a});return}const R=`directory:${C}`,k=d.children.get(R);if(k&&k.kind==="directory"){d=k;return}const V=Sn(m,C);d.children.set(R,V),d=V})}return Hn(On([...n.children.values()]))}function $n(t,n){const a=t.oldPath?`${t.oldPath} -> ${t.path}`:t.path;return qt(t)?`${a} ${n}`:a}function qt(t){return t.status==="D"||t.stagedStatus==="D"||t.worktreeStatus==="D"}function gt(t){return t.split("/").filter(Boolean).pop()??t}function Ct(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function Sn(t,n){return{kind:"directory",name:t,path:n,children:new Map}}function On(t){return[...t].sort((n,a)=>n.kind!==a.kind?n.kind==="directory"?-1:1:n.name.localeCompare(a.name,"zh-CN")).map(n=>n.kind==="directory"?{kind:"directory",name:n.name,path:n.path,children:On([...n.children.values()])}:n)}function Hn(t){return t.map(n=>{var m;if(n.kind!=="directory")return n;const a=Hn(n.children);let o=n.name,h=n.path,d=a;for(;d.length===1&&((m=d[0])==null?void 0:m.kind)==="directory";){const x=d[0];o=`${o}/${x.name}`,h=x.path,d=x.children}return{kind:"directory",name:o,path:h,children:d}})}const Mi=450,_i=60*1e3,Nn=20,Dn=16;function Ri({sessionId:t,workspaceId:n,showSystemFiles:a,selectedPath:o,refreshVersion:h,onCountChange:d,onSelectFile:m,onOpenFile:x}){const[C,R]=u.useState("tree"),[k,V]=u.useState([]),[oe,L]=u.useState(!0),[ce,ue]=u.useState(!1),[W,tt]=u.useState([]),D=u.useRef(null),{showToast:me}=Wn();u.useEffect(()=>{const b=Kt(ht(n,t),_i);R("tree"),V(b??[]),L(b===null),ue(!1),tt([]),D.current=null},[t,n]),u.useEffect(()=>{let b=!1;async function v(){L(!0);try{const j=await Ht(t,n);b||(V(j),yt(ht(n,t),j))}catch(j){b||me({title:zt(j,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{b||L(!1)}}return v(),()=>{b=!0}},[h,t,me,n]);async function Dt(){L(!0);try{const b=await Ht(t,n);V(b),yt(ht(n,t),b)}catch(b){me({title:zt(b,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{L(!1)}}async function be(){if(De.length!==0){ue(!0);try{await bi(n,De.map(v=>v.path));const b=await Ht(t,n);V(b),yt(ht(n,t),b),me({title:r("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(b){me({title:zt(b,r("git.stageFailed")),tone:"error"})}finally{ue(!1)}}}function S(b){tt(v=>v.includes(b)?v.filter(j=>j!==b):[...v,b])}function B(b){const v=Date.now(),j=D.current;return D.current={filePath:b,timestamp:v},(j==null?void 0:j.filePath)===b&&v-j.timestamp<=Mi}async function $(b,v){if(v&&B(b)){await x(b),D.current=null;return}v||(D.current=null),await m(b)}const N=u.useMemo(()=>Xt(k,b=>gt(b.path),a),[k,a]),De=N.filter(b=>!b.staged),O=ki(N),Ee=new Set(W);return u.useEffect(()=>{d==null||d(N.length)},[d,N.length]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"file-panel-session-toolbar",children:[i.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":r("conversation.filePanelSessionViewLabel"),children:[i.jsx("button",{className:C==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":C==="tree",onClick:()=>R("tree"),children:r("conversation.filePanelSessionTreeView")}),i.jsx("button",{className:C==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":C==="list",onClick:()=>R("list"),children:r("conversation.filePanelSessionListView")})]}),i.jsxs("div",{className:"file-panel-session-actions",children:[i.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Dt(),disabled:oe||ce,children:r("conversation.filePanelRefresh")}),i.jsx("button",{className:"primary-button",type:"button",onClick:()=>void be(),disabled:ce||De.length===0,children:r("conversation.filePanelSessionStageAll")})]})]}),i.jsxs("div",{className:"file-panel-session-summary",children:[i.jsx("span",{children:`${r("conversation.filePanelSessionSummary")} ${N.length}`}),i.jsx("span",{children:`${r("conversation.filePanelSessionUnstagedSummary")} ${De.length}`})]}),i.jsx("div",{className:"file-tree",children:oe?i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionLoading")}):N.length===0?i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionEmpty")}):C==="tree"?zn({nodes:O,depth:0,collapsedPathSet:Ee,selectedPath:o,onToggleTreePath:S,onFileClick:$}):Ti({items:N,selectedPath:o,onFileClick:$})})]})}function zn({nodes:t,depth:n,collapsedPathSet:a,selectedPath:o,onToggleTreePath:h,onFileClick:d}){return t.map(m=>{if(m.kind==="directory"){const x=!a.has(m.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":x,style:{paddingInlineStart:`${Nn+n*Dn}px`},onClick:()=>h(m.path),children:[i.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:x?"v":">"}),i.jsx("span",{className:"file-tree-label",children:m.name})]}),x?i.jsx("div",{className:"file-tree-children",children:zn({nodes:m.children,depth:n+1,collapsedPathSet:a,selectedPath:o,onToggleTreePath:h,onFileClick:d})}):null]},`session-directory:${m.path}`)}return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":o===m.change.path,"data-kind":"file",style:{paddingInlineStart:`${Nn+n*Dn}px`},onClick:()=>void d(m.change.path,!qt(m.change)),children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),i.jsx("span",{className:"git-tree-file-icon","data-kind":St(m.name),"aria-hidden":"true",children:wt(m.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:m.name}),i.jsx("span",{className:"file-tree-path",children:$n(m.change,r("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":m.change.status,children:m.change.status}),i.jsx("span",{className:"file-session-badge subtle",children:m.change.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-file:${m.path}`)})}function Ti({items:t,selectedPath:n,onFileClick:a}){return t.map(o=>i.jsx("div",{className:"file-session-list-item",children:i.jsxs("button",{className:"file-session-list-button",type:"button","data-active":n===o.path,onClick:()=>void a(o.path,!qt(o)),children:[i.jsx("span",{className:"git-tree-file-icon","data-kind":St(gt(o.path)),"aria-hidden":"true",children:wt(gt(o.path))}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:gt(o.path)}),i.jsx("span",{className:"file-tree-path",children:$n(o,r("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":o.status,children:o.status}),i.jsx("span",{className:"file-session-badge subtle",children:o.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-list:${o.path}`))}function ht(t,n){return`file-panel.session-changes.${t}.${n}`}function zt(t,n){return t instanceof Ln?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??n):n}const g="",Fi=450,Z=8,pt=4,Ai=176,Bi=120,Li=300*1e3,Wi=60*1e3,En=1600,$i=20,Oi=16;function Da({className:t,sessionId:n,workspaceId:a,hideHeading:o=!1,hideTabs:h=!1,externalRevealRequest:d=null,externalWindowMode:m=!1,workbenchShellOverrides:x}){var Pn,jn;const C=vi(),{navigationGroups:R,subscribeFileTree:k,requestFileTreeRefresh:V,addFileTreeSnapshotListener:oe,subscribeGitSnapshot:L,requestGitRefresh:ce,addGitSnapshotListener:ue}={...C,...x},[W,tt]=u.useState({}),[D,me]=u.useState([]),[Dt,be]=u.useState([]),[S,B]=u.useState(g),[$,N]=u.useState([]),[De,O]=u.useState(null),[Ee,b]=u.useState(!1),[v,j]=u.useState(!1),[E,nt]=u.useState(!1),[We,$e]=u.useState(!1),[Q,Oe]=u.useState(""),[Et,I]=u.useState(null),[it,at]=u.useState(!1),[st,lt]=u.useState(null),[H,He]=u.useState("workspace"),[Zt,rt]=u.useState(0),[Jt,kt]=u.useState(0),[ze,fe]=u.useState(!1),[Ue,z]=u.useState(!1),[ee,K]=u.useState(null),[de,ke]=u.useState(null),[T,Me]=u.useState(null),[F,Qt]=u.useState(null),[It,en]=u.useState([]),[G,Mt]=u.useState(!1),[qn,ve]=u.useState(null),te=u.useRef({}),ne=u.useRef({}),M=u.useRef([]),X=u.useRef(g),Ve=u.useRef(!1),Ke=u.useRef(null),tn=u.useRef(null),nn=u.useRef(null),_t=u.useRef(null),an=u.useRef(null),sn=u.useRef(null),ye=u.useRef(0),ie=u.useRef(new Map),{showToast:P}=Wn(),Ge=fi(),q=pi(e=>e.showSystemFiles),Xe=!!(n!=null&&n.trim()),ln=o&&Ge.isMobile;u.useEffect(()=>{Ne("file_panel.props",{sessionId:n,workspaceId:a,externalWindowMode:m})},[m,n,a]),u.useEffect(()=>{X.current=S},[S]);function xe(e){tt(s=>{const l=typeof e=="function"?e(s):e;return te.current=l,l})}function _e(e){me(s=>{const l=typeof e=="function"?e(s):e;return M.current=l,l})}u.useEffect(()=>{var f,p;if(At(),!a){At(),Ve.current=!1,te.current={},ne.current={},M.current=[],X.current=g,xe({}),_e([]),be([]),B(g),$e(!1),Oe(""),I(null),at(!1),b(!1),Mt(!1),ve(null),N([]),O(null),K(null),ke(null),Me(null);return}Ve.current=!0;const e=Kt(Tn(a),Li);Ne("file_panel.workspace_snapshot",{workspaceId:a,cached:!!e,cachedRootItems:((p=(f=e==null?void 0:e.treeCache)==null?void 0:f[g])==null?void 0:p.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const s=na((e==null?void 0:e.activeDirectoryPath)??g,(e==null?void 0:e.treeCache)??{}),l=Rn((e==null?void 0:e.expandedDirectories)??[],s),c=vt((e==null?void 0:e.treeCache)??{},s,l);te.current=c,ne.current=Fn((e==null?void 0:e.treeRevisionByPath)??{},c),M.current=l,X.current=s,xe(c),_e(l),be([]),B(s),b(!1),j(!1),$e(!1),Oe(""),I(null),at(!1),queueMicrotask(()=>{Ve.current=!1})},[a]),u.useEffect(()=>{if(!d||d.workspaceId!==a)return;const e=()=>{if(sn.current===d.requestId)return;sn.current=d.requestId,He("workspace"),(d.openViewer?Ae(d.filePath):pe(d.filePath)).catch(l=>{P({title:J(l,r("conversation.filePanelOpenFailed")),tone:"error"})})};if(Ve.current){queueMicrotask(e);return}e()},[d,Ae,pe,P,a]),u.useEffect(()=>{if(a)return oe(e=>{e.workspaceId===a&&(ne.current={...ne.current,[e.path]:typeof e.revision=="string"?e.revision:null},xe(s=>({...s,[e.path]:e.items})),e.path===g&&b(!1),be(s=>s.filter(l=>l!==e.path)),Jn(e.path,e.items))})},[oe,a]),u.useEffect(()=>()=>{At()},[]),u.useEffect(()=>{a&&k(a,Vt(M.current,X.current),{knownRevisionByPath:ne.current})},[S,D,k,a]),u.useEffect(()=>{N([]),O(null),lt(null),ve(null),rt(0),fe(!1),z(!1),K(null),ke(null),Me(null),Ke.current=null,ye.current+=1},[n]),u.useEffect(()=>{!Xe&&H==="session"&&He("workspace")},[H,Xe]),u.useEffect(()=>{h&&H!=="workspace"&&He("workspace")},[H,h]),u.useEffect(()=>{if(!ze&&!Ue&&!ee)return;function e(l){var y,w,se;if(!(l.target instanceof Node))return;const c=((y=tn.current)==null?void 0:y.contains(l.target))??!1,f=((w=nn.current)==null?void 0:w.contains(l.target))??!1,p=((se=_t.current)==null?void 0:se.contains(l.target))??!1;!c&&!f&&!p&&(fe(!1),z(!1),K(null),ke(null))}function s(l){l.key==="Escape"&&(fe(!1),z(!1),K(null),ke(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",s),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",s)}},[ze,Ue,ee]),u.useLayoutEffect(()=>{if(!ee||typeof window>"u"){ke(null);return}const e=ee;function s(){const c=_t.current;if(!c)return;const f=c.getBoundingClientRect();ke(qi({x:e.positionX,y:e.positionY},{width:f.width||Ai,height:f.height||c.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}s();const l=window.requestAnimationFrame(s);return window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{window.cancelAnimationFrame(l),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[ee]),u.useEffect(()=>{if(!a)return;const e=Rn(D,S),s=vt(W,S,e);yt(Tn(a),{treeCache:s,treeRevisionByPath:Fn(ne.current,s),expandedDirectories:e,activeDirectoryPath:S})},[S,D,W,a]),u.useEffect(()=>{if(Ve.current)return;const e=vt(W,S,D);aa(W,e)||xe(e)},[S,D,W]),u.useEffect(()=>{let e=!1;const s=(a==null?void 0:a.trim())??null;async function l(f){if(!s)return;const p=xt(te.current[g]??[],q),y=(f==null?void 0:f.silent)!==!0&&p.length===0;y&&b(!0),Ne("file_panel.load_root_tree.start",{sessionId:n,workspaceId:s,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:p.length});try{const w=await Ft(g,{force:!0});e||(Ne("file_panel.load_root_tree.end",{sessionId:n,workspaceId:s,itemCount:w.length}),xe(se=>({...vt(se,X.current,M.current),[g]:w})))}catch(w){!e&&!An(w)&&P({title:J(w,r("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&y&&b(!1)}}if(xt(te.current[g]??[],q).length>0){const f=window.setTimeout(()=>{s&&(k(s,Vt(M.current,X.current),{knownRevisionByPath:ne.current}),l({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return l(),()=>{e=!0}},[n,q,P,a]),u.useEffect(()=>{if(!a||!n){kt(0);return}const e=Kt(sa(a,n),Wi);Ne("file_panel.session_change_count.snapshot",{sessionId:n,workspaceId:a,cached:e!==null,cachedCount:e}),kt(e??0)},[n,Zt,a]),u.useEffect(()=>{if(!a){en([]);return}const e=a.trim();L(e),ce(e)},[a,L,ce]),u.useEffect(()=>{if(!a)return;const e=a.trim();return ue(s=>{var l;s.workspaceId===e&&en(((l=s.status)==null?void 0:l.changes)??[])})},[ue,a]);const ot=u.useMemo(()=>Xt(It,e=>Ot(e.path),q),[It,q]),A=u.useMemo(()=>{const e=new Map,s=new Set;for(const l of ot){const c=l.path.replace(/\\/g,"/"),f=l.worktreeStatus??l.stagedStatus??l.status;e.set(c,f);const p=c.split("/");for(let y=1;y<p.length;y++)s.add(p.slice(0,y).join("/"))}return{statusByPath:e,changedDirs:s}},[ot]),ge=u.useMemo(()=>Di(W,q),[q,W]),Ce=u.useMemo(()=>Et===null?null:xt(Et,q),[Et,q]),Re=ge[g]??[],Pe=We&&Ce!==null,ct=u.useMemo(()=>G?Gt(Re,ge,A.statusByPath,A.changedDirs):Re,[A.changedDirs,A.statusByPath,Re,G,ge]),Yn=u.useMemo(()=>Pe?(Ce??[]).map(e=>U(e.path,e.kind)):Un(ct,ge,D,G,A.statusByPath,A.changedDirs),[D,A.changedDirs,A.statusByPath,Pe,G,Ce,ge,ct]),Te=((Pn=R.find(e=>e.workspace.id===a))==null?void 0:Pn.workspace)??null,_=_n($),Rt=(_==null?void 0:_.path)??null,he=(_==null?void 0:_.kind)==="file"?_.path:null,ut=u.useMemo(()=>new Set($.map(e=>e.path)),[$]),qe=u.useMemo(()=>bt($),[$]),Tt=!!(Te!=null&&Te.path&&$.length===1&&Rt),rn=$.length===1&&(_==null?void 0:_.kind)==="file",on=qe.length>0,je=qe.length>0,Ye=!!(F!=null&&F.items.length&&a),cn=!!((he?re(he):S)&&D.length);async function un(e,s=!1){if(!a)return[];if(!s){const l=te.current[e];if(l)return l}e===g?b(!0):be(l=>jt(l,e));try{const l=await Ft(e,{force:s});return xe(c=>({...c,[e]:l})),l}catch(l){throw An(l)||P({title:J(l,r("conversation.filePanelLoadFailed")),tone:"error"}),l}finally{e===g?b(!1):be(l=>l.filter(c=>c!==e))}}async function we(e){if(!a)return;const s=(e==null?void 0:e.activeDirectoryPath)??X.current,l=(e==null?void 0:e.expandedDirectories)??M.current,c=ia(te.current,s,l);Ne("file_panel.refresh_tree_cache.start",{sessionId:n,workspaceId:a,targetDirectories:c});const p=(await Promise.all(c.map(async y=>{const w=await Ft(y,{force:!0});return[y,w]}))).reduce((y,[w,se])=>(y[w]=se,y),{});Ne("file_panel.refresh_tree_cache.end",{sessionId:n,workspaceId:a,targetDirectories:c,directoryCount:Object.keys(p).length}),xe(p)}async function Ft(e,s){if(!a)return[];if(!(s!=null&&s.force)){const c=te.current[e];if(c)return c}const l=Vt(jt(M.current,e),e||X.current);return k(a,l,{knownRevisionByPath:ne.current}),V(a,[e],{knownRevisionByPath:ne.current}),Zn(e,En,{allowCached:(s==null?void 0:s.force)!==!0})}function Zn(e,s=En,l){const c=te.current[e];return(l==null?void 0:l.allowCached)!==!1&&c?Promise.resolve(c):new Promise((f,p)=>{const y=window.setTimeout(()=>{Qn(e,y),p(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},s),w=ie.current.get(e)??[];ie.current.set(e,[...w,{resolve:f,reject:p,timerId:y}])})}function Jn(e,s){const l=ie.current.get(e)??[];l.length!==0&&(ie.current.delete(e),l.forEach(c=>{window.clearTimeout(c.timerId),c.resolve(s)}))}function Qn(e,s){const c=(ie.current.get(e)??[]).filter(f=>f.timerId!==s);if(c.length===0){ie.current.delete(e);return}ie.current.set(e,c)}function At(){for(const[e,s]of ie.current.entries())s.forEach(l=>{window.clearTimeout(l.timerId),l.reject(new Error(`FILE_TREE_ABORTED:${e}`))});ie.current.clear()}function Ze(e){N([e]),O(e.path)}function Je(e){B(e.kind==="directory"?e.path:re(e.path))}function In(e){const s=Ui(Yn,De,e);N(s),O(e.path),Je(e)}function ei(e){const s=zi($,e),l=_n(s);N(s),O(e.path),l&&Je(l)}function fn(e){Ze(e),Je(e)}function Fe(e,s){if(s!=null&&s.shiftKey){In(e);return}if(mt(s)){ei(e);return}fn(e)}async function ft(e,s=!1){const l=et(e,s);if(!l.length){B(g);return}_e(c=>Gn(c,l)),B(l[l.length-1]??g);for(const c of l)try{await un(c)}catch{return}}async function pe(e){const s=U(e,"file");Ze(s),Je(s),await ft(e)}async function Ae(e){lt(e),ve(null),Ke.current=null,ye.current+=1,pe(e);const s=ye.current,l=e.replace(/\\/g,"/"),c=A.statusByPath.get(l);if(a&&c&&c!=="?"&&c!=="D")try{const f=await yi(a,e,!1);ye.current===s&&ve(f.content||null)}catch{ye.current===s&&ve(null)}}function dn(e){const s=Date.now(),l=Ke.current;return Ke.current={filePath:e,timestamp:s},(l==null?void 0:l.filePath)===e&&s-l.timestamp<=Fi}function Se(){Ke.current=null}async function ti(e,s){const l=U(e,"file");if(s!=null&&s.shiftKey||mt(s)){Se(),Fe(l,s);return}if(dn(e)){await Ae(e);return}Fe(l,s),await ft(e)}function hn(){$e(!1),Oe(""),I(null),Se()}async function ni(e,s){const l=U(e.path,e.kind);if(s!=null&&s.shiftKey||mt(s)){Se(),Fe(l,s);return}if(e.kind==="directory"){hn(),Fe(l,s),await pn(e.path);return}if(dn(e.path)){hn(),await Ae(e.path);return}await pe(e.path)}async function pn(e){if(Ze(U(e,"directory")),B(e),!M.current.includes(e))try{await un(e),_e(s=>jt(s,e))}catch{}}async function mn(e){if(Ze(U(e,"directory")),B(e),M.current.includes(e)){bn(e);return}await pn(e)}function bn(e){_e(s=>s.filter(l=>l!==e&&!l.startsWith(`${e}/`))),B(re(e)),N([]),O(null)}async function vn(){if(!a)return;const e=a;try{if(ce(e),await we(),he&&await ft(he),Pe&&Q.trim()){const s=await dt(e,Q.trim());I(s.items)}}catch(s){P({title:J(s,r("conversation.filePanelLoadFailed")),tone:"error"})}}async function ii(e){if(e==null||e.preventDefault(),!a||!Q.trim()){I(null);return}at(!0);try{const s=await dt(a,Q.trim());I(s.items)}catch(s){P({title:J(s,r("conversation.filePanelSearchFailed")),tone:"error"})}finally{at(!1)}}function yn(){if(We){$e(!1),Oe(""),I(null);return}$e(!0)}function Y(e){z(!1),e()}function xn(){var e;(e=an.current)==null||e.click()}async function ai(e){var p;const s=((p=e.target.files)==null?void 0:p[0])??null;if(e.target.value="",!s||!a)return;const l=Hi(s.name);if(!l){P({title:r("conversation.filePanelUploadFailed"),tone:"error"});return}const c=kn(S,_),f=Mn(c,l);nt(!0);try{const y=await Ji(s);await xi({workspaceId:a,path:f,contentBase64:y}),await we(),await pe(f),P({title:r("conversation.filePanelUploadSuccess",{name:l}),tone:"success"})}catch(y){P({title:J(y,r("conversation.filePanelUploadFailed")),tone:"error"})}finally{nt(!1)}}async function Bt(e=he){if(!(!a||!e)){nt(!0);try{const s=await gi(a,e),l=Qi(s.contentBase64);Ii(s.fileName,new Blob([l],{type:"application/octet-stream"})),P({title:r("conversation.filePanelDownloadSuccess",{name:s.fileName}),tone:"success"})}catch(s){P({title:J(s,r("conversation.filePanelDownloadFailed")),tone:"error"})}finally{nt(!1)}}}function gn(){const e=he?re(he):S;!e||!M.current.includes(e)||bn(e)}async function Be(e,s=kn(S,_)){if(!a)return;const l=s,c=l?`${l}/`:"",f=window.prompt(e==="create_file"?r("conversation.filePanelCreateFilePrompt"):r("conversation.filePanelCreateDirectoryPrompt"),c);if(!(f!=null&&f.trim()))return;const p=f.trim();j(!0);try{await $t({workspaceId:a,opType:e,dstPath:p,content:e==="create_file"?"":void 0}),await we(),e==="create_directory"?(await ft(p,!0),Ze(U(p,"directory")),B(p)):await pe(p)}catch(y){P({title:J(y,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{j(!1)}}function ae(e,s=qe){var c;if(s.length===0)return;const l=bt(s);Qt({mode:e,items:l}),N(l),O(((c=l[l.length-1])==null?void 0:c.path)??null),P({title:e==="copy"?r("conversation.filePanelCopySelectionSuccess",{count:l.length}):r("conversation.filePanelCutSelectionSuccess",{count:l.length}),tone:"success"}),K(null)}async function Qe(e=Gi(_,S)){if(!a||!F||!F.items.length)return;const s=e??g,l=F.items.map(c=>({source:c,destinationPath:Mn(s,Ot(c.path)||c.path)}));j(!0);try{for(const p of l)F.mode==="cut"&&Pt(p.source.path)===Pt(p.destinationPath)||await $t({workspaceId:a,opType:F.mode==="copy"?"copy":"move",srcPath:p.source.path,dstPath:p.destinationPath});const c=l.map(p=>U(p.destinationPath,p.source.kind)),f=c[c.length-1]??null;if(F.mode==="cut"&&Qt(null),N(c),O((f==null?void 0:f.path)??null),f&&Je(f),Se(),await we({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?re(f.path):X.current,expandedDirectories:M.current}),Pe&&Q.trim()){const p=await dt(a,Q.trim());I(p.items)}rt(p=>p+1),P({title:r("conversation.filePanelPasteSuccess",{count:c.length}),tone:"success"}),K(null)}catch(c){await we().catch(()=>{}),P({title:J(c,r("conversation.filePanelPasteFailed")),tone:"error"})}finally{j(!1)}}function Lt(e=qe){!e.length||v||(Me(bt(e)),K(null))}async function si(){var s,l;if(!a||!(T!=null&&T.length))return;const e=bt(T);j(!0);try{for(const p of e)await $t({workspaceId:a,opType:"delete",srcPath:p.path});const c=Xi(S,e),f=M.current.filter(p=>!e.some(y=>y.kind==="directory"&&Nt(y.path,p)));if(st&&e.some(p=>Nt(p.path,st))&&(ye.current+=1,lt(null),ve(null)),Me(null),N([]),O(null),X.current=c,M.current=f,B(c),_e(f),Se(),await we({activeDirectoryPath:c,expandedDirectories:f}),Pe&&Q.trim()){const p=await dt(a,Q.trim());I(p.items)}rt(p=>p+1),P({title:e.length===1?r("conversation.filePanelDeleteSuccess",{name:Ot(((s=e[0])==null?void 0:s.path)??"")||((l=e[0])==null?void 0:l.path)||""}):r("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(c){P({title:J(c,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{j(!1)}}async function Le(e,s=_){const l=(Te==null?void 0:Te.path)??"",c=(s==null?void 0:s.path)??null;if(c===null||!l){fe(!1);return}try{const f=Zi(l),p=e==="absolute"?Yi(l,c,f):Pt(c,f);await ea(p,Ge),P({title:e==="absolute"?r("conversation.filePanelCopyAbsolutePathSuccess"):r("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){P({title:f instanceof Error?f.message:r("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{fe(!1),K(null)}}function li(e,s,l){return[{id:`open-${e.path}`,label:e.kind==="directory"?D.includes(e.path)?r("conversation.filePanelCollapseDirectory"):r("conversation.filePanelExpandDirectory"):r("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){mn(e.path);return}Ae(e.path)}},{id:`download-${e.path}`,label:r("conversation.filePanelDownload"),disabled:e.kind!=="file"||E,onSelect:()=>{Bt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:r("conversation.filePanelNewFile"),disabled:!a||v||E,onSelect:()=>{Be("create_file",l)}},{id:`create-directory-${e.path}`,label:r("conversation.filePanelNewDirectory"),disabled:!a||v||E,onSelect:()=>{Be("create_directory",l)}},{id:`copy-${e.path}`,label:r("conversation.filePanelCopy"),disabled:s.length===0,onSelect:()=>ae("copy",s)},{id:`cut-${e.path}`,label:r("conversation.filePanelCut"),disabled:s.length===0,onSelect:()=>ae("cut",s)},{id:`paste-${e.path}`,label:r("conversation.filePanelPaste"),disabled:!Ye,onSelect:()=>{Qe(l)}},{id:`copy-relative-${e.path}`,label:r("conversation.filePanelCopyRelativePath"),onSelect:()=>{Le("relative",e)}},{id:`copy-absolute-${e.path}`,label:r("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{Le("absolute",e)}},{id:`delete-${e.path}`,label:r("conversation.filePanelDelete"),disabled:s.length===0||v||E,onSelect:()=>Lt(s)}]}async function Cn(e,s){if(Ge.isMobile)return;e.preventDefault();const l=U(s.path,s.kind),c=ut.has(l.path)?qe:[l],f=l.kind==="directory"?l.path:re(l.path);ut.has(l.path)||fn(l);const p=li(l,c,f);if(Ge.isDesktop){await Ci(p);return}Ge.isWeb&&(fe(!1),z(!1),K({positionX:e.clientX,positionY:e.clientY,items:p}))}u.useEffect(()=>{if(H!=="workspace")return;function e(s){if(!Vi(s)||s.altKey||s.shiftKey||Ki(s.target))return;const l=s.key.toLowerCase();if(l==="c"&&je){s.preventDefault(),ae("copy");return}if(l==="x"&&je){s.preventDefault(),ae("cut");return}l==="v"&&Ye&&(s.preventDefault(),Qe())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[H,je,Ye,ae,Qe]);function Wt(e,s){return i.jsx(i.Fragment,{children:e.map(l=>{const c=U(l.path,l.kind),f=l.kind==="directory",p=f&&D.includes(l.path),y=f&&Dt.includes(l.path),w=ge[l.path]??[],se=G?Gt(w,ge,A.statusByPath,A.changedDirs):w,oi=ut.has(l.path),ci=Rt===l.path,Ie=A.statusByPath.get(l.path.replace(/\\/g,"/")),wn=f&&A.changedDirs.has(l.path.replace(/\\/g,"/")),ui=(F==null?void 0:F.mode)==="cut"&&F.items.some(le=>le.path===l.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-active":ci,"data-selected":oi,"data-cut-pending":ui||void 0,"data-kind":l.kind,"aria-expanded":f?p:void 0,style:{paddingInlineStart:`${$i+s*Oi}px`},onClick:le=>{if(f){if(le.shiftKey||mt(le)){Se(),Fe(c,le);return}Se(),Fe(c,le),mn(l.path);return}ti(l.path,le)},onContextMenu:le=>{Cn(le,l)},children:[i.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:p?"v":">"}),f?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":St(l.name),"aria-hidden":"true",children:wt(l.name)}),i.jsx("span",{className:"file-tree-label","data-status":Ie??void 0,"data-has-changes":wn||void 0,children:l.name}),!f&&Ie?i.jsx("span",{className:"git-status-badge","data-status":Ie,"aria-label":Ie,children:Ie}):null,f&&wn?i.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,y?i.jsx("span",{className:"file-tree-meta",children:r("common.loading")}):null]}),f&&p?i.jsx("div",{className:"file-tree-children",children:y&&!w.length?i.jsx("p",{className:"file-tree-empty",children:r("common.loading")}):se.length?Wt(se,s+1):i.jsx("p",{className:"file-tree-empty",children:r("conversation.filePanelEmptyDirectory")})}):null]},`${l.kind}-${l.path}`)})})}function ri(e){return i.jsx(i.Fragment,{children:e.map(s=>{const l=s.kind==="directory",c=ut.has(s.path),f=Rt===s.path;return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":f,"data-selected":c,"data-kind":s.kind,onClick:p=>{ni(s,p)},onContextMenu:p=>{Cn(p,s)},children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),l?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":St(s.name),"aria-hidden":"true",children:wt(s.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:s.name}),i.jsx("span",{className:"file-tree-path",children:s.path})]})]})},`search-${s.kind}-${s.path}`)})})}return i.jsx("section",{className:["conversation-panel","surface-card","file-panel",t].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:a?i.jsxs(i.Fragment,{children:[i.jsx(ji,{workspaceId:a,filePath:st,open:st!==null,onClose:()=>{ye.current+=1,lt(null),ve(null)},onSaved:async e=>{await we(),await pe(e),rt(s=>s+1)},diffContent:qn}),o?null:i.jsx("div",{className:"file-panel-heading-row",children:i.jsx("h2",{className:"file-panel-heading",children:r("conversation.filePanelTitle")})}),h?null:i.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":r("conversation.filePanelTitle"),children:[i.jsx("button",{className:H==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":H==="workspace",onClick:()=>He("workspace"),children:r("conversation.filePanelWorkspaceTab")}),i.jsxs("button",{className:H==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":H==="session",onClick:()=>{Xe&&He("session")},disabled:!Xe,children:[r("conversation.filePanelSessionTab"),i.jsx("span",{className:"file-panel-tab-badge","aria-label":`${r("conversation.filePanelSessionTab")} ${Jt}`,children:Jt})]})]}),H==="workspace"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:an,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void ai(e)}),ln?i.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":r("conversation.filePanelTitle"),children:i.jsxs("div",{className:"file-mobile-action-shell",ref:nn,children:[i.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":r("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":Ue,"data-active":Ue,onClick:()=>{fe(!1),z(e=>!e)},children:[i.jsx("span",{children:r("conversation.filePanelActionsMenu")}),i.jsx(va,{})]}),Ue?i.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":r("conversation.filePanelActionsMenu"),children:[i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ae("copy")),disabled:!je,children:r("conversation.filePanelCopy")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ae("cut")),disabled:!je,children:r("conversation.filePanelCut")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Qe()),disabled:!Ye||v||E,children:r("conversation.filePanelPaste")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{z(!1),yn()},children:We?r("conversation.filePanelHideSearch"):r("conversation.filePanelShowSearch")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{z(!1),Mt(e=>!e)},disabled:ot.length===0,children:G?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(vn),disabled:Ee||v||it,children:r("conversation.filePanelRefresh")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{z(!1),gn()},disabled:!cn,children:r("conversation.filePanelCollapseCurrent")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{z(!1),xn()},disabled:v||E,children:r("conversation.filePanelUpload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(Bt),disabled:!rn||E,children:r("conversation.filePanelDownload")}),i.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>Y(Lt),disabled:!on||v||E,children:r("conversation.filePanelDelete")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Be("create_file")),disabled:v||E,children:r("conversation.filePanelNewFile")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Be("create_directory")),disabled:v||E,children:r("conversation.filePanelNewDirectory")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Le("absolute")),disabled:!Tt,children:r("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Le("relative")),disabled:!Tt,children:r("conversation.filePanelCopyRelativePath")})]}):null]})}):i.jsxs("div",{className:"file-panel-toolbar","aria-label":r("conversation.filePanelTitle"),children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopy"),"aria-label":r("conversation.filePanelCopy"),onClick:()=>ae("copy"),disabled:!je,children:i.jsx(ca,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCut"),"aria-label":r("conversation.filePanelCut"),onClick:()=>ae("cut"),disabled:!je,children:i.jsx(ua,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelPaste"),"aria-label":r("conversation.filePanelPaste"),onClick:()=>void Qe(),disabled:!Ye||v||E,children:i.jsx(fa,{})}),i.jsxs("div",{className:"file-toolbar-menu-shell",ref:tn,children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopyPath"),"aria-label":r("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":ze,"data-active":ze,onClick:()=>{z(!1),fe(e=>!e)},disabled:!Tt,children:i.jsx(oa,{})}),ze?i.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Le("absolute"),children:r("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Le("relative"),children:r("conversation.filePanelCopyRelativePath")})]}):null]}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCollapseCurrent"),"aria-label":r("conversation.filePanelCollapseCurrent"),onClick:gn,disabled:!cn,children:i.jsx(la,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRefresh"),"aria-label":r("conversation.filePanelRefresh"),onClick:()=>void vn(),disabled:Ee||v||it,children:i.jsx(ra,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),"data-active":We,onClick:yn,disabled:Ee,children:i.jsx(Bn,{})}),ot.length>0?i.jsx("button",{className:"file-toolbar-button",type:"button",title:G?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"aria-label":G?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"data-active":G,onClick:()=>Mt(e=>!e),children:i.jsx(ya,{})}):null,i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelUpload"),"aria-label":r("conversation.filePanelUpload"),onClick:xn,disabled:v||E,children:i.jsx(ha,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelDownload"),"aria-label":r("conversation.filePanelDownload"),onClick:()=>void Bt(),disabled:!rn||E,children:i.jsx(pa,{})}),i.jsx("button",{className:"file-toolbar-button danger",type:"button",title:r("conversation.filePanelDelete"),"aria-label":r("conversation.filePanelDelete"),onClick:()=>Lt(),disabled:!on||v||E,children:i.jsx(ma,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewFile"),"aria-label":r("conversation.filePanelNewFile"),onClick:()=>void Be("create_file"),disabled:v||E,children:i.jsx(da,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewDirectory"),"aria-label":r("conversation.filePanelNewDirectory"),onClick:()=>void Be("create_directory"),disabled:v||E,children:i.jsx(ba,{})})]}),ee&&typeof document<"u"?di.createPortal(i.jsx("div",{className:"file-web-context-menu",ref:_t,role:"menu","aria-label":r("conversation.filePanelActionsMenu"),style:{left:`${(de==null?void 0:de.left)??Math.max(8,ee.positionX)}px`,top:`${(de==null?void 0:de.top)??Math.max(8,ee.positionY)}px`,maxHeight:de?`${de.maxHeight}px`:void 0},children:ee.items.map(e=>i.jsx("button",{className:["file-web-context-menu-item",e.label===r("conversation.filePanelDelete")?"danger":""].filter(Boolean).join(" "),type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>{K(null),e.onSelect()},children:e.label},e.id))}),document.body):null,We?i.jsxs("form",{className:"file-toolbar-search",onSubmit:e=>void ii(e),children:[i.jsx("input",{value:Q,onChange:e=>Oe(e.target.value),placeholder:r("conversation.filePanelSearchPlaceholder")}),ln?i.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":r("conversation.filePanelSearchButton"),disabled:it,children:r("conversation.filePanelSearchButton")}):i.jsx("button",{className:"file-toolbar-button",type:"submit",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),disabled:it,children:i.jsx(Bn,{})})]}):null,i.jsx("div",{className:"file-tree","data-search-mode":Pe,children:Ee&&Re.length===0?i.jsx("p",{className:"file-tree-status status-text",children:r("common.loading")}):Pe?Ce!=null&&Ce.length?ri(Ce):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSearchEmpty")}):G?ct.length?Wt(ct,0):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelNoChanges")}):Re.length?Wt(Re,0):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelEmptyDirectory")})}),i.jsxs(Pi,{open:T!==null,title:r("conversation.filePanelDeleteConfirmTitle"),description:r("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{v||Me(null)},children:[i.jsx("p",{className:"workbench-section-empty",children:T!=null&&T.length?T.length===1?((jn=T[0])==null?void 0:jn.kind)==="directory"?r("conversation.filePanelDeleteDirectoryConfirm",{path:T[0].path}):r("conversation.filePanelDeleteFileConfirm",{path:T[0].path}):r("conversation.filePanelDeleteSelectionConfirm",{count:T.length}):""}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:v,onClick:()=>Me(null),children:r("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:v,onClick:()=>{si()},children:v?r("conversation.filePanelDeleting"):r("conversation.filePanelDelete")})]})]})]}):Xe&&n?i.jsx(Ri,{sessionId:n,workspaceId:a,showSystemFiles:q,selectedPath:he,refreshVersion:Zt,onCountChange:kt,onSelectFile:pe,onOpenFile:Ae}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:r("conversation.filePanelSessionNoSession")})})]}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:r("conversation.filePanelNoWorkspace")})})})}function re(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):g}function et(t,n=!1){const a=t.split("/").filter(Boolean),o=n?a.length:a.length-1,h=[];for(let d=0;d<o;d+=1)h.push(a.slice(0,d+1).join("/"));return h}function kn(t,n){return t||((n==null?void 0:n.kind)==="directory"?n.path:n!=null&&n.path?re(n.path):g)}function Mn(t,n){return t?`${t}/${n}`:n}function Hi(t){var n;return((n=t.split(/[/\\]/).pop())==null?void 0:n.trim())??""}function U(t,n){return{path:t,kind:n}}function _n(t){return t[t.length-1]??null}function zi(t,n){return t.findIndex(o=>o.path===n.path)>=0?t.filter(o=>o.path!==n.path):[...t,n]}function Ui(t,n,a){const o=t.findIndex(x=>x.path===a.path);if(o<0)return[a];const h=n?t.findIndex(x=>x.path===n):o;if(h<0)return[a];const d=Math.min(h,o),m=Math.max(h,o);return t.slice(d,m+1)}function mt(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function Vi(t){return t.ctrlKey||t.metaKey}function Ki(t){if(!(t instanceof HTMLElement))return!1;const n=t.tagName.toLowerCase();return n==="input"||n==="textarea"||n==="select"||t.isContentEditable}function bt(t){const n=[...new Map(t.map(o=>[o.path,o])).values()].sort((o,h)=>o.path.localeCompare(h.path)),a=[];for(const o of n)a.some(h=>h.kind==="directory"&&Nt(h.path,o.path))||a.push(o);return a}function Gi(t,n){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?re(t.path):n}function Xi(t,n){let a=t;for(;a&&n.some(o=>o.kind==="directory"&&Nt(o.path,a));)a=re(a);return a}function Un(t,n,a,o,h,d){const m=[];for(const x of t){if(m.push(U(x.path,x.kind)),x.kind!=="directory"||!a.includes(x.path))continue;const C=n[x.path]??[],R=o?Gt(C,n,h,d):C;m.push(...Un(R,n,a,o,h,d))}return m}function qi(t,n,a){const o=Math.max(0,a.width),h=Math.max(0,a.height),d=Math.max(0,h-Z*2),m=Math.max(0,o-Z*2),x=Math.min(Math.max(n.width,0),m),C=Math.max(0,h-t.y-pt-Z),R=Math.max(0,t.y-pt-Z),k=C<n.height&&R>C,oe=Ut(Math.max(k?R:C,Bi),0,d),L=Math.min(Math.max(n.height,0),oe),ce=k?t.y-pt-L:t.y+pt,ue=Math.max(Z,h-Z-L),W=Math.max(Z,o-Z-x);return{top:Ut(ce,Z,ue),left:Ut(t.x,Z,W),maxHeight:Math.max(0,oe)}}function Ut(t,n,a){return!Number.isFinite(t)||a<n?n:Math.min(Math.max(t,n),a)}function Pt(t,n="posix"){return t?Vn(t,n):"."}function Yi(t,n,a){const o=Vn(t,a),h=Pt(n,a).replace(/^\.[/\\]?/,"");if(!h)return o;const d=Kn(a),m=h.replace(/^[/\\]+/,"");return m?o.endsWith("/")||o.endsWith("\\")?`${o}${m}`:`${o}${d}${m}`:o}function Zi(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function Vn(t,n){return t&&(Kn(n)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function Kn(t){return t==="windows"?"\\":"/"}function Nt(t,n){return n===t||n.startsWith(`${t}/`)}async function Ji(t){const n=await t.arrayBuffer(),a=new Uint8Array(n),o=32768;let h="";for(let d=0;d<a.length;d+=o){const m=a.subarray(d,d+o);h+=String.fromCharCode(...m)}return btoa(h)}function Qi(t){const n=atob(t),a=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)a[o]=n.charCodeAt(o);return a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength)}function Ii(t,n){if(typeof document>"u")throw new Error(r("conversation.filePanelDownloadFailed"));const a=window.URL.createObjectURL(n),o=document.createElement("a");o.href=a,o.download=t,document.body.append(o),o.click(),o.remove(),window.URL.revokeObjectURL(a)}async function ea(t,n){var a;if(!(n.isDesktop&&(await n.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((a=navigator.clipboard)!=null&&a.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!ta(t))throw new Error(r("conversation.filePanelCopyPathFailed"))}}function ta(t){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.left="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n)}}function na(t,n){return t&&et(t,!0).every(h=>h in n)?t:g}function Rn(t,n){if(!n)return[];const a=et(n,!0);return t.filter(o=>a.includes(o))}function vt(t,n,a){const o=Yt(n,a);return Object.entries(t).reduce((h,[d,m])=>(o.has(d)&&(h[d]=m),h),{})}function ia(t,n,a){const h=[...Yt(n,a)].filter(d=>d===g||d in t);return h.length?h:[g]}function Yt(t,n){const a=new Set([g]),o=Gn(n,et(t,!0));for(const h of o){a.add(h);for(const d of et(h,!0))a.add(d)}return a}function aa(t,n){const a=Object.keys(t),o=Object.keys(n);return a.length!==o.length?!1:a.every(h=>t[h]===n[h])}function jt(t,n){return t.includes(n)?t:[...t,n]}function Gn(t,n){return n.reduce((a,o)=>jt(a,o),t)}function Tn(t){return`file-panel.workspace-tree.${t}`}function sa(t,n){return`file-panel.session-change-count.${t}.${n}`}function Fn(t,n){return Object.fromEntries(Object.keys(n).map(a=>[a,t[a]??null]))}function Vt(t,n){return[...Yt(n,t)]}function J(t,n){return t instanceof Ln?t.message:n}function An(t){return t instanceof Error&&(t.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")||t.message.startsWith("FILE_TREE_ABORTED:"))}function la(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function ra(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M12.8 5.2A5.5 5.5 0 1 0 13.5 8h-1.8A3.7 3.7 0 1 1 10.6 5l-1.4 1.4h4V2l-1.4 1.4z",fill:"currentColor"})})}function Bn(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M11.2 10.1l3 3-1.1 1.1-3-3a5 5 0 1 1 1.1-1.1zM6.8 10.3a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z",fill:"currentColor"})})}function oa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3.5 4.3h5.2v1.4H4.9v5.4H3.5zm3.8-2.1h5.2v9.5H7.3z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function ca(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function ua(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M4.2 4.2a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm0 5.4a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm1-3.2 6.6 5.6M5.2 9.6l6.6-5.6",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})}function fa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function da(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function ha(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function pa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 8.5 2.5 2.5 2.5-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function ma(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.5 4.5h9M6.2 2.5h3.6l.6 1.4H13v1.2H3V3.9h2.6zM5.2 5.7v6.1m2.8-6.1v6.1m2.8-6.1v6.1M4.4 13.5h7.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function ba(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function va(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function ya(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function Gt(t,n,a,o){const h=[];for(const d of t){const m=d.path.replace(/\\/g,"/");d.kind==="file"?a.has(m)&&h.push(d):Xn(m,n,a,o)&&h.push(d)}return h}function Xn(t,n,a,o,h){const d=h??new Set;if(d.has(t))return!1;d.add(t);const m=n[t];if(!m)return o.has(t);for(const x of m){const C=x.path.replace(/\\/g,"/");if(x.kind==="file"){if(a.has(C))return!0}else if(Xn(C,n,a,o,d))return!0}return!1}export{Da as FileContextPanel};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{b as l,t as n,j as e,A as kn}from"./index-C2G8Gmf1.js";import{u as Ni,d as vi,e as Si,f as xn}from"./App-WOLwMld_.js";import{u as Ti,X as tt,r as bn,w as Mi,aD as Ei,av as Hi,aE as yn,aF as wi,aG as jn,aH as Ai,ax as Ri,aI as Pi,aw as Li,aJ as Di,aK as _i,aC as Fi,aL as Cn,b as ki,aM as Oi,aN as Gi}from"./WorkbenchLayout-rwQib5In.js";import{g as $i}from"./default-session-permission-mode-D0wZ9Jek.js";import{S as Bi,v as Ui,w as Wi,e as Vi}from"./MobileSheet-Gzc14EpR.js";import{F as Ii,a as Dt,b as _t}from"./file-tree-icon-Dp_xhVfD.js";import{W as Fe}from"./WorkbenchModal-B09hC9b5.js";import"./window-BWqRixxq.js";import"./event-DvH9tcej.js";const Et=56,Nn=28,Ht=72,nt=8,vn=960,Sn=60*1e3,Tn=20,Mn=9,En=9,wt=68,_=12,it=8,Ft=260,zi=120,At=6e4,st={authMode:"none",username:"",password:"",token:"",rememberOnHost:!1};function ps({className:a,workspaceId:i,panelActive:u=!0,externalWindowMode:g=!1,workbenchShellOverrides:m}){const C=Ni(),x=vi(),y=Ti(),{subscribeGitSnapshot:b,requestGitRefresh:N,addGitSnapshotListener:M,requestNavigationRefresh:S,selectWorkspace:T,upsertNavigationSession:f}={...y,...m},[r,h]=l.useState(null),[j,E]=l.useState(null),[d,R]=l.useState([]),[w,de]=l.useState(0),[I,me]=l.useState(null),[he,rt]=l.useState(!1),[G,Oe]=l.useState(null),[ne,z]=l.useState(null),[ge,fe]=l.useState(""),[ot,U]=l.useState(!1),[v,P]=l.useState(!1),[zn,Bt]=l.useState([]),[Q,Ut]=l.useState(!0),[ee,W]=l.useState(!1),[F,Kn]=l.useState(()=>typeof window<"u"?window.innerWidth<=vn:!1),[lt,$]=l.useState([]),[pe,V]=l.useState(null),[xe,ie]=l.useState("unstaged"),[be,K]=l.useState(null),[se,X]=l.useState(null),[Xn,ct]=l.useState(!1),[qn,ut]=l.useState(null),[Yn,Ge]=l.useState(!1),[Wt,$e]=l.useState(null),[L,ye]=l.useState(null),[Vt,je]=l.useState(null),[Zn,Ce]=l.useState(!1),[Ne,ae]=l.useState(null),[te,dt]=l.useState(!1),[Jn,ve]=l.useState(!1),[Qn,It]=l.useState([]),[rs,zt]=l.useState(!1),[Be,mt]=l.useState(new Set),[ei,Se]=l.useState(new Map),[Ue,Kt]=l.useState(null),[ti,Te]=l.useState(!1),[A,q]=l.useState(st),[Xt,We]=l.useState("generic"),[qt,Ve]=l.useState(null),[k,ht]=l.useState(null),[O,gt]=l.useState(null),[Yt,Zt]=l.useState(Et),[ft,pt]=l.useState(!1),[Jt,Me]=l.useState(null),[ni,Ee]=l.useState(null),Qt=l.useRef(null),en=l.useRef(null),tn=l.useRef(null),nn=l.useRef(null),sn=l.useRef(null),an=l.useRef(null),xt=l.useRef(null),He=l.useRef(new Map),Ie=l.useRef(new Map),we=l.useRef(0),rn=l.useRef(u),{showToast:H}=Si(),on=x.isDesktop&&!F;l.useEffect(()=>{tt("git_sidebar.props",{workspaceId:i,externalWindowMode:g})},[g,i]),l.useEffect(()=>{Bt([]),Ut(!0),de(0),me(null),rt(!1),z(null),fe(""),W(!1),$([]),V(null),ie("unstaged"),K(null),X(null),ct(!1),ut(null),Ge(!1),$e(null),ye(null),je(null),Ce(!1),ae(null),dt(!1),ve(!1),It([]),mt(new Set),Se(new Map),Kt(null),Te(!1),q(st),We("generic"),Ve(null),ht(null),gt(null),pt(!1),Zt(Et),Me(null),Ee(null),Ie.current.clear(),He.current.clear()},[i]),l.useEffect(()=>{function t(){Kn(window.innerWidth<=vn)}return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),l.useEffect(()=>{if(!ft)return;const t=document.body.style.cursor,s=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";function o(p){mn(p.clientY)}function c(){pt(!1)}return window.addEventListener("pointermove",o),window.addEventListener("pointerup",c),()=>{document.body.style.cursor=t,document.body.style.userSelect=s,window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",c)}},[ft]),l.useEffect(()=>{var o,c;if(!(i!=null&&i.trim())){h(null),E(null),R([]),de(0),me(null),Oe(null),U(!1);return}const t=i.trim(),s=bn(Pt(t),Sn);if(tt("git_sidebar.snapshot",{workspaceId:t,cached:!!s,cachedHistoryCount:((o=s==null?void 0:s.history)==null?void 0:o.length)??0,cachedChangedCount:((c=s==null?void 0:s.status)==null?void 0:c.changes.length)??0}),s){bt(s),U(!1);return}h(null),E(null),R([]),de(0),me(null),Oe(null),U(!0)},[i]),l.useEffect(()=>{if(i!=null&&i.trim())return M(t=>{var s,o,c;t.workspaceId===i.trim()&&(tt("git_sidebar.snapshot_received",{workspaceId:t.workspaceId,changedCount:((s=t.status)==null?void 0:s.changes.length)??0,historyCount:t.history.length,branchCount:(((o=t.branches)==null?void 0:o.local.length)??0)+(((c=t.branches)==null?void 0:c.remote.length)??0)}),bt(t),U(!1))})},[M,i]),l.useEffect(()=>{if(!(i!=null&&i.trim()))return;const t=i.trim(),s=bn(Pt(t),Sn);b(t,{knownRevision:(s==null?void 0:s.revision)??null}),s||Y()},[N,b,i]),l.useEffect(()=>{const t=rn.current;rn.current=u,i!=null&&i.trim()&&!t&&u&&N(i.trim(),{knownRevision:j})},[u,N,j,i]),l.useEffect(()=>{i&&Mi(Pt(i),{revision:j,status:r,history:d,historyTotalCount:w,historyNextCursor:I,branches:G})},[G,d,I,w,j,r,i]),l.useEffect(()=>{if(!r||!ne)return;r.changes.find(s=>s.path===ne)||z(null)},[ne,r]),l.useEffect(()=>{Ji(nn.current)},[ge]),l.useEffect(()=>{F||($([]),V(null),K(null),Ve(null))},[F]),l.useEffect(()=>{if(!r){$([]);return}const t=new Set(r.changes.map(s=>s.path));$(s=>s.filter(o=>t.has(o)))},[r]);function ii(){const t=tn.current;if(!t)return;t.querySelectorAll(".git-tree-shell").forEach(o=>{o.scrollTop=0})}function bt(t){E(typeof t.revision=="string"?t.revision:null),h(t.status),R(Array.isArray(t.history)?t.history:[]),de(typeof t.historyTotalCount=="number"?t.historyTotalCount:0),me(typeof t.historyNextCursor=="string"?t.historyNextCursor:null),Oe(t.branches??null)}function Y(t){i!=null&&i.trim()&&(U(!0),tt("git_sidebar.refresh_requested",{workspaceId:i.trim(),resetTreeScroll:!1}),N(i.trim(),{knownRevision:j}))}async function yt(t){if(!(i!=null&&i.trim()))return;const s=i.trim();U(!0);try{const[o,c,p]=await Promise.all([Hi(s),yn(s,Tn,null),wi(s)]);bt({status:o,history:c.items,historyTotalCount:c.totalCount,historyNextCursor:c.nextCursor,branches:p}),N(s),t!=null&&t.resetTreeScroll&&requestAnimationFrame(()=>{ii()})}catch(o){H({title:D(o,n("git.panelLoadFailed")),tone:"error"})}finally{U(!1)}}async function ze(){if(!(!i||!I||he)){rt(!0);try{const t=await yn(i,Tn,I);R(s=>{const o=new Set(s.map(p=>p.commitHash)),c=t.items.filter(p=>!o.has(p.commitHash));return[...s,...c]}),de(t.totalCount),me(t.nextCursor)}catch(t){H({title:D(t,n("git.panelLoadFailed")),tone:"error"})}finally{rt(!1)}}}function si(t){if(!Q||he||!I)return;const s=t.currentTarget;s.scrollHeight-s.scrollTop-s.clientHeight<=40&&ze()}async function ai(){if(i){P(!0);try{const t=await Ei(i,"ai");fe(t.validation.normalizedDraft.subject||t.draft.subject)}catch(t){H({title:D(t,n("git.draftFailed")),tone:"error"})}finally{P(!1)}}}async function Ke(t,s){if(i&&t.length){P(!0);try{const o=s?await Pi(i,t):await Li(i,t);h(o),z(t[t.length-1]??null),$(c=>c.filter(p=>!t.includes(p))),V(null),Y()}catch(o){U(!1),H({title:D(o,n("git.stageFailed")),tone:"error"})}finally{P(!1)}}}async function jt(t){if(i&&t.length){P(!0);try{const s=await _i(i,t);h(s),t.includes(ne??"")&&z(null),$(o=>o.filter(c=>!t.includes(c))),V(null),Y()}catch(s){U(!1),H({title:D(s,n("git.discardFailed")),tone:"error"})}finally{P(!1)}}}async function ri(){if(!(!i||!ge.trim())){P(!0);try{await Ai(i,Yi(ge)),H({title:n("git.commitSuccess"),tone:"success"}),fe(""),z(null),Y()}catch(t){H({title:D(t,n("git.commitFailed")),tone:"error"})}finally{P(!1)}}}function Xe(t){q(ts(Ue)),Te(!0),oi(t)}async function oi(t){const s=i==null?void 0:i.trim();if(!s){We("generic");return}try{const o=await jn(s);if((i==null?void 0:i.trim())!==s)return;We(is(o,t))}catch{if((i==null?void 0:i.trim())!==s)return;We("generic")}}function li(){const t=ns(A),s=Xt==="github"?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder");if(A.authMode==="basic"){if(!A.username.trim()){H({title:n("shell.cloneUsernamePlaceholder"),tone:"error"});return}if(!A.password){H({title:s,tone:"error"});return}}if(A.authMode==="token"&&!A.token){H({title:n("shell.cloneTokenPlaceholder"),tone:"error"});return}Kt(t),Te(!1),H({title:t?n("git.remoteAuthSaved"):n("git.remoteAuthCleared"),description:t&&A.rememberOnHost?n("git.remoteAuthRememberHint"):void 0,tone:"success"})}async function ln(){if(i){zt(!0);try{const t=await jn(i);if(t.length===0){H({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){cn([t[0].name]);return}It(t),mt(new Set),Se(new Map),ve(!0)}catch(t){H({title:D(t,n("git.remoteFailed")),tone:"error"})}finally{zt(!1)}}}async function cn(t){if(!i||t.length===0)return;P(!0),Se(new Map);const s=new Map;let o=!1;try{for(const c of t)try{const p=await Cn(i,"push",c,Ue,A.rememberOnHost);s.set(c,{ok:!0,summary:p.summary})}catch(p){if(o=!0,s.set(c,{ok:!1,summary:D(p,n("git.remoteFailed"))}),Se(new Map(s)),_n(p)){Xe(c);return}}Se(s),Y(),o||(H({title:n("git.pushAllSuccess",{count:String(t.length)}),tone:"success"}),ve(!1))}finally{P(!1)}}async function Ct(t){if(i){if(t==="push"){W(!1),ln();return}P(!0);try{const s=await Cn(i,t,void 0,Ue,A.rememberOnHost);H({title:s.summary,tone:"success"}),W(!1),Y()}catch(s){if(_n(s)){Xe();return}H({title:D(s,n("git.remoteFailed")),tone:"error"})}finally{P(!1)}}}async function re(){if(i){P(!0);try{const t=await Di(i);fe(t.commitSubject??""),H({title:t.summary||n("git.undoLastCommitSuccess"),tone:"success"}),W(!1),Y()}catch(t){H({title:D(t,n("git.undoLastCommitFailed")),tone:"error"})}finally{P(!1)}}}async function ci(t){if(i){P(!0);try{const s=await Oi(i,t,!1);Oe(s),W(!1),Y()}catch(s){H({title:D(s,n("git.branchFailed")),tone:"error"})}finally{P(!1)}}}async function Nt(t){const s=i==null?void 0:i.trim();if(!s)throw new Error(n("git.panelLoadFailed"));const o=Ie.current.get(t);if(o)return o;const c=await Gi(s,t);return Ie.current.set(t,c),c}async function Ae(t){X(null),K(null),ut(t),$e(null);const s=Ie.current.get(t)??null;if(ye(s),Ge(!s),s)return;const o=we.current+1;we.current=o;try{const c=await Nt(t);if(we.current!==o)return;ye(c)}catch(c){if(we.current!==o)return;$e(D(c,n("git.commitDetailLoadFailed"))),ye(null)}finally{we.current===o&&Ge(!1)}}function ui(){ut(null),Ge(!1),$e(null),ye(null)}async function Re(t){try{const s=await Nt(t);await B(s.versionLabel,n("git.copyCommitVersionSuccess"))}catch(s){H({title:D(s,n("git.commitDetailLoadFailed")),tone:"error"})}}function Pe(t){X(null),K(null),je(t),ae(null),Ce(!0)}function di(t){var o;const s=((o=d[0])==null?void 0:o.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 B(t.commitHash,n("git.copyCommitHashSuccess"))},{id:`copy-message:${t.commitHash}`,label:n("git.copyCommitMessage"),onSelect:()=>void B(ue(t),n("git.copyCommitMessageSuccess"))},{id:`copy-version:${t.commitHash}`,label:n("git.copyCommitVersion"),onSelect:()=>void Re(t.commitHash)},{id:`explain:${t.commitHash}`,label:n("git.explainCommitAction"),onSelect:()=>Pe(t.commitHash)},...s?[{id:`undo:${t.commitHash}`,label:n("git.undoLastCommit"),disabled:v,onSelect:()=>void re()}]:[]]}async function un(t){X(null),K(null),await Fi(di(t))}async function mi(){var t,s;if(!(!i||!Vt||!Ne||te)){dt(!0);try{const o=await Nt(Vt),c=await Ui({workspaceId:i,provider:Ne,content:Zi(o),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:$i()}),p=c.session??await Wi(c.sessionId);f(p),S(),T(p.workspaceId),C(ki(p.workspaceId,p.sessionId)),Ce(!1),je(null),ae(null),H({title:n("git.explainCommitStarted"),tone:"success"})}catch(o){H({title:D(o,n("git.explainCommitFailed")),tone:"error"})}finally{dt(!1)}}}function qe(t){Bt(s=>s.includes(t)?s.filter(o=>o!==t):[...s,t])}const hi=450;function dn(t){const s=Date.now(),o=Qt.current;return Qt.current={filePath:t,timestamp:s},(o==null?void 0:o.filePath)===t&&s-o.timestamp<=hi}async function Ye(t,s){if(s.binary){H({title:n("git.binaryDiff"),tone:"info"});return}if(s.status==="A"||s.status==="?")Ee(null),Me(t);else if(i)try{const o=await Ri(i,t,s.staged);Ee(o.content),Me(t)}catch{Ee(null),Me(t)}}function Ze(t){z(t),V(null),$(s=>s.includes(t)?s.filter(o=>o!==t):[...s,t])}function mn(t){const s=en.current;if(!s||!Number.isFinite(t))return;const o=s.getBoundingClientRect(),c=o.height-nt;if(!Number.isFinite(o.top)||!Number.isFinite(o.height)||c<=0)return;const p=(t-o.top-nt/2)/c*100;if(!Number.isFinite(p))return;const _e=Math.max(Nn,Math.min(Ht,Math.round(p)));Zt(_e)}function gi(t){t.preventDefault(),mn(t.clientY),pt(!0)}const Le=(r==null?void 0:r.changes)??[],Z=Le.filter(t=>kt(t,"staged")),oe=Le.filter(t=>kt(t,"unstaged")),hn=Ln(Z,"staged"),gn=Ln(oe,"unstaged"),Je=new Set(zn),Qe=new Set(lt),le=Dn(lt,Le,"staged"),ce=Dn(lt,Le,"unstaged"),vt=Le.length===0&&((r==null?void 0:r.snapshot.ahead)??0)>0,fi=Z.length>0&&ge.trim().length>0,et=(G==null?void 0:G.currentBranch)??(r==null?void 0:r.snapshot.branch)??n("common.unknown"),St=Ue!==null,De=Xt==="github",pi=De?n("git.remoteAuthDescriptionGithub"):n("git.remoteAuthDescription"),xi=De?n("git.remoteAuthGithubPatLabel"):n("shell.clonePasswordLabel"),bi=De?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder"),yi=De?n("git.remoteAuthGithubUsernamePlaceholder"):n("shell.cloneUsernamePlaceholder"),Tt=Number.isFinite(Yt)?Yt:Et,ji=Q?`minmax(120px, ${Tt}fr) ${nt}px minmax(140px, ${100-Tt}fr)`:`minmax(120px, 1fr) ${nt}px auto`;l.useEffect(()=>{pe==="staged"&&le.length===0&&V(null),pe==="unstaged"&&ce.length===0&&V(null)},[pe,le.length,ce.length]),l.useEffect(()=>{if(!F)return;const t=oe.length>0?"unstaged":Z.length>0?"staged":"history";ie(s=>s==="unstaged"&&oe.length>0||s==="staged"&&Z.length>0?s:t)},[F,Z.length,oe.length]),l.useEffect(()=>{be&&(d.some(t=>t.commitHash===be)||K(null))},[d,be]),l.useEffect(()=>{se&&(d.some(t=>t.commitHash===se)||X(null))},[se,d]),l.useEffect(()=>{F&&xe!=="history"&&ee&&W(!1)},[F,ee,xe]),l.useLayoutEffect(()=>{if(F||!ee){ht(null);return}function t(){const o=sn.current,c=an.current;!o||!c||typeof window>"u"||ht(Fn(o.getBoundingClientRect(),{width:c.getBoundingClientRect().width||Ft,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)}},[v,G==null?void 0:G.local.length,et,F,ee,St]);const J=be??se;l.useLayoutEffect(()=>{if(!J){gt(null);return}const t=J;function s(){const c=He.current.get(t)??null,p=xt.current;!c||!p||typeof window>"u"||gt(Fn(c.getBoundingClientRect(),{width:p.getBoundingClientRect().width||Ft,height:p.getBoundingClientRect().height||p.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}s();const o=window.requestAnimationFrame(s);return window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{window.cancelAnimationFrame(o),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[J,d.length]),l.useEffect(()=>{if(!J||typeof document>"u")return;const t=J;function s(o){const c=o.target;if(!(c instanceof Node))return;const p=He.current.get(t)??null,_e=xt.current;p!=null&&p.contains(c)||_e!=null&&_e.contains(c)||(K(null),X(null))}return document.addEventListener("pointerdown",s),()=>{document.removeEventListener("pointerdown",s)}},[J]);async function B(t,s){var o;try{if(typeof navigator>"u"||!((o=navigator.clipboard)!=null&&o.writeText))throw new Error("clipboard unavailable");await navigator.clipboard.writeText(t),H({title:s,tone:"success"})}catch{H({title:n("common.copyContentFailed"),tone:"error"})}}async function fn(t,s){typeof window<"u"&&!window.confirm(n("git.discardConfirm",{path:s}))||await jt(t)}function pn(t){const s=(t==null?void 0:t.desktopFloating)===!0&&!F,o=s?{top:(k==null?void 0:k.top)??_,left:(k==null?void 0:k.left)??_,maxHeight:k==null?void 0:k.maxHeight,transformOrigin:(k==null?void 0:k.transformOrigin)??"top right"}:void 0,c=e.jsxs("div",{ref:s?an:void 0,className:"git-operations-menu","data-floating":s?"true":"false",style:o,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:et})]}),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:St?n("git.remoteAuthConfigured"):n("git.remoteAuthNotConfigured")}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>Xe(),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:G==null?void 0:G.local.map(p=>e.jsx("button",{className:"git-menu-item",type:"button",disabled:v||p.current,onClick:()=>void ci(p.name),children:e.jsx("span",{children:p.current?`${n("git.switchBranch")} ${p.name}`:`${n("git.switchBranchTo")} ${p.name}`})},p.name))})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>{W(!1),ct(!0)},children:e.jsx("span",{children:n("git.viewAllVersions")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void Ct("fetch"),children:e.jsx("span",{children:n("git.fetch")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void Ct("pull"),children:e.jsx("span",{children:n("git.pull")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void Ct("push"),children:e.jsx("span",{children:n("git.push")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void re(),children:e.jsx("span",{children:n("git.undoLastCommit")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v||ot,onClick:()=>void yt({resetTreeScroll:!0}),children:e.jsx("span",{children:n("git.refresh")})})]})]});return s?typeof document>"u"?null:xn.createPortal(c,document.body):c}function Mt(t,s){if(s){He.current.set(t,s);return}He.current.delete(t)}function Ci(){var o;if(!J||typeof document>"u")return null;const t=d.find(c=>c.commitHash===J);if(!t)return null;const s=((o=d[0])==null?void 0:o.commitHash)===t.commitHash&&t.commitKind==="local";return xn.createPortal(e.jsx("div",{ref:xt,className:"git-history-entry-menu","data-floating":"true",style:{top:(O==null?void 0:O.top)??_,left:(O==null?void 0:O.left)??_,maxHeight:O==null?void 0:O.maxHeight,transformOrigin:(O==null?void 0:O.transformOrigin)??"top right"},children:e.jsx(Xi,{item:t,canUndo:s,actioning:v,onViewCommitChanges:c=>void Ae(c),onCopyCommitHash:c=>void B(c,n("git.copyCommitHashSuccess")),onCopyCommitMessage:c=>void B(ue(c),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:c=>void Re(c),onExplainCommitChange:c=>void Pe(c),onUndoLastCommit:()=>void re()})}),document.body)}return 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:nn,rows:1,value:ge,onChange:t=>fe(Un(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 ai(),disabled:v||ot,children:e.jsx(as,{})})]}),e.jsxs("div",{className:"git-primary-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void yt({resetTreeScroll:!0}),disabled:v||ot||!i,children:n("git.refreshNow")}),e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>{if(vt){ln();return}ri()},disabled:v||!vt&&!fi,children:vt?n("git.pushNow"):n("git.commitNow")})]})]}),F?e.jsxs("div",{className:"git-mobile-sections",children:[e.jsx(Rt,{title:n("git.stagedChangesTitle"),count:Z.length,expanded:xe==="staged",onToggle:()=>ie("staged"),children:e.jsx(wn,{title:n("git.stagedChangesTitle"),nodes:hn,collapsedTreePathSet:Je,onToggleTreePath:qe,onToggleMobileSelection:Ze,selectedMobilePathSet:Qe,selectedTargets:le,actioning:v,variant:"staged",swipeRowState:qt,onSwipeRowChange:Ve,onStageToggle:Ke,onDiscardWithConfirm:fn,onClearSelectedTargets:()=>$(t=>t.filter(s=>!le.includes(s))),onPreviewFile:Ye})}),e.jsx(Rt,{title:n("git.changesTitle"),count:oe.length,expanded:xe==="unstaged",onToggle:()=>ie("unstaged"),children:e.jsx(wn,{title:n("git.changesTitle"),nodes:gn,collapsedTreePathSet:Je,onToggleTreePath:qe,onToggleMobileSelection:Ze,selectedMobilePathSet:Qe,selectedTargets:ce,actioning:v,variant:"unstaged",swipeRowState:qt,onSwipeRowChange:Ve,onStageToggle:Ke,onDiscardWithConfirm:fn,onClearSelectedTargets:()=>$(t=>t.filter(s=>!ce.includes(s))),onPreviewFile:Ye})}),e.jsxs(Rt,{title:n("git.recentVersionsTitle"),count:w,expanded:xe==="history",onToggle:()=>ie("history"),trailingContent:e.jsx("span",{className:"badge",children:et}),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":ee,onClick:()=>{ie("history"),W(t=>!t)},disabled:v,children:e.jsx(ke,{})}),children:[ee?e.jsx("div",{className:"git-mobile-operations-shell",children:pn()}):null,e.jsx(Ki,{history:d,historyLoadingMore:he,hasMore:!!I,actioning:v,openCommitHash:be,onMenuTriggerRef:Mt,onToggleMenu:t=>K(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void B(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void B(ue(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Re(t),onExplainCommitChange:t=>void Pe(t),onUndoLastCommit:()=>void re(),onLoadMore:()=>void ze()})]})]}):e.jsxs("div",{ref:en,className:"git-content-split",style:{gridTemplateRows:ji},children:[e.jsx("section",{className:"git-card git-tree-panel",children:e.jsxs("div",{ref:tn,className:"git-tree-panel-body",children:[Z.length>0?e.jsx(Hn,{title:n("git.stagedChangesTitle"),count:Z.length,nodes:hn,selectedPath:ne,collapsedTreePathSet:Je,onToggleTreePath:qe,onSelectFile:z,onPreviewFile:(t,s)=>{dn(t)&&Ye(t,s)},onToggleMobileSelection:Ze,onStageToggle:Ke,onDiscard:jt,actioning:v,variant:"staged",isMobileViewport:F,selectedMobilePathSet:Qe,selectedTargets:le,mobileActionMenuOpen:pe==="staged",onToggleMobileActionMenu:()=>V(t=>t==="staged"?null:"staged"),onClearSelectedTargets:()=>$(t=>t.filter(s=>!le.includes(s)))}):null,e.jsx(Hn,{title:n("git.changesTitle"),count:oe.length,nodes:gn,selectedPath:ne,collapsedTreePathSet:Je,onToggleTreePath:qe,onSelectFile:z,onPreviewFile:(t,s)=>{dn(t)&&Ye(t,s)},onToggleMobileSelection:Ze,onStageToggle:Ke,onDiscard:jt,actioning:v,variant:"unstaged",isMobileViewport:F,selectedMobilePathSet:Qe,selectedTargets:ce,mobileActionMenuOpen:pe==="unstaged",onToggleMobileActionMenu:()=>V(t=>t==="unstaged"?null:"unstaged"),onClearSelectedTargets:()=>$(t=>t.filter(s=>!ce.includes(s)))})]})}),e.jsx("button",{className:"git-panel-divider",type:"button",role:"separator","aria-label":n("git.resizePanels"),"aria-orientation":"horizontal","aria-valuemin":Nn,"aria-valuemax":Ht,"aria-valuenow":Q?Tt:Ht,"data-dragging":ft,onPointerDown:gi,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":Q,"aria-label":Q?n("git.collapseRecentVersions"):n("git.expandRecentVersions"),onClick:()=>Ut(t=>!t),children:[e.jsxs("span",{className:"git-section-toggle-main",children:[e.jsx(at,{expanded:Q}),e.jsx("span",{children:n("git.recentVersionsTitle")})]}),e.jsx("span",{className:"workbench-section-counter",children:w})]}),e.jsxs("div",{className:"git-history-actions",children:[e.jsx("span",{className:"badge",children:et}),e.jsx("button",{className:"git-icon-button",type:"button",ref:sn,"aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:()=>W(t=>!t),disabled:v,children:e.jsx(ke,{})}),ee?pn({desktopFloating:!0}):null]})]}),Q?e.jsx(Rn,{history:d,historyLoadingMore:he,hasMore:!!I,actioning:v,openCommitHash:se,useNativeContextMenu:on,onMenuTriggerRef:Mt,onScroll:si,onToggleMenu:t=>{if(on){const s=d.find(o=>o.commitHash===t);s&&un(s);return}X(s=>s===t?null:t)},onOpenContextMenu:t=>void un(t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void B(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void B(ue(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Re(t),onExplainCommitChange:t=>void Pe(t),onUndoLastCommit:()=>void re(),onLoadMore:()=>void ze()}):null]})]}),e.jsxs(Fe,{open:Jn,title:n("git.selectRemoteTitle"),description:n("git.selectRemoteDesc"),onClose:()=>{v||ve(!1)},children:[e.jsxs("div",{className:"git-remote-auth-banner",children:[e.jsxs("div",{className:"git-remote-auth-banner-copy",children:[e.jsx("strong",{children:n("git.remoteAuthStatusLabel")}),e.jsx("span",{children:St?n("git.remoteAuthConfigured"):n("git.remoteAuthNotConfigured")})]}),e.jsx("button",{className:"secondary-button",type:"button",disabled:v,onClick:()=>Xe(),children:n("git.remoteAuthAction")})]}),e.jsx("div",{className:"git-remote-select-list",children:Qn.map(t=>{const s=Be.has(t.name),o=ei.get(t.name);return e.jsxs("label",{className:"git-remote-item",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:v,onChange:()=>{mt(c=>{const p=new Set(c);return p.has(t.name)?p.delete(t.name):p.add(t.name),p})}}),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}),o&&e.jsx("span",{className:`git-remote-result ${o.ok?"ok":"err"}`,children:o.summary})]})]},t.name)})}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:v,onClick:()=>ve(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:v||Be.size===0,onClick:()=>void cn(Array.from(Be)),children:v?n("git.pushing"):n("git.pushSelected",{count:String(Be.size)})})]})]}),e.jsxs(Fe,{open:ti,title:n("git.remoteAuthTitle"),description:pi,onClose:()=>{v||Te(!1)},children:[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:A.authMode,disabled:v,onChange:t=>q(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")})]})]}),A.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:A.username,placeholder:yi,autoComplete:"username",onChange:t=>q(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:xi}),e.jsx("input",{type:"password",value:A.password,placeholder:bi,autoComplete:"current-password",onChange:t=>q(s=>({...s,password:t.target.value}))})]})]}):null,A.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:A.username,placeholder:n("shell.cloneTokenUsernamePlaceholder"),autoComplete:"username",onChange:t=>q(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:A.token,placeholder:n("shell.cloneTokenPlaceholder"),autoComplete:"current-password",onChange:t=>q(s=>({...s,token:t.target.value}))})]})]}):null,De?e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthGithubPatHint")}):null,A.authMode!=="none"?e.jsxs("label",{className:"settings-checkbox git-remote-auth-remember-toggle",children:[e.jsx("input",{type:"checkbox",checked:A.rememberOnHost,onChange:t=>q(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:v,onClick:()=>Te(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:v,onClick:li,children:n("git.remoteAuthSave")})]})]}),e.jsx(Fe,{open:Xn,title:n("git.viewAllVersions"),description:n("git.viewAllVersionsDescription",{count:String(w)}),onClose:()=>ct(!1),children:e.jsx(Rn,{history:d,historyLoadingMore:he,hasMore:!!I,actioning:v,openCommitHash:se,className:"git-history-modal-list",onMenuTriggerRef:Mt,onToggleMenu:t=>X(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void B(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void B(ue(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Re(t),onExplainCommitChange:t=>void Pe(t),onUndoLastCommit:()=>void re(),onLoadMore:()=>void ze()})}),e.jsx(Fe,{open:qn!==null,className:"git-commit-detail-modal",title:(L==null?void 0:L.subject)||n("git.commitDetailTitle"),description:L?n("git.commitDetailDescription",{hash:L.shortHash}):n("git.commitDetailLoading"),onClose:ui,children:Yn?e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailLoading")})}):Wt?e.jsx("div",{className:"git-commit-detail-state is-error",children:e.jsx("p",{children:Wt})}):L?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:L.versionLabel})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitHashLabel")}),e.jsx("strong",{children:L.commitHash})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitAuthorLabel")}),e.jsx("strong",{children:L.authorName})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitTimeLabel")}),e.jsx("strong",{children:Qi(L.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:ue(L)})]}),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:L.changedFiles.length})]}),e.jsx("div",{className:"git-commit-detail-file-list",children:L.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")}),L.diffTruncated?e.jsx("span",{className:"git-commit-detail-truncated",children:n("git.diffTruncated")}):null]}),e.jsx("pre",{className:"git-commit-detail-diff",children:L.diffContent||n("git.emptyDiff")})]})]}):e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailEmpty")})})}),e.jsx(Fe,{open:Zn,className:"git-explain-provider-modal",title:n("git.explainCommitTitle"),description:n("git.explainCommitDescription"),onClose:()=>{te||(Ce(!1),je(null),ae(null))},children:e.jsxs("div",{className:"git-explain-provider-shell",children:[e.jsx(Bi,{workspaceId:i,selectedProvider:Ne,pendingProvider:te?Ne:null,disabled:te,onSelect:t=>ae(t)}),e.jsxs("div",{className:"git-explain-provider-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:te,onClick:()=>{Ce(!1),je(null),ae(null)},children:n("common.cancel")}),e.jsx("button",{type:"button",className:"primary-button",disabled:!Ne||te,onClick:()=>void mi(),children:te?n("conversation.sendingState"):n("git.startExplainCommit")})]})]})}),e.jsx(Ii,{workspaceId:i,filePath:Jt,open:Jt!==null,onClose:()=>{Me(null),Ee(null)},onSaved:async()=>{await yt({resetTreeScroll:!0})},diffContent:ni}),Ci()]})}function Hn({title:a,count:i,nodes:u,selectedPath:g,collapsedTreePathSet:m,onToggleTreePath:C,onSelectFile:x,onPreviewFile:y,onToggleMobileSelection:b,onStageToggle:N,onDiscard:M,actioning:S,variant:T,isMobileViewport:f,selectedMobilePathSet:r,selectedTargets:h,mobileActionMenuOpen:j,onToggleMobileActionMenu:E,onClearSelectedTargets:d}){const R=$t(u),w=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}),!f&&R.length>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":w,title:w,onClick:()=>void N(R,T==="staged"),disabled:S,children:e.jsx(Ot,{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 M(R),disabled:S,children:e.jsx(Gt,{})}):null]}):null,f&&h.length>0?e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:E,disabled:S,children:e.jsx(ke,{})}):null]}),f&&j?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:h.length})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void N(h,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 M(h),children:e.jsx("span",{children:n("git.discard")})}):null,e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:d,children:e.jsx("span",{children:n("git.clearSelection")})})]})]}):null]}),e.jsx("div",{className:"git-tree-shell",role:"tree","aria-label":a,children:u.length?Gn({nodes:u,depth:0,collapsedTreePathSet:m,selectedPath:g,onToggleTreePath:C,onSelectFile:x,onPreviewFile:y,onToggleMobileSelection:b,onStageToggle:N,onDiscard:M,actioning:S,variant:T,isMobileViewport:f,selectedMobilePathSet:r}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Rt({title:a,count:i,expanded:u,onToggle:g,trailingContent:m,headerAction:C,children:x}){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:g,children:[e.jsxs("span",{className:"git-mobile-section-toggle-main",children:[e.jsx(at,{expanded:u}),e.jsx("h3",{children:a})]}),e.jsxs("span",{className:"git-mobile-section-toggle-meta",children:[m,e.jsx("span",{className:"workbench-section-counter",children:i})]})]}),C?e.jsx("div",{className:"git-mobile-section-header-action",children:C}):null]}),u?e.jsx("div",{className:"git-mobile-section-body",children:x}):null]})}function wn({title:a,nodes:i,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,selectedTargets:x,actioning:y,variant:b,swipeRowState:N,onSwipeRowChange:M,onStageToggle:S,onDiscardWithConfirm:T,onClearSelectedTargets:f,onPreviewFile:r}){return e.jsxs("div",{className:"git-mobile-record-shell",children:[x.length>0?e.jsxs("div",{className:"git-mobile-selection-toolbar",children:[e.jsxs("span",{className:"git-mobile-selection-count",children:[n("git.selectedFiles")," ",x.length]}),e.jsxs("div",{className:"git-mobile-selection-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:y,onClick:()=>void S(x,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:y,onClick:()=>void T(x,`${x.length}`),children:n("git.discard")}):null,e.jsx("button",{type:"button",className:"secondary-button",disabled:y,onClick:f,children:n("git.clearSelection")})]})]}):null,e.jsx("div",{className:"git-mobile-record-list",role:"tree","aria-label":a,children:i.length?On({nodes:i,depth:0,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,actioning:y,variant:b,swipeRowState:N,onSwipeRowChange:M,onStageToggle:S,onDiscardWithConfirm:T,onPreviewFile:r}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function On({nodes:a,depth:i,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,actioning:x,variant:y,swipeRowState:b,onSwipeRowChange:N,onStageToggle:M,onDiscardWithConfirm:S,onPreviewFile:T}){return a.map(f=>{if(f.kind==="directory"){const j=!u.has(f.path),E=$t(f.children),d=`directory:${f.path}`;return e.jsxs("div",{className:"git-mobile-record-branch",children:[e.jsx(An,{rowKey:d,openState:(b==null?void 0:b.path)===d?b.direction:null,onOpenStateChange:R=>N(R?{path:d,direction:R}:null),trailingActions:E.length>0?[{label:y==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M(E,y==="staged")},...y==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S(E,f.path)}]:[]]:null,children:e.jsxs("button",{className:"git-mobile-record git-mobile-record-directory",type:"button",style:{paddingInlineStart:`${Mn+i*En}px`},onClick:()=>g(f.path),children:[e.jsxs("span",{className:"git-mobile-record-leading",children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":j,children:e.jsx(at,{expanded:j})}),e.jsx("span",{className:"git-mobile-record-title",children:f.name})]}),e.jsx("span",{className:"git-mobile-record-meta",children:E.length})]})}),j?e.jsx("div",{className:"git-mobile-record-children",role:"group",children:On({nodes:f.children,depth:i+1,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,actioning:x,variant:y,swipeRowState:b,onSwipeRowChange:N,onStageToggle:M,onDiscardWithConfirm:S,onPreviewFile:T})}):null]},d)}const r=`file:${f.path}`,h=C.has(f.path);return e.jsx(An,{rowKey:r,openState:(b==null?void 0:b.path)===r?b.direction:null,onOpenStateChange:j=>N(j?{path:r,direction:j}:null),trailingActions:[{label:n("git.preview"),tone:"neutral",onPress:()=>T(f.change.path,f.change)},{label:y==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M([f.change.path],y==="staged")},...y==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S([f.change.path],f.path)}]:[]],children:e.jsxs("div",{className:"git-mobile-record git-mobile-record-file","data-active":h,style:{paddingInlineStart:`${Mn+i*En}px`},children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:h,"aria-label":`${n("git.selectFile")} ${f.name}`,onChange:()=>m(f.change.path)}),e.jsxs("button",{className:"git-mobile-record-file-main",type:"button",onClick:()=>m(f.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":_t(f.name),"aria-hidden":"true",children:Dt(f.name)}),e.jsxs("span",{className:"git-mobile-record-copy",children:[e.jsx("span",{className:"git-mobile-record-title",children:f.name}),e.jsx("span",{className:"git-mobile-record-path",children:f.path})]}),e.jsx("span",{className:"git-status-badge","data-status":f.status,children:f.status})]})]})},r)})}function An({rowKey:a,openState:i,onOpenStateChange:u,trailingActions:g,children:m}){const C=Vi(),x=l.useRef(null),[y,b]=l.useState(0),N=((g==null?void 0:g.length)??0)*wt;l.useEffect(()=>{i||b(0)},[i,a]);const M=y!==0?y:i==="trailing"?-N:0;function S(h){var j,E;h.button===0&&(x.current={pointerId:h.pointerId,startX:h.clientX},(E=(j=h.currentTarget).setPointerCapture)==null||E.call(j,h.pointerId))}function T(h){const j=x.current;if(!j||j.pointerId!==h.pointerId)return;const E=N>0?N+10:0,d=Math.max(-E,Math.min(0,h.clientX-j.startX));b(d)}function f(h){var E,d;const j=x.current;if(!(!j||j.pointerId!==h.pointerId)){if((d=(E=h.currentTarget).releasePointerCapture)==null||d.call(E,h.pointerId),x.current=null,y<=-44&&(g!=null&&g.length)){C.trigger("gesture"),u("trailing"),b(0);return}u(null),b(0)}}function r(h){var E,d;const j=x.current;!j||j.pointerId!==h.pointerId||((d=(E=h.currentTarget).releasePointerCapture)==null||d.call(E,h.pointerId),x.current=null,b(0))}return e.jsxs("div",{className:"git-mobile-swipe-row","data-open-state":i??"closed","data-dragging":y!==0,children:[g==null?void 0:g.map((h,j)=>e.jsx("button",{type:"button",className:"git-mobile-swipe-action trailing","data-tone":h.tone,style:{right:j*wt,width:wt},onClick:()=>{C.trigger(h.tone==="danger"?"warning":"action"),u(null),h.onPress()},children:h.label},`trailing-${j}`)),e.jsx("div",{className:"git-mobile-swipe-content",style:{transform:`translateX(${M}px)`},onPointerDown:S,onPointerMove:T,onPointerUp:f,onPointerCancel:r,children:m})]})}function Ki({history:a,historyLoadingMore:i,hasMore:u,actioning:g,openCommitHash:m,onMenuTriggerRef:C,onToggleMenu:x,onViewCommitChanges:y,onCopyCommitHash:b,onCopyCommitMessage:N,onCopyCommitVersion:M,onExplainCommitChange:S,onUndoLastCommit:T,onLoadMore:f}){return a.length?e.jsxs("div",{className:"git-mobile-history-list",children:[a.map(r=>e.jsx("article",{className:"git-mobile-history-entry","data-kind":r.commitKind,children:e.jsxs("div",{className:"git-mobile-history-entry-main",children:[e.jsx("span",{className:"git-history-marker","data-kind":r.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:r.subject,children:r.subject}),e.jsx("span",{className:"git-history-kind-badge","data-kind":r.commitKind,children:Wn(r.commitKind)})]}),r.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:r.refs.map(h=>e.jsx("span",{className:"git-history-ref-pill","data-kind":h.kind,"data-remote-index":String(Vn(h.remoteName)),children:h.name},`${r.commitHash}:${h.kind}:${h.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:r.commitHash.slice(0,8)}),e.jsx("span",{children:r.authorName}),e.jsx("time",{dateTime:r.authoredAt,children:In(r.authoredAt)})]})]}),e.jsx("button",{type:"button",className:"git-icon-button",ref:h=>C(r.commitHash,h),"aria-label":n("git.historyItemMenu"),onClick:()=>x(r.commitHash),children:e.jsx(ke,{})})]})},r.commitHash)),u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:f,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"git-tree-status",children:n("git.noHistory")})}function Rn({history:a,historyLoadingMore:i,hasMore:u,actioning:g,openCommitHash:m,className:C,useNativeContextMenu:x=!1,onMenuTriggerRef:y,onScroll:b,onToggleMenu:N,onOpenContextMenu:M,onViewCommitChanges:S,onCopyCommitHash:T,onCopyCommitMessage:f,onCopyCommitVersion:r,onExplainCommitChange:h,onUndoLastCommit:j,onLoadMore:E}){return a.length?e.jsxs("div",{className:["git-history-list",C].filter(Boolean).join(" "),onScroll:b,children:[a.map(d=>{const R=m===d.commitHash;return e.jsxs("article",{className:"git-history-entry","data-kind":d.commitKind,"data-menu-open":R?"true":"false",onContextMenu:w=>{!x||!M||(w.preventDefault(),w.stopPropagation(),M(d))},children:[e.jsx("span",{className:"git-history-marker","data-kind":d.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:d.subject,children:d.subject}),e.jsxs("div",{className:"git-history-title-actions",children:[e.jsx("span",{className:"git-history-kind-badge","data-kind":d.commitKind,children:Wn(d.commitKind)}),x?null:e.jsx("button",{type:"button",className:"git-icon-button git-history-more",ref:w=>y(d.commitHash,w),"aria-label":n("git.historyItemMenu"),onClick:()=>{N(d.commitHash)},children:e.jsx(ke,{})})]})]}),d.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:d.refs.map(w=>e.jsx("span",{className:"git-history-ref-pill","data-kind":w.kind,"data-remote-index":String(Vn(w.remoteName)),children:w.name},`${d.commitHash}:${w.kind}:${w.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:d.commitHash.slice(0,8)}),e.jsx("span",{children:d.authorName}),e.jsx("time",{dateTime:d.authoredAt,children:In(d.authoredAt)})]})]})]},d.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:E,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"status-text",children:n("git.noHistory")})}function Xi({item:a,canUndo:i,actioning:u,onViewCommitChanges:g,onCopyCommitHash:m,onCopyCommitMessage:C,onCopyCommitVersion:x,onExplainCommitChange:y,onUndoLastCommit:b}){return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>g(a.commitHash),children:e.jsx("span",{children:n("git.viewCommitChanges")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>m(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitHash")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>C(a),children:e.jsx("span",{children:n("git.copyCommitMessage")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>x(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitVersion")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>y(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 Gn({nodes:a,depth:i,collapsedTreePathSet:u,selectedPath:g,onToggleTreePath:m,onSelectFile:C,onPreviewFile:x,onToggleMobileSelection:y,onStageToggle:b,onDiscard:N,actioning:M,variant:S,isMobileViewport:T,selectedMobilePathSet:f}){return a.map(r=>{if(r.kind==="directory"){const E=!u.has(r.path),d=$t(r.children),R=`${S==="staged"?n("git.unstage"):n("git.stage")} ${r.path}`,w=`${n("git.discard")} ${r.path}`;return e.jsxs("div",{className:"git-tree-node",children:[e.jsxs("div",{className:"git-tree-row",role:"treeitem","aria-expanded":E,children:[e.jsxs("button",{className:"git-tree-trigger",type:"button",style:{paddingInlineStart:`${6+i*8}px`},onClick:()=>m(r.path),children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":E,children:e.jsx(at,{expanded:E})}),e.jsx("span",{className:"git-tree-label git-tree-label-directory",children:r.name})]}),!T&&d.length>0?e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":R,title:R,onClick:()=>void b(d,S==="staged"),disabled:M,children:e.jsx(Ot,{staged:S==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":w,title:w,onClick:()=>void N(d),disabled:M,children:e.jsx(Gt,{})}):null]}):null]}),E?e.jsx("div",{className:"git-tree-children",role:"group",children:Gn({nodes:r.children,depth:i+1,collapsedTreePathSet:u,selectedPath:g,onToggleTreePath:m,onSelectFile:C,onPreviewFile:x,onToggleMobileSelection:y,onStageToggle:b,onDiscard:N,actioning:M,variant:S,isMobileViewport:T,selectedMobilePathSet:f})}):null]},`directory:${r.path}`)}const h=f.has(r.path),j=T?h:g===r.path;return T?e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":j,"data-mobile":"true",children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:h,"aria-label":`${n("git.selectFile")} ${r.name}`,onChange:()=>y(r.change.path)}),e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":j,"data-mobile":"true",style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>y(r.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":_t(r.name),"aria-hidden":"true",children:Dt(r.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:r.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":r.status,children:r.status})})]})]},`file:${r.path}`):e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":j,children:[e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":j,style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>{C(r.change.path),x&&x(r.change.path,r.change)},children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":_t(r.name),"aria-hidden":"true",children:Dt(r.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:r.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":r.status,children:r.status})})]}),e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":r.variant==="staged"?n("git.unstage"):n("git.stage"),title:r.variant==="staged"?n("git.unstage"):n("git.stage"),onClick:()=>void b([r.change.path],r.variant==="staged"),disabled:M,children:e.jsx(Ot,{staged:r.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 N([r.change.path]),disabled:M,children:e.jsx(Gt,{})}):null]})]},`file:${r.path}`)})}function Pn(a,i){return{kind:"directory",name:a,path:i,children:new Map}}function Ln(a,i){const u=Pn("","");for(const g of a){const m=g.path.replace(/\\/g,"/"),C=m.split("/").filter(Boolean);let x=u;C.forEach((y,b)=>{const N=C.slice(0,b+1).join("/");if(b===C.length-1){x.children.set(`file:${N}`,{kind:"file",name:y,path:m,change:g,status:qi(g,i),variant:i});return}const M=`directory:${N}`,S=x.children.get(M);if(S&&S.kind==="directory"){x=S;return}const T=Pn(y,N);x.children.set(M,T),x=T})}return Bn($n([...u.children.values()]))}function $n(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:$n([...i.children.values()])}:i)}function Bn(a){return a.map(i=>{var x;if(i.kind!=="directory")return i;const u=Bn(i.children);let g=i.name,m=i.path,C=u;for(;C.length===1&&((x=C[0])==null?void 0:x.kind)==="directory";){const y=C[0];g=`${g}/${y.name}`,m=y.path,C=y.children}return{kind:"directory",name:g,path:m,children:C}})}function Dn(a,i,u){const g=new Set(a);return i.filter(m=>kt(m,u)&&g.has(m.path)).map(m=>m.path)}function $t(a){const i=[],u=new Set;function g(m){if(m.kind==="file"){u.has(m.path)||(u.add(m.path),i.push(m.path));return}m.children.forEach(g)}return a.forEach(g),i}function kt(a,i){return i==="staged"?!!a.stagedStatus:!!a.worktreeStatus}function qi(a,i){return i==="staged"?a.stagedStatus??a.status:a.worktreeStatus??a.status}function Yi(a){return{subject:Un(a).trim(),body:null,footer:null,source:"manual"}}function Un(a){return a.replace(/[\r\n]+/g," ")}function ue(a){const i=a.subject.trim(),u=a.body.trim();return u?`${i}
|
|
2
|
+
|
|
3
|
+
${u}`:i}function Zi(a){const i=a.changedFiles.map(m=>`- [${m.status}] ${m.path}${m.oldPath?` (from ${m.oldPath})`:""}`).join(`
|
|
4
|
+
`),u=a.diffContent.length>At?a.diffContent.slice(0,At):a.diffContent,g=a.diffContent.length>At||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||"- 无",g,"","Diff:",u||"(empty diff)"].join(`
|
|
6
|
+
`)}function Ji(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 Wn(a){switch(a){case"local":return n("git.historyKindLocal");case"remote":return n("git.historyKindRemote");default:return n("git.historyKindShared")}}function Vn(a){if(!a)return 0;let i=0;for(const u of a)i=i*33+u.charCodeAt(0)>>>0;return i%6}function Qi(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 D(a,i){return a instanceof kn?es(a)??a.message:typeof a=="object"&&a&&"message"in a?a.message:i}function Pt(a){return`git-sidebar.snapshot.${a}`}function es(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_DISCARD_FAILED":return n("git.discardFailed");case"GIT_UNDO_FAILED":return n("git.undoLastCommitFailed");default:return null}}function _n(a){return a instanceof kn&&a.errorCode==="GIT_REMOTE_AUTH_FAILED"}function ts(a){return!a||!a.mode||a.mode==="none"?st:a.mode==="basic"?{authMode:"basic",username:a.username??"",password:a.password??"",token:"",rememberOnHost:!1}:a.mode==="token"?{authMode:"token",username:a.username??"",password:"",token:a.token??"",rememberOnHost:!1}:st}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 is(a,i){const u=a.find(m=>m.name===i)??a.find(m=>m.name==="origin")??a[0];if(!u)return"generic";const g=u.pushUrl||u.fetchUrl;return ss(g)?"github":"generic"}function ss(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 Fn(a,i,u){const g=Math.max(0,u.width),m=Math.max(0,u.height),C=Math.max(0,m-_*2),x=Math.max(0,g-_*2),y=Math.min(Math.max(i.width||Ft,0),x),b=Math.max(0,m-a.bottom-it-_),N=Math.max(0,a.top-it-_),M=b<i.height&&N>b,T=Lt(Math.max(M?N:b,zi),0,C),f=Math.min(Math.max(i.height,0),T),r=M?a.top-it-f:a.bottom+it,h=Math.max(_,m-_-f),j=Math.max(_,g-_-y);return{top:Lt(r,_,h),left:Lt(a.right-y,_,j),maxHeight:Math.max(0,T),transformOrigin:`${M?"bottom":"top"} right`}}function Lt(a,i,u){return!Number.isFinite(a)||u<i?i:Math.min(Math.max(a,i),u)}function at({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 Ot({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 Gt(){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 as(){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 ke(){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 In(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{ps as GitSidebar,Fn as resolveGitOperationsMenuPosition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as c,j as e,t as a}from"./index-
|
|
1
|
+
import{b as c,j as e,t as a}from"./index-C2G8Gmf1.js";import{e as j,M as f,f as k,h as g,i as v,j as M,k as S,S as L}from"./MobileSheet-Gzc14EpR.js";function E({open:o,workspaces:l,workspaceOptions:t,initialWorkspaceId:d,onClose:b,onSelect:x}){const[n,p]=c.useState(""),[h,u]=c.useState(!1),m=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&&(p(N(i,d)),u(!1))},[d,o,w]),!o)return null;const r=i.find(s=>s.workspace.id===n)??i[0]??null;return e.jsxs(f,{open:o,title:a("shell.createSessionModalTitle"),description:a("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(k,{className:"mobile-create-session-section",tone:"accent",children:e.jsxs(g,{label:a("shell.createSessionWorkspaceLabel"),children:[e.jsxs("button",{type:"button",className:"mobile-create-session-workspace-trigger","aria-label":`${a("shell.createSessionWorkspaceLabel")} ${(r==null?void 0:r.label)??""}`.trim(),"aria-expanded":h?"true":"false",disabled:i.length===0,onClick:()=>{m.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)??a("common.unknown")}),e.jsx("span",{children:(r==null?void 0:r.subtitle)??a("common.unknown")})]}),e.jsx(C,{expanded:h})]}),h?e.jsx(v,{className:"mobile-workspace-home-group mobile-create-session-workspace-list",role:"list",children:i.map(s=>e.jsx(M,{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===n,trailing:e.jsx("span",{className:"mobile-workspace-home-row-trailing",children:s.workspace.id===n?e.jsx(I,{}):e.jsx(y,{})}),style:{"--mobile-workspace-tree-depth":String(s.depth)},onClick:()=>{s.workspace.id!==n&&m.trigger("selection"),p(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(S,{className:"mobile-workspace-home-worktree-badge",children:a("shell.mobileWorktreeBadge")}):null,s.label]}),e.jsx("span",{children:s.subtitle})]})},s.workspace.id))}):null]})}),e.jsx(k,{className:"mobile-create-session-provider-block",heading:a("shell.createSessionProviderLabel"),description:a("shell.providerOptionHint"),children:e.jsx(L,{disabled:!n,workspaceId:n||null,onSelect:s=>{n&&x(n,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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var V=Object.defineProperty;var Z=(e,n,s)=>n in e?V(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var R=(e,n,s)=>Z(e,typeof n!="symbol"?n+"":n,s);import{B as i,A as Y,b as w,t as g,j as r,f as X,Q as H,h as $}from"./index-C2G8Gmf1.js";import{d as _,f as ee}from"./App-WOLwMld_.js";function ne(){return i.request("/api/workspaces")}async function Te(){try{return await i.request("/api/workbench")}catch(e){if(!(e instanceof Y)||e.status!==404)throw e;const n=await ne();return{items:await Promise.all(n.items.map(async o=>({workspace:o,sessions:(await se(o.id)).items})))}}}function Be(e){return i.request("/api/workspaces/import",{method:"POST",body:JSON.stringify(e)})}function Me(e){return i.request("/api/workspaces/clone",{method:"POST",body:JSON.stringify(e)})}function je(e){return i.request(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})}function ke(e){return i.request("/api/debug-targets/analyze",{method:"POST",body:JSON.stringify(e)})}function Ke(e,n){return i.request(`/api/debug-targets/${encodeURIComponent(e)}/launch-plan`,{method:"POST",body:JSON.stringify({})})}function Fe(){return i.request("/api/framework-compatibility-matrix")}function Je(e){return i.request("/api/workspaces/reorder",{method:"PUT",body:JSON.stringify(e)})}function Qe(e,n){return i.request(`/api/workspaces/${encodeURIComponent(e)}/navigation-state`,{method:"PUT",body:JSON.stringify(n)})}function Ge(e){const n=new URLSearchParams;return e!=null&&e.trim()&&n.set("path",e.trim()),i.request(`/api/workspaces/browse${n.size>0?`?${n.toString()}`:""}`)}function We(e){return i.request("/api/workspaces/directories",{method:"POST",body:JSON.stringify(e)})}function se(e){return i.request(`/api/sessions?workspaceId=${encodeURIComponent(e)}`)}function ze(e){return i.request(`/api/sessions/${encodeURIComponent(e)}`)}function Ve(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/changed-files`)}function Ze(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/seen`,{method:"POST"})}function Ye(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/title`,{method:"PATCH",body:JSON.stringify({title:n})})}function Xe(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/archive`,{method:"PATCH",body:JSON.stringify({archived:n})})}function He(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/favorite`,{method:"PATCH",body:JSON.stringify({favorite:n})})}function $e(e){return i.request(`/api/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function _e(e){return i.request("/api/worktrees",{method:"POST",body:JSON.stringify(e)})}function en(e){return i.request(`/api/worktrees/${encodeURIComponent(e)}/merge-preview`,{method:"POST"})}function nn(e){return i.request(`/api/worktrees/${encodeURIComponent(e)}/merge-into-parent`,{method:"POST"})}function sn(e,n){return i.request(`/api/worktrees/${encodeURIComponent(e)}/cleanup`,{method:"POST",body:JSON.stringify(n??{})})}function tn(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/capabilities`)}function on(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests`)}function rn(){return i.request("/api/preferences/quick-phrases")}function an(e){return i.request("/api/preferences/quick-phrases",{method:"PUT",body:JSON.stringify({items:e})})}function te(e,n){const s=new URLSearchParams;return n!=null&&n.trim()&&s.set("workspaceId",n.trim()),i.request(`/api/providers/${encodeURIComponent(e)}/capabilities${s.size>0?`?${s.toString()}`:""}`)}async function oe(e,n){const s=await Promise.allSettled(e.map(async t=>[t,await te(t,n)])),o=[];for(const t of s){if(t.status!=="fulfilled")continue;const[a,l]=t.value;o.push([a,l])}return Object.fromEntries(o)}function un(e,n,s,o="forward"){const t=new URLSearchParams;return n&&t.set("cursor",n),t.set("limit",String(s)),t.set("direction",o),i.request(`/api/sessions/${encodeURIComponent(e)}/messages?${t.toString()}`)}function ln(e,n){return i.requestBlob(`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(n)}/content`)}function cn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(n)})}function dn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/forks`,{method:"POST",body:JSON.stringify(n)})}function fn(e){return i.request("/api/sessions/start-live",{method:"POST",body:JSON.stringify(e)})}function pn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/messages/live`,{method:"POST",body:JSON.stringify(n)})}function mn(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue`)}function gn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue`,{method:"POST",body:JSON.stringify(n)})}function Sn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(n)}`,{method:"DELETE"})}function An(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(n)}/steer`,{method:"POST"})}function hn(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/runtime`)}function yn(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:"POST"})}function vn(e,n,s){return i.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests/${encodeURIComponent(n)}/reply`,{method:"POST",body:JSON.stringify(s)})}const I="codingns.workspace.session-display-sort-mode",b="codingns.file-panel.show-system-files",q="codingns.notification.preferences",C={notifyOnPermissionRequest:!0,notifyOnSessionCompleted:!0,notifyOnSessionFailed:!0};function D(){return typeof window<"u"&&typeof window.localStorage<"u"}function re(e){return e==="createdAt"||e==="updatedAt"||e==="title"}function B(){if(!D())return"createdAt";const e=window.localStorage.getItem(I);return re(e)?e:"createdAt"}function M(){return D()?window.localStorage.getItem(b)==="1":!1}function U(e){return typeof e=="boolean"}function j(){if(!D())return C;const e=window.localStorage.getItem(q);if(!e)return C;try{const n=JSON.parse(e);return{notifyOnPermissionRequest:U(n.notifyOnPermissionRequest)?n.notifyOnPermissionRequest:C.notifyOnPermissionRequest,notifyOnSessionCompleted:U(n.notifyOnSessionCompleted)?n.notifyOnSessionCompleted:C.notifyOnSessionCompleted,notifyOnSessionFailed:U(n.notifyOnSessionFailed)?n.notifyOnSessionFailed:C.notifyOnSessionFailed}}catch{return C}}function k(e,n){return e.notifyOnPermissionRequest===n.notifyOnPermissionRequest&&e.notifyOnSessionCompleted===n.notifyOnSessionCompleted&&e.notifyOnSessionFailed===n.notifyOnSessionFailed}function ie(e){D()&&window.localStorage.setItem(q,JSON.stringify(e))}class ae{constructor(){R(this,"state",{sessionDisplaySortMode:B(),showSystemFiles:M(),notificationPreferences:j()});R(this,"listeners",new Set);R(this,"subscribe",n=>(this.listeners.add(n),()=>{this.listeners.delete(n)}));R(this,"getState",()=>this.state);R(this,"handleStorage",n=>{if(n.key!==null&&n.key!==I&&n.key!==b&&n.key!==q)return;const s=B(),o=M(),t=j(),a=this.state.sessionDisplaySortMode===s,l=this.state.showSystemFiles===o,d=k(this.state.notificationPreferences,t);a&&l&&d||(this.state={sessionDisplaySortMode:s,showSystemFiles:o,notificationPreferences:t},this.emit())});typeof window<"u"&&window.addEventListener("storage",this.handleStorage)}setSessionDisplaySortMode(n){D()&&(n==="createdAt"?window.localStorage.removeItem(I):window.localStorage.setItem(I,n)),this.state.sessionDisplaySortMode!==n&&(this.state={...this.state,sessionDisplaySortMode:n},this.emit())}setShowSystemFiles(n){D()&&(n?window.localStorage.setItem(b,"1"):window.localStorage.removeItem(b)),this.state.showSystemFiles!==n&&(this.state={...this.state,showSystemFiles:n},this.emit())}setNotificationPreferences(n){const s={...this.state.notificationPreferences,...n};k(this.state.notificationPreferences,s)||(ie(s),this.state={...this.state,notificationPreferences:s},this.emit())}emit(){for(const n of this.listeners)n()}}const K=new ae;function Rn(e){return w.useSyncExternalStore(K.subscribe,()=>e(K.getState()))}function ue(){return _().haptics}const le="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAF+0lEQVRYha2XbXBUZxXHf+e5u4SkCZjg0NIWnQLJLgRF5UWnL75MP9gMjqPT2eyC0qlMiYxOUAR206LOyhiSTVscp52O0xamWgu7WTp0qLUz6kht6Qed1L7M5GUTsAoDTRSIJJos2b33+GFfWMJuNqmcT/c595z/+d3nOc+9zxXKWE9Li7tm0fjyqmT6H0t/Fp8sFz9XM+UCauouH8Rx+ifmWWdP7Q0sLRbT98g3lySC/mcSQd+GGwrQt2vzx1G2ZEa6KJ3S1mJxlpOKIDyEmEM3FGCk5vw5YCw3FmFbb9hXfV2gcm/26vINBfhS+LU0qgcKXB9xT1hbr6kdDhtgcYaDxHSNwVBg92Ao0DMY8n97zgAAZnK8U2AoX1D0++rzWfkC44k6wAVghP7C3EQo8Iiijyq61oEDiV2bPjojwKk234pEsPnh/lDgzpyv/olXrwi6qyDsjsQy2ZQXmJdefPWWvp0v3uZ/CLQ9NxZINpxJj84IYDvmOUT2G/T1DD0CUB/pflnhd1eT5Mcnwl90Adi23JzPl9TbAEN7fF9AeapQW5AOicftGQFEOJ+9tEDbB9v8x99r21wLYBlnJ5AGUKhfklz8QEbY3J71nVnZceziUPAbtzvGxAB3wdPH6yPRx6cXvw4gbbm/B5zIO5SvVKjdMxAMrKvviPcpHMyLqvyoN+ybh7AUwIi+M9TaVOGI/SJwc4Fsf6rS2SqgxQBkukPDYTM40RdCZB/Z5gKmEGmzjStq2alBoDqbvF2hEWgF9oEuAvlugdx/Deaz9ZEjvcWKFwXIWaLNv14cDqmwugDvFRVOi8qOrOMdhT6BzQhvoNxzjbjItxo6o8+VqjEjAMBQa1OFXbXwh4KGuLqmDleXToHzwG1FpLs9kah/uvf98IPz08nkSuZbp+vDL4zNCJAHaQt82lH9JfCJ2cQrTFjq8hiZGrfVtQGcDQhrFNYAywELuFw15SwRgN6dvrrahcnkreGXJ0pCtDZVOFULwsCerEBJExhVGAY8FH/Z2cBvPJHY1ySx13cbaXMaqACSwCVRLqlhVNBRVTOm4lxCOSdqPkB0FdA2m5kosGGEHpC3UP2z6uRJb9fx8SwsJEL+nwBNwEKgWqBSoXaORQqtH+VNhDdErJMNnYf/ViqwbBNO3lRbVZFSS9yyIG1jucRuVuGnM6TZZL4d/wS9KEgawIH/gF5EzAWBvzecto9KPG7PqgkBTu0NLHVs7VBlcxnwS8ALgtyp6Kco3S9/OF850lQWYCD41RpMZUiUH5BZmgkRDqmyVaCqeJYeS1dqwJq4UoG56S5w7hb4PMp6YH426LJR1+qSAOrzWYPLZCvIPuAWAIHXxGGXY3geWAV6DOTrJRR+r5q8P9dskNtJ1etBVl4R19FPdh4eLQowEPR5RKxfgebOeGMqGvLMX/V0YrK/W+B+4ATCYZRnEJ5E+Q5gFM4AFwQ+I8hbLks2Ltt/ZKTUg163Rwfamrcj5q/54spvLZes9nZ2/yIx0b8jW/wCLmeLOLoCAEdeAjmYnaWPGXga9Jiia1O28+bAbt8dswJQEFF5IrO2chGVBzxdsY0r2qNnBx5uvkuELkAFedDTHj+nIl4AIzJsjL2XTAOisB+XtqryKLBcLHNyKLSpsSyAgKrKJoRtbksaPV3R5yFz7BaHOOBGOdAQib6SRV4L4KQZqe+I/wvYmZWqE1ue8nbFggjbgDoH/VOxY3vZXdDT0uKuqR37I+jdIH9JV9r3NIbjU717fLe4jPkASDVEYhW5730i2PwqIvdlZkK3eCPdv06E/GuAbmCBJxJbUnIGill13b8fyxRnRG070BiOTwG4MeuyszBSeNiw3KZFYDTzdPLzU7u3LPZEYu+qTq5Tlev+K2YESAQD94rKjqzgl72Pxd/P3VNLsgAyXJizoj161kG3Z4d1aZP6HIC36/i4tyt6dE4AasQNDIhxNnoisXevvZndJcLw9DxvpLsb5XGE9yzD2ZlqzPpVPN0SIf854FaUZz1dsW0fVqdsD5Q05Qhgg7z+oTX+Xyv2pzNX+x+eTlGviPgh3AAAAABJRU5ErkJggg==",Q="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAbGSURBVHgBzZo/bBtVHMd/ZzuJA0gYCYlsOFO7xRFDy1R3olucqd0SJtiSjiCknBckpjZjBxRn7BR3owOqs5Wp7tZKoDgSQysh4UqUOCG2eZ/3/Oznv/fObqJ+pfPZd+/ufn++vz/vnQN5FwjbGZFGQSRYUb+yIu2c2tSxIOOMqpktqKpzz9X3ioSLNZkRgUwLhA4aW9KWvPqVl6mgldmVGZSJr0BX8Pb2gIVnRUltxbiKxFOgeLJzAYL3I5BQdhaL/sN9EJ5k1dADw+1LQU1tN328kYgaIMWzDSX4s0sUHmSVwZ5JeFqIGjhZgeKpokyzdKGUGQuyWOtA03YCxlNIC98K5X3AhLgYrYB2ndLeE5l0IFvXklK4mpRsxvyuvmqrrSX71aZUjlsyM4LkpuzM7w8dHhqoAxbO+9Fm63pSwhspLTSo1dt6n830bl1SStx9fK6/Z9LmWL3B1hZ/BHUl1+pgYI9S4Eh0EEVjJ5/SwiPI7m9Nuf+02SfUZi4pO+o8ynDcKmlRqRkPlZ43xQ+q8IXpVfdIsu88vJd2ZOSD/OcJKRXmtMW//PlMyi9a0jjvH5NZCDStEDydCjSlfvm9pa/hd24poc+zf/zH8PUjsCT57wOp/FjpqtQ9pakjR+KJo60Fbdnl3dMubSw4vrc2J/msSXLlF4ZCg+M4zzjGEzM39888aAWVFpYlZN+fRnfEE1iMh8JtVygsDWWefTOvhYMiCLX+8L8h4QHnVx+cas/klgLZvpb0eDrp9d/trjr609P6brbhgesPDXXA5kpS7t0ywYwVi4fERD8noJ1WfIDzBDYeRRw8GscL1gP5iCv0g7FsqAIX4UH9pHeegEb44uG5EuKsT3iuPbg9J08252VPxQ3CoowFGYlgRhEMEY2eFzp3CbbEQ3j28BnXjwI0CSvnXQu6lMJrnOd67qOV6fAf2HuuLPn2l4kbRgGT9yf2OU825o11lXDw+bgenb8LV5JdjwE8s/rAxMPXj0xMkGbxBkpWX8epCRp5WvuERNAHl9qADQ+j8xz0QuGDOz3rIizXW8/wHa7bzISSKAveNCQGGoVElPU3coaTcDQKhmoL3QxEkLMna2FplzKAOCFLGf6b4x+nJQbauURnHjsWWJQg8+1nsChCsZGh2LuUwTvb11J94zfVeVtPGOOej4CuNNlJI2xa9BUeQQaD3FKG83iAdItHClcSQ4rzLJvRohGsRCowqoexyCxKbNiUqVPrnf5MhBL0VKRTv6IWZCJnZJR4bujm7eprY+GD2/M6g/hZyypgKENGspThHha2fqxdjZ4sUg8iRz16aYLXBrN5SLPLa5tBMrGCT3T7wD0GgYcM1XwU0IWsXZ80wPY7WMpVguM2g0ABvMDmZhkXZox4w3dswvQV44FFSIe4vqT46rrbzSAEru1pXF6j1L2vTND6Us10p15Zr5Ywq2OTQRwUO0UMyiCM27PYDDKYLomRoy2VNq+n9HGfbGbvyzM9FWgd+4zMfWY4iaV1v6+assHCZNOl7XcKnUC0bUQ9osrq3qnTevgUTtZYUz4ecGEDDwtjaTYER8jsx0YAO5Gxc2EfyyP83lqq27b4Fc6gqhRolEXSe1FDrRBUZioslrYpkD3WthzHSyg0WNCIkVFeoNWw3S7UsQsAHqiobvQTgrgSNbL80gizdmU4EyEswsNzPMQxV3hqiO1oR3kDoyD87tOm57QStKusUNiUcigRXSlZQRchZW2qpc0Sdg5AbQDuw3XboDIQcwGAUm7uh3LWEPvPx88zRiNgWd5OaBr3o+oBrmeaCJhdDeZ7BB83kbETdjZ3bmzryii6eaDCR8c0PzUk/wOdTX7SFU//bEmg5EYoUiOCvv5H5NXbnuDffpHUGYoxLJN892uvarsgXXIPa/14SJTU+pBepXOWVf5W88yFI58VOWqBW9DAYNM3KQMRE0x4gO2JYmLZrtD1ItLTC3ooK2rKasdvzAIVwNp2PfTqpwmdWZY+CswMKzDeYZp579acNgDjodSLv+IK31JvcT4o218jlhYbM78LcJcUR8EG8xSWrynLL7sHZl7cnQQUoYKvLJn0eVwnHTenCVgxSSbwWNwF4cmm+owsbpeLxLqEC+WhoyPHhosl4Y3hewN4Pyw8mNzfhiehxFgzvRgg/IfhuLPRDXr4ljfwe5f/nkxz/m6HDWMR4zWrPBHPFx+zQ7/BX/d5zRrvRfeFU0pbfVcJHvpeMcVfDfAGby8TG/LO0BFc0vftiwtfzPBnD02rvFnZnrrwVUR3wvEFt5heARddZVDE/uXGjRdt4bru4UWODcfT5WmFdvE/Jeqz44iuBr4AAAAASUVORK5CYII=",ce="/assets/gemini-D4G1NbrE.png",de="/assets/kimi-BWNNSh7e.png",fe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAABzUlEQVR4AeycQQrCQBAEF1+g6J/0o5LPCXmCnnNx0E2nNqGEPciw024VffV0PZ/fHo7BqflBCSgAxd+aAhQAE4DjbYACYAJwvA1QAEwAjrcBCgAIDBRpA2AZClAATACOtwEKgAnA8TZAATABOD7egNc8tz2ftJ+4gPQD9r5fAbDBDQXALx00XgGwGAUoACYAx9sABcAE4HgboACYABxvAxSwJHC7XFryLNP4bzYg7KBar4CKUHiugDDgar0CKkLhuQLCgKv1CqgIhecKCAOu1iugIhSeKyAMuFqvgIpQeK6AMOBq/XAC7o9H6z5fdlRAtp4PJ2BrAHSeAmADClAATACOtwEKgAnA8TZAATABON4GKAAmAMev2AD4JTuNVwAsTgEKgAnA8TZAATABON4GKAAmAMfbAAXABOB4G9ApoPe6AnoJdt5XQCfA3uvDCXhOU0ueXmBr3x9OwNoPHH2fAmBDClAATACOtwEKgAnA8TZAAX8QONAVGwDLVIACYAJwfLwByf/+2WJ32k9cQPoBe9+vANigAhQAE4DjbYACYAJw/A8NgH/pQeMVAItVgAJgAnC8DVAATACOtwEKgAnA8TZAATABON4GFALS4w8AAAD//x7wkLQAAAAGSURBVAMAKj5LkLSa6SQAAAAASUVORK5CYII=",pe=new Set(["low","medium","high","xhigh"]),me=["claude-code","codex","opencode","gemini","kimi"],ge=["codex","claude-code","opencode","gemini","kimi"],G={"claude-code":{displayNameKey:"conversation.providerClaude",fullDisplayNameKey:"shell.providerClaudeCode",draftTitleKey:"conversation.draftTitleClaude",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:le,defaultRunInputMode:"streaming_guidance",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!0,supportsRunSteeringByDefault:!0,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},codex:{displayNameKey:"conversation.providerCodex",draftTitleKey:"conversation.draftTitleCodex",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:Q,defaultRunInputMode:"streaming_guidance",reasoningLevelPersists:!0,defaultReasoningLevel:null,supportsSlashMenuByDefault:!1,supportsRunSteeringByDefault:!0,supportsQueueWhileRunningByDefault:!0,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!0},opencode:{displayNameKey:"conversation.providerOpenCode",draftTitleKey:"conversation.draftTitleOpenCode",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:fe,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},gemini:{displayNameKey:"conversation.providerGemini",draftTitleKey:"conversation.draftTitleGemini",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:ce,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:null,supportsInterrupt:!0,supportsAttachments:!1,supportsPermissionPrompt:!1,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},kimi:{displayNameKey:"conversation.providerKimi",draftTitleKey:"conversation.draftTitleKimi",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:de,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:null,supportsInterrupt:!0,supportsAttachments:!1,supportsPermissionPrompt:!1,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!0}},Se=Array.from(new Set(Object.values(G).map(e=>e.icon)));let F=!1;function Ae(e){return me.includes(e)}function c(e){return!e||!Ae(e)?null:G[e]}function he(e){return[{id:"provider-default",name:g(e),usesProviderDefault:!0}]}function ye(e){const n=c(e);return he((n==null?void 0:n.defaultModelLabelKey)??"conversation.modelUseCliDefault")}function Cn(e){return!!(e&&c(e))}function wn(e){const n=c(e);return g((n==null?void 0:n.draftTitleKey)??"conversation.draftTitleCodex")}function ve(e,n="compact"){const s=c(e);return s?n==="full"&&s.fullDisplayNameKey?g(s.fullDisplayNameKey):g(s.displayNameKey):(e==null?void 0:e.trim())||g("conversation.providerCodex")}function Re(e){const n=c(e);return(n==null?void 0:n.icon)??Q}function W(){F||typeof window>"u"||(F=!0,Se.forEach(e=>{const n=new window.Image;n.decoding="async",n.src=e,typeof n.decode=="function"&&n.decode().catch(()=>{})}))}function Dn(e){const n=c(e);return{provider:e,canStartSession:!0,canResumeSession:!0,canSendMessage:!0,inRunInputMode:(n==null?void 0:n.defaultRunInputMode)??"none",supportsSubagents:!1,supportsInterrupt:(n==null?void 0:n.supportsInterrupt)??!1,supportsStructuredToolCalls:!0,supportsTokenUsage:!0,supportsAttachments:(n==null?void 0:n.supportsAttachments)??!0,supportsPermissionPrompt:(n==null?void 0:n.supportsPermissionPrompt)??!0,supportsCheckpoint:!1,supportsSessionDelete:(n==null?void 0:n.supportsSessionDeleteByDefault)??!1,modelOptions:ye(e),defaultReasoningLevel:n==null?void 0:n.defaultReasoningLevel,supportsRunSteering:n==null?void 0:n.supportsRunSteeringByDefault,supportsQueueWhileRunning:n==null?void 0:n.supportsQueueWhileRunningByDefault,limitations:[]}}function Pn(e){return(e==null?void 0:e.provider)??"claude-code"}function On(e){var s;if((e==null?void 0:e.supportsSlashMenu)!==void 0)return e.supportsSlashMenu;const n=(e==null?void 0:e.provider)??null;return((s=c(n))==null?void 0:s.supportsSlashMenuByDefault)??!1}function Nn(e){var n;return(e==null?void 0:e.supportsReasoningSelector)!==void 0?e.supportsReasoningSelector:!!((n=e==null?void 0:e.modelOptions)!=null&&n.some(s=>{var o;return((o=s.supportedReasoningEfforts)==null?void 0:o.some(t=>pe.has(t)))??!1}))}function In(e,n){var a;if((e==null?void 0:e.supportsQueueWhileRunning)!==void 0)return e.supportsQueueWhileRunning;const s=(e==null?void 0:e.provider)??null,o=(a=c(s))==null?void 0:a.supportsQueueWhileRunningByDefault;if(o!==void 0)return o;const t=(e==null?void 0:e.inRunInputMode)??"none";return t==="queued_guidance"||t==="none"||t==="streaming_guidance"&&n===!1}function bn(e){var s;if((e==null?void 0:e.supportsRunSteering)!==void 0)return e.supportsRunSteering;const n=(e==null?void 0:e.provider)??null;return((s=c(n))==null?void 0:s.supportsRunSteeringByDefault)??(e==null?void 0:e.inRunInputMode)==="streaming_guidance"}function En(e){const n=c(e);return(n==null?void 0:n.reasoningLevelPersists)??!1}function Ln(e,n){var o;return((o=c(n??null))==null?void 0:o.foldRulesMessagesByDefault)??!1}typeof window<"u"&&W();const x=new Map;function Un(){x.clear()}function qn({disabled:e=!1,workspaceId:n=null,pendingProvider:s=null,selectedProvider:o=null,providers:t=ge,className:a,disabledReasons:l,statusHintByProvider:d,onSelect:P}){const O=ue(),S=!!n,[v,f]=w.useState(()=>J(t,n)),A=t.map(u=>({provider:u}));return w.useEffect(()=>{W()},[]),w.useEffect(()=>{if(!n){f({});return}const u=J(t,n);f(u);const h=t.filter(m=>!u[m]);if(h.length===0)return;let p=!1;return oe(h,n).then(m=>{we(n,m),p||f(N=>({...N,...m}))}),()=>{p=!0}},[t,n]),r.jsx("div",{className:`session-provider-grid${a?` ${a}`:""}`,children:A.map(u=>{const h=ve(u.provider,"full"),p=s===u.provider,m=o===u.provider,N=!!v[u.provider],E=Ce(v[u.provider]??null),L=(l==null?void 0:l[u.provider])??E,T=p?g("shell.startingSession"):L||((d==null?void 0:d[u.provider])??(S&&!N&&!p?g("shell.providerChecking"):null));return r.jsxs("button",{type:"button",className:"session-provider-card","data-provider":u.provider,"data-pending":p?"true":"false","data-selected":m?"true":"false","aria-label":h,disabled:e||!!L,onClick:()=>{O.trigger("action"),P(u.provider)},children:[r.jsx("span",{className:"session-provider-card-icon","aria-hidden":"true",children:r.jsx("img",{src:Re(u.provider),alt:"",loading:"eager",decoding:"async"})}),r.jsxs("span",{className:"session-provider-card-copy",children:[r.jsx("strong",{children:h}),T?r.jsx("span",{className:"session-provider-card-status",children:T}):null]})]},u.provider)})})}function Ce(e){return!e||e.canStartSession!==!1?null:e.limitations[0]??g("conversation.capabilityDenied")}function J(e,n){const s=(n==null?void 0:n.trim())??"";if(!s)return{};const o=[];for(const t of e){const a=x.get(z(s,t));a&&o.push([t,a])}return Object.fromEntries(o)}function we(e,n){const s=e.trim();if(s)for(const[o,t]of Object.entries(n))t&&x.set(z(s,o),t)}function z(e,n){return`${e}::${n}`}function xn(){const e=X(s=>s),n=H(s=>s);return De(e,n)}function De(e,n){var a;const s=$(e);if(!s)return null;const o=!!((a=s.relayTunnel)!=null&&a.enabled),t=n.activeHostId===s.id&&n.candidateProbePhase==="ready"?Pe(n):null;if(t){const l=Oe(t.kind);return{kind:l,url:t.url,endpointId:t.endpointId,autoDirect:o&&l!=="relay",probeInProgress:!1}}return{kind:Ne(s),url:s.baseUrl,endpointId:null,autoDirect:!1,probeInProgress:o&&n.activeHostId===s.id&&n.candidateProbePhase==="probing"}}function Tn(e){switch(e){case"relay":return"common.connectionRouteRelay";case"lan":return"common.connectionRouteLan";case"loopback":return"common.connectionRouteLoopback";case"tailscale":return"common.connectionRouteTailscale";default:return"common.connectionRouteDirect"}}function Pe(e){const n=e.preferredDirectCandidateEndpointId??e.preferredCandidateEndpointId;return n?e.candidateEndpoints.find(s=>s.endpointId===n&&s.status==="verified")??null:null}function Oe(e){return e==="custom"?"direct":e}function Ne(e){var n;if((n=e.relayTunnel)!=null&&n.enabled&&Ie(e.baseUrl,e.relayTunnel.tunnelDomain))return"relay";try{const s=new URL(e.baseUrl).hostname.toLowerCase();if(be(s))return"loopback";if(Ee(s))return"tailscale";if(Le(s))return"lan"}catch{return"direct"}return e.kind==="local"?"loopback":e.kind==="lan"?"lan":"direct"}function Ie(e,n){try{return new URL(e).hostname.toLowerCase()===n.trim().toLowerCase()}catch{return!1}}function be(e){return e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="[::1]"}function Ee(e){if(e.endsWith(".ts.net"))return!0;const n=e.split(".").map(t=>Number(t));if(n.length!==4||n.some(t=>Number.isNaN(t)))return!1;const[s,o]=n;return s===100&&o>=64&&o<=127}function Le(e){const n=e.split(".").map(t=>Number(t));if(n.length!==4||n.some(t=>Number.isNaN(t)))return!1;const[s,o]=n;return s===10||s===192&&o===168||s===172&&o>=16&&o<=31}function Bn({heading:e,description:n,actions:s,tone:o="default",className:t,children:a}){return r.jsxs("section",{className:y("modal-section",t),"data-tone":o,children:[e||n||s?r.jsxs("div",{className:"modal-section-header",children:[r.jsxs("div",{className:"modal-section-copy",children:[e?r.jsx("strong",{className:"modal-section-heading",children:e}):null,n?r.jsx("p",{className:"modal-section-description",children:n}):null]}),s?r.jsx("div",{className:"modal-section-actions",children:s}):null]}):null,a]})}function Mn({label:e,description:n,className:s,htmlFor:o,children:t}){return r.jsxs("div",{className:y("workbench-modal-field","modal-field",s),children:[r.jsxs("div",{className:"modal-field-copy",children:[o?r.jsx("label",{className:"modal-field-label",htmlFor:o,children:e}):r.jsx("span",{className:"modal-field-label",children:e}),n?r.jsx("span",{className:"modal-field-description",children:n}):null]}),t]})}function jn({align:e="end",stack:n=!1,className:s,children:o,...t}){return r.jsx("div",{className:y("workbench-modal-actions","modal-actions",s),"data-align":e,"data-stack":n?"true":void 0,...t,children:o})}function kn({compact:e=!1,className:n,children:s,...o}){return r.jsx("div",{className:y("modal-list",n),"data-compact":e?"true":void 0,...o,children:s})}function Kn(e){const{as:n="div",label:s,description:o,leading:t,trailing:a,tone:l="default",selected:d=!1,className:P,children:O,...S}=e,f={className:y("modal-list-item",P),"data-tone":l!=="default"?l:void 0,"data-selected":d?"true":void 0,"data-interactive":n==="button"?"true":void 0},A=r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"modal-list-item-main",children:[t?r.jsx("span",{className:"modal-list-item-leading",children:t}):null,r.jsxs("span",{className:"modal-list-item-copy",children:[s?r.jsx("span",{className:"modal-list-item-label",children:s}):null,o?r.jsx("span",{className:"modal-list-item-description",children:o}):null,O]})]}),a?r.jsx("span",{className:"modal-list-item-trailing",children:a}):null]});if(n==="button"){const u=S;return r.jsx("button",{type:u.type??"button",...u,...f,children:A})}return r.jsx("div",{...S,...f,children:A})}function Fn({title:e,description:n,action:s,className:o,compact:t=!1}){return r.jsxs("div",{className:y("modal-empty-state",o),"data-compact":t?"true":void 0,children:[r.jsx("strong",{className:"modal-empty-state-title",children:e}),n?r.jsx("p",{className:"modal-empty-state-description",children:n}):null,s?r.jsx("div",{className:"modal-empty-state-action",children:s}):null]})}function Jn({tone:e="default",className:n,children:s,...o}){return r.jsx("span",{className:y("modal-tag",n),"data-tone":e!=="default"?e:void 0,...o,children:s})}function y(...e){return e.filter(Boolean).join(" ")}function Qn({open:e,title:n,description:s,height:o="auto",kind:t="form",dismissible:a=!0,closeOnBackdrop:l=!0,showHandle:d=!1,showCancelButton:P=!0,cancelLabel:O,className:S,cardClassName:v,bodyClassName:f,footer:A,onClose:u,children:h}){const p=w.useId(),m=w.useId(),N=a&&l;return!e||typeof document>"u"?null:ee.createPortal(r.jsx("div",{className:"ios-action-sheet-overlay mobile-sheet-overlay",role:"presentation",onClick:()=>{N&&u()},children:r.jsxs("div",{className:`mobile-workspace-home-sheet mobile-sheet${S?` ${S}`:""}`,"data-height":o,"data-kind":t,role:"dialog","aria-modal":"true","aria-labelledby":p,"aria-describedby":s?m:void 0,onClick:E=>E.stopPropagation(),children:[r.jsxs("div",{className:`mobile-workspace-home-sheet-card mobile-sheet-card${v?` ${v}`:""}`,children:[d?r.jsx("div",{className:"mobile-sheet-handle","aria-hidden":"true"}):null,r.jsx("div",{className:"mobile-workspace-home-sheet-header mobile-sheet-header",children:r.jsxs("div",{className:"mobile-sheet-title-wrap",children:[r.jsx("strong",{id:p,children:n}),s?r.jsx("p",{id:m,children:s}):null]})}),r.jsx("div",{className:f?`mobile-sheet-body ${f}`:"mobile-sheet-body",children:h}),A?r.jsx("div",{className:"mobile-sheet-footer",children:A}):null]}),P?r.jsx("button",{type:"button",className:"ios-action-sheet-cancel mobile-sheet-cancel",disabled:!a,onClick:()=>{a&&u()},children:O??g("common.cancel")}):null]})}),document.body)}export{Ge as $,Sn as A,An as B,yn as C,vn as D,Ze as E,hn as F,tn as G,on as H,mn as I,cn as J,Cn as K,bn as L,Qn as M,wn as N,Fn as O,$e as P,Pn as Q,Nn as R,qn as S,On as T,In as U,an as V,En as W,rn as X,Ln as Y,ln as Z,Re as _,ve as a,Me as a0,Be as a1,We as a2,en as a3,nn as a4,sn as a5,Xe as a6,Un as a7,Qe as a8,Je as a9,He as aa,Ye as ab,_e as ac,K as ad,Ve as ae,ke as b,Ke as c,Fe as d,ue as e,Bn as f,Te as g,Mn as h,kn as i,Kn as j,Jn as k,xn as l,Tn as m,Dn as n,te as o,oe as p,ge as q,je as r,dn as s,pn as t,Rn as u,fn as v,ze as w,jn as x,un as y,gn as z};
|
package/dist/public/assets/{MobileTopHeaderFrame-DArgZI7L.js → MobileTopHeaderFrame-BWorAJ1C.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as i}from"./index-
|
|
1
|
+
import{j as i}from"./index-C2G8Gmf1.js";function m({children:e,className:o,frameRef:r,...a}){return i.jsx("div",{ref:r,className:["mobile-top-header-frame",o].filter(Boolean).join(" "),...a,children:e})}export{m as M};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as j,f as $,
|
|
1
|
+
import{b as j,f as $,h as B,j as t,t as l}from"./index-C2G8Gmf1.js";import{e as K,i as F,j as P,k as S,M as G}from"./MobileSheet-Gzc14EpR.js";import{as as q,m as z,at as D,$ as X,au as J}from"./WorkbenchLayout-rwQib5In.js";import{u as Q,e as V}from"./App-WOLwMld_.js";import{M as Y}from"./MobileTopHeaderFrame-BWorAJ1C.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,f]=j.useState(null),b=K(),I=Q(),{showToast:T}=V(),r=$(e=>e),h=B(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){f(U);try{e.host.id!==r.activeHostId&&(b.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{f(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}b.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)},children:t.jsxs("div",{className:e.kind==="host"?"mobile-workspace-home-session-main mobile-host-workspace-switcher-host-main":"mobile-workspace-home-session-main",children:[t.jsxs("span",{className:"mobile-workspace-home-session-title",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,e.kind==="host"?e.host.name:e.option.label]}),t.jsx("span",{className:"mobile-workspace-home-session-meta",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};
|
package/dist/public/assets/{ServerSettingsModal-izoYMx9U.js → ServerSettingsModal-BYB0GvTl.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as i,n as U,j as r,t as s}from"./index-
|
|
1
|
+
import{b as i,n as U,j as r,t as s}from"./index-C2G8Gmf1.js";import{a as v,q as k,s as I,t as O}from"./App-WOLwMld_.js";import{W as y}from"./WorkbenchModal-B09hC9b5.js";function w({isOpen:t,onClose:u,onSave:c,theme:P="dark"}){const d=v(e=>e.baseUrl),b=v(e=>e.options),m=v(e=>e.presetOptions),h=I(),[l,n]=i.useState(d),[p,o]=i.useState(null),a=i.useMemo(()=>{try{return U(l)}catch{return null}},[l]),f=k(a??l,b),x=m.find(e=>e.value===f)??null,g="server-settings-preset",S="server-settings-address";if(i.useEffect(()=>{t&&(n(d),o(null))},[t,d]),!t)return null;function N(){if(!a){o(s("auth.serverInvalid"));return}O.setBaseUrl(a),c==null||c(a),u()}function B(){a&&n(a)}return r.jsx(y,{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(),N()},children:[r.jsxs("label",{className:"workbench-modal-field",htmlFor:g,children:[r.jsx("span",{children:s("auth.serverPreset")}),r.jsxs("select",{id:g,"aria-label":s("auth.serverPreset"),value:f,onChange:e=>{const j=e.target.value;j!==h&&(n(j),o(null))},children:[m.map(e=>r.jsx("option",{value:e.value,children:C(e)},`${e.source}:${e.value}`)),r.jsx("option",{value:h,children:s("auth.serverCustomOption")})]})]}),x?r.jsx("div",{className:"server-settings-modal-tags","aria-live":"polite",children:x.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:S,children:[r.jsx("span",{children:s("auth.serverAddress")}),r.jsx("input",{id:S,"aria-label":s("auth.serverAddress"),value:l,placeholder:s("auth.serverPlaceholder"),onBlur:B,onChange:e=>{n(e.target.value),o(null)}})]}),p?r.jsx("p",{className:"server-settings-modal-status","data-tone":"error",children:p}):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",children:s("auth.saveServerSettings")})]})]})})}function C(t){return t.source==="discovered"?`${t.value} · ${s("auth.serverDiscoveredTag")}`:t.value}export{w as ServerSettingsModal};
|