@openchamber/web 1.11.6 → 1.11.7
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/README.md +6 -0
- package/bin/cli.js +443 -2
- package/dist/assets/{MarkdownRendererImpl-COdbjw73.js → MarkdownRendererImpl-DaF15QNC.js} +3 -3
- package/dist/assets/{MultiRunWindow-BKSHxjMq.js → MultiRunWindow-Cl7wS_CB.js} +1 -1
- package/dist/assets/{OnboardingScreen-Chjg337p.js → OnboardingScreen-DTv6YJI1.js} +2 -2
- package/dist/assets/{SettingsWindow-C0lRRW8M.js → SettingsWindow-_c3TTL2z.js} +1 -1
- package/dist/assets/{TerminalView-Bvil3j1u.js → TerminalView-CuXkDROt.js} +3 -3
- package/dist/assets/es-CYoUf2D-.js +15 -0
- package/dist/assets/{index-B9LvUHdG.js → index-3WXrN3AX.js} +1 -1
- package/dist/assets/index-BREIbhcb.css +1 -0
- package/dist/assets/ko-2tM0fIna.js +15 -0
- package/dist/assets/main-BF3kWAJ9.js +239 -0
- package/dist/assets/{main-Blhx9Fp5.js → main-o8ZERrmU.js} +2 -2
- package/dist/assets/miniChat-BZQjpK23.js +2 -0
- package/dist/assets/{modelPrefsAutoSave-DRJSYigo.js → modelPrefsAutoSave-wwnbqBk7.js} +110 -108
- package/dist/assets/pl-Dq8uAotM.js +15 -0
- package/dist/assets/pt-BR-nh9s9DFT.js +15 -0
- package/dist/assets/{renderElectronMiniChatApp-BxZRI73j.js → renderElectronMiniChatApp-C-Ezew9P.js} +2 -2
- package/dist/assets/uk-BZtz0wUV.js +15 -0
- package/dist/assets/{vendor-.bun-Bum-iBXX.js → vendor-.bun-CV3tusA8.js} +1 -1
- package/dist/assets/zh-CN-j_nYMchE.js +15 -0
- package/dist/assets/zh-TW-B11UpkDJ.js +15 -0
- package/dist/index.html +11 -28
- package/dist/mini-chat.html +4 -4
- package/package.json +1 -1
- package/server/lib/fs/routes.js +5 -0
- package/server/lib/fs/routes.test.js +61 -1
- package/server/lib/git/DOCUMENTATION.md +1 -0
- package/server/lib/git/routes.js +82 -1
- package/server/lib/git/service.js +338 -19
- package/server/lib/git/service.test.js +414 -8
- package/server/lib/opencode/env-runtime.js +52 -4
- package/server/lib/opencode/env-runtime.test.js +82 -6
- package/server/lib/opencode/openchamber-routes.js +9 -7
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-runtime.js +39 -1
- package/server/lib/opencode/settings-runtime.test.js +39 -0
- package/server/lib/skills-catalog/source.js +1 -1
- package/dist/assets/es-BZIAUghG.js +0 -15
- package/dist/assets/index-UcCH2KN9.css +0 -1
- package/dist/assets/ko-DU9l-zox.js +0 -15
- package/dist/assets/main-d2-dY4er.js +0 -232
- package/dist/assets/miniChat-CJ7-rZFl.js +0 -2
- package/dist/assets/pl-CdqzokG-.js +0 -15
- package/dist/assets/pt-BR-Bknbr_Y3.js +0 -15
- package/dist/assets/uk-Be4E8ZNO.js +0 -15
- package/dist/assets/zh-CN-qpPiaZMg.js +0 -15
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{R as n,j as f,x as xt,bB as vt,bC as Tt,bD as kt}from"./vendor-.bun-Bum-iBXX.js";import{u as bt,v as Ct,b0 as Et,c as Ze,M as Rt,bI as At,eT as St,a as Me,b as It,V as ht,bh as Mt,I as fe,eU as it,cA as dt,as as ne}from"./modelPrefsAutoSave-DRJSYigo.js";import{u as X,P as Bt,S as Pt}from"./main-d2-dY4er.js";import{a8 as Dt}from"./index-B9LvUHdG.js";function Nt(u){const{colors:c}=u,d=c.syntax.base;return{background:c.surface.background,foreground:d.foreground,cursor:c.interactive.cursor,cursorAccent:c.surface.background,selectionBackground:c.interactive.selection,selectionForeground:c.interactive.selectionForeground,selectionInactiveBackground:c.interactive.selection+"50",black:c.surface.muted,red:c.status.error,green:c.status.success,yellow:c.status.warning,blue:d.function,magenta:d.keyword,cyan:d.type,white:d.foreground,brightBlack:d.comment,brightRed:c.status.error,brightGreen:c.status.success,brightYellow:c.status.warning,brightBlue:d.function,brightMagenta:d.keyword,brightCyan:d.type,brightWhite:c.surface.elevatedForeground}}function Vt(u,c,d,S,C=!1){const G=`${u}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`;return{cursorBlink:!1,cursorStyle:"bar",fontSize:c,lineHeight:1.15,fontFamily:G,allowTransparency:!1,theme:{background:d.background,foreground:d.foreground,cursor:d.cursor,cursorAccent:d.cursorAccent,selectionBackground:d.selectionBackground,selectionForeground:d.selectionForeground,black:d.black,red:d.red,green:d.green,yellow:d.yellow,blue:d.blue,magenta:d.magenta,cyan:d.cyan,white:d.white,brightBlack:d.brightBlack,brightRed:d.brightRed,brightGreen:d.brightGreen,brightYellow:d.brightYellow,brightBlue:d.brightBlue,brightMagenta:d.brightMagenta,brightCyan:d.brightCyan,brightWhite:d.brightWhite},scrollback:1e4,ghostty:S,disableStdin:C}}let pt=null;function jt(){return pt||(pt=kt.load()),pt}function Lt(u){if(typeof window>"u")return null;const c=[u,...Array.from(u.querySelectorAll("*"))];let d=null;for(const S of c){const $=window.getComputedStyle(S).overflowY;if(!($!=="auto"&&$!=="scroll")){if(S.scrollHeight-S.clientHeight>2)return S;d||(d=S)}}return d}const gt=n.forwardRef(({sessionKey:u,chunks:c,onInput:d,onResize:S,theme:C,fontFamily:$,fontSize:G,className:be,enableTouchScroll:R,autoFocus:at=!0,isVisible:Ne=!0},Ce)=>{const{t:_}=bt(),O=n.useRef(null),Ve=n.useRef(null),I=n.useRef(null),et=n.useRef(null),Y=n.useRef(d),Ue=n.useRef(S),x=n.useRef(null),Ee=n.useRef(""),re=n.useRef(null),je=n.useRef(!1),Le=n.useRef(null),ge=n.useRef(!0),oe=n.useRef(null),J=n.useRef(null),Re=n.useRef(0),se=n.useRef(null),We=n.useRef(null),de=n.useRef(!1),Z=n.useRef(!1),xe=n.useRef(null),V=n.useRef(null),D=n.useRef(null),we=n.useRef(""),Fe=n.useRef(null),j=n.useRef(!R),tt=n.useRef(Ne),[,ft]=n.useReducer(e=>e+1,0),[nt,ct]=n.useReducer(e=>e+1,0);Y.current=d,Ue.current=S;const lt=typeof navigator<"u"&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform==="Android"),b=!!R;n.useEffect(()=>{if(!R){j.current=!0,tt.current=Ne;return}!tt.current&&Ne&&(j.current=!1),tt.current=Ne},[R,Ne]);const rt=n.useCallback(()=>{if(!b)return;const e=O.current,i=se.current;if(!e)return;const s=[];e.getAttribute("contenteditable")==="true"&&s.push(e),s.push(...Array.from(e.querySelectorAll('[contenteditable="true"]'))),s.forEach(o=>{o.setAttribute("data-terminal-disabled-contenteditable","true"),o.setAttribute("contenteditable","false"),o.setAttribute("aria-hidden","true"),o.tabIndex=-1,o.style.setProperty("caret-color","transparent"),o.style.color="transparent",o.style.setProperty("-webkit-text-fill-color","transparent"),o.style.background="transparent",o.style.outline="none",o.style.boxShadow="none",o.style.textShadow="none",o.style.setProperty("user-select","none"),o.style.setProperty("-webkit-user-select","none")}),e.tabIndex=-1,e.removeAttribute("role"),e.removeAttribute("aria-multiline"),Array.from(e.querySelectorAll("textarea")).forEach(o=>{o.style.setProperty("caret-color","transparent"),o.style.color="transparent",o.style.setProperty("-webkit-text-fill-color","transparent"),o.style.background="transparent",o.style.border="0",o.style.outline="none",o.style.boxShadow="none",o.style.textShadow="none",o.style.fontSize="0",o.style.lineHeight="0",o!==i&&o.getAttribute("data-terminal-disabled-input")!=="true"&&(o.setAttribute("data-terminal-disabled-input","true"),o.setAttribute("aria-hidden","true"),o.tabIndex=-1,o.disabled=!0,o.style.position="absolute",o.style.opacity="0",o.style.width="0px",o.style.height="0px",o.style.pointerEvents="none",o.style.zIndex="-1")})},[b]),A=n.useCallback(e=>{if(Fe.current===e)return;const i=I.current;if(i)try{if(typeof i.setOption=="function"){i.setOption("cursorBlink",e),Fe.current=e;return}i.options&&(i.options.cursorBlink=e,Fe.current=e)}catch{}},[]),pe=b&<,E=n.useCallback((e,i)=>{const s=pe?We.current:se.current,m=O.current;if(!s||!m)return;const o=m.getBoundingClientRect(),k=typeof window<"u"?window.innerWidth:o.width,y=typeof window<"u"?window.innerHeight:o.height,M=o.left+o.width/2,ee=o.top+o.height-12,r=typeof e=="number"?e:M,B=typeof i=="number"?i:ee,F=8,U=Math.max(F,Math.min(k-F,r)),Ae=Math.max(F,Math.min(y-F,B));s.style.left=`${U}px`,s.style.top=`${Ae}px`,s.style.bottom="",(s instanceof HTMLTextAreaElement||s instanceof HTMLInputElement)&&(s.disabled=!1,s.readOnly=!1,s.removeAttribute("disabled"),s.removeAttribute("readonly"));try{s.focus({preventScroll:!0})}catch{try{s.focus()}catch{}}},[pe]),L=n.useCallback(()=>{if(b){E(),A(!0);return}I.current?.focus(),A(!0)},[E,A,b]),N=n.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??"",[]),z=n.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value="";return}e.textContent=""},[]),Ke=n.useCallback(e=>{if(typeof window>"u"||pe)return;D.current!==null&&(window.clearTimeout(D.current),D.current=null);let i=0;const s=3,m=()=>{D.current=window.setTimeout(()=>{D.current=null;const o=N(e);if(!o){if(i+=1,i<s){m();return}return}const k=we.current;we.current=o;const y=o.startsWith(k)?o.slice(k.length):o;y&&Y.current(y.replace(/\r\n|\r|\n/g,"\r")),z(e),we.current=""},i===0?0:24)};m()},[z,N,pe]);n.useEffect(()=>{const e=O.current;if(!b||!e||R)return;const i=s=>{const m=s.target;if(m&&m.getAttribute("data-terminal-hidden-input")!=="true"&&e.contains(m)){try{m.blur()}catch{}E()}};return e.addEventListener("focusin",i,!0),()=>{e.removeEventListener("focusin",i,!0)}},[R,b,E]);const qe=n.useCallback(()=>{const e=I.current;if(!e||typeof e.getSelection!="function")return"";const i=e.getSelection();return typeof i=="string"?i:""},[]),Xe=n.useCallback(()=>{if(typeof window>"u")return"";const e=window.getSelection();if(!e)return"";const i=e.toString();if(!i.trim())return"";const s=O.current;if(!s)return"";const m=e.anchorNode,o=e.focusNode;return m&&!s.contains(m)||o&&!s.contains(o)?"":i},[]),ve=n.useCallback(async()=>{if(typeof document>"u")return;const e=qe()||Xe();e.trim()&&await Ct(e)},[Xe,qe]),Q=n.useCallback(()=>qe().trim()?!0:!!Xe().trim(),[Xe,qe]);n.useEffect(()=>{if(typeof window>"u")return;const e=i=>{Q()&&(i.preventDefault(),ve())};return window.addEventListener("openchamber:copy",e),()=>{window.removeEventListener("openchamber:copy",e)}},[ve,Q]);const ie=n.useCallback(()=>{Ee.current="",re.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(re.current),re.current=null,je.current=!1,Le.current=null},[]),H=n.useCallback(()=>{const e=et.current,i=I.current,s=O.current;if(!e||!i||!s)return;const m=s.getBoundingClientRect();if(!(m.width<24||m.height<24))try{e.fit();const o={cols:i.cols,rows:i.rows},k=x.current;(!k||k.cols!==o.cols||k.rows!==o.rows)&&(x.current=o,Ue.current(o.cols,o.rows))}catch{}},[]),Te=n.useCallback(()=>{if(je.current)return;const e=I.current;if(!e){ie();return}if(!Ee.current)return;const i=Ee.current;Ee.current="",je.current=!0,e.write(i,()=>{je.current=!1,Ee.current&&(typeof window<"u"?re.current=window.requestAnimationFrame(()=>{re.current=null,Te()}):Te())})},[ie]),Be=n.useCallback(()=>{re.current===null&&(typeof window<"u"?re.current=window.requestAnimationFrame(()=>{re.current=null,Te()}):Te())},[Te]),$e=n.useCallback(e=>{e&&(Ee.current+=e,Be())},[Be]),Pe=n.useCallback(()=>{if(oe.current?.(),oe.current=null,J.current!==null&&typeof window<"u"&&(window.clearTimeout(J.current),J.current=null),!R){Re.current=0;return}const e=O.current;if(!e)return;const i=I.current;if(!i)return;Re.current=0;const s=2.2,m=2.8,o=25,k=.25,y=8,M=.05,ee=.015,r={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},B=()=>typeof performance<"u"?performance.now():Date.now(),F=Math.max(12,Math.round(G*1.35));let U=0;const Ae=a=>{if(!a)return!1;const he=i.getViewportY(),P=U+a,le=Math.trunc(P/F);return U=P-le*F,le!==0&&i.scrollLines(le),i.getViewportY()!==he},W=()=>{r.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(r.rafId),r.rafId=null},T={passive:!1,capture:!1};if(typeof window<"u"&&"PointerEvent"in window){const a=Object.assign(r,{pointerId:null,startX:null,startY:null,moved:!1}),he=6,P=t=>{if(t.pointerType==="touch"){W(),a.pointerId=t.pointerId,a.startX=t.clientX,a.startY=t.clientY,a.moved=!1,a.lastY=t.clientY,a.lastTime=B(),a.velocity=0;try{e.setPointerCapture(t.pointerId)}catch{}}},le=t=>{if(t.pointerType!=="touch"||a.pointerId!==t.pointerId)return;if(a.startX!==null&&a.startY!==null&&!a.moved){const Ie=t.clientX-a.startX,ze=t.clientY-a.startY;Math.hypot(Ie,ze)>=he&&(a.moved=!0)}if(a.lastY===null){a.lastY=t.clientY,a.lastTime=B();return}const p=a.lastY,l=a.lastTime??B(),h=B();a.lastY=t.clientY,a.lastTime=h;const w=p-t.clientY;if(Math.abs(w)<1)return;const v=Math.max(h-l,8),g=s+Math.min(m,Math.abs(w)/o),te=w*g,ye=te/v;a.velocity=a.velocity*(1-k)+ye*k,a.velocity>y?a.velocity=y:a.velocity<-y&&(a.velocity=-y),a.moved&&(t.cancelable&&t.preventDefault(),t.stopPropagation()),Ae(te)},me=t=>{if(t.pointerType!=="touch"||a.pointerId!==t.pointerId)return;const p=!a.moved;a.pointerId=null,a.startX=null,a.startY=null,a.moved=!1,a.lastY=null,a.lastTime=null;try{e.releasePointerCapture(t.pointerId)}catch{}if(p){b?E(t.clientX,t.clientY):R&&!j.current&&(j.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(a.velocity)<M){a.velocity=0;return}let l=B();const h=()=>{const w=B(),v=Math.max(w-l,8);l=w;const g=Ae(a.velocity*v)??!1,te=Math.sign(a.velocity),ye=Math.max(0,Math.abs(a.velocity)-ee*v);if(a.velocity=ye*te,!g||ye<=M){W(),a.velocity=0;return}a.rafId=window.requestAnimationFrame(h)};a.rafId=window.requestAnimationFrame(h)};e.addEventListener("pointerdown",P,T),e.addEventListener("pointermove",le,T),e.addEventListener("pointerup",me,T),e.addEventListener("pointercancel",me,T);const ue=e.style.touchAction;e.style.touchAction="manipulation",oe.current=()=>{W(),J.current!==null&&typeof window<"u"&&(window.clearTimeout(J.current),J.current=null),Re.current=0,e.removeEventListener("pointerdown",P,T),e.removeEventListener("pointermove",le,T),e.removeEventListener("pointerup",me,T),e.removeEventListener("pointercancel",me,T),e.style.touchAction=ue};return}const ae=6,De=a=>{a.touches.length===1&&(W(),r.lastY=a.touches[0].clientY,r.lastTime=B(),r.velocity=0,r.startX=a.touches[0].clientX,r.startY=a.touches[0].clientY,r.didMove=!1)},Se=a=>{if(a.touches.length!==1){r.lastY=null,r.lastTime=null,r.velocity=0,r.startX=null,r.startY=null,r.didMove=!1,W();return}const he=a.touches[0].clientX,P=a.touches[0].clientY;if(r.startX!==null&&r.startY!==null&&!r.didMove){const v=he-r.startX,g=P-r.startY;Math.hypot(v,g)>=ae&&(r.didMove=!0)}if(r.lastY===null){r.lastY=P,r.lastTime=B();return}const le=r.lastY,me=r.lastTime??B(),ue=B();r.lastY=P,r.lastTime=ue;const t=le-P;if(Math.abs(t)<1)return;const p=Math.max(ue-me,8),l=s+Math.min(m,Math.abs(t)/o),h=t*l,w=h/p;r.velocity=r.velocity*(1-k)+w*k,r.velocity>y?r.velocity=y:r.velocity<-y&&(r.velocity=-y),r.didMove&&(a.preventDefault(),a.stopPropagation()),Ae(h)},q=a=>{const he=!r.didMove;r.lastY=null,r.lastTime=null;const P=r.velocity;if(r.startX=null,r.startY=null,r.didMove=!1,he){const ue=a.changedTouches?.[0];b?E(ue?.clientX,ue?.clientY):R&&!j.current&&(j.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(P)<M){r.velocity=0;return}let le=B();const me=()=>{const ue=B(),t=Math.max(ue-le,8);le=ue;const p=Ae(r.velocity*t)??!1,l=Math.sign(r.velocity),h=Math.max(0,Math.abs(r.velocity)-ee*t);if(r.velocity=h*l,!p||h<=M){W(),r.velocity=0;return}r.rafId=window.requestAnimationFrame(me)};r.rafId=window.requestAnimationFrame(me)};e.addEventListener("touchstart",De,T),e.addEventListener("touchmove",Se,T),e.addEventListener("touchend",q,T),e.addEventListener("touchcancel",q,T);const ce=e.style.touchAction;e.style.touchAction="manipulation",oe.current=()=>{W(),J.current!==null&&typeof window<"u"&&(window.clearTimeout(J.current),J.current=null),Re.current=0,e.removeEventListener("touchstart",De,T),e.removeEventListener("touchmove",Se,T),e.removeEventListener("touchend",q,T),e.removeEventListener("touchcancel",q,T),e.style.touchAction=ce}},[R,b,E,G]);n.useEffect(()=>{let e=!1,i=null,s=null,m=null,o=[],k=null,y=null;const M=O.current;if(!M)return;if(M.tabIndex=b?-1:0,b){const W=M.focus.bind(M),T=M;T.focus=((...K)=>{E()}),y=()=>{T.focus=W}}const ee=()=>{A(!0)},r=()=>{A(!1)},B=W=>{const T=W.target;if(T&&M.contains(T)){if(b&&T instanceof HTMLElement){window.setTimeout(()=>{T.blur(),E()},0),A(!1);return}if(R&&!j.current&&T instanceof HTMLElement){window.setTimeout(()=>{T.blur()},0),A(!1);return}A(!0);return}A(!1)},F=()=>{A(!1)};let U=null;return(async()=>{try{const W=await jt();if(e)return;const T=Vt($,G,C,W,!1),K=new vt(T);ge.current=!0,b&&(K.focus=()=>{});const ae=K;if(typeof ae.scrollToBottom=="function"){const ce=ae.scrollToBottom.bind(ae);ae.scrollToBottom=()=>{ge.current&&ce()},k=()=>{ae.scrollToBottom=ce}}const De=new Tt;i=K,I.current=K,et.current=De,K.loadAddon(De),K.open(M),ct(),Fe.current=!1,U=K.textarea??M.querySelector("textarea"),U&&(U.addEventListener("focus",ee),U.addEventListener("blur",r)),rt(),typeof MutationObserver<"u"&&(m=new MutationObserver(()=>{rt()}),m.observe(M,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["contenteditable","role","tabindex","aria-label"]}));const Se=Lt(M);Se?(Se.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),Ve.current=Se,ft()):Ve.current=null,H();const q=De;typeof q.observeResize=="function"&&q.observeResize(),Pe(),o=[K.onData(ce=>{Y.current(ce)}),K.onScroll(ce=>{if(typeof ce=="number"&&Number.isFinite(ce)){const a=typeof K.hasSelection=="function"&&K.hasSelection();ge.current=!a&&ce<=.5}}),K.onSelectionChange(()=>{if(typeof K.hasSelection=="function"&&K.hasSelection()){ge.current=!1;return}const a=typeof K.getViewportY=="function"?K.getViewportY():0;ge.current=a<=.5})],s=new ResizeObserver(()=>{H()}),s.observe(M),typeof window<"u"&&window.setTimeout(()=>{H()},0)}catch{}})(),document.addEventListener("focusin",B,!0),window.addEventListener("blur",F),()=>{e=!0,oe.current?.(),oe.current=null,document.removeEventListener("focusin",B,!0),window.removeEventListener("blur",F),o.forEach(W=>W.dispose()),k?.(),k=null,U&&(U.removeEventListener("focus",ee),U.removeEventListener("blur",r)),s?.disconnect(),m?.disconnect(),y?.(),i?.dispose(),I.current=null,et.current=null,Ve.current=null,x.current=null,Fe.current=null,ie()}},[rt,R,H,E,$,G,Pe,C,ie,A,b]),n.useEffect(()=>{const e=I.current;e&&(e.reset(),ie(),x.current=null,H())},[u,nt,H,ie]),n.useEffect(()=>{!at||!I.current||L()},[at,L,u,nt]),n.useEffect(()=>(Pe(),()=>{oe.current?.(),oe.current=null}),[Pe,u]),n.useEffect(()=>{const e=I.current;if(!e)return;if(c.length===0){Le.current!==null&&(e.reset(),ie(),H());return}const i=Le.current;let s;if(i===null)s=c;else{const m=c.findIndex(o=>o.id===i);s=m>=0?c.slice(m+1):c}s.length>0&&$e(s.map(m=>m.data).join("")),Le.current=c[c.length-1].id},[c,nt,$e,H,ie]),n.useImperativeHandle(Ce,()=>({focus:()=>{L()},clear:()=>{const e=I.current;e&&(e.reset(),ie(),H())},fit:()=>{H()}}),[L,H,ie]);const Ge=n.useCallback(e=>{if(!b)return;const i=O.current,s=e.relatedTarget,m=s?.tagName,o=m==="INPUT"||m==="TEXTAREA"||s?.isContentEditable,k=s?.getAttribute("data-terminal-hidden-input")==="true",y=!!(s&&i?.contains(s))},[b]),Oe=n.useCallback(e=>{const i=e.nativeEvent,s=i?.inputType??"",m=typeof i?.data=="string"?i.data:"";if(V.current=typeof performance<"u"?performance.now():Date.now(),s==="insertCompositionText"){de.current=!0;return}if(!s&&m){if(de.current)return;e.preventDefault(),Y.current(m),xe.current={type:"insertText",at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0;return}if(s==="insertText"&&m){if(de.current)return;e.preventDefault(),Y.current(m),xe.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0;return}if(s==="insertLineBreak"){if(de.current)return;e.preventDefault(),Y.current("\r"),xe.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0;return}if(s==="deleteContentBackward"){if(de.current)return;e.preventDefault(),Y.current(""),xe.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0}},[]),ot=n.useCallback(e=>{const i=e.currentTarget;if(V.current=typeof performance<"u"?performance.now():Date.now(),de.current)return;if(Z.current){const o=xe.current,k=typeof performance<"u"?performance.now():Date.now();if(o&&k-o.at<50){Z.current=!1,z(i);return}Z.current=!1}const s=N(i);if(!s)return;we.current=s;const m=s.replace(/\r\n|\r|\n/g,"\r");Y.current(m),z(i),we.current=""},[z,N]),_e=n.useCallback(e=>{e.stopPropagation();const i=e.key.toLowerCase(),s=e.metaKey&&!e.ctrlKey&&!e.altKey&&i==="c",m=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&i==="c";if((s||m)&&Q()){e.preventDefault(),ve();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){const F=e.key.toUpperCase();if(F>="A"&&F<="Z"){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),Y.current(String.fromCharCode(F.charCodeAt(0)-64)),z(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),Y.current("\x1B"+e.key),z(e.currentTarget);return}const k={ArrowUp:"\x1B[A",ArrowDown:"\x1B[B",ArrowRight:"\x1B[C",ArrowLeft:"\x1B[D",Escape:"\x1B",Tab:" ",Delete:"\x1B[3~",Home:"\x1B[H",End:"\x1B[F"}[e.key];if(k){e.preventDefault(),Y.current(k),z(e.currentTarget);return}const y=e.currentTarget;if(e.nativeEvent?.isComposing)return;const ee=xe.current,r=typeof performance<"u"?performance.now():Date.now(),B=!!(ee&&r-ee.at<50);if(e.key==="Enter"){if(B&&ee?.type==="insertLineBreak")return;e.preventDefault(),Y.current("\r"),z(y);return}if(e.key==="Backspace"){if(e.preventDefault(),B&&ee?.type==="deleteContentBackward")return;N(y)||Y.current("")}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const F=V.current;F&&r-F<50||(e.preventDefault(),Y.current(e.key),Z.current=!0,xe.current={type:"keydown-text",at:r})}Ke(y)},[z,ve,Q,N,Ke]),Ye=n.useCallback(e=>{e.stopPropagation();const i=e.currentTarget;e.nativeEvent?.isComposing||Ke(i)},[Ke]),Je=n.useCallback(e=>{const i=e.currentTarget;de.current=!1;const s=e.data||N(i);if(V.current=typeof performance<"u"?performance.now():Date.now(),!s)return;const m=s.replace(/\r\n|\r|\n/g,"\r");Y.current(m),z(i),xe.current={type:"compositionend",at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0},[z,N]),He=n.useCallback(e=>{e.stopPropagation();const i=e.clipboardData?.getData("text")??"";if(!i)return;e.preventDefault();const m=I.current?.hasBracketedPaste?.()?`\x1B[200~${i}\x1B[201~`:i;Y.current(m)},[]),ke={position:"fixed",left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:"transparent",color:"transparent",WebkitTextFillColor:"transparent",caretColor:"transparent",textShadow:"none",WebkitAppearance:"none",appearance:"none",resize:"none",overflow:"hidden",whiteSpace:"nowrap",border:"0",padding:0,margin:0,outline:"none",outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:"none",WebkitUserSelect:"none",userSelect:"none"};return f.jsxs("div",{ref:O,className:Ze("relative h-full w-full terminal-viewport-container",be),"data-hidden-input-overlay-active":b?"true":void 0,style:{backgroundColor:C.background},onTouchStart:e=>{if(!(!b||R)&&!Q()){const i=e.touches?.[0];E(i?.clientX,i?.clientY)}},onClick:e=>{if(!R)if(b){if(Q())return;E(e.clientX,e.clientY)}else I.current?.focus()},onMouseUp:()=>{!R&&Q()&&ve()},onTouchEnd:()=>{!R&&Q()&&ve()},children:[b&&typeof document<"u"?xt.createPortal(f.jsxs(f.Fragment,{children:[f.jsx("input",{ref:We,type:"text",inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":_("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...ke,display:pe?"block":"none"},onBlur:Ge,onBeforeInput:Oe,onCompositionStart:()=>{de.current=!0},onInput:ot,onKeyDown:_e,onKeyUp:Ye,onCompositionEnd:Je,onPaste:He}),f.jsx("textarea",{ref:se,inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":_("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...ke,display:pe?"none":"block"},onBlur:Ge,onBeforeInput:Oe,onCompositionStart:()=>{de.current=!0},onInput:ot,onKeyDown:_e,onKeyUp:Ye,onCompositionEnd:Je,onPaste:He})]}),document.body):null,Ve.current&&!R?f.jsx(Et,{containerRef:Ve,disableHorizontal:!0,className:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero"}):null]})});gt.displayName="TerminalViewport";const Ft="\x1B",Kt=new RegExp(`${Ft}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Ot=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,Yt=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,Ht=/Serving HTTP on .*? port (\d{2,5})/i,zt=new Set([".",",",";",":","!","?"]),Ut=u=>{let c=u;for(;c.length>0;){const d=c[c.length-1];if(d===")"||d==="]"||d==="}"||d===">"){const S=d===")"?"(":d==="]"?"[":d==="}"?"{":"<",C=c.slice(0,-1),$=(C.match(new RegExp(`\\${S}`,"g"))||[]).length,G=(C.match(new RegExp(`\\${d}`,"g"))||[]).length;if($>G)break;c=C;continue}if(zt.has(d)){c=c.slice(0,-1);continue}break}return c},yt=u=>{let c=Ut(u);return c=c.replace("0.0.0.0","127.0.0.1"),c=c.replace("[::1]","127.0.0.1"),c=c.replace("[::]","127.0.0.1"),c},Wt=u=>{if(!u)return null;const c=u.replace(Kt,""),d=c.match(Ht);if(d?.[1]){const C=Number.parseInt(d[1],10);if(Number.isFinite(C)&&C>0&&C<=65535)return`http://127.0.0.1:${C}/`}const S=c.split(`
|
|
2
|
-
`);for(const C of S){if(!Yt.test(C))continue;const $=Array.from(C.matchAll(Ot));if($.length===0)continue;const G=$.find(be=>{try{return!!new URL(yt(be[1])).port}catch{return!1}});return yt((G??$[0])[1])}return null},qt=async(u,c=1500)=>{if(!u||typeof window>"u")return!1;let d;try{d=new URL(u)}catch{return!1}if(d.protocol!=="http:"&&d.protocol!=="https:")return!1;const S=d.hostname.toLowerCase();if(S!=="localhost"&&S!=="127.0.0.1"&&S!=="0.0.0.0"&&S!=="::1"&&S!=="::")return!1;const C=new AbortController,$=window.setTimeout(()=>C.abort(),c);try{const G=await fetch("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:d.toString()}),cache:"no-store",signal:C.signal});return G.ok?(await G.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout($)}},Xt={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},ut={ctrl:"5",cmd:"3"},mt={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},$t={retry:{...mt.retry,initialDelayMs:200,maxDelayMs:500},connectionTimeoutMs:1500},Gt=(u,c)=>{if(c)switch(u){case"arrow-up":return`\x1B[1;${ut[c]}A`;case"arrow-down":return`\x1B[1;${ut[c]}B`;case"arrow-right":return`\x1B[1;${ut[c]}C`;case"arrow-left":return`\x1B[1;${ut[c]}D`}return Xt[u]??null},tn=()=>{const{t:u}=bt(),{terminal:c,runtime:d}=Rt(),{currentTheme:S}=At(),{monoFont:C}=St(),$=Me(t=>t.terminalFontSize),G=Me(t=>t.bottomTerminalHeight),be=Me(t=>t.isBottomTerminalExpanded),{isMobile:R,isTablet:at,hasTouchOnlyPointer:Ne}=It(),Ce=R||at,_=(Ce||Ne)&&d.platform==="web",O=d.platform!=="vscode",
|
|
1
|
+
import{R as n,j as f,x as xt,bC as vt,bD as Tt,bE as kt}from"./vendor-.bun-CV3tusA8.js";import{u as bt,v as Ct,b0 as Et,c as Ze,M as Rt,bP as At,f1 as St,a as Me,b as It,W as ht,bo as Mt,I as fe,f2 as it,cH as dt,as as ne}from"./modelPrefsAutoSave-wwnbqBk7.js";import{u as X,P as Pt,S as Bt}from"./main-BF3kWAJ9.js";import{ac as Dt}from"./index-3WXrN3AX.js";function Nt(u){const{colors:c}=u,d=c.syntax.base;return{background:c.surface.background,foreground:d.foreground,cursor:c.interactive.cursor,cursorAccent:c.surface.background,selectionBackground:c.interactive.selection,selectionForeground:c.interactive.selectionForeground,selectionInactiveBackground:c.interactive.selection+"50",black:c.surface.muted,red:c.status.error,green:c.status.success,yellow:c.status.warning,blue:d.function,magenta:d.keyword,cyan:d.type,white:d.foreground,brightBlack:d.comment,brightRed:c.status.error,brightGreen:c.status.success,brightYellow:c.status.warning,brightBlue:d.function,brightMagenta:d.keyword,brightCyan:d.type,brightWhite:c.surface.elevatedForeground}}function jt(u,c,d,S,C=!1){const G=`${u}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`;return{cursorBlink:!1,cursorStyle:"bar",fontSize:c,lineHeight:1.15,fontFamily:G,allowTransparency:!1,theme:{background:d.background,foreground:d.foreground,cursor:d.cursor,cursorAccent:d.cursorAccent,selectionBackground:d.selectionBackground,selectionForeground:d.selectionForeground,black:d.black,red:d.red,green:d.green,yellow:d.yellow,blue:d.blue,magenta:d.magenta,cyan:d.cyan,white:d.white,brightBlack:d.brightBlack,brightRed:d.brightRed,brightGreen:d.brightGreen,brightYellow:d.brightYellow,brightBlue:d.brightBlue,brightMagenta:d.brightMagenta,brightCyan:d.brightCyan,brightWhite:d.brightWhite},scrollback:1e4,ghostty:S,disableStdin:C}}let pt=null;function Vt(){return pt||(pt=kt.load()),pt}function Lt(u){if(typeof window>"u")return null;const c=[u,...Array.from(u.querySelectorAll("*"))];let d=null;for(const S of c){const $=window.getComputedStyle(S).overflowY;if(!($!=="auto"&&$!=="scroll")){if(S.scrollHeight-S.clientHeight>2)return S;d||(d=S)}}return d}const gt=n.forwardRef(({sessionKey:u,chunks:c,onInput:d,onResize:S,theme:C,fontFamily:$,fontSize:G,className:be,enableTouchScroll:R,autoFocus:at=!0,isVisible:Ne=!0},Ce)=>{const{t:_}=bt(),O=n.useRef(null),je=n.useRef(null),I=n.useRef(null),et=n.useRef(null),Y=n.useRef(d),Ue=n.useRef(S),x=n.useRef(null),Ee=n.useRef(""),re=n.useRef(null),Ve=n.useRef(!1),Le=n.useRef(null),ge=n.useRef(!0),oe=n.useRef(null),J=n.useRef(null),Re=n.useRef(0),se=n.useRef(null),We=n.useRef(null),de=n.useRef(!1),Z=n.useRef(!1),xe=n.useRef(null),j=n.useRef(null),D=n.useRef(null),we=n.useRef(""),Fe=n.useRef(null),V=n.useRef(!R),tt=n.useRef(Ne),[,ft]=n.useReducer(e=>e+1,0),[nt,ct]=n.useReducer(e=>e+1,0);Y.current=d,Ue.current=S;const lt=typeof navigator<"u"&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform==="Android"),b=!!R;n.useEffect(()=>{if(!R){V.current=!0,tt.current=Ne;return}!tt.current&&Ne&&(V.current=!1),tt.current=Ne},[R,Ne]);const rt=n.useCallback(()=>{if(!b)return;const e=O.current,i=se.current;if(!e)return;const s=[];e.getAttribute("contenteditable")==="true"&&s.push(e),s.push(...Array.from(e.querySelectorAll('[contenteditable="true"]'))),s.forEach(o=>{o.setAttribute("data-terminal-disabled-contenteditable","true"),o.setAttribute("contenteditable","false"),o.setAttribute("aria-hidden","true"),o.tabIndex=-1,o.style.setProperty("caret-color","transparent"),o.style.color="transparent",o.style.setProperty("-webkit-text-fill-color","transparent"),o.style.background="transparent",o.style.outline="none",o.style.boxShadow="none",o.style.textShadow="none",o.style.setProperty("user-select","none"),o.style.setProperty("-webkit-user-select","none")}),e.tabIndex=-1,e.removeAttribute("role"),e.removeAttribute("aria-multiline"),Array.from(e.querySelectorAll("textarea")).forEach(o=>{o.style.setProperty("caret-color","transparent"),o.style.color="transparent",o.style.setProperty("-webkit-text-fill-color","transparent"),o.style.background="transparent",o.style.border="0",o.style.outline="none",o.style.boxShadow="none",o.style.textShadow="none",o.style.fontSize="0",o.style.lineHeight="0",o!==i&&o.getAttribute("data-terminal-disabled-input")!=="true"&&(o.setAttribute("data-terminal-disabled-input","true"),o.setAttribute("aria-hidden","true"),o.tabIndex=-1,o.disabled=!0,o.style.position="absolute",o.style.opacity="0",o.style.width="0px",o.style.height="0px",o.style.pointerEvents="none",o.style.zIndex="-1")})},[b]),A=n.useCallback(e=>{if(Fe.current===e)return;const i=I.current;if(i)try{if(typeof i.setOption=="function"){i.setOption("cursorBlink",e),Fe.current=e;return}i.options&&(i.options.cursorBlink=e,Fe.current=e)}catch{}},[]),pe=b&<,E=n.useCallback((e,i)=>{const s=pe?We.current:se.current,m=O.current;if(!s||!m)return;const o=m.getBoundingClientRect(),k=typeof window<"u"?window.innerWidth:o.width,y=typeof window<"u"?window.innerHeight:o.height,M=o.left+o.width/2,ee=o.top+o.height-12,r=typeof e=="number"?e:M,P=typeof i=="number"?i:ee,F=8,U=Math.max(F,Math.min(k-F,r)),Ae=Math.max(F,Math.min(y-F,P));s.style.left=`${U}px`,s.style.top=`${Ae}px`,s.style.bottom="",(s instanceof HTMLTextAreaElement||s instanceof HTMLInputElement)&&(s.disabled=!1,s.readOnly=!1,s.removeAttribute("disabled"),s.removeAttribute("readonly"));try{s.focus({preventScroll:!0})}catch{try{s.focus()}catch{}}},[pe]),L=n.useCallback(()=>{if(b){E(),A(!0);return}I.current?.focus(),A(!0)},[E,A,b]),N=n.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??"",[]),z=n.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value="";return}e.textContent=""},[]),Ke=n.useCallback(e=>{if(typeof window>"u"||pe)return;D.current!==null&&(window.clearTimeout(D.current),D.current=null);let i=0;const s=3,m=()=>{D.current=window.setTimeout(()=>{D.current=null;const o=N(e);if(!o){if(i+=1,i<s){m();return}return}const k=we.current;we.current=o;const y=o.startsWith(k)?o.slice(k.length):o;y&&Y.current(y.replace(/\r\n|\r|\n/g,"\r")),z(e),we.current=""},i===0?0:24)};m()},[z,N,pe]);n.useEffect(()=>{const e=O.current;if(!b||!e||R)return;const i=s=>{const m=s.target;if(m&&m.getAttribute("data-terminal-hidden-input")!=="true"&&e.contains(m)){try{m.blur()}catch{}E()}};return e.addEventListener("focusin",i,!0),()=>{e.removeEventListener("focusin",i,!0)}},[R,b,E]);const qe=n.useCallback(()=>{const e=I.current;if(!e||typeof e.getSelection!="function")return"";const i=e.getSelection();return typeof i=="string"?i:""},[]),Xe=n.useCallback(()=>{if(typeof window>"u")return"";const e=window.getSelection();if(!e)return"";const i=e.toString();if(!i.trim())return"";const s=O.current;if(!s)return"";const m=e.anchorNode,o=e.focusNode;return m&&!s.contains(m)||o&&!s.contains(o)?"":i},[]),ve=n.useCallback(async()=>{if(typeof document>"u")return;const e=qe()||Xe();e.trim()&&await Ct(e)},[Xe,qe]),Q=n.useCallback(()=>qe().trim()?!0:!!Xe().trim(),[Xe,qe]);n.useEffect(()=>{if(typeof window>"u")return;const e=i=>{Q()&&(i.preventDefault(),ve())};return window.addEventListener("openchamber:copy",e),()=>{window.removeEventListener("openchamber:copy",e)}},[ve,Q]);const ie=n.useCallback(()=>{Ee.current="",re.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(re.current),re.current=null,Ve.current=!1,Le.current=null},[]),H=n.useCallback(()=>{const e=et.current,i=I.current,s=O.current;if(!e||!i||!s)return;const m=s.getBoundingClientRect();if(!(m.width<24||m.height<24))try{e.fit();const o={cols:i.cols,rows:i.rows},k=x.current;(!k||k.cols!==o.cols||k.rows!==o.rows)&&(x.current=o,Ue.current(o.cols,o.rows))}catch{}},[]),Te=n.useCallback(()=>{if(Ve.current)return;const e=I.current;if(!e){ie();return}if(!Ee.current)return;const i=Ee.current;Ee.current="",Ve.current=!0,e.write(i,()=>{Ve.current=!1,Ee.current&&(typeof window<"u"?re.current=window.requestAnimationFrame(()=>{re.current=null,Te()}):Te())})},[ie]),Pe=n.useCallback(()=>{re.current===null&&(typeof window<"u"?re.current=window.requestAnimationFrame(()=>{re.current=null,Te()}):Te())},[Te]),$e=n.useCallback(e=>{e&&(Ee.current+=e,Pe())},[Pe]),Be=n.useCallback(()=>{if(oe.current?.(),oe.current=null,J.current!==null&&typeof window<"u"&&(window.clearTimeout(J.current),J.current=null),!R){Re.current=0;return}const e=O.current;if(!e)return;const i=I.current;if(!i)return;Re.current=0;const s=2.2,m=2.8,o=25,k=.25,y=8,M=.05,ee=.015,r={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},P=()=>typeof performance<"u"?performance.now():Date.now(),F=Math.max(12,Math.round(G*1.35));let U=0;const Ae=a=>{if(!a)return!1;const he=i.getViewportY(),B=U+a,le=Math.trunc(B/F);return U=B-le*F,le!==0&&i.scrollLines(le),i.getViewportY()!==he},W=()=>{r.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(r.rafId),r.rafId=null},T={passive:!1,capture:!1};if(typeof window<"u"&&"PointerEvent"in window){const a=Object.assign(r,{pointerId:null,startX:null,startY:null,moved:!1}),he=6,B=t=>{if(t.pointerType==="touch"){W(),a.pointerId=t.pointerId,a.startX=t.clientX,a.startY=t.clientY,a.moved=!1,a.lastY=t.clientY,a.lastTime=P(),a.velocity=0;try{e.setPointerCapture(t.pointerId)}catch{}}},le=t=>{if(t.pointerType!=="touch"||a.pointerId!==t.pointerId)return;if(a.startX!==null&&a.startY!==null&&!a.moved){const Ie=t.clientX-a.startX,ze=t.clientY-a.startY;Math.hypot(Ie,ze)>=he&&(a.moved=!0)}if(a.lastY===null){a.lastY=t.clientY,a.lastTime=P();return}const p=a.lastY,l=a.lastTime??P(),h=P();a.lastY=t.clientY,a.lastTime=h;const w=p-t.clientY;if(Math.abs(w)<1)return;const v=Math.max(h-l,8),g=s+Math.min(m,Math.abs(w)/o),te=w*g,ye=te/v;a.velocity=a.velocity*(1-k)+ye*k,a.velocity>y?a.velocity=y:a.velocity<-y&&(a.velocity=-y),a.moved&&(t.cancelable&&t.preventDefault(),t.stopPropagation()),Ae(te)},me=t=>{if(t.pointerType!=="touch"||a.pointerId!==t.pointerId)return;const p=!a.moved;a.pointerId=null,a.startX=null,a.startY=null,a.moved=!1,a.lastY=null,a.lastTime=null;try{e.releasePointerCapture(t.pointerId)}catch{}if(p){b?E(t.clientX,t.clientY):R&&!V.current&&(V.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(a.velocity)<M){a.velocity=0;return}let l=P();const h=()=>{const w=P(),v=Math.max(w-l,8);l=w;const g=Ae(a.velocity*v)??!1,te=Math.sign(a.velocity),ye=Math.max(0,Math.abs(a.velocity)-ee*v);if(a.velocity=ye*te,!g||ye<=M){W(),a.velocity=0;return}a.rafId=window.requestAnimationFrame(h)};a.rafId=window.requestAnimationFrame(h)};e.addEventListener("pointerdown",B,T),e.addEventListener("pointermove",le,T),e.addEventListener("pointerup",me,T),e.addEventListener("pointercancel",me,T);const ue=e.style.touchAction;e.style.touchAction="manipulation",oe.current=()=>{W(),J.current!==null&&typeof window<"u"&&(window.clearTimeout(J.current),J.current=null),Re.current=0,e.removeEventListener("pointerdown",B,T),e.removeEventListener("pointermove",le,T),e.removeEventListener("pointerup",me,T),e.removeEventListener("pointercancel",me,T),e.style.touchAction=ue};return}const ae=6,De=a=>{a.touches.length===1&&(W(),r.lastY=a.touches[0].clientY,r.lastTime=P(),r.velocity=0,r.startX=a.touches[0].clientX,r.startY=a.touches[0].clientY,r.didMove=!1)},Se=a=>{if(a.touches.length!==1){r.lastY=null,r.lastTime=null,r.velocity=0,r.startX=null,r.startY=null,r.didMove=!1,W();return}const he=a.touches[0].clientX,B=a.touches[0].clientY;if(r.startX!==null&&r.startY!==null&&!r.didMove){const v=he-r.startX,g=B-r.startY;Math.hypot(v,g)>=ae&&(r.didMove=!0)}if(r.lastY===null){r.lastY=B,r.lastTime=P();return}const le=r.lastY,me=r.lastTime??P(),ue=P();r.lastY=B,r.lastTime=ue;const t=le-B;if(Math.abs(t)<1)return;const p=Math.max(ue-me,8),l=s+Math.min(m,Math.abs(t)/o),h=t*l,w=h/p;r.velocity=r.velocity*(1-k)+w*k,r.velocity>y?r.velocity=y:r.velocity<-y&&(r.velocity=-y),r.didMove&&(a.preventDefault(),a.stopPropagation()),Ae(h)},q=a=>{const he=!r.didMove;r.lastY=null,r.lastTime=null;const B=r.velocity;if(r.startX=null,r.startY=null,r.didMove=!1,he){const ue=a.changedTouches?.[0];b?E(ue?.clientX,ue?.clientY):R&&!V.current&&(V.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(B)<M){r.velocity=0;return}let le=P();const me=()=>{const ue=P(),t=Math.max(ue-le,8);le=ue;const p=Ae(r.velocity*t)??!1,l=Math.sign(r.velocity),h=Math.max(0,Math.abs(r.velocity)-ee*t);if(r.velocity=h*l,!p||h<=M){W(),r.velocity=0;return}r.rafId=window.requestAnimationFrame(me)};r.rafId=window.requestAnimationFrame(me)};e.addEventListener("touchstart",De,T),e.addEventListener("touchmove",Se,T),e.addEventListener("touchend",q,T),e.addEventListener("touchcancel",q,T);const ce=e.style.touchAction;e.style.touchAction="manipulation",oe.current=()=>{W(),J.current!==null&&typeof window<"u"&&(window.clearTimeout(J.current),J.current=null),Re.current=0,e.removeEventListener("touchstart",De,T),e.removeEventListener("touchmove",Se,T),e.removeEventListener("touchend",q,T),e.removeEventListener("touchcancel",q,T),e.style.touchAction=ce}},[R,b,E,G]);n.useEffect(()=>{let e=!1,i=null,s=null,m=null,o=[],k=null,y=null;const M=O.current;if(!M)return;if(M.tabIndex=b?-1:0,b){const W=M.focus.bind(M),T=M;T.focus=((...K)=>{E()}),y=()=>{T.focus=W}}const ee=()=>{A(!0)},r=()=>{A(!1)},P=W=>{const T=W.target;if(T&&M.contains(T)){if(b&&T instanceof HTMLElement){window.setTimeout(()=>{T.blur(),E()},0),A(!1);return}if(R&&!V.current&&T instanceof HTMLElement){window.setTimeout(()=>{T.blur()},0),A(!1);return}A(!0);return}A(!1)},F=()=>{A(!1)};let U=null;return(async()=>{try{const W=await Vt();if(e)return;const T=jt($,G,C,W,!1),K=new vt(T);ge.current=!0,b&&(K.focus=()=>{});const ae=K;if(typeof ae.scrollToBottom=="function"){const ce=ae.scrollToBottom.bind(ae);ae.scrollToBottom=()=>{ge.current&&ce()},k=()=>{ae.scrollToBottom=ce}}const De=new Tt;i=K,I.current=K,et.current=De,K.loadAddon(De),K.open(M),ct(),Fe.current=!1,U=K.textarea??M.querySelector("textarea"),U&&(U.addEventListener("focus",ee),U.addEventListener("blur",r)),rt(),typeof MutationObserver<"u"&&(m=new MutationObserver(()=>{rt()}),m.observe(M,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["contenteditable","role","tabindex","aria-label"]}));const Se=Lt(M);Se?(Se.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),je.current=Se,ft()):je.current=null,H();const q=De;typeof q.observeResize=="function"&&q.observeResize(),Be(),o=[K.onData(ce=>{Y.current(ce)}),K.onScroll(ce=>{if(typeof ce=="number"&&Number.isFinite(ce)){const a=typeof K.hasSelection=="function"&&K.hasSelection();ge.current=!a&&ce<=.5}}),K.onSelectionChange(()=>{if(typeof K.hasSelection=="function"&&K.hasSelection()){ge.current=!1;return}const a=typeof K.getViewportY=="function"?K.getViewportY():0;ge.current=a<=.5})],s=new ResizeObserver(()=>{H()}),s.observe(M),typeof window<"u"&&window.setTimeout(()=>{H()},0)}catch{}})(),document.addEventListener("focusin",P,!0),window.addEventListener("blur",F),()=>{e=!0,oe.current?.(),oe.current=null,document.removeEventListener("focusin",P,!0),window.removeEventListener("blur",F),o.forEach(W=>W.dispose()),k?.(),k=null,U&&(U.removeEventListener("focus",ee),U.removeEventListener("blur",r)),s?.disconnect(),m?.disconnect(),y?.(),i?.dispose(),I.current=null,et.current=null,je.current=null,x.current=null,Fe.current=null,ie()}},[rt,R,H,E,$,G,Be,C,ie,A,b]),n.useEffect(()=>{const e=I.current;e&&(e.reset(),ie(),x.current=null,H())},[u,nt,H,ie]),n.useEffect(()=>{!at||!I.current||L()},[at,L,u,nt]),n.useEffect(()=>(Be(),()=>{oe.current?.(),oe.current=null}),[Be,u]),n.useEffect(()=>{const e=I.current;if(!e)return;if(c.length===0){Le.current!==null&&(e.reset(),ie(),H());return}const i=Le.current;let s;if(i===null)s=c;else{const m=c.findIndex(o=>o.id===i);s=m>=0?c.slice(m+1):c}s.length>0&&$e(s.map(m=>m.data).join("")),Le.current=c[c.length-1].id},[c,nt,$e,H,ie]),n.useImperativeHandle(Ce,()=>({focus:()=>{L()},clear:()=>{const e=I.current;e&&(e.reset(),ie(),H())},fit:()=>{H()}}),[L,H,ie]);const Ge=n.useCallback(e=>{if(!b)return;const i=O.current,s=e.relatedTarget,m=s?.tagName,o=m==="INPUT"||m==="TEXTAREA"||s?.isContentEditable,k=s?.getAttribute("data-terminal-hidden-input")==="true",y=!!(s&&i?.contains(s))},[b]),Oe=n.useCallback(e=>{const i=e.nativeEvent,s=i?.inputType??"",m=typeof i?.data=="string"?i.data:"";if(j.current=typeof performance<"u"?performance.now():Date.now(),s==="insertCompositionText"){de.current=!0;return}if(!s&&m){if(de.current)return;e.preventDefault(),Y.current(m),xe.current={type:"insertText",at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0;return}if(s==="insertText"&&m){if(de.current)return;e.preventDefault(),Y.current(m),xe.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0;return}if(s==="insertLineBreak"){if(de.current)return;e.preventDefault(),Y.current("\r"),xe.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0;return}if(s==="deleteContentBackward"){if(de.current)return;e.preventDefault(),Y.current(""),xe.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0}},[]),ot=n.useCallback(e=>{const i=e.currentTarget;if(j.current=typeof performance<"u"?performance.now():Date.now(),de.current)return;if(Z.current){const o=xe.current,k=typeof performance<"u"?performance.now():Date.now();if(o&&k-o.at<50){Z.current=!1,z(i);return}Z.current=!1}const s=N(i);if(!s)return;we.current=s;const m=s.replace(/\r\n|\r|\n/g,"\r");Y.current(m),z(i),we.current=""},[z,N]),_e=n.useCallback(e=>{e.stopPropagation();const i=e.key.toLowerCase(),s=e.metaKey&&!e.ctrlKey&&!e.altKey&&i==="c",m=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&i==="c";if((s||m)&&Q()){e.preventDefault(),ve();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){const F=e.key.toUpperCase();if(F>="A"&&F<="Z"){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),Y.current(String.fromCharCode(F.charCodeAt(0)-64)),z(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),Y.current("\x1B"+e.key),z(e.currentTarget);return}const k={ArrowUp:"\x1B[A",ArrowDown:"\x1B[B",ArrowRight:"\x1B[C",ArrowLeft:"\x1B[D",Escape:"\x1B",Tab:" ",Delete:"\x1B[3~",Home:"\x1B[H",End:"\x1B[F"}[e.key];if(k){e.preventDefault(),Y.current(k),z(e.currentTarget);return}const y=e.currentTarget;if(e.nativeEvent?.isComposing)return;const ee=xe.current,r=typeof performance<"u"?performance.now():Date.now(),P=!!(ee&&r-ee.at<50);if(e.key==="Enter"){if(P&&ee?.type==="insertLineBreak")return;e.preventDefault(),Y.current("\r"),z(y);return}if(e.key==="Backspace"){if(e.preventDefault(),P&&ee?.type==="deleteContentBackward")return;N(y)||Y.current("")}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const F=j.current;F&&r-F<50||(e.preventDefault(),Y.current(e.key),Z.current=!0,xe.current={type:"keydown-text",at:r})}Ke(y)},[z,ve,Q,N,Ke]),Ye=n.useCallback(e=>{e.stopPropagation();const i=e.currentTarget;e.nativeEvent?.isComposing||Ke(i)},[Ke]),Je=n.useCallback(e=>{const i=e.currentTarget;de.current=!1;const s=e.data||N(i);if(j.current=typeof performance<"u"?performance.now():Date.now(),!s)return;const m=s.replace(/\r\n|\r|\n/g,"\r");Y.current(m),z(i),xe.current={type:"compositionend",at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0},[z,N]),He=n.useCallback(e=>{e.stopPropagation();const i=e.clipboardData?.getData("text")??"";if(!i)return;e.preventDefault();const m=I.current?.hasBracketedPaste?.()?`\x1B[200~${i}\x1B[201~`:i;Y.current(m)},[]),ke={position:"fixed",left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:"transparent",color:"transparent",WebkitTextFillColor:"transparent",caretColor:"transparent",textShadow:"none",WebkitAppearance:"none",appearance:"none",resize:"none",overflow:"hidden",whiteSpace:"nowrap",border:"0",padding:0,margin:0,outline:"none",outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:"none",WebkitUserSelect:"none",userSelect:"none"};return f.jsxs("div",{ref:O,className:Ze("relative h-full w-full terminal-viewport-container",be),"data-hidden-input-overlay-active":b?"true":void 0,style:{backgroundColor:C.background},onTouchStart:e=>{if(!(!b||R)&&!Q()){const i=e.touches?.[0];E(i?.clientX,i?.clientY)}},onClick:e=>{if(!R)if(b){if(Q())return;E(e.clientX,e.clientY)}else I.current?.focus()},onMouseUp:()=>{!R&&Q()&&ve()},onTouchEnd:()=>{!R&&Q()&&ve()},children:[b&&typeof document<"u"?xt.createPortal(f.jsxs(f.Fragment,{children:[f.jsx("input",{ref:We,type:"text",inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":_("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...ke,display:pe?"block":"none"},onBlur:Ge,onBeforeInput:Oe,onCompositionStart:()=>{de.current=!0},onInput:ot,onKeyDown:_e,onKeyUp:Ye,onCompositionEnd:Je,onPaste:He}),f.jsx("textarea",{ref:se,inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":_("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...ke,display:pe?"none":"block"},onBlur:Ge,onBeforeInput:Oe,onCompositionStart:()=>{de.current=!0},onInput:ot,onKeyDown:_e,onKeyUp:Ye,onCompositionEnd:Je,onPaste:He})]}),document.body):null,je.current&&!R?f.jsx(Et,{containerRef:je,disableHorizontal:!0,className:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero"}):null]})});gt.displayName="TerminalViewport";const Ft="\x1B",Kt=new RegExp(`${Ft}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Ot=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,Yt=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,Ht=/Serving HTTP on .*? port (\d{2,5})/i,zt=new Set([".",",",";",":","!","?"]),Ut=u=>{let c=u;for(;c.length>0;){const d=c[c.length-1];if(d===")"||d==="]"||d==="}"||d===">"){const S=d===")"?"(":d==="]"?"[":d==="}"?"{":"<",C=c.slice(0,-1),$=(C.match(new RegExp(`\\${S}`,"g"))||[]).length,G=(C.match(new RegExp(`\\${d}`,"g"))||[]).length;if($>G)break;c=C;continue}if(zt.has(d)){c=c.slice(0,-1);continue}break}return c},yt=u=>{let c=Ut(u);return c=c.replace("0.0.0.0","127.0.0.1"),c=c.replace("[::1]","127.0.0.1"),c=c.replace("[::]","127.0.0.1"),c},Wt=u=>{if(!u)return null;const c=u.replace(Kt,""),d=c.match(Ht);if(d?.[1]){const C=Number.parseInt(d[1],10);if(Number.isFinite(C)&&C>0&&C<=65535)return`http://127.0.0.1:${C}/`}const S=c.split(`
|
|
2
|
+
`);for(const C of S){if(!Yt.test(C))continue;const $=Array.from(C.matchAll(Ot));if($.length===0)continue;const G=$.find(be=>{try{return!!new URL(yt(be[1])).port}catch{return!1}});return yt((G??$[0])[1])}return null},qt=async(u,c=1500)=>{if(!u||typeof window>"u")return!1;let d;try{d=new URL(u)}catch{return!1}if(d.protocol!=="http:"&&d.protocol!=="https:")return!1;const S=d.hostname.toLowerCase();if(S!=="localhost"&&S!=="127.0.0.1"&&S!=="0.0.0.0"&&S!=="::1"&&S!=="::")return!1;const C=new AbortController,$=window.setTimeout(()=>C.abort(),c);try{const G=await fetch("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:d.toString()}),cache:"no-store",signal:C.signal});return G.ok?(await G.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout($)}},Xt={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},ut={ctrl:"5",cmd:"3"},mt={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},$t={retry:{...mt.retry,initialDelayMs:200,maxDelayMs:500},connectionTimeoutMs:1500},Gt=(u,c)=>{if(c)switch(u){case"arrow-up":return`\x1B[1;${ut[c]}A`;case"arrow-down":return`\x1B[1;${ut[c]}B`;case"arrow-right":return`\x1B[1;${ut[c]}C`;case"arrow-left":return`\x1B[1;${ut[c]}D`}return Xt[u]??null},tn=()=>{const{t:u}=bt(),{terminal:c,runtime:d}=Rt(),{currentTheme:S}=At(),{monoFont:C}=St(),$=Me(t=>t.terminalFontSize),G=Me(t=>t.bottomTerminalHeight),be=Me(t=>t.isBottomTerminalExpanded),{isMobile:R,isTablet:at,hasTouchOnlyPointer:Ne}=It(),Ce=R||at,_=(Ce||Ne)&&d.platform==="web",O=d.platform!=="vscode",je=Me(t=>t.showTerminalQuickKeysOnDesktop),I=Ce||je,et=ht(t=>t.currentSessionId),Y=ht(t=>t.newSessionDraft),Ue=et!==null||Y?.open===!0,x=Mt()??null,Ee=X(t=>t.sessions),re=X(t=>t.hasHydrated),Ve=X(t=>t.ensureDirectory),Le=X(t=>t.createTab),ge=X(t=>t.setActiveTab),oe=X(t=>t.closeTab),J=X(t=>t.setTabSessionId),Re=X(t=>t.setTabLifecycle),se=X(t=>t.setConnecting),We=X(t=>t.appendToBuffer),de=X(t=>t.setTabPreviewUrl),Z=X(t=>t.clearBuffer),xe=Me(t=>t.openContextPreview),j=n.useMemo(()=>{if(x)return Ee.get(x)},[Ee,x]),D=n.useMemo(()=>j?O?j.activeTabId??j.tabs[0]?.id??null:j.tabs[0]?.id??null:null,[j,O]),we=n.useMemo(()=>{if(j)return D?j.tabs.find(t=>t.id===D)??j.tabs[0]:j.tabs[0]},[j,D]),Fe=n.useMemo(()=>(j?.tabs??[]).map(t=>({icon:(()=>{const p=t.iconKey?Pt[t.iconKey]??"terminal":"terminal";return f.jsx(fe,{name:p,className:"h-4 w-4"})})(),id:t.id,label:t.label,title:t.label,closeLabel:u("terminalView.tabs.closeTabTitle")})),[j?.tabs,u]),V=we?.terminalSessionId??null,tt=we?.lifecycle??"idle",ft=we?.bufferChunks??[],nt=we?.isConnecting??!1,ct=we?.previewUrl??null,[lt,b]=n.useState(null),[rt,A]=n.useState(!1),[pe,E]=n.useState(!1),[L,N]=n.useState(null),[z,Ke]=n.useState(!1),[qe,Xe]=n.useState(0),ve=n.useRef(null),Q=n.useRef(null),ie=n.useRef(D),H=n.useRef(V),Te=n.useRef(x),Pe=n.useRef(null),$e=n.useRef(null),Be=n.useRef(!1),Ge=n.useRef(null),Oe=n.useRef(new Set),ot=n.useRef(!1),_e=n.useRef(""),Ye=n.useRef(new Set),Je=n.useRef(0),He=n.useCallback(()=>{_e.current="",Ye.current.clear(),Je.current+=1},[]),ke=n.useCallback(()=>{_||typeof document<"u"&&!document.hasFocus()||Pe.current?.focus()},[_]),e=n.useCallback(()=>{_||Pe.current?.focus()},[_]);n.useEffect(()=>{if(!re||ot.current)return;ot.current=!0;const t=new Set;for(const[,p]of X.getState().sessions.entries())for(const l of p.tabs)l.terminalSessionId&&t.add(l.terminalSessionId);Oe.current=t},[re]);const i=Me(t=>t.activeMainTab),s=Me(t=>t.isBottomTerminalOpen),m=Me(t=>t.setBottomTerminalOpen),o=Me(t=>t.setBottomTerminalExpanded),k=i==="terminal",y=k||s,[M,ee]=n.useState(y);n.useEffect(()=>{!y||d.platform==="vscode"||Dt()},[y,d.platform]),n.useEffect(()=>{y&&ee(!0)},[y]),n.useEffect(()=>{Be.current=y},[y]),n.useEffect(()=>{H.current=V},[V]),n.useEffect(()=>{ie.current=D,He()},[D,He]),n.useEffect(()=>{Te.current=x},[x]),n.useEffect(()=>{!I&&L!==null&&N(null)},[I,L,N]),n.useEffect(()=>{!V&&L!==null&&N(null)},[V,L,N]);const r=n.useCallback(()=>{ve.current?.(),ve.current=null,Q.current=null,E(!1)},[]);n.useEffect(()=>()=>{r(),H.current=null},[r]);const P=n.useCallback((t,p,l)=>{if(!l)return;const h=`${_e.current}${l}`.replace(/\r\n|\r/g,`
|
|
3
3
|
`),w=h.split(`
|
|
4
4
|
`),v=h.endsWith(`
|
|
5
5
|
`)?w.join(`
|
|
6
6
|
`):w.slice(0,-1).join(`
|
|
7
7
|
`);if(_e.current=h.endsWith(`
|
|
8
|
-
`)?"":(w[w.length-1]??"").slice(-1024),!v)return;const g=Wt(v);if(!g||Ye.current.has(g))return;const te=Je.current;Ye.current.add(g),qt(g).then(ye=>{if(Ye.current.delete(g),!ye||Je.current!==te)return;const Ie=X.getState().getDirectoryState(t)?.tabs.find(ze=>ze.id===p);!Ie||Ie.previewUrlLocked||Ie.previewUrl===g||de(t,p,g,{locked:!1,autoOpened:!1})})},[de]),F=n.useCallback((t,p,l,h=mt)=>{if(Q.current===l)return;r(),Q.current=l;const w=c.connect(l,{onEvent:v=>{if(Q.current===l)switch(v.type){case"connected":{se(t,p,!1),b(null),A(!1),E(!1),ke(),Ge.current===l&&(Ge.current=null,c.sendInput(l,"\r").catch(()=>{}));break}case"reconnecting":{b(null),A(!1),E(!0);break}case"data":{v.data&&(We(t,p,v.data),B(t,p,v.data));break}case"exit":{const g=typeof v.exitCode=="number"?v.exitCode:null,te=typeof v.signal=="number"?v.signal:null,Ie=!!X.getState().getDirectoryState(t)?.tabs.find(ze=>ze.id===p)?.label?.startsWith("Action:");We(t,p,u("terminalView.stream.processExitedMessage",{exitCodeSegment:g!==null?u("terminalView.stream.processExitedWithCode",{exitCode:g}):"",signalSegment:te!==null?u("terminalView.stream.processExitedWithSignal",{signal:te}):""})),Re(t,p,"exited"),J(t,p,null),se(t,p,!1),b(Ie?null:u("terminalView.error.sessionEnded")),A(!1),E(!1),r();break}}},onError:(v,g)=>{if(Q.current===l){if(!g){b(null),A(!1);return}E(!1),b(u("terminalView.error.connectionFailed",{message:v.message})),A(!0),se(t,p,!1),Z(t,p),Re(t,p,"exited"),J(t,p,null),r()}}},h);ve.current=()=>{w.close(),Q.current=null}},[We,Z,r,ke,B,se,Re,J,u,c]);n.useEffect(()=>{let t=!1;if(!re||!M)return;if(!x){b(u(Ue?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),r();return}return(async()=>{const l=x;if(!Te.current||Te.current!==l)return;je(l);const h=X.getState().getDirectoryState(l);if(!h||h.tabs.length===0)return;const w=O?h.activeTabId??h.tabs[0]?.id??null:h.tabs[0]?.id??null;if(!w)return;const v=h.tabs.find(st=>st.id===w)??h.tabs[0];let g=v?.terminalSessionId??null;const te=v?.lifecycle??"idle",ye=!!v?.label?.startsWith("Action:"),Ie=(v?.bufferLength??0)>0||(v?.bufferChunks?.length??0)>0,ze=!!g&&Oe.current.has(g)&&(v?.bufferLength??0)===0&&(v?.bufferChunks?.length??0)===0,wt=!!g&&Oe.current.has(g);if(!g){if(te==="exited"){se(l,w,!1);return}if(ye&&Ie){se(l,w,!1);return}const st=$e.current;if(!st&&Pe.current)return;b(null),A(!1),E(!1),se(l,w,!0);try{const Qe=await c.createSession({cwd:l,cols:st?.cols,rows:st?.rows});if(!(!t&&Te.current===l&&ie.current===w)){try{await c.close(Qe.sessionId)}catch{}return}J(l,w,Qe.sessionId),g=Qe.sessionId}catch(Qe){t||(b(Qe instanceof Error?Qe.message:u("terminalView.error.startSessionFailed")),A(!0),E(!1),se(l,w,!1));return}}!g||t||(H.current=g,wt&&Oe.current.delete(g),ze&&(Ge.current=g),F(l,w,g,wt?$t:mt))})(),()=>{t=!0,H.current=null,r()}},[Ue,x,j,tt,D,M,qe,O,re,je,se,Re,J,F,r,u,c]),n.useEffect(()=>{if(!y||_)return;if(typeof window>"u"){ke();return}const t=window.requestAnimationFrame(()=>{ke()});return()=>{window.cancelAnimationFrame(t)}},[D,ke,y,_]);const U=n.useCallback(async()=>{if(!x||z)return;const t=X.getState().getDirectoryState(x),p=O?D??t?.activeTabId??t?.tabs[0]?.id??null:t?.tabs[0]?.id??null;if(p){Ke(!0),b(null),A(!1),E(!1),r(),Z(x,p),He();try{await oe(x,p)}catch(l){b(l instanceof Error?l.message:u("terminalView.error.restartFailed")),A(!0),E(!1)}finally{Ke(!1)}}},[D,Z,oe,r,x,O,z,He,u]),Ae=n.useCallback(async()=>{await U()},[U]),W=n.useCallback(()=>{if(!x)return;const t=Le(x);ge(x,t),b(null),A(!1),E(!1),r()},[Le,r,x,ge]),T=n.useCallback(t=>{x&&(ge(x,t),b(null),A(!1),E(!1),r())},[r,x,ge]),K=n.useCallback(t=>{x&&(t===D&&r(),b(null),A(!1),E(!1),oe(x,t))},[D,oe,r,x]),ae=n.useCallback(t=>{if(!t||pe)return;let p=t,l=!1;if(L&&t.length>0){const w=t[0];if(w.length===1&&/[a-zA-Z]/.test(w)){const v=w.toUpperCase();(L==="ctrl"||L==="cmd")&&(p=String.fromCharCode(v.charCodeAt(0)&31),l=!0)}l||(l=!0)}const h=H.current;h&&(c.sendInput(h,p).catch(w=>{pe||b(w instanceof Error?w.message:u("terminalView.error.sendInputFailed"))}),l&&(N(null),e()))},[L,e,pe,N,u,c]),De=n.useCallback((t,p)=>{const l=$e.current;if((!l||l.cols!==t||l.rows!==p)&&($e.current={cols:t,rows:p},Xe(w=>w+1)),!Pe.current)return;const h=H.current;h&&c.resize({sessionId:h,cols:t,rows:p}).catch(()=>{})},[c]),Se=n.useCallback(t=>{N(p=>p===t?null:t),e()},[e,N]),q=n.useCallback(t=>{const p=Gt(t,L);p&&(ae(p),N(null),e())},[L,e,ae,N]);n.useEffect(()=>{if(!I||!L||!j)return;const t=p=>{if(p.repeat)return;const l=p.key;if(!l||l==="Control"||l==="Meta"||l==="Alt"||l==="Shift")return;const h=l.length===1?l.toLowerCase():l,w=p.code??"",v=w.startsWith("Key")&&w.length===4?w.slice(3).toUpperCase():null,g=l.length===1&&/[a-zA-Z]/.test(l)?l.toUpperCase():v,te={Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc",tab:"tab",enter:"enter",arrowup:"arrow-up",arrowdown:"arrow-down",arrowleft:"arrow-left",arrowright:"arrow-right",escape:"esc"};if(h in te){p.preventDefault(),p.stopPropagation(),q(te[h]);return}if(L==="ctrl"&&g&&g.length===1&&g>="A"&&g<="Z"){const ye=String.fromCharCode(g.charCodeAt(0)&31);p.preventDefault(),p.stopPropagation(),ae(ye),N(null),e()}};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[L,q,ae,e,I,N,j]);const ce=n.useMemo(()=>{const t=it[dt].stack;if(typeof window>"u")return(it[C]??it[dt]).stack;const l=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return l&&l.trim().length>0?l.trim():(it[C]??it[dt]).stack??t},[C]),a=n.useMemo(()=>Nt(S),[S]),he=n.useMemo(()=>`${x??"no-dir"}::${D??"no-tab"}::${j??"no-terminal"}`,[x,D,j]);if(n.useEffect(()=>{if(!y||_)return;const t=Be.current;if(!t)return;const p=()=>{t.fit()};if(typeof window<"u"){const l=window.requestAnimationFrame(()=>{p(),ke()}),h=[220,400].map(w=>window.setTimeout(p,w));return()=>{window.cancelAnimationFrame(l),h.forEach(w=>window.clearTimeout(w))}}p()},[ke,y,_,he,j]),n.useEffect(()=>{if(_||!y||!s)return;const t=Be.current;if(!t)return;const p=()=>{t.fit()};if(typeof window<"u"){const l=window.requestAnimationFrame(()=>{p()}),h=[0,80,180,320].map(w=>window.setTimeout(p,w));return()=>{window.cancelAnimationFrame(l),h.forEach(w=>window.clearTimeout(w))}}p()},[G,be,s,y,_]),!Ue)return f.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:u("terminalView.empty.selectSession")});if(!x)return f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[f.jsx("p",{children:u("terminalView.empty.noWorkingDirectoryForSession")}),f.jsx("button",{onClick:U,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:u("terminalView.actions.retry")})]});const P=!j||nt||z||pe,le=M,me=!Ce&&s&&!k,ue=f.jsxs(f.Fragment,{children:[f.jsx(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 px-2 text-xs",onClick:()=>q("esc"),disabled:P,children:u("terminalView.quickKeys.escape")}),f.jsxs(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>q("tab"),disabled:P,children:[f.jsx(fe,{name:"arrow-right",className:"h-4 w-4"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.tabAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"chip","aria-pressed":L==="ctrl",className:"h-6 w-9 p-0",onClick:()=>Se("ctrl"),disabled:P,children:[f.jsx("span",{className:"text-xs font-medium",children:u("terminalView.quickKeys.controlLabel")}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.controlModifierAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"chip","aria-pressed":L==="cmd",className:"h-6 w-9 p-0",onClick:()=>Se("cmd"),disabled:P,children:[f.jsx(fe,{name:"command"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.commandModifierAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>q("arrow-up"),disabled:P,children:[f.jsx(fe,{name:"arrow-up"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowUpAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>q("arrow-left"),disabled:P,children:[f.jsx(fe,{name:"arrow-left"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowLeftAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>q("arrow-down"),disabled:P,children:[f.jsx(fe,{name:"arrow-down"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowDownAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>q("arrow-right"),disabled:P,children:[f.jsx(fe,{name:"arrow-right"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowRightAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>q("enter"),disabled:P,children:[f.jsx(fe,{name:"arrow-go-back"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.enterAria")})]})]});return f.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[f.jsxs("div",{className:Ze("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",Ce?"px-3 py-1.5":"pl-3 pr-1.5 py-1"),children:[O&&V?f.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[f.jsx("div",{className:Ze("min-w-0 flex-1",Ce?"h-8":"h-7"),children:f.jsx(Pt,{items:Fe,activeId:D,onSelect:T,onClose:K,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),f.jsx(ne,{type:"button",size:"xs",variant:"ghost",className:Ze("shrink-0",Ce?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:W,title:u("terminalView.tabs.newTabTitle"),children:f.jsx(fe,{name:"add",className:`${Ce?"h-[18px] w-[18px]":"h-4 w-4"}`})}),f.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-visible",children:[ct?f.jsxs(ne,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{x&&xe(x,ct)},title:u("terminalView.preview.openTitle"),children:[f.jsx(fe,{name:"global",className:"h-3.5 w-3.5 shrink-0"}),f.jsx("span",{className:"whitespace-nowrap",children:u("terminalView.preview.open")})]}):null,me?f.jsxs(f.Fragment,{children:[f.jsx(ne,{type:"button",size:"xs",variant:"ghost",onClick:()=>o(!be),className:Ze("shrink-0 p-0",R?"h-8 w-8":"h-7 w-7"),title:u(be?"terminalView.bottomDock.restoreTitle":"terminalView.bottomDock.expandTitle"),"aria-label":u(be?"terminalView.bottomDock.restoreAria":"terminalView.bottomDock.expandAria"),children:be?f.jsx(fe,{name:"fullscreen-exit",className:"h-4 w-4"}):f.jsx(fe,{name:"fullscreen",className:"h-4 w-4"})}),f.jsx(ne,{type:"button",size:"xs",variant:"ghost",onClick:()=>m(!1),className:Ze("shrink-0 p-0",R?"h-8 w-8":"h-7 w-7"),title:u("terminalView.bottomDock.closeTitle"),"aria-label":u("terminalView.bottomDock.closeAria"),children:f.jsx(fe,{name:"close",className:"h-4 w-4"})})]}):null]})]}):null,!R&&I&&O&&V?f.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:ue}):null,I&&(R||!O||!V)?f.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:ue}):null]}),f.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:a.background},children:[f.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:le?f.jsx(gt,{ref:t=>{Be.current=t},sessionKey:he,chunks:ft,onInput:ae,onResize:De,theme:a,fontFamily:ce,fontSize:$,enableTouchScroll:_,autoFocus:!_&&y,isVisible:y},he):null}),!pe&<&&f.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2",children:[f.jsx("span",{children:lt}),rt&&R&&f.jsx(ne,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:Ae,disabled:z,title:u("terminalView.actions.hardRestartTitle"),type:"button",children:u("terminalView.actions.hardRestart")})]})]})]})};export{tn as TerminalView};
|
|
8
|
+
`)?"":(w[w.length-1]??"").slice(-1024),!v)return;const g=Wt(v);if(!g||Ye.current.has(g))return;const te=Je.current;Ye.current.add(g),qt(g).then(ye=>{if(Ye.current.delete(g),!ye||Je.current!==te)return;const Ie=X.getState().getDirectoryState(t)?.tabs.find(ze=>ze.id===p);!Ie||Ie.previewUrlLocked||Ie.previewUrl===g||de(t,p,g,{locked:!1,autoOpened:!1})})},[de]),F=n.useCallback((t,p,l,h=mt)=>{if(Q.current===l)return;r(),Q.current=l;const w=c.connect(l,{onEvent:v=>{if(Q.current===l)switch(v.type){case"connected":{se(t,p,!1),b(null),A(!1),E(!1),ke(),Ge.current===l&&(Ge.current=null,c.sendInput(l,"\r").catch(()=>{}));break}case"reconnecting":{b(null),A(!1),E(!0);break}case"data":{v.data&&(We(t,p,v.data),P(t,p,v.data));break}case"exit":{const g=typeof v.exitCode=="number"?v.exitCode:null,te=typeof v.signal=="number"?v.signal:null,Ie=!!X.getState().getDirectoryState(t)?.tabs.find(ze=>ze.id===p)?.label?.startsWith("Action:");We(t,p,u("terminalView.stream.processExitedMessage",{exitCodeSegment:g!==null?u("terminalView.stream.processExitedWithCode",{exitCode:g}):"",signalSegment:te!==null?u("terminalView.stream.processExitedWithSignal",{signal:te}):""})),Re(t,p,"exited"),J(t,p,null),se(t,p,!1),b(Ie?null:u("terminalView.error.sessionEnded")),A(!1),E(!1),r();break}}},onError:(v,g)=>{if(Q.current===l){if(!g){b(null),A(!1);return}E(!1),b(u("terminalView.error.connectionFailed",{message:v.message})),A(!0),se(t,p,!1),Z(t,p),Re(t,p,"exited"),J(t,p,null),r()}}},h);ve.current=()=>{w.close(),Q.current=null}},[We,Z,r,ke,P,se,Re,J,u,c]);n.useEffect(()=>{let t=!1;if(!re||!M)return;if(!x){b(u(Ue?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),r();return}return(async()=>{const l=x;if(!Te.current||Te.current!==l)return;Ve(l);const h=X.getState().getDirectoryState(l);if(!h||h.tabs.length===0)return;const w=O?h.activeTabId??h.tabs[0]?.id??null:h.tabs[0]?.id??null;if(!w)return;const v=h.tabs.find(st=>st.id===w)??h.tabs[0];let g=v?.terminalSessionId??null;const te=v?.lifecycle??"idle",ye=!!v?.label?.startsWith("Action:"),Ie=(v?.bufferLength??0)>0||(v?.bufferChunks?.length??0)>0,ze=!!g&&Oe.current.has(g)&&(v?.bufferLength??0)===0&&(v?.bufferChunks?.length??0)===0,wt=!!g&&Oe.current.has(g);if(!g){if(te==="exited"){se(l,w,!1);return}if(ye&&Ie){se(l,w,!1);return}const st=$e.current;if(!st&&Be.current)return;b(null),A(!1),E(!1),se(l,w,!0);try{const Qe=await c.createSession({cwd:l,cols:st?.cols,rows:st?.rows});if(!(!t&&Te.current===l&&ie.current===w)){try{await c.close(Qe.sessionId)}catch{}return}J(l,w,Qe.sessionId),g=Qe.sessionId}catch(Qe){t||(b(Qe instanceof Error?Qe.message:u("terminalView.error.startSessionFailed")),A(!0),E(!1),se(l,w,!1));return}}!g||t||(H.current=g,wt&&Oe.current.delete(g),ze&&(Ge.current=g),F(l,w,g,wt?$t:mt))})(),()=>{t=!0,H.current=null,r()}},[Ue,x,V,tt,D,M,qe,O,re,Ve,se,Re,J,F,r,u,c]),n.useEffect(()=>{if(!y||_)return;if(typeof window>"u"){ke();return}const t=window.requestAnimationFrame(()=>{ke()});return()=>{window.cancelAnimationFrame(t)}},[D,ke,y,_]);const U=n.useCallback(async()=>{if(!x||z)return;const t=X.getState().getDirectoryState(x),p=O?D??t?.activeTabId??t?.tabs[0]?.id??null:t?.tabs[0]?.id??null;if(p){Ke(!0),b(null),A(!1),E(!1),r(),Z(x,p),He();try{await oe(x,p)}catch(l){b(l instanceof Error?l.message:u("terminalView.error.restartFailed")),A(!0),E(!1)}finally{Ke(!1)}}},[D,Z,oe,r,x,O,z,He,u]),Ae=n.useCallback(async()=>{await U()},[U]),W=n.useCallback(()=>{if(!x)return;const t=Le(x);ge(x,t),b(null),A(!1),E(!1),r()},[Le,r,x,ge]),T=n.useCallback(t=>{x&&(ge(x,t),b(null),A(!1),E(!1),r())},[r,x,ge]),K=n.useCallback(t=>{x&&(t===D&&r(),b(null),A(!1),E(!1),oe(x,t))},[D,oe,r,x]),ae=n.useCallback(t=>{if(!t||pe)return;let p=t,l=!1;if(L&&t.length>0){const w=t[0];if(w.length===1&&/[a-zA-Z]/.test(w)){const v=w.toUpperCase();(L==="ctrl"||L==="cmd")&&(p=String.fromCharCode(v.charCodeAt(0)&31),l=!0)}l||(l=!0)}const h=H.current;h&&(c.sendInput(h,p).catch(w=>{pe||b(w instanceof Error?w.message:u("terminalView.error.sendInputFailed"))}),l&&(N(null),e()))},[L,e,pe,N,u,c]),De=n.useCallback((t,p)=>{const l=$e.current;if((!l||l.cols!==t||l.rows!==p)&&($e.current={cols:t,rows:p},Xe(w=>w+1)),!Be.current)return;const h=H.current;h&&c.resize({sessionId:h,cols:t,rows:p}).catch(()=>{})},[c]),Se=n.useCallback(t=>{N(p=>p===t?null:t),e()},[e,N]),q=n.useCallback(t=>{const p=Gt(t,L);p&&(ae(p),N(null),e())},[L,e,ae,N]);n.useEffect(()=>{if(!I||!L||!V)return;const t=p=>{if(p.repeat)return;const l=p.key;if(!l||l==="Control"||l==="Meta"||l==="Alt"||l==="Shift")return;const h=l.length===1?l.toLowerCase():l,w=p.code??"",v=w.startsWith("Key")&&w.length===4?w.slice(3).toUpperCase():null,g=l.length===1&&/[a-zA-Z]/.test(l)?l.toUpperCase():v,te={Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc",tab:"tab",enter:"enter",arrowup:"arrow-up",arrowdown:"arrow-down",arrowleft:"arrow-left",arrowright:"arrow-right",escape:"esc"};if(h in te){p.preventDefault(),p.stopPropagation(),q(te[h]);return}if(L==="ctrl"&&g&&g.length===1&&g>="A"&&g<="Z"){const ye=String.fromCharCode(g.charCodeAt(0)&31);p.preventDefault(),p.stopPropagation(),ae(ye),N(null),e()}};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[L,q,ae,e,I,N,V]);const ce=n.useMemo(()=>{const t=it[dt].stack;if(typeof window>"u")return(it[C]??it[dt]).stack;const l=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return l&&l.trim().length>0?l.trim():(it[C]??it[dt]).stack??t},[C]),a=n.useMemo(()=>Nt(S),[S]),he=n.useMemo(()=>`${x??"no-dir"}::${D??"no-tab"}::${V??"no-terminal"}`,[x,D,V]);if(n.useEffect(()=>{if(!y||_)return;const t=Pe.current;if(!t)return;const p=()=>{t.fit()};if(typeof window<"u"){const l=window.requestAnimationFrame(()=>{p(),ke()}),h=[220,400].map(w=>window.setTimeout(p,w));return()=>{window.cancelAnimationFrame(l),h.forEach(w=>window.clearTimeout(w))}}p()},[ke,y,_,he,V]),n.useEffect(()=>{if(_||!y||!s)return;const t=Pe.current;if(!t)return;const p=()=>{t.fit()};if(typeof window<"u"){const l=window.requestAnimationFrame(()=>{p()}),h=[0,80,180,320].map(w=>window.setTimeout(p,w));return()=>{window.cancelAnimationFrame(l),h.forEach(w=>window.clearTimeout(w))}}p()},[G,be,s,y,_]),!Ue)return f.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:u("terminalView.empty.selectSession")});if(!x)return f.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[f.jsx("p",{children:u("terminalView.empty.noWorkingDirectoryForSession")}),f.jsx("button",{onClick:U,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:u("terminalView.actions.retry")})]});const B=!V||nt||z||pe,le=M,me=!Ce&&s&&!k,ue=f.jsxs(f.Fragment,{children:[f.jsx(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 px-2 text-xs",onClick:()=>q("esc"),disabled:B,children:u("terminalView.quickKeys.escape")}),f.jsxs(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>q("tab"),disabled:B,children:[f.jsx(fe,{name:"arrow-right",className:"h-4 w-4"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.tabAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"chip","aria-pressed":L==="ctrl",className:"h-6 w-9 p-0",onClick:()=>Se("ctrl"),disabled:B,children:[f.jsx("span",{className:"text-xs font-medium",children:u("terminalView.quickKeys.controlLabel")}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.controlModifierAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"chip","aria-pressed":L==="cmd",className:"h-6 w-9 p-0",onClick:()=>Se("cmd"),disabled:B,children:[f.jsx(fe,{name:"command"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.commandModifierAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>q("arrow-up"),disabled:B,children:[f.jsx(fe,{name:"arrow-up"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowUpAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>q("arrow-left"),disabled:B,children:[f.jsx(fe,{name:"arrow-left"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowLeftAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>q("arrow-down"),disabled:B,children:[f.jsx(fe,{name:"arrow-down"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowDownAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>q("arrow-right"),disabled:B,children:[f.jsx(fe,{name:"arrow-right"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowRightAria")})]}),f.jsxs(ne,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>q("enter"),disabled:B,children:[f.jsx(fe,{name:"arrow-go-back"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.enterAria")})]})]});return f.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[f.jsxs("div",{className:Ze("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",Ce?"px-3 py-1.5":"pl-3 pr-1.5 py-1"),children:[O&&j?f.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[f.jsx("div",{className:Ze("min-w-0 flex-1",Ce?"h-8":"h-7"),children:f.jsx(Bt,{items:Fe,activeId:D,onSelect:T,onClose:K,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),f.jsx(ne,{type:"button",size:"xs",variant:"ghost",className:Ze("shrink-0",Ce?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:W,title:u("terminalView.tabs.newTabTitle"),children:f.jsx(fe,{name:"add",className:`${Ce?"h-[18px] w-[18px]":"h-4 w-4"}`})}),f.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-visible",children:[ct?f.jsxs(ne,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{x&&xe(x,ct)},title:u("terminalView.preview.openTitle"),children:[f.jsx(fe,{name:"global",className:"h-3.5 w-3.5 shrink-0"}),f.jsx("span",{className:"whitespace-nowrap",children:u("terminalView.preview.open")})]}):null,me?f.jsxs(f.Fragment,{children:[f.jsx(ne,{type:"button",size:"xs",variant:"ghost",onClick:()=>o(!be),className:Ze("shrink-0 p-0",R?"h-8 w-8":"h-7 w-7"),title:u(be?"terminalView.bottomDock.restoreTitle":"terminalView.bottomDock.expandTitle"),"aria-label":u(be?"terminalView.bottomDock.restoreAria":"terminalView.bottomDock.expandAria"),children:be?f.jsx(fe,{name:"fullscreen-exit",className:"h-4 w-4"}):f.jsx(fe,{name:"fullscreen",className:"h-4 w-4"})}),f.jsx(ne,{type:"button",size:"xs",variant:"ghost",onClick:()=>m(!1),className:Ze("shrink-0 p-0",R?"h-8 w-8":"h-7 w-7"),title:u("terminalView.bottomDock.closeTitle"),"aria-label":u("terminalView.bottomDock.closeAria"),children:f.jsx(fe,{name:"close",className:"h-4 w-4"})})]}):null]})]}):null,!R&&I&&O&&j?f.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:ue}):null,I&&(R||!O||!j)?f.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:ue}):null]}),f.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:a.background},children:[f.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:le?f.jsx(gt,{ref:t=>{Pe.current=t},sessionKey:he,chunks:ft,onInput:ae,onResize:De,theme:a,fontFamily:ce,fontSize:$,enableTouchScroll:_,autoFocus:!_&&y,isVisible:y},he):null}),!pe&<&&f.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2",children:[f.jsx("span",{children:lt}),rt&&R&&f.jsx(ne,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:Ae,disabled:z,title:u("terminalView.actions.hardRestartTitle"),type:"button",children:u("terminalView.actions.hardRestart")})]})]})]})};export{tn as TerminalView};
|