@tencent-ai/agent-sdk 0.3.245-dev.cd0b453.202608251505 → 0.3.246
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/cli/CHANGELOG.md +33 -0
- package/cli/dist/codebuddy-headless.js +228 -293
- package/cli/dist/web-ui/assets/{CanvasPaneStandaloneView-Cmwt9Y8a.js → CanvasPaneStandaloneView-BD_qZwpK.js} +1 -1
- package/cli/dist/web-ui/assets/{CanvasView-kh-VwNZt.js → CanvasView-BAUxFLH1.js} +1 -1
- package/cli/dist/web-ui/assets/{ChangesView-LyTT64_e.js → ChangesView-Bvr-6a62.js} +1 -1
- package/cli/dist/web-ui/assets/{DocsView-DzT0XXMI.js → DocsView-BVidmMmQ.js} +1 -1
- package/cli/dist/web-ui/assets/EditorView-BWnNeB5q.js +75 -0
- package/cli/dist/web-ui/assets/{FileIcon-CiviXX19.js → FileIcon-BsViq6H0.js} +1 -1
- package/cli/dist/web-ui/assets/{KeybindingsView-CYLH1DTg.js → KeybindingsView-QuWWE_H3.js} +1 -1
- package/cli/dist/web-ui/assets/{LogsView-RDobPjF6.js → LogsView-DUMNTy8H.js} +3 -3
- package/cli/dist/web-ui/assets/{MetricsView-0TBamh3L.js → MetricsView-BY2YOvXi.js} +3 -3
- package/cli/dist/web-ui/assets/{PluginsView-CzAIf5_-.js → PluginsView-BzgBeIFp.js} +2 -2
- package/cli/dist/web-ui/assets/{RemoteControlView-CNsCKFhh.js → RemoteControlView-BuKYLVCs.js} +1 -1
- package/cli/dist/web-ui/assets/{SettingsView-B2RLsYo0.js → SettingsView-Bu_9EZ8x.js} +2 -2
- package/cli/dist/web-ui/assets/{SplitContainer-CJB8eH3c.js → SplitContainer-C2WbFxdL.js} +1 -1
- package/cli/dist/web-ui/assets/{StatsView-wHMAAyEJ.js → StatsView-h44ujqat.js} +2 -2
- package/cli/dist/web-ui/assets/{TasksView-DOFeNXmC.js → TasksView-D2q4JOBP.js} +2 -2
- package/cli/dist/web-ui/assets/{TerminalPaneView-BXNcwxsi.js → TerminalPaneView-lhajvnaH.js} +3 -3
- package/cli/dist/web-ui/assets/{TracesView-BtPCpydR.js → TracesView-B5i4emxN.js} +3 -3
- package/cli/dist/web-ui/assets/{WorkersView-sQMhvJ2l.js → WorkersView-Bw2bTNo6.js} +2 -2
- package/cli/dist/web-ui/assets/{canvas-store-0BnkCTHk.js → canvas-store-Smrtng_e.js} +1 -1
- package/cli/dist/web-ui/assets/{cssMode-jwjmt121.js → cssMode-EsOJVYiu.js} +1 -1
- package/cli/dist/web-ui/assets/{download-iNxRYv3J.js → download-BsdRqzY7.js} +1 -1
- package/cli/dist/web-ui/assets/{editor.main-CGYuAeQx.js → editor.main-q4R8cbC1.js} +3 -3
- package/cli/dist/web-ui/assets/{external-link-D5RWsA9l.js → external-link-Ea1Nar0e.js} +1 -1
- package/cli/dist/web-ui/assets/{freemarker2-CX3QfLDV.js → freemarker2-DVmHExbB.js} +1 -1
- package/cli/dist/web-ui/assets/{handlebars-C5TLi2Pr.js → handlebars-Cguwj4ew.js} +1 -1
- package/cli/dist/web-ui/assets/{html-VGWLEWVQ.js → html-DRfZqNG-.js} +1 -1
- package/cli/dist/web-ui/assets/{htmlMode-B7yDtJr6.js → htmlMode-mn7qxh39.js} +1 -1
- package/cli/dist/web-ui/assets/index-BOvl5ICo.css +1 -0
- package/cli/dist/web-ui/assets/{index-CHcoPr8x.js → index-CBmymKHy.js} +180 -175
- package/cli/dist/web-ui/assets/{javascript-rebq-3hM.js → javascript-Dv0-Ka9H.js} +1 -1
- package/cli/dist/web-ui/assets/{jsonMode-CisSEnRa.js → jsonMode-MVrw6wSj.js} +1 -1
- package/cli/dist/web-ui/assets/{liquid-C0GU_tuJ.js → liquid-2HR35IQO.js} +1 -1
- package/cli/dist/web-ui/assets/{lspLanguageFeatures-DdEy47qR.js → lspLanguageFeatures-BA4h_1Zp.js} +1 -1
- package/cli/dist/web-ui/assets/{markdown-DIY6o85n.js → markdown-CP9awqWt.js} +1 -1
- package/cli/dist/web-ui/assets/{mdx-DjEmR07p.js → mdx-CFi7brpM.js} +1 -1
- package/cli/dist/web-ui/assets/{minus-BHON617T.js → minus-Dw9-WG76.js} +1 -1
- package/cli/dist/web-ui/assets/{power-BoeeA3TI.js → power-BJk8Xq9U.js} +1 -1
- package/cli/dist/web-ui/assets/{python-YOuEQ1oe.js → python-BqoHrqNK.js} +1 -1
- package/cli/dist/web-ui/assets/{razor-DTO4iPoC.js → razor-CPnz313K.js} +1 -1
- package/cli/dist/web-ui/assets/{server-Gy9um44Z.js → server-D4446JKI.js} +1 -1
- package/cli/dist/web-ui/assets/{timer-CVn2LoSe.js → timer-D8MX3pYj.js} +1 -1
- package/cli/dist/web-ui/assets/{tsMode-J-jxLo7h.js → tsMode-DMOs1uPQ.js} +1 -1
- package/cli/dist/web-ui/assets/{typescript-BTZe1y3z.js → typescript-CP_zrnR8.js} +1 -1
- package/cli/dist/web-ui/assets/{vendor-D35k0Cos.js → vendor-iLJwFVtf.js} +1 -1
- package/cli/dist/web-ui/assets/{worker-store-CsMfXxjm.js → worker-store-qfd_N8Zm.js} +1 -1
- package/cli/dist/web-ui/assets/{xml-DaZe33xf.js → xml-BNASinsS.js} +1 -1
- package/cli/dist/web-ui/assets/{yaml-yofIoqGl.js → yaml-D_cB1VDT.js} +1 -1
- package/cli/dist/web-ui/assets/{zap-BeZalqcf.js → zap-yafQUspl.js} +1 -1
- package/cli/dist/web-ui/index.html +4 -4
- package/cli/dist/web-ui/sw.js +1 -1
- package/cli/package.json +2 -3
- package/cli/product.cloudhosted.json +4 -2
- package/cli/product.internal.json +4 -2
- package/cli/product.ioa.json +4 -2
- package/cli/product.json +383 -17
- package/cli/product.selfhosted.json +4 -2
- package/cli/vendor/shim/sitecustomize.py +43 -1
- package/package.json +2 -3
- package/cli/dist/web-ui/assets/EditorView-ZUnDw1V1.js +0 -75
- package/cli/dist/web-ui/assets/index-Ddq_addW.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r,j as a}from"./markdown-
|
|
1
|
+
import{a as r,j as a}from"./markdown-CP9awqWt.js";import{TerminalPaneView as f}from"./TerminalPaneView-lhajvnaH.js";import{u as x,g as c,a as l,S as h}from"./index-CBmymKHy.js";import{u as d}from"./canvas-store-Smrtng_e.js";import"./vendor-iLJwFVtf.js";function w(){const{t:i}=x(),[s,u]=r.useState(()=>c().get("paneId")||"");r.useEffect(()=>{const e=()=>{u(c().get("paneId")||"")};return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);const t=d(e=>Object.values(e.tiles).find(n=>n.paneId===s)??null),m=l(e=>{var n;return s?(n=e.panes[s])==null?void 0:n.title:null}),o=d(e=>e.setTilePty),p=r.useCallback(e=>{t&&o(t.id,e.sessionId,e.cwd||null)},[t,o]);return r.useEffect(()=>{if(!s)return;const e=l.getState();e.panes[s]||l.setState({panes:{...e.panes,[s]:{id:s,ptySessionId:(t==null?void 0:t.ptySessionId)??null,ptyStatus:"disconnected",errorMessage:null}}})},[s,t==null?void 0:t.ptySessionId]),s?a.jsxs("div",{className:"flex flex-col h-full w-full bg-bg-primary",children:[a.jsxs("div",{className:"flex items-center gap-2 px-3 select-none",style:{height:32,background:"var(--color-canvas-tile-header)",color:"var(--color-canvas-tile-header-text)",borderBottom:"1px solid var(--color-border-default)"},children:[a.jsx(h,{size:14,style:{opacity:.6}}),a.jsx("span",{className:"text-xs truncate",style:{fontSize:12,fontWeight:500},children:m||i("canvas.defaultTitle")})]}),a.jsx("div",{className:"flex-1 min-h-0 relative",children:a.jsx(f,{paneId:s,initialCwd:(t==null?void 0:t.cwd)??null,onPtyCreated:p})})]}):a.jsx("div",{className:"flex items-center justify-center h-full w-full bg-bg-primary text-text-secondary text-sm",children:i("canvas.standalone.missingPaneId")})}export{w as CanvasPaneStandaloneView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var be=Object.defineProperty;var Se=(o,n,t)=>n in o?be(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t;var H=(o,n,t)=>Se(o,typeof n!="symbol"?n+"":n,t);import{a as f,j as h}from"./markdown-
|
|
1
|
+
var be=Object.defineProperty;var Se=(o,n,t)=>n in o?be(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t;var H=(o,n,t)=>Se(o,typeof n!="symbol"?n+"":n,t);import{a as f,j as h}from"./markdown-CP9awqWt.js";import{c as de,u as he,i as ke,P as Te,a as Ee,S as ze,C as Me,b as Pe,M as Ie,d as je,X as Ce}from"./index-CBmymKHy.js";import{M as re,a as ie,u as k,C as we,G as Ne,S as Re,R as xe,b as ce,c as le,T as Le}from"./canvas-store-Smrtng_e.js";import{E as ve}from"./external-link-Ea1Nar0e.js";import{TerminalPaneView as He}from"./TerminalPaneView-lhajvnaH.js";import{M as Xe}from"./minus-Dw9-WG76.js";import"./vendor-iLJwFVtf.js";/**
|
|
2
2
|
* @license lucide-react v1.18.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d,j as e}from"./markdown-
|
|
1
|
+
import{a as d,j as e}from"./markdown-CP9awqWt.js";import{u as k,j as b,k as U,l as B,m as G,n as z,A as W,o as _,p as H,L as V,D as q,G as Z}from"./index-CBmymKHy.js";import{F as J,U as y}from"./FileIcon-BsViq6H0.js";import{S as K}from"./SplitContainer-C2WbFxdL.js";import"./vendor-iLJwFVtf.js";const w=12,E=12;function Q(i){const a={children:[]},c=i.map(s=>s.uri);let n="";if(c.length>0){const s=c[0].split("/");let l=0;for(let r=0;r<s.length;r++){const m=s.slice(0,r+1).join("/");if(c.every(o=>o.startsWith(m+"/")))l=r+1;else break}n=s.slice(0,l).join("/")}for(const s of i){let l=s.uri;n&&l.startsWith(n)&&(l=l.slice(n.length).replace(/^\//,""));const r=l.split("/");let m=a;for(let o=0;o<r.length;o++){const j=o===r.length-1;let f=m.children.find(p=>p.name===r[o]);f||(f={name:r[o],path:r.slice(0,o+1).join("/"),type:j?"file":"directory",children:[],fileInfo:j?s:void 0},m.children.push(f)),m=f}}function t(s){return s.type==="file"?s:(s.children=s.children.map(t),s.children.length===1&&s.children[0].type==="directory"?{...s.children[0],name:`${s.name}/${s.children[0].name}`}:s)}function h(s){return s.type==="file"&&s.fileInfo?[s.fileInfo.uri]:s.children.flatMap(h)}function u(s){return s.type==="directory"&&(s.allFilePaths=h(s),s.children.forEach(u)),s}function g(s){return s.sort((l,r)=>l.type!==r.type?l.type==="directory"?-1:1:l.name.localeCompare(r.name)).map(l=>(l.type==="directory"&&(l.children=g(l.children)),l))}return g(a.children.map(t).map(u))}function X({changeType:i}){const a={created:{letter:"U",cls:"changes-badge-created"},modified:{letter:"M",cls:"changes-badge-modified"},deleted:{letter:"D",cls:"changes-badge-deleted"}},{letter:c,cls:n}=a[i]||a.modified;return e.jsx("span",{className:`changes-type-badge ${n}`,children:c})}function T({depth:i}){return e.jsx(e.Fragment,{children:Array.from({length:i},(a,c)=>e.jsx("span",{className:"file-tree-indent-guide",style:{left:E+c*w+6}},c))})}function L({node:i,depth:a,selectedFile:c,onSelectFile:n,onRevert:t}){var o,j;const[h,u]=d.useState(!0),[g,s]=d.useState(!1),{t:l}=k(),r=E+a*w,m=d.useCallback(f=>{f.stopPropagation(),t&&(i.type==="file"&&i.fileInfo?t([i.fileInfo.uri]):i.allFilePaths&&t(i.allFilePaths))},[i,t]);if(i.type==="file"){const f=i.name;return e.jsxs("div",{className:`file-tree-item ${c===((o=i.fileInfo)==null?void 0:o.uri)?"selected":""}`,onClick:()=>i.fileInfo&&n(i.fileInfo.uri),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),title:(j=i.fileInfo)==null?void 0:j.uri,children:[e.jsx(T,{depth:a}),e.jsx("span",{style:{width:r,flexShrink:0}}),e.jsx(J,{name:f,type:"file",size:16}),e.jsx("span",{className:"file-tree-item-name",children:f}),g&&t&&e.jsx("button",{className:"changes-tree-revert-btn",onClick:m,title:l("changes.revert"),children:e.jsx(y,{size:12})}),e.jsx(X,{changeType:i.fileInfo.changeType})]})}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"file-tree-item",onClick:()=>u(!h),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[e.jsx(T,{depth:a}),e.jsx("span",{style:{width:r,flexShrink:0}}),e.jsx(b,{size:16,className:`file-tree-chevron ${h?"expanded":""}`}),e.jsx("span",{className:"file-tree-item-name",children:i.name}),g&&t&&i.allFilePaths&&i.allFilePaths.length>0&&e.jsx("button",{className:"changes-tree-revert-btn",onClick:m,title:l("changes.revertDirectory"),children:e.jsx(y,{size:12})})]}),h&&i.children.map(f=>e.jsx(L,{node:f,depth:a+1,selectedFile:c,onSelectFile:n,onRevert:t},f.path))]})}function Y({fileChanges:i,selectedFile:a,onSelectFile:c,onRevertFiles:n}){const t=d.useMemo(()=>Q(i),[i]);return e.jsx("div",{className:"file-tree changes-tree",children:e.jsx("div",{className:"file-tree-content",children:t.map(h=>e.jsx(L,{node:h,depth:0,selectedFile:a,onSelectFile:c,onRevert:n},h.path))})})}function le({onMenuClick:i}){const{t:a}=k(),{fileChanges:c,selectedFile:n,selectedDiff:t,diffLoading:h,checkpoints:u,reverting:g,selectFile:s,revertFiles:l,revertAll:r,revertToCheckpoint:m,loadCheckpoints:o}=U(),[j,f]=d.useState(.28),[p,$]=d.useState(!0),[N,D]=d.useState(!0),x=B(),[M,v]=d.useState(!1),I=d.useRef(x);d.useEffect(()=>{o()},[o]),d.useEffect(()=>{I.current!==x&&(I.current=x,x?n&&v(!0):v(!1))},[x,n]),d.useEffect(()=>{x&&n&&v(!0)},[x,n]);const P=d.useCallback(C=>{s(C),x&&v(!0)},[x,s]),A=d.useCallback(()=>{v(!1)},[]),O=d.useCallback((C,R)=>{m(C,R)},[m]),S=()=>h?e.jsx("div",{className:"changes-empty-state",children:e.jsx(V,{size:20,className:"animate-spin",style:{opacity:.4}})}):n&&t?e.jsx("div",{className:"changes-diff-scroll",children:e.jsx(q,{path:n,oldText:t.oldText??null,newText:t.newText,maxHeight:"100%"})}):e.jsxs("div",{className:"changes-empty-state",children:[e.jsx(Z,{size:48,strokeWidth:1,style:{opacity:.12}}),e.jsx("span",{className:"changes-empty-text",children:a("fileChanges.empty")})]}),F=e.jsxs("div",{className:"changes-left changes-left-mobile-safe",children:[e.jsxs("div",{className:"changes-title-bar",children:[i&&e.jsx("button",{className:"changes-title-menu",onClick:i,title:a("editor.toggleSidebar"),children:e.jsx(G,{size:16})}),e.jsx("span",{className:"changes-title-text",children:a("fileChanges.title")})]}),e.jsxs("div",{className:"changes-accordion",children:[e.jsxs("div",{className:`changes-section ${p&&N?"half":p?"full":"collapsed"}`,children:[e.jsxs("div",{className:"changes-section-header changes-section-first",onClick:()=>$(!p),children:[p?e.jsx(z,{size:12}):e.jsx(b,{size:12}),e.jsx("span",{className:"changes-section-name",children:a("fileChanges.changesSection")}),c.length>0&&e.jsx("div",{className:"changes-section-actions",onClick:C=>C.stopPropagation(),children:e.jsx("button",{className:"changes-section-action",onClick:r,disabled:g,title:a("fileChanges.revertAll"),children:e.jsx(y,{size:14})})}),c.length>0&&e.jsx("span",{className:"changes-section-badge",children:c.length})]}),p&&e.jsx("div",{className:"changes-section-content",children:e.jsx(Y,{fileChanges:c,selectedFile:n,onSelectFile:P,onRevertFiles:l})})]}),e.jsxs("div",{className:`changes-section ${N&&p?"half":N?"full":"collapsed"}`,children:[e.jsxs("div",{className:"changes-section-header",onClick:()=>{D(!N),N||o()},children:[N?e.jsx(z,{size:12}):e.jsx(b,{size:12}),e.jsx("span",{className:"changes-section-name",children:a("fileChanges.checkpoints").toUpperCase()})]}),N&&e.jsx("div",{className:"changes-section-content",children:e.jsx(ee,{checkpoints:u,reverting:g,onRevert:O})})]})]})]});return x?e.jsxs("div",{className:"changes-fullview changes-fullview-mobile",children:[F,e.jsxs("div",{className:`changes-mobile-panel ${M?"open":""}`,children:[e.jsxs("div",{className:"changes-mobile-header",children:[e.jsx("button",{className:"changes-mobile-back",onClick:A,children:e.jsx(W,{size:18})}),e.jsx("div",{className:"changes-mobile-title",children:n?n.split("/").pop():a("fileChanges.empty")})]}),e.jsx("div",{className:"changes-right",children:S()})]})]}):e.jsx("div",{className:"changes-fullview",children:e.jsxs(K,{direction:"horizontal",ratio:j,onRatioChange:f,children:[F,e.jsx("div",{className:"changes-right",children:S()})]})})}function ee({checkpoints:i,reverting:a,onRevert:c}){const{t:n}=k();return i.length===0?e.jsx("div",{className:"changes-empty-state changes-timeline-empty",children:e.jsx("span",{className:"changes-empty-text",children:n("fileChanges.noCheckpoints")})}):e.jsx("div",{className:"changes-timeline",children:i.map((t,h)=>{const u=new Date(t.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),g=t.files.length>0||t.additions>0||t.deletions>0,s=h===0,l=h===i.length-1,r=s?"latest":"historical";return e.jsxs("div",{className:"changes-timeline-item",children:[e.jsxs("div",{className:"changes-timeline-line",children:[e.jsx("div",{className:`changes-timeline-dot ${r}`}),!l&&e.jsx("div",{className:`changes-timeline-connector ${s?"latest":"historical"}`})]}),e.jsx("div",{className:"changes-timeline-content",children:e.jsxs("div",{className:"changes-timeline-header",children:[e.jsx("span",{className:"changes-timeline-time",children:u}),e.jsx("span",{className:"changes-timeline-label",children:t.label||`${t.files.length} file${t.files.length!==1?"s":""}`}),e.jsxs("div",{className:"changes-timeline-actions",children:[e.jsx("button",{className:"changes-timeline-action",onClick:()=>c(t.id,"Conversation"),disabled:a,title:n("fileChanges.revertChat"),children:e.jsx(_,{size:13})}),g&&e.jsx("button",{className:"changes-timeline-action",onClick:()=>c(t.id,"Code"),disabled:a,title:n("fileChanges.revertCode"),children:e.jsx(H,{size:13})}),e.jsx("button",{className:"changes-timeline-action danger",onClick:()=>c(t.id,"CodeAndConversation"),disabled:a,title:n("fileChanges.revertCodeAndChat"),children:e.jsx(y,{size:13})})]})]})})]},t.id||h)})})}export{le as ChangesView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as _,j as a,M as xe,c as ge}from"./markdown-
|
|
1
|
+
import{a as _,j as a,M as xe,c as ge}from"./markdown-CP9awqWt.js";import{c as pe,e as be,u as H,q as ye,r as we,v as _e,s as ve,t as ie,F as je,n as q,j as Y,w as ke,x as Z,X as ze,d as Se,y as X}from"./index-CBmymKHy.js";import{E as Ce}from"./external-link-Ea1Nar0e.js";import"./vendor-iLJwFVtf.js";/**
|
|
2
2
|
* @license lucide-react v1.18.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CBmymKHy.js","assets/markdown-CP9awqWt.js","assets/vendor-iLJwFVtf.js","assets/index-BOvl5ICo.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as ce,z as Rt,h as Ke,u as te,q as Ft,B as js,E as vs,H as ys,L as ke,I as Tt,J as ks,K as ae,N as ws,O as It,Q as Cs,R as Lt,T as dt,U as Ns,e as $t,_ as at,V as Ss,W as Ps,Y as Ee,P as Se,Z as Ot,$ as Te,a0 as Ds,a1 as ze,a2 as Ms,a3 as zs,X as ut,j as oe,a4 as Es,a5 as At,d as Bt,r as Rs,v as Fs,s as Ts,a6 as nt,w as Is,g as _t,a7 as Ls,a8 as $s,n as pe,a9 as Os,aa as ht,ab as Ie,ac as As,ad as Bs,ae as _s,af as Wt,ag as re,ah as Ws,a as Hs,M as qs,ai as Vs,aj as Ht,ak as Ks,al as Us,am as bt,t as ft,m as Gs,an as Qs,ao as qt,C as Xs,ap as Ys,aq as Js,ar as Zs,as as ea,at as Vt,S as rt,D as ta,au as sa,l as aa,av as jt,aw as na,ax as ra,p as ia,A as la,ay as oa}from"./index-CBmymKHy.js";import{a as r,j as e,M as ca,c as da}from"./markdown-CP9awqWt.js";import{F as we,U as mt}from"./FileIcon-BsViq6H0.js";import{D as Le}from"./download-BsdRqzY7.js";import{M as Ue}from"./minus-Dw9-WG76.js";import{TerminalPaneView as ua}from"./TerminalPaneView-lhajvnaH.js";import{E as Kt}from"./external-link-Ea1Nar0e.js";import"./vendor-iLJwFVtf.js";/**
|
|
3
|
+
* @license lucide-react v1.18.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/const ha=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],fa=ce("case-sensitive",ha);/**
|
|
8
|
+
* @license lucide-react v1.18.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/const ma=[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],pa=ce("copy-minus",ma);/**
|
|
13
|
+
* @license lucide-react v1.18.0 - ISC
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the ISC license.
|
|
16
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/const xa=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ga=ce("file-exclamation-point",xa);/**
|
|
18
|
+
* @license lucide-react v1.18.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/const ba=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]],ja=ce("file-plus",ba);/**
|
|
23
|
+
* @license lucide-react v1.18.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/const va=[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]],Ut=ce("files",va);/**
|
|
28
|
+
* @license lucide-react v1.18.0 - ISC
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the ISC license.
|
|
31
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/const ya=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]],ka=ce("fold-vertical",ya);/**
|
|
33
|
+
* @license lucide-react v1.18.0 - ISC
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the ISC license.
|
|
36
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
+
*/const wa=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Ca=ce("house",wa);/**
|
|
38
|
+
* @license lucide-react v1.18.0 - ISC
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the ISC license.
|
|
41
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/const Na=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],Gt=ce("list",Na);/**
|
|
43
|
+
* @license lucide-react v1.18.0 - ISC
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the ISC license.
|
|
46
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/const Sa=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]],Pa=ce("panel-bottom",Sa);/**
|
|
48
|
+
* @license lucide-react v1.18.0 - ISC
|
|
49
|
+
*
|
|
50
|
+
* This source code is licensed under the ISC license.
|
|
51
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
+
*/const Da=[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]],Ma=ce("regex",Da);/**
|
|
53
|
+
* @license lucide-react v1.18.0 - ISC
|
|
54
|
+
*
|
|
55
|
+
* This source code is licensed under the ISC license.
|
|
56
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
+
*/const za=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],Ea=ce("scan",za);/**
|
|
58
|
+
* @license lucide-react v1.18.0 - ISC
|
|
59
|
+
*
|
|
60
|
+
* This source code is licensed under the ISC license.
|
|
61
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
+
*/const Ra=[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]],Qt=ce("tree-pine",Ra);/**
|
|
63
|
+
* @license lucide-react v1.18.0 - ISC
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the ISC license.
|
|
66
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/const Fa=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]],Ta=ce("unfold-vertical",Fa);/**
|
|
68
|
+
* @license lucide-react v1.18.0 - ISC
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the ISC license.
|
|
71
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
+
*/const Ia=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],La=ce("whole-word",Ia);function Xt(t){const s=t.split("/").pop();return s&&s.trim()?s:t}function Yt(t,s){const n=URL.createObjectURL(s),a=document.createElement("a");a.href=n,a.download=t,a.click(),URL.revokeObjectURL(n)}function Jt(t,s){Yt(t,new Blob([s],{type:"text/plain;charset=utf-8"}))}async function $e(t,s){const n=await fetch(Rt(t),{headers:Ke()});if(!n.ok)throw new Error(`HTTP ${n.status}`);Yt(s,await n.blob())}function $a(t){const s=new Map;function n(i){const o=s.get(i);o!==void 0&&(clearTimeout(o),s.delete(i))}function a(i,o){n(i);const h=setTimeout(()=>{s.get(i)===h&&(s.delete(i),o())},t);s.set(i,h)}function l(){for(const i of s.values())clearTimeout(i);s.clear()}return{schedule:a,cancel:n,dispose:l}}function vt(t,s){const n=ae.getState().pendingReveal;if(!n||n.path!==s)return!1;ae.getState().setPendingReveal(null);const{line:a,col:l,query:i}=n,o=t.getModel();if(!o)return!1;const h=l&&l>0?l:1;if(t.revealLineInCenter(a),t.setPosition({lineNumber:a,column:h}),t.focus(),i){const u=o.findMatches(i,!1,!1,!1,null,!0);if(u.length>0){const d=u.find(m=>m.range.startLineNumber>=a)||u[0];t.setSelection(d.range),t.revealRangeInCenter(d.range);const b=u.map(m=>({range:m.range,options:{className:"search-find-match",overviewRuler:{color:"#d7ba7d",position:1}}})),j=t.deltaDecorations([],b);setTimeout(()=>{try{t.deltaDecorations(j,[])}catch{}},5e3)}}return!0}function Zt({path:t,content:s,language:n,onContentChange:a,onSave:l,minimap:i=!0,onCursorChange:o}){const{t:h}=te(),{resolved:u}=Ft(),d=r.useRef(null),b=r.useRef(o);b.current=o;const j=u==="dark"?"cbc-dark":"cbc-light",[m,v]=r.useState(()=>typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);r.useEffect(()=>{const w=window.matchMedia("(prefers-reduced-motion: reduce)"),c=()=>v(w.matches);return w.addEventListener("change",c),()=>w.removeEventListener("change",c)},[]);const[T,D]=r.useState(!1),[y,x]=r.useState(null),g=r.useRef(null);r.useEffect(()=>{let w=!1;return js().then(()=>{w||D(!0)}),()=>{w=!0}},[]),r.useEffect(()=>{if(y)return vs({onClose:()=>x(null),isInside:w=>Cs(w,g.current)})},[y]),r.useLayoutEffect(()=>{!y||!g.current||ys(g.current,y.x+4,y.y+4)},[y]);const F=e.jsxs("div",{className:"flex items-center justify-center h-full gap-2",style:{color:"var(--color-text-tertiary)"},children:[e.jsx(ke,{size:16,className:"animate-spin"}),e.jsx("span",{style:{fontSize:13},children:h("editor.loading")})]}),K=r.useCallback((w,c)=>{d.current=w,c.editor.defineTheme("cbc-dark",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#121314"}}),c.editor.defineTheme("cbc-light",{base:"vs",inherit:!0,rules:[],colors:{"editor.background":"#ffffff"}}),c.editor.setTheme(j),w.addCommand(c.KeyMod.CtrlCmd|c.KeyCode.KeyS,()=>{l()});const k=()=>{const P=b.current;if(!P)return;const U=w.getPosition(),Q=w.getSelection();if(!U)return;let $=0,O=0;if(Q&&!Q.isEmpty()){const E=w.getModel();E&&($=E.getValueInRange(Q).length,O=Math.abs(Q.endLineNumber-Q.startLineNumber)+1)}P(U.lineNumber,U.column,$,O)};w.onDidChangeCursorPosition(k),w.onDidChangeCursorSelection(k),k()},[j,l]),C=r.useCallback(w=>{var k;w.preventDefault(),w.stopPropagation();const c=(k=d.current)==null?void 0:k.getSelection();x({x:w.clientX,y:w.clientY,hasSelection:!!(c&&!c.isEmpty())})},[]),N=r.useCallback(()=>x(null),[]),L=r.useCallback(()=>{const w=d.current,c=w==null?void 0:w.getSelection();N(),!(!w||!c||c.isEmpty())&&Tt(ks(t,{startLineNumber:c.startLineNumber,startColumn:c.startColumn,endLineNumber:c.endLineNumber,endColumn:c.endColumn}))},[N,t]),M=r.useCallback(w=>{const c=d.current;N(),c&&(c.focus(),c.trigger("keyboard",w,void 0))},[N]),S=r.useCallback(async()=>{const w=d.current;if(N(),!!w){w.focus();try{const c=await navigator.clipboard.readText();if(c){w.trigger("keyboard","type",{text:c});return}}catch{}w.trigger("keyboard","editor.action.clipboardPasteAction",void 0)}},[N]),H=r.useCallback(w=>{w!==void 0&&a(w)},[a]);r.useEffect(()=>{const w=d.current;if(!w)return;const c=w.getModel();c&&s.length>0&&c.getValue()!==s&&c.setValue(s)},[s]);const I=ae(w=>w.pendingReveal);return r.useEffect(()=>{if(!I||I.path!==t)return;if(d.current){vt(d.current,t);return}let w=0;const c=setInterval(()=>{w++,d.current?(vt(d.current,t),clearInterval(c)):w>=50&&clearInterval(c)},50);return()=>clearInterval(c)},[t,I]),T?e.jsxs("div",{className:"h-full",onContextMenu:C,children:[e.jsx(ws,{height:"100%",language:n,theme:j,defaultValue:s,onChange:H,onMount:K,loading:F,options:{fontSize:13,fontFamily:"'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace",lineHeight:20,minimap:{enabled:i,maxColumn:80},scrollBeyondLastLine:!1,automaticLayout:!0,wordWrap:"off",tabSize:4,insertSpaces:!0,renderWhitespace:"selection",bracketPairColorization:{enabled:!0},padding:{top:8},smoothScrolling:!m,cursorBlinking:m?"solid":"smooth",cursorSmoothCaretAnimation:m?"off":"on",fixedOverflowWidgets:!0,contextmenu:!1}},t),y&&It.createPortal(e.jsxs("div",{ref:g,className:"editor-context-menu",role:"menu",style:{left:y.x,top:y.y},onPointerDown:w=>w.stopPropagation(),onContextMenu:w=>w.preventDefault(),children:[y.hasSelection&&e.jsx("button",{type:"button",role:"menuitem",onClick:L,children:h("editor.addToChat")}),y.hasSelection&&e.jsx("div",{className:"editor-context-separator",role:"separator"}),e.jsx("button",{type:"button",role:"menuitem",disabled:!y.hasSelection,onClick:()=>M("editor.action.clipboardCutAction"),children:h("editor.cut")}),e.jsx("button",{type:"button",role:"menuitem",disabled:!y.hasSelection,onClick:()=>M("editor.action.clipboardCopyAction"),children:h("editor.copy")}),e.jsx("button",{type:"button",role:"menuitem",onClick:()=>{S().catch(()=>{})},children:h("editor.paste")})]}),document.body)]}):F}function es({tab:t,onRetry:s}){const{t:n}=te();return t.loadStatus==="ready"?null:t.loadStatus==="loading"?e.jsxs("div",{className:"editor-content-state",role:"status","aria-live":"polite",children:[e.jsx("span",{className:"editor-state-spinner","aria-hidden":"true"}),e.jsx("span",{children:n("editor.loadingFile")})]}):t.loadStatus==="too-large"?e.jsxs("div",{className:"editor-content-state",role:"status",children:[e.jsx(ga,{className:"editor-content-state-icon",size:24,"aria-hidden":"true"}),e.jsx("span",{children:n("editor.fileTooLarge")})]}):e.jsxs("div",{className:"editor-content-state editor-content-state-error",role:"alert",children:[e.jsx(Lt,{className:"editor-content-state-icon",size:24,"aria-hidden":"true"}),e.jsx("span",{children:n("editor.loadError")}),t.loadError&&e.jsx("span",{className:"editor-content-state-reason",children:t.loadError}),e.jsx("button",{type:"button",className:"editor-content-state-retry",onClick:()=>{Promise.resolve(s()).catch(()=>{})},children:n("editor.retryLoad")})]})}async function fe(t,s,n=!0){var h;const a=dt(),l={...s,...a?{cwd:a}:{}},i=await Ns(`/api/v1/git/${t}`,{method:"POST",headers:{...Ke(),"Content-Type":"application/json"},body:JSON.stringify(l)},n?void 0:{maxRetries:0});if(!i.ok){const u=await i.json().catch(()=>({error:{message:i.statusText}}));throw new Error(((h=u.error)==null?void 0:h.message)||`Git API error: ${i.status}`)}const o=await i.json();return o.data??o}async function Oa(){return fe("status")}async function yt(t){await fe("stage",{paths:t},!1)}async function kt(t){await fe("unstage",{paths:t},!1)}async function Aa(t){return fe("commit",{message:t},!1)}async function ts(t,s){return fe("diff",{path:t,staged:s})}async function Je(t,s){await fe("discard",{paths:t,useTrash:s},!1)}async function Ba(){return(await fe("branches")).branches}async function _a(t){return fe("branch/switch",{name:t},!1)}async function Wa(t,s=!0){return fe("branch/create",{name:t,checkout:s},!1)}async function Ha(){return fe("push",void 0,!1)}async function qa(){return fe("pull",void 0,!1)}async function Va(t){return(await fe("log",{limit:t})).entries}const Ka=3e3;let He=null,Fe=null,Ze=!1;async function Ua(){try{const{authHeaders:t}=await at(async()=>{const{authHeaders:a}=await import("./index-CBmymKHy.js").then(l=>l.bp);return{authHeaders:a}},__vite__mapDeps([0,1,2,3])),{fetchWithRetry:s}=await at(async()=>{const{fetchWithRetry:a}=await import("./index-CBmymKHy.js").then(l=>l.bo);return{fetchWithRetry:a}},__vite__mapDeps([0,1,2,3])),n=await s("/api/v1/info",{headers:t()});if(n.ok){const a=await n.json();return(a.data??a).cwd||void 0}}catch{}}const ge=$t((t,s)=>({isGitRepo:!1,loading:!1,error:null,files:[],currentBranch:null,ahead:0,behind:0,remote:null,branches:[],branchesLoading:!1,branchOperationInProgress:!1,repositoryOperationInProgress:!1,selectedFile:null,selectedFileStaged:!1,diffResult:null,diffLoading:!1,commitMessage:"",committing:!1,pushing:!1,pulling:!1,operationFeedback:null,refresh:async(n=!1)=>{if(Fe&&(await Fe,!n))return;const a=(async()=>{s().files.length===0&&!s().isGitRepo&&t({loading:!0,error:null});try{const i=await Oa();t({isGitRepo:i.isGitRepo,files:i.files,currentBranch:i.branch,ahead:i.ahead,behind:i.behind,remote:i.remote,loading:!1})}catch(i){t({loading:!1,error:i.message})}})();Fe=a;try{await a}finally{Fe===a&&(Fe=null)}},loadBranches:async()=>{t({branchesLoading:!0});try{const n=await Ba();t({branches:n,branchesLoading:!1})}catch{t({branchesLoading:!1})}},stageFile:async n=>{if(!s().repositoryOperationInProgress){t({repositoryOperationInProgress:!0,operationFeedback:null});try{await yt([n]),await s().refresh(!0)}catch(a){t({operationFeedback:{operation:"stage",success:!1,message:a.message}})}finally{t({repositoryOperationInProgress:!1})}}},unstageFile:async n=>{if(!s().repositoryOperationInProgress){t({repositoryOperationInProgress:!0,operationFeedback:null});try{await kt([n]),await s().refresh(!0)}catch(a){t({operationFeedback:{operation:"unstage",success:!1,message:a.message}})}finally{t({repositoryOperationInProgress:!1})}}},stageAll:async()=>{if(s().repositoryOperationInProgress)return;const n=s().files.filter(a=>!a.staged).map(a=>a.path);if(n.length!==0){t({repositoryOperationInProgress:!0,operationFeedback:null});try{await yt(n),await s().refresh(!0)}catch(a){t({operationFeedback:{operation:"stage",success:!1,message:a.message}})}finally{t({repositoryOperationInProgress:!1})}}},unstageAll:async()=>{if(s().repositoryOperationInProgress)return;const n=s().files.filter(a=>a.staged).map(a=>a.path);if(n.length!==0){t({repositoryOperationInProgress:!0,operationFeedback:null});try{await kt(n),await s().refresh(!0)}catch(a){t({operationFeedback:{operation:"unstage",success:!1,message:a.message}})}finally{t({repositoryOperationInProgress:!1})}}},discardFile:async n=>{if(!s().repositoryOperationInProgress){t({repositoryOperationInProgress:!0,operationFeedback:null});try{await Je([n],!0),await s().refresh(!0)}catch(a){t({operationFeedback:{operation:"discard",success:!1,message:a.message}})}finally{t({repositoryOperationInProgress:!1})}}},discardAll:async()=>{if(s().repositoryOperationInProgress)return;const n=s().files.filter(i=>!i.staged);if(n.length===0)return;const a=n.filter(i=>i.status!=="untracked"),l=n.filter(i=>i.status==="untracked");t({repositoryOperationInProgress:!0,operationFeedback:null});try{a.length>0&&await Je(a.map(i=>i.path)),l.length>0&&await Je(l.map(i=>i.path),!0),await s().refresh(!0)}catch(i){t({operationFeedback:{operation:"discard",success:!1,message:i.message}})}finally{t({repositoryOperationInProgress:!1})}},commit:async()=>{const n=s().commitMessage.trim();if(!(!n||s().repositoryOperationInProgress)){t({committing:!0,repositoryOperationInProgress:!0,operationFeedback:null});try{const a=await Aa(n);t({committing:!1,commitMessage:a.success?"":s().commitMessage,operationFeedback:{operation:"commit",success:a.success,message:a.message}}),await s().refresh(!0)}catch(a){t({committing:!1,operationFeedback:{operation:"commit",success:!1,message:a.message}})}finally{t({repositoryOperationInProgress:!1})}}},push:async()=>{if(!s().repositoryOperationInProgress){t({pushing:!0,repositoryOperationInProgress:!0,operationFeedback:null});try{const n=await Ha();t({pushing:!1,operationFeedback:{operation:"push",success:n.success,message:n.message}}),await s().refresh(!0)}catch(n){t({pushing:!1,operationFeedback:{operation:"push",success:!1,message:n.message}})}finally{t({repositoryOperationInProgress:!1})}}},pull:async()=>{if(!s().repositoryOperationInProgress){t({pulling:!0,repositoryOperationInProgress:!0,operationFeedback:null});try{const n=await qa();t({pulling:!1,operationFeedback:{operation:"pull",success:n.success,message:n.message}}),await s().refresh(!0)}catch(n){t({pulling:!1,operationFeedback:{operation:"pull",success:!1,message:n.message}})}finally{t({repositoryOperationInProgress:!1})}}},switchBranch:async n=>{if(!(s().repositoryOperationInProgress||n===s().currentBranch)){t({branchOperationInProgress:!0,repositoryOperationInProgress:!0,operationFeedback:null});try{const a=await _a(n);t({operationFeedback:{operation:"switchBranch",success:a.success,message:a.message,target:n}}),await s().refresh(!0),a.success&&await s().loadBranches()}catch(a){t({operationFeedback:{operation:"switchBranch",success:!1,message:a.message,target:n}})}finally{t({branchOperationInProgress:!1,repositoryOperationInProgress:!1})}}},createBranch:async n=>{if(!s().repositoryOperationInProgress){t({branchOperationInProgress:!0,repositoryOperationInProgress:!0,operationFeedback:null});try{const a=await Wa(n);t({operationFeedback:{operation:"createBranch",success:a.success,message:a.message,target:n}}),await s().refresh(!0),await s().loadBranches()}catch(a){t({operationFeedback:{operation:"createBranch",success:!1,message:a.message,target:n}})}finally{t({branchOperationInProgress:!1,repositoryOperationInProgress:!1})}}},selectFile:async(n,a)=>{if(s().selectedFile===n&&s().selectedFileStaged===a){t({selectedFile:null,diffResult:null,selectedFileStaged:!1});return}t({selectedFile:n,selectedFileStaged:a,diffLoading:!0,diffResult:null});try{const l=await ts(n,a);t({diffResult:l,diffLoading:!1})}catch{t({diffLoading:!1})}},clearSelection:()=>t({selectedFile:null,diffResult:null,selectedFileStaged:!1}),setCommitMessage:n=>t({commitMessage:n}),clearOperationMessage:()=>t({operationFeedback:null}),startWatching:async()=>{if(Ze)return;let n=dt();n||(n=await Ua()),n&&(Ze=!0,He=setInterval(()=>{s().refresh()},Ka))},stopWatching:async()=>{Ze=!1,He&&(clearInterval(He),He=null)}}));Ss(async()=>{const t=ge.getState();await t.stopWatching(),t.refresh(),await t.startWatching()});function pt(t,s){const n=t.toLowerCase();return/repository is busy|index\.lock|another git process|could not lock|unable to create.*\.lock/.test(n)?"ide.scm.error.busy":/untracked working tree files.*overwritten/s.test(n)?"ide.scm.error.untrackedFiles":/local changes.*overwritten|would be overwritten by (?:checkout|merge)/s.test(n)?"ide.scm.error.localChanges":/resolve your current index first|unmerged files|you need to resolve your current index/.test(n)?"ide.scm.error.conflicts":/pathspec.*did not match|not a commit|unknown revision/.test(n)?"ide.scm.error.branchNotFound":s==="switchBranch"?"ide.scm.error.switchFailed":"ide.scm.error.operationFailed"}function ss(t,s){if(!["switchBranch","createBranch","push","pull"].includes(s))return!1;const n=pt(t,s);return n==="ide.scm.error.busy"||n==="ide.scm.error.switchFailed"||n==="ide.scm.error.operationFailed"}function as({currentBranch:t,branches:s,branchesLoading:n,operationInProgress:a,onSwitch:l,onCreate:i,onLoadBranches:o,actions:h,defaultOpen:u,onClose:d}){const{t:b}=te(),[j,m]=r.useState(u??!1),[v,T]=r.useState(""),[D,y]=r.useState(""),[x,g]=r.useState(0),[F,K]=r.useState(!1),C=r.useRef(null),N=r.useCallback(k=>{m(k),k||d==null||d()},[d]);r.useEffect(()=>{const k=setTimeout(()=>y(v),100);return()=>clearTimeout(k)},[v]),r.useEffect(()=>{j&&o()},[j,o]),r.useEffect(()=>{j?setTimeout(()=>{var k;return(k=C.current)==null?void 0:k.focus()},0):(T(""),y(""),g(0),K(!1))},[j]);const{localBranches:L,remoteBranches:M,flatList:S}=r.useMemo(()=>{let k;if(D){const $=[];for(const O of s){const E=Ps(D,O.name);E.match&&$.push({...O,_score:E.score})}$.sort((O,E)=>E._score-O._score),k=$}else k=s;const P=k.filter($=>!$.isRemote),U=k.filter($=>$.isRemote),Q=[...P,...U];return{localBranches:P,remoteBranches:U,flatList:Q}},[s,D]);r.useEffect(()=>{g(0)},[v]);const H=r.useCallback(k=>{a||(k.key==="Escape"?N(!1):k.key==="ArrowDown"?(k.preventDefault(),g(P=>Math.min(P+1,S.length-1))):k.key==="ArrowUp"?(k.preventDefault(),g(P=>Math.max(P-1,0))):k.key==="Enter"&&(k.preventDefault(),F?v.trim()&&(i(v.trim()),N(!1)):S[x]?(l(S[x].name),N(!1)):v.trim()&&S.length===0&&(i(v.trim()),N(!1))))},[S,x,F,v,l,i,a]),I=r.useCallback(k=>{a||k===t||(l(k),N(!1))},[t,l,a]),w=r.useCallback(()=>{K(!0),setTimeout(()=>{var k;return(k=C.current)==null?void 0:k.focus()},0)},[]),c=r.useCallback(()=>{v.trim()&&(i(v.trim()),N(!1))},[v,i]);return e.jsxs("div",{className:"branch-picker",children:[!u&&e.jsxs("div",{className:"branch-picker-header",children:[e.jsxs("button",{className:"branch-picker-trigger",onClick:()=>N(!j),title:t||"",disabled:a,children:[a?e.jsx(ke,{size:14,className:"branch-picker-icon animate-spin"}):e.jsx(Ee,{size:14,className:"branch-picker-icon"}),e.jsx("span",{className:"branch-picker-name",children:t||b("ide.scm.noBranch")})]}),h]}),j&&It.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"branch-picker-backdrop",onClick:()=>N(!1)}),e.jsxs("div",{className:"branch-picker-dropdown",onKeyDown:H,onMouseDown:k=>k.stopPropagation(),onClick:k=>k.stopPropagation(),children:[e.jsx("div",{className:"branch-picker-search",children:e.jsx("input",{ref:C,className:"branch-picker-input",type:"text",value:v,onChange:k=>T(k.target.value),placeholder:b(F?"ide.scm.newBranchPlaceholder":"ide.scm.branchSearchPlaceholder")})}),!F&&e.jsx("div",{className:"branch-picker-actions",children:e.jsxs("button",{className:"branch-picker-action",onClick:w,children:[e.jsx(Se,{size:14}),e.jsx("span",{children:b("ide.scm.createBranch")})]})}),F&&e.jsx("div",{className:"branch-picker-actions",children:e.jsxs("button",{className:"branch-picker-action branch-picker-action-confirm",onClick:c,disabled:!v.trim(),children:[e.jsx(Se,{size:14}),e.jsx("span",{children:v.trim()?b("ide.scm.createBranchNamed",{name:v.trim()}):b("ide.scm.newBranchPlaceholder")})]})}),S.length>0&&e.jsx(Ga,{flatList:S,localCount:L.length,remoteCount:M.length,currentBranch:t,highlightIdx:x,onSelect:I,onHover:g}),n&&S.length===0&&e.jsx("div",{className:"branch-picker-empty",children:b("ide.scm.loadingBranches")}),!n&&S.length===0&&!F&&e.jsx("div",{className:"branch-picker-empty",children:b(D?"ide.scm.noBranchMatch":"ide.scm.noBranches")})]})]}),document.body)]})}const Me=40,qe=24;function Ga({flatList:t,localCount:s,remoteCount:n,currentBranch:a,highlightIdx:l,onSelect:i,onHover:o}){const h=r.useRef(null),[u,d]=r.useState(0),[b,j]=r.useState(300);r.useEffect(()=>{const x=h.current;if(!x)return;const g=new ResizeObserver(F=>{for(const K of F)j(K.contentRect.height)});return g.observe(x),()=>g.disconnect()},[]),r.useEffect(()=>{const x=h.current;if(!x)return;const g=l*Me;g<x.scrollTop?x.scrollTop=g:g+Me>x.scrollTop+b&&(x.scrollTop=g+Me-b)},[l,b]);const m=r.useCallback(x=>{d(x.target.scrollTop)},[]),v=t.length*Me+(s>0&&n>0?qe:0)+(n>0?qe:0),T=Math.max(0,Math.floor(u/Me)-2),D=Math.min(t.length,Math.ceil((u+b)/Me)+2),y=[];s>0&&n>0&&T===0&&y.push(e.jsx("div",{className:"branch-picker-group-label",style:{height:qe},children:"branches"},"label-local"));for(let x=T;x<D;x++){const g=t[x];g&&(x===s&&n>0&&y.push(e.jsx("div",{className:"branch-picker-group-label",style:{height:qe},children:"remotes"},"label-remote")),y.push(e.jsx(Qa,{branch:g,isCurrent:g.name===a,isHighlighted:x===l,dataIdx:x,onSelect:i,onHover:()=>o(x)},g.name)))}return e.jsx("div",{ref:h,className:"branch-picker-list",onScroll:m,children:e.jsx("div",{style:{height:v,position:"relative"},children:e.jsx("div",{style:{position:"absolute",top:T*Me,left:0,right:0},children:y})})})}function Qa({branch:t,isCurrent:s,isHighlighted:n,dataIdx:a,onSelect:l,onHover:i}){return e.jsxs("div",{className:`branch-picker-item ${n?"highlighted":""} ${s?"current":""}`,"data-idx":a,onClick:()=>l(t.name),onMouseEnter:i,title:t.lastCommitMessage?`${t.name}
|
|
73
|
+
${t.lastCommitAuthor} • ${t.lastCommitHash} • ${t.lastCommitMessage}`:t.name,children:[e.jsxs("div",{className:"branch-picker-item-main",children:[e.jsx(Ee,{size:14,className:"branch-picker-item-icon"}),e.jsx("span",{className:"branch-picker-item-name",children:t.name}),t.lastCommitDate&&e.jsx("span",{className:"branch-picker-item-date",children:t.lastCommitDate}),s&&e.jsx(Ot,{size:14,className:"branch-picker-item-check"}),t.ahead||t.behind?e.jsxs("span",{className:"branch-picker-item-sync",children:[t.ahead?`↑${t.ahead}`:"",t.behind?`↓${t.behind}`:""]}):null]}),t.lastCommitMessage&&e.jsxs("div",{className:"branch-picker-item-detail",children:[e.jsx("span",{className:"branch-picker-item-author",children:t.lastCommitAuthor}),e.jsx("span",{className:"branch-picker-item-separator",children:"•"}),e.jsx("span",{className:"branch-picker-item-hash",children:t.lastCommitHash}),e.jsx("span",{className:"branch-picker-item-separator",children:"•"}),e.jsx("span",{className:"branch-picker-item-message",children:t.lastCommitMessage})]})]})}const Ve={image:"editor.view.image",svg:"editor.view.svg",markdown:"editor.view.markdown",pdf:"editor.view.pdf",binary:"editor.view.binary"};function ns({language:t,cursorLine:s,cursorColumn:n,selectedCount:a,selectedLines:l,viewMode:i="editor",isDirty:o=!1,saveStatus:h="idle",saveError:u,imageInfo:d,zoom:b,extraRight:j}){const{t:m}=te();if(i==="image"||i==="svg")return e.jsxs("div",{className:"editor-statusbar",children:[e.jsxs("div",{className:"editor-statusbar-left",children:[e.jsx(et,{}),d&&e.jsxs("span",{className:"editor-statusbar-item",children:[d.width," × ",d.height]})]}),e.jsxs("div",{className:"editor-statusbar-right",children:[b!=null&&e.jsxs("span",{className:"editor-statusbar-item",children:[Math.round(b*100),"%"]}),e.jsx("span",{className:"editor-statusbar-item",children:Ve[i]?m(Ve[i]):i}),j]})]});if(i!=="editor")return e.jsxs("div",{className:"editor-statusbar",children:[e.jsx("div",{className:"editor-statusbar-left",children:e.jsx(et,{})}),e.jsxs("div",{className:"editor-statusbar-right",children:[e.jsx("span",{className:"editor-statusbar-item",children:Ve[i]?m(Ve[i]):i}),j]})]});const v=m("editor.cursorPosition",{line:s,col:n});let T="";return a&&a>0&&(T=` (${a} ${m("editor.selected")})`,l&&l>1&&(T=` (${a} ${m("editor.selected")}, ${l} ${m("editor.lines")})`)),e.jsxs("div",{className:"editor-statusbar",children:[e.jsxs("div",{className:"editor-statusbar-left",children:[e.jsx(Xa,{isDirty:o,saveStatus:h,saveError:u,translate:m}),e.jsx(et,{}),e.jsxs("span",{className:"editor-statusbar-item editor-statusbar-cursor",children:[v,T]})]}),e.jsxs("div",{className:"editor-statusbar-right",children:[t&&e.jsx("span",{className:"editor-statusbar-item editor-statusbar-language",children:t}),j]})]})}function Xa({isDirty:t,saveStatus:s,saveError:n,translate:a}){return s==="saving"?e.jsxs("span",{className:"editor-statusbar-item editor-statusbar-save",role:"status",children:[e.jsx("span",{className:"editor-status-save-spinner","aria-hidden":"true"}),a("editor.saving")]}):s==="error"?e.jsx("span",{className:"editor-statusbar-item editor-statusbar-save editor-statusbar-save-error",role:"status",title:n,children:a("editor.saveFailed")}):t?e.jsxs("span",{className:"editor-statusbar-item editor-statusbar-save editor-statusbar-save-dirty",role:"status",children:[e.jsx("span",{className:"editor-status-save-dot","aria-hidden":"true"}),a("editor.unsaved")]}):null}function et(){const{t}=te(),{currentBranch:s,branches:n,branchesLoading:a,branchOperationInProgress:l,repositoryOperationInProgress:i,operationFeedback:o,isGitRepo:h,switchBranch:u,createBranch:d,loadBranches:b,refresh:j,clearOperationMessage:m}=ge(),[v,T]=r.useState(!1),D=r.useRef(null);r.useEffect(()=>{j()},[j]);const y=r.useCallback(g=>{D.current={operation:"switchBranch",target:g},u(g),T(!1)},[u]),x=r.useCallback(g=>{D.current={operation:"createBranch",target:g},d(g),T(!1)},[d]);return r.useEffect(()=>{const g=D.current;if(!g||l||!o||o.operation!==g.operation||o.target!==g.target)return;if(D.current=null,o.success){const C=setTimeout(m,3e3);return()=>clearTimeout(C)}const F=g.operation==="switchBranch"?u:d,K=ss(o.message,g.operation);Te.error(t(pt(o.message,g.operation)),{id:"git-branch-operation-error",durationMs:0,action:K?{label:t("ide.scm.feedback.retry"),onClick:()=>(D.current=g,F(g.target),!0)}:void 0})},[l,o,u,d,m,t]),h?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"editor-statusbar-branch",onClick:g=>{g.stopPropagation(),T(F=>!F)},onPointerDown:g=>g.stopPropagation(),onMouseDown:g=>g.stopPropagation(),"aria-expanded":v,disabled:i,title:s||t("ide.scm.noBranch"),children:[e.jsx(Ee,{size:12}),e.jsx("span",{children:s||t("ide.scm.noBranch")})]}),v&&e.jsx(as,{currentBranch:s,branches:n,branchesLoading:a,operationInProgress:i,onSwitch:y,onCreate:x,onLoadBranches:b,defaultOpen:!0,onClose:()=>T(!1)})]}):null}function tt(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"}function rs({actions:t,onRequestClose:s}){const{t:n}=te(),{tabs:a,activeTabId:l,rootPath:i,setActiveTab:o,closeSavedTabs:h,reorderTabs:u,pinTab:d,unpinTab:b}=ae(),[j,m]=r.useState(null),v=r.useRef(null),[T,D]=r.useState(null),y=r.useRef(-1),x=r.useRef(null),[g,F]=r.useState(!1),[K,C]=r.useState(!1),N=r.useMemo(()=>Ds(a),[a]),L=r.useCallback(()=>{const f=x.current;f&&(F(f.scrollLeft>0),C(f.scrollLeft+f.clientWidth<f.scrollWidth-1))},[]);r.useEffect(()=>{const f=x.current;if(!f)return;L(),f.addEventListener("scroll",L,{passive:!0});const B=new ResizeObserver(L);return B.observe(f),()=>{f.removeEventListener("scroll",L),B.disconnect()}},[L,a.length]),r.useEffect(()=>{if(!l||!x.current)return;const B=x.current.querySelector(".editor-tab.active");B&&B.scrollIntoView({block:"nearest",inline:"nearest",behavior:tt()})},[l]);const M=r.useCallback(()=>{var f;(f=x.current)==null||f.scrollBy({left:-150,behavior:tt()})},[]),S=r.useCallback(()=>{var f;(f=x.current)==null||f.scrollBy({left:150,behavior:tt()})},[]),H=r.useCallback(f=>{const B=a[f];B&&(o(B.id),requestAnimationFrame(()=>{var z,J;const q=(z=x.current)==null?void 0:z.querySelectorAll('[role="tab"]');(J=q==null?void 0:q[f])==null||J.focus()}))},[o,a]),I=r.useCallback((f,B)=>{let q=null;f.key==="ArrowLeft"&&(q=(B-1+a.length)%a.length),f.key==="ArrowRight"&&(q=(B+1)%a.length),f.key==="Home"&&(q=0),f.key==="End"&&(q=a.length-1),q!==null&&(f.preventDefault(),H(q))},[H,a.length]),w=r.useCallback((f,B)=>{f.preventDefault(),m({x:f.clientX,y:f.clientY,tabId:B})},[]),c=r.useCallback(()=>{m(null)},[]),k=r.useCallback((f,B)=>{f.button===1&&(f.preventDefault(),s({kind:"single",id:B}).catch(()=>{}))},[s]),P=r.useCallback((f,B)=>{y.current=B,f.dataTransfer.effectAllowed="move",f.currentTarget instanceof HTMLElement&&f.dataTransfer.setDragImage(f.currentTarget,0,0)},[]),U=r.useCallback((f,B)=>{f.preventDefault(),f.dataTransfer.dropEffect="move",D(B)},[]),Q=r.useCallback((f,B)=>{f.preventDefault();const q=y.current;q>=0&&q!==B&&u(q,B),y.current=-1,D(null)},[u]),$=r.useCallback(()=>{y.current=-1,D(null)},[]),O=r.useCallback(f=>{const B=a.find(q=>q.id===f);B&&ze(B.path),c()},[a,c]),E=r.useCallback(f=>{const B=a.find(q=>q.id===f);if(B&&i){const q=B.path.startsWith(i+"/")?B.path.slice(i.length+1):B.path;ze(q)}else B&&ze(B.path);c()},[a,i,c]),X=r.useCallback(f=>{const B=a.find(q=>q.id===f);if(B){const{selectPath:q,toggleExpand:z,expandedPaths:J}=ae.getState(),ue=B.path.split("/");for(let le=1;le<ue.length;le++){const Z=ue.slice(0,le).join("/");Z&&!J.has(Z)&&z(Z)}q(B.path)}c()},[a,c]),G=r.useCallback(f=>{s(f).catch(()=>{}),c()},[c,s]);if(a.length===0)return null;const A=j?a.find(f=>f.id===j.tabId):null;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"editor-tabs-wrapper",children:[g&&e.jsx("button",{className:"editor-tabs-scroll-btn","aria-label":n("editor.scrollTabsLeft"),onClick:M,children:e.jsx(Ms,{size:14})}),e.jsx("div",{className:"editor-tabs",ref:x,role:"tablist","aria-label":n("editor.openEditors"),children:a.map((f,B)=>{let q=null,z="";f.saveStatus==="saving"?(q="saving",z=n("editor.saving")):f.saveStatus==="error"?(q="error",z=`${n("editor.saveFailed")}${f.saveError?`: ${f.saveError}`:""}`):f.isDirty&&(q="dirty",z=n("editor.unsaved"));const J=N.get(f.id),ue=z?`${f.path} — ${z}`:f.path,le=z?`${f.name}, ${z}`:f.name;return e.jsxs("div",{className:`editor-tab${f.id===l?" active":""}${T===B?" drag-indicator":""}`,onMouseDown:Z=>k(Z,f.id),onContextMenu:Z=>w(Z,f.id),title:ue,draggable:!0,onDragStart:Z=>P(Z,B),onDragOver:Z=>U(Z,B),onDrop:Z=>Q(Z,B),onDragEnd:$,children:[e.jsxs("button",{type:"button",className:"editor-tab-main",role:"tab",tabIndex:f.id===l?0:-1,"aria-selected":f.id===l,"aria-label":le,onClick:()=>o(f.id),onKeyDown:Z=>I(Z,B),children:[e.jsx(we,{name:f.name,type:"file",size:14}),e.jsx("span",{className:"editor-tab-name",children:f.name}),J&&e.jsx("span",{className:"editor-tab-description",children:J}),f.isPinned&&e.jsx("span",{className:"pin-icon",title:n("editor.pin"),children:e.jsx(zs,{size:14})}),e.jsxs("span",{className:"editor-tab-state",children:[q==="saving"&&e.jsx("span",{className:"tab-save-indicator",title:z,children:e.jsx("span",{className:"tab-save-spinner","aria-hidden":"true"})}),q==="error"&&e.jsx("span",{className:"tab-save-indicator tab-save-error",title:z,"aria-hidden":"true",children:"!"}),q==="dirty"&&e.jsx("span",{className:"tab-save-indicator",title:z,children:e.jsx("span",{className:"dirty-dot","aria-hidden":"true"})})]})]}),e.jsx("button",{type:"button",className:`close-btn${q?"":" clean-close"}`,tabIndex:f.id===l?0:-1,"aria-label":n("editor.closeTabAriaLabel",{name:f.name}),onClick:()=>{s({kind:"single",id:f.id}).catch(()=>{})},children:e.jsx(ut,{size:12})})]},f.id)})}),K&&e.jsx("button",{className:"editor-tabs-scroll-btn","aria-label":n("editor.scrollTabsRight"),onClick:S,children:e.jsx(oe,{size:14})}),t&&e.jsx("div",{className:"editor-tabs-actions",children:t})]}),j&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-context-overlay",onClick:c}),e.jsxs("div",{ref:v,className:"editor-context-menu",style:{left:j.x,top:j.y},children:[A!=null&&A.isPinned?e.jsx("button",{onClick:()=>{b(j.tabId),c()},children:n("editor.unpin")}):e.jsx("button",{onClick:()=>{d(j.tabId),c()},children:n("editor.pin")}),e.jsx("div",{className:"editor-context-separator"}),e.jsx("button",{onClick:()=>O(j.tabId),children:n("editor.copyPath")}),e.jsx("button",{onClick:()=>E(j.tabId),children:n("editor.copyRelativePath")}),e.jsx("button",{onClick:()=>X(j.tabId),children:n("editor.revealInExplorer")}),e.jsx("div",{className:"editor-context-separator"}),e.jsx("button",{onClick:()=>G({kind:"single",id:j.tabId}),children:n("editor.close")}),e.jsx("button",{onClick:()=>G({kind:"others",id:j.tabId}),children:n("editor.closeOthers")}),e.jsx("button",{onClick:()=>G({kind:"right",id:j.tabId}),children:n("editor.closeToRight")}),e.jsx("button",{onClick:()=>{h(),c()},children:n("editor.closeSaved")}),e.jsx("button",{onClick:()=>G({kind:"all"}),children:n("editor.closeAll")})]})]})]})}const Ya=Rs,is=Rt;function wt({path:t,onImageInfo:s,onZoomChange:n}){const{t:a}=te(),l=r.useRef(null),i=r.useRef(null),[o,h]=r.useState("fit"),u=At(is(t)),[d,b]=r.useState(null),[j,m]=r.useState(!1),[v,T]=r.useState({x:0,y:0}),D=r.useRef({x:0,y:0,tx:0,ty:0}),y=r.useCallback(()=>{if(!l.current||!d)return 1;const c=l.current.clientWidth-40,k=l.current.clientHeight-80;return c<=0||k<=0?1:Math.min(c/d.w,k/d.h,1)},[d]),x=o==="fit"?y():o,g=r.useCallback(()=>{const c=i.current;if(!c)return;const k=c.naturalWidth,P=c.naturalHeight;b({w:k,h:P}),s==null||s({width:k,height:P})},[s]);r.useEffect(()=>{n==null||n(x)},[x,n]);const F=r.useCallback(c=>{!c.ctrlKey&&!c.metaKey||(c.preventDefault(),h(k=>{const P=k==="fit"?y():k,U=c.deltaY<0?.1:-.1;return Math.min(5,Math.max(.1,P+U))}))},[y]),K=r.useCallback(c=>{o!=="fit"&&(c.preventDefault(),m(!0),D.current={x:c.clientX,y:c.clientY,tx:v.x,ty:v.y})},[o,v]),C=r.useCallback(c=>{if(!j)return;const k=c.clientX-D.current.x,P=c.clientY-D.current.y;T({x:D.current.tx+k,y:D.current.ty+P})},[j]),N=r.useCallback(()=>{m(!1)},[]),L=()=>h(c=>Math.min(5,(c==="fit"?y():c)+.1)),M=()=>h(c=>Math.max(.1,(c==="fit"?y():c)-.1)),S=()=>{h("fit"),T({x:0,y:0})},H=()=>{h(1),T({x:0,y:0})},I=()=>{const c=t.split("/").pop()||t;$e(t,c).catch(k=>{console.warn("[FilePreview] download failed:",String(k))})},w=x>=3;return e.jsxs("div",{ref:l,className:"file-preview-image-container checkerboard",onWheel:F,onMouseDown:K,onMouseMove:C,onMouseUp:N,onMouseLeave:N,style:{cursor:o!=="fit"?j?"grabbing":"grab":"default"},children:[u&&e.jsx("img",{ref:i,src:u,alt:t,onLoad:g,className:w?"pixelated":"",style:{transform:`translate(${v.x}px, ${v.y}px) scale(${x})`,transformOrigin:"center center",maxWidth:"none",maxHeight:"none",userSelect:"none",pointerEvents:"none"},draggable:!1}),e.jsxs("div",{className:"image-zoom-toolbar",children:[e.jsx("button",{onClick:M,title:a("filePreview.zoomOut"),children:e.jsx(Ue,{size:16})}),e.jsxs("span",{className:"image-zoom-label",children:[Math.round(x*100),"%"]}),e.jsx("button",{onClick:L,title:a("filePreview.zoomIn"),children:e.jsx(Se,{size:16})}),e.jsx("button",{onClick:S,title:a("filePreview.fitToWindow"),children:e.jsx(Bt,{size:16})}),e.jsx("button",{onClick:H,title:a("filePreview.actualSize"),children:e.jsx(Ea,{size:16})}),e.jsx("button",{onClick:I,title:a("filePreview.download"),children:e.jsx(Le,{size:16})})]})]})}function Ja({className:t,children:s}){const n=Ft(i=>i.resolved),a=(t||"").match(/language-(\w+)/),l=String(s).replace(/\n$/,"");return a?e.jsx("div",{className:"relative group my-3",children:e.jsx(Ya,{style:n==="dark"?Fs:Ts,language:a[1],PreTag:"div",customStyle:{margin:0,borderRadius:"8px",fontSize:"13px",lineHeight:"1.6"},codeTagProps:{style:{background:"transparent",textShadow:"none"}},children:l})}):e.jsx("code",{className:"markdown-inline-code",children:s})}function Za({path:t,name:s,content:n}){const{t:a}=te(),l=()=>{Jt(s||t.split("/").pop()||"file.md",n)};return e.jsxs("div",{className:"file-preview-markdown",children:[e.jsx("div",{className:"file-preview-markdown-toolbar",children:e.jsxs("button",{type:"button",onClick:l,title:a("filePreview.download"),children:[e.jsx(Le,{size:16}),a("filePreview.download")]})}),e.jsx("div",{className:"file-preview-markdown-content",children:e.jsx(ca,{remarkPlugins:[da],components:{code:Ja},children:n})})]})}function en({path:t,name:s}){const{t:n}=te(),a=At(is(t)),l=()=>{$e(t,s||t.split("/").pop()||"file.pdf").catch(i=>{console.warn("[FilePreview] download failed:",String(i))})};return a?e.jsxs("div",{className:"file-preview-pdf-wrap",children:[e.jsx("iframe",{src:a,className:"file-preview-pdf",title:n("filePreview.pdfPreview")}),e.jsxs("button",{type:"button",className:"file-preview-pdf-download",onClick:l,title:n("filePreview.download"),children:[e.jsx(Le,{size:16}),n("filePreview.download")]})]}):null}function tn({path:t,name:s}){const{t:n}=te(),a=r.useCallback(()=>{$e(t,s).catch(l=>{console.warn("[FilePreview] download failed:",String(l))})},[t,s]);return e.jsxs("div",{className:"file-preview-binary",children:[e.jsx(Es,{size:48,className:"text-[var(--color-text-tertiary)]"}),e.jsx("div",{className:"mt-4 text-lg font-medium text-[var(--color-text-primary)]",children:s}),e.jsx("div",{className:"mt-2 text-sm text-[var(--color-text-secondary)]",children:n("filePreview.binaryNotSupported")}),e.jsxs("button",{onClick:a,className:"mt-4 inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-[var(--color-bg-tertiary)] text-[var(--color-text-primary)] hover:bg-[var(--color-bg-quaternary)] transition-colors text-sm",children:[e.jsx(Le,{size:16}),n("filePreview.download")]})]})}function ls({path:t,name:s,content:n,viewMode:a,onImageInfo:l,onZoomChange:i}){switch(a){case"image":return e.jsx(wt,{path:t,onImageInfo:l,onZoomChange:i});case"svg":return e.jsx(wt,{path:t,onImageInfo:l,onZoomChange:i});case"markdown":return e.jsx(Za,{path:t,name:s,content:n});case"pdf":return e.jsx(en,{path:t,name:s});case"binary":return e.jsx(tn,{path:t,name:s});default:return null}}function sn(t,s=300){const[n,a]=r.useState(!1);return r.useEffect(()=>{if(!t){a(!1);return}const l=setTimeout(()=>a(!0),s);return()=>clearTimeout(l)},[t,s]),n}function an(t){switch(t){case"modified":return"M";case"added":return"A";case"untracked":return"U";case"deleted":return"D";case"conflicted":return"C";case"renamed":return"R";case"copied":return"C";default:return""}}function os(t){return`file-tree-item-${encodeURIComponent(t)}`}function cs({node:t,depth:s,isExpanded:n,isSelected:a,isMultiSelected:l,isRenaming:i,expandedPaths:o,selectedPath:h,selectedPaths:u,renamingPath:d,gitStatusMap:b,onToggleExpand:j,onSelect:m,onOpenFile:v,onConfirmRename:T,onCancelRename:D,onContextMenu:y,onDragStart:x,onDrop:g}){const F=t.type==="directory",K=12+s*12,C=b.get(t.path),N=ae(z=>z.showHiddenFiles),L=sn(!!t.isLoading),M=r.useMemo(()=>nt(t.children,N),[t.children,N]),[S,H]=r.useState(t.name),I=r.useRef(null),[w,c]=r.useState(!1);r.useEffect(()=>{if(i&&I.current){H(t.name),I.current.focus();const z=t.name.lastIndexOf(".");!F&&z>0?I.current.setSelectionRange(0,z):I.current.select()}},[i,t.name,F]);const k=r.useCallback(z=>{i||(m(t.path,{ctrl:z.ctrlKey||z.metaKey,shift:z.shiftKey}),F?j(t.path):!z.ctrlKey&&!z.metaKey&&!z.shiftKey&&v(t.path,t.name))},[i,t.path,F,t.name,m,j,v]),P=r.useCallback(()=>{i||F||v(t.path,t.name)},[i,F,t.path,t.name,v]),U=r.useCallback(z=>{z.stopPropagation(),z.key==="Enter"?(z.preventDefault(),T(t.path,S)):z.key==="Escape"&&(z.preventDefault(),D())},[t.path,S,T,D]),Q=r.useCallback(()=>{T(t.path,S)},[t.path,S,T]),$=r.useCallback(z=>{z.preventDefault(),y(z,t.path)},[y,t.path]),O=r.useCallback(z=>{const J=l?[...u]:[t.path];z.dataTransfer.effectAllowed="copyMove",z.dataTransfer.setData("text/plain",JSON.stringify(J)),z.dataTransfer.setData("application/x-file-paths",JSON.stringify(J)),x(J)},[l,u,t.path,x]),E=r.useCallback(z=>{F&&(z.preventDefault(),z.dataTransfer.dropEffect="move",c(!0))},[F]),X=r.useCallback(()=>{c(!1)},[]),G=r.useCallback(z=>{z.preventDefault(),c(!1),F&&g(t.path)},[F,t.path,g]),A=a||l,f=C?`Git: ${C}`:void 0,B=12,q=12;return e.jsxs("div",{id:os(t.path),role:"treeitem","aria-level":s+1,"aria-expanded":F?n:void 0,"aria-selected":A,"aria-label":f?`${t.name}, ${f}`:t.name,"data-path":t.path,title:f?`${t.path} (${f})`:t.path,children:[e.jsxs("div",{className:`file-tree-item ${A?"selected":""} ${w?"drag-over":""}`,onClick:k,onDoubleClick:P,onContextMenu:$,draggable:!i,onDragStart:O,onDragOver:E,onDragLeave:X,onDrop:G,children:[Array.from({length:s},(z,J)=>e.jsx("span",{className:"file-tree-indent-guide",style:{left:q+J*B+6}},J)),e.jsx("span",{style:{width:K,flexShrink:0}}),F?L?e.jsx(ke,{size:16,className:"file-tree-chevron animate-spin"}):e.jsx(oe,{size:16,className:`file-tree-chevron ${n?"expanded":""}`}):e.jsx(we,{name:t.name,type:t.type,isExpanded:n,size:16}),i?e.jsx("input",{ref:I,className:"file-tree-rename-input",value:S,onChange:z=>H(z.target.value),onKeyDown:U,onBlur:Q,onClick:z=>z.stopPropagation()}):e.jsx("span",{className:`file-tree-item-name${C?` git-status-${C}`:""}`,children:t.name}),C&&!F&&e.jsx("span",{className:`file-tree-git-badge git-status-${C}`,"aria-label":f,title:f,children:an(C)})]}),F&&n&&e.jsx("div",{role:"group",children:M.map(z=>e.jsx(cs,{node:z,depth:s+1,isExpanded:o.has(z.path),isSelected:h===z.path,isMultiSelected:u.has(z.path),isRenaming:d===z.path,expandedPaths:o,selectedPath:h,selectedPaths:u,renamingPath:d,gitStatusMap:b,onToggleExpand:j,onSelect:m,onOpenFile:v,onConfirmRename:T,onCancelRename:D,onContextMenu:y,onDragStart:x,onDrop:g},z.path))})]})}function ds(t){var W;const{t:s}=te(),n=Is(p=>p.info),{rootPath:a,tree:l,treeLoading:i,treeError:o,expandedPaths:h,selectedPath:u,selectedPaths:d,tabs:b,renamingPath:j,setRootPath:m,toggleExpand:v,selectPath:T,openFile:D,refreshTree:y,collapseAll:x,createNewFile:g,createNewFolder:F,startRename:K,startCreateFile:C,startCreateFolder:N,confirmRename:L,cancelRename:M,deleteSelected:S,moveToDirectory:H,showHiddenFiles:I,toggleShowHiddenFiles:w}=ae(),c=ge(p=>p.files),k=r.useMemo(()=>{const p=new Map;if(!c.length||!a)return p;const _={conflicted:6,deleted:5,modified:4,renamed:3,added:2,copied:1,untracked:0};for(const R of c){const V=R.path.startsWith("/")?R.path:`${a}/${R.path}`;p.set(V,R.status);let se=V.substring(0,V.lastIndexOf("/"));for(;se&&se.length>=a.length;){const ne=p.get(se);(!ne||(_[R.status]??0)>(_[ne]??0))&&p.set(se,R.status),se=se.substring(0,se.lastIndexOf("/"))}}return p},[c,a]),P=r.useMemo(()=>nt(l==null?void 0:l.children,I),[l==null?void 0:l.children,I]),[U,Q]=r.useState(!1),[$,O]=r.useState(!1),[E,X]=r.useState(!1),G=r.useRef(null),[A,f]=r.useState(null),B=r.useRef([]);r.useEffect(()=>{const p=_t().has("path");n!=null&&n.cwd&&!a&&!p?m(n.cwd):a&&!l&&!i&&!o&&m(a)},[n==null?void 0:n.cwd,a,l,i,o,m]);const q=r.useCallback(p=>{O(!1),m(p)},[m]),z=r.useCallback((p,_)=>{D(p,_)},[D]),J=r.useCallback((p,_)=>{L(p,_)},[L]),ue=r.useCallback((p,_)=>{p.preventDefault(),d.has(_)||T(_),f({x:p.clientX,y:p.clientY,path:_})},[d,T]),le=r.useCallback(()=>f(null),[]),Z=r.useCallback(()=>{A&&(K(A.path),f(null))},[A,K]),ee=r.useCallback((p,_)=>{if(!p)return null;if(p.path===_)return p;if(p.children)for(const R of p.children){const V=ee(R,_);if(V)return V}return null},[]),he=A?((W=ee(l,A.path))==null?void 0:W.type)==="directory":!1,me=r.useCallback(()=>{if(d.size===0)return;const p=[...d],_=p.some(V=>{var se;return((se=ee(l,V))==null?void 0:se.type)==="directory"}),R=b.some(V=>V.isDirty&&p.some(se=>V.path===se||V.path.startsWith(`${se}/`)));if(p.length>1||_||R){X(!0);return}S().catch(()=>{})},[S,ee,d,b,l]),Pe=r.useCallback(()=>{f(null),me()},[me]),be=r.useCallback(()=>{X(!1),S().catch(()=>{})},[S]),Y=r.useCallback(p=>{if(!A)return;const _=ee(l,A.path),R=(_==null?void 0:_.type)==="directory"?A.path:A.path.substring(0,A.path.lastIndexOf("/"));if(R){h.has(R)||v(R);const V=`${R}/__new_${p}__`;p==="file"?C(V):N(V)}f(null)},[A,h,ee,C,N,v,l]),ie=r.useCallback(()=>{A&&(ze(A.path),f(null))},[A]),de=r.useCallback(()=>{if(A&&a){const p=A.path.startsWith(a+"/")?A.path.slice(a.length+1):A.path;ze(p),f(null)}},[A,a]),xe=r.useCallback(()=>{A&&(ze(A.path.split("/").pop()||A.path),f(null))},[A]),De=r.useCallback(()=>{if(!A)return;const p=ee(l,A.path);(p==null?void 0:p.type)==="file"&&z(p.path,p.name),f(null)},[A,ee,z,l]),Ge=r.useCallback(()=>{A&&(Tt(Ls(A.path)),f(null))},[A]),Qe=r.useCallback(()=>{if(!A)return;const p=ee(l,A.path);if((p==null?void 0:p.type)!=="file"){f(null);return}$e(p.path,p.name||Xt(p.path)).catch(()=>{Te.error(s("editor.downloadFailed"))}),f(null)},[A,ee,s,l]),Oe=r.useCallback(p=>{B.current=p},[]),Ce=r.useCallback(p=>{const _=B.current;B.current=[],_.length!==0&&H(_,p).catch(R=>{const V=R instanceof Error?R.message:String(R);Te.error(`${s("editor.moveFailed")}: ${V}`)})},[H,s]),Ae=r.useCallback(p=>{if(j||!l)return;const _=$s(l,h,I);if(_.length===0)return;const R=u?_.indexOf(u):-1,V=u?ee(l,u):null;function se(ne,Re=!1){var Xe,_e;T(ne,{shift:Re}),(_e=(Xe=G.current)==null?void 0:Xe.querySelector(`[data-path="${CSS.escape(ne)}"]`))==null||_e.scrollIntoView({block:"nearest"})}switch(p.key){case"ArrowDown":{p.preventDefault();const ne=R<_.length-1?R+1:0;se(_[ne],p.shiftKey);break}case"ArrowUp":{p.preventDefault();const ne=R>0?R-1:_.length-1;se(_[ne],p.shiftKey);break}case"ArrowRight":{if(p.preventDefault(),(V==null?void 0:V.type)!=="directory")break;if(!h.has(V.path))v(V.path);else{const ne=nt(V.children,I)[0];ne&&se(ne.path)}break}case"ArrowLeft":{if(p.preventDefault(),(V==null?void 0:V.type)==="directory"&&h.has(V.path)){v(V.path);break}if(u){const ne=u.substring(0,u.lastIndexOf("/"));_.includes(ne)&&se(ne)}break}case"Enter":case" ":{p.preventDefault(),(V==null?void 0:V.type)==="directory"?v(V.path):V&&D(V.path,V.name);break}case"F2":{p.preventDefault(),u&&K(u);break}case"Delete":case"Backspace":{p.preventDefault(),d.size>0&&me();break}}},[l,h,u,d,j,I,ee,T,v,K,D,me]);r.useEffect(()=>{if(!u)return;const p=setTimeout(()=>{var V;const _=(V=G.current)==null?void 0:V.querySelector(`[data-path="${CSS.escape(u)}"]`),R=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth";_==null||_.scrollIntoView({block:"nearest",behavior:R})},60);return()=>clearTimeout(p)},[u]);const Be=(l==null?void 0:l.name)||(a==null?void 0:a.split("/").pop())||"WORKSPACE";return e.jsxs("div",{className:"file-tree",children:[e.jsx("div",{className:"file-tree-title-bar",children:e.jsx("span",{className:"file-tree-title-text",children:s("editor.explorer")})}),e.jsxs("div",{className:"file-tree-section-header",children:[e.jsxs("button",{type:"button",className:"file-tree-section-toggle","aria-expanded":!U,onClick:()=>Q(p=>!p),children:[U?e.jsx(oe,{size:12,style:{flexShrink:0}}):e.jsx(pe,{size:12,style:{flexShrink:0}}),e.jsx("span",{className:"file-tree-section-name",children:Be.toUpperCase()})]}),e.jsxs("div",{className:"file-tree-section-actions",children:[e.jsx("button",{className:"file-tree-section-action",onClick:g,title:s("editor.newFile"),"aria-label":s("editor.newFile"),children:e.jsx(ja,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:F,title:s("editor.newFolder"),"aria-label":s("editor.newFolder"),children:e.jsx(Os,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:()=>O(!0),title:s("editor.openFolder"),"aria-label":s("editor.openFolder"),children:e.jsx(ht,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:()=>{y().catch(()=>{})},title:s("editor.refresh"),"aria-label":s("editor.refresh"),children:e.jsx(Ie,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:x,title:s("editor.collapseAll"),"aria-label":s("editor.collapseAll"),children:e.jsx(pa,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:w,title:s(I?"editor.hideHiddenFiles":"editor.showHiddenFiles"),"aria-label":s(I?"editor.hideHiddenFiles":"editor.showHiddenFiles"),children:I?e.jsx(As,{size:14}):e.jsx(Bs,{size:14})})]})]}),$&&e.jsx(_s,{initialPath:a||(n==null?void 0:n.cwd)||"/",onSelect:q,onClose:()=>O(!1)}),E&&e.jsx(Wt,{title:s("editor.deleteConfirmTitle"),message:s("editor.deleteConfirmMessage",{count:d.size}),confirmLabel:s("editor.delete"),danger:!0,onConfirm:be,onCancel:()=>X(!1)}),!U&&e.jsxs("div",{className:"file-tree-content",ref:G,role:"tree","aria-label":s("editor.fileTreeAriaLabel"),"aria-multiselectable":"true","aria-activedescendant":u?os(u):void 0,tabIndex:0,onKeyDown:Ae,onClick:()=>{var p;return(p=G.current)==null?void 0:p.focus()},children:[i&&!l&&e.jsx("div",{className:"file-tree-loading",children:e.jsx(ke,{size:16,className:"animate-spin"})}),!i&&!l&&o&&a&&e.jsxs("div",{className:"file-tree-empty",children:[e.jsx("span",{children:s("editor.loadError")}),e.jsxs("button",{className:"file-tree-retry-btn",onClick:()=>m(a),children:[e.jsx(Ie,{size:12}),s("editor.refresh")]}),(n==null?void 0:n.cwd)&&a!==n.cwd&&e.jsxs("button",{className:"file-tree-retry-btn",onClick:()=>m(n.cwd),children:[e.jsx(Ca,{size:12}),s("editor.backToWorkDir")]})]}),P.map(p=>e.jsx(cs,{node:p,depth:0,isExpanded:h.has(p.path),isSelected:u===p.path,isMultiSelected:d.has(p.path),isRenaming:j===p.path,expandedPaths:h,selectedPath:u,selectedPaths:d,renamingPath:j,gitStatusMap:k,onToggleExpand:v,onSelect:T,onOpenFile:z,onConfirmRename:J,onCancelRename:M,onContextMenu:ue,onDragStart:Oe,onDrop:Ce},p.path)),P.length===0&&(l==null?void 0:l.children)&&e.jsx("div",{className:"file-tree-empty",children:s("editor.emptyFolder")})]}),A&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-context-overlay",onClick:le}),e.jsxs("div",{className:"editor-context-menu",style:{left:A.x,top:A.y},children:[!he&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:De,children:s("editor.open")}),e.jsx("button",{onClick:Ge,children:s("editor.addToChat")}),e.jsx("button",{onClick:Qe,children:s("editor.download")}),e.jsx("div",{className:"editor-context-separator"})]}),he&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>Y("file"),children:s("editor.newFile")}),e.jsx("button",{onClick:()=>Y("folder"),children:s("editor.newFolder")}),e.jsx("div",{className:"editor-context-separator"})]}),e.jsx("button",{onClick:ie,children:s("editor.copyPath")}),e.jsx("button",{onClick:de,children:s("editor.copyRelativePath")}),e.jsx("button",{onClick:xe,children:s("editor.copyName")}),e.jsx("div",{className:"editor-context-separator"}),d.size<=1&&e.jsx("button",{onClick:Z,children:s("editor.rename")}),e.jsx("button",{className:"danger",onClick:Pe,children:d.size>1?`${s("editor.delete")} (${d.size})`:s("editor.delete")})]})]})]})}function nn(t,s){fetch(`/api/v1/pty/${t}/input/send`,{method:"POST",headers:{...Ke(),"Content-Type":"application/json"},body:JSON.stringify({data:s})}).catch(()=>{})}function rn(t){return/^[a-zA-Z0-9_./-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function us(){const{t}=te(),{bottomTerminals:s,activeBottomTerminalId:n,bottomPanelMaximized:a,createBottomTerminal:l,closeBottomTerminal:i,closeOtherBottomTerminals:o,closeBottomTerminalsToRight:h,closeAllBottomTerminals:u,setActiveBottomTerminal:d,setBottomPanelCollapsed:b,toggleBottomPanelMaximize:j}=re(),m=Ws(c=>c.cwd),[v,T]=r.useState(null),D=r.useCallback((c,k)=>{c.preventDefault(),T({x:c.clientX,y:c.clientY,tabId:k})},[]),y=r.useCallback(()=>{T(null)},[]),x=Hs(c=>c.panes),g=r.useRef(null);r.useEffect(()=>{const c=setTimeout(()=>{window.dispatchEvent(new Event("resize"))},60);return()=>clearTimeout(c)},[]),r.useEffect(()=>{if(!n||!g.current)return;const k=g.current.querySelector(".ide-bottom-tab.active");k&&k.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})},[n]);const F=r.useCallback(()=>{l()},[l]),K=r.useCallback((c,k)=>{c.stopPropagation(),i(k)},[i]),C=r.useCallback(()=>{b(!0)},[b]),[N,L]=r.useState(!1),M=r.useRef(0),S=r.useCallback(c=>{c.preventDefault(),c.stopPropagation(),M.current++,(c.dataTransfer.types.includes("text/plain")||c.dataTransfer.types.includes("application/x-file-paths"))&&L(!0)},[]),H=r.useCallback(c=>{c.preventDefault(),c.stopPropagation(),c.dataTransfer.dropEffect="copy"},[]),I=r.useCallback(c=>{c.preventDefault(),c.stopPropagation(),M.current--,M.current<=0&&(M.current=0,L(!1))},[]),w=r.useCallback(c=>{c.preventDefault(),c.stopPropagation(),L(!1),M.current=0;let k=[];const P=c.dataTransfer.getData("application/x-file-paths")||c.dataTransfer.getData("text/plain");if(P)try{const O=JSON.parse(P);Array.isArray(O)&&(k=O)}catch{k=[P]}if(k.length===0&&c.dataTransfer.files.length>0)for(let O=0;O<c.dataTransfer.files.length;O++){const E=c.dataTransfer.files[O],X=E.path||E.webkitRelativePath||E.name;X&&k.push(X)}if(k.length===0)return;const U=n;if(!U)return;const Q=x[U];if(!(Q!=null&&Q.ptySessionId))return;const $=k.map(rn).join(" ");nn(Q.ptySessionId,$),setTimeout(()=>{const O=document.querySelector('.ide-bottom-terminal-wrap[style*="flex"] .xterm-helper-textarea');O==null||O.focus()},50)},[n,x]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`ide-bottom-panel ${N?"drop-highlight":""}`,onDragEnter:S,onDragOver:H,onDragLeave:I,onDrop:w,children:[e.jsxs("div",{className:"ide-bottom-tabs",children:[e.jsx("div",{className:"ide-bottom-tabs-list",ref:g,onDoubleClick:c=>{c.target===c.currentTarget&&F()},children:s.map((c,k)=>{const P=x[c],U=(P==null?void 0:P.title)||`Terminal ${k+1}`,Q=c===n;return e.jsxs("button",{className:`ide-bottom-tab ${Q?"active":""}`,onClick:()=>d(c),onDoubleClick:()=>j(),onContextMenu:$=>D($,c),children:[e.jsx("span",{className:"ide-bottom-tab-title",title:U,children:U}),e.jsx("span",{className:"ide-bottom-tab-close",onClick:$=>K($,c),children:e.jsx(ut,{size:14})})]},c)})}),e.jsxs("div",{className:"ide-bottom-tabs-actions",children:[e.jsx("button",{className:"ide-bottom-action-btn",onClick:F,title:t("ide.newTerminal"),children:e.jsx(Se,{size:16})}),e.jsx("button",{className:"ide-bottom-action-btn",onClick:j,title:t(a?"ide.restorePanel":"ide.maximizePanel"),children:a?e.jsx(qs,{size:16}):e.jsx(Bt,{size:16})}),e.jsx("button",{className:"ide-bottom-action-btn",onClick:C,title:t("ide.hidePanel"),children:e.jsx(pe,{size:16})})]})]}),e.jsxs("div",{className:"ide-bottom-content",children:[s.map(c=>e.jsx("div",{className:"ide-bottom-terminal-wrap",style:{display:c===n?"flex":"none"},children:e.jsx(ua,{paneId:c,initialCwd:m})},c)),s.length===0&&e.jsx("div",{className:"ide-bottom-empty",children:e.jsxs("button",{className:"ide-bottom-empty-btn",onClick:F,children:[e.jsx(Se,{size:16}),e.jsx("span",{children:t("ide.newTerminal")})]})})]})]}),v&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-context-overlay",onClick:y}),e.jsxs("div",{className:"editor-context-menu",style:{left:v.x,top:v.y},children:[e.jsx("button",{onClick:()=>{i(v.tabId),y()},children:t("terminal.close")}),e.jsx("button",{onClick:()=>{o(v.tabId),y()},children:t("terminal.closeOthers")}),e.jsx("button",{onClick:()=>{h(v.tabId),y()},children:t("terminal.closeToRight")}),e.jsx("div",{className:"editor-context-separator"}),e.jsx("button",{onClick:()=>{u(),y()},children:t("terminal.closeAll")})]})]})]})}function Ct(t){const{direction:s,initialSize:n,minSize:a=120,maxSize:l,collapsible:i=!0,collapseThreshold:o,defaultCollapsed:h=!1,onResize:u,onCollapse:d,onMaximize:b,maximizeThreshold:j=.92,reverse:m=!1,ariaLabel:v,keyboardStep:T=10}=t,[D,y]=r.useState(n),[x,g]=r.useState(h),[F,K]=r.useState(!1),C=r.useRef(!1),N=r.useRef(null),L=r.useRef(n);r.useEffect(()=>{!x&&!C.current&&y(n)},[n,x]),r.useEffect(()=>{g(h)},[h]);const M=o??a*.6,S=r.useCallback(()=>{if(l)return l;const $=N.current;if(!($!=null&&$.parentElement))return 1/0;const O=$.parentElement.getBoundingClientRect();return(s==="horizontal"?O.width:O.height)*.8},[s,l]),H=r.useCallback($=>{const O=Math.max(a,Math.min(S(),$));y(O),L.current=O,u==null||u(O)},[a,S,u]),I=r.useCallback(()=>{g($=>{const O=!$;if(O)L.current=D;else{const E=Math.max(a,L.current);y(E),u==null||u(E)}return d==null||d(O),O})},[D,a,u,d]),w=r.useCallback(($,O,E,X)=>{C.current=!0,K(!0);const G=N.current;if(!G){C.current=!1,K(!1);return}const A=x?0:D,f=S(),q=(s==="horizontal"?G.clientWidth:G.clientHeight)*j;let z=!1,J=null;J=Vs({pointerId:E,target:X,cursor:s==="horizontal"?"col-resize":"row-resize",onMove:(le,Z)=>{if(z)return;let ee;s==="horizontal"?ee=le-$:ee=Z-O,m&&(ee=-ee);const he=A+ee;if(i&&he<M){x||(L.current=D>a?D:n,g(!0),d==null||d(!0));return}if(b&&he>=q){z=!0,b(),J==null||J();return}x&&he>=a&&(g(!1),d==null||d(!1));const me=Math.max(a,Math.min(f,he));y(me),u==null||u(me)},onEnd:()=>{C.current=!1,K(!1)}})},[x,D,s,m,i,M,a,n,S,u,d,b,j]),c=r.useCallback($=>{$.button!==0&&$.pointerType==="mouse"||($.preventDefault(),$.stopPropagation(),w($.clientX,$.clientY,$.pointerId,$.currentTarget))},[w]),k=r.useCallback($=>{if(($.key==="Enter"||$.key===" ")&&i){$.preventDefault(),I();return}if($.key==="Home"){$.preventDefault(),x&&(g(!1),d==null||d(!1)),H(a);return}if($.key==="End"){$.preventDefault(),x&&(g(!1),d==null||d(!1));const E=S();Number.isFinite(E)&&H(E);return}let O=0;s==="horizontal"?($.key==="ArrowLeft"&&(O=-T),$.key==="ArrowRight"&&(O=T)):($.key==="ArrowUp"&&(O=-T),$.key==="ArrowDown"&&(O=T)),O!==0&&($.preventDefault(),m&&(O=-O),x&&(g(!1),d==null||d(!1)),H((x?a:D)+O))},[x,i,s,S,T,a,d,m,H,D,I]),P=["ide-sash",s==="horizontal"?"ide-sash-vertical":"ide-sash-horizontal",F?"dragging":""].filter(Boolean).join(" "),U=S(),Q=Number.isFinite(U)?U:Math.max(a,D);return{size:x?0:D,collapsed:x,sashProps:{onPointerDown:c,onDoubleClick:I,onKeyDown:k,className:P,role:"separator",tabIndex:0,"aria-label":v,"aria-orientation":s==="horizontal"?"vertical":"horizontal","aria-valuemin":i?0:a,"aria-valuemax":Math.round(Q),"aria-valuenow":Math.round(x?0:D)},containerRef:N,setSize:H,toggleCollapse:I,dragging:F}}function ln(t){return[...t].sort((s,n)=>s.type==="directory"&&n.type!=="directory"?-1:s.type!=="directory"&&n.type==="directory"?1:s.name.localeCompare(n.name,void 0,{numeric:!0,sensitivity:"base"}))}function Nt({filePath:t,rootPath:s,onSegmentClick:n,onOpenFile:a}){const i=(t.startsWith(s)?t.slice(s.length).replace(/^\//,""):t).split("/").filter(Boolean),[o,h]=r.useState(null),[u,d]=r.useState([]),[b,j]=r.useState(!1),[m,v]=r.useState(-1),T=r.useRef(null),D=r.useRef(null),y=r.useCallback(async(C,N)=>{const L=N.getBoundingClientRect();h({dirPath:C,anchorRect:L}),j(!0),d([]),v(-1);try{const M=await Ht(C);d(ln(M.map(S=>({name:S.name,path:S.path,type:S.type}))))}catch{d([])}j(!1)},[]),x=r.useCallback(()=>{h(null),d([]),v(-1)},[]),g=r.useCallback(C=>{C.type==="directory"?(n(C.path),x()):(a(C.path),x())},[n,a,x]);r.useEffect(()=>{if(!o)return;const C=N=>{if(N.key==="Escape"){N.preventDefault(),x();return}N.key==="ArrowDown"?(N.preventDefault(),v(L=>L<u.length-1?L+1:0)):N.key==="ArrowUp"?(N.preventDefault(),v(L=>L>0?L-1:u.length-1)):N.key==="Enter"&&m>=0&&m<u.length&&(N.preventDefault(),g(u[m]))};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[o,u,m,x,g]),r.useEffect(()=>{var C;m>=0&&D.current&&((C=D.current.querySelectorAll(".breadcrumb-dropdown-item")[m])==null||C.scrollIntoView({block:"nearest"}))},[m]);const F=r.useCallback((C,N)=>{C.stopPropagation();const L=C.currentTarget;o&&o.dirPath===N?x():y(N,L)},[o,y,x]),K=r.useCallback((C,N)=>{C.stopPropagation();const L=C.currentTarget;o&&o.dirPath===N?x():y(N,L)},[o,y,x]);return e.jsxs("div",{className:"editor-breadcrumbs",children:[e.jsx("span",{style:{display:"inline-flex",alignItems:"center"},children:e.jsx("span",{className:`editor-breadcrumb-segment ${i.length===0?"active":""}`,onClick:C=>F(C,s),children:e.jsx("span",{children:s.split("/").pop()||s})})}),i.map((C,N)=>{const L=N===i.length-1,M=s+"/"+i.slice(0,N+1).join("/"),S=N===0?s:s+"/"+i.slice(0,N).join("/");return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center"},children:[e.jsx("span",{className:"editor-breadcrumb-separator",children:e.jsx(oe,{size:10})}),e.jsxs("span",{className:`editor-breadcrumb-segment ${L?"active":""} ${(o==null?void 0:o.dirPath)===(L?S:M)?"dropdown-open":""}`,onClick:H=>L?K(H,S):F(H,M),children:[L&&e.jsx(we,{name:C,type:"file",size:14}),e.jsx("span",{style:L?{fontWeight:500}:void 0,children:C})]})]},M)}),o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"breadcrumb-dropdown-overlay",onClick:x}),e.jsx("div",{ref:T,className:"breadcrumb-dropdown",style:{left:Math.min(o.anchorRect.left,window.innerWidth-260),top:o.anchorRect.bottom+2},children:b?e.jsx("div",{className:"breadcrumb-dropdown-loading",children:e.jsx(ke,{size:14,className:"animate-spin"})}):u.length===0?e.jsx("div",{className:"breadcrumb-dropdown-empty",children:"Empty"}):e.jsx("div",{className:"breadcrumb-dropdown-list",ref:D,children:u.map((C,N)=>{const L=C.path===t,M=N===m;return e.jsxs("div",{className:`breadcrumb-dropdown-item ${L?"current":""} ${M?"highlighted":""}`,onClick:()=>g(C),children:[C.type==="directory"?e.jsx(oe,{size:12,style:{flexShrink:0,opacity:.5}}):e.jsx(we,{name:C.name,type:C.type,size:16}),e.jsx("span",{className:"breadcrumb-dropdown-item-name",children:C.name})]},C.path)})})})]})]})}function on(t,s){const n=t.toLowerCase(),a=s.toLowerCase();let l=0,i=0,o=-1;for(let h=0;h<a.length&&l<n.length;h++)a[h]===n[l]&&(i+=h===o+1?2:1,(h===0||a[h-1]==="/"||a[h-1]===".")&&(i+=3),o=h,l++);return{match:l===n.length,score:i}}const St=20,cn=3;function hs({isOpen:t,onClose:s,onSelect:n,rootPath:a,showHiddenFiles:l}){const{t:i}=te(),[o,h]=r.useState(""),[u,d]=r.useState(0),[b,j]=r.useState([]),[m,v]=r.useState(!1),T=r.useRef(null),D=r.useRef(null),y=r.useRef(null),x=r.useId(),g=r.useRef(""),F=r.useRef([]),K=r.useCallback(async(M,S,H)=>{if(S>cn)return[];try{const I=await Ht(M),w=[];for(const c of I){if(!l&&Ks(c.name))continue;const k=H?`${H}/${c.name}`:c.name;if(c.type==="file"&&!Us(c.path))w.push({name:c.name,path:c.path,relativePath:k});else if(c.type==="directory"){const P=await K(c.path,S+1,k);w.push(...P)}}return w}catch{return[]}},[l]);r.useEffect(()=>{if(!t)return;h(""),d(0),y.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const M=window.setTimeout(()=>{var I;return(I=T.current)==null?void 0:I.focus()},0),S=`${a}\0${l?"hidden":"visible"}`;if(g.current===S&&F.current.length>0)return j(F.current),v(!1),()=>{var I;window.clearTimeout(M),(I=y.current)==null||I.focus(),y.current=null};let H=!1;return v(!0),K(a,0,"").then(I=>{H||(g.current=S,F.current=I,j(I),v(!1))}),()=>{var I;H=!0,window.clearTimeout(M),(I=y.current)==null||I.focus(),y.current=null}},[t,a,l,K]);const C=r.useMemo(()=>{if(!o.trim())return b.slice(0,St);const M=[];for(const S of b){const H=on(o,S.relativePath);H.match&&M.push({entry:S,score:H.score})}return M.sort((S,H)=>H.score-S.score),M.slice(0,St).map(S=>S.entry)},[b,o]);r.useEffect(()=>{d(0)},[C.length,o]);const N=r.useCallback(M=>{var S;switch(M.key){case"Tab":M.preventDefault(),(S=T.current)==null||S.focus();break;case"ArrowDown":M.preventDefault(),d(H=>(H+1)%Math.max(C.length,1));break;case"ArrowUp":M.preventDefault(),d(H=>(H-1+C.length)%Math.max(C.length,1));break;case"Enter":M.preventDefault(),C[u]&&n(C[u].path);break;case"Escape":M.preventDefault(),s();break}},[C,u,n,s]);if(r.useEffect(()=>{var S;const M=(S=D.current)==null?void 0:S.children[u];M==null||M.scrollIntoView({block:"nearest"})},[u]),!t)return null;const L=C[u]?`${x}-option-${u}`:void 0;return e.jsx("div",{className:"quick-open-overlay",onClick:s,children:e.jsxs("div",{className:"quick-open-dialog",role:"dialog","aria-modal":"true","aria-label":i("editor.quickOpen"),onClick:M=>M.stopPropagation(),onKeyDown:N,children:[e.jsx("input",{ref:T,className:"quick-open-input",type:"text",role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":x,"aria-activedescendant":L,value:o,onChange:M=>h(M.target.value),placeholder:i("editor.quickOpenPlaceholder")}),e.jsx("div",{className:"quick-open-list",ref:D,id:x,role:"listbox","aria-busy":m,children:m?e.jsx("div",{className:"quick-open-empty",role:"status",children:i("editor.quickOpenLoading")}):C.length===0?e.jsx("div",{className:"quick-open-empty",role:"status",children:i("editor.quickOpenEmpty")}):C.map((M,S)=>e.jsxs("div",{id:`${x}-option-${S}`,role:"option","aria-selected":S===u,className:`quick-open-item${S===u?" active":""}`,onClick:()=>n(M.path),onMouseEnter:()=>d(S),children:[e.jsx(we,{name:M.name,type:"file",size:14}),e.jsx("span",{className:"quick-open-item-name",children:M.name}),e.jsx("span",{className:"quick-open-item-path",children:M.relativePath})]},M.path))})]})})}function dn({gitFileCount:t=0}){const{t:s}=te(),n=re(b=>b.activePanel),a=re(b=>b.sidePanelCollapsed),l=re(b=>b.toggleActivePanel),i=re(b=>b.bottomPanelCollapsed),o=re(b=>b.toggleBottomPanel),h=bt(b=>b.isOpen),u=bt(b=>b.toggle),d=r.useCallback(b=>n===b&&!a,[n,a]);return e.jsxs("div",{className:"ide-activity-bar",children:[e.jsxs("div",{className:"ide-activity-bar-top",children:[e.jsx("button",{type:"button",className:`ide-activity-btn ide-activity-btn--nav ${d("explorer")?"active":""}`,onClick:()=>l("explorer"),title:s("ide.explorer"),"aria-label":s("ide.explorer"),"aria-pressed":d("explorer"),children:e.jsx(Ut,{size:22,strokeWidth:1.5})}),e.jsx("button",{type:"button",className:`ide-activity-btn ide-activity-btn--nav ${d("search")?"active":""}`,onClick:()=>l("search"),title:s("ide.search"),"aria-label":s("ide.search"),"aria-pressed":d("search"),children:e.jsx(ft,{size:22,strokeWidth:1.5})}),e.jsxs("button",{type:"button",className:`ide-activity-btn ide-activity-btn--nav ${d("source-control")?"active":""}`,onClick:()=>l("source-control"),title:s("ide.sourceControl"),"aria-label":s("ide.sourceControl"),"aria-pressed":d("source-control"),children:[e.jsx(Ee,{size:22,strokeWidth:1.5}),t>0&&e.jsx("span",{className:"ide-activity-badge",children:t>99?"99+":t})]})]}),e.jsxs("div",{className:"ide-activity-bar-bottom",children:[e.jsx("button",{type:"button",className:`ide-activity-btn ide-activity-btn--utility ${i?"":"active"}`,onClick:o,title:s("ide.terminal"),"aria-label":s("ide.terminal"),"aria-pressed":!i,children:e.jsx(Pa,{size:22,strokeWidth:1.5})}),e.jsx("button",{type:"button",className:`ide-activity-btn ide-activity-btn--utility ${h?"active":""}`,onClick:u,title:s("sidebar.toggle"),"aria-label":s("sidebar.toggle"),"aria-pressed":h,children:e.jsx(Gs,{size:22,strokeWidth:1.5})})]})]})}function un(){try{const t=localStorage.getItem("cbc_search_prefs");if(t)return{...Pt,...JSON.parse(t)}}catch{}return Pt}const Pt={viewMode:"tree",caseSensitive:!1,isRegex:!1,wholeWord:!1,query:"",includePattern:"",excludePattern:"",useDefaultExcludes:!0};function ve(t){try{localStorage.setItem("cbc_search_prefs",JSON.stringify(t))}catch{}}function ye(t){return{viewMode:t.viewMode,caseSensitive:t.caseSensitive,isRegex:t.isRegex,wholeWord:t.wholeWord,query:t.query,includePattern:t.includePattern,excludePattern:t.excludePattern,useDefaultExcludes:t.useDefaultExcludes}}const Ne=un(),hn=$t((t,s)=>({query:Ne.query,isRegex:Ne.isRegex,caseSensitive:Ne.caseSensitive,wholeWord:Ne.wholeWord,includePattern:Ne.includePattern,excludePattern:Ne.excludePattern,useDefaultExcludes:Ne.useDefaultExcludes,viewMode:Ne.viewMode,results:[],searching:!1,totalMatches:0,fileCount:0,error:null,setQuery:n=>{t({query:n}),ve(ye({...s(),query:n}))},search:async()=>{var j;const{query:n,isRegex:a,caseSensitive:l,wholeWord:i,includePattern:o,excludePattern:h,useDefaultExcludes:u}=s();if(!n.trim())return;const d=dt();let b=h||void 0;if(u){const m="node_modules,**/.git,**/dist,**/build,**/.next,**/coverage";b=b?`${b},${m}`:m}t({searching:!0,error:null,results:[],totalMatches:0,fileCount:0});try{const m=await fetch("/api/v1/fs/search-content",{method:"POST",headers:{...Ke(),"Content-Type":"application/json"},body:JSON.stringify({query:n.trim(),cwd:d||void 0,isRegex:a,caseSensitive:l,wholeWord:i,includeGlob:o||void 0,excludeGlob:b,maxResults:200})});if(m.ok){const v=await m.json(),D=(v.data??v).results||[],y=new Map;for(const g of D)y.has(g.path)||y.set(g.path,[]),y.get(g.path).push(g);const x=[];for(const[g,F]of y)x.push({path:g,matches:F});t({results:x,totalMatches:D.length,fileCount:x.length,searching:!1})}else{const v=await m.json().catch(()=>null),T=((j=v==null?void 0:v.error)==null?void 0:j.message)||`HTTP ${m.status}`;t({searching:!1,error:T})}}catch(m){t({searching:!1,error:m.message||"Search failed"})}},toggleRegex:()=>{t(n=>({isRegex:!n.isRegex})),ve(ye(s()))},toggleCaseSensitive:()=>{t(n=>({caseSensitive:!n.caseSensitive})),ve(ye(s()))},toggleWholeWord:()=>{t(n=>({wholeWord:!n.wholeWord})),ve(ye(s()))},setIncludePattern:n=>{t({includePattern:n}),ve(ye({...s(),includePattern:n}))},setExcludePattern:n=>{t({excludePattern:n}),ve(ye({...s(),excludePattern:n}))},toggleUseDefaultExcludes:()=>{t(n=>({useDefaultExcludes:!n.useDefaultExcludes})),ve(ye(s()))},setViewMode:n=>{t({viewMode:n}),ve(ye(s()))},clear:()=>{t({query:"",includePattern:"",excludePattern:"",results:[],totalMatches:0,fileCount:0,searching:!1,error:null}),ve(ye(s()))}}));function fn(t){const s={children:[]};for(const a of t){const l=a.path.split("/");let i=s;for(let o=0;o<l.length;o++){const h=l[o];if(o===l.length-1)i.children.push({name:h,fullPath:a.path,isDir:!1,children:[],matches:a.matches,matchCount:a.matches.length});else{let d=i.children.find(b=>b.isDir&&b.name===h);d||(d={name:h,fullPath:l.slice(0,o+1).join("/"),isDir:!0,children:[],matchCount:0},i.children.push(d)),i=d}}}function n(a){if(a.isDir&&a.children.length===1&&a.children[0].isDir){const o=a.children[0];return n({...o,name:`${a.name}/${o.name}`})}const l=a.children.map(n),i=l.reduce((o,h)=>o+h.matchCount,0);return{...a,children:l,matchCount:a.isDir?i:a.matchCount}}return s.children.map(n)}function fs(){const{t}=te(),{query:s,isRegex:n,caseSensitive:a,wholeWord:l,includePattern:i,excludePattern:o,useDefaultExcludes:h,viewMode:u,results:d,searching:b,totalMatches:j,fileCount:m,error:v,setQuery:T,search:D,toggleRegex:y,toggleCaseSensitive:x,toggleWholeWord:g,setIncludePattern:F,setExcludePattern:K,toggleUseDefaultExcludes:C,setViewMode:N}=hn(),{openFile:L}=ae(),M=r.useRef(null),[S,H]=r.useState(new Set),[I,w]=r.useState(!0);r.useEffect(()=>{var E;(E=M.current)==null||E.focus()},[]);const c=r.useCallback(()=>{const E=new Set;for(const X of d){E.add(X.path);const G=X.path.split("/");for(let A=1;A<G.length;A++)E.add(G.slice(0,A).join("/"))}return E},[d]);r.useEffect(()=>{H(c()),w(!0)},[c]);const k=r.useMemo(()=>fn(d),[d]),P=r.useCallback(E=>{E.key==="Enter"&&(E.preventDefault(),D())},[D]),U=r.useCallback(E=>{H(X=>{const G=new Set(X);return G.has(E)?G.delete(E):G.add(E),G})},[]),Q=r.useCallback(()=>{H(new Set),w(!1)},[]),$=r.useCallback(()=>{H(c()),w(!0)},[c]),O=r.useCallback((E,X)=>{const G=X?{line:X,query:s.trim()}:void 0;L(E,void 0,G)},[L,s]);return e.jsxs("div",{className:"search-panel",children:[e.jsx("div",{className:"scm-header",children:e.jsx("span",{className:"scm-header-title",children:t("ide.search.title")})}),e.jsxs("div",{className:"search-input-section",children:[e.jsxs("div",{className:"search-field",children:[e.jsx("input",{ref:M,className:"search-field-input",value:s,onChange:E=>T(E.target.value),onKeyDown:P,placeholder:t("ide.search.placeholder")}),e.jsxs("div",{className:"search-field-actions",children:[e.jsx("button",{className:`search-field-btn ${a?"active":""}`,onClick:x,title:t("ide.search.matchCase"),children:e.jsx(fa,{size:14})}),e.jsx("button",{className:`search-field-btn ${l?"active":""}`,onClick:g,title:t("ide.search.wholeWord"),children:e.jsx(La,{size:14})}),e.jsx("button",{className:`search-field-btn ${n?"active":""}`,onClick:y,title:t("ide.search.regex"),children:e.jsx(Ma,{size:14})})]})]}),e.jsxs("div",{className:"search-filter-section",children:[e.jsx("span",{className:"search-filter-label",children:t("ide.search.filesToInclude")}),e.jsx("div",{className:"search-field",children:e.jsx("input",{className:"search-field-input",value:i,onChange:E=>F(E.target.value),onKeyDown:P,placeholder:t("ide.search.includePlaceholder")||"e.g. *.ts, src/**/include"})})]}),e.jsxs("div",{className:"search-filter-section",children:[e.jsx("span",{className:"search-filter-label",children:t("ide.search.filesToExclude")}),e.jsxs("div",{className:"search-field",children:[e.jsx("input",{className:"search-field-input",value:o,onChange:E=>K(E.target.value),onKeyDown:P,placeholder:t("ide.search.excludePlaceholder")||"e.g. node_modules, *.min.js"}),e.jsx("div",{className:"search-field-actions",children:e.jsx("button",{className:`search-field-btn ${h?"active":""}`,onClick:C,title:t("ide.search.useExcludeSettings"),children:e.jsx(Qs,{size:14})})})]})]})]}),(b||j>0||v)&&e.jsxs("div",{className:"search-status-bar",children:[b&&e.jsxs("div",{className:"search-status",children:[e.jsx(ke,{size:14,className:"animate-spin"}),e.jsx("span",{children:t("ide.search.searching")})]}),!b&&j>0&&e.jsx("div",{className:"search-status",children:e.jsx("span",{children:t("ide.search.results",{count:j,files:m})})}),v&&e.jsx("div",{className:"search-status search-error",children:v.includes("timed out")?t("ide.search.timedOut"):t("ide.search.failed")}),j>0&&e.jsxs("div",{className:"search-status-actions",children:[e.jsx("button",{className:`scm-icon-btn ${u==="list"?"active":""}`,onClick:()=>N("list"),title:t("ide.listView"),children:e.jsx(Gt,{size:14})}),e.jsx("button",{className:`scm-icon-btn ${u==="tree"?"active":""}`,onClick:()=>N("tree"),title:t("ide.treeView"),children:e.jsx(Qt,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:I?Q:$,title:t(I?"editor.collapseAll":"editor.expandAll"),children:I?e.jsx(ka,{size:14}):e.jsx(Ta,{size:14})})]})]}),e.jsxs("div",{className:"search-results",children:[u==="tree"&&k.map(E=>e.jsx(ms,{node:E,depth:0,expandedPaths:S,onToggle:U,onFileClick:O,query:s},E.fullPath)),u==="list"&&d.map(E=>e.jsxs("div",{className:"search-tree-group",children:[e.jsxs("div",{className:"search-tree-file",style:{paddingLeft:"4px"},onClick:()=>U(E.path),children:[S.has(E.path)?e.jsx(pe,{size:14}):e.jsx(oe,{size:14}),e.jsx(we,{name:E.path.split("/").pop()||"",type:"file",size:14}),e.jsx("span",{className:"search-tree-name",children:E.path.split("/").pop()}),e.jsx("span",{className:"search-list-filepath",children:E.path}),e.jsx("span",{className:"search-tree-badge",children:E.matches.length})]}),S.has(E.path)&&e.jsx("div",{className:"search-tree-matches",children:E.matches.map((X,G)=>e.jsx("div",{className:"search-tree-match",style:{paddingLeft:"24px"},onClick:()=>O(E.path,X.line),children:e.jsx(ps,{text:X.text,query:s})},G))})]},E.path)),!b&&s&&j===0&&!v&&e.jsxs("div",{className:"scm-empty",children:[e.jsx(ft,{size:20,strokeWidth:1.5,style:{opacity:.3}}),e.jsx("span",{children:t("ide.search.noResults")})]})]})]})}function ms({node:t,depth:s,expandedPaths:n,onToggle:a,onFileClick:l,query:i}){const o=n.has(t.fullPath),h=s*14;if(t.isDir)return e.jsxs("div",{className:"search-tree-group",children:[e.jsxs("div",{className:"search-tree-dir",style:{paddingLeft:`${h+4}px`},onClick:()=>a(t.fullPath),children:[o?e.jsx(pe,{size:14}):e.jsx(oe,{size:14}),e.jsx(qt,{size:14,className:"scm-tree-folder-icon"}),e.jsx("span",{className:"search-tree-name",children:t.name}),e.jsx("span",{className:"search-tree-badge",children:t.matchCount})]}),o&&t.children.map(d=>e.jsx(ms,{node:d,depth:s+1,expandedPaths:n,onToggle:a,onFileClick:l,query:i},d.fullPath))]});const u=t.name;return e.jsxs("div",{className:"search-tree-group",children:[e.jsxs("div",{className:"search-tree-file",style:{paddingLeft:`${h+4}px`},onClick:()=>a(t.fullPath),children:[o?e.jsx(pe,{size:14}):e.jsx(oe,{size:14}),e.jsx(we,{name:u,type:"file",size:14}),e.jsx("span",{className:"search-tree-name",children:u}),e.jsx("span",{className:"search-tree-badge",children:t.matchCount})]}),o&&t.matches&&e.jsx("div",{className:"search-tree-matches",children:t.matches.map((d,b)=>e.jsx("div",{className:"search-tree-match",style:{paddingLeft:`${h+24}px`},onClick:()=>l(t.fullPath,d.line),children:e.jsx(ps,{text:d.text,query:i})},b))})]})}function ps({text:t,query:s}){if(!s)return e.jsx("span",{className:"search-match-text",children:t});const n=[],a=t.toLowerCase(),l=s.toLowerCase();let i=0,o=a.indexOf(l),h=0;for(;o!==-1&&h<10;)o>i&&n.push(e.jsx("span",{children:t.slice(i,o)},h++)),n.push(e.jsx("span",{className:"search-highlight",children:t.slice(o,o+s.length)},h++)),i=o+s.length,o=a.indexOf(l,i);return i<t.length&&n.push(e.jsx("span",{children:t.slice(i)},h++)),e.jsx("span",{className:"search-match-text",children:n})}function mn(t,s){const n={children:[]};for(const a of t){const l=s(a).split("/");let i=n;for(let o=0;o<l.length;o++){const h=l[o],u=o===l.length-1,d=l.slice(0,o+1).join("/");if(u)i.children.push({name:h,path:d,isDir:!1,children:[],data:a});else{let b=i.children.find(j=>j.isDir&&j.name===h);b||(b={name:h,path:d,isDir:!0,children:[]},i.children.push(b)),i=b}}}return n.children.map(it)}function it(t){if(t.isDir&&t.children.length===1&&t.children[0].isDir){const s=t.children[0];return it({...s,name:`${t.name}/${s.name}`})}return{...t,children:t.children.map(it)}}const xs={modified:{label:"M",color:"var(--color-accent-yellow)"},added:{label:"A",color:"var(--color-accent-green)"},deleted:{label:"D",color:"var(--color-accent-red)"},renamed:{label:"R",color:"var(--color-accent-blue)"},copied:{label:"C",color:"var(--color-accent-blue)"},untracked:{label:"U",color:"var(--color-accent-green)"},conflicted:{label:"!",color:"var(--color-accent-red)"}};function gs({file:t,onStage:s,onUnstage:n,onDiscard:a,onOpenFile:l}){const{t:i}=te(),o=r.useCallback(h=>{h.stopPropagation(),ze(t.path)},[t.path]);return e.jsxs("div",{className:"scm-file-actions",children:[e.jsx("button",{className:"scm-file-action-btn",onClick:o,title:i("ide.scm.copyPath"),children:e.jsx(Xs,{size:13})}),l&&t.status!=="deleted"&&e.jsx("button",{className:"scm-file-action-btn",onClick:h=>{h.stopPropagation(),l(t.path)},title:i("ide.scm.openFile"),children:e.jsx(Kt,{size:13})}),a&&e.jsx("button",{className:"scm-file-action-btn",onClick:h=>{h.stopPropagation(),a(t.path)},title:i("ide.scm.discard"),children:e.jsx(mt,{size:13})}),s&&e.jsx("button",{className:"scm-file-action-btn",onClick:h=>{h.stopPropagation(),s(t.path)},title:i("ide.scm.stage"),children:e.jsx(Se,{size:13})}),n&&e.jsx("button",{className:"scm-file-action-btn",onClick:h=>{h.stopPropagation(),n(t.path)},title:i("ide.scm.unstage"),children:e.jsx(Ue,{size:13})})]})}function pn({files:t,sectionTitle:s,sectionCount:n,sectionActions:a,onStage:l,onUnstage:i,onDiscard:o,onSelect:h,onOpenFile:u}){const[d,b]=r.useState(!0);return e.jsxs("div",{className:"scm-file-list",children:[s&&e.jsxs("div",{className:"scm-tree-section-root",onClick:()=>b(j=>!j),children:[d?e.jsx(pe,{size:14}):e.jsx(oe,{size:14}),e.jsx("span",{className:"scm-tree-section-title",children:s}),n!==void 0&&e.jsx("span",{className:"scm-section-count",children:n}),a&&e.jsx("div",{className:"scm-file-actions",children:a})]}),(!s||d)&&t.map(j=>{const m=xs[j.status]||{label:"?",color:"var(--color-text-tertiary)"},v=j.path.split("/").pop()||j.path,T=j.path.includes("/")?j.path.substring(0,j.path.lastIndexOf("/")):"";return e.jsxs("div",{className:"scm-file-item",onClick:()=>h==null?void 0:h(j.path),children:[e.jsx(we,{name:v,type:"file",size:16}),e.jsx("span",{className:"scm-file-name-text",children:v}),T&&e.jsx("span",{className:"scm-file-path-desc",children:T}),e.jsx(gs,{file:j,onStage:l,onUnstage:i,onDiscard:o,onOpenFile:u}),e.jsx("span",{className:"scm-file-status",style:{color:m.color},children:m.label})]},`${j.path}-${j.staged}`)})]})}function lt({node:t,depth:s,onStage:n,onUnstage:a,onDiscard:l,onSelect:i,onOpenFile:o}){const{t:h}=te(),[u,d]=r.useState(!0);function b(x){if(!x.isDir)return null;const g=ct(x);return g.length===0?null:g.some(F=>F.status==="modified")?"var(--color-accent-yellow)":g.some(F=>F.status==="untracked"||F.status==="added")?"var(--color-accent-green)":"var(--color-text-tertiary)"}const j=b(t),m=ct(t),v=r.useCallback(x=>{x.stopPropagation(),n&&m.forEach(g=>n(g.path))},[n,m]),T=r.useCallback(x=>{x.stopPropagation(),l&&m.forEach(g=>l(g.path))},[l,m]),D=r.useCallback(x=>{x.stopPropagation(),a&&m.forEach(g=>a(g.path))},[a,m]),y=s*16+4;return e.jsxs("div",{className:"scm-tree-group",children:[e.jsxs("div",{className:"scm-tree-dir",style:{paddingLeft:`${y}px`},onClick:()=>d(x=>!x),children:[Array.from({length:s},(x,g)=>e.jsx("span",{className:"scm-tree-indent-guide",style:{left:`${g*16+12}px`}},g)),u?e.jsx(pe,{size:14}):e.jsx(oe,{size:14}),e.jsx(qt,{size:14,className:"scm-tree-folder-icon"}),e.jsx("span",{className:"scm-tree-dir-name",children:t.name}),e.jsxs("div",{className:"scm-file-actions",children:[l&&e.jsx("button",{className:"scm-file-action-btn",onClick:T,title:h("ide.scm.discardAll"),children:e.jsx(mt,{size:13})}),n&&e.jsx("button",{className:"scm-file-action-btn",onClick:v,title:h("ide.scm.stageAll"),children:e.jsx(Se,{size:13})}),a&&e.jsx("button",{className:"scm-file-action-btn",onClick:D,title:h("ide.scm.unstageAll"),children:e.jsx(Ue,{size:13})})]}),j&&e.jsx("span",{className:"scm-tree-dir-dot",style:{background:j}})]}),u&&t.children.map(x=>x.isDir?e.jsx(lt,{node:x,depth:s+1,onStage:n,onUnstage:a,onDiscard:l,onSelect:i,onOpenFile:o},x.path):e.jsx(ot,{node:x,depth:s+1,onStage:n,onUnstage:a,onDiscard:l,onSelect:i,onOpenFile:o},x.path))]})}function ot({node:t,depth:s,onStage:n,onUnstage:a,onDiscard:l,onSelect:i,onOpenFile:o}){const h=t.data,u=xs[h.status]||{label:"?",color:"var(--color-text-tertiary)"};return e.jsxs("div",{className:"scm-file-item",style:{paddingLeft:`${s*16+20}px`},onClick:()=>i==null?void 0:i(h.path),children:[Array.from({length:s},(d,b)=>e.jsx("span",{className:"scm-tree-indent-guide",style:{left:`${b*16+12}px`}},b)),e.jsx(we,{name:t.name,type:"file",size:16}),e.jsx("span",{className:"scm-file-name-text",children:t.name}),e.jsx(gs,{file:h,onStage:n,onUnstage:a,onDiscard:l,onOpenFile:o}),e.jsx("span",{className:"scm-file-status",style:{color:u.color},children:u.label})]})}function ct(t){return t.isDir?t.children.flatMap(ct):t.data?[t.data]:[]}function xn({files:t,sectionTitle:s,sectionCount:n,sectionActions:a,onStage:l,onUnstage:i,onDiscard:o,onSelect:h,onOpenFile:u}){const[d,b]=r.useState(!0),j=mn(t,m=>m.path);return s?e.jsxs("div",{className:"scm-file-list scm-tree-view",children:[e.jsxs("div",{className:"scm-tree-section-root",onClick:()=>b(m=>!m),children:[d?e.jsx(pe,{size:14}):e.jsx(oe,{size:14}),e.jsx("span",{className:"scm-tree-section-title",children:s}),n!==void 0&&e.jsx("span",{className:"scm-section-count",children:n}),a&&e.jsx("div",{className:"scm-file-actions",children:a})]}),d&&j.map(m=>m.isDir?e.jsx(lt,{node:m,depth:1,onStage:l,onUnstage:i,onDiscard:o,onSelect:h,onOpenFile:u},m.path):e.jsx(ot,{node:m,depth:1,onStage:l,onUnstage:i,onDiscard:o,onSelect:h,onOpenFile:u},m.path))]}):e.jsx("div",{className:"scm-file-list scm-tree-view",children:j.map(m=>m.isDir?e.jsx(lt,{node:m,depth:0,onStage:l,onUnstage:i,onDiscard:o,onSelect:h,onOpenFile:u},m.path):e.jsx(ot,{node:m,depth:0,onStage:l,onUnstage:i,onDiscard:o,onSelect:h,onOpenFile:u},m.path))})}function Dt(t){return t.viewMode==="tree"?e.jsx(xn,{...t}):e.jsx(pn,{...t})}const Mt=["var(--color-accent-green)","var(--color-accent-blue)","var(--color-accent-yellow)","var(--color-accent-purple)","var(--color-accent-red)"];function gn(t){try{const s=new Date(t),a=new Date().getTime()-s.getTime(),l=Math.floor(a/6e4);if(l<60)return`${l}m ago`;const i=Math.floor(l/60);if(i<24)return`${i}h ago`;const o=Math.floor(i/24);return o<7?`${o}d ago`:s.toLocaleDateString()}catch{return t}}function bn(){const{t}=te(),[s,n]=r.useState(!1),[a,l]=r.useState([]),[i,o]=r.useState(!1),h=r.useCallback(async()=>{o(!0);try{const u=await Va(30);l(u)}catch{}o(!1)},[]);return r.useEffect(()=>{s&&a.length===0&&!i&&h()},[s,a.length,i,h]),e.jsxs("div",{className:"scm-graph",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>n(u=>!u),children:[s?e.jsx(pe,{size:14}):e.jsx(oe,{size:14}),e.jsx("span",{children:t("ide.scm.graph")}),s&&e.jsx("button",{className:"scm-icon-btn",onClick:u=>{u.stopPropagation(),h()},title:t("ide.refresh"),children:e.jsx(Ie,{size:12,className:i?"animate-spin":""})})]}),s&&e.jsxs("div",{className:"scm-graph-list",children:[i&&a.length===0&&e.jsx("div",{className:"scm-graph-loading",children:e.jsx(ke,{size:14,className:"animate-spin"})}),a.map((u,d)=>e.jsxs("div",{className:"scm-graph-entry",title:`${u.hash}
|
|
74
|
+
${u.author}
|
|
75
|
+
${u.date}`,children:[e.jsx("span",{className:"scm-graph-dot",style:{background:Mt[d%Mt.length]}}),e.jsx("span",{className:"scm-graph-msg",children:u.message}),e.jsx("span",{className:"scm-graph-time",children:gn(u.date)})]},u.hash))]})]})}function bs(){const{t}=te(),{isGitRepo:s,loading:n,files:a,currentBranch:l,ahead:i,behind:o,pushing:h,pulling:u,repositoryOperationInProgress:d,branches:b,branchesLoading:j,operationFeedback:m,refresh:v,loadBranches:T,stageFile:D,unstageFile:y,stageAll:x,unstageAll:g,discardFile:F,discardAll:K,push:C,pull:N,switchBranch:L,createBranch:M,clearOperationMessage:S}=ge(),H=ae(f=>f.openFile),I=re(f=>f.scmViewMode),w=re(f=>f.setScmViewMode),[c,k]=r.useState(!0),[P,U]=r.useState(!0);r.useEffect(()=>{v(),ge.getState().startWatching()},[v]),r.useEffect(()=>{if(m!=null&&m.success){const f=setTimeout(S,3e3);return()=>clearTimeout(f)}},[m,S]);const Q=L,$=(m==null?void 0:m.operation)==="switchBranch"||(m==null?void 0:m.operation)==="createBranch",O=r.useCallback(()=>{if(m)switch(m.operation){case"switchBranch":m.target&&L(m.target);break;case"createBranch":m.target&&M(m.target);break;case"push":C();break;case"pull":N();break}},[m,L,M,C,N]),E=r.useCallback(async(f,B)=>{re.getState().bottomPanelMaximized&&re.setState({bottomPanelMaximized:!1});try{const q=await ts(f,B);ae.getState().openDiffTab(f,{oldText:q.oldText,newText:q.newText,staged:B})}catch{}},[]),X=H,G=a.filter(f=>f.staged),A=a.filter(f=>!f.staged);return s?e.jsxs("div",{className:"scm-panel",children:[e.jsxs("div",{className:"scm-header",children:[e.jsx("span",{className:"scm-header-title",children:t("ide.scm.title")}),e.jsxs("div",{className:"scm-header-actions",children:[e.jsx("button",{className:`scm-icon-btn ${I==="list"?"active":""}`,onClick:()=>w("list"),title:t("ide.listView"),children:e.jsx(Gt,{size:14})}),e.jsx("button",{className:`scm-icon-btn ${I==="tree"?"active":""}`,onClick:()=>w("tree"),title:t("ide.treeView"),children:e.jsx(Qt,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:()=>v(),disabled:n,title:t("ide.refresh"),children:e.jsx(Ie,{size:14,className:n?"animate-spin":""})})]})]}),e.jsxs("div",{className:"scm-scroll",children:[e.jsxs("div",{className:"scm-section",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>k(f=>!f),children:[c?e.jsx(pe,{size:14}):e.jsx(oe,{size:14}),e.jsx("span",{children:t("ide.scm.repositories")})]}),c&&e.jsx(as,{currentBranch:l,branches:b,branchesLoading:j,operationInProgress:d,onSwitch:Q,onCreate:M,onLoadBranches:T,actions:e.jsxs(e.Fragment,{children:[(i>0||o>0)&&e.jsxs("span",{className:"scm-branch-sync",children:[i>0&&e.jsxs("span",{children:["↑",i]}),o>0&&e.jsxs("span",{children:["↓",o]})]}),e.jsxs("div",{className:"scm-branch-actions",children:[e.jsx("button",{className:"scm-icon-btn",onClick:N,disabled:d,title:t("ide.scm.pull"),children:u?e.jsx(ke,{size:14,className:"animate-spin"}):e.jsx(Ys,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:C,disabled:d,title:t("ide.scm.push"),children:h?e.jsx(ke,{size:14,className:"animate-spin"}):e.jsx(Js,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:()=>v(),disabled:n,title:t("ide.refresh"),children:e.jsx(Ie,{size:12,className:n?"animate-spin":""})})]})]})}),m&&$&&e.jsx(zt,{feedback:m,onRetry:O,onClose:S})]}),e.jsxs("div",{className:"scm-section",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>U(f=>!f),children:[P?e.jsx(pe,{size:14}):e.jsx(oe,{size:14}),e.jsx("span",{children:t("ide.scm.changes")}),e.jsx("span",{className:"scm-section-count",children:a.length})]}),m&&!$&&e.jsx(zt,{feedback:m,onRetry:O,onClose:S}),P&&e.jsxs(e.Fragment,{children:[G.length>0&&e.jsx(Dt,{files:G,viewMode:I,sectionTitle:t("ide.scm.stagedChanges"),sectionCount:G.length,sectionActions:e.jsx("button",{className:"scm-file-action-btn",onClick:()=>g(),disabled:d,title:t("ide.scm.unstageAll"),children:e.jsx(Ue,{size:13})}),onUnstage:d?void 0:y,onSelect:f=>E(f,!0),onOpenFile:X}),A.length>0&&e.jsx(Dt,{files:A,viewMode:I,sectionTitle:t("ide.scm.changes"),sectionCount:A.length,sectionActions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"scm-file-action-btn",onClick:()=>K(),disabled:d,title:t("ide.scm.discardAll"),children:e.jsx(mt,{size:13})}),e.jsx("button",{className:"scm-file-action-btn",onClick:()=>x(),disabled:d,title:t("ide.scm.stageAll"),children:e.jsx(Se,{size:13})})]}),onStage:d?void 0:D,onDiscard:d?void 0:F,onSelect:f=>E(f,!1),onOpenFile:X}),a.length===0&&!n&&e.jsxs("div",{className:"scm-empty",children:[e.jsx(Ot,{size:20,strokeWidth:1.5,style:{opacity:.3}}),e.jsx("span",{children:t("ide.scm.noChanges")})]})]})]}),e.jsx(bn,{})]})]}):e.jsxs("div",{className:"scm-panel",children:[e.jsx("div",{className:"scm-header",children:e.jsx("span",{className:"scm-header-title",children:t("ide.scm.title")})}),e.jsxs("div",{className:"ide-panel-placeholder",children:[e.jsx(Ee,{size:32,strokeWidth:1,style:{opacity:.2}}),e.jsx("div",{className:"ide-panel-placeholder-text",children:t("ide.scm.notGitRepo")})]})]})}function zt({feedback:t,onRetry:s,onClose:n}){const{t:a}=te();let l,i=!t.success;if(t.success)switch(t.operation){case"switchBranch":l=a("ide.scm.feedback.switched",{name:t.target||""});break;case"createBranch":l=a("ide.scm.feedback.created",{name:t.target||""});break;case"push":l=a("ide.scm.feedback.pushed");break;case"pull":l=a("ide.scm.feedback.pulled");break;default:l=a("ide.scm.feedback.completed")}else{const o=pt(t.message,t.operation);l=a(o),i=ss(t.message,t.operation)}return e.jsxs("div",{className:`scm-operation-notice ${t.success?"success":"error"}`,role:t.success?"status":"alert",children:[e.jsx("div",{className:"scm-operation-notice-icon",children:t.success?e.jsx(Zs,{size:16}):e.jsx(Lt,{size:16})}),e.jsxs("div",{className:"scm-operation-notice-content",children:[e.jsx("strong",{children:t.success?a("ide.scm.feedback.success"):a("ide.scm.feedback.failed")}),e.jsx("span",{children:l}),!t.success&&t.message&&e.jsxs("details",{className:"scm-operation-details",children:[e.jsx("summary",{children:a("ide.scm.feedback.details")}),e.jsx("pre",{children:t.message})]}),!t.success&&i&&e.jsxs("button",{className:"scm-operation-retry",onClick:s,children:[e.jsx(ea,{size:12}),a("ide.scm.feedback.retry")]})]}),e.jsx("button",{className:"scm-operation-close",onClick:n,title:a("common.close"),children:e.jsx(ut,{size:14})})]})}function jn({activePanel:t,onMenuClick:s}){return e.jsxs("div",{className:"ide-side-panel-content",children:[t==="explorer"&&e.jsx(ds,{onMenuClick:s}),t==="search"&&e.jsx(fs,{}),t==="source-control"&&e.jsx(bs,{})]})}const vn=640;function yn({onMenuClick:t,activeTab:s,tabActions:n,cursorInfo:a,imageInfo:l,previewZoom:i,isMarkdownSource:o,quickOpenVisible:h,setQuickOpenVisible:u,onContentChange:d,onSave:b,onRequestClose:j,onCursorChange:m,onImageInfo:v,onZoomChange:T,hideActivityBar:D=!1}){const{t:y}=te(),x=r.useRef(null),[g,F]=r.useState(!1),[K,C]=r.useState("explorer"),{rootPath:N,openFile:L,revealInTree:M,loadTab:S,showHiddenFiles:H}=ae(),I=Vt(Y=>Y.tabs.find(ie=>ie.id===Y.activeId)??null),w=D&&(I==null?void 0:I.kind)==="editor"&&!I.filePath;r.useLayoutEffect(()=>{const Y=x.current;if(!D||!Y){F(!1);return}const ie=xe=>F(xe<=vn);ie(Y.getBoundingClientRect().width);const de=new ResizeObserver(xe=>{const De=xe[0];De&&ie(De.contentRect.width)});return de.observe(Y),()=>de.disconnect()},[D]);const{activePanel:c,sidePanelWidth:k,sidePanelCollapsed:P,setSidePanelWidth:U,setSidePanelCollapsed:Q,bottomPanelHeight:$,bottomPanelCollapsed:O,bottomPanelMaximized:E,setBottomPanelHeight:X,setBottomPanelCollapsed:G,toggleBottomPanel:A,toggleBottomPanelMaximize:f}=re(),B=Ct({direction:"horizontal",initialSize:k,minSize:160,maxSize:600,collapsible:!0,defaultCollapsed:P,onResize:U,onCollapse:Q,ariaLabel:y("ide.resizeSidePanel")}),q=Ct({direction:"vertical",initialSize:$,minSize:140,maxSize:typeof window<"u"?Math.max(300,window.innerHeight-80):500,collapsible:!0,defaultCollapsed:O,reverse:!0,onResize:X,onCollapse:G,onMaximize:f,maximizeThreshold:.85,ariaLabel:y("ide.resizeBottomPanel")}),z=ge(Y=>Y.files.length);r.useEffect(()=>(ge.getState().refresh(),ge.getState().startWatching(),()=>{ge.getState().stopWatching()}),[]);const J=typeof navigator<"u"&&navigator.platform.includes("Mac"),ue=()=>w?e.jsx(Et,{t:y}):s?s.loadStatus!=="ready"?e.jsx(es,{tab:s,onRetry:()=>S(s.id)}):s.viewMode==="diff"&&s.diffData?e.jsx("div",{className:"editor-container",children:e.jsx(ta,{path:s.path,oldText:s.diffData.oldText,newText:s.diffData.newText})}):s.viewMode==="editor"||o?e.jsx("div",{className:"editor-container",children:e.jsx(Zt,{path:s.path,content:s.content,language:s.language,onContentChange:d,onSave:b,minimap:!g,onCursorChange:m})}):e.jsx(ls,{path:s.path,name:s.name,content:s.content,viewMode:s.viewMode,onImageInfo:v,onZoomChange:T}):D?e.jsx(Et,{t:y}):e.jsx(kn,{isMac:J,t:y}),le=h&&N&&e.jsx(hs,{isOpen:h,onClose:()=>u(!1),onSelect:Y=>{L(Y),u(!1)},rootPath:N,showHiddenFiles:H}),Z=D?"explorer":c??"explorer";r.useEffect(()=>{!D||!g||C(w||!s?"explorer":"editor")},[s==null?void 0:s.path,g,I==null?void 0:I.id,w,D]);const ee=g&&K==="explorer",he=D?g?ee:!B.collapsed:!!(c&&!B.collapsed),me=!g||!ee,Pe=!q.collapsed,be=r.useRef(null);return r.useEffect(()=>{if(!D)return;const Y=(s==null?void 0:s.path)??(w?"__open__":null);!Y||be.current===Y||(be.current=Y,P&&Q(!1))},[s==null?void 0:s.path,w,D,Q,P]),e.jsxs("div",{className:"ide-layout",ref:x,children:[le,e.jsxs("div",{className:"ide-layout-row",ref:B.containerRef,children:[!D&&e.jsx(dn,{gitFileCount:z}),he&&e.jsxs("div",{className:"ide-side-panel",style:{width:g?"100%":B.size},children:[e.jsx(jn,{activePanel:Z,onMenuClick:t}),!g&&e.jsx("div",{...B.sashProps})]}),e.jsxs("div",{className:"ide-main-area",ref:q.containerRef,style:{display:me?"flex":"none"},children:[!E&&e.jsxs("div",{className:"ide-editor-area",style:{flex:Pe?void 0:1,height:Pe?`calc(100% - ${q.size}px)`:"100%"},children:[!D&&e.jsx(rs,{actions:n,onRequestClose:j}),D?e.jsxs("div",{className:"ide-dock-editor-tools",children:[g&&s&&!w&&e.jsx("button",{type:"button",className:"ide-dock-terminal-btn",onClick:()=>C("explorer"),title:y("dock.pickFromTree"),"aria-label":y("dock.pickFromTree"),children:e.jsx(ht,{size:14})}),w||!s||!N?e.jsx("span",{className:"ide-dock-editor-tools-spacer"}):e.jsx(Nt,{filePath:s.path,rootPath:N,onSegmentClick:M,onOpenFile:L}),e.jsx("button",{type:"button",className:`ide-dock-terminal-btn${O?"":" on"}`,onPointerDown:Y=>Y.stopPropagation(),onClick:()=>A(),title:y("ide.toggleTerminal"),"aria-label":y("ide.toggleTerminal"),"aria-pressed":!O,children:e.jsx(rt,{size:14})})]}):s&&N&&e.jsx(Nt,{filePath:s.path,rootPath:N,onSegmentClick:M,onOpenFile:L}),e.jsx("div",{className:"ide-editor-content",onDragOver:Y=>{Y.preventDefault(),Y.dataTransfer.dropEffect="copy"},onDrop:Y=>{Y.preventDefault();const ie=Y.dataTransfer.getData("application/x-file-paths")||Y.dataTransfer.getData("text/plain");if(ie){try{const de=JSON.parse(ie),xe=Array.isArray(de)?de:[ie];xe.length>0&&L(xe[0])}catch{ie&&L(ie)}setTimeout(()=>{const de=document.querySelector(".ide-editor-content .monaco-editor textarea");de==null||de.focus()},100)}},children:ue()})]}),Pe&&e.jsxs(e.Fragment,{children:[!E&&e.jsx("div",{...q.sashProps}),e.jsx("div",{className:"ide-bottom-panel-wrap",style:{height:E?"100%":q.size},children:e.jsx(us,{})})]})]})]}),e.jsx("div",{className:"ide-statusbar-drag-zone",onPointerDown:q.sashProps.onPointerDown,onDoubleClick:q.sashProps.onDoubleClick,children:e.jsx(ns,{language:(s==null?void 0:s.language)||"",cursorLine:a.line,cursorColumn:a.col,selectedCount:a.selectedChars,selectedLines:a.selectedLines,viewMode:s?o?"editor":s.viewMode:"editor",isDirty:s==null?void 0:s.isDirty,saveStatus:s==null?void 0:s.saveStatus,saveError:s==null?void 0:s.saveError,imageInfo:l,zoom:i,extraRight:D?e.jsxs("button",{type:"button",className:`editor-statusbar-item clickable${O?"":" is-active"}`,onPointerDown:Y=>Y.stopPropagation(),onClick:()=>A(),title:y("ide.toggleTerminal"),"aria-label":y("ide.toggleTerminal"),"aria-pressed":!O,children:[e.jsx(rt,{size:12}),e.jsx("span",{children:y("ide.terminal")})]}):void 0})})]})}function Et({t}){return e.jsxs("div",{className:"dock-open-file-empty",children:[e.jsx(ht,{size:40,strokeWidth:1.25,"aria-hidden":!0}),e.jsx("h2",{children:t("dock.openFile")}),e.jsx("p",{children:t("dock.pickFromTree")})]})}function kn({isMac:t,t:s}){const n=r.useRef(null),[a,l]=r.useState(!1);return r.useEffect(()=>{const i=n.current;if(!i)return;const o=new ResizeObserver(h=>{for(const u of h)l(u.contentRect.height<300)});return o.observe(i),()=>o.disconnect()},[]),e.jsxs("div",{className:"editor-empty",ref:n,children:[e.jsx("div",{className:"ide-empty-icon",children:e.jsx("img",{src:sa,alt:"CodeBuddy",width:"64",height:"64",style:{opacity:.15,filter:"grayscale(1)"}})}),!a&&e.jsxs("div",{className:"editor-empty-shortcuts",children:[e.jsxs("div",{className:"editor-empty-hint",children:[e.jsxs("kbd",{children:[t?"⌘":"Ctrl","+P"]}),e.jsx("span",{children:s("editor.quickOpen")})]}),e.jsxs("div",{className:"editor-empty-hint",children:[e.jsxs("kbd",{children:[t?"⌘":"Ctrl","+B"]}),e.jsx("span",{children:s("ide.toggleSidebar")})]}),e.jsxs("div",{className:"editor-empty-hint",children:[e.jsxs("kbd",{children:[t?"⌃":"Ctrl","+`"]}),e.jsx("span",{children:s("ide.toggleTerminal")})]})]})]})}function wn(){const{t}=te(),s=re(i=>i.activeMobilePanel),n=re(i=>i.setActiveMobilePanel),a=ge(i=>i.files.length),l=[{id:"explorer",icon:e.jsx(Ut,{size:20,strokeWidth:1.5}),label:t("ide.explorer")},{id:"search",icon:e.jsx(ft,{size:20,strokeWidth:1.5}),label:t("ide.search")},{id:"source-control",icon:e.jsx(Ee,{size:20,strokeWidth:1.5}),label:t("ide.sourceControl"),badge:a},{id:"terminal",icon:e.jsx(rt,{size:20,strokeWidth:1.5}),label:t("ide.terminal")}];return e.jsx("div",{className:"mobile-tab-bar",children:l.map(i=>e.jsxs("button",{className:`mobile-tab-bar-btn ${s===i.id?"active":""}`,onClick:()=>n(i.id),children:[e.jsxs("span",{className:"mobile-tab-bar-icon",children:[i.icon,i.badge!=null&&i.badge>0&&e.jsx("span",{className:"mobile-tab-bar-badge",children:i.badge>99?"99+":i.badge})]}),e.jsx("span",{className:"mobile-tab-bar-label",children:i.label})]},i.id))})}const Cn=1e3;function st(t){return`editor-save:${t}`}function Fn({onMenuClick:t,isVisible:s=!0,hideActivityBar:n=!1}){const{t:a,resolved:l}=te(),{tabs:i,activeTabId:o,rootPath:h,openFile:u,loadTab:d,updateTabContent:b,saveTab:j,requestCloseTabs:m,discardTabs:v,revealInTree:T,pendingReveal:D,showHiddenFiles:y,setActiveTab:x}=ae(),[g,F]=r.useState(!1),[K]=r.useState(()=>$a(Cn)),C=re(W=>W.toggleBottomPanel),N=aa(),[L,M]=r.useState(!1),S=r.useRef(!1),H=r.useRef(null),I=r.useRef(null),w=r.useCallback(()=>{S.current||(I.current=document.activeElement instanceof HTMLElement?document.activeElement:null,S.current=!0,M(!0))},[]),c=r.useCallback(()=>{S.current=!1,M(!1),requestAnimationFrame(()=>{var W;(W=I.current)==null||W.focus(),I.current=null})},[]);r.useEffect(()=>{H.current&&(H.current.inert=!L)},[L,N]);const k=r.useRef("");r.useEffect(()=>{const W=async()=>{if(!s)return;const _=_t(),R=_.get("path");if(!R)return;const V=_.get("line"),se=_.get("col"),ne=`${R}:${V}:${se}`;if(ne===k.current)return;k.current=ne;const Re=ae.getState();if(!Re.rootPath){const je=_.get("folder")||new URLSearchParams(window.location.search).get("folder");je&&await Re.setRootPath(je)}const _e=await oa(R),We=ae.getState().rootPath;if(_e==="directory")We&&(R===We||R.startsWith(We+"/"))?Re.revealInTree(R):(await ae.getState().setRootPath(R),at(async()=>{const{useFolderStore:je}=await import("./index-CBmymKHy.js").then(Ye=>Ye.bq);return{useFolderStore:je}},__vite__mapDeps([0,1,2,3])).then(({useFolderStore:je})=>{je.getState().setFolder(R)}));else{if(!We){const gt=R.substring(0,R.lastIndexOf("/"));gt&&await ae.getState().setRootPath(gt)}const je=V?parseInt(V,10):void 0,Ye=je?{line:je,col:se?parseInt(se,10):1,query:""}:void 0,xt=ae.getState();xt.openFile(R,void 0,Ye),xt.revealInTree(R)}};W();const p=()=>W();return window.addEventListener("hashchange",p),()=>window.removeEventListener("hashchange",p)},[s]),r.useEffect(()=>{N||(S.current=!1,M(!1))},[N]),r.useEffect(()=>{N&&o&&w()},[N,o,i.length,w]),r.useEffect(()=>{N&&D&&o&&w()},[N,D,o,w]),r.useEffect(()=>{if(!o)return;const W=ae.getState().tabs.find(p=>p.id===o);W&&T(W.path)},[o,T]);const P=i.find(W=>W.id===o)||null;r.useEffect(()=>{i.length===0||i.some(W=>W.id===o)||x(i[0].id)},[o,x,i]);const U=Vt(W=>W.quickOpenNonce),Q=r.useRef(null),$=r.useRef(0);r.useEffect(()=>{!n||U===$.current||($.current=U,U>0&&F(!0))},[n,U]);const O=a("editor.saveFailed"),E=a("app.retry"),X=r.useRef(new Map);r.useEffect(()=>{const W=X.current,p=new Set,_=jt.getState().removeToast;for(const R of i){if(R.saveStatus!=="error")continue;p.add(R.id);const V=`${l}:${R.saveError??""}`;W.get(R.id)!==V&&(W.set(R.id,V),Te.error(`${O}${R.saveError?`: ${R.saveError}`:""}`,{id:st(R.id),durationMs:0,action:{label:E,onClick:()=>ae.getState().saveTab(R.id)}}))}for(const R of W.keys())p.has(R)||(_(st(R)),W.delete(R))},[l,E,O,i]),r.useEffect(()=>()=>{const W=X.current,p=jt.getState().removeToast;for(const _ of W.keys())p(st(_));W.clear()},[]);const G=r.useCallback(W=>{if(!o)return;b(o,W);const p=o;K.schedule(p,()=>{const _=ae.getState(),R=_.tabs.find(V=>V.id===p);(R==null?void 0:R.loadStatus)==="ready"&&R.isDirty&&_.saveTab(p).catch(()=>!1)})},[o,K,b]);r.useEffect(()=>()=>K.dispose(),[K]),r.useEffect(()=>{const W=p=>{ae.getState().tabs.some(R=>R.isDirty||R.saveStatus==="saving")&&(p.preventDefault(),p.returnValue="")};return window.addEventListener("beforeunload",W),()=>window.removeEventListener("beforeunload",W)},[]);const[A,f]=r.useState(null),B=r.useCallback(async W=>{na(ae.getState().tabs,W).forEach(R=>K.cancel(R));const _=await m(W);f(_.closed?null:_)},[K,m]);r.useEffect(()=>{if(!s)return;const W=p=>{if(p.defaultPrevented||!s)return;if(n){const R=Q.current,V=p.target;if(!R||!(V instanceof Node)||!R.contains(V))return}const _=p.metaKey||p.ctrlKey;if(_&&p.key==="p"&&!p.shiftKey&&(p.preventDefault(),F(!0)),_&&p.key==="w"&&!p.shiftKey&&(p.preventDefault(),o&&B({kind:"single",id:o}).catch(()=>{})),_&&p.key==="b"&&!p.shiftKey){if(n)return;p.preventDefault();const R=re.getState();R.setSidePanelCollapsed(!R.sidePanelCollapsed)}_&&p.key==="`"&&(p.preventDefault(),C())};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[o,B,n,s,C]);const q=r.useCallback(()=>{o&&(K.cancel(o),j(o).catch(()=>!1))},[o,K,j]),[z,J]=r.useState({line:1,col:1,selectedChars:0,selectedLines:0}),ue=r.useCallback((W,p,_,R)=>{J({line:W,col:p,selectedChars:_,selectedLines:R})},[]),[le,Z]=r.useState(null),[ee,he]=r.useState(1),[me,Pe]=r.useState(new Set),be=(P==null?void 0:P.viewMode)==="markdown"&&!me.has(P.id),Y=r.useCallback(()=>{o&&Pe(W=>{const p=new Set(W);return p.has(o)?p.delete(o):p.add(o),p})},[o]);let ie=null;(P==null?void 0:P.viewMode)==="markdown"&&(ie=be?e.jsx("button",{className:"editor-action-btn",onClick:Y,title:a("editor.preview"),"aria-label":a("editor.preview"),children:e.jsx(ra,{size:16})}):e.jsx("button",{className:"editor-action-btn",onClick:Y,title:a("editor.source"),"aria-label":a("editor.source"),children:e.jsx(ia,{size:16})}));const de=r.useCallback(()=>{const W=new URLSearchParams(window.location.search);W.set("standalone","1"),window.open(`#/editor?${W.toString()}`,"_blank","noopener,noreferrer")},[]),xe=r.useCallback(()=>{if(!P)return;const W=P.name||Xt(P.path);if(P.viewMode==="editor"||P.viewMode==="markdown"){Jt(W,P.content??"");return}$e(P.path,W).catch(()=>{Te.error(a("editor.downloadFailed"))})},[P,a]),De=e.jsxs(e.Fragment,{children:[ie,P?e.jsx("button",{className:"editor-action-btn",onClick:xe,title:a("editor.download"),"aria-label":a("editor.download"),children:e.jsx(Le,{size:16})}):null,e.jsx("button",{className:"editor-action-btn",onClick:de,title:a("editor.openInNewWindow"),"aria-label":a("editor.openInNewWindow"),children:e.jsx(Kt,{size:16})})]}),Ge=r.useCallback(()=>{A&&(A.targetIds.forEach(W=>K.cancel(W)),v(A.targetIds),f(null))},[K,v,A]),Qe=r.useCallback(()=>{f(null)},[]),Oe=A?e.jsx(Wt,{title:a("editor.closeSaveFailedTitle",{count:A.failedTabIds.length}),message:a("editor.closeSaveFailedMessage",{count:A.failedTabIds.length}),confirmLabel:a("editor.discardAndClose"),danger:!0,onConfirm:Ge,onCancel:Qe}):null,Ce=re(W=>W.activeMobilePanel),Ae=re(W=>W.createBottomTerminal),Be=re(W=>W.bottomTerminals);if(r.useEffect(()=>{N&&Ce==="terminal"&&Be.length===0&&Ae()},[N,Ce,Be.length,Ae]),N){const W=g&&h&&e.jsx(hs,{isOpen:g,onClose:()=>F(!1),onSelect:_=>{u(_),F(!1)},rootPath:h,showHiddenFiles:y});let p=null;return P&&(P.loadStatus!=="ready"?p=e.jsx(es,{tab:P,onRetry:()=>d(P.id)}):P.viewMode==="editor"||be?p=e.jsx("div",{className:"editor-container",children:e.jsx(Zt,{path:P.path,content:P.content,language:P.language,onContentChange:G,onSave:q,minimap:!1,onCursorChange:ue})}):p=e.jsx(ls,{path:P.path,name:P.name,content:P.content,viewMode:P.viewMode,onImageInfo:Z,onZoomChange:he})),e.jsxs("div",{className:"editor-view editor-view-mobile",ref:Q,children:[W,Oe,e.jsxs("div",{className:"mobile-panel-content",children:[Ce==="explorer"&&e.jsx("div",{className:"editor-sidebar editor-sidebar-mobile",children:e.jsx(ds,{onMenuClick:t})}),Ce==="search"&&e.jsx(fs,{}),Ce==="source-control"&&e.jsx(bs,{}),Ce==="terminal"&&e.jsx("div",{className:"mobile-terminal-panel",children:e.jsx(us,{})})]}),e.jsx("div",{ref:H,className:`editor-mobile-panel ${L?"open":""}`,"aria-hidden":!L,children:e.jsxs("div",{className:"editor-main",children:[e.jsxs("div",{className:"editor-mobile-header",children:[e.jsx("button",{className:"editor-mobile-back",onClick:c,"aria-label":a("editor.mobileBack"),children:e.jsx(la,{size:18})}),e.jsx("div",{className:"editor-mobile-tabs-wrap",children:e.jsx(rs,{actions:De,onRequestClose:B})})]}),p,P&&e.jsx(ns,{language:P.language,cursorLine:z.line,cursorColumn:z.col,selectedCount:z.selectedChars,selectedLines:z.selectedLines,viewMode:be?"editor":P.viewMode,isDirty:P.isDirty,saveStatus:P.saveStatus,saveError:P.saveError,imageInfo:le,zoom:ee})]})}),e.jsx(wn,{})]})}return e.jsxs("div",{className:"editor-view",ref:Q,children:[Oe,e.jsx(yn,{onMenuClick:t,activeTab:P,tabActions:De,cursorInfo:z,imageInfo:le,previewZoom:ee,isMarkdownSource:be,quickOpenVisible:g,setQuickOpenVisible:F,onContentChange:G,onSave:q,onRequestClose:B,onCursorChange:ue,onImageInfo:Z,onZoomChange:he,hideActivityBar:n})]})}export{Fn as EditorView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as u,aa as c,
|
|
1
|
+
import{c as u,aa as c,a4 as $}from"./index-CBmymKHy.js";import{j as l}from"./markdown-CP9awqWt.js";/**
|
|
2
2
|
* @license lucide-react v1.18.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a,j as t}from"./markdown-
|
|
1
|
+
import{a,j as t}from"./markdown-CP9awqWt.js";import{u as K,az as P,aA as L,aB as M,aC as I,W as q,t as F,X as B,as as J,aD as Q}from"./index-CBmymKHy.js";import"./vendor-iLJwFVtf.js";const V=({isOpen:n,actionId:d,actionName:v,context:i,existingBindings:y,onSave:C,onCancel:g})=>{const{t:b}=K(),[c,S]=a.useState([]),[f,j]=a.useState([]);a.useEffect(()=>{n&&(S([]),j([]))},[n]),a.useEffect(()=>{if(!n)return;const x=l=>{if(l.preventDefault(),l.stopPropagation(),["Control","Shift","Alt","Meta"].includes(l.key))return;const u=L(l);if(!u)return;const k=[...c,u];S(k);const z=M(k).toLowerCase(),R=y.filter(h=>h.action===d&&h.context===i?!1:M(h.chord).toLowerCase()===z&&h.action!==null).map(h=>`${h.action} (${h.context})`);j(R)};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[n,c,y,d,i]);const o=a.useCallback(()=>{if(c.length===0)return;const x=c.map(l=>{const u=[];return l.ctrl&&u.push("ctrl"),l.alt&&u.push("alt"),l.shift&&u.push("shift"),l.super&&u.push("cmd"),u.push(l.key===" "?"space":l.key),u.join("+")});C(x.join(" "))},[c,C]),$=a.useCallback(()=>{S([]),j([])},[]);return n?t.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/50",style:{zIndex:"var(--z-modal, 100)"},onClick:g,children:t.jsxs("div",{className:"bg-[var(--color-bg-primary)] border border-[var(--color-border-default)] rounded-lg p-6 w-[440px] shadow-xl",onClick:x=>x.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-medium text-[var(--color-text-primary)] mb-1",children:b("keybindings.record.title")}),t.jsxs("p",{className:"text-sm text-[var(--color-text-secondary)] mb-4",children:[v," ",t.jsxs("span",{className:"text-[var(--color-text-muted)]",children:["(",i,")"]})]}),t.jsx("div",{className:"border border-[var(--color-border-default)] rounded-md p-4 mb-4 text-center min-h-[60px] flex items-center justify-center bg-[var(--color-bg-secondary)]",children:c.length>0?t.jsx("span",{className:"text-lg font-mono text-[var(--color-text-primary)]",children:c.map((x,l)=>t.jsxs("span",{children:[l>0&&t.jsx("span",{className:"text-[var(--color-text-muted)] mx-1",children:" "}),P(x)]},l))}):t.jsx("span",{className:"text-sm text-[var(--color-text-muted)]",children:b("keybindings.record.hint")})}),f.length>0&&t.jsxs("div",{className:"text-sm text-[var(--color-warning)] mb-4",children:[b("keybindings.record.conflict"),": ",f.join(", ")]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[c.length>0&&t.jsx("button",{className:"px-3 py-1.5 text-sm text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors",onClick:$,children:b("keybindings.action.reset")}),t.jsx("button",{className:"px-3 py-1.5 text-sm text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors",onClick:g,children:b("app.cancel")}),t.jsx("button",{className:`px-4 py-1.5 text-sm rounded-md transition-colors ${c.length===0?"bg-[var(--color-bg-secondary)] text-[var(--color-text-muted)] cursor-not-allowed":"bg-[var(--color-accent-brand)] text-[var(--color-bg-primary)] hover:opacity-90"}`,disabled:c.length===0,onClick:o,children:b("app.confirm")})]})]})}):null},H=()=>{const{t:n,tryT:d}=K(),{defaults:v,userBlocks:i,bindings:y,warnings:C,loaded:g,loadBindings:b,saveUserBindings:c,resetBindings:S}=I(),[f,j]=a.useState(""),[o,$]=a.useState(null),x=a.useCallback(s=>d(`keybindings.ctx.${s}`)??s,[d]),l=a.useCallback(s=>d(`keybindings.ctxDesc.${s}`)??"",[d]),u=a.useCallback(s=>d(`keybindings.act.${s}`)??W(s),[d]);a.useEffect(()=>{g||b()},[g,b]);const k=a.useMemo(()=>{if(!g)return[];const s=new Set;if(i)for(const e of i)for(const[p,m]of Object.entries(e.bindings))s.add(`${e.context}:${m??"null"}:${p}`);const r=new Map;for(const e of y){const p=`${e.context}:${e.action}`,m=M(e.chord),D=e.chord.map(N=>{const w=[];return N.ctrl&&w.push("ctrl"),N.alt&&w.push("alt"),N.shift&&w.push("shift"),N.super&&w.push("cmd"),w.push(N.key===" "?"space":N.key),w.join("+")}).join(" "),A=s.has(`${e.context}:${e.action}:${D}`);r.set(p,{action:e.action??"",displayName:e.action?u(e.action):"",keyDisplay:m,keyRaw:D,context:e.context,source:A?"user":"default",isUnbound:e.action===null})}return Array.from(r.values()).filter(e=>!e.isUnbound)},[g,y,i,u]),z=a.useMemo(()=>f.trim()?k.filter(s=>[s.displayName,s.action,s.keyDisplay,x(s.context)].some(e=>q(f,e).match)):k,[k,f,x]),R=a.useMemo(()=>{const s=new Map;for(const r of z){const e=s.get(r.context)||[];e.push(r),s.set(r.context,e)}return s},[z]),h=a.useCallback(async s=>{if(!o)return;const r=i?JSON.parse(JSON.stringify(i)):[];let e=r.find(p=>p.context===o.context);e||(e={context:o.context,bindings:{}},r.push(e));for(const[p,m]of Object.entries(e.bindings))m===o.action&&delete e.bindings[p];e.bindings[s]=o.action,await c({bindings:r}),$(null)},[o,i,c]),O=a.useCallback(async s=>{const r=i?JSON.parse(JSON.stringify(i)):[];let e=r.find(p=>p.context===s.context);e||(e={context:s.context,bindings:{}},r.push(e)),e.bindings[s.keyRaw]=null,await c({bindings:r})},[i,c]),U=a.useCallback(async s=>{if(!i)return;const r=JSON.parse(JSON.stringify(i)),e=r.find(m=>m.context===s.context);if(!e)return;delete e.bindings[s.keyRaw];for(const[m,E]of Object.entries(e.bindings))if(E===s.action||E===null){const D=v.find(A=>A.context===s.context);D&&D.bindings[m]===s.action&&delete e.bindings[m]}const p=r.filter(m=>Object.keys(m.bindings).length>0);await c({bindings:p})},[i,v,c]);return g?t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-2 border-b border-[var(--color-border-default)] flex items-center gap-2",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(F,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-muted)]"}),t.jsx("input",{type:"text",value:f,onChange:s=>j(s.target.value),placeholder:n("keybindings.search.placeholder"),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-[var(--color-bg-secondary)] text-[var(--color-text-primary)] border border-[var(--color-border-default)] rounded-md outline-none focus:border-[var(--color-accent-blue)]"}),f&&t.jsx("button",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]",onClick:()=>j(""),children:t.jsx(B,{size:14})})]}),t.jsx("button",{className:"p-1.5 text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] transition-colors",onClick:()=>S(),title:n("keybindings.reset.all"),children:t.jsx(J,{size:14})})]}),C.length>0&&t.jsx("div",{className:"px-4 py-2 bg-[var(--color-warning-bg,rgba(255,170,0,0.1))] border-b border-[var(--color-border-default)]",children:C.slice(0,3).map((s,r)=>t.jsxs("p",{className:"text-xs text-[var(--color-warning)]",children:[s.severity==="error"?"x":"!"," ",s.message]},r))}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[Array.from(R.entries()).map(([s,r])=>t.jsxs("div",{className:"mb-2",children:[t.jsxs("div",{className:"sticky top-0 px-4 py-2 bg-[var(--color-bg-secondary)] border-b border-[var(--color-border-default)]",children:[t.jsx("span",{className:"text-xs font-semibold text-[var(--color-text-secondary)] uppercase tracking-wider",children:x(s)}),t.jsx("span",{className:"text-xs text-[var(--color-text-muted)] ml-2 font-normal normal-case tracking-normal",children:l(s)})]}),r.map(e=>t.jsxs("div",{className:`
|
|
2
2
|
group flex items-center gap-2 px-4 py-2.5 border-b border-[var(--color-border-muted)]
|
|
3
3
|
hover:bg-[var(--color-bg-secondary)] transition-colors
|
|
4
4
|
${e.source==="user"?"border-l-2 border-l-[var(--color-accent-blue)]":"border-l-2 border-l-transparent"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{a as l,j as e}from"./markdown-
|
|
1
|
+
import{a as l,j as e}from"./markdown-CP9awqWt.js";import{u as T,q as z,aE as W,t as P,X as _,ab as w,aF as A,r as I}from"./index-CBmymKHy.js";import{u as O}from"./worker-store-qfd_N8Zm.js";import{o as F,a as $}from"./one-light-daQKygYj.js";import"./vendor-iLJwFVtf.js";const H=I,V=5e3,B={telemetry:{zh:"遥测日志",en:"Telemetry"},process:{zh:"进程输出",en:"Process"},debug:{zh:"调试日志",en:"Debug"},transcript:{zh:"对话记录",en:"Transcript"}};function Q(){const{t:r,resolved:i}=T(),c=z(t=>t.resolved),{workers:d,fetchWorkers:x,logsContent:s,logsType:n,logsAvailableTypes:p,logsPath:u,fetchLogs:m}=O(),[a,b]=l.useState(""),[h,v]=l.useState(""),[g,L]=l.useState(!1),f=l.useRef(null);l.useEffect(()=>{x();const o=window.location.hash.match(/[?&]worker=(\d+)/);o&&b(o[1])},[x]),l.useEffect(()=>{a&&m(a)},[a,m]),l.useEffect(()=>{if(!a&&d.length>0){const o=window.location.hash.match(/[?&]worker=(\d+)/);if(o)b(o[1]);else{const j=d.find(S=>S.isCurrent);j&&b(String(j.pid))}}},[d,a]),l.useEffect(()=>{if(!g||!a)return;const t=setInterval(()=>{m(a,n||void 0)},V);return()=>clearInterval(t)},[g,a,n,m]),l.useEffect(()=>{f.current&&(f.current.scrollTop=f.current.scrollHeight)},[s]);const C=l.useCallback(()=>{a&&m(a,n||void 0)},[a,n,m]),E=l.useCallback(t=>{a&&m(a,t)},[a,m]),N=l.useMemo(()=>{if(!h.trim()||!s)return s;const t=h.toLowerCase();return s.split(`
|
|
2
2
|
`).filter(j=>j.toLowerCase().includes(t)).join(`
|
|
3
3
|
`)},[s,h]),R=l.useMemo(()=>{if(!h.trim()||!s)return 0;const t=h.toLowerCase();return s.split(`
|
|
4
4
|
`).filter(o=>o.toLowerCase().includes(t)).length},[s,h]),y=d.find(t=>String(t.pid)===a);return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-none px-4 py-3 border-b border-border-primary bg-bg-primary",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{size:18,className:"text-accent-brand"}),e.jsx("h1",{className:"text-base font-semibold text-text-primary",children:r("logs.title")})]}),e.jsxs("select",{value:a,onChange:t=>b(t.target.value),className:`px-2.5 py-1.5 text-xs rounded-lg border border-border-primary bg-bg-secondary
|
|
5
|
-
text-text-primary focus:outline-none focus:border-accent-brand min-w-[180px]`,children:[e.jsx("option",{value:"",children:r("logs.selectWorker")}),d.map(t=>e.jsxs("option",{value:t.pid,children:["PID ",t.pid," — ",t.name||t.kind,t.isCurrent?` (${r("logs.current")})`:""]},t.pid))]}),p.length>0&&e.jsx("div",{className:"flex items-center gap-0.5 bg-bg-tertiary rounded-lg p-0.5",children:p.map(t=>{var o;return e.jsx("button",{onClick:()=>E(t),className:`px-2.5 py-1 text-[11px] font-medium rounded-md transition-colors ${t===n?"bg-bg-primary text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:((o=
|
|
5
|
+
text-text-primary focus:outline-none focus:border-accent-brand min-w-[180px]`,children:[e.jsx("option",{value:"",children:r("logs.selectWorker")}),d.map(t=>e.jsxs("option",{value:t.pid,children:["PID ",t.pid," — ",t.name||t.kind,t.isCurrent?` (${r("logs.current")})`:""]},t.pid))]}),p.length>0&&e.jsx("div",{className:"flex items-center gap-0.5 bg-bg-tertiary rounded-lg p-0.5",children:p.map(t=>{var o;return e.jsx("button",{onClick:()=>E(t),className:`px-2.5 py-1 text-[11px] font-medium rounded-md transition-colors ${t===n?"bg-bg-primary text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:((o=B[t])==null?void 0:o[i])||t},t)})}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",children:[e.jsx(P,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-text-tertiary"}),e.jsx("input",{type:"text",value:h,onChange:t=>v(t.target.value),placeholder:r("logs.search"),className:`pl-7 pr-7 py-1.5 text-xs rounded-lg border border-border-primary bg-bg-secondary
|
|
6
6
|
text-text-primary placeholder:text-text-tertiary focus:outline-none focus:border-accent-brand w-[180px]`}),h&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"absolute right-8 top-1/2 -translate-y-1/2 text-[10px] text-text-tertiary",children:R}),e.jsx("button",{onClick:()=>v(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-tertiary hover:text-text-primary",children:e.jsx(_,{size:12})})]})]}),e.jsxs("button",{onClick:()=>L(!g),className:`flex items-center gap-1 px-2.5 py-1.5 text-xs rounded-lg border transition-colors ${g?"border-accent-brand/40 bg-accent-brand/10 text-accent-brand":"border-border-primary text-text-secondary hover:text-text-primary"}`,title:r("logs.autoRefresh"),children:[e.jsx(w,{size:12,className:g?"animate-spin":""}),r("logs.autoRefresh")]}),e.jsx("button",{onClick:C,className:"p-1.5 rounded-lg text-text-tertiary hover:text-text-primary hover:bg-bg-hover transition-colors",title:r("logs.refresh"),children:e.jsx(w,{size:14})})]}),y&&e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[11px] text-text-tertiary",children:[u&&e.jsx(A,{path:u,className:"font-mono truncate max-w-[400px]"}),y.url&&e.jsx("a",{href:y.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent-brand hover:underline",children:y.url})]})]}),e.jsx("div",{className:"flex-1 overflow-auto bg-bg-primary",children:a?!s&&p.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-text-tertiary text-sm",children:r("logs.empty")}):h?e.jsx("div",{ref:f,className:"p-4 font-mono text-xs leading-5 min-h-full",children:N?N.split(`
|
|
7
|
-
`).map((t,o)=>e.jsx(U,{line:t,searchText:h},o)):e.jsx("span",{className:"text-text-tertiary",children:r("logs.empty")})}):e.jsx("div",{ref:f,className:"min-h-full",children:e.jsx(
|
|
7
|
+
`).map((t,o)=>e.jsx(U,{line:t,searchText:h},o)):e.jsx("span",{className:"text-text-tertiary",children:r("logs.empty")})}):e.jsx("div",{ref:f,className:"min-h-full",children:e.jsx(H,{language:"log",style:c==="dark"?F:$,showLineNumbers:!0,wrapLongLines:!0,customStyle:{margin:0,padding:"16px",border:"none",background:"transparent",fontSize:"12px",lineHeight:"1.5"},codeTagProps:{style:{background:"transparent",textShadow:"none"}},lineNumberStyle:{minWidth:"3em",paddingRight:"1em",color:"var(--color-text-tertiary)",userSelect:"none"},children:s||r("logs.empty")})}):e.jsx("div",{className:"flex items-center justify-center h-full text-text-tertiary text-sm",children:r("logs.selectWorker")})})]})}const D={ERROR:"text-red-500 dark:text-red-400",WARN:"text-amber-600 dark:text-amber-400",INFO:"text-blue-500 dark:text-blue-400",DEBUG:"text-text-tertiary"},G={ERROR:"bg-red-50/50 dark:bg-red-900/10",WARN:"bg-amber-50/50 dark:bg-amber-900/10"},M=/^\[(\w+)\]\s/;function U({line:r,searchText:i}){var u;if(!r.trim())return e.jsx("div",{className:"h-5"});const c=r.match(M),d=((u=c==null?void 0:c[1])==null?void 0:u.toUpperCase())||"",x=D[d]||"text-text-secondary",s=G[d]||"",p=i&&r.toLowerCase().includes(i.toLowerCase())?"bg-yellow-100/60 dark:bg-yellow-900/20":"";return e.jsx("div",{className:`whitespace-pre-wrap break-all px-2 py-px rounded-sm ${s} ${p}`,children:c?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:`font-semibold ${x}`,children:["[",c[1],"]"]}),e.jsx("span",{className:"text-text-secondary",children:k(r.slice(c[0].length),i)})]}):e.jsx("span",{className:"text-text-secondary",children:k(r,i)})})}function k(r,i){if(!i)return r;const c=r.toLowerCase(),d=i.toLowerCase(),x=[];let s=0,n=c.indexOf(d);for(;n!==-1;)n>s&&x.push(r.slice(s,n)),x.push(e.jsx("mark",{className:"bg-yellow-300 dark:bg-yellow-700 text-text-primary rounded-sm px-px",children:r.slice(n,n+i.length)},n)),s=n+i.length,n=c.indexOf(d,s);return s<r.length&&x.push(r.slice(s)),x.length>0?e.jsx(e.Fragment,{children:x}):r}export{Q as LogsView};
|