@openchamber/web 1.13.5 → 1.13.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lib/commands-update.test.js +50 -0
- package/dist/assets/{DiagramView-Bbj-QI7h.js → DiagramView-BJkP8Fjp.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-BNr_9Jsb.js → MarkdownRendererImpl-Nq7bOf31.js} +3 -3
- package/dist/assets/{MultiRunWindow-DMMu53kw.js → MultiRunWindow-CRKVePMG.js} +1 -1
- package/dist/assets/NewWorktreeDialog-Dj6KETex.js +167 -0
- package/dist/assets/{OnboardingScreen-BucKVBD7.js → OnboardingScreen-DRe8UNiS.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-B6kvduse.js → SessionSwitcherDropdown-Cn_yoQrm.js} +1 -1
- package/dist/assets/{SettingsWindow-BEfDro9b.js → SettingsWindow-BIKNrxSK.js} +1 -1
- package/dist/assets/{TerminalView-CMdqMpTy.js → TerminalView-BDjzrhGS.js} +1 -1
- package/dist/assets/{es-Bk-yR0w-.js → es-D0PPWgfL.js} +1 -1
- package/dist/assets/{fr-f1ibV7QU.js → fr-4AxG2GNC.js} +1 -1
- package/dist/assets/index-AsCHiJ5P.js +3 -0
- package/dist/assets/{index-B82A6jBD.css → index-Bv4711NQ.css} +1 -1
- package/dist/assets/{ja-D9mS3zWP.js → ja-BPVJtPU2.js} +1 -1
- package/dist/assets/{ko-Cpl1IA3D.js → ko-BJHERh2a.js} +1 -1
- package/dist/assets/main-BByFAmjA.js +214 -0
- package/dist/assets/{main-KEVf2Yak.js → main-BJDsJGkp.js} +2 -2
- package/dist/assets/miniChat-Ckr71tB9.js +2 -0
- package/dist/assets/mobile-DVDtnIcD.js +2 -0
- package/dist/assets/{pl-CYke_fxL.js → pl-CH00wT_K.js} +1 -1
- package/dist/assets/{pt-BR-Clb6Z8up.js → pt-BR-1tfKEfvN.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-Cb1iUq8M.js → renderElectronMiniChatApp-CXvtB6Rd.js} +2 -2
- package/dist/assets/{renderMobileApp-7chEBHPK.js → renderMobileApp-BVAt5rTM.js} +3 -3
- package/dist/assets/{uk-CXn8cxXa.js → uk-BkeRI8D4.js} +1 -1
- package/dist/assets/{useAppFontEffects-Bd0ks39c.js → useAppFontEffects-B66TruVB.js} +114 -114
- package/dist/assets/{zh-CN-BRwwlEdG.js → zh-CN-DtROWolc.js} +1 -1
- package/dist/assets/{zh-TW-D5pg5Z8l.js → zh-TW-CDqNEP6z.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/package-manager.js +2 -2
- package/server/lib/package-manager.test.js +13 -1
- package/dist/assets/NewWorktreeDialog-5TYBoMMA.js +0 -167
- package/dist/assets/index-BsXkdBYx.js +0 -3
- package/dist/assets/main-DOdUrt3s.js +0 -214
- package/dist/assets/miniChat-Nlzqr3Df.js +0 -2
- package/dist/assets/mobile-BIhOFhia.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as I,j as t,R as a,e as W}from"./vendor-.bun-By2L9XvG.js";import{h as O,a1 as B,e as M,z as re,C as ae,f as le}from"./index-BsXkdBYx.js";import{u as V,eb as me,f5 as oe,aG as Z,ea as ee,B as U,n as z,p as ce,m as J,I as T,aJ as Q}from"./useAppFontEffects-Bd0ks39c.js";function pe(r){switch(r){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function q(r){return r==="wrong-service"||r==="unreachable"||r==="incompatible"}function ie({onBack:r,showBackButton:e=!0,initialUrl:c="",initialLabel:n="",isRecoveryMode:o=!1,onConnect:b,onSwitchToLocal:i}){const{t:s}=V(),[h,y]=I.useState(c),[x,S]=I.useState(n),[N,f]=I.useState("idle"),[m,v]=I.useState(null),[R,C]=I.useState(""),j=me(h),p=j?.persistedUrl??null,w=I.useCallback(d=>{y(d.target.value),f("idle"),v(null),C("")},[]),g=I.useCallback(d=>{S(d.target.value)},[]),k=I.useCallback(async()=>{if(p){f("testing"),v(null),C("");try{const d=await oe(p);v(d),f(d.status==="ok"||d.status==="update-recommended"?"success":"error")}catch(d){C(d instanceof Error?d.message:s("onboarding.remoteConnection.errors.connectionTestFailed")),f("error")}}},[p,s]),K=I.useCallback(async()=>{if(!j)return;const d=j.persistedUrl;f("testing"),v(null),C("");try{const D=await oe(d);if(v(D),q(D.status)){f("error");return}const F=await Z(),de=x.trim()||d,G=F.hosts.find($=>$.url===d),Y=G?G.id:`host-${Date.now().toString(16)}`,te={id:Y,label:de,url:d,apiUrl:d},ue=G?F.hosts.map($=>$.id===Y?te:$):[...F.hosts,te];if(await ee({hosts:ue,defaultHostId:Y,initialHostChoiceCompleted:!0}),b?.(),j.redeemUrl){window.location.assign(j.redeemUrl);return}O()&&await B()}catch(D){C(D instanceof Error?D.message:s("onboarding.remoteConnection.errors.failedToSaveConnection")),f("error")}},[j,x,b,s]),L=N==="testing",A=p!==null&&!L,_=p!==null&&!L&&!q(m?.status??null),P=pe(m?.status??null),H=m?.status==="ok",u=m?.status==="update-recommended",E=m?.status==="auth",l=q(m?.status??null);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e&&t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:s("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(o?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s("onboarding.remoteConnection.description")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx(z,{id:"remote-url",type:"url",value:h,onChange:w,placeholder:s("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:L})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.nameOptional")}),t.jsx(z,{id:"remote-label",type:"text",value:x,onChange:g,placeholder:s("onboarding.remoteConnection.field.namePlaceholder"),disabled:L})]})]}),m&&H&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:s("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&E&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:s("onboarding.remoteConnection.status.authWarning")}),m&&u&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:P?s(P):null}),m&&l&&t.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold mb-1",children:s("onboarding.remoteConnection.status.connectionFailed")}),t.jsx("div",{className:"opacity-90",children:P?s(P):null})]}),t.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?s("onboarding.remoteConnection.status.suggestionsUnreachable"):s("onboarding.remoteConnection.status.suggestionsWrongService")})]}),R&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:R}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(U,{variant:"outline",onClick:k,disabled:!A,children:s(L?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),t.jsx(U,{onClick:K,disabled:!_,children:s("onboarding.remoteConnection.actions.connectAndRestart")})]}),l&&t.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:s("onboarding.remoteConnection.actions.whatToDo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(U,{variant:"outline",size:"sm",onClick:r,className:"flex-1",children:s("onboarding.remoteConnection.actions.chooseDifferentServer")}),!o&&i&&t.jsx(U,{variant:"outline",size:"sm",onClick:i,className:"flex-1",children:s("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const he="curl -fsSL https://opencode.ai/install | bash",fe="https://opencode.ai/docs",se=2500;function be(r){const e=W.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:n,"aria-label":n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}function xe({onCliAvailable:r}){const{t:e}=V(),[c,n]=a.useState(!1),[o,b]=a.useState(!1),[i,s]=a.useState(!1),[h,y]=a.useState(!1),[x,S]=a.useState(""),[N,f]=a.useState("unknown"),[m,v]=a.useState("local"),[R,C]=a.useState(!1),[j,p]=a.useState(!1);a.useEffect(()=>{b(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){f("unknown");return}const l=navigator.userAgent||"";/Windows/i.test(l)?f("windows"):/Macintosh|Mac OS X/i.test(l)?f("macos"):/Linux/i.test(l)?f("linux"):f("unknown")},[]),a.useEffect(()=>{let l=!1;return(async()=>{try{const d=await M("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!d.ok)return;const D=await d.json().catch(()=>null);if(!D||l)return;const F=typeof D.opencodeBinary=="string"?D.opencodeBinary.trim():"";F&&S(F)}catch{}})(),()=>{l=!0}},[]);const w=a.useCallback(async l=>{const d=l.target;d.closest(".app-region-no-drag")||d.closest("button, a, input, select, textarea, code, summary, details")||l.button===0&&o&&await re()},[o]),g=a.useCallback(async()=>{try{const l=await M("/health");if(!l.ok)return!1;const d=await l.json();return d.openCodeRunning===!0||d.isOpenCodeReady===!0}catch{return!1}},[]),k=a.useCallback(async l=>{if(!o)return;const d=await Z();await ee({...d,...l==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[o]),K=a.useCallback(async()=>{o&&await k("local"),r?.()},[o,r,k]);a.useEffect(()=>{if(m!=="local")return;let l=!1,d=null;const D=async()=>{if(!l){try{const F=await g();if(l)return;if(F){await K();return}}catch{}l||(d=setTimeout(D,se))}};return d=setTimeout(D,se),()=>{l=!0,d&&clearTimeout(d)}},[m,g,K]);const L=a.useCallback(async()=>{y(!0);try{await g()&&await K()}finally{y(!1)}},[g,K]),A=a.useCallback(async()=>{if(!(typeof window>"u")&&o)try{const l=await ae();l.success&&l.path&&l.path.trim().length>0&&S(l.path.trim())}catch{}},[o]),_=a.useCallback(async()=>{s(!0);try{if(await le({opencodeBinary:x.trim()}),o){await k("local"),await B();return}await M("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>s(!1),1e3)}},[o,x,k]),P=a.useCallback(async()=>{const l=await ce(he);l.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",l.error)},[]),H=fe,u=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",E=!o||m==="local";return t.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:w,children:t.jsxs("div",{className:"w-full max-w-md space-y-7",children:[t.jsxs("header",{className:"text-center space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:e("onboarding.chooser.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e("onboarding.chooser.description")})]}),o&&t.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[t.jsx("button",{type:"button",className:J("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("local"),children:e("onboarding.chooser.tabs.localInstall")}),t.jsx("button",{type:"button",className:J("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("remote"),children:e("onboarding.chooser.tabs.connectRemote")})]}),o&&m==="remote"?t.jsx("div",{className:"app-region-no-drag",children:t.jsx(ie,{onBack:()=>v("local"),showBackButton:!1,onSwitchToLocal:()=>v("local")})}):null,E&&t.jsxs("div",{className:"space-y-4",children:[N==="windows"&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-4",children:[t.jsx("div",{className:"text-sm text-foreground",children:e("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:e("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:e("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:e("onboarding.localSetup.intro")}),t.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:c?t.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),e("onboarding.common.status.copiedToClipboard")]}):t.jsx(be,{onCopy:P,copyTitle:e("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[t.jsxs("a",{href:H,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[e(N==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),t.jsx("button",{type:"button",onClick:L,disabled:h,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:e(h?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),t.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[t.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 shrink-0","aria-hidden":!0,children:[t.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}}),t.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-foreground leading-tight",children:e("onboarding.localSetup.status.watching")}),t.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:e("onboarding.localSetup.status.autoContinue")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:R,onToggle:l=>C(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.advanced.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsxs("div",{className:"pb-4 space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(z,{value:x,onChange:l=>S(l.target.value),placeholder:u,disabled:i,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:i||!o,children:e("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",size:"sm",onClick:_,disabled:i||!x.trim(),children:e("onboarding.localSetup.actions.apply")})]}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:e("onboarding.localSetup.helper.saveAndReload")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:j,onToggle:l=>p(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.troubleshoot.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:N==="windows"?t.jsx(t.Fragment,{children:t.jsx("li",{children:e("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("li",{children:e("onboarding.localSetup.hint.ensurePath")}),t.jsx("li",{children:e("onboarding.localSetup.hint.setEnv")}),t.jsx("li",{children:e("onboarding.localSetup.hint.missingRuntime")})]})})]})]})]})})}const ge="curl -fsSL https://opencode.ai/install | bash",ye="https://opencode.ai/docs";function ve(r){const e=W.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-center gap-3",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}const we=3e4;function je({onBack:r,onCliAvailable:e,isFromRecovery:c=!1,onSwitchToRemote:n}){const{t:o}=V(),[b,i]=a.useState(!1),[s,h]=a.useState(!1),[y,x]=a.useState(!1),[S,N]=a.useState(!1),[f,m]=a.useState(!1),[v,R]=a.useState(null),[C,j]=a.useState(""),[p,w]=a.useState("unknown");a.useEffect(()=>{const u=setTimeout(()=>h(!0),we);return()=>clearTimeout(u)},[]),a.useEffect(()=>{x(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){w("unknown");return}const u=navigator.userAgent||"";if(/Windows/i.test(u)){w("windows");return}if(/Macintosh|Mac OS X/i.test(u)){w("macos");return}if(/Linux/i.test(u)){w("linux");return}w("unknown")},[]),a.useEffect(()=>{let u=!1;return(async()=>{try{const E=await M("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!E.ok)return;const l=await E.json().catch(()=>null);if(!l||u)return;const d=typeof l.opencodeBinary=="string"?l.opencodeBinary.trim():"";d&&j(d)}catch{}})(),()=>{u=!0}},[]);const g=a.useCallback(async u=>{u.target.closest("button, a, input, select, textarea, code")||u.button===0&&y&&await re()},[y]),k=a.useCallback(async()=>{try{const u=await M("/health");if(!u.ok)return!1;const E=await u.json();return E.openCodeRunning===!0||E.isOpenCodeReady===!0}catch{return!1}},[]),K=a.useCallback(async()=>{if(!(typeof window>"u")&&y)try{const u=await ae();u.success&&u.path&&u.path.trim().length>0&&j(u.path.trim())}catch{}},[y]),L=a.useCallback(async()=>{N(!0);try{if(await le({opencodeBinary:C.trim()}),y){await B();return}await M("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>N(!1),1e3)}},[y,C]),A=a.useCallback(async()=>{const u=await ce(ge);u.ok?(i(!0),setTimeout(()=>i(!1),2e3)):console.error("Failed to copy:",u.error)},[]),_=a.useCallback(async()=>{m(!0),R(null);try{await k()?e?.():R(o("onboarding.localSetup.errors.cliNotReady"))}catch(u){R(u instanceof Error?u.message:o("onboarding.localSetup.errors.detectionFailed"))}finally{m(!1)}},[k,e,o]),P=ye,H=p==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":p==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode";return t.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:g,children:[t.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:o("onboarding.localSetup.title")}),t.jsx("p",{className:"text-muted-foreground",children:o("onboarding.localSetup.description")})]}),p==="windows"&&t.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[t.jsx("div",{className:"text-sm text-foreground",children:o("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:o("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:o("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:b?t.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),o("onboarding.common.status.copiedToClipboard")]}):t.jsx(ve,{onCopy:A,copyTitle:o("onboarding.common.copyToClipboard")})})}),t.jsxs("a",{href:P,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1 justify-center",children:[o(p==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),v&&t.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:v}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(U,{type:"button",onClick:_,disabled:f,className:"w-full max-w-xs",size:"lg",children:o(f?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:o("onboarding.localSetup.helper.checkAndContinue")})]}),t.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:o("onboarding.localSetup.field.alreadyInstalled")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(z,{value:C,onChange:u=>j(u.target.value),placeholder:H,disabled:S,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",onClick:K,disabled:S||!y,children:o("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",onClick:L,disabled:S,children:o("onboarding.localSetup.actions.apply")})]}),t.jsx("div",{className:"text-xs text-muted-foreground/70",children:o("onboarding.localSetup.helper.saveAndReload")})]})}),c&&n&&t.jsxs("div",{className:"text-center pt-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:o("onboarding.localSetup.remotePreference")}),t.jsx(U,{variant:"link",onClick:n,children:o("onboarding.localSetup.actions.connectRemoteServer")})]})]}),s&&t.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:p==="windows"?t.jsx(t.Fragment,{children:t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.ensurePath")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.setEnv")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.missingRuntime")})]})})]})}function X(r,e){if(r?.trim())return Q(r.trim());if(e)return Q(e)}function ke(r,e,c){switch(r){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const n=X(e,c);return{title:"Remote Server Unreachable",description:`Could not connect to "${n||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-wrong-service":{const n=X(e,c);return{title:"Incompatible Server",description:`The server at "${n||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-incompatible":{const n=X(e,c);return{title:"Server Update Required",description:`The OpenChamber server at "${n||"unknown"}" is not compatible with this app version. Update OpenChamber on the server, then try again.`,titleKey:"onboarding.desktopRecovery.remoteIncompatible.title",descriptionKey:"onboarding.desktopRecovery.remoteIncompatible.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"missing-default-host":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};default:{const n=r;throw new Error(`Unknown recovery variant: ${n}`)}}}function Ce(r){switch(r){case"local":return t.jsx(T,{name:"macbook",className:"h-8 w-8"});case"remote":return t.jsx(T,{name:"server",className:"h-8 w-8"})}}function Ne({variant:r,hostLabel:e,hostUrl:c,onRetry:n,onUseLocal:o,onUseRemote:b,isRetrying:i=!1}){const{t:s}=V(),h=ke(r,e,c),y=h.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",x=a.useMemo(()=>{if(h.descriptionParams?.host)return h.descriptionParams;if(r==="remote-unreachable")return{host:s("onboarding.desktopRecovery.placeholders.remoteServer")};if(r==="remote-wrong-service"||r==="remote-incompatible")return{host:s("onboarding.desktopRecovery.placeholders.unknownServer")}},[h.descriptionParams,s,r]);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[t.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:t.jsx("div",{style:{color:"var(--status-warning)"},children:Ce(h.iconKey)})}),t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(h.titleKey)}),t.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:s(h.descriptionKey,x)})]}),c&&(r==="remote-unreachable"||r==="remote-wrong-service"||r==="remote-incompatible")&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:Q(c)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[h.showRetry&&n&&t.jsxs(U,{onClick:n,disabled:i,className:"w-full",children:[t.jsx(T,{name:"refresh",className:J("h-4 w-4",i&&"animate-spin")}),s(i?"onboarding.desktopRecovery.actions.retrying":y)]}),t.jsxs("div",{className:"flex gap-2",children:[h.showUseLocal&&o&&t.jsxs(U,{variant:"outline",onClick:o,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"macbook",className:"h-4 w-4"}),s(h.useLocalLabelKey)]}),h.showUseRemote&&b&&t.jsxs(U,{variant:"outline",onClick:b,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"server",className:"h-4 w-4"}),s(h.useRemoteLabelKey)]})]})]})]})})}function ne(r,e){if(e==="use-remote")return{kind:"remote-form"};switch(r){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const c=r;throw new Error(`Unhandled RecoveryVariant: ${c}`)}}}function Re(r){const e=W.c(27),{variant:c,hostUrl:n,hostLabel:o,onRetry:b,onChooseRemote:i,showRemoteForm:s,onCloseRemoteForm:h,onSwitchToLocalFromRemote:y,onEnterLocalSetup:x,isRetrying:S}=r,N=s===void 0?!1:s,f=S===void 0?!1:S,m=Se;let v;e[0]!==b?(v=async()=>{if(O()){await B();return}await M("/api/config/reload",{method:"POST"}),b?.()},e[0]=b,e[1]=v):v=e[1];const R=v;let C;e[2]!==x||e[3]!==c?(C=async()=>{if(ne(c,"use-local").kind==="local-setup"){x?.();return}if(await m("local"),O()){await B();return}window.location.reload()},e[2]=x,e[3]=c,e[4]=C):C=e[4];const j=C;let p;e[5]!==i||e[6]!==c?(p=()=>{ne(c,"use-remote").kind==="remote-form"&&i?.()},e[5]=i,e[6]=c,e[7]=p):p=e[7];const w=p;if(N){const k=c==="remote-wrong-service"?"":n||"",K=c==="remote-wrong-service"?"":o||"";let L;e[8]!==i||e[9]!==h?(L=h||(()=>i?.()),e[8]=i,e[9]=h,e[10]=L):L=e[10];let A;e[11]!==x||e[12]!==y?(A=y||(()=>{m("local").then(()=>{O()?B():x?.()})}),e[11]=x,e[12]=y,e[13]=A):A=e[13];let _;return e[14]!==K||e[15]!==k||e[16]!==L||e[17]!==A?(_=t.jsx(ie,{onBack:L,initialUrl:k,initialLabel:K,isRecoveryMode:!0,onSwitchToLocal:A}),e[14]=K,e[15]=k,e[16]=L,e[17]=A,e[18]=_):_=e[18],_}let g;return e[19]!==R||e[20]!==j||e[21]!==w||e[22]!==o||e[23]!==n||e[24]!==f||e[25]!==c?(g=t.jsx(Ne,{variant:c,hostLabel:o,hostUrl:n,onRetry:R,onUseLocal:j,onUseRemote:w,isRetrying:f}),e[19]=R,e[20]=j,e[21]=w,e[22]=o,e[23]=n,e[24]=f,e[25]=c,e[26]=g):g=e[26],g}async function Se(r){if(!O())return;const e=await Z();await ee({...e,...r==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function Ke(r){const e=W.c(26),{onBack:c,onCliAvailable:n,mode:o,recoveryVariant:b,recoveryHostUrl:i,recoveryHostLabel:s,onEnterLocalSetup:h}=r,y=o===void 0?"first-launch":o,x=b===void 0?"missing-default-host":b,[S,N]=a.useState(!1),[f,m]=a.useState(!1);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{m(!1),N(!1)},e[0]=v):v=e[0];let R;e[1]!==y||e[2]!==s||e[3]!==i||e[4]!==x?(R=[y,x,i,s],e[1]=y,e[2]=s,e[3]=i,e[4]=x,e[5]=R):R=e[5],a.useEffect(v,R);const C=f?"local-setup":y;if(C==="recovery"){let p,w;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>N(!1),w=()=>{N(!1),m(!0)},e[6]=p,e[7]=w):(p=e[6],w=e[7]);let g;e[8]!==h?(g=()=>{m(!0),h?.()},e[8]=h,e[9]=g):g=e[9];let k;return e[10]!==s||e[11]!==i||e[12]!==x||e[13]!==S||e[14]!==g?(k=t.jsx(Re,{variant:x,hostUrl:i,hostLabel:s,showRemoteForm:S,onCloseRemoteForm:p,onSwitchToLocalFromRemote:w,onEnterLocalSetup:g}),e[10]=s,e[11]=i,e[12]=x,e[13]=S,e[14]=g,e[15]=k):k=e[15],k}if(C==="local-setup"){let p;e[16]!==c||e[17]!==f?(p=()=>{f?m(!1):c?.()},e[16]=c,e[17]=f,e[18]=p):p=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=()=>N(!0),e[19]=w):w=e[19];let g;return e[20]!==n||e[21]!==f||e[22]!==p?(g=t.jsx(je,{onBack:p,onCliAvailable:n,isFromRecovery:f,onSwitchToRemote:w}),e[20]=n,e[21]=f,e[22]=p,e[23]=g):g=e[23],g}let j;return e[24]!==n?(j=t.jsx(xe,{onCliAvailable:n}),e[24]=n,e[25]=j):j=e[25],j}export{Ke as OnboardingScreen};
|
|
1
|
+
import{H as I,j as t,R as a,e as W}from"./vendor-.bun-By2L9XvG.js";import{h as O,a1 as B,e as M,z as re,C as ae,f as le}from"./index-AsCHiJ5P.js";import{u as V,ec as me,f6 as oe,aG as Z,eb as ee,B as U,n as z,p as ce,m as J,I as T,aJ as Q}from"./useAppFontEffects-B66TruVB.js";function pe(r){switch(r){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function q(r){return r==="wrong-service"||r==="unreachable"||r==="incompatible"}function ie({onBack:r,showBackButton:e=!0,initialUrl:c="",initialLabel:n="",isRecoveryMode:o=!1,onConnect:b,onSwitchToLocal:i}){const{t:s}=V(),[h,y]=I.useState(c),[x,S]=I.useState(n),[N,f]=I.useState("idle"),[m,v]=I.useState(null),[R,C]=I.useState(""),j=me(h),p=j?.persistedUrl??null,w=I.useCallback(d=>{y(d.target.value),f("idle"),v(null),C("")},[]),g=I.useCallback(d=>{S(d.target.value)},[]),k=I.useCallback(async()=>{if(p){f("testing"),v(null),C("");try{const d=await oe(p);v(d),f(d.status==="ok"||d.status==="update-recommended"?"success":"error")}catch(d){C(d instanceof Error?d.message:s("onboarding.remoteConnection.errors.connectionTestFailed")),f("error")}}},[p,s]),K=I.useCallback(async()=>{if(!j)return;const d=j.persistedUrl;f("testing"),v(null),C("");try{const D=await oe(d);if(v(D),q(D.status)){f("error");return}const F=await Z(),de=x.trim()||d,G=F.hosts.find($=>$.url===d),Y=G?G.id:`host-${Date.now().toString(16)}`,te={id:Y,label:de,url:d,apiUrl:d},ue=G?F.hosts.map($=>$.id===Y?te:$):[...F.hosts,te];if(await ee({hosts:ue,defaultHostId:Y,initialHostChoiceCompleted:!0}),b?.(),j.redeemUrl){window.location.assign(j.redeemUrl);return}O()&&await B()}catch(D){C(D instanceof Error?D.message:s("onboarding.remoteConnection.errors.failedToSaveConnection")),f("error")}},[j,x,b,s]),L=N==="testing",A=p!==null&&!L,_=p!==null&&!L&&!q(m?.status??null),P=pe(m?.status??null),H=m?.status==="ok",u=m?.status==="update-recommended",E=m?.status==="auth",l=q(m?.status??null);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e&&t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:s("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(o?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s("onboarding.remoteConnection.description")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx(z,{id:"remote-url",type:"url",value:h,onChange:w,placeholder:s("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:L})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.nameOptional")}),t.jsx(z,{id:"remote-label",type:"text",value:x,onChange:g,placeholder:s("onboarding.remoteConnection.field.namePlaceholder"),disabled:L})]})]}),m&&H&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:s("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&E&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:s("onboarding.remoteConnection.status.authWarning")}),m&&u&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:P?s(P):null}),m&&l&&t.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold mb-1",children:s("onboarding.remoteConnection.status.connectionFailed")}),t.jsx("div",{className:"opacity-90",children:P?s(P):null})]}),t.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?s("onboarding.remoteConnection.status.suggestionsUnreachable"):s("onboarding.remoteConnection.status.suggestionsWrongService")})]}),R&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:R}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(U,{variant:"outline",onClick:k,disabled:!A,children:s(L?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),t.jsx(U,{onClick:K,disabled:!_,children:s("onboarding.remoteConnection.actions.connectAndRestart")})]}),l&&t.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:s("onboarding.remoteConnection.actions.whatToDo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(U,{variant:"outline",size:"sm",onClick:r,className:"flex-1",children:s("onboarding.remoteConnection.actions.chooseDifferentServer")}),!o&&i&&t.jsx(U,{variant:"outline",size:"sm",onClick:i,className:"flex-1",children:s("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const he="curl -fsSL https://opencode.ai/install | bash",fe="https://opencode.ai/docs",se=2500;function be(r){const e=W.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:n,"aria-label":n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}function xe({onCliAvailable:r}){const{t:e}=V(),[c,n]=a.useState(!1),[o,b]=a.useState(!1),[i,s]=a.useState(!1),[h,y]=a.useState(!1),[x,S]=a.useState(""),[N,f]=a.useState("unknown"),[m,v]=a.useState("local"),[R,C]=a.useState(!1),[j,p]=a.useState(!1);a.useEffect(()=>{b(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){f("unknown");return}const l=navigator.userAgent||"";/Windows/i.test(l)?f("windows"):/Macintosh|Mac OS X/i.test(l)?f("macos"):/Linux/i.test(l)?f("linux"):f("unknown")},[]),a.useEffect(()=>{let l=!1;return(async()=>{try{const d=await M("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!d.ok)return;const D=await d.json().catch(()=>null);if(!D||l)return;const F=typeof D.opencodeBinary=="string"?D.opencodeBinary.trim():"";F&&S(F)}catch{}})(),()=>{l=!0}},[]);const w=a.useCallback(async l=>{const d=l.target;d.closest(".app-region-no-drag")||d.closest("button, a, input, select, textarea, code, summary, details")||l.button===0&&o&&await re()},[o]),g=a.useCallback(async()=>{try{const l=await M("/health");if(!l.ok)return!1;const d=await l.json();return d.openCodeRunning===!0||d.isOpenCodeReady===!0}catch{return!1}},[]),k=a.useCallback(async l=>{if(!o)return;const d=await Z();await ee({...d,...l==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[o]),K=a.useCallback(async()=>{o&&await k("local"),r?.()},[o,r,k]);a.useEffect(()=>{if(m!=="local")return;let l=!1,d=null;const D=async()=>{if(!l){try{const F=await g();if(l)return;if(F){await K();return}}catch{}l||(d=setTimeout(D,se))}};return d=setTimeout(D,se),()=>{l=!0,d&&clearTimeout(d)}},[m,g,K]);const L=a.useCallback(async()=>{y(!0);try{await g()&&await K()}finally{y(!1)}},[g,K]),A=a.useCallback(async()=>{if(!(typeof window>"u")&&o)try{const l=await ae();l.success&&l.path&&l.path.trim().length>0&&S(l.path.trim())}catch{}},[o]),_=a.useCallback(async()=>{s(!0);try{if(await le({opencodeBinary:x.trim()}),o){await k("local"),await B();return}await M("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>s(!1),1e3)}},[o,x,k]),P=a.useCallback(async()=>{const l=await ce(he);l.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",l.error)},[]),H=fe,u=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",E=!o||m==="local";return t.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:w,children:t.jsxs("div",{className:"w-full max-w-md space-y-7",children:[t.jsxs("header",{className:"text-center space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:e("onboarding.chooser.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e("onboarding.chooser.description")})]}),o&&t.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[t.jsx("button",{type:"button",className:J("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("local"),children:e("onboarding.chooser.tabs.localInstall")}),t.jsx("button",{type:"button",className:J("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("remote"),children:e("onboarding.chooser.tabs.connectRemote")})]}),o&&m==="remote"?t.jsx("div",{className:"app-region-no-drag",children:t.jsx(ie,{onBack:()=>v("local"),showBackButton:!1,onSwitchToLocal:()=>v("local")})}):null,E&&t.jsxs("div",{className:"space-y-4",children:[N==="windows"&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-4",children:[t.jsx("div",{className:"text-sm text-foreground",children:e("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:e("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:e("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:e("onboarding.localSetup.intro")}),t.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:c?t.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),e("onboarding.common.status.copiedToClipboard")]}):t.jsx(be,{onCopy:P,copyTitle:e("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[t.jsxs("a",{href:H,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[e(N==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),t.jsx("button",{type:"button",onClick:L,disabled:h,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:e(h?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),t.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[t.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 shrink-0","aria-hidden":!0,children:[t.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}}),t.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-foreground leading-tight",children:e("onboarding.localSetup.status.watching")}),t.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:e("onboarding.localSetup.status.autoContinue")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:R,onToggle:l=>C(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.advanced.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsxs("div",{className:"pb-4 space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(z,{value:x,onChange:l=>S(l.target.value),placeholder:u,disabled:i,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:i||!o,children:e("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",size:"sm",onClick:_,disabled:i||!x.trim(),children:e("onboarding.localSetup.actions.apply")})]}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:e("onboarding.localSetup.helper.saveAndReload")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:j,onToggle:l=>p(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.troubleshoot.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:N==="windows"?t.jsx(t.Fragment,{children:t.jsx("li",{children:e("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("li",{children:e("onboarding.localSetup.hint.ensurePath")}),t.jsx("li",{children:e("onboarding.localSetup.hint.setEnv")}),t.jsx("li",{children:e("onboarding.localSetup.hint.missingRuntime")})]})})]})]})]})})}const ge="curl -fsSL https://opencode.ai/install | bash",ye="https://opencode.ai/docs";function ve(r){const e=W.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-center gap-3",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}const we=3e4;function je({onBack:r,onCliAvailable:e,isFromRecovery:c=!1,onSwitchToRemote:n}){const{t:o}=V(),[b,i]=a.useState(!1),[s,h]=a.useState(!1),[y,x]=a.useState(!1),[S,N]=a.useState(!1),[f,m]=a.useState(!1),[v,R]=a.useState(null),[C,j]=a.useState(""),[p,w]=a.useState("unknown");a.useEffect(()=>{const u=setTimeout(()=>h(!0),we);return()=>clearTimeout(u)},[]),a.useEffect(()=>{x(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){w("unknown");return}const u=navigator.userAgent||"";if(/Windows/i.test(u)){w("windows");return}if(/Macintosh|Mac OS X/i.test(u)){w("macos");return}if(/Linux/i.test(u)){w("linux");return}w("unknown")},[]),a.useEffect(()=>{let u=!1;return(async()=>{try{const E=await M("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!E.ok)return;const l=await E.json().catch(()=>null);if(!l||u)return;const d=typeof l.opencodeBinary=="string"?l.opencodeBinary.trim():"";d&&j(d)}catch{}})(),()=>{u=!0}},[]);const g=a.useCallback(async u=>{u.target.closest("button, a, input, select, textarea, code")||u.button===0&&y&&await re()},[y]),k=a.useCallback(async()=>{try{const u=await M("/health");if(!u.ok)return!1;const E=await u.json();return E.openCodeRunning===!0||E.isOpenCodeReady===!0}catch{return!1}},[]),K=a.useCallback(async()=>{if(!(typeof window>"u")&&y)try{const u=await ae();u.success&&u.path&&u.path.trim().length>0&&j(u.path.trim())}catch{}},[y]),L=a.useCallback(async()=>{N(!0);try{if(await le({opencodeBinary:C.trim()}),y){await B();return}await M("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>N(!1),1e3)}},[y,C]),A=a.useCallback(async()=>{const u=await ce(ge);u.ok?(i(!0),setTimeout(()=>i(!1),2e3)):console.error("Failed to copy:",u.error)},[]),_=a.useCallback(async()=>{m(!0),R(null);try{await k()?e?.():R(o("onboarding.localSetup.errors.cliNotReady"))}catch(u){R(u instanceof Error?u.message:o("onboarding.localSetup.errors.detectionFailed"))}finally{m(!1)}},[k,e,o]),P=ye,H=p==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":p==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode";return t.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:g,children:[t.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:o("onboarding.localSetup.title")}),t.jsx("p",{className:"text-muted-foreground",children:o("onboarding.localSetup.description")})]}),p==="windows"&&t.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[t.jsx("div",{className:"text-sm text-foreground",children:o("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:o("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:o("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:b?t.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),o("onboarding.common.status.copiedToClipboard")]}):t.jsx(ve,{onCopy:A,copyTitle:o("onboarding.common.copyToClipboard")})})}),t.jsxs("a",{href:P,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1 justify-center",children:[o(p==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),v&&t.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:v}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(U,{type:"button",onClick:_,disabled:f,className:"w-full max-w-xs",size:"lg",children:o(f?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:o("onboarding.localSetup.helper.checkAndContinue")})]}),t.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:o("onboarding.localSetup.field.alreadyInstalled")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(z,{value:C,onChange:u=>j(u.target.value),placeholder:H,disabled:S,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",onClick:K,disabled:S||!y,children:o("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",onClick:L,disabled:S,children:o("onboarding.localSetup.actions.apply")})]}),t.jsx("div",{className:"text-xs text-muted-foreground/70",children:o("onboarding.localSetup.helper.saveAndReload")})]})}),c&&n&&t.jsxs("div",{className:"text-center pt-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:o("onboarding.localSetup.remotePreference")}),t.jsx(U,{variant:"link",onClick:n,children:o("onboarding.localSetup.actions.connectRemoteServer")})]})]}),s&&t.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:p==="windows"?t.jsx(t.Fragment,{children:t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.ensurePath")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.setEnv")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.missingRuntime")})]})})]})}function X(r,e){if(r?.trim())return Q(r.trim());if(e)return Q(e)}function ke(r,e,c){switch(r){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const n=X(e,c);return{title:"Remote Server Unreachable",description:`Could not connect to "${n||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-wrong-service":{const n=X(e,c);return{title:"Incompatible Server",description:`The server at "${n||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-incompatible":{const n=X(e,c);return{title:"Server Update Required",description:`The OpenChamber server at "${n||"unknown"}" is not compatible with this app version. Update OpenChamber on the server, then try again.`,titleKey:"onboarding.desktopRecovery.remoteIncompatible.title",descriptionKey:"onboarding.desktopRecovery.remoteIncompatible.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"missing-default-host":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};default:{const n=r;throw new Error(`Unknown recovery variant: ${n}`)}}}function Ce(r){switch(r){case"local":return t.jsx(T,{name:"macbook",className:"h-8 w-8"});case"remote":return t.jsx(T,{name:"server",className:"h-8 w-8"})}}function Ne({variant:r,hostLabel:e,hostUrl:c,onRetry:n,onUseLocal:o,onUseRemote:b,isRetrying:i=!1}){const{t:s}=V(),h=ke(r,e,c),y=h.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",x=a.useMemo(()=>{if(h.descriptionParams?.host)return h.descriptionParams;if(r==="remote-unreachable")return{host:s("onboarding.desktopRecovery.placeholders.remoteServer")};if(r==="remote-wrong-service"||r==="remote-incompatible")return{host:s("onboarding.desktopRecovery.placeholders.unknownServer")}},[h.descriptionParams,s,r]);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[t.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:t.jsx("div",{style:{color:"var(--status-warning)"},children:Ce(h.iconKey)})}),t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(h.titleKey)}),t.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:s(h.descriptionKey,x)})]}),c&&(r==="remote-unreachable"||r==="remote-wrong-service"||r==="remote-incompatible")&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:Q(c)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[h.showRetry&&n&&t.jsxs(U,{onClick:n,disabled:i,className:"w-full",children:[t.jsx(T,{name:"refresh",className:J("h-4 w-4",i&&"animate-spin")}),s(i?"onboarding.desktopRecovery.actions.retrying":y)]}),t.jsxs("div",{className:"flex gap-2",children:[h.showUseLocal&&o&&t.jsxs(U,{variant:"outline",onClick:o,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"macbook",className:"h-4 w-4"}),s(h.useLocalLabelKey)]}),h.showUseRemote&&b&&t.jsxs(U,{variant:"outline",onClick:b,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"server",className:"h-4 w-4"}),s(h.useRemoteLabelKey)]})]})]})]})})}function ne(r,e){if(e==="use-remote")return{kind:"remote-form"};switch(r){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const c=r;throw new Error(`Unhandled RecoveryVariant: ${c}`)}}}function Re(r){const e=W.c(27),{variant:c,hostUrl:n,hostLabel:o,onRetry:b,onChooseRemote:i,showRemoteForm:s,onCloseRemoteForm:h,onSwitchToLocalFromRemote:y,onEnterLocalSetup:x,isRetrying:S}=r,N=s===void 0?!1:s,f=S===void 0?!1:S,m=Se;let v;e[0]!==b?(v=async()=>{if(O()){await B();return}await M("/api/config/reload",{method:"POST"}),b?.()},e[0]=b,e[1]=v):v=e[1];const R=v;let C;e[2]!==x||e[3]!==c?(C=async()=>{if(ne(c,"use-local").kind==="local-setup"){x?.();return}if(await m("local"),O()){await B();return}window.location.reload()},e[2]=x,e[3]=c,e[4]=C):C=e[4];const j=C;let p;e[5]!==i||e[6]!==c?(p=()=>{ne(c,"use-remote").kind==="remote-form"&&i?.()},e[5]=i,e[6]=c,e[7]=p):p=e[7];const w=p;if(N){const k=c==="remote-wrong-service"?"":n||"",K=c==="remote-wrong-service"?"":o||"";let L;e[8]!==i||e[9]!==h?(L=h||(()=>i?.()),e[8]=i,e[9]=h,e[10]=L):L=e[10];let A;e[11]!==x||e[12]!==y?(A=y||(()=>{m("local").then(()=>{O()?B():x?.()})}),e[11]=x,e[12]=y,e[13]=A):A=e[13];let _;return e[14]!==K||e[15]!==k||e[16]!==L||e[17]!==A?(_=t.jsx(ie,{onBack:L,initialUrl:k,initialLabel:K,isRecoveryMode:!0,onSwitchToLocal:A}),e[14]=K,e[15]=k,e[16]=L,e[17]=A,e[18]=_):_=e[18],_}let g;return e[19]!==R||e[20]!==j||e[21]!==w||e[22]!==o||e[23]!==n||e[24]!==f||e[25]!==c?(g=t.jsx(Ne,{variant:c,hostLabel:o,hostUrl:n,onRetry:R,onUseLocal:j,onUseRemote:w,isRetrying:f}),e[19]=R,e[20]=j,e[21]=w,e[22]=o,e[23]=n,e[24]=f,e[25]=c,e[26]=g):g=e[26],g}async function Se(r){if(!O())return;const e=await Z();await ee({...e,...r==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function Ke(r){const e=W.c(26),{onBack:c,onCliAvailable:n,mode:o,recoveryVariant:b,recoveryHostUrl:i,recoveryHostLabel:s,onEnterLocalSetup:h}=r,y=o===void 0?"first-launch":o,x=b===void 0?"missing-default-host":b,[S,N]=a.useState(!1),[f,m]=a.useState(!1);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{m(!1),N(!1)},e[0]=v):v=e[0];let R;e[1]!==y||e[2]!==s||e[3]!==i||e[4]!==x?(R=[y,x,i,s],e[1]=y,e[2]=s,e[3]=i,e[4]=x,e[5]=R):R=e[5],a.useEffect(v,R);const C=f?"local-setup":y;if(C==="recovery"){let p,w;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>N(!1),w=()=>{N(!1),m(!0)},e[6]=p,e[7]=w):(p=e[6],w=e[7]);let g;e[8]!==h?(g=()=>{m(!0),h?.()},e[8]=h,e[9]=g):g=e[9];let k;return e[10]!==s||e[11]!==i||e[12]!==x||e[13]!==S||e[14]!==g?(k=t.jsx(Re,{variant:x,hostUrl:i,hostLabel:s,showRemoteForm:S,onCloseRemoteForm:p,onSwitchToLocalFromRemote:w,onEnterLocalSetup:g}),e[10]=s,e[11]=i,e[12]=x,e[13]=S,e[14]=g,e[15]=k):k=e[15],k}if(C==="local-setup"){let p;e[16]!==c||e[17]!==f?(p=()=>{f?m(!1):c?.()},e[16]=c,e[17]=f,e[18]=p):p=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=()=>N(!0),e[19]=w):w=e[19];let g;return e[20]!==n||e[21]!==f||e[22]!==p?(g=t.jsx(je,{onBack:p,onCliAvailable:n,isFromRecovery:f,onSwitchToRemote:w}),e[20]=n,e[21]=f,e[22]=p,e[23]=g):g=e[23],g}let j;return e[24]!==n?(j=t.jsx(xe,{onCliAvailable:n}),e[24]=n,e[25]=j):j=e[25],j}export{Ke as OnboardingScreen};
|
package/dist/assets/{SessionSwitcherDropdown-B6kvduse.js → SessionSwitcherDropdown-Cn_yoQrm.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as ne,R as je,j as r,H as Oe,a as Ue,ad as Ae}from"./vendor-.bun-By2L9XvG.js";import{u as _e,m as X,ay as Be,aa as We,ab as Ge,I as q,M as Ye,ax as He,aw as Ke,bU as Je,bV as Qe,bb as Re,y as Ve,D as Xe,cl as qe,co as ke,ap as Ze,ar as et,as as tt,z as Pe,cL as st,cN as nt}from"./useAppFontEffects-Bd0ks39c.js";import{x as Se,D as rt,b as Ne}from"./index-BsXkdBYx.js";const Bt=s=>{const e=ne.c(129),{totalTokens:t,percentage:o,colorPercentage:n,contextLimit:i,outputLimit:a,size:c,isMobile:x,hideIcon:m,showPercentIcon:l,className:f,valueClassName:v,percentIconClassName:b,onClick:p,pressed:w}=s,S=c===void 0?"default":c,h=x===void 0?!1:x,j=m===void 0?!1:m,N=l===void 0?!1:l,C=w===void 0?!1:w,{t:d}=_e(),[_,y]=je.useState(!1),u=typeof n=="number"?n:o;let g,D,k,I,L,W,B,G;if(e[0]!==u||e[1]!==i||e[2]!==j||e[3]!==h||e[4]!==p||e[5]!==a||e[6]!==b||e[7]!==o||e[8]!==N||e[9]!==d||e[10]!==t||e[11]!==v){const z=We(o)??0,M=Ge(u),$=M==="critical"?"var(--status-error)":M==="warn"?"var(--status-warning)":"var(--status-success)";g=ot,D=it;const T=2*Math.PI*8.5,P=T*(1-z/100);I=typeof a=="number"?Math.max(a,0):0;let E;e[20]!==d||e[21]!==t?(E=d("contextUsage.tooltip.usedTokens",{tokens:g(t)}),e[20]=d,e[21]=t,e[22]=E):E=e[22];let O;e[23]!==i||e[24]!==d?(O=d("contextUsage.tooltip.contextLimit",{tokens:g(i)}),e[23]=i,e[24]=d,e[25]=O):O=e[25];let U;e[26]!==I||e[27]!==d?(U=d("contextUsage.tooltip.outputLimit",{tokens:g(I)}),e[26]=I,e[27]=d,e[28]=U):U=e[28];let R;e[29]!==O||e[30]!==U||e[31]!==E?(R=[E,O,U],e[29]=O,e[30]=U,e[31]=E,e[32]=R):R=e[32],G=R,k=!h&&typeof p=="function",e[33]!==j||e[34]!==h?(B=!h&&!j&&r.jsx(q,{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=X("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:X("h-3.5 w-3.5 -rotate-90",b),role:"progressbar","aria-valuenow":Math.round(z),"aria-valuemin":0,"aria-valuemax":100,children:[r.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),r.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:$,strokeWidth:3,strokeLinecap:"round",strokeDasharray:T,strokeDashoffset:P,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),r.jsxs("span",{className:"text-foreground",children:[Math.min(o,999).toFixed(1),"%"]})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:D(u),children:Math.min(o,999).toFixed(1)}),"%"]}),e[0]=u,e[1]=i,e[2]=j,e[3]=h,e[4]=p,e[5]=a,e[6]=b,e[7]=o,e[8]=N,e[9]=d,e[10]=t,e[11]=v,e[12]=g,e[13]=D,e[14]=k,e[15]=I,e[16]=L,e[17]=W,e[18]=B,e[19]=G}else g=e[12],D=e[13],k=e[14],I=e[15],L=e[16],W=e[17],B=e[18],G=e[19];let Y;e[38]!==L||e[39]!==W?(Y=r.jsx("span",{className:L,children:W}),e[38]=L,e[39]=W,e[40]=Y):Y=e[40];let Z;e[41]!==B||e[42]!==Y?(Z=r.jsxs(r.Fragment,{children:[B,Y]}),e[41]=B,e[42]=Y,e[43]=Z):Z=e[43];const H=Z,ee=S==="compact"?"typography-micro":"typography-meta";let te;e[44]!==f||e[45]!==k||e[46]!==ee?(te=X("app-region-no-drag flex items-center gap-1.5 select-none",ee,k?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",f),e[44]=f,e[45]=k,e[46]=ee,e[47]=te):te=e[47];const K=te;let J;e[48]!==H||e[49]!==k||e[50]!==h||e[51]!==p||e[52]!==C||e[53]!==K||e[54]!==d?(J=k?r.jsx("button",{type:"button",className:K,"aria-label":d("contextUsage.aria.label"),"aria-pressed":C,onClick:p,children:H}):r.jsx("div",{className:K,"aria-label":d("contextUsage.aria.label"),onClick:h?()=>y(!0):void 0,children:H}),e[48]=H,e[49]=k,e[50]=h,e[51]=p,e[52]=C,e[53]=K,e[54]=d,e[55]=J):J=e[55];const V=J;if(h){let z;e[56]===Symbol.for("react.memo_cache_sentinel")?(z=()=>y(!1),e[56]=z):z=e[56];let M;e[57]!==d?(M=d("contextUsage.mobile.title"),e[57]=d,e[58]=M):M=e[58];let $;e[59]!==d?($=d("contextUsage.mobile.usedTokens"),e[59]=d,e[60]=$):$=e[60];let T;e[61]!==$?(T=r.jsx("span",{className:"typography-meta text-muted-foreground",children:$}),e[61]=$,e[62]=T):T=e[62];let P;e[63]!==g||e[64]!==t?(P=g(t),e[63]=g,e[64]=t,e[65]=P):P=e[65];let E;e[66]!==P?(E=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:P}),e[66]=P,e[67]=E):E=e[67];let O;e[68]!==T||e[69]!==E?(O=r.jsxs("div",{className:"flex justify-between items-center",children:[T,E]}),e[68]=T,e[69]=E,e[70]=O):O=e[70];let U;e[71]!==d?(U=d("contextUsage.mobile.contextLimit"),e[71]=d,e[72]=U):U=e[72];let R;e[73]!==U?(R=r.jsx("span",{className:"typography-meta text-muted-foreground",children:U}),e[73]=U,e[74]=R):R=e[74];let re;e[75]!==i||e[76]!==g?(re=g(i),e[75]=i,e[76]=g,e[77]=re):re=e[77];let oe;e[78]!==re?(oe=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:re}),e[78]=re,e[79]=oe):oe=e[79];let ie;e[80]!==R||e[81]!==oe?(ie=r.jsxs("div",{className:"flex justify-between items-center",children:[R,oe]}),e[80]=R,e[81]=oe,e[82]=ie):ie=e[82];let ae;e[83]!==d?(ae=d("contextUsage.mobile.outputLimit"),e[83]=d,e[84]=ae):ae=e[84];let le;e[85]!==ae?(le=r.jsx("span",{className:"typography-meta text-muted-foreground",children:ae}),e[85]=ae,e[86]=le):le=e[86];let ce;e[87]!==g||e[88]!==I?(ce=g(I),e[87]=g,e[88]=I,e[89]=ce):ce=e[89];let de;e[90]!==ce?(de=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:ce}),e[90]=ce,e[91]=de):de=e[91];let ue;e[92]!==le||e[93]!==de?(ue=r.jsxs("div",{className:"flex justify-between items-center",children:[le,de]}),e[92]=le,e[93]=de,e[94]=ue):ue=e[94];let me;e[95]!==d?(me=d("contextUsage.mobile.usage"),e[95]=d,e[96]=me):me=e[96];let fe;e[97]!==me?(fe=r.jsx("span",{className:"typography-meta text-muted-foreground",children:me}),e[97]=me,e[98]=fe):fe=e[98];let he;e[99]!==u||e[100]!==D?(he=X("typography-meta font-semibold",D(u)),e[99]=u,e[100]=D,e[101]=he):he=e[101];const De=Math.min(o,999);let pe;e[102]!==De?(pe=De.toFixed(1),e[102]=De,e[103]=pe):pe=e[103];let ge;e[104]!==he||e[105]!==pe?(ge=r.jsxs("span",{className:he,children:[pe,"%"]}),e[104]=he,e[105]=pe,e[106]=ge):ge=e[106];let xe;e[107]!==fe||e[108]!==ge?(xe=r.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[fe,ge]}),e[107]=fe,e[108]=ge,e[109]=xe):xe=e[109];let be;e[110]!==O||e[111]!==ie||e[112]!==ue||e[113]!==xe?(be=r.jsx("div",{className:"flex flex-col gap-1.5",children:r.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[O,ie,ue,xe]})}),e[110]=O,e[111]=ie,e[112]=ue,e[113]=xe,e[114]=be):be=e[114];let we;e[115]!==_||e[116]!==M||e[117]!==be?(we=r.jsx(Ye,{open:_,onClose:z,title:M,children:be}),e[115]=_,e[116]=M,e[117]=be,e[118]=we):we=e[118];let ve;return e[119]!==V||e[120]!==we?(ve=r.jsxs(r.Fragment,{children:[V,we]}),e[119]=V,e[120]=we,e[121]=ve):ve=e[121],ve}let A;e[122]!==V?(A=r.jsx(He,{asChild:!0,children:V}),e[122]=V,e[123]=A):A=e[123];let F;e[124]!==G?(F=r.jsx(Be,{children:r.jsx("div",{className:"space-y-0.5",children:G.map(at)})}),e[124]=G,e[125]=F):F=e[125];let Q;return e[126]!==A||e[127]!==F?(Q=r.jsxs(Ke,{children:[A,F]}),e[126]=A,e[127]=F,e[128]=Q):Q=e[128],Q};function ot(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toFixed(1).replace(/\.0$/,"")}function it(s){return s>=90?"text-status-error":s>=75?"text-status-warning":"text-status-success"}function at(s){return r.jsx("p",{className:"typography-micro leading-tight",children:s},s)}const Wt=je.memo(function(e){const t=ne.c(40),{visible:o}=e,{t:n}=_e(),[i,a]=je.useState(!1);let c,x;if(t[0]!==o?(c=()=>{if(!o)return;let D=!1;Se("desktop_get_current_window_state").then(I=>{D||a(!!I?.maximized)}).catch(lt);const k=I=>{const L=I.detail;a(!!L?.maximized)};return window.addEventListener("openchamber:window-maximized-changed",k),()=>{D=!0,window.removeEventListener("openchamber:window-maximized-changed",k)}},x=[o],t[0]=o,t[1]=c,t[2]=x):(c=t[1],x=t[2]),Oe.useEffect(c,x),!o)return null;let m;t[3]!==n?(m=n("header.windowControls.groupAria"),t[3]=n,t[4]=m):m=t[4];let l;t[5]!==n?(l=n("header.windowControls.minimize"),t[5]=n,t[6]=l):l=t[6];let f;t[7]!==n?(f=n("header.windowControls.minimize"),t[7]=n,t[8]=f):f=t[8];let v;t[9]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(q,{name:"subtract",className:"h-4 w-4"}),t[9]=v):v=t[9];let b;t[10]!==l||t[11]!==f?(b=r.jsx("button",{type:"button",className:"app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:ct,title:l,"aria-label":f,children:v}),t[10]=l,t[11]=f,t[12]=b):b=t[12];let p;t[13]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{Se("desktop_toggle_current_window_maximized").then(D=>a(!!D?.maximized)).catch(dt)},t[13]=p):p=t[13];let w;t[14]!==i||t[15]!==n?(w=n(i?"header.windowControls.restore":"header.windowControls.maximize"),t[14]=i,t[15]=n,t[16]=w):w=t[16];let S;t[17]!==i||t[18]!==n?(S=n(i?"header.windowControls.restore":"header.windowControls.maximize"),t[17]=i,t[18]=n,t[19]=S):S=t[19];const h=i?"fullscreen-exit":"checkbox-blank";let j;t[20]!==h?(j=r.jsx(q,{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=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 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(q,{name:"close",className:"h-4 w-4"}),t[31]=y):y=t[31];let u;t[32]!==d||t[33]!==_?(u=r.jsx("button",{type:"button",className:C,onClick:ut,title:d,"aria-label":_,children:y}),t[32]=d,t[33]=_,t[34]=u):u=t[34];let g;return t[35]!==N||t[36]!==u||t[37]!==m||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":m,children:[b,N,u]}),t[35]=N,t[36]=u,t[37]=m,t[38]=b,t[39]=g):g=t[39],g});function lt(){}function ct(){Se("desktop_minimize_current_window")}function dt(){}function ut(){Se("desktop_close_current_window")}const Fe="oc.sessions.pinned",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}},Me=(s,e)=>{try{s.setItem(Fe,JSON.stringify([...e]))}catch{}},Ce=rt(),ft=Ue((s,e)=>({ids:mt(Ce),setIds:t=>{const o=e().ids,n=typeof t=="function"?t(o):t;n!==o&&(s({ids:n}),Me(Ce,n))},toggle:t=>{const o=e().ids,n=new Set(o);n.has(t)?n.delete(t):n.add(t),s({ids:n}),Me(Ce,n)}})),se=(s,e)=>Je(Qe.getState().dictionary,s,e),ht=s=>{const e=new Date(s),t=new Date,o=(a,c)=>a.getFullYear()===c.getFullYear()&&a.getMonth()===c.getMonth()&&a.getDate()===c.getDate(),n=new Date(t);return n.setDate(t.getDate()-1),o(e,t)?se("common.date.today"):o(e,n)?se("common.date.yesterday"):e.toLocaleDateString(Re(),{month:"short",day:"numeric",year:"numeric"}).replace(",","")},Gt=s=>{const e=new Date,t=new Date(s);if(((n,i)=>n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate())(t,e)){const n=Date.now()-s;return n<6e4?se("common.relative.justNow"):n<36e5?se("common.relative.minutesAgoShort",{count:Math.floor(n/6e4)}):se("common.relative.hoursAgoShort",{count:Math.floor(n/36e5)})}return ht(s)},pt=s=>{const e=Math.max(0,Date.now()-s),t=6e4,o=60*t,n=24*o,i=7*n,a=30*n,c=365*n;return e<o?`${Math.max(1,Math.floor(e/t))}m`:e<n?`${Math.floor(e/o)}h`:e<i?se("common.relative.daysAgoCompact",{count:Math.floor(e/n)}):e<5*i?se("common.relative.weeksAgoCompact",{count:Math.floor(e/i)}):e<c?`${Math.floor(e/a)}mo`:se("common.relative.yearsAgoCompact",{count:Math.floor(e/c)})},ye=s=>{if(!s)return null;const e=s.replace(/\\/g,"/").replace(/\/+$/,"");return e.length===0?"/":e},gt=(s,e)=>{const t=ye(s),o=ye(e);return!t||!o?!1:t===o?!0:o==="/"?t.startsWith("/"):t.startsWith(`${o}/`)},Le=s=>s.toLowerCase().replace(/^opencode[/-]?/i,"").replace(/[-_]/g,"").trim(),Yt=(s,e)=>s?Le(s)!==Le(e):!1,Ie=s=>{if(typeof s=="number"&&Number.isFinite(s))return s;if(typeof s=="string"&&s.trim().length>0){const e=Number(s);if(Number.isFinite(e))return e}},$e=s=>Ie(s.time?.created)??0,ze=s=>Ie(s.time?.updated)??Ie(s.time?.created)??0,Te=(s,e,t)=>{const o=t.has(s.id),n=t.has(e.id);return o!==n?o?-1:1:o&&n?$e(e)-$e(s):ze(e)-ze(s)},Ht=s=>{const e=new Map;return s.forEach(t=>{e.set(t.id,t)}),Array.from(e.values())},Kt=s=>`__archived__:${s}`,Jt=(s,e)=>{const t=ye(s.directory??null),o=ye(s.project?.worktree??null),n=t??o;if(!n)return"unassigned";if(e&&n===e)return"project root";const a=(e&&n.startsWith(`${e}/`)?n.slice(e.length+1):n).split("/").filter(Boolean);return a[a.length-1]??"unassigned"},Qt=(s,e,t)=>{const o=ye(s.directory??null),n=ye(s.project?.worktree??null);return n&&(n===e||n.startsWith(`${e}/`))?!0:o?t&&t.has(o)?!0:o===e||o.startsWith(`${e}/`):!1},Rt=s=>s.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),Vt=(s,e)=>{if(!e)return s;const t=s.toLowerCase(),o=e.toLowerCase(),n=o.length;if(n===0)return s;const i=[];let a=0,c=t.indexOf(o,a);for(;c!==-1;){c>a&&i.push(s.slice(a,c));const x=s.slice(c,c+n);i.push(r.jsx("mark",{className:"bg-primary text-primary-foreground ring-1 ring-primary/90",children:x},`${c}-${x}`)),a=c+n,c=t.indexOf(o,a)}return a<s.length&&i.push(s.slice(a)),i.length>0?i:s},xt=7,bt=s=>{if(!s)return null;const e=s.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},wt=s=>{if(!s)return null;const e=s.label?.trim();if(e)return e;const t=s.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},yt=(s,e)=>{const t=ne.c(18);let o;t[0]!==e?(o=e===void 0?{}:e,t[0]=e,t[1]=o):o=t[1];const n=o,{scopeProjectId:i}=n,a=i===void 0?null:i,c=Ve(vt),x=Xe(jt),m=ft(St),l=qe();let f;t[2]!==x?(f=x.map(Nt).filter(_t),t[2]=x,t[3]=f):f=t[3];const v=f;let b;t[4]!==v?(b=h=>h?v.filter(N=>gt(h,N.normalizedPath)).sort(Dt)[0]??null:null,t[4]=v,t[5]=b):b=t[5];const p=b;let w;{let h;if(t[7]!==c||t[8]!==l||t[9]!==p||t[10]!==m||t[11]!==a){const j=new Map;for(const y of c){const u=y.parentID;if(!u||y.time?.archived)continue;const g=j.get(u);g?g.push(y):j.set(u,[y])}j.forEach(y=>{y.sort((u,g)=>Te(u,g,m))});let N;t[13]!==p||t[14]!==a?(N=y=>{if(!a)return!0;const u=ke(y);return p(u)?.id===a},t[13]=p,t[14]=a,t[15]=N):N=t[15];let C;t[16]!==m?(C=(y,u)=>Te(y,u,m),t[16]=m,t[17]=C):C=t[17];const d=c.filter(Ct).filter(kt).filter(N).sort(C).slice(0,xt),_=y=>{const u=j.get(y.id)??[];return{session:y,children:u.map(g=>_(g)),worktree:null}};h=d.map(y=>{const u=ke(y),g=p(u),D=wt(g),k=u?l.get(u)??null:null;return{node:_(y),projectId:g?.id??null,groupDirectory:u,secondaryMeta:{projectLabel:D,branchLabel:k&&k!==D?k:null}}}),t[7]=c,t[8]=l,t[9]=p,t[10]=m,t[11]=a,t[12]=h}else h=t[12];w=h}return w};function vt(s){return s.activeSessions}function jt(s){return s.projects}function St(s){return s.ids}function Nt(s){return{...s,normalizedPath:bt(s.path)}}function _t(s){return s.normalizedPath}function Dt(s,e){return(e.normalizedPath?.length??0)-(s.normalizedPath?.length??0)}function Ct(s){return!s.time?.archived}function kt(s){return!s.parentID}function Xt(s){const e=ne.c(18),{children:t,variant:o,scopeProjectId:n,align:i}=s,a=o===void 0?"default":o,c=n===void 0?null:n,x=i===void 0?"start":i,m=Ne(It),l=Ne(Pt);let f;e[0]!==t?(f=r.jsx(Ze,{asChild:!0,children:t}),e[0]=t,e[1]=f):f=e[1];const v=a==="compact"?"w-[280px]":"w-[360px]";let b;e[2]!==v?(b=X("overflow-hidden p-1 max-w-[calc(100vw-32px)]",v),e[2]=v,e[3]=b):b=e[3];let p;e[4]!==m||e[5]!==c||e[6]!==l||e[7]!==a?(p=m?r.jsx(Mt,{onSelect:()=>l(!1),variant:a,scopeProjectId:c}):null,e[4]=m,e[5]=c,e[6]=l,e[7]=a,e[8]=p):p=e[8];let w;e[9]!==x||e[10]!==b||e[11]!==p?(w=r.jsx(et,{align:x,sideOffset:6,className:b,children:p}),e[9]=x,e[10]=b,e[11]=p,e[12]=w):w=e[12];let S;return e[13]!==m||e[14]!==l||e[15]!==f||e[16]!==w?(S=r.jsxs(tt,{open:m,onOpenChange:l,modal:!1,children:[f,w]}),e[13]=m,e[14]=l,e[15]=f,e[16]=w,e[17]=S):S=e[17],S}function Pt(s){return s.setSessionDropdownOpen}function It(s){return s.isSessionDropdownOpen}function Mt(s){const e=ne.c(26),{onSelect:t,variant:o,scopeProjectId:n}=s;let i;e[0]!==n?(i={scopeProjectId:n},e[0]=n,e[1]=i):i=e[1];const a=yt(!0,i),c=Pe($t),x=Ne(Lt),{t:m}=_e();let l;e[2]!==t||e[3]!==c||e[4]!==x?(l=()=>{x("chat"),t(),c()},e[2]=t,e[3]=c,e[4]=x,e[5]=l):l=e[5];const f=l;let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=new Set,e[6]=v):v=e[6];const[b,p]=je.useState(v);let w;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=u=>{p(g=>{const D=new Set(g);return D.has(u)?D.delete(u):D.add(u),D})},e[7]=w):w=e[7];const S=w;let h,j;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=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"),j=r.jsx(q,{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]!==m?(N=m("sessions.sidebar.header.actions.newSession"),e[10]=m,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]!==f||e[15]!==C?(d=r.jsxs(Ae,{onClick:f,className:h,children:[j,C]}),e[14]=f,e[15]=C,e[16]=d):d=e[16];let _;e[17]!==b||e[18]!==a||e[19]!==t||e[20]!==m||e[21]!==o?(_=a.length===0?r.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:m("sessions.switcher.empty")}):a.map(u=>r.jsx(Ee,{item:u,depth:0,variant:o,expandedParents:b,toggleParent:S,closeDropdown:t},u.node.session.id)),e[17]=b,e[18]=a,e[19]=t,e[20]=m,e[21]=o,e[22]=_):_=e[22];let y;return e[23]!==_||e[24]!==d?(y=r.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:r.jsxs("div",{className:"space-y-0.5",children:[d,_]})}),e[23]=_,e[24]=d,e[25]=y):y=e[25],y}function Lt(s){return s.setActiveMainTab}function $t(s){return s.openNewSessionDraft}function Ee(s){const e=ne.c(31),{item:t,depth:o,variant:n,expandedParents:i,toggleParent:a,closeDropdown:c}=s,{node:x,secondaryMeta:m}=t,l=x.session,f=x.children.length>0;let v;e[0]!==i||e[1]!==l.id?(v=i.has(l.id),e[0]=i,e[1]=l.id,e[2]=v):v=e[2];const b=v;let p;e[3]!==f||e[4]!==l.id||e[5]!==a?(p=f?()=>a(l.id):void 0,e[3]=f,e[4]=l.id,e[5]=a,e[6]=p):p=e[6];let w;e[7]!==c||e[8]!==o||e[9]!==f||e[10]!==b||e[11]!==m||e[12]!==l||e[13]!==p||e[14]!==n?(w=r.jsx(zt,{session:l,depth:o,variant:n,secondaryMeta:m,hasChildren:f,isExpanded:b,onToggleExpand:p,closeDropdown:c}),e[7]=c,e[8]=o,e[9]=f,e[10]=b,e[11]=m,e[12]=l,e[13]=p,e[14]=n,e[15]=w):w=e[15];let S;e[16]!==c||e[17]!==o||e[18]!==i||e[19]!==f||e[20]!==b||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==x.children||e[24]!==m||e[25]!==a||e[26]!==n?(S=f&&b?x.children.map(j=>r.jsx(Ee,{item:{node:j,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:m},depth:o+1,variant:n,expandedParents:i,toggleParent:a,closeDropdown:c},j.session.id)):null,e[16]=c,e[17]=o,e[18]=i,e[19]=f,e[20]=b,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=x.children,e[24]=m,e[25]=a,e[26]=n,e[27]=S):S=e[27];let h;return e[28]!==w||e[29]!==S?(h=r.jsxs(r.Fragment,{children:[w,S]}),e[28]=w,e[29]=S,e[30]=h):h=e[30],h}function zt(s){const e=ne.c(57),{session:t,depth:o,variant:n,secondaryMeta:i,hasChildren:a,isExpanded:c,onToggleExpand:x,closeDropdown:m}=s,{t:l}=_e(),f=Pe(Ft),v=Pe(At),b=Ne(Tt),p=st(t.id),w=nt(t.id),S=f===t.id;let h;e[0]!==t.title||e[1]!==l?(h=t.title?.trim()||l("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=l,e[2]=h):h=e[2];const j=h,N=!!t.parentID,C=w>0&&(!N||b),d=p?.type??"idle",_=d==="busy"||d==="retry",y=!_&&C&&!S;let u;e[3]!==t.time?.created||e[4]!==t.time?.updated?(u=t.time?.updated||t.time?.created||Date.now(),e[3]=t.time?.created,e[4]=t.time?.updated,e[5]=u):u=e[5];const g=u;let D;e[6]!==g?(D=pt(g),e[6]=g,e[7]=D):D=e[7];const k=D;let I;e[8]!==i?.projectLabel?(I=i?.projectLabel?.trim()||null,e[8]=i?.projectLabel,e[9]=I):I=e[9];const L=I;let W;e[10]!==i?.branchLabel?(W=i?.branchLabel?.trim()||null,e[10]=i?.branchLabel,e[11]=W):W=e[11];const B=W,G=B&&B!=="HEAD"?B:null;let Y;e[12]!==m||e[13]!==S||e[14]!==t||e[15]!==v?(Y=()=>{if(S){m();return}const P=ke(t);v(t.id,P??null),m()},e[12]=m,e[13]=S,e[14]=t,e[15]=v,e[16]=Y):Y=e[16];const Z=Y;let H;e[17]!==Z?(H=P=>{if(P.target?.closest("[data-switcher-expand]")){P.preventDefault();return}Z()},e[17]=Z,e[18]=H):H=e[18];let ee;e[19]===Symbol.for("react.memo_cache_sentinel")?(ee=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[19]=ee):ee=e[19];const te=8+o*12;let K;e[20]!==te?(K={paddingLeft:te},e[20]=te,e[21]=K):K=e[21];let J;e[22]!==a||e[23]!==c||e[24]!==x||e[25]!==l||e[26]!==n?(J=n==="compact"&&a?r.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:P=>{P.preventDefault(),P.stopPropagation(),x?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?r.jsx(q,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):r.jsx(q,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[22]=a,e[23]=c,e[24]=x,e[25]=l,e[26]=n,e[27]=J):J=e[27];const V=S?"text-primary":"text-foreground";let A;e[28]!==V?(A=X("truncate text-[14px] font-normal leading-tight",V),e[28]=V,e[29]=A):A=e[29];let F;e[30]!==j||e[31]!==A?(F=r.jsx("span",{className:A,children:j}),e[30]=j,e[31]=A,e[32]=F):F=e[32];let Q;e[33]!==J||e[34]!==F?(Q=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[J,F]}),e[33]=J,e[34]=F,e[35]=Q):Q=e[35];let z;e[36]!==G||e[37]!==a||e[38]!==c||e[39]!==x||e[40]!==L||e[41]!==l||e[42]!==k||e[43]!==n?(z=n==="default"?r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:[a?r.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:P=>{P.preventDefault(),P.stopPropagation(),x?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?r.jsx(q,{name:"arrow-down-s",className:"h-3 w-3"}):r.jsx(q,{name:"arrow-right-s",className:"h-3 w-3"})}):null,r.jsx("span",{className:"flex-shrink-0",children:k}),L?r.jsx("span",{className:"truncate",children:L}):null,G?r.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[r.jsx(q,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),r.jsx("span",{className:"truncate",children:G})]}):null]}):null,e[36]=G,e[37]=a,e[38]=c,e[39]=x,e[40]=L,e[41]=l,e[42]=k,e[43]=n,e[44]=z):z=e[44];let M;e[45]!==Q||e[46]!==z?(M=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[Q,z]}),e[45]=Q,e[46]=z,e[47]=M):M=e[47];let $;e[48]!==_||e[49]!==y||e[50]!==l?($=_||y?r.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:_?r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":l("sessions.sidebar.session.status.active"),title:l("sessions.sidebar.session.status.active")}):r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":l("sessions.sidebar.session.status.unread"),title:l("sessions.sidebar.session.status.unread")})}):null,e[48]=_,e[49]=y,e[50]=l,e[51]=$):$=e[51];let T;return e[52]!==K||e[53]!==M||e[54]!==$||e[55]!==H?(T=r.jsxs(Ae,{onClick:H,"data-slot":"session-switcher-item",className:ee,style:K,children:[M,$]}),e[52]=K,e[53]=M,e[54]=$,e[55]=H,e[56]=T):T=e[56],T}function Tt(s){return s.notifyOnSubtasks}function At(s){return s.setCurrentSession}function Ft(s){return s.currentSessionId}export{Bt as C,Xt as S,Wt as W,Le as a,Yt as b,Te as c,Ht as d,Vt as e,Rt as f,Kt as g,Gt as h,Qt as i,pt as j,ye as n,Jt as r,ft as u};
|
|
1
|
+
import{e as ne,R as je,j as r,H as Oe,a as Ue,ad as Ae}from"./vendor-.bun-By2L9XvG.js";import{u as _e,m as X,ay as Be,aa as We,ab as Ge,I as q,M as Ye,ax as He,aw as Ke,bU as Je,bV as Qe,bb as Re,y as Ve,D as Xe,co as qe,cr as Pe,ap as Ze,ar as et,as as tt,z as ke,cN as st,cP as nt}from"./useAppFontEffects-B66TruVB.js";import{x as Se,D as rt,b as Ne}from"./index-AsCHiJ5P.js";const Bt=s=>{const e=ne.c(129),{totalTokens:t,percentage:o,colorPercentage:n,contextLimit:i,outputLimit:a,size:c,isMobile:x,hideIcon:m,showPercentIcon:l,className:f,valueClassName:v,percentIconClassName:b,onClick:p,pressed:w}=s,S=c===void 0?"default":c,h=x===void 0?!1:x,j=m===void 0?!1:m,N=l===void 0?!1:l,C=w===void 0?!1:w,{t:d}=_e(),[_,y]=je.useState(!1),u=typeof n=="number"?n:o;let g,D,P,I,L,W,B,G;if(e[0]!==u||e[1]!==i||e[2]!==j||e[3]!==h||e[4]!==p||e[5]!==a||e[6]!==b||e[7]!==o||e[8]!==N||e[9]!==d||e[10]!==t||e[11]!==v){const z=We(o)??0,M=Ge(u),$=M==="critical"?"var(--status-error)":M==="warn"?"var(--status-warning)":"var(--status-success)";g=ot,D=it;const T=2*Math.PI*8.5,k=T*(1-z/100);I=typeof a=="number"?Math.max(a,0):0;let E;e[20]!==d||e[21]!==t?(E=d("contextUsage.tooltip.usedTokens",{tokens:g(t)}),e[20]=d,e[21]=t,e[22]=E):E=e[22];let O;e[23]!==i||e[24]!==d?(O=d("contextUsage.tooltip.contextLimit",{tokens:g(i)}),e[23]=i,e[24]=d,e[25]=O):O=e[25];let U;e[26]!==I||e[27]!==d?(U=d("contextUsage.tooltip.outputLimit",{tokens:g(I)}),e[26]=I,e[27]=d,e[28]=U):U=e[28];let R;e[29]!==O||e[30]!==U||e[31]!==E?(R=[E,O,U],e[29]=O,e[30]=U,e[31]=E,e[32]=R):R=e[32],G=R,P=!h&&typeof p=="function",e[33]!==j||e[34]!==h?(B=!h&&!j&&r.jsx(q,{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=X("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:X("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]=i,e[2]=j,e[3]=h,e[4]=p,e[5]=a,e[6]=b,e[7]=o,e[8]=N,e[9]=d,e[10]=t,e[11]=v,e[12]=g,e[13]=D,e[14]=P,e[15]=I,e[16]=L,e[17]=W,e[18]=B,e[19]=G}else g=e[12],D=e[13],P=e[14],I=e[15],L=e[16],W=e[17],B=e[18],G=e[19];let Y;e[38]!==L||e[39]!==W?(Y=r.jsx("span",{className:L,children:W}),e[38]=L,e[39]=W,e[40]=Y):Y=e[40];let Z;e[41]!==B||e[42]!==Y?(Z=r.jsxs(r.Fragment,{children:[B,Y]}),e[41]=B,e[42]=Y,e[43]=Z):Z=e[43];const H=Z,ee=S==="compact"?"typography-micro":"typography-meta";let te;e[44]!==f||e[45]!==P||e[46]!==ee?(te=X("app-region-no-drag flex items-center gap-1.5 select-none",ee,P?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",f),e[44]=f,e[45]=P,e[46]=ee,e[47]=te):te=e[47];const K=te;let J;e[48]!==H||e[49]!==P||e[50]!==h||e[51]!==p||e[52]!==C||e[53]!==K||e[54]!==d?(J=P?r.jsx("button",{type:"button",className:K,"aria-label":d("contextUsage.aria.label"),"aria-pressed":C,onClick:p,children:H}):r.jsx("div",{className:K,"aria-label":d("contextUsage.aria.label"),onClick:h?()=>y(!0):void 0,children:H}),e[48]=H,e[49]=P,e[50]=h,e[51]=p,e[52]=C,e[53]=K,e[54]=d,e[55]=J):J=e[55];const V=J;if(h){let z;e[56]===Symbol.for("react.memo_cache_sentinel")?(z=()=>y(!1),e[56]=z):z=e[56];let M;e[57]!==d?(M=d("contextUsage.mobile.title"),e[57]=d,e[58]=M):M=e[58];let $;e[59]!==d?($=d("contextUsage.mobile.usedTokens"),e[59]=d,e[60]=$):$=e[60];let T;e[61]!==$?(T=r.jsx("span",{className:"typography-meta text-muted-foreground",children:$}),e[61]=$,e[62]=T):T=e[62];let 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 R;e[73]!==U?(R=r.jsx("span",{className:"typography-meta text-muted-foreground",children:U}),e[73]=U,e[74]=R):R=e[74];let re;e[75]!==i||e[76]!==g?(re=g(i),e[75]=i,e[76]=g,e[77]=re):re=e[77];let oe;e[78]!==re?(oe=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:re}),e[78]=re,e[79]=oe):oe=e[79];let ie;e[80]!==R||e[81]!==oe?(ie=r.jsxs("div",{className:"flex justify-between items-center",children:[R,oe]}),e[80]=R,e[81]=oe,e[82]=ie):ie=e[82];let ae;e[83]!==d?(ae=d("contextUsage.mobile.outputLimit"),e[83]=d,e[84]=ae):ae=e[84];let le;e[85]!==ae?(le=r.jsx("span",{className:"typography-meta text-muted-foreground",children:ae}),e[85]=ae,e[86]=le):le=e[86];let ce;e[87]!==g||e[88]!==I?(ce=g(I),e[87]=g,e[88]=I,e[89]=ce):ce=e[89];let de;e[90]!==ce?(de=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:ce}),e[90]=ce,e[91]=de):de=e[91];let ue;e[92]!==le||e[93]!==de?(ue=r.jsxs("div",{className:"flex justify-between items-center",children:[le,de]}),e[92]=le,e[93]=de,e[94]=ue):ue=e[94];let me;e[95]!==d?(me=d("contextUsage.mobile.usage"),e[95]=d,e[96]=me):me=e[96];let fe;e[97]!==me?(fe=r.jsx("span",{className:"typography-meta text-muted-foreground",children:me}),e[97]=me,e[98]=fe):fe=e[98];let he;e[99]!==u||e[100]!==D?(he=X("typography-meta font-semibold",D(u)),e[99]=u,e[100]=D,e[101]=he):he=e[101];const De=Math.min(o,999);let pe;e[102]!==De?(pe=De.toFixed(1),e[102]=De,e[103]=pe):pe=e[103];let ge;e[104]!==he||e[105]!==pe?(ge=r.jsxs("span",{className:he,children:[pe,"%"]}),e[104]=he,e[105]=pe,e[106]=ge):ge=e[106];let xe;e[107]!==fe||e[108]!==ge?(xe=r.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[fe,ge]}),e[107]=fe,e[108]=ge,e[109]=xe):xe=e[109];let be;e[110]!==O||e[111]!==ie||e[112]!==ue||e[113]!==xe?(be=r.jsx("div",{className:"flex flex-col gap-1.5",children:r.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[O,ie,ue,xe]})}),e[110]=O,e[111]=ie,e[112]=ue,e[113]=xe,e[114]=be):be=e[114];let we;e[115]!==_||e[116]!==M||e[117]!==be?(we=r.jsx(Ye,{open:_,onClose:z,title:M,children:be}),e[115]=_,e[116]=M,e[117]=be,e[118]=we):we=e[118];let ve;return e[119]!==V||e[120]!==we?(ve=r.jsxs(r.Fragment,{children:[V,we]}),e[119]=V,e[120]=we,e[121]=ve):ve=e[121],ve}let A;e[122]!==V?(A=r.jsx(He,{asChild:!0,children:V}),e[122]=V,e[123]=A):A=e[123];let F;e[124]!==G?(F=r.jsx(Be,{children:r.jsx("div",{className:"space-y-0.5",children:G.map(at)})}),e[124]=G,e[125]=F):F=e[125];let Q;return e[126]!==A||e[127]!==F?(Q=r.jsxs(Ke,{children:[A,F]}),e[126]=A,e[127]=F,e[128]=Q):Q=e[128],Q};function ot(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toFixed(1).replace(/\.0$/,"")}function it(s){return s>=90?"text-status-error":s>=75?"text-status-warning":"text-status-success"}function at(s){return r.jsx("p",{className:"typography-micro leading-tight",children:s},s)}const Wt=je.memo(function(e){const t=ne.c(40),{visible:o}=e,{t:n}=_e(),[i,a]=je.useState(!1);let c,x;if(t[0]!==o?(c=()=>{if(!o)return;let D=!1;Se("desktop_get_current_window_state").then(I=>{D||a(!!I?.maximized)}).catch(lt);const P=I=>{const L=I.detail;a(!!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]=c,t[2]=x):(c=t[1],x=t[2]),Oe.useEffect(c,x),!o)return null;let m;t[3]!==n?(m=n("header.windowControls.groupAria"),t[3]=n,t[4]=m):m=t[4];let l;t[5]!==n?(l=n("header.windowControls.minimize"),t[5]=n,t[6]=l):l=t[6];let f;t[7]!==n?(f=n("header.windowControls.minimize"),t[7]=n,t[8]=f):f=t[8];let v;t[9]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(q,{name:"subtract",className:"h-4 w-4"}),t[9]=v):v=t[9];let b;t[10]!==l||t[11]!==f?(b=r.jsx("button",{type:"button",className:"app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:ct,title:l,"aria-label":f,children:v}),t[10]=l,t[11]=f,t[12]=b):b=t[12];let p;t[13]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{Se("desktop_toggle_current_window_maximized").then(D=>a(!!D?.maximized)).catch(dt)},t[13]=p):p=t[13];let w;t[14]!==i||t[15]!==n?(w=n(i?"header.windowControls.restore":"header.windowControls.maximize"),t[14]=i,t[15]=n,t[16]=w):w=t[16];let S;t[17]!==i||t[18]!==n?(S=n(i?"header.windowControls.restore":"header.windowControls.maximize"),t[17]=i,t[18]=n,t[19]=S):S=t[19];const h=i?"fullscreen-exit":"checkbox-blank";let j;t[20]!==h?(j=r.jsx(q,{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=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 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(q,{name:"close",className:"h-4 w-4"}),t[31]=y):y=t[31];let u;t[32]!==d||t[33]!==_?(u=r.jsx("button",{type:"button",className:C,onClick:ut,title:d,"aria-label":_,children:y}),t[32]=d,t[33]=_,t[34]=u):u=t[34];let g;return t[35]!==N||t[36]!==u||t[37]!==m||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":m,children:[b,N,u]}),t[35]=N,t[36]=u,t[37]=m,t[38]=b,t[39]=g):g=t[39],g});function lt(){}function ct(){Se("desktop_minimize_current_window")}function dt(){}function ut(){Se("desktop_close_current_window")}const Fe="oc.sessions.pinned",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}},Me=(s,e)=>{try{s.setItem(Fe,JSON.stringify([...e]))}catch{}},Ce=rt(),ft=Ue((s,e)=>({ids:mt(Ce),setIds:t=>{const o=e().ids,n=typeof t=="function"?t(o):t;n!==o&&(s({ids:n}),Me(Ce,n))},toggle:t=>{const o=e().ids,n=new Set(o);n.has(t)?n.delete(t):n.add(t),s({ids:n}),Me(Ce,n)}})),se=(s,e)=>Je(Qe.getState().dictionary,s,e),ht=s=>{const e=new Date(s),t=new Date,o=(a,c)=>a.getFullYear()===c.getFullYear()&&a.getMonth()===c.getMonth()&&a.getDate()===c.getDate(),n=new Date(t);return n.setDate(t.getDate()-1),o(e,t)?se("common.date.today"):o(e,n)?se("common.date.yesterday"):e.toLocaleDateString(Re(),{month:"short",day:"numeric",year:"numeric"}).replace(",","")},Gt=s=>{const e=new Date,t=new Date(s);if(((n,i)=>n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate())(t,e)){const n=Date.now()-s;return n<6e4?se("common.relative.justNow"):n<36e5?se("common.relative.minutesAgoShort",{count:Math.floor(n/6e4)}):se("common.relative.hoursAgoShort",{count:Math.floor(n/36e5)})}return ht(s)},pt=s=>{const e=Math.max(0,Date.now()-s),t=6e4,o=60*t,n=24*o,i=7*n,a=30*n,c=365*n;return e<o?`${Math.max(1,Math.floor(e/t))}m`:e<n?`${Math.floor(e/o)}h`:e<i?se("common.relative.daysAgoCompact",{count:Math.floor(e/n)}):e<5*i?se("common.relative.weeksAgoCompact",{count:Math.floor(e/i)}):e<c?`${Math.floor(e/a)}mo`:se("common.relative.yearsAgoCompact",{count:Math.floor(e/c)})},ye=s=>{if(!s)return null;const e=s.replace(/\\/g,"/").replace(/\/+$/,"");return e.length===0?"/":e},gt=(s,e)=>{const t=ye(s),o=ye(e);return!t||!o?!1:t===o?!0:o==="/"?t.startsWith("/"):t.startsWith(`${o}/`)},Le=s=>s.toLowerCase().replace(/^opencode[/-]?/i,"").replace(/[-_]/g,"").trim(),Yt=(s,e)=>s?Le(s)!==Le(e):!1,Ie=s=>{if(typeof s=="number"&&Number.isFinite(s))return s;if(typeof s=="string"&&s.trim().length>0){const e=Number(s);if(Number.isFinite(e))return e}},$e=s=>Ie(s.time?.created)??0,ze=s=>Ie(s.time?.updated)??Ie(s.time?.created)??0,Te=(s,e,t)=>{const o=t.has(s.id),n=t.has(e.id);return o!==n?o?-1:1:o&&n?$e(e)-$e(s):ze(e)-ze(s)},Ht=s=>{const e=new Map;return s.forEach(t=>{e.set(t.id,t)}),Array.from(e.values())},Kt=s=>`__archived__:${s}`,Jt=(s,e)=>{const t=ye(s.directory??null),o=ye(s.project?.worktree??null),n=t??o;if(!n)return"unassigned";if(e&&n===e)return"project root";const a=(e&&n.startsWith(`${e}/`)?n.slice(e.length+1):n).split("/").filter(Boolean);return a[a.length-1]??"unassigned"},Qt=(s,e,t)=>{const o=ye(s.directory??null),n=ye(s.project?.worktree??null);return n&&(n===e||n.startsWith(`${e}/`))?!0:o?t&&t.has(o)?!0:o===e||o.startsWith(`${e}/`):!1},Rt=s=>s.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),Vt=(s,e)=>{if(!e)return s;const t=s.toLowerCase(),o=e.toLowerCase(),n=o.length;if(n===0)return s;const i=[];let a=0,c=t.indexOf(o,a);for(;c!==-1;){c>a&&i.push(s.slice(a,c));const x=s.slice(c,c+n);i.push(r.jsx("mark",{className:"bg-primary text-primary-foreground ring-1 ring-primary/90",children:x},`${c}-${x}`)),a=c+n,c=t.indexOf(o,a)}return a<s.length&&i.push(s.slice(a)),i.length>0?i:s},xt=7,bt=s=>{if(!s)return null;const e=s.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},wt=s=>{if(!s)return null;const e=s.label?.trim();if(e)return e;const t=s.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},yt=(s,e)=>{const t=ne.c(18);let o;t[0]!==e?(o=e===void 0?{}:e,t[0]=e,t[1]=o):o=t[1];const n=o,{scopeProjectId:i}=n,a=i===void 0?null:i,c=Ve(vt),x=Xe(jt),m=ft(St),l=qe();let f;t[2]!==x?(f=x.map(Nt).filter(_t),t[2]=x,t[3]=f):f=t[3];const v=f;let b;t[4]!==v?(b=h=>h?v.filter(N=>gt(h,N.normalizedPath)).sort(Dt)[0]??null:null,t[4]=v,t[5]=b):b=t[5];const p=b;let w;{let h;if(t[7]!==c||t[8]!==l||t[9]!==p||t[10]!==m||t[11]!==a){const j=new Map;for(const y of c){const u=y.parentID;if(!u||y.time?.archived)continue;const g=j.get(u);g?g.push(y):j.set(u,[y])}j.forEach(y=>{y.sort((u,g)=>Te(u,g,m))});let N;t[13]!==p||t[14]!==a?(N=y=>{if(!a)return!0;const u=Pe(y);return p(u)?.id===a},t[13]=p,t[14]=a,t[15]=N):N=t[15];let C;t[16]!==m?(C=(y,u)=>Te(y,u,m),t[16]=m,t[17]=C):C=t[17];const d=c.filter(Ct).filter(Pt).filter(N).sort(C).slice(0,xt),_=y=>{const u=j.get(y.id)??[];return{session:y,children:u.map(g=>_(g)),worktree:null}};h=d.map(y=>{const u=Pe(y),g=p(u),D=wt(g),P=u?l.get(u)??null:null;return{node:_(y),projectId:g?.id??null,groupDirectory:u,secondaryMeta:{projectLabel:D,branchLabel:P&&P!==D?P:null}}}),t[7]=c,t[8]=l,t[9]=p,t[10]=m,t[11]=a,t[12]=h}else h=t[12];w=h}return w};function vt(s){return s.activeSessions}function jt(s){return s.projects}function St(s){return s.ids}function Nt(s){return{...s,normalizedPath:bt(s.path)}}function _t(s){return s.normalizedPath}function Dt(s,e){return(e.normalizedPath?.length??0)-(s.normalizedPath?.length??0)}function Ct(s){return!s.time?.archived}function Pt(s){return!s.parentID}function Xt(s){const e=ne.c(18),{children:t,variant:o,scopeProjectId:n,align:i}=s,a=o===void 0?"default":o,c=n===void 0?null:n,x=i===void 0?"start":i,m=Ne(It),l=Ne(kt);let f;e[0]!==t?(f=r.jsx(Ze,{asChild:!0,children:t}),e[0]=t,e[1]=f):f=e[1];const v=a==="compact"?"w-[280px]":"w-[360px]";let b;e[2]!==v?(b=X("overflow-hidden p-1 max-w-[calc(100vw-32px)]",v),e[2]=v,e[3]=b):b=e[3];let p;e[4]!==m||e[5]!==c||e[6]!==l||e[7]!==a?(p=m?r.jsx(Mt,{onSelect:()=>l(!1),variant:a,scopeProjectId:c}):null,e[4]=m,e[5]=c,e[6]=l,e[7]=a,e[8]=p):p=e[8];let w;e[9]!==x||e[10]!==b||e[11]!==p?(w=r.jsx(et,{align:x,sideOffset:6,className:b,children:p}),e[9]=x,e[10]=b,e[11]=p,e[12]=w):w=e[12];let S;return e[13]!==m||e[14]!==l||e[15]!==f||e[16]!==w?(S=r.jsxs(tt,{open:m,onOpenChange:l,modal:!1,children:[f,w]}),e[13]=m,e[14]=l,e[15]=f,e[16]=w,e[17]=S):S=e[17],S}function kt(s){return s.setSessionDropdownOpen}function It(s){return s.isSessionDropdownOpen}function Mt(s){const e=ne.c(26),{onSelect:t,variant:o,scopeProjectId:n}=s;let i;e[0]!==n?(i={scopeProjectId:n},e[0]=n,e[1]=i):i=e[1];const a=yt(!0,i),c=ke($t),x=Ne(Lt),{t:m}=_e();let l;e[2]!==t||e[3]!==c||e[4]!==x?(l=()=>{x("chat"),t(),c()},e[2]=t,e[3]=c,e[4]=x,e[5]=l):l=e[5];const f=l;let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=new Set,e[6]=v):v=e[6];const[b,p]=je.useState(v);let w;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=u=>{p(g=>{const D=new Set(g);return D.has(u)?D.delete(u):D.add(u),D})},e[7]=w):w=e[7];const S=w;let h,j;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=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"),j=r.jsx(q,{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]!==m?(N=m("sessions.sidebar.header.actions.newSession"),e[10]=m,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]!==f||e[15]!==C?(d=r.jsxs(Ae,{onClick:f,className:h,children:[j,C]}),e[14]=f,e[15]=C,e[16]=d):d=e[16];let _;e[17]!==b||e[18]!==a||e[19]!==t||e[20]!==m||e[21]!==o?(_=a.length===0?r.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:m("sessions.switcher.empty")}):a.map(u=>r.jsx(Ee,{item:u,depth:0,variant:o,expandedParents:b,toggleParent:S,closeDropdown:t},u.node.session.id)),e[17]=b,e[18]=a,e[19]=t,e[20]=m,e[21]=o,e[22]=_):_=e[22];let y;return e[23]!==_||e[24]!==d?(y=r.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:r.jsxs("div",{className:"space-y-0.5",children:[d,_]})}),e[23]=_,e[24]=d,e[25]=y):y=e[25],y}function Lt(s){return s.setActiveMainTab}function $t(s){return s.openNewSessionDraft}function Ee(s){const e=ne.c(31),{item:t,depth:o,variant:n,expandedParents:i,toggleParent:a,closeDropdown:c}=s,{node:x,secondaryMeta:m}=t,l=x.session,f=x.children.length>0;let v;e[0]!==i||e[1]!==l.id?(v=i.has(l.id),e[0]=i,e[1]=l.id,e[2]=v):v=e[2];const b=v;let p;e[3]!==f||e[4]!==l.id||e[5]!==a?(p=f?()=>a(l.id):void 0,e[3]=f,e[4]=l.id,e[5]=a,e[6]=p):p=e[6];let w;e[7]!==c||e[8]!==o||e[9]!==f||e[10]!==b||e[11]!==m||e[12]!==l||e[13]!==p||e[14]!==n?(w=r.jsx(zt,{session:l,depth:o,variant:n,secondaryMeta:m,hasChildren:f,isExpanded:b,onToggleExpand:p,closeDropdown:c}),e[7]=c,e[8]=o,e[9]=f,e[10]=b,e[11]=m,e[12]=l,e[13]=p,e[14]=n,e[15]=w):w=e[15];let S;e[16]!==c||e[17]!==o||e[18]!==i||e[19]!==f||e[20]!==b||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==x.children||e[24]!==m||e[25]!==a||e[26]!==n?(S=f&&b?x.children.map(j=>r.jsx(Ee,{item:{node:j,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:m},depth:o+1,variant:n,expandedParents:i,toggleParent:a,closeDropdown:c},j.session.id)):null,e[16]=c,e[17]=o,e[18]=i,e[19]=f,e[20]=b,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=x.children,e[24]=m,e[25]=a,e[26]=n,e[27]=S):S=e[27];let h;return e[28]!==w||e[29]!==S?(h=r.jsxs(r.Fragment,{children:[w,S]}),e[28]=w,e[29]=S,e[30]=h):h=e[30],h}function zt(s){const e=ne.c(57),{session:t,depth:o,variant:n,secondaryMeta:i,hasChildren:a,isExpanded:c,onToggleExpand:x,closeDropdown:m}=s,{t:l}=_e(),f=ke(Ft),v=ke(At),b=Ne(Tt),p=st(t.id),w=nt(t.id),S=f===t.id;let h;e[0]!==t.title||e[1]!==l?(h=t.title?.trim()||l("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=l,e[2]=h):h=e[2];const j=h,N=!!t.parentID,C=w>0&&(!N||b),d=p?.type??"idle",_=d==="busy"||d==="retry",y=!_&&C&&!S;let u;e[3]!==t.time?.created||e[4]!==t.time?.updated?(u=t.time?.updated||t.time?.created||Date.now(),e[3]=t.time?.created,e[4]=t.time?.updated,e[5]=u):u=e[5];const g=u;let D;e[6]!==g?(D=pt(g),e[6]=g,e[7]=D):D=e[7];const P=D;let I;e[8]!==i?.projectLabel?(I=i?.projectLabel?.trim()||null,e[8]=i?.projectLabel,e[9]=I):I=e[9];const L=I;let W;e[10]!==i?.branchLabel?(W=i?.branchLabel?.trim()||null,e[10]=i?.branchLabel,e[11]=W):W=e[11];const B=W,G=B&&B!=="HEAD"?B:null;let Y;e[12]!==m||e[13]!==S||e[14]!==t||e[15]!==v?(Y=()=>{if(S){m();return}const k=Pe(t);v(t.id,k??null),m()},e[12]=m,e[13]=S,e[14]=t,e[15]=v,e[16]=Y):Y=e[16];const Z=Y;let H;e[17]!==Z?(H=k=>{if(k.target?.closest("[data-switcher-expand]")){k.preventDefault();return}Z()},e[17]=Z,e[18]=H):H=e[18];let ee;e[19]===Symbol.for("react.memo_cache_sentinel")?(ee=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[19]=ee):ee=e[19];const te=8+o*12;let K;e[20]!==te?(K={paddingLeft:te},e[20]=te,e[21]=K):K=e[21];let J;e[22]!==a||e[23]!==c||e[24]!==x||e[25]!==l||e[26]!==n?(J=n==="compact"&&a?r.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick: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":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?r.jsx(q,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):r.jsx(q,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[22]=a,e[23]=c,e[24]=x,e[25]=l,e[26]=n,e[27]=J):J=e[27];const V=S?"text-primary":"text-foreground";let A;e[28]!==V?(A=X("truncate text-[14px] font-normal leading-tight",V),e[28]=V,e[29]=A):A=e[29];let F;e[30]!==j||e[31]!==A?(F=r.jsx("span",{className:A,children:j}),e[30]=j,e[31]=A,e[32]=F):F=e[32];let Q;e[33]!==J||e[34]!==F?(Q=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[J,F]}),e[33]=J,e[34]=F,e[35]=Q):Q=e[35];let z;e[36]!==G||e[37]!==a||e[38]!==c||e[39]!==x||e[40]!==L||e[41]!==l||e[42]!==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:[a?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":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?r.jsx(q,{name:"arrow-down-s",className:"h-3 w-3"}):r.jsx(q,{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(q,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),r.jsx("span",{className:"truncate",children:G})]}):null]}):null,e[36]=G,e[37]=a,e[38]=c,e[39]=x,e[40]=L,e[41]=l,e[42]=P,e[43]=n,e[44]=z):z=e[44];let M;e[45]!==Q||e[46]!==z?(M=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[Q,z]}),e[45]=Q,e[46]=z,e[47]=M):M=e[47];let $;e[48]!==_||e[49]!==y||e[50]!==l?($=_||y?r.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:_?r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":l("sessions.sidebar.session.status.active"),title:l("sessions.sidebar.session.status.active")}):r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":l("sessions.sidebar.session.status.unread"),title:l("sessions.sidebar.session.status.unread")})}):null,e[48]=_,e[49]=y,e[50]=l,e[51]=$):$=e[51];let T;return e[52]!==K||e[53]!==M||e[54]!==$||e[55]!==H?(T=r.jsxs(Ae,{onClick:H,"data-slot":"session-switcher-item",className:ee,style:K,children:[M,$]}),e[52]=K,e[53]=M,e[54]=$,e[55]=H,e[56]=T):T=e[56],T}function Tt(s){return s.notifyOnSubtasks}function At(s){return s.setCurrentSession}function Ft(s){return s.currentSessionId}export{Bt as C,Xt as S,Wt as W,Le as a,Yt as b,Te as c,Ht as d,Vt as e,Rt as f,Kt as g,Gt as h,Qt as i,pt as j,ye as n,Jt as r,ft as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as h,R as b,j as t,bi as w,bh as j,bg as v,be as D,bc as k}from"./vendor-.bun-By2L9XvG.js";import{u as R,m as g}from"./useAppFontEffects-
|
|
1
|
+
import{e as h,R as b,j as t,bi as w,bh as j,bg as v,be as D,bc as k}from"./vendor-.bun-By2L9XvG.js";import{u as R,m as g}from"./useAppFontEffects-B66TruVB.js";import{h as S}from"./NewWorktreeDialog-Dj6KETex.js";import"./index-AsCHiJ5P.js";import"./mobileLayoutPreference-Dio-WWkI.js";const B=x=>{const e=h.c(19),{open:m,onOpenChange:n}=x,{t:u}=R(),s=b.useId(),y=_;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(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(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(k,{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,k as vt,cj as xt,ck as Tt,cl as kt}from"./vendor-.bun-By2L9XvG.js";import{u as bt,p as Ct,eI as Et,m as et,a as Rt,q as St,f6 as At,at as It,z as ht,b as Bt,I as fe,B as oe}from"./useAppFontEffects-Bd0ks39c.js";import{u as q}from"./main-DOdUrt3s.js";import{e as Mt,b as Me,bP as Pt,bO as it,ad as pt}from"./index-BsXkdBYx.js";import{v as Dt,w as Nt}from"./NewWorktreeDialog-5TYBoMMA.js";import"./SessionSwitcherDropdown-B6kvduse.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,cj as xt,ck as Tt,cl as kt}from"./vendor-.bun-By2L9XvG.js";import{u as bt,p as Ct,eJ as Et,m as et,a as Rt,q as St,f7 as At,at as It,z as ht,b as Bt,I as fe,B as oe}from"./useAppFontEffects-B66TruVB.js";import{u as q}from"./main-BByFAmjA.js";import{e as Mt,b as Me,bP as Pt,bO as it,ad as pt}from"./index-AsCHiJ5P.js";import{v as Dt,w as Nt}from"./NewWorktreeDialog-Dj6KETex.js";import"./SessionSwitcherDropdown-Cn_yoQrm.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(`
|