@vantran-se/openchamber-web 2.0.6 → 2.0.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.js +18 -6
- package/bin/lib/commands-update.test.js +14 -1
- package/dist/assets/{CodeMirrorCommentWidgets-BlzB2e0C.js → CodeMirrorCommentWidgets-C55OCQB7.js} +1 -1
- package/dist/assets/{DiffView-D7JQzQVZ.js → DiffView-D80HdPcb.js} +1 -1
- package/dist/assets/{FilesView-DC2gadXM.js → FilesView-CPu9KAn_.js} +1 -1
- package/dist/assets/{GitView-Gzl0wbdd.js → GitView-Cyb4HROP.js} +1 -1
- package/dist/assets/{GuestAttachDialog-CQdDIeco.js → GuestAttachDialog-CdC8RfDh.js} +1 -1
- package/dist/assets/{GuestSurfacePane-CrOhlIdt.js → GuestSurfacePane-ByCCvFv4.js} +1 -1
- package/dist/assets/{JsonTreeView-C3QZifYe.js → JsonTreeView-pYH8Escm.js} +1 -1
- package/dist/assets/{LinearIssuesView-X27TCI3v.js → LinearIssuesView-lyflKD5B.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-BlTWU9oH.js → MarkdownImageGallery-DOU9EkBG.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-Cno7QsJO.js → MarkdownRendererImpl-BKISoFr4.js} +1 -1
- package/dist/assets/{OnboardingScreen-Wr_UzNtt.js → OnboardingScreen-_Ln6bjbQ.js} +1 -1
- package/dist/assets/{PatchDiff-D6pWS7cD.js → PatchDiff-DmYhtAwM.js} +1 -1
- package/dist/assets/{PierreDiffViewer-DDljFbJJ.js → PierreDiffViewer-pRlYFUzk.js} +1 -1
- package/dist/assets/{PlanView-LcfEbBPi.js → PlanView-Bjk4ILam.js} +1 -1
- package/dist/assets/{PluginPane-DPWPLc2f.js → PluginPane-DJgKVT9D.js} +1 -1
- package/dist/assets/{SettingsView-CFe9O3EM.js → SettingsView-DkZCkUK1.js} +1 -1
- package/dist/assets/{SettingsWindow-DT1xhvgi.js → SettingsWindow-fWY8N5ei.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-CBHXaIkB.js → SubmoduleDiffSummary-Dpv4MPVo.js} +1 -1
- package/dist/assets/{ToolOutputDialog-B_ZX8ZbZ.js → ToolOutputDialog-BK3T8zOg.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-D_HQzkXU.js → ToolPartDiffPreview-bT5jc7Fw.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-BUK1ujXg.js → VirtualizedFileDiff-DOhvVx32.js} +1 -1
- package/dist/assets/{WalkthroughView-H-tYOvhO.js → WalkthroughView-o4P1auMo.js} +1 -1
- package/dist/assets/{appThemeRegistry-BoJGAwCP.js → appThemeRegistry-CF0I57r1.js} +1 -1
- package/dist/assets/{commitAndPush-BzZrF8bK.js → commitAndPush-Dm3wnp4u.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-kYyVjXLu.js → computeVirtualFileMetrics-CcxmuPAX.js} +1 -1
- package/dist/assets/{de-ByfQDcPj.js → de-CFmy555r.js} +1 -1
- package/dist/assets/{es-DzNbjsQS.js → es-DLf8iVkG.js} +1 -1
- package/dist/assets/{fr-B8AVLrnX.js → fr-J24E2vLK.js} +1 -1
- package/dist/assets/{index-0-ON1L7L.js → index-CliHhehR.js} +1 -1
- package/dist/assets/{isDiffPlainText-Bgm_aLpu.js → isDiffPlainText-Bwg3vzSL.js} +1 -1
- package/dist/assets/{isFilePlainText-D5GMgURH.js → isFilePlainText-D7OOnOq1.js} +1 -1
- package/dist/assets/{ja-1g6S0G19.js → ja-lWSJzoL3.js} +1 -1
- package/dist/assets/{ko-CxplvYkJ.js → ko-eOc96o9x.js} +1 -1
- package/dist/assets/{main--Y98ZLsD.js → main-C0R2Xb0E.js} +2 -2
- package/dist/assets/{main-GjXmVNpD.js → main-vkkdS1mY.js} +4 -4
- package/dist/assets/{markdownCore-CVdUcVCi.js → markdownCore-fx1suKTc.js} +1 -1
- package/dist/assets/{miniChat-tTx5mpbd.js → miniChat-zdTAhJRJ.js} +2 -2
- package/dist/assets/{mobile-BmbiDWGb.js → mobile-CygK96hE.js} +2 -2
- package/dist/assets/{patchFileDiff-CV4iVQ8L.js → patchFileDiff-D3bSFjjg.js} +1 -1
- package/dist/assets/{pl-f3QyqvIB.js → pl-1eAnXR9t.js} +1 -1
- package/dist/assets/{pt-BR-BsaoaiCK.js → pt-BR-BrGSooa_.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-BnCdnDhv.js → renderElectronMiniChatApp-uJeO0EuJ.js} +2 -2
- package/dist/assets/{renderMobileApp-CKn8nbSW.js → renderMobileApp-B5ErILfl.js} +3 -3
- package/dist/assets/{runtimeEndpointReset-sCi88eed.js → runtimeEndpointReset-BsoTecOZ.js} +3 -3
- package/dist/assets/{shikiHighlight-O5_xLmWt.js → shikiHighlight-U-ER5VqY.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-XM4VefqN.js → textMateThemeFromAppTheme-CFZUMoyT.js} +1 -1
- package/dist/assets/{tr-BNFsa6nz.js → tr-CCBiZbUG.js} +1 -1
- package/dist/assets/{uk-CJ9y5ULA.js → uk-DdUzOSao.js} +1 -1
- package/dist/assets/{useAppFontEffects-BN06mgHB.js → useAppFontEffects-Cfuya0Zd.js} +10 -10
- package/dist/assets/{useInlineCommentController-Bb9Gjz1Q.js → useInlineCommentController-GbLdwSYb.js} +1 -1
- package/dist/assets/{useRootScrollLock-Chk1cFUw.js → useRootScrollLock-1Q9TrnWg.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-C2qMZiA7.js → vendor-codemirror-language-data-CcqLCIWH.js} +2 -2
- package/dist/assets/{web-components-BQWjCn_U.js → web-components-BWh2SieS.js} +1 -1
- package/dist/assets/{zh-CN-U0QjVlAA.js → zh-CN-CyPbhaBn.js} +1 -1
- package/dist/assets/{zh-TW-J9PTJQJi.js → zh-TW-D3yWw7PT.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/mini-chat.html +1 -1
- package/dist/mobile.html +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as D,j as e,R as c,f as G}from"./vendor-react-BUCujlKS.js";import{f as Q,B as U,X as V,g as me,O as Ce,h as ne,I as O}from"./useAppFontEffects-BN06mgHB.js";import{Q as W,cU as Ne,cR as le,cN as z,F as B,ay as H,ec as Se,aF as ue,Y as pe,h as Y,aO as he,v as xe,V as re}from"./index-Di6zUe5h.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-BSoePkpP.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-C2qMZiA7.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-client-DSZl7jSi.js";function Re(a){switch(a){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 oe(a){return a==="wrong-service"||a==="unreachable"||a==="incompatible"}function fe({onBack:a,showBackButton:t=!0,initialUrl:s="",initialLabel:i="",isRecoveryMode:n=!1,onConnect:l,onSwitchToLocal:u,showInstancePicker:r=!1}){const{t:o}=Q(),[w,R]=D.useState(s),[j,T]=D.useState(i),[I,x]=D.useState("idle"),[m,k]=D.useState(null),[C,b]=D.useState(""),[N,K]=D.useState([]),[y,f]=D.useState(()=>r?"instances":"add"),[g,L]=D.useState("");D.useEffect(()=>{r&&W().then(h=>K(h.hosts)).catch(h=>{b(h instanceof Error?h.message:String(h))})},[r]);const S=Ne(w),A=S?.persistedUrl??null,E=D.useCallback(h=>{R(h.target.value),x("idle"),k(null),b("")},[]),M=D.useCallback(h=>{T(h.target.value)},[]),d=D.useCallback(async()=>{if(A){x("testing"),k(null),b("");try{const h=await le(A);k(h),x(h.status==="ok"||h.status==="update-recommended"?"success":"error")}catch(h){b(h instanceof Error?h.message:o("onboarding.remoteConnection.errors.connectionTestFailed")),x("error")}}},[A,o]),_=D.useCallback(async()=>{if(!S)return;const h=S.persistedUrl;x("testing"),k(null),b("");try{const F=await le(h);if(k(F),oe(F.status)){x("error");return}const Z=await W(),je=j.trim()||h,ee=Z.hosts.find(q=>q.url===h),te=ee?ee.id:`host-${Date.now().toString(16)}`,ie={id:te,label:je,url:h,apiUrl:h},ke=ee?Z.hosts.map(q=>q.id===te?ie:q):[...Z.hosts,ie];if(await z({hosts:ke,defaultHostId:te,initialHostChoiceCompleted:!0}),l?.(),S.redeemUrl){window.location.assign(S.redeemUrl);return}B()&&await H()}catch(F){b(F instanceof Error?F.message:o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[S,j,l,o]),$=D.useCallback(async h=>{const F=await W();await z({hosts:F.hosts,defaultHostId:h,initialHostChoiceCompleted:!0}),await H()},[]),p=D.useCallback(async()=>{x("testing"),b("");try{const h=await W(),F=await Se(g,h.hosts);await z({hosts:F.hosts,defaultHostId:F.hostId,initialHostChoiceCompleted:!0}),await H()}catch(h){b(h instanceof Error&&h.message==="invalid-connect-link"?o("settings.remoteInstances.direct.error.invalidConnectLink"):o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[g,o]),v=I==="testing",P=A!==null&&!v,J=A!==null&&!v&&!oe(m?.status??null),X=Re(m?.status??null),ye=m?.status==="ok",ve=m?.status==="update-recommended",we=m?.status==="auth",ae=oe(m?.status??null);return r&&y==="instances"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("desktopHostSwitcher.actions.switchInstance")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.description")})]}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx("div",{className:"space-y-2",children:N.length===0?e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:o("settings.remoteInstances.direct.state.empty")}):N.map(h=>e.jsx(U,{variant:"outline",className:"w-full justify-start",onClick:()=>{$(h.id)},children:e.jsx("span",{className:"min-w-0 truncate",children:h.label})},h.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(U,{variant:"outline",className:"flex-1",onClick:()=>f("import"),children:o("settings.remoteInstances.direct.import.action")}),e.jsx(U,{className:"flex-1",onClick:()=>f("add"),children:o("settings.remoteInstances.direct.actions.add")})]})]})}):r&&y==="import"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsx(U,{variant:"ghost",onClick:()=>f("instances"),className:"p-0 text-muted-foreground",children:o("onboarding.common.actions.back")}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("settings.remoteInstances.direct.import.action")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.import.description")})]}),e.jsx(V,{value:g,onChange:h=>L(h.target.value),placeholder:o("settings.remoteInstances.direct.import.placeholder"),disabled:v,autoFocus:!0}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx(U,{onClick:()=>{p()},disabled:v||!g.trim(),children:o("settings.remoteInstances.direct.import.action")})]})}):e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[(t||r)&&e.jsx("div",{className:"flex items-center",children:e.jsx(U,{variant:"ghost",onClick:r?()=>f("instances"):a,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o(n?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("onboarding.remoteConnection.description")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.serverAddress")}),e.jsx(V,{id:"remote-url",type:"url",value:w,onChange:E,placeholder:o("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:v})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.nameOptional")}),e.jsx(V,{id:"remote-label",type:"text",value:j,onChange:M,placeholder:o("onboarding.remoteConnection.field.namePlaceholder"),disabled:v})]})]}),m&&ye&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:o("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&we&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:o("onboarding.remoteConnection.status.authWarning")}),m&&ve&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:X?o(X):null}),m&&ae&&e.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold mb-1",children:o("onboarding.remoteConnection.status.connectionFailed")}),e.jsx("div",{className:"opacity-90",children:X?o(X):null})]}),e.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?o("onboarding.remoteConnection.status.suggestionsUnreachable"):o("onboarding.remoteConnection.status.suggestionsWrongService")})]}),C&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:C}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(U,{variant:"outline",onClick:d,disabled:!P,children:o(v?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),e.jsx(U,{onClick:_,disabled:!J,children:o("onboarding.remoteConnection.actions.connectAndRestart")})]}),ae&&e.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[e.jsx("div",{className:"text-xs text-muted-foreground text-center",children:o("onboarding.remoteConnection.actions.whatToDo")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(U,{variant:"outline",size:"sm",onClick:a,className:"flex-1",children:o("onboarding.remoteConnection.actions.chooseDifferentServer")}),!n&&u&&e.jsx(U,{variant:"outline",size:"sm",onClick:u,className:"flex-1",children:o("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const Le="curl -fsSL https://opencode.ai/v2/install | bash",ge="npm install -g @opencode/cli",Ue="https://opencode.ai/download",ce=2500;function Ie(a){const t=G.c(9),{windows:s,onCopy:i,copyTitle:n}=a;let l;t[0]!==s?(l=e.jsx("code",{className:"flex-1 min-w-0 text-left overflow-x-auto whitespace-nowrap",children:s?e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:ge}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/v2/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]})}),t[0]=s,t[1]=l):l=t[1];let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=e.jsx(O,{name:"file-copy",className:"h-4 w-4"}),t[2]=u):u=t[2];let r;t[3]!==n||t[4]!==i?(r=e.jsx("button",{onClick:i,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:n,"aria-label":n,children:u}),t[3]=n,t[4]=i,t[5]=r):r=t[5];let o;return t[6]!==l||t[7]!==r?(o=e.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[l,r]}),t[6]=l,t[7]=r,t[8]=o):o=t[8],o}function Te({onCliAvailable:a,localAvailable:t=!0}){const{t:s}=Q(),[i,n]=c.useState(!1),[l,u]=c.useState(!1),[r,o]=c.useState(!1),[w,R]=c.useState(!1),[j,T]=c.useState(""),[I,x]=c.useState("unknown"),[m,k]=c.useState(()=>t?"local":"remote"),[C,b]=c.useState(!1),[N,K]=c.useState(!1);c.useEffect(()=>{u(B())},[]),c.useEffect(()=>{if(typeof navigator>"u"){x("unknown");return}const p=navigator.userAgent||"";/Windows/i.test(p)?x("windows"):/Macintosh|Mac OS X/i.test(p)?x("macos"):/Linux/i.test(p)?x("linux"):x("unknown")},[]),c.useEffect(()=>{let p=!1;return(async()=>{try{const v=await ue();if(!v||p)return;const P=v.opencodeBinary??"";P&&T(P)}catch{}})(),()=>{p=!0}},[]);const y=c.useCallback(async p=>{const v=p.target;v.closest(".app-region-no-drag")||v.closest("button, a, input, select, textarea, code, summary, details")||p.button===0&&l&&await pe()},[l]),f=c.useCallback(async()=>{try{const p=await Y("/health");if(!p.ok)return!1;const v=await p.json();return v.openCodeRunning===!0||v.isOpenCodeReady===!0}catch{return!1}},[]),g=c.useCallback(async p=>{if(!l)return;const v=await W();await z({...v,...p==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[l]),L=c.useCallback(async()=>{l&&await g("local"),a?.()},[l,a,g]);c.useEffect(()=>{if(!t||m!=="local")return;let p=!1,v=null;const P=async()=>{if(!p){try{const J=await f();if(p)return;if(J){await L();return}}catch{}p||(v=setTimeout(P,ce))}};return v=setTimeout(P,ce),()=>{p=!0,v&&clearTimeout(v)}},[m,f,L,t]);const S=c.useCallback(async()=>{R(!0);try{await f()&&await L()}finally{R(!1)}},[f,L]),A=c.useCallback(async()=>{if(!(typeof window>"u")&&l)try{const p=await he();p.success&&p.path&&p.path.trim().length>0&&T(p.path.trim())}catch{}},[l]),E=c.useCallback(async()=>{o(!0);try{if(await xe({opencodeBinary:j.trim()}),l){await g("local"),await H();return}await Y("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>o(!1),1e3)}},[l,j,g]),M=c.useCallback(async()=>{const p=await me(I==="windows"?ge:Le);p.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",p.error)},[I]),d=Ue,_=I==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":I==="linux"?"/home/you/.opencode/bin/opencode":"/Users/you/.opencode/bin/opencode",$=t&&(!l||m==="local");return e.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:y,children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("header",{className:"flex flex-col items-center text-center",children:[e.jsx(Ce,{width:48,height:48}),e.jsx("h1",{className:"mt-6 text-xl font-semibold tracking-tight text-foreground",children:s("onboarding.chooser.title")}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:s("onboarding.chooser.description")})]}),l&&t&&e.jsxs("div",{role:"tablist",className:"app-region-no-drag mt-7 flex gap-1 rounded-lg border border-border p-1",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":m==="local",className:ne("flex-1 rounded-md px-3 py-1.5 text-sm transition-colors",m==="local"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]":"text-muted-foreground hover:text-foreground"),onClick:()=>k("local"),children:s("onboarding.chooser.tabs.localInstall")}),e.jsx("button",{type:"button",role:"tab","aria-selected":m==="remote",className:ne("flex-1 rounded-md px-3 py-1.5 text-sm transition-colors",m==="remote"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]":"text-muted-foreground hover:text-foreground"),onClick:()=>k("remote"),children:s("onboarding.chooser.tabs.connectRemote")})]}),l&&m==="remote"?e.jsx("div",{className:"app-region-no-drag mt-6",children:e.jsx(fe,{onBack:()=>t&&k("local"),showBackButton:!1,showInstancePicker:!t,onSwitchToLocal:t?()=>k("local"):void 0})}):null,$&&e.jsxs("div",{className:"mt-6",children:[I==="windows"&&e.jsxs("div",{className:"mb-4 rounded-lg border border-border p-4",children:[e.jsx("div",{className:"text-sm text-foreground",children:s("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:s("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:s("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("p",{className:"text-center text-sm leading-relaxed text-muted-foreground text-balance",children:s("onboarding.localSetup.intro")}),e.jsx("div",{className:"app-region-no-drag mt-3 rounded-lg border border-border bg-background/60 px-4 py-3 font-mono text-sm",children:i?e.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(O,{name:"check",className:"h-4 w-4"}),s("onboarding.common.status.copiedToClipboard")]}):e.jsx(Ie,{windows:I==="windows",onCopy:M,copyTitle:s("onboarding.common.copyToClipboard")})}),e.jsxs("div",{className:"app-region-no-drag mt-3 flex items-center gap-2.5 px-1",role:"status","aria-live":"polite",children:[e.jsx("span",{className:"relative inline-flex h-2 w-2 shrink-0","aria-hidden":!0,children:e.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}})}),e.jsxs("span",{className:"min-w-0 flex-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"text-foreground",children:s("onboarding.localSetup.status.watching")})," · ",s("onboarding.localSetup.status.autoContinue")]}),e.jsx("button",{type:"button",onClick:S,disabled:w,className:"shrink-0 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",children:s(w?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),e.jsxs("div",{className:"mt-6 divide-y divide-border/60 border-y border-border/60",children:[e.jsxs("details",{className:"app-region-no-drag group",open:C,onToggle:p=>b(p.currentTarget.open),children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between py-3 text-sm text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.advanced.title")}),e.jsx(O,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsxs("div",{className:"space-y-2 pb-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(V,{value:j,onChange:p=>T(p.target.value),placeholder:_,disabled:r,className:"flex-1 font-mono text-xs"}),e.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:r||!l,children:s("onboarding.localSetup.actions.browse")}),e.jsx(U,{type:"button",size:"sm",onClick:E,disabled:r||!j.trim(),children:s("onboarding.localSetup.actions.apply")})]}),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:s("onboarding.localSetup.helper.saveAndReload")})]})]}),e.jsxs("details",{className:"app-region-no-drag group",open:N,onToggle:p=>K(p.currentTarget.open),children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between py-3 text-sm text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.troubleshoot.title")}),e.jsx(O,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsx("ul",{className:"list-disc space-y-1.5 pb-4 pl-4 text-xs text-muted-foreground",children:I==="windows"?e.jsx("li",{children:s("onboarding.localSetup.windows.hintDetectionFailed")}):e.jsxs(e.Fragment,{children:[e.jsx("li",{children:s("onboarding.localSetup.hint.ensurePath")}),e.jsx("li",{children:s("onboarding.localSetup.hint.setEnv")}),e.jsx("li",{children:s("onboarding.localSetup.hint.missingRuntime")})]})})]})]}),e.jsx("div",{className:"app-region-no-drag mt-5 text-center",children:e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[s(I==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(O,{name:"external-link",className:"h-3 w-3"})]})})]})]})})}const Ke="curl -fsSL https://opencode.ai/v2/install | bash",be="npm install -g @opencode/cli",De="https://opencode.ai/download";function _e(a){const t=G.c(9),{windows:s,onCopy:i,copyTitle:n}=a;let l;t[0]!==s?(l=e.jsx("code",{className:"flex-1 min-w-0 text-left overflow-x-auto whitespace-nowrap",children:s?e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:be}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/v2/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]})}),t[0]=s,t[1]=l):l=t[1];let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=e.jsx(O,{name:"file-copy",className:"h-4 w-4"}),t[2]=u):u=t[2];let r;t[3]!==n||t[4]!==i?(r=e.jsx("button",{onClick:i,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:n,"aria-label":n,children:u}),t[3]=n,t[4]=i,t[5]=r):r=t[5];let o;return t[6]!==l||t[7]!==r?(o=e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[l,r]}),t[6]=l,t[7]=r,t[8]=o):o=t[8],o}const Ae=3e4;function Oe({onBack:a,onCliAvailable:t,isFromRecovery:s=!1,onSwitchToRemote:i}){const{t:n}=Q(),[l,u]=c.useState(!1),[r,o]=c.useState(!1),[w,R]=c.useState(!1),[j,T]=c.useState(!1),[I,x]=c.useState(!1),[m,k]=c.useState(null),[C,b]=c.useState(""),[N,K]=c.useState("unknown");c.useEffect(()=>{const d=setTimeout(()=>o(!0),Ae);return()=>clearTimeout(d)},[]),c.useEffect(()=>{R(B())},[]),c.useEffect(()=>{if(typeof navigator>"u"){K("unknown");return}const d=navigator.userAgent||"";if(/Windows/i.test(d)){K("windows");return}if(/Macintosh|Mac OS X/i.test(d)){K("macos");return}if(/Linux/i.test(d)){K("linux");return}K("unknown")},[]),c.useEffect(()=>{let d=!1;return(async()=>{try{const _=await ue();if(!_||d)return;const $=_.opencodeBinary??"";$&&b($)}catch{}})(),()=>{d=!0}},[]);const y=c.useCallback(async d=>{d.target.closest("button, a, input, select, textarea, code")||d.button===0&&w&&await pe()},[w]),f=c.useCallback(async()=>{try{const d=await Y("/health");if(!d.ok)return!1;const _=await d.json();return _.openCodeRunning===!0||_.isOpenCodeReady===!0}catch{return!1}},[]),g=c.useCallback(async()=>{if(!(typeof window>"u")&&w)try{const d=await he();d.success&&d.path&&d.path.trim().length>0&&b(d.path.trim())}catch{}},[w]),L=c.useCallback(async()=>{T(!0);try{if(await xe({opencodeBinary:C.trim()}),w){await H();return}await Y("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>T(!1),1e3)}},[w,C]),S=c.useCallback(async()=>{const d=await me(N==="windows"?be:Ke);d.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error("Failed to copy:",d.error)},[N]),A=c.useCallback(async()=>{x(!0),k(null);try{await f()?t?.():k(n("onboarding.localSetup.errors.cliNotReady"))}catch(d){k(d instanceof Error?d.message:n("onboarding.localSetup.errors.detectionFailed"))}finally{x(!1)}},[f,t,n]),E=De,M=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.opencode/bin/opencode":"/Users/you/.opencode/bin/opencode";return e.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:y,children:[e.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[e.jsx("div",{className:"flex items-center",children:e.jsx(U,{variant:"ghost",onClick:a,className:"p-0 text-muted-foreground hover:text-foreground",children:n("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:n("onboarding.localSetup.title")}),e.jsx("p",{className:"text-muted-foreground",children:n("onboarding.localSetup.description")})]}),N==="windows"&&e.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[e.jsx("div",{className:"text-sm text-foreground",children:n("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:n("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:n("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("div",{className:"flex justify-center",children:e.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:l?e.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(O,{name:"check",className:"h-4 w-4"}),n("onboarding.common.status.copiedToClipboard")]}):e.jsx(_e,{windows:N==="windows",onCopy:S,copyTitle:n("onboarding.common.copyToClipboard")})})}),e.jsxs("a",{href:E,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:[n(N==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(O,{name:"external-link",className:"h-3 w-3"})]}),m&&e.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:m}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{type:"button",onClick:A,disabled:I,className:"w-full max-w-xs",size:"lg",children:n(I?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("onboarding.localSetup.helper.checkAndContinue")})]}),e.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:n("onboarding.localSetup.field.alreadyInstalled")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(V,{value:C,onChange:d=>b(d.target.value),placeholder:M,disabled:j,className:"flex-1 font-mono text-xs"}),e.jsx(U,{type:"button",variant:"secondary",onClick:g,disabled:j||!w,children:n("onboarding.localSetup.actions.browse")}),e.jsx(U,{type:"button",onClick:L,disabled:j,children:n("onboarding.localSetup.actions.apply")})]}),e.jsx("div",{className:"text-xs text-muted-foreground/70",children:n("onboarding.localSetup.helper.saveAndReload")})]})}),s&&i&&e.jsxs("div",{className:"text-center pt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:n("onboarding.localSetup.remotePreference")}),e.jsx(U,{variant:"link",onClick:i,children:n("onboarding.localSetup.actions.connectRemoteServer")})]})]}),r&&e.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:N==="windows"?e.jsx(e.Fragment,{children:e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.windows.hintDetectionFailed")})}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.ensurePath")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.setEnv")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.missingRuntime")})]})})]})}function se(a,t){if(a?.trim())return re(a.trim());if(t)return re(t)}function Ee(a,t,s){switch(a){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 i=se(t,s);return{title:"Remote Server Unreachable",description:`Could not connect to "${i||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:i?{host:i}: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 i=se(t,s);return{title:"Incompatible Server",description:`The server at "${i||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:i?{host:i}: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 i=se(t,s);return{title:"Server Update Required",description:`The OpenChamber server at "${i||"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:i?{host:i}: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 i=a;throw new Error(`Unknown recovery variant: ${i}`)}}}function Fe(a){switch(a){case"local":return e.jsx(O,{name:"macbook",className:"h-8 w-8"});case"remote":return e.jsx(O,{name:"server",className:"h-8 w-8"})}}function Me({variant:a,hostLabel:t,hostUrl:s,onRetry:i,onUseLocal:n,onUseRemote:l,isRetrying:u=!1}){const{t:r}=Q(),o=Ee(a,t,s),w=o.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",R=c.useMemo(()=>{if(o.descriptionParams?.host)return o.descriptionParams;if(a==="remote-unreachable")return{host:r("onboarding.desktopRecovery.placeholders.remoteServer")};if(a==="remote-wrong-service"||a==="remote-incompatible")return{host:r("onboarding.desktopRecovery.placeholders.unknownServer")}},[o.descriptionParams,r,a]);return e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[e.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:e.jsx("div",{style:{color:"var(--status-warning)"},children:Fe(o.iconKey)})}),e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:r(o.titleKey)}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:r(o.descriptionKey,R)})]}),s&&(a==="remote-unreachable"||a==="remote-wrong-service"||a==="remote-incompatible")&&e.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:r("onboarding.remoteConnection.field.serverAddress")}),e.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:re(s)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[o.showRetry&&i&&e.jsxs(U,{onClick:i,disabled:u,className:"w-full",children:[e.jsx(O,{name:"refresh",className:ne("h-4 w-4",u&&"animate-spin")}),r(u?"onboarding.desktopRecovery.actions.retrying":w)]}),e.jsxs("div",{className:"flex gap-2",children:[o.showUseLocal&&n&&e.jsxs(U,{variant:"outline",onClick:n,disabled:u,className:"flex-1",children:[e.jsx(O,{name:"macbook",className:"h-4 w-4"}),r(o.useLocalLabelKey)]}),o.showUseRemote&&l&&e.jsxs(U,{variant:"outline",onClick:l,disabled:u,className:"flex-1",children:[e.jsx(O,{name:"server",className:"h-4 w-4"}),r(o.useRemoteLabelKey)]})]})]})]})})}function de(a,t){if(t==="use-remote")return{kind:"remote-form"};switch(a){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 s=a;throw new Error(`Unhandled RecoveryVariant: ${s}`)}}}function He(a){const t=G.c(29),{variant:s,hostUrl:i,hostLabel:n,onRetry:l,onChooseRemote:u,showRemoteForm:r,onCloseRemoteForm:o,onSwitchToLocalFromRemote:w,onEnterLocalSetup:R,isRetrying:j,localAvailable:T}=a,I=r===void 0?!1:r,x=j===void 0?!1:j,m=T===void 0?!0:T,k=Pe;let C;t[0]!==l?(C=async()=>{if(B()){await H();return}await Y("/api/config/reload",{method:"POST"}),l?.()},t[0]=l,t[1]=C):C=t[1];const b=C;let N;t[2]!==R||t[3]!==s?(N=async()=>{if(de(s,"use-local").kind==="local-setup"){R?.();return}if(await k("local"),B()){await H();return}window.location.reload()},t[2]=R,t[3]=s,t[4]=N):N=t[4];const K=N;let y;t[5]!==u||t[6]!==s?(y=()=>{de(s,"use-remote").kind==="remote-form"&&u?.()},t[5]=u,t[6]=s,t[7]=y):y=t[7];const f=y;if(I){const S=s==="remote-wrong-service"?"":i||"",A=s==="remote-wrong-service"?"":n||"";let E;t[8]!==u||t[9]!==o?(E=o||(()=>u?.()),t[8]=u,t[9]=o,t[10]=E):E=t[10];const M=!m;let d;t[11]!==m||t[12]!==R||t[13]!==w?(d=m?w||(()=>{k("local").then(()=>{B()?H():R?.()})}):void 0,t[11]=m,t[12]=R,t[13]=w,t[14]=d):d=t[14];let _;return t[15]!==A||t[16]!==S||t[17]!==E||t[18]!==M||t[19]!==d?(_=e.jsx(fe,{onBack:E,initialUrl:S,initialLabel:A,isRecoveryMode:!0,showInstancePicker:M,onSwitchToLocal:d}),t[15]=A,t[16]=S,t[17]=E,t[18]=M,t[19]=d,t[20]=_):_=t[20],_}const g=m?K:void 0;let L;return t[21]!==b||t[22]!==f||t[23]!==n||t[24]!==i||t[25]!==x||t[26]!==g||t[27]!==s?(L=e.jsx(Me,{variant:s,hostLabel:n,hostUrl:i,onRetry:b,onUseLocal:g,onUseRemote:f,isRetrying:x}),t[21]=b,t[22]=f,t[23]=n,t[24]=i,t[25]=x,t[26]=g,t[27]=s,t[28]=L):L=t[28],L}async function Pe(a){if(!B())return;const t=await W();await z({...t,...a==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function fo(a){const t=G.c(29),{onBack:s,onCliAvailable:i,mode:n,recoveryVariant:l,recoveryHostUrl:u,recoveryHostLabel:r,onEnterLocalSetup:o,localAvailable:w}=a,R=n===void 0?"first-launch":n,j=l===void 0?"missing-default-host":l,T=w===void 0?!0:w,[I,x]=c.useState(!1),[m,k]=c.useState(!1);let C;t[0]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{k(!1),x(!1)},t[0]=C):C=t[0];let b;t[1]!==R||t[2]!==r||t[3]!==u||t[4]!==j?(b=[R,j,u,r],t[1]=R,t[2]=r,t[3]=u,t[4]=j,t[5]=b):b=t[5],c.useEffect(C,b);const N=m?"local-setup":R;if(N==="recovery"){let y;t[6]===Symbol.for("react.memo_cache_sentinel")?(y=()=>x(!0),t[6]=y):y=t[6];let f,g;t[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!1),g=()=>{x(!1),k(!0)},t[7]=f,t[8]=g):(f=t[7],g=t[8]);let L;t[9]!==o?(L=()=>{k(!0),o?.()},t[9]=o,t[10]=L):L=t[10];let S;return t[11]!==T||t[12]!==r||t[13]!==u||t[14]!==j||t[15]!==I||t[16]!==L?(S=e.jsx(He,{variant:j,hostUrl:u,hostLabel:r,onChooseRemote:y,showRemoteForm:I,onCloseRemoteForm:f,onSwitchToLocalFromRemote:g,onEnterLocalSetup:L,localAvailable:T}),t[11]=T,t[12]=r,t[13]=u,t[14]=j,t[15]=I,t[16]=L,t[17]=S):S=t[17],S}if(N==="local-setup"){let y;t[18]!==s||t[19]!==m?(y=()=>{m?k(!1):s?.()},t[18]=s,t[19]=m,t[20]=y):y=t[20];let f;t[21]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!0),t[21]=f):f=t[21];let g;return t[22]!==i||t[23]!==m||t[24]!==y?(g=e.jsx(Oe,{onBack:y,onCliAvailable:i,isFromRecovery:m,onSwitchToRemote:f}),t[22]=i,t[23]=m,t[24]=y,t[25]=g):g=t[25],g}let K;return t[26]!==T||t[27]!==i?(K=e.jsx(Te,{onCliAvailable:i,localAvailable:T}),t[26]=T,t[27]=i,t[28]=K):K=t[28],K}export{fo as OnboardingScreen};
|
|
1
|
+
import{r as D,j as e,R as c,f as G}from"./vendor-react-BUCujlKS.js";import{f as Q,B as U,X as V,g as me,O as Ce,h as ne,I as O}from"./useAppFontEffects-Cfuya0Zd.js";import{Q as W,cU as Ne,cR as le,cN as z,F as B,ay as H,ec as Se,aF as ue,Y as pe,h as Y,aO as he,v as xe,V as re}from"./index-Di6zUe5h.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-BSoePkpP.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CcqLCIWH.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-client-DSZl7jSi.js";function Re(a){switch(a){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 oe(a){return a==="wrong-service"||a==="unreachable"||a==="incompatible"}function fe({onBack:a,showBackButton:t=!0,initialUrl:s="",initialLabel:i="",isRecoveryMode:n=!1,onConnect:l,onSwitchToLocal:u,showInstancePicker:r=!1}){const{t:o}=Q(),[w,R]=D.useState(s),[j,T]=D.useState(i),[I,x]=D.useState("idle"),[m,k]=D.useState(null),[C,b]=D.useState(""),[N,K]=D.useState([]),[y,f]=D.useState(()=>r?"instances":"add"),[g,L]=D.useState("");D.useEffect(()=>{r&&W().then(h=>K(h.hosts)).catch(h=>{b(h instanceof Error?h.message:String(h))})},[r]);const S=Ne(w),A=S?.persistedUrl??null,E=D.useCallback(h=>{R(h.target.value),x("idle"),k(null),b("")},[]),M=D.useCallback(h=>{T(h.target.value)},[]),d=D.useCallback(async()=>{if(A){x("testing"),k(null),b("");try{const h=await le(A);k(h),x(h.status==="ok"||h.status==="update-recommended"?"success":"error")}catch(h){b(h instanceof Error?h.message:o("onboarding.remoteConnection.errors.connectionTestFailed")),x("error")}}},[A,o]),_=D.useCallback(async()=>{if(!S)return;const h=S.persistedUrl;x("testing"),k(null),b("");try{const F=await le(h);if(k(F),oe(F.status)){x("error");return}const Z=await W(),je=j.trim()||h,ee=Z.hosts.find(q=>q.url===h),te=ee?ee.id:`host-${Date.now().toString(16)}`,ie={id:te,label:je,url:h,apiUrl:h},ke=ee?Z.hosts.map(q=>q.id===te?ie:q):[...Z.hosts,ie];if(await z({hosts:ke,defaultHostId:te,initialHostChoiceCompleted:!0}),l?.(),S.redeemUrl){window.location.assign(S.redeemUrl);return}B()&&await H()}catch(F){b(F instanceof Error?F.message:o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[S,j,l,o]),$=D.useCallback(async h=>{const F=await W();await z({hosts:F.hosts,defaultHostId:h,initialHostChoiceCompleted:!0}),await H()},[]),p=D.useCallback(async()=>{x("testing"),b("");try{const h=await W(),F=await Se(g,h.hosts);await z({hosts:F.hosts,defaultHostId:F.hostId,initialHostChoiceCompleted:!0}),await H()}catch(h){b(h instanceof Error&&h.message==="invalid-connect-link"?o("settings.remoteInstances.direct.error.invalidConnectLink"):o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[g,o]),v=I==="testing",P=A!==null&&!v,J=A!==null&&!v&&!oe(m?.status??null),X=Re(m?.status??null),ye=m?.status==="ok",ve=m?.status==="update-recommended",we=m?.status==="auth",ae=oe(m?.status??null);return r&&y==="instances"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("desktopHostSwitcher.actions.switchInstance")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.description")})]}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx("div",{className:"space-y-2",children:N.length===0?e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:o("settings.remoteInstances.direct.state.empty")}):N.map(h=>e.jsx(U,{variant:"outline",className:"w-full justify-start",onClick:()=>{$(h.id)},children:e.jsx("span",{className:"min-w-0 truncate",children:h.label})},h.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(U,{variant:"outline",className:"flex-1",onClick:()=>f("import"),children:o("settings.remoteInstances.direct.import.action")}),e.jsx(U,{className:"flex-1",onClick:()=>f("add"),children:o("settings.remoteInstances.direct.actions.add")})]})]})}):r&&y==="import"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsx(U,{variant:"ghost",onClick:()=>f("instances"),className:"p-0 text-muted-foreground",children:o("onboarding.common.actions.back")}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("settings.remoteInstances.direct.import.action")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.import.description")})]}),e.jsx(V,{value:g,onChange:h=>L(h.target.value),placeholder:o("settings.remoteInstances.direct.import.placeholder"),disabled:v,autoFocus:!0}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx(U,{onClick:()=>{p()},disabled:v||!g.trim(),children:o("settings.remoteInstances.direct.import.action")})]})}):e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[(t||r)&&e.jsx("div",{className:"flex items-center",children:e.jsx(U,{variant:"ghost",onClick:r?()=>f("instances"):a,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o(n?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("onboarding.remoteConnection.description")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.serverAddress")}),e.jsx(V,{id:"remote-url",type:"url",value:w,onChange:E,placeholder:o("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:v})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.nameOptional")}),e.jsx(V,{id:"remote-label",type:"text",value:j,onChange:M,placeholder:o("onboarding.remoteConnection.field.namePlaceholder"),disabled:v})]})]}),m&&ye&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:o("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&we&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:o("onboarding.remoteConnection.status.authWarning")}),m&&ve&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:X?o(X):null}),m&&ae&&e.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold mb-1",children:o("onboarding.remoteConnection.status.connectionFailed")}),e.jsx("div",{className:"opacity-90",children:X?o(X):null})]}),e.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?o("onboarding.remoteConnection.status.suggestionsUnreachable"):o("onboarding.remoteConnection.status.suggestionsWrongService")})]}),C&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:C}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(U,{variant:"outline",onClick:d,disabled:!P,children:o(v?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),e.jsx(U,{onClick:_,disabled:!J,children:o("onboarding.remoteConnection.actions.connectAndRestart")})]}),ae&&e.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[e.jsx("div",{className:"text-xs text-muted-foreground text-center",children:o("onboarding.remoteConnection.actions.whatToDo")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(U,{variant:"outline",size:"sm",onClick:a,className:"flex-1",children:o("onboarding.remoteConnection.actions.chooseDifferentServer")}),!n&&u&&e.jsx(U,{variant:"outline",size:"sm",onClick:u,className:"flex-1",children:o("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const Le="curl -fsSL https://opencode.ai/v2/install | bash",ge="npm install -g @opencode/cli",Ue="https://opencode.ai/download",ce=2500;function Ie(a){const t=G.c(9),{windows:s,onCopy:i,copyTitle:n}=a;let l;t[0]!==s?(l=e.jsx("code",{className:"flex-1 min-w-0 text-left overflow-x-auto whitespace-nowrap",children:s?e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:ge}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/v2/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]})}),t[0]=s,t[1]=l):l=t[1];let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=e.jsx(O,{name:"file-copy",className:"h-4 w-4"}),t[2]=u):u=t[2];let r;t[3]!==n||t[4]!==i?(r=e.jsx("button",{onClick:i,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:n,"aria-label":n,children:u}),t[3]=n,t[4]=i,t[5]=r):r=t[5];let o;return t[6]!==l||t[7]!==r?(o=e.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[l,r]}),t[6]=l,t[7]=r,t[8]=o):o=t[8],o}function Te({onCliAvailable:a,localAvailable:t=!0}){const{t:s}=Q(),[i,n]=c.useState(!1),[l,u]=c.useState(!1),[r,o]=c.useState(!1),[w,R]=c.useState(!1),[j,T]=c.useState(""),[I,x]=c.useState("unknown"),[m,k]=c.useState(()=>t?"local":"remote"),[C,b]=c.useState(!1),[N,K]=c.useState(!1);c.useEffect(()=>{u(B())},[]),c.useEffect(()=>{if(typeof navigator>"u"){x("unknown");return}const p=navigator.userAgent||"";/Windows/i.test(p)?x("windows"):/Macintosh|Mac OS X/i.test(p)?x("macos"):/Linux/i.test(p)?x("linux"):x("unknown")},[]),c.useEffect(()=>{let p=!1;return(async()=>{try{const v=await ue();if(!v||p)return;const P=v.opencodeBinary??"";P&&T(P)}catch{}})(),()=>{p=!0}},[]);const y=c.useCallback(async p=>{const v=p.target;v.closest(".app-region-no-drag")||v.closest("button, a, input, select, textarea, code, summary, details")||p.button===0&&l&&await pe()},[l]),f=c.useCallback(async()=>{try{const p=await Y("/health");if(!p.ok)return!1;const v=await p.json();return v.openCodeRunning===!0||v.isOpenCodeReady===!0}catch{return!1}},[]),g=c.useCallback(async p=>{if(!l)return;const v=await W();await z({...v,...p==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[l]),L=c.useCallback(async()=>{l&&await g("local"),a?.()},[l,a,g]);c.useEffect(()=>{if(!t||m!=="local")return;let p=!1,v=null;const P=async()=>{if(!p){try{const J=await f();if(p)return;if(J){await L();return}}catch{}p||(v=setTimeout(P,ce))}};return v=setTimeout(P,ce),()=>{p=!0,v&&clearTimeout(v)}},[m,f,L,t]);const S=c.useCallback(async()=>{R(!0);try{await f()&&await L()}finally{R(!1)}},[f,L]),A=c.useCallback(async()=>{if(!(typeof window>"u")&&l)try{const p=await he();p.success&&p.path&&p.path.trim().length>0&&T(p.path.trim())}catch{}},[l]),E=c.useCallback(async()=>{o(!0);try{if(await xe({opencodeBinary:j.trim()}),l){await g("local"),await H();return}await Y("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>o(!1),1e3)}},[l,j,g]),M=c.useCallback(async()=>{const p=await me(I==="windows"?ge:Le);p.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",p.error)},[I]),d=Ue,_=I==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":I==="linux"?"/home/you/.opencode/bin/opencode":"/Users/you/.opencode/bin/opencode",$=t&&(!l||m==="local");return e.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:y,children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("header",{className:"flex flex-col items-center text-center",children:[e.jsx(Ce,{width:48,height:48}),e.jsx("h1",{className:"mt-6 text-xl font-semibold tracking-tight text-foreground",children:s("onboarding.chooser.title")}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:s("onboarding.chooser.description")})]}),l&&t&&e.jsxs("div",{role:"tablist",className:"app-region-no-drag mt-7 flex gap-1 rounded-lg border border-border p-1",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":m==="local",className:ne("flex-1 rounded-md px-3 py-1.5 text-sm transition-colors",m==="local"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]":"text-muted-foreground hover:text-foreground"),onClick:()=>k("local"),children:s("onboarding.chooser.tabs.localInstall")}),e.jsx("button",{type:"button",role:"tab","aria-selected":m==="remote",className:ne("flex-1 rounded-md px-3 py-1.5 text-sm transition-colors",m==="remote"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]":"text-muted-foreground hover:text-foreground"),onClick:()=>k("remote"),children:s("onboarding.chooser.tabs.connectRemote")})]}),l&&m==="remote"?e.jsx("div",{className:"app-region-no-drag mt-6",children:e.jsx(fe,{onBack:()=>t&&k("local"),showBackButton:!1,showInstancePicker:!t,onSwitchToLocal:t?()=>k("local"):void 0})}):null,$&&e.jsxs("div",{className:"mt-6",children:[I==="windows"&&e.jsxs("div",{className:"mb-4 rounded-lg border border-border p-4",children:[e.jsx("div",{className:"text-sm text-foreground",children:s("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:s("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:s("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("p",{className:"text-center text-sm leading-relaxed text-muted-foreground text-balance",children:s("onboarding.localSetup.intro")}),e.jsx("div",{className:"app-region-no-drag mt-3 rounded-lg border border-border bg-background/60 px-4 py-3 font-mono text-sm",children:i?e.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(O,{name:"check",className:"h-4 w-4"}),s("onboarding.common.status.copiedToClipboard")]}):e.jsx(Ie,{windows:I==="windows",onCopy:M,copyTitle:s("onboarding.common.copyToClipboard")})}),e.jsxs("div",{className:"app-region-no-drag mt-3 flex items-center gap-2.5 px-1",role:"status","aria-live":"polite",children:[e.jsx("span",{className:"relative inline-flex h-2 w-2 shrink-0","aria-hidden":!0,children:e.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}})}),e.jsxs("span",{className:"min-w-0 flex-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"text-foreground",children:s("onboarding.localSetup.status.watching")})," · ",s("onboarding.localSetup.status.autoContinue")]}),e.jsx("button",{type:"button",onClick:S,disabled:w,className:"shrink-0 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",children:s(w?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),e.jsxs("div",{className:"mt-6 divide-y divide-border/60 border-y border-border/60",children:[e.jsxs("details",{className:"app-region-no-drag group",open:C,onToggle:p=>b(p.currentTarget.open),children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between py-3 text-sm text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.advanced.title")}),e.jsx(O,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsxs("div",{className:"space-y-2 pb-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(V,{value:j,onChange:p=>T(p.target.value),placeholder:_,disabled:r,className:"flex-1 font-mono text-xs"}),e.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:r||!l,children:s("onboarding.localSetup.actions.browse")}),e.jsx(U,{type:"button",size:"sm",onClick:E,disabled:r||!j.trim(),children:s("onboarding.localSetup.actions.apply")})]}),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:s("onboarding.localSetup.helper.saveAndReload")})]})]}),e.jsxs("details",{className:"app-region-no-drag group",open:N,onToggle:p=>K(p.currentTarget.open),children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between py-3 text-sm text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.troubleshoot.title")}),e.jsx(O,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsx("ul",{className:"list-disc space-y-1.5 pb-4 pl-4 text-xs text-muted-foreground",children:I==="windows"?e.jsx("li",{children:s("onboarding.localSetup.windows.hintDetectionFailed")}):e.jsxs(e.Fragment,{children:[e.jsx("li",{children:s("onboarding.localSetup.hint.ensurePath")}),e.jsx("li",{children:s("onboarding.localSetup.hint.setEnv")}),e.jsx("li",{children:s("onboarding.localSetup.hint.missingRuntime")})]})})]})]}),e.jsx("div",{className:"app-region-no-drag mt-5 text-center",children:e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[s(I==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(O,{name:"external-link",className:"h-3 w-3"})]})})]})]})})}const Ke="curl -fsSL https://opencode.ai/v2/install | bash",be="npm install -g @opencode/cli",De="https://opencode.ai/download";function _e(a){const t=G.c(9),{windows:s,onCopy:i,copyTitle:n}=a;let l;t[0]!==s?(l=e.jsx("code",{className:"flex-1 min-w-0 text-left overflow-x-auto whitespace-nowrap",children:s?e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:be}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/v2/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]})}),t[0]=s,t[1]=l):l=t[1];let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=e.jsx(O,{name:"file-copy",className:"h-4 w-4"}),t[2]=u):u=t[2];let r;t[3]!==n||t[4]!==i?(r=e.jsx("button",{onClick:i,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:n,"aria-label":n,children:u}),t[3]=n,t[4]=i,t[5]=r):r=t[5];let o;return t[6]!==l||t[7]!==r?(o=e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[l,r]}),t[6]=l,t[7]=r,t[8]=o):o=t[8],o}const Ae=3e4;function Oe({onBack:a,onCliAvailable:t,isFromRecovery:s=!1,onSwitchToRemote:i}){const{t:n}=Q(),[l,u]=c.useState(!1),[r,o]=c.useState(!1),[w,R]=c.useState(!1),[j,T]=c.useState(!1),[I,x]=c.useState(!1),[m,k]=c.useState(null),[C,b]=c.useState(""),[N,K]=c.useState("unknown");c.useEffect(()=>{const d=setTimeout(()=>o(!0),Ae);return()=>clearTimeout(d)},[]),c.useEffect(()=>{R(B())},[]),c.useEffect(()=>{if(typeof navigator>"u"){K("unknown");return}const d=navigator.userAgent||"";if(/Windows/i.test(d)){K("windows");return}if(/Macintosh|Mac OS X/i.test(d)){K("macos");return}if(/Linux/i.test(d)){K("linux");return}K("unknown")},[]),c.useEffect(()=>{let d=!1;return(async()=>{try{const _=await ue();if(!_||d)return;const $=_.opencodeBinary??"";$&&b($)}catch{}})(),()=>{d=!0}},[]);const y=c.useCallback(async d=>{d.target.closest("button, a, input, select, textarea, code")||d.button===0&&w&&await pe()},[w]),f=c.useCallback(async()=>{try{const d=await Y("/health");if(!d.ok)return!1;const _=await d.json();return _.openCodeRunning===!0||_.isOpenCodeReady===!0}catch{return!1}},[]),g=c.useCallback(async()=>{if(!(typeof window>"u")&&w)try{const d=await he();d.success&&d.path&&d.path.trim().length>0&&b(d.path.trim())}catch{}},[w]),L=c.useCallback(async()=>{T(!0);try{if(await xe({opencodeBinary:C.trim()}),w){await H();return}await Y("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>T(!1),1e3)}},[w,C]),S=c.useCallback(async()=>{const d=await me(N==="windows"?be:Ke);d.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error("Failed to copy:",d.error)},[N]),A=c.useCallback(async()=>{x(!0),k(null);try{await f()?t?.():k(n("onboarding.localSetup.errors.cliNotReady"))}catch(d){k(d instanceof Error?d.message:n("onboarding.localSetup.errors.detectionFailed"))}finally{x(!1)}},[f,t,n]),E=De,M=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.opencode/bin/opencode":"/Users/you/.opencode/bin/opencode";return e.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:y,children:[e.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[e.jsx("div",{className:"flex items-center",children:e.jsx(U,{variant:"ghost",onClick:a,className:"p-0 text-muted-foreground hover:text-foreground",children:n("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:n("onboarding.localSetup.title")}),e.jsx("p",{className:"text-muted-foreground",children:n("onboarding.localSetup.description")})]}),N==="windows"&&e.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[e.jsx("div",{className:"text-sm text-foreground",children:n("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:n("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:n("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("div",{className:"flex justify-center",children:e.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:l?e.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(O,{name:"check",className:"h-4 w-4"}),n("onboarding.common.status.copiedToClipboard")]}):e.jsx(_e,{windows:N==="windows",onCopy:S,copyTitle:n("onboarding.common.copyToClipboard")})})}),e.jsxs("a",{href:E,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:[n(N==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(O,{name:"external-link",className:"h-3 w-3"})]}),m&&e.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:m}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{type:"button",onClick:A,disabled:I,className:"w-full max-w-xs",size:"lg",children:n(I?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("onboarding.localSetup.helper.checkAndContinue")})]}),e.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:n("onboarding.localSetup.field.alreadyInstalled")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(V,{value:C,onChange:d=>b(d.target.value),placeholder:M,disabled:j,className:"flex-1 font-mono text-xs"}),e.jsx(U,{type:"button",variant:"secondary",onClick:g,disabled:j||!w,children:n("onboarding.localSetup.actions.browse")}),e.jsx(U,{type:"button",onClick:L,disabled:j,children:n("onboarding.localSetup.actions.apply")})]}),e.jsx("div",{className:"text-xs text-muted-foreground/70",children:n("onboarding.localSetup.helper.saveAndReload")})]})}),s&&i&&e.jsxs("div",{className:"text-center pt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:n("onboarding.localSetup.remotePreference")}),e.jsx(U,{variant:"link",onClick:i,children:n("onboarding.localSetup.actions.connectRemoteServer")})]})]}),r&&e.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:N==="windows"?e.jsx(e.Fragment,{children:e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.windows.hintDetectionFailed")})}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.ensurePath")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.setEnv")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.missingRuntime")})]})})]})}function se(a,t){if(a?.trim())return re(a.trim());if(t)return re(t)}function Ee(a,t,s){switch(a){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 i=se(t,s);return{title:"Remote Server Unreachable",description:`Could not connect to "${i||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:i?{host:i}: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 i=se(t,s);return{title:"Incompatible Server",description:`The server at "${i||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:i?{host:i}: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 i=se(t,s);return{title:"Server Update Required",description:`The OpenChamber server at "${i||"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:i?{host:i}: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 i=a;throw new Error(`Unknown recovery variant: ${i}`)}}}function Fe(a){switch(a){case"local":return e.jsx(O,{name:"macbook",className:"h-8 w-8"});case"remote":return e.jsx(O,{name:"server",className:"h-8 w-8"})}}function Me({variant:a,hostLabel:t,hostUrl:s,onRetry:i,onUseLocal:n,onUseRemote:l,isRetrying:u=!1}){const{t:r}=Q(),o=Ee(a,t,s),w=o.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",R=c.useMemo(()=>{if(o.descriptionParams?.host)return o.descriptionParams;if(a==="remote-unreachable")return{host:r("onboarding.desktopRecovery.placeholders.remoteServer")};if(a==="remote-wrong-service"||a==="remote-incompatible")return{host:r("onboarding.desktopRecovery.placeholders.unknownServer")}},[o.descriptionParams,r,a]);return e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[e.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:e.jsx("div",{style:{color:"var(--status-warning)"},children:Fe(o.iconKey)})}),e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:r(o.titleKey)}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:r(o.descriptionKey,R)})]}),s&&(a==="remote-unreachable"||a==="remote-wrong-service"||a==="remote-incompatible")&&e.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:r("onboarding.remoteConnection.field.serverAddress")}),e.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:re(s)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[o.showRetry&&i&&e.jsxs(U,{onClick:i,disabled:u,className:"w-full",children:[e.jsx(O,{name:"refresh",className:ne("h-4 w-4",u&&"animate-spin")}),r(u?"onboarding.desktopRecovery.actions.retrying":w)]}),e.jsxs("div",{className:"flex gap-2",children:[o.showUseLocal&&n&&e.jsxs(U,{variant:"outline",onClick:n,disabled:u,className:"flex-1",children:[e.jsx(O,{name:"macbook",className:"h-4 w-4"}),r(o.useLocalLabelKey)]}),o.showUseRemote&&l&&e.jsxs(U,{variant:"outline",onClick:l,disabled:u,className:"flex-1",children:[e.jsx(O,{name:"server",className:"h-4 w-4"}),r(o.useRemoteLabelKey)]})]})]})]})})}function de(a,t){if(t==="use-remote")return{kind:"remote-form"};switch(a){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 s=a;throw new Error(`Unhandled RecoveryVariant: ${s}`)}}}function He(a){const t=G.c(29),{variant:s,hostUrl:i,hostLabel:n,onRetry:l,onChooseRemote:u,showRemoteForm:r,onCloseRemoteForm:o,onSwitchToLocalFromRemote:w,onEnterLocalSetup:R,isRetrying:j,localAvailable:T}=a,I=r===void 0?!1:r,x=j===void 0?!1:j,m=T===void 0?!0:T,k=Pe;let C;t[0]!==l?(C=async()=>{if(B()){await H();return}await Y("/api/config/reload",{method:"POST"}),l?.()},t[0]=l,t[1]=C):C=t[1];const b=C;let N;t[2]!==R||t[3]!==s?(N=async()=>{if(de(s,"use-local").kind==="local-setup"){R?.();return}if(await k("local"),B()){await H();return}window.location.reload()},t[2]=R,t[3]=s,t[4]=N):N=t[4];const K=N;let y;t[5]!==u||t[6]!==s?(y=()=>{de(s,"use-remote").kind==="remote-form"&&u?.()},t[5]=u,t[6]=s,t[7]=y):y=t[7];const f=y;if(I){const S=s==="remote-wrong-service"?"":i||"",A=s==="remote-wrong-service"?"":n||"";let E;t[8]!==u||t[9]!==o?(E=o||(()=>u?.()),t[8]=u,t[9]=o,t[10]=E):E=t[10];const M=!m;let d;t[11]!==m||t[12]!==R||t[13]!==w?(d=m?w||(()=>{k("local").then(()=>{B()?H():R?.()})}):void 0,t[11]=m,t[12]=R,t[13]=w,t[14]=d):d=t[14];let _;return t[15]!==A||t[16]!==S||t[17]!==E||t[18]!==M||t[19]!==d?(_=e.jsx(fe,{onBack:E,initialUrl:S,initialLabel:A,isRecoveryMode:!0,showInstancePicker:M,onSwitchToLocal:d}),t[15]=A,t[16]=S,t[17]=E,t[18]=M,t[19]=d,t[20]=_):_=t[20],_}const g=m?K:void 0;let L;return t[21]!==b||t[22]!==f||t[23]!==n||t[24]!==i||t[25]!==x||t[26]!==g||t[27]!==s?(L=e.jsx(Me,{variant:s,hostLabel:n,hostUrl:i,onRetry:b,onUseLocal:g,onUseRemote:f,isRetrying:x}),t[21]=b,t[22]=f,t[23]=n,t[24]=i,t[25]=x,t[26]=g,t[27]=s,t[28]=L):L=t[28],L}async function Pe(a){if(!B())return;const t=await W();await z({...t,...a==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function fo(a){const t=G.c(29),{onBack:s,onCliAvailable:i,mode:n,recoveryVariant:l,recoveryHostUrl:u,recoveryHostLabel:r,onEnterLocalSetup:o,localAvailable:w}=a,R=n===void 0?"first-launch":n,j=l===void 0?"missing-default-host":l,T=w===void 0?!0:w,[I,x]=c.useState(!1),[m,k]=c.useState(!1);let C;t[0]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{k(!1),x(!1)},t[0]=C):C=t[0];let b;t[1]!==R||t[2]!==r||t[3]!==u||t[4]!==j?(b=[R,j,u,r],t[1]=R,t[2]=r,t[3]=u,t[4]=j,t[5]=b):b=t[5],c.useEffect(C,b);const N=m?"local-setup":R;if(N==="recovery"){let y;t[6]===Symbol.for("react.memo_cache_sentinel")?(y=()=>x(!0),t[6]=y):y=t[6];let f,g;t[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!1),g=()=>{x(!1),k(!0)},t[7]=f,t[8]=g):(f=t[7],g=t[8]);let L;t[9]!==o?(L=()=>{k(!0),o?.()},t[9]=o,t[10]=L):L=t[10];let S;return t[11]!==T||t[12]!==r||t[13]!==u||t[14]!==j||t[15]!==I||t[16]!==L?(S=e.jsx(He,{variant:j,hostUrl:u,hostLabel:r,onChooseRemote:y,showRemoteForm:I,onCloseRemoteForm:f,onSwitchToLocalFromRemote:g,onEnterLocalSetup:L,localAvailable:T}),t[11]=T,t[12]=r,t[13]=u,t[14]=j,t[15]=I,t[16]=L,t[17]=S):S=t[17],S}if(N==="local-setup"){let y;t[18]!==s||t[19]!==m?(y=()=>{m?k(!1):s?.()},t[18]=s,t[19]=m,t[20]=y):y=t[20];let f;t[21]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!0),t[21]=f):f=t[21];let g;return t[22]!==i||t[23]!==m||t[24]!==y?(g=e.jsx(Oe,{onBack:y,onCliAvailable:i,isFromRecovery:m,onSwitchToRemote:f}),t[22]=i,t[23]=m,t[24]=y,t[25]=g):g=t[25],g}let K;return t[26]!==T||t[27]!==i?(K=e.jsx(Te,{onCliAvailable:i,localAvailable:T}),t[26]=T,t[27]=i,t[28]=K):K=t[28],K}export{fo as OnboardingScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{kf as S,kk as j,ks as y}from"./useAppFontEffects-
|
|
1
|
+
import{kf as S,kk as j,ks as y}from"./useAppFontEffects-Cfuya0Zd.js";import{k as D,a as C}from"./web-components-BWh2SieS.js";import{M as P,G as O,u as L,W as A,a as M,b as R,n as F,t as H}from"./Virtualizer-CZlLSacm.js";import{j as d,r as w}from"./vendor-react-BUCujlKS.js";import{V as _,F as N}from"./VirtualizedFileDiff-DOhvVx32.js";function T({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function V(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:z(n,e.startContentIndex)}}function z(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const o=e.hunkContent[l];n+=o.type==="context"?o.lines:o.deletions+o.additions}return n}function U(e){const t=S(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:o,renderHeaderMetadata:x,renderAnnotation:f,renderGutterUtility:u,renderMergeConflictUtility:s,lineAnnotations:a,getHoveredLine:p,getInstance:m}){const g=n?.(e),c=l?.(e),i=o?.(e),v=x?.(e);return d.jsxs(d.Fragment,{children:[g!=null?d.jsx("div",{slot:j,children:g}):d.jsxs(d.Fragment,{children:[c!=null&&d.jsx("div",{slot:"header-prefix",children:c}),i!=null&&d.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&d.jsx("div",{slot:"header-metadata",children:v})]}),f!=null&&a?.map((r,h)=>d.jsx("div",{slot:D(r),children:f(r)},h)),t!=null&&s!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return d.jsx("div",{slot:h,style:P,children:s(r,m)},h)}),u!=null&&d.jsx("div",{slot:"gutter-utility-slot",style:O,children:u(p)})]})}function b(e,t){const n=V(e,t);return n!=null?T({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const k=typeof window>"u"?w.useEffect:w.useLayoutEffect;function G({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:o,metrics:x,hasGutterRenderUtility:f,hasCustomHeader:u,disableWorkerPool:s,contentEditable:a}){const p=L(),m=l!==void 0,g=w.useContext(A),c=M(),i=w.useRef(null),v=R(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");p!=null?i.current=new _(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),p,x,s?void 0:g,!0):i.current=new N(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),s?void 0:g,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:o})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return k(()=>{const{current:r}=i;if(r==null)return;const h=E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),I=!C(r.options,h);r.setOptions(h),r.render({forceRender:I,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),k(()=>{if(a&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[a,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function E({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:o,hasGutterRenderUtility:x}){const f=n&&o,u=t||x||l;if(!u&&!f)return e;let s={...e};return u&&(s={...s,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),f&&(s={...s,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),s}function X({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:o,className:x,style:f,prerenderedHTML:u,renderAnnotation:s,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=q(e),{ref:h,getHoveredLine:I}=G({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:o,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:a!=null,disableWorkerPool:i,contentEditable:v});return d.jsx(y,{ref:h,className:x,style:f,children:H($({fileDiff:r,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderAnnotation:s,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>U(e),[e])}export{X as P};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as $,j as F,c as we,r as l}from"./vendor-react-BUCujlKS.js";import{a as nt}from"./web-components-
|
|
1
|
+
import{R as $,j as F,c as we,r as l}from"./vendor-react-BUCujlKS.js";import{a as nt}from"./web-components-BWh2SieS.js";import{f as We}from"./computeVirtualFileMetrics-CcxmuPAX.js";import{V as rt,F as it}from"./VirtualizedFileDiff-DOhvVx32.js";import{V as ot}from"./Virtualizer-D_a8gKmg.js";import{eH as st,eI as je,bj as at,c8 as lt,h as Be}from"./useAppFontEffects-Cfuya0Zd.js";import{I as _e,a as ct,u as dt}from"./useInlineCommentController-GbLdwSYb.js";import"./index-Di6zUe5h.js";import{ay as ut}from"./runtimeEndpointReset-BsoTecOZ.js";import{ensurePierreThemeRegistered as Ve,getResolvedShikiTheme as Ue}from"./appThemeRegistry-CF0I57r1.js";const xe=n=>{if(n.type==="new"){const r=Math.min(n.selection.start,n.selection.end),i=Math.max(n.selection.start,n.selection.end);return`new-comment-${n.selection.side??"additions"}-${r}-${i}`}return`draft-${n.draft.id}`},ft=n=>{const{drafts:r,editingDraftId:i,selection:s}=n,c=[];for(const m of r){if(!Number.isFinite(m.endLine))continue;const x=Math.max(1,Math.floor(m.endLine)),M=m.side==="original"?"deletions":"additions";c.push({lineNumber:x,side:M,metadata:{type:m.id===i?"edit":"saved",draft:m}})}return s&&!i&&c.push({lineNumber:Math.max(s.start,s.end),side:s.side??"additions",metadata:{type:"new",selection:s}}),c};function ht(n){const r=n.trim();if(!r)return null;if(/^-?\d+(\.\d+)?$/.test(r)){const i=Number.parseFloat(r);return Number.isFinite(i)?i:null}if(r.endsWith("px")){const i=Number.parseFloat(r.slice(0,-2));return Number.isFinite(i)?i:null}return null}function Ke(n){if(!(!n||n<=0))return Math.max(200,Math.floor(n))}function pt(n){const{diffRootRef:r,drafts:i,selection:s,editingDraftId:c,commentText:m,onTextChange:x,fileLabel:M,onSave:d,onCancel:R,onEdit:z,onDelete:N}=n,[ue,W]=$.useState(0),[O,U]=$.useState(null),D=$.useMemo(()=>!s||c?null:xe({type:"new",selection:s}),[c,s]),Z=$.useMemo(()=>{const h=i.map(T=>xe({type:T.id===c?"edit":"saved",draft:T}));return D&&h.push(D),h},[i,c,D]),A=$.useCallback(h=>{const T=r.current;if(!T)return null;const E=T.querySelector("diffs-container");if(!(E instanceof HTMLElement))return null;const w=E.querySelector(`[data-annotation-id="${h}"]`);if(w instanceof HTMLElement)return w;const C=E.shadowRoot;return C?C.querySelector(`[data-annotation-id="${h}"]`):null},[r]);$.useEffect(()=>{if(Z.length===0)return;let h=!1,T=0;const E=12,w=()=>{h||Z.every(q=>!!A(q))||T>=E||(T+=1,requestAnimationFrame(()=>{h||(W(q=>q+1),w())}))};return w(),()=>{h=!0}},[Z,A]),$.useEffect(()=>{const h=r.current;if(!h)return;const T=()=>{const w=getComputedStyle(h),C=ht(w.getPropertyValue("--oc-context-panel-width")),q=h.getBoundingClientRect(),I=C??q.width;U(I>0?I:null)};T();const E=new ResizeObserver(()=>{T()});return E.observe(h),window.addEventListener("resize",T),()=>{E.disconnect(),window.removeEventListener("resize",T)}},[r]);const ee=$.useCallback(h=>{const E=r.current?.getBoundingClientRect(),w=h.closest("[data-annotation-content]"),C=w instanceof HTMLElement?w.getBoundingClientRect():h.getBoundingClientRect(),q=[C.width];E&&q.push(E.right-C.left);const I=q.filter(K=>Number.isFinite(K)&&K>0);return I.length>0?Ke(Math.min(...I)):Ke(O)},[r,O]);return F.jsxs(F.Fragment,{children:[i.map(h=>{const T=xe({type:h.id===c?"edit":"saved",draft:h}),E=A(T);if(!E)return null;const w=ee(E);return h.id===c?we.createPortal(F.jsx(_e,{initialText:m,onTextChange:x,fileLabel:M,lineRange:{start:h.startLine,end:h.endLine,side:h.side==="original"?"deletions":"additions"},isEditing:!0,onSave:d,onCancel:R,maxWidth:w}),E,`draft-edit-${h.id}`):we.createPortal(F.jsx(ct,{draft:h,onEdit:()=>z(h),onDelete:()=>N(h),maxWidth:w}),E,`draft-card-${h.id}`)}),s&&!c&&D&&(()=>{const h=A(D);if(!h)return null;const T=ee(h);return we.createPortal(F.jsx(_e,{initialText:m,onTextChange:x,fileLabel:M,lineRange:s,isEditing:!1,onSave:d,onCancel:R,maxWidth:T}),h,D)})()]})}const Ge=[],mt=`
|
|
2
2
|
[data-gutter-buffer="annotation"] { min-height: 0; }
|
|
3
3
|
[data-code] { min-height: 2.5rem; align-content: start; }
|
|
4
4
|
`,Ye=5e5,gt=`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as t,j as n}from"./vendor-react-BUCujlKS.js";import{n as jt,u as Qe,a as he,y as qe,h as Xe,z as bt}from"./index-Di6zUe5h.js";import{c as xt,s as Ct,P as Rt,C as Mt}from"./shikiHighlight-
|
|
1
|
+
import{R as t,j as n}from"./vendor-react-BUCujlKS.js";import{n as jt,u as Qe,a as he,y as qe,h as Xe,z as bt}from"./index-Di6zUe5h.js";import{c as xt,s as Ct,P as Rt,C as Mt}from"./shikiHighlight-U-ER5VqY.js";import{f as Tt,z as G,cC as Pt,aJ as kt,b as Ze,K as Et,ai as Nt,_ as It,bj as Dt,T as Vt,f$ as Ft,a3 as Lt,iD as At,l as et,f_ as Ot,ay as tt,hE as zt,fY as Kt,dA as nt,g1 as Wt,g2 as _t,m as Bt,iE as $t,as as rt,ae as ge,af as ve,at as st,B as ee,I as L,ag as we,av as it,bh as te,g as Gt,c8 as Jt,aB as Ut,cp as Ht,iF as Yt}from"./useAppFontEffects-Cfuya0Zd.js";import{u as Qt,n as qt}from"./useInlineCommentController-GbLdwSYb.js";import{b as Xt}from"./CodeMirrorCommentWidgets-C55OCQB7.js";import{getResolvedShikiTheme as Zt}from"./appThemeRegistry-CF0I57r1.js";import{E as en}from"./vendor-codemirror-view-CiLROUVV.js";import{ax as tn}from"./runtimeEndpointReset-BsoTecOZ.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-BSoePkpP.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-DSZl7jSi.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CcqLCIWH.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./textMateThemeFromAppTheme-CFZUMoyT.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./GuestAttachDialog-CdC8RfDh.js";import"./PluginPane-DJgKVT9D.js";const nn=()=>{const l=new Map,d=new Map;return{schedule:(c,s,m)=>{if(s<=(d.get(c)??Number.NEGATIVE_INFINITY))return l.get(c)??Promise.resolve();d.set(c,s);const h=(l.get(c)??Promise.resolve()).then(m,m);return l.set(c,h.catch(()=>{d.get(c)===s&&d.delete(c)})),h},pendingFor:async c=>{await l.get(c)},reset:c=>{d.delete(c)}}},y=l=>{if(!l)return"";const d=l.replace(/\\/g,"/");return d==="/"?"/":d.replace(/\/+$/,"")},rn=(l,d)=>{const c=y(d.currentDirectory),s=y(d.homeDirectory),m=y(l);return c&&m.startsWith(c+"/")?m.slice(c.length+1):s&&m===s?"~":s&&m.startsWith(s+"/")?`~${m.slice(s.length)}`:m},sn=(l,d,c)=>{const s=y(l.trim());if(!s)return null;const m=c?d.find(h=>h.id===c)??null:null;if(m?.path){const h=y(m.path);if(s===h||s.startsWith(`${h}/`))return{id:m.id,path:m.path}}const R=d.filter(h=>{const M=y(h.path);return s===M||s.startsWith(`${M}/`)}).sort((h,M)=>y(M.path).length-y(h.path).length)[0];return R?{id:R.id,path:R.path}:null},on=l=>bt(()=>l()),as=({targetPath:l=null,savedProjectPlan:d=null,onNavigatedToChat:c})=>{const{t:s}=Tt(),m=G(e=>e.currentSessionId),R=G(e=>e.createSession),h=G(e=>e.initializeNewOpenChamberSession),M=G(e=>e.sendMessage),Se=G(e=>e.setCurrentSession),ye=Pt(),J=jt(e=>e.homeDirectory),je=kt(e=>e.planModeEnabled),be=Ze(e=>e.projects),xe=Ze(e=>e.activeProjectId),Ce=Et(e=>e.directories),Re=Nt()??"",Me=Qe(e=>e.setSessionSwitcherOpen),A=It(),O=t.useSyncExternalStore(on,he,he),{isMobile:Te}=Dt(),{currentTheme:U}=Vt(),ne=t.useMemo(()=>m?ye.find(e=>e.id===m)??null:null,[m,ye]),N=t.useMemo(()=>{const e=typeof ne?.directory=="string"?ne.directory:"";return y(e||"")},[ne?.directory]),Pe=t.useMemo(()=>y(Re||N),[Re,N]),z=t.useMemo(()=>sn(Pe,be,xe),[xe,Pe,be]),re=d?.projectRef.id??null,se=d?.projectRef.path??null,g=t.useMemo(()=>re&&se?{id:re,path:se}:null,[re,se]),b=d?.planId??null,K=g&&b?JSON.stringify(["saved-plan",O,Ft(g),b]):null,I=g?.id===Lt,H=t.useMemo(()=>{const e=g??z;return e?Ce.get(e.path)?.isGitRepo===!0:!1},[z,Ce,g]),[T,D]=t.useState(null),[ke,Ee]=t.useState(!1),[u,W]=t.useState(null),[ie,oe]=t.useState(null),ot=!!u||!!ie,ae=t.useMemo(()=>!u||!N||!J?u:rn(u,{currentDirectory:N,homeDirectory:J}),[u,N,J]),[f,P]=t.useState(""),{isPlaying:Y,play:at,stop:lt}=At(),ct=et(e=>e.showMessageTTSButtons),[Ne,le]=t.useState(null),[Ie,ce]=t.useState(null),ue=t.useMemo(()=>ae&&ae.split("/").pop()||s("planView.file.defaultName"),[ae,s]),de=t.useMemo(()=>f.trim()?Ot(f,s("planView.title.default")).title:s("planView.title.default"),[f,s]),Q=t.useMemo(()=>de.trim()||s("planView.title.default"),[de,s]),[ut,_]=t.useState(!1),[dt,De]=t.useState(!1),[q,Ve]=t.useState("edit"),B=t.useRef(null),[a,w]=t.useState(null),Fe=t.useRef(null),mt=t.useRef(null),Le="openchamber:plan:md-viewer-mode";t.useEffect(()=>{try{const e=localStorage.getItem(Le);if(!e)return;const i=JSON.parse(e);(i==="preview"||i==="edit")&&Ve(i)}catch{}},[]);const pt=t.useCallback(e=>{Ve(e);try{localStorage.setItem(Le,JSON.stringify(e))}catch{}},[]),V=t.useRef(!1),x=t.useRef(null),[Ae,F]=t.useState(!1);t.useEffect(()=>{const e=()=>{V.current=!1,x.current=null,F(!1)};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[]);const ft=t.useCallback((e,i)=>{const o=e.split(`
|
|
2
2
|
`),r=Math.max(1,i.start),p=Math.min(o.length,i.end);return r>p?"":o.slice(r-1,p).join(`
|
|
3
3
|
`)},[]),ht=Qt({source:"plan",fileLabel:ue,language:u&&tt(u)||"markdown",getCodeForRange:e=>ft(f,qt(e)),toStoreRange:e=>({startLine:e.start,endLine:e.end}),fromDraftRange:e=>({start:e.startLine,end:e.endLine})}),{drafts:Oe,commentText:X,setCommentText:ze,editingDraftId:me,setSelection:Ke,saveComment:We,cancel:$,reset:_e,startEdit:Be,deleteDraft:$e}=ht;t.useEffect(()=>{w(null),_e()},[f,_e]),t.useEffect(()=>{Ke(a)},[a,Ke]);const Ge=t.useCallback(()=>{w(null),$()},[$]),Je=t.useCallback((e,i)=>{i&&w(i),We(e,i??a??void 0),w(null)},[a,We]);t.useEffect(()=>{if(!a)return;const e=o=>{const r=o.target;r.closest('[data-comment-card="true"]')||r.closest('[data-comment-input="true"]')||r.closest(".oc-block-widget")||r.closest(".cm-gutterElement")||r.closest("[data-sonner-toast]")||r.closest("[data-sonner-toaster]")||X.trim()||(w(null),$())},i=window.setTimeout(()=>{document.addEventListener("click",e)},100);return()=>{window.clearTimeout(i),document.removeEventListener("click",e)}},[$,X,me,Te,a]);const pe=Qe(e=>e.editorFontSize),gt=t.useMemo(()=>{const e=u?tt(u):null,i=!!e&&e!=="markdown",o=[xt(U,i?{syntaxColors:!1,fontSize:pe}:{fontSize:pe})],r=zt(u||"plan.md");return r&&o.push(r),i&&e&&o.push(Ct({language:e,themeName:U.metadata.id,theme:Zt(U)})),o.push(en.lineWrapping),o},[U,u,pe]),j=t.useRef({key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""}),k=t.useState(nn)[0],Ue=t.useCallback(async(e,i)=>{if("filePath"in e){const r=A.files??qe()?.files;if(r?.writeFile){if(!(await r.writeFile(e.filePath,i))?.success)throw new Error("Plan file write failed");return}const p=await Xe("/api/fs/write",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e.filePath,content:i})});if(!p.ok)throw new Error(`Failed to write plan file (${p.status})`);return}if(!await Kt.getState().savePlan(e.projectRef,e.planId,i))throw new Error("Plan save rejected: the plan no longer exists")},[A.files]),He=t.useRef(Ue);He.current=Ue;const E=t.useCallback(()=>{const e=j.current;if(!e.key||!e.target||e.editRevision<=e.savedRevision)return;const i={key:e.key,target:e.target,content:e.content,revision:e.editRevision,runtimeKey:e.runtimeKey,write:He.current};k.schedule(i.key,i.revision,async()=>{if(he()!==i.runtimeKey)return;await i.write(i.target,i.content);const o=j.current;o.key===i.key&&(o.savedRevision=Math.max(o.savedRevision,i.revision),le(null))}).catch(o=>{j.current.key===i.key&&le(o instanceof Error?o.message:"Plan save failed")})},[k]);t.useEffect(()=>{if(!je&&!l&&!b){E(),j.current={key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""},W(null),oe(null),P(""),_(!1);return}let e=!1;const i=async r=>{if(A.files?.readFile)return(await A.files.readFile(r))?.content??"";const p=qe()?.files;if(p?.readFile)return(await p.readFile(r,{optional:!0}))?.content??"";const v=await Xe(`/api/fs/read?path=${encodeURIComponent(r)}&optional=true`,{cache:"no-store"});if(!v.ok)throw new Error(`Failed to read plan file (${v.status})`);return v.text()};return(async()=>{if(E(),j.current={key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""},W(null),oe(null),P(""),le(null),ce(null),b&&g&&K){if(await k.pendingFor(K),e)return;k.reset(K),_(!0);try{const r=await Yt(g,b);if(e)return;if(!r){ce("Plan not found");return}j.current={key:K,target:{projectRef:g,planId:b},content:r.raw,editRevision:0,savedRevision:0,runtimeKey:O},P(r.raw),oe(b)}catch(r){if(e)return;ce(r instanceof Error?r.message:"Plan load failed")}finally{e||_(!1)}return}if(l){const r=JSON.stringify(["plan-file",O,l]);if(await k.pendingFor(r),e)return;k.reset(r),_(!0);try{const p=await i(l);if(e)return;j.current={key:r,target:{filePath:l},content:p,editRevision:0,savedRevision:0,runtimeKey:O},W(l),P(p)}catch{if(e)return;W(null),P("")}finally{e||_(!1)}return}W(null),P("")})(),()=>{e=!0}},[O,J,je,A.files,b,K,g,k,E,N,l]);const vt=t.useCallback(e=>{j.current.content=e,j.current.editRevision+=1,P(e)},[]);t.useEffect(()=>{if(!u&&!ie)return;const e=window.setTimeout(()=>{E()},350);return()=>{window.clearTimeout(e)}},[f,ie,u,E]),t.useEffect(()=>()=>{E()},[E]),t.useEffect(()=>()=>{B.current!==null&&window.clearTimeout(B.current)},[]);const Ye=t.useCallback(()=>{Me(!1),c?.()},[c,Me]),wt=t.useCallback(async e=>{const i=g??z;if(!i||!T||I)return;const o=await nt(T.action==="improve"?"plan.improve.visible":"plan.implement.visible",{plan_title:Q}),r=await nt(T.action==="improve"?"plan.improve.instructions":"plan.implement.instructions",{plan_title:Q,plan_path:u??""}),v=[{synthetic:!0,text:u?r:[r,"","The plan is not stored as a file in the repository and has no file path. Its full current contents follow below this note and are the source of truth for the plan. Where the instructions above refer to the plan file, treat the plan as stored in OpenChamber project knowledge (it is edited through the OpenChamber UI): propose plan revisions as plan text in the chat rather than editing a file.","",f].join(`
|
|
4
4
|
`)}];Ee(!0);try{Ye();let S=null,fe=i.path;if(T.target==="worktree"){if(!H)return;const C=await Wt(i.path,_t());if(!C?.id)return;S=C.id,fe=C.path}else{const C=await R(void 0,i.path,void 0,{model:{providerID:e.providerID,id:e.modelID,variant:e.variant||void 0},agent:e.agent.trim()||void 0});if(!C?.id)return;S=C.id,fe=C.directory??i.path,h(C.id,et.getState().agents??[])}if(!S)return;const Z=Bt.getState();Z.saveSessionModelSelection(S,e.providerID,e.modelID),e.agent.trim()&&(Z.saveSessionAgentSelection(S,e.agent),Z.saveAgentModelForSession(S,e.agent,e.providerID,e.modelID),Z.saveAgentModelVariantForSession(S,e.agent,e.providerID,e.modelID,e.variant||void 0)),Se(S,fe);const yt=e.runAsGoal===!0?[`Implement the plan "${Q}" end-to-end${u?` (plan file: ${u})`:" (the full plan follows)"}.`,u?"Re-read that file for full details — it is the source of truth.":"The full plan follows in this message and is the source of truth.","",f].join(`
|