@openchamber/web 1.16.0 → 1.16.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 (54) hide show
  1. package/README.md +5 -5
  2. package/dist/assets/{DiagramView-he_RFVx5.js → DiagramView-Elkp8b4l.js} +1 -1
  3. package/dist/assets/{MarkdownRendererImpl-CdBIHSPZ.js → MarkdownRendererImpl-DLhrL6oX.js} +4 -4
  4. package/dist/assets/{MultiRunWindow-B_C-tvVq.js → MultiRunWindow-DVpNCqnE.js} +1 -1
  5. package/dist/assets/{OnboardingScreen-BBnTt-9w.js → OnboardingScreen-CpcR0gyq.js} +1 -1
  6. package/dist/assets/SessionSwitcherDropdown-DHO5Je6v.js +1 -0
  7. package/dist/assets/{SettingsWindow-CjqLdpTE.js → SettingsWindow-Bewo7vwh.js} +1 -1
  8. package/dist/assets/{TerminalView-DQcdegHp.js → TerminalView-D9C7fNLm.js} +1 -1
  9. package/dist/assets/es-D9nOo8Wx.js +15 -0
  10. package/dist/assets/fr-DEF71lgt.js +13 -0
  11. package/dist/assets/index-BklNmnVr.js +2 -0
  12. package/dist/assets/index-C3uMIExE.css +1 -0
  13. package/dist/assets/ja-CpNfaEje.js +15 -0
  14. package/dist/assets/ko-DLS_rnE-.js +15 -0
  15. package/dist/assets/main-B0CxEOP5.js +237 -0
  16. package/dist/assets/{main-Dfm-VKZ9.js → main-Ck3ZNw8-.js} +2 -2
  17. package/dist/assets/miniChat-BAJj2Ome.js +2 -0
  18. package/dist/assets/mobile-CJoX4Cdj.js +2 -0
  19. package/dist/assets/pl-BjtFn5-n.js +15 -0
  20. package/dist/assets/pt-BR-C0_4Rnzn.js +15 -0
  21. package/dist/assets/renderElectronMiniChatApp-D4-OXCXM.js +2 -0
  22. package/dist/assets/{renderMobileApp-o7Fs9EBx.js → renderMobileApp-DHWdI195.js} +3 -3
  23. package/dist/assets/runtimeEndpointReset-B0P2DED1.js +167 -0
  24. package/dist/assets/uk-BDu4E0s0.js +15 -0
  25. package/dist/assets/{useAppFontEffects-DkPuAMXD.js → useAppFontEffects-9LFMCKYW.js} +127 -127
  26. package/dist/assets/zh-CN-BcwMqxIR.js +15 -0
  27. package/dist/assets/zh-TW-bNDQjKEu.js +15 -0
  28. package/dist/index.html +3 -3
  29. package/dist/mini-chat.html +3 -3
  30. package/dist/mobile.html +3 -3
  31. package/package.json +1 -1
  32. package/server/lib/opencode/settings-helpers.js +9 -0
  33. package/server/lib/package-manager.js +1 -1
  34. package/server/lib/small-model/DOCUMENTATION.md +3 -1
  35. package/server/lib/small-model/call.js +45 -8
  36. package/server/lib/small-model/call.test.js +338 -0
  37. package/server/lib/small-model/index.js +1 -0
  38. package/dist/assets/SessionSwitcherDropdown-CWWrCFzr.js +0 -1
  39. package/dist/assets/es-r0_jT91q.js +0 -15
  40. package/dist/assets/fr-Bo8rtAJ1.js +0 -13
  41. package/dist/assets/index-8J6waVO6.js +0 -2
  42. package/dist/assets/index-DEMqM4Lz.css +0 -1
  43. package/dist/assets/ja-BPWtkG-c.js +0 -15
  44. package/dist/assets/ko-Bv0k-0E3.js +0 -15
  45. package/dist/assets/main-B-GA5Tg5.js +0 -237
  46. package/dist/assets/miniChat-CfmCFFfu.js +0 -2
  47. package/dist/assets/mobile-CXJqeDlm.js +0 -2
  48. package/dist/assets/pl-CiTP50bz.js +0 -15
  49. package/dist/assets/pt-BR-DadIjX5L.js +0 -15
  50. package/dist/assets/renderElectronMiniChatApp-DS7Dy2ii.js +0 -2
  51. package/dist/assets/runtimeEndpointReset-MTaPPm4F.js +0 -167
  52. package/dist/assets/uk-2RpsWGoZ.js +0 -15
  53. package/dist/assets/zh-CN-BwKWaTuz.js +0 -15
  54. package/dist/assets/zh-TW--f_BqBpD.js +0 -15
package/README.md CHANGED
@@ -1,17 +1,17 @@
1
- # <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.com/btriapitsyn/openchamber/raw/HEAD/docs/references/badges/openchamber-logo-dark.svg"><img src="https://github.com/btriapitsyn/openchamber/raw/HEAD/docs/references/badges/openchamber-logo-light.svg" width="32" height="32" align="absmiddle" /></picture> @openchamber/web
1
+ # <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.com/openchamber/openchamber/raw/HEAD/docs/references/badges/openchamber-logo-dark.svg"><img src="https://github.com/openchamber/openchamber/raw/HEAD/docs/references/badges/openchamber-logo-light.svg" width="32" height="32" align="absmiddle" /></picture> @openchamber/web
2
2
 
3
- [![GitHub stars](https://img.shields.io/github/stars/btriapitsyn/openchamber?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgZmlsbD0iI2YxZWNlYyIgdmlld0JveD0iMCAwIDI1NiAyNTYiPjxwYXRoIGQ9Ik0yMjkuMDYsMTA4Ljc5bC00OC43LDQyLDE0Ljg4LDYyLjc5YTguNCw4LjQsMCwwLDEtMTIuNTIsOS4xN0wxMjgsMTg5LjA5LDczLjI4LDIyMi43NGE4LjQsOC40LDAsMCwxLTEyLjUyLTkuMTdsMTQuODgtNjIuNzktNDguNy00MkE4LjQ2LDguNDYsMCwwLDEsMzEuNzMsOTRMOTUuNjQsODguOGwyNC42Mi01OS42YTguMzYsOC4zNiwwLDAsMSwxNS40OCwwbDI0LjYyLDU5LjZMMjI0LjI3LDk0QTguNDYsOC40NiwwLDAsMSwyMjkuMDYsMTA4Ljc5WiIgb3BhY2l0eT0iMC4yIj48L3BhdGg%2BPHBhdGggZD0iTTIzOS4xOCw5Ny4yNkExNi4zOCwxNi4zOCwwLDAsMCwyMjQuOTIsODZsLTU5LTQuNzZMMTQzLjE0LDI2LjE1YTE2LjM2LDE2LjM2LDAsMCwwLTMwLjI3LDBMOTAuMTEsODEuMjMsMzEuMDgsODZhMTYuNDYsMTYuNDYsMCwwLDAtOS4zNywyOC44Nmw0NSwzOC44M0w1MywyMTEuNzVhMTYuMzgsMTYuMzgsMCwwLDAsMjQuNSwxNy44MkwxMjgsMTk4LjQ5bDUwLjUzLDMxLjA4QTE2LjQsMTYuNCwwLDAsMCwyMDMsMjExLjc1bC0xMy43Ni01OC4wNyw0NS0zOC44M0ExNi40MywxNi40MywwLDAsMCwyMzkuMTgsOTcuMjZabS0xNS4zNCw1LjQ3LTQ4LjcsNDJhOCw4LDAsMCwwLTIuNTYsNy45MWwxNC44OCw2Mi44YS4zNy4zNywwLDAsMS0uMTcuNDhjLS4xOC4xNC0uMjMuMTEtLjM4LDBsLTU0LjcyLTMzLjY1YTgsOCwwLDAsMC04LjM4LDBMNjkuMDksMjE1Ljk0Yy0uMTUuMDktLjE5LjEyLS4zOCwwYS4zNy4zNywwLDAsMS0uMTctLjQ4bDE0Ljg4LTYyLjhhOCw4LDAsMCwwLTIuNTYtNy45MWwtNDguNy00MmMtLjEyLS4xLS4yMy0uMTktLjEzLS41cy4xOC0uMjcuMzMtLjI5bDYzLjkyLTUuMTZBOCw4LDAsMCwwLDEwMyw5MS44NmwyNC42Mi01OS42MWMuMDgtLjE3LjExLS4yNS4zNS0uMjVzLjI3LjA4LjM1LjI1TDE1Myw5MS44NmE4LDgsMCwwLDAsNi43NSw0LjkybDYzLjkyLDUuMTZjLjE1LDAsLjI0LDAsLjMzLjI5UzIyNCwxMDIuNjMsMjIzLjg0LDEwMi43M1oiPjwvcGF0aD48L3N2Zz4%3D&logoColor=FFFCF0&labelColor=100F0F&color=66800B)](https://github.com/btriapitsyn/openchamber/stargazers)
4
- [![GitHub release](https://img.shields.io/github/v/release/btriapitsyn/openchamber?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgZmlsbD0iI2YxZWNlYyIgdmlld0JveD0iMCAwIDI1NiAyNTYiPjxwYXRoIGQ9Ik0xMjgsMTI5LjA5VjIzMmE4LDgsMCwwLDEtMy44NC0xbC04OC00OC4xOGE4LDgsMCwwLDEtNC4xNi03VjgwLjE4YTgsOCwwLDAsMSwuNy0zLjI1WiIgb3BhY2l0eT0iMC4yIj48L3BhdGg%2BPHBhdGggZD0iTTIyMy42OCw2Ni4xNSwxMzUuNjgsMThhMTUuODgsMTUuODgsMCwwLDAtMTUuMzYsMGwtODgsNDguMTdhMTYsMTYsMCwwLDAtOC4zMiwxNHY5NS42NGExNiwxNiwwLDAsMCw4LjMyLDE0bDg4LDQ4LjE3YTE1Ljg4LDE1Ljg4LDAsMCwwLDE1LjM2LDBsODgtNDguMTdhMTYsMTYsMCwwLDAsOC4zMi0xNFY4MC4xOEExNiwxNiwwLDAsMCwyMjMuNjgsNjYuMTVaTTEyOCwzMmw4MC4zNCw0NC0yOS43NywxNi4zLTgwLjM1LTQ0Wk0xMjgsMTIwLDQ3LjY2LDc2bDMzLjktMTguNTYsODAuMzQsNDRaTTQwLDkwbDgwLDQzLjc4djg1Ljc5TDQwLDE3NS44MlptMTc2LDg1Ljc4aDBsLTgwLDQzLjc5VjEzMy44MmwzMi0xNy41MVYxNTJhOCw4LDAsMCwwLDE2LDBWMTA3LjU1TDIxNiw5MHY4NS43N1oiPjwvcGF0aD48L3N2Zz4%3D&logoColor=FFFCF0&labelColor=100F0F&color=205EA6)](https://github.com/btriapitsyn/openchamber/releases/latest)
3
+ [![GitHub stars](https://img.shields.io/github/stars/openchamber/openchamber?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgZmlsbD0iI2YxZWNlYyIgdmlld0JveD0iMCAwIDI1NiAyNTYiPjxwYXRoIGQ9Ik0yMjkuMDYsMTA4Ljc5bC00OC43LDQyLDE0Ljg4LDYyLjc5YTguNCw4LjQsMCwwLDEtMTIuNTIsOS4xN0wxMjgsMTg5LjA5LDczLjI4LDIyMi43NGE4LjQsOC40LDAsMCwxLTEyLjUyLTkuMTdsMTQuODgtNjIuNzktNDguNy00MkE4LjQ2LDguNDYsMCwwLDEsMzEuNzMsOTRMOTUuNjQsODguOGwyNC42Mi01OS42YTguMzYsOC4zNiwwLDAsMSwxNS40OCwwbDI0LjYyLDU5LjZMMjI0LjI3LDk0QTguNDYsOC40NiwwLDAsMSwyMjkuMDYsMTA4Ljc5WiIgb3BhY2l0eT0iMC4yIj48L3BhdGg%2BPHBhdGggZD0iTTIzOS4xOCw5Ny4yNkExNi4zOCwxNi4zOCwwLDAsMCwyMjQuOTIsODZsLTU5LTQuNzZMMTQzLjE0LDI2LjE1YTE2LjM2LDE2LjM2LDAsMCwwLTMwLjI3LDBMOTAuMTEsODEuMjMsMzEuMDgsODZhMTYuNDYsMTYuNDYsMCwwLDAtOS4zNywyOC44Nmw0NSwzOC44M0w1MywyMTEuNzVhMTYuMzgsMTYuMzgsMCwwLDAsMjQuNSwxNy44MkwxMjgsMTk4LjQ5bDUwLjUzLDMxLjA4QTE2LjQsMTYuNCwwLDAsMCwyMDMsMjExLjc1bC0xMy43Ni01OC4wNyw0NS0zOC44M0ExNi40MywxNi40MywwLDAsMCwyMzkuMTgsOTcuMjZabS0xNS4zNCw1LjQ3LTQ4LjcsNDJhOCw4LDAsMCwwLTIuNTYsNy45MWwxNC44OCw2Mi44YS4zNy4zNywwLDAsMS0uMTcuNDhjLS4xOC4xNC0uMjMuMTEtLjM4LDBsLTU0LjcyLTMzLjY1YTgsOCwwLDAsMC04LjM4LDBMNjkuMDksMjE1Ljk0Yy0uMTUuMDktLjE5LjEyLS4zOCwwYS4zNy4zNywwLDAsMS0uMTctLjQ4bDE0Ljg4LTYyLjhhOCw4LDAsMCwwLTIuNTYtNy45MWwtNDguNy00MmMtLjEyLS4xLS4yMy0uMTktLjEzLS41cy4xOC0uMjcuMzMtLjI5bDYzLjkyLTUuMTZBOCw4LDAsMCwwLDEwMyw5MS44NmwyNC42Mi01OS42MWMuMDgtLjE3LjExLS4yNS4zNS0uMjVzLjI3LjA4LjM1LjI1TDE1Myw5MS44NmE4LDgsMCwwLDAsNi43NSw0LjkybDYzLjkyLDUuMTZjLjE1LDAsLjI0LDAsLjMzLjI5UzIyNCwxMDIuNjMsMjIzLjg0LDEwMi43M1oiPjwvcGF0aD48L3N2Zz4%3D&logoColor=FFFCF0&labelColor=100F0F&color=66800B)](https://github.com/openchamber/openchamber/stargazers)
4
+ [![GitHub release](https://img.shields.io/github/v/release/openchamber/openchamber?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgZmlsbD0iI2YxZWNlYyIgdmlld0JveD0iMCAwIDI1NiAyNTYiPjxwYXRoIGQ9Ik0xMjgsMTI5LjA5VjIzMmE4LDgsMCwwLDEtMy44NC0xbC04OC00OC4xOGE4LDgsMCwwLDEtNC4xNi03VjgwLjE4YTgsOCwwLDAsMSwuNy0zLjI1WiIgb3BhY2l0eT0iMC4yIj48L3BhdGg%2BPHBhdGggZD0iTTIyMy42OCw2Ni4xNSwxMzUuNjgsMThhMTUuODgsMTUuODgsMCwwLDAtMTUuMzYsMGwtODgsNDguMTdhMTYsMTYsMCwwLDAtOC4zMiwxNHY5NS42NGExNiwxNiwwLDAsMCw4LjMyLDE0bDg4LDQ4LjE3YTE1Ljg4LDE1Ljg4LDAsMCwwLDE1LjM2LDBsODgtNDguMTdhMTYsMTYsMCwwLDAsOC4zMi0xNFY4MC4xOEExNiwxNiwwLDAsMCwyMjMuNjgsNjYuMTVaTTEyOCwzMmw4MC4zNCw0NC0yOS43NywxNi4zLTgwLjM1LTQ0Wk0xMjgsMTIwLDQ3LjY2LDc2bDMzLjktMTguNTYsODAuMzQsNDRaTTQwLDkwbDgwLDQzLjc4djg1Ljc5TDQwLDE3NS44MlptMTc2LDg1Ljc4aDBsLTgwLDQzLjc5VjEzMy44MmwzMi0xNy41MVYxNTJhOCw4LDAsMCwwLDE2LDBWMTA3LjU1TDIxNiw5MHY4NS43N1oiPjwvcGF0aD48L3N2Zz4%3D&logoColor=FFFCF0&labelColor=100F0F&color=205EA6)](https://github.com/openchamber/openchamber/releases/latest)
5
5
  [![Discord](https://img.shields.io/badge/Discord-join.svg?style=flat&labelColor=100F0F&color=8B7EC8&logo=discord&logoColor=FFFCF0)](https://discord.gg/ZYRSdnwwKA)
6
6
 
7
7
  Run [OpenCode](https://opencode.ai) in your browser. Install the CLI, open `localhost:3000`, done. Works on desktop browsers, tablets, and phones as a PWA.
8
8
 
9
- Full project overview, screenshots, and all features: [github.com/btriapitsyn/openchamber](https://github.com/btriapitsyn/openchamber)
9
+ Full project overview, screenshots, and all features: [github.com/openchamber/openchamber](https://github.com/openchamber/openchamber)
10
10
 
11
11
  ## Install
12
12
 
13
13
  ```bash
14
- curl -fsSL https://raw.githubusercontent.com/btriapitsyn/openchamber/main/scripts/install.sh | bash
14
+ curl -fsSL https://raw.githubusercontent.com/openchamber/openchamber/main/scripts/install.sh | bash
15
15
  ```
16
16
 
17
17
  Or install manually: `bun add -g @openchamber/web` (or npm, pnpm, yarn).
@@ -1 +1 @@
1
- import{R as s,j as e}from"./vendor-.bun-BE757pvp.js";import{u as c}from"./index-8J6waVO6.js";import{c as j,d as b,I as a}from"./useAppFontEffects-DkPuAMXD.js";import{D as y}from"./main-B-GA5Tg5.js";import"./runtimeEndpointReset-MTaPPm4F.js";import"./mobileLayoutPreference-Dio-WWkI.js";import"./SessionSwitcherDropdown-CWWrCFzr.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-BE757pvp.js";import{u as c}from"./index-BklNmnVr.js";import{c as j,d as b,I as a}from"./useAppFontEffects-9LFMCKYW.js";import{D as y}from"./main-B0CxEOP5.js";import"./runtimeEndpointReset-B0P2DED1.js";import"./mobileLayoutPreference-Dio-WWkI.js";import"./SessionSwitcherDropdown-DHO5Je6v.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,11 +1,11 @@
1
- import{cf as Ke,cg as je,ch as de,ci as At,R as N,b as K,cj as Et,ck as kt,cl as vt,j as re}from"./vendor-.bun-BE757pvp.js";import{eY as Ct,eZ as St,e_ as Lt,e$ as Mt,f0 as Ue,f1 as Nt,f2 as xt,y as pe,d2 as Rt,d3 as Tt,f3 as _t,f4 as It,d as Ze,e as Xe,f5 as Ge,v as Ye,dI as Pt,A as Ce,c as Ft,f6 as $t,f7 as Ot,f8 as Dt,o as Wt,f9 as Se,fa as qt,fb as Bt,ca as zt}from"./useAppFontEffects-DkPuAMXD.js";import{E as Ae,u as Y,v as Ht,w as Vt,h as Kt}from"./index-8J6waVO6.js";const ee=t=>t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),jt=t=>/^\[[^\]]+\]:\s+\S+/m.test(t)||/^\[\^[^\]]+\]:\s+/m.test(t),Ut=t=>{const e=t.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!e)return!1;const n=e[1];if(!n)return!1;const r=n[0],a=n.length,o=t.trimEnd().split(`
2
- `).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${r}{${a},}[\\t ]*$`).test(o)},te=t=>{try{return At(t,{linkMode:"text-only"})}catch{return t}},Zt=(t,e)=>{if(!e)return[{raw:t,src:t,mode:"full",highlight:!0}];if(jt(t))return[{raw:t,src:te(t),mode:"live",highlight:!0}];let n;try{n=Ke.lexer(t)}catch{return[{raw:t,src:te(t),mode:"live",highlight:!0}]}let r=-1;for(let o=n.length-1;o>=0;o-=1)if(n[o]?.type!=="space"){r=o;break}if(r<0)return[{raw:t,src:te(t),mode:"live",highlight:!0}];const a=[];for(let o=0;o<n.length;o+=1){const i=n[o];if(!i||i.type==="space")continue;const s=i.raw??"",c=o===r,l=i.type==="code"&&Ut(s);a.push({raw:s,src:l?s:te(s),mode:c?"live":"full",highlight:!l})}return a.length===0?[{raw:t,src:te(t),mode:"live",highlight:!0}]:a},Je=(t,e,n)=>{try{return je.renderToString(t,{displayMode:n,throwOnError:!1})}catch{return e}},Xt={name:"inlineMath",level:"inline",start(t){const e=t.indexOf("\\(");return e<0?void 0:e},tokenizer(t){const e=/^\\\(([\s\S]+?)\\\)/.exec(t);if(e)return{type:"inlineMath",raw:e[0],text:e[1]??""}},renderer(t){const e=t;return Je(e.text,e.raw,!1)}},Gt={name:"blockMath",level:"block",start(t){const e=t.indexOf("\\[");return e<0?void 0:e},tokenizer(t){const e=/^\\\[([\s\S]+?)\\\]/.exec(t);if(e)return{type:"blockMath",raw:e[0],text:e[1]??""}},renderer(t){const e=t;return Je(e.text,e.raw,!0)}},Qe=Ke.use({gfm:!0,breaks:!1,extensions:[Xt,Gt],renderer:{link({href:t,title:e,text:n}){const r=t??"",a=Ct(r);if(a)return`<a href="${ee(Lt(a))}" data-openchamber-agent-mention="true" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">${n}</a>`;const o=St(r);if(o)return`<a href="${ee(r)}" data-skill-name="${ee(o)}" class="text-primary hover:underline">${n}</a>`;const i=e?` title="${ee(e)}"`:"";return`<a href="${ee(r)}"${i} class="external-link" target="_blank" rel="noopener noreferrer">${n}</a>`}}}),Yt=t=>t.replace(/\$\$([\s\S]*?)\$\$/g,(e,n)=>{try{return je.renderToString(n,{displayMode:!0,throwOnError:!1})}catch{return`$$${n}$$`}}),et=t=>{if(t.indexOf("$")===-1)return t;const e=/(<(?:pre|code|kbd)[^>]*>[\s\S]*?<\/(?:pre|code|kbd)>)/gi;return t.split(e).map((n,r)=>r%2===1?n:Yt(n)).join("")},Jt=/<pre><code(?:\s+class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,Qt=1200,en=200,tn=(t,e)=>{let n=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&++n>e)return!0;return!1},nn=t=>t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&"),rn=async t=>{const e=[...t.matchAll(Jt)];if(e.length===0)return t;const n=Ae()?en:Qt;let r=t;for(const a of e){const[o,i,s]=a,c=(i||"text").toLowerCase();if(c==="mermaid")continue;const l=nn(s??"");if(tn(l,n)){r=r.replace(o,()=>o.replace("<pre",`<pre data-md-lang="${c}"`));continue}const d=await Mt(l,c);if(d){const u=d.replace(/^<pre/,`<pre data-md-lang="${c}"`);r=r.replace(o,()=>u)}}return r},on={USE_PROFILES:{html:!0,mathMl:!0,svg:!0},ADD_TAGS:["svg","path","g","rect","line","polygon","polyline","circle","ellipse","text","tspan","defs","marker"],ADD_ATTR:["d","viewBox","preserveAspectRatio","xmlns","target","fill","stroke","stroke-width","transform","points","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","style"],FORBID_TAGS:["script"],FORBID_CONTENTS:["script"]};let Le=!1;const an=()=>{Le||typeof window>"u"||!de.isSupported||(Le=!0,de.addHook("afterSanitizeAttributes",t=>{t instanceof HTMLAnchorElement&&t.target==="_blank"&&t.setAttribute("rel","noopener noreferrer")}))},tt=t=>de.isSupported?(an(),de.sanitize(t,on)):"",sn=240,G=new Map,cn=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)},Me=(t,e)=>{if(G.delete(t),G.set(t,e),G.size<=sn)return;const n=G.keys().next().value;n&&G.delete(n)},ln=async t=>{const e=await Promise.resolve(Qe.parse(t.src)),n=et(e),r=t.highlight?await rn(n):n;return tt(r)},dn=t=>{if(!t)return"";const e=Qe.parse(t),n=et(e);return tt(n)},un=async(t,e,n)=>{if(!t)return[];const r=Zt(t,e);return Promise.all(r.map(async(a,o)=>{const i=cn(a.raw),s=`${i}:${a.mode}:${a.highlight?1:0}`,c=`${n}:${o}:${a.mode}`,l=G.get(c);if(l&&l.hash===i)return Me(c,l),{id:s,html:l.html};const d=await ln(a);return Me(c,{hash:i,html:d}),{id:s,html:d}}))},_=t=>Number.isFinite(t)&&t>0,Ne=t=>{if(typeof t=="number")return _(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 _(n)?n:null},he=(t,e,n)=>Math.min(n,Math.max(e,t)),mn=6,xe=1.25,fn=1.0015,pn=.5,hn=12,Re=3,gn=400,oe='[data-markdown="mermaid-block"]',B=t=>t.querySelector(oe)!==null,bn=t=>[t.x,t.y,t.width,t.height].map(e=>{const n=Number(e.toFixed(mn));return Object.is(n,-0)?"0":String(n)}).join(" "),wn=t=>{const e=t.viewBox?.trim().split(/[\s,]+/).map(a=>Number.parseFloat(a));if(e?.length===4){const[a,o,i,s]=e;if(Number.isFinite(a)&&Number.isFinite(o)&&_(i)&&_(s))return{x:a,y:o,width:i,height:s}}const n=Ne(t.width),r=Ne(t.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},yn=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)},An=t=>{const e=t.renderMode||"unknown",n=t.svgMarkup??"";if(!n){const r=[t.viewBox??"",t.width??"",t.height??""];return r.some(a=>a!=="")?`${e}:bounds:${r.join(":")}`:`${e}:no-svg`}return[e,yn(n)].join(":")},nt=(t,e)=>{if(!_(e.width)||!_(e.height))return t;const n=t.width/t.height,r=e.width/e.height;if(n>r){const o=t.width/r;return{x:t.x,y:t.y-(o-t.height)/2,width:t.width,height:o}}const a=t.height*r;return{x:t.x-(a-t.width)/2,y:t.y,width:a,height:t.height}},En=({currentBox:t,viewport:e,delta:n})=>!_(e.width)||!_(e.height)||!_(t.width)||!_(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},kn=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return n*n+r*r>Re*Re},vn=({currentBox:t,contentBox:e,viewport:n,pointer:r,zoomFactor:a,minScale:o,maxScale:i})=>{if(!_(n.width)||!_(n.height)||!_(a)||!_(t.width)||!_(t.height)||!_(e.width)||!_(e.height)||!_(o)||!_(i))return t;const s=Math.min(o,i),c=Math.max(o,i),l=nt(e,n),d=l.width/t.width,u=he(d*a,s,c),f=l.width/u,p=f/(t.width/t.height),g=he(r.x/n.width,0,1),k=he(r.y/n.height,0,1),v=t.x+g*t.width,A=t.y+k*t.height;return{x:v-g*f,y:A-k*p,width:f,height:p}},Ee=new WeakMap,Cn=t=>t instanceof HTMLElement?Ee.get(t)??null:null,Sn=t=>t.querySelector('[data-markdown="mermaid-viewport"]')??t.querySelector('[data-markdown="mermaid"]'),Te=t=>{const e=t.querySelector('[data-markdown="mermaid"] svg'),n=t.querySelector('[data-markdown="mermaid"]');return An({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")})},ne=t=>{const e=t.getBoundingClientRect();return{width:e.width,height:e.height}},Ln=(t,e)=>{const n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},Mn=t=>t instanceof Element&&!!t.closest('button, a, [role="button"]'),Nn=t=>{const e=Sn(t),n=t.querySelector('[data-markdown="mermaid"] svg');if(!e||!n)return null;const r=wn({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let a=r,o=null,i=null,s=null,c=null;const l=m=>{a=m,n.setAttribute("viewBox",bn(m)),n.removeAttribute("width"),n.removeAttribute("height")},d=()=>{l(nt(r,ne(e)))},u=(m,L)=>{l(vn({currentBox:a,contentBox:r,viewport:ne(e),pointer:m,zoomFactor:L,minScale:pn,maxScale:hn}))},f=()=>{const m=ne(e);u({x:m.width/2,y:m.height/2},xe)},p=()=>{const m=ne(e);u({x:m.width/2,y:m.height/2},1/xe)},g=m=>{!m.ctrlKey&&!m.metaKey||(m.preventDefault(),m.stopPropagation(),u(Ln(m,e),Math.pow(fn,-m.deltaY)))},k=m=>{m.button!==0||Mn(m.target)||(o=m.pointerId,i={x:m.clientX,y:m.clientY},s=i,c!==null&&(window.clearTimeout(c),c=null),t.removeAttribute("data-mermaid-suppress-click"),e.setPointerCapture?.(m.pointerId),t.setAttribute("data-mermaid-panning","true"),m.preventDefault())},v=m=>{if(o!==m.pointerId||!s)return;const L={x:m.clientX,y:m.clientY};l(En({currentBox:a,viewport:ne(e),delta:{x:L.x-s.x,y:L.y-s.y}})),s=L,i&&kn(i,L)&&t.setAttribute("data-mermaid-suppress-click","true"),m.preventDefault()},A=m=>{o===m.pointerId&&(e.releasePointerCapture?.(m.pointerId),o=null,i=null,s=null,t.removeAttribute("data-mermaid-panning"),t.hasAttribute("data-mermaid-suppress-click")&&(c=window.setTimeout(()=>{t.removeAttribute("data-mermaid-suppress-click"),c=null},gn)))},S=()=>{d()};e.addEventListener("wheel",g,{passive:!1}),e.addEventListener("pointerdown",k),e.addEventListener("pointermove",v),e.addEventListener("pointerup",A),e.addEventListener("pointercancel",A),window.addEventListener("resize",S);const M=typeof ResizeObserver>"u"?null:new ResizeObserver(S);return M?.observe(e),d(),{zoomIn:f,zoomOut:p,fit:d,cleanup:()=>{e.removeEventListener("wheel",g),e.removeEventListener("pointerdown",k),e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",A),e.removeEventListener("pointercancel",A),window.removeEventListener("resize",S),M?.disconnect(),c!==null&&window.clearTimeout(c),t.removeAttribute("data-mermaid-panning"),t.removeAttribute("data-mermaid-suppress-click"),Ee.delete(t)}}},xn=t=>{const e=new Map,n=new Map,r=()=>{for(const[o,i]of Array.from(e.entries())){const s=Te(o);(!t.contains(o)||s!==n.get(o))&&(i.cleanup(),e.delete(o),n.delete(o))}for(const o of Array.from(t.querySelectorAll(oe))){if(e.has(o)||o.querySelector('[data-markdown="mermaid"] svg')===null)continue;const i=Nn(o);i&&(e.set(o,i),n.set(o,Te(o)),Ee.set(o,i))}},a=()=>{for(const o of e.values())o.cleanup();e.clear(),n.clear()};return r(),{refresh:r,cleanup:a}},z=t=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${t}"></use></svg>`,ue={copy:z("file-copy"),check:z("check"),download:z("download"),zoomIn:z("add"),zoomOut:z("subtract"),fit:z("refresh"),textWrap:z("text-wrap")},rt="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)]",me=(t,e)=>{t.innerHTML=e},W=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className=rt,r.setAttribute("data-md-action",n),r.setAttribute("title",e),r.setAttribute("aria-label",e),me(r,ue[t]),r},ot=(t,e,n)=>{const r=t.querySelector("[data-md-code-body]"),a=t.querySelector("pre"),o=t.querySelector("pre code"),i=t.querySelector('[data-md-action="toggle-code-wrap"]');if(t.setAttribute("data-code-wrap",e?"true":"false"),r?.classList.toggle("overflow-x-auto",!e),r?.classList.toggle("overflow-x-hidden",e),a?.classList.toggle("whitespace-pre-wrap",e),a?.classList.toggle("break-words",e),o?.classList.toggle("whitespace-pre-wrap",e),o?.classList.toggle("break-words",e),a&&(a.style.whiteSpace=e?"pre-wrap":"pre",a.style.overflowWrap=e?"anywhere":"normal"),o&&(o.style.whiteSpace=e?"pre-wrap":"pre",o.style.overflowWrap=e?"anywhere":"normal"),i){const s=e?n.disableCodeWrap:n.enableCodeWrap;i.setAttribute("title",s),i.setAttribute("aria-label",s),i.classList.toggle("text-foreground",e),i.classList.toggle("opacity-100",e),i.classList.toggle("text-muted-foreground",!e),i.classList.toggle("opacity-65",!e),i.setAttribute("aria-pressed",e?"true":"false")}},at=t=>{const e=document.createElement("div");e.setAttribute("data-md-code-line-numbers",""),e.setAttribute("aria-hidden","true"),e.className="min-w-8 shrink-0 select-none border-r border-border/50 pr-3 text-right font-mono text-[13px] text-muted-foreground/45";const n=t.textContent??"",r=Math.max(1,n.endsWith(`
1
+ import{cf as Ke,cg as je,ch as de,ci as At,R as N,b as K,cj as Et,ck as kt,cl as vt,j as re}from"./vendor-.bun-BE757pvp.js";import{e_ as Ct,e$ as St,f0 as Lt,f1 as Mt,f2 as Ue,f3 as Nt,f4 as xt,y as pe,d3 as Rt,d4 as Tt,f5 as _t,f6 as Pt,d as Xe,e as Ze,f7 as Ge,v as Ye,dK as It,A as Ce,c as Ft,f8 as $t,f9 as Ot,fa as Dt,o as Wt,fb as Se,fc as qt,fd as Bt,ca as zt}from"./useAppFontEffects-9LFMCKYW.js";import{E as Ae,u as Y,v as Ht,w as Vt,h as Kt}from"./index-BklNmnVr.js";const ee=t=>t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),jt=t=>/^\[[^\]]+\]:\s+\S+/m.test(t)||/^\[\^[^\]]+\]:\s+/m.test(t),Ut=t=>{const e=t.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!e)return!1;const n=e[1];if(!n)return!1;const r=n[0],a=n.length,o=t.trimEnd().split(`
2
+ `).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${r}{${a},}[\\t ]*$`).test(o)},te=t=>{try{return At(t,{linkMode:"text-only"})}catch{return t}},Xt=(t,e)=>{if(!e)return[{raw:t,src:t,mode:"full",highlight:!0}];if(jt(t))return[{raw:t,src:te(t),mode:"live",highlight:!0}];let n;try{n=Ke.lexer(t)}catch{return[{raw:t,src:te(t),mode:"live",highlight:!0}]}let r=-1;for(let o=n.length-1;o>=0;o-=1)if(n[o]?.type!=="space"){r=o;break}if(r<0)return[{raw:t,src:te(t),mode:"live",highlight:!0}];const a=[];for(let o=0;o<n.length;o+=1){const i=n[o];if(!i||i.type==="space")continue;const s=i.raw??"",c=o===r,l=i.type==="code"&&Ut(s);a.push({raw:s,src:l?s:te(s),mode:c?"live":"full",highlight:!l})}return a.length===0?[{raw:t,src:te(t),mode:"live",highlight:!0}]:a},Je=(t,e,n)=>{try{return je.renderToString(t,{displayMode:n,throwOnError:!1})}catch{return e}},Zt={name:"inlineMath",level:"inline",start(t){const e=t.indexOf("\\(");return e<0?void 0:e},tokenizer(t){const e=/^\\\(([\s\S]+?)\\\)/.exec(t);if(e)return{type:"inlineMath",raw:e[0],text:e[1]??""}},renderer(t){const e=t;return Je(e.text,e.raw,!1)}},Gt={name:"blockMath",level:"block",start(t){const e=t.indexOf("\\[");return e<0?void 0:e},tokenizer(t){const e=/^\\\[([\s\S]+?)\\\]/.exec(t);if(e)return{type:"blockMath",raw:e[0],text:e[1]??""}},renderer(t){const e=t;return Je(e.text,e.raw,!0)}},Qe=Ke.use({gfm:!0,breaks:!1,extensions:[Zt,Gt],renderer:{link({href:t,title:e,text:n}){const r=t??"",a=Ct(r);if(a)return`<a href="${ee(Lt(a))}" data-openchamber-agent-mention="true" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">${n}</a>`;const o=St(r);if(o)return`<a href="${ee(r)}" data-skill-name="${ee(o)}" class="text-primary hover:underline">${n}</a>`;const i=e?` title="${ee(e)}"`:"";return`<a href="${ee(r)}"${i} class="external-link" target="_blank" rel="noopener noreferrer">${n}</a>`}}}),Yt=t=>t.replace(/\$\$([\s\S]*?)\$\$/g,(e,n)=>{try{return je.renderToString(n,{displayMode:!0,throwOnError:!1})}catch{return`$$${n}$$`}}),et=t=>{if(t.indexOf("$")===-1)return t;const e=/(<(?:pre|code|kbd)[^>]*>[\s\S]*?<\/(?:pre|code|kbd)>)/gi;return t.split(e).map((n,r)=>r%2===1?n:Yt(n)).join("")},Jt=/<pre><code(?:\s+class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,Qt=1200,en=200,tn=(t,e)=>{let n=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&++n>e)return!0;return!1},nn=t=>t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&"),rn=async t=>{const e=[...t.matchAll(Jt)];if(e.length===0)return t;const n=Ae()?en:Qt;let r=t;for(const a of e){const[o,i,s]=a,c=(i||"text").toLowerCase();if(c==="mermaid")continue;const l=nn(s??"");if(tn(l,n)){r=r.replace(o,()=>o.replace("<pre",`<pre data-md-lang="${c}"`));continue}const d=await Mt(l,c);if(d){const u=d.replace(/^<pre/,`<pre data-md-lang="${c}"`);r=r.replace(o,()=>u)}}return r},on={USE_PROFILES:{html:!0,mathMl:!0,svg:!0},ADD_TAGS:["svg","path","g","rect","line","polygon","polyline","circle","ellipse","text","tspan","defs","marker"],ADD_ATTR:["d","viewBox","preserveAspectRatio","xmlns","target","fill","stroke","stroke-width","transform","points","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","style"],FORBID_TAGS:["script"],FORBID_CONTENTS:["script"]};let Le=!1;const an=()=>{Le||typeof window>"u"||!de.isSupported||(Le=!0,de.addHook("afterSanitizeAttributes",t=>{t instanceof HTMLAnchorElement&&t.target==="_blank"&&t.setAttribute("rel","noopener noreferrer")}))},tt=t=>de.isSupported?(an(),de.sanitize(t,on)):"",sn=240,G=new Map,cn=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)},Me=(t,e)=>{if(G.delete(t),G.set(t,e),G.size<=sn)return;const n=G.keys().next().value;n&&G.delete(n)},ln=async t=>{const e=await Promise.resolve(Qe.parse(t.src)),n=et(e),r=t.highlight?await rn(n):n;return tt(r)},dn=t=>{if(!t)return"";const e=Qe.parse(t),n=et(e);return tt(n)},un=async(t,e,n)=>{if(!t)return[];const r=Xt(t,e);return Promise.all(r.map(async(a,o)=>{const i=cn(a.raw),s=`${i}:${a.mode}:${a.highlight?1:0}`,c=`${n}:${o}:${a.mode}`,l=G.get(c);if(l&&l.hash===i)return Me(c,l),{id:s,html:l.html};const d=await ln(a);return Me(c,{hash:i,html:d}),{id:s,html:d}}))},_=t=>Number.isFinite(t)&&t>0,Ne=t=>{if(typeof t=="number")return _(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 _(n)?n:null},he=(t,e,n)=>Math.min(n,Math.max(e,t)),mn=6,xe=1.25,fn=1.0015,pn=.5,hn=12,Re=3,gn=400,oe='[data-markdown="mermaid-block"]',B=t=>t.querySelector(oe)!==null,bn=t=>[t.x,t.y,t.width,t.height].map(e=>{const n=Number(e.toFixed(mn));return Object.is(n,-0)?"0":String(n)}).join(" "),wn=t=>{const e=t.viewBox?.trim().split(/[\s,]+/).map(a=>Number.parseFloat(a));if(e?.length===4){const[a,o,i,s]=e;if(Number.isFinite(a)&&Number.isFinite(o)&&_(i)&&_(s))return{x:a,y:o,width:i,height:s}}const n=Ne(t.width),r=Ne(t.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},yn=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)},An=t=>{const e=t.renderMode||"unknown",n=t.svgMarkup??"";if(!n){const r=[t.viewBox??"",t.width??"",t.height??""];return r.some(a=>a!=="")?`${e}:bounds:${r.join(":")}`:`${e}:no-svg`}return[e,yn(n)].join(":")},nt=(t,e)=>{if(!_(e.width)||!_(e.height))return t;const n=t.width/t.height,r=e.width/e.height;if(n>r){const o=t.width/r;return{x:t.x,y:t.y-(o-t.height)/2,width:t.width,height:o}}const a=t.height*r;return{x:t.x-(a-t.width)/2,y:t.y,width:a,height:t.height}},En=({currentBox:t,viewport:e,delta:n})=>!_(e.width)||!_(e.height)||!_(t.width)||!_(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},kn=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return n*n+r*r>Re*Re},vn=({currentBox:t,contentBox:e,viewport:n,pointer:r,zoomFactor:a,minScale:o,maxScale:i})=>{if(!_(n.width)||!_(n.height)||!_(a)||!_(t.width)||!_(t.height)||!_(e.width)||!_(e.height)||!_(o)||!_(i))return t;const s=Math.min(o,i),c=Math.max(o,i),l=nt(e,n),d=l.width/t.width,u=he(d*a,s,c),f=l.width/u,p=f/(t.width/t.height),g=he(r.x/n.width,0,1),k=he(r.y/n.height,0,1),v=t.x+g*t.width,A=t.y+k*t.height;return{x:v-g*f,y:A-k*p,width:f,height:p}},Ee=new WeakMap,Cn=t=>t instanceof HTMLElement?Ee.get(t)??null:null,Sn=t=>t.querySelector('[data-markdown="mermaid-viewport"]')??t.querySelector('[data-markdown="mermaid"]'),Te=t=>{const e=t.querySelector('[data-markdown="mermaid"] svg'),n=t.querySelector('[data-markdown="mermaid"]');return An({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")})},ne=t=>{const e=t.getBoundingClientRect();return{width:e.width,height:e.height}},Ln=(t,e)=>{const n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},Mn=t=>t instanceof Element&&!!t.closest('button, a, [role="button"]'),Nn=t=>{const e=Sn(t),n=t.querySelector('[data-markdown="mermaid"] svg');if(!e||!n)return null;const r=wn({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let a=r,o=null,i=null,s=null,c=null;const l=m=>{a=m,n.setAttribute("viewBox",bn(m)),n.removeAttribute("width"),n.removeAttribute("height")},d=()=>{l(nt(r,ne(e)))},u=(m,L)=>{l(vn({currentBox:a,contentBox:r,viewport:ne(e),pointer:m,zoomFactor:L,minScale:pn,maxScale:hn}))},f=()=>{const m=ne(e);u({x:m.width/2,y:m.height/2},xe)},p=()=>{const m=ne(e);u({x:m.width/2,y:m.height/2},1/xe)},g=m=>{!m.ctrlKey&&!m.metaKey||(m.preventDefault(),m.stopPropagation(),u(Ln(m,e),Math.pow(fn,-m.deltaY)))},k=m=>{m.button!==0||Mn(m.target)||(o=m.pointerId,i={x:m.clientX,y:m.clientY},s=i,c!==null&&(window.clearTimeout(c),c=null),t.removeAttribute("data-mermaid-suppress-click"),e.setPointerCapture?.(m.pointerId),t.setAttribute("data-mermaid-panning","true"),m.preventDefault())},v=m=>{if(o!==m.pointerId||!s)return;const L={x:m.clientX,y:m.clientY};l(En({currentBox:a,viewport:ne(e),delta:{x:L.x-s.x,y:L.y-s.y}})),s=L,i&&kn(i,L)&&t.setAttribute("data-mermaid-suppress-click","true"),m.preventDefault()},A=m=>{o===m.pointerId&&(e.releasePointerCapture?.(m.pointerId),o=null,i=null,s=null,t.removeAttribute("data-mermaid-panning"),t.hasAttribute("data-mermaid-suppress-click")&&(c=window.setTimeout(()=>{t.removeAttribute("data-mermaid-suppress-click"),c=null},gn)))},S=()=>{d()};e.addEventListener("wheel",g,{passive:!1}),e.addEventListener("pointerdown",k),e.addEventListener("pointermove",v),e.addEventListener("pointerup",A),e.addEventListener("pointercancel",A),window.addEventListener("resize",S);const M=typeof ResizeObserver>"u"?null:new ResizeObserver(S);return M?.observe(e),d(),{zoomIn:f,zoomOut:p,fit:d,cleanup:()=>{e.removeEventListener("wheel",g),e.removeEventListener("pointerdown",k),e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",A),e.removeEventListener("pointercancel",A),window.removeEventListener("resize",S),M?.disconnect(),c!==null&&window.clearTimeout(c),t.removeAttribute("data-mermaid-panning"),t.removeAttribute("data-mermaid-suppress-click"),Ee.delete(t)}}},xn=t=>{const e=new Map,n=new Map,r=()=>{for(const[o,i]of Array.from(e.entries())){const s=Te(o);(!t.contains(o)||s!==n.get(o))&&(i.cleanup(),e.delete(o),n.delete(o))}for(const o of Array.from(t.querySelectorAll(oe))){if(e.has(o)||o.querySelector('[data-markdown="mermaid"] svg')===null)continue;const i=Nn(o);i&&(e.set(o,i),n.set(o,Te(o)),Ee.set(o,i))}},a=()=>{for(const o of e.values())o.cleanup();e.clear(),n.clear()};return r(),{refresh:r,cleanup:a}},z=t=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${t}"></use></svg>`,ue={copy:z("file-copy"),check:z("check"),download:z("download"),zoomIn:z("add"),zoomOut:z("subtract"),fit:z("refresh"),textWrap:z("text-wrap")},rt="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)]",me=(t,e)=>{t.innerHTML=e},W=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className=rt,r.setAttribute("data-md-action",n),r.setAttribute("title",e),r.setAttribute("aria-label",e),me(r,ue[t]),r},ot=(t,e,n)=>{const r=t.querySelector("[data-md-code-body]"),a=t.querySelector("pre"),o=t.querySelector("pre code"),i=t.querySelector('[data-md-action="toggle-code-wrap"]');if(t.setAttribute("data-code-wrap",e?"true":"false"),r?.classList.toggle("overflow-x-auto",!e),r?.classList.toggle("overflow-x-hidden",e),a?.classList.toggle("whitespace-pre-wrap",e),a?.classList.toggle("break-words",e),o?.classList.toggle("whitespace-pre-wrap",e),o?.classList.toggle("break-words",e),a&&(a.style.whiteSpace=e?"pre-wrap":"pre",a.style.overflowWrap=e?"anywhere":"normal"),o&&(o.style.whiteSpace=e?"pre-wrap":"pre",o.style.overflowWrap=e?"anywhere":"normal"),i){const s=e?n.disableCodeWrap:n.enableCodeWrap;i.setAttribute("title",s),i.setAttribute("aria-label",s),i.classList.toggle("text-foreground",e),i.classList.toggle("opacity-100",e),i.classList.toggle("text-muted-foreground",!e),i.classList.toggle("opacity-65",!e),i.setAttribute("aria-pressed",e?"true":"false")}},at=t=>{const e=document.createElement("div");e.setAttribute("data-md-code-line-numbers",""),e.setAttribute("aria-hidden","true"),e.className="min-w-8 shrink-0 select-none border-r border-border/50 pr-3 text-right font-mono text-[13px] text-muted-foreground/45";const n=t.textContent??"",r=Math.max(1,n.endsWith(`
3
3
  `)?n.split(`
4
4
  `).length-1:n.split(`
5
5
  `).length);for(let a=1;a<=r;a+=1){const o=document.createElement("div");o.className="tabular-nums",o.textContent=String(a),e.appendChild(o)}return e},Rn=t=>{const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let r=n.nextNode();for(;r;)e.push(r),r=n.nextNode();return e},_e=(t,e)=>{let n=0;for(const a of t){const o=n+a.data.length;if(e<=o)return{node:a,offset:Math.max(0,e-n)};n=o}const r=t.at(-1);return r?{node:r,offset:r.data.length}:null},st=t=>{const e=t.querySelectorAll('[data-component="markdown-code"]');for(const n of Array.from(e)){const r=n.querySelector("pre code"),a=n.querySelector("[data-md-code-line-numbers]");if(!r||!a)continue;const o=Array.from(a.children),i=r.textContent??"",s=Rn(r),c=window.getComputedStyle(r),l=Number.parseFloat(c.lineHeight)||20;a.style.fontFamily=c.fontFamily,a.style.fontSize=c.fontSize,a.style.lineHeight=`${l}px`;let d=0;for(let u=0;u<o.length;u+=1){const f=i.indexOf(`
6
- `,d),p=f===-1?i.length:f,g=o[u];if(!g)continue;const k=_e(s,d),v=_e(s,p);if(!k||!v||d===p)g.style.height=`${l}px`,g.style.lineHeight=`${l}px`;else{const A=document.createRange();A.setStart(k.node,k.offset),A.setEnd(v.node,v.offset);const S=[];for(const m of Array.from(A.getClientRects()))m.width===0&&m.height===0||S.some(L=>Math.abs(L-m.top)<2)||S.push(m.top);const M=Math.max(l,Math.max(1,S.length)*l);A.detach(),g.style.height=`${M}px`,g.style.lineHeight=`${l}px`}d=p+1}}},ke=t=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>st(t))})},Tn=(t,e,n)=>{const r=t.querySelectorAll('[data-component="markdown-code"]');for(const a of Array.from(r)){const o=a.querySelector("[data-md-code-body]"),i=a.querySelector("pre");o&&i&&!o.querySelector("[data-md-code-line-numbers]")&&(o.classList.add("flex","gap-3"),o.insertBefore(at(i),i)),ot(a,e,n)}ke(t)},Ie=(t,e,n,r)=>{me(t,ue.check),t.setAttribute("title",e),t.setAttribute("aria-label",e),window.setTimeout(()=>{me(t,ue[n]),t.setAttribute("title",r),t.setAttribute("aria-label",r)},2e3)},_n=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")},In=(t,e)=>{const n=t.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const a=r.parentElement;if(!a||a.closest('[data-component="markdown-code"]'))continue;const o=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],i=r.getAttribute("data-md-lang")??o??"text",s=document.createElement("div");s.setAttribute("data-component","markdown-code"),s.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const c=document.createElement("div");c.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const l=document.createElement("span");l.className="font-mono text-[13px] text-muted-foreground",l.textContent=i;const d=W("copy",e.labels.copy,"copy-code"),u=W("textWrap",e.codeBlockLineWrap?e.labels.disableCodeWrap:e.labels.enableCodeWrap,"toggle-code-wrap");c.appendChild(l);const f=document.createElement("div");f.className="flex items-center gap-1",f.appendChild(u),f.appendChild(d),c.appendChild(f);const p=document.createElement("div");p.setAttribute("data-md-code-body",""),p.className=e.deferCodeLineNumberSync?"px-3 py-2.5 overflow-x-auto":"flex gap-3 px-3 py-2.5 overflow-x-auto",a.replaceChild(s,r),r.style.margin="0",r.style.background="transparent",r.classList.add("min-w-0","w-full","flex-1"),e.deferCodeLineNumberSync||p.appendChild(at(r)),p.appendChild(r),s.appendChild(c),s.appendChild(p),ot(s,e.codeBlockLineWrap,e.labels),e.deferCodeLineNumberSync||ke(s)}},Pe=t=>{const e=[],n=[],r=t.querySelectorAll("thead th");for(const o of Array.from(r))e.push((o.textContent??"").trim());const a=t.querySelectorAll("tbody tr");for(const o of Array.from(a)){const i=Array.from(o.querySelectorAll("td")).map(s=>(s.textContent??"").trim());i.length>0&&n.push(i)}return{headers:e,rows:n}},Pn=t=>/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t,Fe=({headers:t,rows:e})=>[t,...e].map(n=>n.map(Pn).join(",")).join(`
6
+ `,d),p=f===-1?i.length:f,g=o[u];if(!g)continue;const k=_e(s,d),v=_e(s,p);if(!k||!v||d===p)g.style.height=`${l}px`,g.style.lineHeight=`${l}px`;else{const A=document.createRange();A.setStart(k.node,k.offset),A.setEnd(v.node,v.offset);const S=[];for(const m of Array.from(A.getClientRects()))m.width===0&&m.height===0||S.some(L=>Math.abs(L-m.top)<2)||S.push(m.top);const M=Math.max(l,Math.max(1,S.length)*l);A.detach(),g.style.height=`${M}px`,g.style.lineHeight=`${l}px`}d=p+1}}},ke=t=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>st(t))})},Tn=(t,e,n)=>{const r=t.querySelectorAll('[data-component="markdown-code"]');for(const a of Array.from(r)){const o=a.querySelector("[data-md-code-body]"),i=a.querySelector("pre");o&&i&&!o.querySelector("[data-md-code-line-numbers]")&&(o.classList.add("flex","gap-3"),o.insertBefore(at(i),i)),ot(a,e,n)}ke(t)},Pe=(t,e,n,r)=>{me(t,ue.check),t.setAttribute("title",e),t.setAttribute("aria-label",e),window.setTimeout(()=>{me(t,ue[n]),t.setAttribute("title",r),t.setAttribute("aria-label",r)},2e3)},_n=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")},Pn=(t,e)=>{const n=t.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const a=r.parentElement;if(!a||a.closest('[data-component="markdown-code"]'))continue;const o=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],i=r.getAttribute("data-md-lang")??o??"text",s=document.createElement("div");s.setAttribute("data-component","markdown-code"),s.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const c=document.createElement("div");c.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const l=document.createElement("span");l.className="font-mono text-[13px] text-muted-foreground",l.textContent=i;const d=W("copy",e.labels.copy,"copy-code"),u=W("textWrap",e.codeBlockLineWrap?e.labels.disableCodeWrap:e.labels.enableCodeWrap,"toggle-code-wrap");c.appendChild(l);const f=document.createElement("div");f.className="flex items-center gap-1",f.appendChild(u),f.appendChild(d),c.appendChild(f);const p=document.createElement("div");p.setAttribute("data-md-code-body",""),p.className=e.deferCodeLineNumberSync?"px-3 py-2.5 overflow-x-auto":"flex gap-3 px-3 py-2.5 overflow-x-auto",a.replaceChild(s,r),r.style.margin="0",r.style.background="transparent",r.classList.add("min-w-0","w-full","flex-1"),e.deferCodeLineNumberSync||p.appendChild(at(r)),p.appendChild(r),s.appendChild(c),s.appendChild(p),ot(s,e.codeBlockLineWrap,e.labels),e.deferCodeLineNumberSync||ke(s)}},Ie=t=>{const e=[],n=[],r=t.querySelectorAll("thead th");for(const o of Array.from(r))e.push((o.textContent??"").trim());const a=t.querySelectorAll("tbody tr");for(const o of Array.from(a)){const i=Array.from(o.querySelectorAll("td")).map(s=>(s.textContent??"").trim());i.length>0&&n.push(i)}return{headers:e,rows:n}},In=t=>/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t,Fe=({headers:t,rows:e})=>[t,...e].map(n=>n.map(In).join(",")).join(`
7
7
  `),Fn=({headers:t,rows:e})=>[t,...e].map(n=>n.join(" ")).join(`
8
8
  `),$e=({headers:t,rows:e})=>{const n=`| ${t.join(" | ")} |`,r=`| ${t.map(()=>"---").join(" | ")} |`,a=e.map(o=>`| ${o.join(" | ")} |`).join(`
9
9
  `);return`${n}
10
10
  ${r}
11
- ${a}`},Oe=(t,e)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${Rt}`,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 a=document.createElement("button");a.type="button",a.className=`w-full text-left ${Tt}`,a.setAttribute("data-md-action",`${t}-${r.key}`),a.textContent=r.label,n.appendChild(a)}return n},$n=(t,e)=>{const n=t.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const i=document.createElement("div");i.className="flex items-center justify-end gap-1";const s=document.createElement("div");s.className="relative",s.appendChild(W("copy",e.copyTable,"table-copy-toggle")),s.appendChild(Oe("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const c=document.createElement("div");c.className="relative",c.appendChild(W("download",e.downloadTable,"table-download-toggle")),c.appendChild(Oe("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),i.appendChild(s),i.appendChild(c);const l=document.createElement("div");l.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const d=r.parentElement;if(!d)continue;d.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const f of Array.from(r.querySelectorAll("tr")))f.classList.add("border-b","border-border/60");const u=r.querySelector("tbody tr:last-child");u?.classList.remove("border-b"),u?.classList.add("border-0");for(const f of Array.from(r.querySelectorAll("th")))f.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 f of Array.from(r.querySelectorAll("td")))f.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");l.appendChild(r),o.appendChild(i),o.appendChild(l)}},On=(t,e)=>{const n=t.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const a=r.parentElement;if(!a)continue;const o=(r.textContent??"").replace(/\s+$/,""),i=e.renderMermaid(o),s=document.createElement("div");s.setAttribute("data-markdown","mermaid-block"),s.setAttribute("data-md-source",o),s.className="group relative";const c=document.createElement("div");c.setAttribute("data-markdown","mermaid-scroll");const l=document.createElement("div");if(l.setAttribute("data-markdown","mermaid-toolbar"),l.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",i.svg){s.setAttribute("data-mermaid-render","svg");const u=document.createElement("div");u.setAttribute("data-markdown","mermaid-viewport");const f=document.createElement("div");if(f.setAttribute("data-markdown","mermaid"),f.setAttribute("data-md-original-svg",i.svg),f.innerHTML=i.svg,u.appendChild(f),c.appendChild(u),e.mermaidControls.showPanZoomControls&&(l.appendChild(W("zoomIn",e.labels.zoomInDiagram,"mermaid-zoom-in")),l.appendChild(W("zoomOut",e.labels.zoomOutDiagram,"mermaid-zoom-out")),l.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",o),l.appendChild(p)}if(e.mermaidControls.download){const p=W("download",e.labels.downloadDiagram,"mermaid-download");p.setAttribute("data-md-svg","1"),l.appendChild(p)}}else{s.setAttribute("data-mermaid-render","ascii");const u=document.createElement("pre");if(u.setAttribute("data-markdown","mermaid-ascii"),u.textContent=i.ascii||o,c.appendChild(u),e.mermaidControls.copy){const f=W("copy",e.labels.copyDiagram,"mermaid-copy");f.setAttribute("data-md-source",i.ascii||o),l.appendChild(f)}}s.appendChild(c),s.appendChild(l);const d=a.parentElement;d&&d.replaceChild(s,a)}},Dn=(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 a=r.getAttribute("href")??"";if(!Ue(a))continue;r.setAttribute("data-md-link-decorated","true");const o=Nt(a);if(o){const i=document.createElement("span");i.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const s=document.createElement("img");s.src=o,s.alt="",s.setAttribute("aria-hidden","true"),s.loading="lazy",s.decoding="async",s.className="size-3.5 rounded-sm",s.addEventListener("error",()=>i.remove(),{once:!0}),i.appendChild(s),r.parentNode?.insertBefore(i,r)}if(e.onPreviewLoopback&&xt(a)){const i=document.createElement("button");i.type="button",i.className=`ml-1 align-middle ${rt}`,i.setAttribute("data-md-action","preview-loopback"),i.setAttribute("data-md-url",a),i.setAttribute("title",e.labels.previewTitle),i.setAttribute("aria-label",e.labels.previewLabel),me(i,ue.download),r.parentNode?.insertBefore(i,r.nextSibling)}}},De=(t,e)=>{_n(t),On(t,e),In(t,e),$n(t,e.labels),Dn(t,e)},We=(t,e,n)=>{const r=new Blob([e],{type:n}),a=URL.createObjectURL(r),o=document.createElement("a");o.href=a,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},ie=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},Wn=(t,e)=>{const n=r=>{const a=r.target;if(!(a instanceof Element))return;const o=a.closest("[data-md-action]");if(!o){ie(t);return}const i=o.getAttribute("data-md-action")??"";if(i==="copy-code"){const c=o.closest('[data-component="markdown-code"]')?.querySelector("code")?.textContent??"";c&&pe(c).then(()=>Ie(o,e.labels.copied,"copy",e.labels.copy));return}if(i==="toggle-code-wrap"){r.preventDefault(),e.onToggleCodeBlockLineWrap?.();return}if(i==="table-copy-toggle"||i==="table-download-toggle"){r.preventDefault();const s=o.parentElement?.querySelector("[data-md-menu]")??null,c=s?.classList.contains("hidden")??!1;ie(t),s&&c&&s.classList.remove("hidden");return}if(i.startsWith("table-copy-")){const s=i.replace("table-copy-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const l=Pe(c),d=s==="csv"?Fe(l):s==="tsv"?Fn(l):$e(l);pe(d)}ie(t);return}if(i.startsWith("table-download-")){const s=i.replace("table-download-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const l=Pe(c),d=s==="csv"?Fe(l):$e(l);We(s==="csv"?"table.csv":"table.md",d,s==="csv"?"text/csv":"text/markdown")}ie(t);return}if(i==="mermaid-copy"){const s=o.getAttribute("data-md-source")??"";s&&pe(s).then(()=>Ie(o,e.labels.copied,"copy",e.labels.copyDiagram));return}if(i==="mermaid-zoom-in"||i==="mermaid-zoom-out"||i==="mermaid-fit"){r.preventDefault();const s=o.closest('[data-markdown="mermaid-block"]'),c=Cn(s);i==="mermaid-zoom-in"?c?.zoomIn():i==="mermaid-zoom-out"?c?.zoomOut():c?.fit();return}if(i==="mermaid-download"){const s=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),c=s?.getAttribute("data-md-original-svg")??s?.innerHTML??"";c&&We("diagram.svg",c,"image/svg+xml;charset=utf-8");return}if(i==="preview-loopback"){r.preventDefault();const s=o.getAttribute("data-md-url")??"";s&&e.onPreviewLoopback?.(s);return}};return t.addEventListener("click",n),()=>t.removeEventListener("click",n)},qn=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),qe=Array.from(qn).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Bn=t=>It(t),zn=t=>_t(t),fe=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):""},ce=t=>{let e=fe(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 a=qe.length>0?e.match(new RegExp(`^(.*(?:/|^)(${qe})):.*$`,"i")):null;return a&&(e=a[1]??e),fe(e)},it=t=>{const e=fe(t);if(!e)return null;const n=e.indexOf(";"),r=n>=0?fe(e.slice(0,n)):e;if(!r)return null;const a=r.match(/^(.*?):(\d+)-(\d+)$/);if(a){const c=ce(a[1]??""),l=Number.parseInt(a[2]??"",10),d=Number.parseInt(a[3]??"",10);return!c||!Number.isFinite(l)||!Number.isFinite(d)||d<l?null:{path:c,line:l,endLine:d}}const o=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const c=ce(o[1]??""),l=Number.parseInt(o[2]??"",10),d=o[3]?Number.parseInt(o[3],10):void 0;return!c||!Number.isFinite(l)?null:{path:c,line:l,column:Number.isFinite(d??Number.NaN)?d:void 0}}const i=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(i){const c=ce(i[1]??""),l=Number.parseInt(i[2]??"",10),d=i[3]?Number.parseInt(i[3],10):void 0;return!c||!Number.isFinite(l)?null:{path:c,line:l,column:Number.isFinite(d??Number.NaN)?d:void 0}}const s=ce(r);return s?{path:s}:null},ge=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,ct=()=>{const t=K.c(4),e=Pt();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=Ce(!1),t[0]=n):n=t[0];const r=n;let a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=Ce(!0),t[1]=a):a=t[1];const o=a;let i;return t[2]!==e?.currentTheme?(i=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:r),t[2]=e?.currentTheme,t[3]=i):i=t[3],i},lt=t=>{const e=K.c(4),{containerRef:n,enabled:r}=t;let a,o;e[0]!==n||e[1]!==r?(a=()=>{if(r===!1)return;const i=n.current;if(!i)return;const s=br;return i.addEventListener("click",s),()=>{i.removeEventListener("click",s)}},o=[n,r],e[0]=n,e[1]=r,e[2]=a,e[3]=o):(a=e[2],o=e[3]),N.useEffect(a,o)},Q={download:!0,copy:!0,showPanZoomControls:!0},dt=!0,Hn=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},Be='[data-openchamber-file-link="true"]',ut="data-openchamber-block-path-token",mt=`[${ut}]`,J="data-openchamber-block-paths-scanned",Vn=2e5,Kn=4,jn=1e3,Un=200,Zn=80,Xn=40,ze=160,H=new Map;let le=0;const He=[],Gn=()=>Ae()?Un:jn,Yn=()=>Ae()?Xn:Zn,Jn=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),ve=t=>Bn(t),Qn=t=>zn(t),er=(t,e)=>zt(t,e),tr=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},ft=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=ve(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return Jn.has(r)||r.startsWith(".")&&r.length>1?!0:tr(e)},pt=t=>{const e=it(t);return e?ft(e.path):!1},Ve=(t,e)=>{let n=0;for(const a of t){const o=n+a.data.length;if(e<=o)return{node:a,offset:Math.max(0,e-n)};n=o}const r=t.at(-1);return r?{node:r,offset:r.data.length}:null},nr=t=>{const e=t.querySelectorAll(mt);for(const r of Array.from(e))r.replaceWith(t.ownerDocument.createTextNode(r.textContent??""));const n=t.querySelectorAll(`code[${J}]`);for(const r of Array.from(n))r.removeAttribute(J),r.normalize()},be=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim();if(e&&pt(e))return e}return(t.textContent||"").trim()},rr=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(J)==="true")continue;if((r.textContent??"").length>Vn){r.setAttribute(J,"true");continue}const a=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let i=a.nextNode();for(;i;)o.push(i),i=a.nextNode();const s=r.textContent??"";if(!s.includes(".")){r.setAttribute(J,"true");continue}ge.lastIndex=0;const c=[];let l=ge.exec(s);for(;l;){const d=l[0];d&&pt(d)&&c.push({start:l.index,end:l.index+d.length,raw:d}),l=ge.exec(s)}for(const{start:d,end:u,raw:f}of c.reverse()){const p=Ve(o,d),g=Ve(o,u);if(!p||!g)continue;const k=n.createRange();k.setStart(p.node,p.offset),k.setEnd(g.node,g.offset);const v=n.createElement("span");v.setAttribute(ut,"true"),v.textContent=f,k.deleteContents(),k.insertNode(v)}r.setAttribute(J,"true")}},we=(t,e)=>{const n=it(t);if(!n||!ft(n.path))return null;const r=Qn(n.path)?ve(n.path):er(e,n.path);return r?{...n,resolvedPath:r}:null},or=t=>{const e=ve(t);if(!e)return Promise.resolve(!1);const n=H.get(e);if(n)return H.delete(e),H.set(e,n),n;const r=new Promise(o=>{const i=()=>{le+=1,Kt(`/api/fs/stat?path=${encodeURIComponent(e)}&optional=true`,{method:"GET",cache:"no-store"}).then(async s=>{if(!s.ok){o(!1);return}const c=await s.json().catch(()=>null);o(c?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{le=Math.max(0,le-1),He.shift()?.()})};if(le<Kn){i();return}He.push(i)}),a=Gn();for(;H.size>=a;){const o=H.keys().next().value;if(typeof o!="string")break;H.delete(o)}return H.set(e,r),r},ar=(t,e)=>t||Bt(t,e),ht=t=>{const e=K.c(7),{containerRef:n,effectiveDirectory:r,editor:a,preferRuntimeEditor:o,enabled:i}=t,s=N.useRef(null);let c,l;e[0]!==n||e[1]!==a||e[2]!==r||e[3]!==i||e[4]!==o?(c=()=>{const d=n.current;if(!d)return;let u=!1;const f=Yn(),p=i&&!Ot(),g=wr,k=()=>{const y=d.querySelectorAll(Be);for(const w of Array.from(y))g(w);nr(d)};if(!p){k();return}const v=y=>{const w=y;if(s.current!==null&&typeof window<"u"&&window.clearTimeout(s.current),typeof window>"u"){A();return}s.current=window.setTimeout(()=>{s.current=null,window.requestAnimationFrame(()=>{u||A()})},w)},A=()=>{p&&rr(d);const y=d.querySelectorAll(`[data-markdown="inline-code"], a, ${mt}`);let w=0;for(const h of Array.from(y)){const I=be(h),b=we(I,r);if(g(h),!b||w>=f)continue;w=w+1,(Ht()&&Vt()&&!Se(b.resolvedPath,r)?Promise.resolve(!0):or(b.resolvedPath)).then(R=>{if(u||!R||!d.contains(h))return;const F=be(h),$=we(F,r);!$||$.resolvedPath!==b.resolvedPath||(h.setAttribute("data-openchamber-file-link","true"),h.setAttribute("data-openchamber-file-ref",F),h.setAttribute("data-openchamber-file-path",$.resolvedPath),h.setAttribute("title","Open file"),h.tagName.toLowerCase()!=="a"&&(h.setAttribute("role","button"),h.setAttribute("tabindex","0")))})}},S=async y=>{const w=y.getAttribute("data-openchamber-file-ref")||be(y),h=we(w,r);if(!h)return;const I=ar(r,h.resolvedPath);if(o&&a){a.openFile(h.resolvedPath,Number.isFinite(h.line??Number.NaN)?Math.max(1,Math.trunc(h.line)):void 0,Number.isFinite(h.column??Number.NaN)?Math.max(1,Math.trunc(h.column)):void 0);return}Se(h.resolvedPath,r)||await qt(h.resolvedPath,r);const b=Y.getState();Number.isFinite(h.line??Number.NaN)?b.openContextFileAtLine(I,h.resolvedPath,Math.max(1,Math.trunc(h.line)),Number.isFinite(h.column??Number.NaN)?Math.max(1,Math.trunc(h.column)):1):b.openContextFile(I,h.resolvedPath)},M=y=>{const w=y.target;if(!(w instanceof Element))return;const h=w.closest(Be);h instanceof HTMLElement&&(y.preventDefault(),y.stopPropagation(),S(h))},m=y=>{if(y.key!=="Enter"&&y.key!==" ")return;const w=y.target;!(w instanceof HTMLElement)||w.getAttribute("data-openchamber-file-link")!=="true"||(y.preventDefault(),y.stopPropagation(),S(w))};v(ze);const L=new MutationObserver(()=>{v(ze)});return L.observe(d,{childList:!0,subtree:!0}),d.addEventListener("click",M),d.addEventListener("keydown",m),()=>{u=!0,s.current!==null&&typeof window<"u"&&window.clearTimeout(s.current),s.current=null,L.disconnect(),d.removeEventListener("click",M),d.removeEventListener("keydown",m)}},l=[n,a,r,o,i],e[0]=n,e[1]=a,e[2]=r,e[3]=i,e[4]=o,e[5]=c,e[6]=l):(c=e[5],l=e[6]),N.useEffect(c,l)},gt=t=>{const e=K.c(7),{containerRef:n,onShowPopup:r,enableFullscreen:a,enablePanZoom:o,allowMermaidWheelEvents:i}=t;let s,c;e[0]!==i||e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r?(s=()=>{const l=n.current;if(!l)return;const d=f=>{if(!a||!r)return;const p=f.target;if(!(p instanceof Element)||p.closest('button, a, [role="button"]'))return;const g=p.closest(oe);if(!g)return;if(g instanceof HTMLElement&&g.hasAttribute("data-mermaid-suppress-click")){g.removeAttribute("data-mermaid-suppress-click");return}const v=Array.from(l.querySelectorAll(oe)).indexOf(g);if(v<0)return;const A=g instanceof HTMLElement?g.getAttribute("data-md-source"):null;if(!A||A.trim().length===0)return;const S=`Diagram ${v+1}`;r({open:!0,title:S,content:"",metadata:{tool:"mermaid-preview",filename:S},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(A)}`,source:A,filename:S}})},u=f=>{if(i||(f.ctrlKey||f.metaKey)&&o)return;const p=f.target;!(p instanceof Element)||!p.closest(oe)||f.stopPropagation()};return l.addEventListener("click",d),l.addEventListener("wheel",u,{capture:!0,passive:!0}),()=>{l.removeEventListener("click",d),l.removeEventListener("wheel",u,!0)}},c=[i,n,a,o,r],e[0]=i,e[1]=n,e[2]=a,e[3]=o,e[4]=r,e[5]=s,e[6]=c):(s=e[5],c=e[6]),N.useEffect(s,c)},ye=64,sr=24,ir=ye/sr,cr=/[\s.,!?;:)\]]/,lr=t=>{const e=t<=12?2:t<=48?4:t<=96?8:Math.min(24,Math.ceil(t/8));return Math.max(1,Math.round(e*ir))},dr=(t,e)=>{const n=Math.min(t.length,e+lr(t.length-e));for(let r=n;r<Math.min(t.length,n+8);r+=1)if(cr.test(t[r]??""))return r+1;return n},ur=(t,e)=>{const[n,r]=N.useState(()=>e?0:t.length),a=N.useRef(n);return a.current=n,N.useEffect(()=>{if(!e||typeof window>"u"){r(t.length);return}a.current>t.length&&r(t.length);let o=null;const i=()=>{const s=Math.min(a.current,t.length);if(s>=t.length){o=null;return}r(dr(t,s)),o=window.setTimeout(i,ye)};return a.current<t.length&&(o=window.setTimeout(i,ye)),()=>{o!==null&&window.clearTimeout(o)}},[t,e]),e?t.slice(0,Math.min(n,t.length)):t},V=new Map,mr=100,fr=(t,e)=>{const n=V.get(t);if(n)return V.delete(t),V.set(t,n),n;const r=e();if(V.set(t,r),V.size>mr){const a=V.keys().next().value;a&&V.delete(a)}return r},pr=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"}),bt=(t,e,n,r=Q)=>{const{t:a}=Ft(),o=N.useMemo(()=>({copy:a("markdownRenderer.code.actions.copyTitle"),copied:a("markdownRenderer.code.actions.copiedTitle"),enableCodeWrap:a("markdownRenderer.code.actions.enableWrapTitle"),disableCodeWrap:a("markdownRenderer.code.actions.disableWrapTitle"),copyTable:a("markdownRenderer.table.actions.copyTitle"),downloadTable:a("markdownRenderer.table.actions.downloadTitle"),copyDiagram:a("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:a("markdownRenderer.mermaid.actions.downloadSvgTitle"),zoomInDiagram:a("markdownRenderer.mermaid.actions.zoomInTitle"),zoomOutDiagram:a("markdownRenderer.mermaid.actions.zoomOutTitle"),resetDiagramView:a("markdownRenderer.mermaid.actions.resetViewTitle"),previewLabel:a("terminalView.preview.open"),previewTitle:a("terminalView.preview.openTitle")}),[a]),i=Y(l=>l.codeBlockLineWrap),s=Y(l=>l.setCodeBlockLineWrap),c=N.useCallback(()=>{s(!Y.getState().codeBlockLineWrap)},[s]);return N.useMemo(()=>{const l=pr(t),d=Y.getState().mermaidRenderingMode,u=t.metadata?.id??"theme";return{labels:o,mermaidControls:r,codeBlockLineWrap:i,deferCodeLineNumberSync:e,onToggleCodeBlockLineWrap:c,renderMermaid:p=>fr(`${u}:${d}:${p}`,()=>{try{return d==="ascii"?{ascii:Et(p)}:{svg:kt(p,l)}}catch{return{}}}),onPreviewLoopback:n}},[t,o,r,i,e,c,n])},wt=t=>{const e=K.c(36),{containerRef:n,text:r,streaming:a,cacheKey:o,syntaxVars:i,ctx:s}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0],N.useEffect(yr,c);const l=N.useRef(null);let d;e[1]!==n?(d=()=>{const b=n.current;if(b){if(!l.current){if(!B(b))return;l.current=xn(b);return}l.current.refresh()}},e[1]=n,e[2]=d):d=e[2];const u=d;let f,p;e[3]!==n||e[4]!==s||e[5]!==u||e[6]!==r?(f=()=>{const b=n.current,E=b?.querySelector("[data-markdown-content]")??b;if(E&&r&&E.childNodes.length===0){const C=document.createElement("div");C.setAttribute("data-md-block",""),C.style.display="contents",C.innerHTML=dn(r),De(C,s),E.appendChild(C),B(C)&&u()}},p=[n,r,s,u],e[3]=n,e[4]=s,e[5]=u,e[6]=r,e[7]=f,e[8]=p):(f=e[7],p=e[8]),N.useLayoutEffect(f,p);let g,k;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=()=>()=>{l.current?.cleanup(),l.current=null},k=[],e[9]=g,e[10]=k):(g=e[9],k=e[10]),N.useEffect(g,k);let v,A;e[11]!==o||e[12]!==n||e[13]!==s||e[14]!==u||e[15]!==a||e[16]!==r?(v=()=>{const b=n.current;if(!b)return;const E=b.querySelector("[data-markdown-content]")??b;let C=!0;return un(r,a,o).then(R=>{if(!C)return;const F=Array.from(E.children);R.forEach((x,P)=>{let T=F[P];if(T||(T=document.createElement("div"),T.setAttribute("data-md-block",""),T.style.display="contents",E.appendChild(T)),T.getAttribute("data-md-id")===x.id)return;const D=document.createElement("div");D.innerHTML=x.html,De(D,s);const j=B(T),q=B(D);vt(T,D,{childrenOnly:!0,onBeforeElUpdated:Ar}),T.setAttribute("data-md-id",x.id),(j||q||B(T))&&u()});const $=B(E);let O=!1;for(let x=F.length-1;x>=R.length;x=x-1,x){const P=F[x];P&&B(P)&&(O=!0),P?.remove()}(O||F.length>R.length&&$)&&u(),s.deferCodeLineNumberSync||ke(E)}),()=>{C=!1}},A=[n,r,a,o,s,u],e[11]=o,e[12]=n,e[13]=s,e[14]=u,e[15]=a,e[16]=r,e[17]=v,e[18]=A):(v=e[17],A=e[18]),N.useEffect(v,A);let S,M;e[19]!==n||e[20]!==s?(M=()=>{const b=n.current;if(b)return Wn(b,s)},S=[n,s],e[19]=n,e[20]=s,e[21]=S,e[22]=M):(S=e[21],M=e[22]),N.useEffect(M,S);let m,L;e[23]!==n||e[24]!==i?(m=()=>{const b=n.current,E=b?.querySelector("[data-markdown-content]")??b;if(E)for(const[C,R]of Object.entries(i))E.style.setProperty(C,R)},L=[n,i],e[23]=n,e[24]=i,e[25]=m,e[26]=L):(m=e[25],L=e[26]),N.useEffect(m,L);let y,w;e[27]!==n||e[28]!==s.codeBlockLineWrap||e[29]!==s.deferCodeLineNumberSync||e[30]!==s.labels?(y=()=>{const b=n.current,E=b?.querySelector("[data-markdown-content]")??b;E&&(s.deferCodeLineNumberSync||Tn(E,s.codeBlockLineWrap,s.labels))},w=[n,s.codeBlockLineWrap,s.deferCodeLineNumberSync,s.labels],e[27]=n,e[28]=s.codeBlockLineWrap,e[29]=s.deferCodeLineNumberSync,e[30]=s.labels,e[31]=y,e[32]=w):(y=e[31],w=e[32]),N.useEffect(y,w);let h,I;e[33]!==n?(h=()=>{const b=n.current,E=b?.querySelector("[data-markdown-content]")??b;if(!E||typeof ResizeObserver>"u")return;let C=null;const R=new ResizeObserver(()=>{C!==null&&window.cancelAnimationFrame(C),C=window.requestAnimationFrame(()=>{C=null,st(E)})});return R.observe(E),()=>{R.disconnect(),C!==null&&window.cancelAnimationFrame(C)}},I=[n],e[33]=n,e[34]=h,e[35]=I):(h=e[34],I=e[35]),N.useEffect(h,I)},yt=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",hr=t=>{const e=K.c(32),{content:n,part:r,messageId:a,isAnimated:o,skipFadeIn:i,className:s,isStreaming:c,disableStreamAnimation:l,variant:d,onShowPopup:u,enableFileReferences:f}=t,p=o===void 0?!0:o,g=i===void 0?!1:i,k=c===void 0?!1:c,v=l===void 0?!1:l,A=d===void 0?"assistant":d,S=f===void 0?!0:f,M=ct(),{editor:m,runtime:L}=Ze(),y=N.useRef(null),w=Xe()??"",h=Y(Er);let I;e[0]!==w||e[1]!==h?(I=X=>{w&&h(w,X)},e[0]=w,e[1]=h,e[2]=I):I=e[2];const b=I,E=k&&!v,C=ur(n,E);let R;e[3]!==u?(R={containerRef:y,onShowPopup:u,enableFullscreen:dt,enablePanZoom:Q.showPanZoomControls},e[3]=u,e[4]=R):R=e[4],gt(R);const F=S&&!k;let $;e[5]!==m||e[6]!==w||e[7]!==L.isVSCode||e[8]!==F?($={containerRef:y,effectiveDirectory:w,editor:m,preferRuntimeEditor:L.isVSCode,enabled:F},e[5]=m,e[6]=w,e[7]=L.isVSCode,e[8]=F,e[9]=$):$=e[9],ht($);let O;e[10]===Symbol.for("react.memo_cache_sentinel")?(O={containerRef:y},e[10]=O):O=e[10],lt(O);let x;e[11]!==M?(x=Ge(M),e[11]=M,e[12]=x):x=e[12];const P=x,T=bt(M,E,w?b:void 0,Q),D=`markdown-${r?.id?`part-${r.id}`:`message-${a}`}`;let j;e[13]!==D||e[14]!==T||e[15]!==E||e[16]!==C||e[17]!==P?(j={containerRef:y,text:C,streaming:E,cacheKey:D,syntaxVars:P,ctx:T},e[13]=D,e[14]=T,e[15]=E,e[16]=C,e[17]=P,e[18]=j):j=e[18],wt(j);let q;e[19]!==s?(q=Ye("break-words w-full min-w-0",s),e[19]=s,e[20]=q):q=e[20];let U;e[21]!==A?(U=yt(A),e[21]=A,e[22]=U):U=e[22];let Z;e[23]!==U?(Z=re.jsx("div",{className:U,"data-markdown-content":!0}),e[23]=U,e[24]=Z):Z=e[24];let ae;e[25]!==q||e[26]!==Z?(ae=re.jsx("div",{className:q,ref:y,children:Z}),e[25]=q,e[26]=Z,e[27]=ae):ae=e[27];const se=ae;if(p){let X;return e[28]!==D||e[29]!==se||e[30]!==g?(X=re.jsx(Dt,{skipAnimation:g,children:se},D),e[28]=D,e[29]=se,e[30]=g,e[31]=X):X=e[31],X}return se},Sr=N.memo(hr,(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),gr=t=>{const e=K.c(30),{content:n,className:r,variant:a,disableLinkSafety:o,stripFrontmatter:i,onShowPopup:s,mermaidControls:c,allowMermaidWheelEvents:l,enableFileReferences:d}=t,u=a===void 0?"assistant":a,f=i===void 0?!1:i,p=c===void 0?Q:c,g=l===void 0?!1:l,k=d===void 0?!0:d,{editor:v,runtime:A}=Ze(),S=ct(),M=N.useRef(null),m=Xe()??"";let L;e[0]!==n||e[1]!==f?(L=f?Hn(n):n,e[0]=n,e[1]=f,e[2]=L):L=e[2];const y=L;let w;e[3]!==g||e[4]!==p.showPanZoomControls||e[5]!==s?(w={containerRef:M,onShowPopup:s,enableFullscreen:dt,enablePanZoom:p.showPanZoomControls,allowMermaidWheelEvents:g},e[3]=g,e[4]=p.showPanZoomControls,e[5]=s,e[6]=w):w=e[6],gt(w);let h;e[7]!==v||e[8]!==m||e[9]!==k||e[10]!==A.isVSCode?(h={containerRef:M,effectiveDirectory:m,editor:v,preferRuntimeEditor:A.isVSCode,enabled:k},e[7]=v,e[8]=m,e[9]=k,e[10]=A.isVSCode,e[11]=h):h=e[11],ht(h);const I=!o;let b;e[12]!==I?(b={containerRef:M,enabled:I},e[12]=I,e[13]=b):b=e[13],lt(b);let E;e[14]!==S?(E=Ge(S),e[14]=S,e[15]=E):E=e[15];const C=E,R=bt(S,!1,void 0,p),F=`simple:${u}`;let $;e[16]!==R||e[17]!==y||e[18]!==C||e[19]!==F?($={containerRef:M,text:y,streaming:!1,cacheKey:F,syntaxVars:C,ctx:R},e[16]=R,e[17]=y,e[18]=C,e[19]=F,e[20]=$):$=e[20],wt($);let O;e[21]!==r?(O=Ye("break-words w-full min-w-0",r),e[21]=r,e[22]=O):O=e[22];let x;e[23]!==u?(x=yt(u),e[23]=u,e[24]=x):x=e[24];let P;e[25]!==x?(P=re.jsx("div",{className:x,"data-markdown-content":!0}),e[25]=x,e[26]=P):P=e[26];let T;return e[27]!==O||e[28]!==P?(T=re.jsx("div",{className:O,ref:M,children:P}),e[27]=O,e[28]=P,e[29]=T):T=e[29],T},Lr=N.memo(gr,(t,e)=>{const n=t.mermaidControls??Q,r=e.mermaidControls??Q;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 br(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")??"";Ue(r)&&(t.preventDefault(),t.stopPropagation(),Wt(r))}function wr(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 yr(){$t()}function Ar(t,e){return!t.isEqualNode(e)}function Er(t){return t.openContextPreview}export{Sr as MarkdownRenderer,Lr as SimpleMarkdownRenderer};
11
+ ${a}`},Oe=(t,e)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${Rt}`,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 a=document.createElement("button");a.type="button",a.className=`w-full text-left ${Tt}`,a.setAttribute("data-md-action",`${t}-${r.key}`),a.textContent=r.label,n.appendChild(a)}return n},$n=(t,e)=>{const n=t.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const i=document.createElement("div");i.className="flex items-center justify-end gap-1";const s=document.createElement("div");s.className="relative",s.appendChild(W("copy",e.copyTable,"table-copy-toggle")),s.appendChild(Oe("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const c=document.createElement("div");c.className="relative",c.appendChild(W("download",e.downloadTable,"table-download-toggle")),c.appendChild(Oe("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),i.appendChild(s),i.appendChild(c);const l=document.createElement("div");l.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const d=r.parentElement;if(!d)continue;d.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const f of Array.from(r.querySelectorAll("tr")))f.classList.add("border-b","border-border/60");const u=r.querySelector("tbody tr:last-child");u?.classList.remove("border-b"),u?.classList.add("border-0");for(const f of Array.from(r.querySelectorAll("th")))f.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 f of Array.from(r.querySelectorAll("td")))f.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");l.appendChild(r),o.appendChild(i),o.appendChild(l)}},On=(t,e)=>{const n=t.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const a=r.parentElement;if(!a)continue;const o=(r.textContent??"").replace(/\s+$/,""),i=e.renderMermaid(o),s=document.createElement("div");s.setAttribute("data-markdown","mermaid-block"),s.setAttribute("data-md-source",o),s.className="group relative";const c=document.createElement("div");c.setAttribute("data-markdown","mermaid-scroll");const l=document.createElement("div");if(l.setAttribute("data-markdown","mermaid-toolbar"),l.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",i.svg){s.setAttribute("data-mermaid-render","svg");const u=document.createElement("div");u.setAttribute("data-markdown","mermaid-viewport");const f=document.createElement("div");if(f.setAttribute("data-markdown","mermaid"),f.setAttribute("data-md-original-svg",i.svg),f.innerHTML=i.svg,u.appendChild(f),c.appendChild(u),e.mermaidControls.showPanZoomControls&&(l.appendChild(W("zoomIn",e.labels.zoomInDiagram,"mermaid-zoom-in")),l.appendChild(W("zoomOut",e.labels.zoomOutDiagram,"mermaid-zoom-out")),l.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",o),l.appendChild(p)}if(e.mermaidControls.download){const p=W("download",e.labels.downloadDiagram,"mermaid-download");p.setAttribute("data-md-svg","1"),l.appendChild(p)}}else{s.setAttribute("data-mermaid-render","ascii");const u=document.createElement("pre");if(u.setAttribute("data-markdown","mermaid-ascii"),u.textContent=i.ascii||o,c.appendChild(u),e.mermaidControls.copy){const f=W("copy",e.labels.copyDiagram,"mermaid-copy");f.setAttribute("data-md-source",i.ascii||o),l.appendChild(f)}}s.appendChild(c),s.appendChild(l);const d=a.parentElement;d&&d.replaceChild(s,a)}},Dn=(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 a=r.getAttribute("href")??"";if(!Ue(a))continue;r.setAttribute("data-md-link-decorated","true");const o=Nt(a);if(o){const i=document.createElement("span");i.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const s=document.createElement("img");s.src=o,s.alt="",s.setAttribute("aria-hidden","true"),s.loading="lazy",s.decoding="async",s.className="size-3.5 rounded-sm",s.addEventListener("error",()=>i.remove(),{once:!0}),i.appendChild(s),r.parentNode?.insertBefore(i,r)}if(e.onPreviewLoopback&&xt(a)){const i=document.createElement("button");i.type="button",i.className=`ml-1 align-middle ${rt}`,i.setAttribute("data-md-action","preview-loopback"),i.setAttribute("data-md-url",a),i.setAttribute("title",e.labels.previewTitle),i.setAttribute("aria-label",e.labels.previewLabel),me(i,ue.download),r.parentNode?.insertBefore(i,r.nextSibling)}}},De=(t,e)=>{_n(t),On(t,e),Pn(t,e),$n(t,e.labels),Dn(t,e)},We=(t,e,n)=>{const r=new Blob([e],{type:n}),a=URL.createObjectURL(r),o=document.createElement("a");o.href=a,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},ie=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},Wn=(t,e)=>{const n=r=>{const a=r.target;if(!(a instanceof Element))return;const o=a.closest("[data-md-action]");if(!o){ie(t);return}const i=o.getAttribute("data-md-action")??"";if(i==="copy-code"){const c=o.closest('[data-component="markdown-code"]')?.querySelector("code")?.textContent??"";c&&pe(c).then(()=>Pe(o,e.labels.copied,"copy",e.labels.copy));return}if(i==="toggle-code-wrap"){r.preventDefault(),e.onToggleCodeBlockLineWrap?.();return}if(i==="table-copy-toggle"||i==="table-download-toggle"){r.preventDefault();const s=o.parentElement?.querySelector("[data-md-menu]")??null,c=s?.classList.contains("hidden")??!1;ie(t),s&&c&&s.classList.remove("hidden");return}if(i.startsWith("table-copy-")){const s=i.replace("table-copy-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const l=Ie(c),d=s==="csv"?Fe(l):s==="tsv"?Fn(l):$e(l);pe(d)}ie(t);return}if(i.startsWith("table-download-")){const s=i.replace("table-download-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const l=Ie(c),d=s==="csv"?Fe(l):$e(l);We(s==="csv"?"table.csv":"table.md",d,s==="csv"?"text/csv":"text/markdown")}ie(t);return}if(i==="mermaid-copy"){const s=o.getAttribute("data-md-source")??"";s&&pe(s).then(()=>Pe(o,e.labels.copied,"copy",e.labels.copyDiagram));return}if(i==="mermaid-zoom-in"||i==="mermaid-zoom-out"||i==="mermaid-fit"){r.preventDefault();const s=o.closest('[data-markdown="mermaid-block"]'),c=Cn(s);i==="mermaid-zoom-in"?c?.zoomIn():i==="mermaid-zoom-out"?c?.zoomOut():c?.fit();return}if(i==="mermaid-download"){const s=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),c=s?.getAttribute("data-md-original-svg")??s?.innerHTML??"";c&&We("diagram.svg",c,"image/svg+xml;charset=utf-8");return}if(i==="preview-loopback"){r.preventDefault();const s=o.getAttribute("data-md-url")??"";s&&e.onPreviewLoopback?.(s);return}};return t.addEventListener("click",n),()=>t.removeEventListener("click",n)},qn=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),qe=Array.from(qn).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Bn=t=>Pt(t),zn=t=>_t(t),fe=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):""},ce=t=>{let e=fe(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 a=qe.length>0?e.match(new RegExp(`^(.*(?:/|^)(${qe})):.*$`,"i")):null;return a&&(e=a[1]??e),fe(e)},it=t=>{const e=fe(t);if(!e)return null;const n=e.indexOf(";"),r=n>=0?fe(e.slice(0,n)):e;if(!r)return null;const a=r.match(/^(.*?):(\d+)-(\d+)$/);if(a){const c=ce(a[1]??""),l=Number.parseInt(a[2]??"",10),d=Number.parseInt(a[3]??"",10);return!c||!Number.isFinite(l)||!Number.isFinite(d)||d<l?null:{path:c,line:l,endLine:d}}const o=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const c=ce(o[1]??""),l=Number.parseInt(o[2]??"",10),d=o[3]?Number.parseInt(o[3],10):void 0;return!c||!Number.isFinite(l)?null:{path:c,line:l,column:Number.isFinite(d??Number.NaN)?d:void 0}}const i=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(i){const c=ce(i[1]??""),l=Number.parseInt(i[2]??"",10),d=i[3]?Number.parseInt(i[3],10):void 0;return!c||!Number.isFinite(l)?null:{path:c,line:l,column:Number.isFinite(d??Number.NaN)?d:void 0}}const s=ce(r);return s?{path:s}:null},ge=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,ct=()=>{const t=K.c(4),e=It();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=Ce(!1),t[0]=n):n=t[0];const r=n;let a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=Ce(!0),t[1]=a):a=t[1];const o=a;let i;return t[2]!==e?.currentTheme?(i=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:r),t[2]=e?.currentTheme,t[3]=i):i=t[3],i},lt=t=>{const e=K.c(4),{containerRef:n,enabled:r}=t;let a,o;e[0]!==n||e[1]!==r?(a=()=>{if(r===!1)return;const i=n.current;if(!i)return;const s=br;return i.addEventListener("click",s),()=>{i.removeEventListener("click",s)}},o=[n,r],e[0]=n,e[1]=r,e[2]=a,e[3]=o):(a=e[2],o=e[3]),N.useEffect(a,o)},Q={download:!0,copy:!0,showPanZoomControls:!0},dt=!0,Hn=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},Be='[data-openchamber-file-link="true"]',ut="data-openchamber-block-path-token",mt=`[${ut}]`,J="data-openchamber-block-paths-scanned",Vn=2e5,Kn=4,jn=1e3,Un=200,Xn=80,Zn=40,ze=160,H=new Map;let le=0;const He=[],Gn=()=>Ae()?Un:jn,Yn=()=>Ae()?Zn:Xn,Jn=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),ve=t=>Bn(t),Qn=t=>zn(t),er=(t,e)=>zt(t,e),tr=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},ft=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=ve(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return Jn.has(r)||r.startsWith(".")&&r.length>1?!0:tr(e)},pt=t=>{const e=it(t);return e?ft(e.path):!1},Ve=(t,e)=>{let n=0;for(const a of t){const o=n+a.data.length;if(e<=o)return{node:a,offset:Math.max(0,e-n)};n=o}const r=t.at(-1);return r?{node:r,offset:r.data.length}:null},nr=t=>{const e=t.querySelectorAll(mt);for(const r of Array.from(e))r.replaceWith(t.ownerDocument.createTextNode(r.textContent??""));const n=t.querySelectorAll(`code[${J}]`);for(const r of Array.from(n))r.removeAttribute(J),r.normalize()},be=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim();if(e&&pt(e))return e}return(t.textContent||"").trim()},rr=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(J)==="true")continue;if((r.textContent??"").length>Vn){r.setAttribute(J,"true");continue}const a=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let i=a.nextNode();for(;i;)o.push(i),i=a.nextNode();const s=r.textContent??"";if(!s.includes(".")){r.setAttribute(J,"true");continue}ge.lastIndex=0;const c=[];let l=ge.exec(s);for(;l;){const d=l[0];d&&pt(d)&&c.push({start:l.index,end:l.index+d.length,raw:d}),l=ge.exec(s)}for(const{start:d,end:u,raw:f}of c.reverse()){const p=Ve(o,d),g=Ve(o,u);if(!p||!g)continue;const k=n.createRange();k.setStart(p.node,p.offset),k.setEnd(g.node,g.offset);const v=n.createElement("span");v.setAttribute(ut,"true"),v.textContent=f,k.deleteContents(),k.insertNode(v)}r.setAttribute(J,"true")}},we=(t,e)=>{const n=it(t);if(!n||!ft(n.path))return null;const r=Qn(n.path)?ve(n.path):er(e,n.path);return r?{...n,resolvedPath:r}:null},or=t=>{const e=ve(t);if(!e)return Promise.resolve(!1);const n=H.get(e);if(n)return H.delete(e),H.set(e,n),n;const r=new Promise(o=>{const i=()=>{le+=1,Kt(`/api/fs/stat?path=${encodeURIComponent(e)}&optional=true`,{method:"GET",cache:"no-store"}).then(async s=>{if(!s.ok){o(!1);return}const c=await s.json().catch(()=>null);o(c?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{le=Math.max(0,le-1),He.shift()?.()})};if(le<Kn){i();return}He.push(i)}),a=Gn();for(;H.size>=a;){const o=H.keys().next().value;if(typeof o!="string")break;H.delete(o)}return H.set(e,r),r},ar=(t,e)=>t||Bt(t,e),ht=t=>{const e=K.c(7),{containerRef:n,effectiveDirectory:r,editor:a,preferRuntimeEditor:o,enabled:i}=t,s=N.useRef(null);let c,l;e[0]!==n||e[1]!==a||e[2]!==r||e[3]!==i||e[4]!==o?(c=()=>{const d=n.current;if(!d)return;let u=!1;const f=Yn(),p=i&&!Ot(),g=wr,k=()=>{const y=d.querySelectorAll(Be);for(const w of Array.from(y))g(w);nr(d)};if(!p){k();return}const v=y=>{const w=y;if(s.current!==null&&typeof window<"u"&&window.clearTimeout(s.current),typeof window>"u"){A();return}s.current=window.setTimeout(()=>{s.current=null,window.requestAnimationFrame(()=>{u||A()})},w)},A=()=>{p&&rr(d);const y=d.querySelectorAll(`[data-markdown="inline-code"], a, ${mt}`);let w=0;for(const h of Array.from(y)){const P=be(h),b=we(P,r);if(g(h),!b||w>=f)continue;w=w+1,(Ht()&&Vt()&&!Se(b.resolvedPath,r)?Promise.resolve(!0):or(b.resolvedPath)).then(R=>{if(u||!R||!d.contains(h))return;const F=be(h),$=we(F,r);!$||$.resolvedPath!==b.resolvedPath||(h.setAttribute("data-openchamber-file-link","true"),h.setAttribute("data-openchamber-file-ref",F),h.setAttribute("data-openchamber-file-path",$.resolvedPath),h.setAttribute("title","Open file"),h.tagName.toLowerCase()!=="a"&&(h.setAttribute("role","button"),h.setAttribute("tabindex","0")))})}},S=async y=>{const w=y.getAttribute("data-openchamber-file-ref")||be(y),h=we(w,r);if(!h)return;const P=ar(r,h.resolvedPath);if(o&&a){a.openFile(h.resolvedPath,Number.isFinite(h.line??Number.NaN)?Math.max(1,Math.trunc(h.line)):void 0,Number.isFinite(h.column??Number.NaN)?Math.max(1,Math.trunc(h.column)):void 0);return}Se(h.resolvedPath,r)||await qt(h.resolvedPath,r);const b=Y.getState();Number.isFinite(h.line??Number.NaN)?b.openContextFileAtLine(P,h.resolvedPath,Math.max(1,Math.trunc(h.line)),Number.isFinite(h.column??Number.NaN)?Math.max(1,Math.trunc(h.column)):1):b.openContextFile(P,h.resolvedPath)},M=y=>{const w=y.target;if(!(w instanceof Element))return;const h=w.closest(Be);h instanceof HTMLElement&&(y.preventDefault(),y.stopPropagation(),S(h))},m=y=>{if(y.key!=="Enter"&&y.key!==" ")return;const w=y.target;!(w instanceof HTMLElement)||w.getAttribute("data-openchamber-file-link")!=="true"||(y.preventDefault(),y.stopPropagation(),S(w))};v(ze);const L=new MutationObserver(()=>{v(ze)});return L.observe(d,{childList:!0,subtree:!0}),d.addEventListener("click",M),d.addEventListener("keydown",m),()=>{u=!0,s.current!==null&&typeof window<"u"&&window.clearTimeout(s.current),s.current=null,L.disconnect(),d.removeEventListener("click",M),d.removeEventListener("keydown",m)}},l=[n,a,r,o,i],e[0]=n,e[1]=a,e[2]=r,e[3]=i,e[4]=o,e[5]=c,e[6]=l):(c=e[5],l=e[6]),N.useEffect(c,l)},gt=t=>{const e=K.c(7),{containerRef:n,onShowPopup:r,enableFullscreen:a,enablePanZoom:o,allowMermaidWheelEvents:i}=t;let s,c;e[0]!==i||e[1]!==n||e[2]!==a||e[3]!==o||e[4]!==r?(s=()=>{const l=n.current;if(!l)return;const d=f=>{if(!a||!r)return;const p=f.target;if(!(p instanceof Element)||p.closest('button, a, [role="button"]'))return;const g=p.closest(oe);if(!g)return;if(g instanceof HTMLElement&&g.hasAttribute("data-mermaid-suppress-click")){g.removeAttribute("data-mermaid-suppress-click");return}const v=Array.from(l.querySelectorAll(oe)).indexOf(g);if(v<0)return;const A=g instanceof HTMLElement?g.getAttribute("data-md-source"):null;if(!A||A.trim().length===0)return;const S=`Diagram ${v+1}`;r({open:!0,title:S,content:"",metadata:{tool:"mermaid-preview",filename:S},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(A)}`,source:A,filename:S}})},u=f=>{if(i||(f.ctrlKey||f.metaKey)&&o)return;const p=f.target;!(p instanceof Element)||!p.closest(oe)||f.stopPropagation()};return l.addEventListener("click",d),l.addEventListener("wheel",u,{capture:!0,passive:!0}),()=>{l.removeEventListener("click",d),l.removeEventListener("wheel",u,!0)}},c=[i,n,a,o,r],e[0]=i,e[1]=n,e[2]=a,e[3]=o,e[4]=r,e[5]=s,e[6]=c):(s=e[5],c=e[6]),N.useEffect(s,c)},ye=64,sr=24,ir=ye/sr,cr=/[\s.,!?;:)\]]/,lr=t=>{const e=t<=12?2:t<=48?4:t<=96?8:Math.min(24,Math.ceil(t/8));return Math.max(1,Math.round(e*ir))},dr=(t,e)=>{const n=Math.min(t.length,e+lr(t.length-e));for(let r=n;r<Math.min(t.length,n+8);r+=1)if(cr.test(t[r]??""))return r+1;return n},ur=(t,e)=>{const[n,r]=N.useState(()=>e?0:t.length),a=N.useRef(n);return a.current=n,N.useEffect(()=>{if(!e||typeof window>"u"){r(t.length);return}a.current>t.length&&r(t.length);let o=null;const i=()=>{const s=Math.min(a.current,t.length);if(s>=t.length){o=null;return}r(dr(t,s)),o=window.setTimeout(i,ye)};return a.current<t.length&&(o=window.setTimeout(i,ye)),()=>{o!==null&&window.clearTimeout(o)}},[t,e]),e?t.slice(0,Math.min(n,t.length)):t},V=new Map,mr=100,fr=(t,e)=>{const n=V.get(t);if(n)return V.delete(t),V.set(t,n),n;const r=e();if(V.set(t,r),V.size>mr){const a=V.keys().next().value;a&&V.delete(a)}return r},pr=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"}),bt=(t,e,n,r=Q)=>{const{t:a}=Ft(),o=N.useMemo(()=>({copy:a("markdownRenderer.code.actions.copyTitle"),copied:a("markdownRenderer.code.actions.copiedTitle"),enableCodeWrap:a("markdownRenderer.code.actions.enableWrapTitle"),disableCodeWrap:a("markdownRenderer.code.actions.disableWrapTitle"),copyTable:a("markdownRenderer.table.actions.copyTitle"),downloadTable:a("markdownRenderer.table.actions.downloadTitle"),copyDiagram:a("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:a("markdownRenderer.mermaid.actions.downloadSvgTitle"),zoomInDiagram:a("markdownRenderer.mermaid.actions.zoomInTitle"),zoomOutDiagram:a("markdownRenderer.mermaid.actions.zoomOutTitle"),resetDiagramView:a("markdownRenderer.mermaid.actions.resetViewTitle"),previewLabel:a("terminalView.preview.open"),previewTitle:a("terminalView.preview.openTitle")}),[a]),i=Y(l=>l.codeBlockLineWrap),s=Y(l=>l.setCodeBlockLineWrap),c=N.useCallback(()=>{s(!Y.getState().codeBlockLineWrap)},[s]);return N.useMemo(()=>{const l=pr(t),d=Y.getState().mermaidRenderingMode,u=t.metadata?.id??"theme";return{labels:o,mermaidControls:r,codeBlockLineWrap:i,deferCodeLineNumberSync:e,onToggleCodeBlockLineWrap:c,renderMermaid:p=>fr(`${u}:${d}:${p}`,()=>{try{return d==="ascii"?{ascii:Et(p)}:{svg:kt(p,l)}}catch{return{}}}),onPreviewLoopback:n}},[t,o,r,i,e,c,n])},wt=t=>{const e=K.c(36),{containerRef:n,text:r,streaming:a,cacheKey:o,syntaxVars:i,ctx:s}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0],N.useEffect(yr,c);const l=N.useRef(null);let d;e[1]!==n?(d=()=>{const b=n.current;if(b){if(!l.current){if(!B(b))return;l.current=xn(b);return}l.current.refresh()}},e[1]=n,e[2]=d):d=e[2];const u=d;let f,p;e[3]!==n||e[4]!==s||e[5]!==u||e[6]!==r?(f=()=>{const b=n.current,E=b?.querySelector("[data-markdown-content]")??b;if(E&&r&&E.childNodes.length===0){const C=document.createElement("div");C.setAttribute("data-md-block",""),C.style.display="contents",C.innerHTML=dn(r),De(C,s),E.appendChild(C),B(C)&&u()}},p=[n,r,s,u],e[3]=n,e[4]=s,e[5]=u,e[6]=r,e[7]=f,e[8]=p):(f=e[7],p=e[8]),N.useLayoutEffect(f,p);let g,k;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=()=>()=>{l.current?.cleanup(),l.current=null},k=[],e[9]=g,e[10]=k):(g=e[9],k=e[10]),N.useEffect(g,k);let v,A;e[11]!==o||e[12]!==n||e[13]!==s||e[14]!==u||e[15]!==a||e[16]!==r?(v=()=>{const b=n.current;if(!b)return;const E=b.querySelector("[data-markdown-content]")??b;let C=!0;return un(r,a,o).then(R=>{if(!C)return;const F=Array.from(E.children);R.forEach((x,I)=>{let T=F[I];if(T||(T=document.createElement("div"),T.setAttribute("data-md-block",""),T.style.display="contents",E.appendChild(T)),T.getAttribute("data-md-id")===x.id)return;const D=document.createElement("div");D.innerHTML=x.html,De(D,s);const j=B(T),q=B(D);vt(T,D,{childrenOnly:!0,onBeforeElUpdated:Ar}),T.setAttribute("data-md-id",x.id),(j||q||B(T))&&u()});const $=B(E);let O=!1;for(let x=F.length-1;x>=R.length;x=x-1,x){const I=F[x];I&&B(I)&&(O=!0),I?.remove()}(O||F.length>R.length&&$)&&u(),s.deferCodeLineNumberSync||ke(E)}),()=>{C=!1}},A=[n,r,a,o,s,u],e[11]=o,e[12]=n,e[13]=s,e[14]=u,e[15]=a,e[16]=r,e[17]=v,e[18]=A):(v=e[17],A=e[18]),N.useEffect(v,A);let S,M;e[19]!==n||e[20]!==s?(M=()=>{const b=n.current;if(b)return Wn(b,s)},S=[n,s],e[19]=n,e[20]=s,e[21]=S,e[22]=M):(S=e[21],M=e[22]),N.useEffect(M,S);let m,L;e[23]!==n||e[24]!==i?(m=()=>{const b=n.current,E=b?.querySelector("[data-markdown-content]")??b;if(E)for(const[C,R]of Object.entries(i))E.style.setProperty(C,R)},L=[n,i],e[23]=n,e[24]=i,e[25]=m,e[26]=L):(m=e[25],L=e[26]),N.useEffect(m,L);let y,w;e[27]!==n||e[28]!==s.codeBlockLineWrap||e[29]!==s.deferCodeLineNumberSync||e[30]!==s.labels?(y=()=>{const b=n.current,E=b?.querySelector("[data-markdown-content]")??b;E&&(s.deferCodeLineNumberSync||Tn(E,s.codeBlockLineWrap,s.labels))},w=[n,s.codeBlockLineWrap,s.deferCodeLineNumberSync,s.labels],e[27]=n,e[28]=s.codeBlockLineWrap,e[29]=s.deferCodeLineNumberSync,e[30]=s.labels,e[31]=y,e[32]=w):(y=e[31],w=e[32]),N.useEffect(y,w);let h,P;e[33]!==n?(h=()=>{const b=n.current,E=b?.querySelector("[data-markdown-content]")??b;if(!E||typeof ResizeObserver>"u")return;let C=null;const R=new ResizeObserver(()=>{C!==null&&window.cancelAnimationFrame(C),C=window.requestAnimationFrame(()=>{C=null,st(E)})});return R.observe(E),()=>{R.disconnect(),C!==null&&window.cancelAnimationFrame(C)}},P=[n],e[33]=n,e[34]=h,e[35]=P):(h=e[34],P=e[35]),N.useEffect(h,P)},yt=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",hr=t=>{const e=K.c(32),{content:n,part:r,messageId:a,isAnimated:o,skipFadeIn:i,className:s,isStreaming:c,disableStreamAnimation:l,variant:d,onShowPopup:u,enableFileReferences:f}=t,p=o===void 0?!0:o,g=i===void 0?!1:i,k=c===void 0?!1:c,v=l===void 0?!1:l,A=d===void 0?"assistant":d,S=f===void 0?!0:f,M=ct(),{editor:m,runtime:L}=Xe(),y=N.useRef(null),w=Ze()??"",h=Y(Er);let P;e[0]!==w||e[1]!==h?(P=Z=>{w&&h(w,Z)},e[0]=w,e[1]=h,e[2]=P):P=e[2];const b=P,E=k&&!v,C=ur(n,E);let R;e[3]!==u?(R={containerRef:y,onShowPopup:u,enableFullscreen:dt,enablePanZoom:Q.showPanZoomControls},e[3]=u,e[4]=R):R=e[4],gt(R);const F=S&&!k;let $;e[5]!==m||e[6]!==w||e[7]!==L.isVSCode||e[8]!==F?($={containerRef:y,effectiveDirectory:w,editor:m,preferRuntimeEditor:L.isVSCode,enabled:F},e[5]=m,e[6]=w,e[7]=L.isVSCode,e[8]=F,e[9]=$):$=e[9],ht($);let O;e[10]===Symbol.for("react.memo_cache_sentinel")?(O={containerRef:y},e[10]=O):O=e[10],lt(O);let x;e[11]!==M?(x=Ge(M),e[11]=M,e[12]=x):x=e[12];const I=x,T=bt(M,E,w?b:void 0,Q),D=`markdown-${r?.id?`part-${r.id}`:`message-${a}`}`;let j;e[13]!==D||e[14]!==T||e[15]!==E||e[16]!==C||e[17]!==I?(j={containerRef:y,text:C,streaming:E,cacheKey:D,syntaxVars:I,ctx:T},e[13]=D,e[14]=T,e[15]=E,e[16]=C,e[17]=I,e[18]=j):j=e[18],wt(j);let q;e[19]!==s?(q=Ye("break-words w-full min-w-0",s),e[19]=s,e[20]=q):q=e[20];let U;e[21]!==A?(U=yt(A),e[21]=A,e[22]=U):U=e[22];let X;e[23]!==U?(X=re.jsx("div",{className:U,"data-markdown-content":!0}),e[23]=U,e[24]=X):X=e[24];let ae;e[25]!==q||e[26]!==X?(ae=re.jsx("div",{className:q,ref:y,children:X}),e[25]=q,e[26]=X,e[27]=ae):ae=e[27];const se=ae;if(p){let Z;return e[28]!==D||e[29]!==se||e[30]!==g?(Z=re.jsx(Dt,{skipAnimation:g,children:se},D),e[28]=D,e[29]=se,e[30]=g,e[31]=Z):Z=e[31],Z}return se},Sr=N.memo(hr,(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),gr=t=>{const e=K.c(30),{content:n,className:r,variant:a,disableLinkSafety:o,stripFrontmatter:i,onShowPopup:s,mermaidControls:c,allowMermaidWheelEvents:l,enableFileReferences:d}=t,u=a===void 0?"assistant":a,f=i===void 0?!1:i,p=c===void 0?Q:c,g=l===void 0?!1:l,k=d===void 0?!0:d,{editor:v,runtime:A}=Xe(),S=ct(),M=N.useRef(null),m=Ze()??"";let L;e[0]!==n||e[1]!==f?(L=f?Hn(n):n,e[0]=n,e[1]=f,e[2]=L):L=e[2];const y=L;let w;e[3]!==g||e[4]!==p.showPanZoomControls||e[5]!==s?(w={containerRef:M,onShowPopup:s,enableFullscreen:dt,enablePanZoom:p.showPanZoomControls,allowMermaidWheelEvents:g},e[3]=g,e[4]=p.showPanZoomControls,e[5]=s,e[6]=w):w=e[6],gt(w);let h;e[7]!==v||e[8]!==m||e[9]!==k||e[10]!==A.isVSCode?(h={containerRef:M,effectiveDirectory:m,editor:v,preferRuntimeEditor:A.isVSCode,enabled:k},e[7]=v,e[8]=m,e[9]=k,e[10]=A.isVSCode,e[11]=h):h=e[11],ht(h);const P=!o;let b;e[12]!==P?(b={containerRef:M,enabled:P},e[12]=P,e[13]=b):b=e[13],lt(b);let E;e[14]!==S?(E=Ge(S),e[14]=S,e[15]=E):E=e[15];const C=E,R=bt(S,!1,void 0,p),F=`simple:${u}`;let $;e[16]!==R||e[17]!==y||e[18]!==C||e[19]!==F?($={containerRef:M,text:y,streaming:!1,cacheKey:F,syntaxVars:C,ctx:R},e[16]=R,e[17]=y,e[18]=C,e[19]=F,e[20]=$):$=e[20],wt($);let O;e[21]!==r?(O=Ye("break-words w-full min-w-0",r),e[21]=r,e[22]=O):O=e[22];let x;e[23]!==u?(x=yt(u),e[23]=u,e[24]=x):x=e[24];let I;e[25]!==x?(I=re.jsx("div",{className:x,"data-markdown-content":!0}),e[25]=x,e[26]=I):I=e[26];let T;return e[27]!==O||e[28]!==I?(T=re.jsx("div",{className:O,ref:M,children:I}),e[27]=O,e[28]=I,e[29]=T):T=e[29],T},Lr=N.memo(gr,(t,e)=>{const n=t.mermaidControls??Q,r=e.mermaidControls??Q;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 br(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")??"";Ue(r)&&(t.preventDefault(),t.stopPropagation(),Wt(r))}function wr(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 yr(){$t()}function Ar(t,e){return!t.isEqualNode(e)}function Er(t){return t.openContextPreview}export{Sr as MarkdownRenderer,Lr as SimpleMarkdownRenderer};
@@ -1 +1 @@
1
- import{b as N,R as _,j as n,bl as D,bj as C,bk as I,bh as M,bf as S}from"./vendor-.bun-BE757pvp.js";import{c as z,v as w,I as O}from"./useAppFontEffects-DkPuAMXD.js";import{M as P}from"./main-B-GA5Tg5.js";import"./index-8J6waVO6.js";import"./runtimeEndpointReset-MTaPPm4F.js";import"./mobileLayoutPreference-Dio-WWkI.js";import"./SessionSwitcherDropdown-CWWrCFzr.js";const G=R=>{const e=N.c(33),{open:y,onOpenChange:t,initialPrompt:v}=R,i=_.useId(),{t:o}=z(),k=B;let s;e[0]!==t?(s=j=>{!j&&k()||t(j)},e[0]=t,e[1]=s):s=e[1];let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(D,{className:w("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]=b):b=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=w("relative pointer-events-auto","w-[90vw] max-w-[720px] h-[680px] max-h-[85vh]","flex flex-col rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]"),e[3]=h):h=e[3];let a;e[4]!==t?(a=()=>t(!1),e[4]=t,e[5]=a):a=e[5];let l;e[6]!==o?(l=o("multiRun.window.actions.closeAria"),e[6]=o,e[7]=l):l=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(O,{name:"close",className:"h-5 w-5"}),e[8]=x):x=e[8];let r;e[9]!==a||e[10]!==l?(r=n.jsx("div",{className:"absolute right-0.5 top-0.5 z-50",children:n.jsx("button",{type:"button",onClick:a,"aria-label":l,className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:x})}),e[9]=a,e[10]=l,e[11]=r):r=e[11];let c;e[12]!==o?(c=o("multiRun.window.description"),e[12]=o,e[13]=c):c=e[13];let d;e[14]!==i||e[15]!==c?(d=n.jsx(C,{id:i,className:"sr-only",children:c}),e[14]=i,e[15]=c,e[16]=d):d=e[16];let u,m;e[17]!==t?(u=()=>t(!1),m=()=>t(!1),e[17]=t,e[18]=u,e[19]=m):(u=e[18],m=e[19]);let f;e[20]!==v||e[21]!==u||e[22]!==m?(f=n.jsx(P,{initialPrompt:v,onCreated:u,onCancel:m,isWindowed:!0}),e[20]=v,e[21]=u,e[22]=m,e[23]=f):f=e[23];let p;e[24]!==i||e[25]!==f||e[26]!==r||e[27]!==d?(p=n.jsxs(I,{children:[b,n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:n.jsxs(M,{"aria-describedby":i,className:h,children:[r,d,f]})})]}),e[24]=i,e[25]=f,e[26]=r,e[27]=d,e[28]=p):p=e[28];let g;return e[29]!==y||e[30]!==s||e[31]!==p?(g=n.jsx(S,{open:y,onOpenChange:s,children:p}),e[29]=y,e[30]=s,e[31]=p,e[32]=g):g=e[32],g};function B(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{G as MultiRunWindow};
1
+ import{b as N,R as _,j as n,bl as D,bj as C,bk as I,bh as M,bf as S}from"./vendor-.bun-BE757pvp.js";import{c as z,v as w,I as O}from"./useAppFontEffects-9LFMCKYW.js";import{M as P}from"./main-B0CxEOP5.js";import"./index-BklNmnVr.js";import"./runtimeEndpointReset-B0P2DED1.js";import"./mobileLayoutPreference-Dio-WWkI.js";import"./SessionSwitcherDropdown-DHO5Je6v.js";const G=R=>{const e=N.c(33),{open:y,onOpenChange:t,initialPrompt:v}=R,i=_.useId(),{t:o}=z(),k=B;let s;e[0]!==t?(s=j=>{!j&&k()||t(j)},e[0]=t,e[1]=s):s=e[1];let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(D,{className:w("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]=b):b=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=w("relative pointer-events-auto","w-[90vw] max-w-[720px] h-[680px] max-h-[85vh]","flex flex-col rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]"),e[3]=h):h=e[3];let a;e[4]!==t?(a=()=>t(!1),e[4]=t,e[5]=a):a=e[5];let l;e[6]!==o?(l=o("multiRun.window.actions.closeAria"),e[6]=o,e[7]=l):l=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(O,{name:"close",className:"h-5 w-5"}),e[8]=x):x=e[8];let r;e[9]!==a||e[10]!==l?(r=n.jsx("div",{className:"absolute right-0.5 top-0.5 z-50",children:n.jsx("button",{type:"button",onClick:a,"aria-label":l,className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:x})}),e[9]=a,e[10]=l,e[11]=r):r=e[11];let c;e[12]!==o?(c=o("multiRun.window.description"),e[12]=o,e[13]=c):c=e[13];let d;e[14]!==i||e[15]!==c?(d=n.jsx(C,{id:i,className:"sr-only",children:c}),e[14]=i,e[15]=c,e[16]=d):d=e[16];let u,m;e[17]!==t?(u=()=>t(!1),m=()=>t(!1),e[17]=t,e[18]=u,e[19]=m):(u=e[18],m=e[19]);let f;e[20]!==v||e[21]!==u||e[22]!==m?(f=n.jsx(P,{initialPrompt:v,onCreated:u,onCancel:m,isWindowed:!0}),e[20]=v,e[21]=u,e[22]=m,e[23]=f):f=e[23];let p;e[24]!==i||e[25]!==f||e[26]!==r||e[27]!==d?(p=n.jsxs(I,{children:[b,n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:n.jsxs(M,{"aria-describedby":i,className:h,children:[r,d,f]})})]}),e[24]=i,e[25]=f,e[26]=r,e[27]=d,e[28]=p):p=e[28];let g;return e[29]!==y||e[30]!==s||e[31]!==p?(g=n.jsx(S,{open:y,onOpenChange:s,children:p}),e[29]=y,e[30]=s,e[31]=p,e[32]=g):g=e[32],g};function B(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{G as MultiRunWindow};
@@ -1 +1 @@
1
- import{r as E,j as t,R as a,b as z}from"./vendor-.bun-BE757pvp.js";import{ag as me,ak as oe,F as Z,af as ee,v as O,aa as B,h as M,L as re,O as ae,t as le,I as J}from"./index-8J6waVO6.js";import{c as V,B as U,w as W,y as ce,v as Q,I as T}from"./useAppFontEffects-DkPuAMXD.js";function pe(r){switch(r){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function q(r){return r==="wrong-service"||r==="unreachable"||r==="incompatible"}function ie({onBack:r,showBackButton:e=!0,initialUrl:c="",initialLabel:n="",isRecoveryMode:o=!1,onConnect:b,onSwitchToLocal:i}){const{t:s}=V(),[h,y]=E.useState(c),[x,S]=E.useState(n),[N,f]=E.useState("idle"),[m,v]=E.useState(null),[R,C]=E.useState(""),j=me(h),p=j?.persistedUrl??null,w=E.useCallback(d=>{y(d.target.value),f("idle"),v(null),C("")},[]),g=E.useCallback(d=>{S(d.target.value)},[]),k=E.useCallback(async()=>{if(p){f("testing"),v(null),C("");try{const d=await oe(p);v(d),f(d.status==="ok"||d.status==="update-recommended"?"success":"error")}catch(d){C(d instanceof Error?d.message:s("onboarding.remoteConnection.errors.connectionTestFailed")),f("error")}}},[p,s]),K=E.useCallback(async()=>{if(!j)return;const d=j.persistedUrl;f("testing"),v(null),C("");try{const D=await oe(d);if(v(D),q(D.status)){f("error");return}const P=await Z(),de=x.trim()||d,G=P.hosts.find($=>$.url===d),Y=G?G.id:`host-${Date.now().toString(16)}`,te={id:Y,label:de,url:d,apiUrl:d},ue=G?P.hosts.map($=>$.id===Y?te:$):[...P.hosts,te];if(await ee({hosts:ue,defaultHostId:Y,initialHostChoiceCompleted:!0}),b?.(),j.redeemUrl){window.location.assign(j.redeemUrl);return}O()&&await B()}catch(D){C(D instanceof Error?D.message:s("onboarding.remoteConnection.errors.failedToSaveConnection")),f("error")}},[j,x,b,s]),L=N==="testing",A=p!==null&&!L,I=p!==null&&!L&&!q(m?.status??null),F=pe(m?.status??null),H=m?.status==="ok",u=m?.status==="update-recommended",_=m?.status==="auth",l=q(m?.status??null);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e&&t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:s("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(o?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s("onboarding.remoteConnection.description")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx(W,{id:"remote-url",type:"url",value:h,onChange:w,placeholder:s("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:L})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.nameOptional")}),t.jsx(W,{id:"remote-label",type:"text",value:x,onChange:g,placeholder:s("onboarding.remoteConnection.field.namePlaceholder"),disabled:L})]})]}),m&&H&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:s("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&_&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:s("onboarding.remoteConnection.status.authWarning")}),m&&u&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:F?s(F):null}),m&&l&&t.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold mb-1",children:s("onboarding.remoteConnection.status.connectionFailed")}),t.jsx("div",{className:"opacity-90",children:F?s(F):null})]}),t.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?s("onboarding.remoteConnection.status.suggestionsUnreachable"):s("onboarding.remoteConnection.status.suggestionsWrongService")})]}),R&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:R}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(U,{variant:"outline",onClick:k,disabled:!A,children:s(L?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),t.jsx(U,{onClick:K,disabled:!I,children:s("onboarding.remoteConnection.actions.connectAndRestart")})]}),l&&t.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:s("onboarding.remoteConnection.actions.whatToDo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(U,{variant:"outline",size:"sm",onClick:r,className:"flex-1",children:s("onboarding.remoteConnection.actions.chooseDifferentServer")}),!o&&i&&t.jsx(U,{variant:"outline",size:"sm",onClick:i,className:"flex-1",children:s("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const he="curl -fsSL https://opencode.ai/install | bash",fe="https://opencode.ai/docs",se=2500;function be(r){const e=z.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:n,"aria-label":n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}function xe({onCliAvailable:r}){const{t:e}=V(),[c,n]=a.useState(!1),[o,b]=a.useState(!1),[i,s]=a.useState(!1),[h,y]=a.useState(!1),[x,S]=a.useState(""),[N,f]=a.useState("unknown"),[m,v]=a.useState("local"),[R,C]=a.useState(!1),[j,p]=a.useState(!1);a.useEffect(()=>{b(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){f("unknown");return}const l=navigator.userAgent||"";/Windows/i.test(l)?f("windows"):/Macintosh|Mac OS X/i.test(l)?f("macos"):/Linux/i.test(l)?f("linux"):f("unknown")},[]),a.useEffect(()=>{let l=!1;return(async()=>{try{const d=await M("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!d.ok)return;const D=await d.json().catch(()=>null);if(!D||l)return;const P=typeof D.opencodeBinary=="string"?D.opencodeBinary.trim():"";P&&S(P)}catch{}})(),()=>{l=!0}},[]);const w=a.useCallback(async l=>{const d=l.target;d.closest(".app-region-no-drag")||d.closest("button, a, input, select, textarea, code, summary, details")||l.button===0&&o&&await re()},[o]),g=a.useCallback(async()=>{try{const l=await M("/health");if(!l.ok)return!1;const d=await l.json();return d.openCodeRunning===!0||d.isOpenCodeReady===!0}catch{return!1}},[]),k=a.useCallback(async l=>{if(!o)return;const d=await Z();await ee({...d,...l==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[o]),K=a.useCallback(async()=>{o&&await k("local"),r?.()},[o,r,k]);a.useEffect(()=>{if(m!=="local")return;let l=!1,d=null;const D=async()=>{if(!l){try{const P=await g();if(l)return;if(P){await K();return}}catch{}l||(d=setTimeout(D,se))}};return d=setTimeout(D,se),()=>{l=!0,d&&clearTimeout(d)}},[m,g,K]);const L=a.useCallback(async()=>{y(!0);try{await g()&&await K()}finally{y(!1)}},[g,K]),A=a.useCallback(async()=>{if(!(typeof window>"u")&&o)try{const l=await ae();l.success&&l.path&&l.path.trim().length>0&&S(l.path.trim())}catch{}},[o]),I=a.useCallback(async()=>{s(!0);try{if(await le({opencodeBinary:x.trim()}),o){await k("local"),await B();return}await M("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>s(!1),1e3)}},[o,x,k]),F=a.useCallback(async()=>{const l=await ce(he);l.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",l.error)},[]),H=fe,u=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",_=!o||m==="local";return t.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:w,children:t.jsxs("div",{className:"w-full max-w-md space-y-7",children:[t.jsxs("header",{className:"text-center space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:e("onboarding.chooser.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e("onboarding.chooser.description")})]}),o&&t.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[t.jsx("button",{type:"button",className:Q("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("local"),children:e("onboarding.chooser.tabs.localInstall")}),t.jsx("button",{type:"button",className:Q("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("remote"),children:e("onboarding.chooser.tabs.connectRemote")})]}),o&&m==="remote"?t.jsx("div",{className:"app-region-no-drag",children:t.jsx(ie,{onBack:()=>v("local"),showBackButton:!1,onSwitchToLocal:()=>v("local")})}):null,_&&t.jsxs("div",{className:"space-y-4",children:[N==="windows"&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-4",children:[t.jsx("div",{className:"text-sm text-foreground",children:e("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:e("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:e("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:e("onboarding.localSetup.intro")}),t.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:c?t.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),e("onboarding.common.status.copiedToClipboard")]}):t.jsx(be,{onCopy:F,copyTitle:e("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[t.jsxs("a",{href:H,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[e(N==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),t.jsx("button",{type:"button",onClick:L,disabled:h,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:e(h?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),t.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[t.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 shrink-0","aria-hidden":!0,children:[t.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}}),t.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-foreground leading-tight",children:e("onboarding.localSetup.status.watching")}),t.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:e("onboarding.localSetup.status.autoContinue")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:R,onToggle:l=>C(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.advanced.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsxs("div",{className:"pb-4 space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(W,{value:x,onChange:l=>S(l.target.value),placeholder:u,disabled:i,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:i||!o,children:e("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",size:"sm",onClick:I,disabled:i||!x.trim(),children:e("onboarding.localSetup.actions.apply")})]}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:e("onboarding.localSetup.helper.saveAndReload")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:j,onToggle:l=>p(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.troubleshoot.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:N==="windows"?t.jsx(t.Fragment,{children:t.jsx("li",{children:e("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("li",{children:e("onboarding.localSetup.hint.ensurePath")}),t.jsx("li",{children:e("onboarding.localSetup.hint.setEnv")}),t.jsx("li",{children:e("onboarding.localSetup.hint.missingRuntime")})]})})]})]})]})})}const ge="curl -fsSL https://opencode.ai/install | bash",ye="https://opencode.ai/docs";function ve(r){const e=z.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-center gap-3",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}const we=3e4;function je({onBack:r,onCliAvailable:e,isFromRecovery:c=!1,onSwitchToRemote:n}){const{t:o}=V(),[b,i]=a.useState(!1),[s,h]=a.useState(!1),[y,x]=a.useState(!1),[S,N]=a.useState(!1),[f,m]=a.useState(!1),[v,R]=a.useState(null),[C,j]=a.useState(""),[p,w]=a.useState("unknown");a.useEffect(()=>{const u=setTimeout(()=>h(!0),we);return()=>clearTimeout(u)},[]),a.useEffect(()=>{x(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){w("unknown");return}const u=navigator.userAgent||"";if(/Windows/i.test(u)){w("windows");return}if(/Macintosh|Mac OS X/i.test(u)){w("macos");return}if(/Linux/i.test(u)){w("linux");return}w("unknown")},[]),a.useEffect(()=>{let u=!1;return(async()=>{try{const _=await M("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!_.ok)return;const l=await _.json().catch(()=>null);if(!l||u)return;const d=typeof l.opencodeBinary=="string"?l.opencodeBinary.trim():"";d&&j(d)}catch{}})(),()=>{u=!0}},[]);const g=a.useCallback(async u=>{u.target.closest("button, a, input, select, textarea, code")||u.button===0&&y&&await re()},[y]),k=a.useCallback(async()=>{try{const u=await M("/health");if(!u.ok)return!1;const _=await u.json();return _.openCodeRunning===!0||_.isOpenCodeReady===!0}catch{return!1}},[]),K=a.useCallback(async()=>{if(!(typeof window>"u")&&y)try{const u=await ae();u.success&&u.path&&u.path.trim().length>0&&j(u.path.trim())}catch{}},[y]),L=a.useCallback(async()=>{N(!0);try{if(await le({opencodeBinary:C.trim()}),y){await B();return}await M("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>N(!1),1e3)}},[y,C]),A=a.useCallback(async()=>{const u=await ce(ge);u.ok?(i(!0),setTimeout(()=>i(!1),2e3)):console.error("Failed to copy:",u.error)},[]),I=a.useCallback(async()=>{m(!0),R(null);try{await k()?e?.():R(o("onboarding.localSetup.errors.cliNotReady"))}catch(u){R(u instanceof Error?u.message:o("onboarding.localSetup.errors.detectionFailed"))}finally{m(!1)}},[k,e,o]),F=ye,H=p==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":p==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode";return t.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:g,children:[t.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:o("onboarding.localSetup.title")}),t.jsx("p",{className:"text-muted-foreground",children:o("onboarding.localSetup.description")})]}),p==="windows"&&t.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[t.jsx("div",{className:"text-sm text-foreground",children:o("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:o("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:o("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:b?t.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),o("onboarding.common.status.copiedToClipboard")]}):t.jsx(ve,{onCopy:A,copyTitle:o("onboarding.common.copyToClipboard")})})}),t.jsxs("a",{href: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:[o(p==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),v&&t.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:v}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(U,{type:"button",onClick:I,disabled:f,className:"w-full max-w-xs",size:"lg",children:o(f?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:o("onboarding.localSetup.helper.checkAndContinue")})]}),t.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:o("onboarding.localSetup.field.alreadyInstalled")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(W,{value:C,onChange:u=>j(u.target.value),placeholder:H,disabled:S,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",onClick:K,disabled:S||!y,children:o("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",onClick:L,disabled:S,children:o("onboarding.localSetup.actions.apply")})]}),t.jsx("div",{className:"text-xs text-muted-foreground/70",children:o("onboarding.localSetup.helper.saveAndReload")})]})}),c&&n&&t.jsxs("div",{className:"text-center pt-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:o("onboarding.localSetup.remotePreference")}),t.jsx(U,{variant:"link",onClick:n,children:o("onboarding.localSetup.actions.connectRemoteServer")})]})]}),s&&t.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:p==="windows"?t.jsx(t.Fragment,{children:t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.ensurePath")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.setEnv")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.missingRuntime")})]})})]})}function X(r,e){if(r?.trim())return J(r.trim());if(e)return J(e)}function ke(r,e,c){switch(r){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const n=X(e,c);return{title:"Remote Server Unreachable",description:`Could not connect to "${n||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-wrong-service":{const n=X(e,c);return{title:"Incompatible Server",description:`The server at "${n||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-incompatible":{const n=X(e,c);return{title:"Server Update Required",description:`The OpenChamber server at "${n||"unknown"}" is not compatible with this app version. Update OpenChamber on the server, then try again.`,titleKey:"onboarding.desktopRecovery.remoteIncompatible.title",descriptionKey:"onboarding.desktopRecovery.remoteIncompatible.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"missing-default-host":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};default:{const n=r;throw new Error(`Unknown recovery variant: ${n}`)}}}function Ce(r){switch(r){case"local":return t.jsx(T,{name:"macbook",className:"h-8 w-8"});case"remote":return t.jsx(T,{name:"server",className:"h-8 w-8"})}}function Ne({variant:r,hostLabel:e,hostUrl:c,onRetry:n,onUseLocal:o,onUseRemote:b,isRetrying:i=!1}){const{t:s}=V(),h=ke(r,e,c),y=h.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",x=a.useMemo(()=>{if(h.descriptionParams?.host)return h.descriptionParams;if(r==="remote-unreachable")return{host:s("onboarding.desktopRecovery.placeholders.remoteServer")};if(r==="remote-wrong-service"||r==="remote-incompatible")return{host:s("onboarding.desktopRecovery.placeholders.unknownServer")}},[h.descriptionParams,s,r]);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[t.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:t.jsx("div",{style:{color:"var(--status-warning)"},children:Ce(h.iconKey)})}),t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(h.titleKey)}),t.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:s(h.descriptionKey,x)})]}),c&&(r==="remote-unreachable"||r==="remote-wrong-service"||r==="remote-incompatible")&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:J(c)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[h.showRetry&&n&&t.jsxs(U,{onClick:n,disabled:i,className:"w-full",children:[t.jsx(T,{name:"refresh",className:Q("h-4 w-4",i&&"animate-spin")}),s(i?"onboarding.desktopRecovery.actions.retrying":y)]}),t.jsxs("div",{className:"flex gap-2",children:[h.showUseLocal&&o&&t.jsxs(U,{variant:"outline",onClick:o,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"macbook",className:"h-4 w-4"}),s(h.useLocalLabelKey)]}),h.showUseRemote&&b&&t.jsxs(U,{variant:"outline",onClick:b,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"server",className:"h-4 w-4"}),s(h.useRemoteLabelKey)]})]})]})]})})}function ne(r,e){if(e==="use-remote")return{kind:"remote-form"};switch(r){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const c=r;throw new Error(`Unhandled RecoveryVariant: ${c}`)}}}function Re(r){const e=z.c(27),{variant:c,hostUrl:n,hostLabel:o,onRetry:b,onChooseRemote:i,showRemoteForm:s,onCloseRemoteForm:h,onSwitchToLocalFromRemote:y,onEnterLocalSetup:x,isRetrying:S}=r,N=s===void 0?!1:s,f=S===void 0?!1:S,m=Se;let v;e[0]!==b?(v=async()=>{if(O()){await B();return}await M("/api/config/reload",{method:"POST"}),b?.()},e[0]=b,e[1]=v):v=e[1];const R=v;let C;e[2]!==x||e[3]!==c?(C=async()=>{if(ne(c,"use-local").kind==="local-setup"){x?.();return}if(await m("local"),O()){await B();return}window.location.reload()},e[2]=x,e[3]=c,e[4]=C):C=e[4];const j=C;let p;e[5]!==i||e[6]!==c?(p=()=>{ne(c,"use-remote").kind==="remote-form"&&i?.()},e[5]=i,e[6]=c,e[7]=p):p=e[7];const w=p;if(N){const k=c==="remote-wrong-service"?"":n||"",K=c==="remote-wrong-service"?"":o||"";let L;e[8]!==i||e[9]!==h?(L=h||(()=>i?.()),e[8]=i,e[9]=h,e[10]=L):L=e[10];let A;e[11]!==x||e[12]!==y?(A=y||(()=>{m("local").then(()=>{O()?B():x?.()})}),e[11]=x,e[12]=y,e[13]=A):A=e[13];let I;return e[14]!==K||e[15]!==k||e[16]!==L||e[17]!==A?(I=t.jsx(ie,{onBack:L,initialUrl:k,initialLabel:K,isRecoveryMode:!0,onSwitchToLocal:A}),e[14]=K,e[15]=k,e[16]=L,e[17]=A,e[18]=I):I=e[18],I}let g;return e[19]!==R||e[20]!==j||e[21]!==w||e[22]!==o||e[23]!==n||e[24]!==f||e[25]!==c?(g=t.jsx(Ne,{variant:c,hostLabel:o,hostUrl:n,onRetry:R,onUseLocal:j,onUseRemote:w,isRetrying:f}),e[19]=R,e[20]=j,e[21]=w,e[22]=o,e[23]=n,e[24]=f,e[25]=c,e[26]=g):g=e[26],g}async function Se(r){if(!O())return;const e=await Z();await ee({...e,...r==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function Ke(r){const e=z.c(26),{onBack:c,onCliAvailable:n,mode:o,recoveryVariant:b,recoveryHostUrl:i,recoveryHostLabel:s,onEnterLocalSetup:h}=r,y=o===void 0?"first-launch":o,x=b===void 0?"missing-default-host":b,[S,N]=a.useState(!1),[f,m]=a.useState(!1);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{m(!1),N(!1)},e[0]=v):v=e[0];let R;e[1]!==y||e[2]!==s||e[3]!==i||e[4]!==x?(R=[y,x,i,s],e[1]=y,e[2]=s,e[3]=i,e[4]=x,e[5]=R):R=e[5],a.useEffect(v,R);const C=f?"local-setup":y;if(C==="recovery"){let p,w;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>N(!1),w=()=>{N(!1),m(!0)},e[6]=p,e[7]=w):(p=e[6],w=e[7]);let g;e[8]!==h?(g=()=>{m(!0),h?.()},e[8]=h,e[9]=g):g=e[9];let k;return e[10]!==s||e[11]!==i||e[12]!==x||e[13]!==S||e[14]!==g?(k=t.jsx(Re,{variant:x,hostUrl:i,hostLabel:s,showRemoteForm:S,onCloseRemoteForm:p,onSwitchToLocalFromRemote:w,onEnterLocalSetup:g}),e[10]=s,e[11]=i,e[12]=x,e[13]=S,e[14]=g,e[15]=k):k=e[15],k}if(C==="local-setup"){let p;e[16]!==c||e[17]!==f?(p=()=>{f?m(!1):c?.()},e[16]=c,e[17]=f,e[18]=p):p=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=()=>N(!0),e[19]=w):w=e[19];let g;return e[20]!==n||e[21]!==f||e[22]!==p?(g=t.jsx(je,{onBack:p,onCliAvailable:n,isFromRecovery:f,onSwitchToRemote:w}),e[20]=n,e[21]=f,e[22]=p,e[23]=g):g=e[23],g}let j;return e[24]!==n?(j=t.jsx(xe,{onCliAvailable:n}),e[24]=n,e[25]=j):j=e[25],j}export{Ke as OnboardingScreen};
1
+ import{r as E,j as t,R as a,b as z}from"./vendor-.bun-BE757pvp.js";import{ag as me,ak as oe,F as Z,af as ee,v as O,aa as B,h as M,L as re,O as ae,t as le,I as J}from"./index-BklNmnVr.js";import{c as V,B as U,w as W,y as ce,v as Q,I as T}from"./useAppFontEffects-9LFMCKYW.js";function pe(r){switch(r){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function q(r){return r==="wrong-service"||r==="unreachable"||r==="incompatible"}function ie({onBack:r,showBackButton:e=!0,initialUrl:c="",initialLabel:n="",isRecoveryMode:o=!1,onConnect:b,onSwitchToLocal:i}){const{t:s}=V(),[h,y]=E.useState(c),[x,S]=E.useState(n),[N,f]=E.useState("idle"),[m,v]=E.useState(null),[R,C]=E.useState(""),j=me(h),p=j?.persistedUrl??null,w=E.useCallback(d=>{y(d.target.value),f("idle"),v(null),C("")},[]),g=E.useCallback(d=>{S(d.target.value)},[]),k=E.useCallback(async()=>{if(p){f("testing"),v(null),C("");try{const d=await oe(p);v(d),f(d.status==="ok"||d.status==="update-recommended"?"success":"error")}catch(d){C(d instanceof Error?d.message:s("onboarding.remoteConnection.errors.connectionTestFailed")),f("error")}}},[p,s]),K=E.useCallback(async()=>{if(!j)return;const d=j.persistedUrl;f("testing"),v(null),C("");try{const D=await oe(d);if(v(D),q(D.status)){f("error");return}const P=await Z(),de=x.trim()||d,G=P.hosts.find($=>$.url===d),Y=G?G.id:`host-${Date.now().toString(16)}`,te={id:Y,label:de,url:d,apiUrl:d},ue=G?P.hosts.map($=>$.id===Y?te:$):[...P.hosts,te];if(await ee({hosts:ue,defaultHostId:Y,initialHostChoiceCompleted:!0}),b?.(),j.redeemUrl){window.location.assign(j.redeemUrl);return}O()&&await B()}catch(D){C(D instanceof Error?D.message:s("onboarding.remoteConnection.errors.failedToSaveConnection")),f("error")}},[j,x,b,s]),L=N==="testing",A=p!==null&&!L,I=p!==null&&!L&&!q(m?.status??null),F=pe(m?.status??null),H=m?.status==="ok",u=m?.status==="update-recommended",_=m?.status==="auth",l=q(m?.status??null);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e&&t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:s("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(o?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s("onboarding.remoteConnection.description")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx(W,{id:"remote-url",type:"url",value:h,onChange:w,placeholder:s("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:L})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.nameOptional")}),t.jsx(W,{id:"remote-label",type:"text",value:x,onChange:g,placeholder:s("onboarding.remoteConnection.field.namePlaceholder"),disabled:L})]})]}),m&&H&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:s("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&_&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:s("onboarding.remoteConnection.status.authWarning")}),m&&u&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:F?s(F):null}),m&&l&&t.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold mb-1",children:s("onboarding.remoteConnection.status.connectionFailed")}),t.jsx("div",{className:"opacity-90",children:F?s(F):null})]}),t.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?s("onboarding.remoteConnection.status.suggestionsUnreachable"):s("onboarding.remoteConnection.status.suggestionsWrongService")})]}),R&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:R}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(U,{variant:"outline",onClick:k,disabled:!A,children:s(L?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),t.jsx(U,{onClick:K,disabled:!I,children:s("onboarding.remoteConnection.actions.connectAndRestart")})]}),l&&t.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:s("onboarding.remoteConnection.actions.whatToDo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(U,{variant:"outline",size:"sm",onClick:r,className:"flex-1",children:s("onboarding.remoteConnection.actions.chooseDifferentServer")}),!o&&i&&t.jsx(U,{variant:"outline",size:"sm",onClick:i,className:"flex-1",children:s("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const he="curl -fsSL https://opencode.ai/install | bash",fe="https://opencode.ai/docs",se=2500;function be(r){const e=z.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:n,"aria-label":n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}function xe({onCliAvailable:r}){const{t:e}=V(),[c,n]=a.useState(!1),[o,b]=a.useState(!1),[i,s]=a.useState(!1),[h,y]=a.useState(!1),[x,S]=a.useState(""),[N,f]=a.useState("unknown"),[m,v]=a.useState("local"),[R,C]=a.useState(!1),[j,p]=a.useState(!1);a.useEffect(()=>{b(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){f("unknown");return}const l=navigator.userAgent||"";/Windows/i.test(l)?f("windows"):/Macintosh|Mac OS X/i.test(l)?f("macos"):/Linux/i.test(l)?f("linux"):f("unknown")},[]),a.useEffect(()=>{let l=!1;return(async()=>{try{const d=await M("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!d.ok)return;const D=await d.json().catch(()=>null);if(!D||l)return;const P=typeof D.opencodeBinary=="string"?D.opencodeBinary.trim():"";P&&S(P)}catch{}})(),()=>{l=!0}},[]);const w=a.useCallback(async l=>{const d=l.target;d.closest(".app-region-no-drag")||d.closest("button, a, input, select, textarea, code, summary, details")||l.button===0&&o&&await re()},[o]),g=a.useCallback(async()=>{try{const l=await M("/health");if(!l.ok)return!1;const d=await l.json();return d.openCodeRunning===!0||d.isOpenCodeReady===!0}catch{return!1}},[]),k=a.useCallback(async l=>{if(!o)return;const d=await Z();await ee({...d,...l==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[o]),K=a.useCallback(async()=>{o&&await k("local"),r?.()},[o,r,k]);a.useEffect(()=>{if(m!=="local")return;let l=!1,d=null;const D=async()=>{if(!l){try{const P=await g();if(l)return;if(P){await K();return}}catch{}l||(d=setTimeout(D,se))}};return d=setTimeout(D,se),()=>{l=!0,d&&clearTimeout(d)}},[m,g,K]);const L=a.useCallback(async()=>{y(!0);try{await g()&&await K()}finally{y(!1)}},[g,K]),A=a.useCallback(async()=>{if(!(typeof window>"u")&&o)try{const l=await ae();l.success&&l.path&&l.path.trim().length>0&&S(l.path.trim())}catch{}},[o]),I=a.useCallback(async()=>{s(!0);try{if(await le({opencodeBinary:x.trim()}),o){await k("local"),await B();return}await M("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>s(!1),1e3)}},[o,x,k]),F=a.useCallback(async()=>{const l=await ce(he);l.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",l.error)},[]),H=fe,u=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",_=!o||m==="local";return t.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:w,children:t.jsxs("div",{className:"w-full max-w-md space-y-7",children:[t.jsxs("header",{className:"text-center space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:e("onboarding.chooser.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e("onboarding.chooser.description")})]}),o&&t.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[t.jsx("button",{type:"button",className:Q("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("local"),children:e("onboarding.chooser.tabs.localInstall")}),t.jsx("button",{type:"button",className:Q("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("remote"),children:e("onboarding.chooser.tabs.connectRemote")})]}),o&&m==="remote"?t.jsx("div",{className:"app-region-no-drag",children:t.jsx(ie,{onBack:()=>v("local"),showBackButton:!1,onSwitchToLocal:()=>v("local")})}):null,_&&t.jsxs("div",{className:"space-y-4",children:[N==="windows"&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-4",children:[t.jsx("div",{className:"text-sm text-foreground",children:e("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:e("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:e("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:e("onboarding.localSetup.intro")}),t.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:c?t.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),e("onboarding.common.status.copiedToClipboard")]}):t.jsx(be,{onCopy:F,copyTitle:e("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[t.jsxs("a",{href:H,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[e(N==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),t.jsx("button",{type:"button",onClick:L,disabled:h,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:e(h?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),t.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[t.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 shrink-0","aria-hidden":!0,children:[t.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}}),t.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-foreground leading-tight",children:e("onboarding.localSetup.status.watching")}),t.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:e("onboarding.localSetup.status.autoContinue")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:R,onToggle:l=>C(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.advanced.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsxs("div",{className:"pb-4 space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(W,{value:x,onChange:l=>S(l.target.value),placeholder:u,disabled:i,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:i||!o,children:e("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",size:"sm",onClick:I,disabled:i||!x.trim(),children:e("onboarding.localSetup.actions.apply")})]}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:e("onboarding.localSetup.helper.saveAndReload")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:j,onToggle:l=>p(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.troubleshoot.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:N==="windows"?t.jsx(t.Fragment,{children:t.jsx("li",{children:e("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("li",{children:e("onboarding.localSetup.hint.ensurePath")}),t.jsx("li",{children:e("onboarding.localSetup.hint.setEnv")}),t.jsx("li",{children:e("onboarding.localSetup.hint.missingRuntime")})]})})]})]})]})})}const ge="curl -fsSL https://opencode.ai/install | bash",ye="https://opencode.ai/docs";function ve(r){const e=z.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-center gap-3",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}const we=3e4;function je({onBack:r,onCliAvailable:e,isFromRecovery:c=!1,onSwitchToRemote:n}){const{t:o}=V(),[b,i]=a.useState(!1),[s,h]=a.useState(!1),[y,x]=a.useState(!1),[S,N]=a.useState(!1),[f,m]=a.useState(!1),[v,R]=a.useState(null),[C,j]=a.useState(""),[p,w]=a.useState("unknown");a.useEffect(()=>{const u=setTimeout(()=>h(!0),we);return()=>clearTimeout(u)},[]),a.useEffect(()=>{x(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){w("unknown");return}const u=navigator.userAgent||"";if(/Windows/i.test(u)){w("windows");return}if(/Macintosh|Mac OS X/i.test(u)){w("macos");return}if(/Linux/i.test(u)){w("linux");return}w("unknown")},[]),a.useEffect(()=>{let u=!1;return(async()=>{try{const _=await M("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!_.ok)return;const l=await _.json().catch(()=>null);if(!l||u)return;const d=typeof l.opencodeBinary=="string"?l.opencodeBinary.trim():"";d&&j(d)}catch{}})(),()=>{u=!0}},[]);const g=a.useCallback(async u=>{u.target.closest("button, a, input, select, textarea, code")||u.button===0&&y&&await re()},[y]),k=a.useCallback(async()=>{try{const u=await M("/health");if(!u.ok)return!1;const _=await u.json();return _.openCodeRunning===!0||_.isOpenCodeReady===!0}catch{return!1}},[]),K=a.useCallback(async()=>{if(!(typeof window>"u")&&y)try{const u=await ae();u.success&&u.path&&u.path.trim().length>0&&j(u.path.trim())}catch{}},[y]),L=a.useCallback(async()=>{N(!0);try{if(await le({opencodeBinary:C.trim()}),y){await B();return}await M("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>N(!1),1e3)}},[y,C]),A=a.useCallback(async()=>{const u=await ce(ge);u.ok?(i(!0),setTimeout(()=>i(!1),2e3)):console.error("Failed to copy:",u.error)},[]),I=a.useCallback(async()=>{m(!0),R(null);try{await k()?e?.():R(o("onboarding.localSetup.errors.cliNotReady"))}catch(u){R(u instanceof Error?u.message:o("onboarding.localSetup.errors.detectionFailed"))}finally{m(!1)}},[k,e,o]),F=ye,H=p==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":p==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode";return t.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:g,children:[t.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:o("onboarding.localSetup.title")}),t.jsx("p",{className:"text-muted-foreground",children:o("onboarding.localSetup.description")})]}),p==="windows"&&t.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[t.jsx("div",{className:"text-sm text-foreground",children:o("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:o("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:o("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:b?t.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),o("onboarding.common.status.copiedToClipboard")]}):t.jsx(ve,{onCopy:A,copyTitle:o("onboarding.common.copyToClipboard")})})}),t.jsxs("a",{href: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:[o(p==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),v&&t.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:v}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(U,{type:"button",onClick:I,disabled:f,className:"w-full max-w-xs",size:"lg",children:o(f?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:o("onboarding.localSetup.helper.checkAndContinue")})]}),t.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:o("onboarding.localSetup.field.alreadyInstalled")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(W,{value:C,onChange:u=>j(u.target.value),placeholder:H,disabled:S,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",onClick:K,disabled:S||!y,children:o("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",onClick:L,disabled:S,children:o("onboarding.localSetup.actions.apply")})]}),t.jsx("div",{className:"text-xs text-muted-foreground/70",children:o("onboarding.localSetup.helper.saveAndReload")})]})}),c&&n&&t.jsxs("div",{className:"text-center pt-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:o("onboarding.localSetup.remotePreference")}),t.jsx(U,{variant:"link",onClick:n,children:o("onboarding.localSetup.actions.connectRemoteServer")})]})]}),s&&t.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:p==="windows"?t.jsx(t.Fragment,{children:t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.ensurePath")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.setEnv")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.missingRuntime")})]})})]})}function X(r,e){if(r?.trim())return J(r.trim());if(e)return J(e)}function ke(r,e,c){switch(r){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const n=X(e,c);return{title:"Remote Server Unreachable",description:`Could not connect to "${n||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-wrong-service":{const n=X(e,c);return{title:"Incompatible Server",description:`The server at "${n||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-incompatible":{const n=X(e,c);return{title:"Server Update Required",description:`The OpenChamber server at "${n||"unknown"}" is not compatible with this app version. Update OpenChamber on the server, then try again.`,titleKey:"onboarding.desktopRecovery.remoteIncompatible.title",descriptionKey:"onboarding.desktopRecovery.remoteIncompatible.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"missing-default-host":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};default:{const n=r;throw new Error(`Unknown recovery variant: ${n}`)}}}function Ce(r){switch(r){case"local":return t.jsx(T,{name:"macbook",className:"h-8 w-8"});case"remote":return t.jsx(T,{name:"server",className:"h-8 w-8"})}}function Ne({variant:r,hostLabel:e,hostUrl:c,onRetry:n,onUseLocal:o,onUseRemote:b,isRetrying:i=!1}){const{t:s}=V(),h=ke(r,e,c),y=h.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",x=a.useMemo(()=>{if(h.descriptionParams?.host)return h.descriptionParams;if(r==="remote-unreachable")return{host:s("onboarding.desktopRecovery.placeholders.remoteServer")};if(r==="remote-wrong-service"||r==="remote-incompatible")return{host:s("onboarding.desktopRecovery.placeholders.unknownServer")}},[h.descriptionParams,s,r]);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[t.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:t.jsx("div",{style:{color:"var(--status-warning)"},children:Ce(h.iconKey)})}),t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(h.titleKey)}),t.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:s(h.descriptionKey,x)})]}),c&&(r==="remote-unreachable"||r==="remote-wrong-service"||r==="remote-incompatible")&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:J(c)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[h.showRetry&&n&&t.jsxs(U,{onClick:n,disabled:i,className:"w-full",children:[t.jsx(T,{name:"refresh",className:Q("h-4 w-4",i&&"animate-spin")}),s(i?"onboarding.desktopRecovery.actions.retrying":y)]}),t.jsxs("div",{className:"flex gap-2",children:[h.showUseLocal&&o&&t.jsxs(U,{variant:"outline",onClick:o,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"macbook",className:"h-4 w-4"}),s(h.useLocalLabelKey)]}),h.showUseRemote&&b&&t.jsxs(U,{variant:"outline",onClick:b,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"server",className:"h-4 w-4"}),s(h.useRemoteLabelKey)]})]})]})]})})}function ne(r,e){if(e==="use-remote")return{kind:"remote-form"};switch(r){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const c=r;throw new Error(`Unhandled RecoveryVariant: ${c}`)}}}function Re(r){const e=z.c(27),{variant:c,hostUrl:n,hostLabel:o,onRetry:b,onChooseRemote:i,showRemoteForm:s,onCloseRemoteForm:h,onSwitchToLocalFromRemote:y,onEnterLocalSetup:x,isRetrying:S}=r,N=s===void 0?!1:s,f=S===void 0?!1:S,m=Se;let v;e[0]!==b?(v=async()=>{if(O()){await B();return}await M("/api/config/reload",{method:"POST"}),b?.()},e[0]=b,e[1]=v):v=e[1];const R=v;let C;e[2]!==x||e[3]!==c?(C=async()=>{if(ne(c,"use-local").kind==="local-setup"){x?.();return}if(await m("local"),O()){await B();return}window.location.reload()},e[2]=x,e[3]=c,e[4]=C):C=e[4];const j=C;let p;e[5]!==i||e[6]!==c?(p=()=>{ne(c,"use-remote").kind==="remote-form"&&i?.()},e[5]=i,e[6]=c,e[7]=p):p=e[7];const w=p;if(N){const k=c==="remote-wrong-service"?"":n||"",K=c==="remote-wrong-service"?"":o||"";let L;e[8]!==i||e[9]!==h?(L=h||(()=>i?.()),e[8]=i,e[9]=h,e[10]=L):L=e[10];let A;e[11]!==x||e[12]!==y?(A=y||(()=>{m("local").then(()=>{O()?B():x?.()})}),e[11]=x,e[12]=y,e[13]=A):A=e[13];let I;return e[14]!==K||e[15]!==k||e[16]!==L||e[17]!==A?(I=t.jsx(ie,{onBack:L,initialUrl:k,initialLabel:K,isRecoveryMode:!0,onSwitchToLocal:A}),e[14]=K,e[15]=k,e[16]=L,e[17]=A,e[18]=I):I=e[18],I}let g;return e[19]!==R||e[20]!==j||e[21]!==w||e[22]!==o||e[23]!==n||e[24]!==f||e[25]!==c?(g=t.jsx(Ne,{variant:c,hostLabel:o,hostUrl:n,onRetry:R,onUseLocal:j,onUseRemote:w,isRetrying:f}),e[19]=R,e[20]=j,e[21]=w,e[22]=o,e[23]=n,e[24]=f,e[25]=c,e[26]=g):g=e[26],g}async function Se(r){if(!O())return;const e=await Z();await ee({...e,...r==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function Ke(r){const e=z.c(26),{onBack:c,onCliAvailable:n,mode:o,recoveryVariant:b,recoveryHostUrl:i,recoveryHostLabel:s,onEnterLocalSetup:h}=r,y=o===void 0?"first-launch":o,x=b===void 0?"missing-default-host":b,[S,N]=a.useState(!1),[f,m]=a.useState(!1);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{m(!1),N(!1)},e[0]=v):v=e[0];let R;e[1]!==y||e[2]!==s||e[3]!==i||e[4]!==x?(R=[y,x,i,s],e[1]=y,e[2]=s,e[3]=i,e[4]=x,e[5]=R):R=e[5],a.useEffect(v,R);const C=f?"local-setup":y;if(C==="recovery"){let p,w;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>N(!1),w=()=>{N(!1),m(!0)},e[6]=p,e[7]=w):(p=e[6],w=e[7]);let g;e[8]!==h?(g=()=>{m(!0),h?.()},e[8]=h,e[9]=g):g=e[9];let k;return e[10]!==s||e[11]!==i||e[12]!==x||e[13]!==S||e[14]!==g?(k=t.jsx(Re,{variant:x,hostUrl:i,hostLabel:s,showRemoteForm:S,onCloseRemoteForm:p,onSwitchToLocalFromRemote:w,onEnterLocalSetup:g}),e[10]=s,e[11]=i,e[12]=x,e[13]=S,e[14]=g,e[15]=k):k=e[15],k}if(C==="local-setup"){let p;e[16]!==c||e[17]!==f?(p=()=>{f?m(!1):c?.()},e[16]=c,e[17]=f,e[18]=p):p=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=()=>N(!0),e[19]=w):w=e[19];let g;return e[20]!==n||e[21]!==f||e[22]!==p?(g=t.jsx(je,{onBack:p,onCliAvailable:n,isFromRecovery:f,onSwitchToRemote:w}),e[20]=n,e[21]=f,e[22]=p,e[23]=g):g=e[23],g}let j;return e[24]!==n?(j=t.jsx(xe,{onCliAvailable:n}),e[24]=n,e[25]=j):j=e[25],j}export{Ke as OnboardingScreen};
@@ -0,0 +1 @@
1
+ import{b as ne,R as je,j as r,r as Oe,a as Ue,af as ze}from"./vendor-.bun-BE757pvp.js";import{u as ye,aw as We,aH as Be,J as Se,a as Ge}from"./index-BklNmnVr.js";import{c as _e,v as q,aL as Ye,am as Ke,an as Je,I as V,M as He,aK as Re,aJ as Qe,c1 as Xe,c2 as qe,bk as Ve,cK as Ne,u as Ze,b as et,cz as tt,r as ke,aD as st,aF as nt,aG as rt,G as Pe,cY as ot,d1 as it}from"./useAppFontEffects-9LFMCKYW.js";function Kt(){const s=ne.c(5),e=ye(at);let t;s[0]===Symbol.for("react.memo_cache_sentinel")?(t=We(),s[0]=t):t=s[0];const i=t;let o;s[1]!==e?(o=Be(e),s[1]=e,s[2]=o):o=s[2];const a=o;let n;return s[3]!==a?(n={usesFramelessChrome:i,side:a},s[3]=a,s[4]=n):n=s[4],n}function at(s){return s.desktopWindowControlsPosition}const Jt=s=>{const e=ne.c(129),{totalTokens:t,percentage:i,colorPercentage:o,contextLimit:a,outputLimit:n,size:l,isMobile:b,hideIcon:m,showPercentIcon:c,className:g,valueClassName:w,percentIconClassName:x,onClick:f,pressed:v}=s,S=l===void 0?"default":l,p=b===void 0?!1:b,j=m===void 0?!1:m,N=c===void 0?!1:c,k=v===void 0?!1:v,{t:d}=_e(),[_,y]=je.useState(!1),u=typeof o=="number"?o:i;let h,C,D,P,M,T,L,E;if(e[0]!==u||e[1]!==a||e[2]!==j||e[3]!==p||e[4]!==f||e[5]!==n||e[6]!==x||e[7]!==i||e[8]!==N||e[9]!==d||e[10]!==t||e[11]!==w){const z=Ke(i)??0,$=Je(u),F=$==="critical"?"var(--status-error)":$==="warn"?"var(--status-warning)":"var(--status-success)";h=lt,C=ct;const A=2*Math.PI*8.5,I=A*(1-z/100);P=typeof n=="number"?Math.max(n,0):0;let W;e[20]!==d||e[21]!==t?(W=d("contextUsage.tooltip.usedTokens",{tokens:h(t)}),e[20]=d,e[21]=t,e[22]=W):W=e[22];let B;e[23]!==a||e[24]!==d?(B=d("contextUsage.tooltip.contextLimit",{tokens:h(a)}),e[23]=a,e[24]=d,e[25]=B):B=e[25];let G;e[26]!==P||e[27]!==d?(G=d("contextUsage.tooltip.outputLimit",{tokens:h(P)}),e[26]=P,e[27]=d,e[28]=G):G=e[28];let Q;e[29]!==B||e[30]!==G||e[31]!==W?(Q=[W,B,G],e[29]=B,e[30]=G,e[31]=W,e[32]=Q):Q=e[32],E=Q,D=!p&&typeof f=="function",e[33]!==j||e[34]!==p?(L=!p&&!j&&r.jsx(V,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e[33]=j,e[34]=p,e[35]=L):L=e[35],e[36]!==w?(M=q("font-medium inline-flex items-center gap-1.5",w),e[36]=w,e[37]=M):M=e[37],T=N?r.jsxs(r.Fragment,{children:[r.jsxs("svg",{viewBox:"0 0 20 20",className:q("h-3.5 w-3.5 -rotate-90",x),role:"progressbar","aria-valuenow":Math.round(z),"aria-valuemin":0,"aria-valuemax":100,children:[r.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),r.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:F,strokeWidth:3,strokeLinecap:"round",strokeDasharray:A,strokeDashoffset:I,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),r.jsxs("span",{className:"text-foreground",children:[Math.min(i,999).toFixed(1),"%"]})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:C(u),children:Math.min(i,999).toFixed(1)}),"%"]}),e[0]=u,e[1]=a,e[2]=j,e[3]=p,e[4]=f,e[5]=n,e[6]=x,e[7]=i,e[8]=N,e[9]=d,e[10]=t,e[11]=w,e[12]=h,e[13]=C,e[14]=D,e[15]=P,e[16]=M,e[17]=T,e[18]=L,e[19]=E}else h=e[12],C=e[13],D=e[14],P=e[15],M=e[16],T=e[17],L=e[18],E=e[19];let Y;e[38]!==M||e[39]!==T?(Y=r.jsx("span",{className:M,children:T}),e[38]=M,e[39]=T,e[40]=Y):Y=e[40];let Z;e[41]!==L||e[42]!==Y?(Z=r.jsxs(r.Fragment,{children:[L,Y]}),e[41]=L,e[42]=Y,e[43]=Z):Z=e[43];const K=Z,ee=S==="compact"?"typography-micro":"typography-meta";let te;e[44]!==g||e[45]!==D||e[46]!==ee?(te=q("app-region-no-drag flex items-center gap-1.5 select-none",ee,D?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",g),e[44]=g,e[45]=D,e[46]=ee,e[47]=te):te=e[47];const J=te;let H;e[48]!==K||e[49]!==D||e[50]!==p||e[51]!==f||e[52]!==k||e[53]!==J||e[54]!==d?(H=D?r.jsx("button",{type:"button",className:J,"aria-label":d("contextUsage.aria.label"),"aria-pressed":k,onClick:f,children:K}):r.jsx("div",{className:J,"aria-label":d("contextUsage.aria.label"),onClick:p?()=>y(!0):void 0,children:K}),e[48]=K,e[49]=D,e[50]=p,e[51]=f,e[52]=k,e[53]=J,e[54]=d,e[55]=H):H=e[55];const X=H;if(p){let z;e[56]===Symbol.for("react.memo_cache_sentinel")?(z=()=>y(!1),e[56]=z):z=e[56];let $;e[57]!==d?($=d("contextUsage.mobile.title"),e[57]=d,e[58]=$):$=e[58];let F;e[59]!==d?(F=d("contextUsage.mobile.usedTokens"),e[59]=d,e[60]=F):F=e[60];let A;e[61]!==F?(A=r.jsx("span",{className:"typography-meta text-muted-foreground",children:F}),e[61]=F,e[62]=A):A=e[62];let I;e[63]!==h||e[64]!==t?(I=h(t),e[63]=h,e[64]=t,e[65]=I):I=e[65];let W;e[66]!==I?(W=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:I}),e[66]=I,e[67]=W):W=e[67];let B;e[68]!==A||e[69]!==W?(B=r.jsxs("div",{className:"flex justify-between items-center",children:[A,W]}),e[68]=A,e[69]=W,e[70]=B):B=e[70];let G;e[71]!==d?(G=d("contextUsage.mobile.contextLimit"),e[71]=d,e[72]=G):G=e[72];let Q;e[73]!==G?(Q=r.jsx("span",{className:"typography-meta text-muted-foreground",children:G}),e[73]=G,e[74]=Q):Q=e[74];let re;e[75]!==a||e[76]!==h?(re=h(a),e[75]=a,e[76]=h,e[77]=re):re=e[77];let oe;e[78]!==re?(oe=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:re}),e[78]=re,e[79]=oe):oe=e[79];let ie;e[80]!==Q||e[81]!==oe?(ie=r.jsxs("div",{className:"flex justify-between items-center",children:[Q,oe]}),e[80]=Q,e[81]=oe,e[82]=ie):ie=e[82];let ae;e[83]!==d?(ae=d("contextUsage.mobile.outputLimit"),e[83]=d,e[84]=ae):ae=e[84];let le;e[85]!==ae?(le=r.jsx("span",{className:"typography-meta text-muted-foreground",children:ae}),e[85]=ae,e[86]=le):le=e[86];let ce;e[87]!==h||e[88]!==P?(ce=h(P),e[87]=h,e[88]=P,e[89]=ce):ce=e[89];let de;e[90]!==ce?(de=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:ce}),e[90]=ce,e[91]=de):de=e[91];let ue;e[92]!==le||e[93]!==de?(ue=r.jsxs("div",{className:"flex justify-between items-center",children:[le,de]}),e[92]=le,e[93]=de,e[94]=ue):ue=e[94];let me;e[95]!==d?(me=d("contextUsage.mobile.usage"),e[95]=d,e[96]=me):me=e[96];let fe;e[97]!==me?(fe=r.jsx("span",{className:"typography-meta text-muted-foreground",children:me}),e[97]=me,e[98]=fe):fe=e[98];let pe;e[99]!==u||e[100]!==C?(pe=q("typography-meta font-semibold",C(u)),e[99]=u,e[100]=C,e[101]=pe):pe=e[101];const Ce=Math.min(i,999);let he;e[102]!==Ce?(he=Ce.toFixed(1),e[102]=Ce,e[103]=he):he=e[103];let ge;e[104]!==pe||e[105]!==he?(ge=r.jsxs("span",{className:pe,children:[he,"%"]}),e[104]=pe,e[105]=he,e[106]=ge):ge=e[106];let xe;e[107]!==fe||e[108]!==ge?(xe=r.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[fe,ge]}),e[107]=fe,e[108]=ge,e[109]=xe):xe=e[109];let be;e[110]!==B||e[111]!==ie||e[112]!==ue||e[113]!==xe?(be=r.jsx("div",{className:"flex flex-col gap-1.5",children:r.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[B,ie,ue,xe]})}),e[110]=B,e[111]=ie,e[112]=ue,e[113]=xe,e[114]=be):be=e[114];let we;e[115]!==_||e[116]!==$||e[117]!==be?(we=r.jsx(He,{open:_,onClose:z,title:$,children:be}),e[115]=_,e[116]=$,e[117]=be,e[118]=we):we=e[118];let ve;return e[119]!==X||e[120]!==we?(ve=r.jsxs(r.Fragment,{children:[X,we]}),e[119]=X,e[120]=we,e[121]=ve):ve=e[121],ve}let O;e[122]!==X?(O=r.jsx(Re,{asChild:!0,children:X}),e[122]=X,e[123]=O):O=e[123];let U;e[124]!==E?(U=r.jsx(Ye,{children:r.jsx("div",{className:"space-y-0.5",children:E.map(dt)})}),e[124]=E,e[125]=U):U=e[125];let R;return e[126]!==O||e[127]!==U?(R=r.jsxs(Qe,{children:[O,U]}),e[126]=O,e[127]=U,e[128]=R):R=e[128],R};function lt(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toFixed(1).replace(/\.0$/,"")}function ct(s){return s>=90?"text-status-error":s>=75?"text-status-warning":"text-status-success"}function dt(s){return r.jsx("p",{className:"typography-micro leading-tight",children:s},s)}const Ht=je.memo(function(e){const t=ne.c(41),{visible:i,position:o}=e,a=o===void 0?"right":o,{t:n}=_e(),[l,b]=je.useState(!1);let m,c;if(t[0]!==i?(m=()=>{if(!i)return;let M=!1;Se("desktop_get_current_window_state").then(L=>{M||b(!!L?.maximized)}).catch(ut);const T=L=>{const E=L.detail;b(!!E?.maximized)};return window.addEventListener("openchamber:window-maximized-changed",T),()=>{M=!0,window.removeEventListener("openchamber:window-maximized-changed",T)}},c=[i],t[0]=i,t[1]=m,t[2]=c):(m=t[1],c=t[2]),Oe.useEffect(m,c),!i)return null;const g=a==="left"?"app-region-no-drag -ml-3 mr-2 flex h-12 shrink-0 items-center":"app-region-no-drag -mr-3 ml-2 flex h-12 shrink-0 items-center";let w;t[3]!==n?(w=n("header.windowControls.groupAria"),t[3]=n,t[4]=w):w=t[4];let x;t[5]!==n?(x=n("header.windowControls.minimize"),t[5]=n,t[6]=x):x=t[6];let f;t[7]!==n?(f=n("header.windowControls.minimize"),t[7]=n,t[8]=f):f=t[8];let v;t[9]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(V,{name:"subtract",className:"h-4 w-4"}),t[9]=v):v=t[9];let S;t[10]!==x||t[11]!==f?(S=r.jsx("button",{type:"button",className:"app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:mt,title:x,"aria-label":f,children:v}),t[10]=x,t[11]=f,t[12]=S):S=t[12];let p;t[13]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{Se("desktop_toggle_current_window_maximized").then(M=>b(!!M?.maximized)).catch(ft)},t[13]=p):p=t[13];let j;t[14]!==l||t[15]!==n?(j=n(l?"header.windowControls.restore":"header.windowControls.maximize"),t[14]=l,t[15]=n,t[16]=j):j=t[16];let N;t[17]!==l||t[18]!==n?(N=n(l?"header.windowControls.restore":"header.windowControls.maximize"),t[17]=l,t[18]=n,t[19]=N):N=t[19];const k=l?"fullscreen-exit":"checkbox-blank";let d;t[20]!==k?(d=r.jsx(V,{name:k,className:"h-3.5 w-3.5"}),t[20]=k,t[21]=d):d=t[21];let _;t[22]!==j||t[23]!==N||t[24]!==d?(_=r.jsx("button",{type:"button",className:"app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:p,title:j,"aria-label":N,children:d}),t[22]=j,t[23]=N,t[24]=d,t[25]=_):_=t[25];let y;t[26]===Symbol.for("react.memo_cache_sentinel")?(y=q("app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","hover:bg-status-error hover:text-status-error-foreground"),t[26]=y):y=t[26];let u;t[27]!==n?(u=n("header.windowControls.close"),t[27]=n,t[28]=u):u=t[28];let h;t[29]!==n?(h=n("header.windowControls.close"),t[29]=n,t[30]=h):h=t[30];let C;t[31]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(V,{name:"close",className:"h-4 w-4"}),t[31]=C):C=t[31];let D;t[32]!==u||t[33]!==h?(D=r.jsx("button",{type:"button",className:y,onClick:pt,title:u,"aria-label":h,children:C}),t[32]=u,t[33]=h,t[34]=D):D=t[34];let P;return t[35]!==g||t[36]!==_||t[37]!==D||t[38]!==w||t[39]!==S?(P=r.jsxs("div",{className:g,"aria-label":w,children:[S,_,D]}),t[35]=g,t[36]=_,t[37]=D,t[38]=w,t[39]=S,t[40]=P):P=t[40],P});function ut(){}function mt(){Se("desktop_minimize_current_window")}function ft(){}function pt(){Se("desktop_close_current_window")}const Ae="oc.sessions.pinned",ht=s=>{try{const e=s.getItem(Ae);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(i=>typeof i=="string")):new Set}catch{return new Set}},Me=(s,e)=>{try{s.setItem(Ae,JSON.stringify([...e]))}catch{}},De=Ge(),gt=Ue((s,e)=>({ids:ht(De),setIds:t=>{const i=e().ids,o=typeof t=="function"?t(i):t;o!==i&&(s({ids:o}),Me(De,o))},toggle:t=>{const i=e().ids,o=new Set(i);o.has(t)?o.delete(t):o.add(t),s({ids:o}),Me(De,o)}})),se=(s,e)=>Xe(qe.getState().dictionary,s,e),xt=s=>{const e=new Date(s),t=new Date,i=(n,l)=>n.getFullYear()===l.getFullYear()&&n.getMonth()===l.getMonth()&&n.getDate()===l.getDate(),o=new Date(t);return o.setDate(t.getDate()-1),i(e,t)?se("common.date.today"):i(e,o)?se("common.date.yesterday"):e.toLocaleDateString(Ve(),{month:"short",day:"numeric",year:"numeric"}).replace(",","")},Rt=s=>{const e=new Date,t=new Date(s);if(((o,a)=>o.getFullYear()===a.getFullYear()&&o.getMonth()===a.getMonth()&&o.getDate()===a.getDate())(t,e)){const o=Date.now()-s;return o<6e4?se("common.relative.justNow"):o<36e5?se("common.relative.minutesAgoShort",{count:Math.floor(o/6e4)}):se("common.relative.hoursAgoShort",{count:Math.floor(o/36e5)})}return xt(s)},bt=s=>{const e=Math.max(0,Date.now()-s),t=6e4,i=60*t,o=24*i,a=7*o,n=30*o,l=365*o;return e<i?`${Math.max(1,Math.floor(e/t))}m`:e<o?`${Math.floor(e/i)}h`:e<a?se("common.relative.daysAgoCompact",{count:Math.floor(e/o)}):e<5*a?se("common.relative.weeksAgoCompact",{count:Math.floor(e/a)}):e<l?`${Math.floor(e/n)}mo`:se("common.relative.yearsAgoCompact",{count:Math.floor(e/l)})},wt=(s,e)=>{const t=Ne(s),i=Ne(e);return yt(t,i)},yt=(s,e)=>!s||!e?!1:s===e?!0:e==="/"?s.startsWith("/"):s.startsWith(`${e}/`),Le=s=>s.toLowerCase().replace(/^opencode[/-]?/i,"").replace(/[-_]/g,"").trim(),Qt=(s,e)=>s?Le(s)!==Le(e):!1,Ie=s=>{if(typeof s=="number"&&Number.isFinite(s))return s;if(typeof s=="string"&&s.trim().length>0){const e=Number(s);if(Number.isFinite(e))return e}},$e=s=>Ie(s.time?.created)??0,Fe=s=>Ie(s.time?.updated)??Ie(s.time?.created)??0,Te=(s,e,t)=>{const i=t.has(s.id),o=t.has(e.id);return i!==o?i?-1:1:i&&o?$e(e)-$e(s):Fe(e)-Fe(s)},Xt=s=>{const e=new Map;return s.forEach(t=>{e.set(t.id,t)}),Array.from(e.values())},qt=s=>`__archived__:${s}`,Vt=(s,e)=>{const t=Ne(s.directory??null),i=Ne(s.project?.worktree??null),o=t??i;if(!o)return"unassigned";if(e&&o===e)return"project root";const n=(e&&o.startsWith(`${e}/`)?o.slice(e.length+1):o).split("/").filter(Boolean);return n[n.length-1]??"unassigned"},Zt=s=>s.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),es=(s,e)=>{if(!e)return s;const t=s.toLowerCase(),i=e.toLowerCase(),o=i.length;if(o===0)return s;const a=[];let n=0,l=t.indexOf(i,n);for(;l!==-1;){l>n&&a.push(s.slice(n,l));const b=s.slice(l,l+o);a.push(r.jsx("mark",{className:"bg-primary text-primary-foreground ring-1 ring-primary/90",children:b},`${l}-${b}`)),n=l+o,l=t.indexOf(i,n)}return n<s.length&&a.push(s.slice(n)),a.length>0?a:s},vt=7,jt=s=>{if(!s)return null;const e=s.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},St=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},Nt=(s,e)=>{const t=ne.c(18);let i;t[0]!==e?(i=e===void 0?{}:e,t[0]=e,t[1]=i):i=t[1];const o=i,{scopeProjectId:a}=o,n=a===void 0?null:a,l=Ze(_t),b=et(Ct),m=gt(Dt),c=tt();let g;t[2]!==b?(g=b.map(kt).filter(Pt),t[2]=b,t[3]=g):g=t[3];const w=g;let x;t[4]!==w?(x=p=>p?w.filter(N=>wt(p,N.normalizedPath)).sort(It)[0]??null:null,t[4]=w,t[5]=x):x=t[5];const f=x;let v;{let p;if(t[7]!==l||t[8]!==c||t[9]!==f||t[10]!==m||t[11]!==n){const j=new Map;for(const y of l){const u=y.parentID;if(!u||y.time?.archived)continue;const h=j.get(u);h?h.push(y):j.set(u,[y])}j.forEach(y=>{y.sort((u,h)=>Te(u,h,m))});let N;t[13]!==f||t[14]!==n?(N=y=>{if(!n)return!0;const u=ke(y);return f(u)?.id===n},t[13]=f,t[14]=n,t[15]=N):N=t[15];let k;t[16]!==m?(k=(y,u)=>Te(y,u,m),t[16]=m,t[17]=k):k=t[17];const d=l.filter(Mt).filter(Lt).filter(N).sort(k).slice(0,vt),_=y=>{const u=j.get(y.id)??[];return{session:y,children:u.map(h=>_(h)),worktree:null}};p=d.map(y=>{const u=ke(y),h=f(u),C=St(h),D=u?c.get(u)??null:null;return{node:_(y),projectId:h?.id??null,groupDirectory:u,secondaryMeta:{projectLabel:C,branchLabel:D&&D!==C?D:null}}}),t[7]=l,t[8]=c,t[9]=f,t[10]=m,t[11]=n,t[12]=p}else p=t[12];v=p}return v};function _t(s){return s.activeSessions}function Ct(s){return s.projects}function Dt(s){return s.ids}function kt(s){return{...s,normalizedPath:jt(s.path)}}function Pt(s){return s.normalizedPath}function It(s,e){return(e.normalizedPath?.length??0)-(s.normalizedPath?.length??0)}function Mt(s){return!s.time?.archived}function Lt(s){return!s.parentID}function ts(s){const e=ne.c(18),{children:t,variant:i,scopeProjectId:o,align:a}=s,n=i===void 0?"default":i,l=o===void 0?null:o,b=a===void 0?"start":a,m=ye(Ft),c=ye($t);let g;e[0]!==t?(g=r.jsx(st,{asChild:!0,children:t}),e[0]=t,e[1]=g):g=e[1];const w=n==="compact"?"w-[280px]":"w-[360px]";let x;e[2]!==w?(x=q("overflow-hidden p-1 max-w-[calc(100vw-32px)]",w),e[2]=w,e[3]=x):x=e[3];let f;e[4]!==m||e[5]!==l||e[6]!==c||e[7]!==n?(f=m?r.jsx(Tt,{onSelect:()=>c(!1),variant:n,scopeProjectId:l}):null,e[4]=m,e[5]=l,e[6]=c,e[7]=n,e[8]=f):f=e[8];let v;e[9]!==b||e[10]!==x||e[11]!==f?(v=r.jsx(nt,{align:b,sideOffset:6,className:x,children:f}),e[9]=b,e[10]=x,e[11]=f,e[12]=v):v=e[12];let S;return e[13]!==m||e[14]!==c||e[15]!==g||e[16]!==v?(S=r.jsxs(rt,{open:m,onOpenChange:c,modal:!1,children:[g,v]}),e[13]=m,e[14]=c,e[15]=g,e[16]=v,e[17]=S):S=e[17],S}function $t(s){return s.setSessionDropdownOpen}function Ft(s){return s.isSessionDropdownOpen}function Tt(s){const e=ne.c(26),{onSelect:t,variant:i,scopeProjectId:o}=s;let a;e[0]!==o?(a={scopeProjectId:o},e[0]=o,e[1]=a):a=e[1];const n=Nt(!0,a),l=Pe(At),b=ye(zt),{t:m}=_e();let c;e[2]!==t||e[3]!==l||e[4]!==b?(c=()=>{b("chat"),t(),l()},e[2]=t,e[3]=l,e[4]=b,e[5]=c):c=e[5];const g=c;let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=new Set,e[6]=w):w=e[6];const[x,f]=je.useState(w);let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=u=>{f(h=>{const C=new Set(h);return C.has(u)?C.delete(u):C.add(u),C})},e[7]=v):v=e[7];const S=v;let p,j;e[8]===Symbol.for("react.memo_cache_sentinel")?(p=q("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),j=r.jsx(V,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e[8]=p,e[9]=j):(p=e[8],j=e[9]);let N;e[10]!==m?(N=m("sessions.sidebar.header.actions.newSession"),e[10]=m,e[11]=N):N=e[11];let k;e[12]!==N?(k=r.jsx("span",{className:"truncate text-[14px] font-normal leading-tight text-foreground",children:N}),e[12]=N,e[13]=k):k=e[13];let d;e[14]!==g||e[15]!==k?(d=r.jsxs(ze,{onClick:g,className:p,children:[j,k]}),e[14]=g,e[15]=k,e[16]=d):d=e[16];let _;e[17]!==x||e[18]!==n||e[19]!==t||e[20]!==m||e[21]!==i?(_=n.length===0?r.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:m("sessions.switcher.empty")}):n.map(u=>r.jsx(Ee,{item:u,depth:0,variant:i,expandedParents:x,toggleParent:S,closeDropdown:t},u.node.session.id)),e[17]=x,e[18]=n,e[19]=t,e[20]=m,e[21]=i,e[22]=_):_=e[22];let y;return e[23]!==_||e[24]!==d?(y=r.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:r.jsxs("div",{className:"space-y-0.5",children:[d,_]})}),e[23]=_,e[24]=d,e[25]=y):y=e[25],y}function zt(s){return s.setActiveMainTab}function At(s){return s.openNewSessionDraft}function Ee(s){const e=ne.c(31),{item:t,depth:i,variant:o,expandedParents:a,toggleParent:n,closeDropdown:l}=s,{node:b,secondaryMeta:m}=t,c=b.session,g=b.children.length>0;let w;e[0]!==a||e[1]!==c.id?(w=a.has(c.id),e[0]=a,e[1]=c.id,e[2]=w):w=e[2];const x=w;let f;e[3]!==g||e[4]!==c.id||e[5]!==n?(f=g?()=>n(c.id):void 0,e[3]=g,e[4]=c.id,e[5]=n,e[6]=f):f=e[6];let v;e[7]!==l||e[8]!==i||e[9]!==g||e[10]!==x||e[11]!==m||e[12]!==c||e[13]!==f||e[14]!==o?(v=r.jsx(Et,{session:c,depth:i,variant:o,secondaryMeta:m,hasChildren:g,isExpanded:x,onToggleExpand:f,closeDropdown:l}),e[7]=l,e[8]=i,e[9]=g,e[10]=x,e[11]=m,e[12]=c,e[13]=f,e[14]=o,e[15]=v):v=e[15];let S;e[16]!==l||e[17]!==i||e[18]!==a||e[19]!==g||e[20]!==x||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==b.children||e[24]!==m||e[25]!==n||e[26]!==o?(S=g&&x?b.children.map(j=>r.jsx(Ee,{item:{node:j,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:m},depth:i+1,variant:o,expandedParents:a,toggleParent:n,closeDropdown:l},j.session.id)):null,e[16]=l,e[17]=i,e[18]=a,e[19]=g,e[20]=x,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=b.children,e[24]=m,e[25]=n,e[26]=o,e[27]=S):S=e[27];let p;return e[28]!==v||e[29]!==S?(p=r.jsxs(r.Fragment,{children:[v,S]}),e[28]=v,e[29]=S,e[30]=p):p=e[30],p}function Et(s){const e=ne.c(57),{session:t,depth:i,variant:o,secondaryMeta:a,hasChildren:n,isExpanded:l,onToggleExpand:b,closeDropdown:m}=s,{t:c}=_e(),g=Pe(Wt),w=Pe(Ut),x=ye(Ot),f=ot(t.id),v=it(t.id),S=g===t.id;let p;e[0]!==t.title||e[1]!==c?(p=t.title?.trim()||c("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=c,e[2]=p):p=e[2];const j=p,N=!!t.parentID,k=v>0&&(!N||x),d=f?.type??"idle",_=d==="busy"||d==="retry",y=!_&&k&&!S;let u;e[3]!==t.time?.created||e[4]!==t.time?.updated?(u=t.time?.updated||t.time?.created||Date.now(),e[3]=t.time?.created,e[4]=t.time?.updated,e[5]=u):u=e[5];const h=u;let C;e[6]!==h?(C=bt(h),e[6]=h,e[7]=C):C=e[7];const D=C;let P;e[8]!==a?.projectLabel?(P=a?.projectLabel?.trim()||null,e[8]=a?.projectLabel,e[9]=P):P=e[9];const M=P;let T;e[10]!==a?.branchLabel?(T=a?.branchLabel?.trim()||null,e[10]=a?.branchLabel,e[11]=T):T=e[11];const L=T,E=L&&L!=="HEAD"?L:null;let Y;e[12]!==m||e[13]!==S||e[14]!==t||e[15]!==w?(Y=()=>{if(S){m();return}const I=ke(t);w(t.id,I??null),m()},e[12]=m,e[13]=S,e[14]=t,e[15]=w,e[16]=Y):Y=e[16];const Z=Y;let K;e[17]!==Z?(K=I=>{if(I.target?.closest("[data-switcher-expand]")){I.preventDefault();return}Z()},e[17]=Z,e[18]=K):K=e[18];let ee;e[19]===Symbol.for("react.memo_cache_sentinel")?(ee=q("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),e[19]=ee):ee=e[19];const te=8+i*12;let J;e[20]!==te?(J={paddingLeft:te},e[20]=te,e[21]=J):J=e[21];let H;e[22]!==n||e[23]!==l||e[24]!==b||e[25]!==c||e[26]!==o?(H=o==="compact"&&n?r.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:I=>{I.preventDefault(),I.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":c(l?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:l?r.jsx(V,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):r.jsx(V,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[22]=n,e[23]=l,e[24]=b,e[25]=c,e[26]=o,e[27]=H):H=e[27];const X=S?"text-primary":"text-foreground";let O;e[28]!==X?(O=q("truncate text-[14px] font-normal leading-tight",X),e[28]=X,e[29]=O):O=e[29];let U;e[30]!==j||e[31]!==O?(U=r.jsx("span",{className:O,children:j}),e[30]=j,e[31]=O,e[32]=U):U=e[32];let R;e[33]!==H||e[34]!==U?(R=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[H,U]}),e[33]=H,e[34]=U,e[35]=R):R=e[35];let z;e[36]!==E||e[37]!==n||e[38]!==l||e[39]!==b||e[40]!==M||e[41]!==c||e[42]!==D||e[43]!==o?(z=o==="default"?r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:[n?r.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:I=>{I.preventDefault(),I.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":c(l?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:l?r.jsx(V,{name:"arrow-down-s",className:"h-3 w-3"}):r.jsx(V,{name:"arrow-right-s",className:"h-3 w-3"})}):null,r.jsx("span",{className:"flex-shrink-0",children:D}),M?r.jsx("span",{className:"truncate",children:M}):null,E?r.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[r.jsx(V,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),r.jsx("span",{className:"truncate",children:E})]}):null]}):null,e[36]=E,e[37]=n,e[38]=l,e[39]=b,e[40]=M,e[41]=c,e[42]=D,e[43]=o,e[44]=z):z=e[44];let $;e[45]!==R||e[46]!==z?($=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[R,z]}),e[45]=R,e[46]=z,e[47]=$):$=e[47];let F;e[48]!==_||e[49]!==y||e[50]!==c?(F=_||y?r.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:_?r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":c("sessions.sidebar.session.status.active"),title:c("sessions.sidebar.session.status.active")}):r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":c("sessions.sidebar.session.status.unread"),title:c("sessions.sidebar.session.status.unread")})}):null,e[48]=_,e[49]=y,e[50]=c,e[51]=F):F=e[51];let A;return e[52]!==J||e[53]!==$||e[54]!==F||e[55]!==K?(A=r.jsxs(ze,{onClick:K,"data-slot":"session-switcher-item",className:ee,style:J,children:[$,F]}),e[52]=J,e[53]=$,e[54]=F,e[55]=K,e[56]=A):A=e[56],A}function Ot(s){return s.notifyOnSubtasks}function Ut(s){return s.setCurrentSession}function Wt(s){return s.currentSessionId}export{Jt as C,ts as S,Ht as W,es as a,Rt as b,Te as c,Xt as d,bt as e,Zt as f,qt as g,gt as h,Qt as i,Le as n,Vt as r,Kt as u};