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