@openchamber/web 1.17.0 → 1.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +3 -0
  2. package/dist/assets/{DiagramView-CRjw8BGO.js → DiagramView-CI2JhNxs.js} +1 -1
  3. package/dist/assets/{MarkdownRendererImpl-BjjFniUt.js → MarkdownRendererImpl-Bq-wtyiF.js} +3 -3
  4. package/dist/assets/{OnboardingScreen-JuiKjRTI.js → OnboardingScreen-B6BqjJ0l.js} +1 -1
  5. package/dist/assets/{SessionSwitcherDropdown-S2EvRz-E.js → SessionSwitcherDropdown-DepVWyeA.js} +1 -1
  6. package/dist/assets/{SettingsWindow-PzqMjCEx.js → SettingsWindow-Xj4Uy_Fr.js} +1 -1
  7. package/dist/assets/{document-attachments-DZf4VoiD.js → document-attachments-C5tUWELq.js} +1 -1
  8. package/dist/assets/{es-CErIcckI.js → es-DSTFcl6A.js} +1 -1
  9. package/dist/assets/{fr-z5ORYrou.js → fr-CEeK5ifb.js} +1 -1
  10. package/dist/assets/index-DUBtXIPQ.css +1 -0
  11. package/dist/assets/{index-DMCrPMIW.js → index-Dld5wFqI.js} +3 -3
  12. package/dist/assets/{ja-ecPbYMn0.js → ja-pu3u7ZOY.js} +1 -1
  13. package/dist/assets/{ko-CASkpaQH.js → ko-CStr_CJ-.js} +1 -1
  14. package/dist/assets/{main-BTLr2DyB.js → main-DBG0rE6P.js} +36 -36
  15. package/dist/assets/{main-DQ-uX_zf.js → main-Xc2GeALp.js} +2 -2
  16. package/dist/assets/{markdownCore-C4XTgyYU.js → markdownCore-Bn8Ywh-t.js} +2 -2
  17. package/dist/assets/miniChat-D5FFElbH.js +2 -0
  18. package/dist/assets/mobile-B4K4IpE7.js +2 -0
  19. package/dist/assets/{pl-BYtGQyDI.js → pl-nD08d1Bo.js} +1 -1
  20. package/dist/assets/{pt-BR-D8dONk68.js → pt-BR-DqcoQ-nE.js} +1 -1
  21. package/dist/assets/{renderElectronMiniChatApp-Cbdusroc.js → renderElectronMiniChatApp-B-rksap7.js} +2 -2
  22. package/dist/assets/renderMobileApp-U-jxDI_G.js +16 -0
  23. package/dist/assets/runtimeEndpointReset-fpfBYOyW.js +174 -0
  24. package/dist/assets/{uk-C8z1P8tg.js → uk-DkX7DsWk.js} +1 -1
  25. package/dist/assets/{useAppFontEffects-DrLhDSC3.js → useAppFontEffects-CZdEKvZ8.js} +129 -127
  26. package/dist/assets/{vendor-.bun-DvcSrJLa.js → vendor-.bun-BzW0Lgld.js} +1 -1
  27. package/dist/assets/{zh-CN-BwJPtjKq.js → zh-CN-DlqHNM1o.js} +1 -1
  28. package/dist/assets/{zh-TW-C7FpgD-Y.js → zh-TW-DeKAHBhV.js} +1 -1
  29. package/dist/index.html +4 -4
  30. package/dist/mini-chat.html +4 -4
  31. package/dist/mobile.html +4 -4
  32. package/package.json +2 -2
  33. package/server/index.js +31 -2
  34. package/server/lib/openchamber-sessions/routes.js +30 -30
  35. package/server/lib/openchamber-sessions/routes.test.js +38 -0
  36. package/server/lib/opencode/DOCUMENTATION.md +7 -2
  37. package/server/lib/opencode/env-runtime.js +18 -0
  38. package/server/lib/opencode/env-runtime.test.js +12 -0
  39. package/server/lib/opencode/feature-routes-runtime.js +2 -0
  40. package/server/lib/opencode/lifecycle.js +18 -6
  41. package/server/lib/opencode/lifecycle.test.js +67 -1
  42. package/server/lib/opencode/proxy.js +32 -2
  43. package/server/lib/opencode/routes-upgrade.test.js +113 -0
  44. package/server/lib/opencode/routes.js +69 -36
  45. package/server/lib/opencode/server-utils-runtime.js +2 -0
  46. package/server/lib/opencode/settings-helpers.js +3 -0
  47. package/server/lib/opencode/settings-helpers.test.js +8 -0
  48. package/server/lib/opencode/upgrade-capability.js +36 -0
  49. package/server/lib/opencode/upgrade-capability.test.js +57 -0
  50. package/server/lib/quota/providers/codex.js +18 -0
  51. package/server/lib/quota/providers/codex.test.js +28 -0
  52. package/server/lib/scheduled-tasks/runtime.js +44 -18
  53. package/server/lib/scheduled-tasks/runtime.test.js +12 -1
  54. package/server/lib/session-goal/DOCUMENTATION.md +12 -3
  55. package/server/lib/system-prompt/DOCUMENTATION.md +36 -0
  56. package/server/lib/system-prompt/runtime.js +68 -0
  57. package/server/lib/system-prompt/runtime.test.js +76 -0
  58. package/server/opencode-proxy.test.js +49 -0
  59. package/dist/assets/index-Csh1A7Eh.css +0 -1
  60. package/dist/assets/miniChat-ComIlrTa.js +0 -2
  61. package/dist/assets/mobile-DUYXEkKA.js +0 -2
  62. package/dist/assets/renderMobileApp-m9MPmIZT.js +0 -16
  63. package/dist/assets/runtimeEndpointReset-B0yQKPe0.js +0 -174
package/README.md CHANGED
@@ -52,6 +52,9 @@ openchamber update # Update to latest version
52
52
  When OpenChamber launches the local OpenCode server, it also registers a native
53
53
  `openchamber` agent tool for project, session, and scheduled-task orchestration.
54
54
  The tool is not injected when connecting to an external OpenCode server.
55
+ Behavior settings can optionally inject a managed system-prompt optimizer on
56
+ the next OpenCode restart. It is disabled by default and is not available for
57
+ external OpenCode servers.
55
58
 
56
59
  ### Tunnel behavior notes
57
60
 
@@ -1 +1 @@
1
- import{R as s,j as e}from"./vendor-.bun-DvcSrJLa.js";import{u as c}from"./index-DMCrPMIW.js";import{f as j,h as b,I as a}from"./useAppFontEffects-DrLhDSC3.js";import{D as y}from"./main-BTLr2DyB.js";import"./runtimeEndpointReset-B0yQKPe0.js";import"./mobileLayoutPreference-Dio-WWkI.js";import"./SessionSwitcherDropdown-S2EvRz-E.js";function S(){const{t:n}=j(),{files:r}=b(),[t,x]=s.useState(null),[l,o]=s.useState(""),[p,m]=s.useState(!0),u=s.useRef(null),f=c(i=>i.pendingDiagramFile),d=s.useCallback(async i=>{m(!0),x(i);try{const g=await r?.readFile?.(i);g&&o(g.content)}catch{o("")}finally{m(!1)}},[r]);s.useEffect(()=>{if(!f)return;const i=c.getState().consumePendingDiagramFile();i&&d(i)},[d,f]);const h=s.useCallback(async()=>{const i=u.current?.getXml();t&&r?.writeFile&&i&&i!==l&&(await r.writeFile(t,i),o(i))},[t,r,l]),v=t?t.split("/").pop()||t:"";return t?p?e.jsx("div",{className:"flex h-full items-center justify-center p-3",children:e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"})}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[e.jsx(a,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:v}),e.jsx("button",{type:"button",onClick:()=>{h()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:n("filesView.diagram.saveDiagram"),children:e.jsx(a,{name:"save-3",className:"size-4"})}),e.jsx("button",{type:"button",onClick:()=>c.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:n("filesView.diagram.closeDiagramView"),children:e.jsx(a,{name:"close",className:"size-4"})})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(y,{ref:u,xml:l,className:"h-full"})})]}):e.jsx("div",{className:"flex h-full items-center justify-center p-3",children:e.jsx("div",{className:"typography-ui text-muted-foreground",children:n("filesView.editor.pickFileFromTree")})})}export{S as DiagramView};
1
+ import{R as s,j as e}from"./vendor-.bun-BzW0Lgld.js";import{u as c}from"./index-Dld5wFqI.js";import{f as j,h as b,I as a}from"./useAppFontEffects-CZdEKvZ8.js";import{D as y}from"./main-DBG0rE6P.js";import"./runtimeEndpointReset-fpfBYOyW.js";import"./mobileLayoutPreference-Dio-WWkI.js";import"./SessionSwitcherDropdown-DepVWyeA.js";function S(){const{t:n}=j(),{files:r}=b(),[t,x]=s.useState(null),[l,o]=s.useState(""),[p,m]=s.useState(!0),u=s.useRef(null),f=c(i=>i.pendingDiagramFile),d=s.useCallback(async i=>{m(!0),x(i);try{const g=await r?.readFile?.(i);g&&o(g.content)}catch{o("")}finally{m(!1)}},[r]);s.useEffect(()=>{if(!f)return;const i=c.getState().consumePendingDiagramFile();i&&d(i)},[d,f]);const h=s.useCallback(async()=>{const i=u.current?.getXml();t&&r?.writeFile&&i&&i!==l&&(await r.writeFile(t,i),o(i))},[t,r,l]),v=t?t.split("/").pop()||t:"";return t?p?e.jsx("div",{className:"flex h-full items-center justify-center p-3",children:e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"})}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[e.jsx(a,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:v}),e.jsx("button",{type:"button",onClick:()=>{h()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:n("filesView.diagram.saveDiagram"),children:e.jsx(a,{name:"save-3",className:"size-4"})}),e.jsx("button",{type:"button",onClick:()=>c.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:n("filesView.diagram.closeDiagramView"),children:e.jsx(a,{name:"close",className:"size-4"})})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(y,{ref:u,xml:l,className:"h-full"})})]}):e.jsx("div",{className:"flex h-full items-center justify-center p-3",children:e.jsx("div",{className:"typography-ui text-muted-foreground",children:n("filesView.editor.pickFileFromTree")})})}export{S as DiagramView};
@@ -1,12 +1,12 @@
1
- import{R as x,b as V,cl as at,cm as it,cn as st,j as Q}from"./vendor-.bun-DvcSrJLa.js";import{fl as Ie,fm as lt,fn as ct,C as ce,df as dt,dg as mt,fo as ut,fp as ft,h as Oe,i as De,fq as We,y as $e,e0 as pt,f as ht,fr as bt,fs as gt,ft as wt,o as yt,fu as be,fv as At,fw as vt,bv as Et}from"./useAppFontEffects-DrLhDSC3.js";import{G as ge,cw as Ct,u as X,e as we,I as qe,y as kt,z as St,j as Lt}from"./index-DMCrPMIW.js";import{renderMarkdownSync as Mt,renderMarkdownBlocks as Nt}from"./markdownCore-C4XTgyYU.js";const R=t=>Number.isFinite(t)&&t>0,ye=t=>{if(typeof t=="number")return R(t)?t:null;if(typeof t!="string")return null;const e=t.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!e)return null;const n=Number(e[1]);return R(n)?n:null},de=(t,e,n)=>Math.min(n,Math.max(e,t)),Rt=6,Ae=1.25,xt=1.0015,Tt=.5,_t=12,ve=3,Pt=400,ee='[data-markdown="mermaid-block"]',$=t=>t.querySelector(ee)!==null,Ft=t=>[t.x,t.y,t.width,t.height].map(e=>{const n=Number(e.toFixed(Rt));return Object.is(n,-0)?"0":String(n)}).join(" "),It=t=>{const e=t.viewBox?.trim().split(/[\s,]+/).map(i=>Number.parseFloat(i));if(e?.length===4){const[i,a,s,o]=e;if(Number.isFinite(i)&&Number.isFinite(a)&&R(s)&&R(o))return{x:i,y:a,width:s,height:o}}const n=ye(t.width),r=ye(t.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},Ot=t=>{let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(36)},Dt=t=>{const e=t.renderMode||"unknown",n=t.svgMarkup??"";if(!n){const r=[t.viewBox??"",t.width??"",t.height??""];return r.some(i=>i!=="")?`${e}:bounds:${r.join(":")}`:`${e}:no-svg`}return[e,Ot(n)].join(":")},Be=(t,e)=>{if(!R(e.width)||!R(e.height))return t;const n=t.width/t.height,r=e.width/e.height;if(n>r){const a=t.width/r;return{x:t.x,y:t.y-(a-t.height)/2,width:t.width,height:a}}const i=t.height*r;return{x:t.x-(i-t.width)/2,y:t.y,width:i,height:t.height}},Wt=({currentBox:t,viewport:e,delta:n})=>!R(e.width)||!R(e.height)||!R(t.width)||!R(t.height)?t:{x:t.x-n.x/e.width*t.width,y:t.y-n.y/e.height*t.height,width:t.width,height:t.height},$t=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return n*n+r*r>ve*ve},qt=({currentBox:t,contentBox:e,viewport:n,pointer:r,zoomFactor:i,minScale:a,maxScale:s})=>{if(!R(n.width)||!R(n.height)||!R(i)||!R(t.width)||!R(t.height)||!R(e.width)||!R(e.height)||!R(a)||!R(s))return t;const o=Math.min(a,s),l=Math.max(a,s),c=Be(e,n),d=c.width/t.width,f=de(d*i,o,l),u=c.width/f,p=u/(t.width/t.height),b=de(r.x/n.width,0,1),v=de(r.y/n.height,0,1),C=t.x+b*t.width,y=t.y+v*t.height;return{x:C-b*u,y:y-v*p,width:u,height:p}},pe=new WeakMap,Bt=t=>t instanceof HTMLElement?pe.get(t)??null:null,zt=t=>t.querySelector('[data-markdown="mermaid-viewport"]')??t.querySelector('[data-markdown="mermaid"]'),Ee=t=>{const e=t.querySelector('[data-markdown="mermaid"] svg'),n=t.querySelector('[data-markdown="mermaid"]');return Dt({renderMode:t.getAttribute("data-mermaid-render"),svgMarkup:n?.getAttribute("data-md-original-svg")??e?.outerHTML??null,viewBox:e?.getAttribute("viewBox"),width:e?.getAttribute("width"),height:e?.getAttribute("height")})},J=t=>{const e=t.getBoundingClientRect();return{width:e.width,height:e.height}},Vt=(t,e)=>{const n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},Ht=t=>t instanceof Element&&!!t.closest('button, a, [role="button"]'),jt=t=>{const e=zt(t),n=t.querySelector('[data-markdown="mermaid"] svg');if(!e||!n)return null;const r=It({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let i=r,a=null,s=null,o=null,l=null;const c=h=>{i=h,n.setAttribute("viewBox",Ft(h)),n.removeAttribute("width"),n.removeAttribute("height")},d=()=>{c(Be(r,J(e)))},f=(h,k)=>{c(qt({currentBox:i,contentBox:r,viewport:J(e),pointer:h,zoomFactor:k,minScale:Tt,maxScale:_t}))},u=()=>{const h=J(e);f({x:h.width/2,y:h.height/2},Ae)},p=()=>{const h=J(e);f({x:h.width/2,y:h.height/2},1/Ae)},b=h=>{!h.ctrlKey&&!h.metaKey||(h.preventDefault(),h.stopPropagation(),f(Vt(h,e),Math.pow(xt,-h.deltaY)))},v=h=>{h.button!==0||Ht(h.target)||(a=h.pointerId,s={x:h.clientX,y:h.clientY},o=s,l!==null&&(window.clearTimeout(l),l=null),t.removeAttribute("data-mermaid-suppress-click"),e.setPointerCapture?.(h.pointerId),t.setAttribute("data-mermaid-panning","true"),h.preventDefault())},C=h=>{if(a!==h.pointerId||!o)return;const k={x:h.clientX,y:h.clientY};c(Wt({currentBox:i,viewport:J(e),delta:{x:k.x-o.x,y:k.y-o.y}})),o=k,s&&$t(s,k)&&t.setAttribute("data-mermaid-suppress-click","true"),h.preventDefault()},y=h=>{a===h.pointerId&&(e.releasePointerCapture?.(h.pointerId),a=null,s=null,o=null,t.removeAttribute("data-mermaid-panning"),t.hasAttribute("data-mermaid-suppress-click")&&(l=window.setTimeout(()=>{t.removeAttribute("data-mermaid-suppress-click"),l=null},Pt)))},L=()=>{d()};e.addEventListener("wheel",b,{passive:!1}),e.addEventListener("pointerdown",v),e.addEventListener("pointermove",C),e.addEventListener("pointerup",y),e.addEventListener("pointercancel",y),window.addEventListener("resize",L);const M=typeof ResizeObserver>"u"?null:new ResizeObserver(L);return M?.observe(e),d(),{zoomIn:u,zoomOut:p,fit:d,cleanup:()=>{e.removeEventListener("wheel",b),e.removeEventListener("pointerdown",v),e.removeEventListener("pointermove",C),e.removeEventListener("pointerup",y),e.removeEventListener("pointercancel",y),window.removeEventListener("resize",L),M?.disconnect(),l!==null&&window.clearTimeout(l),t.removeAttribute("data-mermaid-panning"),t.removeAttribute("data-mermaid-suppress-click"),pe.delete(t)}}},Kt=t=>{const e=new Map,n=new Map,r=()=>{for(const[a,s]of Array.from(e.entries())){const o=Ee(a);(!t.contains(a)||o!==n.get(a))&&(s.cleanup(),e.delete(a),n.delete(a))}for(const a of Array.from(t.querySelectorAll(ee))){if(e.has(a)||a.querySelector('[data-markdown="mermaid"] svg')===null)continue;const s=jt(a);s&&(e.set(a,s),n.set(a,Ee(a)),pe.set(a,s))}},i=()=>{for(const a of e.values())a.cleanup();e.clear(),n.clear()};return r(),{refresh:r,cleanup:i}},q=t=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${t}"></use></svg>`,ie={copy:q("file-copy"),check:q("check"),download:q("download"),zoomIn:q("add"),zoomOut:q("subtract"),fit:q("refresh"),textWrap:q("text-wrap")},ze="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]",se=(t,e)=>{t.innerHTML=e},W=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className=ze,r.setAttribute("data-md-action",n),r.setAttribute("title",e),r.setAttribute("aria-label",e),se(r,ie[t]),r},Ve=(t,e,n)=>{const r=t.querySelector("[data-md-code-body]"),i=t.querySelector("pre"),a=t.querySelector("pre code"),s=t.querySelectorAll("[data-md-code-line-content]"),o=t.querySelector('[data-md-action="toggle-code-wrap"]');t.setAttribute("data-code-wrap",e?"true":"false"),r?.classList.toggle("overflow-x-auto",!e),r?.classList.toggle("overflow-x-hidden",e),i?.classList.toggle("whitespace-pre-wrap",e),i?.classList.toggle("break-words",e),a?.classList.toggle("whitespace-pre-wrap",e),a?.classList.toggle("break-words",e),i&&(i.style.whiteSpace=e?"pre-wrap":"pre",i.style.overflowWrap=e?"anywhere":"normal"),a&&(a.style.whiteSpace=e?"pre-wrap":"pre",a.style.overflowWrap=e?"anywhere":"normal");for(const l of Array.from(s))l.style.whiteSpace=e?"pre-wrap":"pre",l.style.overflowWrap=e?"anywhere":"normal";if(o){const l=e?n.disableCodeWrap:n.enableCodeWrap;o.setAttribute("title",l),o.setAttribute("aria-label",l),o.classList.toggle("text-foreground",e),o.classList.toggle("opacity-100",e),o.classList.toggle("text-muted-foreground",!e),o.classList.toggle("opacity-65",!e),o.setAttribute("aria-pressed",e?"true":"false")}},He=t=>{const e=t.querySelector(":scope > code");if(!e||e.hasAttribute("data-md-code-lines"))return;const n=e.textContent??"",r=n.endsWith(`
1
+ import{R as x,b as V,cl as at,cm as it,cn as st,j as Q}from"./vendor-.bun-BzW0Lgld.js";import{fm as Ie,fn as lt,fo as ct,C as ce,df as dt,dg as mt,fp as ut,fq as ft,h as Oe,i as De,fr as We,y as $e,e0 as pt,f as ht,fs as bt,ft as gt,fu as wt,o as yt,fv as be,fw as At,fx as vt,bv as Et}from"./useAppFontEffects-CZdEKvZ8.js";import{E as ge,cw as Ct,u as X,d as we,G as qe,w as kt,x as St,r as Lt}from"./index-Dld5wFqI.js";import{renderMarkdownSync as Mt,renderMarkdownBlocks as Nt}from"./markdownCore-Bn8Ywh-t.js";const R=t=>Number.isFinite(t)&&t>0,ye=t=>{if(typeof t=="number")return R(t)?t:null;if(typeof t!="string")return null;const e=t.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!e)return null;const n=Number(e[1]);return R(n)?n:null},de=(t,e,n)=>Math.min(n,Math.max(e,t)),Rt=6,Ae=1.25,xt=1.0015,Tt=.5,_t=12,ve=3,Pt=400,ee='[data-markdown="mermaid-block"]',$=t=>t.querySelector(ee)!==null,Ft=t=>[t.x,t.y,t.width,t.height].map(e=>{const n=Number(e.toFixed(Rt));return Object.is(n,-0)?"0":String(n)}).join(" "),It=t=>{const e=t.viewBox?.trim().split(/[\s,]+/).map(i=>Number.parseFloat(i));if(e?.length===4){const[i,a,s,o]=e;if(Number.isFinite(i)&&Number.isFinite(a)&&R(s)&&R(o))return{x:i,y:a,width:s,height:o}}const n=ye(t.width),r=ye(t.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},Ot=t=>{let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(36)},Dt=t=>{const e=t.renderMode||"unknown",n=t.svgMarkup??"";if(!n){const r=[t.viewBox??"",t.width??"",t.height??""];return r.some(i=>i!=="")?`${e}:bounds:${r.join(":")}`:`${e}:no-svg`}return[e,Ot(n)].join(":")},Be=(t,e)=>{if(!R(e.width)||!R(e.height))return t;const n=t.width/t.height,r=e.width/e.height;if(n>r){const a=t.width/r;return{x:t.x,y:t.y-(a-t.height)/2,width:t.width,height:a}}const i=t.height*r;return{x:t.x-(i-t.width)/2,y:t.y,width:i,height:t.height}},Wt=({currentBox:t,viewport:e,delta:n})=>!R(e.width)||!R(e.height)||!R(t.width)||!R(t.height)?t:{x:t.x-n.x/e.width*t.width,y:t.y-n.y/e.height*t.height,width:t.width,height:t.height},$t=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return n*n+r*r>ve*ve},qt=({currentBox:t,contentBox:e,viewport:n,pointer:r,zoomFactor:i,minScale:a,maxScale:s})=>{if(!R(n.width)||!R(n.height)||!R(i)||!R(t.width)||!R(t.height)||!R(e.width)||!R(e.height)||!R(a)||!R(s))return t;const o=Math.min(a,s),l=Math.max(a,s),c=Be(e,n),d=c.width/t.width,f=de(d*i,o,l),u=c.width/f,p=u/(t.width/t.height),b=de(r.x/n.width,0,1),v=de(r.y/n.height,0,1),C=t.x+b*t.width,y=t.y+v*t.height;return{x:C-b*u,y:y-v*p,width:u,height:p}},pe=new WeakMap,Bt=t=>t instanceof HTMLElement?pe.get(t)??null:null,zt=t=>t.querySelector('[data-markdown="mermaid-viewport"]')??t.querySelector('[data-markdown="mermaid"]'),Ee=t=>{const e=t.querySelector('[data-markdown="mermaid"] svg'),n=t.querySelector('[data-markdown="mermaid"]');return Dt({renderMode:t.getAttribute("data-mermaid-render"),svgMarkup:n?.getAttribute("data-md-original-svg")??e?.outerHTML??null,viewBox:e?.getAttribute("viewBox"),width:e?.getAttribute("width"),height:e?.getAttribute("height")})},J=t=>{const e=t.getBoundingClientRect();return{width:e.width,height:e.height}},Vt=(t,e)=>{const n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},Ht=t=>t instanceof Element&&!!t.closest('button, a, [role="button"]'),Kt=t=>{const e=zt(t),n=t.querySelector('[data-markdown="mermaid"] svg');if(!e||!n)return null;const r=It({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let i=r,a=null,s=null,o=null,l=null;const c=h=>{i=h,n.setAttribute("viewBox",Ft(h)),n.removeAttribute("width"),n.removeAttribute("height")},d=()=>{c(Be(r,J(e)))},f=(h,k)=>{c(qt({currentBox:i,contentBox:r,viewport:J(e),pointer:h,zoomFactor:k,minScale:Tt,maxScale:_t}))},u=()=>{const h=J(e);f({x:h.width/2,y:h.height/2},Ae)},p=()=>{const h=J(e);f({x:h.width/2,y:h.height/2},1/Ae)},b=h=>{!h.ctrlKey&&!h.metaKey||(h.preventDefault(),h.stopPropagation(),f(Vt(h,e),Math.pow(xt,-h.deltaY)))},v=h=>{h.button!==0||Ht(h.target)||(a=h.pointerId,s={x:h.clientX,y:h.clientY},o=s,l!==null&&(window.clearTimeout(l),l=null),t.removeAttribute("data-mermaid-suppress-click"),e.setPointerCapture?.(h.pointerId),t.setAttribute("data-mermaid-panning","true"),h.preventDefault())},C=h=>{if(a!==h.pointerId||!o)return;const k={x:h.clientX,y:h.clientY};c(Wt({currentBox:i,viewport:J(e),delta:{x:k.x-o.x,y:k.y-o.y}})),o=k,s&&$t(s,k)&&t.setAttribute("data-mermaid-suppress-click","true"),h.preventDefault()},y=h=>{a===h.pointerId&&(e.releasePointerCapture?.(h.pointerId),a=null,s=null,o=null,t.removeAttribute("data-mermaid-panning"),t.hasAttribute("data-mermaid-suppress-click")&&(l=window.setTimeout(()=>{t.removeAttribute("data-mermaid-suppress-click"),l=null},Pt)))},L=()=>{d()};e.addEventListener("wheel",b,{passive:!1}),e.addEventListener("pointerdown",v),e.addEventListener("pointermove",C),e.addEventListener("pointerup",y),e.addEventListener("pointercancel",y),window.addEventListener("resize",L);const M=typeof ResizeObserver>"u"?null:new ResizeObserver(L);return M?.observe(e),d(),{zoomIn:u,zoomOut:p,fit:d,cleanup:()=>{e.removeEventListener("wheel",b),e.removeEventListener("pointerdown",v),e.removeEventListener("pointermove",C),e.removeEventListener("pointerup",y),e.removeEventListener("pointercancel",y),window.removeEventListener("resize",L),M?.disconnect(),l!==null&&window.clearTimeout(l),t.removeAttribute("data-mermaid-panning"),t.removeAttribute("data-mermaid-suppress-click"),pe.delete(t)}}},jt=t=>{const e=new Map,n=new Map,r=()=>{for(const[a,s]of Array.from(e.entries())){const o=Ee(a);(!t.contains(a)||o!==n.get(a))&&(s.cleanup(),e.delete(a),n.delete(a))}for(const a of Array.from(t.querySelectorAll(ee))){if(e.has(a)||a.querySelector('[data-markdown="mermaid"] svg')===null)continue;const s=Kt(a);s&&(e.set(a,s),n.set(a,Ee(a)),pe.set(a,s))}},i=()=>{for(const a of e.values())a.cleanup();e.clear(),n.clear()};return r(),{refresh:r,cleanup:i}},q=t=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${t}"></use></svg>`,ie={copy:q("file-copy"),check:q("check"),download:q("download"),zoomIn:q("add"),zoomOut:q("subtract"),fit:q("refresh"),textWrap:q("text-wrap")},ze="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]",se=(t,e)=>{t.innerHTML=e},W=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className=ze,r.setAttribute("data-md-action",n),r.setAttribute("title",e),r.setAttribute("aria-label",e),se(r,ie[t]),r},Ve=(t,e,n)=>{const r=t.querySelector("[data-md-code-body]"),i=t.querySelector("pre"),a=t.querySelector("pre code"),s=t.querySelectorAll("[data-md-code-line-content]"),o=t.querySelector('[data-md-action="toggle-code-wrap"]');t.setAttribute("data-code-wrap",e?"true":"false"),r?.classList.toggle("overflow-x-auto",!e),r?.classList.toggle("overflow-x-hidden",e),i?.classList.toggle("whitespace-pre-wrap",e),i?.classList.toggle("break-words",e),a?.classList.toggle("whitespace-pre-wrap",e),a?.classList.toggle("break-words",e),i&&(i.style.whiteSpace=e?"pre-wrap":"pre",i.style.overflowWrap=e?"anywhere":"normal"),a&&(a.style.whiteSpace=e?"pre-wrap":"pre",a.style.overflowWrap=e?"anywhere":"normal");for(const l of Array.from(s))l.style.whiteSpace=e?"pre-wrap":"pre",l.style.overflowWrap=e?"anywhere":"normal";if(o){const l=e?n.disableCodeWrap:n.enableCodeWrap;o.setAttribute("title",l),o.setAttribute("aria-label",l),o.classList.toggle("text-foreground",e),o.classList.toggle("opacity-100",e),o.classList.toggle("text-muted-foreground",!e),o.classList.toggle("opacity-65",!e),o.setAttribute("aria-pressed",e?"true":"false")}},He=t=>{const e=t.querySelector(":scope > code");if(!e||e.hasAttribute("data-md-code-lines"))return;const n=e.textContent??"",r=n.endsWith(`
2
2
  `),i=r?n.slice(0,-1).split(`
3
3
  `):n.split(`
4
4
  `),a=i.length>0?i:[""],s=Array.from(e.children).filter(c=>c.classList.contains("line"));r&&s.length===a.length+1&&s.at(-1)?.textContent===""&&s.pop();const o=s.length===a.length,l=document.createDocumentFragment();a.forEach((c,d)=>{const f=document.createElement("span");f.setAttribute("data-md-code-line","");const u=document.createElement("span");u.setAttribute("data-md-code-line-number",""),u.setAttribute("aria-hidden","true"),u.textContent=String(d+1);const p=document.createElement("span");if(p.setAttribute("data-md-code-line-content",""),o){const b=s[d];b&&p.append(...Array.from(b.childNodes))}else p.textContent=c;if(f.append(u,p),l.appendChild(f),d<a.length-1||r){const b=document.createElement("span");b.setAttribute("data-md-code-line-break",""),b.textContent=`
5
- `,l.appendChild(b)}}),e.replaceChildren(l),e.setAttribute("data-md-code-lines",""),e.toggleAttribute("data-md-code-trailing-newline",r)},je=t=>{const e=Array.from(t.querySelectorAll("[data-md-code-line-content]"));if(e.length===0)return t.textContent??"";const n=e.map(r=>r.textContent??"").join(`
5
+ `,l.appendChild(b)}}),e.replaceChildren(l),e.setAttribute("data-md-code-lines",""),e.toggleAttribute("data-md-code-trailing-newline",r)},Ke=t=>{const e=Array.from(t.querySelectorAll("[data-md-code-line-content]"));if(e.length===0)return t.textContent??"";const n=e.map(r=>r.textContent??"").join(`
6
6
  `);return t.hasAttribute("data-md-code-trailing-newline")?`${n}
7
7
  `:n},Ut=(t,e,n)=>{const r=t.querySelectorAll('[data-component="markdown-code"]');for(const i of Array.from(r)){const a=i.querySelector("pre");a&&He(a),Ve(i,e,n)}},Ce=(t,e,n,r)=>{se(t,ie.check),t.setAttribute("title",e),t.setAttribute("aria-label",e),window.setTimeout(()=>{se(t,ie[n]),t.setAttribute("title",r),t.setAttribute("aria-label",r)},2e3)},Zt=t=>{const e=t.querySelectorAll(":not(pre) > code");for(const n of Array.from(e))n.getAttribute("data-markdown")!=="inline-code"&&n.setAttribute("data-markdown","inline-code")},Xt=(t,e)=>{const n=t.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const i=r.parentElement;if(!i||i.closest('[data-component="markdown-code"]'))continue;const a=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],s=r.getAttribute("data-md-lang")??a??"text",o=document.createElement("div");o.setAttribute("data-component","markdown-code"),o.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const l=document.createElement("div");l.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const c=document.createElement("span");c.className="font-mono text-[13px] text-muted-foreground",c.textContent=s;const d=W("copy",e.labels.copy,"copy-code"),f=W("textWrap",e.codeBlockLineWrap?e.labels.disableCodeWrap:e.labels.enableCodeWrap,"toggle-code-wrap");l.appendChild(c);const u=document.createElement("div");u.className="flex items-center gap-1",u.setAttribute("data-md-code-actions",""),u.appendChild(f),u.appendChild(d),l.appendChild(u);const p=document.createElement("div");p.setAttribute("data-md-code-body",""),p.className="px-3 py-2.5 overflow-x-auto",i.replaceChild(o,r),r.style.margin="0",r.style.background="transparent",r.classList.add("min-w-0","w-full","flex-1"),e.deferCodeLineNumberSync||He(r),p.appendChild(r),o.appendChild(l),o.appendChild(p),Ve(o,e.codeBlockLineWrap,e.labels)}},ke=t=>{const e=[],n=[],r=t.querySelectorAll("thead th");for(const a of Array.from(r))e.push((a.textContent??"").trim());const i=t.querySelectorAll("tbody tr");for(const a of Array.from(i)){const s=Array.from(a.querySelectorAll("td")).map(o=>(o.textContent??"").trim());s.length>0&&n.push(s)}return{headers:e,rows:n}},Gt=t=>/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t,Se=({headers:t,rows:e})=>[t,...e].map(n=>n.map(Gt).join(",")).join(`
8
8
  `),Yt=({headers:t,rows:e})=>[t,...e].map(n=>n.join(" ")).join(`
9
9
  `),Le=({headers:t,rows:e})=>{const n=`| ${t.join(" | ")} |`,r=`| ${t.map(()=>"---").join(" | ")} |`,i=e.map(a=>`| ${a.join(" | ")} |`).join(`
10
10
  `);return`${n}
11
11
  ${r}
12
- ${i}`},Me=(t,e)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${dt}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",t);for(const r of e){const i=document.createElement("button");i.type="button",i.className=`w-full text-left ${mt}`,i.setAttribute("data-md-action",`${t}-${r.key}`),i.textContent=r.label,n.appendChild(i)}return n},Jt=(t,e)=>{const n=t.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const a=document.createElement("div");a.className="group my-4 flex flex-col space-y-2",a.setAttribute("data-markdown","table-wrapper");const s=document.createElement("div");s.className="flex items-center justify-end gap-1";const o=document.createElement("div");o.className="relative",o.appendChild(W("copy",e.copyTable,"table-copy-toggle")),o.appendChild(Me("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const l=document.createElement("div");l.className="relative",l.appendChild(W("download",e.downloadTable,"table-download-toggle")),l.appendChild(Me("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),s.appendChild(o),s.appendChild(l);const c=document.createElement("div");c.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const d=r.parentElement;if(!d)continue;d.replaceChild(a,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const u of Array.from(r.querySelectorAll("tr")))u.classList.add("border-b","border-border/60");const f=r.querySelector("tbody tr:last-child");f?.classList.remove("border-b"),f?.classList.add("border-0");for(const u of Array.from(r.querySelectorAll("th")))u.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const u of Array.from(r.querySelectorAll("td")))u.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");c.appendChild(r),a.appendChild(s),a.appendChild(c)}},Qt=(t,e)=>{const n=t.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const i=r.parentElement;if(!i)continue;const a=(r.textContent??"").replace(/\s+$/,""),s=e.renderMermaid(a),o=document.createElement("div");o.setAttribute("data-markdown","mermaid-block"),o.setAttribute("data-md-source",a),o.className="group relative";const l=document.createElement("div");l.setAttribute("data-markdown","mermaid-scroll");const c=document.createElement("div");if(c.setAttribute("data-markdown","mermaid-toolbar"),c.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",s.svg){o.setAttribute("data-mermaid-render","svg");const f=document.createElement("div");f.setAttribute("data-markdown","mermaid-viewport");const u=document.createElement("div");if(u.setAttribute("data-markdown","mermaid"),u.setAttribute("data-md-original-svg",s.svg),u.innerHTML=s.svg,f.appendChild(u),l.appendChild(f),e.mermaidControls.showPanZoomControls&&(c.appendChild(W("zoomIn",e.labels.zoomInDiagram,"mermaid-zoom-in")),c.appendChild(W("zoomOut",e.labels.zoomOutDiagram,"mermaid-zoom-out")),c.appendChild(W("fit",e.labels.resetDiagramView,"mermaid-fit"))),e.mermaidControls.copy){const p=W("copy",e.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",a),c.appendChild(p)}if(e.mermaidControls.download){const p=W("download",e.labels.downloadDiagram,"mermaid-download");p.setAttribute("data-md-svg","1"),c.appendChild(p)}}else{o.setAttribute("data-mermaid-render","ascii");const f=document.createElement("pre");if(f.setAttribute("data-markdown","mermaid-ascii"),f.textContent=s.ascii||a,l.appendChild(f),e.mermaidControls.copy){const u=W("copy",e.labels.copyDiagram,"mermaid-copy");u.setAttribute("data-md-source",s.ascii||a),c.appendChild(u)}}o.appendChild(l),o.appendChild(c);const d=i.parentElement;d&&d.replaceChild(o,i)}},en=(t,e)=>{const n=t.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-openchamber-file-link")==="true")continue;const i=r.getAttribute("href")??"";if(!Ie(i))continue;r.setAttribute("data-md-link-decorated","true");const a=lt(i);if(a){const s=document.createElement("span");s.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const o=document.createElement("img");o.src=a,o.alt="",o.setAttribute("aria-hidden","true"),o.loading="lazy",o.decoding="async",o.className="size-3.5 rounded-sm",o.addEventListener("error",()=>s.remove(),{once:!0}),s.appendChild(o),r.parentNode?.insertBefore(s,r)}if(e.onPreviewLoopback&&ct(i)){const s=document.createElement("button");s.type="button",s.className=`ml-1 align-middle ${ze}`,s.setAttribute("data-md-action","preview-loopback"),s.setAttribute("data-md-url",i),s.setAttribute("title",e.labels.previewTitle),s.setAttribute("aria-label",e.labels.previewLabel),se(s,ie.download),r.parentNode?.insertBefore(s,r.nextSibling)}}},Ne=(t,e)=>{Zt(t),Qt(t,e),Xt(t,e),Jt(t,e.labels),en(t,e)},Re=(t,e,n)=>{const r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement("a");a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)},re=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},tn=(t,e)=>{const n=r=>{const i=r.target;if(!(i instanceof Element))return;const a=i.closest("[data-md-action]");if(!a){re(t);return}const s=a.getAttribute("data-md-action")??"";if(s==="copy-code"){const o=a.closest('[data-component="markdown-code"]')?.querySelector("code"),l=o?je(o):"";l&&ce(l).then(()=>Ce(a,e.labels.copied,"copy",e.labels.copy));return}if(s==="toggle-code-wrap"){r.preventDefault(),e.onToggleCodeBlockLineWrap?.();return}if(s==="table-copy-toggle"||s==="table-download-toggle"){r.preventDefault();const o=a.parentElement?.querySelector("[data-md-menu]")??null,l=o?.classList.contains("hidden")??!1;re(t),o&&l&&o.classList.remove("hidden");return}if(s.startsWith("table-copy-")){const o=s.replace("table-copy-",""),l=a.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const c=ke(l),d=o==="csv"?Se(c):o==="tsv"?Yt(c):Le(c);ce(d)}re(t);return}if(s.startsWith("table-download-")){const o=s.replace("table-download-",""),l=a.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const c=ke(l),d=o==="csv"?Se(c):Le(c);Re(o==="csv"?"table.csv":"table.md",d,o==="csv"?"text/csv":"text/markdown")}re(t);return}if(s==="mermaid-copy"){const o=a.getAttribute("data-md-source")??"";o&&ce(o).then(()=>Ce(a,e.labels.copied,"copy",e.labels.copyDiagram));return}if(s==="mermaid-zoom-in"||s==="mermaid-zoom-out"||s==="mermaid-fit"){r.preventDefault();const o=a.closest('[data-markdown="mermaid-block"]'),l=Bt(o);s==="mermaid-zoom-in"?l?.zoomIn():s==="mermaid-zoom-out"?l?.zoomOut():l?.fit();return}if(s==="mermaid-download"){const o=a.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),l=o?.getAttribute("data-md-original-svg")??o?.innerHTML??"";l&&Re("diagram.svg",l,"image/svg+xml;charset=utf-8");return}if(s==="preview-loopback"){r.preventDefault();const o=a.getAttribute("data-md-url")??"";o&&e.onPreviewLoopback?.(o);return}};return t.addEventListener("click",n),()=>t.removeEventListener("click",n)},xe=(t,e,n)=>{let r=0;for(const a of t){const s=r+a.data.length;if(e<s||e===s&&n==="left")return{node:a,offset:Math.max(0,e-r)};r=s}const i=t.at(-1);return i?{node:i,offset:i.data.length}:null},nn=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Te=Array.from(nn).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),rn=t=>ft(t),on=t=>ut(t),le=t=>{let e=(t||"").trim();return e?((e.startsWith("`")&&e.endsWith("`")||e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e=e.replace(/[.,;!?]+$/g,""),e.endsWith(")")&&!e.includes("(")&&(e=e.slice(0,-1)),e.endsWith("]")&&!e.includes("[")&&(e=e.slice(0,-1)),e):""},oe=t=>{let e=le(t);if(!e)return"";const n=e.indexOf(";");n>=0&&(e=e.slice(0,n)),e=e.replace(/#.*$/,"");const r=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(e=r[1]??e);const i=Te.length>0?e.match(new RegExp(`^(.*(?:/|^)(${Te})):.*$`,"i")):null;return i&&(e=i[1]??e),le(e)},Ke=t=>{const e=le(t);if(!e)return null;const n=e.indexOf(";"),r=n>=0?le(e.slice(0,n)):e;if(!r)return null;const i=r.match(/^(.*?):(\d+)-(\d+)$/);if(i){const l=oe(i[1]??""),c=Number.parseInt(i[2]??"",10),d=Number.parseInt(i[3]??"",10);return!l||!Number.isFinite(c)||!Number.isFinite(d)||d<c?null:{path:l,line:c,endLine:d}}const a=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(a){const l=oe(a[1]??""),c=Number.parseInt(a[2]??"",10),d=a[3]?Number.parseInt(a[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const s=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(s){const l=oe(s[1]??""),c=Number.parseInt(s[2]??"",10),d=s[3]?Number.parseInt(s[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const o=oe(r);return o?{path:o}:null},me=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,Ue=()=>{const t=V.c(4),e=pt();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=we(!1),t[0]=n):n=t[0];const r=n;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=we(!0),t[1]=i):i=t[1];const a=i;let s;return t[2]!==e?.currentTheme?(s=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?a:r),t[2]=e?.currentTheme,t[3]=s):s=t[3],s},Ze=t=>{const e=V.c(4),{containerRef:n,enabled:r}=t;let i,a;e[0]!==n||e[1]!==r?(i=()=>{if(r===!1)return;const s=n.current;if(!s)return;const o=Nn;return s.addEventListener("click",o),()=>{s.removeEventListener("click",o)}},a=[n,r],e[0]=n,e[1]=r,e[2]=i,e[3]=a):(i=e[2],a=e[3]),x.useEffect(i,a)},Y={download:!0,copy:!0,showPanZoomControls:!0},Xe=!0,an=t=>{const e=t.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return e?t.slice(e[0].length):t},_e='[data-openchamber-file-link="true"]',Ge="data-openchamber-block-path-token",Ye=`[${Ge}]`,G="data-openchamber-block-paths-scanned",sn=2e5,ln=4,cn=1e3,dn=200,mn=80,un=40,Pe=160,B=new Map;let ae=0;const Fe=[],fn=()=>qe()?dn:cn,pn=()=>qe()?un:mn,hn=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),he=t=>rn(t),bn=t=>on(t),gn=(t,e)=>Et(t,e),wn=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},Je=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=he(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return hn.has(r)||r.startsWith(".")&&r.length>1?!0:wn(e)},Qe=t=>{const e=Ke(t);return e?Je(e.path):!1},yn=t=>{const e=t.querySelectorAll(Ye);for(const r of Array.from(e))r.replaceWith(t.ownerDocument.createTextNode(r.textContent??""));const n=t.querySelectorAll(`code[${G}]`);for(const r of Array.from(n))r.removeAttribute(G),r.normalize()},ue=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim();if(e&&Qe(e))return e}return(t.textContent||"").trim()},An=t=>{const e=t.querySelectorAll("pre code");if(e.length===0)return;const n=t.ownerDocument;if(n)for(const r of Array.from(e)){if(r.getAttribute(G)==="true")continue;if((r.textContent??"").length>sn){r.setAttribute(G,"true");continue}const i=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),a=[];let s=i.nextNode();for(;s;){const d=s;d.parentElement?.closest("[data-md-code-line-number]")||a.push(d),s=i.nextNode()}const o=je(r);if(!o.includes(".")){r.setAttribute(G,"true");continue}me.lastIndex=0;const l=[];let c=me.exec(o);for(;c;){const d=c[0];d&&Qe(d)&&l.push({start:c.index,end:c.index+d.length,raw:d}),c=me.exec(o)}for(const{start:d,end:f,raw:u}of l.reverse()){const p=xe(a,d,"right"),b=xe(a,f,"left");if(!p||!b)continue;const v=n.createRange();v.setStart(p.node,p.offset),v.setEnd(b.node,b.offset);const C=n.createElement("span");C.setAttribute(Ge,"true"),C.textContent=u,v.deleteContents(),v.insertNode(C)}r.setAttribute(G,"true")}},fe=(t,e)=>{const n=Ke(t);if(!n||!Je(n.path))return null;const r=bn(n.path)?he(n.path):gn(e,n.path);return r?{...n,resolvedPath:r}:null},vn=t=>{const e=he(t);if(!e)return Promise.resolve(!1);const n=B.get(e);if(n)return B.delete(e),B.set(e,n),n;const r=new Promise(a=>{const s=()=>{ae+=1,Lt(`/api/fs/stat?path=${encodeURIComponent(e)}&optional=true`,{method:"GET",cache:"no-store"}).then(async o=>{if(!o.ok){a(!1);return}const l=await o.json().catch(()=>null);a(l?.exists!==!1)}).catch(()=>a(!1)).finally(()=>{ae=Math.max(0,ae-1),Fe.shift()?.()})};if(ae<ln){s();return}Fe.push(s)}),i=fn();for(;B.size>=i;){const a=B.keys().next().value;if(typeof a!="string")break;B.delete(a)}return B.set(e,r),r},En=(t,e)=>t||vt(t,e),et=t=>{const e=V.c(7),{containerRef:n,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,enabled:s}=t,o=x.useRef(null);let l,c;e[0]!==n||e[1]!==i||e[2]!==r||e[3]!==s||e[4]!==a?(l=()=>{const d=n.current;if(!d)return;let f=!1;const u=pn(),p=s&&!gt(),b=Rn,v=()=>{const w=d.querySelectorAll(_e);for(const g of Array.from(w))b(g);yn(d)};if(!p){v();return}const C=w=>{const g=w;if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){y();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{f||y()})},g)},y=()=>{p&&An(d);const w=d.querySelectorAll(`[data-markdown="inline-code"], a, ${Ye}`);let g=0;for(const m of Array.from(w)){const A=ue(m),E=fe(A,r);if(b(m),!E||g>=u)continue;g=g+1,(kt()&&St()&&!be(E.resolvedPath,r)?Promise.resolve(!0):vn(E.resolvedPath)).then(D=>{if(f||!D||!d.contains(m))return;const I=ue(m),S=fe(I,r);!S||S.resolvedPath!==E.resolvedPath||(m.setAttribute("data-openchamber-file-link","true"),m.setAttribute("data-openchamber-file-ref",I),m.setAttribute("data-openchamber-file-path",S.resolvedPath),m.setAttribute("title","Open file"),m.tagName.toLowerCase()!=="a"&&(m.setAttribute("role","button"),m.setAttribute("tabindex","0")))})}},L=async w=>{const g=w.getAttribute("data-openchamber-file-ref")||ue(w),m=fe(g,r);if(!m)return;const A=En(r,m.resolvedPath);if(a&&i){i.openFile(m.resolvedPath,Number.isFinite(m.line??Number.NaN)?Math.max(1,Math.trunc(m.line)):void 0,Number.isFinite(m.column??Number.NaN)?Math.max(1,Math.trunc(m.column)):void 0);return}be(m.resolvedPath,r)||await At(m.resolvedPath,r);const E=X.getState();Number.isFinite(m.line??Number.NaN)?E.openContextFileAtLine(A,m.resolvedPath,Math.max(1,Math.trunc(m.line)),Number.isFinite(m.column??Number.NaN)?Math.max(1,Math.trunc(m.column)):1):E.openContextFile(A,m.resolvedPath)},M=w=>{const g=w.target;if(!(g instanceof Element))return;const m=g.closest(_e);m instanceof HTMLElement&&(w.preventDefault(),w.stopPropagation(),L(m))},h=w=>{if(w.key!=="Enter"&&w.key!==" ")return;const g=w.target;!(g instanceof HTMLElement)||g.getAttribute("data-openchamber-file-link")!=="true"||(w.preventDefault(),w.stopPropagation(),L(g))};C(Pe);const k=new MutationObserver(()=>{C(Pe)});return k.observe(d,{childList:!0,subtree:!0}),d.addEventListener("click",M),d.addEventListener("keydown",h),()=>{f=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,k.disconnect(),d.removeEventListener("click",M),d.removeEventListener("keydown",h)}},c=[n,i,r,a,s],e[0]=n,e[1]=i,e[2]=r,e[3]=s,e[4]=a,e[5]=l,e[6]=c):(l=e[5],c=e[6]),x.useEffect(l,c)},tt=t=>{const e=V.c(7),{containerRef:n,onShowPopup:r,enableFullscreen:i,enablePanZoom:a,allowMermaidWheelEvents:s}=t;let o,l;e[0]!==s||e[1]!==n||e[2]!==i||e[3]!==a||e[4]!==r?(o=()=>{const c=n.current;if(!c)return;const d=u=>{if(!i||!r)return;const p=u.target;if(!(p instanceof Element)||p.closest('button, a, [role="button"]'))return;const b=p.closest(ee);if(!b)return;if(b instanceof HTMLElement&&b.hasAttribute("data-mermaid-suppress-click")){b.removeAttribute("data-mermaid-suppress-click");return}const C=Array.from(c.querySelectorAll(ee)).indexOf(b);if(C<0)return;const y=b instanceof HTMLElement?b.getAttribute("data-md-source"):null;if(!y||y.trim().length===0)return;const L=`Diagram ${C+1}`;r({open:!0,title:L,content:"",metadata:{tool:"mermaid-preview",filename:L},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(y)}`,source:y,filename:L}})},f=u=>{if(s||(u.ctrlKey||u.metaKey)&&a)return;const p=u.target;!(p instanceof Element)||!p.closest(ee)||u.stopPropagation()};return c.addEventListener("click",d),c.addEventListener("wheel",f,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",d),c.removeEventListener("wheel",f,!0)}},l=[s,n,i,a,r],e[0]=s,e[1]=n,e[2]=i,e[3]=a,e[4]=r,e[5]=o,e[6]=l):(o=e[5],l=e[6]),x.useEffect(o,l)},z=new Map,Cn=100,kn=(t,e)=>{const n=z.get(t);if(n)return z.delete(t),z.set(t,n),n;const r=e();if(z.set(t,r),z.size>Cn){const i=z.keys().next().value;i&&z.delete(i)}return r},Sn=t=>({bg:t.colors.surface.elevated,fg:t.colors.surface.foreground,line:t.colors.interactive.border,accent:t.colors.primary.base,muted:t.colors.surface.mutedForeground,surface:t.colors.surface.muted,border:t.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),nt=(t,e,n,r=Y)=>{const{t:i}=ht(),a=x.useMemo(()=>({copy:i("markdownRenderer.code.actions.copyTitle"),copied:i("markdownRenderer.code.actions.copiedTitle"),enableCodeWrap:i("markdownRenderer.code.actions.enableWrapTitle"),disableCodeWrap:i("markdownRenderer.code.actions.disableWrapTitle"),copyTable:i("markdownRenderer.table.actions.copyTitle"),downloadTable:i("markdownRenderer.table.actions.downloadTitle"),copyDiagram:i("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:i("markdownRenderer.mermaid.actions.downloadSvgTitle"),zoomInDiagram:i("markdownRenderer.mermaid.actions.zoomInTitle"),zoomOutDiagram:i("markdownRenderer.mermaid.actions.zoomOutTitle"),resetDiagramView:i("markdownRenderer.mermaid.actions.resetViewTitle"),previewLabel:i("terminalView.preview.open"),previewTitle:i("terminalView.preview.openTitle")}),[i]),s=X(c=>c.codeBlockLineWrap),o=X(c=>c.setCodeBlockLineWrap),l=x.useCallback(()=>{o(!X.getState().codeBlockLineWrap)},[o]);return x.useMemo(()=>{const c=Sn(t),d=X.getState().mermaidRenderingMode,f=t.metadata?.id??"theme";return{labels:a,mermaidControls:r,codeBlockLineWrap:s,deferCodeLineNumberSync:e,onToggleCodeBlockLineWrap:l,renderMermaid:p=>kn(`${f}:${d}:${p}`,()=>{try{return d==="ascii"?{ascii:at(p)}:{svg:it(p,c)}}catch{return{}}}),onPreviewLoopback:n}},[t,a,r,s,e,l,n])},rt=t=>{const e=V.c(33),{containerRef:n,text:r,streaming:i,cacheKey:a,syntaxVars:s,ctx:o}=t;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=[],e[0]=l):l=e[0],x.useEffect(xn,l);const c=x.useRef(null);let d;e[1]!==n?(d=()=>{const m=n.current;if(m){if(!c.current){if(!$(m))return;c.current=Kt(m);return}c.current.refresh()}},e[1]=n,e[2]=d):d=e[2];const f=d;let u,p;e[3]!==n||e[4]!==o||e[5]!==f||e[6]!==r?(u=()=>{const m=n.current,A=m?.querySelector("[data-markdown-content]")??m;if(A&&r&&A.childNodes.length===0){const E=document.createElement("div");E.setAttribute("data-md-block",""),E.style.display="contents",E.innerHTML=Mt(r),Ne(E,o),A.appendChild(E),$(E)&&f()}},p=[n,r,o,f],e[3]=n,e[4]=o,e[5]=f,e[6]=r,e[7]=u,e[8]=p):(u=e[7],p=e[8]),x.useLayoutEffect(u,p);let b,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=()=>()=>{c.current?.cleanup(),c.current=null},v=[],e[9]=b,e[10]=v):(b=e[9],v=e[10]),x.useEffect(b,v);let C,y;e[11]!==a||e[12]!==n||e[13]!==o||e[14]!==f||e[15]!==i||e[16]!==r?(C=()=>{const m=n.current;if(!m)return;const A=m.querySelector("[data-markdown-content]")??m;let E=!0;return Nt(r,i,a).then(_=>{if(!E)return;const F=Array.from(A.children);_.forEach((S,T)=>{let N=F[T];if(N||(N=document.createElement("div"),N.setAttribute("data-md-block",""),N.style.display="contents",A.appendChild(N)),N.getAttribute("data-md-id")===S.id)return;const P=document.createElement("div");P.innerHTML=S.html,Ne(P,o);const O=$(N),H=$(P);st(N,P,{childrenOnly:!0,onBeforeElUpdated:Tn}),N.setAttribute("data-md-id",S.id),(O||H||$(N))&&f()});const D=$(A);let I=!1;for(let S=F.length-1;S>=_.length;S=S-1,S){const T=F[S];T&&$(T)&&(I=!0),T?.remove()}(I||F.length>_.length&&D)&&f()}),()=>{E=!1}},y=[n,r,i,a,o,f],e[11]=a,e[12]=n,e[13]=o,e[14]=f,e[15]=i,e[16]=r,e[17]=C,e[18]=y):(C=e[17],y=e[18]),x.useEffect(C,y);let L,M;e[19]!==n||e[20]!==o?(M=()=>{const m=n.current;if(m)return tn(m,o)},L=[n,o],e[19]=n,e[20]=o,e[21]=L,e[22]=M):(L=e[21],M=e[22]),x.useEffect(M,L);let h,k;e[23]!==n||e[24]!==s?(h=()=>{const m=n.current,A=m?.querySelector("[data-markdown-content]")??m;if(A)for(const[E,_]of Object.entries(s))A.style.setProperty(E,_)},k=[n,s],e[23]=n,e[24]=s,e[25]=h,e[26]=k):(h=e[25],k=e[26]),x.useEffect(h,k);let w,g;e[27]!==n||e[28]!==o.codeBlockLineWrap||e[29]!==o.deferCodeLineNumberSync||e[30]!==o.labels?(w=()=>{const m=n.current,A=m?.querySelector("[data-markdown-content]")??m;A&&(o.deferCodeLineNumberSync||Ut(A,o.codeBlockLineWrap,o.labels))},g=[n,o.codeBlockLineWrap,o.deferCodeLineNumberSync,o.labels],e[27]=n,e[28]=o.codeBlockLineWrap,e[29]=o.deferCodeLineNumberSync,e[30]=o.labels,e[31]=w,e[32]=g):(w=e[31],g=e[32]),x.useEffect(w,g)},ot=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",Ln=t=>{const e=V.c(32),{content:n,part:r,messageId:i,isAnimated:a,skipFadeIn:s,className:o,isStreaming:l,disableStreamAnimation:c,variant:d,onShowPopup:f,enableFileReferences:u}=t,p=a===void 0?!0:a,b=s===void 0?!1:s,v=l===void 0?!1:l,C=c===void 0?!1:c,y=d===void 0?"assistant":d,L=u===void 0?!0:u;ge("ui.markdown_renderer.render"),v&&ge("ui.markdown_renderer.render.streaming"),Ct("ui.markdown_renderer.content_len",n.length);const M=Ue(),{editor:h,runtime:k}=Oe(),w=x.useRef(null),g=De()??"",m=X(_n);let A;e[0]!==g||e[1]!==m?(A=Z=>{g&&m(g,Z)},e[0]=g,e[1]=m,e[2]=A):A=e[2];const E=A,_=v&&!C;let F;e[3]!==f?(F={containerRef:w,onShowPopup:f,enableFullscreen:Xe,enablePanZoom:Y.showPanZoomControls},e[3]=f,e[4]=F):F=e[4],tt(F);const D=L&&!v;let I;e[5]!==h||e[6]!==g||e[7]!==k.isVSCode||e[8]!==D?(I={containerRef:w,effectiveDirectory:g,editor:h,preferRuntimeEditor:k.isVSCode,enabled:D},e[5]=h,e[6]=g,e[7]=k.isVSCode,e[8]=D,e[9]=I):I=e[9],et(I);let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S={containerRef:w},e[10]=S):S=e[10],Ze(S);let T;e[11]!==M?(T=We(M),e[11]=M,e[12]=T):T=e[12];const N=T,P=nt(M,_,g?E:void 0,Y),O=`markdown-${r?.id?`part-${r.id}`:`message-${i}`}`;let H;e[13]!==O||e[14]!==n||e[15]!==P||e[16]!==_||e[17]!==N?(H={containerRef:w,text:n,streaming:_,cacheKey:O,syntaxVars:N,ctx:P},e[13]=O,e[14]=n,e[15]=P,e[16]=_,e[17]=N,e[18]=H):H=e[18],rt(H);let j;e[19]!==o?(j=$e("break-words w-full min-w-0",o),e[19]=o,e[20]=j):j=e[20];let K;e[21]!==y?(K=ot(y),e[21]=y,e[22]=K):K=e[22];let U;e[23]!==K?(U=Q.jsx("div",{className:K,"data-markdown-content":!0}),e[23]=K,e[24]=U):U=e[24];let te;e[25]!==j||e[26]!==U?(te=Q.jsx("div",{className:j,ref:w,children:U}),e[25]=j,e[26]=U,e[27]=te):te=e[27];const ne=te;if(p){let Z;return e[28]!==O||e[29]!==ne||e[30]!==b?(Z=Q.jsx(wt,{skipAnimation:b,children:ne},O),e[28]=O,e[29]=ne,e[30]=b,e[31]=Z):Z=e[31],Z}return ne},Dn=x.memo(Ln,(t,e)=>t.content===e.content&&t.isStreaming===e.isStreaming&&t.disableStreamAnimation===e.disableStreamAnimation&&t.variant===e.variant&&t.isAnimated===e.isAnimated&&t.skipFadeIn===e.skipFadeIn&&t.className===e.className&&t.messageId===e.messageId&&t.onShowPopup===e.onShowPopup&&t.enableFileReferences===e.enableFileReferences&&t.part?.id===e.part?.id),Mn=t=>{const e=V.c(30),{content:n,className:r,variant:i,disableLinkSafety:a,stripFrontmatter:s,onShowPopup:o,mermaidControls:l,allowMermaidWheelEvents:c,enableFileReferences:d}=t,f=i===void 0?"assistant":i,u=s===void 0?!1:s,p=l===void 0?Y:l,b=c===void 0?!1:c,v=d===void 0?!0:d,{editor:C,runtime:y}=Oe(),L=Ue(),M=x.useRef(null),h=De()??"";let k;e[0]!==n||e[1]!==u?(k=u?an(n):n,e[0]=n,e[1]=u,e[2]=k):k=e[2];const w=k;let g;e[3]!==b||e[4]!==p.showPanZoomControls||e[5]!==o?(g={containerRef:M,onShowPopup:o,enableFullscreen:Xe,enablePanZoom:p.showPanZoomControls,allowMermaidWheelEvents:b},e[3]=b,e[4]=p.showPanZoomControls,e[5]=o,e[6]=g):g=e[6],tt(g);let m;e[7]!==C||e[8]!==h||e[9]!==v||e[10]!==y.isVSCode?(m={containerRef:M,effectiveDirectory:h,editor:C,preferRuntimeEditor:y.isVSCode,enabled:v},e[7]=C,e[8]=h,e[9]=v,e[10]=y.isVSCode,e[11]=m):m=e[11],et(m);const A=!a;let E;e[12]!==A?(E={containerRef:M,enabled:A},e[12]=A,e[13]=E):E=e[13],Ze(E);let _;e[14]!==L?(_=We(L),e[14]=L,e[15]=_):_=e[15];const F=_,D=nt(L,!1,void 0,p),I=`simple:${f}`;let S;e[16]!==D||e[17]!==w||e[18]!==F||e[19]!==I?(S={containerRef:M,text:w,streaming:!1,cacheKey:I,syntaxVars:F,ctx:D},e[16]=D,e[17]=w,e[18]=F,e[19]=I,e[20]=S):S=e[20],rt(S);let T;e[21]!==r?(T=$e("break-words w-full min-w-0",r),e[21]=r,e[22]=T):T=e[22];let N;e[23]!==f?(N=ot(f),e[23]=f,e[24]=N):N=e[24];let P;e[25]!==N?(P=Q.jsx("div",{className:N,"data-markdown-content":!0}),e[25]=N,e[26]=P):P=e[26];let O;return e[27]!==T||e[28]!==P?(O=Q.jsx("div",{className:T,ref:M,children:P}),e[27]=T,e[28]=P,e[29]=O):O=e[29],O},Wn=x.memo(Mn,(t,e)=>{const n=t.mermaidControls??Y,r=e.mermaidControls??Y;return t.content===e.content&&t.variant===e.variant&&t.className===e.className&&t.disableLinkSafety===e.disableLinkSafety&&t.stripFrontmatter===e.stripFrontmatter&&t.onShowPopup===e.onShowPopup&&n.download===r.download&&n.copy===r.copy&&n.showPanZoomControls===r.showPanZoomControls&&t.allowMermaidWheelEvents===e.allowMermaidWheelEvents&&t.enableFileReferences===e.enableFileReferences});function Nn(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;const e=t.target;if(!(e instanceof Element))return;const n=e.closest("a[href]");if(!(n instanceof HTMLAnchorElement)||n.getAttribute("data-openchamber-file-link")==="true")return;const r=n.getAttribute("href")??"";Ie(r)&&(t.preventDefault(),t.stopPropagation(),yt(r))}function Rn(t){t.removeAttribute("data-openchamber-file-link"),t.removeAttribute("data-openchamber-file-ref"),t.removeAttribute("data-openchamber-file-path"),t.getAttribute("title")==="Open file"&&t.removeAttribute("title"),t.tagName.toLowerCase()!=="a"&&(t.removeAttribute("role"),t.removeAttribute("tabindex"))}function xn(){bt()}function Tn(t,e){return!t.isEqualNode(e)}function _n(t){return t.openContextPreview}export{Dn as MarkdownRenderer,Wn as SimpleMarkdownRenderer};
12
+ ${i}`},Me=(t,e)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${dt}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",t);for(const r of e){const i=document.createElement("button");i.type="button",i.className=`w-full text-left ${mt}`,i.setAttribute("data-md-action",`${t}-${r.key}`),i.textContent=r.label,n.appendChild(i)}return n},Jt=(t,e)=>{const n=t.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const a=document.createElement("div");a.className="group my-4 flex flex-col space-y-2",a.setAttribute("data-markdown","table-wrapper");const s=document.createElement("div");s.className="flex items-center justify-end gap-1";const o=document.createElement("div");o.className="relative",o.appendChild(W("copy",e.copyTable,"table-copy-toggle")),o.appendChild(Me("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const l=document.createElement("div");l.className="relative",l.appendChild(W("download",e.downloadTable,"table-download-toggle")),l.appendChild(Me("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),s.appendChild(o),s.appendChild(l);const c=document.createElement("div");c.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const d=r.parentElement;if(!d)continue;d.replaceChild(a,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const u of Array.from(r.querySelectorAll("tr")))u.classList.add("border-b","border-border/60");const f=r.querySelector("tbody tr:last-child");f?.classList.remove("border-b"),f?.classList.add("border-0");for(const u of Array.from(r.querySelectorAll("th")))u.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const u of Array.from(r.querySelectorAll("td")))u.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");c.appendChild(r),a.appendChild(s),a.appendChild(c)}},Qt=(t,e)=>{const n=t.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const i=r.parentElement;if(!i)continue;const a=(r.textContent??"").replace(/\s+$/,""),s=e.renderMermaid(a),o=document.createElement("div");o.setAttribute("data-markdown","mermaid-block"),o.setAttribute("data-md-source",a),o.className="group relative";const l=document.createElement("div");l.setAttribute("data-markdown","mermaid-scroll");const c=document.createElement("div");if(c.setAttribute("data-markdown","mermaid-toolbar"),c.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",s.svg){o.setAttribute("data-mermaid-render","svg");const f=document.createElement("div");f.setAttribute("data-markdown","mermaid-viewport");const u=document.createElement("div");if(u.setAttribute("data-markdown","mermaid"),u.setAttribute("data-md-original-svg",s.svg),u.innerHTML=s.svg,f.appendChild(u),l.appendChild(f),e.mermaidControls.showPanZoomControls&&(c.appendChild(W("zoomIn",e.labels.zoomInDiagram,"mermaid-zoom-in")),c.appendChild(W("zoomOut",e.labels.zoomOutDiagram,"mermaid-zoom-out")),c.appendChild(W("fit",e.labels.resetDiagramView,"mermaid-fit"))),e.mermaidControls.copy){const p=W("copy",e.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",a),c.appendChild(p)}if(e.mermaidControls.download){const p=W("download",e.labels.downloadDiagram,"mermaid-download");p.setAttribute("data-md-svg","1"),c.appendChild(p)}}else{o.setAttribute("data-mermaid-render","ascii");const f=document.createElement("pre");if(f.setAttribute("data-markdown","mermaid-ascii"),f.textContent=s.ascii||a,l.appendChild(f),e.mermaidControls.copy){const u=W("copy",e.labels.copyDiagram,"mermaid-copy");u.setAttribute("data-md-source",s.ascii||a),c.appendChild(u)}}o.appendChild(l),o.appendChild(c);const d=i.parentElement;d&&d.replaceChild(o,i)}},en=(t,e)=>{const n=t.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-openchamber-file-link")==="true")continue;const i=r.getAttribute("href")??"";if(!Ie(i))continue;r.setAttribute("data-md-link-decorated","true");const a=lt(i);if(a){const s=document.createElement("span");s.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const o=document.createElement("img");o.src=a,o.alt="",o.setAttribute("aria-hidden","true"),o.loading="lazy",o.decoding="async",o.className="size-3.5 rounded-sm",o.addEventListener("error",()=>s.remove(),{once:!0}),s.appendChild(o),r.parentNode?.insertBefore(s,r)}if(e.onPreviewLoopback&&ct(i)){const s=document.createElement("button");s.type="button",s.className=`ml-1 align-middle ${ze}`,s.setAttribute("data-md-action","preview-loopback"),s.setAttribute("data-md-url",i),s.setAttribute("title",e.labels.previewTitle),s.setAttribute("aria-label",e.labels.previewLabel),se(s,ie.download),r.parentNode?.insertBefore(s,r.nextSibling)}}},Ne=(t,e)=>{Zt(t),Qt(t,e),Xt(t,e),Jt(t,e.labels),en(t,e)},Re=(t,e,n)=>{const r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement("a");a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)},re=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},tn=(t,e)=>{const n=r=>{const i=r.target;if(!(i instanceof Element))return;const a=i.closest("[data-md-action]");if(!a){re(t);return}const s=a.getAttribute("data-md-action")??"";if(s==="copy-code"){const o=a.closest('[data-component="markdown-code"]')?.querySelector("code"),l=o?Ke(o):"";l&&ce(l).then(()=>Ce(a,e.labels.copied,"copy",e.labels.copy));return}if(s==="toggle-code-wrap"){r.preventDefault(),e.onToggleCodeBlockLineWrap?.();return}if(s==="table-copy-toggle"||s==="table-download-toggle"){r.preventDefault();const o=a.parentElement?.querySelector("[data-md-menu]")??null,l=o?.classList.contains("hidden")??!1;re(t),o&&l&&o.classList.remove("hidden");return}if(s.startsWith("table-copy-")){const o=s.replace("table-copy-",""),l=a.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const c=ke(l),d=o==="csv"?Se(c):o==="tsv"?Yt(c):Le(c);ce(d)}re(t);return}if(s.startsWith("table-download-")){const o=s.replace("table-download-",""),l=a.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const c=ke(l),d=o==="csv"?Se(c):Le(c);Re(o==="csv"?"table.csv":"table.md",d,o==="csv"?"text/csv":"text/markdown")}re(t);return}if(s==="mermaid-copy"){const o=a.getAttribute("data-md-source")??"";o&&ce(o).then(()=>Ce(a,e.labels.copied,"copy",e.labels.copyDiagram));return}if(s==="mermaid-zoom-in"||s==="mermaid-zoom-out"||s==="mermaid-fit"){r.preventDefault();const o=a.closest('[data-markdown="mermaid-block"]'),l=Bt(o);s==="mermaid-zoom-in"?l?.zoomIn():s==="mermaid-zoom-out"?l?.zoomOut():l?.fit();return}if(s==="mermaid-download"){const o=a.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),l=o?.getAttribute("data-md-original-svg")??o?.innerHTML??"";l&&Re("diagram.svg",l,"image/svg+xml;charset=utf-8");return}if(s==="preview-loopback"){r.preventDefault();const o=a.getAttribute("data-md-url")??"";o&&e.onPreviewLoopback?.(o);return}};return t.addEventListener("click",n),()=>t.removeEventListener("click",n)},xe=(t,e,n)=>{let r=0;for(const a of t){const s=r+a.data.length;if(e<s||e===s&&n==="left")return{node:a,offset:Math.max(0,e-r)};r=s}const i=t.at(-1);return i?{node:i,offset:i.data.length}:null},nn=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Te=Array.from(nn).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),rn=t=>ft(t),on=t=>ut(t),le=t=>{let e=(t||"").trim();return e?((e.startsWith("`")&&e.endsWith("`")||e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e=e.replace(/[.,;!?]+$/g,""),e.endsWith(")")&&!e.includes("(")&&(e=e.slice(0,-1)),e.endsWith("]")&&!e.includes("[")&&(e=e.slice(0,-1)),e):""},oe=t=>{let e=le(t);if(!e)return"";const n=e.indexOf(";");n>=0&&(e=e.slice(0,n)),e=e.replace(/#.*$/,"");const r=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(e=r[1]??e);const i=Te.length>0?e.match(new RegExp(`^(.*(?:/|^)(${Te})):.*$`,"i")):null;return i&&(e=i[1]??e),le(e)},je=t=>{const e=le(t);if(!e)return null;const n=e.indexOf(";"),r=n>=0?le(e.slice(0,n)):e;if(!r)return null;const i=r.match(/^(.*?):(\d+)-(\d+)$/);if(i){const l=oe(i[1]??""),c=Number.parseInt(i[2]??"",10),d=Number.parseInt(i[3]??"",10);return!l||!Number.isFinite(c)||!Number.isFinite(d)||d<c?null:{path:l,line:c,endLine:d}}const a=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(a){const l=oe(a[1]??""),c=Number.parseInt(a[2]??"",10),d=a[3]?Number.parseInt(a[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const s=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(s){const l=oe(s[1]??""),c=Number.parseInt(s[2]??"",10),d=s[3]?Number.parseInt(s[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const o=oe(r);return o?{path:o}:null},me=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,Ue=()=>{const t=V.c(4),e=pt();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=we(!1),t[0]=n):n=t[0];const r=n;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=we(!0),t[1]=i):i=t[1];const a=i;let s;return t[2]!==e?.currentTheme?(s=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?a:r),t[2]=e?.currentTheme,t[3]=s):s=t[3],s},Ze=t=>{const e=V.c(4),{containerRef:n,enabled:r}=t;let i,a;e[0]!==n||e[1]!==r?(i=()=>{if(r===!1)return;const s=n.current;if(!s)return;const o=Nn;return s.addEventListener("click",o),()=>{s.removeEventListener("click",o)}},a=[n,r],e[0]=n,e[1]=r,e[2]=i,e[3]=a):(i=e[2],a=e[3]),x.useEffect(i,a)},Y={download:!0,copy:!0,showPanZoomControls:!0},Xe=!0,an=t=>{const e=t.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return e?t.slice(e[0].length):t},_e='[data-openchamber-file-link="true"]',Ge="data-openchamber-block-path-token",Ye=`[${Ge}]`,G="data-openchamber-block-paths-scanned",sn=2e5,ln=4,cn=1e3,dn=200,mn=80,un=40,Pe=160,B=new Map;let ae=0;const Fe=[],fn=()=>qe()?dn:cn,pn=()=>qe()?un:mn,hn=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),he=t=>rn(t),bn=t=>on(t),gn=(t,e)=>Et(t,e),wn=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},Je=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=he(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return hn.has(r)||r.startsWith(".")&&r.length>1?!0:wn(e)},Qe=t=>{const e=je(t);return e?Je(e.path):!1},yn=t=>{const e=t.querySelectorAll(Ye);for(const r of Array.from(e))r.replaceWith(t.ownerDocument.createTextNode(r.textContent??""));const n=t.querySelectorAll(`code[${G}]`);for(const r of Array.from(n))r.removeAttribute(G),r.normalize()},ue=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim();if(e&&Qe(e))return e}return(t.textContent||"").trim()},An=t=>{const e=t.querySelectorAll("pre code");if(e.length===0)return;const n=t.ownerDocument;if(n)for(const r of Array.from(e)){if(r.getAttribute(G)==="true")continue;if((r.textContent??"").length>sn){r.setAttribute(G,"true");continue}const i=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),a=[];let s=i.nextNode();for(;s;){const d=s;d.parentElement?.closest("[data-md-code-line-number]")||a.push(d),s=i.nextNode()}const o=Ke(r);if(!o.includes(".")){r.setAttribute(G,"true");continue}me.lastIndex=0;const l=[];let c=me.exec(o);for(;c;){const d=c[0];d&&Qe(d)&&l.push({start:c.index,end:c.index+d.length,raw:d}),c=me.exec(o)}for(const{start:d,end:f,raw:u}of l.reverse()){const p=xe(a,d,"right"),b=xe(a,f,"left");if(!p||!b)continue;const v=n.createRange();v.setStart(p.node,p.offset),v.setEnd(b.node,b.offset);const C=n.createElement("span");C.setAttribute(Ge,"true"),C.textContent=u,v.deleteContents(),v.insertNode(C)}r.setAttribute(G,"true")}},fe=(t,e)=>{const n=je(t);if(!n||!Je(n.path))return null;const r=bn(n.path)?he(n.path):gn(e,n.path);return r?{...n,resolvedPath:r}:null},vn=t=>{const e=he(t);if(!e)return Promise.resolve(!1);const n=B.get(e);if(n)return B.delete(e),B.set(e,n),n;const r=new Promise(a=>{const s=()=>{ae+=1,Lt(`/api/fs/stat?path=${encodeURIComponent(e)}&optional=true`,{method:"GET",cache:"no-store"}).then(async o=>{if(!o.ok){a(!1);return}const l=await o.json().catch(()=>null);a(l?.exists!==!1)}).catch(()=>a(!1)).finally(()=>{ae=Math.max(0,ae-1),Fe.shift()?.()})};if(ae<ln){s();return}Fe.push(s)}),i=fn();for(;B.size>=i;){const a=B.keys().next().value;if(typeof a!="string")break;B.delete(a)}return B.set(e,r),r},En=(t,e)=>t||vt(t,e),et=t=>{const e=V.c(7),{containerRef:n,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,enabled:s}=t,o=x.useRef(null);let l,c;e[0]!==n||e[1]!==i||e[2]!==r||e[3]!==s||e[4]!==a?(l=()=>{const d=n.current;if(!d)return;let f=!1;const u=pn(),p=s&&!gt(),b=Rn,v=()=>{const w=d.querySelectorAll(_e);for(const g of Array.from(w))b(g);yn(d)};if(!p){v();return}const C=w=>{const g=w;if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){y();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{f||y()})},g)},y=()=>{p&&An(d);const w=d.querySelectorAll(`[data-markdown="inline-code"], a, ${Ye}`);let g=0;for(const m of Array.from(w)){const A=ue(m),E=fe(A,r);if(b(m),!E||g>=u)continue;g=g+1,(kt()&&St()&&!be(E.resolvedPath,r)?Promise.resolve(!0):vn(E.resolvedPath)).then(D=>{if(f||!D||!d.contains(m))return;const I=ue(m),S=fe(I,r);!S||S.resolvedPath!==E.resolvedPath||(m.setAttribute("data-openchamber-file-link","true"),m.setAttribute("data-openchamber-file-ref",I),m.setAttribute("data-openchamber-file-path",S.resolvedPath),m.setAttribute("title","Open file"),m.tagName.toLowerCase()!=="a"&&(m.setAttribute("role","button"),m.setAttribute("tabindex","0")))})}},L=async w=>{const g=w.getAttribute("data-openchamber-file-ref")||ue(w),m=fe(g,r);if(!m)return;const A=En(r,m.resolvedPath);if(a&&i){i.openFile(m.resolvedPath,Number.isFinite(m.line??Number.NaN)?Math.max(1,Math.trunc(m.line)):void 0,Number.isFinite(m.column??Number.NaN)?Math.max(1,Math.trunc(m.column)):void 0);return}be(m.resolvedPath,r)||await At(m.resolvedPath,r);const E=X.getState();Number.isFinite(m.line??Number.NaN)?E.openContextFileAtLine(A,m.resolvedPath,Math.max(1,Math.trunc(m.line)),Number.isFinite(m.column??Number.NaN)?Math.max(1,Math.trunc(m.column)):1):E.openContextFile(A,m.resolvedPath)},M=w=>{const g=w.target;if(!(g instanceof Element))return;const m=g.closest(_e);m instanceof HTMLElement&&(w.preventDefault(),w.stopPropagation(),L(m))},h=w=>{if(w.key!=="Enter"&&w.key!==" ")return;const g=w.target;!(g instanceof HTMLElement)||g.getAttribute("data-openchamber-file-link")!=="true"||(w.preventDefault(),w.stopPropagation(),L(g))};C(Pe);const k=new MutationObserver(()=>{C(Pe)});return k.observe(d,{childList:!0,subtree:!0}),d.addEventListener("click",M),d.addEventListener("keydown",h),()=>{f=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,k.disconnect(),d.removeEventListener("click",M),d.removeEventListener("keydown",h)}},c=[n,i,r,a,s],e[0]=n,e[1]=i,e[2]=r,e[3]=s,e[4]=a,e[5]=l,e[6]=c):(l=e[5],c=e[6]),x.useEffect(l,c)},tt=t=>{const e=V.c(7),{containerRef:n,onShowPopup:r,enableFullscreen:i,enablePanZoom:a,allowMermaidWheelEvents:s}=t;let o,l;e[0]!==s||e[1]!==n||e[2]!==i||e[3]!==a||e[4]!==r?(o=()=>{const c=n.current;if(!c)return;const d=u=>{if(!i||!r)return;const p=u.target;if(!(p instanceof Element)||p.closest('button, a, [role="button"]'))return;const b=p.closest(ee);if(!b)return;if(b instanceof HTMLElement&&b.hasAttribute("data-mermaid-suppress-click")){b.removeAttribute("data-mermaid-suppress-click");return}const C=Array.from(c.querySelectorAll(ee)).indexOf(b);if(C<0)return;const y=b instanceof HTMLElement?b.getAttribute("data-md-source"):null;if(!y||y.trim().length===0)return;const L=`Diagram ${C+1}`;r({open:!0,title:L,content:"",metadata:{tool:"mermaid-preview",filename:L},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(y)}`,source:y,filename:L}})},f=u=>{if(s||(u.ctrlKey||u.metaKey)&&a)return;const p=u.target;!(p instanceof Element)||!p.closest(ee)||u.stopPropagation()};return c.addEventListener("click",d),c.addEventListener("wheel",f,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",d),c.removeEventListener("wheel",f,!0)}},l=[s,n,i,a,r],e[0]=s,e[1]=n,e[2]=i,e[3]=a,e[4]=r,e[5]=o,e[6]=l):(o=e[5],l=e[6]),x.useEffect(o,l)},z=new Map,Cn=100,kn=(t,e)=>{const n=z.get(t);if(n)return z.delete(t),z.set(t,n),n;const r=e();if(z.set(t,r),z.size>Cn){const i=z.keys().next().value;i&&z.delete(i)}return r},Sn=t=>({bg:t.colors.surface.elevated,fg:t.colors.surface.foreground,line:t.colors.interactive.border,accent:t.colors.primary.base,muted:t.colors.surface.mutedForeground,surface:t.colors.surface.muted,border:t.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),nt=(t,e,n,r=Y)=>{const{t:i}=ht(),a=x.useMemo(()=>({copy:i("markdownRenderer.code.actions.copyTitle"),copied:i("markdownRenderer.code.actions.copiedTitle"),enableCodeWrap:i("markdownRenderer.code.actions.enableWrapTitle"),disableCodeWrap:i("markdownRenderer.code.actions.disableWrapTitle"),copyTable:i("markdownRenderer.table.actions.copyTitle"),downloadTable:i("markdownRenderer.table.actions.downloadTitle"),copyDiagram:i("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:i("markdownRenderer.mermaid.actions.downloadSvgTitle"),zoomInDiagram:i("markdownRenderer.mermaid.actions.zoomInTitle"),zoomOutDiagram:i("markdownRenderer.mermaid.actions.zoomOutTitle"),resetDiagramView:i("markdownRenderer.mermaid.actions.resetViewTitle"),previewLabel:i("terminalView.preview.open"),previewTitle:i("terminalView.preview.openTitle")}),[i]),s=X(c=>c.codeBlockLineWrap),o=X(c=>c.setCodeBlockLineWrap),l=x.useCallback(()=>{o(!X.getState().codeBlockLineWrap)},[o]);return x.useMemo(()=>{const c=Sn(t),d=X.getState().mermaidRenderingMode,f=t.metadata?.id??"theme";return{labels:a,mermaidControls:r,codeBlockLineWrap:s,deferCodeLineNumberSync:e,onToggleCodeBlockLineWrap:l,renderMermaid:p=>kn(`${f}:${d}:${p}`,()=>{try{return d==="ascii"?{ascii:at(p)}:{svg:it(p,c)}}catch{return{}}}),onPreviewLoopback:n}},[t,a,r,s,e,l,n])},rt=t=>{const e=V.c(33),{containerRef:n,text:r,streaming:i,cacheKey:a,syntaxVars:s,ctx:o}=t;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=[],e[0]=l):l=e[0],x.useEffect(xn,l);const c=x.useRef(null);let d;e[1]!==n?(d=()=>{const m=n.current;if(m){if(!c.current){if(!$(m))return;c.current=jt(m);return}c.current.refresh()}},e[1]=n,e[2]=d):d=e[2];const f=d;let u,p;e[3]!==n||e[4]!==o||e[5]!==f||e[6]!==r?(u=()=>{const m=n.current,A=m?.querySelector("[data-markdown-content]")??m;if(A&&r&&A.childNodes.length===0){const E=document.createElement("div");E.setAttribute("data-md-block",""),E.style.display="contents",E.innerHTML=Mt(r),Ne(E,o),A.appendChild(E),$(E)&&f()}},p=[n,r,o,f],e[3]=n,e[4]=o,e[5]=f,e[6]=r,e[7]=u,e[8]=p):(u=e[7],p=e[8]),x.useLayoutEffect(u,p);let b,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=()=>()=>{c.current?.cleanup(),c.current=null},v=[],e[9]=b,e[10]=v):(b=e[9],v=e[10]),x.useEffect(b,v);let C,y;e[11]!==a||e[12]!==n||e[13]!==o||e[14]!==f||e[15]!==i||e[16]!==r?(C=()=>{const m=n.current;if(!m)return;const A=m.querySelector("[data-markdown-content]")??m;let E=!0;return Nt(r,i,a).then(_=>{if(!E)return;const F=Array.from(A.children);_.forEach((S,T)=>{let N=F[T];if(N||(N=document.createElement("div"),N.setAttribute("data-md-block",""),N.style.display="contents",A.appendChild(N)),N.getAttribute("data-md-id")===S.id)return;const P=document.createElement("div");P.innerHTML=S.html,Ne(P,o);const O=$(N),H=$(P);st(N,P,{childrenOnly:!0,onBeforeElUpdated:Tn}),N.setAttribute("data-md-id",S.id),(O||H||$(N))&&f()});const D=$(A);let I=!1;for(let S=F.length-1;S>=_.length;S=S-1,S){const T=F[S];T&&$(T)&&(I=!0),T?.remove()}(I||F.length>_.length&&D)&&f()}),()=>{E=!1}},y=[n,r,i,a,o,f],e[11]=a,e[12]=n,e[13]=o,e[14]=f,e[15]=i,e[16]=r,e[17]=C,e[18]=y):(C=e[17],y=e[18]),x.useEffect(C,y);let L,M;e[19]!==n||e[20]!==o?(M=()=>{const m=n.current;if(m)return tn(m,o)},L=[n,o],e[19]=n,e[20]=o,e[21]=L,e[22]=M):(L=e[21],M=e[22]),x.useEffect(M,L);let h,k;e[23]!==n||e[24]!==s?(h=()=>{const m=n.current,A=m?.querySelector("[data-markdown-content]")??m;if(A)for(const[E,_]of Object.entries(s))A.style.setProperty(E,_)},k=[n,s],e[23]=n,e[24]=s,e[25]=h,e[26]=k):(h=e[25],k=e[26]),x.useEffect(h,k);let w,g;e[27]!==n||e[28]!==o.codeBlockLineWrap||e[29]!==o.deferCodeLineNumberSync||e[30]!==o.labels?(w=()=>{const m=n.current,A=m?.querySelector("[data-markdown-content]")??m;A&&(o.deferCodeLineNumberSync||Ut(A,o.codeBlockLineWrap,o.labels))},g=[n,o.codeBlockLineWrap,o.deferCodeLineNumberSync,o.labels],e[27]=n,e[28]=o.codeBlockLineWrap,e[29]=o.deferCodeLineNumberSync,e[30]=o.labels,e[31]=w,e[32]=g):(w=e[31],g=e[32]),x.useEffect(w,g)},ot=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",Ln=t=>{const e=V.c(32),{content:n,part:r,messageId:i,isAnimated:a,skipFadeIn:s,className:o,isStreaming:l,disableStreamAnimation:c,variant:d,onShowPopup:f,enableFileReferences:u}=t,p=a===void 0?!0:a,b=s===void 0?!1:s,v=l===void 0?!1:l,C=c===void 0?!1:c,y=d===void 0?"assistant":d,L=u===void 0?!0:u;ge("ui.markdown_renderer.render"),v&&ge("ui.markdown_renderer.render.streaming"),Ct("ui.markdown_renderer.content_len",n.length);const M=Ue(),{editor:h,runtime:k}=Oe(),w=x.useRef(null),g=De()??"",m=X(_n);let A;e[0]!==g||e[1]!==m?(A=Z=>{g&&m(g,Z)},e[0]=g,e[1]=m,e[2]=A):A=e[2];const E=A,_=v&&!C;let F;e[3]!==f?(F={containerRef:w,onShowPopup:f,enableFullscreen:Xe,enablePanZoom:Y.showPanZoomControls},e[3]=f,e[4]=F):F=e[4],tt(F);const D=L&&!v;let I;e[5]!==h||e[6]!==g||e[7]!==k.isVSCode||e[8]!==D?(I={containerRef:w,effectiveDirectory:g,editor:h,preferRuntimeEditor:k.isVSCode,enabled:D},e[5]=h,e[6]=g,e[7]=k.isVSCode,e[8]=D,e[9]=I):I=e[9],et(I);let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S={containerRef:w},e[10]=S):S=e[10],Ze(S);let T;e[11]!==M?(T=We(M),e[11]=M,e[12]=T):T=e[12];const N=T,P=nt(M,_,g?E:void 0,Y),O=`markdown-${r?.id?`part-${r.id}`:`message-${i}`}`;let H;e[13]!==O||e[14]!==n||e[15]!==P||e[16]!==_||e[17]!==N?(H={containerRef:w,text:n,streaming:_,cacheKey:O,syntaxVars:N,ctx:P},e[13]=O,e[14]=n,e[15]=P,e[16]=_,e[17]=N,e[18]=H):H=e[18],rt(H);let K;e[19]!==o?(K=$e("break-words w-full min-w-0",o),e[19]=o,e[20]=K):K=e[20];let j;e[21]!==y?(j=ot(y),e[21]=y,e[22]=j):j=e[22];let U;e[23]!==j?(U=Q.jsx("div",{className:j,"data-markdown-content":!0}),e[23]=j,e[24]=U):U=e[24];let te;e[25]!==K||e[26]!==U?(te=Q.jsx("div",{className:K,ref:w,children:U}),e[25]=K,e[26]=U,e[27]=te):te=e[27];const ne=te;if(p){let Z;return e[28]!==O||e[29]!==ne||e[30]!==b?(Z=Q.jsx(wt,{skipAnimation:b,children:ne},O),e[28]=O,e[29]=ne,e[30]=b,e[31]=Z):Z=e[31],Z}return ne},Dn=x.memo(Ln,(t,e)=>t.content===e.content&&t.isStreaming===e.isStreaming&&t.disableStreamAnimation===e.disableStreamAnimation&&t.variant===e.variant&&t.isAnimated===e.isAnimated&&t.skipFadeIn===e.skipFadeIn&&t.className===e.className&&t.messageId===e.messageId&&t.onShowPopup===e.onShowPopup&&t.enableFileReferences===e.enableFileReferences&&t.part?.id===e.part?.id),Mn=t=>{const e=V.c(30),{content:n,className:r,variant:i,disableLinkSafety:a,stripFrontmatter:s,onShowPopup:o,mermaidControls:l,allowMermaidWheelEvents:c,enableFileReferences:d}=t,f=i===void 0?"assistant":i,u=s===void 0?!1:s,p=l===void 0?Y:l,b=c===void 0?!1:c,v=d===void 0?!0:d,{editor:C,runtime:y}=Oe(),L=Ue(),M=x.useRef(null),h=De()??"";let k;e[0]!==n||e[1]!==u?(k=u?an(n):n,e[0]=n,e[1]=u,e[2]=k):k=e[2];const w=k;let g;e[3]!==b||e[4]!==p.showPanZoomControls||e[5]!==o?(g={containerRef:M,onShowPopup:o,enableFullscreen:Xe,enablePanZoom:p.showPanZoomControls,allowMermaidWheelEvents:b},e[3]=b,e[4]=p.showPanZoomControls,e[5]=o,e[6]=g):g=e[6],tt(g);let m;e[7]!==C||e[8]!==h||e[9]!==v||e[10]!==y.isVSCode?(m={containerRef:M,effectiveDirectory:h,editor:C,preferRuntimeEditor:y.isVSCode,enabled:v},e[7]=C,e[8]=h,e[9]=v,e[10]=y.isVSCode,e[11]=m):m=e[11],et(m);const A=!a;let E;e[12]!==A?(E={containerRef:M,enabled:A},e[12]=A,e[13]=E):E=e[13],Ze(E);let _;e[14]!==L?(_=We(L),e[14]=L,e[15]=_):_=e[15];const F=_,D=nt(L,!1,void 0,p),I=`simple:${f}`;let S;e[16]!==D||e[17]!==w||e[18]!==F||e[19]!==I?(S={containerRef:M,text:w,streaming:!1,cacheKey:I,syntaxVars:F,ctx:D},e[16]=D,e[17]=w,e[18]=F,e[19]=I,e[20]=S):S=e[20],rt(S);let T;e[21]!==r?(T=$e("break-words w-full min-w-0",r),e[21]=r,e[22]=T):T=e[22];let N;e[23]!==f?(N=ot(f),e[23]=f,e[24]=N):N=e[24];let P;e[25]!==N?(P=Q.jsx("div",{className:N,"data-markdown-content":!0}),e[25]=N,e[26]=P):P=e[26];let O;return e[27]!==T||e[28]!==P?(O=Q.jsx("div",{className:T,ref:M,children:P}),e[27]=T,e[28]=P,e[29]=O):O=e[29],O},Wn=x.memo(Mn,(t,e)=>{const n=t.mermaidControls??Y,r=e.mermaidControls??Y;return t.content===e.content&&t.variant===e.variant&&t.className===e.className&&t.disableLinkSafety===e.disableLinkSafety&&t.stripFrontmatter===e.stripFrontmatter&&t.onShowPopup===e.onShowPopup&&n.download===r.download&&n.copy===r.copy&&n.showPanZoomControls===r.showPanZoomControls&&t.allowMermaidWheelEvents===e.allowMermaidWheelEvents&&t.enableFileReferences===e.enableFileReferences});function Nn(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;const e=t.target;if(!(e instanceof Element))return;const n=e.closest("a[href]");if(!(n instanceof HTMLAnchorElement)||n.getAttribute("data-openchamber-file-link")==="true")return;const r=n.getAttribute("href")??"";Ie(r)&&(t.preventDefault(),t.stopPropagation(),yt(r))}function Rn(t){t.removeAttribute("data-openchamber-file-link"),t.removeAttribute("data-openchamber-file-ref"),t.removeAttribute("data-openchamber-file-path"),t.getAttribute("title")==="Open file"&&t.removeAttribute("title"),t.tagName.toLowerCase()!=="a"&&(t.removeAttribute("role"),t.removeAttribute("tabindex"))}function xn(){bt()}function Tn(t,e){return!t.isEqualNode(e)}function _n(t){return t.openContextPreview}export{Dn as MarkdownRenderer,Wn as SimpleMarkdownRenderer};
@@ -1 +1 @@
1
- import{r as _,j as e,R as l,b as J}from"./vendor-.bun-DvcSrJLa.js";import{J as V,aq as we,au as ie,ap as q,y as $,ag as B,cB as je,j as z,Q as ue,R as me,x as pe,M as ne}from"./index-DMCrPMIW.js";import{f as Q,B as L,z as G,C as he,y as re,I as A}from"./useAppFontEffects-DrLhDSC3.js";function ke(a){switch(a){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function oe(a){return a==="wrong-service"||a==="unreachable"||a==="incompatible"}function xe({onBack:a,showBackButton:t=!0,initialUrl:s="",initialLabel:r="",isRecoveryMode:n=!1,onConnect:i,onSwitchToLocal:u,showInstancePicker:h=!1}){const{t:o}=Q(),[w,S]=_.useState(s),[j,U]=_.useState(r),[K,x]=_.useState("idle"),[m,k]=_.useState(null),[C,g]=_.useState(""),[T,I]=_.useState([]),[y,f]=_.useState(()=>h?"instances":"add"),[b,R]=_.useState("");_.useEffect(()=>{h&&V().then(p=>I(p.hosts)).catch(p=>{g(p instanceof Error?p.message:String(p))})},[h]);const N=we(w),E=N?.persistedUrl??null,F=_.useCallback(p=>{S(p.target.value),x("idle"),k(null),g("")},[]),M=_.useCallback(p=>{U(p.target.value)},[]),c=_.useCallback(async()=>{if(E){x("testing"),k(null),g("");try{const p=await ie(E);k(p),x(p.status==="ok"||p.status==="update-recommended"?"success":"error")}catch(p){g(p instanceof Error?p.message:o("onboarding.remoteConnection.errors.connectionTestFailed")),x("error")}}},[E,o]),D=_.useCallback(async()=>{if(!N)return;const p=N.persistedUrl;x("testing"),k(null),g("");try{const H=await ie(p);if(k(H),oe(H.status)){x("error");return}const Z=await V(),ye=j.trim()||p,ee=Z.hosts.find(X=>X.url===p),te=ee?ee.id:`host-${Date.now().toString(16)}`,le={id:te,label:ye,url:p,apiUrl:p},ve=ee?Z.hosts.map(X=>X.id===te?le:X):[...Z.hosts,le];if(await q({hosts:ve,defaultHostId:te,initialHostChoiceCompleted:!0}),i?.(),N.redeemUrl){window.location.assign(N.redeemUrl);return}$()&&await B()}catch(H){g(H instanceof Error?H.message:o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[N,j,i,o]),P=_.useCallback(async p=>{const H=await V();await q({hosts:H.hosts,defaultHostId:p,initialHostChoiceCompleted:!0}),await B()},[]),d=_.useCallback(async()=>{x("testing"),g("");try{const p=await V(),H=await je(b,p.hosts);await q({hosts:H.hosts,defaultHostId:H.hostId,initialHostChoiceCompleted:!0}),await B()}catch(p){g(p instanceof Error&&p.message==="invalid-connect-link"?o("settings.remoteInstances.direct.error.invalidConnectLink"):o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[b,o]),v=K==="testing",O=E!==null&&!v,W=E!==null&&!v&&!oe(m?.status??null),Y=ke(m?.status??null),fe=m?.status==="ok",be=m?.status==="update-recommended",ge=m?.status==="auth",ae=oe(m?.status??null);return h&&y==="instances"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("desktopHostSwitcher.actions.switchInstance")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.description")})]}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx("div",{className:"space-y-2",children:T.length===0?e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:o("settings.remoteInstances.direct.state.empty")}):T.map(p=>e.jsx(L,{variant:"outline",className:"w-full justify-start",onClick:()=>{P(p.id)},children:e.jsx("span",{className:"min-w-0 truncate",children:p.label})},p.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{variant:"outline",className:"flex-1",onClick:()=>f("import"),children:o("settings.remoteInstances.direct.import.action")}),e.jsx(L,{className:"flex-1",onClick:()=>f("add"),children:o("settings.remoteInstances.direct.actions.add")})]})]})}):h&&y==="import"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsx(L,{variant:"ghost",onClick:()=>f("instances"),className:"p-0 text-muted-foreground",children:o("onboarding.common.actions.back")}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("settings.remoteInstances.direct.import.action")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.import.description")})]}),e.jsx(G,{value:b,onChange:p=>R(p.target.value),placeholder:o("settings.remoteInstances.direct.import.placeholder"),disabled:v,autoFocus:!0}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx(L,{onClick:()=>{d()},disabled:v||!b.trim(),children:o("settings.remoteInstances.direct.import.action")})]})}):e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[(t||h)&&e.jsx("div",{className:"flex items-center",children:e.jsx(L,{variant:"ghost",onClick:h?()=>f("instances"):a,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o(n?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("onboarding.remoteConnection.description")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.serverAddress")}),e.jsx(G,{id:"remote-url",type:"url",value:w,onChange:F,placeholder:o("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:v})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.nameOptional")}),e.jsx(G,{id:"remote-label",type:"text",value:j,onChange:M,placeholder:o("onboarding.remoteConnection.field.namePlaceholder"),disabled:v})]})]}),m&&fe&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:o("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&ge&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:o("onboarding.remoteConnection.status.authWarning")}),m&&be&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:Y?o(Y):null}),m&&ae&&e.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold mb-1",children:o("onboarding.remoteConnection.status.connectionFailed")}),e.jsx("div",{className:"opacity-90",children:Y?o(Y):null})]}),e.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?o("onboarding.remoteConnection.status.suggestionsUnreachable"):o("onboarding.remoteConnection.status.suggestionsWrongService")})]}),C&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:C}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(L,{variant:"outline",onClick:c,disabled:!O,children:o(v?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),e.jsx(L,{onClick:D,disabled:!W,children:o("onboarding.remoteConnection.actions.connectAndRestart")})]}),ae&&e.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[e.jsx("div",{className:"text-xs text-muted-foreground text-center",children:o("onboarding.remoteConnection.actions.whatToDo")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{variant:"outline",size:"sm",onClick:a,className:"flex-1",children:o("onboarding.remoteConnection.actions.chooseDifferentServer")}),!n&&u&&e.jsx(L,{variant:"outline",size:"sm",onClick:u,className:"flex-1",children:o("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const Ce="curl -fsSL https://opencode.ai/install | bash",Ne="https://opencode.ai/docs",ce=2500;function Se(a){const t=J.c(5),{onCopy:s,copyTitle:r}=a;let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),t[0]=n):n=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=e.jsx(A,{name:"file-copy",className:"h-4 w-4"}),t[1]=i):i=t[1];let u;return t[2]!==r||t[3]!==s?(u=e.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[n,e.jsx("button",{onClick:s,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:r,"aria-label":r,children:i})]}),t[2]=r,t[3]=s,t[4]=u):u=t[4],u}function Re({onCliAvailable:a,localAvailable:t=!0}){const{t:s}=Q(),[r,n]=l.useState(!1),[i,u]=l.useState(!1),[h,o]=l.useState(!1),[w,S]=l.useState(!1),[j,U]=l.useState(""),[K,x]=l.useState("unknown"),[m,k]=l.useState(()=>t?"local":"remote"),[C,g]=l.useState(!1),[T,I]=l.useState(!1);l.useEffect(()=>{u($())},[]),l.useEffect(()=>{if(typeof navigator>"u"){x("unknown");return}const d=navigator.userAgent||"";/Windows/i.test(d)?x("windows"):/Macintosh|Mac OS X/i.test(d)?x("macos"):/Linux/i.test(d)?x("linux"):x("unknown")},[]),l.useEffect(()=>{let d=!1;return(async()=>{try{const v=await z("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!v.ok)return;const O=await v.json().catch(()=>null);if(!O||d)return;const W=typeof O.opencodeBinary=="string"?O.opencodeBinary.trim():"";W&&U(W)}catch{}})(),()=>{d=!0}},[]);const y=l.useCallback(async d=>{const v=d.target;v.closest(".app-region-no-drag")||v.closest("button, a, input, select, textarea, code, summary, details")||d.button===0&&i&&await ue()},[i]),f=l.useCallback(async()=>{try{const d=await z("/health");if(!d.ok)return!1;const v=await d.json();return v.openCodeRunning===!0||v.isOpenCodeReady===!0}catch{return!1}},[]),b=l.useCallback(async d=>{if(!i)return;const v=await V();await q({...v,...d==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[i]),R=l.useCallback(async()=>{i&&await b("local"),a?.()},[i,a,b]);l.useEffect(()=>{if(!t||m!=="local")return;let d=!1,v=null;const O=async()=>{if(!d){try{const W=await f();if(d)return;if(W){await R();return}}catch{}d||(v=setTimeout(O,ce))}};return v=setTimeout(O,ce),()=>{d=!0,v&&clearTimeout(v)}},[m,f,R,t]);const N=l.useCallback(async()=>{S(!0);try{await f()&&await R()}finally{S(!1)}},[f,R]),E=l.useCallback(async()=>{if(!(typeof window>"u")&&i)try{const d=await me();d.success&&d.path&&d.path.trim().length>0&&U(d.path.trim())}catch{}},[i]),F=l.useCallback(async()=>{o(!0);try{if(await pe({opencodeBinary:j.trim()}),i){await b("local"),await B();return}await z("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>o(!1),1e3)}},[i,j,b]),M=l.useCallback(async()=>{const d=await he(Ce);d.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",d.error)},[]),c=Ne,D=K==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":K==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",P=t&&(!i||m==="local");return e.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:y,children:e.jsxs("div",{className:"w-full max-w-md space-y-7",children:[e.jsxs("header",{className:"text-center space-y-1.5",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:s("onboarding.chooser.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("onboarding.chooser.description")})]}),i&&t&&e.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[e.jsx("button",{type:"button",className:re("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>k("local"),children:s("onboarding.chooser.tabs.localInstall")}),e.jsx("button",{type:"button",className:re("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>k("remote"),children:s("onboarding.chooser.tabs.connectRemote")})]}),i&&m==="remote"?e.jsx("div",{className:"app-region-no-drag",children:e.jsx(xe,{onBack:()=>t&&k("local"),showBackButton:!1,showInstancePicker:!t,onSwitchToLocal:t?()=>k("local"):void 0})}):null,P&&e.jsxs("div",{className:"space-y-4",children:[K==="windows"&&e.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-4",children:[e.jsx("div",{className:"text-sm text-foreground",children:s("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:s("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:s("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:s("onboarding.localSetup.intro")}),e.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:r?e.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(A,{name:"check",className:"h-4 w-4"}),s("onboarding.common.status.copiedToClipboard")]}):e.jsx(Se,{onCopy:M,copyTitle:s("onboarding.common.copyToClipboard")})}),e.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[e.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[s(K==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(A,{name:"external-link",className:"h-3 w-3"})]}),e.jsx("button",{type:"button",onClick:N,disabled:w,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:s(w?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),e.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[e.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 shrink-0","aria-hidden":!0,children:[e.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}}),e.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-foreground leading-tight",children:s("onboarding.localSetup.status.watching")}),e.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:s("onboarding.localSetup.status.autoContinue")})]})]}),e.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:C,onToggle:d=>g(d.currentTarget.open),children:[e.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.advanced.title")}),e.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsxs("div",{className:"pb-4 space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{value:j,onChange:d=>U(d.target.value),placeholder:D,disabled:h,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",size:"sm",onClick:E,disabled:h||!i,children:s("onboarding.localSetup.actions.browse")}),e.jsx(L,{type:"button",size:"sm",onClick:F,disabled:h||!j.trim(),children:s("onboarding.localSetup.actions.apply")})]}),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:s("onboarding.localSetup.helper.saveAndReload")})]})]}),e.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:T,onToggle:d=>I(d.currentTarget.open),children:[e.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.troubleshoot.title")}),e.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:K==="windows"?e.jsx(e.Fragment,{children:e.jsx("li",{children:s("onboarding.localSetup.windows.hintDetectionFailed")})}):e.jsxs(e.Fragment,{children:[e.jsx("li",{children:s("onboarding.localSetup.hint.ensurePath")}),e.jsx("li",{children:s("onboarding.localSetup.hint.setEnv")}),e.jsx("li",{children:s("onboarding.localSetup.hint.missingRuntime")})]})})]})]})]})})}const Le="curl -fsSL https://opencode.ai/install | bash",Ue="https://opencode.ai/docs";function Te(a){const t=J.c(5),{onCopy:s,copyTitle:r}=a;let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsxs("code",{children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),t[0]=n):n=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=e.jsx(A,{name:"file-copy",className:"h-4 w-4"}),t[1]=i):i=t[1];let u;return t[2]!==r||t[3]!==s?(u=e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[n,e.jsx("button",{onClick:s,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:r,children:i})]}),t[2]=r,t[3]=s,t[4]=u):u=t[4],u}const Ke=3e4;function Ie({onBack:a,onCliAvailable:t,isFromRecovery:s=!1,onSwitchToRemote:r}){const{t:n}=Q(),[i,u]=l.useState(!1),[h,o]=l.useState(!1),[w,S]=l.useState(!1),[j,U]=l.useState(!1),[K,x]=l.useState(!1),[m,k]=l.useState(null),[C,g]=l.useState(""),[T,I]=l.useState("unknown");l.useEffect(()=>{const c=setTimeout(()=>o(!0),Ke);return()=>clearTimeout(c)},[]),l.useEffect(()=>{S($())},[]),l.useEffect(()=>{if(typeof navigator>"u"){I("unknown");return}const c=navigator.userAgent||"";if(/Windows/i.test(c)){I("windows");return}if(/Macintosh|Mac OS X/i.test(c)){I("macos");return}if(/Linux/i.test(c)){I("linux");return}I("unknown")},[]),l.useEffect(()=>{let c=!1;return(async()=>{try{const D=await z("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!D.ok)return;const P=await D.json().catch(()=>null);if(!P||c)return;const d=typeof P.opencodeBinary=="string"?P.opencodeBinary.trim():"";d&&g(d)}catch{}})(),()=>{c=!0}},[]);const y=l.useCallback(async c=>{c.target.closest("button, a, input, select, textarea, code")||c.button===0&&w&&await ue()},[w]),f=l.useCallback(async()=>{try{const c=await z("/health");if(!c.ok)return!1;const D=await c.json();return D.openCodeRunning===!0||D.isOpenCodeReady===!0}catch{return!1}},[]),b=l.useCallback(async()=>{if(!(typeof window>"u")&&w)try{const c=await me();c.success&&c.path&&c.path.trim().length>0&&g(c.path.trim())}catch{}},[w]),R=l.useCallback(async()=>{U(!0);try{if(await pe({opencodeBinary:C.trim()}),w){await B();return}await z("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>U(!1),1e3)}},[w,C]),N=l.useCallback(async()=>{const c=await he(Le);c.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error("Failed to copy:",c.error)},[]),E=l.useCallback(async()=>{x(!0),k(null);try{await f()?t?.():k(n("onboarding.localSetup.errors.cliNotReady"))}catch(c){k(c instanceof Error?c.message:n("onboarding.localSetup.errors.detectionFailed"))}finally{x(!1)}},[f,t,n]),F=Ue,M=T==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":T==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode";return e.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:y,children:[e.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[e.jsx("div",{className:"flex items-center",children:e.jsx(L,{variant:"ghost",onClick:a,className:"p-0 text-muted-foreground hover:text-foreground",children:n("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:n("onboarding.localSetup.title")}),e.jsx("p",{className:"text-muted-foreground",children:n("onboarding.localSetup.description")})]}),T==="windows"&&e.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[e.jsx("div",{className:"text-sm text-foreground",children:n("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:n("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:n("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:i?e.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(A,{name:"check",className:"h-4 w-4"}),n("onboarding.common.status.copiedToClipboard")]}):e.jsx(Te,{onCopy:N,copyTitle:n("onboarding.common.copyToClipboard")})})}),e.jsxs("a",{href:F,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(T==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(A,{name:"external-link",className:"h-3 w-3"})]}),m&&e.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:m}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(L,{type:"button",onClick:E,disabled:K,className:"w-full max-w-xs",size:"lg",children:n(K?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("onboarding.localSetup.helper.checkAndContinue")})]}),e.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:n("onboarding.localSetup.field.alreadyInstalled")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{value:C,onChange:c=>g(c.target.value),placeholder:M,disabled:j,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",onClick:b,disabled:j||!w,children:n("onboarding.localSetup.actions.browse")}),e.jsx(L,{type:"button",onClick:R,disabled:j,children:n("onboarding.localSetup.actions.apply")})]}),e.jsx("div",{className:"text-xs text-muted-foreground/70",children:n("onboarding.localSetup.helper.saveAndReload")})]})}),s&&r&&e.jsxs("div",{className:"text-center pt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:n("onboarding.localSetup.remotePreference")}),e.jsx(L,{variant:"link",onClick:r,children:n("onboarding.localSetup.actions.connectRemoteServer")})]})]}),h&&e.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:T==="windows"?e.jsx(e.Fragment,{children:e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.windows.hintDetectionFailed")})}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.ensurePath")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.setEnv")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.missingRuntime")})]})})]})}function se(a,t){if(a?.trim())return ne(a.trim());if(t)return ne(t)}function _e(a,t,s){switch(a){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const r=se(t,s);return{title:"Remote Server Unreachable",description:`Could not connect to "${r||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:r?{host:r}: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 r=se(t,s);return{title:"Incompatible Server",description:`The server at "${r||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:r?{host:r}: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 r=se(t,s);return{title:"Server Update Required",description:`The OpenChamber server at "${r||"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:r?{host:r}: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 r=a;throw new Error(`Unknown recovery variant: ${r}`)}}}function De(a){switch(a){case"local":return e.jsx(A,{name:"macbook",className:"h-8 w-8"});case"remote":return e.jsx(A,{name:"server",className:"h-8 w-8"})}}function Ee({variant:a,hostLabel:t,hostUrl:s,onRetry:r,onUseLocal:n,onUseRemote:i,isRetrying:u=!1}){const{t:h}=Q(),o=_e(a,t,s),w=o.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",S=l.useMemo(()=>{if(o.descriptionParams?.host)return o.descriptionParams;if(a==="remote-unreachable")return{host:h("onboarding.desktopRecovery.placeholders.remoteServer")};if(a==="remote-wrong-service"||a==="remote-incompatible")return{host:h("onboarding.desktopRecovery.placeholders.unknownServer")}},[o.descriptionParams,h,a]);return e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[e.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:e.jsx("div",{style:{color:"var(--status-warning)"},children:De(o.iconKey)})}),e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:h(o.titleKey)}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:h(o.descriptionKey,S)})]}),s&&(a==="remote-unreachable"||a==="remote-wrong-service"||a==="remote-incompatible")&&e.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:h("onboarding.remoteConnection.field.serverAddress")}),e.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:ne(s)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[o.showRetry&&r&&e.jsxs(L,{onClick:r,disabled:u,className:"w-full",children:[e.jsx(A,{name:"refresh",className:re("h-4 w-4",u&&"animate-spin")}),h(u?"onboarding.desktopRecovery.actions.retrying":w)]}),e.jsxs("div",{className:"flex gap-2",children:[o.showUseLocal&&n&&e.jsxs(L,{variant:"outline",onClick:n,disabled:u,className:"flex-1",children:[e.jsx(A,{name:"macbook",className:"h-4 w-4"}),h(o.useLocalLabelKey)]}),o.showUseRemote&&i&&e.jsxs(L,{variant:"outline",onClick:i,disabled:u,className:"flex-1",children:[e.jsx(A,{name:"server",className:"h-4 w-4"}),h(o.useRemoteLabelKey)]})]})]})]})})}function de(a,t){if(t==="use-remote")return{kind:"remote-form"};switch(a){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const s=a;throw new Error(`Unhandled RecoveryVariant: ${s}`)}}}function Ae(a){const t=J.c(29),{variant:s,hostUrl:r,hostLabel:n,onRetry:i,onChooseRemote:u,showRemoteForm:h,onCloseRemoteForm:o,onSwitchToLocalFromRemote:w,onEnterLocalSetup:S,isRetrying:j,localAvailable:U}=a,K=h===void 0?!1:h,x=j===void 0?!1:j,m=U===void 0?!0:U,k=Fe;let C;t[0]!==i?(C=async()=>{if($()){await B();return}await z("/api/config/reload",{method:"POST"}),i?.()},t[0]=i,t[1]=C):C=t[1];const g=C;let T;t[2]!==S||t[3]!==s?(T=async()=>{if(de(s,"use-local").kind==="local-setup"){S?.();return}if(await k("local"),$()){await B();return}window.location.reload()},t[2]=S,t[3]=s,t[4]=T):T=t[4];const I=T;let y;t[5]!==u||t[6]!==s?(y=()=>{de(s,"use-remote").kind==="remote-form"&&u?.()},t[5]=u,t[6]=s,t[7]=y):y=t[7];const f=y;if(K){const N=s==="remote-wrong-service"?"":r||"",E=s==="remote-wrong-service"?"":n||"";let F;t[8]!==u||t[9]!==o?(F=o||(()=>u?.()),t[8]=u,t[9]=o,t[10]=F):F=t[10];const M=!m;let c;t[11]!==m||t[12]!==S||t[13]!==w?(c=m?w||(()=>{k("local").then(()=>{$()?B():S?.()})}):void 0,t[11]=m,t[12]=S,t[13]=w,t[14]=c):c=t[14];let D;return t[15]!==E||t[16]!==N||t[17]!==F||t[18]!==M||t[19]!==c?(D=e.jsx(xe,{onBack:F,initialUrl:N,initialLabel:E,isRecoveryMode:!0,showInstancePicker:M,onSwitchToLocal:c}),t[15]=E,t[16]=N,t[17]=F,t[18]=M,t[19]=c,t[20]=D):D=t[20],D}const b=m?I:void 0;let R;return t[21]!==g||t[22]!==f||t[23]!==n||t[24]!==r||t[25]!==x||t[26]!==b||t[27]!==s?(R=e.jsx(Ee,{variant:s,hostLabel:n,hostUrl:r,onRetry:g,onUseLocal:b,onUseRemote:f,isRetrying:x}),t[21]=g,t[22]=f,t[23]=n,t[24]=r,t[25]=x,t[26]=b,t[27]=s,t[28]=R):R=t[28],R}async function Fe(a){if(!$())return;const t=await V();await q({...t,...a==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function Be(a){const t=J.c(29),{onBack:s,onCliAvailable:r,mode:n,recoveryVariant:i,recoveryHostUrl:u,recoveryHostLabel:h,onEnterLocalSetup:o,localAvailable:w}=a,S=n===void 0?"first-launch":n,j=i===void 0?"missing-default-host":i,U=w===void 0?!0:w,[K,x]=l.useState(!1),[m,k]=l.useState(!1);let C;t[0]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{k(!1),x(!1)},t[0]=C):C=t[0];let g;t[1]!==S||t[2]!==h||t[3]!==u||t[4]!==j?(g=[S,j,u,h],t[1]=S,t[2]=h,t[3]=u,t[4]=j,t[5]=g):g=t[5],l.useEffect(C,g);const T=m?"local-setup":S;if(T==="recovery"){let y;t[6]===Symbol.for("react.memo_cache_sentinel")?(y=()=>x(!0),t[6]=y):y=t[6];let f,b;t[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!1),b=()=>{x(!1),k(!0)},t[7]=f,t[8]=b):(f=t[7],b=t[8]);let R;t[9]!==o?(R=()=>{k(!0),o?.()},t[9]=o,t[10]=R):R=t[10];let N;return t[11]!==U||t[12]!==h||t[13]!==u||t[14]!==j||t[15]!==K||t[16]!==R?(N=e.jsx(Ae,{variant:j,hostUrl:u,hostLabel:h,onChooseRemote:y,showRemoteForm:K,onCloseRemoteForm:f,onSwitchToLocalFromRemote:b,onEnterLocalSetup:R,localAvailable:U}),t[11]=U,t[12]=h,t[13]=u,t[14]=j,t[15]=K,t[16]=R,t[17]=N):N=t[17],N}if(T==="local-setup"){let y;t[18]!==s||t[19]!==m?(y=()=>{m?k(!1):s?.()},t[18]=s,t[19]=m,t[20]=y):y=t[20];let f;t[21]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!0),t[21]=f):f=t[21];let b;return t[22]!==r||t[23]!==m||t[24]!==y?(b=e.jsx(Ie,{onBack:y,onCliAvailable:r,isFromRecovery:m,onSwitchToRemote:f}),t[22]=r,t[23]=m,t[24]=y,t[25]=b):b=t[25],b}let I;return t[26]!==U||t[27]!==r?(I=e.jsx(Re,{onCliAvailable:r,localAvailable:U}),t[26]=U,t[27]=r,t[28]=I):I=t[28],I}export{Be as OnboardingScreen};
1
+ import{r as _,j as e,R as l,b as J}from"./vendor-.bun-BzW0Lgld.js";import{H as V,aq as we,au as ie,ap as q,w as $,ag as B,cB as je,r as z,N as ue,P as me,v as pe,K as ne}from"./index-Dld5wFqI.js";import{f as Q,B as L,z as G,C as he,y as re,I as A}from"./useAppFontEffects-CZdEKvZ8.js";function ke(a){switch(a){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function oe(a){return a==="wrong-service"||a==="unreachable"||a==="incompatible"}function xe({onBack:a,showBackButton:t=!0,initialUrl:s="",initialLabel:r="",isRecoveryMode:n=!1,onConnect:i,onSwitchToLocal:u,showInstancePicker:h=!1}){const{t:o}=Q(),[w,S]=_.useState(s),[j,U]=_.useState(r),[K,x]=_.useState("idle"),[m,k]=_.useState(null),[C,g]=_.useState(""),[T,I]=_.useState([]),[y,f]=_.useState(()=>h?"instances":"add"),[b,R]=_.useState("");_.useEffect(()=>{h&&V().then(p=>I(p.hosts)).catch(p=>{g(p instanceof Error?p.message:String(p))})},[h]);const N=we(w),E=N?.persistedUrl??null,F=_.useCallback(p=>{S(p.target.value),x("idle"),k(null),g("")},[]),O=_.useCallback(p=>{U(p.target.value)},[]),c=_.useCallback(async()=>{if(E){x("testing"),k(null),g("");try{const p=await ie(E);k(p),x(p.status==="ok"||p.status==="update-recommended"?"success":"error")}catch(p){g(p instanceof Error?p.message:o("onboarding.remoteConnection.errors.connectionTestFailed")),x("error")}}},[E,o]),D=_.useCallback(async()=>{if(!N)return;const p=N.persistedUrl;x("testing"),k(null),g("");try{const H=await ie(p);if(k(H),oe(H.status)){x("error");return}const Z=await V(),ye=j.trim()||p,ee=Z.hosts.find(X=>X.url===p),te=ee?ee.id:`host-${Date.now().toString(16)}`,le={id:te,label:ye,url:p,apiUrl:p},ve=ee?Z.hosts.map(X=>X.id===te?le:X):[...Z.hosts,le];if(await q({hosts:ve,defaultHostId:te,initialHostChoiceCompleted:!0}),i?.(),N.redeemUrl){window.location.assign(N.redeemUrl);return}$()&&await B()}catch(H){g(H instanceof Error?H.message:o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[N,j,i,o]),M=_.useCallback(async p=>{const H=await V();await q({hosts:H.hosts,defaultHostId:p,initialHostChoiceCompleted:!0}),await B()},[]),d=_.useCallback(async()=>{x("testing"),g("");try{const p=await V(),H=await je(b,p.hosts);await q({hosts:H.hosts,defaultHostId:H.hostId,initialHostChoiceCompleted:!0}),await B()}catch(p){g(p instanceof Error&&p.message==="invalid-connect-link"?o("settings.remoteInstances.direct.error.invalidConnectLink"):o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[b,o]),v=K==="testing",P=E!==null&&!v,W=E!==null&&!v&&!oe(m?.status??null),Y=ke(m?.status??null),fe=m?.status==="ok",be=m?.status==="update-recommended",ge=m?.status==="auth",ae=oe(m?.status??null);return h&&y==="instances"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("desktopHostSwitcher.actions.switchInstance")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.description")})]}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx("div",{className:"space-y-2",children:T.length===0?e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:o("settings.remoteInstances.direct.state.empty")}):T.map(p=>e.jsx(L,{variant:"outline",className:"w-full justify-start",onClick:()=>{M(p.id)},children:e.jsx("span",{className:"min-w-0 truncate",children:p.label})},p.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{variant:"outline",className:"flex-1",onClick:()=>f("import"),children:o("settings.remoteInstances.direct.import.action")}),e.jsx(L,{className:"flex-1",onClick:()=>f("add"),children:o("settings.remoteInstances.direct.actions.add")})]})]})}):h&&y==="import"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsx(L,{variant:"ghost",onClick:()=>f("instances"),className:"p-0 text-muted-foreground",children:o("onboarding.common.actions.back")}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("settings.remoteInstances.direct.import.action")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.import.description")})]}),e.jsx(G,{value:b,onChange:p=>R(p.target.value),placeholder:o("settings.remoteInstances.direct.import.placeholder"),disabled:v,autoFocus:!0}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx(L,{onClick:()=>{d()},disabled:v||!b.trim(),children:o("settings.remoteInstances.direct.import.action")})]})}):e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[(t||h)&&e.jsx("div",{className:"flex items-center",children:e.jsx(L,{variant:"ghost",onClick:h?()=>f("instances"):a,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o(n?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("onboarding.remoteConnection.description")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.serverAddress")}),e.jsx(G,{id:"remote-url",type:"url",value:w,onChange:F,placeholder:o("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:v})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.nameOptional")}),e.jsx(G,{id:"remote-label",type:"text",value:j,onChange:O,placeholder:o("onboarding.remoteConnection.field.namePlaceholder"),disabled:v})]})]}),m&&fe&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:o("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&ge&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:o("onboarding.remoteConnection.status.authWarning")}),m&&be&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:Y?o(Y):null}),m&&ae&&e.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold mb-1",children:o("onboarding.remoteConnection.status.connectionFailed")}),e.jsx("div",{className:"opacity-90",children:Y?o(Y):null})]}),e.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?o("onboarding.remoteConnection.status.suggestionsUnreachable"):o("onboarding.remoteConnection.status.suggestionsWrongService")})]}),C&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:C}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(L,{variant:"outline",onClick:c,disabled:!P,children:o(v?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),e.jsx(L,{onClick:D,disabled:!W,children:o("onboarding.remoteConnection.actions.connectAndRestart")})]}),ae&&e.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[e.jsx("div",{className:"text-xs text-muted-foreground text-center",children:o("onboarding.remoteConnection.actions.whatToDo")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{variant:"outline",size:"sm",onClick:a,className:"flex-1",children:o("onboarding.remoteConnection.actions.chooseDifferentServer")}),!n&&u&&e.jsx(L,{variant:"outline",size:"sm",onClick:u,className:"flex-1",children:o("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const Ce="curl -fsSL https://opencode.ai/install | bash",Ne="https://opencode.ai/docs",ce=2500;function Se(a){const t=J.c(5),{onCopy:s,copyTitle:r}=a;let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),t[0]=n):n=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=e.jsx(A,{name:"file-copy",className:"h-4 w-4"}),t[1]=i):i=t[1];let u;return t[2]!==r||t[3]!==s?(u=e.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[n,e.jsx("button",{onClick:s,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:r,"aria-label":r,children:i})]}),t[2]=r,t[3]=s,t[4]=u):u=t[4],u}function Re({onCliAvailable:a,localAvailable:t=!0}){const{t:s}=Q(),[r,n]=l.useState(!1),[i,u]=l.useState(!1),[h,o]=l.useState(!1),[w,S]=l.useState(!1),[j,U]=l.useState(""),[K,x]=l.useState("unknown"),[m,k]=l.useState(()=>t?"local":"remote"),[C,g]=l.useState(!1),[T,I]=l.useState(!1);l.useEffect(()=>{u($())},[]),l.useEffect(()=>{if(typeof navigator>"u"){x("unknown");return}const d=navigator.userAgent||"";/Windows/i.test(d)?x("windows"):/Macintosh|Mac OS X/i.test(d)?x("macos"):/Linux/i.test(d)?x("linux"):x("unknown")},[]),l.useEffect(()=>{let d=!1;return(async()=>{try{const v=await z("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!v.ok)return;const P=await v.json().catch(()=>null);if(!P||d)return;const W=typeof P.opencodeBinary=="string"?P.opencodeBinary.trim():"";W&&U(W)}catch{}})(),()=>{d=!0}},[]);const y=l.useCallback(async d=>{const v=d.target;v.closest(".app-region-no-drag")||v.closest("button, a, input, select, textarea, code, summary, details")||d.button===0&&i&&await ue()},[i]),f=l.useCallback(async()=>{try{const d=await z("/health");if(!d.ok)return!1;const v=await d.json();return v.openCodeRunning===!0||v.isOpenCodeReady===!0}catch{return!1}},[]),b=l.useCallback(async d=>{if(!i)return;const v=await V();await q({...v,...d==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[i]),R=l.useCallback(async()=>{i&&await b("local"),a?.()},[i,a,b]);l.useEffect(()=>{if(!t||m!=="local")return;let d=!1,v=null;const P=async()=>{if(!d){try{const W=await f();if(d)return;if(W){await R();return}}catch{}d||(v=setTimeout(P,ce))}};return v=setTimeout(P,ce),()=>{d=!0,v&&clearTimeout(v)}},[m,f,R,t]);const N=l.useCallback(async()=>{S(!0);try{await f()&&await R()}finally{S(!1)}},[f,R]),E=l.useCallback(async()=>{if(!(typeof window>"u")&&i)try{const d=await me();d.success&&d.path&&d.path.trim().length>0&&U(d.path.trim())}catch{}},[i]),F=l.useCallback(async()=>{o(!0);try{if(await pe({opencodeBinary:j.trim()}),i){await b("local"),await B();return}await z("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>o(!1),1e3)}},[i,j,b]),O=l.useCallback(async()=>{const d=await he(Ce);d.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",d.error)},[]),c=Ne,D=K==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":K==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",M=t&&(!i||m==="local");return e.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:y,children:e.jsxs("div",{className:"w-full max-w-md space-y-7",children:[e.jsxs("header",{className:"text-center space-y-1.5",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:s("onboarding.chooser.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("onboarding.chooser.description")})]}),i&&t&&e.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[e.jsx("button",{type:"button",className:re("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>k("local"),children:s("onboarding.chooser.tabs.localInstall")}),e.jsx("button",{type:"button",className:re("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>k("remote"),children:s("onboarding.chooser.tabs.connectRemote")})]}),i&&m==="remote"?e.jsx("div",{className:"app-region-no-drag",children:e.jsx(xe,{onBack:()=>t&&k("local"),showBackButton:!1,showInstancePicker:!t,onSwitchToLocal:t?()=>k("local"):void 0})}):null,M&&e.jsxs("div",{className:"space-y-4",children:[K==="windows"&&e.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-4",children:[e.jsx("div",{className:"text-sm text-foreground",children:s("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:s("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:s("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:s("onboarding.localSetup.intro")}),e.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:r?e.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(A,{name:"check",className:"h-4 w-4"}),s("onboarding.common.status.copiedToClipboard")]}):e.jsx(Se,{onCopy:O,copyTitle:s("onboarding.common.copyToClipboard")})}),e.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[e.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[s(K==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(A,{name:"external-link",className:"h-3 w-3"})]}),e.jsx("button",{type:"button",onClick:N,disabled:w,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:s(w?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),e.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[e.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 shrink-0","aria-hidden":!0,children:[e.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}}),e.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-foreground leading-tight",children:s("onboarding.localSetup.status.watching")}),e.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:s("onboarding.localSetup.status.autoContinue")})]})]}),e.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:C,onToggle:d=>g(d.currentTarget.open),children:[e.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.advanced.title")}),e.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsxs("div",{className:"pb-4 space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{value:j,onChange:d=>U(d.target.value),placeholder:D,disabled:h,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",size:"sm",onClick:E,disabled:h||!i,children:s("onboarding.localSetup.actions.browse")}),e.jsx(L,{type:"button",size:"sm",onClick:F,disabled:h||!j.trim(),children:s("onboarding.localSetup.actions.apply")})]}),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:s("onboarding.localSetup.helper.saveAndReload")})]})]}),e.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:T,onToggle:d=>I(d.currentTarget.open),children:[e.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.troubleshoot.title")}),e.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:K==="windows"?e.jsx(e.Fragment,{children:e.jsx("li",{children:s("onboarding.localSetup.windows.hintDetectionFailed")})}):e.jsxs(e.Fragment,{children:[e.jsx("li",{children:s("onboarding.localSetup.hint.ensurePath")}),e.jsx("li",{children:s("onboarding.localSetup.hint.setEnv")}),e.jsx("li",{children:s("onboarding.localSetup.hint.missingRuntime")})]})})]})]})]})})}const Le="curl -fsSL https://opencode.ai/install | bash",Ue="https://opencode.ai/docs";function Te(a){const t=J.c(5),{onCopy:s,copyTitle:r}=a;let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsxs("code",{children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),t[0]=n):n=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=e.jsx(A,{name:"file-copy",className:"h-4 w-4"}),t[1]=i):i=t[1];let u;return t[2]!==r||t[3]!==s?(u=e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[n,e.jsx("button",{onClick:s,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:r,children:i})]}),t[2]=r,t[3]=s,t[4]=u):u=t[4],u}const Ke=3e4;function Ie({onBack:a,onCliAvailable:t,isFromRecovery:s=!1,onSwitchToRemote:r}){const{t:n}=Q(),[i,u]=l.useState(!1),[h,o]=l.useState(!1),[w,S]=l.useState(!1),[j,U]=l.useState(!1),[K,x]=l.useState(!1),[m,k]=l.useState(null),[C,g]=l.useState(""),[T,I]=l.useState("unknown");l.useEffect(()=>{const c=setTimeout(()=>o(!0),Ke);return()=>clearTimeout(c)},[]),l.useEffect(()=>{S($())},[]),l.useEffect(()=>{if(typeof navigator>"u"){I("unknown");return}const c=navigator.userAgent||"";if(/Windows/i.test(c)){I("windows");return}if(/Macintosh|Mac OS X/i.test(c)){I("macos");return}if(/Linux/i.test(c)){I("linux");return}I("unknown")},[]),l.useEffect(()=>{let c=!1;return(async()=>{try{const D=await z("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!D.ok)return;const M=await D.json().catch(()=>null);if(!M||c)return;const d=typeof M.opencodeBinary=="string"?M.opencodeBinary.trim():"";d&&g(d)}catch{}})(),()=>{c=!0}},[]);const y=l.useCallback(async c=>{c.target.closest("button, a, input, select, textarea, code")||c.button===0&&w&&await ue()},[w]),f=l.useCallback(async()=>{try{const c=await z("/health");if(!c.ok)return!1;const D=await c.json();return D.openCodeRunning===!0||D.isOpenCodeReady===!0}catch{return!1}},[]),b=l.useCallback(async()=>{if(!(typeof window>"u")&&w)try{const c=await me();c.success&&c.path&&c.path.trim().length>0&&g(c.path.trim())}catch{}},[w]),R=l.useCallback(async()=>{U(!0);try{if(await pe({opencodeBinary:C.trim()}),w){await B();return}await z("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>U(!1),1e3)}},[w,C]),N=l.useCallback(async()=>{const c=await he(Le);c.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error("Failed to copy:",c.error)},[]),E=l.useCallback(async()=>{x(!0),k(null);try{await f()?t?.():k(n("onboarding.localSetup.errors.cliNotReady"))}catch(c){k(c instanceof Error?c.message:n("onboarding.localSetup.errors.detectionFailed"))}finally{x(!1)}},[f,t,n]),F=Ue,O=T==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":T==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode";return e.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:y,children:[e.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[e.jsx("div",{className:"flex items-center",children:e.jsx(L,{variant:"ghost",onClick:a,className:"p-0 text-muted-foreground hover:text-foreground",children:n("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:n("onboarding.localSetup.title")}),e.jsx("p",{className:"text-muted-foreground",children:n("onboarding.localSetup.description")})]}),T==="windows"&&e.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[e.jsx("div",{className:"text-sm text-foreground",children:n("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:n("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:n("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:i?e.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(A,{name:"check",className:"h-4 w-4"}),n("onboarding.common.status.copiedToClipboard")]}):e.jsx(Te,{onCopy:N,copyTitle:n("onboarding.common.copyToClipboard")})})}),e.jsxs("a",{href:F,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(T==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(A,{name:"external-link",className:"h-3 w-3"})]}),m&&e.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:m}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(L,{type:"button",onClick:E,disabled:K,className:"w-full max-w-xs",size:"lg",children:n(K?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("onboarding.localSetup.helper.checkAndContinue")})]}),e.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:n("onboarding.localSetup.field.alreadyInstalled")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{value:C,onChange:c=>g(c.target.value),placeholder:O,disabled:j,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",onClick:b,disabled:j||!w,children:n("onboarding.localSetup.actions.browse")}),e.jsx(L,{type:"button",onClick:R,disabled:j,children:n("onboarding.localSetup.actions.apply")})]}),e.jsx("div",{className:"text-xs text-muted-foreground/70",children:n("onboarding.localSetup.helper.saveAndReload")})]})}),s&&r&&e.jsxs("div",{className:"text-center pt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:n("onboarding.localSetup.remotePreference")}),e.jsx(L,{variant:"link",onClick:r,children:n("onboarding.localSetup.actions.connectRemoteServer")})]})]}),h&&e.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:T==="windows"?e.jsx(e.Fragment,{children:e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.windows.hintDetectionFailed")})}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.ensurePath")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.setEnv")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.missingRuntime")})]})})]})}function se(a,t){if(a?.trim())return ne(a.trim());if(t)return ne(t)}function _e(a,t,s){switch(a){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const r=se(t,s);return{title:"Remote Server Unreachable",description:`Could not connect to "${r||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:r?{host:r}: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 r=se(t,s);return{title:"Incompatible Server",description:`The server at "${r||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:r?{host:r}: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 r=se(t,s);return{title:"Server Update Required",description:`The OpenChamber server at "${r||"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:r?{host:r}: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 r=a;throw new Error(`Unknown recovery variant: ${r}`)}}}function De(a){switch(a){case"local":return e.jsx(A,{name:"macbook",className:"h-8 w-8"});case"remote":return e.jsx(A,{name:"server",className:"h-8 w-8"})}}function Ee({variant:a,hostLabel:t,hostUrl:s,onRetry:r,onUseLocal:n,onUseRemote:i,isRetrying:u=!1}){const{t:h}=Q(),o=_e(a,t,s),w=o.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",S=l.useMemo(()=>{if(o.descriptionParams?.host)return o.descriptionParams;if(a==="remote-unreachable")return{host:h("onboarding.desktopRecovery.placeholders.remoteServer")};if(a==="remote-wrong-service"||a==="remote-incompatible")return{host:h("onboarding.desktopRecovery.placeholders.unknownServer")}},[o.descriptionParams,h,a]);return e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[e.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:e.jsx("div",{style:{color:"var(--status-warning)"},children:De(o.iconKey)})}),e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:h(o.titleKey)}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:h(o.descriptionKey,S)})]}),s&&(a==="remote-unreachable"||a==="remote-wrong-service"||a==="remote-incompatible")&&e.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:h("onboarding.remoteConnection.field.serverAddress")}),e.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:ne(s)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[o.showRetry&&r&&e.jsxs(L,{onClick:r,disabled:u,className:"w-full",children:[e.jsx(A,{name:"refresh",className:re("h-4 w-4",u&&"animate-spin")}),h(u?"onboarding.desktopRecovery.actions.retrying":w)]}),e.jsxs("div",{className:"flex gap-2",children:[o.showUseLocal&&n&&e.jsxs(L,{variant:"outline",onClick:n,disabled:u,className:"flex-1",children:[e.jsx(A,{name:"macbook",className:"h-4 w-4"}),h(o.useLocalLabelKey)]}),o.showUseRemote&&i&&e.jsxs(L,{variant:"outline",onClick:i,disabled:u,className:"flex-1",children:[e.jsx(A,{name:"server",className:"h-4 w-4"}),h(o.useRemoteLabelKey)]})]})]})]})})}function de(a,t){if(t==="use-remote")return{kind:"remote-form"};switch(a){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const s=a;throw new Error(`Unhandled RecoveryVariant: ${s}`)}}}function Ae(a){const t=J.c(29),{variant:s,hostUrl:r,hostLabel:n,onRetry:i,onChooseRemote:u,showRemoteForm:h,onCloseRemoteForm:o,onSwitchToLocalFromRemote:w,onEnterLocalSetup:S,isRetrying:j,localAvailable:U}=a,K=h===void 0?!1:h,x=j===void 0?!1:j,m=U===void 0?!0:U,k=Fe;let C;t[0]!==i?(C=async()=>{if($()){await B();return}await z("/api/config/reload",{method:"POST"}),i?.()},t[0]=i,t[1]=C):C=t[1];const g=C;let T;t[2]!==S||t[3]!==s?(T=async()=>{if(de(s,"use-local").kind==="local-setup"){S?.();return}if(await k("local"),$()){await B();return}window.location.reload()},t[2]=S,t[3]=s,t[4]=T):T=t[4];const I=T;let y;t[5]!==u||t[6]!==s?(y=()=>{de(s,"use-remote").kind==="remote-form"&&u?.()},t[5]=u,t[6]=s,t[7]=y):y=t[7];const f=y;if(K){const N=s==="remote-wrong-service"?"":r||"",E=s==="remote-wrong-service"?"":n||"";let F;t[8]!==u||t[9]!==o?(F=o||(()=>u?.()),t[8]=u,t[9]=o,t[10]=F):F=t[10];const O=!m;let c;t[11]!==m||t[12]!==S||t[13]!==w?(c=m?w||(()=>{k("local").then(()=>{$()?B():S?.()})}):void 0,t[11]=m,t[12]=S,t[13]=w,t[14]=c):c=t[14];let D;return t[15]!==E||t[16]!==N||t[17]!==F||t[18]!==O||t[19]!==c?(D=e.jsx(xe,{onBack:F,initialUrl:N,initialLabel:E,isRecoveryMode:!0,showInstancePicker:O,onSwitchToLocal:c}),t[15]=E,t[16]=N,t[17]=F,t[18]=O,t[19]=c,t[20]=D):D=t[20],D}const b=m?I:void 0;let R;return t[21]!==g||t[22]!==f||t[23]!==n||t[24]!==r||t[25]!==x||t[26]!==b||t[27]!==s?(R=e.jsx(Ee,{variant:s,hostLabel:n,hostUrl:r,onRetry:g,onUseLocal:b,onUseRemote:f,isRetrying:x}),t[21]=g,t[22]=f,t[23]=n,t[24]=r,t[25]=x,t[26]=b,t[27]=s,t[28]=R):R=t[28],R}async function Fe(a){if(!$())return;const t=await V();await q({...t,...a==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function Be(a){const t=J.c(29),{onBack:s,onCliAvailable:r,mode:n,recoveryVariant:i,recoveryHostUrl:u,recoveryHostLabel:h,onEnterLocalSetup:o,localAvailable:w}=a,S=n===void 0?"first-launch":n,j=i===void 0?"missing-default-host":i,U=w===void 0?!0:w,[K,x]=l.useState(!1),[m,k]=l.useState(!1);let C;t[0]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{k(!1),x(!1)},t[0]=C):C=t[0];let g;t[1]!==S||t[2]!==h||t[3]!==u||t[4]!==j?(g=[S,j,u,h],t[1]=S,t[2]=h,t[3]=u,t[4]=j,t[5]=g):g=t[5],l.useEffect(C,g);const T=m?"local-setup":S;if(T==="recovery"){let y;t[6]===Symbol.for("react.memo_cache_sentinel")?(y=()=>x(!0),t[6]=y):y=t[6];let f,b;t[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!1),b=()=>{x(!1),k(!0)},t[7]=f,t[8]=b):(f=t[7],b=t[8]);let R;t[9]!==o?(R=()=>{k(!0),o?.()},t[9]=o,t[10]=R):R=t[10];let N;return t[11]!==U||t[12]!==h||t[13]!==u||t[14]!==j||t[15]!==K||t[16]!==R?(N=e.jsx(Ae,{variant:j,hostUrl:u,hostLabel:h,onChooseRemote:y,showRemoteForm:K,onCloseRemoteForm:f,onSwitchToLocalFromRemote:b,onEnterLocalSetup:R,localAvailable:U}),t[11]=U,t[12]=h,t[13]=u,t[14]=j,t[15]=K,t[16]=R,t[17]=N):N=t[17],N}if(T==="local-setup"){let y;t[18]!==s||t[19]!==m?(y=()=>{m?k(!1):s?.()},t[18]=s,t[19]=m,t[20]=y):y=t[20];let f;t[21]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!0),t[21]=f):f=t[21];let b;return t[22]!==r||t[23]!==m||t[24]!==y?(b=e.jsx(Ie,{onBack:y,onCliAvailable:r,isFromRecovery:m,onSwitchToRemote:f}),t[22]=r,t[23]=m,t[24]=y,t[25]=b):b=t[25],b}let I;return t[26]!==U||t[27]!==r?(I=e.jsx(Re,{onCliAvailable:r,localAvailable:U}),t[26]=U,t[27]=r,t[28]=I):I=t[28],I}export{Be as OnboardingScreen};
@@ -1 +1 @@
1
- import{b as ne,R as je,j as n,r as $e,af as Ie}from"./vendor-.bun-DvcSrJLa.js";import{u as ye,aB as ze,aV as Te,aW as Fe,N as Ne,$ as Se}from"./index-DMCrPMIW.js";import{f as Ce,y as Q,aP as Oe,aq as Ee,ar as We,I as X,N as Ae,aO as Be,aN as Ue,bq as Ke,br as Ge,bn as Ye,u as He,b as Re,c as qe,d as Je,cC as Qe,e as Pe,r as _e,aH as Ve,aJ as Xe,aK as Ze,K as ke,d7 as et,dd as tt}from"./useAppFontEffects-DrLhDSC3.js";function Wt(){const s=ne.c(5),e=ye(st);let t;s[0]===Symbol.for("react.memo_cache_sentinel")?(t=ze(),s[0]=t):t=s[0];const a=t;let r;s[1]!==e?(r=Te(e),s[1]=e,s[2]=r):r=s[2];const i=r;let o;return s[3]!==i?(o={usesFramelessChrome:a,side:i},s[3]=i,s[4]=o):o=s[4],o}function st(s){return s.desktopWindowControlsPosition}const At=s=>{const e=ne.c(129),{totalTokens:t,percentage:a,colorPercentage:r,contextLimit:i,outputLimit:o,size:c,isMobile:b,hideIcon:u,showPercentIcon:l,className:x,valueClassName:g,percentIconClassName:f,onClick:p,pressed:w}=s,y=c===void 0?"default":c,v=b===void 0?!1:b,j=u===void 0?!1:u,S=l===void 0?!1:l,C=w===void 0?!1:w,{t:d}=Ce(),[_,M]=je.useState(!1),h=typeof r=="number"?r:a;let m,N,P,k,T,U,B,K;if(e[0]!==h||e[1]!==i||e[2]!==j||e[3]!==v||e[4]!==p||e[5]!==o||e[6]!==f||e[7]!==a||e[8]!==S||e[9]!==d||e[10]!==t||e[11]!==g){const $=Ee(a)??0,L=We(h),I=L==="critical"?"var(--status-error)":L==="warn"?"var(--status-warning)":"var(--status-success)";m=nt,N=ot;const z=2*Math.PI*8.5,D=z*(1-$/100);k=typeof o=="number"?Math.max(o,0):0;let E;e[20]!==d||e[21]!==t?(E=d("contextUsage.tooltip.usedTokens",{tokens:m(t)}),e[20]=d,e[21]=t,e[22]=E):E=e[22];let W;e[23]!==i||e[24]!==d?(W=d("contextUsage.tooltip.contextLimit",{tokens:m(i)}),e[23]=i,e[24]=d,e[25]=W):W=e[25];let A;e[26]!==k||e[27]!==d?(A=d("contextUsage.tooltip.outputLimit",{tokens:m(k)}),e[26]=k,e[27]=d,e[28]=A):A=e[28];let J;e[29]!==W||e[30]!==A||e[31]!==E?(J=[E,W,A],e[29]=W,e[30]=A,e[31]=E,e[32]=J):J=e[32],K=J,P=!v&&typeof p=="function",e[33]!==j||e[34]!==v?(B=!v&&!j&&n.jsx(X,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e[33]=j,e[34]=v,e[35]=B):B=e[35],e[36]!==g?(T=Q("font-medium inline-flex items-center gap-1.5",g),e[36]=g,e[37]=T):T=e[37],U=S?n.jsxs(n.Fragment,{children:[n.jsxs("svg",{viewBox:"0 0 20 20",className:Q("h-3.5 w-3.5 -rotate-90",f),role:"progressbar","aria-valuenow":Math.round($),"aria-valuemin":0,"aria-valuemax":100,children:[n.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),n.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:I,strokeWidth:3,strokeLinecap:"round",strokeDasharray:z,strokeDashoffset:D,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),n.jsxs("span",{className:"text-foreground",children:[Math.min(a,999).toFixed(1),"%"]})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:N(h),children:Math.min(a,999).toFixed(1)}),"%"]}),e[0]=h,e[1]=i,e[2]=j,e[3]=v,e[4]=p,e[5]=o,e[6]=f,e[7]=a,e[8]=S,e[9]=d,e[10]=t,e[11]=g,e[12]=m,e[13]=N,e[14]=P,e[15]=k,e[16]=T,e[17]=U,e[18]=B,e[19]=K}else m=e[12],N=e[13],P=e[14],k=e[15],T=e[16],U=e[17],B=e[18],K=e[19];let G;e[38]!==T||e[39]!==U?(G=n.jsx("span",{className:T,children:U}),e[38]=T,e[39]=U,e[40]=G):G=e[40];let Z;e[41]!==B||e[42]!==G?(Z=n.jsxs(n.Fragment,{children:[B,G]}),e[41]=B,e[42]=G,e[43]=Z):Z=e[43];const Y=Z,ee=y==="compact"?"typography-micro":"typography-meta";let te;e[44]!==x||e[45]!==P||e[46]!==ee?(te=Q("app-region-no-drag flex items-center gap-1.5 select-none",ee,P?Q("rounded-md px-2 py-1.5 text-foreground transition-colors","hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"):"text-muted-foreground/60",x),e[44]=x,e[45]=P,e[46]=ee,e[47]=te):te=e[47];const H=te;let R;e[48]!==Y||e[49]!==P||e[50]!==v||e[51]!==p||e[52]!==C||e[53]!==H||e[54]!==d?(R=P?n.jsx("button",{type:"button",className:H,"aria-label":d("contextUsage.aria.label"),"aria-pressed":C,onClick:p,children:Y}):n.jsx("div",{className:H,"aria-label":d("contextUsage.aria.label"),onClick:v?()=>M(!0):void 0,children:Y}),e[48]=Y,e[49]=P,e[50]=v,e[51]=p,e[52]=C,e[53]=H,e[54]=d,e[55]=R):R=e[55];const V=R;if(v){let $;e[56]===Symbol.for("react.memo_cache_sentinel")?($=()=>M(!1),e[56]=$):$=e[56];let L;e[57]!==d?(L=d("contextUsage.mobile.title"),e[57]=d,e[58]=L):L=e[58];let I;e[59]!==d?(I=d("contextUsage.mobile.usedTokens"),e[59]=d,e[60]=I):I=e[60];let z;e[61]!==I?(z=n.jsx("span",{className:"typography-meta text-muted-foreground",children:I}),e[61]=I,e[62]=z):z=e[62];let D;e[63]!==m||e[64]!==t?(D=m(t),e[63]=m,e[64]=t,e[65]=D):D=e[65];let E;e[66]!==D?(E=n.jsx("span",{className:"typography-meta text-foreground font-medium",children:D}),e[66]=D,e[67]=E):E=e[67];let W;e[68]!==z||e[69]!==E?(W=n.jsxs("div",{className:"flex justify-between items-center",children:[z,E]}),e[68]=z,e[69]=E,e[70]=W):W=e[70];let A;e[71]!==d?(A=d("contextUsage.mobile.contextLimit"),e[71]=d,e[72]=A):A=e[72];let J;e[73]!==A?(J=n.jsx("span",{className:"typography-meta text-muted-foreground",children:A}),e[73]=A,e[74]=J):J=e[74];let oe;e[75]!==i||e[76]!==m?(oe=m(i),e[75]=i,e[76]=m,e[77]=oe):oe=e[77];let re;e[78]!==oe?(re=n.jsx("span",{className:"typography-meta text-foreground font-medium",children:oe}),e[78]=oe,e[79]=re):re=e[79];let ie;e[80]!==J||e[81]!==re?(ie=n.jsxs("div",{className:"flex justify-between items-center",children:[J,re]}),e[80]=J,e[81]=re,e[82]=ie):ie=e[82];let ae;e[83]!==d?(ae=d("contextUsage.mobile.outputLimit"),e[83]=d,e[84]=ae):ae=e[84];let le;e[85]!==ae?(le=n.jsx("span",{className:"typography-meta text-muted-foreground",children:ae}),e[85]=ae,e[86]=le):le=e[86];let ce;e[87]!==m||e[88]!==k?(ce=m(k),e[87]=m,e[88]=k,e[89]=ce):ce=e[89];let de;e[90]!==ce?(de=n.jsx("span",{className:"typography-meta text-foreground font-medium",children:ce}),e[90]=ce,e[91]=de):de=e[91];let ue;e[92]!==le||e[93]!==de?(ue=n.jsxs("div",{className:"flex justify-between items-center",children:[le,de]}),e[92]=le,e[93]=de,e[94]=ue):ue=e[94];let me;e[95]!==d?(me=d("contextUsage.mobile.usage"),e[95]=d,e[96]=me):me=e[96];let fe;e[97]!==me?(fe=n.jsx("span",{className:"typography-meta text-muted-foreground",children:me}),e[97]=me,e[98]=fe):fe=e[98];let pe;e[99]!==h||e[100]!==N?(pe=Q("typography-meta font-semibold",N(h)),e[99]=h,e[100]=N,e[101]=pe):pe=e[101];const De=Math.min(a,999);let he;e[102]!==De?(he=De.toFixed(1),e[102]=De,e[103]=he):he=e[103];let xe;e[104]!==pe||e[105]!==he?(xe=n.jsxs("span",{className:pe,children:[he,"%"]}),e[104]=pe,e[105]=he,e[106]=xe):xe=e[106];let ge;e[107]!==fe||e[108]!==xe?(ge=n.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[fe,xe]}),e[107]=fe,e[108]=xe,e[109]=ge):ge=e[109];let we;e[110]!==W||e[111]!==ie||e[112]!==ue||e[113]!==ge?(we=n.jsx("div",{className:"flex flex-col gap-1.5",children:n.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[W,ie,ue,ge]})}),e[110]=W,e[111]=ie,e[112]=ue,e[113]=ge,e[114]=we):we=e[114];let be;e[115]!==_||e[116]!==L||e[117]!==we?(be=n.jsx(Ae,{open:_,onClose:$,title:L,children:we}),e[115]=_,e[116]=L,e[117]=we,e[118]=be):be=e[118];let ve;return e[119]!==V||e[120]!==be?(ve=n.jsxs(n.Fragment,{children:[V,be]}),e[119]=V,e[120]=be,e[121]=ve):ve=e[121],ve}let F;e[122]!==V?(F=n.jsx(Be,{asChild:!0,children:V}),e[122]=V,e[123]=F):F=e[123];let O;e[124]!==K?(O=n.jsx(Oe,{children:n.jsx("div",{className:"space-y-0.5",children:K.map(rt)})}),e[124]=K,e[125]=O):O=e[125];let q;return e[126]!==F||e[127]!==O?(q=n.jsxs(Ue,{children:[F,O]}),e[126]=F,e[127]=O,e[128]=q):q=e[128],q};function nt(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toFixed(1).replace(/\.0$/,"")}function ot(s){return s>=90?"text-status-error":s>=75?"text-status-warning":"text-status-success"}function rt(s){return n.jsx("p",{className:"typography-micro leading-tight",children:s},s)}const Bt=je.memo(function(e){const t=ne.c(16),{visible:a,position:r}=e,i=r===void 0?"right":r,{t:o}=Ce(),[c,b]=je.useState(!1);let u,l;if(t[0]!==a?(u=()=>{if(!a)return;let y=!1;Ne("desktop_get_current_window_state").then(j=>{y||b(!!j?.maximized)}).catch(it);const v=j=>{const S=j.detail;b(!!S?.maximized)};return window.addEventListener("openchamber:window-maximized-changed",v),()=>{y=!0,window.removeEventListener("openchamber:window-maximized-changed",v)}},l=[a],t[0]=a,t[1]=u,t[2]=l):(u=t[1],l=t[2]),$e.useEffect(u,l),!a)return null;const x=i==="left";let g,f,p;if(t[3]!==x||t[4]!==c||t[5]!==i||t[6]!==o){const y=Q("app-region-no-drag inline-flex items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",x?"h-8 w-8 rounded-md":"h-12 w-11"),v=x?"app-region-no-drag mr-1 flex h-8 shrink-0 items-center":"app-region-no-drag ml-1 flex h-12 shrink-0 items-center",j=S=>S==="minimize"?n.jsx("button",{type:"button",className:y,onClick:at,title:o("header.windowControls.minimize"),"aria-label":o("header.windowControls.minimize"),children:n.jsx(X,{name:"subtract",className:"h-4 w-4"})},"minimize"):S==="maximize"?n.jsx("button",{type:"button",className:y,onClick:()=>{Ne("desktop_toggle_current_window_maximized").then(C=>b(!!C?.maximized)).catch(lt)},title:o(c?"header.windowControls.restore":"header.windowControls.maximize"),"aria-label":o(c?"header.windowControls.restore":"header.windowControls.maximize"),children:n.jsx(X,{name:c?"fullscreen-exit":"checkbox-blank",className:"h-3.5 w-3.5"})},"maximize"):n.jsx("button",{type:"button",className:Q(y,"hover:bg-status-error hover:text-status-error-foreground"),onClick:ct,title:o("header.windowControls.close"),"aria-label":o("header.windowControls.close"),children:n.jsx(X,{name:"close",className:"h-4 w-4"})},"close");g=v,t[10]!==o?(f=o("header.windowControls.groupAria"),t[10]=o,t[11]=f):f=t[11],p=Fe(i).map(j),t[3]=x,t[4]=c,t[5]=i,t[6]=o,t[7]=g,t[8]=f,t[9]=p}else g=t[7],f=t[8],p=t[9];let w;return t[12]!==g||t[13]!==f||t[14]!==p?(w=n.jsx("div",{className:g,"aria-label":f,children:p}),t[12]=g,t[13]=f,t[14]=p,t[15]=w):w=t[15],w});function it(){}function at(){Ne("desktop_minimize_current_window")}function lt(){}function ct(){Ne("desktop_close_current_window")}const Ut=(s,e,t)=>{const a=`${t}:`,r=new Set([...e].filter(i=>i.startsWith(a)));return s.size===r.size&&[...r].every(i=>s.has(i))?s:r},Kt=(s,e)=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t},se=(s,e)=>Ke(Ge.getState().dictionary,s,e),dt=s=>{const e=new Date(s),t=new Date,a=(o,c)=>o.getFullYear()===c.getFullYear()&&o.getMonth()===c.getMonth()&&o.getDate()===c.getDate(),r=new Date(t);return r.setDate(t.getDate()-1),a(e,t)?se("common.date.today"):a(e,r)?se("common.date.yesterday"):e.toLocaleDateString(Ye(),{month:"short",day:"numeric",year:"numeric"}).replace(",","")},Gt=s=>{const e=new Date,t=new Date(s);if(((r,i)=>r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate())(t,e)){const r=Date.now()-s;return r<6e4?se("common.relative.justNow"):r<36e5?se("common.relative.minutesAgoShort",{count:Math.floor(r/6e4)}):se("common.relative.hoursAgoShort",{count:Math.floor(r/36e5)})}return dt(s)},ut=s=>{const e=Math.max(0,Date.now()-s),t=6e4,a=60*t,r=24*a,i=7*r,o=30*r,c=365*r;return e<a?`${Math.max(1,Math.floor(e/t))}m`:e<r?`${Math.floor(e/a)}h`:e<i?se("common.relative.daysAgoCompact",{count:Math.floor(e/r)}):e<5*i?se("common.relative.weeksAgoCompact",{count:Math.floor(e/i)}):e<c?`${Math.floor(e/o)}mo`:se("common.relative.yearsAgoCompact",{count:Math.floor(e/c)})},mt=(s,e)=>{const t=Se(s),a=Se(e);return ft(t,a)},ft=(s,e)=>!s||!e?!1:s===e?!0:e==="/"?s.startsWith("/"):s.startsWith(`${e}/`),Le=s=>s.toLowerCase().replace(/^opencode[/-]?/i,"").replace(/[-_]/g,"").trim(),Yt=(s,e)=>s?Le(s)!==Le(e):!1,Ht=s=>{const e=new Map;return s.forEach(t=>{e.set(t.id,t)}),Array.from(e.values())},Rt=s=>`__archived__:${s}`,qt=(s,e)=>{const t=Se(s.directory??null),a=Se(s.project?.worktree??null),r=t??a;if(!r)return"unassigned";if(e&&r===e)return"project root";const o=(e&&r.startsWith(`${e}/`)?r.slice(e.length+1):r).split("/").filter(Boolean);return o[o.length-1]??"unassigned"},Jt=s=>s.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),Qt=(s,e)=>{if(!e)return s;const t=s.toLowerCase(),a=e.toLowerCase(),r=a.length;if(r===0)return s;const i=[];let o=0,c=t.indexOf(a,o);for(;c!==-1;){c>o&&i.push(s.slice(o,c));const b=s.slice(c,c+r);i.push(n.jsx("mark",{className:"bg-primary text-primary-foreground ring-1 ring-primary/90",children:b},`${c}-${b}`)),o=c+r,c=t.indexOf(a,o)}return o<s.length&&i.push(s.slice(o)),i.length>0?i:s},pt=7,ht=s=>{if(!s)return null;const e=s.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},xt=s=>{if(!s)return null;const e=s.label?.trim();if(e)return e;const t=s.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},gt=(s,e)=>{const t=ne.c(20);let a;t[0]!==e?(a=e===void 0?{}:e,t[0]=e,t[1]=a):a=t[1];const r=a,{scopeProjectId:i}=r,o=i===void 0?null:i,c=He(wt),b=Re(bt),u=qe(yt),l=Je(vt),x=Qe();let g;t[2]!==b?(g=b.map(jt).filter(Nt),t[2]=b,t[3]=g):g=t[3];const f=g;let p;t[4]!==f?(p=j=>j?f.filter(C=>mt(j,C.normalizedPath)).sort(St)[0]??null:null,t[4]=f,t[5]=p):p=t[5];const w=p;let y;{let j;if(t[7]!==c||t[8]!==x||t[9]!==w||t[10]!==u||t[11]!==o||t[12]!==l){const S=new Map;for(const h of c){const m=h.parentID;if(!m||h.time?.archived)continue;const N=S.get(m);N?N.push(h):S.set(m,[h])}S.forEach(h=>{h.sort((m,N)=>Pe(m,N,u,l))});let C;t[14]!==w||t[15]!==o?(C=h=>{if(!o)return!0;const m=_e(h);return w(m)?.id===o},t[14]=w,t[15]=o,t[16]=C):C=t[16];let d;t[17]!==u||t[18]!==l?(d=(h,m)=>Pe(h,m,u,l),t[17]=u,t[18]=l,t[19]=d):d=t[19];const _=c.filter(Ct).filter(Dt).filter(C).sort(d).slice(0,pt),M=h=>{const m=S.get(h.id)??[];return{session:h,children:m.map(N=>M(N)),worktree:null}};j=_.map(h=>{const m=_e(h),N=w(m),P=xt(N),k=m?x.get(m)??null:null;return{node:M(h),projectId:N?.id??null,groupDirectory:m,secondaryMeta:{projectLabel:P,branchLabel:k&&k!==P?k:null}}}),t[7]=c,t[8]=x,t[9]=w,t[10]=u,t[11]=o,t[12]=l,t[13]=j}else j=t[13];y=j}return y};function wt(s){return s.activeSessions}function bt(s){return s.projects}function yt(s){return s.ids}function vt(s){return s.rankById}function jt(s){return{...s,normalizedPath:ht(s.path)}}function Nt(s){return s.normalizedPath}function St(s,e){return(e.normalizedPath?.length??0)-(s.normalizedPath?.length??0)}function Ct(s){return!s.time?.archived}function Dt(s){return!s.parentID}function Vt(s){const e=ne.c(18),{children:t,variant:a,scopeProjectId:r,align:i}=s,o=a===void 0?"default":a,c=r===void 0?null:r,b=i===void 0?"start":i,u=ye(kt),l=ye(_t);let x;e[0]!==t?(x=n.jsx(Ve,{asChild:!0,children:t}),e[0]=t,e[1]=x):x=e[1];const g=o==="compact"?"w-[280px]":"w-[360px]";let f;e[2]!==g?(f=Q("overflow-hidden p-1 max-w-[calc(100vw-32px)]",g),e[2]=g,e[3]=f):f=e[3];let p;e[4]!==u||e[5]!==c||e[6]!==l||e[7]!==o?(p=u?n.jsx(Pt,{onSelect:()=>l(!1),variant:o,scopeProjectId:c}):null,e[4]=u,e[5]=c,e[6]=l,e[7]=o,e[8]=p):p=e[8];let w;e[9]!==b||e[10]!==f||e[11]!==p?(w=n.jsx(Xe,{align:b,sideOffset:6,className:f,children:p}),e[9]=b,e[10]=f,e[11]=p,e[12]=w):w=e[12];let y;return e[13]!==u||e[14]!==l||e[15]!==x||e[16]!==w?(y=n.jsxs(Ze,{open:u,onOpenChange:l,modal:!1,children:[x,w]}),e[13]=u,e[14]=l,e[15]=x,e[16]=w,e[17]=y):y=e[17],y}function _t(s){return s.setSessionDropdownOpen}function kt(s){return s.isSessionDropdownOpen}function Pt(s){const e=ne.c(26),{onSelect:t,variant:a,scopeProjectId:r}=s;let i;e[0]!==r?(i={scopeProjectId:r},e[0]=r,e[1]=i):i=e[1];const o=gt(!0,i),c=ke(It),b=ye(Lt),{t:u}=Ce();let l;e[2]!==t||e[3]!==c||e[4]!==b?(l=()=>{b("chat"),t(),c()},e[2]=t,e[3]=c,e[4]=b,e[5]=l):l=e[5];const x=l;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=new Set,e[6]=g):g=e[6];const[f,p]=je.useState(g);let w;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=h=>{p(m=>{const N=new Set(m);return N.has(h)?N.delete(h):N.add(h),N})},e[7]=w):w=e[7];const y=w;let v,j;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=Q("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),j=n.jsx(X,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e[8]=v,e[9]=j):(v=e[8],j=e[9]);let S;e[10]!==u?(S=u("sessions.sidebar.header.actions.newSession"),e[10]=u,e[11]=S):S=e[11];let C;e[12]!==S?(C=n.jsx("span",{className:"truncate text-[14px] font-normal leading-tight text-foreground",children:S}),e[12]=S,e[13]=C):C=e[13];let d;e[14]!==x||e[15]!==C?(d=n.jsxs(Ie,{onClick:x,className:v,children:[j,C]}),e[14]=x,e[15]=C,e[16]=d):d=e[16];let _;e[17]!==f||e[18]!==o||e[19]!==t||e[20]!==u||e[21]!==a?(_=o.length===0?n.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:u("sessions.switcher.empty")}):o.map(h=>n.jsx(Me,{item:h,depth:0,variant:a,expandedParents:f,toggleParent:y,closeDropdown:t},h.node.session.id)),e[17]=f,e[18]=o,e[19]=t,e[20]=u,e[21]=a,e[22]=_):_=e[22];let M;return e[23]!==_||e[24]!==d?(M=n.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:n.jsxs("div",{className:"space-y-0.5",children:[d,_]})}),e[23]=_,e[24]=d,e[25]=M):M=e[25],M}function Lt(s){return s.setActiveMainTab}function It(s){return s.openNewSessionDraft}function Me(s){const e=ne.c(31),{item:t,depth:a,variant:r,expandedParents:i,toggleParent:o,closeDropdown:c}=s,{node:b,secondaryMeta:u}=t,l=b.session,x=b.children.length>0;let g;e[0]!==i||e[1]!==l.id?(g=i.has(l.id),e[0]=i,e[1]=l.id,e[2]=g):g=e[2];const f=g;let p;e[3]!==x||e[4]!==l.id||e[5]!==o?(p=x?()=>o(l.id):void 0,e[3]=x,e[4]=l.id,e[5]=o,e[6]=p):p=e[6];let w;e[7]!==c||e[8]!==a||e[9]!==x||e[10]!==f||e[11]!==u||e[12]!==l||e[13]!==p||e[14]!==r?(w=n.jsx(Mt,{session:l,depth:a,variant:r,secondaryMeta:u,hasChildren:x,isExpanded:f,onToggleExpand:p,closeDropdown:c}),e[7]=c,e[8]=a,e[9]=x,e[10]=f,e[11]=u,e[12]=l,e[13]=p,e[14]=r,e[15]=w):w=e[15];let y;e[16]!==c||e[17]!==a||e[18]!==i||e[19]!==x||e[20]!==f||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==b.children||e[24]!==u||e[25]!==o||e[26]!==r?(y=x&&f?b.children.map(j=>n.jsx(Me,{item:{node:j,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:u},depth:a+1,variant:r,expandedParents:i,toggleParent:o,closeDropdown:c},j.session.id)):null,e[16]=c,e[17]=a,e[18]=i,e[19]=x,e[20]=f,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=b.children,e[24]=u,e[25]=o,e[26]=r,e[27]=y):y=e[27];let v;return e[28]!==w||e[29]!==y?(v=n.jsxs(n.Fragment,{children:[w,y]}),e[28]=w,e[29]=y,e[30]=v):v=e[30],v}function Mt(s){const e=ne.c(57),{session:t,depth:a,variant:r,secondaryMeta:i,hasChildren:o,isExpanded:c,onToggleExpand:b,closeDropdown:u}=s,{t:l}=Ce(),x=ke(Tt),g=ke(zt),f=ye($t),p=et(t.id),w=tt(t.id),y=x===t.id;let v;e[0]!==t.title||e[1]!==l?(v=t.title?.trim()||l("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=l,e[2]=v):v=e[2];const j=v,S=!!t.parentID,C=w>0&&(!S||f),d=p?.type??"idle",_=d==="busy"||d==="retry",M=!_&&C&&!y;let h;e[3]!==t.time?.created||e[4]!==t.time?.updated?(h=t.time?.updated||t.time?.created||Date.now(),e[3]=t.time?.created,e[4]=t.time?.updated,e[5]=h):h=e[5];const m=h;let N;e[6]!==m?(N=ut(m),e[6]=m,e[7]=N):N=e[7];const P=N;let k;e[8]!==i?.projectLabel?(k=i?.projectLabel?.trim()||null,e[8]=i?.projectLabel,e[9]=k):k=e[9];const T=k;let U;e[10]!==i?.branchLabel?(U=i?.branchLabel?.trim()||null,e[10]=i?.branchLabel,e[11]=U):U=e[11];const B=U,K=B&&B!=="HEAD"?B:null;let G;e[12]!==u||e[13]!==y||e[14]!==t||e[15]!==g?(G=()=>{if(y){u();return}const D=_e(t);g(t.id,D??null),u()},e[12]=u,e[13]=y,e[14]=t,e[15]=g,e[16]=G):G=e[16];const Z=G;let Y;e[17]!==Z?(Y=D=>{if(D.target?.closest("[data-switcher-expand]")){D.preventDefault();return}Z()},e[17]=Z,e[18]=Y):Y=e[18];let ee;e[19]===Symbol.for("react.memo_cache_sentinel")?(ee=Q("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),e[19]=ee):ee=e[19];const te=8+a*12;let H;e[20]!==te?(H={paddingLeft:te},e[20]=te,e[21]=H):H=e[21];let R;e[22]!==o||e[23]!==c||e[24]!==b||e[25]!==l||e[26]!==r?(R=r==="compact"&&o?n.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:D=>{D.preventDefault(),D.stopPropagation(),b?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?n.jsx(X,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):n.jsx(X,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[22]=o,e[23]=c,e[24]=b,e[25]=l,e[26]=r,e[27]=R):R=e[27];const V=y?"text-primary":"text-foreground";let F;e[28]!==V?(F=Q("truncate text-[14px] font-normal leading-tight",V),e[28]=V,e[29]=F):F=e[29];let O;e[30]!==j||e[31]!==F?(O=n.jsx("span",{className:F,children:j}),e[30]=j,e[31]=F,e[32]=O):O=e[32];let q;e[33]!==R||e[34]!==O?(q=n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[R,O]}),e[33]=R,e[34]=O,e[35]=q):q=e[35];let $;e[36]!==K||e[37]!==o||e[38]!==c||e[39]!==b||e[40]!==T||e[41]!==l||e[42]!==P||e[43]!==r?($=r==="default"?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:[o?n.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:D=>{D.preventDefault(),D.stopPropagation(),b?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?n.jsx(X,{name:"arrow-down-s",className:"h-3 w-3"}):n.jsx(X,{name:"arrow-right-s",className:"h-3 w-3"})}):null,n.jsx("span",{className:"flex-shrink-0",children:P}),T?n.jsx("span",{className:"truncate",children:T}):null,K?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx(X,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),n.jsx("span",{className:"truncate",children:K})]}):null]}):null,e[36]=K,e[37]=o,e[38]=c,e[39]=b,e[40]=T,e[41]=l,e[42]=P,e[43]=r,e[44]=$):$=e[44];let L;e[45]!==q||e[46]!==$?(L=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[q,$]}),e[45]=q,e[46]=$,e[47]=L):L=e[47];let I;e[48]!==_||e[49]!==M||e[50]!==l?(I=_||M?n.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:_?n.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":l("sessions.sidebar.session.status.active"),title:l("sessions.sidebar.session.status.active")}):n.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":l("sessions.sidebar.session.status.unread"),title:l("sessions.sidebar.session.status.unread")})}):null,e[48]=_,e[49]=M,e[50]=l,e[51]=I):I=e[51];let z;return e[52]!==H||e[53]!==L||e[54]!==I||e[55]!==Y?(z=n.jsxs(Ie,{onClick:Y,"data-slot":"session-switcher-item",className:ee,style:H,children:[L,I]}),e[52]=H,e[53]=L,e[54]=I,e[55]=Y,e[56]=z):z=e[56],z}function $t(s){return s.notifyOnSubtasks}function zt(s){return s.setCurrentSession}function Tt(s){return s.currentSessionId}export{At as C,Vt as S,Bt as W,Qt as a,Gt as b,ut as c,Ht as d,Jt as f,Rt as g,Yt as i,Le as n,qt as r,Ut as s,Kt as t,Wt as u};
1
+ import{b as ne,R as je,j as n,r as $e,af as Ie}from"./vendor-.bun-BzW0Lgld.js";import{u as ye,aB as ze,aV as Te,aW as Fe,L as Ne,$ as Se}from"./index-Dld5wFqI.js";import{f as Ce,y as Q,aP as Oe,aq as Ee,ar as We,I as X,N as Ae,aO as Be,aN as Ue,bq as Ke,br as Ge,bn as Ye,u as He,b as Re,c as qe,d as Je,cC as Qe,e as Pe,r as _e,aH as Ve,aJ as Xe,aK as Ze,K as ke,d7 as et,dd as tt}from"./useAppFontEffects-CZdEKvZ8.js";function Wt(){const s=ne.c(5),e=ye(st);let t;s[0]===Symbol.for("react.memo_cache_sentinel")?(t=ze(),s[0]=t):t=s[0];const a=t;let r;s[1]!==e?(r=Te(e),s[1]=e,s[2]=r):r=s[2];const i=r;let o;return s[3]!==i?(o={usesFramelessChrome:a,side:i},s[3]=i,s[4]=o):o=s[4],o}function st(s){return s.desktopWindowControlsPosition}const At=s=>{const e=ne.c(129),{totalTokens:t,percentage:a,colorPercentage:r,contextLimit:i,outputLimit:o,size:c,isMobile:b,hideIcon:u,showPercentIcon:l,className:x,valueClassName:g,percentIconClassName:f,onClick:p,pressed:w}=s,y=c===void 0?"default":c,v=b===void 0?!1:b,j=u===void 0?!1:u,S=l===void 0?!1:l,C=w===void 0?!1:w,{t:d}=Ce(),[_,M]=je.useState(!1),h=typeof r=="number"?r:a;let m,N,P,k,T,U,B,K;if(e[0]!==h||e[1]!==i||e[2]!==j||e[3]!==v||e[4]!==p||e[5]!==o||e[6]!==f||e[7]!==a||e[8]!==S||e[9]!==d||e[10]!==t||e[11]!==g){const $=Ee(a)??0,L=We(h),I=L==="critical"?"var(--status-error)":L==="warn"?"var(--status-warning)":"var(--status-success)";m=nt,N=ot;const z=2*Math.PI*8.5,D=z*(1-$/100);k=typeof o=="number"?Math.max(o,0):0;let E;e[20]!==d||e[21]!==t?(E=d("contextUsage.tooltip.usedTokens",{tokens:m(t)}),e[20]=d,e[21]=t,e[22]=E):E=e[22];let W;e[23]!==i||e[24]!==d?(W=d("contextUsage.tooltip.contextLimit",{tokens:m(i)}),e[23]=i,e[24]=d,e[25]=W):W=e[25];let A;e[26]!==k||e[27]!==d?(A=d("contextUsage.tooltip.outputLimit",{tokens:m(k)}),e[26]=k,e[27]=d,e[28]=A):A=e[28];let J;e[29]!==W||e[30]!==A||e[31]!==E?(J=[E,W,A],e[29]=W,e[30]=A,e[31]=E,e[32]=J):J=e[32],K=J,P=!v&&typeof p=="function",e[33]!==j||e[34]!==v?(B=!v&&!j&&n.jsx(X,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e[33]=j,e[34]=v,e[35]=B):B=e[35],e[36]!==g?(T=Q("font-medium inline-flex items-center gap-1.5",g),e[36]=g,e[37]=T):T=e[37],U=S?n.jsxs(n.Fragment,{children:[n.jsxs("svg",{viewBox:"0 0 20 20",className:Q("h-3.5 w-3.5 -rotate-90",f),role:"progressbar","aria-valuenow":Math.round($),"aria-valuemin":0,"aria-valuemax":100,children:[n.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),n.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:I,strokeWidth:3,strokeLinecap:"round",strokeDasharray:z,strokeDashoffset:D,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),n.jsxs("span",{className:"text-foreground",children:[Math.min(a,999).toFixed(1),"%"]})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:N(h),children:Math.min(a,999).toFixed(1)}),"%"]}),e[0]=h,e[1]=i,e[2]=j,e[3]=v,e[4]=p,e[5]=o,e[6]=f,e[7]=a,e[8]=S,e[9]=d,e[10]=t,e[11]=g,e[12]=m,e[13]=N,e[14]=P,e[15]=k,e[16]=T,e[17]=U,e[18]=B,e[19]=K}else m=e[12],N=e[13],P=e[14],k=e[15],T=e[16],U=e[17],B=e[18],K=e[19];let G;e[38]!==T||e[39]!==U?(G=n.jsx("span",{className:T,children:U}),e[38]=T,e[39]=U,e[40]=G):G=e[40];let Z;e[41]!==B||e[42]!==G?(Z=n.jsxs(n.Fragment,{children:[B,G]}),e[41]=B,e[42]=G,e[43]=Z):Z=e[43];const Y=Z,ee=y==="compact"?"typography-micro":"typography-meta";let te;e[44]!==x||e[45]!==P||e[46]!==ee?(te=Q("app-region-no-drag flex items-center gap-1.5 select-none",ee,P?Q("rounded-md px-2 py-1.5 text-foreground transition-colors","hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"):"text-muted-foreground/60",x),e[44]=x,e[45]=P,e[46]=ee,e[47]=te):te=e[47];const H=te;let R;e[48]!==Y||e[49]!==P||e[50]!==v||e[51]!==p||e[52]!==C||e[53]!==H||e[54]!==d?(R=P?n.jsx("button",{type:"button",className:H,"aria-label":d("contextUsage.aria.label"),"aria-pressed":C,onClick:p,children:Y}):n.jsx("div",{className:H,"aria-label":d("contextUsage.aria.label"),onClick:v?()=>M(!0):void 0,children:Y}),e[48]=Y,e[49]=P,e[50]=v,e[51]=p,e[52]=C,e[53]=H,e[54]=d,e[55]=R):R=e[55];const V=R;if(v){let $;e[56]===Symbol.for("react.memo_cache_sentinel")?($=()=>M(!1),e[56]=$):$=e[56];let L;e[57]!==d?(L=d("contextUsage.mobile.title"),e[57]=d,e[58]=L):L=e[58];let I;e[59]!==d?(I=d("contextUsage.mobile.usedTokens"),e[59]=d,e[60]=I):I=e[60];let z;e[61]!==I?(z=n.jsx("span",{className:"typography-meta text-muted-foreground",children:I}),e[61]=I,e[62]=z):z=e[62];let D;e[63]!==m||e[64]!==t?(D=m(t),e[63]=m,e[64]=t,e[65]=D):D=e[65];let E;e[66]!==D?(E=n.jsx("span",{className:"typography-meta text-foreground font-medium",children:D}),e[66]=D,e[67]=E):E=e[67];let W;e[68]!==z||e[69]!==E?(W=n.jsxs("div",{className:"flex justify-between items-center",children:[z,E]}),e[68]=z,e[69]=E,e[70]=W):W=e[70];let A;e[71]!==d?(A=d("contextUsage.mobile.contextLimit"),e[71]=d,e[72]=A):A=e[72];let J;e[73]!==A?(J=n.jsx("span",{className:"typography-meta text-muted-foreground",children:A}),e[73]=A,e[74]=J):J=e[74];let oe;e[75]!==i||e[76]!==m?(oe=m(i),e[75]=i,e[76]=m,e[77]=oe):oe=e[77];let re;e[78]!==oe?(re=n.jsx("span",{className:"typography-meta text-foreground font-medium",children:oe}),e[78]=oe,e[79]=re):re=e[79];let ie;e[80]!==J||e[81]!==re?(ie=n.jsxs("div",{className:"flex justify-between items-center",children:[J,re]}),e[80]=J,e[81]=re,e[82]=ie):ie=e[82];let ae;e[83]!==d?(ae=d("contextUsage.mobile.outputLimit"),e[83]=d,e[84]=ae):ae=e[84];let le;e[85]!==ae?(le=n.jsx("span",{className:"typography-meta text-muted-foreground",children:ae}),e[85]=ae,e[86]=le):le=e[86];let ce;e[87]!==m||e[88]!==k?(ce=m(k),e[87]=m,e[88]=k,e[89]=ce):ce=e[89];let de;e[90]!==ce?(de=n.jsx("span",{className:"typography-meta text-foreground font-medium",children:ce}),e[90]=ce,e[91]=de):de=e[91];let ue;e[92]!==le||e[93]!==de?(ue=n.jsxs("div",{className:"flex justify-between items-center",children:[le,de]}),e[92]=le,e[93]=de,e[94]=ue):ue=e[94];let me;e[95]!==d?(me=d("contextUsage.mobile.usage"),e[95]=d,e[96]=me):me=e[96];let fe;e[97]!==me?(fe=n.jsx("span",{className:"typography-meta text-muted-foreground",children:me}),e[97]=me,e[98]=fe):fe=e[98];let pe;e[99]!==h||e[100]!==N?(pe=Q("typography-meta font-semibold",N(h)),e[99]=h,e[100]=N,e[101]=pe):pe=e[101];const De=Math.min(a,999);let he;e[102]!==De?(he=De.toFixed(1),e[102]=De,e[103]=he):he=e[103];let xe;e[104]!==pe||e[105]!==he?(xe=n.jsxs("span",{className:pe,children:[he,"%"]}),e[104]=pe,e[105]=he,e[106]=xe):xe=e[106];let ge;e[107]!==fe||e[108]!==xe?(ge=n.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[fe,xe]}),e[107]=fe,e[108]=xe,e[109]=ge):ge=e[109];let we;e[110]!==W||e[111]!==ie||e[112]!==ue||e[113]!==ge?(we=n.jsx("div",{className:"flex flex-col gap-1.5",children:n.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[W,ie,ue,ge]})}),e[110]=W,e[111]=ie,e[112]=ue,e[113]=ge,e[114]=we):we=e[114];let be;e[115]!==_||e[116]!==L||e[117]!==we?(be=n.jsx(Ae,{open:_,onClose:$,title:L,children:we}),e[115]=_,e[116]=L,e[117]=we,e[118]=be):be=e[118];let ve;return e[119]!==V||e[120]!==be?(ve=n.jsxs(n.Fragment,{children:[V,be]}),e[119]=V,e[120]=be,e[121]=ve):ve=e[121],ve}let F;e[122]!==V?(F=n.jsx(Be,{asChild:!0,children:V}),e[122]=V,e[123]=F):F=e[123];let O;e[124]!==K?(O=n.jsx(Oe,{children:n.jsx("div",{className:"space-y-0.5",children:K.map(rt)})}),e[124]=K,e[125]=O):O=e[125];let q;return e[126]!==F||e[127]!==O?(q=n.jsxs(Ue,{children:[F,O]}),e[126]=F,e[127]=O,e[128]=q):q=e[128],q};function nt(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toFixed(1).replace(/\.0$/,"")}function ot(s){return s>=90?"text-status-error":s>=75?"text-status-warning":"text-status-success"}function rt(s){return n.jsx("p",{className:"typography-micro leading-tight",children:s},s)}const Bt=je.memo(function(e){const t=ne.c(16),{visible:a,position:r}=e,i=r===void 0?"right":r,{t:o}=Ce(),[c,b]=je.useState(!1);let u,l;if(t[0]!==a?(u=()=>{if(!a)return;let y=!1;Ne("desktop_get_current_window_state").then(j=>{y||b(!!j?.maximized)}).catch(it);const v=j=>{const S=j.detail;b(!!S?.maximized)};return window.addEventListener("openchamber:window-maximized-changed",v),()=>{y=!0,window.removeEventListener("openchamber:window-maximized-changed",v)}},l=[a],t[0]=a,t[1]=u,t[2]=l):(u=t[1],l=t[2]),$e.useEffect(u,l),!a)return null;const x=i==="left";let g,f,p;if(t[3]!==x||t[4]!==c||t[5]!==i||t[6]!==o){const y=Q("app-region-no-drag inline-flex items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",x?"h-8 w-8 rounded-md":"h-12 w-11"),v=x?"app-region-no-drag mr-1 flex h-8 shrink-0 items-center":"app-region-no-drag ml-1 flex h-12 shrink-0 items-center",j=S=>S==="minimize"?n.jsx("button",{type:"button",className:y,onClick:at,title:o("header.windowControls.minimize"),"aria-label":o("header.windowControls.minimize"),children:n.jsx(X,{name:"subtract",className:"h-4 w-4"})},"minimize"):S==="maximize"?n.jsx("button",{type:"button",className:y,onClick:()=>{Ne("desktop_toggle_current_window_maximized").then(C=>b(!!C?.maximized)).catch(lt)},title:o(c?"header.windowControls.restore":"header.windowControls.maximize"),"aria-label":o(c?"header.windowControls.restore":"header.windowControls.maximize"),children:n.jsx(X,{name:c?"fullscreen-exit":"checkbox-blank",className:"h-3.5 w-3.5"})},"maximize"):n.jsx("button",{type:"button",className:Q(y,"hover:bg-status-error hover:text-status-error-foreground"),onClick:ct,title:o("header.windowControls.close"),"aria-label":o("header.windowControls.close"),children:n.jsx(X,{name:"close",className:"h-4 w-4"})},"close");g=v,t[10]!==o?(f=o("header.windowControls.groupAria"),t[10]=o,t[11]=f):f=t[11],p=Fe(i).map(j),t[3]=x,t[4]=c,t[5]=i,t[6]=o,t[7]=g,t[8]=f,t[9]=p}else g=t[7],f=t[8],p=t[9];let w;return t[12]!==g||t[13]!==f||t[14]!==p?(w=n.jsx("div",{className:g,"aria-label":f,children:p}),t[12]=g,t[13]=f,t[14]=p,t[15]=w):w=t[15],w});function it(){}function at(){Ne("desktop_minimize_current_window")}function lt(){}function ct(){Ne("desktop_close_current_window")}const Ut=(s,e,t)=>{const a=`${t}:`,r=new Set([...e].filter(i=>i.startsWith(a)));return s.size===r.size&&[...r].every(i=>s.has(i))?s:r},Kt=(s,e)=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t},se=(s,e)=>Ke(Ge.getState().dictionary,s,e),dt=s=>{const e=new Date(s),t=new Date,a=(o,c)=>o.getFullYear()===c.getFullYear()&&o.getMonth()===c.getMonth()&&o.getDate()===c.getDate(),r=new Date(t);return r.setDate(t.getDate()-1),a(e,t)?se("common.date.today"):a(e,r)?se("common.date.yesterday"):e.toLocaleDateString(Ye(),{month:"short",day:"numeric",year:"numeric"}).replace(",","")},Gt=s=>{const e=new Date,t=new Date(s);if(((r,i)=>r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate())(t,e)){const r=Date.now()-s;return r<6e4?se("common.relative.justNow"):r<36e5?se("common.relative.minutesAgoShort",{count:Math.floor(r/6e4)}):se("common.relative.hoursAgoShort",{count:Math.floor(r/36e5)})}return dt(s)},ut=s=>{const e=Math.max(0,Date.now()-s),t=6e4,a=60*t,r=24*a,i=7*r,o=30*r,c=365*r;return e<a?`${Math.max(1,Math.floor(e/t))}m`:e<r?`${Math.floor(e/a)}h`:e<i?se("common.relative.daysAgoCompact",{count:Math.floor(e/r)}):e<5*i?se("common.relative.weeksAgoCompact",{count:Math.floor(e/i)}):e<c?`${Math.floor(e/o)}mo`:se("common.relative.yearsAgoCompact",{count:Math.floor(e/c)})},mt=(s,e)=>{const t=Se(s),a=Se(e);return ft(t,a)},ft=(s,e)=>!s||!e?!1:s===e?!0:e==="/"?s.startsWith("/"):s.startsWith(`${e}/`),Le=s=>s.toLowerCase().replace(/^opencode[/-]?/i,"").replace(/[-_]/g,"").trim(),Yt=(s,e)=>s?Le(s)!==Le(e):!1,Ht=s=>{const e=new Map;return s.forEach(t=>{e.set(t.id,t)}),Array.from(e.values())},Rt=s=>`__archived__:${s}`,qt=(s,e)=>{const t=Se(s.directory??null),a=Se(s.project?.worktree??null),r=t??a;if(!r)return"unassigned";if(e&&r===e)return"project root";const o=(e&&r.startsWith(`${e}/`)?r.slice(e.length+1):r).split("/").filter(Boolean);return o[o.length-1]??"unassigned"},Jt=s=>s.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),Qt=(s,e)=>{if(!e)return s;const t=s.toLowerCase(),a=e.toLowerCase(),r=a.length;if(r===0)return s;const i=[];let o=0,c=t.indexOf(a,o);for(;c!==-1;){c>o&&i.push(s.slice(o,c));const b=s.slice(c,c+r);i.push(n.jsx("mark",{className:"bg-primary text-primary-foreground ring-1 ring-primary/90",children:b},`${c}-${b}`)),o=c+r,c=t.indexOf(a,o)}return o<s.length&&i.push(s.slice(o)),i.length>0?i:s},pt=7,ht=s=>{if(!s)return null;const e=s.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},xt=s=>{if(!s)return null;const e=s.label?.trim();if(e)return e;const t=s.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},gt=(s,e)=>{const t=ne.c(20);let a;t[0]!==e?(a=e===void 0?{}:e,t[0]=e,t[1]=a):a=t[1];const r=a,{scopeProjectId:i}=r,o=i===void 0?null:i,c=He(wt),b=Re(bt),u=qe(yt),l=Je(vt),x=Qe();let g;t[2]!==b?(g=b.map(jt).filter(Nt),t[2]=b,t[3]=g):g=t[3];const f=g;let p;t[4]!==f?(p=j=>j?f.filter(C=>mt(j,C.normalizedPath)).sort(St)[0]??null:null,t[4]=f,t[5]=p):p=t[5];const w=p;let y;{let j;if(t[7]!==c||t[8]!==x||t[9]!==w||t[10]!==u||t[11]!==o||t[12]!==l){const S=new Map;for(const h of c){const m=h.parentID;if(!m||h.time?.archived)continue;const N=S.get(m);N?N.push(h):S.set(m,[h])}S.forEach(h=>{h.sort((m,N)=>Pe(m,N,u,l))});let C;t[14]!==w||t[15]!==o?(C=h=>{if(!o)return!0;const m=_e(h);return w(m)?.id===o},t[14]=w,t[15]=o,t[16]=C):C=t[16];let d;t[17]!==u||t[18]!==l?(d=(h,m)=>Pe(h,m,u,l),t[17]=u,t[18]=l,t[19]=d):d=t[19];const _=c.filter(Ct).filter(Dt).filter(C).sort(d).slice(0,pt),M=h=>{const m=S.get(h.id)??[];return{session:h,children:m.map(N=>M(N)),worktree:null}};j=_.map(h=>{const m=_e(h),N=w(m),P=xt(N),k=m?x.get(m)??null:null;return{node:M(h),projectId:N?.id??null,groupDirectory:m,secondaryMeta:{projectLabel:P,branchLabel:k&&k!==P?k:null}}}),t[7]=c,t[8]=x,t[9]=w,t[10]=u,t[11]=o,t[12]=l,t[13]=j}else j=t[13];y=j}return y};function wt(s){return s.activeSessions}function bt(s){return s.projects}function yt(s){return s.ids}function vt(s){return s.rankById}function jt(s){return{...s,normalizedPath:ht(s.path)}}function Nt(s){return s.normalizedPath}function St(s,e){return(e.normalizedPath?.length??0)-(s.normalizedPath?.length??0)}function Ct(s){return!s.time?.archived}function Dt(s){return!s.parentID}function Vt(s){const e=ne.c(18),{children:t,variant:a,scopeProjectId:r,align:i}=s,o=a===void 0?"default":a,c=r===void 0?null:r,b=i===void 0?"start":i,u=ye(kt),l=ye(_t);let x;e[0]!==t?(x=n.jsx(Ve,{asChild:!0,children:t}),e[0]=t,e[1]=x):x=e[1];const g=o==="compact"?"w-[280px]":"w-[360px]";let f;e[2]!==g?(f=Q("overflow-hidden p-1 max-w-[calc(100vw-32px)]",g),e[2]=g,e[3]=f):f=e[3];let p;e[4]!==u||e[5]!==c||e[6]!==l||e[7]!==o?(p=u?n.jsx(Pt,{onSelect:()=>l(!1),variant:o,scopeProjectId:c}):null,e[4]=u,e[5]=c,e[6]=l,e[7]=o,e[8]=p):p=e[8];let w;e[9]!==b||e[10]!==f||e[11]!==p?(w=n.jsx(Xe,{align:b,sideOffset:6,className:f,children:p}),e[9]=b,e[10]=f,e[11]=p,e[12]=w):w=e[12];let y;return e[13]!==u||e[14]!==l||e[15]!==x||e[16]!==w?(y=n.jsxs(Ze,{open:u,onOpenChange:l,modal:!1,children:[x,w]}),e[13]=u,e[14]=l,e[15]=x,e[16]=w,e[17]=y):y=e[17],y}function _t(s){return s.setSessionDropdownOpen}function kt(s){return s.isSessionDropdownOpen}function Pt(s){const e=ne.c(26),{onSelect:t,variant:a,scopeProjectId:r}=s;let i;e[0]!==r?(i={scopeProjectId:r},e[0]=r,e[1]=i):i=e[1];const o=gt(!0,i),c=ke(It),b=ye(Lt),{t:u}=Ce();let l;e[2]!==t||e[3]!==c||e[4]!==b?(l=()=>{b("chat"),t(),c()},e[2]=t,e[3]=c,e[4]=b,e[5]=l):l=e[5];const x=l;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=new Set,e[6]=g):g=e[6];const[f,p]=je.useState(g);let w;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=h=>{p(m=>{const N=new Set(m);return N.has(h)?N.delete(h):N.add(h),N})},e[7]=w):w=e[7];const y=w;let v,j;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=Q("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),j=n.jsx(X,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e[8]=v,e[9]=j):(v=e[8],j=e[9]);let S;e[10]!==u?(S=u("sessions.sidebar.header.actions.newSession"),e[10]=u,e[11]=S):S=e[11];let C;e[12]!==S?(C=n.jsx("span",{className:"truncate text-[14px] font-normal leading-tight text-foreground",children:S}),e[12]=S,e[13]=C):C=e[13];let d;e[14]!==x||e[15]!==C?(d=n.jsxs(Ie,{onClick:x,className:v,children:[j,C]}),e[14]=x,e[15]=C,e[16]=d):d=e[16];let _;e[17]!==f||e[18]!==o||e[19]!==t||e[20]!==u||e[21]!==a?(_=o.length===0?n.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:u("sessions.switcher.empty")}):o.map(h=>n.jsx(Me,{item:h,depth:0,variant:a,expandedParents:f,toggleParent:y,closeDropdown:t},h.node.session.id)),e[17]=f,e[18]=o,e[19]=t,e[20]=u,e[21]=a,e[22]=_):_=e[22];let M;return e[23]!==_||e[24]!==d?(M=n.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:n.jsxs("div",{className:"space-y-0.5",children:[d,_]})}),e[23]=_,e[24]=d,e[25]=M):M=e[25],M}function Lt(s){return s.setActiveMainTab}function It(s){return s.openNewSessionDraft}function Me(s){const e=ne.c(31),{item:t,depth:a,variant:r,expandedParents:i,toggleParent:o,closeDropdown:c}=s,{node:b,secondaryMeta:u}=t,l=b.session,x=b.children.length>0;let g;e[0]!==i||e[1]!==l.id?(g=i.has(l.id),e[0]=i,e[1]=l.id,e[2]=g):g=e[2];const f=g;let p;e[3]!==x||e[4]!==l.id||e[5]!==o?(p=x?()=>o(l.id):void 0,e[3]=x,e[4]=l.id,e[5]=o,e[6]=p):p=e[6];let w;e[7]!==c||e[8]!==a||e[9]!==x||e[10]!==f||e[11]!==u||e[12]!==l||e[13]!==p||e[14]!==r?(w=n.jsx(Mt,{session:l,depth:a,variant:r,secondaryMeta:u,hasChildren:x,isExpanded:f,onToggleExpand:p,closeDropdown:c}),e[7]=c,e[8]=a,e[9]=x,e[10]=f,e[11]=u,e[12]=l,e[13]=p,e[14]=r,e[15]=w):w=e[15];let y;e[16]!==c||e[17]!==a||e[18]!==i||e[19]!==x||e[20]!==f||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==b.children||e[24]!==u||e[25]!==o||e[26]!==r?(y=x&&f?b.children.map(j=>n.jsx(Me,{item:{node:j,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:u},depth:a+1,variant:r,expandedParents:i,toggleParent:o,closeDropdown:c},j.session.id)):null,e[16]=c,e[17]=a,e[18]=i,e[19]=x,e[20]=f,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=b.children,e[24]=u,e[25]=o,e[26]=r,e[27]=y):y=e[27];let v;return e[28]!==w||e[29]!==y?(v=n.jsxs(n.Fragment,{children:[w,y]}),e[28]=w,e[29]=y,e[30]=v):v=e[30],v}function Mt(s){const e=ne.c(57),{session:t,depth:a,variant:r,secondaryMeta:i,hasChildren:o,isExpanded:c,onToggleExpand:b,closeDropdown:u}=s,{t:l}=Ce(),x=ke(Tt),g=ke(zt),f=ye($t),p=et(t.id),w=tt(t.id),y=x===t.id;let v;e[0]!==t.title||e[1]!==l?(v=t.title?.trim()||l("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=l,e[2]=v):v=e[2];const j=v,S=!!t.parentID,C=w>0&&(!S||f),d=p?.type??"idle",_=d==="busy"||d==="retry",M=!_&&C&&!y;let h;e[3]!==t.time?.created||e[4]!==t.time?.updated?(h=t.time?.updated||t.time?.created||Date.now(),e[3]=t.time?.created,e[4]=t.time?.updated,e[5]=h):h=e[5];const m=h;let N;e[6]!==m?(N=ut(m),e[6]=m,e[7]=N):N=e[7];const P=N;let k;e[8]!==i?.projectLabel?(k=i?.projectLabel?.trim()||null,e[8]=i?.projectLabel,e[9]=k):k=e[9];const T=k;let U;e[10]!==i?.branchLabel?(U=i?.branchLabel?.trim()||null,e[10]=i?.branchLabel,e[11]=U):U=e[11];const B=U,K=B&&B!=="HEAD"?B:null;let G;e[12]!==u||e[13]!==y||e[14]!==t||e[15]!==g?(G=()=>{if(y){u();return}const D=_e(t);g(t.id,D??null),u()},e[12]=u,e[13]=y,e[14]=t,e[15]=g,e[16]=G):G=e[16];const Z=G;let Y;e[17]!==Z?(Y=D=>{if(D.target?.closest("[data-switcher-expand]")){D.preventDefault();return}Z()},e[17]=Z,e[18]=Y):Y=e[18];let ee;e[19]===Symbol.for("react.memo_cache_sentinel")?(ee=Q("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),e[19]=ee):ee=e[19];const te=8+a*12;let H;e[20]!==te?(H={paddingLeft:te},e[20]=te,e[21]=H):H=e[21];let R;e[22]!==o||e[23]!==c||e[24]!==b||e[25]!==l||e[26]!==r?(R=r==="compact"&&o?n.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:D=>{D.preventDefault(),D.stopPropagation(),b?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?n.jsx(X,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):n.jsx(X,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[22]=o,e[23]=c,e[24]=b,e[25]=l,e[26]=r,e[27]=R):R=e[27];const V=y?"text-primary":"text-foreground";let F;e[28]!==V?(F=Q("truncate text-[14px] font-normal leading-tight",V),e[28]=V,e[29]=F):F=e[29];let O;e[30]!==j||e[31]!==F?(O=n.jsx("span",{className:F,children:j}),e[30]=j,e[31]=F,e[32]=O):O=e[32];let q;e[33]!==R||e[34]!==O?(q=n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[R,O]}),e[33]=R,e[34]=O,e[35]=q):q=e[35];let $;e[36]!==K||e[37]!==o||e[38]!==c||e[39]!==b||e[40]!==T||e[41]!==l||e[42]!==P||e[43]!==r?($=r==="default"?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:[o?n.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:D=>{D.preventDefault(),D.stopPropagation(),b?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?n.jsx(X,{name:"arrow-down-s",className:"h-3 w-3"}):n.jsx(X,{name:"arrow-right-s",className:"h-3 w-3"})}):null,n.jsx("span",{className:"flex-shrink-0",children:P}),T?n.jsx("span",{className:"truncate",children:T}):null,K?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx(X,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),n.jsx("span",{className:"truncate",children:K})]}):null]}):null,e[36]=K,e[37]=o,e[38]=c,e[39]=b,e[40]=T,e[41]=l,e[42]=P,e[43]=r,e[44]=$):$=e[44];let L;e[45]!==q||e[46]!==$?(L=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[q,$]}),e[45]=q,e[46]=$,e[47]=L):L=e[47];let I;e[48]!==_||e[49]!==M||e[50]!==l?(I=_||M?n.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:_?n.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":l("sessions.sidebar.session.status.active"),title:l("sessions.sidebar.session.status.active")}):n.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":l("sessions.sidebar.session.status.unread"),title:l("sessions.sidebar.session.status.unread")})}):null,e[48]=_,e[49]=M,e[50]=l,e[51]=I):I=e[51];let z;return e[52]!==H||e[53]!==L||e[54]!==I||e[55]!==Y?(z=n.jsxs(Ie,{onClick:Y,"data-slot":"session-switcher-item",className:ee,style:H,children:[L,I]}),e[52]=H,e[53]=L,e[54]=I,e[55]=Y,e[56]=z):z=e[56],z}function $t(s){return s.notifyOnSubtasks}function zt(s){return s.setCurrentSession}function Tt(s){return s.currentSessionId}export{At as C,Vt as S,Bt as W,Qt as a,Gt as b,ut as c,Ht as d,Jt as f,Rt as g,Yt as i,Le as n,qt as r,Ut as s,Kt as t,Wt as u};
@@ -1 +1 @@
1
- import{b as x,R as h,j as t,bq as w,bo as j,bp as k,bm as v,bk as D}from"./vendor-.bun-DvcSrJLa.js";import{f as R,y as u}from"./useAppFontEffects-DrLhDSC3.js";import{k as S}from"./runtimeEndpointReset-B0yQKPe0.js";import"./index-DMCrPMIW.js";import"./mobileLayoutPreference-Dio-WWkI.js";const z=b=>{const e=x.c(19),{open:m,onOpenChange:n}=b,{t:f}=R(),s=h.useId(),y=_;let a;e[0]!==n?(a=g=>{!g&&y()||n(g)},e[0]=n,e[1]=a):a=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(w,{className:u("fixed inset-0 z-50 bg-black/50 dark:bg-black/75","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),e[2]=d):d=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=u("relative pointer-events-auto","w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]","rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]","data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]"),e[3]=c):c=e[3];let o;e[4]!==f?(o=f("settings.window.description"),e[4]=f,e[5]=o):o=e[5];let i;e[6]!==s||e[7]!==o?(i=t.jsx(j,{id:s,className:"sr-only",children:o}),e[6]=s,e[7]=o,e[8]=i):i=e[8];let l;e[9]!==n?(l=t.jsx(S,{onClose:()=>n(!1),isWindowed:!0}),e[9]=n,e[10]=l):l=e[10];let r;e[11]!==s||e[12]!==i||e[13]!==l?(r=t.jsxs(k,{children:[d,t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:t.jsxs(v,{"aria-describedby":s,className:c,children:[i,l]})})]}),e[11]=s,e[12]=i,e[13]=l,e[14]=r):r=e[14];let p;return e[15]!==m||e[16]!==a||e[17]!==r?(p=t.jsx(D,{open:m,onOpenChange:a,children:r}),e[15]=m,e[16]=a,e[17]=r,e[18]=p):p=e[18],p};function _(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{z as SettingsWindow};
1
+ import{b as x,R as h,j as t,bq as w,bo as j,bp as k,bm as v,bk as D}from"./vendor-.bun-BzW0Lgld.js";import{f as R,y as u}from"./useAppFontEffects-CZdEKvZ8.js";import{k as S}from"./runtimeEndpointReset-fpfBYOyW.js";import"./index-Dld5wFqI.js";import"./mobileLayoutPreference-Dio-WWkI.js";const z=b=>{const e=x.c(19),{open:m,onOpenChange:n}=b,{t:f}=R(),s=h.useId(),y=_;let a;e[0]!==n?(a=g=>{!g&&y()||n(g)},e[0]=n,e[1]=a):a=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(w,{className:u("fixed inset-0 z-50 bg-black/50 dark:bg-black/75","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),e[2]=d):d=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=u("relative pointer-events-auto","w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]","rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]","data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]"),e[3]=c):c=e[3];let o;e[4]!==f?(o=f("settings.window.description"),e[4]=f,e[5]=o):o=e[5];let i;e[6]!==s||e[7]!==o?(i=t.jsx(j,{id:s,className:"sr-only",children:o}),e[6]=s,e[7]=o,e[8]=i):i=e[8];let l;e[9]!==n?(l=t.jsx(S,{onClose:()=>n(!1),isWindowed:!0}),e[9]=n,e[10]=l):l=e[10];let r;e[11]!==s||e[12]!==i||e[13]!==l?(r=t.jsxs(k,{children:[d,t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:t.jsxs(v,{"aria-describedby":s,className:c,children:[i,l]})})]}),e[11]=s,e[12]=i,e[13]=l,e[14]=r):r=e[14];let p;return e[15]!==m||e[16]!==a||e[17]!==r?(p=t.jsx(D,{open:m,onOpenChange:a,children:r}),e[15]=m,e[16]=a,e[17]=r,e[18]=p):p=e[18],p};function _(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{z as SettingsWindow};