@vantran-se/openchamber-web 2.4.0 → 2.4.2
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/dist/assets/{AboutDialog-Dh2Z6Rpo.js → AboutDialog-Dz_8z7Rq.js} +1 -1
- package/dist/assets/{ArchiveView-31PVMzC2.js → ArchiveView-BoMjLD0N.js} +1 -1
- package/dist/assets/{ChangedPathLabel-CbXts83B.js → ChangedPathLabel-BirEUxH2.js} +1 -1
- package/dist/assets/{CommandPalette-DzOIUvyX.js → CommandPalette-DkLX-AKB.js} +1 -1
- package/dist/assets/{DiffView-C6UN20mH.js → DiffView-DwyXDHsF.js} +1 -1
- package/dist/assets/{FilesView-V9SCRZ9-.js → FilesView-BFi9HBg1.js} +1 -1
- package/dist/assets/{GitView-RJHLEROE.js → GitView-BzWRNg_F.js} +1 -1
- package/dist/assets/{GuestSurfacePane-C9dmI3Di.js → GuestSurfacePane-zDcKyz78.js} +1 -1
- package/dist/assets/{HelpDialog-DyGX9_8h.js → HelpDialog-DZVlv3x2.js} +1 -1
- package/dist/assets/{InProgressOperationBanner-B3oEOw3O.js → InProgressOperationBanner-BiEntIfh.js} +1 -1
- package/dist/assets/{IntegrationsCatalogView-CwBk0nb-.js → IntegrationsCatalogView-CCHFMcZP.js} +1 -1
- package/dist/assets/{JsonTreeView-BnV3bUfi.js → JsonTreeView-BwELoub1.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DwFPVpAe.js → MarkdownRendererImpl-DxBYkSKd.js} +1 -1
- package/dist/assets/{MemoryDebugPanel-DwNkGEQI.js → MemoryDebugPanel-C9zpPXVo.js} +1 -1
- package/dist/assets/{OnboardingScreen-CLGQ5tGv.js → OnboardingScreen-Cnzzs_TQ.js} +1 -1
- package/dist/assets/{OpenCodeStatusDialog-D7ZnJOuR.js → OpenCodeStatusDialog-DizE9xAy.js} +1 -1
- package/dist/assets/{PatchDiff-BriSysUP.js → PatchDiff-Cz_UxB-k.js} +1 -1
- package/dist/assets/{PierreDiffViewer-ToKfUZsI.js → PierreDiffViewer-BT3MrXwN.js} +1 -1
- package/dist/assets/{PlanView-YOnwcP8k.js → PlanView-B-SCCd7M.js} +1 -1
- package/dist/assets/{ProjectActionsDialog-C3u320eT.js → ProjectActionsDialog-4OSNuzpG.js} +1 -1
- package/dist/assets/{PullRequestComparisonSelector-Cvng5foj.js → PullRequestComparisonSelector-lp98DrYm.js} +1 -1
- package/dist/assets/{RunOverview-CX4EWbX4.js → RunOverview-DJhjR9uR.js} +1 -1
- package/dist/assets/{ScheduledTasksDialog-Cg0llpjw.js → ScheduledTasksDialog-Dwil7zsx.js} +1 -1
- package/dist/assets/{SettingsView-C5MS7v4D.js → SettingsView-DVcV2Rk9.js} +1 -1
- package/dist/assets/{SettingsWindow-ZCLlBZBD.js → SettingsWindow-DbbAS4Se.js} +1 -1
- package/dist/assets/{SourceBoardView-DeQ_gjii.js → SourceBoardView-BVcmYpvE.js} +1 -1
- package/dist/assets/{SpaceAccessDialog-MzV-zdo9.js → SpaceAccessDialog-DxjFUcHZ.js} +1 -1
- package/dist/assets/{SpaceApplyDialog-DDxyMT0_.js → SpaceApplyDialog-Dbrbh-j4.js} +1 -1
- package/dist/assets/{SpaceRow-sK_fpiHu.js → SpaceRow-Cwam4mHh.js} +1 -1
- package/dist/assets/{SpaceSetupOutput-DXkmiL2Y.js → SpaceSetupOutput-B_w02jDi.js} +1 -1
- package/dist/assets/{SpacesView-DZNEvbJ7.js → SpacesView-CGrFWnO-.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-E0GcoYiO.js → SubmoduleDiffSummary-DFL-m_eu.js} +1 -1
- package/dist/assets/{ToolOutputDialog-CKl9iGaM.js → ToolOutputDialog-Co0VXa0y.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-CRANc7sQ.js → ToolPartDiffPreview-CBSzwkat.js} +1 -1
- package/dist/assets/{UsageStatsView-np-Qgyn0.js → UsageStatsView-BjtTNSt8.js} +1 -1
- package/dist/assets/{Virtualizer-CgLU97RO.js → Virtualizer-Cmng0Q1E.js} +1 -1
- package/dist/assets/{WalkthroughView-oJlQ42QA.js → WalkthroughView-C7AkVuHQ.js} +1 -1
- package/dist/assets/{WorktreesView-XC8e1Gxk.js → WorktreesView-CYU2KJ6E.js} +1 -1
- package/dist/assets/{appThemeRegistry-DsBAd3cG.js → appThemeRegistry-CDGE1wtP.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-tFBUWYu1.js → computeVirtualFileMetrics-BgqasG86.js} +1 -1
- package/dist/assets/{decorate-N1FIdwTF.js → decorate-CpxLqoVw.js} +1 -1
- package/dist/assets/{flexokiTheme-qbTuJgIP.js → flexokiTheme-BG4cSAMb.js} +1 -1
- package/dist/assets/{index-DppcIt7q.js → index-BrL960j-.js} +1 -1
- package/dist/assets/{initializeSharedPreferences-Cfgz92Al.js → initializeSharedPreferences-CrnmmfFs.js} +1 -1
- package/dist/assets/{install-iZ64WEBd.js → install-DvRQsTjX.js} +1 -1
- package/dist/assets/{isDiffPlainText-DxiX2X7Q.js → isDiffPlainText-KGYbp86N.js} +1 -1
- package/dist/assets/{isFilePlainText-y0Pch-hF.js → isFilePlainText-D7rclQrA.js} +1 -1
- package/dist/assets/{main-BggWUmia.js → main-Cmc8m6dZ.js} +4 -4
- package/dist/assets/{main-CcAbEyCv.js → main-D4-y6PQ0.js} +2 -2
- package/dist/assets/{markdownCore-P3Pd8JpY.js → markdownCore-D_5e0Wl7.js} +1 -1
- package/dist/assets/{miniChat-iJHNCDmk.js → miniChat-CjJ77DDL.js} +2 -2
- package/dist/assets/{mobile-C1tleU1e.js → mobile-DlFdLxjR.js} +2 -2
- package/dist/assets/{moveWorkspacePath-CUn1SV66.js → moveWorkspacePath-CVdEBQ6v.js} +1 -1
- package/dist/assets/{parseDiffFromFile-Phw3Q2Mh.js → parseDiffFromFile-DWemyyqU.js} +1 -1
- package/dist/assets/{pierreDiffTint-J7FoDbyq.js → pierreDiffTint-B7qPTZmL.js} +1 -1
- package/dist/assets/{relocateRestoredSession-Ch0D1a0g.js → relocateRestoredSession-cOuWlgWB.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-QPvTS_hc.js → renderElectronMiniChatApp-DFnEi5Tr.js} +2 -2
- package/dist/assets/{renderMobileApp-Ci_S1TJm.js → renderMobileApp-C2TYqVOV.js} +3 -3
- package/dist/assets/{restartOpenCode-BE2HLPm1.js → restartOpenCode-Dvk4CWW7.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DcZoNIpr.js → runtimeEndpointReset-D7viEboD.js} +3 -3
- package/dist/assets/{selectionMarkdown-Dw3ME6dV.js → selectionMarkdown-CCursbAw.js} +1 -1
- package/dist/assets/{shikiHighlight-3Hs_1ia3.js → shikiHighlight-CLj7Oan9.js} +1 -1
- package/dist/assets/{space-apply-CvoK3fqX.js → space-apply-DdhqZWNy.js} +1 -1
- package/dist/assets/{space-close-B_kflt9L.js → space-close-KXdazynX.js} +1 -1
- package/dist/assets/{spaceNetwork-ClSGQtiE.js → spaceNetwork-DzU3SK9K.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-kAREvDjp.js → textMateThemeFromAppTheme-C-jxkZJj.js} +1 -1
- package/dist/assets/{useAppFontEffects-BZrjCfFw.js → useAppFontEffects-DAUhSLPu.js} +13 -13
- package/dist/assets/{useCallableModelProviders-CpxZpJTR.js → useCallableModelProviders-B-UCRuyn.js} +1 -1
- package/dist/assets/{useDiffFindSurface-D6svD0Z1.js → useDiffFindSurface-CU_63uoI.js} +1 -1
- package/dist/assets/{useInlineCommentController-CV8dwlO7.js → useInlineCommentController-bYCeqE6r.js} +1 -1
- package/dist/assets/{useMarkdownLocalAssets-D0S_fJEu.js → useMarkdownLocalAssets-CnMxnDdI.js} +1 -1
- package/dist/assets/{useRootScrollLock-5OfQ_8IH.js → useRootScrollLock-DNYaZ34X.js} +2 -2
- package/dist/assets/{useWalkthroughReview-CxCd3Z0I.js → useWalkthroughReview-DGPyQ634.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-DsRKCbVv.js → vendor-codemirror-language-data-KulAIuMz.js} +2 -2
- package/dist/index.html +1 -1
- package/dist/mini-chat.html +1 -1
- package/dist/mobile.html +1 -1
- package/package.json +1 -1
- package/server/index.js +6 -3
- package/server/lib/guests/service-registry.js +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as oe,R as $,j as t}from"./vendor-react-BUCujlKS.js";import{u as Ve,G as We,ae as Ze,af as Ge,ag as He,ah as Je,ai as Te,aj as Xe,n as ze,V as Ye,W as Ke,B as k,X as Qe,ak as et,al as tt,N as st,I as te}from"./useAppFontEffects-BZrjCfFw.js";import{v as Ne,w as De,x as rt}from"./katex.min-u4DtE8E5.js";import{g as Le,r as at}from"./main-BggWUmia.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-zod-DDir2TeQ.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.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-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DsRKCbVv.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.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-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-client-h8RufjAw.js";import"./runtimeEndpointReset-DcZoNIpr.js";import"./useRootScrollLock-5OfQ_8IH.js";import"./moveWorkspacePath-CUn1SV66.js";function nt(r){switch(r){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const Fe=r=>{if(r<1e3)return`${Math.round(r)}ms`;const e=r/1e3;if(e<60)return`${e.toFixed(1)}s`;const o=Math.floor(e/60),s=Math.round(e%60);return`${o}m ${s}s`},$e=r=>`${(r/1e3).toFixed(2)} s`,ot=()=>{const r=oe.c(4),e=tt(!0);let o;r[0]!==e?(o=st("h-3 w-3 text-[var(--status-info)]",e),r[0]=e,r[1]=o):o=r[1];let s;return r[2]!==o?(s=t.jsx(te,{name:"pulse",className:o}),r[2]=o,r[3]=s):s=r[3],s},g=r=>{const e=oe.c(8),{label:o,value:s}=r;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=m):m=e[0];let n;e[1]!==o?(n=t.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:o}),e[1]=o,e[2]=n):n=e[2];let u;e[3]!==s?(u=t.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:s}),e[3]=s,e[4]=u):u=e[4];let p;return e[5]!==n||e[6]!==u?(p=t.jsxs("div",{className:"rounded-md p-2",style:m,children:[n,u]}),e[5]=n,e[6]=u,e[7]=p):p=e[7],p},Oe=r=>{const e=oe.c(43),{title:o,snapshot:s,emptyLabel:m}=r,{t:n}=Ve();let u;if(e[0]!==m||e[1]!==s.durationMs||e[2]!==s.entries||e[3]!==s.lastUpdatedAt||e[4]!==s.startedAt||e[5]!==n||e[6]!==o){const p=s.entries.slice(0,12);let v;e[8]!==s.entries?(v=s.entries.reduce(it,0),e[8]=s.entries,e[9]=v):v=e[9];const S=v;let f;e[10]!==o?(f=t.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:o}),e[10]=o,e[11]=f):f=e[11];let i;e[12]!==s.durationMs||e[13]!==s.startedAt||e[14]!==n?(i=s.startedAt?Fe(s.durationMs):n("memoryDebugPanel.common.idle"),e[12]=s.durationMs,e[13]=s.startedAt,e[14]=n,e[15]=i):i=e[15];let D;e[16]!==i?(D=t.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:i}),e[16]=i,e[17]=D):D=e[17];let x;e[18]!==f||e[19]!==D?(x=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f,D]}),e[18]=f,e[19]=D,e[20]=x):x=e[20];let h;e[21]!==n?(h=n("memoryDebugPanel.metric.metrics"),e[21]=n,e[22]=h):h=e[22];let N;e[23]!==s.entries.length||e[24]!==h?(N=t.jsx(g,{label:h,value:s.entries.length}),e[23]=s.entries.length,e[24]=h,e[25]=N):N=e[25];let b;e[26]!==n?(b=n("memoryDebugPanel.metric.samples"),e[26]=n,e[27]=b):b=e[27];let a;e[28]!==b||e[29]!==S?(a=t.jsx(g,{label:b,value:S}),e[28]=b,e[29]=S,e[30]=a):a=e[30];let y;e[31]!==n?(y=n("memoryDebugPanel.metric.lastUpdate"),e[31]=n,e[32]=y):y=e[32];let j;e[33]!==s.lastUpdatedAt||e[34]!==n?(j=s.lastUpdatedAt?n("memoryDebugPanel.common.live"):n("memoryDebugPanel.common.notAvailable"),e[33]=s.lastUpdatedAt,e[34]=n,e[35]=j):j=e[35];let d;e[36]!==y||e[37]!==j?(d=t.jsx(g,{label:y,value:j}),e[36]=y,e[37]=j,e[38]=d):d=e[38];let P;e[39]!==a||e[40]!==d||e[41]!==N?(P=t.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[N,a,d]}),e[39]=a,e[40]=d,e[41]=N,e[42]=P):P=e[42],u=t.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[x,P,p.length===0?t.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:m}):t.jsx(ze,{outerClassName:"max-h-64",className:"pe-1",children:t.jsx("div",{className:"space-y-1",children:p.map(w=>t.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[t.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:w.metric}),t.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[t.jsx("span",{children:n("memoryDebugPanel.metric.countValue",{value:w.count})}),t.jsx("span",{children:n("memoryDebugPanel.metric.avgValue",{value:w.avg})}),t.jsx("span",{children:n("memoryDebugPanel.metric.maxValue",{value:w.max})}),t.jsx("span",{children:n("memoryDebugPanel.metric.totalValue",{value:w.total})})]})]},w.metric))})})]}),e[0]=m,e[1]=s.durationMs,e[2]=s.entries,e[3]=s.lastUpdatedAt,e[4]=s.startedAt,e[5]=n,e[6]=o,e[7]=u}else u=e[7];return u},Ee=r=>{const e=oe.c(24),{series:o,peak:s,windowSeconds:m,ariaLabel:n,maxLabel:u}=r,p=m,v=o.reduce(mt,0),S=s>0?52/s:0;let f;e[0]!==v||e[1]!==p?(f=d=>p-v+d,e[0]=v,e[1]=p,e[2]=f):f=e[2];const i=f;let D;e[3]!==S?(D=d=>56-d*S,e[3]=S,e[4]=D):D=e[4];const x=D;let h;e[5]!==u?(h=t.jsx("span",{className:"pointer-events-none absolute inset-s-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:u}),e[5]=u,e[6]=h):h=e[6];const N=`0 0 ${p} 56`;let b;e[7]!==p?(b=t.jsx("line",{x1:0,y1:56,x2:p,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=p,e[8]=b):b=e[8];let a;if(e[9]!==o||e[10]!==i||e[11]!==x){let d;e[13]!==i||e[14]!==x?(d=(P,w)=>{const c=P.samples.length;if(c===0)return null;const C=P.samples.map((R,L)=>`${i(L)},${x(R).toFixed(2)}`),_=`M ${C.join(" L ")}`;return t.jsxs($.Fragment,{children:[P.filled?t.jsx("path",{d:`M ${i(0)},56 L ${C.join(" L ")} L ${i(c-1)},56 Z`,fill:`color-mix(in srgb, ${P.color} 18%, transparent)`,stroke:"none"}):null,t.jsx("path",{d:_,fill:"none",stroke:P.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},w)},e[13]=i,e[14]=x,e[15]=d):d=e[15],a=o.map(d),e[9]=o,e[10]=i,e[11]=x,e[12]=a}else a=e[12];let y;e[16]!==n||e[17]!==N||e[18]!==b||e[19]!==a?(y=t.jsxs("svg",{viewBox:N,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":n,children:[b,a]}),e[16]=n,e[17]=N,e[18]=b,e[19]=a,e[20]=y):y=e[20];let j;return e[21]!==h||e[22]!==y?(j=t.jsxs("div",{className:"relative w-full",children:[h,y]}),e[21]=h,e[22]=y,e[23]=j):j=e[23],j},lt=r=>{const e=oe.c(100),{onClose:o}=r,{t:s}=Ve(),[m,n]=$.useState("memory"),[u,p]=$.useState("idle"),v=We(ct),S=Ze(ut),f=Ge(),i=He(dt),D=Je(pt),[x,h]=$.useState(gt),[N,b]=$.useState(ft),[a,y]=$.useState(xt),j=[{label:"p50",current:a.ageP50,samples:a.p50Samples,color:"var(--status-success)"},{label:"p90",current:a.ageP90,samples:a.p90Samples,color:"var(--status-info)"},{label:"p99",current:a.ageP99,samples:a.p99Samples,color:"var(--status-warning)"},{label:"max",current:a.ageMax,samples:a.maxSamples,color:"var(--status-error)"}];let d;e[0]!==a.samples?(d=a.samples.reduce(ht,0),e[0]=a.samples,e[1]=d):d=e[1];const P=d,w=j.reduce(yt,0);let c;e[2]!==x.entries?(c=new Map,x.entries.forEach(l=>{c.set(l.metric,l.count)}),e[2]=x.entries,e[3]=c):c=e[3];let C;e[4]!==c?(C=c.get("ui.message_list.render")??0,e[4]=c,e[5]=C):C=e[5];let _;e[6]!==c?(_=c.get("ui.message_list.render.streaming")??0,e[6]=c,e[7]=_):_=e[7];let R;e[8]!==c?(R=c.get("ui.chat_message.render")??0,e[8]=c,e[9]=R):R=e[9];let L;e[10]!==c?(L=c.get("ui.chat_message.render.streaming")??0,e[10]=c,e[11]=L):L=e[11];let A;e[12]!==c?(A=c.get("ui.chat_message.render.static_during_stream")??0,e[12]=c,e[13]=A):A=e[13];let q;e[14]!==c?(q=c.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=c,e[15]=q):q=e[15];let le;e[16]!==C||e[17]!==_||e[18]!==R||e[19]!==L||e[20]!==A||e[21]!==q?(le={messageListRender:C,messageListRenderStreaming:_,chatMessageRender:R,chatMessageRenderStreaming:L,chatMessageRenderStaticDuringStream:A,chatMessageRenderStaticOutsideActiveTurnDuringStream:q},e[16]=C,e[17]=_,e[18]=R,e[19]=L,e[20]=A,e[21]=q,e[22]=le):le=e[22];const I=le;let ie,me;e[23]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{const l=()=>{h(Ne()),b(De()),y(Le())};l();const M=window.setInterval(l,500);return()=>window.clearInterval(M)},ie=[],e[23]=ie,e[24]=me):(ie=e[23],me=e[24]),$.useEffect(me,ie);let ce,ue;e[25]!==u?(ce=()=>{if(u==="idle")return;const l=window.setTimeout(()=>{p("idle")},1500);return()=>window.clearTimeout(l)},ue=[u],e[25]=u,e[26]=ce,e[27]=ue):(ce=e[26],ue=e[27]),$.useEffect(ce,ue);let se=0,re=0,ae=0;for(const l of Object.keys(i)){const M=i[l]??[];re=re+M.length;for(const ne of M)ne.role==="user"?ae=ae+1:ne.role==="assistant"&&(se=se+1)}let de;e[28]!==se||e[29]!==re||e[30]!==ae?(de={assistant:se,total:re,user:ae},e[28]=se,e[29]=re,e[30]=ae,e[31]=de):de=e[31];const pe=de;let ge;if(e[32]!==v||e[33]!==i||e[34]!==S||e[35]!==f||e[36]!==s){let l;e[38]!==v||e[39]!==i||e[40]!==S||e[41]!==s?(l=M=>{const ne=i[M.id]??[];let _e=0,Re=0;for(const Ie of ne)Ie.role==="user"?Re=Re+1:Ie.role==="assistant"&&(_e=_e+1);const Se=S.get(M.id);return{id:M.id,title:M.title||s("memoryDebugPanel.common.untitled"),assistantMessageCount:_e,messageCount:ne.length,userMessageCount:Re,isStreaming:Se?.isStreaming||!1,isZombie:Se?.isZombie||!1,backgroundCount:Se?.backgroundMessageCount||0,lastAccessed:Se?.lastAccessedAt||0,isCurrent:M.id===v}},e[38]=v,e[39]=i,e[40]=S,e[41]=s,e[42]=l):l=e[42],ge=f.map(l).sort(vt),e[32]=v,e[33]=i,e[34]=S,e[35]=f,e[36]=s,e[37]=ge}else ge=e[37];const Ae=ge;let fe;e[43]!==i?(fe=Object.keys(i),e[43]=i,e[44]=fe):fe=e[44];const Ue=fe.length;let xe;e[45]===Symbol.for("react.memo_cache_sentinel")?(xe=async()=>{try{const l={generatedAt:new Date().toISOString(),ui:Ne(),vscode:De()};await navigator.clipboard.writeText(JSON.stringify(l,null,2)),p("copied")}catch{p("error")}},e[45]=xe):xe=e[45];const qe=xe,Pe=et,Be="fixed bottom-4 inset-e-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let T;e[46]===Symbol.for("react.memo_cache_sentinel")?(T={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=T):T=e[46];let O;e[47]!==m?(O=nt(m),e[47]=m,e[48]=O):O=e[48];let E;e[49]!==O?(E=t.jsx(te,{name:O,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=O,e[50]=E):E=e[50];let V;e[51]!==s?(V=s("memoryDebugPanel.title"),e[51]=s,e[52]=V):V=e[52];let z;e[53]!==V?(z=t.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:V}),e[53]=V,e[54]=z):z=e[54];let F;e[55]!==E||e[56]!==z?(F=t.jsxs("div",{className:"flex items-center gap-2",children:[E,z]}),e[55]=E,e[56]=z,e[57]=F):F=e[57];let U;e[58]!==m?(U=m==="streaming"?t.jsxs(t.Fragment,{children:[t.jsx(k,{size:"xs",variant:"ghost",onClick:qe,children:t.jsx(te,{name:"file-copy",className:"h-3.5 w-3.5"})}),t.jsx(k,{size:"xs",variant:"ghost",onClick:()=>{rt(),h(Ne()),b(De())},children:t.jsx(te,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=m,e[59]=U):U=e[59];let B;e[60]!==m?(B=m==="requests"?t.jsx(k,{size:"xs",variant:"ghost",onClick:()=>{at(),y(Le())},children:t.jsx(te,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=m,e[61]=B):B=e[61];let W;e[62]!==o?(W=o?t.jsx(k,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:o,children:t.jsx(te,{name:"close",className:"h-4 w-4"})}):null,e[62]=o,e[63]=W):W=e[63];let Z;e[64]!==U||e[65]!==B||e[66]!==W?(Z=t.jsxs("div",{className:"flex items-center gap-1",children:[U,B,W]}),e[64]=U,e[65]=B,e[66]=W,e[67]=Z):Z=e[67];let G;e[68]!==F||e[69]!==Z?(G=t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[F,Z]}),e[68]=F,e[69]=Z,e[70]=G):G=e[70];let he;e[71]===Symbol.for("react.memo_cache_sentinel")?(he={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=he):he=e[71];const we=m==="memory"?"secondary":"ghost";let be;e[72]===Symbol.for("react.memo_cache_sentinel")?(be=()=>n("memory"),e[72]=be):be=e[72];let H;e[73]!==s?(H=s("memoryDebugPanel.tabs.memory"),e[73]=s,e[74]=H):H=e[74];let J;e[75]!==we||e[76]!==H?(J=t.jsx(k,{size:"sm",variant:we,className:"flex-1",onClick:be,children:H}),e[75]=we,e[76]=H,e[77]=J):J=e[77];const Me=m==="streaming"?"secondary":"ghost";let ye;e[78]===Symbol.for("react.memo_cache_sentinel")?(ye=()=>n("streaming"),e[78]=ye):ye=e[78];let X;e[79]!==s?(X=s("memoryDebugPanel.tabs.streaming"),e[79]=s,e[80]=X):X=e[80];let Y;e[81]!==Me||e[82]!==X?(Y=t.jsx(k,{size:"sm",variant:Me,className:"flex-1",onClick:ye,children:X}),e[81]=Me,e[82]=X,e[83]=Y):Y=e[83];const Ce=m==="requests"?"secondary":"ghost";let ve;e[84]===Symbol.for("react.memo_cache_sentinel")?(ve=()=>n("requests"),e[84]=ve):ve=e[84];let K;e[85]!==s?(K=s("memoryDebugPanel.tabs.requests"),e[85]=s,e[86]=K):K=e[86];let Q;e[87]!==Ce||e[88]!==K?(Q=t.jsx(k,{size:"sm",variant:Ce,className:"flex-1",onClick:ve,children:K}),e[87]=Ce,e[88]=K,e[89]=Q):Q=e[89];let ee;e[90]!==J||e[91]!==Y||e[92]!==Q?(ee=t.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:he,children:[J,Y,Q]}),e[90]=J,e[91]=Y,e[92]=Q,e[93]=ee):ee=e[93];const ke=m==="memory"?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[t.jsx(g,{label:s("memoryDebugPanel.metric.totalMessages"),value:pe.total}),t.jsx(g,{label:s("memoryDebugPanel.metric.cachedSessions"),value:`${Ue} / ${Te.MAX_SESSIONS}`}),t.jsx(g,{label:s("memoryDebugPanel.metric.userMessages"),value:pe.user}),t.jsx(g,{label:s("memoryDebugPanel.metric.assistantMessages"),value:pe.assistant})]}),t.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[t.jsxs("div",{className:"flex justify-between gap-2",children:[t.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:s("memoryDebugPanel.metric.viewportWindow")}),t.jsx("span",{className:"text-[var(--surface-foreground)]",children:s("memoryDebugPanel.metric.messagesValue",{count:Xe()})})]}),t.jsxs("div",{className:"flex justify-between gap-2",children:[t.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:s("memoryDebugPanel.metric.zombieTimeout")}),t.jsx("span",{className:"text-[var(--surface-foreground)]",children:s("memoryDebugPanel.metric.minutesValue",{count:Te.ZOMBIE_TIMEOUT/1e3/60})})]}),t.jsxs("div",{className:"flex justify-between gap-2",children:[t.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:s("memoryDebugPanel.metric.githubTotalRequests")}),t.jsx("span",{className:"text-[var(--surface-foreground)]",children:D})]})]}),t.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[t.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:s("memoryDebugPanel.section.sessionsInMemory")}),t.jsx(ze,{outerClassName:"max-h-48",className:"space-y-1 pe-1",children:Ae.map(l=>t.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:l.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:l.title}),l.isStreaming?t.jsx(ot,{}):null,l.isZombie?t.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:s("memoryDebugPanel.metric.roleMsgsValue",{assistant:l.assistantMessageCount,user:l.userMessageCount})}),t.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:s("memoryDebugPanel.metric.msgsValue",{count:l.messageCount})}),l.backgroundCount>0?t.jsxs("span",{className:"text-[var(--status-info)]",children:["+",l.backgroundCount]}):null]})]},l.id))})]}),t.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:t.jsxs(Ye,{children:[t.jsx(Ke,{asChild:!0,children:t.jsx(k,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:f.map(jt),currentSessionId:v,cachedSessions:Object.keys(i),messageRoleCounts:pe,sessionMessageRoleCounts:Ae.map(St),memoryStates:Object.fromEntries(S)})},children:s("memoryDebugPanel.actions.logState")})}),t.jsx(Qe,{side:"top",children:s("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):m==="streaming"?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[t.jsx("span",{children:s(u==="copied"?"memoryDebugPanel.streaming.copy.copied":u==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),t.jsx(k,{size:"xs",variant:"outline",onClick:qe,children:s("memoryDebugPanel.actions.copyJson")})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx(g,{label:s("memoryDebugPanel.metric.uiMetrics"),value:x.entries.length}),t.jsx(g,{label:s("memoryDebugPanel.metric.vscodeMetrics"),value:N.entries.length}),t.jsx(g,{label:s("memoryDebugPanel.metric.messageListRenders"),value:I.messageListRender}),t.jsx(g,{label:s("memoryDebugPanel.metric.messageListStreamRenders"),value:I.messageListRenderStreaming}),t.jsx(g,{label:s("memoryDebugPanel.metric.chatMessageRenders"),value:I.chatMessageRender}),t.jsx(g,{label:s("memoryDebugPanel.metric.chatMessageStreamRenders"),value:I.chatMessageRenderStreaming}),t.jsx(g,{label:s("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:I.chatMessageRenderStaticDuringStream}),t.jsx(g,{label:s("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:I.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),t.jsx(Oe,{title:s("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:x,emptyLabel:s("memoryDebugPanel.section.noUiSamples")}),N.entries.length>0?t.jsx(Oe,{title:s("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:N,emptyLabel:s("memoryDebugPanel.section.noVscodeSamples")}):null]}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[t.jsx(g,{label:s("memoryDebugPanel.requests.totalRequests"),value:`${a.totalSettled} / ${a.totalStarted}`}),t.jsx(g,{label:s("memoryDebugPanel.requests.tracking"),value:a.startedAt?Fe(a.durationMs):s("memoryDebugPanel.common.idle")})]}),a.samples.length===0?t.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:s("memoryDebugPanel.requests.noSamples")}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[t.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:s("memoryDebugPanel.requests.inFlight")}),t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:a.inFlight}),t.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",s("memoryDebugPanel.requests.peak")," "]}),t.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:a.peak})]})]}),t.jsx(Ee,{series:[{samples:a.samples,color:"var(--status-info)",filled:!0}],peak:P,windowSeconds:a.windowSeconds,ariaLabel:s("memoryDebugPanel.requests.chartLabel",{peak:a.peak}),maxLabel:`${P}`}),t.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[t.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:s("memoryDebugPanel.requests.duration")}),t.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:$e(a.peakAgeMs)})]}),t.jsx(Ee,{series:j.map(Nt),peak:w,windowSeconds:a.windowSeconds,ariaLabel:s("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:$e(w)}),t.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:j.map(Dt)}),t.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[t.jsx("span",{children:s("memoryDebugPanel.requests.windowHint",{seconds:a.windowSeconds})}),t.jsx("span",{children:s("memoryDebugPanel.requests.now")})]})]})]});let je;return e[94]!==Pe||e[95]!==T||e[96]!==G||e[97]!==ee||e[98]!==ke?(je=t.jsxs(Pe,{className:Be,style:T,children:[G,ee,ke]}),e[94]=Pe,e[95]=T,e[96]=G,e[97]=ee,e[98]=ke,e[99]=je):je=e[99],je},rr=lt;function it(r,e){return r+e.count}function mt(r,e){return Math.max(r,e.samples.length)}function ct(r){return r.currentSessionId}function ut(r){return r.sessionMemoryState}function dt(r){return r.message}function pt(r){return r.totalRequestCount}function gt(){return Ne()}function ft(){return De()}function xt(){return Le()}function ht(r,e){return Math.max(r,e)}function bt(r,e){return Math.max(r,e)}function yt(r,e){return e.samples.reduce(bt,r)}function vt(r,e){return e.lastAccessed-r.lastAccessed}function jt(r){return{id:r.id,title:r.title}}function St(r){return{id:r.id,title:r.title,total:r.messageCount,user:r.userMessageCount,assistant:r.assistantMessageCount}}function Nt(r){return{samples:r.samples,color:r.color}}function Dt(r){return t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:r.color}}),t.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r.label}),t.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:$e(r.current)})]},r.label)}export{rr as MemoryDebugPanel};
|
|
1
|
+
import{f as oe,R as $,j as t}from"./vendor-react-BUCujlKS.js";import{u as Ve,G as We,ae as Ze,af as Ge,ag as He,ah as Je,ai as Te,aj as Xe,n as ze,V as Ye,W as Ke,B as k,X as Qe,ak as et,al as tt,N as st,I as te}from"./useAppFontEffects-DAUhSLPu.js";import{v as Ne,w as De,x as rt}from"./katex.min-u4DtE8E5.js";import{g as Le,r as at}from"./main-Cmc8m6dZ.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-zod-DDir2TeQ.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.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-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-KulAIuMz.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.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-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-client-h8RufjAw.js";import"./runtimeEndpointReset-D7viEboD.js";import"./useRootScrollLock-DNYaZ34X.js";import"./moveWorkspacePath-CVdEBQ6v.js";function nt(r){switch(r){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const Fe=r=>{if(r<1e3)return`${Math.round(r)}ms`;const e=r/1e3;if(e<60)return`${e.toFixed(1)}s`;const o=Math.floor(e/60),s=Math.round(e%60);return`${o}m ${s}s`},$e=r=>`${(r/1e3).toFixed(2)} s`,ot=()=>{const r=oe.c(4),e=tt(!0);let o;r[0]!==e?(o=st("h-3 w-3 text-[var(--status-info)]",e),r[0]=e,r[1]=o):o=r[1];let s;return r[2]!==o?(s=t.jsx(te,{name:"pulse",className:o}),r[2]=o,r[3]=s):s=r[3],s},g=r=>{const e=oe.c(8),{label:o,value:s}=r;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=m):m=e[0];let n;e[1]!==o?(n=t.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:o}),e[1]=o,e[2]=n):n=e[2];let u;e[3]!==s?(u=t.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:s}),e[3]=s,e[4]=u):u=e[4];let p;return e[5]!==n||e[6]!==u?(p=t.jsxs("div",{className:"rounded-md p-2",style:m,children:[n,u]}),e[5]=n,e[6]=u,e[7]=p):p=e[7],p},Oe=r=>{const e=oe.c(43),{title:o,snapshot:s,emptyLabel:m}=r,{t:n}=Ve();let u;if(e[0]!==m||e[1]!==s.durationMs||e[2]!==s.entries||e[3]!==s.lastUpdatedAt||e[4]!==s.startedAt||e[5]!==n||e[6]!==o){const p=s.entries.slice(0,12);let v;e[8]!==s.entries?(v=s.entries.reduce(it,0),e[8]=s.entries,e[9]=v):v=e[9];const S=v;let f;e[10]!==o?(f=t.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:o}),e[10]=o,e[11]=f):f=e[11];let i;e[12]!==s.durationMs||e[13]!==s.startedAt||e[14]!==n?(i=s.startedAt?Fe(s.durationMs):n("memoryDebugPanel.common.idle"),e[12]=s.durationMs,e[13]=s.startedAt,e[14]=n,e[15]=i):i=e[15];let D;e[16]!==i?(D=t.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:i}),e[16]=i,e[17]=D):D=e[17];let x;e[18]!==f||e[19]!==D?(x=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f,D]}),e[18]=f,e[19]=D,e[20]=x):x=e[20];let h;e[21]!==n?(h=n("memoryDebugPanel.metric.metrics"),e[21]=n,e[22]=h):h=e[22];let N;e[23]!==s.entries.length||e[24]!==h?(N=t.jsx(g,{label:h,value:s.entries.length}),e[23]=s.entries.length,e[24]=h,e[25]=N):N=e[25];let b;e[26]!==n?(b=n("memoryDebugPanel.metric.samples"),e[26]=n,e[27]=b):b=e[27];let a;e[28]!==b||e[29]!==S?(a=t.jsx(g,{label:b,value:S}),e[28]=b,e[29]=S,e[30]=a):a=e[30];let y;e[31]!==n?(y=n("memoryDebugPanel.metric.lastUpdate"),e[31]=n,e[32]=y):y=e[32];let j;e[33]!==s.lastUpdatedAt||e[34]!==n?(j=s.lastUpdatedAt?n("memoryDebugPanel.common.live"):n("memoryDebugPanel.common.notAvailable"),e[33]=s.lastUpdatedAt,e[34]=n,e[35]=j):j=e[35];let d;e[36]!==y||e[37]!==j?(d=t.jsx(g,{label:y,value:j}),e[36]=y,e[37]=j,e[38]=d):d=e[38];let P;e[39]!==a||e[40]!==d||e[41]!==N?(P=t.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[N,a,d]}),e[39]=a,e[40]=d,e[41]=N,e[42]=P):P=e[42],u=t.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[x,P,p.length===0?t.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:m}):t.jsx(ze,{outerClassName:"max-h-64",className:"pe-1",children:t.jsx("div",{className:"space-y-1",children:p.map(w=>t.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[t.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:w.metric}),t.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[t.jsx("span",{children:n("memoryDebugPanel.metric.countValue",{value:w.count})}),t.jsx("span",{children:n("memoryDebugPanel.metric.avgValue",{value:w.avg})}),t.jsx("span",{children:n("memoryDebugPanel.metric.maxValue",{value:w.max})}),t.jsx("span",{children:n("memoryDebugPanel.metric.totalValue",{value:w.total})})]})]},w.metric))})})]}),e[0]=m,e[1]=s.durationMs,e[2]=s.entries,e[3]=s.lastUpdatedAt,e[4]=s.startedAt,e[5]=n,e[6]=o,e[7]=u}else u=e[7];return u},Ee=r=>{const e=oe.c(24),{series:o,peak:s,windowSeconds:m,ariaLabel:n,maxLabel:u}=r,p=m,v=o.reduce(mt,0),S=s>0?52/s:0;let f;e[0]!==v||e[1]!==p?(f=d=>p-v+d,e[0]=v,e[1]=p,e[2]=f):f=e[2];const i=f;let D;e[3]!==S?(D=d=>56-d*S,e[3]=S,e[4]=D):D=e[4];const x=D;let h;e[5]!==u?(h=t.jsx("span",{className:"pointer-events-none absolute inset-s-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:u}),e[5]=u,e[6]=h):h=e[6];const N=`0 0 ${p} 56`;let b;e[7]!==p?(b=t.jsx("line",{x1:0,y1:56,x2:p,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=p,e[8]=b):b=e[8];let a;if(e[9]!==o||e[10]!==i||e[11]!==x){let d;e[13]!==i||e[14]!==x?(d=(P,w)=>{const c=P.samples.length;if(c===0)return null;const C=P.samples.map((R,L)=>`${i(L)},${x(R).toFixed(2)}`),_=`M ${C.join(" L ")}`;return t.jsxs($.Fragment,{children:[P.filled?t.jsx("path",{d:`M ${i(0)},56 L ${C.join(" L ")} L ${i(c-1)},56 Z`,fill:`color-mix(in srgb, ${P.color} 18%, transparent)`,stroke:"none"}):null,t.jsx("path",{d:_,fill:"none",stroke:P.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},w)},e[13]=i,e[14]=x,e[15]=d):d=e[15],a=o.map(d),e[9]=o,e[10]=i,e[11]=x,e[12]=a}else a=e[12];let y;e[16]!==n||e[17]!==N||e[18]!==b||e[19]!==a?(y=t.jsxs("svg",{viewBox:N,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":n,children:[b,a]}),e[16]=n,e[17]=N,e[18]=b,e[19]=a,e[20]=y):y=e[20];let j;return e[21]!==h||e[22]!==y?(j=t.jsxs("div",{className:"relative w-full",children:[h,y]}),e[21]=h,e[22]=y,e[23]=j):j=e[23],j},lt=r=>{const e=oe.c(100),{onClose:o}=r,{t:s}=Ve(),[m,n]=$.useState("memory"),[u,p]=$.useState("idle"),v=We(ct),S=Ze(ut),f=Ge(),i=He(dt),D=Je(pt),[x,h]=$.useState(gt),[N,b]=$.useState(ft),[a,y]=$.useState(xt),j=[{label:"p50",current:a.ageP50,samples:a.p50Samples,color:"var(--status-success)"},{label:"p90",current:a.ageP90,samples:a.p90Samples,color:"var(--status-info)"},{label:"p99",current:a.ageP99,samples:a.p99Samples,color:"var(--status-warning)"},{label:"max",current:a.ageMax,samples:a.maxSamples,color:"var(--status-error)"}];let d;e[0]!==a.samples?(d=a.samples.reduce(ht,0),e[0]=a.samples,e[1]=d):d=e[1];const P=d,w=j.reduce(yt,0);let c;e[2]!==x.entries?(c=new Map,x.entries.forEach(l=>{c.set(l.metric,l.count)}),e[2]=x.entries,e[3]=c):c=e[3];let C;e[4]!==c?(C=c.get("ui.message_list.render")??0,e[4]=c,e[5]=C):C=e[5];let _;e[6]!==c?(_=c.get("ui.message_list.render.streaming")??0,e[6]=c,e[7]=_):_=e[7];let R;e[8]!==c?(R=c.get("ui.chat_message.render")??0,e[8]=c,e[9]=R):R=e[9];let L;e[10]!==c?(L=c.get("ui.chat_message.render.streaming")??0,e[10]=c,e[11]=L):L=e[11];let A;e[12]!==c?(A=c.get("ui.chat_message.render.static_during_stream")??0,e[12]=c,e[13]=A):A=e[13];let q;e[14]!==c?(q=c.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=c,e[15]=q):q=e[15];let le;e[16]!==C||e[17]!==_||e[18]!==R||e[19]!==L||e[20]!==A||e[21]!==q?(le={messageListRender:C,messageListRenderStreaming:_,chatMessageRender:R,chatMessageRenderStreaming:L,chatMessageRenderStaticDuringStream:A,chatMessageRenderStaticOutsideActiveTurnDuringStream:q},e[16]=C,e[17]=_,e[18]=R,e[19]=L,e[20]=A,e[21]=q,e[22]=le):le=e[22];const I=le;let ie,me;e[23]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{const l=()=>{h(Ne()),b(De()),y(Le())};l();const M=window.setInterval(l,500);return()=>window.clearInterval(M)},ie=[],e[23]=ie,e[24]=me):(ie=e[23],me=e[24]),$.useEffect(me,ie);let ce,ue;e[25]!==u?(ce=()=>{if(u==="idle")return;const l=window.setTimeout(()=>{p("idle")},1500);return()=>window.clearTimeout(l)},ue=[u],e[25]=u,e[26]=ce,e[27]=ue):(ce=e[26],ue=e[27]),$.useEffect(ce,ue);let se=0,re=0,ae=0;for(const l of Object.keys(i)){const M=i[l]??[];re=re+M.length;for(const ne of M)ne.role==="user"?ae=ae+1:ne.role==="assistant"&&(se=se+1)}let de;e[28]!==se||e[29]!==re||e[30]!==ae?(de={assistant:se,total:re,user:ae},e[28]=se,e[29]=re,e[30]=ae,e[31]=de):de=e[31];const pe=de;let ge;if(e[32]!==v||e[33]!==i||e[34]!==S||e[35]!==f||e[36]!==s){let l;e[38]!==v||e[39]!==i||e[40]!==S||e[41]!==s?(l=M=>{const ne=i[M.id]??[];let _e=0,Re=0;for(const Ie of ne)Ie.role==="user"?Re=Re+1:Ie.role==="assistant"&&(_e=_e+1);const Se=S.get(M.id);return{id:M.id,title:M.title||s("memoryDebugPanel.common.untitled"),assistantMessageCount:_e,messageCount:ne.length,userMessageCount:Re,isStreaming:Se?.isStreaming||!1,isZombie:Se?.isZombie||!1,backgroundCount:Se?.backgroundMessageCount||0,lastAccessed:Se?.lastAccessedAt||0,isCurrent:M.id===v}},e[38]=v,e[39]=i,e[40]=S,e[41]=s,e[42]=l):l=e[42],ge=f.map(l).sort(vt),e[32]=v,e[33]=i,e[34]=S,e[35]=f,e[36]=s,e[37]=ge}else ge=e[37];const Ae=ge;let fe;e[43]!==i?(fe=Object.keys(i),e[43]=i,e[44]=fe):fe=e[44];const Ue=fe.length;let xe;e[45]===Symbol.for("react.memo_cache_sentinel")?(xe=async()=>{try{const l={generatedAt:new Date().toISOString(),ui:Ne(),vscode:De()};await navigator.clipboard.writeText(JSON.stringify(l,null,2)),p("copied")}catch{p("error")}},e[45]=xe):xe=e[45];const qe=xe,Pe=et,Be="fixed bottom-4 inset-e-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let T;e[46]===Symbol.for("react.memo_cache_sentinel")?(T={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=T):T=e[46];let O;e[47]!==m?(O=nt(m),e[47]=m,e[48]=O):O=e[48];let E;e[49]!==O?(E=t.jsx(te,{name:O,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=O,e[50]=E):E=e[50];let V;e[51]!==s?(V=s("memoryDebugPanel.title"),e[51]=s,e[52]=V):V=e[52];let z;e[53]!==V?(z=t.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:V}),e[53]=V,e[54]=z):z=e[54];let F;e[55]!==E||e[56]!==z?(F=t.jsxs("div",{className:"flex items-center gap-2",children:[E,z]}),e[55]=E,e[56]=z,e[57]=F):F=e[57];let U;e[58]!==m?(U=m==="streaming"?t.jsxs(t.Fragment,{children:[t.jsx(k,{size:"xs",variant:"ghost",onClick:qe,children:t.jsx(te,{name:"file-copy",className:"h-3.5 w-3.5"})}),t.jsx(k,{size:"xs",variant:"ghost",onClick:()=>{rt(),h(Ne()),b(De())},children:t.jsx(te,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=m,e[59]=U):U=e[59];let B;e[60]!==m?(B=m==="requests"?t.jsx(k,{size:"xs",variant:"ghost",onClick:()=>{at(),y(Le())},children:t.jsx(te,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=m,e[61]=B):B=e[61];let W;e[62]!==o?(W=o?t.jsx(k,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:o,children:t.jsx(te,{name:"close",className:"h-4 w-4"})}):null,e[62]=o,e[63]=W):W=e[63];let Z;e[64]!==U||e[65]!==B||e[66]!==W?(Z=t.jsxs("div",{className:"flex items-center gap-1",children:[U,B,W]}),e[64]=U,e[65]=B,e[66]=W,e[67]=Z):Z=e[67];let G;e[68]!==F||e[69]!==Z?(G=t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[F,Z]}),e[68]=F,e[69]=Z,e[70]=G):G=e[70];let he;e[71]===Symbol.for("react.memo_cache_sentinel")?(he={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=he):he=e[71];const we=m==="memory"?"secondary":"ghost";let be;e[72]===Symbol.for("react.memo_cache_sentinel")?(be=()=>n("memory"),e[72]=be):be=e[72];let H;e[73]!==s?(H=s("memoryDebugPanel.tabs.memory"),e[73]=s,e[74]=H):H=e[74];let J;e[75]!==we||e[76]!==H?(J=t.jsx(k,{size:"sm",variant:we,className:"flex-1",onClick:be,children:H}),e[75]=we,e[76]=H,e[77]=J):J=e[77];const Me=m==="streaming"?"secondary":"ghost";let ye;e[78]===Symbol.for("react.memo_cache_sentinel")?(ye=()=>n("streaming"),e[78]=ye):ye=e[78];let X;e[79]!==s?(X=s("memoryDebugPanel.tabs.streaming"),e[79]=s,e[80]=X):X=e[80];let Y;e[81]!==Me||e[82]!==X?(Y=t.jsx(k,{size:"sm",variant:Me,className:"flex-1",onClick:ye,children:X}),e[81]=Me,e[82]=X,e[83]=Y):Y=e[83];const Ce=m==="requests"?"secondary":"ghost";let ve;e[84]===Symbol.for("react.memo_cache_sentinel")?(ve=()=>n("requests"),e[84]=ve):ve=e[84];let K;e[85]!==s?(K=s("memoryDebugPanel.tabs.requests"),e[85]=s,e[86]=K):K=e[86];let Q;e[87]!==Ce||e[88]!==K?(Q=t.jsx(k,{size:"sm",variant:Ce,className:"flex-1",onClick:ve,children:K}),e[87]=Ce,e[88]=K,e[89]=Q):Q=e[89];let ee;e[90]!==J||e[91]!==Y||e[92]!==Q?(ee=t.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:he,children:[J,Y,Q]}),e[90]=J,e[91]=Y,e[92]=Q,e[93]=ee):ee=e[93];const ke=m==="memory"?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[t.jsx(g,{label:s("memoryDebugPanel.metric.totalMessages"),value:pe.total}),t.jsx(g,{label:s("memoryDebugPanel.metric.cachedSessions"),value:`${Ue} / ${Te.MAX_SESSIONS}`}),t.jsx(g,{label:s("memoryDebugPanel.metric.userMessages"),value:pe.user}),t.jsx(g,{label:s("memoryDebugPanel.metric.assistantMessages"),value:pe.assistant})]}),t.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[t.jsxs("div",{className:"flex justify-between gap-2",children:[t.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:s("memoryDebugPanel.metric.viewportWindow")}),t.jsx("span",{className:"text-[var(--surface-foreground)]",children:s("memoryDebugPanel.metric.messagesValue",{count:Xe()})})]}),t.jsxs("div",{className:"flex justify-between gap-2",children:[t.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:s("memoryDebugPanel.metric.zombieTimeout")}),t.jsx("span",{className:"text-[var(--surface-foreground)]",children:s("memoryDebugPanel.metric.minutesValue",{count:Te.ZOMBIE_TIMEOUT/1e3/60})})]}),t.jsxs("div",{className:"flex justify-between gap-2",children:[t.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:s("memoryDebugPanel.metric.githubTotalRequests")}),t.jsx("span",{className:"text-[var(--surface-foreground)]",children:D})]})]}),t.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[t.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:s("memoryDebugPanel.section.sessionsInMemory")}),t.jsx(ze,{outerClassName:"max-h-48",className:"space-y-1 pe-1",children:Ae.map(l=>t.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:l.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:l.title}),l.isStreaming?t.jsx(ot,{}):null,l.isZombie?t.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:s("memoryDebugPanel.metric.roleMsgsValue",{assistant:l.assistantMessageCount,user:l.userMessageCount})}),t.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:s("memoryDebugPanel.metric.msgsValue",{count:l.messageCount})}),l.backgroundCount>0?t.jsxs("span",{className:"text-[var(--status-info)]",children:["+",l.backgroundCount]}):null]})]},l.id))})]}),t.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:t.jsxs(Ye,{children:[t.jsx(Ke,{asChild:!0,children:t.jsx(k,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:f.map(jt),currentSessionId:v,cachedSessions:Object.keys(i),messageRoleCounts:pe,sessionMessageRoleCounts:Ae.map(St),memoryStates:Object.fromEntries(S)})},children:s("memoryDebugPanel.actions.logState")})}),t.jsx(Qe,{side:"top",children:s("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):m==="streaming"?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[t.jsx("span",{children:s(u==="copied"?"memoryDebugPanel.streaming.copy.copied":u==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),t.jsx(k,{size:"xs",variant:"outline",onClick:qe,children:s("memoryDebugPanel.actions.copyJson")})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx(g,{label:s("memoryDebugPanel.metric.uiMetrics"),value:x.entries.length}),t.jsx(g,{label:s("memoryDebugPanel.metric.vscodeMetrics"),value:N.entries.length}),t.jsx(g,{label:s("memoryDebugPanel.metric.messageListRenders"),value:I.messageListRender}),t.jsx(g,{label:s("memoryDebugPanel.metric.messageListStreamRenders"),value:I.messageListRenderStreaming}),t.jsx(g,{label:s("memoryDebugPanel.metric.chatMessageRenders"),value:I.chatMessageRender}),t.jsx(g,{label:s("memoryDebugPanel.metric.chatMessageStreamRenders"),value:I.chatMessageRenderStreaming}),t.jsx(g,{label:s("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:I.chatMessageRenderStaticDuringStream}),t.jsx(g,{label:s("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:I.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),t.jsx(Oe,{title:s("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:x,emptyLabel:s("memoryDebugPanel.section.noUiSamples")}),N.entries.length>0?t.jsx(Oe,{title:s("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:N,emptyLabel:s("memoryDebugPanel.section.noVscodeSamples")}):null]}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[t.jsx(g,{label:s("memoryDebugPanel.requests.totalRequests"),value:`${a.totalSettled} / ${a.totalStarted}`}),t.jsx(g,{label:s("memoryDebugPanel.requests.tracking"),value:a.startedAt?Fe(a.durationMs):s("memoryDebugPanel.common.idle")})]}),a.samples.length===0?t.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:s("memoryDebugPanel.requests.noSamples")}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[t.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:s("memoryDebugPanel.requests.inFlight")}),t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:a.inFlight}),t.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",s("memoryDebugPanel.requests.peak")," "]}),t.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:a.peak})]})]}),t.jsx(Ee,{series:[{samples:a.samples,color:"var(--status-info)",filled:!0}],peak:P,windowSeconds:a.windowSeconds,ariaLabel:s("memoryDebugPanel.requests.chartLabel",{peak:a.peak}),maxLabel:`${P}`}),t.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[t.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:s("memoryDebugPanel.requests.duration")}),t.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:$e(a.peakAgeMs)})]}),t.jsx(Ee,{series:j.map(Nt),peak:w,windowSeconds:a.windowSeconds,ariaLabel:s("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:$e(w)}),t.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:j.map(Dt)}),t.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[t.jsx("span",{children:s("memoryDebugPanel.requests.windowHint",{seconds:a.windowSeconds})}),t.jsx("span",{children:s("memoryDebugPanel.requests.now")})]})]})]});let je;return e[94]!==Pe||e[95]!==T||e[96]!==G||e[97]!==ee||e[98]!==ke?(je=t.jsxs(Pe,{className:Be,style:T,children:[G,ee,ke]}),e[94]=Pe,e[95]=T,e[96]=G,e[97]=ee,e[98]=ke,e[99]=je):je=e[99],je},rr=lt;function it(r,e){return r+e.count}function mt(r,e){return Math.max(r,e.samples.length)}function ct(r){return r.currentSessionId}function ut(r){return r.sessionMemoryState}function dt(r){return r.message}function pt(r){return r.totalRequestCount}function gt(){return Ne()}function ft(){return De()}function xt(){return Le()}function ht(r,e){return Math.max(r,e)}function bt(r,e){return Math.max(r,e)}function yt(r,e){return e.samples.reduce(bt,r)}function vt(r,e){return e.lastAccessed-r.lastAccessed}function jt(r){return{id:r.id,title:r.title}}function St(r){return{id:r.id,title:r.title,total:r.messageCount,user:r.userMessageCount,assistant:r.assistantMessageCount}}function Nt(r){return{samples:r.samples,color:r.color}}function Dt(r){return t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:r.color}}),t.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r.label}),t.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:$e(r.current)})]},r.label)}export{rr as MemoryDebugPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as K,j as t,R as d,f as Q}from"./vendor-react-BUCujlKS.js";import{u as oe,B as L,y as J,eU as he,aA as fe,ac as Ce,N as ee,I as F,al as Se}from"./useAppFontEffects-BZrjCfFw.js";import{aL as G,aM as Re,aN as ue,aO as Z,ax as X,aP as Y,aQ as Le,aR as xe,aS as ge,k as te,aT as be,aU as ye,aV as ce,aW as Ue,aX as Ie,aY as Te}from"./katex.min-u4DtE8E5.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-zod-DDir2TeQ.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.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-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DsRKCbVv.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.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-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-client-h8RufjAw.js";function _e(r){switch(r){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function ie(r){return r==="wrong-service"||r==="unreachable"||r==="incompatible"}function ve({onBack:r,showBackButton:e=!0,initialUrl:o="",initialLabel:a="",isRecoveryMode:n=!1,onConnect:l,onSwitchToLocal:u,showInstancePicker:i=!1}){const{t:s}=oe(),[h,x]=K.useState(o),[m,U]=K.useState(a),[R,y]=K.useState("idle"),[b,g]=K.useState(null),[S,N]=K.useState(""),[T,I]=K.useState([]),[D,w]=K.useState(()=>i?"instances":"add"),[v,j]=K.useState("");K.useEffect(()=>{i&&G().then(p=>I(p.hosts)).catch(p=>{N(p instanceof Error?p.message:String(p))})},[i]);const k=Re(h),A=k?.persistedUrl??null,B=K.useCallback(p=>{x(p.target.value),y("idle"),g(null),N("")},[]),$=K.useCallback(p=>{U(p.target.value)},[]),W=K.useCallback(async()=>{if(A){y("testing"),g(null),N("");try{const p=await ue(A);g(p),y(p.status==="ok"||p.status==="update-recommended"?"success":"error")}catch(p){N(p instanceof Error?p.message:s("onboarding.remoteConnection.errors.connectionTestFailed")),y("error")}}},[A,s]),f=K.useCallback(async()=>{if(!k)return;const p=k.persistedUrl;y("testing"),g(null),N("");try{const z=await ue(p);if(g(z),ie(z.status)){y("error");return}const ne=await G(),ke=m.trim()||p,re=ne.hosts.find(se=>se.url===p),ae=re?re.id:`host-${Date.now().toString(16)}`,de={id:ae,label:ke,url:p,apiUrl:p},Ne=re?ne.hosts.map(se=>se.id===ae?de:se):[...ne.hosts,de];if(await Z({hosts:Ne,defaultHostId:ae,initialHostChoiceCompleted:!0}),l?.(),k.redeemUrl){window.location.assign(k.redeemUrl);return}X()&&await Y()}catch(z){N(z instanceof Error?z.message:s("onboarding.remoteConnection.errors.failedToSaveConnection")),y("error")}},[k,m,l,s]),E=K.useCallback(async p=>{const z=await G();await Z({hosts:z.hosts,defaultHostId:p,initialHostChoiceCompleted:!0}),await Y()},[]),V=K.useCallback(async()=>{y("testing"),N("");try{const p=await G(),z=await Le(v,p.hosts);await Z({hosts:z.hosts,defaultHostId:z.hostId,initialHostChoiceCompleted:!0}),await Y()}catch(p){N(p instanceof Error&&p.message==="invalid-connect-link"?s("settings.remoteInstances.direct.error.invalidConnectLink"):s("onboarding.remoteConnection.errors.failedToSaveConnection")),y("error")}},[v,s]),c=R==="testing",C=A!==null&&!c,M=A!==null&&!c&&!ie(b?.status??null),_=_e(b?.status??null),O=b?.status==="ok",H=b?.status==="update-recommended",q=b?.status==="auth",P=ie(b?.status??null);return i&&D==="instances"?t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s("desktopHostSwitcher.actions.switchInstance")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s("settings.remoteInstances.direct.description")})]}),S?t.jsx("div",{className:"text-sm text-[var(--status-error)]",children:S}):null,t.jsx("div",{className:"space-y-2",children:T.length===0?t.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:s("settings.remoteInstances.direct.state.empty")}):T.map(p=>t.jsx(L,{variant:"outline",className:"w-full justify-start",onClick:()=>{E(p.id)},children:t.jsx("span",{className:"min-w-0 truncate",children:p.label})},p.id))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(L,{variant:"outline",className:"flex-1",onClick:()=>w("import"),children:s("settings.remoteInstances.direct.import.action")}),t.jsx(L,{className:"flex-1",onClick:()=>w("add"),children:s("settings.remoteInstances.direct.actions.add")})]})]})}):i&&D==="import"?t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsx(L,{variant:"ghost",onClick:()=>w("instances"),className:"p-0 text-muted-foreground",children:s("onboarding.common.actions.back")}),t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s("settings.remoteInstances.direct.import.action")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s("settings.remoteInstances.direct.import.description")})]}),t.jsx(J,{value:v,onChange:p=>j(p.target.value),placeholder:s("settings.remoteInstances.direct.import.placeholder"),disabled:c,autoFocus:!0}),S?t.jsx("div",{className:"text-sm text-[var(--status-error)]",children:S}):null,t.jsx(L,{onClick:()=>{V()},disabled:c||!v.trim(),children:s("settings.remoteInstances.direct.import.action")})]})}):t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[(e||i)&&t.jsx("div",{className:"flex items-center",children:t.jsx(L,{variant:"ghost",onClick:i?()=>w("instances"):r,className:"p-0 text-muted-foreground hover:text-foreground",children:s("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(n?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s("onboarding.remoteConnection.description")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx(J,{id:"remote-url",type:"url",value:h,onChange:B,placeholder:s("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:c})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.nameOptional")}),t.jsx(J,{id:"remote-label",type:"text",value:m,onChange:$,placeholder:s("onboarding.remoteConnection.field.namePlaceholder"),disabled:c})]})]}),b&&O&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:s("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:b.latencyMs})}),b&&q&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:s("onboarding.remoteConnection.status.authWarning")}),b&&H&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:_?s(_):null}),b&&P&&t.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold mb-1",children:s("onboarding.remoteConnection.status.connectionFailed")}),t.jsx("div",{className:"opacity-90",children:_?s(_):null})]}),t.jsx("div",{className:"text-xs opacity-80",children:b.status==="unreachable"?s("onboarding.remoteConnection.status.suggestionsUnreachable"):s("onboarding.remoteConnection.status.suggestionsWrongService")})]}),S&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:S}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(L,{variant:"outline",onClick:W,disabled:!C,children:s(c?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),t.jsx(L,{onClick:f,disabled:!M,children:s("onboarding.remoteConnection.actions.connectAndRestart")})]}),P&&t.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:s("onboarding.remoteConnection.actions.whatToDo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(L,{variant:"outline",size:"sm",onClick:r,className:"flex-1",children:s("onboarding.remoteConnection.actions.chooseDifferentServer")}),!n&&u&&t.jsx(L,{variant:"outline",size:"sm",onClick:u,className:"flex-1",children:s("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const De="curl -fsSL https://opencode.ai/v2/install | bash",we="npm install -g @opencode/cli",Ae="https://opencode.ai/download",me=2500;function Ke(r){const e=Q.c(9),{windows:o,onCopy:a,copyTitle:n}=r;let l;e[0]!==o?(l=t.jsx("code",{className:"flex-1 min-w-0 text-start overflow-x-auto whitespace-nowrap",children:o?t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:we}):t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/v2/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]})}),e[0]=o,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(F,{name:"file-copy",className:"h-4 w-4"}),e[2]=u):u=e[2];let i;e[3]!==n||e[4]!==a?(i=t.jsx("button",{onClick:a,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:n,"aria-label":n,children:u}),e[3]=n,e[4]=a,e[5]=i):i=e[5];let s;return e[6]!==l||e[7]!==i?(s=t.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[l,i]}),e[6]=l,e[7]=i,e[8]=s):s=e[8],s}function Ee(){const r=Q.c(5),e=Se(!0);let o;r[0]!==e?(o=ee("absolute inset-0 rounded-full",e),r[0]=e,r[1]=o):o=r[1];let a;r[2]===Symbol.for("react.memo_cache_sentinel")?(a={backgroundColor:"var(--primary-base)"},r[2]=a):a=r[2];let n;return r[3]!==o?(n=t.jsx("span",{className:o,style:a}),r[3]=o,r[4]=n):n=r[4],n}function Fe({onCliAvailable:r,localAvailable:e=!0}){const{t:o}=oe(),[a,n]=d.useState(!1),[l,u]=d.useState(!1),[i,s]=d.useState(!1),[h,x]=d.useState(!1),[m,U]=d.useState(""),R=he(c=>c.opencodeBinary),[y,b]=d.useState("unknown"),[g,S]=d.useState(()=>e?"local":"remote"),[N,T]=d.useState(!1),[I,D]=d.useState(!1);d.useEffect(()=>{u(X())},[]),d.useEffect(()=>{if(typeof navigator>"u"){b("unknown");return}const c=navigator.userAgent||"";/Windows/i.test(c)?b("windows"):/Macintosh|Mac OS X/i.test(c)?b("macos"):/Linux/i.test(c)?b("linux"):b("unknown")},[]),d.useEffect(()=>{let c=!1;return(async()=>{try{const C=await xe();if(!C||c)return;const M=C.opencodeBinary??"";M&&U(M)}catch{}})(),()=>{c=!0}},[]);const w=d.useCallback(async c=>{const C=c.target;C.closest(".app-region-no-drag")||C.closest("button, a, input, select, textarea, code, summary, details")||c.button===0&&l&&await ge()},[l]),v=d.useCallback(async()=>{try{const c=await te("/health");if(!c.ok)return!1;const C=await c.json();return C.openCodeRunning===!0||C.isOpenCodeReady===!0}catch{return!1}},[]),j=d.useCallback(async c=>{if(!l)return;const C=await G();await Z({...C,...c==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[l]),k=d.useCallback(async()=>{l&&await j("local"),r?.()},[l,r,j]);d.useEffect(()=>{if(!e||g!=="local")return;let c=!1,C=null;const M=async()=>{if(!c){try{const _=await v();if(c)return;if(_){await k();return}}catch{}c||(C=setTimeout(M,me))}};return C=setTimeout(M,me),()=>{c=!0,C&&clearTimeout(C)}},[g,v,k,e]);const A=d.useCallback(async()=>{x(!0);try{await v()&&await k()}finally{x(!1)}},[v,k]),B=d.useCallback(async()=>{if(!(typeof window>"u")&&l)try{const c=await be();c.success&&c.path&&c.path.trim().length>0&&U(c.path.trim())}catch{}},[l]),$=d.useCallback(async()=>{s(!0);try{if(await ye({opencodeBinary:m.trim()}),l){await j("local"),await Y();return}await te("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>s(!1),1e3)}},[l,m,j]),W=d.useCallback(async()=>{const c=await fe(y==="windows"?we:De);c.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",c.error)},[y]),f=Ae,E=y==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":y==="linux"?"/home/you/.opencode/bin/opencode":"/Users/you/.opencode/bin/opencode",V=e&&(!l||g==="local");return t.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:w,children:t.jsxs("div",{className:"w-full max-w-md",children:[t.jsxs("header",{className:"flex flex-col items-center text-center",children:[t.jsx(Ce,{width:48,height:48}),t.jsx("h1",{className:"mt-6 text-xl font-semibold tracking-tight text-foreground",children:o("onboarding.chooser.title")}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:o("onboarding.chooser.description")})]}),l&&e&&t.jsxs("div",{role:"tablist",className:"app-region-no-drag mt-7 flex gap-1 rounded-lg border border-border p-1",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":g==="local",className:ee("flex-1 rounded-md px-3 py-1.5 text-sm transition-colors",g==="local"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]":"text-muted-foreground hover:text-foreground"),onClick:()=>S("local"),children:o("onboarding.chooser.tabs.localInstall")}),t.jsx("button",{type:"button",role:"tab","aria-selected":g==="remote",className:ee("flex-1 rounded-md px-3 py-1.5 text-sm transition-colors",g==="remote"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]":"text-muted-foreground hover:text-foreground"),onClick:()=>S("remote"),children:o("onboarding.chooser.tabs.connectRemote")})]}),l&&g==="remote"?t.jsx("div",{className:"app-region-no-drag mt-6",children:t.jsx(ve,{onBack:()=>e&&S("local"),showBackButton:!1,showInstancePicker:!e,onSwitchToLocal:e?()=>S("local"):void 0})}):null,V&&t.jsxs("div",{className:"mt-6",children:[y==="windows"&&t.jsxs("div",{className:"mb-4 rounded-lg border border-border p-4",children:[t.jsx("div",{className:"text-sm text-foreground",children:o("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 ps-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:o("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:o("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("p",{className:"text-center text-sm leading-relaxed text-muted-foreground text-balance",children:o("onboarding.localSetup.intro")}),t.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:a?t.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(F,{name:"check",className:"h-4 w-4"}),o("onboarding.common.status.copiedToClipboard")]}):t.jsx(Ke,{windows:y==="windows",onCopy:W,copyTitle:o("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag mt-3 flex items-center gap-2.5 px-1",role:"status","aria-live":"polite",children:[t.jsx("span",{className:"relative inline-flex h-2 w-2 shrink-0","aria-hidden":!0,children:t.jsx(Ee,{})}),t.jsxs("span",{className:"min-w-0 flex-1 text-xs text-muted-foreground",children:[t.jsx("span",{className:"text-foreground",children:o("onboarding.localSetup.status.watching")})," · ",o("onboarding.localSetup.status.autoContinue")]}),t.jsx("button",{type:"button",onClick:A,disabled:h,className:"shrink-0 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",children:o(h?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),t.jsxs("div",{className:"mt-6 divide-y divide-border/60 border-y border-border/60",children:[t.jsxs("details",{className:"app-region-no-drag group",open:N,onToggle:c=>T(c.currentTarget.open),children:[t.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:[t.jsx("span",{children:o("onboarding.localSetup.advanced.title")}),t.jsx(F,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsxs("div",{className:"space-y-2 pb-4",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(J,{value:R??m,onChange:c=>U(c.target.value),placeholder:E,disabled:i||R!==null,className:"flex-1 font-mono text-xs"}),R===null&&t.jsxs(t.Fragment,{children:[t.jsx(L,{type:"button",variant:"secondary",size:"sm",onClick:B,disabled:i||!l,children:o("onboarding.localSetup.actions.browse")}),t.jsx(L,{type:"button",size:"sm",onClick:$,disabled:i||!m.trim(),children:o("onboarding.localSetup.actions.apply")})]})]}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:o(R===null?"onboarding.localSetup.helper.saveAndReload":"onboarding.localSetup.helper.pinnedByAdministrator")})]})]}),t.jsxs("details",{className:"app-region-no-drag group",open:I,onToggle:c=>D(c.currentTarget.open),children:[t.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:[t.jsx("span",{children:o("onboarding.localSetup.troubleshoot.title")}),t.jsx(F,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsx("ul",{className:"list-disc space-y-1.5 pb-4 ps-4 text-xs text-muted-foreground",children:y==="windows"?t.jsx("li",{children:o("onboarding.localSetup.windows.hintDetectionFailed")}):t.jsxs(t.Fragment,{children:[t.jsx("li",{children:o("onboarding.localSetup.hint.ensurePath")}),t.jsx("li",{children:o("onboarding.localSetup.hint.setEnv")}),t.jsx("li",{children:o("onboarding.localSetup.hint.missingRuntime")})]})})]})]}),t.jsx("div",{className:"app-region-no-drag mt-5 text-center",children:t.jsxs("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[o(y==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(F,{name:"external-link",className:"h-3 w-3"})]})})]})]})})}const Me="curl -fsSL https://opencode.ai/v2/install | bash",je="npm install -g @opencode/cli",Oe="https://opencode.ai/download";function He(r){const e=Q.c(9),{windows:o,onCopy:a,copyTitle:n}=r;let l;e[0]!==o?(l=t.jsx("code",{className:"flex-1 min-w-0 text-start overflow-x-auto whitespace-nowrap",children:o?t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:je}):t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/v2/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]})}),e[0]=o,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(F,{name:"file-copy",className:"h-4 w-4"}),e[2]=u):u=e[2];let i;e[3]!==n||e[4]!==a?(i=t.jsx("button",{onClick:a,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:n,"aria-label":n,children:u}),e[3]=n,e[4]=a,e[5]=i):i=e[5];let s;return e[6]!==l||e[7]!==i?(s=t.jsxs("div",{className:"flex items-center justify-center gap-3",children:[l,i]}),e[6]=l,e[7]=i,e[8]=s):s=e[8],s}const Pe=3e4;function Be({onBack:r,onCliAvailable:e,isFromRecovery:o=!1,onSwitchToRemote:a}){const{t:n}=oe(),[l,u]=d.useState(!1),[i,s]=d.useState(!1),[h,x]=d.useState(!1),[m,U]=d.useState(!1),[R,y]=d.useState(!1),[b,g]=d.useState(null),[S,N]=d.useState(""),T=he(f=>f.opencodeBinary),[I,D]=d.useState("unknown");d.useEffect(()=>{const f=setTimeout(()=>s(!0),Pe);return()=>clearTimeout(f)},[]),d.useEffect(()=>{x(X())},[]),d.useEffect(()=>{if(typeof navigator>"u"){D("unknown");return}const f=navigator.userAgent||"";if(/Windows/i.test(f)){D("windows");return}if(/Macintosh|Mac OS X/i.test(f)){D("macos");return}if(/Linux/i.test(f)){D("linux");return}D("unknown")},[]),d.useEffect(()=>{let f=!1;return(async()=>{try{const E=await xe();if(!E||f)return;const V=E.opencodeBinary??"";V&&N(V)}catch{}})(),()=>{f=!0}},[]);const w=d.useCallback(async f=>{f.target.closest("button, a, input, select, textarea, code")||f.button===0&&h&&await ge()},[h]),v=d.useCallback(async()=>{try{const f=await te("/health");if(!f.ok)return!1;const E=await f.json();return E.openCodeRunning===!0||E.isOpenCodeReady===!0}catch{return!1}},[]),j=d.useCallback(async()=>{if(!(typeof window>"u")&&h)try{const f=await be();f.success&&f.path&&f.path.trim().length>0&&N(f.path.trim())}catch{}},[h]),k=d.useCallback(async()=>{U(!0);try{if(await ye({opencodeBinary:S.trim()}),h){await Y();return}await te("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>U(!1),1e3)}},[h,S]),A=d.useCallback(async()=>{const f=await fe(I==="windows"?je:Me);f.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error("Failed to copy:",f.error)},[I]),B=d.useCallback(async()=>{y(!0),g(null);try{await v()?e?.():g(n("onboarding.localSetup.errors.cliNotReady"))}catch(f){g(f instanceof Error?f.message:n("onboarding.localSetup.errors.detectionFailed"))}finally{y(!1)}},[v,e,n]),$=Oe,W=I==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":I==="linux"?"/home/you/.opencode/bin/opencode":"/Users/you/.opencode/bin/opencode";return t.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:w,children:[t.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[t.jsx("div",{className:"flex items-center",children:t.jsx(L,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:n("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:n("onboarding.localSetup.title")}),t.jsx("p",{className:"text-muted-foreground",children:n("onboarding.localSetup.description")})]}),I==="windows"&&t.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-start",children:[t.jsx("div",{className:"text-sm text-foreground",children:n("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 ps-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:n("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:n("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:l?t.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(F,{name:"check",className:"h-4 w-4"}),n("onboarding.common.status.copiedToClipboard")]}):t.jsx(He,{windows:I==="windows",onCopy:A,copyTitle:n("onboarding.common.copyToClipboard")})})}),t.jsxs("a",{href:$,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(I==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(F,{name:"external-link",className:"h-3 w-3"})]}),b&&t.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:b}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(L,{type:"button",onClick:B,disabled:R,className:"w-full max-w-xs",size:"lg",children:n(R?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:n("onboarding.localSetup.helper.checkAndContinue")})]}),t.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:n("onboarding.localSetup.field.alreadyInstalled")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(J,{value:T??S,onChange:f=>N(f.target.value),placeholder:W,disabled:m||T!==null,className:"flex-1 font-mono text-xs"}),T===null&&t.jsxs(t.Fragment,{children:[t.jsx(L,{type:"button",variant:"secondary",onClick:j,disabled:m||!h,children:n("onboarding.localSetup.actions.browse")}),t.jsx(L,{type:"button",onClick:k,disabled:m,children:n("onboarding.localSetup.actions.apply")})]})]}),t.jsx("div",{className:"text-xs text-muted-foreground/70",children:n(T===null?"onboarding.localSetup.helper.saveAndReload":"onboarding.localSetup.helper.pinnedByAdministrator")})]})}),o&&a&&t.jsxs("div",{className:"text-center pt-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:n("onboarding.localSetup.remotePreference")}),t.jsx(L,{variant:"link",onClick:a,children:n("onboarding.localSetup.actions.connectRemoteServer")})]})]}),i&&t.jsx("div",{className:"absolute bottom-8 inset-s-0 inset-e-0 text-center space-y-1",children:I==="windows"?t.jsx(t.Fragment,{children:t.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.ensurePath")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.setEnv")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.missingRuntime")})]})})]})}function le(r,e){if(r?.trim())return ce(r.trim());if(e)return ce(e)}function $e(r,e,o){switch(r){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const a=le(e,o);return{title:"Remote Server Unreachable",description:`Could not connect to "${a||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:a?{host:a}: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 a=le(e,o);return{title:"Incompatible Server",description:`The server at "${a||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:a?{host:a}: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 a=le(e,o);return{title:"Server Update Required",description:`The OpenChamber server at "${a||"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:a?{host:a}: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 a=r;throw new Error(`Unknown recovery variant: ${a}`)}}}const We="openchamber update";function Ve(r){const e=Q.c(17),{state:o}=r,{t:a}=oe();if(o.kind==="idle"||o.kind==="updating")return null;let n;e[0]!==o.kind||e[1]!==a?(n=o.kind==="refused"?a("onboarding.desktopRecovery.remoteIncompatible.updateRefused"):o.kind==="auth"?a("onboarding.desktopRecovery.remoteIncompatible.updateAuth"):a("onboarding.desktopRecovery.remoteIncompatible.updateTimeout"),e[0]=o.kind,e[1]=a,e[2]=n):n=e[2];const l=n;let u;e[3]!==l?(u=t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:l}),e[3]=l,e[4]=u):u=e[4];let i;e[5]!==o.error||e[6]!==o.kind?(i=o.kind==="refused"&&o.error&&t.jsx("p",{className:"typography-meta text-muted-foreground",children:o.error}),e[5]=o.error,e[6]=o.kind,e[7]=i):i=e[7];let s;e[8]!==a?(s=a("onboarding.desktopRecovery.remoteIncompatible.manualUpdate"),e[8]=a,e[9]=s):s=e[9];let h;e[10]!==s?(h=t.jsx("p",{className:"typography-meta text-muted-foreground",children:s}),e[10]=s,e[11]=h):h=e[11];let x;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("code",{className:"block select-text rounded-md border border-border bg-background/50 px-3 py-2 font-mono text-sm text-foreground",children:We}),e[12]=x):x=e[12];let m;return e[13]!==u||e[14]!==i||e[15]!==h?(m=t.jsxs("div",{className:"space-y-2",children:[u,i,h,x]}),e[13]=u,e[14]=i,e[15]=h,e[16]=m):m=e[16],m}function ze(r){switch(r){case"local":return t.jsx(F,{name:"macbook",className:"h-8 w-8"});case"remote":return t.jsx(F,{name:"server",className:"h-8 w-8"})}}function Ye({variant:r,hostLabel:e,hostUrl:o,onRetry:a,onUseLocal:n,onUseRemote:l,isRetrying:u=!1,onUpdateServer:i,serverUpdate:s={kind:"idle"}}){const h=s.kind==="updating",{t:x}=oe(),m=$e(r,e,o),U=m.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",R=d.useMemo(()=>{if(m.descriptionParams?.host)return m.descriptionParams;if(r==="remote-unreachable")return{host:x("onboarding.desktopRecovery.placeholders.remoteServer")};if(r==="remote-wrong-service"||r==="remote-incompatible")return{host:x("onboarding.desktopRecovery.placeholders.unknownServer")}},[m.descriptionParams,x,r]);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[t.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:t.jsx("div",{style:{color:"var(--status-warning)"},children:ze(m.iconKey)})}),t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:x(m.titleKey)}),t.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:x(m.descriptionKey,R)})]}),o&&(r==="remote-unreachable"||r==="remote-wrong-service"||r==="remote-incompatible")&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:x("onboarding.remoteConnection.field.serverAddress")}),t.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:ce(o)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[i&&t.jsxs(t.Fragment,{children:[t.jsxs(L,{onClick:i,disabled:h||u,className:"w-full",children:[t.jsx(F,{name:h?"loader":"download",className:ee("h-4 w-4",h&&"animate-spin")}),x(h?"onboarding.desktopRecovery.remoteIncompatible.updatingServer":"onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),h&&t.jsx("p",{className:"typography-meta text-center text-muted-foreground",children:x("onboarding.desktopRecovery.remoteIncompatible.updatingHint")}),t.jsx(Ve,{state:s})]}),m.showRetry&&a&&t.jsxs(L,{onClick:a,disabled:u||h,variant:i?"outline":"default",className:"w-full",children:[t.jsx(F,{name:"refresh",className:ee("h-4 w-4",u&&"animate-spin")}),x(u?"onboarding.desktopRecovery.actions.retrying":U)]}),t.jsxs("div",{className:"flex gap-2",children:[m.showUseLocal&&n&&t.jsxs(L,{variant:"outline",onClick:n,disabled:u||h,className:"flex-1",children:[t.jsx(F,{name:"macbook",className:"h-4 w-4"}),x(m.useLocalLabelKey)]}),m.showUseRemote&&l&&t.jsxs(L,{variant:"outline",onClick:l,disabled:u||h,className:"flex-1",children:[t.jsx(F,{name:"server",className:"h-4 w-4"}),x(m.useRemoteLabelKey)]})]})]})]})})}function pe(r,e){if(e==="use-remote")return{kind:"remote-form"};switch(r){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const o=r;throw new Error(`Unhandled RecoveryVariant: ${o}`)}}}function Xe(r){const e=Q.c(39),{variant:o,hostUrl:a,hostLabel:n,hostId:l,onRetry:u,onChooseRemote:i,showRemoteForm:s,onCloseRemoteForm:h,onSwitchToLocalFromRemote:x,onEnterLocalSetup:m,isRetrying:U,localAvailable:R}=r,y=s===void 0?!1:s,b=U===void 0?!1:U,g=R===void 0?!0:R,S=Ge;let N;e[0]!==u?(N=async()=>{if(X()){await Y();return}await te("/api/config/reload",{method:"POST"}),u?.()},e[0]=u,e[1]=N):N=e[1];const T=N;let I;e[2]!==m||e[3]!==o?(I=async()=>{if(pe(o,"use-local").kind==="local-setup"){m?.();return}if(await S("local"),X()){await Y();return}window.location.reload()},e[2]=m,e[3]=o,e[4]=I):I=e[4];const D=I;let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w={kind:"idle"},e[5]=w):w=e[5];const[v,j]=d.useState(w),[k,A]=d.useState(null);let B,$;e[6]!==l||e[7]!==o?(B=()=>{if(A(null),o!=="remote-incompatible"||!l||!X())return;let _=!1;return G().then(O=>{const H=O.hosts.find(P=>P.id===l),q=Ue(H?.apiUrl||H?.url||"");!_&&q&&A(l)}).catch(qe),()=>{_=!0}},$=[o,l],e[6]=l,e[7]=o,e[8]=B,e[9]=$):(B=e[8],$=e[9]),d.useEffect(B,$);let W;e[10]===Symbol.for("react.memo_cache_sentinel")?(W=async _=>{j({kind:"updating"});try{const O=await Ie(_);if(O.status==="auth"){j({kind:"auth"});return}if(O.status==="failed"){j({kind:"refused",error:O.error});return}if(await Te(_)==="timeout"){j({kind:"timeout"});return}await Y()||j({kind:"idle"})}catch{j({kind:"timeout"})}},e[10]=W):W=e[10];const f=W;let E;e[11]!==i||e[12]!==o?(E=()=>{pe(o,"use-remote").kind==="remote-form"&&i?.()},e[11]=i,e[12]=o,e[13]=E):E=e[13];const V=E;if(y){const _=o==="remote-wrong-service"?"":a||"",O=o==="remote-wrong-service"?"":n||"";let H;e[14]!==i||e[15]!==h?(H=h||(()=>i?.()),e[14]=i,e[15]=h,e[16]=H):H=e[16];const q=!g;let P;e[17]!==g||e[18]!==m||e[19]!==x?(P=g?x||(()=>{S("local").then(()=>{X()?Y():m?.()})}):void 0,e[17]=g,e[18]=m,e[19]=x,e[20]=P):P=e[20];let p;return e[21]!==O||e[22]!==_||e[23]!==H||e[24]!==q||e[25]!==P?(p=t.jsx(ve,{onBack:H,initialUrl:_,initialLabel:O,isRecoveryMode:!0,showInstancePicker:q,onSwitchToLocal:P}),e[21]=O,e[22]=_,e[23]=H,e[24]=q,e[25]=P,e[26]=p):p=e[26],p}const c=g?D:void 0;let C;e[27]!==k?(C=k?()=>{f(k)}:void 0,e[27]=k,e[28]=C):C=e[28];let M;return e[29]!==T||e[30]!==V||e[31]!==n||e[32]!==a||e[33]!==b||e[34]!==v||e[35]!==c||e[36]!==C||e[37]!==o?(M=t.jsx(Ye,{variant:o,hostLabel:n,hostUrl:a,onRetry:T,onUseLocal:c,onUseRemote:V,isRetrying:b,onUpdateServer:C,serverUpdate:v}),e[29]=T,e[30]=V,e[31]=n,e[32]=a,e[33]=b,e[34]=v,e[35]=c,e[36]=C,e[37]=o,e[38]=M):M=e[38],M}function qe(){}async function Ge(r){if(!X())return;const e=await G();await Z({...e,...r==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function So(r){const e=Q.c(30),{onBack:o,onCliAvailable:a,mode:n,recoveryVariant:l,recoveryHostUrl:u,recoveryHostLabel:i,recoveryHostId:s,onEnterLocalSetup:h,localAvailable:x}=r,m=n===void 0?"first-launch":n,U=l===void 0?"missing-default-host":l,R=x===void 0?!0:x,[y,b]=d.useState(!1),[g,S]=d.useState(!1);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{S(!1),b(!1)},e[0]=N):N=e[0];let T;e[1]!==m||e[2]!==i||e[3]!==u||e[4]!==U?(T=[m,U,u,i],e[1]=m,e[2]=i,e[3]=u,e[4]=U,e[5]=T):T=e[5],d.useEffect(N,T);const I=g?"local-setup":m;if(I==="recovery"){let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=()=>b(!0),e[6]=w):w=e[6];let v,j;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>b(!1),j=()=>{b(!1),S(!0)},e[7]=v,e[8]=j):(v=e[7],j=e[8]);let k;e[9]!==h?(k=()=>{S(!0),h?.()},e[9]=h,e[10]=k):k=e[10];let A;return e[11]!==R||e[12]!==s||e[13]!==i||e[14]!==u||e[15]!==U||e[16]!==y||e[17]!==k?(A=t.jsx(Xe,{variant:U,hostUrl:u,hostLabel:i,hostId:s,onChooseRemote:w,showRemoteForm:y,onCloseRemoteForm:v,onSwitchToLocalFromRemote:j,onEnterLocalSetup:k,localAvailable:R}),e[11]=R,e[12]=s,e[13]=i,e[14]=u,e[15]=U,e[16]=y,e[17]=k,e[18]=A):A=e[18],A}if(I==="local-setup"){let w;e[19]!==o||e[20]!==g?(w=()=>{g?S(!1):o?.()},e[19]=o,e[20]=g,e[21]=w):w=e[21];let v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=()=>b(!0),e[22]=v):v=e[22];let j;return e[23]!==a||e[24]!==g||e[25]!==w?(j=t.jsx(Be,{onBack:w,onCliAvailable:a,isFromRecovery:g,onSwitchToRemote:v}),e[23]=a,e[24]=g,e[25]=w,e[26]=j):j=e[26],j}let D;return e[27]!==R||e[28]!==a?(D=t.jsx(Fe,{onCliAvailable:a,localAvailable:R}),e[27]=R,e[28]=a,e[29]=D):D=e[29],D}export{So as OnboardingScreen};
|
|
1
|
+
import{r as K,j as t,R as d,f as Q}from"./vendor-react-BUCujlKS.js";import{u as oe,B as L,y as J,eU as he,aA as fe,ac as Ce,N as ee,I as F,al as Se}from"./useAppFontEffects-DAUhSLPu.js";import{aL as G,aM as Re,aN as ue,aO as Z,ax as X,aP as Y,aQ as Le,aR as xe,aS as ge,k as te,aT as be,aU as ye,aV as ce,aW as Ue,aX as Ie,aY as Te}from"./katex.min-u4DtE8E5.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-zod-DDir2TeQ.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.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-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-KulAIuMz.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.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-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-client-h8RufjAw.js";function _e(r){switch(r){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function ie(r){return r==="wrong-service"||r==="unreachable"||r==="incompatible"}function ve({onBack:r,showBackButton:e=!0,initialUrl:o="",initialLabel:a="",isRecoveryMode:n=!1,onConnect:l,onSwitchToLocal:u,showInstancePicker:i=!1}){const{t:s}=oe(),[h,x]=K.useState(o),[m,U]=K.useState(a),[R,y]=K.useState("idle"),[b,g]=K.useState(null),[S,N]=K.useState(""),[T,I]=K.useState([]),[D,w]=K.useState(()=>i?"instances":"add"),[v,j]=K.useState("");K.useEffect(()=>{i&&G().then(p=>I(p.hosts)).catch(p=>{N(p instanceof Error?p.message:String(p))})},[i]);const k=Re(h),A=k?.persistedUrl??null,B=K.useCallback(p=>{x(p.target.value),y("idle"),g(null),N("")},[]),$=K.useCallback(p=>{U(p.target.value)},[]),W=K.useCallback(async()=>{if(A){y("testing"),g(null),N("");try{const p=await ue(A);g(p),y(p.status==="ok"||p.status==="update-recommended"?"success":"error")}catch(p){N(p instanceof Error?p.message:s("onboarding.remoteConnection.errors.connectionTestFailed")),y("error")}}},[A,s]),f=K.useCallback(async()=>{if(!k)return;const p=k.persistedUrl;y("testing"),g(null),N("");try{const z=await ue(p);if(g(z),ie(z.status)){y("error");return}const ne=await G(),ke=m.trim()||p,re=ne.hosts.find(se=>se.url===p),ae=re?re.id:`host-${Date.now().toString(16)}`,de={id:ae,label:ke,url:p,apiUrl:p},Ne=re?ne.hosts.map(se=>se.id===ae?de:se):[...ne.hosts,de];if(await Z({hosts:Ne,defaultHostId:ae,initialHostChoiceCompleted:!0}),l?.(),k.redeemUrl){window.location.assign(k.redeemUrl);return}X()&&await Y()}catch(z){N(z instanceof Error?z.message:s("onboarding.remoteConnection.errors.failedToSaveConnection")),y("error")}},[k,m,l,s]),E=K.useCallback(async p=>{const z=await G();await Z({hosts:z.hosts,defaultHostId:p,initialHostChoiceCompleted:!0}),await Y()},[]),V=K.useCallback(async()=>{y("testing"),N("");try{const p=await G(),z=await Le(v,p.hosts);await Z({hosts:z.hosts,defaultHostId:z.hostId,initialHostChoiceCompleted:!0}),await Y()}catch(p){N(p instanceof Error&&p.message==="invalid-connect-link"?s("settings.remoteInstances.direct.error.invalidConnectLink"):s("onboarding.remoteConnection.errors.failedToSaveConnection")),y("error")}},[v,s]),c=R==="testing",C=A!==null&&!c,M=A!==null&&!c&&!ie(b?.status??null),_=_e(b?.status??null),O=b?.status==="ok",H=b?.status==="update-recommended",q=b?.status==="auth",P=ie(b?.status??null);return i&&D==="instances"?t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s("desktopHostSwitcher.actions.switchInstance")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s("settings.remoteInstances.direct.description")})]}),S?t.jsx("div",{className:"text-sm text-[var(--status-error)]",children:S}):null,t.jsx("div",{className:"space-y-2",children:T.length===0?t.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:s("settings.remoteInstances.direct.state.empty")}):T.map(p=>t.jsx(L,{variant:"outline",className:"w-full justify-start",onClick:()=>{E(p.id)},children:t.jsx("span",{className:"min-w-0 truncate",children:p.label})},p.id))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(L,{variant:"outline",className:"flex-1",onClick:()=>w("import"),children:s("settings.remoteInstances.direct.import.action")}),t.jsx(L,{className:"flex-1",onClick:()=>w("add"),children:s("settings.remoteInstances.direct.actions.add")})]})]})}):i&&D==="import"?t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsx(L,{variant:"ghost",onClick:()=>w("instances"),className:"p-0 text-muted-foreground",children:s("onboarding.common.actions.back")}),t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s("settings.remoteInstances.direct.import.action")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s("settings.remoteInstances.direct.import.description")})]}),t.jsx(J,{value:v,onChange:p=>j(p.target.value),placeholder:s("settings.remoteInstances.direct.import.placeholder"),disabled:c,autoFocus:!0}),S?t.jsx("div",{className:"text-sm text-[var(--status-error)]",children:S}):null,t.jsx(L,{onClick:()=>{V()},disabled:c||!v.trim(),children:s("settings.remoteInstances.direct.import.action")})]})}):t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[(e||i)&&t.jsx("div",{className:"flex items-center",children:t.jsx(L,{variant:"ghost",onClick:i?()=>w("instances"):r,className:"p-0 text-muted-foreground hover:text-foreground",children:s("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(n?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s("onboarding.remoteConnection.description")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx(J,{id:"remote-url",type:"url",value:h,onChange:B,placeholder:s("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:c})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.nameOptional")}),t.jsx(J,{id:"remote-label",type:"text",value:m,onChange:$,placeholder:s("onboarding.remoteConnection.field.namePlaceholder"),disabled:c})]})]}),b&&O&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:s("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:b.latencyMs})}),b&&q&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:s("onboarding.remoteConnection.status.authWarning")}),b&&H&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:_?s(_):null}),b&&P&&t.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold mb-1",children:s("onboarding.remoteConnection.status.connectionFailed")}),t.jsx("div",{className:"opacity-90",children:_?s(_):null})]}),t.jsx("div",{className:"text-xs opacity-80",children:b.status==="unreachable"?s("onboarding.remoteConnection.status.suggestionsUnreachable"):s("onboarding.remoteConnection.status.suggestionsWrongService")})]}),S&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:S}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(L,{variant:"outline",onClick:W,disabled:!C,children:s(c?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),t.jsx(L,{onClick:f,disabled:!M,children:s("onboarding.remoteConnection.actions.connectAndRestart")})]}),P&&t.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:s("onboarding.remoteConnection.actions.whatToDo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(L,{variant:"outline",size:"sm",onClick:r,className:"flex-1",children:s("onboarding.remoteConnection.actions.chooseDifferentServer")}),!n&&u&&t.jsx(L,{variant:"outline",size:"sm",onClick:u,className:"flex-1",children:s("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const De="curl -fsSL https://opencode.ai/v2/install | bash",we="npm install -g @opencode/cli",Ae="https://opencode.ai/download",me=2500;function Ke(r){const e=Q.c(9),{windows:o,onCopy:a,copyTitle:n}=r;let l;e[0]!==o?(l=t.jsx("code",{className:"flex-1 min-w-0 text-start overflow-x-auto whitespace-nowrap",children:o?t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:we}):t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/v2/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]})}),e[0]=o,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(F,{name:"file-copy",className:"h-4 w-4"}),e[2]=u):u=e[2];let i;e[3]!==n||e[4]!==a?(i=t.jsx("button",{onClick:a,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:n,"aria-label":n,children:u}),e[3]=n,e[4]=a,e[5]=i):i=e[5];let s;return e[6]!==l||e[7]!==i?(s=t.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[l,i]}),e[6]=l,e[7]=i,e[8]=s):s=e[8],s}function Ee(){const r=Q.c(5),e=Se(!0);let o;r[0]!==e?(o=ee("absolute inset-0 rounded-full",e),r[0]=e,r[1]=o):o=r[1];let a;r[2]===Symbol.for("react.memo_cache_sentinel")?(a={backgroundColor:"var(--primary-base)"},r[2]=a):a=r[2];let n;return r[3]!==o?(n=t.jsx("span",{className:o,style:a}),r[3]=o,r[4]=n):n=r[4],n}function Fe({onCliAvailable:r,localAvailable:e=!0}){const{t:o}=oe(),[a,n]=d.useState(!1),[l,u]=d.useState(!1),[i,s]=d.useState(!1),[h,x]=d.useState(!1),[m,U]=d.useState(""),R=he(c=>c.opencodeBinary),[y,b]=d.useState("unknown"),[g,S]=d.useState(()=>e?"local":"remote"),[N,T]=d.useState(!1),[I,D]=d.useState(!1);d.useEffect(()=>{u(X())},[]),d.useEffect(()=>{if(typeof navigator>"u"){b("unknown");return}const c=navigator.userAgent||"";/Windows/i.test(c)?b("windows"):/Macintosh|Mac OS X/i.test(c)?b("macos"):/Linux/i.test(c)?b("linux"):b("unknown")},[]),d.useEffect(()=>{let c=!1;return(async()=>{try{const C=await xe();if(!C||c)return;const M=C.opencodeBinary??"";M&&U(M)}catch{}})(),()=>{c=!0}},[]);const w=d.useCallback(async c=>{const C=c.target;C.closest(".app-region-no-drag")||C.closest("button, a, input, select, textarea, code, summary, details")||c.button===0&&l&&await ge()},[l]),v=d.useCallback(async()=>{try{const c=await te("/health");if(!c.ok)return!1;const C=await c.json();return C.openCodeRunning===!0||C.isOpenCodeReady===!0}catch{return!1}},[]),j=d.useCallback(async c=>{if(!l)return;const C=await G();await Z({...C,...c==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[l]),k=d.useCallback(async()=>{l&&await j("local"),r?.()},[l,r,j]);d.useEffect(()=>{if(!e||g!=="local")return;let c=!1,C=null;const M=async()=>{if(!c){try{const _=await v();if(c)return;if(_){await k();return}}catch{}c||(C=setTimeout(M,me))}};return C=setTimeout(M,me),()=>{c=!0,C&&clearTimeout(C)}},[g,v,k,e]);const A=d.useCallback(async()=>{x(!0);try{await v()&&await k()}finally{x(!1)}},[v,k]),B=d.useCallback(async()=>{if(!(typeof window>"u")&&l)try{const c=await be();c.success&&c.path&&c.path.trim().length>0&&U(c.path.trim())}catch{}},[l]),$=d.useCallback(async()=>{s(!0);try{if(await ye({opencodeBinary:m.trim()}),l){await j("local"),await Y();return}await te("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>s(!1),1e3)}},[l,m,j]),W=d.useCallback(async()=>{const c=await fe(y==="windows"?we:De);c.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",c.error)},[y]),f=Ae,E=y==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":y==="linux"?"/home/you/.opencode/bin/opencode":"/Users/you/.opencode/bin/opencode",V=e&&(!l||g==="local");return t.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:w,children:t.jsxs("div",{className:"w-full max-w-md",children:[t.jsxs("header",{className:"flex flex-col items-center text-center",children:[t.jsx(Ce,{width:48,height:48}),t.jsx("h1",{className:"mt-6 text-xl font-semibold tracking-tight text-foreground",children:o("onboarding.chooser.title")}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:o("onboarding.chooser.description")})]}),l&&e&&t.jsxs("div",{role:"tablist",className:"app-region-no-drag mt-7 flex gap-1 rounded-lg border border-border p-1",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":g==="local",className:ee("flex-1 rounded-md px-3 py-1.5 text-sm transition-colors",g==="local"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]":"text-muted-foreground hover:text-foreground"),onClick:()=>S("local"),children:o("onboarding.chooser.tabs.localInstall")}),t.jsx("button",{type:"button",role:"tab","aria-selected":g==="remote",className:ee("flex-1 rounded-md px-3 py-1.5 text-sm transition-colors",g==="remote"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]":"text-muted-foreground hover:text-foreground"),onClick:()=>S("remote"),children:o("onboarding.chooser.tabs.connectRemote")})]}),l&&g==="remote"?t.jsx("div",{className:"app-region-no-drag mt-6",children:t.jsx(ve,{onBack:()=>e&&S("local"),showBackButton:!1,showInstancePicker:!e,onSwitchToLocal:e?()=>S("local"):void 0})}):null,V&&t.jsxs("div",{className:"mt-6",children:[y==="windows"&&t.jsxs("div",{className:"mb-4 rounded-lg border border-border p-4",children:[t.jsx("div",{className:"text-sm text-foreground",children:o("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 ps-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:o("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:o("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("p",{className:"text-center text-sm leading-relaxed text-muted-foreground text-balance",children:o("onboarding.localSetup.intro")}),t.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:a?t.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(F,{name:"check",className:"h-4 w-4"}),o("onboarding.common.status.copiedToClipboard")]}):t.jsx(Ke,{windows:y==="windows",onCopy:W,copyTitle:o("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag mt-3 flex items-center gap-2.5 px-1",role:"status","aria-live":"polite",children:[t.jsx("span",{className:"relative inline-flex h-2 w-2 shrink-0","aria-hidden":!0,children:t.jsx(Ee,{})}),t.jsxs("span",{className:"min-w-0 flex-1 text-xs text-muted-foreground",children:[t.jsx("span",{className:"text-foreground",children:o("onboarding.localSetup.status.watching")})," · ",o("onboarding.localSetup.status.autoContinue")]}),t.jsx("button",{type:"button",onClick:A,disabled:h,className:"shrink-0 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",children:o(h?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),t.jsxs("div",{className:"mt-6 divide-y divide-border/60 border-y border-border/60",children:[t.jsxs("details",{className:"app-region-no-drag group",open:N,onToggle:c=>T(c.currentTarget.open),children:[t.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:[t.jsx("span",{children:o("onboarding.localSetup.advanced.title")}),t.jsx(F,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsxs("div",{className:"space-y-2 pb-4",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(J,{value:R??m,onChange:c=>U(c.target.value),placeholder:E,disabled:i||R!==null,className:"flex-1 font-mono text-xs"}),R===null&&t.jsxs(t.Fragment,{children:[t.jsx(L,{type:"button",variant:"secondary",size:"sm",onClick:B,disabled:i||!l,children:o("onboarding.localSetup.actions.browse")}),t.jsx(L,{type:"button",size:"sm",onClick:$,disabled:i||!m.trim(),children:o("onboarding.localSetup.actions.apply")})]})]}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:o(R===null?"onboarding.localSetup.helper.saveAndReload":"onboarding.localSetup.helper.pinnedByAdministrator")})]})]}),t.jsxs("details",{className:"app-region-no-drag group",open:I,onToggle:c=>D(c.currentTarget.open),children:[t.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:[t.jsx("span",{children:o("onboarding.localSetup.troubleshoot.title")}),t.jsx(F,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsx("ul",{className:"list-disc space-y-1.5 pb-4 ps-4 text-xs text-muted-foreground",children:y==="windows"?t.jsx("li",{children:o("onboarding.localSetup.windows.hintDetectionFailed")}):t.jsxs(t.Fragment,{children:[t.jsx("li",{children:o("onboarding.localSetup.hint.ensurePath")}),t.jsx("li",{children:o("onboarding.localSetup.hint.setEnv")}),t.jsx("li",{children:o("onboarding.localSetup.hint.missingRuntime")})]})})]})]}),t.jsx("div",{className:"app-region-no-drag mt-5 text-center",children:t.jsxs("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[o(y==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(F,{name:"external-link",className:"h-3 w-3"})]})})]})]})})}const Me="curl -fsSL https://opencode.ai/v2/install | bash",je="npm install -g @opencode/cli",Oe="https://opencode.ai/download";function He(r){const e=Q.c(9),{windows:o,onCopy:a,copyTitle:n}=r;let l;e[0]!==o?(l=t.jsx("code",{className:"flex-1 min-w-0 text-start overflow-x-auto whitespace-nowrap",children:o?t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:je}):t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/v2/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]})}),e[0]=o,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(F,{name:"file-copy",className:"h-4 w-4"}),e[2]=u):u=e[2];let i;e[3]!==n||e[4]!==a?(i=t.jsx("button",{onClick:a,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:n,"aria-label":n,children:u}),e[3]=n,e[4]=a,e[5]=i):i=e[5];let s;return e[6]!==l||e[7]!==i?(s=t.jsxs("div",{className:"flex items-center justify-center gap-3",children:[l,i]}),e[6]=l,e[7]=i,e[8]=s):s=e[8],s}const Pe=3e4;function Be({onBack:r,onCliAvailable:e,isFromRecovery:o=!1,onSwitchToRemote:a}){const{t:n}=oe(),[l,u]=d.useState(!1),[i,s]=d.useState(!1),[h,x]=d.useState(!1),[m,U]=d.useState(!1),[R,y]=d.useState(!1),[b,g]=d.useState(null),[S,N]=d.useState(""),T=he(f=>f.opencodeBinary),[I,D]=d.useState("unknown");d.useEffect(()=>{const f=setTimeout(()=>s(!0),Pe);return()=>clearTimeout(f)},[]),d.useEffect(()=>{x(X())},[]),d.useEffect(()=>{if(typeof navigator>"u"){D("unknown");return}const f=navigator.userAgent||"";if(/Windows/i.test(f)){D("windows");return}if(/Macintosh|Mac OS X/i.test(f)){D("macos");return}if(/Linux/i.test(f)){D("linux");return}D("unknown")},[]),d.useEffect(()=>{let f=!1;return(async()=>{try{const E=await xe();if(!E||f)return;const V=E.opencodeBinary??"";V&&N(V)}catch{}})(),()=>{f=!0}},[]);const w=d.useCallback(async f=>{f.target.closest("button, a, input, select, textarea, code")||f.button===0&&h&&await ge()},[h]),v=d.useCallback(async()=>{try{const f=await te("/health");if(!f.ok)return!1;const E=await f.json();return E.openCodeRunning===!0||E.isOpenCodeReady===!0}catch{return!1}},[]),j=d.useCallback(async()=>{if(!(typeof window>"u")&&h)try{const f=await be();f.success&&f.path&&f.path.trim().length>0&&N(f.path.trim())}catch{}},[h]),k=d.useCallback(async()=>{U(!0);try{if(await ye({opencodeBinary:S.trim()}),h){await Y();return}await te("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>U(!1),1e3)}},[h,S]),A=d.useCallback(async()=>{const f=await fe(I==="windows"?je:Me);f.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error("Failed to copy:",f.error)},[I]),B=d.useCallback(async()=>{y(!0),g(null);try{await v()?e?.():g(n("onboarding.localSetup.errors.cliNotReady"))}catch(f){g(f instanceof Error?f.message:n("onboarding.localSetup.errors.detectionFailed"))}finally{y(!1)}},[v,e,n]),$=Oe,W=I==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":I==="linux"?"/home/you/.opencode/bin/opencode":"/Users/you/.opencode/bin/opencode";return t.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:w,children:[t.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[t.jsx("div",{className:"flex items-center",children:t.jsx(L,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:n("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:n("onboarding.localSetup.title")}),t.jsx("p",{className:"text-muted-foreground",children:n("onboarding.localSetup.description")})]}),I==="windows"&&t.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-start",children:[t.jsx("div",{className:"text-sm text-foreground",children:n("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 ps-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:n("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:n("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:l?t.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(F,{name:"check",className:"h-4 w-4"}),n("onboarding.common.status.copiedToClipboard")]}):t.jsx(He,{windows:I==="windows",onCopy:A,copyTitle:n("onboarding.common.copyToClipboard")})})}),t.jsxs("a",{href:$,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(I==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(F,{name:"external-link",className:"h-3 w-3"})]}),b&&t.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:b}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(L,{type:"button",onClick:B,disabled:R,className:"w-full max-w-xs",size:"lg",children:n(R?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:n("onboarding.localSetup.helper.checkAndContinue")})]}),t.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:n("onboarding.localSetup.field.alreadyInstalled")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(J,{value:T??S,onChange:f=>N(f.target.value),placeholder:W,disabled:m||T!==null,className:"flex-1 font-mono text-xs"}),T===null&&t.jsxs(t.Fragment,{children:[t.jsx(L,{type:"button",variant:"secondary",onClick:j,disabled:m||!h,children:n("onboarding.localSetup.actions.browse")}),t.jsx(L,{type:"button",onClick:k,disabled:m,children:n("onboarding.localSetup.actions.apply")})]})]}),t.jsx("div",{className:"text-xs text-muted-foreground/70",children:n(T===null?"onboarding.localSetup.helper.saveAndReload":"onboarding.localSetup.helper.pinnedByAdministrator")})]})}),o&&a&&t.jsxs("div",{className:"text-center pt-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:n("onboarding.localSetup.remotePreference")}),t.jsx(L,{variant:"link",onClick:a,children:n("onboarding.localSetup.actions.connectRemoteServer")})]})]}),i&&t.jsx("div",{className:"absolute bottom-8 inset-s-0 inset-e-0 text-center space-y-1",children:I==="windows"?t.jsx(t.Fragment,{children:t.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.ensurePath")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.setEnv")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.missingRuntime")})]})})]})}function le(r,e){if(r?.trim())return ce(r.trim());if(e)return ce(e)}function $e(r,e,o){switch(r){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const a=le(e,o);return{title:"Remote Server Unreachable",description:`Could not connect to "${a||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:a?{host:a}: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 a=le(e,o);return{title:"Incompatible Server",description:`The server at "${a||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:a?{host:a}: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 a=le(e,o);return{title:"Server Update Required",description:`The OpenChamber server at "${a||"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:a?{host:a}: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 a=r;throw new Error(`Unknown recovery variant: ${a}`)}}}const We="openchamber update";function Ve(r){const e=Q.c(17),{state:o}=r,{t:a}=oe();if(o.kind==="idle"||o.kind==="updating")return null;let n;e[0]!==o.kind||e[1]!==a?(n=o.kind==="refused"?a("onboarding.desktopRecovery.remoteIncompatible.updateRefused"):o.kind==="auth"?a("onboarding.desktopRecovery.remoteIncompatible.updateAuth"):a("onboarding.desktopRecovery.remoteIncompatible.updateTimeout"),e[0]=o.kind,e[1]=a,e[2]=n):n=e[2];const l=n;let u;e[3]!==l?(u=t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:l}),e[3]=l,e[4]=u):u=e[4];let i;e[5]!==o.error||e[6]!==o.kind?(i=o.kind==="refused"&&o.error&&t.jsx("p",{className:"typography-meta text-muted-foreground",children:o.error}),e[5]=o.error,e[6]=o.kind,e[7]=i):i=e[7];let s;e[8]!==a?(s=a("onboarding.desktopRecovery.remoteIncompatible.manualUpdate"),e[8]=a,e[9]=s):s=e[9];let h;e[10]!==s?(h=t.jsx("p",{className:"typography-meta text-muted-foreground",children:s}),e[10]=s,e[11]=h):h=e[11];let x;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("code",{className:"block select-text rounded-md border border-border bg-background/50 px-3 py-2 font-mono text-sm text-foreground",children:We}),e[12]=x):x=e[12];let m;return e[13]!==u||e[14]!==i||e[15]!==h?(m=t.jsxs("div",{className:"space-y-2",children:[u,i,h,x]}),e[13]=u,e[14]=i,e[15]=h,e[16]=m):m=e[16],m}function ze(r){switch(r){case"local":return t.jsx(F,{name:"macbook",className:"h-8 w-8"});case"remote":return t.jsx(F,{name:"server",className:"h-8 w-8"})}}function Ye({variant:r,hostLabel:e,hostUrl:o,onRetry:a,onUseLocal:n,onUseRemote:l,isRetrying:u=!1,onUpdateServer:i,serverUpdate:s={kind:"idle"}}){const h=s.kind==="updating",{t:x}=oe(),m=$e(r,e,o),U=m.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",R=d.useMemo(()=>{if(m.descriptionParams?.host)return m.descriptionParams;if(r==="remote-unreachable")return{host:x("onboarding.desktopRecovery.placeholders.remoteServer")};if(r==="remote-wrong-service"||r==="remote-incompatible")return{host:x("onboarding.desktopRecovery.placeholders.unknownServer")}},[m.descriptionParams,x,r]);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[t.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:t.jsx("div",{style:{color:"var(--status-warning)"},children:ze(m.iconKey)})}),t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:x(m.titleKey)}),t.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:x(m.descriptionKey,R)})]}),o&&(r==="remote-unreachable"||r==="remote-wrong-service"||r==="remote-incompatible")&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:x("onboarding.remoteConnection.field.serverAddress")}),t.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:ce(o)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[i&&t.jsxs(t.Fragment,{children:[t.jsxs(L,{onClick:i,disabled:h||u,className:"w-full",children:[t.jsx(F,{name:h?"loader":"download",className:ee("h-4 w-4",h&&"animate-spin")}),x(h?"onboarding.desktopRecovery.remoteIncompatible.updatingServer":"onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),h&&t.jsx("p",{className:"typography-meta text-center text-muted-foreground",children:x("onboarding.desktopRecovery.remoteIncompatible.updatingHint")}),t.jsx(Ve,{state:s})]}),m.showRetry&&a&&t.jsxs(L,{onClick:a,disabled:u||h,variant:i?"outline":"default",className:"w-full",children:[t.jsx(F,{name:"refresh",className:ee("h-4 w-4",u&&"animate-spin")}),x(u?"onboarding.desktopRecovery.actions.retrying":U)]}),t.jsxs("div",{className:"flex gap-2",children:[m.showUseLocal&&n&&t.jsxs(L,{variant:"outline",onClick:n,disabled:u||h,className:"flex-1",children:[t.jsx(F,{name:"macbook",className:"h-4 w-4"}),x(m.useLocalLabelKey)]}),m.showUseRemote&&l&&t.jsxs(L,{variant:"outline",onClick:l,disabled:u||h,className:"flex-1",children:[t.jsx(F,{name:"server",className:"h-4 w-4"}),x(m.useRemoteLabelKey)]})]})]})]})})}function pe(r,e){if(e==="use-remote")return{kind:"remote-form"};switch(r){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const o=r;throw new Error(`Unhandled RecoveryVariant: ${o}`)}}}function Xe(r){const e=Q.c(39),{variant:o,hostUrl:a,hostLabel:n,hostId:l,onRetry:u,onChooseRemote:i,showRemoteForm:s,onCloseRemoteForm:h,onSwitchToLocalFromRemote:x,onEnterLocalSetup:m,isRetrying:U,localAvailable:R}=r,y=s===void 0?!1:s,b=U===void 0?!1:U,g=R===void 0?!0:R,S=Ge;let N;e[0]!==u?(N=async()=>{if(X()){await Y();return}await te("/api/config/reload",{method:"POST"}),u?.()},e[0]=u,e[1]=N):N=e[1];const T=N;let I;e[2]!==m||e[3]!==o?(I=async()=>{if(pe(o,"use-local").kind==="local-setup"){m?.();return}if(await S("local"),X()){await Y();return}window.location.reload()},e[2]=m,e[3]=o,e[4]=I):I=e[4];const D=I;let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w={kind:"idle"},e[5]=w):w=e[5];const[v,j]=d.useState(w),[k,A]=d.useState(null);let B,$;e[6]!==l||e[7]!==o?(B=()=>{if(A(null),o!=="remote-incompatible"||!l||!X())return;let _=!1;return G().then(O=>{const H=O.hosts.find(P=>P.id===l),q=Ue(H?.apiUrl||H?.url||"");!_&&q&&A(l)}).catch(qe),()=>{_=!0}},$=[o,l],e[6]=l,e[7]=o,e[8]=B,e[9]=$):(B=e[8],$=e[9]),d.useEffect(B,$);let W;e[10]===Symbol.for("react.memo_cache_sentinel")?(W=async _=>{j({kind:"updating"});try{const O=await Ie(_);if(O.status==="auth"){j({kind:"auth"});return}if(O.status==="failed"){j({kind:"refused",error:O.error});return}if(await Te(_)==="timeout"){j({kind:"timeout"});return}await Y()||j({kind:"idle"})}catch{j({kind:"timeout"})}},e[10]=W):W=e[10];const f=W;let E;e[11]!==i||e[12]!==o?(E=()=>{pe(o,"use-remote").kind==="remote-form"&&i?.()},e[11]=i,e[12]=o,e[13]=E):E=e[13];const V=E;if(y){const _=o==="remote-wrong-service"?"":a||"",O=o==="remote-wrong-service"?"":n||"";let H;e[14]!==i||e[15]!==h?(H=h||(()=>i?.()),e[14]=i,e[15]=h,e[16]=H):H=e[16];const q=!g;let P;e[17]!==g||e[18]!==m||e[19]!==x?(P=g?x||(()=>{S("local").then(()=>{X()?Y():m?.()})}):void 0,e[17]=g,e[18]=m,e[19]=x,e[20]=P):P=e[20];let p;return e[21]!==O||e[22]!==_||e[23]!==H||e[24]!==q||e[25]!==P?(p=t.jsx(ve,{onBack:H,initialUrl:_,initialLabel:O,isRecoveryMode:!0,showInstancePicker:q,onSwitchToLocal:P}),e[21]=O,e[22]=_,e[23]=H,e[24]=q,e[25]=P,e[26]=p):p=e[26],p}const c=g?D:void 0;let C;e[27]!==k?(C=k?()=>{f(k)}:void 0,e[27]=k,e[28]=C):C=e[28];let M;return e[29]!==T||e[30]!==V||e[31]!==n||e[32]!==a||e[33]!==b||e[34]!==v||e[35]!==c||e[36]!==C||e[37]!==o?(M=t.jsx(Ye,{variant:o,hostLabel:n,hostUrl:a,onRetry:T,onUseLocal:c,onUseRemote:V,isRetrying:b,onUpdateServer:C,serverUpdate:v}),e[29]=T,e[30]=V,e[31]=n,e[32]=a,e[33]=b,e[34]=v,e[35]=c,e[36]=C,e[37]=o,e[38]=M):M=e[38],M}function qe(){}async function Ge(r){if(!X())return;const e=await G();await Z({...e,...r==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function So(r){const e=Q.c(30),{onBack:o,onCliAvailable:a,mode:n,recoveryVariant:l,recoveryHostUrl:u,recoveryHostLabel:i,recoveryHostId:s,onEnterLocalSetup:h,localAvailable:x}=r,m=n===void 0?"first-launch":n,U=l===void 0?"missing-default-host":l,R=x===void 0?!0:x,[y,b]=d.useState(!1),[g,S]=d.useState(!1);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{S(!1),b(!1)},e[0]=N):N=e[0];let T;e[1]!==m||e[2]!==i||e[3]!==u||e[4]!==U?(T=[m,U,u,i],e[1]=m,e[2]=i,e[3]=u,e[4]=U,e[5]=T):T=e[5],d.useEffect(N,T);const I=g?"local-setup":m;if(I==="recovery"){let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=()=>b(!0),e[6]=w):w=e[6];let v,j;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>b(!1),j=()=>{b(!1),S(!0)},e[7]=v,e[8]=j):(v=e[7],j=e[8]);let k;e[9]!==h?(k=()=>{S(!0),h?.()},e[9]=h,e[10]=k):k=e[10];let A;return e[11]!==R||e[12]!==s||e[13]!==i||e[14]!==u||e[15]!==U||e[16]!==y||e[17]!==k?(A=t.jsx(Xe,{variant:U,hostUrl:u,hostLabel:i,hostId:s,onChooseRemote:w,showRemoteForm:y,onCloseRemoteForm:v,onSwitchToLocalFromRemote:j,onEnterLocalSetup:k,localAvailable:R}),e[11]=R,e[12]=s,e[13]=i,e[14]=u,e[15]=U,e[16]=y,e[17]=k,e[18]=A):A=e[18],A}if(I==="local-setup"){let w;e[19]!==o||e[20]!==g?(w=()=>{g?S(!1):o?.()},e[19]=o,e[20]=g,e[21]=w):w=e[21];let v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=()=>b(!0),e[22]=v):v=e[22];let j;return e[23]!==a||e[24]!==g||e[25]!==w?(j=t.jsx(Be,{onBack:w,onCliAvailable:a,isFromRecovery:g,onSwitchToRemote:v}),e[23]=a,e[24]=g,e[25]=w,e[26]=j):j=e[26],j}let D;return e[27]!==R||e[28]!==a?(D=t.jsx(Fe,{onCliAvailable:a,localAvailable:R}),e[27]=R,e[28]=a,e[29]=D):D=e[29],D}export{So as OnboardingScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as L,j as i}from"./vendor-react-BUCujlKS.js";import{u as B,aA as E,A as R,l as I,F as N,D as _,B as U,q as A,t as F}from"./useAppFontEffects-
|
|
1
|
+
import{f as L,j as i}from"./vendor-react-BUCujlKS.js";import{u as B,aA as E,A as R,l as I,F as N,D as _,B as U,q as A,t as F}from"./useAppFontEffects-DAUhSLPu.js";import{u as v}from"./katex.min-u4DtE8E5.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-zod-DDir2TeQ.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.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-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-KulAIuMz.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.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-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-client-h8RufjAw.js";const xo=()=>{const t=L.c(44),{t:o}=B(),j=v($),y=v(q),e=v(H);let C;t[0]!==e||t[1]!==o?(C=async()=>{if(!e)return;if((await E(e)).ok){R.success(o("openCodeStatusDialog.toast.copiedTitle"),{description:o("openCodeStatusDialog.toast.copiedDescription")});return}R.error(o("openCodeStatusDialog.toast.copyFailed"))},t[0]=e,t[1]=o,t[2]=C):C=t[2];const O=C;let h;t[3]!==e?(h=()=>{if(!e)return;const k=URL.createObjectURL(new Blob([e],{type:"text/plain;charset=utf-8"})),x=document.createElement("a");x.href=k,x.download=`openchamber-diagnostics-${new Date().toISOString().replace(/[:.]/g,"-")}.log`,document.body.appendChild(x),x.click(),x.remove(),setTimeout(()=>URL.revokeObjectURL(k),1e3)},t[3]=e,t[4]=h):h=t[4];const b=h;let r;t[5]!==o?(r=o("openCodeStatusDialog.title"),t[5]=o,t[6]=r):r=t[6];let p;t[7]!==r?(p=i.jsx(I,{children:r}),t[7]=r,t[8]=p):p=t[8];let s;t[9]!==o?(s=o("openCodeStatusDialog.description"),t[9]=o,t[10]=s):s=t[10];let m;t[11]!==s?(m=i.jsx(N,{children:s}),t[11]=s,t[12]=m):m=t[12];let n;t[13]!==p||t[14]!==m?(n=i.jsxs(_,{children:[p,m]}),t[13]=p,t[14]=m,t[15]=n):n=t[15];const w=!e;let a;t[16]!==o?(a=o("openCodeStatusDialog.actions.copy"),t[16]=o,t[17]=a):a=t[17];let l;t[18]!==O||t[19]!==w||t[20]!==a?(l=i.jsx(U,{type:"button",variant:"outline",onClick:O,disabled:w,children:a}),t[18]=O,t[19]=w,t[20]=a,t[21]=l):l=t[21];const T=!e;let c;t[22]!==o?(c=o("openCodeStatusDialog.actions.download"),t[22]=o,t[23]=c):c=t[23];let d;t[24]!==b||t[25]!==T||t[26]!==c?(d=i.jsx(U,{type:"button",onClick:b,disabled:T,children:c}),t[24]=b,t[25]=T,t[26]=c,t[27]=d):d=t[27];let u;t[28]!==d||t[29]!==l?(u=i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l,d]}),t[28]=d,t[29]=l,t[30]=u):u=t[30];let f;t[31]!==e||t[32]!==o?(f=e||o("openCodeStatusDialog.empty.noData"),t[31]=e,t[32]=o,t[33]=f):f=t[33];let g;t[34]!==f?(g=i.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:f}),t[34]=f,t[35]=g):g=t[35];let D;t[36]!==u||t[37]!==g||t[38]!==n?(D=i.jsxs(A,{className:"max-w-2xl",children:[n,u,g]}),t[36]=u,t[37]=g,t[38]=n,t[39]=D):D=t[39];let S;return t[40]!==j||t[41]!==y||t[42]!==D?(S=i.jsx(F,{open:j,onOpenChange:y,children:D}),t[40]=j,t[41]=y,t[42]=D,t[43]=S):S=t[43],S};function $(t){return t.isOpenCodeStatusDialogOpen}function q(t){return t.setOpenCodeStatusDialogOpen}function H(t){return t.openCodeStatusText}export{xo as OpenCodeStatusDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{eg as X,eh as Y,ei as Z}from"./useAppFontEffects-
|
|
1
|
+
import{eg as X,eh as Y,ei as Z}from"./useAppFontEffects-DAUhSLPu.js";import{g as U,a as nn,p as en}from"./parseDiffFromFile-DWemyyqU.js";import{M as tn,G as rn,u as ln,W as on,a as un,b as R,n as z,c as H,t as sn}from"./Virtualizer-BP6uuKe_.js";import{j as c,r as f}from"./vendor-react-BUCujlKS.js";import{a as cn}from"./isDiffPlainText-KGYbp86N.js";import{V as fn,F as an}from"./pierreDiffTint-B7qPTZmL.js";function dn({hunkIndex:n,lineIndex:t,conflictIndex:e}){return`merge-conflict-action-${n}-${t}-${e}`}function hn(n,t){const e=t.hunks[n.hunkIndex];if(e!=null)return{hunkIndex:n.hunkIndex,lineIndex:pn(e,n.startContentIndex)}}function pn(n,t){let e=n.unifiedLineStart;for(let r=0;r<t;r++){const i=n.hunkContent[r];e+=i.type==="context"?i.lines:i.deletions+i.additions}return e}function mn(n){const t=X(n);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:e}=t[0];if(e.length!==1)throw console.error(e),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return e[0]}function xn({fileDiff:n,actions:t,renderCustomHeader:e,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:o,renderAnnotation:u,renderGutterUtility:a,renderMergeConflictUtility:w,lineAnnotations:A,getHoveredLine:g,getInstance:p,getAnnotationSlotName:S=U}){const E=e?.(n),D=r?.(n),x=i?.(n),F=o?.(n);return c.jsxs(c.Fragment,{children:[E!=null?c.jsx("div",{slot:Y,children:E}):c.jsxs(c.Fragment,{children:[D!=null&&c.jsx("div",{slot:"header-prefix",children:D}),x!=null&&c.jsx("div",{slot:"header-filename-suffix",children:x}),F!=null&&c.jsx("div",{slot:"header-metadata",children:F})]}),u!=null&&A?.map((s,m)=>c.jsx("div",{slot:S(s),children:u(s)},m)),t!=null&&w!=null&&p!=null&&t.map(s=>{if(s==null)return;const m=gn(s,n);return c.jsx("div",{slot:m,style:tn,children:w(s,p)},m)}),a!=null&&c.jsx("div",{slot:"gutter-utility-slot",style:rn,children:a(g)})]})}function gn(n,t){const e=hn(n,t);return e!=null?dn({hunkIndex:e.hunkIndex,lineIndex:e.lineIndex,conflictIndex:n.conflictIndex}):void 0}const En=typeof window>"u"?f.useEffect:f.useLayoutEffect;function Dn({fileDiff:n,oldFile:t,newFile:e,options:r,editorOptions:i,editStateKey:o,lineAnnotations:u,selectedLines:a,prerenderedHTML:w,metrics:A,hasGutterRenderUtility:g,hasCustomHeader:p,disableWorkerPool:S,edit:E,onEditChange:D,onEditComplete:x}){const F=ln(),s=a!==void 0,m=f.useContext(on),y=un(),[C,O]=f.useState(),_=R(l=>D?.(l)),P=D!=null?_:void 0,j=f.useRef(null),G=R(l=>{const I=x?.(l)??"reject";return I==="accept"&&(j.current={fileDiff:{installed:l.fileDiff,stale:l.originalFileDiff},filePair:n==null?{fileDiff:l.fileDiff,installed:{oldFile:l.oldFile,newFile:l.newFile},stale:{oldFile:t??null,newFile:e??null}}:null,annotations:{installed:l.lineAnnotations,stale:l.originalLineAnnotations}}),I}),L=x!=null?G:void 0,M=Fn({acceptedCache:j,fileDiff:n,newFile:e,oldFile:t,parseDiffOptions:r?.parseDiffOptions}),d=f.useRef(null),v=f.useRef(null),h=f.useRef(null),W=R(()=>{if(y==null)throw new Error("FileDiff: EditContext is not attached");return y("file-diff",i??{},o)}),B=R(l=>{if(l!=null){if(d.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");F!=null?d.current=new fn(b({controlledSelection:s,hasCustomHeader:p,hasGutterRenderUtility:g,onEditChange:P,onEditComplete:L,options:r}),F,A,S?void 0:m,!0):d.current=new an(b({controlledSelection:s,hasCustomHeader:p,hasGutterRenderUtility:g,onEditChange:P,onEditComplete:L,options:r}),S?void 0:m,!0),d.current.hydrate({fileDiff:M,fileContainer:l,lineAnnotations:u,prerenderedHTML:w})}else{if(d.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");h.current=null,d.current.cleanUp(),d.current=null,v.current=null}});En(()=>{const{current:l}=d;if(l==null)return;const I=b({controlledSelection:s,hasCustomHeader:p,hasGutterRenderUtility:g,onEditChange:P,onEditComplete:L,options:r}),Q=I!==void 0&&!nn(l.options,I);if(l.setOptions(I),!E&&(h.current=null,v.current!=null)){const{current:V}=v;v.current=null,V()}const T=vn(M,u,j);if(l.render({forceRender:Q,fileDiff:T.fileDiff,lineAnnotations:T.lineAnnotations}),a!==void 0&&l.setSelectedLines(a),!E||v.current!=null)return;if(y==null)throw new Error("FileDiff: EditContext is not attached");const q=()=>{d.current!==l||v.current!=null||!l.__canAttachEditor()||(v.current=wn(l,W))};if(l.__canAttachEditor()){h.current=null,q();return}const k=l.__prepareForEditing();if(k==null){h.current=null;return}if(h.current?.promise===k)return;const N={promise:k};h.current=N,k.then(()=>{h.current===N&&(q(),h.current=null)}).catch(V=>{h.current===N&&(h.current=null,O(V))})});const J=f.useCallback(()=>d.current?.getHoveredLine(),[]),K=f.useCallback(l=>d.current?.getAnnotationSlotName(l)??U(l),[]);if(C!=null)throw C;return{fileDiff:M,ref:B,getHoveredLine:J,getAnnotationSlotName:K}}function Fn({acceptedCache:n,fileDiff:t,newFile:e,oldFile:r,parseDiffOptions:i}){return f.useMemo(()=>{if(t!=null)return t;const{current:o}=n,u=o?.filePair;if(o!=null&&u!=null){if($(r,e,u.stale)||$(r,e,u.installed))return u.fileDiff;o.filePair=null}return en(r??null,e??null,i)},[n,t,r,e,i])}function $(n,t,e){return H(n??void 0,e.oldFile??void 0)&&H(t??void 0,e.newFile??void 0)}function vn(n,t,e){const{current:r}=e;if(r==null)return{fileDiff:n,lineAnnotations:t};const{fileDiff:i,annotations:o}=r;let u=n;i!=null&&(cn(n,i.stale)?u=i.installed:r.fileDiff=null);let a=t;return o!=null&&(t===o.stale?a=o.installed:r.annotations=null),r.fileDiff==null&&r.annotations==null&&r.filePair==null&&(e.current=null),{fileDiff:u,lineAnnotations:a}}function b({options:n,controlledSelection:t,hasCustomHeader:e,hasGutterRenderUtility:r,onEditChange:i,onEditComplete:o}){return t||r||e||i!=null||o!=null?{...n,controlledSelection:t,renderCustomHeader:e?z:n?.renderCustomHeader,renderGutterUtility:r?z:n?.renderGutterUtility,onEditChange:i,onEditComplete:o}:n}function wn(n,t){const e=t();try{return e.edit(n)}catch(r){throw e.cleanUp(),r}}function kn({patch:n,options:t,editorOptions:e,editStateKey:r,metrics:i,lineAnnotations:o,selectedLines:u,className:a,style:w,prerenderedHTML:A,renderAnnotation:g,renderCustomHeader:p,renderHeaderPrefix:S,renderHeaderFilenameSuffix:E,renderHeaderMetadata:D,renderGutterUtility:x,disableWorkerPool:F=!1,edit:s=!1,onEditChange:m,onEditComplete:y}){const C=An(n),{ref:O,getHoveredLine:_,getAnnotationSlotName:P}=Dn({fileDiff:C,options:t,editorOptions:e,editStateKey:r,metrics:i,lineAnnotations:o,selectedLines:u,prerenderedHTML:A,hasGutterRenderUtility:x!=null,hasCustomHeader:p!=null,disableWorkerPool:F,edit:s,onEditChange:m,onEditComplete:y}),j=xn({fileDiff:C,renderCustomHeader:p,renderHeaderPrefix:S,renderHeaderFilenameSuffix:E,renderHeaderMetadata:D,renderAnnotation:g,lineAnnotations:o,renderGutterUtility:x,getHoveredLine:_,getAnnotationSlotName:P});return c.jsx(Z,{ref:O,className:a,style:w,children:sn(j,A)})}function An(n){return f.useMemo(()=>mn(n),[n])}export{kn as P};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as D,j as $,c as Te,f as Ct,r as p}from"./vendor-react-BUCujlKS.js";import{p as _t,a as Ot}from"./parseDiffFromFile-
|
|
1
|
+
import{R as D,j as $,c as Te,f as Ct,r as p}from"./vendor-react-BUCujlKS.js";import{p as _t,a as Ot}from"./parseDiffFromFile-DWemyyqU.js";import{c as ut}from"./isDiffPlainText-KGYbp86N.js";import{P as Dt,V as ft,F as zt}from"./pierreDiffTint-B7qPTZmL.js";import{V as Wt}from"./Virtualizer-Cmng0Q1E.js";import{u as Et,a9 as Bt,aa as ht,aF as qt,f2 as jt,n as Vt,N as pt}from"./useAppFontEffects-DAUhSLPu.js";import"./katex.min-u4DtE8E5.js";import{I as mt,a as Kt,u as Ut}from"./useInlineCommentController-bYCeqE6r.js";import{Q as Gt}from"./runtimeEndpointReset-D7viEboD.js";import{ensurePierreThemeRegistered as gt,getResolvedShikiTheme as yt}from"./appThemeRegistry-CDGE1wtP.js";const Ae=t=>{if(t.type==="new"){const e=Math.min(t.selection.start,t.selection.end),r=Math.max(t.selection.start,t.selection.end);return`new-comment-${t.selection.side??"additions"}-${e}-${r}`}return`draft-${t.draft.id}`},Xt=t=>{const{drafts:e,editingDraftId:r,selection:n}=t,o=[];for(const a of e){if(!Number.isFinite(a.endLine))continue;const l=Math.max(1,Math.floor(a.endLine)),u=a.side==="original"?"deletions":"additions";o.push({lineNumber:l,side:u,metadata:{type:a.id===r?"edit":"saved",draft:a}})}return n&&!r&&o.push({lineNumber:Math.max(n.start,n.end),side:n.side??"additions",metadata:{type:"new",selection:n}}),o};function Yt(t){const e=t.trim();if(!e)return null;if(/^-?\d+(\.\d+)?$/.test(e)){const r=Number.parseFloat(e);return Number.isFinite(r)?r:null}if(e.endsWith("px")){const r=Number.parseFloat(e.slice(0,-2));return Number.isFinite(r)?r:null}return null}function vt(t){if(!(!t||t<=0))return Math.max(200,Math.floor(t))}function Qt(t){const{diffRootRef:e,drafts:r,selection:n,editingDraftId:o,commentText:a,onTextChange:l,fileLabel:u,onSave:s,onCancel:d,onEdit:f,onDelete:m}=t,[y,R]=D.useState(0),[P,A]=D.useState(null),q=D.useMemo(()=>!n||o?null:Ae({type:"new",selection:n}),[o,n]),V=D.useMemo(()=>{const b=r.map(N=>Ae({type:N.id===o?"edit":"saved",draft:N}));return q&&b.push(q),b},[r,o,q]),H=D.useCallback(b=>{const N=e.current;if(!N)return null;const T=N.querySelector("diffs-container");if(!(T instanceof HTMLElement))return null;const _=T.querySelector(`[data-annotation-id="${b}"]`);if(_ instanceof HTMLElement)return _;const K=T.shadowRoot;return K?K.querySelector(`[data-annotation-id="${b}"]`):null},[e]);D.useEffect(()=>{if(V.length===0)return;let b=!1,N=0;const T=12,_=()=>{b||V.every(U=>!!H(U))||N>=T||(N+=1,requestAnimationFrame(()=>{b||(R(U=>U+1),_())}))};return _(),()=>{b=!0}},[V,H]),D.useEffect(()=>{const b=e.current;if(!b)return;const N=()=>{const _=getComputedStyle(b),K=Yt(_.getPropertyValue("--oc-context-panel-width")),U=b.getBoundingClientRect(),X=K??U.width;A(X>0?X:null)};N();const T=new ResizeObserver(()=>{N()});return T.observe(b),window.addEventListener("resize",N),()=>{T.disconnect(),window.removeEventListener("resize",N)}},[e]);const O=D.useCallback(b=>{const T=e.current?.getBoundingClientRect(),_=b.closest("[data-annotation-content]"),K=_ instanceof HTMLElement?_.getBoundingClientRect():b.getBoundingClientRect(),U=[K.width];T&&U.push(T.right-K.left);const X=U.filter(z=>Number.isFinite(z)&&z>0);return X.length>0?vt(Math.min(...X)):vt(P)},[e,P]),G=()=>{const b=e.current?.querySelector("diffs-container")?.shadowRoot,N=b?Array.from(b.querySelectorAll("[data-line][data-selected-line]")).at(-1):void 0;if(N)return getComputedStyle(N).getPropertyValue("--diffs-computed-selected-line-bg").trim()||void 0};return $.jsxs($.Fragment,{children:[r.map(b=>{const N=Ae({type:b.id===o?"edit":"saved",draft:b}),T=H(N);if(!T)return null;const _=O(T);return b.id===o?Te.createPortal($.jsx(mt,{initialText:a,onTextChange:l,fileLabel:u,lineRange:{start:b.startLine,end:b.endLine,side:b.side==="original"?"deletions":"additions"},isEditing:!0,onSave:s,onCancel:d,maxWidth:_,bandColor:G()}),T,`draft-edit-${b.id}`):Te.createPortal($.jsx(Kt,{draft:b,onEdit:()=>f(b),onDelete:()=>m(b),maxWidth:_}),T,`draft-card-${b.id}`)}),n&&!o&&q&&(()=>{const b=H(q);if(!b)return null;const N=O(b);return Te.createPortal($.jsx(mt,{initialText:a,onTextChange:l,fileLabel:u,lineRange:n,isEditing:!1,onSave:s,onCancel:d,maxWidth:N,bandColor:G()}),b,q)})()]})}const Zn=14,er=t=>t.slice(t.lastIndexOf("/",t.length-2)+1),It=t=>t.replace(/\\/g,"/").replace(/^\/+/,"").trim(),bt=(t,e)=>({id:`dir:${t}`,path:t,name:e,children:new Map,directFiles:[],files:[]}),tr=t=>{const e=bt("","");for(const r of t){const n=It(r.path);if(!n)continue;const a=n.split("/").filter(Boolean).slice(0,-1);let l=e;if(l.files.push(r),a.length>0){let u="";for(const s of a){u=u?`${u}/${s}`:s;const d=l.children.get(s);if(d){d.files.push(r),l=d;continue}const f=bt(u,s);f.files.push(r),l.children.set(s,f),l=f}}l.directFiles.push(r)}return e},Jt=t=>{let e=t,r=t.name;for(;e.directFiles.length===0&&e.children.size===1;){const[n]=e.children.values();e=n,r=`${r}/${n.name}`}return{node:e,label:r}},nr=(t,e)=>{const r=[],n=(o,a)=>{const l=Array.from(o.children.values()).sort((s,d)=>s.path.localeCompare(d.path));for(const s of l){const{node:d,label:f}=Jt(s);r.push({key:d.id,kind:"directory",depth:a,label:f,directory:d}),e.has(d.path)&&n(d,a+1)}const u=[...o.directFiles].sort((s,d)=>s.path.localeCompare(d.path));for(const s of u)r.push({key:`file:${It(s.path)}`,kind:"file",depth:a,file:s})};return n(t,0),r},qe=3,Zt=1e6,xt=new WeakMap,en=t=>{const e=xt.get(t);if(e)return e;let r=!1;const n=[];for(const a of t.hunks){const l=[];for(const u of a.hunkContent){if(u.type==="context"){Ke(l,{...u});continue}const s=tn(t,u);(s.length>1||s[0]?.type==="context")&&(r=!0);for(const d of s)Ke(l,d)}n.push(...rn(a,l))}const o=r?sn(t,n):t;return xt.set(t,o),o},wt=t=>t.replace(/\s+/g,""),tn=(t,e)=>{if(e.deletions===0||e.additions===0)return[{...e}];const r=t.deletionLines.slice(e.deletionLineIndex,e.deletionLineIndex+e.deletions),n=t.additionLines.slice(e.additionLineIndex,e.additionLineIndex+e.additions),o=[];let a=0,l=0;for(const[u,s]of nn(r,n))(u>a||s>l)&&o.push({type:"change",deletions:u-a,deletionLineIndex:e.deletionLineIndex+a,additions:s-l,additionLineIndex:e.additionLineIndex+l}),Ke(o,{type:"context",lines:1,deletionLineIndex:e.deletionLineIndex+u,additionLineIndex:e.additionLineIndex+s}),a=u+1,l=s+1;return(a<e.deletions||l<e.additions)&&o.push({type:"change",deletions:e.deletions-a,deletionLineIndex:e.deletionLineIndex+a,additions:e.additions-l,additionLineIndex:e.additionLineIndex+l}),o},nn=(t,e)=>{const r=t.map(wt),n=e.map(wt),o=[];let a=0;for(;a<r.length&&a<n.length&&r[a]===n[a];)o.push([a,a]),a+=1;let l=0;for(;l<r.length-a&&l<n.length-a&&r[r.length-1-l]===n[n.length-1-l];)l+=1;const u=r.length-a-l,s=n.length-a-l;if(u>0&&s>0&&(u+1)*(s+1)<=Zt){const d=s+1,f=new Uint32Array((u+1)*d);for(let R=u-1;R>=0;R-=1)for(let P=s-1;P>=0;P-=1)f[R*d+P]=r[a+R]===n[a+P]?f[(R+1)*d+P+1]+1:Math.max(f[(R+1)*d+P],f[R*d+P+1]);let m=0,y=0;for(;m<u&&y<s;)r[a+m]===n[a+y]?(o.push([a+m,a+y]),m+=1,y+=1):f[(m+1)*d+y]>=f[m*d+y+1]?m+=1:y+=1}for(let d=l;d>0;d-=1)o.push([r.length-d,n.length-d]);return o},Ke=(t,e)=>{const r=t.at(-1);if(r?.type==="context"&&e.type==="context"){r.lines+=e.lines;return}t.push(e)},Lt=(t,e,r)=>({type:"context",lines:r,deletionLineIndex:t.deletionLineIndex+e,additionLineIndex:t.additionLineIndex+e}),rn=(t,e)=>{const r=[];let n=null;for(const[a,l]of e.entries()){if(l.type==="change"){if(!n){n=[];const s=e[a-1];if(s?.type==="context"){const d=Math.min(s.lines,qe);n.push(Lt(s,s.lines-d,d))}}n.push(l);continue}if(!n)continue;if(a<e.length-1&&l.lines<=qe*2){n.push(l);continue}n.push(Lt(l,0,Math.min(l.lines,qe))),r.push(n),n=null}n&&r.push(n);const o=e.at(-1);return r.map(a=>{const l=a.at(-1),u=l!==void 0&&o!==void 0&&Ee(l,"deletion")===Ee(o,"deletion")&&Ee(l,"addition")===Ee(o,"addition");return on(t,a,u)})},Ee=(t,e)=>e==="deletion"?t.deletionLineIndex+(t.type==="context"?t.lines:t.deletions):t.additionLineIndex+(t.type==="context"?t.lines:t.additions),on=(t,e,r)=>{let n=0,o=0,a=0,l=0,u=0;for(const A of e)A.type==="context"?(a+=A.lines,l+=A.lines,u+=A.lines):(n+=A.additions,o+=A.deletions,l+=Math.max(A.additions,A.deletions),u+=A.additions+A.deletions);const s=e[0],d=a+n,f=a+o,m=kt(Me(t.additionStart,t.additionCount)+s.additionLineIndex-t.additionLineIndex,d),y=kt(Me(t.deletionStart,t.deletionCount)+s.deletionLineIndex-t.deletionLineIndex,f),P=s.additionLineIndex===t.additionLineIndex&&s.deletionLineIndex===t.deletionLineIndex?t.hunkContext:void 0;return{collapsedBefore:0,additionStart:m,additionCount:d,additionLines:n,additionLineIndex:s.additionLineIndex,deletionStart:y,deletionCount:f,deletionLines:o,deletionLineIndex:s.deletionLineIndex,hunkContent:e,hunkContext:P,hunkSpecs:`@@ -${y},${f} +${m},${d} @@${P?` ${P}`:""}
|
|
2
2
|
`,splitLineStart:0,splitLineCount:l,unifiedLineStart:0,unifiedLineCount:u,noEOFCRDeletions:r&&t.noEOFCRDeletions,noEOFCRAdditions:r&&t.noEOFCRAdditions}},Me=(t,e)=>t-(e===0?0:1),kt=(t,e)=>t+(e===0?0:1),sn=(t,e)=>{let r=0,n=0,o=0;for(const l of e)l.collapsedBefore=Math.max(Me(l.additionStart,l.additionCount)-o,0),l.splitLineStart=r+l.collapsedBefore,l.unifiedLineStart=n+l.collapsedBefore,r+=l.collapsedBefore+l.splitLineCount,n+=l.collapsedBefore+l.unifiedLineCount,o=Me(l.additionStart,l.additionCount)+l.additionCount;if(e.at(-1)&&!t.isPartial&&t.additionLines.length>0&&t.deletionLines.length>0){const l=Math.max(t.additionLines.length-o,0);r+=l,n+=l}return{...t,...t.isPartial?an(t,e):{hunks:e},splitLineCount:r,unifiedLineCount:n,cacheKey:t.cacheKey===void 0?void 0:`${t.cacheKey}:hide-whitespace`}},an=(t,e)=>{const r=[],n=[],o=(l,u,s,d)=>{for(let f=s;f<s+d;f+=1)u.push(l[f])};return{hunks:e.map(l=>{const u=r.length,s=n.length,d=l.hunkContent.map(f=>{const m={...f,deletionLineIndex:r.length,additionLineIndex:n.length};return o(t.deletionLines,r,f.deletionLineIndex,f.type==="context"?f.lines:f.deletions),o(t.additionLines,n,f.additionLineIndex,f.type==="context"?f.lines:f.additions),m});return{...l,deletionLineIndex:u,additionLineIndex:s,hunkContent:d}}),deletionLines:r,additionLines:n}},ln=t=>t.replace(/\r?\n$/,""),cn=(t,e,r)=>{if(!t.isPartial)return r-1;for(const n of t.hunks){const o=e==="additions"?n.additionStart:n.deletionStart,a=e==="additions"?n.additionCount:n.deletionCount;if(r<o||r>=o+a)continue;return(e==="additions"?n.additionLineIndex:n.deletionLineIndex)+(r-o)}return null},dn=(t,e,r,n)=>{const o=e==="additions"?t.additionLines:t.deletionLines,a=[];for(let l=Math.max(1,r);l<=n;l+=1){const u=cn(t,e,l),s=u===null?void 0:o[u];s!==void 0&&a.push(ln(s))}return a.join(`
|
|
3
3
|
`)},je=/[\p{L}\p{N}_$]/u,un=(t,e)=>{if(e<0||e>t.length)return null;const r=e===t.length?t.length-1:e;if(r<0||!je.test(t[r]))return null;let n=r,o=r+1;for(;n>0&&je.test(t[n-1]);)n-=1;for(;o<t.length&&je.test(t[o]);)o+=1;return{word:t.slice(n,o),spanStart:n}},fn=t=>t?Array.from(t.children).filter(e=>e instanceof HTMLElement&&e.hasAttribute("data-code")):[],hn=(t,e)=>{const r=new Map,n=()=>{const s=t.getBoundingClientRect().left,d=Array.from(r.values(),f=>({entry:f,left:f.column.getBoundingClientRect().left-s,clientWidth:f.column.clientWidth,scrollWidth:f.column.scrollWidth,scrollLeft:f.column.scrollLeft}));e.hidden=!d.some(f=>f.scrollWidth-f.clientWidth>1);for(const{entry:f,left:m,clientWidth:y,scrollWidth:R,scrollLeft:P}of d){const A=R-y>1;f.track.hidden=!A,A&&(f.track.style.left=`${m}px`,f.track.style.width=`${y}px`,f.spacer.style.width=`${R}px`,f.track.scrollLeft=P)}},o=new ResizeObserver(n),a=new MutationObserver(()=>u()),l=s=>{const d=document.createElement("div");d.className="absolute inset-y-0 overflow-x-auto overflow-y-hidden overscroll-x-none",d.tabIndex=-1,d.hidden=!0;const f=document.createElement("div");f.className="h-px",d.appendChild(f),e.appendChild(d);const m=()=>{Math.abs(d.scrollLeft-s.scrollLeft)>=1&&(d.scrollLeft=s.scrollLeft)},y=()=>{Math.abs(s.scrollLeft-d.scrollLeft)>=1&&(s.scrollLeft=d.scrollLeft)};return s.addEventListener("scroll",m,{passive:!0}),d.addEventListener("scroll",y,{passive:!0}),o.observe(s),{column:s,content:null,track:d,spacer:f,detach:()=>{s.removeEventListener("scroll",m),d.removeEventListener("scroll",y),o.unobserve(s),d.remove()}}},u=()=>{const s=t.querySelector("diffs-container")?.shadowRoot??null,d=s?.querySelector("pre")??null,f=fn(d);for(const[m,y]of r)f.includes(m)||(y.detach(),y.content&&o.unobserve(y.content),r.delete(m));for(const m of f){const y=r.get(m)??l(m);r.set(m,y);const R=Array.from(m.children).find(P=>P.hasAttribute("data-content"))??null;R!==y.content&&(y.content&&o.unobserve(y.content),R&&o.observe(R),y.content=R)}a.disconnect(),a.observe(t,{childList:!0}),s&&a.observe(s,{childList:!0}),d&&a.observe(d,{childList:!0});for(const m of f)a.observe(m,{childList:!0});r.size===0&&(e.hidden=!0)};return u(),o.observe(t),()=>{a.disconnect(),o.disconnect();for(const s of r.values())s.detach();r.clear(),e.hidden=!0}},pn=t=>{const e=Ct.c(4),{containerRef:r}=t,n=D.useRef(null);let o,a;e[0]!==r?(o=()=>{const u=r.current,s=n.current;if(!(!u||!s))return hn(u,s)},a=[r],e[0]=r,e[1]=o,e[2]=a):(o=e[1],a=e[2]),D.useEffect(o,a);let l;return e[3]===Symbol.for("react.memo_cache_sentinel")?(l=$.jsx("div",{ref:n,hidden:!0,"aria-hidden":"true",className:"sticky bottom-0 z-10 h-2.5 bg-background"}),e[3]=l):l=e[3],l},St=[],mn=`
|
|
4
4
|
[data-gutter-buffer="annotation"] { min-height: 0; }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as t,j as n}from"./vendor-react-BUCujlKS.js";import{c as xt,P as bt,C as Pt}from"./flexokiTheme-
|
|
1
|
+
import{R as t,j as n}from"./vendor-react-BUCujlKS.js";import{c as xt,P as bt,C as Pt}from"./flexokiTheme-BG4cSAMb.js";import{u as Rt,G as z,af as Mt,a5 as Ye,aD as Tt,aE as kt,aF as It,aG as Nt,aH as Et,aI as Dt,a1 as qe,aJ as Vt,aK as Lt,aL as Ze,aM as Ft,aN as At,aO as Ot,aP as st,aQ as Kt,aR as et,V as ue,W as me,aS as tt,B as Q,I as _,X as pe,aT as nt,aU as X,aA as Wt,N as zt,n as _t,aV as Bt,aW as Gt,aX as rt}from"./useAppFontEffects-DAUhSLPu.js";import{u as fe,a5 as he,a6 as Ht,a7 as Ut}from"./katex.min-u4DtE8E5.js";import{u as $t,n as Jt}from"./useInlineCommentController-bYCeqE6r.js";import{u as Qt,b as Xt,F as Yt,c as qt}from"./useMarkdownLocalAssets-CnMxnDdI.js";import{E as Zt}from"./vendor-codemirror-view-B66jUSmE.js";import{u as en,o as tn,C as nn,T as rn}from"./runtimeEndpointReset-D7viEboD.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-search-BKAwkhkm.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-replit-codemirror-vim-CKWqK1yR.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-zod-DDir2TeQ.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.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-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-KulAIuMz.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.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-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-client-h8RufjAw.js";const sn=()=>{const d=new Map,u=new Map;return{schedule:(c,v,o)=>{if(v<=(u.get(c)??Number.NEGATIVE_INFINITY))return d.get(c)??Promise.resolve();u.set(c,v);const p=(d.get(c)??Promise.resolve()).then(o,o);return d.set(c,p.catch(()=>{u.get(c)===v&&u.delete(c)})),p},pendingFor:async c=>{await d.get(c)},reset:c=>{u.delete(c)}}},k=d=>{if(!d)return"";const u=d.replace(/\\/g,"/");return u==="/"?"/":u.replace(/\/+$/,"")},on=(d,u,c)=>{const v=k(d.trim());if(!v)return null;const o=c?u.find(p=>p.id===c)??null:null;if(o?.path){const p=k(o.path);if(v===p||v.startsWith(`${p}/`))return{id:o.id,path:o.path}}const I=u.filter(p=>{const b=k(p.path);return v===b||v.startsWith(`${b}/`)}).sort((p,b)=>k(b.path).length-k(p.path).length)[0];return I?{id:I.id,path:I.path}:null},an=async(d,u)=>{if(!await st.getState().savePlan(d.projectRef,d.planId,u))throw new Error("Plan save rejected: the plan no longer exists")},ln=d=>Ut(()=>d()),Gr=({visible:d=!0,savedProjectPlan:u=null,onNavigatedToChat:c,leading:v})=>{const{t:o}=Rt(),I=en(),p=z(e=>e.currentSessionId),b=z(e=>e.createSession),ve=z(e=>e.initializeNewOpenChamberSession),ge=z(e=>e.sendMessage),we=z(e=>e.setCurrentSession),Se=Mt(),ye=Ye(e=>e.projects),Ce=Ye(e=>e.activeProjectId),je=Tt(e=>e.directories),xe=kt()??"",be=fe(e=>e.setSessionSwitcherOpen),Y=t.useSyncExternalStore(ln,he,he),{isMobile:Pe}=It(),{currentTheme:q}=Nt(),Z=t.useMemo(()=>p?Se.find(e=>e.id===p)??null:null,[p,Se]),Re=t.useMemo(()=>{const e=typeof Z?.directory=="string"?Z.directory:"";return k(e||"")},[Z?.directory]),Me=t.useMemo(()=>k(xe||Re),[xe,Re]),L=t.useMemo(()=>on(Me,ye,Ce),[Ce,Me,ye]),ee=u?.projectRef.id??null,te=u?.projectRef.path??null,l=t.useMemo(()=>ee&&te?{id:ee,path:te}:null,[ee,te]),f=u?.planId??null,S=l&&f?JSON.stringify(["saved-plan",Y,Et(l),f]):null,N=l?.id===Ht,B=t.useMemo(()=>{const e=l??L;return e?je.get(e.path)?.isGitRepo===!0:!1},[L,je,l]),[P,E]=t.useState(null),[Te,ke]=t.useState(!1),[F,ne]=t.useState(null),[G,re]=t.useState(null),Ie=!!F,[m,A]=t.useState(""),{isPlaying:H,play:ot,stop:at}=Dt(),it=qe(e=>e.showMessageTTSButtons),[Ne,se]=t.useState(null),[Ee,oe]=t.useState(null),ae=o("planView.file.defaultName"),De=G??ae,ie=t.useMemo(()=>m.trim()?Vt(m,o("planView.title.default")).title:o("planView.title.default"),[m,o]),U=t.useMemo(()=>ie.trim()||o("planView.title.default"),[ie,o]),[lt,le]=t.useState(!1),[ct,Ve]=t.useState(!1),[O,Le]=t.useState("edit"),K=t.useRef(null),[i,g]=t.useState(null),Fe=t.useRef(null),dt=t.useRef(null),Ae=t.useRef(null),[ut,mt]=t.useState(null),pt=t.useCallback(e=>{Ae.current=e,mt(e)},[]),ft=t.useCallback(e=>{l?.path&&fe.getState().openContextFile(l.path,e)},[l]);Qt({container:ut,filePath:G,workspaceRoot:l?.path??null,onOpenFile:ft,enabled:O==="preview"&&Ie,colorScheme:q.metadata.variant==="light"?"light":"dark"});const Oe="openchamber:plan:md-viewer-mode";t.useEffect(()=>{try{const e=localStorage.getItem(Oe);if(!e)return;const r=JSON.parse(e);(r==="preview"||r==="edit")&&Le(r)}catch{}},[]);const ht=t.useCallback(e=>{Le(e);try{localStorage.setItem(Oe,JSON.stringify(e))}catch{}},[]),D=t.useRef(!1),C=t.useRef(null),[Ke,V]=t.useState(!1);t.useEffect(()=>{const e=()=>{D.current=!1,C.current=null,V(!1)};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[]);const vt=t.useCallback((e,r)=>{const s=e.split(`
|
|
2
2
|
`),a=Math.max(1,r.start),h=Math.min(s.length,r.end);return a>h?"":s.slice(a-1,h).join(`
|
|
3
3
|
`)},[]),gt=$t({source:"plan",fileLabel:De,language:"markdown",getCodeForRange:e=>vt(m,Jt(e)),toStoreRange:e=>({startLine:e.start,endLine:e.end}),fromDraftRange:e=>({start:e.startLine,end:e.endLine})}),{drafts:We,commentText:$,setCommentText:ze,editingDraftId:ce,setSelection:_e,saveComment:Be,cancel:W,reset:Ge,startEdit:He,deleteDraft:Ue}=gt;t.useEffect(()=>{g(null),Ge()},[m,Ge]),t.useEffect(()=>{_e(i)},[i,_e]);const $e=t.useCallback(()=>{g(null),W()},[W]),Je=t.useCallback((e,r)=>{r&&g(r),Be(e,r??i??void 0),g(null)},[i,Be]);t.useEffect(()=>{if(!i)return;const e=s=>{const a=s.target;a.closest('[data-comment-card="true"]')||a.closest('[data-comment-input="true"]')||a.closest(".oc-block-widget")||a.closest(".cm-gutterElement")||a.closest("[data-sonner-toast]")||a.closest("[data-sonner-toaster]")||$.trim()||(g(null),W())},r=window.setTimeout(()=>{document.addEventListener("click",e)},100);return()=>{window.clearTimeout(r),document.removeEventListener("click",e)}},[W,$,ce,Pe,i]);const Qe=fe(e=>e.editorFontSize),wt=t.useMemo(()=>{const e=[xt(q,{fontSize:Qe})],r=Lt("plan.md");return r&&e.push(r),e.push(Zt.lineWrapping),e},[q,Qe]),w=t.useRef({key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""}),R=t.useState(sn)[0],M=t.useCallback(()=>{const e=w.current;if(!e.key||!e.target||e.editRevision<=e.savedRevision)return;const r={key:e.key,target:e.target,content:e.content,revision:e.editRevision,runtimeKey:e.runtimeKey};R.schedule(r.key,r.revision,async()=>{if(he()!==r.runtimeKey)return;await an(r.target,r.content);const s=w.current;s.key===r.key&&(s.savedRevision=Math.max(s.savedRevision,r.revision),se(null))}).catch(s=>{w.current.key===r.key&&se(s instanceof Error?s.message:"Plan save failed")})},[R]);t.useEffect(()=>{if(!f){M(),w.current={key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""},ne(null),re(null),A(""),le(!1);return}let e=!1;return(async()=>{if(M(),w.current={key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""},ne(null),re(null),A(""),se(null),oe(null),!(!l||!S)&&(await R.pendingFor(S),!e)){R.reset(S),le(!0);try{const s=await rt(l,f);if(e)return;if(!s){oe("Plan not found");return}w.current={key:S,target:{projectRef:l,planId:f},content:s.raw,editRevision:0,savedRevision:0,runtimeKey:Y},A(s.raw),ne(f),re(s.path??null)}catch(s){if(e)return;oe(s instanceof Error?s.message:"Plan load failed")}finally{e||le(!1)}}})(),()=>{e=!0}},[Y,f,S,l,R,M]),t.useEffect(()=>{if(!d||!l||!f||!S||F!==f)return;const e=w.current;if(e.key!==S)return;const r=qt({readContent:async()=>{await R.pendingFor(S);const T=await rt(l,f);if(!T)throw new Error("Plan not found");return T.raw},getLoadedContent:()=>e.content,getLoadedRevision:()=>e.editRevision,isDirty:()=>w.current!==e||e.editRevision>e.savedRevision,applyContent:T=>{e.content=T,A(T)}});let s=!1;const a=async()=>{if(!(s||document.visibilityState==="hidden")){s=!0;try{await r.poll()}finally{s=!1}}},h=tn(l,a),j=window.setInterval(()=>{a()},2e3);return()=>{window.clearInterval(j),h(),r.dispose()}},[F,f,S,l,R,d]);const St=t.useCallback(e=>{e!==w.current.content&&(w.current.content=e,w.current.editRevision+=1,A(e))},[]);t.useEffect(()=>{if(!F)return;const e=window.setTimeout(()=>{M()},350);return()=>{window.clearTimeout(e)}},[m,F,M]),t.useEffect(()=>()=>{M()},[M]),t.useEffect(()=>()=>{K.current!==null&&window.clearTimeout(K.current)},[]);const Xe=t.useCallback(()=>{be(!1),c?.()},[c,be]),yt=t.useCallback(async e=>{const r=l??L;if(!r||!P||N)return;const s=await Ze(P.action==="improve"?"plan.improve.visible":"plan.implement.visible",{plan_title:U}),a=G,h=await Ze(P.action==="improve"?"plan.improve.instructions":"plan.implement.instructions",{plan_title:U,plan_path:a??""}),T=[{synthetic:!0,text:a?h:[h,"","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.","",m].join(`
|
|
4
4
|
`)}];ke(!0);try{Xe();let y=null,de=r.path;if(P.target==="worktree"){if(!B)return;const x=await Ft(r.path,At());if(!x?.id)return;y=x.id,de=x.directory}else{const x=await b(void 0,r.path,void 0,{model:{providerID:e.providerID,id:e.modelID,variant:e.variant||void 0},agent:e.agent.trim()||void 0});if(!x?.id)return;y=x.id,de=x.directory??r.path,ve(x.id,qe.getState().agents??[])}if(!y)return;const J=Ot.getState();J.saveSessionModelSelection(y,e.providerID,e.modelID),e.agent.trim()&&(J.saveSessionAgentSelection(y,e.agent),J.saveAgentModelForSession(y,e.agent,e.providerID,e.modelID),J.saveAgentModelVariantForSession(y,e.agent,e.providerID,e.modelID,e.variant||void 0)),we(y,de),l&&f&&st.getState().linkPlanSession(l,f,y);const jt=e.runAsGoal===!0?[`Implement the plan "${U}" end-to-end${a?` (plan file: ${a})`:" (the full plan follows)"}.`,a?"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.","",m].join(`
|