@tencent-ai/codebuddy-code 2.136.0 → 2.137.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/codebuddy-headless.js +119 -119
- package/dist/codebuddy.js +161 -161
- package/dist/web-ui/assets/{CanvasPaneStandaloneView-CnUnpfNN.js → CanvasPaneStandaloneView-yAqCNJQH.js} +1 -1
- package/dist/web-ui/assets/{CanvasView-Dyb-GuvE.js → CanvasView-DmK2CB5G.js} +1 -1
- package/dist/web-ui/assets/{DocsView-DDVFr0zx.js → DocsView-C4jD_tKc.js} +1 -1
- package/dist/web-ui/assets/{EditorView-Cc_EqOqU.js → EditorView-CXlm0Kc3.js} +4 -4
- package/dist/web-ui/assets/{KeybindingsView-0obq6Itn.js → KeybindingsView-nIBT0Ctg.js} +1 -1
- package/dist/web-ui/assets/{LogsView-UvLm6zAO.js → LogsView-Bfi8rVsn.js} +1 -1
- package/dist/web-ui/assets/{MetricsView-C3ro6Ty5.js → MetricsView-gz6ZrAe_.js} +1 -1
- package/dist/web-ui/assets/{RemoteControlView-Bv8wHyxr.js → RemoteControlView-CoNm10cu.js} +1 -1
- package/dist/web-ui/assets/{StatsView-CTwIFpEZ.js → StatsView--tmfKeoJ.js} +1 -1
- package/dist/web-ui/assets/{TracesView-DsCd_ji4.js → TracesView-DHXiTMsi.js} +1 -1
- package/dist/web-ui/assets/{WorkersView-nGhdzq8o.js → WorkersView-DmfPikWv.js} +1 -1
- package/dist/web-ui/assets/{canvas-store-B2G_0qSy.js → canvas-store-rmm9aYgS.js} +1 -1
- package/dist/web-ui/assets/{cssMode-7bMZTt16.js → cssMode-BI9Jf2yL.js} +1 -1
- package/dist/web-ui/assets/{editor.main-Cgio2T3r.js → editor.main-DcOYuMpW.js} +3 -3
- package/dist/web-ui/assets/{freemarker2-D9NmE5sy.js → freemarker2-CUyCYVvf.js} +1 -1
- package/dist/web-ui/assets/{handlebars-kwTbXcqs.js → handlebars-BH_mxFeP.js} +1 -1
- package/dist/web-ui/assets/{html-CAh2ppfp.js → html-DqvNp6j_.js} +1 -1
- package/dist/web-ui/assets/{htmlMode-BQPqOruy.js → htmlMode-MSF6QrAa.js} +1 -1
- package/dist/web-ui/assets/{index-CfC-qiXR.js → index-DJF_5kYl.js} +202 -202
- package/dist/web-ui/assets/{javascript-D7GemI2o.js → javascript-CgDUWyP1.js} +1 -1
- package/dist/web-ui/assets/{jsonMode-DeTKOLm8.js → jsonMode-CND3mWml.js} +1 -1
- package/dist/web-ui/assets/{liquid-COxqTghQ.js → liquid-qbmiJgFI.js} +1 -1
- package/dist/web-ui/assets/{lspLanguageFeatures-O1icfLsY.js → lspLanguageFeatures-CEsh20ZM.js} +1 -1
- package/dist/web-ui/assets/{mdx-BlW2F-jn.js → mdx-7a8NGziy.js} +1 -1
- package/dist/web-ui/assets/{minus-C6OH_v4w.js → minus-CdC1z50X.js} +1 -1
- package/dist/web-ui/assets/{python-U7zWzqja.js → python-CzVx_2c5.js} +1 -1
- package/dist/web-ui/assets/{razor-drEQfKB0.js → razor-D7rHJADG.js} +1 -1
- package/dist/web-ui/assets/{server-BBzH30YA.js → server-Vphrdtn9.js} +1 -1
- package/dist/web-ui/assets/{tsMode-BPhbnv9S.js → tsMode-JA5QIvWx.js} +1 -1
- package/dist/web-ui/assets/{typescript-C5ff4g7y.js → typescript-wSoLXvhL.js} +1 -1
- package/dist/web-ui/assets/{worker-store-tViJ1gIU.js → worker-store-C5Ek6Mvk.js} +1 -1
- package/dist/web-ui/assets/{xml-5eWaqSbe.js → xml-CAu7vat5.js} +1 -1
- package/dist/web-ui/assets/{yaml-C_7vIaXe.js → yaml-DV4EBiFI.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/dist/web-ui/sw.js +1 -1
- package/package.json +1 -1
- package/product.cloudhosted.json +7 -3
- package/product.internal.json +7 -3
- package/product.ioa.json +7 -3
- package/product.json +26 -6
- package/product.selfhosted.json +7 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r,j as a}from"./markdown-DIY6o85n.js";import{u as f,g as c,a as l,S as x,T as h}from"./index-
|
|
1
|
+
import{a as r,j as a}from"./markdown-DIY6o85n.js";import{u as f,g as c,a as l,S as x,T as h}from"./index-DJF_5kYl.js";import{u as d}from"./canvas-store-rmm9aYgS.js";import"./vendor-D35k0Cos.js";function j(){const{t:i}=f(),[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(x,{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(h,{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{j 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-DIY6o85n.js";import{c as de,u as he,P as ke,E as xe,a as Te,S as Ee,C as ze,b as Me,M as Pe,d as Ie,X as je,T as Ce}from"./index-
|
|
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-DIY6o85n.js";import{c as de,u as he,P as ke,E as xe,a as Te,S as Ee,C as ze,b as Me,M as Pe,d as Ie,X as je,T as Ce}from"./index-DJF_5kYl.js";import{M as re,a as ie,u as k,C as we,G as Ne,S as Re,R as ve,b as ce,c as le,T as Le}from"./canvas-store-rmm9aYgS.js";import{M as He}from"./minus-CdC1z50X.js";import"./vendor-D35k0Cos.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 as _,j as a,M as xe,c as ge}from"./markdown-DIY6o85n.js";import{c as pe,e as be,u as H,i as ye,j as we,o as _e,k as ve,l as ie,F as je,m as q,n as Y,p as ke,q as Z,X as ze,E as Se,d as Ce,r as X}from"./index-
|
|
1
|
+
import{a as _,j as a,M as xe,c as ge}from"./markdown-DIY6o85n.js";import{c as pe,e as be,u as H,i as ye,j as we,o as _e,k as ve,l as ie,F as je,m as q,n as Y,p as ke,q as Z,X as ze,E as Se,d as Ce,r as X}from"./index-DJF_5kYl.js";import"./vendor-D35k0Cos.js";/**
|
|
2
2
|
* @license lucide-react v1.18.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{c as ie,u as te,i as gt,s as Xt,L as ve,t as se,v as Yt,w as Jt,x as Ze,y as Zt,h as $e,e as bt,_ as Ue,z as es,A as ts,G as Se,B as ss,P as je,D as vt,H as as,I as Ne,J as xe,K as ns,X as jt,n as ce,N as is,O as rs,Q as yt,d as kt,R as ls,j as cs,o as os,k as ds,U as Ge,p as us,g as wt,V as Ct,W as hs,m as he,Y as ms,Z as Me,$ as fs,a0 as Nt,a1 as ne,a2 as ps,a as xs,M as gs,T as bs,a3 as St,a4 as vs,a5 as js,a6 as nt,l as et,a7 as ys,a8 as ks,a9 as Mt,aa as tt,C as ws,E as Pt,ab as Cs,ac as Ns,ad as Ss,ae as Ms,S as Ps,af as Ds,ag as it,ah as zs,ai as Es,aj as Rs,ak as Ts,al as rt,am as Ls}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DJF_5kYl.js","assets/markdown-DIY6o85n.js","assets/vendor-D35k0Cos.js","assets/index-CXEvM6mn.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as ie,u as te,i as gt,s as Xt,L as ve,t as se,v as Yt,w as Jt,x as Ze,y as Zt,h as $e,e as bt,_ as Ue,z as es,A as ts,G as Se,B as ss,P as je,D as vt,H as as,I as Ne,J as xe,K as ns,X as jt,n as ce,N as is,O as rs,Q as yt,d as kt,R as ls,j as cs,o as os,k as ds,U as Ge,p as us,g as wt,V as Ct,W as hs,m as he,Y as ms,Z as Me,$ as fs,a0 as Nt,a1 as ne,a2 as ps,a as xs,M as gs,T as bs,a3 as St,a4 as vs,a5 as js,a6 as nt,l as et,a7 as ys,a8 as ks,a9 as Mt,aa as tt,C as ws,E as Pt,ab as Cs,ac as Ns,ad as Ss,ae as Ms,S as Ps,af as Ds,ag as it,ah as zs,ai as Es,aj as Rs,ak as Ts,al as rt,am as Ls}from"./index-DJF_5kYl.js";import{a as n,j as e,M as $s,c as Fs}from"./markdown-DIY6o85n.js";import{M as Fe}from"./minus-CdC1z50X.js";import"./vendor-D35k0Cos.js";/**
|
|
3
3
|
* @license lucide-react v1.18.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -89,7 +89,7 @@ import{c as ie,u as te,i as gt,s as Xt,L as ve,t as se,v as Yt,w as Jt,x as Ze,y
|
|
|
89
89
|
*
|
|
90
90
|
* This source code is licensed under the ISC license.
|
|
91
91
|
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
-
*/const fa=[["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"}]],pa=ie("whole-word",fa);function xa(t){const s=new Map;function a(r){const c=s.get(r);c!==void 0&&(clearTimeout(c),s.delete(r))}function i(r,c){a(r);const u=setTimeout(()=>{s.get(r)===u&&(s.delete(r),c())},t);s.set(r,u)}function l(){for(const r of s.values())clearTimeout(r);s.clear()}return{schedule:i,cancel:a,dispose:l}}function lt(t,s){const a=se.getState().pendingReveal;if(!a||a.path!==s)return!1;se.getState().setPendingReveal(null);const{line:i,col:l,query:r}=a,c=t.getModel();if(!c)return!1;const u=l&&l>0?l:1;if(t.revealLineInCenter(i),t.setPosition({lineNumber:i,column:u}),t.focus(),r){const d=c.findMatches(r,!1,!1,!1,null,!0);if(d.length>0){const h=d.find(m=>m.range.startLineNumber>=i)||d[0];t.setSelection(h.range),t.revealRangeInCenter(h.range);const g=d.map(m=>({range:m.range,options:{className:"search-find-match",overviewRuler:{color:"#d7ba7d",position:1}}})),b=t.deltaDecorations([],g);setTimeout(()=>{try{t.deltaDecorations(b,[])}catch{}},5e3)}}return!0}function Rt({path:t,content:s,language:a,onContentChange:i,onSave:l,minimap:r=!0,onCursorChange:c}){const{t:u}=te(),{resolved:d}=gt(),h=n.useRef(null),g=n.useRef(c);g.current=c;const b=d==="dark"?"cbc-dark":"cbc-light",[m,C]=n.useState(()=>typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);n.useEffect(()=>{const R=window.matchMedia("(prefers-reduced-motion: reduce)"),x=()=>C(R.matches);return R.addEventListener("change",x),()=>R.removeEventListener("change",x)},[]);const[D,E]=n.useState(!1);n.useEffect(()=>{let R=!1;return Xt().then(()=>{R||E(!0)}),()=>{R=!0}},[]);const S=e.jsxs("div",{className:"flex items-center justify-center h-full gap-2",style:{color:"var(--color-text-tertiary)"},children:[e.jsx(ve,{size:16,className:"animate-spin"}),e.jsx("span",{style:{fontSize:13},children:u("editor.loading")})]}),f=n.useCallback((R,x)=>{h.current=R,x.editor.defineTheme("cbc-dark",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#121314"}}),x.editor.defineTheme("cbc-light",{base:"vs",inherit:!0,rules:[],colors:{"editor.background":"#ffffff"}}),x.editor.setTheme(b),R.addCommand(x.KeyMod.CtrlCmd|x.KeyCode.KeyS,()=>{l()});const T=()=>{const $=g.current;if(!$)return;const j=R.getPosition(),N=R.getSelection();if(!j)return;let A=0,I=0;if(N&&!N.isEmpty()){const O=R.getModel();O&&(A=O.getValueInRange(N).length,I=Math.abs(N.endLineNumber-N.startLineNumber)+1)}$(j.lineNumber,j.column,A,I)};R.onDidChangeCursorPosition(T),R.onDidChangeCursorSelection(T),T()},[l]),y=n.useCallback(R=>{R!==void 0&&i(R)},[i]);n.useEffect(()=>{const R=h.current;if(!R)return;const x=R.getModel();x&&s.length>0&&x.getValue()!==s&&x.setValue(s)},[s]);const P=se(R=>R.pendingReveal);return n.useEffect(()=>{if(!P||P.path!==t)return;if(h.current){lt(h.current,t);return}let R=0;const x=setInterval(()=>{R++,h.current?(lt(h.current,t),clearInterval(x)):R>=50&&clearInterval(x)},50);return()=>clearInterval(x)},[t,P]),D?e.jsx(Yt,{height:"100%",language:a,theme:b,defaultValue:s,onChange:y,onMount:f,loading:S,options:{fontSize:13,fontFamily:"'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace",lineHeight:20,minimap:{enabled:r,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}},t):S}function Tt({tab:t,onRetry:s}){const{t:a}=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:a("editor.loadingFile")})]}):t.loadStatus==="too-large"?e.jsxs("div",{className:"editor-content-state",role:"status",children:[e.jsx(Gs,{className:"editor-content-state-icon",size:24,"aria-hidden":"true"}),e.jsx("span",{children:a("editor.fileTooLarge")})]}):e.jsxs("div",{className:"editor-content-state editor-content-state-error",role:"alert",children:[e.jsx(Jt,{className:"editor-content-state-icon",size:24,"aria-hidden":"true"}),e.jsx("span",{children:a("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:a("editor.retryLoad")})]})}async function de(t,s){var c;const a=Ze(),i={...s,...a?{cwd:a}:{}},l=await Zt(`/api/v1/git/${t}`,{method:"POST",headers:{...$e(),"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok){const u=await l.json().catch(()=>({error:{message:l.statusText}}));throw new Error(((c=u.error)==null?void 0:c.message)||`Git API error: ${l.status}`)}const r=await l.json();return r.data??r}async function ga(){return de("status")}async function ct(t){await de("stage",{paths:t})}async function ot(t){await de("unstage",{paths:t})}async function ba(t){return de("commit",{message:t})}async function Lt(t,s){return de("diff",{path:t,staged:s})}async function _e(t,s){await de("discard",{paths:t,useTrash:s})}async function va(){return(await de("branches")).branches}async function ja(t){return de("branch/switch",{name:t})}async function ya(t,s=!0){return de("branch/create",{name:t,checkout:s})}async function ka(){return de("push")}async function wa(){return de("pull")}async function Ca(t){return(await de("log",{limit:t})).entries}const Na=3e3;let Te=null,We=!1,He=!1;async function Sa(){try{const{authHeaders:t}=await Ue(async()=>{const{authHeaders:i}=await import("./index-CfC-qiXR.js").then(l=>l.aR);return{authHeaders:i}},__vite__mapDeps([0,1,2,3])),{fetchWithRetry:s}=await Ue(async()=>{const{fetchWithRetry:i}=await import("./index-CfC-qiXR.js").then(l=>l.aQ);return{fetchWithRetry:i}},__vite__mapDeps([0,1,2,3])),a=await s("/api/v1/info",{headers:t()});if(a.ok){const i=await a.json();return(i.data??i).cwd||void 0}}catch{}}const me=bt((t,s)=>({isGitRepo:!1,loading:!1,error:null,files:[],currentBranch:null,ahead:0,behind:0,remote:null,branches:[],branchesLoading:!1,selectedFile:null,selectedFileStaged:!1,diffResult:null,diffLoading:!1,commitMessage:"",committing:!1,pushing:!1,pulling:!1,lastOperationMessage:null,refresh:async()=>{if(We)return;We=!0,s().files.length===0&&!s().isGitRepo&&t({loading:!0,error:null});try{const i=await ga();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})}finally{We=!1}},loadBranches:async()=>{t({branchesLoading:!0});try{const a=await va();t({branches:a,branchesLoading:!1})}catch{t({branchesLoading:!1})}},stageFile:async a=>{await ct([a]),await s().refresh()},unstageFile:async a=>{await ot([a]),await s().refresh()},stageAll:async()=>{const a=s().files.filter(i=>!i.staged).map(i=>i.path);a.length>0&&(await ct(a),await s().refresh())},unstageAll:async()=>{const a=s().files.filter(i=>i.staged).map(i=>i.path);a.length>0&&(await ot(a),await s().refresh())},discardFile:async a=>{await _e([a],!0),await s().refresh()},discardAll:async()=>{const a=s().files.filter(r=>!r.staged),i=a.filter(r=>r.status!=="untracked"),l=a.filter(r=>r.status==="untracked");i.length>0&&await _e(i.map(r=>r.path)),l.length>0&&await _e(l.map(r=>r.path),!0),await s().refresh()},commit:async()=>{const a=s().commitMessage.trim();if(a){t({committing:!0});try{const i=await ba(a);t({committing:!1,commitMessage:"",lastOperationMessage:i.success?"Committed successfully":i.message}),await s().refresh()}catch(i){t({committing:!1,lastOperationMessage:i.message})}}},push:async()=>{t({pushing:!0});try{const a=await ka();t({pushing:!1,lastOperationMessage:a.success?"Pushed successfully":a.message}),await s().refresh()}catch(a){t({pushing:!1,lastOperationMessage:a.message})}},pull:async()=>{t({pulling:!0});try{const a=await wa();t({pulling:!1,lastOperationMessage:a.success?"Pulled successfully":a.message}),await s().refresh()}catch(a){t({pulling:!1,lastOperationMessage:a.message})}},switchBranch:async a=>{try{const i=await ja(a);t({lastOperationMessage:i.success?`Switched to ${a}`:i.message}),await s().refresh()}catch(i){t({lastOperationMessage:i.message})}},createBranch:async a=>{try{const i=await ya(a);t({lastOperationMessage:i.success?`Created branch ${a}`:i.message}),await s().refresh(),await s().loadBranches()}catch(i){t({lastOperationMessage:i.message})}},selectFile:async(a,i)=>{if(s().selectedFile===a&&s().selectedFileStaged===i){t({selectedFile:null,diffResult:null,selectedFileStaged:!1});return}t({selectedFile:a,selectedFileStaged:i,diffLoading:!0,diffResult:null});try{const l=await Lt(a,i);t({diffResult:l,diffLoading:!1})}catch{t({diffLoading:!1})}},clearSelection:()=>t({selectedFile:null,diffResult:null,selectedFileStaged:!1}),setCommitMessage:a=>t({commitMessage:a}),clearOperationMessage:()=>t({lastOperationMessage:null}),startWatching:async()=>{if(He)return;let a=Ze();a||(a=await Sa()),a&&(He=!0,Te=setInterval(()=>{s().refresh()},Na))},stopWatching:async()=>{He=!1,Te&&(clearInterval(Te),Te=null)}}));es(async()=>{const t=me.getState();await t.stopWatching(),t.refresh(),await t.startWatching()});function $t({currentBranch:t,branches:s,branchesLoading:a,onSwitch:i,onCreate:l,onLoadBranches:r,actions:c,defaultOpen:u,onClose:d}){const{t:h}=te(),[g,b]=n.useState(u??!1),[m,C]=n.useState(""),[D,E]=n.useState(""),[S,f]=n.useState(0),[y,P]=n.useState(!1),R=n.useRef(null),x=n.useCallback(o=>{b(o),o||d==null||d()},[d]);n.useEffect(()=>{const o=setTimeout(()=>E(m),100);return()=>clearTimeout(o)},[m]),n.useEffect(()=>{g&&r()},[g,r]),n.useEffect(()=>{g?setTimeout(()=>{var o;return(o=R.current)==null?void 0:o.focus()},0):(C(""),E(""),f(0),P(!1))},[g]);const{localBranches:T,remoteBranches:$,flatList:j}=n.useMemo(()=>{let o;if(D){const z=[];for(const H of s){const _=ts(D,H.name);_.match&&z.push({...H,_score:_.score})}z.sort((H,_)=>_._score-H._score),o=z}else o=s;const w=o.filter(z=>!z.isRemote),G=o.filter(z=>z.isRemote),Y=[...w,...G];return{localBranches:w,remoteBranches:G,flatList:Y}},[s,D]);n.useEffect(()=>{f(0)},[m]);const N=n.useCallback(o=>{o.key==="Escape"?x(!1):o.key==="ArrowDown"?(o.preventDefault(),f(w=>Math.min(w+1,j.length-1))):o.key==="ArrowUp"?(o.preventDefault(),f(w=>Math.max(w-1,0))):o.key==="Enter"&&(o.preventDefault(),y?m.trim()&&(l(m.trim()),x(!1)):j[S]?(i(j[S].name),x(!1)):m.trim()&&j.length===0&&(l(m.trim()),x(!1)))},[j,S,y,m,i,l]),A=n.useCallback(o=>{i(o),x(!1)},[i]),I=n.useCallback(()=>{P(!0),setTimeout(()=>{var o;return(o=R.current)==null?void 0:o.focus()},0)},[]),O=n.useCallback(()=>{m.trim()&&(l(m.trim()),x(!1))},[m,l]);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:()=>x(!g),title:t||"",children:[e.jsx(Se,{size:14,className:"branch-picker-icon"}),e.jsx("span",{className:"branch-picker-name",children:t||"No branch"})]}),c]}),g&&ss.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"branch-picker-backdrop",onClick:()=>x(!1)}),e.jsxs("div",{className:"branch-picker-dropdown",onKeyDown:N,onMouseDown:o=>o.stopPropagation(),onClick:o=>o.stopPropagation(),children:[e.jsx("div",{className:"branch-picker-search",children:e.jsx("input",{ref:R,className:"branch-picker-input",type:"text",value:m,onChange:o=>C(o.target.value),placeholder:y?h("ide.scm.newBranchPlaceholder")||"New branch name...":h("ide.scm.branchSearchPlaceholder")||"Select a branch or tag to checkout"})}),!y&&e.jsx("div",{className:"branch-picker-actions",children:e.jsxs("button",{className:"branch-picker-action",onClick:I,children:[e.jsx(je,{size:14}),e.jsx("span",{children:h("ide.scm.createBranch")||"Create new branch..."})]})}),y&&e.jsx("div",{className:"branch-picker-actions",children:e.jsxs("button",{className:"branch-picker-action branch-picker-action-confirm",onClick:O,disabled:!m.trim(),children:[e.jsx(je,{size:14}),e.jsx("span",{children:m.trim()?`Create branch "${m.trim()}"`:h("ide.scm.newBranchPlaceholder")||"Type branch name..."})]})}),j.length>0&&e.jsx(Ma,{flatList:j,localCount:T.length,remoteCount:$.length,currentBranch:t,highlightIdx:S,onSelect:A,onHover:f}),a&&j.length===0&&e.jsx("div",{className:"branch-picker-empty",children:"Loading..."}),!a&&j.length===0&&!y&&e.jsx("div",{className:"branch-picker-empty",children:D?h("ide.scm.noBranchMatch")||"No matching branches":h("ide.scm.noBranchMatch")||"No branches found"})]})]}),document.body)]})}const Ce=40,Le=24;function Ma({flatList:t,localCount:s,remoteCount:a,currentBranch:i,highlightIdx:l,onSelect:r,onHover:c}){const u=n.useRef(null),[d,h]=n.useState(0),[g,b]=n.useState(300);n.useEffect(()=>{const f=u.current;if(!f)return;const y=new ResizeObserver(P=>{for(const R of P)b(R.contentRect.height)});return y.observe(f),()=>y.disconnect()},[]),n.useEffect(()=>{const f=u.current;if(!f)return;const y=l*Ce;y<f.scrollTop?f.scrollTop=y:y+Ce>f.scrollTop+g&&(f.scrollTop=y+Ce-g)},[l,g]);const m=n.useCallback(f=>{h(f.target.scrollTop)},[]),C=t.length*Ce+(s>0&&a>0?Le:0)+(a>0?Le:0),D=Math.max(0,Math.floor(d/Ce)-2),E=Math.min(t.length,Math.ceil((d+g)/Ce)+2),S=[];s>0&&a>0&&D===0&&S.push(e.jsx("div",{className:"branch-picker-group-label",style:{height:Le},children:"branches"},"label-local"));for(let f=D;f<E;f++){const y=t[f];y&&(f===s&&a>0&&S.push(e.jsx("div",{className:"branch-picker-group-label",style:{height:Le},children:"remotes"},"label-remote")),S.push(e.jsx(Pa,{branch:y,isCurrent:y.name===i,isHighlighted:f===l,dataIdx:f,onSelect:r,onHover:()=>c(f)},y.name)))}return e.jsx("div",{ref:u,className:"branch-picker-list",onScroll:m,children:e.jsx("div",{style:{height:C,position:"relative"},children:e.jsx("div",{style:{position:"absolute",top:D*Ce,left:0,right:0},children:S})})})}function Pa({branch:t,isCurrent:s,isHighlighted:a,dataIdx:i,onSelect:l,onHover:r}){return e.jsxs("div",{className:`branch-picker-item ${a?"highlighted":""} ${s?"current":""}`,"data-idx":i,onClick:()=>l(t.name),onMouseEnter:r,title:t.lastCommitMessage?`${t.name}
|
|
92
|
+
*/const fa=[["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"}]],pa=ie("whole-word",fa);function xa(t){const s=new Map;function a(r){const c=s.get(r);c!==void 0&&(clearTimeout(c),s.delete(r))}function i(r,c){a(r);const u=setTimeout(()=>{s.get(r)===u&&(s.delete(r),c())},t);s.set(r,u)}function l(){for(const r of s.values())clearTimeout(r);s.clear()}return{schedule:i,cancel:a,dispose:l}}function lt(t,s){const a=se.getState().pendingReveal;if(!a||a.path!==s)return!1;se.getState().setPendingReveal(null);const{line:i,col:l,query:r}=a,c=t.getModel();if(!c)return!1;const u=l&&l>0?l:1;if(t.revealLineInCenter(i),t.setPosition({lineNumber:i,column:u}),t.focus(),r){const d=c.findMatches(r,!1,!1,!1,null,!0);if(d.length>0){const h=d.find(m=>m.range.startLineNumber>=i)||d[0];t.setSelection(h.range),t.revealRangeInCenter(h.range);const g=d.map(m=>({range:m.range,options:{className:"search-find-match",overviewRuler:{color:"#d7ba7d",position:1}}})),b=t.deltaDecorations([],g);setTimeout(()=>{try{t.deltaDecorations(b,[])}catch{}},5e3)}}return!0}function Rt({path:t,content:s,language:a,onContentChange:i,onSave:l,minimap:r=!0,onCursorChange:c}){const{t:u}=te(),{resolved:d}=gt(),h=n.useRef(null),g=n.useRef(c);g.current=c;const b=d==="dark"?"cbc-dark":"cbc-light",[m,C]=n.useState(()=>typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);n.useEffect(()=>{const R=window.matchMedia("(prefers-reduced-motion: reduce)"),x=()=>C(R.matches);return R.addEventListener("change",x),()=>R.removeEventListener("change",x)},[]);const[D,E]=n.useState(!1);n.useEffect(()=>{let R=!1;return Xt().then(()=>{R||E(!0)}),()=>{R=!0}},[]);const S=e.jsxs("div",{className:"flex items-center justify-center h-full gap-2",style:{color:"var(--color-text-tertiary)"},children:[e.jsx(ve,{size:16,className:"animate-spin"}),e.jsx("span",{style:{fontSize:13},children:u("editor.loading")})]}),f=n.useCallback((R,x)=>{h.current=R,x.editor.defineTheme("cbc-dark",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#121314"}}),x.editor.defineTheme("cbc-light",{base:"vs",inherit:!0,rules:[],colors:{"editor.background":"#ffffff"}}),x.editor.setTheme(b),R.addCommand(x.KeyMod.CtrlCmd|x.KeyCode.KeyS,()=>{l()});const T=()=>{const $=g.current;if(!$)return;const j=R.getPosition(),N=R.getSelection();if(!j)return;let A=0,I=0;if(N&&!N.isEmpty()){const O=R.getModel();O&&(A=O.getValueInRange(N).length,I=Math.abs(N.endLineNumber-N.startLineNumber)+1)}$(j.lineNumber,j.column,A,I)};R.onDidChangeCursorPosition(T),R.onDidChangeCursorSelection(T),T()},[l]),y=n.useCallback(R=>{R!==void 0&&i(R)},[i]);n.useEffect(()=>{const R=h.current;if(!R)return;const x=R.getModel();x&&s.length>0&&x.getValue()!==s&&x.setValue(s)},[s]);const P=se(R=>R.pendingReveal);return n.useEffect(()=>{if(!P||P.path!==t)return;if(h.current){lt(h.current,t);return}let R=0;const x=setInterval(()=>{R++,h.current?(lt(h.current,t),clearInterval(x)):R>=50&&clearInterval(x)},50);return()=>clearInterval(x)},[t,P]),D?e.jsx(Yt,{height:"100%",language:a,theme:b,defaultValue:s,onChange:y,onMount:f,loading:S,options:{fontSize:13,fontFamily:"'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace",lineHeight:20,minimap:{enabled:r,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}},t):S}function Tt({tab:t,onRetry:s}){const{t:a}=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:a("editor.loadingFile")})]}):t.loadStatus==="too-large"?e.jsxs("div",{className:"editor-content-state",role:"status",children:[e.jsx(Gs,{className:"editor-content-state-icon",size:24,"aria-hidden":"true"}),e.jsx("span",{children:a("editor.fileTooLarge")})]}):e.jsxs("div",{className:"editor-content-state editor-content-state-error",role:"alert",children:[e.jsx(Jt,{className:"editor-content-state-icon",size:24,"aria-hidden":"true"}),e.jsx("span",{children:a("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:a("editor.retryLoad")})]})}async function de(t,s){var c;const a=Ze(),i={...s,...a?{cwd:a}:{}},l=await Zt(`/api/v1/git/${t}`,{method:"POST",headers:{...$e(),"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok){const u=await l.json().catch(()=>({error:{message:l.statusText}}));throw new Error(((c=u.error)==null?void 0:c.message)||`Git API error: ${l.status}`)}const r=await l.json();return r.data??r}async function ga(){return de("status")}async function ct(t){await de("stage",{paths:t})}async function ot(t){await de("unstage",{paths:t})}async function ba(t){return de("commit",{message:t})}async function Lt(t,s){return de("diff",{path:t,staged:s})}async function _e(t,s){await de("discard",{paths:t,useTrash:s})}async function va(){return(await de("branches")).branches}async function ja(t){return de("branch/switch",{name:t})}async function ya(t,s=!0){return de("branch/create",{name:t,checkout:s})}async function ka(){return de("push")}async function wa(){return de("pull")}async function Ca(t){return(await de("log",{limit:t})).entries}const Na=3e3;let Te=null,We=!1,He=!1;async function Sa(){try{const{authHeaders:t}=await Ue(async()=>{const{authHeaders:i}=await import("./index-DJF_5kYl.js").then(l=>l.aR);return{authHeaders:i}},__vite__mapDeps([0,1,2,3])),{fetchWithRetry:s}=await Ue(async()=>{const{fetchWithRetry:i}=await import("./index-DJF_5kYl.js").then(l=>l.aQ);return{fetchWithRetry:i}},__vite__mapDeps([0,1,2,3])),a=await s("/api/v1/info",{headers:t()});if(a.ok){const i=await a.json();return(i.data??i).cwd||void 0}}catch{}}const me=bt((t,s)=>({isGitRepo:!1,loading:!1,error:null,files:[],currentBranch:null,ahead:0,behind:0,remote:null,branches:[],branchesLoading:!1,selectedFile:null,selectedFileStaged:!1,diffResult:null,diffLoading:!1,commitMessage:"",committing:!1,pushing:!1,pulling:!1,lastOperationMessage:null,refresh:async()=>{if(We)return;We=!0,s().files.length===0&&!s().isGitRepo&&t({loading:!0,error:null});try{const i=await ga();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})}finally{We=!1}},loadBranches:async()=>{t({branchesLoading:!0});try{const a=await va();t({branches:a,branchesLoading:!1})}catch{t({branchesLoading:!1})}},stageFile:async a=>{await ct([a]),await s().refresh()},unstageFile:async a=>{await ot([a]),await s().refresh()},stageAll:async()=>{const a=s().files.filter(i=>!i.staged).map(i=>i.path);a.length>0&&(await ct(a),await s().refresh())},unstageAll:async()=>{const a=s().files.filter(i=>i.staged).map(i=>i.path);a.length>0&&(await ot(a),await s().refresh())},discardFile:async a=>{await _e([a],!0),await s().refresh()},discardAll:async()=>{const a=s().files.filter(r=>!r.staged),i=a.filter(r=>r.status!=="untracked"),l=a.filter(r=>r.status==="untracked");i.length>0&&await _e(i.map(r=>r.path)),l.length>0&&await _e(l.map(r=>r.path),!0),await s().refresh()},commit:async()=>{const a=s().commitMessage.trim();if(a){t({committing:!0});try{const i=await ba(a);t({committing:!1,commitMessage:"",lastOperationMessage:i.success?"Committed successfully":i.message}),await s().refresh()}catch(i){t({committing:!1,lastOperationMessage:i.message})}}},push:async()=>{t({pushing:!0});try{const a=await ka();t({pushing:!1,lastOperationMessage:a.success?"Pushed successfully":a.message}),await s().refresh()}catch(a){t({pushing:!1,lastOperationMessage:a.message})}},pull:async()=>{t({pulling:!0});try{const a=await wa();t({pulling:!1,lastOperationMessage:a.success?"Pulled successfully":a.message}),await s().refresh()}catch(a){t({pulling:!1,lastOperationMessage:a.message})}},switchBranch:async a=>{try{const i=await ja(a);t({lastOperationMessage:i.success?`Switched to ${a}`:i.message}),await s().refresh()}catch(i){t({lastOperationMessage:i.message})}},createBranch:async a=>{try{const i=await ya(a);t({lastOperationMessage:i.success?`Created branch ${a}`:i.message}),await s().refresh(),await s().loadBranches()}catch(i){t({lastOperationMessage:i.message})}},selectFile:async(a,i)=>{if(s().selectedFile===a&&s().selectedFileStaged===i){t({selectedFile:null,diffResult:null,selectedFileStaged:!1});return}t({selectedFile:a,selectedFileStaged:i,diffLoading:!0,diffResult:null});try{const l=await Lt(a,i);t({diffResult:l,diffLoading:!1})}catch{t({diffLoading:!1})}},clearSelection:()=>t({selectedFile:null,diffResult:null,selectedFileStaged:!1}),setCommitMessage:a=>t({commitMessage:a}),clearOperationMessage:()=>t({lastOperationMessage:null}),startWatching:async()=>{if(He)return;let a=Ze();a||(a=await Sa()),a&&(He=!0,Te=setInterval(()=>{s().refresh()},Na))},stopWatching:async()=>{He=!1,Te&&(clearInterval(Te),Te=null)}}));es(async()=>{const t=me.getState();await t.stopWatching(),t.refresh(),await t.startWatching()});function $t({currentBranch:t,branches:s,branchesLoading:a,onSwitch:i,onCreate:l,onLoadBranches:r,actions:c,defaultOpen:u,onClose:d}){const{t:h}=te(),[g,b]=n.useState(u??!1),[m,C]=n.useState(""),[D,E]=n.useState(""),[S,f]=n.useState(0),[y,P]=n.useState(!1),R=n.useRef(null),x=n.useCallback(o=>{b(o),o||d==null||d()},[d]);n.useEffect(()=>{const o=setTimeout(()=>E(m),100);return()=>clearTimeout(o)},[m]),n.useEffect(()=>{g&&r()},[g,r]),n.useEffect(()=>{g?setTimeout(()=>{var o;return(o=R.current)==null?void 0:o.focus()},0):(C(""),E(""),f(0),P(!1))},[g]);const{localBranches:T,remoteBranches:$,flatList:j}=n.useMemo(()=>{let o;if(D){const z=[];for(const H of s){const _=ts(D,H.name);_.match&&z.push({...H,_score:_.score})}z.sort((H,_)=>_._score-H._score),o=z}else o=s;const w=o.filter(z=>!z.isRemote),G=o.filter(z=>z.isRemote),Y=[...w,...G];return{localBranches:w,remoteBranches:G,flatList:Y}},[s,D]);n.useEffect(()=>{f(0)},[m]);const N=n.useCallback(o=>{o.key==="Escape"?x(!1):o.key==="ArrowDown"?(o.preventDefault(),f(w=>Math.min(w+1,j.length-1))):o.key==="ArrowUp"?(o.preventDefault(),f(w=>Math.max(w-1,0))):o.key==="Enter"&&(o.preventDefault(),y?m.trim()&&(l(m.trim()),x(!1)):j[S]?(i(j[S].name),x(!1)):m.trim()&&j.length===0&&(l(m.trim()),x(!1)))},[j,S,y,m,i,l]),A=n.useCallback(o=>{i(o),x(!1)},[i]),I=n.useCallback(()=>{P(!0),setTimeout(()=>{var o;return(o=R.current)==null?void 0:o.focus()},0)},[]),O=n.useCallback(()=>{m.trim()&&(l(m.trim()),x(!1))},[m,l]);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:()=>x(!g),title:t||"",children:[e.jsx(Se,{size:14,className:"branch-picker-icon"}),e.jsx("span",{className:"branch-picker-name",children:t||"No branch"})]}),c]}),g&&ss.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"branch-picker-backdrop",onClick:()=>x(!1)}),e.jsxs("div",{className:"branch-picker-dropdown",onKeyDown:N,onMouseDown:o=>o.stopPropagation(),onClick:o=>o.stopPropagation(),children:[e.jsx("div",{className:"branch-picker-search",children:e.jsx("input",{ref:R,className:"branch-picker-input",type:"text",value:m,onChange:o=>C(o.target.value),placeholder:y?h("ide.scm.newBranchPlaceholder")||"New branch name...":h("ide.scm.branchSearchPlaceholder")||"Select a branch or tag to checkout"})}),!y&&e.jsx("div",{className:"branch-picker-actions",children:e.jsxs("button",{className:"branch-picker-action",onClick:I,children:[e.jsx(je,{size:14}),e.jsx("span",{children:h("ide.scm.createBranch")||"Create new branch..."})]})}),y&&e.jsx("div",{className:"branch-picker-actions",children:e.jsxs("button",{className:"branch-picker-action branch-picker-action-confirm",onClick:O,disabled:!m.trim(),children:[e.jsx(je,{size:14}),e.jsx("span",{children:m.trim()?`Create branch "${m.trim()}"`:h("ide.scm.newBranchPlaceholder")||"Type branch name..."})]})}),j.length>0&&e.jsx(Ma,{flatList:j,localCount:T.length,remoteCount:$.length,currentBranch:t,highlightIdx:S,onSelect:A,onHover:f}),a&&j.length===0&&e.jsx("div",{className:"branch-picker-empty",children:"Loading..."}),!a&&j.length===0&&!y&&e.jsx("div",{className:"branch-picker-empty",children:D?h("ide.scm.noBranchMatch")||"No matching branches":h("ide.scm.noBranchMatch")||"No branches found"})]})]}),document.body)]})}const Ce=40,Le=24;function Ma({flatList:t,localCount:s,remoteCount:a,currentBranch:i,highlightIdx:l,onSelect:r,onHover:c}){const u=n.useRef(null),[d,h]=n.useState(0),[g,b]=n.useState(300);n.useEffect(()=>{const f=u.current;if(!f)return;const y=new ResizeObserver(P=>{for(const R of P)b(R.contentRect.height)});return y.observe(f),()=>y.disconnect()},[]),n.useEffect(()=>{const f=u.current;if(!f)return;const y=l*Ce;y<f.scrollTop?f.scrollTop=y:y+Ce>f.scrollTop+g&&(f.scrollTop=y+Ce-g)},[l,g]);const m=n.useCallback(f=>{h(f.target.scrollTop)},[]),C=t.length*Ce+(s>0&&a>0?Le:0)+(a>0?Le:0),D=Math.max(0,Math.floor(d/Ce)-2),E=Math.min(t.length,Math.ceil((d+g)/Ce)+2),S=[];s>0&&a>0&&D===0&&S.push(e.jsx("div",{className:"branch-picker-group-label",style:{height:Le},children:"branches"},"label-local"));for(let f=D;f<E;f++){const y=t[f];y&&(f===s&&a>0&&S.push(e.jsx("div",{className:"branch-picker-group-label",style:{height:Le},children:"remotes"},"label-remote")),S.push(e.jsx(Pa,{branch:y,isCurrent:y.name===i,isHighlighted:f===l,dataIdx:f,onSelect:r,onHover:()=>c(f)},y.name)))}return e.jsx("div",{ref:u,className:"branch-picker-list",onScroll:m,children:e.jsx("div",{style:{height:C,position:"relative"},children:e.jsx("div",{style:{position:"absolute",top:D*Ce,left:0,right:0},children:S})})})}function Pa({branch:t,isCurrent:s,isHighlighted:a,dataIdx:i,onSelect:l,onHover:r}){return e.jsxs("div",{className:`branch-picker-item ${a?"highlighted":""} ${s?"current":""}`,"data-idx":i,onClick:()=>l(t.name),onMouseEnter:r,title:t.lastCommitMessage?`${t.name}
|
|
93
93
|
${t.lastCommitAuthor} • ${t.lastCommitHash} • ${t.lastCommitMessage}`:t.name,children:[e.jsxs("div",{className:"branch-picker-item-main",children:[e.jsx(Se,{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(vt,{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 dt={image:"Image",svg:"SVG",markdown:"Markdown Preview",pdf:"PDF",binary:"Binary"};function Ft({language:t,cursorLine:s,cursorColumn:a,selectedCount:i,selectedLines:l,viewMode:r="editor",isDirty:c=!1,saveStatus:u="idle",saveError:d,imageInfo:h,zoom:g,extraRight:b}){const{t:m}=te();if(r==="image"||r==="svg")return e.jsxs("div",{className:"editor-statusbar",children:[e.jsxs("div",{className:"editor-statusbar-left",children:[e.jsx(qe,{}),h&&e.jsxs("span",{className:"editor-statusbar-item",children:[h.width," × ",h.height]})]}),e.jsxs("div",{className:"editor-statusbar-right",children:[g!=null&&e.jsxs("span",{className:"editor-statusbar-item",children:[Math.round(g*100),"%"]}),e.jsx("span",{className:"editor-statusbar-item",children:dt[r]}),b]})]});if(r!=="editor")return e.jsxs("div",{className:"editor-statusbar",children:[e.jsx("div",{className:"editor-statusbar-left",children:e.jsx(qe,{})}),e.jsxs("div",{className:"editor-statusbar-right",children:[e.jsx("span",{className:"editor-statusbar-item",children:dt[r]||r}),b]})]});const C=`Ln ${s}, Col ${a}`;let D="";return i&&i>0&&(D=` (${i} ${m("editor.selected")})`,l&&l>1&&(D=` (${i} ${m("editor.selected")}, ${l} ${m("editor.lines")})`)),e.jsxs("div",{className:"editor-statusbar",children:[e.jsxs("div",{className:"editor-statusbar-left",children:[e.jsx(Da,{isDirty:c,saveStatus:u,saveError:d,translate:m}),e.jsx(qe,{}),e.jsxs("span",{className:"editor-statusbar-item editor-statusbar-cursor",children:[C,D]})]}),e.jsxs("div",{className:"editor-statusbar-right",children:[t&&e.jsx("span",{className:"editor-statusbar-item editor-statusbar-language",children:t}),b]})]})}function Da({isDirty:t,saveStatus:s,saveError:a,translate:i}){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"}),i("editor.saving")]}):s==="error"?e.jsx("span",{className:"editor-statusbar-item editor-statusbar-save editor-statusbar-save-error",role:"status",title:a,children:i("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"}),i("editor.unsaved")]}):null}function qe(){const{currentBranch:t,branches:s,branchesLoading:a,isGitRepo:i,switchBranch:l,createBranch:r,loadBranches:c,refresh:u}=me(),[d,h]=n.useState(!1);n.useEffect(()=>{u()},[u]);const g=n.useCallback(m=>{l(m),h(!1)},[l]),b=n.useCallback(m=>{r(m),h(!1)},[r]);return i?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"editor-statusbar-branch",onClick:m=>{m.stopPropagation(),h(C=>!C)},onPointerDown:m=>m.stopPropagation(),onMouseDown:m=>m.stopPropagation(),"aria-expanded":d,title:t||"No branch",children:[e.jsx(Se,{size:12}),e.jsx("span",{children:t||"No branch"})]}),d&&e.jsx($t,{currentBranch:t,branches:s,branchesLoading:a,onSwitch:g,onCreate:b,onLoadBranches:c,defaultOpen:!0,onClose:()=>h(!1)})]}):null}function Ve(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"}function At({actions:t,onRequestClose:s}){const{t:a}=te(),{tabs:i,activeTabId:l,rootPath:r,setActiveTab:c,closeSavedTabs:u,reorderTabs:d,pinTab:h,unpinTab:g}=se(),[b,m]=n.useState(null),C=n.useRef(null),[D,E]=n.useState(null),S=n.useRef(-1),f=n.useRef(null),[y,P]=n.useState(!1),[R,x]=n.useState(!1),T=n.useMemo(()=>as(i),[i]),$=n.useCallback(()=>{const p=f.current;p&&(P(p.scrollLeft>0),x(p.scrollLeft+p.clientWidth<p.scrollWidth-1))},[]);n.useEffect(()=>{const p=f.current;if(!p)return;$(),p.addEventListener("scroll",$,{passive:!0});const L=new ResizeObserver($);return L.observe(p),()=>{p.removeEventListener("scroll",$),L.disconnect()}},[$,i.length]),n.useEffect(()=>{if(!l||!f.current)return;const L=f.current.querySelector(".editor-tab.active");L&&L.scrollIntoView({block:"nearest",inline:"nearest",behavior:Ve()})},[l]);const j=n.useCallback(()=>{var p;(p=f.current)==null||p.scrollBy({left:-150,behavior:Ve()})},[]),N=n.useCallback(()=>{var p;(p=f.current)==null||p.scrollBy({left:150,behavior:Ve()})},[]),A=n.useCallback(p=>{const L=i[p];L&&(c(L.id),requestAnimationFrame(()=>{var M,Z;const V=(M=f.current)==null?void 0:M.querySelectorAll('[role="tab"]');(Z=V==null?void 0:V[p])==null||Z.focus()}))},[c,i]),I=n.useCallback((p,L)=>{let V=null;p.key==="ArrowLeft"&&(V=(L-1+i.length)%i.length),p.key==="ArrowRight"&&(V=(L+1)%i.length),p.key==="Home"&&(V=0),p.key==="End"&&(V=i.length-1),V!==null&&(p.preventDefault(),A(V))},[A,i.length]),O=n.useCallback((p,L)=>{p.preventDefault(),m({x:p.clientX,y:p.clientY,tabId:L})},[]),o=n.useCallback(()=>{m(null)},[]),w=n.useCallback((p,L)=>{p.button===1&&(p.preventDefault(),s({kind:"single",id:L}).catch(()=>{}))},[s]),G=n.useCallback((p,L)=>{S.current=L,p.dataTransfer.effectAllowed="move",p.currentTarget instanceof HTMLElement&&p.dataTransfer.setDragImage(p.currentTarget,0,0)},[]),Y=n.useCallback((p,L)=>{p.preventDefault(),p.dataTransfer.dropEffect="move",E(L)},[]),z=n.useCallback((p,L)=>{p.preventDefault();const V=S.current;V>=0&&V!==L&&d(V,L),S.current=-1,E(null)},[d]),H=n.useCallback(()=>{S.current=-1,E(null)},[]),_=n.useCallback(p=>{const L=i.find(V=>V.id===p);L&&Ne(L.path),o()},[i,o]),F=n.useCallback(p=>{const L=i.find(V=>V.id===p);if(L&&r){const V=L.path.startsWith(r+"/")?L.path.slice(r.length+1):L.path;Ne(V)}else L&&Ne(L.path);o()},[i,r,o]),B=n.useCallback(p=>{const L=i.find(V=>V.id===p);if(L){const{selectPath:V,toggleExpand:M,expandedPaths:Z}=se.getState(),le=L.path.split("/");for(let ue=1;ue<le.length;ue++){const J=le.slice(0,ue).join("/");J&&!Z.has(J)&&M(J)}V(L.path)}o()},[i,o]),X=n.useCallback(p=>{s(p).catch(()=>{}),o()},[o,s]);if(i.length===0)return null;const q=b?i.find(p=>p.id===b.tabId):null;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"editor-tabs-wrapper",children:[y&&e.jsx("button",{className:"editor-tabs-scroll-btn","aria-label":a("editor.scrollTabsLeft"),onClick:j,children:e.jsx(Bs,{size:14})}),e.jsx("div",{className:"editor-tabs",ref:f,role:"tablist","aria-label":a("editor.openEditors"),children:i.map((p,L)=>{let V=null,M="";p.saveStatus==="saving"?(V="saving",M=a("editor.saving")):p.saveStatus==="error"?(V="error",M=`${a("editor.saveFailed")}${p.saveError?`: ${p.saveError}`:""}`):p.isDirty&&(V="dirty",M=a("editor.unsaved"));const Z=T.get(p.id),le=M?`${p.path} — ${M}`:p.path,ue=M?`${p.name}, ${M}`:p.name;return e.jsxs("div",{className:`editor-tab${p.id===l?" active":""}${D===L?" drag-indicator":""}`,onMouseDown:J=>w(J,p.id),onContextMenu:J=>O(J,p.id),title:le,draggable:!0,onDragStart:J=>G(J,L),onDragOver:J=>Y(J,L),onDrop:J=>z(J,L),onDragEnd:H,children:[e.jsxs("button",{type:"button",className:"editor-tab-main",role:"tab",tabIndex:p.id===l?0:-1,"aria-selected":p.id===l,"aria-label":ue,onClick:()=>c(p.id),onKeyDown:J=>I(J,L),children:[e.jsx(xe,{name:p.name,type:"file",size:14}),e.jsx("span",{className:"editor-tab-name",children:p.name}),Z&&e.jsx("span",{className:"editor-tab-description",children:Z}),p.isPinned&&e.jsx("span",{className:"pin-icon",title:a("editor.pin"),children:e.jsx(ns,{size:14})}),e.jsxs("span",{className:"editor-tab-state",children:[V==="saving"&&e.jsx("span",{className:"tab-save-indicator",title:M,children:e.jsx("span",{className:"tab-save-spinner","aria-hidden":"true"})}),V==="error"&&e.jsx("span",{className:"tab-save-indicator tab-save-error",title:M,"aria-hidden":"true",children:"!"}),V==="dirty"&&e.jsx("span",{className:"tab-save-indicator",title:M,children:e.jsx("span",{className:"dirty-dot","aria-hidden":"true"})})]})]}),e.jsx("button",{type:"button",className:`close-btn${V?"":" clean-close"}`,tabIndex:p.id===l?0:-1,"aria-label":a("editor.closeTabAriaLabel",{name:p.name}),onClick:()=>{s({kind:"single",id:p.id}).catch(()=>{})},children:e.jsx(jt,{size:12})})]},p.id)})}),R&&e.jsx("button",{className:"editor-tabs-scroll-btn","aria-label":a("editor.scrollTabsRight"),onClick:N,children:e.jsx(ce,{size:14})}),t&&e.jsx("div",{className:"editor-tabs-actions",children:t})]}),b&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-context-overlay",onClick:o}),e.jsxs("div",{ref:C,className:"editor-context-menu",style:{left:b.x,top:b.y},children:[q!=null&&q.isPinned?e.jsx("button",{onClick:()=>{g(b.tabId),o()},children:a("editor.unpin")}):e.jsx("button",{onClick:()=>{h(b.tabId),o()},children:a("editor.pin")}),e.jsx("div",{className:"editor-context-separator"}),e.jsx("button",{onClick:()=>_(b.tabId),children:a("editor.copyPath")}),e.jsx("button",{onClick:()=>F(b.tabId),children:a("editor.copyRelativePath")}),e.jsx("button",{onClick:()=>B(b.tabId),children:a("editor.revealInExplorer")}),e.jsx("div",{className:"editor-context-separator"}),e.jsx("button",{onClick:()=>X({kind:"single",id:b.tabId}),children:a("editor.close")}),e.jsx("button",{onClick:()=>X({kind:"others",id:b.tabId}),children:a("editor.closeOthers")}),e.jsx("button",{onClick:()=>X({kind:"right",id:b.tabId}),children:a("editor.closeToRight")}),e.jsx("button",{onClick:()=>{u(),o()},children:a("editor.closeSaved")}),e.jsx("button",{onClick:()=>X({kind:"all"}),children:a("editor.closeAll")})]})]})]})}const za=cs,st=ls;function ut({path:t,onImageInfo:s,onZoomChange:a}){const{t:i}=te(),l=n.useRef(null),r=n.useRef(null),[c,u]=n.useState("fit"),d=yt(st(t)),[h,g]=n.useState(null),[b,m]=n.useState(!1),[C,D]=n.useState({x:0,y:0}),E=n.useRef({x:0,y:0,tx:0,ty:0}),S=n.useCallback(()=>{if(!l.current||!h)return 1;const O=l.current.clientWidth-40,o=l.current.clientHeight-80;return O<=0||o<=0?1:Math.min(O/h.w,o/h.h,1)},[h]),f=c==="fit"?S():c,y=n.useCallback(()=>{const O=r.current;if(!O)return;const o=O.naturalWidth,w=O.naturalHeight;g({w:o,h:w}),s==null||s({width:o,height:w})},[s]);n.useEffect(()=>{a==null||a(f)},[f,a]);const P=n.useCallback(O=>{!O.ctrlKey&&!O.metaKey||(O.preventDefault(),u(o=>{const w=o==="fit"?S():o,G=O.deltaY<0?.1:-.1;return Math.min(5,Math.max(.1,w+G))}))},[S]),R=n.useCallback(O=>{c!=="fit"&&(O.preventDefault(),m(!0),E.current={x:O.clientX,y:O.clientY,tx:C.x,ty:C.y})},[c,C]),x=n.useCallback(O=>{if(!b)return;const o=O.clientX-E.current.x,w=O.clientY-E.current.y;D({x:E.current.tx+o,y:E.current.ty+w})},[b]),T=n.useCallback(()=>{m(!1)},[]),$=()=>u(O=>Math.min(5,(O==="fit"?S():O)+.1)),j=()=>u(O=>Math.max(.1,(O==="fit"?S():O)-.1)),N=()=>{u("fit"),D({x:0,y:0})},A=()=>{u(1),D({x:0,y:0})},I=f>=3;return e.jsxs("div",{ref:l,className:"file-preview-image-container checkerboard",onWheel:P,onMouseDown:R,onMouseMove:x,onMouseUp:T,onMouseLeave:T,style:{cursor:c!=="fit"?b?"grabbing":"grab":"default"},children:[d&&e.jsx("img",{ref:r,src:d,alt:t,onLoad:y,className:I?"pixelated":"",style:{transform:`translate(${C.x}px, ${C.y}px) scale(${f})`,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:j,title:i("filePreview.zoomOut"),children:e.jsx(Fe,{size:16})}),e.jsxs("span",{className:"image-zoom-label",children:[Math.round(f*100),"%"]}),e.jsx("button",{onClick:$,title:i("filePreview.zoomIn"),children:e.jsx(je,{size:16})}),e.jsx("button",{onClick:N,title:i("filePreview.fitToWindow"),children:e.jsx(kt,{size:16})}),e.jsx("button",{onClick:A,title:i("filePreview.actualSize"),children:e.jsx(da,{size:16})})]})]})}function Ea({className:t,children:s}){const a=gt(r=>r.resolved),i=(t||"").match(/language-(\w+)/),l=String(s).replace(/\n$/,"");return i?e.jsx("div",{className:"relative group my-3",children:e.jsx(za,{style:a==="dark"?os:ds,language:i[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:"bg-[var(--color-bg-tertiary)] px-1.5 py-0.5 rounded text-[13px]",children:s})}function Ra({content:t}){return e.jsx("div",{className:"file-preview-markdown",children:e.jsx("div",{className:"file-preview-markdown-content",children:e.jsx($s,{remarkPlugins:[Fs],components:{code:Ea},children:t})})})}function Ta({path:t}){const{t:s}=te(),a=yt(st(t));return a?e.jsx("iframe",{src:a,className:"file-preview-pdf",title:s("filePreview.pdfPreview")}):null}function La({path:t,name:s}){const{t:a}=te(),i=n.useCallback(()=>{fetch(st(t),{headers:$e()}).then(l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);return l.blob()}).then(l=>{const r=URL.createObjectURL(l),c=document.createElement("a");c.href=r,c.download=s,c.click(),URL.revokeObjectURL(r)}).catch(l=>{console.warn("[FilePreview] download failed:",String(l))})},[t,s]);return e.jsxs("div",{className:"file-preview-binary",children:[e.jsx(is,{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:a("filePreview.binaryNotSupported")}),e.jsxs("button",{onClick:i,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(rs,{size:16}),a("filePreview.download")]})]})}function It({path:t,name:s,content:a,viewMode:i,onImageInfo:l,onZoomChange:r}){switch(i){case"image":return e.jsx(ut,{path:t,onImageInfo:l,onZoomChange:r});case"svg":return e.jsx(ut,{path:t,onImageInfo:l,onZoomChange:r});case"markdown":return e.jsx(Ra,{content:a});case"pdf":return e.jsx(Ta,{path:t});case"binary":return e.jsx(La,{path:t,name:s});default:return null}}function $a(t,s=300){const[a,i]=n.useState(!1);return n.useEffect(()=>{if(!t){i(!1);return}const l=setTimeout(()=>i(!0),s);return()=>clearTimeout(l)},[t,s]),a}function Fa(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 Ot(t){return`file-tree-item-${encodeURIComponent(t)}`}function Bt({node:t,depth:s,isExpanded:a,isSelected:i,isMultiSelected:l,isRenaming:r,expandedPaths:c,selectedPath:u,selectedPaths:d,renamingPath:h,gitStatusMap:g,onToggleExpand:b,onSelect:m,onOpenFile:C,onConfirmRename:D,onCancelRename:E,onContextMenu:S,onDragStart:f,onDrop:y}){const P=t.type==="directory",R=12+s*12,x=g.get(t.path),T=se(M=>M.showHiddenFiles),$=$a(!!t.isLoading),j=n.useMemo(()=>Ge(t.children,T),[t.children,T]),[N,A]=n.useState(t.name),I=n.useRef(null),[O,o]=n.useState(!1);n.useEffect(()=>{if(r&&I.current){A(t.name),I.current.focus();const M=t.name.lastIndexOf(".");!P&&M>0?I.current.setSelectionRange(0,M):I.current.select()}},[r,t.name,P]);const w=n.useCallback(M=>{r||(m(t.path,{ctrl:M.ctrlKey||M.metaKey,shift:M.shiftKey}),P?b(t.path):!M.ctrlKey&&!M.metaKey&&!M.shiftKey&&C(t.path,t.name))},[r,t.path,P,t.name,m,b,C]),G=n.useCallback(()=>{r||P||C(t.path,t.name)},[r,P,t.path,t.name,C]),Y=n.useCallback(M=>{M.stopPropagation(),M.key==="Enter"?(M.preventDefault(),D(t.path,N)):M.key==="Escape"&&(M.preventDefault(),E())},[t.path,N,D,E]),z=n.useCallback(()=>{D(t.path,N)},[t.path,N,D]),H=n.useCallback(M=>{M.preventDefault(),S(M,t.path)},[S,t.path]),_=n.useCallback(M=>{const Z=l?[...d]:[t.path];M.dataTransfer.effectAllowed="copyMove",M.dataTransfer.setData("text/plain",JSON.stringify(Z)),M.dataTransfer.setData("application/x-file-paths",JSON.stringify(Z)),f(Z)},[l,d,t.path,f]),F=n.useCallback(M=>{P&&(M.preventDefault(),M.dataTransfer.dropEffect="move",o(!0))},[P]),B=n.useCallback(()=>{o(!1)},[]),X=n.useCallback(M=>{M.preventDefault(),o(!1),P&&y(t.path)},[P,t.path,y]),q=i||l,p=x?`Git: ${x}`:void 0,L=12,V=12;return e.jsxs("div",{id:Ot(t.path),role:"treeitem","aria-level":s+1,"aria-expanded":P?a:void 0,"aria-selected":q,"aria-label":p?`${t.name}, ${p}`:t.name,"data-path":t.path,title:p?`${t.path} (${p})`:t.path,children:[e.jsxs("div",{className:`file-tree-item ${q?"selected":""} ${O?"drag-over":""}`,onClick:w,onDoubleClick:G,onContextMenu:H,draggable:!r,onDragStart:_,onDragOver:F,onDragLeave:B,onDrop:X,children:[Array.from({length:s},(M,Z)=>e.jsx("span",{className:"file-tree-indent-guide",style:{left:V+Z*L+6}},Z)),e.jsx("span",{style:{width:R,flexShrink:0}}),P?$?e.jsx(ve,{size:16,className:"file-tree-chevron animate-spin"}):e.jsx(ce,{size:16,className:`file-tree-chevron ${a?"expanded":""}`}):e.jsx(xe,{name:t.name,type:t.type,isExpanded:a,size:16}),r?e.jsx("input",{ref:I,className:"file-tree-rename-input",value:N,onChange:M=>A(M.target.value),onKeyDown:Y,onBlur:z,onClick:M=>M.stopPropagation()}):e.jsx("span",{className:`file-tree-item-name${x?` git-status-${x}`:""}`,children:t.name}),x&&!P&&e.jsx("span",{className:`file-tree-git-badge git-status-${x}`,"aria-label":p,title:p,children:Fa(x)})]}),P&&a&&e.jsx("div",{role:"group",children:j.map(M=>e.jsx(Bt,{node:M,depth:s+1,isExpanded:c.has(M.path),isSelected:u===M.path,isMultiSelected:d.has(M.path),isRenaming:h===M.path,expandedPaths:c,selectedPath:u,selectedPaths:d,renamingPath:h,gitStatusMap:g,onToggleExpand:b,onSelect:m,onOpenFile:C,onConfirmRename:D,onCancelRename:E,onContextMenu:S,onDragStart:f,onDrop:y},M.path))})]})}function _t(t){var K;const{t:s}=te(),a=us(v=>v.info),{rootPath:i,tree:l,treeLoading:r,treeError:c,expandedPaths:u,selectedPath:d,selectedPaths:h,tabs:g,renamingPath:b,setRootPath:m,toggleExpand:C,selectPath:D,openFile:E,refreshTree:S,collapseAll:f,createNewFile:y,createNewFolder:P,startRename:R,startCreateFile:x,startCreateFolder:T,confirmRename:$,cancelRename:j,deleteSelected:N,moveToDirectory:A,showHiddenFiles:I,toggleShowHiddenFiles:O}=se(),o=me(v=>v.files),w=n.useMemo(()=>{const v=new Map;if(!o.length||!i)return v;const k={conflicted:6,deleted:5,modified:4,renamed:3,added:2,copied:1,untracked:0};for(const Q of o){const U=Q.path.startsWith("/")?Q.path:`${i}/${Q.path}`;v.set(U,Q.status);let ee=U.substring(0,U.lastIndexOf("/"));for(;ee&&ee.length>=i.length;){const re=v.get(ee);(!re||(k[Q.status]??0)>(k[re]??0))&&v.set(ee,Q.status),ee=ee.substring(0,ee.lastIndexOf("/"))}}return v},[o,i]),G=n.useMemo(()=>Ge(l==null?void 0:l.children,I),[l==null?void 0:l.children,I]),[Y,z]=n.useState(!1),[H,_]=n.useState(!1),[F,B]=n.useState(!1),X=n.useRef(null),[q,p]=n.useState(null),L=n.useRef([]);n.useEffect(()=>{const v=wt().has("path");a!=null&&a.cwd&&!i&&!v?m(a.cwd):i&&!l&&!r&&!c&&m(i)},[a==null?void 0:a.cwd,i,l,r,c,m]);const V=n.useCallback(v=>{_(!1),m(v)},[m]),M=n.useCallback((v,k)=>{E(v,k)},[E]),Z=n.useCallback((v,k)=>{$(v,k)},[$]),le=n.useCallback((v,k)=>{v.preventDefault(),h.has(k)||D(k),p({x:v.clientX,y:v.clientY,path:k})},[h,D]),ue=n.useCallback(()=>p(null),[]),J=n.useCallback(()=>{q&&(R(q.path),p(null))},[q,R]),ae=n.useCallback((v,k)=>{if(!v)return null;if(v.path===k)return v;if(v.children)for(const Q of v.children){const U=ae(Q,k);if(U)return U}return null},[]),ye=q?((K=ae(l,q.path))==null?void 0:K.type)==="directory":!1,ke=n.useCallback(()=>{if(h.size===0)return;const v=[...h],k=v.some(U=>{var ee;return((ee=ae(l,U))==null?void 0:ee.type)==="directory"}),Q=g.some(U=>U.isDirty&&v.some(ee=>U.path===ee||U.path.startsWith(`${ee}/`)));if(v.length>1||k||Q){B(!0);return}N().catch(()=>{})},[N,ae,h,g,l]),Ae=n.useCallback(()=>{p(null),ke()},[ke]),Pe=n.useCallback(()=>{B(!1),N().catch(()=>{})},[N]),De=n.useCallback(v=>{if(!q)return;const k=ae(l,q.path),Q=(k==null?void 0:k.type)==="directory"?q.path:q.path.substring(0,q.path.lastIndexOf("/"));if(Q){u.has(Q)||C(Q);const U=`${Q}/__new_${v}__`;v==="file"?x(U):T(U)}p(null)},[q,u,ae,x,T,C,l]),Ie=n.useCallback(()=>{q&&(Ne(q.path),p(null))},[q]),ze=n.useCallback(()=>{if(q&&i){const v=q.path.startsWith(i+"/")?q.path.slice(i.length+1):q.path;Ne(v),p(null)}},[q,i]),ge=n.useCallback(v=>{L.current=v},[]),Ee=n.useCallback(v=>{const k=L.current;L.current=[],k.length!==0&&A(k,v).catch(Q=>{const U=Q instanceof Error?Q.message:String(Q);Ct.error(`${s("editor.moveFailed")}: ${U}`)})},[A,s]),Re=n.useCallback(v=>{if(b||!l)return;const k=hs(l,u,I);if(k.length===0)return;const Q=d?k.indexOf(d):-1,U=d?ae(l,d):null;function ee(re,Oe=!1){var we,oe;D(re,{shift:Oe}),(oe=(we=X.current)==null?void 0:we.querySelector(`[data-path="${CSS.escape(re)}"]`))==null||oe.scrollIntoView({block:"nearest"})}switch(v.key){case"ArrowDown":{v.preventDefault();const re=Q<k.length-1?Q+1:0;ee(k[re],v.shiftKey);break}case"ArrowUp":{v.preventDefault();const re=Q>0?Q-1:k.length-1;ee(k[re],v.shiftKey);break}case"ArrowRight":{if(v.preventDefault(),(U==null?void 0:U.type)!=="directory")break;if(!u.has(U.path))C(U.path);else{const re=Ge(U.children,I)[0];re&&ee(re.path)}break}case"ArrowLeft":{if(v.preventDefault(),(U==null?void 0:U.type)==="directory"&&u.has(U.path)){C(U.path);break}if(d){const re=d.substring(0,d.lastIndexOf("/"));k.includes(re)&&ee(re)}break}case"Enter":case" ":{v.preventDefault(),(U==null?void 0:U.type)==="directory"?C(U.path):U&&E(U.path,U.name);break}case"F2":{v.preventDefault(),d&&R(d);break}case"Delete":case"Backspace":{v.preventDefault(),h.size>0&&ke();break}}},[l,u,d,h,b,I,ae,D,C,R,E,ke]);n.useEffect(()=>{if(!d)return;const v=setTimeout(()=>{var U;const k=(U=X.current)==null?void 0:U.querySelector(`[data-path="${CSS.escape(d)}"]`),Q=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth";k==null||k.scrollIntoView({block:"nearest",behavior:Q})},60);return()=>clearTimeout(v)},[d]);const W=(l==null?void 0:l.name)||(i==null?void 0:i.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":!Y,onClick:()=>z(v=>!v),children:[Y?e.jsx(ce,{size:12,style:{flexShrink:0}}):e.jsx(he,{size:12,style:{flexShrink:0}}),e.jsx("span",{className:"file-tree-section-name",children:W.toUpperCase()})]}),e.jsxs("div",{className:"file-tree-section-actions",children:[e.jsx("button",{className:"file-tree-section-action",onClick:y,title:s("editor.newFile"),"aria-label":s("editor.newFile"),children:e.jsx(Xs,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:P,title:s("editor.newFolder"),"aria-label":s("editor.newFolder"),children:e.jsx(ta,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:()=>_(!0),title:s("editor.openFolder"),"aria-label":s("editor.openFolder"),children:e.jsx(ms,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:()=>{S().catch(()=>{})},title:s("editor.refresh"),"aria-label":s("editor.refresh"),children:e.jsx(Me,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:f,title:s("editor.collapseAll"),"aria-label":s("editor.collapseAll"),children:e.jsx(Ws,{size:14})}),e.jsx("button",{className:"file-tree-section-action",onClick:O,title:s(I?"editor.hideHiddenFiles":"editor.showHiddenFiles"),"aria-label":s(I?"editor.hideHiddenFiles":"editor.showHiddenFiles"),children:I?e.jsx(Ks,{size:14}):e.jsx(qs,{size:14})})]})]}),H&&e.jsx(fs,{initialPath:i||(a==null?void 0:a.cwd)||"/",onSelect:V,onClose:()=>_(!1)}),F&&e.jsx(Nt,{title:s("editor.deleteConfirmTitle"),message:s("editor.deleteConfirmMessage",{count:h.size}),confirmLabel:s("editor.delete"),danger:!0,onConfirm:Pe,onCancel:()=>B(!1)}),!Y&&e.jsxs("div",{className:"file-tree-content",ref:X,role:"tree","aria-label":s("editor.fileTreeAriaLabel"),"aria-multiselectable":"true","aria-activedescendant":d?Ot(d):void 0,tabIndex:0,onKeyDown:Re,onClick:()=>{var v;return(v=X.current)==null?void 0:v.focus()},children:[r&&!l&&e.jsx("div",{className:"file-tree-loading",children:e.jsx(ve,{size:16,className:"animate-spin"})}),!r&&!l&&c&&i&&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(i),children:[e.jsx(Me,{size:12}),s("editor.refresh")]}),(a==null?void 0:a.cwd)&&i!==a.cwd&&e.jsxs("button",{className:"file-tree-retry-btn",onClick:()=>m(a.cwd),children:[e.jsx(aa,{size:12}),s("editor.backToWorkDir")]})]}),G.map(v=>e.jsx(Bt,{node:v,depth:0,isExpanded:u.has(v.path),isSelected:d===v.path,isMultiSelected:h.has(v.path),isRenaming:b===v.path,expandedPaths:u,selectedPath:d,selectedPaths:h,renamingPath:b,gitStatusMap:w,onToggleExpand:C,onSelect:D,onOpenFile:M,onConfirmRename:Z,onCancelRename:j,onContextMenu:le,onDragStart:ge,onDrop:Ee},v.path)),G.length===0&&(l==null?void 0:l.children)&&e.jsx("div",{className:"file-tree-empty",children:s("editor.emptyFolder")})]}),q&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-context-overlay",onClick:ue}),e.jsxs("div",{className:"editor-context-menu",style:{left:q.x,top:q.y},children:[ye&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>De("file"),children:s("editor.newFile")}),e.jsx("button",{onClick:()=>De("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:ze,children:s("editor.copyRelativePath")}),e.jsx("div",{className:"editor-context-separator"}),h.size<=1&&e.jsx("button",{onClick:J,children:s("editor.rename")}),e.jsx("button",{className:"danger",onClick:Ae,children:h.size>1?`${s("editor.delete")} (${h.size})`:s("editor.delete")})]})]})]})}function Aa(t,s){fetch(`/api/v1/pty/${t}/input/send`,{method:"POST",headers:{...$e(),"Content-Type":"application/json"},body:JSON.stringify({data:s})}).catch(()=>{})}function Ia(t){return/^[a-zA-Z0-9_./-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function Wt(){const{t}=te(),{bottomTerminals:s,activeBottomTerminalId:a,bottomPanelMaximized:i,createBottomTerminal:l,closeBottomTerminal:r,closeOtherBottomTerminals:c,closeBottomTerminalsToRight:u,closeAllBottomTerminals:d,setActiveBottomTerminal:h,setBottomPanelCollapsed:g,toggleBottomPanelMaximize:b}=ne(),m=ps(o=>o.cwd),[C,D]=n.useState(null),E=n.useCallback((o,w)=>{o.preventDefault(),D({x:o.clientX,y:o.clientY,tabId:w})},[]),S=n.useCallback(()=>{D(null)},[]),f=xs(o=>o.panes),y=n.useRef(null);n.useEffect(()=>{const o=setTimeout(()=>{window.dispatchEvent(new Event("resize"))},60);return()=>clearTimeout(o)},[]),n.useEffect(()=>{if(!a||!y.current)return;const w=y.current.querySelector(".ide-bottom-tab.active");w&&w.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})},[a]);const P=n.useCallback(()=>{l()},[l]),R=n.useCallback((o,w)=>{o.stopPropagation(),r(w)},[r]),x=n.useCallback(()=>{g(!0)},[g]),[T,$]=n.useState(!1),j=n.useRef(0),N=n.useCallback(o=>{o.preventDefault(),o.stopPropagation(),j.current++,(o.dataTransfer.types.includes("text/plain")||o.dataTransfer.types.includes("application/x-file-paths"))&&$(!0)},[]),A=n.useCallback(o=>{o.preventDefault(),o.stopPropagation(),o.dataTransfer.dropEffect="copy"},[]),I=n.useCallback(o=>{o.preventDefault(),o.stopPropagation(),j.current--,j.current<=0&&(j.current=0,$(!1))},[]),O=n.useCallback(o=>{o.preventDefault(),o.stopPropagation(),$(!1),j.current=0;let w=[];const G=o.dataTransfer.getData("application/x-file-paths")||o.dataTransfer.getData("text/plain");if(G)try{const _=JSON.parse(G);Array.isArray(_)&&(w=_)}catch{w=[G]}if(w.length===0&&o.dataTransfer.files.length>0)for(let _=0;_<o.dataTransfer.files.length;_++){const F=o.dataTransfer.files[_],B=F.path||F.webkitRelativePath||F.name;B&&w.push(B)}if(w.length===0)return;const Y=a;if(!Y)return;const z=f[Y];if(!(z!=null&&z.ptySessionId))return;const H=w.map(Ia).join(" ");Aa(z.ptySessionId,H),setTimeout(()=>{const _=document.querySelector('.ide-bottom-terminal-wrap[style*="flex"] .xterm-helper-textarea');_==null||_.focus()},50)},[a,f]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`ide-bottom-panel ${T?"drop-highlight":""}`,onDragEnter:N,onDragOver:A,onDragLeave:I,onDrop:O,children:[e.jsxs("div",{className:"ide-bottom-tabs",children:[e.jsx("div",{className:"ide-bottom-tabs-list",ref:y,onDoubleClick:o=>{o.target===o.currentTarget&&P()},children:s.map((o,w)=>{const G=f[o],Y=(G==null?void 0:G.title)||`Terminal ${w+1}`,z=o===a;return e.jsxs("button",{className:`ide-bottom-tab ${z?"active":""}`,onClick:()=>h(o),onDoubleClick:()=>b(),onContextMenu:H=>E(H,o),children:[e.jsx("span",{className:"ide-bottom-tab-title",title:Y,children:Y}),e.jsx("span",{className:"ide-bottom-tab-close",onClick:H=>R(H,o),children:e.jsx(jt,{size:14})})]},o)})}),e.jsxs("div",{className:"ide-bottom-tabs-actions",children:[e.jsx("button",{className:"ide-bottom-action-btn",onClick:P,title:t("ide.newTerminal"),children:e.jsx(je,{size:16})}),e.jsx("button",{className:"ide-bottom-action-btn",onClick:b,title:i?t("ide.restorePanel")||"Restore Panel Size":t("ide.maximizePanel")||"Maximize Panel",children:i?e.jsx(gs,{size:16}):e.jsx(kt,{size:16})}),e.jsx("button",{className:"ide-bottom-action-btn",onClick:x,title:t("ide.hidePanel"),children:e.jsx(he,{size:16})})]})]}),e.jsxs("div",{className:"ide-bottom-content",children:[s.map(o=>e.jsx("div",{className:"ide-bottom-terminal-wrap",style:{display:o===a?"flex":"none"},children:e.jsx(bs,{paneId:o,initialCwd:m})},o)),s.length===0&&e.jsx("div",{className:"ide-bottom-empty",children:e.jsxs("button",{className:"ide-bottom-empty-btn",onClick:P,children:[e.jsx(je,{size:16}),e.jsx("span",{children:t("ide.newTerminal")||"New Terminal"})]})})]})]}),C&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-context-overlay",onClick:S}),e.jsxs("div",{className:"editor-context-menu",style:{left:C.x,top:C.y},children:[e.jsx("button",{onClick:()=>{r(C.tabId),S()},children:t("terminal.close")}),e.jsx("button",{onClick:()=>{c(C.tabId),S()},children:t("terminal.closeOthers")}),e.jsx("button",{onClick:()=>{u(C.tabId),S()},children:t("terminal.closeToRight")}),e.jsx("div",{className:"editor-context-separator"}),e.jsx("button",{onClick:()=>{d(),S()},children:t("terminal.closeAll")})]})]})]})}function ht(t){const{direction:s,initialSize:a,minSize:i=120,maxSize:l,collapsible:r=!0,collapseThreshold:c,defaultCollapsed:u=!1,onResize:d,onCollapse:h,onMaximize:g,maximizeThreshold:b=.92,reverse:m=!1,ariaLabel:C,keyboardStep:D=10}=t,[E,S]=n.useState(a),[f,y]=n.useState(u),[P,R]=n.useState(!1),x=n.useRef(null),T=n.useRef(a);n.useEffect(()=>{f||S(a)},[a,f]),n.useEffect(()=>{y(u)},[u]);const $=c??i*.6,j=n.useCallback(()=>{if(l)return l;const z=x.current;if(!(z!=null&&z.parentElement))return 1/0;const H=z.parentElement.getBoundingClientRect();return(s==="horizontal"?H.width:H.height)*.8},[s,l]),N=n.useCallback(z=>{const H=Math.max(i,Math.min(j(),z));S(H),T.current=H,d==null||d(H)},[i,j,d]),A=n.useCallback(()=>{y(z=>{const H=!z;if(H)T.current=E;else{const _=Math.max(i,T.current);S(_),d==null||d(_)}return h==null||h(H),H})},[E,i,d,h]),I=n.useCallback((z,H)=>{R(!0);const _=x.current;if(!_)return;const F=f?0:E,B=j(),q=(s==="horizontal"?_.clientWidth:_.clientHeight)*b;let p=!1;const L=()=>{R(!1),document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",Z),document.removeEventListener("pointercancel",Z),document.body.style.cursor="",document.body.style.userSelect="",document.body.classList.remove("ide-sash-dragging")},V=(le,ue)=>{if(p)return;let J;s==="horizontal"?J=le-z:J=ue-H,m&&(J=-J);const ae=F+J;if(r&&ae<$){f||(T.current=E>i?E:a,y(!0),h==null||h(!0));return}if(g&&ae>=q){p=!0,g(),L();return}f&&ae>=i&&(y(!1),h==null||h(!1));const ye=Math.max(i,Math.min(B,ae));S(ye),d==null||d(ye)},M=le=>V(le.clientX,le.clientY),Z=()=>L();document.addEventListener("pointermove",M),document.addEventListener("pointerup",Z),document.addEventListener("pointercancel",Z),document.body.style.cursor=s==="horizontal"?"col-resize":"row-resize",document.body.style.userSelect="none",document.body.classList.add("ide-sash-dragging")},[f,E,s,m,r,$,i,a,j,d,h,g,b]),O=n.useCallback(z=>{z.preventDefault(),z.stopPropagation(),I(z.clientX,z.clientY)},[I]),o=n.useCallback(z=>{if((z.key==="Enter"||z.key===" ")&&r){z.preventDefault(),A();return}if(z.key==="Home"){z.preventDefault(),f&&(y(!1),h==null||h(!1)),N(i);return}if(z.key==="End"){z.preventDefault(),f&&(y(!1),h==null||h(!1));const _=j();Number.isFinite(_)&&N(_);return}let H=0;s==="horizontal"?(z.key==="ArrowLeft"&&(H=-D),z.key==="ArrowRight"&&(H=D)):(z.key==="ArrowUp"&&(H=-D),z.key==="ArrowDown"&&(H=D)),H!==0&&(z.preventDefault(),m&&(H=-H),f&&(y(!1),h==null||h(!1)),N((f?i:E)+H))},[f,r,s,j,D,i,h,m,N,E,A]),w=["ide-sash",s==="horizontal"?"ide-sash-vertical":"ide-sash-horizontal",P?"dragging":""].filter(Boolean).join(" "),G=j(),Y=Number.isFinite(G)?G:Math.max(i,E);return{size:f?0:E,collapsed:f,sashProps:{onPointerDown:O,onDoubleClick:A,onKeyDown:o,className:w,role:"separator",tabIndex:0,"aria-label":C,"aria-orientation":s==="horizontal"?"vertical":"horizontal","aria-valuemin":r?0:i,"aria-valuemax":Math.round(Y),"aria-valuenow":Math.round(f?0:E)},containerRef:x,setSize:N,toggleCollapse:A,dragging:P}}function Oa(t){return[...t].sort((s,a)=>s.type==="directory"&&a.type!=="directory"?-1:s.type!=="directory"&&a.type==="directory"?1:s.name.localeCompare(a.name,void 0,{numeric:!0,sensitivity:"base"}))}function Ba({filePath:t,rootPath:s,onSegmentClick:a,onOpenFile:i}){const r=(t.startsWith(s)?t.slice(s.length).replace(/^\//,""):t).split("/").filter(Boolean),[c,u]=n.useState(null),[d,h]=n.useState([]),[g,b]=n.useState(!1),[m,C]=n.useState(-1),D=n.useRef(null),E=n.useRef(null),S=n.useCallback(async(x,T)=>{const $=T.getBoundingClientRect();u({dirPath:x,anchorRect:$}),b(!0),h([]),C(-1);try{const j=await St(x);h(Oa(j.map(N=>({name:N.name,path:N.path,type:N.type}))))}catch{h([])}b(!1)},[]),f=n.useCallback(()=>{u(null),h([]),C(-1)},[]),y=n.useCallback(x=>{x.type==="directory"?(a(x.path),f()):(i(x.path),f())},[a,i,f]);n.useEffect(()=>{if(!c)return;const x=T=>{if(T.key==="Escape"){T.preventDefault(),f();return}T.key==="ArrowDown"?(T.preventDefault(),C($=>$<d.length-1?$+1:0)):T.key==="ArrowUp"?(T.preventDefault(),C($=>$>0?$-1:d.length-1)):T.key==="Enter"&&m>=0&&m<d.length&&(T.preventDefault(),y(d[m]))};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[c,d,m,f,y]),n.useEffect(()=>{var x;m>=0&&E.current&&((x=E.current.querySelectorAll(".breadcrumb-dropdown-item")[m])==null||x.scrollIntoView({block:"nearest"}))},[m]);const P=n.useCallback((x,T)=>{x.stopPropagation();const $=x.currentTarget;c&&c.dirPath===T?f():S(T,$)},[c,S,f]),R=n.useCallback((x,T)=>{x.stopPropagation();const $=x.currentTarget;c&&c.dirPath===T?f():S(T,$)},[c,S,f]);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 ${r.length===0?"active":""}`,onClick:x=>P(x,s),children:e.jsx("span",{children:s.split("/").pop()||s})})}),r.map((x,T)=>{const $=T===r.length-1,j=s+"/"+r.slice(0,T+1).join("/"),N=T===0?s:s+"/"+r.slice(0,T).join("/");return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center"},children:[e.jsx("span",{className:"editor-breadcrumb-separator",children:e.jsx(ce,{size:10})}),e.jsxs("span",{className:`editor-breadcrumb-segment ${$?"active":""} ${(c==null?void 0:c.dirPath)===($?N:j)?"dropdown-open":""}`,onClick:A=>$?R(A,N):P(A,j),children:[$&&e.jsx(xe,{name:x,type:"file",size:14}),e.jsx("span",{style:$?{fontWeight:500}:void 0,children:x})]})]},j)}),c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"breadcrumb-dropdown-overlay",onClick:f}),e.jsx("div",{ref:D,className:"breadcrumb-dropdown",style:{left:Math.min(c.anchorRect.left,window.innerWidth-260),top:c.anchorRect.bottom+2},children:g?e.jsx("div",{className:"breadcrumb-dropdown-loading",children:e.jsx(ve,{size:14,className:"animate-spin"})}):d.length===0?e.jsx("div",{className:"breadcrumb-dropdown-empty",children:"Empty"}):e.jsx("div",{className:"breadcrumb-dropdown-list",ref:E,children:d.map((x,T)=>{const $=x.path===t,j=T===m;return e.jsxs("div",{className:`breadcrumb-dropdown-item ${$?"current":""} ${j?"highlighted":""}`,onClick:()=>y(x),children:[x.type==="directory"?e.jsx(ce,{size:12,style:{flexShrink:0,opacity:.5}}):e.jsx(xe,{name:x.name,type:x.type,size:16}),e.jsx("span",{className:"breadcrumb-dropdown-item-name",children:x.name})]},x.path)})})})]})]})}function _a(t,s){const a=t.toLowerCase(),i=s.toLowerCase();let l=0,r=0,c=-1;for(let u=0;u<i.length&&l<a.length;u++)i[u]===a[l]&&(r+=u===c+1?2:1,(u===0||i[u-1]==="/"||i[u-1]===".")&&(r+=3),c=u,l++);return{match:l===a.length,score:r}}const mt=20,Wa=3;function Ht({isOpen:t,onClose:s,onSelect:a,rootPath:i,showHiddenFiles:l}){const{t:r}=te(),[c,u]=n.useState(""),[d,h]=n.useState(0),[g,b]=n.useState([]),[m,C]=n.useState(!1),D=n.useRef(null),E=n.useRef(null),S=n.useRef(null),f=n.useId(),y=n.useRef(""),P=n.useRef([]),R=n.useCallback(async(j,N,A)=>{if(N>Wa)return[];try{const I=await St(j),O=[];for(const o of I){if(!l&&vs(o.name))continue;const w=A?`${A}/${o.name}`:o.name;if(o.type==="file"&&!js(o.path))O.push({name:o.name,path:o.path,relativePath:w});else if(o.type==="directory"){const G=await R(o.path,N+1,w);O.push(...G)}}return O}catch{return[]}},[l]);n.useEffect(()=>{if(!t)return;u(""),h(0),S.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const j=window.setTimeout(()=>{var I;return(I=D.current)==null?void 0:I.focus()},0),N=`${i}\0${l?"hidden":"visible"}`;if(y.current===N&&P.current.length>0)return b(P.current),C(!1),()=>{var I;window.clearTimeout(j),(I=S.current)==null||I.focus(),S.current=null};let A=!1;return C(!0),R(i,0,"").then(I=>{A||(y.current=N,P.current=I,b(I),C(!1))}),()=>{var I;A=!0,window.clearTimeout(j),(I=S.current)==null||I.focus(),S.current=null}},[t,i,l,R]);const x=n.useMemo(()=>{if(!c.trim())return g.slice(0,mt);const j=[];for(const N of g){const A=_a(c,N.relativePath);A.match&&j.push({entry:N,score:A.score})}return j.sort((N,A)=>A.score-N.score),j.slice(0,mt).map(N=>N.entry)},[g,c]);n.useEffect(()=>{h(0)},[x.length,c]);const T=n.useCallback(j=>{var N;switch(j.key){case"Tab":j.preventDefault(),(N=D.current)==null||N.focus();break;case"ArrowDown":j.preventDefault(),h(A=>(A+1)%Math.max(x.length,1));break;case"ArrowUp":j.preventDefault(),h(A=>(A-1+x.length)%Math.max(x.length,1));break;case"Enter":j.preventDefault(),x[d]&&a(x[d].path);break;case"Escape":j.preventDefault(),s();break}},[x,d,a,s]);if(n.useEffect(()=>{var N;const j=(N=E.current)==null?void 0:N.children[d];j==null||j.scrollIntoView({block:"nearest"})},[d]),!t)return null;const $=x[d]?`${f}-option-${d}`: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":r("editor.quickOpen"),onClick:j=>j.stopPropagation(),onKeyDown:T,children:[e.jsx("input",{ref:D,className:"quick-open-input",type:"text",role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":f,"aria-activedescendant":$,value:c,onChange:j=>u(j.target.value),placeholder:r("editor.quickOpenPlaceholder")}),e.jsx("div",{className:"quick-open-list",ref:E,id:f,role:"listbox","aria-busy":m,children:m?e.jsx("div",{className:"quick-open-empty",role:"status",children:r("editor.quickOpenLoading")}):x.length===0?e.jsx("div",{className:"quick-open-empty",role:"status",children:r("editor.quickOpenEmpty")}):x.map((j,N)=>e.jsxs("div",{id:`${f}-option-${N}`,role:"option","aria-selected":N===d,className:`quick-open-item${N===d?" active":""}`,onClick:()=>a(j.path),onMouseEnter:()=>h(N),children:[e.jsx(xe,{name:j.name,type:"file",size:14}),e.jsx("span",{className:"quick-open-item-name",children:j.name}),e.jsx("span",{className:"quick-open-item-path",children:j.relativePath})]},j.path))})]})})}function Ha({gitFileCount:t=0}){const{t:s}=te(),a=ne(g=>g.activePanel),i=ne(g=>g.sidePanelCollapsed),l=ne(g=>g.toggleActivePanel),r=ne(g=>g.bottomPanelCollapsed),c=ne(g=>g.toggleBottomPanel),u=nt(g=>g.isOpen),d=nt(g=>g.toggle),h=n.useCallback(g=>a===g&&!i,[a,i]);return e.jsxs("div",{className:"ide-activity-bar",children:[e.jsxs("div",{className:"ide-activity-bar-top",children:[e.jsx("button",{className:`ide-activity-btn ${h("explorer")?"active":""}`,onClick:()=>l("explorer"),title:s("ide.explorer")||"Explorer",children:e.jsx(Dt,{size:22,strokeWidth:1.5})}),e.jsx("button",{className:`ide-activity-btn ${h("search")?"active":""}`,onClick:()=>l("search"),title:s("ide.search")||"Search",children:e.jsx(et,{size:22,strokeWidth:1.5})}),e.jsxs("button",{className:`ide-activity-btn ${h("source-control")?"active":""}`,onClick:()=>l("source-control"),title:s("ide.sourceControl")||"Source Control",children:[e.jsx(Se,{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",{className:`ide-activity-btn ${r?"":"active"}`,onClick:c,title:s("ide.terminal")||"Terminal",children:e.jsx(ra,{size:22,strokeWidth:1.5})}),e.jsx("button",{className:`ide-activity-btn ${u?"active":""}`,onClick:d,title:s("sidebar.toggle")||"Toggle Sidebar",children:e.jsx(ys,{size:22,strokeWidth:1.5})})]})]})}function qa(){try{const t=localStorage.getItem("cbc_search_prefs");if(t)return{...ft,...JSON.parse(t)}}catch{}return ft}const ft={viewMode:"tree",caseSensitive:!1,isRegex:!1,wholeWord:!1,query:"",includePattern:"",excludePattern:"",useDefaultExcludes:!0};function fe(t){try{localStorage.setItem("cbc_search_prefs",JSON.stringify(t))}catch{}}function pe(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 be=qa(),Va=bt((t,s)=>({query:be.query,isRegex:be.isRegex,caseSensitive:be.caseSensitive,wholeWord:be.wholeWord,includePattern:be.includePattern,excludePattern:be.excludePattern,useDefaultExcludes:be.useDefaultExcludes,viewMode:be.viewMode,results:[],searching:!1,totalMatches:0,fileCount:0,error:null,setQuery:a=>{t({query:a}),fe(pe({...s(),query:a}))},search:async()=>{var b;const{query:a,isRegex:i,caseSensitive:l,wholeWord:r,includePattern:c,excludePattern:u,useDefaultExcludes:d}=s();if(!a.trim())return;const h=Ze();let g=u||void 0;if(d){const m="node_modules,**/.git,**/dist,**/build,**/.next,**/coverage";g=g?`${g},${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:{...$e(),"Content-Type":"application/json"},body:JSON.stringify({query:a.trim(),cwd:h||void 0,isRegex:i,caseSensitive:l,wholeWord:r,includeGlob:c||void 0,excludeGlob:g,maxResults:200})});if(m.ok){const C=await m.json(),E=(C.data??C).results||[],S=new Map;for(const y of E)S.has(y.path)||S.set(y.path,[]),S.get(y.path).push(y);const f=[];for(const[y,P]of S)f.push({path:y,matches:P});t({results:f,totalMatches:E.length,fileCount:f.length,searching:!1})}else{const C=await m.json().catch(()=>null),D=((b=C==null?void 0:C.error)==null?void 0:b.message)||`HTTP ${m.status}`;t({searching:!1,error:D})}}catch(m){t({searching:!1,error:m.message||"Search failed"})}},toggleRegex:()=>{t(a=>({isRegex:!a.isRegex})),fe(pe(s()))},toggleCaseSensitive:()=>{t(a=>({caseSensitive:!a.caseSensitive})),fe(pe(s()))},toggleWholeWord:()=>{t(a=>({wholeWord:!a.wholeWord})),fe(pe(s()))},setIncludePattern:a=>{t({includePattern:a}),fe(pe({...s(),includePattern:a}))},setExcludePattern:a=>{t({excludePattern:a}),fe(pe({...s(),excludePattern:a}))},toggleUseDefaultExcludes:()=>{t(a=>({useDefaultExcludes:!a.useDefaultExcludes})),fe(pe(s()))},setViewMode:a=>{t({viewMode:a}),fe(pe(s()))},clear:()=>{t({query:"",includePattern:"",excludePattern:"",results:[],totalMatches:0,fileCount:0,searching:!1,error:null}),fe(pe(s()))}}));function Ka(t){const s={children:[]};for(const i of t){const l=i.path.split("/");let r=s;for(let c=0;c<l.length;c++){const u=l[c];if(c===l.length-1)r.children.push({name:u,fullPath:i.path,isDir:!1,children:[],matches:i.matches,matchCount:i.matches.length});else{let h=r.children.find(g=>g.isDir&&g.name===u);h||(h={name:u,fullPath:l.slice(0,c+1).join("/"),isDir:!0,children:[],matchCount:0},r.children.push(h)),r=h}}}function a(i){if(i.isDir&&i.children.length===1&&i.children[0].isDir){const c=i.children[0];return a({...c,name:`${i.name}/${c.name}`})}const l=i.children.map(a),r=l.reduce((c,u)=>c+u.matchCount,0);return{...i,children:l,matchCount:i.isDir?r:i.matchCount}}return s.children.map(a)}function qt(){const{t}=te(),{query:s,isRegex:a,caseSensitive:i,wholeWord:l,includePattern:r,excludePattern:c,useDefaultExcludes:u,viewMode:d,results:h,searching:g,totalMatches:b,fileCount:m,error:C,setQuery:D,search:E,toggleRegex:S,toggleCaseSensitive:f,toggleWholeWord:y,setIncludePattern:P,setExcludePattern:R,toggleUseDefaultExcludes:x,setViewMode:T}=Va(),{openFile:$}=se(),j=n.useRef(null),[N,A]=n.useState(new Set),[I,O]=n.useState(!0);n.useEffect(()=>{var F;(F=j.current)==null||F.focus()},[]);const o=n.useCallback(()=>{const F=new Set;for(const B of h){F.add(B.path);const X=B.path.split("/");for(let q=1;q<X.length;q++)F.add(X.slice(0,q).join("/"))}return F},[h]);n.useEffect(()=>{A(o()),O(!0)},[o]);const w=n.useMemo(()=>Ka(h),[h]),G=n.useCallback(F=>{F.key==="Enter"&&(F.preventDefault(),E())},[E]),Y=n.useCallback(F=>{A(B=>{const X=new Set(B);return X.has(F)?X.delete(F):X.add(F),X})},[]),z=n.useCallback(()=>{A(new Set),O(!1)},[]),H=n.useCallback(()=>{A(o()),O(!0)},[o]),_=n.useCallback((F,B)=>{const X=B?{line:B,query:s.trim()}:void 0;$(F,void 0,X)},[$,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:j,className:"search-field-input",value:s,onChange:F=>D(F.target.value),onKeyDown:G,placeholder:t("ide.search.placeholder")}),e.jsxs("div",{className:"search-field-actions",children:[e.jsx("button",{className:`search-field-btn ${i?"active":""}`,onClick:f,title:t("ide.search.matchCase"),children:e.jsx(Is,{size:14})}),e.jsx("button",{className:`search-field-btn ${l?"active":""}`,onClick:y,title:t("ide.search.wholeWord"),children:e.jsx(pa,{size:14})}),e.jsx("button",{className:`search-field-btn ${a?"active":""}`,onClick:S,title:t("ide.search.regex"),children:e.jsx(ca,{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:r,onChange:F=>P(F.target.value),onKeyDown:G,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:c,onChange:F=>R(F.target.value),onKeyDown:G,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 ${u?"active":""}`,onClick:x,title:t("ide.search.useExcludeSettings")||"Use Exclude Settings and Ignore Files",children:e.jsx(ks,{size:14})})})]})]})]}),(g||b>0||C)&&e.jsxs("div",{className:"search-status-bar",children:[g&&e.jsxs("div",{className:"search-status",children:[e.jsx(ve,{size:14,className:"animate-spin"}),e.jsx("span",{children:t("ide.search.searching")})]}),!g&&b>0&&e.jsx("div",{className:"search-status",children:e.jsxs("span",{children:[b," results in ",m," files"]})}),C&&e.jsx("div",{className:"search-status search-error",children:C.includes("timed out")?t("ide.search.timedOut"):t("ide.search.failed")}),b>0&&e.jsxs("div",{className:"search-status-actions",children:[e.jsx("button",{className:`scm-icon-btn ${d==="list"?"active":""}`,onClick:()=>T("list"),title:t("ide.listView"),children:e.jsx(zt,{size:14})}),e.jsx("button",{className:`scm-icon-btn ${d==="tree"?"active":""}`,onClick:()=>T("tree"),title:t("ide.treeView"),children:e.jsx(Et,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:I?z:H,title:I?"Collapse All":"Expand All",children:I?e.jsx(Zs,{size:14}):e.jsx(ma,{size:14})})]})]}),e.jsxs("div",{className:"search-results",children:[d==="tree"&&w.map(F=>e.jsx(Vt,{node:F,depth:0,expandedPaths:N,onToggle:Y,onFileClick:_,query:s},F.fullPath)),d==="list"&&h.map(F=>e.jsxs("div",{className:"search-tree-group",children:[e.jsxs("div",{className:"search-tree-file",style:{paddingLeft:"4px"},onClick:()=>Y(F.path),children:[N.has(F.path)?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx(xe,{name:F.path.split("/").pop()||"",type:"file",size:14}),e.jsx("span",{className:"search-tree-name",children:F.path.split("/").pop()}),e.jsx("span",{className:"search-list-filepath",children:F.path}),e.jsx("span",{className:"search-tree-badge",children:F.matches.length})]}),N.has(F.path)&&e.jsx("div",{className:"search-tree-matches",children:F.matches.map((B,X)=>e.jsx("div",{className:"search-tree-match",style:{paddingLeft:"24px"},onClick:()=>_(F.path,B.line),children:e.jsx(Kt,{text:B.text,query:s})},X))})]},F.path)),!g&&s&&b===0&&!C&&e.jsxs("div",{className:"scm-empty",children:[e.jsx(et,{size:20,strokeWidth:1.5,style:{opacity:.3}}),e.jsx("span",{children:t("ide.search.noResults")})]})]})]})}function Vt({node:t,depth:s,expandedPaths:a,onToggle:i,onFileClick:l,query:r}){const c=a.has(t.fullPath),u=s*14;if(t.isDir)return e.jsxs("div",{className:"search-tree-group",children:[e.jsxs("div",{className:"search-tree-dir",style:{paddingLeft:`${u+4}px`},onClick:()=>i(t.fullPath),children:[c?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx(Mt,{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})]}),c&&t.children.map(h=>e.jsx(Vt,{node:h,depth:s+1,expandedPaths:a,onToggle:i,onFileClick:l,query:r},h.fullPath))]});const d=t.name;return e.jsxs("div",{className:"search-tree-group",children:[e.jsxs("div",{className:"search-tree-file",style:{paddingLeft:`${u+4}px`},onClick:()=>i(t.fullPath),children:[c?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx(xe,{name:d,type:"file",size:14}),e.jsx("span",{className:"search-tree-name",children:d}),e.jsx("span",{className:"search-tree-badge",children:t.matchCount})]}),c&&t.matches&&e.jsx("div",{className:"search-tree-matches",children:t.matches.map((h,g)=>e.jsx("div",{className:"search-tree-match",style:{paddingLeft:`${u+24}px`},onClick:()=>l(t.fullPath,h.line),children:e.jsx(Kt,{text:h.text,query:r})},g))})]})}function Kt({text:t,query:s}){if(!s)return e.jsx("span",{className:"search-match-text",children:t});const a=[],i=t.toLowerCase(),l=s.toLowerCase();let r=0,c=i.indexOf(l),u=0;for(;c!==-1&&u<10;)c>r&&a.push(e.jsx("span",{children:t.slice(r,c)},u++)),a.push(e.jsx("span",{className:"search-highlight",children:t.slice(c,c+s.length)},u++)),r=c+s.length,c=i.indexOf(l,r);return r<t.length&&a.push(e.jsx("span",{children:t.slice(r)},u++)),e.jsx("span",{className:"search-match-text",children:a})}function Ua(t,s){const a={children:[]};for(const i of t){const l=s(i).split("/");let r=a;for(let c=0;c<l.length;c++){const u=l[c],d=c===l.length-1,h=l.slice(0,c+1).join("/");if(d)r.children.push({name:u,path:h,isDir:!1,children:[],data:i});else{let g=r.children.find(b=>b.isDir&&b.name===u);g||(g={name:u,path:h,isDir:!0,children:[]},r.children.push(g)),r=g}}}return a.children.map(Qe)}function Qe(t){if(t.isDir&&t.children.length===1&&t.children[0].isDir){const s=t.children[0];return Qe({...s,name:`${t.name}/${s.name}`})}return{...t,children:t.children.map(Qe)}}const Ut={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 Gt({file:t,onStage:s,onUnstage:a,onDiscard:i,onOpenFile:l}){const{t:r}=te(),c=n.useCallback(u=>{u.stopPropagation(),Ne(t.path)},[t.path]);return e.jsxs("div",{className:"scm-file-actions",children:[e.jsx("button",{className:"scm-file-action-btn",onClick:c,title:r("ide.scm.copyPath"),children:e.jsx(ws,{size:13})}),l&&t.status!=="deleted"&&e.jsx("button",{className:"scm-file-action-btn",onClick:u=>{u.stopPropagation(),l(t.path)},title:r("ide.scm.openFile"),children:e.jsx(Pt,{size:13})}),i&&e.jsx("button",{className:"scm-file-action-btn",onClick:u=>{u.stopPropagation(),i(t.path)},title:r("ide.scm.discard"),children:e.jsx(tt,{size:13})}),s&&e.jsx("button",{className:"scm-file-action-btn",onClick:u=>{u.stopPropagation(),s(t.path)},title:r("ide.scm.stage"),children:e.jsx(je,{size:13})}),a&&e.jsx("button",{className:"scm-file-action-btn",onClick:u=>{u.stopPropagation(),a(t.path)},title:r("ide.scm.unstage"),children:e.jsx(Fe,{size:13})})]})}function Ga({files:t,sectionTitle:s,sectionCount:a,sectionActions:i,onStage:l,onUnstage:r,onDiscard:c,onSelect:u,onOpenFile:d}){const[h,g]=n.useState(!0);return e.jsxs("div",{className:"scm-file-list",children:[s&&e.jsxs("div",{className:"scm-tree-section-root",onClick:()=>g(b=>!b),children:[h?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx("span",{className:"scm-tree-section-title",children:s}),a!==void 0&&e.jsx("span",{className:"scm-section-count",children:a}),i&&e.jsx("div",{className:"scm-file-actions",children:i})]}),(!s||h)&&t.map(b=>{const m=Ut[b.status]||{label:"?",color:"var(--color-text-tertiary)"},C=b.path.split("/").pop()||b.path,D=b.path.includes("/")?b.path.substring(0,b.path.lastIndexOf("/")):"";return e.jsxs("div",{className:"scm-file-item",onClick:()=>u==null?void 0:u(b.path),children:[e.jsx(xe,{name:C,type:"file",size:16}),e.jsx("span",{className:"scm-file-name-text",children:C}),D&&e.jsx("span",{className:"scm-file-path-desc",children:D}),e.jsx(Gt,{file:b,onStage:l,onUnstage:r,onDiscard:c,onOpenFile:d}),e.jsx("span",{className:"scm-file-status",style:{color:m.color},children:m.label})]},`${b.path}-${b.staged}`)})]})}function Xe({node:t,depth:s,onStage:a,onUnstage:i,onDiscard:l,onSelect:r,onOpenFile:c}){const{t:u}=te(),[d,h]=n.useState(!0);function g(f){if(!f.isDir)return null;const y=Je(f);return y.length===0?null:y.some(P=>P.status==="modified")?"var(--color-accent-yellow)":y.some(P=>P.status==="untracked"||P.status==="added")?"var(--color-accent-green)":"var(--color-text-tertiary)"}const b=g(t),m=Je(t),C=n.useCallback(f=>{f.stopPropagation(),a&&m.forEach(y=>a(y.path))},[a,m]),D=n.useCallback(f=>{f.stopPropagation(),l&&m.forEach(y=>l(y.path))},[l,m]),E=n.useCallback(f=>{f.stopPropagation(),i&&m.forEach(y=>i(y.path))},[i,m]),S=s*16+4;return e.jsxs("div",{className:"scm-tree-group",children:[e.jsxs("div",{className:"scm-tree-dir",style:{paddingLeft:`${S}px`},onClick:()=>h(f=>!f),children:[Array.from({length:s},(f,y)=>e.jsx("span",{className:"scm-tree-indent-guide",style:{left:`${y*16+12}px`}},y)),d?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx(Mt,{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:D,title:u("ide.scm.discardAll"),children:e.jsx(tt,{size:13})}),a&&e.jsx("button",{className:"scm-file-action-btn",onClick:C,title:u("ide.scm.stageAll"),children:e.jsx(je,{size:13})}),i&&e.jsx("button",{className:"scm-file-action-btn",onClick:E,title:u("ide.scm.unstageAll"),children:e.jsx(Fe,{size:13})})]}),b&&e.jsx("span",{className:"scm-tree-dir-dot",style:{background:b}})]}),d&&t.children.map(f=>f.isDir?e.jsx(Xe,{node:f,depth:s+1,onStage:a,onUnstage:i,onDiscard:l,onSelect:r,onOpenFile:c},f.path):e.jsx(Ye,{node:f,depth:s+1,onStage:a,onUnstage:i,onDiscard:l,onSelect:r,onOpenFile:c},f.path))]})}function Ye({node:t,depth:s,onStage:a,onUnstage:i,onDiscard:l,onSelect:r,onOpenFile:c}){const u=t.data,d=Ut[u.status]||{label:"?",color:"var(--color-text-tertiary)"};return e.jsxs("div",{className:"scm-file-item",style:{paddingLeft:`${s*16+20}px`},onClick:()=>r==null?void 0:r(u.path),children:[Array.from({length:s},(h,g)=>e.jsx("span",{className:"scm-tree-indent-guide",style:{left:`${g*16+12}px`}},g)),e.jsx(xe,{name:t.name,type:"file",size:16}),e.jsx("span",{className:"scm-file-name-text",children:t.name}),e.jsx(Gt,{file:u,onStage:a,onUnstage:i,onDiscard:l,onOpenFile:c}),e.jsx("span",{className:"scm-file-status",style:{color:d.color},children:d.label})]})}function Je(t){return t.isDir?t.children.flatMap(Je):t.data?[t.data]:[]}function Qa({files:t,sectionTitle:s,sectionCount:a,sectionActions:i,onStage:l,onUnstage:r,onDiscard:c,onSelect:u,onOpenFile:d}){const[h,g]=n.useState(!0),b=Ua(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:()=>g(m=>!m),children:[h?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx("span",{className:"scm-tree-section-title",children:s}),a!==void 0&&e.jsx("span",{className:"scm-section-count",children:a}),i&&e.jsx("div",{className:"scm-file-actions",children:i})]}),h&&b.map(m=>m.isDir?e.jsx(Xe,{node:m,depth:1,onStage:l,onUnstage:r,onDiscard:c,onSelect:u,onOpenFile:d},m.path):e.jsx(Ye,{node:m,depth:1,onStage:l,onUnstage:r,onDiscard:c,onSelect:u,onOpenFile:d},m.path))]}):e.jsx("div",{className:"scm-file-list scm-tree-view",children:b.map(m=>m.isDir?e.jsx(Xe,{node:m,depth:0,onStage:l,onUnstage:r,onDiscard:c,onSelect:u,onOpenFile:d},m.path):e.jsx(Ye,{node:m,depth:0,onStage:l,onUnstage:r,onDiscard:c,onSelect:u,onOpenFile:d},m.path))})}function pt(t){return t.viewMode==="tree"?e.jsx(Qa,{...t}):e.jsx(Ga,{...t})}const xt=["var(--color-accent-green)","var(--color-accent-blue)","var(--color-accent-yellow)","var(--color-accent-purple)","var(--color-accent-red)"];function Xa(t){try{const s=new Date(t),i=new Date().getTime()-s.getTime(),l=Math.floor(i/6e4);if(l<60)return`${l}m ago`;const r=Math.floor(l/60);if(r<24)return`${r}h ago`;const c=Math.floor(r/24);return c<7?`${c}d ago`:s.toLocaleDateString()}catch{return t}}function Ya(){const{t}=te(),[s,a]=n.useState(!1),[i,l]=n.useState([]),[r,c]=n.useState(!1),u=n.useCallback(async()=>{c(!0);try{const d=await Ca(30);l(d)}catch{}c(!1)},[]);return n.useEffect(()=>{s&&i.length===0&&!r&&u()},[s,i.length,r,u]),e.jsxs("div",{className:"scm-graph",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>a(d=>!d),children:[s?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx("span",{children:t("ide.scm.graph")}),s&&e.jsx("button",{className:"scm-icon-btn",onClick:d=>{d.stopPropagation(),u()},title:t("ide.refresh"),children:e.jsx(Me,{size:12,className:r?"animate-spin":""})})]}),s&&e.jsxs("div",{className:"scm-graph-list",children:[r&&i.length===0&&e.jsx("div",{className:"scm-graph-loading",children:e.jsx(ve,{size:14,className:"animate-spin"})}),i.map((d,h)=>e.jsxs("div",{className:"scm-graph-entry",title:`${d.hash}
|
|
94
94
|
${d.author}
|
|
95
|
-
${d.date}`,children:[e.jsx("span",{className:"scm-graph-dot",style:{background:xt[h%xt.length]}}),e.jsx("span",{className:"scm-graph-msg",children:d.message}),e.jsx("span",{className:"scm-graph-time",children:Xa(d.date)})]},d.hash))]})]})}function Qt(){const{t}=te(),{isGitRepo:s,loading:a,files:i,currentBranch:l,ahead:r,behind:c,pushing:u,pulling:d,branches:h,branchesLoading:g,lastOperationMessage:b,refresh:m,loadBranches:C,stageFile:D,unstageFile:E,stageAll:S,unstageAll:f,discardFile:y,discardAll:P,push:R,pull:x,switchBranch:T,createBranch:$,clearOperationMessage:j}=me(),N=se(B=>B.openFile),A=ne(B=>B.scmViewMode),I=ne(B=>B.setScmViewMode),[O,o]=n.useState(!0),[w,G]=n.useState(!0);n.useEffect(()=>{m(),me.getState().startWatching()},[m]),n.useEffect(()=>{if(b){const B=setTimeout(j,3e3);return()=>clearTimeout(B)}},[b,j]);const Y=T,z=n.useCallback(async(B,X)=>{ne.getState().bottomPanelMaximized&&ne.setState({bottomPanelMaximized:!1});try{const q=await Lt(B,X);se.getState().openDiffTab(B,{oldText:q.oldText,newText:q.newText,staged:X})}catch{}},[]),H=N,_=i.filter(B=>B.staged),F=i.filter(B=>!B.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 ${A==="list"?"active":""}`,onClick:()=>I("list"),title:t("ide.listView"),children:e.jsx(zt,{size:14})}),e.jsx("button",{className:`scm-icon-btn ${A==="tree"?"active":""}`,onClick:()=>I("tree"),title:t("ide.treeView"),children:e.jsx(Et,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:m,disabled:a,title:t("ide.refresh"),children:e.jsx(Me,{size:14,className:a?"animate-spin":""})})]})]}),e.jsxs("div",{className:"scm-scroll",children:[e.jsxs("div",{className:"scm-section",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>o(B=>!B),children:[O?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx("span",{children:t("ide.scm.repositories")})]}),O&&e.jsx($t,{currentBranch:l,branches:h,branchesLoading:g,onSwitch:Y,onCreate:$,onLoadBranches:C,actions:e.jsxs(e.Fragment,{children:[(r>0||c>0)&&e.jsxs("span",{className:"scm-branch-sync",children:[r>0&&e.jsxs("span",{children:["↑",r]}),c>0&&e.jsxs("span",{children:["↓",c]})]}),e.jsxs("div",{className:"scm-branch-actions",children:[e.jsx("button",{className:"scm-icon-btn",onClick:x,disabled:d,title:t("ide.scm.pull"),children:d?e.jsx(ve,{size:14,className:"animate-spin"}):e.jsx(Cs,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:R,disabled:u,title:t("ide.scm.push"),children:u?e.jsx(ve,{size:14,className:"animate-spin"}):e.jsx(Ns,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:m,disabled:a,title:t("ide.refresh"),children:e.jsx(Me,{size:12,className:a?"animate-spin":""})})]})]})})]}),e.jsxs("div",{className:"scm-section",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>G(B=>!B),children:[w?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx("span",{children:t("ide.scm.changes")}),e.jsx("span",{className:"scm-section-count",children:i.length})]}),b&&e.jsx("div",{className:"scm-operation-msg",children:b}),w&&e.jsxs(e.Fragment,{children:[_.length>0&&e.jsx(pt,{files:_,viewMode:A,sectionTitle:t("ide.scm.stagedChanges"),sectionCount:_.length,sectionActions:e.jsx("button",{className:"scm-file-action-btn",onClick:()=>f(),title:t("ide.scm.unstageAll"),children:e.jsx(Fe,{size:13})}),onUnstage:E,onSelect:B=>z(B,!0),onOpenFile:H}),F.length>0&&e.jsx(pt,{files:F,viewMode:A,sectionTitle:t("ide.scm.changes"),sectionCount:F.length,sectionActions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"scm-file-action-btn",onClick:()=>P(),title:t("ide.scm.discardAll"),children:e.jsx(tt,{size:13})}),e.jsx("button",{className:"scm-file-action-btn",onClick:()=>S(),title:t("ide.scm.stageAll"),children:e.jsx(je,{size:13})})]}),onStage:D,onDiscard:y,onSelect:B=>z(B,!1),onOpenFile:H}),i.length===0&&!a&&e.jsxs("div",{className:"scm-empty",children:[e.jsx(vt,{size:20,strokeWidth:1.5,style:{opacity:.3}}),e.jsx("span",{children:t("ide.scm.noChanges")})]})]})]}),e.jsx(Ya,{})]})]}):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(Se,{size:32,strokeWidth:1,style:{opacity:.2}}),e.jsx("div",{className:"ide-panel-placeholder-text",children:t("ide.scm.notGitRepo")})]})]})}function Ja({activePanel:t,onMenuClick:s}){return e.jsxs("div",{className:"ide-side-panel-content",children:[t==="explorer"&&e.jsx(_t,{onMenuClick:s}),t==="search"&&e.jsx(qt,{}),t==="source-control"&&e.jsx(Qt,{})]})}function Za({onMenuClick:t,activeTab:s,tabActions:a,cursorInfo:i,imageInfo:l,previewZoom:r,isMarkdownSource:c,quickOpenVisible:u,setQuickOpenVisible:d,onContentChange:h,onSave:g,onRequestClose:b,onCursorChange:m,onImageInfo:C,onZoomChange:D}){const{t:E}=te(),{rootPath:S,openFile:f,revealInTree:y,loadTab:P,showHiddenFiles:R}=se(),{activePanel:x,sidePanelWidth:T,sidePanelCollapsed:$,setSidePanelWidth:j,setSidePanelCollapsed:N,bottomPanelHeight:A,bottomPanelCollapsed:I,bottomPanelMaximized:O,setBottomPanelHeight:o,setBottomPanelCollapsed:w,toggleBottomPanelMaximize:G}=ne(),Y=ht({direction:"horizontal",initialSize:T,minSize:160,maxSize:600,collapsible:!0,defaultCollapsed:$,onResize:j,onCollapse:N,ariaLabel:E("ide.resizeSidePanel")}),z=ht({direction:"vertical",initialSize:A,minSize:140,maxSize:typeof window<"u"?Math.max(300,window.innerHeight-80):500,collapsible:!0,defaultCollapsed:I,reverse:!0,onResize:o,onCollapse:w,onMaximize:G,maximizeThreshold:.85,ariaLabel:E("ide.resizeBottomPanel")}),H=me(p=>p.files.length);n.useEffect(()=>(me.getState().refresh(),me.getState().startWatching(),()=>{me.getState().stopWatching()}),[]);const _=typeof navigator<"u"&&navigator.platform.includes("Mac"),F=()=>s?s.loadStatus!=="ready"?e.jsx(Tt,{tab:s,onRetry:()=>P(s.id)}):s.viewMode==="diff"&&s.diffData?e.jsx("div",{className:"editor-container",children:e.jsx(Ss,{path:s.path,oldText:s.diffData.oldText,newText:s.diffData.newText})}):s.viewMode==="editor"||c?e.jsx("div",{className:"editor-container",children:e.jsx(Rt,{path:s.path,content:s.content,language:s.language,onContentChange:h,onSave:g,minimap:!0,onCursorChange:m})}):e.jsx(It,{path:s.path,name:s.name,content:s.content,viewMode:s.viewMode,onImageInfo:C,onZoomChange:D}):e.jsx(en,{isMac:_,t:E}),B=u&&S&&e.jsx(Ht,{isOpen:u,onClose:()=>d(!1),onSelect:p=>{f(p),d(!1)},rootPath:S,showHiddenFiles:R}),X=x&&!Y.collapsed,q=!z.collapsed;return e.jsxs("div",{className:"ide-layout",children:[B,e.jsxs("div",{className:"ide-layout-row",ref:Y.containerRef,children:[e.jsx(Ha,{gitFileCount:H}),X&&e.jsxs("div",{className:"ide-side-panel",style:{width:Y.size},children:[e.jsx(Ja,{activePanel:x,onMenuClick:t}),e.jsx("div",{...Y.sashProps})]}),e.jsxs("div",{className:"ide-main-area",ref:z.containerRef,children:[!O&&e.jsxs("div",{className:"ide-editor-area",style:{flex:q?void 0:1,height:q?`calc(100% - ${z.size}px)`:"100%"},children:[e.jsx(At,{actions:a,onRequestClose:b}),s&&S&&e.jsx(Ba,{filePath:s.path,rootPath:S,onSegmentClick:y,onOpenFile:f}),e.jsx("div",{className:"ide-editor-content",onDragOver:p=>{p.preventDefault(),p.dataTransfer.dropEffect="copy"},onDrop:p=>{p.preventDefault();const L=p.dataTransfer.getData("application/x-file-paths")||p.dataTransfer.getData("text/plain");if(L){try{const V=JSON.parse(L),M=Array.isArray(V)?V:[L];M.length>0&&f(M[0])}catch{L&&f(L)}setTimeout(()=>{const V=document.querySelector(".ide-editor-content .monaco-editor textarea");V==null||V.focus()},100)}},children:F()})]}),q&&e.jsxs(e.Fragment,{children:[!O&&e.jsx("div",{...z.sashProps}),e.jsx("div",{className:"ide-bottom-panel-wrap",style:{height:O?"100%":z.size},children:e.jsx(Wt,{})})]})]})]}),e.jsx("div",{className:"ide-statusbar-drag-zone",onPointerDown:z.sashProps.onPointerDown,onDoubleClick:z.sashProps.onDoubleClick,children:e.jsx(Ft,{language:(s==null?void 0:s.language)||"",cursorLine:i.line,cursorColumn:i.col,selectedCount:i.selectedChars,selectedLines:i.selectedLines,viewMode:s?c?"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:r})})]})}function en({isMac:t,t:s}){const a=n.useRef(null),[i,l]=n.useState(!1);return n.useEffect(()=>{const r=a.current;if(!r)return;const c=new ResizeObserver(u=>{for(const d of u)l(d.contentRect.height<300)});return c.observe(r),()=>c.disconnect()},[]),e.jsxs("div",{className:"editor-empty",ref:a,children:[e.jsx("div",{className:"ide-empty-icon",children:e.jsx("img",{src:Ms,alt:"CodeBuddy",width:"64",height:"64",style:{opacity:.15,filter:"grayscale(1)"}})}),!i&&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")||"Toggle Sidebar"})]}),e.jsxs("div",{className:"editor-empty-hint",children:[e.jsxs("kbd",{children:[t?"⌃":"Ctrl","+`"]}),e.jsx("span",{children:s("ide.toggleTerminal")||"Toggle Terminal"})]})]})]})}function tn(){const{t}=te(),s=ne(r=>r.activeMobilePanel),a=ne(r=>r.setActiveMobilePanel),i=me(r=>r.files.length),l=[{id:"explorer",icon:e.jsx(Dt,{size:20,strokeWidth:1.5}),label:t("ide.explorer")||"Explorer"},{id:"search",icon:e.jsx(et,{size:20,strokeWidth:1.5}),label:t("ide.search")||"Search"},{id:"source-control",icon:e.jsx(Se,{size:20,strokeWidth:1.5}),label:t("ide.sourceControl")||"Source Control",badge:i},{id:"terminal",icon:e.jsx(Ps,{size:20,strokeWidth:1.5}),label:t("ide.terminal")||"Terminal"}];return e.jsx("div",{className:"mobile-tab-bar",children:l.map(r=>e.jsxs("button",{className:`mobile-tab-bar-btn ${s===r.id?"active":""}`,onClick:()=>a(r.id),children:[e.jsxs("span",{className:"mobile-tab-bar-icon",children:[r.icon,r.badge!=null&&r.badge>0&&e.jsx("span",{className:"mobile-tab-bar-badge",children:r.badge>99?"99+":r.badge})]}),e.jsx("span",{className:"mobile-tab-bar-label",children:r.label})]},r.id))})}const sn=1e3;function Ke(t){return`editor-save:${t}`}function cn({onMenuClick:t,isVisible:s=!0}){const{t:a,resolved:i}=te(),{tabs:l,activeTabId:r,rootPath:c,setRootPath:u,openFile:d,loadTab:h,updateTabContent:g,saveTab:b,requestCloseTabs:m,discardTabs:C,revealInTree:D,pendingReveal:E,showHiddenFiles:S}=se(),[f,y]=n.useState(!1),[P]=n.useState(()=>xa(sn)),R=ne(W=>W.toggleBottomPanel),x=Ds(),[T,$]=n.useState(!1),j=n.useRef(!1),N=n.useRef(null),A=n.useRef(null),I=n.useCallback(()=>{j.current||(A.current=document.activeElement instanceof HTMLElement?document.activeElement:null,j.current=!0,$(!0))},[]),O=n.useCallback(()=>{j.current=!1,$(!1),requestAnimationFrame(()=>{var W;(W=A.current)==null||W.focus(),A.current=null})},[]);n.useEffect(()=>{N.current&&(N.current.inert=!T)},[T,x]);const o=n.useRef("");n.useEffect(()=>{const W=async()=>{if(rt()!=="editor")return;const v=wt(),k=v.get("path");if(!k)return;const Q=v.get("line"),U=v.get("col"),ee=`${k}:${Q}:${U}`;if(ee===o.current)return;if(o.current=ee,!se.getState().rootPath){const oe=v.get("folder")||new URLSearchParams(window.location.search).get("folder");oe&&await u(oe)}const Oe=await Ls(k),we=se.getState().rootPath;if(Oe==="directory")we&&(k===we||k.startsWith(we+"/"))?D(k):(await u(k),Ue(async()=>{const{useFolderStore:oe}=await import("./index-CfC-qiXR.js").then(Be=>Be.aS);return{useFolderStore:oe}},__vite__mapDeps([0,1,2,3])).then(({useFolderStore:oe})=>{oe.getState().setFolder(k)}));else{if(!we){const at=k.substring(0,k.lastIndexOf("/"));at&&await u(at)}const oe=Q?parseInt(Q,10):void 0,Be=oe?{line:oe,col:U?parseInt(U,10):1,query:""}:void 0;d(k,void 0,Be),D(k)}};W();const K=()=>W();return window.addEventListener("hashchange",K),()=>window.removeEventListener("hashchange",K)},[]),n.useEffect(()=>{x||(j.current=!1,$(!1))},[x]),n.useEffect(()=>{x&&r&&I()},[x,r,l.length,I]),n.useEffect(()=>{x&&E&&r&&I()},[x,E,r,I]),n.useEffect(()=>{if(!r)return;const W=se.getState().tabs.find(K=>K.id===r);W&&D(W.path)},[r,D]);const w=l.find(W=>W.id===r)||null,G=a("editor.saveFailed"),Y=a("app.retry"),z=n.useRef(new Map);n.useEffect(()=>{const W=z.current,K=new Set,v=it.getState().removeToast;for(const k of l){if(k.saveStatus!=="error")continue;K.add(k.id);const Q=`${i}:${k.saveError??""}`;W.get(k.id)!==Q&&(W.set(k.id,Q),Ct.error(`${G}${k.saveError?`: ${k.saveError}`:""}`,{id:Ke(k.id),durationMs:0,action:{label:Y,onClick:()=>se.getState().saveTab(k.id)}}))}for(const k of W.keys())K.has(k)||(v(Ke(k)),W.delete(k))},[i,Y,G,l]),n.useEffect(()=>()=>{const W=z.current,K=it.getState().removeToast;for(const v of W.keys())K(Ke(v));W.clear()},[]);const H=n.useCallback(W=>{if(!r)return;g(r,W);const K=r;P.schedule(K,()=>{const v=se.getState(),k=v.tabs.find(Q=>Q.id===K);(k==null?void 0:k.loadStatus)==="ready"&&k.isDirty&&v.saveTab(K).catch(()=>!1)})},[r,P,g]);n.useEffect(()=>()=>P.dispose(),[P]),n.useEffect(()=>{const W=K=>{se.getState().tabs.some(k=>k.isDirty||k.saveStatus==="saving")&&(K.preventDefault(),K.returnValue="")};return window.addEventListener("beforeunload",W),()=>window.removeEventListener("beforeunload",W)},[]);const[_,F]=n.useState(null),B=n.useCallback(async W=>{zs(se.getState().tabs,W).forEach(k=>P.cancel(k));const v=await m(W);F(v.closed?null:v)},[P,m]);n.useEffect(()=>{if(!s)return;const W=K=>{if(K.defaultPrevented||!s||rt()!=="editor")return;const v=K.metaKey||K.ctrlKey;if(v&&K.key==="p"&&!K.shiftKey&&(K.preventDefault(),y(!0)),v&&K.key==="w"&&!K.shiftKey&&(K.preventDefault(),r&&B({kind:"single",id:r}).catch(()=>{})),v&&K.key==="b"&&!K.shiftKey){K.preventDefault();const k=ne.getState();k.setSidePanelCollapsed(!k.sidePanelCollapsed)}v&&K.key==="`"&&(K.preventDefault(),R())};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[r,B,s,R]);const X=n.useCallback(()=>{r&&(P.cancel(r),b(r).catch(()=>!1))},[r,P,b]),[q,p]=n.useState({line:1,col:1,selectedChars:0,selectedLines:0}),L=n.useCallback((W,K,v,k)=>{p({line:W,col:K,selectedChars:v,selectedLines:k})},[]),[V,M]=n.useState(null),[Z,le]=n.useState(1),[ue,J]=n.useState(new Set),ae=(w==null?void 0:w.viewMode)==="markdown"&&!ue.has(w.id),ye=n.useCallback(()=>{r&&J(W=>{const K=new Set(W);return K.has(r)?K.delete(r):K.add(r),K})},[r]);let ke=null;(w==null?void 0:w.viewMode)==="markdown"&&(ke=ae?e.jsx("button",{className:"editor-action-btn",onClick:ye,title:a("editor.preview"),"aria-label":a("editor.preview"),children:e.jsx(Es,{size:16})}):e.jsx("button",{className:"editor-action-btn",onClick:ye,title:a("editor.source"),"aria-label":a("editor.source"),children:e.jsx(Rs,{size:16})}));const Ae=n.useCallback(()=>{const W=new URLSearchParams(window.location.search);W.set("standalone","1"),window.open(`#/editor?${W.toString()}`,"_blank","noopener,noreferrer")},[]),Pe=e.jsxs(e.Fragment,{children:[ke,e.jsx("button",{className:"editor-action-btn",onClick:Ae,title:a("editor.openInNewWindow"),"aria-label":a("editor.openInNewWindow"),children:e.jsx(Pt,{size:16})})]}),De=n.useCallback(()=>{_&&(_.targetIds.forEach(W=>P.cancel(W)),C(_.targetIds),F(null))},[P,C,_]),Ie=n.useCallback(()=>{F(null)},[]),ze=_?e.jsx(Nt,{title:a("editor.closeSaveFailedTitle",{count:_.failedTabIds.length}),message:a("editor.closeSaveFailedMessage",{count:_.failedTabIds.length}),confirmLabel:a("editor.discardAndClose"),danger:!0,onConfirm:De,onCancel:Ie}):null,ge=ne(W=>W.activeMobilePanel),Ee=ne(W=>W.createBottomTerminal),Re=ne(W=>W.bottomTerminals);if(n.useEffect(()=>{x&&ge==="terminal"&&Re.length===0&&Ee()},[x,ge,Re.length,Ee]),x){const W=f&&c&&e.jsx(Ht,{isOpen:f,onClose:()=>y(!1),onSelect:v=>{d(v),y(!1)},rootPath:c,showHiddenFiles:S});let K=null;return w&&(w.loadStatus!=="ready"?K=e.jsx(Tt,{tab:w,onRetry:()=>h(w.id)}):w.viewMode==="editor"||ae?K=e.jsx("div",{className:"editor-container",children:e.jsx(Rt,{path:w.path,content:w.content,language:w.language,onContentChange:H,onSave:X,minimap:!1,onCursorChange:L})}):K=e.jsx(It,{path:w.path,name:w.name,content:w.content,viewMode:w.viewMode,onImageInfo:M,onZoomChange:le})),e.jsxs("div",{className:"editor-view editor-view-mobile",children:[W,ze,e.jsxs("div",{className:"mobile-panel-content",children:[ge==="explorer"&&e.jsx("div",{className:"editor-sidebar editor-sidebar-mobile",children:e.jsx(_t,{onMenuClick:t})}),ge==="search"&&e.jsx(qt,{}),ge==="source-control"&&e.jsx(Qt,{}),ge==="terminal"&&e.jsx("div",{className:"mobile-terminal-panel",children:e.jsx(Wt,{})})]}),e.jsx("div",{ref:N,className:`editor-mobile-panel ${T?"open":""}`,"aria-hidden":!T,children:e.jsxs("div",{className:"editor-main",children:[e.jsxs("div",{className:"editor-mobile-header",children:[e.jsx("button",{className:"editor-mobile-back",onClick:O,"aria-label":a("editor.mobileBack"),children:e.jsx(Ts,{size:18})}),e.jsx("div",{className:"editor-mobile-tabs-wrap",children:e.jsx(At,{actions:Pe,onRequestClose:B})})]}),K,w&&e.jsx(Ft,{language:w.language,cursorLine:q.line,cursorColumn:q.col,selectedCount:q.selectedChars,selectedLines:q.selectedLines,viewMode:ae?"editor":w.viewMode,isDirty:w.isDirty,saveStatus:w.saveStatus,saveError:w.saveError,imageInfo:V,zoom:Z})]})}),e.jsx(tn,{})]})}return e.jsxs("div",{className:"editor-view",children:[ze,e.jsx(Za,{onMenuClick:t,activeTab:w,tabActions:Pe,cursorInfo:q,imageInfo:V,previewZoom:Z,isMarkdownSource:ae,quickOpenVisible:f,setQuickOpenVisible:y,onContentChange:H,onSave:X,onRequestClose:B,onCursorChange:L,onImageInfo:M,onZoomChange:le})]})}export{cn as EditorView};
|
|
95
|
+
${d.date}`,children:[e.jsx("span",{className:"scm-graph-dot",style:{background:xt[h%xt.length]}}),e.jsx("span",{className:"scm-graph-msg",children:d.message}),e.jsx("span",{className:"scm-graph-time",children:Xa(d.date)})]},d.hash))]})]})}function Qt(){const{t}=te(),{isGitRepo:s,loading:a,files:i,currentBranch:l,ahead:r,behind:c,pushing:u,pulling:d,branches:h,branchesLoading:g,lastOperationMessage:b,refresh:m,loadBranches:C,stageFile:D,unstageFile:E,stageAll:S,unstageAll:f,discardFile:y,discardAll:P,push:R,pull:x,switchBranch:T,createBranch:$,clearOperationMessage:j}=me(),N=se(B=>B.openFile),A=ne(B=>B.scmViewMode),I=ne(B=>B.setScmViewMode),[O,o]=n.useState(!0),[w,G]=n.useState(!0);n.useEffect(()=>{m(),me.getState().startWatching()},[m]),n.useEffect(()=>{if(b){const B=setTimeout(j,3e3);return()=>clearTimeout(B)}},[b,j]);const Y=T,z=n.useCallback(async(B,X)=>{ne.getState().bottomPanelMaximized&&ne.setState({bottomPanelMaximized:!1});try{const q=await Lt(B,X);se.getState().openDiffTab(B,{oldText:q.oldText,newText:q.newText,staged:X})}catch{}},[]),H=N,_=i.filter(B=>B.staged),F=i.filter(B=>!B.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 ${A==="list"?"active":""}`,onClick:()=>I("list"),title:t("ide.listView"),children:e.jsx(zt,{size:14})}),e.jsx("button",{className:`scm-icon-btn ${A==="tree"?"active":""}`,onClick:()=>I("tree"),title:t("ide.treeView"),children:e.jsx(Et,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:m,disabled:a,title:t("ide.refresh"),children:e.jsx(Me,{size:14,className:a?"animate-spin":""})})]})]}),e.jsxs("div",{className:"scm-scroll",children:[e.jsxs("div",{className:"scm-section",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>o(B=>!B),children:[O?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx("span",{children:t("ide.scm.repositories")})]}),O&&e.jsx($t,{currentBranch:l,branches:h,branchesLoading:g,onSwitch:Y,onCreate:$,onLoadBranches:C,actions:e.jsxs(e.Fragment,{children:[(r>0||c>0)&&e.jsxs("span",{className:"scm-branch-sync",children:[r>0&&e.jsxs("span",{children:["↑",r]}),c>0&&e.jsxs("span",{children:["↓",c]})]}),e.jsxs("div",{className:"scm-branch-actions",children:[e.jsx("button",{className:"scm-icon-btn",onClick:x,disabled:d,title:t("ide.scm.pull"),children:d?e.jsx(ve,{size:14,className:"animate-spin"}):e.jsx(Cs,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:R,disabled:u,title:t("ide.scm.push"),children:u?e.jsx(ve,{size:14,className:"animate-spin"}):e.jsx(Ns,{size:14})}),e.jsx("button",{className:"scm-icon-btn",onClick:m,disabled:a,title:t("ide.refresh"),children:e.jsx(Me,{size:12,className:a?"animate-spin":""})})]})]})})]}),e.jsxs("div",{className:"scm-section",children:[e.jsxs("button",{className:"scm-section-header",onClick:()=>G(B=>!B),children:[w?e.jsx(he,{size:14}):e.jsx(ce,{size:14}),e.jsx("span",{children:t("ide.scm.changes")}),e.jsx("span",{className:"scm-section-count",children:i.length})]}),b&&e.jsx("div",{className:"scm-operation-msg",children:b}),w&&e.jsxs(e.Fragment,{children:[_.length>0&&e.jsx(pt,{files:_,viewMode:A,sectionTitle:t("ide.scm.stagedChanges"),sectionCount:_.length,sectionActions:e.jsx("button",{className:"scm-file-action-btn",onClick:()=>f(),title:t("ide.scm.unstageAll"),children:e.jsx(Fe,{size:13})}),onUnstage:E,onSelect:B=>z(B,!0),onOpenFile:H}),F.length>0&&e.jsx(pt,{files:F,viewMode:A,sectionTitle:t("ide.scm.changes"),sectionCount:F.length,sectionActions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"scm-file-action-btn",onClick:()=>P(),title:t("ide.scm.discardAll"),children:e.jsx(tt,{size:13})}),e.jsx("button",{className:"scm-file-action-btn",onClick:()=>S(),title:t("ide.scm.stageAll"),children:e.jsx(je,{size:13})})]}),onStage:D,onDiscard:y,onSelect:B=>z(B,!1),onOpenFile:H}),i.length===0&&!a&&e.jsxs("div",{className:"scm-empty",children:[e.jsx(vt,{size:20,strokeWidth:1.5,style:{opacity:.3}}),e.jsx("span",{children:t("ide.scm.noChanges")})]})]})]}),e.jsx(Ya,{})]})]}):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(Se,{size:32,strokeWidth:1,style:{opacity:.2}}),e.jsx("div",{className:"ide-panel-placeholder-text",children:t("ide.scm.notGitRepo")})]})]})}function Ja({activePanel:t,onMenuClick:s}){return e.jsxs("div",{className:"ide-side-panel-content",children:[t==="explorer"&&e.jsx(_t,{onMenuClick:s}),t==="search"&&e.jsx(qt,{}),t==="source-control"&&e.jsx(Qt,{})]})}function Za({onMenuClick:t,activeTab:s,tabActions:a,cursorInfo:i,imageInfo:l,previewZoom:r,isMarkdownSource:c,quickOpenVisible:u,setQuickOpenVisible:d,onContentChange:h,onSave:g,onRequestClose:b,onCursorChange:m,onImageInfo:C,onZoomChange:D}){const{t:E}=te(),{rootPath:S,openFile:f,revealInTree:y,loadTab:P,showHiddenFiles:R}=se(),{activePanel:x,sidePanelWidth:T,sidePanelCollapsed:$,setSidePanelWidth:j,setSidePanelCollapsed:N,bottomPanelHeight:A,bottomPanelCollapsed:I,bottomPanelMaximized:O,setBottomPanelHeight:o,setBottomPanelCollapsed:w,toggleBottomPanelMaximize:G}=ne(),Y=ht({direction:"horizontal",initialSize:T,minSize:160,maxSize:600,collapsible:!0,defaultCollapsed:$,onResize:j,onCollapse:N,ariaLabel:E("ide.resizeSidePanel")}),z=ht({direction:"vertical",initialSize:A,minSize:140,maxSize:typeof window<"u"?Math.max(300,window.innerHeight-80):500,collapsible:!0,defaultCollapsed:I,reverse:!0,onResize:o,onCollapse:w,onMaximize:G,maximizeThreshold:.85,ariaLabel:E("ide.resizeBottomPanel")}),H=me(p=>p.files.length);n.useEffect(()=>(me.getState().refresh(),me.getState().startWatching(),()=>{me.getState().stopWatching()}),[]);const _=typeof navigator<"u"&&navigator.platform.includes("Mac"),F=()=>s?s.loadStatus!=="ready"?e.jsx(Tt,{tab:s,onRetry:()=>P(s.id)}):s.viewMode==="diff"&&s.diffData?e.jsx("div",{className:"editor-container",children:e.jsx(Ss,{path:s.path,oldText:s.diffData.oldText,newText:s.diffData.newText})}):s.viewMode==="editor"||c?e.jsx("div",{className:"editor-container",children:e.jsx(Rt,{path:s.path,content:s.content,language:s.language,onContentChange:h,onSave:g,minimap:!0,onCursorChange:m})}):e.jsx(It,{path:s.path,name:s.name,content:s.content,viewMode:s.viewMode,onImageInfo:C,onZoomChange:D}):e.jsx(en,{isMac:_,t:E}),B=u&&S&&e.jsx(Ht,{isOpen:u,onClose:()=>d(!1),onSelect:p=>{f(p),d(!1)},rootPath:S,showHiddenFiles:R}),X=x&&!Y.collapsed,q=!z.collapsed;return e.jsxs("div",{className:"ide-layout",children:[B,e.jsxs("div",{className:"ide-layout-row",ref:Y.containerRef,children:[e.jsx(Ha,{gitFileCount:H}),X&&e.jsxs("div",{className:"ide-side-panel",style:{width:Y.size},children:[e.jsx(Ja,{activePanel:x,onMenuClick:t}),e.jsx("div",{...Y.sashProps})]}),e.jsxs("div",{className:"ide-main-area",ref:z.containerRef,children:[!O&&e.jsxs("div",{className:"ide-editor-area",style:{flex:q?void 0:1,height:q?`calc(100% - ${z.size}px)`:"100%"},children:[e.jsx(At,{actions:a,onRequestClose:b}),s&&S&&e.jsx(Ba,{filePath:s.path,rootPath:S,onSegmentClick:y,onOpenFile:f}),e.jsx("div",{className:"ide-editor-content",onDragOver:p=>{p.preventDefault(),p.dataTransfer.dropEffect="copy"},onDrop:p=>{p.preventDefault();const L=p.dataTransfer.getData("application/x-file-paths")||p.dataTransfer.getData("text/plain");if(L){try{const V=JSON.parse(L),M=Array.isArray(V)?V:[L];M.length>0&&f(M[0])}catch{L&&f(L)}setTimeout(()=>{const V=document.querySelector(".ide-editor-content .monaco-editor textarea");V==null||V.focus()},100)}},children:F()})]}),q&&e.jsxs(e.Fragment,{children:[!O&&e.jsx("div",{...z.sashProps}),e.jsx("div",{className:"ide-bottom-panel-wrap",style:{height:O?"100%":z.size},children:e.jsx(Wt,{})})]})]})]}),e.jsx("div",{className:"ide-statusbar-drag-zone",onPointerDown:z.sashProps.onPointerDown,onDoubleClick:z.sashProps.onDoubleClick,children:e.jsx(Ft,{language:(s==null?void 0:s.language)||"",cursorLine:i.line,cursorColumn:i.col,selectedCount:i.selectedChars,selectedLines:i.selectedLines,viewMode:s?c?"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:r})})]})}function en({isMac:t,t:s}){const a=n.useRef(null),[i,l]=n.useState(!1);return n.useEffect(()=>{const r=a.current;if(!r)return;const c=new ResizeObserver(u=>{for(const d of u)l(d.contentRect.height<300)});return c.observe(r),()=>c.disconnect()},[]),e.jsxs("div",{className:"editor-empty",ref:a,children:[e.jsx("div",{className:"ide-empty-icon",children:e.jsx("img",{src:Ms,alt:"CodeBuddy",width:"64",height:"64",style:{opacity:.15,filter:"grayscale(1)"}})}),!i&&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")||"Toggle Sidebar"})]}),e.jsxs("div",{className:"editor-empty-hint",children:[e.jsxs("kbd",{children:[t?"⌃":"Ctrl","+`"]}),e.jsx("span",{children:s("ide.toggleTerminal")||"Toggle Terminal"})]})]})]})}function tn(){const{t}=te(),s=ne(r=>r.activeMobilePanel),a=ne(r=>r.setActiveMobilePanel),i=me(r=>r.files.length),l=[{id:"explorer",icon:e.jsx(Dt,{size:20,strokeWidth:1.5}),label:t("ide.explorer")||"Explorer"},{id:"search",icon:e.jsx(et,{size:20,strokeWidth:1.5}),label:t("ide.search")||"Search"},{id:"source-control",icon:e.jsx(Se,{size:20,strokeWidth:1.5}),label:t("ide.sourceControl")||"Source Control",badge:i},{id:"terminal",icon:e.jsx(Ps,{size:20,strokeWidth:1.5}),label:t("ide.terminal")||"Terminal"}];return e.jsx("div",{className:"mobile-tab-bar",children:l.map(r=>e.jsxs("button",{className:`mobile-tab-bar-btn ${s===r.id?"active":""}`,onClick:()=>a(r.id),children:[e.jsxs("span",{className:"mobile-tab-bar-icon",children:[r.icon,r.badge!=null&&r.badge>0&&e.jsx("span",{className:"mobile-tab-bar-badge",children:r.badge>99?"99+":r.badge})]}),e.jsx("span",{className:"mobile-tab-bar-label",children:r.label})]},r.id))})}const sn=1e3;function Ke(t){return`editor-save:${t}`}function cn({onMenuClick:t,isVisible:s=!0}){const{t:a,resolved:i}=te(),{tabs:l,activeTabId:r,rootPath:c,setRootPath:u,openFile:d,loadTab:h,updateTabContent:g,saveTab:b,requestCloseTabs:m,discardTabs:C,revealInTree:D,pendingReveal:E,showHiddenFiles:S}=se(),[f,y]=n.useState(!1),[P]=n.useState(()=>xa(sn)),R=ne(W=>W.toggleBottomPanel),x=Ds(),[T,$]=n.useState(!1),j=n.useRef(!1),N=n.useRef(null),A=n.useRef(null),I=n.useCallback(()=>{j.current||(A.current=document.activeElement instanceof HTMLElement?document.activeElement:null,j.current=!0,$(!0))},[]),O=n.useCallback(()=>{j.current=!1,$(!1),requestAnimationFrame(()=>{var W;(W=A.current)==null||W.focus(),A.current=null})},[]);n.useEffect(()=>{N.current&&(N.current.inert=!T)},[T,x]);const o=n.useRef("");n.useEffect(()=>{const W=async()=>{if(rt()!=="editor")return;const v=wt(),k=v.get("path");if(!k)return;const Q=v.get("line"),U=v.get("col"),ee=`${k}:${Q}:${U}`;if(ee===o.current)return;if(o.current=ee,!se.getState().rootPath){const oe=v.get("folder")||new URLSearchParams(window.location.search).get("folder");oe&&await u(oe)}const Oe=await Ls(k),we=se.getState().rootPath;if(Oe==="directory")we&&(k===we||k.startsWith(we+"/"))?D(k):(await u(k),Ue(async()=>{const{useFolderStore:oe}=await import("./index-DJF_5kYl.js").then(Be=>Be.aS);return{useFolderStore:oe}},__vite__mapDeps([0,1,2,3])).then(({useFolderStore:oe})=>{oe.getState().setFolder(k)}));else{if(!we){const at=k.substring(0,k.lastIndexOf("/"));at&&await u(at)}const oe=Q?parseInt(Q,10):void 0,Be=oe?{line:oe,col:U?parseInt(U,10):1,query:""}:void 0;d(k,void 0,Be),D(k)}};W();const K=()=>W();return window.addEventListener("hashchange",K),()=>window.removeEventListener("hashchange",K)},[]),n.useEffect(()=>{x||(j.current=!1,$(!1))},[x]),n.useEffect(()=>{x&&r&&I()},[x,r,l.length,I]),n.useEffect(()=>{x&&E&&r&&I()},[x,E,r,I]),n.useEffect(()=>{if(!r)return;const W=se.getState().tabs.find(K=>K.id===r);W&&D(W.path)},[r,D]);const w=l.find(W=>W.id===r)||null,G=a("editor.saveFailed"),Y=a("app.retry"),z=n.useRef(new Map);n.useEffect(()=>{const W=z.current,K=new Set,v=it.getState().removeToast;for(const k of l){if(k.saveStatus!=="error")continue;K.add(k.id);const Q=`${i}:${k.saveError??""}`;W.get(k.id)!==Q&&(W.set(k.id,Q),Ct.error(`${G}${k.saveError?`: ${k.saveError}`:""}`,{id:Ke(k.id),durationMs:0,action:{label:Y,onClick:()=>se.getState().saveTab(k.id)}}))}for(const k of W.keys())K.has(k)||(v(Ke(k)),W.delete(k))},[i,Y,G,l]),n.useEffect(()=>()=>{const W=z.current,K=it.getState().removeToast;for(const v of W.keys())K(Ke(v));W.clear()},[]);const H=n.useCallback(W=>{if(!r)return;g(r,W);const K=r;P.schedule(K,()=>{const v=se.getState(),k=v.tabs.find(Q=>Q.id===K);(k==null?void 0:k.loadStatus)==="ready"&&k.isDirty&&v.saveTab(K).catch(()=>!1)})},[r,P,g]);n.useEffect(()=>()=>P.dispose(),[P]),n.useEffect(()=>{const W=K=>{se.getState().tabs.some(k=>k.isDirty||k.saveStatus==="saving")&&(K.preventDefault(),K.returnValue="")};return window.addEventListener("beforeunload",W),()=>window.removeEventListener("beforeunload",W)},[]);const[_,F]=n.useState(null),B=n.useCallback(async W=>{zs(se.getState().tabs,W).forEach(k=>P.cancel(k));const v=await m(W);F(v.closed?null:v)},[P,m]);n.useEffect(()=>{if(!s)return;const W=K=>{if(K.defaultPrevented||!s||rt()!=="editor")return;const v=K.metaKey||K.ctrlKey;if(v&&K.key==="p"&&!K.shiftKey&&(K.preventDefault(),y(!0)),v&&K.key==="w"&&!K.shiftKey&&(K.preventDefault(),r&&B({kind:"single",id:r}).catch(()=>{})),v&&K.key==="b"&&!K.shiftKey){K.preventDefault();const k=ne.getState();k.setSidePanelCollapsed(!k.sidePanelCollapsed)}v&&K.key==="`"&&(K.preventDefault(),R())};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[r,B,s,R]);const X=n.useCallback(()=>{r&&(P.cancel(r),b(r).catch(()=>!1))},[r,P,b]),[q,p]=n.useState({line:1,col:1,selectedChars:0,selectedLines:0}),L=n.useCallback((W,K,v,k)=>{p({line:W,col:K,selectedChars:v,selectedLines:k})},[]),[V,M]=n.useState(null),[Z,le]=n.useState(1),[ue,J]=n.useState(new Set),ae=(w==null?void 0:w.viewMode)==="markdown"&&!ue.has(w.id),ye=n.useCallback(()=>{r&&J(W=>{const K=new Set(W);return K.has(r)?K.delete(r):K.add(r),K})},[r]);let ke=null;(w==null?void 0:w.viewMode)==="markdown"&&(ke=ae?e.jsx("button",{className:"editor-action-btn",onClick:ye,title:a("editor.preview"),"aria-label":a("editor.preview"),children:e.jsx(Es,{size:16})}):e.jsx("button",{className:"editor-action-btn",onClick:ye,title:a("editor.source"),"aria-label":a("editor.source"),children:e.jsx(Rs,{size:16})}));const Ae=n.useCallback(()=>{const W=new URLSearchParams(window.location.search);W.set("standalone","1"),window.open(`#/editor?${W.toString()}`,"_blank","noopener,noreferrer")},[]),Pe=e.jsxs(e.Fragment,{children:[ke,e.jsx("button",{className:"editor-action-btn",onClick:Ae,title:a("editor.openInNewWindow"),"aria-label":a("editor.openInNewWindow"),children:e.jsx(Pt,{size:16})})]}),De=n.useCallback(()=>{_&&(_.targetIds.forEach(W=>P.cancel(W)),C(_.targetIds),F(null))},[P,C,_]),Ie=n.useCallback(()=>{F(null)},[]),ze=_?e.jsx(Nt,{title:a("editor.closeSaveFailedTitle",{count:_.failedTabIds.length}),message:a("editor.closeSaveFailedMessage",{count:_.failedTabIds.length}),confirmLabel:a("editor.discardAndClose"),danger:!0,onConfirm:De,onCancel:Ie}):null,ge=ne(W=>W.activeMobilePanel),Ee=ne(W=>W.createBottomTerminal),Re=ne(W=>W.bottomTerminals);if(n.useEffect(()=>{x&&ge==="terminal"&&Re.length===0&&Ee()},[x,ge,Re.length,Ee]),x){const W=f&&c&&e.jsx(Ht,{isOpen:f,onClose:()=>y(!1),onSelect:v=>{d(v),y(!1)},rootPath:c,showHiddenFiles:S});let K=null;return w&&(w.loadStatus!=="ready"?K=e.jsx(Tt,{tab:w,onRetry:()=>h(w.id)}):w.viewMode==="editor"||ae?K=e.jsx("div",{className:"editor-container",children:e.jsx(Rt,{path:w.path,content:w.content,language:w.language,onContentChange:H,onSave:X,minimap:!1,onCursorChange:L})}):K=e.jsx(It,{path:w.path,name:w.name,content:w.content,viewMode:w.viewMode,onImageInfo:M,onZoomChange:le})),e.jsxs("div",{className:"editor-view editor-view-mobile",children:[W,ze,e.jsxs("div",{className:"mobile-panel-content",children:[ge==="explorer"&&e.jsx("div",{className:"editor-sidebar editor-sidebar-mobile",children:e.jsx(_t,{onMenuClick:t})}),ge==="search"&&e.jsx(qt,{}),ge==="source-control"&&e.jsx(Qt,{}),ge==="terminal"&&e.jsx("div",{className:"mobile-terminal-panel",children:e.jsx(Wt,{})})]}),e.jsx("div",{ref:N,className:`editor-mobile-panel ${T?"open":""}`,"aria-hidden":!T,children:e.jsxs("div",{className:"editor-main",children:[e.jsxs("div",{className:"editor-mobile-header",children:[e.jsx("button",{className:"editor-mobile-back",onClick:O,"aria-label":a("editor.mobileBack"),children:e.jsx(Ts,{size:18})}),e.jsx("div",{className:"editor-mobile-tabs-wrap",children:e.jsx(At,{actions:Pe,onRequestClose:B})})]}),K,w&&e.jsx(Ft,{language:w.language,cursorLine:q.line,cursorColumn:q.col,selectedCount:q.selectedChars,selectedLines:q.selectedLines,viewMode:ae?"editor":w.viewMode,isDirty:w.isDirty,saveStatus:w.saveStatus,saveError:w.saveError,imageInfo:V,zoom:Z})]})}),e.jsx(tn,{})]})}return e.jsxs("div",{className:"editor-view",children:[ze,e.jsx(Za,{onMenuClick:t,activeTab:w,tabActions:Pe,cursorInfo:q,imageInfo:V,previewZoom:Z,isMarkdownSource:ae,quickOpenVisible:f,setQuickOpenVisible:y,onContentChange:H,onSave:X,onRequestClose:B,onCursorChange:L,onImageInfo:M,onZoomChange:le})]})}export{cn as EditorView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a,j as t}from"./markdown-DIY6o85n.js";import{u as U,an as P,ao as L,ap as M,aq as q,A as I,l as F,X as J,ar as K,as as Q}from"./index-
|
|
1
|
+
import{a,j as t}from"./markdown-DIY6o85n.js";import{u as U,an as P,ao as L,ap as M,aq as q,A as I,l as F,X as J,ar as K,as as Q}from"./index-DJF_5kYl.js";import"./vendor-D35k0Cos.js";const V=({isOpen:n,actionId:d,actionName:v,context:i,existingBindings:y,onSave:C,onCancel:g})=>{const{t:b}=U(),[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 R=M(k).toLowerCase(),D=y.filter(h=>h.action===d&&h.context===i?!1:M(h.chord).toLowerCase()===R&&h.action!==null).map(h=>`${h.action} (${h.context})`);j(D)};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},W=()=>{const{t:n,tryT:d}=U(),{defaults:v,userBlocks:i,bindings:y,warnings:C,loaded:g,loadBindings:b,saveUserBindings:c,resetBindings:S}=q(),[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}`)??X(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),z=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}:${z}`);r.set(p,{action:e.action??"",displayName:e.action?u(e.action):"",keyDisplay:m,keyRaw:z,context:e.context,source:A?"user":"default",isUnbound:e.action===null})}return Array.from(r.values()).filter(e=>!e.isUnbound)},[g,y,i,u]),R=a.useMemo(()=>f.trim()?k.filter(s=>[s.displayName,s.action,s.keyDisplay,x(s.context)].some(e=>I(f,e).match)):k,[k,f,x]),D=a.useMemo(()=>{const s=new Map;for(const r of R){const e=s.get(r.context)||[];e.push(r),s.set(r.context,e)}return s},[R]),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]),B=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 z=v.find(A=>A.context===s.context);z&&z.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(J,{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(K,{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(D.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,4 +1,4 @@
|
|
|
1
|
-
import{a as l,j as e}from"./markdown-DIY6o85n.js";import{u as T,i as z,at as W,l as P,X as _,Z as k,au as A,j as I,o as O,k as $}from"./index-
|
|
1
|
+
import{a as l,j as e}from"./markdown-DIY6o85n.js";import{u as T,i as z,at as W,l as P,X as _,Z as k,au as A,j as I,o as O,k as $}from"./index-DJF_5kYl.js";import{u as F}from"./worker-store-C5Ek6Mvk.js";import"./vendor-D35k0Cos.js";const H=I,V=5e3,B={telemetry:{zh:"遥测日志",en:"Telemetry"},process:{zh:"进程输出",en:"Process"},debug:{zh:"调试日志",en:"Debug"},transcript:{zh:"对话记录",en:"Transcript"}};function J(){const{t:r,resolved:i}=T(),c=z(t=>t.resolved),{workers:d,fetchWorkers:x,logsContent:s,logsType:n,logsAvailableTypes:u,logsPath:p,fetchLogs:m}=F(),[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
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as N,j as r}from"./markdown-DIY6o85n.js";import{c as v,e as M,y as $,h as C,u as c,r as T,av as z,Z as U,aw as k,au as P,E as F,ax as h}from"./index-
|
|
1
|
+
import{a as N,j as r}from"./markdown-DIY6o85n.js";import{c as v,e as M,y as $,h as C,u as c,r as T,av as z,Z as U,aw as k,au as P,E as F,ax as h}from"./index-DJF_5kYl.js";import{u as S}from"./worker-store-C5Ek6Mvk.js";import{S as b}from"./server-Vphrdtn9.js";import"./vendor-D35k0Cos.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 as n,j as e}from"./markdown-DIY6o85n.js";import{c as W,u as J,q as A,ay as P,y as E,h as V,ak as R,az as I,aA as q,P as T,Z,aB as X,aC as Y}from"./index-
|
|
1
|
+
import{a as n,j as e}from"./markdown-DIY6o85n.js";import{c as W,u as J,q as A,ay as P,y as E,h as V,ak as R,az as I,aA as q,P as T,Z,aB as X,aC as Y}from"./index-DJF_5kYl.js";import"./vendor-D35k0Cos.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 as g,j as e}from"./markdown-DIY6o85n.js";import{c as O,e as W,aD as $,u as D,i as U,aE as B,aF as K,aG as w,aH as J,aI as V,ax as q,r as X,aJ as Y,Z as Q}from"./index-
|
|
1
|
+
import{a as g,j as e}from"./markdown-DIY6o85n.js";import{c as O,e as W,aD as $,u as D,i as U,aE as B,aF as K,aG as w,aH as J,aI as V,ax as q,r as X,aJ as Y,Z as Q}from"./index-DJF_5kYl.js";import"./vendor-D35k0Cos.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{j as e,a as f}from"./markdown-DIY6o85n.js";import{c as oe,e as Ee,y as ce,h as ie,aK as xe,G as Ae,aG as ge,aE as ze,aL as Le,u as Y,i as Ce,j as Re,o as _e,k as Xe,aM as te,X as Ye,C as Fe,I as Oe,l as Pe,n as ue,m as Te,aN as We,Z as ye,aB as He,ak as Be,aO as Ve}from"./index-
|
|
1
|
+
import{j as e,a as f}from"./markdown-DIY6o85n.js";import{c as oe,e as Ee,y as ce,h as ie,aK as xe,G as Ae,aG as ge,aE as ze,aL as Le,u as Y,i as Ce,j as Re,o as _e,k as Xe,aM as te,X as Ye,C as Fe,I as Oe,l as Pe,n as ue,m as Te,aN as We,Z as ye,aB as He,ak as Be,aO as Ve}from"./index-DJF_5kYl.js";import{u as qe}from"./worker-store-C5Ek6Mvk.js";import"./vendor-D35k0Cos.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 as o,j as e}from"./markdown-DIY6o85n.js";import{c as S,u as p,a0 as L,aw as y,Z as R,E as j,L as g,b as $,ar as D,F as W,aP as E,au as I,ax as M}from"./index-
|
|
1
|
+
import{a as o,j as e}from"./markdown-DIY6o85n.js";import{c as S,u as p,a0 as L,aw as y,Z as R,E as j,L as g,b as $,ar as D,F as W,aP as E,au as I,ax as M}from"./index-DJF_5kYl.js";import{u as P,g as _}from"./worker-store-C5Ek6Mvk.js";import{S as v}from"./server-Vphrdtn9.js";import"./vendor-D35k0Cos.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{e as z,f as L,a as d,h as B}from"./index-
|
|
1
|
+
import{e as z,f as L,a as d,h as B}from"./index-DJF_5kYl.js";const E=400,Z=300,A=200,G=150,N=.1,P=5,a=20,R=3,W=8,X=10,D=32,b=D;function M(){return B({"Content-Type":"application/json"})}async function C(i){try{const o=await fetch(`/api/v1/pty/${i}`,{headers:M()});if(!o.ok)return null;const n=await o.json(),e=n.data??n;return typeof(e==null?void 0:e.cwd)=="string"?e.cwd:null}catch{return null}}function _(i){const o=Object.values(i);if(o.length===0)return;const e={...d.getState().panes};let t=!1;for(const s of o){const r=e[s.paneId];r?s.ptySessionId&&r.ptySessionId!==s.ptySessionId&&(e[s.paneId]={...r,ptySessionId:s.ptySessionId},t=!0):(e[s.paneId]={id:s.paneId,ptySessionId:s.ptySessionId??null,ptyStatus:"disconnected",errorMessage:null},t=!0)}t&&d.setState({panes:e})}const O=z()(L((i,o)=>({viewport:{panX:0,panY:0,zoom:1},tiles:{},nextZIndex:1,selectedTileIds:[],setViewport:n=>{i({viewport:n})},addTile:()=>{const n=`tile-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,e=`canvas-pane-${n}`,{nextZIndex:t,viewport:s}=o(),r=s.zoom||1,l=(-s.panX+window.innerWidth/2)/r-E/2,c=(-s.panY+window.innerHeight/2)/r-Z/2,S=Math.round(l/a)*a,w=Math.round(c/a)*a,I={id:n,type:"terminal",x:S,y:w,width:E,height:Z,zIndex:t,paneId:e,windowState:"normal",ptySessionId:null,cwd:null},x=d.getState();if(!x.panes[e]){const p={...x.panes,[e]:{id:e,ptySessionId:null,ptyStatus:"disconnected",errorMessage:null}};d.setState({panes:p})}return i(p=>({tiles:{...p.tiles,[n]:I},nextZIndex:p.nextZIndex+1})),n},duplicateTile:n=>{var T,y,v,g;const e=o().tiles[n];if(!e)return null;const t=`tile-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,s=`canvas-pane-${t}`,{nextZIndex:r}=o(),l=((T=e.prevBounds)==null?void 0:T.width)??e.width,c=((y=e.prevBounds)==null?void 0:y.height)??e.height,S=((v=e.prevBounds)==null?void 0:v.x)??e.x,w=((g=e.prevBounds)==null?void 0:g.y)??e.y,I=a*2,x=Math.round((S+I)/a)*a,p=Math.round((w+I)/a)*a,H={id:t,type:"terminal",x,y:p,width:l,height:c,zIndex:r,paneId:s,windowState:"normal",ptySessionId:null,cwd:e.cwd??null},f=d.getState();f.panes[s]||d.setState({panes:{...f.panes,[s]:{id:s,ptySessionId:null,ptyStatus:"disconnected",errorMessage:null}}}),i(u=>({tiles:{...u.tiles,[t]:H},nextZIndex:u.nextZIndex+1}));const h=d.getState().panes[e.paneId],m=h==null?void 0:h.ptySessionId;return m&&C(m).then(u=>{u&&(o().updateTile(e.id,{cwd:u}),o().updateTile(t,{cwd:u}))}),t},removeTile:n=>{const e=o().tiles[n];if(e){const t=d.getState(),s=t.panes[e.paneId];if(s!=null&&s.ptySessionId&&fetch(`/api/v1/pty/${s.ptySessionId}`,{method:"DELETE",headers:M()}).catch(()=>{}),t.panes[e.paneId]){const{[e.paneId]:r,...l}=t.panes;d.setState({panes:l})}}i(t=>{const{[n]:s,...r}=t.tiles;return{tiles:r,selectedTileIds:t.selectedTileIds.filter(l=>l!==n)}})},updateTile:(n,e)=>{i(t=>{const s=t.tiles[n];return s?{tiles:{...t.tiles,[n]:{...s,...e}}}:t})},selectTile:n=>i({selectedTileIds:[n]}),deselectAll:()=>i({selectedTileIds:[]}),selectTiles:n=>i({selectedTileIds:n}),bringToFront:n=>{i(e=>{const t=e.tiles[n];return t?{tiles:{...e.tiles,[n]:{...t,zIndex:e.nextZIndex}},nextZIndex:e.nextZIndex+1}:e})},maximizeTile:n=>{i(e=>{const t=e.tiles[n];if(!t)return e;const s=t.windowState==="normal"?{x:t.x,y:t.y,width:t.width,height:t.height}:t.prevBounds;return{tiles:{...e.tiles,[n]:{...t,windowState:"maximized",prevBounds:s,zIndex:e.nextZIndex}},nextZIndex:e.nextZIndex+1}})},minimizeTile:n=>{i(e=>{const t=e.tiles[n];if(!t)return e;const s=t.windowState==="normal"?{x:t.x,y:t.y,width:t.width,height:t.height}:t.prevBounds;return{tiles:{...e.tiles,[n]:{...t,height:b,windowState:"minimized",prevBounds:s}}}})},restoreTile:n=>{i(e=>{const t=e.tiles[n];return!t||!t.prevBounds?t?{tiles:{...e.tiles,[n]:{...t,windowState:"normal"}}}:e:{tiles:{...e.tiles,[n]:{...t,x:t.prevBounds.x,y:t.prevBounds.y,width:t.prevBounds.width,height:t.prevBounds.height,windowState:"normal",prevBounds:void 0}}}})},toggleMaximize:n=>{const e=o().tiles[n];e&&(e.windowState==="maximized"?o().restoreTile(n):o().maximizeTile(n))},toggleMinimize:n=>{const e=o().tiles[n];e&&(e.windowState==="minimized"?o().restoreTile(n):o().minimizeTile(n))},setTilePty:(n,e,t)=>{let s=null;if(i(r=>{const l=r.tiles[n];if(!l)return r;s=l.paneId;const c={...l,ptySessionId:e};return t!==void 0&&(c.cwd=t),{tiles:{...r.tiles,[n]:c}}}),s){const r=d.getState(),l=r.panes[s];l&&l.ptySessionId!==e&&d.setState({panes:{...r.panes,[s]:{...l,ptySessionId:e}}})}},loadFromStorage:()=>{}}),{namespace:"canvas",fields:["viewport","tiles","nextZIndex"],scope:"workspace",debounceMs:1e3,onLoad:(i,o)=>{const n={};i.viewport&&(n.viewport=i.viewport),i.tiles&&(n.tiles=i.tiles),i.nextZIndex!==void 0&&(n.nextZIndex=i.nextZIndex),Object.keys(n).length>0&&(o(n),n.tiles&&_(n.tiles))}}));_(O.getState().tiles);export{R as C,a as G,N as M,W as R,X as S,D as T,P as a,A as b,G as c,O as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c,l as s}from"./editor.main-
|
|
1
|
+
import{c,l as s}from"./editor.main-DcOYuMpW.js";import{C as h,H as u,D as p,a as m,R as f,b as _,c as w,d as k,F as v,e as D,S as P,f as R,g as I}from"./lspLanguageFeatures-CEsh20ZM.js";import{h as U,i as T,j as x,t as j,k as M}from"./lspLanguageFeatures-CEsh20ZM.js";import"./index-DJF_5kYl.js";import"./markdown-DIY6o85n.js";import"./vendor-D35k0Cos.js";const C=120*1e3;class A{constructor(n){this._defaults=n,this._worker=null,this._client=null,this._idleCheckInterval=window.setInterval(()=>this._checkIfIdle(),30*1e3),this._lastUsedTime=0,this._configChangeListener=this._defaults.onDidChange(()=>this._stopWorker())}_stopWorker(){this._worker&&(this._worker.dispose(),this._worker=null),this._client=null}dispose(){clearInterval(this._idleCheckInterval),this._configChangeListener.dispose(),this._stopWorker()}_checkIfIdle(){if(!this._worker)return;Date.now()-this._lastUsedTime>C&&this._stopWorker()}_getClient(){return this._lastUsedTime=Date.now(),this._client||(this._worker=c({moduleId:"vs/language/css/cssWorker",createWorker:()=>new Worker(new URL("/assets/css.worker-B4z49cGk.js",import.meta.url),{type:"module"}),label:this._defaults.languageId,createData:{options:this._defaults.options,languageId:this._defaults.languageId}}),this._client=this._worker.getProxy()),this._client}getLanguageServiceWorker(...n){let e;return this._getClient().then(a=>{e=a}).then(a=>{if(this._worker)return this._worker.withSyncedResources(n)}).then(a=>e)}}function b(o){const n=[],e=[],a=new A(o);n.push(a);const r=(...t)=>a.getLanguageServiceWorker(...t);function l(){const{languageId:t,modeConfiguration:i}=o;g(e),i.completionItems&&e.push(s.registerCompletionItemProvider(t,new h(r,["/","-",":"]))),i.hovers&&e.push(s.registerHoverProvider(t,new u(r))),i.documentHighlights&&e.push(s.registerDocumentHighlightProvider(t,new p(r))),i.definitions&&e.push(s.registerDefinitionProvider(t,new m(r))),i.references&&e.push(s.registerReferenceProvider(t,new f(r))),i.documentSymbols&&e.push(s.registerDocumentSymbolProvider(t,new _(r))),i.rename&&e.push(s.registerRenameProvider(t,new w(r))),i.colors&&e.push(s.registerColorProvider(t,new k(r))),i.foldingRanges&&e.push(s.registerFoldingRangeProvider(t,new v(r))),i.diagnostics&&e.push(new D(t,r,o.onDidChange)),i.selectionRanges&&e.push(s.registerSelectionRangeProvider(t,new P(r))),i.documentFormattingEdits&&e.push(s.registerDocumentFormattingEditProvider(t,new R(r))),i.documentRangeFormattingEdits&&e.push(s.registerDocumentRangeFormattingEditProvider(t,new I(r)))}return l(),n.push(d(e)),d(n)}function d(o){return{dispose:()=>g(o)}}function g(o){for(;o.length;)o.pop().dispose()}export{h as CompletionAdapter,m as DefinitionAdapter,D as DiagnosticsAdapter,k as DocumentColorAdapter,R as DocumentFormattingEditProvider,p as DocumentHighlightAdapter,U as DocumentLinkAdapter,I as DocumentRangeFormattingEditProvider,_ as DocumentSymbolAdapter,v as FoldingRangeAdapter,u as HoverAdapter,f as ReferenceAdapter,w as RenameAdapter,P as SelectionRangeAdapter,A as WorkerManager,T as fromPosition,x as fromRange,b as setupMode,j as toRange,M as toTextEdit};
|