@openchamber/web 1.12.2 → 1.12.3

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.
Files changed (34) hide show
  1. package/dist/assets/{MarkdownRendererImpl-2INOOMmV.js → MarkdownRendererImpl-C2snGm6y.js} +1 -1
  2. package/dist/assets/{MultiRunWindow-BovvaCrr.js → MultiRunWindow-DXXoYCBh.js} +1 -1
  3. package/dist/assets/{NewWorktreeDialog-6y6rHfOQ.js → NewWorktreeDialog-C6394QE9.js} +1 -1
  4. package/dist/assets/OnboardingScreen-CLXmHHBW.js +1 -0
  5. package/dist/assets/{SessionSwitcherDropdown-DSXsR7zB.js → SessionSwitcherDropdown-BMN9gaXo.js} +1 -1
  6. package/dist/assets/{SettingsWindow-Dll7W_Kd.js → SettingsWindow-DXEjjH2f.js} +1 -1
  7. package/dist/assets/{TerminalView-D_ktT_L5.js → TerminalView-CePdcScA.js} +1 -1
  8. package/dist/assets/{es-9Cy-lgBh.js → es-rCA6AcBs.js} +1 -1
  9. package/dist/assets/{ko-BxmPoeb2.js → ko-CTiirGAp.js} +1 -1
  10. package/dist/assets/{main-BpZQobwD.js → main-D1IN8sAs.js} +2 -2
  11. package/dist/assets/{main-D8KFwoUt.js → main-DIwL7PaU.js} +46 -46
  12. package/dist/assets/{miniChat-BdEth0Oc.js → miniChat-DXW_W4_n.js} +2 -2
  13. package/dist/assets/{mobile-BxWzNO1C.js → mobile-DWyy0wq-.js} +2 -2
  14. package/dist/assets/{pl-J7oKZUR2.js → pl-CwJAYYhT.js} +1 -1
  15. package/dist/assets/{pt-BR-p6gRuJwx.js → pt-BR-xndordtt.js} +1 -1
  16. package/dist/assets/{renderElectronMiniChatApp-MNKYhIaT.js → renderElectronMiniChatApp-BmvjGDb_.js} +2 -2
  17. package/dist/assets/{renderMobileApp-DpYY7X9v.js → renderMobileApp-1BEmeUF9.js} +3 -3
  18. package/dist/assets/{uk-BOvMb8eG.js → uk-C52rE_cP.js} +1 -1
  19. package/dist/assets/{useAppFontEffects-DEZpweZZ.js → useAppFontEffects-hYm-4PtP.js} +4 -4
  20. package/dist/assets/{zh-CN-Cv0tBxN1.js → zh-CN-B7IfGwyh.js} +1 -1
  21. package/dist/assets/{zh-TW-CS7R6Ak3.js → zh-TW-DiO_1_-_.js} +1 -1
  22. package/dist/index.html +1 -1
  23. package/dist/mini-chat.html +1 -1
  24. package/dist/mobile.html +1 -1
  25. package/package.json +1 -1
  26. package/server/index.js +0 -15
  27. package/server/lib/fs/routes.js +28 -2
  28. package/server/lib/opencode/env-runtime.js +20 -158
  29. package/server/lib/opencode/env-runtime.test.js +38 -11
  30. package/server/lib/opencode/lifecycle.js +5 -24
  31. package/server/lib/opencode/lifecycle.test.js +0 -2
  32. package/server/lib/opencode/network-runtime.js +1 -1
  33. package/server/lib/opencode/routes.js +1 -1
  34. package/dist/assets/OnboardingScreen-B1Ft9kmW.js +0 -1
@@ -1 +1 @@
1
- import{c as te,R as Ne,j as s,H as Oe,b as Ue,aP as Me}from"./vendor-.bun-TPgXvEwq.js";import{u as Pe,m as X,H,ak as Ae,M as Fe,aj as Be,ai as Re,aS as _e,bN as We,x as Ge,D as He,cn as Je,cE as $e,cq as Ie,fn as Ke,T as Ce,as as qe,au as Xe,av as Ye,y as Le,cZ as Ze,c$ as Qe,aR as Ve,d5 as et}from"./useAppFontEffects-DEZpweZZ.js";const zt=n=>{const e=te.c(110),{totalTokens:t,percentage:c,colorPercentage:i,contextLimit:d,outputLimit:m,size:f,isMobile:w,hideIcon:l,showPercentIcon:o,className:u,valueClassName:j,percentIconClassName:p,onClick:x,pressed:g}=n,y=f===void 0?"default":f,h=w===void 0?!1:w,v=l===void 0?!1:l,N=o===void 0?!1:o,C=g===void 0?!1:g,{t:r}=Pe(),[_,b]=Ne.useState(!1),a=typeof i=="number"?i:c,S=tt,P=st,k=typeof m=="number"?Math.max(m,0):0;let I;e[0]!==r||e[1]!==t?(I=r("contextUsage.tooltip.usedTokens",{tokens:S(t)}),e[0]=r,e[1]=t,e[2]=I):I=e[2];let L;e[3]!==d||e[4]!==r?(L=r("contextUsage.tooltip.contextLimit",{tokens:S(d)}),e[3]=d,e[4]=r,e[5]=L):L=e[5];let J;e[6]!==k||e[7]!==r?(J=r("contextUsage.tooltip.outputLimit",{tokens:S(k)}),e[6]=k,e[7]=r,e[8]=J):J=e[8];let Y;e[9]!==I||e[10]!==L||e[11]!==J?(Y=[I,L,J],e[9]=I,e[10]=L,e[11]=J,e[12]=Y):Y=e[12];const Q=Y,T=!h&&typeof x=="function";let K;e[13]!==v||e[14]!==h?(K=!h&&!v&&s.jsx(H,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e[13]=v,e[14]=h,e[15]=K):K=e[15];let O;e[16]!==j?(O=X("font-medium inline-flex items-center gap-1.5",j),e[16]=j,e[17]=O):O=e[17];let U;e[18]!==a||e[19]!==p||e[20]!==c||e[21]!==N?(U=N?s.jsxs(s.Fragment,{children:[s.jsx(H,{name:"donut-chart-fill",className:X("h-3.5 w-3.5",p,P(a)),"aria-hidden":"true"}),s.jsxs("span",{className:"text-foreground",children:[Math.min(c,999).toFixed(1),"%"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:P(a),children:Math.min(c,999).toFixed(1)}),"%"]}),e[18]=a,e[19]=p,e[20]=c,e[21]=N,e[22]=U):U=e[22];let q;e[23]!==O||e[24]!==U?(q=s.jsx("span",{className:O,children:U}),e[23]=O,e[24]=U,e[25]=q):q=e[25];let A;e[26]!==K||e[27]!==q?(A=s.jsxs(s.Fragment,{children:[K,q]}),e[26]=K,e[27]=q,e[28]=A):A=e[28];const Z=A,ee=y==="compact"?"typography-micro":"typography-meta";let F;e[29]!==u||e[30]!==T||e[31]!==ee?(F=X("app-region-no-drag flex items-center gap-1.5 select-none",ee,T?X("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",u),e[29]=u,e[30]=T,e[31]=ee,e[32]=F):F=e[32];const B=F;let V;e[33]!==Z||e[34]!==T||e[35]!==h||e[36]!==x||e[37]!==C||e[38]!==B||e[39]!==r?(V=T?s.jsx("button",{type:"button",className:B,"aria-label":r("contextUsage.aria.label"),"aria-pressed":C,onClick:x,children:Z}):s.jsx("div",{className:B,"aria-label":r("contextUsage.aria.label"),onClick:h?()=>b(!0):void 0,children:Z}),e[33]=Z,e[34]=T,e[35]=h,e[36]=x,e[37]=C,e[38]=B,e[39]=r,e[40]=V):V=e[40];const $=V;if(h){let W;e[41]===Symbol.for("react.memo_cache_sentinel")?(W=()=>b(!1),e[41]=W):W=e[41];let E;e[42]!==r?(E=r("contextUsage.mobile.title"),e[42]=r,e[43]=E):E=e[43];let G;e[44]!==r?(G=r("contextUsage.mobile.usedTokens"),e[44]=r,e[45]=G):G=e[45];let D;e[46]!==G?(D=s.jsx("span",{className:"typography-meta text-muted-foreground",children:G}),e[46]=G,e[47]=D):D=e[47];let se;e[48]!==t?(se=S(t),e[48]=t,e[49]=se):se=e[49];let ne;e[50]!==se?(ne=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:se}),e[50]=se,e[51]=ne):ne=e[51];let ie;e[52]!==D||e[53]!==ne?(ie=s.jsxs("div",{className:"flex justify-between items-center",children:[D,ne]}),e[52]=D,e[53]=ne,e[54]=ie):ie=e[54];let oe;e[55]!==r?(oe=r("contextUsage.mobile.contextLimit"),e[55]=r,e[56]=oe):oe=e[56];let re;e[57]!==oe?(re=s.jsx("span",{className:"typography-meta text-muted-foreground",children:oe}),e[57]=oe,e[58]=re):re=e[58];let le;e[59]!==d?(le=S(d),e[59]=d,e[60]=le):le=e[60];let ae;e[61]!==le?(ae=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:le}),e[61]=le,e[62]=ae):ae=e[62];let ce;e[63]!==re||e[64]!==ae?(ce=s.jsxs("div",{className:"flex justify-between items-center",children:[re,ae]}),e[63]=re,e[64]=ae,e[65]=ce):ce=e[65];let de;e[66]!==r?(de=r("contextUsage.mobile.outputLimit"),e[66]=r,e[67]=de):de=e[67];let ue;e[68]!==de?(ue=s.jsx("span",{className:"typography-meta text-muted-foreground",children:de}),e[68]=de,e[69]=ue):ue=e[69];let me;e[70]!==k?(me=S(k),e[70]=k,e[71]=me):me=e[71];let fe;e[72]!==me?(fe=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:me}),e[72]=me,e[73]=fe):fe=e[73];let pe;e[74]!==ue||e[75]!==fe?(pe=s.jsxs("div",{className:"flex justify-between items-center",children:[ue,fe]}),e[74]=ue,e[75]=fe,e[76]=pe):pe=e[76];let he;e[77]!==r?(he=r("contextUsage.mobile.usage"),e[77]=r,e[78]=he):he=e[78];let xe;e[79]!==he?(xe=s.jsx("span",{className:"typography-meta text-muted-foreground",children:he}),e[79]=he,e[80]=xe):xe=e[80];let ge;e[81]!==a?(ge=X("typography-meta font-semibold",P(a)),e[81]=a,e[82]=ge):ge=e[82];const ke=Math.min(c,999);let be;e[83]!==ke?(be=ke.toFixed(1),e[83]=ke,e[84]=be):be=e[84];let we;e[85]!==ge||e[86]!==be?(we=s.jsxs("span",{className:ge,children:[be,"%"]}),e[85]=ge,e[86]=be,e[87]=we):we=e[87];let je;e[88]!==xe||e[89]!==we?(je=s.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[xe,we]}),e[88]=xe,e[89]=we,e[90]=je):je=e[90];let ye;e[91]!==ie||e[92]!==ce||e[93]!==pe||e[94]!==je?(ye=s.jsx("div",{className:"flex flex-col gap-1.5",children:s.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[ie,ce,pe,je]})}),e[91]=ie,e[92]=ce,e[93]=pe,e[94]=je,e[95]=ye):ye=e[95];let ve;e[96]!==_||e[97]!==E||e[98]!==ye?(ve=s.jsx(Fe,{open:_,onClose:W,title:E,children:ye}),e[96]=_,e[97]=E,e[98]=ye,e[99]=ve):ve=e[99];let Se;return e[100]!==$||e[101]!==ve?(Se=s.jsxs(s.Fragment,{children:[$,ve]}),e[100]=$,e[101]=ve,e[102]=Se):Se=e[102],Se}let z;e[103]!==$?(z=s.jsx(Be,{asChild:!0,children:$}),e[103]=$,e[104]=z):z=e[104];let M;e[105]!==Q?(M=s.jsx(Ae,{children:s.jsx("div",{className:"space-y-0.5",children:Q.map(nt)})}),e[105]=Q,e[106]=M):M=e[106];let R;return e[107]!==z||e[108]!==M?(R=s.jsxs(Re,{children:[z,M]}),e[107]=z,e[108]=M,e[109]=R):R=e[109],R};function tt(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:n.toFixed(1).replace(/\.0$/,"")}function st(n){return n>=90?"text-status-error":n>=75?"text-status-warning":"text-status-success"}function nt(n){return s.jsx("p",{className:"typography-micro leading-tight",children:n},n)}const Mt=Ne.memo(function(e){const t=te.c(40),{visible:c}=e,{t:i}=Pe(),[d,m]=Ne.useState(!1);let f,w;if(t[0]!==c?(f=()=>{if(!c)return;let P=!1;_e("desktop_get_current_window_state").then(I=>{P||m(!!I?.maximized)}).catch(it);const k=I=>{const L=I.detail;m(!!L?.maximized)};return window.addEventListener("openchamber:window-maximized-changed",k),()=>{P=!0,window.removeEventListener("openchamber:window-maximized-changed",k)}},w=[c],t[0]=c,t[1]=f,t[2]=w):(f=t[1],w=t[2]),Oe.useEffect(f,w),!c)return null;let l;t[3]!==i?(l=i("header.windowControls.groupAria"),t[3]=i,t[4]=l):l=t[4];let o;t[5]!==i?(o=i("header.windowControls.minimize"),t[5]=i,t[6]=o):o=t[6];let u;t[7]!==i?(u=i("header.windowControls.minimize"),t[7]=i,t[8]=u):u=t[8];let j;t[9]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(H,{name:"subtract",className:"h-4 w-4"}),t[9]=j):j=t[9];let p;t[10]!==o||t[11]!==u?(p=s.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:ot,title:o,"aria-label":u,children:j}),t[10]=o,t[11]=u,t[12]=p):p=t[12];let x;t[13]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{_e("desktop_toggle_current_window_maximized").then(P=>m(!!P?.maximized)).catch(rt)},t[13]=x):x=t[13];let g;t[14]!==d||t[15]!==i?(g=i(d?"header.windowControls.restore":"header.windowControls.maximize"),t[14]=d,t[15]=i,t[16]=g):g=t[16];let y;t[17]!==d||t[18]!==i?(y=i(d?"header.windowControls.restore":"header.windowControls.maximize"),t[17]=d,t[18]=i,t[19]=y):y=t[19];const h=d?"fullscreen-exit":"checkbox-blank";let v;t[20]!==h?(v=s.jsx(H,{name:h,className:"h-3.5 w-3.5"}),t[20]=h,t[21]=v):v=t[21];let N;t[22]!==y||t[23]!==v||t[24]!==g?(N=s.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:x,title:g,"aria-label":y,children:v}),t[22]=y,t[23]=v,t[24]=g,t[25]=N):N=t[25];let C;t[26]===Symbol.for("react.memo_cache_sentinel")?(C=X("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 r;t[27]!==i?(r=i("header.windowControls.close"),t[27]=i,t[28]=r):r=t[28];let _;t[29]!==i?(_=i("header.windowControls.close"),t[29]=i,t[30]=_):_=t[30];let b;t[31]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(H,{name:"close",className:"h-4 w-4"}),t[31]=b):b=t[31];let a;t[32]!==r||t[33]!==_?(a=s.jsx("button",{type:"button",className:C,onClick:lt,title:r,"aria-label":_,children:b}),t[32]=r,t[33]=_,t[34]=a):a=t[34];let S;return t[35]!==N||t[36]!==a||t[37]!==l||t[38]!==p?(S=s.jsxs("div",{className:"app-region-no-drag -mr-3 ml-2 flex h-12 shrink-0 items-center","aria-label":l,children:[p,N,a]}),t[35]=N,t[36]=a,t[37]=l,t[38]=p,t[39]=S):S=t[39],S});function it(){}function ot(){_e("desktop_minimize_current_window")}function rt(){}function lt(){_e("desktop_close_current_window")}const Ee="oc.sessions.pinned",at=n=>{try{const e=n.getItem(Ee);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(c=>typeof c=="string")):new Set}catch{return new Set}},ze=(n,e)=>{try{n.setItem(Ee,JSON.stringify([...e]))}catch{}},De=We(),ct=Ue((n,e)=>({ids:at(De),setIds:t=>{const c=e().ids,i=typeof t=="function"?t(c):t;i!==c&&(n({ids:i}),ze(De,i))},toggle:t=>{const c=e().ids,i=new Set(c);i.has(t)?i.delete(t):i.add(t),n({ids:i}),ze(De,i)}})),dt=7,ut=n=>{if(!n)return null;const e=n.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},mt=n=>{if(!n)return null;const e=n.label?.trim();if(e)return e;const t=n.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},ft=(n,e)=>{const t=te.c(18);let c;t[0]!==e?(c=e===void 0?{}:e,t[0]=e,t[1]=c):c=t[1];const i=c,{scopeProjectId:d}=i,m=d===void 0?null:d,f=Ge(pt),w=He(ht),l=ct(xt),o=Je();let u;t[2]!==w?(u=w.map(gt).filter(bt),t[2]=w,t[3]=u):u=t[3];const j=u;let p;t[4]!==j?(p=h=>h?j.filter(N=>Ke(h,N.normalizedPath)).sort(wt)[0]??null:null,t[4]=j,t[5]=p):p=t[5];const x=p;let g;{let h;if(t[7]!==f||t[8]!==o||t[9]!==x||t[10]!==l||t[11]!==m){const v=new Map;for(const b of f){const a=b.parentID;if(!a||b.time?.archived)continue;const S=v.get(a);S?S.push(b):v.set(a,[b])}v.forEach(b=>{b.sort((a,S)=>$e(a,S,l))});let N;t[13]!==x||t[14]!==m?(N=b=>{if(!m)return!0;const a=Ie(b);return x(a)?.id===m},t[13]=x,t[14]=m,t[15]=N):N=t[15];let C;t[16]!==l?(C=(b,a)=>$e(b,a,l),t[16]=l,t[17]=C):C=t[17];const r=f.filter(jt).filter(yt).filter(N).sort(C).slice(0,dt),_=b=>{const a=v.get(b.id)??[];return{session:b,children:a.map(S=>_(S)),worktree:null}};h=r.map(b=>{const a=Ie(b),S=x(a),P=mt(S),k=a?o.get(a)??null:null;return{node:_(b),projectId:S?.id??null,groupDirectory:a,secondaryMeta:{projectLabel:P,branchLabel:k&&k!==P?k:null}}}),t[7]=f,t[8]=o,t[9]=x,t[10]=l,t[11]=m,t[12]=h}else h=t[12];g=h}return g};function pt(n){return n.activeSessions}function ht(n){return n.projects}function xt(n){return n.ids}function gt(n){return{...n,normalizedPath:ut(n.path)}}function bt(n){return n.normalizedPath}function wt(n,e){return(e.normalizedPath?.length??0)-(n.normalizedPath?.length??0)}function jt(n){return!n.time?.archived}function yt(n){return!n.parentID}function Et(n){const e=te.c(18),{children:t,variant:c,scopeProjectId:i,align:d}=n,m=c===void 0?"default":c,f=i===void 0?null:i,w=d===void 0?"start":d,l=Ce(St),o=Ce(vt);let u;e[0]!==t?(u=s.jsx(qe,{asChild:!0,children:t}),e[0]=t,e[1]=u):u=e[1];const j=m==="compact"?"w-[280px]":"w-[360px]";let p;e[2]!==j?(p=X("overflow-hidden p-1 max-w-[calc(100vw-32px)]",j),e[2]=j,e[3]=p):p=e[3];let x;e[4]!==l||e[5]!==f||e[6]!==o||e[7]!==m?(x=l?s.jsx(Nt,{onSelect:()=>o(!1),variant:m,scopeProjectId:f}):null,e[4]=l,e[5]=f,e[6]=o,e[7]=m,e[8]=x):x=e[8];let g;e[9]!==w||e[10]!==p||e[11]!==x?(g=s.jsx(Xe,{align:w,sideOffset:6,className:p,children:x}),e[9]=w,e[10]=p,e[11]=x,e[12]=g):g=e[12];let y;return e[13]!==l||e[14]!==o||e[15]!==u||e[16]!==g?(y=s.jsxs(Ye,{open:l,onOpenChange:o,modal:!1,children:[u,g]}),e[13]=l,e[14]=o,e[15]=u,e[16]=g,e[17]=y):y=e[17],y}function vt(n){return n.setSessionDropdownOpen}function St(n){return n.isSessionDropdownOpen}function Nt(n){const e=te.c(26),{onSelect:t,variant:c,scopeProjectId:i}=n;let d;e[0]!==i?(d={scopeProjectId:i},e[0]=i,e[1]=d):d=e[1];const m=ft(!0,d),f=Le(Ct),w=Ce(_t),{t:l}=Pe();let o;e[2]!==t||e[3]!==f||e[4]!==w?(o=()=>{w("chat"),t(),f()},e[2]=t,e[3]=f,e[4]=w,e[5]=o):o=e[5];const u=o;let j;e[6]===Symbol.for("react.memo_cache_sentinel")?(j=new Set,e[6]=j):j=e[6];const[p,x]=Ne.useState(j);let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=a=>{x(S=>{const P=new Set(S);return P.has(a)?P.delete(a):P.add(a),P})},e[7]=g):g=e[7];const y=g;let h,v;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=X("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"),v=s.jsx(H,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e[8]=h,e[9]=v):(h=e[8],v=e[9]);let N;e[10]!==l?(N=l("sessions.sidebar.header.actions.newSession"),e[10]=l,e[11]=N):N=e[11];let C;e[12]!==N?(C=s.jsx("span",{className:"truncate text-[14px] font-normal leading-tight text-foreground",children:N}),e[12]=N,e[13]=C):C=e[13];let r;e[14]!==u||e[15]!==C?(r=s.jsxs(Me,{onClick:u,className:h,children:[v,C]}),e[14]=u,e[15]=C,e[16]=r):r=e[16];let _;e[17]!==p||e[18]!==m||e[19]!==t||e[20]!==l||e[21]!==c?(_=m.length===0?s.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:l("sessions.switcher.empty")}):m.map(a=>s.jsx(Te,{item:a,depth:0,variant:c,expandedParents:p,toggleParent:y,closeDropdown:t},a.node.session.id)),e[17]=p,e[18]=m,e[19]=t,e[20]=l,e[21]=c,e[22]=_):_=e[22];let b;return e[23]!==_||e[24]!==r?(b=s.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:s.jsxs("div",{className:"space-y-0.5",children:[r,_]})}),e[23]=_,e[24]=r,e[25]=b):b=e[25],b}function _t(n){return n.setActiveMainTab}function Ct(n){return n.openNewSessionDraft}function Te(n){const e=te.c(31),{item:t,depth:c,variant:i,expandedParents:d,toggleParent:m,closeDropdown:f}=n,{node:w,secondaryMeta:l}=t,o=w.session,u=w.children.length>0;let j;e[0]!==d||e[1]!==o.id?(j=d.has(o.id),e[0]=d,e[1]=o.id,e[2]=j):j=e[2];const p=j;let x;e[3]!==u||e[4]!==o.id||e[5]!==m?(x=u?()=>m(o.id):void 0,e[3]=u,e[4]=o.id,e[5]=m,e[6]=x):x=e[6];let g;e[7]!==f||e[8]!==c||e[9]!==u||e[10]!==p||e[11]!==l||e[12]!==o||e[13]!==x||e[14]!==i?(g=s.jsx(Pt,{session:o,depth:c,variant:i,secondaryMeta:l,hasChildren:u,isExpanded:p,onToggleExpand:x,closeDropdown:f}),e[7]=f,e[8]=c,e[9]=u,e[10]=p,e[11]=l,e[12]=o,e[13]=x,e[14]=i,e[15]=g):g=e[15];let y;e[16]!==f||e[17]!==c||e[18]!==d||e[19]!==u||e[20]!==p||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==w.children||e[24]!==l||e[25]!==m||e[26]!==i?(y=u&&p?w.children.map(v=>s.jsx(Te,{item:{node:v,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:l},depth:c+1,variant:i,expandedParents:d,toggleParent:m,closeDropdown:f},v.session.id)):null,e[16]=f,e[17]=c,e[18]=d,e[19]=u,e[20]=p,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=w.children,e[24]=l,e[25]=m,e[26]=i,e[27]=y):y=e[27];let h;return e[28]!==g||e[29]!==y?(h=s.jsxs(s.Fragment,{children:[g,y]}),e[28]=g,e[29]=y,e[30]=h):h=e[30],h}function Pt(n){const e=te.c(60),{session:t,depth:c,variant:i,secondaryMeta:d,hasChildren:m,isExpanded:f,onToggleExpand:w,closeDropdown:l}=n,{t:o}=Pe(),u=Le(It),j=Le(Dt),p=Ce(kt),x=Ze(t.id),g=Qe(t.id),y=u===t.id;let h;e[0]!==t.title||e[1]!==o?(h=t.title?.trim()||o("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=o,e[2]=h):h=e[2];const v=h,N=!!t.parentID,C=g>0&&(!N||p),r=x?.type??"idle",_=r==="busy"||r==="retry",b=!_&&C&&!y,a=t.summary;let S;e[3]!==a?(S=Ve(a),e[3]=a,e[4]=S):S=e[4];const P=S;let k;e[5]!==t.time?.created||e[6]!==t.time?.updated?(k=t.time?.updated||t.time?.created||Date.now(),e[5]=t.time?.created,e[6]=t.time?.updated,e[7]=k):k=e[7];const I=k;let L;e[8]!==I?(L=et(I),e[8]=I,e[9]=L):L=e[9];const J=L;let Y;e[10]!==d?.projectLabel?(Y=d?.projectLabel?.trim()||null,e[10]=d?.projectLabel,e[11]=Y):Y=e[11];const Q=Y;let T;e[12]!==d?.branchLabel?(T=d?.branchLabel?.trim()||null,e[12]=d?.branchLabel,e[13]=T):T=e[13];const K=T,O=K&&K!=="HEAD"?K:null;let U;e[14]!==l||e[15]!==y||e[16]!==t||e[17]!==j?(U=()=>{if(y){l();return}const D=Ie(t);j(t.id,D??null),l()},e[14]=l,e[15]=y,e[16]=t,e[17]=j,e[18]=U):U=e[18];const q=U;let A;e[19]!==q?(A=D=>{if(D.target?.closest("[data-switcher-expand]")){D.preventDefault();return}q()},e[19]=q,e[20]=A):A=e[20];let Z;e[21]===Symbol.for("react.memo_cache_sentinel")?(Z=X("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[21]=Z):Z=e[21];const ee=8+c*12;let F;e[22]!==ee?(F={paddingLeft:ee},e[22]=ee,e[23]=F):F=e[23];let B;e[24]!==m||e[25]!==f||e[26]!==w||e[27]!==o||e[28]!==i?(B=i==="compact"&&m?s.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:D=>{D.preventDefault(),D.stopPropagation(),w?.()},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":o(f?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:f?s.jsx(H,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):s.jsx(H,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[24]=m,e[25]=f,e[26]=w,e[27]=o,e[28]=i,e[29]=B):B=e[29];const V=y?"text-primary":"text-foreground";let $;e[30]!==V?($=X("truncate text-[14px] font-normal leading-tight",V),e[30]=V,e[31]=$):$=e[31];let z;e[32]!==v||e[33]!==$?(z=s.jsx("span",{className:$,children:v}),e[32]=v,e[33]=$,e[34]=z):z=e[34];let M;e[35]!==B||e[36]!==z?(M=s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[B,z]}),e[35]=B,e[36]=z,e[37]=M):M=e[37];let R;e[38]!==O||e[39]!==P||e[40]!==m||e[41]!==f||e[42]!==w||e[43]!==Q||e[44]!==o||e[45]!==J||e[46]!==i?(R=i==="default"?s.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:[m?s.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:D=>{D.preventDefault(),D.stopPropagation(),w?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":o(f?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:f?s.jsx(H,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(H,{name:"arrow-right-s",className:"h-3 w-3"})}):null,s.jsx("span",{className:"flex-shrink-0",children:J}),Q?s.jsx("span",{className:"truncate",children:Q}):null,O?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(H,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:O})]}):null,P?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-0 text-[0.92em]",children:[s.jsxs("span",{className:"text-status-success/80",children:["+",P.additions]}),s.jsx("span",{className:"text-muted-foreground/60",children:"/"}),s.jsxs("span",{className:"text-status-error/65",children:["-",P.deletions]})]}):null]}):null,e[38]=O,e[39]=P,e[40]=m,e[41]=f,e[42]=w,e[43]=Q,e[44]=o,e[45]=J,e[46]=i,e[47]=R):R=e[47];let W;e[48]!==M||e[49]!==R?(W=s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[M,R]}),e[48]=M,e[49]=R,e[50]=W):W=e[50];let E;e[51]!==_||e[52]!==b||e[53]!==o?(E=_||b?s.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:_?s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":o("sessions.sidebar.session.status.active"),title:o("sessions.sidebar.session.status.active")}):s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":o("sessions.sidebar.session.status.unread"),title:o("sessions.sidebar.session.status.unread")})}):null,e[51]=_,e[52]=b,e[53]=o,e[54]=E):E=e[54];let G;return e[55]!==F||e[56]!==W||e[57]!==E||e[58]!==A?(G=s.jsxs(Me,{onClick:A,"data-slot":"session-switcher-item",className:Z,style:F,children:[W,E]}),e[55]=F,e[56]=W,e[57]=E,e[58]=A,e[59]=G):G=e[59],G}function kt(n){return n.notifyOnSubtasks}function Dt(n){return n.setCurrentSession}function It(n){return n.currentSessionId}export{zt as C,Et as S,Mt as W,ct as u};
1
+ import{c as te,R as Ne,j as s,H as Oe,b as Ue,aP as Me}from"./vendor-.bun-TPgXvEwq.js";import{u as Pe,m as X,H,ak as Ae,M as Fe,aj as Be,ai as Re,aS as _e,bN as We,x as Ge,D as He,cn as Je,cE as $e,cq as Ie,fn as Ke,T as Ce,as as qe,au as Xe,av as Ye,y as Le,cZ as Ze,c$ as Qe,aR as Ve,d5 as et}from"./useAppFontEffects-hYm-4PtP.js";const zt=n=>{const e=te.c(110),{totalTokens:t,percentage:c,colorPercentage:i,contextLimit:d,outputLimit:m,size:f,isMobile:w,hideIcon:l,showPercentIcon:o,className:u,valueClassName:j,percentIconClassName:p,onClick:x,pressed:g}=n,y=f===void 0?"default":f,h=w===void 0?!1:w,v=l===void 0?!1:l,N=o===void 0?!1:o,C=g===void 0?!1:g,{t:r}=Pe(),[_,b]=Ne.useState(!1),a=typeof i=="number"?i:c,S=tt,P=st,k=typeof m=="number"?Math.max(m,0):0;let I;e[0]!==r||e[1]!==t?(I=r("contextUsage.tooltip.usedTokens",{tokens:S(t)}),e[0]=r,e[1]=t,e[2]=I):I=e[2];let L;e[3]!==d||e[4]!==r?(L=r("contextUsage.tooltip.contextLimit",{tokens:S(d)}),e[3]=d,e[4]=r,e[5]=L):L=e[5];let J;e[6]!==k||e[7]!==r?(J=r("contextUsage.tooltip.outputLimit",{tokens:S(k)}),e[6]=k,e[7]=r,e[8]=J):J=e[8];let Y;e[9]!==I||e[10]!==L||e[11]!==J?(Y=[I,L,J],e[9]=I,e[10]=L,e[11]=J,e[12]=Y):Y=e[12];const Q=Y,T=!h&&typeof x=="function";let K;e[13]!==v||e[14]!==h?(K=!h&&!v&&s.jsx(H,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e[13]=v,e[14]=h,e[15]=K):K=e[15];let O;e[16]!==j?(O=X("font-medium inline-flex items-center gap-1.5",j),e[16]=j,e[17]=O):O=e[17];let U;e[18]!==a||e[19]!==p||e[20]!==c||e[21]!==N?(U=N?s.jsxs(s.Fragment,{children:[s.jsx(H,{name:"donut-chart-fill",className:X("h-3.5 w-3.5",p,P(a)),"aria-hidden":"true"}),s.jsxs("span",{className:"text-foreground",children:[Math.min(c,999).toFixed(1),"%"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:P(a),children:Math.min(c,999).toFixed(1)}),"%"]}),e[18]=a,e[19]=p,e[20]=c,e[21]=N,e[22]=U):U=e[22];let q;e[23]!==O||e[24]!==U?(q=s.jsx("span",{className:O,children:U}),e[23]=O,e[24]=U,e[25]=q):q=e[25];let A;e[26]!==K||e[27]!==q?(A=s.jsxs(s.Fragment,{children:[K,q]}),e[26]=K,e[27]=q,e[28]=A):A=e[28];const Z=A,ee=y==="compact"?"typography-micro":"typography-meta";let F;e[29]!==u||e[30]!==T||e[31]!==ee?(F=X("app-region-no-drag flex items-center gap-1.5 select-none",ee,T?X("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",u),e[29]=u,e[30]=T,e[31]=ee,e[32]=F):F=e[32];const B=F;let V;e[33]!==Z||e[34]!==T||e[35]!==h||e[36]!==x||e[37]!==C||e[38]!==B||e[39]!==r?(V=T?s.jsx("button",{type:"button",className:B,"aria-label":r("contextUsage.aria.label"),"aria-pressed":C,onClick:x,children:Z}):s.jsx("div",{className:B,"aria-label":r("contextUsage.aria.label"),onClick:h?()=>b(!0):void 0,children:Z}),e[33]=Z,e[34]=T,e[35]=h,e[36]=x,e[37]=C,e[38]=B,e[39]=r,e[40]=V):V=e[40];const $=V;if(h){let W;e[41]===Symbol.for("react.memo_cache_sentinel")?(W=()=>b(!1),e[41]=W):W=e[41];let E;e[42]!==r?(E=r("contextUsage.mobile.title"),e[42]=r,e[43]=E):E=e[43];let G;e[44]!==r?(G=r("contextUsage.mobile.usedTokens"),e[44]=r,e[45]=G):G=e[45];let D;e[46]!==G?(D=s.jsx("span",{className:"typography-meta text-muted-foreground",children:G}),e[46]=G,e[47]=D):D=e[47];let se;e[48]!==t?(se=S(t),e[48]=t,e[49]=se):se=e[49];let ne;e[50]!==se?(ne=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:se}),e[50]=se,e[51]=ne):ne=e[51];let ie;e[52]!==D||e[53]!==ne?(ie=s.jsxs("div",{className:"flex justify-between items-center",children:[D,ne]}),e[52]=D,e[53]=ne,e[54]=ie):ie=e[54];let oe;e[55]!==r?(oe=r("contextUsage.mobile.contextLimit"),e[55]=r,e[56]=oe):oe=e[56];let re;e[57]!==oe?(re=s.jsx("span",{className:"typography-meta text-muted-foreground",children:oe}),e[57]=oe,e[58]=re):re=e[58];let le;e[59]!==d?(le=S(d),e[59]=d,e[60]=le):le=e[60];let ae;e[61]!==le?(ae=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:le}),e[61]=le,e[62]=ae):ae=e[62];let ce;e[63]!==re||e[64]!==ae?(ce=s.jsxs("div",{className:"flex justify-between items-center",children:[re,ae]}),e[63]=re,e[64]=ae,e[65]=ce):ce=e[65];let de;e[66]!==r?(de=r("contextUsage.mobile.outputLimit"),e[66]=r,e[67]=de):de=e[67];let ue;e[68]!==de?(ue=s.jsx("span",{className:"typography-meta text-muted-foreground",children:de}),e[68]=de,e[69]=ue):ue=e[69];let me;e[70]!==k?(me=S(k),e[70]=k,e[71]=me):me=e[71];let fe;e[72]!==me?(fe=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:me}),e[72]=me,e[73]=fe):fe=e[73];let pe;e[74]!==ue||e[75]!==fe?(pe=s.jsxs("div",{className:"flex justify-between items-center",children:[ue,fe]}),e[74]=ue,e[75]=fe,e[76]=pe):pe=e[76];let he;e[77]!==r?(he=r("contextUsage.mobile.usage"),e[77]=r,e[78]=he):he=e[78];let xe;e[79]!==he?(xe=s.jsx("span",{className:"typography-meta text-muted-foreground",children:he}),e[79]=he,e[80]=xe):xe=e[80];let ge;e[81]!==a?(ge=X("typography-meta font-semibold",P(a)),e[81]=a,e[82]=ge):ge=e[82];const ke=Math.min(c,999);let be;e[83]!==ke?(be=ke.toFixed(1),e[83]=ke,e[84]=be):be=e[84];let we;e[85]!==ge||e[86]!==be?(we=s.jsxs("span",{className:ge,children:[be,"%"]}),e[85]=ge,e[86]=be,e[87]=we):we=e[87];let je;e[88]!==xe||e[89]!==we?(je=s.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[xe,we]}),e[88]=xe,e[89]=we,e[90]=je):je=e[90];let ye;e[91]!==ie||e[92]!==ce||e[93]!==pe||e[94]!==je?(ye=s.jsx("div",{className:"flex flex-col gap-1.5",children:s.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[ie,ce,pe,je]})}),e[91]=ie,e[92]=ce,e[93]=pe,e[94]=je,e[95]=ye):ye=e[95];let ve;e[96]!==_||e[97]!==E||e[98]!==ye?(ve=s.jsx(Fe,{open:_,onClose:W,title:E,children:ye}),e[96]=_,e[97]=E,e[98]=ye,e[99]=ve):ve=e[99];let Se;return e[100]!==$||e[101]!==ve?(Se=s.jsxs(s.Fragment,{children:[$,ve]}),e[100]=$,e[101]=ve,e[102]=Se):Se=e[102],Se}let z;e[103]!==$?(z=s.jsx(Be,{asChild:!0,children:$}),e[103]=$,e[104]=z):z=e[104];let M;e[105]!==Q?(M=s.jsx(Ae,{children:s.jsx("div",{className:"space-y-0.5",children:Q.map(nt)})}),e[105]=Q,e[106]=M):M=e[106];let R;return e[107]!==z||e[108]!==M?(R=s.jsxs(Re,{children:[z,M]}),e[107]=z,e[108]=M,e[109]=R):R=e[109],R};function tt(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:n.toFixed(1).replace(/\.0$/,"")}function st(n){return n>=90?"text-status-error":n>=75?"text-status-warning":"text-status-success"}function nt(n){return s.jsx("p",{className:"typography-micro leading-tight",children:n},n)}const Mt=Ne.memo(function(e){const t=te.c(40),{visible:c}=e,{t:i}=Pe(),[d,m]=Ne.useState(!1);let f,w;if(t[0]!==c?(f=()=>{if(!c)return;let P=!1;_e("desktop_get_current_window_state").then(I=>{P||m(!!I?.maximized)}).catch(it);const k=I=>{const L=I.detail;m(!!L?.maximized)};return window.addEventListener("openchamber:window-maximized-changed",k),()=>{P=!0,window.removeEventListener("openchamber:window-maximized-changed",k)}},w=[c],t[0]=c,t[1]=f,t[2]=w):(f=t[1],w=t[2]),Oe.useEffect(f,w),!c)return null;let l;t[3]!==i?(l=i("header.windowControls.groupAria"),t[3]=i,t[4]=l):l=t[4];let o;t[5]!==i?(o=i("header.windowControls.minimize"),t[5]=i,t[6]=o):o=t[6];let u;t[7]!==i?(u=i("header.windowControls.minimize"),t[7]=i,t[8]=u):u=t[8];let j;t[9]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(H,{name:"subtract",className:"h-4 w-4"}),t[9]=j):j=t[9];let p;t[10]!==o||t[11]!==u?(p=s.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:ot,title:o,"aria-label":u,children:j}),t[10]=o,t[11]=u,t[12]=p):p=t[12];let x;t[13]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{_e("desktop_toggle_current_window_maximized").then(P=>m(!!P?.maximized)).catch(rt)},t[13]=x):x=t[13];let g;t[14]!==d||t[15]!==i?(g=i(d?"header.windowControls.restore":"header.windowControls.maximize"),t[14]=d,t[15]=i,t[16]=g):g=t[16];let y;t[17]!==d||t[18]!==i?(y=i(d?"header.windowControls.restore":"header.windowControls.maximize"),t[17]=d,t[18]=i,t[19]=y):y=t[19];const h=d?"fullscreen-exit":"checkbox-blank";let v;t[20]!==h?(v=s.jsx(H,{name:h,className:"h-3.5 w-3.5"}),t[20]=h,t[21]=v):v=t[21];let N;t[22]!==y||t[23]!==v||t[24]!==g?(N=s.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:x,title:g,"aria-label":y,children:v}),t[22]=y,t[23]=v,t[24]=g,t[25]=N):N=t[25];let C;t[26]===Symbol.for("react.memo_cache_sentinel")?(C=X("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 r;t[27]!==i?(r=i("header.windowControls.close"),t[27]=i,t[28]=r):r=t[28];let _;t[29]!==i?(_=i("header.windowControls.close"),t[29]=i,t[30]=_):_=t[30];let b;t[31]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(H,{name:"close",className:"h-4 w-4"}),t[31]=b):b=t[31];let a;t[32]!==r||t[33]!==_?(a=s.jsx("button",{type:"button",className:C,onClick:lt,title:r,"aria-label":_,children:b}),t[32]=r,t[33]=_,t[34]=a):a=t[34];let S;return t[35]!==N||t[36]!==a||t[37]!==l||t[38]!==p?(S=s.jsxs("div",{className:"app-region-no-drag -mr-3 ml-2 flex h-12 shrink-0 items-center","aria-label":l,children:[p,N,a]}),t[35]=N,t[36]=a,t[37]=l,t[38]=p,t[39]=S):S=t[39],S});function it(){}function ot(){_e("desktop_minimize_current_window")}function rt(){}function lt(){_e("desktop_close_current_window")}const Ee="oc.sessions.pinned",at=n=>{try{const e=n.getItem(Ee);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(c=>typeof c=="string")):new Set}catch{return new Set}},ze=(n,e)=>{try{n.setItem(Ee,JSON.stringify([...e]))}catch{}},De=We(),ct=Ue((n,e)=>({ids:at(De),setIds:t=>{const c=e().ids,i=typeof t=="function"?t(c):t;i!==c&&(n({ids:i}),ze(De,i))},toggle:t=>{const c=e().ids,i=new Set(c);i.has(t)?i.delete(t):i.add(t),n({ids:i}),ze(De,i)}})),dt=7,ut=n=>{if(!n)return null;const e=n.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},mt=n=>{if(!n)return null;const e=n.label?.trim();if(e)return e;const t=n.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},ft=(n,e)=>{const t=te.c(18);let c;t[0]!==e?(c=e===void 0?{}:e,t[0]=e,t[1]=c):c=t[1];const i=c,{scopeProjectId:d}=i,m=d===void 0?null:d,f=Ge(pt),w=He(ht),l=ct(xt),o=Je();let u;t[2]!==w?(u=w.map(gt).filter(bt),t[2]=w,t[3]=u):u=t[3];const j=u;let p;t[4]!==j?(p=h=>h?j.filter(N=>Ke(h,N.normalizedPath)).sort(wt)[0]??null:null,t[4]=j,t[5]=p):p=t[5];const x=p;let g;{let h;if(t[7]!==f||t[8]!==o||t[9]!==x||t[10]!==l||t[11]!==m){const v=new Map;for(const b of f){const a=b.parentID;if(!a||b.time?.archived)continue;const S=v.get(a);S?S.push(b):v.set(a,[b])}v.forEach(b=>{b.sort((a,S)=>$e(a,S,l))});let N;t[13]!==x||t[14]!==m?(N=b=>{if(!m)return!0;const a=Ie(b);return x(a)?.id===m},t[13]=x,t[14]=m,t[15]=N):N=t[15];let C;t[16]!==l?(C=(b,a)=>$e(b,a,l),t[16]=l,t[17]=C):C=t[17];const r=f.filter(jt).filter(yt).filter(N).sort(C).slice(0,dt),_=b=>{const a=v.get(b.id)??[];return{session:b,children:a.map(S=>_(S)),worktree:null}};h=r.map(b=>{const a=Ie(b),S=x(a),P=mt(S),k=a?o.get(a)??null:null;return{node:_(b),projectId:S?.id??null,groupDirectory:a,secondaryMeta:{projectLabel:P,branchLabel:k&&k!==P?k:null}}}),t[7]=f,t[8]=o,t[9]=x,t[10]=l,t[11]=m,t[12]=h}else h=t[12];g=h}return g};function pt(n){return n.activeSessions}function ht(n){return n.projects}function xt(n){return n.ids}function gt(n){return{...n,normalizedPath:ut(n.path)}}function bt(n){return n.normalizedPath}function wt(n,e){return(e.normalizedPath?.length??0)-(n.normalizedPath?.length??0)}function jt(n){return!n.time?.archived}function yt(n){return!n.parentID}function Et(n){const e=te.c(18),{children:t,variant:c,scopeProjectId:i,align:d}=n,m=c===void 0?"default":c,f=i===void 0?null:i,w=d===void 0?"start":d,l=Ce(St),o=Ce(vt);let u;e[0]!==t?(u=s.jsx(qe,{asChild:!0,children:t}),e[0]=t,e[1]=u):u=e[1];const j=m==="compact"?"w-[280px]":"w-[360px]";let p;e[2]!==j?(p=X("overflow-hidden p-1 max-w-[calc(100vw-32px)]",j),e[2]=j,e[3]=p):p=e[3];let x;e[4]!==l||e[5]!==f||e[6]!==o||e[7]!==m?(x=l?s.jsx(Nt,{onSelect:()=>o(!1),variant:m,scopeProjectId:f}):null,e[4]=l,e[5]=f,e[6]=o,e[7]=m,e[8]=x):x=e[8];let g;e[9]!==w||e[10]!==p||e[11]!==x?(g=s.jsx(Xe,{align:w,sideOffset:6,className:p,children:x}),e[9]=w,e[10]=p,e[11]=x,e[12]=g):g=e[12];let y;return e[13]!==l||e[14]!==o||e[15]!==u||e[16]!==g?(y=s.jsxs(Ye,{open:l,onOpenChange:o,modal:!1,children:[u,g]}),e[13]=l,e[14]=o,e[15]=u,e[16]=g,e[17]=y):y=e[17],y}function vt(n){return n.setSessionDropdownOpen}function St(n){return n.isSessionDropdownOpen}function Nt(n){const e=te.c(26),{onSelect:t,variant:c,scopeProjectId:i}=n;let d;e[0]!==i?(d={scopeProjectId:i},e[0]=i,e[1]=d):d=e[1];const m=ft(!0,d),f=Le(Ct),w=Ce(_t),{t:l}=Pe();let o;e[2]!==t||e[3]!==f||e[4]!==w?(o=()=>{w("chat"),t(),f()},e[2]=t,e[3]=f,e[4]=w,e[5]=o):o=e[5];const u=o;let j;e[6]===Symbol.for("react.memo_cache_sentinel")?(j=new Set,e[6]=j):j=e[6];const[p,x]=Ne.useState(j);let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=a=>{x(S=>{const P=new Set(S);return P.has(a)?P.delete(a):P.add(a),P})},e[7]=g):g=e[7];const y=g;let h,v;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=X("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"),v=s.jsx(H,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e[8]=h,e[9]=v):(h=e[8],v=e[9]);let N;e[10]!==l?(N=l("sessions.sidebar.header.actions.newSession"),e[10]=l,e[11]=N):N=e[11];let C;e[12]!==N?(C=s.jsx("span",{className:"truncate text-[14px] font-normal leading-tight text-foreground",children:N}),e[12]=N,e[13]=C):C=e[13];let r;e[14]!==u||e[15]!==C?(r=s.jsxs(Me,{onClick:u,className:h,children:[v,C]}),e[14]=u,e[15]=C,e[16]=r):r=e[16];let _;e[17]!==p||e[18]!==m||e[19]!==t||e[20]!==l||e[21]!==c?(_=m.length===0?s.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:l("sessions.switcher.empty")}):m.map(a=>s.jsx(Te,{item:a,depth:0,variant:c,expandedParents:p,toggleParent:y,closeDropdown:t},a.node.session.id)),e[17]=p,e[18]=m,e[19]=t,e[20]=l,e[21]=c,e[22]=_):_=e[22];let b;return e[23]!==_||e[24]!==r?(b=s.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:s.jsxs("div",{className:"space-y-0.5",children:[r,_]})}),e[23]=_,e[24]=r,e[25]=b):b=e[25],b}function _t(n){return n.setActiveMainTab}function Ct(n){return n.openNewSessionDraft}function Te(n){const e=te.c(31),{item:t,depth:c,variant:i,expandedParents:d,toggleParent:m,closeDropdown:f}=n,{node:w,secondaryMeta:l}=t,o=w.session,u=w.children.length>0;let j;e[0]!==d||e[1]!==o.id?(j=d.has(o.id),e[0]=d,e[1]=o.id,e[2]=j):j=e[2];const p=j;let x;e[3]!==u||e[4]!==o.id||e[5]!==m?(x=u?()=>m(o.id):void 0,e[3]=u,e[4]=o.id,e[5]=m,e[6]=x):x=e[6];let g;e[7]!==f||e[8]!==c||e[9]!==u||e[10]!==p||e[11]!==l||e[12]!==o||e[13]!==x||e[14]!==i?(g=s.jsx(Pt,{session:o,depth:c,variant:i,secondaryMeta:l,hasChildren:u,isExpanded:p,onToggleExpand:x,closeDropdown:f}),e[7]=f,e[8]=c,e[9]=u,e[10]=p,e[11]=l,e[12]=o,e[13]=x,e[14]=i,e[15]=g):g=e[15];let y;e[16]!==f||e[17]!==c||e[18]!==d||e[19]!==u||e[20]!==p||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==w.children||e[24]!==l||e[25]!==m||e[26]!==i?(y=u&&p?w.children.map(v=>s.jsx(Te,{item:{node:v,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:l},depth:c+1,variant:i,expandedParents:d,toggleParent:m,closeDropdown:f},v.session.id)):null,e[16]=f,e[17]=c,e[18]=d,e[19]=u,e[20]=p,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=w.children,e[24]=l,e[25]=m,e[26]=i,e[27]=y):y=e[27];let h;return e[28]!==g||e[29]!==y?(h=s.jsxs(s.Fragment,{children:[g,y]}),e[28]=g,e[29]=y,e[30]=h):h=e[30],h}function Pt(n){const e=te.c(60),{session:t,depth:c,variant:i,secondaryMeta:d,hasChildren:m,isExpanded:f,onToggleExpand:w,closeDropdown:l}=n,{t:o}=Pe(),u=Le(It),j=Le(Dt),p=Ce(kt),x=Ze(t.id),g=Qe(t.id),y=u===t.id;let h;e[0]!==t.title||e[1]!==o?(h=t.title?.trim()||o("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=o,e[2]=h):h=e[2];const v=h,N=!!t.parentID,C=g>0&&(!N||p),r=x?.type??"idle",_=r==="busy"||r==="retry",b=!_&&C&&!y,a=t.summary;let S;e[3]!==a?(S=Ve(a),e[3]=a,e[4]=S):S=e[4];const P=S;let k;e[5]!==t.time?.created||e[6]!==t.time?.updated?(k=t.time?.updated||t.time?.created||Date.now(),e[5]=t.time?.created,e[6]=t.time?.updated,e[7]=k):k=e[7];const I=k;let L;e[8]!==I?(L=et(I),e[8]=I,e[9]=L):L=e[9];const J=L;let Y;e[10]!==d?.projectLabel?(Y=d?.projectLabel?.trim()||null,e[10]=d?.projectLabel,e[11]=Y):Y=e[11];const Q=Y;let T;e[12]!==d?.branchLabel?(T=d?.branchLabel?.trim()||null,e[12]=d?.branchLabel,e[13]=T):T=e[13];const K=T,O=K&&K!=="HEAD"?K:null;let U;e[14]!==l||e[15]!==y||e[16]!==t||e[17]!==j?(U=()=>{if(y){l();return}const D=Ie(t);j(t.id,D??null),l()},e[14]=l,e[15]=y,e[16]=t,e[17]=j,e[18]=U):U=e[18];const q=U;let A;e[19]!==q?(A=D=>{if(D.target?.closest("[data-switcher-expand]")){D.preventDefault();return}q()},e[19]=q,e[20]=A):A=e[20];let Z;e[21]===Symbol.for("react.memo_cache_sentinel")?(Z=X("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[21]=Z):Z=e[21];const ee=8+c*12;let F;e[22]!==ee?(F={paddingLeft:ee},e[22]=ee,e[23]=F):F=e[23];let B;e[24]!==m||e[25]!==f||e[26]!==w||e[27]!==o||e[28]!==i?(B=i==="compact"&&m?s.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:D=>{D.preventDefault(),D.stopPropagation(),w?.()},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":o(f?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:f?s.jsx(H,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):s.jsx(H,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[24]=m,e[25]=f,e[26]=w,e[27]=o,e[28]=i,e[29]=B):B=e[29];const V=y?"text-primary":"text-foreground";let $;e[30]!==V?($=X("truncate text-[14px] font-normal leading-tight",V),e[30]=V,e[31]=$):$=e[31];let z;e[32]!==v||e[33]!==$?(z=s.jsx("span",{className:$,children:v}),e[32]=v,e[33]=$,e[34]=z):z=e[34];let M;e[35]!==B||e[36]!==z?(M=s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[B,z]}),e[35]=B,e[36]=z,e[37]=M):M=e[37];let R;e[38]!==O||e[39]!==P||e[40]!==m||e[41]!==f||e[42]!==w||e[43]!==Q||e[44]!==o||e[45]!==J||e[46]!==i?(R=i==="default"?s.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:[m?s.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:D=>{D.preventDefault(),D.stopPropagation(),w?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":o(f?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:f?s.jsx(H,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(H,{name:"arrow-right-s",className:"h-3 w-3"})}):null,s.jsx("span",{className:"flex-shrink-0",children:J}),Q?s.jsx("span",{className:"truncate",children:Q}):null,O?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(H,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:O})]}):null,P?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-0 text-[0.92em]",children:[s.jsxs("span",{className:"text-status-success/80",children:["+",P.additions]}),s.jsx("span",{className:"text-muted-foreground/60",children:"/"}),s.jsxs("span",{className:"text-status-error/65",children:["-",P.deletions]})]}):null]}):null,e[38]=O,e[39]=P,e[40]=m,e[41]=f,e[42]=w,e[43]=Q,e[44]=o,e[45]=J,e[46]=i,e[47]=R):R=e[47];let W;e[48]!==M||e[49]!==R?(W=s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[M,R]}),e[48]=M,e[49]=R,e[50]=W):W=e[50];let E;e[51]!==_||e[52]!==b||e[53]!==o?(E=_||b?s.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:_?s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":o("sessions.sidebar.session.status.active"),title:o("sessions.sidebar.session.status.active")}):s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":o("sessions.sidebar.session.status.unread"),title:o("sessions.sidebar.session.status.unread")})}):null,e[51]=_,e[52]=b,e[53]=o,e[54]=E):E=e[54];let G;return e[55]!==F||e[56]!==W||e[57]!==E||e[58]!==A?(G=s.jsxs(Me,{onClick:A,"data-slot":"session-switcher-item",className:Z,style:F,children:[W,E]}),e[55]=F,e[56]=W,e[57]=E,e[58]=A,e[59]=G):G=e[59],G}function kt(n){return n.notifyOnSubtasks}function Dt(n){return n.setCurrentSession}function It(n){return n.currentSessionId}export{zt as C,Et as S,Mt as W,ct as u};
@@ -1 +1 @@
1
- import{c as b,R as h,j as t,b4 as w,b2 as j,b3 as v,b0 as D,a_ as _}from"./vendor-.bun-TPgXvEwq.js";import{u as k,m as g}from"./useAppFontEffects-DEZpweZZ.js";import{c as R}from"./NewWorktreeDialog-6y6rHfOQ.js";import"./index-D9t9eCUC.js";import"./mobileLayoutPreference-Dio-WWkI.js";const B=x=>{const e=b.c(19),{open:m,onOpenChange:n}=x,{t:u}=k(),s=h.useId(),y=S;let a;e[0]!==n?(a=f=>{!f&&y()||n(f)},e[0]=n,e[1]=a):a=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(w,{className:g("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]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=g("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]"),e[3]=d):d=e[3];let o;e[4]!==u?(o=u("settings.window.description"),e[4]=u,e[5]=o):o=e[5];let i;e[6]!==s||e[7]!==o?(i=t.jsx(j,{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(R,{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(v,{children:[c,t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:t.jsxs(D,{"aria-describedby":s,className:d,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(_,{open:m,onOpenChange:a,children:r}),e[15]=m,e[16]=a,e[17]=r,e[18]=p):p=e[18],p};function S(){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
+ import{c as b,R as h,j as t,b4 as w,b2 as j,b3 as v,b0 as D,a_ as _}from"./vendor-.bun-TPgXvEwq.js";import{u as k,m as g}from"./useAppFontEffects-hYm-4PtP.js";import{c as R}from"./NewWorktreeDialog-C6394QE9.js";import"./index-D9t9eCUC.js";import"./mobileLayoutPreference-Dio-WWkI.js";const B=x=>{const e=b.c(19),{open:m,onOpenChange:n}=x,{t:u}=k(),s=h.useId(),y=S;let a;e[0]!==n?(a=f=>{!f&&y()||n(f)},e[0]=n,e[1]=a):a=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(w,{className:g("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]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=g("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]"),e[3]=d):d=e[3];let o;e[4]!==u?(o=u("settings.window.description"),e[4]=u,e[5]=o):o=e[5];let i;e[6]!==s||e[7]!==o?(i=t.jsx(j,{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(R,{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(v,{children:[c,t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:t.jsxs(D,{"aria-describedby":s,className:d,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(_,{open:m,onOpenChange:a,children:r}),e[15]=m,e[16]=a,e[17]=r,e[18]=p):p=e[18],p};function S(){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,4 +1,4 @@
1
- import{R as n,j as f,f as xt,ce as vt,cf as Tt,cg as kt}from"./vendor-.bun-TPgXvEwq.js";import{u as bt,o as Ct,f7 as Et,m as Ze,a as Rt,p as At,fw as St,T as Me,ay as It,y as ht,b as Mt,H as fe,fx as it,eE as dt,B as ne}from"./useAppFontEffects-DEZpweZZ.js";import{u as X}from"./main-D8KFwoUt.js";import{l as Bt,m as Pt}from"./NewWorktreeDialog-6y6rHfOQ.js";import{b as Dt,al as Nt}from"./index-D9t9eCUC.js";import"./SessionSwitcherDropdown-DSXsR7zB.js";import"./mobileLayoutPreference-Dio-WWkI.js";function jt(u){const{colors:c}=u,d=c.syntax.base;return{background:c.surface.background,foreground:d.foreground,cursor:c.interactive.cursor,cursorAccent:c.surface.background,selectionBackground:c.interactive.selection,selectionForeground:c.interactive.selectionForeground,selectionInactiveBackground:c.interactive.selection+"50",black:c.surface.muted,red:c.status.error,green:c.status.success,yellow:c.status.warning,blue:d.function,magenta:d.keyword,cyan:d.type,white:d.foreground,brightBlack:d.comment,brightRed:c.status.error,brightGreen:c.status.success,brightYellow:c.status.warning,brightBlue:d.function,brightMagenta:d.keyword,brightCyan:d.type,brightWhite:c.surface.elevatedForeground}}function Vt(u,c,d,S,C=!1){const G=`${u}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`;return{cursorBlink:!1,cursorStyle:"bar",fontSize:c,lineHeight:1.15,fontFamily:G,allowTransparency:!1,theme:{background:d.background,foreground:d.foreground,cursor:d.cursor,cursorAccent:d.cursorAccent,selectionBackground:d.selectionBackground,selectionForeground:d.selectionForeground,black:d.black,red:d.red,green:d.green,yellow:d.yellow,blue:d.blue,magenta:d.magenta,cyan:d.cyan,white:d.white,brightBlack:d.brightBlack,brightRed:d.brightRed,brightGreen:d.brightGreen,brightYellow:d.brightYellow,brightBlue:d.brightBlue,brightMagenta:d.brightMagenta,brightCyan:d.brightCyan,brightWhite:d.brightWhite},scrollback:1e4,ghostty:S,disableStdin:C}}let pt=null;function Lt(){return pt||(pt=kt.load()),pt}function Ft(u){if(typeof window>"u")return null;const c=[u,...Array.from(u.querySelectorAll("*"))];let d=null;for(const S of c){const $=window.getComputedStyle(S).overflowY;if(!($!=="auto"&&$!=="scroll")){if(S.scrollHeight-S.clientHeight>2)return S;d||(d=S)}}return d}const gt=n.forwardRef(({sessionKey:u,chunks:c,onInput:d,onResize:S,theme:C,fontFamily:$,fontSize:G,className:be,enableTouchScroll:R,autoFocus:at=!0,isVisible:Ne=!0},Ce)=>{const{t:_}=bt(),O=n.useRef(null),je=n.useRef(null),I=n.useRef(null),et=n.useRef(null),Y=n.useRef(d),Ue=n.useRef(S),x=n.useRef(null),Ee=n.useRef(""),re=n.useRef(null),Ve=n.useRef(!1),Le=n.useRef(null),ge=n.useRef(!0),oe=n.useRef(null),J=n.useRef(null),Re=n.useRef(0),se=n.useRef(null),We=n.useRef(null),de=n.useRef(!1),Z=n.useRef(!1),xe=n.useRef(null),j=n.useRef(null),D=n.useRef(null),we=n.useRef(""),Fe=n.useRef(null),V=n.useRef(!R),tt=n.useRef(Ne),[,ft]=n.useReducer(e=>e+1,0),[nt,ct]=n.useReducer(e=>e+1,0);Y.current=d,Ue.current=S;const lt=typeof navigator<"u"&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform==="Android"),b=!!R;n.useEffect(()=>{if(!R){V.current=!0,tt.current=Ne;return}!tt.current&&Ne&&(V.current=!1),tt.current=Ne},[R,Ne]);const rt=n.useCallback(()=>{if(!b)return;const e=O.current,i=se.current;if(!e)return;const s=[];e.getAttribute("contenteditable")==="true"&&s.push(e),s.push(...Array.from(e.querySelectorAll('[contenteditable="true"]'))),s.forEach(o=>{o.setAttribute("data-terminal-disabled-contenteditable","true"),o.setAttribute("contenteditable","false"),o.setAttribute("aria-hidden","true"),o.tabIndex=-1,o.style.setProperty("caret-color","transparent"),o.style.color="transparent",o.style.setProperty("-webkit-text-fill-color","transparent"),o.style.background="transparent",o.style.outline="none",o.style.boxShadow="none",o.style.textShadow="none",o.style.setProperty("user-select","none"),o.style.setProperty("-webkit-user-select","none")}),e.tabIndex=-1,e.removeAttribute("role"),e.removeAttribute("aria-multiline"),Array.from(e.querySelectorAll("textarea")).forEach(o=>{o.style.setProperty("caret-color","transparent"),o.style.color="transparent",o.style.setProperty("-webkit-text-fill-color","transparent"),o.style.background="transparent",o.style.border="0",o.style.outline="none",o.style.boxShadow="none",o.style.textShadow="none",o.style.fontSize="0",o.style.lineHeight="0",o!==i&&o.getAttribute("data-terminal-disabled-input")!=="true"&&(o.setAttribute("data-terminal-disabled-input","true"),o.setAttribute("aria-hidden","true"),o.tabIndex=-1,o.disabled=!0,o.style.position="absolute",o.style.opacity="0",o.style.width="0px",o.style.height="0px",o.style.pointerEvents="none",o.style.zIndex="-1")})},[b]),A=n.useCallback(e=>{if(Fe.current===e)return;const i=I.current;if(i)try{if(typeof i.setOption=="function"){i.setOption("cursorBlink",e),Fe.current=e;return}i.options&&(i.options.cursorBlink=e,Fe.current=e)}catch{}},[]),pe=b&&lt,E=n.useCallback((e,i)=>{const s=pe?We.current:se.current,m=O.current;if(!s||!m)return;const o=m.getBoundingClientRect(),k=typeof window<"u"?window.innerWidth:o.width,y=typeof window<"u"?window.innerHeight:o.height,M=o.left+o.width/2,ee=o.top+o.height-12,r=typeof e=="number"?e:M,B=typeof i=="number"?i:ee,F=8,U=Math.max(F,Math.min(k-F,r)),Ae=Math.max(F,Math.min(y-F,B));s.style.left=`${U}px`,s.style.top=`${Ae}px`,s.style.bottom="",(s instanceof HTMLTextAreaElement||s instanceof HTMLInputElement)&&(s.disabled=!1,s.readOnly=!1,s.removeAttribute("disabled"),s.removeAttribute("readonly"));try{s.focus({preventScroll:!0})}catch{try{s.focus()}catch{}}},[pe]),L=n.useCallback(()=>{if(b){E(),A(!0);return}I.current?.focus(),A(!0)},[E,A,b]),N=n.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??"",[]),z=n.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value="";return}e.textContent=""},[]),Ke=n.useCallback(e=>{if(typeof window>"u"||pe)return;D.current!==null&&(window.clearTimeout(D.current),D.current=null);let i=0;const s=3,m=()=>{D.current=window.setTimeout(()=>{D.current=null;const o=N(e);if(!o){if(i+=1,i<s){m();return}return}const k=we.current;we.current=o;const y=o.startsWith(k)?o.slice(k.length):o;y&&Y.current(y.replace(/\r\n|\r|\n/g,"\r")),z(e),we.current=""},i===0?0:24)};m()},[z,N,pe]);n.useEffect(()=>{const e=O.current;if(!b||!e||R)return;const i=s=>{const m=s.target;if(m&&m.getAttribute("data-terminal-hidden-input")!=="true"&&e.contains(m)){try{m.blur()}catch{}E()}};return e.addEventListener("focusin",i,!0),()=>{e.removeEventListener("focusin",i,!0)}},[R,b,E]);const qe=n.useCallback(()=>{const e=I.current;if(!e||typeof e.getSelection!="function")return"";const i=e.getSelection();return typeof i=="string"?i:""},[]),Xe=n.useCallback(()=>{if(typeof window>"u")return"";const e=window.getSelection();if(!e)return"";const i=e.toString();if(!i.trim())return"";const s=O.current;if(!s)return"";const m=e.anchorNode,o=e.focusNode;return m&&!s.contains(m)||o&&!s.contains(o)?"":i},[]),ve=n.useCallback(async()=>{if(typeof document>"u")return;const e=qe()||Xe();e.trim()&&await Ct(e)},[Xe,qe]),Q=n.useCallback(()=>qe().trim()?!0:!!Xe().trim(),[Xe,qe]);n.useEffect(()=>{if(typeof window>"u")return;const e=i=>{Q()&&(i.preventDefault(),ve())};return window.addEventListener("openchamber:copy",e),()=>{window.removeEventListener("openchamber:copy",e)}},[ve,Q]);const ie=n.useCallback(()=>{Ee.current="",re.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(re.current),re.current=null,Ve.current=!1,Le.current=null},[]),H=n.useCallback(()=>{const e=et.current,i=I.current,s=O.current;if(!e||!i||!s)return;const m=s.getBoundingClientRect();if(!(m.width<24||m.height<24))try{e.fit();const o={cols:i.cols,rows:i.rows},k=x.current;(!k||k.cols!==o.cols||k.rows!==o.rows)&&(x.current=o,Ue.current(o.cols,o.rows))}catch{}},[]),Te=n.useCallback(()=>{if(Ve.current)return;const e=I.current;if(!e){ie();return}if(!Ee.current)return;const i=Ee.current;Ee.current="",Ve.current=!0,e.write(i,()=>{Ve.current=!1,Ee.current&&(typeof window<"u"?re.current=window.requestAnimationFrame(()=>{re.current=null,Te()}):Te())})},[ie]),Be=n.useCallback(()=>{re.current===null&&(typeof window<"u"?re.current=window.requestAnimationFrame(()=>{re.current=null,Te()}):Te())},[Te]),$e=n.useCallback(e=>{e&&(Ee.current+=e,Be())},[Be]),Pe=n.useCallback(()=>{if(oe.current?.(),oe.current=null,J.current!==null&&typeof window<"u"&&(window.clearTimeout(J.current),J.current=null),!R){Re.current=0;return}const e=O.current;if(!e)return;const i=I.current;if(!i)return;Re.current=0;const s=2.2,m=2.8,o=25,k=.25,y=8,M=.05,ee=.015,r={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},B=()=>typeof performance<"u"?performance.now():Date.now(),F=Math.max(12,Math.round(G*1.35));let U=0;const Ae=a=>{if(!a)return!1;const he=i.getViewportY(),P=U+a,le=Math.trunc(P/F);return U=P-le*F,le!==0&&i.scrollLines(le),i.getViewportY()!==he},W=()=>{r.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(r.rafId),r.rafId=null},T={passive:!1,capture:!1};if(typeof window<"u"&&"PointerEvent"in window){const a=Object.assign(r,{pointerId:null,startX:null,startY:null,moved:!1}),he=6,P=t=>{if(t.pointerType==="touch"){W(),a.pointerId=t.pointerId,a.startX=t.clientX,a.startY=t.clientY,a.moved=!1,a.lastY=t.clientY,a.lastTime=B(),a.velocity=0;try{e.setPointerCapture(t.pointerId)}catch{}}},le=t=>{if(t.pointerType!=="touch"||a.pointerId!==t.pointerId)return;if(a.startX!==null&&a.startY!==null&&!a.moved){const Ie=t.clientX-a.startX,ze=t.clientY-a.startY;Math.hypot(Ie,ze)>=he&&(a.moved=!0)}if(a.lastY===null){a.lastY=t.clientY,a.lastTime=B();return}const p=a.lastY,l=a.lastTime??B(),h=B();a.lastY=t.clientY,a.lastTime=h;const w=p-t.clientY;if(Math.abs(w)<1)return;const v=Math.max(h-l,8),g=s+Math.min(m,Math.abs(w)/o),te=w*g,ye=te/v;a.velocity=a.velocity*(1-k)+ye*k,a.velocity>y?a.velocity=y:a.velocity<-y&&(a.velocity=-y),a.moved&&(t.cancelable&&t.preventDefault(),t.stopPropagation()),Ae(te)},me=t=>{if(t.pointerType!=="touch"||a.pointerId!==t.pointerId)return;const p=!a.moved;a.pointerId=null,a.startX=null,a.startY=null,a.moved=!1,a.lastY=null,a.lastTime=null;try{e.releasePointerCapture(t.pointerId)}catch{}if(p){b?E(t.clientX,t.clientY):R&&!V.current&&(V.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(a.velocity)<M){a.velocity=0;return}let l=B();const h=()=>{const w=B(),v=Math.max(w-l,8);l=w;const g=Ae(a.velocity*v)??!1,te=Math.sign(a.velocity),ye=Math.max(0,Math.abs(a.velocity)-ee*v);if(a.velocity=ye*te,!g||ye<=M){W(),a.velocity=0;return}a.rafId=window.requestAnimationFrame(h)};a.rafId=window.requestAnimationFrame(h)};e.addEventListener("pointerdown",P,T),e.addEventListener("pointermove",le,T),e.addEventListener("pointerup",me,T),e.addEventListener("pointercancel",me,T);const ue=e.style.touchAction;e.style.touchAction="manipulation",oe.current=()=>{W(),J.current!==null&&typeof window<"u"&&(window.clearTimeout(J.current),J.current=null),Re.current=0,e.removeEventListener("pointerdown",P,T),e.removeEventListener("pointermove",le,T),e.removeEventListener("pointerup",me,T),e.removeEventListener("pointercancel",me,T),e.style.touchAction=ue};return}const ae=6,De=a=>{a.touches.length===1&&(W(),r.lastY=a.touches[0].clientY,r.lastTime=B(),r.velocity=0,r.startX=a.touches[0].clientX,r.startY=a.touches[0].clientY,r.didMove=!1)},Se=a=>{if(a.touches.length!==1){r.lastY=null,r.lastTime=null,r.velocity=0,r.startX=null,r.startY=null,r.didMove=!1,W();return}const he=a.touches[0].clientX,P=a.touches[0].clientY;if(r.startX!==null&&r.startY!==null&&!r.didMove){const v=he-r.startX,g=P-r.startY;Math.hypot(v,g)>=ae&&(r.didMove=!0)}if(r.lastY===null){r.lastY=P,r.lastTime=B();return}const le=r.lastY,me=r.lastTime??B(),ue=B();r.lastY=P,r.lastTime=ue;const t=le-P;if(Math.abs(t)<1)return;const p=Math.max(ue-me,8),l=s+Math.min(m,Math.abs(t)/o),h=t*l,w=h/p;r.velocity=r.velocity*(1-k)+w*k,r.velocity>y?r.velocity=y:r.velocity<-y&&(r.velocity=-y),r.didMove&&(a.preventDefault(),a.stopPropagation()),Ae(h)},q=a=>{const he=!r.didMove;r.lastY=null,r.lastTime=null;const P=r.velocity;if(r.startX=null,r.startY=null,r.didMove=!1,he){const ue=a.changedTouches?.[0];b?E(ue?.clientX,ue?.clientY):R&&!V.current&&(V.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(P)<M){r.velocity=0;return}let le=B();const me=()=>{const ue=B(),t=Math.max(ue-le,8);le=ue;const p=Ae(r.velocity*t)??!1,l=Math.sign(r.velocity),h=Math.max(0,Math.abs(r.velocity)-ee*t);if(r.velocity=h*l,!p||h<=M){W(),r.velocity=0;return}r.rafId=window.requestAnimationFrame(me)};r.rafId=window.requestAnimationFrame(me)};e.addEventListener("touchstart",De,T),e.addEventListener("touchmove",Se,T),e.addEventListener("touchend",q,T),e.addEventListener("touchcancel",q,T);const ce=e.style.touchAction;e.style.touchAction="manipulation",oe.current=()=>{W(),J.current!==null&&typeof window<"u"&&(window.clearTimeout(J.current),J.current=null),Re.current=0,e.removeEventListener("touchstart",De,T),e.removeEventListener("touchmove",Se,T),e.removeEventListener("touchend",q,T),e.removeEventListener("touchcancel",q,T),e.style.touchAction=ce}},[R,b,E,G]);n.useEffect(()=>{let e=!1,i=null,s=null,m=null,o=[],k=null,y=null;const M=O.current;if(!M)return;if(M.tabIndex=b?-1:0,b){const W=M.focus.bind(M),T=M;T.focus=((...K)=>{E()}),y=()=>{T.focus=W}}const ee=()=>{A(!0)},r=()=>{A(!1)},B=W=>{const T=W.target;if(T&&M.contains(T)){if(b&&T instanceof HTMLElement){window.setTimeout(()=>{T.blur(),E()},0),A(!1);return}if(R&&!V.current&&T instanceof HTMLElement){window.setTimeout(()=>{T.blur()},0),A(!1);return}A(!0);return}A(!1)},F=()=>{A(!1)};let U=null;return(async()=>{try{const W=await Lt();if(e)return;const T=Vt($,G,C,W,!1),K=new vt(T);ge.current=!0,b&&(K.focus=()=>{});const ae=K;if(typeof ae.scrollToBottom=="function"){const ce=ae.scrollToBottom.bind(ae);ae.scrollToBottom=()=>{ge.current&&ce()},k=()=>{ae.scrollToBottom=ce}}const De=new Tt;i=K,I.current=K,et.current=De,K.loadAddon(De),K.open(M),ct(),Fe.current=!1,U=K.textarea??M.querySelector("textarea"),U&&(U.addEventListener("focus",ee),U.addEventListener("blur",r)),rt(),typeof MutationObserver<"u"&&(m=new MutationObserver(()=>{rt()}),m.observe(M,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["contenteditable","role","tabindex","aria-label"]}));const Se=Ft(M);Se?(Se.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),je.current=Se,ft()):je.current=null,H();const q=De;typeof q.observeResize=="function"&&q.observeResize(),Pe(),o=[K.onData(ce=>{Y.current(ce)}),K.onScroll(ce=>{if(typeof ce=="number"&&Number.isFinite(ce)){const a=typeof K.hasSelection=="function"&&K.hasSelection();ge.current=!a&&ce<=.5}}),K.onSelectionChange(()=>{if(typeof K.hasSelection=="function"&&K.hasSelection()){ge.current=!1;return}const a=typeof K.getViewportY=="function"?K.getViewportY():0;ge.current=a<=.5})],s=new ResizeObserver(()=>{H()}),s.observe(M),typeof window<"u"&&window.setTimeout(()=>{H()},0)}catch{}})(),document.addEventListener("focusin",B,!0),window.addEventListener("blur",F),()=>{e=!0,oe.current?.(),oe.current=null,document.removeEventListener("focusin",B,!0),window.removeEventListener("blur",F),o.forEach(W=>W.dispose()),k?.(),k=null,U&&(U.removeEventListener("focus",ee),U.removeEventListener("blur",r)),s?.disconnect(),m?.disconnect(),y?.(),i?.dispose(),I.current=null,et.current=null,je.current=null,x.current=null,Fe.current=null,ie()}},[rt,R,H,E,$,G,Pe,C,ie,A,b]),n.useEffect(()=>{const e=I.current;e&&(e.reset(),ie(),x.current=null,H())},[u,nt,H,ie]),n.useEffect(()=>{!at||!I.current||L()},[at,L,u,nt]),n.useEffect(()=>(Pe(),()=>{oe.current?.(),oe.current=null}),[Pe,u]),n.useEffect(()=>{const e=I.current;if(!e)return;if(c.length===0){Le.current!==null&&(e.reset(),ie(),H());return}const i=Le.current;let s;if(i===null)s=c;else{const m=c.findIndex(o=>o.id===i);s=m>=0?c.slice(m+1):c}s.length>0&&$e(s.map(m=>m.data).join("")),Le.current=c[c.length-1].id},[c,nt,$e,H,ie]),n.useImperativeHandle(Ce,()=>({focus:()=>{L()},clear:()=>{const e=I.current;e&&(e.reset(),ie(),H())},fit:()=>{H()}}),[L,H,ie]);const Ge=n.useCallback(e=>{if(!b)return;const i=O.current,s=e.relatedTarget,m=s?.tagName,o=m==="INPUT"||m==="TEXTAREA"||s?.isContentEditable,k=s?.getAttribute("data-terminal-hidden-input")==="true",y=!!(s&&i?.contains(s))},[b]),Oe=n.useCallback(e=>{const i=e.nativeEvent,s=i?.inputType??"",m=typeof i?.data=="string"?i.data:"";if(j.current=typeof performance<"u"?performance.now():Date.now(),s==="insertCompositionText"){de.current=!0;return}if(!s&&m){if(de.current)return;e.preventDefault(),Y.current(m),xe.current={type:"insertText",at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0;return}if(s==="insertText"&&m){if(de.current)return;e.preventDefault(),Y.current(m),xe.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0;return}if(s==="insertLineBreak"){if(de.current)return;e.preventDefault(),Y.current("\r"),xe.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0;return}if(s==="deleteContentBackward"){if(de.current)return;e.preventDefault(),Y.current(""),xe.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0}},[]),ot=n.useCallback(e=>{const i=e.currentTarget;if(j.current=typeof performance<"u"?performance.now():Date.now(),de.current)return;if(Z.current){const o=xe.current,k=typeof performance<"u"?performance.now():Date.now();if(o&&k-o.at<50){Z.current=!1,z(i);return}Z.current=!1}const s=N(i);if(!s)return;we.current=s;const m=s.replace(/\r\n|\r|\n/g,"\r");Y.current(m),z(i),we.current=""},[z,N]),_e=n.useCallback(e=>{e.stopPropagation();const i=e.key.toLowerCase(),s=e.metaKey&&!e.ctrlKey&&!e.altKey&&i==="c",m=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&i==="c";if((s||m)&&Q()){e.preventDefault(),ve();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){const F=e.key.toUpperCase();if(F>="A"&&F<="Z"){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),Y.current(String.fromCharCode(F.charCodeAt(0)-64)),z(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),Y.current("\x1B"+e.key),z(e.currentTarget);return}const k={ArrowUp:"\x1B[A",ArrowDown:"\x1B[B",ArrowRight:"\x1B[C",ArrowLeft:"\x1B[D",Escape:"\x1B",Tab:" ",Delete:"\x1B[3~",Home:"\x1B[H",End:"\x1B[F"}[e.key];if(k){e.preventDefault(),Y.current(k),z(e.currentTarget);return}const y=e.currentTarget;if(e.nativeEvent?.isComposing)return;const ee=xe.current,r=typeof performance<"u"?performance.now():Date.now(),B=!!(ee&&r-ee.at<50);if(e.key==="Enter"){if(B&&ee?.type==="insertLineBreak")return;e.preventDefault(),Y.current("\r"),z(y);return}if(e.key==="Backspace"){if(e.preventDefault(),B&&ee?.type==="deleteContentBackward")return;N(y)||Y.current("")}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const F=j.current;F&&r-F<50||(e.preventDefault(),Y.current(e.key),Z.current=!0,xe.current={type:"keydown-text",at:r})}Ke(y)},[z,ve,Q,N,Ke]),Ye=n.useCallback(e=>{e.stopPropagation();const i=e.currentTarget;e.nativeEvent?.isComposing||Ke(i)},[Ke]),Je=n.useCallback(e=>{const i=e.currentTarget;de.current=!1;const s=e.data||N(i);if(j.current=typeof performance<"u"?performance.now():Date.now(),!s)return;const m=s.replace(/\r\n|\r|\n/g,"\r");Y.current(m),z(i),xe.current={type:"compositionend",at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0},[z,N]),He=n.useCallback(e=>{e.stopPropagation();const i=e.clipboardData?.getData("text")??"";if(!i)return;e.preventDefault();const m=I.current?.hasBracketedPaste?.()?`\x1B[200~${i}\x1B[201~`:i;Y.current(m)},[]),ke={position:"fixed",left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:"transparent",color:"transparent",WebkitTextFillColor:"transparent",caretColor:"transparent",textShadow:"none",WebkitAppearance:"none",appearance:"none",resize:"none",overflow:"hidden",whiteSpace:"nowrap",border:"0",padding:0,margin:0,outline:"none",outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:"none",WebkitUserSelect:"none",userSelect:"none"};return f.jsxs("div",{ref:O,className:Ze("relative h-full w-full terminal-viewport-container",be),"data-hidden-input-overlay-active":b?"true":void 0,style:{backgroundColor:C.background},onTouchStart:e=>{if(!(!b||R)&&!Q()){const i=e.touches?.[0];E(i?.clientX,i?.clientY)}},onClick:e=>{if(!R)if(b){if(Q())return;E(e.clientX,e.clientY)}else I.current?.focus()},onMouseUp:()=>{!R&&Q()&&ve()},onTouchEnd:()=>{!R&&Q()&&ve()},children:[b&&typeof document<"u"?xt.createPortal(f.jsxs(f.Fragment,{children:[f.jsx("input",{ref:We,type:"text",inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":_("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...ke,display:pe?"block":"none"},onBlur:Ge,onBeforeInput:Oe,onCompositionStart:()=>{de.current=!0},onInput:ot,onKeyDown:_e,onKeyUp:Ye,onCompositionEnd:Je,onPaste:He}),f.jsx("textarea",{ref:se,inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":_("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...ke,display:pe?"none":"block"},onBlur:Ge,onBeforeInput:Oe,onCompositionStart:()=>{de.current=!0},onInput:ot,onKeyDown:_e,onKeyUp:Ye,onCompositionEnd:Je,onPaste:He})]}),document.body):null,je.current&&!R?f.jsx(Et,{containerRef:je,disableHorizontal:!0,className:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero"}):null]})});gt.displayName="TerminalViewport";const Kt="\x1B",Ot=new RegExp(`${Kt}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Yt=/(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 c=u;for(;c.length>0;){const d=c[c.length-1];if(d===")"||d==="]"||d==="}"||d===">"){const S=d===")"?"(":d==="]"?"[":d==="}"?"{":"<",C=c.slice(0,-1),$=(C.match(new RegExp(`\\${S}`,"g"))||[]).length,G=(C.match(new RegExp(`\\${d}`,"g"))||[]).length;if($>G)break;c=C;continue}if(Ut.has(d)){c=c.slice(0,-1);continue}break}return c},yt=u=>{let c=Wt(u);return c=c.replace("0.0.0.0","127.0.0.1"),c=c.replace("[::1]","127.0.0.1"),c=c.replace("[::]","127.0.0.1"),c},qt=u=>{if(!u)return null;const c=u.replace(Ot,""),d=c.match(zt);if(d?.[1]){const C=Number.parseInt(d[1],10);if(Number.isFinite(C)&&C>0&&C<=65535)return`http://127.0.0.1:${C}/`}const S=c.split(`
1
+ import{R as n,j as f,f as xt,ce as vt,cf as Tt,cg as kt}from"./vendor-.bun-TPgXvEwq.js";import{u as bt,o as Ct,f7 as Et,m as Ze,a as Rt,p as At,fw as St,T as Me,ay as It,y as ht,b as Mt,H as fe,fx as it,eE as dt,B as ne}from"./useAppFontEffects-hYm-4PtP.js";import{u as X}from"./main-DIwL7PaU.js";import{l as Bt,m as Pt}from"./NewWorktreeDialog-C6394QE9.js";import{b as Dt,al as Nt}from"./index-D9t9eCUC.js";import"./SessionSwitcherDropdown-BMN9gaXo.js";import"./mobileLayoutPreference-Dio-WWkI.js";function jt(u){const{colors:c}=u,d=c.syntax.base;return{background:c.surface.background,foreground:d.foreground,cursor:c.interactive.cursor,cursorAccent:c.surface.background,selectionBackground:c.interactive.selection,selectionForeground:c.interactive.selectionForeground,selectionInactiveBackground:c.interactive.selection+"50",black:c.surface.muted,red:c.status.error,green:c.status.success,yellow:c.status.warning,blue:d.function,magenta:d.keyword,cyan:d.type,white:d.foreground,brightBlack:d.comment,brightRed:c.status.error,brightGreen:c.status.success,brightYellow:c.status.warning,brightBlue:d.function,brightMagenta:d.keyword,brightCyan:d.type,brightWhite:c.surface.elevatedForeground}}function Vt(u,c,d,S,C=!1){const G=`${u}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`;return{cursorBlink:!1,cursorStyle:"bar",fontSize:c,lineHeight:1.15,fontFamily:G,allowTransparency:!1,theme:{background:d.background,foreground:d.foreground,cursor:d.cursor,cursorAccent:d.cursorAccent,selectionBackground:d.selectionBackground,selectionForeground:d.selectionForeground,black:d.black,red:d.red,green:d.green,yellow:d.yellow,blue:d.blue,magenta:d.magenta,cyan:d.cyan,white:d.white,brightBlack:d.brightBlack,brightRed:d.brightRed,brightGreen:d.brightGreen,brightYellow:d.brightYellow,brightBlue:d.brightBlue,brightMagenta:d.brightMagenta,brightCyan:d.brightCyan,brightWhite:d.brightWhite},scrollback:1e4,ghostty:S,disableStdin:C}}let pt=null;function Lt(){return pt||(pt=kt.load()),pt}function Ft(u){if(typeof window>"u")return null;const c=[u,...Array.from(u.querySelectorAll("*"))];let d=null;for(const S of c){const $=window.getComputedStyle(S).overflowY;if(!($!=="auto"&&$!=="scroll")){if(S.scrollHeight-S.clientHeight>2)return S;d||(d=S)}}return d}const gt=n.forwardRef(({sessionKey:u,chunks:c,onInput:d,onResize:S,theme:C,fontFamily:$,fontSize:G,className:be,enableTouchScroll:R,autoFocus:at=!0,isVisible:Ne=!0},Ce)=>{const{t:_}=bt(),O=n.useRef(null),je=n.useRef(null),I=n.useRef(null),et=n.useRef(null),Y=n.useRef(d),Ue=n.useRef(S),x=n.useRef(null),Ee=n.useRef(""),re=n.useRef(null),Ve=n.useRef(!1),Le=n.useRef(null),ge=n.useRef(!0),oe=n.useRef(null),J=n.useRef(null),Re=n.useRef(0),se=n.useRef(null),We=n.useRef(null),de=n.useRef(!1),Z=n.useRef(!1),xe=n.useRef(null),j=n.useRef(null),D=n.useRef(null),we=n.useRef(""),Fe=n.useRef(null),V=n.useRef(!R),tt=n.useRef(Ne),[,ft]=n.useReducer(e=>e+1,0),[nt,ct]=n.useReducer(e=>e+1,0);Y.current=d,Ue.current=S;const lt=typeof navigator<"u"&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform==="Android"),b=!!R;n.useEffect(()=>{if(!R){V.current=!0,tt.current=Ne;return}!tt.current&&Ne&&(V.current=!1),tt.current=Ne},[R,Ne]);const rt=n.useCallback(()=>{if(!b)return;const e=O.current,i=se.current;if(!e)return;const s=[];e.getAttribute("contenteditable")==="true"&&s.push(e),s.push(...Array.from(e.querySelectorAll('[contenteditable="true"]'))),s.forEach(o=>{o.setAttribute("data-terminal-disabled-contenteditable","true"),o.setAttribute("contenteditable","false"),o.setAttribute("aria-hidden","true"),o.tabIndex=-1,o.style.setProperty("caret-color","transparent"),o.style.color="transparent",o.style.setProperty("-webkit-text-fill-color","transparent"),o.style.background="transparent",o.style.outline="none",o.style.boxShadow="none",o.style.textShadow="none",o.style.setProperty("user-select","none"),o.style.setProperty("-webkit-user-select","none")}),e.tabIndex=-1,e.removeAttribute("role"),e.removeAttribute("aria-multiline"),Array.from(e.querySelectorAll("textarea")).forEach(o=>{o.style.setProperty("caret-color","transparent"),o.style.color="transparent",o.style.setProperty("-webkit-text-fill-color","transparent"),o.style.background="transparent",o.style.border="0",o.style.outline="none",o.style.boxShadow="none",o.style.textShadow="none",o.style.fontSize="0",o.style.lineHeight="0",o!==i&&o.getAttribute("data-terminal-disabled-input")!=="true"&&(o.setAttribute("data-terminal-disabled-input","true"),o.setAttribute("aria-hidden","true"),o.tabIndex=-1,o.disabled=!0,o.style.position="absolute",o.style.opacity="0",o.style.width="0px",o.style.height="0px",o.style.pointerEvents="none",o.style.zIndex="-1")})},[b]),A=n.useCallback(e=>{if(Fe.current===e)return;const i=I.current;if(i)try{if(typeof i.setOption=="function"){i.setOption("cursorBlink",e),Fe.current=e;return}i.options&&(i.options.cursorBlink=e,Fe.current=e)}catch{}},[]),pe=b&&lt,E=n.useCallback((e,i)=>{const s=pe?We.current:se.current,m=O.current;if(!s||!m)return;const o=m.getBoundingClientRect(),k=typeof window<"u"?window.innerWidth:o.width,y=typeof window<"u"?window.innerHeight:o.height,M=o.left+o.width/2,ee=o.top+o.height-12,r=typeof e=="number"?e:M,B=typeof i=="number"?i:ee,F=8,U=Math.max(F,Math.min(k-F,r)),Ae=Math.max(F,Math.min(y-F,B));s.style.left=`${U}px`,s.style.top=`${Ae}px`,s.style.bottom="",(s instanceof HTMLTextAreaElement||s instanceof HTMLInputElement)&&(s.disabled=!1,s.readOnly=!1,s.removeAttribute("disabled"),s.removeAttribute("readonly"));try{s.focus({preventScroll:!0})}catch{try{s.focus()}catch{}}},[pe]),L=n.useCallback(()=>{if(b){E(),A(!0);return}I.current?.focus(),A(!0)},[E,A,b]),N=n.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??"",[]),z=n.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value="";return}e.textContent=""},[]),Ke=n.useCallback(e=>{if(typeof window>"u"||pe)return;D.current!==null&&(window.clearTimeout(D.current),D.current=null);let i=0;const s=3,m=()=>{D.current=window.setTimeout(()=>{D.current=null;const o=N(e);if(!o){if(i+=1,i<s){m();return}return}const k=we.current;we.current=o;const y=o.startsWith(k)?o.slice(k.length):o;y&&Y.current(y.replace(/\r\n|\r|\n/g,"\r")),z(e),we.current=""},i===0?0:24)};m()},[z,N,pe]);n.useEffect(()=>{const e=O.current;if(!b||!e||R)return;const i=s=>{const m=s.target;if(m&&m.getAttribute("data-terminal-hidden-input")!=="true"&&e.contains(m)){try{m.blur()}catch{}E()}};return e.addEventListener("focusin",i,!0),()=>{e.removeEventListener("focusin",i,!0)}},[R,b,E]);const qe=n.useCallback(()=>{const e=I.current;if(!e||typeof e.getSelection!="function")return"";const i=e.getSelection();return typeof i=="string"?i:""},[]),Xe=n.useCallback(()=>{if(typeof window>"u")return"";const e=window.getSelection();if(!e)return"";const i=e.toString();if(!i.trim())return"";const s=O.current;if(!s)return"";const m=e.anchorNode,o=e.focusNode;return m&&!s.contains(m)||o&&!s.contains(o)?"":i},[]),ve=n.useCallback(async()=>{if(typeof document>"u")return;const e=qe()||Xe();e.trim()&&await Ct(e)},[Xe,qe]),Q=n.useCallback(()=>qe().trim()?!0:!!Xe().trim(),[Xe,qe]);n.useEffect(()=>{if(typeof window>"u")return;const e=i=>{Q()&&(i.preventDefault(),ve())};return window.addEventListener("openchamber:copy",e),()=>{window.removeEventListener("openchamber:copy",e)}},[ve,Q]);const ie=n.useCallback(()=>{Ee.current="",re.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(re.current),re.current=null,Ve.current=!1,Le.current=null},[]),H=n.useCallback(()=>{const e=et.current,i=I.current,s=O.current;if(!e||!i||!s)return;const m=s.getBoundingClientRect();if(!(m.width<24||m.height<24))try{e.fit();const o={cols:i.cols,rows:i.rows},k=x.current;(!k||k.cols!==o.cols||k.rows!==o.rows)&&(x.current=o,Ue.current(o.cols,o.rows))}catch{}},[]),Te=n.useCallback(()=>{if(Ve.current)return;const e=I.current;if(!e){ie();return}if(!Ee.current)return;const i=Ee.current;Ee.current="",Ve.current=!0,e.write(i,()=>{Ve.current=!1,Ee.current&&(typeof window<"u"?re.current=window.requestAnimationFrame(()=>{re.current=null,Te()}):Te())})},[ie]),Be=n.useCallback(()=>{re.current===null&&(typeof window<"u"?re.current=window.requestAnimationFrame(()=>{re.current=null,Te()}):Te())},[Te]),$e=n.useCallback(e=>{e&&(Ee.current+=e,Be())},[Be]),Pe=n.useCallback(()=>{if(oe.current?.(),oe.current=null,J.current!==null&&typeof window<"u"&&(window.clearTimeout(J.current),J.current=null),!R){Re.current=0;return}const e=O.current;if(!e)return;const i=I.current;if(!i)return;Re.current=0;const s=2.2,m=2.8,o=25,k=.25,y=8,M=.05,ee=.015,r={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},B=()=>typeof performance<"u"?performance.now():Date.now(),F=Math.max(12,Math.round(G*1.35));let U=0;const Ae=a=>{if(!a)return!1;const he=i.getViewportY(),P=U+a,le=Math.trunc(P/F);return U=P-le*F,le!==0&&i.scrollLines(le),i.getViewportY()!==he},W=()=>{r.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(r.rafId),r.rafId=null},T={passive:!1,capture:!1};if(typeof window<"u"&&"PointerEvent"in window){const a=Object.assign(r,{pointerId:null,startX:null,startY:null,moved:!1}),he=6,P=t=>{if(t.pointerType==="touch"){W(),a.pointerId=t.pointerId,a.startX=t.clientX,a.startY=t.clientY,a.moved=!1,a.lastY=t.clientY,a.lastTime=B(),a.velocity=0;try{e.setPointerCapture(t.pointerId)}catch{}}},le=t=>{if(t.pointerType!=="touch"||a.pointerId!==t.pointerId)return;if(a.startX!==null&&a.startY!==null&&!a.moved){const Ie=t.clientX-a.startX,ze=t.clientY-a.startY;Math.hypot(Ie,ze)>=he&&(a.moved=!0)}if(a.lastY===null){a.lastY=t.clientY,a.lastTime=B();return}const p=a.lastY,l=a.lastTime??B(),h=B();a.lastY=t.clientY,a.lastTime=h;const w=p-t.clientY;if(Math.abs(w)<1)return;const v=Math.max(h-l,8),g=s+Math.min(m,Math.abs(w)/o),te=w*g,ye=te/v;a.velocity=a.velocity*(1-k)+ye*k,a.velocity>y?a.velocity=y:a.velocity<-y&&(a.velocity=-y),a.moved&&(t.cancelable&&t.preventDefault(),t.stopPropagation()),Ae(te)},me=t=>{if(t.pointerType!=="touch"||a.pointerId!==t.pointerId)return;const p=!a.moved;a.pointerId=null,a.startX=null,a.startY=null,a.moved=!1,a.lastY=null,a.lastTime=null;try{e.releasePointerCapture(t.pointerId)}catch{}if(p){b?E(t.clientX,t.clientY):R&&!V.current&&(V.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(a.velocity)<M){a.velocity=0;return}let l=B();const h=()=>{const w=B(),v=Math.max(w-l,8);l=w;const g=Ae(a.velocity*v)??!1,te=Math.sign(a.velocity),ye=Math.max(0,Math.abs(a.velocity)-ee*v);if(a.velocity=ye*te,!g||ye<=M){W(),a.velocity=0;return}a.rafId=window.requestAnimationFrame(h)};a.rafId=window.requestAnimationFrame(h)};e.addEventListener("pointerdown",P,T),e.addEventListener("pointermove",le,T),e.addEventListener("pointerup",me,T),e.addEventListener("pointercancel",me,T);const ue=e.style.touchAction;e.style.touchAction="manipulation",oe.current=()=>{W(),J.current!==null&&typeof window<"u"&&(window.clearTimeout(J.current),J.current=null),Re.current=0,e.removeEventListener("pointerdown",P,T),e.removeEventListener("pointermove",le,T),e.removeEventListener("pointerup",me,T),e.removeEventListener("pointercancel",me,T),e.style.touchAction=ue};return}const ae=6,De=a=>{a.touches.length===1&&(W(),r.lastY=a.touches[0].clientY,r.lastTime=B(),r.velocity=0,r.startX=a.touches[0].clientX,r.startY=a.touches[0].clientY,r.didMove=!1)},Se=a=>{if(a.touches.length!==1){r.lastY=null,r.lastTime=null,r.velocity=0,r.startX=null,r.startY=null,r.didMove=!1,W();return}const he=a.touches[0].clientX,P=a.touches[0].clientY;if(r.startX!==null&&r.startY!==null&&!r.didMove){const v=he-r.startX,g=P-r.startY;Math.hypot(v,g)>=ae&&(r.didMove=!0)}if(r.lastY===null){r.lastY=P,r.lastTime=B();return}const le=r.lastY,me=r.lastTime??B(),ue=B();r.lastY=P,r.lastTime=ue;const t=le-P;if(Math.abs(t)<1)return;const p=Math.max(ue-me,8),l=s+Math.min(m,Math.abs(t)/o),h=t*l,w=h/p;r.velocity=r.velocity*(1-k)+w*k,r.velocity>y?r.velocity=y:r.velocity<-y&&(r.velocity=-y),r.didMove&&(a.preventDefault(),a.stopPropagation()),Ae(h)},q=a=>{const he=!r.didMove;r.lastY=null,r.lastTime=null;const P=r.velocity;if(r.startX=null,r.startY=null,r.didMove=!1,he){const ue=a.changedTouches?.[0];b?E(ue?.clientX,ue?.clientY):R&&!V.current&&(V.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(P)<M){r.velocity=0;return}let le=B();const me=()=>{const ue=B(),t=Math.max(ue-le,8);le=ue;const p=Ae(r.velocity*t)??!1,l=Math.sign(r.velocity),h=Math.max(0,Math.abs(r.velocity)-ee*t);if(r.velocity=h*l,!p||h<=M){W(),r.velocity=0;return}r.rafId=window.requestAnimationFrame(me)};r.rafId=window.requestAnimationFrame(me)};e.addEventListener("touchstart",De,T),e.addEventListener("touchmove",Se,T),e.addEventListener("touchend",q,T),e.addEventListener("touchcancel",q,T);const ce=e.style.touchAction;e.style.touchAction="manipulation",oe.current=()=>{W(),J.current!==null&&typeof window<"u"&&(window.clearTimeout(J.current),J.current=null),Re.current=0,e.removeEventListener("touchstart",De,T),e.removeEventListener("touchmove",Se,T),e.removeEventListener("touchend",q,T),e.removeEventListener("touchcancel",q,T),e.style.touchAction=ce}},[R,b,E,G]);n.useEffect(()=>{let e=!1,i=null,s=null,m=null,o=[],k=null,y=null;const M=O.current;if(!M)return;if(M.tabIndex=b?-1:0,b){const W=M.focus.bind(M),T=M;T.focus=((...K)=>{E()}),y=()=>{T.focus=W}}const ee=()=>{A(!0)},r=()=>{A(!1)},B=W=>{const T=W.target;if(T&&M.contains(T)){if(b&&T instanceof HTMLElement){window.setTimeout(()=>{T.blur(),E()},0),A(!1);return}if(R&&!V.current&&T instanceof HTMLElement){window.setTimeout(()=>{T.blur()},0),A(!1);return}A(!0);return}A(!1)},F=()=>{A(!1)};let U=null;return(async()=>{try{const W=await Lt();if(e)return;const T=Vt($,G,C,W,!1),K=new vt(T);ge.current=!0,b&&(K.focus=()=>{});const ae=K;if(typeof ae.scrollToBottom=="function"){const ce=ae.scrollToBottom.bind(ae);ae.scrollToBottom=()=>{ge.current&&ce()},k=()=>{ae.scrollToBottom=ce}}const De=new Tt;i=K,I.current=K,et.current=De,K.loadAddon(De),K.open(M),ct(),Fe.current=!1,U=K.textarea??M.querySelector("textarea"),U&&(U.addEventListener("focus",ee),U.addEventListener("blur",r)),rt(),typeof MutationObserver<"u"&&(m=new MutationObserver(()=>{rt()}),m.observe(M,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["contenteditable","role","tabindex","aria-label"]}));const Se=Ft(M);Se?(Se.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),je.current=Se,ft()):je.current=null,H();const q=De;typeof q.observeResize=="function"&&q.observeResize(),Pe(),o=[K.onData(ce=>{Y.current(ce)}),K.onScroll(ce=>{if(typeof ce=="number"&&Number.isFinite(ce)){const a=typeof K.hasSelection=="function"&&K.hasSelection();ge.current=!a&&ce<=.5}}),K.onSelectionChange(()=>{if(typeof K.hasSelection=="function"&&K.hasSelection()){ge.current=!1;return}const a=typeof K.getViewportY=="function"?K.getViewportY():0;ge.current=a<=.5})],s=new ResizeObserver(()=>{H()}),s.observe(M),typeof window<"u"&&window.setTimeout(()=>{H()},0)}catch{}})(),document.addEventListener("focusin",B,!0),window.addEventListener("blur",F),()=>{e=!0,oe.current?.(),oe.current=null,document.removeEventListener("focusin",B,!0),window.removeEventListener("blur",F),o.forEach(W=>W.dispose()),k?.(),k=null,U&&(U.removeEventListener("focus",ee),U.removeEventListener("blur",r)),s?.disconnect(),m?.disconnect(),y?.(),i?.dispose(),I.current=null,et.current=null,je.current=null,x.current=null,Fe.current=null,ie()}},[rt,R,H,E,$,G,Pe,C,ie,A,b]),n.useEffect(()=>{const e=I.current;e&&(e.reset(),ie(),x.current=null,H())},[u,nt,H,ie]),n.useEffect(()=>{!at||!I.current||L()},[at,L,u,nt]),n.useEffect(()=>(Pe(),()=>{oe.current?.(),oe.current=null}),[Pe,u]),n.useEffect(()=>{const e=I.current;if(!e)return;if(c.length===0){Le.current!==null&&(e.reset(),ie(),H());return}const i=Le.current;let s;if(i===null)s=c;else{const m=c.findIndex(o=>o.id===i);s=m>=0?c.slice(m+1):c}s.length>0&&$e(s.map(m=>m.data).join("")),Le.current=c[c.length-1].id},[c,nt,$e,H,ie]),n.useImperativeHandle(Ce,()=>({focus:()=>{L()},clear:()=>{const e=I.current;e&&(e.reset(),ie(),H())},fit:()=>{H()}}),[L,H,ie]);const Ge=n.useCallback(e=>{if(!b)return;const i=O.current,s=e.relatedTarget,m=s?.tagName,o=m==="INPUT"||m==="TEXTAREA"||s?.isContentEditable,k=s?.getAttribute("data-terminal-hidden-input")==="true",y=!!(s&&i?.contains(s))},[b]),Oe=n.useCallback(e=>{const i=e.nativeEvent,s=i?.inputType??"",m=typeof i?.data=="string"?i.data:"";if(j.current=typeof performance<"u"?performance.now():Date.now(),s==="insertCompositionText"){de.current=!0;return}if(!s&&m){if(de.current)return;e.preventDefault(),Y.current(m),xe.current={type:"insertText",at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0;return}if(s==="insertText"&&m){if(de.current)return;e.preventDefault(),Y.current(m),xe.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0;return}if(s==="insertLineBreak"){if(de.current)return;e.preventDefault(),Y.current("\r"),xe.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0;return}if(s==="deleteContentBackward"){if(de.current)return;e.preventDefault(),Y.current(""),xe.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0}},[]),ot=n.useCallback(e=>{const i=e.currentTarget;if(j.current=typeof performance<"u"?performance.now():Date.now(),de.current)return;if(Z.current){const o=xe.current,k=typeof performance<"u"?performance.now():Date.now();if(o&&k-o.at<50){Z.current=!1,z(i);return}Z.current=!1}const s=N(i);if(!s)return;we.current=s;const m=s.replace(/\r\n|\r|\n/g,"\r");Y.current(m),z(i),we.current=""},[z,N]),_e=n.useCallback(e=>{e.stopPropagation();const i=e.key.toLowerCase(),s=e.metaKey&&!e.ctrlKey&&!e.altKey&&i==="c",m=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&i==="c";if((s||m)&&Q()){e.preventDefault(),ve();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){const F=e.key.toUpperCase();if(F>="A"&&F<="Z"){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),Y.current(String.fromCharCode(F.charCodeAt(0)-64)),z(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),Y.current("\x1B"+e.key),z(e.currentTarget);return}const k={ArrowUp:"\x1B[A",ArrowDown:"\x1B[B",ArrowRight:"\x1B[C",ArrowLeft:"\x1B[D",Escape:"\x1B",Tab:" ",Delete:"\x1B[3~",Home:"\x1B[H",End:"\x1B[F"}[e.key];if(k){e.preventDefault(),Y.current(k),z(e.currentTarget);return}const y=e.currentTarget;if(e.nativeEvent?.isComposing)return;const ee=xe.current,r=typeof performance<"u"?performance.now():Date.now(),B=!!(ee&&r-ee.at<50);if(e.key==="Enter"){if(B&&ee?.type==="insertLineBreak")return;e.preventDefault(),Y.current("\r"),z(y);return}if(e.key==="Backspace"){if(e.preventDefault(),B&&ee?.type==="deleteContentBackward")return;N(y)||Y.current("")}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const F=j.current;F&&r-F<50||(e.preventDefault(),Y.current(e.key),Z.current=!0,xe.current={type:"keydown-text",at:r})}Ke(y)},[z,ve,Q,N,Ke]),Ye=n.useCallback(e=>{e.stopPropagation();const i=e.currentTarget;e.nativeEvent?.isComposing||Ke(i)},[Ke]),Je=n.useCallback(e=>{const i=e.currentTarget;de.current=!1;const s=e.data||N(i);if(j.current=typeof performance<"u"?performance.now():Date.now(),!s)return;const m=s.replace(/\r\n|\r|\n/g,"\r");Y.current(m),z(i),xe.current={type:"compositionend",at:typeof performance<"u"?performance.now():Date.now()},Z.current=!0},[z,N]),He=n.useCallback(e=>{e.stopPropagation();const i=e.clipboardData?.getData("text")??"";if(!i)return;e.preventDefault();const m=I.current?.hasBracketedPaste?.()?`\x1B[200~${i}\x1B[201~`:i;Y.current(m)},[]),ke={position:"fixed",left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:"transparent",color:"transparent",WebkitTextFillColor:"transparent",caretColor:"transparent",textShadow:"none",WebkitAppearance:"none",appearance:"none",resize:"none",overflow:"hidden",whiteSpace:"nowrap",border:"0",padding:0,margin:0,outline:"none",outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:"none",WebkitUserSelect:"none",userSelect:"none"};return f.jsxs("div",{ref:O,className:Ze("relative h-full w-full terminal-viewport-container",be),"data-hidden-input-overlay-active":b?"true":void 0,style:{backgroundColor:C.background},onTouchStart:e=>{if(!(!b||R)&&!Q()){const i=e.touches?.[0];E(i?.clientX,i?.clientY)}},onClick:e=>{if(!R)if(b){if(Q())return;E(e.clientX,e.clientY)}else I.current?.focus()},onMouseUp:()=>{!R&&Q()&&ve()},onTouchEnd:()=>{!R&&Q()&&ve()},children:[b&&typeof document<"u"?xt.createPortal(f.jsxs(f.Fragment,{children:[f.jsx("input",{ref:We,type:"text",inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":_("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...ke,display:pe?"block":"none"},onBlur:Ge,onBeforeInput:Oe,onCompositionStart:()=>{de.current=!0},onInput:ot,onKeyDown:_e,onKeyUp:Ye,onCompositionEnd:Je,onPaste:He}),f.jsx("textarea",{ref:se,inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":_("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...ke,display:pe?"none":"block"},onBlur:Ge,onBeforeInput:Oe,onCompositionStart:()=>{de.current=!0},onInput:ot,onKeyDown:_e,onKeyUp:Ye,onCompositionEnd:Je,onPaste:He})]}),document.body):null,je.current&&!R?f.jsx(Et,{containerRef:je,disableHorizontal:!0,className:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero"}):null]})});gt.displayName="TerminalViewport";const Kt="\x1B",Ot=new RegExp(`${Kt}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Yt=/(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 c=u;for(;c.length>0;){const d=c[c.length-1];if(d===")"||d==="]"||d==="}"||d===">"){const S=d===")"?"(":d==="]"?"[":d==="}"?"{":"<",C=c.slice(0,-1),$=(C.match(new RegExp(`\\${S}`,"g"))||[]).length,G=(C.match(new RegExp(`\\${d}`,"g"))||[]).length;if($>G)break;c=C;continue}if(Ut.has(d)){c=c.slice(0,-1);continue}break}return c},yt=u=>{let c=Wt(u);return c=c.replace("0.0.0.0","127.0.0.1"),c=c.replace("[::1]","127.0.0.1"),c=c.replace("[::]","127.0.0.1"),c},qt=u=>{if(!u)return null;const c=u.replace(Ot,""),d=c.match(zt);if(d?.[1]){const C=Number.parseInt(d[1],10);if(Number.isFinite(C)&&C>0&&C<=65535)return`http://127.0.0.1:${C}/`}const S=c.split(`
2
2
  `);for(const C of S){if(!Ht.test(C))continue;const $=Array.from(C.matchAll(Yt));if($.length===0)continue;const G=$.find(be=>{try{return!!new URL(yt(be[1])).port}catch{return!1}});return yt((G??$[0])[1])}return null},Xt=async(u,c=1500)=>{if(!u||typeof window>"u")return!1;let d;try{d=new URL(u)}catch{return!1}if(d.protocol!=="http:"&&d.protocol!=="https:")return!1;const S=d.hostname.toLowerCase();if(S!=="localhost"&&S!=="127.0.0.1"&&S!=="0.0.0.0"&&S!=="::1"&&S!=="::")return!1;const C=new AbortController,$=window.setTimeout(()=>C.abort(),c);try{const G=await Dt("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:d.toString()}),cache:"no-store",signal:C.signal});return G.ok?(await G.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout($)}},$t={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},ut={ctrl:"5",cmd:"3"},mt={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},Gt={retry:{...mt.retry,initialDelayMs:200,maxDelayMs:500},connectionTimeoutMs:1500},_t=(u,c)=>{if(c)switch(u){case"arrow-up":return`\x1B[1;${ut[c]}A`;case"arrow-down":return`\x1B[1;${ut[c]}B`;case"arrow-right":return`\x1B[1;${ut[c]}C`;case"arrow-left":return`\x1B[1;${ut[c]}D`}return $t[u]??null},sn=()=>{const{t:u}=bt(),{terminal:c,runtime:d}=Rt(),{currentTheme:S}=At(),{monoFont:C}=St(),$=Me(t=>t.terminalFontSize),G=Me(t=>t.bottomTerminalHeight),be=Me(t=>t.isBottomTerminalExpanded),{isMobile:R,isTablet:at,hasTouchOnlyPointer:Ne}=It(),Ce=R||at,_=(Ce||Ne)&&d.platform==="web",O=d.platform!=="vscode",je=Me(t=>t.showTerminalQuickKeysOnDesktop),I=Ce||je,et=ht(t=>t.currentSessionId),Y=ht(t=>t.newSessionDraft),Ue=et!==null||Y?.open===!0,x=Mt()??null,Ee=X(t=>t.sessions),re=X(t=>t.hasHydrated),Ve=X(t=>t.ensureDirectory),Le=X(t=>t.createTab),ge=X(t=>t.setActiveTab),oe=X(t=>t.closeTab),J=X(t=>t.setTabSessionId),Re=X(t=>t.setTabLifecycle),se=X(t=>t.setConnecting),We=X(t=>t.appendToBuffer),de=X(t=>t.setTabPreviewUrl),Z=X(t=>t.clearBuffer),xe=Me(t=>t.openContextPreview),j=n.useMemo(()=>{if(x)return Ee.get(x)},[Ee,x]),D=n.useMemo(()=>j?O?j.activeTabId??j.tabs[0]?.id??null:j.tabs[0]?.id??null:null,[j,O]),we=n.useMemo(()=>{if(j)return D?j.tabs.find(t=>t.id===D)??j.tabs[0]:j.tabs[0]},[j,D]),Fe=n.useMemo(()=>(j?.tabs??[]).map(t=>({icon:(()=>{const p=t.iconKey?Bt[t.iconKey]??"terminal":"terminal";return f.jsx(fe,{name:p,className:"h-4 w-4"})})(),id:t.id,label:t.label,title:t.label,closeLabel:u("terminalView.tabs.closeTabTitle")})),[j?.tabs,u]),V=we?.terminalSessionId??null,tt=we?.lifecycle??"idle",ft=we?.bufferChunks??[],nt=we?.isConnecting??!1,ct=we?.previewUrl??null,[lt,b]=n.useState(null),[rt,A]=n.useState(!1),[pe,E]=n.useState(!1),[L,N]=n.useState(null),[z,Ke]=n.useState(!1),[qe,Xe]=n.useState(0),ve=n.useRef(null),Q=n.useRef(null),ie=n.useRef(D),H=n.useRef(V),Te=n.useRef(x),Be=n.useRef(null),$e=n.useRef(null),Pe=n.useRef(!1),Ge=n.useRef(null),Oe=n.useRef(new Set),ot=n.useRef(!1),_e=n.useRef(""),Ye=n.useRef(new Set),Je=n.useRef(0),He=n.useCallback(()=>{_e.current="",Ye.current.clear(),Je.current+=1},[]),ke=n.useCallback(()=>{_||typeof document<"u"&&!document.hasFocus()||Be.current?.focus()},[_]),e=n.useCallback(()=>{_||Be.current?.focus()},[_]);n.useEffect(()=>{if(!re||ot.current)return;ot.current=!0;const t=new Set;for(const[,p]of X.getState().sessions.entries())for(const l of p.tabs)l.terminalSessionId&&t.add(l.terminalSessionId);Oe.current=t},[re]);const i=Me(t=>t.activeMainTab),s=Me(t=>t.isBottomTerminalOpen),m=Me(t=>t.setBottomTerminalOpen),o=Me(t=>t.setBottomTerminalExpanded),k=i==="terminal",y=k||s,[M,ee]=n.useState(y);n.useEffect(()=>{!y||d.platform==="vscode"||Nt()},[y,d.platform]),n.useEffect(()=>{y&&ee(!0)},[y]),n.useEffect(()=>{Pe.current=y},[y]),n.useEffect(()=>{H.current=V},[V]),n.useEffect(()=>{ie.current=D,He()},[D,He]),n.useEffect(()=>{Te.current=x},[x]),n.useEffect(()=>{!I&&L!==null&&N(null)},[I,L,N]),n.useEffect(()=>{!V&&L!==null&&N(null)},[V,L,N]);const r=n.useCallback(()=>{ve.current?.(),ve.current=null,Q.current=null,E(!1)},[]);n.useEffect(()=>()=>{r(),H.current=null},[r]);const B=n.useCallback((t,p,l)=>{if(!l)return;const h=`${_e.current}${l}`.replace(/\r\n|\r/g,`
3
3
  `),w=h.split(`
4
4
  `),v=h.endsWith(`