@openchamber/web 1.11.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{JsonTreeView-CUIfrcFf.js → JsonTreeView-bLRkNPS9.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-Bma9y3dD.js → MarkdownRendererImpl-FSTq-eVA.js} +2 -2
- package/dist/assets/{MultiRunWindow-Cwc0x7fs.js → MultiRunWindow-DezP_Pyy.js} +1 -1
- package/dist/assets/{OnboardingScreen-BhozUlcE.js → OnboardingScreen-CeZMVgH8.js} +1 -1
- package/dist/assets/{SettingsWindow-B4B2bn0C.js → SettingsWindow-Dlfk0yzA.js} +1 -1
- package/dist/assets/TerminalView-CdCfCaFq.js +1 -0
- package/dist/assets/{ToolOutputDialog-7U42lN20.js → ToolOutputDialog-CePopKV7.js} +6 -6
- package/dist/assets/es-CyjenLd8.js +15 -0
- package/dist/assets/index-NnYXwoao.css +1 -0
- package/dist/assets/ko-Cs7yF9Jn.js +15 -0
- package/dist/assets/{main-rHOaDqOy.js → main-BvaFBcXN.js} +2 -2
- package/dist/assets/main-DcpUnRRo.js +225 -0
- package/dist/assets/miniChat-Dmzb8Mwv.js +2 -0
- package/dist/assets/{modelPrefsAutoSave-D5z_F_WP.js → modelPrefsAutoSave-HUPrH1r2.js} +99 -93
- package/dist/assets/pl-XjTt7Hsk.js +15 -0
- package/dist/assets/pt-BR-knvpJ94d.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-EXGwfTjq.js +2 -0
- package/dist/assets/uk-DUPvcQAj.js +15 -0
- package/dist/assets/zh-CN-DWiTG93s.js +15 -0
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/package.json +1 -1
- package/server/lib/preview/proxy-runtime.js +43 -3
- package/dist/assets/TerminalView-BpoHWJj6.js +0 -1
- package/dist/assets/es-DLzL0vVb.js +0 -15
- package/dist/assets/index-D5TVqnib.css +0 -1
- package/dist/assets/ko-apnbnEuD.js +0 -15
- package/dist/assets/main-ClS4RVxe.js +0 -217
- package/dist/assets/miniChat-Cx8YK32Y.js +0 -2
- package/dist/assets/pl-DUKUujvh.js +0 -15
- package/dist/assets/pt-BR-D0UPeIZC.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-zbukf-1g.js +0 -2
- package/dist/assets/uk-CaTe2At9.js +0 -15
- package/dist/assets/zh-CN-D-oQmPdK.js +0 -15
- /package/dist/assets/{index-B2ztI3pp.js → index-CKlDk4Io.js} +0 -0
package/dist/index.html
CHANGED
|
@@ -532,10 +532,10 @@
|
|
|
532
532
|
pointer-events: none;
|
|
533
533
|
}
|
|
534
534
|
</style>
|
|
535
|
-
<script type="module" crossorigin src="/assets/main-
|
|
536
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
535
|
+
<script type="module" crossorigin src="/assets/main-BvaFBcXN.js"></script>
|
|
536
|
+
<link rel="modulepreload" crossorigin href="/assets/index-CKlDk4Io.js">
|
|
537
537
|
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-BFTPeDgG.js">
|
|
538
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
538
|
+
<link rel="stylesheet" crossorigin href="/assets/index-NnYXwoao.css">
|
|
539
539
|
<link rel="stylesheet" crossorigin href="/assets/vendor--V65Sl9C2.css">
|
|
540
540
|
</head>
|
|
541
541
|
<body class="h-full bg-background text-foreground">
|
package/dist/mini-chat.html
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
|
|
6
6
|
<title>OpenChamber Mini Chat</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/miniChat-
|
|
8
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/miniChat-Dmzb8Mwv.js"></script>
|
|
8
|
+
<link rel="modulepreload" crossorigin href="/assets/index-CKlDk4Io.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-BFTPeDgG.js">
|
|
10
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
10
|
+
<link rel="stylesheet" crossorigin href="/assets/index-NnYXwoao.css">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/vendor--V65Sl9C2.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body class="h-full bg-background text-foreground">
|
package/package.json
CHANGED
|
@@ -484,9 +484,35 @@ const PREVIEW_BRIDGE_SCRIPT = String.raw`(() => {
|
|
|
484
484
|
};
|
|
485
485
|
|
|
486
486
|
const proxiedUrl = (value) => {
|
|
487
|
-
if (typeof value !== 'string'
|
|
488
|
-
if (
|
|
489
|
-
|
|
487
|
+
if (typeof value !== 'string') return value;
|
|
488
|
+
if (value.startsWith('/')) {
|
|
489
|
+
if (!shouldProxyPath(value)) return value;
|
|
490
|
+
return proxyBase + value;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
try {
|
|
494
|
+
const parsed = new URL(value, window.location.href);
|
|
495
|
+
if (parsed.origin === window.location.origin && shouldProxyPath(parsed.pathname)) {
|
|
496
|
+
return proxyBase + parsed.pathname + parsed.search + parsed.hash;
|
|
497
|
+
}
|
|
498
|
+
} catch {}
|
|
499
|
+
|
|
500
|
+
return value;
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
const proxiedWebSocketUrl = (value) => {
|
|
504
|
+
if (typeof value !== 'string') return value;
|
|
505
|
+
try {
|
|
506
|
+
const parsed = new URL(value, window.location.href);
|
|
507
|
+
const current = new URL(window.location.href);
|
|
508
|
+
const sameHost = parsed.host === current.host;
|
|
509
|
+
const isWebSocketProtocol = parsed.protocol === 'ws:' || parsed.protocol === 'wss:';
|
|
510
|
+
if (sameHost && isWebSocketProtocol && shouldProxyPath(parsed.pathname)) {
|
|
511
|
+
parsed.pathname = proxyBase + parsed.pathname;
|
|
512
|
+
return parsed.toString();
|
|
513
|
+
}
|
|
514
|
+
} catch {}
|
|
515
|
+
return value;
|
|
490
516
|
};
|
|
491
517
|
|
|
492
518
|
if (typeof window.fetch === 'function') {
|
|
@@ -529,6 +555,20 @@ const PREVIEW_BRIDGE_SCRIPT = String.raw`(() => {
|
|
|
529
555
|
Object.defineProperty(OpenChamberPreviewEventSource, 'name', { value: 'EventSource' });
|
|
530
556
|
window.EventSource = OpenChamberPreviewEventSource;
|
|
531
557
|
}
|
|
558
|
+
|
|
559
|
+
if (typeof window.WebSocket === 'function') {
|
|
560
|
+
const NativeWebSocket = window.WebSocket;
|
|
561
|
+
function OpenChamberPreviewAppWebSocket(url, protocols) {
|
|
562
|
+
const nextUrl = proxiedWebSocketUrl(String(url));
|
|
563
|
+
return arguments.length === 1
|
|
564
|
+
? new NativeWebSocket(nextUrl)
|
|
565
|
+
: new NativeWebSocket(nextUrl, protocols);
|
|
566
|
+
}
|
|
567
|
+
OpenChamberPreviewAppWebSocket.prototype = NativeWebSocket.prototype;
|
|
568
|
+
Object.setPrototypeOf(OpenChamberPreviewAppWebSocket, NativeWebSocket);
|
|
569
|
+
Object.defineProperty(OpenChamberPreviewAppWebSocket, 'name', { value: 'WebSocket' });
|
|
570
|
+
window.WebSocket = OpenChamberPreviewAppWebSocket;
|
|
571
|
+
}
|
|
532
572
|
};
|
|
533
573
|
|
|
534
574
|
const selectorPart = (element) => {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as n,j as a,s as yt,bv as ht,bw as bt,bx as gt}from"./vendor-.bun-BFTPeDgG.js";import{u as dt,v as xt,aZ as vt,c as Ue,M as Tt,bE as kt,eH as Ct,a as Ie,b as Et,V as ft,b7 as Rt,I as ie,eI as et,cs as ct,as as Q}from"./modelPrefsAutoSave-D5z_F_WP.js";import{u as J,P as At,S as St}from"./main-ClS4RVxe.js";import{a3 as It}from"./index-B2ztI3pp.js";import"./JsonTreeView-CUIfrcFf.js";function Mt(f){const{colors:p}=f,m=p.syntax.base;return{background:p.surface.background,foreground:m.foreground,cursor:p.interactive.cursor,cursorAccent:p.surface.background,selectionBackground:p.interactive.selection,selectionForeground:p.interactive.selectionForeground,selectionInactiveBackground:p.interactive.selection+"50",black:p.surface.muted,red:p.status.error,green:p.status.success,yellow:p.status.warning,blue:m.function,magenta:m.keyword,cyan:m.type,white:m.foreground,brightBlack:m.comment,brightRed:p.status.error,brightGreen:p.status.success,brightYellow:p.status.warning,brightBlue:m.function,brightMagenta:m.keyword,brightCyan:m.type,brightWhite:p.surface.elevatedForeground}}function Bt(f,p,m,ee,de=!1){const ye=`${f}, "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:p,lineHeight:1.15,fontFamily:ye,allowTransparency:!1,theme:{background:m.background,foreground:m.foreground,cursor:m.cursor,cursorAccent:m.cursorAccent,selectionBackground:m.selectionBackground,selectionForeground:m.selectionForeground,black:m.black,red:m.red,green:m.green,yellow:m.yellow,blue:m.blue,magenta:m.magenta,cyan:m.cyan,white:m.white,brightBlack:m.brightBlack,brightRed:m.brightRed,brightGreen:m.brightGreen,brightYellow:m.brightYellow,brightBlue:m.brightBlue,brightMagenta:m.brightMagenta,brightCyan:m.brightCyan,brightWhite:m.brightWhite},scrollback:1e4,ghostty:ee,disableStdin:de}}let lt=null;function Dt(){return lt||(lt=gt.load()),lt}function Nt(f){if(typeof window>"u")return null;const p=[f,...Array.from(f.querySelectorAll("*"))];let m=null;for(const ee of p){const Me=window.getComputedStyle(ee).overflowY;if(!(Me!=="auto"&&Me!=="scroll")){if(ee.scrollHeight-ee.clientHeight>2)return ee;m||(m=ee)}}return m}const pt=n.forwardRef(({sessionKey:f,chunks:p,onInput:m,onResize:ee,theme:de,fontFamily:Me,fontSize:ye,className:Be,enableTouchScroll:E,autoFocus:tt=!0,isVisible:je=!0},he)=>{const{t:F}=dt(),N=n.useRef(null),Fe=n.useRef(null),I=n.useRef(null),_e=n.useRef(null),P=n.useRef(m),ze=n.useRef(ee),h=n.useRef(null),be=n.useRef(""),te=n.useRef(null),Le=n.useRef(!1),Ke=n.useRef(null),pe=n.useRef(!0),ne=n.useRef(null),q=n.useRef(null),ge=n.useRef(0),re=n.useRef(null),qe=n.useRef(null),ce=n.useRef(!1),k=n.useRef(!1),R=n.useRef(null),me=n.useRef(null),Ye=n.useRef(null),j=n.useRef(""),Oe=n.useRef(null),xe=n.useRef(!E),$e=n.useRef(je),[,nt]=n.useReducer(e=>e+1,0),[We,O]=n.useReducer(e=>e+1,0);P.current=m,ze.current=ee;const at=typeof navigator<"u"&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform==="Android"),y=!!E;n.useEffect(()=>{if(!E){xe.current=!0,$e.current=je;return}!$e.current&&je&&(xe.current=!1),$e.current=je},[E,je]);const ve=n.useCallback(()=>{if(!y)return;const e=N.current,o=re.current;if(!e)return;const s=[];e.getAttribute("contenteditable")==="true"&&s.push(e),s.push(...Array.from(e.querySelectorAll('[contenteditable="true"]'))),s.forEach(r=>{r.setAttribute("data-terminal-disabled-contenteditable","true"),r.setAttribute("contenteditable","false"),r.setAttribute("aria-hidden","true"),r.tabIndex=-1,r.style.setProperty("caret-color","transparent"),r.style.color="transparent",r.style.setProperty("-webkit-text-fill-color","transparent"),r.style.background="transparent",r.style.outline="none",r.style.boxShadow="none",r.style.textShadow="none",r.style.setProperty("user-select","none"),r.style.setProperty("-webkit-user-select","none")}),e.tabIndex=-1,e.removeAttribute("role"),e.removeAttribute("aria-multiline"),Array.from(e.querySelectorAll("textarea")).forEach(r=>{r.style.setProperty("caret-color","transparent"),r.style.color="transparent",r.style.setProperty("-webkit-text-fill-color","transparent"),r.style.background="transparent",r.style.border="0",r.style.outline="none",r.style.boxShadow="none",r.style.textShadow="none",r.style.fontSize="0",r.style.lineHeight="0",r!==o&&r.getAttribute("data-terminal-disabled-input")!=="true"&&(r.setAttribute("data-terminal-disabled-input","true"),r.setAttribute("aria-hidden","true"),r.tabIndex=-1,r.disabled=!0,r.style.position="absolute",r.style.opacity="0",r.style.width="0px",r.style.height="0px",r.style.pointerEvents="none",r.style.zIndex="-1")})},[y]),A=n.useCallback(e=>{if(Oe.current===e)return;const o=I.current;if(o)try{if(typeof o.setOption=="function"){o.setOption("cursorBlink",e),Oe.current=e;return}o.options&&(o.options.cursorBlink=e,Oe.current=e)}catch{}},[]),M=y&&at,C=n.useCallback((e,o)=>{const s=M?qe.current:re.current,c=N.current;if(!s||!c)return;const r=c.getBoundingClientRect(),v=typeof window<"u"?window.innerWidth:r.width,S=typeof window<"u"?window.innerHeight:r.height,D=r.left+r.width/2,G=r.top+r.height-12,l=typeof e=="number"?e:D,T=typeof o=="number"?o:G,V=8,H=Math.max(V,Math.min(v-V,l)),K=Math.max(V,Math.min(S-V,T));s.style.left=`${H}px`,s.style.top=`${K}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{}}},[M]),Te=n.useCallback(()=>{if(y){C(),A(!0);return}I.current?.focus(),A(!0)},[C,A,y]),le=n.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??"",[]),W=n.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value="";return}e.textContent=""},[]),He=n.useCallback(e=>{if(typeof window>"u"||M)return;Ye.current!==null&&(window.clearTimeout(Ye.current),Ye.current=null);let o=0;const s=3,c=()=>{Ye.current=window.setTimeout(()=>{Ye.current=null;const r=le(e);if(!r){if(o+=1,o<s){c();return}return}const v=j.current;j.current=r;const S=r.startsWith(v)?r.slice(v.length):r;S&&P.current(S.replace(/\r\n|\r|\n/g,"\r")),W(e),j.current=""},o===0?0:24)};c()},[W,le,M]);n.useEffect(()=>{const e=N.current;if(!y||!e||E)return;const o=s=>{const c=s.target;if(c&&c.getAttribute("data-terminal-hidden-input")!=="true"&&e.contains(c)){try{c.blur()}catch{}C()}};return e.addEventListener("focusin",o,!0),()=>{e.removeEventListener("focusin",o,!0)}},[E,y,C]);const De=n.useCallback(()=>{const e=I.current;if(!e||typeof e.getSelection!="function")return"";const o=e.getSelection();return typeof o=="string"?o:""},[]),ue=n.useCallback(()=>{if(typeof window>"u")return"";const e=window.getSelection();if(!e)return"";const o=e.toString();if(!o.trim())return"";const s=N.current;if(!s)return"";const c=e.anchorNode,r=e.focusNode;return c&&!s.contains(c)||r&&!s.contains(r)?"":o},[]),ke=n.useCallback(async()=>{if(typeof document>"u")return;const e=De()||ue();e.trim()&&await xt(e)},[ue,De]),X=n.useCallback(()=>De().trim()?!0:!!ue().trim(),[ue,De]);n.useEffect(()=>{if(typeof window>"u")return;const e=o=>{X()&&(o.preventDefault(),ke())};return window.addEventListener("openchamber:copy",e),()=>{window.removeEventListener("openchamber:copy",e)}},[ke,X]);const U=n.useCallback(()=>{be.current="",te.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(te.current),te.current=null,Le.current=!1,Ke.current=null},[]),L=n.useCallback(()=>{const e=_e.current,o=I.current,s=N.current;if(!e||!o||!s)return;const c=s.getBoundingClientRect();if(!(c.width<24||c.height<24))try{e.fit();const r={cols:o.cols,rows:o.rows},v=h.current;(!v||v.cols!==r.cols||v.rows!==r.rows)&&(h.current=r,ze.current(r.cols,r.rows))}catch{}},[]),Ne=n.useCallback(()=>{if(Le.current)return;const e=I.current;if(!e){U();return}if(!be.current)return;const o=be.current;be.current="",Le.current=!0,e.write(o,()=>{Le.current=!1,be.current&&(typeof window<"u"?te.current=window.requestAnimationFrame(()=>{te.current=null,Ne()}):Ne())})},[U]),Ge=n.useCallback(()=>{te.current===null&&(typeof window<"u"?te.current=window.requestAnimationFrame(()=>{te.current=null,Ne()}):Ne())},[Ne]),Xe=n.useCallback(e=>{e&&(be.current+=e,Ge())},[Ge]),Ce=n.useCallback(()=>{if(ne.current?.(),ne.current=null,q.current!==null&&typeof window<"u"&&(window.clearTimeout(q.current),q.current=null),!E){ge.current=0;return}const e=N.current;if(!e)return;const o=I.current;if(!o)return;ge.current=0;const s=2.2,c=2.8,r=25,v=.25,S=8,D=.05,G=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},T=()=>typeof performance<"u"?performance.now():Date.now(),V=Math.max(12,Math.round(ye*1.35));let H=0;const K=t=>{if(!t)return!1;const u=o.getViewportY(),i=H+t,b=Math.trunc(i/V);return H=i-b*V,b!==0&&o.scrollLines(b),o.getViewportY()!==u},Y=()=>{l.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(l.rafId),l.rafId=null},x={passive:!1,capture:!1};if(typeof window<"u"&&"PointerEvent"in window){const t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),u=6,i=d=>{if(d.pointerType==="touch"){Y(),t.pointerId=d.pointerId,t.startX=d.clientX,t.startY=d.clientY,t.moved=!1,t.lastY=d.clientY,t.lastTime=T(),t.velocity=0;try{e.setPointerCapture(d.pointerId)}catch{}}},b=d=>{if(d.pointerType!=="touch"||t.pointerId!==d.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){const mt=d.clientX-t.startX,wt=d.clientY-t.startY;Math.hypot(mt,wt)>=u&&(t.moved=!0)}if(t.lastY===null){t.lastY=d.clientY,t.lastTime=T();return}const _=t.lastY,oe=t.lastTime??T(),$=T();t.lastY=d.clientY,t.lastTime=$;const ae=_-d.clientY;if(Math.abs(ae)<1)return;const Se=Math.max($-oe,8),se=s+Math.min(c,Math.abs(ae)/r),Pe=ae*se,Je=Pe/Se;t.velocity=t.velocity*(1-v)+Je*v,t.velocity>S?t.velocity=S:t.velocity<-S&&(t.velocity=-S),t.moved&&(d.cancelable&&d.preventDefault(),d.stopPropagation()),K(Pe)},w=d=>{if(d.pointerType!=="touch"||t.pointerId!==d.pointerId)return;const _=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(d.pointerId)}catch{}if(_){y?C(d.clientX,d.clientY):E&&!xe.current&&(xe.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(t.velocity)<D){t.velocity=0;return}let oe=T();const $=()=>{const ae=T(),Se=Math.max(ae-oe,8);oe=ae;const se=K(t.velocity*Se)??!1,Pe=Math.sign(t.velocity),Je=Math.max(0,Math.abs(t.velocity)-G*Se);if(t.velocity=Je*Pe,!se||Je<=D){Y(),t.velocity=0;return}t.rafId=window.requestAnimationFrame($)};t.rafId=window.requestAnimationFrame($)};e.addEventListener("pointerdown",i,x),e.addEventListener("pointermove",b,x),e.addEventListener("pointerup",w,x),e.addEventListener("pointercancel",w,x);const g=e.style.touchAction;e.style.touchAction="manipulation",ne.current=()=>{Y(),q.current!==null&&typeof window<"u"&&(window.clearTimeout(q.current),q.current=null),ge.current=0,e.removeEventListener("pointerdown",i,x),e.removeEventListener("pointermove",b,x),e.removeEventListener("pointerup",w,x),e.removeEventListener("pointercancel",w,x),e.style.touchAction=g};return}const Re=6,z=t=>{t.touches.length===1&&(Y(),l.lastY=t.touches[0].clientY,l.lastTime=T(),l.velocity=0,l.startX=t.touches[0].clientX,l.startY=t.touches[0].clientY,l.didMove=!1)},Ve=t=>{if(t.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,Y();return}const u=t.touches[0].clientX,i=t.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){const Se=u-l.startX,se=i-l.startY;Math.hypot(Se,se)>=Re&&(l.didMove=!0)}if(l.lastY===null){l.lastY=i,l.lastTime=T();return}const b=l.lastY,w=l.lastTime??T(),g=T();l.lastY=i,l.lastTime=g;const d=b-i;if(Math.abs(d)<1)return;const _=Math.max(g-w,8),oe=s+Math.min(c,Math.abs(d)/r),$=d*oe,ae=$/_;l.velocity=l.velocity*(1-v)+ae*v,l.velocity>S?l.velocity=S:l.velocity<-S&&(l.velocity=-S),l.didMove&&(t.preventDefault(),t.stopPropagation()),K($)},Ae=t=>{const u=!l.didMove;l.lastY=null,l.lastTime=null;const i=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,u){const g=t.changedTouches?.[0];y?C(g?.clientX,g?.clientY):E&&!xe.current&&(xe.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(i)<D){l.velocity=0;return}let b=T();const w=()=>{const g=T(),d=Math.max(g-b,8);b=g;const _=K(l.velocity*d)??!1,oe=Math.sign(l.velocity),$=Math.max(0,Math.abs(l.velocity)-G*d);if(l.velocity=$*oe,!_||$<=D){Y(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(w)};l.rafId=window.requestAnimationFrame(w)};e.addEventListener("touchstart",z,x),e.addEventListener("touchmove",Ve,x),e.addEventListener("touchend",Ae,x),e.addEventListener("touchcancel",Ae,x);const Z=e.style.touchAction;e.style.touchAction="manipulation",ne.current=()=>{Y(),q.current!==null&&typeof window<"u"&&(window.clearTimeout(q.current),q.current=null),ge.current=0,e.removeEventListener("touchstart",z,x),e.removeEventListener("touchmove",Ve,x),e.removeEventListener("touchend",Ae,x),e.removeEventListener("touchcancel",Ae,x),e.style.touchAction=Z}},[E,y,C,ye]);n.useEffect(()=>{let e=!1,o=null,s=null,c=null,r=[],v=null,S=null;const D=N.current;if(!D)return;if(D.tabIndex=y?-1:0,y){const Y=D.focus.bind(D),x=D;x.focus=((...B)=>{C()}),S=()=>{x.focus=Y}}const G=()=>{A(!0)},l=()=>{A(!1)},T=Y=>{const x=Y.target;if(x&&D.contains(x)){if(y&&x instanceof HTMLElement){window.setTimeout(()=>{x.blur(),C()},0),A(!1);return}if(E&&!xe.current&&x instanceof HTMLElement){window.setTimeout(()=>{x.blur()},0),A(!1);return}A(!0);return}A(!1)},V=()=>{A(!1)};let H=null;return(async()=>{try{const Y=await Dt();if(e)return;const x=Bt(Me,ye,de,Y,!1),B=new ht(x);pe.current=!0,y&&(B.focus=()=>{});const Re=B;if(typeof Re.scrollToBottom=="function"){const Z=Re.scrollToBottom.bind(Re);Re.scrollToBottom=()=>{pe.current&&Z()},v=()=>{Re.scrollToBottom=Z}}const z=new bt;o=B,I.current=B,_e.current=z,B.loadAddon(z),B.open(D),O(),Oe.current=!1,H=B.textarea??D.querySelector("textarea"),H&&(H.addEventListener("focus",G),H.addEventListener("blur",l)),ve(),typeof MutationObserver<"u"&&(c=new MutationObserver(()=>{ve()}),c.observe(D,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["contenteditable","role","tabindex","aria-label"]}));const Ve=Nt(D);Ve?(Ve.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),Fe.current=Ve,nt()):Fe.current=null,L();const Ae=z;typeof Ae.observeResize=="function"&&Ae.observeResize(),Ce(),r=[B.onData(Z=>{P.current(Z)}),B.onScroll(Z=>{if(typeof Z=="number"&&Number.isFinite(Z)){const t=typeof B.hasSelection=="function"&&B.hasSelection();pe.current=!t&&Z<=.5}}),B.onSelectionChange(()=>{if(typeof B.hasSelection=="function"&&B.hasSelection()){pe.current=!1;return}const t=typeof B.getViewportY=="function"?B.getViewportY():0;pe.current=t<=.5})],s=new ResizeObserver(()=>{L()}),s.observe(D),typeof window<"u"&&window.setTimeout(()=>{L()},0)}catch{}})(),document.addEventListener("focusin",T,!0),window.addEventListener("blur",V),()=>{e=!0,ne.current?.(),ne.current=null,document.removeEventListener("focusin",T,!0),window.removeEventListener("blur",V),r.forEach(Y=>Y.dispose()),v?.(),v=null,H&&(H.removeEventListener("focus",G),H.removeEventListener("blur",l)),s?.disconnect(),c?.disconnect(),S?.(),o?.dispose(),I.current=null,_e.current=null,Fe.current=null,h.current=null,Oe.current=null,U()}},[ve,E,L,C,Me,ye,Ce,de,U,A,y]),n.useEffect(()=>{const e=I.current;e&&(e.reset(),U(),h.current=null,L())},[f,We,L,U]),n.useEffect(()=>{!tt||!I.current||Te()},[tt,Te,f,We]),n.useEffect(()=>(Ce(),()=>{ne.current?.(),ne.current=null}),[Ce,f]),n.useEffect(()=>{const e=I.current;if(!e)return;if(p.length===0){Ke.current!==null&&(e.reset(),U(),L());return}const o=Ke.current;let s;if(o===null)s=p;else{const c=p.findIndex(r=>r.id===o);s=c>=0?p.slice(c+1):p}s.length>0&&Xe(s.map(c=>c.data).join("")),Ke.current=p[p.length-1].id},[p,We,Xe,L,U]),n.useImperativeHandle(he,()=>({focus:()=>{Te()},clear:()=>{const e=I.current;e&&(e.reset(),U(),L())},fit:()=>{L()}}),[Te,L,U]);const Ze=n.useCallback(e=>{if(!y)return;const o=N.current,s=e.relatedTarget,c=s?.tagName,r=c==="INPUT"||c==="TEXTAREA"||s?.isContentEditable,v=s?.getAttribute("data-terminal-hidden-input")==="true",S=!!(s&&o?.contains(s))},[y]),we=n.useCallback(e=>{const o=e.nativeEvent,s=o?.inputType??"",c=typeof o?.data=="string"?o.data:"";if(me.current=typeof performance<"u"?performance.now():Date.now(),s==="insertCompositionText"){ce.current=!0;return}if(!s&&c){if(ce.current)return;e.preventDefault(),P.current(c),R.current={type:"insertText",at:typeof performance<"u"?performance.now():Date.now()},k.current=!0;return}if(s==="insertText"&&c){if(ce.current)return;e.preventDefault(),P.current(c),R.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},k.current=!0;return}if(s==="insertLineBreak"){if(ce.current)return;e.preventDefault(),P.current("\r"),R.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},k.current=!0;return}if(s==="deleteContentBackward"){if(ce.current)return;e.preventDefault(),P.current(""),R.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},k.current=!0}},[]),fe=n.useCallback(e=>{const o=e.currentTarget;if(me.current=typeof performance<"u"?performance.now():Date.now(),ce.current)return;if(k.current){const r=R.current,v=typeof performance<"u"?performance.now():Date.now();if(r&&v-r.at<50){k.current=!1,W(o);return}k.current=!1}const s=le(o);if(!s)return;j.current=s;const c=s.replace(/\r\n|\r|\n/g,"\r");P.current(c),W(o),j.current=""},[W,le]),rt=n.useCallback(e=>{e.stopPropagation();const o=e.key.toLowerCase(),s=e.metaKey&&!e.ctrlKey&&!e.altKey&&o==="c",c=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&o==="c";if((s||c)&&X()){e.preventDefault(),ke();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){const V=e.key.toUpperCase();if(V>="A"&&V<="Z"){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),P.current(String.fromCharCode(V.charCodeAt(0)-64)),W(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),P.current("\x1B"+e.key),W(e.currentTarget);return}const v={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(v){e.preventDefault(),P.current(v),W(e.currentTarget);return}const S=e.currentTarget;if(e.nativeEvent?.isComposing)return;const G=R.current,l=typeof performance<"u"?performance.now():Date.now(),T=!!(G&&l-G.at<50);if(e.key==="Enter"){if(T&&G?.type==="insertLineBreak")return;e.preventDefault(),P.current("\r"),W(S);return}if(e.key==="Backspace"){if(e.preventDefault(),T&&G?.type==="deleteContentBackward")return;le(S)||P.current("")}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const V=me.current;V&&l-V<50||(e.preventDefault(),P.current(e.key),k.current=!0,R.current={type:"keydown-text",at:l})}He(S)},[W,ke,X,le,He]),Ee=n.useCallback(e=>{e.stopPropagation();const o=e.currentTarget;e.nativeEvent?.isComposing||He(o)},[He]),ot=n.useCallback(e=>{const o=e.currentTarget;ce.current=!1;const s=e.data||le(o);if(me.current=typeof performance<"u"?performance.now():Date.now(),!s)return;const c=s.replace(/\r\n|\r|\n/g,"\r");P.current(c),W(o),R.current={type:"compositionend",at:typeof performance<"u"?performance.now():Date.now()},k.current=!0},[W,le]),st=n.useCallback(e=>{e.stopPropagation();const o=e.clipboardData?.getData("text")??"";if(!o)return;e.preventDefault();const c=I.current?.hasBracketedPaste?.()?`\x1B[200~${o}\x1B[201~`:o;P.current(c)},[]),Qe={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 a.jsxs("div",{ref:N,className:Ue("relative h-full w-full terminal-viewport-container",Be),"data-hidden-input-overlay-active":y?"true":void 0,style:{backgroundColor:de.background},onTouchStart:e=>{if(!(!y||E)&&!X()){const o=e.touches?.[0];C(o?.clientX,o?.clientY)}},onClick:e=>{if(!E)if(y){if(X())return;C(e.clientX,e.clientY)}else I.current?.focus()},onMouseUp:()=>{!E&&X()&&ke()},onTouchEnd:()=>{!E&&X()&&ke()},children:[y&&typeof document<"u"?yt.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:qe,type:"text",inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":F("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...Qe,display:M?"block":"none"},onBlur:Ze,onBeforeInput:we,onCompositionStart:()=>{ce.current=!0},onInput:fe,onKeyDown:rt,onKeyUp:Ee,onCompositionEnd:ot,onPaste:st}),a.jsx("textarea",{ref:re,inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":F("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...Qe,display:M?"none":"block"},onBlur:Ze,onBeforeInput:we,onCompositionStart:()=>{ce.current=!0},onInput:fe,onKeyDown:rt,onKeyUp:Ee,onCompositionEnd:ot,onPaste:st})]}),document.body):null,Fe.current&&!E?a.jsx(vt,{containerRef:Fe,disableHorizontal:!0,className:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero"}):null]})});pt.displayName="TerminalViewport";const Vt={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},it={ctrl:"5",cmd:"3"},ut={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},Pt={retry:{...ut.retry,initialDelayMs:200,maxDelayMs:500},connectionTimeoutMs:1500},jt=(f,p)=>{if(p)switch(f){case"arrow-up":return`\x1B[1;${it[p]}A`;case"arrow-down":return`\x1B[1;${it[p]}B`;case"arrow-right":return`\x1B[1;${it[p]}C`;case"arrow-left":return`\x1B[1;${it[p]}D`}return Vt[f]??null},Ht=()=>{const{t:f}=dt(),{terminal:p,runtime:m}=Tt(),{currentTheme:ee}=kt(),{monoFont:de}=Ct(),Me=Ie(t=>t.terminalFontSize),ye=Ie(t=>t.bottomTerminalHeight),Be=Ie(t=>t.isBottomTerminalExpanded),{isMobile:E,isTablet:tt,hasTouchOnlyPointer:je}=Et(),he=E||tt,F=(he||je)&&m.platform==="web",N=m.platform!=="vscode",Fe=Ie(t=>t.showTerminalQuickKeysOnDesktop),I=he||Fe,_e=ft(t=>t.currentSessionId),P=ft(t=>t.newSessionDraft),ze=_e!==null||P?.open===!0,h=Rt()??null,be=J(t=>t.sessions),te=J(t=>t.hasHydrated),Le=J(t=>t.ensureDirectory),Ke=J(t=>t.createTab),pe=J(t=>t.setActiveTab),ne=J(t=>t.closeTab),q=J(t=>t.setTabSessionId),ge=J(t=>t.setTabLifecycle),re=J(t=>t.setConnecting),qe=J(t=>t.appendToBuffer),ce=Ie(t=>t.openContextPreview),k=n.useMemo(()=>{if(h)return be.get(h)},[be,h]),R=n.useMemo(()=>k?N?k.activeTabId??k.tabs[0]?.id??null:k.tabs[0]?.id??null:null,[k,N]),me=n.useMemo(()=>{if(k)return R?k.tabs.find(t=>t.id===R)??k.tabs[0]:k.tabs[0]},[k,R]),Ye=n.useMemo(()=>(k?.tabs??[]).map(t=>({icon:(()=>{const u=t.iconKey?At[t.iconKey]??"terminal":"terminal";return a.jsx(ie,{name:u,className:"h-4 w-4"})})(),id:t.id,label:t.label,title:t.label,closeLabel:f("terminalView.tabs.closeTabTitle")})),[k?.tabs,f]),j=me?.terminalSessionId??null,Oe=me?.lifecycle??"idle",xe=me?.bufferChunks??[],$e=me?.isConnecting??!1,nt=me?.previewUrl??null,[We,O]=n.useState(null),[at,y]=n.useState(!1),[ve,A]=n.useState(!1),[M,C]=n.useState(null),[Te,le]=n.useState(!1),[W,He]=n.useState(0),De=n.useRef(null),ue=n.useRef(null),ke=n.useRef(R),X=n.useRef(j),U=n.useRef(h),L=n.useRef(null),Ne=n.useRef(null),Ge=n.useRef(!1),Xe=n.useRef(null),Ce=n.useRef(new Set),Ze=n.useRef(!1),we=n.useCallback(()=>{F||typeof document<"u"&&!document.hasFocus()||L.current?.focus()},[F]),fe=n.useCallback(()=>{F||L.current?.focus()},[F]);n.useEffect(()=>{if(!te||Ze.current)return;Ze.current=!0;const t=new Set;for(const[,u]of J.getState().sessions.entries())for(const i of u.tabs)i.terminalSessionId&&t.add(i.terminalSessionId);Ce.current=t},[te]);const rt=Ie(t=>t.activeMainTab),Ee=Ie(t=>t.isBottomTerminalOpen),ot=Ie(t=>t.setBottomTerminalOpen),st=Ie(t=>t.setBottomTerminalExpanded),Qe=rt==="terminal",e=Qe||Ee,[o,s]=n.useState(e);n.useEffect(()=>{!e||m.platform==="vscode"||It()},[e,m.platform]),n.useEffect(()=>{e&&s(!0)},[e]),n.useEffect(()=>{Ge.current=e},[e]),n.useEffect(()=>{X.current=j},[j]),n.useEffect(()=>{ke.current=R},[R]),n.useEffect(()=>{U.current=h},[h]),n.useEffect(()=>{!I&&M!==null&&C(null)},[I,M,C]),n.useEffect(()=>{!j&&M!==null&&C(null)},[j,M,C]);const c=n.useCallback(()=>{De.current?.(),De.current=null,ue.current=null,A(!1)},[]);n.useEffect(()=>()=>{c(),X.current=null},[c]);const r=n.useCallback((t,u,i,b=ut)=>{if(ue.current===i)return;c(),ue.current=i;const w=p.connect(i,{onEvent:g=>{if(ue.current===i)switch(g.type){case"connected":{re(t,u,!1),O(null),y(!1),A(!1),we(),Xe.current===i&&(Xe.current=null,p.sendInput(i,"\r").catch(()=>{}));break}case"reconnecting":{O(null),y(!1),A(!0);break}case"data":{g.data&&qe(t,u,g.data);break}case"exit":{const d=typeof g.exitCode=="number"?g.exitCode:null,_=typeof g.signal=="number"?g.signal:null,$=!!J.getState().getDirectoryState(t)?.tabs.find(ae=>ae.id===u)?.label?.startsWith("Action:");qe(t,u,f("terminalView.stream.processExitedMessage",{exitCodeSegment:d!==null?f("terminalView.stream.processExitedWithCode",{exitCode:d}):"",signalSegment:_!==null?f("terminalView.stream.processExitedWithSignal",{signal:_}):""})),ge(t,u,"exited"),q(t,u,null),re(t,u,!1),O($?null:f("terminalView.error.sessionEnded")),y(!1),A(!1),c();break}}},onError:(g,d)=>{if(ue.current===i){if(!d){O(null),y(!1);return}A(!1),O(f("terminalView.error.connectionFailed",{message:g.message})),y(!0),re(t,u,!1),ge(t,u,"exited"),q(t,u,null),c()}}},b);De.current=()=>{w.close(),ue.current=null}},[qe,c,we,re,ge,q,f,p]);n.useEffect(()=>{let t=!1;if(!te||!o)return;if(!h){O(f(ze?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),c();return}return(async()=>{const i=h;if(!U.current||U.current!==i)return;Le(i);const b=J.getState().getDirectoryState(i);if(!b||b.tabs.length===0)return;const w=N?b.activeTabId??b.tabs[0]?.id??null:b.tabs[0]?.id??null;if(!w)return;const g=b.tabs.find(se=>se.id===w)??b.tabs[0];let d=g?.terminalSessionId??null;const _=g?.lifecycle??"idle",oe=!!g?.label?.startsWith("Action:"),$=(g?.bufferLength??0)>0||(g?.bufferChunks?.length??0)>0,ae=!!d&&Ce.current.has(d)&&(g?.bufferLength??0)===0&&(g?.bufferChunks?.length??0)===0,Se=!!d&&Ce.current.has(d);if(!d){if(_==="exited"){re(i,w,!1);return}if(oe&&$){re(i,w,!1);return}O(null),y(!1),A(!1),re(i,w,!0);try{const se=Ne.current,Pe=await p.createSession({cwd:i,cols:se?.cols,rows:se?.rows});if(!(!t&&U.current===i&&ke.current===w)){try{await p.close(Pe.sessionId)}catch{}return}q(i,w,Pe.sessionId),d=Pe.sessionId}catch(se){t||(O(se instanceof Error?se.message:f("terminalView.error.startSessionFailed")),y(!0),A(!1),re(i,w,!1));return}}!d||t||(X.current=d,Se&&Ce.current.delete(d),ae&&(Xe.current=d),r(i,w,d,Se?Pt:ut))})(),()=>{t=!0,X.current=null,c()}},[ze,h,j,Oe,R,o,N,te,Le,re,ge,q,r,c,f,p]),n.useEffect(()=>{if(!e||F)return;if(typeof window>"u"){we();return}const t=window.requestAnimationFrame(()=>{we()});return()=>{window.cancelAnimationFrame(t)}},[R,we,e,F]);const v=n.useCallback(async()=>{if(!h||Te)return;const t=J.getState().getDirectoryState(h),u=N?R??t?.activeTabId??t?.tabs[0]?.id??null:t?.tabs[0]?.id??null;if(u){le(!0),O(null),y(!1),A(!1),c();try{await ne(h,u)}catch(i){O(i instanceof Error?i.message:f("terminalView.error.restartFailed")),y(!0),A(!1)}finally{le(!1)}}},[R,ne,c,h,N,Te,f]),S=n.useCallback(async()=>{await v()},[v]),D=n.useCallback(()=>{if(!h)return;const t=Ke(h);pe(h,t),O(null),y(!1),A(!1),c()},[Ke,c,h,pe]),G=n.useCallback(t=>{h&&(pe(h,t),O(null),y(!1),A(!1),c())},[c,h,pe]),l=n.useCallback(t=>{h&&(t===R&&c(),O(null),y(!1),A(!1),ne(h,t))},[R,ne,c,h]),T=n.useCallback(t=>{if(!t||ve)return;let u=t,i=!1;if(M&&t.length>0){const w=t[0];if(w.length===1&&/[a-zA-Z]/.test(w)){const g=w.toUpperCase();(M==="ctrl"||M==="cmd")&&(u=String.fromCharCode(g.charCodeAt(0)&31),i=!0)}i||(i=!0)}const b=X.current;b&&(p.sendInput(b,u).catch(w=>{ve||O(w instanceof Error?w.message:f("terminalView.error.sendInputFailed"))}),i&&(C(null),fe()))},[M,fe,ve,C,f,p]),V=n.useCallback((t,u)=>{if(Ne.current={cols:t,rows:u},!Ge.current)return;const i=X.current;i&&p.resize({sessionId:i,cols:t,rows:u}).catch(()=>{})},[p]),H=n.useCallback(t=>{C(u=>u===t?null:t),fe()},[fe,C]),K=n.useCallback(t=>{const u=jt(t,M);u&&(T(u),C(null),fe())},[M,fe,T,C]);n.useEffect(()=>{if(!I||!M||!j)return;const t=u=>{if(u.repeat)return;const i=u.key;if(!i||i==="Control"||i==="Meta"||i==="Alt"||i==="Shift")return;const b=i.length===1?i.toLowerCase():i,w=u.code??"",g=w.startsWith("Key")&&w.length===4?w.slice(3).toUpperCase():null,d=i.length===1&&/[a-zA-Z]/.test(i)?i.toUpperCase():g,_={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(b in _){u.preventDefault(),u.stopPropagation(),K(_[b]);return}if(M==="ctrl"&&d&&d.length===1&&d>="A"&&d<="Z"){const oe=String.fromCharCode(d.charCodeAt(0)&31);u.preventDefault(),u.stopPropagation(),T(oe),C(null),fe()}};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[M,K,T,fe,I,C,j]);const Y=n.useMemo(()=>{const t=et[ct].stack;if(typeof window>"u")return(et[de]??et[ct]).stack;const i=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return i&&i.trim().length>0?i.trim():(et[de]??et[ct]).stack??t},[de]),x=n.useMemo(()=>Mt(ee),[ee]),B=n.useMemo(()=>`${h??"no-dir"}::${R??"no-tab"}::${j??"no-terminal"}`,[h,R,j]),Re=n.useMemo(()=>`${B}::layout-${W}`,[B,W]);if(n.useEffect(()=>{if(F||!Ee||!e)return;if(typeof window>"u"){He(u=>u+1);return}const t=window.setTimeout(()=>{He(u=>u+1)},140);return()=>{window.clearTimeout(t)}},[ye,Be,Ee,e,F]),n.useEffect(()=>{if(!e||F)return;const t=L.current;if(!t)return;const u=()=>{t.fit()};if(typeof window<"u"){const i=window.requestAnimationFrame(()=>{u(),we()}),b=[220,400].map(w=>window.setTimeout(u,w));return()=>{window.cancelAnimationFrame(i),b.forEach(w=>window.clearTimeout(w))}}u()},[we,e,F,B,j]),n.useEffect(()=>{if(F||!e||!Ee)return;const t=L.current;if(!t)return;const u=()=>{t.fit()};if(typeof window<"u"){const i=window.requestAnimationFrame(()=>{u()}),b=[0,80,180,320].map(w=>window.setTimeout(u,w));return()=>{window.cancelAnimationFrame(i),b.forEach(w=>window.clearTimeout(w))}}u()},[ye,Be,Ee,e,F]),!ze)return a.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:f("terminalView.empty.selectSession")});if(!h)return a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[a.jsx("p",{children:f("terminalView.empty.noWorkingDirectoryForSession")}),a.jsx("button",{onClick:v,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:f("terminalView.actions.retry")})]});const z=!j||$e||Te||ve,Ve=o,Ae=!he&&Ee&&!Qe,Z=a.jsxs(a.Fragment,{children:[a.jsx(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 px-2 text-xs",onClick:()=>K("esc"),disabled:z,children:f("terminalView.quickKeys.escape")}),a.jsxs(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("tab"),disabled:z,children:[a.jsx(ie,{name:"arrow-right",className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.tabAria")})]}),a.jsxs(Q,{type:"button",size:"sm",variant:"chip","aria-pressed":M==="ctrl",className:"h-6 w-9 p-0",onClick:()=>H("ctrl"),disabled:z,children:[a.jsx("span",{className:"text-xs font-medium",children:f("terminalView.quickKeys.controlLabel")}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.controlModifierAria")})]}),a.jsxs(Q,{type:"button",size:"sm",variant:"chip","aria-pressed":M==="cmd",className:"h-6 w-9 p-0",onClick:()=>H("cmd"),disabled:z,children:[a.jsx(ie,{name:"command"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.commandModifierAria")})]}),a.jsxs(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("arrow-up"),disabled:z,children:[a.jsx(ie,{name:"arrow-up"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowUpAria")})]}),a.jsxs(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("arrow-left"),disabled:z,children:[a.jsx(ie,{name:"arrow-left"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowLeftAria")})]}),a.jsxs(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("arrow-down"),disabled:z,children:[a.jsx(ie,{name:"arrow-down"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowDownAria")})]}),a.jsxs(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("arrow-right"),disabled:z,children:[a.jsx(ie,{name:"arrow-right"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowRightAria")})]}),a.jsxs(Q,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("enter"),disabled:z,children:[a.jsx(ie,{name:"arrow-go-back"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.enterAria")})]})]});return a.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[a.jsxs("div",{className:Ue("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",he?"px-3 py-1.5":"pl-3 pr-1.5 py-1"),children:[N&&k?a.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[a.jsx("div",{className:Ue("min-w-0 flex-1",he?"h-8":"h-7"),children:a.jsx(St,{items:Ye,activeId:R,onSelect:G,onClose:l,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),a.jsx(Q,{type:"button",size:"xs",variant:"ghost",className:Ue("shrink-0",he?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:D,title:f("terminalView.tabs.newTabTitle"),children:a.jsx(ie,{name:"add",className:`${he?"h-[18px] w-[18px]":"h-4 w-4"}`})}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-visible",children:[nt?a.jsxs(Q,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{h&&ce(h,nt)},title:f("terminalView.preview.openTitle"),children:[a.jsx(ie,{name:"global",className:"h-3.5 w-3.5 shrink-0"}),a.jsx("span",{className:"whitespace-nowrap",children:f("terminalView.preview.open")})]}):null,Ae?a.jsxs(a.Fragment,{children:[a.jsx(Q,{type:"button",size:"xs",variant:"ghost",onClick:()=>st(!Be),className:Ue("shrink-0 p-0",E?"h-8 w-8":"h-7 w-7"),title:f(Be?"terminalView.bottomDock.restoreTitle":"terminalView.bottomDock.expandTitle"),"aria-label":f(Be?"terminalView.bottomDock.restoreAria":"terminalView.bottomDock.expandAria"),children:Be?a.jsx(ie,{name:"fullscreen-exit",className:"h-4 w-4"}):a.jsx(ie,{name:"fullscreen",className:"h-4 w-4"})}),a.jsx(Q,{type:"button",size:"xs",variant:"ghost",onClick:()=>ot(!1),className:Ue("shrink-0 p-0",E?"h-8 w-8":"h-7 w-7"),title:f("terminalView.bottomDock.closeTitle"),"aria-label":f("terminalView.bottomDock.closeAria"),children:a.jsx(ie,{name:"close",className:"h-4 w-4"})})]}):null]})]}):null,!E&&I&&N&&k?a.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:Z}):null,I&&(E||!N||!k)?a.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:Z}):null]}),a.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:x.background},children:[a.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:Ve?a.jsx(pt,{ref:t=>{L.current=t},sessionKey:Re,chunks:xe,onInput:T,onResize:V,theme:x,fontFamily:Y,fontSize:Me,enableTouchScroll:F,autoFocus:!F&&e,isVisible:e}):null}),!ve&&We&&a.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:[a.jsx("span",{children:We}),at&&E&&a.jsx(Q,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:S,disabled:Te,title:f("terminalView.actions.hardRestartTitle"),type:"button",children:f("terminalView.actions.hardRestart")})]})]})]})};export{Ht as TerminalView};
|