@openchamber/web 1.14.1 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.test.js +8 -0
- package/bin/lib/DOCUMENTATION.md +3 -0
- package/bin/lib/cli-args.js +10 -0
- package/bin/lib/commands-connect-url.js +169 -22
- package/dist/assets/{DiagramView-Cb58svCq.js → DiagramView-HR2xZxJ8.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-sm01Q7R7.js +11 -0
- package/dist/assets/{MultiRunWindow-BPSxV_B7.js → MultiRunWindow-DlFUaNQK.js} +1 -1
- package/dist/assets/OnboardingScreen-DVRz82mJ.js +1 -0
- package/dist/assets/{SessionSwitcherDropdown-4FWg9xMC.js → SessionSwitcherDropdown-DvoOalMY.js} +1 -1
- package/dist/assets/SettingsWindow-CkInZcj7.js +1 -0
- package/dist/assets/{TerminalView-fTYjnQkh.js → TerminalView-D_9BAjtv.js} +3 -3
- package/dist/assets/es-cjUissX4.js +15 -0
- package/dist/assets/fr-DqbXnTdK.js +13 -0
- package/dist/assets/index-Dg0nmvQU.css +1 -0
- package/dist/assets/index-ltrmNGAf.js +2 -0
- package/dist/assets/ja-Cetyq6Eg.js +15 -0
- package/dist/assets/ko-DtunWisP.js +15 -0
- package/dist/assets/main-BC0m8s1v.js +236 -0
- package/dist/assets/main-DzNa8r0N.js +2 -0
- package/dist/assets/miniChat-BRYDE-Se.js +2 -0
- package/dist/assets/mobile-C3QJVA97.js +2 -0
- package/dist/assets/pl-DctGLgve.js +15 -0
- package/dist/assets/pt-BR-CXPhf78S.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-CVFbDC5A.js +2 -0
- package/dist/assets/renderMobileApp-wkBjh5WR.js +16 -0
- package/dist/assets/runtimeEndpointReset-C42u8PvG.js +167 -0
- package/dist/assets/uk-Bdrc-kqF.js +15 -0
- package/dist/assets/{useAppFontEffects-BUUJYbAZ.js → useAppFontEffects-DzBg8hrC.js} +123 -119
- package/dist/assets/{vendor-.bun-C6iL44L9.js → vendor-.bun-BE757pvp.js} +1 -1
- package/dist/assets/zh-CN-CeCVKrHP.js +15 -0
- package/dist/assets/zh-TW-CoqiQING.js +15 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +2 -2
- package/server/index.js +130 -1
- package/server/lib/client-auth/pairing.js +308 -0
- package/server/lib/client-auth/pairing.test.js +142 -0
- package/server/lib/client-auth/remote-clients.js +65 -3
- package/server/lib/notifications/apns-runtime.js +9 -16
- package/server/lib/opencode/bootstrap-runtime.js +10 -0
- package/server/lib/opencode/core-routes.js +246 -6
- package/server/lib/opencode/core-routes.test.js +248 -9
- package/server/lib/opencode/network-runtime.js +14 -1
- package/server/lib/opencode/network-runtime.test.js +29 -9
- package/server/lib/opencode/proxy.js +47 -6
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +11 -0
- package/server/lib/opencode/settings-normalization-runtime.js +2 -0
- package/server/lib/package-manager.js +18 -5
- package/server/lib/relay/DOCUMENTATION.md +78 -0
- package/server/lib/relay/cross-compat.test.js +135 -0
- package/server/lib/relay/e2ee.js +341 -0
- package/server/lib/relay/e2ee.test.js +124 -0
- package/server/lib/relay/host-client.js +389 -0
- package/server/lib/relay/host-client.test.js +280 -0
- package/server/lib/relay/identity.js +73 -0
- package/server/lib/relay/identity.test.js +78 -0
- package/server/lib/relay/service.js +247 -0
- package/server/lib/relay/signing-key.js +50 -0
- package/server/lib/relay/tunnel-codec.js +373 -0
- package/server/lib/relay/tunnel-codec.test.js +58 -0
- package/server/lib/relay/tunnel-host.js +462 -0
- package/server/lib/ui-auth/DOCUMENTATION.md +6 -0
- package/server/lib/ui-auth/ui-auth.js +10 -0
- package/server/opencode-proxy.test.js +38 -0
- package/dist/assets/MarkdownRendererImpl-D2yCDL5A.js +0 -7
- package/dist/assets/OnboardingScreen-Sl-6JgaP.js +0 -1
- package/dist/assets/SettingsWindow-CY8q4msv.js +0 -1
- package/dist/assets/es-bWcuDy_2.js +0 -15
- package/dist/assets/fr-DzRs3OzV.js +0 -13
- package/dist/assets/index-KnWk9fmM.css +0 -1
- package/dist/assets/index-ZJTzZ0_U.js +0 -2
- package/dist/assets/ja-BqUX_UD3.js +0 -15
- package/dist/assets/ko-BQo10SNx.js +0 -15
- package/dist/assets/main-BDoqLlQB.js +0 -236
- package/dist/assets/main-DUGyTrDt.js +0 -2
- package/dist/assets/miniChat-DNDiX8GA.js +0 -2
- package/dist/assets/mobile-DnghtOCb.js +0 -2
- package/dist/assets/pl-Bgx_ATJT.js +0 -15
- package/dist/assets/pt-BR-B1yXRvoX.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-BB4C1K7t.js +0 -2
- package/dist/assets/renderMobileApp-CZgaXKi5.js +0 -16
- package/dist/assets/runtimeEndpointReset-By39StyB.js +0 -167
- package/dist/assets/uk-C9k8SP8q.js +0 -15
- package/dist/assets/zh-CN-Bri-Vo5y.js +0 -15
- package/dist/assets/zh-TW-DAUGzmYG.js +0 -15
package/dist/assets/{SessionSwitcherDropdown-4FWg9xMC.js → SessionSwitcherDropdown-DvoOalMY.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as ne,R as je,j as r,H as Oe,a as Ue,ae as Ae}from"./vendor-.bun-C6iL44L9.js";import{c as _e,p as q,aH as Be,ah as We,ai as Ge,I as V,M as Ye,aG as He,aF as Ke,c1 as Je,c2 as Qe,bk as Re,u as Xe,b as qe,cw as Ve,r as ke,ay as Ze,aA as et,aB as tt,D as Pe,cU as st,cW as nt}from"./useAppFontEffects-BUUJYbAZ.js";import{z as Se,P as rt,u as Ne}from"./index-ZJTzZ0_U.js";const Bt=s=>{const e=ne.c(129),{totalTokens:t,percentage:o,colorPercentage:n,contextLimit:i,outputLimit:a,size:c,isMobile:x,hideIcon:f,showPercentIcon:l,className:m,valueClassName:v,percentIconClassName:b,onClick:p,pressed:w}=s,S=c===void 0?"default":c,h=x===void 0?!1:x,j=f===void 0?!1:f,N=l===void 0?!1:l,C=w===void 0?!1:w,{t:d}=_e(),[_,y]=je.useState(!1),u=typeof n=="number"?n:o;let g,D,k,I,L,W,B,G;if(e[0]!==u||e[1]!==i||e[2]!==j||e[3]!==h||e[4]!==p||e[5]!==a||e[6]!==b||e[7]!==o||e[8]!==N||e[9]!==d||e[10]!==t||e[11]!==v){const z=We(o)??0,M=Ge(u),$=M==="critical"?"var(--status-error)":M==="warn"?"var(--status-warning)":"var(--status-success)";g=ot,D=it;const T=2*Math.PI*8.5,P=T*(1-z/100);I=typeof a=="number"?Math.max(a,0):0;let E;e[20]!==d||e[21]!==t?(E=d("contextUsage.tooltip.usedTokens",{tokens:g(t)}),e[20]=d,e[21]=t,e[22]=E):E=e[22];let O;e[23]!==i||e[24]!==d?(O=d("contextUsage.tooltip.contextLimit",{tokens:g(i)}),e[23]=i,e[24]=d,e[25]=O):O=e[25];let U;e[26]!==I||e[27]!==d?(U=d("contextUsage.tooltip.outputLimit",{tokens:g(I)}),e[26]=I,e[27]=d,e[28]=U):U=e[28];let R;e[29]!==O||e[30]!==U||e[31]!==E?(R=[E,O,U],e[29]=O,e[30]=U,e[31]=E,e[32]=R):R=e[32],G=R,k=!h&&typeof p=="function",e[33]!==j||e[34]!==h?(B=!h&&!j&&r.jsx(V,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e[33]=j,e[34]=h,e[35]=B):B=e[35],e[36]!==v?(L=q("font-medium inline-flex items-center gap-1.5",v),e[36]=v,e[37]=L):L=e[37],W=N?r.jsxs(r.Fragment,{children:[r.jsxs("svg",{viewBox:"0 0 20 20",className:q("h-3.5 w-3.5 -rotate-90",b),role:"progressbar","aria-valuenow":Math.round(z),"aria-valuemin":0,"aria-valuemax":100,children:[r.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),r.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:$,strokeWidth:3,strokeLinecap:"round",strokeDasharray:T,strokeDashoffset:P,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),r.jsxs("span",{className:"text-foreground",children:[Math.min(o,999).toFixed(1),"%"]})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:D(u),children:Math.min(o,999).toFixed(1)}),"%"]}),e[0]=u,e[1]=i,e[2]=j,e[3]=h,e[4]=p,e[5]=a,e[6]=b,e[7]=o,e[8]=N,e[9]=d,e[10]=t,e[11]=v,e[12]=g,e[13]=D,e[14]=k,e[15]=I,e[16]=L,e[17]=W,e[18]=B,e[19]=G}else g=e[12],D=e[13],k=e[14],I=e[15],L=e[16],W=e[17],B=e[18],G=e[19];let Y;e[38]!==L||e[39]!==W?(Y=r.jsx("span",{className:L,children:W}),e[38]=L,e[39]=W,e[40]=Y):Y=e[40];let Z;e[41]!==B||e[42]!==Y?(Z=r.jsxs(r.Fragment,{children:[B,Y]}),e[41]=B,e[42]=Y,e[43]=Z):Z=e[43];const H=Z,ee=S==="compact"?"typography-micro":"typography-meta";let te;e[44]!==m||e[45]!==k||e[46]!==ee?(te=q("app-region-no-drag flex items-center gap-1.5 select-none",ee,k?q("rounded-md px-2 py-1.5 text-foreground transition-colors","hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"):"text-muted-foreground/60",m),e[44]=m,e[45]=k,e[46]=ee,e[47]=te):te=e[47];const K=te;let J;e[48]!==H||e[49]!==k||e[50]!==h||e[51]!==p||e[52]!==C||e[53]!==K||e[54]!==d?(J=k?r.jsx("button",{type:"button",className:K,"aria-label":d("contextUsage.aria.label"),"aria-pressed":C,onClick:p,children:H}):r.jsx("div",{className:K,"aria-label":d("contextUsage.aria.label"),onClick:h?()=>y(!0):void 0,children:H}),e[48]=H,e[49]=k,e[50]=h,e[51]=p,e[52]=C,e[53]=K,e[54]=d,e[55]=J):J=e[55];const X=J;if(h){let z;e[56]===Symbol.for("react.memo_cache_sentinel")?(z=()=>y(!1),e[56]=z):z=e[56];let M;e[57]!==d?(M=d("contextUsage.mobile.title"),e[57]=d,e[58]=M):M=e[58];let $;e[59]!==d?($=d("contextUsage.mobile.usedTokens"),e[59]=d,e[60]=$):$=e[60];let T;e[61]!==$?(T=r.jsx("span",{className:"typography-meta text-muted-foreground",children:$}),e[61]=$,e[62]=T):T=e[62];let P;e[63]!==g||e[64]!==t?(P=g(t),e[63]=g,e[64]=t,e[65]=P):P=e[65];let E;e[66]!==P?(E=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:P}),e[66]=P,e[67]=E):E=e[67];let O;e[68]!==T||e[69]!==E?(O=r.jsxs("div",{className:"flex justify-between items-center",children:[T,E]}),e[68]=T,e[69]=E,e[70]=O):O=e[70];let U;e[71]!==d?(U=d("contextUsage.mobile.contextLimit"),e[71]=d,e[72]=U):U=e[72];let R;e[73]!==U?(R=r.jsx("span",{className:"typography-meta text-muted-foreground",children:U}),e[73]=U,e[74]=R):R=e[74];let re;e[75]!==i||e[76]!==g?(re=g(i),e[75]=i,e[76]=g,e[77]=re):re=e[77];let oe;e[78]!==re?(oe=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:re}),e[78]=re,e[79]=oe):oe=e[79];let ie;e[80]!==R||e[81]!==oe?(ie=r.jsxs("div",{className:"flex justify-between items-center",children:[R,oe]}),e[80]=R,e[81]=oe,e[82]=ie):ie=e[82];let ae;e[83]!==d?(ae=d("contextUsage.mobile.outputLimit"),e[83]=d,e[84]=ae):ae=e[84];let le;e[85]!==ae?(le=r.jsx("span",{className:"typography-meta text-muted-foreground",children:ae}),e[85]=ae,e[86]=le):le=e[86];let ce;e[87]!==g||e[88]!==I?(ce=g(I),e[87]=g,e[88]=I,e[89]=ce):ce=e[89];let de;e[90]!==ce?(de=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:ce}),e[90]=ce,e[91]=de):de=e[91];let ue;e[92]!==le||e[93]!==de?(ue=r.jsxs("div",{className:"flex justify-between items-center",children:[le,de]}),e[92]=le,e[93]=de,e[94]=ue):ue=e[94];let fe;e[95]!==d?(fe=d("contextUsage.mobile.usage"),e[95]=d,e[96]=fe):fe=e[96];let me;e[97]!==fe?(me=r.jsx("span",{className:"typography-meta text-muted-foreground",children:fe}),e[97]=fe,e[98]=me):me=e[98];let he;e[99]!==u||e[100]!==D?(he=q("typography-meta font-semibold",D(u)),e[99]=u,e[100]=D,e[101]=he):he=e[101];const De=Math.min(o,999);let pe;e[102]!==De?(pe=De.toFixed(1),e[102]=De,e[103]=pe):pe=e[103];let ge;e[104]!==he||e[105]!==pe?(ge=r.jsxs("span",{className:he,children:[pe,"%"]}),e[104]=he,e[105]=pe,e[106]=ge):ge=e[106];let xe;e[107]!==me||e[108]!==ge?(xe=r.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[me,ge]}),e[107]=me,e[108]=ge,e[109]=xe):xe=e[109];let be;e[110]!==O||e[111]!==ie||e[112]!==ue||e[113]!==xe?(be=r.jsx("div",{className:"flex flex-col gap-1.5",children:r.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[O,ie,ue,xe]})}),e[110]=O,e[111]=ie,e[112]=ue,e[113]=xe,e[114]=be):be=e[114];let we;e[115]!==_||e[116]!==M||e[117]!==be?(we=r.jsx(Ye,{open:_,onClose:z,title:M,children:be}),e[115]=_,e[116]=M,e[117]=be,e[118]=we):we=e[118];let ve;return e[119]!==X||e[120]!==we?(ve=r.jsxs(r.Fragment,{children:[X,we]}),e[119]=X,e[120]=we,e[121]=ve):ve=e[121],ve}let A;e[122]!==X?(A=r.jsx(He,{asChild:!0,children:X}),e[122]=X,e[123]=A):A=e[123];let F;e[124]!==G?(F=r.jsx(Be,{children:r.jsx("div",{className:"space-y-0.5",children:G.map(at)})}),e[124]=G,e[125]=F):F=e[125];let Q;return e[126]!==A||e[127]!==F?(Q=r.jsxs(Ke,{children:[A,F]}),e[126]=A,e[127]=F,e[128]=Q):Q=e[128],Q};function ot(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toFixed(1).replace(/\.0$/,"")}function it(s){return s>=90?"text-status-error":s>=75?"text-status-warning":"text-status-success"}function at(s){return r.jsx("p",{className:"typography-micro leading-tight",children:s},s)}const Wt=je.memo(function(e){const t=ne.c(40),{visible:o}=e,{t:n}=_e(),[i,a]=je.useState(!1);let c,x;if(t[0]!==o?(c=()=>{if(!o)return;let D=!1;Se("desktop_get_current_window_state").then(I=>{D||a(!!I?.maximized)}).catch(lt);const k=I=>{const L=I.detail;a(!!L?.maximized)};return window.addEventListener("openchamber:window-maximized-changed",k),()=>{D=!0,window.removeEventListener("openchamber:window-maximized-changed",k)}},x=[o],t[0]=o,t[1]=c,t[2]=x):(c=t[1],x=t[2]),Oe.useEffect(c,x),!o)return null;let f;t[3]!==n?(f=n("header.windowControls.groupAria"),t[3]=n,t[4]=f):f=t[4];let l;t[5]!==n?(l=n("header.windowControls.minimize"),t[5]=n,t[6]=l):l=t[6];let m;t[7]!==n?(m=n("header.windowControls.minimize"),t[7]=n,t[8]=m):m=t[8];let v;t[9]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(V,{name:"subtract",className:"h-4 w-4"}),t[9]=v):v=t[9];let b;t[10]!==l||t[11]!==m?(b=r.jsx("button",{type:"button",className:"app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:ct,title:l,"aria-label":m,children:v}),t[10]=l,t[11]=m,t[12]=b):b=t[12];let p;t[13]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{Se("desktop_toggle_current_window_maximized").then(D=>a(!!D?.maximized)).catch(dt)},t[13]=p):p=t[13];let w;t[14]!==i||t[15]!==n?(w=n(i?"header.windowControls.restore":"header.windowControls.maximize"),t[14]=i,t[15]=n,t[16]=w):w=t[16];let S;t[17]!==i||t[18]!==n?(S=n(i?"header.windowControls.restore":"header.windowControls.maximize"),t[17]=i,t[18]=n,t[19]=S):S=t[19];const h=i?"fullscreen-exit":"checkbox-blank";let j;t[20]!==h?(j=r.jsx(V,{name:h,className:"h-3.5 w-3.5"}),t[20]=h,t[21]=j):j=t[21];let N;t[22]!==S||t[23]!==j||t[24]!==w?(N=r.jsx("button",{type:"button",className:"app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:p,title:w,"aria-label":S,children:j}),t[22]=S,t[23]=j,t[24]=w,t[25]=N):N=t[25];let C;t[26]===Symbol.for("react.memo_cache_sentinel")?(C=q("app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","hover:bg-status-error hover:text-status-error-foreground"),t[26]=C):C=t[26];let d;t[27]!==n?(d=n("header.windowControls.close"),t[27]=n,t[28]=d):d=t[28];let _;t[29]!==n?(_=n("header.windowControls.close"),t[29]=n,t[30]=_):_=t[30];let y;t[31]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(V,{name:"close",className:"h-4 w-4"}),t[31]=y):y=t[31];let u;t[32]!==d||t[33]!==_?(u=r.jsx("button",{type:"button",className:C,onClick:ut,title:d,"aria-label":_,children:y}),t[32]=d,t[33]=_,t[34]=u):u=t[34];let g;return t[35]!==N||t[36]!==u||t[37]!==f||t[38]!==b?(g=r.jsxs("div",{className:"app-region-no-drag -mr-3 ml-2 flex h-12 shrink-0 items-center","aria-label":f,children:[b,N,u]}),t[35]=N,t[36]=u,t[37]=f,t[38]=b,t[39]=g):g=t[39],g});function lt(){}function ct(){Se("desktop_minimize_current_window")}function dt(){}function ut(){Se("desktop_close_current_window")}const Fe="oc.sessions.pinned",ft=s=>{try{const e=s.getItem(Fe);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(o=>typeof o=="string")):new Set}catch{return new Set}},Me=(s,e)=>{try{s.setItem(Fe,JSON.stringify([...e]))}catch{}},Ce=rt(),mt=Ue((s,e)=>({ids:ft(Ce),setIds:t=>{const o=e().ids,n=typeof t=="function"?t(o):t;n!==o&&(s({ids:n}),Me(Ce,n))},toggle:t=>{const o=e().ids,n=new Set(o);n.has(t)?n.delete(t):n.add(t),s({ids:n}),Me(Ce,n)}})),se=(s,e)=>Je(Qe.getState().dictionary,s,e),ht=s=>{const e=new Date(s),t=new Date,o=(a,c)=>a.getFullYear()===c.getFullYear()&&a.getMonth()===c.getMonth()&&a.getDate()===c.getDate(),n=new Date(t);return n.setDate(t.getDate()-1),o(e,t)?se("common.date.today"):o(e,n)?se("common.date.yesterday"):e.toLocaleDateString(Re(),{month:"short",day:"numeric",year:"numeric"}).replace(",","")},Gt=s=>{const e=new Date,t=new Date(s);if(((n,i)=>n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate())(t,e)){const n=Date.now()-s;return n<6e4?se("common.relative.justNow"):n<36e5?se("common.relative.minutesAgoShort",{count:Math.floor(n/6e4)}):se("common.relative.hoursAgoShort",{count:Math.floor(n/36e5)})}return ht(s)},pt=s=>{const e=Math.max(0,Date.now()-s),t=6e4,o=60*t,n=24*o,i=7*n,a=30*n,c=365*n;return e<o?`${Math.max(1,Math.floor(e/t))}m`:e<n?`${Math.floor(e/o)}h`:e<i?se("common.relative.daysAgoCompact",{count:Math.floor(e/n)}):e<5*i?se("common.relative.weeksAgoCompact",{count:Math.floor(e/i)}):e<c?`${Math.floor(e/a)}mo`:se("common.relative.yearsAgoCompact",{count:Math.floor(e/c)})},ye=s=>{if(!s)return null;const e=s.replace(/\\/g,"/").replace(/\/+$/,"");return e.length===0?"/":e},gt=(s,e)=>{const t=ye(s),o=ye(e);return!t||!o?!1:t===o?!0:o==="/"?t.startsWith("/"):t.startsWith(`${o}/`)},Le=s=>s.toLowerCase().replace(/^opencode[/-]?/i,"").replace(/[-_]/g,"").trim(),Yt=(s,e)=>s?Le(s)!==Le(e):!1,Ie=s=>{if(typeof s=="number"&&Number.isFinite(s))return s;if(typeof s=="string"&&s.trim().length>0){const e=Number(s);if(Number.isFinite(e))return e}},$e=s=>Ie(s.time?.created)??0,ze=s=>Ie(s.time?.updated)??Ie(s.time?.created)??0,Te=(s,e,t)=>{const o=t.has(s.id),n=t.has(e.id);return o!==n?o?-1:1:o&&n?$e(e)-$e(s):ze(e)-ze(s)},Ht=s=>{const e=new Map;return s.forEach(t=>{e.set(t.id,t)}),Array.from(e.values())},Kt=s=>`__archived__:${s}`,Jt=(s,e)=>{const t=ye(s.directory??null),o=ye(s.project?.worktree??null),n=t??o;if(!n)return"unassigned";if(e&&n===e)return"project root";const a=(e&&n.startsWith(`${e}/`)?n.slice(e.length+1):n).split("/").filter(Boolean);return a[a.length-1]??"unassigned"},Qt=(s,e,t)=>{const o=ye(s.directory??null),n=ye(s.project?.worktree??null);return n&&(n===e||n.startsWith(`${e}/`))?!0:o?t&&t.has(o)?!0:o===e||o.startsWith(`${e}/`):!1},Rt=s=>s.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),Xt=(s,e)=>{if(!e)return s;const t=s.toLowerCase(),o=e.toLowerCase(),n=o.length;if(n===0)return s;const i=[];let a=0,c=t.indexOf(o,a);for(;c!==-1;){c>a&&i.push(s.slice(a,c));const x=s.slice(c,c+n);i.push(r.jsx("mark",{className:"bg-primary text-primary-foreground ring-1 ring-primary/90",children:x},`${c}-${x}`)),a=c+n,c=t.indexOf(o,a)}return a<s.length&&i.push(s.slice(a)),i.length>0?i:s},xt=7,bt=s=>{if(!s)return null;const e=s.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},wt=s=>{if(!s)return null;const e=s.label?.trim();if(e)return e;const t=s.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},yt=(s,e)=>{const t=ne.c(18);let o;t[0]!==e?(o=e===void 0?{}:e,t[0]=e,t[1]=o):o=t[1];const n=o,{scopeProjectId:i}=n,a=i===void 0?null:i,c=Xe(vt),x=qe(jt),f=mt(St),l=Ve();let m;t[2]!==x?(m=x.map(Nt).filter(_t),t[2]=x,t[3]=m):m=t[3];const v=m;let b;t[4]!==v?(b=h=>h?v.filter(N=>gt(h,N.normalizedPath)).sort(Dt)[0]??null:null,t[4]=v,t[5]=b):b=t[5];const p=b;let w;{let h;if(t[7]!==c||t[8]!==l||t[9]!==p||t[10]!==f||t[11]!==a){const j=new Map;for(const y of c){const u=y.parentID;if(!u||y.time?.archived)continue;const g=j.get(u);g?g.push(y):j.set(u,[y])}j.forEach(y=>{y.sort((u,g)=>Te(u,g,f))});let N;t[13]!==p||t[14]!==a?(N=y=>{if(!a)return!0;const u=ke(y);return p(u)?.id===a},t[13]=p,t[14]=a,t[15]=N):N=t[15];let C;t[16]!==f?(C=(y,u)=>Te(y,u,f),t[16]=f,t[17]=C):C=t[17];const d=c.filter(Ct).filter(kt).filter(N).sort(C).slice(0,xt),_=y=>{const u=j.get(y.id)??[];return{session:y,children:u.map(g=>_(g)),worktree:null}};h=d.map(y=>{const u=ke(y),g=p(u),D=wt(g),k=u?l.get(u)??null:null;return{node:_(y),projectId:g?.id??null,groupDirectory:u,secondaryMeta:{projectLabel:D,branchLabel:k&&k!==D?k:null}}}),t[7]=c,t[8]=l,t[9]=p,t[10]=f,t[11]=a,t[12]=h}else h=t[12];w=h}return w};function vt(s){return s.activeSessions}function jt(s){return s.projects}function St(s){return s.ids}function Nt(s){return{...s,normalizedPath:bt(s.path)}}function _t(s){return s.normalizedPath}function Dt(s,e){return(e.normalizedPath?.length??0)-(s.normalizedPath?.length??0)}function Ct(s){return!s.time?.archived}function kt(s){return!s.parentID}function qt(s){const e=ne.c(18),{children:t,variant:o,scopeProjectId:n,align:i}=s,a=o===void 0?"default":o,c=n===void 0?null:n,x=i===void 0?"start":i,f=Ne(It),l=Ne(Pt);let m;e[0]!==t?(m=r.jsx(Ze,{asChild:!0,children:t}),e[0]=t,e[1]=m):m=e[1];const v=a==="compact"?"w-[280px]":"w-[360px]";let b;e[2]!==v?(b=q("overflow-hidden p-1 max-w-[calc(100vw-32px)]",v),e[2]=v,e[3]=b):b=e[3];let p;e[4]!==f||e[5]!==c||e[6]!==l||e[7]!==a?(p=f?r.jsx(Mt,{onSelect:()=>l(!1),variant:a,scopeProjectId:c}):null,e[4]=f,e[5]=c,e[6]=l,e[7]=a,e[8]=p):p=e[8];let w;e[9]!==x||e[10]!==b||e[11]!==p?(w=r.jsx(et,{align:x,sideOffset:6,className:b,children:p}),e[9]=x,e[10]=b,e[11]=p,e[12]=w):w=e[12];let S;return e[13]!==f||e[14]!==l||e[15]!==m||e[16]!==w?(S=r.jsxs(tt,{open:f,onOpenChange:l,modal:!1,children:[m,w]}),e[13]=f,e[14]=l,e[15]=m,e[16]=w,e[17]=S):S=e[17],S}function Pt(s){return s.setSessionDropdownOpen}function It(s){return s.isSessionDropdownOpen}function Mt(s){const e=ne.c(26),{onSelect:t,variant:o,scopeProjectId:n}=s;let i;e[0]!==n?(i={scopeProjectId:n},e[0]=n,e[1]=i):i=e[1];const a=yt(!0,i),c=Pe($t),x=Ne(Lt),{t:f}=_e();let l;e[2]!==t||e[3]!==c||e[4]!==x?(l=()=>{x("chat"),t(),c()},e[2]=t,e[3]=c,e[4]=x,e[5]=l):l=e[5];const m=l;let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=new Set,e[6]=v):v=e[6];const[b,p]=je.useState(v);let w;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=u=>{p(g=>{const D=new Set(g);return D.has(u)?D.delete(u):D.add(u),D})},e[7]=w):w=e[7];const S=w;let h,j;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=q("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),j=r.jsx(V,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e[8]=h,e[9]=j):(h=e[8],j=e[9]);let N;e[10]!==f?(N=f("sessions.sidebar.header.actions.newSession"),e[10]=f,e[11]=N):N=e[11];let C;e[12]!==N?(C=r.jsx("span",{className:"truncate text-[14px] font-normal leading-tight text-foreground",children:N}),e[12]=N,e[13]=C):C=e[13];let d;e[14]!==m||e[15]!==C?(d=r.jsxs(Ae,{onClick:m,className:h,children:[j,C]}),e[14]=m,e[15]=C,e[16]=d):d=e[16];let _;e[17]!==b||e[18]!==a||e[19]!==t||e[20]!==f||e[21]!==o?(_=a.length===0?r.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:f("sessions.switcher.empty")}):a.map(u=>r.jsx(Ee,{item:u,depth:0,variant:o,expandedParents:b,toggleParent:S,closeDropdown:t},u.node.session.id)),e[17]=b,e[18]=a,e[19]=t,e[20]=f,e[21]=o,e[22]=_):_=e[22];let y;return e[23]!==_||e[24]!==d?(y=r.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:r.jsxs("div",{className:"space-y-0.5",children:[d,_]})}),e[23]=_,e[24]=d,e[25]=y):y=e[25],y}function Lt(s){return s.setActiveMainTab}function $t(s){return s.openNewSessionDraft}function Ee(s){const e=ne.c(31),{item:t,depth:o,variant:n,expandedParents:i,toggleParent:a,closeDropdown:c}=s,{node:x,secondaryMeta:f}=t,l=x.session,m=x.children.length>0;let v;e[0]!==i||e[1]!==l.id?(v=i.has(l.id),e[0]=i,e[1]=l.id,e[2]=v):v=e[2];const b=v;let p;e[3]!==m||e[4]!==l.id||e[5]!==a?(p=m?()=>a(l.id):void 0,e[3]=m,e[4]=l.id,e[5]=a,e[6]=p):p=e[6];let w;e[7]!==c||e[8]!==o||e[9]!==m||e[10]!==b||e[11]!==f||e[12]!==l||e[13]!==p||e[14]!==n?(w=r.jsx(zt,{session:l,depth:o,variant:n,secondaryMeta:f,hasChildren:m,isExpanded:b,onToggleExpand:p,closeDropdown:c}),e[7]=c,e[8]=o,e[9]=m,e[10]=b,e[11]=f,e[12]=l,e[13]=p,e[14]=n,e[15]=w):w=e[15];let S;e[16]!==c||e[17]!==o||e[18]!==i||e[19]!==m||e[20]!==b||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==x.children||e[24]!==f||e[25]!==a||e[26]!==n?(S=m&&b?x.children.map(j=>r.jsx(Ee,{item:{node:j,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:f},depth:o+1,variant:n,expandedParents:i,toggleParent:a,closeDropdown:c},j.session.id)):null,e[16]=c,e[17]=o,e[18]=i,e[19]=m,e[20]=b,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=x.children,e[24]=f,e[25]=a,e[26]=n,e[27]=S):S=e[27];let h;return e[28]!==w||e[29]!==S?(h=r.jsxs(r.Fragment,{children:[w,S]}),e[28]=w,e[29]=S,e[30]=h):h=e[30],h}function zt(s){const e=ne.c(57),{session:t,depth:o,variant:n,secondaryMeta:i,hasChildren:a,isExpanded:c,onToggleExpand:x,closeDropdown:f}=s,{t:l}=_e(),m=Pe(Ft),v=Pe(At),b=Ne(Tt),p=st(t.id),w=nt(t.id),S=m===t.id;let h;e[0]!==t.title||e[1]!==l?(h=t.title?.trim()||l("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=l,e[2]=h):h=e[2];const j=h,N=!!t.parentID,C=w>0&&(!N||b),d=p?.type??"idle",_=d==="busy"||d==="retry",y=!_&&C&&!S;let u;e[3]!==t.time?.created||e[4]!==t.time?.updated?(u=t.time?.updated||t.time?.created||Date.now(),e[3]=t.time?.created,e[4]=t.time?.updated,e[5]=u):u=e[5];const g=u;let D;e[6]!==g?(D=pt(g),e[6]=g,e[7]=D):D=e[7];const k=D;let I;e[8]!==i?.projectLabel?(I=i?.projectLabel?.trim()||null,e[8]=i?.projectLabel,e[9]=I):I=e[9];const L=I;let W;e[10]!==i?.branchLabel?(W=i?.branchLabel?.trim()||null,e[10]=i?.branchLabel,e[11]=W):W=e[11];const B=W,G=B&&B!=="HEAD"?B:null;let Y;e[12]!==f||e[13]!==S||e[14]!==t||e[15]!==v?(Y=()=>{if(S){f();return}const P=ke(t);v(t.id,P??null),f()},e[12]=f,e[13]=S,e[14]=t,e[15]=v,e[16]=Y):Y=e[16];const Z=Y;let H;e[17]!==Z?(H=P=>{if(P.target?.closest("[data-switcher-expand]")){P.preventDefault();return}Z()},e[17]=Z,e[18]=H):H=e[18];let ee;e[19]===Symbol.for("react.memo_cache_sentinel")?(ee=q("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),e[19]=ee):ee=e[19];const te=8+o*12;let K;e[20]!==te?(K={paddingLeft:te},e[20]=te,e[21]=K):K=e[21];let J;e[22]!==a||e[23]!==c||e[24]!==x||e[25]!==l||e[26]!==n?(J=n==="compact"&&a?r.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:P=>{P.preventDefault(),P.stopPropagation(),x?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?r.jsx(V,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):r.jsx(V,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[22]=a,e[23]=c,e[24]=x,e[25]=l,e[26]=n,e[27]=J):J=e[27];const X=S?"text-primary":"text-foreground";let A;e[28]!==X?(A=q("truncate text-[14px] font-normal leading-tight",X),e[28]=X,e[29]=A):A=e[29];let F;e[30]!==j||e[31]!==A?(F=r.jsx("span",{className:A,children:j}),e[30]=j,e[31]=A,e[32]=F):F=e[32];let Q;e[33]!==J||e[34]!==F?(Q=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[J,F]}),e[33]=J,e[34]=F,e[35]=Q):Q=e[35];let z;e[36]!==G||e[37]!==a||e[38]!==c||e[39]!==x||e[40]!==L||e[41]!==l||e[42]!==k||e[43]!==n?(z=n==="default"?r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:[a?r.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:P=>{P.preventDefault(),P.stopPropagation(),x?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?r.jsx(V,{name:"arrow-down-s",className:"h-3 w-3"}):r.jsx(V,{name:"arrow-right-s",className:"h-3 w-3"})}):null,r.jsx("span",{className:"flex-shrink-0",children:k}),L?r.jsx("span",{className:"truncate",children:L}):null,G?r.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[r.jsx(V,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),r.jsx("span",{className:"truncate",children:G})]}):null]}):null,e[36]=G,e[37]=a,e[38]=c,e[39]=x,e[40]=L,e[41]=l,e[42]=k,e[43]=n,e[44]=z):z=e[44];let M;e[45]!==Q||e[46]!==z?(M=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[Q,z]}),e[45]=Q,e[46]=z,e[47]=M):M=e[47];let $;e[48]!==_||e[49]!==y||e[50]!==l?($=_||y?r.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:_?r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":l("sessions.sidebar.session.status.active"),title:l("sessions.sidebar.session.status.active")}):r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":l("sessions.sidebar.session.status.unread"),title:l("sessions.sidebar.session.status.unread")})}):null,e[48]=_,e[49]=y,e[50]=l,e[51]=$):$=e[51];let T;return e[52]!==K||e[53]!==M||e[54]!==$||e[55]!==H?(T=r.jsxs(Ae,{onClick:H,"data-slot":"session-switcher-item",className:ee,style:K,children:[M,$]}),e[52]=K,e[53]=M,e[54]=$,e[55]=H,e[56]=T):T=e[56],T}function Tt(s){return s.notifyOnSubtasks}function At(s){return s.setCurrentSession}function Ft(s){return s.currentSessionId}export{Bt as C,qt as S,Wt as W,Le as a,Yt as b,Te as c,Ht as d,Xt as e,Rt as f,Kt as g,Gt as h,Qt as i,pt as j,ye as n,Jt as r,mt as u};
|
|
1
|
+
import{b as ne,R as je,j as r,r as Oe,a as Ue,af as Ae}from"./vendor-.bun-BE757pvp.js";import{c as _e,v as q,aJ as Be,ak as We,al as Ge,I as V,M as Ye,aI as He,aH as Je,b$ as Ke,c0 as Qe,bi as Re,u as Xe,b as qe,cu as Ve,r as ke,aB as Ze,aD as et,aE as tt,G as Pe,cS as st,cU as nt}from"./useAppFontEffects-DzBg8hrC.js";import{I as Se,a as rt,u as Ne}from"./index-ltrmNGAf.js";const Bt=s=>{const e=ne.c(129),{totalTokens:t,percentage:o,colorPercentage:n,contextLimit:i,outputLimit:a,size:c,isMobile:x,hideIcon:f,showPercentIcon:l,className:m,valueClassName:v,percentIconClassName:b,onClick:p,pressed:w}=s,S=c===void 0?"default":c,h=x===void 0?!1:x,j=f===void 0?!1:f,N=l===void 0?!1:l,C=w===void 0?!1:w,{t:d}=_e(),[_,y]=je.useState(!1),u=typeof n=="number"?n:o;let g,D,k,I,$,W,B,G;if(e[0]!==u||e[1]!==i||e[2]!==j||e[3]!==h||e[4]!==p||e[5]!==a||e[6]!==b||e[7]!==o||e[8]!==N||e[9]!==d||e[10]!==t||e[11]!==v){const z=We(o)??0,M=Ge(u),L=M==="critical"?"var(--status-error)":M==="warn"?"var(--status-warning)":"var(--status-success)";g=ot,D=it;const T=2*Math.PI*8.5,P=T*(1-z/100);I=typeof a=="number"?Math.max(a,0):0;let F;e[20]!==d||e[21]!==t?(F=d("contextUsage.tooltip.usedTokens",{tokens:g(t)}),e[20]=d,e[21]=t,e[22]=F):F=e[22];let O;e[23]!==i||e[24]!==d?(O=d("contextUsage.tooltip.contextLimit",{tokens:g(i)}),e[23]=i,e[24]=d,e[25]=O):O=e[25];let U;e[26]!==I||e[27]!==d?(U=d("contextUsage.tooltip.outputLimit",{tokens:g(I)}),e[26]=I,e[27]=d,e[28]=U):U=e[28];let R;e[29]!==O||e[30]!==U||e[31]!==F?(R=[F,O,U],e[29]=O,e[30]=U,e[31]=F,e[32]=R):R=e[32],G=R,k=!h&&typeof p=="function",e[33]!==j||e[34]!==h?(B=!h&&!j&&r.jsx(V,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e[33]=j,e[34]=h,e[35]=B):B=e[35],e[36]!==v?($=q("font-medium inline-flex items-center gap-1.5",v),e[36]=v,e[37]=$):$=e[37],W=N?r.jsxs(r.Fragment,{children:[r.jsxs("svg",{viewBox:"0 0 20 20",className:q("h-3.5 w-3.5 -rotate-90",b),role:"progressbar","aria-valuenow":Math.round(z),"aria-valuemin":0,"aria-valuemax":100,children:[r.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),r.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:L,strokeWidth:3,strokeLinecap:"round",strokeDasharray:T,strokeDashoffset:P,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),r.jsxs("span",{className:"text-foreground",children:[Math.min(o,999).toFixed(1),"%"]})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:D(u),children:Math.min(o,999).toFixed(1)}),"%"]}),e[0]=u,e[1]=i,e[2]=j,e[3]=h,e[4]=p,e[5]=a,e[6]=b,e[7]=o,e[8]=N,e[9]=d,e[10]=t,e[11]=v,e[12]=g,e[13]=D,e[14]=k,e[15]=I,e[16]=$,e[17]=W,e[18]=B,e[19]=G}else g=e[12],D=e[13],k=e[14],I=e[15],$=e[16],W=e[17],B=e[18],G=e[19];let Y;e[38]!==$||e[39]!==W?(Y=r.jsx("span",{className:$,children:W}),e[38]=$,e[39]=W,e[40]=Y):Y=e[40];let Z;e[41]!==B||e[42]!==Y?(Z=r.jsxs(r.Fragment,{children:[B,Y]}),e[41]=B,e[42]=Y,e[43]=Z):Z=e[43];const H=Z,ee=S==="compact"?"typography-micro":"typography-meta";let te;e[44]!==m||e[45]!==k||e[46]!==ee?(te=q("app-region-no-drag flex items-center gap-1.5 select-none",ee,k?q("rounded-md px-2 py-1.5 text-foreground transition-colors","hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"):"text-muted-foreground/60",m),e[44]=m,e[45]=k,e[46]=ee,e[47]=te):te=e[47];const J=te;let K;e[48]!==H||e[49]!==k||e[50]!==h||e[51]!==p||e[52]!==C||e[53]!==J||e[54]!==d?(K=k?r.jsx("button",{type:"button",className:J,"aria-label":d("contextUsage.aria.label"),"aria-pressed":C,onClick:p,children:H}):r.jsx("div",{className:J,"aria-label":d("contextUsage.aria.label"),onClick:h?()=>y(!0):void 0,children:H}),e[48]=H,e[49]=k,e[50]=h,e[51]=p,e[52]=C,e[53]=J,e[54]=d,e[55]=K):K=e[55];const X=K;if(h){let z;e[56]===Symbol.for("react.memo_cache_sentinel")?(z=()=>y(!1),e[56]=z):z=e[56];let M;e[57]!==d?(M=d("contextUsage.mobile.title"),e[57]=d,e[58]=M):M=e[58];let L;e[59]!==d?(L=d("contextUsage.mobile.usedTokens"),e[59]=d,e[60]=L):L=e[60];let T;e[61]!==L?(T=r.jsx("span",{className:"typography-meta text-muted-foreground",children:L}),e[61]=L,e[62]=T):T=e[62];let P;e[63]!==g||e[64]!==t?(P=g(t),e[63]=g,e[64]=t,e[65]=P):P=e[65];let F;e[66]!==P?(F=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:P}),e[66]=P,e[67]=F):F=e[67];let O;e[68]!==T||e[69]!==F?(O=r.jsxs("div",{className:"flex justify-between items-center",children:[T,F]}),e[68]=T,e[69]=F,e[70]=O):O=e[70];let U;e[71]!==d?(U=d("contextUsage.mobile.contextLimit"),e[71]=d,e[72]=U):U=e[72];let R;e[73]!==U?(R=r.jsx("span",{className:"typography-meta text-muted-foreground",children:U}),e[73]=U,e[74]=R):R=e[74];let re;e[75]!==i||e[76]!==g?(re=g(i),e[75]=i,e[76]=g,e[77]=re):re=e[77];let oe;e[78]!==re?(oe=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:re}),e[78]=re,e[79]=oe):oe=e[79];let ie;e[80]!==R||e[81]!==oe?(ie=r.jsxs("div",{className:"flex justify-between items-center",children:[R,oe]}),e[80]=R,e[81]=oe,e[82]=ie):ie=e[82];let ae;e[83]!==d?(ae=d("contextUsage.mobile.outputLimit"),e[83]=d,e[84]=ae):ae=e[84];let le;e[85]!==ae?(le=r.jsx("span",{className:"typography-meta text-muted-foreground",children:ae}),e[85]=ae,e[86]=le):le=e[86];let ce;e[87]!==g||e[88]!==I?(ce=g(I),e[87]=g,e[88]=I,e[89]=ce):ce=e[89];let de;e[90]!==ce?(de=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:ce}),e[90]=ce,e[91]=de):de=e[91];let ue;e[92]!==le||e[93]!==de?(ue=r.jsxs("div",{className:"flex justify-between items-center",children:[le,de]}),e[92]=le,e[93]=de,e[94]=ue):ue=e[94];let fe;e[95]!==d?(fe=d("contextUsage.mobile.usage"),e[95]=d,e[96]=fe):fe=e[96];let me;e[97]!==fe?(me=r.jsx("span",{className:"typography-meta text-muted-foreground",children:fe}),e[97]=fe,e[98]=me):me=e[98];let he;e[99]!==u||e[100]!==D?(he=q("typography-meta font-semibold",D(u)),e[99]=u,e[100]=D,e[101]=he):he=e[101];const De=Math.min(o,999);let pe;e[102]!==De?(pe=De.toFixed(1),e[102]=De,e[103]=pe):pe=e[103];let ge;e[104]!==he||e[105]!==pe?(ge=r.jsxs("span",{className:he,children:[pe,"%"]}),e[104]=he,e[105]=pe,e[106]=ge):ge=e[106];let xe;e[107]!==me||e[108]!==ge?(xe=r.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[me,ge]}),e[107]=me,e[108]=ge,e[109]=xe):xe=e[109];let be;e[110]!==O||e[111]!==ie||e[112]!==ue||e[113]!==xe?(be=r.jsx("div",{className:"flex flex-col gap-1.5",children:r.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[O,ie,ue,xe]})}),e[110]=O,e[111]=ie,e[112]=ue,e[113]=xe,e[114]=be):be=e[114];let we;e[115]!==_||e[116]!==M||e[117]!==be?(we=r.jsx(Ye,{open:_,onClose:z,title:M,children:be}),e[115]=_,e[116]=M,e[117]=be,e[118]=we):we=e[118];let ve;return e[119]!==X||e[120]!==we?(ve=r.jsxs(r.Fragment,{children:[X,we]}),e[119]=X,e[120]=we,e[121]=ve):ve=e[121],ve}let A;e[122]!==X?(A=r.jsx(He,{asChild:!0,children:X}),e[122]=X,e[123]=A):A=e[123];let E;e[124]!==G?(E=r.jsx(Be,{children:r.jsx("div",{className:"space-y-0.5",children:G.map(at)})}),e[124]=G,e[125]=E):E=e[125];let Q;return e[126]!==A||e[127]!==E?(Q=r.jsxs(Je,{children:[A,E]}),e[126]=A,e[127]=E,e[128]=Q):Q=e[128],Q};function ot(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toFixed(1).replace(/\.0$/,"")}function it(s){return s>=90?"text-status-error":s>=75?"text-status-warning":"text-status-success"}function at(s){return r.jsx("p",{className:"typography-micro leading-tight",children:s},s)}const Wt=je.memo(function(e){const t=ne.c(40),{visible:o}=e,{t:n}=_e(),[i,a]=je.useState(!1);let c,x;if(t[0]!==o?(c=()=>{if(!o)return;let D=!1;Se("desktop_get_current_window_state").then(I=>{D||a(!!I?.maximized)}).catch(lt);const k=I=>{const $=I.detail;a(!!$?.maximized)};return window.addEventListener("openchamber:window-maximized-changed",k),()=>{D=!0,window.removeEventListener("openchamber:window-maximized-changed",k)}},x=[o],t[0]=o,t[1]=c,t[2]=x):(c=t[1],x=t[2]),Oe.useEffect(c,x),!o)return null;let f;t[3]!==n?(f=n("header.windowControls.groupAria"),t[3]=n,t[4]=f):f=t[4];let l;t[5]!==n?(l=n("header.windowControls.minimize"),t[5]=n,t[6]=l):l=t[6];let m;t[7]!==n?(m=n("header.windowControls.minimize"),t[7]=n,t[8]=m):m=t[8];let v;t[9]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(V,{name:"subtract",className:"h-4 w-4"}),t[9]=v):v=t[9];let b;t[10]!==l||t[11]!==m?(b=r.jsx("button",{type:"button",className:"app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:ct,title:l,"aria-label":m,children:v}),t[10]=l,t[11]=m,t[12]=b):b=t[12];let p;t[13]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{Se("desktop_toggle_current_window_maximized").then(D=>a(!!D?.maximized)).catch(dt)},t[13]=p):p=t[13];let w;t[14]!==i||t[15]!==n?(w=n(i?"header.windowControls.restore":"header.windowControls.maximize"),t[14]=i,t[15]=n,t[16]=w):w=t[16];let S;t[17]!==i||t[18]!==n?(S=n(i?"header.windowControls.restore":"header.windowControls.maximize"),t[17]=i,t[18]=n,t[19]=S):S=t[19];const h=i?"fullscreen-exit":"checkbox-blank";let j;t[20]!==h?(j=r.jsx(V,{name:h,className:"h-3.5 w-3.5"}),t[20]=h,t[21]=j):j=t[21];let N;t[22]!==S||t[23]!==j||t[24]!==w?(N=r.jsx("button",{type:"button",className:"app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:p,title:w,"aria-label":S,children:j}),t[22]=S,t[23]=j,t[24]=w,t[25]=N):N=t[25];let C;t[26]===Symbol.for("react.memo_cache_sentinel")?(C=q("app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","hover:bg-status-error hover:text-status-error-foreground"),t[26]=C):C=t[26];let d;t[27]!==n?(d=n("header.windowControls.close"),t[27]=n,t[28]=d):d=t[28];let _;t[29]!==n?(_=n("header.windowControls.close"),t[29]=n,t[30]=_):_=t[30];let y;t[31]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(V,{name:"close",className:"h-4 w-4"}),t[31]=y):y=t[31];let u;t[32]!==d||t[33]!==_?(u=r.jsx("button",{type:"button",className:C,onClick:ut,title:d,"aria-label":_,children:y}),t[32]=d,t[33]=_,t[34]=u):u=t[34];let g;return t[35]!==N||t[36]!==u||t[37]!==f||t[38]!==b?(g=r.jsxs("div",{className:"app-region-no-drag -mr-3 ml-2 flex h-12 shrink-0 items-center","aria-label":f,children:[b,N,u]}),t[35]=N,t[36]=u,t[37]=f,t[38]=b,t[39]=g):g=t[39],g});function lt(){}function ct(){Se("desktop_minimize_current_window")}function dt(){}function ut(){Se("desktop_close_current_window")}const Ee="oc.sessions.pinned",ft=s=>{try{const e=s.getItem(Ee);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(o=>typeof o=="string")):new Set}catch{return new Set}},Me=(s,e)=>{try{s.setItem(Ee,JSON.stringify([...e]))}catch{}},Ce=rt(),mt=Ue((s,e)=>({ids:ft(Ce),setIds:t=>{const o=e().ids,n=typeof t=="function"?t(o):t;n!==o&&(s({ids:n}),Me(Ce,n))},toggle:t=>{const o=e().ids,n=new Set(o);n.has(t)?n.delete(t):n.add(t),s({ids:n}),Me(Ce,n)}})),se=(s,e)=>Ke(Qe.getState().dictionary,s,e),ht=s=>{const e=new Date(s),t=new Date,o=(a,c)=>a.getFullYear()===c.getFullYear()&&a.getMonth()===c.getMonth()&&a.getDate()===c.getDate(),n=new Date(t);return n.setDate(t.getDate()-1),o(e,t)?se("common.date.today"):o(e,n)?se("common.date.yesterday"):e.toLocaleDateString(Re(),{month:"short",day:"numeric",year:"numeric"}).replace(",","")},Gt=s=>{const e=new Date,t=new Date(s);if(((n,i)=>n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate())(t,e)){const n=Date.now()-s;return n<6e4?se("common.relative.justNow"):n<36e5?se("common.relative.minutesAgoShort",{count:Math.floor(n/6e4)}):se("common.relative.hoursAgoShort",{count:Math.floor(n/36e5)})}return ht(s)},pt=s=>{const e=Math.max(0,Date.now()-s),t=6e4,o=60*t,n=24*o,i=7*n,a=30*n,c=365*n;return e<o?`${Math.max(1,Math.floor(e/t))}m`:e<n?`${Math.floor(e/o)}h`:e<i?se("common.relative.daysAgoCompact",{count:Math.floor(e/n)}):e<5*i?se("common.relative.weeksAgoCompact",{count:Math.floor(e/i)}):e<c?`${Math.floor(e/a)}mo`:se("common.relative.yearsAgoCompact",{count:Math.floor(e/c)})},ye=s=>{if(!s)return null;const e=s.replace(/\\/g,"/").replace(/\/+$/,"");return e.length===0?"/":e},gt=(s,e)=>{const t=ye(s),o=ye(e);return!t||!o?!1:t===o?!0:o==="/"?t.startsWith("/"):t.startsWith(`${o}/`)},$e=s=>s.toLowerCase().replace(/^opencode[/-]?/i,"").replace(/[-_]/g,"").trim(),Yt=(s,e)=>s?$e(s)!==$e(e):!1,Ie=s=>{if(typeof s=="number"&&Number.isFinite(s))return s;if(typeof s=="string"&&s.trim().length>0){const e=Number(s);if(Number.isFinite(e))return e}},Le=s=>Ie(s.time?.created)??0,ze=s=>Ie(s.time?.updated)??Ie(s.time?.created)??0,Te=(s,e,t)=>{const o=t.has(s.id),n=t.has(e.id);return o!==n?o?-1:1:o&&n?Le(e)-Le(s):ze(e)-ze(s)},Ht=s=>{const e=new Map;return s.forEach(t=>{e.set(t.id,t)}),Array.from(e.values())},Jt=s=>`__archived__:${s}`,Kt=(s,e)=>{const t=ye(s.directory??null),o=ye(s.project?.worktree??null),n=t??o;if(!n)return"unassigned";if(e&&n===e)return"project root";const a=(e&&n.startsWith(`${e}/`)?n.slice(e.length+1):n).split("/").filter(Boolean);return a[a.length-1]??"unassigned"},Qt=(s,e,t)=>{const o=ye(s.directory??null),n=ye(s.project?.worktree??null);return n&&(n===e||n.startsWith(`${e}/`))?!0:o?t&&t.has(o)?!0:o===e||o.startsWith(`${e}/`):!1},Rt=s=>s.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),Xt=(s,e)=>{if(!e)return s;const t=s.toLowerCase(),o=e.toLowerCase(),n=o.length;if(n===0)return s;const i=[];let a=0,c=t.indexOf(o,a);for(;c!==-1;){c>a&&i.push(s.slice(a,c));const x=s.slice(c,c+n);i.push(r.jsx("mark",{className:"bg-primary text-primary-foreground ring-1 ring-primary/90",children:x},`${c}-${x}`)),a=c+n,c=t.indexOf(o,a)}return a<s.length&&i.push(s.slice(a)),i.length>0?i:s},xt=7,bt=s=>{if(!s)return null;const e=s.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},wt=s=>{if(!s)return null;const e=s.label?.trim();if(e)return e;const t=s.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},yt=(s,e)=>{const t=ne.c(18);let o;t[0]!==e?(o=e===void 0?{}:e,t[0]=e,t[1]=o):o=t[1];const n=o,{scopeProjectId:i}=n,a=i===void 0?null:i,c=Xe(vt),x=qe(jt),f=mt(St),l=Ve();let m;t[2]!==x?(m=x.map(Nt).filter(_t),t[2]=x,t[3]=m):m=t[3];const v=m;let b;t[4]!==v?(b=h=>h?v.filter(N=>gt(h,N.normalizedPath)).sort(Dt)[0]??null:null,t[4]=v,t[5]=b):b=t[5];const p=b;let w;{let h;if(t[7]!==c||t[8]!==l||t[9]!==p||t[10]!==f||t[11]!==a){const j=new Map;for(const y of c){const u=y.parentID;if(!u||y.time?.archived)continue;const g=j.get(u);g?g.push(y):j.set(u,[y])}j.forEach(y=>{y.sort((u,g)=>Te(u,g,f))});let N;t[13]!==p||t[14]!==a?(N=y=>{if(!a)return!0;const u=ke(y);return p(u)?.id===a},t[13]=p,t[14]=a,t[15]=N):N=t[15];let C;t[16]!==f?(C=(y,u)=>Te(y,u,f),t[16]=f,t[17]=C):C=t[17];const d=c.filter(Ct).filter(kt).filter(N).sort(C).slice(0,xt),_=y=>{const u=j.get(y.id)??[];return{session:y,children:u.map(g=>_(g)),worktree:null}};h=d.map(y=>{const u=ke(y),g=p(u),D=wt(g),k=u?l.get(u)??null:null;return{node:_(y),projectId:g?.id??null,groupDirectory:u,secondaryMeta:{projectLabel:D,branchLabel:k&&k!==D?k:null}}}),t[7]=c,t[8]=l,t[9]=p,t[10]=f,t[11]=a,t[12]=h}else h=t[12];w=h}return w};function vt(s){return s.activeSessions}function jt(s){return s.projects}function St(s){return s.ids}function Nt(s){return{...s,normalizedPath:bt(s.path)}}function _t(s){return s.normalizedPath}function Dt(s,e){return(e.normalizedPath?.length??0)-(s.normalizedPath?.length??0)}function Ct(s){return!s.time?.archived}function kt(s){return!s.parentID}function qt(s){const e=ne.c(18),{children:t,variant:o,scopeProjectId:n,align:i}=s,a=o===void 0?"default":o,c=n===void 0?null:n,x=i===void 0?"start":i,f=Ne(It),l=Ne(Pt);let m;e[0]!==t?(m=r.jsx(Ze,{asChild:!0,children:t}),e[0]=t,e[1]=m):m=e[1];const v=a==="compact"?"w-[280px]":"w-[360px]";let b;e[2]!==v?(b=q("overflow-hidden p-1 max-w-[calc(100vw-32px)]",v),e[2]=v,e[3]=b):b=e[3];let p;e[4]!==f||e[5]!==c||e[6]!==l||e[7]!==a?(p=f?r.jsx(Mt,{onSelect:()=>l(!1),variant:a,scopeProjectId:c}):null,e[4]=f,e[5]=c,e[6]=l,e[7]=a,e[8]=p):p=e[8];let w;e[9]!==x||e[10]!==b||e[11]!==p?(w=r.jsx(et,{align:x,sideOffset:6,className:b,children:p}),e[9]=x,e[10]=b,e[11]=p,e[12]=w):w=e[12];let S;return e[13]!==f||e[14]!==l||e[15]!==m||e[16]!==w?(S=r.jsxs(tt,{open:f,onOpenChange:l,modal:!1,children:[m,w]}),e[13]=f,e[14]=l,e[15]=m,e[16]=w,e[17]=S):S=e[17],S}function Pt(s){return s.setSessionDropdownOpen}function It(s){return s.isSessionDropdownOpen}function Mt(s){const e=ne.c(26),{onSelect:t,variant:o,scopeProjectId:n}=s;let i;e[0]!==n?(i={scopeProjectId:n},e[0]=n,e[1]=i):i=e[1];const a=yt(!0,i),c=Pe(Lt),x=Ne($t),{t:f}=_e();let l;e[2]!==t||e[3]!==c||e[4]!==x?(l=()=>{x("chat"),t(),c()},e[2]=t,e[3]=c,e[4]=x,e[5]=l):l=e[5];const m=l;let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=new Set,e[6]=v):v=e[6];const[b,p]=je.useState(v);let w;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=u=>{p(g=>{const D=new Set(g);return D.has(u)?D.delete(u):D.add(u),D})},e[7]=w):w=e[7];const S=w;let h,j;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=q("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),j=r.jsx(V,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e[8]=h,e[9]=j):(h=e[8],j=e[9]);let N;e[10]!==f?(N=f("sessions.sidebar.header.actions.newSession"),e[10]=f,e[11]=N):N=e[11];let C;e[12]!==N?(C=r.jsx("span",{className:"truncate text-[14px] font-normal leading-tight text-foreground",children:N}),e[12]=N,e[13]=C):C=e[13];let d;e[14]!==m||e[15]!==C?(d=r.jsxs(Ae,{onClick:m,className:h,children:[j,C]}),e[14]=m,e[15]=C,e[16]=d):d=e[16];let _;e[17]!==b||e[18]!==a||e[19]!==t||e[20]!==f||e[21]!==o?(_=a.length===0?r.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:f("sessions.switcher.empty")}):a.map(u=>r.jsx(Fe,{item:u,depth:0,variant:o,expandedParents:b,toggleParent:S,closeDropdown:t},u.node.session.id)),e[17]=b,e[18]=a,e[19]=t,e[20]=f,e[21]=o,e[22]=_):_=e[22];let y;return e[23]!==_||e[24]!==d?(y=r.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:r.jsxs("div",{className:"space-y-0.5",children:[d,_]})}),e[23]=_,e[24]=d,e[25]=y):y=e[25],y}function $t(s){return s.setActiveMainTab}function Lt(s){return s.openNewSessionDraft}function Fe(s){const e=ne.c(31),{item:t,depth:o,variant:n,expandedParents:i,toggleParent:a,closeDropdown:c}=s,{node:x,secondaryMeta:f}=t,l=x.session,m=x.children.length>0;let v;e[0]!==i||e[1]!==l.id?(v=i.has(l.id),e[0]=i,e[1]=l.id,e[2]=v):v=e[2];const b=v;let p;e[3]!==m||e[4]!==l.id||e[5]!==a?(p=m?()=>a(l.id):void 0,e[3]=m,e[4]=l.id,e[5]=a,e[6]=p):p=e[6];let w;e[7]!==c||e[8]!==o||e[9]!==m||e[10]!==b||e[11]!==f||e[12]!==l||e[13]!==p||e[14]!==n?(w=r.jsx(zt,{session:l,depth:o,variant:n,secondaryMeta:f,hasChildren:m,isExpanded:b,onToggleExpand:p,closeDropdown:c}),e[7]=c,e[8]=o,e[9]=m,e[10]=b,e[11]=f,e[12]=l,e[13]=p,e[14]=n,e[15]=w):w=e[15];let S;e[16]!==c||e[17]!==o||e[18]!==i||e[19]!==m||e[20]!==b||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==x.children||e[24]!==f||e[25]!==a||e[26]!==n?(S=m&&b?x.children.map(j=>r.jsx(Fe,{item:{node:j,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:f},depth:o+1,variant:n,expandedParents:i,toggleParent:a,closeDropdown:c},j.session.id)):null,e[16]=c,e[17]=o,e[18]=i,e[19]=m,e[20]=b,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=x.children,e[24]=f,e[25]=a,e[26]=n,e[27]=S):S=e[27];let h;return e[28]!==w||e[29]!==S?(h=r.jsxs(r.Fragment,{children:[w,S]}),e[28]=w,e[29]=S,e[30]=h):h=e[30],h}function zt(s){const e=ne.c(57),{session:t,depth:o,variant:n,secondaryMeta:i,hasChildren:a,isExpanded:c,onToggleExpand:x,closeDropdown:f}=s,{t:l}=_e(),m=Pe(Et),v=Pe(At),b=Ne(Tt),p=st(t.id),w=nt(t.id),S=m===t.id;let h;e[0]!==t.title||e[1]!==l?(h=t.title?.trim()||l("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=l,e[2]=h):h=e[2];const j=h,N=!!t.parentID,C=w>0&&(!N||b),d=p?.type??"idle",_=d==="busy"||d==="retry",y=!_&&C&&!S;let u;e[3]!==t.time?.created||e[4]!==t.time?.updated?(u=t.time?.updated||t.time?.created||Date.now(),e[3]=t.time?.created,e[4]=t.time?.updated,e[5]=u):u=e[5];const g=u;let D;e[6]!==g?(D=pt(g),e[6]=g,e[7]=D):D=e[7];const k=D;let I;e[8]!==i?.projectLabel?(I=i?.projectLabel?.trim()||null,e[8]=i?.projectLabel,e[9]=I):I=e[9];const $=I;let W;e[10]!==i?.branchLabel?(W=i?.branchLabel?.trim()||null,e[10]=i?.branchLabel,e[11]=W):W=e[11];const B=W,G=B&&B!=="HEAD"?B:null;let Y;e[12]!==f||e[13]!==S||e[14]!==t||e[15]!==v?(Y=()=>{if(S){f();return}const P=ke(t);v(t.id,P??null),f()},e[12]=f,e[13]=S,e[14]=t,e[15]=v,e[16]=Y):Y=e[16];const Z=Y;let H;e[17]!==Z?(H=P=>{if(P.target?.closest("[data-switcher-expand]")){P.preventDefault();return}Z()},e[17]=Z,e[18]=H):H=e[18];let ee;e[19]===Symbol.for("react.memo_cache_sentinel")?(ee=q("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),e[19]=ee):ee=e[19];const te=8+o*12;let J;e[20]!==te?(J={paddingLeft:te},e[20]=te,e[21]=J):J=e[21];let K;e[22]!==a||e[23]!==c||e[24]!==x||e[25]!==l||e[26]!==n?(K=n==="compact"&&a?r.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:P=>{P.preventDefault(),P.stopPropagation(),x?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?r.jsx(V,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):r.jsx(V,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[22]=a,e[23]=c,e[24]=x,e[25]=l,e[26]=n,e[27]=K):K=e[27];const X=S?"text-primary":"text-foreground";let A;e[28]!==X?(A=q("truncate text-[14px] font-normal leading-tight",X),e[28]=X,e[29]=A):A=e[29];let E;e[30]!==j||e[31]!==A?(E=r.jsx("span",{className:A,children:j}),e[30]=j,e[31]=A,e[32]=E):E=e[32];let Q;e[33]!==K||e[34]!==E?(Q=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[K,E]}),e[33]=K,e[34]=E,e[35]=Q):Q=e[35];let z;e[36]!==G||e[37]!==a||e[38]!==c||e[39]!==x||e[40]!==$||e[41]!==l||e[42]!==k||e[43]!==n?(z=n==="default"?r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:[a?r.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:P=>{P.preventDefault(),P.stopPropagation(),x?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?r.jsx(V,{name:"arrow-down-s",className:"h-3 w-3"}):r.jsx(V,{name:"arrow-right-s",className:"h-3 w-3"})}):null,r.jsx("span",{className:"flex-shrink-0",children:k}),$?r.jsx("span",{className:"truncate",children:$}):null,G?r.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[r.jsx(V,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),r.jsx("span",{className:"truncate",children:G})]}):null]}):null,e[36]=G,e[37]=a,e[38]=c,e[39]=x,e[40]=$,e[41]=l,e[42]=k,e[43]=n,e[44]=z):z=e[44];let M;e[45]!==Q||e[46]!==z?(M=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[Q,z]}),e[45]=Q,e[46]=z,e[47]=M):M=e[47];let L;e[48]!==_||e[49]!==y||e[50]!==l?(L=_||y?r.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:_?r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":l("sessions.sidebar.session.status.active"),title:l("sessions.sidebar.session.status.active")}):r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":l("sessions.sidebar.session.status.unread"),title:l("sessions.sidebar.session.status.unread")})}):null,e[48]=_,e[49]=y,e[50]=l,e[51]=L):L=e[51];let T;return e[52]!==J||e[53]!==M||e[54]!==L||e[55]!==H?(T=r.jsxs(Ae,{onClick:H,"data-slot":"session-switcher-item",className:ee,style:J,children:[M,L]}),e[52]=J,e[53]=M,e[54]=L,e[55]=H,e[56]=T):T=e[56],T}function Tt(s){return s.notifyOnSubtasks}function At(s){return s.setCurrentSession}function Et(s){return s.currentSessionId}export{Bt as C,qt as S,Wt as W,$e as a,Yt as b,Te as c,Ht as d,Xt as e,Rt as f,Jt as g,Gt as h,Qt as i,pt as j,ye as n,Kt as r,mt as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as x,R as y,j as t,bl as j,bj as w,bk as k,bh as v,bf as D}from"./vendor-.bun-BE757pvp.js";import{c as R,v as u}from"./useAppFontEffects-DzBg8hrC.js";import{k as S}from"./runtimeEndpointReset-C42u8PvG.js";import"./index-ltrmNGAf.js";import"./mobileLayoutPreference-Dio-WWkI.js";const B=b=>{const e=x.c(19),{open:m,onOpenChange:n}=b,{t:f}=R(),s=y.useId(),h=_;let a;e[0]!==n?(a=g=>{!g&&h()||n(g)},e[0]=n,e[1]=a):a=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(j,{className:u("fixed inset-0 z-50 bg-black/50 dark:bg-black/75","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),e[2]=d):d=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=u("relative pointer-events-auto","w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]","rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]","data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]"),e[3]=c):c=e[3];let o;e[4]!==f?(o=f("settings.window.description"),e[4]=f,e[5]=o):o=e[5];let i;e[6]!==s||e[7]!==o?(i=t.jsx(w,{id:s,className:"sr-only",children:o}),e[6]=s,e[7]=o,e[8]=i):i=e[8];let l;e[9]!==n?(l=t.jsx(S,{onClose:()=>n(!1),isWindowed:!0}),e[9]=n,e[10]=l):l=e[10];let r;e[11]!==s||e[12]!==i||e[13]!==l?(r=t.jsxs(k,{children:[d,t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:t.jsxs(v,{"aria-describedby":s,className:c,children:[i,l]})})]}),e[11]=s,e[12]=i,e[13]=l,e[14]=r):r=e[14];let p;return e[15]!==m||e[16]!==a||e[17]!==r?(p=t.jsx(D,{open:m,onOpenChange:a,children:r}),e[15]=m,e[16]=a,e[17]=r,e[18]=p):p=e[18],p};function _(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{B as SettingsWindow};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{R as n,j as f,i as vt,cl as xt,cm as Tt,cn as kt}from"./vendor-.bun-C6iL44L9.js";import{c as bt,w as Ct,eJ as Et,p as et,d as Rt,x as St,U as At,aC as It,D as ht,e as Bt,I as fe,B as oe}from"./useAppFontEffects-BUUJYbAZ.js";import{u as q}from"./main-BDoqLlQB.js";import{h as Mt,u as Me,bT as Pt,bS as it,ae as pt}from"./index-ZJTzZ0_U.js";import{w as Dt,x as Nt}from"./runtimeEndpointReset-By39StyB.js";import"./SessionSwitcherDropdown-4FWg9xMC.js";import"./mobileLayoutPreference-Dio-WWkI.js";function jt(u){const{colors:l}=u,d=l.syntax.base;return{background:l.surface.background,foreground:d.foreground,cursor:l.interactive.cursor,cursorAccent:l.surface.background,selectionBackground:l.interactive.selection,selectionForeground:l.interactive.selectionForeground,selectionInactiveBackground:l.interactive.selection+"50",black:l.surface.muted,red:l.status.error,green:l.status.success,yellow:l.status.warning,blue:d.function,magenta:d.keyword,cyan:d.type,white:d.foreground,brightBlack:d.comment,brightRed:l.status.error,brightGreen:l.status.success,brightYellow:l.status.warning,brightBlue:d.function,brightMagenta:d.keyword,brightCyan:d.type,brightWhite:l.surface.elevatedForeground}}function Vt(u,l,d,I,E=!1){const _=`${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:l,lineHeight:1.15,fontFamily:_,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:I,disableStdin:E}}let mt=null;function Lt(){return mt||(mt=kt.load()),mt}function Ft(u){if(typeof window>"u")return null;const l=[u,...Array.from(u.querySelectorAll("*"))];let d=null;for(const I of l){const X=window.getComputedStyle(I).overflowY;if(!(X!=="auto"&&X!=="scroll")){if(I.scrollHeight-I.clientHeight>2)return I;d||(d=I)}}return d}const gt=n.forwardRef(({sessionKey:u,chunks:l,onInput:d,onResize:I,theme:E,fontFamily:X,fontSize:_,className:ye,enableTouchScroll:R,autoFocus:at=!0,isVisible:Ne=!0},Se)=>{const{t:J}=bt(),O=n.useRef(null),je=n.useRef(null),B=n.useRef(null),tt=n.useRef(null),K=n.useRef(d),Ue=n.useRef(I),v=n.useRef(null),Ae=n.useRef(""),se=n.useRef(null),Ve=n.useRef(!1),Le=n.useRef(null),be=n.useRef(!0),ie=n.useRef(null),Q=n.useRef(null),Ie=n.useRef(0),ae=n.useRef(null),We=n.useRef(null),de=n.useRef(!1),ee=n.useRef(!1),ge=n.useRef(null),V=n.useRef(null),D=n.useRef(null),he=n.useRef(""),Fe=n.useRef(null),L=n.useRef(!R),nt=n.useRef(Ne),[,dt]=n.useReducer(e=>e+1,0),[rt,ct]=n.useReducer(e=>e+1,0);K.current=d,Ue.current=I;const lt=typeof navigator<"u"&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform==="Android"),b=!!R;n.useEffect(()=>{if(!R){L.current=!0,nt.current=Ne;return}!nt.current&&Ne&&(L.current=!1),nt.current=Ne},[R,Ne]);const ot=n.useCallback(()=>{if(!b)return;const e=O.current,c=ae.current;if(!e)return;const a=[];e.getAttribute("contenteditable")==="true"&&a.push(e),a.push(...Array.from(e.querySelectorAll('[contenteditable="true"]'))),a.forEach(s=>{s.setAttribute("data-terminal-disabled-contenteditable","true"),s.setAttribute("contenteditable","false"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.style.setProperty("caret-color","transparent"),s.style.color="transparent",s.style.setProperty("-webkit-text-fill-color","transparent"),s.style.background="transparent",s.style.outline="none",s.style.boxShadow="none",s.style.textShadow="none",s.style.setProperty("user-select","none"),s.style.setProperty("-webkit-user-select","none")}),e.tabIndex=-1,e.removeAttribute("role"),e.removeAttribute("aria-multiline"),Array.from(e.querySelectorAll("textarea")).forEach(s=>{s.style.setProperty("caret-color","transparent"),s.style.color="transparent",s.style.setProperty("-webkit-text-fill-color","transparent"),s.style.background="transparent",s.style.border="0",s.style.outline="none",s.style.boxShadow="none",s.style.textShadow="none",s.style.fontSize="0",s.style.lineHeight="0",s!==c&&s.getAttribute("data-terminal-disabled-input")!=="true"&&(s.setAttribute("data-terminal-disabled-input","true"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.disabled=!0,s.style.position="absolute",s.style.opacity="0",s.style.width="0px",s.style.height="0px",s.style.pointerEvents="none",s.style.zIndex="-1")})},[b]),A=n.useCallback(e=>{if(Fe.current===e)return;const c=B.current;if(c)try{if(typeof c.setOption=="function"){c.setOption("cursorBlink",e),Fe.current=e;return}c.options&&(c.options.cursorBlink=e,Fe.current=e)}catch{}},[]),pe=b&<,S=n.useCallback((e,c)=>{const a=pe?We.current:ae.current,w=O.current;if(!a||!w)return;const s=w.getBoundingClientRect(),T=typeof window<"u"?window.innerWidth:s.width,h=typeof window<"u"?window.innerHeight:s.height,te=s.left+s.width/2,M=s.top+s.height-12,o=typeof e=="number"?e:te,P=typeof c=="number"?c:M,Y=8,me=Math.max(Y,Math.min(T-Y,o)),$=Math.max(Y,Math.min(h-Y,P));a.style.left=`${me}px`,a.style.top=`${$}px`,a.style.bottom="",(a instanceof HTMLTextAreaElement||a instanceof HTMLInputElement)&&(a.disabled=!1,a.readOnly=!1,a.removeAttribute("disabled"),a.removeAttribute("readonly"));try{a.focus({preventScroll:!0})}catch{try{a.focus()}catch{}}},[pe]),F=n.useCallback(()=>{if(b){S(),A(!0);return}B.current?.focus(),A(!0)},[S,A,b]),N=n.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??"",[]),U=n.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value="";return}e.textContent=""},[]),Ye=n.useCallback(e=>{if(typeof window>"u"||pe)return;D.current!==null&&(window.clearTimeout(D.current),D.current=null);let c=0;const a=3,w=()=>{D.current=window.setTimeout(()=>{D.current=null;const s=N(e);if(!s){if(c+=1,c<a){w();return}return}const T=he.current;he.current=s;const h=s.startsWith(T)?s.slice(T.length):s;h&&K.current(h.replace(/\r\n|\r|\n/g,"\r")),U(e),he.current=""},c===0?0:24)};w()},[U,N,pe]);n.useEffect(()=>{const e=O.current;if(!b||!e||R)return;const c=a=>{const w=a.target;if(w&&w.getAttribute("data-terminal-hidden-input")!=="true"&&e.contains(w)){try{w.blur()}catch{}S()}};return e.addEventListener("focusin",c,!0),()=>{e.removeEventListener("focusin",c,!0)}},[R,b,S]);const qe=n.useCallback(()=>{const e=B.current;if(!e||typeof e.getSelection!="function")return"";const c=e.getSelection();return typeof c=="string"?c:""},[]),Xe=n.useCallback(()=>{if(typeof window>"u")return"";const e=window.getSelection();if(!e)return"";const c=e.toString();if(!c.trim())return"";const a=O.current;if(!a)return"";const w=e.anchorNode,s=e.focusNode;return w&&!a.contains(w)||s&&!a.contains(s)?"":c},[]),ve=n.useCallback(async()=>{if(typeof document>"u")return;const e=qe()||Xe();e.trim()&&await Ct(e)},[Xe,qe]),Z=n.useCallback(()=>qe().trim()?!0:!!Xe().trim(),[Xe,qe]);n.useEffect(()=>{if(typeof window>"u")return;const e=c=>{Z()&&(c.preventDefault(),ve())};return window.addEventListener("openchamber:copy",e),()=>{window.removeEventListener("openchamber:copy",e)}},[ve,Z]);const ce=n.useCallback(()=>{Ae.current="",se.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(se.current),se.current=null,Ve.current=!1,Le.current=null},[]),H=n.useCallback(()=>{const e=tt.current,c=B.current,a=O.current;if(!e||!c||!a)return;const w=a.getBoundingClientRect();if(!(w.width<24||w.height<24))try{e.fit();const s={cols:c.cols,rows:c.rows},T=v.current;(!T||T.cols!==s.cols||T.rows!==s.rows)&&(v.current=s,Ue.current(s.cols,s.rows))}catch{}},[]),xe=n.useCallback(()=>{if(Ve.current)return;const e=B.current;if(!e){ce();return}if(!Ae.current)return;const c=Ae.current;Ae.current="",Ve.current=!0,e.write(c,()=>{Ve.current=!1,Ae.current&&(typeof window<"u"?se.current=window.requestAnimationFrame(()=>{se.current=null,xe()}):xe())})},[ce]),Pe=n.useCallback(()=>{se.current===null&&(typeof window<"u"?se.current=window.requestAnimationFrame(()=>{se.current=null,xe()}):xe())},[xe]),$e=n.useCallback(e=>{e&&(Ae.current+=e,Pe())},[Pe]),De=n.useCallback(()=>{if(ie.current?.(),ie.current=null,Q.current!==null&&typeof window<"u"&&(window.clearTimeout(Q.current),Q.current=null),!R){Ie.current=0;return}const e=O.current;if(!e)return;const c=B.current;if(!c)return;Ie.current=0;const a=2.2,w=2.8,s=25,T=.25,h=8,te=.05,M=.015,o={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},P=()=>typeof performance<"u"?performance.now():Date.now(),Y=Math.max(12,Math.round(_*1.35));let me=0;const $=i=>{if(!i)return!1;const W=c.getViewportY(),re=me+i,le=Math.trunc(re/Y);return me=re-le*Y,le!==0&&c.scrollLines(le),c.getViewportY()!==W},ke=()=>{o.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.rafId),o.rafId=null},k={passive:!1,capture:!1};if(typeof window<"u"&&"PointerEvent"in window){const i=Object.assign(o,{pointerId:null,startX:null,startY:null,moved:!1}),W=6,re=r=>{if(r.pointerType==="touch"){ke(),i.pointerId=r.pointerId,i.startX=r.clientX,i.startY=r.clientY,i.moved=!1,i.lastY=r.clientY,i.lastTime=P(),i.velocity=0;try{e.setPointerCapture(r.pointerId)}catch{}}},le=r=>{if(r.pointerType!=="touch"||i.pointerId!==r.pointerId)return;if(i.startX!==null&&i.startY!==null&&!i.moved){const ut=r.clientX-i.startX,ze=r.clientY-i.startY;Math.hypot(ut,ze)>=W&&(i.moved=!0)}if(i.lastY===null){i.lastY=r.clientY,i.lastTime=P();return}const g=i.lastY,m=i.lastTime??P(),x=P();i.lastY=r.clientY,i.lastTime=x;const y=g-r.clientY;if(Math.abs(y)<1)return;const G=Math.max(x-m,8),Ee=a+Math.min(w,Math.abs(y)/s),we=y*Ee,Re=we/G;i.velocity=i.velocity*(1-T)+Re*T,i.velocity>h?i.velocity=h:i.velocity<-h&&(i.velocity=-h),i.moved&&(r.cancelable&&r.preventDefault(),r.stopPropagation()),$(we)},ue=r=>{if(r.pointerType!=="touch"||i.pointerId!==r.pointerId)return;const g=!i.moved;i.pointerId=null,i.startX=null,i.startY=null,i.moved=!1,i.lastY=null,i.lastTime=null;try{e.releasePointerCapture(r.pointerId)}catch{}if(g){b?S(r.clientX,r.clientY):R&&!L.current&&(L.current=!0,B.current?.focus());return}if(typeof window>"u")return;if(Math.abs(i.velocity)<te){i.velocity=0;return}let m=P();const x=()=>{const y=P(),G=Math.max(y-m,8);m=y;const Ee=$(i.velocity*G)??!1,we=Math.sign(i.velocity),Re=Math.max(0,Math.abs(i.velocity)-M*G);if(i.velocity=Re*we,!Ee||Re<=te){ke(),i.velocity=0;return}i.rafId=window.requestAnimationFrame(x)};i.rafId=window.requestAnimationFrame(x)};e.addEventListener("pointerdown",re,k),e.addEventListener("pointermove",le,k),e.addEventListener("pointerup",ue,k),e.addEventListener("pointercancel",ue,k);const t=e.style.touchAction,p=e.style.overscrollBehaviorY;e.style.touchAction="none",e.style.overscrollBehaviorY="contain",ie.current=()=>{ke(),Q.current!==null&&typeof window<"u"&&(window.clearTimeout(Q.current),Q.current=null),Ie.current=0,e.removeEventListener("pointerdown",re,k),e.removeEventListener("pointermove",le,k),e.removeEventListener("pointerup",ue,k),e.removeEventListener("pointercancel",ue,k),e.style.touchAction=t,e.style.overscrollBehaviorY=p};return}const C=6,Ce=i=>{i.touches.length===1&&(ke(),o.lastY=i.touches[0].clientY,o.lastTime=P(),o.velocity=0,o.startX=i.touches[0].clientX,o.startY=i.touches[0].clientY,o.didMove=!1)},Be=i=>{if(i.touches.length!==1){o.lastY=null,o.lastTime=null,o.velocity=0,o.startX=null,o.startY=null,o.didMove=!1,ke();return}const W=i.touches[0].clientX,re=i.touches[0].clientY;if(o.startX!==null&&o.startY!==null&&!o.didMove){const y=W-o.startX,G=re-o.startY;Math.hypot(y,G)>=C&&(o.didMove=!0)}if(o.lastY===null){o.lastY=re,o.lastTime=P();return}const le=o.lastY,ue=o.lastTime??P(),t=P();o.lastY=re,o.lastTime=t;const p=le-re;if(Math.abs(p)<1)return;const r=Math.max(t-ue,8),g=a+Math.min(w,Math.abs(p)/s),m=p*g,x=m/r;o.velocity=o.velocity*(1-T)+x*T,o.velocity>h?o.velocity=h:o.velocity<-h&&(o.velocity=-h),o.didMove&&(i.preventDefault(),i.stopPropagation()),$(m)},z=i=>{const W=!o.didMove;o.lastY=null,o.lastTime=null;const re=o.velocity;if(o.startX=null,o.startY=null,o.didMove=!1,W){const t=i.changedTouches?.[0];b?S(t?.clientX,t?.clientY):R&&!L.current&&(L.current=!0,B.current?.focus());return}if(typeof window>"u")return;if(Math.abs(re)<te){o.velocity=0;return}let le=P();const ue=()=>{const t=P(),p=Math.max(t-le,8);le=t;const r=$(o.velocity*p)??!1,g=Math.sign(o.velocity),m=Math.max(0,Math.abs(o.velocity)-M*p);if(o.velocity=m*g,!r||m<=te){ke(),o.velocity=0;return}o.rafId=window.requestAnimationFrame(ue)};o.rafId=window.requestAnimationFrame(ue)};e.addEventListener("touchstart",Ce,k),e.addEventListener("touchmove",Be,k),e.addEventListener("touchend",z,k),e.addEventListener("touchcancel",z,k);const Qe=e.style.touchAction,j=e.style.overscrollBehaviorY;e.style.touchAction="none",e.style.overscrollBehaviorY="contain",ie.current=()=>{ke(),Q.current!==null&&typeof window<"u"&&(window.clearTimeout(Q.current),Q.current=null),Ie.current=0,e.removeEventListener("touchstart",Ce,k),e.removeEventListener("touchmove",Be,k),e.removeEventListener("touchend",z,k),e.removeEventListener("touchcancel",z,k),e.style.touchAction=Qe,e.style.overscrollBehaviorY=j}},[R,b,S,_]);n.useEffect(()=>{let e=!1,c=null,a=null,w=null,s=[],T=null,h=null,te=null;const M=O.current;if(!M)return;if(M.tabIndex=b?-1:0,b){const k=M.focus.bind(M),ne=M;ne.focus=((...C)=>{S()}),te=()=>{ne.focus=k}}const o=()=>{A(!0)},P=()=>{A(!1)},Y=k=>{const ne=k.target;if(ne&&M.contains(ne)){if(b&&ne instanceof HTMLElement){window.setTimeout(()=>{ne.blur(),S()},0),A(!1);return}if(R&&!L.current&&ne instanceof HTMLElement){window.setTimeout(()=>{ne.blur()},0),A(!1);return}A(!0);return}A(!1)},me=()=>{A(!1)};let $=null;return(async()=>{try{const k=await Lt();if(e)return;const ne=Vt(X,_,E,k,!1),C=new xt(ne);be.current=!0,b&&(C.focus=()=>{});const Ce=C;if(typeof Ce.scrollToBottom=="function"){const j=Ce.scrollToBottom.bind(Ce);Ce.scrollToBottom=()=>{be.current&&j()},T=()=>{Ce.scrollToBottom=j}}const Be=new Tt;if(c=C,B.current=C,tt.current=Be,C.loadAddon(Be),C.open(M),R){const j=C.renderer;if(j&&typeof j.renderScrollbar=="function"){const i=j.renderScrollbar.bind(j);j.renderScrollbar=()=>{},h=()=>{j.renderScrollbar=i}}}ct(),Fe.current=!1,$=C.textarea??M.querySelector("textarea"),$&&($.addEventListener("focus",o),$.addEventListener("blur",P)),ot(),typeof MutationObserver<"u"&&(w=new MutationObserver(()=>{ot()}),w.observe(M,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["contenteditable","role","tabindex","aria-label"]}));const z=Ft(M);z?(z.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),je.current=z,dt()):je.current=null,H();const Qe=Be;typeof Qe.observeResize=="function"&&Qe.observeResize(),De(),s=[C.onData(j=>{K.current(j)}),C.onScroll(j=>{if(typeof j=="number"&&Number.isFinite(j)){const i=typeof C.hasSelection=="function"&&C.hasSelection();be.current=!i&&j<=.5}}),C.onSelectionChange(()=>{if(typeof C.hasSelection=="function"&&C.hasSelection()){be.current=!1;return}const i=typeof C.getViewportY=="function"?C.getViewportY():0;be.current=i<=.5})],a=new ResizeObserver(()=>{H()}),a.observe(M),typeof window<"u"&&window.setTimeout(()=>{H()},0)}catch{}})(),document.addEventListener("focusin",Y,!0),window.addEventListener("blur",me),()=>{e=!0,ie.current?.(),ie.current=null,document.removeEventListener("focusin",Y,!0),window.removeEventListener("blur",me),s.forEach(k=>k.dispose()),T?.(),T=null,h?.(),h=null,$&&($.removeEventListener("focus",o),$.removeEventListener("blur",P)),a?.disconnect(),w?.disconnect(),te?.(),c?.dispose(),B.current=null,tt.current=null,je.current=null,v.current=null,Fe.current=null,ce()}},[ot,R,H,S,X,_,De,E,ce,A,b]),n.useEffect(()=>{const e=B.current;e&&(e.reset(),ce(),v.current=null,H())},[u,rt,H,ce]),n.useEffect(()=>{!at||!B.current||F()},[at,F,u,rt]),n.useEffect(()=>(De(),()=>{ie.current?.(),ie.current=null}),[De,u]),n.useEffect(()=>{const e=B.current;if(!e)return;if(l.length===0){Le.current!==null&&(e.reset(),ce(),H());return}const c=Le.current;let a;if(c===null)a=l;else{const w=l.findIndex(s=>s.id===c);a=w>=0?l.slice(w+1):l}a.length>0&&$e(a.map(w=>w.data).join("")),Le.current=l[l.length-1].id},[l,rt,$e,H,ce]),n.useImperativeHandle(Se,()=>({focus:()=>{F()},clear:()=>{const e=B.current;e&&(e.reset(),ce(),H())},fit:()=>{H()}}),[F,H,ce]);const Ge=n.useCallback(e=>{if(!b)return;const c=O.current,a=e.relatedTarget,w=a?.tagName,s=w==="INPUT"||w==="TEXTAREA"||a?.isContentEditable,T=a?.getAttribute("data-terminal-hidden-input")==="true",h=!!(a&&c?.contains(a))},[b]),Oe=n.useCallback(e=>{const c=e.nativeEvent,a=c?.inputType??"",w=typeof c?.data=="string"?c.data:"";if(V.current=typeof performance<"u"?performance.now():Date.now(),a==="insertCompositionText"){de.current=!0;return}if(!a&&w){if(de.current)return;e.preventDefault(),K.current(w),ge.current={type:"insertText",at:typeof performance<"u"?performance.now():Date.now()},ee.current=!0;return}if(a==="insertText"&&w){if(de.current)return;e.preventDefault(),K.current(w),ge.current={type:a,at:typeof performance<"u"?performance.now():Date.now()},ee.current=!0;return}if(a==="insertLineBreak"){if(de.current)return;e.preventDefault(),K.current("\r"),ge.current={type:a,at:typeof performance<"u"?performance.now():Date.now()},ee.current=!0;return}if(a==="deleteContentBackward"){if(de.current)return;e.preventDefault(),K.current(""),ge.current={type:a,at:typeof performance<"u"?performance.now():Date.now()},ee.current=!0}},[]),st=n.useCallback(e=>{const c=e.currentTarget;if(V.current=typeof performance<"u"?performance.now():Date.now(),de.current)return;if(ee.current){const s=ge.current,T=typeof performance<"u"?performance.now():Date.now();if(s&&T-s.at<50){ee.current=!1,U(c);return}ee.current=!1}const a=N(c);if(!a)return;he.current=a;const w=a.replace(/\r\n|\r|\n/g,"\r");K.current(w),U(c),he.current=""},[U,N]),_e=n.useCallback(e=>{e.stopPropagation();const c=e.key.toLowerCase(),a=e.metaKey&&!e.ctrlKey&&!e.altKey&&c==="c",w=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&c==="c";if((a||w)&&Z()){e.preventDefault(),ve();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){const Y=e.key.toUpperCase();if(Y>="A"&&Y<="Z"){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),K.current(String.fromCharCode(Y.charCodeAt(0)-64)),U(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),K.current("\x1B"+e.key),U(e.currentTarget);return}const T={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(T){e.preventDefault(),K.current(T),U(e.currentTarget);return}const h=e.currentTarget;if(e.nativeEvent?.isComposing)return;const M=ge.current,o=typeof performance<"u"?performance.now():Date.now(),P=!!(M&&o-M.at<50);if(e.key==="Enter"){if(P&&M?.type==="insertLineBreak")return;e.preventDefault(),K.current("\r"),U(h);return}if(e.key==="Backspace"){if(e.preventDefault(),P&&M?.type==="deleteContentBackward")return;N(h)||K.current("")}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const Y=V.current;Y&&o-Y<50||(e.preventDefault(),K.current(e.key),ee.current=!0,ge.current={type:"keydown-text",at:o})}Ye(h)},[U,ve,Z,N,Ye]),Ke=n.useCallback(e=>{e.stopPropagation();const c=e.currentTarget;e.nativeEvent?.isComposing||Ye(c)},[Ye]),Je=n.useCallback(e=>{const c=e.currentTarget;de.current=!1;const a=e.data||N(c);if(V.current=typeof performance<"u"?performance.now():Date.now(),!a)return;const w=a.replace(/\r\n|\r|\n/g,"\r");K.current(w),U(c),ge.current={type:"compositionend",at:typeof performance<"u"?performance.now():Date.now()},ee.current=!0},[U,N]),He=n.useCallback(e=>{e.stopPropagation();const c=e.clipboardData?.getData("text")??"";if(!c)return;e.preventDefault();const w=B.current?.hasBracketedPaste?.()?`\x1B[200~${c}\x1B[201~`:c;K.current(w)},[]),Te={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:et("relative h-full w-full terminal-viewport-container",ye),"data-hidden-input-overlay-active":b?"true":void 0,style:{backgroundColor:E.background},onTouchStart:e=>{if(!(!b||R)&&!Z()){const c=e.touches?.[0];S(c?.clientX,c?.clientY)}},onClick:e=>{if(!R)if(b){if(Z())return;S(e.clientX,e.clientY)}else B.current?.focus()},onMouseUp:()=>{!R&&Z()&&ve()},onTouchEnd:()=>{!R&&Z()&&ve()},children:[b&&typeof document<"u"?vt.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":J("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...Te,display:pe?"block":"none"},onBlur:Ge,onBeforeInput:Oe,onCompositionStart:()=>{de.current=!0},onInput:st,onKeyDown:_e,onKeyUp:Ke,onCompositionEnd:Je,onPaste:He}),f.jsx("textarea",{ref:ae,inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":J("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...Te,display:pe?"none":"block"},onBlur:Ge,onBeforeInput:Oe,onCompositionStart:()=>{de.current=!0},onInput:st,onKeyDown:_e,onKeyUp:Ke,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 Yt="\x1B",Ot=new RegExp(`${Yt}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Kt=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,Ht=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,zt=/Serving HTTP on .*? port (\d{2,5})/i,Ut=new Set([".",",",";",":","!","?"]),Wt=u=>{let l=u;for(;l.length>0;){const d=l[l.length-1];if(d===")"||d==="]"||d==="}"||d===">"){const I=d===")"?"(":d==="]"?"[":d==="}"?"{":"<",E=l.slice(0,-1),X=(E.match(new RegExp(`\\${I}`,"g"))||[]).length,_=(E.match(new RegExp(`\\${d}`,"g"))||[]).length;if(X>_)break;l=E;continue}if(Ut.has(d)){l=l.slice(0,-1);continue}break}return l},yt=u=>{let l=Wt(u);return l=l.replace("0.0.0.0","127.0.0.1"),l=l.replace("[::1]","127.0.0.1"),l=l.replace("[::]","127.0.0.1"),l},qt=u=>{if(!u)return null;const l=u.replace(Ot,""),d=l.match(zt);if(d?.[1]){const E=Number.parseInt(d[1],10);if(Number.isFinite(E)&&E>0&&E<=65535)return`http://127.0.0.1:${E}/`}const I=l.split(`
|
|
2
|
-
`);for(const E of I){if(!
|
|
1
|
+
import{R as n,j as f,k as vt,cm as xt,cn as Tt,co as kt}from"./vendor-.bun-BE757pvp.js";import{c as bt,y as Ct,eE as Et,v as et,d as Rt,z as St,W as At,aF as It,G as ht,e as Bt,I as fe,B as oe}from"./useAppFontEffects-DzBg8hrC.js";import{u as q}from"./main-BC0m8s1v.js";import{h as Mt,u as Me,cb as Pt,ca as it,as as pt}from"./index-ltrmNGAf.js";import{y as Dt,z as Nt}from"./runtimeEndpointReset-C42u8PvG.js";import"./SessionSwitcherDropdown-DvoOalMY.js";import"./mobileLayoutPreference-Dio-WWkI.js";function jt(u){const{colors:l}=u,d=l.syntax.base;return{background:l.surface.background,foreground:d.foreground,cursor:l.interactive.cursor,cursorAccent:l.surface.background,selectionBackground:l.interactive.selection,selectionForeground:l.interactive.selectionForeground,selectionInactiveBackground:l.interactive.selection+"50",black:l.surface.muted,red:l.status.error,green:l.status.success,yellow:l.status.warning,blue:d.function,magenta:d.keyword,cyan:d.type,white:d.foreground,brightBlack:d.comment,brightRed:l.status.error,brightGreen:l.status.success,brightYellow:l.status.warning,brightBlue:d.function,brightMagenta:d.keyword,brightCyan:d.type,brightWhite:l.surface.elevatedForeground}}function Vt(u,l,d,I,E=!1){const _=`${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:l,lineHeight:1.15,fontFamily:_,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:I,disableStdin:E}}let mt=null;function Lt(){return mt||(mt=kt.load()),mt}function Ft(u){if(typeof window>"u")return null;const l=[u,...Array.from(u.querySelectorAll("*"))];let d=null;for(const I of l){const X=window.getComputedStyle(I).overflowY;if(!(X!=="auto"&&X!=="scroll")){if(I.scrollHeight-I.clientHeight>2)return I;d||(d=I)}}return d}const gt=n.forwardRef(({sessionKey:u,chunks:l,onInput:d,onResize:I,theme:E,fontFamily:X,fontSize:_,className:ye,enableTouchScroll:R,autoFocus:at=!0,isVisible:Ne=!0},Se)=>{const{t:J}=bt(),O=n.useRef(null),je=n.useRef(null),B=n.useRef(null),tt=n.useRef(null),K=n.useRef(d),Ue=n.useRef(I),v=n.useRef(null),Ae=n.useRef(""),se=n.useRef(null),Ve=n.useRef(!1),Le=n.useRef(null),be=n.useRef(!0),ie=n.useRef(null),Q=n.useRef(null),Ie=n.useRef(0),ae=n.useRef(null),We=n.useRef(null),de=n.useRef(!1),ee=n.useRef(!1),ge=n.useRef(null),V=n.useRef(null),D=n.useRef(null),he=n.useRef(""),Fe=n.useRef(null),L=n.useRef(!R),nt=n.useRef(Ne),[,dt]=n.useReducer(e=>e+1,0),[rt,ct]=n.useReducer(e=>e+1,0);K.current=d,Ue.current=I;const lt=typeof navigator<"u"&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform==="Android"),b=!!R;n.useEffect(()=>{if(!R){L.current=!0,nt.current=Ne;return}!nt.current&&Ne&&(L.current=!1),nt.current=Ne},[R,Ne]);const ot=n.useCallback(()=>{if(!b)return;const e=O.current,c=ae.current;if(!e)return;const a=[];e.getAttribute("contenteditable")==="true"&&a.push(e),a.push(...Array.from(e.querySelectorAll('[contenteditable="true"]'))),a.forEach(s=>{s.setAttribute("data-terminal-disabled-contenteditable","true"),s.setAttribute("contenteditable","false"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.style.setProperty("caret-color","transparent"),s.style.color="transparent",s.style.setProperty("-webkit-text-fill-color","transparent"),s.style.background="transparent",s.style.outline="none",s.style.boxShadow="none",s.style.textShadow="none",s.style.setProperty("user-select","none"),s.style.setProperty("-webkit-user-select","none")}),e.tabIndex=-1,e.removeAttribute("role"),e.removeAttribute("aria-multiline"),Array.from(e.querySelectorAll("textarea")).forEach(s=>{s.style.setProperty("caret-color","transparent"),s.style.color="transparent",s.style.setProperty("-webkit-text-fill-color","transparent"),s.style.background="transparent",s.style.border="0",s.style.outline="none",s.style.boxShadow="none",s.style.textShadow="none",s.style.fontSize="0",s.style.lineHeight="0",s!==c&&s.getAttribute("data-terminal-disabled-input")!=="true"&&(s.setAttribute("data-terminal-disabled-input","true"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.disabled=!0,s.style.position="absolute",s.style.opacity="0",s.style.width="0px",s.style.height="0px",s.style.pointerEvents="none",s.style.zIndex="-1")})},[b]),A=n.useCallback(e=>{if(Fe.current===e)return;const c=B.current;if(c)try{if(typeof c.setOption=="function"){c.setOption("cursorBlink",e),Fe.current=e;return}c.options&&(c.options.cursorBlink=e,Fe.current=e)}catch{}},[]),pe=b&<,S=n.useCallback((e,c)=>{const a=pe?We.current:ae.current,w=O.current;if(!a||!w)return;const s=w.getBoundingClientRect(),T=typeof window<"u"?window.innerWidth:s.width,h=typeof window<"u"?window.innerHeight:s.height,te=s.left+s.width/2,M=s.top+s.height-12,o=typeof e=="number"?e:te,P=typeof c=="number"?c:M,Y=8,me=Math.max(Y,Math.min(T-Y,o)),$=Math.max(Y,Math.min(h-Y,P));a.style.left=`${me}px`,a.style.top=`${$}px`,a.style.bottom="",(a instanceof HTMLTextAreaElement||a instanceof HTMLInputElement)&&(a.disabled=!1,a.readOnly=!1,a.removeAttribute("disabled"),a.removeAttribute("readonly"));try{a.focus({preventScroll:!0})}catch{try{a.focus()}catch{}}},[pe]),F=n.useCallback(()=>{if(b){S(),A(!0);return}B.current?.focus(),A(!0)},[S,A,b]),N=n.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??"",[]),U=n.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value="";return}e.textContent=""},[]),Ye=n.useCallback(e=>{if(typeof window>"u"||pe)return;D.current!==null&&(window.clearTimeout(D.current),D.current=null);let c=0;const a=3,w=()=>{D.current=window.setTimeout(()=>{D.current=null;const s=N(e);if(!s){if(c+=1,c<a){w();return}return}const T=he.current;he.current=s;const h=s.startsWith(T)?s.slice(T.length):s;h&&K.current(h.replace(/\r\n|\r|\n/g,"\r")),U(e),he.current=""},c===0?0:24)};w()},[U,N,pe]);n.useEffect(()=>{const e=O.current;if(!b||!e||R)return;const c=a=>{const w=a.target;if(w&&w.getAttribute("data-terminal-hidden-input")!=="true"&&e.contains(w)){try{w.blur()}catch{}S()}};return e.addEventListener("focusin",c,!0),()=>{e.removeEventListener("focusin",c,!0)}},[R,b,S]);const qe=n.useCallback(()=>{const e=B.current;if(!e||typeof e.getSelection!="function")return"";const c=e.getSelection();return typeof c=="string"?c:""},[]),Xe=n.useCallback(()=>{if(typeof window>"u")return"";const e=window.getSelection();if(!e)return"";const c=e.toString();if(!c.trim())return"";const a=O.current;if(!a)return"";const w=e.anchorNode,s=e.focusNode;return w&&!a.contains(w)||s&&!a.contains(s)?"":c},[]),ve=n.useCallback(async()=>{if(typeof document>"u")return;const e=qe()||Xe();e.trim()&&await Ct(e)},[Xe,qe]),Z=n.useCallback(()=>qe().trim()?!0:!!Xe().trim(),[Xe,qe]);n.useEffect(()=>{if(typeof window>"u")return;const e=c=>{Z()&&(c.preventDefault(),ve())};return window.addEventListener("openchamber:copy",e),()=>{window.removeEventListener("openchamber:copy",e)}},[ve,Z]);const ce=n.useCallback(()=>{Ae.current="",se.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(se.current),se.current=null,Ve.current=!1,Le.current=null},[]),z=n.useCallback(()=>{const e=tt.current,c=B.current,a=O.current;if(!e||!c||!a)return;const w=a.getBoundingClientRect();if(!(w.width<24||w.height<24))try{e.fit();const s={cols:c.cols,rows:c.rows},T=v.current;(!T||T.cols!==s.cols||T.rows!==s.rows)&&(v.current=s,Ue.current(s.cols,s.rows))}catch{}},[]),xe=n.useCallback(()=>{if(Ve.current)return;const e=B.current;if(!e){ce();return}if(!Ae.current)return;const c=Ae.current;Ae.current="",Ve.current=!0,e.write(c,()=>{Ve.current=!1,Ae.current&&(typeof window<"u"?se.current=window.requestAnimationFrame(()=>{se.current=null,xe()}):xe())})},[ce]),Pe=n.useCallback(()=>{se.current===null&&(typeof window<"u"?se.current=window.requestAnimationFrame(()=>{se.current=null,xe()}):xe())},[xe]),$e=n.useCallback(e=>{e&&(Ae.current+=e,Pe())},[Pe]),De=n.useCallback(()=>{if(ie.current?.(),ie.current=null,Q.current!==null&&typeof window<"u"&&(window.clearTimeout(Q.current),Q.current=null),!R){Ie.current=0;return}const e=O.current;if(!e)return;const c=B.current;if(!c)return;Ie.current=0;const a=2.2,w=2.8,s=25,T=.25,h=8,te=.05,M=.015,o={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},P=()=>typeof performance<"u"?performance.now():Date.now(),Y=Math.max(12,Math.round(_*1.35));let me=0;const $=i=>{if(!i)return!1;const W=c.getViewportY(),re=me+i,le=Math.trunc(re/Y);return me=re-le*Y,le!==0&&c.scrollLines(le),c.getViewportY()!==W},ke=()=>{o.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.rafId),o.rafId=null},k={passive:!1,capture:!1};if(typeof window<"u"&&"PointerEvent"in window){const i=Object.assign(o,{pointerId:null,startX:null,startY:null,moved:!1}),W=6,re=r=>{if(r.pointerType==="touch"){ke(),i.pointerId=r.pointerId,i.startX=r.clientX,i.startY=r.clientY,i.moved=!1,i.lastY=r.clientY,i.lastTime=P(),i.velocity=0;try{e.setPointerCapture(r.pointerId)}catch{}}},le=r=>{if(r.pointerType!=="touch"||i.pointerId!==r.pointerId)return;if(i.startX!==null&&i.startY!==null&&!i.moved){const ut=r.clientX-i.startX,He=r.clientY-i.startY;Math.hypot(ut,He)>=W&&(i.moved=!0)}if(i.lastY===null){i.lastY=r.clientY,i.lastTime=P();return}const g=i.lastY,m=i.lastTime??P(),x=P();i.lastY=r.clientY,i.lastTime=x;const y=g-r.clientY;if(Math.abs(y)<1)return;const G=Math.max(x-m,8),Ee=a+Math.min(w,Math.abs(y)/s),we=y*Ee,Re=we/G;i.velocity=i.velocity*(1-T)+Re*T,i.velocity>h?i.velocity=h:i.velocity<-h&&(i.velocity=-h),i.moved&&(r.cancelable&&r.preventDefault(),r.stopPropagation()),$(we)},ue=r=>{if(r.pointerType!=="touch"||i.pointerId!==r.pointerId)return;const g=!i.moved;i.pointerId=null,i.startX=null,i.startY=null,i.moved=!1,i.lastY=null,i.lastTime=null;try{e.releasePointerCapture(r.pointerId)}catch{}if(g){b?S(r.clientX,r.clientY):R&&!L.current&&(L.current=!0,B.current?.focus());return}if(typeof window>"u")return;if(Math.abs(i.velocity)<te){i.velocity=0;return}let m=P();const x=()=>{const y=P(),G=Math.max(y-m,8);m=y;const Ee=$(i.velocity*G)??!1,we=Math.sign(i.velocity),Re=Math.max(0,Math.abs(i.velocity)-M*G);if(i.velocity=Re*we,!Ee||Re<=te){ke(),i.velocity=0;return}i.rafId=window.requestAnimationFrame(x)};i.rafId=window.requestAnimationFrame(x)};e.addEventListener("pointerdown",re,k),e.addEventListener("pointermove",le,k),e.addEventListener("pointerup",ue,k),e.addEventListener("pointercancel",ue,k);const t=e.style.touchAction,p=e.style.overscrollBehaviorY;e.style.touchAction="none",e.style.overscrollBehaviorY="contain",ie.current=()=>{ke(),Q.current!==null&&typeof window<"u"&&(window.clearTimeout(Q.current),Q.current=null),Ie.current=0,e.removeEventListener("pointerdown",re,k),e.removeEventListener("pointermove",le,k),e.removeEventListener("pointerup",ue,k),e.removeEventListener("pointercancel",ue,k),e.style.touchAction=t,e.style.overscrollBehaviorY=p};return}const C=6,Ce=i=>{i.touches.length===1&&(ke(),o.lastY=i.touches[0].clientY,o.lastTime=P(),o.velocity=0,o.startX=i.touches[0].clientX,o.startY=i.touches[0].clientY,o.didMove=!1)},Be=i=>{if(i.touches.length!==1){o.lastY=null,o.lastTime=null,o.velocity=0,o.startX=null,o.startY=null,o.didMove=!1,ke();return}const W=i.touches[0].clientX,re=i.touches[0].clientY;if(o.startX!==null&&o.startY!==null&&!o.didMove){const y=W-o.startX,G=re-o.startY;Math.hypot(y,G)>=C&&(o.didMove=!0)}if(o.lastY===null){o.lastY=re,o.lastTime=P();return}const le=o.lastY,ue=o.lastTime??P(),t=P();o.lastY=re,o.lastTime=t;const p=le-re;if(Math.abs(p)<1)return;const r=Math.max(t-ue,8),g=a+Math.min(w,Math.abs(p)/s),m=p*g,x=m/r;o.velocity=o.velocity*(1-T)+x*T,o.velocity>h?o.velocity=h:o.velocity<-h&&(o.velocity=-h),o.didMove&&(i.preventDefault(),i.stopPropagation()),$(m)},H=i=>{const W=!o.didMove;o.lastY=null,o.lastTime=null;const re=o.velocity;if(o.startX=null,o.startY=null,o.didMove=!1,W){const t=i.changedTouches?.[0];b?S(t?.clientX,t?.clientY):R&&!L.current&&(L.current=!0,B.current?.focus());return}if(typeof window>"u")return;if(Math.abs(re)<te){o.velocity=0;return}let le=P();const ue=()=>{const t=P(),p=Math.max(t-le,8);le=t;const r=$(o.velocity*p)??!1,g=Math.sign(o.velocity),m=Math.max(0,Math.abs(o.velocity)-M*p);if(o.velocity=m*g,!r||m<=te){ke(),o.velocity=0;return}o.rafId=window.requestAnimationFrame(ue)};o.rafId=window.requestAnimationFrame(ue)};e.addEventListener("touchstart",Ce,k),e.addEventListener("touchmove",Be,k),e.addEventListener("touchend",H,k),e.addEventListener("touchcancel",H,k);const Qe=e.style.touchAction,j=e.style.overscrollBehaviorY;e.style.touchAction="none",e.style.overscrollBehaviorY="contain",ie.current=()=>{ke(),Q.current!==null&&typeof window<"u"&&(window.clearTimeout(Q.current),Q.current=null),Ie.current=0,e.removeEventListener("touchstart",Ce,k),e.removeEventListener("touchmove",Be,k),e.removeEventListener("touchend",H,k),e.removeEventListener("touchcancel",H,k),e.style.touchAction=Qe,e.style.overscrollBehaviorY=j}},[R,b,S,_]);n.useEffect(()=>{let e=!1,c=null,a=null,w=null,s=[],T=null,h=null,te=null;const M=O.current;if(!M)return;if(M.tabIndex=b?-1:0,b){const k=M.focus.bind(M),ne=M;ne.focus=((...C)=>{S()}),te=()=>{ne.focus=k}}const o=()=>{A(!0)},P=()=>{A(!1)},Y=k=>{const ne=k.target;if(ne&&M.contains(ne)){if(b&&ne instanceof HTMLElement){window.setTimeout(()=>{ne.blur(),S()},0),A(!1);return}if(R&&!L.current&&ne instanceof HTMLElement){window.setTimeout(()=>{ne.blur()},0),A(!1);return}A(!0);return}A(!1)},me=()=>{A(!1)};let $=null;return(async()=>{try{const k=await Lt();if(e)return;const ne=Vt(X,_,E,k,!1),C=new xt(ne);be.current=!0,b&&(C.focus=()=>{});const Ce=C;if(typeof Ce.scrollToBottom=="function"){const j=Ce.scrollToBottom.bind(Ce);Ce.scrollToBottom=()=>{be.current&&j()},T=()=>{Ce.scrollToBottom=j}}const Be=new Tt;if(c=C,B.current=C,tt.current=Be,C.loadAddon(Be),C.open(M),R){const j=C.renderer;if(j&&typeof j.renderScrollbar=="function"){const i=j.renderScrollbar.bind(j);j.renderScrollbar=()=>{},h=()=>{j.renderScrollbar=i}}}ct(),Fe.current=!1,$=C.textarea??M.querySelector("textarea"),$&&($.addEventListener("focus",o),$.addEventListener("blur",P)),ot(),typeof MutationObserver<"u"&&(w=new MutationObserver(()=>{ot()}),w.observe(M,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["contenteditable","role","tabindex","aria-label"]}));const H=Ft(M);H?(H.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),je.current=H,dt()):je.current=null,z();const Qe=Be;typeof Qe.observeResize=="function"&&Qe.observeResize(),De(),s=[C.onData(j=>{K.current(j)}),C.onScroll(j=>{if(typeof j=="number"&&Number.isFinite(j)){const i=typeof C.hasSelection=="function"&&C.hasSelection();be.current=!i&&j<=.5}}),C.onSelectionChange(()=>{if(typeof C.hasSelection=="function"&&C.hasSelection()){be.current=!1;return}const i=typeof C.getViewportY=="function"?C.getViewportY():0;be.current=i<=.5})],a=new ResizeObserver(()=>{z()}),a.observe(M),typeof window<"u"&&window.setTimeout(()=>{z()},0)}catch{}})(),document.addEventListener("focusin",Y,!0),window.addEventListener("blur",me),()=>{e=!0,ie.current?.(),ie.current=null,document.removeEventListener("focusin",Y,!0),window.removeEventListener("blur",me),s.forEach(k=>k.dispose()),T?.(),T=null,h?.(),h=null,$&&($.removeEventListener("focus",o),$.removeEventListener("blur",P)),a?.disconnect(),w?.disconnect(),te?.(),c?.dispose(),B.current=null,tt.current=null,je.current=null,v.current=null,Fe.current=null,ce()}},[ot,R,z,S,X,_,De,E,ce,A,b]),n.useEffect(()=>{const e=B.current;e&&(e.reset(),ce(),v.current=null,z())},[u,rt,z,ce]),n.useEffect(()=>{!at||!B.current||F()},[at,F,u,rt]),n.useEffect(()=>(De(),()=>{ie.current?.(),ie.current=null}),[De,u]),n.useEffect(()=>{const e=B.current;if(!e)return;if(l.length===0){Le.current!==null&&(e.reset(),ce(),z());return}const c=Le.current;let a;if(c===null)a=l;else{const w=l.findIndex(s=>s.id===c);a=w>=0?l.slice(w+1):l}a.length>0&&$e(a.map(w=>w.data).join("")),Le.current=l[l.length-1].id},[l,rt,$e,z,ce]),n.useImperativeHandle(Se,()=>({focus:()=>{F()},clear:()=>{const e=B.current;e&&(e.reset(),ce(),z())},fit:()=>{z()}}),[F,z,ce]);const Ge=n.useCallback(e=>{if(!b)return;const c=O.current,a=e.relatedTarget,w=a?.tagName,s=w==="INPUT"||w==="TEXTAREA"||a?.isContentEditable,T=a?.getAttribute("data-terminal-hidden-input")==="true",h=!!(a&&c?.contains(a))},[b]),Oe=n.useCallback(e=>{const c=e.nativeEvent,a=c?.inputType??"",w=typeof c?.data=="string"?c.data:"";if(V.current=typeof performance<"u"?performance.now():Date.now(),a==="insertCompositionText"){de.current=!0;return}if(!a&&w){if(de.current)return;e.preventDefault(),K.current(w),ge.current={type:"insertText",at:typeof performance<"u"?performance.now():Date.now()},ee.current=!0;return}if(a==="insertText"&&w){if(de.current)return;e.preventDefault(),K.current(w),ge.current={type:a,at:typeof performance<"u"?performance.now():Date.now()},ee.current=!0;return}if(a==="insertLineBreak"){if(de.current)return;e.preventDefault(),K.current("\r"),ge.current={type:a,at:typeof performance<"u"?performance.now():Date.now()},ee.current=!0;return}if(a==="deleteContentBackward"){if(de.current)return;e.preventDefault(),K.current(""),ge.current={type:a,at:typeof performance<"u"?performance.now():Date.now()},ee.current=!0}},[]),st=n.useCallback(e=>{const c=e.currentTarget;if(V.current=typeof performance<"u"?performance.now():Date.now(),de.current)return;if(ee.current){const s=ge.current,T=typeof performance<"u"?performance.now():Date.now();if(s&&T-s.at<50){ee.current=!1,U(c);return}ee.current=!1}const a=N(c);if(!a)return;he.current=a;const w=a.replace(/\r\n|\r|\n/g,"\r");K.current(w),U(c),he.current=""},[U,N]),_e=n.useCallback(e=>{e.stopPropagation();const c=e.key.toLowerCase(),a=e.metaKey&&!e.ctrlKey&&!e.altKey&&c==="c",w=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&c==="c";if((a||w)&&Z()){e.preventDefault(),ve();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){const Y=e.key.toUpperCase();if(Y>="A"&&Y<="Z"){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),K.current(String.fromCharCode(Y.charCodeAt(0)-64)),U(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),K.current("\x1B"+e.key),U(e.currentTarget);return}const T={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(T){e.preventDefault(),K.current(T),U(e.currentTarget);return}const h=e.currentTarget;if(e.nativeEvent?.isComposing)return;const M=ge.current,o=typeof performance<"u"?performance.now():Date.now(),P=!!(M&&o-M.at<50);if(e.key==="Enter"){if(P&&M?.type==="insertLineBreak")return;e.preventDefault(),K.current("\r"),U(h);return}if(e.key==="Backspace"){if(e.preventDefault(),P&&M?.type==="deleteContentBackward")return;N(h)||K.current("")}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const Y=V.current;Y&&o-Y<50||(e.preventDefault(),K.current(e.key),ee.current=!0,ge.current={type:"keydown-text",at:o})}Ye(h)},[U,ve,Z,N,Ye]),Ke=n.useCallback(e=>{e.stopPropagation();const c=e.currentTarget;e.nativeEvent?.isComposing||Ye(c)},[Ye]),Je=n.useCallback(e=>{const c=e.currentTarget;de.current=!1;const a=e.data||N(c);if(V.current=typeof performance<"u"?performance.now():Date.now(),!a)return;const w=a.replace(/\r\n|\r|\n/g,"\r");K.current(w),U(c),ge.current={type:"compositionend",at:typeof performance<"u"?performance.now():Date.now()},ee.current=!0},[U,N]),ze=n.useCallback(e=>{e.stopPropagation();const c=e.clipboardData?.getData("text")??"";if(!c)return;e.preventDefault();const w=B.current?.hasBracketedPaste?.()?`\x1B[200~${c}\x1B[201~`:c;K.current(w)},[]),Te={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:et("relative h-full w-full terminal-viewport-container",ye),"data-hidden-input-overlay-active":b?"true":void 0,style:{backgroundColor:E.background},onTouchStart:e=>{if(!(!b||R)&&!Z()){const c=e.touches?.[0];S(c?.clientX,c?.clientY)}},onClick:e=>{if(!R)if(b){if(Z())return;S(e.clientX,e.clientY)}else B.current?.focus()},onMouseUp:()=>{!R&&Z()&&ve()},onTouchEnd:()=>{!R&&Z()&&ve()},children:[b&&typeof document<"u"?vt.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":J("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...Te,display:pe?"block":"none"},onBlur:Ge,onBeforeInput:Oe,onCompositionStart:()=>{de.current=!0},onInput:st,onKeyDown:_e,onKeyUp:Ke,onCompositionEnd:Je,onPaste:ze}),f.jsx("textarea",{ref:ae,inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":J("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...Te,display:pe?"none":"block"},onBlur:Ge,onBeforeInput:Oe,onCompositionStart:()=>{de.current=!0},onInput:st,onKeyDown:_e,onKeyUp:Ke,onCompositionEnd:Je,onPaste:ze})]}),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 Yt="\x1B",Ot=new RegExp(`${Yt}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Kt=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,zt=/(?:➜\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,Ut=new Set([".",",",";",":","!","?"]),Wt=u=>{let l=u;for(;l.length>0;){const d=l[l.length-1];if(d===")"||d==="]"||d==="}"||d===">"){const I=d===")"?"(":d==="]"?"[":d==="}"?"{":"<",E=l.slice(0,-1),X=(E.match(new RegExp(`\\${I}`,"g"))||[]).length,_=(E.match(new RegExp(`\\${d}`,"g"))||[]).length;if(X>_)break;l=E;continue}if(Ut.has(d)){l=l.slice(0,-1);continue}break}return l},yt=u=>{let l=Wt(u);return l=l.replace("0.0.0.0","127.0.0.1"),l=l.replace("[::1]","127.0.0.1"),l=l.replace("[::]","127.0.0.1"),l},qt=u=>{if(!u)return null;const l=u.replace(Ot,""),d=l.match(Ht);if(d?.[1]){const E=Number.parseInt(d[1],10);if(Number.isFinite(E)&&E>0&&E<=65535)return`http://127.0.0.1:${E}/`}const I=l.split(`
|
|
2
|
+
`);for(const E of I){if(!zt.test(E))continue;const X=Array.from(E.matchAll(Kt));if(X.length===0)continue;const _=X.find(ye=>{try{return!!new URL(yt(ye[1])).port}catch{return!1}});return yt((_??X[0])[1])}return null},Xt=async(u,l=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 I=d.hostname.toLowerCase();if(I!=="localhost"&&I!=="127.0.0.1"&&I!=="0.0.0.0"&&I!=="::1"&&I!=="::")return!1;const E=new AbortController,X=window.setTimeout(()=>E.abort(),l);try{const _=await Mt("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:d.toString()}),cache:"no-store",signal:E.signal});return _.ok?(await _.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(X)}},$t={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},ft={ctrl:"5",cmd:"3"},wt={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},Gt={retry:{...wt.retry,initialDelayMs:200,maxDelayMs:500},connectionTimeoutMs:1500},_t=(u,l)=>{if(l)switch(u){case"arrow-up":return`\x1B[1;${ft[l]}A`;case"arrow-down":return`\x1B[1;${ft[l]}B`;case"arrow-right":return`\x1B[1;${ft[l]}C`;case"arrow-left":return`\x1B[1;${ft[l]}D`}return $t[u]??null},sn=()=>{const{t:u}=bt(),{terminal:l,runtime:d}=Rt(),{currentTheme:I}=St(),{monoFont:E}=At(),X=Me(t=>t.terminalFontSize),_=Me(t=>t.bottomTerminalHeight),ye=Me(t=>t.isBottomTerminalExpanded),{isMobile:R,isTablet:at,hasTouchOnlyPointer:Ne}=It(),Se=R||at,J=(Se||Ne)&&d.platform==="web",O=d.platform!=="vscode",je=Me(t=>t.showTerminalQuickKeysOnDesktop),B=Se||je,tt=ht(t=>t.currentSessionId),K=ht(t=>t.newSessionDraft),Ue=tt!==null||K?.open===!0,v=Bt()??null,Ae=q(t=>t.sessions),se=q(t=>t.hasHydrated),Ve=q(t=>t.ensureDirectory),Le=q(t=>t.createTab),be=q(t=>t.setActiveTab),ie=q(t=>t.closeTab),Q=q(t=>t.setTabSessionId),Ie=q(t=>t.setTabLifecycle),ae=q(t=>t.setConnecting),We=q(t=>t.appendToBuffer),de=q(t=>t.setTabPreviewUrl),ee=q(t=>t.clearBuffer),ge=Me(t=>t.openContextPreview),V=n.useMemo(()=>{if(v)return Ae.get(v)},[Ae,v]),D=n.useMemo(()=>V?O?V.activeTabId??V.tabs[0]?.id??null:V.tabs[0]?.id??null:null,[V,O]),he=n.useMemo(()=>{if(V)return D?V.tabs.find(t=>t.id===D)??V.tabs[0]:V.tabs[0]},[V,D]),Fe=n.useMemo(()=>(V?.tabs??[]).map(t=>({icon:(()=>{const p=t.iconKey?Dt[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")})),[V?.tabs,u]),L=he?.terminalSessionId??null,nt=he?.lifecycle??"idle",dt=he?.bufferChunks??[],rt=he?.isConnecting??!1,ct=he?.previewUrl??null,[lt,b]=n.useState(null),[ot,A]=n.useState(!1),[pe,S]=n.useState(!1),[F,N]=n.useState(null),[U,Ye]=n.useState(!1),[qe,Xe]=n.useState(0),ve=n.useRef(null),Z=n.useRef(null),ce=n.useRef(D),z=n.useRef(L),xe=n.useRef(v),Pe=n.useRef(null),$e=n.useRef(null),De=n.useRef(!1),Ge=n.useRef(null),Oe=n.useRef(new Set),st=n.useRef(!1),_e=n.useRef(""),Ke=n.useRef(new Set),Je=n.useRef(0),ze=n.useCallback(()=>{_e.current="",Ke.current.clear(),Je.current+=1},[]),Te=n.useCallback(()=>{J||typeof document<"u"&&!document.hasFocus()||Pe.current?.focus()},[J]),e=n.useCallback(()=>{J||Pe.current?.focus()},[J]);n.useEffect(()=>{if(!se||st.current)return;st.current=!0;const t=new Set;for(const[,p]of q.getState().sessions.entries())for(const r of p.tabs)r.terminalSessionId&&t.add(r.terminalSessionId);Oe.current=t},[se]);const c=Me(t=>t.activeMainTab),a=Me(t=>t.isBottomTerminalOpen),w=Me(t=>t.setBottomTerminalOpen),s=Me(t=>t.setBottomTerminalExpanded),T=c==="terminal",h=T||a,[te,M]=n.useState(h);n.useEffect(()=>{!h||d.platform==="vscode"||Pt()},[h,d.platform]),n.useEffect(()=>{h&&M(!0)},[h]),n.useEffect(()=>{De.current=h},[h]),n.useEffect(()=>{z.current=L},[L]),n.useEffect(()=>{ce.current=D,ze()},[D,ze]),n.useEffect(()=>{xe.current=v},[v]),n.useEffect(()=>{!B&&F!==null&&N(null)},[B,F,N]),n.useEffect(()=>{!L&&F!==null&&N(null)},[L,F,N]);const o=n.useCallback(()=>{ve.current?.(),ve.current=null,Z.current=null,S(!1)},[]);n.useEffect(()=>()=>{o(),z.current=null},[o]);const P=n.useCallback((t,p,r)=>{if(!r)return;const g=`${_e.current}${r}`.replace(/\r\n|\r/g,`
|
|
3
3
|
`),m=g.split(`
|
|
4
4
|
`),x=g.endsWith(`
|
|
5
5
|
`)?m.join(`
|
|
6
6
|
`):m.slice(0,-1).join(`
|
|
7
7
|
`);if(_e.current=g.endsWith(`
|
|
8
|
-
`)?"":(m[m.length-1]??"").slice(-1024),!x)return;const y=qt(x);if(!y||Ke.current.has(y))return;const G=Je.current;Ke.current.add(y),Xt(y).then(Ee=>{if(Ke.current.delete(y),!Ee||Je.current!==G)return;const we=q.getState().getDirectoryState(t)?.tabs.find(Re=>Re.id===p);!we||we.previewUrlLocked||we.previewUrl===y||de(t,p,y,{locked:!1,autoOpened:!1})})},[de]),Y=n.useCallback((t,p,r,g=wt)=>{if(Z.current===r)return;o(),Z.current=r;const m=l.connect(r,{onEvent:x=>{if(Z.current===r)switch(x.type){case"connected":{ae(t,p,!1),b(null),A(!1),S(!1),Te(),Ge.current===r&&(Ge.current=null,l.sendInput(r,"\r").catch(()=>{}));break}case"reconnecting":{b(null),A(!1),S(!0);break}case"data":{x.data&&(We(t,p,x.data),P(t,p,x.data));break}case"exit":{const y=typeof x.exitCode=="number"?x.exitCode:null,G=typeof x.signal=="number"?x.signal:null,we=!!q.getState().getDirectoryState(t)?.tabs.find(Re=>Re.id===p)?.label?.startsWith("Action:");We(t,p,u("terminalView.stream.processExitedMessage",{exitCodeSegment:y!==null?u("terminalView.stream.processExitedWithCode",{exitCode:y}):"",signalSegment:G!==null?u("terminalView.stream.processExitedWithSignal",{signal:G}):""})),Ie(t,p,"exited"),Q(t,p,null),ae(t,p,!1),b(we?null:u("terminalView.error.sessionEnded")),A(!1),S(!1),o();break}}},onError:(x,y)=>{if(Z.current===r){if(!y){b(null),A(!1);return}S(!1),b(u("terminalView.error.connectionFailed",{message:x.message})),A(!0),ae(t,p,!1),ee(t,p),Ie(t,p,"exited"),Q(t,p,null),o()}}},g);ve.current=()=>{m.close(),Z.current=null}},[We,ee,o,Te,P,ae,Ie,Q,u,l]);n.useEffect(()=>{let t=!1;if(!se||!te)return;if(!v){b(u(Ue?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),o();return}return(async()=>{const r=v;if(!xe.current||xe.current!==r)return;Ve(r);const g=q.getState().getDirectoryState(r);if(!g||g.tabs.length===0)return;const m=O?g.activeTabId??g.tabs[0]?.id??null:g.tabs[0]?.id??null;if(!m)return;const x=g.tabs.find(ze=>ze.id===m)??g.tabs[0];let y=x?.terminalSessionId??null;const G=x?.lifecycle??"idle",Ee=!!x?.label?.startsWith("Action:"),we=(x?.bufferLength??0)>0||(x?.bufferChunks?.length??0)>0,Re=!!y&&Oe.current.has(y)&&(x?.bufferLength??0)===0&&(x?.bufferChunks?.length??0)===0,ut=!!y&&Oe.current.has(y);if(!y){if(G==="exited"){ae(r,m,!1);return}if(Ee&&we){ae(r,m,!1);return}const ze=$e.current;if(!ze&&De.current)return;b(null),A(!1),S(!1),ae(r,m,!0);try{const Ze=await l.createSession({cwd:r,cols:ze?.cols,rows:ze?.rows});if(!(!t&&xe.current===r&&ce.current===m)){try{await l.close(Ze.sessionId)}catch{}return}Q(r,m,Ze.sessionId),y=Ze.sessionId}catch(Ze){t||(b(Ze instanceof Error?Ze.message:u("terminalView.error.startSessionFailed")),A(!0),S(!1),ae(r,m,!1));return}}!y||t||(H.current=y,ut&&Oe.current.delete(y),Re&&(Ge.current=y),Y(r,m,y,ut?Gt:wt))})(),()=>{t=!0,H.current=null,o()}},[Ue,v,L,nt,D,te,qe,O,se,Ve,ae,Ie,Q,Y,o,u,l]),n.useEffect(()=>{if(!h||J)return;if(typeof window>"u"){Te();return}const t=window.requestAnimationFrame(()=>{Te()});return()=>{window.cancelAnimationFrame(t)}},[D,Te,h,J]);const me=n.useCallback(async()=>{if(!v||U)return;const t=q.getState().getDirectoryState(v),p=O?D??t?.activeTabId??t?.tabs[0]?.id??null:t?.tabs[0]?.id??null;if(p){Ye(!0),b(null),A(!1),S(!1),o(),ee(v,p),He();try{await ie(v,p)}catch(r){b(r instanceof Error?r.message:u("terminalView.error.restartFailed")),A(!0),S(!1)}finally{Ye(!1)}}},[D,ee,ie,o,v,O,U,He,u]),$=n.useCallback(async()=>{await me()},[me]),ke=n.useCallback(()=>{if(!v)return;const t=Le(v);be(v,t),b(null),A(!1),S(!1),o()},[Le,o,v,be]),k=n.useCallback(t=>{v&&(be(v,t),b(null),A(!1),S(!1),o())},[o,v,be]),ne=n.useCallback(t=>{v&&(t===D&&o(),b(null),A(!1),S(!1),ie(v,t))},[D,ie,o,v]),C=n.useCallback(t=>{if(!t||pe)return;let p=t,r=!1;if(F&&t.length>0){const m=t[0];if(m.length===1&&/[a-zA-Z]/.test(m)){const x=m.toUpperCase();(F==="ctrl"||F==="cmd")&&(p=String.fromCharCode(x.charCodeAt(0)&31),r=!0)}r||(r=!0)}const g=H.current;g&&(l.sendInput(g,p).catch(m=>{pe||b(m instanceof Error?m.message:u("terminalView.error.sendInputFailed"))}),r&&(N(null),e()))},[F,e,pe,N,u,l]),Ce=n.useCallback((t,p)=>{const r=$e.current;if((!r||r.cols!==t||r.rows!==p)&&($e.current={cols:t,rows:p},Xe(m=>m+1)),!De.current)return;const g=H.current;g&&l.resize({sessionId:g,cols:t,rows:p}).catch(()=>{})},[l]),Be=n.useCallback(t=>{N(p=>p===t?null:t),e()},[e,N]),z=n.useCallback(t=>{const p=_t(t,F);p&&(C(p),N(null),e())},[F,e,C,N]);n.useEffect(()=>{if(!B||!F||!L)return;const t=p=>{if(p.repeat)return;const r=p.key;if(!r||r==="Control"||r==="Meta"||r==="Alt"||r==="Shift")return;const g=r.length===1?r.toLowerCase():r,m=p.code??"",x=m.startsWith("Key")&&m.length===4?m.slice(3).toUpperCase():null,y=r.length===1&&/[a-zA-Z]/.test(r)?r.toUpperCase():x,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(g in G){p.preventDefault(),p.stopPropagation(),z(G[g]);return}if(F==="ctrl"&&y&&y.length===1&&y>="A"&&y<="Z"){const Ee=String.fromCharCode(y.charCodeAt(0)&31);p.preventDefault(),p.stopPropagation(),C(Ee),N(null),e()}};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[F,z,C,e,B,N,L]);const Qe=n.useMemo(()=>{const t=it[pt].stack;if(typeof window>"u")return(it[E]??it[pt]).stack;const r=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return r&&r.trim().length>0?r.trim():(it[E]??it[pt]).stack??t},[E]),j=n.useMemo(()=>jt(I),[I]),i=n.useMemo(()=>`${v??"no-dir"}::${D??"no-tab"}::${L??"no-terminal"}`,[v,D,L]);if(n.useEffect(()=>{if(!h||J)return;const t=Pe.current;if(!t)return;const p=()=>{t.fit()};if(typeof window<"u"){const r=window.requestAnimationFrame(()=>{p(),Te()}),g=[220,400].map(m=>window.setTimeout(p,m));return()=>{window.cancelAnimationFrame(r),g.forEach(m=>window.clearTimeout(m))}}p()},[Te,h,J,i,L]),n.useEffect(()=>{if(J||!h||!a)return;const t=Pe.current;if(!t)return;const p=()=>{t.fit()};if(typeof window<"u"){const r=window.requestAnimationFrame(()=>{p()}),g=[0,80,180,320].map(m=>window.setTimeout(p,m));return()=>{window.cancelAnimationFrame(r),g.forEach(m=>window.clearTimeout(m))}}p()},[_,ye,a,h,J]),!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(!v)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:me,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 W=!L||rt||U||pe,re=te,le=!Se&&a&&!T,ue=f.jsxs(f.Fragment,{children:[f.jsx(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 px-2 text-xs",onClick:()=>z("esc"),disabled:W,children:u("terminalView.quickKeys.escape")}),f.jsxs(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>z("tab"),disabled:W,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(oe,{type:"button",size:"sm",variant:"chip","aria-pressed":F==="ctrl",className:"h-6 w-9 p-0",onClick:()=>Be("ctrl"),disabled:W,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(oe,{type:"button",size:"sm",variant:"chip","aria-pressed":F==="cmd",className:"h-6 w-9 p-0",onClick:()=>Be("cmd"),disabled:W,children:[f.jsx(fe,{name:"command"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.commandModifierAria")})]}),f.jsxs(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>z("arrow-up"),disabled:W,children:[f.jsx(fe,{name:"arrow-up"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowUpAria")})]}),f.jsxs(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>z("arrow-left"),disabled:W,children:[f.jsx(fe,{name:"arrow-left"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowLeftAria")})]}),f.jsxs(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>z("arrow-down"),disabled:W,children:[f.jsx(fe,{name:"arrow-down"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowDownAria")})]}),f.jsxs(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>z("arrow-right"),disabled:W,children:[f.jsx(fe,{name:"arrow-right"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowRightAria")})]}),f.jsxs(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>z("enter"),disabled:W,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:et("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",Se?"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:et("min-w-0 flex-1",Se?"h-8":"h-7"),children:f.jsx(Nt,{items:Fe,activeId:D,onSelect:k,onClose:ne,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),f.jsx(oe,{type:"button",size:"xs",variant:"ghost",className:et("shrink-0",Se?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:ke,title:u("terminalView.tabs.newTabTitle"),children:f.jsx(fe,{name:"add",className:`${Se?"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(oe,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{v&&ge(v,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,le?f.jsxs(f.Fragment,{children:[f.jsx(oe,{type:"button",size:"xs",variant:"ghost",onClick:()=>s(!ye),className:et("shrink-0 p-0",R?"h-8 w-8":"h-7 w-7"),title:u(ye?"terminalView.bottomDock.restoreTitle":"terminalView.bottomDock.expandTitle"),"aria-label":u(ye?"terminalView.bottomDock.restoreAria":"terminalView.bottomDock.expandAria"),children:ye?f.jsx(fe,{name:"fullscreen-exit",className:"h-4 w-4"}):f.jsx(fe,{name:"fullscreen",className:"h-4 w-4"})}),f.jsx(oe,{type:"button",size:"xs",variant:"ghost",onClick:()=>w(!1),className:et("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&&B&&O&&V?f.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:ue}):null,B&&(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:j.background},children:[f.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:re?f.jsx(gt,{ref:t=>{Pe.current=t},sessionKey:i,chunks:dt,onInput:C,onResize:Ce,theme:j,fontFamily:Qe,fontSize:X,enableTouchScroll:J,autoFocus:!J&&h,isVisible:h},i):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}),ot&&R&&f.jsx(oe,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:$,disabled:U,title:u("terminalView.actions.hardRestartTitle"),type:"button",children:u("terminalView.actions.hardRestart")})]})]})]})};export{sn as TerminalView};
|
|
8
|
+
`)?"":(m[m.length-1]??"").slice(-1024),!x)return;const y=qt(x);if(!y||Ke.current.has(y))return;const G=Je.current;Ke.current.add(y),Xt(y).then(Ee=>{if(Ke.current.delete(y),!Ee||Je.current!==G)return;const we=q.getState().getDirectoryState(t)?.tabs.find(Re=>Re.id===p);!we||we.previewUrlLocked||we.previewUrl===y||de(t,p,y,{locked:!1,autoOpened:!1})})},[de]),Y=n.useCallback((t,p,r,g=wt)=>{if(Z.current===r)return;o(),Z.current=r;const m=l.connect(r,{onEvent:x=>{if(Z.current===r)switch(x.type){case"connected":{ae(t,p,!1),b(null),A(!1),S(!1),Te(),Ge.current===r&&(Ge.current=null,l.sendInput(r,"\r").catch(()=>{}));break}case"reconnecting":{b(null),A(!1),S(!0);break}case"data":{x.data&&(We(t,p,x.data),P(t,p,x.data));break}case"exit":{const y=typeof x.exitCode=="number"?x.exitCode:null,G=typeof x.signal=="number"?x.signal:null,we=!!q.getState().getDirectoryState(t)?.tabs.find(Re=>Re.id===p)?.label?.startsWith("Action:");We(t,p,u("terminalView.stream.processExitedMessage",{exitCodeSegment:y!==null?u("terminalView.stream.processExitedWithCode",{exitCode:y}):"",signalSegment:G!==null?u("terminalView.stream.processExitedWithSignal",{signal:G}):""})),Ie(t,p,"exited"),Q(t,p,null),ae(t,p,!1),b(we?null:u("terminalView.error.sessionEnded")),A(!1),S(!1),o();break}}},onError:(x,y)=>{if(Z.current===r){if(!y){b(null),A(!1);return}S(!1),b(u("terminalView.error.connectionFailed",{message:x.message})),A(!0),ae(t,p,!1),ee(t,p),Ie(t,p,"exited"),Q(t,p,null),o()}}},g);ve.current=()=>{m.close(),Z.current=null}},[We,ee,o,Te,P,ae,Ie,Q,u,l]);n.useEffect(()=>{let t=!1;if(!se||!te)return;if(!v){b(u(Ue?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),o();return}return(async()=>{const r=v;if(!xe.current||xe.current!==r)return;Ve(r);const g=q.getState().getDirectoryState(r);if(!g||g.tabs.length===0)return;const m=O?g.activeTabId??g.tabs[0]?.id??null:g.tabs[0]?.id??null;if(!m)return;const x=g.tabs.find(He=>He.id===m)??g.tabs[0];let y=x?.terminalSessionId??null;const G=x?.lifecycle??"idle",Ee=!!x?.label?.startsWith("Action:"),we=(x?.bufferLength??0)>0||(x?.bufferChunks?.length??0)>0,Re=!!y&&Oe.current.has(y)&&(x?.bufferLength??0)===0&&(x?.bufferChunks?.length??0)===0,ut=!!y&&Oe.current.has(y);if(!y){if(G==="exited"){ae(r,m,!1);return}if(Ee&&we){ae(r,m,!1);return}const He=$e.current;if(!He&&De.current)return;b(null),A(!1),S(!1),ae(r,m,!0);try{const Ze=await l.createSession({cwd:r,cols:He?.cols,rows:He?.rows});if(!(!t&&xe.current===r&&ce.current===m)){try{await l.close(Ze.sessionId)}catch{}return}Q(r,m,Ze.sessionId),y=Ze.sessionId}catch(Ze){t||(b(Ze instanceof Error?Ze.message:u("terminalView.error.startSessionFailed")),A(!0),S(!1),ae(r,m,!1));return}}!y||t||(z.current=y,ut&&Oe.current.delete(y),Re&&(Ge.current=y),Y(r,m,y,ut?Gt:wt))})(),()=>{t=!0,z.current=null,o()}},[Ue,v,L,nt,D,te,qe,O,se,Ve,ae,Ie,Q,Y,o,u,l]),n.useEffect(()=>{if(!h||J)return;if(typeof window>"u"){Te();return}const t=window.requestAnimationFrame(()=>{Te()});return()=>{window.cancelAnimationFrame(t)}},[D,Te,h,J]);const me=n.useCallback(async()=>{if(!v||U)return;const t=q.getState().getDirectoryState(v),p=O?D??t?.activeTabId??t?.tabs[0]?.id??null:t?.tabs[0]?.id??null;if(p){Ye(!0),b(null),A(!1),S(!1),o(),ee(v,p),ze();try{await ie(v,p)}catch(r){b(r instanceof Error?r.message:u("terminalView.error.restartFailed")),A(!0),S(!1)}finally{Ye(!1)}}},[D,ee,ie,o,v,O,U,ze,u]),$=n.useCallback(async()=>{await me()},[me]),ke=n.useCallback(()=>{if(!v)return;const t=Le(v);be(v,t),b(null),A(!1),S(!1),o()},[Le,o,v,be]),k=n.useCallback(t=>{v&&(be(v,t),b(null),A(!1),S(!1),o())},[o,v,be]),ne=n.useCallback(t=>{v&&(t===D&&o(),b(null),A(!1),S(!1),ie(v,t))},[D,ie,o,v]),C=n.useCallback(t=>{if(!t||pe)return;let p=t,r=!1;if(F&&t.length>0){const m=t[0];if(m.length===1&&/[a-zA-Z]/.test(m)){const x=m.toUpperCase();(F==="ctrl"||F==="cmd")&&(p=String.fromCharCode(x.charCodeAt(0)&31),r=!0)}r||(r=!0)}const g=z.current;g&&(l.sendInput(g,p).catch(m=>{pe||b(m instanceof Error?m.message:u("terminalView.error.sendInputFailed"))}),r&&(N(null),e()))},[F,e,pe,N,u,l]),Ce=n.useCallback((t,p)=>{const r=$e.current;if((!r||r.cols!==t||r.rows!==p)&&($e.current={cols:t,rows:p},Xe(m=>m+1)),!De.current)return;const g=z.current;g&&l.resize({sessionId:g,cols:t,rows:p}).catch(()=>{})},[l]),Be=n.useCallback(t=>{N(p=>p===t?null:t),e()},[e,N]),H=n.useCallback(t=>{const p=_t(t,F);p&&(C(p),N(null),e())},[F,e,C,N]);n.useEffect(()=>{if(!B||!F||!L)return;const t=p=>{if(p.repeat)return;const r=p.key;if(!r||r==="Control"||r==="Meta"||r==="Alt"||r==="Shift")return;const g=r.length===1?r.toLowerCase():r,m=p.code??"",x=m.startsWith("Key")&&m.length===4?m.slice(3).toUpperCase():null,y=r.length===1&&/[a-zA-Z]/.test(r)?r.toUpperCase():x,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(g in G){p.preventDefault(),p.stopPropagation(),H(G[g]);return}if(F==="ctrl"&&y&&y.length===1&&y>="A"&&y<="Z"){const Ee=String.fromCharCode(y.charCodeAt(0)&31);p.preventDefault(),p.stopPropagation(),C(Ee),N(null),e()}};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[F,H,C,e,B,N,L]);const Qe=n.useMemo(()=>{const t=it[pt].stack;if(typeof window>"u")return(it[E]??it[pt]).stack;const r=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return r&&r.trim().length>0?r.trim():(it[E]??it[pt]).stack??t},[E]),j=n.useMemo(()=>jt(I),[I]),i=n.useMemo(()=>`${v??"no-dir"}::${D??"no-tab"}::${L??"no-terminal"}`,[v,D,L]);if(n.useEffect(()=>{if(!h||J)return;const t=Pe.current;if(!t)return;const p=()=>{t.fit()};if(typeof window<"u"){const r=window.requestAnimationFrame(()=>{p(),Te()}),g=[220,400].map(m=>window.setTimeout(p,m));return()=>{window.cancelAnimationFrame(r),g.forEach(m=>window.clearTimeout(m))}}p()},[Te,h,J,i,L]),n.useEffect(()=>{if(J||!h||!a)return;const t=Pe.current;if(!t)return;const p=()=>{t.fit()};if(typeof window<"u"){const r=window.requestAnimationFrame(()=>{p()}),g=[0,80,180,320].map(m=>window.setTimeout(p,m));return()=>{window.cancelAnimationFrame(r),g.forEach(m=>window.clearTimeout(m))}}p()},[_,ye,a,h,J]),!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(!v)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:me,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 W=!L||rt||U||pe,re=te,le=!Se&&a&&!T,ue=f.jsxs(f.Fragment,{children:[f.jsx(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 px-2 text-xs",onClick:()=>H("esc"),disabled:W,children:u("terminalView.quickKeys.escape")}),f.jsxs(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>H("tab"),disabled:W,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(oe,{type:"button",size:"sm",variant:"chip","aria-pressed":F==="ctrl",className:"h-6 w-9 p-0",onClick:()=>Be("ctrl"),disabled:W,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(oe,{type:"button",size:"sm",variant:"chip","aria-pressed":F==="cmd",className:"h-6 w-9 p-0",onClick:()=>Be("cmd"),disabled:W,children:[f.jsx(fe,{name:"command"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.commandModifierAria")})]}),f.jsxs(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>H("arrow-up"),disabled:W,children:[f.jsx(fe,{name:"arrow-up"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowUpAria")})]}),f.jsxs(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>H("arrow-left"),disabled:W,children:[f.jsx(fe,{name:"arrow-left"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowLeftAria")})]}),f.jsxs(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>H("arrow-down"),disabled:W,children:[f.jsx(fe,{name:"arrow-down"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowDownAria")})]}),f.jsxs(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>H("arrow-right"),disabled:W,children:[f.jsx(fe,{name:"arrow-right"}),f.jsx("span",{className:"sr-only",children:u("terminalView.quickKeys.arrowRightAria")})]}),f.jsxs(oe,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>H("enter"),disabled:W,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:et("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",Se?"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:et("min-w-0 flex-1",Se?"h-8":"h-7"),children:f.jsx(Nt,{items:Fe,activeId:D,onSelect:k,onClose:ne,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),f.jsx(oe,{type:"button",size:"xs",variant:"ghost",className:et("shrink-0",Se?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:ke,title:u("terminalView.tabs.newTabTitle"),children:f.jsx(fe,{name:"add",className:`${Se?"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(oe,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{v&&ge(v,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,le?f.jsxs(f.Fragment,{children:[f.jsx(oe,{type:"button",size:"xs",variant:"ghost",onClick:()=>s(!ye),className:et("shrink-0 p-0",R?"h-8 w-8":"h-7 w-7"),title:u(ye?"terminalView.bottomDock.restoreTitle":"terminalView.bottomDock.expandTitle"),"aria-label":u(ye?"terminalView.bottomDock.restoreAria":"terminalView.bottomDock.expandAria"),children:ye?f.jsx(fe,{name:"fullscreen-exit",className:"h-4 w-4"}):f.jsx(fe,{name:"fullscreen",className:"h-4 w-4"})}),f.jsx(oe,{type:"button",size:"xs",variant:"ghost",onClick:()=>w(!1),className:et("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&&B&&O&&V?f.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:ue}):null,B&&(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:j.background},children:[f.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:re?f.jsx(gt,{ref:t=>{Pe.current=t},sessionKey:i,chunks:dt,onInput:C,onResize:Ce,theme:j,fontFamily:Qe,fontSize:X,enableTouchScroll:J,autoFocus:!J&&h,isVisible:h},i):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}),ot&&R&&f.jsx(oe,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:$,disabled:U,title:u("terminalView.actions.hardRestartTitle"),type:"button",children:u("terminalView.actions.hardRestart")})]})]})]})};export{sn as TerminalView};
|